[AMDGPU][AsmParser][NFC] Translate parsed MIMG instructions to MCInsts automatically.
[llvm-project.git] / clang-tools-extra / clang-doc / ClangDoc.cpp
blobda4165a18d04cbddc8ac98bc94e360dae8124174
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.
13 //===----------------------------------------------------------------------===//
15 #include "ClangDoc.h"
16 #include "Mapper.h"
17 #include "Representation.h"
18 #include "clang/AST/AST.h"
19 #include "clang/AST/ASTConsumer.h"
20 #include "clang/AST/ASTContext.h"
21 #include "clang/AST/RecursiveASTVisitor.h"
22 #include "clang/Frontend/ASTConsumers.h"
23 #include "clang/Frontend/CompilerInstance.h"
24 #include "clang/Frontend/FrontendActions.h"
26 namespace clang {
27 namespace doc {
29 class MapperActionFactory : public tooling::FrontendActionFactory {
30 public:
31 MapperActionFactory(ClangDocContext CDCtx) : CDCtx(CDCtx) {}
32 std::unique_ptr<FrontendAction> create() override;
34 private:
35 ClangDocContext CDCtx;
38 std::unique_ptr<FrontendAction> MapperActionFactory::create() {
39 class ClangDocAction : public clang::ASTFrontendAction {
40 public:
41 ClangDocAction(ClangDocContext CDCtx) : CDCtx(CDCtx) {}
43 std::unique_ptr<clang::ASTConsumer>
44 CreateASTConsumer(clang::CompilerInstance &Compiler,
45 llvm::StringRef InFile) override {
46 return std::make_unique<MapASTVisitor>(&Compiler.getASTContext(), CDCtx);
49 private:
50 ClangDocContext CDCtx;
52 return std::make_unique<ClangDocAction>(CDCtx);
55 std::unique_ptr<tooling::FrontendActionFactory>
56 newMapperActionFactory(ClangDocContext CDCtx) {
57 return std::make_unique<MapperActionFactory>(CDCtx);
60 } // namespace doc
61 } // namespace clang