#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Path.h"
+#include <sstream>
#include <stdexcept>
#include <string>
namespace {
+ std::stringstream* GlobalTimeLog;
+
sys::Path getTempDir() {
sys::Path tempDir;
namespace llvmc {
+// Used to implement -time option. External linkage is intentional.
+void AppendToGlobalTimeLog(const std::string& cmd, double time) {
+ *GlobalTimeLog << "# " << cmd << ' ' << time << '\n';
+}
+
// Sometimes plugins want to condition on the value in argv[0].
const char* ProgramName;
throw std::runtime_error("no input files");
}
- return BuildTargets(graph, langMap);
+ if (Time) {
+ GlobalTimeLog = new std::stringstream;
+ GlobalTimeLog->precision(2);
+ }
+
+ int ret = BuildTargets(graph, langMap);
+
+ if (Time) {
+ llvm::errs() << GlobalTimeLog->str();
+ delete GlobalTimeLog;
+ }
+
+ return ret;
}
catch(llvmc::error_code& ec) {
return ec.code();