================
@@ -1597,3 +1597,25 @@ void Sema::checkReferenceToTULocalFromOtherTU(
PendingCheckReferenceForTULocal.push_back(
std::make_pair(FD, PointOfInstantiation));
}
+
+bool Sema::isFromSameSingleIncludeHeader(const Decl *PrevD,
+ SourceLocation NewLoc) {
+ if (!PrevD->isFromASTFile())
+ return false;
+ SourceLocation PrevLoc = PrevD->getLocation();
+ if (!PrevLoc.isValid() || !NewLoc.isValid())
+ return false;
+ SourceManager &SM = getSourceManager();
+ auto [PrevFileID, PrevOffset] = SM.getDecomposedExpansionLoc(PrevLoc);
+ auto [NewFileID, NewOffset] = SM.getDecomposedExpansionLoc(NewLoc);
+ if (PrevOffset != NewOffset)
----------------
vsapsai wrote:
Added a test case demonstrating SourceLocation equality isn't sufficient for
Decl equality. In "headers-mismatched/sub/sub.h" definition can be different in
different context despite being at the same location.
https://github.com/llvm/llvm-project/pull/214345
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits