Skip to content

Commit

Permalink
[analyzer] Fix crash on dereference invalid return value of getAdjust…
Browse files Browse the repository at this point in the history
…edParameterIndex() (llvm#83585)

Fixes llvm#78810 
Thanks for Snape3058 's comment

---------

Co-authored-by: miaozhiyuan <[email protected]>
  • Loading branch information
mzyKi and miaozhiyuan authored Mar 6, 2024
1 parent d9d9301 commit d4687fe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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}}
}

0 comments on commit d4687fe

Please sign in to comment.