llvmc: Do not prefix option names with AutoGenerated.

Since they now live in the namespace 'autogenerated'.

llvm-svn: 111620
This commit is contained in:
Mikhail Glushenkov 2010-08-20 11:24:51 +00:00
parent 63df898925
commit f0f98cc3de
2 changed files with 31 additions and 20 deletions

View File

@ -8,7 +8,7 @@ namespace llvmc {
extern char *ProgramName;
namespace autogenerated {
extern llvm::cl::opt<std::string> AutoGeneratedParameter_p;
extern llvm::cl::opt<std::string> Parameter_p;
}
}
@ -32,10 +32,10 @@ namespace hooks {
std::string
GetLowerCasePartDefine(void) {
std::string Partname;
if (autogenerated::AutoGeneratedParameter_p.empty()) {
if (autogenerated::Parameter_p.empty()) {
Partname = "16f1xxx";
} else {
Partname = autogenerated::AutoGeneratedParameter_p;
Partname = autogenerated::Parameter_p;
}
std::string LowerCase;
@ -49,10 +49,10 @@ GetLowerCasePartDefine(void) {
std::string
GetUpperCasePartDefine(void) {
std::string Partname;
if (autogenerated::AutoGeneratedParameter_p.empty()) {
if (autogenerated::Parameter_p.empty()) {
Partname = "16f1xxx";
} else {
Partname = autogenerated::AutoGeneratedParameter_p;
Partname = autogenerated::Parameter_p;
}
std::string UpperCase;

View File

@ -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';
}