brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · ec802d6 Raw
58 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8//9// This file implements the main entry point for the clang-doc tool. It runs10// the clang-doc mapper on a given set of source code files using a11// 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) {}28  std::unique_ptr<FrontendAction> create() override;29 30private:31  ClangDocContext CDCtx;32};33 34std::unique_ptr<FrontendAction> MapperActionFactory::create() {35  class ClangDocAction : public clang::ASTFrontendAction {36  public:37    ClangDocAction(ClangDocContext CDCtx) : CDCtx(CDCtx) {}38 39    std::unique_ptr<clang::ASTConsumer>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 51std::unique_ptr<tooling::FrontendActionFactory>52newMapperActionFactory(ClangDocContext CDCtx) {53  return std::make_unique<MapperActionFactory>(CDCtx);54}55 56} // namespace doc57} // namespace clang58