Commit 7de1a17
authored
[clang-tidy] Fix
This code:
```cpp
void f() {
std::lock_guard<std::mutex> dont_crash {some_nonexistant_variable};
}
```
Generates an AST like this:
```txt
TranslationUnitDecl
`-FunctionDecl <line:3:1, line:5:1> line:3:6 f 'void ()'
`-CompoundStmt <col:10, line:5:1>
`-DeclStmt <line:4:3, col:69>
`-VarDecl <col:3, col:31> col:31 dont_crash 'std::lock_guard<std::mutex>' destroyed
```
Where the `VarDecl` has no initializer. The check doesn't expect this
and crashes.modernize-use-scoped-lock crash on malformed code (#165127)1 parent d63983b commit 7de1a17
File tree
3 files changed
+16
-1
lines changed- clang-tools-extra
- clang-tidy/modernize
- docs
- test/clang-tidy/checkers/modernize
3 files changed
+16
-1
lines changedLines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
| 220 | + | |
| 221 | + | |
221 | 222 | | |
222 | 223 | | |
223 | 224 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
383 | 388 | | |
384 | 389 | | |
385 | 390 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
0 commit comments