clang API Documentation

DeclReferenceMap.h
Go to the documentation of this file.
00001 //===--- DeclReferenceMap.h - Map Decls to their references -----*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 //  DeclReferenceMap creates a mapping from Decls to the ASTLocations that
00011 //  reference them.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_CLANG_INDEX_DECLREFERENCEMAP_H
00016 #define LLVM_CLANG_INDEX_DECLREFERENCEMAP_H
00017 
00018 #include "clang/Index/ASTLocation.h"
00019 #include "clang/Index/STLExtras.h"
00020 #include <map>
00021 
00022 namespace clang {
00023   class ASTContext;
00024   class NamedDecl;
00025 
00026 namespace idx {
00027 
00028 /// \brief Maps NamedDecls with the ASTLocations that reference them.
00029 ///
00030 /// References are mapped and retrieved using the canonical decls.
00031 class DeclReferenceMap {
00032 public:
00033   explicit DeclReferenceMap(ASTContext &Ctx);
00034 
00035   typedef std::multimap<NamedDecl*, ASTLocation> MapTy;
00036   typedef pair_value_iterator<MapTy::iterator> astlocation_iterator;
00037 
00038   astlocation_iterator refs_begin(NamedDecl *D) const;
00039   astlocation_iterator refs_end(NamedDecl *D) const;
00040   bool refs_empty(NamedDecl *D) const;
00041 
00042 private:
00043   mutable MapTy Map;
00044 };
00045 
00046 } // end idx namespace
00047 
00048 } // end clang namespace
00049 
00050 #endif