summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDavid Carlier <devnexen@gmail.com>2018-07-20 20:39:49 +0000
committerDavid Carlier <devnexen@gmail.com>2018-07-20 20:39:49 +0000
commitc30cedfcc0f96390a10816fec3d7c8e6d1dc2b86 (patch)
tree4a97d06d84645d069302c255786dc7dc06489cee /clang/lib
parenta66d77b22bee82e9ca2e00150ab55501a1ffb69a (diff)
downloadbcm5719-llvm-c30cedfcc0f96390a10816fec3d7c8e6d1dc2b86.tar.gz
bcm5719-llvm-c30cedfcc0f96390a10816fec3d7c8e6d1dc2b86.zip
[CStringSyntaxChecker] Fix build bot builds != x86 archs
Reviewers: NoQ,george.karpenkov Reviewed By: NoQ Differential Revision: https://reviews.llvm.org/D49588 llvm-svn: 337611
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp
index 6654e822e1c..b1f37f5a342 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp
@@ -147,7 +147,7 @@ bool WalkAST::containsBadStrlcpyPattern(const CallExpr *CE) {
const Expr *DstArg = CE->getArg(0);
const Expr *LenArg = CE->getArg(2);
- const auto *DstArgDecl = dyn_cast<DeclRefExpr>(DstArg->IgnoreParenCasts());
+ const auto *DstArgDecl = dyn_cast<DeclRefExpr>(DstArg->IgnoreParenImpCasts());
const auto *LenArgDecl = dyn_cast<DeclRefExpr>(LenArg->IgnoreParenLValueCasts());
// - size_t dstlen = sizeof(dst)
if (LenArgDecl) {
@@ -159,14 +159,15 @@ bool WalkAST::containsBadStrlcpyPattern(const CallExpr *CE) {
// - integral value
// We try to figure out if the last argument is possibly longer
// than the destination can possibly handle if its size can be defined
- if (const auto *IL = dyn_cast<IntegerLiteral>(LenArg->IgnoreParenCasts())) {
+ if (const auto *IL = dyn_cast<IntegerLiteral>(LenArg->IgnoreParenImpCasts())) {
uint64_t ILRawVal = IL->getValue().getZExtValue();
- if (const auto *Buffer = dyn_cast<ConstantArrayType>(DstArgDecl->getType())) {
- ASTContext &C = BR.getContext();
- uint64_t Usize = C.getTypeSizeInChars(DstArg->getType()).getQuantity();
- uint64_t BufferLen = BR.getContext().getTypeSize(Buffer) / Usize;
- if (BufferLen < ILRawVal)
- return true;
+ if (DstArgDecl) {
+ if (const auto *Buffer = dyn_cast<ConstantArrayType>(DstArgDecl->getType())) {
+ ASTContext &C = BR.getContext();
+ uint64_t BufferLen = C.getTypeSize(Buffer) / 8;
+ if (BufferLen < ILRawVal)
+ return true;
+ }
}
}
OpenPOWER on IntegriCloud