summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/AST/Stmt.h3
-rw-r--r--clang/lib/AST/Stmt.cpp8
2 files changed, 11 insertions, 0 deletions
diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index b9cfda7c6b8..33d4e70e02a 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -413,6 +413,9 @@ public:
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;
diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp
index 6ed71fd6733..687b9c24b09 100644
--- a/clang/lib/AST/Stmt.cpp
+++ b/clang/lib/AST/Stmt.cpp
@@ -302,6 +302,14 @@ SourceLocation Stmt::getEndLoc() 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) {
OpenPOWER on IntegriCloud