2008-12-02 12:01:29 +01:00
|
|
|
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
|
|
|
|
//
|
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
|
//
|
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
|
//
|
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
// THE SOFTWARE.
|
|
|
|
|
|
2017-05-24 11:08:24 +02:00
|
|
|
#include "Control.h"
|
|
|
|
|
#include "CoreTypes.h"
|
|
|
|
|
#include "Literals.h"
|
2014-03-24 16:06:39 +01:00
|
|
|
#include "Matcher.h"
|
2017-05-24 11:08:24 +02:00
|
|
|
#include "Names.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "Scope.h"
|
2017-05-24 11:08:24 +02:00
|
|
|
#include "Symbols.h"
|
|
|
|
|
#include "SymbolVisitor.h"
|
2011-03-28 13:21:37 +02:00
|
|
|
#include "Templates.h"
|
2017-05-24 11:08:24 +02:00
|
|
|
#include "TypeVisitor.h"
|
|
|
|
|
|
|
|
|
|
#include <cstring>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-10-20 11:21:25 +02:00
|
|
|
using namespace CPlusPlus;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
UsingNamespaceDirective::UsingNamespaceDirective(TranslationUnit *translationUnit,
|
2019-07-24 18:40:10 +02:00
|
|
|
int sourceLocation, const Name *name)
|
2008-12-02 12:01:29 +01:00
|
|
|
: Symbol(translationUnit, sourceLocation, name)
|
|
|
|
|
{ }
|
|
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
UsingNamespaceDirective::UsingNamespaceDirective(Clone *clone, Subst *subst, UsingNamespaceDirective *original)
|
|
|
|
|
: Symbol(clone, subst, original)
|
|
|
|
|
{ }
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
FullySpecifiedType UsingNamespaceDirective::type() const
|
|
|
|
|
{ return FullySpecifiedType(); }
|
|
|
|
|
|
|
|
|
|
void UsingNamespaceDirective::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
2022-06-23 16:56:36 +02:00
|
|
|
|
2010-05-05 10:18:11 +02:00
|
|
|
NamespaceAlias::NamespaceAlias(TranslationUnit *translationUnit,
|
2019-07-24 18:40:10 +02:00
|
|
|
int sourceLocation, const Name *name)
|
2019-07-31 17:21:41 +02:00
|
|
|
: Symbol(translationUnit, sourceLocation, name), _namespaceName(nullptr)
|
2010-05-05 10:18:11 +02:00
|
|
|
{ }
|
|
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
NamespaceAlias::NamespaceAlias(Clone *clone, Subst *subst, NamespaceAlias *original)
|
|
|
|
|
: Symbol(clone, subst, original)
|
|
|
|
|
, _namespaceName(clone->name(original->_namespaceName, subst))
|
|
|
|
|
{ }
|
|
|
|
|
|
2010-05-05 10:18:11 +02:00
|
|
|
FullySpecifiedType NamespaceAlias::type() const
|
|
|
|
|
{ return FullySpecifiedType(); }
|
|
|
|
|
|
|
|
|
|
void NamespaceAlias::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
UsingDeclaration::UsingDeclaration(TranslationUnit *translationUnit,
|
2019-07-24 18:40:10 +02:00
|
|
|
int sourceLocation, const Name *name)
|
2008-12-02 12:01:29 +01:00
|
|
|
: Symbol(translationUnit, sourceLocation, name)
|
|
|
|
|
{ }
|
|
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
UsingDeclaration::UsingDeclaration(Clone *clone, Subst *subst, UsingDeclaration *original)
|
|
|
|
|
: Symbol(clone, subst, original)
|
|
|
|
|
{ }
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
FullySpecifiedType UsingDeclaration::type() const
|
|
|
|
|
{ return FullySpecifiedType(); }
|
|
|
|
|
|
2022-06-23 16:56:36 +02:00
|
|
|
void CPlusPlus::UsingDeclaration::visitSymbol0(SymbolVisitor *visitor)
|
2008-12-02 12:01:29 +01:00
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
2022-06-23 16:56:36 +02:00
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
Declaration::Declaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
|
2010-08-11 12:47:28 +02:00
|
|
|
: Symbol(translationUnit, sourceLocation, name)
|
2019-07-31 17:21:41 +02:00
|
|
|
, _initializer(nullptr)
|
2008-12-02 12:01:29 +01:00
|
|
|
{ }
|
|
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
Declaration::Declaration(Clone *clone, Subst *subst, Declaration *original)
|
|
|
|
|
: Symbol(clone, subst, original)
|
|
|
|
|
, _type(clone->type(original->_type, subst))
|
2012-01-28 22:58:08 +04:00
|
|
|
, _initializer(clone->stringLiteral(original->_initializer))
|
2017-05-24 11:08:24 +02:00
|
|
|
{
|
|
|
|
|
const char* nameId = nullptr;
|
2017-09-13 14:02:16 +02:00
|
|
|
const Name *theName = name();
|
|
|
|
|
if (!theName)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (const Identifier* identifier = theName->identifier())
|
2017-05-24 11:08:24 +02:00
|
|
|
nameId = identifier->chars();
|
|
|
|
|
else
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Class *enClass = original->enclosingClass();
|
|
|
|
|
const char* enClassNameId = nullptr;
|
|
|
|
|
if (enClass && enClass->name() && enClass->name()->identifier()) {
|
|
|
|
|
enClassNameId = enClass->name()->identifier()->chars();
|
|
|
|
|
} else {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!enClassNameId)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Template *templSpec = enClass->enclosingTemplate();
|
|
|
|
|
const char* enNamespaceNameId = nullptr;
|
|
|
|
|
if (templSpec) {
|
|
|
|
|
if (Namespace* ns = templSpec->enclosingNamespace()) {
|
|
|
|
|
if (ns->isInline())
|
|
|
|
|
ns = ns->enclosingNamespace();
|
|
|
|
|
|
|
|
|
|
if (ns->name() && ns->name()->identifier())
|
|
|
|
|
enNamespaceNameId =ns->name()->identifier()->chars();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!enNamespaceNameId || templSpec->templateParameterCount() < 1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const Name *firstTemplParamName = nullptr;
|
|
|
|
|
if (const TypenameArgument *templParam =
|
|
|
|
|
templSpec->templateParameterAt(0)->asTypenameArgument()) {
|
|
|
|
|
firstTemplParamName = templParam->name();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!firstTemplParamName)
|
|
|
|
|
return;
|
|
|
|
|
|
2018-05-16 08:12:30 +02:00
|
|
|
if (!subst)
|
|
|
|
|
return;
|
|
|
|
|
|
2017-05-24 11:08:24 +02:00
|
|
|
FullySpecifiedType newType;
|
|
|
|
|
if (std::strcmp(enNamespaceNameId, "std") == 0 ||
|
|
|
|
|
std::strcmp(enNamespaceNameId, "__cxx11") == 0) {
|
|
|
|
|
if (std::strcmp(enClassNameId, "unique_ptr") == 0) {
|
|
|
|
|
if (std::strcmp(nameId, "pointer") == 0) {
|
2019-07-31 17:21:41 +02:00
|
|
|
newType = clone->type(subst->apply(firstTemplParamName), nullptr);
|
2017-05-24 11:08:24 +02:00
|
|
|
newType = FullySpecifiedType(clone->control()->pointerType(newType));
|
|
|
|
|
}
|
|
|
|
|
} else if (std::strcmp(enClassNameId, "list") == 0 ||
|
|
|
|
|
std::strcmp(enClassNameId, "forward_list") == 0 ||
|
|
|
|
|
std::strcmp(enClassNameId, "vector") == 0 ||
|
|
|
|
|
std::strcmp(enClassNameId, "queue") == 0 ||
|
|
|
|
|
std::strcmp(enClassNameId, "deque") == 0 ||
|
|
|
|
|
std::strcmp(enClassNameId, "set") == 0 ||
|
|
|
|
|
std::strcmp(enClassNameId, "unordered_set") == 0 ||
|
|
|
|
|
std::strcmp(enClassNameId, "multiset") == 0 ||
|
|
|
|
|
std::strcmp(enClassNameId, "array") == 0) {
|
|
|
|
|
if (std::strcmp(nameId, "reference") == 0 ||
|
|
|
|
|
std::strcmp(nameId, "const_reference") == 0) {
|
2019-07-31 17:21:41 +02:00
|
|
|
newType = clone->type(subst->apply(firstTemplParamName), nullptr);
|
2017-05-24 11:08:24 +02:00
|
|
|
} else if (std::strcmp(nameId, "iterator") == 0 ||
|
|
|
|
|
std::strcmp(nameId, "reverse_iterator") == 0 ||
|
|
|
|
|
std::strcmp(nameId, "const_reverse_iterator") == 0 ||
|
|
|
|
|
std::strcmp(nameId, "const_iterator") == 0) {
|
2019-07-31 17:21:41 +02:00
|
|
|
newType = clone->type(subst->apply(firstTemplParamName), nullptr);
|
2017-05-24 11:08:24 +02:00
|
|
|
newType = FullySpecifiedType(clone->control()->pointerType(newType));
|
|
|
|
|
}
|
|
|
|
|
} else if (std::strcmp(enClassNameId, "_Hash") == 0 ||
|
|
|
|
|
std::strcmp(enClassNameId, "_Tree") == 0 ) {
|
|
|
|
|
if (std::strcmp(nameId, "iterator") == 0 ||
|
|
|
|
|
std::strcmp(nameId, "reverse_iterator") == 0 ||
|
|
|
|
|
std::strcmp(nameId, "const_reverse_iterator") == 0 ||
|
|
|
|
|
std::strcmp(nameId, "const_iterator") == 0) {
|
2019-07-31 17:21:41 +02:00
|
|
|
FullySpecifiedType clonedType = clone->type(subst->apply(firstTemplParamName), nullptr);
|
2017-05-24 11:08:24 +02:00
|
|
|
if (NamedType *namedType = clonedType.type()->asNamedType()) {
|
|
|
|
|
if (const TemplateNameId * templateNameId =
|
|
|
|
|
namedType->name()->asTemplateNameId()) {
|
|
|
|
|
if (templateNameId->templateArgumentCount()) {
|
2020-05-14 23:07:05 +03:00
|
|
|
newType = clone->type(templateNameId->templateArgumentAt(0).type(), nullptr);
|
2017-05-24 11:08:24 +02:00
|
|
|
newType = FullySpecifiedType(clone->control()->pointerType(newType));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (newType.isValid())
|
|
|
|
|
_type = newType;
|
|
|
|
|
}
|
2011-03-28 13:21:37 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void Declaration::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
2022-06-23 16:56:36 +02:00
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
EnumeratorDeclaration::EnumeratorDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
|
2011-05-09 13:52:03 +02:00
|
|
|
: Declaration(translationUnit, sourceLocation, name)
|
2019-07-31 17:21:41 +02:00
|
|
|
, _constantValue(nullptr)
|
2011-05-09 13:52:03 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
Argument::Argument(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
|
2008-12-02 12:01:29 +01:00
|
|
|
: Symbol(translationUnit, sourceLocation, name),
|
2019-07-31 17:21:41 +02:00
|
|
|
_initializer(nullptr)
|
2008-12-02 12:01:29 +01:00
|
|
|
{ }
|
|
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
Argument::Argument(Clone *clone, Subst *subst, Argument *original)
|
|
|
|
|
: Symbol(clone, subst, original)
|
|
|
|
|
, _initializer(clone->stringLiteral(original->_initializer))
|
|
|
|
|
, _type(clone->type(original->_type, subst))
|
|
|
|
|
{ }
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void Argument::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
2022-06-23 16:56:36 +02:00
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
TypenameArgument::TypenameArgument(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
|
2009-12-08 11:58:27 +01:00
|
|
|
: Symbol(translationUnit, sourceLocation, name)
|
2016-07-31 23:53:01 +03:00
|
|
|
, _isClassDeclarator(false)
|
2009-12-08 11:58:27 +01:00
|
|
|
{ }
|
|
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
TypenameArgument::TypenameArgument(Clone *clone, Subst *subst, TypenameArgument *original)
|
|
|
|
|
: Symbol(clone, subst, original)
|
|
|
|
|
, _type(clone->type(original->_type, subst))
|
2016-07-31 23:53:01 +03:00
|
|
|
, _isClassDeclarator(original->_isClassDeclarator)
|
2011-03-28 13:21:37 +02:00
|
|
|
{ }
|
|
|
|
|
|
2009-12-08 11:58:27 +01:00
|
|
|
void TypenameArgument::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
2022-06-23 16:56:36 +02:00
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
Function::Function(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
|
2010-08-11 12:26:02 +02:00
|
|
|
: Scope(translationUnit, sourceLocation, name),
|
2010-08-05 17:02:25 +02:00
|
|
|
_flags(0)
|
|
|
|
|
{ }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
Function::Function(Clone *clone, Subst *subst, Function *original)
|
|
|
|
|
: Scope(clone, subst, original)
|
|
|
|
|
, _returnType(clone->type(original->_returnType, subst))
|
2019-10-07 14:31:32 +02:00
|
|
|
, _exceptionSpecification(original->_exceptionSpecification)
|
2011-03-28 13:21:37 +02:00
|
|
|
, _flags(original->_flags)
|
|
|
|
|
{ }
|
|
|
|
|
|
2014-05-15 15:15:02 -04:00
|
|
|
bool Function::isSignatureEqualTo(const Function *other, Matcher *matcher) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2013-12-05 19:51:53 +02:00
|
|
|
if (! other)
|
2008-12-02 12:01:29 +01:00
|
|
|
return false;
|
2013-12-05 19:51:53 +02:00
|
|
|
else if (isConst() != other->isConst())
|
2009-05-19 12:15:30 +02:00
|
|
|
return false;
|
2013-12-05 19:51:53 +02:00
|
|
|
else if (isVolatile() != other->isVolatile())
|
2009-05-19 12:15:30 +02:00
|
|
|
return false;
|
2014-05-15 15:15:02 -04:00
|
|
|
else if (! Matcher::match(unqualifiedName(), other->unqualifiedName(), matcher))
|
|
|
|
|
return false;
|
2009-05-19 12:15:30 +02:00
|
|
|
|
2020-07-16 15:09:34 +02:00
|
|
|
class FallbackMatcher : public Matcher
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
explicit FallbackMatcher(Matcher *baseMatcher) : m_baseMatcher(baseMatcher) {}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool match(const NamedType *type, const NamedType *otherType) override
|
|
|
|
|
{
|
|
|
|
|
if (type == otherType)
|
|
|
|
|
return true;
|
|
|
|
|
const Name *name = type->name();
|
|
|
|
|
if (const QualifiedNameId *q = name->asQualifiedNameId())
|
|
|
|
|
name = q->name();
|
|
|
|
|
const Name *otherName = otherType->name();
|
|
|
|
|
if (const QualifiedNameId *q = otherName->asQualifiedNameId())
|
|
|
|
|
otherName = q->name();
|
|
|
|
|
return Matcher::match(name, otherName, m_baseMatcher);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Matcher * const m_baseMatcher;
|
|
|
|
|
} fallbackMatcher(matcher);
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
const int argc = argumentCount();
|
2014-05-15 15:15:02 -04:00
|
|
|
if (argc != other->argumentCount())
|
|
|
|
|
return false;
|
2019-07-24 18:40:10 +02:00
|
|
|
for (int i = 0; i < argc; ++i) {
|
2014-05-15 15:15:02 -04:00
|
|
|
Symbol *l = argumentAt(i);
|
|
|
|
|
Symbol *r = other->argumentAt(i);
|
2017-07-04 14:56:04 +02:00
|
|
|
if (! l->type().match(r->type(), matcher)) {
|
2022-06-24 16:45:12 +02:00
|
|
|
if (!l->type()->asReferenceType() && !l->type()->asPointerType()
|
|
|
|
|
&& !l->type()->asPointerToMemberType()
|
|
|
|
|
&& !r->type()->asReferenceType() && !r->type()->asPointerType()
|
|
|
|
|
&& !r->type()->asPointerToMemberType()) {
|
2017-07-04 14:56:04 +02:00
|
|
|
FullySpecifiedType lType = l->type();
|
|
|
|
|
FullySpecifiedType rType = r->type();
|
|
|
|
|
lType.setConst(false);
|
|
|
|
|
lType.setVolatile(false);
|
|
|
|
|
rType.setConst(false);
|
|
|
|
|
rType.setVolatile(false);
|
|
|
|
|
if (lType.match(rType))
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2020-07-16 15:09:34 +02:00
|
|
|
if (l->type().match(r->type(), &fallbackMatcher))
|
|
|
|
|
continue;
|
2008-12-02 12:01:29 +01:00
|
|
|
return false;
|
2017-07-04 14:56:04 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2014-05-15 15:15:02 -04:00
|
|
|
return true;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Function::accept0(TypeVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
2014-03-24 16:06:39 +01:00
|
|
|
bool Function::match0(const Type *otherType, Matcher *matcher) const
|
2009-11-23 11:56:44 +01:00
|
|
|
{
|
|
|
|
|
if (const Function *otherTy = otherType->asFunctionType())
|
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
FullySpecifiedType Function::type() const
|
2010-04-19 09:40:38 +02:00
|
|
|
{
|
|
|
|
|
FullySpecifiedType ty(const_cast<Function *>(this));
|
|
|
|
|
ty.setConst(isConst());
|
|
|
|
|
ty.setVolatile(isVolatile());
|
2020-11-06 14:15:18 +01:00
|
|
|
ty.setStatic(isStatic());
|
2010-04-19 09:40:38 +02:00
|
|
|
return ty;
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-03-26 16:43:38 +01:00
|
|
|
bool Function::hasReturnType() const
|
|
|
|
|
{
|
|
|
|
|
const FullySpecifiedType ty = returnType();
|
|
|
|
|
return ty.isValid() || ty.isSigned() || ty.isUnsigned();
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
int Function::argumentCount() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2019-07-24 18:40:10 +02:00
|
|
|
const int memCnt = memberCount();
|
2022-06-24 16:45:12 +02:00
|
|
|
if (memCnt > 0 && memberAt(0)->type()->asVoidType())
|
2010-11-16 12:58:30 +01:00
|
|
|
return 0;
|
2013-03-13 13:04:54 +01:00
|
|
|
|
|
|
|
|
// Definitions with function-try-blocks will have more than a block, and
|
|
|
|
|
// arguments with a lambda as default argument will also have more blocks.
|
2019-07-24 18:40:10 +02:00
|
|
|
int argc = 0;
|
|
|
|
|
for (int it = 0; it < memCnt; ++it)
|
2022-06-23 16:56:36 +02:00
|
|
|
if (memberAt(it)->asArgument())
|
2013-03-13 13:04:54 +01:00
|
|
|
++argc;
|
|
|
|
|
return argc;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
Symbol *Function::argumentAt(int index) const
|
2013-03-13 13:04:54 +01:00
|
|
|
{
|
2019-07-24 18:40:10 +02:00
|
|
|
for (int it = 0, eit = memberCount(); it < eit; ++it) {
|
2013-03-13 13:04:54 +01:00
|
|
|
if (Argument *arg = memberAt(it)->asArgument()) {
|
|
|
|
|
if (index == 0)
|
|
|
|
|
return arg;
|
|
|
|
|
else
|
|
|
|
|
--index;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-31 17:21:41 +02:00
|
|
|
return nullptr;
|
2013-03-13 13:04:54 +01:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-03-26 16:43:38 +01:00
|
|
|
bool Function::hasArguments() const
|
|
|
|
|
{
|
2019-07-24 18:40:10 +02:00
|
|
|
int argc = argumentCount();
|
2022-06-24 16:45:12 +02:00
|
|
|
return ! (argc == 0 || (argc == 1 && argumentAt(0)->type()->asVoidType()));
|
2009-03-26 16:43:38 +01:00
|
|
|
}
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
int Function::minimumArgumentCount() const
|
2010-08-03 17:34:51 +02:00
|
|
|
{
|
2019-07-24 18:40:10 +02:00
|
|
|
int index = 0;
|
2010-08-03 17:34:51 +02:00
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
for (int ei = argumentCount(); index < ei; ++index) {
|
2010-08-05 17:02:25 +02:00
|
|
|
if (Argument *arg = argumentAt(index)->asArgument()) {
|
2010-08-03 17:34:51 +02:00
|
|
|
if (arg->hasInitializer())
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return index;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void Function::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
|
{
|
|
|
|
|
if (visitor->visit(this)) {
|
2019-07-24 18:40:10 +02:00
|
|
|
for (int i = 0; i < memberCount(); ++i) {
|
2008-12-02 12:01:29 +01:00
|
|
|
visitSymbol(memberAt(i), visitor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
bool Function::maybeValidPrototype(int actualArgumentCount) const
|
2010-12-10 10:32:46 +01:00
|
|
|
{
|
2019-07-24 18:40:10 +02:00
|
|
|
const int argc = argumentCount();
|
|
|
|
|
int minNumberArguments = 0;
|
2010-12-10 10:32:46 +01:00
|
|
|
|
2013-03-13 12:51:58 +01:00
|
|
|
for (; minNumberArguments < argc; ++minNumberArguments) {
|
|
|
|
|
Argument *arg = argumentAt(minNumberArguments)->asArgument();
|
2010-12-10 10:32:46 +01:00
|
|
|
|
2013-03-13 13:04:54 +01:00
|
|
|
if (! arg)
|
2013-03-06 09:54:25 +01:00
|
|
|
return false;
|
|
|
|
|
|
2010-12-10 10:32:46 +01:00
|
|
|
if (arg->hasInitializer())
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-14 23:07:05 +03:00
|
|
|
if (isVariadicTemplate())
|
|
|
|
|
--minNumberArguments;
|
|
|
|
|
|
2010-12-10 10:32:46 +01:00
|
|
|
if (actualArgumentCount < minNumberArguments) {
|
|
|
|
|
// not enough arguments.
|
|
|
|
|
return false;
|
|
|
|
|
|
2013-03-13 12:51:58 +01:00
|
|
|
} else if (!isVariadic() && actualArgumentCount > argc) {
|
2010-12-10 10:32:46 +01:00
|
|
|
// too many arguments.
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
Block::Block(TranslationUnit *translationUnit, int sourceLocation)
|
2019-07-31 17:21:41 +02:00
|
|
|
: Scope(translationUnit, sourceLocation, /*name = */ nullptr)
|
2008-12-02 12:01:29 +01:00
|
|
|
{ }
|
|
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
Block::Block(Clone *clone, Subst *subst, Block *original)
|
|
|
|
|
: Scope(clone, subst, original)
|
|
|
|
|
{ }
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
FullySpecifiedType Block::type() const
|
|
|
|
|
{ return FullySpecifiedType(); }
|
|
|
|
|
|
|
|
|
|
void Block::visitSymbol0(SymbolVisitor *visitor)
|
2009-06-25 11:02:02 +02:00
|
|
|
{
|
|
|
|
|
if (visitor->visit(this)) {
|
2019-07-24 18:40:10 +02:00
|
|
|
for (int i = 0; i < memberCount(); ++i) {
|
2009-06-25 11:02:02 +02:00
|
|
|
visitSymbol(memberAt(i), visitor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
Enum::Enum(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
|
2010-08-11 12:26:02 +02:00
|
|
|
: Scope(translationUnit, sourceLocation, name)
|
2012-10-25 07:56:01 +02:00
|
|
|
, _isScoped(false)
|
2008-12-02 12:01:29 +01:00
|
|
|
{ }
|
|
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
Enum::Enum(Clone *clone, Subst *subst, Enum *original)
|
|
|
|
|
: Scope(clone, subst, original)
|
2012-10-25 07:56:01 +02:00
|
|
|
, _isScoped(original->isScoped())
|
2011-03-28 13:21:37 +02:00
|
|
|
{ }
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
FullySpecifiedType Enum::type() const
|
|
|
|
|
{ return FullySpecifiedType(const_cast<Enum *>(this)); }
|
|
|
|
|
|
2012-10-25 07:56:01 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void Enum::accept0(TypeVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
2014-03-24 16:06:39 +01:00
|
|
|
bool Enum::match0(const Type *otherType, Matcher *matcher) const
|
2009-11-23 11:56:44 +01:00
|
|
|
{
|
|
|
|
|
if (const Enum *otherTy = otherType->asEnumType())
|
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void Enum::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
|
{
|
|
|
|
|
if (visitor->visit(this)) {
|
2019-07-24 18:40:10 +02:00
|
|
|
for (int i = 0; i < memberCount(); ++i) {
|
2008-12-02 12:01:29 +01:00
|
|
|
visitSymbol(memberAt(i), visitor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
Template::Template(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
|
2010-08-11 13:46:32 +02:00
|
|
|
: Scope(translationUnit, sourceLocation, name)
|
|
|
|
|
{ }
|
|
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
Template::Template(Clone *clone, Subst *subst, Template *original)
|
|
|
|
|
: Scope(clone, subst, original)
|
|
|
|
|
{ }
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
int Template::templateParameterCount() const
|
2010-08-11 13:46:32 +02:00
|
|
|
{
|
2019-07-31 17:21:41 +02:00
|
|
|
if (declaration() != nullptr)
|
2010-08-11 13:46:32 +02:00
|
|
|
return memberCount() - 1;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Symbol *Template::declaration() const
|
|
|
|
|
{
|
|
|
|
|
if (isEmpty())
|
2019-07-31 17:21:41 +02:00
|
|
|
return nullptr;
|
2010-08-11 13:46:32 +02:00
|
|
|
|
|
|
|
|
if (Symbol *s = memberAt(memberCount() - 1)) {
|
2022-06-23 16:56:36 +02:00
|
|
|
if (s->asClass() || s->asForwardClassDeclaration() ||
|
|
|
|
|
s->asTemplate() || s->asFunction() || s->asDeclaration())
|
2010-08-11 13:46:32 +02:00
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-31 17:21:41 +02:00
|
|
|
return nullptr;
|
2010-08-11 13:46:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FullySpecifiedType Template::type() const
|
|
|
|
|
{ return FullySpecifiedType(const_cast<Template *>(this)); }
|
|
|
|
|
|
|
|
|
|
void Template::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
|
{
|
|
|
|
|
if (visitor->visit(this)) {
|
2019-07-24 18:40:10 +02:00
|
|
|
for (int i = 0; i < memberCount(); ++i) {
|
2010-08-11 13:46:32 +02:00
|
|
|
visitSymbol(memberAt(i), visitor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Template::accept0(TypeVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
2014-03-24 16:06:39 +01:00
|
|
|
bool Template::match0(const Type *otherType, Matcher *matcher) const
|
2010-08-11 13:46:32 +02:00
|
|
|
{
|
|
|
|
|
if (const Template *otherTy = otherType->asTemplateType())
|
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
Namespace::Namespace(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
|
2010-08-11 12:26:02 +02:00
|
|
|
: Scope(translationUnit, sourceLocation, name)
|
2012-02-02 10:19:58 +01:00
|
|
|
, _isInline(false)
|
2008-12-02 12:01:29 +01:00
|
|
|
{ }
|
|
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
Namespace::Namespace(Clone *clone, Subst *subst, Namespace *original)
|
|
|
|
|
: Scope(clone, subst, original)
|
2012-02-02 10:19:58 +01:00
|
|
|
, _isInline(original->_isInline)
|
2011-03-28 13:21:37 +02:00
|
|
|
{ }
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void Namespace::accept0(TypeVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
2014-03-24 16:06:39 +01:00
|
|
|
bool Namespace::match0(const Type *otherType, Matcher *matcher) const
|
2009-11-23 11:56:44 +01:00
|
|
|
{
|
|
|
|
|
if (const Namespace *otherTy = otherType->asNamespaceType())
|
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void Namespace::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
|
{
|
|
|
|
|
if (visitor->visit(this)) {
|
2019-07-24 18:40:10 +02:00
|
|
|
for (int i = 0; i < memberCount(); ++i) {
|
2008-12-02 12:01:29 +01:00
|
|
|
visitSymbol(memberAt(i), visitor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FullySpecifiedType Namespace::type() const
|
|
|
|
|
{ return FullySpecifiedType(const_cast<Namespace *>(this)); }
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
BaseClass::BaseClass(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
|
2008-12-02 12:01:29 +01:00
|
|
|
: Symbol(translationUnit, sourceLocation, name),
|
|
|
|
|
_isVirtual(false)
|
|
|
|
|
{ }
|
|
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
BaseClass::BaseClass(Clone *clone, Subst *subst, BaseClass *original)
|
|
|
|
|
: Symbol(clone, subst, original)
|
|
|
|
|
, _isVirtual(original->_isVirtual)
|
|
|
|
|
, _type(clone->type(original->_type, subst))
|
|
|
|
|
{ }
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void BaseClass::visitSymbol0(SymbolVisitor *visitor)
|
2009-02-16 15:43:24 +01:00
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
2022-06-23 16:56:36 +02:00
|
|
|
|
2009-02-16 15:43:24 +01:00
|
|
|
ForwardClassDeclaration::ForwardClassDeclaration(TranslationUnit *translationUnit,
|
2019-07-24 18:40:10 +02:00
|
|
|
int sourceLocation, const Name *name)
|
2010-08-11 12:47:28 +02:00
|
|
|
: Symbol(translationUnit, sourceLocation, name)
|
2009-02-16 15:43:24 +01:00
|
|
|
{ }
|
|
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
ForwardClassDeclaration::ForwardClassDeclaration(Clone *clone, Subst *subst, ForwardClassDeclaration *original)
|
|
|
|
|
: Symbol(clone, subst, original)
|
|
|
|
|
{ }
|
|
|
|
|
|
2009-02-16 15:43:24 +01:00
|
|
|
FullySpecifiedType ForwardClassDeclaration::type() const
|
|
|
|
|
{ return FullySpecifiedType(const_cast<ForwardClassDeclaration *>(this)); }
|
|
|
|
|
|
|
|
|
|
void ForwardClassDeclaration::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
|
|
|
|
void ForwardClassDeclaration::accept0(TypeVisitor *visitor)
|
2008-12-02 12:01:29 +01:00
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
2014-03-24 16:06:39 +01:00
|
|
|
bool ForwardClassDeclaration::match0(const Type *otherType, Matcher *matcher) const
|
2009-11-23 11:56:44 +01:00
|
|
|
{
|
|
|
|
|
if (const ForwardClassDeclaration *otherTy = otherType->asForwardClassDeclarationType())
|
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
Class::Class(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
|
2010-08-11 12:26:02 +02:00
|
|
|
: Scope(translationUnit, sourceLocation, name),
|
2010-08-11 12:47:28 +02:00
|
|
|
_key(ClassKey)
|
2008-12-02 12:01:29 +01:00
|
|
|
{ }
|
|
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
Class::Class(Clone *clone, Subst *subst, Class *original)
|
|
|
|
|
: Scope(clone, subst, original)
|
|
|
|
|
, _key(original->_key)
|
|
|
|
|
{
|
|
|
|
|
for (size_t i = 0; i < original->_baseClasses.size(); ++i)
|
|
|
|
|
addBaseClass(clone->symbol(original->_baseClasses.at(i), subst)->asBaseClass());
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void Class::accept0(TypeVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
2014-03-24 16:06:39 +01:00
|
|
|
bool Class::match0(const Type *otherType, Matcher *matcher) const
|
2009-11-23 11:56:44 +01:00
|
|
|
{
|
|
|
|
|
if (const Class *otherTy = otherType->asClassType())
|
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
int Class::baseClassCount() const
|
|
|
|
|
{ return int(_baseClasses.size()); }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
BaseClass *Class::baseClassAt(int index) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{ return _baseClasses.at(index); }
|
|
|
|
|
|
|
|
|
|
void Class::addBaseClass(BaseClass *baseClass)
|
|
|
|
|
{ _baseClasses.push_back(baseClass); }
|
|
|
|
|
|
|
|
|
|
FullySpecifiedType Class::type() const
|
|
|
|
|
{ return FullySpecifiedType(const_cast<Class *>(this)); }
|
|
|
|
|
|
|
|
|
|
void Class::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
|
{
|
|
|
|
|
if (visitor->visit(this)) {
|
2019-07-24 18:40:10 +02:00
|
|
|
for (int i = 0; i < int(_baseClasses.size()); ++i) {
|
2008-12-02 12:01:29 +01:00
|
|
|
visitSymbol(_baseClasses.at(i), visitor);
|
|
|
|
|
}
|
2019-07-24 18:40:10 +02:00
|
|
|
for (int i = 0; i < memberCount(); ++i) {
|
2008-12-02 12:01:29 +01:00
|
|
|
visitSymbol(memberAt(i), visitor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 12:16:45 +01:00
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
QtPropertyDeclaration::QtPropertyDeclaration(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
|
2010-12-06 12:16:45 +01:00
|
|
|
: Symbol(translationUnit, sourceLocation, name)
|
2010-12-06 13:10:09 +01:00
|
|
|
, _flags(NoFlags)
|
2010-12-06 12:16:45 +01:00
|
|
|
{ }
|
|
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
QtPropertyDeclaration::QtPropertyDeclaration(Clone *clone, Subst *subst, QtPropertyDeclaration *original)
|
|
|
|
|
: Symbol(clone, subst, original)
|
|
|
|
|
, _type(clone->type(original->_type, subst))
|
|
|
|
|
, _flags(original->_flags)
|
|
|
|
|
{ }
|
|
|
|
|
|
2010-12-06 12:16:45 +01:00
|
|
|
void QtPropertyDeclaration::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
QtEnum::QtEnum(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
|
2010-12-06 13:10:09 +01:00
|
|
|
: Symbol(translationUnit, sourceLocation, name)
|
|
|
|
|
{ }
|
|
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
QtEnum::QtEnum(Clone *clone, Subst *subst, QtEnum *original)
|
|
|
|
|
: Symbol(clone, subst, original)
|
|
|
|
|
{ }
|
|
|
|
|
|
2010-12-06 13:10:09 +01:00
|
|
|
void QtEnum::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
ObjCBaseClass::ObjCBaseClass(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
|
2009-10-05 18:02:01 +02:00
|
|
|
: Symbol(translationUnit, sourceLocation, name)
|
|
|
|
|
{ }
|
|
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
ObjCBaseClass::ObjCBaseClass(Clone *clone, Subst *subst, ObjCBaseClass *original)
|
|
|
|
|
: Symbol(clone, subst, original)
|
|
|
|
|
{ }
|
|
|
|
|
|
2009-10-05 18:02:01 +02:00
|
|
|
|
|
|
|
|
FullySpecifiedType ObjCBaseClass::type() const
|
|
|
|
|
{ return FullySpecifiedType(); }
|
|
|
|
|
|
|
|
|
|
void ObjCBaseClass::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
ObjCBaseProtocol::ObjCBaseProtocol(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
|
2009-10-05 18:02:01 +02:00
|
|
|
: Symbol(translationUnit, sourceLocation, name)
|
|
|
|
|
{ }
|
|
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
ObjCBaseProtocol::ObjCBaseProtocol(Clone *clone, Subst *subst, ObjCBaseProtocol *original)
|
|
|
|
|
: Symbol(clone, subst, original)
|
|
|
|
|
{ }
|
|
|
|
|
|
2009-10-05 18:02:01 +02:00
|
|
|
FullySpecifiedType ObjCBaseProtocol::type() const
|
|
|
|
|
{ return FullySpecifiedType(); }
|
|
|
|
|
|
|
|
|
|
void ObjCBaseProtocol::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
ObjCClass::ObjCClass(TranslationUnit *translationUnit, int sourceLocation, const Name *name):
|
2010-09-03 12:11:15 +02:00
|
|
|
Scope(translationUnit, sourceLocation, name),
|
2019-07-31 17:21:41 +02:00
|
|
|
_categoryName(nullptr),
|
|
|
|
|
_baseClass(nullptr),
|
2010-09-03 12:11:15 +02:00
|
|
|
_isInterface(false)
|
2011-03-28 13:21:37 +02:00
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
ObjCClass::ObjCClass(Clone *clone, Subst *subst, ObjCClass *original)
|
|
|
|
|
: Scope(clone, subst, original)
|
|
|
|
|
, _categoryName(clone->name(original->_categoryName, subst))
|
2019-07-31 17:21:41 +02:00
|
|
|
, _baseClass(nullptr)
|
2011-03-28 13:21:37 +02:00
|
|
|
, _isInterface(original->_isInterface)
|
2009-07-28 16:34:15 +02:00
|
|
|
{
|
2011-03-28 13:21:37 +02:00
|
|
|
if (original->_baseClass)
|
|
|
|
|
_baseClass = clone->symbol(original->_baseClass, subst)->asObjCBaseClass();
|
|
|
|
|
for (size_t i = 0; i < original->_protocols.size(); ++i)
|
|
|
|
|
addProtocol(clone->symbol(original->_protocols.at(i), subst)->asObjCBaseProtocol());
|
2009-07-28 16:34:15 +02:00
|
|
|
}
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
int ObjCClass::protocolCount() const
|
|
|
|
|
{ return int(_protocols.size()); }
|
2010-03-30 15:35:42 +02:00
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
ObjCBaseProtocol *ObjCClass::protocolAt(int index) const
|
2010-03-30 15:35:42 +02:00
|
|
|
{ return _protocols.at(index); }
|
|
|
|
|
|
|
|
|
|
void ObjCClass::addProtocol(ObjCBaseProtocol *protocol)
|
|
|
|
|
{ _protocols.push_back(protocol); }
|
|
|
|
|
|
2009-07-28 16:34:15 +02:00
|
|
|
FullySpecifiedType ObjCClass::type() const
|
|
|
|
|
{ return FullySpecifiedType(const_cast<ObjCClass *>(this)); }
|
|
|
|
|
|
|
|
|
|
void ObjCClass::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
|
{
|
|
|
|
|
if (visitor->visit(this)) {
|
2009-09-28 11:46:00 +02:00
|
|
|
if (_baseClass)
|
|
|
|
|
visitSymbol(_baseClass, visitor);
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
for (int i = 0; i < int(_protocols.size()); ++i)
|
2009-07-28 16:34:15 +02:00
|
|
|
visitSymbol(_protocols.at(i), visitor);
|
2009-09-28 11:46:00 +02:00
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
for (int i = 0; i < memberCount(); ++i)
|
2009-09-28 11:46:00 +02:00
|
|
|
visitSymbol(memberAt(i), visitor);
|
2009-07-28 16:34:15 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ObjCClass::accept0(TypeVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
2014-03-24 16:06:39 +01:00
|
|
|
bool ObjCClass::match0(const Type *otherType, Matcher *matcher) const
|
2009-11-23 11:56:44 +01:00
|
|
|
{
|
|
|
|
|
if (const ObjCClass *otherTy = otherType->asObjCClassType())
|
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
ObjCProtocol::ObjCProtocol(TranslationUnit *translationUnit, int sourceLocation, const Name *name):
|
2010-08-11 12:26:02 +02:00
|
|
|
Scope(translationUnit, sourceLocation, name)
|
2009-07-28 16:34:15 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
ObjCProtocol::ObjCProtocol(Clone *clone, Subst *subst, ObjCProtocol *original)
|
|
|
|
|
: Scope(clone, subst, original)
|
|
|
|
|
{
|
|
|
|
|
for (size_t i = 0; i < original->_protocols.size(); ++i)
|
|
|
|
|
addProtocol(clone->symbol(original->_protocols.at(i), subst)->asObjCBaseProtocol());
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
int ObjCProtocol::protocolCount() const
|
|
|
|
|
{ return int(_protocols.size()); }
|
2010-03-30 15:35:42 +02:00
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
ObjCBaseProtocol *ObjCProtocol::protocolAt(int index) const
|
2010-03-30 15:35:42 +02:00
|
|
|
{ return _protocols.at(index); }
|
|
|
|
|
|
|
|
|
|
void ObjCProtocol::addProtocol(ObjCBaseProtocol *protocol)
|
|
|
|
|
{ _protocols.push_back(protocol); }
|
|
|
|
|
|
2009-07-28 16:34:15 +02:00
|
|
|
FullySpecifiedType ObjCProtocol::type() const
|
|
|
|
|
{ return FullySpecifiedType(const_cast<ObjCProtocol *>(this)); }
|
|
|
|
|
|
|
|
|
|
void ObjCProtocol::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
|
{
|
|
|
|
|
if (visitor->visit(this)) {
|
2019-07-24 18:40:10 +02:00
|
|
|
for (int i = 0; i < int(_protocols.size()); ++i)
|
2009-07-28 16:34:15 +02:00
|
|
|
visitSymbol(_protocols.at(i), visitor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ObjCProtocol::accept0(TypeVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
2014-03-24 16:06:39 +01:00
|
|
|
bool ObjCProtocol::match0(const Type *otherType, Matcher *matcher) const
|
2009-11-23 11:56:44 +01:00
|
|
|
{
|
|
|
|
|
if (const ObjCProtocol *otherTy = otherType->asObjCProtocolType())
|
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
ObjCForwardClassDeclaration::ObjCForwardClassDeclaration(TranslationUnit *translationUnit, int sourceLocation,
|
2009-12-01 12:46:15 +01:00
|
|
|
const Name *name):
|
2009-07-28 16:34:15 +02:00
|
|
|
Symbol(translationUnit, sourceLocation, name)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
ObjCForwardClassDeclaration::ObjCForwardClassDeclaration(Clone *clone, Subst *subst, ObjCForwardClassDeclaration *original)
|
|
|
|
|
: Symbol(clone, subst, original)
|
|
|
|
|
{ }
|
|
|
|
|
|
2009-07-28 16:34:15 +02:00
|
|
|
FullySpecifiedType ObjCForwardClassDeclaration::type() const
|
2009-08-05 17:14:08 +02:00
|
|
|
{ return FullySpecifiedType(); }
|
2009-07-28 16:34:15 +02:00
|
|
|
|
|
|
|
|
void ObjCForwardClassDeclaration::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
2009-09-28 11:46:00 +02:00
|
|
|
void ObjCForwardClassDeclaration::accept0(TypeVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
2014-03-24 16:06:39 +01:00
|
|
|
bool ObjCForwardClassDeclaration::match0(const Type *otherType, Matcher *matcher) const
|
2009-11-23 11:56:44 +01:00
|
|
|
{
|
|
|
|
|
if (const ObjCForwardClassDeclaration *otherTy = otherType->asObjCForwardClassDeclarationType())
|
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
ObjCForwardProtocolDeclaration::ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, int sourceLocation,
|
2009-12-01 12:46:15 +01:00
|
|
|
const Name *name):
|
2009-07-28 16:34:15 +02:00
|
|
|
Symbol(translationUnit, sourceLocation, name)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
ObjCForwardProtocolDeclaration::ObjCForwardProtocolDeclaration(Clone *clone, Subst *subst, ObjCForwardProtocolDeclaration *original)
|
|
|
|
|
: Symbol(clone, subst, original)
|
|
|
|
|
{ }
|
|
|
|
|
|
2009-07-28 16:34:15 +02:00
|
|
|
FullySpecifiedType ObjCForwardProtocolDeclaration::type() const
|
2009-08-05 17:14:08 +02:00
|
|
|
{ return FullySpecifiedType(); }
|
2009-07-28 16:34:15 +02:00
|
|
|
|
|
|
|
|
void ObjCForwardProtocolDeclaration::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
2009-09-28 11:46:00 +02:00
|
|
|
void ObjCForwardProtocolDeclaration::accept0(TypeVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
2014-03-24 16:06:39 +01:00
|
|
|
bool ObjCForwardProtocolDeclaration::match0(const Type *otherType, Matcher *matcher) const
|
2009-11-23 11:56:44 +01:00
|
|
|
{
|
|
|
|
|
if (const ObjCForwardProtocolDeclaration *otherTy = otherType->asObjCForwardProtocolDeclarationType())
|
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
ObjCMethod::ObjCMethod(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
|
2010-08-11 12:26:02 +02:00
|
|
|
: Scope(translationUnit, sourceLocation, name),
|
2009-08-05 18:30:18 +02:00
|
|
|
_flags(0)
|
2010-08-11 12:26:02 +02:00
|
|
|
{ }
|
2009-08-05 18:30:18 +02:00
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
ObjCMethod::ObjCMethod(Clone *clone, Subst *subst, ObjCMethod *original)
|
|
|
|
|
: Scope(clone, subst, original)
|
|
|
|
|
, _returnType(clone->type(original->_returnType, subst))
|
|
|
|
|
, _flags(original->_flags)
|
|
|
|
|
{ }
|
|
|
|
|
|
2009-08-05 18:30:18 +02:00
|
|
|
void ObjCMethod::accept0(TypeVisitor *visitor)
|
|
|
|
|
{ visitor->visit(this); }
|
|
|
|
|
|
2014-03-24 16:06:39 +01:00
|
|
|
bool ObjCMethod::match0(const Type *otherType, Matcher *matcher) const
|
2009-11-23 11:56:44 +01:00
|
|
|
{
|
|
|
|
|
if (const ObjCMethod *otherTy = otherType->asObjCMethodType())
|
|
|
|
|
return matcher->match(this, otherTy);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-05 18:30:18 +02:00
|
|
|
FullySpecifiedType ObjCMethod::type() const
|
|
|
|
|
{ return FullySpecifiedType(const_cast<ObjCMethod *>(this)); }
|
|
|
|
|
|
|
|
|
|
bool ObjCMethod::hasReturnType() const
|
|
|
|
|
{
|
|
|
|
|
const FullySpecifiedType ty = returnType();
|
|
|
|
|
return ty.isValid() || ty.isSigned() || ty.isUnsigned();
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
int ObjCMethod::argumentCount() const
|
2009-08-05 18:30:18 +02:00
|
|
|
{
|
2019-07-24 18:40:10 +02:00
|
|
|
const int c = memberCount();
|
2022-06-23 16:56:36 +02:00
|
|
|
if (c > 0 && memberAt(c - 1)->asBlock())
|
2010-08-16 11:31:53 +02:00
|
|
|
return c - 1;
|
|
|
|
|
return c;
|
2009-08-05 18:30:18 +02:00
|
|
|
}
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
Symbol *ObjCMethod::argumentAt(int index) const
|
2010-08-11 12:26:02 +02:00
|
|
|
{
|
|
|
|
|
return memberAt(index);
|
|
|
|
|
}
|
2009-08-05 18:30:18 +02:00
|
|
|
|
|
|
|
|
bool ObjCMethod::hasArguments() const
|
|
|
|
|
{
|
|
|
|
|
return ! (argumentCount() == 0 ||
|
2022-06-24 16:45:12 +02:00
|
|
|
(argumentCount() == 1 && argumentAt(0)->type()->asVoidType()));
|
2009-08-05 18:30:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ObjCMethod::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
|
{
|
|
|
|
|
if (visitor->visit(this)) {
|
2019-07-24 18:40:10 +02:00
|
|
|
for (int i = 0; i < memberCount(); ++i) {
|
2009-08-05 18:30:18 +02:00
|
|
|
visitSymbol(memberAt(i), visitor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-11 09:32:05 +01:00
|
|
|
ObjCPropertyDeclaration::ObjCPropertyDeclaration(TranslationUnit *translationUnit,
|
2019-07-24 18:40:10 +02:00
|
|
|
int sourceLocation,
|
2009-12-01 12:46:15 +01:00
|
|
|
const Name *name):
|
2009-11-11 09:32:05 +01:00
|
|
|
Symbol(translationUnit, sourceLocation, name),
|
2019-07-31 17:21:41 +02:00
|
|
|
_getterName(nullptr),
|
|
|
|
|
_setterName(nullptr),
|
2010-09-03 12:11:15 +02:00
|
|
|
_propertyAttributes(None)
|
2009-11-11 09:32:05 +01:00
|
|
|
{}
|
|
|
|
|
|
2011-03-28 13:21:37 +02:00
|
|
|
ObjCPropertyDeclaration::ObjCPropertyDeclaration(Clone *clone, Subst *subst, ObjCPropertyDeclaration *original)
|
|
|
|
|
: Symbol(clone, subst, original)
|
|
|
|
|
, _getterName(clone->name(original->_getterName, subst))
|
|
|
|
|
, _setterName(clone->name(original->_setterName, subst))
|
|
|
|
|
, _type(clone->type(original->_type, subst))
|
|
|
|
|
, _propertyAttributes(original->_propertyAttributes)
|
|
|
|
|
{ }
|
|
|
|
|
|
2009-11-11 09:32:05 +01:00
|
|
|
void ObjCPropertyDeclaration::visitSymbol0(SymbolVisitor *visitor)
|
|
|
|
|
{
|
|
|
|
|
if (visitor->visit(this)) {
|
|
|
|
|
}
|
|
|
|
|
}
|