Skip to content

Commit 0b91f63

Browse files
committed
[ASTScope] Don't consider freestanding macro expansions as being part of a
macro argument.
1 parent 9824954 commit 0b91f63

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/AST/ASTScopeLookup.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,16 @@ bool ASTScopeImpl::isInMacroArgument(SourceFile *sourceFile,
689689
do {
690690
if (scope->isMacroArgumentScope())
691691
return true;
692+
693+
// If we've reached a source file scope, we can't be inside of
694+
// a macro argument. Either this is a top-level source file, or
695+
// it's macro expansion buffer. We have to check for this because
696+
// macro expansion buffers for freestanding macros are children of
697+
// MacroExpansionDeclScope, and child scopes of freestanding macros
698+
// are otherwise inside the macro argument.
699+
if (scope->getClassName() == "ASTSourceFileScope")
700+
return false;
701+
692702
} while ((scope = scope->getParent().getPtrOrNull()));
693703

694704
return false;

0 commit comments

Comments
 (0)