(help "Specifies a framework to link against")),
(parameter_list_option "weak_framework",
(help "Specifies a framework to weakly link against"), (hidden)),
+ (parameter_option "filelist", (hidden),
+ (help "Link the files listed in file")),
(prefix_list_option "F",
(help "Add a directory to framework search path")),
(prefix_list_option "I",
(out_language "executable"),
(output_suffix "out"),
(cmd_line !strconcat(cmd_prefix, " $INFILE -o $OUTFILE")),
+ (works_on_empty (case (not_empty "filelist"), true,
+ (default), false)),
(join),
(actions (case
(switch_on "pthread"), (append_cmd "-lpthread"),
(not_empty "arch"), (forward "arch"),
(not_empty "framework"), (forward "framework"),
(not_empty "weak_framework"), (forward "weak_framework"),
+ (not_empty "filelist"), (forward "filelist"),
(switch_on "m32"), (forward "m32"),
(switch_on "m64"), (forward "m64"),
(not_empty "l"), (forward "l"),
std::string OutLanguage;
std::string OutputSuffix;
unsigned Flags;
+ const Init* OnEmpty;
// Various boolean properties
void setSink() { Flags |= ToolFlags::Sink; }
// Default ctor here is needed because StringMap can only store
// DefaultConstructible objects
- ToolDescription() : CmdLine(0), Actions(0), Flags(0) {}
+ ToolDescription() : CmdLine(0), Actions(0), Flags(0), OnEmpty(0) {}
ToolDescription (const std::string& n)
- : Name(n), CmdLine(0), Actions(0), Flags(0)
+ : Name(n), CmdLine(0), Actions(0), Flags(0), OnEmpty(0)
{}
};
AddHandler("out_language", &CollectToolProperties::onOutLanguage);
AddHandler("output_suffix", &CollectToolProperties::onOutputSuffix);
AddHandler("sink", &CollectToolProperties::onSink);
+ AddHandler("works_on_empty", &CollectToolProperties::onWorksOnEmpty);
staticMembersInitialized_ = true;
}
toolDesc_.setSink();
}
+ void onWorksOnEmpty (const DagInit& d) {
+ toolDesc_.OnEmpty = d.getArg(0);
+ }
+
};
/// CollectToolDescriptions - Gather information about tool properties
/// EmitCaseConstructHandler - Emit code that handles the 'case'
/// construct. Takes a function object that should emit code for every case
/// clause. Implemented on top of WalkCase.
-/// Callback's type is void F(Init* Statement, unsigned IndentLevel,
+/// Callback's type is void F(const Init* Statement, unsigned IndentLevel,
/// raw_ostream& O).
/// EmitElseIf parameter controls the type of condition that is emitted ('if
/// (..) {..} else if (..) {} .. else {..}' vs. 'if (..) {..} if(..) {..}
O.indent(Indent1) << "}\n\n";
}
+/// EmitWorksOnEmptyCallback - Callback used by EmitWorksOnEmptyMethod in
+/// conjunction with EmitCaseConstructHandler.
+void EmitWorksOnEmptyCallback (const Init* Value,
+ unsigned IndentLevel, raw_ostream& O) {
+ CheckBooleanConstant(Value);
+ O.indent(IndentLevel) << "return " << Value->getAsString() << ";\n";
+}
+
+/// EmitWorksOnEmptyMethod - Emit the WorksOnEmpty() method for a given Tool
+/// class.
+void EmitWorksOnEmptyMethod (const ToolDescription& D,
+ const OptionDescriptions& OptDescs,
+ raw_ostream& O)
+{
+ O.indent(Indent1) << "bool WorksOnEmpty() const {\n";
+ if (D.OnEmpty == 0)
+ O.indent(Indent2) << "return false;\n";
+ else
+ EmitCaseConstructHandler(D.OnEmpty, Indent2, EmitWorksOnEmptyCallback,
+ /*EmitElseIf = */ true, OptDescs, O);
+ O.indent(Indent1) << "}\n\n";
+}
+
/// EmitStaticMemberDefinitions - Emit static member definitions for a
/// given Tool class.
void EmitStaticMemberDefinitions(const ToolDescription& D, raw_ostream& O) {
EmitNameMethod(D, O);
EmitInOutLanguageMethods(D, O);
EmitIsJoinMethod(D, O);
+ EmitWorksOnEmptyMethod(D, OptDescs, O);
EmitGenerateActionMethods(D, OptDescs, O);
// Close class definition