1diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp
2index 99c7b8e6..f9a57b25 100644
3--- a/clang/lib/Driver/ToolChains.cpp
4+++ b/clang/lib/Driver/ToolChains.cpp
5@@ -1241,20 +1241,31 @@ Generic_GCC::GCCVersion Linux::GCCVersion::Parse(StringRef VersionText) {
6   if (First.first.getAsInteger(10, GoodVersion.Major) || GoodVersion.Major < 0)
7     return BadVersion;
8   GoodVersion.MajorStr = First.first.str();
9-  if (Second.first.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 0)
10+  if (First.second.empty())
11+    return GoodVersion;
12+  StringRef MinorStr = Second.first;
13+  if (Second.second.empty()) {
14+    if (size_t EndNumber = MinorStr.find_first_not_of("0123456789")) {
15+      GoodVersion.PatchSuffix = MinorStr.substr(EndNumber);
16+      MinorStr = MinorStr.slice(0, EndNumber);
17+    }
18+  }
19+  if (MinorStr.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 0)
20     return BadVersion;
21-  GoodVersion.MinorStr = Second.first.str();
22+  GoodVersion.MinorStr = MinorStr.str();
23
24   // First look for a number prefix and parse that if present. Otherwise just
25   // stash the entire patch string in the suffix, and leave the number
26   // unspecified. This covers versions strings such as:
27+  //   5        (handled above)
28   //   4.4
29+  //   4.4-patched
30   //   4.4.0
31   //   4.4.x
32   //   4.4.2-rc4
33   //   4.4.x-patched
34   // And retains any patch number it finds.
35-  StringRef PatchText = GoodVersion.PatchSuffix = Second.second.str();
36+  StringRef PatchText = Second.second.str();
37   if (!PatchText.empty()) {
38     if (size_t EndNumber = PatchText.find_first_not_of("0123456789")) {
39       // Try to parse the number and any suffix.
40diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
41index 70799663..b9ca8b9d 100644
42--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
43+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
44@@ -565,8 +565,7 @@ uptr internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr arg5) {
45 }
46 #endif
47
48-uptr internal_sigaltstack(const struct sigaltstack *ss,
49-                         struct sigaltstack *oss) {
50+uptr internal_sigaltstack(const void *ss, void *oss) {
51   return internal_syscall(SYSCALL(sigaltstack), (uptr)ss, (uptr)oss);
52 }
53
54diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.h b/compiler-rt/lib/sanitizer_common/sanitizer_linux.h
55index 77bfbd15..5572793e 100644
56--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.h
57+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.h
58@@ -21,7 +21,6 @@
59 #include "sanitizer_platform_limits_posix.h"
60
61 struct link_map;  // Opaque type returned by dlopen().
62-struct sigaltstack;
63
64 namespace __sanitizer {
65 // Dirent structure for getdents(). Note that this structure is different from
66@@ -30,8 +29,7 @@ struct linux_dirent;
67
68 // Syscall wrappers.
69 uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count);
70-uptr internal_sigaltstack(const struct sigaltstack* ss,
71-                          struct sigaltstack* oss);
72+uptr internal_sigaltstack(const void* ss, void* oss);
73 uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set,
74     __sanitizer_sigset_t *oldset);
75 void internal_sigfillset(__sanitizer_sigset_t *set);
76diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
77index d1e2f6ac..2df7be58 100644
78--- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
79+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
80@@ -272,7 +272,7 @@ static int TracerThread(void* argument) {
81
82   // Alternate stack for signal handling.
83   InternalScopedBuffer<char> handler_stack_memory(kHandlerStackSize);
84-  struct sigaltstack handler_stack;
85+  stack_t handler_stack;
86   internal_memset(&handler_stack, 0, sizeof(handler_stack));
87   handler_stack.ss_sp = handler_stack_memory.data();
88   handler_stack.ss_size = kHandlerStackSize;
89diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc
90index 66025611..98a5b135 100644
91--- a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc
92+++ b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc
93@@ -311,7 +311,7 @@ bool IsGlobalVar(uptr addr) {
94 int ExtractResolvFDs(void *state, int *fds, int nfd) {
95 #if SANITIZER_LINUX && !SANITIZER_ANDROID
96   int cnt = 0;
97-  __res_state *statp = (__res_state*)state;
98+  struct __res_state *statp = (struct __res_state*)state;
99   for (int i = 0; i < MAXNS && cnt < nfd; i++) {
100     if (statp->_u._ext.nsaddrs[i] && statp->_u._ext.nssocks[i] != -1)
101       fds[cnt++] = statp->_u._ext.nssocks[i];
102diff --git a/libcxx/include/__locale b/libcxx/include/__locale
103index 7bc701dd..ae0372fe 100644
104--- a/libcxx/include/__locale
105+++ b/libcxx/include/__locale
106@@ -34,7 +34,7 @@
107 # include <support/solaris/xlocale.h>
108 #elif defined(_NEWLIB_VERSION)
109 # include <support/newlib/xlocale.h>
110-#elif (defined(__GLIBC__) || defined(__APPLE__)      || defined(__FreeBSD__) \
111+#elif (defined(__APPLE__)      || defined(__FreeBSD__) \
112     || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
113 # include <xlocale.h>
114 #elif defined(_LIBCPP_HAS_MUSL_LIBC)
115diff --git a/llvm/include/llvm/IR/ValueMap.h b/llvm/include/llvm/IR/ValueMap.h
116index ad518ac0..d928f6a2 100644
117--- a/llvm/include/llvm/IR/ValueMap.h
118+++ b/llvm/include/llvm/IR/ValueMap.h
119@@ -99,7 +99,7 @@ public:
120   explicit ValueMap(const ExtraData &Data, unsigned NumInitBuckets = 64)
121       : Map(NumInitBuckets), Data(Data) {}
122
123-  bool hasMD() const { return MDMap; }
124+  bool hasMD() const { return static_cast<bool>(MDMap); }
125   MDMapT &MD() {
126     if (!MDMap)
127       MDMap.reset(new MDMapT);