[llvm-commits] [llvm] r50973 - in /llvm/trunk: test/LLVMC/wall.c tools/llvmc2/Tools.td utils/TableGen/LLVMCConfigurationEmitter.cpp
Mikhail Glushenkov
foldr at codedgers.com
Mon May 12 09:33:06 PDT 2008
Author: foldr
Date: Mon May 12 11:33:06 2008
New Revision: 50973
URL: http://llvm.org/viewvc/llvm-project?rev=50973&view=rev
Log:
Filter option names to escape symbols not allowed as C++ identifiers.
Makes it possible to use options with names like "Wa,".
Also fixes the -Wall option handling as a side-effect.
Added:
llvm/trunk/test/LLVMC/wall.c
Modified:
llvm/trunk/tools/llvmc2/Tools.td
llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
Added: llvm/trunk/test/LLVMC/wall.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/wall.c?rev=50973&view=auto
==============================================================================
--- llvm/trunk/test/LLVMC/wall.c (added)
+++ llvm/trunk/test/LLVMC/wall.c Mon May 12 11:33:06 2008
@@ -0,0 +1,12 @@
+/*
+ * 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;
+}
Modified: llvm/trunk/tools/llvmc2/Tools.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Tools.td?rev=50973&r1=50972&r2=50973&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc2/Tools.td (original)
+++ llvm/trunk/tools/llvmc2/Tools.td Mon May 12 11:33:06 2008
@@ -71,7 +71,7 @@
(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"))
]>;
// Default linker
@@ -83,7 +83,7 @@
(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++
@@ -97,7 +97,7 @@
(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))
]>;
// Language map
Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=50973&r1=50972&r2=50973&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Mon May 12 11:33:06 2008
@@ -135,19 +135,36 @@
}
}
+ // 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 {
+ const std::string& EscapedName = EscapeVariableName(Name);
switch (Type) {
case OptionType::Switch:
- return "AutoGeneratedSwitch" + Name;
+ return "AutoGeneratedSwitch" + EscapedName;
case OptionType::Prefix:
- return "AutoGeneratedPrefix" + Name;
+ return "AutoGeneratedPrefix" + EscapedName;
case OptionType::PrefixList:
- return "AutoGeneratedPrefixList" + Name;
+ return "AutoGeneratedPrefixList" + EscapedName;
case OptionType::Parameter:
- return "AutoGeneratedParameter" + Name;
+ return "AutoGeneratedParameter" + EscapedName;
case OptionType::ParameterList:
default:
- return "AutoGeneratedParameterList" + Name;
+ return "AutoGeneratedParameterList" + EscapedName;
}
}
More information about the llvm-commits
mailing list