From 978d498e401c292b6be5248abaf828b66739bcb8 Mon Sep 17 00:00:00 2001 From: Mikhail Glushenkov Date: Tue, 6 May 2008 18:13:00 +0000 Subject: [PATCH] Add a --linker command-line option, make all tests pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50755 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/LLVMC/false.c | 4 ++-- test/LLVMC/hello.cpp | 2 +- tools/llvmc2/Example.td | 9 ++++++- tools/llvmc2/Tools.td | 25 ++++++++++---------- utils/TableGen/LLVMCConfigurationEmitter.cpp | 11 +++++---- 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/test/LLVMC/false.c b/test/LLVMC/false.c index 80e9e03b543..8319036c363 100644 --- a/test/LLVMC/false.c +++ b/test/LLVMC/false.c @@ -1,5 +1,5 @@ // Test that we can compile .c files as C++ and vice versa -// RUN: llvmc2 -x c++ %s -x c %p/false.cpp -x lisp -x whatnot -x none %p/false2.cpp -o %t +// RUN: llvmc2 --linker=c++ -x c++ %s -x c %p/false.cpp -x lisp -x whatnot -x none %p/false2.cpp -o %t // RUN: ./%t | grep hello #include @@ -10,5 +10,5 @@ extern std::string test2(); int main() { std::cout << "h"; test(); - std::cout << test2() << '\n'; + std::cout << test2() << '\n'; } diff --git a/test/LLVMC/hello.cpp b/test/LLVMC/hello.cpp index a3148c3c164..4b45ea945e0 100644 --- a/test/LLVMC/hello.cpp +++ b/test/LLVMC/hello.cpp @@ -1,5 +1,5 @@ // Test that we can compile C++ code. -// RUN: llvmc2 %s -o %t +// RUN: llvmc2 --linker=c++ %s -o %t // RUN: ./%t | grep hello #include diff --git a/tools/llvmc2/Example.td b/tools/llvmc2/Example.td index 57629904d18..227090258a9 100644 --- a/tools/llvmc2/Example.td +++ b/tools/llvmc2/Example.td @@ -33,6 +33,13 @@ def CompilationGraph : CompilationGraph<[ Edge, Edge, + OptionalEdge, - Edge + + Edge, + OptionalEdge ]>; diff --git a/tools/llvmc2/Tools.td b/tools/llvmc2/Tools.td index 897892415eb..e803915da65 100644 --- a/tools/llvmc2/Tools.td +++ b/tools/llvmc2/Tools.td @@ -81,19 +81,18 @@ def llvm_gcc_linker : Tool< ]>; // Alternative linker for C++ -// TOTHINK: how to implement this best? -// Something like input_file_language can only choose between two languages. -// def llvm_gcc_cpp_linker : Tool< -// [(in_language "object-code"), -// (out_language "executable"), -// (output_suffix "out"), -// (cmd_line "llvm-g++ $INFILE -o $OUTFILE"), -// (join), -// //(input_file_language "c++"), -// (prefix_list_option "L", (forward)), -// (prefix_list_option "l", (forward)), -// (prefix_list_option "Wl", (unpack_values)) -// ]>; +def llvm_gcc_cpp_linker : Tool< +[(in_language "object-code"), + (out_language "executable"), + (output_suffix "out"), + (cmd_line "llvm-g++ $INFILE -o $OUTFILE"), + (join), + (parameter_option "linker", + (help "Choose linker (possible values: gcc, g++)")), + (prefix_list_option "L", (forward)), + (prefix_list_option "l", (forward)), + (prefix_list_option "Wl", (unpack_values)) +]>; // Language map diff --git a/utils/TableGen/LLVMCConfigurationEmitter.cpp b/utils/TableGen/LLVMCConfigurationEmitter.cpp index aaa10992d99..32b6d383288 100644 --- a/utils/TableGen/LLVMCConfigurationEmitter.cpp +++ b/utils/TableGen/LLVMCConfigurationEmitter.cpp @@ -175,11 +175,12 @@ struct GlobalOptionDescription : public OptionDescription { if (other.Type != Type) throw "Conflicting definitions for the option " + Name + "!"; - if (Help.empty() && !other.Help.empty()) + if (Help == DefaultHelpString) Help = other.Help; - else if (!Help.empty() && !other.Help.empty()) - cerr << "Warning: more than one help string defined for option " + else if (other.Help != DefaultHelpString) { + llvm::cerr << "Warning: more than one help string defined for option " + Name + "\n"; + } Flags |= other.Flags; } @@ -290,8 +291,8 @@ struct ToolProperties : public RefCountedBase { // Default ctor here is needed because StringMap can only store // DefaultConstructible objects - ToolProperties() {} - ToolProperties (const std::string& n) : Name(n) {} + ToolProperties() : Flags(0) {} + ToolProperties (const std::string& n) : Name(n), Flags(0) {} }; -- 2.34.1