Skip to content

Commit 75c7e79

Browse files
brettwilovepi
authored andcommitted
[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
1 parent 8dd07e3 commit 75c7e79

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,10 @@ Example usage for a project using a compile commands database:
231231
if (Format == "html") {
232232
void *MainAddr = (void *)(intptr_t)GetExecutablePath;
233233
std::string ClangDocPath = GetExecutablePath(argv[0], MainAddr);
234+
llvm::SmallString<128> NativeClangDocPath;
235+
llvm::sys::path::native(ClangDocPath, NativeClangDocPath);
234236
llvm::SmallString<128> AssetsPath;
235-
llvm::sys::path::native(ClangDocPath, AssetsPath);
236-
AssetsPath = llvm::sys::path::parent_path(AssetsPath);
237+
AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath);
237238
llvm::sys::path::append(AssetsPath, "..", "share", "clang");
238239
llvm::SmallString<128> DefaultStylesheet;
239240
llvm::sys::path::native(AssetsPath, DefaultStylesheet);

0 commit comments

Comments
 (0)