summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/sanitizer_flags.h
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2015-01-02 21:28:37 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2015-01-02 21:28:37 +0000
commitc426c337ed8ceee256a7ce29de400bb4c44e2dcf (patch)
treed4b297fc121d440ca04dee449f8ba1910c305201 /compiler-rt/lib/sanitizer_common/sanitizer_flags.h
parent1d59f49f9ce096887aaa5fdc4be134c9ea5784a9 (diff)
downloadbcm5719-llvm-c426c337ed8ceee256a7ce29de400bb4c44e2dcf.tar.gz
bcm5719-llvm-c426c337ed8ceee256a7ce29de400bb4c44e2dcf.zip
Revert "Revert r224736: "[Sanitizer] Make CommonFlags immutable after initialization.""
Fix test failures by introducing CommonFlags::CopyFrom() to make sure compiler doesn't insert memcpy() calls into runtime code. Original commit message: 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. llvm-svn: 225088
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_flags.h')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_flags.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_flags.h b/compiler-rt/lib/sanitizer_common/sanitizer_flags.h
index f71cf43b278..c39bb781723 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_flags.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_flags.h
@@ -69,11 +69,13 @@ struct CommonFlags {
void SetDefaults();
void ParseFromString(const char *str);
+
+ void CopyFrom(const CommonFlags &other);
};
// 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;
}
@@ -84,6 +86,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.CopyFrom(cf);
+}
+
void PrintFlagDescriptions();
} // namespace __sanitizer
OpenPOWER on IntegriCloud