diff options
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index bc94bd0bb57..d0c58ef994b 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -8553,12 +8553,14 @@ ASTContext::getMaterializedTemporaryValue(const MaterializeTemporaryExpr *E, bool MayCreate) { assert(E && E->getStorageDuration() == SD_Static && "don't need to cache the computed value for this temporary"); - if (MayCreate) - return &MaterializedTemporaryValues[E]; + if (MayCreate) { + APValue *&MTVI = MaterializedTemporaryValues[E]; + if (!MTVI) + MTVI = new (*this) APValue; + return MTVI; + } - llvm::DenseMap<const MaterializeTemporaryExpr *, APValue>::iterator I = - MaterializedTemporaryValues.find(E); - return I == MaterializedTemporaryValues.end() ? nullptr : &I->second; + return MaterializedTemporaryValues.lookup(E); } bool ASTContext::AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const { |