LLVM/project 83ca6fc — libc/src/time time_utils.cpp, libc/test/src/time gmtime_test.cpp

[libc] Fix gmtime and mktime for years before zero (#236515)

yrs % 4 is negative for a year before zero, which moved the month out of
range and aborted on the assertion that follows. Mask the low two bits
instead, which is the non-negative remainder

Add the year before zero and year zero to the gmtime test

AI disclosure: this patch was written with Claude Code. I reviewed the
change and ran the new test; it fails without the fix and passes with it

Assisted-by: Claude
DeltaFile
+8-1libc/test/src/time/gmtime_test.cpp
+4-2libc/src/time/time_utils.cpp
+12-32 files

LLVM/project 0dfa6b3 — libc/include/llvm-libc-types EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.h EFI_STATUS.h, libc/src/__support/OSUtil/uefi CMakeLists.txt error.h

[libc][uefi] Encode the error bit in EFI_STATUS error codes (#235071)

Set the high bit on the EFI_STATUS error macros through new
EFI_ERROR_BIT, EFIERR and EFI_ERROR helpers, and use them 
directly in the errno translation table, so that error codes match
the values returned by UEFI firmware while warnings remain
plain values. Add EFI_UNSUPPORTED and 
EFI_BUFFER_TOO_SMALL to the table, map unrecognized error
statuses to EIO and unrecognized warnings to success, and
cover the conversions with a unit test.

Include the standard boolean header in the UEFI type definitions that
use bool, so that C translation units prior to C23 can include them.
DeltaFile
+56-65libc/src/__support/OSUtil/uefi/error.h
+76-0libc/test/src/__support/OSUtil/uefi/error_test.cpp
+39-33libc/include/llvm-libc-types/EFI_STATUS.h
+12-0libc/src/__support/OSUtil/uefi/CMakeLists.txt
+10-0libc/test/src/__support/OSUtil/uefi/CMakeLists.txt
+2-0libc/include/llvm-libc-types/EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.h
+195-986 files not shown
+201-9812 files

LLVM/project bd6e444 — llvm/lib/Analysis ValueTracking.cpp, llvm/test/Transforms/InstSimplify fp-undef-poison-strictfp.ll

[ValueTracking] Add constrained intrinsics variants to intrinsicPropagatesPoison (#239270)

Followup to #239135. Maybe we can make this tablegen-generated in the
future.
DeltaFile
+245-0llvm/test/Transforms/InstSimplify/fp-undef-poison-strictfp.ll
+29-0llvm/lib/Analysis/ValueTracking.cpp
+274-02 files

LLVM/project 24efce6 — utils/bazel/llvm-project-overlay/flang/lib/Optimizer/Dialect BUILD.bazel

[Bazel] fix bazel layering check after 960bcc8 (#239296)
DeltaFile
+2-0utils/bazel/llvm-project-overlay/flang/lib/Optimizer/Dialect/BUILD.bazel
+2-01 files

LLVM/project f16e3e2 — llvm/lib/IR RuntimeLibcalls.cpp, llvm/test/TableGen RuntimeLibcallEmitter-attributes.td

RuntimeLibcalls: Mark vector libcall out pointers dereferenceable

The whole vector width will be written, so mark the vector width. To
maintain the element width alignment for some functions, we need to
start explicitly tracking if the element alignment is used or not.

Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
DeltaFile
+9-5llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
+10-3llvm/test/TableGen/RuntimeLibcallEmitter-attributes.td
+11-2llvm/lib/IR/RuntimeLibcalls.cpp
+6-6llvm/test/Transforms/Util/DeclareRuntimeLibcalls/sleef.ll
+6-6llvm/test/Transforms/Util/DeclareRuntimeLibcalls/armpl.ll
+6-6llvm/test/Transforms/Util/DeclareRuntimeLibcalls/amdlibm.ll
+48-282 files not shown
+53-348 files

LLVM/project ae02bf2 — llvm/include/llvm/IR RuntimeLibcalls.td RuntimeLibcallsImpl.td, llvm/lib/IR RuntimeLibcalls.cpp

RuntimeLibcalls: Declare vector libcall attributes in TableGen (#238227)

Replace the type-based heuristics for vector math libcall attributes
with attributes declared on the libcall definitions, emitted with the
same attribute table helpers as intrinsics.

Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
DeltaFile
+226-1llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
+103-0llvm/test/TableGen/RuntimeLibcallEmitter-attributes.td
+26-56llvm/lib/IR/RuntimeLibcalls.cpp
+52-0llvm/test/TableGen/RuntimeLibcallEmitter-attributes-errors.td
+44-3llvm/include/llvm/IR/RuntimeLibcallsImpl.td
+23-9llvm/include/llvm/IR/RuntimeLibcalls.td
+474-691 files not shown
+478-737 files

LLVM/project 6ad97ae — llvm/utils/TableGen/Common CodeGenRegisters.cpp CodeGenRegisters.h

TableGen: Key register classes by member EnumValues in Key2RC

Key2RC is searched with Key::operator<, which compares member lists and
loads every register in both. Store the EnumValues of the non-artificial
members in the keys instead, so a lookup only loads the members of the
class being looked up.

AMDGPU tablegen runs that build the register bank:

            Gigainstructions  Gigacycles     CPU seconds
  Before    561               295            95
  After     536 (-4.5%)       287 (-2.7%)    93 (-1.9%)

Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
DeltaFile
+34-1llvm/utils/TableGen/Common/CodeGenRegisters.h
+18-5llvm/utils/TableGen/Common/CodeGenRegisters.cpp
+52-62 files

LLVM/project 59347b8 — llvm/utils/TableGen/Common CodeGenRegisters.cpp

TableGen: Only collect sub-registers when there are candidate sub-classes

For each register class and sub-register index, inferMatchingSuperRegClass
looked up the sub-register of every member before checking for candidate
sub-classes, but most pairs have none: 73% for AMDGPU, with 62% of the
lookups. Collect the sub-registers when the first candidate is found.

The candidates are found by the TopoSigs of the sub-registers, which are
the same for registers with the same TopoSig. So find them once per class
from one member per TopoSig, which is usually a single member.

AMDGPU tablegen runs that build the register bank:

            Gigainstructions  Gigacycles     CPU seconds
  Before    564               311            100
  After     561 (-0.5%)       295 (-5.2%)    95 (-4.9%)

Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
DeltaFile
+36-11llvm/utils/TableGen/Common/CodeGenRegisters.cpp
+36-111 files

LLVM/project a533db6 — llvm/utils/TableGen CallingConvEmitter.cpp

TableGen: Only build the register bank in CallingConvEmitter when needed

CallingConvEmitter built the register bank to find registers named by
strings, which only CCAssignToRegTuple uses. No target does, but
building the register bank is most of the work for targets with many
registers. Build it when the first register name is looked up instead.

All 16 CallingConv tablegen runs in an LLVM build with all targets:

            Gigainstructions  Gigacycles      CPU seconds
  Before    73.5              43.4            15.1
  After     47.1 (-35.9%)     27.7 (-36.2%)   10.2 (-32.2%)

For AMDGPU alone, the run executes 63% fewer cycles.

Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
DeltaFile
+8-4llvm/utils/TableGen/CallingConvEmitter.cpp
+8-41 files

LLVM/project 1c994e7 — llvm/include/llvm/TargetParser CMakeLists.txt, llvm/lib/Target/RISCV RISCVFeatures.td RISCVRegisterInfo.td

RISCV: Use minimal tablegen inputs for TargetParser (#239104)

Generate RISCVTargetParserDef.inc from a reduced td file which
includes only the features, profiles and processors, instead of all of
RISCV.td. The processors reference scheduling models, which are
defined with the scheduling information for the instructions, so the
new file defines empty placeholder models instead, as was done for
AArch64 in #231954.

RISCV was the last TargetParser input that parsed the full target, and
took 1.74 of the 1.78 seconds spent in the TargetParser tablegen jobs.

llvm-min-tblgen -gen-riscv-target-def, mean of 5 runs

Gigainstructions Seconds Peak RSS .td deps
  RISCV.td                   7.47              1.74     407 MB    139
  RISCVTargetParserDef.td    0.04              0.01       7 MB      9

Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>

Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
DeltaFile
+44-0llvm/lib/Target/RISCV/RISCVTargetParserDef.td
+0-3llvm/lib/Target/RISCV/RISCVFeatures.td
+3-0llvm/lib/Target/RISCV/RISCVRegisterInfo.td
+1-1utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+1-1llvm/utils/gn/secondary/llvm/include/llvm/TargetParser/BUILD.gn
+1-1llvm/include/llvm/TargetParser/CMakeLists.txt
+50-66 files

LLVM/project b7bc61f — llvm/lib/Target/RISCV RISCVFeatures.td RISCVMacroFusionXQCI.td

RISCV: Define macro fusion features separately from predicates (#239103)

Move the fusion tuning features to RISCVFeatures.td with the other
tuning features, and attach the predicates with SimpleFusionFor and
FusionFor. The features no longer depend on the instruction definitions.

Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
DeltaFile
+125-161llvm/lib/Target/RISCV/RISCVMacroFusion.td
+60-72llvm/lib/Target/RISCV/RISCVMacroFusionXQCI.td
+104-0llvm/lib/Target/RISCV/RISCVFeatures.td
+289-2333 files

LLVM/project 88bd907 — llvm/include/llvm/Target TargetMacroFusion.td, llvm/test/TableGen MacroFusionDuplicate.td MacroFusionFor.td

TableGen: Allow macro fusion predicates for a separate subtarget feature (#239102)

Fusion defines a subtarget feature and its fusion predicates in a single
record. The predicates reference instructions, so the feature can't be
defined without the instruction definitions. Add FusionFor and
SimpleFusionFor to attach fusion predicates to a SubtargetFeature
defined elsewhere.

Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
DeltaFile
+73-0llvm/test/TableGen/MacroFusionFor.td
+49-19llvm/include/llvm/Target/TargetMacroFusion.td
+30-0llvm/test/TableGen/MacroFusionDuplicate.td
+15-14llvm/utils/TableGen/MacroFusionPredicatorEmitter.cpp
+19-1llvm/utils/TableGen/Common/CodeGenTarget.cpp
+6-1llvm/utils/TableGen/Common/CodeGenTarget.h
+192-351 files not shown
+193-367 files

LLVM/project dfc43d3 — flang/include/flang/Lower SymbolMap.h, flang/lib/Lower SymbolMap.cpp

[flang] Fix references to a LOCAL variable of an enclosing DO CONCURRENT (#238647)

A `REDUCE` locality-spec on a nested `DO CONCURRENT` that names a
variable with `LOCAL` or `LOCAL_INIT` locality in the enclosing `DO
CONCURRENT` crashes lowering:

```fortran
subroutine s(n, nz, work)
  integer :: n, nz, work(nz), j, k, tmp
  do concurrent (k=1:nz) local(tmp)
    tmp = 0
    do concurrent (j=1:n) reduce(max:tmp)
      tmp = max(tmp, j)
    end do
    work(k) = tmp
  end do
end subroutine
```


    [67 lines not shown]
DeltaFile
+180-0flang/test/Lower/do_concurrent_nested_locality.f90
+70-0flang/test/Semantics/symbol09.f90
+19-2flang/include/flang/Lower/SymbolMap.h
+12-3flang/lib/Lower/Support/Utils.cpp
+6-6flang/lib/Lower/SymbolMap.cpp
+6-0flang/lib/Semantics/resolve-names.cpp
+293-116 files

LLVM/project 56a7efd —

Fix Bazel build for fa8c673 (#239300)

Buildkite error link:
https://buildkite.com/llvm-project/upstream-bazel/builds?commit=fa8c67382e4fa68010fce98bbd267f91b397f80e

Co-authored-by: Google Bazel Bot <google-bazel-bot at google.com>
DeltaFile
+0-00 files

LLVM/project 921b800 — bolt/lib/Passes VeneerElimination.cpp, bolt/test/AArch64 veneer-erratum-843419-cfg.s

[BOLT] Connect inlined e843419 veneer block to its return target (#238108)

When an lld Cortex-A53 erratum 843419 veneer is inlined, the branch
being replaced is a tail call, so its block has no successors in the
CFG. The block then ends in the veneer's load/store with no edge to
the veneer's branch-back target. Block reordering and splitting are
free to separate the two, and fixBranches adds no branch, because a
block with no successors has no fall-through to fix up: execution
runs into whatever was laid out next.

Record the edge when inlining, and only inline over a branch that is
the block's unconditional terminator, which is what lld writes in
place of the patched load/store.
DeltaFile
+65-0bolt/test/AArch64/veneer-erratum-843419-cfg.s
+27-4bolt/lib/Passes/VeneerElimination.cpp
+92-42 files

LLVM/project d0e7695 — clang/lib/DependencyScanning DependencyScanningWorker.cpp, clang/unittests/Tooling DependencyScannerTest.cpp

[clang][DepScan] Support subdirectory seach in getModuleMapsForModules (#238860)

Respect resolving modulemaps with
`-fmodulemap-allow-subdirectory-search` in `getModuleMapsForModules` to
match the normal scan's lookup. Note this option is default disabled.
DeltaFile
+31-0clang/unittests/Tooling/DependencyScannerTest.cpp
+2-1clang/lib/DependencyScanning/DependencyScanningWorker.cpp
+33-12 files

LLVM/project 3042140 — bolt/include/bolt/Core BinaryContext.h, bolt/lib/Core BinaryContext.cpp

[BOLT] Handle relative vtable slots covered by WPD aliases (#238065)

A PC-relative relocation in read-only data will be treated as a relative
vtable slot and resolved against its function symbol if and only if the
innermost data symbol containing it is a vtable. Otherwise BOLT will
treat it as a reference to S+A.

With ThinLTO split LTO units, WPD could export a hidden alias symbol
`__typeid_<id>_<offset>_unique_member` at a vtable's address point. It
inherits the vtable's size, so it extends past the vtable, is not nested
under it, and is the innermost symbol for the slots. A slot's addend is
its offset from the address point, so S+A can land inside the target
function, which is then incorrectly interpreted as having an unclaimed
internal reference and marked as non-simple.

The fix is to keep an address-sorted index of vtables, filled when
symbols are registered, and look up the vtable containing a slot
directly. Vtables do not overlap, so only the last one starting at or
before the slot can contain it. This would also handle any new kind of

    [2 lines not shown]
DeltaFile
+75-0bolt/test/AArch64/relative-vtable-typeid-alias.s
+14-0bolt/lib/Core/BinaryContext.cpp
+9-0bolt/include/bolt/Core/BinaryContext.h
+1-2bolt/lib/Rewrite/RewriteInstance.cpp
+99-24 files

LLVM/project 4836728 — llvm/lib/CodeGen/GlobalISel IRTranslator.cpp, llvm/lib/CodeGen/SelectionDAG FunctionLoweringInfo.cpp

[CodeGen] Overwrite a 0 sized alloca to have same number of bytes as it's Frame Object (#232755)

Fix: instruction selection rounds a zero-sized `alloca`'s frame object
up to one byte without updating the `alloca`, leading to bad alias
information and wrong access conclusions in BasicAA.

---

#### Context

I ran into a bug where StackColoring (on a mix of C and Rust codebase)
would collapse 1 byte LLVM IR alloca into other 0 byte LLVM IR allocas
but their FrameObject would have a min-size of 1 byte. However, when
BasicAA runs it reads the LLVM IR `alloca` to get the size, and not the
Frame Object. The LLVM IR alloca would still show 0 bytes, and this can
break BasicAA's conclusions about whether two accesses can touch the
same memory and results in bad program behaviour (e.g. wrong values,
hangs, crashes, deadlocks, etc).


    [29 lines not shown]
DeltaFile
+68-0llvm/test/CodeGen/RISCV/isel-zero-size-alloca.ll
+59-0llvm/test/CodeGen/RISCV/zero-size-alloca-misched.ll
+7-7llvm/test/CodeGen/AMDGPU/issue130120-eliminate-frame-index.ll
+10-2llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
+9-1llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+153-105 files

LLVM/project ed7735b — llvm/lib/Target/AMDGPU AMDGPUTargetTransformInfo.cpp, llvm/test/Analysis/CostModel/AMDGPU bitcast-int-fp.ll

[AMDGPU] Move the bitcast cost comments, document the i1 mask test

Put the comment about the scalarized parts of a vector bitcast above
the size check, and the comment about the shared registers inside it.
Say in the test which case @i1_mask covers.

Assisted-by: Claude Opus
DeltaFile
+4-2llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
+3-0llvm/test/Analysis/CostModel/AMDGPU/bitcast-int-fp.ll
+7-22 files

LLVM/project f227f40 — llvm/lib/Target/AMDGPU AMDGPUTargetTransformInfo.cpp, llvm/test/Analysis/CostModel/AMDGPU bitcast-int-fp.ll

[AMDGPU] Treat a bitcast between legal types as free

The generic cost model treats a bitcast as free only when both types
are integer types or both are not. AMDGPU keeps integer and
floating-point values in the same registers, so a bitcast between two
legal types is a no-op. A scalar bitcast from i32 to float cost 1, but
the vector bitcast from <2 x i32> to <2 x float> cost 0. The SLP
vectorizer counted this difference as a saving.

A bitcast that involves a type the target legalizes, such as a vector
of i8, keeps its cost, because the lanes may need repacking.

Assisted-by: Claude Opus
DeltaFile
+35-35llvm/test/Analysis/CostModel/AMDGPU/bitcast-int-fp.ll
+4-3llvm/test/Transforms/SLPVectorizer/AMDGPU/bitcast-int-fp.ll
+6-0llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
+45-383 files

LLVM/project b156213 — llvm/test/Analysis/CostModel/AMDGPU bitcast-int-fp.ll

[AMDGPU][NFC] Add bitcast cost tests for legalized types and pointers

Add bitcasts that involve types the target legalizes, such as vectors
of i8, i24 and <2 x i24>, and bitcasts of pointers. Add a gfx7 RUN
line, where i16 and <2 x i16> are not legal.

Assisted-by: Claude Opus
DeltaFile
+134-2llvm/test/Analysis/CostModel/AMDGPU/bitcast-int-fp.ll
+134-21 files

LLVM/project cb61a87 — llvm/lib/Target/AMDGPU AMDGPUTargetTransformInfo.cpp, llvm/test/Analysis/CostModel/AMDGPU bitcast-int-fp.ll

[AMDGPU] Treat a bitcast between scalars legalized to the same size as free
DeltaFile
+15-7llvm/test/Analysis/CostModel/AMDGPU/bitcast-int-fp.ll
+11-8llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
+26-152 files

LLVM/project 06ef175 — llvm/lib/Target/AMDGPU AMDGPUTargetTransformInfo.cpp, llvm/test/Analysis/CostModel/AMDGPU bitcast-int-fp.ll

[AMDGPU] Require equal sizes for a free bitcast, add i1 mask and gfx6 tests
DeltaFile
+79-49llvm/test/Analysis/CostModel/AMDGPU/bitcast-int-fp.ll
+5-3llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
+84-522 files

LLVM/project f2d6195 — llvm/test/Analysis/CostModel/AMDGPU bitcast-int-fp.ll, llvm/test/Transforms/SLPVectorizer/AMDGPU bitcast-int-fp.ll

[AMDGPU][NFC] Add tests for bitcasts between integer and FP types

Add cost model tests for bitcasts between integer and floating-point
types of the same size, as scalars and as vectors. Add an SLP test that
stores a pair of values bitcast from i32 to float.

Assisted-by: Claude Opus
DeltaFile
+106-0llvm/test/Analysis/CostModel/AMDGPU/bitcast-int-fp.ll
+72-0llvm/test/Transforms/SLPVectorizer/AMDGPU/bitcast-int-fp.ll
+178-02 files

LLVM/project d048633 — llvm/include/llvm/MC MCPseudoProbe.h, llvm/unittests/MC CMakeLists.txt MCPseudoProbeTest.cpp

[PseudoProbe] Avoid OOB in pseudo probe search (#239082)

There's an OOB access if `GUIDProbeFunctionMap` tries to find an invalid
GUID that over the biggest GUID. `lower_bound` returns the end of
vector, which makes the dereference invalid.

Assisted by: Opus 5.5
DeltaFile
+53-0llvm/unittests/MC/MCPseudoProbeTest.cpp
+1-1llvm/include/llvm/MC/MCPseudoProbe.h
+1-0llvm/unittests/MC/CMakeLists.txt
+55-13 files

LLVM/project 438673e — libcxx/test/libcxx/depr/depr.default.allocator/allocator.members max_size.cxx20.verify.cpp address.cxx20.verify.cpp

[libc++] Rewrite some std::allocator verify tests (#238802)

They were written in a way that makes it look like they are executed,
when in reality they aren't.

The underlying motivation for rewriting is that some of the verify
checks were written inside `assert(...)`, which made them fail if the
`assert` macro expands to nothing or expands to something that evaluates
the expression twice (both of which are terrible implementations of
assert).

Assisted by Claude
DeltaFile
+0-77libcxx/test/libcxx/depr/depr.default.allocator/allocator.members/construct.cxx20.verify.cpp
+54-0libcxx/test/libcxx/depr/depr.default.allocator/allocator.members/construct_destroy.cxx20.verify.cpp
+6-15libcxx/test/libcxx/depr/depr.default.allocator/allocator.members/address.cxx20.verify.cpp
+2-13libcxx/test/libcxx/depr/depr.default.allocator/allocator.members/max_size.cxx20.verify.cpp
+62-1054 files

LLVM/project e23aefa — llvm/test/Transforms/StructurizeCFG callbr.ll

add forgotten CHECK lines for new test
DeltaFile
+15-1llvm/test/Transforms/StructurizeCFG/callbr.ll
+15-11 files

LLVM/project 9baf701 — lld/ELF InputFiles.h Symbols.h, lld/test/ELF lazy-undef.s

[ELF] Parallelize symbol interning while parsing files. NFC (#238701)

Looking up global symbol names in the symbol table dominates the serial
doParseFiles loop, mostly through cache misses. Shard the global symbol
map and let helper threads run ahead of the loop, interning the names of
relocatable object files in input order. Before parsing a file, the loop
waits for the helper that claimed it, or claims the file and inserts its
symbols serially.

An interned symbol is invisible to find() until SymbolTable::insert
appends it to symVector, and resolution stays serial, so the output is
unchanged. The shards are locked only while the helpers run.

```
           Chromium                         clang (release)
--threads  link (ms)            parse       link (ms)           parse
1          +30 (+0.8%)          659 -> 690  +3 (+0.7%)          49 -> 52
2          2724 -> 2502 (-8%)   663 -> 455  347 -> 337 (-3.5%)  50 -> 40
8          1767 -> 1412 (-20%)  667 -> 313  181 -> 151 (-17%)   56 -> 24
16         1692 -> 1315 (-21%)  688 -> 326  159 -> 136 (-14%)   50 -> 25
```
DeltaFile
+66-8lld/ELF/InputFiles.cpp
+31-26lld/ELF/SymbolTable.cpp
+32-4lld/ELF/SymbolTable.h
+28-0lld/test/ELF/lazy-undef.s
+8-4lld/ELF/Symbols.h
+6-0lld/ELF/InputFiles.h
+171-426 files

LLVM/project c28200d — llvm/lib/Transforms/IPO FunctionSpecialization.cpp

[fixup] Run clang-format because originally the source wasn't properly formatted
DeltaFile
+3-3llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
+3-31 files

LLVM/project 41cfdef — clang-tools-extra/clangd GlobalCompilationDatabase.cpp, clang-tools-extra/test/clang-doc DR-131697.cpp

[Tooling] Resolve relative "directory" against the compilation database (#235400)

JSONCompilationDatabase does not resolve a relative "directory", e.g.
`{"directory": ".", "command": "cc ../src/a.c", "file": "../src/a.c"}`.
getCompileCommands finds nothing, so clang-check reports "Compile
command not found" and clangd uses a fallback command.
getAllCompileCommands returns the directory verbatim, so each consumer
resolves it against its own working directory.

Resolve it against the directory containing compile_commands.json,
without resolving symlinks, so that paths keep the spelling clangd
receives from the editor. A compile_commands.json symlinked into the
source root is therefore relative to the source root. Since
loadFromBuffer has no file path, it takes the base directory as a new
first parameter.

LLM-aided
DeltaFile
+64-5clang/unittests/Tooling/CompilationDatabaseTest.cpp
+28-13clang/lib/Tooling/JSONCompilationDatabase.cpp
+15-11clang/include/clang/Tooling/JSONCompilationDatabase.h
+5-11clang-tools-extra/test/clang-doc/DR-131697.cpp
+2-1clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+1-1clang/unittests/Tooling/ToolingTest.cpp
+115-422 files not shown
+119-428 files