diff options
author | Mikhail Glushenkov <foldr@codedgers.com> | 2008-05-12 16:33:06 +0000 |
---|---|---|
committer | Mikhail Glushenkov <foldr@codedgers.com> | 2008-05-12 16:33:06 +0000 |
commit | c79304461a7a1bc04d365b8085b78afc8694fc71 (patch) | |
tree | ec73d6e205c34607c724b835a3ccdc9b2916357d /llvm/utils | |
parent | 3f896c8d163865e365ed30c7e524c8f29ed0ed68 (diff) | |
download | bcm5719-llvm-c79304461a7a1bc04d365b8085b78afc8694fc71.tar.gz bcm5719-llvm-c79304461a7a1bc04d365b8085b78afc8694fc71.zip |
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.
llvm-svn: 50973
Diffstat (limited to 'llvm/utils')
-rw-r--r-- | llvm/utils/TableGen/LLVMCConfigurationEmitter.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/llvm/utils/TableGen/LLVMCConfigurationEmitter.cpp b/llvm/utils/TableGen/LLVMCConfigurationEmitter.cpp index 1947aa5bef5..8e4d870f76b 100644 --- a/llvm/utils/TableGen/LLVMCConfigurationEmitter.cpp +++ b/llvm/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; } } |