
Introducing a plugin API and a simple HelloWorld Plugin example. This patch adds the `-load` and `-plugin` flags to frontend driver and the code around using custom frontend actions from within a plugin shared library object. It also adds to the Driver-help test to check the help option with the updated driver flags. Additionally, the patch creates a plugin-example test to check the HelloWorld plugin example runs correctly. As part of this, a new CMake flag (`FLANG_BUILD_EXAMPLES`) is added to allow the example to be built and for the test to run. This Plugin API has only been tested on Linux. Reviewed By: awarzynski Differential Revision: https://reviews.llvm.org/D106137
26 lines
942 B
C++
26 lines
942 B
C++
//===-- HelloWorldPlugin.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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Basic example Flang plugin which simply prints a Hello World statement
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "flang/Frontend/FrontendActions.h"
|
|
#include "flang/Frontend/FrontendPluginRegistry.h"
|
|
|
|
using namespace Fortran::frontend;
|
|
|
|
class HelloWorldFlangPlugin : public PluginParseTreeAction {
|
|
void ExecuteAction() override {
|
|
llvm::outs() << "Hello World from your new Flang plugin\n";
|
|
}
|
|
};
|
|
|
|
static FrontendPluginRegistry::Add<HelloWorldFlangPlugin> X(
|
|
"-hello-world", "Hello World Plugin example");
|