1 //===--- Indexer.h - IndexProvider implementation ---------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // IndexProvider implementation.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_INDEX_INDEXER_H
15 #define LLVM_CLANG_INDEX_INDEXER_H
17 #include "clang/Index/IndexProvider.h"
18 #include "clang/Index/Entity.h"
19 #include "clang/Index/GlobalSelector.h"
20 #include "llvm/ADT/SmallPtrSet.h"
21 #include "llvm/ADT/DenseMap.h"
30 class TranslationUnit;
32 /// \brief Maps information to TranslationUnits.
33 class Indexer : public IndexProvider {
35 typedef llvm::SmallPtrSet<TranslationUnit *, 4> TUSetTy;
36 typedef llvm::DenseMap<ASTContext *, TranslationUnit *> CtxTUMapTy;
37 typedef std::map<Entity, TUSetTy> MapTy;
38 typedef std::map<GlobalSelector, TUSetTy> SelMapTy;
39 typedef std::map<Entity, std::pair<FunctionDecl*,TranslationUnit*> > DefMapTy;
41 explicit Indexer(Program &prog) :
44 Program &getProgram() const { return Prog; }
46 /// \brief Find all Entities and map them to the given translation unit.
47 void IndexAST(TranslationUnit *TU);
49 virtual void GetTranslationUnitsFor(Entity Ent,
50 TranslationUnitHandler &Handler);
51 virtual void GetTranslationUnitsFor(GlobalSelector Sel,
52 TranslationUnitHandler &Handler);
54 std::pair<FunctionDecl*, TranslationUnit*> getDefinitionFor(Entity Ent);
60 // Map a function Entity to the its definition.