parent
0070a78101
commit
b61feaf77f
|
@ -910,7 +910,7 @@ const Token * Token::findClosingBracket() const
|
|||
if (!mPrevious)
|
||||
return nullptr;
|
||||
|
||||
if (!(mPrevious->isName() ||
|
||||
if (!(mPrevious->isName() || Token::simpleMatch(mPrevious, "]") ||
|
||||
Token::Match(mPrevious->previous(), "operator %op% <") ||
|
||||
Token::Match(mPrevious->tokAt(-2), "operator [([] [)]] <")))
|
||||
return nullptr;
|
||||
|
@ -939,7 +939,7 @@ const Token * Token::findClosingBracket() const
|
|||
return nullptr;
|
||||
// we can make some guesses for template parameters
|
||||
else if (closing->str() == "<" && closing->previous() &&
|
||||
(closing->previous()->isName() || isOperator(closing->previous())) &&
|
||||
(closing->previous()->isName() || Token::simpleMatch(closing->previous(), "]") || isOperator(closing->previous())) &&
|
||||
(templateParameter ? templateParameters.find(closing->strAt(-1)) == templateParameters.end() : true))
|
||||
++depth;
|
||||
else if (closing->str() == ">") {
|
||||
|
|
|
@ -106,6 +106,7 @@ private:
|
|||
TEST_CASE(canFindMatchingBracketsWithTooManyClosing);
|
||||
TEST_CASE(canFindMatchingBracketsWithTooManyOpening);
|
||||
TEST_CASE(findClosingBracket);
|
||||
TEST_CASE(findClosingBracket2);
|
||||
|
||||
TEST_CASE(expressionString);
|
||||
|
||||
|
@ -1084,6 +1085,13 @@ private:
|
|||
ASSERT(Token::simpleMatch(t, "> struct"));
|
||||
}
|
||||
|
||||
void findClosingBracket2() const {
|
||||
givenACodeSampleToTokenize var("const auto g = []<typename T>() {};\n"); // #11275
|
||||
|
||||
const Token* const t = Token::findsimplematch(var.tokens(), "<");
|
||||
ASSERT(t && Token::simpleMatch(t->findClosingBracket(), ">"));
|
||||
}
|
||||
|
||||
void expressionString() const {
|
||||
givenACodeSampleToTokenize var1("void f() { *((unsigned long long *)x) = 0; }");
|
||||
const Token *const tok1 = Token::findsimplematch(var1.tokens(), "*");
|
||||
|
|
Loading…
Reference in New Issue