[PATCH] D48395: Added PublicOnly flag

2018-07-06 Thread Annie Cherkaev via Phabricator via cfe-commits
anniecherk updated this revision to Diff 154470.
anniecherk added a comment.

Updated according to Julie's suggestions, mostly adjusted formatting.


https://reviews.llvm.org/D48395

Files:
  clang-tools-extra/clang-doc/ClangDoc.cpp
  clang-tools-extra/clang-doc/ClangDoc.h
  clang-tools-extra/clang-doc/Mapper.cpp
  clang-tools-extra/clang-doc/Mapper.h
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/Serialize.cpp
  clang-tools-extra/clang-doc/Serialize.h
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/test/clang-doc/yaml-module.cpp
  clang-tools-extra/test/clang-doc/yaml-public-module.cpp
  clang-tools-extra/test/clang-doc/yaml-public-records.cpp

Index: clang-tools-extra/test/clang-doc/yaml-public-records.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-doc/yaml-public-records.cpp
@@ -0,0 +1,339 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --public --doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: clang-doc --doxygen -p %t %t/test.cpp -output=%t/docs-without-flag
+// RUN: cat %t/docs/function.yaml | FileCheck %s --check-prefix=CHECK-A
+// RUN: cat %t/docs/inlinedFunction.yaml | FileCheck %s --check-prefix=CHECK-B
+// RUN: cat %t/docs/functionWithInnerClass.yaml | FileCheck %s --check-prefix=CHECK-C
+// RUN: cat %t/docs/inlinedFunctionWithInnerClass.yaml | FileCheck %s --check-prefix=CHECK-D
+// RUN: cat %t/docs/Class/publicMethod.yaml| FileCheck %s --check-prefix=CHECK-E
+// RUN: cat %t/docs/Class.yaml| FileCheck %s --check-prefix=CHECK-F
+// RUN: cat %t/docs/Class/protectedMethod.yaml| FileCheck %s --check-prefix=CHECK-G
+// RUN: cat %t/docs/named.yaml| FileCheck %s --check-prefix=CHECK-H
+// RUN: cat %t/docs/named/NamedClass.yaml| FileCheck %s --check-prefix=CHECK-I
+// RUN: cat %t/docs/named/namedFunction.yaml| FileCheck %s --check-prefix=CHECK-J
+// RUN: cat %t/docs/named/namedInlineFunction.yaml| FileCheck %s --check-prefix=CHECK-K
+// RUN: cat %t/docs/named/NamedClass/namedPublicMethod.yaml| FileCheck %s --check-prefix=CHECK-L
+// RUN: cat %t/docs/named/NamedClass/namedProtectedMethod.yaml| FileCheck %s --check-prefix=CHECK-M
+// RUN: (diff -qry %t/docs-without-flag %t/docs | sed 's:.*/::' > %t/public.diff) || true
+// RUN: cat %t/public.diff | FileCheck %s --check-prefix=CHECK-N
+
+void function(int x);
+
+// CHECK-A: ---
+// CHECK-A-NEXT: USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
+// CHECK-A-NEXT: Name:'function'
+// CHECK-A-NEXT: Location:
+// CHECK-A-NEXT:   - LineNumber:  23
+// CHECK-A-NEXT: Filename:{{.*}}
+// CHECK-A-NEXT: Params:
+// CHECK-A-NEXT:   - Type:
+// CHECK-A-NEXT:   Name:'int'
+// CHECK-A-NEXT: Name:'x'
+// CHECK-A-NEXT: ReturnType:
+// CHECK-A-NEXT:   Type:
+// CHECK-A-NEXT: Name:'void'
+// CHECK-A-NEXT: ...
+
+inline int inlinedFunction(int x);
+
+// CHECK-B: ---
+// CHECK-B-NEXT: USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
+// CHECK-B-NEXT: Name:'inlinedFunction'
+// CHECK-B-NEXT: Location:
+// CHECK-B-NEXT:   - LineNumber:  40
+// CHECK-B-NEXT: Filename:{{.*}}
+// CHECK-B-NEXT: Params:
+// CHECK-B-NEXT:   - Type:
+// CHECK-B-NEXT:   Name:'int'
+// CHECK-B-NEXT: Name:'x'
+// CHECK-B-NEXT: ReturnType:
+// CHECK-B-NEXT:   Type:
+// CHECK-B-NEXT: Name:'int'
+// CHECK-B-NEXT: ...
+
+int functionWithInnerClass(int x){
+class InnerClass { //NoLinkage
+  public:
+int innerPublicMethod() { return 2; };
+}; //end class
+InnerClass temp;
+return temp.innerPublicMethod();
+};
+
+// CHECK-C: ---
+// CHECK-C-NEXT: USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
+// CHECK-C-NEXT: Name:'functionWithInnerClass'
+// CHECK-C-NEXT: DefLocation:
+// CHECK-C-NEXT:   LineNumber:  57
+// CHECK-C-NEXT:   Filename:{{.*}}
+// CHECK-C-NEXT: Params:
+// CHECK-C-NEXT:   

