[cfe-dev] C++ Header File Parsing: Update
Raghavendra K
raghavendrak at huawei.com
Fri May 31 05:58:21 PDT 2013
Hi,
I discovered the way to this problem,
const TemplateSpecializationType* tempSpeType = (*classfieldItr)->getType().getTypePtrOrNull()->getAs <TemplateSpecializationType>();
for(int i=0;i<tempSpeType->getNumArgs();i++)
{
fprintf(flogs,"**MAP Arg[%d]=%s ",i,tempSpeType->getArg(i).getAsType().getTypePtrOrNull()->getUnqualifiedDesugaredType()->getTypeClassName());
regards
ragha
________________________________________
From: Raghavendra K
Sent: Thursday, May 30, 2013 2:39 PM
To: cfe-dev at cs.uiuc.edu
Cc: Arvind Saraswat; Linxiaowen
Subject: C++ Header File Parsing: Update
Hi,
calling getParent from the FieldDecl class yields container class. So it is always null.
I have changed the program not use getParent but directly cast to CXXRecordDecl.
Class X
{
A obk;
std::map<int,int> bobj;
};
As per the above class, i get 2 fieldDecl.
First fieldDecl,refers to a local class A and am able to get its fields
Now second fieldDecl is a template, when i try to get CTemplateRecordDecl, it is givingNULL
is it bug in clang? Pls help how to proceed.
Code:
CXXRecordDecl* fieldClass = (*classfieldItr)->getType().getTypePtrOrNull()->getUnqualifiedDesugaredType()->getAsCXXRecordDecl();
CXXRecordDecl* pCXXRecord = (CXXRecordDecl*)fieldClass->getDefinition();
if(pCXXRecord)
{
fprintf(flogs,"****1\n");
TemplateSpecializationKind tempKind = pCXXRecord->getTemplateSpecializationKind();
fprintf(flogs,"****TemplateKind=%d\n",(int)tempKind);
fprintf(flogs,"****Qualfier=%s\n",pCXXRecord->getQualifiedNameAsString().c_str());
ClassTemplateDecl* classTemp = pCXXRecord->getDescribedClassTemplate();=============>is NULL.
if(classTemp)
{
fprintf(flogs,"****2\n");
TemplateParameterList* tempList = classTemp->getTemplateParameters();
if(tempList)
fprintf(flogs,"****SOFAR SO GOOD\n");
}
MemberSpecializationInfo* memSpc = pCXXRecord->getMemberSpecializationInfo();
NamedDecl* pNamedDecl = memSpc->getInstantiatedFrom();
fprintf(flogs,"****NamedDecl=%s\n",pNamedDecl->getNameAsString().c_str());
More information about the cfe-dev
mailing list