From: David Blaikie Date: Wed, 29 Apr 2020 00:58:53 +0000 (-0700) Subject: ASTUnit::FileDecls: Use unique_ptr to simplify memory management X-Git-Tag: llvmorg-12-init~7516 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d9485dfbc12b277e4ba222f4c0e371c5914fe51e;p=platform%2Fupstream%2Fllvm.git ASTUnit::FileDecls: Use unique_ptr to simplify memory management --- diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h index a366551..50ab86e 100644 --- a/clang/include/clang/Frontend/ASTUnit.h +++ b/clang/include/clang/Frontend/ASTUnit.h @@ -172,7 +172,7 @@ private: /// Sorted (by file offset) vector of pairs of file offset/Decl. using LocDeclsTy = SmallVector, 64>; - using FileDeclsTy = llvm::DenseMap; + using FileDeclsTy = llvm::DenseMap>; /// Map from FileID to the file-level declarations that it contains. /// The files and decls are only local (and non-preamble) ones. diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index 7920aa2..57d025b 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -224,7 +224,7 @@ struct ASTUnit::ASTWriterData { }; void ASTUnit::clearFileLevelDecls() { - llvm::DeleteContainerSeconds(FileDecls); + FileDecls.clear(); } /// After failing to build a precompiled preamble (due to @@ -2436,9 +2436,9 @@ void ASTUnit::addFileLevelDecl(Decl *D) { if (FID.isInvalid()) return; - LocDeclsTy *&Decls = FileDecls[FID]; + std::unique_ptr &Decls = FileDecls[FID]; if (!Decls) - Decls = new LocDeclsTy(); + Decls = std::make_unique(); std::pair LocDecl(Offset, D);