jansvoboda11 wrote:

Since I moved up the special-casing of built-ins buffer up in my last commit, 
it was happening before we got chance to walk up from `FileID(3)` to 
`FileID(2)`, meaning it wasn't kicking in. I think we need to sink the 
special-casing into `isInTheSameTranslationUnit()` and apply it to whatever 
`FileID` we end up with after not finding the common ancestor without assuming 
they are in different TUs entirely.

Also, it seems that the code previously assumed that two `SourceLocations` are 
in the same TU iff they have the same common ancestor. There are at least two 
counter-examples to this:
* The built-ins buffer doesn't have any ancestor, but still is part of the TU.
* With implicit modules (or lazy loaded explicit modules), all top-level 
SLocEntries loaded from PCM files have their include location adjusted to the 
import statement, so they became part of the importer SLocEntry tree and are 
all considered to be part of the importing TU.

I started tracking the SLocEntries allocated for each AST file and use that to 
cut off the include chain walk in order to stay in the same TU we started in. 
This basically make sure we don't skip the special case for loaded built-ins 
buffers.

https://github.com/llvm/llvm-project/pull/66962
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to