clang-tools  8.0.0
ClangDoc.cpp
Go to the documentation of this file.
1 //===-- ClangDoc.cpp - ClangDoc ---------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the main entry point for the clang-doc tool. It runs
11 // the clang-doc mapper on a given set of source code files using a
12 // FrontendActionFactory.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #include "ClangDoc.h"
17 #include "Mapper.h"
18 #include "Representation.h"
19 #include "clang/AST/AST.h"
20 #include "clang/AST/ASTConsumer.h"
21 #include "clang/AST/ASTContext.h"
22 #include "clang/AST/RecursiveASTVisitor.h"
23 #include "clang/Frontend/ASTConsumers.h"
24 #include "clang/Frontend/CompilerInstance.h"
25 #include "clang/Frontend/FrontendActions.h"
26 
27 namespace clang {
28 namespace doc {
29 
30 class MapperActionFactory : public tooling::FrontendActionFactory {
31 public:
32  MapperActionFactory(ClangDocContext CDCtx) : CDCtx(CDCtx) {}
33  clang::FrontendAction *create() override;
34 
35 private:
36  ClangDocContext CDCtx;
37 };
38 
39 clang::FrontendAction *MapperActionFactory::create() {
40  class ClangDocAction : public clang::ASTFrontendAction {
41  public:
42  ClangDocAction(ClangDocContext CDCtx) : CDCtx(CDCtx) {}
43 
44  std::unique_ptr<clang::ASTConsumer>
45  CreateASTConsumer(clang::CompilerInstance &Compiler,
46  llvm::StringRef InFile) override {
47  return llvm::make_unique<MapASTVisitor>(&Compiler.getASTContext(), CDCtx);
48  }
49 
50  private:
51  ClangDocContext CDCtx;
52  };
53  return new ClangDocAction(CDCtx);
54 }
55 
56 std::unique_ptr<tooling::FrontendActionFactory>
58  return llvm::make_unique<MapperActionFactory>(CDCtx);
59 }
60 
61 } // namespace doc
62 } // namespace clang
MapperActionFactory(ClangDocContext CDCtx)
Definition: ClangDoc.cpp:32
clang::FrontendAction * create() override
Definition: ClangDoc.cpp:39
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::unique_ptr< tooling::FrontendActionFactory > newMapperActionFactory(ClangDocContext CDCtx)
Definition: ClangDoc.cpp:57