]> granicus.if.org Git - clang/commitdiff
[AST] [analyzer] NFC: Reuse code in stable ID dumping methods.
authorArtem Dergachev <artem.dergachev@gmail.com>
Mon, 3 Dec 2018 22:19:05 +0000 (22:19 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Mon, 3 Dec 2018 22:19:05 +0000 (22:19 +0000)
Use the new fancy method introduced in r348197 to simplify some code.

Differential Revision: https://reviews.llvm.org/D54488

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348199 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclBase.cpp
lib/AST/DeclCXX.cpp
lib/AST/Stmt.cpp
lib/StaticAnalyzer/Core/ExplodedGraph.cpp
lib/StaticAnalyzer/Core/ProgramState.cpp

index f65d3063e37bc0a630f3902cafffa08a673c1225..95babf791790917f3bafb3b6ac71b7b218ba8941 100644 (file)
@@ -955,10 +955,7 @@ 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);
+  return getASTContext().getAllocator().identifyKnownAlignedObject<Decl>(this);
 }
 
 const FunctionType *Decl::getFunctionType(bool BlocksToo) const {
index 81ee48c1829abbbc0b3c79a848257734cb50d08b..419326ae904650d6c81ae5661fbd08b99055b6b6 100644 (file)
@@ -2247,11 +2247,8 @@ CXXCtorInitializer::CXXCtorInitializer(ASTContext &Context,
       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 {
index 901df9ca75938e79b2e223b43442ad50c539162b..32330ea3bfe221be0da20089c5dd80de9144f379 100644 (file)
@@ -303,10 +303,7 @@ SourceLocation Stmt::getEndLoc() const {
 }
 
 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,
index d76710004c871f61ee579ca9d11c6eaf67899b1e..d6bcbb96b55f16c287e002501f7788aaf8911b5f 100644 (file)
@@ -284,10 +284,7 @@ ExplodedNode * const *ExplodedNode::NodeGroup::end() const {
 }
 
 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 {
index 399cf1830218beff8f924f53f1eb407e8f7d2ddd..ceb4fbdf784f1e2ea41f30886b6cd4b3d788c279 100644 (file)
@@ -70,10 +70,7 @@ ProgramState::~ProgramState() {
 }
 
 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,