CPlusPlus: Inline some simple central functions

Depending on context, callgrind sees contributions of >8% to
the total cost of project parsing for these functions. The
functional are actualy executed executed out-of-line, often
for a function body of one "payload" instruction only.

Inlining removes the call/endbr64/ret overhead.

Change-Id: I6886f08e322fcaa4e0f54d424279e0a8c24e4718
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2022-06-23 16:56:36 +02:00
parent 85cd97a334
commit ffa3aad576
43 changed files with 532 additions and 1213 deletions

View File

@@ -2024,7 +2024,7 @@ bool Bind::visit(SimpleDeclarationAST *ast)
decl->setInitializer(asStringLiteral(initializer)); decl->setInitializer(asStringLiteral(initializer));
} }
if (_scope->isClass()) { if (_scope->asClass()) {
decl->setVisibility(_visibility); decl->setVisibility(_visibility);
if (Function *funTy = decl->type()->asFunctionType()) { if (Function *funTy = decl->type()->asFunctionType()) {
@@ -2050,7 +2050,7 @@ bool Bind::visit(EmptyDeclarationAST *ast)
{ {
(void) ast; (void) ast;
int semicolon_token = ast->semicolon_token; int semicolon_token = ast->semicolon_token;
if (_scope && (_scope->isClass() || _scope->isNamespace())) { if (_scope && (_scope->asClass() || _scope->asNamespace())) {
const Token &tk = tokenAt(semicolon_token); const Token &tk = tokenAt(semicolon_token);
if (! tk.generated()) if (! tk.generated())
@@ -2227,7 +2227,7 @@ bool Bind::visit(AliasDeclarationAST *ast)
decl->setType(ty); decl->setType(ty);
decl->setStorage(Symbol::Typedef); decl->setStorage(Symbol::Typedef);
ast->symbol = decl; ast->symbol = decl;
if (_scope->isClass()) if (_scope->asClass())
decl->setVisibility(_visibility); decl->setVisibility(_visibility);
_scope->addMember(decl); _scope->addMember(decl);
@@ -2299,7 +2299,7 @@ bool Bind::visit(FunctionDefinitionAST *ast)
setDeclSpecifiers(fun, declSpecifiers); setDeclSpecifiers(fun, declSpecifiers);
fun->setEndOffset(tokenAt(ast->lastToken() - 1).utf16charsEnd()); fun->setEndOffset(tokenAt(ast->lastToken() - 1).utf16charsEnd());
if (_scope->isClass()) { if (_scope->asClass()) {
fun->setVisibility(_visibility); fun->setVisibility(_visibility);
fun->setMethodKey(methodKey); fun->setMethodKey(methodKey);
} }
@@ -3147,7 +3147,7 @@ bool Bind::visit(ClassSpecifierAST *ast)
klass->setEndOffset(tokenAt(ast->lastToken() - 1).utf16charsEnd()); klass->setEndOffset(tokenAt(ast->lastToken() - 1).utf16charsEnd());
_scope->addMember(klass); _scope->addMember(klass);
if (_scope->isClass()) if (_scope->asClass())
klass->setVisibility(_visibility); klass->setVisibility(_visibility);
// set the class key // set the class key
@@ -3210,7 +3210,7 @@ bool Bind::visit(EnumSpecifierAST *ast)
ast->symbol = e; ast->symbol = e;
_scope->addMember(e); _scope->addMember(e);
if (_scope->isClass()) if (_scope->asClass())
e->setVisibility(_visibility); e->setVisibility(_visibility);
Scope *previousScope = switchScope(e); Scope *previousScope = switchScope(e);
@@ -3398,7 +3398,7 @@ void Bind::ensureValidClassName(const Name **name, int sourceLocation)
const QualifiedNameId *qName = (*name)->asQualifiedNameId(); const QualifiedNameId *qName = (*name)->asQualifiedNameId();
const Name *uqName = qName ? qName->name() : *name; const Name *uqName = qName ? qName->name() : *name;
if (!uqName->isNameId() && !uqName->isTemplateNameId()) { if (!uqName->asNameId() && !uqName->asTemplateNameId()) {
translationUnit()->error(sourceLocation, "expected a class-name"); translationUnit()->error(sourceLocation, "expected a class-name");
*name = uqName->identifier(); *name = uqName->identifier();

View File

@@ -33,17 +33,9 @@ FullySpecifiedType::FullySpecifiedType(Type *type) :
_type = UndefinedType::instance(); _type = UndefinedType::instance();
} }
FullySpecifiedType::~FullySpecifiedType()
{ }
bool FullySpecifiedType::isValid() const bool FullySpecifiedType::isValid() const
{ return _type != UndefinedType::instance(); } { return _type != UndefinedType::instance(); }
Type *FullySpecifiedType::type() const
{ return _type; }
void FullySpecifiedType::setType(Type *type)
{ _type = type; }
FullySpecifiedType FullySpecifiedType::qualifiedType() const FullySpecifiedType FullySpecifiedType::qualifiedType() const
{ {
@@ -215,12 +207,6 @@ FullySpecifiedType FullySpecifiedType::simplified() const
return *this; return *this;
} }
unsigned FullySpecifiedType::flags() const
{ return _flags; }
void FullySpecifiedType::setFlags(unsigned flags)
{ _flags = flags; }
bool FullySpecifiedType::match(const FullySpecifiedType &otherTy, Matcher *matcher) const bool FullySpecifiedType::match(const FullySpecifiedType &otherTy, Matcher *matcher) const
{ {
static const unsigned flagsMask = [](){ static const unsigned flagsMask = [](){

View File

@@ -25,17 +25,17 @@
namespace CPlusPlus { namespace CPlusPlus {
class CPLUSPLUS_EXPORT FullySpecifiedType class CPLUSPLUS_EXPORT FullySpecifiedType final
{ {
public: public:
FullySpecifiedType(Type *type = nullptr); FullySpecifiedType(Type *type = nullptr);
~FullySpecifiedType(); ~FullySpecifiedType() = default;
bool isValid() const; bool isValid() const;
explicit operator bool() const; explicit operator bool() const;
Type *type() const; Type *type() const { return _type; }
void setType(Type *type); void setType(Type *type) { _type = type; }
FullySpecifiedType qualifiedType() const; FullySpecifiedType qualifiedType() const;
@@ -109,8 +109,8 @@ public:
FullySpecifiedType simplified() const; FullySpecifiedType simplified() const;
unsigned flags() const; unsigned flags() const { return _flags; }
void setFlags(unsigned flags); void setFlags(unsigned flags) { _flags = flags; }
private: private:
Type *_type; Type *_type;

View File

@@ -105,7 +105,7 @@ private:
}; };
}; };
class CPLUSPLUS_EXPORT Identifier: public Literal, public Name class CPLUSPLUS_EXPORT Identifier final : public Literal, public Name
{ {
public: public:
Identifier(const char *chars, int size) Identifier(const char *chars, int size)
@@ -114,8 +114,7 @@ public:
const Identifier *identifier() const override { return this; } const Identifier *identifier() const override { return this; }
const Identifier *asNameId() const override const Identifier *asNameId() const override { return this; }
{ return this; }
protected: protected:
void accept0(NameVisitor *visitor) const override; void accept0(NameVisitor *visitor) const override;

View File

@@ -35,30 +35,6 @@ Name::Name()
Name::~Name() Name::~Name()
{ } { }
bool Name::isNameId() const
{ return asNameId() != nullptr; }
bool Name::isAnonymousNameId() const
{ return asAnonymousNameId() != nullptr; }
bool Name::isTemplateNameId() const
{ return asTemplateNameId() != nullptr; }
bool Name::isDestructorNameId() const
{ return asDestructorNameId() != nullptr; }
bool Name::isOperatorNameId() const
{ return asOperatorNameId() != nullptr; }
bool Name::isConversionNameId() const
{ return asConversionNameId() != nullptr; }
bool Name::isQualifiedNameId() const
{ return asQualifiedNameId() != nullptr; }
bool Name::isSelectorNameId() const
{ return asSelectorNameId() != nullptr; }
void Name::accept(NameVisitor *visitor) const void Name::accept(NameVisitor *visitor) const
{ {
if (visitor->preVisit(this)) if (visitor->preVisit(this))

View File

@@ -35,15 +35,6 @@ public:
virtual const Identifier *identifier() const = 0; virtual const Identifier *identifier() const = 0;
bool isNameId() const;
bool isAnonymousNameId() const;
bool isTemplateNameId() const;
bool isDestructorNameId() const;
bool isOperatorNameId() const;
bool isConversionNameId() const;
bool isQualifiedNameId() const;
bool isSelectorNameId() const;
virtual const Identifier *asNameId() const { return nullptr; } virtual const Identifier *asNameId() const { return nullptr; }
virtual const AnonymousNameId *asAnonymousNameId() const { return nullptr; } virtual const AnonymousNameId *asAnonymousNameId() const { return nullptr; }
virtual const TemplateNameId *asTemplateNameId() const { return nullptr; } virtual const TemplateNameId *asTemplateNameId() const { return nullptr; }

View File

@@ -171,9 +171,6 @@ bool OperatorNameId::match0(const Name *otherName, Matcher *matcher) const
OperatorNameId::Kind OperatorNameId::kind() const OperatorNameId::Kind OperatorNameId::kind() const
{ return _kind; } { return _kind; }
const Identifier *OperatorNameId::identifier() const
{ return nullptr; }
ConversionNameId::ConversionNameId(const FullySpecifiedType &type) ConversionNameId::ConversionNameId(const FullySpecifiedType &type)
: _type(type) : _type(type)
{ } { }
@@ -191,11 +188,7 @@ bool ConversionNameId::match0(const Name *otherName, Matcher *matcher) const
return false; return false;
} }
FullySpecifiedType ConversionNameId::type() const
{ return _type; }
const Identifier *ConversionNameId::identifier() const
{ return nullptr; }
SelectorNameId::~SelectorNameId() SelectorNameId::~SelectorNameId()
{ } { }
@@ -249,5 +242,4 @@ bool AnonymousNameId::match0(const Name *otherName, Matcher *matcher) const
return false; return false;
} }
const Identifier *AnonymousNameId::identifier() const
{ return nullptr; }

View File

@@ -234,10 +234,8 @@ public:
Kind kind() const; Kind kind() const;
const Identifier *identifier() const override; const Identifier *identifier() const override { return nullptr; }
const OperatorNameId *asOperatorNameId() const override { return this; }
const OperatorNameId *asOperatorNameId() const override
{ return this; }
protected: protected:
void accept0(NameVisitor *visitor) const override; void accept0(NameVisitor *visitor) const override;
@@ -253,12 +251,9 @@ public:
ConversionNameId(const FullySpecifiedType &type); ConversionNameId(const FullySpecifiedType &type);
virtual ~ConversionNameId(); virtual ~ConversionNameId();
FullySpecifiedType type() const; FullySpecifiedType type() const { return _type; }
const Identifier *identifier() const override { return nullptr; }
const Identifier *identifier() const override; const ConversionNameId *asConversionNameId() const override { return this; }
const ConversionNameId *asConversionNameId() const override
{ return this; }
protected: protected:
void accept0(NameVisitor *visitor) const override; void accept0(NameVisitor *visitor) const override;
@@ -300,7 +295,7 @@ private:
bool _hasArguments; bool _hasArguments;
}; };
class CPLUSPLUS_EXPORT AnonymousNameId: public Name class CPLUSPLUS_EXPORT AnonymousNameId final : public Name
{ {
public: public:
AnonymousNameId(int classTokenIndex); AnonymousNameId(int classTokenIndex);
@@ -308,10 +303,9 @@ public:
int classTokenIndex() const; int classTokenIndex() const;
const Identifier *identifier() const override; const Identifier *identifier() const override { return nullptr; }
const AnonymousNameId *asAnonymousNameId() const override const AnonymousNameId *asAnonymousNameId() const override { return this; }
{ return this; }
protected: protected:
void accept0(NameVisitor *visitor) const override; void accept0(NameVisitor *visitor) const override;

View File

@@ -154,7 +154,7 @@ Symbol *SymbolTable::lookat(const Identifier *id) const
} else if (const DestructorNameId *d = identity->asDestructorNameId()) { } else if (const DestructorNameId *d = identity->asDestructorNameId()) {
if (d->identifier()->match(id)) if (d->identifier()->match(id))
break; break;
} else if (identity->isQualifiedNameId()) { } else if (identity->asQualifiedNameId()) {
return nullptr; return nullptr;
} else if (const SelectorNameId *selectorNameId = identity->asSelectorNameId()) { } else if (const SelectorNameId *selectorNameId = identity->asSelectorNameId()) {
if (selectorNameId->identifier()->match(id)) if (selectorNameId->identifier()->match(id))

View File

@@ -142,23 +142,7 @@ void Symbol::visitSymbol(Symbol *symbol, SymbolVisitor *visitor)
symbol->visitSymbol(visitor); symbol->visitSymbol(visitor);
} }
int Symbol::sourceLocation() const
{ return _sourceLocation; }
bool Symbol::isGenerated() const
{ return _isGenerated; }
bool Symbol::isDeprecated() const
{ return _isDeprecated; }
void Symbol::setDeprecated(bool isDeprecated)
{ _isDeprecated = isDeprecated; }
bool Symbol::isUnavailable() const
{ return _isUnavailable; }
void Symbol::setUnavailable(bool isUnavailable)
{ _isUnavailable = isUnavailable; }
void Symbol::setSourceLocation(int sourceLocation, TranslationUnit *translationUnit) void Symbol::setSourceLocation(int sourceLocation, TranslationUnit *translationUnit)
{ {
@@ -176,21 +160,6 @@ void Symbol::setSourceLocation(int sourceLocation, TranslationUnit *translationU
} }
} }
int Symbol::line() const
{
return _line;
}
int Symbol::column() const
{
return _column;
}
const StringLiteral *Symbol::fileId() const
{
return _fileId;
}
const char *Symbol::fileName() const const char *Symbol::fileName() const
{ return _fileId ? _fileId->chars() : ""; } { return _fileId ? _fileId->chars() : ""; }
@@ -208,9 +177,6 @@ const Name *Symbol::unqualifiedName() const
return _name; return _name;
} }
const Name *Symbol::name() const
{ return _name; }
void Symbol::setName(const Name *name) void Symbol::setName(const Name *name)
{ {
_name = name; _name = name;
@@ -231,9 +197,6 @@ const Identifier *Symbol::identifier() const
return nullptr; return nullptr;
} }
Scope *Symbol::enclosingScope() const
{ return _enclosingScope; }
void Symbol::setEnclosingScope(Scope *scope) void Symbol::setEnclosingScope(Scope *scope)
{ {
CPP_CHECK(! _enclosingScope); CPP_CHECK(! _enclosingScope);
@@ -299,126 +262,6 @@ Block *Symbol::enclosingBlock() const
return nullptr; return nullptr;
} }
unsigned Symbol::index() const
{ return _index; }
Symbol *Symbol::next() const
{ return _next; }
unsigned Symbol::hashCode() const
{ return _hashCode; }
int Symbol::storage() const
{ return _storage; }
void Symbol::setStorage(int storage)
{ _storage = storage; }
int Symbol::visibility() const
{ return _visibility; }
void Symbol::setVisibility(int visibility)
{ _visibility = visibility; }
bool Symbol::isFriend() const
{ return _storage == Friend; }
bool Symbol::isRegister() const
{ return _storage == Register; }
bool Symbol::isStatic() const
{ return _storage == Static; }
bool Symbol::isExtern() const
{ return _storage == Extern; }
bool Symbol::isMutable() const
{ return _storage == Mutable; }
bool Symbol::isTypedef() const
{ return _storage == Typedef; }
bool Symbol::isPublic() const
{ return _visibility == Public; }
bool Symbol::isProtected() const
{ return _visibility == Protected; }
bool Symbol::isPrivate() const
{ return _visibility == Private; }
bool Symbol::isScope() const
{ return asScope() != nullptr; }
bool Symbol::isEnum() const
{ return asEnum() != nullptr; }
bool Symbol::isFunction() const
{ return asFunction() != nullptr; }
bool Symbol::isNamespace() const
{ return asNamespace() != nullptr; }
bool Symbol::isTemplate() const
{ return asTemplate() != nullptr; }
bool Symbol::isClass() const
{ return asClass() != nullptr; }
bool Symbol::isForwardClassDeclaration() const
{ return asForwardClassDeclaration() != nullptr; }
bool Symbol::isQtPropertyDeclaration() const
{ return asQtPropertyDeclaration() != nullptr; }
bool Symbol::isQtEnum() const
{ return asQtEnum() != nullptr; }
bool Symbol::isBlock() const
{ return asBlock() != nullptr; }
bool Symbol::isUsingNamespaceDirective() const
{ return asUsingNamespaceDirective() != nullptr; }
bool Symbol::isUsingDeclaration() const
{ return asUsingDeclaration() != nullptr; }
bool Symbol::isDeclaration() const
{ return asDeclaration() != nullptr; }
bool Symbol::isArgument() const
{ return asArgument() != nullptr; }
bool Symbol::isTypenameArgument() const
{ return asTypenameArgument() != nullptr; }
bool Symbol::isBaseClass() const
{ return asBaseClass() != nullptr; }
bool Symbol::isObjCBaseClass() const
{ return asObjCBaseClass() != nullptr; }
bool Symbol::isObjCBaseProtocol() const
{ return asObjCBaseProtocol() != nullptr; }
bool Symbol::isObjCClass() const
{ return asObjCClass() != nullptr; }
bool Symbol::isObjCForwardClassDeclaration() const
{ return asObjCForwardClassDeclaration() != nullptr; }
bool Symbol::isObjCProtocol() const
{ return asObjCProtocol() != nullptr; }
bool Symbol::isObjCForwardProtocolDeclaration() const
{ return asObjCForwardProtocolDeclaration() != nullptr; }
bool Symbol::isObjCMethod() const
{ return asObjCMethod() != nullptr; }
bool Symbol::isObjCPropertyDeclaration() const
{ return asObjCPropertyDeclaration() != nullptr; }
void Symbol::copy(Symbol *other) void Symbol::copy(Symbol *other)
{ {
_sourceLocation = other->_sourceLocation; _sourceLocation = other->_sourceLocation;

View File

@@ -61,16 +61,16 @@ public:
virtual ~Symbol(); virtual ~Symbol();
/// Returns this Symbol's source location. /// Returns this Symbol's source location.
int sourceLocation() const; int sourceLocation() const { return _sourceLocation; }
/// \returns this Symbol's line number. The line number is 1-based. /// \returns this Symbol's line number. The line number is 1-based.
int line() const; int line() const { return _line; }
/// \returns this Symbol's column number. The column number is 1-based. /// \returns this Symbol's column number. The column number is 1-based.
int column() const; int column() const { return _column; }
/// Returns this Symbol's file name. /// Returns this Symbol's file name.
const StringLiteral *fileId() const; const StringLiteral *fileId() const { return _fileId; }
/// Returns this Symbol's file name. /// Returns this Symbol's file name.
const char *fileName() const; const char *fileName() const;
@@ -79,7 +79,7 @@ public:
int fileNameLength() const; int fileNameLength() const;
/// Returns this Symbol's name. /// Returns this Symbol's name.
const Name *name() const; const Name *name() const { return _name; }
/// Sets this Symbol's name. /// Sets this Symbol's name.
void setName(const Name *name); // ### dangerous void setName(const Name *name); // ### dangerous
@@ -88,115 +88,46 @@ public:
const Identifier *identifier() const; const Identifier *identifier() const;
/// Returns this Symbol's storage class specifier. /// Returns this Symbol's storage class specifier.
int storage() const; int storage() const { return _storage; }
/// Sets this Symbol's storage class specifier. /// Sets this Symbol's storage class specifier.
void setStorage(int storage); void setStorage(int storage) { _storage = storage; }
/// Returns this Symbol's visibility. /// Returns this Symbol's visibility.
int visibility() const; int visibility() const { return _visibility; }
/// Sets this Symbol's visibility. /// Sets this Symbol's visibility.
void setVisibility(int visibility); void setVisibility(int visibility) { _visibility = visibility; }
/// Returns the next chained Symbol. /// Returns the next chained Symbol.
Symbol *next() const; Symbol *next() const { return _next; }
/// Returns true if this Symbol has friend storage specifier. /// Returns true if this Symbol has friend storage specifier.
bool isFriend() const; bool isFriend() const { return _storage == Friend; }
/// Returns true if this Symbol has register storage specifier. /// Returns true if this Symbol has register storage specifier.
bool isRegister() const; bool isRegister() const { return _storage == Register; }
/// Returns true if this Symbol has static storage specifier. /// Returns true if this Symbol has static storage specifier.
bool isStatic() const; bool isStatic() const { return _storage == Static; }
/// Returns true if this Symbol has extern storage specifier. /// Returns true if this Symbol has extern storage specifier.
bool isExtern() const; bool isExtern() const { return _storage == Extern; }
/// Returns true if this Symbol has mutable storage specifier. /// Returns true if this Symbol has mutable storage specifier.
bool isMutable() const; bool isMutable() const { return _storage == Mutable; }
/// Returns true if this Symbol has typedef storage specifier. /// Returns true if this Symbol has typedef storage specifier.
bool isTypedef() const; bool isTypedef() const { return _storage == Typedef; }
/// Returns true if this Symbol's visibility is public. /// Returns true if this Symbol's visibility is public.
bool isPublic() const; bool isPublic() const { return _visibility == Public; }
/// Returns true if this Symbol's visibility is protected. /// Returns true if this Symbol's visibility is protected.
bool isProtected() const; bool isProtected() const { return _visibility == Protected; }
/// Returns true if this Symbol's visibility is private. /// Returns true if this Symbol's visibility is private.
bool isPrivate() const; bool isPrivate() const { return _visibility == Private; }
/// Returns true if this Symbol is a Scope.
bool isScope() const;
/// Returns true if this Symbol is an Enum.
bool isEnum() const;
/// Returns true if this Symbol is an Function.
bool isFunction() const;
/// Returns true if this Symbol is a Namespace.
bool isNamespace() const;
/// Returns true if this Symbol is a Template.
bool isTemplate() const;
/// Returns true if this Symbol is a Class.
bool isClass() const;
/// Returns true if this Symbol is a Block.
bool isBlock() const;
/// Returns true if this Symbol is a UsingNamespaceDirective.
bool isUsingNamespaceDirective() const;
/// Returns true if this Symbol is a UsingDeclaration.
bool isUsingDeclaration() const;
/// Returns true if this Symbol is a Declaration.
bool isDeclaration() const;
/// Returns true if this Symbol is an Argument.
bool isArgument() const;
/// Returns true if this Symbol is a Typename argument.
bool isTypenameArgument() const;
/// Returns true if this Symbol is a BaseClass.
bool isBaseClass() const;
/// Returns true if this Symbol is a ForwardClassDeclaration.
bool isForwardClassDeclaration() const;
/// Returns true if this Symbol is a QtPropertyDeclaration.
bool isQtPropertyDeclaration() const;
/// Returns true if this Symbol is a QtEnum.
bool isQtEnum() const;
bool isObjCBaseClass() const;
bool isObjCBaseProtocol() const;
/// Returns true if this Symbol is an Objective-C Class declaration.
bool isObjCClass() const;
/// Returns true if this Symbol is an Objective-C Class forward declaration.
bool isObjCForwardClassDeclaration() const;
/// Returns true if this Symbol is an Objective-C Protocol declaration.
bool isObjCProtocol() const;
/// Returns true if this Symbol is an Objective-C Protocol forward declaration.
bool isObjCForwardProtocolDeclaration() const;
/// Returns true if this Symbol is an Objective-C method declaration.
bool isObjCMethod() const;
/// Returns true if this Symbol is an Objective-C @property declaration.
bool isObjCPropertyDeclaration() const;
Utils::Link toLink() const; Utils::Link toLink() const;
@@ -226,53 +157,98 @@ public:
virtual const ObjCMethod *asObjCMethod() const { return nullptr; } virtual const ObjCMethod *asObjCMethod() const { return nullptr; }
virtual const ObjCPropertyDeclaration *asObjCPropertyDeclaration() const { return nullptr; } virtual const ObjCPropertyDeclaration *asObjCPropertyDeclaration() const { return nullptr; }
/// Returns this Symbol as a Scope.
virtual Scope *asScope() { return nullptr; } virtual Scope *asScope() { return nullptr; }
/// Returns this Symbol as an Enum.
virtual Enum *asEnum() { return nullptr; } virtual Enum *asEnum() { return nullptr; }
/// Returns this Symbol as an Function.
virtual Function *asFunction() { return nullptr; } virtual Function *asFunction() { return nullptr; }
/// Returns this Symbol as a Namespace.
virtual Namespace *asNamespace() { return nullptr; } virtual Namespace *asNamespace() { return nullptr; }
/// Returns this Symbol as a Template.
virtual Template *asTemplate() { return nullptr; } virtual Template *asTemplate() { return nullptr; }
virtual NamespaceAlias *asNamespaceAlias() { return nullptr; } virtual NamespaceAlias *asNamespaceAlias() { return nullptr; }
/// Returns this Symbol as a Class.
virtual Class *asClass() { return nullptr; } virtual Class *asClass() { return nullptr; }
/// Returns this Symbol as a Block.
virtual Block *asBlock() { return nullptr; } virtual Block *asBlock() { return nullptr; }
/// Returns this Symbol as a UsingNamespaceDirective.
virtual UsingNamespaceDirective *asUsingNamespaceDirective() { return nullptr; } virtual UsingNamespaceDirective *asUsingNamespaceDirective() { return nullptr; }
/// Returns this Symbol as a UsingDeclaration.
virtual UsingDeclaration *asUsingDeclaration() { return nullptr; } virtual UsingDeclaration *asUsingDeclaration() { return nullptr; }
/// Returns this Symbol as a Declaration.
virtual Declaration *asDeclaration() { return nullptr; } virtual Declaration *asDeclaration() { return nullptr; }
/// Returns this Symbol as an Argument.
virtual Argument *asArgument() { return nullptr; } virtual Argument *asArgument() { return nullptr; }
/// Returns this Symbol as a Typename argument.
virtual TypenameArgument *asTypenameArgument() { return nullptr; } virtual TypenameArgument *asTypenameArgument() { return nullptr; }
/// Returns this Symbol as a BaseClass.
virtual BaseClass *asBaseClass() { return nullptr; } virtual BaseClass *asBaseClass() { return nullptr; }
/// Returns this Symbol as a ForwardClassDeclaration.
virtual ForwardClassDeclaration *asForwardClassDeclaration() { return nullptr; } virtual ForwardClassDeclaration *asForwardClassDeclaration() { return nullptr; }
/// Returns this Symbol as a QtPropertyDeclaration.
virtual QtPropertyDeclaration *asQtPropertyDeclaration() { return nullptr; } virtual QtPropertyDeclaration *asQtPropertyDeclaration() { return nullptr; }
/// Returns this Symbol as a QtEnum.
virtual QtEnum *asQtEnum() { return nullptr; } virtual QtEnum *asQtEnum() { return nullptr; }
virtual ObjCBaseClass *asObjCBaseClass() { return nullptr; } virtual ObjCBaseClass *asObjCBaseClass() { return nullptr; }
virtual ObjCBaseProtocol *asObjCBaseProtocol() { return nullptr; } virtual ObjCBaseProtocol *asObjCBaseProtocol() { return nullptr; }
/// Returns this Symbol as an Objective-C Class declaration.
virtual ObjCClass *asObjCClass() { return nullptr; } virtual ObjCClass *asObjCClass() { return nullptr; }
/// Returns this Symbol as an Objective-C Class forward declaration.
virtual ObjCForwardClassDeclaration *asObjCForwardClassDeclaration() { return nullptr; } virtual ObjCForwardClassDeclaration *asObjCForwardClassDeclaration() { return nullptr; }
/// Returns this Symbol as an Objective-C Protocol declaration.
virtual ObjCProtocol *asObjCProtocol() { return nullptr; } virtual ObjCProtocol *asObjCProtocol() { return nullptr; }
/// Returns this Symbol as an Objective-C Protocol forward declaration.
virtual ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration() { return nullptr; } virtual ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration() { return nullptr; }
/// Returns this Symbol as an Objective-C method declaration.
virtual ObjCMethod *asObjCMethod() { return nullptr; } virtual ObjCMethod *asObjCMethod() { return nullptr; }
/// Returns this Symbol as an Objective-C @property declaration.
virtual ObjCPropertyDeclaration *asObjCPropertyDeclaration() { return nullptr; } virtual ObjCPropertyDeclaration *asObjCPropertyDeclaration() { return nullptr; }
/// Returns this Symbol's type. /// Returns this Symbol's type.
virtual FullySpecifiedType type() const = 0; virtual FullySpecifiedType type() const = 0;
/// Returns this Symbol's hash value. /// Returns this Symbol's hash value.
unsigned hashCode() const; unsigned hashCode() const { return _hashCode; }
/// Returns this Symbol's index. /// Returns this Symbol's index.
unsigned index() const; unsigned index() const { return _index; }
const Name *unqualifiedName() const; const Name *unqualifiedName() const;
bool isGenerated() const; bool isGenerated() const { return _isGenerated; }
bool isDeprecated() const; bool isDeprecated() const { return _isDeprecated; }
void setDeprecated(bool isDeprecated); void setDeprecated(bool isDeprecated) { _isDeprecated = isDeprecated; }
bool isUnavailable() const; bool isUnavailable() const { return _isUnavailable; }
void setUnavailable(bool isUnavailable); void setUnavailable(bool isUnavailable) { _isUnavailable = isUnavailable; }
/// Returns this Symbol's eclosing scope. /// Returns this Symbol's eclosing scope.
Scope *enclosingScope() const; Scope *enclosingScope() const { return _enclosingScope; }
/// Returns the eclosing namespace scope. /// Returns the eclosing namespace scope.
Namespace *enclosingNamespace() const; Namespace *enclosingNamespace() const;

View File

@@ -42,15 +42,13 @@ UsingNamespaceDirective::UsingNamespaceDirective(Clone *clone, Subst *subst, Usi
: Symbol(clone, subst, original) : Symbol(clone, subst, original)
{ } { }
UsingNamespaceDirective::~UsingNamespaceDirective()
{ }
FullySpecifiedType UsingNamespaceDirective::type() const FullySpecifiedType UsingNamespaceDirective::type() const
{ return FullySpecifiedType(); } { return FullySpecifiedType(); }
void UsingNamespaceDirective::visitSymbol0(SymbolVisitor *visitor) void UsingNamespaceDirective::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
NamespaceAlias::NamespaceAlias(TranslationUnit *translationUnit, NamespaceAlias::NamespaceAlias(TranslationUnit *translationUnit,
int sourceLocation, const Name *name) int sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name), _namespaceName(nullptr) : Symbol(translationUnit, sourceLocation, name), _namespaceName(nullptr)
@@ -61,15 +59,6 @@ NamespaceAlias::NamespaceAlias(Clone *clone, Subst *subst, NamespaceAlias *origi
, _namespaceName(clone->name(original->_namespaceName, subst)) , _namespaceName(clone->name(original->_namespaceName, subst))
{ } { }
NamespaceAlias::~NamespaceAlias()
{ }
const Name *NamespaceAlias::namespaceName() const
{ return _namespaceName; }
void NamespaceAlias::setNamespaceName(const Name *namespaceName)
{ _namespaceName = namespaceName; }
FullySpecifiedType NamespaceAlias::type() const FullySpecifiedType NamespaceAlias::type() const
{ return FullySpecifiedType(); } { return FullySpecifiedType(); }
@@ -86,15 +75,13 @@ UsingDeclaration::UsingDeclaration(Clone *clone, Subst *subst, UsingDeclaration
: Symbol(clone, subst, original) : Symbol(clone, subst, original)
{ } { }
UsingDeclaration::~UsingDeclaration()
{ }
FullySpecifiedType UsingDeclaration::type() const FullySpecifiedType UsingDeclaration::type() const
{ return FullySpecifiedType(); } { return FullySpecifiedType(); }
void UsingDeclaration::visitSymbol0(SymbolVisitor *visitor) void CPlusPlus::UsingDeclaration::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
Declaration::Declaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name) Declaration::Declaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name) : Symbol(translationUnit, sourceLocation, name)
, _initializer(nullptr) , _initializer(nullptr)
@@ -204,41 +191,16 @@ Declaration::Declaration(Clone *clone, Subst *subst, Declaration *original)
_type = newType; _type = newType;
} }
Declaration::~Declaration()
{ }
void Declaration::setType(const FullySpecifiedType &type)
{ _type = type; }
void Declaration::setInitializer(const StringLiteral *initializer)
{
_initializer = initializer;
}
FullySpecifiedType Declaration::type() const
{ return _type; }
const StringLiteral *Declaration::getInitializer() const
{
return _initializer;
}
void Declaration::visitSymbol0(SymbolVisitor *visitor) void Declaration::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
EnumeratorDeclaration::EnumeratorDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name) EnumeratorDeclaration::EnumeratorDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
: Declaration(translationUnit, sourceLocation, name) : Declaration(translationUnit, sourceLocation, name)
, _constantValue(nullptr) , _constantValue(nullptr)
{} {}
EnumeratorDeclaration::~EnumeratorDeclaration()
{}
const StringLiteral *EnumeratorDeclaration::constantValue() const
{ return _constantValue; }
void EnumeratorDeclaration::setConstantValue(const StringLiteral *constantValue)
{ _constantValue = constantValue; }
Argument::Argument(TranslationUnit *translationUnit, int sourceLocation, const Name *name) Argument::Argument(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name), : Symbol(translationUnit, sourceLocation, name),
@@ -251,27 +213,10 @@ Argument::Argument(Clone *clone, Subst *subst, Argument *original)
, _type(clone->type(original->_type, subst)) , _type(clone->type(original->_type, subst))
{ } { }
Argument::~Argument()
{ }
bool Argument::hasInitializer() const
{ return _initializer != nullptr; }
const StringLiteral *Argument::initializer() const
{ return _initializer; }
void Argument::setInitializer(const StringLiteral *initializer)
{ _initializer = initializer; }
void Argument::setType(const FullySpecifiedType &type)
{ _type = type; }
FullySpecifiedType Argument::type() const
{ return _type; }
void Argument::visitSymbol0(SymbolVisitor *visitor) void Argument::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
TypenameArgument::TypenameArgument(TranslationUnit *translationUnit, int sourceLocation, const Name *name) TypenameArgument::TypenameArgument(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name) : Symbol(translationUnit, sourceLocation, name)
, _isClassDeclarator(false) , _isClassDeclarator(false)
@@ -283,18 +228,10 @@ TypenameArgument::TypenameArgument(Clone *clone, Subst *subst, TypenameArgument
, _isClassDeclarator(original->_isClassDeclarator) , _isClassDeclarator(original->_isClassDeclarator)
{ } { }
TypenameArgument::~TypenameArgument()
{ }
void TypenameArgument::setType(const FullySpecifiedType &type)
{ _type = type; }
FullySpecifiedType TypenameArgument::type() const
{ return _type; }
void TypenameArgument::visitSymbol0(SymbolVisitor *visitor) void TypenameArgument::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
Function::Function(TranslationUnit *translationUnit, int sourceLocation, const Name *name) Function::Function(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
: Scope(translationUnit, sourceLocation, name), : Scope(translationUnit, sourceLocation, name),
_flags(0) _flags(0)
@@ -307,27 +244,6 @@ Function::Function(Clone *clone, Subst *subst, Function *original)
, _flags(original->_flags) , _flags(original->_flags)
{ } { }
Function::~Function()
{ }
bool Function::isNormal() const
{ return f._methodKey == NormalMethod; }
bool Function::isSignal() const
{ return f._methodKey == SignalMethod; }
bool Function::isSlot() const
{ return f._methodKey == SlotMethod; }
bool Function::isInvokable() const
{ return f._methodKey == InvokableMethod; }
int Function::methodKey() const
{ return f._methodKey; }
void Function::setMethodKey(int key)
{ f._methodKey = key; }
bool Function::isSignatureEqualTo(const Function *other, Matcher *matcher) const bool Function::isSignatureEqualTo(const Function *other, Matcher *matcher) const
{ {
if (! other) if (! other)
@@ -409,12 +325,6 @@ FullySpecifiedType Function::type() const
return ty; return ty;
} }
FullySpecifiedType Function::returnType() const
{ return _returnType; }
void Function::setReturnType(const FullySpecifiedType &returnType)
{ _returnType = returnType; }
bool Function::hasReturnType() const bool Function::hasReturnType() const
{ {
const FullySpecifiedType ty = returnType(); const FullySpecifiedType ty = returnType();
@@ -431,7 +341,7 @@ int Function::argumentCount() const
// arguments with a lambda as default argument will also have more blocks. // arguments with a lambda as default argument will also have more blocks.
int argc = 0; int argc = 0;
for (int it = 0; it < memCnt; ++it) for (int it = 0; it < memCnt; ++it)
if (memberAt(it)->isArgument()) if (memberAt(it)->asArgument())
++argc; ++argc;
return argc; return argc;
} }
@@ -470,66 +380,6 @@ int Function::minimumArgumentCount() const
return index; return index;
} }
bool Function::isVirtual() const
{ return f._isVirtual; }
void Function::setVirtual(bool isVirtual)
{ f._isVirtual = isVirtual; }
bool Function::isOverride() const
{ return f._isOverride; }
void Function::setOverride(bool isOverride)
{ f._isOverride = isOverride; }
bool Function::isFinal() const
{ return f._isFinal; }
void Function::setFinal(bool isFinal)
{ f._isFinal = isFinal; }
bool Function::isVariadic() const
{ return f._isVariadic; }
void Function::setVariadic(bool isVariadic)
{ f._isVariadic = isVariadic; }
bool Function::isVariadicTemplate() const
{ return f._isVariadicTemplate; }
void Function::setVariadicTemplate(bool isVariadicTemplate)
{ f._isVariadicTemplate = isVariadicTemplate; }
bool Function::isConst() const
{ return f._isConst; }
void Function::setConst(bool isConst)
{ f._isConst = isConst; }
bool Function::isVolatile() const
{ return f._isVolatile; }
void Function::setVolatile(bool isVolatile)
{ f._isVolatile = isVolatile; }
bool Function::isPureVirtual() const
{ return f._isPureVirtual; }
void Function::setPureVirtual(bool isPureVirtual)
{ f._isPureVirtual = isPureVirtual; }
Function::RefQualifier Function::refQualifier() const
{ return static_cast<RefQualifier>(f._refQualifier); }
void Function::setRefQualifier(Function::RefQualifier refQualifier)
{ f._refQualifier = refQualifier; }
bool Function::isAmbiguous() const
{ return f._isAmbiguous; }
void Function::setAmbiguous(bool isAmbiguous)
{ f._isAmbiguous = isAmbiguous; }
void Function::visitSymbol0(SymbolVisitor *visitor) void Function::visitSymbol0(SymbolVisitor *visitor)
{ {
if (visitor->visit(this)) { if (visitor->visit(this)) {
@@ -569,11 +419,6 @@ bool Function::maybeValidPrototype(int actualArgumentCount) const
return true; return true;
} }
const StringLiteral *Function::exceptionSpecification()
{ return _exceptionSpecification; }
void Function::setExceptionSpecification(const StringLiteral *spec)
{ _exceptionSpecification = spec; }
Block::Block(TranslationUnit *translationUnit, int sourceLocation) Block::Block(TranslationUnit *translationUnit, int sourceLocation)
: Scope(translationUnit, sourceLocation, /*name = */ nullptr) : Scope(translationUnit, sourceLocation, /*name = */ nullptr)
@@ -583,9 +428,6 @@ Block::Block(Clone *clone, Subst *subst, Block *original)
: Scope(clone, subst, original) : Scope(clone, subst, original)
{ } { }
Block::~Block()
{ }
FullySpecifiedType Block::type() const FullySpecifiedType Block::type() const
{ return FullySpecifiedType(); } { return FullySpecifiedType(); }
@@ -608,21 +450,9 @@ Enum::Enum(Clone *clone, Subst *subst, Enum *original)
, _isScoped(original->isScoped()) , _isScoped(original->isScoped())
{ } { }
Enum::~Enum()
{ }
FullySpecifiedType Enum::type() const FullySpecifiedType Enum::type() const
{ return FullySpecifiedType(const_cast<Enum *>(this)); } { return FullySpecifiedType(const_cast<Enum *>(this)); }
bool Enum::isScoped() const
{
return _isScoped;
}
void Enum::setScoped(bool scoped)
{
_isScoped = scoped;
}
void Enum::accept0(TypeVisitor *visitor) void Enum::accept0(TypeVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
@@ -652,9 +482,6 @@ Template::Template(Clone *clone, Subst *subst, Template *original)
: Scope(clone, subst, original) : Scope(clone, subst, original)
{ } { }
Template::~Template()
{ }
int Template::templateParameterCount() const int Template::templateParameterCount() const
{ {
if (declaration() != nullptr) if (declaration() != nullptr)
@@ -663,17 +490,14 @@ int Template::templateParameterCount() const
return 0; return 0;
} }
Symbol *Template::templateParameterAt(int index) const
{ return memberAt(index); }
Symbol *Template::declaration() const Symbol *Template::declaration() const
{ {
if (isEmpty()) if (isEmpty())
return nullptr; return nullptr;
if (Symbol *s = memberAt(memberCount() - 1)) { if (Symbol *s = memberAt(memberCount() - 1)) {
if (s->isClass() || s->isForwardClassDeclaration() || if (s->asClass() || s->asForwardClassDeclaration() ||
s->isTemplate() || s->isFunction() || s->isDeclaration()) s->asTemplate() || s->asFunction() || s->asDeclaration())
return s; return s;
} }
@@ -712,9 +536,6 @@ Namespace::Namespace(Clone *clone, Subst *subst, Namespace *original)
, _isInline(original->_isInline) , _isInline(original->_isInline)
{ } { }
Namespace::~Namespace()
{ }
void Namespace::accept0(TypeVisitor *visitor) void Namespace::accept0(TypeVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
@@ -749,30 +570,10 @@ BaseClass::BaseClass(Clone *clone, Subst *subst, BaseClass *original)
, _type(clone->type(original->_type, subst)) , _type(clone->type(original->_type, subst))
{ } { }
BaseClass::~BaseClass()
{ }
FullySpecifiedType BaseClass::type() const
{ return _type; }
void BaseClass::setType(const FullySpecifiedType &type)
{ _type = type; }
bool BaseClass::isVirtual() const
{ return _isVirtual; }
void BaseClass::setVirtual(bool isVirtual)
{ _isVirtual = isVirtual; }
bool BaseClass::isVariadic() const
{ return _isVariadic; }
void BaseClass::setVariadic(bool isVariadic)
{ _isVariadic = isVariadic; }
void BaseClass::visitSymbol0(SymbolVisitor *visitor) void BaseClass::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
ForwardClassDeclaration::ForwardClassDeclaration(TranslationUnit *translationUnit, ForwardClassDeclaration::ForwardClassDeclaration(TranslationUnit *translationUnit,
int sourceLocation, const Name *name) int sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name) : Symbol(translationUnit, sourceLocation, name)
@@ -782,9 +583,6 @@ ForwardClassDeclaration::ForwardClassDeclaration(Clone *clone, Subst *subst, For
: Symbol(clone, subst, original) : Symbol(clone, subst, original)
{ } { }
ForwardClassDeclaration::~ForwardClassDeclaration()
{ }
FullySpecifiedType ForwardClassDeclaration::type() const FullySpecifiedType ForwardClassDeclaration::type() const
{ return FullySpecifiedType(const_cast<ForwardClassDeclaration *>(this)); } { return FullySpecifiedType(const_cast<ForwardClassDeclaration *>(this)); }
@@ -815,24 +613,6 @@ Class::Class(Clone *clone, Subst *subst, Class *original)
addBaseClass(clone->symbol(original->_baseClasses.at(i), subst)->asBaseClass()); addBaseClass(clone->symbol(original->_baseClasses.at(i), subst)->asBaseClass());
} }
Class::~Class()
{ }
bool Class::isClass() const
{ return _key == ClassKey; }
bool Class::isStruct() const
{ return _key == StructKey; }
bool Class::isUnion() const
{ return _key == UnionKey; }
Class::Key Class::classKey() const
{ return _key; }
void Class::setClassKey(Key key)
{ _key = key; }
void Class::accept0(TypeVisitor *visitor) void Class::accept0(TypeVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
@@ -880,21 +660,6 @@ QtPropertyDeclaration::QtPropertyDeclaration(Clone *clone, Subst *subst, QtPrope
, _flags(original->_flags) , _flags(original->_flags)
{ } { }
QtPropertyDeclaration::~QtPropertyDeclaration()
{ }
void QtPropertyDeclaration::setType(const FullySpecifiedType &type)
{ _type = type; }
void QtPropertyDeclaration::setFlags(int flags)
{ _flags = flags; }
int QtPropertyDeclaration::flags() const
{ return _flags; }
FullySpecifiedType QtPropertyDeclaration::type() const
{ return _type; }
void QtPropertyDeclaration::visitSymbol0(SymbolVisitor *visitor) void QtPropertyDeclaration::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
@@ -907,12 +672,6 @@ QtEnum::QtEnum(Clone *clone, Subst *subst, QtEnum *original)
: Symbol(clone, subst, original) : Symbol(clone, subst, original)
{ } { }
QtEnum::~QtEnum()
{ }
FullySpecifiedType QtEnum::type() const
{ return FullySpecifiedType(); }
void QtEnum::visitSymbol0(SymbolVisitor *visitor) void QtEnum::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
@@ -925,8 +684,6 @@ ObjCBaseClass::ObjCBaseClass(Clone *clone, Subst *subst, ObjCBaseClass *original
: Symbol(clone, subst, original) : Symbol(clone, subst, original)
{ } { }
ObjCBaseClass::~ObjCBaseClass()
{ }
FullySpecifiedType ObjCBaseClass::type() const FullySpecifiedType ObjCBaseClass::type() const
{ return FullySpecifiedType(); } { return FullySpecifiedType(); }
@@ -942,9 +699,6 @@ ObjCBaseProtocol::ObjCBaseProtocol(Clone *clone, Subst *subst, ObjCBaseProtocol
: Symbol(clone, subst, original) : Symbol(clone, subst, original)
{ } { }
ObjCBaseProtocol::~ObjCBaseProtocol()
{ }
FullySpecifiedType ObjCBaseProtocol::type() const FullySpecifiedType ObjCBaseProtocol::type() const
{ return FullySpecifiedType(); } { return FullySpecifiedType(); }
@@ -970,30 +724,6 @@ ObjCClass::ObjCClass(Clone *clone, Subst *subst, ObjCClass *original)
addProtocol(clone->symbol(original->_protocols.at(i), subst)->asObjCBaseProtocol()); addProtocol(clone->symbol(original->_protocols.at(i), subst)->asObjCBaseProtocol());
} }
ObjCClass::~ObjCClass()
{}
bool ObjCClass::isInterface() const
{ return _isInterface; }
void ObjCClass::setInterface(bool isInterface)
{ _isInterface = isInterface; }
bool ObjCClass::isCategory() const
{ return _categoryName != nullptr; }
const Name *ObjCClass::categoryName() const
{ return _categoryName; }
void ObjCClass::setCategoryName(const Name *categoryName)
{ _categoryName = categoryName; }
ObjCBaseClass *ObjCClass::baseClass() const
{ return _baseClass; }
void ObjCClass::setBaseClass(ObjCBaseClass *baseClass)
{ _baseClass = baseClass; }
int ObjCClass::protocolCount() const int ObjCClass::protocolCount() const
{ return int(_protocols.size()); } { return int(_protocols.size()); }
@@ -1043,9 +773,6 @@ ObjCProtocol::ObjCProtocol(Clone *clone, Subst *subst, ObjCProtocol *original)
addProtocol(clone->symbol(original->_protocols.at(i), subst)->asObjCBaseProtocol()); addProtocol(clone->symbol(original->_protocols.at(i), subst)->asObjCBaseProtocol());
} }
ObjCProtocol::~ObjCProtocol()
{}
int ObjCProtocol::protocolCount() const int ObjCProtocol::protocolCount() const
{ return int(_protocols.size()); } { return int(_protocols.size()); }
@@ -1087,9 +814,6 @@ ObjCForwardClassDeclaration::ObjCForwardClassDeclaration(Clone *clone, Subst *su
: Symbol(clone, subst, original) : Symbol(clone, subst, original)
{ } { }
ObjCForwardClassDeclaration::~ObjCForwardClassDeclaration()
{}
FullySpecifiedType ObjCForwardClassDeclaration::type() const FullySpecifiedType ObjCForwardClassDeclaration::type() const
{ return FullySpecifiedType(); } { return FullySpecifiedType(); }
@@ -1117,9 +841,6 @@ ObjCForwardProtocolDeclaration::ObjCForwardProtocolDeclaration(Clone *clone, Sub
: Symbol(clone, subst, original) : Symbol(clone, subst, original)
{ } { }
ObjCForwardProtocolDeclaration::~ObjCForwardProtocolDeclaration()
{}
FullySpecifiedType ObjCForwardProtocolDeclaration::type() const FullySpecifiedType ObjCForwardProtocolDeclaration::type() const
{ return FullySpecifiedType(); } { return FullySpecifiedType(); }
@@ -1148,9 +869,6 @@ ObjCMethod::ObjCMethod(Clone *clone, Subst *subst, ObjCMethod *original)
, _flags(original->_flags) , _flags(original->_flags)
{ } { }
ObjCMethod::~ObjCMethod()
{ }
void ObjCMethod::accept0(TypeVisitor *visitor) void ObjCMethod::accept0(TypeVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
@@ -1165,12 +883,6 @@ bool ObjCMethod::match0(const Type *otherType, Matcher *matcher) const
FullySpecifiedType ObjCMethod::type() const FullySpecifiedType ObjCMethod::type() const
{ return FullySpecifiedType(const_cast<ObjCMethod *>(this)); } { return FullySpecifiedType(const_cast<ObjCMethod *>(this)); }
FullySpecifiedType ObjCMethod::returnType() const
{ return _returnType; }
void ObjCMethod::setReturnType(const FullySpecifiedType &returnType)
{ _returnType = returnType; }
bool ObjCMethod::hasReturnType() const bool ObjCMethod::hasReturnType() const
{ {
const FullySpecifiedType ty = returnType(); const FullySpecifiedType ty = returnType();
@@ -1180,7 +892,7 @@ bool ObjCMethod::hasReturnType() const
int ObjCMethod::argumentCount() const int ObjCMethod::argumentCount() const
{ {
const int c = memberCount(); const int c = memberCount();
if (c > 0 && memberAt(c - 1)->isBlock()) if (c > 0 && memberAt(c - 1)->asBlock())
return c - 1; return c - 1;
return c; return c;
} }
@@ -1196,12 +908,6 @@ bool ObjCMethod::hasArguments() const
(argumentCount() == 1 && argumentAt(0)->type()->isVoidType())); (argumentCount() == 1 && argumentAt(0)->type()->isVoidType()));
} }
bool ObjCMethod::isVariadic() const
{ return f._isVariadic; }
void ObjCMethod::setVariadic(bool isVariadic)
{ f._isVariadic = isVariadic; }
void ObjCMethod::visitSymbol0(SymbolVisitor *visitor) void ObjCMethod::visitSymbol0(SymbolVisitor *visitor)
{ {
if (visitor->visit(this)) { if (visitor->visit(this)) {
@@ -1228,39 +934,6 @@ ObjCPropertyDeclaration::ObjCPropertyDeclaration(Clone *clone, Subst *subst, Obj
, _propertyAttributes(original->_propertyAttributes) , _propertyAttributes(original->_propertyAttributes)
{ } { }
ObjCPropertyDeclaration::~ObjCPropertyDeclaration()
{}
bool ObjCPropertyDeclaration::hasAttribute(int attribute) const
{ return _propertyAttributes & attribute; }
void ObjCPropertyDeclaration::setAttributes(int attributes)
{ _propertyAttributes = attributes; }
bool ObjCPropertyDeclaration::hasGetter() const
{ return hasAttribute(Getter); }
bool ObjCPropertyDeclaration::hasSetter() const
{ return hasAttribute(Setter); }
const Name *ObjCPropertyDeclaration::getterName() const
{ return _getterName; }
void ObjCPropertyDeclaration::setGetterName(const Name *getterName)
{ _getterName = getterName; }
const Name *ObjCPropertyDeclaration::setterName() const
{ return _setterName; }
void ObjCPropertyDeclaration::setSetterName(const Name *setterName)
{ _setterName = setterName; }
void ObjCPropertyDeclaration::setType(const FullySpecifiedType &type)
{ _type = type; }
FullySpecifiedType ObjCPropertyDeclaration::type() const
{ return _type; }
void ObjCPropertyDeclaration::visitSymbol0(SymbolVisitor *visitor) void ObjCPropertyDeclaration::visitSymbol0(SymbolVisitor *visitor)
{ {
if (visitor->visit(this)) { if (visitor->visit(this)) {

View File

@@ -31,64 +31,55 @@ namespace CPlusPlus {
class StringLiteral; class StringLiteral;
class CPLUSPLUS_EXPORT UsingNamespaceDirective: public Symbol class CPLUSPLUS_EXPORT UsingNamespaceDirective final : public Symbol
{ {
public: public:
UsingNamespaceDirective(TranslationUnit *translationUnit, int sourceLocation, const Name *name); UsingNamespaceDirective(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
UsingNamespaceDirective(Clone *clone, Subst *subst, UsingNamespaceDirective *original); UsingNamespaceDirective(Clone *clone, Subst *subst, UsingNamespaceDirective *original);
virtual ~UsingNamespaceDirective(); ~UsingNamespaceDirective() override = default;
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override;
const UsingNamespaceDirective *asUsingNamespaceDirective() const override const UsingNamespaceDirective *asUsingNamespaceDirective() const override { return this; }
{ return this; } UsingNamespaceDirective *asUsingNamespaceDirective() override { return this; }
UsingNamespaceDirective *asUsingNamespaceDirective() override
{ return this; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
}; };
class CPLUSPLUS_EXPORT UsingDeclaration: public Symbol class CPLUSPLUS_EXPORT UsingDeclaration final : public Symbol
{ {
public: public:
UsingDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name); UsingDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
UsingDeclaration(Clone *clone, Subst *subst, UsingDeclaration *original); UsingDeclaration(Clone *clone, Subst *subst, UsingDeclaration *original);
virtual ~UsingDeclaration(); ~UsingDeclaration() override = default;
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override;
const UsingDeclaration *asUsingDeclaration() const override const UsingDeclaration *asUsingDeclaration() const override { return this; }
{ return this; } UsingDeclaration *asUsingDeclaration() override { return this; }
UsingDeclaration *asUsingDeclaration() override
{ return this; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
}; };
class CPLUSPLUS_EXPORT NamespaceAlias: public Symbol class CPLUSPLUS_EXPORT NamespaceAlias final : public Symbol
{ {
public: public:
NamespaceAlias(TranslationUnit *translationUnit, int sourceLocation, const Name *name); NamespaceAlias(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
NamespaceAlias(Clone *clone, Subst *subst, NamespaceAlias *original); NamespaceAlias(Clone *clone, Subst *subst, NamespaceAlias *original);
virtual ~NamespaceAlias(); ~NamespaceAlias() override = default;
const Name *namespaceName() const; const Name *namespaceName() const { return _namespaceName; }
void setNamespaceName(const Name *namespaceName); void setNamespaceName(const Name *namespaceName) { _namespaceName = namespaceName; }
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override;
const NamespaceAlias *asNamespaceAlias() const override const NamespaceAlias *asNamespaceAlias() const override { return this; }
{ return this; } NamespaceAlias *asNamespaceAlias() override { return this; }
NamespaceAlias *asNamespaceAlias() override
{ return this; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
@@ -97,31 +88,25 @@ private:
const Name *_namespaceName; const Name *_namespaceName;
}; };
class CPLUSPLUS_EXPORT Declaration: public Symbol class CPLUSPLUS_EXPORT Declaration : public Symbol
{ {
public: public:
Declaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name); Declaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
Declaration(Clone *clone, Subst *subst, Declaration *original); Declaration(Clone *clone, Subst *subst, Declaration *original);
virtual ~Declaration(); ~Declaration() override = default;
void setType(const FullySpecifiedType &type); void setType(const FullySpecifiedType &type) { _type = type; }
void setInitializer(StringLiteral const* initializer); void setInitializer(StringLiteral const* initializer) { _initializer = initializer; }
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override { return _type; }
const StringLiteral *getInitializer() const; const StringLiteral *getInitializer() const { return _initializer; }
const Declaration *asDeclaration() const override const Declaration *asDeclaration() const override { return this; }
{ return this; } Declaration *asDeclaration() override { return this; }
Declaration *asDeclaration() override virtual EnumeratorDeclaration *asEnumeratorDeclarator() { return nullptr; }
{ return this; } virtual const EnumeratorDeclaration *asEnumeratorDeclarator() const { return nullptr; }
virtual EnumeratorDeclaration *asEnumeratorDeclarator()
{ return nullptr; }
virtual const EnumeratorDeclaration *asEnumeratorDeclarator() const
{ return nullptr; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
@@ -131,47 +116,41 @@ private:
const StringLiteral *_initializer; const StringLiteral *_initializer;
}; };
class CPLUSPLUS_EXPORT EnumeratorDeclaration: public Declaration class CPLUSPLUS_EXPORT EnumeratorDeclaration final : public Declaration
{ {
public: public:
EnumeratorDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name); EnumeratorDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
virtual ~EnumeratorDeclaration(); ~EnumeratorDeclaration() override = default;
const StringLiteral *constantValue() const; const StringLiteral *constantValue() const { return _constantValue; }
void setConstantValue(const StringLiteral *constantValue); void setConstantValue(const StringLiteral *constantValue) { _constantValue = constantValue; }
EnumeratorDeclaration *asEnumeratorDeclarator() override EnumeratorDeclaration *asEnumeratorDeclarator() override { return this; }
{ return this; } const EnumeratorDeclaration *asEnumeratorDeclarator() const override { return this; }
const EnumeratorDeclaration *asEnumeratorDeclarator() const override
{ return this; }
private: private:
const StringLiteral *_constantValue; const StringLiteral *_constantValue;
}; };
class CPLUSPLUS_EXPORT Argument: public Symbol class CPLUSPLUS_EXPORT Argument final : public Symbol
{ {
public: public:
Argument(TranslationUnit *translationUnit, int sourceLocation, const Name *name); Argument(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
Argument(Clone *clone, Subst *subst, Argument *original); Argument(Clone *clone, Subst *subst, Argument *original);
virtual ~Argument(); ~Argument() override = default;
void setType(const FullySpecifiedType &type); void setType(const FullySpecifiedType &type) { _type = type; }
bool hasInitializer() const; bool hasInitializer() const { return _initializer != nullptr; }
const StringLiteral *initializer() const; const StringLiteral *initializer() const { return _initializer; }
void setInitializer(const StringLiteral *initializer); void setInitializer(const StringLiteral *initializer) { _initializer = initializer; }
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override { return _type; }
const Argument *asArgument() const override const Argument *asArgument() const override { return this; }
{ return this; } Argument *asArgument() override { return this; }
Argument *asArgument() override
{ return this; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
@@ -181,25 +160,22 @@ private:
FullySpecifiedType _type; FullySpecifiedType _type;
}; };
class CPLUSPLUS_EXPORT TypenameArgument: public Symbol class CPLUSPLUS_EXPORT TypenameArgument final : public Symbol
{ {
public: public:
TypenameArgument(TranslationUnit *translationUnit, int sourceLocation, const Name *name); TypenameArgument(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
TypenameArgument(Clone *clone, Subst *subst, TypenameArgument *original); TypenameArgument(Clone *clone, Subst *subst, TypenameArgument *original);
virtual ~TypenameArgument(); ~TypenameArgument() = default;
void setType(const FullySpecifiedType &type); void setType(const FullySpecifiedType &type) { _type = type; }
void setClassDeclarator(bool isClassDecl) { _isClassDeclarator = isClassDecl; } void setClassDeclarator(bool isClassDecl) { _isClassDeclarator = isClassDecl; }
bool isClassDeclarator() const { return _isClassDeclarator; } bool isClassDeclarator() const { return _isClassDeclarator; }
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override { return _type; }
const TypenameArgument *asTypenameArgument() const override const TypenameArgument *asTypenameArgument() const override { return this; }
{ return this; } TypenameArgument *asTypenameArgument() override { return this; }
TypenameArgument *asTypenameArgument() override
{ return this; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
@@ -209,12 +185,12 @@ private:
bool _isClassDeclarator; bool _isClassDeclarator;
}; };
class CPLUSPLUS_EXPORT Block: public Scope class CPLUSPLUS_EXPORT Block final : public Scope
{ {
public: public:
Block(TranslationUnit *translationUnit, int sourceLocation); Block(TranslationUnit *translationUnit, int sourceLocation);
Block(Clone *clone, Subst *subst, Block *original); Block(Clone *clone, Subst *subst, Block *original);
virtual ~Block(); ~Block() override = default;
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override;
@@ -229,28 +205,22 @@ protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
}; };
class CPLUSPLUS_EXPORT ForwardClassDeclaration: public Symbol, public Type class CPLUSPLUS_EXPORT ForwardClassDeclaration final : public Symbol, public Type
{ {
public: public:
ForwardClassDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name); ForwardClassDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
ForwardClassDeclaration(Clone *clone, Subst *subst, ForwardClassDeclaration *original); ForwardClassDeclaration(Clone *clone, Subst *subst, ForwardClassDeclaration *original);
virtual ~ForwardClassDeclaration(); ~ForwardClassDeclaration() override = default;
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override;
const ForwardClassDeclaration *asForwardClassDeclaration() const override const ForwardClassDeclaration *asForwardClassDeclaration() const override { return this; }
{ return this; } ForwardClassDeclaration *asForwardClassDeclaration() override { return this; }
ForwardClassDeclaration *asForwardClassDeclaration() override
{ return this; }
// Type's interface // Type's interface
const ForwardClassDeclaration *asForwardClassDeclarationType() const override const ForwardClassDeclaration *asForwardClassDeclarationType() const override { return this; }
{ return this; } ForwardClassDeclaration *asForwardClassDeclarationType() override { return this; }
ForwardClassDeclaration *asForwardClassDeclarationType() override
{ return this; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
@@ -258,31 +228,25 @@ protected:
bool match0(const Type *otherType, Matcher *matcher) const override; bool match0(const Type *otherType, Matcher *matcher) const override;
}; };
class CPLUSPLUS_EXPORT Enum: public Scope, public Type class CPLUSPLUS_EXPORT Enum final : public Scope, public Type
{ {
public: public:
Enum(TranslationUnit *translationUnit, int sourceLocation, const Name *name); Enum(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
Enum(Clone *clone, Subst *subst, Enum *original); Enum(Clone *clone, Subst *subst, Enum *original);
virtual ~Enum(); ~Enum() override = default;
bool isScoped() const; bool isScoped() const { return _isScoped; }
void setScoped(bool scoped); void setScoped(bool scoped) { _isScoped = scoped; }
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override;
const Enum *asEnum() const override const Enum *asEnum() const override { return this; }
{ return this; } Enum *asEnum() override { return this; }
Enum *asEnum() override
{ return this; }
// Type's interface // Type's interface
const Enum *asEnumType() const override const Enum *asEnumType() const override { return this; }
{ return this; } Enum *asEnumType() override { return this; }
Enum *asEnumType() override
{ return this; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
@@ -293,7 +257,7 @@ private:
bool _isScoped; bool _isScoped;
}; };
class CPLUSPLUS_EXPORT Function: public Scope, public Type class CPLUSPLUS_EXPORT Function final : public Scope, public Type
{ {
public: public:
enum MethodKey { enum MethodKey {
@@ -312,17 +276,18 @@ public:
public: public:
Function(TranslationUnit *translationUnit, int sourceLocation, const Name *name); Function(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
Function(Clone *clone, Subst *subst, Function *original); Function(Clone *clone, Subst *subst, Function *original);
virtual ~Function(); ~Function() override = default;
bool isNormal() const; bool isNormal() const { return f._methodKey == NormalMethod; }
bool isSignal() const; bool isSignal() const { return f._methodKey == SignalMethod; }
bool isSlot() const; bool isSlot() const { return f._methodKey == SlotMethod; }
bool isInvokable() const; bool isInvokable() const { return f._methodKey == InvokableMethod; }
int methodKey() const;
void setMethodKey(int key);
FullySpecifiedType returnType() const; int methodKey() const { return f._methodKey; }
void setReturnType(const FullySpecifiedType &returnType); void setMethodKey(int key) { f._methodKey = key; }
FullySpecifiedType returnType() const { return _returnType; }
void setReturnType(const FullySpecifiedType &returnType) { _returnType = returnType; }
/** Convenience function that returns whether the function returns something (including void). */ /** Convenience function that returns whether the function returns something (including void). */
bool hasReturnType() const; bool hasReturnType() const;
@@ -334,61 +299,55 @@ public:
bool hasArguments() const; bool hasArguments() const;
int minimumArgumentCount() const; int minimumArgumentCount() const;
bool isVirtual() const; bool isVirtual() const { return f._isVirtual; }
void setVirtual(bool isVirtual); void setVirtual(bool isVirtual) { f._isVirtual = isVirtual; }
bool isOverride() const; bool isOverride() const { return f._isOverride; }
void setOverride(bool isOverride); void setOverride(bool isOverride) { f._isOverride = isOverride; }
bool isFinal() const; bool isFinal() const { return f._isFinal; }
void setFinal(bool isFinal); void setFinal(bool isFinal) { f._isFinal = isFinal; }
bool isVariadic() const; bool isVariadic() const { return f._isVariadic; }
void setVariadic(bool isVariadic); void setVariadic(bool isVariadic) { f._isVariadic = isVariadic; }
bool isVariadicTemplate() const; bool isVariadicTemplate() const { return f._isVariadicTemplate; }
void setVariadicTemplate(bool isVariadicTemplate); void setVariadicTemplate(bool isVariadicTemplate) { f._isVariadicTemplate = isVariadicTemplate; }
bool isConst() const; bool isConst() const { return f._isConst; }
void setConst(bool isConst); void setConst(bool isConst) { f._isConst = isConst; }
bool isStatic() const { return f._isStatic; } bool isStatic() const { return f._isStatic; }
void setStatic(bool isStatic) { f._isStatic = isStatic; } void setStatic(bool isStatic) { f._isStatic = isStatic; }
bool isVolatile() const; bool isVolatile() const { return f._isVolatile; }
void setVolatile(bool isVolatile); void setVolatile(bool isVolatile) { f._isVolatile = isVolatile; }
bool isPureVirtual() const; bool isPureVirtual() const { return f._isPureVirtual; }
void setPureVirtual(bool isPureVirtual); void setPureVirtual(bool isPureVirtual) { f._isPureVirtual = isPureVirtual; }
RefQualifier refQualifier() const; RefQualifier refQualifier() const { return static_cast<RefQualifier>(f._refQualifier); }
void setRefQualifier(RefQualifier refQualifier); void setRefQualifier(RefQualifier refQualifier) { f._refQualifier = refQualifier; }
bool isSignatureEqualTo(const Function *other, Matcher *matcher = nullptr) const; bool isSignatureEqualTo(const Function *other, Matcher *matcher = nullptr) const;
bool isAmbiguous() const; // internal bool isAmbiguous() const { return f._isAmbiguous; } // internal
void setAmbiguous(bool isAmbiguous); // internal void setAmbiguous(bool isAmbiguous) { f._isAmbiguous = isAmbiguous; } // internal
bool maybeValidPrototype(int actualArgumentCount) const; bool maybeValidPrototype(int actualArgumentCount) const;
const StringLiteral *exceptionSpecification(); const StringLiteral *exceptionSpecification() { return _exceptionSpecification; }
void setExceptionSpecification(const StringLiteral *spec); void setExceptionSpecification(const StringLiteral *spec) { _exceptionSpecification = spec; }
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override;
const Function *asFunction() const override const Function *asFunction() const override { return this; }
{ return this; } Function *asFunction() override { return this; }
Function *asFunction() override
{ return this; }
// Type's interface // Type's interface
const Function *asFunctionType() const override const Function *asFunctionType() const override { return this; }
{ return this; } Function *asFunctionType() override { return this; }
Function *asFunctionType() override
{ return this; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
@@ -418,32 +377,26 @@ private:
}; };
}; };
class CPLUSPLUS_EXPORT Template: public Scope, public Type class CPLUSPLUS_EXPORT Template final : public Scope, public Type
{ {
public: public:
Template(TranslationUnit *translationUnit, int sourceLocation, const Name *name); Template(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
Template(Clone *clone, Subst *subst, Template *original); Template(Clone *clone, Subst *subst, Template *original);
virtual ~Template(); ~Template() override = default;
int templateParameterCount() const; int templateParameterCount() const;
Symbol *templateParameterAt(int index) const; Symbol *templateParameterAt(int index) const { return memberAt(index); }
Symbol *declaration() const; Symbol *declaration() const;
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override;
const Template *asTemplate() const override const Template *asTemplate() const override { return this; }
{ return this; } Template *asTemplate() override { return this; }
Template *asTemplate() override
{ return this; }
// Type's interface // Type's interface
const Template *asTemplateType() const override const Template *asTemplateType() const override { return this; }
{ return this; } Template *asTemplateType() override { return this; }
Template *asTemplateType() override
{ return this; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
@@ -452,34 +405,25 @@ protected:
}; };
class CPLUSPLUS_EXPORT Namespace: public Scope, public Type class CPLUSPLUS_EXPORT Namespace final : public Scope, public Type
{ {
public: public:
Namespace(TranslationUnit *translationUnit, int sourceLocation, const Name *name); Namespace(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
Namespace(Clone *clone, Subst *subst, Namespace *original); Namespace(Clone *clone, Subst *subst, Namespace *original);
virtual ~Namespace(); ~Namespace() override = default;
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override;
const Namespace *asNamespace() const override const Namespace *asNamespace() const override { return this; }
{ return this; } Namespace *asNamespace() override { return this; }
Namespace *asNamespace() override
{ return this; }
// Type's interface // Type's interface
const Namespace *asNamespaceType() const override const Namespace *asNamespaceType() const override { return this; }
{ return this; } Namespace *asNamespaceType() override { return this; }
Namespace *asNamespaceType() override bool isInline() const { return _isInline; }
{ return this; } void setInline(bool onoff) { _isInline = onoff; }
bool isInline() const
{ return _isInline; }
void setInline(bool onoff)
{ _isInline = onoff; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
@@ -490,28 +434,25 @@ private:
bool _isInline; bool _isInline;
}; };
class CPLUSPLUS_EXPORT BaseClass: public Symbol class CPLUSPLUS_EXPORT BaseClass final : public Symbol
{ {
public: public:
BaseClass(TranslationUnit *translationUnit, int sourceLocation, const Name *name); BaseClass(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
BaseClass(Clone *clone, Subst *subst, BaseClass *original); BaseClass(Clone *clone, Subst *subst, BaseClass *original);
virtual ~BaseClass(); ~BaseClass() override = default;
bool isVirtual() const; bool isVirtual() const { return _isVirtual; }
void setVirtual(bool isVirtual); void setVirtual(bool isVirtual) { _isVirtual = isVirtual; }
bool isVariadic() const; bool isVariadic() const { return _isVariadic; }
void setVariadic(bool isVariadic); void setVariadic(bool isVariadic) { _isVariadic = isVariadic; }
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override { return _type; }
void setType(const FullySpecifiedType &type); void setType(const FullySpecifiedType &type) { _type = type; }
const BaseClass *asBaseClass() const override const BaseClass *asBaseClass() const override { return this; }
{ return this; } BaseClass *asBaseClass() override { return this; }
BaseClass *asBaseClass() override
{ return this; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
@@ -522,12 +463,12 @@ private:
FullySpecifiedType _type; FullySpecifiedType _type;
}; };
class CPLUSPLUS_EXPORT Class: public Scope, public Type class CPLUSPLUS_EXPORT Class final : public Scope, public Type
{ {
public: public:
Class(TranslationUnit *translationUnit, int sourceLocation, const Name *name); Class(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
Class(Clone *clone, Subst *subst, Class *original); Class(Clone *clone, Subst *subst, Class *original);
virtual ~Class(); ~Class() override = default;
enum Key { enum Key {
ClassKey, ClassKey,
@@ -535,11 +476,12 @@ public:
UnionKey UnionKey
}; };
bool isClass() const; bool isClass() const { return _key == ClassKey; }
bool isStruct() const; bool isStruct() const { return _key == StructKey; }
bool isUnion() const; bool isUnion() const { return _key == UnionKey; }
Key classKey() const;
void setClassKey(Key key); Key classKey() const { return _key; }
void setClassKey(Key key) { _key = key; }
int baseClassCount() const; int baseClassCount() const;
BaseClass *baseClassAt(int index) const; BaseClass *baseClassAt(int index) const;
@@ -549,18 +491,12 @@ public:
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override;
const Class *asClass() const override const Class *asClass() const override { return this; }
{ return this; } Class *asClass() override { return this; }
Class *asClass() override
{ return this; }
// Type's interface // Type's interface
const Class *asClassType() const override const Class *asClassType() const override { return this; }
{ return this; } Class *asClassType() override { return this; }
Class *asClassType() override
{ return this; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
@@ -572,7 +508,7 @@ private:
std::vector<BaseClass *> _baseClasses; std::vector<BaseClass *> _baseClasses;
}; };
class CPLUSPLUS_EXPORT QtPropertyDeclaration: public Symbol class CPLUSPLUS_EXPORT QtPropertyDeclaration final : public Symbol
{ {
public: public:
enum Flag { enum Flag {
@@ -597,21 +533,17 @@ public:
public: public:
QtPropertyDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name); QtPropertyDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
QtPropertyDeclaration(Clone *clone, Subst *subst, QtPropertyDeclaration *original); QtPropertyDeclaration(Clone *clone, Subst *subst, QtPropertyDeclaration *original);
virtual ~QtPropertyDeclaration(); ~QtPropertyDeclaration() = default;
void setType(const FullySpecifiedType &type); void setType(const FullySpecifiedType &type) { _type = type; }
void setFlags(int flags) { _flags = flags; }
void setFlags(int flags); int flags() const { return _flags; }
int flags() const;
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override { return _type; }
const QtPropertyDeclaration *asQtPropertyDeclaration() const override const QtPropertyDeclaration *asQtPropertyDeclaration() const override { return this; }
{ return this; } QtPropertyDeclaration *asQtPropertyDeclaration() override { return this; }
QtPropertyDeclaration *asQtPropertyDeclaration() override
{ return this; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
@@ -621,88 +553,73 @@ private:
int _flags; int _flags;
}; };
class CPLUSPLUS_EXPORT QtEnum: public Symbol class CPLUSPLUS_EXPORT QtEnum final : public Symbol
{ {
public: public:
QtEnum(TranslationUnit *translationUnit, int sourceLocation, const Name *name); QtEnum(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
QtEnum(Clone *clone, Subst *subst, QtEnum *original); QtEnum(Clone *clone, Subst *subst, QtEnum *original);
virtual ~QtEnum(); ~QtEnum() override = default;
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override { return FullySpecifiedType(); }
const QtEnum *asQtEnum() const override const QtEnum *asQtEnum() const override { return this; }
{ return this; } QtEnum *asQtEnum() override { return this; }
QtEnum *asQtEnum() override
{ return this; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
}; };
class CPLUSPLUS_EXPORT ObjCBaseClass: public Symbol class CPLUSPLUS_EXPORT ObjCBaseClass final : public Symbol
{ {
public: public:
ObjCBaseClass(TranslationUnit *translationUnit, int sourceLocation, const Name *name); ObjCBaseClass(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
ObjCBaseClass(Clone *clone, Subst *subst, ObjCBaseClass *original); ObjCBaseClass(Clone *clone, Subst *subst, ObjCBaseClass *original);
virtual ~ObjCBaseClass(); ~ObjCBaseClass() override = default;
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override;
const ObjCBaseClass *asObjCBaseClass() const override const ObjCBaseClass *asObjCBaseClass() const override { return this; }
{ return this; } ObjCBaseClass *asObjCBaseClass() override { return this; }
ObjCBaseClass *asObjCBaseClass() override
{ return this; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
}; };
class CPLUSPLUS_EXPORT ObjCBaseProtocol: public Symbol class CPLUSPLUS_EXPORT ObjCBaseProtocol final : public Symbol
{ {
public: public:
ObjCBaseProtocol(TranslationUnit *translationUnit, int sourceLocation, const Name *name); ObjCBaseProtocol(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
ObjCBaseProtocol(Clone *clone, Subst *subst, ObjCBaseProtocol *original); ObjCBaseProtocol(Clone *clone, Subst *subst, ObjCBaseProtocol *original);
virtual ~ObjCBaseProtocol(); ~ObjCBaseProtocol() override = default;
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override;
const ObjCBaseProtocol *asObjCBaseProtocol() const override const ObjCBaseProtocol *asObjCBaseProtocol() const override { return this; }
{ return this; } ObjCBaseProtocol *asObjCBaseProtocol() override { return this; }
ObjCBaseProtocol *asObjCBaseProtocol() override
{ return this; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
}; };
class CPLUSPLUS_EXPORT ObjCForwardProtocolDeclaration: public Symbol, public Type class CPLUSPLUS_EXPORT ObjCForwardProtocolDeclaration final : public Symbol, public Type
{ {
public: public:
ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name); ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
ObjCForwardProtocolDeclaration(Clone *clone, Subst *subst, ObjCForwardProtocolDeclaration *original); ObjCForwardProtocolDeclaration(Clone *clone, Subst *subst, ObjCForwardProtocolDeclaration *original);
virtual ~ObjCForwardProtocolDeclaration(); ~ObjCForwardProtocolDeclaration() override = default;
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override;
const ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration() const override const ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration() const override { return this; }
{ return this; } ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration() override { return this; }
ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration() override
{ return this; }
// Type's interface // Type's interface
const ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType() const override const ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType() const override { return this; }
{ return this; } ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType() override { return this; }
ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType() override
{ return this; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
@@ -710,12 +627,12 @@ protected:
bool match0(const Type *otherType, Matcher *matcher) const override; bool match0(const Type *otherType, Matcher *matcher) const override;
}; };
class CPLUSPLUS_EXPORT ObjCProtocol: public Scope, public Type class CPLUSPLUS_EXPORT ObjCProtocol final : public Scope, public Type
{ {
public: public:
ObjCProtocol(TranslationUnit *translationUnit, int sourceLocation, const Name *name); ObjCProtocol(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
ObjCProtocol(Clone *clone, Subst *subst, ObjCProtocol *original); ObjCProtocol(Clone *clone, Subst *subst, ObjCProtocol *original);
virtual ~ObjCProtocol(); ~ObjCProtocol() override = default;
int protocolCount() const; int protocolCount() const;
ObjCBaseProtocol *protocolAt(int index) const; ObjCBaseProtocol *protocolAt(int index) const;
@@ -724,18 +641,12 @@ public:
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override;
const ObjCProtocol *asObjCProtocol() const override const ObjCProtocol *asObjCProtocol() const override { return this; }
{ return this; } ObjCProtocol *asObjCProtocol() override { return this; }
ObjCProtocol *asObjCProtocol() override
{ return this; }
// Type's interface // Type's interface
const ObjCProtocol *asObjCProtocolType() const override const ObjCProtocol *asObjCProtocolType() const override { return this; }
{ return this; } ObjCProtocol *asObjCProtocolType() override { return this; }
ObjCProtocol *asObjCProtocolType() override
{ return this; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
@@ -746,28 +657,22 @@ private:
std::vector<ObjCBaseProtocol *> _protocols; std::vector<ObjCBaseProtocol *> _protocols;
}; };
class CPLUSPLUS_EXPORT ObjCForwardClassDeclaration: public Symbol, public Type class CPLUSPLUS_EXPORT ObjCForwardClassDeclaration final : public Symbol, public Type
{ {
public: public:
ObjCForwardClassDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name); ObjCForwardClassDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
ObjCForwardClassDeclaration(Clone *clone, Subst *subst, ObjCForwardClassDeclaration *original); ObjCForwardClassDeclaration(Clone *clone, Subst *subst, ObjCForwardClassDeclaration *original);
virtual ~ObjCForwardClassDeclaration(); ~ObjCForwardClassDeclaration() override = default;
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override;
const ObjCForwardClassDeclaration *asObjCForwardClassDeclaration() const override const ObjCForwardClassDeclaration *asObjCForwardClassDeclaration() const override { return this; }
{ return this; } ObjCForwardClassDeclaration *asObjCForwardClassDeclaration() override { return this; }
ObjCForwardClassDeclaration *asObjCForwardClassDeclaration() override
{ return this; }
// Type's interface // Type's interface
const ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType() const override const ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType() const override { return this; }
{ return this; } ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType() override { return this; }
ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType() override
{ return this; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
@@ -775,22 +680,22 @@ protected:
bool match0(const Type *otherType, Matcher *matcher) const override; bool match0(const Type *otherType, Matcher *matcher) const override;
}; };
class CPLUSPLUS_EXPORT ObjCClass: public Scope, public Type class CPLUSPLUS_EXPORT ObjCClass final : public Scope, public Type
{ {
public: public:
ObjCClass(TranslationUnit *translationUnit, int sourceLocation, const Name *name); ObjCClass(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
ObjCClass(Clone *clone, Subst *subst, ObjCClass *original); ObjCClass(Clone *clone, Subst *subst, ObjCClass *original);
virtual ~ObjCClass(); ~ObjCClass() override = default;
bool isInterface() const; bool isInterface() const { return _isInterface; }
void setInterface(bool isInterface); void setInterface(bool isInterface) { _isInterface = isInterface; }
bool isCategory() const; bool isCategory() const { return _categoryName != nullptr; }
const Name *categoryName() const; const Name *categoryName() const { return _categoryName; }
void setCategoryName(const Name *categoryName); void setCategoryName(const Name *categoryName) { _categoryName = categoryName; }
ObjCBaseClass *baseClass() const; ObjCBaseClass *baseClass() const { return _baseClass; }
void setBaseClass(ObjCBaseClass *baseClass); void setBaseClass(ObjCBaseClass *baseClass) { _baseClass = baseClass; }
int protocolCount() const; int protocolCount() const;
ObjCBaseProtocol *protocolAt(int index) const; ObjCBaseProtocol *protocolAt(int index) const;
@@ -799,18 +704,12 @@ public:
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override;
const ObjCClass *asObjCClass() const override const ObjCClass *asObjCClass() const override { return this; }
{ return this; } ObjCClass *asObjCClass() override { return this; }
ObjCClass *asObjCClass() override
{ return this; }
// Type's interface // Type's interface
const ObjCClass *asObjCClassType() const override const ObjCClass *asObjCClassType() const override { return this; }
{ return this; } ObjCClass *asObjCClassType() override { return this; }
ObjCClass *asObjCClassType() override
{ return this; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
@@ -824,15 +723,15 @@ private:
bool _isInterface; bool _isInterface;
}; };
class CPLUSPLUS_EXPORT ObjCMethod: public Scope, public Type class CPLUSPLUS_EXPORT ObjCMethod final : public Scope, public Type
{ {
public: public:
ObjCMethod(TranslationUnit *translationUnit, int sourceLocation, const Name *name); ObjCMethod(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
ObjCMethod(Clone *clone, Subst *subst, ObjCMethod *original); ObjCMethod(Clone *clone, Subst *subst, ObjCMethod *original);
virtual ~ObjCMethod(); ~ObjCMethod() override = default;
FullySpecifiedType returnType() const; FullySpecifiedType returnType() const { return _returnType; }
void setReturnType(const FullySpecifiedType &returnType); void setReturnType(const FullySpecifiedType &returnType) { _returnType = returnType; }
/** Convenience function that returns whether the function returns something (including void). */ /** Convenience function that returns whether the function returns something (including void). */
bool hasReturnType() const; bool hasReturnType() const;
@@ -843,24 +742,18 @@ public:
/** Convenience function that returns whether the function receives any arguments. */ /** Convenience function that returns whether the function receives any arguments. */
bool hasArguments() const; bool hasArguments() const;
bool isVariadic() const; bool isVariadic() const { return f._isVariadic; }
void setVariadic(bool isVariadic); void setVariadic(bool isVariadic) { f._isVariadic = isVariadic; }
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override;
const ObjCMethod *asObjCMethod() const override const ObjCMethod *asObjCMethod() const override { return this; }
{ return this; } ObjCMethod *asObjCMethod() override { return this; }
ObjCMethod *asObjCMethod() override
{ return this; }
// Type's interface // Type's interface
const ObjCMethod *asObjCMethodType() const override const ObjCMethod *asObjCMethodType() const override { return this; }
{ return this; } ObjCMethod *asObjCMethodType() override { return this; }
ObjCMethod *asObjCMethodType() override
{ return this; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;
@@ -878,7 +771,7 @@ private:
}; };
}; };
class CPLUSPLUS_EXPORT ObjCPropertyDeclaration: public Symbol class CPLUSPLUS_EXPORT ObjCPropertyDeclaration final : public Symbol
{ {
public: public:
enum PropertyAttributes { enum PropertyAttributes {
@@ -901,31 +794,27 @@ public:
int sourceLocation, int sourceLocation,
const Name *name); const Name *name);
ObjCPropertyDeclaration(Clone *clone, Subst *subst, ObjCPropertyDeclaration *original); ObjCPropertyDeclaration(Clone *clone, Subst *subst, ObjCPropertyDeclaration *original);
virtual ~ObjCPropertyDeclaration(); ~ObjCPropertyDeclaration() override = default;
bool hasAttribute(int attribute) const; bool hasAttribute(int attribute) const { return _propertyAttributes & attribute; }
void setAttributes(int attributes); void setAttributes(int attributes) { _propertyAttributes = attributes; }
bool hasGetter() const; bool hasGetter() const { return hasAttribute(Getter); }
bool hasSetter() const; bool hasSetter() const { return hasAttribute(Setter); }
const Name *getterName() const; const Name *getterName() const { return _getterName; }
void setGetterName(const Name *getterName) { _getterName = getterName; }
void setGetterName(const Name *getterName); const Name *setterName() const { return _setterName; }
void setSetterName(const Name *setterName) { _setterName = setterName; }
const Name *setterName() const; void setType(const FullySpecifiedType &type) { _type = type; }
void setSetterName(const Name *setterName);
void setType(const FullySpecifiedType &type);
// Symbol's interface // Symbol's interface
FullySpecifiedType type() const override; FullySpecifiedType type() const override { return _type; }
const ObjCPropertyDeclaration *asObjCPropertyDeclaration() const override const ObjCPropertyDeclaration *asObjCPropertyDeclaration() const override { return this; }
{ return this; } ObjCPropertyDeclaration *asObjCPropertyDeclaration() override { return this; }
ObjCPropertyDeclaration *asObjCPropertyDeclaration() override
{ return this; }
protected: protected:
void visitSymbol0(SymbolVisitor *visitor) override; void visitSymbol0(SymbolVisitor *visitor) override;

View File

@@ -174,7 +174,7 @@ protected:
bool visit(Template *symbol) override bool visit(Template *symbol) override
{ {
if (Symbol *decl = symbol->declaration()) { if (Symbol *decl = symbol->declaration()) {
if (decl->isFunction() || decl->isClass() || decl->isDeclaration()) if (decl->asFunction() || decl->asClass() || decl->asDeclaration())
return process(symbol); return process(symbol);
} }
return true; return true;
@@ -522,7 +522,7 @@ QString Document::functionAt(int line, int column, int *lineOpeningDeclaratorPar
if (!scope) if (!scope)
scope = symbol->enclosingScope(); scope = symbol->enclosingScope();
while (scope && !scope->isFunction() ) while (scope && !scope->asFunction() )
scope = scope->enclosingScope(); scope = scope->enclosingScope();
if (!scope) if (!scope)

View File

@@ -458,8 +458,8 @@ FullySpecifiedType UseMinimalNames::apply(const Name *name, Rewrite *rewrite) co
SubstitutionEnvironment *env = rewrite->env; SubstitutionEnvironment *env = rewrite->env;
Scope *scope = env->scope(); Scope *scope = env->scope();
if (name->isTemplateNameId() || if (name->asTemplateNameId() ||
(name->isQualifiedNameId() && name->asQualifiedNameId()->name()->isTemplateNameId())) (name->asQualifiedNameId() && name->asQualifiedNameId()->name()->asTemplateNameId()))
return FullySpecifiedType(); return FullySpecifiedType();
if (! scope) if (! scope)

View File

@@ -514,7 +514,7 @@ QString FindUsages::matchingLine(const Token &tk) const
bool FindUsages::isLocalScope(Scope *scope) bool FindUsages::isLocalScope(Scope *scope)
{ {
if (scope) { if (scope) {
if (scope->isBlock() || scope->isTemplate() || scope->isFunction()) if (scope->asBlock() || scope->asTemplate() || scope->asFunction())
return true; return true;
} }
@@ -527,7 +527,7 @@ bool FindUsages::checkCandidates(const QList<LookupItem> &candidates) const
const LookupItem &r = candidates.at(i); const LookupItem &r = candidates.at(i);
if (Symbol *s = r.declaration()) { if (Symbol *s = r.declaration()) {
if (_declSymbol->isTypenameArgument()) { if (_declSymbol->asTypenameArgument()) {
if (s != _declSymbol) if (s != _declSymbol)
return false; return false;
} }
@@ -535,8 +535,8 @@ bool FindUsages::checkCandidates(const QList<LookupItem> &candidates) const
Scope *declEnclosingScope = _declSymbol->enclosingScope(); Scope *declEnclosingScope = _declSymbol->enclosingScope();
Scope *enclosingScope = s->enclosingScope(); Scope *enclosingScope = s->enclosingScope();
if (isLocalScope(declEnclosingScope) || isLocalScope(enclosingScope)) { if (isLocalScope(declEnclosingScope) || isLocalScope(enclosingScope)) {
if (_declSymbol->isClass() && declEnclosingScope->isTemplate() if (_declSymbol->asClass() && declEnclosingScope->asTemplate()
&& s->isClass() && enclosingScope->isTemplate()) { && s->asClass() && enclosingScope->asTemplate()) {
// for definition of functions of class defined outside the class definition // for definition of functions of class defined outside the class definition
Scope *templEnclosingDeclSymbol = declEnclosingScope; Scope *templEnclosingDeclSymbol = declEnclosingScope;
Scope *scopeOfTemplEnclosingDeclSymbol Scope *scopeOfTemplEnclosingDeclSymbol
@@ -547,9 +547,9 @@ bool FindUsages::checkCandidates(const QList<LookupItem> &candidates) const
if (scopeOfTemplEnclosingCandidateSymbol != scopeOfTemplEnclosingDeclSymbol) if (scopeOfTemplEnclosingCandidateSymbol != scopeOfTemplEnclosingDeclSymbol)
return false; return false;
} else if (_declSymbol->isClass() && declEnclosingScope->isTemplate() } else if (_declSymbol->asClass() && declEnclosingScope->asTemplate()
&& enclosingScope->isClass() && enclosingScope->asClass()
&& enclosingScope->enclosingScope()->isTemplate()) { && enclosingScope->enclosingScope()->asTemplate()) {
// for declaration inside template class // for declaration inside template class
Scope *templEnclosingDeclSymbol = declEnclosingScope; Scope *templEnclosingDeclSymbol = declEnclosingScope;
Scope *scopeOfTemplEnclosingDeclSymbol Scope *scopeOfTemplEnclosingDeclSymbol
@@ -560,18 +560,18 @@ bool FindUsages::checkCandidates(const QList<LookupItem> &candidates) const
if (scopeOfTemplEnclosingCandidateSymbol != scopeOfTemplEnclosingDeclSymbol) if (scopeOfTemplEnclosingCandidateSymbol != scopeOfTemplEnclosingDeclSymbol)
return false; return false;
} else if (enclosingScope->isTemplate() && ! _declSymbol->isTypenameArgument()) { } else if (enclosingScope->asTemplate() && ! _declSymbol->asTypenameArgument()) {
if (declEnclosingScope->isTemplate()) { if (declEnclosingScope->asTemplate()) {
if (enclosingScope->enclosingScope() != declEnclosingScope->enclosingScope()) if (enclosingScope->enclosingScope() != declEnclosingScope->enclosingScope())
return false; return false;
} else { } else {
if (enclosingScope->enclosingScope() != declEnclosingScope) if (enclosingScope->enclosingScope() != declEnclosingScope)
return false; return false;
} }
} else if (declEnclosingScope->isTemplate() && s->isTemplate()) { } else if (declEnclosingScope->asTemplate() && s->asTemplate()) {
if (declEnclosingScope->enclosingScope() != enclosingScope) if (declEnclosingScope->enclosingScope() != enclosingScope)
return false; return false;
} else if (! s->isUsingDeclaration() } else if (! s->asUsingDeclaration()
&& enclosingScope != declEnclosingScope) { && enclosingScope != declEnclosingScope) {
return false; return false;
} }
@@ -854,7 +854,7 @@ void FindUsages::memInitializer(MemInitializerAST *ast)
if (! ast) if (! ast)
return; return;
if (_currentScope->isFunction()) { if (_currentScope->asFunction()) {
Class *classScope = _currentScope->enclosingClass(); Class *classScope = _currentScope->enclosingClass();
if (! classScope) { if (! classScope) {
if (ClassOrNamespace *binding = _context.lookupType(_currentScope)) { if (ClassOrNamespace *binding = _context.lookupType(_currentScope)) {

View File

@@ -57,7 +57,7 @@ Utils::CodeModelIcon::Type iconTypeForSymbol(const Symbol *symbol)
} }
FullySpecifiedType symbolType = symbol->type(); FullySpecifiedType symbolType = symbol->type();
if (symbol->isFunction() || (symbol->isDeclaration() && symbolType && if (symbol->asFunction() || (symbol->asDeclaration() && symbolType &&
symbolType->isFunctionType())) symbolType->isFunctionType()))
{ {
const Function *function = symbol->asFunction(); const Function *function = symbol->asFunction();
@@ -80,9 +80,9 @@ Utils::CodeModelIcon::Type iconTypeForSymbol(const Symbol *symbol)
} else if (symbol->isPrivate()) { } else if (symbol->isPrivate()) {
return symbol->isStatic() ? FuncPrivateStatic : FuncPrivate; return symbol->isStatic() ? FuncPrivateStatic : FuncPrivate;
} }
} else if (symbol->enclosingScope() && symbol->enclosingScope()->isEnum()) { } else if (symbol->enclosingScope() && symbol->enclosingScope()->asEnum()) {
return Enumerator; return Enumerator;
} else if (symbol->isDeclaration() || symbol->isArgument()) { } else if (symbol->asDeclaration() || symbol->asArgument()) {
if (symbol->isPublic()) { if (symbol->isPublic()) {
return symbol->isStatic() ? VarPublicStatic : VarPublic; return symbol->isStatic() ? VarPublicStatic : VarPublic;
} else if (symbol->isProtected()) { } else if (symbol->isProtected()) {
@@ -90,26 +90,26 @@ Utils::CodeModelIcon::Type iconTypeForSymbol(const Symbol *symbol)
} else if (symbol->isPrivate()) { } else if (symbol->isPrivate()) {
return symbol->isStatic() ? VarPrivateStatic : VarPrivate; return symbol->isStatic() ? VarPrivateStatic : VarPrivate;
} }
} else if (symbol->isEnum()) { } else if (symbol->asEnum()) {
return Utils::CodeModelIcon::Enum; return Utils::CodeModelIcon::Enum;
} else if (symbol->isForwardClassDeclaration()) { } else if (symbol->asForwardClassDeclaration()) {
return Utils::CodeModelIcon::Class; // TODO: Store class key in ForwardClassDeclaration return Utils::CodeModelIcon::Class; // TODO: Store class key in ForwardClassDeclaration
} else if (const Class *klass = symbol->asClass()) { } else if (const Class *klass = symbol->asClass()) {
return klass->isStruct() ? Struct : Utils::CodeModelIcon::Class; return klass->isStruct() ? Struct : Utils::CodeModelIcon::Class;
} else if (symbol->isObjCClass() || symbol->isObjCForwardClassDeclaration()) { } else if (symbol->asObjCClass() || symbol->asObjCForwardClassDeclaration()) {
return Utils::CodeModelIcon::Class; return Utils::CodeModelIcon::Class;
} else if (symbol->isObjCProtocol() || symbol->isObjCForwardProtocolDeclaration()) { } else if (symbol->asObjCProtocol() || symbol->asObjCForwardProtocolDeclaration()) {
return Utils::CodeModelIcon::Class; return Utils::CodeModelIcon::Class;
} else if (symbol->isObjCMethod()) { } else if (symbol->asObjCMethod()) {
return FuncPublic; return FuncPublic;
} else if (symbol->isNamespace()) { } else if (symbol->asNamespace()) {
return Utils::CodeModelIcon::Namespace; return Utils::CodeModelIcon::Namespace;
} else if (symbol->isTypenameArgument()) { } else if (symbol->asTypenameArgument()) {
return Utils::CodeModelIcon::Class; return Utils::CodeModelIcon::Class;
} else if (symbol->isQtPropertyDeclaration() || symbol->isObjCPropertyDeclaration()) { } else if (symbol->asQtPropertyDeclaration() || symbol->asObjCPropertyDeclaration()) {
return Property; return Property;
} else if (symbol->isUsingNamespaceDirective() || } else if (symbol->asUsingNamespaceDirective() ||
symbol->isUsingDeclaration()) { symbol->asUsingDeclaration()) {
// TODO: Might be nice to have a different icons for these things // TODO: Might be nice to have a different icons for these things
return Utils::CodeModelIcon::Namespace; return Utils::CodeModelIcon::Namespace;
} }

View File

@@ -56,7 +56,7 @@ static void addNames(const Name *name, QList<const Name *> *names, bool addAllNa
if (const QualifiedNameId *q = name->asQualifiedNameId()) { if (const QualifiedNameId *q = name->asQualifiedNameId()) {
addNames(q->base(), names); addNames(q->base(), names);
addNames(q->name(), names, addAllNames); addNames(q->name(), names, addAllNames);
} else if (addAllNames || name->isNameId() || name->isTemplateNameId() || name->isAnonymousNameId()) { } else if (addAllNames || name->asNameId() || name->asTemplateNameId() || name->asAnonymousNameId()) {
names->append(name); names->append(name);
} }
} }
@@ -71,7 +71,7 @@ static void path_helper(Symbol *symbol,
path_helper(symbol->enclosingScope(), names, policy); path_helper(symbol->enclosingScope(), names, policy);
if (symbol->name()) { if (symbol->name()) {
if (symbol->isClass() || symbol->isNamespace()) { if (symbol->asClass() || symbol->asNamespace()) {
if (policy == LookupContext::HideInlineNamespaces) { if (policy == LookupContext::HideInlineNamespaces) {
auto ns = symbol->asNamespace(); auto ns = symbol->asNamespace();
if (ns && ns->isInline()) if (ns && ns->isInline())
@@ -79,12 +79,12 @@ static void path_helper(Symbol *symbol,
} }
addNames(symbol->name(), names); addNames(symbol->name(), names);
} else if (symbol->isObjCClass() || symbol->isObjCBaseClass() || symbol->isObjCProtocol() } else if (symbol->asObjCClass() || symbol->asObjCBaseClass() || symbol->asObjCProtocol()
|| symbol->isObjCForwardClassDeclaration() || symbol->isObjCForwardProtocolDeclaration() || symbol->asObjCForwardClassDeclaration() || symbol->asObjCForwardProtocolDeclaration()
|| symbol->isForwardClassDeclaration()) { || symbol->asForwardClassDeclaration()) {
addNames(symbol->name(), names); addNames(symbol->name(), names);
} else if (symbol->isFunction()) { } else if (symbol->asFunction()) {
if (const QualifiedNameId *q = symbol->name()->asQualifiedNameId()) if (const QualifiedNameId *q = symbol->name()->asQualifiedNameId())
addNames(q->base(), names); addNames(q->base(), names);
} else if (Enum *e = symbol->asEnum()) { } else if (Enum *e = symbol->asEnum()) {
@@ -316,7 +316,7 @@ QList<LookupItem> LookupContext::lookupByUsing(const Name *name,
{ {
QList<LookupItem> candidates; QList<LookupItem> candidates;
// if it is a nameId there can be a using declaration for it // if it is a nameId there can be a using declaration for it
if (name->isNameId() || name->isTemplateNameId()) { if (name->asNameId() || name->asTemplateNameId()) {
const QList<Symbol *> symbols = bindingScope->symbols(); const QList<Symbol *> symbols = bindingScope->symbols();
for (Symbol *s : symbols) { for (Symbol *s : symbols) {
if (Scope *scope = s->asScope()) { if (Scope *scope = s->asScope()) {
@@ -409,7 +409,7 @@ ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope,
} }
} }
} else if (UsingDeclaration *ud = m->asUsingDeclaration()) { } else if (UsingDeclaration *ud = m->asUsingDeclaration()) {
if (name->isNameId()) { if (name->asNameId()) {
if (const Name *usingDeclarationName = ud->name()) { if (const Name *usingDeclarationName = ud->name()) {
if (const QualifiedNameId *q = usingDeclarationName->asQualifiedNameId()) { if (const QualifiedNameId *q = usingDeclarationName->asQualifiedNameId()) {
if (q->name() && q->name()->match(name)) if (q->name() && q->name()->match(name))
@@ -433,7 +433,7 @@ ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope,
} else if (ClassOrNamespace *b = bindings()->lookupType(scope, enclosingBinding)) { } else if (ClassOrNamespace *b = bindings()->lookupType(scope, enclosingBinding)) {
return b->lookupType(name); return b->lookupType(name);
} else if (Class *scopeAsClass = scope->asClass()) { } else if (Class *scopeAsClass = scope->asClass()) {
if (scopeAsClass->enclosingScope()->isBlock()) { if (scopeAsClass->enclosingScope()->asBlock()) {
if (ClassOrNamespace *b = lookupType(scopeAsClass->name(), if (ClassOrNamespace *b = lookupType(scopeAsClass->name(),
scopeAsClass->enclosingScope(), scopeAsClass->enclosingScope(),
enclosingBinding, enclosingBinding,
@@ -460,13 +460,13 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
return candidates; return candidates;
for (; scope; scope = scope->enclosingScope()) { for (; scope; scope = scope->enclosingScope()) {
if (name->identifier() != nullptr && scope->isBlock()) { if (name->identifier() != nullptr && scope->asBlock()) {
bindings()->lookupInScope(name, scope, &candidates, /*templateId = */ nullptr, /*binding=*/ nullptr); bindings()->lookupInScope(name, scope, &candidates, /*templateId = */ nullptr, /*binding=*/ nullptr);
if (! candidates.isEmpty()) { if (! candidates.isEmpty()) {
// it's a local. // it's a local.
//for qualified it can be outside of the local scope //for qualified it can be outside of the local scope
if (name->isQualifiedNameId()) if (name->asQualifiedNameId())
continue; continue;
else else
break; break;
@@ -502,13 +502,13 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
if (! candidates.isEmpty()) { if (! candidates.isEmpty()) {
// it's an argument or a template parameter. // it's an argument or a template parameter.
//for qualified it can be outside of the local scope //for qualified it can be outside of the local scope
if (name->isQualifiedNameId()) if (name->asQualifiedNameId())
continue; continue;
else else
break; break;
} }
if (fun->name() && fun->name()->isQualifiedNameId()) { if (fun->name() && fun->name()->asQualifiedNameId()) {
if (ClassOrNamespace *binding = bindings()->lookupType(fun)) { if (ClassOrNamespace *binding = bindings()->lookupType(fun)) {
candidates = binding->find(name); candidates = binding->find(name);
@@ -540,7 +540,7 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
if (! candidates.isEmpty()) { if (! candidates.isEmpty()) {
// it's a template parameter. // it's a template parameter.
//for qualified it can be outside of the local scope //for qualified it can be outside of the local scope
if (name->isQualifiedNameId()) if (name->asQualifiedNameId())
continue; continue;
else else
break; break;
@@ -572,7 +572,7 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
if (! candidates.isEmpty()) if (! candidates.isEmpty())
return candidates; return candidates;
} else if (scope->isObjCClass() || scope->isObjCProtocol()) { } else if (scope->asObjCClass() || scope->asObjCProtocol()) {
if (ClassOrNamespace *binding = bindings()->lookupType(scope)) if (ClassOrNamespace *binding = bindings()->lookupType(scope))
candidates = binding->find(name); candidates = binding->find(name);
@@ -740,7 +740,7 @@ void ClassOrNamespace::lookup_helper(const Name *name, ClassOrNamespace *binding
for (Symbol *s : symbols) { for (Symbol *s : symbols) {
if (s->isFriend()) if (s->isFriend())
continue; continue;
else if (s->isUsingNamespaceDirective()) else if (s->asUsingNamespaceDirective())
continue; continue;
@@ -825,11 +825,11 @@ void CreateBindings::lookupInScope(const Name *name, Scope *scope,
for (Symbol *s = scope->find(id); s; s = s->next()) { for (Symbol *s = scope->find(id); s; s = s->next()) {
if (s->isFriend()) if (s->isFriend())
continue; // skip friends continue; // skip friends
else if (s->isUsingNamespaceDirective()) else if (s->asUsingNamespaceDirective())
continue; // skip using namespace directives continue; // skip using namespace directives
else if (! id->match(s->identifier())) else if (! id->match(s->identifier()))
continue; continue;
else if (s->name() && s->name()->isQualifiedNameId()) else if (s->name() && s->name()->asQualifiedNameId())
continue; // skip qualified ids. continue; // skip qualified ids.
if (Q_UNLIKELY(debug)) { if (Q_UNLIKELY(debug)) {
@@ -851,7 +851,7 @@ void CreateBindings::lookupInScope(const Name *name, Scope *scope,
} }
} }
if (templateId && (s->isDeclaration() || s->isFunction())) { if (templateId && (s->asDeclaration() || s->asFunction())) {
FullySpecifiedType ty = DeprecatedGenTemplateInstance::instantiate(templateId, s, control()); FullySpecifiedType ty = DeprecatedGenTemplateInstance::instantiate(templateId, s, control());
item.setType(ty); // override the type. item.setType(ty); // override the type.
} }
@@ -991,7 +991,7 @@ ClassOrNamespace *ClassOrNamespace::lookupType_helper(const Name *name,
} else if (! processed->contains(this)) { } else if (! processed->contains(this)) {
processed->insert(this); processed->insert(this);
if (name->isNameId() || name->isTemplateNameId() || name->isAnonymousNameId()) { if (name->asNameId() || name->asTemplateNameId() || name->asAnonymousNameId()) {
flush(); flush();
const QList<Symbol *> symbolList = symbols(); const QList<Symbol *> symbolList = symbols();
@@ -1136,7 +1136,7 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name,
ClassOrNamespace *origin) ClassOrNamespace *origin)
{ {
Q_ASSERT(name != nullptr); Q_ASSERT(name != nullptr);
Q_ASSERT(name->isNameId() || name->isTemplateNameId() || name->isAnonymousNameId()); Q_ASSERT(name->asNameId() || name->asTemplateNameId() || name->asAnonymousNameId());
const_cast<ClassOrNamespace *>(this)->flush(); const_cast<ClassOrNamespace *>(this)->flush();
@@ -1255,7 +1255,7 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name,
return reference; return reference;
} }
if (!name->isTemplateNameId()) if (!name->asTemplateNameId())
_alreadyConsideredClasses.insert(referenceClass); _alreadyConsideredClasses.insert(referenceClass);
QSet<ClassOrNamespace *> knownUsings = Utils::toSet(reference->usings()); QSet<ClassOrNamespace *> knownUsings = Utils::toSet(reference->usings());
@@ -1270,7 +1270,7 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name,
instantiation->_templateId = templId; instantiation->_templateId = templId;
QSet<ClassOrNamespace *> otherProcessed; QSet<ClassOrNamespace *> otherProcessed;
while (!origin->_symbols.isEmpty() && origin->_symbols[0]->isBlock()) { while (!origin->_symbols.isEmpty() && origin->_symbols[0]->asBlock()) {
if (otherProcessed.contains(origin)) if (otherProcessed.contains(origin))
break; break;
otherProcessed.insert(origin); otherProcessed.insert(origin);
@@ -1634,7 +1634,7 @@ ClassOrNamespace *ClassOrNamespace::findOrCreateType(const Name *name, ClassOrNa
return findOrCreateType(q->base(), origin)->findOrCreateType(q->name(), origin, clazz); return findOrCreateType(q->base(), origin)->findOrCreateType(q->name(), origin, clazz);
} else if (name->isNameId() || name->isTemplateNameId() || name->isAnonymousNameId()) { } else if (name->asNameId() || name->asTemplateNameId() || name->asAnonymousNameId()) {
QSet<ClassOrNamespace *> processed; QSet<ClassOrNamespace *> processed;
ClassOrNamespace *e = nestedType(name, &processed, origin); ClassOrNamespace *e = nestedType(name, &processed, origin);
@@ -1791,7 +1791,7 @@ bool CreateBindings::visit(Class *klass)
ClassOrNamespace *previous = _currentClassOrNamespace; ClassOrNamespace *previous = _currentClassOrNamespace;
ClassOrNamespace *binding = nullptr; ClassOrNamespace *binding = nullptr;
if (klass->name() && klass->name()->isQualifiedNameId()) if (klass->name() && klass->name()->asQualifiedNameId())
binding = _currentClassOrNamespace->lookupType(klass->name()); binding = _currentClassOrNamespace->lookupType(klass->name());
if (! binding) if (! binding)
@@ -1956,7 +1956,7 @@ bool CreateBindings::visit(NamespaceAlias *a)
return false; return false;
} else if (ClassOrNamespace *e = _currentClassOrNamespace->lookupType(a->namespaceName())) { } else if (ClassOrNamespace *e = _currentClassOrNamespace->lookupType(a->namespaceName())) {
if (a->name()->isNameId() || a->name()->isTemplateNameId() || a->name()->isAnonymousNameId()) if (a->name()->asNameId() || a->name()->asTemplateNameId() || a->name()->asAnonymousNameId())
_currentClassOrNamespace->addNestedType(a->name(), e); _currentClassOrNamespace->addNestedType(a->name(), e);
} else if (false) { } else if (false) {
@@ -2042,12 +2042,12 @@ Symbol *CreateBindings::instantiateTemplateFunction(const Name *instantiationNam
Template *specialization) const Template *specialization) const
{ {
if (!specialization || !specialization->declaration() if (!specialization || !specialization->declaration()
|| !specialization->declaration()->isFunction()) || !specialization->declaration()->asFunction())
return nullptr; return nullptr;
int argumentCountOfInstantiation = 0; int argumentCountOfInstantiation = 0;
const TemplateNameId *instantiation = nullptr; const TemplateNameId *instantiation = nullptr;
if (instantiationName->isTemplateNameId()) { if (instantiationName->asTemplateNameId()) {
instantiation = instantiationName->asTemplateNameId(); instantiation = instantiationName->asTemplateNameId();
argumentCountOfInstantiation = instantiation->templateArgumentCount(); argumentCountOfInstantiation = instantiation->templateArgumentCount();
} else { } else {

View File

@@ -1045,7 +1045,7 @@ ClassOrNamespace *ResolveExpression::findClass(const FullySpecifiedType &origina
ClassOrNamespace *binding = nullptr; ClassOrNamespace *binding = nullptr;
if (Class *klass = ty->asClassType()) { if (Class *klass = ty->asClassType()) {
if (scope->isBlock()) if (scope->asBlock())
binding = _context.lookupType(klass->name(), scope, enclosingBinding); binding = _context.lookupType(klass->name(), scope, enclosingBinding);
if (!binding) if (!binding)
binding = _context.lookupType(klass, enclosingBinding); binding = _context.lookupType(klass, enclosingBinding);
@@ -1135,7 +1135,7 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
instantiatedFunction = overloadTy->asFunctionType(); instantiatedFunction = overloadTy->asFunctionType();
} else if (overloadType->isTemplateType() } else if (overloadType->isTemplateType()
&& overloadType->asTemplateType()->declaration() && overloadType->asTemplateType()->declaration()
&& overloadType->asTemplateType()->declaration()->isFunction()) { && overloadType->asTemplateType()->declaration()->asFunction()) {
instantiatedFunction = overloadType->asTemplateType()->declaration()->asFunction(); instantiatedFunction = overloadType->asTemplateType()->declaration()->asFunction();
} }

View File

@@ -41,7 +41,7 @@ void SymbolNameVisitor::accept(Symbol *symbol)
if (Scope *scope = symbol->enclosingScope()) if (Scope *scope = symbol->enclosingScope())
accept(scope); accept(scope);
if (! symbol->isTemplate()) { if (! symbol->asTemplate()) {
if (const Name *name = symbol->name()) { if (const Name *name = symbol->name()) {
std::swap(_symbol, symbol); std::swap(_symbol, symbol);
accept(name); accept(name);

View File

@@ -105,17 +105,17 @@ void ParserTreeItemPrivate::mergeSymbol(const CPlusPlus::Symbol *symbol)
// any symbol which does not contain :: in the name // any symbol which does not contain :: in the name
//! \todo collect statistics and reorder to optimize //! \todo collect statistics and reorder to optimize
if (symbol->isForwardClassDeclaration() if (symbol->asForwardClassDeclaration()
|| symbol->isExtern() || symbol->isExtern()
|| symbol->isFriend() || symbol->isFriend()
|| symbol->isGenerated() || symbol->isGenerated()
|| symbol->isUsingNamespaceDirective() || symbol->asUsingNamespaceDirective()
|| symbol->isUsingDeclaration() || symbol->asUsingDeclaration()
) )
return; return;
const CPlusPlus::Name *symbolName = symbol->name(); const CPlusPlus::Name *symbolName = symbol->name();
if (symbolName && symbolName->isQualifiedNameId()) if (symbolName && symbolName->asQualifiedNameId())
return; return;
QString name = g_overview.prettyName(symbolName).trimmed(); QString name = g_overview.prettyName(symbolName).trimmed();
@@ -139,7 +139,7 @@ void ParserTreeItemPrivate::mergeSymbol(const CPlusPlus::Symbol *symbol)
childItem->d->m_symbolLocations.insert(location); childItem->d->m_symbolLocations.insert(location);
// prevent showing a content of the functions // prevent showing a content of the functions
if (!symbol->isFunction()) { if (!symbol->asFunction()) {
if (const CPlusPlus::Scope *scope = symbol->asScope()) { if (const CPlusPlus::Scope *scope = symbol->asScope()) {
CPlusPlus::Scope::iterator cur = scope->memberBegin(); CPlusPlus::Scope::iterator cur = scope->memberBegin();
CPlusPlus::Scope::iterator last = scope->memberEnd(); CPlusPlus::Scope::iterator last = scope->memberEnd();
@@ -155,7 +155,7 @@ void ParserTreeItemPrivate::mergeSymbol(const CPlusPlus::Symbol *symbol)
} }
// if item is empty and has not to be added // if item is empty and has not to be added
if (!symbol->isNamespace() || childItem->childCount()) if (!symbol->asNamespace() || childItem->childCount())
m_symbolInformations.insert(information, childItem); m_symbolInformations.insert(information, childItem);
} }

View File

@@ -121,7 +121,7 @@ protected:
addType(q->base()); addType(q->base());
addType(q->name()); addType(q->name());
} else if (name->isNameId() || name->isTemplateNameId()) { } else if (name->asNameId() || name->asTemplateNameId()) {
addType(name->identifier()); addType(name->identifier());
} }
@@ -132,7 +132,7 @@ protected:
if (!name) { if (!name) {
return; return;
} else if (name->isNameId()) { } else if (name->asNameId()) {
const Identifier *id = name->identifier(); const Identifier *id = name->identifier();
_fields.insert(QByteArray::fromRawData(id->chars(), id->size())); _fields.insert(QByteArray::fromRawData(id->chars(), id->size()));
@@ -144,7 +144,7 @@ protected:
if (!name) { if (!name) {
return; return;
} else if (name->isNameId()) { } else if (name->asNameId()) {
const Identifier *id = name->identifier(); const Identifier *id = name->identifier();
_functions.insert(QByteArray::fromRawData(id->chars(), id->size())); _functions.insert(QByteArray::fromRawData(id->chars(), id->size()));
} }
@@ -155,7 +155,7 @@ protected:
if (!name) { if (!name) {
return; return;
} else if (name->isNameId() || name->isTemplateNameId()) { } else if (name->asNameId() || name->asTemplateNameId()) {
const Identifier *id = name->identifier(); const Identifier *id = name->identifier();
_statics.insert(QByteArray::fromRawData(id->chars(), id->size())); _statics.insert(QByteArray::fromRawData(id->chars(), id->size()));
@@ -195,7 +195,7 @@ protected:
if (symbol->isTypedef()) if (symbol->isTypedef())
addType(symbol->name()); addType(symbol->name());
else if (!symbol->type()->isFunctionType() && symbol->enclosingScope()->isClass()) else if (!symbol->type()->isFunctionType() && symbol->enclosingScope()->asClass())
addField(symbol->name()); addField(symbol->name());
return true; return true;
@@ -791,7 +791,7 @@ void CheckSymbols::checkNamespace(NameAST *name)
if (ClassOrNamespace *b = _context.lookupType(name->name, enclosingScope())) { if (ClassOrNamespace *b = _context.lookupType(name->name, enclosingScope())) {
const QList<Symbol *> symbols = b->symbols(); const QList<Symbol *> symbols = b->symbols();
for (const Symbol *s : symbols) { for (const Symbol *s : symbols) {
if (s->isNamespace()) if (s->asNamespace())
return; return;
} }
} }
@@ -812,7 +812,7 @@ bool CheckSymbols::hasVirtualDestructor(Class *klass) const
for (Symbol *s = klass->find(id); s; s = s->next()) { for (Symbol *s = klass->find(id); s; s = s->next()) {
if (!s->name()) if (!s->name())
continue; continue;
if (s->name()->isDestructorNameId()) { if (s->name()->asDestructorNameId()) {
if (Function *funTy = s->type()->asFunctionType()) { if (Function *funTy = s->type()->asFunctionType()) {
if (funTy->isVirtual() && id->match(s->identifier())) if (funTy->isVirtual() && id->match(s->identifier()))
return true; return true;
@@ -1229,7 +1229,7 @@ void CheckSymbols::addType(ClassOrNamespace *b, NameAST *ast)
Kind kind = SemanticHighlighter::TypeUse; Kind kind = SemanticHighlighter::TypeUse;
const QList<Symbol *> &symbols = b->symbols(); const QList<Symbol *> &symbols = b->symbols();
for (const Symbol * const s : symbols) { for (const Symbol * const s : symbols) {
if (s->isNamespace()) { if (s->asNamespace()) {
kind = SemanticHighlighter::NamespaceUse; kind = SemanticHighlighter::NamespaceUse;
break; break;
} }
@@ -1243,8 +1243,8 @@ bool CheckSymbols::isTemplateClass(Symbol *symbol) const
if (symbol) { if (symbol) {
if (Template *templ = symbol->asTemplate()) { if (Template *templ = symbol->asTemplate()) {
if (Symbol *declaration = templ->declaration()) { if (Symbol *declaration = templ->declaration()) {
return declaration->isClass() return declaration->asClass()
|| declaration->isForwardClassDeclaration() || declaration->asForwardClassDeclaration()
|| declaration->isTypedef(); || declaration->isTypedef();
} }
} }
@@ -1264,14 +1264,14 @@ bool CheckSymbols::maybeAddTypeOrStatic(const QList<LookupItem> &candidates, Nam
for (const LookupItem &r : candidates) { for (const LookupItem &r : candidates) {
Symbol *c = r.declaration(); Symbol *c = r.declaration();
if (c->isUsingDeclaration()) // skip using declarations... if (c->asUsingDeclaration()) // skip using declarations...
continue; continue;
if (c->isUsingNamespaceDirective()) // ... and using namespace directives. if (c->asUsingNamespaceDirective()) // ... and using namespace directives.
continue; continue;
if (c->isTypedef() || c->isNamespace() || if (c->isTypedef() || c->asNamespace() ||
c->isStatic() || //consider also static variable c->isStatic() || //consider also static variable
c->isClass() || c->isEnum() || isTemplateClass(c) || c->asClass() || c->asEnum() || isTemplateClass(c) ||
c->isForwardClassDeclaration() || c->isTypenameArgument() || c->enclosingEnum()) { c->asForwardClassDeclaration() || c->asTypenameArgument() || c->enclosingEnum()) {
int line, column; int line, column;
getTokenStartPosition(startToken, &line, &column); getTokenStartPosition(startToken, &line, &column);
const unsigned length = tok.utf16chars(); const unsigned length = tok.utf16chars();
@@ -1279,7 +1279,7 @@ bool CheckSymbols::maybeAddTypeOrStatic(const QList<LookupItem> &candidates, Nam
Kind kind = SemanticHighlighter::TypeUse; Kind kind = SemanticHighlighter::TypeUse;
if (c->enclosingEnum() != nullptr) if (c->enclosingEnum() != nullptr)
kind = SemanticHighlighter::EnumerationUse; kind = SemanticHighlighter::EnumerationUse;
else if (c->isNamespace()) else if (c->asNamespace())
kind = SemanticHighlighter::NamespaceUse; kind = SemanticHighlighter::NamespaceUse;
else if (c->isStatic()) else if (c->isStatic())
// treat static variable as a field(highlighting) // treat static variable as a field(highlighting)
@@ -1309,9 +1309,9 @@ bool CheckSymbols::maybeAddField(const QList<LookupItem> &candidates, NameAST *a
Symbol *c = r.declaration(); Symbol *c = r.declaration();
if (!c) if (!c)
continue; continue;
if (!c->isDeclaration()) if (!c->asDeclaration())
return false; return false;
if (!(c->enclosingScope() && c->enclosingScope()->isClass())) if (!(c->enclosingScope() && c->enclosingScope()->asClass()))
return false; // shadowed return false; // shadowed
if (c->isTypedef() || (c->type() && c->type()->isFunctionType())) if (c->isTypedef() || (c->type() && c->type()->isFunctionType()))
return false; // shadowed return false; // shadowed
@@ -1359,7 +1359,7 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST
// In addition check for destructors, since the leading ~ is not taken into consideration. // In addition check for destructors, since the leading ~ is not taken into consideration.
// We don't want to compare destructors with something else or the other way around. // We don't want to compare destructors with something else or the other way around.
if (isDestructor != c->name()->isDestructorNameId()) if (isDestructor != (c->name()->asDestructorNameId() != nullptr))
continue; continue;
isConstructor = isConstructorDeclaration(c); isConstructor = isConstructorDeclaration(c);

View File

@@ -951,7 +951,7 @@ QVariant SymbolsModel::data(const QModelIndex &index, int role) const
} else if (column == SymbolColumn) { } else if (column == SymbolColumn) {
QString name = Overview().prettyName(symbol->name()); QString name = Overview().prettyName(symbol->name());
if (name.isEmpty()) if (name.isEmpty())
name = QLatin1String(symbol->isBlock() ? "<block>" : "<no name>"); name = QLatin1String(symbol->asBlock() ? "<block>" : "<no name>");
return name; return name;
} }
} }

View File

@@ -232,7 +232,7 @@ void CppAssistProposalItem::applyContextualContent(TextDocumentManipulatorInterf
// except when it might take template parameters. // except when it might take template parameters.
if (!function->hasReturnType() if (!function->hasReturnType()
&& (function->unqualifiedName() && (function->unqualifiedName()
&& !function->unqualifiedName()->isDestructorNameId())) { && !function->unqualifiedName()->asDestructorNameId())) {
// Don't insert any magic, since the user might have just wanted to select the class // Don't insert any magic, since the user might have just wanted to select the class
/// ### port me /// ### port me
@@ -488,7 +488,7 @@ public:
AssistProposalItem *operator()(Symbol *symbol) AssistProposalItem *operator()(Symbol *symbol)
{ {
//using declaration can be qualified //using declaration can be qualified
if (!symbol || !symbol->name() || (symbol->name()->isQualifiedNameId() if (!symbol || !symbol->name() || (symbol->name()->asQualifiedNameId()
&& !symbol->asUsingDeclaration())) && !symbol->asUsingDeclaration()))
return nullptr; return nullptr;
@@ -526,7 +526,7 @@ protected:
void visit(const Identifier *name) override void visit(const Identifier *name) override
{ {
_item = newCompletionItem(name); _item = newCompletionItem(name);
if (!_symbol->isScope() || _symbol->isFunction()) if (!_symbol->asScope() || _symbol->asFunction())
_item->setDetail(overview.prettyType(_symbol->type(), name)); _item->setDetail(overview.prettyType(_symbol->type(), name));
} }
@@ -1441,7 +1441,7 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope)
if (ClassOrNamespace *binding = context.lookupType(scope)) { if (ClassOrNamespace *binding = context.lookupType(scope)) {
for (int i = 0; i < scope->memberCount(); ++i) { for (int i = 0; i < scope->memberCount(); ++i) {
Symbol *member = scope->memberAt(i); Symbol *member = scope->memberAt(i);
if (member->isEnum()) { if (member->asEnum()) {
if (ClassOrNamespace *b = binding->findBlock(block)) if (ClassOrNamespace *b = binding->findBlock(block))
completeNamespace(b); completeNamespace(b);
} }
@@ -1451,21 +1451,21 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope)
if (ClassOrNamespace *b = binding->lookupType(u->name())) if (ClassOrNamespace *b = binding->lookupType(u->name()))
usingBindings.append(b); usingBindings.append(b);
} else if (Class *c = member->asClass()) { } else if (Class *c = member->asClass()) {
if (c->name()->isAnonymousNameId()) { if (c->name()->asAnonymousNameId()) {
if (ClassOrNamespace *b = binding->findBlock(block)) if (ClassOrNamespace *b = binding->findBlock(block))
completeClass(b); completeClass(b);
} }
} }
} }
} }
} else if (scope->isFunction() || scope->isClass() || scope->isNamespace()) { } else if (scope->asFunction() || scope->asClass() || scope->asNamespace()) {
currentBinding = context.lookupType(scope); currentBinding = context.lookupType(scope);
break; break;
} }
} }
for (Scope *scope = currentScope; scope; scope = scope->enclosingScope()) { for (Scope *scope = currentScope; scope; scope = scope->enclosingScope()) {
if (scope->isBlock()) { if (scope->asBlock()) {
for (int i = 0; i < scope->memberCount(); ++i) for (int i = 0; i < scope->memberCount(); ++i)
addCompletionItem(scope->memberAt(i), FunctionLocalsOrder); addCompletionItem(scope->memberAt(i), FunctionLocalsOrder);
} else if (Function *fun = scope->asFunction()) { } else if (Function *fun = scope->asFunction()) {
@@ -1491,7 +1491,7 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope)
const QList<Symbol *> symbols = currentBinding->symbols(); const QList<Symbol *> symbols = currentBinding->symbols();
if (!symbols.isEmpty()) { if (!symbols.isEmpty()) {
if (symbols.first()->isClass()) if (symbols.first()->asClass())
completeClass(currentBinding); completeClass(currentBinding);
else else
completeNamespace(currentBinding); completeNamespace(currentBinding);
@@ -1567,7 +1567,7 @@ bool InternalCppCompletionAssistProcessor::completeScope(const QList<LookupItem>
} }
// it can be class defined inside a block // it can be class defined inside a block
if (classTy->enclosingScope()->isBlock()) { if (classTy->enclosingScope()->asBlock()) {
if (ClassOrNamespace *b = context.lookupType(classTy->name(), classTy->enclosingScope())) { if (ClassOrNamespace *b = context.lookupType(classTy->name(), classTy->enclosingScope())) {
completeClass(b); completeClass(b);
break; break;
@@ -1590,7 +1590,7 @@ bool InternalCppCompletionAssistProcessor::completeScope(const QList<LookupItem>
} else if (Enum *e = ty->asEnumType()) { } else if (Enum *e = ty->asEnumType()) {
// it can be class defined inside a block // it can be class defined inside a block
if (e->enclosingScope()->isBlock()) { if (e->enclosingScope()->asBlock()) {
if (ClassOrNamespace *b = context.lookupType(e)) { if (ClassOrNamespace *b = context.lookupType(e)) {
Block *block = e->enclosingScope()->asBlock(); Block *block = e->enclosingScope()->asBlock();
if (ClassOrNamespace *bb = b->findBlock(block)) { if (ClassOrNamespace *bb = b->findBlock(block)) {
@@ -1708,18 +1708,18 @@ void InternalCppCompletionAssistProcessor::addClassMembersToCompletion(Scope *sc
for (Scope::iterator it = scope->memberBegin(); it != scope->memberEnd(); ++it) { for (Scope::iterator it = scope->memberBegin(); it != scope->memberEnd(); ++it) {
Symbol *member = *it; Symbol *member = *it;
if (member->isFriend() if (member->isFriend()
|| member->isQtPropertyDeclaration() || member->asQtPropertyDeclaration()
|| member->isQtEnum()) { || member->asQtEnum()) {
continue; continue;
} else if (!staticLookup && (member->isTypedef() || } else if (!staticLookup && (member->isTypedef() ||
member->isEnum() || member->asEnum() ||
member->isClass())) { member->asClass())) {
continue; continue;
} else if (member->isClass() && member->name()->isAnonymousNameId()) { } else if (member->asClass() && member->name()->asAnonymousNameId()) {
nestedAnonymouses.insert(member->asClass()); nestedAnonymouses.insert(member->asClass());
} else if (member->isDeclaration()) { } else if (member->asDeclaration()) {
Class *declTypeAsClass = member->asDeclaration()->type()->asClassType(); Class *declTypeAsClass = member->asDeclaration()->type()->asClassType();
if (declTypeAsClass && declTypeAsClass->name()->isAnonymousNameId()) if (declTypeAsClass && declTypeAsClass->name()->asAnonymousNameId())
nestedAnonymouses.erase(declTypeAsClass); nestedAnonymouses.erase(declTypeAsClass);
} }
@@ -1924,7 +1924,7 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q
if (!memberName) if (!memberName)
continue; // skip anonymous member. continue; // skip anonymous member.
else if (memberName->isQualifiedNameId()) else if (memberName->asQualifiedNameId())
continue; // skip continue; // skip
if (Function *funTy = member->type()->asFunctionType()) { if (Function *funTy = member->type()->asFunctionType()) {
@@ -2015,7 +2015,7 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q
Scope *sc = context.thisDocument()->scopeAt(line, column); Scope *sc = context.thisDocument()->scopeAt(line, column);
if (sc && (sc->isClass() || sc->isNamespace())) { if (sc && (sc->asClass() || sc->asNamespace())) {
// It may still be a function call. If the whole line parses as a function // It may still be a function call. If the whole line parses as a function
// declaration, we should be certain that it isn't. // declaration, we should be certain that it isn't.
bool autocompleteSignature = false; bool autocompleteSignature = false;

View File

@@ -124,10 +124,10 @@ CppDeclarableElement::CppDeclarableElement(Symbol *declaration)
overview.showReturnTypes = true; overview.showReturnTypes = true;
overview.showTemplateParameters = true; overview.showTemplateParameters = true;
name = overview.prettyName(declaration->name()); name = overview.prettyName(declaration->name());
if (declaration->enclosingScope()->isClass() || if (declaration->enclosingScope()->asClass() ||
declaration->enclosingScope()->isNamespace() || declaration->enclosingScope()->asNamespace() ||
declaration->enclosingScope()->isEnum() || declaration->enclosingScope()->asEnum() ||
declaration->enclosingScope()->isTemplate()) { declaration->enclosingScope()->asTemplate()) {
qualifiedName = overview.prettyName(LookupContext::fullyQualifiedName(declaration)); qualifiedName = overview.prettyName(LookupContext::fullyQualifiedName(declaration));
helpIdCandidates = stripName(qualifiedName); helpIdCandidates = stripName(qualifiedName);
} else { } else {
@@ -187,7 +187,7 @@ void CppClass::lookupBases(QFutureInterfaceBase &futureInterface,
for (ClassOrNamespace *baseClass : bases) { for (ClassOrNamespace *baseClass : bases) {
const QList<Symbol *> &symbols = baseClass->symbols(); const QList<Symbol *> &symbols = baseClass->symbols();
for (Symbol *symbol : symbols) { for (Symbol *symbol : symbols) {
if (symbol->isClass() && ( if (symbol->asClass() && (
clazz = context.lookupType(symbol)) && clazz = context.lookupType(symbol)) &&
!visited.contains(clazz)) { !visited.contains(clazz)) {
CppClass baseCppClass(symbol); CppClass baseCppClass(symbol);
@@ -345,16 +345,16 @@ public:
static bool isCppClass(Symbol *symbol) static bool isCppClass(Symbol *symbol)
{ {
return symbol->isClass() || symbol->isForwardClassDeclaration() return symbol->asClass() || symbol->asForwardClassDeclaration()
|| (symbol->isTemplate() && symbol->asTemplate()->declaration() || (symbol->asTemplate() && symbol->asTemplate()->declaration()
&& (symbol->asTemplate()->declaration()->isClass() && (symbol->asTemplate()->declaration()->asClass()
|| symbol->asTemplate()->declaration()->isForwardClassDeclaration())); || symbol->asTemplate()->declaration()->asForwardClassDeclaration()));
} }
static Symbol *followClassDeclaration(Symbol *symbol, const Snapshot &snapshot, SymbolFinder symbolFinder, static Symbol *followClassDeclaration(Symbol *symbol, const Snapshot &snapshot, SymbolFinder symbolFinder,
LookupContext *context = nullptr) LookupContext *context = nullptr)
{ {
if (!symbol->isForwardClassDeclaration()) if (!symbol->asForwardClassDeclaration())
return symbol; return symbol;
Symbol *classDeclaration = symbolFinder.findMatchingClassDeclaration(symbol, snapshot); Symbol *classDeclaration = symbolFinder.findMatchingClassDeclaration(symbol, snapshot);
@@ -422,7 +422,7 @@ static QSharedPointer<CppElement> handleLookupItemMatch(const Snapshot &snapshot
element = QSharedPointer<CppElement>(new Unknown(type)); element = QSharedPointer<CppElement>(new Unknown(type));
} else { } else {
const FullySpecifiedType &type = declaration->type(); const FullySpecifiedType &type = declaration->type();
if (declaration->isNamespace()) { if (declaration->asNamespace()) {
element = QSharedPointer<CppElement>(new CppNamespace(declaration)); element = QSharedPointer<CppElement>(new CppNamespace(declaration));
} else if (isCppClass(declaration)) { } else if (isCppClass(declaration)) {
LookupContext contextToUse = context; LookupContext contextToUse = context;
@@ -434,11 +434,11 @@ static QSharedPointer<CppElement> handleLookupItemMatch(const Snapshot &snapshot
element = QSharedPointer<CppElement>(new CppEnumerator(enumerator)); element = QSharedPointer<CppElement>(new CppEnumerator(enumerator));
} else if (declaration->isTypedef()) { } else if (declaration->isTypedef()) {
element = QSharedPointer<CppElement>(new CppTypedef(declaration)); element = QSharedPointer<CppElement>(new CppTypedef(declaration));
} else if (declaration->isFunction() } else if (declaration->asFunction()
|| (type.isValid() && type->isFunctionType()) || (type.isValid() && type->isFunctionType())
|| declaration->isTemplate()) { || declaration->asTemplate()) {
element = QSharedPointer<CppElement>(new CppFunction(declaration)); element = QSharedPointer<CppElement>(new CppFunction(declaration));
} else if (declaration->isDeclaration() && type.isValid()) { } else if (declaration->asDeclaration() && type.isValid()) {
element = QSharedPointer<CppElement>( element = QSharedPointer<CppElement>(
new CppVariable(declaration, context, lookupItem.scope())); new CppVariable(declaration, context, lookupItem.scope()));
} else { } else {
@@ -451,7 +451,7 @@ static QSharedPointer<CppElement> handleLookupItemMatch(const Snapshot &snapshot
// special case for bug QTCREATORBUG-4780 // special case for bug QTCREATORBUG-4780
static bool shouldOmitElement(const LookupItem &lookupItem, const Scope *scope) static bool shouldOmitElement(const LookupItem &lookupItem, const Scope *scope)
{ {
return !lookupItem.declaration() && scope && scope->isFunction() return !lookupItem.declaration() && scope && scope->asFunction()
&& lookupItem.type().match(scope->asFunction()->returnType()); && lookupItem.type().match(scope->asFunction()->returnType());
} }
@@ -484,8 +484,8 @@ static LookupItem findLookupItem(const CPlusPlus::Snapshot &snapshot, CPlusPlus:
return LookupItem(); return LookupItem();
auto isInteresting = [followTypedef](Symbol *symbol) { auto isInteresting = [followTypedef](Symbol *symbol) {
return symbol && (!followTypedef || (symbol->isClass() || symbol->isTemplate() return symbol && (!followTypedef || (symbol->asClass() || symbol->asTemplate()
|| symbol->isForwardClassDeclaration() || symbol->isTypedef())); || symbol->asForwardClassDeclaration() || symbol->isTypedef()));
}; };
for (const LookupItem &item : lookupItems) { for (const LookupItem &item : lookupItems) {
@@ -749,7 +749,7 @@ Utils::Link CppElementEvaluator::linkFromExpression(const QString &expression, c
Symbol *symbol = item.declaration(); Symbol *symbol = item.declaration();
if (!symbol) if (!symbol)
continue; continue;
if (!symbol->isClass() && !symbol->isTemplate()) if (!symbol->asClass() && !symbol->asTemplate())
continue; continue;
return symbol->toLink(); return symbol->toLink();
} }

View File

@@ -413,11 +413,11 @@ static void find_helper(QFutureInterface<CPlusPlus::Usage> &future,
symbol->fileNameLength()); symbol->fileNameLength());
Utils::FilePaths files{sourceFile}; Utils::FilePaths files{sourceFile};
if (symbol->isClass() if (symbol->asClass()
|| symbol->isForwardClassDeclaration() || symbol->asForwardClassDeclaration()
|| (symbol->enclosingScope() || (symbol->enclosingScope()
&& !symbol->isStatic() && !symbol->isStatic()
&& symbol->enclosingScope()->isNamespace())) { && symbol->enclosingScope()->asNamespace())) {
const CPlusPlus::Snapshot snapshotFromContext = context.snapshot(); const CPlusPlus::Snapshot snapshotFromContext = context.snapshot();
for (auto i = snapshotFromContext.begin(), ei = snapshotFromContext.end(); i != ei; ++i) { for (auto i = snapshotFromContext.begin(), ei = snapshotFromContext.end(); i != ei; ++i) {
if (i.key() == sourceFile) if (i.key() == sourceFile)
@@ -479,7 +479,7 @@ void CppFindReferences::findUsages(CPlusPlus::Symbol *symbol,
parameters.symbolFileName = QByteArray(symbol->fileName()); parameters.symbolFileName = QByteArray(symbol->fileName());
parameters.categorize = codeModelSettings()->categorizeFindReferences(); parameters.categorize = codeModelSettings()->categorizeFindReferences();
if (symbol->isClass() || symbol->isForwardClassDeclaration()) { if (symbol->asClass() || symbol->asForwardClassDeclaration()) {
CPlusPlus::Overview overview; CPlusPlus::Overview overview;
parameters.prettySymbolName = parameters.prettySymbolName =
overview.prettyName(CPlusPlus::LookupContext::path(symbol).constLast()); overview.prettyName(CPlusPlus::LookupContext::path(symbol).constLast());

View File

@@ -117,13 +117,13 @@ bool VirtualFunctionHelper::canLookupVirtualFunctionOverrides(Function *function
if (!m_document || m_snapshot.isEmpty() || !m_function || !m_scope) if (!m_document || m_snapshot.isEmpty() || !m_function || !m_scope)
return false; return false;
if (m_scope->isClass() && m_function->isPureVirtual()) { if (m_scope->asClass() && m_function->isPureVirtual()) {
m_staticClassOfFunctionCallExpression = m_scope->asClass(); m_staticClassOfFunctionCallExpression = m_scope->asClass();
return true; return true;
} }
if (!m_baseExpressionAST || !m_expressionDocument if (!m_baseExpressionAST || !m_expressionDocument
|| m_scope->isClass() || m_scope->isFunction()) { || m_scope->asClass() || m_scope->asFunction()) {
return false; return false;
} }
@@ -191,7 +191,7 @@ Class *VirtualFunctionHelper::staticClassOfFunctionCallExpression_internal() con
const QList<Symbol *> symbols = binding->symbols(); const QList<Symbol *> symbols = binding->symbols();
if (!symbols.isEmpty()) { if (!symbols.isEmpty()) {
Symbol * const first = symbols.first(); Symbol * const first = symbols.first();
if (first->isForwardClassDeclaration()) if (first->asForwardClassDeclaration())
result = m_finder->findMatchingClassDeclaration(first, m_snapshot); result = m_finder->findMatchingClassDeclaration(first, m_snapshot);
} }
} }
@@ -253,7 +253,7 @@ static bool isForwardClassDeclaration(Type *type)
return true; return true;
} else if (Template *templ = type->asTemplateType()) { } else if (Template *templ = type->asTemplateType()) {
if (Symbol *declaration = templ->declaration()) { if (Symbol *declaration = templ->declaration()) {
if (declaration->isForwardClassDeclaration()) if (declaration->asForwardClassDeclaration())
return true; return true;
} }
} }
@@ -384,7 +384,7 @@ Link attemptDeclDef(const QTextCursor &cursor, Snapshot snapshot,
Symbol *findDefinition(Symbol *symbol, const Snapshot &snapshot, SymbolFinder *symbolFinder) Symbol *findDefinition(Symbol *symbol, const Snapshot &snapshot, SymbolFinder *symbolFinder)
{ {
if (symbol->isFunction()) if (symbol->asFunction())
return nullptr; // symbol is a function definition. return nullptr; // symbol is a function definition.
if (!symbol->type()->isFunctionType()) if (!symbol->type()->isFunctionType())
@@ -706,7 +706,7 @@ void FollowSymbolUnderCursor::findLink(
for (const LookupItem &r : resolvedSymbols) { for (const LookupItem &r : resolvedSymbols) {
if (Symbol *d = r.declaration()) { if (Symbol *d = r.declaration()) {
if (d->isDeclaration() || d->isFunction()) { if (d->asDeclaration() || d->asFunction()) {
const QString fileName = QString::fromUtf8(d->fileName(), d->fileNameLength()); const QString fileName = QString::fromUtf8(d->fileName(), d->fileNameLength());
if (data.filePath().toString() == fileName) { if (data.filePath().toString() == fileName) {
if (line == d->line() && positionInBlock >= d->column()) { if (line == d->line() && positionInBlock >= d->column()) {
@@ -715,7 +715,7 @@ void FollowSymbolUnderCursor::findLink(
break; break;
} }
} }
} else if (d->isUsingDeclaration()) { } else if (d->asUsingDeclaration()) {
int tokenBeginLineNumber = 0; int tokenBeginLineNumber = 0;
int tokenBeginColumnNumber = 0; int tokenBeginColumnNumber = 0;
Utils::Text::convertPosition(document, beginOfToken, &tokenBeginLineNumber, Utils::Text::convertPosition(document, beginOfToken, &tokenBeginLineNumber,
@@ -768,11 +768,11 @@ void FollowSymbolUnderCursor::findLink(
if (def == lastVisibleSymbol) if (def == lastVisibleSymbol)
def = nullptr; // jump to declaration then. def = nullptr; // jump to declaration then.
if (symbol->isForwardClassDeclaration()) { if (symbol->asForwardClassDeclaration()) {
def = symbolFinder->findMatchingClassDeclaration(symbol, snapshot); def = symbolFinder->findMatchingClassDeclaration(symbol, snapshot);
} else if (Template *templ = symbol->asTemplate()) { } else if (Template *templ = symbol->asTemplate()) {
if (Symbol *declaration = templ->declaration()) { if (Symbol *declaration = templ->declaration()) {
if (declaration->isForwardClassDeclaration()) if (declaration->asForwardClassDeclaration())
def = symbolFinder->findMatchingClassDeclaration(declaration, snapshot); def = symbolFinder->findMatchingClassDeclaration(declaration, snapshot);
} }
} }
@@ -828,7 +828,7 @@ void FollowSymbolUnderCursor::switchDeclDef(
} else if (SimpleDeclarationAST *simpleDeclaration = ast->asSimpleDeclaration()) { } else if (SimpleDeclarationAST *simpleDeclaration = ast->asSimpleDeclaration()) {
if (List<Symbol *> *symbols = simpleDeclaration->symbols) { if (List<Symbol *> *symbols = simpleDeclaration->symbols) {
if (Symbol *symbol = symbols->value) { if (Symbol *symbol = symbols->value) {
if (symbol->isDeclaration()) { if (symbol->asDeclaration()) {
declarationSymbol = symbol; declarationSymbol = symbol;
if (symbol->type()->isFunctionType()) { if (symbol->type()->isFunctionType()) {
functionDeclarationSymbol = symbol; functionDeclarationSymbol = symbol;

View File

@@ -76,8 +76,8 @@ protected:
if (Symbol *member = scope->memberAt(i)) { if (Symbol *member = scope->memberAt(i)) {
if (member->isTypedef()) if (member->isTypedef())
continue; continue;
if (!member->isGenerated() && (member->isDeclaration() || member->isArgument())) { if (!member->isGenerated() && (member->asDeclaration() || member->asArgument())) {
if (member->name() && member->name()->isNameId()) { if (member->name() && member->name()->asNameId()) {
const Token token = tokenAt(member->sourceLocation()); const Token token = tokenAt(member->sourceLocation());
int line, column; int line, column;
getPosition(token.utf16charsBegin(), &line, &column); getPosition(token.utf16charsBegin(), &line, &column);
@@ -99,10 +99,10 @@ protected:
const Identifier *id = identifier(simpleName->identifier_token); const Identifier *id = identifier(simpleName->identifier_token);
for (int i = _scopeStack.size() - 1; i != -1; --i) { for (int i = _scopeStack.size() - 1; i != -1; --i) {
if (Symbol *member = _scopeStack.at(i)->find(id)) { if (Symbol *member = _scopeStack.at(i)->find(id)) {
if (member->isTypedef() || !(member->isDeclaration() || member->isArgument())) if (member->isTypedef() || !(member->asDeclaration() || member->asArgument()))
continue; continue;
if (!member->isGenerated() && (member->sourceLocation() < firstToken if (!member->isGenerated() && (member->sourceLocation() < firstToken
|| member->enclosingScope()->isFunction())) { || member->enclosingScope()->asFunction())) {
int line, column; int line, column;
getTokenStartPosition(simpleName->identifier_token, &line, &column); getTokenStartPosition(simpleName->identifier_token, &line, &column);
localUses[member].append( localUses[member].append(

View File

@@ -1485,13 +1485,13 @@ QSet<QString> CppModelManager::symbolsInFiles(const QSet<Utils::FilePath> &files
const CPlusPlus::Identifier *symId = sym->identifier(); const CPlusPlus::Identifier *symId = sym->identifier();
// Add any class, function or namespace identifiers // Add any class, function or namespace identifiers
if ((sym->isClass() || sym->isFunction() || sym->isNamespace()) && symId if ((sym->asClass() || sym->asFunction() || sym->asNamespace()) && symId
&& symId->chars()) { && symId->chars()) {
uniqueSymbols.insert(QString::fromUtf8(symId->chars())); uniqueSymbols.insert(QString::fromUtf8(symId->chars()));
} }
// Handle specific case : get "Foo" in "void Foo::function() {}" // Handle specific case : get "Foo" in "void Foo::function() {}"
if (sym->isFunction() && !sym->asFunction()->isDeclaration()) { if (sym->asFunction() && !sym->asFunction()->asDeclaration()) {
const char *className = belongingClassName(sym->asFunction()); const char *className = belongingClassName(sym->asFunction());
if (className) if (className)
uniqueSymbols.insert(QString::fromUtf8(className)); uniqueSymbols.insert(QString::fromUtf8(className));

View File

@@ -67,11 +67,11 @@ public:
QString name = overviewModel->_overview.prettyName(symbol->name()); QString name = overviewModel->_overview.prettyName(symbol->name());
if (name.isEmpty()) if (name.isEmpty())
name = QLatin1String("anonymous"); name = QLatin1String("anonymous");
if (symbol->isObjCForwardClassDeclaration()) if (symbol->asObjCForwardClassDeclaration())
name = QLatin1String("@class ") + name; name = QLatin1String("@class ") + name;
if (symbol->isObjCForwardProtocolDeclaration() || symbol->isObjCProtocol()) if (symbol->asObjCForwardProtocolDeclaration() || symbol->asObjCProtocol())
name = QLatin1String("@protocol ") + name; name = QLatin1String("@protocol ") + name;
if (symbol->isObjCClass()) { if (symbol->asObjCClass()) {
ObjCClass *clazz = symbol->asObjCClass(); ObjCClass *clazz = symbol->asObjCClass();
if (clazz->isInterface()) if (clazz->isInterface())
name = QLatin1String("@interface ") + name; name = QLatin1String("@interface ") + name;
@@ -83,7 +83,7 @@ public:
clazz->categoryName())); clazz->categoryName()));
} }
} }
if (symbol->isObjCPropertyDeclaration()) if (symbol->asObjCPropertyDeclaration())
name = QLatin1String("@property ") + name; name = QLatin1String("@property ") + name;
// if symbol is a template we might change it now - so, use a copy instead as we're const // if symbol is a template we might change it now - so, use a copy instead as we're const
Symbol *symbl = symbol; Symbol *symbl = symbol;
@@ -98,13 +98,13 @@ public:
name += QString("<%1>").arg(parameters.join(QLatin1String(", "))); name += QString("<%1>").arg(parameters.join(QLatin1String(", ")));
symbl = templateDeclaration; symbl = templateDeclaration;
} }
if (symbl->isObjCMethod()) { if (symbl->asObjCMethod()) {
ObjCMethod *method = symbl->asObjCMethod(); ObjCMethod *method = symbl->asObjCMethod();
if (method->isStatic()) if (method->isStatic())
name = QLatin1Char('+') + name; name = QLatin1Char('+') + name;
else else
name = QLatin1Char('-') + name; name = QLatin1Char('-') + name;
} else if (! symbl->isScope() || symbl->isFunction()) { } else if (! symbl->asScope() || symbl->asFunction()) {
QString type = overviewModel->_overview.prettyType(symbl->type()); QString type = overviewModel->_overview.prettyType(symbl->type());
if (Function *f = symbl->type()->asFunctionType()) { if (Function *f = symbl->type()->asFunctionType()) {
name += type; name += type;

View File

@@ -412,9 +412,9 @@ void PointerDeclarationFormatter::checkAndRewrite(DeclaratorAST *declarator,
QString rewrittenDeclaration; QString rewrittenDeclaration;
const Name *name = symbol->name(); const Name *name = symbol->name();
if (name) { if (name) {
if (name->isOperatorNameId() if (name->asOperatorNameId()
|| (name->isQualifiedNameId() || (name->asQualifiedNameId()
&& name->asQualifiedNameId()->name()->isOperatorNameId())) { && name->asQualifiedNameId()->name()->asOperatorNameId())) {
const QString operatorText = m_cppRefactoringFile->textOf(declarator->core_declarator); const QString operatorText = m_cppRefactoringFile->textOf(declarator->core_declarator);
m_overview.includeWhiteSpaceInOperatorName = operatorText.contains(QLatin1Char(' ')); m_overview.includeWhiteSpaceInOperatorName = operatorText.contains(QLatin1Char(' '));
} }

View File

@@ -159,7 +159,7 @@ Class *isMemberFunction(const LookupContext &context, Function *function)
QTC_ASSERT(function, return nullptr); QTC_ASSERT(function, return nullptr);
Scope *enclosingScope = function->enclosingScope(); Scope *enclosingScope = function->enclosingScope();
while (!(enclosingScope->isNamespace() || enclosingScope->isClass())) while (!(enclosingScope->asNamespace() || enclosingScope->asClass()))
enclosingScope = enclosingScope->enclosingScope(); enclosingScope = enclosingScope->enclosingScope();
QTC_ASSERT(enclosingScope != nullptr, return nullptr); QTC_ASSERT(enclosingScope != nullptr, return nullptr);
@@ -167,7 +167,7 @@ Class *isMemberFunction(const LookupContext &context, Function *function)
if (!functionName) if (!functionName)
return nullptr; return nullptr;
if (!functionName->isQualifiedNameId()) if (!functionName->asQualifiedNameId())
return nullptr; // trying to add a declaration for a global function return nullptr; // trying to add a declaration for a global function
const QualifiedNameId *q = functionName->asQualifiedNameId(); const QualifiedNameId *q = functionName->asQualifiedNameId();
@@ -192,7 +192,7 @@ Namespace *isNamespaceFunction(const LookupContext &context, Function *function)
return nullptr; return nullptr;
Scope *enclosingScope = function->enclosingScope(); Scope *enclosingScope = function->enclosingScope();
while (!(enclosingScope->isNamespace() || enclosingScope->isClass())) while (!(enclosingScope->asNamespace() || enclosingScope->asClass()))
enclosingScope = enclosingScope->enclosingScope(); enclosingScope = enclosingScope->enclosingScope();
QTC_ASSERT(enclosingScope != nullptr, return nullptr); QTC_ASSERT(enclosingScope != nullptr, return nullptr);
@@ -201,7 +201,7 @@ Namespace *isNamespaceFunction(const LookupContext &context, Function *function)
return nullptr; return nullptr;
// global namespace // global namespace
if (!functionName->isQualifiedNameId()) { if (!functionName->asQualifiedNameId()) {
const QList<Symbol *> symbols = context.globalNamespace()->symbols(); const QList<Symbol *> symbols = context.globalNamespace()->symbols();
for (Symbol *s : symbols) { for (Symbol *s : symbols) {
if (Namespace *matchingNamespace = s->asNamespace()) if (Namespace *matchingNamespace = s->asNamespace())
@@ -259,8 +259,8 @@ void insertNewIncludeDirective(const QString &include, CppRefactoringFilePtr fil
bool nameIncludesOperatorName(const Name *name) bool nameIncludesOperatorName(const Name *name)
{ {
return name->isOperatorNameId() return name->asOperatorNameId()
|| (name->isQualifiedNameId() && name->asQualifiedNameId()->name()->isOperatorNameId()); || (name->asQualifiedNameId() && name->asQualifiedNameId()->name()->asOperatorNameId());
} }
QString memberBaseName(const QString &name) QString memberBaseName(const QString &name)
@@ -1981,15 +1981,15 @@ LookupResult lookUpDefinition(const CppQuickFixInterface &interface, const NameA
const QList<LookupItem> results = interface.context().lookup(name, scope); const QList<LookupItem> results = interface.context().lookup(name, scope);
for (const LookupItem &item : results) { for (const LookupItem &item : results) {
if (Symbol *declaration = item.declaration()) { if (Symbol *declaration = item.declaration()) {
if (declaration->isClass()) if (declaration->asClass())
return LookupResult::Declared; return LookupResult::Declared;
if (declaration->isForwardClassDeclaration()) if (declaration->asForwardClassDeclaration())
return LookupResult::ForwardDeclared; return LookupResult::ForwardDeclared;
if (Template *templ = declaration->asTemplate()) { if (Template *templ = declaration->asTemplate()) {
if (Symbol *declaration = templ->declaration()) { if (Symbol *declaration = templ->declaration()) {
if (declaration->isClass()) if (declaration->asClass())
return LookupResult::Declared; return LookupResult::Declared;
if (declaration->isForwardClassDeclaration()) if (declaration->asForwardClassDeclaration())
return LookupResult::ForwardDeclared; return LookupResult::ForwardDeclared;
} }
} }
@@ -2648,7 +2648,7 @@ void InsertDeclFromDef::match(const CppQuickFixInterface &interface, QuickFixOpe
for (Symbol *symbol = matchingClass->find(qName->identifier()); for (Symbol *symbol = matchingClass->find(qName->identifier());
symbol; symbol = symbol->next()) { symbol; symbol = symbol->next()) {
Symbol *s = symbol; Symbol *s = symbol;
if (fun->enclosingScope()->isTemplate()) { if (fun->enclosingScope()->asTemplate()) {
if (const Template *templ = s->type()->asTemplateType()) { if (const Template *templ = s->type()->asTemplateType()) {
if (Symbol *decl = templ->declaration()) { if (Symbol *decl = templ->declaration()) {
if (decl->type()->isFunctionType()) if (decl->type()->isFunctionType())
@@ -3221,7 +3221,7 @@ public:
// Collect all member functions. // Collect all member functions.
for (auto it = theClass->memberBegin(); it != theClass->memberEnd(); ++it) { for (auto it = theClass->memberBegin(); it != theClass->memberEnd(); ++it) {
Symbol * const s = *it; Symbol * const s = *it;
if (!s->identifier() || !s->type() || !s->isDeclaration() || s->asFunction()) if (!s->identifier() || !s->type() || !s->asDeclaration() || s->asFunction())
continue; continue;
Function * const func = s->type()->asFunctionType(); Function * const func = s->type()->asFunctionType();
if (!func || func->isSignal() || func->isFriend()) if (!func || func->isSignal() || func->isFriend())
@@ -3676,7 +3676,7 @@ protected:
if (m_settings->addUsingNamespaceinCppFile()) { if (m_settings->addUsingNamespaceinCppFile()) {
// check if we have to insert a using namespace ... // check if we have to insert a using namespace ...
auto requiredNamespaces = getNamespaceNames( auto requiredNamespaces = getNamespaceNames(
symbol->isClass() ? symbol : symbol->enclosingClass()); symbol->asClass() ? symbol : symbol->enclosingClass());
NSCheckerVisitor visitor(m_sourceFile.get(), NSCheckerVisitor visitor(m_sourceFile.get(),
requiredNamespaces, requiredNamespaces,
m_sourceFile->position(m_sourceFileInsertionPoint.line(), m_sourceFile->position(m_sourceFileInsertionPoint.line(),
@@ -3933,7 +3933,7 @@ void GetterSetterRefactoringHelper::performGeneration(ExistingGetterSetterData d
auto getterLocation = m_settings->determineGetterLocation(1); auto getterLocation = m_settings->determineGetterLocation(1);
// if we have an anonymous class we must add code inside the class // if we have an anonymous class we must add code inside the class
if (data.clazz->name()->isAnonymousNameId()) if (data.clazz->name()->asAnonymousNameId())
getterLocation = CppQuickFixSettings::FunctionLocation::InsideClass; getterLocation = CppQuickFixSettings::FunctionLocation::InsideClass;
if (getterLocation == CppQuickFixSettings::FunctionLocation::InsideClass) { if (getterLocation == CppQuickFixSettings::FunctionLocation::InsideClass) {
@@ -4055,7 +4055,7 @@ void GetterSetterRefactoringHelper::performGeneration(ExistingGetterSetterData d
auto setterLocation = m_settings->determineSetterLocation(body.count('\n') - 2); auto setterLocation = m_settings->determineSetterLocation(body.count('\n') - 2);
// if we have an anonymous class we must add code inside the class // if we have an anonymous class we must add code inside the class
if (data.clazz->name()->isAnonymousNameId()) if (data.clazz->name()->asAnonymousNameId())
setterLocation = CppQuickFixSettings::FunctionLocation::InsideClass; setterLocation = CppQuickFixSettings::FunctionLocation::InsideClass;
if (setterLocation == CppQuickFixSettings::FunctionLocation::CppFile && !hasSourceFile()) if (setterLocation == CppQuickFixSettings::FunctionLocation::CppFile && !hasSourceFile())
@@ -4133,7 +4133,7 @@ void GetterSetterRefactoringHelper::performGeneration(ExistingGetterSetterData d
// body.count('\n') - 2 : do not count the 2 at start // body.count('\n') - 2 : do not count the 2 at start
auto resetLocation = m_settings->determineSetterLocation(body.count('\n') - 2); auto resetLocation = m_settings->determineSetterLocation(body.count('\n') - 2);
// if we have an anonymous class we must add code inside the class // if we have an anonymous class we must add code inside the class
if (data.clazz->name()->isAnonymousNameId()) if (data.clazz->name()->asAnonymousNameId())
resetLocation = CppQuickFixSettings::FunctionLocation::InsideClass; resetLocation = CppQuickFixSettings::FunctionLocation::InsideClass;
if (resetLocation == CppQuickFixSettings::FunctionLocation::CppFile && !hasSourceFile()) if (resetLocation == CppQuickFixSettings::FunctionLocation::CppFile && !hasSourceFile())
@@ -4287,7 +4287,7 @@ QList<Symbol *> getMemberFunctions(const Class *clazz)
Symbol *const s = *it; Symbol *const s = *it;
if (!s->identifier() || !s->type()) if (!s->identifier() || !s->type())
continue; continue;
if ((s->isDeclaration() && s->type()->asFunctionType()) || s->asFunction()) if ((s->asDeclaration() && s->type()->asFunctionType()) || s->asFunction())
memberFunctions << s; memberFunctions << s;
} }
return memberFunctions; return memberFunctions;
@@ -4372,7 +4372,7 @@ void GenerateGetterSetter::match(const CppQuickFixInterface &interface, QuickFix
// no type can be determined // no type can be determined
return; return;
} }
if (!symbol->isDeclaration()) { if (!symbol->asDeclaration()) {
return; return;
} }
existing.declarationSymbol = symbol->asDeclaration(); existing.declarationSymbol = symbol->asDeclaration();
@@ -4668,9 +4668,9 @@ public:
Symbol *const s = *it; Symbol *const s = *it;
if (!s->identifier() || !s->type() || s->type().isTypedef()) if (!s->identifier() || !s->type() || s->type().isTypedef())
continue; continue;
if ((s->isDeclaration() && s->type()->asFunctionType()) || s->asFunction()) if ((s->asDeclaration() && s->type()->asFunctionType()) || s->asFunction())
memberFunctions << s; memberFunctions << s;
else if (s->isDeclaration() && (s->isPrivate() || s->isProtected())) else if (s->asDeclaration() && (s->isPrivate() || s->isProtected()))
dataMembers << s; dataMembers << s;
} }
@@ -5263,7 +5263,7 @@ void ExtractFunction::match(const CppQuickFixInterface &interface, QuickFixOpera
|| !refFuncDef->function_body->asCompoundStatement()->statement_list || !refFuncDef->function_body->asCompoundStatement()->statement_list
|| !refFuncDef->symbol || !refFuncDef->symbol
|| !refFuncDef->symbol->name() || !refFuncDef->symbol->name()
|| refFuncDef->symbol->enclosingScope()->isTemplate() /* TODO: Templates... */) { || refFuncDef->symbol->enclosingScope()->asTemplate() /* TODO: Templates... */) {
return; return;
} }
@@ -5467,7 +5467,7 @@ public:
|| !qName->identifier()->match(s->identifier()) || !qName->identifier()->match(s->identifier())
|| !s->type()->isFunctionType() || !s->type()->isFunctionType()
|| !s->type().match(func->type()) || !s->type().match(func->type())
|| s->isFunction()) { || s->asFunction()) {
continue; continue;
} }
@@ -6657,7 +6657,7 @@ void MoveFuncDefToDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
for (Symbol *symbol = matchingClass->find(qName->identifier()); for (Symbol *symbol = matchingClass->find(qName->identifier());
symbol; symbol = symbol->next()) { symbol; symbol = symbol->next()) {
Symbol *s = symbol; Symbol *s = symbol;
if (func->enclosingScope()->isTemplate()) { if (func->enclosingScope()->asTemplate()) {
if (const Template *templ = s->type()->asTemplateType()) { if (const Template *templ = s->type()->asTemplateType()) {
if (Symbol *decl = templ->declaration()) { if (Symbol *decl = templ->declaration()) {
if (decl->type()->isFunctionType()) if (decl->type()->isFunctionType())
@@ -6669,7 +6669,7 @@ void MoveFuncDefToDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
|| !qName->identifier()->match(s->identifier()) || !qName->identifier()->match(s->identifier())
|| !s->type()->isFunctionType() || !s->type()->isFunctionType()
|| !s->type().match(func->type()) || !s->type().match(func->type())
|| s->isFunction()) { || s->asFunction()) {
continue; continue;
} }
@@ -7362,8 +7362,8 @@ bool findRawAccessFunction(Class *klass, PointerType *pointerType, QString *objA
for (auto it = klass->memberBegin(), end = klass->memberEnd(); it != end; ++it) { for (auto it = klass->memberBegin(), end = klass->memberEnd(); it != end; ++it) {
if (Function *func = (*it)->asFunction()) { if (Function *func = (*it)->asFunction()) {
const Name *funcName = func->name(); const Name *funcName = func->name();
if (!funcName->isOperatorNameId() if (!funcName->asOperatorNameId()
&& !funcName->isConversionNameId() && !funcName->asConversionNameId()
&& func->returnType().type() == pointerType && func->returnType().type() == pointerType
&& func->isConst() && func->isConst()
&& func->argumentCount() == 0) { && func->argumentCount() == 0) {
@@ -8200,7 +8200,7 @@ void RemoveUsingNamespace::match(const CppQuickFixInterface &interface, QuickFix
if (path.last()->asName()) if (path.last()->asName())
--n; --n;
UsingDirectiveAST *usingDirective = path.at(n)->asUsingDirective(); UsingDirectiveAST *usingDirective = path.at(n)->asUsingDirective();
if (usingDirective && usingDirective->name->name->isNameId()) { if (usingDirective && usingDirective->name->name->asNameId()) {
result << new RemoveUsingNamespaceOperation(interface, usingDirective, false); result << new RemoveUsingNamespaceOperation(interface, usingDirective, false);
const bool isHeader = ProjectFile::isHeader(ProjectFile::classify(interface.filePath().toString())); const bool isHeader = ProjectFile::isHeader(ProjectFile::classify(interface.filePath().toString()));
if (isHeader && path.at(n - 1)->asTranslationUnit()) // using namespace at global scope if (isHeader && path.at(n - 1)->asTranslationUnit()) // using namespace at global scope
@@ -8813,9 +8813,9 @@ public:
Symbol *const s = *it; Symbol *const s = *it;
if (!s->identifier() || !s->type() || s->type().isTypedef()) if (!s->identifier() || !s->type() || s->type().isTypedef())
continue; continue;
if ((s->isDeclaration() && s->type()->asFunctionType()) || s->asFunction()) if ((s->asDeclaration() && s->type()->asFunctionType()) || s->asFunction())
continue; continue;
if (s->isDeclaration() && (s->isPrivate() || s->isProtected()) && !s->isStatic()) { if (s->asDeclaration() && (s->isPrivate() || s->isProtected()) && !s->isStatic()) {
const auto name = QString::fromUtf8(s->identifier()->chars(), const auto name = QString::fromUtf8(s->identifier()->chars(),
s->identifier()->size()); s->identifier()->size());
parameterModel.emplaceBackParameter(name, s, memberCounter++); parameterModel.emplaceBackParameter(name, s, memberCounter++);

View File

@@ -178,7 +178,7 @@ bool isOwnershipRAIIType(Symbol *symbol, const LookupContext &context)
// This is not a "real" comparison of types. What we do is to resolve the symbol // This is not a "real" comparison of types. What we do is to resolve the symbol
// in question and then try to match its name with already known ones. // in question and then try to match its name with already known ones.
if (symbol->isDeclaration()) { if (symbol->asDeclaration()) {
Declaration *declaration = symbol->asDeclaration(); Declaration *declaration = symbol->asDeclaration();
const NamedType *namedType = declaration->type()->asNamedType(); const NamedType *namedType = declaration->type()->asNamedType();
if (namedType) { if (namedType) {

View File

@@ -216,7 +216,7 @@ QString DoxygenGenerator::generate(QTextCursor cursor, DeclarationAST *decl)
if (ClassSpecifierAST *classSpec = spec->asClassSpecifier()) { if (ClassSpecifierAST *classSpec = spec->asClassSpecifier()) {
if (classSpec->name) { if (classSpec->name) {
QString aggregate; QString aggregate;
if (classSpec->symbol->isClass()) if (classSpec->symbol->asClass())
aggregate = QLatin1String("class"); aggregate = QLatin1String("class");
else if (classSpec->symbol->isStruct()) else if (classSpec->symbol->isStruct())
aggregate = QLatin1String("struct"); aggregate = QLatin1String("struct");

View File

@@ -130,11 +130,11 @@ static bool isVirtualFunction_helper(const Function *function,
const QList<LookupItem> results = context.lookup(function->name(), function->enclosingScope()); const QList<LookupItem> results = context.lookup(function->name(), function->enclosingScope());
if (!results.isEmpty()) { if (!results.isEmpty()) {
const bool isDestructor = function->name()->isDestructorNameId(); const bool isDestructor = function->name()->asDestructorNameId();
for (const LookupItem &item : results) { for (const LookupItem &item : results) {
if (Symbol *symbol = item.declaration()) { if (Symbol *symbol = item.declaration()) {
if (Function *functionType = symbol->type()->asFunctionType()) { if (Function *functionType = symbol->type()->asFunctionType()) {
if (functionType->name()->isDestructorNameId() != isDestructor) if ((functionType->name()->asDestructorNameId() != nullptr) != isDestructor)
continue; continue;
if (functionType == function) // already tested if (functionType == function) // already tested
continue; continue;

View File

@@ -267,9 +267,9 @@ QString SearchSymbols::scopeName(const QString &name, const Symbol *symbol) cons
if (!name.isEmpty()) if (!name.isEmpty())
return name; return name;
if (symbol->isNamespace()) { if (symbol->asNamespace()) {
return QLatin1String("<anonymous namespace>"); return QLatin1String("<anonymous namespace>");
} else if (symbol->isEnum()) { } else if (symbol->asEnum()) {
return QLatin1String("<anonymous enum>"); return QLatin1String("<anonymous enum>");
} else if (const Class *c = symbol->asClass()) { } else if (const Class *c = symbol->asClass()) {
if (c->isUnion()) if (c->isUnion())

View File

@@ -378,7 +378,7 @@ void SymbolFinder::findMatchingDeclaration(const LookupContext &context,
return; return;
Scope *enclosingScope = functionType->enclosingScope(); Scope *enclosingScope = functionType->enclosingScope();
while (!(enclosingScope->isNamespace() || enclosingScope->isClass())) while (!(enclosingScope->asNamespace() || enclosingScope->asClass()))
enclosingScope = enclosingScope->enclosingScope(); enclosingScope = enclosingScope->enclosingScope();
QTC_ASSERT(enclosingScope != nullptr, return); QTC_ASSERT(enclosingScope != nullptr, return);
@@ -451,9 +451,9 @@ QList<Declaration *> SymbolFinder::findMatchingDeclaration(const LookupContext &
// For member functions not defined inline, add fuzzy matches as fallbacks. We cannot do // For member functions not defined inline, add fuzzy matches as fallbacks. We cannot do
// this for free functions, because there is no guarantee that there's a separate declaration. // this for free functions, because there is no guarantee that there's a separate declaration.
QList<Declaration *> fuzzyMatches = argumentCountMatch + nameMatch; QList<Declaration *> fuzzyMatches = argumentCountMatch + nameMatch;
if (!functionType->enclosingScope() || !functionType->enclosingScope()->isClass()) { if (!functionType->enclosingScope() || !functionType->enclosingScope()->asClass()) {
for (Declaration * const d : fuzzyMatches) { for (Declaration * const d : fuzzyMatches) {
if (d->enclosingScope() && d->enclosingScope()->isClass()) if (d->enclosingScope() && d->enclosingScope()->asClass())
result.append(d); result.append(d);
} }
} }

View File

@@ -159,7 +159,7 @@ LookupItem TypeHierarchyBuilder::followTypedef(const LookupContext &context, con
Symbol *s = item.declaration(); Symbol *s = item.declaration();
if (!s) if (!s)
continue; continue;
if (!s->isClass() && !s->isTemplate() && !s->isTypedef()) if (!s->asClass() && !s->asTemplate() && !s->isTypedef())
continue; continue;
if (!typedefs.insert(s).second) if (!typedefs.insert(s).second)
continue; continue;

View File

@@ -70,15 +70,15 @@ static void debugCppSymbolRecursion(QTextStream &str, const Overview &o,
for (int i = 0; i < recursion; i++) for (int i = 0; i < recursion; i++)
str << " "; str << " ";
str << "Symbol: " << o.prettyName(s.name()) << " at line " << s.line(); str << "Symbol: " << o.prettyName(s.name()) << " at line " << s.line();
if (s.isFunction()) if (s.asFunction())
str << " function"; str << " function";
if (s.isClass()) if (s.asClass())
str << " class"; str << " class";
if (s.isDeclaration()) if (s.asDeclaration())
str << " declaration"; str << " declaration";
if (s.isBlock()) if (s.asBlock())
str << " block"; str << " block";
if (doRecurse && s.isScope()) { if (doRecurse && s.asScope()) {
const Scope *scoped = s.asScope(); const Scope *scoped = s.asScope();
const int size = scoped->memberCount(); const int size = scoped->memberCount();
str << " scoped symbol of " << size << '\n'; str << " scoped symbol of " << size << '\n';
@@ -106,17 +106,17 @@ QDebug operator<<(QDebug d, const Scope &scope)
QTextStream str(&output); QTextStream str(&output);
const int size = scope.memberCount(); const int size = scope.memberCount();
str << "Scope of " << size; str << "Scope of " << size;
if (scope.isNamespace()) if (scope.asNamespace())
str << " namespace"; str << " namespace";
if (scope.isClass()) if (scope.asClass())
str << " class"; str << " class";
if (scope.isEnum()) if (scope.asEnum())
str << " enum"; str << " enum";
if (scope.isBlock()) if (scope.asBlock())
str << " block"; str << " block";
if (scope.isFunction()) if (scope.asFunction())
str << " function"; str << " function";
if (scope.isDeclaration()) if (scope.asDeclaration())
str << " prototype"; str << " prototype";
#if 0 // ### port me #if 0 // ### port me
if (const Symbol *owner = &scope) { if (const Symbol *owner = &scope) {
@@ -168,7 +168,7 @@ static void blockRecursion(const Overview &overview,
// Fixme: loop variables or similar are currently seen in the outer scope // Fixme: loop variables or similar are currently seen in the outer scope
for (int s = scope->memberCount() - 1; s >= 0; --s){ for (int s = scope->memberCount() - 1; s >= 0; --s){
const CPlusPlus::Symbol *symbol = scope->memberAt(s); const CPlusPlus::Symbol *symbol = scope->memberAt(s);
if (symbol->isDeclaration()) { if (symbol->asDeclaration()) {
// Find out about shadowed symbols by bookkeeping // Find out about shadowed symbols by bookkeeping
// the already seen occurrences in a hash. // the already seen occurrences in a hash.
const QString name = overview.prettyName(symbol->name()); const QString name = overview.prettyName(symbol->name());
@@ -210,7 +210,7 @@ QStringList getUninitializedVariables(const Snapshot &snapshot,
// and the innermost scope at cursor position // and the innermost scope at cursor position
const Function *function = nullptr; const Function *function = nullptr;
const Scope *innerMostScope = nullptr; const Scope *innerMostScope = nullptr;
if (symbolAtLine->isFunction()) { if (symbolAtLine->asFunction()) {
function = symbolAtLine->asFunction(); function = symbolAtLine->asFunction();
if (function->memberCount() == 1) // Skip over function block if (function->memberCount() == 1) // Skip over function block
if (Block *block = function->memberAt(0)->asBlock()) if (Block *block = function->memberAt(0)->asBlock())
@@ -218,7 +218,7 @@ QStringList getUninitializedVariables(const Snapshot &snapshot,
} else { } else {
if (const Scope *functionScope = symbolAtLine->enclosingFunction()) { if (const Scope *functionScope = symbolAtLine->enclosingFunction()) {
function = functionScope->asFunction(); function = functionScope->asFunction();
innerMostScope = symbolAtLine->isBlock() ? innerMostScope = symbolAtLine->asBlock() ?
symbolAtLine->asBlock() : symbolAtLine->asBlock() :
symbolAtLine->enclosingBlock(); symbolAtLine->enclosingBlock();
} }
@@ -380,7 +380,7 @@ static int firstRelevantLine(const Document::Ptr document, int line, int column)
if (!scope) if (!scope)
scope = symbol->enclosingScope(); scope = symbol->enclosingScope();
while (scope && !scope->isFunction() ) while (scope && !scope->asFunction() )
scope = scope->enclosingScope(); scope = scope->enclosingScope();
if (!scope) if (!scope)

View File

@@ -106,7 +106,7 @@ protected:
void postVisit(Symbol *symbol) void postVisit(Symbol *symbol)
{ {
if (symbol->isClass()) if (symbol->asClass())
m_currentClass.clear(); m_currentClass.clear();
} }

View File

@@ -76,7 +76,7 @@ void ClassViewController::appendClassDeclarationsFromSymbol(CPlusPlus::Symbol *s
int line, int column, int line, int column,
QSet<QString> *classNames) QSet<QString> *classNames)
{ {
if (symbol->isClass() if (symbol->asClass()
&& (line <= 0 || (symbol->line() == line && symbol->column() == column + 1))) && (line <= 0 || (symbol->line() == line && symbol->column() == column + 1)))
{ {
CPlusPlus::Overview overview; CPlusPlus::Overview overview;
@@ -87,7 +87,7 @@ void ClassViewController::appendClassDeclarationsFromSymbol(CPlusPlus::Symbol *s
classNames->insert(className); classNames->insert(className);
} }
if (symbol->isScope()) { if (symbol->asScope()) {
CPlusPlus::Scope *scope = symbol->asScope(); CPlusPlus::Scope *scope = symbol->asScope();
int total = scope->memberCount(); int total = scope->memberCount();
for (int i = 0; i < total; ++i) { for (int i = 0; i < total; ++i) {

View File

@@ -864,7 +864,7 @@ void CallgrindToolPrivate::handleShowCostsOfFunction()
if (!symbol) if (!symbol)
return; return;
if (!symbol->isFunction()) if (!symbol->asFunction())
return; return;
CPlusPlus::Overview view; CPlusPlus::Overview view;

View File

@@ -210,7 +210,7 @@ void tst_Semantic::function_declaration_1()
QCOMPARE(funTy->argumentCount(), 0); QCOMPARE(funTy->argumentCount(), 0);
QCOMPARE(funTy->refQualifier(), Function::NoRefQualifier); QCOMPARE(funTy->refQualifier(), Function::NoRefQualifier);
QVERIFY(decl->name()->isNameId()); QVERIFY(decl->name()->asNameId());
const Identifier *funId = decl->name()->asNameId()->identifier(); const Identifier *funId = decl->name()->asNameId()->identifier();
QVERIFY(funId); QVERIFY(funId);
@@ -261,7 +261,7 @@ void tst_Semantic::function_declaration_2()
QCOMPARE(QByteArray(namedTypeId->chars(), namedTypeId->size()), QCOMPARE(QByteArray(namedTypeId->chars(), namedTypeId->size()),
QByteArray("QString")); QByteArray("QString"));
QVERIFY(decl->name()->isNameId()); QVERIFY(decl->name()->asNameId());
const Identifier *funId = decl->name()->asNameId()->identifier(); const Identifier *funId = decl->name()->asNameId()->identifier();
QVERIFY(funId); QVERIFY(funId);
@@ -378,7 +378,7 @@ void tst_Semantic::function_definition_1()
QCOMPARE(funTy->argumentCount(), 0); QCOMPARE(funTy->argumentCount(), 0);
QCOMPARE(funTy->refQualifier(), Function::NoRefQualifier); QCOMPARE(funTy->refQualifier(), Function::NoRefQualifier);
QVERIFY(funTy->name()->isNameId()); QVERIFY(funTy->name()->asNameId());
const Identifier *funId = funTy->name()->asNameId()->identifier(); const Identifier *funId = funTy->name()->asNameId()->identifier();
QVERIFY(funId); QVERIFY(funId);