[PATCH] D19084: [scan-build] fix warnings emitted on Clang AST code base

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Thu May 5 10:44:54 PDT 2016


dblaikie added a subscriber: dblaikie.

================
Comment at: lib/AST/ASTDiagnostic.cpp:1686
@@ -1685,3 +1685,3 @@
 
-    if (Same) {
+    if (Same && FromTD) {
       OS << "template " << FromTD->getNameAsString();
----------------
Should this be a condition, or just an assertion?

================
Comment at: lib/AST/ExprConstant.cpp:1992
@@ -1991,2 +1991,3 @@
                                         int64_t Adjustment) {
+  assert(E && "expression to be evaluated must be not NULL");
   CharUnits SizeOfPointee;
----------------
Does the static analyzer assume any pointer parameter may be null? (I didn't think it did that - I thought it only assumed it could be null if there was a null test somewhere in the function?) That seems a bit too pessimistic in most codebases, especially LLVM - we pass a lot of non-null pointers around.

================
Comment at: lib/AST/NestedNameSpecifier.cpp:460
@@ +459,3 @@
+
+    assert(Buffer && "Buffer cannot be NULL");
+
----------------
Again, is this assuming that the Buffer parameter may be null? That seems unlikely to be useful in the LLVM codebase where we have lots of guaranteed non-null pointers floating around (I'm surprised this wouldn't cause tons of analyzer warnings, so presumably it's something more subtle?)


http://reviews.llvm.org/D19084





More information about the cfe-commits mailing list