[PATCH] D136886: [clang] [ASTImporter] RFC: Correct importer to not duplicate sugared types

Vince Bridgers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 29 13:44:45 PDT 2022


vabridgers added a subscriber: gamesh411.
vabridgers added a comment.

Adding more information, seems this patch's "hack" returns the following

QualType(T, 0).getDesugaredType(T->getDecl()->getASTContext()); ->

  ConstantArrayType 0x11413090 'struct __va_list_tag[1]' imported 1 
  `-RecordType 0x11412ed0 'struct __va_list_tag' imported
    `-Record 0x11412e38 '__va_list_tag'

The recent change from @mizvekov returns 
T->desugar(); ->

  ElaboratedType 0x11442870 '__builtin_va_list' sugar imported
  `-TypedefType 0x11442840 '__builtin_va_list' sugar imported
    |-Typedef 0x114130e8 '__builtin_va_list'
    `-ConstantArrayType 0x11413090 'struct __va_list_tag[1]' imported 1 
      `-RecordType 0x11412ed0 'struct __va_list_tag' imported
        `-Record 0x11412e38 '__va_list_tag'

And the code prior to @mizvekov code returns the following...
T->getDecl()->getASTContext().getTypeDeclType(*ToDeclOrErr); ->

  TypedefType 0x11442bf0 'va_list' sugar
  |-Typedef 0x113d4ad0 'va_list'
  `-ElaboratedType 0x1136dbc0 '__builtin_va_list' sugar
    `-TypedefType 0x1136db90 '__builtin_va_list' sugar
      |-Typedef 0x1136db38 '__builtin_va_list'
      `-ConstantArrayType 0x1136dae0 'struct __va_list_tag[1]' 1 
        `-RecordType 0x1136d920 'struct __va_list_tag'
          `-Record 0x1136d898 '__va_list_tag'

Should import desugar types to a canonical underlying type free of syntactic sugar? That's not clear to me at least. @gamesh411 pointed out in our debug session that there are sections of code that iteratively strip sugar until there's no more sugar left wrapping the type. But there's at least one instance where only a single level of sugar is removed.

OTOH, I did find a section of code where va_list is not desugared - looks like for diagnostic purposes - maybe this is a reason to use a solution following @balazske's finding.

Any suggestions on how to proceed with this?

Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136886



More information about the cfe-commits mailing list