blob: cbce934bf7777709efca6ac3f007fff5a1510ae4 [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"
Argyrios Kyrtzidis87bcb502009-07-29 23:41:46 +000018#include "clang/AST/DeclarationName.h"
Argyrios Kyrtzidisf7cf15c2009-07-21 00:07:06 +000019#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 {
Argyrios Kyrtzidisf7cf15c2009-07-21 00:07:06 +000028 Entity Parent;
Argyrios Kyrtzidis87bcb502009-07-29 23:41:46 +000029 DeclarationName Name;
Argyrios Kyrtzidisf7cf15c2009-07-21 00:07:06 +000030
31 /// \brief Identifier namespace.
32 unsigned IdNS;
Mike Stump1eb44332009-09-09 15:08:12 +000033
Argyrios Kyrtzidis87bcb502009-07-29 23:41:46 +000034 /// \brief If Name is a selector, this keeps track whether it's for an
35 /// instance method.
36 bool IsObjCInstanceMethod;
Argyrios Kyrtzidisf7cf15c2009-07-21 00:07:06 +000037
38public:
Argyrios Kyrtzidis87bcb502009-07-29 23:41:46 +000039 EntityImpl(Entity parent, DeclarationName name, unsigned idNS,
40 bool isObjCInstanceMethod)
41 : Parent(parent), Name(name), IdNS(idNS),
42 IsObjCInstanceMethod(isObjCInstanceMethod) { }
Argyrios Kyrtzidisf7cf15c2009-07-21 00:07:06 +000043
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.
Argyrios Kyrtzidis87bcb502009-07-29 23:41:46 +000049 static Entity get(Decl *D, Program &Prog, ProgramImpl &ProgImpl);
Mike Stump1eb44332009-09-09 15:08:12 +000050
Argyrios Kyrtzidis4c7c5a12009-07-21 07:52:21 +000051 std::string getPrintableName();
Argyrios Kyrtzidisf7cf15c2009-07-21 00:07:06 +000052
53 void Profile(llvm::FoldingSetNodeID &ID) const {
Argyrios Kyrtzidis87bcb502009-07-29 23:41:46 +000054 Profile(ID, Parent, Name, IdNS, IsObjCInstanceMethod);
Argyrios Kyrtzidisf7cf15c2009-07-21 00:07:06 +000055 }
Argyrios Kyrtzidisdc1792c2009-07-29 23:40:21 +000056 static void Profile(llvm::FoldingSetNodeID &ID, Entity Parent,
Argyrios Kyrtzidis87bcb502009-07-29 23:41:46 +000057 DeclarationName Name, unsigned IdNS,
58 bool isObjCInstanceMethod) {
Argyrios Kyrtzidisf7cf15c2009-07-21 00:07:06 +000059 ID.AddPointer(Parent.getAsOpaquePtr());
Argyrios Kyrtzidis87bcb502009-07-29 23:41:46 +000060 ID.AddPointer(Name.getAsOpaquePtr());
Argyrios Kyrtzidisf7cf15c2009-07-21 00:07:06 +000061 ID.AddInteger(IdNS);
Argyrios Kyrtzidis87bcb502009-07-29 23:41:46 +000062 ID.AddBoolean(isObjCInstanceMethod);
Argyrios Kyrtzidisf7cf15c2009-07-21 00:07:06 +000063 }
64};
65
66} // namespace idx
67
68} // namespace clang
69
70#endif