summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/AST/DeclBase.h3
-rw-r--r--clang/lib/AST/DeclBase.cpp7
2 files changed, 10 insertions, 0 deletions
diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h
index 37ce07b6db6..0d521200170 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -1141,6 +1141,9 @@ public:
void dump(raw_ostream &Out, bool Deserialize = false) const;
+ /// \return Unique reproducible object identifier
+ int64_t getID() const;
+
/// Looks through the Decl's underlying type to extract a FunctionType
/// when possible. Will return null if the type underlying the Decl does not
/// have a FunctionType.
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 796b5325ee8..6bb2034a9ea 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -930,6 +930,13 @@ bool Decl::AccessDeclContextSanity() const {
static Decl::Kind getKind(const Decl *D) { return D->getKind(); }
static Decl::Kind getKind(const DeclContext *DC) { return DC->getDeclKind(); }
+int64_t Decl::getID() const {
+ Optional<int64_t> Out = getASTContext().getAllocator().identifyObject(this);
+ assert(Out && "Wrong allocator used");
+ assert(*Out % alignof(Decl) == 0 && "Wrong alignment information");
+ return *Out / alignof(Decl);
+}
+
const FunctionType *Decl::getFunctionType(bool BlocksToo) const {
QualType Ty;
if (const auto *D = dyn_cast<ValueDecl>(this))
OpenPOWER on IntegriCloud