12 Commits

Author SHA1 Message Date
Qiongsi Wu
5d01a0ad3d
[clang][Modules] Fixing Incorrect Diagnostics Issued during By-name Dependency Scanning (#178542)
The by-name lookup API uses the same diagnostics engine and consumer for
multiple lookups. When multiple lookups fail, the diagnostics could be
incorrect for all but the first failing lookup. All the subsequent
failing lookups inherit the diagnostics from the first failing lookup.

This PR resets the diagnostics consumer's buffer and the
CompilerInstance's diagnostics engine for each by-name lookup, so each
lookup can produce the correct diagnostics.

Part of work for rdar://136303612.
2026-01-30 08:41:11 -08:00
Jan Svoboda
e667c39e49
[clang] Reference-count ModuleCache non-intrusively (#164889)
The `ModuleCache` class is currently reference-counted intrusively. As
explained in https://github.com/llvm/llvm-project/pull/139584, this is
problematic. This PR uses `std::shared_ptr` to reference-count
`ModuleCache` instead, which clarifies what happens to its lifetime when
constructing `CompilerInstance`, for example. This also makes the
reference in `ModuleManager` non-owning, simplifying the ownership
relationship further. The
`ASTUnit::transferASTDataFromCompilerInstance()` function now accounts
for that by taking care to keep it alive.
2026-01-06 13:38:34 -08:00
Naveen Seth Hanig
02451f54d6
[clang][DependencyScanning] Remove dependency on clangDriver from clangDependencyScanning (#172347)
This is the final patch in a series that removes the dependency of
`clangDependencyScanning` on `clangDriver`, splitting the work from
#169964 into smaller changes (see comment linked below).

This patch updates the remaining parts of the scanning interface in
`DependencyScanningWorker` to only operate on `-cc1` / driver job
command lines.
This follows #171238, which applied this change to the by-name scanning
API.

This is part of a broader effort to support driver-managed builds for
compilations using C++ named modules and/or Clang modules. It is
required for linking the dependency scanning tooling against the driver
without introducing cyclic dependencies, which would otherwise cause
build failures when dynamic linking is enabled.

---------

Co-authored-by: Jan Svoboda <jan@svoboda.ai>
2026-01-05 22:56:32 +00:00
Victor Chernyakin
c438773432
[LLVM][ADT] Migrate users of make_scope_exit to CTAD (#174030)
This is a followup to #173131, which introduced the CTAD functionality.
2026-01-02 20:42:56 -08:00
Cyndy Ishida
36c27c63af
[clang][modules] print mtime of input files when recorded in "module-file-info" (#173120)
When debugging issues related to invalidation for implicit module
compilations, it can be helpful to consult the PCM to see what the saved
mtime was.
2025-12-19 16:54:57 -08:00
Jan Svoboda
5f4b9ae851
[clang][deps] Extract CompilerInvocation creation (#172744)
This PR extracts the modifications we make to the scanner's
`CompilerInvocation` from multiple spots into a single function.
2025-12-17 16:44:52 -08:00
Jan Svoboda
db1fd3fd2a
[clang] Remove pointless hasDiagnostics() checks (#172705)
Calling `CompilerInstance::hasDiagnostics()` after
`CompilerInstance::createDiagnostics()` is pointless, since the creation
step cannot fail. This removes such calls.
2025-12-17 12:18:28 -08:00
Naveen Seth Hanig
57fcbd46bf
[clang][DependencyScanning] Unify initVFS helpers to return OverlayFileSystem (NFC) (#172166)
This patch is part of a series of splitting the work from #169964 into
smaller changes (see review linked below).

As part of this work, the regular and by-name dependency scanning APIs
need to be extended to allow the VFS to be initialized via the
initVFS helpers before invoking the scanning API, with the resulting
overlay filesystem passed into the worker instead.

To make the newly added API changes consistent, this patch updates both
helpers to return an OverlayFileSystem.

https://github.com/llvm/llvm-project/pull/169964#pullrequestreview-3545879529
2025-12-15 17:34:37 +01:00
Naveen Seth Hanig
ad2fca7513
[clang][DependencyScanning] Move driver-command logic for by-name scanning into DependencyScanningTool (#171238)
This is the second patch in a series that removes the dependency of
clangDependencyScanning on clangDriver, splitting the work from
#169964 into smaller changes (see comment linked below).

This patch updates the by-name scanning interface in
DependencyScanningWorker to accept only -cc1 command lines directly
and moves the logic for handling driver-style command lines into
DependencyScanningTool in clangTooling.
Support for -cc1 command lines in by-name scanning is introduced in
this patch.

The next patch will update the remaining parts of
DependencyScanningWorker to operate only on -cc1 command lines,
allowing its dependency on clangDriver to be removed.

https://github.com/llvm/llvm-project/pull/169964#pullrequestreview-3545879529
2025-12-13 04:44:26 +05:30
Naveen Seth Hanig
eab9394a45
[clang][DependencyScanning] Fix spelling mistake for DiagnosticsEngineWithDiagOpts (#171535) 2025-12-10 00:32:39 +00:00
Naveen Seth Hanig
2e2fe683af
[clang][DependencyScanning] Use ArrayRef in function signatures over const std::vector& (NFC) (#170941)
This updates the dependency-scanning tooling to consistently use
`ArrayRef<std::string>` rather than `const std::vector<std::string>&` in
function signatures.

This is done to help break PR #169964 into smaller, more manageable
pieces.
2025-12-05 23:07:55 +00:00
Naveen Seth Hanig
b70be3dc14
[clang][DependencyScanning] Separate clangDependencyScanning and DependencyScanningTool (NFC) (#169962)
This patch is the first of two in refactoring Clang's dependency
scanning tooling to remove its dependency on clangDriver.

It separates Tooling/DependencyScanningTool.cpp from the rest of
clangDependencyScanning and moves clangDependencyScanning out of
clangTooling into its own library. No functional changes are
introduced.

The follow-up patch (#169964) will restrict clangDependencyScanning to
handling only -cc1 command line inputs and will move all functionality
related to handling driver commands into clangTooling.
(Tooling/DependencyScanningTool.cpp).

This is part of a broader effort to support driver-managed builds for
compilations using C++ named modules and/or Clang modules. It is
required for linking the dependency scanning tooling against the driver
without introducing cyclic dependencies, which would otherwise cause
build failures when dynamic linking is enabled.

The RFC for this change can be found here:

https://discourse.llvm.org/t/rfc-new-clangoptions-library-remove-dependency-on-clangdriver-from-clangfrontend-and-flangfrontend/88773?u=naveen-seth
2025-12-04 00:38:21 +01:00