From 70639e8de3f7232504008ae36507eb0125093907 Mon Sep 17 00:00:00 2001 From: Ahmed Charles Date: Fri, 7 Mar 2014 20:03:18 +0000 Subject: Replace OwningPtr with std::unique_ptr. This compiles cleanly with lldb/lld/clang-tools-extra/llvm. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203279 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/ARCMigrate/FileRemapper.h | 2 +- include/clang/AST/ASTContext.h | 6 +- include/clang/ASTMatchers/Dynamic/VariantValue.h | 2 +- include/clang/Analysis/AnalysisContext.h | 10 +-- include/clang/Basic/FileManager.h | 4 +- include/clang/Basic/FileSystemStatCache.h | 4 +- include/clang/Basic/SourceManager.h | 2 +- include/clang/Basic/VirtualFileSystem.h | 13 ++-- include/clang/CodeGen/CodeGenAction.h | 2 +- include/clang/Driver/Job.h | 2 +- include/clang/Driver/ToolChain.h | 8 +- include/clang/Frontend/ASTUnit.h | 68 ++++++++--------- include/clang/Frontend/ChainedDiagnosticConsumer.h | 4 +- include/clang/Frontend/CompilerInstance.h | 8 +- include/clang/Frontend/FrontendAction.h | 4 +- include/clang/Frontend/MultiplexConsumer.h | 4 +- include/clang/Frontend/TextDiagnosticPrinter.h | 2 +- include/clang/Frontend/VerifyDiagnosticConsumer.h | 2 +- include/clang/Lex/HeaderSearch.h | 2 +- include/clang/Lex/Preprocessor.h | 8 +- include/clang/Parse/Parser.h | 34 ++++----- include/clang/Rewrite/Core/TokenRewriter.h | 2 +- include/clang/Rewrite/Frontend/FrontendActions.h | 4 +- include/clang/Sema/Sema.h | 8 +- include/clang/Serialization/ASTReader.h | 4 +- include/clang/Serialization/GlobalModuleIndex.h | 2 +- include/clang/Serialization/Module.h | 2 +- .../Core/BugReporter/PathDiagnostic.h | 2 +- .../StaticAnalyzer/Core/PathSensitive/CoreEngine.h | 4 +- .../Core/PathSensitive/ProgramState.h | 8 +- include/clang/Tooling/CommonOptionsParser.h | 2 +- include/clang/Tooling/CompilationDatabase.h | 2 +- include/clang/Tooling/FileMatchTrie.h | 2 +- include/clang/Tooling/JSONCompilationDatabase.h | 2 +- lib/ARCMigrate/ARCMT.cpp | 10 +-- lib/ARCMigrate/FileRemapper.cpp | 4 +- lib/ARCMigrate/ObjCMT.cpp | 8 +- lib/ARCMigrate/TransRetainReleaseDealloc.cpp | 2 +- lib/ARCMigrate/TransUnbridgedCasts.cpp | 4 +- lib/AST/Expr.cpp | 2 +- lib/Analysis/CFG.cpp | 2 +- lib/Analysis/Consumed.cpp | 5 +- lib/Basic/FileManager.cpp | 4 +- lib/Basic/FileSystemStatCache.cpp | 2 +- lib/Basic/Targets.cpp | 2 +- lib/Basic/VirtualFileSystem.cpp | 20 ++--- lib/CodeGen/BackendUtil.cpp | 2 +- lib/CodeGen/CGBlocks.cpp | 2 +- lib/CodeGen/CGCXXABI.h | 2 +- lib/CodeGen/CGVTables.cpp | 2 +- lib/CodeGen/CodeGenAction.cpp | 6 +- lib/CodeGen/CodeGenModule.h | 4 +- lib/CodeGen/CodeGenPGO.h | 2 +- lib/CodeGen/ModuleBuilder.cpp | 7 +- lib/Driver/Driver.cpp | 2 +- lib/Driver/SanitizerArgs.cpp | 2 +- lib/Driver/ToolChains.cpp | 2 +- lib/Driver/ToolChains.h | 10 +-- lib/Format/ContinuationIndenter.cpp | 2 +- lib/Format/Format.cpp | 2 +- lib/Format/FormatToken.h | 2 +- lib/Format/UnwrappedLineParser.h | 2 +- lib/Frontend/ASTUnit.cpp | 85 +++++++++------------- lib/Frontend/ChainedIncludesSource.cpp | 8 +- lib/Frontend/CompilerInstance.cpp | 8 +- lib/Frontend/CompilerInvocation.cpp | 10 +-- lib/Frontend/CreateInvocationFromCommandLine.cpp | 4 +- lib/Frontend/FrontendAction.cpp | 8 +- lib/Frontend/FrontendActions.cpp | 16 ++-- lib/Frontend/MultiplexConsumer.cpp | 7 +- lib/Frontend/SerializedDiagnosticPrinter.cpp | 2 +- lib/FrontendTool/ExecuteCompilerInvocation.cpp | 6 +- lib/Lex/HeaderMap.cpp | 2 +- lib/Lex/PTHLexer.cpp | 8 +- lib/Parse/ParseAST.cpp | 7 +- lib/Parse/ParseDecl.cpp | 4 +- lib/Parse/ParseStmt.cpp | 22 +++--- lib/Rewrite/Core/Rewriter.cpp | 2 +- lib/Rewrite/Frontend/FixItRewriter.cpp | 2 +- lib/Rewrite/Frontend/FrontendActions.cpp | 4 +- lib/Sema/SemaLookup.cpp | 2 +- lib/Sema/SemaObjCProperty.cpp | 2 +- lib/Serialization/ASTReader.cpp | 4 +- lib/Serialization/GlobalModuleIndex.cpp | 12 +-- lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp | 3 +- .../Checkers/ArrayBoundCheckerV2.cpp | 4 +- .../Checkers/BasicObjCFoundationChecks.cpp | 10 +-- .../Checkers/BoolAssignmentChecker.cpp | 2 +- lib/StaticAnalyzer/Checkers/CStringChecker.cpp | 7 +- .../Checkers/CallAndMessageChecker.cpp | 42 +++++------ lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp | 3 +- .../Checkers/CastToStructChecker.cpp | 2 +- lib/StaticAnalyzer/Checkers/ChrootChecker.cpp | 2 +- lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp | 4 +- lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp | 4 +- lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp | 2 +- .../Checkers/ExprInspectionChecker.cpp | 2 +- .../Checkers/FixedAddressChecker.cpp | 2 +- .../Checkers/GenericTaintChecker.cpp | 2 +- .../Checkers/MacOSKeychainAPIChecker.cpp | 2 +- lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp | 2 +- lib/StaticAnalyzer/Checkers/MallocChecker.cpp | 14 ++-- .../Checkers/NSAutoreleasePoolChecker.cpp | 2 +- .../Checkers/NonNullParamChecker.cpp | 5 +- lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp | 4 +- .../Checkers/ObjCContainersChecker.cpp | 2 +- .../Checkers/PointerArithChecker.cpp | 2 +- lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp | 2 +- lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp | 4 +- lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp | 14 ++-- .../Checkers/ReturnPointerRangeChecker.cpp | 3 +- lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp | 4 +- .../Checkers/SimpleStreamChecker.cpp | 4 +- .../Checkers/StackAddrEscapeChecker.cpp | 4 +- lib/StaticAnalyzer/Checkers/StreamChecker.cpp | 4 +- lib/StaticAnalyzer/Checkers/TaintTesterChecker.cpp | 2 +- lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp | 2 +- .../Checkers/UndefCapturedBlockVarChecker.cpp | 2 +- lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp | 4 +- .../Checkers/UndefinedArraySubscriptChecker.cpp | 2 +- .../Checkers/UndefinedAssignmentChecker.cpp | 2 +- lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp | 4 +- lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp | 2 +- lib/StaticAnalyzer/Core/BugReporter.cpp | 20 +++-- lib/StaticAnalyzer/Core/ExprEngine.cpp | 2 +- lib/StaticAnalyzer/Core/PathDiagnostic.cpp | 4 +- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp | 10 +-- .../Frontend/CheckerRegistration.cpp | 4 +- lib/Tooling/CompilationDatabase.cpp | 6 +- lib/Tooling/JSONCompilationDatabase.cpp | 10 +-- lib/Tooling/Tooling.cpp | 10 +-- tools/arcmt-test/arcmt-test.cpp | 10 +-- tools/clang-check/ClangCheck.cpp | 2 +- tools/clang-format/ClangFormat.cpp | 2 +- tools/diagtool/ShowEnabledWarnings.cpp | 6 +- tools/driver/cc1_main.cpp | 2 +- tools/driver/cc1as_main.cpp | 31 ++++---- tools/driver/driver.cpp | 9 +-- tools/libclang/ARCMigrate.cpp | 4 +- tools/libclang/CIndex.cpp | 49 +++++-------- tools/libclang/CXLoadedDiagnostic.cpp | 9 ++- tools/libclang/Indexing.cpp | 21 +++--- unittests/AST/DeclPrinterTest.cpp | 3 +- unittests/AST/DeclTest.cpp | 2 +- unittests/AST/MatchVerifier.h | 2 +- unittests/AST/StmtPrinterTest.cpp | 3 +- unittests/ASTMatchers/ASTMatchersTest.cpp | 10 ++- unittests/ASTMatchers/ASTMatchersTest.h | 10 ++- unittests/ASTMatchers/Dynamic/RegistryTest.cpp | 2 +- unittests/Basic/VirtualFileSystemTest.cpp | 5 +- unittests/Sema/ExternalSemaSourceTest.cpp | 12 +-- unittests/Tooling/CompilationDatabaseTest.cpp | 18 ++--- unittests/Tooling/RefactoringCallbacksTest.cpp | 2 +- unittests/Tooling/ToolingTest.cpp | 10 +-- 154 files changed, 512 insertions(+), 537 deletions(-) diff --git a/include/clang/ARCMigrate/FileRemapper.h b/include/clang/ARCMigrate/FileRemapper.h index f7677cc862..c69892b69c 100644 --- a/include/clang/ARCMigrate/FileRemapper.h +++ b/include/clang/ARCMigrate/FileRemapper.h @@ -30,7 +30,7 @@ namespace arcmt { class FileRemapper { // FIXME: Reuse the same FileManager for multiple ASTContexts. - OwningPtr FileMgr; + std::unique_ptr FileMgr; typedef llvm::PointerUnion Target; typedef llvm::DenseMap MappingsTy; diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index 20fddf2d44..3f04588d56 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -394,7 +394,7 @@ private: PartialDiagnostic::StorageAllocator DiagAllocator; /// \brief The current C++ ABI. - OwningPtr ABI; + std::unique_ptr ABI; CXXABI *createCXXABI(const TargetInfo &T); /// \brief The logical -> physical address space map. @@ -2300,9 +2300,9 @@ private: friend class DeclarationNameTable; void ReleaseDeclContextMaps(); - llvm::OwningPtr AllParents; + std::unique_ptr AllParents; - llvm::OwningPtr VTContext; + std::unique_ptr VTContext; }; /// \brief Utility function for constructing a nullary selector. diff --git a/include/clang/ASTMatchers/Dynamic/VariantValue.h b/include/clang/ASTMatchers/Dynamic/VariantValue.h index 1b9970dd8f..a20237fc62 100644 --- a/include/clang/ASTMatchers/Dynamic/VariantValue.h +++ b/include/clang/ASTMatchers/Dynamic/VariantValue.h @@ -173,7 +173,7 @@ private: const MatcherT &matcher() const { return *Out; } private: - OwningPtr Out; + std::unique_ptr Out; }; IntrusiveRefCntPtr Value; diff --git a/include/clang/Analysis/AnalysisContext.h b/include/clang/Analysis/AnalysisContext.h index 8fc05f0561..9188d14438 100644 --- a/include/clang/Analysis/AnalysisContext.h +++ b/include/clang/Analysis/AnalysisContext.h @@ -69,16 +69,16 @@ class AnalysisDeclContext { const Decl * const D; - OwningPtr cfg, completeCFG; - OwningPtr cfgStmtMap; + std::unique_ptr cfg, completeCFG; + std::unique_ptr cfgStmtMap; CFG::BuildOptions cfgBuildOptions; CFG::BuildOptions::ForcedBlkExprs *forcedBlkExprs; bool builtCFG, builtCompleteCFG; - OwningPtr PM; - OwningPtr PCA; - OwningPtr CFA; + std::unique_ptr PM; + std::unique_ptr PCA; + std::unique_ptr CFA; llvm::BumpPtrAllocator A; diff --git a/include/clang/Basic/FileManager.h b/include/clang/Basic/FileManager.h index 1e13442770..a1068fe880 100644 --- a/include/clang/Basic/FileManager.h +++ b/include/clang/Basic/FileManager.h @@ -70,7 +70,7 @@ class FileEntry { bool IsValid; // Is this \c FileEntry initialized and valid? /// \brief The open file, if it is owned by the \p FileEntry. - mutable OwningPtr File; + mutable std::unique_ptr File; friend class FileManager; void closeFile() const { @@ -169,7 +169,7 @@ class FileManager : public RefCountedBase { unsigned NumDirCacheMisses, NumFileCacheMisses; // Caching. - OwningPtr StatCache; + std::unique_ptr StatCache; bool getStatValue(const char *Path, FileData &Data, bool isFile, vfs::File **F); diff --git a/include/clang/Basic/FileSystemStatCache.h b/include/clang/Basic/FileSystemStatCache.h index 05b65eede5..96384849c1 100644 --- a/include/clang/Basic/FileSystemStatCache.h +++ b/include/clang/Basic/FileSystemStatCache.h @@ -46,8 +46,8 @@ struct FileData { class FileSystemStatCache { virtual void anchor(); protected: - OwningPtr NextStatCache; - + std::unique_ptr NextStatCache; + public: virtual ~FileSystemStatCache() {} diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index 1d68681483..415a0afdf1 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -569,7 +569,7 @@ class SourceManager : public RefCountedBase { /// \brief Lazily create the object keeping overridden files info, since /// it is uncommonly used. - OwningPtr OverriddenFilesInfo; + std::unique_ptr OverriddenFilesInfo; OverriddenFilesInfoTy &getOverriddenFilesInfo() { if (!OverriddenFilesInfo) diff --git a/include/clang/Basic/VirtualFileSystem.h b/include/clang/Basic/VirtualFileSystem.h index 4c5f5a7f65..5595e143bc 100644 --- a/include/clang/Basic/VirtualFileSystem.h +++ b/include/clang/Basic/VirtualFileSystem.h @@ -84,10 +84,9 @@ public: /// \brief Get the status of the file. virtual llvm::ErrorOr status() = 0; /// \brief Get the contents of the file as a \p MemoryBuffer. - virtual llvm::error_code getBuffer(const Twine &Name, - OwningPtr &Result, - int64_t FileSize = -1, - bool RequiresNullTerminator = true) = 0; + virtual llvm::error_code + getBuffer(const Twine &Name, std::unique_ptr &Result, + int64_t FileSize = -1, bool RequiresNullTerminator = true) = 0; /// \brief Closes the file. virtual llvm::error_code close() = 0; /// \brief Sets the name to use for this file. @@ -103,12 +102,12 @@ public: virtual llvm::ErrorOr status(const Twine &Path) = 0; /// \brief Get a \p File object for the file at \p Path, if one exists. virtual llvm::error_code openFileForRead(const Twine &Path, - OwningPtr &Result) = 0; + std::unique_ptr &Result) = 0; /// This is a convenience method that opens a file, gets its content and then /// closes the file. llvm::error_code getBufferForFile(const Twine &Name, - OwningPtr &Result, + std::unique_ptr &Result, int64_t FileSize = -1, bool RequiresNullTerminator = true); }; @@ -149,7 +148,7 @@ public: llvm::ErrorOr status(const Twine &Path) override; llvm::error_code openFileForRead(const Twine &Path, - OwningPtr &Result) override; + std::unique_ptr &Result) override; }; /// \brief Get a globally unique ID for a virtual file or directory. diff --git a/include/clang/CodeGen/CodeGenAction.h b/include/clang/CodeGen/CodeGenAction.h index 912ef01a01..6097a021a8 100644 --- a/include/clang/CodeGen/CodeGenAction.h +++ b/include/clang/CodeGen/CodeGenAction.h @@ -24,7 +24,7 @@ class BackendConsumer; class CodeGenAction : public ASTFrontendAction { private: unsigned Act; - OwningPtr TheModule; + std::unique_ptr TheModule; llvm::Module *LinkModule; llvm::LLVMContext *VMContext; bool OwnsVMContext; diff --git a/include/clang/Driver/Job.h b/include/clang/Driver/Job.h index d7e74a9ce8..db571bf0c5 100644 --- a/include/clang/Driver/Job.h +++ b/include/clang/Driver/Job.h @@ -117,7 +117,7 @@ public: } private: - OwningPtr Fallback; + std::unique_ptr Fallback; }; /// JobList - A sequence of jobs to perform. diff --git a/include/clang/Driver/ToolChain.h b/include/clang/Driver/ToolChain.h index e8f2c78b73..0acf743b1f 100644 --- a/include/clang/Driver/ToolChain.h +++ b/include/clang/Driver/ToolChain.h @@ -66,15 +66,15 @@ private: /// programs. path_list ProgramPaths; - mutable OwningPtr Clang; - mutable OwningPtr Assemble; - mutable OwningPtr Link; + mutable std::unique_ptr Clang; + mutable std::unique_ptr Assemble; + mutable std::unique_ptr Link; Tool *getClang() const; Tool *getAssemble() const; Tool *getLink() const; Tool *getClangAs() const; - mutable OwningPtr SanitizerArguments; + mutable std::unique_ptr SanitizerArguments; protected: MultilibSet Multilibs; diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h index 3cf6d18642..fd8fed24c2 100644 --- a/include/clang/Frontend/ASTUnit.h +++ b/include/clang/Frontend/ASTUnit.h @@ -87,7 +87,7 @@ private: IntrusiveRefCntPtr Diagnostics; IntrusiveRefCntPtr FileMgr; IntrusiveRefCntPtr SourceMgr; - OwningPtr HeaderInfo; + std::unique_ptr HeaderInfo; IntrusiveRefCntPtr Target; IntrusiveRefCntPtr PP; IntrusiveRefCntPtr Ctx; @@ -97,18 +97,18 @@ private: bool HadModuleLoaderFatalFailure; struct ASTWriterData; - OwningPtr WriterData; + std::unique_ptr WriterData; FileSystemOptions FileSystemOpts; /// \brief The AST consumer that received information about the translation /// unit as it was parsed or loaded. - OwningPtr Consumer; - + std::unique_ptr Consumer; + /// \brief The semantic analysis object used to type-check the translation /// unit. - OwningPtr TheSema; - + std::unique_ptr TheSema; + /// Optional owned invocation, just used to make the invocation used in /// LoadFromCommandLine available. IntrusiveRefCntPtr Invocation; @@ -382,8 +382,8 @@ private: /// \brief Allocator used to store cached code completions. IntrusiveRefCntPtr CachedCompletionAllocator; - - OwningPtr CCTUInfo; + + std::unique_ptr CCTUInfo; /// \brief The set of cached code-completion results. std::vector CachedCompletionResults; @@ -754,19 +754,14 @@ public: /// This will only receive an ASTUnit if a new one was created. If an already /// created ASTUnit was passed in \p Unit then the caller can check that. /// - static ASTUnit *LoadFromCompilerInvocationAction(CompilerInvocation *CI, - IntrusiveRefCntPtr Diags, - ASTFrontendAction *Action = 0, - ASTUnit *Unit = 0, - bool Persistent = true, - StringRef ResourceFilesPath = StringRef(), - bool OnlyLocalDecls = false, - bool CaptureDiagnostics = false, - bool PrecompilePreamble = false, - bool CacheCodeCompletionResults = false, - bool IncludeBriefCommentsInCodeCompletion = false, - bool UserFilesAreVolatile = false, - OwningPtr *ErrAST = 0); + static ASTUnit *LoadFromCompilerInvocationAction( + CompilerInvocation *CI, IntrusiveRefCntPtr Diags, + ASTFrontendAction *Action = 0, ASTUnit *Unit = 0, bool Persistent = true, + StringRef ResourceFilesPath = StringRef(), bool OnlyLocalDecls = false, + bool CaptureDiagnostics = false, bool PrecompilePreamble = false, + bool CacheCodeCompletionResults = false, + bool IncludeBriefCommentsInCodeCompletion = false, + bool UserFilesAreVolatile = false, std::unique_ptr *ErrAST = 0); /// LoadFromCompilerInvocation - Create an ASTUnit from a source file, via a /// CompilerInvocation object. @@ -807,24 +802,19 @@ public: /// // FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we // shouldn't need to specify them at construction time. - static ASTUnit *LoadFromCommandLine(const char **ArgBegin, - const char **ArgEnd, - IntrusiveRefCntPtr Diags, - StringRef ResourceFilesPath, - bool OnlyLocalDecls = false, - bool CaptureDiagnostics = false, - ArrayRef RemappedFiles = None, - bool RemappedFilesKeepOriginalName = true, - bool PrecompilePreamble = false, - TranslationUnitKind TUKind = TU_Complete, - bool CacheCodeCompletionResults = false, - bool IncludeBriefCommentsInCodeCompletion = false, - bool AllowPCHWithCompilerErrors = false, - bool SkipFunctionBodies = false, - bool UserFilesAreVolatile = false, - bool ForSerialization = false, - OwningPtr *ErrAST = 0); - + static ASTUnit *LoadFromCommandLine( + const char **ArgBegin, const char **ArgEnd, + IntrusiveRefCntPtr Diags, StringRef ResourceFilesPath, + bool OnlyLocalDecls = false, bool CaptureDiagnostics = false, + ArrayRef RemappedFiles = None, + bool RemappedFilesKeepOriginalName = true, + bool PrecompilePreamble = false, TranslationUnitKind TUKind = TU_Complete, + bool CacheCodeCompletionResults = false, + bool IncludeBriefCommentsInCodeCompletion = false, + bool AllowPCHWithCompilerErrors = false, bool SkipFunctionBodies = false, + bool UserFilesAreVolatile = false, bool ForSerialization = false, + std::unique_ptr *ErrAST = 0); + /// \brief Reparse the source files using the same command-line options that /// were originally used to produce this translation unit. /// diff --git a/include/clang/Frontend/ChainedDiagnosticConsumer.h b/include/clang/Frontend/ChainedDiagnosticConsumer.h index b7dc7c7b52..b428200f37 100644 --- a/include/clang/Frontend/ChainedDiagnosticConsumer.h +++ b/include/clang/Frontend/ChainedDiagnosticConsumer.h @@ -22,8 +22,8 @@ class LangOptions; /// diagnostics should be included in counts. class ChainedDiagnosticConsumer : public DiagnosticConsumer { virtual void anchor(); - OwningPtr Primary; - OwningPtr Secondary; + std::unique_ptr Primary; + std::unique_ptr Secondary; public: ChainedDiagnosticConsumer(DiagnosticConsumer *_Primary, diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h index 62aeca103c..3cb2d21e81 100644 --- a/include/clang/Frontend/CompilerInstance.h +++ b/include/clang/Frontend/CompilerInstance.h @@ -91,16 +91,16 @@ class CompilerInstance : public ModuleLoader { IntrusiveRefCntPtr Context; /// The AST consumer. - OwningPtr Consumer; + std::unique_ptr Consumer; /// The code completion consumer. - OwningPtr CompletionConsumer; + std::unique_ptr CompletionConsumer; /// \brief The semantic analysis object. - OwningPtr TheSema; + std::unique_ptr TheSema; /// \brief The frontend timer - OwningPtr FrontendTimer; + std::unique_ptr FrontendTimer; /// \brief The ASTReader, if one exists. IntrusiveRefCntPtr ModuleManager; diff --git a/include/clang/Frontend/FrontendAction.h b/include/clang/Frontend/FrontendAction.h index 034d38c1d8..20a7b99fc1 100644 --- a/include/clang/Frontend/FrontendAction.h +++ b/include/clang/Frontend/FrontendAction.h @@ -35,7 +35,7 @@ class CompilerInstance; /// Abstract base class for actions which can be performed by the frontend. class FrontendAction { FrontendInputFile CurrentInput; - OwningPtr CurrentASTUnit; + std::unique_ptr CurrentASTUnit; CompilerInstance *Instance; friend class ASTMergeAction; friend class WrapperFrontendAction; @@ -260,7 +260,7 @@ public: /// some existing action's behavior. It implements every virtual method in /// the FrontendAction interface by forwarding to the wrapped action. class WrapperFrontendAction : public FrontendAction { - OwningPtr WrappedAction; + std::unique_ptr WrappedAction; protected: virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, diff --git a/include/clang/Frontend/MultiplexConsumer.h b/include/clang/Frontend/MultiplexConsumer.h index 6ea7547c71..b0080ec32c 100644 --- a/include/clang/Frontend/MultiplexConsumer.h +++ b/include/clang/Frontend/MultiplexConsumer.h @@ -53,8 +53,8 @@ public: private: std::vector Consumers; // Owns these. - OwningPtr MutationListener; - OwningPtr DeserializationListener; + std::unique_ptr MutationListener; + std::unique_ptr DeserializationListener; }; } // end namespace clang diff --git a/include/clang/Frontend/TextDiagnosticPrinter.h b/include/clang/Frontend/TextDiagnosticPrinter.h index dc8047066c..658f9d4973 100644 --- a/include/clang/Frontend/TextDiagnosticPrinter.h +++ b/include/clang/Frontend/TextDiagnosticPrinter.h @@ -30,7 +30,7 @@ class TextDiagnosticPrinter : public DiagnosticConsumer { IntrusiveRefCntPtr DiagOpts; /// \brief Handle to the currently active text diagnostic emitter. - OwningPtr TextDiag; + std::unique_ptr TextDiag; /// A string to prefix to error messages. std::string Prefix; diff --git a/include/clang/Frontend/VerifyDiagnosticConsumer.h b/include/clang/Frontend/VerifyDiagnosticConsumer.h index 517c7374f0..216b99ac78 100644 --- a/include/clang/Frontend/VerifyDiagnosticConsumer.h +++ b/include/clang/Frontend/VerifyDiagnosticConsumer.h @@ -204,7 +204,7 @@ private: DiagnosticsEngine &Diags; DiagnosticConsumer *PrimaryClient; bool OwnsPrimaryClient; - OwningPtr Buffer; + std::unique_ptr Buffer; const Preprocessor *CurrentPreprocessor; const LangOptions *LangOpts; SourceManager *SrcManager; diff --git a/include/clang/Lex/HeaderSearch.h b/include/clang/Lex/HeaderSearch.h index 93efa2d4a3..ffd13b4c77 100644 --- a/include/clang/Lex/HeaderSearch.h +++ b/include/clang/Lex/HeaderSearch.h @@ -205,7 +205,7 @@ class HeaderSearch { /// include_alias pragma for Microsoft compatibility. typedef llvm::StringMap IncludeAliasMap; - OwningPtr IncludeAliases; + std::unique_ptr IncludeAliases; /// HeaderMaps - This is a mapping from FileEntry -> HeaderMap, uniquing /// headermaps. This vector owns the headermap. diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index e0cfc82c47..a992beee8f 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -102,7 +102,7 @@ class Preprocessor : public RefCountedBase { /// An optional PTHManager object used for getting tokens from /// a token cache rather than lexing the original source file. - OwningPtr PTH; + std::unique_ptr PTH; /// A BumpPtrAllocator object used to quickly allocate and release /// objects internal to the Preprocessor. @@ -254,13 +254,13 @@ class Preprocessor : public RefCountedBase { /// not expanding a macro and we are lexing directly from source code. /// /// Only one of CurLexer, CurPTHLexer, or CurTokenLexer will be non-null. - OwningPtr CurLexer; + std::unique_ptr CurLexer; /// \brief The current top of stack that we're lexing from if /// not expanding from a macro and we are lexing from a PTH cache. /// /// Only one of CurLexer, CurPTHLexer, or CurTokenLexer will be non-null. - OwningPtr CurPTHLexer; + std::unique_ptr CurPTHLexer; /// \brief The current top of the stack what we're lexing from /// if not expanding a macro. @@ -278,7 +278,7 @@ class Preprocessor : public RefCountedBase { /// \brief The current macro we are expanding, if we are expanding a macro. /// /// One of CurLexer and CurTokenLexer must be null. - OwningPtr CurTokenLexer; + std::unique_ptr CurTokenLexer; /// \brief The kind of lexer we're currently working with. enum CurLexerKind { diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 93fc611bdb..0574f18351 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -139,23 +139,23 @@ class Parser : public CodeCompletionHandler { llvm::SmallDenseMap ContextualKeywords; - OwningPtr AlignHandler; - OwningPtr GCCVisibilityHandler; - OwningPtr OptionsHandler; - OwningPtr PackHandler; - OwningPtr MSStructHandler; - OwningPtr UnusedHandler; - OwningPtr WeakHandler; - OwningPtr RedefineExtnameHandler; - OwningPtr FPContractHandler; - OwningPtr OpenCLExtensionHandler; - OwningPtr OpenMPHandler; - OwningPtr MSCommentHandler; - OwningPtr MSDetectMismatchHandler; - OwningPtr MSPointersToMembers; - OwningPtr MSVtorDisp; - - OwningPtr CommentSemaHandler; + std::unique_ptr AlignHandler; + std::unique_ptr GCCVisibilityHandler; + std::unique_ptr OptionsHandler; + std::unique_ptr PackHandler; + std::unique_ptr MSStructHandler; + std::unique_ptr UnusedHandler; + std::unique_ptr WeakHandler; + std::unique_ptr RedefineExtnameHandler; + std::unique_ptr FPContractHandler; + std::unique_ptr OpenCLExtensionHandler; + std::unique_ptr OpenMPHandler; + std::unique_ptr MSCommentHandler; + std::unique_ptr MSDetectMismatchHandler; + std::unique_ptr MSPointersToMembers; + std::unique_ptr MSVtorDisp; + + std::unique_ptr CommentSemaHandler; /// Whether the '>' token acts as an operator or not. This will be /// true except when we are parsing an expression within a C++ diff --git a/include/clang/Rewrite/Core/TokenRewriter.h b/include/clang/Rewrite/Core/TokenRewriter.h index ec0bb5ba08..78fbd24db8 100644 --- a/include/clang/Rewrite/Core/TokenRewriter.h +++ b/include/clang/Rewrite/Core/TokenRewriter.h @@ -41,7 +41,7 @@ namespace clang { /// ScratchBuf - This is the buffer that we create scratch tokens from. /// - OwningPtr ScratchBuf; + std::unique_ptr ScratchBuf; TokenRewriter(const TokenRewriter &) LLVM_DELETED_FUNCTION; void operator=(const TokenRewriter &) LLVM_DELETED_FUNCTION; diff --git a/include/clang/Rewrite/Frontend/FrontendActions.h b/include/clang/Rewrite/Frontend/FrontendActions.h index ea876d9980..70ff71f990 100644 --- a/include/clang/Rewrite/Frontend/FrontendActions.h +++ b/include/clang/Rewrite/Frontend/FrontendActions.h @@ -28,8 +28,8 @@ protected: class FixItAction : public ASTFrontendAction { protected: - OwningPtr Rewriter; - OwningPtr FixItOpts; + std::unique_ptr Rewriter; + std::unique_ptr FixItOpts; virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, StringRef InFile); diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index ffbaa48cc9..49c2b6b0a0 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -333,7 +333,7 @@ public: ExtVectorDeclsType ExtVectorDecls; /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes. - OwningPtr FieldCollector; + std::unique_ptr FieldCollector; typedef llvm::SmallSetVector NamedDeclSetType; @@ -345,7 +345,7 @@ public: /// PureVirtualClassDiagSet - a set of class declarations which we have /// emitted a list of pure virtual functions. Used to prevent emitting the /// same list more than once. - OwningPtr PureVirtualClassDiagSet; + std::unique_ptr PureVirtualClassDiagSet; /// ParsingInitForAutoVars - a set of declarations with auto types for which /// we are currently parsing the initializer. @@ -597,7 +597,7 @@ public: RecordDecl *MSVCGuidDecl; /// \brief Caches identifiers/selectors for NSFoundation APIs. - OwningPtr NSAPIObj; + std::unique_ptr NSAPIObj; /// \brief The declaration of the Objective-C NSNumber class. ObjCInterfaceDecl *NSNumberDecl; @@ -8026,7 +8026,7 @@ public: private: /// \brief A map from magic value to type information. - OwningPtr > + std::unique_ptr> TypeTagForDatatypeMagicValues; /// \brief Peform checks on a call of a function with argument_with_type_tag diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index 1fb493084c..4ab9999d7b 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -322,7 +322,7 @@ public: private: /// \brief The receiver of some callbacks invoked by ASTReader. - OwningPtr Listener; + std::unique_ptr Listener; /// \brief The receiver of deserialization events. ASTDeserializationListener *DeserializationListener; @@ -352,7 +352,7 @@ private: SourceLocation CurrentImportLoc; /// \brief The global module index, if loaded. - llvm::OwningPtr GlobalIndex; + std::unique_ptr GlobalIndex; /// \brief A map of global bit offsets to the module that stores entities /// at those bit offsets. diff --git a/include/clang/Serialization/GlobalModuleIndex.h b/include/clang/Serialization/GlobalModuleIndex.h index 76414ba634..69ba38a119 100644 --- a/include/clang/Serialization/GlobalModuleIndex.h +++ b/include/clang/Serialization/GlobalModuleIndex.h @@ -59,7 +59,7 @@ using serialization::ModuleFile; class GlobalModuleIndex { /// \brief Buffer containing the index file, which is lazily accessed so long /// as the global module index is live. - llvm::OwningPtr Buffer; + std::unique_ptr Buffer; /// \brief The hash table. /// diff --git a/include/clang/Serialization/Module.h b/include/clang/Serialization/Module.h index ce4a7cb1c5..09e6c0ea28 100644 --- a/include/clang/Serialization/Module.h +++ b/include/clang/Serialization/Module.h @@ -151,7 +151,7 @@ public: /// \brief The memory buffer that stores the data associated with /// this AST file. - OwningPtr Buffer; + std::unique_ptr Buffer; /// \brief The size of this file, in bits. uint64_t SizeInBits; diff --git a/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h b/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h index 0bbe1985e2..6e41f38f54 100644 --- a/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h +++ b/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h @@ -499,7 +499,7 @@ class PathDiagnosticEventPiece : public PathDiagnosticSpotPiece { /// supply a message that will be used to construct an extra hint on the /// returns from all the calls on the stack from this event to the final /// diagnostic. - OwningPtr CallStackHint; + std::unique_ptr CallStackHint; public: PathDiagnosticEventPiece(const PathDiagnosticLocation &pos, diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h b/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h index e38fd88c15..2e2f5f2e0b 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h @@ -60,12 +60,12 @@ private: SubEngine& SubEng; /// G - The simulation graph. Each node is a (location,state) pair. - OwningPtr G; + std::unique_ptr G; /// WList - A set of queued nodes that need to be processed by the /// worklist algorithm. It is up to the implementation of WList to decide /// the order that nodes are processed. - OwningPtr WList; + std::unique_ptr WList; /// BCounterFactory - A factory object for created BlockCounter objects. /// These are used to record for key nodes in the ExplodedGraph the diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h b/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h index f10a14c0c7..93c9259ea7 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h @@ -441,8 +441,8 @@ private: SubEngine *Eng; /* Can be null. */ EnvironmentManager EnvMgr; - OwningPtr StoreMgr; - OwningPtr ConstraintMgr; + std::unique_ptr StoreMgr; + std::unique_ptr ConstraintMgr; ProgramState::GenericDataMap::Factory GDMFactory; @@ -454,10 +454,10 @@ private: llvm::FoldingSet StateSet; /// Object that manages the data for all created SVals. - OwningPtr svalBuilder; + std::unique_ptr svalBuilder; /// Manages memory for created CallEvents. - OwningPtr CallEventMgr; + std::unique_ptr CallEventMgr; /// A BumpPtrAllocator to allocate states. llvm::BumpPtrAllocator &Alloc; diff --git a/include/clang/Tooling/CommonOptionsParser.h b/include/clang/Tooling/CommonOptionsParser.h index 666e150478..1f32cd82cf 100644 --- a/include/clang/Tooling/CommonOptionsParser.h +++ b/include/clang/Tooling/CommonOptionsParser.h @@ -87,7 +87,7 @@ public: static const char *const HelpMessage; private: - OwningPtr Compilations; + std::unique_ptr Compilations; std::vector SourcePathList; }; diff --git a/include/clang/Tooling/CompilationDatabase.h b/include/clang/Tooling/CompilationDatabase.h index 8cca3296f9..e24175bd85 100644 --- a/include/clang/Tooling/CompilationDatabase.h +++ b/include/clang/Tooling/CompilationDatabase.h @@ -166,7 +166,7 @@ public: /// The argument list is meant to be compatible with normal llvm command line /// parsing in main methods. /// int main(int argc, char **argv) { - /// OwningPtr Compilations( + /// std::unique_ptr Compilations( /// FixedCompilationDatabase::loadFromCommandLine(argc, argv)); /// cl::ParseCommandLineOptions(argc, argv); /// ... diff --git a/include/clang/Tooling/FileMatchTrie.h b/include/clang/Tooling/FileMatchTrie.h index e531854cca..8e72dc9b24 100644 --- a/include/clang/Tooling/FileMatchTrie.h +++ b/include/clang/Tooling/FileMatchTrie.h @@ -79,7 +79,7 @@ public: raw_ostream &Error) const; private: FileMatchTrieNode *Root; - OwningPtr Comparator; + std::unique_ptr Comparator; }; diff --git a/include/clang/Tooling/JSONCompilationDatabase.h b/include/clang/Tooling/JSONCompilationDatabase.h index e3f149bebc..1ab91fc1eb 100644 --- a/include/clang/Tooling/JSONCompilationDatabase.h +++ b/include/clang/Tooling/JSONCompilationDatabase.h @@ -104,7 +104,7 @@ private: FileMatchTrie MatchTrie; - OwningPtr Database; + std::unique_ptr Database; llvm::SourceMgr SM; llvm::yaml::Stream YAMLStream; }; diff --git a/lib/ARCMigrate/ARCMT.cpp b/lib/ARCMigrate/ARCMT.cpp index f8c477b5ed..5cbd799572 100644 --- a/lib/ARCMigrate/ARCMT.cpp +++ b/lib/ARCMigrate/ARCMT.cpp @@ -167,7 +167,7 @@ static bool HasARCRuntime(CompilerInvocation &origCI) { static CompilerInvocation * createInvocationForMigration(CompilerInvocation &origCI) { - OwningPtr CInvok; + std::unique_ptr CInvok; CInvok.reset(new CompilerInvocation(origCI)); PreprocessorOptions &PPOpts = CInvok->getPreprocessorOpts(); if (!PPOpts.ImplicitPCHInclude.empty()) { @@ -246,7 +246,7 @@ bool arcmt::checkForManualIssues(CompilerInvocation &origCI, NoFinalizeRemoval); assert(!transforms.empty()); - OwningPtr CInvok; + std::unique_ptr CInvok; CInvok.reset(createInvocationForMigration(origCI)); CInvok->getFrontendOpts().Inputs.clear(); CInvok->getFrontendOpts().Inputs.push_back(Input); @@ -263,7 +263,7 @@ bool arcmt::checkForManualIssues(CompilerInvocation &origCI, CaptureDiagnosticConsumer errRec(*Diags, *DiagClient, capturedDiags); Diags->setClient(&errRec, /*ShouldOwnClient=*/false); - OwningPtr Unit( + std::unique_ptr Unit( ASTUnit::LoadFromCompilerInvocationAction(CInvok.release(), Diags)); if (!Unit) { errRec.FinishCapture(); @@ -515,7 +515,7 @@ MigrationProcess::MigrationProcess(const CompilerInvocation &CI, bool MigrationProcess::applyTransform(TransformFn trans, RewriteListener *listener) { - OwningPtr CInvok; + std::unique_ptr CInvok; CInvok.reset(createInvocationForMigration(OrigCI)); CInvok->getDiagnosticOpts().IgnoreWarnings = true; @@ -534,7 +534,7 @@ bool MigrationProcess::applyTransform(TransformFn trans, CaptureDiagnosticConsumer errRec(*Diags, *DiagClient, capturedDiags); Diags->setClient(&errRec, /*ShouldOwnClient=*/false); - OwningPtr ASTAction; + std::unique_ptr ASTAction; ASTAction.reset(new ARCMTMacroTrackerAction(ARCMTMacroLocs)); OwningPtr Unit(ASTUnit::LoadFromCompilerInvocationAction( diff --git a/lib/ARCMigrate/FileRemapper.cpp b/lib/ARCMigrate/FileRemapper.cpp index a6c019bcae..e1cebc71a0 100644 --- a/lib/ARCMigrate/FileRemapper.cpp +++ b/lib/ARCMigrate/FileRemapper.cpp @@ -64,8 +64,8 @@ bool FileRemapper::initFromFile(StringRef filePath, DiagnosticsEngine &Diag, return false; std::vector > pairs; - - OwningPtr fileBuf; + + std::unique_ptr fileBuf; if (llvm::MemoryBuffer::getFile(infoFile.c_str(), fileBuf)) return report("Error opening file: " + infoFile, Diag); diff --git a/lib/ARCMigrate/ObjCMT.cpp b/lib/ARCMigrate/ObjCMT.cpp index d8d84194c5..307f910945 100644 --- a/lib/ARCMigrate/ObjCMT.cpp +++ b/lib/ARCMigrate/ObjCMT.cpp @@ -88,8 +88,8 @@ public: FileID FileId; const TypedefDecl *NSIntegerTypedefed; const TypedefDecl *NSUIntegerTypedefed; - OwningPtr NSAPIObj; - OwningPtr Editor; + std::unique_ptr NSAPIObj; + std::unique_ptr Editor; FileRemapper &Remapper; FileManager &FileMgr; const PPConditionalDirectiveRecord *PPRec; @@ -253,7 +253,7 @@ public: class BodyMigrator : public RecursiveASTVisitor { ObjCMigrateASTConsumer &Consumer; - OwningPtr PMap; + std::unique_ptr PMap; public: BodyMigrator(ObjCMigrateASTConsumer &consumer) : Consumer(consumer) { } @@ -1988,7 +1988,7 @@ public: bool parse(StringRef File, SmallVectorImpl &Entries) { using namespace llvm::yaml; - OwningPtr FileBuf; + std::unique_ptr FileBuf; if (llvm::MemoryBuffer::getFile(File, FileBuf)) return true; diff --git a/lib/ARCMigrate/TransRetainReleaseDealloc.cpp b/lib/ARCMigrate/TransRetainReleaseDealloc.cpp index 61e2e98513..5db5fa084d 100644 --- a/lib/ARCMigrate/TransRetainReleaseDealloc.cpp +++ b/lib/ARCMigrate/TransRetainReleaseDealloc.cpp @@ -38,7 +38,7 @@ class RetainReleaseDeallocRemover : MigrationPass &Pass; ExprSet Removables; - OwningPtr StmtMap; + std::unique_ptr StmtMap; Selector DelegateSel, FinalizeSel; diff --git a/lib/ARCMigrate/TransUnbridgedCasts.cpp b/lib/ARCMigrate/TransUnbridgedCasts.cpp index 8c621280ab..0aa0c89f39 100644 --- a/lib/ARCMigrate/TransUnbridgedCasts.cpp +++ b/lib/ARCMigrate/TransUnbridgedCasts.cpp @@ -60,10 +60,10 @@ namespace { class UnbridgedCastRewriter : public RecursiveASTVisitor{ MigrationPass &Pass; IdentifierInfo *SelfII; - OwningPtr StmtMap; + std::unique_ptr StmtMap; Decl *ParentD; Stmt *Body; - mutable OwningPtr Removables; + mutable std::unique_ptr Removables; public: UnbridgedCastRewriter(MigrationPass &pass) : Pass(pass), ParentD(0), Body(0) { diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 4492d02b7a..0b8948e5fa 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -453,7 +453,7 @@ std::string PredefinedExpr::ComputeName(IdentType IT, const Decl *CurrentDecl) { if (IT == PredefinedExpr::FuncDName) { if (const NamedDecl *ND = dyn_cast(CurrentDecl)) { - OwningPtr MC; + std::unique_ptr MC; MC.reset(Context.createMangleContext()); if (MC->shouldMangleDeclName(ND)) { diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp index da953b779b..f8c8fe4c0a 100644 --- a/lib/Analysis/CFG.cpp +++ b/lib/Analysis/CFG.cpp @@ -291,7 +291,7 @@ class CFGBuilder { typedef BlockScopePosPair JumpSource; ASTContext *Context; - OwningPtr cfg; + std::unique_ptr cfg; CFGBlock *Block; CFGBlock *Succ; diff --git a/lib/Analysis/Consumed.cpp b/lib/Analysis/Consumed.cpp index 23fc437dfa..ce85796ab4 100644 --- a/lib/Analysis/Consumed.cpp +++ b/lib/Analysis/Consumed.cpp @@ -1286,8 +1286,9 @@ void ConsumedAnalyzer::determineExpectedReturnState(AnalysisDeclContext &AC, bool ConsumedAnalyzer::splitState(const CFGBlock *CurrBlock, const ConsumedStmtVisitor &Visitor) { - - OwningPtr FalseStates(new ConsumedStateMap(*CurrStates)); + + std::unique_ptr FalseStates( + new ConsumedStateMap(*CurrStates)); PropagationInfo PInfo; if (const IfStmt *IfNode = diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp index 4431e45962..579c8185b3 100644 --- a/lib/Basic/FileManager.cpp +++ b/lib/Basic/FileManager.cpp @@ -379,7 +379,7 @@ void FileManager::FixupRelativePath(SmallVectorImpl &path) const { llvm::MemoryBuffer *FileManager:: getBufferForFile(const FileEntry *Entry, std::string *ErrorStr, bool isVolatile) { - OwningPtr Result; + std::unique_ptr Result; llvm::error_code ec; uint64_t FileSize = Entry->getSize(); @@ -417,7 +417,7 @@ getBufferForFile(const FileEntry *Entry, std::string *ErrorStr, llvm::MemoryBuffer *FileManager:: getBufferForFile(StringRef Filename, std::string *ErrorStr) { - OwningPtr Result; + std::unique_ptr Result; llvm::error_code ec; if (FileSystemOpts.WorkingDir.empty()) { ec = FS->getBufferForFile(Filename, Result); diff --git a/lib/Basic/FileSystemStatCache.cpp b/lib/Basic/FileSystemStatCache.cpp index dfab9299c0..9d87999509 100644 --- a/lib/Basic/FileSystemStatCache.cpp +++ b/lib/Basic/FileSystemStatCache.cpp @@ -77,7 +77,7 @@ bool FileSystemStatCache::get(const char *Path, FileData &Data, bool isFile, // // Because of this, check to see if the file exists with 'open'. If the // open succeeds, use fstat to get the stat info. - llvm::OwningPtr OwnedFile; + std::unique_ptr OwnedFile; llvm::error_code EC = FS.openFileForRead(Path, OwnedFile); if (EC) { diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index a839b6a938..0d1e388c8d 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -5965,7 +5965,7 @@ TargetInfo *TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags, llvm::Triple Triple(Opts->Triple); // Construct the target - OwningPtr Target(AllocateTarget(Triple)); + std::unique_ptr Target(AllocateTarget(Triple)); if (!Target) { Diags.Report(diag::err_target_unknown_triple) << Triple.str(); return 0; diff --git a/lib/Basic/VirtualFileSystem.cpp b/lib/Basic/VirtualFileSystem.cpp index 3775fda492..1ff21e1552 100644 --- a/lib/Basic/VirtualFileSystem.cpp +++ b/lib/Basic/VirtualFileSystem.cpp @@ -65,10 +65,10 @@ File::~File() {} FileSystem::~FileSystem() {} error_code FileSystem::getBufferForFile(const llvm::Twine &Name, - OwningPtr &Result, + std::unique_ptr &Result, int64_t FileSize, bool RequiresNullTerminator) { - llvm::OwningPtr F; + std::unique_ptr F; if (error_code EC = openFileForRead(Name, F)) return EC; @@ -93,7 +93,7 @@ class RealFile : public File { public: ~RealFile(); ErrorOr status() override; - error_code getBuffer(const Twine &Name, OwningPtr &Result, + error_code getBuffer(const Twine &Name, std::unique_ptr &Result, int64_t FileSize = -1, bool RequiresNullTerminator = true) override; error_code close() override; @@ -116,7 +116,7 @@ ErrorOr RealFile::status() { } error_code RealFile::getBuffer(const Twine &Name, - OwningPtr &Result, + std::unique_ptr &Result, int64_t FileSize, bool RequiresNullTerminator) { assert(FD != -1 && "cannot get buffer for closed file"); return MemoryBuffer::getOpenFile(FD, Name.str().c_str(), Result, FileSize, @@ -150,7 +150,7 @@ class RealFileSystem : public FileSystem { public: ErrorOr status(const Twine &Path) override; error_code openFileForRead(const Twine &Path, - OwningPtr &Result) override; + std::unique_ptr &Result) override; }; } // end anonymous namespace @@ -164,7 +164,7 @@ ErrorOr RealFileSystem::status(const Twine &Path) { } error_code RealFileSystem::openFileForRead(const Twine &Name, - OwningPtr &Result) { + std::unique_ptr &Result) { int FD; if (error_code EC = sys::fs::openFileForRead(Name, FD)) return EC; @@ -200,7 +200,7 @@ ErrorOr OverlayFileSystem::status(const Twine &Path) { } error_code OverlayFileSystem::openFileForRead(const llvm::Twine &Path, - OwningPtr &Result) { + std::unique_ptr &Result) { // FIXME: handle symlinks that cross file systems for (iterator I = overlays_begin(), E = overlays_end(); I != E; ++I) { error_code EC = (*I)->openFileForRead(Path, Result); @@ -389,7 +389,7 @@ public: ErrorOr status(const Twine &Path) override; error_code openFileForRead(const Twine &Path, - OwningPtr &Result) override; + std::unique_ptr &Result) override; }; /// \brief A helper class to hold the common YAML parsing state. @@ -727,7 +727,7 @@ VFSFromYAML *VFSFromYAML::create(MemoryBuffer *Buffer, VFSFromYAMLParser P(Stream); - OwningPtr FS(new VFSFromYAML(ExternalFS)); + std::unique_ptr FS(new VFSFromYAML(ExternalFS)); if (!P.parse(Root, FS.get())) return NULL; @@ -810,7 +810,7 @@ ErrorOr VFSFromYAML::status(const Twine &Path) { } error_code VFSFromYAML::openFileForRead(const Twine &Path, - OwningPtr &Result) { + std::unique_ptr &Result) { ErrorOr E = lookupPath(Path); if (!E) return E.getError(); diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp index dbc62b79de..73b7db7fb9 100644 --- a/lib/CodeGen/BackendUtil.cpp +++ b/lib/CodeGen/BackendUtil.cpp @@ -122,7 +122,7 @@ public: BuryPointer(TM.release()); } - llvm::OwningPtr TM; + std::unique_ptr TM; void EmitAssembly(BackendAction Action, raw_ostream *OS); }; diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index 86afa32489..7f2533d1ff 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -679,7 +679,7 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const BlockExpr *blockExpr) { } // Find the block info for this block and take ownership of it. - OwningPtr blockInfo; + std::unique_ptr blockInfo; blockInfo.reset(findAndRemoveBlockInfo(&FirstBlockInfo, blockExpr->getBlockDecl())); diff --git a/lib/CodeGen/CGCXXABI.h b/lib/CodeGen/CGCXXABI.h index 1112739cc1..73ad93f652 100644 --- a/lib/CodeGen/CGCXXABI.h +++ b/lib/CodeGen/CGCXXABI.h @@ -41,7 +41,7 @@ namespace CodeGen { class CGCXXABI { protected: CodeGenModule &CGM; - OwningPtr MangleCtx; + std::unique_ptr MangleCtx; CGCXXABI(CodeGenModule &CGM) : CGM(CGM), MangleCtx(CGM.getContext().createMangleContext()) {} diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp index 4a381a8d48..0ad765ce22 100644 --- a/lib/CodeGen/CGVTables.cpp +++ b/lib/CodeGen/CGVTables.cpp @@ -554,7 +554,7 @@ CodeGenVTables::GenerateConstructionVTable(const CXXRecordDecl *RD, if (CGDebugInfo *DI = CGM.getModuleDebugInfo()) DI->completeClassData(Base.getBase()); - OwningPtr VTLayout( + std::unique_ptr VTLayout( getItaniumVTableContext().createConstructionVTableLayout( Base.getBase(), Base.getBaseOffset(), BaseIsVirtual, RD)); diff --git a/lib/CodeGen/CodeGenAction.cpp b/lib/CodeGen/CodeGenAction.cpp index 280d7646be..24961abc72 100644 --- a/lib/CodeGen/CodeGenAction.cpp +++ b/lib/CodeGen/CodeGenAction.cpp @@ -47,9 +47,9 @@ namespace clang { Timer LLVMIRGeneration; - OwningPtr Gen; + std::unique_ptr Gen; - OwningPtr TheModule, LinkModule; + std::unique_ptr TheModule, LinkModule; public: BackendConsumer(BackendAction action, DiagnosticsEngine &_Diags, @@ -465,7 +465,7 @@ static raw_ostream *GetOutputStream(CompilerInstance &CI, ASTConsumer *CodeGenAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { BackendAction BA = static_cast(Act); - OwningPtr OS(GetOutputStream(CI, InFile, BA)); + std::unique_ptr OS(GetOutputStream(CI, InFile, BA)); if (BA != Backend_EmitNothing && !OS) return 0; diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h index 11272fc2ca..4bd8b7a3de 100644 --- a/lib/CodeGen/CodeGenModule.h +++ b/lib/CodeGen/CodeGenModule.h @@ -235,7 +235,7 @@ class CodeGenModule : public CodeGenTypeCache { DiagnosticsEngine &Diags; const llvm::DataLayout &TheDataLayout; const TargetInfo &Target; - llvm::OwningPtr ABI; + std::unique_ptr ABI; llvm::LLVMContext &VMContext; CodeGenTBAA *TBAA; @@ -430,7 +430,7 @@ class CodeGenModule : public CodeGenTypeCache { GlobalDecl initializedGlobalDecl; - llvm::OwningPtr SanitizerBlacklist; + std::unique_ptr SanitizerBlacklist; const SanitizerOptions &SanOpts; diff --git a/lib/CodeGen/CodeGenPGO.h b/lib/CodeGen/CodeGenPGO.h index 0fc570ad9c..f556b13dad 100644 --- a/lib/CodeGen/CodeGenPGO.h +++ b/lib/CodeGen/CodeGenPGO.h @@ -30,7 +30,7 @@ class RegionCounter; class PGOProfileData { private: /// The PGO data - llvm::OwningPtr DataBuffer; + std::unique_ptr DataBuffer; /// Offsets into DataBuffer for each function's counters llvm::StringMap DataOffsets; /// Execution counts for each function. diff --git a/lib/CodeGen/ModuleBuilder.cpp b/lib/CodeGen/ModuleBuilder.cpp index d54a4a8186..22914c3775 100644 --- a/lib/CodeGen/ModuleBuilder.cpp +++ b/lib/CodeGen/ModuleBuilder.cpp @@ -30,12 +30,13 @@ using namespace clang; namespace { class CodeGeneratorImpl : public CodeGenerator { DiagnosticsEngine &Diags; - OwningPtr TD; + std::unique_ptr TD; ASTContext *Ctx; const CodeGenOptions CodeGenOpts; // Intentionally copied in. protected: - OwningPtr M; - OwningPtr Builder; + std::unique_ptr M; + std::unique_ptr Builder; + public: CodeGeneratorImpl(DiagnosticsEngine &diags, const std::string& ModuleName, const CodeGenOptions &CGO, llvm::LLVMContext& C) diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index bfe332b902..4dc25e8972 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -1203,7 +1203,7 @@ void Driver::BuildActions(const ToolChain &TC, DerivedArgList &Args, } // Build the pipeline for this file. - OwningPtr Current(new InputAction(*InputArg, InputType)); + std::unique_ptr Current(new InputAction(*InputArg, InputType)); for (SmallVectorImpl::iterator i = PL.begin(), e = PL.end(); i != e; ++i) { phases::ID Phase = *i; diff --git a/lib/Driver/SanitizerArgs.cpp b/lib/Driver/SanitizerArgs.cpp index f2ac7b163f..53b8e9cb74 100644 --- a/lib/Driver/SanitizerArgs.cpp +++ b/lib/Driver/SanitizerArgs.cpp @@ -143,7 +143,7 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC, if (llvm::sys::fs::exists(BLPath)) { // Validate the blacklist format. std::string BLError; - llvm::OwningPtr SCL( + std::unique_ptr SCL( llvm::SpecialCaseList::create(BLPath, BLError)); if (!SCL.get()) D.Diag(diag::err_drv_malformed_sanitizer_blacklist) << BLError; diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 9232a5d4b0..d597da8ecb 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -2682,7 +2682,7 @@ static bool IsUbuntu(enum Distro Distro) { } static Distro DetectDistro(llvm::Triple::ArchType Arch) { - OwningPtr File; + std::unique_ptr File; if (!llvm::MemoryBuffer::getFile("/etc/lsb-release", File)) { StringRef Data = File.get()->getBuffer(); SmallVector Lines; diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index 86cd136f65..cba764e0bf 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -186,8 +186,8 @@ protected: /// @} private: - mutable OwningPtr Preprocess; - mutable OwningPtr Compile; + mutable std::unique_ptr Preprocess; + mutable std::unique_ptr Compile; }; class LLVM_LIBRARY_VISIBILITY MachO : public ToolChain { @@ -196,9 +196,9 @@ protected: virtual Tool *buildLinker() const; virtual Tool *getTool(Action::ActionClass AC) const; private: - mutable OwningPtr Lipo; - mutable OwningPtr Dsymutil; - mutable OwningPtr VerifyDebug; + mutable std::unique_ptr Lipo; + mutable std::unique_ptr Dsymutil; + mutable std::unique_ptr VerifyDebug; public: MachO(const Driver &D, const llvm::Triple &Triple, diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index b82726a6b8..ed5ce4a21e 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -791,7 +791,7 @@ unsigned ContinuationIndenter::breakProtrudingToken(const FormatToken &Current, if (!Current.isStringLiteral() && !Current.is(tok::comment)) return 0; - llvm::OwningPtr Token; + std::unique_ptr Token; unsigned StartColumn = State.Column - Current.ColumnWidth; unsigned ColumnLimit = getColumnLimit(State); diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 79bf101252..18ee6cb839 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -1790,7 +1790,7 @@ FormatStyle getStyle(StringRef StyleName, StringRef FileName, } if (IsFile) { - OwningPtr Text; + std::unique_ptr Text; if (llvm::error_code ec = llvm::MemoryBuffer::getFile(ConfigFile.c_str(), Text)) { llvm::errs() << ec.message() << "\n"; diff --git a/lib/Format/FormatToken.h b/lib/Format/FormatToken.h index a4947dd805..a6849b7c11 100644 --- a/lib/Format/FormatToken.h +++ b/lib/Format/FormatToken.h @@ -187,7 +187,7 @@ struct FormatToken { /// \brief A token can have a special role that can carry extra information /// about the token's formatting. - llvm::OwningPtr Role; + std::unique_ptr Role; /// \brief If this is an opening parenthesis, how are the parameters packed? ParameterPackingKind PackingKind; diff --git a/lib/Format/UnwrappedLineParser.h b/lib/Format/UnwrappedLineParser.h index ce48de2d4f..62e0b58ea1 100644 --- a/lib/Format/UnwrappedLineParser.h +++ b/lib/Format/UnwrappedLineParser.h @@ -112,7 +112,7 @@ private: // FIXME: We are constantly running into bugs where Line.Level is incorrectly // subtracted from beyond 0. Introduce a method to subtract from Line.Level // and use that everywhere in the Parser. - OwningPtr Line; + std::unique_ptr Line; // Comments are sorted into unwrapped lines by whether they are in the same // line as the previous token, or not. If not, they belong to the next token. diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index a3ebd41a58..570ff9ccfb 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -677,7 +677,7 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename, bool CaptureDiagnostics, bool AllowPCHWithCompilerErrors, bool UserFilesAreVolatile) { - OwningPtr AST(new ASTUnit(true)); + std::unique_ptr AST(new ASTUnit(true)); // Recover resources if we crash before exiting this method. llvm::CrashRecoveryContextCleanupRegistrar @@ -1055,7 +1055,7 @@ bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) { } // Create the compiler instance to use for building the AST. - OwningPtr Clang(new CompilerInstance()); + std::unique_ptr Clang(new CompilerInstance()); // Recover resources if we crash before exiting this method. llvm::CrashRecoveryContextCleanupRegistrar @@ -1141,10 +1141,10 @@ bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) { // Keep track of the override buffer; SavedMainFileBuffer = OverrideMainBuffer; } - - OwningPtr Act( - new TopLevelDeclTrackerAction(*this)); - + + std::unique_ptr Act( + new TopLevelDeclTrackerAction(*this)); + // Recover resources if we crash before exiting this method. llvm::CrashRecoveryContextCleanupRegistrar ActCleanup(Act.get()); @@ -1406,7 +1406,7 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble( = ComputePreamble(*PreambleInvocation, MaxLines, CreatedPreambleBuffer); // If ComputePreamble() Take ownership of the preamble buffer. - OwningPtr OwnedPreambleBuffer; + std::unique_ptr OwnedPreambleBuffer; if (CreatedPreambleBuffer) OwnedPreambleBuffer.reset(NewPreamble.first); @@ -1587,7 +1587,7 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble( PreprocessorOpts.PrecompiledPreambleBytes.second = false; // Create the compiler instance to use for building the precompiled preamble. - OwningPtr Clang(new CompilerInstance()); + std::unique_ptr Clang(new CompilerInstance()); // Recover resources if we crash before exiting this method. llvm::CrashRecoveryContextCleanupRegistrar @@ -1638,8 +1638,8 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble( // Create the source manager. Clang->setSourceManager(new SourceManager(getDiagnostics(), Clang->getFileManager())); - - OwningPtr Act; + + std::unique_ptr Act; Act.reset(new PrecompilePreambleAction(*this)); if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0])) { llvm::sys::fs::remove(FrontendOpts.OutputFile); @@ -1786,7 +1786,7 @@ ASTUnit *ASTUnit::create(CompilerInvocation *CI, IntrusiveRefCntPtr Diags, bool CaptureDiagnostics, bool UserFilesAreVolatile) { - OwningPtr AST; + std::unique_ptr AST; AST.reset(new ASTUnit(false)); ConfigureDiags(Diags, 0, 0, *AST, CaptureDiagnostics); AST->Diagnostics = Diags; @@ -1800,22 +1800,16 @@ ASTUnit *ASTUnit::create(CompilerInvocation *CI, return AST.release(); } -ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(CompilerInvocation *CI, - IntrusiveRefCntPtr Diags, - ASTFrontendAction *Action, - ASTUnit *Unit, - bool Persistent, - StringRef ResourceFilesPath, - bool OnlyLocalDecls, - bool CaptureDiagnostics, - bool PrecompilePreamble, - bool CacheCodeCompletionResults, - bool IncludeBriefCommentsInCodeCompletion, - bool UserFilesAreVolatile, - OwningPtr *ErrAST) { +ASTUnit *ASTUnit::LoadFromCompilerInvocationAction( + CompilerInvocation *CI, IntrusiveRefCntPtr Diags, + ASTFrontendAction *Action, ASTUnit *Unit, bool Persistent, + StringRef ResourceFilesPath, bool OnlyLocalDecls, bool CaptureDiagnostics, + bool PrecompilePreamble, bool CacheCodeCompletionResults, + bool IncludeBriefCommentsInCodeCompletion, bool UserFilesAreVolatile, + std::unique_ptr *ErrAST) { assert(CI && "A CompilerInvocation is required"); - OwningPtr OwnAST; + std::unique_ptr OwnAST; ASTUnit *AST = Unit; if (!AST) { // Create the AST unit. @@ -1849,7 +1843,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(CompilerInvocation *CI, ProcessWarningOptions(AST->getDiagnostics(), CI->getDiagnosticOpts()); // Create the compiler instance to use for building the AST. - OwningPtr Clang(new CompilerInstance()); + std::unique_ptr Clang(new CompilerInstance()); // Recover resources if we crash before exiting this method. llvm::CrashRecoveryContextCleanupRegistrar @@ -1895,7 +1889,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(CompilerInvocation *CI, ASTFrontendAction *Act = Action; - OwningPtr TrackerAct; + std::unique_ptr TrackerAct; if (!Act) { TrackerAct.reset(new TopLevelDeclTrackerAction(*AST)); Act = TrackerAct.get(); @@ -1978,7 +1972,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocation(CompilerInvocation *CI, bool IncludeBriefCommentsInCodeCompletion, bool UserFilesAreVolatile) { // Create the AST unit. - OwningPtr AST; + std::unique_ptr AST; AST.reset(new ASTUnit(false)); ConfigureDiags(Diags, 0, 0, *AST, CaptureDiagnostics); AST->Diagnostics = Diags; @@ -2004,23 +1998,16 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocation(CompilerInvocation *CI, : AST.release(); } -ASTUnit *ASTUnit::LoadFromCommandLine(const char **ArgBegin, - const char **ArgEnd, - IntrusiveRefCntPtr Diags, - StringRef ResourceFilesPath, - bool OnlyLocalDecls, - bool CaptureDiagnostics, - ArrayRef RemappedFiles, - bool RemappedFilesKeepOriginalName, - bool PrecompilePreamble, - TranslationUnitKind TUKind, - bool CacheCodeCompletionResults, - bool IncludeBriefCommentsInCodeCompletion, - bool AllowPCHWithCompilerErrors, - bool SkipFunctionBodies, - bool UserFilesAreVolatile, - bool ForSerialization, - OwningPtr *ErrAST) { +ASTUnit *ASTUnit::LoadFromCommandLine( + const char **ArgBegin, const char **ArgEnd, + IntrusiveRefCntPtr Diags, StringRef ResourceFilesPath, + bool OnlyLocalDecls, bool CaptureDiagnostics, + ArrayRef RemappedFiles, bool RemappedFilesKeepOriginalName, + bool PrecompilePreamble, TranslationUnitKind TUKind, + bool CacheCodeCompletionResults, bool IncludeBriefCommentsInCodeCompletion, + bool AllowPCHWithCompilerErrors, bool SkipFunctionBodies, + bool UserFilesAreVolatile, bool ForSerialization, + std::unique_ptr *ErrAST) { if (!Diags.getPtr()) { // No diagnostics engine was provided, so create our own diagnostics object // with the default options. @@ -2058,7 +2045,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine(const char **ArgBegin, CI->getFrontendOpts().SkipFunctionBodies = SkipFunctionBodies; // Create the AST unit. - OwningPtr AST; + std::unique_ptr AST; AST.reset(new ASTUnit(false)); ConfigureDiags(Diags, ArgBegin, ArgEnd, *AST, CaptureDiagnostics); AST->Diagnostics = Diags; @@ -2427,7 +2414,7 @@ void ASTUnit::CodeComplete(StringRef File, unsigned Line, unsigned Column, // Set the language options appropriately. LangOpts = *CCInvocation->getLangOpts(); - OwningPtr Clang(new CompilerInstance()); + std::unique_ptr Clang(new CompilerInstance()); // Recover resources if we crash before exiting this method. llvm::CrashRecoveryContextCleanupRegistrar @@ -2524,8 +2511,8 @@ void ASTUnit::CodeComplete(StringRef File, unsigned Line, unsigned Column, // Disable the preprocessing record if modules are not enabled. if (!Clang->getLangOpts().Modules) PreprocessorOpts.DetailedRecord = false; - - OwningPtr Act; + + std::unique_ptr Act; Act.reset(new SyntaxOnlyAction); if (Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0])) { Act->Execute(); diff --git a/lib/Frontend/ChainedIncludesSource.cpp b/lib/Frontend/ChainedIncludesSource.cpp index 04753ee0c0..674116034b 100644 --- a/lib/Frontend/ChainedIncludesSource.cpp +++ b/lib/Frontend/ChainedIncludesSource.cpp @@ -31,7 +31,7 @@ static ASTReader *createASTReader(CompilerInstance &CI, SmallVectorImpl &bufNames, ASTDeserializationListener *deserialListener = 0) { Preprocessor &PP = CI.getPreprocessor(); - OwningPtr Reader; + std::unique_ptr Reader; Reader.reset(new ASTReader(PP, CI.getASTContext(), /*isysroot=*/"", /*DisableValidation=*/true)); for (unsigned ti = 0; ti < bufNames.size(); ++ti) { @@ -76,7 +76,7 @@ ChainedIncludesSource::create(CompilerInstance &CI) { for (unsigned i = 0, e = includes.size(); i != e; ++i) { bool firstInclude = (i == 0); - OwningPtr CInvok; + std::unique_ptr CInvok; CInvok.reset(new CompilerInvocation(CI.getInvocation())); CInvok->getPreprocessorOpts().ChainedIncludes.clear(); @@ -97,7 +97,7 @@ ChainedIncludesSource::create(CompilerInstance &CI) { IntrusiveRefCntPtr Diags( new DiagnosticsEngine(DiagID, &CI.getDiagnosticOpts(), DiagClient)); - OwningPtr Clang(new CompilerInstance()); + std::unique_ptr Clang(new CompilerInstance()); Clang->setInvocation(CInvok.release()); Clang->setDiagnostics(Diags.getPtr()); Clang->setTarget(TargetInfo::CreateTargetInfo(Clang->getDiagnostics(), @@ -111,7 +111,7 @@ ChainedIncludesSource::create(CompilerInstance &CI) { SmallVector serialAST; llvm::raw_svector_ostream OS(serialAST); - OwningPtr consumer; + std::unique_ptr consumer; consumer.reset(new PCHGenerator(Clang->getPreprocessor(), "-", 0, /*isysroot=*/"", &OS)); Clang->getASTContext().setASTMutationListener( diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index 086d96fca8..11b5ba9f54 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -147,7 +147,7 @@ static void SetupSerializedDiagnostics(DiagnosticOptions *DiagOpts, DiagnosticsEngine &Diags, StringRef OutputFile) { std::string ErrorInfo; - OwningPtr OS; + std::unique_ptr OS; OS.reset(new llvm::raw_fd_ostream(OutputFile.str().c_str(), ErrorInfo, llvm::sys::fs::F_None)); @@ -334,7 +334,7 @@ CompilerInstance::createPCHExternalASTSource(StringRef Path, void *DeserializationListener, bool Preamble, bool UseGlobalModuleIndex) { - OwningPtr Reader; + std::unique_ptr Reader; Reader.reset(new ASTReader(PP, Context, Sysroot.empty() ? "" : Sysroot.c_str(), DisablePCHValidation, @@ -539,7 +539,7 @@ CompilerInstance::createOutputFile(StringRef OutputPath, OutFile = "-"; } - OwningPtr OS; + std::unique_ptr OS; std::string OSFile; if (UseTemporary) { @@ -662,7 +662,7 @@ bool CompilerInstance::InitializeSourceManager(const FrontendInputFile &Input, SourceMgr.createMainFileID(File, Kind); } else { - OwningPtr SB; + std::unique_ptr SB; if (llvm::error_code ec = llvm::MemoryBuffer::getSTDIN(SB)) { Diags.Report(diag::err_fe_error_reading_stdin) << ec.message(); return false; diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index d28af7c469..44fbf45bd1 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1669,12 +1669,12 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res, bool Success = true; // Parse the arguments. - OwningPtr Opts(createDriverOptTable()); + std::unique_ptr Opts(createDriverOptTable()); const unsigned IncludedFlagsBitmask = options::CC1Option; unsigned MissingArgIndex, MissingArgCount; - OwningPtr Args( - Opts->ParseArgs(ArgBegin, ArgEnd, MissingArgIndex, MissingArgCount, - IncludedFlagsBitmask)); + std::unique_ptr Args( + Opts->ParseArgs(ArgBegin, ArgEnd, MissingArgIndex, MissingArgCount, + IncludedFlagsBitmask)); // Check for missing argument error. if (MissingArgCount) { @@ -1834,7 +1834,7 @@ std::string CompilerInvocation::getModuleHash() const { // $sysroot/System/Library/CoreServices/SystemVersion.plist // as part of the module hash. if (!hsOpts.Sysroot.empty()) { - llvm::OwningPtr buffer; + std::unique_ptr buffer; SmallString<128> systemVersionFile; systemVersionFile += hsOpts.Sysroot; llvm::sys::path::append(systemVersionFile, "System"); diff --git a/lib/Frontend/CreateInvocationFromCommandLine.cpp b/lib/Frontend/CreateInvocationFromCommandLine.cpp index 62a89fa130..ededf9a757 100644 --- a/lib/Frontend/CreateInvocationFromCommandLine.cpp +++ b/lib/Frontend/CreateInvocationFromCommandLine.cpp @@ -52,7 +52,7 @@ clang::createInvocationFromCommandLine(ArrayRef ArgList, // Don't check that inputs exist, they may have been remapped. TheDriver.setCheckInputsExist(false); - OwningPtr C(TheDriver.BuildCompilation(Args)); + std::unique_ptr C(TheDriver.BuildCompilation(Args)); // Just print the cc1 options if -### was present. if (C->getArgs().hasArg(driver::options::OPT__HASH_HASH_HASH)) { @@ -78,7 +78,7 @@ clang::createInvocationFromCommandLine(ArrayRef ArgList, } const ArgStringList &CCArgs = Cmd->getArguments(); - OwningPtr CI(new CompilerInvocation()); + std::unique_ptr CI(new CompilerInvocation()); if (!CompilerInvocation::CreateFromArgs(*CI, const_cast(CCArgs.data()), const_cast(CCArgs.data()) + diff --git a/lib/Frontend/FrontendAction.cpp b/lib/Frontend/FrontendAction.cpp index f61b3bacc4..24f2ec496c 100644 --- a/lib/Frontend/FrontendAction.cpp +++ b/lib/Frontend/FrontendAction.cpp @@ -148,7 +148,7 @@ ASTConsumer* FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI, ie = FrontendPluginRegistry::end(); it != ie; ++it) { if (it->getName() == CI.getFrontendOpts().AddPluginActions[i]) { - OwningPtr P(it->instantiate()); + std::unique_ptr P(it->instantiate()); FrontendAction* c = P.get(); if (P->ParseArgs(CI, CI.getFrontendOpts().AddPluginArgs[i])) Consumers.push_back(c->CreateASTConsumer(CI, InFile)); @@ -220,7 +220,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, for (std::vector::const_iterator I = Files.begin(), E = Files.end(); I != E; ++I) { - OwningPtr Buffer; + std::unique_ptr Buffer; if (llvm::errc::success != llvm::MemoryBuffer::getFile(*I, Buffer)) { CI.getDiagnostics().Report(diag::err_missing_vfs_overlay_file) << *I; goto failure; @@ -307,8 +307,8 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, if (!usesPreprocessorOnly()) { CI.createASTContext(); - OwningPtr Consumer( - CreateWrappedASTConsumer(CI, InputFile)); + std::unique_ptr Consumer( + CreateWrappedASTConsumer(CI, InputFile)); if (!Consumer) goto failure; diff --git a/lib/Frontend/FrontendActions.cpp b/lib/Frontend/FrontendActions.cpp index 4ed2df3a25..70c34b9653 100644 --- a/lib/Frontend/FrontendActions.cpp +++ b/lib/Frontend/FrontendActions.cpp @@ -344,13 +344,13 @@ void VerifyPCHAction::ExecuteAction() { CompilerInstance &CI = getCompilerInstance(); bool Preamble = CI.getPreprocessorOpts().PrecompiledPreambleBytes.first != 0; const std::string &Sysroot = CI.getHeaderSearchOpts().Sysroot; - OwningPtr Reader(new ASTReader( - CI.getPreprocessor(), CI.getASTContext(), - Sysroot.empty() ? "" : Sysroot.c_str(), - /*DisableValidation*/false, - /*AllowPCHWithCompilerErrors*/false, - /*AllowConfigurationMismatch*/true, - /*ValidateSystemInputs*/true)); + std::unique_ptr Reader( + new ASTReader(CI.getPreprocessor(), CI.getASTContext(), + Sysroot.empty() ? "" : Sysroot.c_str(), + /*DisableValidation*/ false, + /*AllowPCHWithCompilerErrors*/ false, + /*AllowConfigurationMismatch*/ true, + /*ValidateSystemInputs*/ true)); Reader->ReadAST(getCurrentFile(), Preamble ? serialization::MK_Preamble @@ -461,7 +461,7 @@ namespace { void DumpModuleInfoAction::ExecuteAction() { // Set up the output file. - llvm::OwningPtr OutFile; + std::unique_ptr OutFile; StringRef OutputFileName = getCompilerInstance().getFrontendOpts().OutputFile; if (!OutputFileName.empty() && OutputFileName != "-") { std::string ErrorInfo; diff --git a/lib/Frontend/MultiplexConsumer.cpp b/lib/Frontend/MultiplexConsumer.cpp index 89aeeb4c0b..ca7e6d35b1 100644 --- a/lib/Frontend/MultiplexConsumer.cpp +++ b/lib/Frontend/MultiplexConsumer.cpp @@ -184,10 +184,9 @@ void MultiplexASTMutationListener::DeclarationMarkedUsed(const Decl *D) { } // end namespace clang - -MultiplexConsumer::MultiplexConsumer(ArrayRef C) - : Consumers(C.begin(), C.end()), - MutationListener(0), DeserializationListener(0) { +MultiplexConsumer::MultiplexConsumer(ArrayRef C) + : Consumers(C.begin(), C.end()), MutationListener(), + DeserializationListener() { // Collect the mutation listeners and deserialization listeners of all // children, and create a multiplex listener each if so. std::vector mutationListeners; diff --git a/lib/Frontend/SerializedDiagnosticPrinter.cpp b/lib/Frontend/SerializedDiagnosticPrinter.cpp index bed52b5361..7678435768 100644 --- a/lib/Frontend/SerializedDiagnosticPrinter.cpp +++ b/lib/Frontend/SerializedDiagnosticPrinter.cpp @@ -200,7 +200,7 @@ private: llvm::BitstreamWriter Stream; /// \brief The name of the diagnostics file. - OwningPtr OS; + std::unique_ptr OS; /// \brief The set of constructed record abbreviations. AbbreviationMap Abbrevs; diff --git a/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/lib/FrontendTool/ExecuteCompilerInvocation.cpp index 540e8b6951..0edd5770f1 100644 --- a/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -72,7 +72,7 @@ static FrontendAction *CreateFrontendBaseAction(CompilerInstance &CI) { FrontendPluginRegistry::begin(), ie = FrontendPluginRegistry::end(); it != ie; ++it) { if (it->getName() == CI.getFrontendOpts().ActionName) { - OwningPtr P(it->instantiate()); + std::unique_ptr P(it->instantiate()); if (!P->ParseArgs(CI, CI.getFrontendOpts().PluginArgs)) return 0; return P.release(); @@ -181,7 +181,7 @@ static FrontendAction *CreateFrontendAction(CompilerInstance &CI) { bool clang::ExecuteCompilerInvocation(CompilerInstance *Clang) { // Honor -help. if (Clang->getFrontendOpts().ShowHelp) { - OwningPtr Opts(driver::createDriverOptTable()); + std::unique_ptr Opts(driver::createDriverOptTable()); Opts->PrintHelp(llvm::outs(), "clang -cc1", "LLVM 'Clang' Compiler: http://clang.llvm.org", /*Include=*/ driver::options::CC1Option, /*Exclude=*/ 0); @@ -233,7 +233,7 @@ bool clang::ExecuteCompilerInvocation(CompilerInstance *Clang) { if (Clang->getDiagnostics().hasErrorOccurred()) return false; // Create and execute the frontend action. - OwningPtr Act(CreateFrontendAction(*Clang)); + std::unique_ptr Act(CreateFrontendAction(*Clang)); if (!Act) return false; bool Success = Clang->ExecuteAction(*Act); diff --git a/lib/Lex/HeaderMap.cpp b/lib/Lex/HeaderMap.cpp index 56fd6946b0..d71e4bc278 100644 --- a/lib/Lex/HeaderMap.cpp +++ b/lib/Lex/HeaderMap.cpp @@ -81,7 +81,7 @@ const HeaderMap *HeaderMap::Create(const FileEntry *FE, FileManager &FM) { unsigned FileSize = FE->getSize(); if (FileSize <= sizeof(HMapHeader)) return 0; - OwningPtr FileBuffer(FM.getBufferForFile(FE)); + std::unique_ptr FileBuffer(FM.getBufferForFile(FE)); if (!FileBuffer) return 0; // Unreadable file? const char *FileStart = FileBuffer->getBufferStart(); diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp index c962409dbd..c79aa185d8 100644 --- a/lib/Lex/PTHLexer.cpp +++ b/lib/Lex/PTHLexer.cpp @@ -425,7 +425,7 @@ static void InvalidPTH(DiagnosticsEngine &Diags, const char *Msg) { PTHManager *PTHManager::Create(const std::string &file, DiagnosticsEngine &Diags) { // Memory map the PTH file. - OwningPtr File; + std::unique_ptr File; if (llvm::MemoryBuffer::getFile(file, File)) { // FIXME: Add ec.message() to this diag. @@ -475,7 +475,7 @@ PTHManager *PTHManager::Create(const std::string &file, return 0; // FIXME: Proper error diagnostic? } - OwningPtr FL(PTHFileLookup::Create(FileTable, BufBeg)); + std::unique_ptr FL(PTHFileLookup::Create(FileTable, BufBeg)); // Warn if the PTH file is empty. We still want to create a PTHManager // as the PTH could be used with -include-pth. @@ -501,8 +501,8 @@ PTHManager *PTHManager::Create(const std::string &file, return 0; } - OwningPtr SL(PTHStringIdLookup::Create(StringIdTable, - BufBeg)); + std::unique_ptr SL( + PTHStringIdLookup::Create(StringIdTable, BufBeg)); // Get the location of the spelling cache. const unsigned char* spellingBaseOffset = PrologueOffset + sizeof(uint32_t)*3; diff --git a/lib/Parse/ParseAST.cpp b/lib/Parse/ParseAST.cpp index 5678ece0c8..604d672879 100644 --- a/lib/Parse/ParseAST.cpp +++ b/lib/Parse/ParseAST.cpp @@ -88,7 +88,8 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, CodeCompleteConsumer *CompletionConsumer, bool SkipFunctionBodies) { - OwningPtr S(new Sema(PP, Ctx, *Consumer, TUKind, CompletionConsumer)); + std::unique_ptr S( + new Sema(PP, Ctx, *Consumer, TUKind, CompletionConsumer)); // Recover resources if we crash before exiting this method. llvm::CrashRecoveryContextCleanupRegistrar CleanupSema(S.get()); @@ -109,8 +110,8 @@ void clang::ParseAST(Sema &S, bool PrintStats, bool SkipFunctionBodies) { ASTConsumer *Consumer = &S.getASTConsumer(); - OwningPtr ParseOP(new Parser(S.getPreprocessor(), S, - SkipFunctionBodies)); + std::unique_ptr ParseOP( + new Parser(S.getPreprocessor(), S, SkipFunctionBodies)); Parser &P = *ParseOP.get(); PrettyStackTraceParserEntry CrashInfo(P); diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index e007998be3..b7d9abfc3a 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -302,7 +302,7 @@ void Parser::ParseGNUAttributeArgs(IdentifierInfo *AttrName, // These may refer to the function arguments, but need to be parsed early to // participate in determining whether it's a redeclaration. - llvm::OwningPtr PrototypeScope; + std::unique_ptr PrototypeScope; if (AttrName->isStr("enable_if") && D && D->isFunctionDeclarator()) { DeclaratorChunk::FunctionTypeInfo FTI = D->getFunctionTypeInfo(); PrototypeScope.reset(new ParseScope(this, Scope::FunctionPrototypeScope | @@ -342,7 +342,7 @@ void Parser::ParseGNUAttributeArgs(IdentifierInfo *AttrName, // Parse the non-empty comma-separated list of expressions. do { - OwningPtr Unevaluated; + std::unique_ptr Unevaluated; if (attributeParsedArgsUnevaluated(*AttrName)) Unevaluated.reset(new EnterExpressionEvaluationContext(Actions, Sema::Unevaluated)); diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index 4cd27fe88f..ae30ce715a 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -2163,13 +2163,13 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) { if (buildMSAsmString(PP, AsmLoc, AsmToks, TokOffsets, AsmString)) return StmtError(); - OwningPtr MRI(TheTarget->createMCRegInfo(TT)); - OwningPtr MAI(TheTarget->createMCAsmInfo(*MRI, TT)); + std::unique_ptr MRI(TheTarget->createMCRegInfo(TT)); + std::unique_ptr MAI(TheTarget->createMCAsmInfo(*MRI, TT)); // Get the instruction descriptor. - const llvm::MCInstrInfo *MII = TheTarget->createMCInstrInfo(); - OwningPtr MOFI(new llvm::MCObjectFileInfo()); - OwningPtr - STI(TheTarget->createMCSubtargetInfo(TT, "", "")); + const llvm::MCInstrInfo *MII = TheTarget->createMCInstrInfo(); + std::unique_ptr MOFI(new llvm::MCObjectFileInfo()); + std::unique_ptr STI( + TheTarget->createMCSubtargetInfo(TT, "", "")); llvm::SourceMgr TempSrcMgr; llvm::MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), &TempSrcMgr); @@ -2179,11 +2179,11 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) { // Tell SrcMgr about this buffer, which is what the parser will pick up. TempSrcMgr.AddNewSourceBuffer(Buffer, llvm::SMLoc()); - OwningPtr Str(createNullStreamer(Ctx)); - OwningPtr - Parser(createMCAsmParser(TempSrcMgr, Ctx, *Str.get(), *MAI)); - OwningPtr - TargetParser(TheTarget->createMCAsmParser(*STI, *Parser, *MII)); + std::unique_ptr Str(createNullStreamer(Ctx)); + std::unique_ptr Parser( + createMCAsmParser(TempSrcMgr, Ctx, *Str.get(), *MAI)); + std::unique_ptr TargetParser( + TheTarget->createMCAsmParser(*STI, *Parser, *MII)); llvm::MCInstPrinter *IP = TheTarget->createMCInstPrinter(1, *MAI, *MII, *MRI, *STI); diff --git a/lib/Rewrite/Core/Rewriter.cpp b/lib/Rewrite/Core/Rewriter.cpp index e5f65c28cf..69f039baf5 100644 --- a/lib/Rewrite/Core/Rewriter.cpp +++ b/lib/Rewrite/Core/Rewriter.cpp @@ -471,7 +471,7 @@ private: DiagnosticsEngine &Diagnostics; StringRef Filename; SmallString<128> TempFilename; - OwningPtr FileStream; + std::unique_ptr FileStream; bool &AllWritten; }; } // end anonymous namespace diff --git a/lib/Rewrite/Frontend/FixItRewriter.cpp b/lib/Rewrite/Frontend/FixItRewriter.cpp index 906bc84169..bdff71dcd2 100644 --- a/lib/Rewrite/Frontend/FixItRewriter.cpp +++ b/lib/Rewrite/Frontend/FixItRewriter.cpp @@ -87,7 +87,7 @@ bool FixItRewriter::WriteFixedFiles( int fd; std::string Filename = FixItOpts->RewriteFilename(Entry->getName(), fd); std::string Err; - OwningPtr OS; + std::unique_ptr OS; if (fd != -1) { OS.reset(new llvm::raw_fd_ostream(fd, /*shouldClose=*/true)); } else { diff --git a/lib/Rewrite/Frontend/FrontendActions.cpp b/lib/Rewrite/Frontend/FrontendActions.cpp index e9ec388182..9a5e953fa0 100644 --- a/lib/Rewrite/Frontend/FrontendActions.cpp +++ b/lib/Rewrite/Frontend/FrontendActions.cpp @@ -110,9 +110,9 @@ bool FixItRecompile::BeginInvocation(CompilerInstance &CI) { bool err = false; { const FrontendOptions &FEOpts = CI.getFrontendOpts(); - OwningPtr FixAction(new SyntaxOnlyAction()); + std::unique_ptr FixAction(new SyntaxOnlyAction()); if (FixAction->BeginSourceFile(CI, FEOpts.Inputs[0])) { - OwningPtr FixItOpts; + std::unique_ptr FixItOpts; if (FEOpts.FixToTemporaries) FixItOpts.reset(new FixItRewriteToTemp()); else diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 5c66f077c8..b738d7fdda 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -4163,7 +4163,7 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName, // FIXME: Re-add the ability to skip very unlikely potential corrections. if (IdentifierInfoLookup *External = Context.Idents.getExternalIdentifierLookup()) { - OwningPtr Iter(External->getIdentifiers()); + std::unique_ptr Iter(External->getIdentifiers()); do { StringRef Name = Iter->Next(); if (Name.empty()) diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index c96fcbed53..78db05302e 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -1709,7 +1709,7 @@ void Sema::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl, // require an explicit implementation, via attribute // 'objc_protocol_requires_explicit_implementation'. if (IDecl) { - OwningPtr LazyMap; + std::unique_ptr LazyMap; for (ObjCInterfaceDecl::all_protocol_iterator PI = IDecl->all_referenced_protocol_begin(), diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 99ef8f0c9b..7e31723b16 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -3709,7 +3709,7 @@ std::string ASTReader::getOriginalSourceFile(const std::string &ASTFileName, DiagnosticsEngine &Diags) { // Open the AST file. std::string ErrStr; - OwningPtr Buffer; + std::unique_ptr Buffer; Buffer.reset(FileMgr.getBufferForFile(ASTFileName, &ErrStr)); if (!Buffer) { Diags.Report(diag::err_fe_unable_to_read_pch_file) << ASTFileName << ErrStr; @@ -3798,7 +3798,7 @@ bool ASTReader::readASTFileControlBlock(StringRef Filename, ASTReaderListener &Listener) { // Open the AST file. std::string ErrStr; - OwningPtr Buffer; + std::unique_ptr Buffer; Buffer.reset(FileMgr.getBufferForFile(Filename, &ErrStr)); if (!Buffer) { return true; diff --git a/lib/Serialization/GlobalModuleIndex.cpp b/lib/Serialization/GlobalModuleIndex.cpp index e46cb97b9f..5cd3ad5575 100644 --- a/lib/Serialization/GlobalModuleIndex.cpp +++ b/lib/Serialization/GlobalModuleIndex.cpp @@ -228,7 +228,7 @@ GlobalModuleIndex::readIndex(StringRef Path) { IndexPath += Path; llvm::sys::path::append(IndexPath, IndexFileName); - llvm::OwningPtr Buffer; + std::unique_ptr Buffer; if (llvm::MemoryBuffer::getFile(IndexPath.c_str(), Buffer) != llvm::errc::success) return std::make_pair((GlobalModuleIndex *)0, EC_NotFound); @@ -469,7 +469,7 @@ namespace { bool GlobalModuleIndexBuilder::loadModuleFile(const FileEntry *File) { // Open the module file. - OwningPtr Buffer; + std::unique_ptr Buffer; std::string ErrorStr; Buffer.reset(FileMgr.getBufferForFile(File, &ErrorStr, /*isVolatile=*/true)); if (!Buffer) { @@ -593,10 +593,10 @@ bool GlobalModuleIndexBuilder::loadModuleFile(const FileEntry *File) { if (State == ASTBlock && Code == IDENTIFIER_TABLE && Record[0] > 0) { typedef OnDiskChainedHashTable InterestingIdentifierTable; - llvm::OwningPtr - Table(InterestingIdentifierTable::Create( - (const unsigned char *)Blob.data() + Record[0], - (const unsigned char *)Blob.data())); + std::unique_ptr Table( + InterestingIdentifierTable::Create( + (const unsigned char *)Blob.data() + Record[0], + (const unsigned char *)Blob.data())); for (InterestingIdentifierTable::data_iterator D = Table->data_begin(), DEnd = Table->data_end(); D != DEnd; ++D) { diff --git a/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp b/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp index f76de9bfe6..cb5b01009f 100644 --- a/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp @@ -25,7 +25,8 @@ using namespace ento; namespace { class ArrayBoundChecker : public Checker { - mutable OwningPtr BT; + mutable std::unique_ptr BT; + public: void checkLocation(SVal l, bool isLoad, const Stmt* S, CheckerContext &C) const; diff --git a/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp b/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp index 936d8db466..a8d7b3ab61 100644 --- a/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp +++ b/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp @@ -28,8 +28,8 @@ using namespace ento; namespace { class ArrayBoundCheckerV2 : public Checker { - mutable OwningPtr BT; - + mutable std::unique_ptr BT; + enum OOB_Kind { OOB_Precedes, OOB_Excedes, OOB_Tainted }; void reportOOB(CheckerContext &C, ProgramStateRef errorState, diff --git a/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp b/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp index 53e12cd393..4b2ccd43aa 100644 --- a/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp +++ b/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp @@ -95,7 +95,7 @@ namespace { class NilArgChecker : public Checker, check::PostStmt > { - mutable OwningPtr BT; + mutable std::unique_ptr BT; void warnIfNilExpr(const Expr *E, const char *Msg, @@ -313,7 +313,7 @@ void NilArgChecker::checkPostStmt(const ObjCDictionaryLiteral *DL, namespace { class CFNumberCreateChecker : public Checker< check::PreStmt > { - mutable OwningPtr BT; + mutable std::unique_ptr BT; mutable IdentifierInfo* II; public: CFNumberCreateChecker() : II(0) {} @@ -498,7 +498,7 @@ void CFNumberCreateChecker::checkPreStmt(const CallExpr *CE, namespace { class CFRetainReleaseChecker : public Checker< check::PreStmt > { - mutable OwningPtr BT; + mutable std::unique_ptr BT; mutable IdentifierInfo *Retain, *Release, *MakeCollectable; public: CFRetainReleaseChecker(): Retain(0), Release(0), MakeCollectable(0) {} @@ -590,7 +590,7 @@ class ClassReleaseChecker : public Checker { mutable Selector retainS; mutable Selector autoreleaseS; mutable Selector drainS; - mutable OwningPtr BT; + mutable std::unique_ptr BT; public: void checkPreObjCMessage(const ObjCMethodCall &msg, CheckerContext &C) const; @@ -649,7 +649,7 @@ class VariadicMethodTypeChecker : public Checker { mutable Selector orderedSetWithObjectsS; mutable Selector initWithObjectsS; mutable Selector initWithObjectsAndKeysS; - mutable OwningPtr BT; + mutable std::unique_ptr BT; bool isVariadicMessage(const ObjCMethodCall &msg) const; diff --git a/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp b/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp index 7227dcf82c..83a37c978c 100644 --- a/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp @@ -23,7 +23,7 @@ using namespace ento; namespace { class BoolAssignmentChecker : public Checker< check::Bind > { - mutable OwningPtr BT; + mutable std::unique_ptr BT; void emitReport(ProgramStateRef state, CheckerContext &C) const; public: void checkBind(SVal loc, SVal val, const Stmt *S, CheckerContext &C) const; diff --git a/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/lib/StaticAnalyzer/Checkers/CStringChecker.cpp index 3c5cf615c8..01361c65df 100644 --- a/lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -35,11 +35,8 @@ class CStringChecker : public Checker< eval::Call, check::DeadSymbols, check::RegionChanges > { - mutable OwningPtr BT_Null, - BT_Bounds, - BT_Overlap, - BT_NotCString, - BT_AdditionOverflow; + mutable std::unique_ptr BT_Null, BT_Bounds, BT_Overlap, + BT_NotCString, BT_AdditionOverflow; mutable const char *CurrentFunctionDescription; diff --git a/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp b/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp index c0467b1e7e..1a9e892218 100644 --- a/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp @@ -32,18 +32,19 @@ class CallAndMessageChecker check::PreStmt, check::PreObjCMessage, check::PreCall > { - mutable OwningPtr BT_call_null; - mutable OwningPtr BT_call_undef; - mutable OwningPtr BT_cxx_call_null; - mutable OwningPtr BT_cxx_call_undef; - mutable OwningPtr BT_call_arg; - mutable OwningPtr BT_cxx_delete_undef; - mutable OwningPtr BT_msg_undef; - mutable OwningPtr BT_objc_prop_undef; - mutable OwningPtr BT_objc_subscript_undef; - mutable OwningPtr BT_msg_arg; - mutable OwningPtr BT_msg_ret; - mutable OwningPtr BT_call_few_args; + mutable std::unique_ptr BT_call_null; + mutable std::unique_ptr BT_call_undef; + mutable std::unique_ptr BT_cxx_call_null; + mutable std::unique_ptr BT_cxx_call_undef; + mutable std::unique_ptr BT_call_arg; + mutable std::unique_ptr BT_cxx_delete_undef; + mutable std::unique_ptr BT_msg_undef; + mutable std::unique_ptr BT_objc_prop_undef; + mutable std::unique_ptr BT_objc_subscript_undef; + mutable std::unique_ptr BT_msg_arg; + mutable std::unique_ptr BT_msg_ret; + mutable std::unique_ptr BT_call_few_args; + public: void checkPreStmt(const CallExpr *CE, CheckerContext &C) const; @@ -55,7 +56,7 @@ private: bool PreVisitProcessArg(CheckerContext &C, SVal V, SourceRange argRange, const Expr *argEx, bool IsFirstArgument, bool checkUninitFields, const CallEvent &Call, - OwningPtr &BT) const; + std::unique_ptr &BT) const; static void emitBadCall(BugType *BT, CheckerContext &C, const Expr *BadE); void emitNilReceiverBug(CheckerContext &C, const ObjCMethodCall &msg, @@ -65,7 +66,7 @@ private: ProgramStateRef state, const ObjCMethodCall &msg) const; - void LazyInit_BT(const char *desc, OwningPtr &BT) const { + void LazyInit_BT(const char *desc, std::unique_ptr &BT) const { if (!BT) BT.reset(new BuiltinBug(this, desc)); } @@ -113,13 +114,10 @@ static StringRef describeUninitializedArgumentInCall(const CallEvent &Call, } } -bool CallAndMessageChecker::PreVisitProcessArg(CheckerContext &C, - SVal V, SourceRange argRange, - const Expr *argEx, - bool IsFirstArgument, - bool checkUninitFields, - const CallEvent &Call, - OwningPtr &BT) const { +bool CallAndMessageChecker::PreVisitProcessArg( + CheckerContext &C, SVal V, SourceRange argRange, const Expr *argEx, + bool IsFirstArgument, bool checkUninitFields, const CallEvent &Call, + std::unique_ptr &BT) const { if (V.isUndef()) { if (ExplodedNode *N = C.generateSink()) { LazyInit_BT("Uninitialized argument value", BT); @@ -340,7 +338,7 @@ void CallAndMessageChecker::checkPreCall(const CallEvent &Call, const bool checkUninitFields = !(C.getAnalysisManager().shouldInlineCall() && (D && D->getBody())); - OwningPtr *BT; + std::unique_ptr *BT; if (isa(Call)) BT = &BT_msg_arg; else diff --git a/lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp b/lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp index 79fc1ce849..e9adf305a4 100644 --- a/lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp @@ -23,7 +23,8 @@ using namespace ento; namespace { class CastSizeChecker : public Checker< check::PreStmt > { - mutable OwningPtr BT; + mutable std::unique_ptr BT; + public: void checkPreStmt(const CastExpr *CE, CheckerContext &C) const; }; diff --git a/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp b/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp index e9c7599e15..d765315bb5 100644 --- a/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp @@ -24,7 +24,7 @@ using namespace ento; namespace { class CastToStructChecker : public Checker< check::PreStmt > { - mutable OwningPtr BT; + mutable std::unique_ptr BT; public: void checkPreStmt(const CastExpr *CE, CheckerContext &C) const; diff --git a/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp b/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp index 9cfc0f3116..628cf2c811 100644 --- a/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp @@ -41,7 +41,7 @@ bool isRootChanged(intptr_t k) { return k == ROOT_CHANGED; } class ChrootChecker : public Checker > { mutable IdentifierInfo *II_chroot, *II_chdir; // This bug refers to possibly break out of a chroot() jail. - mutable OwningPtr BT_BreakJail; + mutable std::unique_ptr BT_BreakJail; public: ChrootChecker() : II_chroot(0), II_chdir(0) {} diff --git a/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp b/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp index ee12a4d75f..87f1a3d19a 100644 --- a/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp @@ -128,9 +128,9 @@ class DeadStoreObs : public LiveVariables::Observer { AnalysisDeclContext* AC; ParentMap& Parents; llvm::SmallPtrSet Escaped; - OwningPtr reachableCode; + std::unique_ptr reachableCode; const CFGBlock *currentBlock; - OwningPtr > InEH; + std::unique_ptr> InEH; enum DeadStoreKind { Standard, Enclosing, DeadIncrement, DeadInit }; diff --git a/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp b/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp index bc9a77098d..efdc213ac8 100644 --- a/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp @@ -29,8 +29,8 @@ class DereferenceChecker : public Checker< check::Location, check::Bind, EventDispatcher > { - mutable OwningPtr BT_null; - mutable OwningPtr BT_undef; + mutable std::unique_ptr BT_null; + mutable std::unique_ptr BT_undef; void reportBug(ProgramStateRef State, const Stmt *S, CheckerContext &C, bool IsBind = false) const; diff --git a/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp b/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp index ae76b563b0..e060c36184 100644 --- a/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp @@ -23,7 +23,7 @@ using namespace ento; namespace { class DivZeroChecker : public Checker< check::PreStmt > { - mutable OwningPtr BT; + mutable std::unique_ptr BT; void reportBug(const char *Msg, ProgramStateRef StateZero, CheckerContext &C) const ; diff --git a/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp b/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp index ff36762503..9a0fa09733 100644 --- a/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp @@ -18,7 +18,7 @@ using namespace ento; namespace { class ExprInspectionChecker : public Checker< eval::Call > { - mutable OwningPtr BT; + mutable std::unique_ptr BT; void analyzerEval(const CallExpr *CE, CheckerContext &C) const; void analyzerCheckInlined(const CallExpr *CE, CheckerContext &C) const; diff --git a/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp b/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp index c73b068300..60bb03654f 100644 --- a/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp @@ -25,7 +25,7 @@ using namespace ento; namespace { class FixedAddressChecker : public Checker< check::PreStmt > { - mutable OwningPtr BT; + mutable std::unique_ptr BT; public: void checkPreStmt(const BinaryOperator *B, CheckerContext &C) const; diff --git a/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp b/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp index c65dd8ca87..a55f8112d0 100644 --- a/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp @@ -43,7 +43,7 @@ private: /// Denotes the return vale. static const unsigned ReturnValueIndex = UINT_MAX - 1; - mutable OwningPtr BT; + mutable std::unique_ptr BT; inline void initBugType() const { if (!BT) BT.reset(new BugType(this, "Use of Untrusted Data", "Untrusted Data")); diff --git a/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp b/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp index 57cead1fd7..0c0da8bc7d 100644 --- a/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp @@ -29,7 +29,7 @@ namespace { class MacOSKeychainAPIChecker : public Checker, check::PostStmt, check::DeadSymbols> { - mutable OwningPtr BT; + mutable std::unique_ptr BT; public: /// AllocationState is a part of the checker specific state together with the diff --git a/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp b/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp index 2fbfbafbe2..d9e46990c8 100644 --- a/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp @@ -31,7 +31,7 @@ using namespace ento; namespace { class MacOSXAPIChecker : public Checker< check::PreStmt > { - mutable OwningPtr BT_dispatchOnce; + mutable std::unique_ptr BT_dispatchOnce; public: void checkPreStmt(const CallExpr *CE, CheckerContext &C) const; diff --git a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index de615a88b3..51d26d8a64 100644 --- a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -199,13 +199,13 @@ public: const char *NL, const char *Sep) const; private: - mutable OwningPtr BT_DoubleFree[CK_NumCheckKinds]; - mutable OwningPtr BT_DoubleDelete; - mutable OwningPtr BT_Leak[CK_NumCheckKinds]; - mutable OwningPtr BT_UseFree[CK_NumCheckKinds]; - mutable OwningPtr BT_BadFree[CK_NumCheckKinds]; - mutable OwningPtr BT_MismatchedDealloc; - mutable OwningPtr BT_OffsetFree[CK_NumCheckKinds]; + mutable std::unique_ptr BT_DoubleFree[CK_NumCheckKinds]; + mutable std::unique_ptr BT_DoubleDelete; + mutable std::unique_ptr BT_Leak[CK_NumCheckKinds]; + mutable std::unique_ptr BT_UseFree[CK_NumCheckKinds]; + mutable std::unique_ptr BT_BadFree[CK_NumCheckKinds]; + mutable std::unique_ptr BT_MismatchedDealloc; + mutable std::unique_ptr BT_OffsetFree[CK_NumCheckKinds]; mutable IdentifierInfo *II_malloc, *II_free, *II_realloc, *II_calloc, *II_valloc, *II_reallocf, *II_strndup, *II_strdup; diff --git a/lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp b/lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp index f8570071d1..b180c03f08 100644 --- a/lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp @@ -32,7 +32,7 @@ using namespace ento; namespace { class NSAutoreleasePoolChecker : public Checker { - mutable OwningPtr BT; + mutable std::unique_ptr BT; mutable Selector releaseS; public: diff --git a/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp b/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp index bad2789983..293114ff2f 100644 --- a/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp @@ -29,8 +29,9 @@ using namespace ento; namespace { class NonNullParamChecker : public Checker< check::PreCall > { - mutable OwningPtr BTAttrNonNull; - mutable OwningPtr BTNullRefArg; + mutable std::unique_ptr BTAttrNonNull; + mutable std::unique_ptr BTNullRefArg; + public: void checkPreCall(const CallEvent &Call, CheckerContext &C) const; diff --git a/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp b/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp index 1fce2bbbea..fbf2d73dd8 100644 --- a/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp @@ -26,8 +26,8 @@ using namespace ento; namespace { class ObjCAtSyncChecker : public Checker< check::PreStmt > { - mutable OwningPtr BT_null; - mutable OwningPtr BT_undef; + mutable std::unique_ptr BT_null; + mutable std::unique_ptr BT_undef; public: void checkPreStmt(const ObjCAtSynchronizedStmt *S, CheckerContext &C) const; diff --git a/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp b/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp index 165bdafccb..8e51154fc3 100644 --- a/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp @@ -30,7 +30,7 @@ using namespace ento; namespace { class ObjCContainersChecker : public Checker< check::PreStmt, check::PostStmt > { - mutable OwningPtr BT; + mutable std::unique_ptr BT; inline void initBugType() const { if (!BT) BT.reset(new BugType(this, "CFArray API", diff --git a/lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp b/lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp index 3e86c7618f..00480e4abf 100644 --- a/lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp @@ -24,7 +24,7 @@ using namespace ento; namespace { class PointerArithChecker : public Checker< check::PreStmt > { - mutable OwningPtr BT; + mutable std::unique_ptr BT; public: void checkPreStmt(const BinaryOperator *B, CheckerContext &C) const; diff --git a/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp b/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp index 8f63cecfd3..fbb2628a9c 100644 --- a/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp @@ -25,7 +25,7 @@ using namespace ento; namespace { class PointerSubChecker : public Checker< check::PreStmt > { - mutable OwningPtr BT; + mutable std::unique_ptr BT; public: void checkPreStmt(const BinaryOperator *B, CheckerContext &C) const; diff --git a/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp b/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp index 5686562698..5afa2d1687 100644 --- a/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp @@ -25,8 +25,8 @@ using namespace ento; namespace { class PthreadLockChecker : public Checker< check::PostStmt > { - mutable OwningPtr BT_doublelock; - mutable OwningPtr BT_lor; + mutable std::unique_ptr BT_doublelock; + mutable std::unique_ptr BT_lor; enum LockingSemantics { NotApplicable = 0, PthreadSemantics, diff --git a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp index 1cb92b861d..bd1d417353 100644 --- a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -2338,19 +2338,19 @@ class RetainCountChecker check::RegionChanges, eval::Assume, eval::Call > { - mutable OwningPtr useAfterRelease, releaseNotOwned; - mutable OwningPtr deallocGC, deallocNotOwned; - mutable OwningPtr overAutorelease, returnNotOwnedForOwned; - mutable OwningPtr leakWithinFunction, leakAtReturn; - mutable OwningPtr leakWithinFunctionGC, leakAtReturnGC; + mutable std::unique_ptr useAfterRelease, releaseNotOwned; + mutable std::unique_ptr deallocGC, deallocNotOwned; + mutable std::unique_ptr overAutorelease, returnNotOwnedForOwned; + mutable std::unique_ptr leakWithinFunction, leakAtReturn; + mutable std::unique_ptr leakWithinFunctionGC, leakAtReturnGC; typedef llvm::DenseMap SymbolTagMap; // This map is only used to ensure proper deletion of any allocated tags. mutable SymbolTagMap DeadSymbolTags; - mutable OwningPtr Summaries; - mutable OwningPtr SummariesGC; + mutable std::unique_ptr Summaries; + mutable std::unique_ptr SummariesGC; mutable SummaryLogTy SummaryLog; mutable bool ShouldResetSummaryLog; diff --git a/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp b/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp index 6a43bf8aa2..b1cde6b897 100644 --- a/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp @@ -25,7 +25,8 @@ using namespace ento; namespace { class ReturnPointerRangeChecker : public Checker< check::PreStmt > { - mutable OwningPtr BT; + mutable std::unique_ptr BT; + public: void checkPreStmt(const ReturnStmt *RS, CheckerContext &C) const; }; diff --git a/lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp b/lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp index 0eab41f257..b4d92d69cf 100644 --- a/lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp @@ -25,8 +25,8 @@ using namespace ento; namespace { class ReturnUndefChecker : public Checker< check::PreStmt > { - mutable OwningPtr BT_Undef; - mutable OwningPtr BT_NullReference; + mutable std::unique_ptr BT_Undef; + mutable std::unique_ptr BT_NullReference; void emitUndef(CheckerContext &C, const Expr *RetE) const; void checkReference(CheckerContext &C, const Expr *RetE, diff --git a/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp b/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp index ac250cac1e..483063b52f 100644 --- a/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp @@ -54,8 +54,8 @@ class SimpleStreamChecker : public Checker DoubleCloseBugType; - OwningPtr LeakBugType; + std::unique_ptr DoubleCloseBugType; + std::unique_ptr LeakBugType; void initIdentifierInfo(ASTContext &Ctx) const; diff --git a/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp b/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp index 96384904f6..44c873262d 100644 --- a/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp @@ -28,8 +28,8 @@ using namespace ento; namespace { class StackAddrEscapeChecker : public Checker< check::PreStmt, check::EndFunction > { - mutable OwningPtr BT_stackleak; - mutable OwningPtr BT_returnstack; + mutable std::unique_ptr BT_stackleak; + mutable std::unique_ptr BT_returnstack; public: void checkPreStmt(const ReturnStmt *RS, CheckerContext &C) const; diff --git a/lib/StaticAnalyzer/Checkers/StreamChecker.cpp b/lib/StaticAnalyzer/Checkers/StreamChecker.cpp index 17d6d8e1d5..6000942004 100644 --- a/lib/StaticAnalyzer/Checkers/StreamChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/StreamChecker.cpp @@ -62,8 +62,8 @@ class StreamChecker : public Checker BT_nullfp, BT_illegalwhence, - BT_doubleclose, BT_ResourceLeak; + mutable std::unique_ptr BT_nullfp, BT_illegalwhence, + BT_doubleclose, BT_ResourceLeak; public: StreamChecker() diff --git a/lib/StaticAnalyzer/Checkers/TaintTesterChecker.cpp b/lib/StaticAnalyzer/Checkers/TaintTesterChecker.cpp index 2d261ca62c..d33c977826 100644 --- a/lib/StaticAnalyzer/Checkers/TaintTesterChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/TaintTesterChecker.cpp @@ -22,7 +22,7 @@ using namespace ento; namespace { class TaintTesterChecker : public Checker< check::PostStmt > { - mutable OwningPtr BT; + mutable std::unique_ptr BT; void initBugType() const; /// Given a pointer argument, get the symbol of the value it contains diff --git a/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp b/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp index 410390d0fc..22e215590c 100644 --- a/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp @@ -24,7 +24,7 @@ using namespace ento; namespace { class UndefBranchChecker : public Checker { - mutable OwningPtr BT; + mutable std::unique_ptr BT; struct FindUndefExpr { ProgramStateRef St; diff --git a/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp b/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp index 927f28da3d..93fe7d40a1 100644 --- a/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp @@ -27,7 +27,7 @@ using namespace ento; namespace { class UndefCapturedBlockVarChecker : public Checker< check::PostStmt > { - mutable OwningPtr BT; + mutable std::unique_ptr BT; public: void checkPostStmt(const BlockExpr *BE, CheckerContext &C) const; diff --git a/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp b/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp index fd3c8f1538..00fd971969 100644 --- a/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp @@ -28,8 +28,8 @@ namespace { class UndefResultChecker : public Checker< check::PostStmt > { - mutable OwningPtr BT; - + mutable std::unique_ptr BT; + public: void checkPostStmt(const BinaryOperator *B, CheckerContext &C) const; }; diff --git a/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp b/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp index 3468e67f3c..e952671eff 100644 --- a/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp @@ -25,7 +25,7 @@ using namespace ento; namespace { class UndefinedArraySubscriptChecker : public Checker< check::PreStmt > { - mutable OwningPtr BT; + mutable std::unique_ptr BT; public: void checkPreStmt(const ArraySubscriptExpr *A, CheckerContext &C) const; diff --git a/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp b/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp index b06ecb0576..30775d57ce 100644 --- a/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp @@ -24,7 +24,7 @@ using namespace ento; namespace { class UndefinedAssignmentChecker : public Checker { - mutable OwningPtr BT; + mutable std::unique_ptr BT; public: void checkBind(SVal location, SVal val, const Stmt *S, diff --git a/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp b/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp index bdf789d788..8869654e9c 100644 --- a/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp @@ -30,7 +30,7 @@ using namespace ento; namespace { class UnixAPIChecker : public Checker< check::PreStmt > { - mutable OwningPtr BT_open, BT_pthreadOnce, BT_mallocZero; + mutable std::unique_ptr BT_open, BT_pthreadOnce, BT_mallocZero; mutable Optional Val_O_CREAT; public: @@ -57,7 +57,7 @@ private: const unsigned numArgs, const unsigned sizeArg, const char *fn) const; - void LazyInitialize(OwningPtr &BT, const char *name) const { + void LazyInitialize(std::unique_ptr &BT, const char *name) const { if (BT) return; BT.reset(new BugType(this, name, categories::UnixAPI)); diff --git a/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp b/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp index 966715be0f..c7b2024e34 100644 --- a/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp @@ -29,7 +29,7 @@ using namespace ento; namespace { class VLASizeChecker : public Checker< check::PreStmt > { - mutable OwningPtr BT; + mutable std::unique_ptr BT; enum VLASize_Kind { VLA_Garbage, VLA_Zero, VLA_Tainted }; void reportBug(VLASize_Kind Kind, diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp index 176826d6b9..e3f4287056 100644 --- a/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -2816,7 +2816,7 @@ namespace { class ReportGraph { public: InterExplodedGraphMap BackMap; - OwningPtr Graph; + std::unique_ptr Graph; const ExplodedNode *ErrorNode; size_t Index; }; @@ -2831,7 +2831,7 @@ class TrimmedGraph { typedef std::pair NodeIndexPair; SmallVector ReportNodes; - OwningPtr G; + std::unique_ptr G; /// A helper class for sorting ExplodedNodes by priority. template @@ -3415,15 +3415,13 @@ void BugReporter::FlushReport(BugReport *exampleReport, // Probably doesn't make a difference in practice. BugType& BT = exampleReport->getBugType(); - OwningPtr - D(new PathDiagnostic(exampleReport->getBugType().getCheckName(), - exampleReport->getDeclWithIssue(), - exampleReport->getBugType().getName(), - exampleReport->getDescription(), - exampleReport->getShortDescription(/*Fallback=*/false), - BT.getCategory(), - exampleReport->getUniqueingLocation(), - exampleReport->getUniqueingDecl())); + std::unique_ptr D(new PathDiagnostic( + exampleReport->getBugType().getCheckName(), + exampleReport->getDeclWithIssue(), exampleReport->getBugType().getName(), + exampleReport->getDescription(), + exampleReport->getShortDescription(/*Fallback=*/false), BT.getCategory(), + exampleReport->getUniqueingLocation(), + exampleReport->getUniqueingDecl())); MaxBugClassSize = std::max(bugReports.size(), static_cast(MaxBugClassSize)); diff --git a/lib/StaticAnalyzer/Core/ExprEngine.cpp b/lib/StaticAnalyzer/Core/ExprEngine.cpp index fde466a527..85c7b52665 100644 --- a/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -2550,7 +2550,7 @@ void ExprEngine::ViewGraph(ArrayRef Nodes) { GraphPrintCheckerState = this; GraphPrintSourceManager = &getContext().getSourceManager(); - OwningPtr TrimmedG(G.trim(Nodes)); + std::unique_ptr TrimmedG(G.trim(Nodes)); if (!TrimmedG.get()) llvm::errs() << "warning: Trimmed ExplodedGraph is empty.\n"; diff --git a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp index 8c08e75004..89e4309175 100644 --- a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp +++ b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp @@ -197,8 +197,8 @@ PathDiagnosticConsumer::~PathDiagnosticConsumer() { } void PathDiagnosticConsumer::HandlePathDiagnostic(PathDiagnostic *D) { - OwningPtr OwningD(D); - + std::unique_ptr OwningD(D); + if (!D || D->path.empty()) return; diff --git a/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp index e3977c23f7..c6e6bfd92c 100644 --- a/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ b/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -171,8 +171,8 @@ public: StoreManagerCreator CreateStoreMgr; ConstraintManagerCreator CreateConstraintMgr; - OwningPtr checkerMgr; - OwningPtr Mgr; + std::unique_ptr checkerMgr; + std::unique_ptr Mgr; /// Time the analyzes time of each translation unit. static llvm::Timer* TUTotalTimer; @@ -641,7 +641,7 @@ void AnalysisConsumer::ActionExprEngine(Decl *D, bool ObjCGCEnabled, ExprEngine Eng(*Mgr, ObjCGCEnabled, VisitedCallees, &FunctionSummaries,IMode); // Set the graph auditor. - OwningPtr Auditor; + std::unique_ptr Auditor; if (Mgr->options.visualizeExplodedGraphWithUbiGraph) { Auditor.reset(CreateUbiViz()); ExplodedNode::SetAuditor(Auditor.get()); @@ -704,7 +704,7 @@ ento::CreateAnalysisConsumer(const Preprocessor &pp, const std::string &outDir, namespace { class UbigraphViz : public ExplodedNode::Auditor { - OwningPtr Out; + std::unique_ptr Out; std::string Filename; unsigned Cntr; @@ -727,7 +727,7 @@ static ExplodedNode::Auditor* CreateUbiViz() { llvm::sys::fs::createTemporaryFile("llvm_ubi", "", FD, P); llvm::errs() << "Writing '" << P.str() << "'.\n"; - OwningPtr Stream; + std::unique_ptr Stream; Stream.reset(new llvm::raw_fd_ostream(FD, true)); return new UbigraphViz(Stream.release(), P); diff --git a/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp b/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp index d7cb914822..836007bf46 100644 --- a/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp +++ b/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp @@ -104,8 +104,8 @@ CheckerManager *ento::createCheckerManager(AnalyzerOptions &opts, const LangOptions &langOpts, ArrayRef plugins, DiagnosticsEngine &diags) { - OwningPtr checkerMgr(new CheckerManager(langOpts, - &opts)); + std::unique_ptr checkerMgr( + new CheckerManager(langOpts, &opts)); SmallVector checkerOpts; for (unsigned i = 0, e = opts.CheckersControlList.size(); i != e; ++i) { diff --git a/lib/Tooling/CompilationDatabase.cpp b/lib/Tooling/CompilationDatabase.cpp index 76c006f389..57424e37e9 100644 --- a/lib/Tooling/CompilationDatabase.cpp +++ b/lib/Tooling/CompilationDatabase.cpp @@ -43,7 +43,7 @@ CompilationDatabase::loadFromDirectory(StringRef BuildDirectory, Ie = CompilationDatabasePluginRegistry::end(); It != Ie; ++It) { std::string DatabaseErrorMessage; - OwningPtr Plugin(It->instantiate()); + std::unique_ptr Plugin(It->instantiate()); if (CompilationDatabase *DB = Plugin->loadFromDirectory(BuildDirectory, DatabaseErrorMessage)) return DB; @@ -213,7 +213,7 @@ static bool stripPositionalArgs(std::vector Args, // Neither clang executable nor default image name are required since the // jobs the driver builds will not be executed. - OwningPtr NewDriver(new driver::Driver( + std::unique_ptr NewDriver(new driver::Driver( /* ClangExecutable= */ "", llvm::sys::getDefaultTargetTriple(), /* DefaultImageName= */ "", Diagnostics)); NewDriver->setCheckInputsExist(false); @@ -241,7 +241,7 @@ static bool stripPositionalArgs(std::vector Args, std::remove_if(Args.begin(), Args.end(), MatchesAny(std::string("-no-integrated-as"))); - const OwningPtr Compilation( + const std::unique_ptr Compilation( NewDriver->BuildCompilation(Args)); const driver::JobList &Jobs = Compilation->getJobs(); diff --git a/lib/Tooling/JSONCompilationDatabase.cpp b/lib/Tooling/JSONCompilationDatabase.cpp index 232c329de2..04568757d4 100644 --- a/lib/Tooling/JSONCompilationDatabase.cpp +++ b/lib/Tooling/JSONCompilationDatabase.cpp @@ -122,7 +122,7 @@ class JSONCompilationDatabasePlugin : public CompilationDatabasePlugin { StringRef Directory, std::string &ErrorMessage) { SmallString<1024> JSONDatabasePath(Directory); llvm::sys::path::append(JSONDatabasePath, "compile_commands.json"); - OwningPtr Database( + std::unique_ptr Database( JSONCompilationDatabase::loadFromFile(JSONDatabasePath, ErrorMessage)); if (!Database) return NULL; @@ -144,14 +144,14 @@ volatile int JSONAnchorSource = 0; JSONCompilationDatabase * JSONCompilationDatabase::loadFromFile(StringRef FilePath, std::string &ErrorMessage) { - OwningPtr DatabaseBuffer; + std::unique_ptr DatabaseBuffer; llvm::error_code Result = llvm::MemoryBuffer::getFile(FilePath, DatabaseBuffer); if (Result != 0) { ErrorMessage = "Error while opening JSON database: " + Result.message(); return NULL; } - OwningPtr Database( + std::unique_ptr Database( new JSONCompilationDatabase(DatabaseBuffer.release())); if (!Database->parse(ErrorMessage)) return NULL; @@ -161,9 +161,9 @@ JSONCompilationDatabase::loadFromFile(StringRef FilePath, JSONCompilationDatabase * JSONCompilationDatabase::loadFromBuffer(StringRef DatabaseString, std::string &ErrorMessage) { - OwningPtr DatabaseBuffer( + std::unique_ptr DatabaseBuffer( llvm::MemoryBuffer::getMemBuffer(DatabaseString)); - OwningPtr Database( + std::unique_ptr Database( new JSONCompilationDatabase(DatabaseBuffer.release())); if (!Database->parse(ErrorMessage)) return NULL; diff --git a/lib/Tooling/Tooling.cpp b/lib/Tooling/Tooling.cpp index 9783ed0fe0..c720bf4e85 100644 --- a/lib/Tooling/Tooling.cpp +++ b/lib/Tooling/Tooling.cpp @@ -207,18 +207,18 @@ bool ToolInvocation::run() { IntrusiveRefCntPtr(new DiagnosticIDs()), &*DiagOpts, DiagConsumer ? DiagConsumer : &DiagnosticPrinter, false); - const OwningPtr Driver( + const std::unique_ptr Driver( newDriver(&Diagnostics, BinaryName)); // Since the input might only be virtual, don't check whether it exists. Driver->setCheckInputsExist(false); - const OwningPtr Compilation( + const std::unique_ptr Compilation( Driver->BuildCompilation(llvm::makeArrayRef(Argv))); const llvm::opt::ArgStringList *const CC1Args = getCC1Arguments( &Diagnostics, Compilation.get()); if (CC1Args == NULL) { return false; } - OwningPtr Invocation( + std::unique_ptr Invocation( newInvocation(&Diagnostics, *CC1Args)); for (llvm::StringMap::const_iterator It = MappedFileContents.begin(), End = MappedFileContents.end(); @@ -255,8 +255,8 @@ bool FrontendActionFactory::runInvocation(CompilerInvocation *Invocation, // The FrontendAction can have lifetime requirements for Compiler or its // members, and we need to ensure it's deleted earlier than Compiler. So we - // pass it to an OwningPtr declared after the Compiler variable. - OwningPtr ScopedToolAction(create()); + // pass it to an std::unique_ptr declared after the Compiler variable. + std::unique_ptr ScopedToolAction(create()); // Create the compilers actual diagnostics engine. Compiler.createDiagnostics(DiagConsumer, /*ShouldOwnClient=*/false); diff --git a/tools/arcmt-test/arcmt-test.cpp b/tools/arcmt-test/arcmt-test.cpp index 50426e3f42..518d06f2ad 100644 --- a/tools/arcmt-test/arcmt-test.cpp +++ b/tools/arcmt-test/arcmt-test.cpp @@ -178,7 +178,7 @@ static bool performTransformations(StringRef resourcesPath, origCI.getMigratorOpts().NoFinalizeRemoval); assert(!transforms.empty()); - OwningPtr transformPrinter; + std::unique_ptr transformPrinter; if (OutputTransformations) transformPrinter.reset(new PrintTransforms(llvm::outs())); @@ -207,12 +207,12 @@ static bool performTransformations(StringRef resourcesPath, static bool filesCompareEqual(StringRef fname1, StringRef fname2) { using namespace llvm; - OwningPtr file1; + std::unique_ptr file1; MemoryBuffer::getFile(fname1, file1); if (!file1) return false; - - OwningPtr file2; + + std::unique_ptr file2; MemoryBuffer::getFile(fname2, file2); if (!file2) return false; @@ -238,7 +238,7 @@ static bool verifyTransformedFiles(ArrayRef resultFiles) { resultMap[sys::path::stem(fname)] = fname; } - OwningPtr inputBuf; + std::unique_ptr inputBuf; if (RemappingsFile.empty()) MemoryBuffer::getSTDIN(inputBuf); else diff --git a/tools/clang-check/ClangCheck.cpp b/tools/clang-check/ClangCheck.cpp index 9cdaf878a2..011cd3fad8 100644 --- a/tools/clang-check/ClangCheck.cpp +++ b/tools/clang-check/ClangCheck.cpp @@ -50,7 +50,7 @@ static cl::extrahelp MoreHelp( ); static cl::OptionCategory ClangCheckCategory("clang-check options"); -static OwningPtr Options(createDriverOptTable()); +static std::unique_ptr Options(createDriverOptTable()); static cl::opt ASTDump("ast-dump", cl::desc(Options->getOptionHelpText(options::OPT_ast_dump)), cl::cat(ClangCheckCategory)); diff --git a/tools/clang-format/ClangFormat.cpp b/tools/clang-format/ClangFormat.cpp index 9107fd2b10..6f94461aba 100644 --- a/tools/clang-format/ClangFormat.cpp +++ b/tools/clang-format/ClangFormat.cpp @@ -208,7 +208,7 @@ static bool format(StringRef FileName) { IntrusiveRefCntPtr(new DiagnosticIDs), new DiagnosticOptions); SourceManager Sources(Diagnostics, Files); - OwningPtr Code; + std::unique_ptr Code; if (error_code ec = MemoryBuffer::getFileOrSTDIN(FileName, Code)) { llvm::errs() << ec.message() << "\n"; return true; diff --git a/tools/diagtool/ShowEnabledWarnings.cpp b/tools/diagtool/ShowEnabledWarnings.cpp index 51213a41fc..ad56b03604 100644 --- a/tools/diagtool/ShowEnabledWarnings.cpp +++ b/tools/diagtool/ShowEnabledWarnings.cpp @@ -64,9 +64,9 @@ createDiagnostics(unsigned int argc, char **argv) { new DiagnosticsEngine(DiagIDs, new DiagnosticOptions(), DiagsBuffer)); // Try to build a CompilerInvocation. - OwningPtr Invocation( - createInvocationFromCommandLine(ArrayRef(argv, argc), - InterimDiags)); + std::unique_ptr Invocation( + createInvocationFromCommandLine(ArrayRef(argv, argc), + InterimDiags)); if (!Invocation) return NULL; diff --git a/tools/driver/cc1_main.cpp b/tools/driver/cc1_main.cpp index 8738e0afec..1c37c7ddee 100644 --- a/tools/driver/cc1_main.cpp +++ b/tools/driver/cc1_main.cpp @@ -59,7 +59,7 @@ static void LLVMErrorHandler(void *UserData, const std::string &Message, int cc1_main(const char **ArgBegin, const char **ArgEnd, const char *Argv0, void *MainAddr) { - OwningPtr Clang(new CompilerInstance()); + std::unique_ptr Clang(new CompilerInstance()); IntrusiveRefCntPtr DiagID(new DiagnosticIDs()); // Initialize targets first, so that --version shows registered targets. diff --git a/tools/driver/cc1as_main.cpp b/tools/driver/cc1as_main.cpp index e68bd02592..7d6af7925f 100644 --- a/tools/driver/cc1as_main.cpp +++ b/tools/driver/cc1as_main.cpp @@ -151,10 +151,10 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts, bool Success = true; // Parse the arguments. - OwningPtr OptTbl(createCC1AsOptTable()); + std::unique_ptr OptTbl(createCC1AsOptTable()); unsigned MissingArgIndex, MissingArgCount; - OwningPtr Args( - OptTbl->ParseArgs(ArgBegin, ArgEnd,MissingArgIndex, MissingArgCount)); + std::unique_ptr Args( + OptTbl->ParseArgs(ArgBegin, ArgEnd, MissingArgIndex, MissingArgCount)); // Check for missing argument error. if (MissingArgCount) { @@ -271,7 +271,7 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts, return false; } - OwningPtr BufferPtr; + std::unique_ptr BufferPtr; if (error_code ec = MemoryBuffer::getFileOrSTDIN(Opts.InputFile, BufferPtr)) { Error = ec.message(); Diags.Report(diag::err_fe_error_reading) << Opts.InputFile; @@ -288,10 +288,10 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts, // it later. SrcMgr.setIncludeDirs(Opts.IncludePaths); - OwningPtr MRI(TheTarget->createMCRegInfo(Opts.Triple)); + std::unique_ptr MRI(TheTarget->createMCRegInfo(Opts.Triple)); assert(MRI && "Unable to create target register info!"); - OwningPtr MAI(TheTarget->createMCAsmInfo(*MRI, Opts.Triple)); + std::unique_ptr MAI(TheTarget->createMCAsmInfo(*MRI, Opts.Triple)); assert(MAI && "Unable to create target asm info!"); bool IsBinary = Opts.OutputType == AssemblerInvocation::FT_Obj; @@ -301,7 +301,7 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts, // FIXME: This is not pretty. MCContext has a ptr to MCObjectFileInfo and // MCObjectFileInfo needs a MCContext reference in order to initialize itself. - OwningPtr MOFI(new MCObjectFileInfo()); + std::unique_ptr MOFI(new MCObjectFileInfo()); MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), &SrcMgr); // FIXME: Assembler behavior can change with -static. MOFI->InitMCObjectFileInfo(Opts.Triple, @@ -327,11 +327,11 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts, FS += "," + Opts.Features[i]; } - OwningPtr Str; + std::unique_ptr Str; - OwningPtr MCII(TheTarget->createMCInstrInfo()); - OwningPtr - STI(TheTarget->createMCSubtargetInfo(Opts.Triple, Opts.CPU, FS)); + std::unique_ptr MCII(TheTarget->createMCInstrInfo()); + std::unique_ptr STI( + TheTarget->createMCSubtargetInfo(Opts.Triple, Opts.CPU, FS)); // FIXME: There is a bit of code duplication with addPassesToEmitFile. if (Opts.OutputType == AssemblerInvocation::FT_Asm) { @@ -363,9 +363,10 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts, Str.get()->InitSections(); } - OwningPtr Parser(createMCAsmParser(SrcMgr, Ctx, - *Str.get(), *MAI)); - OwningPtr TAP(TheTarget->createMCAsmParser(*STI, *Parser, *MCII)); + std::unique_ptr Parser( + createMCAsmParser(SrcMgr, Ctx, *Str.get(), *MAI)); + std::unique_ptr TAP( + TheTarget->createMCAsmParser(*STI, *Parser, *MCII)); if (!TAP) { Diags.Report(diag::err_target_unknown_triple) << Opts.Triple; return false; @@ -427,7 +428,7 @@ int cc1as_main(const char **ArgBegin, const char **ArgEnd, // Honor -help. if (Asm.ShowHelp) { - OwningPtr Opts(driver::createCC1AsOptTable()); + std::unique_ptr Opts(driver::createCC1AsOptTable()); Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler"); return 0; } diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp index 90e3371a14..6fca3ecbed 100644 --- a/tools/driver/driver.cpp +++ b/tools/driver/driver.cpp @@ -341,11 +341,10 @@ int main(int argc_, const char **argv_) { IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions; { - OwningPtr Opts(createDriverOptTable()); + std::unique_ptr Opts(createDriverOptTable()); unsigned MissingArgIndex, MissingArgCount; - OwningPtr Args(Opts->ParseArgs(argv.begin()+1, argv.end(), - MissingArgIndex, - MissingArgCount)); + std::unique_ptr Args(Opts->ParseArgs( + argv.begin() + 1, argv.end(), MissingArgIndex, MissingArgCount)); // We ignore MissingArgCount and the return value of ParseDiagnosticArgs. // Any errors that would be diagnosed here will also be diagnosed later, // when the DiagnosticsEngine actually exists. @@ -408,7 +407,7 @@ int main(int argc_, const char **argv_) { if (TheDriver.CCLogDiagnostics) TheDriver.CCLogDiagnosticsFilename = ::getenv("CC_LOG_DIAGNOSTICS_FILE"); - OwningPtr C(TheDriver.BuildCompilation(argv)); + std::unique_ptr C(TheDriver.BuildCompilation(argv)); int Res = 0; SmallVector, 4> FailingCommands; if (C.get()) diff --git a/tools/libclang/ARCMigrate.cpp b/tools/libclang/ARCMigrate.cpp index 1b80b2f5c3..dbb604d797 100644 --- a/tools/libclang/ARCMigrate.cpp +++ b/tools/libclang/ARCMigrate.cpp @@ -55,7 +55,7 @@ CXRemapping clang_getRemappings(const char *migrate_dir_path) { } TextDiagnosticBuffer diagBuffer; - OwningPtr remap(new Remap()); + std::unique_ptr remap(new Remap()); bool err = arcmt::getFileRemappings(remap->Vec, migrate_dir_path,&diagBuffer); @@ -77,7 +77,7 @@ CXRemapping clang_getRemappingsFromFileList(const char **filePaths, unsigned numFiles) { bool Logging = ::getenv("LIBCLANG_LOGGING"); - OwningPtr remap(new Remap()); + std::unique_ptr remap(new Remap()); if (numFiles == 0) { if (Logging) diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 614bb0cbfc..d98acb197f 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -2723,8 +2723,8 @@ static void clang_parseTranslationUnit_Impl(void *UserData) { llvm::CrashRecoveryContextReleaseRefCleanup > DiagCleanup(Diags.getPtr()); - OwningPtr > - RemappedFiles(new std::vector()); + std::unique_ptr> RemappedFiles( + new std::vector()); // Recover resources if we crash before exiting this function. llvm::CrashRecoveryContextCleanupRegistrar< @@ -2738,8 +2738,8 @@ static void clang_parseTranslationUnit_Impl(void *UserData) { Buffer)); } - OwningPtr > - Args(new std::vector()); + std::unique_ptr> Args( + new std::vector()); // Recover resources if we crash before exiting this method. llvm::CrashRecoveryContextCleanupRegistrar > @@ -2779,26 +2779,17 @@ static void clang_parseTranslationUnit_Impl(void *UserData) { } unsigned NumErrors = Diags->getClient()->getNumErrors(); - OwningPtr ErrUnit; - OwningPtr Unit( - ASTUnit::LoadFromCommandLine(Args->size() ? &(*Args)[0] : 0 - /* vector::data() not portable */, - Args->size() ? (&(*Args)[0] + Args->size()) :0, - Diags, - CXXIdx->getClangResourcesPath(), - CXXIdx->getOnlyLocalDecls(), - /*CaptureDiagnostics=*/true, - *RemappedFiles.get(), - /*RemappedFilesKeepOriginalName=*/true, - PrecompilePreamble, - TUKind, - CacheCodeCompletionResults, - IncludeBriefCommentsInCodeCompletion, - /*AllowPCHWithCompilerErrors=*/true, - SkipFunctionBodies, - /*UserFilesAreVolatile=*/true, - ForSerialization, - &ErrUnit)); + std::unique_ptr ErrUnit; + std::unique_ptr Unit(ASTUnit::LoadFromCommandLine( + Args->size() ? &(*Args)[0] : 0 + /* vector::data() not portable */, + Args->size() ? (&(*Args)[0] + Args->size()) : 0, Diags, + CXXIdx->getClangResourcesPath(), CXXIdx->getOnlyLocalDecls(), + /*CaptureDiagnostics=*/true, *RemappedFiles.get(), + /*RemappedFilesKeepOriginalName=*/true, PrecompilePreamble, TUKind, + CacheCodeCompletionResults, IncludeBriefCommentsInCodeCompletion, + /*AllowPCHWithCompilerErrors=*/true, SkipFunctionBodies, + /*UserFilesAreVolatile=*/true, ForSerialization, &ErrUnit)); if (NumErrors != Diags->getClient()->getNumErrors()) { // Make sure to check that 'Unit' is non-NULL. @@ -3019,10 +3010,10 @@ static void clang_reparseTranslationUnit_Impl(void *UserData) { ASTUnit *CXXUnit = cxtu::getASTUnit(TU); ASTUnit::ConcurrencyCheck Check(*CXXUnit); - - OwningPtr > - RemappedFiles(new std::vector()); - + + std::unique_ptr> RemappedFiles( + new std::vector()); + // Recover resources if we crash before exiting this function. llvm::CrashRecoveryContextCleanupRegistrar< std::vector > RemappedCleanup(RemappedFiles.get()); @@ -6524,7 +6515,7 @@ CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU) { } ASTUnit *astUnit = cxtu::getASTUnit(TU); - OwningPtr entries(new MemUsageEntries()); + std::unique_ptr entries(new MemUsageEntries()); ASTContext &astContext = astUnit->getASTContext(); // How much memory is used by AST nodes and types? diff --git a/tools/libclang/CXLoadedDiagnostic.cpp b/tools/libclang/CXLoadedDiagnostic.cpp index 2871256b0c..679c528526 100644 --- a/tools/libclang/CXLoadedDiagnostic.cpp +++ b/tools/libclang/CXLoadedDiagnostic.cpp @@ -259,7 +259,7 @@ CXDiagnosticSet DiagLoader::load(const char *file) { FileSystemOptions FO; FileManager FileMgr(FO); - OwningPtr Buffer; + std::unique_ptr Buffer; Buffer.reset(FileMgr.getBufferForFile(file)); if (!Buffer) { @@ -284,7 +284,8 @@ CXDiagnosticSet DiagLoader::load(const char *file) { return 0; } - OwningPtr Diags(new CXLoadedDiagnosticSetImpl()); + std::unique_ptr Diags( + new CXLoadedDiagnosticSetImpl()); while (true) { unsigned BlockID = 0; @@ -539,8 +540,8 @@ LoadResult DiagLoader::readDiagnosticBlock(llvm::BitstreamCursor &Stream, reportInvalidFile("malformed diagnostic block"); return Failure; } - - OwningPtr D(new CXLoadedDiagnostic()); + + std::unique_ptr D(new CXLoadedDiagnostic()); RecordData Record; while (true) { diff --git a/tools/libclang/Indexing.cpp b/tools/libclang/Indexing.cpp index 29ecd1ccc7..24c1362217 100644 --- a/tools/libclang/Indexing.cpp +++ b/tools/libclang/Indexing.cpp @@ -411,7 +411,7 @@ class IndexingFrontendAction : public ASTFrontendAction { CXTranslationUnit CXTU; SessionSkipBodyData *SKData; - OwningPtr SKCtrl; + std::unique_ptr SKCtrl; public: IndexingFrontendAction(CXClientData clientData, @@ -465,7 +465,7 @@ public: struct IndexSessionData { CXIndex CIdx; - OwningPtr SkipBodyData; + std::unique_ptr SkipBodyData; explicit IndexSessionData(CXIndex cIdx) : CIdx(cIdx), SkipBodyData(new SessionSkipBodyData) {} @@ -559,9 +559,9 @@ static void clang_indexSourceFile_Impl(void *UserData) { llvm::CrashRecoveryContextCleanupRegistrar > DiagCleanup(Diags.getPtr()); - - OwningPtr > - Args(new std::vector()); + + std::unique_ptr> Args( + new std::vector()); // Recover resources if we crash before exiting this method. llvm::CrashRecoveryContextCleanupRegistrar > @@ -592,7 +592,7 @@ static void clang_indexSourceFile_Impl(void *UserData) { if (CInvok->getFrontendOpts().Inputs.empty()) return; - OwningPtr BufOwner(new MemBufferOwner()); + std::unique_ptr BufOwner(new MemBufferOwner()); // Recover resources if we crash before exiting this method. llvm::CrashRecoveryContextCleanupRegistrar @@ -618,7 +618,8 @@ static void clang_indexSourceFile_Impl(void *UserData) { ASTUnit *Unit = ASTUnit::create(CInvok.getPtr(), Diags, CaptureDiagnostics, /*UserFilesAreVolatile=*/true); - OwningPtr CXTU(new CXTUOwner(MakeCXTranslationUnit(CXXIdx, Unit))); + std::unique_ptr CXTU( + new CXTUOwner(MakeCXTranslationUnit(CXXIdx, Unit))); // Recover resources if we crash before exiting this method. llvm::CrashRecoveryContextCleanupRegistrar @@ -631,7 +632,7 @@ static void clang_indexSourceFile_Impl(void *UserData) { if (SkipBodies) CInvok->getFrontendOpts().SkipFunctionBodies = true; - OwningPtr IndexAction; + std::unique_ptr IndexAction; IndexAction.reset(new IndexingFrontendAction(client_data, CB, index_options, CXTU->getTU(), SkipBodies ? IdxSession->SkipBodyData.get() : 0)); @@ -790,14 +791,14 @@ static void clang_indexTranslationUnit_Impl(void *UserData) { ? index_callbacks_size : sizeof(CB); memcpy(&CB, client_index_callbacks, ClientCBSize); - OwningPtr IndexCtx; + std::unique_ptr IndexCtx; IndexCtx.reset(new IndexingContext(client_data, CB, index_options, TU)); // Recover resources if we crash before exiting this method. llvm::CrashRecoveryContextCleanupRegistrar IndexCtxCleanup(IndexCtx.get()); - OwningPtr IndexConsumer; + std::unique_ptr IndexConsumer; IndexConsumer.reset(new IndexingConsumer(*IndexCtx, 0)); // Recover resources if we crash before exiting this method. diff --git a/unittests/AST/DeclPrinterTest.cpp b/unittests/AST/DeclPrinterTest.cpp index 5420d968ce..5340756c03 100644 --- a/unittests/AST/DeclPrinterTest.cpp +++ b/unittests/AST/DeclPrinterTest.cpp @@ -74,7 +74,8 @@ public: PrintMatch Printer; MatchFinder Finder; Finder.addMatcher(NodeMatch, &Printer); - OwningPtr Factory(newFrontendActionFactory(&Finder)); + std::unique_ptr Factory( + newFrontendActionFactory(&Finder)); if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, FileName)) return testing::AssertionFailure() diff --git a/unittests/AST/DeclTest.cpp b/unittests/AST/DeclTest.cpp index c845da2ca6..87aeef47c6 100644 --- a/unittests/AST/DeclTest.cpp +++ b/unittests/AST/DeclTest.cpp @@ -20,7 +20,7 @@ using namespace clang::tooling; TEST(Decl, CleansUpAPValues) { MatchFinder Finder; - llvm::OwningPtr Factory( + std::unique_ptr Factory( newFrontendActionFactory(&Finder)); // This is a regression test for a memory leak in APValues for structs that diff --git a/unittests/AST/MatchVerifier.h b/unittests/AST/MatchVerifier.h index 5a29cde227..0265f4a24a 100644 --- a/unittests/AST/MatchVerifier.h +++ b/unittests/AST/MatchVerifier.h @@ -79,7 +79,7 @@ testing::AssertionResult MatchVerifier::match( std::vector& Args, Language L) { MatchFinder Finder; Finder.addMatcher(AMatcher.bind(""), this); - OwningPtr Factory( + std::unique_ptr Factory( tooling::newFrontendActionFactory(&Finder)); StringRef FileName; diff --git a/unittests/AST/StmtPrinterTest.cpp b/unittests/AST/StmtPrinterTest.cpp index 5f54abd0c0..d7265176d1 100644 --- a/unittests/AST/StmtPrinterTest.cpp +++ b/unittests/AST/StmtPrinterTest.cpp @@ -72,7 +72,8 @@ PrintedStmtMatches(StringRef Code, const std::vector &Args, PrintMatch Printer; MatchFinder Finder; Finder.addMatcher(NodeMatch, &Printer); - OwningPtr Factory(newFrontendActionFactory(&Finder)); + std::unique_ptr Factory( + newFrontendActionFactory(&Finder)); if (!runToolOnCodeWithArgs(Factory->create(), Code, Args)) return testing::AssertionFailure() diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp index 2c656e12ad..f1b792139d 100644 --- a/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -4165,12 +4165,13 @@ TEST(MatchFinder, InterceptsStartOfTranslationUnit) { MatchFinder Finder; VerifyStartOfTranslationUnit VerifyCallback; Finder.addMatcher(decl(), &VerifyCallback); - OwningPtr Factory(newFrontendActionFactory(&Finder)); + std::unique_ptr Factory( + newFrontendActionFactory(&Finder)); ASSERT_TRUE(tooling::runToolOnCode(Factory->create(), "int x;")); EXPECT_TRUE(VerifyCallback.Called); VerifyCallback.Called = false; - OwningPtr AST(tooling::buildASTFromCode("int x;")); + std::unique_ptr AST(tooling::buildASTFromCode("int x;")); ASSERT_TRUE(AST.get()); Finder.matchAST(AST->getASTContext()); EXPECT_TRUE(VerifyCallback.Called); @@ -4192,12 +4193,13 @@ TEST(MatchFinder, InterceptsEndOfTranslationUnit) { MatchFinder Finder; VerifyEndOfTranslationUnit VerifyCallback; Finder.addMatcher(decl(), &VerifyCallback); - OwningPtr Factory(newFrontendActionFactory(&Finder)); + std::unique_ptr Factory( + newFrontendActionFactory(&Finder)); ASSERT_TRUE(tooling::runToolOnCode(Factory->create(), "int x;")); EXPECT_TRUE(VerifyCallback.Called); VerifyCallback.Called = false; - OwningPtr AST(tooling::buildASTFromCode("int x;")); + std::unique_ptr AST(tooling::buildASTFromCode("int x;")); ASSERT_TRUE(AST.get()); Finder.matchAST(AST->getASTContext()); EXPECT_TRUE(VerifyCallback.Called); diff --git a/unittests/ASTMatchers/ASTMatchersTest.h b/unittests/ASTMatchers/ASTMatchersTest.h index e79f9114f2..e224722e96 100644 --- a/unittests/ASTMatchers/ASTMatchersTest.h +++ b/unittests/ASTMatchers/ASTMatchersTest.h @@ -67,7 +67,8 @@ testing::AssertionResult matchesConditionally(const std::string &Code, Finder.addMatcher(AMatcher, new VerifyMatch(0, &Found)); if (!Finder.addDynamicMatcher(AMatcher, new VerifyMatch(0, &DynamicFound))) return testing::AssertionFailure() << "Could not add dynamic matcher"; - OwningPtr Factory(newFrontendActionFactory(&Finder)); + std::unique_ptr Factory( + newFrontendActionFactory(&Finder)); // Some tests use typeof, which is a gnu extension. std::vector Args(1, CompileArg); if (!runToolOnCodeWithArgs(Factory->create(), Code, Args)) { @@ -105,12 +106,13 @@ testing::AssertionResult matchAndVerifyResultConditionally(const std::string &Code, const T &AMatcher, BoundNodesCallback *FindResultVerifier, bool ExpectResult) { - OwningPtr ScopedVerifier(FindResultVerifier); + std::unique_ptr ScopedVerifier(FindResultVerifier); bool VerifiedResult = false; MatchFinder Finder; Finder.addMatcher( AMatcher, new VerifyMatch(FindResultVerifier, &VerifiedResult)); - OwningPtr Factory(newFrontendActionFactory(&Finder)); + std::unique_ptr Factory( + newFrontendActionFactory(&Finder)); // Some tests use typeof, which is a gnu extension. std::vector Args(1, "-std=gnu++98"); if (!runToolOnCodeWithArgs(Factory->create(), Code, Args)) { @@ -125,7 +127,7 @@ matchAndVerifyResultConditionally(const std::string &Code, const T &AMatcher, } VerifiedResult = false; - OwningPtr AST(buildASTFromCodeWithArgs(Code, Args)); + std::unique_ptr AST(buildASTFromCodeWithArgs(Code, Args)); if (!AST.get()) return testing::AssertionFailure() << "Parsing error in \"" << Code << "\" while building AST"; diff --git a/unittests/ASTMatchers/Dynamic/RegistryTest.cpp b/unittests/ASTMatchers/Dynamic/RegistryTest.cpp index 8426649d3e..1d81f2f55b 100644 --- a/unittests/ASTMatchers/Dynamic/RegistryTest.cpp +++ b/unittests/ASTMatchers/Dynamic/RegistryTest.cpp @@ -370,7 +370,7 @@ TEST_F(RegistryTest, VariadicOp) { TEST_F(RegistryTest, Errors) { // Incorrect argument count. - OwningPtr Error(new Diagnostics()); + std::unique_ptr Error(new Diagnostics()); EXPECT_TRUE(constructMatcher("hasInitializer", Error.get()).isNull()); EXPECT_EQ("Incorrect argument count. (Expected = 1) != (Actual = 0)", Error->toString()); diff --git a/unittests/Basic/VirtualFileSystemTest.cpp b/unittests/Basic/VirtualFileSystemTest.cpp index c03ae6bd6c..40d2f168cd 100644 --- a/unittests/Basic/VirtualFileSystemTest.cpp +++ b/unittests/Basic/VirtualFileSystemTest.cpp @@ -38,11 +38,12 @@ public: return error_code(errc::no_such_file_or_directory, posix_category()); return I->second; } - error_code openFileForRead(const Twine &Path, OwningPtr &Result) { + error_code openFileForRead(const Twine &Path, + std::unique_ptr &Result) { llvm_unreachable("unimplemented"); } error_code getBufferForFile(const Twine &Name, - OwningPtr &Result, + std::unique_ptr &Result, int64_t FileSize = -1, bool RequiresNullTerminator = true) { llvm_unreachable("unimplemented"); diff --git a/unittests/Sema/ExternalSemaSourceTest.cpp b/unittests/Sema/ExternalSemaSourceTest.cpp index bc8b211755..7cb5af1f13 100644 --- a/unittests/Sema/ExternalSemaSourceTest.cpp +++ b/unittests/Sema/ExternalSemaSourceTest.cpp @@ -137,7 +137,7 @@ public: class ExternalSemaSourceInstaller : public clang::ASTFrontendAction { std::vector Watchers; std::vector Sources; - llvm::OwningPtr OwnedClient; + std::unique_ptr OwnedClient; protected: virtual clang::ASTConsumer * @@ -178,7 +178,7 @@ public: // Make sure that the NamespaceDiagnosticWatcher is not miscounting. TEST(ExternalSemaSource, SanityCheck) { - llvm::OwningPtr Installer( + std::unique_ptr Installer( new ExternalSemaSourceInstaller); NamespaceDiagnosticWatcher Watcher("AAB", "BBB"); Installer->PushWatcher(&Watcher); @@ -191,7 +191,7 @@ TEST(ExternalSemaSource, SanityCheck) { // Check that when we add a NamespaceTypeProvider, we use that suggestion // instead of the usual suggestion we would use above. TEST(ExternalSemaSource, ExternalTypoCorrectionPrioritized) { - llvm::OwningPtr Installer( + std::unique_ptr Installer( new ExternalSemaSourceInstaller); NamespaceTypoProvider Provider("AAB", "BBB"); NamespaceDiagnosticWatcher Watcher("AAB", "BBB"); @@ -207,7 +207,7 @@ TEST(ExternalSemaSource, ExternalTypoCorrectionPrioritized) { // Check that we use the first successful TypoCorrection returned from an // ExternalSemaSource. TEST(ExternalSemaSource, ExternalTypoCorrectionOrdering) { - llvm::OwningPtr Installer( + std::unique_ptr Installer( new ExternalSemaSourceInstaller); NamespaceTypoProvider First("XXX", "BBB"); NamespaceTypoProvider Second("AAB", "CCC"); @@ -229,7 +229,7 @@ TEST(ExternalSemaSource, ExternalTypoCorrectionOrdering) { // We should only try MaybeDiagnoseMissingCompleteType if we can't otherwise // solve the problem. TEST(ExternalSemaSource, TryOtherTacticsBeforeDiagnosing) { - llvm::OwningPtr Installer( + std::unique_ptr Installer( new ExternalSemaSourceInstaller); CompleteTypeDiagnoser Diagnoser(false); Installer->PushSource(&Diagnoser); @@ -246,7 +246,7 @@ TEST(ExternalSemaSource, TryOtherTacticsBeforeDiagnosing) { // The first ExternalSemaSource where MaybeDiagnoseMissingCompleteType returns // true should be the last one called. TEST(ExternalSemaSource, FirstDiagnoserTaken) { - llvm::OwningPtr Installer( + std::unique_ptr Installer( new ExternalSemaSourceInstaller); CompleteTypeDiagnoser First(false); CompleteTypeDiagnoser Second(true); diff --git a/unittests/Tooling/CompilationDatabaseTest.cpp b/unittests/Tooling/CompilationDatabaseTest.cpp index 9260e621b3..9f078f4103 100644 --- a/unittests/Tooling/CompilationDatabaseTest.cpp +++ b/unittests/Tooling/CompilationDatabaseTest.cpp @@ -42,7 +42,7 @@ TEST(JSONCompilationDatabase, ErrsOnInvalidFormat) { static std::vector getAllFiles(StringRef JSONDatabase, std::string &ErrorMessage) { - OwningPtr Database( + std::unique_ptr Database( JSONCompilationDatabase::loadFromBuffer(JSONDatabase, ErrorMessage)); if (!Database) { ADD_FAILURE() << ErrorMessage; @@ -53,7 +53,7 @@ static std::vector getAllFiles(StringRef JSONDatabase, static std::vector getAllCompileCommands(StringRef JSONDatabase, std::string &ErrorMessage) { - OwningPtr Database( + std::unique_ptr Database( JSONCompilationDatabase::loadFromBuffer(JSONDatabase, ErrorMessage)); if (!Database) { ADD_FAILURE() << ErrorMessage; @@ -115,7 +115,7 @@ TEST(JSONCompilationDatabase, GetAllCompileCommands) { static CompileCommand findCompileArgsInJsonDatabase(StringRef FileName, StringRef JSONDatabase, std::string &ErrorMessage) { - OwningPtr Database( + std::unique_ptr Database( JSONCompilationDatabase::loadFromBuffer(JSONDatabase, ErrorMessage)); if (!Database) return CompileCommand(); @@ -433,7 +433,7 @@ TEST(FixedCompilationDatabase, GetAllCompileCommands) { TEST(ParseFixedCompilationDatabase, ReturnsNullOnEmptyArgumentList) { int Argc = 0; - OwningPtr Database( + std::unique_ptr Database( FixedCompilationDatabase::loadFromCommandLine(Argc, NULL)); EXPECT_FALSE(Database); EXPECT_EQ(0, Argc); @@ -442,7 +442,7 @@ TEST(ParseFixedCompilationDatabase, ReturnsNullOnEmptyArgumentList) { TEST(ParseFixedCompilationDatabase, ReturnsNullWithoutDoubleDash) { int Argc = 2; const char *Argv[] = { "1", "2" }; - OwningPtr Database( + std::unique_ptr Database( FixedCompilationDatabase::loadFromCommandLine(Argc, Argv)); EXPECT_FALSE(Database); EXPECT_EQ(2, Argc); @@ -453,7 +453,7 @@ TEST(ParseFixedCompilationDatabase, ReturnsArgumentsAfterDoubleDash) { const char *Argv[] = { "1", "2", "--\0no-constant-folding", "-DDEF3", "-DDEF4" }; - OwningPtr Database( + std::unique_ptr Database( FixedCompilationDatabase::loadFromCommandLine(Argc, Argv)); ASSERT_TRUE((bool)Database); std::vector Result = @@ -472,7 +472,7 @@ TEST(ParseFixedCompilationDatabase, ReturnsArgumentsAfterDoubleDash) { TEST(ParseFixedCompilationDatabase, ReturnsEmptyCommandLine) { int Argc = 3; const char *Argv[] = { "1", "2", "--\0no-constant-folding" }; - OwningPtr Database( + std::unique_ptr Database( FixedCompilationDatabase::loadFromCommandLine(Argc, Argv)); ASSERT_TRUE((bool)Database); std::vector Result = @@ -489,7 +489,7 @@ TEST(ParseFixedCompilationDatabase, ReturnsEmptyCommandLine) { TEST(ParseFixedCompilationDatabase, HandlesPositionalArgs) { const char *Argv[] = {"1", "2", "--", "-c", "somefile.cpp", "-DDEF3"}; int Argc = sizeof(Argv) / sizeof(char*); - OwningPtr Database( + std::unique_ptr Database( FixedCompilationDatabase::loadFromCommandLine(Argc, Argv)); ASSERT_TRUE((bool)Database); std::vector Result = @@ -508,7 +508,7 @@ TEST(ParseFixedCompilationDatabase, HandlesPositionalArgs) { TEST(ParseFixedCompilationDatabase, HandlesArgv0) { const char *Argv[] = {"1", "2", "--", "mytool", "somefile.cpp"}; int Argc = sizeof(Argv) / sizeof(char*); - OwningPtr Database( + std::unique_ptr Database( FixedCompilationDatabase::loadFromCommandLine(Argc, Argv)); ASSERT_TRUE((bool)Database); std::vector Result = diff --git a/unittests/Tooling/RefactoringCallbacksTest.cpp b/unittests/Tooling/RefactoringCallbacksTest.cpp index 9e086d869a..c2b331c70a 100644 --- a/unittests/Tooling/RefactoringCallbacksTest.cpp +++ b/unittests/Tooling/RefactoringCallbacksTest.cpp @@ -25,7 +25,7 @@ void expectRewritten(const std::string &Code, RefactoringCallback &Callback) { MatchFinder Finder; Finder.addMatcher(AMatcher, &Callback); - OwningPtr Factory( + std::unique_ptr Factory( tooling::newFrontendActionFactory(&Finder)); ASSERT_TRUE(tooling::runToolOnCode(Factory->create(), Code)) << "Parsing error in \"" << Code << "\""; diff --git a/unittests/Tooling/ToolingTest.cpp b/unittests/Tooling/ToolingTest.cpp index 302616b842..f99321c617 100644 --- a/unittests/Tooling/ToolingTest.cpp +++ b/unittests/Tooling/ToolingTest.cpp @@ -107,7 +107,7 @@ TEST(runToolOnCode, FindsClassDecl) { } TEST(buildASTFromCode, FindsClassDecl) { - OwningPtr AST(buildASTFromCode("class X;")); + std::unique_ptr AST(buildASTFromCode("class X;")); ASSERT_TRUE(AST.get()); EXPECT_TRUE(FindClassDeclX(AST.get())); @@ -117,9 +117,9 @@ TEST(buildASTFromCode, FindsClassDecl) { } TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromType) { - OwningPtr Factory( + std::unique_ptr Factory( newFrontendActionFactory()); - OwningPtr Action(Factory->create()); + std::unique_ptr Action(Factory->create()); EXPECT_TRUE(Action.get() != NULL); } @@ -131,9 +131,9 @@ struct IndependentFrontendActionCreator { TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromFactoryType) { IndependentFrontendActionCreator Creator; - OwningPtr Factory( + std::unique_ptr Factory( newFrontendActionFactory(&Creator)); - OwningPtr Action(Factory->create()); + std::unique_ptr Action(Factory->create()); EXPECT_TRUE(Action.get() != NULL); } -- cgit v1.2.3