Fix ignore-traversal to call correct method
authorStephen Kelly <steveire@gmail.com>
Sun, 24 May 2020 21:28:24 +0000 (22:28 +0100)
committerStephen Kelly <steveire@gmail.com>
Sun, 24 May 2020 21:33:10 +0000 (22:33 +0100)
As is done by ignoreParenImpCasts(). We were not previously calling the
correct internal method.  Adjust tests to account for this.

clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
clang/lib/AST/Expr.cpp
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

index 70d2a10..aab45fa 100644 (file)
@@ -196,12 +196,12 @@ void UppercaseLiteralSuffixCheck::registerMatchers(MatchFinder *Finder) {
   // Sadly, we can't check whether the literal has suffix or not.
   // E.g. i32 suffix still results in 'BuiltinType::Kind::Int'.
   // And such an info is not stored in the *Literal itself.
-  Finder->addMatcher(
+  Finder->addMatcher(traverse(TK_AsIs,
       stmt(eachOf(integerLiteral().bind(IntegerLiteralCheck::Name),
                   floatLiteral().bind(FloatingLiteralCheck::Name)),
            unless(anyOf(hasParent(userDefinedLiteral()),
                         hasAncestor(isImplicit()),
-                        hasAncestor(substNonTypeTemplateParmExpr())))),
+                        hasAncestor(substNonTypeTemplateParmExpr()))))),
       this);
 }
 
index 0184140..b9b7ca9 100644 (file)
@@ -2909,7 +2909,7 @@ Expr *Expr::IgnoreUnlessSpelledInSource() {
   Expr *LastE = nullptr;
   while (E != LastE) {
     LastE = E;
-    E = IgnoreExprNodes(E, IgnoreImplicitSingleStep, IgnoreImpCastsSingleStep,
+    E = IgnoreExprNodes(E, IgnoreImplicitSingleStep, IgnoreImpCastsExtraSingleStep,
                         IgnoreParensOnlySingleStep);
 
     auto SR = E->getSourceRange();
index d380866..82a28d0 100644 (file)
@@ -303,11 +303,13 @@ TEST(Matcher, SubstNonTypeTemplateParm) {
   EXPECT_FALSE(matches("template<int N>\n"
                          "struct A {  static const int n = 0; };\n"
                          "struct B : public A<42> {};",
-                       substNonTypeTemplateParmExpr()));
+                         traverse(TK_AsIs,
+                       substNonTypeTemplateParmExpr())));
   EXPECT_TRUE(matches("template<int N>\n"
                         "struct A {  static const int n = N; };\n"
                         "struct B : public A<42> {};",
-                      substNonTypeTemplateParmExpr()));
+                         traverse(TK_AsIs,
+                      substNonTypeTemplateParmExpr())));
 }
 
 TEST(Matcher, NonTypeTemplateParmDecl) {