Export of internal Abseil changes

--
b2a781121ff72fb485b7e67539d5e4ff1eb66df2 by Gennadiy Rozental <rogeeff@google.com>:

Consistently use absl::flat_hash_map instead of std::map in Flags implementation.

PiperOrigin-RevId: 377132816

--
9ab83a154d8f22d51fed0092bf94245b5af1f498 by Derek Mauro <dmauro@google.com>:

Workaround for MSAN being unable to see through getentropy().

https://github.com/google/sanitizers/issues/1173

PiperOrigin-RevId: 377097059

--
8d28e921442d1b246c26f3200f21027557c47657 by Greg Falcon <gfalcon@google.com>:

Disable stack_consumption_test in tsan builds.

A recent tsan change broke the way this test-only utility was counting stack usage.

PiperOrigin-RevId: 377053169
GitOrigin-RevId: b2a781121ff72fb485b7e67539d5e4ff1eb66df2
Change-Id: Ib56356f8128f6c083f32b950091f3a56d9e2cd51
pull/969/head
Abseil Team 4 years ago committed by Derek Mauro
parent 702cae1e76
commit ed53ad03ab
  1. 1
      absl/debugging/BUILD.bazel
  2. 1
      absl/flags/BUILD.bazel
  3. 1
      absl/flags/CMakeLists.txt
  4. 12
      absl/flags/internal/usage.cc
  5. 8
      absl/flags/reflection.cc
  6. 1
      absl/random/internal/BUILD.bazel
  7. 4
      absl/random/internal/seed_material.cc

@ -344,6 +344,7 @@ cc_test(
srcs = ["internal/stack_consumption_test.cc"],
copts = ABSL_TEST_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
tags = ["notsan"],
deps = [
":stack_consumption",
"//absl/base:core_headers",

@ -259,6 +259,7 @@ cc_library(
":reflection",
"//absl/base:config",
"//absl/base:core_headers",
"//absl/container:flat_hash_map",
"//absl/strings",
],
)

@ -239,6 +239,7 @@ absl_cc_library(
absl::flags_private_handle_accessor
absl::flags_program_name
absl::flags_reflection
absl::flat_hash_map
absl::strings
absl::synchronization
)

@ -245,7 +245,7 @@ void FlagsHelpImpl(std::ostream& out, PerFlagFilter filter_cb,
<< XMLElement("usage", program_usage_message) << '\n';
}
// Map of package name to
// Ordered map of package name to
// map of file name to
// vector of flags in the file.
// This map is used to output matching flags grouped by package and file
@ -273,20 +273,26 @@ void FlagsHelpImpl(std::ostream& out, PerFlagFilter filter_cb,
absl::string_view package_separator; // controls blank lines between packages
absl::string_view file_separator; // controls blank lines between files
for (const auto& package : matching_flags) {
for (auto& package : matching_flags) {
if (format == HelpFormat::kHumanReadable) {
out << package_separator;
package_separator = "\n\n";
}
file_separator = "";
for (const auto& flags_in_file : package.second) {
for (auto& flags_in_file : package.second) {
if (format == HelpFormat::kHumanReadable) {
out << file_separator << " Flags from " << flags_in_file.first
<< ":\n";
file_separator = "\n";
}
std::sort(std::begin(flags_in_file.second),
std::end(flags_in_file.second),
[](const CommandLineFlag* lhs, const CommandLineFlag* rhs) {
return lhs->Name() < rhs->Name();
});
for (const auto* flag : flags_in_file.second) {
flags_internal::FlagHelp(out, *flag, format);
}

@ -18,11 +18,11 @@
#include <assert.h>
#include <atomic>
#include <map>
#include <string>
#include "absl/base/config.h"
#include "absl/base/thread_annotations.h"
#include "absl/container/flat_hash_map.h"
#include "absl/flags/commandlineflag.h"
#include "absl/flags/internal/private_handle_accessor.h"
#include "absl/flags/internal/registry.h"
@ -68,7 +68,7 @@ class FlagRegistry {
friend void FinalizeRegistry();
// The map from name to flag, for FindFlag().
using FlagMap = std::map<absl::string_view, CommandLineFlag*>;
using FlagMap = absl::flat_hash_map<absl::string_view, CommandLineFlag*>;
using FlagIterator = FlagMap::iterator;
using FlagConstIterator = FlagMap::const_iterator;
FlagMap flags_;
@ -204,6 +204,10 @@ void FinalizeRegistry() {
for (const auto& f : registry.flags_) {
registry.flat_flags_.push_back(f.second);
}
std::sort(std::begin(registry.flat_flags_), std::end(registry.flat_flags_),
[](const CommandLineFlag* lhs, const CommandLineFlag* rhs) {
return lhs->Name() < rhs->Name();
});
registry.flags_.clear();
registry.finalized_flags_.store(true, std::memory_order_release);
}

@ -82,6 +82,7 @@ cc_library(
deps = [
":fast_uniform_bits",
"//absl/base:core_headers",
"//absl/base:dynamic_annotations",
"//absl/base:raw_logging_internal",
"//absl/strings",
"//absl/types:optional",

@ -28,6 +28,7 @@
#include <cstdlib>
#include <cstring>
#include "absl/base/dynamic_annotations.h"
#include "absl/base/internal/raw_logging.h"
#include "absl/strings/ascii.h"
#include "absl/strings/escaping.h"
@ -142,6 +143,9 @@ bool ReadSeedMaterialFromGetEntropy(absl::Span<uint32_t> values) {
if (result < 0) {
return false;
}
// https://github.com/google/sanitizers/issues/1173
// MemorySanitizer can't see through getentropy().
ABSL_ANNOTATE_MEMORY_IS_INITIALIZED(buffer, to_read);
buffer += to_read;
buffer_size -= to_read;
}

Loading…
Cancel
Save