Lines Matching refs:flag
36 #include "src/flags/flag-definitions.h" // NOLINT(build/include)
40 #include "src/flags/flag-definitions.h" // NOLINT(build/include)
50 // This structure represents a single entry in the flag system, with a pointer
51 // to the actual flag, default value, comment, etc. This is designed to be POD
67 FlagType type_; // What type of flag, bool, int, or string.
68 const char* name_; // Name of the flag, ex "my_flag".
69 void* valptr_; // Pointer to the global flag variable.
72 bool owns_ptr_; // Does the flag own its string value?
225 // Setting the flag manually to false before calling Reset() avoids this
234 // {change_flag} indicates if we're going to change the flag value.
236 // weak implication is being ignored beause a flag is already set by a normal
246 // changes. So specifying the same flag with the same value multiple times
251 // repeated non-boolean flag is considered an error independently of its
265 "Contradictory weak flag implications from --%s and --%s for "
266 "flag %s\n%s",
273 "Contradictory flag implications from --%s and --%s for flag "
295 "Command-line provided flag --%s specified as both true and "
300 "Command-line provided flag --%s specified multiple "
317 // Compare this flag's current value against the default.
345 // Set a flag back to it's default value.
381 #include "src/flags/flag-definitions.h" // NOLINT(build/include)
435 explicit FlagName(const Flag& flag) : flag(flag) {}
436 const Flag& flag;
440 for (const char* c = flag_name.flag.name(); *c != '\0'; ++c) {
446 // Helper for printing flag values.
448 explicit FlagValue(const Flag& flag) : flag(flag) {}
449 const Flag& flag;
453 const Flag& flag = flag_value.flag;
454 switch (flag.type()) {
456 os << (flag.bool_variable() ? "true" : "false");
459 os << (flag.maybe_bool_variable().has_value
460 ? (flag.maybe_bool_variable().value ? "true" : "false")
464 os << flag.int_variable();
467 os << flag.uint_variable();
470 os << flag.uint64_variable();
473 os << flag.float_variable();
476 os << flag.size_t_variable();
479 const char* str = flag.string_value();
487 std::ostream& operator<<(std::ostream& os, const Flag& flag) {
488 if (flag.type() == Flag::TYPE_BOOL) {
489 os << (flag.bool_variable() ? "--" : "--no") << FlagName(flag);
491 os << "--" << FlagName(flag) << "=" << FlagValue(flag);
504 for (const Flag& flag : flags) {
505 if (flag.IsDefault()) continue;
508 if (flag.PointsTo(&FLAG_profile_deserialization)) continue;
510 if (flag.PointsTo(&FLAG_random_seed)) continue;
511 modified_args_as_string << flag;
525 // a flag name and flag value (or nullptr if they are missing). negated is set
536 // find the begin of the flag name
549 // find the end of the flag name
554 // make a copy so we can NUL-terminate flag name
567 bool TryParseUnsigned(Flag* flag, const char* arg, const char* value,
577 "Error: Value for flag %s of type %s is out of bounds "
579 arg, Type2String(flag->type()), max);
595 // split arg into flag components
603 // lookup the flag
604 Flag* flag = FindFlagByName(name);
605 if (flag == nullptr) {
607 // We don't recognize this flag but since we're removing
609 // will be processed somewhere else so this flag might make
613 PrintF(stderr, "Error: unrecognized flag %s\n", arg);
619 // if we still need a flag value, use the next argument if available
620 if (flag->type() != Flag::TYPE_BOOL &&
621 flag->type() != Flag::TYPE_MAYBE_BOOL && value == nullptr) {
626 PrintF(stderr, "Error: missing value for flag %s of type %s\n", arg,
627 Type2String(flag->type()));
633 // set the flag
635 switch (flag->type()) {
637 flag->set_bool_variable(!negated, Flag::SetBy::kCommandLine);
640 flag->set_maybe_bool_variable(MaybeBoolFlag::Create(true, !negated),
644 flag->set_int_variable(static_cast<int>(strtol(value, &endp, 10)),
649 if (TryParseUnsigned(flag, arg, value, &endp, &parsed_value)) {
650 flag->set_uint_variable(parsed_value, Flag::SetBy::kCommandLine);
658 if (TryParseUnsigned(flag, arg, value, &endp, &parsed_value)) {
659 flag->set_uint64_variable(parsed_value, Flag::SetBy::kCommandLine);
666 flag->set_float_variable(strtod(value, &endp),
671 if (TryParseUnsigned(flag, arg, value, &endp, &parsed_value)) {
672 flag->set_size_t_variable(parsed_value, Flag::SetBy::kCommandLine);
679 flag->set_string_value(value ? StrDup(value) : nullptr, true,
685 bool is_bool_type = flag->type() == Flag::TYPE_BOOL ||
686 flag->type() == Flag::TYPE_MAYBE_BOOL;
691 PrintF(stderr, "Error: illegal value for flag %s of type %s\n", arg,
692 Type2String(flag->type()));
695 "To set or unset a boolean flag, use --flag or --no-flag.\n");
701 // remove the flag & value from the command
800 " --flag (bool flags only)\n"
801 " --no-flag (bool flags only)\n"
802 " --flag=value (non-bool flags only, no spaces around '=')\n"
803 " --flag value (non-bool flags only)\n"
847 #include "src/flags/flag-definitions.h" // NOLINT(build/include)