[PATCH] D84005: Introduce ns_error_domain attribute.

Michael Forster via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 29 05:00:27 PDT 2020


MForster added inline comments.


================
Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5350
+
+  D->addAttr(::new (S.Context)
+                 NSErrorDomainAttr(S.Context, AL, IdentLoc->Ident));
----------------
aaron.ballman wrote:
> MForster wrote:
> > aaron.ballman wrote:
> > > Shouldn't we also be validating that what we found is an NSString that has the correct properties? (That doesn't seem like it should be a change which risks breaking code based on what I understood from Doug's description.)
> > > Shouldn't we also be validating that what we found is an NSString that has the correct properties?
> > 
> > Is your suggestion to string-compare the name of the type?
> >>Shouldn't we also be validating that what we found is an NSString that has the correct properties?
> > Is your suggestion to string-compare the name of the type?
> 
> You should be able to compare the `QualType` of the resulting `VarDecl` against `ASTContext::getObjCNSStringType()` (accounting for qualifiers, pointers, etc).
Turns out that this didn't work well. `ASTContext::getObjCNSStringType()` is only initialized if ObjC string literals are instantiated without an `NSString` type being defined. In our case there is an `NSString` type, because we need to declare a global variable of that type.

I've resorted to a string comparison after all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005



More information about the cfe-commits mailing list