Index: libc/src/ctype/ctype_utils.h
===================================================================
--- libc/src/ctype/ctype_utils.h
+++ libc/src/ctype/ctype_utils.h
@@ -18,17 +18,19 @@
 // of a function call by inlining them.
 // ------------------------------------------------------
 
-static inline int isalpha(unsigned ch) { return (ch | 32) - 'a' < 26; }
+static inline int isalpha(unsigned char ch) { return (ch | 32) - 'a' < 26; }
 
-static inline int isdigit(unsigned ch) { return (ch - '0') < 10; }
+static inline int isdigit(unsigned char ch) { return (ch - '0') < 10; }
 
-static inline int isalnum(unsigned ch) { return isalpha(ch) || isdigit(ch); }
+static inline int isalnum(unsigned char ch) {
+  return isalpha(ch) || isdigit(ch);
+}
 
-static inline int isgraph(unsigned ch) { return 0x20 < ch && ch < 0x7f; }
+static inline int isgraph(unsigned char ch) { return 0x20 < ch && ch < 0x7f; }
 
-static inline int islower(unsigned ch) { return (ch - 'a') < 26; }
+static inline int islower(unsigned char ch) { return (ch - 'a') < 26; }
 
-static inline int isupper(unsigned ch) { return (ch - 'A') < 26; }
+static inline int isupper(unsigned char ch) { return (ch - 'A') < 26; }
 
 } // namespace internal
 } // namespace __llvm_libc
Index: libc/src/ctype/isalnum.cpp
===================================================================
--- libc/src/ctype/isalnum.cpp
+++ libc/src/ctype/isalnum.cpp
@@ -15,6 +15,8 @@
 
 // TODO: Currently restricted to default locale.
 // These should be extended using locale information.
-LLVM_LIBC_FUNCTION(int, isalnum, (int c)) { return internal::isalnum(c); }
+LLVM_LIBC_FUNCTION(int, isalnum, (int c)) {
+  return internal::isalnum(static_cast<unsigned char>(c));
+}
 
 } // namespace __llvm_libc
Index: libc/src/ctype/isalpha.cpp
===================================================================
--- libc/src/ctype/isalpha.cpp
+++ libc/src/ctype/isalpha.cpp
@@ -15,6 +15,8 @@
 
 // TODO: Currently restricted to default locale.
 // These should be extended using locale information.
-LLVM_LIBC_FUNCTION(int, isalpha, (int c)) { return internal::isalpha(c); }
+LLVM_LIBC_FUNCTION(int, isalpha, (int c)) {
+  return internal::isalpha(static_cast<unsigned char>(c));
+}
 
 } // namespace __llvm_libc
Index: libc/src/ctype/isblank.cpp
===================================================================
--- libc/src/ctype/isblank.cpp
+++ libc/src/ctype/isblank.cpp
@@ -15,7 +15,7 @@
 // TODO: Currently restricted to default locale.
 // These should be extended using locale information.
 LLVM_LIBC_FUNCTION(int, isblank, (int c)) {
-  const unsigned char ch = static_cast<char>(c);
+  const unsigned char ch = static_cast<unsigned char>(c);
   return ch == ' ' || ch == '\t';
 }
 
Index: libc/src/ctype/iscntrl.cpp
===================================================================
--- libc/src/ctype/iscntrl.cpp
+++ libc/src/ctype/iscntrl.cpp
@@ -15,7 +15,7 @@
 // TODO: Currently restricted to default locale.
 // These should be extended using locale information.
 LLVM_LIBC_FUNCTION(int, iscntrl, (int c)) {
-  const unsigned char ch = static_cast<char>(c);
+  const unsigned char ch = static_cast<unsigned char>(c);
   return ch < 0x20 || ch == 0x7f;
 }
 
Index: libc/src/ctype/isdigit.cpp
===================================================================
--- libc/src/ctype/isdigit.cpp
+++ libc/src/ctype/isdigit.cpp
@@ -14,6 +14,8 @@
 
 // TODO: Currently restricted to default locale.
 // These should be extended using locale information.
-LLVM_LIBC_FUNCTION(int, isdigit, (int c)) { return internal::isdigit(c); }
+LLVM_LIBC_FUNCTION(int, isdigit, (int c)) {
+  return internal::isdigit(static_cast<unsigned char>(c));
+}
 
 } // namespace __llvm_libc
Index: libc/src/ctype/isgraph.cpp
===================================================================
--- libc/src/ctype/isgraph.cpp
+++ libc/src/ctype/isgraph.cpp
@@ -15,6 +15,8 @@
 
 // TODO: Currently restricted to default locale.
 // These should be extended using locale information.
-LLVM_LIBC_FUNCTION(int, isgraph, (int c)) { return internal::isgraph(c); }
+LLVM_LIBC_FUNCTION(int, isgraph, (int c)) {
+  return internal::isgraph(static_cast<unsigned char>(c));
+}
 
 } // namespace __llvm_libc
Index: libc/src/ctype/islower.cpp
===================================================================
--- libc/src/ctype/islower.cpp
+++ libc/src/ctype/islower.cpp
@@ -15,6 +15,8 @@
 
 // TODO: Currently restricted to default locale.
 // These should be extended using locale information.
