llvm/clang/examples/LLVMPrintFunctionNames/LLVMPrintFunctionNames.cpp

//===- LLVMPrintFunctionNames.cpp
//---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Example clang plugin which simply prints the names of all the functions
// within the generated LLVM code.
//
//===----------------------------------------------------------------------===//

#include "clang/AST/AST.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendPluginRegistry.h"
#include "clang/Sema/Sema.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Passes/OptimizationLevel.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Support/raw_ostream.h"
usingnamespaceclang;

namespace {

class PrintPass final : public llvm::AnalysisInfoMixin<PrintPass> {};

void PrintCallback(llvm::PassBuilder &PB) {}

class LLVMPrintFunctionsConsumer : public ASTConsumer {};

class LLVMPrintFunctionNamesAction : public PluginASTAction {};

} // namespace

static FrontendPluginRegistry::Add<LLVMPrintFunctionNamesAction>
    X("llvm-print-fns", "print function names, llvm level");