diff --git a/Makefile b/Makefile index 753348c618a..e2431d614d0 100644 --- a/Makefile +++ b/Makefile @@ -625,7 +625,7 @@ $(libcppdir)/pathanalysis.o: lib/pathanalysis.cpp lib/astutils.h lib/config.h li $(libcppdir)/pathmatch.o: lib/pathmatch.cpp lib/config.h lib/path.h lib/pathmatch.h lib/standards.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/pathmatch.cpp -$(libcppdir)/platform.o: lib/platform.cpp externals/tinyxml2/tinyxml2.h lib/config.h lib/mathlib.h lib/path.h lib/platform.h lib/standards.h lib/xml.h +$(libcppdir)/platform.o: lib/platform.cpp externals/tinyxml2/tinyxml2.h lib/config.h lib/mathlib.h lib/path.h lib/platform.h lib/standards.h lib/utils.h lib/xml.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/platform.cpp $(libcppdir)/preprocessor.o: lib/preprocessor.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/checkers.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/utils.h @@ -697,7 +697,7 @@ cli/executor.o: cli/executor.cpp cli/executor.h lib/addoninfo.h lib/checkers.h l cli/filelister.o: cli/filelister.cpp cli/filelister.h lib/config.h lib/filesettings.h lib/mathlib.h lib/path.h lib/pathmatch.h lib/platform.h lib/standards.h lib/utils.h $(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/filelister.cpp -cli/main.o: cli/main.cpp cli/cppcheckexecutor.h lib/config.h lib/filesettings.h lib/mathlib.h lib/path.h lib/platform.h lib/standards.h +cli/main.o: cli/main.cpp cli/cppcheckexecutor.h lib/config.h lib/filesettings.h lib/mathlib.h lib/path.h lib/platform.h lib/standards.h lib/utils.h $(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/main.cpp cli/processexecutor.o: cli/processexecutor.cpp cli/executor.h cli/processexecutor.h lib/addoninfo.h lib/check.h lib/checkers.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/utils.h diff --git a/cmake/compileroptions.cmake b/cmake/compileroptions.cmake index 4112ddd2418..b4b3c2e0689 100644 --- a/cmake/compileroptions.cmake +++ b/cmake/compileroptions.cmake @@ -136,7 +136,6 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options_safe(-Wno-unused-exception-parameter) add_compile_options_safe(-Wno-sign-conversion) add_compile_options_safe(-Wno-shadow-field-in-constructor) - add_compile_options_safe(-Wno-covered-switch-default) add_compile_options_safe(-Wno-shorten-64-to-32) add_compile_options_safe(-Wno-implicit-int-conversion) add_compile_options_safe(-Wno-double-promotion) diff --git a/gui/checkstatistics.cpp b/gui/checkstatistics.cpp index 25bee336811..54762f1c4fe 100644 --- a/gui/checkstatistics.cpp +++ b/gui/checkstatistics.cpp @@ -18,6 +18,8 @@ #include "checkstatistics.h" +#include "utils.h" + #include #include #include @@ -59,7 +61,6 @@ void CheckStatistics::addItem(const QString &tool, ShowTypes::ShowType type) ::addItem(mInformation, lower); break; case ShowTypes::ShowNone: - default: qDebug() << "Unknown error type - not added to statistics."; break; } @@ -99,10 +100,10 @@ unsigned CheckStatistics::getCount(const QString &tool, ShowTypes::ShowType type case ShowTypes::ShowInformation: return mInformation.value(lower,0); case ShowTypes::ShowNone: - default: qDebug() << "Unknown error type - returning zero statistics."; return 0; } + cppcheck::unreachable(); } QStringList CheckStatistics::getTools() const diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 2d71ef5e7c6..19270f1605b 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -1016,9 +1016,6 @@ bool MainWindow::tryLoadLibrary(Library &library, const QString& filename) case Library::ErrorCode::UNKNOWN_ELEMENT: errmsg = tr("Unknown element"); break; - default: - errmsg = tr("Unknown issue"); - break; } if (!error.reason.empty()) errmsg += " '" + QString::fromStdString(error.reason) + "'"; diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index 0c8ee2e3101..3e5a0b08280 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -32,6 +32,7 @@ #include "showtypes.h" #include "suppressions.h" #include "threadhandler.h" +#include "utils.h" #include "xmlreportv2.h" #include @@ -377,9 +378,10 @@ QString ResultsTree::severityToTranslatedString(Severity severity) return tr("internal"); case Severity::none: - default: return QString(); } + + cppcheck::unreachable(); } ResultItem *ResultsTree::findFileItem(const QString &name) const diff --git a/lib/platform.h b/lib/platform.h index 4673c4859e6..0820672cc47 100644 --- a/lib/platform.h +++ b/lib/platform.h @@ -24,6 +24,7 @@ #include "config.h" #include "mathlib.h" #include "standards.h" +#include "utils.h" #include #include @@ -194,9 +195,8 @@ class CPPCHECKLIB Platform { return "unix64"; case Type::File: return "platformFile"; - default: - throw std::runtime_error("unknown platform"); } + cppcheck::unreachable(); } long long unsignedCharMax() const { diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 1c77a365a1b..c7e56ef01a7 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -4065,9 +4065,8 @@ static const char* functionTypeToString(FunctionType type) return "Function"; case FunctionType::eLambda: return "Lambda"; - default: - return "Unknown"; } + cppcheck::unreachable(); } static std::string tokenToString(const Token* tok, const Tokenizer& tokenizer) diff --git a/oss-fuzz/Makefile b/oss-fuzz/Makefile index ad7fb641024..1d938116996 100644 --- a/oss-fuzz/Makefile +++ b/oss-fuzz/Makefile @@ -305,7 +305,7 @@ $(libcppdir)/pathanalysis.o: ../lib/pathanalysis.cpp ../lib/astutils.h ../lib/co $(libcppdir)/pathmatch.o: ../lib/pathmatch.cpp ../lib/config.h ../lib/path.h ../lib/pathmatch.h ../lib/standards.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/pathmatch.cpp -$(libcppdir)/platform.o: ../lib/platform.cpp ../externals/tinyxml2/tinyxml2.h ../lib/config.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/standards.h ../lib/xml.h +$(libcppdir)/platform.o: ../lib/platform.cpp ../externals/tinyxml2/tinyxml2.h ../lib/config.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/standards.h ../lib/utils.h ../lib/xml.h $(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/platform.cpp $(libcppdir)/preprocessor.o: ../lib/preprocessor.cpp ../externals/simplecpp/simplecpp.h ../lib/addoninfo.h ../lib/checkers.h ../lib/config.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/preprocessor.h ../lib/settings.h ../lib/standards.h ../lib/suppressions.h ../lib/utils.h