[clang-tools-extra] [clang-doc] Add --asset option to clang-doc (PR #94717)

Paul Kirth via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 7 09:37:10 PDT 2024


================
@@ -131,12 +137,55 @@ std::string GetExecutablePath(const char *Argv0, void *MainAddr) {
   return llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
 }
 
+void GetAssetFiles(clang::doc::ClangDocContext &CDCtx) {
+  std::error_code Code;
+  for (auto DirIt = llvm::sys::fs::directory_iterator(
+                std::string(UserAssetPath), Code),
----------------
ilovepi wrote:

Do you need to construct an std::string? Anything convertible to `Twine` should work, like a `StringRef`, `SmallString`, `const char*`, etc. Since the `UserAssetPath` can't be changed, and won't be deallocated (it's a static variable), I don't think you need to worry about lifetimes, which are the big concern when the type is not owning. Here its safe, IMO. 

https://github.com/llvm/llvm-project/pull/94717


More information about the cfe-commits mailing list