r275190 - [ItaniumMangle] Correctly mangle BuiltinTemplateDecls
David Majnemer via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 12 09:48:18 PDT 2016
Author: majnemer
Date: Tue Jul 12 11:48:17 2016
New Revision: 275190
URL: http://llvm.org/viewvc/llvm-project?rev=275190&view=rev
Log:
[ItaniumMangle] Correctly mangle BuiltinTemplateDecls
A BuiltinTemplateDecl has no underlying templated decl and as such they
cannot be relied upon for mangling. The ItaniumMangler had some bugs
here which lead to crashes.
This fixes PR28519.
Modified:
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-template.cpp
Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=275190&r1=275189&r2=275190&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Tue Jul 12 11:48:17 2016
@@ -910,6 +910,8 @@ void CXXNameMangler::mangleUnscopedTempl
assert(!AdditionalAbiTags &&
"template template param cannot have abi tags");
mangleTemplateParameter(TTP->getIndex());
+ } else if (isa<BuiltinTemplateDecl>(ND)) {
+ mangleUnscopedName(ND, AdditionalAbiTags);
} else {
mangleUnscopedName(ND->getTemplatedDecl(), AdditionalAbiTags);
}
@@ -1715,7 +1717,10 @@ void CXXNameMangler::mangleTemplatePrefi
mangleTemplateParameter(TTP->getIndex());
} else {
manglePrefix(getEffectiveDeclContext(ND), NoFunction);
- mangleUnqualifiedName(ND->getTemplatedDecl(), nullptr);
+ if (isa<BuiltinTemplateDecl>(ND))
+ mangleUnqualifiedName(ND, nullptr);
+ else
+ mangleUnqualifiedName(ND->getTemplatedDecl(), nullptr);
}
addSubstitution(ND);
Modified: cfe/trunk/test/CodeGenCXX/mangle-template.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-template.cpp?rev=275190&r1=275189&r2=275190&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-template.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-template.cpp Tue Jul 12 11:48:17 2016
@@ -201,3 +201,14 @@ namespace test14 {
int call(bool b) { return inl<void>(b); }
}
+
+namespace std {
+template <class _Tp, _Tp...> struct integer_sequence {};
+}
+
+namespace test15 {
+template <int N>
+__make_integer_seq<std::integer_sequence, int, N> make() {}
+template __make_integer_seq<std::integer_sequence, int, 5> make<5>();
+// CHECK: define weak_odr void @_ZN6test154makeILi5EEE18__make_integer_seqISt16integer_sequenceiXT_EEv(
+}
More information about the cfe-commits
mailing list