Handle template parameter-dependent bit field widths in libclang
In a class template, a bit field's width may depend on a template
parameter. In this case the width expression cannot be evaluated.
Previously clang_getFieldDeclBitWidth() would assert, or cause memory
unsafety and return an invalid result if assertions are disabled.
This adds a check for this case which returns an error code. An
additional function clang_isBitFieldDecl() is added to disambiguate
between error code meanings.
I just thought how the new API could be used in KDevelop. Currently when clang_getFieldDeclBitWidth() is positive, e.g. 2, KDevelop shows : 2 after the data member name in a tooltip. Ideally a template-param-dependent expression (actual code) would be displayed after the colon. If that's difficult to implement, : [tparam-dependent] or : ? could be displayed instead. But it would be more convenient and efficient to get this information by a single call to clang_getFieldDeclBitWidth() instead of calling clang_isFieldDeclBitWidthDependent() each time clang_getFieldDeclBitWidth() returns -1. So how about returning -2 or 0 from clang_getFieldDeclBitWidth() instead of adding this new API?