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)
[15 lines not shown]
[libunwind][arm64e] Mach-O Support unwinding PAuth_LR frames (#202772)
Under PAuth_LR, compact unwind entries marked UNWIND_ARM64_MODE_FRAME_PAUTH_LR are signed with the PC of the pacibsppc at the start of the range. The compiler may emit those entries with UNWIND_IS_NOT_FUNCTION_START when the pacibsppc is not the first instruction in the function; the unwinder must scan backwards past such entries to find the actual function start (and its LSDA pointer).
When unwinding a PAuth_LR frame, authenticate and re-sign using setIPPAuthLR(), which calls __builtin_ptrauth_auth_with_pc_and_resign when available, falling back to inline asm (autib171615 + pacib) for compilers that lack the builtin.
To reduce the size of Compact Unwind entries for shrinkwrapped frames, new offset bits encode the distance in multiples of 4 bytes from the range start to the pacibsppc. The compiler emits paired FRAMELESS/FRAMELESS+PAUTH_LR entries that the linker merges into a single FRAME_PAUTH_LR | (offset/4) << 12 encoding.
rdar://161907302&169746432&171118419
clang/AMDGPU: Migrate cc1 tests to subarch triples (8)
Rewrite SemaHIP cc1 test RUN lines to the new subarch triple form,
dropping the redundant -target-cpu.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
clang/AMDGPU: Migrate cc1 tests to subarch triples (7)
Rewrite the remaining small test directories (CodeGenCXX, Misc, Sema,
SemaCUDA, SemaCXX) cc1 RUN lines to the new subarch triple form, dropping
the redundant -target-cpu.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
clang/AMDGPU: Migrate cc1 tests to subarch triples (6)
Rewrite CIR/CodeGenHIP cc1 test RUN lines to the new subarch triple form,
dropping the redundant -target-cpu, and regenerate autogenerated CHECK
lines.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[tsan][ppc64] Fix copy-paste bug in __sigsetjmp OPD TOC loading (#210589)
In `__sigsetjmp`'s big-endian OPD path, the TOC was loaded from
`_setjmp`'s OPD entry instead of `__sigsetjmp`'s own entry, due to a
copy-paste error.
```diff
- addis r2,r2,_setjmp-1b at ha
- addi r2,r2,_setjmp-1b at l
+ addis r2,r2,__sigsetjmp-1b at ha
+ addi r2,r2,__sigsetjmp-1b at l
```
This caused an incorrect TOC pointer to be loaded on big-endian PPC64
when `__sigsetjmp`/sigsetjmp was intercepted by TSan. The corresponding
`_setjmp` path (which uses label `0b`) correctly references its own
symbol for the OPD lookup.
Co-authored-by: pmr <prabhas at pmrs-MacBook.local>
git-mfc: Improve handling of remotes
If we can't figure out which remote to use, print a useful error instead
of assuming that "freebsd" is the right remote to use.
[libc] Small correctness tweaks to GPU allocator (#211610)
Summary:
Small bugs, like more strict C++ lifetime ordering for the header and
fixing a bug in alignment sizing.
[Sema] Skip expansion statements when determing local extern context (#210512)
This bug showed up as a failed assertion that was asserting that if
not in a function or method context we should be in the global/file
context.
The root cause is that when determining the linkage context for a
decl we were failing to account for the existence of expansion
contexts. Ignoring the assertion failure, the functional effect of
this is that we would fail to detect incorrect local extern
declarations inside expansion contexts. The fix here is to make
sure that we use `getEnclosingNonExpansionStatementContext()` to
find the true DeclContext for the current scope.
The initial report only identified local extern function declarations
but the same bug occurred with extern var decls, but the path did
not lead to an assertion firing, just incorrect behaviour.
Thanks to Sirraide for explaining why this was going wrong, and
[3 lines not shown]
[Sema] Skip expansion statements when determing local extern context (#210512)
This bug showed up as a failed assertion that was asserting that if
not in a function or method context we should be in the global/file
context.
The root cause is that when determining the linkage context for a
decl we were failing to account for the existence of expansion
contexts. Ignoring the assertion failure, the functional effect of
this is that we would fail to detect incorrect local extern
declarations inside expansion contexts. The fix here is to make
sure that we use `getEnclosingNonExpansionStatementContext()` to
find the true DeclContext for the current scope.
The initial report only identified local extern function declarations
but the same bug occurred with extern var decls, but the path did
not lead to an assertion firing, just incorrect behaviour.
Thanks to Sirraide for explaining why this was going wrong, and
[6 lines not shown]
[libc] Add missing standard and Linux header macros (#211862)
Add missing header macro constants:
* endian-macros.h: __BYTE_ORDER, __LITTLE_ENDIAN, and __BIG_ENDIAN
* sys-stat-macros.h: S_IREAD, S_IWRITE, S_IEXEC, and ACCESSPERMS
* limits-macros.h: _POSIX_HOST_NAME_MAX and HOST_NAME_MAX
* unistd-macros.h: TEMP_FAILURE_RETRY
POSIX.1-2017 specifies _POSIX_HOST_NAME_MAX as 255. The Linux
gethostname(2) man page specifies HOST_NAME_MAX as 64. The
double-underscore byte order macros and TEMP_FAILURE_RETRY macro follow
the Linux and GNU C library conventions.
Assisted-by: Automated tooling, human reviewed.
[libc] Add missing sys/types.h integer and BSD/System V type definitions (#211861)
Add missing type definitions to llvm-libc-types and sys/types.yaml:
* POSIX standard types: id_t, useconds_t
* BSD and System V compatibility typedefs: caddr_t, u_int, u_int8_t,
u_int16_t, u_long, u_short, ulong, ushort
* Large File Support (LFS) and Linux kernel internal types: ino64_t,
off64_t, __off_t, __off64_t, __uint64_t
POSIX.1-2017 defines id_t and useconds_t in sys/types.h. The BSD and
System V standards specify the legacy unsigned integer shorthand types,
and Linux kernel/glibc interfaces use the double-underscore prefix
offset and integer types.
Assisted-by: Automated tooling, human reviewed.