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

Fixes #78810 
Thanks for Snape3058 's comment

---------

Co-authored-by: miaozhiyuan <miaozhiyuan@feysh.com>
This commit is contained in:
Exile 2024-03-07 00:01:30 +08:00 committed by GitHub
parent d9d9301eec
commit d4687fe7d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View File

@ -1409,7 +1409,7 @@ CallEventManager::getSimpleCall(const CallExpr *CE, ProgramStateRef State,
if (const auto *OpCE = dyn_cast<CXXOperatorCallExpr>(CE)) { if (const auto *OpCE = dyn_cast<CXXOperatorCallExpr>(CE)) {
const FunctionDecl *DirectCallee = OpCE->getDirectCallee(); const FunctionDecl *DirectCallee = OpCE->getDirectCallee();
if (const auto *MD = dyn_cast<CXXMethodDecl>(DirectCallee)) if (const auto *MD = dyn_cast<CXXMethodDecl>(DirectCallee))
if (MD->isInstance()) if (MD->isImplicitObjectMemberFunction())
return create<CXXMemberOperatorCall>(OpCE, State, LCtx, ElemRef); return create<CXXMemberOperatorCall>(OpCE, State, LCtx, ElemRef);
} else if (CE->getCallee()->getType()->isBlockPointerType()) { } else if (CE->getCallee()->getType()->isBlockPointerType()) {

View File

@ -60,3 +60,14 @@ void top() {
s.c(); s.c();
s.c(11); 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}}
}