Skip to content

Commit 35e830a

Browse files
author
Your Name
committed
Fix selfcheck
1 parent 9b554ac commit 35e830a

3 files changed

Lines changed: 14 additions & 13 deletions

File tree

.selfcheck_suppressions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ autoNoType:gui/*.cpp
5858
autoNoType:test/*.cpp
5959
autoNoType:tools/triage/mainwindow.cpp
6060
# ticket 11631
61-
templateInstantiation:test/testutils.cpp
61+
templateInstantiation
6262

6363
naming-varname:externals/simplecpp/simplecpp.h
6464
naming-privateMemberVariable:externals/simplecpp/simplecpp.h

lib/templatesimplifier.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@ static ParsedType parseVariableDeclaration(const Token* nameTok)
11871187
if (nameTok->strAt(1) == "[") {
11881188
if (parsed.isReference)
11891189
return ParsedType();
1190-
const Token* rbracket = nameTok->next()->link();
1190+
const Token* rbracket = nameTok->linkAt(1);
11911191
if (!rbracket || Token::simpleMatch(rbracket->next(), "["))
11921192
return ParsedType();
11931193
if (!decayArrayToPointer(parsed.type))
@@ -1453,8 +1453,8 @@ namespace {
14531453
// constructor initializer list
14541454
if (Token::simpleMatch(tok, ":")) {
14551455
tok = tok->next();
1456-
while (Token::Match(tok, "%name% (|{") && tok->next()->link()) {
1457-
tok = tok->next()->link()->next();
1456+
while (Token::Match(tok, "%name% (|{") && tok->linkAt(1)) {
1457+
tok = tok->linkAt(1)->next();
14581458
if (!Token::simpleMatch(tok, ","))
14591459
break;
14601460
tok = tok->next();
@@ -1550,16 +1550,16 @@ static ExprType parseOperandType(const DeductionContext& ctx, const Token*& tok,
15501550
const ParsedType castType = parseType(tok->tokAt(2), closing);
15511551
if (castType.after != closing || !castType.type.valid)
15521552
return ExprType();
1553-
if (!Token::simpleMatch(closing->next(), "(") || !closing->next()->link())
1553+
if (!Token::simpleMatch(closing->next(), "(") || !closing->linkAt(1))
15541554
return ExprType();
1555-
tok = closing->next()->link()->next();
1555+
tok = closing->linkAt(1)->next();
15561556
type = castType.type;
15571557
if (stopsAtPostfix(tok, end))
15581558
return ExprType();
15591559
} else if (tok->str() == "sizeof") {
1560-
if (!Token::simpleMatch(tok->next(), "(") || !tok->next()->link())
1560+
if (!Token::simpleMatch(tok->next(), "(") || !tok->linkAt(1))
15611561
return ExprType();
1562-
tok = tok->next()->link()->next();
1562+
tok = tok->linkAt(1)->next();
15631563
// sizeof yields std::size_t
15641564
const std::size_t size = ctx.settings->platform.sizeof_size_t;
15651565
if (size == 0)
@@ -1586,9 +1586,9 @@ static ExprType parseOperandType(const DeductionContext& ctx, const Token*& tok,
15861586
const ParsedType castType = parseType(tok, tok->next(), true);
15871587
if (castType.after != tok->next() || !castType.type.valid)
15881588
return ExprType();
1589-
if (!tok->next()->link())
1589+
if (!tok->linkAt(1))
15901590
return ExprType();
1591-
tok = tok->next()->link()->next();
1591+
tok = tok->linkAt(1)->next();
15921592
type = castType.type;
15931593
if (stopsAtPostfix(tok, end))
15941594
return ExprType();
@@ -1601,9 +1601,9 @@ static ExprType parseOperandType(const DeductionContext& ctx, const Token*& tok,
16011601
const ParsedType returnType = ctx.symbols->lookupFunctionReturnType(tok->str());
16021602
if (!returnType.type.valid)
16031603
return ExprType();
1604-
if (!tok->next()->link())
1604+
if (!tok->linkAt(1))
16051605
return ExprType();
1606-
tok = tok->next()->link()->next();
1606+
tok = tok->linkAt(1)->next();
16071607
type = returnType.type;
16081608
if (stopsAtPostfix(tok, end))
16091609
return ExprType();
@@ -2011,7 +2011,7 @@ static void recordDeclaration(DeductionSymbolTable& symbols, const Token* tok)
20112011
const ParsedType variable = parseVariableDeclaration(tok);
20122012
if (variable.type.valid) {
20132013
symbols.addVariable(tok->str(), variable);
2014-
} else if (Token::simpleMatch(tok->next(), "(") && tok->next()->link() && !Token::simpleMatch(tok->previous(), "::")) {
2014+
} else if (Token::simpleMatch(tok->next(), "(") && tok->linkAt(1) && !Token::simpleMatch(tok->previous(), "::")) {
20152015
// function declaration; a qualified name ("void A::g()") is not
20162016
// visible under its plain name
20172017
if (TokenList::isFunctionHead(tok->next(), ";{")) {

lib/utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ namespace utils {
437437
* @param t The function forms the lvalue reference to const type of this argument.
438438
*/
439439
template<class T>
440+
// cppcheck-suppress constParameterReference
440441
constexpr typename std::add_const<T>::type & as_const(T& t) noexcept
441442
{
442443
static_assert(!std::is_const<T>::value, "object is already const");

0 commit comments

Comments
 (0)