[PATCH] D19962: [scan-build] fix warnings emitted on Clang StaticAnalyzer code base

Apelete Seketeli via cfe-commits cfe-commits at lists.llvm.org
Thu May 5 03:27:40 PDT 2016


apelete created this revision.
apelete added a reviewer: zaks.anna.
apelete added a subscriber: cfe-commits.

This patch fixes a few "Logic error" warnings of the type "Called c++
object pointer is null" reported by Clang Static Analyzer on the
following files:

- lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp,
- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp.

Signed-off-by: Apelete Seketeli <apelete at seketeli.net>

http://reviews.llvm.org/D19962

Files:
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  lib/StaticAnalyzer/Core/PlistDiagnostics.cpp

Index: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===================================================================
--- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -297,6 +297,7 @@
   if (!Diags.empty())
     SM = &Diags.front()->path.front()->getLocation().getManager();
 
+  assert(SM && "SourceManager is NULL, cannot iterate through the diagnostics");
 
   for (std::vector<const PathDiagnostic*>::iterator DI = Diags.begin(),
        DE = Diags.end(); DI != DE; ++DI) {
Index: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -693,6 +693,8 @@
         !Param->getType()->isReferenceType())
       continue;
 
+    assert(ArgExpr && "cannot get the type of a NULL expression");
+
     NullConstraint Nullness = getNullConstraint(*ArgSVal, State);
 
     Nullability RequiredNullability =


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19962.56257.patch
Type: text/x-patch
Size: 1032 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160505/a656b2e4/attachment-0001.bin>


More information about the cfe-commits mailing list