r189200 - DebugInfo: Emit info for casted decls in template args

David Majnemer david.majnemer at gmail.com
Sun Aug 25 15:13:28 PDT 2013


Author: majnemer
Date: Sun Aug 25 17:13:27 2013
New Revision: 189200

URL: http://llvm.org/viewvc/llvm-project?rev=189200&view=rev
Log:
DebugInfo: Emit info for casted decls in template args

Summary:
Previously the backend wouldn't get to see the underlying GlobalValue
that corresponds to the template argument because it would be hidden by
a cast at the IR level.  Instead strip the pointer casts off of the
value until we see the underlying GlobalValue.

Reviewers: dblaikie, echristo, majnemer

Reviewed By: majnemer

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1508

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

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=189200&r1=189199&r2=189200&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Sun Aug 25 17:13:27 2013
@@ -1258,7 +1258,8 @@ CollectTemplateParams(const TemplatePara
             cast<MemberPointerType>(T.getTypePtr()), chars);
       }
       llvm::DITemplateValueParameter TVP =
-          DBuilder.createTemplateValueParameter(TheCU, Name, TTy, V);
+          DBuilder.createTemplateValueParameter(TheCU, Name, TTy,
+                                                V->stripPointerCasts());
       TemplateParams.push_back(TVP);
     } break;
     case TemplateArgument::NullPtr: {

Modified: cfe/trunk/test/CodeGenCXX/debug-info-template.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-template.cpp?rev=189200&r1=189199&r2=189200&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-template.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-template.cpp Sun Aug 25 17:13:27 2013
@@ -74,7 +74,12 @@
 // CHECK: [[TGIARG1]] = {{.*}}metadata !"", metadata [[CONST_GUID_PTR:![0-9]*]], { i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ab, {{.*}} ; [ DW_TAG_template_value_parameter ]
 // CHECK: [[CONST_GUID_PTR]] = {{.*}}, metadata [[CONST_GUID:![0-9]*]]} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ]
 // CHECK: [[CONST_GUID]] = {{.*}}, metadata [[GUID:![0-9]*]]} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from _GUID]
-// CHECK: [[GUID]] = {{.*}} ; [ DW_TAG_structure_type ] [_GUID] [line 100, size 0, align 0, offset 0] [decl]
+// CHECK: [[GUID]] = {{.*}} ; [ DW_TAG_structure_type ] [_GUID]
+
+// CHECK: metadata [[PTOARGS:![0-9]*]]} ; [ DW_TAG_structure_type ] [PaddingAtEndTemplate<&PaddedObj>]
+// CHECK: [[PTOARGS]] = metadata !{metadata [[PTOARG1:![0-9]*]]}
+// CHECK: [[PTOARG1]] = {{.*}}metadata !"", metadata [[CONST_PADDINGATEND_PTR:![0-9]*]], { i32, i8, [3 x i8] }* @PaddedObj, {{.*}} ; [ DW_TAG_template_value_parameter ]
+// CHECK: [[CONST_PADDINGATEND_PTR]] = {{.*}} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from PaddingAtEnd]
 struct foo {
   char pad[8]; // make the member pointer to 'e' a bit more interesting (nonzero)
   int e;
@@ -104,3 +109,16 @@ struct tmpl_guid {
 
 struct __declspec(uuid("{12345678-1234-1234-1234-1234567890ab}")) uuid;
 tmpl_guid<&__uuidof(uuid)> tgi;
+
+struct PaddingAtEnd {
+  int i;
+  char c;
+};
+
+PaddingAtEnd PaddedObj = {};
+
+template <const PaddingAtEnd *>
+struct PaddingAtEndTemplate {
+};
+
+PaddingAtEndTemplate<&PaddedObj> PaddedTemplateObj;





More information about the cfe-commits mailing list