https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/96358

>From bb407e7c6de15d7ed2f0dd645ca2a469ee1f8a8e Mon Sep 17 00:00:00 2001
From: PeterChou1 <peter.c...@mail.utoronto.ca>
Date: Fri, 21 Jun 2024 16:57:30 -0400
Subject: [PATCH 1/4] Revert "Revert "[clang-doc] Add --asset option to
 clang-doc" (#96354)"

This reverts commit bf824d98c06099c50413cd6c957a75b894a8ac26.
---
 .../clang-doc/tool/ClangDocMain.cpp           | 100 ++++++++++++++----
 .../test/clang-doc/single-source-html.cpp     |   2 +
 2 files changed, 83 insertions(+), 19 deletions(-)
 create mode 100644 clang-tools-extra/test/clang-doc/single-source-html.cpp

diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 5517522d7967d..5a43c70a5ebc3 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -81,6 +81,12 @@ static llvm::cl::list<std::string> UserStylesheets(
     llvm::cl::desc("CSS stylesheets to extend the default styles."),
     llvm::cl::cat(ClangDocCategory));
 
+static llvm::cl::opt<std::string> UserAssetPath(
+    "asset",
+    llvm::cl::desc("User supplied asset path to "
+                   "override the default css and js files for html output"),
+    llvm::cl::cat(ClangDocCategory));
+
 static llvm::cl::opt<std::string> SourceRoot("source-root", llvm::cl::desc(R"(
 Directory where processed files are stored.
 Links to definition locations will only be
@@ -127,16 +133,86 @@ std::string getFormatString() {
 // GetMainExecutable (since some platforms don't support taking the
 // address of main, and some platforms can't implement GetMainExecutable
 // without being given the address of a function in the main executable).
-std::string GetExecutablePath(const char *Argv0, void *MainAddr) {
+std::string getExecutablePath(const char *Argv0, void *MainAddr) {
   return llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
 }
 
+llvm::Error getAssetFiles(clang::doc::ClangDocContext &CDCtx) {
+  using DirIt = llvm::sys::fs::directory_iterator;
+  std::error_code FileErr;
+  llvm::SmallString<128> FilePath(UserAssetPath);
+  for (DirIt DirStart = DirIt(UserAssetPath, FileErr),
+                   DirEnd;
+       !FileErr && DirStart != DirEnd; DirStart.increment(FileErr)) {
+    FilePath = DirStart->path();
+    if (llvm::sys::fs::is_regular_file(FilePath)) {
+      if (llvm::sys::path::extension(FilePath) == ".css")
+        CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(),
+                                     std::string(FilePath));
+      else if (llvm::sys::path::extension(FilePath) == ".js")
+        CDCtx.FilesToCopy.emplace_back(FilePath.str());
+    }
+  }
+  if (FileErr)
+    return llvm::createFileError(FilePath, FileErr);
+  return llvm::Error::success();
+}
+
+llvm::Error getDefaultAssetFiles(const char *Argv0,
+                                 clang::doc::ClangDocContext &CDCtx) {
+  void *MainAddr = (void *)(intptr_t)getExecutablePath;
+  std::string ClangDocPath = getExecutablePath(Argv0, MainAddr);
+  llvm::SmallString<128> NativeClangDocPath;
+  llvm::sys::path::native(ClangDocPath, NativeClangDocPath);
+
+  llvm::SmallString<128> AssetsPath;
+  AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath);
+  llvm::sys::path::append(AssetsPath, "..", "share", "clang");
+  llvm::SmallString<128> DefaultStylesheet;
+  llvm::sys::path::native(AssetsPath, DefaultStylesheet);
+  llvm::sys::path::append(DefaultStylesheet,
+                          "clang-doc-default-stylesheet.css");
+  llvm::SmallString<128> IndexJS;
+  llvm::sys::path::native(AssetsPath, IndexJS);
+  llvm::sys::path::append(IndexJS, "index.js");
+
+  llvm::outs() << "Using default asset: " << AssetsPath << "\n";
+
+  if (!llvm::sys::fs::is_regular_file(IndexJS))
+    return llvm::createStringError(llvm::inconvertibleErrorCode(),
+                                   "default index.js file missing at " +
+                                       IndexJS + "\n");
+
+  if (!llvm::sys::fs::is_regular_file(DefaultStylesheet))
+    return llvm::createStringError(
+        llvm::inconvertibleErrorCode(),
+        "default clang-doc-default-stylesheet.css file missing at " +
+            DefaultStylesheet + "\n");
+
+  CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(),
+                               std::string(DefaultStylesheet));
+  CDCtx.FilesToCopy.emplace_back(IndexJS.str());
+
+  return llvm::Error::success();
+}
+
+llvm::Error getHtmlAssetFiles(const char *Argv0,
+                              clang::doc::ClangDocContext &CDCtx) {
+  if (!UserAssetPath.empty() &&
+      !llvm::sys::fs::is_directory(std::string(UserAssetPath)))
+    llvm::outs() << "Asset path supply is not a directory: " << UserAssetPath
+                 << " falling back to default\n";
+  if (llvm::sys::fs::is_directory(std::string(UserAssetPath)))
+    return getAssetFiles(CDCtx);
+  return getDefaultAssetFiles(Argv0, CDCtx);
+}
+
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   std::error_code OK;
 
   const char *Overview =
-    R"(Generates documentation from source code and comments.
+      R"(Generates documentation from source code and comments.
 
 Example usage for files without flags (default):
 
@@ -182,23 +258,9 @@ Example usage for a project using a compile commands 
database:
       {"index.js", "index_json.js"}};
 
   if (Format == "html") {
-    void *MainAddr = (void *)(intptr_t)GetExecutablePath;
-    std::string ClangDocPath = GetExecutablePath(argv[0], MainAddr);
-    llvm::SmallString<128> NativeClangDocPath;
-    llvm::sys::path::native(ClangDocPath, NativeClangDocPath);
-    llvm::SmallString<128> AssetsPath;
-    AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath);
-    llvm::sys::path::append(AssetsPath, "..", "share", "clang");
-    llvm::SmallString<128> DefaultStylesheet;
-    llvm::sys::path::native(AssetsPath, DefaultStylesheet);
-    llvm::sys::path::append(DefaultStylesheet,
-                            "clang-doc-default-stylesheet.css");
-    llvm::SmallString<128> IndexJS;
-    llvm::sys::path::native(AssetsPath, IndexJS);
-    llvm::sys::path::append(IndexJS, "index.js");
-    CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(),
-                                 std::string(DefaultStylesheet));
-    CDCtx.FilesToCopy.emplace_back(IndexJS.str());
+    if (auto Err = getHtmlAssetFiles(argv[0], CDCtx)) {
+      llvm::outs() << "warning: " <<  toString(std::move(Err)) << "\n";
+    }
   }
 
   // Mapping phase
