Author: Brett Wilson
Date: 2022-08-12T18:37:23Z
New Revision: 75c7e79464a3e77043571d187cd8019370326bcb

URL: 
https://github.com/llvm/llvm-project/commit/75c7e79464a3e77043571d187cd8019370326bcb
DIFF: 
https://github.com/llvm/llvm-project/commit/75c7e79464a3e77043571d187cd8019370326bcb.diff

LOG: [clang-doc] Fix assert on startup

When using `clang-doc --format=html` it will crash on startup because of an 
assertion doing a self-assignment of a `SmallString`. This patch removes the 
self-assignment by creating an intermediate copy.

Reviewed By: paulkirth

Differential Revision: https://reviews.llvm.org/D131793

Added: 
    

Modified: 
    clang-tools-extra/clang-doc/tool/ClangDocMain.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index fc22e55edfb1a..7531f219a6a40 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -231,9 +231,10 @@ Example usage for a project using a compile commands 
database:
   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;
-    llvm::sys::path::native(ClangDocPath, AssetsPath);
-    AssetsPath = llvm::sys::path::parent_path(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);


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

Reply via email to