Page MenuHomePhabricator

D63253.diff
No OneTemporary

File Metadata

Created
Mon, Nov 18, 6:49 AM

D63253.diff

Index: clang-tools-extra/trunk/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
@@ -20,21 +20,6 @@
AST_MATCHER(StringLiteral, lengthIsOne) { return Node.getLength() == 1; }
-::internal::Matcher<Expr>
-constructExprWithArg(llvm::StringRef ClassName,
- const ::internal::Matcher<Expr> &Arg) {
- auto ConstrExpr = cxxConstructExpr(hasType(recordDecl(hasName(ClassName))),
- hasArgument(0, ignoringParenCasts(Arg)));
-
- return anyOf(ConstrExpr, cxxBindTemporaryExpr(has(ConstrExpr)));
-}
-
-::internal::Matcher<Expr>
-copyConstructExprWithArg(llvm::StringRef ClassName,
- const ::internal::Matcher<Expr> &Arg) {
- return constructExprWithArg(ClassName, constructExprWithArg(ClassName, Arg));
-}
-
llvm::Optional<std::string> makeCharacterLiteral(const StringLiteral *Literal) {
std::string Result;
{
@@ -74,11 +59,17 @@
// Binds to a string_view (either absl or std) that was passed by value and
// contructed from string literal.
- auto StringViewArg =
- copyConstructExprWithArg("::absl::string_view", SingleChar);
+ auto StringViewArg = ignoringElidableConstructorCall(ignoringImpCasts(
+ cxxConstructExpr(hasType(recordDecl(hasName("::absl::string_view"))),
+ hasArgument(0, ignoringParenImpCasts(SingleChar)))));
+ // Need to ignore the elidable constructor as otherwise there is no match for
+ // c++14 and earlier.
auto ByAnyCharArg =
- expr(copyConstructExprWithArg("::absl::ByAnyChar", StringViewArg))
+ expr(has(ignoringElidableConstructorCall(
+ ignoringParenCasts(cxxBindTemporaryExpr(has(cxxConstructExpr(
+ hasType(recordDecl(hasName("::absl::ByAnyChar"))),
+ hasArgument(0, StringViewArg))))))))
.bind("ByAnyChar");
// Find uses of absl::StrSplit(..., "x") and absl::StrSplit(...,
Index: clang-tools-extra/trunk/test/clang-tidy/abseil-faster-strsplit-delimiter.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/abseil-faster-strsplit-delimiter.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/abseil-faster-strsplit-delimiter.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -std=c++11,c++14 %s abseil-faster-strsplit-delimiter %t
+// RUN: %check_clang_tidy -std=c++11-or-later %s abseil-faster-strsplit-delimiter %t
// FIXME: Fix the checker to work in C++17 mode.
namespace absl {

Event Timeline