[clang-tools-extra] r337602 - [clang-doc] Adding PublicOnly flag

Julie Hockett via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 20 11:49:55 PDT 2018


Author: juliehockett
Date: Fri Jul 20 11:49:55 2018
New Revision: 337602

URL: http://llvm.org/viewvc/llvm-project?rev=337602&view=rev
Log:
[clang-doc] Adding PublicOnly flag

Submitted on behalf of Annie Cherkaev (@anniecherk)

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

Differential Revision: https://reviews.llvm.org/D48395

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

Modified: clang-tools-extra/trunk/clang-doc/ClangDoc.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/ClangDoc.cpp?rev=337602&r1=337601&r2=337602&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-doc/ClangDoc.cpp (original)
+++ clang-tools-extra/trunk/clang-doc/ClangDoc.cpp Fri Jul 20 11:49:55 2018
@@ -15,6 +15,7 @@
 
 #include "ClangDoc.h"
 #include "Mapper.h"
+#include "Representation.h"
 #include "clang/AST/AST.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
@@ -28,33 +29,33 @@ namespace doc {
 
 class MapperActionFactory : public tooling::FrontendActionFactory {
 public:
-  MapperActionFactory(tooling::ExecutionContext *ECtx) : ECtx(ECtx) {}
+  MapperActionFactory(ClangDocContext CDCtx) : CDCtx(CDCtx) {}
   clang::FrontendAction *create() override;
 
 private:
-  tooling::ExecutionContext *ECtx;
+  ClangDocContext CDCtx;
 };
 
 clang::FrontendAction *MapperActionFactory::create() {
   class ClangDocAction : public clang::ASTFrontendAction {
   public:
-    ClangDocAction(ExecutionContext *ECtx) : ECtx(ECtx) {}
+    ClangDocAction(ClangDocContext CDCtx) : CDCtx(CDCtx) {}
 
     std::unique_ptr<clang::ASTConsumer>
     CreateASTConsumer(clang::CompilerInstance &Compiler,
                       llvm::StringRef InFile) override {
-      return llvm::make_unique<MapASTVisitor>(&Compiler.getASTContext(), ECtx);
+      return llvm::make_unique<MapASTVisitor>(&Compiler.getASTContext(), CDCtx);
     }
 
   private:
-    ExecutionContext *ECtx;
+    ClangDocContext CDCtx;
   };
-  return new ClangDocAction(ECtx);
+  return new ClangDocAction(CDCtx);
 }
 
 std::unique_ptr<tooling::FrontendActionFactory>
-newMapperActionFactory(tooling::ExecutionContext *ECtx) {
-  return llvm::make_unique<MapperActionFactory>(ECtx);
+newMapperActionFactory(ClangDocContext CDCtx) {
+  return llvm::make_unique<MapperActionFactory>(CDCtx);
 }
 
 } // namespace doc

Modified: clang-tools-extra/trunk/clang-doc/ClangDoc.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/ClangDoc.h?rev=337602&r1=337601&r2=337602&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-doc/ClangDoc.h (original)
+++ clang-tools-extra/trunk/clang-doc/ClangDoc.h Fri Jul 20 11:49:55 2018
@@ -17,6 +17,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_CLANGDOC_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_CLANGDOC_H
 
+#include "Representation.h"
 #include "clang/Tooling/Execution.h"
 #include "clang/Tooling/StandaloneExecution.h"
 #include "clang/Tooling/Tooling.h"
@@ -25,7 +26,7 @@ namespace clang {
 namespace doc {
 
 std::unique_ptr<tooling::FrontendActionFactory>
-newMapperActionFactory(tooling::ExecutionContext *ECtx);
+newMapperActionFactory(ClangDocContext CDCtx);
 
 } // namespace doc
 } // namespace clang

Modified: clang-tools-extra/trunk/clang-doc/Mapper.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/Mapper.cpp?rev=337602&r1=337601&r2=337602&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-doc/Mapper.cpp (original)
+++ clang-tools-extra/trunk/clang-doc/Mapper.cpp Fri Jul 20 11:49:55 2018
@@ -33,10 +33,14 @@ template <typename T> bool MapASTVisitor
   if (index::generateUSRForDecl(D, USR))
     return true;
 
-  ECtx->reportResult(llvm::toHex(llvm::toStringRef(serialize::hashUSR(USR))),
-                     serialize::emitInfo(D, getComment(D, D->getASTContext()),
-                                         getLine(D, D->getASTContext()),
-                                         getFile(D, D->getASTContext())));
+  std::string info = serialize::emitInfo(
+      D, getComment(D, D->getASTContext()), getLine(D, D->getASTContext()),
+      getFile(D, D->getASTContext()), CDCtx.PublicOnly);
+
+  if (info != "")
+    CDCtx.ECtx->reportResult(
+        llvm::toHex(llvm::toStringRef(serialize::hashUSR(USR))), info);
+
   return true;
 }
 

