summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2013-08-06 22:51:21 +0000
committerReid Kleckner <reid@kleckner.net>2013-08-06 22:51:21 +0000
commitd78273f4fdce247ab52cb26ed0d1f908efb44f39 (patch)
tree23740d6e8113b11c35a3ea4f3ad42e37c51afbed /llvm/lib/Support
parenta7cd6bf3bbf9d1efc2ec7b9c617209408caf6a86 (diff)
downloadbcm5719-llvm-d78273f4fdce247ab52cb26ed0d1f908efb44f39.tar.gz
bcm5719-llvm-d78273f4fdce247ab52cb26ed0d1f908efb44f39.zip
Remove some std stream usage from Support and TableGen
LLVM's coding standards recommend raw_ostream and MemoryBuffer for reading and writing text. This has the side effect of allowing clang to compile more of Support and TableGen in the Microsoft C++ ABI. llvm-svn: 187826
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r--llvm/lib/Support/Disassembler.cpp10
-rw-r--r--llvm/lib/Support/LockFileManager.cpp22
2 files changed, 18 insertions, 14 deletions
diff --git a/llvm/lib/Support/Disassembler.cpp b/llvm/lib/Support/Disassembler.cpp
index b3244fab7df..27df3a9e2cb 100644
--- a/llvm/lib/Support/Disassembler.cpp
+++ b/llvm/lib/Support/Disassembler.cpp
@@ -41,10 +41,10 @@ bool llvm::sys::hasDisassembler()
std::string llvm::sys::disassembleBuffer(uint8_t* start, size_t length,
uint64_t pc) {
- std::stringstream res;
-
#if (defined (__i386__) || defined (__amd64__) || defined (__x86_64__)) \
&& USE_UDIS86
+ std::stringstream res;
+
unsigned bits;
# if defined(__i386__)
bits = 32;
@@ -66,9 +66,9 @@ std::string llvm::sys::disassembleBuffer(uint8_t* start, size_t length,
while (ud_disassemble(&ud_obj)) {
res << ud_insn_off(&ud_obj) << ":\t" << ud_insn_asm(&ud_obj) << "\n";
}
-#else
- res << "No disassembler available. See configure help for options.\n";
-#endif
return res.str();
+#else
+ return "No disassembler available. See configure help for options.\n";
+#endif
}
diff --git a/llvm/lib/Support/LockFileManager.cpp b/llvm/lib/Support/LockFileManager.cpp
index 21c4d4070d2..b1ff22c2e68 100644
--- a/llvm/lib/Support/LockFileManager.cpp
+++ b/llvm/lib/Support/LockFileManager.cpp
@@ -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 LockFileName) {
// 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)) {
+ 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;
}
OpenPOWER on IntegriCloud