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

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

llvm-svn: 264598
diff --git a/llvm/include/llvm-c/Disassembler.h b/llvm/include/llvm-c/Disassembler.h
index d6cbe31..d6f92e5 100644
--- a/llvm/include/llvm-c/Disassembler.h
+++ b/llvm/include/llvm-c/Disassembler.h
@@ -16,7 +16,11 @@
 #define LLVM_C_DISASSEMBLER_H
 
 #include "llvm/Support/DataTypes.h"
+#ifdef __cplusplus
+#include <cstddef>
+#else
 #include <stddef.h>
+#endif
 
 /**
  * @defgroup LLVMCDisassembler Disassembler
@@ -251,4 +255,4 @@
 }
 #endif /* !defined(__cplusplus) */
 
-#endif /* !defined(LLVM_C_DISASSEMBLER_H) */
+#endif /* LLVM_C_DISASSEMBLER_H */
diff --git a/llvm/include/llvm-c/lto.h b/llvm/include/llvm-c/lto.h
index 88b10fd..42c2802 100644
--- a/llvm/include/llvm-c/lto.h
+++ b/llvm/include/llvm-c/lto.h
@@ -16,7 +16,11 @@
 #ifndef LLVM_C_LTO_H
 #define LLVM_C_LTO_H
 
+#ifdef __cplusplus
+#include <cstddef>
+#else
 #include <stddef.h>
+#endif
 #include <sys/types.h>
 
 #ifndef __cplusplus
@@ -105,7 +109,6 @@
 extern const char*
 lto_get_version(void);
 
-
 /**
  * Returns the last error string or NULL if last operation was successful.
  *
@@ -122,7 +125,6 @@
 extern lto_bool_t
 lto_module_is_object_file(const char* path);
 
-
 /**
  * Checks if a file is a loadable object compiled for requested target.
  *
@@ -132,7 +134,6 @@
 lto_module_is_object_file_for_target(const char* path,
                                      const char* target_triple_prefix);
 
-
 /**
  * Checks if a buffer is a loadable object file.
  *
@@ -141,7 +142,6 @@
 extern lto_bool_t
 lto_module_is_object_file_in_memory(const void* mem, size_t length);
 
-
 /**
  * Checks if a buffer is a loadable object compiled for requested target.
  *
@@ -151,7 +151,6 @@
 lto_module_is_object_file_in_memory_for_target(const void* mem, size_t length,
                                               const char* target_triple_prefix);
 
-
 /**
  * Loads an object file from disk.
  * Returns NULL on error (check lto_get_error_message() for details).
@@ -161,7 +160,6 @@
 extern lto_module_t
 lto_module_create(const char* path);
 
-
 /**
  * Loads an object file from memory.
  * Returns NULL on error (check lto_get_error_message() for details).
@@ -254,7 +252,6 @@
 extern void
 lto_module_set_target_triple(lto_module_t mod, const char *triple);
 
-
 /**
  * Returns the number of symbols in the object module.
  *
@@ -263,7 +260,6 @@
 extern unsigned int
 lto_module_get_num_symbols(lto_module_t mod);
 
-
 /**
  * Returns the name of the ith symbol in the object module.
  *
@@ -272,7 +268,6 @@
 extern const char*
 lto_module_get_symbol_name(lto_module_t mod, unsigned int index);
 
-
 /**
  * Returns the attributes of the ith symbol in the object module.
  *
@@ -281,7 +276,6 @@
 extern lto_symbol_attributes
 lto_module_get_symbol_attribute(lto_module_t mod, unsigned int index);
 
-
 /**
  * Returns the module's linker options.
  *
@@ -293,7 +287,6 @@
 extern const char*
 lto_module_get_linkeropts(lto_module_t mod);
 
-
 /**
  * Diagnostic severity.
  *
@@ -395,7 +388,6 @@
 extern lto_bool_t
 lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model);
 
-
 /**
  * Sets which PIC code model to generated.
  * Returns true on error (check lto_get_error_message() for details).
@@ -405,7 +397,6 @@
 extern lto_bool_t
 lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model);
 
-
 /**
  * Sets the cpu to generate code for.
  *
@@ -414,7 +405,6 @@
 extern void
 lto_codegen_set_cpu(lto_code_gen_t cg, const char *cpu);
 
-
 /**
  * Sets the location of the assembler tool to run. If not set, libLTO
  * will use gcc to invoke the assembler.
@@ -773,4 +763,4 @@
  * @}
  */
 
