]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix errors when clangd can't find sanitizer/lsan_interface.h
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 11 Dec 2022 21:22:25 +0000 (15:22 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 11 Dec 2022 21:22:25 +0000 (15:22 -0600)
.clangd
src/lib/util/lsan.h

diff --git a/.clangd b/.clangd
index b11249f9f40134b178aa0229045c188866b6b47f..e04c81b7bd39b1775011395e2aa6b9b61de93988 100644 (file)
--- 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: [
index 8f805fe2d513af94d1a61cd4ddfcffae3c23bf0d..55abdb2877876404155bc5b1e4acb91660dcd4be 100644 (file)
@@ -27,14 +27,19 @@ RCSIDH(lsan_h, "$Id$")
 extern "C" {
 #endif
 
-#ifdef HAVE_SANITIZER_LSAN_INTERFACE_H
-#  include <sanitizer/lsan_interface.h>
-#endif
+/*
+ *  clangd doesn't inherit all the implicit includes of clang
+ */
+#ifndef __clangd__
+#  ifdef HAVE_SANITIZER_LSAN_INTERFACE_H
+#    include <sanitizer/lsan_interface.h>
+#  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