Port to clang address sanitizer

* src/patch.c (FREE_BEFORE_EXIT): Port to clang, which
uses __has_feature (address_sanitizer) instead of
defined __SANITIZE_ADDRESS__.  Also, rename this to
SANITIZE_ADDRESS since it is really about -fsanitize=address
rather than freeing before exit and as subsequent patches
will show there are simpler ways to pacify -fsanitize=address.
All uses changed.
This commit is contained in:
Paul Eggert 2024-09-19 16:05:45 -07:00
parent e2e6820f71
commit 72a146cfaf

View File

@ -30,10 +30,14 @@
#include <xstdopen.h>
#include <safe.h>
#ifdef __SANITIZE_ADDRESS__
# define FREE_BEFORE_EXIT true
#ifndef __has_feature
# define __has_feature(a) false
#endif
#if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)
# define SANITIZE_ADDRESS true
#else
# define FREE_BEFORE_EXIT false
# define SANITIZE_ADDRESS false
#endif
/* See common.h for the declarations of these variables. */
@ -1801,7 +1805,7 @@ delete_files (void)
removedirs (f->name);
}
next = f->next;
if (FREE_BEFORE_EXIT)
if (SANITIZE_ADDRESS)
free (f);
}
}
@ -1951,7 +1955,7 @@ output_files (struct stat const *st, int exiting)
&& st->st_ino == from_st->st_ino);
}
if (FREE_BEFORE_EXIT ? 0 <= exiting : !exiting)
if (SANITIZE_ADDRESS ? 0 <= exiting : !exiting)
{
free (name);
free (files_to_output);