How would I test if a c++ method is const qualified in clang?
For example::
class Inner{
public:
int i;
Inner();
float inner_method() const;
};
I am using the clang-c library and I have tried using clang_isConstQualifiedType on the inner_method node. however this returns false.
I don’t mind if the answer uses the clang c++ headers.
In the C++ interface, the way to check this is using
CXXMethodDecl::getTypeQualifiers(), or usingFunctionProtoType::getTypeQuals()(depending on whether you have the declaration or the type). TheQualifiers::Constbit indicates whether the method (or method type) is const.In the libclang C API, this information seems to only be used in the implementation of
getCursorUSR, whose result is not intended to be parsed, so using the C++ API or submitting a patch to add this functionality to the C API are the best options.