timshen updated this revision to Diff 60992.
timshen added a comment.

Updated the patch to use ignorngImplicit/Expr::IgnoreImplicit matcher.

I think there is a systematic way to do this change:
Look at every ignoringImpCasts, ignoringParenCasts, ignoringParenImpCasts, 
ignoringParens, and 
Expr::IgnoreImpCasts, Expr::IgnoreParenCasts, Expr::IgnoreParenImpCasts, 
Expr::IgnoreParens to
see if they can be changed to ignoringImplicit or Expr::IgnoreImplicit (which 
also ignores
ExprWithCleanups).

I'd say for most of the cases ExprWithCleanups should be ignored, but I'm not 
sure if I'm the
right person to look at these patterns.


http://reviews.llvm.org/D21243

Files:
  clang-tidy/llvm/TwineLocalCheck.cpp
  clang-tidy/misc/DanglingHandleCheck.cpp
  clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tidy/modernize/UseAutoCheck.cpp
  clang-tidy/readability/RedundantStringInitCheck.cpp

Index: clang-tidy/readability/RedundantStringInitCheck.cpp
===================================================================
--- clang-tidy/readability/RedundantStringInitCheck.cpp
+++ clang-tidy/readability/RedundantStringInitCheck.cpp
@@ -39,21 +39,21 @@
                              stringLiteral(hasSize(0)))));
 
   const auto EmptyStringCtorExprWithTemporaries =
-      expr(ignoringImplicit(
-          cxxConstructExpr(StringConstructorExpr,
-              hasArgument(0, ignoringImplicit(EmptyStringCtorExpr)))));
+      cxxConstructExpr(StringConstructorExpr,
+                       hasArgument(0, ignoringImplicit(EmptyStringCtorExpr)));
 
   // Match a variable declaration with an empty string literal as initializer.
   // Examples:
   //     string foo = "";
   //     string bar("");
   Finder->addMatcher(
-      namedDecl(varDecl(hasType(cxxRecordDecl(hasName("basic_string"))),
-                        hasInitializer(
-                            expr(anyOf(EmptyStringCtorExpr,
-                                       EmptyStringCtorExprWithTemporaries))
-                            .bind("expr"))),
-                unless(parmVarDecl()))
+      namedDecl(
+          varDecl(hasType(cxxRecordDecl(hasName("basic_string"))),
+                  hasInitializer(expr(ignoringImplicit(anyOf(
+                                          EmptyStringCtorExpr,
+                                          EmptyStringCtorExprWithTemporaries)))
+                                     .bind("expr"))),
+          unless(parmVarDecl()))
           .bind("decl"),
       this);
 }
Index: clang-tidy/modernize/UseAutoCheck.cpp
===================================================================
--- clang-tidy/modernize/UseAutoCheck.cpp
+++ clang-tidy/modernize/UseAutoCheck.cpp
@@ -42,6 +42,8 @@
   if (!Init)
     return false;
 
+  Init = Init->IgnoreImplicit();
+
   // The following test is based on DeclPrinter::VisitVarDecl() to find if an
   // initializer is implicit or not.
   if (const auto *Construct = dyn_cast<CXXConstructExpr>(Init)) {
Index: clang-tidy/modernize/LoopConvertUtils.cpp
===================================================================
--- clang-tidy/modernize/LoopConvertUtils.cpp
+++ clang-tidy/modernize/LoopConvertUtils.cpp
@@ -156,7 +156,7 @@
 const Expr *digThroughConstructors(const Expr *E) {
   if (!E)
     return nullptr;
-  E = E->IgnoreParenImpCasts();
+  E = E->IgnoreImplicit();
   if (const auto *ConstructExpr = dyn_cast<CXXConstructExpr>(E)) {
     // The initial constructor must take exactly one parameter, but base class
     // and deferred constructors can take more.
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===================================================================
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "LoopConvertCheck.h"
+#include "../utils/Matchers.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
@@ -141,10 +142,10 @@
   StatementMatcher IteratorComparisonMatcher = expr(
       ignoringParenImpCasts(declRefExpr(to(varDecl().bind(ConditionVarName)))));
 
-  StatementMatcher OverloadedNEQMatcher =
+  auto OverloadedNEQMatcher = matchers::ignoringImplicit(
       cxxOperatorCallExpr(hasOverloadedOperatorName("!="), argumentCountIs(2),
                           hasArgument(0, IteratorComparisonMatcher),
-                          hasArgument(1, IteratorBoundMatcher));
+                          hasArgument(1, IteratorBoundMatcher)));
 
   // This matcher tests that a declaration is a CXXRecordDecl that has an
   // overloaded operator*(). If the operator*() returns by value instead of by
Index: clang-tidy/misc/DanglingHandleCheck.cpp
===================================================================
--- clang-tidy/misc/DanglingHandleCheck.cpp
+++ clang-tidy/misc/DanglingHandleCheck.cpp
@@ -8,11 +8,13 @@
 //===----------------------------------------------------------------------===//
 
 #include "DanglingHandleCheck.h"
+#include "../utils/Matchers.h"
 #include "../utils/OptionsUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
 using namespace clang::ast_matchers;
+using namespace clang::tidy::matchers;
 
 namespace clang {
 namespace tidy {
@@ -135,7 +137,7 @@
           //   1. Value to Handle conversion.
           //   2. Handle copy construction.
           // We have to match both.
-          has(ignoringParenImpCasts(handleFrom(
+          has(ignoringImplicit(handleFrom(
               IsAHandle,
               handleFrom(IsAHandle, declRefExpr(to(varDecl(
                                         // Is function scope ...
Index: clang-tidy/llvm/TwineLocalCheck.cpp
===================================================================
--- clang-tidy/llvm/TwineLocalCheck.cpp
+++ clang-tidy/llvm/TwineLocalCheck.cpp
@@ -33,7 +33,8 @@
   if (VD->hasInit()) {
     // Peel away implicit constructors and casts so we can see the actual type
     // of the initializer.
-    const Expr *C = VD->getInit();
+    const Expr *C = VD->getInit()->IgnoreImplicit();
+
     while (isa<CXXConstructExpr>(C))
       C = cast<CXXConstructExpr>(C)->getArg(0)->IgnoreParenImpCasts();
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to