llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-tidy Author: mitchell (zeyi2) <details> <summary>Changes</summary> Closes #<!-- -->173677 --- Full diff: https://github.com/llvm/llvm-project/pull/173699.diff 2 Files Affected: - (modified) clang-tools-extra/docs/clang-tidy/index.rst (+14) - (added) clang-tools-extra/test/clang-tidy/infrastructure/basic-cuda.cu (+9) ``````````diff diff --git a/clang-tools-extra/docs/clang-tidy/index.rst b/clang-tools-extra/docs/clang-tidy/index.rst index 34da529902308..38aabc77540cf 100644 --- a/clang-tools-extra/docs/clang-tidy/index.rst +++ b/clang-tools-extra/docs/clang-tidy/index.rst @@ -349,6 +349,20 @@ An overview of all the command-line options: some-check.SomeOption: 'some value' ... +Running Clang-Tidy on CUDA Files +-------------------------------- + +:program:`clang-tidy` supports analyzing CUDA source files. +To correctly process host-side code, specify the CUDA toolkit path using +``--cuda-path`` and limit compilation to the host with ``--cuda-host-only``. + +.. code-block:: console + + $ clang-tidy source.cu -- --cuda-path=/path/to/cuda --cuda-host-only + +Using ``--cuda-host-only`` is recommended as it skips device-side compilation, +speeding up the analysis and avoiding potential device-specific errors. + Clang-Tidy Automation ===================== diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/basic-cuda.cu b/clang-tools-extra/test/clang-tidy/infrastructure/basic-cuda.cu new file mode 100644 index 0000000000000..3bc605d864461 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/infrastructure/basic-cuda.cu @@ -0,0 +1,9 @@ +// RUN: clang-tidy %s -checks='-*,modernize-use-nullptr' -- -nocudainc -nocudalib --cuda-host-only | FileCheck %s + +#define __global__ __attribute__((global)) + +// CHECK: :[[@LINE+1]]:38: warning: use nullptr [modernize-use-nullptr] +__global__ void kernel(int *p) { p = 0; } + +// CHECK: :[[@LINE+1]]:11: warning: use nullptr [modernize-use-nullptr] +void *p = 0; `````````` </details> https://github.com/llvm/llvm-project/pull/173699 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
