[clang] 6543878 - [Clang][NFC] assert IFaceT in SemaObjC::HandleExprPropertyRefExpr (#138026)

via cfe-commits cfe-commits at lists.llvm.org
Fri May 2 07:27:53 PDT 2025


Author: Shafik Yaghmour
Date: 2025-05-02T07:27:50-07:00
New Revision: 65438787c7729d84964a25c2db5f7996dd1343cc

URL: https://github.com/llvm/llvm-project/commit/65438787c7729d84964a25c2db5f7996dd1343cc
DIFF: https://github.com/llvm/llvm-project/commit/65438787c7729d84964a25c2db5f7996dd1343cc.diff

LOG: [Clang][NFC] assert IFaceT in SemaObjC::HandleExprPropertyRefExpr (#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

Added: 
    

Modified: 
    clang/lib/Sema/SemaExprObjC.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp
index abed95d3eacfc..b248ea380a526 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()) {


        


More information about the cfe-commits mailing list