[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-06-06 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett closed this revision.
juliehockett added a comment.

Closed in r334103 .


https://reviews.llvm.org/D43667



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-06-05 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added inline comments.



Comment at: clang-doc/YAMLGenerator.cpp:265
+// and thus register the generator.
+volatile int YAMLGeneratorAnchorSource = 0;
+

ioeric wrote:
> nit: add `static`?
`static` declares it as file-local, and so the `extern` reference to this in 
Generators.cpp wouldn't be allowed.



Comment at: clang-doc/generators/YAMLGenerator.cpp:223
+
+template <> struct MappingTraits> {
+  static void mapping(IO , std::unique_ptr ) {

ioeric wrote:
> juliehockett wrote:
> > ioeric wrote:
> > > YAML mapping for `unique_ptr` is a bit unusual. I wonder whether this 
> > > would work all the time e.g. if the unique_ptr has not been allocated. 
> > Mmm yes it's a little weird -- that said, is there a better way emit the 
> > info given a pointer?
> Not sure what the initial intention was for using `unique_ptr` here, but one 
> option is to get rid of the `unique_ptr` and just store `CommentInfo` in the 
> structure. Another (less ideal) option is to check whether `I` is nullptr and 
> allocate when it's null (only when deserialization though; I think you could 
> tell this from `IO`); and you'd probably want to avoid the allocation when 
> the comment info is actually not present in `IO` (IIRC, mapping would be 
> called even when the info is not present).
Sorry this slipped through before -- it's a pointer because it has to be able 
to store itself (the other infos just store the `CommentInfo` directly, but 
each `CommentInfo` can have comment children). The pointer only appears there. 



Comment at: clang-doc/tool/ClangDocMain.cpp:221
+}
+std::error_code FileErr;
+llvm::raw_fd_ostream InfoOS(InfoPath.get(), FileErr, 
llvm::sys::fs::F_None);

ioeric wrote:
> nit: I wonder if you could merge creation of `InfoOS` into `getPath` so that 
> the helper function would just return `llvm::Expected`
You can't, because when you return `llvm::make_error` it invokes a copy 
constructor, which is deleted in `raw_ostream`s.


https://reviews.llvm.org/D43667



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-06-05 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 149997.
juliehockett marked 3 inline comments as done.
juliehockett added a comment.

Fixing comments


https://reviews.llvm.org/D43667

Files:
  clang-doc/CMakeLists.txt
  clang-doc/Generators.cpp
  clang-doc/Generators.h
  clang-doc/Representation.h
  clang-doc/YAMLGenerator.cpp
  clang-doc/tool/ClangDocMain.cpp
  test/clang-doc/yaml-comments.cpp
  test/clang-doc/yaml-namespace.cpp
  test/clang-doc/yaml-record.cpp

Index: test/clang-doc/yaml-record.cpp
===
--- /dev/null
+++ test/clang-doc/yaml-record.cpp
@@ -0,0 +1,250 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: cat %t/docs/A.yaml | FileCheck %s --check-prefix=CHECK-A
+// RUN: cat %t/docs/Bc.yaml | FileCheck %s --check-prefix=CHECK-BC
+// RUN: cat %t/docs/B.yaml | FileCheck %s --check-prefix=CHECK-B
+// RUN: cat %t/docs/C.yaml | FileCheck %s --check-prefix=CHECK-C
+// RUN: cat %t/docs/D.yaml | FileCheck %s --check-prefix=CHECK-D
+// RUN: cat %t/docs/E.yaml | FileCheck %s --check-prefix=CHECK-E
+// RUN: cat %t/docs/E/ProtectedMethod.yaml | FileCheck %s --check-prefix=CHECK-EPM
+// RUN: cat %t/docs/E/E.yaml | FileCheck %s --check-prefix=CHECK-ECON
+// RUN: cat %t/docs/E/'~E.yaml' | FileCheck %s --check-prefix=CHECK-EDES
+// RUN: cat %t/docs/F.yaml | FileCheck %s --check-prefix=CHECK-F
+// RUN: cat %t/docs/X.yaml | FileCheck %s --check-prefix=CHECK-X
+// RUN: cat %t/docs/X/Y.yaml | FileCheck %s --check-prefix=CHECK-Y
+// RUN: cat %t/docs/H.yaml | FileCheck %s --check-prefix=CHECK-H
+// RUN: cat %t/docs/H/I.yaml | FileCheck %s --check-prefix=CHECK-I
+
+union A { int X; int Y; };
+
+// CHECK-A: ---
+// CHECK-A-NEXT: USR: 'ACE81AFA6627B4CEF2B456FB6E1252925674AF7E'
+// CHECK-A-NEXT: Name:'A'
+// CHECK-A-NEXT: DefLocation: 
+// CHECK-A-NEXT:   LineNumber:  21
+// CHECK-A-NEXT:   Filename:'{{.*}}'
+// CHECK-A-NEXT: TagType: Union
+// CHECK-A-NEXT: Members: 
+// CHECK-A-NEXT:   - Type:
+// CHECK-A-NEXT:   Name:'int'
+// CHECK-A-NEXT: Name:'X'
+// CHECK-A-NEXT:   - Type:
+// CHECK-A-NEXT:   Name:'int'
+// CHECK-A-NEXT: Name:'Y'
+// CHECK-A-NEXT: ...
+
+
+enum B { X, Y };
+
+// CHECK-B: ---
+// CHECK-B-NEXT: USR: 'FC07BD34D5E77782C263FA97929EA8753740'
+// CHECK-B-NEXT: Name:'B'
+// CHECK-B-NEXT: DefLocation: 
+// CHECK-B-NEXT:   LineNumber:  40
+// CHECK-B-NEXT:   Filename:'{{.*}}'
+// CHECK-B-NEXT: Members: 
+// CHECK-B-NEXT:   - 'X'
+// CHECK-B-NEXT:   - 'Y'
+// CHECK-B-NEXT: ...
+
+enum class Bc { A, B };
+
+// CHECK-BC: ---
+// CHECK-BC-NEXT: USR: '1E3438A08BA22025C0B46289FF0686F92C8924C5'
+// CHECK-BC-NEXT: Name:'Bc'
+// CHECK-BC-NEXT: DefLocation: 
+// CHECK-BC-NEXT:   LineNumber:  53
+// CHECK-BC-NEXT:   Filename:'{{.*}}'
+// CHECK-BC-NEXT: Scoped:  true
+// CHECK-BC-NEXT: Members: 
+// CHECK-BC-NEXT:   - 'A'
+// CHECK-BC-NEXT:   - 'B'
+// CHECK-BC-NEXT: ...
+
+struct C { int i; };
+
+// CHECK-C: ---
+// CHECK-C-NEXT: USR: '06B5F6A19BA9F6A832E127C9968282B94619B210'
+// CHECK-C-NEXT: Name:'C'
+// CHECK-C-NEXT: DefLocation: 
+// CHECK-C-NEXT:   LineNumber:  67
+// CHECK-C-NEXT:   Filename:'{{.*}}'
+// CHECK-C-NEXT: Members: 
+// CHECK-C-NEXT:   - Type:
+// CHECK-C-NEXT:   Name:'int'
+// CHECK-C-NEXT: Name:'i'
+// CHECK-C-NEXT: ...
+
+class D {};
+
+// CHECK-D: ---
+// CHECK-D-NEXT: USR: '0921737541208B8FA9BB42B60F78AC1D779AA054'
+// CHECK-D-NEXT: Name:'D'
+// CHECK-D-NEXT: DefLocation: 
+// CHECK-D-NEXT:   LineNumber:  81
+// CHECK-D-NEXT:   Filename:'{{.*}}'
+// CHECK-D-NEXT: TagType: Class
+// CHECK-D-NEXT: ...
+
+class E {
+public:
+  E() {}
+
+// CHECK-ECON: ---
+// CHECK-ECON-NEXT: USR: 'DEB4AC1CD9253CD9EF7FBE6BCAC506D77984ABD4'
+// CHECK-ECON-NEXT: Name:'E'
+// CHECK-ECON-NEXT: Namespace:   
+// CHECK-ECON-NEXT:   - Type:Record
+// CHECK-ECON-NEXT: Name:'E'
+// CHECK-ECON-NEXT: USR: '289584A8E0FF4178A794622A547AA622503967A1'
+// CHECK-ECON-NEXT: DefLocation:
+// CHECK-ECON-NEXT:   LineNumber:  94
+// CHECK-ECON-NEXT:   Filename:'{{.*}}'
+// CHECK-ECON-NEXT: IsMethod:true
+// CHECK-ECON-NEXT: Parent:  
+// CHECK-ECON-NEXT:   Type:Record
+// CHECK-ECON-NEXT:   Name:'E'
+// CHECK-ECON-NEXT:   USR: '289584A8E0FF4178A794622A547AA622503967A1'
+// CHECK-ECON-NEXT: ReturnType:  
+// CHECK-ECON-NEXT:   Type:
+// CHECK-ECON-NEXT: Name:'void'
+// CHECK-ECON-NEXT: ...
+  
+  

[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-06-04 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 149856.
juliehockett marked 4 inline comments as done.
juliehockett added a comment.

Addressing comments


https://reviews.llvm.org/D43667

Files:
  clang-doc/CMakeLists.txt
  clang-doc/Generators.cpp
  clang-doc/Generators.h
  clang-doc/Representation.h
  clang-doc/YAMLGenerator.cpp
  clang-doc/tool/ClangDocMain.cpp
  test/clang-doc/yaml-comments.cpp
  test/clang-doc/yaml-namespace.cpp
  test/clang-doc/yaml-record.cpp

Index: test/clang-doc/yaml-record.cpp
===
--- /dev/null
+++ test/clang-doc/yaml-record.cpp
@@ -0,0 +1,250 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: cat %t/docs/A.yaml | FileCheck %s --check-prefix=CHECK-A
+// RUN: cat %t/docs/Bc.yaml | FileCheck %s --check-prefix=CHECK-BC
+// RUN: cat %t/docs/B.yaml | FileCheck %s --check-prefix=CHECK-B
+// RUN: cat %t/docs/C.yaml | FileCheck %s --check-prefix=CHECK-C
+// RUN: cat %t/docs/D.yaml | FileCheck %s --check-prefix=CHECK-D
+// RUN: cat %t/docs/E.yaml | FileCheck %s --check-prefix=CHECK-E
+// RUN: cat %t/docs/E/ProtectedMethod.yaml | FileCheck %s --check-prefix=CHECK-EPM
+// RUN: cat %t/docs/E/E.yaml | FileCheck %s --check-prefix=CHECK-ECON
+// RUN: cat %t/docs/E/'~E.yaml' | FileCheck %s --check-prefix=CHECK-EDES
+// RUN: cat %t/docs/F.yaml | FileCheck %s --check-prefix=CHECK-F
+// RUN: cat %t/docs/X.yaml | FileCheck %s --check-prefix=CHECK-X
+// RUN: cat %t/docs/X/Y.yaml | FileCheck %s --check-prefix=CHECK-Y
+// RUN: cat %t/docs/H.yaml | FileCheck %s --check-prefix=CHECK-H
+// RUN: cat %t/docs/H/I.yaml | FileCheck %s --check-prefix=CHECK-I
+
+union A { int X; int Y; };
+
+// CHECK-A: ---
+// CHECK-A-NEXT: USR: 'ACE81AFA6627B4CEF2B456FB6E1252925674AF7E'
+// CHECK-A-NEXT: Name:'A'
+// CHECK-A-NEXT: DefLocation: 
+// CHECK-A-NEXT:   LineNumber:  21
+// CHECK-A-NEXT:   Filename:'{{.*}}'
+// CHECK-A-NEXT: TagType: Union
+// CHECK-A-NEXT: Members: 
+// CHECK-A-NEXT:   - Type:
+// CHECK-A-NEXT:   Name:'int'
+// CHECK-A-NEXT: Name:'X'
+// CHECK-A-NEXT:   - Type:
+// CHECK-A-NEXT:   Name:'int'
+// CHECK-A-NEXT: Name:'Y'
+// CHECK-A-NEXT: ...
+
+
+enum B { X, Y };
+
+// CHECK-B: ---
+// CHECK-B-NEXT: USR: 'FC07BD34D5E77782C263FA97929EA8753740'
+// CHECK-B-NEXT: Name:'B'
+// CHECK-B-NEXT: DefLocation: 
+// CHECK-B-NEXT:   LineNumber:  40
+// CHECK-B-NEXT:   Filename:'{{.*}}'
+// CHECK-B-NEXT: Members: 
+// CHECK-B-NEXT:   - 'X'
+// CHECK-B-NEXT:   - 'Y'
+// CHECK-B-NEXT: ...
+
+enum class Bc { A, B };
+
+// CHECK-BC: ---
+// CHECK-BC-NEXT: USR: '1E3438A08BA22025C0B46289FF0686F92C8924C5'
+// CHECK-BC-NEXT: Name:'Bc'
+// CHECK-BC-NEXT: DefLocation: 
+// CHECK-BC-NEXT:   LineNumber:  53
+// CHECK-BC-NEXT:   Filename:'{{.*}}'
+// CHECK-BC-NEXT: Scoped:  true
+// CHECK-BC-NEXT: Members: 
+// CHECK-BC-NEXT:   - 'A'
+// CHECK-BC-NEXT:   - 'B'
+// CHECK-BC-NEXT: ...
+
+struct C { int i; };
+
+// CHECK-C: ---
+// CHECK-C-NEXT: USR: '06B5F6A19BA9F6A832E127C9968282B94619B210'
+// CHECK-C-NEXT: Name:'C'
+// CHECK-C-NEXT: DefLocation: 
+// CHECK-C-NEXT:   LineNumber:  67
+// CHECK-C-NEXT:   Filename:'{{.*}}'
+// CHECK-C-NEXT: Members: 
+// CHECK-C-NEXT:   - Type:
+// CHECK-C-NEXT:   Name:'int'
+// CHECK-C-NEXT: Name:'i'
+// CHECK-C-NEXT: ...
+
+class D {};
+
+// CHECK-D: ---
+// CHECK-D-NEXT: USR: '0921737541208B8FA9BB42B60F78AC1D779AA054'
+// CHECK-D-NEXT: Name:'D'
+// CHECK-D-NEXT: DefLocation: 
+// CHECK-D-NEXT:   LineNumber:  81
+// CHECK-D-NEXT:   Filename:'{{.*}}'
+// CHECK-D-NEXT: TagType: Class
+// CHECK-D-NEXT: ...
+
+class E {
+public:
+  E() {}
+
+// CHECK-ECON: ---
+// CHECK-ECON-NEXT: USR: 'DEB4AC1CD9253CD9EF7FBE6BCAC506D77984ABD4'
+// CHECK-ECON-NEXT: Name:'E'
+// CHECK-ECON-NEXT: Namespace:   
+// CHECK-ECON-NEXT:   - Type:Record
+// CHECK-ECON-NEXT: Name:'E'
+// CHECK-ECON-NEXT: USR: '289584A8E0FF4178A794622A547AA622503967A1'
+// CHECK-ECON-NEXT: DefLocation:
+// CHECK-ECON-NEXT:   LineNumber:  94
+// CHECK-ECON-NEXT:   Filename:'{{.*}}'
+// CHECK-ECON-NEXT: IsMethod:true
+// CHECK-ECON-NEXT: Parent:  
+// CHECK-ECON-NEXT:   Type:Record
+// CHECK-ECON-NEXT:   Name:'E'
+// CHECK-ECON-NEXT:   USR: '289584A8E0FF4178A794622A547AA622503967A1'
+// CHECK-ECON-NEXT: ReturnType:  
+// CHECK-ECON-NEXT:   Type:
+// CHECK-ECON-NEXT: Name:'void'
+// CHECK-ECON-NEXT: ...
+  

[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-06-04 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clang-doc/Generators.h:25
+//
+// Derived classes must implement the generate*ForInfo methods, which should
+// emit documentation for the specified info in the relevant format. This is

nit: This seems a bit redundant as the virtual method has been set to 0. 



Comment at: clang-doc/Generators.h:49
+
+static GeneratorRegistry::Add YAML(YAMLGenerator::Format,
+  "Generator for YAML 
output.");

I think this should go into the cpp file, and you might need the anchor 
source/destination trick to force the plugin to be linked. See example:
https://github.com/llvm-mirror/clang/blob/master/lib/Tooling/StandaloneExecution.cpp#L88
https://github.com/llvm-mirror/clang/blob/master/lib/Tooling/Execution.cpp#L111

 `YAMLGenerator` could potentially also live in cpp file if you don't expect it 
to be used directly. 



Comment at: clang-doc/generators/YAMLGenerator.cpp:223
+
+template <> struct MappingTraits> {
+  static void mapping(IO , std::unique_ptr ) {

juliehockett wrote:
> ioeric wrote:
> > YAML mapping for `unique_ptr` is a bit unusual. I wonder whether this would 
> > work all the time e.g. if the unique_ptr has not been allocated. 
> Mmm yes it's a little weird -- that said, is there a better way emit the info 
> given a pointer?
Not sure what the initial intention was for using `unique_ptr` here, but one 
option is to get rid of the `unique_ptr` and just store `CommentInfo` in the 
structure. Another (less ideal) option is to check whether `I` is nullptr and 
allocate when it's null (only when deserialization though; I think you could 
tell this from `IO`); and you'd probably want to avoid the allocation when the 
comment info is actually not present in `IO` (IIRC, mapping would be called 
even when the info is not present).



Comment at: clang-doc/tool/ClangDocMain.cpp:191
 
-  // Reducing phase
+  auto G = doc::findGeneratorByName(Format);
+  if (!G) {

If you want to fail early when `Format` is invalid, maybe move it a bit more 
earlier, e.g. before generating `MapOutput`?



Comment at: clang-doc/tool/ClangDocMain.cpp:221
+}
+std::error_code FileErr;
+llvm::raw_fd_ostream InfoOS(InfoPath.get(), FileErr, 
llvm::sys::fs::F_None);

nit: I wonder if you could merge creation of `InfoOS` into `getPath` so that 
the helper function would just return `llvm::Expected`


https://reviews.llvm.org/D43667



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-05-31 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 149373.

https://reviews.llvm.org/D43667

Files:
  clang-doc/CMakeLists.txt
  clang-doc/Generators.cpp
  clang-doc/Generators.h
  clang-doc/Representation.h
  clang-doc/YAMLGenerator.cpp
  clang-doc/tool/ClangDocMain.cpp
  test/clang-doc/yaml-comments.cpp
  test/clang-doc/yaml-namespace.cpp
  test/clang-doc/yaml-record.cpp

Index: test/clang-doc/yaml-record.cpp
===
--- /dev/null
+++ test/clang-doc/yaml-record.cpp
@@ -0,0 +1,250 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: cat %t/docs/A.yaml | FileCheck %s --check-prefix=CHECK-A
+// RUN: cat %t/docs/Bc.yaml | FileCheck %s --check-prefix=CHECK-BC
+// RUN: cat %t/docs/B.yaml | FileCheck %s --check-prefix=CHECK-B
+// RUN: cat %t/docs/C.yaml | FileCheck %s --check-prefix=CHECK-C
+// RUN: cat %t/docs/D.yaml | FileCheck %s --check-prefix=CHECK-D
+// RUN: cat %t/docs/E.yaml | FileCheck %s --check-prefix=CHECK-E
+// RUN: cat %t/docs/E/ProtectedMethod.yaml | FileCheck %s --check-prefix=CHECK-EPM
+// RUN: cat %t/docs/E/E.yaml | FileCheck %s --check-prefix=CHECK-ECON
+// RUN: cat %t/docs/E/'~E.yaml' | FileCheck %s --check-prefix=CHECK-EDES
+// RUN: cat %t/docs/F.yaml | FileCheck %s --check-prefix=CHECK-F
+// RUN: cat %t/docs/X.yaml | FileCheck %s --check-prefix=CHECK-X
+// RUN: cat %t/docs/X/Y.yaml | FileCheck %s --check-prefix=CHECK-Y
+// RUN: cat %t/docs/H.yaml | FileCheck %s --check-prefix=CHECK-H
+// RUN: cat %t/docs/H/I.yaml | FileCheck %s --check-prefix=CHECK-I
+
+union A { int X; int Y; };
+
+// CHECK-A: ---
+// CHECK-A-NEXT: USR: 'ACE81AFA6627B4CEF2B456FB6E1252925674AF7E'
+// CHECK-A-NEXT: Name:'A'
+// CHECK-A-NEXT: DefLocation: 
+// CHECK-A-NEXT:   LineNumber:  21
+// CHECK-A-NEXT:   Filename:'{{.*}}'
+// CHECK-A-NEXT: TagType: Union
+// CHECK-A-NEXT: Members: 
+// CHECK-A-NEXT:   - Type:
+// CHECK-A-NEXT:   Name:'int'
+// CHECK-A-NEXT: Name:'X'
+// CHECK-A-NEXT:   - Type:
+// CHECK-A-NEXT:   Name:'int'
+// CHECK-A-NEXT: Name:'Y'
+// CHECK-A-NEXT: ...
+
+
+enum B { X, Y };
+
+// CHECK-B: ---
+// CHECK-B-NEXT: USR: 'FC07BD34D5E77782C263FA97929EA8753740'
+// CHECK-B-NEXT: Name:'B'
+// CHECK-B-NEXT: DefLocation: 
+// CHECK-B-NEXT:   LineNumber:  40
+// CHECK-B-NEXT:   Filename:'{{.*}}'
+// CHECK-B-NEXT: Members: 
+// CHECK-B-NEXT:   - 'X'
+// CHECK-B-NEXT:   - 'Y'
+// CHECK-B-NEXT: ...
+
+enum class Bc { A, B };
+
+// CHECK-BC: ---
+// CHECK-BC-NEXT: USR: '1E3438A08BA22025C0B46289FF0686F92C8924C5'
+// CHECK-BC-NEXT: Name:'Bc'
+// CHECK-BC-NEXT: DefLocation: 
+// CHECK-BC-NEXT:   LineNumber:  53
+// CHECK-BC-NEXT:   Filename:'{{.*}}'
+// CHECK-BC-NEXT: Scoped:  true
+// CHECK-BC-NEXT: Members: 
+// CHECK-BC-NEXT:   - 'A'
+// CHECK-BC-NEXT:   - 'B'
+// CHECK-BC-NEXT: ...
+
+struct C { int i; };
+
+// CHECK-C: ---
+// CHECK-C-NEXT: USR: '06B5F6A19BA9F6A832E127C9968282B94619B210'
+// CHECK-C-NEXT: Name:'C'
+// CHECK-C-NEXT: DefLocation: 
+// CHECK-C-NEXT:   LineNumber:  67
+// CHECK-C-NEXT:   Filename:'{{.*}}'
+// CHECK-C-NEXT: Members: 
+// CHECK-C-NEXT:   - Type:
+// CHECK-C-NEXT:   Name:'int'
+// CHECK-C-NEXT: Name:'i'
+// CHECK-C-NEXT: ...
+
+class D {};
+
+// CHECK-D: ---
+// CHECK-D-NEXT: USR: '0921737541208B8FA9BB42B60F78AC1D779AA054'
+// CHECK-D-NEXT: Name:'D'
+// CHECK-D-NEXT: DefLocation: 
+// CHECK-D-NEXT:   LineNumber:  81
+// CHECK-D-NEXT:   Filename:'{{.*}}'
+// CHECK-D-NEXT: TagType: Class
+// CHECK-D-NEXT: ...
+
+class E {
+public:
+  E() {}
+
+// CHECK-ECON: ---
+// CHECK-ECON-NEXT: USR: 'DEB4AC1CD9253CD9EF7FBE6BCAC506D77984ABD4'
+// CHECK-ECON-NEXT: Name:'E'
+// CHECK-ECON-NEXT: Namespace:   
+// CHECK-ECON-NEXT:   - Type:Record
+// CHECK-ECON-NEXT: Name:'E'
+// CHECK-ECON-NEXT: USR: '289584A8E0FF4178A794622A547AA622503967A1'
+// CHECK-ECON-NEXT: DefLocation:
+// CHECK-ECON-NEXT:   LineNumber:  94
+// CHECK-ECON-NEXT:   Filename:'{{.*}}'
+// CHECK-ECON-NEXT: IsMethod:true
+// CHECK-ECON-NEXT: Parent:  
+// CHECK-ECON-NEXT:   Type:Record
+// CHECK-ECON-NEXT:   Name:'E'
+// CHECK-ECON-NEXT:   USR: '289584A8E0FF4178A794622A547AA622503967A1'
+// CHECK-ECON-NEXT: ReturnType:  
+// CHECK-ECON-NEXT:   Type:
+// CHECK-ECON-NEXT: Name:'void'
+// CHECK-ECON-NEXT: ...
+  
+  ~E() {}
+  
+// CHECK-EDES: ---
+// CHECK-EDES-NEXT: USR: 

[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-05-18 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added inline comments.



Comment at: clang-doc/generators/Generators.h:49
+
+class GeneratorFactory {
+public:

ioeric wrote:
> ioeric wrote:
> > Please add documentation and explain why this is needed. 
> If you plan to plugin in more generators (e.g. in your customized build of 
> clang-doc), consider using `llvm::Registry` which allows you to link in new 
> generators without having to modify code. See 
> `clang::clangd::URISchemeRegistry` for sample usage.
Oh cool -- didn't know about that. Thanks!



Comment at: clang-doc/generators/YAMLGenerator.cpp:223
+
+template <> struct MappingTraits {
+  static void mapping(IO , std::unique_ptr ) {

ioeric wrote:
> YAML mapping for `unique_ptr` is a bit unusual. I wonder whether this would 
> work all the time e.g. if the unique_ptr has not been allocated. 
Mmm yes it's a little weird -- that said, is there a better way emit the info 
given a pointer?


https://reviews.llvm.org/D43667



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-05-18 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 147606.
juliehockett marked 11 inline comments as done.
juliehockett edited the summary of this revision.
juliehockett added a comment.

Updating for better integration with MR framework, the generator now takes in 
an info and an output stream and emits the YAML to that stream. Each info is 
emitted to its own YAML file.


https://reviews.llvm.org/D43667

Files:
  clang-doc/CMakeLists.txt
  clang-doc/Representation.h
  clang-doc/generators/CMakeLists.txt
  clang-doc/generators/Generators.h
  clang-doc/generators/YAMLGenerator.cpp
  clang-doc/tool/CMakeLists.txt
  clang-doc/tool/ClangDocMain.cpp
  test/clang-doc/yaml-comments.cpp
  test/clang-doc/yaml-namespace.cpp
  test/clang-doc/yaml-record.cpp

Index: test/clang-doc/yaml-record.cpp
===
--- /dev/null
+++ test/clang-doc/yaml-record.cpp
@@ -0,0 +1,212 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: cat %t/docs/yaml/docs.yaml | FileCheck %s
+
+union A { int X; int Y; };
+
+enum B { X, Y };
+
+enum class Bc { A, B };
+
+struct C { int i; };
+
+class D {};
+
+class E {
+public:
+  E() {}
+  ~E() {}
+
+protected:
+  void ProtectedMethod();
+};
+
+void E::ProtectedMethod() {}
+
+class F : virtual private D, public E {};
+
+class X {
+  class Y {};
+};
+
+void H() {
+  class I {};
+}
+
+// CHECK: ---
+// CHECK-NEXT: Records: 
+// CHECK-NEXT:   - USR: 'ACE81AFA6627B4CEF2B456FB6E1252925674AF7E'
+// CHECK-NEXT: Name:'A'
+// CHECK-NEXT: DefLocation: 
+// CHECK-NEXT:   LineNumber:  8
+// CHECK-NEXT:   Filename:'{{.*}}'
+// CHECK-NEXT: TagType: Union
+// CHECK-NEXT: Members: 
+// CHECK-NEXT:   - Type:
+// CHECK-NEXT:   UnresolvedName:  'int'
+// CHECK-NEXT: Name:'A::X'
+// CHECK-NEXT:   - Type:
+// CHECK-NEXT:   UnresolvedName:  'int'
+// CHECK-NEXT: Name:'A::Y'
+// CHECK-NEXT:   - USR: '06B5F6A19BA9F6A832E127C9968282B94619B210'
+// CHECK-NEXT: Name:'C'
+// CHECK-NEXT: DefLocation: 
+// CHECK-NEXT:   LineNumber:  14
+// CHECK-NEXT:   Filename:'{{.*}}'
+// CHECK-NEXT: Members: 
+// CHECK-NEXT:   - Type:
+// CHECK-NEXT:   UnresolvedName:  'int'
+// CHECK-NEXT: Name:'C::i'
+// CHECK-NEXT:   - USR: '0921737541208B8FA9BB42B60F78AC1D779AA054'
+// CHECK-NEXT: Name:'D'
+// CHECK-NEXT: Records: 
+// CHECK-NEXT:   - Type:Record
+// CHECK-NEXT: USR: 'E3B54702FABFF4037025BA194FC27C47006330B5'
+// CHECK-NEXT: DefLocation: 
+// CHECK-NEXT:   LineNumber:  16
+// CHECK-NEXT:   Filename:'{{.*}}'
+// CHECK-NEXT: TagType: Class
+// CHECK-NEXT:   - USR: '289584A8E0FF4178A794622A547AA622503967A1'
+// CHECK-NEXT: Name:'E'
+// CHECK-NEXT: Records: 
+// CHECK-NEXT:   - Type:Record
+// CHECK-NEXT: USR: 'E3B54702FABFF4037025BA194FC27C47006330B5'
+// CHECK-NEXT: Functions:   
+// CHECK-NEXT:   - Type:Function
+// CHECK-NEXT: USR: 'DEB4AC1CD9253CD9EF7FBE6BCAC506D77984ABD4'
+// CHECK-NEXT:   - Type:Function
+// CHECK-NEXT: USR: 'DEB4AC1CD9253CD9EF7FBE6BCAC506D77984ABD4'
+// CHECK-NEXT:   - Type:Function
+// CHECK-NEXT: USR: 'BD2BDEBD423F80BACCEA75DE6D6622D355FC2D17'
+// CHECK-NEXT:   - Type:Function
+// CHECK-NEXT: USR: 'BD2BDEBD423F80BACCEA75DE6D6622D355FC2D17'
+// CHECK-NEXT:   - Type:Function
+// CHECK-NEXT: USR: '5093D428CDC62096A67547BA52566E4FB9404EEE'
+// CHECK-NEXT:   - Type:Function
+// CHECK-NEXT: USR: '5093D428CDC62096A67547BA52566E4FB9404EEE'
+// CHECK-NEXT: DefLocation: 
+// CHECK-NEXT:   LineNumber:  18
+// CHECK-NEXT:   Filename:'{{.*}}'
+// CHECK-NEXT: TagType: Class
+// CHECK-NEXT:   - USR: 'E3B54702FABFF4037025BA194FC27C47006330B5'
+// CHECK-NEXT: Name:'F'
+// CHECK-NEXT: DefLocation: 
+// CHECK-NEXT:   LineNumber:  29
+// CHECK-NEXT:   Filename:'{{.*}}'
+// CHECK-NEXT: TagType: Class
+// CHECK-NEXT: Parents: 
+// CHECK-NEXT:   - Type:Record
+// CHECK-NEXT: USR: '289584A8E0FF4178A794622A547AA622503967A1'
+// CHECK-NEXT: VirtualParents:  
+// CHECK-NEXT:   - Type:Record
+// CHECK-NEXT: USR: '0921737541208B8FA9BB42B60F78AC1D779AA054'
+// CHECK-NEXT:   - USR:   

[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-05-17 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clang-doc/Representation.h:238
 
+  // Non-const accessors for YAML output.
+  std::vector () { return NamespaceInfos; }

There are two alternatives to avoid this:
1) Pull the info storage into a separate struct e.g. `struct InfoSet::Infos`, 
and add a constructor setter `setInfos(Infos &&)`;
2) `friend yaml::MappingTraits;`



Comment at: clang-doc/generators/CMakeLists.txt:3
+
+add_clang_library(clangDocGenerators
+  YAMLGenerator.cpp

Why is this a separate library?



Comment at: clang-doc/generators/Generators.h:24
+
+class Generator {
+public:

Please add documentation.



Comment at: clang-doc/generators/Generators.h:26
+public:
+  Generator(std::unique_ptr , llvm::StringRef Root,
+llvm::StringRef Format)

The parameters are not trivial. Could you add documentation?



Comment at: clang-doc/generators/Generators.h:26
+public:
+  Generator(std::unique_ptr , llvm::StringRef Root,
+llvm::StringRef Format)

ioeric wrote:
> The parameters are not trivial. Could you add documentation?
Passing a reference to a unique pointer seems a bit strange. If `Generator` 
doesn't own IS, it should be passed by reference; otherwise, this should be 
passed by value.



Comment at: clang-doc/generators/Generators.h:28
+llvm::StringRef Format)
+  : IS(IS), Root(Root), Format(Format) {}
+  virtual ~Generator() = default;

Have you considered passing a output stream instead of passing in a directory 
and writing output to a hardcoded name? And I think `Root` (or a output stream) 
should be passed in via `generate`instead the constructor. 



Comment at: clang-doc/generators/Generators.h:39
+
+class YAMLGenerator : public Generator {
+public:

Please add documentation.



Comment at: clang-doc/generators/Generators.h:49
+
+class GeneratorFactory {
+public:

Please add documentation and explain why this is needed. 



Comment at: clang-doc/generators/Generators.h:49
+
+class GeneratorFactory {
+public:

ioeric wrote:
> Please add documentation and explain why this is needed. 
If you plan to plugin in more generators (e.g. in your customized build of 
clang-doc), consider using `llvm::Registry` which allows you to link in new 
generators without having to modify code. See 
`clang::clangd::URISchemeRegistry` for sample usage.



Comment at: clang-doc/generators/YAMLGenerator.cpp:223
+
+template <> struct MappingTraits {
+  static void mapping(IO , std::unique_ptr ) {

YAML mapping for `unique_ptr` is a bit unusual. I wonder whether this would 
work all the time e.g. if the unique_ptr has not been allocated. 



Comment at: clang-doc/generators/YAMLGenerator.cpp:250
+  std::error_code OutErrorInfo;
+  llvm::raw_fd_ostream OS(Path, OutErrorInfo, llvm::sys::fs::F_None);
+  if (OutErrorInfo != OK) {

Note that this would only work on real file system. You would not be able to 
run this in unit tests, and some tool executors run on virtual file system as 
well, so if you do go with directory, you would also want to pass in a VFS 
(`clang/Basic/VirtualFileSystem.h`).


https://reviews.llvm.org/D43667



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-04-10 Thread Athos via Phabricator via cfe-commits
Athosvk added a comment.

In https://reviews.llvm.org/D43667#1063049, @juliehockett wrote:

> In https://reviews.llvm.org/D43667#1062746, @Athosvk wrote:
>
> > I'm a bit late on this, but I'd say that YAML is usually not a 'final' 
> > format. What would be the use-cases for this? And if is meant as an 
> > alternative intermediate format, why not instead of having one big file, 
> > have one file per input file? Just wondering what the particular motivation 
> > for that could be
>
>
> The idea is that it's a generally-consumable output format, and so could be 
> interpreted by external software fairly trivially. The bitsream format is 
> compact and good for things that will live entirely in the clang-doc tool, 
> but is harder to deal with outside that scope. YAML bridges that gap.


That's what I expected :).

The primary advantage of one file per output to us was granularity. That allows 
you to do incremental builds and distribute them at this stage (locally over 
multiple cores, but also remotely if need be).


https://reviews.llvm.org/D43667



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-04-10 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added a comment.

In https://reviews.llvm.org/D43667#1062746, @Athosvk wrote:

> I'm a bit late on this, but I'd say that YAML is usually not a 'final' 
> format. What would be the use-cases for this? And if is meant as an 
> alternative intermediate format, why not instead of having one big file, have 
> one file per input file? Just wondering what the particular motivation for 
> that could be


The idea is that it's a generally-consumable output format, and so could be 
interpreted by external software fairly trivially. The bitsream format is 
compact and good for things that will live entirely in the clang-doc tool, but 
is harder to deal with outside that scope. YAML bridges that gap.

I haven't thought too much about splitting it up, but it might make sense, 
given that the one file could get very large. By file might work--let me play 
with it a bit to see what makes the most sense.


https://reviews.llvm.org/D43667



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-04-10 Thread Athos via Phabricator via cfe-commits
Athosvk added a comment.

I'm a bit late on this, but I'd say that YAML is usually not a 'final' format. 
What would be the use-cases for this? And if is meant as an alternative 
intermediate format, why not instead of having one big file, have one file per 
input file? Just wondering what the particular motivation for that could be

(Don't mind the previous and inline comment, it was old and I never got to 
submit it. Differential doesn't let me remove it unfortunately)


https://reviews.llvm.org/D43667



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-04-10 Thread Athos via Phabricator via cfe-commits
Athosvk added a comment.

I'm a bit late on this, but I'd say that YAML is usually not a 'final' format. 
What would be the use-cases for this? And if is meant as an alternative 
intermediate format, why not instead of having one big file, have one file per 
input file? Just wondering what the particular motivation for that could be




Comment at: clang-doc/generators/YAMLGenerator.cpp:159
+if (!C->Position.empty()) IO.mapRequired("Position", C->Position);
+if (!C->Children.empty()) IO.mapRequired("Children", C->Children);
+  }

You should easily be able to unify these 'empty' checks


https://reviews.llvm.org/D43667



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-03-27 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 140021.
juliehockett added a comment.

Updating to for adjustments to the internal representation & cleaning up 
duplication.


https://reviews.llvm.org/D43667

Files:
  clang-doc/CMakeLists.txt
  clang-doc/Representation.h
  clang-doc/generators/CMakeLists.txt
  clang-doc/generators/Generators.h
  clang-doc/generators/YAMLGenerator.cpp
  clang-doc/tool/CMakeLists.txt
  clang-doc/tool/ClangDocMain.cpp
  test/clang-doc/yaml-comments.cpp
  test/clang-doc/yaml-namespace.cpp
  test/clang-doc/yaml-record.cpp

Index: test/clang-doc/yaml-record.cpp
===
--- /dev/null
+++ test/clang-doc/yaml-record.cpp
@@ -0,0 +1,212 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: cat %t/docs/yaml/docs.yaml | FileCheck %s
+
+union A { int X; int Y; };
+
+enum B { X, Y };
+
+enum class Bc { A, B };
+
+struct C { int i; };
+
+class D {};
+
+class E {
+public:
+  E() {}
+  ~E() {}
+
+protected:
+  void ProtectedMethod();
+};
+
+void E::ProtectedMethod() {}
+
+class F : virtual private D, public E {};
+
+class X {
+  class Y {};
+};
+
+void H() {
+  class I {};
+}
+
+// CHECK: ---
+// CHECK-NEXT: Records: 
+// CHECK-NEXT:   - USR: 'ACE81AFA6627B4CEF2B456FB6E1252925674AF7E'
+// CHECK-NEXT: Name:'A'
+// CHECK-NEXT: DefLocation: 
+// CHECK-NEXT:   LineNumber:  8
+// CHECK-NEXT:   Filename:'{{.*}}'
+// CHECK-NEXT: TagType: Union
+// CHECK-NEXT: Members: 
+// CHECK-NEXT:   - Type:
+// CHECK-NEXT:   UnresolvedName:  'int'
+// CHECK-NEXT: Name:'A::X'
+// CHECK-NEXT:   - Type:
+// CHECK-NEXT:   UnresolvedName:  'int'
+// CHECK-NEXT: Name:'A::Y'
+// CHECK-NEXT:   - USR: '06B5F6A19BA9F6A832E127C9968282B94619B210'
+// CHECK-NEXT: Name:'C'
+// CHECK-NEXT: DefLocation: 
+// CHECK-NEXT:   LineNumber:  14
+// CHECK-NEXT:   Filename:'{{.*}}'
+// CHECK-NEXT: Members: 
+// CHECK-NEXT:   - Type:
+// CHECK-NEXT:   UnresolvedName:  'int'
+// CHECK-NEXT: Name:'C::i'
+// CHECK-NEXT:   - USR: '0921737541208B8FA9BB42B60F78AC1D779AA054'
+// CHECK-NEXT: Name:'D'
+// CHECK-NEXT: Records: 
+// CHECK-NEXT:   - Type:Record
+// CHECK-NEXT: USR: 'E3B54702FABFF4037025BA194FC27C47006330B5'
+// CHECK-NEXT: DefLocation: 
+// CHECK-NEXT:   LineNumber:  16
+// CHECK-NEXT:   Filename:'{{.*}}'
+// CHECK-NEXT: TagType: Class
+// CHECK-NEXT:   - USR: '289584A8E0FF4178A794622A547AA622503967A1'
+// CHECK-NEXT: Name:'E'
+// CHECK-NEXT: Records: 
+// CHECK-NEXT:   - Type:Record
+// CHECK-NEXT: USR: 'E3B54702FABFF4037025BA194FC27C47006330B5'
+// CHECK-NEXT: Functions:   
+// CHECK-NEXT:   - Type:Function
+// CHECK-NEXT: USR: 'DEB4AC1CD9253CD9EF7FBE6BCAC506D77984ABD4'
+// CHECK-NEXT:   - Type:Function
+// CHECK-NEXT: USR: 'DEB4AC1CD9253CD9EF7FBE6BCAC506D77984ABD4'
+// CHECK-NEXT:   - Type:Function
+// CHECK-NEXT: USR: 'BD2BDEBD423F80BACCEA75DE6D6622D355FC2D17'
+// CHECK-NEXT:   - Type:Function
+// CHECK-NEXT: USR: 'BD2BDEBD423F80BACCEA75DE6D6622D355FC2D17'
+// CHECK-NEXT:   - Type:Function
+// CHECK-NEXT: USR: '5093D428CDC62096A67547BA52566E4FB9404EEE'
+// CHECK-NEXT:   - Type:Function
+// CHECK-NEXT: USR: '5093D428CDC62096A67547BA52566E4FB9404EEE'
+// CHECK-NEXT: DefLocation: 
+// CHECK-NEXT:   LineNumber:  18
+// CHECK-NEXT:   Filename:'{{.*}}'
+// CHECK-NEXT: TagType: Class
+// CHECK-NEXT:   - USR: 'E3B54702FABFF4037025BA194FC27C47006330B5'
+// CHECK-NEXT: Name:'F'
+// CHECK-NEXT: DefLocation: 
+// CHECK-NEXT:   LineNumber:  29
+// CHECK-NEXT:   Filename:'{{.*}}'
+// CHECK-NEXT: TagType: Class
+// CHECK-NEXT: Parents: 
+// CHECK-NEXT:   - Type:Record
+// CHECK-NEXT: USR: '289584A8E0FF4178A794622A547AA622503967A1'
+// CHECK-NEXT: VirtualParents:  
+// CHECK-NEXT:   - Type:Record
+// CHECK-NEXT: USR: '0921737541208B8FA9BB42B60F78AC1D779AA054'
+// CHECK-NEXT:   - USR: 'CA7C7935730B5EACD25F080E9C83FA087CCDC75E'
+// CHECK-NEXT: Name:'X'
+// CHECK-NEXT: Records: 
+// CHECK-NEXT:   - Type:Record
+// CHECK-NEXT:   

[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-03-06 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 137272.
juliehockett marked 6 inline comments as done.
juliehockett added a comment.

Updating based on parent changes


https://reviews.llvm.org/D43667

Files:
  clang-doc/CMakeLists.txt
  clang-doc/Representation.h
  clang-doc/generators/CMakeLists.txt
  clang-doc/generators/GeneratorBase.cpp
  clang-doc/generators/Generators.h
  clang-doc/generators/YAMLGenerator.cpp
  clang-doc/tool/CMakeLists.txt
  clang-doc/tool/ClangDocMain.cpp
  test/clang-doc/yaml-comments.cpp
  test/clang-doc/yaml-namespace.cpp
  test/clang-doc/yaml-record.cpp

Index: test/clang-doc/yaml-record.cpp
===
--- /dev/null
+++ test/clang-doc/yaml-record.cpp
@@ -0,0 +1,161 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: cat %t/docs/yaml/docs.yaml | FileCheck %s
+
+union A { int X; int Y; };
+
+enum B { X, Y };
+
+enum class Bc { A, B };
+
+struct C { int i; };
+
+class D {};
+
+class E {
+public:
+  E() {}
+  ~E() {}
+
+protected:
+  void ProtectedMethod();
+};
+
+void E::ProtectedMethod() {}
+
+class F : virtual private D, public E {};
+
+class X {
+  class Y {};
+};
+
+void H() {
+  class I {};
+}
+
+// CHECK: ---
+// CHECK-NEXT: Records: 
+// CHECK-NEXT:   - USR: 'ACE81AFA6627B4CEF2B456FB6E1252925674AF7E'
+// CHECK-NEXT: Name:'A'
+// CHECK-NEXT: TagType: Union
+// CHECK-NEXT: Members: 
+// CHECK-NEXT:   - Type:
+// CHECK-NEXT:   USR: 'int'
+// CHECK-NEXT: Name:'A::X'
+// CHECK-NEXT:   - Type:
+// CHECK-NEXT:   USR: 'int'
+// CHECK-NEXT: Name:'A::Y'
+// CHECK-NEXT:   - USR: '06B5F6A19BA9F6A832E127C9968282B94619B210'
+// CHECK-NEXT: Name:'C'
+// CHECK-NEXT: Members: 
+// CHECK-NEXT:   - Type:
+// CHECK-NEXT:   USR: 'int'
+// CHECK-NEXT: Name:'C::i'
+// CHECK-NEXT:   - USR: '0921737541208B8FA9BB42B60F78AC1D779AA054'
+// CHECK-NEXT: Name:'D'
+// CHECK-NEXT: TagType: Class
+// CHECK-NEXT:   - USR: '289584A8E0FF4178A794622A547AA622503967A1'
+// CHECK-NEXT: Name:'E'
+// CHECK-NEXT: TagType: Class
+// CHECK-NEXT:   - USR: 'E3B54702FABFF4037025BA194FC27C47006330B5'
+// CHECK-NEXT: Name:'F'
+// CHECK-NEXT: TagType: Class
+// CHECK-NEXT: Parents: 
+// CHECK-NEXT:   - USR: '289584A8E0FF4178A794622A547AA622503967A1'
+// CHECK-NEXT: Type:Record
+// CHECK-NEXT: VirtualParents:  
+// CHECK-NEXT:   - USR: '0921737541208B8FA9BB42B60F78AC1D779AA054'
+// CHECK-NEXT: Type:Record
+// CHECK-NEXT:   - USR: 'CA7C7935730B5EACD25F080E9C83FA087CCDC75E'
+// CHECK-NEXT: Name:'X'
+// CHECK-NEXT: TagType: Class
+// CHECK-NEXT:   - USR: '641AB4A3D36399954ACDE29C7A8833032BF40472'
+// CHECK-NEXT: Name:'Y'
+// CHECK-NEXT: Namespace:   
+// CHECK-NEXT:   - USR: 'CA7C7935730B5EACD25F080E9C83FA087CCDC75E'
+// CHECK-NEXT: Type:Record
+// CHECK-NEXT: TagType: Class
+// CHECK-NEXT:   - USR: '73C72A405B7A00ECFAACE184766DE3ED7C3702DC'
+// CHECK-NEXT: Name:'I'
+// CHECK-NEXT: Namespace:   
+// CHECK-NEXT:   - USR: 'B6AC4C5C9F2EA3F2B3ECE1A33D349F4EE502B24E'
+// CHECK-NEXT: Type:Function
+// CHECK-NEXT: TagType: Class
+// CHECK-NEXT: Functions:   
+// CHECK-NEXT:   - USR: 'DEB4AC1CD9253CD9EF7FBE6BCAC506D77984ABD4'
+// CHECK-NEXT: Name:'E'
+// CHECK-NEXT: Namespace:   
+// CHECK-NEXT:   - USR: '289584A8E0FF4178A794622A547AA622503967A1'
+// CHECK-NEXT: Type:Record
+// CHECK-NEXT: IsMethod:true
+// CHECK-NEXT: Parent:  
+// CHECK-NEXT:   USR: '289584A8E0FF4178A794622A547AA622503967A1'
+// CHECK-NEXT:   Type:Record
+// CHECK-NEXT: ReturnType:  
+// CHECK-NEXT:   Type:
+// CHECK-NEXT: USR: 'void'
+// CHECK-NEXT:   - USR: 'BD2BDEBD423F80BACCEA75DE6D6622D355FC2D17'
+// CHECK-NEXT: Name:'~E'
+// CHECK-NEXT: Namespace:   
+// CHECK-NEXT:   - USR: '289584A8E0FF4178A794622A547AA622503967A1'
+// CHECK-NEXT: Type:Record
+// CHECK-NEXT: IsMethod:true
+// CHECK-NEXT: Parent:  
+// CHECK-NEXT:   USR: '289584A8E0FF4178A794622A547AA622503967A1'
+// CHECK-NEXT:   Type:Record

[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-02-23 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

I may be mistaken, but Clang source code didn't use llvm namespace by default. 
Insetad you should include clang/Basic/LLVM.h and use llvm:: for rest of things.




Comment at: clang-doc/tool/ClangDocMain.cpp:42
 
 namespace {
 

There is no need to enclose static definitions in anonymous namespace.


https://reviews.llvm.org/D43667



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-02-23 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please run Clang-format and Clang-tidy modernize over new code.




Comment at: clang-doc/generators/Generators.h:29
+  Generator(std::unique_ptr , StringRef Root, StringRef Format)
+  : IS(IS), Root(Root), Format(Format){};
+  virtual ~Generator(){};

Unnecessary ; after constructor body. Please enable Clang's -Wextra-semi



Comment at: clang-doc/generators/Generators.h:30
+  : IS(IS), Root(Root), Format(Format){};
+  virtual ~Generator(){};
+

Please use = default;



Comment at: clang-doc/generators/Generators.h:47
+  YAMLGenerator(std::unique_ptr , StringRef Root, StringRef Format)
+  : Generator(IS, Root, Format){};
+  virtual ~YAMLGenerator(){};

Unnecessary ; after constructor body.



Comment at: clang-doc/generators/Generators.h:48
+  : Generator(IS, Root, Format){};
+  virtual ~YAMLGenerator(){};
+

Please use = default;



Comment at: test/clang-doc/namespace-yaml.cpp:11
+void f();
+void f() {};
+

Unnecessary ; after function body.


https://reviews.llvm.org/D43667



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-02-22 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett created this revision.
juliehockett added reviewers: klimek, jakehehrlich, sammccall, lebedev.ri.
juliehockett added a project: clang-tools-extra.
Herald added a subscriber: mgorny.
juliehockett added a dependency: D43341: [clang-doc] Implement reducer portion 
of the frontend framework.

Implmenting a YAML generator from the emitted bitcode summary of declarations. 
Emits one YAML file with all declaration information.

For a more detailed overview of the tool, see the design document on the 
mailing list: RFC: clang-doc proposal 



https://reviews.llvm.org/D43667

Files:
  clang-doc/CMakeLists.txt
  clang-doc/generators/CMakeLists.txt
  clang-doc/generators/GeneratorBase.cpp
  clang-doc/generators/Generators.h
  clang-doc/generators/YAMLGenerator.cpp
  clang-doc/tool/CMakeLists.txt
  clang-doc/tool/ClangDocMain.cpp
  test/clang-doc/namespace-yaml.cpp
  test/clang-doc/record-yaml.cpp

Index: test/clang-doc/record-yaml.cpp
===
--- /dev/null
+++ test/clang-doc/record-yaml.cpp
@@ -0,0 +1,119 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: cat %t/docs/yaml/docs.yaml | FileCheck %s
+
+union A { int X; int Y; };
+
+enum B { X, Y };
+
+struct C { int i; };
+
+class D {};
+
+class E {
+public:
+  E() {}
+  ~E() {}
+
+protected:
+  void ProtectedMethod();
+};
+
+void E::ProtectedMethod() {}
+
+class F : virtual private D, public E {};
+
+// CHECK: ---
+// CHECK: Namespaces:  
+// CHECK: Records: 
+// CHECK:   - Name:A
+// CHECK: TagType: Union
+// CHECK: IsDefinition:true
+// CHECK: Location:
+// CHECK: Members: 
+// CHECK:   - Type:int
+// CHECK: Name:'A::X'
+// CHECK: Access:  None
+// CHECK: Description: 
+// CHECK:   - Type:int
+// CHECK: Name:'A::Y'
+// CHECK: Access:  None
+// CHECK: Description: 
+// CHECK: ParentUSRs:  
+// CHECK: VirtualParentUSRs: 
+// CHECK:   - Name:C
+// CHECK: TagType: Struct
+// CHECK: IsDefinition:true
+// CHECK: Location:
+// CHECK: Members: 
+// CHECK:   - Type:int
+// CHECK: Name:'C::i'
+// CHECK: Access:  None
+// CHECK: Description: 
+// CHECK: ParentUSRs:  
+// CHECK: VirtualParentUSRs: 
+// CHECK:   - Name:D
+// CHECK: TagType: Class
+// CHECK: IsDefinition:true
+// CHECK: Location:
+// CHECK: Members: 
+// CHECK: ParentUSRs:  
+// CHECK: VirtualParentUSRs: 
+// CHECK:   - Name:E
+// CHECK: TagType: Class
+// CHECK: IsDefinition:true
+// CHECK: Location:
+// CHECK: Members: 
+// CHECK: ParentUSRs:  
+// CHECK: VirtualParentUSRs: 
+// CHECK:   - Name:F
+// CHECK: TagType: Class
+// CHECK: IsDefinition:true
+// CHECK: Location:
+// CHECK: Members: 
+// CHECK: ParentUSRs:  
+// CHECK:   - 'c:@S@E'
+// CHECK: VirtualParentUSRs: 
+// CHECK:   - 'c:@S@D'
+// CHECK: Functions:   
+// CHECK:   - Name:E
+// CHECK: IsDefinition:true
+// CHECK: Location:
+// CHECK: ParentUSR:   E
+// CHECK: Params:  
+// CHECK: ReturnType:  
+// CHECK:   Type:void
+// CHECK:   Description: 
+// CHECK: Access:  Public
+// CHECK:   - Name:'~E'
+// CHECK: IsDefinition:true
+// CHECK: Location:
+// CHECK: ParentUSR:   '~E'
+// CHECK: Params:  
+// CHECK: ReturnType:  
+// CHECK:   Type:void
+// CHECK:   Description: 
+// CHECK: Access:  Public
+// CHECK:   - Name:ProtectedMethod
+// CHECK: IsDefinition:true
+// CHECK: Location:
+// CHECK: ParentUSR:   ProtectedMethod
+// CHECK: Params:  
+// CHECK: ReturnType:  
+// CHECK:   Type:void
+// CHECK:   Description: 
+// CHECK: Access:  Public
+// CHECK: Enums:   
+// CHECK:   - Name:B
+// CHECK: IsDefinition:true
+// CHECK: Location:
+// CHECK: Scoped:  false
+// CHECK: Members: 
+// CHECK:   - Type:X
+// CHECK: Description: 
+// CHECK:   - Type:Y
+// CHECK: Description: 
+// CHECK: ...
Index: test/clang-doc/namespace-yaml.cpp
===
--- /dev/null
+++