[libc-commits] [PATCH] D106807: [libc] Add noreturn and constexpr qualifiers to appropriate C lib functions
Alf via Phabricator via libc-commits
libc-commits at lists.llvm.org
Tue Jul 27 11:55:20 PDT 2021
gAlfonso-bit updated this revision to Diff 362125.
gAlfonso-bit added a comment.
Moved ctype function changes to its own diff. This diff now has every requested change!
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106807/new/
https://reviews.llvm.org/D106807
Files:
libc/src/__support/integer_operations.h
libc/src/ctype/ctype_utils.h
libc/utils/HdrGen/Command.h
Index: libc/utils/HdrGen/Command.h
===================================================================
--- libc/utils/HdrGen/Command.h
+++ libc/utils/HdrGen/Command.h
@@ -36,7 +36,7 @@
public:
ErrorReporter(llvm::SMLoc L, llvm::SourceMgr &SM) : Loc(L), SrcMgr(SM) {}
- void printFatalError(llvm::Twine Msg) const {
+ [[noreturn]] void printFatalError(llvm::Twine Msg) const {
SrcMgr.PrintMessage(Loc, llvm::SourceMgr::DK_Error, Msg);
std::exit(1);
}
Index: libc/src/ctype/ctype_utils.h
===================================================================
--- libc/src/ctype/ctype_utils.h
+++ libc/src/ctype/ctype_utils.h
@@ -18,17 +18,17 @@
// of a function call by inlining them.
// ------------------------------------------------------
-static inline int isalpha(unsigned ch) { return (ch | 32) - 'a' < 26; }
+static constexpr int isalpha(unsigned ch) { return (ch | 32) - 'a' < 26; }
-static inline int isdigit(unsigned ch) { return (ch - '0') < 10; }
+static constexpr int isdigit(unsigned ch) { return (ch - '0') < 10; }
-static inline int isalnum(unsigned ch) { return isalpha(ch) || isdigit(ch); }
+static constexpr int isalnum(unsigned ch) { return isalpha(ch) || isdigit(ch); }
-static inline int isgraph(unsigned ch) { return 0x20 < ch && ch < 0x7f; }
+static constexpr int isgraph(unsigned ch) { return 0x20 < ch && ch < 0x7f; }
-static inline int islower(unsigned ch) { return (ch - 'a') < 26; }
+static constexpr int islower(unsigned ch) { return (ch - 'a') < 26; }
-static inline int isupper(unsigned ch) { return (ch - 'A') < 26; }
+static constexpr int isupper(unsigned ch) { return (ch - 'A') < 26; }
} // namespace internal
} // namespace __llvm_libc
Index: libc/src/__support/integer_operations.h
===================================================================
--- libc/src/__support/integer_operations.h
+++ libc/src/__support/integer_operations.h
@@ -14,10 +14,9 @@
namespace __llvm_libc {
template <typename T>
-static inline cpp::EnableIfType<cpp::IsIntegral<T>::Value, T> integerAbs(T n) {
- if (n < 0)
- return -n;
- return n;
+static constexpr cpp::EnableIfType<cpp::IsIntegral<T>::Value, T>
+integerAbs(T n) {
+ return (n < 0) ? -n : n;
}
} // namespace __llvm_libc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106807.362125.patch
Type: text/x-patch
Size: 2264 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20210727/c84a5e53/attachment.bin>
More information about the libc-commits
mailing list