[clang] fcee807 - ASTContext::OMPTraitInfoVector: Use unique_ptr to simplify memory management
David Blaikie via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 28 22:39:10 PDT 2020
Author: David Blaikie
Date: 2020-04-28T22:31:16-07:00
New Revision: fcee80737c3272dc9de2dfd9635a1e90db215c7a
URL: https://github.com/llvm/llvm-project/commit/fcee80737c3272dc9de2dfd9635a1e90db215c7a
DIFF: https://github.com/llvm/llvm-project/commit/fcee80737c3272dc9de2dfd9635a1e90db215c7a.diff
LOG: ASTContext::OMPTraitInfoVector: Use unique_ptr to simplify memory management
Added:
Modified:
clang/include/clang/AST/ASTContext.h
clang/lib/AST/ASTContext.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index 82b8a51b9551..cd7021a5884b 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -3002,7 +3002,7 @@ OPT_LIST(V)
private:
/// All OMPTraitInfo objects live in this collection, one per
/// `pragma omp [begin] declare variant` directive.
- SmallVector<OMPTraitInfo *, 4> OMPTraitInfoVector;
+ SmallVector<std::unique_ptr<OMPTraitInfo>, 4> OMPTraitInfoVector;
};
/// Utility function for constructing a nullary selector.
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 9b07a883234b..612f6eec2d0f 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<Decl *> &TopLevelDecls) {
@@ -11011,6 +11008,6 @@ void ASTContext::getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
}
OMPTraitInfo &ASTContext::getNewOMPTraitInfo() {
- OMPTraitInfoVector.push_back(new OMPTraitInfo());
+ OMPTraitInfoVector.emplace_back(new OMPTraitInfo());
return *OMPTraitInfoVector.back();
}
More information about the cfe-commits
mailing list