mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Spelling driver (#42516)
* spelling: associated Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: change Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: declaration Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: dependents Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: deterministically Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: embedded Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: exclude Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: filesystem Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: given Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: grained Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: incrementality Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: invoke Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: locals Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: preexisting Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: should Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: supplementary Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: suppress Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
This commit is contained in:
@@ -436,7 +436,7 @@ class SameNameNodeMatcher : public NodeMatcher {
|
||||
};
|
||||
|
||||
// Get the priority for the favored name match kind. Favored name match kind
|
||||
// locats before less favored ones.
|
||||
// locals before less favored ones.
|
||||
ArrayRef<NameMatchKind> getNameMatchKindPriority(SDKNodeKind Kind) {
|
||||
if (Kind == SDKNodeKind::DeclFunction) {
|
||||
static NameMatchKind FuncPriority[] = { NameMatchKind::PrintedNameAndUSR,
|
||||
@@ -1129,13 +1129,13 @@ class InterfaceTypeChangeDetector {
|
||||
bool HasOptional = L->getTypeKind() == KnownTypeKind::Optional &&
|
||||
R->getTypeKind() == KnownTypeKind::Optional;
|
||||
if (HasOptional) {
|
||||
// Detect [String: Any]? to [StringRepresentableStruct: Any]? Chnage
|
||||
// Detect [String: Any]? to [StringRepresentableStruct: Any]? Change
|
||||
KeyChangedTo =
|
||||
detectDictionaryKeyChangeInternal(L->getOnlyChild()->getAs<SDKNodeType>(),
|
||||
R->getOnlyChild()->getAs<SDKNodeType>(),
|
||||
Raw);
|
||||
} else {
|
||||
// Detect [String: Any] to [StringRepresentableStruct: Any] Chnage
|
||||
// Detect [String: Any] to [StringRepresentableStruct: Any] Change
|
||||
KeyChangedTo = detectDictionaryKeyChangeInternal(L, R, Raw);
|
||||
}
|
||||
if (!KeyChangedTo.empty()) {
|
||||
@@ -1180,13 +1180,13 @@ class InterfaceTypeChangeDetector {
|
||||
bool HasOptional = L->getTypeKind() == KnownTypeKind::Optional &&
|
||||
R->getTypeKind() == KnownTypeKind::Optional;
|
||||
if (HasOptional) {
|
||||
// Detect [String]? to [StringRepresentableStruct]? Chnage
|
||||
// Detect [String]? to [StringRepresentableStruct]? Change
|
||||
KeyChangedTo =
|
||||
detectArrayMemberChangeInternal(L->getOnlyChild()->getAs<SDKNodeType>(),
|
||||
R->getOnlyChild()->getAs<SDKNodeType>(),
|
||||
Raw);
|
||||
} else {
|
||||
// Detect [String] to [StringRepresentableStruct] Chnage
|
||||
// Detect [String] to [StringRepresentableStruct] Change
|
||||
KeyChangedTo = detectArrayMemberChangeInternal(L, R, Raw);
|
||||
}
|
||||
if (!KeyChangedTo.empty()) {
|
||||
@@ -1618,7 +1618,7 @@ void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
|
||||
}
|
||||
}
|
||||
|
||||
// If we can find a hoisted member for this removed delcaration, we
|
||||
// If we can find a hoisted member for this removed declaration, we
|
||||
// emit the diagnostics as rename instead of removal.
|
||||
auto It = std::find_if(MemberChanges.begin(), MemberChanges.end(),
|
||||
[&](TypeMemberDiffItem &Item) { return Item.usr == Node->getUsr(); });
|
||||
@@ -1642,7 +1642,7 @@ void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We should exlude those declarations that are pulled up to the super classes.
|
||||
// We should exclude those declarations that are pulled up to the super classes.
|
||||
bool FoundInSuperclass = false;
|
||||
if (auto PD = dyn_cast<SDKNodeDecl>(Node->getParent())) {
|
||||
if (PD->isAnnotatedAs(NodeAnnotation::Updated)) {
|
||||
@@ -1847,10 +1847,10 @@ static bool readBreakageAllowlist(SDKContext &Ctx, llvm::StringSet<> &lines,
|
||||
if (BreakageAllowlistPath.empty())
|
||||
return 0;
|
||||
CompilerInstance instance;
|
||||
CompilerInvocation invok;
|
||||
invok.setModuleName("ForClangImporter");
|
||||
CompilerInvocation invoke;
|
||||
invoke.setModuleName("ForClangImporter");
|
||||
std::string InstanceSetupError;
|
||||
if (instance.setup(invok, InstanceSetupError)) {
|
||||
if (instance.setup(invoke, InstanceSetupError)) {
|
||||
return 1;
|
||||
}
|
||||
auto importer = ClangImporter::create(instance.getASTContext());
|
||||
@@ -2055,19 +2055,19 @@ static int generateMigrationScript(StringRef LeftPath, StringRef RightPath,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void setSDKPath(CompilerInvocation &InitInvok, bool IsBaseline,
|
||||
static void setSDKPath(CompilerInvocation &InitInvoke, bool IsBaseline,
|
||||
StringRef SDK, StringRef BaselineSDK) {
|
||||
if (IsBaseline) {
|
||||
// Set baseline SDK
|
||||
if (!BaselineSDK.empty()) {
|
||||
InitInvok.setSDKPath(BaselineSDK.str());
|
||||
InitInvoke.setSDKPath(BaselineSDK.str());
|
||||
}
|
||||
} else {
|
||||
// Set current SDK
|
||||
if (!SDK.empty()) {
|
||||
InitInvok.setSDKPath(SDK.str());
|
||||
InitInvoke.setSDKPath(SDK.str());
|
||||
} else if (const char *SDKROOT = getenv("SDKROOT")) {
|
||||
InitInvok.setSDKPath(SDKROOT);
|
||||
InitInvoke.setSDKPath(SDKROOT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2185,7 +2185,7 @@ class SwiftAPIDigesterInvocation {
|
||||
private:
|
||||
std::string MainExecutablePath;
|
||||
std::unique_ptr<llvm::opt::OptTable> Table;
|
||||
CompilerInvocation InitInvok;
|
||||
CompilerInvocation InitInvoke;
|
||||
ActionType Action = ActionType::None;
|
||||
CheckerOptions CheckerOpts;
|
||||
llvm::StringSet<> IgnoredUsrs;
|
||||
@@ -2379,21 +2379,21 @@ public:
|
||||
return ComparisonInputMode::BaselineJson;
|
||||
}
|
||||
|
||||
int prepareForDump(CompilerInvocation &InitInvok, llvm::StringSet<> &Modules,
|
||||
int prepareForDump(CompilerInvocation &InitInvoke, llvm::StringSet<> &Modules,
|
||||
bool IsBaseline = false) {
|
||||
InitInvok.setMainExecutablePath(MainExecutablePath);
|
||||
InitInvok.setModuleName("swift_ide_test");
|
||||
setSDKPath(InitInvok, IsBaseline, SDK, BaselineSDK);
|
||||
InitInvoke.setMainExecutablePath(MainExecutablePath);
|
||||
InitInvoke.setModuleName("swift_ide_test");
|
||||
setSDKPath(InitInvoke, IsBaseline, SDK, BaselineSDK);
|
||||
|
||||
if (!Triple.empty())
|
||||
InitInvok.setTargetTriple(Triple);
|
||||
InitInvoke.setTargetTriple(Triple);
|
||||
|
||||
// Ensure the tool works on linux properly
|
||||
InitInvok.getLangOptions().EnableObjCInterop =
|
||||
InitInvok.getLangOptions().Target.isOSDarwin();
|
||||
InitInvok.getClangImporterOptions().ModuleCachePath = ModuleCachePath;
|
||||
InitInvoke.getLangOptions().EnableObjCInterop =
|
||||
InitInvoke.getLangOptions().Target.isOSDarwin();
|
||||
InitInvoke.getClangImporterOptions().ModuleCachePath = ModuleCachePath;
|
||||
// Module recovery issue shouldn't bring down the tool.
|
||||
InitInvok.getLangOptions().AllowDeserializingImplementationOnly = true;
|
||||
InitInvoke.getLangOptions().AllowDeserializingImplementationOnly = true;
|
||||
|
||||
if (!SwiftVersion.empty()) {
|
||||
using version::Version;
|
||||
@@ -2401,7 +2401,7 @@ public:
|
||||
if (auto Version =
|
||||
Version::parseVersionString(SwiftVersion, SourceLoc(), nullptr)) {
|
||||
if (auto Effective = Version.getValue().getEffectiveLanguageVersion()) {
|
||||
InitInvok.getLangOptions().EffectiveLanguageVersion = *Effective;
|
||||
InitInvoke.getLangOptions().EffectiveLanguageVersion = *Effective;
|
||||
isValid = true;
|
||||
}
|
||||
}
|
||||
@@ -2412,7 +2412,7 @@ public:
|
||||
}
|
||||
|
||||
if (!ResourceDir.empty()) {
|
||||
InitInvok.setRuntimeResourcePath(ResourceDir);
|
||||
InitInvoke.setRuntimeResourcePath(ResourceDir);
|
||||
}
|
||||
std::vector<SearchPathOptions::FrameworkSearchPath> FramePaths;
|
||||
for (const auto &path : CCSystemFrameworkPaths) {
|
||||
@@ -2422,14 +2422,14 @@ public:
|
||||
for (const auto &path : BaselineFrameworkPaths) {
|
||||
FramePaths.push_back({path, /*isSystem=*/false});
|
||||
}
|
||||
InitInvok.setImportSearchPaths(BaselineModuleInputPaths);
|
||||
InitInvoke.setImportSearchPaths(BaselineModuleInputPaths);
|
||||
} else {
|
||||
for (const auto &path : FrameworkPaths) {
|
||||
FramePaths.push_back({path, /*isSystem=*/false});
|
||||
}
|
||||
InitInvok.setImportSearchPaths(ModuleInputPaths);
|
||||
InitInvoke.setImportSearchPaths(ModuleInputPaths);
|
||||
}
|
||||
InitInvok.setFrameworkSearchPaths(FramePaths);
|
||||
InitInvoke.setFrameworkSearchPaths(FramePaths);
|
||||
if (!ModuleList.empty()) {
|
||||
if (readFileLineByLine(ModuleList, Modules))
|
||||
exit(1);
|
||||
@@ -2438,7 +2438,7 @@ public:
|
||||
Modules.insert(M);
|
||||
}
|
||||
for (auto M : PreferInterfaceForModules) {
|
||||
InitInvok.getFrontendOptions().PreferInterfaceForModules.push_back(M);
|
||||
InitInvoke.getFrontendOptions().PreferInterfaceForModules.push_back(M);
|
||||
}
|
||||
if (Modules.empty()) {
|
||||
llvm::errs() << "Need to specify -include-all or -module <name>\n";
|
||||
@@ -2448,19 +2448,19 @@ public:
|
||||
}
|
||||
|
||||
SDKNodeRoot *getSDKRoot(SDKContext &Ctx, bool IsBaseline) {
|
||||
CompilerInvocation Invok;
|
||||
CompilerInvocation Invoke;
|
||||
llvm::StringSet<> Modules;
|
||||
if (prepareForDump(Invok, Modules, IsBaseline))
|
||||
if (prepareForDump(Invoke, Modules, IsBaseline))
|
||||
return nullptr;
|
||||
return getSDKNodeRoot(Ctx, Invok, Modules);
|
||||
return getSDKNodeRoot(Ctx, Invoke, Modules);
|
||||
}
|
||||
|
||||
SDKNodeRoot *getBaselineFromJson(SDKContext &Ctx) {
|
||||
SwiftDeclCollector Collector(Ctx);
|
||||
CompilerInvocation Invok;
|
||||
CompilerInvocation Invoke;
|
||||
llvm::StringSet<> Modules;
|
||||
// We need to call prepareForDump to parse target triple.
|
||||
if (prepareForDump(Invok, Modules, true))
|
||||
if (prepareForDump(Invoke, Modules, true))
|
||||
return nullptr;
|
||||
|
||||
assert(Modules.size() == 1 &&
|
||||
@@ -2470,14 +2470,14 @@ public:
|
||||
if (!BaselineFilePath.empty()) {
|
||||
Path = BaselineFilePath;
|
||||
} else if (!BaselineDirPath.empty()) {
|
||||
Path = getCustomBaselinePath(Invok.getLangOptions().Target,
|
||||
Path = getCustomBaselinePath(Invoke.getLangOptions().Target,
|
||||
Ctx.checkingABI(), BaselineDirPath);
|
||||
} else if (UseEmptyBaseline) {
|
||||
Path = getEmptyBaselinePath(MainExecutablePath);
|
||||
} else {
|
||||
Path = getDefaultBaselinePath(
|
||||
MainExecutablePath, Modules.begin()->getKey(),
|
||||
Invok.getLangOptions().Target, Ctx.checkingABI());
|
||||
Invoke.getLangOptions().Target, Ctx.checkingABI());
|
||||
}
|
||||
if (!fs::exists(Path)) {
|
||||
llvm::errs() << "Baseline at " << Path << " does not exist\n";
|
||||
@@ -2494,11 +2494,11 @@ public:
|
||||
switch (Action) {
|
||||
case ActionType::DumpSDK: {
|
||||
llvm::StringSet<> Modules;
|
||||
return (prepareForDump(InitInvok, Modules))
|
||||
return (prepareForDump(InitInvoke, Modules))
|
||||
? 1
|
||||
: dumpSDKContent(InitInvok, Modules,
|
||||
: dumpSDKContent(InitInvoke, Modules,
|
||||
getJsonOutputFilePath(
|
||||
InitInvok.getLangOptions().Target,
|
||||
InitInvoke.getLangOptions().Target,
|
||||
CheckerOpts.ABI, OutputFile, OutputDir),
|
||||
CheckerOpts);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user