[llvm-commits] [llvm] r83524 - in /llvm/trunk: test/LLVMC/ExternOptions.td test/LLVMC/ForwardAs.td test/LLVMC/MultiValuedOption.td test/LLVMC/NoActions.td test/LLVMC/OneOrMore.td utils/TableGen/LLVMCConfigurationEmitter.cpp
Mikhail Glushenkov
foldr at codedgers.com
Wed Oct 7 21:40:08 PDT 2009
Author: foldr
Date: Wed Oct 7 23:40:08 2009
New Revision: 83524
URL: http://llvm.org/viewvc/llvm-project?rev=83524&view=rev
Log:
Input files should go before all other options.
Important, for example, when calling 'gcc a.o b.o c.o -lD -lE -lF'.
Modified:
llvm/trunk/test/LLVMC/ExternOptions.td
llvm/trunk/test/LLVMC/ForwardAs.td
llvm/trunk/test/LLVMC/MultiValuedOption.td
llvm/trunk/test/LLVMC/NoActions.td
llvm/trunk/test/LLVMC/OneOrMore.td
llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
Modified: llvm/trunk/test/LLVMC/ExternOptions.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/ExternOptions.td?rev=83524&r1=83523&r2=83524&view=diff
==============================================================================
--- llvm/trunk/test/LLVMC/ExternOptions.td (original)
+++ llvm/trunk/test/LLVMC/ExternOptions.td Wed Oct 7 23:40:08 2009
@@ -10,7 +10,7 @@
(prefix_list_option "L", (extern))]>;
def dummy_tool : Tool<[
-(cmd_line "dummy_cmd"),
+(cmd_line "dummy_cmd $INFILE"),
(in_language "dummy"),
(out_language "dummy"),
(actions (case
Modified: llvm/trunk/test/LLVMC/ForwardAs.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/ForwardAs.td?rev=83524&r1=83523&r2=83524&view=diff
==============================================================================
--- llvm/trunk/test/LLVMC/ForwardAs.td (original)
+++ llvm/trunk/test/LLVMC/ForwardAs.td Wed Oct 7 23:40:08 2009
@@ -8,7 +8,7 @@
def OptList : OptionList<[(parameter_option "dummy", (extern))]>;
def dummy_tool : Tool<[
-(cmd_line "dummy_cmd"),
+(cmd_line "dummy_cmd $INFILE"),
(in_language "dummy"),
(out_language "dummy"),
(actions (case
Modified: llvm/trunk/test/LLVMC/MultiValuedOption.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/MultiValuedOption.td?rev=83524&r1=83523&r2=83524&view=diff
==============================================================================
--- llvm/trunk/test/LLVMC/MultiValuedOption.td (original)
+++ llvm/trunk/test/LLVMC/MultiValuedOption.td Wed Oct 7 23:40:08 2009
@@ -10,7 +10,7 @@
(parameter_list_option "baz", (multi_val 2), (extern))]>;
def dummy_tool : Tool<[
-(cmd_line "dummy_cmd"),
+(cmd_line "dummy_cmd $INFILE"),
(in_language "dummy"),
(out_language "dummy"),
(actions (case
Modified: llvm/trunk/test/LLVMC/NoActions.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/NoActions.td?rev=83524&r1=83523&r2=83524&view=diff
==============================================================================
--- llvm/trunk/test/LLVMC/NoActions.td (original)
+++ llvm/trunk/test/LLVMC/NoActions.td Wed Oct 7 23:40:08 2009
@@ -4,7 +4,7 @@
include "llvm/CompilerDriver/Common.td"
def dummy_tool : Tool<[
-(cmd_line "dummy_cmd"),
+(cmd_line "dummy_cmd $INFILE"),
(in_language "dummy"),
(out_language "dummy")
]>;
Modified: llvm/trunk/test/LLVMC/OneOrMore.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/OneOrMore.td?rev=83524&r1=83523&r2=83524&view=diff
==============================================================================
--- llvm/trunk/test/LLVMC/OneOrMore.td (original)
+++ llvm/trunk/test/LLVMC/OneOrMore.td Wed Oct 7 23:40:08 2009
@@ -11,7 +11,7 @@
(parameter_list_option "baz", (zero_or_one))]>;
def dummy_tool : Tool<[
-(cmd_line "dummy_cmd"),
+(cmd_line "dummy_cmd $INFILE"),
(in_language "dummy"),
(out_language "dummy"),
(actions (case
Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=83524&r1=83523&r2=83524&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Wed Oct 7 23:40:08 2009
@@ -1352,12 +1352,15 @@
++I;
}
+ bool hasINFILE = false;
+
for (; I != E; ++I) {
const std::string& cmd = *I;
assert(!cmd.empty());
O.indent(IndentLevel);
if (cmd.at(0) == '$') {
if (cmd == "$INFILE") {
+ hasINFILE = true;
if (IsJoin) {
O << "for (PathVector::const_iterator B = inFiles.begin()"
<< ", E = inFiles.end();\n";
@@ -1369,7 +1372,8 @@
}
}
else if (cmd == "$OUTFILE") {
- O << "vec.push_back(out_file);\n";
+ O << "vec.push_back(\"\");\n";
+ O.indent(IndentLevel) << "out_file_index = vec.size()-1;\n";
}
else {
O << "vec.push_back(";
@@ -1381,8 +1385,10 @@
O << "vec.push_back(\"" << cmd << "\");\n";
}
}
- O.indent(IndentLevel) << "cmd = ";
+ if (!hasINFILE)
+ throw "Tool '" + ToolName + "' doesn't take any input!";
+ O.indent(IndentLevel) << "cmd = ";
if (StrVec[0][0] == '$')
SubstituteSpecialCommands(StrVec.begin(), StrVec.end(), O);
else
@@ -1566,7 +1572,7 @@
}
};
-// EmitGenerateActionMethod - Emit one of two versions of the
+// EmitGenerateActionMethod - Emit either a normal or a "join" version of the
// Tool::GenerateAction() method.
void EmitGenerateActionMethod (const ToolDescription& D,
const OptionDescriptions& OptDescs,
@@ -1586,17 +1592,7 @@
O.indent(Indent2) << "bool stop_compilation = !HasChildren;\n";
O.indent(Indent2) << "const char* output_suffix = \""
<< D.OutputSuffix << "\";\n";
- O.indent(Indent2) << "std::string out_file;\n\n";
-
- // For every understood option, emit handling code.
- if (D.Actions)
- EmitCaseConstructHandler(D.Actions, Indent2, EmitActionHandler(OptDescs),
- false, OptDescs, O);
-
- O << '\n';
- O.indent(Indent2)
- << "out_file = OutFilename(" << (IsJoin ? "sys::Path(),\n" : "inFile,\n");
- O.indent(Indent3) << "TempDir, stop_compilation, output_suffix).str();\n\n";
+ O.indent(Indent2) << "int out_file_index = -1;\n\n";
// cmd_line is either a string or a 'case' construct.
if (!D.CmdLine)
@@ -1608,6 +1604,20 @@
EmitCmdLineVecFillCallback(IsJoin, D.Name),
true, OptDescs, O);
+ // For every understood option, emit handling code.
+ if (D.Actions)
+ EmitCaseConstructHandler(D.Actions, Indent2, EmitActionHandler(OptDescs),
+ false, OptDescs, O);
+
+ O << '\n';
+ O.indent(Indent2)
+ << "std::string out_file = OutFilename("
+ << (IsJoin ? "sys::Path(),\n" : "inFile,\n");
+ O.indent(Indent3) << "TempDir, stop_compilation, output_suffix).str();\n\n";
+ // TODO: emit this check only when necessary.
+ O.indent(Indent2) << "if (out_file_index != -1)\n";
+ O.indent(Indent3) << "vec[out_file_index] = out_file;\n";
+
// Handle the Sink property.
if (D.isSink()) {
O.indent(Indent2) << "if (!" << SinkOptionName << ".empty()) {\n";
More information about the llvm-commits
mailing list