MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / isConstPointerVariable

Function isConstPointerVariable

lib/checkother.cpp:1826–1842  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1824}
1825
1826static bool isConstPointerVariable(const Variable* p, const Settings& settings)
1827{
1828 const int indirect = p->isArray() ? p->dimensions().size() : 1;
1829 const Token* start = getVariableChangedStart(p);
1830 while (const Token* tok =
1831 findVariableChanged(start, p->scope()->bodyEnd, indirect, p->declarationId(), false, settings)) {
1832 if (p->isReference())
1833 return false;
1834 // Assigning a pointer through another pointer may still be const
1835 if (!Token::simpleMatch(tok->astParent(), "="))
1836 return false;
1837 if (!astIsLHS(tok))
1838 return false;
1839 start = tok->next();
1840 }
1841 return true;
1842}
1843
1844namespace {
1845 struct CompareVariables {

Callers 1

checkConstPointerMethod · 0.85

Calls 9

getVariableChangedStartFunction · 0.85
findVariableChangedFunction · 0.85
astIsLHSFunction · 0.85
isArrayMethod · 0.80
scopeMethod · 0.80
astParentMethod · 0.80
nextMethod · 0.80
simpleMatchFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected