Author: gribozavr Date: Thu Jun 13 08:16:44 2019 New Revision: 363273 URL: http://llvm.org/viewvc/llvm-project?rev=363273&view=rev Log: [clang-tidy] Made abseil-faster-strsplit-delimiter tests pass on C++17
Reviewers: hokein, gribozavr Reviewed By: hokein, gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63253 Patch by Johan Vikström. Modified: clang-tools-extra/trunk/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp clang-tools-extra/trunk/test/clang-tidy/abseil-faster-strsplit-delimiter.cpp Modified: clang-tools-extra/trunk/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp?rev=363273&r1=363272&r2=363273&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp Thu Jun 13 08:16:44 2019 @@ -20,21 +20,6 @@ namespace { 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 @@ void FasterStrsplitDelimiterCheck::regis // 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(..., Modified: clang-tools-extra/trunk/test/clang-tidy/abseil-faster-strsplit-delimiter.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/abseil-faster-strsplit-delimiter.cpp?rev=363273&r1=363272&r2=363273&view=diff ============================================================================== --- clang-tools-extra/trunk/test/clang-tidy/abseil-faster-strsplit-delimiter.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/abseil-faster-strsplit-delimiter.cpp Thu Jun 13 08:16:44 2019 @@ -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 { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits