Index: include/clang/AST/Stmt.h =================================================================== --- include/clang/AST/Stmt.h +++ include/clang/AST/Stmt.h @@ -413,6 +413,9 @@ void dump(raw_ostream &OS, SourceManager &SM) const; void dump(raw_ostream &OS) const; + /// \return Unique reproducible object identifier + int64_t getID(const ASTContext &Context) const; + /// dumpColor - same as dump(), but forces color highlighting. void dumpColor() const; Index: lib/AST/Stmt.cpp =================================================================== --- lib/AST/Stmt.cpp +++ lib/AST/Stmt.cpp @@ -302,6 +302,14 @@ llvm_unreachable("unknown statement kind"); } +int64_t Stmt::getID(const ASTContext &Context) const { + Optional Out = Context.getAllocator().identifyObject(this); + assert(Out && "Wrong allocator used"); + assert(*Out % alignof(Stmt) == 0 && "Wrong alignment information"); + return *Out / alignof(Stmt); + +} + CompoundStmt::CompoundStmt(ArrayRef Stmts, SourceLocation LB, SourceLocation RB) : Stmt(CompoundStmtClass), LBraceLoc(LB), RBraceLoc(RB) {