Manual-sync mirror of chromium.googlesource.com/external/github.com/llvm/llvm-project (bare monorepo, no subtree suffix)
Find a file
Cyrus Ding 84b931c00f
Fix clang-doc crash when comment contains invalid UTF-8 bytes (#210886)
When a source file comment contains non-UTF-8 bytes (e.g., byte 0x97),
clang-doc's JSONGenerator would crash with an assertion failure:

  Assertion `false && "Invalid UTF-8 in value used as JSON"' failed.

This happens because json::Value(StringRef) asserts on invalid UTF-8
input in debug builds. While the release-build path calls fixUTF8()
automatically, the assertion crash affects developers and fuzzer runs.

Fix by following the same pattern used elsewhere in LLVM (lldb, clangd):
check isUTF8() before constructing a json::Value, and call fixUTF8() to
sanitize the string if invalid bytes are detected. This avoids an
unnecessary copy for the common case of valid UTF-8.

The fix covers all paths in serializeComment() where user-written text
from source comments enters JSON objects:
  - CK_TextComment (I.Text)
  - CK_InlineCommandComment (I.Args)
  - CK_VerbatimBlockLineComment / CK_VerbatimLineComment (I.Text)
  - CK_Unknown (I.Text)

Also add a regression test with an actual invalid UTF-8 byte in a
comment.

AI assistance was used for code review analysis and local build
verification.

Fixes: https://github.com/llvm/llvm-project/issues/210675

---------

Co-authored-by: Chenguang Ding <dingchenguang@kylinos.cn>
Co-authored-by: Claude <noreply@anthropic.com>
2026-07-25 05:20:11 +08:00
.ci [libc++] Rename pre-commit CI workflows (#211844) 2026-07-24 14:56:19 -04:00
.github [libc++] Rename pre-commit CI workflows (#211844) 2026-07-24 14:56:19 -04:00
bolt [BOLT] Fix pwrite assertion failure via a new safePWrite wrapper (#198569) 2026-07-24 19:55:26 +08:00
clang [clang][Fuchsia] Add __Fuchsia_Compiler_ABI__ predefine (#211744) 2026-07-24 12:04:35 -07:00
clang-tools-extra Fix clang-doc crash when comment contains invalid UTF-8 bytes (#210886) 2026-07-25 05:20:11 +08:00
cmake Bump version to 24.0.0git (#209473) 2026-07-14 09:21:03 -04:00
compiler-rt [tsan][ppc64] Fix copy-paste bug in __sigsetjmp OPD TOC loading (#210589) 2026-07-24 21:13:11 +00:00
cross-project-tests cross-project-tests: Migrate amdgpu tests to use subarch triples (#210115) 2026-07-24 17:38:34 +02:00
flang [flang][OpenMP] Use llvm::omp::ClauseSet in modifier verification (#211900) 2026-07-24 15:20:10 -05:00
flang-rt [flang-rt] - Reduce ShallowCopy template instantiations to improve LTO time (#209915) 2026-07-24 14:59:57 -05:00
libc [libc] Small correctness tweaks to GPU allocator (#211610) 2026-07-24 16:07:48 -05:00
libclc libclc: Fix signed 0 handling in sincospi (#211260) 2026-07-23 06:24:44 +02:00
libcxx [libc++] Rename pre-commit CI workflows (#211844) 2026-07-24 14:56:19 -04:00
libcxxabi [runtimes] LLVM 24 version bumps (#211262) 2026-07-22 12:38:40 -04:00
libsycl [libsycl][NFC] Move the cmake msvc DLL check (#193485) 2026-07-20 16:55:25 +02:00
libunwind [libunwind][arm64e] Mach-O Support unwinding PAuth_LR frames (#202772) 2026-07-24 14:17:11 -07:00
lld [NFC][test][ELF] Improve ppc32-ifunc-nonpreemptible-(no)pic.s (#210611) 2026-07-23 19:00:40 +01:00
lldb [lldb] Recover a WebAssembly function's mangled name from its declaration (#211707) 2026-07-24 13:40:25 -05:00
llvm [AArch64] Add a OPERAND_IMM_UINT4p1 operand type (#211925) 2026-07-24 22:00:16 +01:00
llvm-libgcc [docs] Finish misc MyST migration (#210209) 2026-07-17 11:56:59 -07:00
mlir [mlir][xegpu] Allow create_mem_desc from ND memref (#211836) 2026-07-24 12:01:20 -07:00
offload [OFFLOAD][L0] Properly consume errors in program validation (#211799) 2026-07-24 16:49:57 +02:00
openmp FIX some OMPT tests that fail on RISC-V (#156914) 2026-07-24 11:24:36 +02:00
orc-rt [orc-rt] Add comment to clarify intended control flow. NFC. (#211454) 2026-07-23 13:25:32 +10:00
polly [SCEV] Use SCEVPtrToAddr instead of SCEVPtrToInt in SCEV. (#180244) 2026-07-24 20:20:48 +01:00
runtimes Remove debug leftovers (#211068) 2026-07-21 23:23:13 -07:00
third-party Fix a warning and an uninitialized variable in benchmark (#200927) 2026-06-02 13:49:06 -07:00
utils [Bazel] Fixes 8a6a039 (#211892) 2026-07-24 19:16:29 +00:00
.clang-format
.clang-format-ignore [Docs] Update coding standard for TD files (#200848) 2026-06-01 21:35:58 +01:00
.clang-tidy Add default empty header filter regex to root .clang-tidy (#167386) 2025-11-11 01:36:25 +03:00
.git-blame-ignore-revs Add "Split clang/lib/CodeGen/CGBuiltin.cpp" to .git-blame-ignore-revs (#203419) 2026-06-12 12:03:28 +01:00
.gitattributes [libclang/python] Enable packaging clang python bindings (#125806) 2025-11-24 17:21:24 -08:00
.gitignore gitignore: Add emacs lock files (#205055) 2026-06-22 18:19:29 +02:00
.mailmap mailmap: Add entries for Peter Collingbourne. (#210526) 2026-07-18 11:02:06 -07:00
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE.TXT
pyproject.toml [docs] Create utils/docs (#203962) 2026-06-24 15:12:48 -04:00
README.md [libc++] Rename pre-commit CI workflows (#211844) 2026-07-24 14:56:19 -04:00
SECURITY.md [SECURITY.md] add pointers to "what is a security issue" (#177372) 2026-01-22 17:19:09 -07:00

The LLVM Compiler Infrastructure

OpenSSF Scorecard OpenSSF Best Practices libc++

Welcome to the LLVM project!

This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.

The LLVM project has multiple components. The core of the project is itself called "LLVM". This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.

C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.

Other components include: the libc++ C++ standard library, the LLD linker, and more.

Getting the Source Code and Building LLVM

Consult the Getting Started with LLVM page for information on building and running LLVM.

For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.

Getting in touch

Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.

The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.