From 5ca98fd98791947eba83a1ed3f2c8191ef7afa6c Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Mon, 24 Nov 2014 09:08:18 +0000 Subject: Vendor import of llvm RELEASE_350/final tag r216957 (effectively, 3.5.0 release): https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_350/final@216957 --- utils/FileUpdate/FileUpdate.cpp | 87 ----------------------------------------- 1 file changed, 87 deletions(-) delete mode 100644 utils/FileUpdate/FileUpdate.cpp (limited to 'utils/FileUpdate/FileUpdate.cpp') diff --git a/utils/FileUpdate/FileUpdate.cpp b/utils/FileUpdate/FileUpdate.cpp deleted file mode 100644 index fbcd9277cd51..000000000000 --- a/utils/FileUpdate/FileUpdate.cpp +++ /dev/null @@ -1,87 +0,0 @@ -//===- FileUpdate.cpp - Conditionally update a file -----------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// FileUpdate is a utility for conditionally updating a file from its input -// based on whether the input differs from the output. It is used to avoid -// unnecessary modifications in a build system. -// -//===----------------------------------------------------------------------===// - -#include "llvm/ADT/OwningPtr.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/PrettyStackTrace.h" -#include "llvm/Support/Signals.h" -#include "llvm/Support/ToolOutputFile.h" -#include "llvm/Support/system_error.h" -using namespace llvm; - -static cl::opt -Quiet("quiet", cl::desc("Don't print unnecessary status information"), - cl::init(false)); - -static cl::opt -InputFilename("input-file", cl::desc("Input file (defaults to stdin)"), - cl::init("-"), cl::value_desc("filename")); - -static cl::opt -OutputFilename(cl::Positional, cl::desc(""), cl::Required); - -int main(int argc, char **argv) { - sys::PrintStackTraceOnErrorSignal(); - PrettyStackTraceProgram X(argc, argv); - cl::ParseCommandLineOptions(argc, argv); - - if (OutputFilename == "-") { - errs() << argv[0] << ": error: Can't update standard output\n"; - return 1; - } - - // Get the input data. - OwningPtr In; - if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename, In)) { - errs() << argv[0] << ": error: Unable to get input '" - << InputFilename << "': " << ec.message() << '\n'; - return 1; - } - - // Get the output data. - OwningPtr Out; - MemoryBuffer::getFile(OutputFilename.c_str(), Out); - - // If the output exists and the contents match, we are done. - if (Out && In->getBufferSize() == Out->getBufferSize() && - memcmp(In->getBufferStart(), Out->getBufferStart(), - Out->getBufferSize()) == 0) { - if (!Quiet) - errs() << argv[0] << ": Not updating '" << OutputFilename - << "', contents match input.\n"; - return 0; - } - - // Otherwise, overwrite the output. - if (!Quiet) - errs() << argv[0] << ": Updating '" << OutputFilename - << "', contents changed.\n"; - std::string ErrorStr; - tool_output_file OutStream(OutputFilename.c_str(), ErrorStr, - sys::fs::F_Binary); - if (!ErrorStr.empty()) { - errs() << argv[0] << ": Unable to write output '" - << OutputFilename << "': " << ErrorStr << '\n'; - return 1; - } - - OutStream.os().write(In->getBufferStart(), In->getBufferSize()); - - // Declare success. - OutStream.keep(); - - return 0; -} -- cgit v1.2.3