Skip to content

Commit ed4a6b4

Browse files
committed
moved Language from settings.h to standards.h
1 parent ba748bf commit ed4a6b4

14 files changed

Lines changed: 93 additions & 95 deletions

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ validateRules:
449449

450450
###### Build
451451

452-
$(libcppdir)/analyzerinfo.o: lib/analyzerinfo.cpp externals/tinyxml2/tinyxml2.h lib/analyzerinfo.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.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
452+
$(libcppdir)/analyzerinfo.o: lib/analyzerinfo.cpp externals/tinyxml2/tinyxml2.h lib/analyzerinfo.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/path.h lib/platform.h lib/standards.h lib/suppressions.h lib/utils.h
453453
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/analyzerinfo.cpp
454454

455455
$(libcppdir)/astutils.o: lib/astutils.cpp lib/astutils.h lib/check.h lib/checkclass.h lib/config.h lib/errortypes.h lib/importproject.h lib/infer.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/valueptr.h lib/vfvalue.h
@@ -563,22 +563,22 @@ $(libcppdir)/importproject.o: lib/importproject.cpp externals/picojson/picojson.
563563
$(libcppdir)/infer.o: lib/infer.cpp lib/calculate.h lib/config.h lib/errortypes.h lib/infer.h lib/mathlib.h lib/valueptr.h lib/vfvalue.h
564564
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/infer.cpp
565565

566-
$(libcppdir)/library.o: lib/library.cpp externals/tinyxml2/tinyxml2.h lib/astutils.h lib/config.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h
566+
$(libcppdir)/library.o: lib/library.cpp externals/tinyxml2/tinyxml2.h lib/astutils.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h
567567
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/library.cpp
568568

569569
$(libcppdir)/mathlib.o: lib/mathlib.cpp externals/simplecpp/simplecpp.h lib/config.h lib/errortypes.h lib/mathlib.h lib/utils.h
570570
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/mathlib.cpp
571571

572-
$(libcppdir)/path.o: lib/path.cpp externals/simplecpp/simplecpp.h lib/config.h lib/errortypes.h lib/importproject.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
572+
$(libcppdir)/path.o: lib/path.cpp externals/simplecpp/simplecpp.h lib/config.h lib/path.h lib/standards.h lib/utils.h
573573
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/path.cpp
574574

575575
$(libcppdir)/pathanalysis.o: lib/pathanalysis.cpp lib/astutils.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/pathanalysis.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/vfvalue.h
576576
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/pathanalysis.cpp
577577

578-
$(libcppdir)/pathmatch.o: lib/pathmatch.cpp lib/config.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/path.h lib/pathmatch.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/utils.h
578+
$(libcppdir)/pathmatch.o: lib/pathmatch.cpp lib/config.h lib/path.h lib/pathmatch.h lib/standards.h lib/utils.h
579579
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/pathmatch.cpp
580580

581-
$(libcppdir)/platform.o: lib/platform.cpp externals/tinyxml2/tinyxml2.h lib/config.h lib/errortypes.h lib/importproject.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
581+
$(libcppdir)/platform.o: lib/platform.cpp externals/tinyxml2/tinyxml2.h lib/config.h lib/path.h lib/platform.h lib/standards.h lib/utils.h
582582
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/platform.cpp
583583

584584
$(libcppdir)/preprocessor.o: lib/preprocessor.cpp externals/simplecpp/simplecpp.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.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/timer.h lib/utils.h
@@ -596,7 +596,7 @@ $(libcppdir)/settings.o: lib/settings.cpp externals/picojson/picojson.h lib/conf
596596
$(libcppdir)/summaries.o: lib/summaries.cpp lib/analyzerinfo.h lib/config.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/summaries.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h
597597
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/summaries.cpp
598598

599-
$(libcppdir)/suppressions.o: lib/suppressions.cpp externals/tinyxml2/tinyxml2.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h
599+
$(libcppdir)/suppressions.o: lib/suppressions.cpp externals/tinyxml2/tinyxml2.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/mathlib.h lib/path.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h
600600
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/suppressions.cpp
601601

