aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/cplusplus
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2022-09-14 16:16:09 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2022-09-15 15:08:20 +0000
commit0fab5956ea91dc0ee40b4d99605ec26a3720c5c8 (patch)
treeed9d8255baa8553d4d39a7685af3cc81746f802f /src/libs/3rdparty/cplusplus
parent2369dcc3242ce11e4e06bc6b1b3350ada5b785d6 (diff)
CppEditor: Store typedefed name for anonymous structs
... and use it as the struct display name in some places. Fixes: QTCREATORBUG-26611 Change-Id: I1b127f5705307a0fabd2441ff871162c882927a5 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/libs/3rdparty/cplusplus')
-rw-r--r--src/libs/3rdparty/cplusplus/Bind.cpp4
-rw-r--r--src/libs/3rdparty/cplusplus/Symbols.cpp5
-rw-r--r--src/libs/3rdparty/cplusplus/Symbols.h4
3 files changed, 13 insertions, 0 deletions
diff --git a/src/libs/3rdparty/cplusplus/Bind.cpp b/src/libs/3rdparty/cplusplus/Bind.cpp
index 64af5b893a..d0963053af 100644
--- a/src/libs/3rdparty/cplusplus/Bind.cpp
+++ b/src/libs/3rdparty/cplusplus/Bind.cpp
@@ -2022,6 +2022,10 @@ bool Bind::visit(SimpleDeclarationAST *ast)
for (const auto &nameAndLoc : qAsConst(namesAndLocations)) {
const int sourceLocation = nameAndLoc.second;
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());
+ }
decl->setType(declTy);
setDeclSpecifiers(decl, type);
diff --git a/src/libs/3rdparty/cplusplus/Symbols.cpp b/src/libs/3rdparty/cplusplus/Symbols.cpp
index 05b5f59793..ba12ea22c2 100644
--- a/src/libs/3rdparty/cplusplus/Symbols.cpp
+++ b/src/libs/3rdparty/cplusplus/Symbols.cpp
@@ -635,6 +635,11 @@ 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 c9267e4fdd..5cb3aee28f 100644
--- a/src/libs/3rdparty/cplusplus/Symbols.h
+++ b/src/libs/3rdparty/cplusplus/Symbols.h
@@ -495,6 +495,9 @@ 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;
@@ -503,6 +506,7 @@ protected:
private:
Key _key;
std::vector<BaseClass *> _baseClasses;
+ const Name *_canonicalTypedefName = nullptr;
};
class CPLUSPLUS_EXPORT QtPropertyDeclaration final : public Symbol