r374967 - [Concepts] ConceptSpecializationExprs mangling
Saar Raz via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 15 19:33:41 PDT 2019
Author: saar.raz
Date: Tue Oct 15 19:33:41 2019
New Revision: 374967
URL: http://llvm.org/viewvc/llvm-project?rev=374967&view=rev
Log:
[Concepts] ConceptSpecializationExprs mangling
Implement mangling for CSEs to match regular template-ids.
Reviewed as part of D41569.
Added:
cfe/trunk/test/CodeGenCXX/mangle-concept.cpp
Modified:
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=374967&r1=374966&r2=374967&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Tue Oct 15 19:33:41 2019
@@ -969,7 +969,7 @@ void CXXNameMangler::mangleUnscopedTempl
assert(!AdditionalAbiTags &&
"template template param cannot have abi tags");
mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
- } else if (isa<BuiltinTemplateDecl>(ND)) {
+ } else if (isa<BuiltinTemplateDecl>(ND) || isa<ConceptDecl>(ND)) {
mangleUnscopedName(ND, AdditionalAbiTags);
} else {
mangleUnscopedName(ND->getTemplatedDecl(), AdditionalAbiTags);
@@ -1890,7 +1890,7 @@ void CXXNameMangler::mangleTemplatePrefi
mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
} else {
manglePrefix(getEffectiveDeclContext(ND), NoFunction);
- if (isa<BuiltinTemplateDecl>(ND))
+ if (isa<BuiltinTemplateDecl>(ND) || isa<ConceptDecl>(ND))
mangleUnqualifiedName(ND, nullptr);
else
mangleUnqualifiedName(ND->getTemplatedDecl(), nullptr);
@@ -3658,7 +3658,6 @@ recurse:
case Expr::ConvertVectorExprClass:
case Expr::StmtExprClass:
case Expr::TypeTraitExprClass:
- case Expr::ConceptSpecializationExprClass:
case Expr::ArrayTypeTraitExprClass:
case Expr::ExpressionTraitExprClass:
case Expr::VAArgExprClass:
@@ -4168,6 +4167,18 @@ recurse:
mangleExpression(cast<ParenExpr>(E)->getSubExpr(), Arity);
break;
+
+ case Expr::ConceptSpecializationExprClass: {
+ // <expr-primary> ::= L <mangled-name> E # external name
+ Out << "L_Z";
+ auto *CSE = cast<ConceptSpecializationExpr>(E);
+ mangleTemplateName(CSE->getNamedConcept(),
+ CSE->getTemplateArguments().data(),
+ CSE->getTemplateArguments().size());
+ Out << 'E';
+ break;
+ }
+
case Expr::DeclRefExprClass:
mangleDeclRefExpr(cast<DeclRefExpr>(E)->getDecl());
break;
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=374967&r1=374966&r2=374967&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Tue Oct 15 19:33:41 2019
@@ -4302,7 +4302,7 @@ ExprResult Sema::BuildTemplateIdExpr(con
TemplateKWLoc, TemplateArgs);
}
- if (R.getAsSingle<ConceptDecl>() && !AnyDependentArguments()) {
+ if (R.getAsSingle<ConceptDecl>()) {
return CheckConceptTemplateId(SS, TemplateKWLoc,
R.getLookupNameInfo().getBeginLoc(),
R.getFoundDecl(),
Added: cfe/trunk/test/CodeGenCXX/mangle-concept.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-concept.cpp?rev=374967&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-concept.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/mangle-concept.cpp Tue Oct 15 19:33:41 2019
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -verify -Wno-return-type -Wno-main -std=c++2a -fconcepts-ts -emit-llvm -triple %itanium_abi_triple -o - %s | FileCheck %s
+// expected-no-diagnostics
+
+namespace test1 {
+template <bool> struct S {};
+template <typename> concept C = true;
+template <typename T = int> S<C<T>> f0() { return S<C<T>>{}; }
+template S<C<int>> f0<>();
+// CHECK: void @_ZN5test12f0IiEENS_1SIXL_ZNS_1CIT_EEEEEEv()
+}
+
+template <bool> struct S {};
+template <typename> concept C = true;
+template <typename T = int> S<C<T>> f0() { return S<C<T>>{}; }
+template S<C<int>> f0<>();
+// CHECK: void @_Z2f0IiE1SIXL_Z1CIT_EEEEv()
\ No newline at end of file
More information about the cfe-commits
mailing list