[Clang] Keep scope annotations covering typo-corrected qualifiers (#223978)
Fixes #221890
While tentatively deciding whether `(void(foo::S<int>))` is a type-id,
the parser annotates `foo::S<int>`. Lookup of `S` in `foo` fails, typo
correction suggests plain `S`, and Sema rebuilds the `CXXScopeSpec`
without the qualifier. The annotation token takes its start from that
scope specifier, so it only covers `S<int>` and the already-consumed
`foo ::` tokens are never replaced in the token cache. They resurface
after the tentative parse backtracks, every later parse sees `foo ::
<type>`, and the second `isTypeIdInParens()` in
`ParseCXXAmbiguousParenExpression` contradicts the first.
The parser owns the invariant that an annotation replaces every token
consumed to produce it, so the fix lives in
`ParseOptionalCXXScopeSpecifier`. After each Sema call that can rewrite
the qualifier through typo correction, the scope specifier is re-ranged
over the tokens actually consumed. When the qualifier was dropped
entirely, the template-id annotation is extended back over those tokens
instead. Sema and the typo-correction recovery are untouched.
[RegAllocFast] Order partial defs before other defs (#222882)
```
%0:gr64_with_sub_8bit = COPY $rax
%0.sub_32bit, %1:gr32 = MULX32rr $ecx, implicit $edx
```
The partial def of %0 is live-through: it reads the rest of %0, so it
must avoid the registers the instruction reads ($ecx, $edx) and is meant
to be allocated before an ordinary def like %1, which may share a
register with a use. The comparator in findAndSortDefOperandIndexes,
from the 2020 rewrite c8757ff3aa7d ("RegAllocFast: Rewrite and
improve"), tests `getSubReg() == 0`, the inverse of the allocation
sites, so %1 is allocated first and takes $eax; %0 then misses its hint
$rax, lands in $rsi, and the copy from $rax stays.
Share one isLiveThroughDef predicate between the ordering and the
allocation. %0 now takes $rax, the copy is deleted, and %1 takes $ecx.
Aided by Opus 5
[flang] Add an example plugin defining compiler directives
flangDirectivesPlugin registers directives with the prefix "example" (a
callback on a procedure, a watch on a variable or COMMON block, and a note on
either). The tests check their lowering to fir.directives attributes, the
semantic and parse errors, and their round trip through module files.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[Support] Clarify purpose of LLVM_DEPRECATED (#228367)
Rename the macro to LLVM_DEPRECATED_WITH_FIXIT, to clarify that is is
used for deprecations where a machine-applicable fix-it exists (which is
only pure rename deprecations).
[clangd] Fix header-name completion replace ranges (#225473)
Handle header-name completion as a special case for replace edits. Its
insert range already extends past the identifier, including delimiters
such as '"' and '>'. Reuse that range for replace edits so that the
insert range remains a prefix of the replace range, as required by the
LSP specification.
Add a unit test covering this case.
Fixes llvm/llvm-project#225326
[Clang] Fix crash in alignment builtins with null pointers (#224549)
Clang can crash when evaluating __builtin_align_up,
__builtin_align_down, or __builtin_is_aligned with a null pointer.
Avoid querying base alignment for pointers without an underlying object
during constant evaluation.
Null pointers are handled as always aligned values, while other
base-less pointers are rejected rather than interpreted using their
numeric address.
Assisted-by: GPT-5.6
AI was used to assist with code analysis, debugging, and drafting the PR
description. I personally debugged, reviewed and verified the changes,
tested the code, and fully understand the submitted contribution.
Fixes https://github.com/llvm/llvm-project/issues/216999
Co-authored-by: Timm Baeder <tbaeder at redhat.com>
[clang-tidy][docs] Rename readability check docs to Markdown [5/5] (#222032)
Tracking issue: #201242
See the [migration guide] for more information.
[migration guide]:
https://llvm.org/docs/SphinxQuickstartTemplate.html#markdown-migration-guidelines
This is the fifth part of the mechanical rename of the check
documentations in readability module.
The rewrite is provided by the next PR in this stack.
[flang][OpenMP] Remember decision of allowing past/future clause (#227419)
When a deprecated or a future clause is used on a directive, and it is
allowed with a warning, remember that decision and consider that clause
allowed on that directive in all subsequent checks.
Introduce OpenMPDeprecated and OpenMPFuture warning categories
to guard these warnings (and the corresponding `-Wopenmp-deprecated`
and `-Wopenmp-future` options).
[clang-format] Allow one indent level before explicit access labels (#227704)
## Summary
With `IndentAccessModifiers: true`, clang-format indents record members
two levels even when the record has no explicit access label. Extend
`IndentAccessModifiers` with a third mode to allow one level until the
first explicit access label:
- `Never` (`false`): indent members one level and use
`AccessModifierOffset` for access labels.
- `Always` (`true`): indent members two levels, even without an explicit
access label.
- `AfterFirstAccessModifier`: indent members one level before the first
explicit access label and two levels from that label onward.
```yaml
IndentAccessModifiers: AfterFirstAccessModifier
```
[24 lines not shown]
[flang][OpenMP] Move leftover functions from structure to loop, NFC (#228705)
There were some loop-related functions still left in the
check-omp-structure.cpp file. Move them to check-omp-loop.cpp.
[flang][OpenMP] Move leftover functions from structure to loop, NFC
There were some loop-related functions still left in the
check-omp-structure.cpp file. Move them to check-omp-loop.cpp.
[PowerPC][SDAG] fix bitcast on ppc_f128 swapping the two halves (#208969)
fixes https://github.com/llvm/llvm-project/issues/44482
This is a long-standing issue
https://github.com/llvm/llvm-project/issues/44482, you can also see the
discrepancy in this small C program compiled with clang and GCC
https://godbolt.org/z/KK1q1EozM.
The representation of ppc_fp128 is endian-agnostic in that its
high-order double is stored at the lower address.
For example, 27.0 is represented in memory as `[0x403b000000000000,
0x0000000000000000]`. Bitcasting these 128 bits as an i128 on
little-endian means the upper 64 bits are `0x0000000000000000`, the
lower are `0x403b000000000000`.
But on big-endian the interpretation of the bytes is flipped, the upper
bits are now `0x403b000000000000` while the lower are in
[8 lines not shown]
[orc-rt] Use the Error matchers in InProcessControllerAccessTest (#228702)
Use the Error matchers introduced in 4c8a437d0487 in place of cantFail
on calls that can fail, so that a failure is reported as a test failure
rather than aborting the test binary (or, with assertions disabled,
going unnoticed).
[Mips][MSA] Lower vector fabs to BCLRI (#228532)
FMAX_A selects an original operand by magnitude and preserves its sign,
so fmax_a(x, x) does not implement fabs. Expand FABS_W and FABS_D to
clear bit 31 and bit 63 with BCLRI, and update their scheduling to match
the bit-clear instructions.
Fixes #228384.
[Mips][MSA] Fix commutability of unordered comparisons (#228567)
Remove IsCommutable from FCULT_W/D and FCULE_W/D, whose predicates are
directional. Extend the existing floating-point comparison tests to
check that reversed comparisons produce separate results.
Fixes: #228422
[orc-rt] Use the Error matchers in OptionParserTest (#228701)
Use the Error matchers introduced in 4c8a437d0487 to clean up error
checks in OptionParserTest.
[X86] Don't skip frame setup/destroy on SEH pseudos and regenerate tests (#225445)
As in title. Skipping setting setup/destroy flags caused pseudos to be
wrongly reordered by scheduling