Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
42 changes: 42 additions & 0 deletions bazel/abseil.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Force internal versions of std classes per
# https://abseil.io/docs/cpp/guides/options
diff --git a/absl/base/options.h b/absl/base/options.h
index 230bf1e..6e1b9e5 100644
--- a/absl/base/options.h
+++ b/absl/base/options.h
@@ -100,7 +100,7 @@
// User code should not inspect this macro. To check in the preprocessor if
// absl::any is a typedef of std::any, use the feature macro ABSL_USES_STD_ANY.

-#define ABSL_OPTION_USE_STD_ANY 2
+#define ABSL_OPTION_USE_STD_ANY 0


// ABSL_OPTION_USE_STD_OPTIONAL
@@ -127,7 +127,7 @@
// absl::optional is a typedef of std::optional, use the feature macro
// ABSL_USES_STD_OPTIONAL.

-#define ABSL_OPTION_USE_STD_OPTIONAL 2
+#define ABSL_OPTION_USE_STD_OPTIONAL 0


// ABSL_OPTION_USE_STD_STRING_VIEW
@@ -154,7 +154,7 @@
// absl::string_view is a typedef of std::string_view, use the feature macro
// ABSL_USES_STD_STRING_VIEW.

-#define ABSL_OPTION_USE_STD_STRING_VIEW 2
+#define ABSL_OPTION_USE_STD_STRING_VIEW 0

// ABSL_OPTION_USE_STD_VARIANT
//
@@ -180,7 +180,7 @@
// absl::variant is a typedef of std::variant, use the feature macro
// ABSL_USES_STD_VARIANT.

-#define ABSL_OPTION_USE_STD_VARIANT 2
+#define ABSL_OPTION_USE_STD_VARIANT 0


// ABSL_OPTION_USE_INLINE_NAMESPACE
6 changes: 5 additions & 1 deletion bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,11 @@ def _com_google_googletest():
# pull in more bits of abseil as needed, and is now the preferred
# method for pure Bazel deps.
def _com_google_absl():
external_http_archive("com_google_absl")
external_http_archive(
name = "com_google_absl",
patches = ["@envoy//bazel:abseil.patch"],
patch_args = ["-p1"],
)
native.bind(
name = "abseil_any",
actual = "@com_google_absl//absl/types:any",
Expand Down
13 changes: 13 additions & 0 deletions source/common/common/stl_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ std::string accumulateToString(const ContainerT& source,
}) +
"]";
}

// Used for converting sanctioned uses of std string_view (e.g. extensions) to absl::string_view
// for internal use.
inline absl::string_view toAbslStringView(std::string_view view) { // NOLINT(std::string_view)
return absl::string_view(view.data(), view.size()); // NOLINT(std::string_view)
}

// Used for converting internal absl::string_view to sanctioned uses of std string_view (e.g.
// extensions).
inline std::string_view toStdStringView(absl::string_view view) { // NOLINT(std::string_view)
return std::string_view(view.data(), view.size()); // NOLINT(std::string_view)
}

} // namespace Envoy

// NOLINT(namespace-envoy)
Expand Down
8 changes: 6 additions & 2 deletions source/common/config/context_provider_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "envoy/config/context_provider.h"

#include "source/common/common/callback_impl.h"
#include "source/common/common/stl_helpers.h"
#include "source/common/common/thread.h"
#include "source/common/config/xds_context_params.h"

