[compiler-rt] r175511 - [Sanitizer] Allow runtime flags be separated by colon as well as space
Alexey Samsonov
samsonov at google.com
Tue Feb 19 05:03:37 PST 2013
Author: samsonov
Date: Tue Feb 19 07:03:37 2013
New Revision: 175511
URL: http://llvm.org/viewvc/llvm-project?rev=175511&view=rev
Log:
[Sanitizer] Allow runtime flags be separated by colon as well as space
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_flags_test.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc?rev=175511&r1=175510&r2=175511&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc Tue Feb 19 07:03:37 2013
@@ -38,7 +38,8 @@ static bool GetFlagValue(const char *env
pos += 1;
end = internal_strchr(pos, '\'');
} else {
- end = internal_strchr(pos, ' ');
+ // Read until the next space or colon.
+ end = pos + internal_strcspn(pos, " :");
}
if (end == 0)
end = pos + internal_strlen(pos);
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_flags_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_flags_test.cc?rev=175511&r1=175510&r2=175511&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_flags_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_flags_test.cc Tue Feb 19 07:03:37 2013
@@ -32,7 +32,7 @@ static void TestStrFlag(const char *star
const char *final_value) {
const char *flag = start_value;
ParseFlag(env, &flag, kFlagName);
- EXPECT_EQ(internal_strcmp(final_value, flag), 0);
+ EXPECT_EQ(0, internal_strcmp(final_value, flag));
}
TEST(SanitizerCommon, BooleanFlags) {
@@ -65,4 +65,21 @@ TEST(SanitizerCommon, StrFlags) {
TestStrFlag("", "--flag_name=\"abc qwe\" asd", "abc qwe");
}
+static void TestTwoFlags(const char *env, bool expected_flag1,
+ const char *expected_flag2) {
+ bool flag1 = !expected_flag1;
+ const char *flag2 = "";
+ ParseFlag(env, &flag1, "flag1");
+ ParseFlag(env, &flag2, "flag2");
+ EXPECT_EQ(expected_flag1, flag1);
+ EXPECT_EQ(0, internal_strcmp(flag2, expected_flag2));
+}
+
+TEST(SanitizerCommon, MultipleFlags) {
+ TestTwoFlags("flag1=1 flag2='zzz'", true, "zzz");
+ TestTwoFlags("flag2='qxx' flag1=0", false, "qxx");
+ TestTwoFlags("flag1=false:flag2='zzz'", false, "zzz");
+ TestTwoFlags("flag2=qxx:flag1=yes", true, "qxx");
+}
+
} // namespace __sanitizer
More information about the llvm-commits
mailing list