[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
Mon Jun 16 02:35:55 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:
@HerrCai0907 I am happy to do so. Are there any examples how it looks like for other clang-tidy checks?
Also, do you want to do it in scope of this PR or as a separate one?
Since non-std function names are also processed for `folly::Optional` in code above my change.
Thanks for review!
https://github.com/llvm/llvm-project/pull/144313
More information about the cfe-commits
mailing list