alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG with a nit.


================
Comment at: clang-tidy/cppcoreguidelines/SlicingCheck.cpp:86
@@ +85,3 @@
+           "slicing object from type %0 to %1 discards override %2")
+          << &DerivedDecl << &BaseDecl << Method;
+    }
----------------
The "slicing ... discards x bytes of state" message is not going to be repeated 
for the same location, so it's fine on its own.

Re: the "discards override" messages, they quite infrequent, IIUC, so the risk 
of spamming people with diagnostics is rather low. In case it's still 
problematic, we can change the repeated parts to notes.

================
Comment at: clang-tidy/cppcoreguidelines/SlicingCheck.cpp:91
@@ +90,3 @@
+  for (const auto &Base : DerivedDecl.bases()) {
+    const auto *BaseRecordType = Base.getType()->getAs<RecordType>();
+    if (!BaseRecordType)
----------------
Let's make the code more consistent:

```
if (const auto *BaseRecordType = Base.getType()->getAs<RecordType>()) {
  if (const auto *BaseRecord =
        cast_or_null<CXXRecordDecl>(BaseRecordType->getDecl()->getDefinition()))
      DiagnoseSlicedOverriddenMethods(Call, *BaseRecord, BaseDecl);
}
```


https://reviews.llvm.org/D21992



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to