Skip to content

Commit a8bd630

Browse files
committed
Ensure fileIndex is unique
Change-Id: I3a8c7b237cb0e08814a4d5f3f3ad0534d9672451 Reviewed-on: https://codereview.kdab.com/c/kdab/code_browser/+/132788 Reviewed-by: Waqar Ahmed <[email protected]>
1 parent 733eaf2 commit a8bd630

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

generator/annotator.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,19 @@ void Annotator::registerInterestingDefinition(clang::SourceRange sourceRange,
243243

244244
bool Annotator::generate(clang::Sema &Sema, bool WasInDatabase)
245245
{
246+
#if CLANG_VERSION_MAJOR >= 16
247+
static const std::string mp_suffix =
248+
llvm::sys::Process::GetEnv("MULTIPROCESS_MODE").value_or("");
249+
#else
250+
static const std::string mp_suffix =
251+
llvm::sys::Process::GetEnv("MULTIPROCESS_MODE").getValueOr("");
252+
#endif
253+
246254
std::ofstream fileIndex;
247-
fileIndex.open(projectManager.outputPrefix + "/fileIndex", std::ios::app);
255+
fileIndex.open(projectManager.outputPrefix + "/fileIndex" + mp_suffix, std::ios::app);
248256
if (!fileIndex) {
249257
create_directories(projectManager.outputPrefix);
250-
fileIndex.open(projectManager.outputPrefix + "/fileIndex", std::ios::app);
258+
fileIndex.open(projectManager.outputPrefix + "/fileIndex" + mp_suffix, std::ios::app);
251259
if (!fileIndex) {
252260
std::cerr << "Can't generate index for " << std::endl;
253261
return false;
@@ -257,14 +265,6 @@ bool Annotator::generate(clang::Sema &Sema, bool WasInDatabase)
257265
// make sure the main file is in the cache.
258266
htmlNameForFile(getSourceMgr().getMainFileID());
259267

260-
#if CLANG_VERSION_MAJOR >= 16
261-
static const std::string mp_suffix =
262-
llvm::sys::Process::GetEnv("MULTIPROCESS_MODE").value_or("");
263-
#else
264-
static const std::string mp_suffix =
265-
llvm::sys::Process::GetEnv("MULTIPROCESS_MODE").getValueOr("");
266-
#endif
267-
268268
std::set<std::string> done;
269269
for (auto it : cache) {
270270
if (!it.second.first)

scripts/runner.py

+3
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ def do_merge(out, max_task):
112112
print("Merging ", refsM)
113113
do_merge_dir(refsM, max_task)
114114

115+
print("Merging fileIndex")
116+
do_merge_dir(out, max_task)
117+
115118

116119
def main():
117120
usage = "python runner.py -p compile_commands.json -o output/ -e ./generator/codebrowser_generator -a project_name -x external_project"

0 commit comments

Comments
 (0)