More robust Token::findClosingBracket
This commit is contained in:
parent
c846c0fbdc
commit
9aa69661b5
|
@ -861,6 +861,14 @@ const Token * Token::findClosingBracket() const
|
|||
if (mStr != "<")
|
||||
return nullptr;
|
||||
|
||||
if (!mPrevious)
|
||||
return nullptr;
|
||||
|
||||
if (!(mPrevious->isName() ||
|
||||
Token::Match(mPrevious->previous(), "operator %op% <") ||
|
||||
Token::Match(mPrevious->tokAt(-2), "operator [([] [)]] <")))
|
||||
return nullptr;
|
||||
|
||||
const Token *closing = nullptr;
|
||||
const bool templateParameter(strAt(-1) == "template");
|
||||
std::set<std::string> templateParameters;
|
||||
|
|
|
@ -5165,7 +5165,8 @@ void Tokenizer::removeExtraTemplateKeywords()
|
|||
}
|
||||
}
|
||||
|
||||
static std::string getExpression(const Token *tok) {
|
||||
static std::string getExpression(const Token *tok)
|
||||
{
|
||||
std::string line;
|
||||
for (const Token *prev = tok->previous(); prev && !Token::Match(prev, "[;{}]"); prev = prev->previous())
|
||||
line = prev->str() + " " + line;
|
||||
|
|
|
@ -4798,7 +4798,7 @@ private:
|
|||
std::istringstream istr(code);
|
||||
tokenizer.createTokens(istr, "test.cpp");
|
||||
tokenizer.createLinks();
|
||||
tokenizer.splitTemplateRightAngleBrackets(false);
|
||||
tokenizer.splitTemplateRightAngleBrackets(false);
|
||||
|
||||
const Token *_tok = tokenizer.tokens();
|
||||
for (unsigned i = 0 ; i < offset ; ++i)
|
||||
|
|
Loading…
Reference in New Issue