[llvm] f1aa734 - [Support] Apply clang-format on .inc files. NFC.
Alexandre Ganea via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 26 06:38:30 PST 2022
Author: Alexandre Ganea
Date: 2022-11-26T09:36:43-05:00
New Revision: f1aa7348d355a57cd9050f37860346bd82118573
URL: https://github.com/llvm/llvm-project/commit/f1aa7348d355a57cd9050f37860346bd82118573
DIFF: https://github.com/llvm/llvm-project/commit/f1aa7348d355a57cd9050f37860346bd82118573.diff
LOG: [Support] Apply clang-format on .inc files. NFC.
Apply clang-format on llvm/lib/Support/Windows/ and llvm/lib/Support/Unix/ since .inc files in these folders aren't picked up by default. Eventually we need to add this extension in the monorepo .clang-format file.
Differential Revision: https://reviews.llvm.org/D138714
Added:
Modified:
llvm/lib/Support/Unix/COM.inc
llvm/lib/Support/Unix/DynamicLibrary.inc
llvm/lib/Support/Unix/Memory.inc
llvm/lib/Support/Unix/Path.inc
llvm/lib/Support/Unix/Process.inc
llvm/lib/Support/Unix/Program.inc
llvm/lib/Support/Unix/Signals.inc
llvm/lib/Support/Unix/ThreadLocal.inc
llvm/lib/Support/Unix/Threading.inc
llvm/lib/Support/Unix/Watchdog.inc
llvm/lib/Support/Windows/COM.inc
llvm/lib/Support/Windows/DynamicLibrary.inc
llvm/lib/Support/Windows/Host.inc
llvm/lib/Support/Windows/Memory.inc
llvm/lib/Support/Windows/Path.inc
llvm/lib/Support/Windows/Process.inc
llvm/lib/Support/Windows/Program.inc
llvm/lib/Support/Windows/Signals.inc
llvm/lib/Support/Windows/ThreadLocal.inc
llvm/lib/Support/Windows/Threading.inc
llvm/lib/Support/Windows/Watchdog.inc
llvm/lib/Support/Windows/explicit_symbols.inc
Removed:
################################################################################
diff --git a/llvm/lib/Support/Unix/COM.inc b/llvm/lib/Support/Unix/COM.inc
index d97b59ac02cfe..846d4b68a7eb3 100644
--- a/llvm/lib/Support/Unix/COM.inc
+++ b/llvm/lib/Support/Unix/COM.inc
@@ -22,5 +22,5 @@ InitializeCOMRAII::InitializeCOMRAII(COMThreadingMode Threading,
bool SpeedOverMemory) {}
InitializeCOMRAII::~InitializeCOMRAII() = default;
-}
-}
+} // namespace sys
+} // namespace llvm
diff --git a/llvm/lib/Support/Unix/DynamicLibrary.inc b/llvm/lib/Support/Unix/DynamicLibrary.inc
index a2a379963de03..7b77da5e0c6b2 100644
--- a/llvm/lib/Support/Unix/DynamicLibrary.inc
+++ b/llvm/lib/Support/Unix/DynamicLibrary.inc
@@ -25,9 +25,10 @@ DynamicLibrary::HandleSet::~HandleSet() {
}
void *DynamicLibrary::HandleSet::DLOpen(const char *File, std::string *Err) {
- void *Handle = ::dlopen(File, RTLD_LAZY|RTLD_GLOBAL);
+ void *Handle = ::dlopen(File, RTLD_LAZY | RTLD_GLOBAL);
if (!Handle) {
- if (Err) *Err = ::dlerror();
+ if (Err)
+ *Err = ::dlerror();
return &DynamicLibrary::Invalid;
}
@@ -41,9 +42,7 @@ void *DynamicLibrary::HandleSet::DLOpen(const char *File, std::string *Err) {
return Handle;
}
-void DynamicLibrary::HandleSet::DLClose(void *Handle) {
- ::dlclose(Handle);
-}
+void DynamicLibrary::HandleSet::DLClose(void *Handle) { ::dlclose(Handle); }
void *DynamicLibrary::HandleSet::DLSym(void *Handle, const char *Symbol) {
return ::dlsym(Handle, Symbol);
@@ -54,12 +53,12 @@ void *DynamicLibrary::HandleSet::DLSym(void *Handle, const char *Symbol) {
DynamicLibrary::HandleSet::~HandleSet() {}
void *DynamicLibrary::HandleSet::DLOpen(const char *File, std::string *Err) {
- if (Err) *Err = "dlopen() not supported on this platform";
+ if (Err)
+ *Err = "dlopen() not supported on this platform";
return &Invalid;
}
-void DynamicLibrary::HandleSet::DLClose(void *Handle) {
-}
+void DynamicLibrary::HandleSet::DLClose(void *Handle) {}
void *DynamicLibrary::HandleSet::DLSym(void *Handle, const char *Symbol) {
return nullptr;
@@ -68,9 +67,11 @@ void *DynamicLibrary::HandleSet::DLSym(void *Handle, const char *Symbol) {
#endif
// Must declare the symbols in the global namespace.
-static void *DoSearch(const char* SymbolName) {
-#define EXPLICIT_SYMBOL(SYM) \
- extern void *SYM; if (!strcmp(SymbolName, #SYM)) return (void*)&SYM
+static void *DoSearch(const char *SymbolName) {
+#define EXPLICIT_SYMBOL(SYM) \
+ extern void *SYM; \
+ if (!strcmp(SymbolName, #SYM)) \
+ return (void *)&SYM
// If this is darwin, it has some funky issues, try to solve them here. Some
// important symbols are marked 'private external' which doesn't allow
@@ -101,8 +102,9 @@ static void *DoSearch(const char* SymbolName) {
#undef EXPLICIT_SYMBOL
// This macro returns the address of a well-known, explicit symbol
-#define EXPLICIT_SYMBOL(SYM) \
- if (!strcmp(SymbolName, #SYM)) return &SYM
+#define EXPLICIT_SYMBOL(SYM) \
+ if (!strcmp(SymbolName, #SYM)) \
+ return &SYM
// Under glibc we have a weird situation. The stderr/out/in symbols are both
// macros and global variables because of standards requirements. So, we
diff --git a/llvm/lib/Support/Unix/Memory.inc b/llvm/lib/Support/Unix/Memory.inc
index e4454fe8c517d..4c8f6b2ea7d3a 100644
--- a/llvm/lib/Support/Unix/Memory.inc
+++ b/llvm/lib/Support/Unix/Memory.inc
@@ -33,7 +33,7 @@
#if defined(__APPLE__)
extern "C" void sys_icache_invalidate(const void *Addr, size_t len);
#else
-extern "C" void __clear_cache(void *, void*);
+extern "C" void __clear_cache(void *, void *);
#endif
static int getPosixProtectionFlags(unsigned Flags) {
@@ -42,9 +42,9 @@ static int getPosixProtectionFlags(unsigned Flags) {
return PROT_READ;
case llvm::sys::Memory::MF_WRITE:
return PROT_WRITE;
- case llvm::sys::Memory::MF_READ|llvm::sys::Memory::MF_WRITE:
+ case llvm::sys::Memory::MF_READ | llvm::sys::Memory::MF_WRITE:
return PROT_READ | PROT_WRITE;
- case llvm::sys::Memory::MF_READ|llvm::sys::Memory::MF_EXEC:
+ case llvm::sys::Memory::MF_READ | llvm::sys::Memory::MF_EXEC:
return PROT_READ | PROT_EXEC;
case llvm::sys::Memory::MF_READ | llvm::sys::Memory::MF_WRITE |
llvm::sys::Memory::MF_EXEC:
@@ -70,11 +70,9 @@ static int getPosixProtectionFlags(unsigned Flags) {
namespace llvm {
namespace sys {
-MemoryBlock
-Memory::allocateMappedMemory(size_t NumBytes,
- const MemoryBlock *const NearBlock,
- unsigned PFlags,
- std::error_code &EC) {
+MemoryBlock Memory::allocateMappedMemory(size_t NumBytes,
+ const MemoryBlock *const NearBlock,
+ unsigned PFlags, std::error_code &EC) {
EC = std::error_code();
if (NumBytes == 0)
return MemoryBlock();
@@ -105,18 +103,19 @@ Memory::allocateMappedMemory(size_t NumBytes,
// Use any near hint and the page size to set a page-aligned starting address
uintptr_t Start = NearBlock ? reinterpret_cast<uintptr_t>(NearBlock->base()) +
- NearBlock->allocatedSize() : 0;
+ NearBlock->allocatedSize()
+ : 0;
static const size_t PageSize = Process::getPageSizeEstimate();
- const size_t NumPages = (NumBytes+PageSize-1)/PageSize;
+ const size_t NumPages = (NumBytes + PageSize - 1) / PageSize;
if (Start && Start % PageSize)
Start += PageSize - Start % PageSize;
// FIXME: Handle huge page requests (MF_HUGE_HINT).
- void *Addr = ::mmap(reinterpret_cast<void *>(Start), PageSize*NumPages, Protect,
- MMFlags, fd, 0);
+ void *Addr = ::mmap(reinterpret_cast<void *>(Start), PageSize * NumPages,
+ Protect, MMFlags, fd, 0);
if (Addr == MAP_FAILED) {
- if (NearBlock) { //Try again without a near hint
+ if (NearBlock) { // Try again without a near hint
#if !defined(MAP_ANON)
close(fd);
#endif
@@ -136,12 +135,12 @@ Memory::allocateMappedMemory(size_t NumBytes,
MemoryBlock Result;
Result.Address = Addr;
- Result.AllocatedSize = PageSize*NumPages;
+ Result.AllocatedSize = PageSize * NumPages;
Result.Flags = PFlags;
// Rely on protectMappedMemory to invalidate instruction cache.
if (PFlags & MF_EXEC) {
- EC = Memory::protectMappedMemory (Result, PFlags);
+ EC = Memory::protectMappedMemory(Result, PFlags);
if (EC != std::error_code())
return MemoryBlock();
}
@@ -149,8 +148,7 @@ Memory::allocateMappedMemory(size_t NumBytes,
return Result;
}
-std::error_code
-Memory::releaseMappedMemory(MemoryBlock &M) {
+std::error_code Memory::releaseMappedMemory(MemoryBlock &M) {
if (M.Address == nullptr || M.AllocatedSize == 0)
return std::error_code();
@@ -163,8 +161,8 @@ Memory::releaseMappedMemory(MemoryBlock &M) {
return std::error_code();
}
-std::error_code
-Memory::protectMappedMemory(const MemoryBlock &M, unsigned Flags) {
+std::error_code Memory::protectMappedMemory(const MemoryBlock &M,
+ unsigned Flags) {
static const Align PageSize = Align(Process::getPageSizeEstimate());
if (M.Address == nullptr || M.AllocatedSize == 0)
return std::error_code();
@@ -173,15 +171,18 @@ Memory::protectMappedMemory(const MemoryBlock &M, unsigned Flags) {
return std::error_code(EINVAL, std::generic_category());
int Protect = getPosixProtectionFlags(Flags);
- uintptr_t Start = alignAddr((const uint8_t *)M.Address - PageSize.value() + 1, PageSize);
- uintptr_t End = alignAddr((const uint8_t *)M.Address + M.AllocatedSize, PageSize);
+ uintptr_t Start =
+ alignAddr((const uint8_t *)M.Address - PageSize.value() + 1, PageSize);
+ uintptr_t End =
+ alignAddr((const uint8_t *)M.Address + M.AllocatedSize, PageSize);
bool InvalidateCache = (Flags & MF_EXEC);
#if defined(__arm__) || defined(__aarch64__)
- // Certain ARM implementations treat icache clear instruction as a memory read,
- // and CPU segfaults on trying to clear cache on !PROT_READ page. Therefore we need
- // to temporarily add PROT_READ for the sake of flushing the instruction caches.
+ // Certain ARM implementations treat icache clear instruction as a memory
+ // read, and CPU segfaults on trying to clear cache on !PROT_READ page.
+ // Therefore we need to temporarily add PROT_READ for the sake of flushing the
+ // instruction caches.
if (InvalidateCache && !(Protect & PROT_READ)) {
int Result = ::mprotect((void *)Start, End - Start, Protect | PROT_READ);
if (Result != 0)
@@ -206,15 +207,14 @@ Memory::protectMappedMemory(const MemoryBlock &M, unsigned Flags) {
/// InvalidateInstructionCache - Before the JIT can run a block of code
/// that has been emitted it must invalidate the instruction cache on some
/// platforms.
-void Memory::InvalidateInstructionCache(const void *Addr,
- size_t Len) {
+void Memory::InvalidateInstructionCache(const void *Addr, size_t Len) {
// icache invalidation for PPC and ARM.
#if defined(__APPLE__)
-# if (defined(__powerpc__) || defined(__arm__) || defined(__arm64__))
+#if (defined(__powerpc__) || defined(__arm__) || defined(__arm64__))
sys_icache_invalidate(const_cast<void *>(Addr), Len);
-# endif
+#endif
#elif defined(__Fuchsia__)
@@ -223,12 +223,12 @@ void Memory::InvalidateInstructionCache(const void *Addr,
#else
-# if defined(__powerpc__) && defined(__GNUC__)
+#if defined(__powerpc__) && defined(__GNUC__)
const size_t LineSize = 32;
const intptr_t Mask = ~(LineSize - 1);
- const intptr_t StartLine = ((intptr_t) Addr) & Mask;
- const intptr_t EndLine = ((intptr_t) Addr + Len + LineSize - 1) & Mask;
+ const intptr_t StartLine = ((intptr_t)Addr) & Mask;
+ const intptr_t EndLine = ((intptr_t)Addr + Len + LineSize - 1) & Mask;
for (intptr_t Line = StartLine; Line < EndLine; Line += LineSize)
asm volatile("dcbf 0, %0" : : "r"(Line));
@@ -237,15 +237,15 @@ void Memory::InvalidateInstructionCache(const void *Addr,
for (intptr_t Line = StartLine; Line < EndLine; Line += LineSize)
asm volatile("icbi 0, %0" : : "r"(Line));
asm volatile("isync");
-# elif (defined(__arm__) || defined(__aarch64__) || defined(__mips__)) && \
- defined(__GNUC__)
+#elif (defined(__arm__) || defined(__aarch64__) || defined(__mips__)) && \
+ defined(__GNUC__)
// FIXME: Can we safely always call this for __GNUC__ everywhere?
const char *Start = static_cast<const char *>(Addr);
const char *End = Start + Len;
__clear_cache(const_cast<char *>(Start), const_cast<char *>(End));
-# endif
+#endif
-#endif // end apple
+#endif // end apple
ValgrindDiscardTranslations(Addr, Len);
}
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index 2eb17474c46f0..3efcad4f2bed4 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -36,9 +36,9 @@
#include <sys/file.h>
#ifdef __APPLE__
+#include <copyfile.h>
#include <mach-o/dyld.h>
#include <sys/attr.h>
-#include <copyfile.h>
#if __has_include(<sys/clonefile.h>)
#include <sys/clonefile.h>
#endif
@@ -111,7 +111,7 @@ typedef uint_t uint;
#define STATVFS_F_FRSIZE(vfs) static_cast<uint64_t>(vfs.f_bsize)
#endif
-#if defined(__NetBSD__) || defined(__DragonFly__) || defined(__GNU__) || \
+#if defined(__NetBSD__) || defined(__DragonFly__) || defined(__GNU__) || \
defined(__MVS__)
#define STATVFS_F_FLAG(vfs) (vfs).f_flag
#else
@@ -121,18 +121,16 @@ typedef uint_t uint;
using namespace llvm;
namespace llvm {
-namespace sys {
+namespace sys {
namespace fs {
const file_t kInvalidFile = -1;
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
defined(__minix) || defined(__FreeBSD_kernel__) || defined(__linux__) || \
- defined(__CYGWIN__) || defined(__DragonFly__) || defined(_AIX) || defined(__GNU__) || \
- (defined(__sun__) && defined(__svr4__))
-static int
-test_dir(char ret[PATH_MAX], const char *dir, const char *bin)
-{
+ defined(__CYGWIN__) || defined(__DragonFly__) || defined(_AIX) || \
+ defined(__GNU__) || (defined(__sun__) && defined(__svr4__))
+static int test_dir(char ret[PATH_MAX], const char *dir, const char *bin) {
struct stat sb;
char fullpath[PATH_MAX];
@@ -149,9 +147,7 @@ test_dir(char ret[PATH_MAX], const char *dir, const char *bin)
return 0;
}
-static char *
-getprogpath(char ret[PATH_MAX], const char *bin)
-{
+static char *getprogpath(char ret[PATH_MAX], const char *bin) {
if (bin == nullptr)
return nullptr;
@@ -319,7 +315,7 @@ std::string getMainExecutableImpl(const char *argv0, void *MainAddr) {
char real_path[PATH_MAX];
if (realpath(exe_path, real_path))
return std::string(real_path);
- break; // Found entry, but realpath failed.
+ break; // Found entry, but realpath failed.
}
#elif defined(HAVE_DLFCN_H) && defined(HAVE_DLADDR)
// Use dladdr to get executable path if available.
@@ -351,9 +347,7 @@ UniqueID file_status::getUniqueID() const {
return UniqueID(fs_st_dev, fs_st_ino);
}
-uint32_t file_status::getLinkCount() const {
- return fs_st_nlinks;
-}
+uint32_t file_status::getLinkCount() const { return fs_st_nlinks; }
ErrorOr<space_info> disk_space(const Twine &Path) {
struct STATVFS Vfs;
@@ -513,7 +507,8 @@ static bool is_local_impl(struct STATVFS &Vfs) {
// Haiku doesn't expose this information.
return false;
#elif defined(__sun)
- // statvfs::f_basetype contains a null-terminated FSType name of the mounted target
+ // statvfs::f_basetype contains a null-terminated FSType name of the mounted
+ // target
StringRef fstype(Vfs.f_basetype);
// NFS is the only non-local fstype??
return !fstype.equals("nfs");
@@ -637,8 +632,7 @@ bool can_execute(const Twine &Path) {
bool equivalent(file_status A, file_status B) {
assert(status_known(A) && status_known(B));
- return A.fs_st_dev == B.fs_st_dev &&
- A.fs_st_ino == B.fs_st_ino;
+ return A.fs_st_dev == B.fs_st_dev && A.fs_st_ino == B.fs_st_ino;
}
std::error_code equivalent(const Twine &A, const Twine &B, bool &result) {
@@ -697,7 +691,6 @@ static void expandTildeExpr(SmallVectorImpl<char> &Path) {
llvm::sys::path::append(Path, Storage);
}
-
void expand_tilde(const Twine &path, SmallVectorImpl<char> &dest) {
dest.clear();
if (path.isTriviallyEmpty())
@@ -749,9 +742,9 @@ static std::error_code fillStatus(int StatRet, const struct stat &Status,
perms Perms = static_cast<perms>(Status.st_mode) & all_perms;
Result = file_status(typeForMode(Status.st_mode), Perms, Status.st_dev,
- Status.st_nlink, Status.st_ino,
- Status.st_atime, atime_nsec, Status.st_mtime, mtime_nsec,
- Status.st_uid, Status.st_gid, Status.st_size);
+ Status.st_nlink, Status.st_ino, Status.st_atime,
+ atime_nsec, Status.st_mtime, mtime_nsec, Status.st_uid,
+ Status.st_gid, Status.st_size);
return std::error_code();
}
@@ -775,7 +768,7 @@ unsigned getUmask() {
// Chose arbitary new mask and reset the umask to the old mask.
// umask(2) never fails so ignore the return of the second call.
unsigned Mask = ::umask(0);
- (void) ::umask(Mask);
+ (void)::umask(Mask);
return Mask;
}
@@ -881,9 +874,9 @@ void mapped_file_region::unmapImpl() {
void mapped_file_region::dontNeedImpl() {
assert(Mode == mapped_file_region::readonly);
if (!Mapping)
- return;
+ return;
#if defined(__MVS__) || defined(_AIX)
- // If we don't have madvise, or it isn't beneficial, treat this as a no-op.
+ // If we don't have madvise, or it isn't beneficial, treat this as a no-op.
#elif defined(POSIX_MADV_DONTNEED)
::posix_madvise(Mapping, Size, POSIX_MADV_DONTNEED);
#else
@@ -891,9 +884,7 @@ void mapped_file_region::dontNeedImpl() {
#endif
}
-int mapped_file_region::alignment() {
- return Process::getPageSizeEstimate();
-}
+int mapped_file_region::alignment() { return Process::getPageSizeEstimate(); }
std::error_code detail::directory_iterator_construct(detail::DirIterState &it,
StringRef path,
@@ -918,7 +909,7 @@ std::error_code detail::directory_iterator_destruct(detail::DirIterState &it) {
return std::error_code();
}
-static file_type direntType(dirent* Entry) {
+static file_type direntType(dirent *Entry) {
// Most platforms provide the file type in the dirent: Linux/BSD/Mac.
// The DTTOIF macro lets us reuse our status -> type conversion.
// Note that while glibc provides a macro to see if this is supported,
@@ -1140,7 +1131,7 @@ std::error_code openFileForRead(const Twine &Name, int &ResultFD,
return EC;
// Attempt to get the real name of the file, if the user asked
- if(!RealPath)
+ if (!RealPath)
return std::error_code();
RealPath->clear();
#if defined(F_GETPATH)
@@ -1192,8 +1183,7 @@ Expected<size_t> readNativeFile(file_t FD, MutableArrayRef<char> Buf) {
#else
size_t Size = Buf.size();
#endif
- ssize_t NumRead =
- sys::RetryAfterSignal(-1, ::read, FD, Buf.data(), Size);
+ ssize_t NumRead = sys::RetryAfterSignal(-1, ::read, FD, Buf.data(), Size);
if (ssize_t(NumRead) == -1)
return errorCodeToError(std::error_code(errno, std::generic_category()));
return NumRead;
@@ -1212,8 +1202,7 @@ Expected<size_t> readNativeFileSlice(file_t FD, MutableArrayRef<char> Buf,
#else
if (lseek(FD, Offset, SEEK_SET) == -1)
return errorCodeToError(std::error_code(errno, std::generic_category()));
- ssize_t NumRead =
- sys::RetryAfterSignal(-1, ::read, FD, Buf.data(), Size);
+ ssize_t NumRead = sys::RetryAfterSignal(-1, ::read, FD, Buf.data(), Size);
#endif
if (NumRead == -1)
return errorCodeToError(std::error_code(errno, std::generic_category()));
@@ -1367,11 +1356,10 @@ bool home_directory(SmallVectorImpl<char> &result) {
}
static bool getDarwinConfDir(bool TempDir, SmallVectorImpl<char> &Result) {
- #if defined(_CS_DARWIN_USER_TEMP_DIR) && defined(_CS_DARWIN_USER_CACHE_DIR)
+#if defined(_CS_DARWIN_USER_TEMP_DIR) && defined(_CS_DARWIN_USER_CACHE_DIR)
// On Darwin, use DARWIN_USER_TEMP_DIR or DARWIN_USER_CACHE_DIR.
// macros defined in <unistd.h> on darwin >= 9
- int ConfName = TempDir ? _CS_DARWIN_USER_TEMP_DIR
- : _CS_DARWIN_USER_CACHE_DIR;
+ int ConfName = TempDir ? _CS_DARWIN_USER_TEMP_DIR : _CS_DARWIN_USER_CACHE_DIR;
size_t ConfLen = confstr(ConfName, nullptr, 0);
if (ConfLen > 0) {
do {
@@ -1387,7 +1375,7 @@ static bool getDarwinConfDir(bool TempDir, SmallVectorImpl<char> &Result) {
Result.clear();
}
- #endif
+#endif
return false;
}
@@ -1417,7 +1405,7 @@ bool user_config_directory(SmallVectorImpl<char> &result) {
bool cache_directory(SmallVectorImpl<char> &result) {
#ifdef __APPLE__
- if (getDarwinConfDir(false/*tempDir*/, result)) {
+ if (getDarwinConfDir(false /*tempDir*/, result)) {
return true;
}
#else
@@ -1503,13 +1491,13 @@ std::error_code copy_file(const Twine &From, const Twine &To) {
auto Errno = errno;
switch (Errno) {
- case EEXIST: // To already exists.
- case ENOTSUP: // Device does not support cloning.
- case EXDEV: // From and To are on
diff erent devices.
- break;
- default:
- // Anything else will also break copyfile().
- return std::error_code(Errno, std::generic_category());
+ case EEXIST: // To already exists.
+ case ENOTSUP: // Device does not support cloning.
+ case EXDEV: // From and To are on
diff erent devices.
+ break;
+ default:
+ // Anything else will also break copyfile().
+ return std::error_code(Errno, std::generic_category());
}
// TODO: For EEXIST, profile calling fs::generateUniqueName() and
diff --git a/llvm/lib/Support/Unix/Process.inc b/llvm/lib/Support/Unix/Process.inc
index c1959b5cc2ae5..f19352e1b04ee 100644
--- a/llvm/lib/Support/Unix/Process.inc
+++ b/llvm/lib/Support/Unix/Process.inc
@@ -40,10 +40,10 @@
#include <malloc/malloc.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
-# include <sys/ioctl.h>
+#include <sys/ioctl.h>
#endif
#ifdef HAVE_TERMIOS_H
-# include <termios.h>
+#include <termios.h>
#endif
//===----------------------------------------------------------------------===//
@@ -54,14 +54,15 @@
using namespace llvm;
using namespace sys;
-static std::pair<std::chrono::microseconds, std::chrono::microseconds> getRUsageTimes() {
+static std::pair<std::chrono::microseconds, std::chrono::microseconds>
+getRUsageTimes() {
#if defined(HAVE_GETRUSAGE)
struct rusage RU;
::getrusage(RUSAGE_SELF, &RU);
- return { toDuration(RU.ru_utime), toDuration(RU.ru_stime) };
+ return {toDuration(RU.ru_utime), toDuration(RU.ru_stime)};
#else
#warning Cannot get usage times on this platform
- return { std::chrono::microseconds::zero(), std::chrono::microseconds::zero() };
+ return {std::chrono::microseconds::zero(), std::chrono::microseconds::zero()};
#endif
}
@@ -99,7 +100,7 @@ size_t Process::GetMallocUsage() {
#elif defined(HAVE_MALLOC_ZONE_STATISTICS) && defined(HAVE_MALLOC_MALLOC_H)
malloc_statistics_t Stats;
malloc_zone_statistics(malloc_default_zone(), &Stats);
- return Stats.size_in_use; // darwin
+ return Stats.size_in_use; // darwin
#elif defined(HAVE_MALLCTL)
size_t alloc, sz;
sz = sizeof(size_t);
@@ -109,9 +110,9 @@ size_t Process::GetMallocUsage() {
#elif defined(HAVE_SBRK)
// Note this is only an approximation and more closely resembles
// the value returned by mallinfo in the arena field.
- static char *StartOfMemory = reinterpret_cast<char*>(::sbrk(0));
- char *EndOfMemory = (char*)sbrk(0);
- if (EndOfMemory != ((char*)-1) && StartOfMemory != ((char*)-1))
+ static char *StartOfMemory = reinterpret_cast<char *>(::sbrk(0));
+ char *EndOfMemory = (char *)sbrk(0);
+ if (EndOfMemory != ((char *)-1) && StartOfMemory != ((char *)-1))
return EndOfMemory - StartOfMemory;
return 0;
#else
@@ -120,7 +121,8 @@ size_t Process::GetMallocUsage() {
#endif
}
-void Process::GetTimeUsage(TimePoint<> &elapsed, std::chrono::nanoseconds &user_time,
+void Process::GetTimeUsage(TimePoint<> &elapsed,
+ std::chrono::nanoseconds &user_time,
std::chrono::nanoseconds &sys_time) {
elapsed = std::chrono::system_clock::now();
std::tie(user_time, sys_time) = getRUsageTimes();
@@ -149,10 +151,9 @@ void Process::PreventCoreFiles() {
exception_port_t OriginalPorts[EXC_TYPES_COUNT];
exception_behavior_t OriginalBehaviors[EXC_TYPES_COUNT];
thread_state_flavor_t OriginalFlavors[EXC_TYPES_COUNT];
- kern_return_t err =
- task_get_exception_ports(mach_task_self(), EXC_MASK_ALL, OriginalMasks,
- &Count, OriginalPorts, OriginalBehaviors,
- OriginalFlavors);
+ kern_return_t err = task_get_exception_ports(
+ mach_task_self(), EXC_MASK_ALL, OriginalMasks, &Count, OriginalPorts,
+ OriginalBehaviors, OriginalFlavors);
if (err == KERN_SUCCESS) {
// replace each with MACH_PORT_NULL.
for (unsigned i = 0; i != Count; ++i)
@@ -163,10 +164,10 @@ void Process::PreventCoreFiles() {
// Disable crash reporting on Mac OS X 10.5
signal(SIGABRT, _exit);
- signal(SIGILL, _exit);
- signal(SIGFPE, _exit);
+ signal(SIGILL, _exit);
+ signal(SIGFPE, _exit);
signal(SIGSEGV, _exit);
- signal(SIGBUS, _exit);
+ signal(SIGBUS, _exit);
#endif
coreFilesPrevented = true;
@@ -197,7 +198,7 @@ private:
int &FD;
bool KeepOpen;
};
-}
+} // namespace
std::error_code Process::FixupStandardFileDescriptors() {
int NullFD = -1;
@@ -239,7 +240,7 @@ std::error_code Process::SafelyCloseFileDescriptor(int FD) {
if (sigfillset(&FullSet) < 0 || sigfillset(&SavedSet) < 0)
return std::error_code(errno, std::generic_category());
- // Atomically swap our current signal mask with a full mask.
+ // Atomically swap our current signal mask with a full mask.
#if LLVM_ENABLE_THREADS
if (int EC = pthread_sigmask(SIG_SETMASK, &FullSet, &SavedSet))
return std::error_code(EC, std::generic_category());
@@ -329,15 +330,15 @@ extern "C" int tigetnum(char *capname);
bool checkTerminalEnvironmentForColors() {
if (const char *TermStr = std::getenv("TERM")) {
return StringSwitch<bool>(TermStr)
- .Case("ansi", true)
- .Case("cygwin", true)
- .Case("linux", true)
- .StartsWith("screen", true)
- .StartsWith("xterm", true)
- .StartsWith("vt100", true)
- .StartsWith("rxvt", true)
- .EndsWith("color", true)
- .Default(false);
+ .Case("ansi", true)
+ .Case("cygwin", true)
+ .Case("linux", true)
+ .StartsWith("screen", true)
+ .StartsWith("xterm", true)
+ .StartsWith("vt100", true)
+ .StartsWith("rxvt", true)
+ .EndsWith("color", true)
+ .Default(false);
}
return false;
@@ -370,7 +371,8 @@ static bool terminalHasColors(int fd) {
// The 'tigetnum' routine returns -2 or -1 on errors, and might return 0 if
// the terminfo says that no colors are supported.
int colors_ti = tigetnum(const_cast<char *>("colors"));
- bool HasColors = colors_ti >= 0 ? colors_ti : checkTerminalEnvironmentForColors();
+ bool HasColors =
+ colors_ti >= 0 ? colors_ti : checkTerminalEnvironmentForColors();
// Now extract the structure allocated by setupterm and free its memory
// through a really silly dance.
@@ -410,20 +412,14 @@ bool Process::ColorNeedsFlush() {
}
const char *Process::OutputColor(char code, bool bold, bool bg) {
- return colorcodes[bg?1:0][bold?1:0][code&7];
+ return colorcodes[bg ? 1 : 0][bold ? 1 : 0][code & 7];
}
-const char *Process::OutputBold(bool bg) {
- return "\033[1m";
-}
+const char *Process::OutputBold(bool bg) { return "\033[1m"; }
-const char *Process::OutputReverse() {
- return "\033[7m";
-}
+const char *Process::OutputReverse() { return "\033[7m"; }
-const char *Process::ResetColor() {
- return "\033[0m";
-}
+const char *Process::ResetColor() { return "\033[0m"; }
#if !HAVE_DECL_ARC4RANDOM
static unsigned GetRandomNumberSeed() {
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
index 089342030b97e..eaa0e2a1f7317 100644
--- a/llvm/lib/Support/Unix/Program.inc
+++ b/llvm/lib/Support/Unix/Program.inc
@@ -1,4 +1,5 @@
-//===- llvm/Support/Unix/Program.cpp -----------------------------*- C++ -*-===//
+//===- llvm/Support/Unix/Program.cpp -----------------------------*- C++
+//-*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -55,7 +56,7 @@
#endif
#if !USE_NSGETENVIRON
- extern char **environ;
+extern char **environ;
#else
#include <crt_externs.h> // _NSGetEnviron
#endif
@@ -89,12 +90,12 @@ ErrorOr<std::string> sys::findProgramByName(StringRef Name,
SmallString<128> FilePath(Path);
sys::path::append(FilePath, Name);
if (sys::fs::can_execute(FilePath.c_str()))
- return std::string(FilePath.str()); // Found the executable!
+ return std::string(FilePath.str()); // Found the executable!
}
return errc::no_such_file_or_directory;
}
-static bool RedirectIO(Optional<StringRef> Path, int FD, std::string* ErrMsg) {
+static bool RedirectIO(Optional<StringRef> Path, int FD, std::string *ErrMsg) {
if (!Path) // Noop
return false;
std::string File;
@@ -105,10 +106,10 @@ static bool RedirectIO(Optional<StringRef> Path, int FD, std::string* ErrMsg) {
File = std::string(*Path);
// Open the file
- int InFD = open(File.c_str(), FD == 0 ? O_RDONLY : O_WRONLY|O_CREAT, 0666);
+ int InFD = open(File.c_str(), FD == 0 ? O_RDONLY : O_WRONLY | O_CREAT, 0666);
if (InFD == -1) {
- MakeErrMsg(ErrMsg, "Cannot open file '" + File + "' for "
- + (FD == 0 ? "input" : "output"));
+ MakeErrMsg(ErrMsg, "Cannot open file '" + File + "' for " +
+ (FD == 0 ? "input" : "output"));
return true;
}
@@ -118,7 +119,7 @@ static bool RedirectIO(Optional<StringRef> Path, int FD, std::string* ErrMsg) {
close(InFD);
return true;
}
- close(InFD); // Close the original FD
+ close(InFD); // Close the original FD
return false;
}
@@ -135,30 +136,28 @@ static bool RedirectIO_PS(const std::string *Path, int FD, std::string *ErrMsg,
File = Path->c_str();
if (int Err = posix_spawn_file_actions_addopen(
- FileActions, FD, File,
- FD == 0 ? O_RDONLY : O_WRONLY | O_CREAT, 0666))
+ FileActions, FD, File, FD == 0 ? O_RDONLY : O_WRONLY | O_CREAT, 0666))
return MakeErrMsg(ErrMsg, "Cannot posix_spawn_file_actions_addopen", Err);
return false;
}
#endif
-static void TimeOutHandler(int Sig) {
-}
+static void TimeOutHandler(int Sig) {}
static void SetMemoryLimits(unsigned size) {
#if HAVE_SYS_RESOURCE_H && HAVE_GETRLIMIT && HAVE_SETRLIMIT
struct rlimit r;
- __typeof__ (r.rlim_cur) limit = (__typeof__ (r.rlim_cur)) (size) * 1048576;
+ __typeof__(r.rlim_cur) limit = (__typeof__(r.rlim_cur))(size)*1048576;
// Heap size
- getrlimit (RLIMIT_DATA, &r);
+ getrlimit(RLIMIT_DATA, &r);
r.rlim_cur = limit;
- setrlimit (RLIMIT_DATA, &r);
+ setrlimit(RLIMIT_DATA, &r);
#ifdef RLIMIT_RSS
// Resident set size.
- getrlimit (RLIMIT_RSS, &r);
+ getrlimit(RLIMIT_RSS, &r);
r.rlim_cur = limit;
- setrlimit (RLIMIT_RSS, &r);
+ setrlimit(RLIMIT_RSS, &r);
#endif
#endif
}
@@ -263,7 +262,7 @@ static bool Execute(ProcessInfo &PI, StringRef Program,
posix_spawn_file_actions_destroy(FileActions);
if (Err)
- return !MakeErrMsg(ErrMsg, "posix_spawn failed", Err);
+ return !MakeErrMsg(ErrMsg, "posix_spawn failed", Err);
PI.Pid = PID;
PI.Process = PID;
@@ -275,56 +274,62 @@ static bool Execute(ProcessInfo &PI, StringRef Program,
// Create a child process.
int child = fork();
switch (child) {
- // An error occurred: Return to the caller.
- case -1:
- MakeErrMsg(ErrMsg, "Couldn't fork");
- return false;
+ // An error occurred: Return to the caller.
+ case -1:
+ MakeErrMsg(ErrMsg, "Couldn't fork");
+ return false;
- // Child process: Execute the program.
- case 0: {
- // Redirect file descriptors...
- if (!Redirects.empty()) {
- // Redirect stdin
- if (RedirectIO(Redirects[0], 0, ErrMsg)) { return false; }
- // Redirect stdout
- if (RedirectIO(Redirects[1], 1, ErrMsg)) { return false; }
- if (Redirects[1] && Redirects[2] && *Redirects[1] == *Redirects[2]) {
- // If stdout and stderr should go to the same place, redirect stderr
- // to the FD already open for stdout.
- if (-1 == dup2(1,2)) {
- MakeErrMsg(ErrMsg, "Can't redirect stderr to stdout");
- return false;
- }
- } else {
- // Just redirect stderr
- if (RedirectIO(Redirects[2], 2, ErrMsg)) { return false; }
- }
+ // Child process: Execute the program.
+ case 0: {
+ // Redirect file descriptors...
+ if (!Redirects.empty()) {
+ // Redirect stdin
+ if (RedirectIO(Redirects[0], 0, ErrMsg)) {
+ return false;
}
-
- // Set memory limits
- if (MemoryLimit!=0) {
- SetMemoryLimits(MemoryLimit);
+ // Redirect stdout
+ if (RedirectIO(Redirects[1], 1, ErrMsg)) {
+ return false;
+ }
+ if (Redirects[1] && Redirects[2] && *Redirects[1] == *Redirects[2]) {
+ // If stdout and stderr should go to the same place, redirect stderr
+ // to the FD already open for stdout.
+ if (-1 == dup2(1, 2)) {
+ MakeErrMsg(ErrMsg, "Can't redirect stderr to stdout");
+ return false;
+ }
+ } else {
+ // Just redirect stderr
+ if (RedirectIO(Redirects[2], 2, ErrMsg)) {
+ return false;
+ }
}
+ }
- // Execute!
- std::string PathStr = std::string(Program);
- if (Envp != nullptr)
- execve(PathStr.c_str(), const_cast<char **>(Argv),
- const_cast<char **>(Envp));
- else
- execv(PathStr.c_str(), const_cast<char **>(Argv));
- // If the execve() failed, we should exit. Follow Unix protocol and
- // return 127 if the executable was not found, and 126 otherwise.
- // Use _exit rather than exit so that atexit functions and static
- // object destructors cloned from the parent process aren't
- // redundantly run, and so that any data buffered in stdio buffers
- // cloned from the parent aren't redundantly written out.
- _exit(errno == ENOENT ? 127 : 126);
+ // Set memory limits
+ if (MemoryLimit != 0) {
+ SetMemoryLimits(MemoryLimit);
}
- // Parent process: Break out of the switch to do our processing.
- default:
- break;
+ // Execute!
+ std::string PathStr = std::string(Program);
+ if (Envp != nullptr)
+ execve(PathStr.c_str(), const_cast<char **>(Argv),
+ const_cast<char **>(Envp));
+ else
+ execv(PathStr.c_str(), const_cast<char **>(Argv));
+ // If the execve() failed, we should exit. Follow Unix protocol and
+ // return 127 if the executable was not found, and 126 otherwise.
+ // Use _exit rather than exit so that atexit functions and static
+ // object destructors cloned from the parent process aren't
+ // redundantly run, and so that any data buffered in stdio buffers
+ // cloned from the parent aren't redundantly written out.
+ _exit(errno == ENOENT ? 127 : 126);
+ }
+
+ // Parent process: Break out of the switch to do our processing.
+ default:
+ break;
}
PI.Pid = child;
@@ -339,7 +344,7 @@ namespace sys {
#ifndef _AIX
using ::wait4;
#else
-static pid_t (wait4)(pid_t pid, int *status, int options, struct rusage *usage);
+static pid_t(wait4)(pid_t pid, int *status, int options, struct rusage *usage);
#endif
} // namespace sys
@@ -347,11 +352,11 @@ static pid_t (wait4)(pid_t pid, int *status, int options, struct rusage *usage);
#ifdef _AIX
#ifndef _ALL_SOURCE
-extern "C" pid_t (wait4)(pid_t pid, int *status, int options,
- struct rusage *usage);
+extern "C" pid_t(wait4)(pid_t pid, int *status, int options,
+ struct rusage *usage);
#endif
-pid_t (llvm::sys::wait4)(pid_t pid, int *status, int options,
- struct rusage *usage) {
+pid_t(llvm::sys::wait4)(pid_t pid, int *status, int options,
+ struct rusage *usage) {
assert(pid > 0 && "Only expecting to handle actual PID values!");
assert((options & ~WNOHANG) == 0 && "Expecting WNOHANG at most!");
assert(usage && "Expecting usage collection!");
@@ -494,13 +499,13 @@ ProcessInfo llvm::sys::Wait(const ProcessInfo &PI, unsigned SecondsToWait,
return WaitResult;
}
-std::error_code llvm::sys::ChangeStdinMode(fs::OpenFlags Flags){
+std::error_code llvm::sys::ChangeStdinMode(fs::OpenFlags Flags) {
if (!(Flags & fs::OF_Text))
return ChangeStdinToBinary();
return std::error_code();
}
-std::error_code llvm::sys::ChangeStdoutMode(fs::OpenFlags Flags){
+std::error_code llvm::sys::ChangeStdoutMode(fs::OpenFlags Flags) {
if (!(Flags & fs::OF_Text))
return ChangeStdoutToBinary();
return std::error_code();
@@ -520,7 +525,8 @@ std::error_code
llvm::sys::writeFileWithEncoding(StringRef FileName, StringRef Contents,
WindowsEncodingMethod Encoding /*unused*/) {
std::error_code EC;
- llvm::raw_fd_ostream OS(FileName, EC, llvm::sys::fs::OpenFlags::OF_TextWithCRLF);
+ llvm::raw_fd_ostream OS(FileName, EC,
+ llvm::sys::fs::OpenFlags::OF_TextWithCRLF);
if (EC)
return EC;
diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc
index b07d3190efcda..254ca0d7e03d4 100644
--- a/llvm/lib/Support/Unix/Signals.inc
+++ b/llvm/lib/Support/Unix/Signals.inc
@@ -48,7 +48,7 @@
#include <algorithm>
#include <string>
#ifdef HAVE_BACKTRACE
-# include BACKTRACE_HEADER // For backtrace().
+#include BACKTRACE_HEADER // For backtrace().
#endif
#if HAVE_SIGNAL_H
#include <signal.h>
@@ -79,8 +79,8 @@
using namespace llvm;
-static void SignalHandler(int Sig); // defined below.
-static void InfoSignalHandler(int Sig); // defined below.
+static void SignalHandler(int Sig); // defined below.
+static void InfoSignalHandler(int Sig); // defined below.
using SignalHandlerFunctionType = void (*)();
/// The function to call if ctrl-c is pressed.
@@ -208,40 +208,45 @@ static StringRef Argv0;
/// Signals that represent requested termination. There's no bug or failure, or
/// if there is, it's not our direct responsibility. For whatever reason, our
/// continued execution is no longer desirable.
-static const int IntSigs[] = {
- SIGHUP, SIGINT, SIGTERM, SIGUSR2
-};
+static const int IntSigs[] = {SIGHUP, SIGINT, SIGTERM, SIGUSR2};
/// Signals that represent that we have a bug, and our prompt termination has
/// been ordered.
-static const int KillSigs[] = {
- SIGILL, SIGTRAP, SIGABRT, SIGFPE, SIGBUS, SIGSEGV, SIGQUIT
+static const int KillSigs[] = {SIGILL,
+ SIGTRAP,
+ SIGABRT,
+ SIGFPE,
+ SIGBUS,
+ SIGSEGV,
+ SIGQUIT
#ifdef SIGSYS
- , SIGSYS
+ ,
+ SIGSYS
#endif
#ifdef SIGXCPU
- , SIGXCPU
+ ,
+ SIGXCPU
#endif
#ifdef SIGXFSZ
- , SIGXFSZ
+ ,
+ SIGXFSZ
#endif
#ifdef SIGEMT
- , SIGEMT
+ ,
+ SIGEMT
#endif
};
/// Signals that represent requests for status.
-static const int InfoSigs[] = {
- SIGUSR1
+static const int InfoSigs[] = {SIGUSR1
#ifdef SIGINFO
- , SIGINFO
+ ,
+ SIGINFO
#endif
};
-static const size_t NumSigs =
- std::size(IntSigs) + std::size(KillSigs) +
- std::size(InfoSigs) + 1 /* SIGPIPE */;
-
+static const size_t NumSigs = std::size(IntSigs) + std::size(KillSigs) +
+ std::size(InfoSigs) + 1 /* SIGPIPE */;
static std::atomic<unsigned> NumRegisteredSignals = ATOMIC_VAR_INIT(0);
static struct {
@@ -334,8 +339,8 @@ static void RegisterHandlers() { // Not signal-safe.
void sys::unregisterHandlers() {
// Restore all of the signal handlers to how they were before we showed up.
for (unsigned i = 0, e = NumRegisteredSignals.load(); i != e; ++i) {
- sigaction(RegisteredSignalInfo[i].SigNo,
- &RegisteredSignalInfo[i].SA, nullptr);
+ sigaction(RegisteredSignalInfo[i].SigNo, &RegisteredSignalInfo[i].SA,
+ nullptr);
--NumRegisteredSignals;
}
}
@@ -412,9 +417,7 @@ static void InfoSignalHandler(int Sig) {
CurrentInfoFunction();
}
-void llvm::sys::RunInterruptHandlers() {
- RemoveFilesToRemove();
-}
+void llvm::sys::RunInterruptHandlers() { RemoveFilesToRemove(); }
void llvm::sys::SetInterruptFunction(void (*IF)()) {
InterruptFunction.exchange(IF);
@@ -437,8 +440,7 @@ void llvm::sys::DefaultOneShotPipeSignalHandler() {
}
// The public API
-bool llvm::sys::RemoveFileOnSignal(StringRef Filename,
- std::string* ErrMsg) {
+bool llvm::sys::RemoveFileOnSignal(StringRef Filename, std::string *ErrMsg) {
// Ensure that cleanup will occur as soon as one file is added.
static ManagedStatic<FilesToRemoveCleanup> FilesToRemoveCleanup;
*FilesToRemoveCleanup;
@@ -461,7 +463,7 @@ void llvm::sys::AddSignalHandler(sys::SignalHandlerCallback FnPtr,
RegisterHandlers();
}
-#if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES && HAVE_LINK_H && \
+#if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES && HAVE_LINK_H && \
(defined(__linux__) || defined(__FreeBSD__) || \
defined(__FreeBSD_kernel__) || defined(__NetBSD__))
struct DlIteratePhdrData {
@@ -474,7 +476,7 @@ struct DlIteratePhdrData {
};
static int dl_iterate_phdr_cb(dl_phdr_info *info, size_t size, void *arg) {
- DlIteratePhdrData *data = (DlIteratePhdrData*)arg;
+ DlIteratePhdrData *data = (DlIteratePhdrData *)arg;
const char *name = data->first ? data->main_exec_name : info->dlpi_name;
data->first = false;
for (int i = 0; i < info->dlpi_phnum; i++) {
@@ -567,8 +569,8 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) {
#if defined(HAVE__UNWIND_BACKTRACE)
// Try _Unwind_Backtrace() if backtrace() failed.
if (!depth)
- depth = unwindBacktrace(StackTrace,
- static_cast<int>(std::size(StackTrace)));
+ depth =
+ unwindBacktrace(StackTrace, static_cast<int>(std::size(StackTrace)));
#endif
if (!depth)
return;
@@ -586,13 +588,16 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) {
for (int i = 0; i < depth; ++i) {
Dl_info dlinfo;
dladdr(StackTrace[i], &dlinfo);
- const char* name = strrchr(dlinfo.dli_fname, '/');
+ const char *name = strrchr(dlinfo.dli_fname, '/');
int nwidth;
- if (!name) nwidth = strlen(dlinfo.dli_fname);
- else nwidth = strlen(name) - 1;
+ if (!name)
+ nwidth = strlen(dlinfo.dli_fname);
+ else
+ nwidth = strlen(name) - 1;
- if (nwidth > width) width = nwidth;
+ if (nwidth > width)
+ width = nwidth;
}
for (int i = 0; i < depth; ++i) {
@@ -601,23 +606,27 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) {
OS << format("%-2d", i);
- const char* name = strrchr(dlinfo.dli_fname, '/');
- if (!name) OS << format(" %-*s", width, dlinfo.dli_fname);
- else OS << format(" %-*s", width, name+1);
+ const char *name = strrchr(dlinfo.dli_fname, '/');
+ if (!name)
+ OS << format(" %-*s", width, dlinfo.dli_fname);
+ else
+ OS << format(" %-*s", width, name + 1);
- OS << format(" %#0*lx", (int)(sizeof(void*) * 2) + 2,
+ OS << format(" %#0*lx", (int)(sizeof(void *) * 2) + 2,
(unsigned long)StackTrace[i]);
if (dlinfo.dli_sname != nullptr) {
OS << ' ';
int res;
- char* d = itaniumDemangle(dlinfo.dli_sname, nullptr, nullptr, &res);
- if (!d) OS << dlinfo.dli_sname;
- else OS << d;
+ char *d = itaniumDemangle(dlinfo.dli_sname, nullptr, nullptr, &res);
+ if (!d)
+ OS << dlinfo.dli_sname;
+ else
+ OS << d;
free(d);
- OS << format(" + %tu", (static_cast<const char*>(StackTrace[i])-
- static_cast<const char*>(dlinfo.dli_saddr)));
+ OS << format(" + %tu", (static_cast<const char *>(StackTrace[i]) -
+ static_cast<const char *>(dlinfo.dli_saddr)));
}
OS << '\n';
}
@@ -648,11 +657,9 @@ void llvm::sys::PrintStackTraceOnErrorSignal(StringRef Argv0,
exception_mask_t mask = EXC_MASK_CRASH;
- kern_return_t ret = task_set_exception_ports(self,
- mask,
- MACH_PORT_NULL,
- EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES,
- THREAD_STATE_NONE);
+ kern_return_t ret = task_set_exception_ports(
+ self, mask, MACH_PORT_NULL,
+ EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, THREAD_STATE_NONE);
(void)ret;
}
#endif
diff --git a/llvm/lib/Support/Unix/ThreadLocal.inc b/llvm/lib/Support/Unix/ThreadLocal.inc
index 0a958a2b952f7..483c5b0d324e1 100644
--- a/llvm/lib/Support/Unix/ThreadLocal.inc
+++ b/llvm/lib/Support/Unix/ThreadLocal.inc
@@ -1,4 +1,5 @@
-//=== llvm/Support/Unix/ThreadLocal.inc - Unix Thread Local Data -*- C++ -*-===//
+//=== llvm/Support/Unix/ThreadLocal.inc - Unix Thread Local Data -*- C++
+//-*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -26,33 +27,31 @@ using namespace sys;
ThreadLocalImpl::ThreadLocalImpl() : data() {
static_assert(sizeof(pthread_key_t) <= sizeof(data), "size too big");
- pthread_key_t* key = reinterpret_cast<pthread_key_t*>(&data);
+ pthread_key_t *key = reinterpret_cast<pthread_key_t *>(&data);
int errorcode = pthread_key_create(key, nullptr);
assert(errorcode == 0);
- (void) errorcode;
+ (void)errorcode;
}
ThreadLocalImpl::~ThreadLocalImpl() {
- pthread_key_t* key = reinterpret_cast<pthread_key_t*>(&data);
+ pthread_key_t *key = reinterpret_cast<pthread_key_t *>(&data);
int errorcode = pthread_key_delete(*key);
assert(errorcode == 0);
- (void) errorcode;
+ (void)errorcode;
}
-void ThreadLocalImpl::setInstance(const void* d) {
- pthread_key_t* key = reinterpret_cast<pthread_key_t*>(&data);
+void ThreadLocalImpl::setInstance(const void *d) {
+ pthread_key_t *key = reinterpret_cast<pthread_key_t *>(&data);
int errorcode = pthread_setspecific(*key, d);
assert(errorcode == 0);
- (void) errorcode;
+ (void)errorcode;
}
void *ThreadLocalImpl::getInstance() {
- pthread_key_t* key = reinterpret_cast<pthread_key_t*>(&data);
+ pthread_key_t *key = reinterpret_cast<pthread_key_t *>(&data);
return pthread_getspecific(*key);
}
-void ThreadLocalImpl::removeInstance() {
- setInstance(nullptr);
-}
+void ThreadLocalImpl::removeInstance() { setInstance(nullptr); }
-}
+} // namespace llvm
diff --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc
index 6a67401500317..037470cadb472 100644
--- a/llvm/lib/Support/Unix/Threading.inc
+++ b/llvm/lib/Support/Unix/Threading.inc
@@ -98,13 +98,9 @@ void llvm_thread_join_impl(pthread_t Thread) {
}
}
-pthread_t llvm_thread_get_id_impl(pthread_t Thread) {
- return Thread;
-}
+pthread_t llvm_thread_get_id_impl(pthread_t Thread) { return Thread; }
-pthread_t llvm_thread_get_current_id_impl() {
- return ::pthread_self();
-}
+pthread_t llvm_thread_get_current_id_impl() { return ::pthread_self(); }
} // namespace llvm
@@ -131,7 +127,6 @@ uint64_t llvm::get_threadid() {
#endif
}
-
static constexpr uint32_t get_max_thread_name_length_impl() {
#if defined(__NetBSD__)
return PTHREAD_MAX_NAMELEN_NP;
@@ -180,7 +175,7 @@ void llvm::set_thread_name(const Twine &Name) {
::pthread_set_name_np(::pthread_self(), NameStr.data());
#elif defined(__NetBSD__)
::pthread_setname_np(::pthread_self(), "%s",
- const_cast<char *>(NameStr.data()));
+ const_cast<char *>(NameStr.data()));
#elif defined(__APPLE__)
::pthread_setname_np(NameStr.data());
#endif
@@ -196,8 +191,8 @@ void llvm::get_thread_name(SmallVectorImpl<char> &Name) {
struct kinfo_proc *kp = nullptr, *nkp;
size_t len = 0;
int error;
- int ctl[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID | KERN_PROC_INC_THREAD,
- (int)pid };
+ int ctl[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID | KERN_PROC_INC_THREAD,
+ (int)pid};
while (1) {
error = sysctl(ctl, 4, kp, &len, nullptr, 0);
@@ -240,7 +235,7 @@ void llvm::get_thread_name(SmallVectorImpl<char> &Name) {
#elif defined(__linux__)
#if HAVE_PTHREAD_GETNAME_NP
constexpr uint32_t len = get_max_thread_name_length_impl();
- char Buffer[len] = {'\0'}; // FIXME: working around MSan false positive.
+ char Buffer[len] = {'\0'}; // FIXME: working around MSan false positive.
if (0 == ::pthread_getname_np(::pthread_self(), Buffer, len))
Name.append(Buffer, Buffer + strlen(Buffer));
#endif
@@ -267,18 +262,22 @@ SetThreadPriorityResult llvm::set_thread_priority(ThreadPriority Priority) {
#elif defined(__APPLE__)
// https://developer.apple.com/documentation/apple-silicon/tuning-your-code-s-performance-for-apple-silicon
//
- // Background - Applies to work that isn’t visible to the user and may take significant
- // time to complete. Examples include indexing, backing up, or synchronizing data. This
- // class emphasizes energy efficiency.
+ // Background - Applies to work that isn’t visible to the user and may take
+ // significant time to complete. Examples include indexing, backing up, or
+ // synchronizing data. This class emphasizes energy efficiency.
//
- // Utility - Applies to work that takes anywhere from a few seconds to a few minutes to
- // complete. Examples include downloading a document or importing data. This class
- // offers a balance between responsiveness, performance, and energy efficiency.
- const auto qosClass = [&](){
+ // Utility - Applies to work that takes anywhere from a few seconds to a few
+ // minutes to complete. Examples include downloading a document or importing
+ // data. This class offers a balance between responsiveness, performance, and
+ // energy efficiency.
+ const auto qosClass = [&]() {
switch (Priority) {
- case ThreadPriority::Background: return QOS_CLASS_BACKGROUND;
- case ThreadPriority::Low: return QOS_CLASS_UTILITY;
- case ThreadPriority::Default: return QOS_CLASS_DEFAULT;
+ case ThreadPriority::Background:
+ return QOS_CLASS_BACKGROUND;
+ case ThreadPriority::Low:
+ return QOS_CLASS_UTILITY;
+ case ThreadPriority::Default:
+ return QOS_CLASS_DEFAULT;
}
}();
return !pthread_set_qos_class_self_np(qosClass, 0)
diff --git a/llvm/lib/Support/Unix/Watchdog.inc b/llvm/lib/Support/Unix/Watchdog.inc
index b363ef7795603..b33e52d88500d 100644
--- a/llvm/lib/Support/Unix/Watchdog.inc
+++ b/llvm/lib/Support/Unix/Watchdog.inc
@@ -17,17 +17,17 @@
#endif
namespace llvm {
- namespace sys {
- Watchdog::Watchdog(unsigned int seconds) {
+namespace sys {
+Watchdog::Watchdog(unsigned int seconds) {
#ifdef HAVE_UNISTD_H
- alarm(seconds);
+ alarm(seconds);
#endif
- }
+}
- Watchdog::~Watchdog() {
+Watchdog::~Watchdog() {
#ifdef HAVE_UNISTD_H
- alarm(0);
+ alarm(0);
#endif
- }
- }
}
+} // namespace sys
+} // namespace llvm
diff --git a/llvm/lib/Support/Windows/COM.inc b/llvm/lib/Support/Windows/COM.inc
index 002182bc39394..d628e5db79026 100644
--- a/llvm/lib/Support/Windows/COM.inc
+++ b/llvm/lib/Support/Windows/COM.inc
@@ -32,5 +32,5 @@ InitializeCOMRAII::InitializeCOMRAII(COMThreadingMode Threading,
}
InitializeCOMRAII::~InitializeCOMRAII() { ::CoUninitialize(); }
-}
-}
+} // namespace sys
+} // namespace llvm
diff --git a/llvm/lib/Support/Windows/DynamicLibrary.inc b/llvm/lib/Support/Windows/DynamicLibrary.inc
index 302fdcf537edc..c434bd62f04c5 100644
--- a/llvm/lib/Support/Windows/DynamicLibrary.inc
+++ b/llvm/lib/Support/Windows/DynamicLibrary.inc
@@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/Support/Windows/WindowsSupport.h"
#include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/Windows/WindowsSupport.h"
#include "llvm/Support/raw_ostream.h"
#include <psapi.h>
@@ -21,13 +21,12 @@
//=== and must not be UNIX code.
//===----------------------------------------------------------------------===//
-
DynamicLibrary::HandleSet::~HandleSet() {
for (void *Handle : llvm::reverse(Handles))
FreeLibrary(HMODULE(Handle));
// 'Process' should not be released on Windows.
- assert((!Process || Process==this) && "Bad Handle");
+ assert((!Process || Process == this) && "Bad Handle");
// llvm_shutdown called, Return to default
DynamicLibrary::SearchOrder = DynamicLibrary::SO_Linker;
}
@@ -51,7 +50,7 @@ void *DynamicLibrary::HandleSet::DLOpen(const char *File, std::string *Err) {
return &DynamicLibrary::Invalid;
}
- return reinterpret_cast<void*>(Handle);
+ return reinterpret_cast<void *>(Handle);
}
static DynamicLibrary::HandleSet *IsOpenedHandlesInstance(void *Handle) {
@@ -60,7 +59,7 @@ static DynamicLibrary::HandleSet *IsOpenedHandlesInstance(void *Handle) {
}
void DynamicLibrary::HandleSet::DLClose(void *Handle) {
- if (HandleSet* HS = IsOpenedHandlesInstance(Handle))
+ if (HandleSet *HS = IsOpenedHandlesInstance(Handle))
HS->Process = nullptr; // Just drop the *Process* handle.
else
FreeLibrary((HMODULE)Handle);
@@ -75,7 +74,7 @@ static bool GetProcessModules(HANDLE H, DWORD &Bytes, HMODULE *Data = nullptr) {
#else
!EnumProcessModules(H, Data, Bytes, &Bytes)
#endif
- ) {
+ ) {
std::string Err;
if (MakeErrMsg(&Err, "EnumProcessModules failure"))
llvm::errs() << Err << "\n";
@@ -85,7 +84,7 @@ static bool GetProcessModules(HANDLE H, DWORD &Bytes, HMODULE *Data = nullptr) {
}
void *DynamicLibrary::HandleSet::DLSym(void *Handle, const char *Symbol) {
- HandleSet* HS = IsOpenedHandlesInstance(Handle);
+ HandleSet *HS = IsOpenedHandlesInstance(Handle);
if (!HS)
return (void *)uintptr_t(GetProcAddress((HMODULE)Handle, Symbol));
@@ -128,7 +127,7 @@ void *DynamicLibrary::HandleSet::DLSym(void *Handle, const char *Symbol) {
// Try EXE first, mirroring what dlsym(dlopen(NULL)) does.
if (FARPROC Ptr = GetProcAddress(HMODULE(Handles.front()), Symbol))
- return (void *) uintptr_t(Ptr);
+ return (void *)uintptr_t(Ptr);
if (Handles.size() > 1) {
// This is
diff erent behaviour than what Posix dlsym(dlopen(NULL)) does.
@@ -137,19 +136,20 @@ void *DynamicLibrary::HandleSet::DLSym(void *Handle, const char *Symbol) {
// symbols from ucrt.dll first, but iterating NOT in reverse here would
// mean that the msvc.dll versions would be returned.
- for (auto I = Handles.rbegin(), E = Handles.rend()-1; I != E; ++I) {
+ for (auto I = Handles.rbegin(), E = Handles.rend() - 1; I != E; ++I) {
if (FARPROC Ptr = GetProcAddress(HMODULE(*I), Symbol))
- return (void *) uintptr_t(Ptr);
+ return (void *)uintptr_t(Ptr);
}
}
return nullptr;
}
-
// Stack probing routines are in the support library (e.g. libgcc), but we don't
// have dynamic linking on windows. Provide a hook.
-#define EXPLICIT_SYMBOL(SYM) \
- extern "C" { extern void *SYM; }
+#define EXPLICIT_SYMBOL(SYM) \
+ extern "C" { \
+ extern void *SYM; \
+ }
#define EXPLICIT_SYMBOL2(SYMFROM, SYMTO) EXPLICIT_SYMBOL(SYMTO)
#ifdef _M_IX86
diff --git a/llvm/lib/Support/Windows/Host.inc b/llvm/lib/Support/Windows/Host.inc
index fa6b00f19b9a0..63c3b8b586b75 100644
--- a/llvm/lib/Support/Windows/Host.inc
+++ b/llvm/lib/Support/Windows/Host.inc
@@ -19,14 +19,13 @@
using namespace llvm;
-static std::string updateTripleOSVersion(std::string Triple) {
- return Triple;
-}
+static std::string updateTripleOSVersion(std::string Triple) { return Triple; }
std::string sys::getDefaultTargetTriple() {
const char *Triple = LLVM_DEFAULT_TARGET_TRIPLE;
- // Override the default target with an environment variable named by LLVM_TARGET_TRIPLE_ENV.
+ // Override the default target with an environment variable named by
+ // LLVM_TARGET_TRIPLE_ENV.
#if defined(LLVM_TARGET_TRIPLE_ENV)
if (const char *EnvTriple = std::getenv(LLVM_TARGET_TRIPLE_ENV))
Triple = EnvTriple;
diff --git a/llvm/lib/Support/Windows/Memory.inc b/llvm/lib/Support/Windows/Memory.inc
index 1b2de1915ec46..93a32111ee3f6 100644
--- a/llvm/lib/Support/Windows/Memory.inc
+++ b/llvm/lib/Support/Windows/Memory.inc
@@ -28,13 +28,12 @@ static DWORD getWindowsProtectionFlags(unsigned Flags) {
case llvm::sys::Memory::MF_WRITE:
// Note: PAGE_WRITE is not supported by VirtualProtect
return PAGE_READWRITE;
- case llvm::sys::Memory::MF_READ|llvm::sys::Memory::MF_WRITE:
+ case llvm::sys::Memory::MF_READ | llvm::sys::Memory::MF_WRITE:
return PAGE_READWRITE;
- case llvm::sys::Memory::MF_READ|llvm::sys::Memory::MF_EXEC:
+ case llvm::sys::Memory::MF_READ | llvm::sys::Memory::MF_EXEC:
return PAGE_EXECUTE_READ;
- case llvm::sys::Memory::MF_READ |
- llvm::sys::Memory::MF_WRITE |
- llvm::sys::Memory::MF_EXEC:
+ case llvm::sys::Memory::MF_READ | llvm::sys::Memory::MF_WRITE |
+ llvm::sys::Memory::MF_EXEC:
return PAGE_EXECUTE_READWRITE;
case llvm::sys::Memory::MF_EXEC:
return PAGE_EXECUTE;
@@ -49,7 +48,7 @@ static DWORD getWindowsProtectionFlags(unsigned Flags) {
// granularity may be larger than a single page (in practice, it is 64K)
// so mapping less than that will create an unreachable fragment of memory.
static size_t getAllocationGranularity() {
- SYSTEM_INFO Info;
+ SYSTEM_INFO Info;
::GetSystemInfo(&Info);
if (Info.dwPageSize > Info.dwAllocationGranularity)
return Info.dwPageSize;
@@ -99,8 +98,7 @@ namespace sys {
MemoryBlock Memory::allocateMappedMemory(size_t NumBytes,
const MemoryBlock *const NearBlock,
- unsigned Flags,
- std::error_code &EC) {
+ unsigned Flags, std::error_code &EC) {
EC = std::error_code();
if (NumBytes == 0)
return MemoryBlock();
@@ -121,8 +119,8 @@ MemoryBlock Memory::allocateMappedMemory(size_t NumBytes,
size_t NumBlocks = (NumBytes + Granularity - 1) / Granularity;
uintptr_t Start = NearBlock ? reinterpret_cast<uintptr_t>(NearBlock->base()) +
- NearBlock->allocatedSize()
- : 0;
+ NearBlock->allocatedSize()
+ : 0;
// If the requested address is not aligned to the allocation granularity,
// round up to get beyond NearBlock. VirtualAlloc would have rounded down.
@@ -132,8 +130,8 @@ MemoryBlock Memory::allocateMappedMemory(size_t NumBytes,
DWORD Protect = getWindowsProtectionFlags(Flags);
size_t AllocSize = NumBlocks * Granularity;
- void *PA = ::VirtualAlloc(reinterpret_cast<void *>(Start),
- AllocSize, AllocType, Protect);
+ void *PA = ::VirtualAlloc(reinterpret_cast<void *>(Start), AllocSize,
+ AllocType, Protect);
if (PA == NULL) {
if (NearBlock || HugePages) {
// Try again without the NearBlock hint and without large memory pages
@@ -154,7 +152,7 @@ MemoryBlock Memory::allocateMappedMemory(size_t NumBytes,
return Result;
}
- std::error_code Memory::releaseMappedMemory(MemoryBlock &M) {
+std::error_code Memory::releaseMappedMemory(MemoryBlock &M) {
if (M.Address == 0 || M.AllocatedSize == 0)
return std::error_code();
@@ -167,8 +165,8 @@ MemoryBlock Memory::allocateMappedMemory(size_t NumBytes,
return std::error_code();
}
- std::error_code Memory::protectMappedMemory(const MemoryBlock &M,
- unsigned Flags) {
+std::error_code Memory::protectMappedMemory(const MemoryBlock &M,
+ unsigned Flags) {
if (M.Address == 0 || M.AllocatedSize == 0)
return std::error_code();
@@ -187,8 +185,7 @@ MemoryBlock Memory::allocateMappedMemory(size_t NumBytes,
/// InvalidateInstructionCache - Before the JIT can run a block of code
/// that has been emitted it must invalidate the instruction cache on some
/// platforms.
-void Memory::InvalidateInstructionCache(
- const void *Addr, size_t Len) {
+void Memory::InvalidateInstructionCache(const void *Addr, size_t Len) {
FlushInstructionCache(GetCurrentProcess(), Addr, Len);
}
diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index 43b1e99aa3c98..92cf4fcda5a68 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/lib/Support/Windows/Path.inc
@@ -37,15 +37,15 @@ typedef int errno_t;
#endif
#ifdef _MSC_VER
-# pragma comment(lib, "advapi32.lib") // This provides CryptAcquireContextW.
-# pragma comment(lib, "ole32.lib") // This provides CoTaskMemFree
+#pragma comment(lib, "advapi32.lib") // This provides CryptAcquireContextW.
+#pragma comment(lib, "ole32.lib") // This provides CoTaskMemFree
#endif
using namespace llvm;
-using llvm::sys::windows::UTF8ToUTF16;
using llvm::sys::windows::CurCPToUTF16;
using llvm::sys::windows::UTF16ToUTF8;
+using llvm::sys::windows::UTF8ToUTF16;
using llvm::sys::windows::widenPath;
static bool is_separator(const wchar_t value) {
@@ -59,7 +59,7 @@ static bool is_separator(const wchar_t value) {
}
namespace llvm {
-namespace sys {
+namespace sys {
namespace windows {
// Convert a UTF-8 path to UTF-16. Also, if the absolute equivalent of the path
@@ -193,9 +193,7 @@ TimePoint<> basic_file_status::getLastModificationTime() const {
return toTimePoint(Time);
}
-uint32_t file_status::getLinkCount() const {
- return NumLinks;
-}
+uint32_t file_status::getLinkCount() const { return NumLinks; }
std::error_code current_path(SmallVectorImpl<char> &result) {
SmallVector<wchar_t, MAX_PATH> cur_path;
@@ -372,8 +370,8 @@ static std::error_code realPathFromHandle(HANDLE H,
// The buffer wasn't big enough, try again. In this case the return value
// *does* indicate the size of the null terminator.
Buffer.resize_for_overwrite(CountChars);
- CountChars = ::GetFinalPathNameByHandleW(
- H, Buffer.begin(), Buffer.size(), FILE_NAME_NORMALIZED);
+ CountChars = ::GetFinalPathNameByHandleW(H, Buffer.begin(), Buffer.size(),
+ FILE_NAME_NORMALIZED);
}
Buffer.truncate(CountChars);
if (CountChars == 0)
@@ -628,8 +626,7 @@ std::error_code access(const Twine &Path, AccessMode Mode) {
if (Attributes == INVALID_FILE_ATTRIBUTES) {
// See if the file didn't actually exist.
DWORD LastError = ::GetLastError();
- if (LastError != ERROR_FILE_NOT_FOUND &&
- LastError != ERROR_PATH_NOT_FOUND)
+ if (LastError != ERROR_FILE_NOT_FOUND && LastError != ERROR_PATH_NOT_FOUND)
return mapWindowsError(LastError);
return errc::no_such_file_or_directory;
}
@@ -650,15 +647,14 @@ bool can_execute(const Twine &Path) {
bool equivalent(file_status A, file_status B) {
assert(status_known(A) && status_known(B));
- return A.FileIndexHigh == B.FileIndexHigh &&
- A.FileIndexLow == B.FileIndexLow &&
- A.FileSizeHigh == B.FileSizeHigh &&
- A.FileSizeLow == B.FileSizeLow &&
- A.LastAccessedTimeHigh == B.LastAccessedTimeHigh &&
- A.LastAccessedTimeLow == B.LastAccessedTimeLow &&
- A.LastWriteTimeHigh == B.LastWriteTimeHigh &&
- A.LastWriteTimeLow == B.LastWriteTimeLow &&
- A.VolumeSerialNumber == B.VolumeSerialNumber;
+ return A.FileIndexHigh == B.FileIndexHigh &&
+ A.FileIndexLow == B.FileIndexLow && A.FileSizeHigh == B.FileSizeHigh &&
+ A.FileSizeLow == B.FileSizeLow &&
+ A.LastAccessedTimeHigh == B.LastAccessedTimeHigh &&
+ A.LastAccessedTimeLow == B.LastAccessedTimeLow &&
+ A.LastWriteTimeHigh == B.LastWriteTimeHigh &&
+ A.LastWriteTimeLow == B.LastWriteTimeLow &&
+ A.VolumeSerialNumber == B.VolumeSerialNumber;
}
std::error_code equivalent(const Twine &A, const Twine &B, bool &result) {
@@ -674,12 +670,10 @@ std::error_code equivalent(const Twine &A, const Twine &B, bool &result) {
static bool isReservedName(StringRef path) {
// This list of reserved names comes from MSDN, at:
// http://msdn.microsoft.com/en-us/library/aa365247%28v=vs.85%29.aspx
- static const char *const sReservedNames[] = { "nul", "con", "prn", "aux",
- "com1", "com2", "com3", "com4",
- "com5", "com6", "com7", "com8",
- "com9", "lpt1", "lpt2", "lpt3",
- "lpt4", "lpt5", "lpt6", "lpt7",
- "lpt8", "lpt9" };
+ static const char *const sReservedNames[] = {
+ "nul", "con", "prn", "aux", "com1", "com2", "com3", "com4",
+ "com5", "com6", "com7", "com8", "com9", "lpt1", "lpt2", "lpt3",
+ "lpt4", "lpt5", "lpt6", "lpt7", "lpt8", "lpt9"};
// First, check to see if this is a device namespace, which always
// starts with \\.\, since device namespaces are not legal file paths.
@@ -744,8 +738,7 @@ static std::error_code getStatus(HANDLE FileHandle, file_status &Result) {
handle_status_error:
DWORD LastError = ::GetLastError();
- if (LastError == ERROR_FILE_NOT_FOUND ||
- LastError == ERROR_PATH_NOT_FOUND)
+ if (LastError == ERROR_FILE_NOT_FOUND || LastError == ERROR_PATH_NOT_FOUND)
Result = file_status(file_type::file_not_found);
else if (LastError == ERROR_SHARING_VIOLATION)
Result = file_status(file_type::type_unknown);
@@ -795,9 +788,7 @@ std::error_code status(file_t FileHandle, file_status &Result) {
return getStatus(FileHandle, Result);
}
-unsigned getUmask() {
- return 0;
-}
+unsigned getUmask() { return 0; }
std::error_code setPermissions(const Twine &Path, perms Permissions) {
SmallVector<wchar_t, 128> PathUTF16;
@@ -816,8 +807,7 @@ std::error_code setPermissions(const Twine &Path, perms Permissions) {
if (Attributes == 0)
// FILE_ATTRIBUTE_NORMAL indicates no other attributes are set.
Attributes |= FILE_ATTRIBUTE_NORMAL;
- }
- else {
+ } else {
Attributes |= FILE_ATTRIBUTE_READONLY;
// FILE_ATTRIBUTE_NORMAL is not compatible with any other attributes, so
// remove it, if it is present.
@@ -853,16 +843,19 @@ std::error_code mapped_file_region::init(sys::fs::file_t OrigFileHandle,
DWORD flprotect;
switch (Mode) {
- case readonly: flprotect = PAGE_READONLY; break;
- case readwrite: flprotect = PAGE_READWRITE; break;
- case priv: flprotect = PAGE_WRITECOPY; break;
+ case readonly:
+ flprotect = PAGE_READONLY;
+ break;
+ case readwrite:
+ flprotect = PAGE_READWRITE;
+ break;
+ case priv:
+ flprotect = PAGE_WRITECOPY;
+ break;
}
- HANDLE FileMappingHandle =
- ::CreateFileMappingW(OrigFileHandle, 0, flprotect,
- Hi_32(Size),
- Lo_32(Size),
- 0);
+ HANDLE FileMappingHandle = ::CreateFileMappingW(OrigFileHandle, 0, flprotect,
+ Hi_32(Size), Lo_32(Size), 0);
if (FileMappingHandle == NULL) {
std::error_code ec = mapWindowsError(GetLastError());
return ec;
@@ -870,15 +863,18 @@ std::error_code mapped_file_region::init(sys::fs::file_t OrigFileHandle,
DWORD dwDesiredAccess;
switch (Mode) {
- case readonly: dwDesiredAccess = FILE_MAP_READ; break;
- case readwrite: dwDesiredAccess = FILE_MAP_WRITE; break;
- case priv: dwDesiredAccess = FILE_MAP_COPY; break;
+ case readonly:
+ dwDesiredAccess = FILE_MAP_READ;
+ break;
+ case readwrite:
+ dwDesiredAccess = FILE_MAP_WRITE;
+ break;
+ case priv:
+ dwDesiredAccess = FILE_MAP_COPY;
+ break;
}
- Mapping = ::MapViewOfFile(FileMappingHandle,
- dwDesiredAccess,
- Offset >> 32,
- Offset & 0xffffffff,
- Size);
+ Mapping = ::MapViewOfFile(FileMappingHandle, dwDesiredAccess, Offset >> 32,
+ Offset & 0xffffffff, Size);
if (Mapping == NULL) {
std::error_code ec = mapWindowsError(GetLastError());
::CloseHandle(FileMappingHandle);
@@ -1008,7 +1004,7 @@ std::error_code detail::directory_iterator_construct(detail::DirIterState &IT,
size_t FilenameLen = ::wcslen(FirstFind.cFileName);
while ((FilenameLen == 1 && FirstFind.cFileName[0] == L'.') ||
(FilenameLen == 2 && FirstFind.cFileName[0] == L'.' &&
- FirstFind.cFileName[1] == L'.'))
+ FirstFind.cFileName[1] == L'.'))
if (!::FindNextFileW(FindHandle, &FirstFind)) {
DWORD LastError = ::GetLastError();
// Check for end.
@@ -1058,7 +1054,7 @@ std::error_code detail::directory_iterator_increment(detail::DirIterState &IT) {
size_t FilenameLen = ::wcslen(FindData.cFileName);
if ((FilenameLen == 1 && FindData.cFileName[0] == L'.') ||
(FilenameLen == 2 && FindData.cFileName[0] == L'.' &&
- FindData.cFileName[1] == L'.'))
+ FindData.cFileName[1] == L'.'))
return directory_iterator_increment(IT);
SmallString<128> DirectoryEntryPathUTF8;
@@ -1074,9 +1070,7 @@ std::error_code detail::directory_iterator_increment(detail::DirIterState &IT) {
return std::error_code();
}
-ErrorOr<basic_file_status> directory_entry::status() const {
- return Status;
-}
+ErrorOr<basic_file_status> directory_entry::status() const { return Status; }
static std::error_code nativeFileToFd(Expected<HANDLE> H, int &ResultFD,
OpenFlags Flags) {
@@ -1365,7 +1359,8 @@ static void expandTildeExpr(SmallVectorImpl<char> &Path) {
StringRef PathStr(Path.begin(), Path.size());
PathStr = PathStr.drop_front();
- StringRef Expr = PathStr.take_until([](char c) { return path::is_separator(c); });
+ StringRef Expr =
+ PathStr.take_until([](char c) { return path::is_separator(c); });
if (!Expr.empty()) {
// This is probably a ~username/ expression. Don't support this on Windows.
@@ -1496,12 +1491,12 @@ void system_temp_directory(bool ErasedOnReboot, SmallVectorImpl<char> &Result) {
} // end namespace path
namespace windows {
-std::error_code CodePageToUTF16(unsigned codepage,
- llvm::StringRef original,
+std::error_code CodePageToUTF16(unsigned codepage, llvm::StringRef original,
llvm::SmallVectorImpl<wchar_t> &utf16) {
if (!original.empty()) {
- int len = ::MultiByteToWideChar(codepage, MB_ERR_INVALID_CHARS, original.begin(),
- original.size(), utf16.begin(), 0);
+ int len =
+ ::MultiByteToWideChar(codepage, MB_ERR_INVALID_CHARS, original.begin(),
+ original.size(), utf16.begin(), 0);
if (len == 0) {
return mapWindowsError(::GetLastError());
@@ -1510,8 +1505,9 @@ std::error_code CodePageToUTF16(unsigned codepage,
utf16.reserve(len + 1);
utf16.resize_for_overwrite(len);
- len = ::MultiByteToWideChar(codepage, MB_ERR_INVALID_CHARS, original.begin(),
- original.size(), utf16.begin(), utf16.size());
+ len =
+ ::MultiByteToWideChar(codepage, MB_ERR_INVALID_CHARS, original.begin(),
+ original.size(), utf16.begin(), utf16.size());
if (len == 0) {
return mapWindowsError(::GetLastError());
@@ -1531,18 +1527,17 @@ std::error_code UTF8ToUTF16(llvm::StringRef utf8,
}
std::error_code CurCPToUTF16(llvm::StringRef curcp,
- llvm::SmallVectorImpl<wchar_t> &utf16) {
+ llvm::SmallVectorImpl<wchar_t> &utf16) {
return CodePageToUTF16(CP_ACP, curcp, utf16);
}
-static
-std::error_code UTF16ToCodePage(unsigned codepage, const wchar_t *utf16,
- size_t utf16_len,
- llvm::SmallVectorImpl<char> &converted) {
+static std::error_code UTF16ToCodePage(unsigned codepage, const wchar_t *utf16,
+ size_t utf16_len,
+ llvm::SmallVectorImpl<char> &converted) {
if (utf16_len) {
// Get length.
- int len = ::WideCharToMultiByte(codepage, 0, utf16, utf16_len, converted.begin(),
- 0, NULL, NULL);
+ int len = ::WideCharToMultiByte(codepage, 0, utf16, utf16_len,
+ converted.begin(), 0, NULL, NULL);
if (len == 0) {
return mapWindowsError(::GetLastError());
diff --git a/llvm/lib/Support/Windows/Process.inc b/llvm/lib/Support/Windows/Process.inc
index b0c55a77bc93e..000a42bc7a80b 100644
--- a/llvm/lib/Support/Windows/Process.inc
+++ b/llvm/lib/Support/Windows/Process.inc
@@ -27,8 +27,8 @@
#include <shellapi.h>
#if !defined(__MINGW32__)
- #pragma comment(lib, "psapi.lib")
- #pragma comment(lib, "shell32.lib")
+#pragma comment(lib, "psapi.lib")
+#pragma comment(lib, "shell32.lib")
#endif
//===----------------------------------------------------------------------===//
@@ -38,7 +38,7 @@
#ifdef __MINGW32__
// This ban should be lifted when MinGW 1.0+ has defined this value.
-# define _HEAPOK (-2)
+#define _HEAPOK (-2)
#endif
using namespace llvm;
@@ -67,9 +67,7 @@ Expected<unsigned> Process::getPageSize() {
return Ret;
}
-size_t
-Process::GetMallocUsage()
-{
+size_t Process::GetMallocUsage() {
_HEAPINFO hinfo;
hinfo._pentry = NULL;
@@ -81,9 +79,11 @@ Process::GetMallocUsage()
return size;
}
-void Process::GetTimeUsage(TimePoint<> &elapsed, std::chrono::nanoseconds &user_time,
+void Process::GetTimeUsage(TimePoint<> &elapsed,
+ std::chrono::nanoseconds &user_time,
std::chrono::nanoseconds &sys_time) {
- elapsed = std::chrono::system_clock::now();;
+ elapsed = std::chrono::system_clock::now();
+ ;
FILETIME ProcCreate, ProcExit, KernelTime, UserTime;
if (GetProcessTimes(GetCurrentProcess(), &ProcCreate, &ProcExit, &KernelTime,
@@ -108,8 +108,7 @@ void Process::PreventCoreFiles() {
//
// Windows also has modal pop-up message boxes. As this method is used by
// bugpoint, preventing these pop-ups is additionally important.
- SetErrorMode(SEM_FAILCRITICALERRORS |
- SEM_NOGPFAULTERRORBOX |
+ SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX |
SEM_NOOPENFILEERRORBOX);
coreFilesPrevented = true;
@@ -131,8 +130,7 @@ Optional<std::string> Process::GetEnv(StringRef Name) {
do {
Buf.resize_for_overwrite(Size);
SetLastError(NO_ERROR);
- Size =
- GetEnvironmentVariableW(NameUTF16.data(), Buf.data(), Buf.size());
+ Size = GetEnvironmentVariableW(NameUTF16.data(), Buf.data(), Buf.size());
if (Size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)
return None;
@@ -281,20 +279,14 @@ std::error_code Process::SafelyCloseFileDescriptor(int FD) {
return std::error_code();
}
-bool Process::StandardInIsUserInput() {
- return FileDescriptorIsDisplayed(0);
-}
+bool Process::StandardInIsUserInput() { return FileDescriptorIsDisplayed(0); }
-bool Process::StandardOutIsDisplayed() {
- return FileDescriptorIsDisplayed(1);
-}
+bool Process::StandardOutIsDisplayed() { return FileDescriptorIsDisplayed(1); }
-bool Process::StandardErrIsDisplayed() {
- return FileDescriptorIsDisplayed(2);
-}
+bool Process::StandardErrIsDisplayed() { return FileDescriptorIsDisplayed(2); }
bool Process::FileDescriptorIsDisplayed(int fd) {
- DWORD Mode; // Unused
+ DWORD Mode; // Unused
return (GetConsoleMode((HANDLE)_get_osfhandle(fd), &Mode) != 0);
}
@@ -319,13 +311,9 @@ bool Process::FileDescriptorHasColors(int fd) {
return FileDescriptorIsDisplayed(fd);
}
-bool Process::StandardOutHasColors() {
- return FileDescriptorHasColors(1);
-}
+bool Process::StandardOutHasColors() { return FileDescriptorHasColors(1); }
-bool Process::StandardErrHasColors() {
- return FileDescriptorHasColors(2);
-}
+bool Process::StandardErrHasColors() { return FileDescriptorHasColors(2); }
static bool UseANSI = false;
void Process::UseANSIEscapeCodes(bool enable) {
@@ -342,41 +330,39 @@ void Process::UseANSIEscapeCodes(bool enable) {
}
namespace {
-class DefaultColors
-{
- private:
- WORD defaultColor;
- public:
- DefaultColors()
- :defaultColor(GetCurrentColor()) {}
- static unsigned GetCurrentColor() {
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi))
- return csbi.wAttributes;
- return 0;
- }
- WORD operator()() const { return defaultColor; }
+class DefaultColors {
+private:
+ WORD defaultColor;
+
+public:
+ DefaultColors() : defaultColor(GetCurrentColor()) {}
+ static unsigned GetCurrentColor() {
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi))
+ return csbi.wAttributes;
+ return 0;
+ }
+ WORD operator()() const { return defaultColor; }
};
DefaultColors defaultColors;
WORD fg_color(WORD color) {
- return color & (FOREGROUND_BLUE | FOREGROUND_GREEN |
- FOREGROUND_INTENSITY | FOREGROUND_RED);
+ return color & (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY |
+ FOREGROUND_RED);
}
WORD bg_color(WORD color) {
- return color & (BACKGROUND_BLUE | BACKGROUND_GREEN |
- BACKGROUND_INTENSITY | BACKGROUND_RED);
-}
+ return color & (BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY |
+ BACKGROUND_RED);
}
+} // namespace
-bool Process::ColorNeedsFlush() {
- return !UseANSI;
-}
+bool Process::ColorNeedsFlush() { return !UseANSI; }
const char *Process::OutputBold(bool bg) {
- if (UseANSI) return "\033[1m";
+ if (UseANSI)
+ return "\033[1m";
WORD colors = DefaultColors::GetCurrentColor();
if (bg)
@@ -388,21 +374,22 @@ const char *Process::OutputBold(bool bg) {
}
const char *Process::OutputColor(char code, bool bold, bool bg) {
- if (UseANSI) return colorcodes[bg?1:0][bold?1:0][code&7];
+ if (UseANSI)
+ return colorcodes[bg ? 1 : 0][bold ? 1 : 0][code & 7];
WORD current = DefaultColors::GetCurrentColor();
WORD colors;
if (bg) {
- colors = ((code&1) ? BACKGROUND_RED : 0) |
- ((code&2) ? BACKGROUND_GREEN : 0 ) |
- ((code&4) ? BACKGROUND_BLUE : 0);
+ colors = ((code & 1) ? BACKGROUND_RED : 0) |
+ ((code & 2) ? BACKGROUND_GREEN : 0) |
+ ((code & 4) ? BACKGROUND_BLUE : 0);
if (bold)
colors |= BACKGROUND_INTENSITY;
colors |= fg_color(current);
} else {
- colors = ((code&1) ? FOREGROUND_RED : 0) |
- ((code&2) ? FOREGROUND_GREEN : 0 ) |
- ((code&4) ? FOREGROUND_BLUE : 0);
+ colors = ((code & 1) ? FOREGROUND_RED : 0) |
+ ((code & 2) ? FOREGROUND_GREEN : 0) |
+ ((code & 4) ? FOREGROUND_BLUE : 0);
if (bold)
colors |= FOREGROUND_INTENSITY;
colors |= bg_color(current);
@@ -418,27 +405,27 @@ static WORD GetConsoleTextAttribute(HANDLE hConsoleOutput) {
}
const char *Process::OutputReverse() {
- if (UseANSI) return "\033[7m";
+ if (UseANSI)
+ return "\033[7m";
- const WORD attributes
- = GetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE));
+ const WORD attributes =
+ GetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE));
const WORD foreground_mask = FOREGROUND_BLUE | FOREGROUND_GREEN |
- FOREGROUND_RED | FOREGROUND_INTENSITY;
+ FOREGROUND_RED | FOREGROUND_INTENSITY;
const WORD background_mask = BACKGROUND_BLUE | BACKGROUND_GREEN |
- BACKGROUND_RED | BACKGROUND_INTENSITY;
+ BACKGROUND_RED | BACKGROUND_INTENSITY;
const WORD color_mask = foreground_mask | background_mask;
WORD new_attributes =
- ((attributes & FOREGROUND_BLUE )?BACKGROUND_BLUE :0) |
- ((attributes & FOREGROUND_GREEN )?BACKGROUND_GREEN :0) |
- ((attributes & FOREGROUND_RED )?BACKGROUND_RED :0) |
- ((attributes & FOREGROUND_INTENSITY)?BACKGROUND_INTENSITY:0) |
- ((attributes & BACKGROUND_BLUE )?FOREGROUND_BLUE :0) |
- ((attributes & BACKGROUND_GREEN )?FOREGROUND_GREEN :0) |
- ((attributes & BACKGROUND_RED )?FOREGROUND_RED :0) |
- ((attributes & BACKGROUND_INTENSITY)?FOREGROUND_INTENSITY:0) |
- 0;
+ ((attributes & FOREGROUND_BLUE) ? BACKGROUND_BLUE : 0) |
+ ((attributes & FOREGROUND_GREEN) ? BACKGROUND_GREEN : 0) |
+ ((attributes & FOREGROUND_RED) ? BACKGROUND_RED : 0) |
+ ((attributes & FOREGROUND_INTENSITY) ? BACKGROUND_INTENSITY : 0) |
+ ((attributes & BACKGROUND_BLUE) ? FOREGROUND_BLUE : 0) |
+ ((attributes & BACKGROUND_GREEN) ? FOREGROUND_GREEN : 0) |
+ ((attributes & BACKGROUND_RED) ? FOREGROUND_RED : 0) |
+ ((attributes & BACKGROUND_INTENSITY) ? FOREGROUND_INTENSITY : 0) | 0;
new_attributes = (attributes & ~color_mask) | (new_attributes & color_mask);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), new_attributes);
@@ -446,7 +433,8 @@ const char *Process::OutputReverse() {
}
const char *Process::ResetColor() {
- if (UseANSI) return "\033[0m";
+ if (UseANSI)
+ return "\033[0m";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), defaultColors());
return 0;
}
@@ -485,7 +473,7 @@ unsigned Process::GetRandomNumber() {
return GetPseudoRandomNumber();
}
-typedef NTSTATUS(WINAPI* RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
+typedef NTSTATUS(WINAPI *RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
#define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
llvm::VersionTuple llvm::GetWindowsOSVersion() {
diff --git a/llvm/lib/Support/Windows/Program.inc b/llvm/lib/Support/Windows/Program.inc
index 58de140a60d18..5a82c9bef5e97 100644
--- a/llvm/lib/Support/Windows/Program.inc
+++ b/llvm/lib/Support/Windows/Program.inc
@@ -82,8 +82,8 @@ ErrorOr<std::string> sys::findProgramByName(StringRef Name,
windows::UTF8ToUTF16(Twine(Name + Ext).str(), U16NameExt))
return EC;
- Len = ::SearchPathW(Path, c_str(U16NameExt), nullptr,
- U16Result.size(), U16Result.data(), nullptr);
+ Len = ::SearchPathW(Path, c_str(U16NameExt), nullptr, U16Result.size(),
+ U16Result.data(), nullptr);
} while (Len > U16Result.size());
if (Len == 0)
@@ -92,7 +92,7 @@ ErrorOr<std::string> sys::findProgramByName(StringRef Name,
U16Result.truncate(Len);
if (std::error_code EC =
- windows::UTF16ToUTF8(U16Result.data(), U16Result.size(), U8Result))
+ windows::UTF16ToUTF8(U16Result.data(), U16Result.size(), U8Result))
return EC;
if (sys::fs::can_execute(U8Result))
@@ -132,8 +132,8 @@ static HANDLE RedirectIO(Optional<StringRef> Path, int fd,
HANDLE h;
if (!Path) {
if (!DuplicateHandle(GetCurrentProcess(), (HANDLE)_get_osfhandle(fd),
- GetCurrentProcess(), &h,
- 0, TRUE, DUPLICATE_SAME_ACCESS))
+ GetCurrentProcess(), &h, 0, TRUE,
+ DUPLICATE_SAME_ACCESS))
return INVALID_HANDLE_VALUE;
return h;
}
@@ -162,14 +162,14 @@ static HANDLE RedirectIO(Optional<StringRef> Path, int fd,
FILE_SHARE_READ, &sa, fd == 0 ? OPEN_EXISTING : CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE) {
- MakeErrMsg(ErrMsg, fname + ": Can't open file for " +
- (fd ? "input" : "output"));
+ MakeErrMsg(ErrMsg,
+ fname + ": Can't open file for " + (fd ? "input" : "output"));
}
return h;
}
-}
+} // namespace llvm
static bool Execute(ProcessInfo &PI, StringRef Program,
ArrayRef<StringRef> Args, Optional<ArrayRef<StringRef>> Env,
@@ -248,8 +248,8 @@ static bool Execute(ProcessInfo &PI, StringRef Program,
// If stdout and stderr should go to the same place, redirect stderr
// to the handle already open for stdout.
if (!DuplicateHandle(GetCurrentProcess(), si.hStdOutput,
- GetCurrentProcess(), &si.hStdError,
- 0, TRUE, DUPLICATE_SAME_ACCESS)) {
+ GetCurrentProcess(), &si.hStdError, 0, TRUE,
+ DUPLICATE_SAME_ACCESS)) {
CloseHandle(si.hStdInput);
CloseHandle(si.hStdOutput);
MakeErrMsg(ErrMsg, "can't dup stderr to stdout");
@@ -301,8 +301,8 @@ static bool Execute(ProcessInfo &PI, StringRef Program,
// Now return an error if the process didn't get created.
if (!rc) {
SetLastError(err);
- MakeErrMsg(ErrMsg, std::string("Couldn't execute program '") +
- Program.str() + "'");
+ MakeErrMsg(ErrMsg,
+ std::string("Couldn't execute program '") + Program.str() + "'");
return false;
}
@@ -490,13 +490,13 @@ ProcessInfo sys::Wait(const ProcessInfo &PI, unsigned SecondsToWait,
return WaitResult;
}
-std::error_code llvm::sys::ChangeStdinMode(sys::fs::OpenFlags Flags){
+std::error_code llvm::sys::ChangeStdinMode(sys::fs::OpenFlags Flags) {
if (!(Flags & fs::OF_CRLF))
return ChangeStdinToBinary();
return std::error_code();
}
-std::error_code llvm::sys::ChangeStdoutMode(sys::fs::OpenFlags Flags){
+std::error_code llvm::sys::ChangeStdoutMode(sys::fs::OpenFlags Flags) {
if (!(Flags & fs::OF_CRLF))
return ChangeStdoutToBinary();
return std::error_code();
@@ -533,8 +533,8 @@ llvm::sys::writeFileWithEncoding(StringRef FileName, StringRef Contents,
if ((EC = windows::UTF8ToUTF16(Contents, ArgsUTF16)))
return EC;
- if ((EC = windows::UTF16ToCurCP(
- ArgsUTF16.data(), ArgsUTF16.size(), ArgsCurCP)))
+ if ((EC = windows::UTF16ToCurCP(ArgsUTF16.data(), ArgsUTF16.size(),
+ ArgsCurCP)))
return EC;
OS.write(ArgsCurCP.data(), ArgsCurCP.size());
@@ -574,4 +574,4 @@ bool llvm::sys::commandLineFitsWithinSystemLimits(StringRef Program,
assert(!Result.getError());
return (Result->size() + 1) <= MaxCommandStringLength;
}
-}
+} // namespace llvm
diff --git a/llvm/lib/Support/Windows/Signals.inc b/llvm/lib/Support/Windows/Signals.inc
index aeb3707e6dba8..ba93afe0803b4 100644
--- a/llvm/lib/Support/Windows/Signals.inc
+++ b/llvm/lib/Support/Windows/Signals.inc
@@ -26,98 +26,99 @@
#include "llvm/Support/Windows/WindowsSupport.h"
#ifdef __MINGW32__
- #include <imagehlp.h>
+#include <imagehlp.h>
#else
- #include <crtdbg.h>
- #include <dbghelp.h>
+#include <crtdbg.h>
+#include <dbghelp.h>
#endif
#include <psapi.h>
#ifdef _MSC_VER
- #pragma comment(lib, "psapi.lib")
+#pragma comment(lib, "psapi.lib")
#elif __MINGW32__
- // The version of g++ that comes with MinGW does *not* properly understand
- // the ll format specifier for printf. However, MinGW passes the format
- // specifiers on to the MSVCRT entirely, and the CRT understands the ll
- // specifier. So these warnings are spurious in this case. Since we compile
- // with -Wall, this will generate these warnings which should be ignored. So
- // we will turn off the warnings for this just file. However, MinGW also does
- // not support push and pop for diagnostics, so we have to manually turn it
- // back on at the end of the file.
- #pragma GCC diagnostic ignored "-Wformat"
- #pragma GCC diagnostic ignored "-Wformat-extra-args"
-
- #if !defined(__MINGW64_VERSION_MAJOR)
- // MinGW.org does not have updated support for the 64-bit versions of the
- // DebugHlp APIs. So we will have to load them manually. The structures and
- // method signatures were pulled from DbgHelp.h in the Windows Platform SDK,
- // and adjusted for brevity.
- typedef struct _IMAGEHLP_LINE64 {
- DWORD SizeOfStruct;
- PVOID Key;
- DWORD LineNumber;
- PCHAR FileName;
- DWORD64 Address;
- } IMAGEHLP_LINE64, *PIMAGEHLP_LINE64;
-
- typedef struct _IMAGEHLP_SYMBOL64 {
- DWORD SizeOfStruct;
- DWORD64 Address;
- DWORD Size;
- DWORD Flags;
- DWORD MaxNameLength;
- CHAR Name[1];
- } IMAGEHLP_SYMBOL64, *PIMAGEHLP_SYMBOL64;
-
- typedef struct _tagADDRESS64 {
- DWORD64 Offset;
- WORD Segment;
- ADDRESS_MODE Mode;
- } ADDRESS64, *LPADDRESS64;
-
- typedef struct _KDHELP64 {
- DWORD64 Thread;
- DWORD ThCallbackStack;
- DWORD ThCallbackBStore;
- DWORD NextCallback;
- DWORD FramePointer;
- DWORD64 KiCallUserMode;
- DWORD64 KeUserCallbackDispatcher;
- DWORD64 SystemRangeStart;
- DWORD64 KiUserExceptionDispatcher;
- DWORD64 StackBase;
- DWORD64 StackLimit;
- DWORD64 Reserved[5];
- } KDHELP64, *PKDHELP64;
-
- typedef struct _tagSTACKFRAME64 {
- ADDRESS64 AddrPC;
- ADDRESS64 AddrReturn;
- ADDRESS64 AddrFrame;
- ADDRESS64 AddrStack;
- ADDRESS64 AddrBStore;
- PVOID FuncTableEntry;
- DWORD64 Params[4];
- BOOL Far;
- BOOL Virtual;
- DWORD64 Reserved[3];
- KDHELP64 KdHelp;
- } STACKFRAME64, *LPSTACKFRAME64;
- #endif // !defined(__MINGW64_VERSION_MAJOR)
+// The version of g++ that comes with MinGW does *not* properly understand
+// the ll format specifier for printf. However, MinGW passes the format
+// specifiers on to the MSVCRT entirely, and the CRT understands the ll
+// specifier. So these warnings are spurious in this case. Since we compile
+// with -Wall, this will generate these warnings which should be ignored. So
+// we will turn off the warnings for this just file. However, MinGW also does
+// not support push and pop for diagnostics, so we have to manually turn it
+// back on at the end of the file.
+#pragma GCC diagnostic ignored "-Wformat"
+#pragma GCC diagnostic ignored "-Wformat-extra-args"
+
+#if !defined(__MINGW64_VERSION_MAJOR)
+// MinGW.org does not have updated support for the 64-bit versions of the
+// DebugHlp APIs. So we will have to load them manually. The structures and
+// method signatures were pulled from DbgHelp.h in the Windows Platform SDK,
+// and adjusted for brevity.
+typedef struct _IMAGEHLP_LINE64 {
+ DWORD SizeOfStruct;
+ PVOID Key;
+ DWORD LineNumber;
+ PCHAR FileName;
+ DWORD64 Address;
+} IMAGEHLP_LINE64, *PIMAGEHLP_LINE64;
+
+typedef struct _IMAGEHLP_SYMBOL64 {
+ DWORD SizeOfStruct;
+ DWORD64 Address;
+ DWORD Size;
+ DWORD Flags;
+ DWORD MaxNameLength;
+ CHAR Name[1];
+} IMAGEHLP_SYMBOL64, *PIMAGEHLP_SYMBOL64;
+
+typedef struct _tagADDRESS64 {
+ DWORD64 Offset;
+ WORD Segment;
+ ADDRESS_MODE Mode;
+} ADDRESS64, *LPADDRESS64;
+
+typedef struct _KDHELP64 {
+ DWORD64 Thread;
+ DWORD ThCallbackStack;
+ DWORD ThCallbackBStore;
+ DWORD NextCallback;
+ DWORD FramePointer;
+ DWORD64 KiCallUserMode;
+ DWORD64 KeUserCallbackDispatcher;
+ DWORD64 SystemRangeStart;
+ DWORD64 KiUserExceptionDispatcher;
+ DWORD64 StackBase;
+ DWORD64 StackLimit;
+ DWORD64 Reserved[5];
+} KDHELP64, *PKDHELP64;
+
+typedef struct _tagSTACKFRAME64 {
+ ADDRESS64 AddrPC;
+ ADDRESS64 AddrReturn;
+ ADDRESS64 AddrFrame;
+ ADDRESS64 AddrStack;
+ ADDRESS64 AddrBStore;
+ PVOID FuncTableEntry;
+ DWORD64 Params[4];
+ BOOL Far;
+ BOOL Virtual;
+ DWORD64 Reserved[3];
+ KDHELP64 KdHelp;
+} STACKFRAME64, *LPSTACKFRAME64;
+#endif // !defined(__MINGW64_VERSION_MAJOR)
#endif // __MINGW32__
-typedef BOOL (__stdcall *PREAD_PROCESS_MEMORY_ROUTINE64)(HANDLE hProcess,
- DWORD64 qwBaseAddress, PVOID lpBuffer, DWORD nSize,
- LPDWORD lpNumberOfBytesRead);
+typedef BOOL(__stdcall *PREAD_PROCESS_MEMORY_ROUTINE64)(
+ HANDLE hProcess, DWORD64 qwBaseAddress, PVOID lpBuffer, DWORD nSize,
+ LPDWORD lpNumberOfBytesRead);
-typedef PVOID (__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE64)( HANDLE ahProcess,
- DWORD64 AddrBase);
+typedef PVOID(__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE64)(HANDLE ahProcess,
+ DWORD64 AddrBase);
-typedef DWORD64 (__stdcall *PGET_MODULE_BASE_ROUTINE64)(HANDLE hProcess,
- DWORD64 Address);
+typedef DWORD64(__stdcall *PGET_MODULE_BASE_ROUTINE64)(HANDLE hProcess,
+ DWORD64 Address);
-typedef DWORD64 (__stdcall *PTRANSLATE_ADDRESS_ROUTINE64)(HANDLE hProcess,
- HANDLE hThread, LPADDRESS64 lpaddr);
+typedef DWORD64(__stdcall *PTRANSLATE_ADDRESS_ROUTINE64)(HANDLE hProcess,
+ HANDLE hThread,
+ LPADDRESS64 lpaddr);
typedef BOOL(WINAPI *fpMiniDumpWriteDump)(HANDLE, DWORD, HANDLE, MINIDUMP_TYPE,
PMINIDUMP_EXCEPTION_INFORMATION,
@@ -125,38 +126,40 @@ typedef BOOL(WINAPI *fpMiniDumpWriteDump)(HANDLE, DWORD, HANDLE, MINIDUMP_TYPE,
PMINIDUMP_CALLBACK_INFORMATION);
static fpMiniDumpWriteDump fMiniDumpWriteDump;
-typedef BOOL (WINAPI *fpStackWalk64)(DWORD, HANDLE, HANDLE, LPSTACKFRAME64,
- PVOID, PREAD_PROCESS_MEMORY_ROUTINE64,
- PFUNCTION_TABLE_ACCESS_ROUTINE64,
- PGET_MODULE_BASE_ROUTINE64,
- PTRANSLATE_ADDRESS_ROUTINE64);
+typedef BOOL(WINAPI *fpStackWalk64)(DWORD, HANDLE, HANDLE, LPSTACKFRAME64,
+ PVOID, PREAD_PROCESS_MEMORY_ROUTINE64,
+ PFUNCTION_TABLE_ACCESS_ROUTINE64,
+ PGET_MODULE_BASE_ROUTINE64,
+ PTRANSLATE_ADDRESS_ROUTINE64);
static fpStackWalk64 fStackWalk64;
-typedef DWORD64 (WINAPI *fpSymGetModuleBase64)(HANDLE, DWORD64);
+typedef DWORD64(WINAPI *fpSymGetModuleBase64)(HANDLE, DWORD64);
static fpSymGetModuleBase64 fSymGetModuleBase64;
-typedef BOOL (WINAPI *fpSymGetSymFromAddr64)(HANDLE, DWORD64,
- PDWORD64, PIMAGEHLP_SYMBOL64);
+typedef BOOL(WINAPI *fpSymGetSymFromAddr64)(HANDLE, DWORD64, PDWORD64,
+ PIMAGEHLP_SYMBOL64);
static fpSymGetSymFromAddr64 fSymGetSymFromAddr64;
-typedef BOOL (WINAPI *fpSymGetLineFromAddr64)(HANDLE, DWORD64,
- PDWORD, PIMAGEHLP_LINE64);
+typedef BOOL(WINAPI *fpSymGetLineFromAddr64)(HANDLE, DWORD64, PDWORD,
+ PIMAGEHLP_LINE64);
static fpSymGetLineFromAddr64 fSymGetLineFromAddr64;
typedef BOOL(WINAPI *fpSymGetModuleInfo64)(HANDLE hProcess, DWORD64 dwAddr,
PIMAGEHLP_MODULE64 ModuleInfo);
static fpSymGetModuleInfo64 fSymGetModuleInfo64;
-typedef PVOID (WINAPI *fpSymFunctionTableAccess64)(HANDLE, DWORD64);
+typedef PVOID(WINAPI *fpSymFunctionTableAccess64)(HANDLE, DWORD64);
static fpSymFunctionTableAccess64 fSymFunctionTableAccess64;
-typedef DWORD (WINAPI *fpSymSetOptions)(DWORD);
+typedef DWORD(WINAPI *fpSymSetOptions)(DWORD);
static fpSymSetOptions fSymSetOptions;
-typedef BOOL (WINAPI *fpSymInitialize)(HANDLE, PCSTR, BOOL);
+typedef BOOL(WINAPI *fpSymInitialize)(HANDLE, PCSTR, BOOL);
static fpSymInitialize fSymInitialize;
-typedef BOOL (WINAPI *fpEnumerateLoadedModules)(HANDLE,PENUMLOADED_MODULES_CALLBACK64,PVOID);
+typedef BOOL(WINAPI *fpEnumerateLoadedModules)(HANDLE,
+ PENUMLOADED_MODULES_CALLBACK64,
+ PVOID);
static fpEnumerateLoadedModules fEnumerateLoadedModules;
static bool isDebugHelpInitialized() {
@@ -166,24 +169,23 @@ static bool isDebugHelpInitialized() {
static bool load64BitDebugHelp(void) {
HMODULE hLib = ::LoadLibraryW(L"Dbghelp.dll");
if (hLib) {
- fMiniDumpWriteDump = (fpMiniDumpWriteDump)
- ::GetProcAddress(hLib, "MiniDumpWriteDump");
- fStackWalk64 = (fpStackWalk64)
- ::GetProcAddress(hLib, "StackWalk64");
- fSymGetModuleBase64 = (fpSymGetModuleBase64)
- ::GetProcAddress(hLib, "SymGetModuleBase64");
- fSymGetSymFromAddr64 = (fpSymGetSymFromAddr64)
- ::GetProcAddress(hLib, "SymGetSymFromAddr64");
- fSymGetLineFromAddr64 = (fpSymGetLineFromAddr64)
- ::GetProcAddress(hLib, "SymGetLineFromAddr64");
- fSymGetModuleInfo64 = (fpSymGetModuleInfo64)
- ::GetProcAddress(hLib, "SymGetModuleInfo64");
- fSymFunctionTableAccess64 = (fpSymFunctionTableAccess64)
- ::GetProcAddress(hLib, "SymFunctionTableAccess64");
+ fMiniDumpWriteDump =
+ (fpMiniDumpWriteDump)::GetProcAddress(hLib, "MiniDumpWriteDump");
+ fStackWalk64 = (fpStackWalk64)::GetProcAddress(hLib, "StackWalk64");
+ fSymGetModuleBase64 =
+ (fpSymGetModuleBase64)::GetProcAddress(hLib, "SymGetModuleBase64");
+ fSymGetSymFromAddr64 =
+ (fpSymGetSymFromAddr64)::GetProcAddress(hLib, "SymGetSymFromAddr64");
+ fSymGetLineFromAddr64 =
+ (fpSymGetLineFromAddr64)::GetProcAddress(hLib, "SymGetLineFromAddr64");
+ fSymGetModuleInfo64 =
+ (fpSymGetModuleInfo64)::GetProcAddress(hLib, "SymGetModuleInfo64");
+ fSymFunctionTableAccess64 = (fpSymFunctionTableAccess64)::GetProcAddress(
+ hLib, "SymFunctionTableAccess64");
fSymSetOptions = (fpSymSetOptions)::GetProcAddress(hLib, "SymSetOptions");
fSymInitialize = (fpSymInitialize)::GetProcAddress(hLib, "SymInitialize");
- fEnumerateLoadedModules = (fpEnumerateLoadedModules)
- ::GetProcAddress(hLib, "EnumerateLoadedModules64");
+ fEnumerateLoadedModules = (fpEnumerateLoadedModules)::GetProcAddress(
+ hLib, "EnumerateLoadedModules64");
}
return isDebugHelpInitialized();
}
@@ -261,12 +263,11 @@ struct FindModuleData {
intptr_t *Offsets;
StringSaver *StrPool;
};
-}
+} // namespace
-static BOOL CALLBACK findModuleCallback(PCSTR ModuleName,
- DWORD64 ModuleBase, ULONG ModuleSize,
- void *VoidData) {
- FindModuleData *Data = (FindModuleData*)VoidData;
+static BOOL CALLBACK findModuleCallback(PCSTR ModuleName, DWORD64 ModuleBase,
+ ULONG ModuleSize, void *VoidData) {
+ FindModuleData *Data = (FindModuleData *)VoidData;
intptr_t Beg = ModuleBase;
intptr_t End = Beg + ModuleSize;
for (int I = 0; I < Data->Depth; I++) {
@@ -454,7 +455,7 @@ static void RegisterHandler() {
}
// The public API
-bool sys::RemoveFileOnSignal(StringRef Filename, std::string* ErrMsg) {
+bool sys::RemoveFileOnSignal(StringRef Filename, std::string *ErrMsg) {
RegisterHandler();
if (CleanupExecuted) {
@@ -482,7 +483,7 @@ void sys::DontRemoveFileOnSignal(StringRef Filename) {
std::vector<std::string>::reverse_iterator I =
find(reverse(*FilesToRemove), Filename);
if (I != FilesToRemove->rend())
- FilesToRemove->erase(I.base()-1);
+ FilesToRemove->erase(I.base() - 1);
LeaveCriticalSection(&CriticalSection);
}
@@ -519,7 +520,7 @@ void sys::PrintStackTraceOnErrorSignal(StringRef Argv0,
RegisterHandler();
LeaveCriticalSection(&CriticalSection);
}
-}
+} // namespace llvm
#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
// Provide a prototype for RtlCaptureContext, mingw32 from mingw.org is
@@ -697,8 +698,7 @@ static bool GetDumpType(HKEY Key, MINIDUMP_TYPE &ResultType) {
DWORD DumpType;
DWORD TypeSize = sizeof(DumpType);
if (ERROR_SUCCESS != ::RegGetValueW(Key, NULL, L"DumpType", RRF_RT_REG_DWORD,
- NULL, &DumpType,
- &TypeSize))
+ NULL, &DumpType, &TypeSize))
return false;
switch (DumpType) {
@@ -865,14 +865,14 @@ static BOOL WINAPI LLVMConsoleCtrlHandler(DWORD dwCtrlType) {
// If an interrupt function has been set, go and run one it; otherwise,
// the process dies.
void (*IF)() = InterruptFunction;
- InterruptFunction = 0; // Don't run it on another CTRL-C.
+ InterruptFunction = 0; // Don't run it on another CTRL-C.
if (IF) {
// Note: if the interrupt function throws an exception, there is nothing
// to catch it in this thread so it will kill the process.
- IF(); // Run it now.
+ IF(); // Run it now.
LeaveCriticalSection(&CriticalSection);
- return TRUE; // Don't kill the process.
+ return TRUE; // Don't kill the process.
}
// Allow normal processing to take place; i.e., the process dies.
@@ -881,12 +881,12 @@ static BOOL WINAPI LLVMConsoleCtrlHandler(DWORD dwCtrlType) {
}
#if __MINGW32__
- // We turned these warnings off for this file so that MinGW-g++ doesn't
- // complain about the ll format specifiers used. Now we are turning the
- // warnings back on. If MinGW starts to support diagnostic stacks, we can
- // replace this with a pop.
- #pragma GCC diagnostic warning "-Wformat"
- #pragma GCC diagnostic warning "-Wformat-extra-args"
+// We turned these warnings off for this file so that MinGW-g++ doesn't
+// complain about the ll format specifiers used. Now we are turning the
+// warnings back on. If MinGW starts to support diagnostic stacks, we can
+// replace this with a pop.
+#pragma GCC diagnostic warning "-Wformat"
+#pragma GCC diagnostic warning "-Wformat-extra-args"
#endif
void sys::unregisterHandlers() {}
diff --git a/llvm/lib/Support/Windows/ThreadLocal.inc b/llvm/lib/Support/Windows/ThreadLocal.inc
index 696e5c843ead4..900444d11b25c 100644
--- a/llvm/lib/Support/Windows/ThreadLocal.inc
+++ b/llvm/lib/Support/Windows/ThreadLocal.inc
@@ -1,4 +1,5 @@
-//= llvm/Support/Win32/ThreadLocal.inc - Win32 Thread Local Data -*- C++ -*-===//
+//= llvm/Support/Win32/ThreadLocal.inc - Win32 Thread Local Data -*- C++
+//-*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -15,37 +16,35 @@
//=== is guaranteed to work on *all* Win32 variants.
//===----------------------------------------------------------------------===//
-#include "llvm/Support/Windows/WindowsSupport.h"
#include "llvm/Support/ThreadLocal.h"
+#include "llvm/Support/Windows/WindowsSupport.h"
namespace llvm {
sys::ThreadLocalImpl::ThreadLocalImpl() : data() {
static_assert(sizeof(DWORD) <= sizeof(data), "size too big");
- DWORD* tls = reinterpret_cast<DWORD*>(&data);
+ DWORD *tls = reinterpret_cast<DWORD *>(&data);
*tls = TlsAlloc();
assert(*tls != TLS_OUT_OF_INDEXES);
}
sys::ThreadLocalImpl::~ThreadLocalImpl() {
- DWORD* tls = reinterpret_cast<DWORD*>(&data);
+ DWORD *tls = reinterpret_cast<DWORD *>(&data);
TlsFree(*tls);
}
void *sys::ThreadLocalImpl::getInstance() {
- DWORD* tls = reinterpret_cast<DWORD*>(&data);
+ DWORD *tls = reinterpret_cast<DWORD *>(&data);
return TlsGetValue(*tls);
}
-void sys::ThreadLocalImpl::setInstance(const void* d){
- DWORD* tls = reinterpret_cast<DWORD*>(&data);
- int errorcode = TlsSetValue(*tls, const_cast<void*>(d));
+void sys::ThreadLocalImpl::setInstance(const void *d) {
+ DWORD *tls = reinterpret_cast<DWORD *>(&data);
+ int errorcode = TlsSetValue(*tls, const_cast<void *>(d));
assert(errorcode != 0);
(void)errorcode;
}
-void sys::ThreadLocalImpl::removeInstance() {
- setInstance(0);
-}
+void sys::ThreadLocalImpl::removeInstance() { setInstance(0); }
-}
+} // namespace llvm
diff --git a/llvm/lib/Support/Windows/Threading.inc b/llvm/lib/Support/Windows/Threading.inc
index 7fa1937a2769b..22cc62d0415a5 100644
--- a/llvm/lib/Support/Windows/Threading.inc
+++ b/llvm/lib/Support/Windows/Threading.inc
@@ -49,19 +49,13 @@ void llvm_thread_detach_impl(HANDLE hThread) {
}
}
-DWORD llvm_thread_get_id_impl(HANDLE hThread) {
- return ::GetThreadId(hThread);
-}
+DWORD llvm_thread_get_id_impl(HANDLE hThread) { return ::GetThreadId(hThread); }
-DWORD llvm_thread_get_current_id_impl() {
- return ::GetCurrentThreadId();
-}
+DWORD llvm_thread_get_current_id_impl() { return ::GetCurrentThreadId(); }
} // namespace llvm
-uint64_t llvm::get_threadid() {
- return uint64_t(::GetCurrentThreadId());
-}
+uint64_t llvm::get_threadid() { return uint64_t(::GetCurrentThreadId()); }
uint32_t llvm::get_max_thread_name_length() { return 0; }
@@ -86,9 +80,8 @@ static void SetThreadName(DWORD Id, LPCSTR Name) {
__try {
::RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR),
- (ULONG_PTR *)&info);
- }
- __except (EXCEPTION_EXECUTE_HANDLER) {
+ (ULONG_PTR *)&info);
+ } __except (EXCEPTION_EXECUTE_HANDLER) {
}
}
#endif
diff --git a/llvm/lib/Support/Windows/Watchdog.inc b/llvm/lib/Support/Windows/Watchdog.inc
index a362c999de769..8086376582654 100644
--- a/llvm/lib/Support/Windows/Watchdog.inc
+++ b/llvm/lib/Support/Windows/Watchdog.inc
@@ -16,8 +16,8 @@
// and a second thread to run the TimerAPCProc.
namespace llvm {
- namespace sys {
- Watchdog::Watchdog(unsigned int seconds) {}
- Watchdog::~Watchdog() {}
- }
-}
+namespace sys {
+Watchdog::Watchdog(unsigned int seconds) {}
+Watchdog::~Watchdog() {}
+} // namespace sys
+} // namespace llvm
diff --git a/llvm/lib/Support/Windows/explicit_symbols.inc b/llvm/lib/Support/Windows/explicit_symbols.inc
index 0a4fda1d4e8c8..39c34f3f0b2d2 100644
--- a/llvm/lib/Support/Windows/explicit_symbols.inc
+++ b/llvm/lib/Support/Windows/explicit_symbols.inc
@@ -1,94 +1,94 @@
/* in libgcc.a */
#ifdef HAVE__ALLOCA
- EXPLICIT_SYMBOL(_alloca)
- EXPLICIT_SYMBOL2(alloca, _alloca)
+EXPLICIT_SYMBOL(_alloca)
+EXPLICIT_SYMBOL2(alloca, _alloca)
#endif
#ifdef HAVE___ALLOCA
- EXPLICIT_SYMBOL(__alloca)
+EXPLICIT_SYMBOL(__alloca)
#endif
#ifdef HAVE___CHKSTK
- EXPLICIT_SYMBOL(__chkstk)
+EXPLICIT_SYMBOL(__chkstk)
#endif
#ifdef HAVE___CHKSTK_MS
- EXPLICIT_SYMBOL(__chkstk_ms)
+EXPLICIT_SYMBOL(__chkstk_ms)
#endif
#ifdef HAVE____CHKSTK
- EXPLICIT_SYMBOL(___chkstk)
+EXPLICIT_SYMBOL(___chkstk)
#endif
#ifdef HAVE____CHKSTK_MS
- EXPLICIT_SYMBOL(___chkstk_ms)
+EXPLICIT_SYMBOL(___chkstk_ms)
#endif
#ifdef HAVE___MAIN
- EXPLICIT_SYMBOL(__main) // FIXME: Don't call it.
+EXPLICIT_SYMBOL(__main) // FIXME: Don't call it.
#endif
#ifdef HAVE___ASHLDI3
- EXPLICIT_SYMBOL(__ashldi3)
+EXPLICIT_SYMBOL(__ashldi3)
#endif
#ifdef HAVE___ASHRDI3
- EXPLICIT_SYMBOL(__ashrdi3)
+EXPLICIT_SYMBOL(__ashrdi3)
#endif
#ifdef HAVE___CMPDI2 // FIXME: unused
- EXPLICIT_SYMBOL(__cmpdi2)
+EXPLICIT_SYMBOL(__cmpdi2)
#endif
#ifdef HAVE___DIVDI3
- EXPLICIT_SYMBOL(__divdi3)
+EXPLICIT_SYMBOL(__divdi3)
#endif
#ifdef HAVE___FIXDFDI
- EXPLICIT_SYMBOL(__fixdfdi)
+EXPLICIT_SYMBOL(__fixdfdi)
#endif
#ifdef HAVE___FIXSFDI
- EXPLICIT_SYMBOL(__fixsfdi)
+EXPLICIT_SYMBOL(__fixsfdi)
#endif
#ifdef HAVE___FIXUNSDFDI
- EXPLICIT_SYMBOL(__fixunsdfdi)
+EXPLICIT_SYMBOL(__fixunsdfdi)
#endif
#ifdef HAVE___FIXUNSSFDI
- EXPLICIT_SYMBOL(__fixunssfdi)
+EXPLICIT_SYMBOL(__fixunssfdi)
#endif
#ifdef HAVE___FLOATDIDF
- EXPLICIT_SYMBOL(__floatdidf)
+EXPLICIT_SYMBOL(__floatdidf)
#endif
#ifdef HAVE___FLOATDISF
- EXPLICIT_SYMBOL(__floatdisf)
+EXPLICIT_SYMBOL(__floatdisf)
#endif
#ifdef HAVE___LSHRDI3
- EXPLICIT_SYMBOL(__lshrdi3)
+EXPLICIT_SYMBOL(__lshrdi3)
#endif
#ifdef HAVE___MODDI3
- EXPLICIT_SYMBOL(__moddi3)
+EXPLICIT_SYMBOL(__moddi3)
#endif
#ifdef HAVE___UDIVDI3
- EXPLICIT_SYMBOL(__udivdi3)
+EXPLICIT_SYMBOL(__udivdi3)
#endif
#ifdef HAVE___UMODDI3
- EXPLICIT_SYMBOL(__umoddi3)
+EXPLICIT_SYMBOL(__umoddi3)
#endif
/* msvcrt */
#if defined(_MSC_VER)
- EXPLICIT_SYMBOL2(alloca, _alloca_probe)
+EXPLICIT_SYMBOL2(alloca, _alloca_probe)
#ifdef _M_IX86
#define INLINE_DEF_FLOAT_SYMBOL(SYM, ARGC) INLINE_DEF_SYMBOL##ARGC(float, SYM)
- INLINE_DEF_FLOAT_SYMBOL(acosf, 1)
- INLINE_DEF_FLOAT_SYMBOL(asinf, 1)
- INLINE_DEF_FLOAT_SYMBOL(atanf, 1)
- INLINE_DEF_FLOAT_SYMBOL(atan2f, 2)
- INLINE_DEF_FLOAT_SYMBOL(ceilf, 1)
- INLINE_DEF_FLOAT_SYMBOL(cosf, 1)
- INLINE_DEF_FLOAT_SYMBOL(coshf, 1)
- INLINE_DEF_FLOAT_SYMBOL(expf, 1)
- INLINE_DEF_FLOAT_SYMBOL(floorf, 1)
- INLINE_DEF_FLOAT_SYMBOL(fmodf, 2)
- INLINE_DEF_FLOAT_SYMBOL(logf, 1)
- INLINE_DEF_FLOAT_SYMBOL(powf, 2)
- INLINE_DEF_FLOAT_SYMBOL(sinf, 1)
- INLINE_DEF_FLOAT_SYMBOL(sinhf, 1)
- INLINE_DEF_FLOAT_SYMBOL(sqrtf, 1)
- INLINE_DEF_FLOAT_SYMBOL(tanf, 1)
- INLINE_DEF_FLOAT_SYMBOL(tanhf, 1)
+INLINE_DEF_FLOAT_SYMBOL(acosf, 1)
+INLINE_DEF_FLOAT_SYMBOL(asinf, 1)
+INLINE_DEF_FLOAT_SYMBOL(atanf, 1)
+INLINE_DEF_FLOAT_SYMBOL(atan2f, 2)
+INLINE_DEF_FLOAT_SYMBOL(ceilf, 1)
+INLINE_DEF_FLOAT_SYMBOL(cosf, 1)
+INLINE_DEF_FLOAT_SYMBOL(coshf, 1)
+INLINE_DEF_FLOAT_SYMBOL(expf, 1)
+INLINE_DEF_FLOAT_SYMBOL(floorf, 1)
+INLINE_DEF_FLOAT_SYMBOL(fmodf, 2)
+INLINE_DEF_FLOAT_SYMBOL(logf, 1)
+INLINE_DEF_FLOAT_SYMBOL(powf, 2)
+INLINE_DEF_FLOAT_SYMBOL(sinf, 1)
+INLINE_DEF_FLOAT_SYMBOL(sinhf, 1)
+INLINE_DEF_FLOAT_SYMBOL(sqrtf, 1)
+INLINE_DEF_FLOAT_SYMBOL(tanf, 1)
+INLINE_DEF_FLOAT_SYMBOL(tanhf, 1)
#undef INLINE_DEF_FLOAT_SYMBOL
#endif
More information about the llvm-commits
mailing list