Set traversal explicitly where needed in tests

Reviewers: aaron.ballman, shafik

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72531
diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp
index 3600395..06f6aa1 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -638,22 +638,16 @@
 TEST_P(ImportExpr, ImportStmtExpr) {
   MatchVerifier<Decl> Verifier;
   testImport(
-    "void declToImport() { int b; int a = b ?: 1; int C = ({int X=4; X;}); }",
-    Lang_C, "", Lang_C, Verifier,
-    functionDecl(hasDescendant(
-        varDecl(
-            hasName("C"),
-            hasType(asString("int")),
-            hasInitializer(
-                stmtExpr(
-                    hasAnySubstatement(declStmt(hasSingleDecl(
-                        varDecl(
-                            hasName("X"),
-                            hasType(asString("int")),
-                            hasInitializer(
-                                integerLiteral(equals(4))))))),
-                    hasDescendant(
-                        implicitCastExpr())))))));
+      "void declToImport() { int b; int a = b ?: 1; int C = ({int X=4; X;}); }",
+      Lang_C, "", Lang_C, Verifier,
+      traverse(ast_type_traits::TK_AsIs,
+               functionDecl(hasDescendant(varDecl(
+                   hasName("C"), hasType(asString("int")),
+                   hasInitializer(stmtExpr(
+                       hasAnySubstatement(declStmt(hasSingleDecl(varDecl(
+                           hasName("X"), hasType(asString("int")),
+                           hasInitializer(integerLiteral(equals(4))))))),
+                       hasDescendant(implicitCastExpr()))))))));
 }
 
 TEST_P(ImportExpr, ImportConditionalOperator) {
@@ -673,22 +667,19 @@
 TEST_P(ImportExpr, ImportBinaryConditionalOperator) {
   MatchVerifier<Decl> Verifier;
   testImport(
-      "void declToImport() { (void)(1 ?: -5); }",
-      Lang_CXX, "", Lang_CXX, Verifier,
-      functionDecl(hasDescendant(
-          binaryConditionalOperator(
-              hasCondition(
-                  implicitCastExpr(
-                      hasSourceExpression(opaqueValueExpr(
-                          hasSourceExpression(integerLiteral(equals(1))))),
-                      hasType(booleanType()))),
-              hasTrueExpression(
-                  opaqueValueExpr(
-                      hasSourceExpression(integerLiteral(equals(1))))),
-              hasFalseExpression(
-                  unaryOperator(
-                      hasOperatorName("-"),
-                      hasUnaryOperand(integerLiteral(equals(5)))))))));
+      "void declToImport() { (void)(1 ?: -5); }", Lang_CXX, "", Lang_CXX,
+      Verifier,
+      traverse(ast_type_traits::TK_AsIs,
+               functionDecl(hasDescendant(binaryConditionalOperator(
+                   hasCondition(implicitCastExpr(
+                       hasSourceExpression(opaqueValueExpr(
+                           hasSourceExpression(integerLiteral(equals(1))))),
+                       hasType(booleanType()))),
+                   hasTrueExpression(opaqueValueExpr(
+                       hasSourceExpression(integerLiteral(equals(1))))),
+                   hasFalseExpression(unaryOperator(
+                       hasOperatorName("-"),
+                       hasUnaryOperand(integerLiteral(equals(5))))))))));
 }
 
 TEST_P(ImportExpr, ImportDesignatedInitExpr) {
@@ -774,10 +765,10 @@
       "struct C {};"
       "void declToImport() { C c = C(); }",
       Lang_CXX, "", Lang_CXX, Verifier,
-      functionDecl(hasDescendant(
-          exprWithCleanups(has(cxxConstructExpr(
-              has(materializeTemporaryExpr(has(implicitCastExpr(
-                  has(cxxTemporaryObjectExpr())))))))))));
+      traverse(ast_type_traits::TK_AsIs,
+               functionDecl(hasDescendant(exprWithCleanups(has(cxxConstructExpr(
+                   has(materializeTemporaryExpr(has(implicitCastExpr(
+                       has(cxxTemporaryObjectExpr()))))))))))));
 }
 
 TEST_P(ImportType, ImportAtomicType) {
@@ -828,9 +819,10 @@
       "template <int K> using dummy2 = dummy<K>;"
       "int declToImport() { return dummy2<3>::i; }",
       Lang_CXX11, "", Lang_CXX11, Verifier,
-      functionDecl(
-          hasDescendant(implicitCastExpr(has(declRefExpr()))),
-          unless(hasAncestor(translationUnitDecl(has(typeAliasDecl()))))));
+      traverse(ast_type_traits::TK_AsIs,
+               functionDecl(hasDescendant(implicitCastExpr(has(declRefExpr()))),
+                            unless(hasAncestor(
+                                translationUnitDecl(has(typeAliasDecl())))))));
 }
 
 const internal::VariadicDynCastAllOfMatcher<Decl, VarTemplateSpecializationDecl>
@@ -851,16 +843,16 @@
 
 TEST_P(ImportType, ImportPackExpansion) {
   MatchVerifier<Decl> Verifier;
-  testImport(
-      "template <typename... Args>"
-      "struct dummy {"
-      "  dummy(Args... args) {}"
-      "  static const int i = 4;"
-      "};"
-      "int declToImport() { return dummy<int>::i; }",
-      Lang_CXX11, "", Lang_CXX11, Verifier,
-      functionDecl(hasDescendant(
-          returnStmt(has(implicitCastExpr(has(declRefExpr())))))));
+  testImport("template <typename... Args>"
+             "struct dummy {"
+             "  dummy(Args... args) {}"
+             "  static const int i = 4;"
+             "};"
+             "int declToImport() { return dummy<int>::i; }",
+             Lang_CXX11, "", Lang_CXX11, Verifier,
+             traverse(ast_type_traits::TK_AsIs,
+                      functionDecl(hasDescendant(returnStmt(
+                          has(implicitCastExpr(has(declRefExpr()))))))));
 }
 
 const internal::VariadicDynCastAllOfMatcher<Type,
@@ -937,11 +929,13 @@
       "  auto a = typeid(int); auto b = typeid(x);"
       "}",
       Lang_CXX11, "", Lang_CXX11, Verifier,
-      functionDecl(
-          hasDescendant(varDecl(
-              hasName("a"), hasInitializer(hasDescendant(cxxTypeidExpr())))),
-          hasDescendant(varDecl(
-              hasName("b"), hasInitializer(hasDescendant(cxxTypeidExpr()))))));
+      traverse(
+          ast_type_traits::TK_AsIs,
+          functionDecl(
+              hasDescendant(varDecl(hasName("a"), hasInitializer(hasDescendant(
+                                                      cxxTypeidExpr())))),
+              hasDescendant(varDecl(hasName("b"), hasInitializer(hasDescendant(
+                                                      cxxTypeidExpr())))))));
 }
 
 TEST_P(ImportExpr, ImportTypeTraitExprValDep) {