szdominik created this revision.
szdominik added reviewers: alexfh, etienneb.
szdominik added subscribers: cfe-commits, xazax.hun.
Additional heuristic to misc-suspicious-missing-comma checker, based on the
(in)equality of the explicitly given array size and the real array size.
Note: in these ca
szdominik added inline comments.
Comment at: clang-tidy/misc/SuspiciousMissingCommaCheck.cpp:92
@@ +91,3 @@
+ has(expr(ignoringImpCasts(ConcatenatedStringLiteral))),
+ hasParent(varDecl(allOf(hasType(arrayType()), isDefinition()))
+.bind("varDecl")));
szdominik updated this revision to Diff 55741.
szdominik added a comment.
Implement the heuristic in a different (and simpler) way.
Based on the array fillers.
http://reviews.llvm.org/D19769
Files:
clang-tidy/misc/SuspiciousMissingCommaCheck.cpp
docs/clang-tidy/checks/misc-suspicious-missin
szdominik added inline comments.
Comment at: clang-tidy/misc/SuspiciousMissingCommaCheck.cpp:94
@@ -93,3 +93,3 @@
Finder->addMatcher(StringsInitializerList.bind("list"), this);
}
etienneb wrote:
> If it's working as-is,... this is neat :)
Well, the array fi
szdominik marked 3 inline comments as done.
Comment at: clang-tidy/misc/SuspiciousMissingCommaCheck.cpp:106
@@ +105,3 @@
+ if (InitializerList->hasArrayFiller()) {
+ diag(InitializerList->getExprLoc(),
+ "wrong string array initialization: "
etienn
szdominik added a comment.
The original size is available - but from the decleration, not from the
initListExpr.
Comment at: clang-tidy/misc/SuspiciousMissingCommaCheck.cpp:106
@@ +105,3 @@
+ if (InitializerList->hasArrayFiller()) {
+ diag(InitializerList->getExprLoc(),
+
szdominik added a comment.
I think the main success is that we don't warn here:
const char* A[2] = {"a", "b" "c");
The problem is, as you said, not remove already supported cases (such as when
the parent is not a vardecl (but also an initListExpr)).
But I'll implement, and we'll see it.
htt
szdominik added a comment.
Hi!
I'm working on the same (or almost the same) checker as you, so maybe you'll
find helpful my code.
I think your approach (or heuristics) is better than mine, but there are other
options in this problem.
e.g.
- more precise location (where exactly is the missing c