[PATCH] D58675: [clang] Adds `-ftime-trace` option to clang that produces Chrome `chrome://tracing` compatible JSON profiling output dumps

Anton Afanasyev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 27 14:56:58 PDT 2019


anton-afanasyev marked an inline comment as done.
anton-afanasyev added inline comments.


================
Comment at: clang/lib/Parse/ParseAST.cpp:154
   if (HaveLexer) {
+    llvm::TimeTraceScope TimeScope("Frontend", StringRef(""));
     P.Initialize();
----------------
takuto.ikuta wrote:
> anton-afanasyev wrote:
> > takuto.ikuta wrote:
> > > Remove StringRef?
> > I use `StringRef("")` to explicitly cast to one of overloaded `TimeScope(StringRef, StringRef)` and `TimeScope(StringRef, fuction_ref(std::string()))`.
> I think function_ref(std::string()) does not have constructor receiving StringRef, so I feel explicit cast is redundant.
> 
The compiler tries to use function_ref<..>(Callable&&, ...) constructor and instantiates `function_ref<std::string()>::function_ref<char const (&)[1]>`, so one gets error like:
```
error: call to constructor of 'llvm::TimeTraceScope' is ambiguous
    llvm::TimeTraceScope TimeScope("Frontend", "");
                         ^         ~~~~~~~~~~~~~~
.../include/llvm/Support/TimeProfiler.h:54:3: note: candidate constructor
  TimeTraceScope(StringRef Name, StringRef Detail) {
  ^
.../include/llvm/Support/TimeProfiler.h:58:3: note: candidate constructor
  TimeTraceScope(StringRef Name, llvm::function_ref<std::string()> Detail) {
  ^

```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58675/new/

https://reviews.llvm.org/D58675





More information about the cfe-commits mailing list