about summary refs log tree commit diff
path: root/absl/flags/parse.cc
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2019-07-17T20·35-0400
committerDerek Mauro <dmauro@google.com>2019-07-17T20·40-0400
commitc6c3c1b498e4ee939b24be59cae29d59c3863be8 (patch)
tree030b875cdbbd25d2d0b7bca0b68a71351eeb2c41 /absl/flags/parse.cc
parent44efe96dfca674a17b45ca53fc77fb69f1e29bf4 (diff)
Export of internal Abseil changes.
--
ed3a3431eee9e48e6553b0320e0308d2dde6725c by Derek Mauro <dmauro@google.com>:

Project import generated by Copybara.

PiperOrigin-RevId: 258631680
GitOrigin-RevId: ed3a3431eee9e48e6553b0320e0308d2dde6725c
Change-Id: I1d7ae86a79783842092d29504605ba039c369603
Diffstat (limited to 'absl/flags/parse.cc')
-rw-r--r--absl/flags/parse.cc25
1 files changed, 7 insertions, 18 deletions
diff --git a/absl/flags/parse.cc b/absl/flags/parse.cc
index 3caaa1c256cb..e9dd4204e8a8 100644
--- a/absl/flags/parse.cc
+++ b/absl/flags/parse.cc
@@ -16,6 +16,7 @@
 #include "absl/flags/parse.h"
 
 #include <stdlib.h>
+
 #include <fstream>
 #include <iostream>
 #include <tuple>
@@ -28,6 +29,7 @@
 #include "absl/flags/internal/program_name.h"
 #include "absl/flags/internal/registry.h"
 #include "absl/flags/internal/usage.h"
+#include "absl/flags/usage.h"
 #include "absl/flags/usage_config.h"
 #include "absl/strings/str_cat.h"
 #include "absl/strings/strip.h"
@@ -280,22 +282,7 @@ void CheckDefaultValuesParsingRoundtrip() {
     IGNORE_TYPE(std::vector<std::string>)
 #undef IGNORE_TYPE
 
-    absl::MutexLock lock(InitFlagIfNecessary(flag));
-
-    std::string v = flag->DefaultValue();
-    void* dst = Clone(flag->op, flag->def);
-    std::string error;
-    if (!flags_internal::Parse(flag->marshalling_op, v, dst, &error)) {
-      ABSL_INTERNAL_LOG(
-          FATAL,
-          absl::StrCat("Flag ", flag->Name(), " (from ", flag->Filename(),
-                       "): std::string form of default value '", v,
-                       "' could not be parsed; error=", error));
-    }
-
-    // We do not compare dst to def since parsing/unparsing may make
-    // small changes, e.g., precision loss for floating point types.
-    Delete(flag->op, dst);
+    flag->CheckDefaultValueParsingRoundtrip();
   });
 #endif
 }
@@ -717,12 +704,14 @@ std::vector<char*> ParseCommandLineImpl(int argc, char* argv[],
 #endif
 
   if (!success) {
-    flags_internal::HandleUsageFlags(std::cout);
+    flags_internal::HandleUsageFlags(std::cout,
+                                     ProgramUsageMessage());
     std::exit(1);
   }
 
   if (usage_flag_act == UsageFlagsAction::kHandleUsage) {
-    int exit_code = flags_internal::HandleUsageFlags(std::cout);
+    int exit_code = flags_internal::HandleUsageFlags(
+        std::cout, ProgramUsageMessage());
 
     if (exit_code != -1) {
       std::exit(exit_code);