Skip to content

Conversation

shafik
Copy link
Collaborator

@shafik shafik commented Aug 14, 2025

Static analysis flagged this code b/c ToFPT could be nullptr but we were not checking it even though in the previous if statement we did. It looks like this was a mistaken refactor from:

#135836

In the older code ToFPT was set using a cast which would have asserted but no longer in the new code.

Static analysis flagged this code b/c ToFPT could be nullptr but we were not
checking it even though in the previous if statement we did. It looks like this
was a mistaken refactor from:

llvm#135836

In the older code ToFPT was set using a cast which would have asserted but no
longer in the new code.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Aug 14, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 14, 2025

@llvm/pr-subscribers-clang

Author: Shafik Yaghmour (shafik)

Changes

Static analysis flagged this code b/c ToFPT could be nullptr but we were not checking it even though in the previous if statement we did. It looks like this was a mistaken refactor from:

#135836

In the older code ToFPT was set using a cast which would have asserted but no longer in the new code.


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

1 Files Affected:

  • (modified) clang/lib/Sema/SemaOverload.cpp (+1-1)
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index ac64dd5c9c41f..7c4405b414c47 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1979,7 +1979,7 @@ bool Sema::IsFunctionConversion(QualType FromType, QualType ToType,
   }
 
   // Drop 'noexcept' if not present in target type.
-  if (FromFPT) {
+  if (FromFPT && ToFPT) {
     if (FromFPT->isNothrow() && !ToFPT->isNothrow()) {
       FromFn = cast<FunctionType>(
           Context.getFunctionTypeWithExceptionSpec(QualType(FromFPT, 0),

Copy link
Member

@Sirraide Sirraide left a comment

Choose a reason for hiding this comment

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

Yeah, I can’t see how that if statement wouldn’t just explode if ToFPT ended up being null, so this makes sense.

@shafik shafik merged commit c22ec9c into llvm:main Aug 15, 2025
12 checks passed
@shafik shafik deleted the IsFunctionConversion_add_toFPT_check branch August 15, 2025 14:16
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.

3 participants