@@ -105,11 +105,6 @@ Turn on time profiler. Generates clang-doc-tracing.json)"),
105
105
llvm::cl::init(false ),
106
106
llvm::cl::cat(ClangDocCategory));
107
107
108
- static llvm::cl::opt<int > FTimeGranularity (" ftime-gran" , llvm::cl::desc(R"(
109
- Specify granularity for ftime-trace defaults to 200)" ),
110
- llvm::cl::init(200 ),
111
- llvm::cl::cat(ClangDocCategory));
112
-
113
108
enum OutputFormatTy {
114
109
md,
115
110
yaml,
@@ -242,9 +237,9 @@ Example usage for a project using a compile commands database:
242
237
243
238
// turns on ftime trace profiling
244
239
if (FTimeTrace)
245
- llvm::timeTraceProfilerInitialize (FTimeGranularity , " clang-doc" );
240
+ llvm::timeTraceProfilerInitialize (200 , " clang-doc" );
246
241
247
- llvm::TimeTraceScope (" clang-doc " , " main " );
242
+ llvm::TimeTraceScope (" main " , " clang-doc " );
248
243
249
244
// Fail early if an invalid format was provided.
250
245
std::string Format = getFormatString ();
@@ -266,12 +261,11 @@ Example usage for a project using a compile commands database:
266
261
Executor->get ()->getExecutionContext (),
267
262
ProjectName,
268
263
PublicOnly,
269
- FTimeTrace,
270
- FTimeGranularity,
271
264
OutDirectory,
272
265
SourceRoot,
273
266
RepositoryUrl,
274
- {UserStylesheets.begin (), UserStylesheets.end ()}};
267
+ {UserStylesheets.begin (), UserStylesheets.end ()},
268
+ FTimeTrace};
275
269
276
270
if (Format == " html" ) {
277
271
if (auto Err = getHtmlAssetFiles (argv[0 ], CDCtx)) {
@@ -280,7 +274,7 @@ Example usage for a project using a compile commands database:
280
274
}
281
275
}
282
276
283
- llvm::timeTraceProfilerBegin (" mapping phase " , " mapping " );
277
+ llvm::timeTraceProfilerBegin (" mapping decls " , " clang-doc " );
284
278
// Mapping phase
285
279
llvm::outs () << " Mapping decls...\n " ;
286
280
auto Err =
@@ -300,7 +294,7 @@ Example usage for a project using a compile commands database:
300
294
// Collect values into output by key.
301
295
// In ToolResults, the Key is the hashed USR and the value is the
302
296
// bitcode-encoded representation of the Info object.
303
- llvm::timeTraceProfilerBegin (" clang-doc " , " collection phase " );
297
+ llvm::timeTraceProfilerBegin (" collecting infos " , " clang-doc " );
304
298
llvm::outs () << " Collecting infos...\n " ;
305
299
llvm::StringMap<std::vector<StringRef>> USRToBitcode;
306
300
Executor->get ()->getToolResults ()->forEachResult (
@@ -316,7 +310,7 @@ Example usage for a project using a compile commands database:
316
310
llvm::StringMap<std::unique_ptr<doc::Info>> USRToInfo;
317
311
318
312
// First reducing phase (reduce all decls into one info per decl).
319
- llvm::timeTraceProfilerBegin (" reduction phase " , " reducing " );
313
+ llvm::timeTraceProfilerBegin (" reducing infos " , " clang-doc " );
320
314
llvm::outs () << " Reducing " << USRToBitcode.size () << " infos...\n " ;
321
315
std::atomic<bool > Error;
322
316
Error = false ;
@@ -326,9 +320,9 @@ Example usage for a project using a compile commands database:
326
320
for (auto &Group : USRToBitcode) {
327
321
Pool.async ([&]() {
328
322
if (FTimeTrace)
329
- llvm::timeTraceProfilerInitialize (FTimeGranularity , " clang-doc" );
323
+ llvm::timeTraceProfilerInitialize (200 , " clang-doc" );
330
324
331
- llvm::timeTraceProfilerBegin (" decoding bitcode phase " , " decoding" );
325
+ llvm::timeTraceProfilerBegin (" decoding bitcode" , " decoding" );
332
326
std::vector<std::unique_ptr<doc::Info>> Infos;
333
327
for (auto &Bitcode : Group.getValue ()) {
334
328
llvm::BitstreamCursor Stream (Bitcode);
@@ -344,7 +338,7 @@ Example usage for a project using a compile commands database:
344
338
}
345
339
llvm::timeTraceProfilerEnd ();
346
340
347
- llvm::timeTraceProfilerBegin (" merging bitcode phase " , " merging " );
341
+ llvm::timeTraceProfilerBegin (" merging infos " , " clang-doc " );
348
342
auto Reduced = doc::mergeInfos (Infos);
349
343
if (!Reduced) {
350
344
llvm::errs () << llvm::toString (Reduced.takeError ());
@@ -358,6 +352,7 @@ Example usage for a project using a compile commands database:
358
352
clang::doc::Generator::addInfoToIndex (CDCtx.Idx , Reduced.get ().get ());
359
353
}
360
354
// Save in the result map (needs a lock due to threaded access).
355
+
361
356
{
362
357
std::lock_guard<llvm::sys::Mutex> Guard (USRToInfoMutex);
363
358
USRToInfo[Group.getKey ()] = std::move (Reduced.get ());
@@ -374,7 +369,7 @@ Example usage for a project using a compile commands database:
374
369
if (Error)
375
370
return 1 ;
376
371
377
- llvm::timeTraceProfilerBegin (" generating phase " , " generating " );
372
+ llvm::timeTraceProfilerBegin (" generating docs " , " clang-doc " );
378
373
// Ensure the root output directory exists.
379
374
if (std::error_code Err = llvm::sys::fs::create_directories (OutDirectory);
380
375
Err != std::error_code ()) {
@@ -401,11 +396,11 @@ Example usage for a project using a compile commands database:
401
396
std::error_code EC;
402
397
llvm::raw_fd_ostream OS (" clang-doc-tracing.json" , EC,
403
398
llvm::sys::fs::OF_Text);
404
- if (!EC) {
399
+ if (!EC)
405
400
llvm::timeTraceProfilerWrite (OS);
406
- } else {
407
- llvm::errs () << " Error opening file: " << EC. message () << " \n " ;
408
- }
401
+ else
402
+ return 1 ;
403
+
409
404
}
410
405
return 0 ;
411
406
}
0 commit comments