[PATCH] D70203: [AST] Attach comment in `/** doc */ typedef struct A {} B` to B as well as A.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 14 08:25:36 PST 2019


sammccall marked 2 inline comments as done.
sammccall added inline comments.


================
Comment at: clang/test/Index/annotate-comments-typedef.m:20
 } MyEnum;
-// CHECK: TypedefDecl=MyEnum:[[@LINE-1]]:3 (Definition) FullCommentAsHTML=[<p class="para-brief"> Documentation for MyEnum </p>] FullCommentAsXML=[<Typedef file="{{[^"]+}}annotate-comments-typedef.m" line="[[@LINE-1]]" column="3"><Name><anonymous></Name><USR>c:@EA at MyEnum</USR><Declaration>typedef enum MyEnum MyEnum</Declaration><Abstract><Para> Documentation for MyEnum </Para></Abstract></Typedef>]
+// CHECK: TypedefDecl=MyEnum:[[@LINE-1]]:3 (Definition) {{.*}} FullCommentAsHTML=[<p class="para-brief"> Documentation for MyEnum </p>] FullCommentAsXML=[<Typedef file="{{[^"]+}}annotate-comments-typedef.m" line="[[@LINE-1]]" column="3"><Name>MyEnum</Name><USR>c:@T at MyEnum</USR><Declaration>typedef enum MyEnum MyEnum</Declaration><Abstract><Para> Documentation for MyEnum </Para></Abstract></Typedef>]
 
----------------
kadircet wrote:
> sorry for being dense, what exactly is the change here ? it looks like comment was already being attributed to `MyEnum`. 
> As for the USR I agree that this looks a whole lot better, apparently for anon decls USR contains the name of the typedef decl instead.
> 
> What is the extra text that we don't care in between?
Yeah, most of this doesn't matter AFAIK and the test is just brittle, as lit tests are wont to be.

The {{.*}} is because the output now includes the RawComment= clause, that previously wasn't included. (Which I think is to do with the comment being immediately before the location?)

Previously the `Name` was `<anonymous>`, and now it's `MyEnum`. And the USR has changed as you noted.


================
Comment at: clang/test/Sema/warn-documentation.cpp:871
 
-// expected-warning at +1 {{empty paragraph passed to '\brief' command}}
+// expected-warning at +1 + {{empty paragraph passed to '\brief' command}}
 /// \brief\author Aaa
----------------
kadircet wrote:
> what is the ` + ` for ?
The warning is now emitted twice, once for the embedded struct definition and once for the typedef.
This isn't perfect but I don't think it's worth fixing. (Again, it's the existing behavior for a broken comment before `int a,b,c`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70203





More information about the cfe-commits mailing list