Skip to content

Commit

Permalink
Add TableGen-based generator for command line arguments
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
devajithvs authored and jenkins committed Feb 23, 2024
1 parent c5692e7 commit c917ab5
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 51 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ if (TARGET clang-headers)
list(APPEND LLVM_COMMON_DEPENDS clang-headers)
endif()

add_subdirectory(include/cling/Interpreter)
add_subdirectory(lib)

if( CLING_INCLUDE_TESTS )
Expand Down
5 changes: 5 additions & 0 deletions include/cling/Interpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
49 changes: 0 additions & 49 deletions include/cling/Interpreter/ClingOptions.inc

This file was deleted.

29 changes: 29 additions & 0 deletions include/cling/Interpreter/ClingOptions.td
Original file line number Diff line number Diff line change
@@ -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">;
4 changes: 2 additions & 2 deletions lib/Interpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ set(LLVM_LINK_COMPONENTS

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

0 comments on commit c917ab5

Please sign in to comment.