forked from qt-creator/qt-creator
CppEditor: Fix possible crash when following typdefs
It's probably also a bug that we don't resolve the identically-named struct correctly, but at least we don't crash anymore. Fixes: QTCREATORBUG-26047 Change-Id: I272e76460c87906c9df23aaf7f37953b451bf1a8 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -146,7 +146,9 @@ TypeHierarchy TypeHierarchyBuilder::buildDerivedTypeHierarchy(QFutureInterfaceBa
|
|||||||
return hierarchy;
|
return hierarchy;
|
||||||
}
|
}
|
||||||
|
|
||||||
LookupItem TypeHierarchyBuilder::followTypedef(const LookupContext &context, const Name *symbolName, Scope *enclosingScope)
|
LookupItem TypeHierarchyBuilder::followTypedef(const LookupContext &context, const Name *symbolName,
|
||||||
|
Scope *enclosingScope,
|
||||||
|
std::set<const Symbol *> typedefs)
|
||||||
{
|
{
|
||||||
QList<LookupItem> items = context.lookup(symbolName, enclosingScope);
|
QList<LookupItem> items = context.lookup(symbolName, enclosingScope);
|
||||||
|
|
||||||
@@ -159,6 +161,8 @@ LookupItem TypeHierarchyBuilder::followTypedef(const LookupContext &context, con
|
|||||||
continue;
|
continue;
|
||||||
if (!s->isClass() && !s->isTemplate() && !s->isTypedef())
|
if (!s->isClass() && !s->isTemplate() && !s->isTypedef())
|
||||||
continue;
|
continue;
|
||||||
|
if (!typedefs.insert(s).second)
|
||||||
|
continue;
|
||||||
actualBaseSymbol = s;
|
actualBaseSymbol = s;
|
||||||
matchingItem = item;
|
matchingItem = item;
|
||||||
break;
|
break;
|
||||||
@@ -173,7 +177,8 @@ LookupItem TypeHierarchyBuilder::followTypedef(const LookupContext &context, con
|
|||||||
// Anonymous aggregate such as: typedef struct {} Empty;
|
// Anonymous aggregate such as: typedef struct {} Empty;
|
||||||
return LookupItem();
|
return LookupItem();
|
||||||
}
|
}
|
||||||
return followTypedef(context, namedType->name(), actualBaseSymbol->enclosingScope());
|
return followTypedef(context, namedType->name(), actualBaseSymbol->enclosingScope(),
|
||||||
|
typedefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
return matchingItem;
|
return matchingItem;
|
||||||
|
|||||||
@@ -34,6 +34,8 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
namespace CPlusPlus {
|
namespace CPlusPlus {
|
||||||
class LookupContext;
|
class LookupContext;
|
||||||
class LookupItem;
|
class LookupItem;
|
||||||
@@ -72,7 +74,8 @@ public:
|
|||||||
const CPlusPlus::Snapshot &snapshot);
|
const CPlusPlus::Snapshot &snapshot);
|
||||||
static CPlusPlus::LookupItem followTypedef(const CPlusPlus::LookupContext &context,
|
static CPlusPlus::LookupItem followTypedef(const CPlusPlus::LookupContext &context,
|
||||||
const CPlusPlus::Name *symbolName,
|
const CPlusPlus::Name *symbolName,
|
||||||
CPlusPlus::Scope *enclosingScope);
|
CPlusPlus::Scope *enclosingScope,
|
||||||
|
std::set<const CPlusPlus::Symbol *> typedefs = {});
|
||||||
private:
|
private:
|
||||||
TypeHierarchyBuilder() = default;
|
TypeHierarchyBuilder() = default;
|
||||||
void buildDerived(QFutureInterfaceBase &futureInterface, TypeHierarchy *typeHierarchy,
|
void buildDerived(QFutureInterfaceBase &futureInterface, TypeHierarchy *typeHierarchy,
|
||||||
|
|||||||
Reference in New Issue
Block a user