[PATCH] D19084: [clang-analyzer] fix warnings emitted on clang code base

Apelete Seketeli via cfe-commits cfe-commits at lists.llvm.org
Thu May 5 02:21:59 PDT 2016


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

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

Changes since last revision:

- split patch into AST changes unit to ease review process.


http://reviews.llvm.org/D19084

Files:
  lib/AST/ASTDiagnostic.cpp
  lib/AST/DeclObjC.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/NestedNameSpecifier.cpp

Index: lib/AST/NestedNameSpecifier.cpp
===================================================================
--- lib/AST/NestedNameSpecifier.cpp
+++ lib/AST/NestedNameSpecifier.cpp
@@ -456,7 +456,9 @@
       Buffer = NewBuffer;
       BufferCapacity = NewCapacity;
     }
-    
+
+    assert(Buffer && "Buffer cannot be NULL");
+
     memcpy(Buffer + BufferSize, Start, End - Start);
     BufferSize += End-Start;
   }
Index: lib/AST/ExprConstant.cpp
===================================================================
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -1989,6 +1989,7 @@
 static bool HandleLValueArrayAdjustment(EvalInfo &Info, const Expr *E,
                                         LValue &LVal, QualType EltTy,
                                         int64_t Adjustment) {
+  assert(E && "expression to be evaluated must be not NULL");
   CharUnits SizeOfPointee;
   if (!HandleSizeof(Info, E->getExprLoc(), EltTy, SizeOfPointee))
     return false;
Index: lib/AST/DeclObjC.cpp
===================================================================
--- lib/AST/DeclObjC.cpp
+++ lib/AST/DeclObjC.cpp
@@ -1577,8 +1577,10 @@
           data().IvarList = layout[0].Ivar; Ix++;
           curIvar = data().IvarList;
         }
-        for ( ; Ix != EIx; curIvar = layout[Ix].Ivar, Ix++)
+        for ( ; Ix != EIx; curIvar = layout[Ix].Ivar, Ix++) {
+          assert(curIvar && "instance variable is NULL, stop iterating through layout");
           curIvar->setNextIvar(layout[Ix].Ivar);
+        }
       }
     }
   }
Index: lib/AST/ASTDiagnostic.cpp
===================================================================
--- lib/AST/ASTDiagnostic.cpp
+++ lib/AST/ASTDiagnostic.cpp
@@ -1683,7 +1683,7 @@
       ToName = ToTD->getQualifiedNameAsString();
     }
 
-    if (Same) {
+    if (Same && FromTD) {
       OS << "template " << FromTD->getNameAsString();
     } else if (!PrintTree) {
       OS << (FromDefault ? "(default) template " : "template ");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19084.56248.patch
Type: text/x-patch
Size: 1982 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160505/89b09137/attachment.bin>


More information about the cfe-commits mailing list