forked from qt-creator/qt-creator
C++: Fix crash on auto deduction with debug enabled
By adding the expression document to the bindings object. Since ResolveExpression is always initialized with the context of a TypeOfExpression object, the symbols and names in the expression document will at least live as long as the most outer TypeOfExpression object. Done-with: Orgad Shaneh <orgads@gmail.com> Task-number: QTCREATORBUG-14253 Change-Id: Ia97c7401a2ada9a36113a04cf39e2283393421dd Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
8ae18a9ca8
commit
f27aa09ac5
@@ -611,32 +611,14 @@ bool ResolveExpression::visit(SimpleNameAST *ast)
|
||||
Document::Ptr exprDoc =
|
||||
documentForExpression(exprTyper.preprocessedExpression(initializer));
|
||||
exprDoc->check();
|
||||
_context.bindings()->addExpressionDocument(exprDoc);
|
||||
|
||||
DeduceAutoCheck deduceAuto(ast->name->identifier(), exprDoc->translationUnit());
|
||||
if (deduceAuto._block)
|
||||
continue;
|
||||
|
||||
const QList<LookupItem> &typeItems = exprTyper(extractExpressionAST(exprDoc), exprDoc,
|
||||
decl->enclosingScope());
|
||||
if (typeItems.empty())
|
||||
continue;
|
||||
|
||||
Clone cloner(_context.bindings()->control().data());
|
||||
|
||||
for (int n = 0; n < typeItems.size(); ++ n) {
|
||||
FullySpecifiedType newType = cloner.type(typeItems[n].type(), 0);
|
||||
if (n == 0) {
|
||||
item.setType(newType);
|
||||
item.setScope(typeItems[n].scope());
|
||||
item.setBinding(typeItems[n].binding());
|
||||
} else {
|
||||
LookupItem newItem(item);
|
||||
newItem.setType(newType);
|
||||
newItem.setScope(typeItems[n].scope());
|
||||
newItem.setBinding(typeItems[n].binding());
|
||||
newCandidates.push_back(newItem);
|
||||
}
|
||||
}
|
||||
newCandidates += exprTyper(extractExpressionAST(exprDoc), exprDoc,
|
||||
decl->enclosingScope());
|
||||
} else {
|
||||
item.setType(item.declaration()->type());
|
||||
item.setScope(item.declaration()->enclosingScope());
|
||||
|
||||
Reference in New Issue
Block a user