Skip to content

Commit e8d1dce

Browse files
committed
Merge remote-tracking branch 'origin/main' into vplan-materialize-constant-vector-tc-tmp
2 parents 97043ee + ec1c73b commit e8d1dce

File tree

88 files changed

+1992
-391
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1992
-391
lines changed

clang/lib/Sema/SemaSwift.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ static bool isValidSwiftErrorResultType(QualType Ty) {
7272
return isValidSwiftContextType(Ty);
7373
}
7474

75+
static bool isValidSwiftContextName(StringRef ContextName) {
76+
// ContextName might be qualified, e.g. 'MyNamespace.MyStruct'.
77+
SmallVector<StringRef, 1> ContextNameComponents;
78+
ContextName.split(ContextNameComponents, '.');
79+
return all_of(ContextNameComponents, [&](StringRef Component) {
80+
return isValidAsciiIdentifier(Component);
81+
});
82+
}
83+
7584
void SemaSwift::handleAttrAttr(Decl *D, const ParsedAttr &AL) {
7685
if (AL.isInvalid() || AL.isUsedAsTypeAttr())
7786
return;
@@ -356,11 +365,11 @@ static bool validateSwiftFunctionName(Sema &S, const ParsedAttr &AL,
356365

357366
// Split at the first '.', if it exists, which separates the context name
358367
// from the base name.
359-
std::tie(ContextName, BaseName) = BaseName.split('.');
368+
std::tie(ContextName, BaseName) = BaseName.rsplit('.');
360369
if (BaseName.empty()) {
361370
BaseName = ContextName;
362371
ContextName = StringRef();
363-
} else if (ContextName.empty() || !isValidAsciiIdentifier(ContextName)) {
372+
} else if (ContextName.empty() || !isValidSwiftContextName(ContextName)) {
364373
S.Diag(Loc, diag::warn_attr_swift_name_invalid_identifier)
365374
<< AL << /*context*/ 1;
366375
return false;
@@ -584,11 +593,11 @@ bool SemaSwift::DiagnoseName(Decl *D, StringRef Name, SourceLocation Loc,
584593
!IsAsync) {
585594
StringRef ContextName, BaseName;
586595

587-
std::tie(ContextName, BaseName) = Name.split('.');
596+
std::tie(ContextName, BaseName) = Name.rsplit('.');
588597
if (BaseName.empty()) {
589598
BaseName = ContextName;
590599
ContextName = StringRef();
591-
} else if (!isValidAsciiIdentifier(ContextName)) {
600+
} else if (!isValidSwiftContextName(ContextName)) {
592601
Diag(Loc, diag::warn_attr_swift_name_invalid_identifier)
593602
<< AL << /*context*/ 1;
594603
return false;

clang/test/SemaObjCXX/attr-swift_name-cxx.mm

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,43 @@
11
// RUN: %clang_cc1 -verify -fsyntax-only -fobjc-arc -fblocks %s
22

3+
#define SWIFT_NAME(name) __attribute__((swift_name(name)))
34
#define SWIFT_ASYNC_NAME(name) __attribute__((__swift_async_name__(name)))
45

6+
namespace MyNS {
7+
struct NestedStruct {};
8+
}
9+
10+
void nestedStruct_method(MyNS::NestedStruct) SWIFT_NAME("MyNS.NestedStruct.method(self:)");
11+
void nestedStruct_methodConstRef(const MyNS::NestedStruct&) SWIFT_NAME("MyNS.NestedStruct.methodConstRef(self:)");
12+
void nestedStruct_invalidContext1(MyNS::NestedStruct) SWIFT_NAME(".MyNS.NestedStruct.invalidContext1(self:)"); // expected-warning {{'swift_name' attribute has invalid identifier for the context name}}
13+
void nestedStruct_invalidContext2(MyNS::NestedStruct) SWIFT_NAME("MyNS::NestedStruct.invalidContext2(self:)"); // expected-warning {{'swift_name' attribute has invalid identifier for the context name}}
14+
void nestedStruct_invalidContext3(MyNS::NestedStruct) SWIFT_NAME("::MyNS::NestedStruct.invalidContext3(self:)"); // expected-warning {{'swift_name' attribute has invalid identifier for the context name}}
15+
void nestedStruct_invalidContext4(MyNS::NestedStruct) SWIFT_NAME("MyNS..NestedStruct.invalidContext4(self:)"); // expected-warning {{'swift_name' attribute has invalid identifier for the context name}}
16+
void nestedStruct_invalidContext5(MyNS::NestedStruct) SWIFT_NAME("MyNS.NestedStruct.invalidContext5.(self:)"); // expected-warning {{'swift_name' attribute has invalid identifier for the base name}}
17+
void nestedStruct_invalidContext6(MyNS::NestedStruct) SWIFT_NAME("MyNS.NestedStruct::invalidContext6(self:)"); // expected-warning {{'swift_name' attribute has invalid identifier for the base name}}
18+
19+
namespace MyNS {
20+
namespace MyDeepNS {
21+
struct DeepNestedStruct {};
22+
}
23+
}
24+
25+
void deepNestedStruct_method(MyNS::MyDeepNS::DeepNestedStruct) SWIFT_NAME("MyNS.MyDeepNS.DeepNestedStruct.method(self:)");
26+
void deepNestedStruct_methodConstRef(const MyNS::MyDeepNS::DeepNestedStruct&) SWIFT_NAME("MyNS.MyDeepNS.DeepNestedStruct.methodConstRef(self:)");
27+
void deepNestedStruct_invalidContext(const MyNS::MyDeepNS::DeepNestedStruct&) SWIFT_NAME("MyNS::MyDeepNS::DeepNestedStruct.methodConstRef(self:)"); // expected-warning {{'swift_name' attribute has invalid identifier for the context name}}
28+
29+
typedef MyNS::MyDeepNS::DeepNestedStruct DeepNestedStructTypedef;
30+
31+
void deepNestedStructTypedef_method(DeepNestedStructTypedef) SWIFT_NAME("DeepNestedStructTypedef.method(self:)");
32+
void deepNestedStructTypedef_methodQualName(MyNS::MyDeepNS::DeepNestedStruct) SWIFT_NAME("DeepNestedStructTypedef.method(self:)");
33+
34+
struct TopLevelStruct {
35+
struct StructInStruct {};
36+
};
37+
38+
void structInStruct_method(TopLevelStruct::StructInStruct) SWIFT_NAME("TopLevelStruct.StructInStruct.method(self:)");
39+
void structInStruct_invalidContext(TopLevelStruct::StructInStruct) SWIFT_NAME("TopLevelStruct::StructInStruct.method(self:)"); // expected-warning {{'swift_name' attribute has invalid identifier for the context name}}
40+
541
typedef int (^CallbackTy)(void);
642

743
class CXXClass {

compiler-rt/lib/builtins/arm/aeabi_cdcmp.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ DEFINE_COMPILERRT_FUNCTION(__aeabi_cdcmple)
128128
msr APSR_nzcvq, ip
129129
#if defined(__ARM_FEATURE_PAC_DEFAULT)
130130
pop {r0-r3, r12, lr}
131-
bxaut r12, lr, sp
131+
PAC_RETURN
132132
#else
133133
pop {r0-r3}
134134
POP_PC()

compiler-rt/lib/builtins/arm/aeabi_cfcmp.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ DEFINE_COMPILERRT_FUNCTION(__aeabi_cfcmple)
128128
msr APSR_nzcvq, ip
129129
#if defined(__ARM_FEATURE_PAC_DEFAULT)
130130
pop {r0-r3, r12, lr}
131-
bxaut r12, lr, sp
131+
PAC_RETURN
132132
#else
133133
pop {r0-r3}
134134
POP_PC()

compiler-rt/lib/builtins/arm/aeabi_dcmp.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# define PROLOGUE PACBTI_LANDING SEPARATOR \
3030
push { r12, lr }
3131
# define EPILOGUE pop { r12, lr } SEPARATOR \
32-
bxaut r12, lr, sp
32+
PAC_RETURN
3333
#elif defined(__ARM_FEATURE_BTI_DEFAULT)
3434
# define PROLOGUE PACBTI_LANDING SEPARATOR \
3535
push { r4, lr }

compiler-rt/lib/builtins/arm/aeabi_fcmp.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# define PROLOGUE PACBTI_LANDING SEPARATOR \
3030
push { r12, lr }
3131
# define EPILOGUE pop { r12, lr } SEPARATOR \
32-
bxaut r12, lr, sp
32+
PAC_RETURN
3333
#elif defined(__ARM_FEATURE_BTI_DEFAULT)
3434
# define PROLOGUE PACBTI_LANDING SEPARATOR \
3535
push { r4, lr }

compiler-rt/lib/builtins/arm/aeabi_idivmod.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ DEFINE_COMPILERRT_FUNCTION(__aeabi_idivmod)
4949
add sp, sp, #4
5050
#if defined(__ARM_FEATURE_PAC_DEFAULT)
5151
pop { r12, lr }
52-
bxaut r12, lr, sp
52+
PAC_RETURN
5353
#else
5454
pop { pc }
5555
#endif

compiler-rt/lib/builtins/arm/aeabi_ldivmod.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ DEFINE_COMPILERRT_FUNCTION(__aeabi_ldivmod)
4545
add sp, sp, #16
4646
#if defined(__ARM_FEATURE_PAC_DEFAULT)
4747
pop {r6, r12, lr}
48-
bxaut r12, lr, sp
48+
PAC_RETURN
4949
#else
5050
pop {r6, pc}
5151
#endif

compiler-rt/lib/builtins/arm/aeabi_uidivmod.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ LOCAL_LABEL(case_denom_larger):
5656
add sp, sp, #4
5757
#if defined(__ARM_FEATURE_PAC_DEFAULT)
5858
pop { r12, lr }
59-
bxaut r12, lr, sp
59+
PAC_RETURN
6060
#else
6161
pop { pc }
6262
#endif

compiler-rt/lib/builtins/arm/aeabi_uldivmod.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ DEFINE_COMPILERRT_FUNCTION(__aeabi_uldivmod)
4545
add sp, sp, #16
4646
#if defined(__ARM_FEATURE_PAC_DEFAULT)
4747
pop {r6, r12, lr}
48-
bxaut r12, lr, sp
48+
PAC_RETURN
4949
#else
5050
pop {r6, pc}
5151
#endif

0 commit comments

Comments
 (0)