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

Method load

externals/simplecpp/simplecpp.cpp:3205–3286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3203}
3204
3205simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens, std::vector<std::string> &filenames, const simplecpp::DUI &dui, simplecpp::OutputList *outputList, FileDataCache cache)
3206{
3207#ifdef SIMPLECPP_WINDOWS
3208 if (dui.clearIncludeCache)
3209 nonExistingFilesCache.clear();
3210#endif
3211
3212 std::list<const Token *> filelist;
3213
3214 // -include files
3215 for (auto it = dui.includes.cbegin(); it != dui.includes.cend(); ++it) {
3216 const std::string &filename = *it;
3217
3218 const auto loadResult = cache.get("", filename, dui, false, filenames, outputList);
3219 const bool loaded = loadResult.second;
3220 FileData *const filedata = loadResult.first;
3221
3222 if (filedata == nullptr) {
3223 if (outputList) {
3224 simplecpp::Output err{
3225 simplecpp::Output::EXPLICIT_INCLUDE_NOT_FOUND,
3226 {},
3227 "Can not open include file '" + filename + "' that is explicitly included."
3228 };
3229 outputList->emplace_back(std::move(err));
3230 }
3231 continue;
3232 }
3233
3234 if (!loaded)
3235 continue;
3236
3237 if (!filedata->tokens.front())
3238 continue;
3239
3240 if (dui.removeComments)
3241 filedata->tokens.removeComments();
3242
3243 filelist.emplace_back(filedata->tokens.front());
3244 }
3245
3246 for (const Token *rawtok = rawtokens.cfront(); rawtok || !filelist.empty(); rawtok = rawtok ? rawtok->next : nullptr) {
3247 if (rawtok == nullptr) {
3248 rawtok = filelist.back();
3249 filelist.pop_back();
3250 }
3251
3252 if (rawtok->op != '#' || sameline(rawtok->previousSkipComments(), rawtok))
3253 continue;
3254
3255 rawtok = rawtok->nextSkipComments();
3256 if (!rawtok || rawtok->str() != INCLUDE)
3257 continue;
3258
3259 const std::string &sourcefile = rawtokens.file(rawtok->location);
3260
3261 const Token * const htok = rawtok->nextSkipComments();
3262 if (!sameline(rawtok, htok))

Callers

nothing calls this directly

Calls 8

frontMethod · 0.80
samelineFunction · 0.70
clearMethod · 0.45
getMethod · 0.45
removeCommentsMethod · 0.45
emptyMethod · 0.45
strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected