llvmc: Cut global namespace pollution.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111619 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Mikhail Glushenkov 2010-08-20 11:24:44 +00:00
parent 68e18b3054
commit 03b6d4e04c
4 changed files with 24 additions and 10 deletions

View File

@ -18,6 +18,8 @@
#include <string>
namespace llvmc {
namespace SaveTempsEnum { enum Values { Cwd, Obj, Unset }; }
extern llvm::cl::list<std::string> InputFilenames;
@ -32,4 +34,6 @@ extern llvm::cl::opt<bool> ViewGraph;
extern llvm::cl::opt<bool> WriteGraph;
extern llvm::cl::opt<SaveTempsEnum::Values> SaveTemps;
} // End namespace llvmc.
#endif // LLVM_INCLUDE_COMPILER_DRIVER_BUILTIN_OPTIONS_H

View File

@ -19,7 +19,7 @@
namespace cl = llvm::cl;
// External linkage here is intentional.
namespace llvmc {
cl::list<std::string> InputFilenames(cl::Positional, cl::desc("<input file>"),
cl::ZeroOrMore);
@ -57,3 +57,5 @@ cl::opt<SaveTempsEnum::Values> SaveTemps
clEnumValN(SaveTempsEnum::Obj, "", "Same as 'cwd'"),
clEnumValEnd),
cl::ValueOptional);
} // End namespace llvmc.

View File

@ -4,13 +4,16 @@
#include <string>
using namespace llvm;
namespace llvmc {
extern char *ProgramName;
namespace autogenerated {
extern llvm::cl::opt<std::string> AutoGeneratedParameter_p;
}
}
extern cl::opt<std::string> AutoGeneratedParameter_p;
using namespace llvm;
using namespace llvmc;
// Returns the platform specific directory separator via #ifdefs.
// FIXME: This currently work on linux and windows only. It does not
@ -29,10 +32,10 @@ namespace hooks {
std::string
GetLowerCasePartDefine(void) {
std::string Partname;
if (AutoGeneratedParameter_p.empty()) {
if (autogenerated::AutoGeneratedParameter_p.empty()) {
Partname = "16f1xxx";
} else {
Partname = AutoGeneratedParameter_p;
Partname = autogenerated::AutoGeneratedParameter_p;
}
std::string LowerCase;
@ -46,10 +49,10 @@ GetLowerCasePartDefine(void) {
std::string
GetUpperCasePartDefine(void) {
std::string Partname;
if (AutoGeneratedParameter_p.empty()) {
if (autogenerated::AutoGeneratedParameter_p.empty()) {
Partname = "16f1xxx";
} else {
Partname = AutoGeneratedParameter_p;
Partname = autogenerated::AutoGeneratedParameter_p;
}
std::string UpperCase;

View File

@ -2909,7 +2909,6 @@ void EmitHookDeclarations(const ToolDescriptions& ToolDescs,
if (HookNames.empty())
return;
O << "namespace hooks {\n";
for (HookInfoMap::const_iterator B = HookNames.begin(),
E = HookNames.end(); B != E; ++B) {
const char* HookName = B->first();
@ -2928,7 +2927,6 @@ void EmitHookDeclarations(const ToolDescriptions& ToolDescs,
O <<");\n";
}
O << "}\n\n";
}
/// EmitIncludes - Emit necessary #include directives and some
@ -3013,12 +3011,19 @@ void EmitPluginCode(const PluginData& Data, raw_ostream& O) {
EmitIncludes(O);
// Emit global option registration code.
O << "namespace llvmc {\n"
<< "namespace autogenerated {\n\n";
EmitOptionDefinitions(Data.OptDescs, Data.HasSink, O);
O << "} // End namespace autogenerated.\n"
<< "} // End namespace llvmc.\n\n";
// Emit hook declarations.
O << "namespace hooks {\n";
EmitHookDeclarations(Data.ToolDescs, Data.OptDescs, O);
O << "} // End namespace hooks.\n\n";
O << "namespace {\n\n";
O << "using namespace llvmc::autogenerated;\n\n";
// Emit Tool classes.
for (ToolDescriptions::const_iterator B = Data.ToolDescs.begin(),