|
@@ -22,7 +22,7 @@ using namespace cxcursor;
|
|
IndexingContext::ObjCProtocolListInfo::ObjCProtocolListInfo(
|
|
IndexingContext::ObjCProtocolListInfo::ObjCProtocolListInfo(
|
|
const ObjCProtocolList &ProtList,
|
|
const ObjCProtocolList &ProtList,
|
|
IndexingContext &IdxCtx,
|
|
IndexingContext &IdxCtx,
|
|
- StrAdapter &SA) {
|
|
|
|
|
|
+ ScratchAlloc &SA) {
|
|
ObjCInterfaceDecl::protocol_loc_iterator LI = ProtList.loc_begin();
|
|
ObjCInterfaceDecl::protocol_loc_iterator LI = ProtList.loc_begin();
|
|
for (ObjCInterfaceDecl::protocol_iterator
|
|
for (ObjCInterfaceDecl::protocol_iterator
|
|
I = ProtList.begin(), E = ProtList.end(); I != E; ++I, ++LI) {
|
|
I = ProtList.begin(), E = ProtList.end(); I != E; ++I, ++LI) {
|
|
@@ -46,9 +46,27 @@ IndexingContext::ObjCProtocolListInfo::ObjCProtocolListInfo(
|
|
Prots.push_back(&ProtInfos[i]);
|
|
Prots.push_back(&ProtInfos[i]);
|
|
}
|
|
}
|
|
|
|
|
|
-IndexingContext::AttrListInfo::AttrListInfo(const Decl *D,
|
|
|
|
- IndexingContext &IdxCtx,
|
|
|
|
- StrAdapter &SA) {
|
|
|
|
|
|
+
|
|
|
|
+IBOutletCollectionInfo::IBOutletCollectionInfo(
|
|
|
|
+ const IBOutletCollectionInfo &other)
|
|
|
|
+ : AttrInfo(CXIdxAttr_IBOutletCollection, other.cursor, other.loc, A) {
|
|
|
|
+
|
|
|
|
+ IBCollInfo.attrInfo = this;
|
|
|
|
+ IBCollInfo.classCursor = other.IBCollInfo.classCursor;
|
|
|
|
+ IBCollInfo.classLoc = other.IBCollInfo.classLoc;
|
|
|
|
+ if (other.IBCollInfo.objcClass) {
|
|
|
|
+ ClassInfo = other.ClassInfo;
|
|
|
|
+ IBCollInfo.objcClass = &ClassInfo;
|
|
|
|
+ } else
|
|
|
|
+ IBCollInfo.objcClass = 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+AttrListInfo::AttrListInfo(const Decl *D,
|
|
|
|
+ IndexingContext &IdxCtx,
|
|
|
|
+ ScratchAlloc &SA) : ref_cnt(0) {
|
|
|
|
+ if (!D->hasAttrs())
|
|
|
|
+ return;
|
|
|
|
+
|
|
for (AttrVec::const_iterator AttrI = D->attr_begin(), AttrE = D->attr_end();
|
|
for (AttrVec::const_iterator AttrI = D->attr_begin(), AttrE = D->attr_end();
|
|
AttrI != AttrE; ++AttrI) {
|
|
AttrI != AttrE; ++AttrI) {
|
|
const Attr *A = *AttrI;
|
|
const Attr *A = *AttrI;
|
|
@@ -95,9 +113,24 @@ IndexingContext::AttrListInfo::AttrListInfo(const Decl *D,
|
|
CXAttrs.push_back(&Attrs[i]);
|
|
CXAttrs.push_back(&Attrs[i]);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+AttrListInfo::AttrListInfo(const AttrListInfo &other) {
|
|
|
|
+ assert(other.ref_cnt == 0 &&
|
|
|
|
+ "Should not copy an AttrListInfo that is ref-counted");
|
|
|
|
+ ref_cnt = 0;
|
|
|
|
+
|
|
|
|
+ Attrs = other.Attrs;
|
|
|
|
+ IBCollAttrs = other.IBCollAttrs;
|
|
|
|
+
|
|
|
|
+ for (unsigned i = 0, e = IBCollAttrs.size(); i != e; ++i)
|
|
|
|
+ CXAttrs.push_back(&IBCollAttrs[i]);
|
|
|
|
+
|
|
|
|
+ for (unsigned i = 0, e = Attrs.size(); i != e; ++i)
|
|
|
|
+ CXAttrs.push_back(&Attrs[i]);
|
|
|
|
+}
|
|
|
|
+
|
|
IndexingContext::CXXBasesListInfo::CXXBasesListInfo(const CXXRecordDecl *D,
|
|
IndexingContext::CXXBasesListInfo::CXXBasesListInfo(const CXXRecordDecl *D,
|
|
IndexingContext &IdxCtx,
|
|
IndexingContext &IdxCtx,
|
|
- IndexingContext::StrAdapter &SA) {
|
|
|
|
|
|
+ ScratchAlloc &SA) {
|
|
for (CXXRecordDecl::base_class_const_iterator
|
|
for (CXXRecordDecl::base_class_const_iterator
|
|
I = D->bases_begin(), E = D->bases_end(); I != E; ++I) {
|
|
I = D->bases_begin(), E = D->bases_end(); I != E; ++I) {
|
|
const CXXBaseSpecifier &Base = *I;
|
|
const CXXBaseSpecifier &Base = *I;
|
|
@@ -155,7 +188,7 @@ SourceLocation IndexingContext::CXXBasesListInfo::getBaseLoc(
|
|
return Loc;
|
|
return Loc;
|
|
}
|
|
}
|
|
|
|
|
|
-const char *IndexingContext::StrAdapter::toCStr(StringRef Str) {
|
|
|
|
|
|
+const char *ScratchAlloc::toCStr(StringRef Str) {
|
|
if (Str.empty())
|
|
if (Str.empty())
|
|
return "";
|
|
return "";
|
|
if (Str.data()[Str.size()] == '\0')
|
|
if (Str.data()[Str.size()] == '\0')
|
|
@@ -163,7 +196,7 @@ const char *IndexingContext::StrAdapter::toCStr(StringRef Str) {
|
|
return copyCStr(Str);
|
|
return copyCStr(Str);
|
|
}
|
|
}
|
|
|
|
|
|
-const char *IndexingContext::StrAdapter::copyCStr(StringRef Str) {
|
|
|
|
|
|
+const char *ScratchAlloc::copyCStr(StringRef Str) {
|
|
char *buf = IdxCtx.StrScratch.Allocate<char>(Str.size() + 1);
|
|
char *buf = IdxCtx.StrScratch.Allocate<char>(Str.size() + 1);
|
|
std::uninitialized_copy(Str.begin(), Str.end(), buf);
|
|
std::uninitialized_copy(Str.begin(), Str.end(), buf);
|
|
buf[Str.size()] = '\0';
|
|
buf[Str.size()] = '\0';
|
|
@@ -195,7 +228,7 @@ void IndexingContext::ppIncludedFile(SourceLocation hashLoc,
|
|
if (!CB.ppIncludedFile)
|
|
if (!CB.ppIncludedFile)
|
|
return;
|
|
return;
|
|
|
|
|
|
- StrAdapter SA(*this);
|
|
|
|
|
|
+ ScratchAlloc SA(*this);
|
|
CXIdxIncludedFileInfo Info = { getIndexLoc(hashLoc),
|
|
CXIdxIncludedFileInfo Info = { getIndexLoc(hashLoc),
|
|
SA.toCStr(filename),
|
|
SA.toCStr(filename),
|
|
(CXFile)File,
|
|
(CXFile)File,
|
|
@@ -226,7 +259,7 @@ bool IndexingContext::handleDecl(const NamedDecl *D,
|
|
if (D->isImplicit() && shouldIgnoreIfImplicit(D))
|
|
if (D->isImplicit() && shouldIgnoreIfImplicit(D))
|
|
return false;
|
|
return false;
|
|
|
|
|
|
- StrAdapter SA(*this);
|
|
|
|
|
|
+ ScratchAlloc SA(*this);
|
|
getEntityInfo(D, DInfo.EntInfo, SA);
|
|
getEntityInfo(D, DInfo.EntInfo, SA);
|
|
if (!DInfo.EntInfo.USR || Loc.isInvalid())
|
|
if (!DInfo.EntInfo.USR || Loc.isInvalid())
|
|
return false;
|
|
return false;
|
|
@@ -320,7 +353,7 @@ bool IndexingContext::handleObjCClass(const ObjCClassDecl *D) {
|
|
}
|
|
}
|
|
|
|
|
|
bool IndexingContext::handleObjCInterface(const ObjCInterfaceDecl *D) {
|
|
bool IndexingContext::handleObjCInterface(const ObjCInterfaceDecl *D) {
|
|
- StrAdapter SA(*this);
|
|
|
|
|
|
+ ScratchAlloc SA(*this);
|
|
|
|
|
|
CXIdxBaseClassInfo BaseClass;
|
|
CXIdxBaseClassInfo BaseClass;
|
|
EntityInfo BaseEntity;
|
|
EntityInfo BaseEntity;
|
|
@@ -366,7 +399,7 @@ bool IndexingContext::handleObjCForwardProtocol(const ObjCProtocolDecl *D,
|
|
}
|
|
}
|
|
|
|
|
|
bool IndexingContext::handleObjCProtocol(const ObjCProtocolDecl *D) {
|
|
bool IndexingContext::handleObjCProtocol(const ObjCProtocolDecl *D) {
|
|
- StrAdapter SA(*this);
|
|
|
|
|
|
+ ScratchAlloc SA(*this);
|
|
ObjCProtocolListInfo ProtListInfo(D->getReferencedProtocols(), *this, SA);
|
|
ObjCProtocolListInfo ProtListInfo(D->getReferencedProtocols(), *this, SA);
|
|
|
|
|
|
ObjCProtocolDeclInfo ProtInfo(D);
|
|
ObjCProtocolDeclInfo ProtInfo(D);
|
|
@@ -378,7 +411,7 @@ bool IndexingContext::handleObjCProtocol(const ObjCProtocolDecl *D) {
|
|
bool IndexingContext::handleObjCCategory(const ObjCCategoryDecl *D) {
|
|
bool IndexingContext::handleObjCCategory(const ObjCCategoryDecl *D) {
|
|
ObjCCategoryDeclInfo CatDInfo(/*isImplementation=*/false);
|
|
ObjCCategoryDeclInfo CatDInfo(/*isImplementation=*/false);
|
|
EntityInfo ClassEntity;
|
|
EntityInfo ClassEntity;
|
|
- StrAdapter SA(*this);
|
|
|
|
|
|
+ ScratchAlloc SA(*this);
|
|
const ObjCInterfaceDecl *IFaceD = D->getClassInterface();
|
|
const ObjCInterfaceDecl *IFaceD = D->getClassInterface();
|
|
SourceLocation ClassLoc = D->getLocation();
|
|
SourceLocation ClassLoc = D->getLocation();
|
|
SourceLocation CategoryLoc = D->IsClassExtension() ? ClassLoc
|
|
SourceLocation CategoryLoc = D->IsClassExtension() ? ClassLoc
|
|
@@ -410,7 +443,7 @@ bool IndexingContext::handleObjCCategoryImpl(const ObjCCategoryImplDecl *D) {
|
|
const ObjCCategoryDecl *CatD = D->getCategoryDecl();
|
|
const ObjCCategoryDecl *CatD = D->getCategoryDecl();
|
|
ObjCCategoryDeclInfo CatDInfo(/*isImplementation=*/true);
|
|
ObjCCategoryDeclInfo CatDInfo(/*isImplementation=*/true);
|
|
EntityInfo ClassEntity;
|
|
EntityInfo ClassEntity;
|
|
- StrAdapter SA(*this);
|
|
|
|
|
|
+ ScratchAlloc SA(*this);
|
|
const ObjCInterfaceDecl *IFaceD = CatD->getClassInterface();
|
|
const ObjCInterfaceDecl *IFaceD = CatD->getClassInterface();
|
|
SourceLocation ClassLoc = D->getLocation();
|
|
SourceLocation ClassLoc = D->getLocation();
|
|
SourceLocation CategoryLoc = D->getCategoryNameLoc();
|
|
SourceLocation CategoryLoc = D->getCategoryNameLoc();
|
|
@@ -519,7 +552,7 @@ bool IndexingContext::handleReference(const NamedDecl *D, SourceLocation Loc,
|
|
return false; // already occurred.
|
|
return false; // already occurred.
|
|
}
|
|
}
|
|
|
|
|
|
- StrAdapter SA(*this);
|
|
|
|
|
|
+ ScratchAlloc SA(*this);
|
|
EntityInfo RefEntity, ParentEntity;
|
|
EntityInfo RefEntity, ParentEntity;
|
|
getEntityInfo(D, RefEntity, SA);
|
|
getEntityInfo(D, RefEntity, SA);
|
|
if (!RefEntity.USR)
|
|
if (!RefEntity.USR)
|
|
@@ -586,7 +619,7 @@ void IndexingContext::setClientEntity(const Decl *D, CXIdxClientEntity client) {
|
|
bool IndexingContext::handleCXXRecordDecl(const CXXRecordDecl *RD,
|
|
bool IndexingContext::handleCXXRecordDecl(const CXXRecordDecl *RD,
|
|
const NamedDecl *OrigD) {
|
|
const NamedDecl *OrigD) {
|
|
if (RD->isThisDeclarationADefinition()) {
|
|
if (RD->isThisDeclarationADefinition()) {
|
|
- StrAdapter SA(*this);
|
|
|
|
|
|
+ ScratchAlloc SA(*this);
|
|
CXXClassDeclInfo CXXDInfo(/*isRedeclaration=*/!OrigD->isCanonicalDecl(),
|
|
CXXClassDeclInfo CXXDInfo(/*isRedeclaration=*/!OrigD->isCanonicalDecl(),
|
|
/*isDefinition=*/RD->isThisDeclarationADefinition());
|
|
/*isDefinition=*/RD->isThisDeclarationADefinition());
|
|
CXXBasesListInfo BaseList(RD, *this, SA);
|
|
CXXBasesListInfo BaseList(RD, *this, SA);
|
|
@@ -731,7 +764,7 @@ void IndexingContext::translateLoc(SourceLocation Loc,
|
|
|
|
|
|
void IndexingContext::getEntityInfo(const NamedDecl *D,
|
|
void IndexingContext::getEntityInfo(const NamedDecl *D,
|
|
EntityInfo &EntityInfo,
|
|
EntityInfo &EntityInfo,
|
|
- StrAdapter &SA) {
|
|
|
|
|
|
+ ScratchAlloc &SA) {
|
|
if (!D)
|
|
if (!D)
|
|
return;
|
|
return;
|
|
|
|
|
|
@@ -743,6 +776,14 @@ void IndexingContext::getEntityInfo(const NamedDecl *D,
|
|
EntityInfo.templateKind = CXIdxEntity_NonTemplate;
|
|
EntityInfo.templateKind = CXIdxEntity_NonTemplate;
|
|
EntityInfo.lang = CXIdxEntityLang_C;
|
|
EntityInfo.lang = CXIdxEntityLang_C;
|
|
|
|
|
|
|
|
+ if (D->hasAttrs()) {
|
|
|
|
+ AttrListInfo *attrs = SA.allocate<AttrListInfo>();
|
|
|
|
+ new (attrs) AttrListInfo(D, *this, SA);
|
|
|
|
+ EntityInfo.AttrList = attrs;
|
|
|
|
+ EntityInfo.attributes = attrs->getAttrs();
|
|
|
|
+ EntityInfo.numAttributes = attrs->getNumAttrs();
|
|
|
|
+ }
|
|
|
|
+
|
|
if (const TagDecl *TD = dyn_cast<TagDecl>(D)) {
|
|
if (const TagDecl *TD = dyn_cast<TagDecl>(D)) {
|
|
switch (TD->getTagKind()) {
|
|
switch (TD->getTagKind()) {
|
|
case TTK_Struct:
|
|
case TTK_Struct:
|