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

Method getConfigsStr

test/testpreprocessor.cpp:384–404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

382
383 template<size_t size>
384 std::string getConfigsStr(const char (&code)[size], const char *arg = nullptr, const char *library = nullptr) {
385 Settings settings;
386 if (arg && std::strncmp(arg,"-D",2)==0)
387 settings.userDefines = arg + 2;
388 if (arg && std::strncmp(arg,"-U",2)==0)
389 settings.userUndefs.insert(arg+2);
390 if (library)
391 ASSERT(settings.library.load("", library, false).errorcode == Library::ErrorCode::OK);
392 std::vector<std::string> files;
393 simplecpp::OutputList outputList;
394 simplecpp::TokenList tokens(code,files,"test.c",&outputList);
395 Preprocessor preprocessor(tokens, settings, *this, Standards::Language::C); // TODO: do we need to consider #file?
396 ASSERT(preprocessor.loadFiles(files));
397 ASSERT(!preprocessor.reportOutput(outputList, true));
398 preprocessor.removeComments();
399 const std::set<std::string> configs = preprocessor.getConfigs();
400 std::string ret;
401 for (const std::string & config : configs)
402 ret += config + '\n';
403 return ret;
404 }
405
406 template<size_t size>
407 std::size_t getHash(const char (&code)[size]) {

Callers

nothing calls this directly

Calls 5

loadFilesMethod · 0.80
reportOutputMethod · 0.80
getConfigsMethod · 0.80
loadMethod · 0.45
removeCommentsMethod · 0.45

Tested by

no test coverage detected