include "llvm/CompilerDriver/Common.td"
-
def Options : OptionList<[
(switch_option "E",
(help "Stop after the preprocessing stage, do not run the compiler"))
]>;
-class clang_base<string language, dag cmdline> : Tool<
+class clang_based<string language, string cmd> : Tool<
[(in_language language),
(out_language "llvm-bitcode"),
(output_suffix "bc"),
- (cmd_line cmdline),
+ (cmd_line (case
+ (switch_on "E"),
+ (case
+ (not_empty "o"),
+ !strconcat(cmd, " -E $INFILE -o $OUTFILE"),
+ (default),
+ !strconcat(cmd, " -E $INFILE")),
+ (default),
+ !strconcat(cmd, " -emit-llvm-bc $INFILE -o $OUTFILE"))),
(switch_option "E", (stop_compilation), (output_suffix "i")),
(sink)
]>;
-def clang_c : clang_base<"c",
-(case
-(switch_on "E"),
- (case
- (not_empty "o"),
- "clang -E -x c $INFILE -o $OUTFILE",
- (default),
- "clang -E -x c $INFILE"),
-(default),
- "clang -emit-llvm-bc -x c $INFILE -o $OUTFILE")>;
-
-def clang_cpp : clang_base<"c++",
-(case
-(switch_on "E"),
- (case
- (not_empty "o"),
- "clang -E -x c++ $INFILE -o $OUTFILE",
- (default),
- "clang -E -x c++ $INFILE"),
-(default),
- "clang -emit-llvm-bc -x c++ $INFILE -o $OUTFILE")>;
-
-def clang_objective_c : clang_base<"objective-c",
-(case
-(switch_on "E"),
- (case
- (not_empty "o"),
- "clang -E -x objective-c $INFILE -o $OUTFILE",
- (default),
- "clang -E -x objective-c $INFILE"),
-(default),
- "clang -emit-llvm-bc -x objective-c $INFILE -o $OUTFILE")>;
+def clang_c : clang_based<"c", "clang -x c">;
+def clang_cpp : clang_based<"c++", "clang -x c++">;
+def clang_objective_c : clang_based<"objective-c", "clang -x objective-c">;
+def clang_objective_cpp : clang_based<"objective-c++",
+ "clang -x objective-c++">;
// Default linker
def llvm_ld : Tool<