diff options
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r-- | llvm/lib/Support/FileUtilities.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/Support/LockFileManager.cpp | 15 | ||||
-rw-r--r-- | llvm/lib/Support/SmallPtrSet.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/Support/StringMap.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/Support/raw_ostream.cpp | 13 |
5 files changed, 31 insertions, 18 deletions
diff --git a/llvm/lib/Support/FileUtilities.cpp b/llvm/lib/Support/FileUtilities.cpp index c6a58cc9d03..39dbefff5b7 100644 --- a/llvm/lib/Support/FileUtilities.cpp +++ b/llvm/lib/Support/FileUtilities.cpp @@ -14,13 +14,17 @@ #include "llvm/Support/FileUtilities.h" #include "llvm/ADT/SmallString.h" +#include "llvm/Support/ErrorOr.h" #include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" #include <cctype> +#include <cmath> +#include <cstdint> #include <cstdlib> #include <cstring> +#include <memory> #include <system_error> + using namespace llvm; static bool isSignedChar(char C) { @@ -215,7 +219,7 @@ int llvm::DiffFilesWithTolerance(StringRef NameA, } bool CompareFailed = false; - while (1) { + while (true) { // Scan for the end of file or next difference. while (F1P < File1End && F2P < File2End && *F1P == *F2P) { ++F1P; diff --git a/llvm/lib/Support/LockFileManager.cpp b/llvm/lib/Support/LockFileManager.cpp index 611f94a9709..357d0e37856 100644 --- a/llvm/lib/Support/LockFileManager.cpp +++ b/llvm/lib/Support/LockFileManager.cpp @@ -6,13 +6,21 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// + #include "llvm/Support/LockFileManager.h" +#include "llvm/ADT/None.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Errc.h" +#include "llvm/Support/ErrorOr.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/Signals.h" +#include <cerrno> +#include <ctime> +#include <memory> +#include <tuple> #include <sys/stat.h> #include <sys/types.h> #if LLVM_ON_WIN32 @@ -31,6 +39,7 @@ #if USE_OSX_GETHOSTUUID #include <uuid/uuid.h> #endif + using namespace llvm; /// \brief Attempt to read the lock file with the given name, if it exists. @@ -112,6 +121,7 @@ bool LockFileManager::processStillExecuting(StringRef HostID, int PID) { } namespace { + /// An RAII helper object ensure that the unique lock file is removed. /// /// Ensures that if there is an error or a signal before we finish acquiring the @@ -127,6 +137,7 @@ public: : Filename(Name), RemoveImmediately(true) { sys::RemoveFileOnSignal(Filename, nullptr); } + ~RemoveUniqueLockFileOnSignal() { if (!RemoveImmediately) { // Leave the signal handler enabled. It will be removed when the lock is @@ -136,8 +147,10 @@ public: sys::fs::remove(Filename); sys::DontRemoveFileOnSignal(Filename); } + void lockAcquired() { RemoveImmediately = false; } }; + } // end anonymous namespace LockFileManager::LockFileManager(StringRef FileName) @@ -202,7 +215,7 @@ LockFileManager::LockFileManager(StringRef FileName) // held since the .lock symlink will point to a nonexistent file. RemoveUniqueLockFileOnSignal RemoveUniqueFile(UniqueLockFileName); - while (1) { + while (true) { // Create a link from the lock file name. If this succeeds, we're done. std::error_code EC = sys::fs::create_link(UniqueLockFileName, LockFileName); diff --git a/llvm/lib/Support/SmallPtrSet.cpp b/llvm/lib/Support/SmallPtrSet.cpp index 539b4eb34da..8fb12ba917b 100644 --- a/llvm/lib/Support/SmallPtrSet.cpp +++ b/llvm/lib/Support/SmallPtrSet.cpp @@ -16,6 +16,7 @@ #include "llvm/ADT/DenseMapInfo.h" #include "llvm/Support/MathExtras.h" #include <algorithm> +#include <cassert> #include <cstdlib> using namespace llvm; @@ -91,7 +92,7 @@ const void * const *SmallPtrSetImplBase::FindBucketFor(const void *Ptr) const { unsigned ProbeAmt = 1; const void *const *Array = CurArray; const void *const *Tombstone = nullptr; - while (1) { + while (true) { // If we found an empty bucket, the pointer doesn't exist in the set. // Return a tombstone if we've seen one so far, or the empty bucket if // not. diff --git a/llvm/lib/Support/StringMap.cpp b/llvm/lib/Support/StringMap.cpp index 7da9ccbd40c..d2315966e32 100644 --- a/llvm/lib/Support/StringMap.cpp +++ b/llvm/lib/Support/StringMap.cpp @@ -14,7 +14,9 @@ #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/MathExtras.h" #include <cassert> + using namespace llvm; /// Returns the number of buckets to allocate to ensure that the DenseMap can @@ -63,7 +65,6 @@ void StringMapImpl::init(unsigned InitSize) { TheTable[NumBuckets] = (StringMapEntryBase*)2; } - /// LookupBucketFor - Look up the bucket that the specified string should end /// up in. If it already exists as a key in the map, the Item pointer for the /// specified bucket will be non-null. Otherwise, it will be null. In either @@ -81,7 +82,7 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name) { unsigned ProbeAmt = 1; int FirstTombstone = -1; - while (1) { + while (true) { StringMapEntryBase *BucketItem = TheTable[BucketNo]; // If we found an empty bucket, this key isn't in the table yet, return it. if (LLVM_LIKELY(!BucketItem)) { @@ -123,7 +124,6 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name) { } } - /// FindKey - Look up the bucket that contains the specified key. If it exists /// in the map, return the bucket number of the key. Otherwise return -1. /// This does not modify the map. @@ -135,7 +135,7 @@ int StringMapImpl::FindKey(StringRef Key) const { unsigned *HashTable = (unsigned *)(TheTable + NumBuckets + 1); unsigned ProbeAmt = 1; - while (1) { + while (true) { StringMapEntryBase *BucketItem = TheTable[BucketNo]; // If we found an empty bucket, this key isn't in the table yet, return. if (LLVM_LIKELY(!BucketItem)) @@ -191,8 +191,6 @@ StringMapEntryBase *StringMapImpl::RemoveKey(StringRef Key) { return Result; } - - /// RehashTable - Grow the table, redistributing values into the buckets with /// the appropriate mod-of-hashtable-size. unsigned StringMapImpl::RehashTable(unsigned BucketNo) { diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp index c4a7b145588..df4c8dc376b 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp @@ -23,10 +23,13 @@ #include "llvm/Support/MathExtras.h" #include "llvm/Support/Process.h" #include "llvm/Support/Program.h" +#include <algorithm> #include <cctype> #include <cerrno> -#include <sys/stat.h> +#include <cstdio> +#include <iterator> #include <system_error> +#include <sys/stat.h> // <fcntl.h> may provide O_BINARY. #if defined(HAVE_FCNTL_H) @@ -266,8 +269,6 @@ raw_ostream &raw_ostream::operator<<(double N) { return this->operator<<(format("%e", N)); } - - void raw_ostream::flush_nonempty() { assert(OutBufCur > OutBufStart && "Invalid call to flush_nonempty."); size_t Length = OutBufCur - OutBufStart; @@ -382,7 +383,7 @@ raw_ostream &raw_ostream::operator<<(const format_object_base &Fmt) { // space. Iterate until we win. SmallVector<char, 128> V; - while (1) { + while (true) { V.resize(NextBufferSize); // Try formatting into the SmallVector. @@ -455,7 +456,6 @@ raw_ostream &raw_ostream::operator<<(const FormattedNumber &FN) { } } - /// indent - Insert 'NumSpaces' spaces. raw_ostream &raw_ostream::indent(unsigned NumSpaces) { static const char Spaces[] = " " @@ -475,7 +475,6 @@ raw_ostream &raw_ostream::indent(unsigned NumSpaces) { return *this; } - //===----------------------------------------------------------------------===// // Formatted Output //===----------------------------------------------------------------------===// @@ -563,7 +562,6 @@ raw_fd_ostream::~raw_fd_ostream() { report_fatal_error("IO failure on output stream.", /*GenCrashDiag=*/false); } - void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) { assert(FD >= 0 && "File already closed."); pos += Size; @@ -740,7 +738,6 @@ raw_ostream &llvm::nulls() { return S; } - //===----------------------------------------------------------------------===// // raw_string_ostream //===----------------------------------------------------------------------===// |