[PATCH] D133662: [Clang] Change -ftime-trace storing path and support multiple compilation jobs

Jamie Schmeiser via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 19 06:48:12 PDT 2022


jamieschmeiser added a comment.

Great.  Also, something you may want to consider, either as part of or after you land this code.  This really is a specific instance of a more generic problem: setting up option handling for something that saves results in a file for each compilation.  This is equally useful for other things such as listings and could also be used by something like print-changed (which currently just outputs to the stream), opt stats reporting, etc.  This code could be organized as a function (or possibly an object, depends...) that takes  a string for the extension, a lambda/template for the virtual call on whether to add the option to a tool so that off-handling, platform-isms, and where files are saved would all be captured neatly and would be re-usable.  InferTimeTrace and getPath, off-loading, platform-isms would be captured in a generic call that would look something like (in this instance)

  PerFileTraceGenerator(".json",
       [](Tool &T, Args &Args)->bool{ return T->supportsTimeTrace() && Args.hasArg(options::OPT_ftime_trace, options::OPT_ftime_trace_EQ; },
       "-ftime-trace="); 

Each option that needs per file output would just call this function appropriately.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133662



More information about the cfe-commits mailing list