summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorMikhail Glushenkov <foldr@codedgers.com>2008-05-12 16:33:06 +0000
committerMikhail Glushenkov <foldr@codedgers.com>2008-05-12 16:33:06 +0000
commit5c98d824f681a5d531e619309faefbfa84e230fe (patch)
tree8cff2a794bd09524366b0e66aa8583cfff3a029a /utils
parentecb977e64f5dbe40b35184124f9ac4b0faaea114 (diff)
downloadllvm-5c98d824f681a5d531e619309faefbfa84e230fe.tar.gz
llvm-5c98d824f681a5d531e619309faefbfa84e230fe.tar.bz2
llvm-5c98d824f681a5d531e619309faefbfa84e230fe.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50973 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/LLVMCConfigurationEmitter.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/utils/TableGen/LLVMCConfigurationEmitter.cpp b/utils/TableGen/LLVMCConfigurationEmitter.cpp
index 1947aa5bef..8e4d870f76 100644
--- a/utils/TableGen/LLVMCConfigurationEmitter.cpp
+++ b/utils/TableGen/LLVMCConfigurationEmitter.cpp
@@ -135,19 +135,36 @@ struct OptionDescription {
}
}
+ // 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;
}
}