Modified: clang-tools-extra/trunk/clang-doc/Mapper.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/Mapper.h?rev=337602&r1=337601&r2=337602&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-doc/Mapper.h (original)
+++ clang-tools-extra/trunk/clang-doc/Mapper.h Fri Jul 20 11:49:55 2018
@@ -18,6 +18,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_MAPPER_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_MAPPER_H
 
+#include "Representation.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Tooling/Execution.h"
 
@@ -30,8 +31,8 @@ namespace doc {
 class MapASTVisitor : public clang::RecursiveASTVisitor<MapASTVisitor>,
                       public ASTConsumer {
 public:
-  explicit MapASTVisitor(ASTContext *Ctx, ExecutionContext *ECtx)
-      : ECtx(ECtx) {}
+  explicit MapASTVisitor(ASTContext *Ctx, ClangDocContext CDCtx)
+      : CDCtx(CDCtx) {}
 
   void HandleTranslationUnit(ASTContext &Context) override;
   bool VisitNamespaceDecl(const NamespaceDecl *D);
@@ -48,7 +49,7 @@ private:
   comments::FullComment *getComment(const NamedDecl *D,
                                     const ASTContext &Context) const;
 
-  ExecutionContext *ECtx;
+  ClangDocContext CDCtx;
 };
 
 } // namespace doc

Modified: clang-tools-extra/trunk/clang-doc/Representation.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/Representation.cpp?rev=337602&r1=337601&r2=337602&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-doc/Representation.cpp (original)
+++ clang-tools-extra/trunk/clang-doc/Representation.cpp Fri Jul 20 11:49:55 2018
@@ -42,7 +42,7 @@ llvm::Expected<std::unique_ptr<Info>>
 mergeInfos(std::vector<std::unique_ptr<Info>> &Values) {
   if (Values.empty())
     return llvm::make_error<llvm::StringError>("No info values to merge.\n",
-                                             llvm::inconvertibleErrorCode());
+                                               llvm::inconvertibleErrorCode());
 
   switch (Values[0]->IT) {
   case InfoType::IT_namespace:

Modified: clang-tools-extra/trunk/clang-doc/Representation.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/Representation.h?rev=337602&r1=337601&r2=337602&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-doc/Representation.h (original)
+++ clang-tools-extra/trunk/clang-doc/Representation.h Fri Jul 20 11:49:55 2018
@@ -17,6 +17,7 @@
 
 #include "clang/AST/Type.h"
 #include "clang/Basic/Specifiers.h"
+#include "clang/Tooling/StandaloneExecution.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
@@ -239,6 +240,11 @@ struct EnumInfo : public SymbolInfo {
 llvm::Expected<std::unique_ptr<Info>>
 mergeInfos(std::vector<std::unique_ptr<Info>> &Values);
 
+struct ClangDocContext {
+  tooling::ExecutionContext *ECtx;
+  bool PublicOnly;
+};
+
 } // namespace doc
 } // namespace clang
 

Modified: clang-tools-extra/trunk/clang-doc/Serialize.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/Serialize.cpp?rev=337602&r1=337601&r2=337602&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-doc/Serialize.cpp (original)
+++ clang-tools-extra/trunk/clang-doc/Serialize.cpp Fri Jul 20 11:49:55 2018
@@ -171,8 +171,20 @@ static RecordDecl *getDeclForType(const
   return Ty->getDecl()->getDefinition();
 }
 
