This revision was automatically updated to reflect the committed changes.
Closed by commit rC342315: Generate unique identifiers for Decl objects 
(authored by george.karpenkov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52113?vs=165564&id=165631#toc

Repository:
  rC Clang

https://reviews.llvm.org/D52113

Files:
  include/clang/AST/DeclBase.h
  lib/AST/DeclBase.cpp


Index: lib/AST/DeclBase.cpp
===================================================================
--- lib/AST/DeclBase.cpp
+++ lib/AST/DeclBase.cpp
@@ -930,6 +930,13 @@
 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))
Index: include/clang/AST/DeclBase.h
===================================================================
--- include/clang/AST/DeclBase.h
+++ include/clang/AST/DeclBase.h
@@ -1141,6 +1141,9 @@
 
   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.


Index: lib/AST/DeclBase.cpp
===================================================================
--- lib/AST/DeclBase.cpp
+++ lib/AST/DeclBase.cpp
@@ -930,6 +930,13 @@
 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))
Index: include/clang/AST/DeclBase.h
===================================================================
--- include/clang/AST/DeclBase.h
+++ include/clang/AST/DeclBase.h
@@ -1141,6 +1141,9 @@
 
   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.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to