diff options
Diffstat (limited to 'unittests/ASTMatchers/ASTMatchersTest.h')
-rw-r--r-- | unittests/ASTMatchers/ASTMatchersTest.h | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersTest.h b/unittests/ASTMatchers/ASTMatchersTest.h index f5bcd37f112dc..2e4ee2c5cbe9e 100644 --- a/unittests/ASTMatchers/ASTMatchersTest.h +++ b/unittests/ASTMatchers/ASTMatchersTest.h @@ -40,14 +40,14 @@ public: : Verified(Verified), FindResultReviewer(FindResultVerifier) {} virtual void run(const MatchFinder::MatchResult &Result) { - if (FindResultReviewer != NULL) { + if (FindResultReviewer != nullptr) { *Verified |= FindResultReviewer->run(&Result.Nodes, Result.Context); } else { *Verified = true; } } - void onEndOfTranslationUnit() LLVM_OVERRIDE { + void onEndOfTranslationUnit() override { if (FindResultReviewer) FindResultReviewer->onEndOfTranslationUnit(); } @@ -64,10 +64,13 @@ testing::AssertionResult matchesConditionally(const std::string &Code, llvm::StringRef CompileArg) { bool Found = false, DynamicFound = false; MatchFinder Finder; - Finder.addMatcher(AMatcher, new VerifyMatch(0, &Found)); - if (!Finder.addDynamicMatcher(AMatcher, new VerifyMatch(0, &DynamicFound))) + VerifyMatch VerifyFound(nullptr, &Found); + Finder.addMatcher(AMatcher, &VerifyFound); + VerifyMatch VerifyDynamicFound(nullptr, &DynamicFound); + if (!Finder.addDynamicMatcher(AMatcher, &VerifyDynamicFound)) return testing::AssertionFailure() << "Could not add dynamic matcher"; - OwningPtr<FrontendActionFactory> Factory(newFrontendActionFactory(&Finder)); + std::unique_ptr<FrontendActionFactory> Factory( + newFrontendActionFactory(&Finder)); // Some tests use typeof, which is a gnu extension. std::vector<std::string> Args(1, CompileArg); if (!runToolOnCodeWithArgs(Factory->create(), Code, Args)) { @@ -105,12 +108,13 @@ testing::AssertionResult matchAndVerifyResultConditionally(const std::string &Code, const T &AMatcher, BoundNodesCallback *FindResultVerifier, bool ExpectResult) { - OwningPtr<BoundNodesCallback> ScopedVerifier(FindResultVerifier); + std::unique_ptr<BoundNodesCallback> ScopedVerifier(FindResultVerifier); bool VerifiedResult = false; MatchFinder Finder; - Finder.addMatcher( - AMatcher, new VerifyMatch(FindResultVerifier, &VerifiedResult)); - OwningPtr<FrontendActionFactory> Factory(newFrontendActionFactory(&Finder)); + VerifyMatch VerifyVerifiedResult(FindResultVerifier, &VerifiedResult); + Finder.addMatcher(AMatcher, &VerifyVerifiedResult); + std::unique_ptr<FrontendActionFactory> Factory( + newFrontendActionFactory(&Finder)); // Some tests use typeof, which is a gnu extension. std::vector<std::string> Args(1, "-std=gnu++98"); if (!runToolOnCodeWithArgs(Factory->create(), Code, Args)) { @@ -125,7 +129,7 @@ matchAndVerifyResultConditionally(const std::string &Code, const T &AMatcher, } VerifiedResult = false; - OwningPtr<ASTUnit> AST(buildASTFromCodeWithArgs(Code, Args)); + std::unique_ptr<ASTUnit> AST(buildASTFromCodeWithArgs(Code, Args)); if (!AST.get()) return testing::AssertionFailure() << "Parsing error in \"" << Code << "\" while building AST"; |