Skip to content

Commit 2dc4329

Browse files
committed
src: replace snapshot flag with affects_annotation
1 parent f14e5f0 commit 2dc4329

4 files changed

Lines changed: 19 additions & 25 deletions

File tree

src/node_options.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -478,14 +478,13 @@ class OptionsParser {
478478
// Options struct instead.
479479
// affects_snapshot marks that the flag's effective value must match between
480480
// snapshot build and load time.
481-
void AddOption(
482-
const char* name,
483-
const char* help_text,
484-
bool Options::*field,
485-
OptionEnvvarSettings env_setting = kDisallowedInEnvvar,
486-
bool default_is_true = false,
487-
OptionNamespaces namespace_id = OptionNamespaces::kNoNamespace,
488-
bool affects_snapshot = false);
481+
void AddOption(const char* name,
482+
const char* help_text,
483+
bool Options::*field,
484+
OptionEnvvarSettings env_setting = kDisallowedInEnvvar,
485+
bool default_is_true = false,
486+
OptionNamespaces namespace_id = OptionNamespaces::kNoNamespace,
487+
bool affects_snapshot = false);
489488
void AddOption(
490489
const char* name,
491490
const char* help_text,
@@ -712,9 +711,9 @@ std::vector<std::string> ParseNodeOptionsEnvVar(
712711

713712
// Describes one snapshot-affecting boolean option.
714713
struct SnapshotFlagInfo {
715-
std::string name; // canonical CLI flag name
716-
bool value; // current effective value
717-
bool default_is_true; // true if the flag defaults to on (--no-* form)
714+
std::string name; // canonical CLI flag name
715+
bool value; // current effective value
716+
bool default_is_true; // true if the flag defaults to on (--no-* form)
718717
};
719718

720719
// Returns every boolean EnvironmentOption marked affects_snapshot=true,

src/node_snapshotable.cc

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -745,19 +745,15 @@ bool SnapshotData::Check() const {
745745
if (options[i].default_is_true) {
746746
// --no-<flag> form is what's passed when the feature is off.
747747
std::string negated = std::string("--no-") + (flag_name + 2);
748-
snap_desc = in_snapshot
749-
? (std::string("with ") + flag_name)
750-
: (std::string("with ") + negated);
751-
curr_desc = in_current
752-
? (std::string("with ") + flag_name)
753-
: (std::string("with ") + negated);
748+
snap_desc = in_snapshot ? (std::string("with ") + flag_name)
749+
: (std::string("with ") + negated);
750+
curr_desc = in_current ? (std::string("with ") + flag_name)
751+
: (std::string("with ") + negated);
754752
} else {
755-
snap_desc = in_snapshot
756-
? (std::string("with ") + flag_name)
757-
: (std::string("without ") + flag_name);
758-
curr_desc = in_current
759-
? (std::string("with ") + flag_name)
760-
: (std::string("without ") + flag_name);
753+
snap_desc = in_snapshot ? (std::string("with ") + flag_name)
754+
: (std::string("without ") + flag_name);
755+
curr_desc = in_current ? (std::string("with ") + flag_name)
756+
: (std::string("without ") + flag_name);
761757
}
762758
fprintf(stderr,
763759
"Failed to load the startup snapshot because it was built "

test/parallel/test-cli-node-options-docs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ for (const [, envVar] of manPageText.matchAll(/\.It Fl (-[a-zA-Z0-9._-]+)/g)) {
3939
}
4040

4141
for (const [, envVar, config] of nodeOptionsCC.matchAll(addOptionRE)) {
42-
// detect default_is_true by anchoring to the env_setting parameter position;
42+
// Detect default_is_true by anchoring to the env_setting parameter position;
4343
// a trailing `true` after OptionNamespaces:: would be affects_snapshot, not default_is_true
4444
const hasTrueAsDefaultValue = /,\s*k(?:Allowed|Disallowed)InEnvvar\s*,\s*(?:true|HAVE_[A-Z_]+)/.test(config);
4545
const isInNodeOption = config.includes('kAllowedInEnvvar') && !config.includes('kDisallowedInEnvvar');

test/parallel/test-preload.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const fixtureC = fixtures.path('printC.js');
2121
const fixtureD = fixtures.path('define-global.js');
2222
const fixtureE = fixtures.path('intrinsic-mutation.js');
2323
const fixtureF = fixtures.path('print-intrinsic-mutation-name.js');
24-
const fixtureG = fixtures.path('worker-from-argv.js');
2524
const fixtureThrows = fixtures.path('throws_error4.js');
2625
const fixtureIsPreloading = fixtures.path('ispreloading.js');
2726

0 commit comments

Comments
 (0)