Mercurial > projects > ldc
comparison gen/toobj.cpp @ 994:18ad5601dff7
Use LLVM OStream wrapper instead of <iostream> in the logger.
llvm::OStream provides all std::ostream functionality (by holding a
std::ostream* internally), but
* doesn't include <iostream>, avoiding per-file overhead.
* allows the stream pointer to be null, and the (inlined) operators do nothing
when that's the case. (This also allows removal of the ofstream("/dev/null")
hack Logger used when disabled, which presumably wasn't very portable)
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Thu, 26 Feb 2009 14:51:02 +0100 |
parents | 27956b440c0a |
children | 5aa5d25508c6 |
comparison
equal
deleted
inserted
replaced
993:27956b440c0a | 994:18ad5601dff7 |
---|---|
6 // License for redistribution is by either the Artistic License | 6 // License for redistribution is by either the Artistic License |
7 // in artistic.txt, or the GNU General Public License in gnu.txt. | 7 // in artistic.txt, or the GNU General Public License in gnu.txt. |
8 // See the included readme.txt for details. | 8 // See the included readme.txt for details. |
9 | 9 |
10 #include <cstddef> | 10 #include <cstddef> |
11 #include <iostream> | |
12 #include <fstream> | 11 #include <fstream> |
13 | 12 |
14 #include "gen/llvm.h" | 13 #include "gen/llvm.h" |
15 #include "llvm/Analysis/Verifier.h" | 14 #include "llvm/Analysis/Verifier.h" |
16 #include "llvm/Bitcode/ReaderWriter.h" | 15 #include "llvm/Bitcode/ReaderWriter.h" |
342 std::vector<const char *> Args; | 341 std::vector<const char *> Args; |
343 for (unsigned i = 0, e = args.size(); i != e; ++i) | 342 for (unsigned i = 0, e = args.size(); i != e; ++i) |
344 Args.push_back(args[i].c_str()); | 343 Args.push_back(args[i].c_str()); |
345 Args.push_back(0); | 344 Args.push_back(0); |
346 | 345 |
347 Logger::println("Assembling with: "); | 346 if (Logger::enabled()) { |
348 std::vector<const char*>::const_iterator I = Args.begin(), E = Args.end(); | 347 Logger::println("Assembling with: "); |
349 std::ostream& logstr = Logger::cout(); | 348 std::vector<const char*>::const_iterator I = Args.begin(), E = Args.end(); |
350 for (; I != E; ++I) | 349 std::ostream& logstr = *Logger::cout().stream(); |
351 if (*I) | 350 for (; I != E; ++I) |
352 logstr << "'" << *I << "'" << " "; | 351 if (*I) |
353 logstr << "\n" << std::flush; | 352 logstr << "'" << *I << "'" << " "; |
353 logstr << "\n" << std::flush; | |
354 } | |
354 | 355 |
355 // Run the compiler to assembly the program. | 356 // Run the compiler to assembly the program. |
356 std::string ErrMsg; | 357 std::string ErrMsg; |
357 int R = sys::Program::ExecuteAndWait( | 358 int R = sys::Program::ExecuteAndWait( |
358 gcc, &Args[0], 0, 0, 0, 0, &ErrMsg); | 359 gcc, &Args[0], 0, 0, 0, 0, &ErrMsg); |