Home | History | Annotate | Download | only in Index
      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 "clang/AST/DeclarationName.h"
     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 {
     28   Entity Parent;
     29   DeclarationName Name;
     30 
     31   /// \brief Identifier namespace.
     32   unsigned IdNS;
     33 
     34   /// \brief If Name is a selector, this keeps track whether it's for an
     35   /// instance method.
     36   bool IsObjCInstanceMethod;
     37 
     38 public:
     39   EntityImpl(Entity parent, DeclarationName name, unsigned idNS,
     40              bool isObjCInstanceMethod)
     41     : Parent(parent), Name(name), IdNS(idNS),
     42       IsObjCInstanceMethod(isObjCInstanceMethod) { }
     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.
     49   static Entity get(Decl *D, Program &Prog, ProgramImpl &ProgImpl);
     50   static Entity get(StringRef Name, Program &Prog, ProgramImpl &ProgImpl);
     51 
     52   std::string getPrintableName();
     53 
     54   void Profile(llvm::FoldingSetNodeID &ID) const {
     55     Profile(ID, Parent, Name, IdNS, IsObjCInstanceMethod);
     56   }
     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());
     62     ID.AddInteger(IdNS);
     63     ID.AddBoolean(isObjCInstanceMethod);
     64   }
     65 };
     66 
     67 } // namespace idx
     68 
     69 } // namespace clang
     70 
     71 #endif
     72