Argiris Kirtzidis | ff08826 | 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" |
| 18 | #include "llvm/ADT/FoldingSet.h" |
| 19 | #include "llvm/ADT/StringSet.h" |
| 20 | |
| 21 | namespace clang { |
Argiris Kirtzidis | a63d6ec | 2009-07-29 23:40:21 +0000 | [diff] [blame^] | 22 | class IdentifierInfo; |
Argiris Kirtzidis | ff08826 | 2009-07-21 00:07:06 +0000 | [diff] [blame] | 23 | |
| 24 | namespace idx { |
| 25 | class ProgramImpl; |
| 26 | |
| 27 | class EntityImpl : public llvm::FoldingSetNode { |
Argiris Kirtzidis | ff08826 | 2009-07-21 00:07:06 +0000 | [diff] [blame] | 28 | Entity Parent; |
Argiris Kirtzidis | a63d6ec | 2009-07-29 23:40:21 +0000 | [diff] [blame^] | 29 | IdentifierInfo *Id; |
Argiris Kirtzidis | ff08826 | 2009-07-21 00:07:06 +0000 | [diff] [blame] | 30 | |
| 31 | /// \brief Identifier namespace. |
| 32 | unsigned IdNS; |
| 33 | |
| 34 | public: |
Argiris Kirtzidis | a63d6ec | 2009-07-29 23:40:21 +0000 | [diff] [blame^] | 35 | EntityImpl(Entity parent, IdentifierInfo *id, unsigned idNS) |
Argiris Kirtzidis | ff08826 | 2009-07-21 00:07:06 +0000 | [diff] [blame] | 36 | : 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 Kirtzidis | 0d0b565 | 2009-07-21 07:52:21 +0000 | [diff] [blame] | 44 | |
| 45 | std::string getPrintableName(); |
Argiris Kirtzidis | ff08826 | 2009-07-21 00:07:06 +0000 | [diff] [blame] | 46 | |
| 47 | void Profile(llvm::FoldingSetNodeID &ID) const { |
| 48 | Profile(ID, Parent, Id, IdNS); |
| 49 | } |
Argiris Kirtzidis | a63d6ec | 2009-07-29 23:40:21 +0000 | [diff] [blame^] | 50 | static void Profile(llvm::FoldingSetNodeID &ID, Entity Parent, |
| 51 | IdentifierInfo *Id, unsigned IdNS) { |
Argiris Kirtzidis | ff08826 | 2009-07-21 00:07:06 +0000 | [diff] [blame] | 52 | 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 |