[clang] [Clang][Sema] Disallow applying `onwership_returns` to functions that return non-pointers (PR #99564)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 19 06:27:38 PDT 2024


AaronBallman wrote:

Adding the static analysis code owners for input.

Also, precommit CI found a valid failure:
```
FAIL: Clang :: AST/attr-print-emit.cpp (400 of 20466)
******************** TEST 'Clang :: AST/attr-print-emit.cpp' FAILED ********************
Exit Code: 1
Command Output (stdout):
--
# RUN: at line 1
c:\ws\src\build\bin\clang.exe -cc1 -internal-isystem C:\ws\src\build\lib\clang\19\include -nostdsysteminc C:\ws\src\clang\test\AST\attr-print-emit.cpp -ast-print | c:\ws\src\build\bin\filecheck.exe C:\ws\src\clang\test\AST\attr-print-emit.cpp
# executed command: 'c:\ws\src\build\bin\clang.exe' -cc1 -internal-isystem 'C:\ws\src\build\lib\clang\19\include' -nostdsysteminc 'C:\ws\src\clang\test\AST\attr-print-emit.cpp' -ast-print
# note: command had no output on stdout or stderr
# executed command: 'c:\ws\src\build\bin\filecheck.exe' 'C:\ws\src\clang\test\AST\attr-print-emit.cpp'
# .---command stderr------------
# | C:\ws\src\clang\test\AST\attr-print-emit.cpp:35:11: error: CHECK: expected string not found in input
# | // CHECK: void ownr(int) __attribute__((ownership_returns(foo, 1)));
# |           ^
# | <stdin>:11:69: note: scanning from here
# | void ownh(int *, int *) __attribute__((ownership_holds(foo, 1, 2)));
# |                                                                     ^
# | <stdin>:12:1: note: possible intended match here
# | void *ownr(int) __attribute__((ownership_returns(foo, 1)));
# | ^
# |
# | Input file: <stdin>
# | Check file: C:\ws\src\clang\test\AST\attr-print-emit.cpp
# |
# | -dump-input=help explains the following input dump.
# |
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |             6: void fmt(int, const char *, ...) __attribute__((format(printf, 2, 3)));
# |             7: char *fmta(int, const char *) __attribute__((format_arg(2)));
# |             8: void nn(int *, int *) __attribute__((nonnull(1, 2)));
# |             9: int *aa(int i) __attribute__((alloc_align(1)));
# |            10: void ownt(int *, int *) __attribute__((ownership_takes(foo, 1, 2)));
# |            11: void ownh(int *, int *) __attribute__((ownership_holds(foo, 1, 2)));
# | check:35'0                                                                         X error: no match found
# |            12: void *ownr(int) __attribute__((ownership_returns(foo, 1)));
# | check:35'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | check:35'1     ?                                                            possible intended match
# |            13: void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 3, 2)));
# | check:35'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            14: void pwtt(void *, int) __attribute__((pointer_with_type_tag(foo, 1, 2)));
# | check:35'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            15: class C {
# | check:35'0     ~~~~~~~~~~
# |            16:  void xla(int a) __attribute__((xray_log_args(2)));
# | check:35'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            17:  void *as2(int, int) __attribute__((alloc_size(2, 3)));
# | check:35'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             .
# |             .
# |             .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1
--
********************
```

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


More information about the cfe-commits mailing list