aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>2016-08-11 18:33:15 +0000
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>2016-08-11 18:33:15 +0000
commitc73e4c3f890dc1388ee694d7e25de153fe3ed05e (patch)
treef9419e2545b3630c5b133bab93eac9e04e3170a0 /clang/lib/Sema/SemaChecking.cpp
parent7cdf01ef58ac9d181fd02cdee69102d26ec24a2d (diff)
downloadllvm-c73e4c3f890dc1388ee694d7e25de153fe3ed05e.zip
llvm-c73e4c3f890dc1388ee694d7e25de153fe3ed05e.tar.gz
llvm-c73e4c3f890dc1388ee694d7e25de153fe3ed05e.tar.bz2
[Sema] Add more strict check for sizeof diagnostics for bzero
Follow-up from r278264 after Joerg's feedback. Since bzero is not standard, be more strict: also check if the first argument is a pointer, which harden the check for when it does not come originally from a builtin. llvm-svn: 278379
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index f76ab08..c1781c2 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -6199,6 +6199,13 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call,
const Expr *SizeOfArg = getSizeOfExprArg(LenExpr);
llvm::FoldingSetNodeID SizeOfArgID;
+ // Although widely used, 'bzero' is not a standard function. Be more strict
+ // with the argument types before allowing diagnostics and only allow the
+ // form bzero(ptr, sizeof(...)).
+ QualType FirstArgTy = Call->getArg(0)->IgnoreParenImpCasts()->getType();
+ if (BId == Builtin::BIbzero && !FirstArgTy->getAs<PointerType>())
+ return;
+
for (unsigned ArgIdx = 0; ArgIdx != LastArg; ++ArgIdx) {
const Expr *Dest = Call->getArg(ArgIdx)->IgnoreParenImpCasts();
SourceRange ArgRange = Call->getArg(ArgIdx)->getSourceRange();