[PATCH] D48231: [Dominators] Change getNode parameter type to const NodeT * (NFC).

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 16 07:51:33 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL334892: [Dominators] Change getNode parameter type to const NodeT * (NFC). (authored by fhahn, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D48231?vs=151540&id=151619#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48231

Files:
  llvm/trunk/include/llvm/Support/GenericDomTree.h
  llvm/trunk/unittests/IR/DominatorTreeTest.cpp


Index: llvm/trunk/include/llvm/Support/GenericDomTree.h
===================================================================
--- llvm/trunk/include/llvm/Support/GenericDomTree.h
+++ llvm/trunk/include/llvm/Support/GenericDomTree.h
@@ -351,15 +351,17 @@
   /// block.  This is the same as using operator[] on this class.  The result
   /// may (but is not required to) be null for a forward (backwards)
   /// statically unreachable block.
-  DomTreeNodeBase<NodeT> *getNode(NodeT *BB) const {
+  DomTreeNodeBase<NodeT> *getNode(const NodeT *BB) const {
     auto I = DomTreeNodes.find(BB);
     if (I != DomTreeNodes.end())
       return I->second.get();
     return nullptr;
   }
 
   /// See getNode.
-  DomTreeNodeBase<NodeT> *operator[](NodeT *BB) const { return getNode(BB); }
+  DomTreeNodeBase<NodeT> *operator[](const NodeT *BB) const {
+    return getNode(BB);
+  }
 
   /// getRootNode - This returns the entry node for the CFG of the function.  If
   /// this tree represents the post-dominance relations for a function, however,
Index: llvm/trunk/unittests/IR/DominatorTreeTest.cpp
===================================================================
--- llvm/trunk/unittests/IR/DominatorTreeTest.cpp
+++ llvm/trunk/unittests/IR/DominatorTreeTest.cpp
@@ -776,7 +776,9 @@
   PDT.insertEdge(From, To);
   EXPECT_TRUE(PDT.verify());
   EXPECT_TRUE(PDT.getRoots().size() == 2);
-  EXPECT_NE(PDT.getNode(B.getOrAddBlock("5")), nullptr);
+  // Make sure we can use a const pointer with getNode.
+  const BasicBlock *BB5 = B.getOrAddBlock("5");
+  EXPECT_NE(PDT.getNode(BB5), nullptr);
 }
 
 TEST(DominatorTree, InsertMixed) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48231.151619.patch
Type: text/x-patch
Size: 1630 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180616/47bcf951/attachment.bin>


More information about the llvm-commits mailing list