diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-29 23:38:21 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-29 23:38:21 +0000 |
commit | dd9ee4aa04e5195e1f43badb9da121cc7dc7dcd1 (patch) | |
tree | 6b1fb5a18368ad96bd6adc385d71f63a3cf6ab70 /clang/lib/Index/IndexProvider.cpp | |
parent | b6b8f9e2915c1c9dd91ddb100fc2f11d4d22881f (diff) | |
download | bcm5719-llvm-dd9ee4aa04e5195e1f43badb9da121cc7dc7dcd1.tar.gz bcm5719-llvm-dd9ee4aa04e5195e1f43badb9da121cc7dc7dcd1.zip |
-Make IndexProvider an abstract interface for getting indexing information.
-Introduce Indexer as an IndexProvider implementation.
llvm-svn: 77524
Diffstat (limited to 'clang/lib/Index/IndexProvider.cpp')
-rw-r--r-- | clang/lib/Index/IndexProvider.cpp | 64 |
1 files changed, 5 insertions, 59 deletions
diff --git a/clang/lib/Index/IndexProvider.cpp b/clang/lib/Index/IndexProvider.cpp index 38317eb9c2c..eea09887570 100644 --- a/clang/lib/Index/IndexProvider.cpp +++ b/clang/lib/Index/IndexProvider.cpp @@ -1,74 +1,20 @@ -//===--- IndexProvider.cpp - Map of entities to translation units ---------===// +//===- IndexProvider.cpp - Maps information to translation units -*- C++ -*-==// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source -// License. See LICENSaE.TXT for details. +// License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // -// Maps Entities to TranslationUnits +// Maps information to TranslationUnits. // //===----------------------------------------------------------------------===// #include "clang/Index/IndexProvider.h" -#include "clang/Index/Program.h" #include "clang/Index/Entity.h" -#include "clang/Index/EntityHandler.h" -#include "clang/Index/TranslationUnit.h" using namespace clang; using namespace idx; -class IndexProvider::Indexer : public EntityHandler { - TranslationUnit *TU; - MapTy ⤅ - -public: - Indexer(TranslationUnit *tu, MapTy &map) : TU(tu), Map(map) { } - - virtual void HandleEntity(Entity Ent) { - if (Ent.isInternalToTU()) - return; - - MapTy::iterator I = Map.find(Ent); - if (I != Map.end()) { - I->second.insert(TU); - return; - } - - Map[Ent].insert(TU); - } -}; - -void IndexProvider::IndexAST(TranslationUnit *TU) { - Indexer Idx(TU, Map); - Prog.FindEntities(TU->getASTContext(), &Idx); -} - -static IndexProvider::TUSetTy EmptySet; - -IndexProvider::translation_unit_iterator -IndexProvider::translation_units_begin(Entity Ent) const { - MapTy::iterator I = Map.find(Ent); - if (I == Map.end()) - return EmptySet.begin(); - - return I->second.begin(); -} - -IndexProvider::translation_unit_iterator -IndexProvider::translation_units_end(Entity Ent) const { - MapTy::iterator I = Map.find(Ent); - if (I == Map.end()) - return EmptySet.end(); - - return I->second.end(); -} - -bool IndexProvider::translation_units_empty(Entity Ent) const { - MapTy::iterator I = Map.find(Ent); - if (I == Map.end()) - return true; - - return I->second.begin() == I->second.end(); -} +// Out-of-line to give the virtual table a home. +IndexProvider::~IndexProvider() { } |