[clang-tidy] Insert absl::StrAppend when replacing StrCat.
authorBenjamin Kramer <benny.kra@googlemail.com>
Tue, 11 Sep 2018 12:19:45 +0000 (12:19 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Tue, 11 Sep 2018 12:19:45 +0000 (12:19 +0000)
There might be no using decl for StrAppend around, inserting the
qualified name is less likely to break things.

llvm-svn: 341929

clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp
clang-tools-extra/test/clang-tidy/abseil-str-cat-append.cpp

index 25b9d17..4907237 100644 (file)
@@ -93,7 +93,7 @@ void StrCatAppendCheck::check(const MatchFinder::MatchResult &Result) {
       << FixItHint::CreateReplacement(
              CharSourceRange::getTokenRange(Op->getBeginLoc(),
                                             Call->getCallee()->getEndLoc()),
-             "StrAppend")
+             "absl::StrAppend")
       << FixItHint::CreateInsertion(Call->getArg(0)->getBeginLoc(), "&");
 }
 
index 9a12733..5ecb284 100644 (file)
@@ -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);
 }