[clang] [Clang][Sema] Add nullptr check in IsFunctionConversion (PR #153710)

via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 14 16:14:39 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Shafik Yaghmour (shafik)

<details>
<summary>Changes</summary>

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:

https://github.com/llvm/llvm-project/pull/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
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),

``````````

</details>


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


More information about the cfe-commits mailing list