Skip to content

Commit 9f81bca

Browse files
committed
Formatting
1 parent 3682ca0 commit 9f81bca

File tree

3 files changed

+37
-26
lines changed

3 files changed

+37
-26
lines changed

lib/AST/ClangTypeConverter.cpp

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,8 @@ ClangTypeConverter::visitBoundGenericType(BoundGenericType *type) {
565565
}
566566

567567
if (auto kind = classifyPointer(type))
568-
return convertPointerType(argType, kind.value(), /*templateArgument=*/false);
568+
return convertPointerType(argType, kind.value(),
569+
/*templateArgument=*/false);
569570

570571
if (auto width = classifySIMD(type))
571572
return convertSIMDType(argType, width.value(), /*templateArgument=*/false);
@@ -576,8 +577,9 @@ ClangTypeConverter::visitBoundGenericType(BoundGenericType *type) {
576577
clang::QualType ClangTypeConverter::convertSIMDType(CanType scalarType,
577578
unsigned width,
578579
bool templateArgument) {
579-
clang::QualType scalarTy = templateArgument ? convertTemplateArgument(scalarType)
580-
: convert(scalarType);
580+
clang::QualType scalarTy = templateArgument
581+
? convertTemplateArgument(scalarType)
582+
: convert(scalarType);
581583
if (scalarTy.isNull())
582584
return clang::QualType();
583585

@@ -599,13 +601,15 @@ clang::QualType ClangTypeConverter::convertPointerType(CanType pointeeType,
599601
LLVM_FALLTHROUGH;
600602

601603
case PointerKind::UnsafeMutablePointer: {
602-
auto clangTy = templateArgument ? convertTemplateArgument(pointeeType) : convert(pointeeType);
604+
auto clangTy = templateArgument ? convertTemplateArgument(pointeeType)
605+
: convert(pointeeType);
603606
if (clangTy.isNull())
604607
return clang::QualType();
605608
return ClangASTContext.getPointerType(clangTy);
606609
}
607610
case PointerKind::UnsafePointer: {
608-
auto clangTy = templateArgument ? convertTemplateArgument(pointeeType) : convert(pointeeType);
611+
auto clangTy = templateArgument ? convertTemplateArgument(pointeeType)
612+
: convert(pointeeType);
609613
if (clangTy.isNull())
610614
return clang::QualType();
611615
return ClangASTContext.getPointerType(clangTy.withConst());
@@ -958,8 +962,11 @@ clang::QualType ClangTypeConverter::convertTemplateArgument(Type type) {
958962
if (boundGenericType->getDecl()->isOptionalDecl()) {
959963
if (auto kind = classifyPointer(argType))
960964
return withCache([&]() {
961-
auto pointeeType = argType->getAs<BoundGenericType>()->getGenericArgs()[0]->getCanonicalType();
962-
return convertPointerType(pointeeType, kind.value(), /*templateArgument=*/true);
965+
auto pointeeType = argType->getAs<BoundGenericType>()
966+
->getGenericArgs()[0]
967+
->getCanonicalType();
968+
return convertPointerType(pointeeType, kind.value(),
969+
/*templateArgument=*/true);
963970
});
964971

965972
// Arbitrary optional types are not (yet) supported
@@ -968,12 +975,14 @@ clang::QualType ClangTypeConverter::convertTemplateArgument(Type type) {
968975

969976
if (auto kind = classifyPointer(boundGenericType))
970977
return withCache([&]() {
971-
return convertPointerType(argType, kind.value(), /*templateArgument=*/true);
978+
return convertPointerType(argType, kind.value(),
979+
/*templateArgument=*/true);
972980
});
973981

974982
if (auto width = classifySIMD(boundGenericType))
975983
return withCache([&]() {
976-
return convertSIMDType(argType, width.value(), /*templateArgument=*/true);
984+
return convertSIMDType(argType, width.value(),
985+
/*templateArgument=*/true);
977986
});
978987

979988
return clang::QualType();
@@ -1025,20 +1034,22 @@ ClangTypeConverter::getClangTemplateArguments(
10251034
return errorInfo;
10261035
}
10271036

1028-
std::optional<ClangTypeConverter::PointerKind> ClangTypeConverter::classifyPointer(Type type) {
1037+
std::optional<ClangTypeConverter::PointerKind>
1038+
ClangTypeConverter::classifyPointer(Type type) {
10291039
auto generic = type->getAs<BoundGenericType>();
10301040
if (!generic || generic->getGenericArgs().size() != 1)
10311041
// Must have got something other than a *Pointer<T>
10321042
return std::nullopt;
10331043

1034-
return llvm::StringSwitch<std::optional<PointerKind>>(generic->getDecl()->getName().str())
1035-
.Case("UnsafeMutablePointer", PointerKind::UnsafeMutablePointer)
1036-
.Case("UnsafePointer", PointerKind::UnsafePointer)
1037-
.Case("AutoreleasingUnsafeMutablePointer",
1038-
PointerKind::AutoreleasingUnsafeMutablePointer)
1039-
.Case("Unmanaged", PointerKind::Unmanaged)
1040-
.Case("CFunctionPointer", PointerKind::CFunctionPointer)
1041-
.Default(std::nullopt);
1044+
return llvm::StringSwitch<std::optional<PointerKind>>(
1045+
generic->getDecl()->getName().str())
1046+
.Case("UnsafeMutablePointer", PointerKind::UnsafeMutablePointer)
1047+
.Case("UnsafePointer", PointerKind::UnsafePointer)
1048+
.Case("AutoreleasingUnsafeMutablePointer",
1049+
PointerKind::AutoreleasingUnsafeMutablePointer)
1050+
.Case("Unmanaged", PointerKind::Unmanaged)
1051+
.Case("CFunctionPointer", PointerKind::CFunctionPointer)
1052+
.Default(std::nullopt);
10421053
}
10431054

10441055
std::optional<unsigned> ClangTypeConverter::classifySIMD(Type type) {
@@ -1051,7 +1062,7 @@ std::optional<unsigned> ClangTypeConverter::classifySIMD(Type type) {
10511062
if (!name.starts_with("SIMD"))
10521063
return std::nullopt;
10531064
name.consume_front("SIMD");
1054-
1065+
10551066
unsigned width;
10561067
if (/*failed to*/ name.getAsInteger<unsigned>(10, width))
10571068
return std::nullopt;

lib/AST/ClangTypeConverter.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,11 @@ class ClangTypeConverter :
120120

121121
clang::QualType convertClangDecl(Type type, const clang::Decl *decl);
122122

123-
clang::QualType convertSIMDType(CanType scalarType, unsigned width, bool templateArgument);
123+
clang::QualType convertSIMDType(CanType scalarType, unsigned width,
124+
bool templateArgument);
124125

125-
clang::QualType convertPointerType(CanType pointeeType, PointerKind kind, bool templateArgument);
126+
clang::QualType convertPointerType(CanType pointeeType, PointerKind kind,
127+
bool templateArgument);
126128

127129
void registerExportedClangDecl(Decl *swiftDecl,
128130
const clang::Decl *clangDecl);

test/Interop/Cxx/templates/Inputs/function-templates.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,9 @@ struct CxxClass {
6161
void method() {}
6262
};
6363

64-
struct
65-
__attribute__((swift_attr("import_reference")))
66-
__attribute__((swift_attr("retain:immortal")))
67-
__attribute__((swift_attr("release:immortal")))
68-
FRT {
64+
struct __attribute__((swift_attr("import_reference")))
65+
__attribute__((swift_attr("retain:immortal")))
66+
__attribute__((swift_attr("release:immortal"))) FRT {
6967
int x;
7068
};
7169

0 commit comments

Comments
 (0)