[PATCH] D21134: clang-tidy: new check readability-misplaced-array-index

Daniel Marjamäki via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 9 00:29:02 PDT 2016


danielmarjamaki marked an inline comment as done.
danielmarjamaki added a comment.

In https://reviews.llvm.org/D21134#508511, @aaron.ballman wrote:

> Is there a reason we don't want this check to be a part of the clang frontend, rather than as a clang-tidy check?


I discussed this with frontend and clang-tidy people in the llvm meeting last year and we came to the conclusion it was better in clang-tidy.

I don't remember the exact reasons.

But I think that this code is just "weird". It could be a bug but I write the warning mostly for readability reasons.


================
Comment at: clang-tidy/readability/MisplacedArrayIndexCheck.cpp:43
@@ +42,3 @@
+
+static StringRef getAsString(const MatchFinder::MatchResult &Result,
+                             const Expr *E) {
----------------
danielmarjamaki wrote:
> alexfh wrote:
> > Looks like this repeats getText from clang/Tooling/FixIt.h.
> Yes indeed..
this is fixed. As you suggested I used createReplacement() in the fixit. It's much nicer!


https://reviews.llvm.org/D21134





More information about the cfe-commits mailing list