[clang] [Clang][Sema] Add nullptr check in IsFunctionConversion (PR #153710)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 14 16:14:06 PDT 2025
https://github.com/shafik created https://github.com/llvm/llvm-project/pull/153710
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.
>From 10fc9a688d4e7870f04124bef3b4394e00fadddb Mon Sep 17 00:00:00 2001
From: Shafik Yaghmour <shafik.yaghmour at intel.com>
Date: Thu, 14 Aug 2025 16:09:46 -0700
Subject: [PATCH] [Clang][Sema] Add nullptr check in IsFunctionConversion
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.
---
clang/lib/Sema/SemaOverload.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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),
More information about the cfe-commits
mailing list