diff options
| author | Raphael Isemann <teemperor@gmail.com> | 2019-07-12 15:30:55 +0000 |
|---|---|---|
| committer | Raphael Isemann <teemperor@gmail.com> | 2019-07-12 15:30:55 +0000 |
| commit | 6f4fb4e7ad67499391dd5b63ad9f5a11b1c74171 (patch) | |
| tree | 99d03447ee96b18f63f9134d7c8291dc6c5437ad /lldb/cmake/modules/AddLLDB.cmake | |
| parent | 38cd364007a928d1a1f8d0768a1020a25a54de76 (diff) | |
| download | bcm5719-llvm-6f4fb4e7ad67499391dd5b63ad9f5a11b1c74171.tar.gz bcm5719-llvm-6f4fb4e7ad67499391dd5b63ad9f5a11b1c74171.zip | |
[lldb] Let table gen create command option initializers.
Summary:
We currently have man large arrays containing initializers for our command options.
These tables are tricky maintain as we don't have any good place to check them for consistency and
it's also hard to read (`nullptr, {}, 0` is not very descriptive).
This patch fixes this by letting table gen generate those tables. This way we can have a more readable
syntax for this (especially for all the default arguments) and we can let TableCheck check them
for consistency (e.g. an option with an optional argument can't have `eArgTypeNone`, naming of flags', etc.).
Also refactoring the related data structures can now be done without changing the hundred of option initializers.
For example, this line:
```
{LLDB_OPT_SET_ALL, false, "hide-aliases", 'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Hide aliases in the command list."},
```
becomes this:
```
def hide_aliases : Option<"hide-aliases", "a">, Desc<"Hide aliases in the command list.">;
```
For now I just moved a few initializers to the new format to demonstrate the change. I'll slowly migrate the other
option initializers tables in separate patches.
Reviewers: JDevlieghere, davide, sgraenitz
Reviewed By: JDevlieghere
Subscribers: jingham, xiaobai, labath, mgorny, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D64365
llvm-svn: 365908
Diffstat (limited to 'lldb/cmake/modules/AddLLDB.cmake')
| -rw-r--r-- | lldb/cmake/modules/AddLLDB.cmake | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake index 9859fe7b68a..e5882329867 100644 --- a/lldb/cmake/modules/AddLLDB.cmake +++ b/lldb/cmake/modules/AddLLDB.cmake @@ -1,4 +1,37 @@ +function(lldb_tablegen) + # Syntax: + # lldb_tablegen output-file [tablegen-arg ...] SOURCE source-file + # [[TARGET cmake-target-name] [DEPENDS extra-dependency ...]] + # + # Generates a custom command for invoking tblgen as + # + # tblgen source-file -o=output-file tablegen-arg ... + # + # and, if cmake-target-name is provided, creates a custom target for + # executing the custom command depending on output-file. It is + # possible to list more files to depend after DEPENDS. + + cmake_parse_arguments(LTG "" "SOURCE;TARGET" "" ${ARGN}) + + if(NOT LTG_SOURCE) + message(FATAL_ERROR "SOURCE source-file required by lldb_tablegen") + endif() + + set(LLVM_TARGET_DEFINITIONS ${LTG_SOURCE}) + tablegen(LLDB ${LTG_UNPARSED_ARGUMENTS}) + + if(LTG_TARGET) + add_public_tablegen_target(${LTG_TARGET}) + set_target_properties( ${LTG_TARGET} PROPERTIES FOLDER "LLDB tablegenning") + set_property(GLOBAL APPEND PROPERTY LLDB_TABLEGEN_TARGETS ${LTG_TARGET}) + endif() +endfunction(lldb_tablegen) + function(add_lldb_library name) + include_directories(BEFORE + ${CMAKE_CURRENT_BINARY_DIR} +) + # only supported parameters to this macro are the optional # MODULE;SHARED;STATIC library type and source files cmake_parse_arguments(PARAM @@ -241,4 +274,4 @@ function(lldb_setup_rpaths name) BUILD_RPATH "${LIST_BUILD_RPATH}" INSTALL_RPATH "${LIST_INSTALL_RPATH}" ) -endfunction()
\ No newline at end of file +endfunction() |

