[llvm-branch-commits] [cfe-branch] r195227 - Merging r195168:
Bill Wendling
isanbard at gmail.com
Tue Nov 19 22:46:42 PST 2013
Author: void
Date: Wed Nov 20 00:46:42 2013
New Revision: 195227
URL: http://llvm.org/viewvc/llvm-project?rev=195227&view=rev
Log:
Merging r195168:
------------------------------------------------------------------------
r195168 | rnk | 2013-11-19 15:23:00 -0800 (Tue, 19 Nov 2013) | 17 lines
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
------------------------------------------------------------------------
Added:
cfe/branches/release_34/test/CodeGen/tbaa-ms-abi.cpp
- copied unchanged from r195168, cfe/trunk/test/CodeGen/tbaa-ms-abi.cpp
Modified:
cfe/branches/release_34/ (props changed)
cfe/branches/release_34/include/clang/AST/Mangle.h
cfe/branches/release_34/lib/AST/ItaniumMangle.cpp
cfe/branches/release_34/lib/AST/MicrosoftMangle.cpp
cfe/branches/release_34/lib/CodeGen/CodeGenTBAA.cpp
Propchange: cfe/branches/release_34/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Nov 20 00:46:42 2013
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163
+/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_34/include/clang/AST/Mangle.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/include/clang/AST/Mangle.h?rev=195227&r1=195226&r2=195227&view=diff
==============================================================================
--- cfe/branches/release_34/include/clang/AST/Mangle.h (original)
+++ cfe/branches/release_34/include/clang/AST/Mangle.h Wed Nov 20 00:46:42 2013
@@ -148,6 +148,12 @@ public:
virtual void mangleDynamicAtExitDestructor(const VarDecl *D,
raw_ostream &) = 0;
+ /// Generates a unique string for an externally visible type for use with TBAA
+ /// or type uniquing.
+ /// TODO: Extend this to internal types by generating names that are unique
+ /// across translation units so it can be used with LTO.
+ virtual void mangleTypeName(QualType T, raw_ostream &) = 0;
+
/// @}
};
Modified: cfe/branches/release_34/lib/AST/ItaniumMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/lib/AST/ItaniumMangle.cpp?rev=195227&r1=195226&r2=195227&view=diff
==============================================================================
--- cfe/branches/release_34/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/branches/release_34/lib/AST/ItaniumMangle.cpp Wed Nov 20 00:46:42 2013
@@ -144,6 +144,7 @@ public:
raw_ostream &);
void mangleCXXRTTI(QualType T, raw_ostream &);
void mangleCXXRTTIName(QualType T, raw_ostream &);
+ void mangleTypeName(QualType T, raw_ostream &);
void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type,
raw_ostream &);
void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type,
@@ -3784,6 +3785,10 @@ void ItaniumMangleContextImpl::mangleCXX
Mangler.mangleType(Ty);
}
+void ItaniumMangleContextImpl::mangleTypeName(QualType Ty, raw_ostream &Out) {
+ mangleCXXRTTIName(Ty, Out);
+}
+
ItaniumMangleContext *
ItaniumMangleContext::create(ASTContext &Context, DiagnosticsEngine &Diags) {
return new ItaniumMangleContextImpl(Context, Diags);
Modified: cfe/branches/release_34/lib/AST/MicrosoftMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/lib/AST/MicrosoftMangle.cpp?rev=195227&r1=195226&r2=195227&view=diff
==============================================================================
--- cfe/branches/release_34/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/branches/release_34/lib/AST/MicrosoftMangle.cpp Wed Nov 20 00:46:42 2013
@@ -197,6 +197,7 @@ public:
raw_ostream &Out);
virtual void mangleCXXRTTI(QualType T, raw_ostream &);
virtual void mangleCXXRTTIName(QualType T, raw_ostream &);
+ virtual void mangleTypeName(QualType T, raw_ostream &);
virtual void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type,
raw_ostream &);
virtual void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type,
@@ -2019,6 +2020,14 @@ void MicrosoftMangleContextImpl::mangleC
<< T.getBaseTypeIdentifier();
}
+void MicrosoftMangleContextImpl::mangleTypeName(QualType T, raw_ostream &Out) {
+ // This is just a made up unique string for the purposes of tbaa. undname
+ // does *not* know how to demangle it.
+ MicrosoftCXXNameMangler Mangler(*this, Out);
+ Mangler.getStream() << '?';
+ Mangler.mangleType(T, SourceRange());
+}
+
void MicrosoftMangleContextImpl::mangleCXXCtor(const CXXConstructorDecl *D,
CXXCtorType Type,
raw_ostream &Out) {
Modified: cfe/branches/release_34/lib/CodeGen/CodeGenTBAA.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/lib/CodeGen/CodeGenTBAA.cpp?rev=195227&r1=195226&r2=195227&view=diff
==============================================================================
--- cfe/branches/release_34/lib/CodeGen/CodeGenTBAA.cpp (original)
+++ cfe/branches/release_34/lib/CodeGen/CodeGenTBAA.cpp Wed Nov 20 00:46:42 2013
@@ -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(QualT
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();
More information about the llvm-branch-commits
mailing list