CppEditor: Remove extra CPlusPlus::Class member

Amends 0fab5956ea.
We want to avoid carrying these eight bytes ber Class instance around.
Instead, we now just replace the (anonymous) struct name with the
typedef'ed one.
Note that in C (but not C++), this is possible:
    struct S {};
    typedef struct {} S;
    struct S s1;
    S s2;
However, our code model has never respected the extra struct namespace,
so it can already not distinguish between occurrences of "S" and "struct
S".

Change-Id: I55feafea7d3a4a5848e10f7011f633a2ce0f626e
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2022-09-15 17:52:31 +02:00
parent cc7d757a3a
commit 6abebbbe35
5 changed files with 3 additions and 15 deletions

View File

@@ -2024,7 +2024,7 @@ bool Bind::visit(SimpleDeclarationAST *ast)
Declaration *decl = control()->newDeclaration(sourceLocation, nameAndLoc.first);
if (const Type * const t = declTy.type(); t && declTy.isTypedef() && t->asClassType()
&& t->asClassType()->name() && t->asClassType()->name()->asAnonymousNameId()) {
declTy.type()->asClassType()->setCanonicalTypedefName(decl->name());
declTy.type()->asClassType()->setName(decl->name());
}
decl->setType(declTy);
setDeclSpecifiers(decl, type);

View File

@@ -635,11 +635,6 @@ void Class::addBaseClass(BaseClass *baseClass)
FullySpecifiedType Class::type() const
{ return FullySpecifiedType(const_cast<Class *>(this)); }
const Name *Class::prettyName() const
{
return _canonicalTypedefName ? _canonicalTypedefName : name();
}
void Class::visitSymbol0(SymbolVisitor *visitor)
{
if (visitor->visit(this)) {

View File

@@ -495,9 +495,6 @@ public:
const Class *asClassType() const override { return this; }
Class *asClassType() override { return this; }
void setCanonicalTypedefName(const Name *n) { _canonicalTypedefName = n; }
const Name *prettyName() const;
protected:
void visitSymbol0(SymbolVisitor *visitor) override;
void accept0(TypeVisitor *visitor) override;
@@ -506,7 +503,6 @@ protected:
private:
Key _key;
std::vector<BaseClass *> _baseClasses;
const Name *_canonicalTypedefName = nullptr;
};
class CPLUSPLUS_EXPORT QtPropertyDeclaration final : public Symbol

View File

@@ -53,9 +53,6 @@ static void path_helper(Symbol *symbol,
if (ns && ns->isInline())
return;
}
if (symbol->asClass())
addNames(symbol->asClass()->prettyName(), names);
else
addNames(symbol->name(), names);
} else if (symbol->asObjCClass() || symbol->asObjCBaseClass() || symbol->asObjCProtocol()

View File

@@ -166,7 +166,7 @@ void TypePrettyPrinter::visit(Template *type)
void TypePrettyPrinter::visit(Class *classTy)
{
_text.prepend(overview()->prettyName(classTy->prettyName()));
_text.prepend(overview()->prettyName(classTy->name()));
prependCv(_fullySpecifiedType);
}