Fix Clang-tidy modernize-deprecated-headers warnings in remaining files; other minor fixes.

Some Include What You Use suggestions were used too.

Use anonymous namespaces in source files.

Differential revision: http://reviews.llvm.org/D18778

llvm-svn: 265454
diff --git a/llvm/lib/Support/Unix/Process.inc b/llvm/lib/Support/Unix/Process.inc
index cad81f8..350b145 100644
--- a/llvm/lib/Support/Unix/Process.inc
+++ b/llvm/lib/Support/Unix/Process.inc
@@ -30,9 +30,7 @@
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
-#if HAVE_SIGNAL_H
-#include <signal.h>
-#endif
+#include <csignal>
 // DragonFlyBSD, OpenBSD, and Bitrig have deprecated <malloc.h> for
 // <stdlib.h> instead. Unix.h includes this for us already.
 #if defined(HAVE_MALLOC_H) && !defined(__DragonFly__) && \
@@ -60,7 +58,9 @@
 using namespace llvm;
 using namespace sys;
 
-static std::pair<TimeValue, TimeValue> getRUsageTimes() {
+namespace {
+
+std::pair<TimeValue, TimeValue> getRUsageTimes() {
 #if defined(HAVE_GETRUSAGE)
   struct rusage RU;
   ::getrusage(RUSAGE_SELF, &RU);
@@ -79,6 +79,8 @@
 #endif
 }
 
+} // end anonymous namespace
+
 // On Cygwin, getpagesize() returns 64k(AllocationGranularity) and
 // offset in mmap(3) should be aligned to the AllocationGranularity.
 unsigned Process::getPageSize() {
@@ -189,6 +191,7 @@
 }
 
 namespace {
+
 class FDCloser {
 public:
   FDCloser(int &FD) : FD(FD), KeepOpen(false) {}
@@ -205,7 +208,8 @@
   int &FD;
   bool KeepOpen;
 };
-}
+
+} // end anonymous namespace
 
 std::error_code Process::FixupStandardFileDescriptors() {
   int NullFD = -1;
@@ -300,7 +304,9 @@
 #endif
 }
 
-static unsigned getColumns(int FileID) {
+namespace {
+
+unsigned getColumns(int FileID) {
   // If COLUMNS is defined in the environment, wrap to that many columns.
   if (const char *ColumnsStr = std::getenv("COLUMNS")) {
     int Columns = std::atoi(ColumnsStr);
@@ -320,6 +326,8 @@
   return Columns;
 }
 
+} // end anonymous namespace
+
 unsigned Process::StandardOutColumns() {
   if (!StandardOutIsDisplayed())
     return 0;
@@ -344,11 +352,13 @@
 extern "C" int tigetnum(char *capname);
 #endif
 
+namespace {
+
 #ifdef HAVE_TERMINFO
-static ManagedStatic<sys::Mutex> TermColorMutex;
+ManagedStatic<sys::Mutex> TermColorMutex;
 #endif
 
-static bool terminalHasColors(int fd) {
+bool terminalHasColors(int fd) {
 #ifdef HAVE_TERMINFO
   // First, acquire a global lock because these C routines are thread hostile.
   MutexGuard G(*TermColorMutex);
@@ -388,6 +398,8 @@
   return false;
 }
 
+} // end anonymous namespace
+
 bool Process::FileDescriptorHasColors(int fd) {
   // A file descriptor has colors if it is displayed and the terminal has
   // colors.
@@ -428,7 +440,10 @@
 }
 
 #if !defined(HAVE_DECL_ARC4RANDOM) || !HAVE_DECL_ARC4RANDOM
-static unsigned GetRandomNumberSeed() {
+
+namespace {
+
+unsigned GetRandomNumberSeed() {
   // Attempt to get the initial seed from /dev/urandom, if possible.
   int urandomFD = open("/dev/urandom", O_RDONLY);
 
@@ -450,6 +465,9 @@
   TimeValue Now = TimeValue::now();
   return hash_combine(Now.seconds(), Now.nanoseconds(), ::getpid());
 }
+
+} // end anonymous namespace
+
 #endif
 
 unsigned llvm::sys::Process::GetRandomNumber() {