602602
$(libcppdir)/symboldatabase.o: lib/symboldatabase.cpp lib/astutils.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h
@@ -641,7 +641,7 @@ cli/cppcheckexecutorsig.o: cli/cppcheckexecutorsig.cpp cli/cppcheckexecutor.h cl
641641
cli/executor.o: cli/executor.cpp cli/executor.h
642642
$(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/executor.cpp
643643

644-
cli/filelister.o: cli/filelister.cpp cli/filelister.h lib/config.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/path.h lib/pathmatch.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/utils.h
644+
cli/filelister.o: cli/filelister.cpp cli/filelister.h lib/config.h lib/path.h lib/pathmatch.h lib/standards.h lib/utils.h
645645
$(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/filelister.cpp
646646

647647
cli/main.o: cli/main.cpp cli/cppcheckexecutor.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/suppressions.h
@@ -758,7 +758,7 @@ test/testoptions.o: test/testoptions.cpp lib/check.h lib/color.h lib/config.h li
758758
test/testother.o: test/testother.cpp externals/simplecpp/simplecpp.h externals/tinyxml2/tinyxml2.h lib/check.h lib/checkother.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h
759759
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testother.cpp
760760

761-
test/testpath.o: test/testpath.cpp lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.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 test/fixture.h
761+
test/testpath.o: test/testpath.cpp lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/path.h lib/standards.h lib/suppressions.h lib/utils.h test/fixture.h
762762
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testpath.cpp
763763

764764
test/testpathmatch.o: test/testpathmatch.cpp lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/pathmatch.h lib/suppressions.h test/fixture.h

cli/cmdlineparser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,9 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
554554
}
555555

556556
if (str == "c")
557-
mSettings->enforcedLang = Settings::Language::C;
557+
mSettings->enforcedLang = Standards::Language::C;
558558
else if (str == "c++")
559-
mSettings->enforcedLang = Settings::Language::CPP;
559+
mSettings->enforcedLang = Standards::Language::CPP;
560560
else {
561561
printError("unknown language '" + str + "' enforced.");
562562
return false;

gui/mainwindow.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,10 @@ void MainWindow::loadSettings()
371371
mUI->mActionToolBarFilter->setChecked(showFilterToolbar);
372372
mUI->mToolBarFilter->setVisible(showFilterToolbar);
373373

374-
const Settings::Language enforcedLanguage = (Settings::Language)mSettings->value(SETTINGS_ENFORCED_LANGUAGE, 0).toInt();
375-
if (enforcedLanguage == Settings::CPP)
374+
const Standards::Language enforcedLanguage = (Standards::Language)mSettings->value(SETTINGS_ENFORCED_LANGUAGE, 0).toInt();
375+
if (enforcedLanguage == Standards::Language::CPP)
376376
mUI->mActionEnforceCpp->setChecked(true);
377-
else if (enforcedLanguage == Settings::C)
377+
else if (enforcedLanguage == Standards::Language::C)
378378
mUI->mActionEnforceC->setChecked(true);
379379
else
380380
mUI->mActionAutoDetectLanguage->setChecked(true);
@@ -448,11 +448,11 @@ void MainWindow::saveSettings() const
448448
mSettings->setValue(SETTINGS_TOOLBARS_FILTER_SHOW, mUI->mToolBarFilter->isVisible());
449449

450450
if (mUI->mActionEnforceCpp->isChecked())
451-
mSettings->setValue(SETTINGS_ENFORCED_LANGUAGE, Settings::CPP);
451+
mSettings->setValue(SETTINGS_ENFORCED_LANGUAGE, Standards::Language::CPP);
452452
else if (mUI->mActionEnforceC->isChecked())
453-
mSettings->setValue(SETTINGS_ENFORCED_LANGUAGE, Settings::C);
453+
mSettings->setValue(SETTINGS_ENFORCED_LANGUAGE, Standards::Language::C);
454454
else
455-
mSettings->setValue(SETTINGS_ENFORCED_LANGUAGE, Settings::None);
455+
mSettings->setValue(SETTINGS_ENFORCED_LANGUAGE, Standards::Language::None);
456456

457457
mApplications->saveSettings();
458458

@@ -1033,7 +1033,7 @@ Settings MainWindow::getCppcheckSettings()
10331033
result.platform((cppcheck::Platform::PlatformType) mSettings->value(SETTINGS_CHECKED_PLATFORM, 0).toInt());
10341034
result.standards.setCPP(mSettings->value(SETTINGS_STD_CPP, QString()).toString().toStdString());
10351035
result.standards.setC(mSettings->value(SETTINGS_STD_C, QString()).toString().toStdString());
1036-
result.enforcedLang = (Settings::Language)mSettings->value(SETTINGS_ENFORCED_LANGUAGE, 0).toInt();
1036+
result.enforcedLang = (Standards::Language)mSettings->value(SETTINGS_ENFORCED_LANGUAGE, 0).toInt();
10371037

10381038
if (result.jobs <= 1) {
10391039
result.jobs = 1;

lib/cppcheck.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -262,18 +262,18 @@ static void createDumpFile(const Settings& settings,
262262

263263
std::string language;
264264
switch (settings.enforcedLang) {
265-
case Settings::Language::C:
265+
case Standards::Language::C:
266266
language = " language=\"c\"";
267267
break;
268-
case Settings::Language::CPP:
268+
case Standards::Language::CPP:
269269
language = " language=\"cpp\"";
270270
break;
271-
case Settings::Language::None:
271+
case Standards::Language::None:
272272
// TODO: error out on unknown language?
273-
const Settings::Language lang = Path::identify(filename);
274-
if (lang == Settings::Language::CPP)
273+
const Standards::Language lang = Path::identify(filename);
274+
if (lang == Standards::Language::CPP)
275275
language = " language=\"cpp\"";
276-
else if (lang == Settings::Language::C)
276+
else if (lang == Standards::Language::C)
277277
language = " language=\"c\"";
278278
break;
279279
}
@@ -458,7 +458,7 @@ unsigned int CppCheck::check(const std::string &path)
458458
if (!mSettings.quiet)
459459
mErrorLogger.reportOut(std::string("Checking ") + path + "...", Color::FgGreen);
460460

461-
const bool isCpp = Path::identify(path) == Settings::Language::CPP;
461+
const bool isCpp = Path::identify(path) == Standards::Language::CPP;
462462

463463
const std::string langOpt = isCpp ? "-x c++" : "-x c";
464464
const std::string analyzerInfo = mSettings.buildDir.empty() ? std::string() : AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, path, emptyString);

lib/path.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ bool Path::isCPP(const std::string &path)
208208
bool Path::acceptFile(const std::string &path, const std::set<std::string> &extra)
209209
{
210210
bool header = false;
211-
return (identify(path, &header) != Settings::Language::None && !header) || extra.find(getFilenameExtension(path)) != extra.end();
211+
return (identify(path, &header) != Standards::Language::None && !header) || extra.find(getFilenameExtension(path)) != extra.end();
212212
}
213213

214214
bool Path::isHeader(const std::string &path)
@@ -217,32 +217,32 @@ bool Path::isHeader(const std::string &path)
217217
return (extension.compare(0, 2, ".h") == 0);
218218
}
219219

220-
Settings::Language Path::identify(const std::string &path, bool *header)
220+
Standards::Language Path::identify(const std::string &path, bool *header)
221221
{
222222
if (header)
223223
*header = false;
224224

225225
std::string ext = getFilenameExtension(path);
226226
if (ext == ".C")
227-
return Settings::Language::CPP;
227+
return Standards::Language::CPP;
228228
if (c_src_exts.find(ext) != c_src_exts.end())
229-
return Settings::Language::C;
229+
return Standards::Language::C;
230230
// cppcheck-suppress knownConditionTrueFalse - TODO: FP
231231
if (!caseInsensitiveFilesystem())
232232
strTolower(ext);
233233
if (ext == ".h") {
234234
if (header)
235235
*header = true;
236-
return Settings::Language::C; // treat as C for now
236+
return Standards::Language::C; // treat as C for now
237237
}
238238
if (cpp_src_exts.find(ext) != cpp_src_exts.end())
239-
return Settings::Language::CPP;
239+
return Standards::Language::CPP;
240240
if (header_exts.find(ext) != header_exts.end()) {
241241
if (header)
242242
*header = true;
243-
return Settings::Language::CPP;
243+
return Standards::Language::CPP;
244244
}
245-
return Settings::Language::None;
245+
return Standards::Language::None;
246246
}
247247

248248
bool Path::isHeader2(const std::string &path)

lib/path.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
//---------------------------------------------------------------------------
2323

2424
#include "config.h"
25-
#include "settings.h"
25+
#include "standards.h"
2626

2727
#include <set>
2828
#include <string>
@@ -184,7 +184,7 @@ class CPPCHECKLIB Path {
184184
* @param header if provided indicates if the file is a header
185185
* @return the language type
186186
*/
187-
static Settings::Language identify(const std::string &path, bool *header = nullptr);
187+
static Standards::Language identify(const std::string &path, bool *header = nullptr);
188188

189189
/**
190190
* @brief Get filename without a directory path part.

lib/preprocessor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,10 +623,10 @@ static simplecpp::DUI createDUI(const Settings &mSettings, const std::string &cf
623623
dui.includes = mSettings.userIncludes; // --include
624624
// TODO: use mSettings.standards.stdValue instead
625625
// TODO: error out on unknown language?
626-
const Settings::Language lang = Path::identify(filename);
627-
if (lang == Settings::Language::CPP)
626+
const Standards::Language lang = Path::identify(filename);
627+
if (lang == Standards::Language::CPP)
628628
dui.std = mSettings.standards.getCPP();
629-
else if (lang == Settings::Language::C)
629+
else if (lang == Standards::Language::C)
630630
dui.std = mSettings.standards.getC();
631631
return dui;
632632
}

lib/settings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Settings::Settings()
5050
debugtemplate(false),
5151
debugwarnings(false),
5252
dump(false),
53-
enforcedLang(Language::None),
53+
enforcedLang(Standards::Language::None),
5454
exceptionHandling(false),
5555
exitCode(0),
5656
force(false),

lib/settings.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,8 @@ class CPPCHECKLIB Settings : public cppcheck::Platform {
178178
bool dump;
179179
std::string dumpFile;
180180

181-
enum Language {
182-
None, C, CPP
183-
};
184-
185181
/** @brief Name of the language that is enforced. Empty per default. */
186-
Language enforcedLang;
182+
Standards::Language enforcedLang;
187183

188184
/** @brief Is --exception-handling given */
189185
bool exceptionHandling;

lib/standards.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
* This struct contains all possible standards that cppcheck recognize.
3535
*/
3636
struct Standards {
37+
enum Language { None, C, CPP };
38+
3739
/** C code standard */
3840
enum cstd_t { C89, C99, C11, CLatest=C11 } c;
3941

0 commit comments

Comments
 (0)