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

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 9 08:26:49 PDT 2015


On Fri, Oct 9, 2015 at 2:26 AM, Alexey Bataev via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> 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.


You mean a patch related to alignment regressed this functionality? Do you
have the specific revision number of that change (since it sounds like you
tracked it down)?


> 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",
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151009/29dbc7f2/attachment.html>


More information about the cfe-commits mailing list