[cfe-commits] r161368 - in /cfe/trunk: lib/CodeGen/CGDebugInfo.cpp test/CodeGenCXX/debug-info-template-quals.cpp

Eric Christopher echristo at apple.com
Mon Aug 6 17:14:25 PDT 2012


Author: echristo
Date: Mon Aug  6 19:14:25 2012
New Revision: 161368

URL: http://llvm.org/viewvc/llvm-project?rev=161368&view=rev
Log:
Make sure when we get the replacement type for a template argument
that we attach the lost qualifiers.

Fixes rdar://11882155

Added:
    cfe/trunk/test/CodeGenCXX/debug-info-template-quals.cpp
Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=161368&r1=161367&r2=161368&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Aug  6 19:14:25 2012
@@ -558,7 +558,7 @@
 
   // Handle qualifiers.
   if (PointeeTy.hasLocalQualifiers())
-    return CreateQualifiedType(PointeeTy, Unit);
+    return CreateQualifiedType(PointeeTy.getCanonicalType(), Unit);
 
   if (const RecordType *RTy = dyn_cast<RecordType>(PointeeTy)) {
     RecordDecl *RD = RTy->getDecl();
@@ -685,8 +685,9 @@
   if (isa<FunctionNoProtoType>(Ty))
     EltTys.push_back(DBuilder.createUnspecifiedParameter());
   else if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(Ty)) {
-    for (unsigned i = 0, e = FPT->getNumArgs(); i != e; ++i)
+    for (unsigned i = 0, e = FPT->getNumArgs(); i != e; ++i) {
       EltTys.push_back(getOrCreateType(FPT->getArgType(i), Unit));
+    }
   }
 
   llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(EltTys);
@@ -1629,8 +1630,13 @@
     case Type::Paren:
       T = cast<ParenType>(T)->getInnerType();
       break;
-    case Type::SubstTemplateTypeParm:
+    case Type::SubstTemplateTypeParm: {
+      // We need to keep the qualifiers handy since getReplacementType()
+      // will strip them away.
+      unsigned Quals = T.getLocalFastQualifiers();
       T = cast<SubstTemplateTypeParmType>(T)->getReplacementType();
+      T.addFastQualifiers(Quals);
+    }
       break;
     case Type::Auto:
       T = cast<AutoType>(T)->getDeducedType();
@@ -1689,10 +1695,11 @@
 
   // Unwrap the type as needed for debug information.
   Ty = UnwrapTypeForDebugInfo(Ty);
-  
+
   llvm::DIType T = getCompletedTypeOrNull(Ty);
 
-  if (T.Verify()) return T;
+  if (T.Verify())
+    return T;
 
   // Otherwise create the type.
   llvm::DIType Res = CreateTypeNode(Ty, Unit);
@@ -1707,6 +1714,7 @@
 
   if (!Res.isForwardDecl())
     CompletedTypeCache[Ty.getAsOpaquePtr()] = Res;
+
   return Res;
 }
 
@@ -1958,6 +1966,7 @@
 llvm::DIType CGDebugInfo::getOrCreateFunctionType(const Decl * D,
                                                   QualType FnType,
                                                   llvm::DIFile F) {
+
   if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D))
     return getOrCreateMethodType(Method, F);
   if (const ObjCMethodDecl *OMethod = dyn_cast<ObjCMethodDecl>(D)) {

Added: cfe/trunk/test/CodeGenCXX/debug-info-template-quals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-template-quals.cpp?rev=161368&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-template-quals.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-template-quals.cpp Mon Aug  6 19:14:25 2012
@@ -0,0 +1,23 @@
+// RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s
+
+template<typename _CharT>
+struct basic_string {
+
+  basic_string&
+  assign(const _CharT* __s)
+  {
+    return *this;
+  }
+};
+
+void foo (const char *c) {
+  basic_string<char> str;
+  str.assign(c);
+}
+
+// CHECK: [[P:.*]] = metadata !{i32 {{.*}}, metadata [[CON:.*]]} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ]
+// CHECK: [[CON]] = metadata !{i32 {{.*}}, metadata [[CH:.*]]} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from char]
+// CHECK: [[CH]] = metadata !{i32 {{.*}}, metadata !"char", {{.*}}} ; [ DW_TAG_base_type ] [char] [line 0, size 8, align 8, offset 0, enc DW_ATE_signed_char]
+// CHECK: metadata !{i32 {{.*}}, metadata !"_ZN12basic_stringIcE6assignEPKc", metadata !6, i32 7, metadata [[TYPE:.*]], i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, %struct.basic_string* (%struct.basic_string*, i8*)* @_ZN12basic_stringIcE6assignEPKc, null, metadata !18, metadata !1, i32 8} ; [ DW_TAG_subprogram ] [line 7] [def] [scope 8] [assign]
+// CHECK: [[TYPE]] = metadata !{i32 {{.*}}, null, metadata [[ARGS:.*]], i32 0, i32 0}
+// CHECK: [[ARGS]] = metadata !{metadata !15, metadata !23, metadata [[P]]}





More information about the cfe-commits mailing list