summaryrefslogtreecommitdiff
path: root/absl/flags/internal/usage.cc
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2021-06-02 13:32:24 -0700
committerGravatar Derek Mauro <dmauro@google.com>2021-06-02 17:19:50 -0400
commited53ad03abd7baf39dda2ac8037ff3d4f5c533e5 (patch)
tree01d0d16bc184dd01d9009516e8b3eeb60e5ef5a1 /absl/flags/internal/usage.cc
parent702cae1e762dc6f2f9d31777db04e1adbdb36697 (diff)
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
Diffstat (limited to 'absl/flags/internal/usage.cc')
-rw-r--r--absl/flags/internal/usage.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/absl/flags/internal/usage.cc b/absl/flags/internal/usage.cc
index a588c7f7..949709e8 100644
--- a/absl/flags/internal/usage.cc
+++ b/absl/flags/internal/usage.cc
@@ -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);
}