[PATCH] D19547: [clang-tidy] Add FixIt for swapping arguments in string-constructor-checker.

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 29 09:14:51 PDT 2016


alexfh requested changes to this revision.
This revision now requires changes to proceed.

================
Comment at: clang-tidy/misc/StringConstructorCheck.cpp:110
@@ -106,2 +109,3 @@
   if (Result.Nodes.getNodeAs<Expr>("swapped-parameter")) {
-    diag(Loc, "constructor parameters are probably swapped");
+    auto D = diag(Loc, "constructor parameters are probably swapped");
+
----------------
We could make the message slightly more specific by saying it's std::(basic_)?string constructor.

================
Comment at: clang-tidy/misc/StringConstructorCheck.cpp:115
@@ +114,3 @@
+    StringRef Param1String =
+        utils::create_fix_it::getSourceRangeAsString(Ctx, Param1);
+    StringRef Param2String =
----------------
You should be able to use `Lexer::getSourceText` instead.


http://reviews.llvm.org/D19547





More information about the cfe-commits mailing list