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

Apelete Seketeli via cfe-commits cfe-commits at lists.llvm.org
Mon May 9 05:19:09 PDT 2016


apelete updated this revision to Diff 56556.
apelete added a comment.

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

- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp: factorize assert and check on '!Diags.empty' condition.


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
@@ -294,9 +294,8 @@
   SmallVector<FileID, 10> Fids;
   const SourceManager* SM = nullptr;
 
-  if (!Diags.empty())
-    SM = &Diags.front()->path.front()->getLocation().getManager();
-
+  assert(!Diags.empty() && "cannot iterate through empty PathDiagnostic");
+  SM = &Diags.front()->path.front()->getLocation().getManager();
 
   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.56556.patch
Type: text/x-patch
Size: 1165 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160509/12c0a815/attachment-0001.bin>


More information about the cfe-commits mailing list