aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Index/Entity.h
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-07-05 22:22:19 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-07-05 22:22:19 +0000
commit9eec4ed6ca0dcf098580da9146b97e0841556d12 (patch)
tree990b7278fb0983249a24c985f00fc4ff361a7d42 /include/clang/Index/Entity.h
parent2c2ba3e258961dd98cacffe3a2167bb6d958fd53 (diff)
Introduce the 'Index' library.
Its purpose is to provide the basic infrastructure for cross-translation-unit analysis like indexing, refactoring, etc. Currently it is very "primitive" and with no type-names support. It can provide functionality like "show me all references of this function from these translation units". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74802 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Index/Entity.h')
-rw-r--r--include/clang/Index/Entity.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/include/clang/Index/Entity.h b/include/clang/Index/Entity.h
new file mode 100644
index 0000000000..8caaeb870f
--- /dev/null
+++ b/include/clang/Index/Entity.h
@@ -0,0 +1,70 @@
+//===--- Entity.h - Cross-translation-unit "token" for decls ----*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Entity is a ASTContext-independent way to refer to declarations that are
+// visible across translation units.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_INDEX_ENTITY_H
+#define LLVM_CLANG_INDEX_ENTITY_H
+
+#include "llvm/ADT/FoldingSet.h"
+
+namespace clang {
+ class ASTContext;
+ class Decl;
+
+namespace idx {
+ class Program;
+
+/// \brief A ASTContext-independent way to refer to declarations that are
+/// visible across translation units.
+///
+/// Entity is basically the link for declarations that are semantically the same
+/// in multiple ASTContexts. A client will convert a Decl into an Entity and
+/// later use that Entity to find the "same" Decl into another ASTContext.
+///
+/// An Entity may only refer to declarations that can be visible by multiple
+/// translation units, e.g. a static function cannot have an Entity associated
+/// with it.
+///
+/// Entities are uniqued so pointer equality can be used (note that the same
+/// Program object should be used when getting Entities).
+///
+class Entity : public llvm::FoldingSetNode {
+public:
+ /// \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, Program &Prog);
+
+ void Profile(llvm::FoldingSetNodeID &ID) const {
+ Profile(ID, Parent, Id);
+ }
+ static void Profile(llvm::FoldingSetNodeID &ID, Entity *Parent, void *Id) {
+ ID.AddPointer(Parent);
+ ID.AddPointer(Id);
+ }
+
+private:
+ Entity *Parent;
+ void *Id;
+
+ Entity(Entity *parent, void *id) : Parent(parent), Id(id) { }
+ friend class EntityGetter;
+};
+
+} // namespace idx
+
+} // namespace clang
+
+#endif