[cfe-commits] r110697 - in /cfe/trunk: lib/CodeGen/CGDebugInfo.cpp test/CodeGen/enum2.c

Chris Lattner clattner at apple.com
Tue Aug 10 13:44:02 PDT 2010


On Aug 10, 2010, at 11:27 AM, Devang Patel wrote:

> Author: dpatel
> Date: Tue Aug 10 13:27:15 2010
> New Revision: 110697
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=110697&view=rev
> Log:
> Do not use DIGlobalVariable to emit debugging information for enums.

Hey Devang,

It would be much better to check that the declrefexpr is or isn't referring to an enum that it is to catch it after a bunch of stuff has been done.  Can you hoist the check earlier and make it happen on the AST?

-Chris

> 
> Added:
>    cfe/trunk/test/CodeGen/enum2.c
> 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=110697&r1=110696&r2=110697&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Aug 10 13:27:15 2010
> @@ -1808,6 +1808,10 @@
>   // Create the descriptor for the variable.
>   llvm::DIFile Unit = getOrCreateFile(VD->getLocation());
>   llvm::StringRef Name = VD->getName();
> +  llvm::DIType Ty = getOrCreateType(VD->getType(), Unit);
> +  // Do not use DIGlobalVariable for enums.
> +  if (Ty.getTag() == llvm::dwarf::DW_TAG_enumeration_type)
> +    return;
>   DebugFactory.CreateGlobalVariable(Unit, Name, Name, Name, Unit,
>                                     getLineNumber(VD->getLocation()),
>                                     getOrCreateType(VD->getType(), Unit),
> 
> Added: cfe/trunk/test/CodeGen/enum2.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/enum2.c?rev=110697&view=auto
> ==============================================================================
> --- cfe/trunk/test/CodeGen/enum2.c (added)
> +++ cfe/trunk/test/CodeGen/enum2.c Tue Aug 10 13:27:15 2010
> @@ -0,0 +1,8 @@
> +// RUN: %clang_cc1 -triple i386-unknown-unknown %s -g -emit-llvm -o /dev/null
> +int v;
> +enum e { MAX };
> +
> +void foo (void)
> +{
> +  v = MAX;
> +}
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits





More information about the cfe-commits mailing list