@@ -381,7 +381,10 @@ DeclAttributes Decl::getSemanticAttrs() const {
381381 return getAttrs ();
382382}
383383
384- void Decl::visitAuxiliaryDecls (AuxiliaryDeclCallback callback) const {
384+ void Decl::visitAuxiliaryDecls (
385+ AuxiliaryDeclCallback callback,
386+ bool visitFreestandingExpanded
387+ ) const {
385388 auto &ctx = getASTContext ();
386389 auto *mutableThis = const_cast <Decl *>(this );
387390 SourceManager &sourceMgr = ctx.SourceMgr ;
@@ -414,13 +417,15 @@ void Decl::visitAuxiliaryDecls(AuxiliaryDeclCallback callback) const {
414417 }
415418 }
416419
417- else if (auto *med = dyn_cast<MacroExpansionDecl>(mutableThis)) {
418- if (auto bufferID = evaluateOrDefault (
419- ctx.evaluator , ExpandMacroExpansionDeclRequest{med}, {})) {
420- auto startLoc = sourceMgr.getLocForBufferStart (*bufferID);
421- auto *sourceFile = moduleDecl->getSourceFileContainingLocation (startLoc);
422- for (auto *decl : sourceFile->getTopLevelDecls ())
423- callback (decl);
420+ if (visitFreestandingExpanded) {
421+ if (auto *med = dyn_cast<MacroExpansionDecl>(mutableThis)) {
422+ if (auto bufferID = evaluateOrDefault (
423+ ctx.evaluator , ExpandMacroExpansionDeclRequest{med}, {})) {
424+ auto startLoc = sourceMgr.getLocForBufferStart (*bufferID);
425+ auto *sourceFile = moduleDecl->getSourceFileContainingLocation (startLoc);
426+ for (auto *decl : sourceFile->getTopLevelDecls ())
427+ callback (decl);
428+ }
424429 }
425430 }
426431
@@ -10637,8 +10642,9 @@ unsigned MacroExpansionDecl::getDiscriminator() const {
1063710642 return getRawDiscriminator ();
1063810643}
1063910644
10640- void MacroExpansionDecl::forEachExpandedExprOrStmt (
10641- ExprOrStmtExpansionCallback callback) const {
10645+ void MacroExpansionDecl::forEachExpandedNode (
10646+ llvm::function_ref<void (ASTNode)> callback
10647+ ) const {
1064210648 auto mutableThis = const_cast <MacroExpansionDecl *>(this );
1064310649 auto bufferID = evaluateOrDefault (
1064410650 getASTContext ().evaluator ,
@@ -10650,8 +10656,7 @@ void MacroExpansionDecl::forEachExpandedExprOrStmt(
1065010656 auto startLoc = sourceMgr.getLocForBufferStart (*bufferID);
1065110657 auto *sourceFile = moduleDecl->getSourceFileContainingLocation (startLoc);
1065210658 for (auto node : sourceFile->getTopLevelItems ())
10653- if (node.is <Expr *>() || node.is <Stmt *>())
10654- callback (node);
10659+ callback (node);
1065510660}
1065610661
1065710662NominalTypeDecl *
0 commit comments