| 913 | } |
| 914 | |
| 915 | unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::string &cfgname, const CreateTokenListFn& createTokenList) |
| 916 | { |
| 917 | // TODO: move to constructor when CppCheck no longer owns the settings |
| 918 | if (mSettings.checks.isEnabled(Checks::unusedFunction) && !mUnusedFunctionsCheck) |
| 919 | mUnusedFunctionsCheck.reset(new CheckUnusedFunctions()); |
| 920 | |
| 921 | const int maxConfigs = mSettings.getMaxConfigs(); |
| 922 | |
| 923 | mLogger->resetExitCode(); |
| 924 | |
| 925 | if (Settings::terminated()) |
| 926 | return mLogger->exitcode(); |
| 927 | |
| 928 | std::unique_ptr<OneShotTimer> checkTimeTimer; |
| 929 | if (mSettings.showtime == Settings::ShowTime::FILE || mSettings.showtime == Settings::ShowTime::FILE_TOTAL || mSettings.showtime == Settings::ShowTime::TOP5_FILE) |
| 930 | checkTimeTimer.reset(new OneShotTimer("Check time: " + file.spath())); |
| 931 | |
| 932 | if (!mSettings.quiet) { |
| 933 | std::string fixedpath = Path::toNativeSeparators(file.spath()); |
| 934 | mErrorLogger.reportOut(std::string("Checking ") + fixedpath + ' ' + cfgname + std::string("..."), Color::FgGreen); |
| 935 | |
| 936 | if (mSettings.verbose) { |
| 937 | mErrorLogger.reportOut("Defines:" + mSettings.userDefines, Color::Reset); |
| 938 | std::string undefs; |
| 939 | for (const std::string& U : mSettings.userUndefs) { |
| 940 | if (!undefs.empty()) |
| 941 | undefs += ';'; |
| 942 | undefs += ' ' + U; |
| 943 | } |
| 944 | mErrorLogger.reportOut("Undefines:" + undefs, Color::Reset); |
| 945 | std::string includePaths; |
| 946 | for (const std::string &I : mSettings.includePaths) |
| 947 | includePaths += " -I" + I; |
| 948 | mErrorLogger.reportOut("Includes:" + includePaths, Color::Reset); |
| 949 | mErrorLogger.reportOut(std::string("Platform:") + mSettings.platform.toString(), Color::Reset); |
| 950 | } |
| 951 | } |
| 952 | |
| 953 | mLogger->closePlist(); |
| 954 | |
| 955 | std::unique_ptr<AnalyzerInformation> analyzerInformation; |
| 956 | |
| 957 | try { |
| 958 | if (mSettings.library.markupFile(file.spath())) { |
| 959 | // TODO: if an exception occurs in this block it will continue in an unexpected code path |
| 960 | if (!mSettings.buildDir.empty()) |
| 961 | { |
| 962 | analyzerInformation.reset(new AnalyzerInformation); |
| 963 | mLogger->setAnalyzerInfo(analyzerInformation.get()); |
| 964 | } |
| 965 | |
| 966 | if (mUnusedFunctionsCheck && (mSettings.useSingleJob() || analyzerInformation)) { |
| 967 | std::size_t hash = 0; |
| 968 | // markup files are special and do not adhere to the enforced language |
| 969 | TokenList tokenlist{mSettings, Standards::Language::C}; |
| 970 | std::vector<std::string> files; |
| 971 | simplecpp::TokenList tokens = createTokenList(files, nullptr); |
| 972 | if (analyzerInformation) { |
nothing calls this directly
no test coverage detected