[Lldb-commits] [PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

Matheus Izvekov via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sat Jul 16 15:48:22 PDT 2022


mizvekov added a comment.

@kimgr One other general comment.

The way this function is implemented is quite error prone:

  static const NamedDecl* TypeToDeclImpl(const Type* type, bool as_written) {
    // Get past all the 'class' and 'struct' prefixes, and namespaces.
    type = RemoveElaboration(type);
  
    // Read past SubstTemplateTypeParmType (this can happen if a
    // template function returns the tpl-arg type: e.g. for
    // 'T MyFn<T>() {...}; MyFn<X>.a', the type of MyFn<X> will be a Subst.
    type = RemoveSubstTemplateTypeParm(type);
  
    CHECK_(!isa<ObjCObjectType>(type) && "IWYU doesn't support Objective-C");

Ie the beginning is being too explicit, testing for very specific sugar type nodes kinds, in a very specific order, just to skip over them.

That makes it very fragile against clang changes.

You can instead just use `getAs` to step over them in a generic fashion.

I don't think this one gets broken by this MR, but I am very confident it will get broken by another patch I have.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112374/new/

https://reviews.llvm.org/D112374



More information about the lldb-commits mailing list