[PATCH] D48395: Added PublicOnly flag

2018-07-03 Thread Annie Cherkaev via Phabricator via cfe-commits
anniecherk marked 11 inline comments as done.
anniecherk added inline comments.



Comment at: clang-tools-extra/clang-doc/Serialize.cpp:322-324
+  if(PublicOnly && ! isPublic(D->getAccess(), D->getLinkageInternal())){
+return "";
+  }

juliehockett wrote:
> Since this is the same for Record/Function/Enum, can we move this to 
> `populateSymbolInfo()`?
> 
> Also, elide braces on single-line ifs.
I don't see a good way to put it into populateSymbolInfo because if the 
condition passes then the emitInfo method needs to bail out and I don't see a 
clean way to do that if the check is in populateSymbolInfo.  A clunky way to do 
this would be to either have populateSymbolInfo set a flag that emitInfo checks 
or emitInfo can assume that populateSymbolInfo bailed if all the info is 
unpopulated, but that seems like a worse way to do it. Am I missing something? 

I can refactor the condition into a function if that would be better for 
understandability / maintainability.


https://reviews.llvm.org/D48395



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


[PATCH] D48395: Added PublicOnly flag

2018-07-02 Thread Annie Cherkaev via Phabricator via cfe-commits
anniecherk updated this revision to Diff 153825.
anniecherk marked 4 inline comments as done.
anniecherk added a comment.

Addressed Julie's comments


https://reviews.llvm.org/D48395

Files:
  clang-tools-extra/clang-doc/ClangDoc.cpp
  clang-tools-extra/clang-doc/ClangDoc.h
  clang-tools-extra/clang-doc/Mapper.cpp
  clang-tools-extra/clang-doc/Mapper.h
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/Serialize.cpp
  clang-tools-extra/clang-doc/Serialize.h
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/test/clang-doc/yaml-module.cpp
  clang-tools-extra/test/clang-doc/yaml-public-module.cpp
  clang-tools-extra/test/clang-doc/yaml-public-records.cpp

