blob: cbce934bf7777709efca6ac3f007fff5a1510ae4 [file] [log] [blame]
Shih-wei Liaof8fd82b2010-02-10 11:10:31 -08001//===--- 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 "clang/AST/DeclarationName.h"
19#include "llvm/ADT/FoldingSet.h"
20#include "llvm/ADT/StringSet.h"
21
22namespace clang {
23
24namespace idx {
25 class ProgramImpl;
26
27class EntityImpl : public llvm::FoldingSetNode {
28 Entity Parent;
29 DeclarationName Name;
30
31 /// \brief Identifier namespace.
32 unsigned IdNS;
33
34 /// \brief If Name is a selector, this keeps track whether it's for an
35 /// instance method.
36 bool IsObjCInstanceMethod;
37
38public:
39 EntityImpl(Entity parent, DeclarationName name, unsigned idNS,
40 bool isObjCInstanceMethod)
41 : Parent(parent), Name(name), IdNS(idNS),
42 IsObjCInstanceMethod(isObjCInstanceMethod) { }
43
44 /// \brief Find the Decl that can be referred to by this entity.
45 Decl *getDecl(ASTContext &AST);
46
47 /// \brief Get an Entity associated with the given Decl.
48 /// \returns Null if an Entity cannot refer to this Decl.
49 static Entity get(Decl *D, Program &Prog, ProgramImpl &ProgImpl);
50
51 std::string getPrintableName();
52
53 void Profile(llvm::FoldingSetNodeID &ID) const {
54 Profile(ID, Parent, Name, IdNS, IsObjCInstanceMethod);
55 }
56 static void Profile(llvm::FoldingSetNodeID &ID, Entity Parent,
57 DeclarationName Name, unsigned IdNS,
58 bool isObjCInstanceMethod) {
59 ID.AddPointer(Parent.getAsOpaquePtr());
60 ID.AddPointer(Name.getAsOpaquePtr());
61 ID.AddInteger(IdNS);
62 ID.AddBoolean(isObjCInstanceMethod);
63 }
64};
65
66} // namespace idx
67
68} // namespace clang
69
70#endif