Skip to content

Commit d8e5cd9

Browse files
authored
Merge pull request #63625 from DougGregor/sourcekit-related-id-checker
Teach the related-id checker to ignore things from other buffers
2 parents b67187c + a712c37 commit d8e5cd9

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/AST/Decl.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,15 @@ unsigned Decl::getAttachedMacroDiscriminator(
422422
foundDiscriminator = discriminator;
423423
});
424424

425-
return *foundDiscriminator;
425+
if (foundDiscriminator)
426+
return *foundDiscriminator;
427+
428+
// If that failed, conjure up a discriminator.
429+
ASTContext &ctx = getASTContext();
430+
assert(ctx.Diags.hadAnyError());
431+
return ctx.getNextMacroDiscriminator(
432+
MacroDiscriminatorContext::getParentOf(getLoc(), getDeclContext()),
433+
DeclBaseName());
426434
}
427435

428436
const Decl *Decl::getInnermostDeclWithAvailability() const {

tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,6 +2398,10 @@ class RelatedIdScanner : public SourceEntityWalker {
23982398
}
23992399

24002400
bool passId(CharSourceRange Range) {
2401+
// FIXME: Ignore things that don't come from this buffer.
2402+
if (!SourceMgr.getRangeForBuffer(BufferID).contains(Range.getStart()))
2403+
return !Cancelled;
2404+
24012405
unsigned Offset = SourceMgr.getLocOffsetInBuffer(Range.getStart(),BufferID);
24022406
Ranges.insert({Offset, Range.getByteLength()});
24032407
return !Cancelled;

0 commit comments

Comments
 (0)