[clang] [clang] Catch missing format attributes (PR #70024)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 10 07:55:58 PDT 2024


AaronBallman wrote:

Pre-commit CI seems to have found a valid failure:
```
_bk;t=1720616429374FAIL: Clang :: Sema/attr-format-missing.c (16228 of 20429)
_bk;t=1720616429374******************** TEST 'Clang :: Sema/attr-format-missing.c' FAILED ********************
_bk;t=1720616429374Exit Code: 1
_bk;t=1720616429374
_bk;t=1720616429374Command Output (stdout):
_bk;t=1720616429374--
_bk;t=1720616429374# RUN: at line 1
_bk;t=1720616429374c:\ws\src\build\bin\clang.exe -cc1 -internal-isystem C:\ws\src\build\lib\clang\19\include -nostdsysteminc -fsyntax-only -verify=expected,c_diagnostics -Wmissing-format-attribute C:\ws\src\clang\test\Sema\attr-format-missing.c
_bk;t=1720616429374# executed command: 'c:\ws\src\build\bin\clang.exe' -cc1 -internal-isystem 'C:\ws\src\build\lib\clang\19\include' -nostdsysteminc -fsyntax-only -verify=expected,c_diagnostics -Wmissing-format-attribute 'C:\ws\src\clang\test\Sema\attr-format-missing.c'
_bk;t=1720616429374# note: command had no output on stdout or stderr
_bk;t=1720616429374# RUN: at line 2
_bk;t=1720616429374c:\ws\src\build\bin\clang.exe -cc1 -internal-isystem C:\ws\src\build\lib\clang\19\include -nostdsysteminc -fsyntax-only -Wmissing-format-attribute -fdiagnostics-parseable-fixits C:\ws\src\clang\test\Sema\attr-format-missing.c 2>&1 | c:\ws\src\build\bin\filecheck.exe C:\ws\src\clang\test\Sema\attr-format-missing.c --check-prefixes=CHECK,C-CHECK
_bk;t=1720616429374# executed command: 'c:\ws\src\build\bin\clang.exe' -cc1 -internal-isystem 'C:\ws\src\build\lib\clang\19\include' -nostdsysteminc -fsyntax-only -Wmissing-format-attribute -fdiagnostics-parseable-fixits 'C:\ws\src\clang\test\Sema\attr-format-missing.c'
_bk;t=1720616429374# note: command had no output on stdout or stderr
_bk;t=1720616429374# executed command: 'c:\ws\src\build\bin\filecheck.exe' 'C:\ws\src\clang\test\Sema\attr-format-missing.c' --check-prefixes=CHECK,C-CHECK
_bk;t=1720616429374# note: command had no output on stdout or stderr
_bk;t=1720616429374# RUN: at line 3
_bk;t=1720616429374c:\ws\src\build\bin\clang.exe -cc1 -internal-isystem C:\ws\src\build\lib\clang\19\include -nostdsysteminc -fsyntax-only -x c++ -verify=expected,cpp_diagnostics -Wmissing-format-attribute C:\ws\src\clang\test\Sema\attr-format-missing.c
_bk;t=1720616429374# executed command: 'c:\ws\src\build\bin\clang.exe' -cc1 -internal-isystem 'C:\ws\src\build\lib\clang\19\include' -nostdsysteminc -fsyntax-only -x c++ -verify=expected,cpp_diagnostics -Wmissing-format-attribute 'C:\ws\src\clang\test\Sema\attr-format-missing.c'
_bk;t=1720616429374# note: command had no output on stdout or stderr
_bk;t=1720616429374# RUN: at line 4
_bk;t=1720616429374c:\ws\src\build\bin\clang.exe -cc1 -internal-isystem C:\ws\src\build\lib\clang\19\include -nostdsysteminc -fsyntax-only -x c++ -verify=expected,cpp_diagnostics -std=c++2b -Wmissing-format-attribute C:\ws\src\clang\test\Sema\attr-format-missing.c
_bk;t=1720616429374# executed command: 'c:\ws\src\build\bin\clang.exe' -cc1 -internal-isystem 'C:\ws\src\build\lib\clang\19\include' -nostdsysteminc -fsyntax-only -x c++ -verify=expected,cpp_diagnostics -std=c++2b -Wmissing-format-attribute 'C:\ws\src\clang\test\Sema\attr-format-missing.c'
_bk;t=1720616429374# note: command had no output on stdout or stderr
_bk;t=1720616429374# RUN: at line 5
_bk;t=1720616429374c:\ws\src\build\bin\clang.exe -cc1 -internal-isystem C:\ws\src\build\lib\clang\19\include -nostdsysteminc -fsyntax-only -x c++ -verify=expected,cpp_diagnostics -std=c++23 -Wmissing-format-attribute C:\ws\src\clang\test\Sema\attr-format-missing.c
_bk;t=1720616429374# executed command: 'c:\ws\src\build\bin\clang.exe' -cc1 -internal-isystem 'C:\ws\src\build\lib\clang\19\include' -nostdsysteminc -fsyntax-only -x c++ -verify=expected,cpp_diagnostics -std=c++23 -Wmissing-format-attribute 'C:\ws\src\clang\test\Sema\attr-format-missing.c'
_bk;t=1720616429374# note: command had no output on stdout or stderr
_bk;t=1720616429374# RUN: at line 6
_bk;t=1720616429374not c:\ws\src\build\bin\clang.exe -cc1 -internal-isystem C:\ws\src\build\lib\clang\19\include -nostdsysteminc -fsyntax-only -x c++ -Wmissing-format-attribute -fdiagnostics-parseable-fixits C:\ws\src\clang\test\Sema\attr-format-missing.c 2>&1 | c:\ws\src\build\bin\filecheck.exe C:\ws\src\clang\test\Sema\attr-format-missing.c --check-prefixes=CHECK,CPP-CHECK
_bk;t=1720616429374# executed command: not 'c:\ws\src\build\bin\clang.exe' -cc1 -internal-isystem 'C:\ws\src\build\lib\clang\19\include' -nostdsysteminc -fsyntax-only -x c++ -Wmissing-format-attribute -fdiagnostics-parseable-fixits 'C:\ws\src\clang\test\Sema\attr-format-missing.c'
_bk;t=1720616429374# note: command had no output on stdout or stderr
_bk;t=1720616429374# executed command: 'c:\ws\src\build\bin\filecheck.exe' 'C:\ws\src\clang\test\Sema\attr-format-missing.c' --check-prefixes=CHECK,CPP-CHECK
_bk;t=1720616429374# .---command stderr------------
_bk;t=1720616429374# | C:\ws\src\clang\test\Sema\attr-format-missing.c:398:16: error: CPP-CHECK: expected string not found in input
_bk;t=1720616429374# |  // CPP-CHECK: fix-it:"{{.*}}":{[[@LINE-14]]:6-[[@LINE-14]]:6}:"__attribute__((format(printf, 1, 2)))"
_bk;t=1720616429374# |                ^
_bk;t=1720616429374# | <stdin>:162:117: note: scanning from here
_bk;t=1720616429374# | fix-it:"C:\\ws\\src\\clang\\test\\Sema\\attr-format-missing.c":{369:6-369:6}:"__attribute__((format(printf, 1, 0)))"
_bk;t=1720616429374# |                                                                                                                     ^
_bk;t=1720616429374# | <stdin>:162:117: note: with "@LINE-14" equal to "384"
_bk;t=1720616429374# | fix-it:"C:\\ws\\src\\clang\\test\\Sema\\attr-format-missing.c":{369:6-369:6}:"__attribute__((format(printf, 1, 0)))"
_bk;t=1720616429374# |                                                                                                                     ^
_bk;t=1720616429374# | <stdin>:162:117: note: with "@LINE-14" equal to "384"
_bk;t=1720616429374# | fix-it:"C:\\ws\\src\\clang\\test\\Sema\\attr-format-missing.c":{369:6-369:6}:"__attribute__((format(printf, 1, 0)))"
_bk;t=1720616429374# |                                                                                                                     ^
_bk;t=1720616429374# | 
_bk;t=1720616429374# | Input file: <stdin>
_bk;t=1720616429374# | Check file: C:\ws\src\clang\test\Sema\attr-format-missing.c
_bk;t=1720616429374# | 
_bk;t=1720616429374# | -dump-input=help explains the following input dump.
_bk;t=1720616429374# | 
_bk;t=1720616429374# | Input was:
_bk;t=1720616429374# | <<<<<<
_bk;t=1720616429374# |              .
_bk;t=1720616429374# |              .
_bk;t=1720616429374# |              .
_bk;t=1720616429374# |            157: fix-it:"C:\\ws\\src\\clang\\test\\Sema\\attr-format-missing.c":{363:6-363:6}:"__attribute__((format(scanf, 1, 0)))" 
_bk;t=1720616429374# |            158: C:\ws\src\clang\test\Sema\attr-format-missing.c:369:6: warning: diagnostic behavior may be improved by adding the 'printf' format attribute to the declaration of 'f39' [-Wmissing-format-attribute] 
_bk;t=1720616429374# |            159:  369 | void f39(const char *out, tdVaList args) // #f39 
_bk;t=1720616429374# |            160:  | ^ 
_bk;t=1720616429374# |            161:  | __attribute__((format(printf, 1, 0))) 
_bk;t=1720616429374# |            162: fix-it:"C:\\ws\\src\\clang\\test\\Sema\\attr-format-missing.c":{369:6-369:6}:"__attribute__((format(printf, 1, 0)))" 
_bk;t=1720616429374# | check:398'0                                                                                                                         X error: no match found
_bk;t=1720616429374# | check:398'1                                                                                                                           with "@LINE-14" equal to "384"
_bk;t=1720616429374# | check:398'2                                                                                                                           with "@LINE-14" equal to "384"
_bk;t=1720616429374# |            163: 24 warnings and 7 errors generated. 
_bk;t=1720616429374# | check:398'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_bk;t=1720616429374# | >>>>>>
_bk;t=1720616429374# `-----------------------------
_bk;t=1720616429374# error: command failed with exit status: 1
_bk;t=1720616429374
_bk;t=1720616429374--
```

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


More information about the cfe-commits mailing list