[PATCH] D63954: Add lifetime categories attributes

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 1 09:08:41 PDT 2019


aaron.ballman added inline comments.


================
Comment at: clang/lib/Sema/SemaDeclAttr.cpp:4553
+  // we always add (and check) the attribute to the cannonical decl.
+  D = D->getCanonicalDecl();
+  if(AL.getKind() ==  ParsedAttr::AT_Owner) {
----------------
xazax.hun wrote:
> aaron.ballman wrote:
> > Will this work? What happens if we see a forward declaration with this attribute first and then see the canonical declaration later? I suspect this work needs to be done when merging declaration attributes instead.
> For `TagDecl`s the canonical decl is the first declaration:
> ```
> TagDecl *TagDecl::getCanonicalDecl() { return getFirstDecl(); }
> ```
> 
> So I suspect we can never see a non-canonical declaration first. And once we see the canonical declaration it remains the same no matter how many new declaration do we see.
This is the scenario I am worried about:
```
struct [[whatever]] Foo;
struct Foo {};
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63954





More information about the cfe-commits mailing list