diff options
Diffstat (limited to 'llvm/lib/TableGen/Main.cpp')
-rw-r--r-- | llvm/lib/TableGen/Main.cpp | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/llvm/lib/TableGen/Main.cpp b/llvm/lib/TableGen/Main.cpp index bcd7dce95a8..3a070162608 100644 --- a/llvm/lib/TableGen/Main.cpp +++ b/llvm/lib/TableGen/Main.cpp @@ -96,21 +96,8 @@ int llvm::TableGenMain(char *argv0, TableGenMainFn *MainFn) { if (Parser.ParseFile()) return 1; - // Write output to memory. - std::string OutString; - raw_string_ostream Out(OutString); - if (MainFn(Out, Records)) - return 1; - - // Only updates the real output file if there are any differences. - // This prevents recompilation of all the files depending on it if there - // aren't any. - if (auto ExistingOrErr = MemoryBuffer::getFile(OutputFilename)) - if (std::move(ExistingOrErr.get())->getBuffer() == Out.str()) - return 0; - std::error_code EC; - ToolOutputFile OutFile(OutputFilename, EC, sys::fs::F_Text); + ToolOutputFile Out(OutputFilename, EC, sys::fs::F_Text); if (EC) return reportError(argv0, "error opening " + OutputFilename + ":" + EC.message() + "\n"); @@ -118,12 +105,14 @@ int llvm::TableGenMain(char *argv0, TableGenMainFn *MainFn) { if (int Ret = createDependencyFile(Parser, argv0)) return Ret; } - OutFile.os() << Out.str(); + + if (MainFn(Out.os(), Records)) + return 1; if (ErrorsPrinted > 0) return reportError(argv0, Twine(ErrorsPrinted) + " errors.\n"); // Declare success. - OutFile.keep(); + Out.keep(); return 0; } |