Skip to content

Spelling clangimporter #42464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Apr 21, 2022
24 changes: 12 additions & 12 deletions include/swift/ClangImporter/CXXMethodBridging.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,67 +8,67 @@
#include <string>
namespace swift {
struct CXXMethodBridging {
enum class Kind { unkown, getter, setter, subscript };
enum class Kind { unknown, getter, setter, subscript };

enum class NameKind { unkown, snake, lower, camel, title };
enum class NameKind { unknown, snake, lower, camel, title };

CXXMethodBridging(const clang::CXXMethodDecl *method) : method(method) {}

Kind classify() {
if (nameIsBlacklist())
return Kind::unkown;
return Kind::unknown;

// this should be handled as snake case. See: rdar://89453010
// case. In the future we could
// import these too, though.
auto nameKind = classifyNameKind();
if (nameKind != NameKind::title && nameKind != NameKind::camel &&
nameKind != NameKind::lower)
return Kind::unkown;
return Kind::unknown;

if (getClangName().startswith_insensitive("set")) {
// Setters only have one parameter.
if (method->getNumParams() != 1)
return Kind::unkown;
return Kind::unknown;

// rdar://89453106 (We need to handle imported properties that return a
// reference)
if (method->getParamDecl(0)->getType()->isReferenceType())
return Kind::unkown;
return Kind::unknown;

return Kind::setter;
}

// Getters and subscripts cannot return void.
if (method->getReturnType()->isVoidType())
return Kind::unkown;
return Kind::unknown;

if (getClangName().startswith_insensitive("get")) {
// Getters cannot take arguments.
if (method->getNumParams() != 0)
return Kind::unkown;
return Kind::unknown;

// rdar://89453106 (We need to handle imported properties that return a
// reference)
if (method->getReturnType()->isReferenceType())
return Kind::unkown;
return Kind::unknown;

return Kind::getter;
}

// rdar://89453187 (Add subscripts clarification to CXXMethod Bridging to
// clean up importDecl)
return Kind::unkown;
return Kind::unknown;
}

NameKind classifyNameKind() {
bool allLower = llvm::all_of(getClangName(), islower);

if (getClangName().empty())
return NameKind::unkown;
return NameKind::unknown;

if (getClangName().contains('_'))
return allLower ? NameKind::snake : NameKind::unkown;
return allLower ? NameKind::snake : NameKind::unknown;

if (allLower)
return NameKind::lower;
Expand Down
4 changes: 2 additions & 2 deletions lib/ClangImporter/ClangImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4393,7 +4393,7 @@ DeclRefExpr *getInteropStaticCastDeclRefExpr(ASTContext &ctx,
"Did you forget to define a __swift_interopStaticCast helper function?");
FuncDecl *staticCastFn = cast<FuncDecl>(results.back());

// Now we have to force instanciate this. We can't let the type checker do
// Now we have to force instantiate this. We can't let the type checker do
// this yet because it can't infer the "To" type.
auto subst =
SubstitutionMap::get(staticCastFn->getGenericSignature(), {derived, base},
Expand Down Expand Up @@ -5207,7 +5207,7 @@ clang::FunctionDecl *ClangImporter::instantiateCXXFunctionTemplate(
return nullptr;
}

// Instanciate a specialization of this template using the substitution map.
// Instantiate a specialization of this template using the substitution map.
auto *templateArgList = clang::TemplateArgumentList::CreateCopy(
func->getASTContext(), templateSubst);
auto &sema = getClangInstance().getSema();
Expand Down
2 changes: 1 addition & 1 deletion lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7377,7 +7377,7 @@ ConstructorDecl *SwiftDeclConverter::importConstructor(
}

void SwiftDeclConverter::recordObjCOverride(AbstractFunctionDecl *decl) {
// Make sure that we always set the overriden declarations.
// Make sure that we always set the overridden declarations.
SWIFT_DEFER {
if (!decl->overriddenDeclsComputed())
decl->setOverriddenDecls({ });
Expand Down
2 changes: 1 addition & 1 deletion lib/ClangImporter/ImportEnumInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ void EnumInfo::determineConstantNamePrefix(const clang::EnumDecl *decl) {
return;
}

// If there are no enumers, there is no prefix to compute.
// If there are no enumerators, there is no prefix to compute.
auto ec = decl->enumerator_begin(), ecEnd = decl->enumerator_end();
if (ec == ecEnd)
return;
Expand Down
4 changes: 2 additions & 2 deletions lib/ClangImporter/ImportName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ NameImporter::considerAsyncImport(
}

// Check whether the parameter itself has a name that indicates that
// it is a completion handelr.
// it is a completion handler.
if (isCompletionHandlerParamName(
params[completionHandlerParamIndex]->getName()))
break;
Expand Down Expand Up @@ -1678,7 +1678,7 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
}
}

// Spcial case: unnamed/anonymous fields.
// Special case: unnamed/anonymous fields.
if (auto field = dyn_cast<clang::FieldDecl>(D)) {
static_assert((clang::Decl::lastField - clang::Decl::firstField) == 2,
"update logic for new FieldDecl subclasses");
Expand Down
2 changes: 1 addition & 1 deletion lib/ClangImporter/ImportName.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ class NameImporter {
/// If \p action returns false, the current name will \e not be added to the
/// set of seen names.
///
/// The active name for \p activeVerion is always first, followed by the
/// The active name for \p activeVersion is always first, followed by the
/// other names in the order of
/// ImportNameVersion::forEachOtherImportNameVersion.
///
Expand Down
2 changes: 1 addition & 1 deletion lib/ClangImporter/ImportType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2121,7 +2121,7 @@ ImportedType ClangImporter::Implementation::importFunctionParamsAndReturnType(
shouldAllowNSUIntegerAsInt(isFromSystemModule, clangDecl);

// Only eagerly import the return type if it's not too expensive (the current
// huristic for that is if it's not a record type).
// heuristic for that is if it's not a record type).
ImportedType importedType;
ImportDiagnosticAdder addDiag(*this, clangDecl,
clangDecl->getSourceRange().getBegin());
Expand Down
2 changes: 1 addition & 1 deletion lib/ClangImporter/ImporterImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ struct PlatformAvailability {
bool isPlatformRelevant(StringRef platform) const;

/// Returns true when the given declaration with the given deprecation
/// should be inlucded in the cutoff of imported deprecated APIs marked
/// should be included in the cutoff of imported deprecated APIs marked
/// unavailable.
bool treatDeprecatedAsUnavailable(const clang::Decl *clangDecl,
const llvm::VersionTuple &version,
Expand Down
2 changes: 1 addition & 1 deletion test/ClangImporter/SceneKit_test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import SceneKit
import Foundation

// Test out some explicit renames of typedefs and globals, which are now new
// wrapper types with nestest values.
// wrapper types with nested values.
@available(macOS 10.11, *)
func testNestingRenames() {
let _ = SCNGeometrySourceSemantic.self
Expand Down
2 changes: 1 addition & 1 deletion test/ClangImporter/experimental_diagnostics_cmacros.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _ = INVALID_ARITHMETIC_1
// CHECK-NEXT: _ = INVALID_ARITHMETIC_1
// CHECK-NEXT: ^~~~~~~~~~~~~~~~~~~~
// CHECK-NEXT: macros.h:{{[0-9]+}}:9: note: macro 'INVALID_ARITHMETIC_1' not imported: structure not supported
// CHECK-NEXT: #define INVALID_ARITHMETIC_1 5 + INVALID_INTERGER_LITERAL_1
// CHECK-NEXT: #define INVALID_ARITHMETIC_1 5 + INVALID_INTEGER_LITERAL_1
// CHECK-NEXT: {{^}} ^

_ = INVALID_ARITHMETIC_2
Expand Down
2 changes: 1 addition & 1 deletion test/ClangImporter/experimental_eager_diagnostics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ import macros
// CHECK-NEXT: {{^}} ^

// CHECK: macros.h:{{[0-9]+}}:9: note: macro 'INVALID_ARITHMETIC_1' not imported: structure not supported
// CHECK-NEXT: #define INVALID_ARITHMETIC_1 5 + INVALID_INTERGER_LITERAL_1
// CHECK-NEXT: #define INVALID_ARITHMETIC_1 5 + INVALID_INTEGER_LITERAL_1
// CHECK-NEXT: {{^}} ^

// CHECK: macros.h:{{[0-9]+}}:9: note: macro 'INVALID_ARITHMETIC_2' not imported: structure not supported
Expand Down
2 changes: 1 addition & 1 deletion test/ClangImporter/objc_async_conformance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ConformsToSync : NSObject, Club {
///////
// selector conflicts

// attempting to satisfy the ObjC async requirement in two ways simultaenously
// attempting to satisfy the ObjC async requirement in two ways simultaneously
// is problematic due to a clash in selector names on this ObjC-compatible type
class SelectorConflict : NSObject, RequiredObserverOnlyCompletion {
func hello() async -> Bool { true } // expected-note {{method 'hello()' declared here}}
Expand Down
4 changes: 2 additions & 2 deletions test/ClangImporter/objc_direct.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Foo {
}
}

var otherthing = Foo() as AnyObject
var otherThing = Foo() as AnyObject

// We expect no error.
let _ = otherthing.directProtocolMethod()
let _ = otherThing.directProtocolMethod()
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
// ~~~~~~~~~~~~~~
//
// One might hope that this can be fixed by having the merge-modules step take a
// PCH as well as other steps in the compilation. That unfortuantely only
// PCH as well as other steps in the compilation. That unfortunately only
// inverts the problem, which resurfaces in the definition-order of Bar itself:
// an XRef to __ObjC.Bar gets serialized, and then _it_ can't be found during
// merge-modules, because the *last-read* defn of Bar -- the modular one, M.Bar
Expand Down
2 changes: 1 addition & 1 deletion test/ClangImporter/pch-bridging-header.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
// RUN: llvm-objdump --raw-clang-ast %t/pch3/*.pch | llvm-bcanalyzer -dump | %FileCheck %s -check-prefix=PERSISTENT
// PERSISTENT: ORIGINAL_FILE{{.*}}Inputs/sdk-bridging-header.h

// Test that -pch-disable-validation works in that it won't implicitely create a PCH
// Test that -pch-disable-validation works in that it won't implicitly create a PCH
// RUN: not %target-swift-frontend -typecheck %s -import-objc-header %S/Inputs/sdk-bridging-header.h -pch-output-dir %t/no-pch -pch-disable-validation 2>&1 | %FileCheck %s -check-prefix=NO-VALIDATION
// NO-VALIDATION: PCH file {{.*}} not found

Expand Down
2 changes: 1 addition & 1 deletion test/Inputs/clang-importer-sdk/usr/include/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ typedef unsigned okay_t;
#define FUNC_LIKE_MACRO_2(PARAM) PARAM

// Unsupported binary arithmetic
#define INVALID_ARITHMETIC_1 5 + INVALID_INTERGER_LITERAL_1
#define INVALID_ARITHMETIC_1 5 + INVALID_INTEGER_LITERAL_1
#define INVALID_ARITHMETIC_2 INVALID_INTEGER_LITERAL_1 + ADD_TWO
#define INVALID_ARITHMETIC_3 ADD_TWO + INVALID_INTEGER_LITERAL_1
#define INVALID_ARITHMETIC_4 \
Expand Down
4 changes: 2 additions & 2 deletions unittests/ClangImporter/ClangImporterTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ TEST(ClangImporterTest, emitPCHInMemory) {
swift::LangOptions langOpts;
langOpts.Target = llvm::Triple("x86_64", "apple", "darwin");
swift::SILOptions silOpts;
swift::TypeCheckerOptions typeckOpts;
swift::TypeCheckerOptions typecheckOpts;
INITIALIZE_LLVM();
swift::SearchPathOptions searchPathOpts;
swift::symbolgraphgen::SymbolGraphOptions symbolGraphOpts;
swift::SourceManager sourceMgr;
swift::DiagnosticEngine diags(sourceMgr);
std::unique_ptr<ASTContext> context(
ASTContext::get(langOpts, typeckOpts, silOpts, searchPathOpts, options,
ASTContext::get(langOpts, typecheckOpts, silOpts, searchPathOpts, options,
symbolGraphOpts, sourceMgr, diags));
auto importer = ClangImporter::create(*context);

Expand Down