Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d4687fe

Browse files
mzyKimiaozhiyuan
and
miaozhiyuan
authoredMar 6, 2024
[analyzer] Fix crash on dereference invalid return value of getAdjustedParameterIndex() (llvm#83585)
Fixes llvm#78810 Thanks for Snape3058 's comment --------- Co-authored-by: miaozhiyuan <[email protected]>
1 parent d9d9301 commit d4687fe

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed
 

‎clang/lib/StaticAnalyzer/Core/CallEvent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,7 @@ CallEventManager::getSimpleCall(const CallExpr *CE, ProgramStateRef State,
14091409
if (const auto *OpCE = dyn_cast<CXXOperatorCallExpr>(CE)) {
14101410
const FunctionDecl *DirectCallee = OpCE->getDirectCallee();
14111411
if (const auto *MD = dyn_cast<CXXMethodDecl>(DirectCallee))
1412-
if (MD->isInstance())
1412+
if (MD->isImplicitObjectMemberFunction())
14131413
return create<CXXMemberOperatorCall>(OpCE, State, LCtx, ElemRef);
14141414

14151415
} else if (CE->getCallee()->getType()->isBlockPointerType()) {

‎clang/test/Analysis/cxx2b-deducing-this.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,14 @@ void top() {
6060
s.c();
6161
s.c(11);
6262
}
63+
64+
65+
struct S2 {
66+
bool operator==(this auto, S2) {
67+
return true;
68+
}
69+
};
70+
void use_deducing_this() {
71+
int result = S2{} == S2{}; // no-crash
72+
clang_analyzer_dump(result); // expected-warning {{1 S32b}}
73+
}

0 commit comments

Comments
 (0)
Please sign in to comment.