[PATCH] D55447: [Sema] Fix Modified Type in address_space AttributedType

Leonard Chan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 10 16:55:23 PST 2018


leonardchan added inline comments.


================
Comment at: clang/tools/libclang/CXType.cpp:132
+      if (!(TU->ParsingOptions & CXTranslationUnit_IncludeAttributedTypes) &&
+          ATT->getAttrKind() != attr::AddressSpace) {
         return MakeCXType(ATT->getModifiedType(), TU);
----------------
aaron.ballman wrote:
> leonardchan wrote:
> > aaron.ballman wrote:
> > > This change seems surprising -- if the parsing options say the caller does not want attributed types, why are we returning one anyway for address space?
> > This has to do with ensuring `clang_getAddressSpace` still returns the proper address_space. It does this by essentially checking the qualifiers of the type, which we now attach to the `AttributedType` whereas before it was attached to the modified type.
> > 
> > This extra condition is necessary for ensuring that calling `clang_getAddressSpace` points to the qualified AttributedType instead of the unqualified modified type.
> My fear is that this will be breaking assumptions in third-party code. If someone disables `CXTranslationUnit_IncludeAttributedTypes`, they are unlikely to expect to receive an `AttributedType` and may react poorly to it.
Instead check if the type is address_space attributed and apply the qualifiers the modified type.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55447





More information about the cfe-commits mailing list