summaryrefslogtreecommitdiffstats
path: root/clang/lib/Index/EntityImpl.h
blob: 3f09f80fc1f62afcd9141fcdcc51e2dd003fa01b (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
58
59
60
61
62
63
64
65
//===--- EntityImpl.h - Internal Entity implementation---------*- C++ -*-=====//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//  Internal implementation for the Entity class
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_INDEX_ENTITYIMPL_H
#define LLVM_CLANG_INDEX_ENTITYIMPL_H

#include "clang/Index/Entity.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/StringSet.h"

namespace clang {

namespace idx {
  class ProgramImpl;

class EntityImpl : public llvm::FoldingSetNode {
public:
  typedef llvm::StringMapEntry<char> IdEntryTy;

private:
  Entity Parent;
  IdEntryTy *Id;

  /// \brief Identifier namespace.
  unsigned IdNS;

public:
  EntityImpl(Entity parent, IdEntryTy *id, unsigned idNS)
    : Parent(parent), Id(id), IdNS(idNS) { }

  /// \brief Find the Decl that can be referred to by this entity.
  Decl *getDecl(ASTContext &AST);

  /// \brief Get an Entity associated with the given Decl.
  /// \returns Null if an Entity cannot refer to this Decl.
  static Entity get(Decl *D, ProgramImpl &Prog);
  
  std::string getPrintableName();

  void Profile(llvm::FoldingSetNodeID &ID) const {
    Profile(ID, Parent, Id, IdNS);
  }
  static void Profile(llvm::FoldingSetNodeID &ID, Entity Parent, IdEntryTy *Id,
                      unsigned IdNS) {
    ID.AddPointer(Parent.getAsOpaquePtr());
    ID.AddPointer(Id);
    ID.AddInteger(IdNS);
  }
};

} // namespace idx

} // namespace clang

#endif
OpenPOWER on IntegriCloud