aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard@metafoo.co.uk>2023-09-12 18:53:54 -0700
committerRichard Smith <richard@metafoo.co.uk>2023-09-20 12:38:15 -0700
commit4b163e343cfa54c8d55c9da73c70d58f55ea9df2 (patch)
treef7a4a25c0d82dba24434851d5731d5e6f0579c7a /clang/lib/Frontend/CompilerInvocation.cpp
parent5d95d27e50c1f5ce4803039d942ff3c25401c77f (diff)
downloadllvm-4b163e343cfa54c8d55c9da73c70d58f55ea9df2.zip
llvm-4b163e343cfa54c8d55c9da73c70d58f55ea9df2.tar.gz
llvm-4b163e343cfa54c8d55c9da73c70d58f55ea9df2.tar.bz2
Implement mangling rules for C++20 concepts and requires-expressions.
This implements proposals from: - https://github.com/itanium-cxx-abi/cxx-abi/issues/24: mangling for constraints, requires-clauses, requires-expressions. - https://github.com/itanium-cxx-abi/cxx-abi/issues/31: requires-clauses and template parameters in a lambda expression are mangled into the <lambda-sig>. - https://github.com/itanium-cxx-abi/cxx-abi/issues/47 (STEP 3): mangling for template argument is prefixed by mangling of template parameter declaration if it's not "obvious", for example because the template parameter is constrained (we already implemented STEP 1 and STEP 2). This changes the manglings for a few cases: - Functions and function templates with constraints. - Function templates with template parameters with deduced types: `typename<auto N> void f();` - Function templates with template template parameters where the argument has a different template-head: `template<template<typename...T>> void f(); f<std::vector>();` In each case where a mangling changed, the change fixes a mangling collision. Note that only function templates are affected, not class templates or variable templates, and only new constructs (template parameters with deduced types, constrained templates) and esoteric constructs (templates with template template parameters with non-matching template template arguments, most of which Clang still does not accept by default due to `-frelaxed-template-template-args` not being enabled by default), so the risk to ABI stability from this change is relatively low. Nonetheless, `-fclang-abi-compat=17` can be used to restore the old manglings for cases which we could successfully but incorrectly mangle before. Fixes #48216, #49884, #61273 Reviewed By: erichkeane, #libc_abi Differential Revision: https://reviews.llvm.org/D147655
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp36
1 files changed, 27 insertions, 9 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index ffb4f30..9293b91 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3549,24 +3549,40 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts,
for (const std::string &F : Opts.NoSanitizeFiles)
GenerateArg(Consumer, OPT_fsanitize_ignorelist_EQ, F);
- if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver3_8)
+ switch (Opts.getClangABICompat()) {
+ case LangOptions::ClangABI::Ver3_8:
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "3.8");
- else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver4)
+ break;
+ case LangOptions::ClangABI::Ver4:
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "4.0");
- else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver6)
+ break;
+ case LangOptions::ClangABI::Ver6:
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "6.0");
- else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver7)
+ break;
+ case LangOptions::ClangABI::Ver7:
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "7.0");
- else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver9)
+ break;
+ case LangOptions::ClangABI::Ver9:
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "9.0");
- else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver11)
+ break;
+ case LangOptions::ClangABI::Ver11:
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "11.0");
- else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver12)
+ break;
+ case LangOptions::ClangABI::Ver12:
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "12.0");
- else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver14)
+ break;
+ case LangOptions::ClangABI::Ver14:
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "14.0");
- else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver15)
+ break;
+ case LangOptions::ClangABI::Ver15:
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "15.0");
+ break;
+ case LangOptions::ClangABI::Ver17:
+ GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "17.0");
+ break;
+ case LangOptions::ClangABI::Latest:
+ break;
+ }
if (Opts.getSignReturnAddressScope() ==
LangOptions::SignReturnAddressScopeKind::All)
@@ -4052,6 +4068,8 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.setClangABICompat(LangOptions::ClangABI::Ver14);
else if (Major <= 15)
Opts.setClangABICompat(LangOptions::ClangABI::Ver15);
+ else if (Major <= 17)
+ Opts.setClangABICompat(LangOptions::ClangABI::Ver17);
} else if (Ver != "latest") {
Diags.Report(diag::err_drv_invalid_value)
<< A->getAsString(Args) << A->getValue();