https://github.com/steakhal created 
https://github.com/llvm/llvm-project/pull/152850

Addresses https://github.com/llvm/llvm-project/pull/83027#discussion_r2264102109

We can only reach this part by a non-null `Ptr`, which also implies a 
dereference of `PtrExpr`. Consequently, `PtrExpr` cannot be null here so the 
check is pointless.

>From c26b33e3d46b7752b707c0f6c3d77b54b0ce62cb Mon Sep 17 00:00:00 2001
From: Balazs Benics <benicsbal...@gmail.com>
Date: Sat, 9 Aug 2025 14:03:54 +0200
Subject: [PATCH] [analyzer] Remove trivially true condition

---
 clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
index da2d16ca9b5dd..3151f504d557f 100644
--- a/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
@@ -124,8 +124,7 @@ ProgramStateRef UnixAPIMisuseChecker::EnsurePtrNotNull(
       auto R = std::make_unique<PathSensitiveBugReport>(
           BT.value_or(std::cref(BT_ArgumentNull)),
           (PtrDescr + " pointer might be NULL.").str(), N);
-      if (PtrExpr)
-        bugreporter::trackExpressionValue(N, PtrExpr, *R);
+      bugreporter::trackExpressionValue(N, PtrExpr, *R);
       C.emitReport(std::move(R));
     }
     return nullptr;

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to