forked from qt-creator/qt-creator
Fix C++ model crash when evaluating deep expressions
Task-number: QTCREATORBUG-3831 Done-with: Roberto Raggi
This commit is contained in:
@@ -66,6 +66,8 @@
|
|||||||
|
|
||||||
using namespace CPlusPlus;
|
using namespace CPlusPlus;
|
||||||
|
|
||||||
|
const int Bind::kMaxDepth(100);
|
||||||
|
|
||||||
Bind::Bind(TranslationUnit *unit)
|
Bind::Bind(TranslationUnit *unit)
|
||||||
: ASTVisitor(unit),
|
: ASTVisitor(unit),
|
||||||
_scope(0),
|
_scope(0),
|
||||||
@@ -75,7 +77,8 @@ Bind::Bind(TranslationUnit *unit)
|
|||||||
_visibility(Symbol::Public),
|
_visibility(Symbol::Public),
|
||||||
_objcVisibility(Symbol::Public),
|
_objcVisibility(Symbol::Public),
|
||||||
_methodKey(Function::NormalMethod),
|
_methodKey(Function::NormalMethod),
|
||||||
_skipFunctionBodies(false)
|
_skipFunctionBodies(false),
|
||||||
|
_depth(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,6 +294,19 @@ FullySpecifiedType Bind::postfixDeclarator(PostfixDeclaratorAST *ast, const Full
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Bind::preVisit(AST *)
|
||||||
|
{
|
||||||
|
++_depth;
|
||||||
|
if (_depth > kMaxDepth)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bind::postVisit(AST *)
|
||||||
|
{
|
||||||
|
--_depth;
|
||||||
|
}
|
||||||
|
|
||||||
// AST
|
// AST
|
||||||
bool Bind::visit(ObjCSelectorArgumentAST *ast)
|
bool Bind::visit(ObjCSelectorArgumentAST *ast)
|
||||||
{
|
{
|
||||||
|
@@ -138,6 +138,9 @@ protected:
|
|||||||
void lambdaDeclarator(LambdaDeclaratorAST *ast);
|
void lambdaDeclarator(LambdaDeclaratorAST *ast);
|
||||||
FullySpecifiedType trailingReturnType(TrailingReturnTypeAST *ast, const FullySpecifiedType &init);
|
FullySpecifiedType trailingReturnType(TrailingReturnTypeAST *ast, const FullySpecifiedType &init);
|
||||||
|
|
||||||
|
virtual bool preVisit(AST *);
|
||||||
|
virtual void postVisit(AST *);
|
||||||
|
|
||||||
// AST
|
// AST
|
||||||
virtual bool visit(ObjCSelectorArgumentAST *ast);
|
virtual bool visit(ObjCSelectorArgumentAST *ast);
|
||||||
virtual bool visit(AttributeAST *ast);
|
virtual bool visit(AttributeAST *ast);
|
||||||
@@ -297,6 +300,8 @@ protected:
|
|||||||
virtual bool visit(ArrayDeclaratorAST *ast);
|
virtual bool visit(ArrayDeclaratorAST *ast);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static const int kMaxDepth;
|
||||||
|
|
||||||
Scope *_scope;
|
Scope *_scope;
|
||||||
ExpressionTy _expression;
|
ExpressionTy _expression;
|
||||||
const Name *_name;
|
const Name *_name;
|
||||||
@@ -306,6 +311,7 @@ private:
|
|||||||
int _objcVisibility;
|
int _objcVisibility;
|
||||||
int _methodKey;
|
int _methodKey;
|
||||||
bool _skipFunctionBodies;
|
bool _skipFunctionBodies;
|
||||||
|
int _depth;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CPlusPlus
|
} // namespace CPlusPlus
|
||||||
|
Reference in New Issue
Block a user