Index: clang-tools-extra/test/clang-doc/yaml-public-records.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-doc/yaml-public-records.cpp
@@ -0,0 +1,339 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --public --doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: clang-doc --doxygen -p %t %t/test.cpp -output=%t/docs-without-flag
+// RUN: cat %t/docs/function.yaml | FileCheck %s --check-prefix=CHECK-A
+// RUN: cat %t/docs/inlinedFunction.yaml | FileCheck %s --check-prefix=CHECK-B
+// RUN: cat %t/docs/functionWithInnerClass.yaml | FileCheck %s --check-prefix=CHECK-C
+// RUN: cat %t/docs/inlinedFunctionWithInnerClass.yaml | FileCheck %s --check-prefix=CHECK-D
+// RUN: cat %t/docs/Class/publicMethod.yaml| FileCheck %s --check-prefix=CHECK-E
+// RUN: cat %t/docs/Class.yaml| FileCheck %s --check-prefix=CHECK-F
+// RUN: cat %t/docs/Class/protectedMethod.yaml| FileCheck %s --check-prefix=CHECK-G
+// RUN: cat %t/docs/named.yaml| FileCheck %s --check-prefix=CHECK-H
+// RUN: cat %t/docs/named/NamedClass.yaml| FileCheck %s --check-prefix=CHECK-I
+// RUN: cat %t/docs/named/namedFunction.yaml| FileCheck %s --check-prefix=CHECK-J
+// RUN: cat %t/docs/named/namedInlineFunction.yaml| FileCheck %s --check-prefix=CHECK-K
+// RUN: cat %t/docs/named/NamedClass/namedPublicMethod.yaml| FileCheck %s --check-prefix=CHECK-L
+// RUN: cat %t/docs/named/NamedClass/namedProtectedMethod.yaml| FileCheck %s --check-prefix=CHECK-M
+// RUN: (diff -qry %t/docs-without-flag %t/docs | sed 's:.*/::' > %t/public.diff) || true
+// RUN: cat %t/public.diff | FileCheck %s --check-prefix=CHECK-N
+
+void function(int x);
+
+// CHECK-A: ---
+// CHECK-A-NEXT: USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
+// CHECK-A-NEXT: Name:'function'
+// CHECK-A-NEXT: Location:
+// CHECK-A-NEXT:   - LineNumber:  23
+// CHECK-A-NEXT: Filename:{{.*}}
+// CHECK-A-NEXT: Params:
+// CHECK-A-NEXT:   - Type:
+// CHECK-A-NEXT:   Name:'int'
+// CHECK-A-NEXT: Name:'x'
+// CHECK-A-NEXT: ReturnType:
+// CHECK-A-NEXT:   Type:
+// CHECK-A-NEXT: Name:'void'
+// CHECK-A-NEXT: ...
+
+inline int inlinedFunction(int x);
+
+// CHECK-B: ---
+// CHECK-B-NEXT: USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
+// CHECK-B-NEXT: Name:'inlinedFunction'
+// CHECK-B-NEXT: Location:
+// CHECK-B-NEXT:   - LineNumber:  40
+// CHECK-B-NEXT: Filename:{{.*}}
+// CHECK-B-NEXT: Params:
+// CHECK-B-NEXT:   - Type:
+// CHECK-B-NEXT:   Name:'int'
+// CHECK-B-NEXT: Name:'x'
+// CHECK-B-NEXT: ReturnType:
+// CHECK-B-NEXT:   Type:
+// CHECK-B-NEXT: Name:'int'
+// CHECK-B-NEXT: ...
+
+int functionWithInnerClass(int x){
+class InnerClass { //NoLinkage
+  public:
+int innerPublicMethod() { return 2; };
+}; //end class
+InnerClass temp;
+return temp.innerPublicMethod();
+};
+
+// CHECK-C: ---
+// CHECK-C-NEXT: USR: '{{[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]}}'
+// CHECK-C-NEXT: Name:'functionWithInnerClass'
+// CHECK-C-NEXT: DefLocation:
+// CHECK-C-NEXT:   LineNumber:  57
+// CHECK-C-NEXT:   Filename:{{.*}}
+// CHECK-C-NEXT: Params:
+// CHECK-C-NEXT:   - Type:
+// CHECK-C-NEXT:   Name:  

[PATCH] D48395: Added PublicOnly flag

2018-07-02 Thread Annie Cherkaev via Phabricator via cfe-commits
anniecherk updated this revision to Diff 153790.
anniecherk added a comment.

Updated the tests to more accurately check that the files that we expect to not 
be generated by clang-doc with the public flag are in fact not being created.

The tests now run clang-doc over the test files with and without the public 
flag, outputting yaml files into two different directories. 
File-check then diffs those directories and verifies that the files we expect 
to be absent in the directory created from running clang-doc with the public 
flag are in fact absent.


https://reviews.llvm.org/D48395

Files:
  clang-tools-extra/clang-doc/ClangDoc.cpp
  clang-tools-extra/clang-doc/ClangDoc.h
  clang-tools-extra/clang-doc/Mapper.cpp
  clang-tools-extra/clang-doc/Mapper.h
  clang-tools-extra/clang-doc/Serialize.cpp
  clang-tools-extra/clang-doc/Serialize.h
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/test/clang-doc/yaml-module.cpp
  clang-tools-extra/test/clang-doc/yaml-public-module.cpp
  clang-tools-extra/test/clang-doc/yaml-public-records.cpp

