about summary refs log tree commit diff
path: root/absl/flags/internal/commandlineflag.h
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2019-11-18T19·02-0800
committerGennadiy Civil <misterg@google.com>2019-11-19T15·27-0500
commit2103fd9acdf58279f739860bff3f8c9f4b845605 (patch)
tree8eee8ff910c004b517eb02c79feac753fe19126e /absl/flags/internal/commandlineflag.h
parent3df7b52a6ada51a72a23796b844549a7b282f1b8 (diff)
Export of internal Abseil changes
--
d447fdcb801036cf08197eece193a5a706661120 by Gennadiy Rozental <rogeeff@google.com>:

Eliminate the need for static function holding help message. This decreases the cost of ABSL_FLAG abstraction by 120 bytes under clang.

PiperOrigin-RevId: 281107806

--
0aa6b91189f0e8b2381438c33465673a7ae02487 by Derek Mauro <dmauro@google.com>:

Disable the weak symbol CCTZ extension in the time test_util
on MinGW, which does not support it.

PiperOrigin-RevId: 280719769

--
67322c41c3e776eb541de90fa4526bdb49422eb6 by Abseil Team <absl-team@google.com>:

Tune PeriodicSampler implementation (for internal-use only)

PiperOrigin-RevId: 280708943

--
3a48c346340c7ed03816645cd327e1ff07729aa4 by Abseil Team <absl-team@google.com>:

Clean up public headers not to have warnings for "-Wcomma"

PiperOrigin-RevId: 280695373

--
981acd1ef3b13a83a84f04f11c8931f4ed4451c9 by Matthew Brown <matthewbr@google.com>:

Release absl::int128.

PiperOrigin-RevId: 280690817

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

Fix -Wundef warnings in random platform detection

PiperOrigin-RevId: 280669598
GitOrigin-RevId: d447fdcb801036cf08197eece193a5a706661120
Change-Id: Ie5e10e567c54b7de211833607689f233d4ddf734
Diffstat (limited to 'absl/flags/internal/commandlineflag.h')
-rw-r--r--absl/flags/internal/commandlineflag.h47
1 files changed, 5 insertions, 42 deletions
diff --git a/absl/flags/internal/commandlineflag.h b/absl/flags/internal/commandlineflag.h
index 13a3352e80f4..7964f1bf8c4a 100644
--- a/absl/flags/internal/commandlineflag.h
+++ b/absl/flags/internal/commandlineflag.h
@@ -60,14 +60,6 @@ enum ValueSource {
   kProgrammaticChange,
 };
 
-// Signature for the help generation function used as an argument for the
-// absl::Flag constructor.
-using HelpGenFunc = std::string (*)();
-
-// Signature for the function generating the initial flag value based (usually
-// based on default value supplied in flag's definition)
-using InitialValGenFunc = void* (*)();
-
 extern const char kStrippedFlagHelp[];
 
 // The per-type function
@@ -149,34 +141,6 @@ inline size_t Sizeof(FlagOpFn op) {
       op(flags_internal::kSizeof, nullptr, nullptr)));
 }
 
-// Holds either a pointer to help text or a function which produces it.  This is
-// needed for supporting both static initialization of Flags while supporting
-// the legacy registration framework.  We can't use absl::variant<const char*,
-// const char*(*)()> since anybody passing 0 or nullptr in to a CommandLineFlag
-// would find an ambiguity.
-class HelpText {
- public:
-  static constexpr HelpText FromFunctionPointer(const HelpGenFunc fn) {
-    return HelpText(fn, nullptr);
-  }
-  static constexpr HelpText FromStaticCString(const char* msg) {
-    return HelpText(nullptr, msg);
-  }
-
-  std::string GetHelpText() const;
-
-  HelpText() = delete;
-  HelpText(const HelpText&) = default;
-  HelpText(HelpText&&) = default;
-
- private:
-  explicit constexpr HelpText(const HelpGenFunc fn, const char* msg)
-      : help_function_(fn), help_message_(msg) {}
-
-  HelpGenFunc help_function_;
-  const char* help_message_;
-};
-
 // Handle to FlagState objects. Specific flag state objects will restore state
 // of a flag produced this flag state from method CommandLineFlag::SaveState().
 class FlagStateInterface {
@@ -190,9 +154,8 @@ class FlagStateInterface {
 // Holds all information for a flag.
 class CommandLineFlag {
  public:
-  constexpr CommandLineFlag(const char* name, HelpText help_text,
-                            const char* filename)
-      : name_(name), help_(help_text), filename_(filename) {}
+  constexpr CommandLineFlag(const char* name, const char* filename)
+      : name_(name), filename_(filename) {}
 
   // Virtual destructor
   virtual void Destroy() const = 0;
@@ -203,7 +166,6 @@ class CommandLineFlag {
 
   // Non-polymorphic access methods.
   absl::string_view Name() const { return name_; }
-  std::string Help() const { return help_.GetHelpText(); }
   absl::string_view Typename() const;
   std::string Filename() const;
 
@@ -250,6 +212,8 @@ class CommandLineFlag {
 
   // Polymorphic access methods
 
+  // Returns help message associated with this flag
+  virtual std::string Help() const = 0;
   // Returns true iff this object corresponds to retired flag
   virtual bool IsRetired() const { return false; }
   // Returns true iff this is a handle to an Abseil Flag.
@@ -285,12 +249,11 @@ class CommandLineFlag {
   // flag's value type.
   virtual void CheckDefaultValueParsingRoundtrip() const = 0;
 
-  // Constant configuration for a particular flag.
  protected:
   ~CommandLineFlag() = default;
 
+  // Constant configuration for a particular flag.
   const char* const name_;      // Flags name passed to ABSL_FLAG as second arg.
-  const HelpText help_;         // The function generating help message.
   const char* const filename_;  // The file name where ABSL_FLAG resides.
 
  private: