From e2bb204d4df47636549f2877c243e8c891cd71f3 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 24 Jun 2022 16:45:12 +0200 Subject: [PATCH] CPlusPlus: Inline more simple Type related functions Change-Id: I2103e8047b385b438e58072e8a2689f1889d2724 Reviewed-by: Christian Kandeler --- src/libs/3rdparty/cplusplus/Bind.cpp | 6 +- src/libs/3rdparty/cplusplus/CoreTypes.cpp | 60 +-------- src/libs/3rdparty/cplusplus/CoreTypes.h | 123 +++++++----------- .../3rdparty/cplusplus/FullySpecifiedType.cpp | 123 ------------------ .../3rdparty/cplusplus/FullySpecifiedType.h | 82 ++++++------ src/libs/3rdparty/cplusplus/Symbols.cpp | 14 +- src/libs/3rdparty/cplusplus/Type.cpp | 64 +-------- src/libs/3rdparty/cplusplus/Type.h | 21 +-- src/libs/cplusplus/CppRewriter.cpp | 2 +- src/libs/cplusplus/FindUsages.cpp | 4 +- src/libs/cplusplus/Icons.cpp | 2 +- src/libs/cplusplus/LookupContext.cpp | 8 +- src/libs/cplusplus/ResolveExpression.cpp | 12 +- src/libs/cplusplus/TypePrettyPrinter.cpp | 12 +- src/libs/qmljs/qmljsfindexportedcpptypes.cpp | 2 +- src/plugins/cppeditor/cppchecksymbols.cpp | 6 +- src/plugins/cppeditor/cppcompletionassist.cpp | 6 +- src/plugins/cppeditor/cppelementevaluator.cpp | 10 +- .../cppeditor/cppfollowsymbolundercursor.cpp | 16 +-- .../cppeditor/cppfunctiondecldeflink.cpp | 2 +- src/plugins/cppeditor/cppquickfixes.cpp | 30 ++--- src/plugins/cppeditor/doxygengenerator.cpp | 2 +- src/plugins/cppeditor/symbolfinder.cpp | 4 +- .../cplusplus/findusages/tst_findusages.cpp | 2 +- tests/auto/cplusplus/lookup/tst_lookup.cpp | 4 +- .../auto/cplusplus/semantic/tst_semantic.cpp | 32 ++--- 26 files changed, 180 insertions(+), 469 deletions(-) diff --git a/src/libs/3rdparty/cplusplus/Bind.cpp b/src/libs/3rdparty/cplusplus/Bind.cpp index 2a911fb0da2..89ea4418423 100644 --- a/src/libs/3rdparty/cplusplus/Bind.cpp +++ b/src/libs/3rdparty/cplusplus/Bind.cpp @@ -371,7 +371,7 @@ FullySpecifiedType Bind::declarator(DeclaratorAST *ast, const FullySpecifiedType if (type.isAuto()) isAuto = true; } - if (!type->isFunctionType()) { + if (!type->asFunctionType()) { ExpressionTy initializer = this->expression(ast->initializer); if (cxx11Enabled && isAuto) { type = initializer; @@ -3249,7 +3249,7 @@ bool Bind::visit(PointerToMemberAST *ast) bool Bind::visit(PointerAST *ast) { - if (_type->isReferenceType()) + if (_type->asReferenceType()) translationUnit()->error(ast->firstToken(), "cannot declare pointer to a reference"); FullySpecifiedType type(control()->pointerType(_type)); @@ -3264,7 +3264,7 @@ bool Bind::visit(ReferenceAST *ast) { const bool rvalueRef = (tokenKind(ast->reference_token) == T_AMPER_AMPER); - if (_type->isReferenceType()) + if (_type->asReferenceType()) translationUnit()->error(ast->firstToken(), "cannot declare reference to a reference"); FullySpecifiedType type(control()->referenceType(_type, rvalueRef)); diff --git a/src/libs/3rdparty/cplusplus/CoreTypes.cpp b/src/libs/3rdparty/cplusplus/CoreTypes.cpp index 4519eabc036..a9b1d88ad81 100644 --- a/src/libs/3rdparty/cplusplus/CoreTypes.cpp +++ b/src/libs/3rdparty/cplusplus/CoreTypes.cpp @@ -21,6 +21,7 @@ #include "CoreTypes.h" #include "TypeVisitor.h" #include "Matcher.h" + #include namespace CPlusPlus { @@ -54,14 +55,6 @@ PointerToMemberType::PointerToMemberType(const Name *memberName, const FullySpec _elementType(elementType) { } -PointerToMemberType::~PointerToMemberType() -{ } - -const Name *PointerToMemberType::memberName() const -{ return _memberName; } - -FullySpecifiedType PointerToMemberType::elementType() const -{ return _elementType; } void PointerToMemberType::accept0(TypeVisitor *visitor) { visitor->visit(this); } @@ -74,12 +67,6 @@ bool PointerToMemberType::match0(const Type *otherType, Matcher *matcher) const return false; } -PointerType::PointerType(const FullySpecifiedType &elementType) - : _elementType(elementType) -{ } - -PointerType::~PointerType() -{ } void PointerType::accept0(TypeVisitor *visitor) { visitor->visit(this); } @@ -92,16 +79,11 @@ bool PointerType::match0(const Type *otherType, Matcher *matcher) const return false; } -FullySpecifiedType PointerType::elementType() const -{ return _elementType; } ReferenceType::ReferenceType(const FullySpecifiedType &elementType, bool rvalueRef) : _elementType(elementType), _rvalueReference(rvalueRef) { } -ReferenceType::~ReferenceType() -{ } - void ReferenceType::accept0(TypeVisitor *visitor) { visitor->visit(this); } @@ -113,19 +95,6 @@ bool ReferenceType::match0(const Type *otherType, Matcher *matcher) const return false; } -FullySpecifiedType ReferenceType::elementType() const -{ return _elementType; } - -bool ReferenceType::isRvalueReference() const -{ return _rvalueReference; } - -IntegerType::IntegerType(int kind) - : _kind(kind) -{ } - -IntegerType::~IntegerType() -{ } - void IntegerType::accept0(TypeVisitor *visitor) { visitor->visit(this); } @@ -137,15 +106,6 @@ bool IntegerType::match0(const Type *otherType, Matcher *matcher) const return false; } -int IntegerType::kind() const -{ return _kind; } - -FloatType::FloatType(int kind) - : _kind(kind) -{ } - -FloatType::~FloatType() -{ } void FloatType::accept0(TypeVisitor *visitor) { visitor->visit(this); } @@ -158,16 +118,11 @@ bool FloatType::match0(const Type *otherType, Matcher *matcher) const return false; } -int FloatType::kind() const -{ return _kind; } ArrayType::ArrayType(const FullySpecifiedType &elementType, unsigned size) : _elementType(elementType), _size(size) { } -ArrayType::~ArrayType() -{ } - void ArrayType::accept0(TypeVisitor *visitor) { visitor->visit(this); } @@ -179,21 +134,8 @@ bool ArrayType::match0(const Type *otherType, Matcher *matcher) const return false; } -FullySpecifiedType ArrayType::elementType() const -{ return _elementType; } -unsigned ArrayType::size() const -{ return _size; } -NamedType::NamedType(const Name *name) - : _name(name) -{ } - -NamedType::~NamedType() -{ } - -const Name *NamedType::name() const -{ return _name; } void NamedType::accept0(TypeVisitor *visitor) { visitor->visit(this); } diff --git a/src/libs/3rdparty/cplusplus/CoreTypes.h b/src/libs/3rdparty/cplusplus/CoreTypes.h index 5f2c30e89c6..7ccd861bb9e 100644 --- a/src/libs/3rdparty/cplusplus/CoreTypes.h +++ b/src/libs/3rdparty/cplusplus/CoreTypes.h @@ -26,37 +26,31 @@ namespace CPlusPlus { -class CPLUSPLUS_EXPORT UndefinedType : public Type +class CPLUSPLUS_EXPORT UndefinedType final : public Type { public: static UndefinedType instance; - const UndefinedType *asUndefinedType() const override - { return this; } - - UndefinedType *asUndefinedType() override - { return this; } + const UndefinedType *asUndefinedType() const override { return this; } + UndefinedType *asUndefinedType() override { return this; } protected: void accept0(TypeVisitor *visitor) override; bool match0(const Type *otherType, Matcher *matcher) const override; }; -class CPLUSPLUS_EXPORT VoidType: public Type +class CPLUSPLUS_EXPORT VoidType final : public Type { public: - const VoidType *asVoidType() const override - { return this; } - - VoidType *asVoidType() override - { return this; } + const VoidType *asVoidType() const override { return this; } + VoidType *asVoidType() override { return this; } protected: void accept0(TypeVisitor *visitor) override; bool match0(const Type *otherType, Matcher *matcher) const override; }; -class CPLUSPLUS_EXPORT IntegerType: public Type +class CPLUSPLUS_EXPORT IntegerType final : public Type { public: enum Kind { @@ -72,16 +66,13 @@ public: }; public: - IntegerType(int kind); - virtual ~IntegerType(); + IntegerType(int kind) : _kind(kind) {} + ~IntegerType() override = default; - int kind() const; + int kind() const { return _kind; } - IntegerType *asIntegerType() override - { return this; } - - const IntegerType *asIntegerType() const override - { return this; } + IntegerType *asIntegerType() override { return this; } + const IntegerType *asIntegerType() const override { return this; } protected: void accept0(TypeVisitor *visitor) override; @@ -91,7 +82,7 @@ private: int _kind; }; -class CPLUSPLUS_EXPORT FloatType: public Type +class CPLUSPLUS_EXPORT FloatType final : public Type { public: enum Kind { @@ -101,16 +92,13 @@ public: }; public: - FloatType(int kind); - virtual ~FloatType(); + FloatType(int kind) : _kind(kind) {} + ~FloatType() override = default; - int kind() const; + int kind() const { return _kind; } - const FloatType *asFloatType() const override - { return this; } - - FloatType *asFloatType() override - { return this; } + const FloatType *asFloatType() const override { return this; } + FloatType *asFloatType() override { return this; } protected: void accept0(TypeVisitor *visitor) override; @@ -120,19 +108,16 @@ private: int _kind; }; -class CPLUSPLUS_EXPORT PointerType: public Type +class CPLUSPLUS_EXPORT PointerType final : public Type { public: - PointerType(const FullySpecifiedType &elementType); - virtual ~PointerType(); + PointerType(const FullySpecifiedType &elementType) : _elementType(elementType) {} + ~PointerType() override = default; - FullySpecifiedType elementType() const; + FullySpecifiedType elementType() const { return _elementType; } - const PointerType *asPointerType() const override - { return this; } - - PointerType *asPointerType() override - { return this; } + const PointerType *asPointerType() const override { return this; } + PointerType *asPointerType() override { return this; } protected: void accept0(TypeVisitor *visitor) override; @@ -142,20 +127,17 @@ private: FullySpecifiedType _elementType; }; -class CPLUSPLUS_EXPORT PointerToMemberType: public Type +class CPLUSPLUS_EXPORT PointerToMemberType final : public Type { public: PointerToMemberType(const Name *memberName, const FullySpecifiedType &elementType); - virtual ~PointerToMemberType(); + ~PointerToMemberType() override = default; - const Name *memberName() const; - FullySpecifiedType elementType() const; + const Name *memberName() const { return _memberName; } + FullySpecifiedType elementType() const { return _elementType; } - const PointerToMemberType *asPointerToMemberType() const override - { return this; } - - PointerToMemberType *asPointerToMemberType() override - { return this; } + const PointerToMemberType *asPointerToMemberType() const override { return this; } + PointerToMemberType *asPointerToMemberType() override { return this; } protected: void accept0(TypeVisitor *visitor) override; @@ -166,20 +148,17 @@ private: FullySpecifiedType _elementType; }; -class CPLUSPLUS_EXPORT ReferenceType: public Type +class CPLUSPLUS_EXPORT ReferenceType final : public Type { public: ReferenceType(const FullySpecifiedType &elementType, bool rvalueRef); - virtual ~ReferenceType(); + ~ReferenceType() override = default; - FullySpecifiedType elementType() const; - bool isRvalueReference() const; + FullySpecifiedType elementType() const { return _elementType; } + bool isRvalueReference() const { return _rvalueReference; } - const ReferenceType *asReferenceType() const override - { return this; } - - ReferenceType *asReferenceType() override - { return this; } + const ReferenceType *asReferenceType() const override { return this; } + ReferenceType *asReferenceType() override { return this; } protected: void accept0(TypeVisitor *visitor) override; @@ -190,20 +169,17 @@ private: bool _rvalueReference; }; -class CPLUSPLUS_EXPORT ArrayType: public Type +class CPLUSPLUS_EXPORT ArrayType final : public Type { public: ArrayType(const FullySpecifiedType &elementType, unsigned size); - virtual ~ArrayType(); + ~ArrayType() override = default; - FullySpecifiedType elementType() const; - unsigned size() const; + FullySpecifiedType elementType() const { return _elementType; } + unsigned size() const { return _size; } - const ArrayType *asArrayType() const override - { return this; } - - ArrayType *asArrayType() override - { return this; } + const ArrayType *asArrayType() const override { return this; } + ArrayType *asArrayType() override { return this; } protected: void accept0(TypeVisitor *visitor) override; @@ -214,19 +190,16 @@ private: unsigned _size; }; -class CPLUSPLUS_EXPORT NamedType: public Type +class CPLUSPLUS_EXPORT NamedType final : public Type { public: - NamedType(const Name *name); - virtual ~NamedType(); + NamedType(const Name *name) : _name(name) {} + ~NamedType() override = default; - const Name *name() const; + const Name *name() const { return _name; } - const NamedType *asNamedType() const override - { return this; } - - NamedType *asNamedType() override - { return this; } + const NamedType *asNamedType() const override { return this; } + NamedType *asNamedType() override { return this; } protected: void accept0(TypeVisitor *visitor) override; diff --git a/src/libs/3rdparty/cplusplus/FullySpecifiedType.cpp b/src/libs/3rdparty/cplusplus/FullySpecifiedType.cpp index 27be623821b..2bc96c17785 100644 --- a/src/libs/3rdparty/cplusplus/FullySpecifiedType.cpp +++ b/src/libs/3rdparty/cplusplus/FullySpecifiedType.cpp @@ -62,135 +62,12 @@ FullySpecifiedType FullySpecifiedType::qualifiedType() const return ty; } -bool FullySpecifiedType::isConst() const -{ return f._isConst; } - -void FullySpecifiedType::setConst(bool isConst) -{ f._isConst = isConst; } - -bool FullySpecifiedType::isVolatile() const -{ return f._isVolatile; } - -void FullySpecifiedType::setVolatile(bool isVolatile) -{ f._isVolatile = isVolatile; } - -bool FullySpecifiedType::isSigned() const -{ return f._isSigned; } - -void FullySpecifiedType::setSigned(bool isSigned) -{ f._isSigned = isSigned; } - -bool FullySpecifiedType::isUnsigned() const -{ return f._isUnsigned; } - -void FullySpecifiedType::setUnsigned(bool isUnsigned) -{ f._isUnsigned = isUnsigned; } - -bool FullySpecifiedType::isFriend() const -{ return f._isFriend; } - -void FullySpecifiedType::setFriend(bool isFriend) -{ f._isFriend = isFriend; } - -bool FullySpecifiedType::isAuto() const -{ return f._isAuto; } - -void FullySpecifiedType::setAuto(bool isAuto) -{ f._isAuto = isAuto; } - -bool FullySpecifiedType::isRegister() const -{ return f._isRegister; } - -void FullySpecifiedType::setRegister(bool isRegister) -{ f._isRegister = isRegister; } - -bool FullySpecifiedType::isStatic() const -{ return f._isStatic; } - -void FullySpecifiedType::setStatic(bool isStatic) -{ f._isStatic = isStatic; } - -bool FullySpecifiedType::isExtern() const -{ return f._isExtern; } - -void FullySpecifiedType::setExtern(bool isExtern) -{ f._isExtern = isExtern; } - -bool FullySpecifiedType::isMutable() const -{ return f._isMutable; } - -void FullySpecifiedType::setMutable(bool isMutable) -{ f._isMutable = isMutable; } - -bool FullySpecifiedType::isTypedef() const -{ return f._isTypedef; } - -void FullySpecifiedType::setTypedef(bool isTypedef) -{ f._isTypedef = isTypedef; } - -bool FullySpecifiedType::isInline() const -{ return f._isInline; } - -void FullySpecifiedType::setInline(bool isInline) -{ f._isInline = isInline; } - -bool FullySpecifiedType::isVirtual() const -{ return f._isVirtual; } - -void FullySpecifiedType::setVirtual(bool isVirtual) -{ f._isVirtual = isVirtual; } - -bool FullySpecifiedType::isOverride() const -{ return f._isOverride; } - -void FullySpecifiedType::setOverride(bool isOverride) -{ f._isOverride = isOverride; } - -bool FullySpecifiedType::isFinal() const -{ return f._isFinal; } - -void FullySpecifiedType::setFinal(bool isFinal) -{ f._isFinal = isFinal; } - -bool FullySpecifiedType::isExplicit() const -{ return f._isExplicit; } - -void FullySpecifiedType::setExplicit(bool isExplicit) -{ f._isExplicit = isExplicit; } - -bool FullySpecifiedType::isDeprecated() const -{ return f._isDeprecated; } - -void FullySpecifiedType::setDeprecated(bool isDeprecated) -{ f._isDeprecated = isDeprecated; } - -bool FullySpecifiedType::isUnavailable() const -{ return f._isUnavailable; } - -void FullySpecifiedType::setUnavailable(bool isUnavailable) -{ f._isUnavailable = isUnavailable; } - -Type &FullySpecifiedType::operator*() -{ return *_type; } - FullySpecifiedType::operator bool() const { return _type != &UndefinedType::instance; } -const Type &FullySpecifiedType::operator*() const -{ return *_type; } - -Type *FullySpecifiedType::operator->() -{ return _type; } - -const Type *FullySpecifiedType::operator->() const -{ return _type; } - bool FullySpecifiedType::operator == (const FullySpecifiedType &other) const { return _type == other._type && _flags == other._flags; } -bool FullySpecifiedType::operator != (const FullySpecifiedType &other) const -{ return ! operator ==(other); } - bool FullySpecifiedType::operator < (const FullySpecifiedType &other) const { if (_type == other._type) diff --git a/src/libs/3rdparty/cplusplus/FullySpecifiedType.h b/src/libs/3rdparty/cplusplus/FullySpecifiedType.h index 03f82b788ea..1e8146ef340 100644 --- a/src/libs/3rdparty/cplusplus/FullySpecifiedType.h +++ b/src/libs/3rdparty/cplusplus/FullySpecifiedType.h @@ -40,68 +40,68 @@ public: FullySpecifiedType qualifiedType() const; - bool isConst() const; - void setConst(bool isConst); + bool isConst() const { return f._isConst; } + void setConst(bool isConst) { f._isConst = isConst; } - bool isVolatile() const; - void setVolatile(bool isVolatile); + bool isVolatile() const { return f._isVolatile; } + void setVolatile(bool isVolatile) { f._isVolatile = isVolatile; } - bool isSigned() const; - void setSigned(bool isSigned); + bool isSigned() const { return f._isSigned; } + void setSigned(bool isSigned) { f._isSigned = isSigned; } - bool isUnsigned() const; - void setUnsigned(bool isUnsigned); + bool isUnsigned() const { return f._isUnsigned; } + void setUnsigned(bool isUnsigned) { f._isUnsigned = isUnsigned; } - bool isFriend() const; - void setFriend(bool isFriend); + bool isFriend() const { return f._isFriend; } + void setFriend(bool isFriend) { f._isFriend = isFriend; } - bool isAuto() const; - void setAuto(bool isAuto); + bool isAuto() const { return f._isAuto; } + void setAuto(bool isAuto) { f._isAuto = isAuto; } - bool isRegister() const; - void setRegister(bool isRegister); + bool isRegister() const { return f._isRegister; } + void setRegister(bool isRegister) { f._isRegister = isRegister; } - bool isStatic() const; - void setStatic(bool isStatic); + bool isStatic() const { return f._isStatic; } + void setStatic(bool isStatic) { f._isStatic = isStatic; } - bool isExtern() const; - void setExtern(bool isExtern); + bool isExtern() const { return f._isExtern; } + void setExtern(bool isExtern) { f._isExtern = isExtern; } - bool isMutable() const; - void setMutable(bool isMutable); + bool isMutable() const { return f._isMutable; } + void setMutable(bool isMutable) { f._isMutable = isMutable; } - bool isTypedef() const; - void setTypedef(bool isTypedef); + bool isTypedef() const { return f._isTypedef; } + void setTypedef(bool isTypedef) { f._isTypedef = isTypedef; } - bool isInline() const; - void setInline(bool isInline); + bool isInline() const { return f._isInline; } + void setInline(bool isInline) { f._isInline = isInline; } - bool isVirtual() const; - void setVirtual(bool isVirtual); + bool isVirtual() const { return f._isVirtual; } + void setVirtual(bool isVirtual) { f._isVirtual = isVirtual; } - bool isOverride() const; - void setOverride(bool isOverride); + bool isOverride() const { return f._isOverride; } + void setOverride(bool isOverride) { f._isOverride = isOverride; } - bool isFinal() const; - void setFinal(bool isFinal); + bool isFinal() const { return f._isFinal; } + void setFinal(bool isFinal) { f._isFinal = isFinal; } - bool isExplicit() const; - void setExplicit(bool isExplicit); + bool isExplicit() const { return f._isExplicit; } + void setExplicit(bool isExplicit) { f._isExplicit = isExplicit; } - bool isDeprecated() const; - void setDeprecated(bool isDeprecated); + bool isDeprecated() const { return f._isDeprecated; } + void setDeprecated(bool isDeprecated) { f._isDeprecated = isDeprecated; } - bool isUnavailable() const; - void setUnavailable(bool isUnavailable); + bool isUnavailable() const { return f._isUnavailable; } + void setUnavailable(bool isUnavailable) { f._isUnavailable = isUnavailable; } - Type &operator*(); - const Type &operator*() const; + Type &operator*() { return *_type; } + const Type &operator*() const { return *_type; } - Type *operator->(); - const Type *operator->() const; + Type *operator->() { return _type; } + const Type *operator->() const { return _type; } bool operator == (const FullySpecifiedType &other) const; - bool operator != (const FullySpecifiedType &other) const; + bool operator != (const FullySpecifiedType &other) const { return ! operator ==(other); } bool operator < (const FullySpecifiedType &other) const; size_t hash() const; diff --git a/src/libs/3rdparty/cplusplus/Symbols.cpp b/src/libs/3rdparty/cplusplus/Symbols.cpp index 19cb80ee58c..05b5f597937 100644 --- a/src/libs/3rdparty/cplusplus/Symbols.cpp +++ b/src/libs/3rdparty/cplusplus/Symbols.cpp @@ -283,10 +283,10 @@ bool Function::isSignatureEqualTo(const Function *other, Matcher *matcher) const Symbol *l = argumentAt(i); Symbol *r = other->argumentAt(i); if (! l->type().match(r->type(), matcher)) { - if (!l->type()->isReferenceType() && !l->type()->isPointerType() - && !l->type()->isPointerToMemberType() - && !r->type()->isReferenceType() && !r->type()->isPointerType() - && !r->type()->isPointerToMemberType()) { + if (!l->type()->asReferenceType() && !l->type()->asPointerType() + && !l->type()->asPointerToMemberType() + && !r->type()->asReferenceType() && !r->type()->asPointerType() + && !r->type()->asPointerToMemberType()) { FullySpecifiedType lType = l->type(); FullySpecifiedType rType = r->type(); lType.setConst(false); @@ -333,7 +333,7 @@ bool Function::hasReturnType() const int Function::argumentCount() const { const int memCnt = memberCount(); - if (memCnt > 0 && memberAt(0)->type()->isVoidType()) + if (memCnt > 0 && memberAt(0)->type()->asVoidType()) return 0; // Definitions with function-try-blocks will have more than a block, and @@ -362,7 +362,7 @@ Symbol *Function::argumentAt(int index) const bool Function::hasArguments() const { int argc = argumentCount(); - return ! (argc == 0 || (argc == 1 && argumentAt(0)->type()->isVoidType())); + return ! (argc == 0 || (argc == 1 && argumentAt(0)->type()->asVoidType())); } int Function::minimumArgumentCount() const @@ -904,7 +904,7 @@ Symbol *ObjCMethod::argumentAt(int index) const bool ObjCMethod::hasArguments() const { return ! (argumentCount() == 0 || - (argumentCount() == 1 && argumentAt(0)->type()->isVoidType())); + (argumentCount() == 1 && argumentAt(0)->type()->asVoidType())); } void ObjCMethod::visitSymbol0(SymbolVisitor *visitor) diff --git a/src/libs/3rdparty/cplusplus/Type.cpp b/src/libs/3rdparty/cplusplus/Type.cpp index 00e84b0a61c..05d8d56d2d4 100644 --- a/src/libs/3rdparty/cplusplus/Type.cpp +++ b/src/libs/3rdparty/cplusplus/Type.cpp @@ -22,76 +22,14 @@ #include "Type.h" #include "TypeVisitor.h" #include "CoreTypes.h" -#include "Symbols.h" using namespace CPlusPlus; -Type::Type() -{ } - -Type::~Type() -{ } +Type::~Type() = default; bool Type::isUndefinedType() const { return this == &UndefinedType::instance; } -bool Type::isVoidType() const -{ return asVoidType() != nullptr; } - -bool Type::isIntegerType() const -{ return asIntegerType() != nullptr; } - -bool Type::isFloatType() const -{ return asFloatType() != nullptr; } - -bool Type::isPointerType() const -{ return asPointerType() != nullptr; } - -bool Type::isPointerToMemberType() const -{ return asPointerToMemberType() != nullptr; } - -bool Type::isReferenceType() const -{ return asReferenceType() != nullptr; } - -bool Type::isArrayType() const -{ return asArrayType() != nullptr; } - -bool Type::isNamedType() const -{ return asNamedType() != nullptr; } - -bool Type::isFunctionType() const -{ return asFunctionType() != nullptr; } - -bool Type::isNamespaceType() const -{ return asNamespaceType() != nullptr; } - -bool Type::isTemplateType() const -{ return asTemplateType() != nullptr; } - -bool Type::isClassType() const -{ return asClassType() != nullptr; } - -bool Type::isEnumType() const -{ return asEnumType() != nullptr; } - -bool Type::isForwardClassDeclarationType() const -{ return asForwardClassDeclarationType() != nullptr; } - -bool Type::isObjCClassType() const -{ return asObjCClassType() != nullptr; } - -bool Type::isObjCProtocolType() const -{ return asObjCProtocolType() != nullptr; } - -bool Type::isObjCMethodType() const -{ return asObjCMethodType() != nullptr; } - -bool Type::isObjCForwardClassDeclarationType() const -{ return asObjCForwardClassDeclarationType() != nullptr; } - -bool Type::isObjCForwardProtocolDeclarationType() const -{ return asObjCForwardProtocolDeclarationType() != nullptr; } - void Type::accept(TypeVisitor *visitor) { if (visitor->preVisit(this)) diff --git a/src/libs/3rdparty/cplusplus/Type.h b/src/libs/3rdparty/cplusplus/Type.h index 72116daf376..44438ecef95 100644 --- a/src/libs/3rdparty/cplusplus/Type.h +++ b/src/libs/3rdparty/cplusplus/Type.h @@ -27,29 +27,10 @@ namespace CPlusPlus { class CPLUSPLUS_EXPORT Type { public: - Type(); + Type() = default; virtual ~Type(); bool isUndefinedType() const; - bool isVoidType() const; - bool isIntegerType() const; - bool isFloatType() const; - bool isPointerType() const; - bool isPointerToMemberType() const; - bool isReferenceType() const; - bool isArrayType() const; - bool isNamedType() const; - bool isFunctionType() const; - bool isNamespaceType() const; - bool isTemplateType() const; - bool isClassType() const; - bool isEnumType() const; - bool isForwardClassDeclarationType() const; - bool isObjCClassType() const; - bool isObjCProtocolType() const; - bool isObjCMethodType() const; - bool isObjCForwardClassDeclarationType() const; - bool isObjCForwardProtocolDeclarationType() const; virtual const UndefinedType *asUndefinedType() const { return nullptr; } virtual const VoidType *asVoidType() const { return nullptr; } diff --git a/src/libs/cplusplus/CppRewriter.cpp b/src/libs/cplusplus/CppRewriter.cpp index e10d9aeec23..6f2a74d366d 100644 --- a/src/libs/cplusplus/CppRewriter.cpp +++ b/src/libs/cplusplus/CppRewriter.cpp @@ -285,7 +285,7 @@ public: } const FullySpecifiedType ty = rewrite->env->apply(name->identifier(), rewrite); - const Name * const minName = ty->isNamedType() ? ty->asNamedType()->name() : name; + const Name * const minName = ty->asNamedType() ? ty->asNamedType()->name() : name; const TemplateNameId * const newTemplateNameId = control()->templateNameId( identifier(minName->identifier()), name->isSpecialization(), args.data(), args.size()); diff --git a/src/libs/cplusplus/FindUsages.cpp b/src/libs/cplusplus/FindUsages.cpp index 8ec65c021a5..2ed6e4f849c 100644 --- a/src/libs/cplusplus/FindUsages.cpp +++ b/src/libs/cplusplus/FindUsages.cpp @@ -315,7 +315,7 @@ private: return Usage::Type::Other; if (const auto refType = type->asReferenceType()) return refType->elementType().isConst() ? Usage::Type::Read : Usage::Type::WritableRef; - while (type->isPointerType()) { + while (type->asPointerType()) { type = type->asPointerType()->elementType(); if (!type.isConst()) return Usage::Type::WritableRef; @@ -434,7 +434,7 @@ private: if (items.isEmpty()) return Usage::Type::Other; for (const LookupItem &item : qAsConst(items)) { - if (item.type()->isFunctionType()) { + if (item.type()->asFunctionType()) { if (item.type().isConst()) return Usage::Type::Read; if (item.type().isStatic()) diff --git a/src/libs/cplusplus/Icons.cpp b/src/libs/cplusplus/Icons.cpp index aaf258b5577..77dfd559d1f 100644 --- a/src/libs/cplusplus/Icons.cpp +++ b/src/libs/cplusplus/Icons.cpp @@ -58,7 +58,7 @@ Utils::CodeModelIcon::Type iconTypeForSymbol(const Symbol *symbol) FullySpecifiedType symbolType = symbol->type(); if (symbol->asFunction() || (symbol->asDeclaration() && symbolType && - symbolType->isFunctionType())) + symbolType->asFunctionType())) { const Function *function = symbol->asFunction(); if (!function) diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index b3d3882ca07..487c60f1b59 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -1089,14 +1089,14 @@ ClassOrNamespace *ClassOrNamespace::findSpecialization(const TemplateNameId *tem = specializationTemplateArgument.type().type()->asPointerType(); // specialization and initialization argument have to be a pointer // additionally type of pointer argument of specialization has to be namedType - if (specPointer && initializationTemplateArgument.type().type()->isPointerType() - && specPointer->elementType().type()->isNamedType()) { + if (specPointer && initializationTemplateArgument.type().type()->asPointerType() + && specPointer->elementType().type()->asNamedType()) { return cit->second; } ArrayType *specArray = specializationTemplateArgument.type().type()->asArrayType(); - if (specArray && initializationTemplateArgument.type().type()->isArrayType()) { + if (specArray && initializationTemplateArgument.type().type()->asArrayType()) { if (const NamedType *argumentNamedType = specArray->elementType().type()->asNamedType()) { if (const Name *argumentName = argumentNamedType->name()) { @@ -1340,7 +1340,7 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name, cloner.type(tParam->type(), &subst); if (i < templSpecArgumentCount - && templSpecId->templateArgumentAt(i).type()->isPointerType()) { + && templSpecId->templateArgumentAt(i).type()->asPointerType()) { if (PointerType *pointerType = ty->asPointerType()) ty = pointerType->elementType(); } diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp index 6803194ec60..99b5d1b927c 100644 --- a/src/libs/cplusplus/ResolveExpression.cpp +++ b/src/libs/cplusplus/ResolveExpression.cpp @@ -168,10 +168,10 @@ private: visited.insert(declaration); // continue working with the typedefed type and scope - if (type->type()->isPointerType()) { + if (type->type()->asPointerType()) { *type = FullySpecifiedType( _context.bindings()->control()->pointerType(declaration->type())); - } else if (type->type()->isReferenceType()) { + } else if (type->type()->asReferenceType()) { *type = FullySpecifiedType( _context.bindings()->control()->referenceType( declaration->type(), @@ -1129,11 +1129,11 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList &bas Function *instantiatedFunction = nullptr; - if (overloadType->isFunctionType()) { + if (overloadType->asFunctionType()) { FullySpecifiedType overloadTy = instantiate(binding->templateId(), overload); instantiatedFunction = overloadTy->asFunctionType(); - } else if (overloadType->isTemplateType() + } else if (overloadType->asTemplateType() && overloadType->asTemplateType()->declaration() && overloadType->asTemplateType()->declaration()->asFunction()) { instantiatedFunction = overloadType->asTemplateType()->declaration()->asFunction(); @@ -1146,7 +1146,7 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList &bas typedefsResolver.resolve(&retTy, &functionScope, r.binding()); - if (! retTy->isPointerType() && ! retTy->isNamedType()) + if (! retTy->asPointerType() && ! retTy->asNamedType()) continue; if (PointerType *ptrTy = retTy->asPointerType()) @@ -1178,7 +1178,7 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList &bas } } else if (accessOp == T_DOT) { if (replacedDotOperator) { - *replacedDotOperator = originalType->isPointerType() || ty->isPointerType(); + *replacedDotOperator = originalType->asPointerType() || ty->asPointerType(); if (PointerType *ptrTy = ty->asPointerType()) ty = ptrTy->elementType(); } diff --git a/src/libs/cplusplus/TypePrettyPrinter.cpp b/src/libs/cplusplus/TypePrettyPrinter.cpp index d6a2ce84fac..a7852edb784 100644 --- a/src/libs/cplusplus/TypePrettyPrinter.cpp +++ b/src/libs/cplusplus/TypePrettyPrinter.cpp @@ -312,8 +312,8 @@ void TypePrettyPrinter::visit(PointerToMemberType *type) void TypePrettyPrinter::prependSpaceBeforeIndirection(const FullySpecifiedType &type) { - const bool elementTypeIsPointerOrReference = type.type()->isPointerType() - || type.type()->isReferenceType(); + const bool elementTypeIsPointerOrReference = type.type()->asPointerType() + || type.type()->asReferenceType(); const bool elementIsConstPointerOrReference = elementTypeIsPointerOrReference && type.isConst(); const bool shouldBindToLeftSpecifier = _overview->starBindFlags & Overview::BindToLeftSpecifier; if (elementIsConstPointerOrReference && ! shouldBindToLeftSpecifier) @@ -342,8 +342,8 @@ void TypePrettyPrinter::prependSpaceAfterIndirection(bool hasName) void TypePrettyPrinter::visit(PointerType *type) { - const bool isIndirectionToFunction = type->elementType().type()->isFunctionType(); - const bool isIndirectionToArray = type->elementType().type()->isArrayType(); + const bool isIndirectionToFunction = type->elementType().type()->asFunctionType(); + const bool isIndirectionToArray = type->elementType().type()->asArrayType(); visitIndirectionType(aPointerType, type->elementType(), isIndirectionToFunction || isIndirectionToArray); @@ -351,8 +351,8 @@ void TypePrettyPrinter::visit(PointerType *type) void TypePrettyPrinter::visit(ReferenceType *type) { - const bool isIndirectionToFunction = type->elementType().type()->isFunctionType(); - const bool isIndirectionToArray = type->elementType().type()->isArrayType(); + const bool isIndirectionToFunction = type->elementType().type()->asFunctionType(); + const bool isIndirectionToArray = type->elementType().type()->asArrayType(); const IndirectionType indirectionType = type->isRvalueReference() ? aRvalueReferenceType : aReferenceType; diff --git a/src/libs/qmljs/qmljsfindexportedcpptypes.cpp b/src/libs/qmljs/qmljsfindexportedcpptypes.cpp index 72a4cfad511..cff74bd1abc 100644 --- a/src/libs/qmljs/qmljsfindexportedcpptypes.cpp +++ b/src/libs/qmljs/qmljsfindexportedcpptypes.cpp @@ -717,7 +717,7 @@ static LanguageUtils::FakeMetaObject::Ptr buildFakeMetaObject( const FullySpecifiedType &type = propDecl->type(); const bool isList = false; // ### fixme const bool isWritable = propDecl->flags() & QtPropertyDeclaration::WriteFunction; - const bool isPointer = type.type() && type.type()->isPointerType(); + const bool isPointer = type.type() && type.type()->asPointerType(); const int revision = 0; // ### fixme FakeMetaProperty property( namePrinter.prettyName(propDecl->name()), diff --git a/src/plugins/cppeditor/cppchecksymbols.cpp b/src/plugins/cppeditor/cppchecksymbols.cpp index fe5b3fca724..6c3b4cc61e8 100644 --- a/src/plugins/cppeditor/cppchecksymbols.cpp +++ b/src/plugins/cppeditor/cppchecksymbols.cpp @@ -190,12 +190,12 @@ protected: if (symbol->enclosingEnum() != nullptr) addStatic(symbol->name()); - if (symbol->type()->isFunctionType()) + if (symbol->type()->asFunctionType()) addFunction(symbol->name()); if (symbol->isTypedef()) addType(symbol->name()); - else if (!symbol->type()->isFunctionType() && symbol->enclosingScope()->asClass()) + else if (!symbol->type()->asFunctionType() && symbol->enclosingScope()->asClass()) addField(symbol->name()); return true; @@ -1313,7 +1313,7 @@ bool CheckSymbols::maybeAddField(const QList &candidates, NameAST *a return false; if (!(c->enclosingScope() && c->enclosingScope()->asClass())) return false; // shadowed - if (c->isTypedef() || (c->type() && c->type()->isFunctionType())) + if (c->isTypedef() || (c->type() && c->type()->asFunctionType())) return false; // shadowed int line, column; diff --git a/src/plugins/cppeditor/cppcompletionassist.cpp b/src/plugins/cppeditor/cppcompletionassist.cpp index 672ca389b12..997945506ec 100644 --- a/src/plugins/cppeditor/cppcompletionassist.cpp +++ b/src/plugins/cppeditor/cppcompletionassist.cpp @@ -258,7 +258,7 @@ void CppAssistProposalItem::applyContextualContent(TextDocumentManipulatorInterf // unless we're doing a scope completion (then it might be function definition). const QChar characterAtCursor = manipulator.characterAt(manipulator.currentPosition()); bool endWithSemicolon = m_typedChar == QLatin1Char(';') - || (function->returnType()->isVoidType() && m_completionOperator != T_COLON_COLON); + || (function->returnType()->asVoidType() && m_completionOperator != T_COLON_COLON); const QChar semicolon = m_typedChar.isNull() ? QLatin1Char(';') : m_typedChar; if (endWithSemicolon && characterAtCursor == semicolon) { @@ -1106,7 +1106,7 @@ bool InternalCppCompletionAssistProcessor::tryObjCCompletion() for (const LookupItem &item : items) { FullySpecifiedType ty = item.type().simplified(); - if (ty->isPointerType()) { + if (ty->asPointerType()) { ty = ty->asPointerType()->elementType().simplified(); if (NamedType *namedTy = ty->asNamedType()) { @@ -1354,7 +1354,7 @@ int InternalCppCompletionAssistProcessor::startCompletionInternal(const QString // If it's a class, add completions for the constructors for (const LookupItem &result : results) { - if (result.type()->isClassType()) { + if (result.type()->asClassType()) { if (completeConstructorOrFunction(results, endOfExpression, true)) return m_positionForProposal; diff --git a/src/plugins/cppeditor/cppelementevaluator.cpp b/src/plugins/cppeditor/cppelementevaluator.cpp index 7fbe8d2c41c..69f90d124e6 100644 --- a/src/plugins/cppeditor/cppelementevaluator.cpp +++ b/src/plugins/cppeditor/cppelementevaluator.cpp @@ -282,15 +282,15 @@ public: const FullySpecifiedType &type = declaration->type(); const Name *typeName = nullptr; - if (type->isNamedType()) { + if (type->asNamedType()) { typeName = type->asNamedType()->name(); - } else if (type->isPointerType() || type->isReferenceType()) { + } else if (type->asPointerType() || type->asReferenceType()) { FullySpecifiedType associatedType; - if (type->isPointerType()) + if (type->asPointerType()) associatedType = type->asPointerType()->elementType(); else associatedType = type->asReferenceType()->elementType(); - if (associatedType->isNamedType()) + if (associatedType->asNamedType()) typeName = associatedType->asNamedType()->name(); } @@ -435,7 +435,7 @@ static QSharedPointer handleLookupItemMatch(const Snapshot &snapshot } else if (declaration->isTypedef()) { element = QSharedPointer(new CppTypedef(declaration)); } else if (declaration->asFunction() - || (type.isValid() && type->isFunctionType()) + || (type.isValid() && type->asFunctionType()) || declaration->asTemplate()) { element = QSharedPointer(new CppFunction(declaration)); } else if (declaration->asDeclaration() && type.isValid()) { diff --git a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp index 9a33620702f..840908f68ef 100644 --- a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp +++ b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp @@ -151,7 +151,7 @@ bool VirtualFunctionHelper::canLookupVirtualFunctionOverrides(Function *function if (!items.isEmpty()) { const LookupItem item = items.first(); if (Symbol *declaration = item.declaration()) - result = declaration->type()->isReferenceType(); + result = declaration->type()->asReferenceType(); } } } @@ -249,7 +249,7 @@ static bool isForwardClassDeclaration(Type *type) if (!type) return false; - if (type->isForwardClassDeclarationType()) { + if (type->asForwardClassDeclarationType()) { return true; } else if (Template *templ = type->asTemplateType()) { if (Symbol *declaration = templ->declaration()) { @@ -279,22 +279,22 @@ inline LookupItem skipForwardDeclarations(const QList &resolvedSymbo } } - if (ty->isObjCForwardClassDeclarationType()) { + if (ty->asObjCForwardClassDeclarationType()) { while (!candidates.isEmpty()) { LookupItem r = candidates.takeFirst(); - if (!r.type()->isObjCForwardClassDeclarationType()) { + if (!r.type()->asObjCForwardClassDeclarationType()) { result = r; break; } } } - if (ty->isObjCForwardProtocolDeclarationType()) { + if (ty->asObjCForwardProtocolDeclarationType()) { while (!candidates.isEmpty()) { LookupItem r = candidates.takeFirst(); - if (!r.type()->isObjCForwardProtocolDeclarationType()) { + if (!r.type()->asObjCForwardProtocolDeclarationType()) { result = r; break; } @@ -387,7 +387,7 @@ Symbol *findDefinition(Symbol *symbol, const Snapshot &snapshot, SymbolFinder *s if (symbol->asFunction()) return nullptr; // symbol is a function definition. - if (!symbol->type()->isFunctionType()) + if (!symbol->type()->asFunctionType()) return nullptr; // not a function declaration return symbolFinder->findMatchingDefinition(symbol, snapshot); @@ -830,7 +830,7 @@ void FollowSymbolUnderCursor::switchDeclDef( if (Symbol *symbol = symbols->value) { if (symbol->asDeclaration()) { declarationSymbol = symbol; - if (symbol->type()->isFunctionType()) { + if (symbol->type()->asFunctionType()) { functionDeclarationSymbol = symbol; break; // Function declaration found! } diff --git a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp index 99a8287afe5..e081a63348f 100644 --- a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp +++ b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp @@ -355,7 +355,7 @@ void FunctionDeclDefLink::showMarker(CppEditorWidget *editor) static int declaredParameterCount(Function *function) { int argc = function->argumentCount(); - if (argc == 0 && function->memberCount() > 0 && function->memberAt(0)->type().type()->isVoidType()) + if (argc == 0 && function->memberCount() > 0 && function->memberAt(0)->type().type()->asVoidType()) return 1; return argc; } diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index e61c0ce6aed..03c6529d1ee 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -1343,7 +1343,7 @@ void TranslateStringLiteral::match(const CppQuickFixInterface &interface, const QList items = b->find(trName); for (const LookupItem &r : items) { Symbol *s = r.declaration(); - if (s->type()->isFunctionType()) { + if (s->type()->asFunctionType()) { // no context required for tr result << new WrapStringLiteralOp(interface, path.size() - 1, TranslateTrAction, @@ -1692,7 +1692,7 @@ void AddLocalDeclaration::match(const CppQuickFixInterface &interface, QuickFixO if (!r.declaration()) continue; if (Declaration *d = r.declaration()->asDeclaration()) { - if (!d->type()->isFunctionType()) { + if (!d->type()->asFunctionType()) { decl = d; break; } @@ -2651,14 +2651,14 @@ void InsertDeclFromDef::match(const CppQuickFixInterface &interface, QuickFixOpe if (fun->enclosingScope()->asTemplate()) { if (const Template *templ = s->type()->asTemplateType()) { if (Symbol *decl = templ->declaration()) { - if (decl->type()->isFunctionType()) + if (decl->type()->asFunctionType()) s = decl; } } } if (!s->name() || !qName->identifier()->match(s->identifier()) - || !s->type()->isFunctionType()) + || !s->type()->asFunctionType()) continue; if (s->type().match(fun->type())) { @@ -3591,10 +3591,10 @@ protected: *customValueType = false; // a type is a value type if it is one of the following const auto isTypeValueType = [](const FullySpecifiedType &t) { - return t->isPointerType() || t->isEnumType() || t->isIntegerType() || t->isFloatType() - || t->isReferenceType(); + return t->asPointerType() || t->asEnumType() || t->asIntegerType() || t->asFloatType() + || t->asReferenceType(); }; - if (type->isNamedType()) { + if (type->asNamedType()) { // we need a recursive search and a lookup context LookupContext context(m_headerFile->cppDocument(), m_changes.snapshot()); auto isValueType = [settings = m_settings, @@ -3616,7 +3616,7 @@ protected: for (auto &&i : localLookup) { if (isTypeValueType(i.type())) return true; - if (i.type()->isNamedType()) { // check if we have to search recursively + if (i.type()->asNamedType()) { // check if we have to search recursively const Name *newName = i.type()->asNamedType()->name(); Scope *newScope = i.declaration()->enclosingScope(); if (Matcher::match(newName, name) @@ -5465,7 +5465,7 @@ public: for (Symbol *s = matchingClass->find(qName->identifier()); s; s = s->next()) { if (!s->name() || !qName->identifier()->match(s->identifier()) - || !s->type()->isFunctionType() + || !s->type()->asFunctionType() || !s->type().match(func->type()) || s->asFunction()) { continue; @@ -6028,7 +6028,7 @@ void ConvertFromAndToPointer::match(const CppQuickFixInterface &interface, Scope *scope = file->scopeAt(declarator->firstToken()); QList result = typeOfExpression(file->textOf(declarator->initializer).toUtf8(), scope, TypeOfExpression::Preprocess); - if (!result.isEmpty() && result.first().type()->isPointerType()) + if (!result.isEmpty() && result.first().type()->asPointerType()) mode = ConvertFromAndToPointerOp::FromPointer; } else if (declarator->ptr_operator_list) { for (PtrOperatorListAST *ops = declarator->ptr_operator_list; ops; ops = ops->next) { @@ -6660,14 +6660,14 @@ void MoveFuncDefToDecl::match(const CppQuickFixInterface &interface, QuickFixOpe if (func->enclosingScope()->asTemplate()) { if (const Template *templ = s->type()->asTemplateType()) { if (Symbol *decl = templ->declaration()) { - if (decl->type()->isFunctionType()) + if (decl->type()->asFunctionType()) s = decl; } } } if (!s->name() || !qName->identifier()->match(s->identifier()) - || !s->type()->isFunctionType() + || !s->type()->asFunctionType() || !s->type().match(func->type()) || s->asFunction()) { continue; @@ -6937,11 +6937,11 @@ void AssignToLocalVariable::match(const CppQuickFixInterface &interface, QuickFi continue; if (Function *func = item.declaration()->asFunction()) { - if (func->isSignal() || func->returnType()->isVoidType()) + if (func->isSignal() || func->returnType()->asVoidType()) return; } else if (Declaration *dec = item.declaration()->asDeclaration()) { if (Function *func = dec->type()->asFunctionType()) { - if (func->isSignal() || func->returnType()->isVoidType()) + if (func->isSignal() || func->returnType()->asVoidType()) return; } } @@ -7349,7 +7349,7 @@ private: Symbol *skipForwardDeclarations(const QList &symbols) { for (Symbol *symbol : symbols) { - if (!symbol->type()->isForwardClassDeclarationType()) + if (!symbol->type()->asForwardClassDeclarationType()) return symbol; } diff --git a/src/plugins/cppeditor/doxygengenerator.cpp b/src/plugins/cppeditor/doxygengenerator.cpp index 555c1502f4b..34f9508936c 100644 --- a/src/plugins/cppeditor/doxygengenerator.cpp +++ b/src/plugins/cppeditor/doxygengenerator.cpp @@ -205,7 +205,7 @@ QString DoxygenGenerator::generate(QTextCursor cursor, DeclarationAST *decl) } if (funcDecltr->symbol && funcDecltr->symbol->returnType().type() - && !funcDecltr->symbol->returnType()->isVoidType() + && !funcDecltr->symbol->returnType()->asVoidType() && !funcDecltr->symbol->returnType()->isUndefinedType()) { writeContinuation(&comment); writeCommand(&comment, ReturnCommand); diff --git a/src/plugins/cppeditor/symbolfinder.cpp b/src/plugins/cppeditor/symbolfinder.cpp index f9da3591de7..0dd0e451f5e 100644 --- a/src/plugins/cppeditor/symbolfinder.cpp +++ b/src/plugins/cppeditor/symbolfinder.cpp @@ -423,13 +423,13 @@ void SymbolFinder::findMatchingDeclaration(const LookupContext &context, if (funcId) { for (Symbol *s = scope->find(funcId); s; s = s->next()) { - if (!s->name() || !funcId->match(s->identifier()) || !s->type()->isFunctionType()) + if (!s->name() || !funcId->match(s->identifier()) || !s->type()->asFunctionType()) continue; findDeclarationOfSymbol(s, functionType, typeMatch, argumentCountMatch, nameMatch); } } else { for (Symbol *s = scope->find(operatorNameId); s; s = s->next()) { - if (!s->name() || !s->type()->isFunctionType()) + if (!s->name() || !s->type()->asFunctionType()) continue; findDeclarationOfSymbol(s, functionType, typeMatch, argumentCountMatch, nameMatch); } diff --git a/tests/auto/cplusplus/findusages/tst_findusages.cpp b/tests/auto/cplusplus/findusages/tst_findusages.cpp index e43d1692b8f..9904f0d4908 100644 --- a/tests/auto/cplusplus/findusages/tst_findusages.cpp +++ b/tests/auto/cplusplus/findusages/tst_findusages.cpp @@ -650,7 +650,7 @@ void tst_FindUsages::objc_args() Declaration *methodIface = iface->memberAt(0)->asDeclaration(); QVERIFY(methodIface); QCOMPARE(methodIface->identifier()->chars(), "method"); - QVERIFY(methodIface->type()->isObjCMethodType()); + QVERIFY(methodIface->type()->asObjCMethodType()); ObjCClass *impl = doc->globalSymbolAt(1)->asObjCClass(); QVERIFY(impl); diff --git a/tests/auto/cplusplus/lookup/tst_lookup.cpp b/tests/auto/cplusplus/lookup/tst_lookup.cpp index b3cefd525f6..f47db0f168a 100644 --- a/tests/auto/cplusplus/lookup/tst_lookup.cpp +++ b/tests/auto/cplusplus/lookup/tst_lookup.cpp @@ -451,7 +451,7 @@ void tst_Lookup::iface_impl_scoping() Argument *method1Arg = method1Impl->memberAt(0)->asArgument(); QVERIFY(method1Arg); QCOMPARE(method1Arg->identifier()->chars(), "arg"); - QVERIFY(method1Arg->type()->isIntegerType()); + QVERIFY(method1Arg->type()->asIntegerType()); Block *method1Body = method1Impl->memberAt(1)->asBlock(); QVERIFY(method1Body); @@ -465,7 +465,7 @@ void tst_Lookup::iface_impl_scoping() QVERIFY(arg->name()); QVERIFY(arg->name()->identifier()); QCOMPARE(arg->name()->identifier()->chars(), "arg"); - QVERIFY(arg->type()->isIntegerType()); + QVERIFY(arg->type()->asIntegerType()); const QList candidates = context.lookup(arg->name(), method1Body->enclosingScope()); QCOMPARE(candidates.size(), 1); diff --git a/tests/auto/cplusplus/semantic/tst_semantic.cpp b/tests/auto/cplusplus/semantic/tst_semantic.cpp index 61b2aa3bb48..8421dcf59a3 100644 --- a/tests/auto/cplusplus/semantic/tst_semantic.cpp +++ b/tests/auto/cplusplus/semantic/tst_semantic.cpp @@ -206,7 +206,7 @@ void tst_Semantic::function_declaration_1() FullySpecifiedType declTy = decl->type(); Function *funTy = declTy->asFunctionType(); QVERIFY(funTy); - QVERIFY(funTy->returnType()->isVoidType()); + QVERIFY(funTy->returnType()->asVoidType()); QCOMPARE(funTy->argumentCount(), 0); QCOMPARE(funTy->refQualifier(), Function::NoRefQualifier); @@ -230,7 +230,7 @@ void tst_Semantic::function_declaration_2() FullySpecifiedType declTy = decl->type(); Function *funTy = declTy->asFunctionType(); QVERIFY(funTy); - QVERIFY(funTy->returnType()->isVoidType()); + QVERIFY(funTy->returnType()->asVoidType()); QCOMPARE(funTy->argumentCount(), 1); QCOMPARE(funTy->refQualifier(), Function::NoRefQualifier); @@ -251,7 +251,7 @@ void tst_Semantic::function_declaration_2() // check the type of the formal argument FullySpecifiedType argTy = arg->type(); - QVERIFY(argTy->isReferenceType()); + QVERIFY(argTy->asReferenceType()); QVERIFY(argTy->asReferenceType()->elementType().isConst()); NamedType *namedTy = argTy->asReferenceType()->elementType()->asNamedType(); QVERIFY(namedTy); @@ -359,7 +359,7 @@ void tst_Semantic::function_declaration_ref_qualifier() FullySpecifiedType declTy = decl->type(); Function *funTy = declTy->asFunctionType(); QVERIFY(funTy); - QVERIFY(funTy->returnType()->isVoidType()); + QVERIFY(funTy->returnType()->asVoidType()); QCOMPARE(funTy->argumentCount(), 0); // check the ref-qualifier @@ -374,7 +374,7 @@ void tst_Semantic::function_definition_1() Function *funTy = doc->globals->memberAt(0)->asFunction(); QVERIFY(funTy); - QVERIFY(funTy->returnType()->isVoidType()); + QVERIFY(funTy->returnType()->asVoidType()); QCOMPARE(funTy->argumentCount(), 0); QCOMPARE(funTy->refQualifier(), Function::NoRefQualifier); @@ -448,7 +448,7 @@ void tst_Semantic::alias_declaration_1() QVERIFY(decl->isTypedef()); QVERIFY(decl->type().isTypedef()); - QVERIFY(decl->type()->isIntegerType()); + QVERIFY(decl->type()->asIntegerType()); } void tst_Semantic::typedef_1() @@ -502,7 +502,7 @@ void tst_Semantic::typedef_2() Declaration *typedefPointDecl = doc->globals->memberAt(1)->asDeclaration(); QVERIFY(typedefPointDecl); QVERIFY(typedefPointDecl->isTypedef()); - QVERIFY(typedefPointDecl->type()->isNamedType()); + QVERIFY(typedefPointDecl->type()->asNamedType()); QCOMPARE(typedefPointDecl->type()->asNamedType()->name(), _pointStruct->name()); Function *mainFun = doc->globals->memberAt(2)->asFunction(); @@ -527,7 +527,7 @@ void tst_Semantic::typedef_3() Declaration *typedefPointDecl = doc->globals->memberAt(1)->asDeclaration(); QVERIFY(typedefPointDecl); QVERIFY(typedefPointDecl->isTypedef()); - QVERIFY(typedefPointDecl->type()->isPointerType()); + QVERIFY(typedefPointDecl->type()->asPointerType()); QCOMPARE(typedefPointDecl->type()->asPointerType()->elementType()->asClassType(), _pointStruct); } @@ -543,16 +543,16 @@ void tst_Semantic::const_1() Declaration *decl = doc->globals->memberAt(0)->asDeclaration(); QVERIFY(decl); - QVERIFY(decl->type()->isFunctionType()); + QVERIFY(decl->type()->asFunctionType()); Function *funTy = decl->type()->asFunctionType(); - QVERIFY(funTy->returnType()->isIntegerType()); + QVERIFY(funTy->returnType()->asIntegerType()); QCOMPARE(funTy->argumentCount(), 1); Argument *arg = funTy->argumentAt(0)->asArgument(); QVERIFY(arg); QVERIFY(! arg->type().isConst()); - QVERIFY(arg->type()->isPointerType()); + QVERIFY(arg->type()->asPointerType()); QVERIFY(arg->type()->asPointerType()->elementType().isConst()); - QVERIFY(arg->type()->asPointerType()->elementType()->isIntegerType()); + QVERIFY(arg->type()->asPointerType()->elementType()->asIntegerType()); } void tst_Semantic::const_2() @@ -566,16 +566,16 @@ void tst_Semantic::const_2() Declaration *decl = doc->globals->memberAt(0)->asDeclaration(); QVERIFY(decl); - QVERIFY(decl->type()->isFunctionType()); + QVERIFY(decl->type()->asFunctionType()); Function *funTy = decl->type()->asFunctionType(); - QVERIFY(funTy->returnType()->isIntegerType()); + QVERIFY(funTy->returnType()->asIntegerType()); QCOMPARE(funTy->argumentCount(), 1); Argument *arg = funTy->argumentAt(0)->asArgument(); QVERIFY(arg); QVERIFY(arg->type().isConst()); - QVERIFY(arg->type()->isPointerType()); + QVERIFY(arg->type()->asPointerType()); QVERIFY(! arg->type()->asPointerType()->elementType().isConst()); - QVERIFY(arg->type()->asPointerType()->elementType()->isIntegerType()); + QVERIFY(arg->type()->asPointerType()->elementType()->asIntegerType()); } void tst_Semantic::pointer_to_function_1()