//===- IndexingContext.cpp - Higher level API functions -------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "IndexingContext.h"
#include "CIndexDiagnostic.h"
#include "CXTranslationUnit.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/Frontend/ASTUnit.h"
using namespace clang;
using namespace cxindex;
using namespace cxcursor;
IndexingContext::ObjCProtocolListInfo::ObjCProtocolListInfo(
const ObjCProtocolList &ProtList,
IndexingContext &IdxCtx,
ScratchAlloc &SA) {
ObjCInterfaceDecl::protocol_loc_iterator LI = ProtList.loc_begin();
for (ObjCInterfaceDecl::protocol_iterator
I = ProtList.begin(), E = ProtList.end(); I != E; ++I, ++LI) {
SourceLocation Loc = *LI;
ObjCProtocolDecl *PD = *I;
ProtEntities.push_back(EntityInfo());
IdxCtx.getEntityInfo(PD, ProtEntities.back(), SA);
CXIdxObjCProtocolRefInfo ProtInfo = { 0,
MakeCursorObjCProtocolRef(PD, Loc, IdxCtx.CXTU),
IdxCtx.getIndexLoc(Loc) };
ProtInfos.push_back(ProtInfo);
if (IdxCtx.shouldSuppressRefs())
IdxCtx.markEntityOccurrenceInFile(PD, Loc);
}
for (unsigned i = 0, e = ProtInfos.size(); i != e; ++i)
ProtInfos[i].protocol = &ProtEntities[i];
for (unsigned i = 0, e = ProtInfos.size(); i != e; ++i)
Prots.push_back(&ProtInfos[i]);
}
IBOutletCollectionInfo::IBOutletCollectionInfo(
const IBOutletCollectionInfo &other)
: AttrInfo(CXIdxAttr_IBOutletCollection, other.cursor, other.loc, other.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)
: SA(IdxCtx), ref_cnt(0) {
if (!D->hasAttrs())
return;
for (AttrVec::const_iterator AttrI = D->attr_begin(), AttrE = D->attr_end();
AttrI != AttrE; ++AttrI) {
const Attr *A = *AttrI;
CXCursor C = MakeCXCursor(A, D, IdxCtx.CXTU);
CXIdxLoc Loc = IdxCtx.getIndexLoc(A->getLocation());
switch (C.kind) {
default:
Attrs.push_back(AttrInfo(CXIdxAttr_Unexposed, C, Loc, A));
break;
case CXCursor_IBActionAttr:
Attrs.push_back(AttrInfo(CXIdxAttr_IBAction, C, Loc, A));
break;
case CXCursor_IBOutletAttr