While audit our code, we found out a strange pattern in one of the LLVM headers and we were wondering if that was expected or if it should be fixed.
Namely the problem looks like this:
// Define some variable.
assert(/use this variable, i.e., outside of the ifndef NDEBUG scope/);
This happens in include/llvm/IR/ValueHandle.h for the variable Poisoned line 494
This works because when we build LLVM with assert we explicitly disable NDEBUG:
if( LLVM_ENABLE_ASSERTIONS )
if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL “DEBUG” )
add_definitions( -UNDEBUG )
If we use this header in a different project and thus, with potentially different rules for macro definitions, the compiler complains with
error: use of undeclared identifier ‘Poisoned’
I think the right thing to do is to fix the code to work without the special way of setting the macros, but I’d like people opinions first.