Skip to content

Commit 5ac52a8

Browse files
author
miaozhiyuan
committed
fix testcase and fix root reason about crash with tomasz-kaminski-sonarsource's help
1 parent b925806 commit 5ac52a8

File tree

3 files changed

+10
-19
lines changed

3 files changed

+10
-19
lines changed

clang/lib/StaticAnalyzer/Core/CallEvent.cpp

+1-1
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/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,8 @@ SVal ExprEngine::computeObjectUnderConstruction(
354354
// Operator arguments do not correspond to operator parameters
355355
// because this-argument is implemented as a normal argument in
356356
// operator call expressions but not in operator declarations.
357-
std::optional<unsigned int> Index =
358-
Caller->getAdjustedParameterIndex(Idx);
359-
if (!Index) {
360-
return std::nullopt;
361-
}
362-
const TypedValueRegion *TVR =
363-
Caller->getParameterLocation(*Index, BldrCtx->blockCount());
357+
const TypedValueRegion *TVR = Caller->getParameterLocation(
358+
*Caller->getAdjustedParameterIndex(Idx), BldrCtx->blockCount());
364359
if (!TVR)
365360
return std::nullopt;
366361

Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
// RUN: %clang_analyze_cc1 -analyzer-checker=core.DivideZero -std=c++23 -verify %s
1+
// RUN: %clang_analyze_cc1 -analyzer-checker=core -std=c++23 -verify %s
22
// expected-no-diagnostics
33

4-
struct S
5-
{
6-
constexpr auto operator==(this auto, S)
7-
{
8-
return true;
9-
}
4+
struct S {
5+
bool operator==(this auto, S) {
6+
return true;
7+
}
108
};
11-
12-
int main()
13-
{
14-
return S {} == S {};
9+
int use_deducing_this() {
10+
return S{} == S{};
1511
}

0 commit comments

Comments
 (0)