aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Index/SelectorMap.h
blob: be01702fcbdbea5fb46f38bcb067d9ff3e5bad0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//===--- SelectorMap.h - Maps selectors to methods and messages -*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//  SelectorMap creates a mapping from selectors to ObjC method declarations
//  and ObjC message expressions.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_INDEX_SELECTORMAP_H
#define LLVM_CLANG_INDEX_SELECTORMAP_H

#include "clang/Index/ASTLocation.h"
#include "clang/Index/STLExtras.h"
#include "clang/Basic/IdentifierTable.h"
#include <map>

namespace clang {
  class ASTContext;
  class ObjCMethodDecl;

namespace idx {

/// \brief Maps NamedDecls with the ASTLocations that reference them.
///
/// References are mapped and retrieved using the canonical decls.
class SelectorMap {
public:
  explicit SelectorMap(ASTContext &Ctx);

  typedef std::multimap<Selector, ObjCMethodDecl *> SelMethMapTy;
  typedef std::multimap<Selector, ASTLocation> SelRefMapTy;

  typedef pair_value_iterator<SelMethMapTy::iterator> method_iterator;
  typedef pair_value_iterator<SelRefMapTy::iterator> astlocation_iterator;

  method_iterator methods_begin(Selector Sel) const;
  method_iterator methods_end(Selector Sel) const;

  astlocation_iterator refs_begin(Selector Sel) const;
  astlocation_iterator refs_end(Selector Sel) const;

private:
  mutable SelMethMapTy SelMethMap;
  mutable SelRefMapTy SelRefMap;
};

} // end idx namespace

} // end clang namespace

#endif