Add TableGen-based generator for command line arguments

Upstream moved away from manually declaring `*def` and `*inc` files. These
are now auto-generated with tablegen. This patch does the same for cling,
making it easier to rebase and maintain.
This commit is contained in:
Devajith Valaparambil Sreeramaswamy 2024-02-06 14:52:32 +01:00 committed by jenkins
parent c5692e71f1
commit c917ab56f3
5 changed files with 37 additions and 51 deletions

View File

@ -546,6 +546,7 @@ if (TARGET clang-headers)
list(APPEND LLVM_COMMON_DEPENDS clang-headers) list(APPEND LLVM_COMMON_DEPENDS clang-headers)
endif() endif()
add_subdirectory(include/cling/Interpreter)
add_subdirectory(lib) add_subdirectory(lib)
if( CLING_INCLUDE_TESTS ) if( CLING_INCLUDE_TESTS )

View File

@ -0,0 +1,5 @@
include_directories(${LLVM_INCLUDE_DIRS})
set(LLVM_TARGET_DEFINITIONS ClingOptions.td)
tablegen(LLVM ClingOptions.inc -gen-opt-parser-defs)
add_public_tablegen_target(ClingDriverOptions)

View File

@ -1,49 +0,0 @@
#ifndef PREFIX
#error "Define PREFIX prior to including this file!"
#endif
/////////
// Prefixes
#define COMMA ,
PREFIX(prefix_0, {llvm::StringLiteral("")})
PREFIX(prefix_1, {llvm::StringLiteral("-") COMMA llvm::StringLiteral("")})
PREFIX(prefix_3, {llvm::StringLiteral("-") COMMA llvm::StringLiteral("--") COMMA llvm::StringLiteral("")})
PREFIX(prefix_2, {llvm::StringLiteral("--") COMMA llvm::StringLiteral("")})
#undef COMMA
#ifndef OPTION
#error "Define OPTION prior to including this file!"
#endif
OPTION(prefix_0, "<input>", INPUT, Input, INVALID, INVALID, 0, 0, 0, 0, 0, 0)
OPTION(prefix_0, "<unknown>", UNKNOWN, Unknown, INVALID, INVALID, 0, 0, 0, 0, 0, 0)
#ifndef NDEBUG
OPTION(prefix_2, "debug-only=", _debugFlags_EQ, Joined, INVALID, INVALID, 0, 0, 0,
"Debug flags to enable", 0, 0)
OPTION(prefix_2, "debug-only", _debugFlags, Separate, INVALID, INVALID, 0, 0, 0,
"Debug flags to enable", 0, 0)
#endif
OPTION(prefix_2, "errorout", _errorout, Flag, INVALID, INVALID, 0, 0, 0,
"Do not recover from input errors", 0, 0)
// Re-implement to forward to our help
OPTION(prefix_3, "help", help, Flag, INVALID, INVALID, 0, 0, 0,
"Print this help text", 0, 0)
OPTION(prefix_1, "L", L, JoinedOrSeparate, INVALID, INVALID, 0, 0, 0,
"Add directory to library search path", "<directory>", 0)
OPTION(prefix_1, "l", l, JoinedOrSeparate, INVALID, INVALID, 0, 0, 0,
"Load a library before prompt", "<library>", 0)
OPTION(prefix_2, "metastr=", _metastr_EQ, Joined, INVALID, INVALID, 0, 0, 0,
"Set the meta command tag, default '.'", 0, 0)
OPTION(prefix_2, "metastr", _metastr, Separate, INVALID, INVALID, 0, 0, 0,
"Set the meta command tag, default '.'", 0, 0)
OPTION(prefix_2, "nologo", _nologo, Flag, INVALID, INVALID, 0, 0, 0,
"Do not show startup-banner", 0, 0)
OPTION(prefix_3, "noruntime", noruntime, Flag, INVALID, INVALID, 0, 0, 0,
"Disable runtime support (no null checking, no value printing)", 0, 0)
OPTION(prefix_2, "ptrcheck", _ptrcheck, Flag, INVALID, INVALID, 0, 0, 0,
"Enable injection of pointer validity checks", 0, 0)
OPTION(prefix_3, "version", version, Flag, INVALID, INVALID, 0, 0, 0,
"Print the compiler version", 0, 0)
OPTION(prefix_1, "v", v, Flag, INVALID, INVALID, 0, 0, 0,
"Enable verbose output", 0, 0)

View File

@ -0,0 +1,29 @@
//===--- ClingOptions.td - Options for cling -----------------------------------===//
//
// CLING - the C++ LLVM-based InterpreterG :)
//
//===----------------------------------------------------------------------===//
//
// This file defines the options accepted by cling.
//
//===----------------------------------------------------------------------===//
// Include the common option parsing interfaces.
include "llvm/Option/OptParser.td"
#ifndef NDEBUG
def _debugFlags_EQ : Joined<["--"], "debug-only=">;
def _debugFlags : Flag<["--"], "debug-only">;
#endif
def _errorout : Flag<["--"], "errorout">, HelpText<"Do not recover from input errors">;
// Re-implement to forward to our help
def help : Flag<["-", "--"], "help">, HelpText<"Print this help text">;
def L : JoinedOrSeparate<["-"], "L">, HelpText<"Add directory to library search path">, MetaVarName<"<directory>">;
def l : JoinedOrSeparate<["-"], "l">, HelpText<"Load a library before prompt">, MetaVarName<"<library>">;
def _metastr_EQ : Joined<["--"], "metastr=">, HelpText<"Set the meta command tag, default '.'">;
def _metastr : Separate<["--"], "metastr">, HelpText<"Set the meta command tag, default '.'">;
def _nologo : Flag<["--"], "nologo">, HelpText<"Do not show startup-banner">;
def noruntime : Flag<["-", "--"], "noruntime">, HelpText<"Disable runtime support (no null checking, no value printing)">;
def _ptrcheck : Flag<["--"], "ptrcheck">, HelpText<"Enable injection of pointer validity checks">;
def version : Flag<["-", "--"], "version">, HelpText<"Print the compiler version">;
def v : Flag<["-"], "v">, HelpText<"Enable verbose output">;

View File

@ -47,9 +47,9 @@ set(LLVM_LINK_COMPONENTS
# clingInterpreter depends on Options.inc to be tablegen-ed # clingInterpreter depends on Options.inc to be tablegen-ed
# (target ClangDriverOptions) from in-tree builds. # (target ClangDriverOptions) from in-tree builds.
set(CLING_DEPENDS) set(CLING_DEPENDS ClingDriverOptions)
if(TARGET ClangDriverOptions) if(TARGET ClangDriverOptions)
set(CLING_DEPENDS ClangDriverOptions) set(CLING_DEPENDS "${CLING_DEPENDS};ClangDriverOptions")
endif() endif()
# clangSema will make sure all of the dependencies of clingInterpreter are met. # clangSema will make sure all of the dependencies of clingInterpreter are met.
if(TARGET clangSema) if(TARGET clangSema)