[PATCH] D19769: [clang-tidy] Add explicitly given array size heuristic to misc-suspicious-missing-comma check.

Etienne Bergeron via cfe-commits cfe-commits at lists.llvm.org
Sun May 1 15:17:12 PDT 2016


etienneb added a comment.

this is cool :)
It's a simple and precise rule to avoid using the probabilistic heuristic.


================
Comment at: clang-tidy/misc/SuspiciousMissingCommaCheck.cpp:94
@@ -93,3 +93,3 @@
   Finder->addMatcher(StringsInitializerList.bind("list"), this);
 }
 
----------------
If it's working as-is,... this is neat  :)

================
Comment at: clang-tidy/misc/SuspiciousMissingCommaCheck.cpp:106
@@ +105,3 @@
+  if (InitializerList->hasArrayFiller()) {
+      diag(InitializerList->getExprLoc(),
+           "wrong string array initialization: "
----------------
The error should still be reported to the missing comma (concatenated token):
  ConcatenatedLiteral->getLocStart(),

We could add a NOTE to point to the array, stating that the size mismatch.

What do you think?

================
Comment at: test/clang-tidy/misc-suspicious-missing-comma.cpp:84
@@ +83,3 @@
+
+// Missing comma or wrong explicit array size.
+const char* TheThreeMusketeers[4] = {
----------------
Could you add the more complicated example I sent you.
More tests is always welcome.

Currently, there is no tests for initialisation list in initialisation list.


http://reviews.llvm.org/D19769





More information about the cfe-commits mailing list