[NFC] Refactor getRenameDecl to use the request evaluator

Move `getRenameDecl` from `PrintAsObjC` into its own request so that
other components can re-use this functionality.
This commit is contained in:
Ben Barham
2021-07-17 09:04:58 +10:00
parent 35aa862e1d
commit f1c45de2a9
14 changed files with 185 additions and 139 deletions

View File

@@ -1638,6 +1638,32 @@ Fingerprint ModuleDecl::getFingerprint() const {
return Fingerprint{std::move(hasher)};
}
bool ModuleDecl::isExternallyConsumed() const {
// Modules for executables aren't expected to be consumed by other modules.
// This picks up all kinds of entrypoints, including script mode,
// @UIApplicationMain and @NSApplicationMain.
if (hasEntryPoint()) {
return false;
}
// If an implicit Objective-C header was needed to construct this module, it
// must be the product of a library target.
if (!getImplicitImportInfo().BridgingHeaderPath.empty()) {
return false;
}
// App extensions are special beasts because they build without entrypoints
// like library targets, but they behave like executable targets because
// their associated modules are not suitable for distribution.
if (getASTContext().LangOpts.EnableAppExtensionRestrictions) {
return false;
}
// FIXME: This is still a lousy approximation of whether the module file will
// be externally consumed.
return true;
}
//===----------------------------------------------------------------------===//
// Cross-Import Overlays
//===----------------------------------------------------------------------===//