mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user