Skip to content

Commit 87d1035

Browse files
committed
Fix nondeterministic input ordering of duplicate basenames
inputNameLinkedMap is a LinkedMap containing list of file definitions indexed by their basenames. The first time we encounter a basename, we create a new list and store the path to that file in fullName, and fullName is not updated again. The problem is this path depends on filesystem ordering (we use the path we happen to hit first). Later on we sort the inputs list using fullName but since fullName itself is nondeterministic this doesn't always produce the same result. Fix this by sorting each basename list first, then sorting using the path of the first file in each list. Afterwards, remove FileName::fullName and FileName::path which are no longer used anywhere.
1 parent 25d4737 commit 87d1035

3 files changed

Lines changed: 10 additions & 14 deletions

File tree

src/doxygen.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11140,7 +11140,7 @@ static void readDir(FileInfo *fi,
1114011140
FileName *fn=nullptr;
1114111141
if (!name.empty())
1114211142
{
11143-
fn = fnMap->add(name,fullName);
11143+
fn = fnMap->add(name);
1114411144
fn->push_back(std::move(fd));
1114511145
}
1114611146
}
@@ -11228,7 +11228,7 @@ void readFileOrDirectory(const QCString &s,
1122811228
auto fd = createFileDef(dirPath+"/",name);
1122911229
if (!name.empty())
1123011230
{
11231-
FileName *fn = fnMap->add(name,filePath);
11231+
FileName *fn = fnMap->add(name);
1123211232
fn->push_back(std::move(fd));
1123311233
}
1123411234
}
@@ -12424,12 +12424,6 @@ void searchInputFiles()
1242412424
}
1242512425

1242612426
// Sort the FileDef objects by full path to get a predictable ordering over multiple runs
12427-
std::stable_sort(Doxygen::inputNameLinkedMap->begin(),
12428-
Doxygen::inputNameLinkedMap->end(),
12429-
[](const auto &f1,const auto &f2)
12430-
{
12431-
return qstricmp_sort(f1->fullName(),f2->fullName())<0;
12432-
});
1243312427
for (auto &fileName : *Doxygen::inputNameLinkedMap)
1243412428
{
1243512429
if (fileName->size()>1)
@@ -12440,6 +12434,12 @@ void searchInputFiles()
1244012434
});
1244112435
}
1244212436
}
12437+
std::stable_sort(Doxygen::inputNameLinkedMap->begin(),
12438+
Doxygen::inputNameLinkedMap->end(),
12439+
[](const auto &f1,const auto &f2)
12440+
{
12441+
return qstricmp_sort(f1->front()->absFilePath(),f2->front()->absFilePath())<0;
12442+
});
1244312443
if (Doxygen::inputNameLinkedMap->empty())
1244412444
{
1244512445
warn_uncond("No files to be processed, please check your settings, in particular INPUT, FILE_PATTERNS, and RECURSIVE\n");

src/filename.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,11 @@ class FileDef;
2929
class FileName : public std::vector< std::unique_ptr<FileDef> >
3030
{
3131
public:
32-
FileName(const QCString &nm,const QCString &fn) : m_name(nm), m_fName(fn), m_pathName("tmp") {}
32+
explicit FileName(const QCString &nm) : m_name(nm) {}
3333
QCString fileName() const { return m_name; }
34-
QCString fullName() const { return m_fName; }
35-
QCString path() const { return m_pathName; }
3634

3735
private:
3836
QCString m_name;
39-
QCString m_fName;
40-
QCString m_pathName;
4137
};
4238

4339
//! Custom combined key compare and hash functor that uses a lower case string in

src/tagreader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,7 @@ void TagFileParser::buildLists(const std::shared_ptr<Entry> &root)
16761676
}
16771677
else
16781678
{
1679-
mn = Doxygen::inputNameLinkedMap->add(tfi->name,fullName);
1679+
mn = Doxygen::inputNameLinkedMap->add(tfi->name);
16801680
mn->push_back(std::move(fd));
16811681
}
16821682
buildMemberList(fe,tfi->members);

0 commit comments

Comments
 (0)