xazax.hun 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) { ---------------- aaron.ballman wrote: > 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 {}; > ``` This works well as the forward declaration is the canonical declaration since it is the first declaration in the redecl chain. A declaration being canonical or being a definition are two independent properties. The only caveat here is that the users of these attributes always need to query the attribute of the canonical decl. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D63954/new/ https://reviews.llvm.org/D63954 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits