aboutsummaryrefslogtreecommitdiff
path: root/unittests
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
commit80bfbba822da41b74969be8e635b1b4c8e2d3a8c (patch)
tree9c04bec373a4ad6b3b51026b7879cf93a535158d /unittests
parent9a8dc2497021b3758e1c521c75f0c716da3ca0d4 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213325 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/AST/EvaluateAsRValueTest.cpp7
-rw-r--r--unittests/AST/ExternalASTSourceTest.cpp6
-rw-r--r--unittests/AST/NamedDeclPrinterTest.cpp4
-rw-r--r--unittests/Frontend/FrontendActionTest.cpp6
-rw-r--r--unittests/Sema/ExternalSemaSourceTest.cpp4
-rw-r--r--unittests/Tooling/RefactoringTest.cpp7
-rw-r--r--unittests/Tooling/TestVisitor.h6
-rw-r--r--unittests/Tooling/ToolingTest.cpp50
8 files changed, 41 insertions, 49 deletions
diff --git a/unittests/AST/EvaluateAsRValueTest.cpp b/unittests/AST/EvaluateAsRValueTest.cpp
index b5f9b32740..9120c936ed 100644
--- a/unittests/AST/EvaluateAsRValueTest.cpp
+++ b/unittests/AST/EvaluateAsRValueTest.cpp
@@ -59,10 +59,9 @@ class EvaluateConstantInitializersVisitor
class EvaluateConstantInitializersAction : public clang::ASTFrontendAction {
public:
- std::unique_ptr<clang::ASTConsumer>
- CreateASTConsumer(clang::CompilerInstance &Compiler,
- llvm::StringRef FilePath) override {
- return llvm::make_unique<Consumer>();
+ clang::ASTConsumer *CreateASTConsumer(clang::CompilerInstance &Compiler,
+ llvm::StringRef FilePath) override {
+ return new Consumer;
}
private:
diff --git a/unittests/AST/ExternalASTSourceTest.cpp b/unittests/AST/ExternalASTSourceTest.cpp
index 6a5db6c1dd..5cc2defe20 100644
--- a/unittests/AST/ExternalASTSourceTest.cpp
+++ b/unittests/AST/ExternalASTSourceTest.cpp
@@ -35,9 +35,9 @@ private:
return ASTFrontendAction::ExecuteAction();
}
- virtual std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
- StringRef InFile) {
- return llvm::make_unique<ASTConsumer>();
+ virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
+ StringRef InFile) {
+ return new ASTConsumer;
}
IntrusiveRefCntPtr<ExternalASTSource> Source;
diff --git a/unittests/AST/NamedDeclPrinterTest.cpp b/unittests/AST/NamedDeclPrinterTest.cpp
index f8fb98454b..4823b44862 100644
--- a/unittests/AST/NamedDeclPrinterTest.cpp
+++ b/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/unittests/Frontend/FrontendActionTest.cpp b/unittests/Frontend/FrontendActionTest.cpp
index 48bc07286e..e39d00f6af 100644
--- a/unittests/Frontend/FrontendActionTest.cpp
+++ b/unittests/Frontend/FrontendActionTest.cpp
@@ -38,9 +38,9 @@ public:
return ASTFrontendAction::BeginSourceFileAction(ci, filename);
}
- virtual std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
- StringRef InFile) {
- return llvm::make_unique<Visitor>(decl_names);
+ virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
+ StringRef InFile) {
+ return new Visitor(decl_names);
}
private:
diff --git a/unittests/Sema/ExternalSemaSourceTest.cpp b/unittests/Sema/ExternalSemaSourceTest.cpp
index 4291b76e7d..bc0d632cfd 100644
--- a/unittests/Sema/ExternalSemaSourceTest.cpp
+++ b/unittests/Sema/ExternalSemaSourceTest.cpp
@@ -140,10 +140,10 @@ class ExternalSemaSourceInstaller : public clang::ASTFrontendAction {
std::unique_ptr<DiagnosticConsumer> OwnedClient;
protected:
- virtual std::unique_ptr<clang::ASTConsumer>
+ virtual clang::ASTConsumer *
CreateASTConsumer(clang::CompilerInstance &Compiler,
llvm::StringRef /* dummy */) {
- return llvm::make_unique<clang::ASTConsumer>();
+ return new clang::ASTConsumer();
}
virtual void ExecuteAction() {
diff --git a/unittests/Tooling/RefactoringTest.cpp b/unittests/Tooling/RefactoringTest.cpp
index 3e067dd3f9..ddb974ac9f 100644
--- a/unittests/Tooling/RefactoringTest.cpp
+++ b/unittests/Tooling/RefactoringTest.cpp
@@ -299,12 +299,11 @@ private:
public:
TestAction(TestVisitor *Visitor) : Visitor(Visitor) {}
- virtual std::unique_ptr<clang::ASTConsumer>
- CreateASTConsumer(clang::CompilerInstance &compiler,
- llvm::StringRef dummy) {
+ virtual clang::ASTConsumer* CreateASTConsumer(
+ clang::CompilerInstance& compiler, llvm::StringRef dummy) {
Visitor->SM = &compiler.getSourceManager();
/// TestConsumer will be deleted by the framework calling us.
- return llvm::make_unique<FindConsumer>(Visitor);
+ return new FindConsumer(Visitor);
}
private:
diff --git a/unittests/Tooling/TestVisitor.h b/unittests/Tooling/TestVisitor.h
index 23ea754d39..205a0aa16e 100644
--- a/unittests/Tooling/TestVisitor.h
+++ b/unittests/Tooling/TestVisitor.h
@@ -95,10 +95,10 @@ protected:
public:
TestAction(TestVisitor *Visitor) : Visitor(Visitor) {}
- virtual std::unique_ptr<clang::ASTConsumer>
- CreateASTConsumer(CompilerInstance &, llvm::StringRef dummy) {
+ virtual clang::ASTConsumer* CreateASTConsumer(
+ CompilerInstance&, llvm::StringRef dummy) {
/// TestConsumer will be deleted by the framework calling us.
- return llvm::make_unique<FindConsumer>(Visitor);
+ return new FindConsumer(Visitor);
}
protected:
diff --git a/unittests/Tooling/ToolingTest.cpp b/unittests/Tooling/ToolingTest.cpp
index 85ab942387..9aede044f6 100644
--- a/unittests/Tooling/ToolingTest.cpp
+++ b/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;
}
};