diff --git a/clang-tools-extra/test/clang-doc/single-source-html.cpp 
b/clang-tools-extra/test/clang-doc/single-source-html.cpp
new file mode 100644
index 0000000000000..32f232b9c45a0
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/single-source-html.cpp
@@ -0,0 +1,2 @@
+// RUN: clang-doc --format=html --executor=standalone %s -output=%t/docs | 
FileCheck %s
+// CHECK: Using default asset: {{.*}}{{[\/]}}share{{[\/]}}clang
\ No newline at end of file

>From 7a3677cb910bda1bd95695731bc8309df656d144 Mon Sep 17 00:00:00 2001
From: PeterChou1 <peter.c...@mail.utoronto.ca>
Date: Fri, 21 Jun 2024 18:40:06 -0400
Subject: [PATCH 2/4] status

---
 clang-tools-extra/CMakeLists.txt           |  2 ++
 clang-tools-extra/test-tool/CmakeLists.txt | 15 +++++++++
 clang-tools-extra/test-tool/testfile.cpp   | 36 ++++++++++++++++++++++
 3 files changed, 53 insertions(+)
 create mode 100644 clang-tools-extra/test-tool/CmakeLists.txt
 create mode 100644 clang-tools-extra/test-tool/testfile.cpp

diff --git a/clang-tools-extra/CMakeLists.txt b/clang-tools-extra/CMakeLists.txt
index f6a6b57b5ef0b..4226ac69477d5 100644
--- a/clang-tools-extra/CMakeLists.txt
+++ b/clang-tools-extra/CMakeLists.txt
@@ -49,3 +49,5 @@ if(CLANG_INCLUDE_TESTS)
   add_subdirectory(unittests)
   umbrella_lit_testsuite_end(check-clang-tools)
 endif()
