[PATCH] D21134: clang-tidy: new check readability-misplaced-array-index
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 16 09:49:13 PDT 2016
alexfh added a comment.
The check seems reasonable, I'm surprised there's no warning in Clang that catches index[array] syntax ;)
A few comments re: implementation.
================
Comment at: clang-tidy/readability/MisplacedArrayIndexCheck.cpp:43
@@ +42,3 @@
+
+static StringRef getAsString(const MatchFinder::MatchResult &Result,
+ const Expr *E) {
----------------
Looks like this repeats getText from clang/Tooling/FixIt.h.
================
Comment at: clang-tidy/readability/MisplacedArrayIndexCheck.cpp:73
@@ +72,3 @@
+
+ D << FixItHint::CreateReplacement(ArraySubscriptE->getLHS()->getSourceRange(),
+ RHSString);
----------------
Looks like you could use createReplacement and/or getText from clang/Tooling/FixIt.h.
http://reviews.llvm.org/D21134
More information about the cfe-commits
mailing list