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

Method compareVaridsForVariable_

test/testvarid.cpp:319–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317#define compareVaridsForVariable(...) compareVaridsForVariable_(__FILE__, __LINE__, __VA_ARGS__)
318 template<size_t size>
319 std::string compareVaridsForVariable_(const char* file, int line, const char (&code)[size], const char varname[]) {
320 SimpleTokenizer tokenizer(settings, *this);
321 ASSERT_LOC((tokenizer.tokenize)(code), file, line);
322
323 unsigned int varid = ~0U;
324 for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next()) {
325 if (tok->str() == varname) {
326 if (varid == ~0U)
327 varid = tok->varId();
328 else if (varid != tok->varId())
329 return std::string("Variable ") + varname + " has different varids:\n" + tokenizer.tokens()->stringifyList(true,true,true,true,false);
330 }
331 }
332
333 return "same varid";
334 }
335
336 void varid1() {
337 {

Callers

nothing calls this directly

Calls 3

nextMethod · 0.80
stringifyListMethod · 0.80
strMethod · 0.45

Tested by

no test coverage detected