ychen created this revision. ychen added reviewers: aaron.ballman, erichkeane. Herald added a project: All. ychen requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
In the same spirit of da6187f566b7881cb <https://reviews.llvm.org/rGda6187f566b7881cb8350621aea9bd582de569b9>. This maintains compatibility with GCC. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D134507 Files: clang/lib/Sema/SemaTemplateDeduction.cpp clang/test/CodeGen/partial-order-variadic.cpp Index: clang/test/CodeGen/partial-order-variadic.cpp =================================================================== --- clang/test/CodeGen/partial-order-variadic.cpp +++ clang/test/CodeGen/partial-order-variadic.cpp @@ -1,5 +1,9 @@ -// 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 +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fclang-abi-compat=15 \ +// RUN: -DCLANG_ABI_COMPAT=15 %s -emit-llvm -disable-llvm-passes -o - \ +// RUN: | FileCheck %s --check-prefixes=CHECK,BEFORE-15 +// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -emit-llvm \ +// RUN: -disable-llvm-passes -o - \ +// RUN: | FileCheck %s --check-prefixes=CHECK,AFTER-15 // CHECK: %struct.S = type { i8 } // CHECK: @_Z2ggiRi @@ -18,7 +22,14 @@ template<class T> void h(const T&) {} template void h(int*); -#if !defined(CLANG_ABI_COMPAT) +#if defined(CLANG_ABI_COMPAT) + +// BEFORE-15: _Z2g2IiJEEvT_DpT0_ +template <class T, class... U> void g2(T, U...) {}; +template <class T> void g2(T, int x = 0) {}; +template void g2(int); + +#else // AFTER-15: @_Z1fIiJEEvPT_DpT0_ template<class T, class... U> void f(T*, U...){} Index: clang/lib/Sema/SemaTemplateDeduction.cpp =================================================================== --- clang/lib/Sema/SemaTemplateDeduction.cpp +++ clang/lib/Sema/SemaTemplateDeduction.cpp @@ -5216,6 +5216,10 @@ bool Variadic1 = NumParams1 && FD1->parameters().back()->isParameterPack(); bool Variadic2 = NumParams2 && FD2->parameters().back()->isParameterPack(); if (Variadic1 != Variadic2) { + bool ClangABICompat15 = Context.getLangOpts().getClangABICompat() <= + LangOptions::ClangABI::Ver15; + if (ClangABICompat15) + return Variadic1 ? FT2 : FT1; if (Variadic1 && NumParams1 > NumParams2) return FT2; if (Variadic2 && NumParams2 > NumParams1)
Index: clang/test/CodeGen/partial-order-variadic.cpp =================================================================== --- clang/test/CodeGen/partial-order-variadic.cpp +++ clang/test/CodeGen/partial-order-variadic.cpp @@ -1,5 +1,9 @@ -// 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 +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fclang-abi-compat=15 \ +// RUN: -DCLANG_ABI_COMPAT=15 %s -emit-llvm -disable-llvm-passes -o - \ +// RUN: | FileCheck %s --check-prefixes=CHECK,BEFORE-15 +// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -emit-llvm \ +// RUN: -disable-llvm-passes -o - \ +// RUN: | FileCheck %s --check-prefixes=CHECK,AFTER-15 // CHECK: %struct.S = type { i8 } // CHECK: @_Z2ggiRi @@ -18,7 +22,14 @@ template<class T> void h(const T&) {} template void h(int*); -#if !defined(CLANG_ABI_COMPAT) +#if defined(CLANG_ABI_COMPAT) + +// BEFORE-15: _Z2g2IiJEEvT_DpT0_ +template <class T, class... U> void g2(T, U...) {}; +template <class T> void g2(T, int x = 0) {}; +template void g2(int); + +#else // AFTER-15: @_Z1fIiJEEvPT_DpT0_ template<class T, class... U> void f(T*, U...){} Index: clang/lib/Sema/SemaTemplateDeduction.cpp =================================================================== --- clang/lib/Sema/SemaTemplateDeduction.cpp +++ clang/lib/Sema/SemaTemplateDeduction.cpp @@ -5216,6 +5216,10 @@ bool Variadic1 = NumParams1 && FD1->parameters().back()->isParameterPack(); bool Variadic2 = NumParams2 && FD2->parameters().back()->isParameterPack(); if (Variadic1 != Variadic2) { + bool ClangABICompat15 = Context.getLangOpts().getClangABICompat() <= + LangOptions::ClangABI::Ver15; + if (ClangABICompat15) + return Variadic1 ? FT2 : FT1; if (Variadic1 && NumParams1 > NumParams2) return FT2; if (Variadic2 && NumParams2 > NumParams1)
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits