diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/AST/Decl.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/AST/Decl.cpp | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/contrib/llvm-project/clang/lib/AST/Decl.cpp b/contrib/llvm-project/clang/lib/AST/Decl.cpp index feb9b0645ebc..10cfe145b3f0 100644 --- a/contrib/llvm-project/clang/lib/AST/Decl.cpp +++ b/contrib/llvm-project/clang/lib/AST/Decl.cpp @@ -2384,11 +2384,11 @@ EvaluatedStmt *VarDecl::getEvaluatedStmt() const { APValue *VarDecl::evaluateValue() const { SmallVector<PartialDiagnosticAt, 8> Notes; - return evaluateValueImpl(Notes, hasConstantInitialization()); + return evaluateValue(Notes); } -APValue *VarDecl::evaluateValueImpl(SmallVectorImpl<PartialDiagnosticAt> &Notes, - bool IsConstantInitialization) const { +APValue *VarDecl::evaluateValue( + SmallVectorImpl<PartialDiagnosticAt> &Notes) const { EvaluatedStmt *Eval = ensureEvaluatedStmt(); const auto *Init = cast<Expr>(Eval->Value); @@ -2407,16 +2407,8 @@ APValue *VarDecl::evaluateValueImpl(SmallVectorImpl<PartialDiagnosticAt> &Notes, Eval->IsEvaluating = true; - ASTContext &Ctx = getASTContext(); - bool Result = Init->EvaluateAsInitializer(Eval->Evaluated, Ctx, this, Notes, - IsConstantInitialization); - - // In C++11, this isn't a constant initializer if we produced notes. In that - // case, we can't keep the result, because it may only be correct under the - // assumption that the initializer is a constant context. - if (IsConstantInitialization && Ctx.getLangOpts().CPlusPlus11 && - !Notes.empty()) - Result = false; + bool Result = Init->EvaluateAsInitializer(Eval->Evaluated, getASTContext(), + this, Notes); // Ensure the computed APValue is cleaned up later if evaluation succeeded, // or that it's empty (so that there's nothing to clean up) if evaluation @@ -2424,7 +2416,7 @@ APValue *VarDecl::evaluateValueImpl(SmallVectorImpl<PartialDiagnosticAt> &Notes, if (!Result) Eval->Evaluated = APValue(); else if (Eval->Evaluated.needsCleanup()) - Ctx.addDestruction(&Eval->Evaluated); + getASTContext().addDestruction(&Eval->Evaluated); Eval->IsEvaluating = false; Eval->WasEvaluated = true; @@ -2478,14 +2470,7 @@ bool VarDecl::checkForConstantInitialization( assert(!cast<Expr>(Eval->Value)->isValueDependent()); // Evaluate the initializer to check whether it's a constant expression. - Eval->HasConstantInitialization = - evaluateValueImpl(Notes, true) && Notes.empty(); - - // If evaluation as a constant initializer failed, allow re-evaluation as a - // non-constant initializer if we later find we want the value. - if (!Eval->HasConstantInitialization) - Eval->WasEvaluated = false; - + Eval->HasConstantInitialization = evaluateValue(Notes) && Notes.empty(); return Eval->HasConstantInitialization; } |