mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Rename C++ macro 'defer' -> 'SWIFT_DEFER'
In C++ we can't have nice things. The macro name 'defer' collided with use of 'defer' in the Tokens.def file and we were already doing horrible workarounds in a couple of places to allow them to be included into the same file. So use a less awesome but more robust name (thanks to Joe for suggesting SWIFT_DEFER). Incidentally, sort a bunch of #inlcudes.
This commit is contained in:
@@ -10,8 +10,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines a 'defer' macro for performing a cleanup on any exit out
|
||||
// of a scope.
|
||||
// This file defines a 'SWIFT_DEFER' macro for performing a cleanup on any exit
|
||||
// out of a scope.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@@ -45,17 +45,15 @@ namespace swift {
|
||||
#define DEFER_CONCAT_IMPL(x, y) x##y
|
||||
#define DEFER_MACRO_CONCAT(x, y) DEFER_CONCAT_IMPL(x, y)
|
||||
|
||||
#define defer_impl \
|
||||
auto DEFER_MACRO_CONCAT(defer_func, __COUNTER__) = \
|
||||
::swift::detail::DeferTask() + [&]()
|
||||
|
||||
/// This macro is used to register a function / lambda to be run on exit from a
|
||||
/// scope. Its typical use looks like:
|
||||
///
|
||||
/// defer {
|
||||
/// SWIFT_DEFER {
|
||||
/// stuff
|
||||
/// };
|
||||
///
|
||||
#define defer defer_impl
|
||||
#define SWIFT_DEFER \
|
||||
auto DEFER_MACRO_CONCAT(defer_func, __COUNTER__) = \
|
||||
::swift::detail::DeferTask() + [&]()
|
||||
|
||||
#endif // SWIFT_BASIC_DEFER_H
|
||||
|
||||
Reference in New Issue
Block a user