aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-04-13 16:31:46 +0000
committerDouglas Gregor <dgregor@apple.com>2012-04-13 16:31:46 +0000
commit87e154c09bbb060a0620bc988d7723bee64fb79c (patch)
tree8c78ea5379aebabc7c8f2ef38827302614a94601 /lib
parentb20c46ea980b5aed7b480761ea1daf2f26c23b2d (diff)
Remove the unused, unmaintained, incomplete 'Index' library.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154672 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/CMakeLists.txt2
-rw-r--r--lib/CMakeLists.txt1
-rw-r--r--lib/Index/ASTLocation.cpp114
-rw-r--r--lib/Index/ASTVisitor.h143
-rw-r--r--lib/Index/Analyzer.cpp470
-rw-r--r--lib/Index/CMakeLists.txt18
-rw-r--r--lib/Index/DeclReferenceMap.cpp90
-rw-r--r--lib/Index/Entity.cpp270
-rw-r--r--lib/Index/EntityImpl.h71
-rw-r--r--lib/Index/GlobalCallGraph.cpp152
-rw-r--r--lib/Index/GlobalSelector.cpp71
-rw-r--r--lib/Index/Handlers.cpp22
-rw-r--r--lib/Index/IndexProvider.cpp20
-rw-r--r--lib/Index/Indexer.cpp121
-rw-r--r--lib/Index/Makefile18
-rw-r--r--lib/Index/Program.cpp50
-rw-r--r--lib/Index/ProgramImpl.h56
-rw-r--r--lib/Index/SelectorMap.cpp84
-rwxr-xr-xlib/Makefile2
-rw-r--r--lib/StaticAnalyzer/Core/AnalysisManager.cpp24
-rw-r--r--lib/StaticAnalyzer/Core/CoreEngine.cpp1
-rw-r--r--lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp1
22 files changed, 3 insertions, 1798 deletions
diff --git a/lib/Analysis/CMakeLists.txt b/lib/Analysis/CMakeLists.txt
index 43c3ffbaf1..ca2392b915 100644
--- a/lib/Analysis/CMakeLists.txt
+++ b/lib/Analysis/CMakeLists.txt
@@ -1,4 +1,4 @@
-set(LLVM_USED_LIBS clangBasic clangAST clangIndex)
+set(LLVM_USED_LIBS clangBasic clangAST)
add_clang_library(clangAnalysis
AnalysisDeclContext.cpp
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 7af01ece6b..dfb9d61ff5 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -14,5 +14,4 @@ add_subdirectory(Serialization)
add_subdirectory(Frontend)
add_subdirectory(FrontendTool)
add_subdirectory(Tooling)
-add_subdirectory(Index)
add_subdirectory(StaticAnalyzer)
diff --git a/lib/Index/ASTLocation.cpp b/lib/Index/ASTLocation.cpp
deleted file mode 100644
index fce6099dac..0000000000
--- a/lib/Index/ASTLocation.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-//===--- ASTLocation.cpp - A <Decl, Stmt> pair ------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// ASTLocation is Decl or a Stmt and its immediate Decl parent.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/Index/ASTLocation.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/DeclObjC.h"
-#include "clang/AST/Stmt.h"
-#include "clang/AST/Expr.h"
-#include "clang/AST/ExprObjC.h"
-using namespace clang;
-using namespace idx;
-
-static Decl *getDeclFromExpr(Stmt *E) {
- if (DeclRefExpr *RefExpr = dyn_cast<DeclRefExpr>(E))
- return RefExpr->getDecl();
- if (MemberExpr *ME = dyn_cast<MemberExpr>(E))
- return ME->getMemberDecl();
- if (ObjCIvarRefExpr *RE = dyn_cast<ObjCIvarRefExpr>(E))
- return RE->getDecl();
-
- if (CallExpr *CE = dyn_cast<CallExpr>(E))
- return getDeclFromExpr(CE->getCallee());
- if (CastExpr *CE = dyn_cast<CastExpr>(E))
- return getDeclFromExpr(CE->getSubExpr());
-
- return 0;
-}
-
-Decl *ASTLocation::getReferencedDecl() {
- if (isInvalid())
- return 0;
-
- switch (getKind()) {
- case N_Type:
- return 0;
- case N_Decl:
- return D;
- case N_NamedRef:
- return NDRef.ND;
- case N_Stmt:
- return getDeclFromExpr(Stm);
- }
-
- llvm_unreachable("Invalid ASTLocation Kind!");
-}
-
-SourceRange ASTLocation::getSourceRange() const {
- if (isInvalid())
- return SourceRange();
-
- switch (getKind()) {
- case N_Decl:
- return D->getSourceRange();
- case N_Stmt:
- return Stm->getSourceRange();
- case N_NamedRef:
- return SourceRange(AsNamedRef().Loc, AsNamedRef().Loc);
- case N_Type:
- return AsTypeLoc().getLocalSourceRange();
- }
-
- llvm_unreachable("Invalid ASTLocation Kind!");
-}
-
-void ASTLocation::print(raw_ostream &OS) const {
- if (isInvalid()) {
- OS << "<< Invalid ASTLocation >>\n";
- return;
- }
-
- ASTContext &Ctx = getParentDecl()->getASTContext();
-
- switch (getKind()) {
- case N_Decl:
- OS << "[Decl: " << AsDecl()->getDeclKindName() << " ";
- if (const NamedDecl *ND = dyn_cast<NamedDecl>(AsDecl()))
- OS << *ND;
- break;
-
- case N_Stmt:
- OS << "[Stmt: " << AsStmt()->getStmtClassName() << " ";
- AsStmt()->printPretty(OS, Ctx, 0, PrintingPolicy(Ctx.getLangOpts()));
- break;
-
- case N_NamedRef:
- OS << "[NamedRef: " << AsNamedRef().ND->getDeclKindName() << " ";
- OS << *AsNamedRef().ND;
- break;
-
- case N_Type: {
- QualType T = AsTypeLoc().getType();
- OS << "[Type: " << T->getTypeClassName() << " " << T.getAsString();
- }
- }
-
- OS << "] <";
-
- SourceRange Range = getSourceRange();
- SourceManager &SourceMgr = Ctx.getSourceManager();
- Range.getBegin().print(OS, SourceMgr);
- OS << ", ";
- Range.getEnd().print(OS, SourceMgr);
- OS << ">\n";
-}
diff --git a/lib/Index/ASTVisitor.h b/lib/Index/ASTVisitor.h
deleted file mode 100644
index 0b8425b2f3..0000000000
--- a/lib/Index/ASTVisitor.h
+++ /dev/null
@@ -1,143 +0,0 @@
-//===--- ASTVisitor.h - Visitor for an ASTContext ---------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines the ASTVisitor interface.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_INDEX_ASTVISITOR_H
-#define LLVM_CLANG_INDEX_ASTVISITOR_H
-
-#include "clang/AST/DeclVisitor.h"
-#include "clang/AST/StmtVisitor.h"
-#include "clang/AST/TypeLocVisitor.h"
-
-namespace clang {
-
-namespace idx {
-
-/// \brief Traverses the full AST, both Decls and Stmts.
-template<typename ImplClass>
-class ASTVisitor : public DeclVisitor<ImplClass>,
- public StmtVisitor<ImplClass>,
- public TypeLocVisitor<ImplClass> {
-public:
- ASTVisitor() : CurrentDecl(0) { }
-
- Decl *CurrentDecl;
-
- typedef ASTVisitor<ImplClass> Base;
- typedef DeclVisitor<ImplClass> BaseDeclVisitor;
- typedef StmtVisitor<ImplClass> BaseStmtVisitor;
- typedef TypeLocVisitor<ImplClass> BaseTypeLocVisitor;
-
- using BaseStmtVisitor::Visit;
-
- //===--------------------------------------------------------------------===//
- // DeclVisitor
- //===--------------------------------------------------------------------===//
-
- void Visit(Decl *D) {
- Decl *PrevDecl = CurrentDecl;
- CurrentDecl = D;
- BaseDeclVisitor::Visit(D);
- CurrentDecl = PrevDecl;
- }
-
- void VisitDeclaratorDecl(DeclaratorDecl *D) {
- BaseDeclVisitor::VisitDeclaratorDecl(D);
- if (TypeSourceInfo *TInfo = D->getTypeSourceInfo())
- Visit(TInfo->getTypeLoc());
- }
-
- void VisitFunctionDecl(FunctionDecl *D) {
- BaseDeclVisitor::VisitFunctionDecl(D);
- if (D->isThisDeclarationADefinition())
- Visit(D->getBody());
- }
-
- void VisitObjCMethodDecl(ObjCMethodDecl *D) {
- BaseDeclVisitor::VisitObjCMethodDecl(D);
- if (D->getBody())
- Visit(D->getBody());
- }
-
- void VisitBlockDecl(BlockDecl *D) {
- BaseDeclVisitor::VisitBlockDecl(D);
- Visit(D->getBody());
- }
-
- void VisitVarDecl(VarDecl *D) {
- BaseDeclVisitor::VisitVarDecl(D);
- if (Expr *Init = D->getInit())
- Visit(Init);
- }
-
- void VisitDecl(Decl *D) {
- if (isa<FunctionDecl>(D) || isa<ObjCMethodDecl>(D) || isa<BlockDecl>(D))
- return;
-
- if (DeclContext *DC = dyn_cast<DeclContext>(D))
- static_cast<ImplClass*>(this)->VisitDeclContext(DC);
- }
-
- void VisitDeclContext(DeclContext *DC) {
- for (DeclContext::decl_iterator
- I = DC->decls_begin(), E = DC->decls_end(); I != E; ++I)
- Visit(*I);
- }
-
- //===--------------------------------------------------------------------===//
- // StmtVisitor
- //===--------------------------------------------------------------------===//
-
- void VisitDeclStmt(DeclStmt *Node) {
- for (DeclStmt::decl_iterator
- I = Node->decl_begin(), E = Node->decl_end(); I != E; ++I)
- Visit(*I);
- }
-
- void VisitBlockExpr(BlockExpr *Node) {
- // The BlockDecl is also visited by 'VisitDeclContext()'. No need to visit it twice.
- }
-
- void VisitStmt(Stmt *Node) {
- for (Stmt::child_range I = Node->children(); I; ++I)
- if (*I)
- Visit(*I);
- }
-
- //===--------------------------------------------------------------------===//
- // TypeLocVisitor
- //===--------------------------------------------------------------------===//
-
- void Visit(TypeLoc TL) {
- for (; TL; TL = TL.getNextTypeLoc())
- BaseTypeLocVisitor::Visit(TL);
- }
-
- void VisitArrayLoc(ArrayTypeLoc TL) {
- BaseTypeLocVisitor::VisitArrayTypeLoc(TL);
- if (TL.getSizeExpr())
- Visit(TL.getSizeExpr());
- }
-
- void VisitFunctionTypeLoc(FunctionTypeLoc TL) {
- BaseTypeLocVisitor::VisitFunctionTypeLoc(TL);
- for (unsigned i = 0; i != TL.getNumArgs(); ++i)
- Visit(TL.getArg(i));
- }
-
-};
-
-} // namespace idx
-
-} // namespace clang
-
-#endif
diff --git a/lib/Index/Analyzer.cpp b/lib/Index/Analyzer.cpp
deleted file mode 100644
index f77e6ef92d..0000000000
--- a/lib/Index/Analyzer.cpp
+++ /dev/null
@@ -1,470 +0,0 @@
-//===--- Analyzer.cpp - Analysis for indexing information -------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the Analyzer interface.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/Index/Analyzer.h"
-#include "clang/Index/Entity.h"
-#include "clang/Index/TranslationUnit.h"
-#include "clang/Index/Handlers.h"
-#include "clang/Index/ASTLocation.h"
-#include "clang/Index/GlobalSelector.h"
-#include "clang/Index/DeclReferenceMap.h"
-#include "clang/Index/SelectorMap.h"
-#include "clang/Index/IndexProvider.h"
-#include "clang/AST/DeclObjC.h"
-#include "clang/AST/ExprObjC.h"
-#include "llvm/ADT/SmallSet.h"
-using namespace clang;
-using namespace idx;
-
-namespace {
-
-//===----------------------------------------------------------------------===//
-// DeclEntityAnalyzer Implementation
-//===----------------------------------------------------------------------===//
-
-class DeclEntityAnalyzer : public TranslationUnitHandler {
- Entity Ent;
- TULocationHandler &TULocHandler;
-
-public:
- DeclEntityAnalyzer(Entity ent, TULocationHandler &handler)
- : Ent(ent), TULocHandler(handler) { }
-
- virtual void Handle(TranslationUnit *TU) {
- assert(TU && "Passed null translation unit");
-
- Decl *D = Ent.getDecl(TU->getASTContext());
- assert(D && "Couldn't resolve Entity");
-
- for (Decl::redecl_iterator I = D->redecls_begin(),
- E = D->redecls_end(); I != E; ++I)
- TULocHandler.Handle(TULocation(TU, ASTLocation(*I)));
- }
-};
-
-//===----------------------------------------------------------------------===//
-// RefEntityAnalyzer Implementation
-//===----------------------------------------------------------------------===//
-
-class RefEntityAnalyzer : public TranslationUnitHandler {
- Entity Ent;
- TULocationHandler &TULocHandler;
-
-public:
- RefEntityAnalyzer(Entity ent, TULocationHandler &handler)
- : Ent(ent), TULocHandler(handler) { }
-
- virtual void Handle(TranslationUnit *TU) {
- assert(TU && "Passed null translation unit");
-
- Decl *D = Ent.getDecl(TU->getASTContext());
- assert(D && "Couldn't resolve Entity");
- NamedDecl *ND = dyn_cast<NamedDecl>(D);
- if (!ND)
- return;
-
- DeclReferenceMap &RefMap = TU->getDeclReferenceMap();
- for (DeclReferenceMap::astlocation_iterator
- I = RefMap.refs_begin(ND), E = RefMap.refs_end(ND); I != E; ++I)
- TULocHandler.Handle(TULocation(TU, *I));
- }
-};
-
-//===----------------------------------------------------------------------===//
-// RefSelectorAnalyzer Implementation
-//===----------------------------------------------------------------------===//
-
-/// \brief Accepts an ObjC method and finds all message expressions that this
-/// method may respond to.
-class RefSelectorAnalyzer : public TranslationUnitHandler {
- Program &Prog;
- TULocationHandler &TULocHandler;
-
- // The original ObjCInterface associated with the method.
- Entity IFaceEnt;
- GlobalSelector GlobSel;
- bool IsInstanceMethod;
-
- /// \brief Super classes of the ObjCInterface.
- typedef llvm::SmallSet<Entity, 16> EntitiesSetTy;
- EntitiesSetTy HierarchyEntities;
-
-public:
- RefSelectorAnalyzer(ObjCMethodDecl *MD,
- Program &prog, TULocationHandler &handler)
- : Prog(prog), TULocHandler(handler) {
- assert(MD);
-
- // FIXME: Protocol methods.
- assert(!isa<ObjCProtocolDecl>(MD->getDeclContext()) &&
- "Protocol methods not supported yet");
-
- ObjCInterfaceDecl *IFD = MD->getClassInterface();
- assert(IFD);
- IFaceEnt = Entity::get(IFD, Prog);
- GlobSel = GlobalSelector::get(MD->getSelector(), Prog);
- IsInstanceMethod = MD->isInstanceMethod();
-
- for (ObjCInterfaceDecl *Cls = IFD->getSuperClass();
- Cls; Cls = Cls->getSuperClass())
- HierarchyEntities.insert(Entity::get(Cls, Prog));
- }
-
- virtual void Handle(TranslationUnit *TU) {
- assert(TU && "Passed null translation unit");
-
- ASTContext &Ctx = TU->getASTContext();
- // Null means it doesn't exist in this translation unit.
- ObjCInterfaceDecl *IFace =
- cast_or_null<ObjCInterfaceDecl>(IFaceEnt.getDecl(Ctx));
- Selector Sel = GlobSel.getSelector(Ctx);
-
- SelectorMap &SelMap = TU->getSelectorMap();
- for (SelectorMap::astlocation_iterator
- I = SelMap.refs_begin(Sel), E = SelMap.refs_end(Sel); I != E; ++I) {
- if (ValidReference(*I, IFace))
- TULocHandler.Handle(TULocation(TU, *I));
- }
- }
-
- /// \brief Determines whether the given message expression is likely to end
- /// up at the given interface decl.
- ///
- /// It returns true "eagerly", meaning it will return false only if it can
- /// "prove" statically that the interface cannot accept this message.
- bool ValidReference(ASTLocation ASTLoc, ObjCInterfaceDecl *IFace) {
- assert(ASTLoc.isStmt());
-
- // FIXME: Finding @selector references should be through another Analyzer
- // method, like FindSelectors.
- if (isa<ObjCSelectorExpr>(ASTLoc.AsStmt()))
- return false;
-
- ObjCInterfaceDecl *MsgD = 0;
- ObjCMessageExpr *Msg = cast<ObjCMessageExpr>(ASTLoc.AsStmt());
-
- switch (Msg->getReceiverKind()) {
- case ObjCMessageExpr::Instance: {
- const ObjCObjectPointerType *OPT =
- Msg->getInstanceReceiver()->getType()->getAsObjCInterfacePointerType();
-
- // Can be anything! Accept it as a possibility..
- if (!OPT || OPT->isObjCIdType() || OPT->isObjCQualifiedIdType())
- return true;
-
- // Expecting class method.
- if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType())
- return !IsInstanceMethod;
-
- MsgD = OPT->getInterfaceDecl();
- assert(MsgD);
-
- // Should be an instance method.
- if (!IsInstanceMethod)
- return false;
- break;
- }
-
- case ObjCMessageExpr::Class: {
- // Expecting class method.
- if (IsInstanceMethod)
- return false;
-
- MsgD = Msg->getClassReceiver()->getAs<ObjCObjectType>()->getInterface();
- break;
- }
-
- case ObjCMessageExpr::SuperClass:
- // Expecting class method.
- if (IsInstanceMethod)
- return false;
-
- MsgD = Msg->getSuperType()->getAs<ObjCObjectType>()->getInterface();
- break;
-
- case ObjCMessageExpr::SuperInstance:
- // Expecting instance method.
- if (!IsInstanceMethod)
- return false;
-
- MsgD = Msg->getSuperType()->getAs<ObjCObjectPointerType>()
- ->getInterfaceDecl();
- break;
- }
-
- assert(MsgD);
-
- // Same interface ? We have a winner!
- if (declaresSameEntity(MsgD, IFace))
- return true;
-
- // If the message interface is a superclass of the original interface,
- // accept this message as a possibility.
- if (HierarchyEntities.count(Entity::get(MsgD, Prog)))
- return true;
-
- // If the message interface is a subclass of the original interface, accept
- // the message unless there is a subclass in the hierarchy that will
- // "steal" the message (thus the message "will go" to the subclass and not
- /// the original interface).
- if (IFace) {
- Selector Sel = Msg->getSelector();
- for (ObjCInterfaceDecl *Cls = MsgD; Cls; Cls = Cls->getSuperClass()) {
- if (declaresSameEntity(Cls, IFace))
- return true;
- if (Cls->getMethod(Sel, IsInstanceMethod))
- return false;
- }
- }
-
- // The interfaces are unrelated, don't accept the message.
- return false;
- }
-};
-
-//===----------------------------------------------------------------------===//
-// MessageAnalyzer Implementation
-//===----------------------------------------------------------------------===//
-
-/// \brief Accepts an ObjC message expression and finds all methods that may
-/// respond to it.
-class MessageAnalyzer : public TranslationUnitHandler {
- Program &Prog;
- TULocationHandler &TULocHandler;
-
- // The ObjCInterface associated with the message. Can be null/invalid.
- Entity MsgIFaceEnt;
- GlobalSelector GlobSel;
- bool CanBeInstanceMethod;
- bool CanBeClassMethod;
-
- /// \brief Super classes of the ObjCInterface.
- typedef llvm::SmallSet<Entity, 16> EntitiesSetTy;
- EntitiesSetTy HierarchyEntities;
-
- /// \brief The interface in the message interface hierarchy that "intercepts"
- /// the selector.
- Entity ReceiverIFaceEnt;
-
-public:
- MessageAnalyzer(ObjCMessageExpr *Msg,
- Program &prog, TULocationHandler &handler)
- : Prog(prog), TULocHandler(handler),
- CanBeInstanceMethod(false),
- CanBeClassMethod(false) {
-
- assert(Msg);
-
- ObjCInterfaceDecl *MsgD = 0;
-
- while (true) {
- switch (Msg->getReceiverKind()) {
- case ObjCMessageExpr::Instance: {
- const ObjCObjectPointerType *OPT =
- Msg->getInstanceReceiver()->getType()
- ->getAsObjCInterfacePointerType();
-
- if (!OPT || OPT->isObjCIdType() || OPT->isObjCQualifiedIdType()) {
- CanBeInstanceMethod = CanBeClassMethod = true;
- break;
- }
-
- if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType()) {
- CanBeClassMethod = true;
- break;
- }
-
- MsgD = OPT->getInterfaceDecl();
- assert(MsgD);
- CanBeInstanceMethod = true;
- break;
- }
-
- case ObjCMessageExpr::Class:
- CanBeClassMethod = true;
- MsgD = Msg->getClassReceiver()->getAs<ObjCObjectType>()->getInterface();
- break;
-
- case ObjCMessageExpr::SuperClass:
- CanBeClassMethod = true;
- MsgD = Msg->getSuperType()->getAs<ObjCObjectType>()->getInterface();
- break;
-
- case ObjCMessageExpr::SuperInstance:
- CanBeInstanceMethod = true;
- MsgD = Msg->getSuperType()->getAs<ObjCObjectPointerType>()
- ->getInterfaceDecl();
- break;
- }
- }
-
- assert(CanBeInstanceMethod || CanBeClassMethod);
-
- Selector sel = Msg->getSelector();
- assert(!sel.isNull());
-
- MsgIFaceEnt = Entity::get(MsgD, Prog);
- GlobSel = GlobalSelector::get(sel, Prog);
-
- if (MsgD) {
- for (ObjCInterfaceDecl *Cls = MsgD->getSuperClass();
- Cls; Cls = Cls->getSuperClass())
- HierarchyEntities.insert(Entity::get(Cls, Prog));
-
- // Find the interface in the hierarchy that "receives" the message.
- for (ObjCInterfaceDecl *Cls = MsgD; Cls; Cls = Cls->getSuperClass()) {
- bool isReceiver = false;
-
- ObjCInterfaceDecl::lookup_const_iterator Meth, MethEnd;
- for (llvm::tie(Meth, MethEnd) = Cls->lookup(sel);
- Meth != MethEnd; ++Meth) {
- if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(*Meth))
- if ((MD->isInstanceMethod() && CanBeInstanceMethod) ||
- (MD->isClassMethod() && CanBeClassMethod)) {
- isReceiver = true;
- break;
- }
- }
-
- if (isReceiver) {
- ReceiverIFaceEnt = Entity::get(Cls, Prog);
- break;
- }
- }
- }
- }
-
- virtual void Handle(TranslationUnit *TU) {
- assert(TU && "Passed null translation unit");
- ASTContext &Ctx = TU->getASTContext();
-
- // Null means it doesn't exist in this translation unit or there was no
- // interface that was determined to receive the original message.
- ObjCInterfaceDecl *ReceiverIFace =
- cast_or_null<ObjCInterfaceDecl>(ReceiverIFaceEnt.getDecl(Ctx));
-
- // No subclass for the original receiver interface, so it remains the
- // receiver.
- if (ReceiverIFaceEnt.isValid() && ReceiverIFace == 0)
- return;
-
- // Null means it doesn't exist in this translation unit or there was no
- // interface associated with the message in the first place.
- ObjCInterfaceDecl *MsgIFace =
- cast_or_null<ObjCInterfaceDecl>(MsgIFaceEnt.getDecl(Ctx));
-
- Selector Sel = GlobSel.getSelector(Ctx);
- SelectorMap &SelMap = TU->getSelectorMap();
- for (SelectorMap::method_iterator
- I = SelMap.methods_begin(Sel), E = SelMap.methods_end(Sel);
- I != E; ++I) {
- ObjCMethodDecl *D = *I;
- if (ValidMethod(D, MsgIFace, ReceiverIFace)) {
- for (ObjCMethodDecl::redecl_iterator
- RI = D->redecls_begin(), RE = D->redecls_end(); RI != RE; ++RI)
- TULocHandler.Handle(TULocation(TU, ASTLocation(*RI)));
- }
- }
- }
-
- /// \brief Determines whether the given method is likely to accept the
- /// original message.
- ///
- /// It returns true "eagerly", meaning it will return false only if it can
- /// "prove" statically that the method cannot accept the original message.
- bool ValidMethod(ObjCMethodDecl *D, ObjCInterfaceDecl *MsgIFace,
- ObjCInterfaceDecl *ReceiverIFace) {
- assert(D);
-
- // FIXME: Protocol methods ?
- if (isa<ObjCProtocolDecl>(D->getDeclContext()))
- return false;
-
- // No specific interface associated with the message. Can be anything.
- if (MsgIFaceEnt.isInvalid())
- return true;
-
- if ((!CanBeInstanceMethod && D->isInstanceMethod()) ||
- (!CanBeClassMethod && D->isClassMethod()))
- return false;
-
- ObjCInterfaceDecl *IFace = D->getClassInterface();
- assert(IFace);
-
- // If the original message interface is the same or a superclass of the
- // given interface, accept the method as a possibility.
- if (MsgIFace && MsgIFace->isSuperClassOf(IFace))
- return true;
-
- if (ReceiverIFace) {
- // The given interface, "overrides" the receiver.
- if (ReceiverIFace->isSuperClassOf(IFace))
- return true;
- } else {
- // No receiver was found for the original message.
- assert(ReceiverIFaceEnt.isInvalid());
-
- // If the original message interface is a subclass of the given interface,
- // accept the message.
- if (HierarchyEntities.count(Entity::get(IFace, Prog)))
- return true;
- }
-
- // The interfaces are unrelated, or the receiver interface wasn't
- // "overriden".
- return false;
- }
-};
-
-} // end anonymous namespace
-
-//===----------------------------------------------------------------------===//
-// Analyzer Implementation
-//===----------------------------------------------------------------------===//
-
-void Analyzer::FindDeclarations(Decl *D, TULocationHandler &Handler) {
- assert(D && "Passed null declaration");
- Entity Ent = Entity::get(D, Prog);
- if (Ent.isInvalid())
- return;
-
- DeclEntityAnalyzer DEA(Ent, Handler);
- Idxer.GetTranslationUnitsFor(Ent, DEA);
-}
-
-void Analyzer::FindReferences(Decl *D, TULocationHandler &Handler) {
- assert(D && "Passed null declaration");
- if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) {
- RefSelectorAnalyzer RSA(MD, Prog, Handler);
- GlobalSelector Sel = GlobalSelector::get(MD->getSelector(), Prog);
- Idxer.GetTranslationUnitsFor(Sel, RSA);
- return;
- }
-
- Entity Ent = Entity::get(D, Prog);
- if (Ent.isInvalid())
- return;
-
- RefEntityAnalyzer REA(Ent, Handler);
- Idxer.GetTranslationUnitsFor(Ent, REA);
-}
-
-/// \brief Find methods that may respond to the given message and pass them
-/// to Handler.
-void Analyzer::FindObjCMethods(ObjCMessageExpr *Msg,
- TULocationHandler &Handler) {
- assert(Msg);
- MessageAnalyzer MsgAnalyz(Msg, Prog, Handler);
- GlobalSelector GlobSel = GlobalSelector::get(Msg->getSelector(), Prog);
- Idxer.GetTranslationUnitsFor(GlobSel, MsgAnalyz);
-}
diff --git a/lib/Index/CMakeLists.txt b/lib/Index/CMakeLists.txt
deleted file mode 100644
index 9bf35e5efe..0000000000
--- a/lib/Index/CMakeLists.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-set(LLVM_USED_LIBS clangBasic clangAST)
-
-add_clang_library(clangIndex
- ASTLocation.cpp
- Analyzer.cpp
- GlobalCallGraph.cpp
- DeclReferenceMap.cpp
- Entity.cpp
- GlobalSelector.cpp
- Handlers.cpp
- IndexProvider.cpp
- Indexer.cpp
- Program.cpp
- SelectorMap.cpp
- )
-
-add_dependencies(clangIndex ClangAttrClasses ClangAttrList
- ClangDeclNodes ClangStmtNodes)
diff --git a/lib/Index/DeclReferenceMap.cpp b/lib/Index/DeclReferenceMap.cpp
deleted file mode 100644
index 3fd4336230..0000000000
--- a/lib/Index/DeclReferenceMap.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-//===--- DeclReferenceMap.cpp - Map Decls to their references -------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// DeclReferenceMap creates a mapping from Decls to the ASTLocations that
-// reference them.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/Index/DeclReferenceMap.h"
-#include "clang/Index/ASTLocation.h"
-#include "ASTVisitor.h"
-using namespace clang;
-using namespace idx;
-
-namespace {
-
-class RefMapper : public ASTVisitor<RefMapper> {
- DeclReferenceMap::MapTy &Map;
-
-public:
- RefMapper(DeclReferenceMap::MapTy &map) : Map(map) { }
-
- void VisitDeclRefExpr(DeclRefExpr *Node);
- void VisitMemberExpr(MemberExpr *Node);
- void VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node);
-
- void VisitTypedefTypeLoc(TypedefTypeLoc TL);
- void VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL);
-};
-
-} // anonymous namespace
-
-//===----------------------------------------------------------------------===//
-// RefMapper Implementation
-//===----------------------------------------------------------------------===//
-
-void RefMapper::VisitDeclRefExpr(DeclRefExpr *Node) {
- NamedDecl *PrimD = cast<NamedDecl>(Node->getDecl()->getCanonicalDecl());
- Map.insert(std::make_pair(PrimD, ASTLocation(CurrentDecl, Node)));
-}
-
-void RefMapper::VisitMemberExpr(MemberExpr *Node) {
- NamedDecl *PrimD = cast<NamedDecl>(Node->getMemberDecl()->getCanonicalDecl());
- Map.insert(std::make_pair(PrimD, ASTLocation(CurrentDecl, Node)));
-}
-
-void RefMapper::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
- Map.insert(std::make_pair(Node->getDecl(), ASTLocation(CurrentDecl, Node)));
-}
-
-void RefMapper::VisitTypedefTypeLoc(TypedefTypeLoc TL) {
- NamedDecl *ND = TL.getTypedefNameDecl();
- Map.insert(std::make_pair(ND, ASTLocation(CurrentDecl, ND, TL.getNameLoc())));
-}
-
-void RefMapper::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {
- NamedDecl *ND = TL.getIFaceDecl();
- Map.insert(std::make_pair(ND, ASTLocation(CurrentDecl, ND, TL.getNameLoc())));
-}
-
-//===----------------------------------------------------------------------===//
-// DeclReferenceMap Implementation
-//===----------------------------------------------------------------------===//
-
-DeclReferenceMap::DeclReferenceMap(ASTContext &Ctx) {
- RefMapper(Map).Visit(Ctx.getTranslationUnitDecl());
-}
-
-DeclReferenceMap::astlocation_iterator
-DeclReferenceMap::refs_begin(NamedDecl *D) const {
- NamedDecl *Prim = cast<NamedDecl>(D->getCanonicalDecl());
- return astlocation_iterator(Map.lower_bound(Prim));
-}
-
-DeclReferenceMap::astlocation_iterator
-DeclReferenceMap::refs_end(NamedDecl *D) const {
- NamedDecl *Prim = cast<NamedDecl>(D->getCanonicalDecl());
- return astlocation_iterator(Map.upper_bound(Prim));
-}
-
-bool DeclReferenceMap::refs_empty(NamedDecl *D) const {
- NamedDecl *Prim = cast<NamedDecl>(D->getCanonicalDecl());
- return refs_begin(Prim) == refs_end(Prim);
-}
diff --git a/lib/Index/Entity.cpp b/lib/Index/Entity.cpp
deleted file mode 100644
index fbab6d8684..0000000000
--- a/lib/Index/Entity.cpp
+++ /dev/null
@@ -1,270 +0,0 @@
-//===--- Entity.cpp - Cross-translation-unit "token" for decls ------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===------------------------------------------------------------