Skip to content

Commit 8ac514a

Browse files
committed
change matching
1 parent fba0ced commit 8ac514a

2 files changed

Lines changed: 6 additions & 14 deletions

File tree

‎lib/analyzerinfo.cpp‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "errorlogger.h"
2222
#include "filesettings.h"
2323
#include "path.h"
24-
#include "utils.h"
2524

2625
#include <array>
2726
#include <cstring>
@@ -197,23 +196,16 @@ std::string AnalyzerInformation::skipAnalysis(const tinyxml2::XMLDocument &analy
197196

198197
std::string AnalyzerInformation::getAnalyzerInfoFileFromFilesTxt(std::istream& filesTxt, const std::string &sourcefile, const std::string &cfg, size_t fsFileId)
199198
{
200-
// An exact match wins, the suffix match is only a fallback for paths spelled differently than in
201-
// files.txt. Otherwise "processexecutor.cpp" matches the "executor.cpp" line and both share one file.
202199
const std::string simplifiedSourcefile = Path::simplifyPath(sourcefile);
203-
std::string suffixMatch;
204200
std::string line;
205201
while (std::getline(filesTxt,line)) {
206202
AnalyzerInformation::Info filesTxtInfo;
207203
if (!filesTxtInfo.parse(line))
208204
continue; // TODO: report error?
209-
if (filesTxtInfo.cfg != cfg || filesTxtInfo.fsFileId != fsFileId)
210-
continue;
211-
if (simplifiedSourcefile == filesTxtInfo.sourceFile)
205+
if (filesTxtInfo.sourceFile == simplifiedSourcefile && filesTxtInfo.cfg == cfg && filesTxtInfo.fsFileId == fsFileId)
212206
return filesTxtInfo.afile;
213-
if (suffixMatch.empty() && endsWith(simplifiedSourcefile, filesTxtInfo.sourceFile))
214-
suffixMatch = filesTxtInfo.afile;
215207
}
216-
return suffixMatch;
208+
return "";
217209
}
218210

219211
std::string AnalyzerInformation::getAnalyzerInfoFile(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, std::size_t fsFileId)

‎test/testanalyzerinformation.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ class TestAnalyzerInformation : public TestFixture {
5454
f.str(filesTxt);
5555
ASSERT_EQUALS("file1.a4", AnalyzerInformationTest::getAnalyzerInfoFileFromFilesTxt(f, "./file1.c", "", 0));
5656

57-
// an exact match wins over a suffix match - "executor.cpp" is a suffix of
58-
// "processexecutor.cpp" so both used to resolve to the same analyzer info file
57+
// only an exact match is used - "executor.cpp" is a suffix of "processexecutor.cpp"
58+
// so both used to resolve to the same analyzer info file
5959
{
6060
constexpr char suffixTxt[] = "executor.a1:::executor.cpp\n"
6161
"processexecutor.a2:::processexecutor.cpp\n";
@@ -75,11 +75,11 @@ class TestAnalyzerInformation : public TestFixture {
7575
ASSERT_EQUALS("executor.a2", AnalyzerInformationTest::getAnalyzerInfoFileFromFilesTxt(f2, "executor.cpp", "", 0));
7676
}
7777

78-
// a suffix match is still used when there is no exact match
78+
// a path that only ends with the path in files.txt is not a match
7979
{
8080
constexpr char relTxt[] = "a.a1:::src/a.c\n";
8181
std::istringstream f1(relTxt);
82-
ASSERT_EQUALS("a.a1", AnalyzerInformationTest::getAnalyzerInfoFileFromFilesTxt(f1, "/home/proj/src/a.c", "", 0));
82+
ASSERT_EQUALS("", AnalyzerInformationTest::getAnalyzerInfoFileFromFilesTxt(f1, "/home/proj/src/a.c", "", 0));
8383
}
8484

8585
// no match at all

0 commit comments

Comments
 (0)