[clang] [clang-tidy] [dataflow] Cache reference accessors for `bugprone-unchecked-optional-access` (PR #128437)

Valentyn Yukhymenko via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 23 13:53:55 PST 2025


================
@@ -580,6 +580,26 @@ void handleConstMemberCall(const CallExpr *CE,
     return;
   }
 
+  // Cache if the const method returns a reference
+  if (RecordLoc != nullptr && CE->isGLValue()) {
+    const FunctionDecl *DirectCallee = CE->getDirectCallee();
+    if (DirectCallee == nullptr)
+      return;
+
+    bool isReference =
+        DirectCallee->getReturnType().getTypePtr()->isReferenceType();
+    if (isReference) {
----------------
BaLiKfromUA wrote:

maybe this check is redundant

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


More information about the cfe-commits mailing list