9 Commits

Author SHA1 Message Date
Aaron Ballman
ac2722873b Revert "Diagnose problematic uses of constructor/destructor attribute (#67673)"
This reverts commit 27ecb63c260400dd20b8c5dc16d0dfd2d0e7122e.

Still fails compiler-rt:
https://lab.llvm.org/buildbot/#/builders/109/builds/75364
2023-10-11 09:02:24 -04:00
Aaron Ballman
27ecb63c26 Diagnose problematic uses of constructor/destructor attribute (#67673)
Functions with these attributes will be automatically called before
main() or after main() exits gracefully. In glibc environments, the
constructor function is passed the same arguments as main(), so that
signature is allowed. In all other environments, we require the function
to accept no arguments and either return `void` or `int`. The functions
must use the C calling convention. In C++ language modes, the functions
cannot be a nonstatic member function, or a consteval function.

Additionally, these reuse the same priority logic as the init_priority
attribute which explicitly reserved priorty values <= 100 or > 65535. So
we now diagnose use of reserved priorities the same as we do for the
init_priority attribute, but we downgrade the error to be a warning
which defaults to an error to ease use for implementers like compiler-rt
or libc.

This relands a633a3761fcbd0799426cbf5fbd7794961080e43 with fixes.
2023-10-11 08:55:33 -04:00
Aaron Ballman
0cb6c413b1 Revert "Diagnose problematic uses of constructor/destructor attribute (#67673)"
This reverts commit a633a3761fcbd0799426cbf5fbd7794961080e43.

Still breaking compiler-rt bots:
https://lab.llvm.org/buildbot/#/builders/109/builds/75360
2023-10-11 08:31:13 -04:00
Aaron Ballman
a633a3761f
Diagnose problematic uses of constructor/destructor attribute (#67673)
Functions with these attributes will be automatically called before
main() or after main() exits gracefully. In glibc environments, the
constructor function is passed the same arguments as main(), so that
signature is allowed. In all other environments, we require the function
to accept no arguments and either return `void` or `int`. The functions
must use the C calling convention. In C++ language modes, the functions
cannot be a nonstatic member function, or a consteval function.

Additionally, these reuse the same priority logic as the init_priority
attribute which explicitly reserved priorty values <= 100 or > 65535. So
we now diagnose use of reserved priorities the same as we do for the
init_priority attribute, but we downgrade the error to be a warning
which defaults to an error to ease use for implementers like compiler-rt
or libc.

This relands b4435104ca3904529723b0673cc0f624cf8c54e6 with fixes.
2023-10-11 08:14:45 -04:00
Aaron Ballman
50abfc4298 Revert "Diagnose problematic uses of constructor/destructor attribute (#67360)"
This reverts commit b4435104ca3904529723b0673cc0f624cf8c54e6.

This caused too many disruptions in compiler-rt where reserved
priorities were being used. Reverting to investigate appropriate
solutions.
2023-09-26 14:05:27 -04:00
Aaron Ballman
b4435104ca
Diagnose problematic uses of constructor/destructor attribute (#67360)
Functions with these attributes will be automatically called before
`main()` or after `main()` exits gracefully, which means the functions
should not accept arguments or have a returned value (nothing can
provide an argument to the call in these cases, and nothing can use the
returned value), nor should they be allowed on a non-static member
function or consteval function in C++. We allow 'int' as a return type for
the function due to finding a significant amount of historical code using
`int(void)` as a signature.

Additionally, these reuse the same priority logic as the init_priority
attribute which explicitly reserved priorty values <= 100 or > 65535. So
we now diagnose use of reserved priorities the same as we do for the
init_priority attribute.
2023-09-26 12:54:30 -04:00
Nikita Popov
1b9a6e58a8 [CodeGenCXX] Convert some tests to opaque pointers (NFC)
Conversion done using the script at
https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34.

These are tests where the conversion worked out of the box and no
manual fixup was performed.
2022-10-06 12:22:03 +02:00
Nikita Popov
532dc62b90 [OpaquePtrs][Clang] Add -no-opaque-pointers to tests (NFC)
This adds -no-opaque-pointers to clang tests whose output will
change when opaque pointers are enabled by default. This is
intended to be part of the migration approach described in
https://discourse.llvm.org/t/enabling-opaque-pointers-by-default/61322/9.

The patch has been produced by replacing %clang_cc1 with
%clang_cc1 -no-opaque-pointers for tests that fail with opaque
pointers enabled. Worth noting that this doesn't cover all tests,
there's a remaining ~40 tests not using %clang_cc1 that will need
a followup change.

Differential Revision: https://reviews.llvm.org/D123115
2022-04-07 12:09:47 +02:00
Xiangling Liao
17497ec514 [AIX][FE] Support constructor/destructor attribute
Support attribute((constructor)) and attribute((destructor)) on AIX

Differential Revision: https://reviews.llvm.org/D90892
2020-11-19 09:24:01 -05:00