llvm.org GIT mirror llvm / 2cdd21c
Finegrainify namespacification git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10464 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 16 years ago
18 changed file(s) with 106 addition(s) and 152 deletion(s). Raw diff Collapse all Expand all
2424 #include "llvm/Type.h"
2525 #include "llvm/Instruction.h"
2626 #include "llvm/ConstantHandling.h"
27
28 namespace llvm {
27 using namespace llvm;
2928
3029 /// Initialize a full (the default) or empty set for the specified type.
3130 ///
249248 void ConstantRange::dump() const {
250249 print(std::cerr);
251250 }
252
253 } // End llvm namespace
1212
1313 #include
1414 #include "Support/Annotation.h"
15
16 namespace llvm {
15 using namespace llvm;
1716
1817 typedef std::map IDMapType;
1918 static unsigned IDCounter = 0; // Unique ID counter
9594 if (I == getFactMap().end()) return 0;
9695 return I->second.first(ID, Obj, I->second.second);
9796 }
98
99 } // End llvm namespace
2222 #include
2323 #include
2424 #include
25
26 namespace llvm {
25 using namespace llvm;
2726
2827 using namespace cl;
2928
888887 cl::location(HiddenPrinter), cl::Hidden, cl::ValueDisallowed);
889888
890889 } // End anonymous namespace
891
892 } // End llvm namespace
2424 #include "llvm/Type.h"
2525 #include "llvm/Instruction.h"
2626 #include "llvm/ConstantHandling.h"
27
28 namespace llvm {
27 using namespace llvm;
2928
3029 /// Initialize a full (the default) or empty set for the specified type.
3130 ///
249248 void ConstantRange::dump() const {
250249 print(std::cerr);
251250 }
252
253 } // End llvm namespace
2222 //
2323 //===----------------------------------------------------------------------===//
2424
25 #include "Support/Statistic.h"
25 #include "Support/Debug.h"
2626 #include "Support/CommandLine.h"
27 using namespace llvm;
2728
28 namespace llvm {
29
30 bool DebugFlag; // DebugFlag - Exported boolean set by the -debug option
29 bool llvm::DebugFlag; // DebugFlag - Exported boolean set by the -debug option
3130
3231 namespace {
3332 #ifndef NDEBUG
5655 // specified on the command line, or if none was specified on the command line
5756 // with the -debug-only=X option.
5857 //
59 bool isCurrentDebugType(const char *DebugType) {
58 bool llvm::isCurrentDebugType(const char *DebugType) {
6059 #ifndef NDEBUG
6160 return CurrentDebugType.empty() || DebugType == CurrentDebugType;
6261 #else
6362 return false;
6463 #endif
6564 }
66
67 } // End llvm namespace
2121 #include "Support/DynamicLinker.h"
2222 #include "Config/dlfcn.h"
2323 #include
24 using namespace llvm;
2425
25 namespace llvm {
26
27 bool LinkDynamicObject (const char *filename, std::string *ErrorMessage) {
26 bool llvm::LinkDynamicObject (const char *filename, std::string *ErrorMessage) {
2827 #if defined (HAVE_DLOPEN)
2928 if (dlopen (filename, RTLD_NOW | RTLD_GLOBAL) == 0) {
3029 if (ErrorMessage) *ErrorMessage = dlerror ();
3635 #endif
3736 }
3837
39 void *GetAddressOfSymbol (const char *symbolName) {
38 void *llvm::GetAddressOfSymbol (const char *symbolName) {
4039 #if defined (HAVE_DLOPEN)
4140 #ifdef RTLD_DEFAULT
4241 return dlsym (RTLD_DEFAULT, symbolName);
5049 }
5150
5251 // soft, cushiony C++ interface.
53 void *GetAddressOfSymbol (const std::string &symbolName) {
52 void *llvm::GetAddressOfSymbol (const std::string &symbolName) {
5453 return GetAddressOfSymbol (symbolName.c_str ());
5554 }
56
57 } // End llvm namespace
1818 #include
1919 #include
2020 #include
21
22 namespace llvm
23 {
21 using namespace llvm;
2422
2523 /// CheckMagic - Returns true IFF the file named FN begins with Magic. FN must
2624 /// name a readable file.
2725 ///
28 bool CheckMagic (const std::string &FN, const std::string &Magic) {
26 bool llvm::CheckMagic(const std::string &FN, const std::string &Magic) {
2927 char buf[1 + Magic.size ()];
3028 std::ifstream f (FN.c_str ());
3129 f.read (buf, Magic.size ());
3634 /// IsArchive - Returns true IFF the file named FN appears to be a "ar" library
3735 /// archive. The file named FN must exist.
3836 ///
39 bool IsArchive(const std::string &FN) {
37 bool llvm::IsArchive(const std::string &FN) {
4038 // Inspect the beginning of the file to see if it contains the "ar"
4139 // library archive format magic string.
4240 return CheckMagic (FN, "!\012");
4543 /// IsBytecode - Returns true IFF the file named FN appears to be an LLVM
4644 /// bytecode file. The file named FN must exist.
4745 ///
48 bool IsBytecode(const std::string &FN) {
46 bool llvm::IsBytecode(const std::string &FN) {
4947 // Inspect the beginning of the file to see if it contains the LLVM
5048 // bytecode format magic string.
5149 return CheckMagic (FN, "llvm");
5452 /// IsSharedObject - Returns trus IFF the file named FN appears to be a shared
5553 /// object with an ELF header. The file named FN must exist.
5654 ///
57 bool IsSharedObject(const std::string &FN) {
55 bool llvm::IsSharedObject(const std::string &FN) {
5856 // Inspect the beginning of the file to see if it contains the ELF shared
5957 // object magic string.
6058 static const char elfMagic[] = { 0x7f, 'E', 'L', 'F', '\0' };
6462 /// FileOpenable - Returns true IFF Filename names an existing regular
6563 /// file which we can successfully open.
6664 ///
67 bool FileOpenable (const std::string &Filename) {
65 bool llvm::FileOpenable(const std::string &Filename) {
6866 struct stat s;
6967 if (stat (Filename.c_str (), &s) == -1)
7068 return false; // Cannot stat file
8280 /// occurs, allowing the caller to distinguish between a failed diff and a file
8381 /// system error.
8482 ///
85 bool DiffFiles(const std::string &FileA, const std::string &FileB,
86 std::string *Error) {
83 bool llvm::DiffFiles(const std::string &FileA, const std::string &FileB,
84 std::string *Error) {
8785 std::ifstream FileAStream(FileA.c_str());
8886 if (!FileAStream) {
8987 if (Error) *Error = "Couldn't open file '" + FileA + "'";
112110 /// or if Old does not exist, move the New file over the Old file. Otherwise,
113111 /// remove the New file.
114112 ///
115 void MoveFileOverIfUpdated(const std::string &New, const std::string &Old) {
113 void llvm::MoveFileOverIfUpdated(const std::string &New,
114 const std::string &Old) {
116115 if (DiffFiles(New, Old)) {
117116 if (std::rename(New.c_str(), Old.c_str()))
118117 std::cerr << "Error renaming '" << New << "' to '" << Old << "'!\n";
123122
124123 /// removeFile - Delete the specified file
125124 ///
126 void removeFile(const std::string &Filename) {
125 void llvm::removeFile(const std::string &Filename) {
127126 std::remove(Filename.c_str());
128127 }
129128
131130 /// file does not exist yet, return it, otherwise add a suffix to make it
132131 /// unique.
133132 ///
134 std::string getUniqueFilename(const std::string &FilenameBase) {
133 std::string llvm::getUniqueFilename(const std::string &FilenameBase) {
135134 if (!std::ifstream(FilenameBase.c_str()))
136135 return FilenameBase; // Couldn't open the file? Use it!
137136
182181 /// umask would allow. Filename must name an existing file or
183182 /// directory. Returns true on success, false on error.
184183 ///
185 bool MakeFileExecutable (const std::string &Filename) {
186 return AddPermissionsBits (Filename, 0111);
184 bool llvm::MakeFileExecutable(const std::string &Filename) {
185 return AddPermissionsBits(Filename, 0111);
187186 }
188187
189188 /// MakeFileReadable - Make the file named Filename readable by
191190 /// umask would allow. Filename must name an existing file or
192191 /// directory. Returns true on success, false on error.
193192 ///
194 bool MakeFileReadable (const std::string &Filename) {
195 return AddPermissionsBits (Filename, 0444);
193 bool llvm::MakeFileReadable(const std::string &Filename) {
194 return AddPermissionsBits(Filename, 0444);
196195 }
197
198 } // End llvm namespace
1313 #include "Support/LeakDetector.h"
1414 #include "llvm/Value.h"
1515 #include
16
17 namespace llvm {
16 using namespace llvm;
1817
1918 // Lazily allocate set so that release build doesn't have to do anything.
2019 static std::set *Objects = 0;
8887 Objects = 0; LLVMObjects = 0;
8988 }
9089 }
91
92 } // End llvm namespace
1414 #include "llvm/Module.h"
1515 #include "llvm/Type.h"
1616 #include "Support/StringExtras.h"
17
18 namespace llvm {
17 using namespace llvm;
1918
2019 static char HexDigit(int V) {
2120 return V < 10 ? V+'0' : V+'A'-10;
9998 else
10099 FoundNames.insert(I->getName()); // Otherwise, keep track of name
101100 }
102
103 } // End llvm namespace
2121 #include "Config/dlfcn.h"
2222 #include "Config/link.h"
2323 #include
24
25 namespace llvm {
24 using namespace llvm;
2625
2726 namespace {
2827 struct PluginLoader {
3938 static cl::opt >
4039 LoadOpt("load", cl::ZeroOrMore, cl::value_desc("plugin.so"),
4140 cl::desc("Load the specified plugin"));
42
43 } // End llvm namespace
1818 #include
1919 #include
2020 #include "Config/config.h" // Get the signal handler return type
21
22 namespace llvm {
21 using namespace llvm;
2322
2423 static std::vector FilesToRemove;
2524
5756 static void RegisterHandler(int Signal) { signal(Signal, SignalHandler); }
5857
5958 // RemoveFileOnSignal - The public API
60 void RemoveFileOnSignal(const std::string &Filename) {
59 void llvm::RemoveFileOnSignal(const std::string &Filename) {
6160 FilesToRemove.push_back(Filename);
6261
6362 std::for_each(IntSigs, IntSigsEnd, RegisterHandler);
6463 std::for_each(KillSigs, KillSigsEnd, RegisterHandler);
6564 }
66
67 } // End llvm namespace
2222 #include "Config/sys/wait.h"
2323 #include "Config/unistd.h"
2424 #include "Config/errno.h"
25
26 namespace llvm {
25 using namespace llvm;
2726
2827 /// isExecutableFile - This function returns true if the filename specified
2928 /// exists and is executable.
3029 ///
31 bool isExecutableFile(const std::string &ExeFileName) {
30 bool llvm::isExecutableFile(const std::string &ExeFileName) {
3231 struct stat Buf;
3332 if (stat(ExeFileName.c_str(), &Buf))
3433 return false; // Must not be executable!
5049 /// directory, nor in the PATH. If the executable cannot be found, return an
5150 /// empty string.
5251 ///
53 std::string FindExecutable(const std::string &ExeName,
54 const std::string &ProgramPath) {
52 std::string llvm::FindExecutable(const std::string &ExeName,
53 const std::string &ProgramPath) {
5554 // First check the directory that bugpoint is in. We can do this if
5655 // BugPointPath contains at least one / character, indicating that it is a
5756 // relative path to bugpoint itself.
115114 /// the calling program if there is an error executing the specified program.
116115 /// It returns the return value of the program, or -1 if a timeout is detected.
117116 ///
118 int RunProgramWithTimeout(const std::string &ProgramPath, const char **Args,
119 const std::string &StdInFile,
120 const std::string &StdOutFile,
121 const std::string &StdErrFile) {
122
117 int llvm::RunProgramWithTimeout(const std::string &ProgramPath,
118 const char **Args,
119 const std::string &StdInFile,
120 const std::string &StdOutFile,
121 const std::string &StdErrFile) {
123122 // FIXME: install sigalarm handler here for timeout...
124123
125124 int Child = fork();
203202 //
204203 // This function does not use $PATH to find programs.
205204 //
206 int
207 ExecWait (const char * const old_argv[], const char * const old_envp[])
208 {
205 int llvm::ExecWait(const char * const old_argv[],
206 const char * const old_envp[]) {
209207 // Child process ID
210208 register int child;
211209
272270 //
273271 return 1;
274272 }
275
276 } // End llvm namespace
1717 #include "Support/FileUtilities.h"
1818 #include
1919 #include
20
21 namespace llvm {
20 using namespace llvm;
2221
2322 //===---------------------------------------------------------------------===//
2423 // LLI Implementation of AbstractIntepreter interface
2524 //
26 class LLI : public AbstractInterpreter {
27 std::string LLIPath; // The path to the LLI executable
28 public:
29 LLI(const std::string &Path) : LLIPath(Path) { }
30
31
32 virtual int ExecuteProgram(const std::string &Bytecode,
33 const std::vector &Args,
34 const std::string &InputFile,
35 const std::string &OutputFile,
36 const std::vector &SharedLibs =
25 namespace {
26 class LLI : public AbstractInterpreter {
27 std::string LLIPath; // The path to the LLI executable
28 public:
29 LLI(const std::string &Path) : LLIPath(Path) { }
30
31
32 virtual int ExecuteProgram(const std::string &Bytecode,
33 const std::vector &Args,
34 const std::string &InputFile,
35 const std::string &OutputFile,
36 const std::vector &SharedLibs =
3737 std::vector());
38 };
38 };
39 }
3940
4041 int LLI::ExecuteProgram(const std::string &Bytecode,
4142 const std::vector &Args,
147148 //===---------------------------------------------------------------------===//
148149 // JIT Implementation of AbstractIntepreter interface
149150 //
150 class JIT : public AbstractInterpreter {
151 std::string LLIPath; // The path to the LLI executable
152 public:
153 JIT(const std::string &Path) : LLIPath(Path) { }
154
155
156 virtual int ExecuteProgram(const std::string &Bytecode,
157 const std::vector &Args,
158 const std::string &InputFile,
159 const std::string &OutputFile,
160 const std::vector &SharedLibs =
151 namespace {
152 class JIT : public AbstractInterpreter {
153 std::string LLIPath; // The path to the LLI executable
154 public:
155 JIT(const std::string &Path) : LLIPath(Path) { }
156
157
158 virtual int ExecuteProgram(const std::string &Bytecode,
159 const std::vector &Args,
160 const std::string &InputFile,
161 const std::string &OutputFile,
162 const std::vector &SharedLibs =
161163 std::vector());
162 };
164 };
165 }
163166
164167 int JIT::ExecuteProgram(const std::string &Bytecode,
165168 const std::vector &Args,
395398 Message = "Found gcc: " + GCCPath + "\n";
396399 return new GCC(GCCPath);
397400 }
398
399 } // End llvm namespace
1717 #include "llvm/Support/ValueHolder.h"
1818 #include "llvm/Type.h"
1919
20 namespace llvm {
20 using namespace llvm;
2121
2222 ValueHolder::ValueHolder(Value *V) : User(Type::TypeTy, Value::TypeVal) {
2323 Operands.push_back(Use(V, this));
2424 }
25
26 } // End llvm namespace
2424 #include "llvm/Type.h"
2525 #include "llvm/Instruction.h"
2626 #include "llvm/ConstantHandling.h"
27
28 namespace llvm {
27 using namespace llvm;
2928
3029 /// Initialize a full (the default) or empty set for the specified type.
3130 ///
249248 void ConstantRange::dump() const {
250249 print(std::cerr);
251250 }
252
253 } // End llvm namespace
1313 #include "Support/LeakDetector.h"
1414 #include "llvm/Value.h"
1515 #include
16
17 namespace llvm {
16 using namespace llvm;
1817
1918 // Lazily allocate set so that release build doesn't have to do anything.
2019 static std::set *Objects = 0;
8887 Objects = 0; LLVMObjects = 0;
8988 }
9089 }
91
92 } // End llvm namespace
1414 #include "llvm/Module.h"
1515 #include "llvm/Type.h"
1616 #include "Support/StringExtras.h"
17
18 namespace llvm {
17 using namespace llvm;
1918
2019 static char HexDigit(int V) {
2120 return V < 10 ? V+'0' : V+'A'-10;
9998 else
10099 FoundNames.insert(I->getName()); // Otherwise, keep track of name
101100 }
102
103 } // End llvm namespace
1717 #include "Support/FileUtilities.h"
1818 #include
1919 #include
20
21 namespace llvm {
20 using namespace llvm;
2221
2322 //===---------------------------------------------------------------------===//
2423 // LLI Implementation of AbstractIntepreter interface
2524 //
26 class LLI : public AbstractInterpreter {
27 std::string LLIPath; // The path to the LLI executable
28 public:
29 LLI(const std::string &Path) : LLIPath(Path) { }
30
31
32 virtual int ExecuteProgram(const std::string &Bytecode,
33 const std::vector &Args,
34 const std::string &InputFile,
35 const std::string &OutputFile,
36 const std::vector &SharedLibs =
25 namespace {
26 class LLI : public AbstractInterpreter {
27 std::string LLIPath; // The path to the LLI executable
28 public:
29 LLI(const std::string &Path) : LLIPath(Path) { }
30
31
32 virtual int ExecuteProgram(const std::string &Bytecode,
33 const std::vector &Args,
34 const std::string &InputFile,
35 const std::string &OutputFile,
36 const std::vector &SharedLibs =
3737 std::vector());
38 };
38 };
39 }
3940
4041 int LLI::ExecuteProgram(const std::string &Bytecode,
4142 const std::vector &Args,
147148 //===---------------------------------------------------------------------===//
148149 // JIT Implementation of AbstractIntepreter interface
149150 //
150 class JIT : public AbstractInterpreter {
151 std::string LLIPath; // The path to the LLI executable
152 public:
153 JIT(const std::string &Path) : LLIPath(Path) { }
154
155
156 virtual int ExecuteProgram(const std::string &Bytecode,
157 const std::vector &Args,
158 const std::string &InputFile,
159 const std::string &OutputFile,
160 const std::vector &SharedLibs =
151 namespace {
152 class JIT : public AbstractInterpreter {
153 std::string LLIPath; // The path to the LLI executable
154 public:
155 JIT(const std::string &Path) : LLIPath(Path) { }
156
157
158 virtual int ExecuteProgram(const std::string &Bytecode,
159 const std::vector &Args,
160 const std::string &InputFile,
161 const std::string &OutputFile,
162 const std::vector &SharedLibs =
161163 std::vector());
162 };
164 };
165 }
163166
164167 int JIT::ExecuteProgram(const std::string &Bytecode,
165168 const std::vector &Args,
395398 Message = "Found gcc: " + GCCPath + "\n";
396399 return new GCC(GCCPath);
397400 }
398
399 } // End llvm namespace