|
@@ -34,6 +34,11 @@ namespace {
|
|
|
|
|
|
bool shouldTraversePostOrder() const { return VisitPostOrder; }
|
|
|
|
|
|
+ bool VisitUnaryOperator(UnaryOperator *Op) {
|
|
|
+ VisitedNodes.push_back(Op->getOpcodeStr(Op->getOpcode()));
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
bool VisitBinaryOperator(BinaryOperator *Op) {
|
|
|
VisitedNodes.push_back(Op->getOpcodeStr());
|
|
|
return true;
|
|
@@ -76,7 +81,7 @@ TEST(RecursiveASTVisitor, PostOrderTraversal) {
|
|
|
auto ASTUnit = tooling::buildASTFromCode(
|
|
|
"class A {"
|
|
|
" class B {"
|
|
|
- " int foo() { while(4) { int i = 9; } return (1 + 3) + 2; }"
|
|
|
+ " int foo() { while(4) { int i = 9; int j = -i; } return (1 + 3) + 2; }"
|
|
|
" };"
|
|
|
"};"
|
|
|
);
|
|
@@ -87,7 +92,7 @@ TEST(RecursiveASTVisitor, PostOrderTraversal) {
|
|
|
Visitor.TraverseTranslationUnitDecl(TU);
|
|
|
|
|
|
std::vector<std::string> expected = {
|
|
|
- "4", "9", "i", "1", "3", "+", "2", "+", "return", "A::B::foo", "A::B", "A"
|
|
|
+ "4", "9", "i", "-", "j", "1", "3", "+", "2", "+", "return", "A::B::foo", "A::B", "A"
|
|
|
};
|
|
|
// Compare the list of actually visited nodes
|
|
|
// with the expected list of visited nodes.
|