Index: clang-tools-extra/test/clang-doc/yaml-public-records.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-doc/yaml-public-records.cpp
@@ -0,0 +1,361 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --public --doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: clang-doc --doxygen -p %t %t/test.cpp -output=%t/docs-without-flag
+// RUN: cat %t/docs/function.yaml | FileCheck %s --check-prefix=CHECK-A
+// RUN: cat %t/docs/inlinedFunction.yaml | FileCheck %s --check-prefix=CHECK-B
+// RUN: cat %t/docs/functionWithInnerClass.yaml | FileCheck %s --check-prefix=CHECK-C
+// RUN: cat %t/docs/inlinedFunctionWithInnerClass.yaml | FileCheck %s --check-prefix=CHECK-D
+// RUN: cat %t/docs/Class/publicMethod.yaml| FileCheck %s --check-prefix=CHECK-E
+// RUN: cat %t/docs/Class.yaml| FileCheck %s --check-prefix=CHECK-F
+// RUN: cat %t/docs/Class/protectedMethod.yaml| FileCheck %s --check-prefix=CHECK-G
+// RUN: cat %t/docs/named.yaml| FileCheck %s --check-prefix=CHECK-H
+// RUN: cat %t/docs/named/NamedClass.yaml| FileCheck %s --check-prefix=CHECK-I
+// RUN: cat %t/docs/named/namedFunction.yaml| FileCheck %s --check-prefix=CHECK-J
+// RUN: cat %t/docs/named/namedInlineFunction.yaml| FileCheck %s --check-prefix=CHECK-K
+// RUN: cat %t/docs/named/NamedClass/namedPublicMethod.yaml| FileCheck %s --check-prefix=CHECK-L
+// RUN: cat %t/docs/named/NamedClass/namedProtectedMethod.yaml| FileCheck %s --check-prefix=CHECK-M
+// RUN: (diff -qry %t/docs-without-flag %t/docs | sed 's:.*/::' > %t/public.diff) || true
+// RUN: cat %t/public.diff | FileCheck %s --check-prefix=CHECK-N
+
+
+void function(int x);
+
+// CHECK-A: ---
+// CHECK-A-NEXT: USR: 'E789672E987C6FCE95B1BB760CB9A6998C4584A9'
+// CHECK-A-NEXT: Name:'function'
+// CHECK-A-NEXT: Location:
+// CHECK-A-NEXT:   - LineNumber:  24
+// CHECK-A-NEXT: Filename:'test'
+// CHECK-A-NEXT: Params:
+// CHECK-A-NEXT:   - Type:
+// CHECK-A-NEXT:   Name:'int'
+// CHECK-A-NEXT: Name:'x'
+// CHECK-A-NEXT: ReturnType:
+// CHECK-A-NEXT:   Type:
+// CHECK-A-NEXT: Name:'void'
+// CHECK-A-NEXT: ...
+
+
+inline int inlinedFunction(int x);
+
+// CHECK-B: ---
+// CHECK-B-NEXT: USR: '9BDA332A65B254CC1F5FF736E8815A1CD3668A87'
+// CHECK-B-NEXT: Name:'inlinedFunction'
+// CHECK-B-NEXT: Location:
+// CHECK-B-NEXT:   - LineNumber:  42
+// CHECK-B-NEXT: Filename:'test'
+// CHECK-B-NEXT: Params:
+// CHECK-B-NEXT:   - Type:
+// CHECK-B-NEXT:   Name:'int'
+// CHECK-B-NEXT: Name:'x'
+// CHECK-B-NEXT: ReturnType:
+// CHECK-B-NEXT:   Type:
+// CHECK-B-NEXT: Name:'int'
+// CHECK-B-NEXT: ...
+
+
+
+int functionWithInnerClass(int x){
+class InnerClass { //NoLinkage
+  public:
+int innerPublicMethod() { return 2; };
+}; //end class
+InnerClass temp;
+return temp.innerPublicMethod();
+};
+
+// CHECK-C: ---
+// CHECK-C-NEXT: USR: 'D7C0B43D134C4D904A64AB58AD050312E0F52B42'
+// CHECK-C-NEXT: Name:'functionWithInnerClass'
+// CHECK-C-NEXT: DefLocation:
+// CHECK-C-NEXT:   LineNumber:  61
+// CHECK-C-NEXT:   Filename:'test'
+// CHECK-C-NEXT: Params:
+// CHECK-C-NEXT:   - Type:
+// CHECK-C-NEXT:   Name:'int'
+// CHECK-C-NEXT: Name:'x'
+// CHECK-C-NEXT: ReturnType:
+// CHECK-C-NEXT:   Type:
+// CHECK-C-NEXT: Name:'int'
+// CHECK-C-NEXT: ...
+
+
+
+
+inline int inlinedFunctionWithInnerClass(int x){
+class InnerClass { //VisibleNoLinkage
+  public:
+int innerPublicMethod() { return 2; };
+}; //end class
+InnerClass temp;
+return temp.innerPublicMethod();
+};
+
+// CHECK-D: ---
+// CHECK-D-NEXT: USR: '346651

