diff options
author | Alexey Samsonov <vonosmas@gmail.com> | 2014-12-22 21:46:10 +0000 |
---|---|---|
committer | Alexey Samsonov <vonosmas@gmail.com> | 2014-12-22 21:46:10 +0000 |
commit | f90d757687ce94eefb139c7db9b9a9b65eab00c5 (patch) | |
tree | aed2bb1f31cbfc17f9839f7d5066b45dd5718eca /lib/sanitizer_common/sanitizer_flags.h | |
parent | 95dab99736e13ec0a7d106b41c7efc21ebf93acf (diff) |
[Sanitizer] Make CommonFlags immutable after initialization.
Summary:
Protect CommonFlags singleton by adding const qualifier to
common_flags() accessor. The only ways to modify the flags are
SetCommonFlagsDefaults(), ParseCommonFlagsFromString() and
OverrideCommonFlags() functions, which are only supposed to be
called during initialization.
Test Plan: regression test suite
Reviewers: kcc, eugenis, glider
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D6741
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224736 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_flags.h')
-rw-r--r-- | lib/sanitizer_common/sanitizer_flags.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/sanitizer_common/sanitizer_flags.h b/lib/sanitizer_common/sanitizer_flags.h index 698fc9c3d..b9f2204a2 100644 --- a/lib/sanitizer_common/sanitizer_flags.h +++ b/lib/sanitizer_common/sanitizer_flags.h @@ -71,7 +71,7 @@ struct CommonFlags { // Functions to get/set global CommonFlags shared by all sanitizer runtimes: extern CommonFlags common_flags_dont_use; -inline CommonFlags *common_flags() { +inline const CommonFlags *common_flags() { return &common_flags_dont_use; } @@ -82,6 +82,16 @@ inline void SetCommonFlagsDefaults() { inline void ParseCommonFlagsFromString(const char *str) { common_flags_dont_use.ParseFromString(str); } + +// This function can only be used to setup tool-specific overrides for +// CommonFlags defaults. Generally, it should only be used right after +// SetCommonFlagsDefaults(), but before ParseCommonFlagsFromString(), and +// only during the flags initialization (i.e. before they are used for +// the first time). +inline void OverrideCommonFlags(const CommonFlags &cf) { + common_flags_dont_use = cf; +} + void PrintFlagDescriptions(); } // namespace __sanitizer |