diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2022-09-15 17:52:31 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2022-09-16 07:31:22 +0000 |
commit | 6abebbbe35bae3b0c7a66efdfdecf845b532594a (patch) | |
tree | 7d7bec729fcc4dc1fdc595a6e286ea386018e403 | |
parent | cc7d757a3ad3e99e672ef0c21a099666c022f621 (diff) |
CppEditor: Remove extra CPlusPlus::Class member
Amends 0fab5956ea91dc0ee40b4d99605ec26a3720c5c8.
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>
-rw-r--r-- | src/libs/3rdparty/cplusplus/Bind.cpp | 2 | ||||
-rw-r--r-- | src/libs/3rdparty/cplusplus/Symbols.cpp | 5 | ||||
-rw-r--r-- | src/libs/3rdparty/cplusplus/Symbols.h | 4 | ||||
-rw-r--r-- | src/libs/cplusplus/LookupContext.cpp | 5 | ||||
-rw-r--r-- | src/libs/cplusplus/TypePrettyPrinter.cpp | 2 |
5 files changed, 3 insertions, 15 deletions
diff --git a/src/libs/3rdparty/cplusplus/Bind.cpp b/src/libs/3rdparty/cplusplus/Bind.cpp index d0963053af9..e7d5bf78bad 100644 --- a/src/libs/3rdparty/cplusplus/Bind.cpp +++ b/src/libs/3rdparty/cplusplus/Bind.cpp @@ -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); diff --git a/src/libs/3rdparty/cplusplus/Symbols.cpp b/src/libs/3rdparty/cplusplus/Symbols.cpp index ba12ea22c2a..05b5f597937 100644 --- a/src/libs/3rdparty/cplusplus/Symbols.cpp +++ b/src/libs/3rdparty/cplusplus/Symbols.cpp @@ -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)) { diff --git a/src/libs/3rdparty/cplusplus/Symbols.h b/src/libs/3rdparty/cplusplus/Symbols.h index 5cb3aee28fa..c9267e4fdde 100644 --- a/src/libs/3rdparty/cplusplus/Symbols.h +++ b/src/libs/3rdparty/cplusplus/Symbols.h @@ -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 diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index 4b34f6f0bbc..3c12070e913 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -53,10 +53,7 @@ static void path_helper(Symbol *symbol, if (ns && ns->isInline()) return; } - if (symbol->asClass()) - addNames(symbol->asClass()->prettyName(), names); - else - addNames(symbol->name(), names); + addNames(symbol->name(), names); } else if (symbol->asObjCClass() || symbol->asObjCBaseClass() || symbol->asObjCProtocol() || symbol->asObjCForwardClassDeclaration() || symbol->asObjCForwardProtocolDeclaration() diff --git a/src/libs/cplusplus/TypePrettyPrinter.cpp b/src/libs/cplusplus/TypePrettyPrinter.cpp index 64bc192b803..41fb22c86b8 100644 --- a/src/libs/cplusplus/TypePrettyPrinter.cpp +++ b/src/libs/cplusplus/TypePrettyPrinter.cpp @@ -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); } |