Update Clang for rebase to r212749.
This also fixes a small issue with arm_neon.h not being generated always.
Includes a cherry-pick of:
r213450 - fixes mac-specific header issue
r213126 - removes a default -Bsymbolic on Android
Change-Id: I2a790a0f5d3b2aab11de596fc3a74e7cbc99081d
diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp
index 691719c..e424acd 100644
--- a/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -44,14 +44,15 @@
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 @@
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;
}
@@ -1015,6 +1017,17 @@
forRangeStmt()));
}
+TEST(Matcher, SubstNonTypeTemplateParm) {
+ EXPECT_FALSE(matches("template<int N>\n"
+ "struct A { static const int n = 0; };\n"
+ "struct B : public A<42> {};",
+ substNonTypeTemplateParmExpr()));
+ EXPECT_TRUE(matches("template<int N>\n"
+ "struct A { static const int n = N; };\n"
+ "struct B : public A<42> {};",
+ substNonTypeTemplateParmExpr()));
+}
+
TEST(Matcher, UserDefinedLiteral) {
EXPECT_TRUE(matches("constexpr char operator \"\" _inc (const char i) {"
" return i + 1;"
@@ -1165,6 +1178,18 @@
"}", Reference));
}
+TEST(Matcher, VarDecl_Storage) {
+ auto M = varDecl(hasName("X"), hasLocalStorage());
+ EXPECT_TRUE(matches("void f() { int X; }", M));
+ EXPECT_TRUE(notMatches("int X;", M));
+ EXPECT_TRUE(notMatches("void f() { static int X; }", M));
+
+ M = varDecl(hasName("X"), hasGlobalStorage());
+ EXPECT_TRUE(notMatches("void f() { int X; }", M));
+ EXPECT_TRUE(matches("int X;", M));
+ EXPECT_TRUE(matches("void f() { static int X; }", M));
+}
+
TEST(Matcher, FindsVarDeclInFunctionParameter) {
EXPECT_TRUE(matches(
"void f(int i) {}",
@@ -3609,6 +3634,27 @@
compoundStmt(hasParent(recordDecl()))));
}
+TEST(HasParent, NoDuplicateParents) {
+ class HasDuplicateParents : public BoundNodesCallback {
+ public:
+ bool run(const BoundNodes *Nodes) override { return false; }
+ bool run(const BoundNodes *Nodes, ASTContext *Context) override {
+ const Stmt *Node = Nodes->getNodeAs<Stmt>("node");
+ std::set<const void *> Parents;
+ for (const auto &Parent : Context->getParents(*Node)) {
+ if (!Parents.insert(Parent.getMemoizationData()).second) {
+ return true;
+ }
+ }
+ return false;
+ }
+ };
+ EXPECT_FALSE(matchAndVerifyResultTrue(
+ "template <typename T> int Foo() { return 1 + 2; }\n"
+ "int x = Foo<int>() + Foo<unsigned>();",
+ stmt().bind("node"), new HasDuplicateParents()));
+}
+
TEST(TypeMatching, MatchesTypes) {
EXPECT_TRUE(matches("struct S {};", qualType().bind("loc")));
}
@@ -4104,7 +4150,7 @@
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;
@@ -4164,7 +4210,7 @@
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
@@ -4173,7 +4219,7 @@
return selectFirst<const T>(
"", match(decl(hasParent(
decl(has(decl(equalsNode(TypedNode)))).bind(""))),
- *Node, Context)) != NULL;
+ *Node, Context)) != nullptr;
}
};