[PATCH] D83189: [clangd] More complete fix for hover crashes on invalid record.
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 6 12:53:26 PDT 2020
kadircet added a comment.
thanks for doing this !
================
Comment at: clang-tools-extra/clangd/Hover.cpp:665
if (auto *RD = llvm::dyn_cast<RecordDecl>(&ND)) {
if (auto Size = Ctx.getTypeSizeInCharsIfKnown(RD->getTypeForDecl()))
HI.Size = Size->getQuantity();
----------------
i think we should bail out for invalid decls in here too. it won't crash but will provide spurious results. so i think an early exit for `ND.isInvalidDecl()` at the beginning of the function would be nice.
================
Comment at: clang-tools-extra/clangd/Hover.cpp:677
HI.Size = Size->getQuantity();
- if (!FD->isInvalidDecl())
HI.Offset = Ctx.getFieldOffset(FD) / 8;
+ }
----------------
could you move this out of the if statement.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83189/new/
https://reviews.llvm.org/D83189
More information about the cfe-commits
mailing list