aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2010-08-12 00:02:44 +0000
committerDevang Patel <dpatel@apple.com>2010-08-12 00:02:44 +0000
commitdabc3e90cc385214a53064d8c44edbece9891ddf (patch)
tree303797eaff783800a574de2d1b1ee6a2395f6a45 /lib/CodeGen/CGDebugInfo.cpp
parentf643264005c428030a83e0147703b919eb31b41d (diff)
Emit debug info for static const class member.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110885 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index bb9f1cbc8a..6c1d321b12 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -553,7 +553,6 @@ CollectRecordFields(const RecordDecl *RD, llvm::DIFile Unit,
I != E; ++I, ++FieldNo) {
FieldDecl *Field = *I;
llvm::DIType FieldTy = getOrCreateType(Field->getType(), Unit);
-
llvm::StringRef FieldName = Field->getName();
// Ignore unnamed fields. Do not ignore unnamed records.
@@ -573,7 +572,6 @@ CollectRecordFields(const RecordDecl *RD, llvm::DIFile Unit,
Expr *BitWidth = Field->getBitWidth();
if (BitWidth)
FieldSize = BitWidth->EvaluateAsInt(CGM.getContext()).getZExtValue();
-
FieldAlign = CGM.getContext().getTypeAlign(FType);
}
@@ -894,6 +892,31 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty,
CollectCXXBases(CXXDecl, Unit, EltTys, FwdDecl);
CollectVTableInfo(CXXDecl, Unit, EltTys);
}
+
+ // Collect static variables with initializers.
+ for (RecordDecl::decl_iterator I = RD->decls_begin(), E = RD->decls_end();
+ I != E; ++I)
+ if (const VarDecl *V = dyn_cast<VarDecl>(*I)) {
+ if (const Expr *Init = V->getInit()) {
+ Expr::EvalResult Result;
+ if (Init->Evaluate(Result, CGM.getContext()) && Result.Val.isInt()) {
+ llvm::ConstantInt *CI
+ = llvm::ConstantInt::get(CGM.getLLVMContext(), Result.Val.getInt());
+
+ // Create the descriptor for static variable.
+ llvm::DIFile VUnit = getOrCreateFile(V->getLocation());
+ llvm::StringRef VName = V->getName();
+ llvm::DIType VTy = getOrCreateType(V->getType(), VUnit);
+ // Do not use DIGlobalVariable for enums.
+ if (VTy.getTag() != llvm::dwarf::DW_TAG_enumeration_type) {
+ DebugFactory.CreateGlobalVariable(FwdDecl, VName, VName, VName, VUnit,
+ getLineNumber(V->getLocation()),
+ VTy, true, true, CI);
+ }
+ }
+ }
+ }
+
CollectRecordFields(RD, Unit, EltTys);
llvm::MDNode *ContainingType = NULL;
if (CXXDecl) {