Skip to content

Commit 733eaf2

Browse files
committed
Improve multiprocess generator run
Each generator process now writes to a different file. All the files are merged at the end of the run. Change-Id: I616ad73a446efae29e68e55cba7bad27e86dcb0b Reviewed-on: https://codereview.kdab.com/c/kdab/code_browser/+/120693 Reviewed-by: Steffen Hansen <[email protected]>
1 parent 4a83af7 commit 733eaf2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

generator/annotator.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include <llvm/ADT/SmallString.h>
4747
#include <llvm/Support/FileSystem.h>
4848
#include <llvm/Support/Path.h>
49+
#include <llvm/Support/Process.h>
4950
#include <llvm/Support/raw_ostream.h>
5051

5152
#include "compat.h"
@@ -349,7 +350,7 @@ bool Annotator::generate(clang::Sema &Sema, bool WasInDatabase)
349350
auto refFilename = it.first;
350351
replace_invalid_filename_chars(refFilename);
351352

352-
std::string filename = projectManager.outputPrefix % "/refs/" % refFilename;
353+
std::string filename = projectManager.outputPrefix % "/refs/" % refFilename % mp_suffix;
353354
#if CLANG_VERSION_MAJOR == 3 && CLANG_VERSION_MINOR <= 5
354355
std::string error;
355356
llvm::raw_fd_ostream myfile(filename.c_str(), error, llvm::sys::fs::F_Append);
@@ -516,7 +517,8 @@ bool Annotator::generate(clang::Sema &Sema, bool WasInDatabase)
516517
'\0' };
517518
llvm::StringRef idxRef(idx, 3); // include the '\0' on purpose
518519
if (saved.find(idxRef) == std::string::npos) {
519-
std::string funcIndexFN = projectManager.outputPrefix % "/fnSearch/" % idx;
520+
std::string funcIndexFN =
521+
projectManager.outputPrefix % "/fnSearch/" % idx % mp_suffix;
520522
#if CLANG_VERSION_MAJOR == 3 && CLANG_VERSION_MINOR <= 5
521523
std::string error;
522524
llvm::raw_fd_ostream funcIndexFile(funcIndexFN.c_str(), error,
@@ -935,7 +937,8 @@ void Annotator::registerMacro(const std::string &ref, clang::SourceLocation refL
935937
}
936938
}
937939

938-
void Annotator::annotateSourceRange(clang::SourceRange range, std::string tag, std::string attributes)
940+
void Annotator::annotateSourceRange(clang::SourceRange range, std::string tag,
941+
std::string attributes)
939942
{
940943
clang::SourceManager &sm = getSourceMgr();
941944
if (!range.getBegin().isFileID()) {

0 commit comments

Comments
 (0)