[PATCH] DW_TAG_typedef and DW_TAG_structure_type not emitted when typedef is used
jyoti allur
jyoti.yalamanchili at gmail.com
Thu Jan 2 07:13:24 PST 2014
Hi dblaikie, echristo,
Hi,
This differential contains a patch for DW_TAG_typedef not being emitted when "typedef" is used on struct.
Patch verified on revision 197492.
Please let me know if this is good for commit.
Thanks!
http://llvm-reviews.chandlerc.com/D2498
Files:
llvm/tools/clang/lib/CodeGen/CGDebugInfo.h
llvm/tools/clang/lib/CodeGen/CGExprScalar.cpp
llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp
llvm/tools/clang/test/CodeGen/Debug-info-typedef.cpp
Index: llvm/tools/clang/lib/CodeGen/CGDebugInfo.h
===================================================================
--- llvm/tools/clang/lib/CodeGen/CGDebugInfo.h
+++ llvm/tools/clang/lib/CodeGen/CGDebugInfo.h
@@ -267,6 +267,9 @@
/// EmitGlobalVariable - Emit global variable's debug info.
void EmitGlobalVariable(const ValueDecl *VD, llvm::Constant *Init);
+ /// EmitTypeDef - Emit typedef debug info.
+ void EmitTypeDef(QualType Ty);
+
/// \brief - Emit C++ using directive.
void EmitUsingDirective(const UsingDirectiveDecl &UD);
Index: llvm/tools/clang/lib/CodeGen/CGExprScalar.cpp
===================================================================
--- llvm/tools/clang/lib/CodeGen/CGExprScalar.cpp
+++ llvm/tools/clang/lib/CodeGen/CGExprScalar.cpp
@@ -274,6 +274,13 @@
Value *VisitExplicitCastExpr(ExplicitCastExpr *E) {
if (E->getType()->isVariablyModifiedType())
CGF.EmitVariablyModifiedType(E->getType());
+ if( E->getType().getTypePtr()->getTypeClass() == Type::Typedef)
+ {
+ CGDebugInfo *DI = CGF.getDebugInfo();
+ if (DI && CGF.CGM.getCodeGenOpts().getDebugInfo()
+ == CodeGenOptions::LimitedDebugInfo)
+ DI->EmitTypeDef((E->getType()));
+ }
return VisitCastExpr(E);
}
Value *VisitCastExpr(CastExpr *E);
Index: llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp
+++ llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3276,3 +3276,12 @@
DBuilder.finalize();
}
+
+void CGDebugInfo::EmitTypeDef(QualType Ty)
+{
+ llvm::DIType DieTy = getOrCreateType(Ty,getOrCreateMainFile());
+ // Don't ignore in case of explicit cast were it is referenced indirectly.
+ DBuilder.retainType(DieTy);
+}
+
+
Index: llvm/tools/clang/test/CodeGen/Debug-info-typedef.cpp
===================================================================
--- llvm/tools/clang/test/CodeGen/Debug-info-typedef.cpp
+++ llvm/tools/clang/test/CodeGen/Debug-info-typedef.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang -fverbose-asm -S -g %s -o - | grep DW_TAG_structure_type
+// RUN: %clang -fverbose-asm -S -g %s -o - | grep DW_TAG_typedef
+// RUN: %clang -fverbose-asm -S -g %s -o - | grep S
+// RUN: %clang -fverbose-asm -S -g %s -o - | grep T
+
+typedef struct S { int i; } *T;
+#define M(p) ((T) (p))
+
+void
+foo (void* p)
+{
+ M (p)->i++;
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2498.1.patch
Type: text/x-patch
Size: 2408 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140102/ee58b608/attachment.bin>
More information about the cfe-commits
mailing list