[clang] [clang-tools-extra] [clang-tidy] `bugprone-unchecked-optional-access`: handle `BloombergLP::bdlb:NullableValue::makeValue` to prevent false-positives (PR #144313)

Valentyn Yukhymenko via cfe-commits cfe-commits at lists.llvm.org
Sun Aug 31 18:01:32 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);
+            }
+          })
+
----------------
BaLiKfromUA wrote:

@vbvictor, sorry, got distracted last week by other work!

I created a [topic on discourse](https://discourse.llvm.org/t/should-dataflowanalysis-diagnosefunction-allow-to-pass-analysis-instance-created-by-caller/88134) with a summary of the problem, and updated the release notes in this PR.

Please let me know if I need to take any further action to resolve this bug fix.

Thank you!

https://github.com/llvm/llvm-project/pull/144313


More information about the cfe-commits mailing list