Skip to content

[analyzer] Fix crash on dereference invalid return value of getAdjustedParameterIndex() #83585

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 3 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/lib/StaticAnalyzer/Core/CallEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ CallEventManager::getSimpleCall(const CallExpr *CE, ProgramStateRef State,
if (const auto *OpCE = dyn_cast<CXXOperatorCallExpr>(CE)) {
const FunctionDecl *DirectCallee = OpCE->getDirectCallee();
if (const auto *MD = dyn_cast<CXXMethodDecl>(DirectCallee))
if (MD->isInstance())
if (MD->isImplicitObjectMemberFunction())
return create<CXXMemberOperatorCall>(OpCE, State, LCtx, ElemRef);

} else if (CE->getCallee()->getType()->isBlockPointerType()) {
Expand Down
11 changes: 11 additions & 0 deletions clang/test/Analysis/cxx2b-deducing-this.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,14 @@ void top() {
s.c();
s.c(11);
}


struct S2 {
bool operator==(this auto, S2) {
return true;
}
};
void use_deducing_this() {
int result = S2{} == S2{}; // no-crash
clang_analyzer_dump(result); // expected-warning {{1 S32b}}
}