Tokenizer: set links for <> in 'a=new b<c>;' code
This commit is contained in:
parent
f2661dae4c
commit
41e4194573
|
@ -3197,7 +3197,7 @@ void Tokenizer::createLinks2()
|
|||
else if (token->str() == ">" || token->str() == ">>") {
|
||||
if (type.empty() || type.top()->str() != "<") // < and > don't match.
|
||||
continue;
|
||||
if (token->next() && !Token::Match(token->next(), "%var%|>|&|*|::|,|(|)|{"))
|
||||
if (token->next() && !Token::Match(token->next(), "%var%|>|&|*|::|,|(|)|{|;"))
|
||||
continue;
|
||||
|
||||
// Check type of open link
|
||||
|
@ -3205,6 +3205,15 @@ void Tokenizer::createLinks2()
|
|||
continue;
|
||||
}
|
||||
|
||||
// if > is followed by ; .. "new a<b>;" is expected
|
||||
if (Token::Match(token->next(), ";")) {
|
||||
Token *prev = type.top()->previous();
|
||||
while (prev && Token::Match(prev->previous(), ":: %var%"))
|
||||
prev = prev->tokAt(-2);
|
||||
if (!prev || !prev->previous() || prev->previous()->str() != "new")
|
||||
continue;
|
||||
}
|
||||
|
||||
Token* top = type.top();
|
||||
type.pop();
|
||||
if (token->str() == ">>" && type.top()->str() != "<") {
|
||||
|
|
|
@ -2878,6 +2878,13 @@ private:
|
|||
ASSERT_EQUALS("void f ( ) { int a ; a = b < T < char , 3 > , int > ( ) ; }", tok(code));
|
||||
}
|
||||
|
||||
{
|
||||
const char code[] = "void f() {\n"
|
||||
" a = new std::map<std::string, std::string>;\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS("void f ( ) { a = new std :: map < std :: string , std :: string > ; }", tok(code));
|
||||
}
|
||||
|
||||
{
|
||||
// ticket #1327
|
||||
const char code[] = "const C<1,2,3> foo ()\n"
|
||||
|
|
Loading…
Reference in New Issue