GCC does not inline this by itself need to use the old syntax since the C++11 [[xxx:always_inline]] cannot be used here
| 411 | // GCC does not inline this by itself |
| 412 | // need to use the old syntax since the C++11 [[xxx:always_inline]] cannot be used here |
| 413 | inline __attribute__((always_inline)) |
| 414 | #endif |
| 415 | int multiComparePercent(const Token *tok, const char*& haystack, nonneg int varid) |
| 416 | { |
| 417 | ++haystack; |
| 418 | // Compare only the first character of the string for optimization reasons |
| 419 | switch (haystack[0]) { |
| 420 | case 'v': |
| 421 | if (haystack[3] == '%') { // %var% |
| 422 | haystack += 4; |
| 423 | if (tok->varId() != 0) |
| 424 | return 1; |
| 425 | } else { // %varid% |
| 426 | if (varid == 0) { |
| 427 | throw InternalError(tok, "Internal error. Token::Match called with varid 0."); |
| 428 | } |
| 429 | |
| 430 | haystack += 6; |
| 431 | |
| 432 | if (tok->varId() == varid) |
| 433 | return 1; |
| 434 | } |
| 435 | break; |
| 436 | case 't': |
| 437 | // Type (%type%) |
| 438 | { |
| 439 | haystack += 5; |
| 440 | if (tok->isName() && tok->varId() == 0) |
| 441 | return 1; |
| 442 | } |
| 443 | break; |
| 444 | case 'a': |
| 445 | // Accept any token (%any%) or assign (%assign%) |
| 446 | { |
| 447 | if (haystack[3] == '%') { // %any% |
| 448 | haystack += 4; |
| 449 | return 1; |
| 450 | } |
| 451 | // %assign% |
| 452 | haystack += 7; |
| 453 | if (tok->isAssignmentOp()) |
| 454 | return 1; |
| 455 | } |
| 456 | break; |
| 457 | case 'n': |
| 458 | // Number (%num%) or name (%name%) |
| 459 | { |
| 460 | if (haystack[4] == '%') { // %name% |
| 461 | haystack += 5; |
| 462 | if (tok->isName()) |
| 463 | return 1; |
| 464 | } else { |
| 465 | haystack += 4; |
| 466 | if (tok->isNumber()) |
| 467 | return 1; |
| 468 | } |
| 469 | } |
| 470 | break; |
no test coverage detected