This is an archive of the discontinued LLVM Phabricator instance.

[Sanitizer] Make CommonFlags immutable after initialization.
ClosedPublic

Authored by samsonov on Dec 19 2014, 1:57 PM.

Details

Summary

Protect CommonFlags singleton by adding const qualifier to
common_flags() accessor. The only ways to modify the flags are
SetCommonFlagsDefaults(), ParseCommonFlagsFromString() functions
and OVERRIDE_COMMON_FLAG macro, which are only supposed to be
called during initialization.

Diff Detail

Repository
rL LLVM

Event Timeline

samsonov updated this revision to Diff 17517.Dec 19 2014, 1:57 PM
samsonov retitled this revision from to [Sanitizer] Make CommonFlags immutable after initialization..
samsonov updated this object.
samsonov edited the test plan for this revision. (Show Details)
samsonov added reviewers: kcc, eugenis, glider.
samsonov added a subscriber: Unknown Object (MLST).
kcc added inline comments.Dec 19 2014, 2:57 PM
lib/sanitizer_common/sanitizer_flags.h
91 ↗(On Diff #17517)

Macro in a header file? You got to be kidding.

samsonov updated this revision to Diff 17527.Dec 19 2014, 5:13 PM
  • Replace macro with a function.
lib/sanitizer_common/sanitizer_flags.h
91 ↗(On Diff #17517)

Replaced it with "OverrideCommonFlags()" function. Unfortunately, we can't atomically switch common_flags_dont_use singleton during tool initialization, and have to gradually update it by calls to SetCommonFlagsDefaults(), OverrideCommonFlags() and ParseCommonFlagsFromString().

kcc requested changes to this revision.Dec 22 2014, 11:47 AM
kcc edited edge metadata.

LGTM

This revision now requires changes to proceed.Dec 22 2014, 11:47 AM
This revision was automatically updated to reflect the committed changes.