summaryrefslogtreecommitdiff
path: root/src/shared/cplusplus/Bind.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/cplusplus/Bind.cpp')
-rw-r--r--src/shared/cplusplus/Bind.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/shared/cplusplus/Bind.cpp b/src/shared/cplusplus/Bind.cpp
index 0ca8e71ba9..a3291e400f 100644
--- a/src/shared/cplusplus/Bind.cpp
+++ b/src/shared/cplusplus/Bind.cpp
@@ -66,6 +66,8 @@
using namespace CPlusPlus;
+const int Bind::kMaxDepth(100);
+
Bind::Bind(TranslationUnit *unit)
: ASTVisitor(unit),
_scope(0),
@@ -75,7 +77,8 @@ Bind::Bind(TranslationUnit *unit)
_visibility(Symbol::Public),
_objcVisibility(Symbol::Public),
_methodKey(Function::NormalMethod),
- _skipFunctionBodies(false)
+ _skipFunctionBodies(false),
+ _depth(0)
{
}
@@ -291,6 +294,19 @@ FullySpecifiedType Bind::postfixDeclarator(PostfixDeclaratorAST *ast, const Full
return value;
}
+bool Bind::preVisit(AST *)
+{
+ ++_depth;
+ if (_depth > kMaxDepth)
+ return false;
+ return true;
+}
+
+void Bind::postVisit(AST *)
+{
+ --_depth;
+}
+
// AST
bool Bind::visit(ObjCSelectorArgumentAST *ast)
{