Author: Balazs Benics
Date: 2025-08-11T14:42:43+02:00
New Revision: 7ed412a9b80c57a4e4da57d2187c1acc33e42e04

URL: 
https://github.com/llvm/llvm-project/commit/7ed412a9b80c57a4e4da57d2187c1acc33e42e04
DIFF: 
https://github.com/llvm/llvm-project/commit/7ed412a9b80c57a4e4da57d2187c1acc33e42e04.diff

LOG: [analyzer] Remove trivially true condition (#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.

Added: 
    

Modified: 
    clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
index e12261603757f..4df751d203973 100644
--- a/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
@@ -137,8 +137,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