From cc99e264756a8e29ed1e2521cf2f2d2db7095082 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Tue, 19 Nov 2013 23:23:00 +0000 Subject: Add a mangler entry point for TBAA rather than using RTTI directly Summary: RTTI is not yet implemented for the Microsoft C++ ABI and isn't expected soon. We could easily add the mangling, but the error is what prevents us from silently miscompiling code that expects RTTI. Instead, add a new mangleTypeName entry point that simply forwards to mangleName or mangleType to produce a string that isn't part of the ABI. Itanium can continue to use RTTI names to avoid unecessary test breakage. This also seems like the right design. The fact that TBAA names happen to be RTTI names is now an implementation detail of the mangler, rather than part of TBAA. Differential Revision: http://llvm-reviews.chandlerc.com/D2153 llvm-svn: 195168 --- clang/lib/CodeGen/CodeGenTBAA.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenTBAA.cpp') diff --git a/clang/lib/CodeGen/CodeGenTBAA.cpp b/clang/lib/CodeGen/CodeGenTBAA.cpp index 11e376ff403..699cc2eabe1 100644 --- a/clang/lib/CodeGen/CodeGenTBAA.cpp +++ b/clang/lib/CodeGen/CodeGenTBAA.cpp @@ -152,11 +152,9 @@ CodeGenTBAA::getTBAAInfo(QualType QTy) { if (!Features.CPlusPlus || !ETy->getDecl()->isExternallyVisible()) return MetadataCache[Ty] = getChar(); - // TODO: This is using the RTTI name. Is there a better way to get - // a unique string for a type? SmallString<256> OutName; llvm::raw_svector_ostream Out(OutName); - MContext.mangleCXXRTTIName(QualType(ETy, 0), Out); + MContext.mangleTypeName(QualType(ETy, 0), Out); Out.flush(); return MetadataCache[Ty] = createTBAAScalarType(OutName, getChar()); } @@ -268,13 +266,11 @@ CodeGenTBAA::getTBAAStructTypeInfo(QualType QTy) { FieldNode, Layout.getFieldOffset(idx) / Context.getCharWidth())); } - // TODO: This is using the RTTI name. Is there a better way to get - // a unique string for a type? SmallString<256> OutName; if (Features.CPlusPlus) { - // Don't use mangleCXXRTTIName for C code. + // Don't use the mangler for C code. llvm::raw_svector_ostream Out(OutName); - MContext.mangleCXXRTTIName(QualType(Ty, 0), Out); + MContext.mangleTypeName(QualType(Ty, 0), Out); Out.flush(); } else { OutName = RD->getName(); -- cgit v1.2.3