[flang][cuda] Adapt ExternalNameConversion to work in gpu module (#117039)
[llvm-project.git] / clang / examples / PluginsOrder / PluginsOrder.cpp
blobe25ab7aceca850636340082d2cbea1097c53ac28
1 //===- PluginsOrder.cpp ---------------------------------------------------===//
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 //===----------------------------------------------------------------------===//
9 #include "clang/AST/AST.h"
10 #include "clang/AST/ASTConsumer.h"
11 #include "clang/Frontend/FrontendPluginRegistry.h"
12 using namespace clang;
14 namespace {
16 class AlwaysBeforeConsumer : public ASTConsumer {
17 public:
18 void HandleTranslationUnit(ASTContext &) override {
19 llvm::errs() << "always-before\n";
23 class AlwaysBeforeAction : public PluginASTAction {
24 public:
25 std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
26 llvm::StringRef) override {
27 return std::make_unique<AlwaysBeforeConsumer>();
30 bool ParseArgs(const CompilerInstance &CI,
31 const std::vector<std::string> &args) override {
32 return true;
35 PluginASTAction::ActionType getActionType() override {
36 return AddBeforeMainAction;
40 class AlwaysAfterConsumer : public ASTConsumer {
41 public:
42 void HandleTranslationUnit(ASTContext &) override {
43 llvm::errs() << "always-after\n";
47 class AlwaysAfterAction : public PluginASTAction {
48 public:
49 std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
50 llvm::StringRef) override {
51 return std::make_unique<AlwaysAfterConsumer>();
54 bool ParseArgs(const CompilerInstance &CI,
55 const std::vector<std::string> &args) override {
56 return true;
59 PluginASTAction::ActionType getActionType() override {
60 return AddAfterMainAction;
64 class CmdAfterConsumer : public ASTConsumer {
65 public:
66 void HandleTranslationUnit(ASTContext &) override {
67 llvm::errs() << "cmd-after\n";
71 class CmdAfterAction : public PluginASTAction {
72 public:
73 std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
74 llvm::StringRef) override {
75 return std::make_unique<CmdAfterConsumer>();
78 bool ParseArgs(const CompilerInstance &CI,
79 const std::vector<std::string> &args) override {
80 return true;
83 PluginASTAction::ActionType getActionType() override {
84 return CmdlineAfterMainAction;
88 class CmdBeforeConsumer : public ASTConsumer {
89 public:
90 void HandleTranslationUnit(ASTContext &) override {
91 llvm::errs() << "cmd-before\n";
95 class CmdBeforeAction : public PluginASTAction {
96 public:
97 std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
98 llvm::StringRef) override {
99 return std::make_unique<CmdBeforeConsumer>();
102 bool ParseArgs(const CompilerInstance &CI,
103 const std::vector<std::string> &args) override {
104 return true;
107 PluginASTAction::ActionType getActionType() override {
108 return CmdlineBeforeMainAction;
112 } // namespace
114 static FrontendPluginRegistry::Add<CmdBeforeAction> X1("cmd-before", "");
115 static FrontendPluginRegistry::Add<CmdAfterAction> X2("cmd-after", "");
116 static FrontendPluginRegistry::Add<AlwaysBeforeAction> X3("always-before", "");
117 static FrontendPluginRegistry::Add<AlwaysAfterAction> X4("always-after", "");