static bool profile_generate = false;
// Sanitize blacklist
-static char *sanitize_blacklist = NULL;
+static char **sanitize_blacklists = NULL;
+
+// Size of sanitize_blacklists
+static size_t sanitize_blacklists_len = 0;
// Whether we are using a precompiled header (either via -include, #include or
// clang's -include-pch or -include-pth).
}
// Possibly hash the sanitize blacklist file path.
- if (sanitize_blacklist) {
+ for (size_t i = 0; i < sanitize_blacklists_len; i++) {
+ char *sanitize_blacklist = sanitize_blacklists[i];
cc_log("Hashing sanitize blacklist %s", sanitize_blacklist);
hash_delimiter(hash, "sanitizeblacklist");
if (!hash_file(hash, sanitize_blacklist)) {
continue;
}
if (str_startswith(argv[i], "-fsanitize-blacklist=")) {
- sanitize_blacklist = x_strdup(argv[i] + 21);
+ sanitize_blacklists = x_realloc(sanitize_blacklists,
+ (sanitize_blacklists_len + 1) * sizeof(char *));
+ sanitize_blacklists[sanitize_blacklists_len++] = x_strdup(argv[i] + 21);
args_add(stripped_args, argv[i]);
continue;
}
free(debug_prefix_maps); debug_prefix_maps = NULL;
debug_prefix_maps_len = 0;
free(profile_dir); profile_dir = NULL;
- free(sanitize_blacklist); sanitize_blacklist = NULL;
+ for (size_t i = 0; i < sanitize_blacklists_len; i++) {
+ free(sanitize_blacklists[i]);
+ sanitize_blacklists[i] = NULL;
+ }
+ free(sanitize_blacklists); sanitize_blacklists = NULL;
+ sanitize_blacklists_len = 0;
free(included_pch_file); included_pch_file = NULL;
args_free(orig_args); orig_args = NULL;
free(input_file); input_file = NULL;
}
SUITE_sanitize_blacklist_SETUP() {
- generate_code 1 test1.c
+ generate_code 2 test1.c
echo "fun:foo" >blacklist.txt
+ echo "fun_1:foo" >blacklist2.txt
unset CCACHE_NODIRECT
}
fi
expect_stat 'error hashing extra file' 1
+
+ # -------------------------------------------------------------------------
+ TEST "Multiple -fsanitize-blacklist"
+
+ $REAL_COMPILER -c -fsanitize-blacklist=blacklist2.txt -fsanitize-blacklist=blacklist.txt test1.c
+
+ $CCACHE_COMPILE -c -fsanitize-blacklist=blacklist2.txt -fsanitize-blacklist=blacklist.txt test1.c
+ expect_stat 'cache hit (direct)' 0
+ expect_stat 'cache miss' 1
+ expect_stat 'files in cache' 2
+
+ $CCACHE_COMPILE -c -fsanitize-blacklist=blacklist2.txt -fsanitize-blacklist=blacklist.txt test1.c
+ expect_stat 'cache hit (direct)' 1
+ expect_stat 'cache miss' 1
+ expect_stat 'files in cache' 2
+
+ echo "fun_2:foo" >blacklist2.txt
+
+ $CCACHE_COMPILE -c -fsanitize-blacklist=blacklist2.txt -fsanitize-blacklist=blacklist.txt test1.c
+ expect_stat 'cache hit (direct)' 1
+ expect_stat 'cache miss' 2
+ expect_stat 'files in cache' 4
+
+ $CCACHE_COMPILE -c -fsanitize-blacklist=blacklist2.txt -fsanitize-blacklist=blacklist.txt test1.c
+ expect_stat 'cache hit (direct)' 2
+ expect_stat 'cache miss' 2
+ expect_stat 'files in cache' 4
}