aboutsummaryrefslogtreecommitdiff
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.cpp58
1 files changed, 11 insertions, 47 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 410c8f5..84a166d 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1677,13 +1677,22 @@ CGDebugInfo::CreateRecordStaticField(const VarDecl *Var, llvm::DIType *RecordTy,
unsigned LineNumber = getLineNumber(Var->getLocation());
StringRef VName = Var->getName();
+ llvm::Constant *C = nullptr;
+ if (Var->getInit()) {
+ const APValue *Value = Var->evaluateValue();
+ if (Value) {
+ if (Value->isInt())
+ C = llvm::ConstantInt::get(CGM.getLLVMContext(), Value->getInt());
+ if (Value->isFloat())
+ C = llvm::ConstantFP::get(CGM.getLLVMContext(), Value->getFloat());
+ }
+ }
llvm::DINode::DIFlags Flags = getAccessFlag(Var->getAccess(), RD);
auto Align = getDeclAlignIfRequired(Var, CGM.getContext());
llvm::DIDerivedType *GV = DBuilder.createStaticMemberType(
- RecordTy, VName, VUnit, LineNumber, VTy, Flags, /* Val */ nullptr, Align);
+ RecordTy, VName, VUnit, LineNumber, VTy, Flags, C, Align);
StaticDataMemberCache[Var->getCanonicalDecl()].reset(GV);
- StaticDataMemberDefinitionsToEmit.push_back(Var->getCanonicalDecl());
return GV;
}
@@ -5587,39 +5596,6 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, const APValue &Init) {
TemplateParameters, Align));
}
-void CGDebugInfo::EmitGlobalVariable(const VarDecl *VD) {
- assert(VD->hasInit());
- assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
- if (VD->hasAttr<NoDebugAttr>())
- return;
-
- auto &GV = DeclCache[VD];
- if (GV)
- return;
-
- auto const *InitVal = VD->evaluateValue();
- if (!InitVal)
- return;
-
- llvm::DIFile *Unit = nullptr;
- llvm::DIScope *DContext = nullptr;
- unsigned LineNo;
- StringRef DeclName, LinkageName;
- QualType T;
- llvm::MDTuple *TemplateParameters = nullptr;
- collectVarDeclProps(VD, Unit, LineNo, T, DeclName, LinkageName,
- TemplateParameters, DContext);
-
- auto Align = getDeclAlignIfRequired(VD, CGM.getContext());
- llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(VD);
- llvm::DIExpression *InitExpr = createConstantValueExpression(VD, *InitVal);
-
- GV.reset(DBuilder.createGlobalVariableExpression(
- TheCU, DeclName, LinkageName, Unit, LineNo, getOrCreateType(T, Unit),
- true, true, InitExpr, getOrCreateStaticDataMemberDeclarationOrNull(VD),
- TemplateParameters, Align, Annotations));
-}
-
void CGDebugInfo::EmitExternalVariable(llvm::GlobalVariable *Var,
const VarDecl *D) {
assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
@@ -5890,18 +5866,6 @@ void CGDebugInfo::finalize() {
DBuilder.replaceTemporary(std::move(FwdDecl), cast<llvm::MDNode>(Repl));
}
- for (auto const *VD : StaticDataMemberDefinitionsToEmit) {
- assert(VD->isStaticDataMember());
-
- if (DeclCache.contains(VD))
- continue;
-
- if (!VD->hasInit())
- continue;
-
- EmitGlobalVariable(VD);
- }
-
// We keep our own list of retained types, because we need to look
// up the final type in the type cache.
for (auto &RT : RetainedTypes)