[cfe-dev] [libclang] Getting unqualified version of Type

John McCall via cfe-dev cfe-dev at lists.llvm.org
Thu Feb 22 08:41:11 PST 2018


> On Feb 22, 2018, at 10:42 AM, Ɓukasz Kucharski <yayamiomate at gmail.com> wrote:
> 
> John,
> 
> Thanks for reply. I have found `QualType::getUnqualifiedType` when
> digging through clang sources. I thought about exporting it, doesn't
> seem like much of trouble, however so far I didn't find free personal
> time, neither asked for company time to do it.
> 
> I presume it would look like e.g `clang_getPointeeType`, there is a
> `libclag.exports` entry and a python binding, and that is seemingly
> pretty much it.

I'm not an expert in the C API, but yes, I think that's all that's required.

In general, Clang's C API is understood to be incomplete in a number of ways;
we often recommend that people write tools against the C++ API for that reason,
but of course that doesn't provide source or binary compatibility guarantees.

> Regarding the functional spec, to me it would make most sense to
> follow original implementation, and be consistent with already
> exported `is_const_qualified` and `is_volatile_qualified`, the just
> wrap around respective `CXType.cpp` function which in turn are simple
> wrappers around methods:
> 
> ```
> unsigned clang_isConstQualifiedType(CXType CT) {
> QualType T = GetQualType(CT);
> return T.isLocalConstQualified();
> }
> ```
> 
> I imagine something similar could be done for
> `QualType::getUnqualifiedType`. I don't think it looks only at local
> specifiers as there are `Local` counterparts for those methods such as
> `getLocalUnqualifiedType`, `isLocalVolatileQualified`, etc. Those are
> not exported. IMO for the consistency it should be 1-1 export, and if
> other functionality is needed then probably more appropriate methods
> should be exported for external binding.

There is a QualType::getLocalUnqualifiedType() method that just removes
these top-level qualifiers.

John.




More information about the cfe-dev mailing list