blob: 6d6a0c6d2b69c922dbe2b87191108505a5f51f6e [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);
Chris Lattner686775d2011-07-20 06:58:45 +000050 static Entity get(StringRef Name, Program &Prog, ProgramImpl &ProgImpl);
Mike Stump1eb44332009-09-09 15:08:12 +000051
Argyrios Kyrtzidis4c7c5a12009-07-21 07:52:21 +000052 std::string getPrintableName();
Argyrios Kyrtzidisf7cf15c2009-07-21 00:07:06 +000053
54 void Profile(llvm::FoldingSetNodeID &ID) const {
Argyrios Kyrtzidis87bcb502009-07-29 23:41:46 +000055 Profile(ID, Parent, Name, IdNS, IsObjCInstanceMethod);
Argyrios Kyrtzidisf7cf15c2009-07-21 00:07:06 +000056 }
Argyrios Kyrtzidisdc1792c2009-07-29 23:40:21 +000057 static void Profile(llvm::FoldingSetNodeID &ID, Entity Parent,
Argyrios Kyrtzidis87bcb502009-07-29 23:41:46 +000058 DeclarationName Name, unsigned IdNS,
59 bool isObjCInstanceMethod) {
Argyrios Kyrtzidisf7cf15c2009-07-21 00:07:06 +000060 ID.AddPointer(Parent.getAsOpaquePtr());
Argyrios Kyrtzidis87bcb502009-07-29 23:41:46 +000061 ID.AddPointer(Name.getAsOpaquePtr());
Argyrios Kyrtzidisf7cf15c2009-07-21 00:07:06 +000062 ID.AddInteger(IdNS);
Argyrios Kyrtzidis87bcb502009-07-29 23:41:46 +000063 ID.AddBoolean(isObjCInstanceMethod);
Argyrios Kyrtzidisf7cf15c2009-07-21 00:07:06 +000064 }
65};
66
67} // namespace idx
68
69} // namespace clang
70
71#endif