[PATCH] D48395: Added PublicOnly flag

2018-06-29 Thread Annie Cherkaev via Phabricator via cfe-commits
anniecherk updated this revision to Diff 153597.
anniecherk added a comment.
Herald added a subscriber: eraman.

- addressed Julie's comments
- updated logic to consider both access specifier & linkage
- added tests for each type of linkage


https://reviews.llvm.org/D48395

Files:
  clang-tools-extra/clang-doc/ClangDoc.cpp
  clang-tools-extra/clang-doc/ClangDoc.h
  clang-tools-extra/clang-doc/Mapper.cpp
  clang-tools-extra/clang-doc/Mapper.h
  clang-tools-extra/clang-doc/Serialize.cpp
  clang-tools-extra/clang-doc/Serialize.h
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/test/clang-doc/public-flag/yaml-public-module-excluded.cpp
  clang-tools-extra/test/clang-doc/public-flag/yaml-public-module-included.cpp
  
clang-tools-extra/test/clang-doc/public-flag/yaml-public-record-excluded-anonInlineFunction.cpp
  
clang-tools-extra/test/clang-doc/public-flag/yaml-public-record-excluded-anonStaticFunction.cpp
  
clang-tools-extra/test/clang-doc/public-flag/yaml-public-record-excluded-anonclass.cpp
  
clang-tools-extra/test/clang-doc/public-flag/yaml-public-record-excluded-anonfunction.cpp
  
clang-tools-extra/test/clang-doc/public-flag/yaml-public-record-excluded-classPrivate.cpp
  
clang-tools-extra/test/clang-doc/public-flag/yaml-public-record-excluded-functionInnerClass.cpp
  
clang-tools-extra/test/clang-doc/public-flag/yaml-public-record-excluded-namespace-private.cpp
  
clang-tools-extra/test/clang-doc/public-flag/yaml-public-record-excluded-static.cpp
  clang-tools-extra/test/clang-doc/public-flag/yaml-public-record-included.cpp
  clang-tools-extra/test/clang-doc/yaml-module.cpp

