[cfe-commits] r104675 - in /cfe/trunk: lib/CodeGen/Mangle.cpp test/CodeGenCXX/mangle-subst-std.cpp
Douglas Gregor
dgregor at apple.com
Tue May 25 22:11:13 PDT 2010
Author: dgregor
Date: Wed May 26 00:11:13 2010
New Revision: 104675
URL: http://llvm.org/viewvc/llvm-project?rev=104675&view=rev
Log:
Be sure to use the standard substitutions when mangling the names of
vtables, VTTs, and construction vtables. Fixes PR7201.
Modified:
cfe/trunk/lib/CodeGen/Mangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-subst-std.cpp
Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=104675&r1=104674&r2=104675&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Wed May 26 00:11:13 2010
@@ -108,7 +108,8 @@
void mangleFunctionEncoding(const FunctionDecl *FD);
void mangleName(const NamedDecl *ND);
void mangleType(QualType T);
-
+ void mangleNameOrStandardSubstitution(const NamedDecl *ND);
+
private:
bool mangleSubstitution(const NamedDecl *ND);
bool mangleSubstitution(QualType T);
@@ -1025,6 +1026,11 @@
addSubstitution(T);
}
+void CXXNameMangler::mangleNameOrStandardSubstitution(const NamedDecl *ND) {
+ if (!mangleStandardSubstitution(ND))
+ mangleName(ND);
+}
+
void CXXNameMangler::mangleType(const BuiltinType *T) {
// <type> ::= <builtin-type>
// <builtin-type> ::= v # void
@@ -2137,7 +2143,7 @@
// <special-name> ::= TV <type> # virtual table
CXXNameMangler Mangler(*this, Res);
Mangler.getStream() << "_ZTV";
- Mangler.mangleName(RD);
+ Mangler.mangleNameOrStandardSubstitution(RD);
}
void MangleContext::mangleCXXVTT(const CXXRecordDecl *RD,
@@ -2145,7 +2151,7 @@
// <special-name> ::= TT <type> # VTT structure
CXXNameMangler Mangler(*this, Res);
Mangler.getStream() << "_ZTT";
- Mangler.mangleName(RD);
+ Mangler.mangleNameOrStandardSubstitution(RD);
}
void MangleContext::mangleCXXCtorVTable(const CXXRecordDecl *RD, int64_t Offset,
@@ -2154,10 +2160,10 @@
// <special-name> ::= TC <type> <offset number> _ <base type>
CXXNameMangler Mangler(*this, Res);
Mangler.getStream() << "_ZTC";
- Mangler.mangleName(RD);
+ Mangler.mangleNameOrStandardSubstitution(RD);
Mangler.getStream() << Offset;
Mangler.getStream() << '_';
- Mangler.mangleName(Type);
+ Mangler.mangleNameOrStandardSubstitution(Type);
}
void MangleContext::mangleCXXRTTI(QualType Ty,
Modified: cfe/trunk/test/CodeGenCXX/mangle-subst-std.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-subst-std.cpp?rev=104675&r1=104674&r2=104675&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-subst-std.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-subst-std.cpp Wed May 26 00:11:13 2010
@@ -1,5 +1,16 @@
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
+// Check mangling of Vtables, VTTs, and construction vtables that
+// involve standard substitutions.
+
+// CHECK: @_ZTVSd = weak_odr constant
+// CHECK: @_ZTCSd0_Si = internal constant
+// CHECK: @_ZTCSd16_So = internal constant
+// CHECK: @_ZTTSd = weak_odr constant
+// CHECK: @_ZTVSo = weak_odr constant
+// CHECK: @_ZTTSo = weak_odr constant
+// CHECK: @_ZTVSi = weak_odr constant
+// CHECK: @_ZTTSi = weak_odr constant
namespace std {
struct A { A(); };
@@ -32,9 +43,30 @@
void f(std::string) { }
namespace std {
- template<typename, typename> struct basic_istream { };
- template<typename, typename> struct basic_ostream { };
- template<typename, typename> struct basic_iostream { };
+ template<typename, typename> struct basic_ios {
+ basic_ios(int);
+ virtual ~basic_ios();
+ };
+ template<typename charT, typename traits = char_traits<charT> >
+ struct basic_istream : virtual public basic_ios<charT, traits> {
+ basic_istream(int x) : basic_ios<charT, traits>(x), stored(x) { }
+
+ int stored;
+ };
+ template<typename charT, typename traits = char_traits<charT> >
+ struct basic_ostream : virtual public basic_ios<charT, traits> {
+ basic_ostream(int x) : basic_ios<charT, traits>(x), stored(x) { }
+
+ float stored;
+ };
+
+ template<typename charT, typename traits = char_traits<charT> >
+ struct basic_iostream : public basic_istream<charT, traits>,
+ public basic_ostream<charT, traits> {
+ basic_iostream(int x) : basic_istream<charT, traits>(x),
+ basic_ostream<charT, traits>(x),
+ basic_ios<charT, traits>(x) { }
+ };
}
// CHECK: _Z1fSi
@@ -61,3 +93,9 @@
template<typename, typename, typename> struct basic_string { };
typedef basic_string<char, std::char_traits<char>, std::allocator<char> > not_string;
void f(not_string) { }
+
+// Manglings for instantiations caused by this function are at the
+// top of the test.
+void create_streams() {
+ std::basic_iostream<char> bio(17);
+}
More information about the cfe-commits
mailing list