-LLVM_LIBC_FUNCTION(int, islower, (int c)) { return internal::islower(c); }
+LLVM_LIBC_FUNCTION(int, islower, (int c)) {
+  return internal::islower(static_cast<unsigned char>(c));
+}
 
 } // namespace __llvm_libc
Index: libc/src/ctype/isprint.cpp
===================================================================
--- libc/src/ctype/isprint.cpp
+++ libc/src/ctype/isprint.cpp
@@ -15,7 +15,7 @@
 // TODO: Currently restricted to default locale.
 // These should be extended using locale information.
 LLVM_LIBC_FUNCTION(int, isprint, (int c)) {
-  const unsigned ch = c;
+  const unsigned char ch = static_cast<unsigned char>(c);
   return (ch - ' ') < 95;
 }
 
Index: libc/src/ctype/ispunct.cpp
===================================================================
--- libc/src/ctype/ispunct.cpp
+++ libc/src/ctype/ispunct.cpp
@@ -16,7 +16,8 @@
 // TODO: Currently restricted to default locale.
 // These should be extended using locale information.
 LLVM_LIBC_FUNCTION(int, ispunct, (int c)) {
-  return !internal::isalnum(c) && internal::isgraph(c);
+  const unsigned char ch = static_cast<unsigned char>(c);
+  return !internal::isalnum(ch) && internal::isgraph(ch);
 }
 
 } // namespace __llvm_libc
Index: libc/src/ctype/isspace.cpp
===================================================================
--- libc/src/ctype/isspace.cpp
+++ libc/src/ctype/isspace.cpp
@@ -15,7 +15,7 @@
 // TODO: Currently restricted to default locale.
 // These should be extended using locale information.
 LLVM_LIBC_FUNCTION(int, isspace, (int c)) {
-  const unsigned ch = c;
+  const unsigned char ch = static_cast<unsigned char>(c);
   return ch == ' ' || (ch - '\t') < 5;
 }
 
Index: libc/src/ctype/isupper.cpp
===================================================================
--- libc/src/ctype/isupper.cpp
+++ libc/src/ctype/isupper.cpp
@@ -15,6 +15,8 @@
 
 // TODO: Currently restricted to default locale.
 // These should be extended using locale information.
-LLVM_LIBC_FUNCTION(int, isupper, (int c)) { return internal::isupper(c); }
+LLVM_LIBC_FUNCTION(int, isupper, (int c)) {
+  return internal::isupper(static_cast<unsigned char>(c));
+}
 
 } // namespace __llvm_libc
Index: libc/src/ctype/isxdigit.cpp
===================================================================
--- libc/src/ctype/isxdigit.cpp
+++ libc/src/ctype/isxdigit.cpp
@@ -16,7 +16,7 @@
 // TODO: Currently restricted to default locale.
 // These should be extended using locale information.
 LLVM_LIBC_FUNCTION(int, isxdigit, (int c)) {
-  const unsigned ch = c;
+  const unsigned char ch = static_cast<unsigned char>(c);
   return internal::isdigit(ch) || (ch | 32) - 'a' < 6;
 }
 
Index: libc/src/ctype/tolower.cpp
===================================================================
--- libc/src/ctype/tolower.cpp
+++ libc/src/ctype/tolower.cpp
@@ -16,7 +16,7 @@
 // TODO: Currently restricted to default locale.
 // These should be extended using locale information.
 LLVM_LIBC_FUNCTION(int, tolower, (int c)) {
-  if (internal::isupper(c))
+  if (internal::isupper(static_cast<unsigned char>(c)))
     return c + 'a' - 'A';
   return c;
 }
Index: libc/src/ctype/toupper.cpp
===================================================================
--- libc/src/ctype/toupper.cpp
+++ libc/src/ctype/toupper.cpp
@@ -16,7 +16,7 @@
 // TODO: Currently restricted to default locale.
 // These should be extended using locale information.
 LLVM_LIBC_FUNCTION(int, toupper, (int c)) {
-  if (internal::islower(c))
+  if (internal::islower(static_cast<unsigned char>(c)))
     return c + 'A' - 'a';
   return c;
 }
Index: llvm/tools/llvm-cvtres/llvm-cvtres.cpp
===================================================================
--- llvm/tools/llvm-cvtres/llvm-cvtres.cpp
+++ llvm/tools/llvm-cvtres/llvm-cvtres.cpp
@@ -67,7 +67,7 @@
 };
 }
 
-static LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg) {
+LLVM_ATTRIBUTE_NORETURN static void reportError(Twine Msg) {
   errs() << Msg;
   exit(1);
 }
Index: mlir/lib/Interfaces/DataLayoutInterfaces.cpp
===================================================================
--- mlir/lib/Interfaces/DataLayoutInterfaces.cpp
+++ mlir/lib/Interfaces/DataLayoutInterfaces.cpp
@@ -23,7 +23,7 @@
 
 /// Reports that the given type is missing the data layout information and
 /// exits.
-static LLVM_ATTRIBUTE_NORETURN void reportMissingDataLayout(Type type) {
+LLVM_ATTRIBUTE_NORETURN static void reportMissingDataLayout(Type type) {
   std::string message;
   llvm::raw_string_ostream os(message);
   os << "neither the scoping op nor the type class provide data layout "