summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenTBAA.cpp
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2013-08-21 20:58:45 +0000
committerManman Ren <manman.ren@gmail.com>2013-08-21 20:58:45 +0000
commit879ce8841dc980104d1e99bd45ad6f15bb4efd2e (patch)
tree22f08ab9016385141039621e2642ac560ffd1c78 /clang/lib/CodeGen/CodeGenTBAA.cpp
parent3380ee5e60c93c5bc8a9d6adc94cb84eb08cce46 (diff)
downloadbcm5719-llvm-879ce8841dc980104d1e99bd45ad6f15bb4efd2e.tar.gz
bcm5719-llvm-879ce8841dc980104d1e99bd45ad6f15bb4efd2e.zip
Don't use mangleCXXRTTIName in TBAA for C code.
With r185721, calling mangleCXXRTTIName on C code will cause crashes. This commit fixes crashes on C testing cases when turning on struct-path TBAA. For C code, we simply use the Decl name without the context. This can cause two different structs having the same name, and may cause inaccurate but conservative alias results. llvm-svn: 188930
Diffstat (limited to 'clang/lib/CodeGen/CodeGenTBAA.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenTBAA.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CodeGenTBAA.cpp b/clang/lib/CodeGen/CodeGenTBAA.cpp
index 0a8c293cb70..f104c2f2f57 100644
--- a/clang/lib/CodeGen/CodeGenTBAA.cpp
+++ b/clang/lib/CodeGen/CodeGenTBAA.cpp
@@ -277,9 +277,14 @@ CodeGenTBAA::getTBAAStructTypeInfo(QualType QTy) {
// 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(Ty, 0), Out);
- Out.flush();
+ if (Features.CPlusPlus) {
+ // Don't use mangleCXXRTTIName for C code.
+ llvm::raw_svector_ostream Out(OutName);
+ MContext.mangleCXXRTTIName(QualType(Ty, 0), Out);
+ Out.flush();
+ } else {
+ OutName = RD->getName();
+ }
// Create the struct type node with a vector of pairs (offset, type).
return StructTypeMetadataCache[Ty] =
MDHelper.createTBAAStructTypeNode(OutName, Fields);
OpenPOWER on IntegriCloud