Remove __asm..
| 10068 | |
| 10069 | // Remove __asm.. |
| 10070 | void Tokenizer::simplifyAsm() |
| 10071 | { |
| 10072 | std::string instruction; |
| 10073 | for (Token *tok = list.front(); tok; tok = tok->next()) { |
| 10074 | if (Token::Match(tok, "__asm|_asm|asm {") && |
| 10075 | tok->linkAt(1)->next()) { |
| 10076 | instruction = tok->tokAt(2)->stringifyList(tok->linkAt(1)); |
| 10077 | Token::eraseTokens(tok, tok->linkAt(1)->next()); |
| 10078 | } |
| 10079 | |
| 10080 | else if (Token::Match(tok, "asm|__asm|__asm__ volatile|__volatile|__volatile__|goto|inline| (")) { |
| 10081 | // Goto "(" |
| 10082 | Token *partok = tok->next(); |
| 10083 | if (partok->str() != "(") |
| 10084 | partok = partok->next(); |
| 10085 | instruction = partok->next()->stringifyList(partok->link()); |
| 10086 | Token::eraseTokens(tok, partok->link()->next()); |
| 10087 | } |
| 10088 | |
| 10089 | else if (Token::Match(tok, "_asm|__asm")) { |
| 10090 | Token *endasm = tok->next(); |
| 10091 | const Token *firstSemiColon = nullptr; |
| 10092 | int comment = 0; |
| 10093 | while (Token::Match(endasm, "%num%|%name%|,|:|;|*|(") || (endasm && (endasm->isLiteral() || endasm->linenr() == comment))) { |
| 10094 | if (Token::Match(endasm, "_asm|__asm|__endasm")) |
| 10095 | break; |
| 10096 | if (endasm->str() == ";") { |
| 10097 | comment = endasm->linenr(); |
| 10098 | if (!firstSemiColon) |
| 10099 | firstSemiColon = endasm; |
| 10100 | } |
| 10101 | if (endasm->str() == "(") { |
| 10102 | if (!firstSemiColon) |
| 10103 | endasm = endasm->link(); |
| 10104 | break; |
| 10105 | } |
| 10106 | endasm = endasm->next(); |
| 10107 | } |
| 10108 | if (Token::simpleMatch(endasm, "__endasm")) { |
| 10109 | instruction = tok->next()->stringifyList(endasm); |
| 10110 | Token::eraseTokens(tok, endasm->next()); |
| 10111 | if (!Token::simpleMatch(tok->next(), ";")) |
| 10112 | tok->insertToken(";"); |
| 10113 | } else if (firstSemiColon) { |
| 10114 | instruction = tok->next()->stringifyList(firstSemiColon); |
| 10115 | Token::eraseTokens(tok, firstSemiColon); |
| 10116 | } else if (Token::Match(endasm, ") { !!}")) { |
| 10117 | tok->deleteThis(); |
| 10118 | tok = endasm->tokAt(2); |
| 10119 | endasm = endasm->linkAt(1); |
| 10120 | instruction = tok->stringifyList(endasm); |
| 10121 | Token::eraseTokens(tok, endasm); |
| 10122 | } else if (!endasm) { |
| 10123 | if (!tok->next()) |
| 10124 | syntaxError(tok); |
| 10125 | instruction = tok->next()->stringifyList(endasm); |
| 10126 | Token::eraseTokens(tok, endasm); |
| 10127 | tok->insertToken(";"); |
nothing calls this directly
no test coverage detected