Skip to content

Commit 45b366a

Browse files
committed
add time trace scope
1 parent 55397cc commit 45b366a

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

clang-tools-extra/clang-doc/Generators.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,27 +84,33 @@ Error MustacheGenerator::generateDocumentation(
8484
return JSONGenerator.takeError();
8585
}
8686

87-
SmallString<128> JSONPath;
88-
sys::path::native(RootDir.str() + "/json", JSONPath);
87+
SmallString<128> JSONDirPath(RootDir);
88+
SmallString<128> DocsDirPath(RootDir);
89+
{
90+
TimeTraceScope TS("Create Output Directories");
91+
sys::path::append(JSONDirPath, "json");
92+
if (auto EC = sys::fs::create_directories(JSONDirPath))
93+
return createFileError(JSONDirPath, EC);
94+
sys::path::append(DocsDirPath, DirName);
95+
if (auto EC = sys::fs::create_directories(DocsDirPath))
96+
return createFileError(DocsDirPath, EC);
97+
}
8998

9099
{
91100
llvm::TimeTraceScope TS("Iterate JSON files");
92101
std::error_code EC;
93-
sys::fs::recursive_directory_iterator JSONIter(JSONPath, EC);
102+
sys::fs::recursive_directory_iterator JSONIter(JSONDirPath, EC);
94103
std::vector<json::Value> JSONFiles;
95104
JSONFiles.reserve(Infos.size());
96105
if (EC)
97106
return createStringError("Failed to create directory iterator.");
98107

99-
SmallString<128> DocsDirPath(RootDir.str() + '/' + DirName);
100-
sys::path::native(DocsDirPath);
101-
if (auto EC = sys::fs::create_directories(DocsDirPath))
102-
return createFileError(DocsDirPath, EC);
103108
while (JSONIter != sys::fs::recursive_directory_iterator()) {
104109
// create the same directory structure in the docs format dir
105110
if (JSONIter->type() == sys::fs::file_type::directory_file) {
106111
SmallString<128> DocsClonedPath(JSONIter->path());
107-
sys::path::replace_path_prefix(DocsClonedPath, JSONPath, DocsDirPath);
112+
sys::path::replace_path_prefix(DocsClonedPath, JSONDirPath,
113+
DocsDirPath);
108114
if (auto EC = sys::fs::create_directories(DocsClonedPath)) {
109115
return createFileError(DocsClonedPath, EC);
110116
}
@@ -134,7 +140,7 @@ Error MustacheGenerator::generateDocumentation(
134140

135141
std::error_code FileErr;
136142
SmallString<128> DocsFilePath(JSONIter->path());
137-
sys::path::replace_path_prefix(DocsFilePath, JSONPath, DocsDirPath);
143+
sys::path::replace_path_prefix(DocsFilePath, JSONDirPath, DocsDirPath);
138144
sys::path::replace_extension(DocsFilePath, DirName);
139145
raw_fd_ostream InfoOS(DocsFilePath, FileErr, sys::fs::OF_None);
140146
if (FileErr)

clang-tools-extra/test/clang-doc/DR-131697.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: rm -rf %t && mkdir -p %t
22
// RUN: split-file %s %t
33
// RUN: clang-doc -format=html %t/compile_commands.json %t/main.cpp
4+
// RUN: clang-doc -format=mustache %t/compile_commands.json %t/main.cpp
45

56
//--- main.cpp
67

0 commit comments

Comments
 (0)