summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 19745dc2a0c..009245c1122 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -43,8 +43,10 @@ CGDebugInfo::CGDebugInfo(CodeGenModule *m)
, RegionEndFn(NULL)
, CompileUnitAnchor(NULL)
, SubprogramAnchor(NULL)
+, GlobalVariableAnchor(NULL)
, RegionStack()
, VariableDescList()
+, GlobalVarDescList(NULL)
, Subprogram(NULL)
{
SR = new llvm::DISerializer();
@@ -79,8 +81,14 @@ CGDebugInfo::~CGDebugInfo()
delete *I;
}
+ for (std::vector<llvm::GlobalVariableDesc *>::iterator I
+ = GlobalVarDescList.begin(); I != GlobalVarDescList.end(); ++I) {
+ delete *I;
+ }
+
delete CompileUnitAnchor;
delete SubprogramAnchor;
+ delete GlobalVariableAnchor;
}
void CGDebugInfo::setLocation(SourceLocation loc)
@@ -566,3 +574,41 @@ void CGDebugInfo::EmitDeclare(const VarDecl *decl, unsigned Tag,
Builder.CreateCall2(DeclareFn, AllocACast, getCastValueFor(Variable), "");
}
+/// EmitGlobalVariable - Emit information about a global variable.
+void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *GV,
+ const VarDecl *decl)
+{
+ // Create global variable debug descriptor.
+ llvm::GlobalVariableDesc *Global = new llvm::GlobalVariableDesc();
+
+ // Push it onto the list so that we can free it.
+ GlobalVarDescList.push_back(Global);
+
+ // Make sure we have an anchor.
+ if (!GlobalVariableAnchor)
+ GlobalVariableAnchor = new llvm::AnchorDesc(Global);
+
+ // Get name information.
+ Global->setName(decl->getName());
+ Global->setFullName(decl->getName());
+
+ llvm::CompileUnitDesc *Unit = getOrCreateCompileUnit(CurLoc);
+ SourceManager &SM = M->getContext().getSourceManager();
+ uint64_t Loc = SM.getLogicalLineNumber(CurLoc);
+
+ llvm::TypeDesc *TyD = getOrCreateType(decl->getType(), Unit);
+
+ // Fill in the Global information.
+ Global->setAnchor(GlobalVariableAnchor);
+ Global->setContext(Unit);
+ Global->setFile(Unit);
+ Global->setLine(Loc);
+ Global->setType(TyD);
+ Global->setIsDefinition(true);
+ Global->setIsStatic(GV->hasInternalLinkage());
+ Global->setGlobalVariable(GV);
+
+ // Make sure global is created if needed.
+ getValueFor(Global);
+}
+
OpenPOWER on IntegriCloud