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" |
| 18 | #include "llvm/ADT/FoldingSet.h" |
| 19 | #include "llvm/ADT/StringSet.h" |
| 20 | |
| 21 | namespace clang { |
| 22 | |
| 23 | namespace idx { |
| 24 | class ProgramImpl; |
| 25 | |
| 26 | class EntityImpl : public llvm::FoldingSetNode { |
| 27 | public: |
| 28 | typedef llvm::StringMapEntry<char> IdEntryTy; |
| 29 | |
| 30 | private: |
| 31 | Entity Parent; |
| 32 | IdEntryTy *Id; |
| 33 | |
| 34 | /// \brief Identifier namespace. |
| 35 | unsigned IdNS; |
| 36 | |
| 37 | public: |
| 38 | EntityImpl(Entity parent, IdEntryTy *id, unsigned idNS) |
| 39 | : Parent(parent), Id(id), IdNS(idNS) { } |
| 40 | |
| 41 | /// \brief Find the Decl that can be referred to by this entity. |
| 42 | Decl *getDecl(ASTContext &AST); |
| 43 | |
| 44 | /// \brief Get an Entity associated with the given Decl. |
| 45 | /// \returns Null if an Entity cannot refer to this Decl. |
| 46 | static Entity get(Decl *D, ProgramImpl &Prog); |
Argyrios Kyrtzidis | 4c7c5a1 | 2009-07-21 07:52:21 +0000 | [diff] [blame] | 47 | |
| 48 | std::string getPrintableName(); |
Argyrios Kyrtzidis | f7cf15c | 2009-07-21 00:07:06 +0000 | [diff] [blame] | 49 | |
| 50 | void Profile(llvm::FoldingSetNodeID &ID) const { |
| 51 | Profile(ID, Parent, Id, IdNS); |
| 52 | } |
| 53 | static void Profile(llvm::FoldingSetNodeID &ID, Entity Parent, IdEntryTy *Id, |
| 54 | unsigned IdNS) { |
| 55 | ID.AddPointer(Parent.getAsOpaquePtr()); |
| 56 | ID.AddPointer(Id); |
| 57 | ID.AddInteger(IdNS); |
| 58 | } |
| 59 | }; |
| 60 | |
| 61 | } // namespace idx |
| 62 | |
| 63 | } // namespace clang |
| 64 | |
| 65 | #endif |