aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/libclang/CIndex.cpp26
-rw-r--r--tools/libclang/CIndexUSRs.cpp7
-rw-r--r--tools/libclang/CursorVisitor.h1
-rw-r--r--tools/libclang/IndexDecl.cpp23
-rw-r--r--tools/libclang/IndexingContext.cpp25
-rw-r--r--tools/libclang/IndexingContext.h4
6 files changed, 22 insertions, 64 deletions
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index f2e6b01329..280a48c101 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -951,6 +951,9 @@ bool CursorVisitor::VisitObjCCategoryDecl(ObjCCategoryDecl *ND) {
}
bool CursorVisitor::VisitObjCProtocolDecl(ObjCProtocolDecl *PID) {
+ if (!PID->isThisDeclarationADefinition())
+ return Visit(MakeCursorObjCProtocolRef(PID, PID->getLocation(), TU));
+
ObjCProtocolDecl::protocol_loc_iterator PL = PID->protocol_loc_begin();
for (ObjCProtocolDecl::protocol_iterator I = PID->protocol_begin(),
E = PID->protocol_end(); I != E; ++I, ++PL)
@@ -1046,17 +1049,6 @@ bool CursorVisitor::VisitObjCImplementationDecl(ObjCImplementationDecl *D) {
return VisitObjCImplDecl(D);
}
-bool CursorVisitor::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D) {
- ObjCForwardProtocolDecl::protocol_loc_iterator PL = D->protocol_loc_begin();
- for (ObjCForwardProtocolDecl::protocol_iterator I = D->protocol_begin(),
- E = D->protocol_end();
- I != E; ++I, ++PL)
- if (Visit(MakeCursorObjCProtocolRef(*I, *PL, TU)))
- return true;
-
- return false;
-}
-
bool CursorVisitor::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *PD) {
if (ObjCIvarDecl *Ivar = PD->getPropertyIvarDecl())
return Visit(MakeCursorMemberRef(Ivar, PD->getPropertyIvarDeclLoc(), TU));
@@ -3882,9 +3874,6 @@ CXCursor clang_getCursorReferenced(CXCursor C) {
return clang_getNullCursor();
if (UsingDecl *Using = dyn_cast<UsingDecl>(D))
return MakeCursorOverloadedDeclRef(Using, D->getLocation(), tu);
- if (ObjCForwardProtocolDecl *Protocols
- = dyn_cast<ObjCForwardProtocolDecl>(D))
- return MakeCursorOverloadedDeclRef(Protocols, D->getLocation(), tu);
if (ObjCPropertyImplDecl *PropImpl =dyn_cast<ObjCPropertyImplDecl>(D))
if (ObjCPropertyDecl *Property = PropImpl->getPropertyDecl())
return MakeCXCursor(Property, tu);
@@ -4158,10 +4147,6 @@ CXCursor clang_getCursorDefinition(CXCursor C) {
return clang_getNullCursor();
- case Decl::ObjCForwardProtocol:
- return MakeCursorOverloadedDeclRef(cast<ObjCForwardProtocolDecl>(D),
- D->getLocation(), TU);
-
case Decl::Friend:
if (NamedDecl *Friend = cast<FriendDecl>(D)->getFriendDecl())
return clang_getCursorDefinition(MakeCXCursor(Friend, TU));
@@ -4217,8 +4202,6 @@ unsigned clang_getNumOverloadedDecls(CXCursor C) {
Decl *D = Storage.get<Decl*>();
if (UsingDecl *Using = dyn_cast<UsingDecl>(D))
return Using->shadow_size();
- if (ObjCForwardProtocolDecl *Protocols =dyn_cast<ObjCForwardProtocolDecl>(D))
- return Protocols->protocol_size();
return 0;
}
@@ -4246,8 +4229,6 @@ CXCursor clang_getOverloadedDecl(CXCursor cursor, unsigned index) {
std::advance(Pos, index);
return MakeCXCursor(cast<UsingShadowDecl>(*Pos)->getTargetDecl(), TU);
}
- if (ObjCForwardProtocolDecl *Protocols = dyn_cast<ObjCForwardProtocolDecl>(D))
- return MakeCXCursor(Protocols->protocol_begin()[index], TU);
return clang_getNullCursor();
}
@@ -5175,7 +5156,6 @@ static CXLanguageKind getDeclLanguage(const Decl *D) {
case Decl::ObjCCategory:
case Decl::ObjCCategoryImpl:
case Decl::ObjCCompatibleAlias:
- case Decl::ObjCForwardProtocol:
case Decl::ObjCImplementation:
case Decl::ObjCInterface:
case Decl::ObjCIvar:
diff --git a/tools/libclang/CIndexUSRs.cpp b/tools/libclang/CIndexUSRs.cpp
index 1b57ef23ad..1c2ffbfeb8 100644
--- a/tools/libclang/CIndexUSRs.cpp
+++ b/tools/libclang/CIndexUSRs.cpp
@@ -76,7 +76,6 @@ public:
void VisitFunctionTemplateDecl(FunctionTemplateDecl *D);
void VisitClassTemplateDecl(ClassTemplateDecl *D);
void VisitObjCContainerDecl(ObjCContainerDecl *CD);
- void VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *P);
void VisitObjCMethodDecl(ObjCMethodDecl *MD);
void VisitObjCPropertyDecl(ObjCPropertyDecl *D);
void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D);
@@ -309,12 +308,6 @@ void USRGenerator::VisitObjCMethodDecl(ObjCMethodDecl *D) {
N.printName(Out);
}
-void USRGenerator::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D) {
- // FIXME: @protocol declarations can refer to multiple protocols. We need
- // to be able to traverse these.
- IgnoreResults = true;
-}
-
void USRGenerator::VisitObjCContainerDecl(ObjCContainerDecl *D) {
switch (D->getKind()) {
default:
diff --git a/tools/libclang/CursorVisitor.h b/tools/libclang/CursorVisitor.h
index 184d36f180..f1258cb666 100644
--- a/tools/libclang/CursorVisitor.h
+++ b/tools/libclang/CursorVisitor.h
@@ -215,7 +215,6 @@ public:
bool VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D);
bool VisitObjCImplementationDecl(ObjCImplementationDecl *D);
// FIXME: ObjCCompatibleAliasDecl requires aliased-class locations.
- bool VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D);
bool VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *PD);
bool VisitLinkageSpecDecl(LinkageSpecDecl *D);
bool VisitNamespaceDecl(NamespaceDecl *D);
diff --git a/tools/libclang/IndexDecl.cpp b/tools/libclang/IndexDecl.cpp
index ee37bba942..9ff65b30f4 100644
--- a/tools/libclang/IndexDecl.cpp
+++ b/tools/libclang/IndexDecl.cpp
@@ -77,19 +77,6 @@ public:
return true;
}
- bool VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D) {
- ObjCForwardProtocolDecl::protocol_loc_iterator LI = D->protocol_loc_begin();
- for (ObjCForwardProtocolDecl::protocol_iterator
- I = D->protocol_begin(), E = D->protocol_end(); I != E; ++I, ++LI) {
- SourceLocation Loc = *LI;
- ObjCProtocolDecl *PD = *I;
-
- bool isRedeclaration = PD->getLocation() != Loc;
- IndexCtx.handleObjCForwardProtocol(PD, Loc, isRedeclaration);
- }
- return true;
- }
-
bool VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
IndexCtx.handleObjCInterface(D);
@@ -101,14 +88,12 @@ public:
}
bool VisitObjCProtocolDecl(ObjCProtocolDecl *D) {
- // Forward decls are handled at VisitObjCForwardProtocolDecl.
- if (!D->isThisDeclarationADefinition())
- return true;
-
IndexCtx.handleObjCProtocol(D);
- IndexCtx.indexTUDeclsInObjCContainer();
- IndexCtx.indexDeclContext(D);
+ if (D->isThisDeclarationADefinition()) {
+ IndexCtx.indexTUDeclsInObjCContainer();
+ IndexCtx.indexDeclContext(D);
+ }
return true;
}
diff --git a/tools/libclang/IndexingContext.cpp b/tools/libclang/IndexingContext.cpp
index 28efe3fd56..14dbc97002 100644
--- a/tools/libclang/IndexingContext.cpp
+++ b/tools/libclang/IndexingContext.cpp
@@ -390,17 +390,22 @@ bool IndexingContext::handleObjCImplementation(
return handleObjCContainer(D, D->getLocation(), getCursor(D), ContDInfo);
}
-bool IndexingContext::handleObjCForwardProtocol(const ObjCProtocolDecl *D,
- SourceLocation Loc,
- bool isRedeclaration) {
- ObjCContainerDeclInfo ContDInfo(/*isForwardRef=*/true,
- isRedeclaration,
- /*isImplementation=*/false);
- return handleObjCContainer(D, Loc, MakeCursorObjCProtocolRef(D, Loc, CXTU),
- ContDInfo);
-}
-
bool IndexingContext::handleObjCProtocol(const ObjCProtocolDecl *D) {
+ if (!D->isThisDeclarationADefinition()) {
+ if (suppressRefs() && markEntityOccurrenceInFile(D, D->getLocation()))
+ return false; // already occurred.
+
+ // FIXME: This seems like the wrong definition for redeclaration.
+ bool isRedeclaration = D->hasDefinition() || D->getPreviousDeclaration();
+ ObjCContainerDeclInfo ContDInfo(/*isForwardRef=*/true,
+ isRedeclaration,
+ /*isImplementation=*/false);
+ return handleObjCContainer(D, D->getLocation(),
+ MakeCursorObjCProtocolRef(D, D->getLocation(),
+ CXTU),
+ ContDInfo);
+ }
+
ScratchAlloc SA(*this);
ObjCProtocolList EmptyProtoList;
ObjCProtocolListInfo ProtListInfo(D->isThisDeclarationADefinition()
diff --git a/tools/libclang/IndexingContext.h b/tools/libclang/IndexingContext.h
index 90801d9694..0091fd1f8c 100644
--- a/tools/libclang/IndexingContext.h
+++ b/tools/libclang/IndexingContext.h
@@ -372,10 +372,6 @@ public:
bool handleObjCInterface(const ObjCInterfaceDecl *D);
bool handleObjCImplementation(const ObjCImplementationDecl *D);
- bool handleObjCForwardProtocol(const ObjCProtocolDecl *D,
- SourceLocation Loc,
- bool isRedeclaration);
-
bool handleObjCProtocol(const ObjCProtocolDecl *D);
bool handleObjCCategory(const ObjCCategoryDecl *D);