clang-tools 23.0.0git
ClangDoc.cpp
Go to the documentation of this file.
1//===-- ClangDoc.cpp - ClangDoc ---------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the main entry point for the clang-doc tool. It runs
10// the clang-doc mapper on a given set of source code files using a
11// FrontendActionFactory.
12//
13//===----------------------------------------------------------------------===//
14
15#include "ClangDoc.h"
16#include "Mapper.h"
17#include "Representation.h"
18#include "clang/AST/ASTConsumer.h"
19#include "clang/Frontend/ASTConsumers.h"
20#include "clang/Frontend/CompilerInstance.h"
21
22namespace clang {
23namespace doc {
24
25class MapperActionFactory : public tooling::FrontendActionFactory {
26public:
27 MapperActionFactory(ClangDocContext CDCtx) : CDCtx(CDCtx) {}
29
30private:
31 ClangDocContext CDCtx;
32};
33
35 class ClangDocAction : public clang::ASTFrontendAction {
36 public:
37 ClangDocAction(ClangDocContext CDCtx) : CDCtx(CDCtx) {}
38
40 CreateASTConsumer(clang::CompilerInstance &Compiler,
41 llvm::StringRef InFile) override {
42 return std::make_unique<MapASTVisitor>(&Compiler.getASTContext(), CDCtx);
43 }
44
45 private:
46 ClangDocContext CDCtx;
47 };
48 return std::make_unique<ClangDocAction>(CDCtx);
49}
50
53 return std::make_unique<MapperActionFactory>(CDCtx);
54}
55
56} // namespace doc
57} // namespace clang
OwnedPtr< FrontendAction > create() override
Definition ClangDoc.cpp:34
MapperActionFactory(ClangDocContext CDCtx)
Definition ClangDoc.cpp:27
OwnedPtr< tooling::FrontendActionFactory > newMapperActionFactory(ClangDocContext CDCtx)
Definition ClangDoc.cpp:52
std::unique_ptr< T > OwnedPtr
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//