Summary: This also changes the way we display Size and Offset to be independent.
Reviewers: sammccall
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D83143
if (Record)
Record = Record->getDefinition();
if (Record && !Record->isDependentType()) {
- uint64_t OffsetBits = Ctx.getFieldOffset(FD);
- if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType())) {
+ if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType()))
HI.Size = Size->getQuantity();
- HI.Offset = OffsetBits / 8;
- }
+ if (!FD->isInvalidDecl())
+ HI.Offset = Ctx.getFieldOffset(FD) / 8;
}
return;
}
HI.CallPassType->PassBy = PassMode::Value;
HI.CallPassType->Converted = false;
}},
+ {// Dont crash on invalid decl
+ R"cpp(
+ // error-ok
+ struct Foo {
+ Bar [[x^x]];
+ };)cpp",
+ [](HoverInfo &HI) {
+ HI.Name = "xx";
+ HI.Kind = index::SymbolKind::Field;
+ HI.NamespaceScope = "";
+ HI.Definition = "int xx";
+ HI.LocalScope = "Foo::";
+ HI.Size = 4;
+ HI.Type = "int";
+ HI.AccessSpecifier = "public";
+ }},
};
for (const auto &Case : Cases) {
SCOPED_TRACE(Case.Code);