When reparsing a translation unit with preamble generation turned on,
no includes are found. This is due to the fact that all SLocs from
AST/PCH files are skipped as they are 'loaded', and inclusions from a
preamble are also 'loaded'. So, in case a file has a preamble, it first
needs to process those loaded inclusions, and then check for any local
inclusions. This latter one is for any includes that are not part of the
preamble, like includes half-way through a file.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
I've seen this bug too. Generally this patch looks good to me.
Could you also add a test for includes half-way through a file case?
tools/c-index-test/c-index-test.c | ||
---|---|---|
1567 ↗ | (On Diff #39187) | This is not a very good idea to add this code here IMO. There are probably some tests that use this function with CINDEXTEST_EDITING set, which could potentially hide some parsing vs. reparsing bugs. I'd suggest to use something like perform_test_reparse_source instead. |
Comment Actions
LGTM, thanks for the fix!
tools/libclang/CIndexInclusionStack.cpp | ||
---|---|---|
32 ↗ | (On Diff #39187) | There's already a wild mix of coding styles in this file, let's not add more of them. bool HasPreamble is the preferred style. |