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 | 929f0135ab60166202f52e0dd19835c0490d792a (patch) | |
tree | 0115fd5547a38d57ae88b0115f8a54007601fc9b /lib/Sema/SemaChecking.cpp | |
parent | 304ed3f81ba96f10a431318e2d30f8fdb8399e60 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132534 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 7430cfb119..05c257ab83 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/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; } |