https://github.com/shafik created 
https://github.com/llvm/llvm-project/pull/138026

Static analysis flagged that we use IFaceT in HandleExprPropertyRefExpr without 
checking even though getInterfaceType() can return nullptr. The comments make 
it clear the assumption is that we will always have an interface, so we will 
document this via an assert.

Fixes: https://github.com/llvm/llvm-project/issues/134954

>From 34dc80d50eddae7ba7ab57fdd6fec01e4fe8e67d Mon Sep 17 00:00:00 2001
From: Shafik Yaghmour <shafik.yaghm...@intel.com>
Date: Wed, 30 Apr 2025 14:18:11 -0700
Subject: [PATCH] [Clang][NFC] assert IFaceT in
 SemaObjC::HandleExprPropertyRefExpr

Static analysis flagged that we use IFaceT in HandleExprPropertyRefExpr without
checking even though getInterfaceType() can return nullptr. The comments make it
clear the assumption is that we will always have an interface, so we will
document this via an assert.

Fixes: https://github.com/llvm/llvm-project/issues/134954
---
 clang/lib/Sema/SemaExprObjC.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp
index 18d9d38eee92f..1514ce4be0658 100644
--- a/clang/lib/Sema/SemaExprObjC.cpp
+++ b/clang/lib/Sema/SemaExprObjC.cpp
@@ -1980,6 +1980,7 @@ ExprResult SemaObjC::HandleExprPropertyRefExpr(
     SourceLocation SuperLoc, QualType SuperType, bool Super) {
   ASTContext &Context = getASTContext();
   const ObjCInterfaceType *IFaceT = OPT->getInterfaceType();
+  assert(IFaceT && "Expected an Interface");
   ObjCInterfaceDecl *IFace = IFaceT->getDecl();
 
   if (!MemberName.isIdentifier()) {

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to