summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Tooling/ToolingTest.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-07-17 22:34:12 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-07-17 22:34:12 +0000
commit62a56f39b7c5587a1b2144880500689bea5f32e4 (patch)
treec6f21dd30c4dfd02f50e4ca54712b24f2022a6f4 /clang/unittests/Tooling/ToolingTest.cpp
parent5bae2c87d5946ee72ad31d88033ed5ecbd01ada2 (diff)
downloadbcm5719-llvm-62a56f39b7c5587a1b2144880500689bea5f32e4.tar.gz
bcm5719-llvm-62a56f39b7c5587a1b2144880500689bea5f32e4.zip
Revert "unique_ptr-ify ownership of ASTConsumers"
This reverts commit r213307. Reverting to have some on-list discussion/confirmation about the ongoing direction of smart pointer usage in the LLVM project. llvm-svn: 213325
Diffstat (limited to 'clang/unittests/Tooling/ToolingTest.cpp')
-rw-r--r--clang/unittests/Tooling/ToolingTest.cpp50
1 files changed, 22 insertions, 28 deletions
diff --git a/clang/unittests/Tooling/ToolingTest.cpp b/clang/unittests/Tooling/ToolingTest.cpp
index 85ab942387b..9aede044f69 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(std::unique_ptr<clang::ASTConsumer> TestConsumer)
- : TestConsumer(std::move(TestConsumer)) {}
+ explicit TestAction(clang::ASTConsumer *TestConsumer)
+ : TestConsumer(TestConsumer) {}
-protected:
- virtual std::unique_ptr<clang::ASTConsumer>
- CreateASTConsumer(clang::CompilerInstance &compiler, StringRef dummy) {
+ protected:
+ virtual clang::ASTConsumer* CreateASTConsumer(
+ clang::CompilerInstance& compiler, StringRef dummy) {
/// TestConsumer will be deleted by the framework calling us.
- return std::move(TestConsumer);
+ return TestConsumer;
}
-private:
- std::unique_ptr<clang::ASTConsumer> TestConsumer;
+ private:
+ clang::ASTConsumer * const TestConsumer;
};
class FindTopLevelDeclConsumer : public clang::ASTConsumer {
@@ -59,10 +59,8 @@ class FindTopLevelDeclConsumer : public clang::ASTConsumer {
TEST(runToolOnCode, FindsNoTopLevelDeclOnEmptyCode) {
bool FoundTopLevelDecl = false;
- EXPECT_TRUE(
- runToolOnCode(new TestAction(llvm::make_unique<FindTopLevelDeclConsumer>(
- &FoundTopLevelDecl)),
- ""));
+ EXPECT_TRUE(runToolOnCode(
+ new TestAction(new FindTopLevelDeclConsumer(&FoundTopLevelDecl)), ""));
EXPECT_FALSE(FoundTopLevelDecl);
}
@@ -99,17 +97,13 @@ bool FindClassDeclX(ASTUnit *AST) {
TEST(runToolOnCode, FindsClassDecl) {
bool FoundClassDeclX = false;
- EXPECT_TRUE(
- runToolOnCode(new TestAction(llvm::make_unique<FindClassDeclXConsumer>(
- &FoundClassDeclX)),
- "class X;"));
+ EXPECT_TRUE(runToolOnCode(new TestAction(
+ new FindClassDeclXConsumer(&FoundClassDeclX)), "class X;"));
EXPECT_TRUE(FoundClassDeclX);
FoundClassDeclX = false;
- EXPECT_TRUE(
- runToolOnCode(new TestAction(llvm::make_unique<FindClassDeclXConsumer>(
- &FoundClassDeclX)),
- "class Y;"));
+ EXPECT_TRUE(runToolOnCode(new TestAction(
+ new FindClassDeclXConsumer(&FoundClassDeclX)), "class Y;"));
EXPECT_FALSE(FoundClassDeclX);
}
@@ -131,8 +125,8 @@ TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromType) {
}
struct IndependentFrontendActionCreator {
- std::unique_ptr<ASTConsumer> newASTConsumer() {
- return llvm::make_unique<FindTopLevelDeclConsumer>(nullptr);
+ ASTConsumer *newASTConsumer() {
+ return new FindTopLevelDeclConsumer(nullptr);
}
};
@@ -191,8 +185,8 @@ struct VerifyEndCallback : public SourceFileCallbacks {
virtual void handleEndSource() {
++EndCalled;
}
- std::unique_ptr<ASTConsumer> newASTConsumer() {
- return llvm::make_unique<FindTopLevelDeclConsumer>(&Matched);
+ ASTConsumer *newASTConsumer() {
+ return new FindTopLevelDeclConsumer(&Matched);
}
unsigned BeginCalled;
unsigned EndCalled;
@@ -231,10 +225,10 @@ struct SkipBodyConsumer : public clang::ASTConsumer {
};
struct SkipBodyAction : public clang::ASTFrontendAction {
- virtual std::unique_ptr<ASTConsumer>
- CreateASTConsumer(CompilerInstance &Compiler, StringRef) {
+ virtual ASTConsumer *CreateASTConsumer(CompilerInstance &Compiler,
+ StringRef) {
Compiler.getFrontendOpts().SkipFunctionBodies = true;
- return llvm::make_unique<SkipBodyConsumer>();
+ return new SkipBodyConsumer;
}
};
OpenPOWER on IntegriCloud