[clang-tools-extra] r273310 - Fix clang-tidy patterns to adapt to newly added ExprWithCleanups nodes.
Tim Shen via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 21 13:11:21 PDT 2016
Author: timshen
Date: Tue Jun 21 15:11:20 2016
New Revision: 273310
URL: http://llvm.org/viewvc/llvm-project?rev=273310&view=rev
Log:
Fix clang-tidy patterns to adapt to newly added ExprWithCleanups nodes.
Summary: This is a fix for the new ExprWithCleanups introduced by clang's temporary variable lifetime marks change.
Reviewers: bkramer, sbenza, angelgarcia, alexth
Subscribers: rsmith, cfe-commits
Differential Revision: http://reviews.llvm.org/D21243
Modified:
clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp
Modified: clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp?rev=273310&r1=273309&r2=273310&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp Tue Jun 21 15:11:20 2016
@@ -33,7 +33,8 @@ void TwineLocalCheck::check(const MatchF
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();
Modified: clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp?rev=273310&r1=273309&r2=273310&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp Tue Jun 21 15:11:20 2016
@@ -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 @@ void DanglingHandleCheck::registerMatche
// 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 ...
Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=273310&r1=273309&r2=273310&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Tue Jun 21 15:11:20 2016
@@ -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 makeIteratorLoopMatcher
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
Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp?rev=273310&r1=273309&r2=273310&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp Tue Jun 21 15:11:20 2016
@@ -156,7 +156,7 @@ bool DeclFinderASTVisitor::VisitTypeLoc(
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.
Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp?rev=273310&r1=273309&r2=273310&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp Tue Jun 21 15:11:20 2016
@@ -42,6 +42,8 @@ AST_MATCHER(VarDecl, hasWrittenNonListIn
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)) {
Modified: clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp?rev=273310&r1=273309&r2=273310&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp Tue Jun 21 15:11:20 2016
@@ -39,21 +39,21 @@ void RedundantStringInitCheck::registerM
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);
}
More information about the cfe-commits
mailing list