Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not convert to absolute path the files after -include #2449

Merged
merged 1 commit into from
Dec 4, 2019

Conversation

gyorb
Copy link
Contributor

@gyorb gyorb commented Nov 26, 2019

File path after the -include flag should not be converted to absolute path.
Only the flags with include path directories should be converted.
If every other include directory flag is set properly the
file set by -include should be found too.

Resolves #2440

@gyorb gyorb added the analyzer 📈 Related to the analyze commands (analysis driver) label Nov 26, 2019
@@ -671,7 +671,7 @@ def __collect_compile_opts(flag_iterator, details):
# order to print these absolute paths natively, this conversion will
# not be necessary.
flags_with_path = ['-I', '-idirafter', '-imacros', '-imultilib',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-imacros should be removed too.

@Xazax-hun
Copy link
Contributor

Why do we ever convert something to absolute path in the first place? If we always set the working directory properly, relative paths should never be the problem.

@Xazax-hun
Copy link
Contributor

Oh, so the plist files section might contain duplicated if the same file is passed both as absolute and as relative path to the compiler invocation. So we are working around a bug in plists. I think we should fix plists at some point rather than trying to work this around.

@gyorb
Copy link
Contributor Author

gyorb commented Nov 27, 2019

Yes, we do it because of the plists, but just converting every path in the plist to absolute is not always the best solution, sometimes you need the relative paths.
The analyzer tools (cppcheck, clang) convert the file path to absolute if the compilation command contains absolute path and if it contains relative path they keep it relative (which is not good if we want to store them)

One option would be to introduce a flag in each analyzer to generate the reports with absolute paths even if the compilation command contained relative, but for this we would have to modify all the supported and planned analyzers. For now it is easier to do the conversion in CodeChecker.

File path after the -include and -imacros flags should not be
converted to absolute path.
Only the flags with include path directories should be converted.
If every other include directory flag is set properly the
file set by -include or -imacros should be found too.
Copy link
Member

@dkrupp dkrupp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dkrupp dkrupp merged commit b6e7301 into Ericsson:master Dec 4, 2019
@gyorb gyorb deleted the include-abs branch December 19, 2019 15:05
whisperity added a commit to whisperity/CodeChecker that referenced this pull request Sep 8, 2021
This was seemingly last touched in Ericsson#2449
(Ericsson/codechecker@7d93b32) but it
seems like a typo. There's no such flag as `-macros` in neither Clang
nor GCC.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer 📈 Related to the analyze commands (analysis driver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect full path reconstruction for -include
4 participants