r239781 - Debug Info: Turn on ODR type uniquing for (the C++ part of) Objective-C++.

Adrian Prantl aprantl at apple.com
Mon Jun 15 16:18:16 PDT 2015


Author: adrian
Date: Mon Jun 15 18:18:16 2015
New Revision: 239781

URL: http://llvm.org/viewvc/llvm-project?rev=239781&view=rev
Log:
Debug Info: Turn on ODR type uniquing for (the C++ part of) Objective-C++.

rdar://problem/20571359

Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/test/CodeGenObjCXX/debug-info-cyclic.mm

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=239781&r1=239780&r2=239781&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jun 15 18:18:16 2015
@@ -590,18 +590,29 @@ llvm::DIType *CGDebugInfo::CreateType(co
                                Ty->getPointeeType(), Unit);
 }
 
+/// \return whether a C++ mangling exists for the type defined by TD.
+static bool hasCXXMangling(const TagDecl *TD, llvm::DICompileUnit *TheCU) {
+  switch (TheCU->getSourceLanguage()) {
+  case llvm::dwarf::DW_LANG_C_plus_plus:
+    return true;
+  case llvm::dwarf::DW_LANG_ObjC_plus_plus:
+    return isa<CXXRecordDecl>(TD) || isa<EnumDecl>(TD);
+  default:
+    return false;
+  }
+}
+
 /// In C++ mode, types have linkage, so we can rely on the ODR and
 /// on their mangled names, if they're external.
 static SmallString<256> getUniqueTagTypeName(const TagType *Ty,
                                              CodeGenModule &CGM,
                                              llvm::DICompileUnit *TheCU) {
   SmallString<256> FullName;
-  // FIXME: ODR should apply to ObjC++ exactly the same wasy it does to C++.
-  // For now, only apply ODR with C++.
   const TagDecl *TD = Ty->getDecl();
-  if (TheCU->getSourceLanguage() != llvm::dwarf::DW_LANG_C_plus_plus ||
-      !TD->isExternallyVisible())
+
+  if (!hasCXXMangling(TD, TheCU) || !TD->isExternallyVisible())
     return FullName;
+
   // Microsoft Mangler does not have support for mangleCXXRTTIName yet.
   if (CGM.getTarget().getCXXABI().isMicrosoft())
     return FullName;

Modified: cfe/trunk/test/CodeGenObjCXX/debug-info-cyclic.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/debug-info-cyclic.mm?rev=239781&r1=239780&r2=239781&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/debug-info-cyclic.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/debug-info-cyclic.mm Mon Jun 15 18:18:16 2015
@@ -1,12 +1,13 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin -g -emit-llvm %s -o - | FileCheck %s
 
 struct B {
-// CHECK: ![[B:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "B"
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "B"
 // CHECK-SAME:                             line: [[@LINE-2]],
 // CHECK-SAME:                             size: 8, align: 8,
 // CHECK-NOT:                              offset:
 // CHECK-NOT:                              DIFlagFwdDecl
 // CHECK-SAME:                             elements: ![[BMEMBERS:[0-9]+]]
+// CHECK-SAME:                             identifier: [[B:.*]])
 // CHECK: ![[BMEMBERS]] = !{![[BB:[0-9]+]]}
   B(struct A *);
 // CHECK: ![[BB]] = !DISubprogram(name: "B", scope: ![[B]]





More information about the cfe-commits mailing list