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
jcfr
mentioned this pull request
jcfr
mentioned this pull request
jcfr
changed the title
Add Apple Framework header support for
feat: Add Darwin-style framework search with ordered path lookup__has_include and #include
jcfr
changed the title
feat: Add Darwin-style framework search with ordered path lookup
feat: Ordered search paths for -I, -isystem, -F, -iframework + Darwin framework support (with legacy -I back-compat)
jcfr and others added 5 commits
…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.
jcfr
mentioned this pull request
jcfr
mentioned this pull request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters