diff --git a/cli/cppcheckexecutorsig.cpp b/cli/cppcheckexecutorsig.cpp index 102aae1d4..40a5b988e 100644 --- a/cli/cppcheckexecutorsig.cpp +++ b/cli/cppcheckexecutorsig.cpp @@ -120,7 +120,6 @@ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context) const Signalmap_t::const_iterator it=listofsignals.find(signo); const char * const signame = (it==listofsignals.end()) ? "unknown" : it->second.c_str(); - bool printCallstack=true; // try to print a callstack? bool lowMem=false; // was low-memory condition detected? Be careful then! Avoid allocating much more memory then. bool unexpectedSignal=true; // unexpected indicates program failure bool terminate=true; // exit process/thread @@ -241,7 +240,6 @@ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context) unexpectedSignal=false; // legal usage: interrupt application via CTRL-C fputs("cppcheck received signal ", output); fputs(signame, output); - printCallstack=true; fputs(".\n", output); break; case SIGSEGV: @@ -277,11 +275,9 @@ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context) fputs(".\n", output); break; } - if (printCallstack) { #ifdef USE_UNIX_BACKTRACE_SUPPORT - print_stacktrace(output, true, -1, lowMem); + print_stacktrace(output, true, -1, lowMem); #endif - } if (unexpectedSignal) { fputs("\nPlease report this to the cppcheck developers!\n", output); } diff --git a/cli/processexecutor.cpp b/cli/processexecutor.cpp index 1e3e87229..01b2a6614 100644 --- a/cli/processexecutor.cpp +++ b/cli/processexecutor.cpp @@ -71,7 +71,7 @@ ProcessExecutor::~ProcessExecutor() class PipeWriter : public ErrorLogger { public: - enum PipeSignal {REPORT_OUT='1',REPORT_ERROR='2', REPORT_VERIFICATION='4', CHILD_END='5'}; + enum PipeSignal {REPORT_OUT='1',REPORT_ERROR='2', CHILD_END='5'}; explicit PipeWriter(int pipe) : mWpipe(pipe) {} diff --git a/gui/common.h b/gui/common.h index 1d10117cf..e98d260e9 100644 --- a/gui/common.h +++ b/gui/common.h @@ -36,8 +36,6 @@ #define SETTINGS_WINDOW_MAXIMIZED "Window maximized" #define SETTINGS_WINDOW_WIDTH "Window width" #define SETTINGS_WINDOW_HEIGHT "Window height" -#define SETTINGS_LOG_VIEW_WIDTH "Log/View width" -#define SETTINGS_LOG_VIEW_HEIGHT "Log/View height" #define SETTINGS_MAINWND_SPLITTER_STATE "Mainwindow/Vertical splitter state" #define SETTINGS_CHECK_DIALOG_WIDTH "Check dialog width" #define SETTINGS_CHECK_DIALOG_HEIGHT "Check dialog height" @@ -101,7 +99,6 @@ #define SETTINGS_LAST_PROJECT_PATH "Last project path" #define SETTINGS_LAST_RESULT_PATH "Last result path" #define SETTINGS_LAST_SOURCE_PATH "Last source path" -#define SETTINGS_LAST_INCLUDE_PATH "Last include path" #define SETTINGS_LAST_APP_PATH "Last application path" #define SETTINGS_LAST_ANALYZE_FILES_FILTER "Last analyze files filter" diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 938abee31..7d73e0b3b 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -92,7 +92,6 @@ #include #include -static const QString OnlineHelpURL("https://cppcheck.sourceforge.io/manual.html"); static const QString compile_commands_json("compile_commands.json"); static QString fromNativePath(const QString& p) { diff --git a/gui/projectfile.h b/gui/projectfile.h index 1f53cd593..7926faf2b 100644 --- a/gui/projectfile.h +++ b/gui/projectfile.h @@ -402,9 +402,11 @@ public: QStringList getCheckUnknownFunctionReturn() const { return mCheckUnknownFunctionReturn; } - void setCheckUnknownFunctionReturn(const QStringList &s) { + /* + void setCheckUnknownFunctionReturn(const QStringList &s) { mCheckUnknownFunctionReturn = s; - } + } + */ /** Use Clang parser */ bool clangParser; diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp index 0fd18e512..47e6c3965 100644 --- a/gui/projectfiledialog.cpp +++ b/gui/projectfiledialog.cpp @@ -347,6 +347,7 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile) mUI->mComboBoxPlatform->setCurrentText(projectFile->getPlatform()); setSuppressions(projectFile->getSuppressions()); + // TODO // Human knowledge.. /* mUI->mListUnknownFunctionReturn->clear(); diff --git a/gui/resultstree.h b/gui/resultstree.h index 5af272ede..1e67dca97 100644 --- a/gui/resultstree.h +++ b/gui/resultstree.h @@ -346,14 +346,6 @@ protected: */ void startApplication(QStandardItem *target, int application = -1); - /** - * @brief Helper function to copy filename/full path to the clipboard - * - * @param target Error tree item to open - * @param fullPath Are we copying full path or only filename? - */ - void copyPathToClipboard(QStandardItem *target, bool fullPath); - /** * @brief Helper function returning the filename/full path of the error tree item \a target. * diff --git a/gui/translationhandler.cpp b/gui/translationhandler.cpp index 375cf5e9f..eaa04cb3a 100644 --- a/gui/translationhandler.cpp +++ b/gui/translationhandler.cpp @@ -90,7 +90,7 @@ bool TranslationHandler::setLanguage(const QString &code) failure = true; } else { // Make sure there is a translator - if (!mTranslator && !failure) + if (!mTranslator) mTranslator = new QTranslator(this); //Load the new language @@ -108,18 +108,19 @@ bool TranslationHandler::setLanguage(const QString &code) else translationFile = appPath + "/" + mTranslations[index].mFilename + ".qm"; - if (!mTranslator->load(translationFile) && !failure) { + if (!mTranslator->load(translationFile)) { + failure = true; //If it failed, lets check if the default file exists if (!QFile::exists(translationFile)) { error = QObject::tr("Language file %1 not found!"); error = error.arg(translationFile); - failure = true; } - - //If file exists, there's something wrong with it - error = QObject::tr("Failed to load translation for language %1 from file %2"); - error = error.arg(mTranslations[index].mName); - error = error.arg(translationFile); + else { + //If file exists, there's something wrong with it + error = QObject::tr("Failed to load translation for language %1 from file %2"); + error = error.arg(mTranslations[index].mName); + error = error.arg(translationFile); + } } } diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 188cab433..80bac3689 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -64,7 +64,6 @@ static const struct CWE CWE571(571U); // Expression is Always True static const struct CWE CWE672(672U); // Operation on a Resource after Expiration or Release static const struct CWE CWE628(628U); // Function Call with Incorrectly Specified Arguments static const struct CWE CWE683(683U); // Function Call With Incorrect Order of Arguments -static const struct CWE CWE686(686U); // Function Call With Incorrect Argument Type static const struct CWE CWE704(704U); // Incorrect Type Conversion or Cast static const struct CWE CWE758(758U); // Reliance on Undefined, Unspecified, or Implementation-Defined Behavior static const struct CWE CWE768(768U); // Incorrect Short Circuit Evaluation diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 481364053..30cf435e2 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -451,11 +451,6 @@ static std::string getContainerName(const Token *containerToken) return ret; } -enum OperandPosition { - Left, - Right -}; - static bool isVector(const Token* tok) { if (!tok) diff --git a/lib/checkuninitvar.h b/lib/checkuninitvar.h index c592d3fca..7eb5e554f 100644 --- a/lib/checkuninitvar.h +++ b/lib/checkuninitvar.h @@ -133,7 +133,6 @@ public: private: std::set mUninitDiags; Check::FileInfo* getFileInfo() const; - bool isUnsafeFunction(const Scope* scope, int argnr, const Token** tok) const; void getErrorMessages(ErrorLogger* errorLogger, const Settings* settings) const override { diff --git a/lib/color.h b/lib/color.h index 871272a62..97115ca62 100644 --- a/lib/color.h +++ b/lib/color.h @@ -32,11 +32,7 @@ enum class Color { FgGreen = 32, FgBlue = 34, FgMagenta = 35, - FgDefault = 39, - BgRed = 41, - BgGreen = 42, - BgBlue = 44, - BgDefault = 49 + FgDefault = 39 }; CPPCHECKLIB std::ostream& operator<<(std::ostream& os, const Color& c); diff --git a/lib/cppcheck.h b/lib/cppcheck.h index 46ab23ae0..b737118e1 100644 --- a/lib/cppcheck.h +++ b/lib/cppcheck.h @@ -121,10 +121,6 @@ public: void tooManyConfigsError(const std::string &file, const int numberOfConfigurations); void purgedConfigurationMessage(const std::string &file, const std::string& configuration); - void dontSimplify() { - mSimplify = false; - } - /** Analyse whole program, run this after all TUs has been scanned. * This is deprecated and the plan is to remove this when * .analyzeinfo is good enough. diff --git a/lib/forwardanalyzer.cpp b/lib/forwardanalyzer.cpp index 325a36d21..73e98f015 100644 --- a/lib/forwardanalyzer.cpp +++ b/lib/forwardanalyzer.cpp @@ -49,7 +49,7 @@ struct OnExit { struct ForwardTraversal { enum class Progress { Continue, Break, Skip }; - enum class Terminate { None, Bail, Escape, Modified, Inconclusive, Conditional }; + enum class Terminate { None, Bail, Inconclusive }; ForwardTraversal(const ValuePtr& analyzer, const Settings& settings) : analyzer(analyzer), settings(settings), actions(Analyzer::Action::None), analyzeOnly(false), analyzeTerminate(false) {} @@ -333,8 +333,6 @@ struct ForwardTraversal { enum class Status { None, - Escaped, - Modified, Inconclusive, }; diff --git a/lib/library.h b/lib/library.h index 325077876..5fac8a733 100644 --- a/lib/library.h +++ b/lib/library.h @@ -254,7 +254,7 @@ public: }; struct RangeItemRecordTypeItem { std::string name; - int templateParameter; + int templateParameter; // TODO: use this }; std::string startPattern, startPattern2, endPattern, itEndPattern; std::map functions; @@ -407,15 +407,6 @@ public: return arg ? arg->valid : emptyString; } - struct InvalidArgValue { - enum class Type {le, lt, eq, ge, gt, range} type; - std::string op1; - std::string op2; - bool isInt() const { - return MathLib::isInt(op1); - } - }; - const ArgumentChecks::IteratorInfo *getArgIteratorInfo(const Token *ftok, int argnr) const { const ArgumentChecks *arg = getarg(ftok, argnr); return arg && arg->iteratorInfo.it ? &arg->iteratorInfo : nullptr; diff --git a/lib/preprocessor.h b/lib/preprocessor.h index bea2b0d27..a64ebdfb5 100644 --- a/lib/preprocessor.h +++ b/lib/preprocessor.h @@ -80,8 +80,7 @@ public: * Include file types. */ enum HeaderTypes { - NoHeader = 0, - UserHeader, + UserHeader = 1, SystemHeader }; @@ -169,10 +168,6 @@ public: static void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings); - void setFile0(const std::string &f) { - mFile0 = f; - } - /** * dump all directives present in source file */ diff --git a/lib/programmemory.h b/lib/programmemory.h index a05c9bb2d..1820b1770 100644 --- a/lib/programmemory.h +++ b/lib/programmemory.h @@ -171,8 +171,6 @@ bool conditionIsTrue(const Token* condition, ProgramMemory pm, const Settings* s */ ProgramMemory getProgramMemory(const Token* tok, const Token* expr, const ValueFlow::Value& value, const Settings* settings); -ProgramMemory getProgramMemory(const Token *tok, const ProgramMemory::Map& vars); - ValueFlow::Value evaluateLibraryFunction(const std::unordered_map& args, const std::string& returnValue, const Settings* settings); diff --git a/lib/reverseanalyzer.cpp b/lib/reverseanalyzer.cpp index d17595668..af5942008 100644 --- a/lib/reverseanalyzer.cpp +++ b/lib/reverseanalyzer.cpp @@ -388,12 +388,6 @@ struct ReverseTraversal { } }; -void valueFlowGenericReverse(Token* start, const ValuePtr& a, const Settings& settings) -{ - ReverseTraversal rt{a, settings}; - rt.traverse(start); -} - void valueFlowGenericReverse(Token* start, const Token* end, const ValuePtr& a, const Settings& settings) { ReverseTraversal rt{a, settings}; diff --git a/lib/reverseanalyzer.h b/lib/reverseanalyzer.h index f42e0852a..db80d3ada 100644 --- a/lib/reverseanalyzer.h +++ b/lib/reverseanalyzer.h @@ -25,7 +25,6 @@ class Token; template class ValuePtr; -void valueFlowGenericReverse(Token* start, const ValuePtr& a, const Settings& settings); void valueFlowGenericReverse(Token* start, const Token* end, const ValuePtr& a, const Settings& settings); #endif diff --git a/lib/settings.h b/lib/settings.h index b1ab699ef..8d3600163 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -61,12 +61,6 @@ public: void fill() { mFlags = 0xFFFFFFFF; } - void setEnabledAll(bool enabled) { - if (enabled) - fill(); - else - clear(); - } bool isEnabled(T flag) const { return (mFlags & (1U << (uint32_t)flag)) != 0; } diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 24f9a464f..ca2f2fee0 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -4462,13 +4462,6 @@ Scope::Scope(const SymbolDatabase *check_, const Token *classDef_, const Scope * className = nameTok->str(); } -bool Scope::hasDefaultConstructor() const -{ - return numConstructors > 0 && std::any_of(functionList.begin(), functionList.end(), [](const Function& func) { - return func.type == Function::eConstructor && func.argCount() == 0; - }); -} - AccessControl Scope::defaultAccess() const { switch (type) { diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index f9f67ce8b..e4ba6a6d5 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -1175,8 +1175,6 @@ public: functionMap.insert(make_pair(back->tokenDef->str(), back)); } - bool hasDefaultConstructor() const; - AccessControl defaultAccess() const; /** diff --git a/lib/token.cpp b/lib/token.cpp index 04376b6ac..bbd401dd7 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -2516,10 +2516,6 @@ Token* findTypeEnd(Token* tok) return tok; } -const Token* findTypeEnd(const Token* tok) { - return findTypeEnd(const_cast(tok)); -} - Token* findLambdaEndScope(Token* tok) { if (!Token::simpleMatch(tok, "[")) diff --git a/lib/token.h b/lib/token.h index 6b5536105..a0ee70413 100644 --- a/lib/token.h +++ b/lib/token.h @@ -1455,7 +1455,6 @@ public: }; Token* findTypeEnd(Token* tok); -const Token* findTypeEnd(const Token* tok); Token* findLambdaEndScope(Token* tok); const Token* findLambdaEndScope(const Token* tok); diff --git a/lib/tokenize.h b/lib/tokenize.h index 212302a9d..18e2c45b6 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -158,13 +158,6 @@ public: nonneg int sizeOfType(const std::string& type) const; void simplifyDebug(); - /** - * Try to determine if function parameter is passed by value by looking - * at the function declaration. - * @param fpar token for function parameter in the function call - * @return true if the parameter is passed by value. if unsure, false is returned - */ - bool isFunctionParameterPassedByValue(const Token *fpar) const; /** Simplify assignment where rhs is a block : "x=({123;});" => "{x=123;}" */ void simplifyAssignmentBlock(); @@ -554,12 +547,6 @@ private: */ void simplifyCPPAttribute(); - /** - * Replace strlen(str) - * @return true if any replacement took place, false else - * */ - bool simplifyStrlen(); - /** * Convert namespace aliases */ diff --git a/test/cfg/boost.cpp b/test/cfg/boost.cpp index 25ef4ceeb..ee6f77dd8 100644 --- a/test/cfg/boost.cpp +++ b/test/cfg/boost.cpp @@ -39,7 +39,7 @@ void valid_code(boost::function &pf_print_hello) pf_print_hello = boost::bind(print_hello); } -void ignoredReturnValue(char * buf) +void ignoredReturnValue() { // cppcheck-suppress ignoredReturnValue boost::math::round(1.5); diff --git a/test/helpers.h b/test/helpers.h index a0ca4bba5..d3117fe55 100644 --- a/test/helpers.h +++ b/test/helpers.h @@ -55,22 +55,6 @@ public: }; -class SimpleSuppressor : public ErrorLogger { -public: - SimpleSuppressor(Settings &settings, ErrorLogger *next) - : settings(settings), next(next) {} - void reportOut(const std::string &outmsg, Color /*c*/ = Color::Reset) override { - next->reportOut(outmsg); - } - void reportErr(const ErrorMessage &msg) override { - if (!msg.callStack.empty() && !settings.nomsg.isSuppressed(msg)) - next->reportErr(msg); - } -private: - Settings &settings; - ErrorLogger *next; -}; - class ScopedFile { public: ScopedFile(std::string name, const std::string &content, std::string path = "");