[llvm] r187826 - Remove some std stream usage from Support and TableGen
Reid Kleckner
rnk at google.com
Tue Aug 6 16:00:45 PDT 2013
On Tue, Aug 6, 2013 at 3:51 PM, Reid Kleckner <reid at kleckner.net> wrote:
> Modified: llvm/trunk/lib/Support/LockFileManager.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/LockFileManager.cpp?rev=187826&r1=187825&r2=187826&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Support/LockFileManager.cpp (original)
> +++ llvm/trunk/lib/Support/LockFileManager.cpp Tue Aug 6 17:51:21 2013
> @@ -7,9 +7,11 @@
> //
>
> //===----------------------------------------------------------------------===//
> #include "llvm/Support/LockFileManager.h"
> +#include "llvm/ADT/STLExtras.h"
> +#include "llvm/ADT/StringExtras.h"
> #include "llvm/Support/FileSystem.h"
> +#include "llvm/Support/MemoryBuffer.h"
> #include "llvm/Support/raw_ostream.h"
> -#include <fstream>
> #include <sys/stat.h>
> #include <sys/types.h>
> #if LLVM_ON_WIN32
> @@ -35,16 +37,18 @@ LockFileManager::readLockFile(StringRef
>
> // Read the owning host and PID out of the lock file. If it appears
> that the
> // owning process is dead, the lock file is invalid.
> - int PID = 0;
> - std::string Hostname;
> - std::ifstream Input(LockFileName.str().c_str());
> - if (Input >> Hostname >> PID && PID > 0 &&
> - processStillExecuting(Hostname, PID))
> - return std::make_pair(Hostname, PID);
> + OwningPtr<MemoryBuffer> MB;
> + if (MemoryBuffer::getFile(LockFileName, MB)) {
>
Speaking of error handling and booleans, it looks like this if condition is
wrong, but we don't have any test coverage for it. D=
> + StringRef Hostname;
> + StringRef PIDStr;
> + tie(Hostname, PIDStr) = getToken(MB->getBuffer(), " ");
> + int PID;
> + if (PIDStr.getAsInteger(10, PID))
> + return std::make_pair(std::string(Hostname), PID);
> + }
>
> // Delete the lock file. It's invalid anyway.
> - bool Existed;
> - sys::fs::remove(LockFileName, Existed);
> + sys::fs::remove(LockFileName);
> return None;
> }
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130806/dfc56df4/attachment.html>
More information about the llvm-commits
mailing list