summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorMikhail Glushenkov <foldr@codedgers.com>2010-08-20 11:24:51 +0000
committerMikhail Glushenkov <foldr@codedgers.com>2010-08-20 11:24:51 +0000
commit7a57454d82625ff3325a378e5f0280128c4d1ee2 (patch)
tree8af19d3d5f78d4f5afd911f04a8153a5a19c0260 /utils
parent03b6d4e04c72c49b01cb2eb5102675421eadbc4c (diff)
downloadllvm-7a57454d82625ff3325a378e5f0280128c4d1ee2.tar.gz
llvm-7a57454d82625ff3325a378e5f0280128c4d1ee2.tar.bz2
llvm-7a57454d82625ff3325a378e5f0280128c4d1ee2.tar.xz
llvmc: Do not prefix option names with AutoGenerated.
Since they now live in the namespace 'autogenerated'. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111620 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/LLVMCConfigurationEmitter.cpp41
1 files changed, 26 insertions, 15 deletions
diff --git a/utils/TableGen/LLVMCConfigurationEmitter.cpp b/utils/TableGen/LLVMCConfigurationEmitter.cpp
index 48c7cc375f..26e9fa4a9d 100644
--- a/utils/TableGen/LLVMCConfigurationEmitter.cpp
+++ b/utils/TableGen/LLVMCConfigurationEmitter.cpp
@@ -49,7 +49,7 @@ const unsigned Indent4 = TabWidth*4;
const char * const DefaultHelpString = "NO HELP MESSAGE PROVIDED";
// Name for the "sink" option.
-const char * const SinkOptionName = "AutoGeneratedSinkOption";
+const char * const SinkOptionName = "SinkOption";
//===----------------------------------------------------------------------===//
/// Helper functions
@@ -261,7 +261,13 @@ struct OptionDescription {
/// GenVariableName - Returns the variable name used in the
/// generated C++ code.
- std::string GenVariableName() const;
+ std::string GenVariableName() const
+ { return "autogenerated::" + GenOptionType() + EscapeVariableName(Name); }
+
+ /// GenPlainVariableName - Returns the variable name without the namespace
+ /// prefix.
+ std::string GenPlainVariableName() const
+ { return GenOptionType() + EscapeVariableName(Name); }
/// Merge - Merge two option descriptions.
void Merge (const OptionDescription& other);
@@ -315,6 +321,10 @@ struct OptionDescription {
{ return (OptionType::IsList(this->Type)
&& !OptionType::IsSwitchList(this->Type)); }
+private:
+
+ // GenOptionType - Helper function used by GenVariableName().
+ std::string GenOptionType() const;
};
void OptionDescription::CheckConsistency() const {
@@ -428,22 +438,21 @@ const char* OptionDescription::GenTypeDeclaration() const {
}
}
-std::string OptionDescription::GenVariableName() const {
- const std::string& EscapedName = EscapeVariableName(Name);
+std::string OptionDescription::GenOptionType() const {
switch (Type) {
case OptionType::Alias:
- return "AutoGeneratedAlias_" + EscapedName;
+ return "Alias_";
case OptionType::PrefixList:
case OptionType::ParameterList:
- return "AutoGeneratedList_" + EscapedName;
+ return "List_";
case OptionType::Switch:
- return "AutoGeneratedSwitch_" + EscapedName;
+ return "Switch_";
case OptionType::SwitchList:
- return "AutoGeneratedSwitchList_" + EscapedName;
+ return "SwitchList_";
case OptionType::Prefix:
case OptionType::Parameter:
default:
- return "AutoGeneratedParameter_" + EscapedName;
+ return "Parameter_";
}
}
@@ -2210,13 +2219,15 @@ void EmitGenerateActionMethod (const ToolDescription& D,
O.indent(Indent2) << "}\n\n";
// Handle the Sink property.
+ std::string SinkOption("autogenerated::");
+ SinkOption += SinkOptionName;
if (D.isSink()) {
- O.indent(Indent2) << "if (!" << SinkOptionName << ".empty()) {\n";
+ O.indent(Indent2) << "if (!" << SinkOption << ".empty()) {\n";
O.indent(Indent3) << "for (cl::list<std::string>::iterator B = "
- << SinkOptionName << ".begin(), E = " << SinkOptionName
+ << SinkOption << ".begin(), E = " << SinkOption
<< ".end(); B != E; ++B)\n";
- O.indent(Indent4) << "vec.push_back(std::make_pair(" << SinkOptionName
- << ".getPosition(B - " << SinkOptionName
+ O.indent(Indent4) << "vec.push_back(std::make_pair(" << SinkOption
+ << ".getPosition(B - " << SinkOption
<< ".begin()), *B));\n";
O.indent(Indent2) << "}\n";
}
@@ -2365,7 +2376,7 @@ void EmitOptionDefinitions (const OptionDescriptions& descs,
}
O << val.GenTypeDeclaration() << ' '
- << val.GenVariableName();
+ << val.GenPlainVariableName();
O << "(\"" << val.Name << "\"\n";
@@ -2427,7 +2438,7 @@ void EmitOptionDefinitions (const OptionDescriptions& descs,
// Emit the sink option.
if (HasSink)
- O << "cl" << "::list<std::string> " << SinkOptionName << "(cl::Sink);\n";
+ O << "cl::list<std::string> " << SinkOptionName << "(cl::Sink);\n";
O << '\n';
}