GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat: Ordered search paths for `-I`, `-isystem`, `-F`, `-iframework` + Darwin framework support (with legacy `-I` back-compat) by jcfr · Pull Request #511 · cppcheck-opensource/simplecpp Conversation
|
|
This should be further improved following guidance originally posted by @glankk in #448 (comment)
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Looks like this is currently executed for all code even if there is no apple framework is available which seems excessive. I wonder if this behavior should be configurable via DUI or consider the Even if it is available it might not be the files you are looking for (can there be conflicts?) as this behavior would be limited to the Apple compiler. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Indeed, this was a deliberate choice anticipating the use of the tool in the context of cross compilation. Adding an option to enable/disable the behavior may be best. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
c5a5cbe to
cdd5fc2
Compare
There was an error while loading. Please reload this page.
|
@glankk Thanks for the suggestion 🙏 All the review comments have been addressed. Once the GitHub workflow have been enabled and the test pass, I believe this will be ready for integration 🚀 we also included a comprehensive docstring explaining how to work with the To improve the developer experience, we could also further extend the If that sounds reasonable, I can amend the last commit and update the tests. cc: @danmar |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Waiting this is integrated, we will stage those changes into a fork and move forward with vendoring those into Related: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
#283 possibly needs to be addressed as prerequisite of this as the include directories are currently not differentiated between system and "local" ones. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks again @hjmjohnson for working on the initial patch and establishing the momentum 🙏 Hopefully our contributions will be integrated shortly 🤞 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
39eeb91 to
e0ed0e3
Compare
e0ed0e3 to
3a900a2
Compare
__has_include and #include3a900a2 to
6899f8e
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
So if I understand it correctly.. if the command line only uses -I then behavior will be unchanged?
this looks pretty good to me. I would like a review by @glankk
To improve the developer experience, we could also further extend the DUI API:
please look at adding such helper functions. It sounds good to me.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I will add those
I am also adding support for this along with integration test update. This issue is related: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
267c55c to
2af5465
Compare
-I, -isystem, -F, -iframework + Darwin framework support (with legacy -I back-compat)
2af5465 to
de861c9
Compare
Ditto 👍 Both
🙏 This is now finalized and ready for review. The PR description has been updated to reflect the full set of changes 🚀
Done. Convenience helpers for I also made sure that each commit in the series compiles and passes the tests individually. Given that, I'd suggest merging with Rebase & Merge (or Merge) to preserve the history, rather than Squashing & Merge. If you'd prefer to consolidate some of the commits for a cleaner log, let me know I would be happy to revisit. cc: @glankk |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…th lookup
This change teaches simplecpp to resolve headers from Apple-style Framework
directories while preserving the left-to-right order of interleaved
-I/-F/-iframework search paths (like GCC/Clang on Darwin).
This enables both:
- `__has_include(<Pkg/Hdr.h>)` -> `<Pkg.framework/Headers/Hdr.h>` (or `PrivateHeaders`)
- `#include <Pkg/Hdr.h>` -> same framework layout when a package prefix exists
Changes:
- Add `DUI::SearchPath` with `PathKind {Include, Framework, SystemFramework}`.
- If `DUI::searchPaths` is non-empty, use it verbatim (interleaved -I/-F/-iframework).
Otherwise preserve back-compat by mirroring `includePaths` as Include paths.
- Update `openHeader()` to consult typed paths, and only rewrite `<Pkg/Hdr.h>`
to `Pkg.framework/{Headers,PrivateHeaders}/Hdr.h` when a package prefix exists.
- Implement `toAppleFrameworkRelatives()` returning prioritized candidates
(Headers first, then PrivateHeaders).
- Tests use `PathKind::Framework` when checking framework layout.
CLI
- Support -F<dir> and -iframework<dir> (keep -I as before).
Behavior notes
- The order of -I/-F/-iframework is preserved exactly as provided.
- `Framework` vs `SystemFramework` differ only in diagnostic semantics (not lookup).
- Legacy users who only set `DUI::includePaths` see identical behavior.
Tests
- Add `appleFrameworkHasIncludeTest` for `__has_include` resolution.
- Add `appleFrameworkIncludeTest` for `#include` resolution.
- Add dummy fixture: `testsuite/Foundation.framework/Headers/Foundation.h`.
This brings simplecpp closer to GCC/Clang behavior on macOS and enables
robust resolution of framework headers like `Foundation/Foundation.h`.
Co-authored-by: Jean-Christophe Fillion-Robin <[email protected]>
Co-authored-by: Hans Johnson <[email protected]>
Suggested-by: glankk <[email protected]>
This change introduces support for the -isystem flag, allowing users to specify system include directories. The addition includes handling the new flag in both the argument parsing and include resolution logic, as well as updating relevant tests to validate the new functionality.
This improves test coverage by ensuring that DUI::addIncludePath is tested with both legacy mode on and off. It adds new test functions for each scenario and updates the test cases accordingly.
This changes the default value of the 'legacy' parameter in the DUI::addIncludePath method to false. Since this API was just introduced, it is preferred to use the new capabilities by preserving the left-to-right order.
de861c9 to
03d7ab0
Compare
|
Not to throw a wrench into this but I think #475 and #524 should land/be fixed before this is being merged. Otherwise things could get quite messy down the road. We might also need to merge those other things downstream first as those regressions are serious and we might even need to backport them. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
it sounds like the simplecpp repo is not fully ready for this PR yet. but I hope we can make the repo ready and get this PR into simplecpp repo soonish and then make a simplecpp release so we can upstream it into cppcheck and test it with daca etc. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I think this looks pretty good overall, the only thing that bothers me a little is building all of the candidate path strings before they're known to be needed. We've recently made an effort to improve the include search performance, I'd prefer if the path strings are constructed as they're searched. I don't know how much this will actually affect the performance though, maybe it's negligible. I think I agree with @firewave that fixing #475 and #524 first would be good. I'm working on #524 now. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
After #438 has been merged and I will extend the callgrind step with that and that might give an indication of the performance impact (so more to merge beforehand?).
As mentioned above we probably need to release a version to downstream before this is merged so we can prepare yet another patch (which also needs some test-related backports which have been requested by a packager). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
In #438 I encountered a framework path. I only treat it like a regular include path but after that has been merged we should hook it up properly via the options you introduced. Might also double as an integration test. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I think we need to get this into simplecpp soon before it starts to rot.. there are conflicts now. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Thanks for the update 🙏. I may be able to rebase & address conflict within a week |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I think we should get the MinGW changes into a release first and get it downstream and do an immediately release with these changes. It is already a lot of changes and might help with bisection. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
goal: try to make sure that performance is not affected negatively by this PR if we only provide -I flags as before..
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (!dui.searchPaths.empty()) { | ||
| searchPaths = dui.searchPaths; | ||
| } else { | ||
| searchPaths.reserve(dui.includePaths.size()); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
if dui.searchPaths is empty then we only need a short simple for loop here as far as I see.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| case 'I': { // include path | ||
| const char * const value = arg[2] ? (argv[i] + 2) : argv[++i]; | ||
| dui.includePaths.push_back(value); | ||
| dui.addIncludePath(value, /* legacy= */ false); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
if "legacy" is used simplecpp will not just skip over the new handling it will copy all the include paths (and as far as I see this is repeated). This solution will introduce a performance penalty.
We have had major performance problems and we managed to improve the situation but this I fear adds cpu overhead.
I envision that in Cppcheck many users will only use -I flags and I would like to be able to get optimal performance by choosing "legacy=true"
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (!dui.searchPaths.empty()) { | ||
| searchPaths = dui.searchPaths; | ||
| } else { | ||
| searchPaths.reserve(dui.includePaths.size()); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
this is a slowdown I fear. If searchPaths is empty we can speedup.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I have WIP changes for |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
I don't see why a mingw release would be needed first? I fear the mingw was mentioned as a prerequisite in august and there is still not mingw available .. imho if prerequisites are not added soon I think we should merge this pr anyway.
well it would be nice with some callgrind scripts.. but I do hope you rest and take care and I am not trying to push you to work even harder.. I believe we can use callgrind anyway to see the impact of this PR even if we don't have a script |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Since it exposed major bugs - it should have been ported back to 2.18 but there were just too many issues (it just exposed another one in the improved
There already is one but it does not rely on include paths as the additional selfcheck does.
Just add |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
People are waiting for the new simplecpp. It solves critical performance issues for a big customer. I will tag simplecpp now so we can merge simplecpp to cppcheck.. and I feel that if mingw is not added soonish then let's merge this PR without it. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The previous MinGW issues are all fixed but the absolute path tests exposed new issues - see #556. It is probably an easy fix but I need to do some manual testing to determine the current behavior and on how to test it properly in the CI. Since my cold has actually worsened I have not been able to look into it yet. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This is ready for review in #560. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Once #560 is integrated, I will rebase this pull request. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
It has been merged. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
differentiate local includes and system includes
There was an error while loading. Please reload this page.