summaryrefslogtreecommitdiff
path: root/absl/flags/reflection.cc
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2020-06-04 14:05:55 -0700
committerGravatar Gennadiy Rozental <rogeeff@google.com>2020-06-04 20:17:52 -0400
commita8b03d90e0afe03fefa16d4a871ece344a5d52ad (patch)
tree6f36a6a3eb64b3aed28bce3512453b4519c6f478 /absl/flags/reflection.cc
parent1d31b5c365e975d3c8a8f90492c3d9de35ef024f (diff)
Export of internal Abseil changes
-- 5b9d5ce21074c0541432555d383d1b9c5898b553 by Gennadiy Rozental <rogeeff@google.com>: Convert FlagSaver into public API PiperOrigin-RevId: 314799739 -- 5f796c9862b1177f161f4b10fe1a84698ebbb5cf by Abseil Team <absl-team@google.com>: Google-internal changes only. PiperOrigin-RevId: 314786474 -- 67f2ae0ac5ae73bcd9d57a058ac4fea8fc1243ba by Gennadiy Rozental <rogeeff@google.com>: Makes sure stacktrace_generic is only used with glibc. Fixes #701 PiperOrigin-RevId: 314726944 -- efb1ef3636b0698b79d3ee3590f12c4dff32a3cb by Samuel Benzaquen <sbenza@google.com>: Take the bits into account when reserving the space for the operation, not just the exponent. PiperOrigin-RevId: 314622744 GitOrigin-RevId: 5b9d5ce21074c0541432555d383d1b9c5898b553 Change-Id: I080a5e333e2dc1545b5aa0417882f7ac7116a20c
Diffstat (limited to 'absl/flags/reflection.cc')
-rw-r--r--absl/flags/reflection.cc21
1 files changed, 5 insertions, 16 deletions
diff --git a/absl/flags/reflection.cc b/absl/flags/reflection.cc
index 02bb6c2e..5fc945f2 100644
--- a/absl/flags/reflection.cc
+++ b/absl/flags/reflection.cc
@@ -65,7 +65,8 @@ class FlagRegistry {
static FlagRegistry& GlobalRegistry(); // returns a singleton registry
private:
- friend class FlagSaverImpl; // reads all the flags in order to copy them
+ friend class flags_internal::FlagSaverImpl; // reads all the flags in order
+ // to copy them
friend void ForEachFlagUnlocked(
std::function<void(CommandLineFlag&)> visitor);
@@ -249,15 +250,6 @@ bool Retire(const char* name, FlagFastTypeId type_id) {
// --------------------------------------------------------------------
-// FlagSaver
-// FlagSaverImpl
-// This class stores the states of all flags at construct time,
-// and restores all flags to that state at destruct time.
-// Its major implementation challenge is that it never modifies
-// pointers in the 'main' registry, so global FLAG_* vars always
-// point to the right place.
-// --------------------------------------------------------------------
-
class FlagSaverImpl {
public:
FlagSaverImpl() = default;
@@ -288,11 +280,10 @@ class FlagSaverImpl {
backup_registry_;
};
-FlagSaver::FlagSaver() : impl_(new FlagSaverImpl) { impl_->SaveFromRegistry(); }
+} // namespace flags_internal
-void FlagSaver::Ignore() {
- delete impl_;
- impl_ = nullptr;
+FlagSaver::FlagSaver() : impl_(new flags_internal::FlagSaverImpl) {
+ impl_->SaveFromRegistry();
}
FlagSaver::~FlagSaver() {
@@ -304,8 +295,6 @@ FlagSaver::~FlagSaver() {
// --------------------------------------------------------------------
-} // namespace flags_internal
-
CommandLineFlag* FindCommandLineFlag(absl::string_view name) {
if (name.empty()) return nullptr;
flags_internal::FlagRegistry& registry =