Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tools/code_format/check_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,8 @@ def checkSourceLine(line, file_path, reportError):
reportError("Don't use std::optional; use absl::optional instead")
if tokenInLine("std::variant", line):
reportError("Don't use std::variant; use absl::variant instead")
if tokenInLine("std::visit", line):
reportError("Don't use std::visit; use absl::visit instead")
if "__attribute__((packed))" in line and file_path != "./include/envoy/common/platform.h":
# __attribute__((packed)) is not supported by MSVC, we have a PACKED_STRUCT macro that
# can be used instead
Expand Down
1 change: 1 addition & 0 deletions tools/code_format/check_format_test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ def runChecks():
"Don't use std::optional; use absl::optional instead")
errors += checkUnfixableError("std_variant.cc",
"Don't use std::variant; use absl::variant instead")
errors += checkUnfixableError("std_visit.cc", "Don't use std::visit; use absl::visit instead")
errors += checkUnfixableError(
"throw.cc", "Don't introduce throws into exception-free files, use error statuses instead.")
errors += checkFileExpectingOK("commented_throw.cc")
Expand Down
12 changes: 12 additions & 0 deletions tools/testdata/check_format/std_visit.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Envoy {
struct SomeVisitorFunctor {
template<typename T>
void operator()(const T& i) const {}
};

void foo() {
absl::variant<int, std::string> foo = std::string("foo");
SomeVisitorFunctor visitor;
std::visit(visitor, foo);
}
} // namespace Envoy