summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
diff options
context:
space:
mode:
authorClement Courbet <courbet@google.com>2016-12-22 14:12:31 +0000
committerClement Courbet <courbet@google.com>2016-12-22 14:12:31 +0000
commit4d260bf0c7d3875e8588ee22731f8e354ac3b450 (patch)
tree97aa996d5999989a0cf66d1c5d9822a54649af8c /clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
parentf6aeed3624d496dbe2f13626c79785aab3f2ea03 (diff)
downloadbcm5719-llvm-4d260bf0c7d3875e8588ee22731f8e354ac3b450.tar.gz
bcm5719-llvm-4d260bf0c7d3875e8588ee22731f8e354ac3b450.zip
[clang-tidy] cppcoreguidelines-slicing: display discarded state size in bytes
https://reviews.llvm.org/D27212 llvm-svn: 290340
Diffstat (limited to 'clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
index 2a6cf098e69..53b2f728fe4 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
@@ -122,10 +122,11 @@ void SlicingCheck::check(const MatchFinder::MatchResult &Result) {
BaseDecl->getASTContext().getASTRecordLayout(BaseDecl);
const auto &DerivedLayout =
DerivedDecl->getASTContext().getASTRecordLayout(DerivedDecl);
- const auto StateSize = DerivedLayout.getDataSize() - BaseLayout.getDataSize();
+ const CharUnits StateSize =
+ DerivedLayout.getDataSize() - BaseLayout.getDataSize();
if (StateSize.isPositive()) {
diag(Call->getExprLoc(), "slicing object from type %0 to %1 discards "
- "%2*sizeof(char) bytes of state")
+ "%2 bytes of state")
<< DerivedDecl << BaseDecl << static_cast<int>(StateSize.getQuantity());
}
}
OpenPOWER on IntegriCloud