[clang-tools-extra] [clangd] Show alignment for records and fields decls (PR #67213)

via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 23 03:30:35 PDT 2023


================
@@ -1001,6 +1001,8 @@ void addLayoutInfo(const NamedDecl &ND, HoverInfo &HI) {
   if (auto *RD = llvm::dyn_cast<RecordDecl>(&ND)) {
     if (auto Size = Ctx.getTypeSizeInCharsIfKnown(RD->getTypeForDecl()))
       HI.Size = Size->getQuantity() * 8;
+    if (!RD->isInvalidDecl() && !RD->isDependentType())
----------------
zyn0217 wrote:

We already have a check for invalid decl at the beginning of the function: `if (ND.isInvalidDecl()) return;`; Maybe we could avoid this extra check? i.e., `if (!RD->isDependentType())` is enough.

https://github.com/llvm/llvm-project/pull/67213


More information about the cfe-commits mailing list