1 //===--- EntityImpl.h - Internal Entity implementation---------*- C++ -*-=====//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Internal implementation for the Entity class
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_INDEX_ENTITYIMPL_H
15 #define LLVM_CLANG_INDEX_ENTITYIMPL_H
17 #include "clang/Index/Entity.h"
18 #include "clang/AST/DeclarationName.h"
19 #include "llvm/ADT/FoldingSet.h"
20 #include "llvm/ADT/StringSet.h"
27 class EntityImpl : public llvm::FoldingSetNode {
31 /// \brief Identifier namespace.
34 /// \brief If Name is a selector, this keeps track whether it's for an
36 bool IsObjCInstanceMethod;
39 EntityImpl(Entity parent, DeclarationName name, unsigned idNS,
40 bool isObjCInstanceMethod)
41 : Parent(parent), Name(name), IdNS(idNS),
42 IsObjCInstanceMethod(isObjCInstanceMethod) { }
44 /// \brief Find the Decl that can be referred to by this entity.
45 Decl *getDecl(ASTContext &AST);
47 /// \brief Get an Entity associated with the given Decl.
48 /// \returns Null if an Entity cannot refer to this Decl.
49 static Entity get(Decl *D, Program &Prog, ProgramImpl &ProgImpl);
50 static Entity get(llvm::StringRef Name, Program &Prog, ProgramImpl &ProgImpl);
52 std::string getPrintableName();
54 void Profile(llvm::FoldingSetNodeID &ID) const {
55 Profile(ID, Parent, Name, IdNS, IsObjCInstanceMethod);
57 static void Profile(llvm::FoldingSetNodeID &ID, Entity Parent,
58 DeclarationName Name, unsigned IdNS,
59 bool isObjCInstanceMethod) {
60 ID.AddPointer(Parent.getAsOpaquePtr());
61 ID.AddPointer(Name.getAsOpaquePtr());
63 ID.AddBoolean(isObjCInstanceMethod);