From fcee80737c3272dc9de2dfd9635a1e90db215c7a Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 28 Apr 2020 20:18:01 -0700 Subject: [PATCH] ASTContext::OMPTraitInfoVector: Use unique_ptr to simplify memory management --- clang/include/clang/AST/ASTContext.h | 2 +- clang/lib/AST/ASTContext.cpp | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 82b8a51..cd7021a 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -3002,7 +3002,7 @@ public: private: /// All OMPTraitInfo objects live in this collection, one per /// `pragma omp [begin] declare variant` directive. - SmallVector OMPTraitInfoVector; + SmallVector, 4> OMPTraitInfoVector; }; /// Utility function for constructing a nullary selector. diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 9b07a88..612f6eec 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1006,9 +1006,6 @@ ASTContext::~ASTContext() { for (APValue *Value : APValueCleanups) Value->~APValue(); - - // Destroy the OMPTraitInfo objects that life here. - llvm::DeleteContainerPointers(OMPTraitInfoVector); } void ASTContext::setTraversalScope(const std::vector &TopLevelDecls) { @@ -11011,6 +11008,6 @@ void ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap, } OMPTraitInfo &ASTContext::getNewOMPTraitInfo() { - OMPTraitInfoVector.push_back(new OMPTraitInfo()); + OMPTraitInfoVector.emplace_back(new OMPTraitInfo()); return *OMPTraitInfoVector.back(); } -- 2.7.4