# https://clangd.llvm.org/config

# Apply a config conditionally to all C files
If:
  PathMatch: .*\.(c|h)$

---

# Apply a config conditionally to all C++ files
If:
  PathMatch: .*\.(c|h)pp

---

# Apply a config conditionally to all CUDA files
If:
  PathMatch: .*\.cuh?
CompileFlags:
  Add:
    # Allow variadic CUDA functions
    - "-Xclang=-fcuda-allow-variadic-functions"

---

# For __cccl/epilogue.h, force-include prologue.h to avoid spurious errors
If:
  PathMatch: ".*libcudacxx/include/cuda/std/__cccl/epilogue[.]h"

CompileFlags:
  Add:
  - -include
  - cuda/std/__cccl/prologue.h
  - -Wno-unknown-pragmas

---

# For __cccl/visibility.h, pretend the file has been included from <cuda/__cccl_config>
If:
  PathMatch: ".*libcudacxx/include/cuda/std/__cccl/visibility[.]h"

CompileFlags:
  Add:
  - -D_CUDA__CCCL_CONFIG

---

# For __execution/epilogue.cuh, force-include prologue.cuh to avoid spurious errors
If:
  PathMatch: ".*cudax/include/cuda/experimental/__execution/epilogue[.]cuh"

CompileFlags:
  Add:
  - -include
  - cuda/experimental/__execution/prologue.cuh
  - -Wno-unknown-pragmas

---

# For libcudacxx test files, add include path to test support headers
If:
  PathMatch: ".*libcudacxx/test/.*[.]cpp"

CompileFlags:
  Add:
  - -I../../../libcudacxx/test/support

---

# Tweak the clangd parse settings for all files
CompileFlags:
  Compiler: clang++
  CompilationDatabase: .
  Add:
    - -x
    - cuda
    - -Wno-unknown-cuda-version
    - -Wno-pragma-system-header-outside-header
    - --no-cuda-version-check
    - -stdlib=libc++
    - "-DLIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE"
    # report all errors
    - "-ferror-limit=0"
    - "-ftemplate-backtrace-limit=0"
  Remove:
    - -G
    - -stdpar
    # strip CUDA fatbin args
    - "-Xfatbin*"
    - "-Xcompiler*"
    - "-Xcudafe*"
    - "-rdc=*"
    - "-gpu=*"
    - "--diag_suppress*"
    # strip CUDA arch flags
    - "-gencode*"
    - "--generate-code*"
    # strip gcc's -fcoroutines
    - -fcoroutines
    # strip CUDA flags unknown to clang
    - "-ccbin*"
    - "--compiler-options*"
    - "--extended-lambda"
    - "--expt-extended-lambda"
    - "--expt-relaxed-constexpr"
    - "-forward-unknown-to-host-compiler"
    - "-Werror=cross-execution-space-call"
Diagnostics:
  Suppress:
    - "variadic_device_fn"
    - "attributes_not_allowed"
    # The NVHPC version of _NVCXX_EXPAND_PACK macro triggers this clang error.
    # Temporarily suppressing it, but should probably fix
    - "template_param_shadow"
