Trouble with using Region::element_iterator();

Hi,

I wrote a FunctionPass that addRequired, and inside my runOnFunction(F). The pass was able to print out the region tree via RegionInfo’s builtin print function. However, when I try iterating over subregions/basicblocks myself, like this

Region *TLR = RI->getTopLevelRegion();

Region::element_iterator EI = TLR->element_begin();
Region::element_iterator EE = TLR->element_end();

for (; I != E; ++I) {
errs() << **I << " , ";
}

I got the following errors, and would like to ask for some suggestions:

In file included from /home/pvario/LLVM/llvm-3.3.src/include/llvm/Analysis/LoopInfo.h:35:0,
from structure_formation.h:8,
from structure_formation.cpp:20:
/home/pvario/LLVM/llvm-3.3.src/include/llvm/ADT/GraphTraits.h: In instantiation of ‘llvm::GraphTraitsllvm::RegionNode*’:
/home/pvario/LLVM/llvm-3.3.src/include/llvm/ADT/DepthFirstIterator.h:65:7: instantiated from ‘llvm::df_iterator<llvm::RegionNode*, llvm::SmallPtrSet<llvm::RegionNode*, 8u>, false, llvm::GraphTraitsllvm::RegionNode* >’
structure_formation.cpp:64:30: instantiated from here
/home/pvario/LLVM/llvm-3.3.src/include/llvm/ADT/GraphTraits.h:60:53: error: ‘llvm::RegionNode*’ is not a class, struct, or union type
In file included from /home/pvario/LLVM/llvm-3.3.src/include/llvm/Analysis/Dominators.h:19:0,
from /home/pvario/LLVM/llvm-3.3.src/include/llvm/Analysis/LoopInfo.h:37,
from structure_formation.h:8,
from structure_formation.cpp:20:
/home/pvario/LLVM/llvm-3.3.src/include/llvm/ADT/DepthFirstIterator.h: In instantiation of ‘llvm::df_iterator<llvm::RegionNode*, llvm::SmallPtrSet<llvm::RegionNode*, 8u>, false, llvm::GraphTraitsllvm::RegionNode* >’:
structure_formation.cpp:64:30: instantiated from here
/home/pvario/LLVM/llvm-3.3.src/include/llvm/ADT/DepthFirstIterator.h:72:42: error: no type named ‘ChildIteratorType’ in ‘struct llvm::GraphTraitsllvm::RegionNode*
make: *** [structure_formation.o] Error 1