summaryrefslogtreecommitdiff
path: root/absl/flags
diff options
context:
space:
mode:
Diffstat (limited to 'absl/flags')
-rw-r--r--absl/flags/BUILD.bazel23
-rw-r--r--absl/flags/CMakeLists.txt17
-rw-r--r--absl/flags/commandlineflag.cc6
-rw-r--r--absl/flags/commandlineflag.h6
-rw-r--r--absl/flags/commandlineflag_test.cc1
-rw-r--r--absl/flags/declare.h1
-rw-r--r--absl/flags/flag.h21
-rw-r--r--absl/flags/flag_benchmark.cc7
-rw-r--r--absl/flags/flag_test.cc354
-rw-r--r--absl/flags/internal/commandlineflag.h7
-rw-r--r--absl/flags/internal/flag.cc11
-rw-r--r--absl/flags/internal/flag.h21
-rw-r--r--absl/flags/internal/parse.h1
-rw-r--r--absl/flags/internal/path_util.h1
-rw-r--r--absl/flags/internal/private_handle_accessor.cc8
-rw-r--r--absl/flags/internal/private_handle_accessor.h6
-rw-r--r--absl/flags/internal/registry.cc1
-rw-r--r--absl/flags/internal/registry.h6
-rw-r--r--absl/flags/internal/type_erased.h1
-rw-r--r--absl/flags/internal/type_erased_test.cc2
-rw-r--r--absl/flags/internal/usage.cc2
-rw-r--r--absl/flags/internal/usage_test.cc2
-rw-r--r--absl/flags/parse.cc1
-rw-r--r--absl/flags/parse.h1
-rw-r--r--absl/flags/usage_config.cc1
25 files changed, 350 insertions, 158 deletions
diff --git a/absl/flags/BUILD.bazel b/absl/flags/BUILD.bazel
index 2d6f799e..6ffd07ce 100644
--- a/absl/flags/BUILD.bazel
+++ b/absl/flags/BUILD.bazel
@@ -114,9 +114,7 @@ cc_library(
visibility = ["//visibility:private"],
deps = [
"//absl/base:config",
- "//absl/base:core_headers",
"//absl/base:fast_type_id",
- "//absl/strings",
],
)
@@ -132,6 +130,9 @@ cc_library(
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":commandlineflag_internal",
+ "//absl/base:config",
+ "//absl/base:fast_type_id",
+ "//absl/strings",
"//absl/types:optional",
],
)
@@ -149,7 +150,12 @@ cc_library(
visibility = [
"//absl/flags:__pkg__",
],
- deps = [":commandlineflag"],
+ deps = [
+ ":commandlineflag",
+ ":commandlineflag_internal",
+ "//absl/base:config",
+ "//absl/strings",
+ ],
)
cc_library(
@@ -193,6 +199,7 @@ cc_library(
visibility = ["//absl/base:__subpackages__"],
deps = [
":commandlineflag",
+ ":commandlineflag_internal",
":config",
":marshalling",
":registry",
@@ -203,6 +210,7 @@ cc_library(
"//absl/meta:type_traits",
"//absl/strings",
"//absl/synchronization",
+ "//absl/utility",
],
)
@@ -220,7 +228,6 @@ cc_library(
deps = [
":config",
":flag_internal",
- ":marshalling",
":registry",
"//absl/base",
"//absl/base:config",
@@ -287,6 +294,7 @@ cc_library(
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":commandlineflag",
+ ":commandlineflag_internal",
":config",
":flag",
":flag_internal",
@@ -315,6 +323,7 @@ cc_test(
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":commandlineflag",
+ ":commandlineflag_internal",
":config",
":flag",
":private_handle_accessor",
@@ -352,6 +361,7 @@ cc_test(
":config",
":flag",
":flag_internal",
+ ":marshalling",
":registry",
"//absl/base:core_headers",
"//absl/base:malloc_internal",
@@ -372,6 +382,8 @@ cc_binary(
visibility = ["//visibility:private"],
deps = [
":flag",
+ ":marshalling",
+ "//absl/strings",
"//absl/time",
"//absl/types:optional",
"@com_github_google_benchmark//:benchmark_main",
@@ -450,8 +462,8 @@ cc_test(
copts = ABSL_TEST_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
+ ":commandlineflag_internal",
":flag",
- ":marshalling",
":registry",
"//absl/memory",
"@com_google_googletest//:gtest_main",
@@ -492,7 +504,6 @@ cc_test(
":registry",
":usage",
":usage_internal",
- "//absl/memory",
"//absl/strings",
"@com_google_googletest//:gtest",
],
diff --git a/absl/flags/CMakeLists.txt b/absl/flags/CMakeLists.txt
index 6ecf3b48..2dc7cf45 100644
--- a/absl/flags/CMakeLists.txt
+++ b/absl/flags/CMakeLists.txt
@@ -103,9 +103,7 @@ absl_cc_library(
${ABSL_DEFAULT_LINKOPTS}
DEPS
absl::config
- absl::core_headers
absl::fast_type_id
- absl::strings
)
absl_cc_library(
@@ -120,8 +118,11 @@ absl_cc_library(
LINKOPTS
${ABSL_DEFAULT_LINKOPTS}
DEPS
+ absl::config
+ absl::fast_type_id
absl::flags_commandlineflag_internal
absl::optional
+ absl::strings
)
# Internal-only target, do not depend on directly.
@@ -137,7 +138,10 @@ absl_cc_library(
LINKOPTS
${ABSL_DEFAULT_LINKOPTS}
DEPS
+ absl::config
absl::flags_commandlineflag
+ absl::flags_commandlineflag_internal
+ absl::strings
)
# Internal-only target, do not depend on directly.
@@ -180,11 +184,13 @@ absl_cc_library(
DEPS
absl::base
absl::config
+ absl::flags_commandlineflag_internal
absl::flags_config
absl::flags_marshalling
absl::flags_registry
absl::synchronization
absl::meta
+ absl::utility
PUBLIC
)
@@ -205,7 +211,6 @@ absl_cc_library(
absl::flags_commandlineflag
absl::flags_config
absl::flags_internal
- absl::flags_marshalling
absl::flags_registry
absl::base
absl::core_headers
@@ -275,6 +280,7 @@ absl_cc_library(
absl::flags_config
absl::flags
absl::flags_commandlineflag
+ absl::flags_commandlineflag_internal
absl::flags_internal
absl::flags_private_handle_accessor
absl::flags_program_name
@@ -297,6 +303,7 @@ absl_cc_test(
DEPS
absl::flags
absl::flags_commandlineflag
+ absl::flags_commandlineflag_internal
absl::flags_config
absl::flags_private_handle_accessor
absl::flags_registry
@@ -330,6 +337,7 @@ absl_cc_test(
absl::flags
absl::flags_config
absl::flags_internal
+ absl::flags_marshalling
absl::flags_registry
absl::strings
absl::time
@@ -399,8 +407,8 @@ absl_cc_test(
COPTS
${ABSL_TEST_COPTS}
DEPS
+ absl::flags_commandlineflag_internal
absl::flags
- absl::flags_marshalling
absl::flags_registry
absl::memory
absl::strings
@@ -437,7 +445,6 @@ absl_cc_test(
absl::flags_parse
absl::flags_registry
absl::flags_usage
- absl::memory
absl::strings
gtest
)
diff --git a/absl/flags/commandlineflag.cc b/absl/flags/commandlineflag.cc
index cea57234..217b2d87 100644
--- a/absl/flags/commandlineflag.cc
+++ b/absl/flags/commandlineflag.cc
@@ -15,6 +15,12 @@
#include "absl/flags/commandlineflag.h"
+#include <string>
+
+#include "absl/base/config.h"
+#include "absl/flags/internal/commandlineflag.h"
+#include "absl/strings/string_view.h"
+
namespace absl {
ABSL_NAMESPACE_BEGIN
diff --git a/absl/flags/commandlineflag.h b/absl/flags/commandlineflag.h
index 43055d04..7e21d05d 100644
--- a/absl/flags/commandlineflag.h
+++ b/absl/flags/commandlineflag.h
@@ -26,7 +26,13 @@
#ifndef ABSL_FLAGS_COMMANDLINEFLAG_H_
#define ABSL_FLAGS_COMMANDLINEFLAG_H_
+#include <memory>
+#include <string>
+
+#include "absl/base/config.h"
+#include "absl/base/internal/fast_type_id.h"
#include "absl/flags/internal/commandlineflag.h"
+#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
namespace absl {
diff --git a/absl/flags/commandlineflag_test.cc b/absl/flags/commandlineflag_test.cc
index 4b9718e9..570bbe2f 100644
--- a/absl/flags/commandlineflag_test.cc
+++ b/absl/flags/commandlineflag_test.cc
@@ -20,6 +20,7 @@
#include "gtest/gtest.h"
#include "absl/flags/flag.h"
+#include "absl/flags/internal/commandlineflag.h"
#include "absl/flags/internal/private_handle_accessor.h"
#include "absl/flags/internal/registry.h"
#include "absl/flags/usage_config.h"
diff --git a/absl/flags/declare.h b/absl/flags/declare.h
index 0f8cc6a5..b9794d8b 100644
--- a/absl/flags/declare.h
+++ b/absl/flags/declare.h
@@ -26,7 +26,6 @@
#define ABSL_FLAGS_DECLARE_H_
#include "absl/base/config.h"
-#include "absl/strings/string_view.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
diff --git a/absl/flags/flag.h b/absl/flags/flag.h
index dd36e6c7..90dc2894 100644
--- a/absl/flags/flag.h
+++ b/absl/flags/flag.h
@@ -33,13 +33,11 @@
#include <type_traits>
#include "absl/base/attributes.h"
-#include "absl/base/casts.h"
#include "absl/base/config.h"
+#include "absl/base/optimization.h"
#include "absl/flags/config.h"
-#include "absl/flags/declare.h"
#include "absl/flags/internal/flag.h"
#include "absl/flags/internal/registry.h"
-#include "absl/flags/marshalling.h"
#include "absl/strings/string_view.h"
namespace absl {
@@ -150,6 +148,8 @@ class Flag {
void Set(const T& v) { GetImpl().Set(v); }
void InvokeCallback() { GetImpl().InvokeCallback(); }
+ const CommandLineFlag& Reflect() const { return GetImpl().Reflect(); }
+
// The data members are logically private, but they need to be public for
// this to be an aggregate type.
const char* name_;
@@ -204,6 +204,21 @@ void SetFlag(absl::Flag<T>* flag, const V& v) {
flag->Set(value);
}
+// GetFlagReflectionHandle()
+//
+// Returns the reflection handle corresponding to specified Abseil Flag
+// instance. Use this handle to access flag's reflection information, like name,
+// location, default value etc.
+//
+// Example:
+//
+// std::string = absl::GetFlagReflectionHandle(FLAGS_count).DefaultValue();
+
+template <typename T>
+const CommandLineFlag& GetFlagReflectionHandle(const absl::Flag<T>& f) {
+ return f.Reflect();
+}
+
ABSL_NAMESPACE_END
} // namespace absl
diff --git a/absl/flags/flag_benchmark.cc b/absl/flags/flag_benchmark.cc
index ff95bb5d..7b52c9bc 100644
--- a/absl/flags/flag_benchmark.cc
+++ b/absl/flags/flag_benchmark.cc
@@ -13,7 +13,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+#include <stdint.h>
+
+#include <string>
+#include <vector>
+
#include "absl/flags/flag.h"
+#include "absl/flags/marshalling.h"
+#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "absl/types/optional.h"
#include "benchmark/benchmark.h"
diff --git a/absl/flags/flag_test.cc b/absl/flags/flag_test.cc
index 58a07999..71661d39 100644
--- a/absl/flags/flag_test.cc
+++ b/absl/flags/flag_test.cc
@@ -15,9 +15,11 @@
#include "absl/flags/flag.h"
+#include <stddef.h>
#include <stdint.h>
#include <cmath>
+#include <new>
#include <string>
#include <thread> // NOLINT
#include <vector>
@@ -28,6 +30,7 @@
#include "absl/flags/declare.h"
#include "absl/flags/internal/flag.h"
#include "absl/flags/internal/registry.h"
+#include "absl/flags/marshalling.h"
#include "absl/flags/usage_config.h"
#include "absl/strings/match.h"
#include "absl/strings/numbers.h"
@@ -44,6 +47,9 @@ namespace {
namespace flags = absl::flags_internal;
std::string TestHelpMsg() { return "dynamic help"; }
+#if defined(_MSC_VER) && !defined(__clang__)
+std::string TestLiteralHelpMsg() { return "literal help"; }
+#endif
template <typename T>
void TestMakeDflt(void* dst) {
new (dst) T{};
@@ -127,15 +133,29 @@ constexpr flags::FlagHelpArg help_arg{flags::FlagHelpMsg("literal help"),
using String = std::string;
-#define DEFINE_CONSTRUCTED_FLAG(T, dflt, dflt_kind) \
- constexpr flags::FlagDefaultArg f1default##T{ \
- flags::FlagDefaultSrc{dflt}, flags::FlagDefaultKind::dflt_kind}; \
- constexpr flags::Flag<T> f1##T("f1", "file", help_arg, f1default##T); \
- ABSL_CONST_INIT flags::Flag<T> f2##T( \
- "f2", "file", \
- {flags::FlagHelpMsg(&TestHelpMsg), flags::FlagHelpKind::kGenFunc}, \
- flags::FlagDefaultArg{flags::FlagDefaultSrc(&TestMakeDflt<T>), \
- flags::FlagDefaultKind::kGenFunc})
+#if !defined(_MSC_VER) || defined(__clang__)
+#define DEFINE_CONSTRUCTED_FLAG(T, dflt, dflt_kind) \
+ constexpr flags::FlagDefaultArg f1default##T{ \
+ flags::FlagDefaultSrc{dflt}, flags::FlagDefaultKind::dflt_kind}; \
+ constexpr absl::Flag<T> f1##T{"f1", "file", help_arg, f1default##T}; \
+ ABSL_CONST_INIT absl::Flag<T> f2##T { \
+ "f2", "file", \
+ {flags::FlagHelpMsg(&TestHelpMsg), flags::FlagHelpKind::kGenFunc}, \
+ flags::FlagDefaultArg { \
+ flags::FlagDefaultSrc(&TestMakeDflt<T>), \
+ flags::FlagDefaultKind::kGenFunc \
+ } \
+ }
+#else
+#define DEFINE_CONSTRUCTED_FLAG(T, dflt, dflt_kind) \
+ constexpr flags::FlagDefaultArg f1default##T{ \
+ flags::FlagDefaultSrc{dflt}, flags::FlagDefaultKind::dflt_kind}; \
+ constexpr absl::Flag<T> f1##T{"f1", "file", &TestLiteralHelpMsg, \
+ &TestMakeDflt<T>}; \
+ ABSL_CONST_INIT absl::Flag<T> f2##T { \
+ "f2", "file", &TestHelpMsg, &TestMakeDflt<T> \
+ }
+#endif
DEFINE_CONSTRUCTED_FLAG(bool, true, kOneWord);
DEFINE_CONSTRUCTED_FLAG(int16_t, 1, kOneWord);
@@ -150,16 +170,17 @@ DEFINE_CONSTRUCTED_FLAG(String, &TestMakeDflt<String>, kGenFunc);
DEFINE_CONSTRUCTED_FLAG(UDT, &TestMakeDflt<UDT>, kGenFunc);
template <typename T>
-bool TestConstructionFor(const flags::Flag<T>& f1, flags::Flag<T>& f2) {
- EXPECT_EQ(f1.Name(), "f1");
- EXPECT_EQ(f1.Help(), "literal help");
- EXPECT_EQ(f1.Filename(), "file");
+bool TestConstructionFor(const absl::Flag<T>& f1, absl::Flag<T>& f2) {
+ EXPECT_EQ(absl::GetFlagReflectionHandle(f1).Name(), "f1");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(f1).Help(), "literal help");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(f1).Filename(), "file");
- flags::FlagRegistrar<T, false>(f2).OnUpdate(TestCallback);
+ flags::FlagRegistrar<T, false>(ABSL_FLAG_IMPL_FLAG_PTR(f2))
+ .OnUpdate(TestCallback);
- EXPECT_EQ(f2.Name(), "f2");
- EXPECT_EQ(f2.Help(), "dynamic help");
- EXPECT_EQ(f2.Filename(), "file");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(f2).Name(), "f2");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(f2).Help(), "dynamic help");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(f2).Filename(), "file");
return true;
}
@@ -203,18 +224,30 @@ namespace {
TEST_F(FlagTest, TestFlagDeclaration) {
// test that we can access flag objects.
- EXPECT_EQ(FLAGS_test_flag_01.Name(), "test_flag_01");
- EXPECT_EQ(FLAGS_test_flag_02.Name(), "test_flag_02");
- EXPECT_EQ(FLAGS_test_flag_03.Name(), "test_flag_03");
- EXPECT_EQ(FLAGS_test_flag_04.Name(), "test_flag_04");
- EXPECT_EQ(FLAGS_test_flag_05.Name(), "test_flag_05");
- EXPECT_EQ(FLAGS_test_flag_06.Name(), "test_flag_06");
- EXPECT_EQ(FLAGS_test_flag_07.Name(), "test_flag_07");
- EXPECT_EQ(FLAGS_test_flag_08.Name(), "test_flag_08");
- EXPECT_EQ(FLAGS_test_flag_09.Name(), "test_flag_09");
- EXPECT_EQ(FLAGS_test_flag_10.Name(), "test_flag_10");
- EXPECT_EQ(FLAGS_test_flag_11.Name(), "test_flag_11");
- EXPECT_EQ(FLAGS_test_flag_12.Name(), "test_flag_12");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_01).Name(),
+ "test_flag_01");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_02).Name(),
+ "test_flag_02");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_03).Name(),
+ "test_flag_03");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_04).Name(),
+ "test_flag_04");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_05).Name(),
+ "test_flag_05");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_06).Name(),
+ "test_flag_06");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_07).Name(),
+ "test_flag_07");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_08).Name(),
+ "test_flag_08");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_09).Name(),
+ "test_flag_09");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_10).Name(),
+ "test_flag_10");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_11).Name(),
+ "test_flag_11");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_12).Name(),
+ "test_flag_12");
}
#endif // !ABSL_FLAGS_STRIP_NAMES
@@ -241,96 +274,168 @@ namespace {
TEST_F(FlagTest, TestFlagDefinition) {
absl::string_view expected_file_name = "absl/flags/flag_test.cc";
- EXPECT_EQ(FLAGS_test_flag_01.Name(), "test_flag_01");
- EXPECT_EQ(FLAGS_test_flag_01.Help(), "test flag 01");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_01.Filename(), expected_file_name))
- << FLAGS_test_flag_01.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_02.Name(), "test_flag_02");
- EXPECT_EQ(FLAGS_test_flag_02.Help(), "test flag 02");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_02.Filename(), expected_file_name))
- << FLAGS_test_flag_02.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_03.Name(), "test_flag_03");
- EXPECT_EQ(FLAGS_test_flag_03.Help(), "test flag 03");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_03.Filename(), expected_file_name))
- << FLAGS_test_flag_03.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_04.Name(), "test_flag_04");
- EXPECT_EQ(FLAGS_test_flag_04.Help(), "test flag 04");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_04.Filename(), expected_file_name))
- << FLAGS_test_flag_04.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_05.Name(), "test_flag_05");
- EXPECT_EQ(FLAGS_test_flag_05.Help(), "test flag 05");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_05.Filename(), expected_file_name))
- << FLAGS_test_flag_05.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_06.Name(), "test_flag_06");
- EXPECT_EQ(FLAGS_test_flag_06.Help(), "test flag 06");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_06.Filename(), expected_file_name))
- << FLAGS_test_flag_06.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_07.Name(), "test_flag_07");
- EXPECT_EQ(FLAGS_test_flag_07.Help(), "test flag 07");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_07.Filename(), expected_file_name))
- << FLAGS_test_flag_07.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_08.Name(), "test_flag_08");
- EXPECT_EQ(FLAGS_test_flag_08.Help(), "test flag 08");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_08.Filename(), expected_file_name))
- << FLAGS_test_flag_08.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_09.Name(), "test_flag_09");
- EXPECT_EQ(FLAGS_test_flag_09.Help(), "test flag 09");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_09.Filename(), expected_file_name))
- << FLAGS_test_flag_09.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_10.Name(), "test_flag_10");
- EXPECT_EQ(FLAGS_test_flag_10.Help(), "test flag 10");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_10.Filename(), expected_file_name))
- << FLAGS_test_flag_10.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_11.Name(), "test_flag_11");
- EXPECT_EQ(FLAGS_test_flag_11.Help(), "test flag 11");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_11.Filename(), expected_file_name))
- << FLAGS_test_flag_11.Filename();
-
- EXPECT_EQ(FLAGS_test_flag_12.Name(), "test_flag_12");
- EXPECT_EQ(FLAGS_test_flag_12.Help(), "test flag 12");
- EXPECT_TRUE(absl::EndsWith(FLAGS_test_flag_12.Filename(), expected_file_name))
- << FLAGS_test_flag_12.Filename();
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_01).Name(),
+ "test_flag_01");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_01).Help(),
+ "test flag 01");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_01).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_01).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_02).Name(),
+ "test_flag_02");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_02).Help(),
+ "test flag 02");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_02).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_02).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_03).Name(),
+ "test_flag_03");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_03).Help(),
+ "test flag 03");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_03).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_03).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_04).Name(),
+ "test_flag_04");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_04).Help(),
+ "test flag 04");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_04).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_04).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_05).Name(),
+ "test_flag_05");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_05).Help(),
+ "test flag 05");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_05).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_05).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_06).Name(),
+ "test_flag_06");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_06).Help(),
+ "test flag 06");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_06).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_06).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_07).Name(),
+ "test_flag_07");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_07).Help(),
+ "test flag 07");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_07).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_07).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_08).Name(),
+ "test_flag_08");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_08).Help(),
+ "test flag 08");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_08).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_08).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_09).Name(),
+ "test_flag_09");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_09).Help(),
+ "test flag 09");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_09).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_09).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_10).Name(),
+ "test_flag_10");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_10).Help(),
+ "test flag 10");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_10).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_10).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_11).Name(),
+ "test_flag_11");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_11).Help(),
+ "test flag 11");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_11).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_11).Filename();
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_12).Name(),
+ "test_flag_12");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_12).Help(),
+ "test flag 12");
+ EXPECT_TRUE(absl::EndsWith(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_12).Filename(),
+ expected_file_name))
+ << absl::GetFlagReflectionHandle(FLAGS_test_flag_12).Filename();
}
#endif // !ABSL_FLAGS_STRIP_NAMES
// --------------------------------------------------------------------
TEST_F(FlagTest, TestDefault) {
- EXPECT_EQ(FLAGS_test_flag_01.DefaultValue(), "true");
- EXPECT_EQ(FLAGS_test_flag_02.DefaultValue(), "1234");
- EXPECT_EQ(FLAGS_test_flag_03.DefaultValue(), "-34");
- EXPECT_EQ(FLAGS_test_flag_04.DefaultValue(), "189");
- EXPECT_EQ(FLAGS_test_flag_05.DefaultValue(), "10765");
- EXPECT_EQ(FLAGS_test_flag_06.DefaultValue(), "40000");
- EXPECT_EQ(FLAGS_test_flag_07.DefaultValue(), "-1234567");
- EXPECT_EQ(FLAGS_test_flag_08.DefaultValue(), "9876543");
- EXPECT_EQ(FLAGS_test_flag_09.DefaultValue(), "-9.876e-50");
- EXPECT_EQ(FLAGS_test_flag_10.DefaultValue(), "1.234e+12");
- EXPECT_EQ(FLAGS_test_flag_11.DefaultValue(), "");
- EXPECT_EQ(FLAGS_test_flag_12.DefaultValue(), "10m");
-
- EXPECT_EQ(FLAGS_test_flag_01.CurrentValue(), "true");
- EXPECT_EQ(FLAGS_test_flag_02.CurrentValue(), "1234");
- EXPECT_EQ(FLAGS_test_flag_03.CurrentValue(), "-34");
- EXPECT_EQ(FLAGS_test_flag_04.CurrentValue(), "189");
- EXPECT_EQ(FLAGS_test_flag_05.CurrentValue(), "10765");
- EXPECT_EQ(FLAGS_test_flag_06.CurrentValue(), "40000");
- EXPECT_EQ(FLAGS_test_flag_07.CurrentValue(), "-1234567");
- EXPECT_EQ(FLAGS_test_flag_08.CurrentValue(), "9876543");
- EXPECT_EQ(FLAGS_test_flag_09.CurrentValue(), "-9.876e-50");
- EXPECT_EQ(FLAGS_test_flag_10.CurrentValue(), "1.234e+12");
- EXPECT_EQ(FLAGS_test_flag_11.CurrentValue(), "");
- EXPECT_EQ(FLAGS_test_flag_12.CurrentValue(), "10m");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_01).DefaultValue(),
+ "true");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_02).DefaultValue(),
+ "1234");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_03).DefaultValue(),
+ "-34");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_04).DefaultValue(),
+ "189");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_05).DefaultValue(),
+ "10765");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_06).DefaultValue(),
+ "40000");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_07).DefaultValue(),
+ "-1234567");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_08).DefaultValue(),
+ "9876543");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_09).DefaultValue(),
+ "-9.876e-50");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_10).DefaultValue(),
+ "1.234e+12");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_11).DefaultValue(),
+ "");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_12).DefaultValue(),
+ "10m");
+
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_01).CurrentValue(),
+ "true");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_02).CurrentValue(),
+ "1234");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_03).CurrentValue(),
+ "-34");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_04).CurrentValue(),
+ "189");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_05).CurrentValue(),
+ "10765");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_06).CurrentValue(),
+ "40000");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_07).CurrentValue(),
+ "-1234567");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_08).CurrentValue(),
+ "9876543");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_09).CurrentValue(),
+ "-9.876e-50");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_10).CurrentValue(),
+ "1.234e+12");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_11).CurrentValue(),
+ "");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_12).CurrentValue(),
+ "10m");
EXPECT_EQ(absl::GetFlag(FLAGS_test_flag_01), true);
EXPECT_EQ(absl::GetFlag(FLAGS_test_flag_02), 1234);
@@ -385,12 +490,18 @@ ABSL_FLAG(NonTriviallyCopyableAggregate, test_flag_eb_06, {}, "");
namespace {
TEST_F(FlagTest, TestEmptyBracesDefault) {
- EXPECT_EQ(FLAGS_test_flag_eb_01.DefaultValue(), "false");
- EXPECT_EQ(FLAGS_test_flag_eb_02.DefaultValue(), "0");
- EXPECT_EQ(FLAGS_test_flag_eb_03.DefaultValue(), "0");
- EXPECT_EQ(FLAGS_test_flag_eb_04.DefaultValue(), "0");
- EXPECT_EQ(FLAGS_test_flag_eb_05.DefaultValue(), "");
- EXPECT_EQ(FLAGS_test_flag_eb_06.DefaultValue(), "0");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_eb_01).DefaultValue(),
+ "false");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_eb_02).DefaultValue(),
+ "0");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_eb_03).DefaultValue(),
+ "0");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_eb_04).DefaultValue(),
+ "0");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_eb_05).DefaultValue(),
+ "");
+ EXPECT_EQ(absl::GetFlagReflectionHandle(FLAGS_test_flag_eb_06).DefaultValue(),
+ "0");
EXPECT_EQ(absl::GetFlag(FLAGS_test_flag_eb_01), false);
EXPECT_EQ(absl::GetFlag(FLAGS_test_flag_eb_02), 0);
@@ -500,8 +611,9 @@ namespace {
#if !ABSL_FLAGS_STRIP_HELP
TEST_F(FlagTest, TestNonConstexprHelp) {
- EXPECT_EQ(FLAGS_test_flag_with_non_const_help.Help(),
- "test flag non const help");
+ EXPECT_EQ(
+ absl::GetFlagReflectionHandle(FLAGS_test_flag_with_non_const_help).Help(),
+ "test flag non const help");
}
#endif //! ABSL_FLAGS_STRIP_HELP
diff --git a/absl/flags/internal/commandlineflag.h b/absl/flags/internal/commandlineflag.h
index 3c149788..cb46fe2e 100644
--- a/absl/flags/internal/commandlineflag.h
+++ b/absl/flags/internal/commandlineflag.h
@@ -16,13 +16,8 @@
#ifndef ABSL_FLAGS_INTERNAL_COMMANDLINEFLAG_H_
#define ABSL_FLAGS_INTERNAL_COMMANDLINEFLAG_H_
-#include <memory>
-#include <string>
-
#include "absl/base/config.h"
#include "absl/base/internal/fast_type_id.h"
-#include "absl/base/macros.h"
-#include "absl/strings/string_view.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
@@ -33,7 +28,7 @@ namespace flags_internal {
// cases this id is enough to uniquely identify the flag's value type. In a few
// cases we'll have to resort to using actual RTTI implementation if it is
// available.
-using FlagFastTypeId = base_internal::FastTypeIdType;
+using FlagFastTypeId = absl::base_internal::FastTypeIdType;
// Options that control SetCommandLineOptionWithMode.
enum FlagSettingMode {
diff --git a/absl/flags/internal/flag.cc b/absl/flags/internal/flag.cc
index ee974244..1502e7f1 100644
--- a/absl/flags/internal/flag.cc
+++ b/absl/flags/internal/flag.cc
@@ -15,21 +15,26 @@
#include "absl/flags/internal/flag.h"
+#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
+#include <array>
#include <atomic>
#include <memory>
+#include <new>
#include <string>
-#include <vector>
+#include <typeinfo>
-#include "absl/base/attributes.h"
+#include "absl/base/call_once.h"
#include "absl/base/casts.h"
#include "absl/base/config.h"
-#include "absl/base/const_init.h"
#include "absl/base/optimization.h"
+#include "absl/flags/config.h"
+#include "absl/flags/internal/commandlineflag.h"
#include "absl/flags/usage_config.h"
+#include "absl/memory/memory.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "absl/synchronization/mutex.h"
diff --git a/absl/flags/internal/flag.h b/absl/flags/internal/flag.h
index e1885809..2cc44e00 100644
--- a/absl/flags/internal/flag.h
+++ b/absl/flags/internal/flag.h
@@ -16,31 +16,36 @@
#ifndef ABSL_FLAGS_INTERNAL_FLAG_H_
#define ABSL_FLAGS_INTERNAL_FLAG_H_
+#include <stddef.h>
#include <stdint.h>
#include <atomic>
#include <cstring>
#include <memory>
+#include <new>
#include <string>
#include <type_traits>
#include <typeinfo>
+#include "absl/base/attributes.h"
#include "absl/base/call_once.h"
#include "absl/base/config.h"
+#include "absl/base/optimization.h"
#include "absl/base/thread_annotations.h"
#include "absl/flags/commandlineflag.h"
#include "absl/flags/config.h"
+#include "absl/flags/internal/commandlineflag.h"
#include "absl/flags/internal/registry.h"
#include "absl/flags/marshalling.h"
-#include "absl/memory/memory.h"
#include "absl/meta/type_traits.h"
-#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "absl/synchronization/mutex.h"
+#include "absl/utility/utility.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
+///////////////////////////////////////////////////////////////////////////////
// Forward declaration of absl::Flag<T> public API.
namespace flags_internal {
template <typename T>
@@ -64,12 +69,15 @@ void SetFlag(absl::Flag<T>* flag, const T& v);
template <typename T, typename V>
void SetFlag(absl::Flag<T>* flag, const V& v);
-namespace flags_internal {
+template <typename U>
+const CommandLineFlag& GetFlagReflectionHandle(const absl::Flag<U>& f);
///////////////////////////////////////////////////////////////////////////////
// Flag value type operations, eg., parsing, copying, etc. are provided
// by function specific to that type with a signature matching FlagOpFn.
+namespace flags_internal {
+
enum class FlagOp {
kAlloc,
kDelete,
@@ -659,6 +667,13 @@ class Flag {
impl_.Write(&v);
}
+ template <typename U>
+ friend const CommandLineFlag& absl::GetFlagReflectionHandle(
+ const absl::Flag<U>& f);
+
+ // Access to the reflection.
+ const CommandLineFlag& Reflect() const { return impl_; }
+
// Flag's data
// The implementation depends on value_ field to be placed exactly after the
// impl_ field, so that impl_ can figure out the offset to the value and
diff --git a/absl/flags/internal/parse.h b/absl/flags/internal/parse.h
index d259be73..de706c89 100644
--- a/absl/flags/internal/parse.h
+++ b/absl/flags/internal/parse.h
@@ -21,6 +21,7 @@
#include "absl/base/config.h"
#include "absl/flags/declare.h"
+#include "absl/strings/string_view.h"
ABSL_DECLARE_FLAG(std::vector<std::string>, flagfile);
ABSL_DECLARE_FLAG(std::vector<std::string>, fromenv);
diff --git a/absl/flags/internal/path_util.h b/absl/flags/internal/path_util.h
index 365c8305..a6594d33 100644
--- a/absl/flags/internal/path_util.h
+++ b/absl/flags/internal/path_util.h
@@ -17,7 +17,6 @@
#define ABSL_FLAGS_INTERNAL_PATH_UTIL_H_
#include "absl/base/config.h"
-#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
namespace absl {
diff --git a/absl/flags/internal/private_handle_accessor.cc b/absl/flags/internal/private_handle_accessor.cc
index 24b49136..a7eb58b6 100644
--- a/absl/flags/internal/private_handle_accessor.cc
+++ b/absl/flags/internal/private_handle_accessor.cc
@@ -15,6 +15,14 @@
#include "absl/flags/internal/private_handle_accessor.h"
+#include <memory>
+#include <string>
+
+#include "absl/base/config.h"
+#include "absl/flags/commandlineflag.h"
+#include "absl/flags/internal/commandlineflag.h"
+#include "absl/strings/string_view.h"
+
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace flags_internal {
diff --git a/absl/flags/internal/private_handle_accessor.h b/absl/flags/internal/private_handle_accessor.h
index 9a327a07..c64435cd 100644
--- a/absl/flags/internal/private_handle_accessor.h
+++ b/absl/flags/internal/private_handle_accessor.h
@@ -16,7 +16,13 @@
#ifndef ABSL_FLAGS_INTERNAL_PRIVATE_HANDLE_ACCESSOR_H_
#define ABSL_FLAGS_INTERNAL_PRIVATE_HANDLE_ACCESSOR_H_
+#include <memory>
+#include <string>
+
+#include "absl/base/config.h"
#include "absl/flags/commandlineflag.h"
+#include "absl/flags/internal/commandlineflag.h"
+#include "absl/strings/string_view.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
diff --git a/absl/flags/internal/registry.cc b/absl/flags/internal/registry.cc
index 4bcebfa9..e582d79d 100644
--- a/absl/flags/internal/registry.cc
+++ b/absl/flags/internal/registry.cc
@@ -29,6 +29,7 @@
#include "absl/base/internal/raw_logging.h"
#include "absl/base/thread_annotations.h"
#include "absl/flags/commandlineflag.h"
+#include "absl/flags/internal/commandlineflag.h"
#include "absl/flags/internal/private_handle_accessor.h"
#include "absl/flags/usage_config.h"
#include "absl/strings/str_cat.h"
diff --git a/absl/flags/internal/registry.h b/absl/flags/internal/registry.h
index a118865a..d207c225 100644
--- a/absl/flags/internal/registry.h
+++ b/absl/flags/internal/registry.h
@@ -17,11 +17,9 @@
#define ABSL_FLAGS_INTERNAL_REGISTRY_H_
#include <functional>
-#include <map>
-#include <string>
#include "absl/base/config.h"
-#include "absl/base/macros.h"
+#include "absl/flags/commandlineflag.h"
#include "absl/flags/internal/commandlineflag.h"
#include "absl/strings/string_view.h"
@@ -30,8 +28,6 @@
namespace absl {
ABSL_NAMESPACE_BEGIN
-class CommandLineFlag;
-
namespace flags_internal {
CommandLineFlag* FindCommandLineFlag(absl::string_view name);
diff --git a/absl/flags/internal/type_erased.h b/absl/flags/internal/type_erased.h
index fd9663e2..437a8c28 100644
--- a/absl/flags/internal/type_erased.h
+++ b/absl/flags/internal/type_erased.h
@@ -20,6 +20,7 @@
#include "absl/base/config.h"
#include "absl/flags/commandlineflag.h"
+#include "absl/flags/internal/commandlineflag.h"
#include "absl/flags/internal/registry.h"
#include "absl/strings/string_view.h"
diff --git a/absl/flags/internal/type_erased_test.cc b/absl/flags/internal/type_erased_test.cc
index bb0ff23e..42f374dc 100644
--- a/absl/flags/internal/type_erased_test.cc
+++ b/absl/flags/internal/type_erased_test.cc
@@ -20,8 +20,8 @@
#include "gtest/gtest.h"
#include "absl/flags/flag.h"
+#include "absl/flags/internal/commandlineflag.h"
#include "absl/flags/internal/registry.h"
-#include "absl/flags/marshalling.h"
#include "absl/memory/memory.h"
ABSL_FLAG(int, int_flag, 1, "int_flag help");
diff --git a/absl/flags/internal/usage.cc b/absl/flags/internal/usage.cc
index 2a2231a7..35b6427b 100644
--- a/absl/flags/internal/usage.cc
+++ b/absl/flags/internal/usage.cc
@@ -15,6 +15,8 @@
#include "absl/flags/internal/usage.h"
+#include <stdint.h>
+
#include <functional>
#include <map>
#include <ostream>
diff --git a/absl/flags/internal/usage_test.cc b/absl/flags/internal/usage_test.cc
index 8dd3532e..53b4d983 100644
--- a/absl/flags/internal/usage_test.cc
+++ b/absl/flags/internal/usage_test.cc
@@ -21,7 +21,6 @@
#include <string>
#include "gtest/gtest.h"
-#include "absl/flags/declare.h"
#include "absl/flags/flag.h"
#include "absl/flags/internal/parse.h"
#include "absl/flags/internal/path_util.h"
@@ -29,7 +28,6 @@
#include "absl/flags/internal/registry.h"
#include "absl/flags/usage.h"
#include "absl/flags/usage_config.h"
-#include "absl/memory/memory.h"
#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
diff --git a/absl/flags/parse.cc b/absl/flags/parse.cc
index 15300786..f0a131f2 100644
--- a/absl/flags/parse.cc
+++ b/absl/flags/parse.cc
@@ -37,6 +37,7 @@
#include "absl/flags/commandlineflag.h"
#include "absl/flags/config.h"
#include "absl/flags/flag.h"
+#include "absl/flags/internal/commandlineflag.h"
#include "absl/flags/internal/flag.h"
#include "absl/flags/internal/parse.h"
#include "absl/flags/internal/private_handle_accessor.h"
diff --git a/absl/flags/parse.h b/absl/flags/parse.h
index f37b0602..929de2cb 100644
--- a/absl/flags/parse.h
+++ b/absl/flags/parse.h
@@ -23,7 +23,6 @@
#ifndef ABSL_FLAGS_PARSE_H_
#define ABSL_FLAGS_PARSE_H_
-#include <string>
#include <vector>
#include "absl/base/config.h"
diff --git a/absl/flags/usage_config.cc b/absl/flags/usage_config.cc
index 0d21bce6..ae2f548a 100644
--- a/absl/flags/usage_config.cc
+++ b/absl/flags/usage_config.cc
@@ -15,6 +15,7 @@
#include "absl/flags/usage_config.h"
+#include <functional>
#include <iostream>
#include <string>