[clang-tools-extra] [clang-tidy] Add avoid-pragma-once. (PR #140388)

Tommy Chen via cfe-commits cfe-commits at lists.llvm.org
Sat May 17 10:51:40 PDT 2025


================
@@ -0,0 +1,5 @@
+// RUN: %check_clang_tidy %s portability-avoid-pragma-once %t \
+// RUN:   -- -- -isystem %S/Inputs/avoid-pragma-once
+
+#include <lib.h>
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: Avoid pragma once. [portability-avoid-pragma-once]
----------------
dl8sd11 wrote:

I'm new to writing tests for header files. I got the following error. Is there a suggestion for this? Thanks!

```
Input was:
<<<<<<
           1: 1 warning generated.
check:5'0     X~~~~~~~~~~~~~~~~~~~~ error: no match found
check:5'1                           with "@LINE-1" equal to "4"
           2: Suppressed 1 warnings (1 in non-user code).
check:5'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:5'2              ?                                   possible intended match
           3: Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
check:5'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>>>
```

https://github.com/llvm/llvm-project/pull/140388


More information about the cfe-commits mailing list