diff options
| author | David Blaikie <dblaikie@gmail.com> | 2015-08-18 23:56:00 +0000 |
|---|---|---|
| committer | David Blaikie <dblaikie@gmail.com> | 2015-08-18 23:56:00 +0000 |
| commit | 8f2a7feec80009dd19031d80f0a6a002e6b2c7f4 (patch) | |
| tree | c18cb50720a9e6702b5a76a7d0c09bc3af95038c | |
| parent | 401cd25b2346d13e2ae77d7ced4e798a252b15e4 (diff) | |
| download | bcm5719-llvm-8f2a7feec80009dd19031d80f0a6a002e6b2c7f4.tar.gz bcm5719-llvm-8f2a7feec80009dd19031d80f0a6a002e6b2c7f4.zip | |
unique_ptrify CXXBasePaths::DeclsFound & remove the then-unnecessary user-defined dtor
Maybe this and the NumDeclsFound member should just be a std::vector
instead. (it could be a std::dynarray, but that missed standardization)
llvm-svn: 245392
| -rw-r--r-- | clang/include/clang/AST/CXXInheritance.h | 15 | ||||
| -rw-r--r-- | clang/lib/AST/CXXInheritance.cpp | 8 |
2 files changed, 10 insertions, 13 deletions
diff --git a/clang/include/clang/AST/CXXInheritance.h b/clang/include/clang/AST/CXXInheritance.h index 008efb36477..8587260049a 100644 --- a/clang/include/clang/AST/CXXInheritance.h +++ b/clang/include/clang/AST/CXXInheritance.h @@ -155,7 +155,7 @@ class CXXBasePaths { /// \brief Array of the declarations that have been found. This /// array is constructed only if needed, e.g., to iterate over the /// results within LookupResult. - NamedDecl **DeclsFound; + std::unique_ptr<NamedDecl *[]> DeclsFound; unsigned NumDeclsFound; friend class CXXRecordDecl; @@ -172,15 +172,12 @@ public: /// BasePaths - Construct a new BasePaths structure to record the /// paths for a derived-to-base search. - explicit CXXBasePaths(bool FindAmbiguities = true, - bool RecordPaths = true, + explicit CXXBasePaths(bool FindAmbiguities = true, bool RecordPaths = true, bool DetectVirtual = true) - : FindAmbiguities(FindAmbiguities), RecordPaths(RecordPaths), - DetectVirtual(DetectVirtual), DetectedVirtual(nullptr), - DeclsFound(nullptr), NumDeclsFound(0) { } - - ~CXXBasePaths() { delete [] DeclsFound; } - + : FindAmbiguities(FindAmbiguities), RecordPaths(RecordPaths), + DetectVirtual(DetectVirtual), DetectedVirtual(nullptr), + NumDeclsFound(0) {} + paths_iterator begin() { return Paths.begin(); } paths_iterator end() { return Paths.end(); } const_paths_iterator begin() const { return Paths.begin(); } diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp index 75d775f260c..6785a0c2935 100644 --- a/clang/lib/AST/CXXInheritance.cpp +++ b/clang/lib/AST/CXXInheritance.cpp @@ -31,16 +31,16 @@ void CXXBasePaths::ComputeDeclsFound() { Decls.insert(Path->Decls.front()); NumDeclsFound = Decls.size(); - DeclsFound = new NamedDecl * [NumDeclsFound]; - std::copy(Decls.begin(), Decls.end(), DeclsFound); + DeclsFound = llvm::make_unique<NamedDecl *[]>(NumDeclsFound); + std::copy(Decls.begin(), Decls.end(), DeclsFound.get()); } CXXBasePaths::decl_range CXXBasePaths::found_decls() { if (NumDeclsFound == 0) ComputeDeclsFound(); - return decl_range(decl_iterator(DeclsFound), - decl_iterator(DeclsFound + NumDeclsFound)); + return decl_range(decl_iterator(DeclsFound.get()), + decl_iterator(DeclsFound.get() + NumDeclsFound)); } /// isAmbiguous - Determines whether the set of paths provided is |

