[cfe-dev] How can I check if the qualifiers of a type has a class in it?

Nikola Smiljanic popizdeh at gmail.com
Mon Jun 30 23:51:16 PDT 2014


That's because the function itself doesn't have a qualifier. You should be
looking at return type and parameter types in case of FunctionDecl. I can't
tell you how to do this exactly but there should be a way to do it. Also
take a look at CXXScopeSpecifier, if you can get this from the type
NestedNameSpecifier can be obtained from it.


On Tue, Jul 1, 2014 at 4:26 PM, Manasij Mukherjee <manasij7479 at gmail.com>
wrote:

> I have a FunctionDecl while overriding VisitFunctionDecl of ASTVisitor.
>
> I did Decl->getQualifier()->getKind() == NestedNameSpecifier::TypeSpec
> But it segfaults in getKind
> So, I am probably calling getQualifier from the wrong thing.
> Decl->getQualifier() is always returning a null value.
>
> When is a valid qualifier returned?
>
> My input code is:
> namespace test { //nested name specifier
>   class HasSubType {
>   public:
>     class SubType {};
>   };
>   HasSubType::SubType FunctionUsingSubtype(HasSubType::SubType s){return
> s;}
>   extern HasSubType::SubType variable;
>   HasSubType FunctionNotUsingSubType(HasSubType h){return h;}
> }
> I want to filter out FunctionUsingSubType and the variable.
>
>
> Thanks
>
>
>  On Tue, Jul 1, 2014 at 10:28 AM, Nikola Smiljanic <popizdeh at gmail.com>
> wrote:
>
>> It looks like you're looking for NestedNameSpecifier. You should check
>> the Kind and traverse the Prefix. I don't know how you obtain the type as
>> it can appear in various contexts, but assuming you have some kind of Decl
>> object on your hands you can call the the getQualifier() method.
>>
>>
>> On Sun, Jun 29, 2014 at 5:30 PM, Manasij Mukherjee <manasij7479 at gmail.com
>> > wrote:
>>
>>> It seems I made a mistake in terminology.
>>>
>>> What is the following called?
>>> Suppose I have the types:
>>> MyNamespace::ClassName
>>> MyNamespace::ClassName::iterator
>>> The second type has MyNamespace::ClassName as its scope (?).
>>>
>>> I want to detect if there are only namespaces there or a class somewhere
>>> in the scope .
>>>
>>>
>>>
>>> On Sun, Jun 29, 2014 at 9:59 AM, Nikola Smiljanic <popizdeh at gmail.com>
>>> wrote:
>>>
>>>> What do you mean by 'if the qualifiers include a class name"?
>>>>
>>>> Qualifiers class deals with const, volatile, etc.
>>>>
>>>>
>>>>  On Sun, Jun 29, 2014 at 12:40 AM, Manasij Mukherjee <
>>>> manasij7479 at gmail.com> wrote:
>>>>
>>>>>  Hi
>>>>> I get the  qualifiers like this:
>>>>> Qualifiers q = qualifiedType.getQualifiers();
>>>>>
>>>>> How can I check whether if the qualifiers include a class name ?
>>>>>
>>>>> I can not figure out how to find this information from the Qualifiers
>>>>> interface.
>>>>>
>>>>> Types in namespaces ..single or nested.. should not trigger this check.
>>>>>
>>>>> Thanks
>>>>> Manasij Mukherjee
>>>>>
>>>>> _______________________________________________
>>>>> cfe-dev mailing list
>>>>> cfe-dev at cs.uiuc.edu
>>>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140701/dc3bad7e/attachment.html>


More information about the cfe-dev mailing list