[clang] 088ba8e - [Clang] follow-up D128745, use ClangABICompat15 instead of ClangABICompat14
Yuanfang Chen via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 23 10:45:55 PDT 2022
Author: Yuanfang Chen
Date: 2022-08-23T10:45:35-07:00
New Revision: 088ba8efeb4921deb49534714ddefb14a91afe46
URL: https://github.com/llvm/llvm-project/commit/088ba8efeb4921deb49534714ddefb14a91afe46
DIFF: https://github.com/llvm/llvm-project/commit/088ba8efeb4921deb49534714ddefb14a91afe46.diff
LOG: [Clang] follow-up D128745, use ClangABICompat15 instead of ClangABICompat14
Since the patch missed release 15.x and will be included in release 16.x. Also, simplify related tests.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D132414
Added:
Modified:
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/LangOptions.h
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/test/CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp
clang/test/CodeGen/partial-order-variadic.cpp
Removed:
################################################################################
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0ba35edd5dcb7..64a2ce2bb2b8b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -144,7 +144,7 @@ C2x Feature Support
C++ Language Changes in Clang
-----------------------------
-- Implemented DR692, DR1395 and DR1432. Use the ``-fclang-abi-compat=14`` option
+- Implemented DR692, DR1395 and DR1432. Use the ``-fclang-abi-compat=15`` option
to get the old partial ordering behavior regarding packs.
C++20 Feature Support
diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h
index 3a1c13dd72568..dd2a7920a5f17 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -223,6 +223,11 @@ class LangOptions : public LangOptionsBase {
/// implicit declaration.
Ver14,
+ /// Attempt to be ABI-compatible with code generated by Clang 15.0.x.
+ /// This causes clang to:
+ /// - Reverse the implementation for DR692, DR1395 and DR1432.
+ Ver15,
+
/// Conform to the underlying platform's C and C++ ABIs as closely
/// as we can.
Latest
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 6b5baa75fd27a..574514bdd0b0a 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3522,6 +3522,8 @@ void CompilerInvocation::GenerateLangArgs(const LangOptions &Opts,
GenerateArg(Args, OPT_fclang_abi_compat_EQ, "12.0", SA);
else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver14)
GenerateArg(Args, OPT_fclang_abi_compat_EQ, "14.0", SA);
+ else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver15)
+ GenerateArg(Args, OPT_fclang_abi_compat_EQ, "15.0", SA);
if (Opts.getSignReturnAddressScope() ==
LangOptions::SignReturnAddressScopeKind::All)
@@ -4014,6 +4016,8 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.setClangABICompat(LangOptions::ClangABI::Ver12);
else if (Major <= 14)
Opts.setClangABICompat(LangOptions::ClangABI::Ver14);
+ else if (Major <= 15)
+ Opts.setClangABICompat(LangOptions::ClangABI::Ver15);
} else if (Ver != "latest") {
Diags.Report(diag::err_drv_invalid_value)
<< A->getAsString(Args) << A->getValue();
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 99119bcb2e4e6..84c4a191ec327 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1107,9 +1107,9 @@ DeduceTemplateArguments(Sema &S,
// During partial ordering, if Ai was originally a function parameter pack:
// - if P does not contain a function parameter type corresponding to Ai then
// Ai is ignored;
- bool ClangABICompat14 = S.Context.getLangOpts().getClangABICompat() <=
- LangOptions::ClangABI::Ver14;
- if (!ClangABICompat14 && PartialOrdering && ArgIdx + 1 == NumArgs &&
+ bool ClangABICompat15 = S.Context.getLangOpts().getClangABICompat() <=
+ LangOptions::ClangABI::Ver15;
+ if (!ClangABICompat15 && PartialOrdering && ArgIdx + 1 == NumArgs &&
isa<PackExpansionType>(Args[ArgIdx]))
return Sema::TDK_Success;
@@ -2445,8 +2445,8 @@ static bool isSameTemplateArg(ASTContext &Context,
if (X.getKind() != Y.getKind())
return false;
- bool ClangABICompat14 =
- Context.getLangOpts().getClangABICompat() <= LangOptions::ClangABI::Ver14;
+ bool ClangABICompat15 =
+ Context.getLangOpts().getClangABICompat() <= LangOptions::ClangABI::Ver15;
switch (X.getKind()) {
case TemplateArgument::Null:
@@ -2480,7 +2480,7 @@ static bool isSameTemplateArg(ASTContext &Context,
}
case TemplateArgument::Pack:
- if (ClangABICompat14) {
+ if (ClangABICompat15) {
if (X.pack_size() != Y.pack_size())
return false;
@@ -5464,9 +5464,9 @@ getMoreSpecialized(Sema &S, QualType T1, QualType T2, TemplateLikeDecl *P1,
return nullptr;
if (Better1 && Better2) {
- bool ClangABICompat14 = S.Context.getLangOpts().getClangABICompat() <=
- LangOptions::ClangABI::Ver14;
- if (!ClangABICompat14) {
+ bool ClangABICompat15 = S.Context.getLangOpts().getClangABICompat() <=
+ LangOptions::ClangABI::Ver15;
+ if (!ClangABICompat15) {
// Consider this a fix for CWG1432. Similar to the fix for CWG1395.
auto *TST1 = T1->castAs<TemplateSpecializationType>();
auto *TST2 = T2->castAs<TemplateSpecializationType>();
diff --git a/clang/test/CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp b/clang/test/CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp
index 52fbd94574229..e3726bd32fb23 100644
--- a/clang/test/CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp
+++ b/clang/test/CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fclang-abi-compat=15.0 -std=c++11 -fsyntax-only -verify %s
template<int ...Values> struct X1;
diff --git a/clang/test/CodeGen/partial-order-variadic.cpp b/clang/test/CodeGen/partial-order-variadic.cpp
index 9a366c83e222c..a10cd6812f988 100644
--- a/clang/test/CodeGen/partial-order-variadic.cpp
+++ b/clang/test/CodeGen/partial-order-variadic.cpp
@@ -1,62 +1,33 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14 %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s --check-prefix=CHECK-14
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s
-
-#if defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 14
-
-// CHECK-14: %"struct.temp_func_order_example3::S" = type { i8 }
-
-// CHECK-14: define dso_local void @_ZN24temp_func_order_example31hEi(i32 noundef %i)
-// CHECK-14-NEXT: entry:
-// CHECK-14-NEXT: %i.addr = alloca i32, align 4
-// CHECK-14-NEXT: %r = alloca ptr, align 8
-// CHECK-14-NEXT: %a = alloca %"struct.temp_func_order_example3::S", align 1
-// CHECK-14-NEXT: store i32 %i, ptr %i.addr, align 4
-// CHECK-14-NEXT: %call = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN24temp_func_order_example31gIiJEEERiPT_DpT0_(ptr noundef %i.addr)
-// CHECK-14-NEXT: store ptr %call, ptr %r, align 8
-// CHECK-14-NEXT: ret void
-
-namespace temp_func_order_example3 {
- template <typename T, typename... U> int &g(T *, U...);
- template <typename T> void g(T);
-
- template <typename T, typename... Ts> struct S;
- template <typename T> struct S<T> {};
-
- void h(int i) {
- int &r = g(&i);
- S<int> a;
- }
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15 %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s --check-prefixes=CHECK,AFTER-15
+
+// CHECK: %struct.S = type { i8 }
+// CHECK: @_Z2ggiRi
+// CHECK: @_Z1gIiJEERiPT_DpT0_
+template <typename T, typename... U> int &g(T *, U...);
+template <typename T> void g(T);
+template <typename T, typename... Ts> struct S;
+template <typename T> struct S<T> {};
+void gg(int i, int &r) {
+ r = g(&i);
+ S<int> a;
}
-#else
+// CHECK: @_Z1hIJiEEvDpPT_
+template<class ...T> void h(T*...) {}
+template<class T> void h(const T&) {}
+template void h(int*);
-// CHECK: %"struct.temp_deduct_type_example1::A" = type { i8 }
+#if !defined(CLANG_ABI_COMPAT)
-// CHECK: $_ZN25temp_deduct_type_example31fIiJEEEvPT_DpT0_ = comdat any
+// AFTER-15: @_Z1fIiJEEvPT_DpT0_
+template<class T, class... U> void f(T*, U...){}
+template<class T> void f(T){}
+template void f(int*);
-// CHECK: define dso_local void @_ZN25temp_deduct_type_example11fEv()
-// CHECK-NEXT: entry:
-// CHECK-NEXT: %a = alloca %"struct.temp_deduct_type_example1::A", align 1
-// CHECK-NEXT: ret void
-
-// CHECK: define weak_odr void @_ZN25temp_deduct_type_example31fIiJEEEvPT_DpT0_(ptr noundef %0)
-// CHECK-NEXT: entry:
-// CHECK-NEXT: %.addr = alloca ptr, align 8
-// CHECK-NEXT: store ptr %0, ptr %.addr, align 8
-// CHECK-NEXT: ret void
-
-namespace temp_deduct_type_example1 {
- template<class T, class... U> struct A;
- template<class T1, class T2, class... U> struct A<T1,T2*,U...> {};
- template<class T1, class T2> struct A<T1,T2>;
- template struct A<int, int*>;
- void f() { A<int, int*> a; }
-}
-
-namespace temp_deduct_type_example3 {
- template<class T, class... U> void f(T*, U...){}
- template<class T> void f(T){}
- template void f(int*);
-}
+template<class T, class... U> struct A;
+template<class T1, class T2, class... U> struct A<T1,T2*,U...> {};
+template<class T1, class T2> struct A<T1,T2>;
+template struct A<int, int*>;
#endif
More information about the cfe-commits
mailing list