[PATCH] D15173: [Preprocessor] Fix assertion in AnnotatePreviousCachedTokens

Duncan P. N. Exon Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 7 14:24:11 PST 2015


> On 2015-Dec-07, at 14:22, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
> 
> 
>> On 2015-Dec-07, at 13:29, Bruno Cardoso Lopes <bruno.cardoso at gmail.com> wrote:
>> 
>> bruno added a comment.
>> 
>> Hi Argyrios,
>> 
>> Thanks for the suggestions, will apply them.
>> The assertion seems important to catch subtle bugs, are you sure it should be placed inside a "#ifndef NDEBUG”?
> 
> FYI, the definition for `assert` is something like:
> 
> #ifdef NDEBUG
> #define assert(cond)
> #else
> #define assert(cond) \
> if (!(cond)) { assertion_failed(#FILE ":" #LINE ": " #cond); };
> #endif

Probably more like:

#ifdef NDEBUG
#define assert(cond) (void)0
#else
#define assert(cond) \
do { \
   if (!(cond)) { assertion_failed(#FILE ":" #LINE ": " #cond); }; \
} while (false)
#endif

but the point is, NDEBUG is the "are assertions on?" macro.

>> 
>> 
>> http://reviews.llvm.org/D15173
>> 
>> 
>> 
> 



More information about the cfe-commits mailing list