[llvm-dev] Use of C++17 in the LLVM codebase

Simon Pilgrim via llvm-dev llvm-dev at lists.llvm.org
Tue Nov 23 04:57:20 PST 2021


Making better use of C++17 came up several times in devmtg chats this year.

I notice we have a number of cases in LLVM source which allows 
(optional) use of C++17, but it is never mandatory or assumed:

e.g  StringRef.h

#if __cplusplus > 201402L
#include <string_view>
#endif

...

     // Constexpr version of std::strlen.
     static constexpr size_t strLen(const char *Str) {
#if __cplusplus > 201402L
       return std::char_traits<char>::length(Str);
#elif __has_builtin(__builtin_strlen) || defined(__GNUC__) || \
     (defined(_MSC_VER) && _MSC_VER >= 1916)
       return __builtin_strlen(Str);
#else
       const char *Begin = Str;
       while (*Str != '\0')
         ++Str;
       return Str - Begin;
#endif
     }

According to https://llvm.org/docs/CodingStandards.html - we only accept 
up to standard C++14 code that is supported by our minimum 
gcc/clang/msvc versions.

Does anyone know what in particular is preventing us from bumping the 
minimum compiler versions to make 'compiler supported' C++17 a similar 
requirement to build LLVM at this time?

https://lists.llvm.org/pipermail/llvm-dev/2018-October/127045.html
https://reviews.llvm.org/D47073

AFAICT, the last time this was discussed (back in 2018/9), some 
developers still had a dependency on Ubuntu 1604 LTS (and other old 
distros), whose default gcc didn't have adequate C++17 support. Support 
for 1604 has been extended to April 2026 - I'm guessing we're not going 
to wait until then?

Cheers, Simon.



More information about the llvm-dev mailing list