Teach the related-id checker to ignore things from other buffers

This commit is contained in:
Doug Gregor
2023-02-13 10:13:39 -08:00
parent b87dfdf2ae
commit a712c37c05
2 changed files with 13 additions and 1 deletions

View File

@@ -422,7 +422,15 @@ unsigned Decl::getAttachedMacroDiscriminator(
foundDiscriminator = discriminator;
});
if (foundDiscriminator)
return *foundDiscriminator;
// If that failed, conjure up a discriminator.
ASTContext &ctx = getASTContext();
assert(ctx.Diags.hadAnyError());
return ctx.getNextMacroDiscriminator(
MacroDiscriminatorContext::getParentOf(getLoc(), getDeclContext()),
DeclBaseName());
}
const Decl *Decl::getInnermostDeclWithAvailability() const {

View File

@@ -2398,6 +2398,10 @@ private:
}
bool passId(CharSourceRange Range) {
// FIXME: Ignore things that don't come from this buffer.
if (!SourceMgr.getRangeForBuffer(BufferID).contains(Range.getStart()))
return !Cancelled;
unsigned Offset = SourceMgr.getLocOffsetInBuffer(Range.getStart(),BufferID);
Ranges.insert({Offset, Range.getByteLength()});
return !Cancelled;