[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
Thu May 5 07:59:06 PDT 2016
etienneb added a comment.
In http://reviews.llvm.org/D19769#422317, @szdominik wrote:
> The original size is available - but from the decleration, not from the initListExpr.
Let do the copy paste (correctly):
clang-query> match namedDecl(hasName("listA"))
Match #1:
Binding for "root":
VarDecl 0x1a06370 </usr/local/google/home/etienneb/examples/test.cc:2:1, col:33> col:13 listA 'const char *[2]' cinit
`-InitListExpr 0x1a06538 <col:23, col:33> 'const char *[2]'
|-ImplicitCastExpr 0x1a06578 <col:24> 'const char *' <ArrayToPointerDecay>
| `-StringLiteral 0x1a06488 <col:24> 'const char [2]' lvalue "a"
`-ImplicitCastExpr 0x1a06598 <col:29> 'const char *' <ArrayToPointerDecay>
`-StringLiteral 0x1a064b8 <col:29> 'const char [2]' lvalue "b"
1 match.
clang-query> match namedDecl(hasName("listB"))
Match #1:
Binding for "root":
VarDecl 0x1a06678 </usr/local/google/home/etienneb/examples/test.cc:3:1, col:34> col:13 listB 'const char *[5]' cinit
`-InitListExpr 0x1a06788 <col:24, col:34> 'const char *[5]'
|-array filler
| `-ImplicitValueInitExpr 0x1a06810 <<invalid sloc>> 'const char *'
|-ImplicitCastExpr 0x1a067c8 <col:25> 'const char *' <ArrayToPointerDecay>
| `-StringLiteral 0x1a066d8 <col:25> 'const char [2]' lvalue "a"
`-ImplicitCastExpr 0x1a067e8 <col:30> 'const char *' <ArrayToPointerDecay>
`-StringLiteral 0x1a06708 <col:30> 'const char [2]' lvalue "b"
Now, if you are telling me there is a way to handle correctly this example:
const char* A[2] = {"a" "b");
Even using "hasParent" and going to the declaration to get the original size.... this worth implementing it.
Just be sure your matcher won't remove actually supported cases. You first proposal was breaking initialization list in initialization list.
So, the plan is:
If the parent is a declaration, and has a size, and the size match.... skip the heuristic even if there is concatenated string literals.
wdyt?
http://reviews.llvm.org/D19769
More information about the cfe-commits
mailing list