[clang] Diagnose problematic uses of constructor/destructor attribute (PR #67360)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 26 07:40:17 PDT 2023
================
@@ -171,6 +171,11 @@ Attribute Changes in Clang
automatic diagnostic to use parameters of types that the format style
supports but that are never the result of default argument promotion, such as
``float``. (`#59824: <https://github.com/llvm/llvm-project/issues/59824>`_)
+- The ``constructor`` and ``destructor`` attributes now diagnose when:
+ - the priority is not between 101 and 65535, inclusive,
+ - the function it is applied to accepts arguments or has a non-void return
----------------
AaronBallman wrote:
Okay, after chatting with @erichkeane about this off-list, it seems we're going to have to support `int` as a return type as there is enough existing code in the wild using it and that returned value is safe on every ABI and calling convention we support. e.g.,
https://searchcode.com/file/664462906/src/sound/alure/CMakeLists.txt (see line 70)
https://searchcode.com/file/624978895/deps/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/memory.h/ (see line 63)
(and others)
As best we can find, it seems all of these uses are returning `int` specifically. So the current thinking is that we accept `void`, `int`, and `unsigned int` as valid return types, and error on any other type. I can update the documentation for the attributes to explain why.
https://github.com/llvm/llvm-project/pull/67360
More information about the cfe-commits
mailing list