[PATCH] D40489: [clangd] Changed tracing interfaces

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 7 01:34:59 PST 2017


sammccall added inline comments.


================
Comment at: clangd/Trace.cpp:138
     return;
-  if (!Args)
-    Args = llvm::make_unique<json::obj>();
-  T->event(Ctx, "E",
-           Args ? json::obj{{"args", std::move(*Args)}} : json::obj{});
+  assert(Args && "Args can't be null at this point");
+  T->end_event(Ctx, Name, std::move(*Args));
----------------
why not?


================
Comment at: clangd/Trace.h:39
+  /// Called when event with \p Name starts.
+  virtual void begin_event(const ContextData &Ctx, llvm::StringRef Name) = 0;
+  /// Called when event with \p Name ends.
----------------
just call this begin?
Otherwise style is `beginEvent` I think


================
Comment at: clangd/Trace.h:41
+  /// Called when event with \p Name ends.
+  virtual void end_event(const ContextData &Ctx, llvm::StringRef Name,
+                         json::obj &&Args) = 0;
----------------
How is identity represented between begin/end event? via Name doesn't seem robust, so why the need to pass it twice? Does providing different contexts for start/end make sense?

It might be cleaner/more flexible to have

std::function<void(json::obj&&)> begin()
and call the return value to signal end.

This seems likely to be pretty easy for different providers to implement, and is easy to use from Span.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40489





More information about the cfe-commits mailing list