From: Arran Cudbard-Bell Date: Sun, 11 Dec 2022 21:22:25 +0000 (-0600) Subject: Fix errors when clangd can't find sanitizer/lsan_interface.h X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=73e7e65b7120cc4a6d8e360d8d936848b9b08c98;p=thirdparty%2Ffreeradius-server.git Fix errors when clangd can't find sanitizer/lsan_interface.h --- diff --git a/.clangd b/.clangd index b11249f9f40..e04c81b7bd3 100644 --- a/.clangd +++ b/.clangd @@ -23,7 +23,8 @@ Diagnostics: CompileFlags: # macos: non-system clangd doesn't seem to include /usr/local/include in the default path Add: [ - "-I/usr/local/include" + "-I/usr/local/include", + "-D__clangd__" ] # macos: flags that come from xcrun that brewd clangd doesn't understand Remove: [ diff --git a/src/lib/util/lsan.h b/src/lib/util/lsan.h index 8f805fe2d51..55abdb28778 100644 --- a/src/lib/util/lsan.h +++ b/src/lib/util/lsan.h @@ -27,14 +27,19 @@ RCSIDH(lsan_h, "$Id$") extern "C" { #endif -#ifdef HAVE_SANITIZER_LSAN_INTERFACE_H -# include -#endif +/* + * clangd doesn't inherit all the implicit includes of clang + */ +#ifndef __clangd__ +# ifdef HAVE_SANITIZER_LSAN_INTERFACE_H +# include +# endif -#ifdef HAVE_SANITIZER_LSAN_INTERFACE_H -# define LSAN_DISABLE(_x) __lsan_disable(); _x; __lsan_enable() -#else -# define LSAN_DISABLE(_x) _x +# ifdef HAVE_SANITIZER_LSAN_INTERFACE_H +# define LSAN_DISABLE(_x) __lsan_disable(); _x; __lsan_enable() +# else +# define LSAN_DISABLE(_x) _x +# endif #endif #ifdef __cplusplus