Expand All @@ -29,13 +30,16 @@ class ContextProviderImpl : public ContextProvider {
void setDynamicContextParam(absl::string_view resource_type_url, absl::string_view key,
absl::string_view value) override {
ASSERT(Thread::MainThread::isMainThread());
(*dynamic_context_[resource_type_url].mutable_params())[key] = value;
(*dynamic_context_[resource_type_url]
.mutable_params())[toStdStringView(key)] = // NOLINT(std::string_view)
toStdStringView(value); // NOLINT(std::string_view)
update_cb_helper_.runCallbacks(resource_type_url);
}
void unsetDynamicContextParam(absl::string_view resource_type_url,
absl::string_view key) override {
ASSERT(Thread::MainThread::isMainThread());
dynamic_context_[resource_type_url].mutable_params()->erase(key);
dynamic_context_[resource_type_url].mutable_params()->erase(
toStdStringView(key)); // NOLINT(std::string_view)
update_cb_helper_.runCallbacks(resource_type_url);
}
ABSL_MUST_USE_RESULT Common::CallbackHandlePtr
Expand Down
2 changes: 1 addition & 1 deletion source/common/formatter/substitution_formatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ FormatterProviderPtr SubstitutionFormatParser::parseBuiltinCommand(const std::st
}

if (serialize_type.empty()) {
serialize_type = TYPED_SERIALIZATION;
serialize_type = std::string(TYPED_SERIALIZATION);
}
if (serialize_type != PLAIN_SERIALIZATION && serialize_type != TYPED_SERIALIZATION) {
throw EnvoyException("Invalid filter state serialize type, only support PLAIN/TYPED.");
Expand Down
8 changes: 5 additions & 3 deletions source/common/formatter/substitution_formatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,15 @@ class SubstitutionFormatParser {
if constexpr (std::is_same_v<typename std::remove_reference<decltype(param)>::type,
std::string>) {
// Compile time handler for std::string.
param = *it;
param = std::string(*it);
it++;
} else {
// Compile time handler for container type. It will catch all remaining tokens and
// move iterator to the end.
param.insert(param.begin(), it, tokens.end());
it = tokens.end();
do {
param.push_back(std::string(*it));
it++;
} while (it != tokens.end());
}
}
}(params),
Expand Down
2 changes: 1 addition & 1 deletion source/common/json/json_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class ObjectHandler : public nlohmann::json_sax<nlohmann::json> {
"documentation in case error string changed.");
} else {
// Extract portion after ": " to get error string.
error_ = error.substr(end + 2);
error_ = std::string(error.substr(end + 2));
// Extract position information if present.
auto start = error.find("at ");
if (start != std::string::npos && (start + 3) < end) {
Expand Down
5 changes: 3 additions & 2 deletions source/common/local_info/local_info_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ class LocalInfoImpl : public LocalInfo {
zone_stat_name_(zone_stat_name_storage_.statName()),
dynamic_update_callback_handle_(context_provider_.addDynamicContextUpdateCallback(
[this](absl::string_view resource_type_url) {
(*node_.mutable_dynamic_parameters())[resource_type_url].CopyFrom(
context_provider_.dynamicContext(resource_type_url));
(*node_.mutable_dynamic_parameters())
[toStdStringView(resource_type_url)] // NOLINT(std::string_view)
.CopyFrom(context_provider_.dynamicContext(resource_type_url));
})) {}

Network::Address::InstanceConstSharedPtr address() const override { return address_; }
Expand Down
6 changes: 3 additions & 3 deletions source/common/stats/tag_extractor_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ bool TagExtractorStdRegexImpl::extractTag(TagExtractionContext& context, std::ve

TagExtractorRe2Impl::TagExtractorRe2Impl(absl::string_view name, absl::string_view regex,
absl::string_view substr)
: TagExtractorImplBase(name, regex, substr), regex_(regex) {}
: TagExtractorImplBase(name, regex, substr), regex_(std::string(regex)) {}

bool TagExtractorRe2Impl::extractTag(TagExtractionContext& context, std::vector<Tag>& tags,
IntervalSet<size_t>& remove_characters) const {
Expand Down Expand Up @@ -186,7 +186,7 @@ TagExtractorTokensImpl::TagExtractorTokensImpl(absl::string_view name, absl::str
if (!tokens_.empty()) {
const absl::string_view first = tokens_[0];
if (first != "$" && first != "*" && first != "**") {
prefix_ = first;
prefix_ = std::string(first);
}
}
}
Expand Down Expand Up @@ -236,7 +236,7 @@ bool TagExtractorTokensImpl::extractTag(TagExtractionContext& context, std::vect
} else if (start > 0) {
--start; // Remove the dot prior to the lat token, e.g. ".ef"
}
addTag(tags) = tag_value;
addTag(tags) = std::string(tag_value);
remove_characters.insert(start, end);

PERF_RECORD(perf, "tokens-match", name_);
Expand Down
2 changes: 1 addition & 1 deletion source/common/stream_info/stream_info_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ struct StreamInfoImpl : public StreamInfo {
absl::optional<uint64_t> connectionID() const override { return connection_id_; }

void setFilterChainName(absl::string_view filter_chain_name) override {
filter_chain_name_ = filter_chain_name;
filter_chain_name_ = std::string(filter_chain_name);
}

const std::string& filterChainName() const override { return filter_chain_name_; }
Expand Down
Loading