Argyrios Kyrtzidis | f7cf15c | 2009-07-21 00:07:06 +0000 | [diff] [blame] | 1 | //===--- 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 Kyrtzidis | 87bcb50 | 2009-07-29 23:41:46 +0000 | [diff] [blame] | 18 | #include "clang/AST/DeclarationName.h" |
Argyrios Kyrtzidis | f7cf15c | 2009-07-21 00:07:06 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/FoldingSet.h" |
| 20 | #include "llvm/ADT/StringSet.h" |
| 21 | |
| 22 | namespace clang { |
| 23 | |
| 24 | namespace idx { |
| 25 | class ProgramImpl; |
| 26 | |
| 27 | class EntityImpl : public llvm::FoldingSetNode { |
Argyrios Kyrtzidis | f7cf15c | 2009-07-21 00:07:06 +0000 | [diff] [blame] | 28 | Entity Parent; |
Argyrios Kyrtzidis | 87bcb50 | 2009-07-29 23:41:46 +0000 | [diff] [blame] | 29 | DeclarationName Name; |
Argyrios Kyrtzidis | f7cf15c | 2009-07-21 00:07:06 +0000 | [diff] [blame] | 30 | |
| 31 | /// \brief Identifier namespace. |
| 32 | unsigned IdNS; |
Argyrios Kyrtzidis | 87bcb50 | 2009-07-29 23:41:46 +0000 | [diff] [blame] | 33 | |
| 34 | /// \brief If Name is a selector, this keeps track whether it's for an |
| 35 | /// instance method. |
| 36 | bool IsObjCInstanceMethod; |
Argyrios Kyrtzidis | f7cf15c | 2009-07-21 00:07:06 +0000 | [diff] [blame] | 37 | |
| 38 | public: |
Argyrios Kyrtzidis | 87bcb50 | 2009-07-29 23:41:46 +0000 | [diff] [blame] | 39 | EntityImpl(Entity parent, DeclarationName name, unsigned idNS, |
| 40 | bool isObjCInstanceMethod) |
| 41 | : Parent(parent), Name(name), IdNS(idNS), |
| 42 | IsObjCInstanceMethod(isObjCInstanceMethod) { } |
Argyrios Kyrtzidis | f7cf15c | 2009-07-21 00:07:06 +0000 | [diff] [blame] | 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. |
Argyrios Kyrtzidis | 87bcb50 | 2009-07-29 23:41:46 +0000 | [diff] [blame] | 49 | static Entity get(Decl *D, Program &Prog, ProgramImpl &ProgImpl); |
Argyrios Kyrtzidis | 4c7c5a1 | 2009-07-21 07:52:21 +0000 | [diff] [blame] | 50 | |
| 51 | std::string getPrintableName(); |
Argyrios Kyrtzidis | f7cf15c | 2009-07-21 00:07:06 +0000 | [diff] [blame] | 52 | |
| 53 | void Profile(llvm::FoldingSetNodeID &ID) const { |
Argyrios Kyrtzidis | 87bcb50 | 2009-07-29 23:41:46 +0000 | [diff] [blame] | 54 | Profile(ID, Parent, Name, IdNS, IsObjCInstanceMethod); |
Argyrios Kyrtzidis | f7cf15c | 2009-07-21 00:07:06 +0000 | [diff] [blame] | 55 | } |
Argyrios Kyrtzidis | dc1792c | 2009-07-29 23:40:21 +0000 | [diff] [blame] | 56 | static void Profile(llvm::FoldingSetNodeID &ID, Entity Parent, |
Argyrios Kyrtzidis | 87bcb50 | 2009-07-29 23:41:46 +0000 | [diff] [blame] | 57 | DeclarationName Name, unsigned IdNS, |
| 58 | bool isObjCInstanceMethod) { |
Argyrios Kyrtzidis | f7cf15c | 2009-07-21 00:07:06 +0000 | [diff] [blame] | 59 | ID.AddPointer(Parent.getAsOpaquePtr()); |
Argyrios Kyrtzidis | 87bcb50 | 2009-07-29 23:41:46 +0000 | [diff] [blame] | 60 | ID.AddPointer(Name.getAsOpaquePtr()); |
Argyrios Kyrtzidis | f7cf15c | 2009-07-21 00:07:06 +0000 | [diff] [blame] | 61 | ID.AddInteger(IdNS); |
Argyrios Kyrtzidis | 87bcb50 | 2009-07-29 23:41:46 +0000 | [diff] [blame] | 62 | ID.AddBoolean(isObjCInstanceMethod); |
Argyrios Kyrtzidis | f7cf15c | 2009-07-21 00:07:06 +0000 | [diff] [blame] | 63 | } |
| 64 | }; |
| 65 | |
| 66 | } // namespace idx |
| 67 | |
| 68 | } // namespace clang |
| 69 | |
| 70 | #endif |