Index: clang-tools-extra/test/clang-doc/yaml-module.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-doc/yaml-module.cpp
@@ -0,0 +1,63 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --extra-arg=-fmodules-ts --doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: cat %t/docs/moduleFunction.yaml | FileCheck %s --check-prefix=CHECK-A
+// RUN: cat %t/docs/staticModuleFunction.yaml | FileCheck %s --check-prefix=CHECK-B
+// RUN: cat %t/docs/exportedModuleFunction.yaml | FileCheck %s --check-prefix=CHECK-C
+
+export module M;
+
+int moduleFunction(int x); //ModuleLinkage
+// CHECK-A: ---
+// CHECK-A-NEXT: USR: '4429AA8706EF483A44B1DCE2D956BF0FEF82A9B7'
+// CHECK-A-NEXT: Name:'moduleFunction'
+// CHECK-A-NEXT: Location:
+// CHECK-A-NEXT:   - LineNumber:  12
+// CHECK-A-NEXT: Filename:'test'
+// CHECK-A-NEXT: Params:
+// CHECK-A-NEXT:   - Type:
+// CHECK-A-NEXT:   Name:'int'
+// CHECK-A-NEXT: Name:'x'
+// CHECK-A-NEXT: ReturnType:
+// CHECK-A-NEXT:   Type:
+// CHECK-A-NEXT: Name:'int'
+// CHECK-A-NEXT: ...
+
+
+static int staticModuleFunction(int x); //ModuleInternalLinkage
+// CHECK-B: ---
+// CHECK-B-NEXT: USR: '2E49675BF9D3FCCF51D5AA5EA02C280D894C1E4C'
+// CHECK-B-NEXT: Name:'staticModuleFunction'
+// CHECK-B-NEXT: Location:
+// CHECK-B-NEXT:   - LineNumber:  29
+// CHECK-B-NEXT: Filename:'test'
+// CHECK-B-NEXT: Params:
+// CHECK-B-NEXT:   - Type:
+// CHECK-B-NEXT:   Name:'int'
+// CHECK-B-NEXT: Name:'x'
+// CHECK-B-NEXT: ReturnType:
+// CHECK-B-NEXT:   Type:
+// CHECK-B-NEXT: Name:'int'
+// CHECK-B-NEXT: ...
+
+
+export double exportedModuleFunction(double y, int z); //ExternalLinkage
+// CHECK-C: ---
+// CHECK-C-NEXT: USR: '325C328D4EB158CCBA4DF2B5321F63EB39C2B17C'
+// CHECK-C-NEXT: Name:'exportedModuleFunction'
+// CHECK-C-NEXT: Location:
+// CHECK-C-NEXT:   - LineNumber:  46
+// CHECK-C-NEXT: Filename:'test'
+// CHECK-C-NEXT: Params:
+// CHECK-C-NEXT:   - Type:
+// CHECK-C-NEXT:   Name:'double'
+// CHECK-C-NEXT: Name:'y'
+// CHECK-C-NEXT:   - Type:
+// CHECK-C-NEXT:   Name:'int'
+// CHECK-C-NEXT: Name:'z'
+// CHECK-C-NEXT: ReturnType:
+// CHECK-C-NEXT:   Type:
+// CHECK-C-NEXT: Name:'double'
+// CHECK-C-NEXT: ...
Index: clang-tools-extra/test/clang-doc/public-flag/yaml-public-record-included.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-doc/public-flag/yaml-public-record-included.cpp
@@ -0,0 +1,311 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --public --doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: cat %t/docs/function.yaml | FileCheck %s --check-prefix=CHECK-A
+// RUN: cat %t/docs/inlinedFunction.yaml | FileCheck %s --check-prefix=CHECK-B
+// RUN: cat %t/docs/functionWithInnerClass.yaml | FileCheck %s --check-prefix=CHECK-C
+// RUN: cat %t/docs/inlinedFunctionWithInnerClass.yaml | FileCheck %s --check-prefix=

[PATCH] D48395: Added PublicOnly flag

2018-06-20 Thread Annie Cherkaev via Phabricator via cfe-commits
anniecherk created this revision.
anniecherk added reviewers: juliehockett, jakehehrlich, mcgrathr, phosek.
Herald added a subscriber: cfe-commits.

Added a flag which, when enabled, documents only those methods and fields which 
have a Public attribute.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48395

Files:
  clang-tools-extra/clang-doc/ClangDoc.cpp
  clang-tools-extra/clang-doc/ClangDoc.h
  clang-tools-extra/clang-doc/Mapper.cpp
  clang-tools-extra/clang-doc/Mapper.h
  clang-tools-extra/clang-doc/Serialize.cpp
  clang-tools-extra/clang-doc/Serialize.h
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/test/clang-doc/yaml-record-public-only.cpp

