[clang] [clang-tools-extra] [clang-tidy] `bugprone-unchecked-optional-access`: handle `BloombergLP::bdlb:NullableValue::makeValue` to prevent false-positives (PR #144313)
Baranov Victor via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 13 09:12:19 PDT 2025
================
@@ -985,6 +985,20 @@ auto buildTransferMatchSwitch() {
isOptionalMemberCallWithNameMatcher(hasName("isNull")),
transferOptionalIsNullCall)
+ // NullableValue::makeValue, NullableValue::makeValueInplace
+ // Only NullableValue has these methods, but this
+ // will also pass for other types
+ .CaseOfCFGStmt<CXXMemberCallExpr>(
+ isOptionalMemberCallWithNameMatcher(
+ hasAnyName("makeValue", "makeValueInplace")),
+ [](const CXXMemberCallExpr *E, const MatchFinder::MatchResult &,
+ LatticeTransferState &State) {
+ if (RecordStorageLocation *Loc =
+ getImplicitObjectLocation(*E, State.Env)) {
+ setHasValue(*Loc, State.Env.getBoolLiteralValue(true), State.Env);
+ }
+ })
+
----------------
vbvictor wrote:
I'm not familiar with dataflow framework and I can't give a good direction for implementing this.
Added [ymand](https://github.com/ymand) as one of the previous reviewers of the code and [Xazax-hun](https://github.com/Xazax-hun), [gribozavr](https://github.com/gribozavr) as maintainers of analysis framework.
They may share an opinion on this matter.
https://github.com/llvm/llvm-project/pull/144313
More information about the cfe-commits
mailing list