AST: Fix availability checking for macros as default arguments (#72813)

This commit is contained in:
Allan Shortlidge
2024-04-03 20:37:23 -07:00
committed by GitHub
parent 36569ea6b6
commit ffa8c9a5c9
6 changed files with 64 additions and 12 deletions

View File

@@ -1179,9 +1179,7 @@ ASTNode SourceFile::getMacroExpansion() const {
if (Kind != SourceFileKind::MacroExpansion)
return nullptr;
auto genInfo =
*getASTContext().SourceMgr.getGeneratedSourceInfo(*getBufferID());
return ASTNode::getFromOpaqueValue(genInfo.astNode);
return getNodeInEnclosingSourceFile();
}
SourceRange SourceFile::getMacroInsertionRange() const {
@@ -1233,6 +1231,16 @@ SourceFile *SourceFile::getEnclosingSourceFile() const {
return getParentModule()->getSourceFileContainingLocation(sourceLoc);
}
ASTNode SourceFile::getNodeInEnclosingSourceFile() const {
if (Kind != SourceFileKind::MacroExpansion &&
Kind != SourceFileKind::DefaultArgument)
return nullptr;
auto genInfo =
*getASTContext().SourceMgr.getGeneratedSourceInfo(*getBufferID());
return ASTNode::getFromOpaqueValue(genInfo.astNode);
}
void ModuleDecl::lookupClassMember(ImportPath::Access accessPath,
DeclName name,
SmallVectorImpl<ValueDecl*> &results) const {