| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
This should be further improved following guidance originally posted by @glankk in #448 (comment)
|
Sorry, something went wrong.
|
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 __APPLE__ preprocessor define. 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.
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.
|
@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 DUI struct. /** * Command line preprocessor settings. * * Mirrors typical compiler options: * -D <name>=<value> Add macro definition * -U <name> Undefine macro * -I <dir> Add include search directory * -F <dir> Add framework search directory (Darwin) * -iframework <dir> Add system framework search directory (Darwin) * --include <file> Force inclusion of a header * -std=<version> Select language standard (C++17, C23, etc.) * * Path search behavior: * - If searchPaths is non-empty, it is used directly, preserving the * left-to-right order and distinguishing between Include, Framework, * and SystemFramework kinds. * - If searchPaths is empty, legacy includePaths is used instead, and * each entry is treated as a normal Include path (for backward * compatibility). */ To improve the developer experience, we could also further extend the DUI API: // Mirrors GCC/Clang -I <dir>
void addIncludePath(const std::string& p) {
searchPaths.push_back({p, PathKind::Include});
}
// Mirrors GCC/Clang -F <dir>
void addFrameworkPath(const std::string& p) {
searchPaths.push_back({p, PathKind::Framework});
}
// Mirrors GCC/Clang -iframework <dir>
void addSystemFrameworkPath(const std::string& p) {
searchPaths.push_back({p, PathKind::SystemFramework});
}
If that sounds reasonable, I can amend the last commit and update the tests. cc: @danmar |
Sorry, something went wrong.
|
Waiting this is integrated, we will stage those changes into a fork and move forward with vendoring those into PythonQt. Related: |
Sorry, something went wrong.
|
#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.
Sorry, something went wrong.
|
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 a problem hiding this comment.
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.
I will add those
I am also adding support for this along with integration test update. This issue is related: |
Sorry, something went wrong.
Ditto 👍 Both openHeader (via simplecpp::preprocess) and FileDataCache::tryload (via FileDataCache::get) behave identically whether only -I is passed on the CLI or includePaths are provided directly through simplecpp::DUI.
🙏 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 addIncludePath, addSystemIncludePath, addFrameworkPath, and addSystemFrameworkPath are included. 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.
…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 <jchris.fillionr@kitware.com>
Co-authored-by: Hans Johnson <hans-johnson@uiowa.edu>
Suggested-by: glankk <glankk@users.noreply.github.com>
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.
|
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.
|
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.
|
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.
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.
|
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.
|
I think we need to get this into simplecpp soon before it starts to rot.. there are conflicts now. |
Sorry, something went wrong.
|
Thanks for the update 🙏. I may be able to rebase & address conflict within a week |
Sorry, something went wrong.
|
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 a problem hiding this comment.
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.
| if (!dui.searchPaths.empty()) { | ||
| searchPaths = dui.searchPaths; | ||
| } else { | ||
| searchPaths.reserve(dui.includePaths.size()); |
There was a problem hiding this comment.
if dui.searchPaths is empty then we only need a short simple for loop here as far as I see.
Sorry, something went wrong.
| 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.
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.
| if (!dui.searchPaths.empty()) { | ||
| searchPaths = dui.searchPaths; | ||
| } else { | ||
| searchPaths.reserve(dui.includePaths.size()); |
There was a problem hiding this comment.
this is a slowdown I fear. If searchPaths is empty we can speedup.
Sorry, something went wrong.
I have WIP changes for selfcheck.sh which runs it with callgrind and will help with this. Since I am currently out sick I cannot work on this right now. |
Sorry, something went wrong.
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.
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 isAbsolutePath()).
There already is one but it does not rely on include paths as the additional selfcheck does.
Just add valgrind --tool=callgrind to the ./simplecpp calls in selfcheck.sh. I have it parameterized and such and it just needs to be cleaned up so not much work is necessary I just cannot be bothered right now cough. |
Sorry, something went wrong.
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.
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.
This is ready for review in #560. |
Sorry, something went wrong.
|
Once #560 is integrated, I will rebase this pull request. |
Sorry, something went wrong.
It has been merged. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This PR modernizes simplecpp's header lookup to more closely match GCC/Clang, while preserving backward compatibility for existing users.
What's new
Typed, ordered search paths
Introduce DUI::SearchPath with PathKind:
If DUI::searchPaths is non-empty, it is honored verbatim in the order provided.
If it's empty, legacy includePaths are mirrored as Include entries for back-compat.
CLI flags
Public API convenience
New helpers on DUI:
addIncludePath defaults to legacy=false; tests exercise both modes.
Darwin frameworks
Lookup order (summary of actual implementation)
For "quotes" includes only: directory of the including file (unchanged).
Interleaved searchPaths in left-to-right CLI order:
System include paths (SystemInclude, i.e., -isystem)
System framework paths (SystemFramework, i.e., -iframework)
(Standard library dirs are outside simplecpp's scope; -idirafter/-iquote are not implemented in this series.)
Core loader refactors
Tests & tooling
Integration tests
New helpers to build fixtures:
test_framework_lookup: verifies Headers vs PrivateHeaders and -F vs -iframework.
test_searchpath_order: a single parametrized test that validates precedence across -I, -isystem, -F, -iframework, including interleaving and duplicates, asserting on the exact #line path chosen.
Unit tests (test.cpp)
Supersedes the following pull request:
Related issues: