[clang-tools-extra] r341929 - [clang-tidy] Insert absl::StrAppend when replacing StrCat.
Benjamin Kramer via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 11 05:19:45 PDT 2018
Author: d0k
Date: Tue Sep 11 05:19:45 2018
New Revision: 341929
URL: http://llvm.org/viewvc/llvm-project?rev=341929&view=rev
Log:
[clang-tidy] Insert absl::StrAppend when replacing StrCat.
There might be no using decl for StrAppend around, inserting the
qualified name is less likely to break things.
Modified:
clang-tools-extra/trunk/clang-tidy/abseil/StrCatAppendCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/abseil-str-cat-append.cpp
Modified: clang-tools-extra/trunk/clang-tidy/abseil/StrCatAppendCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/StrCatAppendCheck.cpp?rev=341929&r1=341928&r2=341929&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/abseil/StrCatAppendCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/StrCatAppendCheck.cpp Tue Sep 11 05:19:45 2018
@@ -93,7 +93,7 @@ void StrCatAppendCheck::check(const Matc
<< FixItHint::CreateReplacement(
CharSourceRange::getTokenRange(Op->getBeginLoc(),
Call->getCallee()->getEndLoc()),
- "StrAppend")
+ "absl::StrAppend")
<< FixItHint::CreateInsertion(Call->getArg(0)->getBeginLoc(), "&");
}
Modified: clang-tools-extra/trunk/test/clang-tidy/abseil-str-cat-append.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/abseil-str-cat-append.cpp?rev=341929&r1=341928&r2=341929&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/abseil-str-cat-append.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/abseil-str-cat-append.cpp Tue Sep 11 05:19:45 2018
@@ -97,7 +97,7 @@ void Bar() {
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: call to 'absl::StrCat' has no effect
A = StrCat(A, B);
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: call 'absl::StrAppend' instead of 'absl::StrCat' when appending to a string to avoid a performance penalty
-// CHECK-FIXES: {{^}} StrAppend(&A, B);
+// CHECK-FIXES: {{^}} absl::StrAppend(&A, B);
B = StrCat(A, B);
#define M(X) X = StrCat(X, A)
@@ -117,13 +117,13 @@ void OutsideAbsl() {
std::string A, B;
A = absl::StrCat(A, B);
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: call 'absl::StrAppend' instead of 'absl::StrCat' when appending to a string to avoid a performance penalty
-// CHECK-FIXES: {{^}} StrAppend(&A, B);
+// CHECK-FIXES: {{^}} absl::StrAppend(&A, B);
}
-void OutisdeUsingAbsl() {
+void OutsideUsingAbsl() {
std::string A, B;
using absl::StrCat;
A = StrCat(A, B);
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: call 'absl::StrAppend' instead of 'absl::StrCat' when appending to a string to avoid a performance penalty
-// CHECK-FIXES: {{^}} StrAppend(&A, B);
+// CHECK-FIXES: {{^}} absl::StrAppend(&A, B);
}
More information about the cfe-commits
mailing list