+
+add_subdirectory(test-tool)
\ No newline at end of file
diff --git a/clang-tools-extra/test-tool/CmakeLists.txt 
b/clang-tools-extra/test-tool/CmakeLists.txt
new file mode 100644
index 0000000000000..0fc082f304ada
--- /dev/null
+++ b/clang-tools-extra/test-tool/CmakeLists.txt
@@ -0,0 +1,15 @@
+set(LLVM_LINK_COMPONENTS support)
+
+add_clang_executable(loop-convert
+        testfile.cpp
+)
+
+target_link_libraries(loop-convert
+        PRIVATE
+        clangAST
+        clangASTMatchers
+        clangBasic
+        clangFrontend
+        clangSerialization
+        clangTooling
+)
\ No newline at end of file
diff --git a/clang-tools-extra/test-tool/testfile.cpp 
b/clang-tools-extra/test-tool/testfile.cpp
new file mode 100644
index 0000000000000..ddd9f1017520f
--- /dev/null
+++ b/clang-tools-extra/test-tool/testfile.cpp
@@ -0,0 +1,36 @@
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Support/CommandLine.h"
+#include "clang/Tooling/Execution.h"
+
+using namespace clang::tooling;
+using namespace llvm;
+
+class MapASTVisitor : public clang::ASTConsumer {
+public:
+  explicit MapASTVisitor() {}
+  void HandleTranslationUnit(clang::ASTContext &Context) override {}
+};
+class MyAction : public clang::ASTFrontendAction {
+public:
+  MyAction() {}
+  std::unique_ptr<clang::ASTConsumer>
+  CreateASTConsumer(clang::CompilerInstance &Compiler,
+                    llvm::StringRef InFile) override {
+    return std::make_unique<MapASTVisitor>();
+  }
+};
+
+static llvm::cl::OptionCategory MyToolCategory("my-tool");
+int main(int argc, const char **argv) {
+  const char *Overview = "";
+  auto Executor = clang::tooling::createExecutorFromCommandLineArgs(
+      argc, argv, MyToolCategory, Overview);
+  if (!Executor) {
+    llvm::errs() << toString(Executor.takeError()) << "\n";
+    return 1;
+  }
+  auto Err = Executor->get()->execute(newFrontendActionFactory<MyAction>());
+  return 0;
+}
\ No newline at end of file

>From 678f43219bf5ee9a2eec3f84dfb8f8ab536998e6 Mon Sep 17 00:00:00 2001
From: PeterChou1 <peter.c...@mail.utoronto.ca>
Date: Mon, 24 Jun 2024 15:41:43 -0400
Subject: [PATCH 3/4] [clang][clang-doc] address PR comments refactor --asset
 option

---
 clang-tools-extra/clang-doc/HTMLGenerator.cpp | 13 +++++++++--
 .../clang-doc/Representation.cpp              |  6 ++---
 clang-tools-extra/clang-doc/Representation.h  |  5 +----
 .../clang-doc/tool/CMakeLists.txt             |  2 +-
 .../clang-doc/tool/ClangDocMain.cpp           | 15 ++++++-------
 .../Inputs/basic-project/src/Calculator.cpp   |  4 ----
 .../clang-doc/Inputs/test-assets/test.css     |  3 +++
 .../test/clang-doc/Inputs/test-assets/test.js |  1 +
 clang-tools-extra/test/clang-doc/assets.cpp   | 22 +++++++++++++++++++
 .../test/clang-doc/basic-project.test         | 18 +++++++--------
 .../test/clang-doc/single-source-html.cpp     |  2 --
 .../unittests/clang-doc/HTMLGeneratorTest.cpp |  7 +++++-
 12 files changed, 63 insertions(+), 35 deletions(-)
 create mode 100644 clang-tools-extra/test/clang-doc/Inputs/test-assets/test.css
 create mode 100644 clang-tools-extra/test/clang-doc/Inputs/test-assets/test.js
 create mode 100644 clang-tools-extra/test/clang-doc/assets.cpp
 delete mode 100644 clang-tools-extra/test/clang-doc/single-source-html.cpp

