[llvm-branch-commits] [clang] [analyzer][NFC] Determine object parameter constness for getExtraInvalidatedValues (PR #223272)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sun Sep 13 13:01:20 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Benedek Kaibas (benedekaibas)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/223272.diff
1 Files Affected:
- (modified) clang/lib/StaticAnalyzer/Core/CallEvent.cpp (+11-1)
``````````diff
diff --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
index 4eed56b2963b5..9adc99d2db8fc 100644
--- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -758,6 +758,16 @@ const FunctionDecl *CXXInstanceCall::getDecl() const {
return getSVal(CE->getCallee()).getAsFunctionDecl();
}
+static bool hasConstObjectParameter(const CXXMethodDecl *MD) {
+ if (!MD->isExplicitObjectMemberFunction())
+ return MD->isConst();
+
+ QualType ObjTy = MD->getParamDecl(0)->getType();
+ if (const auto *RT = ObjTy->getAs<ReferenceType>())
+ return RT->getPointeeType().isConstQualified();
+ return true;
+}
+
void CXXInstanceCall::getExtraInvalidatedValues(
ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const {
SVal ThisVal = getCXXThisVal();
@@ -765,7 +775,7 @@ void CXXInstanceCall::getExtraInvalidatedValues(
// Don't invalidate if the method is const and there are no mutable fields.
if (const auto *D = cast_or_null<CXXMethodDecl>(getDecl())) {
- if (!D->isConst())
+ if (!hasConstObjectParameter(D))
return;
// Get the record decl for the class of 'This'. D->getParent() may return
``````````
</details>
https://github.com/llvm/llvm-project/pull/223272
More information about the llvm-branch-commits
mailing list