Skip to content

Commit bc20feb

Browse files
committed
s [skip ci]
1 parent c07c738 commit bc20feb

10 files changed

Lines changed: 32 additions & 37 deletions

cli/filelister.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ std::string FileLister::addFiles(std::list<PathWithDetails>&files, const std::st
131131

132132
// files inside directories need to be sorted as the filesystem doesn't provide a stable order
133133
filesSorted.sort([](const decltype(filesSorted)::value_type& a, const decltype(filesSorted)::value_type& b) {
134-
return a.first < b.first;
134+
return a.path() < b.path();
135135
});
136136

137137
files.insert(files.end(), std::make_move_iterator(filesSorted.begin()), std::make_move_iterator(filesSorted.end()));

gui/threadresult.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ FileSettings ThreadResult::getNextFileSettings()
7272
{
7373
std::lock_guard<std::mutex> locker(mutex);
7474
if (mFileSettings.empty()) {
75-
return FileSettings();
75+
return FileSettings("");
7676
}
7777
const FileSettings fs = mFileSettings.front();
7878
mFileSettings.pop_front();

lib/filesettings.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class PathWithDetails
3737
, mSize(0)
3838
{}
3939

40-
explicit PathWithDetails(std::string path, std::size_t size)
40+
PathWithDetails(std::string path, std::size_t size)
4141
: mPath(std::move(path))
4242
, mSize(size)
4343
{}
@@ -58,7 +58,15 @@ class PathWithDetails
5858

5959
/** File settings. Multiple configurations for a file is allowed. */
6060
struct CPPCHECKLIB FileSettings {
61-
FileSettings() = default; // TODO: call PathWithDetails c'tor
61+
//FileSettings() = default; // TODO: remove
62+
63+
explicit FileSettings(std::string path)
64+
: path(std::move(path))
65+
{}
66+
67+
FileSettings(std::string path, std::size_t size)
68+
: path(std::move(path), size)
69+
{}
6270

6371
std::string cfg;
6472
PathWithDetails path;

lib/importproject.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,15 +398,15 @@ bool ImportProject::importCompileCommands(std::istream &istr)
398398
if (!Path::acceptFile(file))
399399
continue;
400400

401-
FileSettings fs;
401+
FileSettings fs{""};
402402
if (Path::isAbsolute(file))
403403
fs.path = PathWithDetails{Path::simplifyPath(file)};
404404
#ifdef _WIN32
405405
else if (file[0] == '/' && directory.size() > 2 && std::isalpha(directory[0]) && directory[1] == ':')
406406
// directory: C:\foo\bar
407407
// file: /xy/z.c
408408
// => c:/xy/z.c
409-
fs.filename = Path::simplifyPath(directory.substr(0,2) + file);
409+
fs.path = PathWithDetails{Path::simplifyPath(directory.substr(0,2) + file)};
410410
#endif
411411
else
412412
fs.path = PathWithDetails{Path::simplifyPath(directory + file)};
@@ -759,8 +759,7 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map<std::str
759759
continue;
760760
}
761761

762-
FileSettings fs;
763-
fs.path = PathWithDetails{cfilename};
762+
FileSettings fs{cfilename};
764763
fs.cfg = p.name;
765764
// TODO: detect actual MSC version
766765
fs.msc = true;
@@ -1055,10 +1054,9 @@ bool ImportProject::importBcb6Prj(const std::string &projectFilename)
10551054
//
10561055
// We can also force C++ compilation for all files using the -P command line switch.
10571056
const bool cppMode = forceCppMode || Path::getFilenameExtensionInLowerCase(c) == ".cpp";
1058-
FileSettings fs;
1057+
FileSettings fs{Path::simplifyPath(Path::isAbsolute(c) ? c : projectDir + c)};
10591058
fsSetIncludePaths(fs, projectDir, toStringList(includePath), variables);
10601059
fsSetDefines(fs, cppMode ? cppDefines : defines);
1061-
fs.path = PathWithDetails{Path::simplifyPath(Path::isAbsolute(c) ? c : projectDir + c)};
10621060
fileSettings.push_back(std::move(fs));
10631061
}
10641062

test/testcppcheck.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ class TestCppcheck : public TestFixture {
122122

123123
ErrorLogger2 errorLogger;
124124
CppCheck cppcheck(errorLogger, false, {});
125-
FileSettings fs;
126-
fs.path = PathWithDetails{file.path()};
125+
FileSettings fs{file.path()};
127126
ASSERT_EQUALS(1, cppcheck.check(fs));
128127
// TODO: how to properly disable these warnings?
129128
errorLogger.ids.erase(std::remove_if(errorLogger.ids.begin(), errorLogger.ids.end(), [](const std::string& id) {

test/testimportproject.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class TestImportProject : public TestFixture {
6969
}
7070

7171
void setDefines() const {
72-
FileSettings fs;
72+
FileSettings fs{""};
7373

7474
ImportProject::fsSetDefines(fs, "A");
7575
ASSERT_EQUALS("A=1", fs.defines);
@@ -85,7 +85,7 @@ class TestImportProject : public TestFixture {
8585
}
8686

8787
void setIncludePaths1() const {
88-
FileSettings fs;
88+
FileSettings fs{""};
8989
std::list<std::string> in(1, "../include");
9090
std::map<std::string, std::string, cppcheck::stricmp> variables;
9191
ImportProject::fsSetIncludePaths(fs, "abc/def/", in, variables);
@@ -94,7 +94,7 @@ class TestImportProject : public TestFixture {
9494
}
9595

9696
void setIncludePaths2() const {
97-
FileSettings fs;
97+
FileSettings fs{""};
9898
std::list<std::string> in(1, "$(SolutionDir)other");
9999
std::map<std::string, std::string, cppcheck::stricmp> variables;
100100
variables["SolutionDir"] = "c:/abc/";
@@ -104,7 +104,7 @@ class TestImportProject : public TestFixture {
104104
}
105105

106106
void setIncludePaths3() const { // macro names are case insensitive
107-
FileSettings fs;
107+
FileSettings fs{""};
108108
std::list<std::string> in(1, "$(SOLUTIONDIR)other");
109109
std::map<std::string, std::string, cppcheck::stricmp> variables;
110110
variables["SolutionDir"] = "c:/abc/";
@@ -371,9 +371,8 @@ class TestImportProject : public TestFixture {
371371
}
372372

373373
void ignorePaths() const {
374-
FileSettings fs1, fs2;
375-
fs1.path = PathWithDetails{"foo/bar"};
376-
fs2.path = PathWithDetails{"qwe/rty"};
374+
FileSettings fs1{"foo/bar"};
375+
FileSettings fs2{"qwe/rty"};
377376
TestImporter project;
378377
project.fileSettings = {std::move(fs1), std::move(fs2)};
379378

test/testprocessexecutor.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ class TestProcessExecutorBase : public TestFixture {
7474
std::string f_s = fprefix() + "_" + std::to_string(i) + ".cpp";
7575
filelist.emplace_back(f_s, data.size());
7676
if (useFS) {
77-
FileSettings fs;
78-
fs.path = PathWithDetails{std::move(f_s)};
77+
FileSettings fs{std::move(f_s)};
7978
fileSettings.emplace_back(std::move(fs));
8079
}
8180
}
@@ -85,8 +84,7 @@ class TestProcessExecutorBase : public TestFixture {
8584
{
8685
filelist.emplace_back(f, data.size());
8786
if (useFS) {
88-
FileSettings fs;
89-
fs.path = PathWithDetails{f};
87+
FileSettings fs{f};
9088
fileSettings.emplace_back(std::move(fs));
9189
}
9290
}

test/testsingleexecutor.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ class TestSingleExecutorBase : public TestFixture {
7979
std::string f_s = fprefix() + "_" + zpad3(i) + ".cpp";
8080
filelist.emplace_back(f_s, data.size());
8181
if (useFS) {
82-
FileSettings fs;
83-
fs.path = PathWithDetails{std::move(f_s)};
82+
FileSettings fs{std::move(f_s)};
8483
fileSettings.emplace_back(std::move(fs));
8584
}
8685
}
@@ -90,8 +89,7 @@ class TestSingleExecutorBase : public TestFixture {
9089
{
9190
filelist.emplace_back(f, data.size());
9291
if (useFS) {
93-
FileSettings fs;
94-
fs.path = PathWithDetails{f};
92+
FileSettings fs{f};
9593
fileSettings.emplace_back(std::move(fs));
9694
}
9795
}

test/testsuppressions.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,7 @@ class TestSuppressions : public TestFixture {
233233
for (std::map<std::string, std::string>::const_iterator i = f.cbegin(); i != f.cend(); ++i) {
234234
filelist.emplace_back(i->first, i->second.size());
235235
if (useFS) {
236-
FileSettings fs;
237-
fs.path = PathWithDetails{i->first};
236+
FileSettings fs{i->first};
238237
fileSettings.emplace_back(std::move(fs));
239238
}
240239
}
@@ -282,8 +281,7 @@ class TestSuppressions : public TestFixture {
282281
std::list<PathWithDetails> filelist;
283282
filelist.emplace_back("test.cpp", strlen(code));
284283
if (useFS) {
285-
FileSettings fs;
286-
fs.path = PathWithDetails{"test.cpp"};
284+
FileSettings fs{"test.cpp"};
287285
fileSettings.emplace_back(std::move(fs));
288286
}
289287

@@ -328,8 +326,7 @@ class TestSuppressions : public TestFixture {
328326
std::list<PathWithDetails> filelist;
329327
filelist.emplace_back("test.cpp", strlen(code));
330328
if (useFS) {
331-
FileSettings fs;
332-
fs.path = PathWithDetails{"test.cpp"};
329+
FileSettings fs{"test.cpp"};
333330
fileSettings.emplace_back(std::move(fs));
334331
}
335332

test/testthreadexecutor.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ class TestThreadExecutorBase : public TestFixture {
7474
std::string f_s = fprefix() + "_" + std::to_string(i) + ".cpp";
7575
filelist.emplace_back(f_s, data.size());
7676
if (useFS) {
77-
FileSettings fs;
78-
fs.path = PathWithDetails{std::move(f_s)};
77+
FileSettings fs{std::move(f_s)};
7978
fileSettings.emplace_back(std::move(fs));
8079
}
8180
}
@@ -85,8 +84,7 @@ class TestThreadExecutorBase : public TestFixture {
8584
{
8685
filelist.emplace_back(f, data.size());
8786
if (useFS) {
88-
FileSettings fs;
89-
fs.path = PathWithDetails{f};
87+
FileSettings fs{f};
9088
fileSettings.emplace_back(std::move(fs));
9189
}
9290
}

0 commit comments

Comments
 (0)