[PATCH] D19146: [clang-tidy] New checker to detect suspicious string constructor.
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 15 18:14:36 PDT 2016
alexfh added inline comments.
================
Comment at: clang-tidy/misc/StringConstructorCheck.cpp:104
@@ +103,3 @@
+ const auto *E = Result.Nodes.getNodeAs<Expr>("constructor");
+ assert(E);
+
----------------
We usually add some description to asserts (`assert(X && "X should not be nullptr");`).
================
Comment at: clang-tidy/misc/StringConstructorCheck.cpp:107
@@ +106,3 @@
+ if (Result.Nodes.getNodeAs<Expr>("swapped-parameter")) {
+ diag(E->getLocStart(), "constructor parameters are probably swapped");
+ } else if (Result.Nodes.getNodeAs<Expr>("empty-string")) {
----------------
Might be nicer to pull `E->getLocStart()` to a variable.
http://reviews.llvm.org/D19146
More information about the cfe-commits
mailing list