[cfe-dev] hasDefinition() is false for ClassTemplateSpecializationDecl instances
Sergey Lyskov via cfe-dev
cfe-dev at lists.llvm.org
Wed Apr 20 11:54:05 PDT 2016
Never mind, i think i figured this out: turned out that ClassTemplateSpecializationDecl will not have definition info if class is not yet instantiated so workaround for this problem is to check if point of instantiation give a valid source location (i.e. ->getPointOfInstantiation().isInvalid() )
Best,
Sergey.
> On Apr 17, 2016, at 5:16 PM, Sergey Lyskov <sergey.lyskov at gmail.com> wrote:
>
> Dear Developers,
>
> I am working on source analysis tool using LibTooling which use RecursiveASTVisitor to inspect CXXRecordDecl. This works well but occasionally i am getting 'queried property of class with no definition’ (full error below) while trying to access various CXXRecordDecl properties. I am guessing this because underlying CXXRecordDecl is just a forward declaration (is this correct?) so no records could be accessed.
>
> So to filter such forward declarations i added check that call CXXRecordDecl::hasDefinition() and avoid inspecting records that have no definition. This seems to work but this check filter all ClassTemplateSpecializationDecl instances as well because ClassTemplateSpecializationDecl::hasDefinition() return false even for instances that could be inspected.
>
> Is there is a way i can check if instance of ClassTemplateSpecializationDecl has definition and it properties could be queried?
>
> Thanks,
>
> Sergey.
>
> DeclCXX.h:592: clang::CXXRecordDecl::DefinitionData& clang::CXXRecordDecl::data() const: Assertion `DD && "queried property of class with no definition"
>
>
More information about the cfe-dev
mailing list