diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 557555f97..6efc95f65 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -284,13 +284,11 @@ unsigned int CppCheck::processFile(const std::string& filename, const std::strin cfg = _settings.userDefines + cfg; } - std::string codeWithoutCfg; - { - Timer t("Preprocessor::getcode", _settings.showtime, &S_timerResults); - codeWithoutCfg = preprocessor.getcode(tokens1, cfg, files, true); - } - if (_settings.preprocessOnly) { + Timer t("Preprocessor::getcode", _settings.showtime, &S_timerResults); + std::string codeWithoutCfg = preprocessor.getcode(tokens1, cfg, files, true); + t.Stop(); + if (codeWithoutCfg.compare(0,5,"#file") == 0) codeWithoutCfg.insert(0U, "//"); std::string::size_type pos = 0; @@ -314,11 +312,11 @@ unsigned int CppCheck::processFile(const std::string& filename, const std::strin bool result; // Create tokens, skip rest of iteration if failed - std::istringstream istr(codeWithoutCfg); Timer timer("Tokenizer::createTokens", _settings.showtime, &S_timerResults); - result = _tokenizer.createTokens(istr, filename); + const simplecpp::TokenList &tokensP = preprocessor.preprocess(tokens1, cfg, files); + _tokenizer.createTokens(&tokensP); timer.Stop(); - if (!result) + if (tokensP.empty()) continue; // skip rest of iteration if just checking configuration