llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: None (smanna12) <details> <summary>Changes</summary> This patch adds a null check for the current method declaration before attempting to determine if it is a designated initializer. This prevents a potential null pointer dereference when `getCurMethodDecl()` returns nullptr, reported by static analyzer tool in clang::SemaObjC::BuildInstanceMessage(). --- Full diff: https://github.com/llvm/llvm-project/pull/97220.diff 1 Files Affected: - (modified) clang/lib/Sema/SemaExprObjC.cpp (+4-2) ``````````diff diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index 7ccecf055feed..05aa30e16ed8e 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -3206,9 +3206,11 @@ ExprResult SemaObjC::BuildInstanceMessage( } if (!isDesignatedInitChain) { const ObjCMethodDecl *InitMethod = nullptr; + auto *CurMD = SemaRef.getCurMethodDecl(); + if (!CurMD) + return nullptr; bool isDesignated = - SemaRef.getCurMethodDecl()->isDesignatedInitializerForTheInterface( - &InitMethod); + CurMD->isDesignatedInitializerForTheInterface(&InitMethod); assert(isDesignated && InitMethod); (void)isDesignated; Diag(SelLoc, SuperLoc.isValid() ? `````````` </details> https://github.com/llvm/llvm-project/pull/97220 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits