blob: 334dcfb4ecd9229a18decf274c400b1bb4ba238f [file] [log] [blame]
Argiris Kirtzidisff088262009-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);
47
48 void Profile(llvm::FoldingSetNodeID &ID) const {
49 Profile(ID, Parent, Id, IdNS);
50 }
51 static void Profile(llvm::FoldingSetNodeID &ID, Entity Parent, IdEntryTy *Id,
52 unsigned IdNS) {
53 ID.AddPointer(Parent.getAsOpaquePtr());
54 ID.AddPointer(Id);
55 ID.AddInteger(IdNS);
56 }
57};
58
59} // namespace idx
60
61} // namespace clang
62
63#endif