summaryrefslogtreecommitdiff
path: root/unittests/ASTMatchers
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2014-06-08 08:38:12 +0000
committerCraig Topper <craig.topper@gmail.com>2014-06-08 08:38:12 +0000
commitb23b4992370221b27d64fa5b1da01a52aa271bef (patch)
tree9e75ef10ad41e4a485a12e26383248f7f6f0e3ed /unittests/ASTMatchers
parent085452490f953a5bb7b54827d99276029be1b6c6 (diff)
downloadclang-b23b4992370221b27d64fa5b1da01a52aa271bef.tar.gz
clang-b23b4992370221b27d64fa5b1da01a52aa271bef.tar.bz2
clang-b23b4992370221b27d64fa5b1da01a52aa271bef.tar.xz
[C++11] Use 'nullptr'. Unittests edition.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210423 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ASTMatchers')
-rw-r--r--unittests/ASTMatchers/ASTMatchersTest.cpp22
-rw-r--r--unittests/ASTMatchers/ASTMatchersTest.h6
-rw-r--r--unittests/ASTMatchers/Dynamic/RegistryTest.cpp9
3 files changed, 20 insertions, 17 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp
index bcdc10ab6c..03acfe3060 100644
--- a/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -44,14 +44,15 @@ TEST(IsDerivedFromDeathTest, DiesOnEmptyBaseName) {
TEST(Finder, DynamicOnlyAcceptsSomeMatchers) {
MatchFinder Finder;
- EXPECT_TRUE(Finder.addDynamicMatcher(decl(), NULL));
- EXPECT_TRUE(Finder.addDynamicMatcher(callExpr(), NULL));
- EXPECT_TRUE(Finder.addDynamicMatcher(constantArrayType(hasSize(42)), NULL));
+ EXPECT_TRUE(Finder.addDynamicMatcher(decl(), nullptr));
+ EXPECT_TRUE(Finder.addDynamicMatcher(callExpr(), nullptr));
+ EXPECT_TRUE(Finder.addDynamicMatcher(constantArrayType(hasSize(42)),
+ nullptr));
// Do not accept non-toplevel matchers.
- EXPECT_FALSE(Finder.addDynamicMatcher(isArrow(), NULL));
- EXPECT_FALSE(Finder.addDynamicMatcher(hasSize(2), NULL));
- EXPECT_FALSE(Finder.addDynamicMatcher(hasName("x"), NULL));
+ EXPECT_FALSE(Finder.addDynamicMatcher(isArrow(), nullptr));
+ EXPECT_FALSE(Finder.addDynamicMatcher(hasSize(2), nullptr));
+ EXPECT_FALSE(Finder.addDynamicMatcher(hasName("x"), nullptr));
}
TEST(Decl, MatchesDeclarations) {
@@ -697,7 +698,8 @@ public:
EXPECT_EQ(Nodes->getNodeAs<T>(Id), I->second.get<T>());
return true;
}
- EXPECT_TRUE(M.count(Id) == 0 || M.find(Id)->second.template get<T>() == 0);
+ EXPECT_TRUE(M.count(Id) == 0 ||
+ M.find(Id)->second.template get<T>() == nullptr);
return false;
}
@@ -4116,7 +4118,7 @@ public:
virtual bool run(const BoundNodes *Nodes, ASTContext *Context) {
const T *Node = Nodes->getNodeAs<T>(Id);
return selectFirst<const T>(InnerId,
- match(InnerMatcher, *Node, *Context)) != NULL;
+ match(InnerMatcher, *Node, *Context)) !=nullptr;
}
private:
std::string Id;
@@ -4176,7 +4178,7 @@ public:
return selectFirst<const T>(
"", match(stmt(hasParent(
stmt(has(stmt(equalsNode(TypedNode)))).bind(""))),
- *Node, Context)) != NULL;
+ *Node, Context)) != nullptr;
}
bool verify(const BoundNodes &Nodes, ASTContext &Context, const Decl *Node) {
// Use the original typed pointer to verify we can pass pointers to subtypes
@@ -4185,7 +4187,7 @@ public:
return selectFirst<const T>(
"", match(decl(hasParent(
decl(has(decl(equalsNode(TypedNode)))).bind(""))),
- *Node, Context)) != NULL;
+ *Node, Context)) != nullptr;
}
};
diff --git a/unittests/ASTMatchers/ASTMatchersTest.h b/unittests/ASTMatchers/ASTMatchersTest.h
index 8e243cf078..2e4ee2c5cb 100644
--- a/unittests/ASTMatchers/ASTMatchersTest.h
+++ b/unittests/ASTMatchers/ASTMatchersTest.h
@@ -40,7 +40,7 @@ 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;
@@ -64,9 +64,9 @@ testing::AssertionResult matchesConditionally(const std::string &Code,
llvm::StringRef CompileArg) {
bool Found = false, DynamicFound = false;
MatchFinder Finder;
- VerifyMatch VerifyFound(0, &Found);
+ VerifyMatch VerifyFound(nullptr, &Found);
Finder.addMatcher(AMatcher, &VerifyFound);
- VerifyMatch VerifyDynamicFound(0, &DynamicFound);
+ VerifyMatch VerifyDynamicFound(nullptr, &DynamicFound);
if (!Finder.addDynamicMatcher(AMatcher, &VerifyDynamicFound))
return testing::AssertionFailure() << "Could not add dynamic matcher";
std::unique_ptr<FrontendActionFactory> Factory(
diff --git a/unittests/ASTMatchers/Dynamic/RegistryTest.cpp b/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
index abacb6fe7d..5d5392492d 100644
--- a/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ b/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -40,7 +40,7 @@ public:
}
VariantMatcher constructMatcher(StringRef MatcherName,
- Diagnostics *Error = NULL) {
+ Diagnostics *Error = nullptr) {
Diagnostics DummyError;
if (!Error) Error = &DummyError;
llvm::Optional<MatcherCtor> Ctor = lookupMatcherCtor(MatcherName);
@@ -53,7 +53,7 @@ public:
VariantMatcher constructMatcher(StringRef MatcherName,
const VariantValue &Arg1,
- Diagnostics *Error = NULL) {
+ Diagnostics *Error = nullptr) {
Diagnostics DummyError;
if (!Error) Error = &DummyError;
llvm::Optional<MatcherCtor> Ctor = lookupMatcherCtor(MatcherName);
@@ -67,7 +67,7 @@ public:
VariantMatcher constructMatcher(StringRef MatcherName,
const VariantValue &Arg1,
const VariantValue &Arg2,
- Diagnostics *Error = NULL) {
+ Diagnostics *Error = nullptr) {
Diagnostics DummyError;
if (!Error) Error = &DummyError;
llvm::Optional<MatcherCtor> Ctor = lookupMatcherCtor(MatcherName);
@@ -110,7 +110,8 @@ public:
}
bool hasCompletion(const CompVector &Comps, StringRef TypedText,
- StringRef MatcherDecl = StringRef(), unsigned *Index = 0) {
+ StringRef MatcherDecl = StringRef(),
+ unsigned *Index = nullptr) {
for (CompVector::const_iterator I = Comps.begin(), E = Comps.end(); I != E;
++I) {
if (I->TypedText == TypedText &&