Commit 41a9df2
authored
[Clang] Fix handling of explicit parameters in
Previously, the presence of an explicit parameter list was detected by
querying `getNumTypeObjects()` from the `Declarator` block of the lambda
definition. This breaks for lambdas which do not have a parameter list
but _do_ have a trailing return type; that is, both of
```
[]() -> int { return 0; };
[] -> int { return 0; };
```
would return `true` when inspecting
`LambdaExpr::hasExplicitParameters()`.
Fix this by instead querying the `LParenLoc()` from the `Declarator`'s
`FunctionTypeInfo`. If `isValid() == true`, then an explicit parameter
list must be present, and if it is `false`, then it is not.
This commit also adds `hasExplicitParameters` as an attribute to a
`LambdaExpr`'s JSON AST dump. A new test (`ast-dump-lambda-json.cpp`) is
also added to validate the fix and presence of the new attribute in the
output. `ast-dump-expr-json.cpp` is also updated to validate the new
attribute.
Fixes #168452.SemaLambda (#168558)1 parent 764c1d4 commit 41a9df2
File tree
6 files changed
+3419
-9
lines changed- clang
- docs
- include/clang/AST
- lib
- AST
- Sema
- test/AST
6 files changed
+3419
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
684 | 684 | | |
685 | 685 | | |
686 | 686 | | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
687 | 690 | | |
688 | 691 | | |
689 | 692 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
| 318 | + | |
318 | 319 | | |
319 | 320 | | |
320 | 321 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1607 | 1607 | | |
1608 | 1608 | | |
1609 | 1609 | | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
1610 | 1614 | | |
1611 | 1615 | | |
1612 | 1616 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1439 | 1439 | | |
1440 | 1440 | | |
1441 | 1441 | | |
1442 | | - | |
1443 | | - | |
1444 | | - | |
1445 | | - | |
| 1442 | + | |
1446 | 1443 | | |
1447 | | - | |
1448 | | - | |
1449 | | - | |
1450 | | - | |
1451 | | - | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
1452 | 1452 | | |
1453 | 1453 | | |
1454 | 1454 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3889 | 3889 | | |
3890 | 3890 | | |
3891 | 3891 | | |
| 3892 | + | |
3892 | 3893 | | |
3893 | 3894 | | |
3894 | 3895 | | |
| |||
4098 | 4099 | | |
4099 | 4100 | | |
4100 | 4101 | | |
| 4102 | + | |
4101 | 4103 | | |
4102 | 4104 | | |
4103 | 4105 | | |
| |||
4413 | 4415 | | |
4414 | 4416 | | |
4415 | 4417 | | |
| 4418 | + | |
4416 | 4419 | | |
4417 | 4420 | | |
4418 | 4421 | | |
| |||
4615 | 4618 | | |
4616 | 4619 | | |
4617 | 4620 | | |
| 4621 | + | |
4618 | 4622 | | |
4619 | 4623 | | |
4620 | 4624 | | |
| |||
4871 | 4875 | | |
4872 | 4876 | | |
4873 | 4877 | | |
| 4878 | + | |
4874 | 4879 | | |
4875 | 4880 | | |
4876 | 4881 | | |
| |||
5088 | 5093 | | |
5089 | 5094 | | |
5090 | 5095 | | |
| 5096 | + | |
5091 | 5097 | | |
5092 | 5098 | | |
5093 | 5099 | | |
| |||
5234 | 5240 | | |
5235 | 5241 | | |
5236 | 5242 | | |
| 5243 | + | |
5237 | 5244 | | |
5238 | 5245 | | |
5239 | 5246 | | |
| |||
5476 | 5483 | | |
5477 | 5484 | | |
5478 | 5485 | | |
| 5486 | + | |
5479 | 5487 | | |
5480 | 5488 | | |
5481 | 5489 | | |
| |||
5622 | 5630 | | |
5623 | 5631 | | |
5624 | 5632 | | |
| 5633 | + | |
5625 | 5634 | | |
5626 | 5635 | | |
5627 | 5636 | | |
| |||
5864 | 5873 | | |
5865 | 5874 | | |
5866 | 5875 | | |
| 5876 | + | |
5867 | 5877 | | |
5868 | 5878 | | |
5869 | 5879 | | |
| |||
6425 | 6435 | | |
6426 | 6436 | | |
6427 | 6437 | | |
| 6438 | + | |
6428 | 6439 | | |
6429 | 6440 | | |
6430 | 6441 | | |
| |||
6688 | 6699 | | |
6689 | 6700 | | |
6690 | 6701 | | |
| 6702 | + | |
6691 | 6703 | | |
6692 | 6704 | | |
6693 | 6705 | | |
| |||
6892 | 6904 | | |
6893 | 6905 | | |
6894 | 6906 | | |
| 6907 | + | |
6895 | 6908 | | |
6896 | 6909 | | |
6897 | 6910 | | |
| |||
7094 | 7107 | | |
7095 | 7108 | | |
7096 | 7109 | | |
| 7110 | + | |
7097 | 7111 | | |
7098 | 7112 | | |
7099 | 7113 | | |
| |||
7296 | 7310 | | |
7297 | 7311 | | |
7298 | 7312 | | |
| 7313 | + | |
7299 | 7314 | | |
7300 | 7315 | | |
7301 | 7316 | | |
| |||
0 commit comments