Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Clang][NFC] assert IFaceT in SemaObjC::HandleExprPropertyRefExpr #138026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2025

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
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
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