diff options
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 16 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.h | 4 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 4 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 4 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 2 |
5 files changed, 17 insertions, 13 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index c0af91fd62d..5e3e975a778 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -3606,8 +3606,8 @@ llvm::DIGlobalVariable *CGDebugInfo::CollectAnonRecordDecls( } // Use VarDecl's Tag, Scope and Line number. GV = DBuilder.createGlobalVariable(DContext, FieldName, LinkageName, Unit, - LineNo, FieldTy, - Var->hasLocalLinkage(), Var, nullptr); + LineNo, FieldTy, Var->hasLocalLinkage()); + Var->addDebugInfo(GV); } return GV; } @@ -3640,14 +3640,14 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var, } else { GV = DBuilder.createGlobalVariable( DContext, DeclName, LinkageName, Unit, LineNo, getOrCreateType(T, Unit), - Var->hasLocalLinkage(), Var, + Var->hasLocalLinkage(), /*Expr=*/nullptr, getOrCreateStaticDataMemberDeclarationOrNull(D)); + Var->addDebugInfo(GV); } DeclCache[D->getCanonicalDecl()].reset(GV); } -void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, - llvm::Constant *Init) { +void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, const APValue &Init) { assert(DebugKind >= codegenoptions::LimitedDebugInfo); if (VD->hasAttr<NoDebugAttr>()) return; @@ -3687,9 +3687,13 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, auto &GV = DeclCache[VD]; if (GV) return; + llvm::DIExpression *InitExpr = nullptr; + if (Init.isInt()) + InitExpr = + DBuilder.createConstantValueExpression(Init.getInt().getExtValue()); GV.reset(DBuilder.createGlobalVariable( DContext, Name, StringRef(), Unit, getLineNumber(VD->getLocation()), Ty, - true, Init, getOrCreateStaticDataMemberDeclarationOrNull(VarD))); + true, InitExpr, getOrCreateStaticDataMemberDeclarationOrNull(VarD))); } llvm::DIScope *CGDebugInfo::getCurrentContextDescriptor(const Decl *D) { diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index eba46bade14..486eb2a3fa4 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -354,8 +354,8 @@ public: /// Emit information about a global variable. void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl); - /// Emit global variable's debug info. - void EmitGlobalVariable(const ValueDecl *VD, llvm::Constant *Init); + /// Emit a constant global variable's debug info. + void EmitGlobalVariable(const ValueDecl *VD, const APValue &Init); /// Emit C++ using directive. void EmitUsingDirective(const UsingDirectiveDecl &UD); diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 5f710f97bd5..7fee7985075 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -1180,10 +1180,10 @@ CodeGenFunction::tryEmitAsConstant(DeclRefExpr *refExpr) { // This should probably fire even for if (isa<VarDecl>(value)) { if (!getContext().DeclMustBeEmitted(cast<VarDecl>(value))) - EmitDeclRefExprDbgValue(refExpr, C); + EmitDeclRefExprDbgValue(refExpr, result.Val); } else { assert(isa<EnumConstantDecl>(value)); - EmitDeclRefExprDbgValue(refExpr, C); + EmitDeclRefExprDbgValue(refExpr, result.Val); } // If we emitted a reference constant, we need to dereference that. diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 2341eab0b31..116079e4a7f 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -1840,8 +1840,8 @@ Address CodeGenFunction::EmitMSVAListRef(const Expr *E) { } void CodeGenFunction::EmitDeclRefExprDbgValue(const DeclRefExpr *E, - llvm::Constant *Init) { - assert (Init && "Invalid DeclRefExpr initializer!"); + const APValue &Init) { + assert(!Init.isUninit() && "Invalid DeclRefExpr initializer!"); if (CGDebugInfo *Dbg = getDebugInfo()) if (CGM.getCodeGenOpts().getDebugInfo() >= codegenoptions::LimitedDebugInfo) Dbg->EmitGlobalVariable(E->getDecl(), Init); diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index bb0437157e5..db8b634539f 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -2810,7 +2810,7 @@ public: LValue EmitStmtExprLValue(const StmtExpr *E); LValue EmitPointerToDataMemberBinaryExpr(const BinaryOperator *E); LValue EmitObjCSelectorLValue(const ObjCSelectorExpr *E); - void EmitDeclRefExprDbgValue(const DeclRefExpr *E, llvm::Constant *Init); + void EmitDeclRefExprDbgValue(const DeclRefExpr *E, const APValue &Init); //===--------------------------------------------------------------------===// // Scalar Expression Emission |