================
@@ -1496,9 +1615,37 @@ static bool
IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
return false;
}
- if (Field1->isBitField())
- return IsStructurallyEquivalent(Context, Field1->getBitWidth(),
- Field2->getBitWidth());
+ if ((Field1->isBitField() || Field2->isBitField()) &&
+ !IsStructurallyEquivalent(Context, Field1->getBitWidth(),
+ Field2->getBitWidth())) {
+ if (Context.Complain) {
+ auto DiagNote = [&](const FieldDecl *FD,
+ DiagnosticBuilder (
+ StructuralEquivalenceContext::*Diag)(
+ SourceLocation, unsigned)) {
+ if (FD->isBitField()) {
+ std::string Str;
+ llvm::raw_string_ostream OS(Str);
+ PrintingPolicy Policy(Context.LangOpts);
+ FD->getBitWidth()->printPretty(OS, nullptr, Policy);
----------------
AaronBallman wrote:
Good question! That interface asserts if the width is invalid whereas the
`printPretty()` interface will still emit output. I went back and forth on
which way to go (I wasn't able to come up with a test case where
`getBitWidthValue()` would trigger an assertion, but I still wasn't comfortable
going that route). I can switch if you think it's worth it.
https://github.com/llvm/llvm-project/pull/132939
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits