Skip to content

Commit 6369e51

Browse files
authored
enabled and fixed -Wcovered-switch-default Clang warnings (#8153)
1 parent 803fdfe commit 6369e51

File tree

8 files changed

+12
-14
lines changed

8 files changed

+12
-14
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ $(libcppdir)/pathanalysis.o: lib/pathanalysis.cpp lib/astutils.h lib/config.h li
625625
$(libcppdir)/pathmatch.o: lib/pathmatch.cpp lib/config.h lib/path.h lib/pathmatch.h lib/standards.h
626626
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/pathmatch.cpp
627627

628-
$(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
628+
$(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
629629
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/platform.cpp
630630

631631
$(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
697697
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
698698
$(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/filelister.cpp
699699

700-
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
700+
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
701701
$(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/main.cpp
702702

703703
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

cmake/compileroptions.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
136136
add_compile_options_safe(-Wno-unused-exception-parameter)
137137
add_compile_options_safe(-Wno-sign-conversion)
138138
add_compile_options_safe(-Wno-shadow-field-in-constructor)
139-
add_compile_options_safe(-Wno-covered-switch-default)
140139
add_compile_options_safe(-Wno-shorten-64-to-32)
141140
add_compile_options_safe(-Wno-implicit-int-conversion)
142141
add_compile_options_safe(-Wno-double-promotion)

gui/checkstatistics.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#include "checkstatistics.h"
2020

21+
#include "utils.h"
22+
2123
#include <QDebug>
2224
#include <QList>
2325
#include <QSet>
@@ -59,7 +61,6 @@ void CheckStatistics::addItem(const QString &tool, ShowTypes::ShowType type)
5961
::addItem(mInformation, lower);
6062
break;
6163
case ShowTypes::ShowNone:
62-
default:
6364
qDebug() << "Unknown error type - not added to statistics.";
6465
break;
6566
}
@@ -99,10 +100,10 @@ unsigned CheckStatistics::getCount(const QString &tool, ShowTypes::ShowType type
99100
case ShowTypes::ShowInformation:
100101
return mInformation.value(lower,0);
101102
case ShowTypes::ShowNone:
102-
default:
103103
qDebug() << "Unknown error type - returning zero statistics.";
104104
return 0;
105105
}
106+
cppcheck::unreachable();
106107
}
107108

108109
QStringList CheckStatistics::getTools() const

gui/mainwindow.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,9 +1016,6 @@ bool MainWindow::tryLoadLibrary(Library &library, const QString& filename)
10161016
case Library::ErrorCode::UNKNOWN_ELEMENT:
10171017
errmsg = tr("Unknown element");
10181018
break;
1019-
default:
1020-
errmsg = tr("Unknown issue");
1021-
break;
10221019
}
10231020
if (!error.reason.empty())
10241021
errmsg += " '" + QString::fromStdString(error.reason) + "'";

gui/resultstree.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "showtypes.h"
3333
#include "suppressions.h"
3434
#include "threadhandler.h"
35+
#include "utils.h"
3536
#include "xmlreportv2.h"
3637

3738
#include <algorithm>
@@ -377,9 +378,10 @@ QString ResultsTree::severityToTranslatedString(Severity severity)
377378
return tr("internal");
378379

379380
case Severity::none:
380-
default:
381381
return QString();
382382
}
383+
384+
cppcheck::unreachable();
383385
}
384386

385387
ResultItem *ResultsTree::findFileItem(const QString &name) const

lib/platform.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "config.h"
2525
#include "mathlib.h"
2626
#include "standards.h"
27+
#include "utils.h"
2728

2829
#include <cassert>
2930
#include <climits>
@@ -194,9 +195,8 @@ class CPPCHECKLIB Platform {
194195
return "unix64";
195196
case Type::File:
196197
return "platformFile";
197-
default:
198-
throw std::runtime_error("unknown platform");
199198
}
199+
cppcheck::unreachable();
200200
}
201201

202202
long long unsignedCharMax() const {

lib/symboldatabase.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4065,9 +4065,8 @@ static const char* functionTypeToString(FunctionType type)
40654065
return "Function";
40664066
case FunctionType::eLambda:
40674067
return "Lambda";
4068-
default:
4069-
return "Unknown";
40704068
}
4069+
cppcheck::unreachable();
40714070
}
40724071

40734072
static std::string tokenToString(const Token* tok, const Tokenizer& tokenizer)

oss-fuzz/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ $(libcppdir)/pathanalysis.o: ../lib/pathanalysis.cpp ../lib/astutils.h ../lib/co
305305
$(libcppdir)/pathmatch.o: ../lib/pathmatch.cpp ../lib/config.h ../lib/path.h ../lib/pathmatch.h ../lib/standards.h
306306
$(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/pathmatch.cpp
307307

308-
$(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
308+
$(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
309309
$(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/platform.cpp
310310

311311
$(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

0 commit comments

Comments
 (0)