| 1891 | } |
| 1892 | |
| 1893 | static const Token* getEndOfVarScope(const Variable* var) |
| 1894 | { |
| 1895 | if (!var) |
| 1896 | return nullptr; |
| 1897 | const Scope* innerScope = var->scope(); |
| 1898 | const Scope* outerScope = innerScope; |
| 1899 | if (var->typeStartToken() && var->typeStartToken()->scope()) |
| 1900 | outerScope = var->typeStartToken()->scope(); |
| 1901 | if (!innerScope && outerScope) |
| 1902 | innerScope = outerScope; |
| 1903 | if (!innerScope || !outerScope) |
| 1904 | return nullptr; |
| 1905 | if (!innerScope->isExecutable()) |
| 1906 | return nullptr; |
| 1907 | // If the variable is defined in a for/while initializer then we want to |
| 1908 | // pick one token after the end so forward analysis can analyze the exit |
| 1909 | // conditions |
| 1910 | if (innerScope != outerScope && outerScope->isExecutable() && innerScope->isLoopScope() && |
| 1911 | !isRangeForScope(innerScope)) |
| 1912 | return innerScope->bodyEnd->next(); |
| 1913 | return innerScope->bodyEnd; |
| 1914 | } |
| 1915 | |
| 1916 | const Token* ValueFlow::getEndOfExprScope(const Token* tok, const Scope* defaultScope, bool smallest) |
| 1917 | { |
no test coverage detected