2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2009-10-27 12:01:45 +01:00
|
|
|
|
|
|
|
|
#include "FindUsages.h"
|
2013-03-27 18:54:03 +01:00
|
|
|
|
2010-06-01 11:57:25 +02:00
|
|
|
#include "Overview.h"
|
2013-03-27 18:54:03 +01:00
|
|
|
|
|
|
|
|
#include <cplusplus/AST.h>
|
2020-08-28 14:07:16 +02:00
|
|
|
#include <cplusplus/ASTPath.h>
|
2013-03-27 18:54:03 +01:00
|
|
|
#include <cplusplus/Control.h>
|
|
|
|
|
#include <cplusplus/CoreTypes.h>
|
|
|
|
|
#include <cplusplus/Literals.h>
|
2020-08-28 14:07:16 +02:00
|
|
|
#include <cplusplus/Names.h>
|
2013-03-27 18:54:03 +01:00
|
|
|
#include <cplusplus/Scope.h>
|
2020-08-28 14:07:16 +02:00
|
|
|
#include <cplusplus/Symbols.h>
|
|
|
|
|
#include <cplusplus/TranslationUnit.h>
|
|
|
|
|
#include <cplusplus/TypeOfExpression.h>
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
#include <QDebug>
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2022-08-26 10:30:00 +02:00
|
|
|
#include <optional>
|
2020-08-28 14:07:16 +02:00
|
|
|
|
2009-10-27 12:01:45 +01:00
|
|
|
using namespace CPlusPlus;
|
|
|
|
|
|
2021-05-26 17:24:18 +02:00
|
|
|
FindUsages::FindUsages(const QByteArray &originalSource, Document::Ptr doc,
|
|
|
|
|
const Snapshot &snapshot, bool categorize)
|
2009-11-17 13:28:20 +01:00
|
|
|
: ASTVisitor(doc->translationUnit()),
|
2009-10-27 12:01:45 +01:00
|
|
|
_doc(doc),
|
|
|
|
|
_snapshot(snapshot),
|
2010-05-12 12:53:16 +02:00
|
|
|
_context(doc, snapshot),
|
2011-01-17 14:41:19 +01:00
|
|
|
_originalSource(originalSource),
|
2021-05-26 17:24:18 +02:00
|
|
|
_source(_doc->utf8Source()),
|
|
|
|
|
_categorize(categorize)
|
2009-10-27 12:01:45 +01:00
|
|
|
{
|
|
|
|
|
_snapshot.insert(_doc);
|
2010-05-17 13:06:49 +02:00
|
|
|
typeofExpression.init(_doc, _snapshot, _context.bindings());
|
2013-02-26 14:09:44 +01:00
|
|
|
|
|
|
|
|
prepareLines(_originalSource);
|
2009-10-27 12:01:45 +01:00
|
|
|
}
|
|
|
|
|
|
2010-05-31 12:09:28 +02:00
|
|
|
FindUsages::FindUsages(const LookupContext &context)
|
|
|
|
|
: ASTVisitor(context.thisDocument()->translationUnit()),
|
|
|
|
|
_doc(context.thisDocument()),
|
|
|
|
|
_snapshot(context.snapshot()),
|
|
|
|
|
_context(context),
|
2012-01-12 17:53:56 +01:00
|
|
|
_originalSource(_doc->utf8Source()),
|
2017-04-27 10:53:56 +03:00
|
|
|
_source(_doc->utf8Source())
|
2010-05-31 12:09:28 +02:00
|
|
|
{
|
|
|
|
|
typeofExpression.init(_doc, _snapshot, _context.bindings());
|
2013-02-26 14:09:44 +01:00
|
|
|
|
|
|
|
|
prepareLines(_originalSource);
|
2010-05-31 12:09:28 +02:00
|
|
|
}
|
|
|
|
|
|
2009-12-01 17:31:41 +01:00
|
|
|
QList<Usage> FindUsages::usages() const
|
|
|
|
|
{ return _usages; }
|
|
|
|
|
|
|
|
|
|
QList<int> FindUsages::references() const
|
|
|
|
|
{ return _references; }
|
|
|
|
|
|
2009-12-03 11:59:37 +01:00
|
|
|
void FindUsages::operator()(Symbol *symbol)
|
2009-10-27 12:01:45 +01:00
|
|
|
{
|
2010-08-05 12:49:29 +02:00
|
|
|
if (! symbol)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
_id = symbol->identifier();
|
|
|
|
|
|
|
|
|
|
if (! _id)
|
|
|
|
|
return;
|
|
|
|
|
|
2009-11-04 12:02:19 +01:00
|
|
|
_processed.clear();
|
2009-10-27 12:01:45 +01:00
|
|
|
_references.clear();
|
2009-12-01 17:31:41 +01:00
|
|
|
_usages.clear();
|
2010-08-10 14:40:27 +02:00
|
|
|
_declSymbol = symbol;
|
2010-08-05 12:49:29 +02:00
|
|
|
_declSymbolFullyQualifiedName = LookupContext::fullyQualifiedName(symbol);
|
2009-12-03 11:59:37 +01:00
|
|
|
|
2010-08-05 12:49:29 +02:00
|
|
|
// get the canonical id
|
2010-08-11 14:24:28 +02:00
|
|
|
_id = _doc->control()->identifier(_id->chars(), _id->size());
|
2009-12-03 11:59:37 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
if (AST *ast = _doc->translationUnit()->ast())
|
|
|
|
|
translationUnit(ast->asTranslationUnit());
|
2009-10-27 12:01:45 +01:00
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::reportResult(unsigned tokenIndex, const Name *name, Scope *scope)
|
|
|
|
|
{
|
2019-07-31 17:21:41 +02:00
|
|
|
if (! (tokenIndex && name != nullptr))
|
2010-08-10 14:40:27 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (name->identifier() != _id)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (! scope)
|
|
|
|
|
scope = _currentScope;
|
|
|
|
|
|
|
|
|
|
const QList<LookupItem> candidates = _context.lookup(name, scope);
|
|
|
|
|
reportResult(tokenIndex, candidates);
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-16 11:03:39 +02:00
|
|
|
void FindUsages::reportResult(unsigned tokenIndex, const QList<LookupItem> &candidates)
|
2009-10-27 12:01:45 +01:00
|
|
|
{
|
2009-11-04 12:02:19 +01:00
|
|
|
if (_processed.contains(tokenIndex))
|
|
|
|
|
return;
|
|
|
|
|
|
2020-08-28 17:46:52 +02:00
|
|
|
if (!checkCandidates(candidates))
|
|
|
|
|
return;
|
2011-01-27 14:51:01 +01:00
|
|
|
|
2010-05-25 14:53:21 +02:00
|
|
|
const Token &tk = tokenAt(tokenIndex);
|
|
|
|
|
if (tk.generated())
|
|
|
|
|
return;
|
2009-11-04 12:02:19 +01:00
|
|
|
|
|
|
|
|
_processed.insert(tokenIndex);
|
|
|
|
|
|
2019-07-24 18:40:10 +02:00
|
|
|
int line, col;
|
2009-10-27 12:01:45 +01:00
|
|
|
getTokenStartPosition(tokenIndex, &line, &col);
|
2011-01-27 14:51:01 +01:00
|
|
|
QString lineText;
|
2019-07-24 18:40:10 +02:00
|
|
|
if (line < int(_sourceLineEnds.size()))
|
2013-02-26 14:09:44 +01:00
|
|
|
lineText = fetchLine(line);
|
2011-04-11 09:56:26 +02:00
|
|
|
else
|
|
|
|
|
lineText = matchingLine(tk);
|
2013-12-12 21:37:46 +01:00
|
|
|
const int len = tk.utf16chars();
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2020-08-28 14:07:16 +02:00
|
|
|
const Usage u(Utils::FilePath::fromString(_doc->fileName()), lineText,
|
2022-06-10 10:47:38 +02:00
|
|
|
getContainingFunction(line, col), getType(line, col, tokenIndex),
|
|
|
|
|
line, col - 1, len);
|
2009-12-01 17:31:41 +01:00
|
|
|
_usages.append(u);
|
2009-10-27 12:01:45 +01:00
|
|
|
_references.append(tokenIndex);
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-10 10:47:38 +02:00
|
|
|
QString FindUsages::getContainingFunction(int line, int column)
|
|
|
|
|
{
|
|
|
|
|
const QList<AST *> astPath = ASTPath(_doc)(line, column);
|
|
|
|
|
bool hasBlock = false;
|
|
|
|
|
for (auto it = astPath.crbegin(); it != astPath.crend(); ++it) {
|
|
|
|
|
if (!hasBlock && (*it)->asCompoundStatement())
|
|
|
|
|
hasBlock = true;
|
|
|
|
|
if (const auto func = (*it)->asFunctionDefinition()) {
|
|
|
|
|
if (!hasBlock)
|
|
|
|
|
return {};
|
|
|
|
|
if (!func->symbol)
|
|
|
|
|
return {};
|
|
|
|
|
return Overview().prettyName(func->symbol->name());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-12 16:10:23 +01:00
|
|
|
class FindUsages::GetUsageType
|
2020-08-28 14:07:16 +02:00
|
|
|
{
|
2021-01-12 16:10:23 +01:00
|
|
|
public:
|
|
|
|
|
GetUsageType(FindUsages *findUsages, const QList<AST *> &astPath, int tokenIndex)
|
|
|
|
|
: m_findUsages(findUsages), m_astPath(astPath), m_tokenIndex(tokenIndex)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Usage::Type getUsageType() const
|
|
|
|
|
{
|
|
|
|
|
if (m_astPath.size() < 2 || !m_astPath.last()->asSimpleName())
|
|
|
|
|
return Usage::Type::Other;
|
|
|
|
|
|
|
|
|
|
for (auto it = m_astPath.rbegin() + 1; it != m_astPath.rend(); ++it) {
|
|
|
|
|
if ((*it)->asExpressionStatement())
|
|
|
|
|
return Usage::Type::Read;
|
|
|
|
|
if ((*it)->asSwitchStatement())
|
|
|
|
|
return Usage::Type::Read;
|
|
|
|
|
if ((*it)->asCaseStatement())
|
|
|
|
|
return Usage::Type::Read;
|
|
|
|
|
if ((*it)->asIfStatement())
|
|
|
|
|
return Usage::Type::Read;
|
|
|
|
|
if ((*it)->asLambdaCapture())
|
|
|
|
|
return Usage::Type::Other;
|
|
|
|
|
if ((*it)->asTypenameTypeParameter())
|
|
|
|
|
return Usage::Type::Declaration;
|
|
|
|
|
if ((*it)->asNewExpression())
|
|
|
|
|
return Usage::Type::Other;
|
|
|
|
|
if (ClassSpecifierAST *classSpec = (*it)->asClassSpecifier()) {
|
|
|
|
|
if (classSpec->name == *(it - 1))
|
|
|
|
|
return Usage::Type::Declaration;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (const auto memInitAst = (*it)->asMemInitializer()) {
|
|
|
|
|
if (memInitAst->name == *(it - 1))
|
|
|
|
|
return Usage::Type::Write;
|
|
|
|
|
return Usage::Type::Read;
|
|
|
|
|
}
|
|
|
|
|
if ((*it)->asCall())
|
|
|
|
|
return checkPotentialWrite(getUsageTypeForCall(it), it + 1);
|
|
|
|
|
if ((*it)->asDeleteExpression())
|
|
|
|
|
return Usage::Type::Write;
|
|
|
|
|
if (const auto binExpr = (*it)->asBinaryExpression()) {
|
|
|
|
|
if (binExpr->left_expression == *(it - 1) && isAssignment(binExpr->binary_op_token))
|
|
|
|
|
return checkPotentialWrite(Usage::Type::Write, it + 1);
|
2022-08-26 10:30:00 +02:00
|
|
|
const std::optional<LookupItem> item = getTypeOfExpr(binExpr->left_expression,
|
|
|
|
|
it + 1);
|
2021-01-12 16:10:23 +01:00
|
|
|
if (!item)
|
|
|
|
|
return Usage::Type::Other;
|
|
|
|
|
return checkPotentialWrite(getUsageTypeFromLhsAndRhs(
|
|
|
|
|
item->type(), binExpr->right_expression, it),
|
|
|
|
|
it + 1);
|
|
|
|
|
}
|
|
|
|
|
if (const auto unaryOp = (*it)->asUnaryExpression()) {
|
|
|
|
|
switch (m_findUsages->tokenKind(unaryOp->unary_op_token)) {
|
|
|
|
|
case T_PLUS_PLUS: case T_MINUS_MINUS:
|
|
|
|
|
return checkPotentialWrite(Usage::Type::Write, it + 1);
|
|
|
|
|
case T_AMPER: case T_STAR:
|
|
|
|
|
continue;
|
|
|
|
|
default:
|
|
|
|
|
return Usage::Type::Read;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (const auto sizeofExpr = (*it)->asSizeofExpression()) {
|
|
|
|
|
if (containsToken(sizeofExpr->expression))
|
|
|
|
|
return Usage::Type::Read;
|
|
|
|
|
return Usage::Type::Other;
|
|
|
|
|
}
|
|
|
|
|
if (const auto arrayExpr = (*it)->asArrayAccess()) {
|
|
|
|
|
if (containsToken(arrayExpr->expression))
|
|
|
|
|
return Usage::Type::Read;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (const auto postIncrDecrOp = (*it)->asPostIncrDecr())
|
|
|
|
|
return checkPotentialWrite(Usage::Type::Write, it + 1);
|
|
|
|
|
if (const auto declaratorId = (*it)->asDeclaratorId()) {
|
|
|
|
|
// We don't want to classify constructors and destructors as declarations
|
|
|
|
|
// when listing class usages.
|
|
|
|
|
if (m_findUsages->_declSymbol->asClass())
|
|
|
|
|
return Usage::Type::Other;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (const auto declarator = (*it)->asDeclarator()) {
|
|
|
|
|
if (containsToken(declarator->core_declarator)) {
|
2021-02-25 14:09:42 +01:00
|
|
|
if (declarator->initializer && declarator->equal_token
|
|
|
|
|
&& (!declarator->postfix_declarator_list
|
2021-01-12 16:10:23 +01:00
|
|
|
|| !declarator->postfix_declarator_list->value
|
|
|
|
|
|| !declarator->postfix_declarator_list->value->asFunctionDeclarator())) {
|
|
|
|
|
return Usage::Type::Initialization;
|
|
|
|
|
}
|
|
|
|
|
return Usage::Type::Declaration;
|
|
|
|
|
}
|
|
|
|
|
if (const auto decl = (*(it + 1))->asSimpleDeclaration()) {
|
|
|
|
|
if (decl->symbols && decl->symbols->value) {
|
|
|
|
|
return checkPotentialWrite(
|
|
|
|
|
getUsageTypeFromLhsAndRhs(decl->symbols->value->type(),
|
|
|
|
|
declarator->initializer, it + 1),
|
|
|
|
|
it + 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Usage::Type::Other;
|
|
|
|
|
}
|
|
|
|
|
if (const auto retStmt = (*it)->asReturnStatement()) {
|
|
|
|
|
for (auto funcIt = it + 1; funcIt != m_astPath.rend(); ++funcIt) {
|
|
|
|
|
if (FunctionDefinitionAST * const funcAst = (*funcIt)->asFunctionDefinition()) {
|
|
|
|
|
if (funcAst->symbol) {
|
|
|
|
|
return checkPotentialWrite(
|
|
|
|
|
getUsageTypeFromLhsAndRhs(funcAst->symbol->type(),
|
|
|
|
|
retStmt->expression, funcIt),
|
|
|
|
|
funcIt + 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Usage::Type::Other;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Usage::Type::Other;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
using Iterator = QList<AST *>::const_reverse_iterator;
|
|
|
|
|
|
|
|
|
|
bool containsToken(const AST *ast) const
|
|
|
|
|
{
|
|
|
|
|
return ast && ast->firstToken() <= m_tokenIndex && ast->lastToken() > m_tokenIndex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isAssignment(int token) const
|
|
|
|
|
{
|
|
|
|
|
switch (m_findUsages->tokenKind(token)) {
|
2020-08-28 14:07:16 +02:00
|
|
|
case T_AMPER_EQUAL: case T_CARET_EQUAL: case T_SLASH_EQUAL: case T_EQUAL:
|
|
|
|
|
case T_MINUS_EQUAL: case T_PERCENT_EQUAL: case T_PIPE_EQUAL: case T_PLUS_EQUAL:
|
|
|
|
|
case T_STAR_EQUAL: case T_TILDE_EQUAL:
|
|
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2021-01-12 16:10:23 +01:00
|
|
|
}
|
2020-08-28 14:07:16 +02:00
|
|
|
|
|
|
|
|
// This is called for the type of the LHS of an (initialization) assignment.
|
|
|
|
|
// We consider the RHS to be writable through the LHS if the LHS is a pointer
|
|
|
|
|
// that is non-const at any element level, or if it is a a non-const reference.
|
2021-01-12 16:10:23 +01:00
|
|
|
static Usage::Type getUsageTypeFromDataType(FullySpecifiedType type)
|
|
|
|
|
{
|
2020-08-28 14:07:16 +02:00
|
|
|
if (type.isAuto())
|
|
|
|
|
return Usage::Type::Other;
|
|
|
|
|
if (const auto refType = type->asReferenceType())
|
|
|
|
|
return refType->elementType().isConst() ? Usage::Type::Read : Usage::Type::WritableRef;
|
2022-06-24 16:45:12 +02:00
|
|
|
while (type->asPointerType()) {
|
2020-08-28 14:07:16 +02:00
|
|
|
type = type->asPointerType()->elementType();
|
|
|
|
|
if (!type.isConst())
|
|
|
|
|
return Usage::Type::WritableRef;
|
|
|
|
|
}
|
|
|
|
|
return Usage::Type::Read;
|
2021-01-12 16:10:23 +01:00
|
|
|
}
|
2020-08-28 14:07:16 +02:00
|
|
|
|
|
|
|
|
// If we found a potential write access inside a lambda, we have to check whether the variable
|
|
|
|
|
// was captured by value. If so, it's not really a write access.
|
|
|
|
|
// FIXME: The parser does not record whether the capture was by reference.
|
2021-01-12 16:10:23 +01:00
|
|
|
Usage::Type checkPotentialWrite(Usage::Type usageType, Iterator startIt) const
|
|
|
|
|
{
|
2020-08-28 14:07:16 +02:00
|
|
|
if (usageType != Usage::Type::Write && usageType != Usage::Type::WritableRef)
|
|
|
|
|
return usageType;
|
2021-01-12 16:10:23 +01:00
|
|
|
for (auto it = startIt; it != m_astPath.rend(); ++it) {
|
|
|
|
|
if ((*it)->firstToken() > m_tokenIndex)
|
2020-08-28 14:07:16 +02:00
|
|
|
break;
|
|
|
|
|
const auto lambdaExpr = (*it)->asLambdaExpression();
|
|
|
|
|
if (!lambdaExpr)
|
|
|
|
|
continue;
|
|
|
|
|
LambdaCaptureAST * const captureAst = lambdaExpr->lambda_introducer->lambda_capture;
|
|
|
|
|
if (!captureAst)
|
|
|
|
|
continue;
|
|
|
|
|
for (CaptureListAST *capList = captureAst->capture_list; capList;
|
|
|
|
|
capList = capList->next) {
|
|
|
|
|
if (!capList->value || !capList->value->identifier)
|
|
|
|
|
continue;
|
2021-01-12 16:10:23 +01:00
|
|
|
if (!Matcher::match(m_findUsages->_declSymbol->name(),
|
|
|
|
|
capList->value->identifier->name)) {
|
2020-08-28 14:07:16 +02:00
|
|
|
continue;
|
2021-01-12 16:10:23 +01:00
|
|
|
}
|
2020-08-28 14:07:16 +02:00
|
|
|
return capList->value->amper_token ? usageType : Usage::Type::Read;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return usageType;
|
2021-01-12 16:10:23 +01:00
|
|
|
}
|
2020-08-28 14:07:16 +02:00
|
|
|
|
2021-01-12 16:10:23 +01:00
|
|
|
const QList<LookupItem> getTypesOfExpr(ExpressionAST *expr, Iterator scopeSearchPos) const
|
|
|
|
|
{
|
2020-08-28 14:07:16 +02:00
|
|
|
if (!expr)
|
|
|
|
|
return {};
|
|
|
|
|
Scope *scope = nullptr;
|
2021-01-12 16:10:23 +01:00
|
|
|
for (auto it = scopeSearchPos; !scope && it != m_astPath.rend(); ++it) {
|
2020-08-28 14:07:16 +02:00
|
|
|
if (const auto stmt = (*it)->asCompoundStatement())
|
|
|
|
|
scope = stmt->symbol;
|
|
|
|
|
else if (const auto klass = (*it)->asClassSpecifier())
|
|
|
|
|
scope = klass->symbol;
|
|
|
|
|
else if (const auto ns = (*it)->asNamespace())
|
|
|
|
|
scope = ns->symbol;
|
|
|
|
|
}
|
|
|
|
|
if (!scope)
|
2021-01-12 16:10:23 +01:00
|
|
|
scope = m_findUsages->_doc->globalNamespace();
|
|
|
|
|
return m_findUsages->typeofExpression(expr, m_findUsages->_doc, scope);
|
|
|
|
|
}
|
2020-09-10 17:53:19 +02:00
|
|
|
|
2022-08-26 10:30:00 +02:00
|
|
|
std::optional<LookupItem> getTypeOfExpr(ExpressionAST *expr, Iterator scopeSearchPos) const
|
2021-01-12 16:10:23 +01:00
|
|
|
{
|
2020-09-10 17:53:19 +02:00
|
|
|
const QList<LookupItem> items = getTypesOfExpr(expr, scopeSearchPos);
|
2020-08-28 14:07:16 +02:00
|
|
|
if (items.isEmpty())
|
|
|
|
|
return {};
|
2022-08-26 10:30:00 +02:00
|
|
|
return std::optional<LookupItem>(items.first());
|
2021-01-12 16:10:23 +01:00
|
|
|
}
|
2020-08-28 14:07:16 +02:00
|
|
|
|
2021-01-12 16:10:23 +01:00
|
|
|
Usage::Type getUsageTypeFromLhsAndRhs(const FullySpecifiedType &lhsType, ExpressionAST *rhs,
|
|
|
|
|
Iterator scopeSearchPos) const
|
|
|
|
|
{
|
2020-08-28 14:07:16 +02:00
|
|
|
const Usage::Type usageType = getUsageTypeFromDataType(lhsType);
|
|
|
|
|
if (usageType != Usage::Type::Other)
|
|
|
|
|
return usageType;
|
|
|
|
|
|
|
|
|
|
// If the lhs has type auto, we use the RHS type.
|
2022-08-26 10:30:00 +02:00
|
|
|
const std::optional<LookupItem> item = getTypeOfExpr(rhs, scopeSearchPos);
|
2020-08-28 14:07:16 +02:00
|
|
|
if (!item)
|
|
|
|
|
return Usage::Type::Other;
|
|
|
|
|
return getUsageTypeFromDataType(item->type());
|
2021-01-12 16:10:23 +01:00
|
|
|
}
|
2020-08-28 14:07:16 +02:00
|
|
|
|
2021-01-12 16:10:23 +01:00
|
|
|
Usage::Type getUsageTypeForCall(Iterator callIt) const
|
|
|
|
|
{
|
2020-08-28 14:07:16 +02:00
|
|
|
CallAST * const call = (*callIt)->asCall();
|
|
|
|
|
|
|
|
|
|
// Check whether this is a member function call on the symbol we are looking for
|
|
|
|
|
// (possibly indirectly via a data member).
|
|
|
|
|
// If it is and the function is not const, then this is a potential write.
|
|
|
|
|
if (call->base_expression == *(callIt - 1)) {
|
2021-01-12 16:10:23 +01:00
|
|
|
for (auto it = callIt; it != m_astPath.rbegin(); --it) {
|
2020-08-28 14:07:16 +02:00
|
|
|
const auto memberAccess = (*it)->asMemberAccess();
|
2020-11-06 11:52:41 +01:00
|
|
|
if (!memberAccess || !memberAccess->member_name || !memberAccess->member_name->name)
|
2020-08-28 14:07:16 +02:00
|
|
|
continue;
|
|
|
|
|
if (memberAccess->member_name == *(it - 1))
|
|
|
|
|
return Usage::Type::Other;
|
2022-08-26 10:30:00 +02:00
|
|
|
const std::optional<LookupItem> item = getTypeOfExpr(memberAccess->base_expression,
|
|
|
|
|
it);
|
2020-08-28 14:07:16 +02:00
|
|
|
if (!item)
|
|
|
|
|
return Usage::Type::Other;
|
|
|
|
|
FullySpecifiedType baseExprType = item->type();
|
|
|
|
|
if (const auto refType = baseExprType->asReferenceType())
|
|
|
|
|
baseExprType = refType->elementType();
|
|
|
|
|
while (const auto ptrType = baseExprType->asPointerType())
|
|
|
|
|
baseExprType = ptrType->elementType();
|
|
|
|
|
Class *klass = baseExprType->asClassType();
|
2021-01-12 16:10:23 +01:00
|
|
|
const LookupContext context(m_findUsages->_doc, m_findUsages->_snapshot);
|
2020-08-28 14:07:16 +02:00
|
|
|
QList<LookupItem> items;
|
|
|
|
|
if (!klass) {
|
|
|
|
|
if (const auto namedType = baseExprType->asNamedType()) {
|
|
|
|
|
items = context.lookup(namedType->name(), item->scope());
|
2020-11-06 11:52:41 +01:00
|
|
|
for (const LookupItem &item : qAsConst(items)) {
|
|
|
|
|
if ((klass = item.type()->asClassType()))
|
|
|
|
|
break;
|
|
|
|
|
}
|
2020-08-28 14:07:16 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!klass)
|
|
|
|
|
return Usage::Type::Other;
|
|
|
|
|
items = context.lookup(memberAccess->member_name->name, klass);
|
|
|
|
|
if (items.isEmpty())
|
|
|
|
|
return Usage::Type::Other;
|
|
|
|
|
for (const LookupItem &item : qAsConst(items)) {
|
2022-06-24 16:45:12 +02:00
|
|
|
if (item.type()->asFunctionType()) {
|
2020-11-06 14:07:14 +01:00
|
|
|
if (item.type().isConst())
|
|
|
|
|
return Usage::Type::Read;
|
|
|
|
|
if (item.type().isStatic())
|
|
|
|
|
return Usage::Type::Other;
|
|
|
|
|
return Usage::Type::WritableRef;
|
|
|
|
|
}
|
2020-08-28 14:07:16 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Usage::Type::Other;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check whether our symbol is passed as an argument to the function.
|
|
|
|
|
// If it is and the corresponding parameter is a non-const pointer or reference,
|
|
|
|
|
// then this is a potential write.
|
|
|
|
|
bool match = false;
|
|
|
|
|
int argPos = -1;
|
|
|
|
|
for (ExpressionListAST *argList = call->expression_list; argList && !match;
|
|
|
|
|
argList = argList->next, ++argPos) {
|
|
|
|
|
match = argList->value == *(callIt - 1);
|
|
|
|
|
}
|
|
|
|
|
if (!match)
|
|
|
|
|
return Usage::Type::Other;
|
2020-09-10 17:53:19 +02:00
|
|
|
|
|
|
|
|
// If we find more than one overload with a matching number of arguments,
|
|
|
|
|
// and they have conflicting usage types, then we give up and report Type::Other.
|
|
|
|
|
// We could do better by trying to match the types manually and finding out
|
|
|
|
|
// which overload is the right one, but that would be an inordinate amount
|
|
|
|
|
// of effort and we'd still have no guarantee that the result is correct.
|
|
|
|
|
Usage::Type currentType = Usage::Type::Other;
|
|
|
|
|
for (const LookupItem &item : getTypesOfExpr(call->base_expression, callIt + 1)) {
|
|
|
|
|
Function * const func = item.type()->asFunctionType();
|
|
|
|
|
if (!func || func->argumentCount() <= argPos)
|
|
|
|
|
continue;
|
|
|
|
|
const Usage::Type newType = getUsageTypeFromLhsAndRhs(
|
|
|
|
|
func->argumentAt(argPos)->type(), (*(callIt - 1))->asExpression(), callIt);
|
|
|
|
|
if (newType != Usage::Type::Other && newType != currentType) {
|
|
|
|
|
if (currentType != Usage::Type::Other)
|
|
|
|
|
return Usage::Type::Other;
|
|
|
|
|
currentType = newType;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return currentType;
|
2020-08-28 14:07:16 +02:00
|
|
|
}
|
|
|
|
|
|
2021-01-12 16:10:23 +01:00
|
|
|
FindUsages * const m_findUsages;
|
|
|
|
|
const QList<AST *> &m_astPath;
|
|
|
|
|
const int m_tokenIndex;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Usage::Type FindUsages::getType(int line, int column, int tokenIndex)
|
|
|
|
|
{
|
2021-05-26 17:24:18 +02:00
|
|
|
if (!_categorize)
|
|
|
|
|
return Usage::Type::Other;
|
2021-01-12 16:10:23 +01:00
|
|
|
return GetUsageType(this, ASTPath(_doc)(line, column), tokenIndex).getUsageType();
|
2020-08-28 14:07:16 +02:00
|
|
|
}
|
|
|
|
|
|
2020-08-28 17:46:52 +02:00
|
|
|
QString FindUsages::matchingLine(const Token &tk) const
|
|
|
|
|
{
|
|
|
|
|
const char *beg = _source.constData();
|
|
|
|
|
const char *cp = beg + tk.bytesBegin();
|
|
|
|
|
for (; cp != beg - 1; --cp) {
|
|
|
|
|
if (*cp == '\n')
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
++cp;
|
|
|
|
|
|
|
|
|
|
const char *lineEnd = cp + 1;
|
|
|
|
|
for (; *lineEnd; ++lineEnd) {
|
|
|
|
|
if (*lineEnd == '\n')
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return QString::fromUtf8(cp, lineEnd - cp);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-26 13:38:07 +02:00
|
|
|
bool FindUsages::isLocalScope(Scope *scope)
|
|
|
|
|
{
|
|
|
|
|
if (scope) {
|
2022-06-23 16:56:36 +02:00
|
|
|
if (scope->asBlock() || scope->asTemplate() || scope->asFunction())
|
2010-08-26 13:38:07 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-16 11:03:39 +02:00
|
|
|
bool FindUsages::checkCandidates(const QList<LookupItem> &candidates) const
|
2009-10-27 12:01:45 +01:00
|
|
|
{
|
2010-08-05 12:49:29 +02:00
|
|
|
for (int i = candidates.size() - 1; i != -1; --i) {
|
|
|
|
|
const LookupItem &r = candidates.at(i);
|
|
|
|
|
|
|
|
|
|
if (Symbol *s = r.declaration()) {
|
2022-06-23 16:56:36 +02:00
|
|
|
if (_declSymbol->asTypenameArgument()) {
|
2010-08-12 12:51:54 +02:00
|
|
|
if (s != _declSymbol)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-19 18:22:03 +03:00
|
|
|
Scope *declEnclosingScope = _declSymbol->enclosingScope();
|
|
|
|
|
Scope *enclosingScope = s->enclosingScope();
|
|
|
|
|
if (isLocalScope(declEnclosingScope) || isLocalScope(enclosingScope)) {
|
2022-06-23 16:56:36 +02:00
|
|
|
if (_declSymbol->asClass() && declEnclosingScope->asTemplate()
|
|
|
|
|
&& s->asClass() && enclosingScope->asTemplate()) {
|
2013-06-07 08:15:19 +02:00
|
|
|
// for definition of functions of class defined outside the class definition
|
2014-05-19 18:22:03 +03:00
|
|
|
Scope *templEnclosingDeclSymbol = declEnclosingScope;
|
2013-06-07 08:15:19 +02:00
|
|
|
Scope *scopeOfTemplEnclosingDeclSymbol
|
|
|
|
|
= templEnclosingDeclSymbol->enclosingScope();
|
2014-05-19 18:22:03 +03:00
|
|
|
Scope *templEnclosingCandidateSymbol = enclosingScope;
|
2013-06-07 08:15:19 +02:00
|
|
|
Scope *scopeOfTemplEnclosingCandidateSymbol
|
|
|
|
|
= templEnclosingCandidateSymbol->enclosingScope();
|
|
|
|
|
|
|
|
|
|
if (scopeOfTemplEnclosingCandidateSymbol != scopeOfTemplEnclosingDeclSymbol)
|
|
|
|
|
return false;
|
2022-06-23 16:56:36 +02:00
|
|
|
} else if (_declSymbol->asClass() && declEnclosingScope->asTemplate()
|
|
|
|
|
&& enclosingScope->asClass()
|
|
|
|
|
&& enclosingScope->enclosingScope()->asTemplate()) {
|
2013-06-07 08:15:19 +02:00
|
|
|
// for declaration inside template class
|
2014-05-19 18:22:03 +03:00
|
|
|
Scope *templEnclosingDeclSymbol = declEnclosingScope;
|
2013-06-07 08:15:19 +02:00
|
|
|
Scope *scopeOfTemplEnclosingDeclSymbol
|
|
|
|
|
= templEnclosingDeclSymbol->enclosingScope();
|
2014-05-19 18:22:03 +03:00
|
|
|
Scope *templEnclosingCandidateSymbol = enclosingScope->enclosingScope();
|
2013-06-07 08:15:19 +02:00
|
|
|
Scope *scopeOfTemplEnclosingCandidateSymbol
|
|
|
|
|
= templEnclosingCandidateSymbol->enclosingScope();
|
|
|
|
|
|
|
|
|
|
if (scopeOfTemplEnclosingCandidateSymbol != scopeOfTemplEnclosingDeclSymbol)
|
|
|
|
|
return false;
|
2022-06-23 16:56:36 +02:00
|
|
|
} else if (enclosingScope->asTemplate() && ! _declSymbol->asTypenameArgument()) {
|
|
|
|
|
if (declEnclosingScope->asTemplate()) {
|
2014-05-19 18:22:03 +03:00
|
|
|
if (enclosingScope->enclosingScope() != declEnclosingScope->enclosingScope())
|
2013-07-08 12:30:06 +02:00
|
|
|
return false;
|
|
|
|
|
} else {
|
2014-05-19 18:22:03 +03:00
|
|
|
if (enclosingScope->enclosingScope() != declEnclosingScope)
|
2013-07-08 12:30:06 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
2022-06-23 16:56:36 +02:00
|
|
|
} else if (declEnclosingScope->asTemplate() && s->asTemplate()) {
|
2014-05-19 18:22:03 +03:00
|
|
|
if (declEnclosingScope->enclosingScope() != enclosingScope)
|
2011-01-17 13:39:41 +01:00
|
|
|
return false;
|
2022-06-23 16:56:36 +02:00
|
|
|
} else if (! s->asUsingDeclaration()
|
2014-05-19 18:22:03 +03:00
|
|
|
&& enclosingScope != declEnclosingScope) {
|
2010-08-10 14:40:27 +02:00
|
|
|
return false;
|
2011-01-17 13:39:41 +01:00
|
|
|
}
|
2010-08-10 14:40:27 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-05 12:49:29 +02:00
|
|
|
if (compareFullyQualifiedName(LookupContext::fullyQualifiedName(s), _declSymbolFullyQualifiedName))
|
2010-05-25 15:55:12 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
2009-10-27 12:01:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::checkExpression(unsigned startToken, unsigned endToken, Scope *scope)
|
2009-10-27 12:01:45 +01:00
|
|
|
{
|
2013-12-13 18:41:15 +01:00
|
|
|
const unsigned begin = tokenAt(startToken).bytesBegin();
|
|
|
|
|
const unsigned end = tokenAt(endToken).bytesEnd();
|
2010-08-10 14:40:27 +02:00
|
|
|
|
2012-01-12 17:35:37 +01:00
|
|
|
const QByteArray expression = _source.mid(begin, end - begin);
|
2010-08-10 14:40:27 +02:00
|
|
|
// qDebug() << "*** check expression:" << expression;
|
|
|
|
|
|
|
|
|
|
if (! scope)
|
|
|
|
|
scope = _currentScope;
|
|
|
|
|
|
2013-01-19 13:17:34 +01:00
|
|
|
// make possible to instantiate templates
|
|
|
|
|
typeofExpression.setExpandTemplates(true);
|
2010-08-11 13:46:32 +02:00
|
|
|
const QList<LookupItem> results = typeofExpression(expression, scope, TypeOfExpression::Preprocess);
|
2010-08-10 14:40:27 +02:00
|
|
|
reportResult(endToken, results);
|
2009-10-27 12:01:45 +01:00
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
Scope *FindUsages::switchScope(Scope *scope)
|
2010-08-05 12:49:29 +02:00
|
|
|
{
|
2010-08-11 12:26:02 +02:00
|
|
|
if (! scope)
|
|
|
|
|
return _currentScope;
|
|
|
|
|
|
2010-08-11 13:46:32 +02:00
|
|
|
Scope *previousScope = _currentScope;
|
|
|
|
|
_currentScope = scope;
|
|
|
|
|
return previousScope;
|
2010-08-05 12:49:29 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::statement(StatementAST *ast)
|
2009-10-27 12:01:45 +01:00
|
|
|
{
|
2010-08-10 14:40:27 +02:00
|
|
|
accept(ast);
|
|
|
|
|
}
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::expression(ExpressionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
accept(ast);
|
2009-10-27 12:01:45 +01:00
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::declaration(DeclarationAST *ast)
|
2009-10-27 12:01:45 +01:00
|
|
|
{
|
2010-08-10 14:40:27 +02:00
|
|
|
accept(ast);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Name *FindUsages::name(NameAST *ast)
|
|
|
|
|
{
|
|
|
|
|
if (ast) {
|
|
|
|
|
accept(ast);
|
|
|
|
|
return ast->name;
|
2009-10-27 12:01:45 +01:00
|
|
|
}
|
|
|
|
|
|
2019-07-31 17:21:41 +02:00
|
|
|
return nullptr;
|
2009-10-27 12:01:45 +01:00
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::specifier(SpecifierAST *ast)
|
2009-10-27 12:01:45 +01:00
|
|
|
{
|
2010-08-10 14:40:27 +02:00
|
|
|
accept(ast);
|
|
|
|
|
}
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::ptrOperator(PtrOperatorAST *ast)
|
|
|
|
|
{
|
|
|
|
|
accept(ast);
|
|
|
|
|
}
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::coreDeclarator(CoreDeclaratorAST *ast)
|
|
|
|
|
{
|
|
|
|
|
accept(ast);
|
|
|
|
|
}
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::postfixDeclarator(PostfixDeclaratorAST *ast)
|
|
|
|
|
{
|
|
|
|
|
accept(ast);
|
2009-10-27 12:01:45 +01:00
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
// AST
|
|
|
|
|
bool FindUsages::visit(ObjCSelectorArgumentAST *ast)
|
2009-10-27 12:01:45 +01:00
|
|
|
{
|
2010-08-10 14:40:27 +02:00
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::objCSelectorArgument(ObjCSelectorArgumentAST *ast)
|
|
|
|
|
{
|
|
|
|
|
if (! ast)
|
|
|
|
|
return;
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
// unsigned name_token = ast->name_token;
|
|
|
|
|
// unsigned colon_token = ast->colon_token;
|
|
|
|
|
}
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2014-07-15 12:37:19 +02:00
|
|
|
bool FindUsages::visit(GnuAttributeAST *ast)
|
2010-08-10 14:40:27 +02:00
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2014-07-15 12:37:19 +02:00
|
|
|
void FindUsages::attribute(GnuAttributeAST *ast)
|
2010-08-10 14:40:27 +02:00
|
|
|
{
|
|
|
|
|
if (! ast)
|
|
|
|
|
return;
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
// unsigned identifier_token = ast->identifier_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
// unsigned tag_token = ast->tag_token;
|
|
|
|
|
for (ExpressionListAST *it = ast->expression_list; it; it = it->next) {
|
|
|
|
|
this->expression(it->value);
|
2009-10-27 12:01:45 +01:00
|
|
|
}
|
2010-08-10 14:40:27 +02:00
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
}
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(DeclaratorAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2010-08-11 12:26:02 +02:00
|
|
|
void FindUsages::declarator(DeclaratorAST *ast, Scope *symbol)
|
2010-08-10 14:40:27 +02:00
|
|
|
{
|
|
|
|
|
if (! ast)
|
|
|
|
|
return;
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
for (SpecifierListAST *it = ast->attribute_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
for (PtrOperatorListAST *it = ast->ptr_operator_list; it; it = it->next) {
|
|
|
|
|
this->ptrOperator(it->value);
|
|
|
|
|
}
|
2010-08-10 15:54:31 +02:00
|
|
|
|
|
|
|
|
Scope *previousScope = switchScope(symbol);
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
this->coreDeclarator(ast->core_declarator);
|
|
|
|
|
for (PostfixDeclaratorListAST *it = ast->postfix_declarator_list; it; it = it->next) {
|
|
|
|
|
this->postfixDeclarator(it->value);
|
2009-10-27 12:01:45 +01:00
|
|
|
}
|
2010-08-10 14:40:27 +02:00
|
|
|
for (SpecifierListAST *it = ast->post_attribute_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned equals_token = ast->equals_token;
|
|
|
|
|
this->expression(ast->initializer);
|
2010-08-10 15:54:31 +02:00
|
|
|
(void) switchScope(previousScope);
|
2010-08-10 14:40:27 +02:00
|
|
|
}
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(QtPropertyDeclarationItemAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
2009-10-27 12:01:45 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::qtPropertyDeclarationItem(QtPropertyDeclarationItemAST *ast)
|
2009-10-27 12:01:45 +01:00
|
|
|
{
|
2010-08-10 14:40:27 +02:00
|
|
|
if (! ast)
|
|
|
|
|
return;
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
// unsigned item_name_token = ast->item_name_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
}
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(QtInterfaceNameAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
2009-10-27 12:01:45 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::qtInterfaceName(QtInterfaceNameAST *ast)
|
2009-10-27 12:01:45 +01:00
|
|
|
{
|
2010-08-10 14:40:27 +02:00
|
|
|
if (! ast)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/*const Name *interface_name =*/ this->name(ast->interface_name);
|
|
|
|
|
for (NameListAST *it = ast->constraint_list; it; it = it->next) {
|
|
|
|
|
/*const Name *value =*/ this->name(it->value);
|
2009-10-27 12:01:45 +01:00
|
|
|
}
|
2010-08-10 14:40:27 +02:00
|
|
|
}
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(BaseSpecifierAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
2009-10-27 12:01:45 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::baseSpecifier(BaseSpecifierAST *ast)
|
2009-10-27 12:01:45 +01:00
|
|
|
{
|
2010-08-10 14:40:27 +02:00
|
|
|
if (! ast)
|
|
|
|
|
return;
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
// unsigned virtual_token = ast->virtual_token;
|
|
|
|
|
// unsigned access_specifier_token = ast->access_specifier_token;
|
|
|
|
|
/*const Name *name =*/ this->name(ast->name);
|
|
|
|
|
// BaseClass *symbol = ast->symbol;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(CtorInitializerAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
2009-10-27 12:01:45 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::ctorInitializer(CtorInitializerAST *ast)
|
2009-10-27 12:01:45 +01:00
|
|
|
{
|
2010-08-10 14:40:27 +02:00
|
|
|
if (! ast)
|
|
|
|
|
return;
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
// unsigned colon_token = ast->colon_token;
|
|
|
|
|
for (MemInitializerListAST *it = ast->member_initializer_list; it; it = it->next) {
|
|
|
|
|
this->memInitializer(it->value);
|
2009-10-27 12:01:45 +01:00
|
|
|
}
|
2010-08-10 14:40:27 +02:00
|
|
|
// unsigned dot_dot_dot_token = ast->dot_dot_dot_token;
|
|
|
|
|
}
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(EnumeratorAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
2009-10-27 12:01:45 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::enumerator(EnumeratorAST *ast)
|
2009-10-27 12:01:45 +01:00
|
|
|
{
|
2010-08-10 14:40:27 +02:00
|
|
|
if (! ast)
|
|
|
|
|
return;
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
// unsigned identifier_token = ast->identifier_token;
|
|
|
|
|
reportResult(ast->identifier_token, identifier(ast->identifier_token));
|
|
|
|
|
// unsigned equal_token = ast->equal_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
}
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2012-02-02 11:40:01 +01:00
|
|
|
bool FindUsages::visit(DynamicExceptionSpecificationAST *ast)
|
2010-08-10 14:40:27 +02:00
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::exceptionSpecification(ExceptionSpecificationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
if (! ast)
|
|
|
|
|
return;
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2012-02-02 11:40:01 +01:00
|
|
|
if (DynamicExceptionSpecificationAST *dyn = ast->asDynamicExceptionSpecification()) {
|
|
|
|
|
// unsigned throw_token = ast->throw_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
// unsigned dot_dot_dot_token = ast->dot_dot_dot_token;
|
|
|
|
|
for (ExpressionListAST *it = dyn->type_id_list; it; it = it->next) {
|
|
|
|
|
this->expression(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
} else if (NoExceptSpecificationAST *no = ast->asNoExceptSpecification()) {
|
|
|
|
|
this->expression(no->expression);
|
2009-10-27 12:01:45 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(MemInitializerAST *ast)
|
2009-10-27 12:01:45 +01:00
|
|
|
{
|
2010-08-10 14:40:27 +02:00
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
2009-10-27 12:01:45 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::memInitializer(MemInitializerAST *ast)
|
2009-10-27 12:01:45 +01:00
|
|
|
{
|
2010-08-10 14:40:27 +02:00
|
|
|
if (! ast)
|
|
|
|
|
return;
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2022-06-23 16:56:36 +02:00
|
|
|
if (_currentScope->asFunction()) {
|
2010-08-11 12:26:02 +02:00
|
|
|
Class *classScope = _currentScope->enclosingClass();
|
2010-08-10 14:40:27 +02:00
|
|
|
if (! classScope) {
|
2015-11-19 13:49:26 +01:00
|
|
|
if (ClassOrNamespace *binding = _context.lookupType(_currentScope)) {
|
2022-05-19 13:06:41 +02:00
|
|
|
const QList<Symbol *> symbols = binding->symbols();
|
|
|
|
|
for (Symbol *s : symbols) {
|
2010-08-10 14:40:27 +02:00
|
|
|
if (Class *k = s->asClass()) {
|
2010-08-11 12:26:02 +02:00
|
|
|
classScope = k;
|
2010-08-10 14:40:27 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
if (classScope) {
|
|
|
|
|
Scope *previousScope = switchScope(classScope);
|
|
|
|
|
/*const Name *name =*/ this->name(ast->name);
|
|
|
|
|
(void) switchScope(previousScope);
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-09-17 09:58:09 +02:00
|
|
|
this->expression(ast->expression);
|
2010-08-10 14:40:27 +02:00
|
|
|
}
|
2009-10-27 12:01:45 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(NestedNameSpecifierAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
2009-10-27 12:01:45 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::nestedNameSpecifier(NestedNameSpecifierAST *ast)
|
2009-10-27 12:01:45 +01:00
|
|
|
{
|
2010-08-10 14:40:27 +02:00
|
|
|
if (! ast)
|
|
|
|
|
return;
|
2010-02-11 10:18:05 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
/*const Name *class_or_namespace_name =*/ this->name(ast->class_or_namespace_name);
|
|
|
|
|
// unsigned scope_token = ast->scope_token;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-12 12:41:46 +02:00
|
|
|
bool FindUsages::visit(ExpressionListParenAST *ast)
|
2010-08-10 14:40:27 +02:00
|
|
|
{
|
2012-09-17 09:58:09 +02:00
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
for (ExpressionListAST *it = ast->expression_list; it; it = it->next) {
|
|
|
|
|
this->expression(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
2010-02-11 10:18:05 +01:00
|
|
|
return false;
|
2009-10-27 12:01:45 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-12 12:41:46 +02:00
|
|
|
void FindUsages::newPlacement(ExpressionListParenAST *ast)
|
2010-02-08 09:34:51 +01:00
|
|
|
{
|
2010-08-10 14:40:27 +02:00
|
|
|
if (! ast)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
for (ExpressionListAST *it = ast->expression_list; it; it = it->next) {
|
|
|
|
|
this->expression(it->value);
|
2010-02-08 09:34:51 +01:00
|
|
|
}
|
2010-08-10 14:40:27 +02:00
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
}
|
2010-02-08 09:34:51 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(NewArrayDeclaratorAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
2010-02-08 09:34:51 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
2010-03-12 11:32:22 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::newArrayDeclarator(NewArrayDeclaratorAST *ast)
|
2010-03-12 11:32:22 +01:00
|
|
|
{
|
2010-08-10 14:40:27 +02:00
|
|
|
if (! ast)
|
|
|
|
|
return;
|
2010-03-12 11:32:22 +01:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
// unsigned lbracket_token = ast->lbracket_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
// unsigned rbracket_token = ast->rbracket_token;
|
|
|
|
|
}
|
2010-06-01 11:57:25 +02:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(NewTypeIdAST *ast)
|
2010-06-01 11:57:25 +02:00
|
|
|
{
|
2010-08-10 14:40:27 +02:00
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
2010-08-05 15:01:59 +02:00
|
|
|
return false;
|
2010-06-01 11:57:25 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::newTypeId(NewTypeIdAST *ast)
|
2010-06-01 11:57:25 +02:00
|
|
|
{
|
2010-08-10 14:40:27 +02:00
|
|
|
if (! ast)
|
|
|
|
|
return;
|
2010-08-05 15:01:59 +02:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
for (PtrOperatorListAST *it = ast->ptr_operator_list; it; it = it->next) {
|
|
|
|
|
this->ptrOperator(it->value);
|
|
|
|
|
}
|
|
|
|
|
for (NewArrayDeclaratorListAST *it = ast->new_array_declarator_list; it; it = it->next) {
|
|
|
|
|
this->newArrayDeclarator(it->value);
|
2010-06-01 11:57:25 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(OperatorAST *ast)
|
2010-06-01 11:57:25 +02:00
|
|
|
{
|
2010-08-10 14:40:27 +02:00
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-08-05 15:01:59 +02:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::cppOperator(OperatorAST *ast)
|
|
|
|
|
{
|
|
|
|
|
if (! ast)
|
|
|
|
|
return;
|
2010-08-05 15:01:59 +02:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
// unsigned op_token = ast->op_token;
|
|
|
|
|
// unsigned open_token = ast->open_token;
|
|
|
|
|
// unsigned close_token = ast->close_token;
|
2010-06-01 11:57:25 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(ParameterDeclarationClauseAST *ast)
|
2010-06-01 11:57:25 +02:00
|
|
|
{
|
2010-08-10 14:40:27 +02:00
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-08-05 15:01:59 +02:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::parameterDeclarationClause(ParameterDeclarationClauseAST *ast)
|
|
|
|
|
{
|
|
|
|
|
if (! ast)
|
|
|
|
|
return;
|
2010-08-05 15:01:59 +02:00
|
|
|
|
2010-08-26 15:55:31 +02:00
|
|
|
for (ParameterDeclarationListAST *it = ast->parameter_declaration_list; it; it = it->next) {
|
2010-08-10 14:40:27 +02:00
|
|
|
this->declaration(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned dot_dot_dot_token = ast->dot_dot_dot_token;
|
|
|
|
|
}
|
2010-08-05 15:01:59 +02:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(TranslationUnitAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-08-05 15:01:59 +02:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::translationUnit(TranslationUnitAST *ast)
|
|
|
|
|
{
|
|
|
|
|
if (! ast)
|
|
|
|
|
return;
|
2010-08-05 15:01:59 +02:00
|
|
|
|
2010-08-11 12:26:02 +02:00
|
|
|
Scope *previousScope = switchScope(_doc->globalNamespace());
|
2010-08-10 14:40:27 +02:00
|
|
|
for (DeclarationListAST *it = ast->declaration_list; it; it = it->next) {
|
|
|
|
|
this->declaration(it->value);
|
|
|
|
|
}
|
|
|
|
|
(void) switchScope(previousScope);
|
|
|
|
|
}
|
2010-06-01 11:57:25 +02:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(ObjCProtocolRefsAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-08-05 15:01:59 +02:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::objCProtocolRefs(ObjCProtocolRefsAST *ast)
|
|
|
|
|
{
|
|
|
|
|
if (! ast)
|
|
|
|
|
return;
|
2010-08-05 15:01:59 +02:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
// unsigned less_token = ast->less_token;
|
|
|
|
|
for (NameListAST *it = ast->identifier_list; it; it = it->next) {
|
|
|
|
|
/*const Name *value =*/ this->name(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned greater_token = ast->greater_token;
|
|
|
|
|
}
|
2010-08-05 15:01:59 +02:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(ObjCMessageArgumentAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-08-06 11:29:41 +02:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::objCMessageArgument(ObjCMessageArgumentAST *ast)
|
|
|
|
|
{
|
|
|
|
|
if (! ast)
|
|
|
|
|
return;
|
2010-08-06 11:29:41 +02:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
this->expression(ast->parameter_value_expression);
|
|
|
|
|
}
|
2010-06-01 11:57:25 +02:00
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(ObjCTypeNameAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
|
|
|
|
return false;
|
2010-08-05 15:01:59 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
void FindUsages::objCTypeName(ObjCTypeNameAST *ast)
|
2010-08-05 15:01:59 +02:00
|
|
|
{
|
2010-08-10 14:40:27 +02:00
|
|
|
if (! ast)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
// unsigned type_qualifier_token = ast->type_qualifier_token;
|
|
|
|
|
this->expression(ast->type_id);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
2010-08-05 15:01:59 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(ObjCInstanceVariablesDeclarationAST *ast)
|
2010-08-05 15:01:59 +02:00
|
|
|
{
|
2010-08-10 14:40:27 +02:00
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
|
|
|
|
return false;
|
2010-06-01 11:57:25 +02:00
|
|
|
}
|
2010-08-10 14:40:27 +02:00
|
|
|
|
|
|
|
|
void FindUsages::objCInstanceVariablesDeclaration(ObjCInstanceVariablesDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
if (! ast)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// unsigned lbrace_token = ast->lbrace_token;
|
|
|
|
|
for (DeclarationListAST *it = ast->instance_variable_list; it; it = it->next) {
|
|
|
|
|
this->declaration(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned rbrace_token = ast->rbrace_token;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ObjCPropertyAttributeAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FindUsages::objCPropertyAttribute(ObjCPropertyAttributeAST *ast)
|
|
|
|
|
{
|
|
|
|
|
if (! ast)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// unsigned attribute_identifier_token = ast->attribute_identifier_token;
|
|
|
|
|
// unsigned equals_token = ast->equals_token;
|
|
|
|
|
/*const Name *method_selector =*/ this->name(ast->method_selector);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ObjCMessageArgumentDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FindUsages::objCMessageArgumentDeclaration(ObjCMessageArgumentDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
if (! ast)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
this->objCTypeName(ast->type_name);
|
|
|
|
|
for (SpecifierListAST *it = ast->attribute_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
/*const Name *param_name =*/ this->name(ast->param_name);
|
|
|
|
|
// Argument *argument = ast->argument;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ObjCMethodPrototypeAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FindUsages::objCMethodPrototype(ObjCMethodPrototypeAST *ast)
|
|
|
|
|
{
|
|
|
|
|
if (! ast)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// unsigned method_type_token = ast->method_type_token;
|
|
|
|
|
this->objCTypeName(ast->type_name);
|
|
|
|
|
/*const Name *selector =*/ this->name(ast->selector);
|
|
|
|
|
Scope *previousScope = switchScope(ast->symbol);
|
|
|
|
|
for (ObjCMessageArgumentDeclarationListAST *it = ast->argument_list; it; it = it->next) {
|
|
|
|
|
this->objCMessageArgumentDeclaration(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned dot_dot_dot_token = ast->dot_dot_dot_token;
|
|
|
|
|
for (SpecifierListAST *it = ast->attribute_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
// ObjCMethod *symbol = ast->symbol;
|
|
|
|
|
(void) switchScope(previousScope);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ObjCSynthesizedPropertyAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FindUsages::objCSynthesizedProperty(ObjCSynthesizedPropertyAST *ast)
|
|
|
|
|
{
|
|
|
|
|
if (! ast)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// unsigned property_identifier_token = ast->property_identifier_token;
|
|
|
|
|
// unsigned equals_token = ast->equals_token;
|
|
|
|
|
// unsigned alias_identifier_token = ast->alias_identifier_token;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(LambdaIntroducerAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FindUsages::lambdaIntroducer(LambdaIntroducerAST *ast)
|
|
|
|
|
{
|
|
|
|
|
if (! ast)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// unsigned lbracket_token = ast->lbracket_token;
|
|
|
|
|
this->lambdaCapture(ast->lambda_capture);
|
|
|
|
|
// unsigned rbracket_token = ast->rbracket_token;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(LambdaCaptureAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FindUsages::lambdaCapture(LambdaCaptureAST *ast)
|
|
|
|
|
{
|
|
|
|
|
if (! ast)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// unsigned default_capture_token = ast->default_capture_token;
|
|
|
|
|
for (CaptureListAST *it = ast->capture_list; it; it = it->next) {
|
|
|
|
|
this->capture(it->value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(CaptureAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FindUsages::capture(CaptureAST *ast)
|
|
|
|
|
{
|
|
|
|
|
if (! ast)
|
|
|
|
|
return;
|
|
|
|
|
|
2012-10-25 16:22:42 +02:00
|
|
|
this->name(ast->identifier);
|
2010-08-10 14:40:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(LambdaDeclaratorAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FindUsages::lambdaDeclarator(LambdaDeclaratorAST *ast)
|
|
|
|
|
{
|
|
|
|
|
if (! ast)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
this->parameterDeclarationClause(ast->parameter_declaration_clause);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
for (SpecifierListAST *it = ast->attributes; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned mutable_token = ast->mutable_token;
|
|
|
|
|
this->exceptionSpecification(ast->exception_specification);
|
|
|
|
|
this->trailingReturnType(ast->trailing_return_type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(TrailingReturnTypeAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
Q_ASSERT(!"unreachable");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FindUsages::trailingReturnType(TrailingReturnTypeAST *ast)
|
|
|
|
|
{
|
|
|
|
|
if (! ast)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// unsigned arrow_token = ast->arrow_token;
|
|
|
|
|
for (SpecifierListAST *it = ast->attributes; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
2010-08-26 15:55:31 +02:00
|
|
|
for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) {
|
2010-08-10 14:40:27 +02:00
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
this->declarator(ast->declarator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// StatementAST
|
|
|
|
|
bool FindUsages::visit(QtMemberDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned q_token = ast->q_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
this->expression(ast->type_id);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(CaseStatementAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned case_token = ast->case_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
// unsigned colon_token = ast->colon_token;
|
|
|
|
|
this->statement(ast->statement);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(CompoundStatementAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned lbrace_token = ast->lbrace_token;
|
|
|
|
|
Scope *previousScope = switchScope(ast->symbol);
|
|
|
|
|
for (StatementListAST *it = ast->statement_list; it; it = it->next) {
|
|
|
|
|
this->statement(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned rbrace_token = ast->rbrace_token;
|
|
|
|
|
// Block *symbol = ast->symbol;
|
|
|
|
|
(void) switchScope(previousScope);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(DeclarationStatementAST *ast)
|
|
|
|
|
{
|
|
|
|
|
this->declaration(ast->declaration);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(DoStatementAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned do_token = ast->do_token;
|
|
|
|
|
this->statement(ast->statement);
|
|
|
|
|
// unsigned while_token = ast->while_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
// unsigned semicolon_token = ast->semicolon_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ExpressionOrDeclarationStatementAST *ast)
|
|
|
|
|
{
|
|
|
|
|
this->statement(ast->expression);
|
|
|
|
|
this->statement(ast->declaration);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ExpressionStatementAST *ast)
|
|
|
|
|
{
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
// unsigned semicolon_token = ast->semicolon_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ForeachStatementAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned foreach_token = ast->foreach_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
Scope *previousScope = switchScope(ast->symbol);
|
|
|
|
|
for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
this->declarator(ast->declarator);
|
|
|
|
|
this->expression(ast->initializer);
|
|
|
|
|
// unsigned comma_token = ast->comma_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
this->statement(ast->statement);
|
|
|
|
|
// Block *symbol = ast->symbol;
|
|
|
|
|
(void) switchScope(previousScope);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-19 16:33:25 +04:00
|
|
|
bool FindUsages::visit(RangeBasedForStatementAST *ast)
|
|
|
|
|
{
|
|
|
|
|
Scope *previousScope = switchScope(ast->symbol);
|
|
|
|
|
for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
this->declarator(ast->declarator);
|
|
|
|
|
// unsigned comma_token = ast->comma_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
this->statement(ast->statement);
|
|
|
|
|
// Block *symbol = ast->symbol;
|
|
|
|
|
(void) switchScope(previousScope);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(ForStatementAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned for_token = ast->for_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
Scope *previousScope = switchScope(ast->symbol);
|
|
|
|
|
this->statement(ast->initializer);
|
|
|
|
|
this->expression(ast->condition);
|
|
|
|
|
// unsigned semicolon_token = ast->semicolon_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
this->statement(ast->statement);
|
|
|
|
|
// Block *symbol = ast->symbol;
|
|
|
|
|
(void) switchScope(previousScope);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(IfStatementAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned if_token = ast->if_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
Scope *previousScope = switchScope(ast->symbol);
|
|
|
|
|
this->expression(ast->condition);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
this->statement(ast->statement);
|
|
|
|
|
// unsigned else_token = ast->else_token;
|
|
|
|
|
this->statement(ast->else_statement);
|
|
|
|
|
// Block *symbol = ast->symbol;
|
|
|
|
|
(void) switchScope(previousScope);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(LabeledStatementAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned label_token = ast->label_token;
|
|
|
|
|
// unsigned colon_token = ast->colon_token;
|
|
|
|
|
this->statement(ast->statement);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(BreakStatementAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
// unsigned break_token = ast->break_token;
|
|
|
|
|
// unsigned semicolon_token = ast->semicolon_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ContinueStatementAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
// unsigned continue_token = ast->continue_token;
|
|
|
|
|
// unsigned semicolon_token = ast->semicolon_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(GotoStatementAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
// unsigned goto_token = ast->goto_token;
|
|
|
|
|
// unsigned identifier_token = ast->identifier_token;
|
|
|
|
|
// unsigned semicolon_token = ast->semicolon_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ReturnStatementAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned return_token = ast->return_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
// unsigned semicolon_token = ast->semicolon_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(SwitchStatementAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned switch_token = ast->switch_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
Scope *previousScope = switchScope(ast->symbol);
|
|
|
|
|
this->expression(ast->condition);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
this->statement(ast->statement);
|
|
|
|
|
// Block *symbol = ast->symbol;
|
|
|
|
|
(void) switchScope(previousScope);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(TryBlockStatementAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned try_token = ast->try_token;
|
|
|
|
|
this->statement(ast->statement);
|
|
|
|
|
for (CatchClauseListAST *it = ast->catch_clause_list; it; it = it->next) {
|
|
|
|
|
this->statement(it->value);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(CatchClauseAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned catch_token = ast->catch_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
Scope *previousScope = switchScope(ast->symbol);
|
|
|
|
|
this->declaration(ast->exception_declaration);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
this->statement(ast->statement);
|
|
|
|
|
// Block *symbol = ast->symbol;
|
|
|
|
|
(void) switchScope(previousScope);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(WhileStatementAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned while_token = ast->while_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
Scope *previousScope = switchScope(ast->symbol);
|
|
|
|
|
this->expression(ast->condition);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
this->statement(ast->statement);
|
|
|
|
|
// Block *symbol = ast->symbol;
|
|
|
|
|
(void) switchScope(previousScope);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ObjCFastEnumerationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned for_token = ast->for_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
Scope *previousScope = switchScope(ast->symbol);
|
|
|
|
|
for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
this->declarator(ast->declarator);
|
|
|
|
|
this->expression(ast->initializer);
|
|
|
|
|
// unsigned in_token = ast->in_token;
|
|
|
|
|
this->expression(ast->fast_enumeratable_expression);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
this->statement(ast->statement);
|
|
|
|
|
// Block *symbol = ast->symbol;
|
|
|
|
|
(void) switchScope(previousScope);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ObjCSynchronizedStatementAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned synchronized_token = ast->synchronized_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
this->expression(ast->synchronized_object);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
this->statement(ast->statement);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ExpressionAST
|
|
|
|
|
bool FindUsages::visit(IdExpressionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
/*const Name *name =*/ this->name(ast->name);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(CompoundExpressionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
this->statement(ast->statement);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(CompoundLiteralAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
this->expression(ast->type_id);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
this->expression(ast->initializer);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(QtMethodAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned method_token = ast->method_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
this->declarator(ast->declarator);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(BinaryExpressionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
this->expression(ast->left_expression);
|
|
|
|
|
// unsigned binary_op_token = ast->binary_op_token;
|
|
|
|
|
this->expression(ast->right_expression);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(CastExpressionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
this->expression(ast->type_id);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ConditionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
this->declarator(ast->declarator);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ConditionalExpressionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
this->expression(ast->condition);
|
|
|
|
|
// unsigned question_token = ast->question_token;
|
|
|
|
|
this->expression(ast->left_expression);
|
|
|
|
|
// unsigned colon_token = ast->colon_token;
|
|
|
|
|
this->expression(ast->right_expression);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(CppCastExpressionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned cast_token = ast->cast_token;
|
|
|
|
|
// unsigned less_token = ast->less_token;
|
|
|
|
|
this->expression(ast->type_id);
|
|
|
|
|
// unsigned greater_token = ast->greater_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(DeleteExpressionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned scope_token = ast->scope_token;
|
|
|
|
|
// unsigned delete_token = ast->delete_token;
|
|
|
|
|
// unsigned lbracket_token = ast->lbracket_token;
|
|
|
|
|
// unsigned rbracket_token = ast->rbracket_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ArrayInitializerAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned lbrace_token = ast->lbrace_token;
|
|
|
|
|
for (ExpressionListAST *it = ast->expression_list; it; it = it->next) {
|
|
|
|
|
this->expression(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned rbrace_token = ast->rbrace_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(NewExpressionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned scope_token = ast->scope_token;
|
|
|
|
|
// unsigned new_token = ast->new_token;
|
|
|
|
|
this->newPlacement(ast->new_placement);
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
this->expression(ast->type_id);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
this->newTypeId(ast->new_type_id);
|
2012-09-19 11:26:33 +02:00
|
|
|
this->expression(ast->new_initializer);
|
2010-08-10 14:40:27 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(TypeidExpressionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned typeid_token = ast->typeid_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(TypenameCallExpressionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned typename_token = ast->typename_token;
|
|
|
|
|
/*const Name *name =*/ this->name(ast->name);
|
2012-09-19 10:26:07 +02:00
|
|
|
this->expression(ast->expression);
|
2010-08-10 14:40:27 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(TypeConstructorCallAST *ast)
|
|
|
|
|
{
|
|
|
|
|
for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
2012-09-19 10:26:07 +02:00
|
|
|
this->expression(ast->expression);
|
2010-08-10 14:40:27 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(SizeofExpressionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned sizeof_token = ast->sizeof_token;
|
|
|
|
|
// unsigned dot_dot_dot_token = ast->dot_dot_dot_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-18 13:33:26 +01:00
|
|
|
bool FindUsages::visit(PointerLiteralAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
// unsigned literal_token = ast->literal_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(NumericLiteralAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
// unsigned literal_token = ast->literal_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(BoolLiteralAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
// unsigned literal_token = ast->literal_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ThisExpressionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
// unsigned this_token = ast->this_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(NestedExpressionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(StringLiteralAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned literal_token = ast->literal_token;
|
|
|
|
|
this->expression(ast->next);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ThrowExpressionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned throw_token = ast->throw_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-22 11:08:01 +02:00
|
|
|
bool FindUsages::visit(NoExceptOperatorExpressionAST* ast)
|
|
|
|
|
{
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(TypeIdAST *ast)
|
|
|
|
|
{
|
|
|
|
|
for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
this->declarator(ast->declarator);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(UnaryExpressionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned unary_op_token = ast->unary_op_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ObjCMessageExpressionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned lbracket_token = ast->lbracket_token;
|
|
|
|
|
this->expression(ast->receiver_expression);
|
|
|
|
|
/*const Name *selector =*/ this->name(ast->selector);
|
|
|
|
|
for (ObjCMessageArgumentListAST *it = ast->argument_list; it; it = it->next) {
|
|
|
|
|
this->objCMessageArgument(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned rbracket_token = ast->rbracket_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ObjCProtocolExpressionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
// unsigned protocol_token = ast->protocol_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
// unsigned identifier_token = ast->identifier_token;
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ObjCEncodeExpressionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned encode_token = ast->encode_token;
|
|
|
|
|
this->objCTypeName(ast->type_name);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ObjCSelectorExpressionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned selector_token = ast->selector_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
/*const Name *selector =*/ this->name(ast->selector);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(LambdaExpressionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
this->lambdaIntroducer(ast->lambda_introducer);
|
|
|
|
|
this->lambdaDeclarator(ast->lambda_declarator);
|
|
|
|
|
this->statement(ast->statement);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(BracedInitializerAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned lbrace_token = ast->lbrace_token;
|
|
|
|
|
for (ExpressionListAST *it = ast->expression_list; it; it = it->next) {
|
|
|
|
|
this->expression(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned comma_token = ast->comma_token;
|
|
|
|
|
// unsigned rbrace_token = ast->rbrace_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// DeclarationAST
|
|
|
|
|
bool FindUsages::visit(SimpleDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned qt_invokable_token = ast->qt_invokable_token;
|
|
|
|
|
for (SpecifierListAST *it = ast->decl_specifier_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
for (DeclaratorListAST *it = ast->declarator_list; it; it = it->next) {
|
|
|
|
|
this->declarator(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned semicolon_token = ast->semicolon_token;
|
|
|
|
|
// List<Declaration *> *symbols = ast->symbols;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(EmptyDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
// unsigned semicolon_token = ast->semicolon_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(AccessDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
// unsigned access_specifier_token = ast->access_specifier_token;
|
|
|
|
|
// unsigned slots_token = ast->slots_token;
|
|
|
|
|
// unsigned colon_token = ast->colon_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(QtObjectTagAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
// unsigned q_object_token = ast->q_object_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(QtPrivateSlotAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned q_private_slot_token = ast->q_private_slot_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
// unsigned dptr_token = ast->dptr_token;
|
|
|
|
|
// unsigned dptr_lparen_token = ast->dptr_lparen_token;
|
|
|
|
|
// unsigned dptr_rparen_token = ast->dptr_rparen_token;
|
|
|
|
|
// unsigned comma_token = ast->comma_token;
|
2010-08-26 15:55:31 +02:00
|
|
|
for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) {
|
2010-08-10 14:40:27 +02:00
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
this->declarator(ast->declarator);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(QtPropertyDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned property_specifier_token = ast->property_specifier_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
this->expression(ast->type_id);
|
|
|
|
|
/*const Name *property_name =*/ this->name(ast->property_name);
|
2010-08-26 15:55:31 +02:00
|
|
|
for (QtPropertyDeclarationItemListAST *it = ast->property_declaration_item_list; it; it = it->next) {
|
2010-08-10 14:40:27 +02:00
|
|
|
this->qtPropertyDeclarationItem(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(QtEnumDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned enum_specifier_token = ast->enum_specifier_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
for (NameListAST *it = ast->enumerator_list; it; it = it->next) {
|
|
|
|
|
/*const Name *value =*/ this->name(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(QtFlagsDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned flags_specifier_token = ast->flags_specifier_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
for (NameListAST *it = ast->flag_enums_list; it; it = it->next) {
|
|
|
|
|
/*const Name *value =*/ this->name(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(QtInterfacesDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned interfaces_token = ast->interfaces_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
for (QtInterfaceNameListAST *it = ast->interface_name_list; it; it = it->next) {
|
|
|
|
|
this->qtInterfaceName(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(AsmDefinitionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
// unsigned asm_token = ast->asm_token;
|
|
|
|
|
// unsigned volatile_token = ast->volatile_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
// unsigned semicolon_token = ast->semicolon_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ExceptionDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
this->declarator(ast->declarator);
|
|
|
|
|
// unsigned dot_dot_dot_token = ast->dot_dot_dot_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(FunctionDefinitionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned qt_invokable_token = ast->qt_invokable_token;
|
|
|
|
|
for (SpecifierListAST *it = ast->decl_specifier_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
2010-08-10 15:54:31 +02:00
|
|
|
this->declarator(ast->declarator, ast->symbol);
|
|
|
|
|
Scope *previousScope = switchScope(ast->symbol);
|
2010-08-10 14:40:27 +02:00
|
|
|
this->ctorInitializer(ast->ctor_initializer);
|
|
|
|
|
this->statement(ast->function_body);
|
|
|
|
|
// Function *symbol = ast->symbol;
|
|
|
|
|
(void) switchScope(previousScope);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(LinkageBodyAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned lbrace_token = ast->lbrace_token;
|
|
|
|
|
for (DeclarationListAST *it = ast->declaration_list; it; it = it->next) {
|
|
|
|
|
this->declaration(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned rbrace_token = ast->rbrace_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(LinkageSpecificationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned extern_token = ast->extern_token;
|
|
|
|
|
// unsigned extern_type_token = ast->extern_type_token;
|
|
|
|
|
this->declaration(ast->declaration);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(NamespaceAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned namespace_token = ast->namespace_token;
|
|
|
|
|
// unsigned identifier_token = ast->identifier_token;
|
|
|
|
|
reportResult(ast->identifier_token, identifier(ast->identifier_token));
|
|
|
|
|
Scope *previousScope = switchScope(ast->symbol);
|
|
|
|
|
for (SpecifierListAST *it = ast->attribute_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
this->declaration(ast->linkage_body);
|
|
|
|
|
// Namespace *symbol = ast->symbol;
|
|
|
|
|
(void) switchScope(previousScope);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(NamespaceAliasDefinitionAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned namespace_token = ast->namespace_token;
|
|
|
|
|
// unsigned namespace_name_token = ast->namespace_name_token;
|
|
|
|
|
// unsigned equal_token = ast->equal_token;
|
|
|
|
|
/*const Name *name =*/ this->name(ast->name);
|
|
|
|
|
// unsigned semicolon_token = ast->semicolon_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ParameterDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
this->declarator(ast->declarator);
|
|
|
|
|
// unsigned equal_token = ast->equal_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
// Argument *symbol = ast->symbol;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-02 13:39:24 +01:00
|
|
|
bool FindUsages::visit(StaticAssertDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(TemplateDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned export_token = ast->export_token;
|
|
|
|
|
// unsigned template_token = ast->template_token;
|
|
|
|
|
// unsigned less_token = ast->less_token;
|
2010-08-11 14:56:51 +02:00
|
|
|
|
|
|
|
|
Scope *previousScope = switchScope(ast->symbol);
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
for (DeclarationListAST *it = ast->template_parameter_list; it; it = it->next) {
|
|
|
|
|
this->declaration(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned greater_token = ast->greater_token;
|
|
|
|
|
this->declaration(ast->declaration);
|
2010-08-11 14:56:51 +02:00
|
|
|
|
|
|
|
|
(void) switchScope(previousScope);
|
2010-08-10 14:40:27 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(TypenameTypeParameterAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned classkey_token = ast->classkey_token;
|
|
|
|
|
// unsigned dot_dot_dot_token = ast->dot_dot_dot_token;
|
|
|
|
|
/*const Name *name =*/ this->name(ast->name);
|
|
|
|
|
// unsigned equal_token = ast->equal_token;
|
|
|
|
|
this->expression(ast->type_id);
|
|
|
|
|
// TypenameArgument *symbol = ast->symbol;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(TemplateTypeParameterAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned template_token = ast->template_token;
|
|
|
|
|
// unsigned less_token = ast->less_token;
|
|
|
|
|
for (DeclarationListAST *it = ast->template_parameter_list; it; it = it->next) {
|
|
|
|
|
this->declaration(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned greater_token = ast->greater_token;
|
|
|
|
|
// unsigned class_token = ast->class_token;
|
|
|
|
|
// unsigned dot_dot_dot_token = ast->dot_dot_dot_token;
|
|
|
|
|
/*const Name *name =*/ this->name(ast->name);
|
|
|
|
|
// unsigned equal_token = ast->equal_token;
|
|
|
|
|
this->expression(ast->type_id);
|
|
|
|
|
// TypenameArgument *symbol = ast->symbol;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(UsingAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned using_token = ast->using_token;
|
|
|
|
|
// unsigned typename_token = ast->typename_token;
|
|
|
|
|
/*const Name *name =*/ this->name(ast->name);
|
|
|
|
|
// unsigned semicolon_token = ast->semicolon_token;
|
|
|
|
|
// UsingDeclaration *symbol = ast->symbol;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(UsingDirectiveAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned using_token = ast->using_token;
|
|
|
|
|
// unsigned namespace_token = ast->namespace_token;
|
|
|
|
|
/*const Name *name =*/ this->name(ast->name);
|
|
|
|
|
// unsigned semicolon_token = ast->semicolon_token;
|
|
|
|
|
// UsingNamespaceDirective *symbol = ast->symbol;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ObjCClassForwardDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
for (SpecifierListAST *it = ast->attribute_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned class_token = ast->class_token;
|
|
|
|
|
for (NameListAST *it = ast->identifier_list; it; it = it->next) {
|
|
|
|
|
/*const Name *value =*/ this->name(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned semicolon_token = ast->semicolon_token;
|
|
|
|
|
// List<ObjCForwardClassDeclaration *> *symbols = ast->symbols;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ObjCClassDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
for (SpecifierListAST *it = ast->attribute_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned interface_token = ast->interface_token;
|
|
|
|
|
// unsigned implementation_token = ast->implementation_token;
|
|
|
|
|
/*const Name *class_name =*/ this->name(ast->class_name);
|
|
|
|
|
|
|
|
|
|
Scope *previousScope = switchScope(ast->symbol);
|
|
|
|
|
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
/*const Name *category_name =*/ this->name(ast->category_name);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
// unsigned colon_token = ast->colon_token;
|
|
|
|
|
/*const Name *superclass =*/ this->name(ast->superclass);
|
|
|
|
|
this->objCProtocolRefs(ast->protocol_refs);
|
|
|
|
|
this->objCInstanceVariablesDeclaration(ast->inst_vars_decl);
|
|
|
|
|
for (DeclarationListAST *it = ast->member_declaration_list; it; it = it->next) {
|
|
|
|
|
this->declaration(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned end_token = ast->end_token;
|
|
|
|
|
// ObjCClass *symbol = ast->symbol;
|
|
|
|
|
(void) switchScope(previousScope);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ObjCProtocolForwardDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
for (SpecifierListAST *it = ast->attribute_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned protocol_token = ast->protocol_token;
|
|
|
|
|
for (NameListAST *it = ast->identifier_list; it; it = it->next) {
|
|
|
|
|
/*const Name *value =*/ this->name(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned semicolon_token = ast->semicolon_token;
|
|
|
|
|
// List<ObjCForwardProtocolDeclaration *> *symbols = ast->symbols;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ObjCProtocolDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
for (SpecifierListAST *it = ast->attribute_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned protocol_token = ast->protocol_token;
|
|
|
|
|
/*const Name *name =*/ this->name(ast->name);
|
|
|
|
|
|
|
|
|
|
Scope *previousScope = switchScope(ast->symbol);
|
|
|
|
|
|
|
|
|
|
this->objCProtocolRefs(ast->protocol_refs);
|
|
|
|
|
for (DeclarationListAST *it = ast->member_declaration_list; it; it = it->next) {
|
|
|
|
|
this->declaration(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned end_token = ast->end_token;
|
|
|
|
|
// ObjCProtocol *symbol = ast->symbol;
|
|
|
|
|
(void) switchScope(previousScope);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ObjCVisibilityDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
// unsigned visibility_token = ast->visibility_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ObjCPropertyDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
for (SpecifierListAST *it = ast->attribute_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned property_token = ast->property_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
for (ObjCPropertyAttributeListAST *it = ast->property_attribute_list; it; it = it->next) {
|
|
|
|
|
this->objCPropertyAttribute(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
this->declaration(ast->simple_declaration);
|
|
|
|
|
// List<ObjCPropertyDeclaration *> *symbols = ast->symbols;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ObjCMethodDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
this->objCMethodPrototype(ast->method_prototype);
|
|
|
|
|
this->statement(ast->function_body);
|
|
|
|
|
// unsigned semicolon_token = ast->semicolon_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ObjCSynthesizedPropertiesDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned synthesized_token = ast->synthesized_token;
|
|
|
|
|
for (ObjCSynthesizedPropertyListAST *it = ast->property_identifier_list; it; it = it->next) {
|
|
|
|
|
this->objCSynthesizedProperty(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned semicolon_token = ast->semicolon_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ObjCDynamicPropertiesDeclarationAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned dynamic_token = ast->dynamic_token;
|
|
|
|
|
for (NameListAST *it = ast->property_identifier_list; it; it = it->next) {
|
|
|
|
|
/*const Name *value =*/ this->name(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned semicolon_token = ast->semicolon_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NameAST
|
|
|
|
|
bool FindUsages::visit(ObjCSelectorAST *ast)
|
|
|
|
|
{
|
|
|
|
|
if (ast->name)
|
|
|
|
|
reportResult(ast->firstToken(), ast->name);
|
|
|
|
|
|
|
|
|
|
for (ObjCSelectorArgumentListAST *it = ast->selector_argument_list; it; it = it->next) {
|
|
|
|
|
this->objCSelectorArgument(it->value);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(QualifiedNameAST *ast)
|
|
|
|
|
{
|
|
|
|
|
#if 0
|
|
|
|
|
// unsigned global_scope_token = ast->global_scope_token;
|
|
|
|
|
for (NestedNameSpecifierListAST *it = ast->nested_name_specifier_list; it; it = it->next) {
|
|
|
|
|
this->nestedNameSpecifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
const Name *unqualified_name = this->name(ast->unqualified_name);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
for (NestedNameSpecifierListAST *it = ast->nested_name_specifier_list; it; it = it->next) {
|
|
|
|
|
NestedNameSpecifierAST *nested_name_specifier = it->value;
|
|
|
|
|
|
|
|
|
|
if (NameAST *class_or_namespace_name = nested_name_specifier->class_or_namespace_name) {
|
|
|
|
|
SimpleNameAST *simple_name = class_or_namespace_name->asSimpleName();
|
|
|
|
|
|
2019-07-31 17:21:41 +02:00
|
|
|
TemplateIdAST *template_id = nullptr;
|
2010-08-10 14:40:27 +02:00
|
|
|
if (! simple_name) {
|
|
|
|
|
template_id = class_or_namespace_name->asTemplateId();
|
|
|
|
|
|
|
|
|
|
if (template_id) {
|
2010-08-11 15:02:08 +02:00
|
|
|
for (ExpressionListAST *arg_it = template_id->template_argument_list; arg_it; arg_it = arg_it->next) {
|
2010-08-10 14:40:27 +02:00
|
|
|
this->expression(arg_it->value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (simple_name || template_id) {
|
|
|
|
|
const unsigned identifier_token = simple_name
|
|
|
|
|
? simple_name->identifier_token
|
|
|
|
|
: template_id->identifier_token;
|
|
|
|
|
|
|
|
|
|
if (identifier(identifier_token) == _id)
|
|
|
|
|
checkExpression(ast->firstToken(), identifier_token);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (NameAST *unqualified_name = ast->unqualified_name) {
|
|
|
|
|
unsigned identifier_token = 0;
|
|
|
|
|
|
|
|
|
|
if (SimpleNameAST *simple_name = unqualified_name->asSimpleName())
|
|
|
|
|
identifier_token = simple_name->identifier_token;
|
2012-08-07 17:03:52 +02:00
|
|
|
else if (DestructorNameAST *dtor = unqualified_name->asDestructorName())
|
|
|
|
|
identifier_token = dtor->unqualified_name->firstToken();
|
2010-08-10 14:40:27 +02:00
|
|
|
|
2019-07-31 17:21:41 +02:00
|
|
|
TemplateIdAST *template_id = nullptr;
|
2010-08-10 14:40:27 +02:00
|
|
|
if (! identifier_token) {
|
|
|
|
|
template_id = unqualified_name->asTemplateId();
|
|
|
|
|
|
|
|
|
|
if (template_id) {
|
|
|
|
|
identifier_token = template_id->identifier_token;
|
|
|
|
|
|
2010-08-11 15:02:08 +02:00
|
|
|
for (ExpressionListAST *template_arguments = template_id->template_argument_list;
|
2010-08-10 14:40:27 +02:00
|
|
|
template_arguments; template_arguments = template_arguments->next) {
|
|
|
|
|
this->expression(template_arguments->value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (identifier_token && identifier(identifier_token) == _id)
|
|
|
|
|
checkExpression(ast->firstToken(), identifier_token);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(OperatorFunctionIdAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned operator_token = ast->operator_token;
|
|
|
|
|
this->cppOperator(ast->op);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ConversionFunctionIdAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned operator_token = ast->operator_token;
|
|
|
|
|
for (SpecifierListAST *it = ast->type_specifier_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
for (PtrOperatorListAST *it = ast->ptr_operator_list; it; it = it->next) {
|
|
|
|
|
this->ptrOperator(it->value);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(SimpleNameAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned identifier_token = ast->identifier_token;
|
|
|
|
|
reportResult(ast->identifier_token, ast->name);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(TemplateIdAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned identifier_token = ast->identifier_token;
|
|
|
|
|
reportResult(ast->identifier_token, ast->name);
|
|
|
|
|
// unsigned less_token = ast->less_token;
|
|
|
|
|
for (ExpressionListAST *it = ast->template_argument_list; it; it = it->next) {
|
|
|
|
|
this->expression(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned greater_token = ast->greater_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// SpecifierAST
|
|
|
|
|
bool FindUsages::visit(SimpleSpecifierAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
// unsigned specifier_token = ast->specifier_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-15 12:37:19 +02:00
|
|
|
bool FindUsages::visit(GnuAttributeSpecifierAST *ast)
|
2010-08-10 14:40:27 +02:00
|
|
|
{
|
|
|
|
|
// unsigned attribute_token = ast->attribute_token;
|
|
|
|
|
// unsigned first_lparen_token = ast->first_lparen_token;
|
|
|
|
|
// unsigned second_lparen_token = ast->second_lparen_token;
|
2014-07-15 12:37:19 +02:00
|
|
|
for (GnuAttributeListAST *it = ast->attribute_list; it; it = it->next) {
|
2010-08-10 14:40:27 +02:00
|
|
|
this->attribute(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned first_rparen_token = ast->first_rparen_token;
|
|
|
|
|
// unsigned second_rparen_token = ast->second_rparen_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-14 23:07:05 +03:00
|
|
|
bool FindUsages::visit(MsvcDeclspecSpecifierAST *ast)
|
|
|
|
|
{
|
|
|
|
|
for (GnuAttributeListAST *it = ast->attribute_list; it; it = it->next) {
|
|
|
|
|
this->attribute(it->value);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(StdAttributeSpecifierAST *ast)
|
|
|
|
|
{
|
|
|
|
|
for (GnuAttributeListAST *it = ast->attribute_list; it; it = it->next) {
|
|
|
|
|
this->attribute(it->value);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(TypeofSpecifierAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned typeof_token = ast->typeof_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-10 14:41:58 +01:00
|
|
|
bool FindUsages::visit(DecltypeSpecifierAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned typeof_token = ast->typeof_token;
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(ClassSpecifierAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned classkey_token = ast->classkey_token;
|
|
|
|
|
for (SpecifierListAST *it = ast->attribute_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
/*const Name *name =*/ this->name(ast->name);
|
|
|
|
|
|
|
|
|
|
Scope *previousScope = switchScope(ast->symbol);
|
|
|
|
|
|
|
|
|
|
// unsigned colon_token = ast->colon_token;
|
|
|
|
|
for (BaseSpecifierListAST *it = ast->base_clause_list; it; it = it->next) {
|
|
|
|
|
this->baseSpecifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned dot_dot_dot_token = ast->dot_dot_dot_token;
|
|
|
|
|
// unsigned lbrace_token = ast->lbrace_token;
|
|
|
|
|
for (DeclarationListAST *it = ast->member_specifier_list; it; it = it->next) {
|
|
|
|
|
this->declaration(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned rbrace_token = ast->rbrace_token;
|
|
|
|
|
// Class *symbol = ast->symbol;
|
|
|
|
|
(void) switchScope(previousScope);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(NamedTypeSpecifierAST *ast)
|
|
|
|
|
{
|
|
|
|
|
/*const Name *name =*/ this->name(ast->name);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ElaboratedTypeSpecifierAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned classkey_token = ast->classkey_token;
|
|
|
|
|
for (SpecifierListAST *it = ast->attribute_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
/*const Name *name =*/ this->name(ast->name);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(EnumSpecifierAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned enum_token = ast->enum_token;
|
|
|
|
|
/*const Name *name =*/ this->name(ast->name);
|
|
|
|
|
// unsigned lbrace_token = ast->lbrace_token;
|
|
|
|
|
Scope *previousScope = switchScope(ast->symbol);
|
|
|
|
|
for (EnumeratorListAST *it = ast->enumerator_list; it; it = it->next) {
|
|
|
|
|
this->enumerator(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned rbrace_token = ast->rbrace_token;
|
|
|
|
|
// Enum *symbol = ast->symbol;
|
|
|
|
|
(void) switchScope(previousScope);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// PtrOperatorAST
|
|
|
|
|
bool FindUsages::visit(PointerToMemberAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned global_scope_token = ast->global_scope_token;
|
|
|
|
|
for (NestedNameSpecifierListAST *it = ast->nested_name_specifier_list; it; it = it->next) {
|
|
|
|
|
this->nestedNameSpecifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned star_token = ast->star_token;
|
|
|
|
|
for (SpecifierListAST *it = ast->cv_qualifier_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(PointerAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned star_token = ast->star_token;
|
|
|
|
|
for (SpecifierListAST *it = ast->cv_qualifier_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ReferenceAST *ast)
|
|
|
|
|
{
|
|
|
|
|
(void) ast;
|
|
|
|
|
// unsigned reference_token = ast->reference_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// PostfixAST
|
|
|
|
|
bool FindUsages::visit(CallAST *ast)
|
|
|
|
|
{
|
|
|
|
|
this->expression(ast->base_expression);
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
for (ExpressionListAST *it = ast->expression_list; it; it = it->next) {
|
|
|
|
|
this->expression(it->value);
|
|
|
|
|
}
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ArrayAccessAST *ast)
|
|
|
|
|
{
|
|
|
|
|
this->expression(ast->base_expression);
|
|
|
|
|
// unsigned lbracket_token = ast->lbracket_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
// unsigned rbracket_token = ast->rbracket_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(PostIncrDecrAST *ast)
|
|
|
|
|
{
|
|
|
|
|
this->expression(ast->base_expression);
|
|
|
|
|
// unsigned incr_decr_token = ast->incr_decr_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(MemberAccessAST *ast)
|
|
|
|
|
{
|
|
|
|
|
this->expression(ast->base_expression);
|
|
|
|
|
// unsigned access_token = ast->access_token;
|
|
|
|
|
// unsigned template_token = ast->template_token;
|
|
|
|
|
|
|
|
|
|
if (ast->member_name) {
|
|
|
|
|
if (SimpleNameAST *simple = ast->member_name->asSimpleName()) {
|
2014-09-02 17:56:22 +04:00
|
|
|
if (identifier(simple->identifier_token) == _id)
|
2010-08-10 14:40:27 +02:00
|
|
|
checkExpression(ast->firstToken(), simple->identifier_token);
|
2014-09-02 17:56:22 +04:00
|
|
|
} else if (TemplateIdAST *templateId = ast->member_name->asTemplateId()) {
|
|
|
|
|
if (identifier(templateId->identifier_token) == _id)
|
|
|
|
|
checkExpression(ast->firstToken(), templateId->identifier_token);
|
|
|
|
|
accept(templateId->template_argument_list);
|
2010-08-10 14:40:27 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CoreDeclaratorAST
|
|
|
|
|
bool FindUsages::visit(DeclaratorIdAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned dot_dot_dot_token = ast->dot_dot_dot_token;
|
|
|
|
|
/*const Name *name =*/ this->name(ast->name);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-17 18:10:53 +02:00
|
|
|
bool FindUsages::visit(DecompositionDeclaratorAST *ast)
|
|
|
|
|
{
|
|
|
|
|
for (auto it = ast->identifiers->begin(); it != ast->identifiers->end(); ++it)
|
|
|
|
|
name(*it);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:40:27 +02:00
|
|
|
bool FindUsages::visit(NestedDeclaratorAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
|
|
|
|
this->declarator(ast->declarator);
|
|
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// PostfixDeclaratorAST
|
|
|
|
|
bool FindUsages::visit(FunctionDeclaratorAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned lparen_token = ast->lparen_token;
|
2020-06-15 10:52:29 +03:00
|
|
|
Scope *previousScope = switchScope(ast->symbol);
|
2010-08-26 15:55:31 +02:00
|
|
|
this->parameterDeclarationClause(ast->parameter_declaration_clause);
|
2010-08-10 14:40:27 +02:00
|
|
|
// unsigned rparen_token = ast->rparen_token;
|
|
|
|
|
for (SpecifierListAST *it = ast->cv_qualifier_list; it; it = it->next) {
|
|
|
|
|
this->specifier(it->value);
|
|
|
|
|
}
|
|
|
|
|
this->exceptionSpecification(ast->exception_specification);
|
|
|
|
|
this->trailingReturnType(ast->trailing_return_type);
|
|
|
|
|
this->expression(ast->as_cpp_initializer);
|
2020-06-15 10:52:29 +03:00
|
|
|
(void) switchScope(previousScope);
|
2010-08-10 14:40:27 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FindUsages::visit(ArrayDeclaratorAST *ast)
|
|
|
|
|
{
|
|
|
|
|
// unsigned lbracket_token = ast->lbracket_token;
|
|
|
|
|
this->expression(ast->expression);
|
|
|
|
|
// unsigned rbracket_token = ast->rbracket_token;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-02-26 14:09:44 +01:00
|
|
|
|
|
|
|
|
void FindUsages::prepareLines(const QByteArray &bytes)
|
|
|
|
|
{
|
|
|
|
|
_sourceLineEnds.reserve(1000);
|
|
|
|
|
const char *s = bytes.constData();
|
|
|
|
|
_sourceLineEnds.push_back(s - 1); // we start counting at line 1, so line 0 is always empty.
|
|
|
|
|
|
|
|
|
|
for (; *s; ++s)
|
|
|
|
|
if (*s == '\n')
|
|
|
|
|
_sourceLineEnds.push_back(s);
|
|
|
|
|
if (s != _sourceLineEnds.back() + 1) // no newline at the end of the file
|
|
|
|
|
_sourceLineEnds.push_back(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString FindUsages::fetchLine(unsigned lineNr) const
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(lineNr < _sourceLineEnds.size());
|
|
|
|
|
if (lineNr == 0)
|
|
|
|
|
return QString();
|
|
|
|
|
|
|
|
|
|
const char *start = _sourceLineEnds.at(lineNr - 1) + 1;
|
|
|
|
|
const char *end = _sourceLineEnds.at(lineNr);
|
|
|
|
|
return QString::fromUtf8(start, end - start);
|
|
|
|
|
}
|
|
|
|
|
|