Simplify template keyword bracket (#3399)
This commit is contained in:
parent
5313a40c3b
commit
818fd248e1
10
lib/token.h
10
lib/token.h
|
@ -641,6 +641,13 @@ public:
|
||||||
setFlag(fIsInline, b);
|
setFlag(fIsInline, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isTemplate() const {
|
||||||
|
return getFlag(fIsTemplate);
|
||||||
|
}
|
||||||
|
void isTemplate(bool b) {
|
||||||
|
setFlag(fIsTemplate, b);
|
||||||
|
}
|
||||||
|
|
||||||
bool isBitfield() const {
|
bool isBitfield() const {
|
||||||
return mImpl->mBits > 0;
|
return mImpl->mBits > 0;
|
||||||
}
|
}
|
||||||
|
@ -1239,7 +1246,8 @@ private:
|
||||||
fIsSplitVarDeclComma = (1 << 29), // set to true when variable declarations are split up ('int a,b;' => 'int a; int b;')
|
fIsSplitVarDeclComma = (1 << 29), // set to true when variable declarations are split up ('int a,b;' => 'int a; int b;')
|
||||||
fIsSplitVarDeclEq = (1 << 30), // set to true when variable declaration with initialization is split up ('int a=5;' => 'int a; a=5;')
|
fIsSplitVarDeclEq = (1 << 30), // set to true when variable declaration with initialization is split up ('int a=5;' => 'int a; a=5;')
|
||||||
fIsImplicitInt = (1U << 31), // Is "int" token implicitly added?
|
fIsImplicitInt = (1U << 31), // Is "int" token implicitly added?
|
||||||
fIsInline = (1ULL << 32) // Is this a inline type
|
fIsInline = (1ULL << 32), // Is this a inline type
|
||||||
|
fIsTemplate = (1ULL << 33)
|
||||||
};
|
};
|
||||||
|
|
||||||
Token::Type mTokType;
|
Token::Type mTokType;
|
||||||
|
|
|
@ -4509,7 +4509,8 @@ void Tokenizer::createLinks2()
|
||||||
type.pop();
|
type.pop();
|
||||||
}
|
}
|
||||||
} else if (token->str() == "<" &&
|
} else if (token->str() == "<" &&
|
||||||
((token->previous() && token->previous()->isName() && !token->previous()->varId()) ||
|
((token->previous() && (token->previous()->isTemplate() ||
|
||||||
|
(token->previous()->isName() && !token->previous()->varId()))) ||
|
||||||
Token::Match(token->next(), ">|>>"))) {
|
Token::Match(token->next(), ">|>>"))) {
|
||||||
type.push(token);
|
type.push(token);
|
||||||
if (!templateToken && (token->previous()->str() == "template"))
|
if (!templateToken && (token->previous()->str() == "template"))
|
||||||
|
@ -5634,8 +5635,19 @@ void Tokenizer::removeExtraTemplateKeywords()
|
||||||
{
|
{
|
||||||
if (isCPP()) {
|
if (isCPP()) {
|
||||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||||
if (Token::Match(tok, "%name%|> .|:: template %name%"))
|
if (Token::Match(tok, "%name%|>|) .|:: template %name%")) {
|
||||||
tok->next()->deleteNext();
|
tok->next()->deleteNext();
|
||||||
|
Token* templateName = tok->tokAt(2);
|
||||||
|
while (Token::Match(templateName, "%name%|::")) {
|
||||||
|
templateName->isTemplate(true);
|
||||||
|
templateName = templateName->next();
|
||||||
|
}
|
||||||
|
if (Token::Match(templateName->previous(), "operator %op%|(")) {
|
||||||
|
templateName->isTemplate(true);
|
||||||
|
if (templateName->str() == "(" && templateName->link())
|
||||||
|
templateName->link()->isTemplate(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6632,6 +6632,12 @@ private:
|
||||||
" for (size_t e = 0; e < d; e++)\n"
|
" for (size_t e = 0; e < d; e++)\n"
|
||||||
" ;\n"
|
" ;\n"
|
||||||
"}\n"));
|
"}\n"));
|
||||||
|
|
||||||
|
ASSERT_NO_THROW(tokenizeAndStringify(
|
||||||
|
"template <std::size_t First, std::size_t... Indices, typename Functor>\n"
|
||||||
|
"constexpr void constexpr_for_fold_impl([[maybe_unused]] Functor&& f, std::index_sequence<Indices...>) noexcept {\n"
|
||||||
|
" (std::forward<Functor>(f).template operator() < First + Indices > (), ...);\n"
|
||||||
|
"}\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkNamespaces() {
|
void checkNamespaces() {
|
||||||
|
|
Loading…
Reference in New Issue