File tree Expand file tree Collapse file tree 2 files changed +26
-9
lines changed Expand file tree Collapse file tree 2 files changed +26
-9
lines changed Original file line number Diff line number Diff line change 103
103
#define SWIFT_CRASH_BUG_REPORT_MESSAGE \
104
104
" Please " SWIFT_BUG_REPORT_MESSAGE_BASE " and the crash backtrace."
105
105
106
+ // Conditionally exclude declarations or statements that are only needed for
107
+ // assertions from release builds (NDEBUG) without cluttering the surrounding
108
+ // code by #ifdefs.
109
+ //
110
+ // struct DoThings {
111
+ // SWIFT_ASSERT_ONLY_DECL(unsigned verifyCount = 0);
112
+ // DoThings() {
113
+ // SWIFT_ASSERT_ONLY(verifyCount = getNumberOfThingsToDo());
114
+ // }
115
+ // void doThings() {
116
+ // do {
117
+ // // ... do each thing
118
+ // SWIFT_ASSERT_ONLY(--verifyCount);
119
+ // } while (!done());
120
+ // assert(verifyCount == 0 && "did not do everything");
121
+ // }
122
+ // };
123
+ #ifdef NDEBUG
124
+ #define SWIFT_ASSERT_ONLY_DECL (X )
125
+ #define SWIFT_ASSERT_ONLY (X ) do { } while (false )
126
+ #else
127
+ #define SWIFT_ASSERT_ONLY_DECL (X ) X
128
+ #define SWIFT_ASSERT_ONLY (X ) do { X; } while (false )
129
+ #endif
130
+
106
131
#endif // SWIFT_BASIC_COMPILER_H
Original file line number Diff line number Diff line change 90
90
91
91
#include " swift/SIL/SILBasicBlock.h"
92
92
93
- #ifdef NDEBUG
94
- #define SWIFT_ASSERT_ONLY_MEMBER (X )
95
- #define SWIFT_ASSERT_ONLY (X ) do { } while (false )
96
- #else
97
- #define SWIFT_ASSERT_ONLY_MEMBER (X ) X
98
- #define SWIFT_ASSERT_ONLY (X ) do { X; } while (false )
99
- #endif
100
-
101
93
namespace swift {
102
94
103
95
// / Discover "pruned" liveness for an arbitrary set of uses. The client builds
@@ -140,7 +132,7 @@ class PrunedLiveBlocks {
140
132
llvm::SmallDenseMap<SILBasicBlock *, bool , 4 > liveBlocks;
141
133
142
134
// Once the first use has been seen, no definitions can be added.
143
- SWIFT_ASSERT_ONLY_MEMBER (bool seenUse = false );
135
+ SWIFT_ASSERT_ONLY_DECL (bool seenUse = false );
144
136
145
137
public:
146
138
bool empty () const { return liveBlocks.empty (); }
You can’t perform that action at this time.
0 commit comments