diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-12-28 19:48:30 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-12-28 19:48:30 +0000 |
commit | 80d4b55db94db2172a04617d1a80feca6bbcea5c (patch) | |
tree | 04bad08faed06c04c4580572a8de2b877768a108 /lib/CodeGen/CGDebugInfo.cpp | |
parent | 0e743b1582d53d3ebb2074da881e00bfb759f250 (diff) |
Small refactoring and simplification of constant evaluation and some of its
clients. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147318 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index af6d25d363..f48157f48c 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1107,18 +1107,18 @@ 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->EvaluateAsRValue(Result, CGM.getContext()) && - Result.Val.isInt()) { - llvm::ConstantInt *CI - = llvm::ConstantInt::get(CGM.getLLVMContext(), Result.Val.getInt()); - + llvm::SmallVector<PartialDiagnosticAt, 8> Notes; + if (V->getInit() && V->evaluateValue(Notes)) { + APValue *Value = V->getEvaluatedValue(); + if (Value && Value->isInt()) { + llvm::ConstantInt *CI + = llvm::ConstantInt::get(CGM.getLLVMContext(), Value->getInt()); + // Create the descriptor for static variable. llvm::DIFile VUnit = getOrCreateFile(V->getLocation()); StringRef VName = V->getName(); |