summaryrefslogtreecommitdiff
path: root/absl/flags
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2021-08-10 08:52:44 -0700
committerGravatar Derek Mauro <dmauro@google.com>2021-08-10 12:30:11 -0400
commit8e088c5f3c290c5ac53dd5010fd501d80b483115 (patch)
tree7deaab3f9a34b0ea1b7b7f917a73de30f02a2614 /absl/flags
parentbf31a10b65d945665cecfb9d8807702ae4a7fde1 (diff)
Export of internal Abseil changes
-- 77cd6291781bc39e8472c706163d6951fe2ae573 by Derek Mauro <dmauro@google.com>: absl::uint128: Use intrinsics for more operations when available This change also inlines the division and modulus operators when intrinsics are available for better code generation. Fixes #987 PiperOrigin-RevId: 389895706 -- fa23339584599e07ebcb4d0a857e2553b017757c by Abseil Team <absl-team@google.com>: only hide retired flags if human-readable output is requested PiperOrigin-RevId: 389835452 -- f1111f2b88359d4b253d4d81681c8a488458a36e by Martijn Vels <mvels@google.com>: Add helpers IsFlat(), IsExternal(), etc to improve readability PiperOrigin-RevId: 389779333 -- 785b8712261e41695ebeeb64b4317f93b37adc11 by Martijn Vels <mvels@google.com>: Split off 'concat' and 'btree' RepMemoryUsageLeaf and RepMemoryUsageDataEdge PiperOrigin-RevId: 389701120 -- 5264bffebffc2b377bf7e18f0ce69a3ed38c6629 by CJ Johnson <johnsoncj@google.com>: Eagerly destroy `Callback` in `absl::Cleanup` PiperOrigin-RevId: 389678813 -- a05312f0668458e97c50ca932c8f974c1508ebf2 by Abseil Team <absl-team@google.com>: Have one instance of empty_group per program, rather than one per translation unit. https://stackoverflow.com/questions/185624/static-variables-in-an-inlined-function PiperOrigin-RevId: 389185845 GitOrigin-RevId: 77cd6291781bc39e8472c706163d6951fe2ae573 Change-Id: Iac8d9cb27707a9562c831c77a552d1fb4bb0405f
Diffstat (limited to 'absl/flags')
-rw-r--r--absl/flags/internal/usage.cc17
-rw-r--r--absl/flags/internal/usage_test.cc3
2 files changed, 16 insertions, 4 deletions
diff --git a/absl/flags/internal/usage.cc b/absl/flags/internal/usage.cc
index 949709e8..a883567f 100644
--- a/absl/flags/internal/usage.cc
+++ b/absl/flags/internal/usage.cc
@@ -17,6 +17,7 @@
#include <stdint.h>
+#include <algorithm>
#include <functional>
#include <map>
#include <ostream>
@@ -255,9 +256,6 @@ void FlagsHelpImpl(std::ostream& out, PerFlagFilter filter_cb,
matching_flags;
flags_internal::ForEachFlag([&](absl::CommandLineFlag& flag) {
- // Ignore retired flags.
- if (flag.IsRetired()) return;
-
// If the flag has been stripped, pretend that it doesn't exist.
if (flag.Help() == flags_internal::kStrippedFlagHelp) return;
@@ -275,6 +273,14 @@ void FlagsHelpImpl(std::ostream& out, PerFlagFilter filter_cb,
absl::string_view file_separator; // controls blank lines between files
for (auto& package : matching_flags) {
if (format == HelpFormat::kHumanReadable) {
+ // Hide packages with only retired flags
+ bool all_package_flags_are_retired = true;
+ for (const auto& flags_in_file : package.second) {
+ for (const auto* flag : flags_in_file.second) {
+ all_package_flags_are_retired &= flag->IsRetired();
+ }
+ }
+ if (all_package_flags_are_retired) continue;
out << package_separator;
package_separator = "\n\n";
}
@@ -334,8 +340,11 @@ void FlagsHelpImpl(std::ostream& out,
// Produces the help message describing specific flag.
void FlagHelp(std::ostream& out, const CommandLineFlag& flag,
HelpFormat format) {
- if (format == HelpFormat::kHumanReadable)
+ if (format == HelpFormat::kHumanReadable) {
+ // Ignore retired flags
+ if (flag.IsRetired()) return;
flags_internal::FlagHelpHumanReadable(flag, out);
+ }
}
// --------------------------------------------------------------------
diff --git a/absl/flags/internal/usage_test.cc b/absl/flags/internal/usage_test.cc
index 044d71c8..5055640a 100644
--- a/absl/flags/internal/usage_test.cc
+++ b/absl/flags/internal/usage_test.cc
@@ -61,6 +61,9 @@ ABSL_FLAG(
"Even more long long long long long long long long long long long long "
"help message.");
+ABSL_RETIRED_FLAG(int64_t, usage_reporting_test_flag_07, 1,
+ "usage_reporting_test_flag_07 help message");
+
namespace {
namespace flags = absl::flags_internal;