timshen created this revision.
timshen added a reviewer: rsmith.
timshen added a subscriber: cfe-commits.
This is a fix for the new ExprWithCleanups introduced by clang's temporary
variable lifetime marks change.
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
@@ -48,12 +48,13 @@
// 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(ignoringExprWithCleanups(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,9 @@
if (!Init)
return false;
+ if (const auto *E = dyn_cast<ExprWithCleanups>(Init))
+ Init = E->getSubExpr();
+
// 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,6 +156,8 @@
const Expr *digThroughConstructors(const Expr *E) {
if (!E)
return nullptr;
+ if (auto Cleanups = dyn_cast<ExprWithCleanups>(E))
+ E = Cleanups->getSubExpr();
E = E->IgnoreParenImpCasts();
if (const auto *ConstructExpr = dyn_cast<CXXConstructExpr>(E)) {
// The initial constructor must take exactly one parameter, but base class
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===================================================================
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -141,10 +141,10 @@
StatementMatcher IteratorComparisonMatcher = expr(
ignoringParenImpCasts(declRefExpr(to(varDecl().bind(ConditionVarName)))));
- StatementMatcher OverloadedNEQMatcher =
+ StatementMatcher OverloadedNEQMatcher = ignoringExprWithCleanups(
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
@@ -135,15 +135,15 @@
// 1. Value to Handle conversion.
// 2. Handle copy construction.
// We have to match both.
- has(ignoringParenImpCasts(handleFrom(
+ has(ignoringExprWithCleanups(ignoringParenImpCasts(handleFrom(
IsAHandle,
handleFrom(IsAHandle, declRefExpr(to(varDecl(
// Is function scope ...
hasAutomaticStorageDuration(),
// ... and it is a local array or Value.
anyOf(hasType(arrayType()),
hasType(recordDecl(
- unless(IsAHandle))))))))))),
+ unless(IsAHandle)))))))))))),
// Temporary fix for false positives inside lambdas.
unless(hasAncestor(lambdaExpr())))
.bind("bad_stmt"),
Index: clang-tidy/llvm/TwineLocalCheck.cpp
===================================================================
--- clang-tidy/llvm/TwineLocalCheck.cpp
+++ clang-tidy/llvm/TwineLocalCheck.cpp
@@ -34,6 +34,10 @@
// Peel away implicit constructors and casts so we can see the actual type
// of the initializer.
const Expr *C = VD->getInit();
+
+ if (auto Expr = dyn_cast<ExprWithCleanups>(C))
+ C = Expr->getSubExpr();
+
while (isa<CXXConstructExpr>(C))
C = cast<CXXConstructExpr>(C)->getArg(0)->IgnoreParenImpCasts();
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits