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

Method addtoken

lib/tokenlist.cpp:131–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129//---------------------------------------------------------------------------
130
131void TokenList::addtoken(const std::string& str, const nonneg int lineno, const nonneg int column, const nonneg int fileno, bool split)
132{
133 if (str.empty())
134 return;
135
136 // If token contains # characters, split it up
137 if (split) {
138 size_t begin = 0;
139 size_t end = 0;
140 while ((end = str.find("##", begin)) != std::string::npos) {
141 addtoken(str.substr(begin, end - begin), lineno, fileno, false);
142 addtoken("##", lineno, column, fileno, false);
143 begin = end+2;
144 }
145 if (begin != 0) {
146 addtoken(str.substr(begin), lineno, column, fileno, false);
147 return;
148 }
149 }
150
151 if (mTokensFrontBack->back) {
152 mTokensFrontBack->back->insertToken(str);
153 } else {
154 mTokensFrontBack->front = new Token(*this, mTokensFrontBack);
155 mTokensFrontBack->back = mTokensFrontBack->front;
156 mTokensFrontBack->back->str(str);
157 }
158
159 mTokensFrontBack->back->linenr(lineno);
160 mTokensFrontBack->back->column(column);
161 mTokensFrontBack->back->fileIndex(fileno);
162}
163
164void TokenList::addtoken(const std::string& str, const Token *locationTok)
165{

Callers 6

parsedeclFunction · 0.45
addNamespaceMethod · 0.45
expandTemplateMethod · 0.45
testaddtoken1Method · 0.45
testaddtoken2Method · 0.45

Calls 6

insertTokenMethod · 0.80
columnMethod · 0.80
fileIndexMethod · 0.80
emptyMethod · 0.45
findMethod · 0.45
strMethod · 0.45

Tested by 2

testaddtoken1Method · 0.36
testaddtoken2Method · 0.36