blob: 3f09f80fc1f62afcd9141fcdcc51e2dd003fa01b [file] [log] [blame]
Argyrios Kyrtzidisf7cf15c2009-07-21 00:07:06 +00001//===--- EntityImpl.h - Internal Entity implementation---------*- 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// Internal implementation for the Entity class
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_INDEX_ENTITYIMPL_H
15#define LLVM_CLANG_INDEX_ENTITYIMPL_H
16
17#include "clang/Index/Entity.h"
18#include "llvm/ADT/FoldingSet.h"
19#include "llvm/ADT/StringSet.h"
20
21namespace clang {
22
23namespace idx {
24 class ProgramImpl;
25
26class EntityImpl : public llvm::FoldingSetNode {
27public:
28 typedef llvm::StringMapEntry<char> IdEntryTy;
29
30private:
31 Entity Parent;
32 IdEntryTy *Id;
33
34 /// \brief Identifier namespace.
35 unsigned IdNS;
36
37public:
38 EntityImpl(Entity parent, IdEntryTy *id, unsigned idNS)
39 : Parent(parent), Id(id), IdNS(idNS) { }
40
41 /// \brief Find the Decl that can be referred to by this entity.
42 Decl *getDecl(ASTContext &AST);
43
44 /// \brief Get an Entity associated with the given Decl.
45 /// \returns Null if an Entity cannot refer to this Decl.
46 static Entity get(Decl *D, ProgramImpl &Prog);
Argyrios Kyrtzidis4c7c5a12009-07-21 07:52:21 +000047
48 std::string getPrintableName();
Argyrios Kyrtzidisf7cf15c2009-07-21 00:07:06 +000049
50 void Profile(llvm::FoldingSetNodeID &ID) const {
51 Profile(ID, Parent, Id, IdNS);
52 }
53 static void Profile(llvm::FoldingSetNodeID &ID, Entity Parent, IdEntryTy *Id,
54 unsigned IdNS) {
55 ID.AddPointer(Parent.getAsOpaquePtr());
56 ID.AddPointer(Id);
57 ID.AddInteger(IdNS);
58 }
59};
60
61} // namespace idx
62
63} // namespace clang
64
65#endif