forked from qt-creator/qt-creator
CPlusPlus: Inline more simple Type related functions
Change-Id: I2103e8047b385b438e58072e8a2689f1889d2724 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
6
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
6
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
@ -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));
|
||||
|
60
src/libs/3rdparty/cplusplus/CoreTypes.cpp
vendored
60
src/libs/3rdparty/cplusplus/CoreTypes.cpp
vendored
@ -21,6 +21,7 @@
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeVisitor.h"
|
||||
#include "Matcher.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
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); }
|
||||
|
123
src/libs/3rdparty/cplusplus/CoreTypes.h
vendored
123
src/libs/3rdparty/cplusplus/CoreTypes.h
vendored
@ -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;
|
||||
|
123
src/libs/3rdparty/cplusplus/FullySpecifiedType.cpp
vendored
123
src/libs/3rdparty/cplusplus/FullySpecifiedType.cpp
vendored
@ -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)
|
||||
|
82
src/libs/3rdparty/cplusplus/FullySpecifiedType.h
vendored
82
src/libs/3rdparty/cplusplus/FullySpecifiedType.h
vendored
@ -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;
|
||||
|
14
src/libs/3rdparty/cplusplus/Symbols.cpp
vendored
14
src/libs/3rdparty/cplusplus/Symbols.cpp
vendored
@ -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)
|
||||
|
64
src/libs/3rdparty/cplusplus/Type.cpp
vendored
64
src/libs/3rdparty/cplusplus/Type.cpp
vendored
@ -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))
|
||||
|
21
src/libs/3rdparty/cplusplus/Type.h
vendored
21
src/libs/3rdparty/cplusplus/Type.h
vendored
@ -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; }
|
||||
|
@ -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());
|
||||
|
@ -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())
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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<LookupItem> &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<LookupItem> &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<LookupItem> &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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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()),
|
||||
|
@ -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<LookupItem> &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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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<CppElement> handleLookupItemMatch(const Snapshot &snapshot
|
||||
} else if (declaration->isTypedef()) {
|
||||
element = QSharedPointer<CppElement>(new CppTypedef(declaration));
|
||||
} else if (declaration->asFunction()
|
||||
|| (type.isValid() && type->isFunctionType())
|
||||
|| (type.isValid() && type->asFunctionType())
|
||||
|| declaration->asTemplate()) {
|
||||
element = QSharedPointer<CppElement>(new CppFunction(declaration));
|
||||
} else if (declaration->asDeclaration() && type.isValid()) {
|
||||
|
@ -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<LookupItem> &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!
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -1343,7 +1343,7 @@ void TranslateStringLiteral::match(const CppQuickFixInterface &interface,
|
||||
const QList<LookupItem> 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<LookupItem> 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<Symbol *> &symbols)
|
||||
{
|
||||
for (Symbol *symbol : symbols) {
|
||||
if (!symbol->type()->isForwardClassDeclarationType())
|
||||
if (!symbol->type()->asForwardClassDeclarationType())
|
||||
return symbol;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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<LookupItem> candidates = context.lookup(arg->name(), method1Body->enclosingScope());
|
||||
QCOMPARE(candidates.size(), 1);
|
||||
|
@ -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()
|
||||
|
Reference in New Issue
Block a user