-#endif
+#endif /* LLVM_C_LTO_H */
diff --git a/llvm/include/llvm/ADT/Statistic.h b/llvm/include/llvm/ADT/Statistic.h
index 7c84e3e..57e7253 100644
--- a/llvm/include/llvm/ADT/Statistic.h
+++ b/llvm/include/llvm/ADT/Statistic.h
@@ -27,7 +27,7 @@
 #define LLVM_ADT_STATISTIC_H
 
 #include "llvm/Support/Atomic.h"
-#include "llvm/Support/Valgrind.h"
+#include "llvm/Support/Compiler.h"
 #include <memory>
 
 namespace llvm {
@@ -181,6 +181,6 @@
 /// \brief Print statistics to the given output stream.
 void PrintStatistics(raw_ostream &OS);
 
-} // End llvm namespace
+} // end llvm namespace
 
-#endif
+#endif // LLVM_ADT_STATISTIC_H
diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h b/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h
index adec27a..7e39beb 100644
--- a/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h
+++ b/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h
@@ -14,7 +14,8 @@
 #include "llvm/DebugInfo/CodeView/CodeView.h"
 #include "llvm/Support/Endian.h"
 #include <functional>
-#include <stdint.h>
+#include <cstdint>
+#include <cstring>
 
 namespace llvm {
 
@@ -382,9 +383,11 @@
     uint64_t UInt64;
     char *String;
   } Value;
+
 #define VARIANT_EQUAL_CASE(Enum)                                               \
   case PDB_VariantType::Enum:                                                  \
     return Value.Enum == Other.Value.Enum;
+
   bool operator==(const Variant &Other) const {
     if (Type != Other.Type)
       return false;
@@ -405,7 +408,9 @@
       return true;
     }
   }
+
 #undef VARIANT_EQUAL_CASE
+
   bool operator!=(const Variant &Other) const { return !(*this == Other); }
   Variant &operator=(const Variant &Other) {
     if (this == &Other)
@@ -450,9 +455,9 @@
   // This contains the block # of the block map.
   support::ulittle32_t BlockMapAddr;
 };
-}
+} // end namespace PDB
 
-} // namespace llvm
+} // end namespace llvm
 
 namespace std {
 template <> struct hash<llvm::PDB_SymType> {
@@ -463,7 +468,6 @@
     return std::hash<int>()(static_cast<int>(Arg));
   }
 };
-}
+} // end namespace std
 
-
-#endif
+#endif // LLVM_DEBUGINFO_PDB_PDBTYPES_H
diff --git a/llvm/include/llvm/Support/DataTypes.h.cmake b/llvm/include/llvm/Support/DataTypes.h.cmake
index cccd0bc..71aa1ea 100644
--- a/llvm/include/llvm/Support/DataTypes.h.cmake
+++ b/llvm/include/llvm/Support/DataTypes.h.cmake
@@ -35,15 +35,23 @@
 #include <math.h>
 #endif
 
+#ifdef __cplusplus
+#include <cinttypes>
+#else
 #ifdef HAVE_INTTYPES_H
 #include <inttypes.h>
 #endif
+#endif
 
+#ifdef __cplusplus
+#include <cstdint>
+#else
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
 #else
 #error "Compiler must provide an implementation of stdint.h"
 #endif
+#endif
 
 #ifndef _MSC_VER
 
@@ -79,14 +87,14 @@
 #endif
 
 #else /* _MSC_VER */
+#ifdef __cplusplus
+#include <cstdlib>
+#include <cstddef>
+#else
 #include <stdlib.h>
 #include <stddef.h>
-#include <sys/types.h>
-#ifdef __cplusplus
-#include <cmath>
-#else
-#include <math.h>
 #endif
+#include <sys/types.h>
 
 #if defined(_WIN64)
 typedef signed __int64 ssize_t;
@@ -127,4 +135,4 @@
 #define HUGE_VALF (float)HUGE_VAL
 #endif
 
