[PATCH] D32942: [clang-tidy] readability-function-size: add NestingThreshold param.
Roman Lebedev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 13 10:54:56 PDT 2017
lebedev.ri added a comment.
In https://reviews.llvm.org/D32942#778729, @malcolm.parsons wrote:
> In https://reviews.llvm.org/D32942#777001, @lebedev.ri wrote:
>
> > Which makes sense, since in AST, they are nested:
>
>
> They're not nested in the formatting, so I don't think it makes sense.
As usual, all the meaningful review happens post-factum :)
So, it should warn on:
void yes_nesting() { // 1
if (true) { // 2
int j;
} else {
if (true) { // 2 or 3?
int j;
} else {
if (true) { // 2 or 4?
int j;
} else {
if (true) { // 2 or 5?
int j;
}
}
}
}
}
which is
`-FunctionDecl <line:12:1, line:28:1> line:12:6 yes_nesting 'void (void)'
`-CompoundStmt <col:20, line:28:1>
`-IfStmt <line:13:3, line:27:3>
|-<<<NULL>>>
|-<<<NULL>>>
|-CXXBoolLiteralExpr <line:13:7> '_Bool' true
|-CompoundStmt <col:13, line:15:3>
| `-DeclStmt <line:14:5, col:10>
| `-VarDecl <col:5, col:9> col:9 j 'int'
`-CompoundStmt <line:15:10, line:27:3>
`-IfStmt <line:16:5, line:26:5>
|-<<<NULL>>>
|-<<<NULL>>>
|-CXXBoolLiteralExpr <line:16:9> '_Bool' true
|-CompoundStmt <col:15, line:18:5>
| `-DeclStmt <line:17:7, col:12>
| `-VarDecl <col:7, col:11> col:11 j 'int'
`-CompoundStmt <line:18:12, line:26:5>
`-IfStmt <line:19:7, line:25:7>
|-<<<NULL>>>
|-<<<NULL>>>
|-CXXBoolLiteralExpr <line:19:11> '_Bool' true
|-CompoundStmt <col:17, line:21:7>
| `-DeclStmt <line:20:9, col:14>
| `-VarDecl <col:9, col:13> col:13 j 'int'
`-CompoundStmt <line:21:14, line:25:7>
`-IfStmt <line:22:9, line:24:9>
|-<<<NULL>>>
|-<<<NULL>>>
|-CXXBoolLiteralExpr <line:22:13> '_Bool' true
|-CompoundStmt <col:19, line:24:9>
| `-DeclStmt <line:23:11, col:16>
| `-VarDecl <col:11, col:15> col:15 j 'int'
`-<<<NULL>>>
but should not on what you/i posted in the previous comment.
The difference seems to be some kind of implicit `CompoundStmt` added by `IfStmt`?
Assuming that is the case, maybe this is as simple as checking whether this `CompoundStmt` is implicit or not?
Best to move open a new bug about this. I'll see what can be done.
Repository:
rL LLVM
https://reviews.llvm.org/D32942
More information about the cfe-commits
mailing list