donat.nagy added inline comments.
================ Comment at: clang/test/Analysis/Inputs/std-c-library-functions.h:1-2 +typedef typeof(sizeof(int)) size_t; +typedef signed long ssize_t; +typedef struct { ---------------- balazske wrote: > steakhal wrote: > > balazske wrote: > > > steakhal wrote: > > > > `ssize_t`'s size should match the size of `size_t`. In this > > > > implementation, it would be true only if `size_t` is `long`. > > > > > > > I could not find a working way of defining the type in that way (there is > > > no `__sizte_t`). The current definition should work well in the test > > > code, the property of being the same size is supposedly not used in the > > > tests. The previous definition was not better than this (and different in > > > different places). > > I think [[ > > https://github.com/llvm/llvm-project/blob/main/clang/test/Sema/format-strings-scanf.c#L7-L15 > > | clang/test/Sema/format-strings-scanf.c ]] uses something like this: > > ```lang=C++ > > typedef __SIZE_TYPE__ size_t; > > #define __SSIZE_TYPE__ > > \ > > __typeof__(_Generic((__SIZE_TYPE__)0, > > \ > > unsigned long long int : (long long int)0, > > \ > > unsigned long int : (long int)0, > > \ > > unsigned int : (int)0, > > \ > > unsigned short : (short)0, > > \ > > unsigned char : (signed char)0)) > > typedef __SSIZE_TYPE__ ssize_t; > > ``` > This may work (probably not on all platforms) but still I think in this > context it is only important that we have a type called `ssize_t` and it is > signed, it is less important that it is exactly the correct type. Other types > in the same header are not exact, and `ssize_t` in other test code (in > Analysis tests) is defined not in this way. I agree that we don't need that `_Generic` magic in this particular test file. If we want consistency between the sizes of `size_t` and `ssize_t` then you may define them as e.g. just `unsigned long long` and `long long` -- but I think even that consideration is overkill. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149158/new/ https://reviews.llvm.org/D149158 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits