[all-commits] [llvm/llvm-project] 7de1a1: [clang-tidy] Fix `modernize-use-scoped-lock` crash...
Victor Chernyakin via All-commits
all-commits at lists.llvm.org
Mon Oct 27 20:04:21 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 7de1a17cc64bfcd1f0de055682d562dfb6476fb2
https://github.com/llvm/llvm-project/commit/7de1a17cc64bfcd1f0de055682d562dfb6476fb2
Author: Victor Chernyakin <chernyakin.victor.j at outlook.com>
Date: 2025-10-27 (Mon, 27 Oct 2025)
Changed paths:
M clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp
M clang-tools-extra/docs/ReleaseNotes.rst
A clang-tools-extra/test/clang-tidy/checkers/modernize/use-scoped-lock-no-crash.cpp
Log Message:
-----------
[clang-tidy] Fix `modernize-use-scoped-lock` crash on malformed code (#165127)
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.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list