mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[SourceKit] Always check buffer in SemanticAnnotator
Make sure we don't ever try to record semantic tokens for a different buffer. This works around an ASTWalker issue where it will walk macro expanded bodies even in non-macro-expansion mode. rdar://165420658
This commit is contained in:
@@ -1027,12 +1027,11 @@ public:
|
||||
if (!Range.isValid())
|
||||
return;
|
||||
|
||||
// If we are walking into macro expansions, make sure we only report ranges
|
||||
// from the requested buffer, not any buffers of child macro expansions.
|
||||
if (IsWalkingMacroExpansionBuffer &&
|
||||
SM.findBufferContainingLoc(Range.getStart()) != BufferID) {
|
||||
// Make sure we only report from the requested buffer, not any buffers of
|
||||
// child macro expansions.
|
||||
if (SM.findBufferContainingLoc(Range.getStart()) != BufferID)
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned ByteOffset = SM.getLocOffsetInBuffer(Range.getStart(), BufferID);
|
||||
unsigned Length = Range.getByteLength();
|
||||
auto Kind = ContextFreeCodeCompletionResult::getCodeCompletionDeclKind(D);
|
||||
|
||||
Reference in New Issue
Block a user