-#endif  /* SUPPORT_DATATYPES_H */
+#endif /* SUPPORT_DATATYPES_H */
diff --git a/llvm/include/llvm/Support/Valgrind.h b/llvm/include/llvm/Support/Valgrind.h
index 12b0dc9..084b901 100644
--- a/llvm/include/llvm/Support/Valgrind.h
+++ b/llvm/include/llvm/Support/Valgrind.h
@@ -1,4 +1,4 @@
-//===- llvm/Support/Valgrind.h - Communication with Valgrind -----*- C++ -*-===//
+//===- llvm/Support/Valgrind.h - Communication with Valgrind ----*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -16,9 +16,7 @@
 #ifndef LLVM_SUPPORT_VALGRIND_H
 #define LLVM_SUPPORT_VALGRIND_H
 
-#include "llvm/Config/llvm-config.h"
-#include "llvm/Support/Compiler.h"
-#include <stddef.h>
+#include <cstddef>
 
 namespace llvm {
 namespace sys {
@@ -28,7 +26,7 @@
   // Discard valgrind's translation of code in the range [Addr .. Addr + Len).
   // Otherwise valgrind may continue to execute the old version of the code.
   void ValgrindDiscardTranslations(const void *Addr, size_t Len);
-}
-}
+} // namespace sys
+} // end namespace llvm
 
-#endif
+#endif // LLVM_SUPPORT_VALGRIND_H
diff --git a/llvm/include/llvm/Target/TargetCallingConv.h b/llvm/include/llvm/Target/TargetCallingConv.h
index 0c6c1f1..e906f1c 100644
--- a/llvm/include/llvm/Target/TargetCallingConv.h
+++ b/llvm/include/llvm/Target/TargetCallingConv.h
@@ -18,7 +18,7 @@
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/MathExtras.h"
 #include <string>
-#include <limits.h>
+#include <limits>
 
 namespace llvm {
 
@@ -60,6 +60,7 @@
     static const uint64_t One            = 1ULL; ///< 1 of this type, for shifts
 
     uint64_t Flags;
+
   public:
     ArgFlagsTy() : Flags(0) { }
 
@@ -141,7 +142,7 @@
     /// Index original Function's argument.
     unsigned OrigArgIndex;
     /// Sentinel value for implicit machine-level input arguments.
-    static const unsigned NoArgIndex = UINT_MAX;
+    static const unsigned NoArgIndex = std::numeric_limits<uint32_t>::max();
 
     /// Offset in bytes of current input value relative to the beginning of
     /// original argument. E.g. if argument was splitted into four 32 bit
@@ -195,8 +196,8 @@
       ArgVT = argvt;
     }
   };
-}
+} // end namespace ISD
 
 } // end llvm namespace
 
-#endif
+#endif // LLVM_TARGET_TARGETCALLINGCONV_H
diff --git a/llvm/include/llvm/Transforms/IPO/LowerBitSets.h b/llvm/include/llvm/Transforms/IPO/LowerBitSets.h
index e5fb7b98..4810e0b 100644
--- a/llvm/include/llvm/Transforms/IPO/LowerBitSets.h
+++ b/llvm/include/llvm/Transforms/IPO/LowerBitSets.h
@@ -18,7 +18,8 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
 
-#include <stdint.h>
+#include <cstdint>
+#include <cstring>
 #include <limits>
 #include <set>
 #include <vector>
@@ -196,6 +197,6 @@
                 uint64_t &AllocByteOffset, uint8_t &AllocMask);
 };
 
-} // namespace llvm
+} // end namespace llvm
 
-#endif
+#endif // LLVM_TRANSFORMS_IPO_LOWERBITSETS_H
diff --git a/llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h b/llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h
index e544bc6..0ac3f66 100644
--- a/llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h
+++ b/llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h
@@ -16,11 +16,10 @@
 #define LLVM_TRANSFORMS_IPO_WHOLEPROGRAMDEVIRT_H
 
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/DenseMapInfo.h"
+#include <cassert>
+#include <cstdint>
 #include <utility>
 #include <vector>
-#include <assert.h>
-#include <stdint.h>
 
 namespace llvm {
 
@@ -209,7 +208,7 @@
                           uint64_t AllocAfter, unsigned BitWidth,
                           int64_t &OffsetByte, uint64_t &OffsetBit);
 
-}
-}
+} // end namespace wholeprogramdevirt
+} // end namespace llvm
 
-#endif
+#endif // LLVM_TRANSFORMS_IPO_WHOLEPROGRAMDEVIRT_H