[PATCH] D48395: Added PublicOnly flag

Julie Hockett via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 21 15:15:58 PDT 2018


juliehockett added a comment.

So on seeing this, all of the plumbing needed to get that particular value where you need it is a bit ugly. I'm inclined to suggest wrapping it in a `ClangDocContext`, containing it and the `ExecutionContext` in the `ClangDoc.h` file:

  struct ClangDocContext {
      ExecutionContext &ECtx;
      bool PublicOnly;
  }

and then basically just replace everywhere the `ECtx` is plumbed through with the new context object.



================
Comment at: clang-tools-extra/clang-doc/Serialize.cpp:307
 
 std::string emitInfo(const RecordDecl *D, const FullComment *FC, int LineNumber,
+                     llvm::StringRef File, bool PublicOnly) {
----------------
You also want to check access here (records can be private to a class).


================
Comment at: clang-tools-extra/clang-doc/Serialize.cpp:334
   I.Access = D->getAccess();
+  if(PublicOnly && (I.Access != clang::AccessSpecifier::AS_public)){
+    return "";
----------------
Move this to the top of the function and do the check before you set the value on `I` -- if we're not going to return anything, you should exit quickly before you do all of the allocation.


================
Comment at: clang-tools-extra/clang-doc/Serialize.cpp:340
 
 std::string emitInfo(const EnumDecl *D, const FullComment *FC, int LineNumber,
+                     llvm::StringRef File, bool PublicOnly) {
----------------
Also check here


================
Comment at: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp:68
+static llvm::cl::opt<bool> PublicOnly(
+    "public-only",
+    llvm::cl::desc("Only document public methods & public fields."),
----------------
Can we make the flag just `--public`?


================
Comment at: clang-tools-extra/test/clang-doc/yaml-record-public-only.cpp:10
+// RUN: cat %t/docs/Class/publicMethod.yaml | FileCheck %s --check-prefix=CHECK-D
+
+struct Struct {
----------------
Add a test case for a function.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48395





More information about the cfe-commits mailing list