[PATCH] D18457: [clang-tidy] Add a new checker to detect missing comma in initializer list.

Etienne Bergeron via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 31 09:44:11 PDT 2016


etienneb added a comment.

ready to land.


================
Comment at: clang-tidy/misc/SuspiciousMissingCommaCheck.cpp:75
@@ +74,3 @@
+  diag(ConcatenatedLiteral->getLocStart(),
+       "suspicious string literal, probably missing a comma");
+}
----------------
alexfh wrote:
> xazax.hun wrote:
> > alexfh wrote:
> > > We need to add a recommendation on how to silence this warning (use parentheses, for example). Fine for a follow up.
> > A possible way to silence this warning would be to implement a heuristic that is available in szdominik's implementation, i.e.: when the size of the array is explicitly given by the user and it matches the length of the initializer list do not warn.
> The check shouldn't complain in this case, but I wouldn't recommend this as a fix, since it makes the code more strict in an inconvenient way.
I'll provide the recommendation when it will be implemented. Next patch.

================
Comment at: clang-tidy/misc/SuspiciousMissingCommaCheck.cpp:75
@@ +74,3 @@
+  diag(ConcatenatedLiteral->getLocStart(),
+       "suspicious string literal, probably missing a comma");
+}
----------------
etienneb wrote:
> alexfh wrote:
> > xazax.hun wrote:
> > > alexfh wrote:
> > > > We need to add a recommendation on how to silence this warning (use parentheses, for example). Fine for a follow up.
> > > A possible way to silence this warning would be to implement a heuristic that is available in szdominik's implementation, i.e.: when the size of the array is explicitly given by the user and it matches the length of the initializer list do not warn.
> > The check shouldn't complain in this case, but I wouldn't recommend this as a fix, since it makes the code more strict in an inconvenient way.
> I'll provide the recommendation when it will be implemented. Next patch.
in case of a fixed array size, the algorithm could be more aggressive.
Feel free to push a patch for this.

I don't believe it's quite common to set the size for string literals. If you have example for it, please share it.


http://reviews.llvm.org/D18457





More information about the cfe-commits mailing list