Skip to content

Commit

Permalink
Enable C++17 on linux (including in CFI builds)
Browse files Browse the repository at this point in the history
The prerequisite rolled in in
https://chromium-review.googlesource.com/c/chromium/src/+/3315436

With this, all platforms use -std=c++17.
Please don't rely on that yet though:
- it's not yet clear that this is going to stick
- we'll send out guidelines on how we'll adopt C++17 features

Bug: 1273966,752720
Cq-Include-Trybots: luci.chromium.try:linux_chromium_cfi_rel_ng
Change-Id: Icda9a95b159b8ae6fd1f74095fea7913343d210a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3308459
Commit-Queue: Nico Weber <thakis@chromium.org>
Auto-Submit: Nico Weber <thakis@chromium.org>
Reviewed-by: Hans Wennborg <hans@chromium.org>
Cr-Commit-Position: refs/heads/main@{#948345}
  • Loading branch information
nico authored and Chromium LUCI CQ committed Dec 4, 2021
1 parent 9bd095d commit c8494f8
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 20 deletions.
6 changes: 1 addition & 5 deletions base/strings/string_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <type_traits>
#include <vector>

#include "base/cfi_buildflags.h"
#include "base/check_op.h"
#include "base/cxx17_backports.h"
#include "base/no_destructor.h"
Expand All @@ -35,12 +34,9 @@ namespace base {

bool IsWprintfFormatPortable(const wchar_t* format) {
// This snippet of code checks that we can build C++17 code.
// TODO(thakis): Enable this on all platforms, and then remove it again.
#if !defined(OS_LINUX) && !BUILDFLAG(CFI_ICALL_CHECK) && \
!BUILDFLAG(CFI_CAST_CHECK)
// TODO(thakis): Remove this again in a bit.
if constexpr (constexpr int i = 0; i > 0) {
}
#endif

for (const wchar_t* position = format; *position != '\0'; ++position) {
if (*position == '%') {
Expand Down
6 changes: 0 additions & 6 deletions base/template_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,7 @@ struct negation : bool_constant<!static_cast<bool>(B::value)> {};
// [1] https://en.cppreference.com/w/cpp/types/result_of
// [2] https://wg21.link/meta.trans.other#lib:invoke_result
template <typename Functor, typename... Args>
#if __cplusplus >= 201703
// result_of is deprecated in c++17, so don't use it there.
using invoke_result = std::invoke_result<Functor, Args...>;
#else
// TODO(thakis): Remove this branch once all platforms use C++17.
using invoke_result = std::result_of<Functor && (Args && ...)>;
#endif

// Implementation of C++17's std::invoke_result_t.
//
Expand Down
5 changes: 1 addition & 4 deletions build/config/compiler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,7 @@ config("compiler") {
}

cflags_c += [ "-std=${standard_prefix}11" ]

# TODO(https://crbug.com/1273966): Use C++17 with is_cfi and is_linux once
# CFI works with -std=c++17.
if ((is_nacl && !is_nacl_saigo) || is_cfi || is_linux) {
if (is_nacl && !is_nacl_saigo) {
# This is for the pnacl_newlib toolchain. It's only used to build
# a few independent ppapi test files that don't pull in any other
# dependencies.
Expand Down
5 changes: 0 additions & 5 deletions components/omnibox/browser/autocomplete_result.cc
Original file line number Diff line number Diff line change
Expand Up @@ -968,12 +968,7 @@ void AutocompleteResult::MaybeCullTailSuggestions(
// as a default match (and that's a non-tail suggestion).
// 1) above.
if (default_tail != matches->end() && default_non_tail == matches->end()) {
// TODO(thakis): Remove this branch once CFI builds use C++17.
#if __cplusplus >= 201703L
base::EraseIf(*matches, std::not_fn(is_tail));
#else
base::EraseIf(*matches, std::not1(is_tail));
#endif
return;
}
// 2) above.
Expand Down

0 comments on commit c8494f8

Please sign in to comment.