[PATCH] Patch for missing debug info of type being explicitly casted to

jyoti allur jyoti.yalamanchili at gmail.com
Sun Sep 21 23:11:26 PDT 2014


================
Comment at: llvm/tools/clang/test/CodeGen/Debug-info-explicitcast.c:7
@@ +6,3 @@
+void foo(void *p) { ((T)(p))->i++; }
+// CHECK: metadata !{i32 {{.*}}, metadata !{{.*}}, null, metadata !"T", i32 3, i64 0, i64 0, i64 0, i32 0, metadata !{{.*}}} ; [ DW_TAG_typedef ] [T] [line 3, size 0, align 0, offset 0] [from ]
+// CHECK: metadata !{i32 {{.*}}, metadata !{{.*}}, null, metadata !"S", i32 3, i64 32, i64 32, i32 0, i32 0, null, metadata !{{.*}}, i32 0, null, null, null} ; [ DW_TAG_structure_type ] [S] [line 3, size 32, align 32, offset 0] [def] [from ]
----------------
dblaikie wrote:
> There's no need to check the metadata in this level of detail (especially the block of checks at the end of this file) - it makes the tests particularly brittle to metadata schema changes.
> 
> Check out some of the other tests to get a sense of the minimal metadata needing to be checked.
> 
> Drop the typedef from the test - since that's not the unedrlying issue, and just test the cast to "struct S*" then in the CHECK, something as simple as:
> 
> CHECK: ; [ DW_TAG_structure_type ] [S]
> 
> should be sufficient to demonstrate that the type was emitted. 
> 
> As a side note, given this code /in C++/ (coupled with your change):
> 
>   struct S { };
>   void sink(S*);
>   void foo(void* v) {
>     sink((S*)v);
>   }
> 
> do we emit the declaration of S? (ie: do we emit S (rather than leaving it out entirely) and do we only emit a declaration (since the full definition of S was never needed)? - arguably we could just avoid emitting it entirely here, since no one ever dereferenced the pointer and we don't need the declaration to describe any other entities... )
Okay, i'll modify the testcase to check minimal metdata and remove typedef cases as you suggested.

For the code above, we do emit a declaration of S with my patch, since v was casted to type S. This behaviour is inline with gcc. Without my patch declaration of S was not emitted.

I did try with this modified code and no declaration of S was emitted.

struct S { };
void sink(void*);
void foo(void* v) {
  sink(v);
}

http://reviews.llvm.org/D2498






More information about the cfe-commits mailing list