blob: d28936ee2cb9c907e9a31fb059bdc52d44a20720 [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 {
Argiris Kirtzidisa63d6ec2009-07-29 23:40:21 +000022 class IdentifierInfo;
Argiris Kirtzidisff088262009-07-21 00:07:06 +000023
24namespace idx {
25 class ProgramImpl;
26
27class EntityImpl : public llvm::FoldingSetNode {
Argiris Kirtzidisff088262009-07-21 00:07:06 +000028 Entity Parent;
Argiris Kirtzidisa63d6ec2009-07-29 23:40:21 +000029 IdentifierInfo *Id;
Argiris Kirtzidisff088262009-07-21 00:07:06 +000030
31 /// \brief Identifier namespace.
32 unsigned IdNS;
33
34public:
Argiris Kirtzidisa63d6ec2009-07-29 23:40:21 +000035 EntityImpl(Entity parent, IdentifierInfo *id, unsigned idNS)
Argiris Kirtzidisff088262009-07-21 00:07:06 +000036 : Parent(parent), Id(id), IdNS(idNS) { }
37
38 /// \brief Find the Decl that can be referred to by this entity.
39 Decl *getDecl(ASTContext &AST);
40
41 /// \brief Get an Entity associated with the given Decl.
42 /// \returns Null if an Entity cannot refer to this Decl.
43 static Entity get(Decl *D, ProgramImpl &Prog);
Argiris Kirtzidis0d0b5652009-07-21 07:52:21 +000044
45 std::string getPrintableName();
Argiris Kirtzidisff088262009-07-21 00:07:06 +000046
47 void Profile(llvm::FoldingSetNodeID &ID) const {
48 Profile(ID, Parent, Id, IdNS);
49 }
Argiris Kirtzidisa63d6ec2009-07-29 23:40:21 +000050 static void Profile(llvm::FoldingSetNodeID &ID, Entity Parent,
51 IdentifierInfo *Id, unsigned IdNS) {
Argiris Kirtzidisff088262009-07-21 00:07:06 +000052 ID.AddPointer(Parent.getAsOpaquePtr());
53 ID.AddPointer(Id);
54 ID.AddInteger(IdNS);
55 }
56};
57
58} // namespace idx
59
60} // namespace clang
61
62#endif