blob: e1671bbdce6c9e122aac864dc9938784387de5dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
//===--- 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 a printable name for debugging purpose.
std::string getPrintableName(ASTContext &Ctx);
/// \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
|