Makes it possible to use options with names like "Wa,".
Also fixes the -Wall option handling as a side-effect.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50973
91177308-0d34-0410-b5e6-
96231b3b80d8
--- /dev/null
+/*
+ * Check that -Wall works as intended
+ * RUN: llvmc2 -Wall %s -o %t
+ * RUN: ./%t | grep hello
+ */
+
+#include <stdio.h>
+
+int main() {
+ printf("hello\n");
+ return 0;
+}
(cmd_line "llvm-gcc -c -x assembler $INFILE -o $OUTFILE"),
(switch_option "c", (stop_compilation),
(help "Compile and assemble, but do not link")),
(cmd_line "llvm-gcc -c -x assembler $INFILE -o $OUTFILE"),
(switch_option "c", (stop_compilation),
(help "Compile and assemble, but do not link")),
- (prefix_list_option "Wa", (unpack_values), (help "pass options to assembler"))
+ (prefix_list_option "Wa,", (unpack_values), (help "pass options to assembler"))
(join),
(prefix_list_option "L", (forward), (help "add a directory to link path")),
(prefix_list_option "l", (forward), (help "search a library when linking")),
(join),
(prefix_list_option "L", (forward), (help "add a directory to link path")),
(prefix_list_option "l", (forward), (help "search a library when linking")),
- (prefix_list_option "Wl", (unpack_values), (help "pass options to linker"))
+ (prefix_list_option "Wl,", (unpack_values), (help "pass options to linker"))
]>;
// Alternative linker for C++
]>;
// Alternative linker for C++
(help "Choose linker (possible values: gcc, g++)")),
(prefix_list_option "L", (forward)),
(prefix_list_option "l", (forward)),
(help "Choose linker (possible values: gcc, g++)")),
(prefix_list_option "L", (forward)),
(prefix_list_option "l", (forward)),
- (prefix_list_option "Wl", (unpack_values))
+ (prefix_list_option "Wl,", (unpack_values))
+ // Escape commas and other symbols not allowed in the C++ variable
+ // names. Makes it possible to use options with names like "Wa,"
+ // (useful for prefix options).
+ std::string EscapeVariableName(const std::string& Var) const {
+ std::string ret;
+ for (unsigned i = 0; i != Var.size(); ++i) {
+ if (Var[i] == ',') {
+ ret += "_comma_";
+ }
+ else {
+ ret.push_back(Var[i]);
+ }
+ }
+ return ret;
+ }
+
std::string GenVariableName() const {
std::string GenVariableName() const {
+ const std::string& EscapedName = EscapeVariableName(Name);
switch (Type) {
case OptionType::Switch:
switch (Type) {
case OptionType::Switch:
- return "AutoGeneratedSwitch" + Name;
+ return "AutoGeneratedSwitch" + EscapedName;
- return "AutoGeneratedPrefix" + Name;
+ return "AutoGeneratedPrefix" + EscapedName;
case OptionType::PrefixList:
case OptionType::PrefixList:
- return "AutoGeneratedPrefixList" + Name;
+ return "AutoGeneratedPrefixList" + EscapedName;
case OptionType::Parameter:
case OptionType::Parameter:
- return "AutoGeneratedParameter" + Name;
+ return "AutoGeneratedParameter" + EscapedName;
case OptionType::ParameterList:
default:
case OptionType::ParameterList:
default:
- return "AutoGeneratedParameterList" + Name;
+ return "AutoGeneratedParameterList" + EscapedName;