1 //===--- DeclReferenceMap.h - Map Decls to their references -----*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // DeclReferenceMap creates a mapping from Decls to the ASTLocations that 11 // reference them. 12 // 13 //===----------------------------------------------------------------------===// 14 15 #ifndef LLVM_CLANG_INDEX_DECLREFERENCEMAP_H 16 #define LLVM_CLANG_INDEX_DECLREFERENCEMAP_H 17 18 #include "clang/Index/ASTLocation.h" 19 #include "clang/Index/STLExtras.h" 20 #include <map> 21 22 namespace clang { 23 class ASTContext; 24 class NamedDecl; 25 26 namespace idx { 27 28 /// \brief Maps NamedDecls with the ASTLocations that reference them. 29 /// 30 /// References are mapped and retrieved using the canonical decls. 31 class DeclReferenceMap { 32 public: 33 explicit DeclReferenceMap(ASTContext &Ctx); 34 35 typedef std::multimap<NamedDecl*, ASTLocation> MapTy; 36 typedef pair_value_iterator<MapTy::iterator> astlocation_iterator; 37 38 astlocation_iterator refs_begin(NamedDecl *D) const; 39 astlocation_iterator refs_end(NamedDecl *D) const; 40 bool refs_empty(NamedDecl *D) const; 41 42 private: 43 mutable MapTy Map; 44 }; 45 46 } // end idx namespace 47 48 } // end clang namespace 49 50 #endif 51