C++: Fix crash when accessing an empty list in Rewrite

Task-number: QTCREATORBUG-14163
Change-Id: I57eca70466bbf5d28d16afafc07ab243206fcff5
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Lorenz Haas
2015-03-21 20:10:12 +01:00
parent c097867f3c
commit da67c7c6c9

View File

@@ -63,8 +63,10 @@ public:
{
TypeVisitor::accept(ty.type());
unsigned flags = ty.flags();
flags |= temps.back().flags();
temps.back().setFlags(flags);
if (!temps.isEmpty()) {
flags |= temps.back().flags();
temps.back().setFlags(flags);
}
}
public:
@@ -73,7 +75,7 @@ public:
FullySpecifiedType operator()(const FullySpecifiedType &ty)
{
accept(ty);
return temps.takeLast();
return (!temps.isEmpty()) ? temps.takeLast() : ty;
}
virtual void visit(UndefinedType *)
@@ -241,7 +243,7 @@ public:
return 0;
accept(name);
return temps.takeLast();
return (!temps.isEmpty()) ? temps.takeLast() : name;
}
virtual void visit(const QualifiedNameId *name)