[PATCH] D13582: [DEBUG INFO] Emit debug info for type used in explicit cast only.

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 9 02:26:16 PDT 2015


ABataev created this revision.
ABataev added a reviewer: echristo.
ABataev added a subscriber: cfe-commits.

Currently debug info for types used in explicit cast only is not emitted. It happened after a patch for better alignment handling. This patch fixes this bug.

http://reviews.llvm.org/D13582

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGenCXX/debug-info-explicit-cast.cpp

Index: lib/CodeGen/CGExpr.cpp
===================================================================
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -799,6 +799,10 @@
     if (E->getType()->isVariablyModifiedType())
       EmitVariablyModifiedType(E->getType());
 
+    if (isa<ExplicitCastExpr>(CE))
+      if (CGDebugInfo *DI = getDebugInfo())
+        DI->EmitExplicitCastType(E->getType());
+
     switch (CE->getCastKind()) {
     // Non-converting casts (but not C's implicit conversion from void*).
     case CK_BitCast:
Index: test/CodeGenCXX/debug-info-explicit-cast.cpp
===================================================================
--- test/CodeGenCXX/debug-info-explicit-cast.cpp
+++ test/CodeGenCXX/debug-info-explicit-cast.cpp
@@ -0,0 +1,18 @@
+// RUN: %clangxx -c -target x86_64-unknown-unknown -g %s -emit-llvm -S -o - | FileCheck %s
+struct Foo {
+  int a;
+  Foo() : a(1){};
+};
+
+struct Bar {
+  int b;
+  Bar() : b(2){};
+};
+
+int main() {
+  Bar *pb = new Bar;
+
+  return reinterpret_cast<Foo *>(pb)->a;
+}
+
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Foo",


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13582.36928.patch
Type: text/x-patch
Size: 1113 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151009/7c017544/attachment-0001.bin>


More information about the cfe-commits mailing list