diff options
Diffstat (limited to 'clang/unittests')
| -rw-r--r-- | clang/unittests/AST/EvaluateAsRValueTest.cpp | 7 | ||||
| -rw-r--r-- | clang/unittests/AST/ExternalASTSourceTest.cpp | 6 | ||||
| -rw-r--r-- | clang/unittests/AST/NamedDeclPrinterTest.cpp | 4 | ||||
| -rw-r--r-- | clang/unittests/Frontend/FrontendActionTest.cpp | 6 | ||||
| -rw-r--r-- | clang/unittests/Sema/ExternalSemaSourceTest.cpp | 4 | ||||
| -rw-r--r-- | clang/unittests/Tooling/RefactoringTest.cpp | 7 | ||||
| -rw-r--r-- | clang/unittests/Tooling/TestVisitor.h | 6 | ||||
| -rw-r--r-- | clang/unittests/Tooling/ToolingTest.cpp | 50 |
8 files changed, 49 insertions, 41 deletions
diff --git a/clang/unittests/AST/EvaluateAsRValueTest.cpp b/clang/unittests/AST/EvaluateAsRValueTest.cpp index 9120c936ed1..b5f9b32740f 100644 --- a/clang/unittests/AST/EvaluateAsRValueTest.cpp +++ b/clang/unittests/AST/EvaluateAsRValueTest.cpp @@ -59,9 +59,10 @@ class EvaluateConstantInitializersVisitor class EvaluateConstantInitializersAction : public clang::ASTFrontendAction { public: - clang::ASTConsumer *CreateASTConsumer(clang::CompilerInstance &Compiler, - llvm::StringRef FilePath) override { - return new Consumer; + std::unique_ptr<clang::ASTConsumer> + CreateASTConsumer(clang::CompilerInstance &Compiler, + llvm::StringRef FilePath) override { + return llvm::make_unique<Consumer>(); } private: diff --git a/clang/unittests/AST/ExternalASTSourceTest.cpp b/clang/unittests/AST/ExternalASTSourceTest.cpp index 5cc2defe20f..6a5db6c1dd3 100644 --- a/clang/unittests/AST/ExternalASTSourceTest.cpp +++ b/clang/unittests/AST/ExternalASTSourceTest.cpp @@ -35,9 +35,9 @@ private: return ASTFrontendAction::ExecuteAction(); } - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - StringRef InFile) { - return new ASTConsumer; + virtual std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) { + return llvm::make_unique<ASTConsumer>(); } IntrusiveRefCntPtr<ExternalASTSource> Source; diff --git a/clang/unittests/AST/NamedDeclPrinterTest.cpp b/clang/unittests/AST/NamedDeclPrinterTest.cpp index 4823b44862e..f8fb98454bd 100644 --- a/clang/unittests/AST/NamedDeclPrinterTest.cpp +++ b/clang/unittests/AST/NamedDeclPrinterTest.cpp @@ -68,8 +68,8 @@ PrintedNamedDeclMatches(StringRef Code, const std::vector<std::string> &Args, PrintMatch Printer(SuppressUnwrittenScope); MatchFinder Finder; Finder.addMatcher(NodeMatch, &Printer); - std::unique_ptr<FrontendActionFactory> Factory( - newFrontendActionFactory(&Finder)); + std::unique_ptr<FrontendActionFactory> Factory = + newFrontendActionFactory(&Finder); if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, FileName)) return testing::AssertionFailure() diff --git a/clang/unittests/Frontend/FrontendActionTest.cpp b/clang/unittests/Frontend/FrontendActionTest.cpp index 44843eed137..cb9cc527258 100644 --- a/clang/unittests/Frontend/FrontendActionTest.cpp +++ b/clang/unittests/Frontend/FrontendActionTest.cpp @@ -38,9 +38,9 @@ public: return ASTFrontendAction::BeginSourceFileAction(ci, filename); } - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - StringRef InFile) { - return new Visitor(decl_names); + virtual std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) { + return llvm::make_unique<Visitor>(decl_names); } private: diff --git a/clang/unittests/Sema/ExternalSemaSourceTest.cpp b/clang/unittests/Sema/ExternalSemaSourceTest.cpp index bc0d632cfdb..4291b76e7d4 100644 --- a/clang/unittests/Sema/ExternalSemaSourceTest.cpp +++ b/clang/unittests/Sema/ExternalSemaSourceTest.cpp @@ -140,10 +140,10 @@ class ExternalSemaSourceInstaller : public clang::ASTFrontendAction { std::unique_ptr<DiagnosticConsumer> OwnedClient; protected: - virtual clang::ASTConsumer * + virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance &Compiler, llvm::StringRef /* dummy */) { - return new clang::ASTConsumer(); + return llvm::make_unique<clang::ASTConsumer>(); } virtual void ExecuteAction() { diff --git a/clang/unittests/Tooling/RefactoringTest.cpp b/clang/unittests/Tooling/RefactoringTest.cpp index ddb974ac9f4..3e067dd3f99 100644 --- a/clang/unittests/Tooling/RefactoringTest.cpp +++ b/clang/unittests/Tooling/RefactoringTest.cpp @@ -299,11 +299,12 @@ private: public: TestAction(TestVisitor *Visitor) : Visitor(Visitor) {} - virtual clang::ASTConsumer* CreateASTConsumer( - clang::CompilerInstance& compiler, llvm::StringRef dummy) { + virtual std::unique_ptr<clang::ASTConsumer> + CreateASTConsumer(clang::CompilerInstance &compiler, + llvm::StringRef dummy) { Visitor->SM = &compiler.getSourceManager(); /// TestConsumer will be deleted by the framework calling us. - return new FindConsumer(Visitor); + return llvm::make_unique<FindConsumer>(Visitor); } private: diff --git a/clang/unittests/Tooling/TestVisitor.h b/clang/unittests/Tooling/TestVisitor.h index 205a0aa16eb..23ea754d39a 100644 --- a/clang/unittests/Tooling/TestVisitor.h +++ b/clang/unittests/Tooling/TestVisitor.h @@ -95,10 +95,10 @@ protected: public: TestAction(TestVisitor *Visitor) : Visitor(Visitor) {} - virtual clang::ASTConsumer* CreateASTConsumer( - CompilerInstance&, llvm::StringRef dummy) { + virtual std::unique_ptr<clang::ASTConsumer> + CreateASTConsumer(CompilerInstance &, llvm::StringRef dummy) { /// TestConsumer will be deleted by the framework calling us. - return new FindConsumer(Visitor); + return llvm::make_unique<FindConsumer>(Visitor); } protected: diff --git a/clang/unittests/Tooling/ToolingTest.cpp b/clang/unittests/Tooling/ToolingTest.cpp index 9aede044f69..85ab942387b 100644 --- a/clang/unittests/Tooling/ToolingTest.cpp +++ b/clang/unittests/Tooling/ToolingTest.cpp @@ -28,20 +28,20 @@ namespace { /// Takes an ast consumer and returns it from CreateASTConsumer. This only /// works with single translation unit compilations. class TestAction : public clang::ASTFrontendAction { - public: +public: /// Takes ownership of TestConsumer. - explicit TestAction(clang::ASTConsumer *TestConsumer) - : TestConsumer(TestConsumer) {} + explicit TestAction(std::unique_ptr<clang::ASTConsumer> TestConsumer) + : TestConsumer(std::move(TestConsumer)) {} - protected: - virtual clang::ASTConsumer* CreateASTConsumer( - clang::CompilerInstance& compiler, StringRef dummy) { +protected: + virtual std::unique_ptr<clang::ASTConsumer> + CreateASTConsumer(clang::CompilerInstance &compiler, StringRef dummy) { /// TestConsumer will be deleted by the framework calling us. - return TestConsumer; + return std::move(TestConsumer); } - private: - clang::ASTConsumer * const TestConsumer; +private: + std::unique_ptr<clang::ASTConsumer> TestConsumer; }; class FindTopLevelDeclConsumer : public clang::ASTConsumer { @@ -59,8 +59,10 @@ class FindTopLevelDeclConsumer : public clang::ASTConsumer { TEST(runToolOnCode, FindsNoTopLevelDeclOnEmptyCode) { bool FoundTopLevelDecl = false; - EXPECT_TRUE(runToolOnCode( - new TestAction(new FindTopLevelDeclConsumer(&FoundTopLevelDecl)), "")); + EXPECT_TRUE( + runToolOnCode(new TestAction(llvm::make_unique<FindTopLevelDeclConsumer>( + &FoundTopLevelDecl)), + "")); EXPECT_FALSE(FoundTopLevelDecl); } @@ -97,13 +99,17 @@ bool FindClassDeclX(ASTUnit *AST) { TEST(runToolOnCode, FindsClassDecl) { bool FoundClassDeclX = false; - EXPECT_TRUE(runToolOnCode(new TestAction( - new FindClassDeclXConsumer(&FoundClassDeclX)), "class X;")); + EXPECT_TRUE( + runToolOnCode(new TestAction(llvm::make_unique<FindClassDeclXConsumer>( + &FoundClassDeclX)), + "class X;")); EXPECT_TRUE(FoundClassDeclX); FoundClassDeclX = false; - EXPECT_TRUE(runToolOnCode(new TestAction( - new FindClassDeclXConsumer(&FoundClassDeclX)), "class Y;")); + EXPECT_TRUE( + runToolOnCode(new TestAction(llvm::make_unique<FindClassDeclXConsumer>( + &FoundClassDeclX)), + "class Y;")); EXPECT_FALSE(FoundClassDeclX); } @@ -125,8 +131,8 @@ TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromType) { } struct IndependentFrontendActionCreator { - ASTConsumer *newASTConsumer() { - return new FindTopLevelDeclConsumer(nullptr); + std::unique_ptr<ASTConsumer> newASTConsumer() { + return llvm::make_unique<FindTopLevelDeclConsumer>(nullptr); } }; @@ -185,8 +191,8 @@ struct VerifyEndCallback : public SourceFileCallbacks { virtual void handleEndSource() { ++EndCalled; } - ASTConsumer *newASTConsumer() { - return new FindTopLevelDeclConsumer(&Matched); + std::unique_ptr<ASTConsumer> newASTConsumer() { + return llvm::make_unique<FindTopLevelDeclConsumer>(&Matched); } unsigned BeginCalled; unsigned EndCalled; @@ -225,10 +231,10 @@ struct SkipBodyConsumer : public clang::ASTConsumer { }; struct SkipBodyAction : public clang::ASTFrontendAction { - virtual ASTConsumer *CreateASTConsumer(CompilerInstance &Compiler, - StringRef) { + virtual std::unique_ptr<ASTConsumer> + CreateASTConsumer(CompilerInstance &Compiler, StringRef) { Compiler.getFrontendOpts().SkipFunctionBodies = true; - return new SkipBodyConsumer; + return llvm::make_unique<SkipBodyConsumer>(); } }; |

