[clang] [Clang][NFC] assert IFaceT in SemaObjC::HandleExprPropertyRefExpr (PR #138026)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 30 14:21:24 PDT 2025
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.yaghmour at 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()) {
More information about the cfe-commits
mailing list