[Macros] Remove ModuleDecl::isInGeneratedBuffer.

This method was misleading. The majority of callers (all but one!) don't want
to unconditionally treat all locations in any macro expansion buffer the
same way, because the code also must handle nested macro expansions. There
is one part of SourceKit (and possibly others) that really do want to ignore
all macro expansions, but those can be handled within SourceKit / IDE code,
because I don't believe this utility is useful in the frontend.
This commit is contained in:
Holly Borla
2023-04-19 21:28:09 -07:00
parent 265c8a47d9
commit b958e43528
6 changed files with 26 additions and 18 deletions

View File

@@ -649,11 +649,20 @@ renameAvailabilityInfo(const ValueDecl *VD, Optional<RenameRefInfo> RefInfo) {
AvailKind = RefactorAvailableKind::Unavailable_has_no_name;
}
auto isInMacroExpansionBuffer = [](const ValueDecl *VD) -> bool {
auto *module = VD->getModuleContext();
auto *file = module->getSourceFileContainingLocation(VD->getLoc());
if (!file)
return false;
return file->getFulfilledMacroRole() != None;
};
if (AvailKind == RefactorAvailableKind::Available) {
SourceLoc Loc = VD->getLoc();
if (!Loc.isValid()) {
AvailKind = RefactorAvailableKind::Unavailable_has_no_location;
} else if (VD->getModuleContext()->isInGeneratedBuffer(Loc)) {
} else if (isInMacroExpansionBuffer(VD)) {
AvailKind = RefactorAvailableKind::Unavailable_decl_in_macro;
}
}