Skip to content

Commit

Permalink
fix testcase and fix root reason about crash with tomasz-kaminski-son…
Browse files Browse the repository at this point in the history
…arsource's help
  • Loading branch information
miaozhiyuan committed Mar 5, 2024
1 parent b925806 commit 5ac52a8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
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
9 changes: 2 additions & 7 deletions clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,8 @@ SVal ExprEngine::computeObjectUnderConstruction(
// Operator arguments do not correspond to operator parameters
// because this-argument is implemented as a normal argument in
// operator call expressions but not in operator declarations.
std::optional<unsigned int> Index =
Caller->getAdjustedParameterIndex(Idx);
if (!Index) {
return std::nullopt;
}
const TypedValueRegion *TVR =
Caller->getParameterLocation(*Index, BldrCtx->blockCount());
const TypedValueRegion *TVR = Caller->getParameterLocation(
*Caller->getAdjustedParameterIndex(Idx), BldrCtx->blockCount());
if (!TVR)
return std::nullopt;

Expand Down
18 changes: 7 additions & 11 deletions clang/test/Analysis/engine/expr-engine-cxx-crash.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core.DivideZero -std=c++23 -verify %s
// RUN: %clang_analyze_cc1 -analyzer-checker=core -std=c++23 -verify %s
// expected-no-diagnostics

struct S
{
constexpr auto operator==(this auto, S)
{
return true;
}
struct S {
bool operator==(this auto, S) {
return true;
}
};

int main()
{
return S {} == S {};
int use_deducing_this() {
return S{} == S{};
}

0 comments on commit 5ac52a8

Please sign in to comment.