Author: dblaikie Date: Tue Aug 18 18:56:00 2015 New Revision: 245392 URL: http://llvm.org/viewvc/llvm-project?rev=245392&view=rev Log: 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) Modified: cfe/trunk/include/clang/AST/CXXInheritance.h cfe/trunk/lib/AST/CXXInheritance.cpp Modified: cfe/trunk/include/clang/AST/CXXInheritance.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CXXInheritance.h?rev=245392&r1=245391&r2=245392&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/CXXInheritance.h (original) +++ cfe/trunk/include/clang/AST/CXXInheritance.h Tue Aug 18 18:56:00 2015 @@ -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(); } Modified: cfe/trunk/lib/AST/CXXInheritance.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CXXInheritance.cpp?rev=245392&r1=245391&r2=245392&view=diff ============================================================================== --- cfe/trunk/lib/AST/CXXInheritance.cpp (original) +++ cfe/trunk/lib/AST/CXXInheritance.cpp Tue Aug 18 18:56:00 2015 @@ -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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits