diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2011-06-03 06:23:57 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2011-06-03 06:23:57 +0000 |
commit | ac6872655bc64ac54c05dbf47e2e790b2b1bca9c (patch) | |
tree | 25fb9e2918a771ca3dffac6b7fe53b0ebcf48dd2 /clang/lib/Sema/SemaChecking.cpp | |
parent | 7ae2638d73d78844163bb693b037764372d207ef (diff) | |
download | llvm-ac6872655bc64ac54c05dbf47e2e790b2b1bca9c.zip llvm-ac6872655bc64ac54c05dbf47e2e790b2b1bca9c.tar.gz llvm-ac6872655bc64ac54c05dbf47e2e790b2b1bca9c.tar.bz2 |
Clean up the "non-POD memaccess" stuff some. This adds a properly named
diagnostic group to cover the cases where we have definitively bad
behavior: dynamic classes.
It also rips out the existing support for POD-based checking. This
didn't work well, and triggered too many false positives. I'm looking
into a possibly more principled way to warn on the fundamental buggy
construct here. POD-ness isn't the critical aspect anyways, so a clean
slate is better. This also removes some silliness from the code until
the new checks arrive.
llvm-svn: 132534
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 7430cfb..05c257a 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -1814,7 +1814,7 @@ static bool isDynamicClassType(QualType T) { /// \brief Check for dangerous or invalid arguments to memset(). /// -/// This issues warnings on known problematic or dangerous or unspecified +/// This issues warnings on known problematic, dangerous or unspecified /// arguments to the standard 'memset', 'memcpy', and 'memmove' function calls. /// /// \param Call The call expression to diagnose. @@ -1836,27 +1836,21 @@ void Sema::CheckMemsetcpymoveArguments(const CallExpr *Call, if (PointeeTy->isVoidType()) continue; - unsigned DiagID = 0; // Always complain about dynamic classes. - if (isDynamicClassType(PointeeTy)) - DiagID = diag::warn_dyn_class_memaccess; - // Check the C++11 POD definition regardless of language mode; it is more - // relaxed than earlier definitions and we don't want spurious warnings. - else if (!PointeeTy->isCXX11PODType()) - DiagID = diag::warn_non_pod_memaccess; - else + if (isDynamicClassType(PointeeTy)) { + DiagRuntimeBehavior( + Dest->getExprLoc(), Dest, + PDiag(diag::warn_dyn_class_memaccess) + << ArgIdx << FnName << PointeeTy + << Call->getCallee()->getSourceRange()); + } else { continue; - - DiagRuntimeBehavior( - Dest->getExprLoc(), Dest, - PDiag(DiagID) - << ArgIdx << FnName << PointeeTy - << Call->getCallee()->getSourceRange()); + } SourceRange ArgRange = Call->getArg(0)->getSourceRange(); DiagRuntimeBehavior( Dest->getExprLoc(), Dest, - PDiag(diag::note_non_pod_memaccess_silence) + PDiag(diag::note_bad_memaccess_silence) << FixItHint::CreateInsertion(ArgRange.getBegin(), "(void*)")); break; } |