summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaar Raz <saar@raz.email>2019-10-16 02:33:41 +0000
committerSaar Raz <saar@raz.email>2019-10-16 02:33:41 +0000
commit65608d476635681ff244878e4df11daab3160791 (patch)
treee57a78aab2226c3e3b64b1c3fb16a5d3b0c37a40
parenta5f406013645696985998bdaf1d4d85c95a280dd (diff)
downloadclang-65608d476635681ff244878e4df11daab3160791.tar.gz
[Concepts] ConceptSpecializationExprs mangling
Implement mangling for CSEs to match regular template-ids. Reviewed as part of D41569. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374967 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AST/ItaniumMangle.cpp17
-rw-r--r--lib/Sema/SemaTemplate.cpp2
-rw-r--r--test/CodeGenCXX/mangle-concept.cpp16
3 files changed, 31 insertions, 4 deletions
diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp
index 8e3ad4c266..534a92d2cb 100644
--- a/lib/AST/ItaniumMangle.cpp
+++ b/lib/AST/ItaniumMangle.cpp
@@ -969,7 +969,7 @@ void CXXNameMangler::mangleUnscopedTemplateName(
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::mangleTemplatePrefix(const TemplateDecl *ND,
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;
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index 2871511466..09cc525837 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -4302,7 +4302,7 @@ ExprResult Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS,
TemplateKWLoc, TemplateArgs);
}
- if (R.getAsSingle<ConceptDecl>() && !AnyDependentArguments()) {
+ if (R.getAsSingle<ConceptDecl>()) {
return CheckConceptTemplateId(SS, TemplateKWLoc,
R.getLookupNameInfo().getBeginLoc(),
R.getFoundDecl(),
diff --git a/test/CodeGenCXX/mangle-concept.cpp b/test/CodeGenCXX/mangle-concept.cpp
new file mode 100644
index 0000000000..8f6d8171ab
--- /dev/null
+++ b/test/CodeGenCXX/mangle-concept.cpp
@@ -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