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

JSON Compilation Database: support -isystem includes #1799

Closed
wants to merge 1 commit into from

Conversation

tisoft
Copy link
Contributor

@tisoft tisoft commented Jan 27, 2020

  • -isystem includes are treated the same as -I

Fixes #1215


This change is Reviewable

* -isystem includes are treated the same as -I

Fixes SonarOpenCommunity#1215
@tisoft
Copy link
Contributor Author

tisoft commented Jan 27, 2020

According to spec -isystem includes would need to be sorted after the -I includes, and there are also -iquote and -idirafter. Do we need to support all that?

@tisoft
Copy link
Contributor Author

tisoft commented Jan 27, 2020

Will add a testcase as soon as we have decided if we need the correct sorting, or if it's ok to combine -I and -isystem for now.

@guwirth
Copy link
Collaborator

guwirth commented Jan 28, 2020

@tisoft thanks for this PR.

According to spec -isystem includes would need to be sorted after the -I includes, and there are also -iquote and -idirafter. Do we need to support all that?

That's always difficult to answer. Additional includes means always slower analysis times. On the other hand you need often the includes to get valid C++ code. Small sample:

You can parse this code without knowing details of the type:

void MyType func() {}

No valid C++ without knowing EXPORT:

void EXPORT int func() {}

The order of the includes is always important. To get same results as the compiler you have to ensure that search order of includes is the same as in your original environment. So I think "sort" is the wrong way.

  • In best case you can use it in the same order as they are in the json file
  • Makes also sense that you put all -isystem after the other includes, but my feeling is that you have to keep the order inside of -isystem and -I.

Maybe you can verify this in your build environment in which order the compiler gets it.

@guwirth guwirth added this to the 1.3.2 milestone Jan 28, 2020
@guwirth guwirth changed the title Support isystem includes JSON Compilation Database: support -isystem includes Jan 28, 2020
@guwirth
Copy link
Collaborator

guwirth commented Jan 28, 2020

@tisoft

According to spec -isystem includes would need to be sorted after the -I includes, and there are also -iquote and -idirafter. Do we need to support all that?

Would collect in three separate lists:

  • includes
  • sysincludes
  • dirafter

And merge at the end in the order above.

For iquote we have no support. Would handle it like -I.

Maybe you can also fix this, should be 1 (not empty)
-D<macro>=<value>
Define <macro> to <value> (or 1 if <value> omitted)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

JSON Compilation Database class does not handle "-isystem" include path references
2 participants