[AST] [analyzer] NFC: Reuse code in stable ID dumping methods.
Use the new fancy method introduced in r348197 to simplify some code.
Differential Revision: https://reviews.llvm.org/D54488
llvm-svn: 348199
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index f65d306..95babf7 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -955,10 +955,7 @@
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);
+ return getASTContext().getAllocator().identifyKnownAlignedObject<Decl>(this);
}
const FunctionType *Decl::getFunctionType(bool BlocksToo) const {
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 81ee48c..419326ae 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -2247,11 +2247,8 @@
IsDelegating(true), IsVirtual(false), IsWritten(false), SourceOrder(0) {}
int64_t CXXCtorInitializer::getID(const ASTContext &Context) const {
- Optional<int64_t> Out = Context.getAllocator().identifyObject(this);
- assert(Out && "Wrong allocator used");
- assert(*Out % alignof(CXXCtorInitializer) == 0 &&
- "Wrong alignment information");
- return *Out / alignof(CXXCtorInitializer);
+ return Context.getAllocator()
+ .identifyKnownAlignedObject<CXXCtorInitializer>(this);
}
TypeLoc CXXCtorInitializer::getBaseClassLoc() const {
diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp
index 901df9c..32330ea 100644
--- a/clang/lib/AST/Stmt.cpp
+++ b/clang/lib/AST/Stmt.cpp
@@ -303,10 +303,7 @@
}
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);
+ return Context.getAllocator().identifyKnownAlignedObject<Stmt>(this);
}
CompoundStmt::CompoundStmt(ArrayRef<Stmt *> Stmts, SourceLocation LB,
diff --git a/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp b/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
index d767100..d6bcbb9 100644
--- a/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
@@ -284,10 +284,7 @@
}
int64_t ExplodedNode::getID(ExplodedGraph *G) const {
- Optional<int64_t> Out = G->getAllocator().identifyObject(this);
- assert(Out && "Wrong allocator used");
- assert(*Out % alignof(ExplodedNode) == 0 && "Wrong alignment information");
- return *Out / alignof(ExplodedNode);
+ return G->getAllocator().identifyKnownAlignedObject<ExplodedNode>(this);
}
bool ExplodedNode::isTrivial() const {
diff --git a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp b/clang/lib/StaticAnalyzer/Core/ProgramState.cpp
index 399cf18..ceb4fbd 100644
--- a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -70,10 +70,7 @@
}
int64_t ProgramState::getID() const {
- Optional<int64_t> Out = getStateManager().Alloc.identifyObject(this);
- assert(Out && "Wrong allocator used");
- assert(*Out % alignof(ProgramState) == 0 && "Wrong alignment information");
- return *Out / alignof(ProgramState);
+ return getStateManager().Alloc.identifyKnownAlignedObject<ProgramState>(this);
}
ProgramStateManager::ProgramStateManager(ASTContext &Ctx,