summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-06-16 02:00:04 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-06-16 02:00:04 +0000
commita05e09ba486a4fa54d2fdfb48bea4d7b290f00d7 (patch)
tree3eae765f39911b3a1f2fd337e51eec72a674eea0 /clang/lib/Sema/SemaChecking.cpp
parent575d0163bb1e0005698ad92dc97b7c290eca1bf1 (diff)
downloadbcm5719-llvm-a05e09ba486a4fa54d2fdfb48bea4d7b290f00d7.tar.gz
bcm5719-llvm-a05e09ba486a4fa54d2fdfb48bea4d7b290f00d7.zip
Skip both character pointers and void pointers when diagnosing bad
argument types for mem{set,cpy,move}. Character pointers, much like void pointers, often point to generic "memory", so trying to check whether they match the type of the argument to 'sizeof' (or other checks) is unproductive and often results in false positives. Nico, please review; does this miss any of the bugs you were trying to find with this warning? The array test case you had should be caught by the array-specific sizeof warning I think. llvm-svn: 133136
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index d45ebf9033d..945964fc351 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -1866,7 +1866,9 @@ void Sema::CheckMemsetcpymoveArguments(const CallExpr *Call,
if (const PointerType *DestPtrTy = DestTy->getAs<PointerType>()) {
QualType PointeeTy = DestPtrTy->getPointeeType();
- if (PointeeTy->isVoidType())
+ // Don't warn about void pointers or char pointers as both are often used
+ // for directly representing memory, regardless of its underlying type.
+ if (PointeeTy->isVoidType() || PointeeTy->isCharType())
continue;
// Catch "memset(p, 0, sizeof(p))" -- needs to be sizeof(*p).
OpenPOWER on IntegriCloud