[clang-tools-extra] 2be92b7 - Fix ignore-traversal to call correct method

Stephen Kelly via cfe-commits cfe-commits at lists.llvm.org
Sun May 24 14:33:45 PDT 2020


Author: Stephen Kelly
Date: 2020-05-24T22:33:10+01:00
New Revision: 2be92b7f7e41037e051096df8a9c4de35502c036

URL: https://github.com/llvm/llvm-project/commit/2be92b7f7e41037e051096df8a9c4de35502c036
DIFF: https://github.com/llvm/llvm-project/commit/2be92b7f7e41037e051096df8a9c4de35502c036.diff

LOG: Fix ignore-traversal to call correct method

As is done by ignoreParenImpCasts(). We were not previously calling the
correct internal method.  Adjust tests to account for this.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp b/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
index 70d2a10ae2d8..aab45faa6cb3 100644
--- a/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
@@ -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);
 }
 

diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 0184140ab07e..b9b7ca95b218 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -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();

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index d38086616460..82a28d00cebf 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -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) {


        


More information about the cfe-commits mailing list