Index: clang-tools-extra/test/clang-doc/yaml-record-public-only.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-doc/yaml-record-public-only.cpp
@@ -0,0 +1,103 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --public-only --doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: cat %t/docs/Struct.yaml | FileCheck %s --check-prefix=CHECK-A
+// RUN: cat %t/docs/Struct/publicMethod.yaml | FileCheck %s --check-prefix=CHECK-B
+// RUN: cat %t/docs/Class.yaml | FileCheck %s --check-prefix=CHECK-C
+// RUN: cat %t/docs/Class/publicMethod.yaml | FileCheck %s --check-prefix=CHECK-D
+
+struct Struct {
+  public:
+void publicMethod();
+int  publicField;
+ protected:
+void protectedMethod();
+int  protectedField;
+ private:
+void privateMethod();
+int  privateField;
+};
+
+
+// CHECK-A: ---
+// CHECK-A-NEXT: USR: '0E0522198A2C7D141073719DA0815FCD6DC95610'
+// CHECK-A-NEXT: Name:'Struct'
+// CHECK-A-NEXT: DefLocation:
+// CHECK-A-NEXT:   LineNumber:  11
+// CHECK-A-NEXT:   Filename:'test'
+// CHECK-A-NEXT: Members:
+// CHECK-A-NEXT:   - Type:
+// CHECK-A-NEXT:   Name:'int'
+// CHECK-A-NEXT: Name:'publicField'
+// CHECK-A-NEXT: ...
+
+
+// CHECK-B: ---
+// CHECK-B-NEXT: USR: 'DC71C1FF683E2DE57395B0029458ADC4BDDE46CA'
+// CHECK-B-NEXT: Name:'publicMethod'
+// CHECK-B-NEXT: Namespace:
+// CHECK-B-NEXT:   - Type:Record
+// CHECK-B-NEXT: Name:'Struct'
+// CHECK-B-NEXT: USR: '0E0522198A2C7D141073719DA0815FCD6DC95610'
+// CHECK-B-NEXT: Location:
+// CHECK-B-NEXT:   - LineNumber:  13
+// CHECK-B-NEXT: Filename:'test'
+// CHECK-B-NEXT: IsMethod:true
+// CHECK-B-NEXT: Parent:
+// CHECK-B-NEXT:   Type:Record
+// CHECK-B-NEXT:   Name:'Struct'
+// CHECK-B-NEXT:   USR: '0E0522198A2C7D141073719DA0815FCD6DC95610'
+// CHECK-B-NEXT: ReturnType:
+// CHECK-B-NEXT:   Type:
+// CHECK-B-NEXT: Name:'void'
+// CHECK-B-NEXT: ...
+
+
+class Class {
+ public:
+  void publicMethod();
+  int  publicField;
+ protected:
+  void protectedMethod();
+  int  protectedField;
+ private:
+  void privateMethod();
+  int  privateField;
+};
+
+
+// CHECK-C: ---
+// CHECK-C-NEXT: USR: '7CDD73DCD6CD72F7E5CE25502810A182C66C4B45'
+// CHECK-C-NEXT: Name:'Class'
+// CHECK-C-NEXT: DefLocation:
+// CHECK-C-NEXT:   LineNumber:  58
+// CHECK-C-NEXT:   Filename:'test'
+// CHECK-C-NEXT: TagType: Class
+// CHECK-C-NEXT: Members:
+// CHECK-C-NEXT:   - Type:
+// CHECK-C-NEXT:   Name:'int'
+// CHECK-C-NEXT: Name:'publicField'
+// CHECK-C-NEXT: ...
+
+
+// CHECK-D: ---
+// CHECK-D-NEXT: USR: '05682AF6307337176313391E00A231C2C55A4972'
+// CHECK-D-NEXT: Name:'publicMethod'
+// CHECK-D-NEXT: Namespace:
+// CHECK-D-NEXT:   - Type:Record
+// CHECK-D-NEXT: Name:'Class'
+// CHECK-D-NEXT: USR: '7CDD73DCD6CD72F7E5CE25502810A182C66C4B45'
+// CHECK-D-NEXT: Location:
+// CHECK-D-NEXT:   - LineNumber:  60
+// CHECK-D-NEXT: Filename:'test'
+// CHECK-D-NEXT: IsMethod:true
+// CHECK-D-NEXT: Parent:
+// CHECK-D-NEXT:   Type:Record
+// CHECK-D-NEXT:   Name:'Class'
+// CHECK-D-NEXT:   USR: '7CDD73DCD6CD72F7E5CE25502810A182C66C4B45'
+// CHECK-D-NEXT: ReturnType:
+// CHECK-D-NEXT:   Type:
+// CHECK-D-NEXT: Name:'void'
+// CHECK-D-NEXT: ...
Index: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
===
--- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -64,6 +64,11 @@
 llvm::cl::desc("Dump intermediate results to bitcode file."),
 llvm::cl::init(false), llvm::cl::cat(ClangDocCategory));
 
+static llvm::cl::opt PublicOnly(
+"public-only",
+llvm::cl::desc("Only document public methods & public fields."),
+llvm::cl::init(false), llvm::cl::cat(ClangDocCategory));
+
 enum OutputFormatTy