[clang] [Clang] Fix __is_array returning true for zero-sized arrays (PR #86652)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed May 15 10:04:50 PDT 2024
https://github.com/AaronBallman approved this pull request.
Realistically, I don't think we can deprecate the extension in general:
https://sourcegraph.com/search?q=context:global+%5BA-Za-z0-9_%5D%2B%5Cs%5BA-Za-z0-9_%5D%2B%5C%5B0%5C%5D%3B+-file:.*test.*+-file:.*clang.*+count:100000&patternType=regexp&sm=0
I don't think we can even deprecate it for just C++:
https://sourcegraph.com/search?q=context:global+%5BA-Za-z0-9_%5D%2B%5Cs%5BA-Za-z0-9_%5D%2B%5C%5B0%5C%5D%3B+-file:.*test.*+-file:.*clang.*+count:100000+lang:C%2B%2B+&patternType=regexp&sm=0
but we might be able to deprecate it for uses where the zero-sized array is not the last member of a structure declaration:
https://sourcegraph.com/search?q=context:global+%5BA-Za-z0-9_%5D%2B%5Cs%5BA-Za-z0-9_%5D%2B%5C%5B0%5C%5D%3B%5Cs*%5BA-Za-z_%5D+-file:.*test.*+-file:.*clang.*+lang:C+count:100000&patternType=regexp&sm=0 (has a lot of false positives like `sizeof foo[0];` and `return foo[0];`)
I think we should consider deprecation orthogonal to this patch though.
There does not seem to be evidence that this is being used for anything other than implementing traits: https://sourcegraph.com/search?q=context:global+__is_array%5Cb+lang:C%2B%2B+-file:.*test.*+-file:.*clang.*+-file:.*libcxx.*+-file:.*libc%5C%2B%5C%2B.*+-file:.*trait.*+-repo:.*clang.*&patternType=regexp&sm=0
so I think the patch is "correct" insofar as this terrible extension is concerned. Some small nits with the changes, but otherwise LGTM.
https://github.com/llvm/llvm-project/pull/86652
More information about the cfe-commits
mailing list