#include "llvm/Support/Timer.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/Streams.h"
#include "llvm/System/Process.h"
#include <algorithm>
#include <fstream>
#include <functional>
-#include <iostream>
#include <map>
using namespace llvm;
// getLibSupportInfoOutputFilename - This ugly hack is brought to you courtesy
// of constructor/destructor ordering being unspecified by C++. Basically the
-// problem is that a Statistic<> object gets destroyed, which ends up calling
+// problem is that a Statistic object gets destroyed, which ends up calling
// 'GetLibSupportInfoOutputFile()' (below), which calls this function.
// LibSupportInfoOutputFilename used to be a global variable, but sometimes it
// would get destroyed before the Statistic, causing havoc to ensue. We "fix"
llvm::GetLibSupportInfoOutputFile() {
std::string &LibSupportInfoOutputFilename = getLibSupportInfoOutputFilename();
if (LibSupportInfoOutputFilename.empty())
- return &std::cerr;
+ return cerr.stream();
if (LibSupportInfoOutputFilename == "-")
- return &std::cout;
+ return cout.stream();
std::ostream *Result = new std::ofstream(LibSupportInfoOutputFilename.c_str(),
std::ios::app);
if (!Result->good()) {
- std::cerr << "Error opening info-output-file '"
- << LibSupportInfoOutputFilename << " for appending!\n";
+ cerr << "Error opening info-output-file '"
+ << LibSupportInfoOutputFilename << " for appending!\n";
delete Result;
- return &std::cerr;
+ return cerr.stream();
}
return Result;
}
TimersToPrint.clear();
- if (OutStream != &std::cerr && OutStream != &std::cout)
+ if (OutStream != cerr.stream() && OutStream != cout.stream())
delete OutStream; // Close the file...
}