[PATCH] D43803: [RFC] Handle qualified unnamed types in CodeView printer

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 27 10:59:56 PST 2018


rnk added inline comments.


================
Comment at: lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:1817-1818
   }
   // An unnamed member must represent a nested struct or union. Add all the
   // indirect fields to the current record.
   assert((DDTy->getOffsetInBits() % 8) == 0 && "Unnamed bitfield member!");
----------------
smeenai wrote:
> rnk wrote:
> > This seems like a flawed assumption. Other frontends might want to emit unnamed fields that aren't nested structs. I'd rather rewrite this logic so that it's a pattern match of an unnamed DICompositeType that is possibly wrapped in qualifier types. Basically, I'd just make the DICompositeType cast below a dyn_cast, and if it fails, drop the unnamed member. I have a feeling that VS and windbg will not cope with unnamed members.
> Thanks. Is there a better way to do that pattern match than what I have here? (In particular, should I be concerned about preserving the qualifiers in the nested types, as opposed to just dropping them, which I'm doing right now?)
I suppose the correct thing to do is to mark all the indirect members inside the anonymous struct here with the qualifiers on the outer struct. It would look kind of like this:
```
struct Outer {
  const struct {
    int inner1;
    int inner2;
  };
};
--> codeview
struct Outer {
  const int inner1;
  const int inner2;
};
```

That could be implemented by adding qualifiers to ClassInfo::MemberInfo, and then copying some of the logic from `lowerTypeModifier` to generate the right LF_MODIFIER records for it. Alternatively, we could synthesize new DIDerivedType metadata and then call `getTypeIndex` on it. It seems a little heroic, though, just to deal with a format limitation.

`lowerTypeModifier` is also about to get more complicated in D43060.

In conclusion, I'd drop them for now. Add a FIXME, maybe?


Repository:
  rL LLVM

https://reviews.llvm.org/D43803





More information about the llvm-commits mailing list