The generated identifiers are stable across multiple runs, and can be a
great debug or visualization aid.
Differential Revision: https://reviews.llvm.org/D51822
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342309
91177308-0d34-0410-b5e6-
96231b3b80d8
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;
llvm_unreachable("unknown statement kind");
}
+int64_t Stmt::getID(const ASTContext &Context) const {
+ Optional<int64_t> 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<Stmt *> Stmts, SourceLocation LB,
SourceLocation RB)
: Stmt(CompoundStmtClass), LBraceLoc(LB), RBraceLoc(RB) {