diff options
Diffstat (limited to 'clang/unittests/Tooling')
-rw-r--r-- | clang/unittests/Tooling/CommentHandlerTest.cpp | 4 | ||||
-rw-r--r-- | clang/unittests/Tooling/ExecutionTest.cpp | 4 | ||||
-rw-r--r-- | clang/unittests/Tooling/RefactoringTest.cpp | 2 | ||||
-rw-r--r-- | clang/unittests/Tooling/TestVisitor.h | 4 | ||||
-rw-r--r-- | clang/unittests/Tooling/ToolingTest.cpp | 111 |
5 files changed, 58 insertions, 67 deletions
diff --git a/clang/unittests/Tooling/CommentHandlerTest.cpp b/clang/unittests/Tooling/CommentHandlerTest.cpp index 682f19e9b13..9c3abdc4b15 100644 --- a/clang/unittests/Tooling/CommentHandlerTest.cpp +++ b/clang/unittests/Tooling/CommentHandlerTest.cpp @@ -56,8 +56,8 @@ public: CommentVerifier GetVerifier(); protected: - std::unique_ptr<FrontendAction> CreateTestAction() override { - return llvm::make_unique<CommentHandlerAction>(this); + ASTFrontendAction *CreateTestAction() override { + return new CommentHandlerAction(this); } private: diff --git a/clang/unittests/Tooling/ExecutionTest.cpp b/clang/unittests/Tooling/ExecutionTest.cpp index 19e5de7823c..26db8c6d0ea 100644 --- a/clang/unittests/Tooling/ExecutionTest.cpp +++ b/clang/unittests/Tooling/ExecutionTest.cpp @@ -79,9 +79,7 @@ private: class ReportResultActionFactory : public FrontendActionFactory { public: ReportResultActionFactory(ExecutionContext *Context) : Context(Context) {} - std::unique_ptr<FrontendAction> create() override { - return llvm::make_unique<ReportResultAction>(Context); - } + FrontendAction *create() override { return new ReportResultAction(Context); } private: ExecutionContext *const Context; diff --git a/clang/unittests/Tooling/RefactoringTest.cpp b/clang/unittests/Tooling/RefactoringTest.cpp index d9d82eb43fa..41836f11ee2 100644 --- a/clang/unittests/Tooling/RefactoringTest.cpp +++ b/clang/unittests/Tooling/RefactoringTest.cpp @@ -650,7 +650,7 @@ template <typename T> class TestVisitor : public clang::RecursiveASTVisitor<T> { public: bool runOver(StringRef Code) { - return runToolOnCode(llvm::make_unique<TestAction>(this), Code); + return runToolOnCode(new TestAction(this), Code); } protected: diff --git a/clang/unittests/Tooling/TestVisitor.h b/clang/unittests/Tooling/TestVisitor.h index acaaabfac71..fb6a76ccadd 100644 --- a/clang/unittests/Tooling/TestVisitor.h +++ b/clang/unittests/Tooling/TestVisitor.h @@ -82,8 +82,8 @@ public: } protected: - virtual std::unique_ptr<FrontendAction> CreateTestAction() { - return llvm::make_unique<TestAction>(this); + virtual ASTFrontendAction* CreateTestAction() { + return new TestAction(this); } class FindConsumer : public ASTConsumer { diff --git a/clang/unittests/Tooling/ToolingTest.cpp b/clang/unittests/Tooling/ToolingTest.cpp index a4fb579038b..6dd0e53c4dd 100644 --- a/clang/unittests/Tooling/ToolingTest.cpp +++ b/clang/unittests/Tooling/ToolingTest.cpp @@ -64,10 +64,10 @@ class FindTopLevelDeclConsumer : public clang::ASTConsumer { TEST(runToolOnCode, FindsNoTopLevelDeclOnEmptyCode) { bool FoundTopLevelDecl = false; - EXPECT_TRUE(runToolOnCode( - llvm::make_unique<TestAction>( - llvm::make_unique<FindTopLevelDeclConsumer>(&FoundTopLevelDecl)), - "")); + EXPECT_TRUE( + runToolOnCode(new TestAction(llvm::make_unique<FindTopLevelDeclConsumer>( + &FoundTopLevelDecl)), + "")); EXPECT_FALSE(FoundTopLevelDecl); } @@ -104,17 +104,17 @@ bool FindClassDeclX(ASTUnit *AST) { TEST(runToolOnCode, FindsClassDecl) { bool FoundClassDeclX = false; - EXPECT_TRUE(runToolOnCode( - llvm::make_unique<TestAction>( - llvm::make_unique<FindClassDeclXConsumer>(&FoundClassDeclX)), - "class X;")); + EXPECT_TRUE( + runToolOnCode(new TestAction(llvm::make_unique<FindClassDeclXConsumer>( + &FoundClassDeclX)), + "class X;")); EXPECT_TRUE(FoundClassDeclX); FoundClassDeclX = false; - EXPECT_TRUE(runToolOnCode( - llvm::make_unique<TestAction>( - llvm::make_unique<FindClassDeclXConsumer>(&FoundClassDeclX)), - "class Y;")); + EXPECT_TRUE( + runToolOnCode(new TestAction(llvm::make_unique<FindClassDeclXConsumer>( + &FoundClassDeclX)), + "class Y;")); EXPECT_FALSE(FoundClassDeclX); } @@ -162,8 +162,8 @@ TEST(ToolInvocation, TestMapVirtualFile) { Args.push_back("-Idef"); Args.push_back("-fsyntax-only"); Args.push_back("test.cpp"); - clang::tooling::ToolInvocation Invocation( - Args, llvm::make_unique<SyntaxOnlyAction>(), Files.get()); + clang::tooling::ToolInvocation Invocation(Args, new SyntaxOnlyAction, + Files.get()); InMemoryFileSystem->addFile( "test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("#include <abc>\n")); InMemoryFileSystem->addFile("def/abc", 0, @@ -188,8 +188,8 @@ TEST(ToolInvocation, TestVirtualModulesCompilation) { Args.push_back("-Idef"); Args.push_back("-fsyntax-only"); Args.push_back("test.cpp"); - clang::tooling::ToolInvocation Invocation( - Args, llvm::make_unique<SyntaxOnlyAction>(), Files.get()); + clang::tooling::ToolInvocation Invocation(Args, new SyntaxOnlyAction, + Files.get()); InMemoryFileSystem->addFile( "test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("#include <abc>\n")); InMemoryFileSystem->addFile("def/abc", 0, @@ -259,64 +259,61 @@ TEST(runToolOnCode, TestSkipFunctionBody) { std::vector<std::string> Args = {"-std=c++11"}; std::vector<std::string> Args2 = {"-fno-delayed-template-parsing"}; - EXPECT_TRUE(runToolOnCode(llvm::make_unique<SkipBodyAction>(), + EXPECT_TRUE(runToolOnCode(new SkipBodyAction, "int skipMe() { an_error_here }")); - EXPECT_FALSE(runToolOnCode(llvm::make_unique<SkipBodyAction>(), + EXPECT_FALSE(runToolOnCode(new SkipBodyAction, "int skipMeNot() { an_error_here }")); // Test constructors with initializers EXPECT_TRUE(runToolOnCodeWithArgs( - llvm::make_unique<SkipBodyAction>(), + new SkipBodyAction, "struct skipMe { skipMe() : an_error() { more error } };", Args)); EXPECT_TRUE(runToolOnCodeWithArgs( - llvm::make_unique<SkipBodyAction>(), - "struct skipMe { skipMe(); };" - "skipMe::skipMe() : an_error([](){;}) { more error }", + new SkipBodyAction, "struct skipMe { skipMe(); };" + "skipMe::skipMe() : an_error([](){;}) { more error }", Args)); EXPECT_TRUE(runToolOnCodeWithArgs( - llvm::make_unique<SkipBodyAction>(), - "struct skipMe { skipMe(); };" - "skipMe::skipMe() : an_error{[](){;}} { more error }", + new SkipBodyAction, "struct skipMe { skipMe(); };" + "skipMe::skipMe() : an_error{[](){;}} { more error }", Args)); EXPECT_TRUE(runToolOnCodeWithArgs( - llvm::make_unique<SkipBodyAction>(), + new SkipBodyAction, "struct skipMe { skipMe(); };" "skipMe::skipMe() : a<b<c>(e)>>(), f{}, g() { error }", Args)); EXPECT_TRUE(runToolOnCodeWithArgs( - llvm::make_unique<SkipBodyAction>(), - "struct skipMe { skipMe() : bases()... { error } };", Args)); + new SkipBodyAction, "struct skipMe { skipMe() : bases()... { error } };", + Args)); EXPECT_FALSE(runToolOnCodeWithArgs( - llvm::make_unique<SkipBodyAction>(), - "struct skipMeNot { skipMeNot() : an_error() { } };", Args)); - EXPECT_FALSE(runToolOnCodeWithArgs(llvm::make_unique<SkipBodyAction>(), + new SkipBodyAction, "struct skipMeNot { skipMeNot() : an_error() { } };", + Args)); + EXPECT_FALSE(runToolOnCodeWithArgs(new SkipBodyAction, "struct skipMeNot { skipMeNot(); };" "skipMeNot::skipMeNot() : an_error() { }", Args)); // Try/catch EXPECT_TRUE(runToolOnCode( - llvm::make_unique<SkipBodyAction>(), + new SkipBodyAction, "void skipMe() try { an_error() } catch(error) { error };")); EXPECT_TRUE(runToolOnCode( - llvm::make_unique<SkipBodyAction>(), + new SkipBodyAction, "struct S { void skipMe() try { an_error() } catch(error) { error } };")); EXPECT_TRUE( - runToolOnCode(llvm::make_unique<SkipBodyAction>(), + runToolOnCode(new SkipBodyAction, "void skipMe() try { an_error() } catch(error) { error; }" "catch(error) { error } catch (error) { }")); EXPECT_FALSE(runToolOnCode( - llvm::make_unique<SkipBodyAction>(), + new SkipBodyAction, "void skipMe() try something;")); // don't crash while parsing // Template - EXPECT_TRUE( - runToolOnCode(llvm::make_unique<SkipBodyAction>(), - "template<typename T> int skipMe() { an_error_here }" - "int x = skipMe<int>();")); + EXPECT_TRUE(runToolOnCode( + new SkipBodyAction, "template<typename T> int skipMe() { an_error_here }" + "int x = skipMe<int>();")); EXPECT_FALSE(runToolOnCodeWithArgs( - llvm::make_unique<SkipBodyAction>(), + new SkipBodyAction, "template<typename T> int skipMeNot() { an_error_here }", Args2)); } @@ -330,8 +327,7 @@ TEST(runToolOnCodeWithArgs, TestNoDepFile) { Args.push_back(DepFilePath.str()); Args.push_back("-MF"); Args.push_back(DepFilePath.str()); - EXPECT_TRUE( - runToolOnCodeWithArgs(llvm::make_unique<SkipBodyAction>(), "", Args)); + EXPECT_TRUE(runToolOnCodeWithArgs(new SkipBodyAction, "", Args)); EXPECT_FALSE(llvm::sys::fs::exists(DepFilePath.str())); EXPECT_FALSE(llvm::sys::fs::remove(DepFilePath.str())); } @@ -355,26 +351,23 @@ private: TEST(runToolOnCodeWithArgs, DiagnosticsColor) { + EXPECT_TRUE(runToolOnCodeWithArgs(new CheckColoredDiagnosticsAction(true), "", + {"-fcolor-diagnostics"})); + EXPECT_TRUE(runToolOnCodeWithArgs(new CheckColoredDiagnosticsAction(false), + "", {"-fno-color-diagnostics"})); + EXPECT_TRUE( + runToolOnCodeWithArgs(new CheckColoredDiagnosticsAction(true), "", + {"-fno-color-diagnostics", "-fcolor-diagnostics"})); + EXPECT_TRUE( + runToolOnCodeWithArgs(new CheckColoredDiagnosticsAction(false), "", + {"-fcolor-diagnostics", "-fno-color-diagnostics"})); EXPECT_TRUE(runToolOnCodeWithArgs( - llvm::make_unique<CheckColoredDiagnosticsAction>(true), "", - {"-fcolor-diagnostics"})); - EXPECT_TRUE(runToolOnCodeWithArgs( - llvm::make_unique<CheckColoredDiagnosticsAction>(false), "", - {"-fno-color-diagnostics"})); - EXPECT_TRUE(runToolOnCodeWithArgs( - llvm::make_unique<CheckColoredDiagnosticsAction>(true), "", - {"-fno-color-diagnostics", "-fcolor-diagnostics"})); - EXPECT_TRUE(runToolOnCodeWithArgs( - llvm::make_unique<CheckColoredDiagnosticsAction>(false), "", - {"-fcolor-diagnostics", "-fno-color-diagnostics"})); - EXPECT_TRUE(runToolOnCodeWithArgs( - llvm::make_unique<CheckColoredDiagnosticsAction>(true), "", + new CheckColoredDiagnosticsAction(true), "", {"-fno-color-diagnostics", "-fdiagnostics-color=always"})); // Check that this test would fail if ShowColors is not what it should. - EXPECT_FALSE(runToolOnCodeWithArgs( - llvm::make_unique<CheckColoredDiagnosticsAction>(false), "", - {"-fcolor-diagnostics"})); + EXPECT_FALSE(runToolOnCodeWithArgs(new CheckColoredDiagnosticsAction(false), + "", {"-fcolor-diagnostics"})); } TEST(ClangToolTest, ArgumentAdjusters) { @@ -610,7 +603,7 @@ TEST(runToolOnCode, TestResetDiagnostics) { // Should not crash EXPECT_FALSE( - runToolOnCode(llvm::make_unique<ResetDiagnosticAction>(), + runToolOnCode(new ResetDiagnosticAction, "struct Foo { Foo(int); ~Foo(); struct Fwd _fwd; };" "void func() { long x; Foo f(x); }")); } |