diff --git a/test/LLVMC/ForwardAs.td b/test/LLVMC/ForwardAs.td new file mode 100644 index 00000000000..5e5a087c629 --- /dev/null +++ b/test/LLVMC/ForwardAs.td @@ -0,0 +1,18 @@ +// Check the fix for PR4159. +// http://llvm.org/bugs/show_bug.cgi?id=4159 +// RUN: tblgen -I $srcroot/include --gen-llvmc %s -o %t +// RUN: grep unique_name %t + +include "llvm/CompilerDriver/Common.td" + +def OptList : OptionList<[(parameter_option "dummy", (extern))]>; + +def dummy_tool : Tool<[ +(cmd_line "dummy_cmd"), +(in_language "dummy"), +(out_language "dummy"), +(actions (case + (not_empty "dummy"), (forward_as "dummy", "unique_name"))) +]>; + +def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>; diff --git a/tools/llvmc/doc/LLVMC-Reference.rst b/tools/llvmc/doc/LLVMC-Reference.rst index f6d1843faaf..d99fa0cc6f6 100644 --- a/tools/llvmc/doc/LLVMC-Reference.rst +++ b/tools/llvmc/doc/LLVMC-Reference.rst @@ -529,7 +529,7 @@ The list of all possible actions follows. - ``forward_as`` - Change the name of an option, but forward the argument unchanged. - Example: ``(forward_as "O0" "--disable-optimization")``. + Example: ``(forward_as "O0", "--disable-optimization")``. - ``output_suffix`` - modify the output suffix of this tool. diff --git a/utils/TableGen/LLVMCConfigurationEmitter.cpp b/utils/TableGen/LLVMCConfigurationEmitter.cpp index 2dee3e988ca..0157b61f835 100644 --- a/utils/TableGen/LLVMCConfigurationEmitter.cpp +++ b/utils/TableGen/LLVMCConfigurationEmitter.cpp @@ -1444,7 +1444,7 @@ class EmitActionHandler { else if (ActionName == "forward_as") { checkNumberOfArguments(&Dag, 2); const std::string& Name = InitPtrToString(Dag.getArg(0)); - const std::string& NewName = InitPtrToString(Dag.getArg(0)); + const std::string& NewName = InitPtrToString(Dag.getArg(1)); EmitForwardOptionPropertyHandlingCode(OptDescs.FindOption(Name), IndentLevel, NewName, O); }