Skip to content

Conversation

@shafik
Copy link
Collaborator

@shafik shafik commented Apr 30, 2025

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: #134954

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: llvm#134954
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Apr 30, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 30, 2025

@llvm/pr-subscribers-clang

Author: Shafik Yaghmour (shafik)

Changes

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: #134954


Full diff: https://github.com/llvm/llvm-project/pull/138026.diff

1 Files Affected:

  • (modified) clang/lib/Sema/SemaExprObjC.cpp (+1)
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()) {

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shafik shafik merged commit 6543878 into llvm:main May 2, 2025
14 checks passed
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
…vm#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: llvm#134954
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
…vm#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: llvm#134954
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SemaObjC::HandleExprPropertyRefExpr assumes getInterfaceType() will never return nullptr

3 participants