-static void parseFields(RecordInfo &I, const RecordDecl *D) {
+static bool isPublic(const clang::AccessSpecifier AS,
+                     const clang::Linkage Link) {
+  if (AS == clang::AccessSpecifier::AS_private)
+    return false;
+  else if ((Link == clang::Linkage::ModuleLinkage) ||
+           (Link == clang::Linkage::ExternalLinkage))
+    return true;
+  return false; // otherwise, linkage is some form of internal linkage
+}
+
+static void parseFields(RecordInfo &I, const RecordDecl *D, bool PublicOnly) {
   for (const FieldDecl *F : D->fields()) {
+    if (PublicOnly && !isPublic(F->getAccessUnsafe(), F->getLinkageInternal()))
+      continue;
     if (const auto *T = getDeclForType(F->getTypeSourceInfo()->getType())) {
       // Use getAccessUnsafe so that we just get the default AS_none if it's not
       // valid, as opposed to an assert.
@@ -295,25 +307,32 @@ static void populateFunctionInfo(Functio
 }
 
 std::string emitInfo(const NamespaceDecl *D, const FullComment *FC,
-                     int LineNumber, llvm::StringRef File) {
+                     int LineNumber, llvm::StringRef File, bool PublicOnly) {
+  if (PublicOnly && ((D->isAnonymousNamespace()) ||
+                     !isPublic(D->getAccess(), D->getLinkageInternal())))
+    return "";
   NamespaceInfo I;
   populateInfo(I, D, FC);
   return serialize(I);
 }
 
 std::string emitInfo(const RecordDecl *D, const FullComment *FC, int LineNumber,
-                     llvm::StringRef File) {
+                     llvm::StringRef File, bool PublicOnly) {
+  if (PublicOnly && !isPublic(D->getAccess(), D->getLinkageInternal()))
+    return "";
   RecordInfo I;
   populateSymbolInfo(I, D, FC, LineNumber, File);
   I.TagType = D->getTagKind();
-  parseFields(I, D);
+  parseFields(I, D, PublicOnly);
   if (const auto *C = dyn_cast<CXXRecordDecl>(D))
     parseBases(I, C);
   return serialize(I);
 }
 
 std::string emitInfo(const FunctionDecl *D, const FullComment *FC,
-                     int LineNumber, llvm::StringRef File) {
+                     int LineNumber, llvm::StringRef File, bool PublicOnly) {
+  if (PublicOnly && !isPublic(D->getAccess(), D->getLinkageInternal()))
+    return "";
   FunctionInfo I;
   populateFunctionInfo(I, D, FC, LineNumber, File);
   I.Access = clang::AccessSpecifier::AS_none;
@@ -321,7 +340,9 @@ std::string emitInfo(const FunctionDecl
 }
 
 std::string emitInfo(const CXXMethodDecl *D, const FullComment *FC,
-                     int LineNumber, llvm::StringRef File) {
+                     int LineNumber, llvm::StringRef File, bool PublicOnly) {
+  if (PublicOnly && !isPublic(D->getAccess(), D->getLinkageInternal()))
+    return "";
   FunctionInfo I;
   populateFunctionInfo(I, D, FC, LineNumber, File);
   I.IsMethod = true;
@@ -332,7 +353,9 @@ std::string emitInfo(const CXXMethodDecl
 }
 
 std::string emitInfo(const EnumDecl *D, const FullComment *FC, int LineNumber,
-                     llvm::StringRef File) {
+                     llvm::StringRef File, bool PublicOnly) {
+  if (PublicOnly && !isPublic(D->getAccess(), D->getLinkageInternal()))
+    return "";
   EnumInfo I;
   populateSymbolInfo(I, D, FC, LineNumber, File);
   I.Scoped = D->isScoped();

Modified: clang-tools-extra/trunk/clang-doc/Serialize.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/Serialize.h?rev=337602&r1=337601&r2=337602&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-doc/Serialize.h (original)
+++ clang-tools-extra/trunk/clang-doc/Serialize.h Fri Jul 20 11:49:55 2018
@@ -29,15 +29,15 @@ namespace doc {
 namespace serialize {
 
 std::string emitInfo(const NamespaceDecl *D, const FullComment *FC,
-                     int LineNumber, StringRef File);
+                     int LineNumber, StringRef File, bool PublicOnly);
 std::string emitInfo(const RecordDecl *D, const FullComment *FC, int LineNumber,
-                     StringRef File);
+                     StringRef File, bool PublicOnly);
 std::string emitInfo(const EnumDecl *D, const FullComment *FC, int LineNumber,
-                     StringRef File);
+                     StringRef File, bool PublicOnly);
 std::string emitInfo(const FunctionDecl *D, const FullComment *FC,
-                     int LineNumber, StringRef File);
+                     int LineNumber, StringRef File, bool PublicOnly);
 std::string emitInfo(const CXXMethodDecl *D, const FullComment *FC,
-                     int LineNumber, StringRef File);
+                     int LineNumber, StringRef File, bool PublicOnly);
 
 // Function to hash a given USR value for storage.
 // As USRs (Unified Symbol Resolution) could be large, especially for functions

Modified: clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp?rev=337602&r1=337601&r2=337602&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp (original)
+++ clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp Fri Jul 20 11:49:55 2018
@@ -64,6 +64,10 @@ static llvm::cl::opt<bool> DumpIntermedi
     llvm::cl::desc("Dump intermediate results to bitcode file."),
     llvm::cl::init(false), llvm::cl::cat(ClangDocCategory));
 
+static llvm::cl::opt<bool>
+    PublicOnly("public", llvm::cl::desc("Document only public declarations."),
+               llvm::cl::init(false), llvm::cl::cat(ClangDocCategory));
+
 enum OutputFormatTy {
   yaml,
 };
@@ -171,9 +175,10 @@ int main(int argc, const char **argv) {
 
   // Mapping phase
   llvm::outs() << "Mapping decls...\n";
-  auto Err = Exec->get()->execute(
-      doc::newMapperActionFactory(Exec->get()->getExecutionContext()),
-      ArgAdjuster);
+  clang::doc::ClangDocContext CDCtx = {Exec->get()->getExecutionContext(),
+                                       PublicOnly};
+  auto Err =
+      Exec->get()->execute(doc::newMapperActionFactory(CDCtx), ArgAdjuster);
   if (Err) {
     llvm::errs() << toString(std::move(Err)) << "\n";
     return 1;

Added: clang-tools-extra/trunk/test/clang-doc/module.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-doc/module.cpp?rev=337602&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-doc/module.cpp (added)
+++ clang-tools-extra/trunk/test/clang-doc/module.cpp Fri Jul 20 11:49:55 2018
@@ -0,0 +1,61 @@
+// 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:             '{{[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:            'moduleFunction'
+// CHECK-A-NEXT: Location:
+// CHECK-A-NEXT:   - LineNumber:      12
+// 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:            'int'
+// CHECK-A-NEXT: ...
+
+static int staticModuleFunction(int x); //ModuleInternalLinkage
+// 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:            'staticModuleFunction'
+// CHECK-B-NEXT: Location:
+// CHECK-B-NEXT:   - LineNumber:      28
+// 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: ...
+
+export double exportedModuleFunction(double y, int z); //ExternalLinkage
+// 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:            'exportedModuleFunction'
+// CHECK-C-NEXT: Location:
+// CHECK-C-NEXT:   - LineNumber:      44
+// CHECK-C-NEXT:     Filename:        {{.*}}
+// 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: ...

Added: clang-tools-extra/trunk/test/clang-doc/public-module.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-doc/public-module.cpp?rev=337602&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-doc/public-module.cpp (added)
+++ clang-tools-extra/trunk/test/clang-doc/public-module.cpp Fri Jul 20 11:49:55 2018
@@ -0,0 +1,53 @@
+// This test requires linux because it uses `diff` and compares filepaths
+// REQUIRES: system-linux
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --public --extra-arg=-fmodules-ts --doxygen -p %t %t/test.cpp -output=%t/docs-with-public-flag
+// RUN: clang-doc --extra-arg=-fmodules-ts --doxygen -p %t %t/test.cpp -output=%t/docs-without
+// RUN: cat %t/docs-with-public-flag/moduleFunction.yaml | FileCheck %s --check-prefix=CHECK-A
+// RUN: cat %t/docs-with-public-flag/exportedModuleFunction.yaml | FileCheck %s --check-prefix=CHECK-B
+// RUN: (diff -qry %t/docs-with-public-flag %t/docs-without | sed 's:.*/::' > %t/public.diff) || true
+// RUN: cat %t/public.diff | FileCheck %s --check-prefix=CHECK-C
+
+export module M;
+
+int moduleFunction(int x); //ModuleLinkage
+// 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:            'moduleFunction'
+// CHECK-A-NEXT: Location:
+// CHECK-A-NEXT:   - LineNumber:      16
+// 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:            'int'
+// CHECK-A-NEXT: ...
+
+static int staticModuleFunction(int x); //ModuleInternalLinkage
+
+export double exportedModuleFunction(double y, int z); //ExternalLinkage
+// 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:            'exportedModuleFunction'
+// CHECK-B-NEXT: Location:
+// CHECK-B-NEXT:   - LineNumber:      34
+// CHECK-B-NEXT:     Filename:        {{.*}}
+// CHECK-B-NEXT: Params:
+// CHECK-B-NEXT:   - Type:
+// CHECK-B-NEXT:       Name:            'double'
+// CHECK-B-NEXT:     Name:            'y'
+// CHECK-B-NEXT:   - Type:
+// CHECK-B-NEXT:       Name:            'int'
+// CHECK-B-NEXT:     Name:            'z'
+// CHECK-B-NEXT: ReturnType:
+// CHECK-B-NEXT:   Type:
+// CHECK-B-NEXT:     Name:            'double'
+// CHECK-B-NEXT: ...
+
+// CHECK-C: docs-without: staticModuleFunction.yaml

Added: clang-tools-extra/trunk/test/clang-doc/public-records.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-doc/public-records.cpp?rev=337602&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-doc/public-records.cpp (added)
+++ clang-tools-extra/trunk/test/clang-doc/public-records.cpp Fri Jul 20 11:49:55 2018
@@ -0,0 +1,341 @@
+// This test requires linux because it uses `diff` and compares filepaths
+// REQUIRES: system-linux
+// 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:      25
+// 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:      42
+// 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:      59
+// CHECK-C-NEXT:   Filename:        {{.*}}
+// 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:             '{{[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-D-NEXT: Name:            'inlinedFunctionWithInnerClass'
+// CHECK-D-NEXT: DefLocation:
+// CHECK-D-NEXT:   LineNumber:      83
+// CHECK-D-NEXT:   Filename:        {{.*}}
+// CHECK-D-NEXT: Params:
+// CHECK-D-NEXT:   - Type:
+// CHECK-D-NEXT:       Name:            'int'
+// CHECK-D-NEXT:     Name:            'x'
+// CHECK-D-NEXT: ReturnType:
+// CHECK-D-NEXT:   Type:
+// CHECK-D-NEXT:     Name:            'int'
+// CHECK-D-NEXT: ...
+
+class Class {
+ public:
+  void publicMethod();
+  int  publicField;
+ protected:
+  void protectedMethod();
+  int  protectedField;
+ private:
+  void privateMethod();
+  int  privateField;
+};
+
+// CHECK-E: ---
+// CHECK-E-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-E-NEXT: Name:            'publicMethod'
+// CHECK-E-NEXT: Namespace:
+// CHECK-E-NEXT:   - Type:            Record
+// CHECK-E-NEXT:     Name:            'Class'
+// CHECK-E-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-E-NEXT: Location:
+// CHECK-E-NEXT:   - LineNumber:      109
+// CHECK-E-NEXT:     Filename:        {{.*}}
+// CHECK-E-NEXT: IsMethod:        true
+// CHECK-E-NEXT: Parent:
+// CHECK-E-NEXT:   Type:            Record
+// CHECK-E-NEXT:   Name:            'Class'
+// CHECK-E-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-E-NEXT: ReturnType:
+// CHECK-E-NEXT:   Type:
+// CHECK-E-NEXT:     Name:            'void'
+// CHECK-E-NEXT: ...
+
+// CHECK-F: ---
+// CHECK-F-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-F-NEXT: Name:            'Class'
+// CHECK-F-NEXT: DefLocation:
+// CHECK-F-NEXT:   LineNumber:      107
+// CHECK-F-NEXT:   Filename:        {{.*}}
+// CHECK-F-NEXT: TagType:         Class
+// CHECK-F-NEXT: Members:
+// CHECK-F-NEXT:   - Type:
+// CHECK-F-NEXT:       Name:            'int'
+// CHECK-F-NEXT:     Name:            'publicField'
+// CHECK-F-NEXT:   - Type:
+// CHECK-F-NEXT:       Name:            'int'
+// CHECK-F-NEXT:     Name:            'protectedField'
+// CHECK-F-NEXT:     Access:          Protected
+// CHECK-F-NEXT: ...
+
+// CHECK-G: ---
+// CHECK-G-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-G-NEXT: Name:            'protectedMethod'
+// CHECK-G-NEXT: Namespace:
+// CHECK-G-NEXT:   - Type:            Record
+// CHECK-G-NEXT:     Name:            'Class'
+// CHECK-G-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-G-NEXT: Location:
+// CHECK-G-NEXT:   - LineNumber:      112
+// CHECK-G-NEXT:     Filename:        {{.*}}
+// CHECK-G-NEXT: IsMethod:        true
+// CHECK-G-NEXT: Parent:
+// CHECK-G-NEXT:   Type:            Record
+// CHECK-G-NEXT:   Name:            'Class'
+// CHECK-G-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-G-NEXT: ReturnType:
+// CHECK-G-NEXT:   Type:
+// CHECK-G-NEXT:     Name:            'void'
+// CHECK-G-NEXT: ...
+
+namespace named{
+    class NamedClass {
+     public:
+      void namedPublicMethod();
+      int  namedPublicField;
+     protected:
+      void namedProtectedMethod();
+      int  namedProtectedField;
+     private:
+      void namedPrivateMethod();
+      int  namedPrivateField;
+    };
+
+    void namedFunction();
+    static void namedStaticFunction();
+    inline void namedInlineFunction();
+}
+
+// CHECK-H: ---
+// CHECK-H-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-H-NEXT: Name:            'named'
+// CHECK-H-NEXT: ...
+
+// CHECK-I: ---
+// CHECK-I-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-I-NEXT: Name:            'NamedClass'
+// CHECK-I-NEXT: Namespace:
+// CHECK-I-NEXT:   - Type:            Namespace
+// CHECK-I-NEXT:     Name:            'named'
+// CHECK-I-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-I-NEXT: DefLocation:
+// CHECK-I-NEXT:   LineNumber:      177
+// CHECK-I-NEXT:   Filename:        {{.*}}
+// CHECK-I-NEXT: TagType:         Class
+// CHECK-I-NEXT: Members:
+// CHECK-I-NEXT:   - Type:
+// CHECK-I-NEXT:       Name:            'int'
+// CHECK-I-NEXT:     Name:            'namedPublicField'
+// CHECK-I-NEXT:   - Type:
+// CHECK-I-NEXT:       Name:            'int'
+// CHECK-I-NEXT:     Name:            'namedProtectedField'
+// CHECK-I-NEXT:     Access:          Protected
+// CHECK-I-NEXT: ...
+
+// CHECK-J: ---
+// CHECK-J-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-J-NEXT: Name:            'namedFunction'
+// CHECK-J-NEXT: Namespace:
+// CHECK-J-NEXT:   - Type:            Namespace
+// CHECK-J-NEXT:     Name:            'named'
+// CHECK-J-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-J-NEXT: Location:
+// CHECK-J-NEXT:   - LineNumber:      189
+// CHECK-J-NEXT:     Filename:        {{.*}}
+// CHECK-J-NEXT: ReturnType:
+// CHECK-J-NEXT:   Type:
+// CHECK-J-NEXT:     Name:            'void'
+// CHECK-J-NEXT: ...
+
+// CHECK-K: ---
+// CHECK-K-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-K-NEXT: Name:            'namedInlineFunction'
+// CHECK-K-NEXT: Namespace:
+// CHECK-K-NEXT:   - Type:            Namespace
+// CHECK-K-NEXT:     Name:            'named'
+// CHECK-K-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-K-NEXT: Location:
+// CHECK-K-NEXT:   - LineNumber:      191
+// CHECK-K-NEXT:     Filename:        {{.*}}
+// CHECK-K-NEXT: ReturnType:
+// CHECK-K-NEXT:   Type:
+// CHECK-K-NEXT:     Name:            'void'
+// CHECK-K-NEXT: ...
+
+// CHECK-L: ---
+// CHECK-L-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-L-NEXT: Name:            'namedPublicMethod'
+// CHECK-L-NEXT: Namespace:
+// CHECK-L-NEXT:   - Type:            Record
+// CHECK-L-NEXT:     Name:            'NamedClass'
+// CHECK-L-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-L-NEXT:   - Type:            Namespace
+// CHECK-L-NEXT:     Name:            'named'
+// CHECK-L-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-L-NEXT: Location:
+// CHECK-L-NEXT:   - LineNumber:      179
+// CHECK-L-NEXT:     Filename:        {{.*}}
+// CHECK-L-NEXT: IsMethod:        true
+// CHECK-L-NEXT: Parent:
+// CHECK-L-NEXT:   Type:            Record
+// CHECK-L-NEXT:   Name:            'NamedClass'
+// CHECK-L-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-L-NEXT: ReturnType:
+// CHECK-L-NEXT:   Type:
+// CHECK-L-NEXT:     Name:            'void'
+// CHECK-L-NEXT: ...
+
+// CHECK-M: ---
+// CHECK-M-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-M-NEXT: Name:            'namedProtectedMethod'
+// CHECK-M-NEXT: Namespace:
+// CHECK-M-NEXT:   - Type:            Record
+// CHECK-M-NEXT:     Name:            'NamedClass'
+// CHECK-M-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-M-NEXT:   - Type:            Namespace
+// CHECK-M-NEXT:     Name:            'named'
+// CHECK-M-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-M-NEXT: Location:
+// CHECK-M-NEXT:   - LineNumber:      182
+// CHECK-M-NEXT:     Filename:        {{.*}}
+// CHECK-M-NEXT: IsMethod:        true
+// CHECK-M-NEXT: Parent:
+// CHECK-M-NEXT:   Type:            Record
+// CHECK-M-NEXT:   Name:            'NamedClass'
+// CHECK-M-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-M-NEXT: ReturnType:
+// CHECK-M-NEXT:   Type:
+// CHECK-M-NEXT:     Name:            'void'
+// CHECK-M-NEXT: ...
+
+
+static void staticFunction(int x); //Internal Linkage
+
+static int staticFunctionWithInnerClass(int x){
+    class InnerClass { //NoLinkage
+      public:
+        int innerPublicMethod() { return 2; };
+    }; //end class
+    InnerClass temp;
+    return temp.innerPublicMethod();
+};
+
+namespace{
+    class AnonClass {
+     public:
+      void anonPublicMethod();
+      int  anonPublicField;
+     protected:
+      void anonProtectedMethod();
+      int  anonProtectedField;
+     private:
+      void anonPrivateMethod();
+      int  anonPrivateField;
+    };
+
+    void anonFunction();
+    static void anonStaticFunction();
+    inline void anonInlineFunction();
+}
+
+// CHECK-N: docs-without-flag: .yaml
+// CHECK-N-NEXT: docs-without-flag: AnonClass
+// CHECK-N-NEXT: docs-without-flag: AnonClass.yaml
+// CHECK-N-NEXT: Class: privateMethod.yaml
+// CHECK-N-NEXT: Class.yaml differ
+// CHECK-N-NEXT: docs-without-flag: anonFunction.yaml
+// CHECK-N-NEXT: docs-without-flag: anonInlineFunction.yaml
+// CHECK-N-NEXT: docs-without-flag: anonStaticFunction.yaml
+// CHECK-N-NEXT: docs-without-flag: functionWithInnerClass
+// CHECK-N-NEXT: docs-without-flag: inlinedFunctionWithInnerClass
+// CHECK-N-NEXT: NamedClass: namedPrivateMethod.yaml
+// CHECK-N-NEXT: NamedClass.yaml differ
+// CHECK-N-NEXT: named: namedStaticFunction.yaml
+// CHECK-N-NEXT: docs-without-flag: staticFunction.yaml
+// CHECK-N-NEXT: docs-without-flag: staticFunctionWithInnerClass
+// CHECK-N-NEXT: docs-without-flag: staticFunctionWithInnerClass.yaml




More information about the cfe-commits mailing list