aboutsummaryrefslogtreecommitdiff
path: root/lib/Index/EntityImpl.h
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-07-21 00:07:06 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-07-21 00:07:06 +0000
commitf7cf15ca3c9bee7c0348f549e7a8f0af32b5fa54 (patch)
tree05e1fd135984a32777ddfbd291bfdc913046d50a /lib/Index/EntityImpl.h
parent07ef804f918d8aade8739a02e78c6209fd3062a9 (diff)
Change the semantics for Entity.
Entity can now refer to declarations that are not visible outside the translation unit. It is a wrapper of a pointer union, it's either a Decl* for declarations that don't "cross" translation units, or an EntityImpl* which is associated with the specific "visible" Decl. Included is a test case for handling fields across translation units. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76515 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Index/EntityImpl.h')
-rw-r--r--lib/Index/EntityImpl.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/lib/Index/EntityImpl.h b/lib/Index/EntityImpl.h
new file mode 100644
index 0000000000..334dcfb4ec
--- /dev/null
+++ b/lib/Index/EntityImpl.h
@@ -0,0 +1,63 @@
+//===--- EntityImpl.h - Internal Entity implementation---------*- C++ -*-=====//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Internal implementation for the Entity class
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_INDEX_ENTITYIMPL_H
+#define LLVM_CLANG_INDEX_ENTITYIMPL_H
+
+#include "clang/Index/Entity.h"
+#include "llvm/ADT/FoldingSet.h"
+#include "llvm/ADT/StringSet.h"
+
+namespace clang {
+
+namespace idx {
+ class ProgramImpl;
+
+class EntityImpl : public llvm::FoldingSetNode {
+public:
+ typedef llvm::StringMapEntry<char> IdEntryTy;
+
+private:
+ Entity Parent;
+ IdEntryTy *Id;
+
+ /// \brief Identifier namespace.
+ unsigned IdNS;
+
+public:
+ EntityImpl(Entity parent, IdEntryTy *id, unsigned idNS)
+ : Parent(parent), Id(id), IdNS(idNS) { }
+
+ /// \brief Find the Decl that can be referred to by this entity.
+ Decl *getDecl(ASTContext &AST);
+
+ /// \brief Get an Entity associated with the given Decl.
+ /// \returns Null if an Entity cannot refer to this Decl.
+ static Entity get(Decl *D, ProgramImpl &Prog);
+
+ void Profile(llvm::FoldingSetNodeID &ID) const {
+ Profile(ID, Parent, Id, IdNS);
+ }
+ static void Profile(llvm::FoldingSetNodeID &ID, Entity Parent, IdEntryTy *Id,
+ unsigned IdNS) {
+ ID.AddPointer(Parent.getAsOpaquePtr());
+ ID.AddPointer(Id);
+ ID.AddInteger(IdNS);
+ }
+};
+
+} // namespace idx
+
+} // namespace clang
+
+#endif