diff --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp 
b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index c0faf5f7e8fd9..43277ecd77109 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -289,9 +289,18 @@ genStylesheetsHTML(StringRef InfoPath, const 
ClangDocContext &CDCtx) {
 static std::vector<std::unique_ptr<TagNode>>
 genJsScriptsHTML(StringRef InfoPath, const ClangDocContext &CDCtx) {
   std::vector<std::unique_ptr<TagNode>> Out;
+
+  // index_json.js is part of every generated HTML file
+  SmallString<128> IndexJSONPath = computeRelativePath("", InfoPath);
+  auto IndexJSONNode = std::make_unique<TagNode>(HTMLTag::TAG_SCRIPT);
+  llvm::sys::path::append(IndexJSONPath, "index_json.js");
+  llvm::sys::path::native(IndexJSONPath, llvm::sys::path::Style::posix);
+  IndexJSONNode->Attributes.emplace_back("src", std::string(IndexJSONPath));
+  Out.emplace_back(std::move(IndexJSONNode));
+
   for (const auto &FilePath : CDCtx.JsScripts) {
-    auto ScriptNode = std::make_unique<TagNode>(HTMLTag::TAG_SCRIPT);
     SmallString<128> ScriptPath = computeRelativePath("", InfoPath);
+    auto ScriptNode = std::make_unique<TagNode>(HTMLTag::TAG_SCRIPT);
     llvm::sys::path::append(ScriptPath, llvm::sys::path::filename(FilePath));
     // Paths in HTML must be in posix-style
     llvm::sys::path::native(ScriptPath, llvm::sys::path::Style::posix);
@@ -1069,7 +1078,7 @@ llvm::Error 
HTMLGenerator::createResources(ClangDocContext &CDCtx) {
     if (Err)
       return Err;
   }
-  for (const auto &FilePath : CDCtx.FilesToCopy) {
+  for (const auto &FilePath : CDCtx.JsScripts) {
     Err = CopyFile(FilePath, CDCtx.OutDirectory);
     if (Err)
       return Err;
diff --git a/clang-tools-extra/clang-doc/Representation.cpp 
b/clang-tools-extra/clang-doc/Representation.cpp
index 2afff2929cf79..d08afbb962189 100644
--- a/clang-tools-extra/clang-doc/Representation.cpp
+++ b/clang-tools-extra/clang-doc/Representation.cpp
@@ -368,11 +368,9 @@ ClangDocContext::ClangDocContext(tooling::ExecutionContext 
*ECtx,
                                  StringRef ProjectName, bool PublicOnly,
                                  StringRef OutDirectory, StringRef SourceRoot,
                                  StringRef RepositoryUrl,
-                                 std::vector<std::string> UserStylesheets,
-                                 std::vector<std::string> JsScripts)
+                                 std::vector<std::string> UserStylesheets)
     : ECtx(ECtx), ProjectName(ProjectName), PublicOnly(PublicOnly),
-      OutDirectory(OutDirectory), UserStylesheets(UserStylesheets),
-      JsScripts(JsScripts) {
+      OutDirectory(OutDirectory), UserStylesheets(UserStylesheets) {
   llvm::SmallString<128> SourceRootDir(SourceRoot);
   if (SourceRoot.empty())
     // If no SourceRoot was provided the current path is used as the default
diff --git a/clang-tools-extra/clang-doc/Representation.h 
b/clang-tools-extra/clang-doc/Representation.h
index a6b144eb7fa2a..d70c279f7a2bd 100644
--- a/clang-tools-extra/clang-doc/Representation.h
+++ b/clang-tools-extra/clang-doc/Representation.h
@@ -482,8 +482,7 @@ struct ClangDocContext {
   ClangDocContext(tooling::ExecutionContext *ECtx, StringRef ProjectName,
                   bool PublicOnly, StringRef OutDirectory, StringRef 
SourceRoot,
                   StringRef RepositoryUrl,
-                  std::vector<std::string> UserStylesheets,
-                  std::vector<std::string> JsScripts);
+                  std::vector<std::string> UserStylesheets);
   tooling::ExecutionContext *ECtx;
   std::string ProjectName; // Name of project clang-doc is documenting.
   bool PublicOnly; // Indicates if only public declarations are documented.
@@ -498,8 +497,6 @@ struct ClangDocContext {
   std::vector<std::string> UserStylesheets;
   // JavaScript files that will be imported in allHTML file.
   std::vector<std::string> JsScripts;
-  // Other files that should be copied to OutDirectory, besides 
UserStylesheets.
-  std::vector<std::string> FilesToCopy;
   Index Idx;
 };
 
diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt 
b/clang-tools-extra/clang-doc/tool/CMakeLists.txt
index 4944251245c6b..4d0e637d4a0dc 100644
--- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt
+++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt
@@ -25,7 +25,7 @@ set(assets
 )
 
 set(asset_dir "${CMAKE_CURRENT_SOURCE_DIR}/../assets")
-set(resource_dir "${CMAKE_BINARY_DIR}/share/clang")
+set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc")
 set(out_files)
 
 function(copy_files_to_dst src_dir dst_dir file)
diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 5a43c70a5ebc3..6198a6e0cdcc3 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -150,7 +150,7 @@ llvm::Error getAssetFiles(clang::doc::ClangDocContext 
&CDCtx) {
         CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(),
                                      std::string(FilePath));
       else if (llvm::sys::path::extension(FilePath) == ".js")
-        CDCtx.FilesToCopy.emplace_back(FilePath.str());
+        CDCtx.JsScripts.emplace_back(FilePath.str());
     }
   }
   if (FileErr)
@@ -167,7 +167,7 @@ llvm::Error getDefaultAssetFiles(const char *Argv0,
 
   llvm::SmallString<128> AssetsPath;
   AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath);
-  llvm::sys::path::append(AssetsPath, "..", "share", "clang");
+  llvm::sys::path::append(AssetsPath, "..", "share", "clang-doc");
   llvm::SmallString<128> DefaultStylesheet;
   llvm::sys::path::native(AssetsPath, DefaultStylesheet);
   llvm::sys::path::append(DefaultStylesheet,
@@ -176,8 +176,6 @@ llvm::Error getDefaultAssetFiles(const char *Argv0,
   llvm::sys::path::native(AssetsPath, IndexJS);
   llvm::sys::path::append(IndexJS, "index.js");
 
-  llvm::outs() << "Using default asset: " << AssetsPath << "\n";
-
   if (!llvm::sys::fs::is_regular_file(IndexJS))
     return llvm::createStringError(llvm::inconvertibleErrorCode(),
                                    "default index.js file missing at " +
@@ -191,7 +189,7 @@ llvm::Error getDefaultAssetFiles(const char *Argv0,
 
   CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(),
                                std::string(DefaultStylesheet));
-  CDCtx.FilesToCopy.emplace_back(IndexJS.str());
+  CDCtx.JsScripts.emplace_back(IndexJS.str());
 
   return llvm::Error::success();
 }
@@ -254,12 +252,13 @@ Example usage for a project using a compile commands 
database:
       OutDirectory,
       SourceRoot,
       RepositoryUrl,
-      {UserStylesheets.begin(), UserStylesheets.end()},
-      {"index.js", "index_json.js"}};
+      {UserStylesheets.begin(), UserStylesheets.end()}
+  };
 
   if (Format == "html") {
     if (auto Err = getHtmlAssetFiles(argv[0], CDCtx)) {
-      llvm::outs() << "warning: " <<  toString(std::move(Err)) << "\n";
+      llvm::errs() << toString(std::move(Err)) << "\n";
+      return 1;
     }
   }
 
diff --git 
a/clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Calculator.cpp 
b/clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Calculator.cpp
index df1778c3b9d55..64f31dbf13d87 100644
--- a/clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Calculator.cpp
+++ b/clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Calculator.cpp
@@ -1,5 +1,4 @@
 #include "Calculator.h"
-#include <stdexcept>
 
 int Calculator::add(int a, int b) {
     return a + b;
@@ -14,8 +13,5 @@ int Calculator::multiply(int a, int b) {
 }
 
 double Calculator::divide(int a, int b) {
-    if (b == 0) {
-        throw std::invalid_argument("Division by zero");
-    }
     return static_cast<double>(a) / b;
 }
diff --git a/clang-tools-extra/test/clang-doc/Inputs/test-assets/test.css 
b/clang-tools-extra/test/clang-doc/Inputs/test-assets/test.css
new file mode 100644
index 0000000000000..5c5532659be5e
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/Inputs/test-assets/test.css
@@ -0,0 +1,3 @@
+body {
+    padding: 0;
+}
\ No newline at end of file
diff --git a/clang-tools-extra/test/clang-doc/Inputs/test-assets/test.js 
b/clang-tools-extra/test/clang-doc/Inputs/test-assets/test.js
new file mode 100644
index 0000000000000..06f320c59b9b0
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/Inputs/test-assets/test.js
@@ -0,0 +1 @@
+console.log("Hello, world!");
\ No newline at end of file
diff --git a/clang-tools-extra/test/clang-doc/assets.cpp 
b/clang-tools-extra/test/clang-doc/assets.cpp
new file mode 100644
index 0000000000000..4b439f0048537
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/assets.cpp
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t && mkdir -p %t/docs %t/build
+// RUN: clang-doc --format=html --output=%t/docs --asset=%S/Inputs/test-assets 
--executor=standalone %s --output=%t/docs
+// RUN: FileCheck %s -input-file=%t/docs/index.html -check-prefix=INDEX
+// RUN: FileCheck %s -input-file=%t/docs/test.css -check-prefix=CSS
+// RUN: FileCheck %s -input-file=%t/docs/test.js -check-prefix=JS
+
+// INDEX: <!DOCTYPE html>
+// INDEX-NEXT: <meta charset="utf-8"/>
+// INDEX-NEXT: <title>Index</title>
+// INDEX-NEXT: <link rel="stylesheet" href="test.css"/>
+// INDEX-NEXT: <script src="index_json.js"></script>
+// INDEX-NEXT: <script src="test.js"></script>
+// INDEX-NEXT: <header id="project-title"></header>
+// INDEX-NEXT: <main>
+// INDEX-NEXT:   <div id="sidebar-left" path="" class="col-xs-6 col-sm-3 
col-md-2 sidebar sidebar-offcanvas-left" style="flex: 0 100%;"></div>
+// INDEX-NEXT: </main>
+
+// CSS: body {
+// CSS-NEXT:     padding: 0;
+// CSS-NEXT: }
+
+// JS: console.log("Hello, world!");
\ No newline at end of file
diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 0898acaea3a33..3118c20495987 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -57,8 +57,8 @@
 // HTML-SHAPE-NEXT: <meta charset="utf-8"/>
 // HTML-SHAPE-NEXT: <title>class Shape</title>
 // HTML-SHAPE-NEXT: <link rel="stylesheet" 
href="../clang-doc-default-stylesheet.css"/>
-// HTML-SHAPE-NEXT: <script src="../index.js"></script>
-// HTML-SHAPE-NEXT: <script src="../index_json.js"></script>
+// HTML-SHAPE-NEXT: <script src="{{.*}}index_json.js"></script>
+// HTML-SHAPE-NEXT: <script src="{{.*}}index.js"></script>
 // HTML-SHAPE-NEXT: <header id="project-title"></header>
 // HTML-SHAPE-NEXT: <main>
 // HTML-SHAPE-NEXT:   <div id="sidebar-left" path="GlobalNamespace" 
class="col-xs-6 col-sm-3 col-md-2 sidebar sidebar-offcanvas-left"></div>
@@ -122,8 +122,8 @@
 // HTML-CALC-NEXT: <meta charset="utf-8"/>
 // HTML-CALC-NEXT: <title>class Calculator</title>
 // HTML-CALC-NEXT: <link rel="stylesheet" 
href="{{.*}}clang-doc-default-stylesheet.css"/>
-// HTML-CALC-NEXT: <script src="{{.*}}index.js"></script>
 // HTML-CALC-NEXT: <script src="{{.*}}index_json.js"></script>
+// HTML-CALC-NEXT: <script src="{{.*}}index.js"></script>
 // HTML-CALC-NEXT: <header id="project-title"></header>
 // HTML-CALC-NEXT: <main>
 // HTML-CALC-NEXT:   <div id="sidebar-left" path="GlobalNamespace" 
class="col-xs-6 col-sm-3 col-md-2 sidebar sidebar-offcanvas-left"></div>
@@ -139,25 +139,25 @@
 // HTML-CALC-NEXT:     <div>
 // HTML-CALC-NEXT:       <h3 id="{{([0-9A-F]{40})}}">add</h3>
 // HTML-CALC-NEXT:       <p>public int add(int a, int b)</p>
-// HTML-CALC-NEXT:       <p>Defined at line 4 of file {{.*}}Calculator.cpp</p>
+// HTML-CALC-NEXT:       <p>Defined at line 3 of file {{.*}}Calculator.cpp</p>
 // HTML-CALC-NEXT:       <div>
 // HTML-CALC-NEXT:         <div></div>
 // HTML-CALC-NEXT:       </div>
 // HTML-CALC-NEXT:       <h3 id="{{([0-9A-F]{40})}}">subtract</h3>
 // HTML-CALC-NEXT:       <p>public int subtract(int a, int b)</p>
-// HTML-CALC-NEXT:       <p>Defined at line 8 of file {{.*}}Calculator.cpp</p>
+// HTML-CALC-NEXT:       <p>Defined at line 7 of file {{.*}}Calculator.cpp</p>
 // HTML-CALC-NEXT:       <div>
 // HTML-CALC-NEXT:         <div></div>
 // HTML-CALC-NEXT:       </div>
 // HTML-CALC-NEXT:       <h3 id="{{([0-9A-F]{40})}}">multiply</h3>
 // HTML-CALC-NEXT:       <p>public int multiply(int a, int b)</p>
-// HTML-CALC-NEXT:       <p>Defined at line 12 of file {{.*}}Calculator.cpp</p>
+// HTML-CALC-NEXT:       <p>Defined at line 11 of file {{.*}}Calculator.cpp</p>
 // HTML-CALC-NEXT:       <div>
 // HTML-CALC-NEXT:         <div></div>
 // HTML-CALC-NEXT:       </div>
 // HTML-CALC-NEXT:       <h3 id="{{([0-9A-F]{40})}}">divide</h3>
 // HTML-CALC-NEXT:       <p>public double divide(int a, int b)</p>
-// HTML-CALC-NEXT:       <p>Defined at line 16 of file {{.*}}Calculator.cpp</p>
+// HTML-CALC-NEXT:       <p>Defined at line 15 of file {{.*}}Calculator.cpp</p>
 // HTML-CALC-NEXT:       <div>
 // HTML-CALC-NEXT:         <div></div>
 // HTML-CALC-NEXT:       </div>
@@ -200,8 +200,8 @@
 // HTML-RECTANGLE-NEXT: <meta charset="utf-8"/>
 // HTML-RECTANGLE-NEXT: <title>class Rectangle</title>
 // HTML-RECTANGLE-NEXT: <link rel="stylesheet" 
href="{{.*}}clang-doc-default-stylesheet.css"/>
-// HTML-RECTANGLE-NEXT: <script src="{{.*}}index.js"></script>
 // HTML-RECTANGLE-NEXT: <script src="{{.*}}index_json.js"></script>
+// HTML-RECTANGLE-NEXT: <script src="{{.*}}index.js"></script>
 // HTML-RECTANGLE-NEXT: <header id="project-title"></header>
 // HTML-RECTANGLE-NEXT: <main>
 // HTML-RECTANGLE-NEXT:   <div id="sidebar-left" path="GlobalNamespace" 
class="col-xs-6 col-sm-3 col-md-2 sidebar sidebar-offcanvas-left"></div>
@@ -281,8 +281,8 @@
 // HTML-CIRCLE-NEXT: <meta charset="utf-8"/>
 // HTML-CIRCLE-NEXT: <title>class Circle</title>
 // HTML-CIRCLE-NEXT: <link rel="stylesheet" 
href="{{.*}}clang-doc-default-stylesheet.css"/>
-// HTML-CIRCLE-NEXT: <script src="{{.*}}index.js"></script>
 // HTML-CIRCLE-NEXT: <script src="{{.*}}index_json.js"></script>
+// HTML-CIRCLE-NEXT: <script src="{{.*}}index.js"></script>
 // HTML-CIRCLE-NEXT: <header id="project-title"></header>
 // HTML-CIRCLE-NEXT: <main>
 // HTML-CIRCLE-NEXT:   <div id="sidebar-left" path="GlobalNamespace" 
class="col-xs-6 col-sm-3 col-md-2 sidebar sidebar-offcanvas-left"></div>
diff --git a/clang-tools-extra/test/clang-doc/single-source-html.cpp 
b/clang-tools-extra/test/clang-doc/single-source-html.cpp
deleted file mode 100644
index 32f232b9c45a0..0000000000000
--- a/clang-tools-extra/test/clang-doc/single-source-html.cpp
+++ /dev/null
@@ -1,2 +0,0 @@
-// RUN: clang-doc --format=html --executor=standalone %s -output=%t/docs | 
FileCheck %s
-// CHECK: Using default asset: {{.*}}{{[\/]}}share{{[\/]}}clang
\ No newline at end of file
diff --git a/clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp 
b/clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
index 9aabb1ed30e42..e4a7340318b93 100644
--- a/clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ b/clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -30,7 +30,7 @@ ClangDocContext
 getClangDocContext(std::vector<std::string> UserStylesheets = {},
                    StringRef RepositoryUrl = "") {
   ClangDocContext CDCtx{
-      {}, "test-project", {}, {}, {}, RepositoryUrl, UserStylesheets, {}};
+      {}, "test-project", {}, {}, {}, RepositoryUrl, UserStylesheets};
   CDCtx.UserStylesheets.insert(
       CDCtx.UserStylesheets.begin(),
       "../share/clang/clang-doc-default-stylesheet.css");
@@ -66,6 +66,7 @@ TEST(HTMLGeneratorTest, emitNamespaceHTML) {
 <title>namespace Namespace</title>
 <link rel="stylesheet" href="../clang-doc-default-stylesheet.css"/>
 <link rel="stylesheet" href="../user-provided-stylesheet.css"/>
+<script src="../index_json.js"></script>
 <script src="../index.js"></script>
 <header id="project-title">test-project</header>
 <main>
@@ -176,6 +177,7 @@ TEST(HTMLGeneratorTest, emitRecordHTML) {
 <meta charset="utf-8"/>
 <title>class r</title>
 <link rel="stylesheet" href="../../../clang-doc-default-stylesheet.css"/>
+<script src="../../../index_json.js"></script>
 <script src="../../../index.js"></script>
 <header id="project-title">test-project</header>
 <main>
@@ -290,6 +292,7 @@ TEST(HTMLGeneratorTest, emitFunctionHTML) {
 <meta charset="utf-8"/>
 <title></title>
 <link rel="stylesheet" href="clang-doc-default-stylesheet.css"/>
+<script src="index_json.js"></script>
 <script src="index.js"></script>
 <header id="project-title">test-project</header>
 <main>
@@ -337,6 +340,7 @@ TEST(HTMLGeneratorTest, emitEnumHTML) {
 <meta charset="utf-8"/>
 <title></title>
 <link rel="stylesheet" href="clang-doc-default-stylesheet.css"/>
+<script src="index_json.js"></script>
 <script src="index.js"></script>
 <header id="project-title">test-project</header>
 <main>
@@ -422,6 +426,7 @@ TEST(HTMLGeneratorTest, emitCommentHTML) {
 <meta charset="utf-8"/>
 <title></title>
 <link rel="stylesheet" href="clang-doc-default-stylesheet.css"/>
+<script src="index_json.js"></script>
 <script src="index.js"></script>
 <header id="project-title">test-project</header>
 <main>

>From 76ce46ef6232afed395b88dbbfa8304b695dfcf3 Mon Sep 17 00:00:00 2001
From: PeterChou1 <peter.c...@mail.utoronto.ca>
Date: Mon, 24 Jun 2024 15:44:41 -0400
Subject: [PATCH 4/4] [clang][clang-doc] remove test tool

---
 clang-tools-extra/CMakeLists.txt           |  4 +--
 clang-tools-extra/test-tool/CmakeLists.txt | 15 ---------
 clang-tools-extra/test-tool/testfile.cpp   | 36 ----------------------
 3 files changed, 1 insertion(+), 54 deletions(-)
 delete mode 100644 clang-tools-extra/test-tool/CmakeLists.txt
 delete mode 100644 clang-tools-extra/test-tool/testfile.cpp

diff --git a/clang-tools-extra/CMakeLists.txt b/clang-tools-extra/CMakeLists.txt
index 4226ac69477d5..ab83671b88ba8 100644
--- a/clang-tools-extra/CMakeLists.txt
+++ b/clang-tools-extra/CMakeLists.txt
@@ -48,6 +48,4 @@ if(CLANG_INCLUDE_TESTS)
   add_subdirectory(test)
   add_subdirectory(unittests)
   umbrella_lit_testsuite_end(check-clang-tools)
-endif()
-
-add_subdirectory(test-tool)
\ No newline at end of file
+endif()
\ No newline at end of file
diff --git a/clang-tools-extra/test-tool/CmakeLists.txt 
b/clang-tools-extra/test-tool/CmakeLists.txt
deleted file mode 100644
index 0fc082f304ada..0000000000000
--- a/clang-tools-extra/test-tool/CmakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-set(LLVM_LINK_COMPONENTS support)
-
-add_clang_executable(loop-convert
-        testfile.cpp
-)
-
-target_link_libraries(loop-convert
-        PRIVATE
-        clangAST
-        clangASTMatchers
-        clangBasic
-        clangFrontend
-        clangSerialization
-        clangTooling
-)
\ No newline at end of file
diff --git a/clang-tools-extra/test-tool/testfile.cpp 
b/clang-tools-extra/test-tool/testfile.cpp
deleted file mode 100644
index ddd9f1017520f..0000000000000
--- a/clang-tools-extra/test-tool/testfile.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "clang/Frontend/FrontendActions.h"
-#include "clang/Tooling/CommonOptionsParser.h"
-#include "clang/Tooling/Tooling.h"
-#include "llvm/Support/CommandLine.h"
-#include "clang/Tooling/Execution.h"
-
-using namespace clang::tooling;
-using namespace llvm;
-
-class MapASTVisitor : public clang::ASTConsumer {
-public:
-  explicit MapASTVisitor() {}
-  void HandleTranslationUnit(clang::ASTContext &Context) override {}
-};
-class MyAction : public clang::ASTFrontendAction {
-public:
-  MyAction() {}
-  std::unique_ptr<clang::ASTConsumer>
-  CreateASTConsumer(clang::CompilerInstance &Compiler,
-                    llvm::StringRef InFile) override {
-    return std::make_unique<MapASTVisitor>();
-  }
-};
-
-static llvm::cl::OptionCategory MyToolCategory("my-tool");
-int main(int argc, const char **argv) {
-  const char *Overview = "";
-  auto Executor = clang::tooling::createExecutorFromCommandLineArgs(
-      argc, argv, MyToolCategory, Overview);
-  if (!Executor) {
-    llvm::errs() << toString(Executor.takeError()) << "\n";
-    return 1;
-  }
-  auto Err = Executor->get()->execute(newFrontendActionFactory<MyAction>());
-  return 0;
-}
\ No newline at end of file

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to