-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clang-tidy crash in ASTMatcher(cppcoreguidelines-owning-memory) with GMock/GTest and lambdas. #91206
Comments
It looks like this is because of invalid code: https://godbolt.org/z/9M77aWPzv I think the issue is due to clang seeing there is one capture, but then the capture init is a llvm-project/clang/lib/ASTMatchers/ASTMatchFinder.cpp Lines 287 to 295 in 94204f5
-> dereferencing a nullptr because we may want to match on capture initializers.
Manually reduced example: struct DeletedCopy {
DeletedCopy() = default;
DeletedCopy(const DeletedCopy &) = delete;
DeletedCopy &operator=(const DeletedCopy &) = delete;
};
class Mock {
public:
void Foo() {}
DeletedCopy c;
};
void TestBody() {
Mock mock;
auto foo = [mock](int x) { return mock.Foo(x); };
} https://godbolt.org/z/xq6E7jnK9 Debug stacktrace:
|
Duplicate of #70460 |
Running clang-tidy on the following piece of code causes clang-tidy to crash:
Resulting clang-tidy crash output:
The example is running using a combination of GTest and GMock tagged at commit hash 5197b1a8e6a1ef9f214f4aa537b0be17cbf91946.
If the piece of code is not wrapped in a TEST block, clang-tidy doesn't crash. Seems to be a combination of using a GMock class, a GTest test block, and trying to improperly capture the instance of the GMock class in a lambda.
The project is being built using CMake 3.29 and using the built in CXX_CLANG_TIDY property. I'm using the LLVM tools at version 18.1.4 downloaded and installed from Chocolatey.
CMake looks like this:
The text was updated successfully, but these errors were encountered: