[PATCH] D19084: [scan-build] fix warnings emitted on Clang AST code base
Apelete Seketeli via cfe-commits
cfe-commits at lists.llvm.org
Wed May 18 01:13:04 PDT 2016
apelete updated this revision to Diff 57571.
apelete retitled this revision from "[scan-build] fix warnings emitted on Clang AST code base " to "[scan-build] fix warnings emitted on Clang AST code base".
apelete added a comment.
[scan-build] fix warnings emitted on Clang AST code base
Changes since last revision:
- lib/AST/ASTDiagnostic.cpp: replace if() condition by assert to ensure that template diffing print message is done only when both 'FromTD' and 'ToTD' are non-null.
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
@@ -1684,6 +1684,8 @@
}
if (Same) {
+ assert((FromTD && ToTD) &&
+ "Same implies both template arguments are non-null.");
OS << "template " << FromTD->getNameAsString();
} else if (!PrintTree) {
OS << (FromDefault ? "(default) template " : "template ");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19084.57571.patch
Type: text/x-patch
Size: 2008 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160518/d5d8742d/attachment-0001.bin>
More information about the cfe-commits
mailing list