clang API Documentation

EntityImpl.h
Go to the documentation of this file.
00001 //===--- EntityImpl.h - Internal Entity implementation---------*- C++ -*-=====//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 //  Internal implementation for the Entity class
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_CLANG_INDEX_ENTITYIMPL_H
00015 #define LLVM_CLANG_INDEX_ENTITYIMPL_H
00016 
00017 #include "clang/Index/Entity.h"
00018 #include "clang/AST/DeclarationName.h"
00019 #include "llvm/ADT/FoldingSet.h"
00020 #include "llvm/ADT/StringSet.h"
00021 
00022 namespace clang {
00023 
00024 namespace idx {
00025   class ProgramImpl;
00026 
00027 class EntityImpl : public llvm::FoldingSetNode {
00028   Entity Parent;
00029   DeclarationName Name;
00030 
00031   /// \brief Identifier namespace.
00032   unsigned IdNS;
00033 
00034   /// \brief If Name is a selector, this keeps track whether it's for an
00035   /// instance method.
00036   bool IsObjCInstanceMethod;
00037 
00038 public:
00039   EntityImpl(Entity parent, DeclarationName name, unsigned idNS,
00040              bool isObjCInstanceMethod)
00041     : Parent(parent), Name(name), IdNS(idNS),
00042       IsObjCInstanceMethod(isObjCInstanceMethod) { }
00043 
00044   /// \brief Find the Decl that can be referred to by this entity.
00045   Decl *getDecl(ASTContext &AST);
00046 
00047   /// \brief Get an Entity associated with the given Decl.
00048   /// \returns Null if an Entity cannot refer to this Decl.
00049   static Entity get(Decl *D, Program &Prog, ProgramImpl &ProgImpl);
00050   static Entity get(StringRef Name, Program &Prog, ProgramImpl &ProgImpl);
00051 
00052   std::string getPrintableName();
00053 
00054   void Profile(llvm::FoldingSetNodeID &ID) const {
00055     Profile(ID, Parent, Name, IdNS, IsObjCInstanceMethod);
00056   }
00057   static void Profile(llvm::FoldingSetNodeID &ID, Entity Parent,
00058                       DeclarationName Name, unsigned IdNS,
00059                       bool isObjCInstanceMethod) {
00060     ID.AddPointer(Parent.getAsOpaquePtr());
00061     ID.AddPointer(Name.getAsOpaquePtr());
00062     ID.AddInteger(IdNS);
00063     ID.AddBoolean(isObjCInstanceMethod);
00064   }
00065 };
00066 
00067 } // namespace idx
00068 
00069 } // namespace clang
00070 
00071 #endif