The existing padding checker skips classes that have any base classes. This patch allows the checker to traverse very simple cases: classes that have no fields and have one base class. This is important mostly in the case of array declarations. For example, this case with allowedPad=20:
struct FakeIntSandwich { char c1; int i; char c2; }; struct AnotherIntSandwich : FakeIntSandwich { // no-warning }; // But we don't yet support multiple base classes. struct IntSandwich {}; struct TooManyBaseClasses : FakeIntSandwich, IntSandwich { // no-warning }; AnotherIntSandwich ais[100];
would not ordinarily have been caught; FakeIntSandwich was not previously padded poorly enough to cause a warning. The previous version of the padding checker saw the declaration of ais of type AnotherIntSandwich[100] and ignored it because it had base classes. With these new changes, the padding checker *will* catch this, having traversed this simple class hierarchy. This test case is included in the file padding_inherit.cpp.
This check is already in shouldSkipDecl() (?)