18 Commits

Author SHA1 Message Date
Haojian Wu
7b3db8079d
[include-cleaner] Respect the UsingShadowDecl when find headers for ambiguous std symbols. (#66485)
In libcpp, the `std::remove(const char*)` is a using decl in std
namespace `using ::remove`, which was not handled correctly in
`headerForAmbiguousStdSymbol`
2023-09-22 14:35:00 +02:00
Jan Svoboda
eea232da82 [clang][tools] Remove path separator assumption
After 98e6deb6 the 'HeadersForSymbolTest.IWYUTransitiveExportWithPrivate' test in 'ClangIncludeCleanerTest' started failing. This is most likely because `FileEntryRef::getName()` now starts with ".\" on Windows, whereas `FileEntry::getName()` did not. This commit fixes assumption of forward slash separators.
2023-09-09 11:38:32 -07:00
Jan Svoboda
98e6deb62c [clang][tools] Use FileEntryRef in include_cleaner::Header 2023-09-09 09:54:13 -07:00
Viktoriia Bakalova
d71adebb9f [include-cleaner] Map the 4-argument move overload to the algorithm header.
Differential Revision: https://reviews.llvm.org/D159463
2023-09-06 11:38:56 +00:00
Viktoriia Bakalova
c3ad4b7636 [include-cleaner] Follow IWYU pragma: export links transitively.
Differential Revision: https://reviews.llvm.org/D157395
2023-08-09 12:10:13 +00:00
Kadir Cetinkaya
5933d265b7
[include-cleaner] Add a signal to down-rank exporting headers
Currently exporter can have same relevance signals as the origin header
when name match signals don't trigger.
This patch introduces a tie braker signal to boost origin headers in
such cases, this is deliberately introduced with lower significance than
public-ness to make sure we still prefer a public-exporter instead of a
private-origin header.

Differential Revision: https://reviews.llvm.org/D154349
2023-07-05 15:37:17 +02:00
Haojian Wu
48967c6e55 [include-cleaner] Don't apply the PreferredHeader hint for standard headers.
Fixes https://github.com/llvm/llvm-project/issues/62635

Differential Revision: https://reviews.llvm.org/D152801
2023-06-13 18:57:45 +02:00
Kadir Cetinkaya
3402b77db3
[include-cleaner] Only ignore builtins without a header
Certain standard library functions (e.g. std::move) are also implemented
as builtins. This patch moves filtering logic to the symbol->header
mapping phase to rather generate these references without any providers
only when we don't have a mapping.
That way we can also map them to header names mentioned in the builtin
mappings.

Differential Revision: https://reviews.llvm.org/D147449
2023-04-04 13:28:56 +02:00
Haojian Wu
b2897ad703 [include-cleaner] Fix a crash on non-identifier-name symbols.
Differential Revision: https://reviews.llvm.org/D145364
2023-03-06 13:18:43 +01:00
Haojian Wu
504aa8ae94 [include-cleaner] Better support ambiguous std symbols
By special-casing them at the moment. The tooling stdlib lib doesn't
support these symbols (most important one is std::move).

Differential Revision: https://reviews.llvm.org/D143906
2023-02-14 10:18:38 +01:00
Kadir Cetinkaya
749c6a7083
[include-cleaner] Ranking of providers based on hints
Introduce signals to rank providers of a symbol.

Differential Revision: https://reviews.llvm.org/D139921
2023-01-23 15:22:47 +01:00
Haojian Wu
f4a7448653 [include-cleaner] FindHeaders respects IWYU export pragma for standard headers.
Fixes https://github.com/llvm/llvm-project/issues/59927

Differential Revision: https://reviews.llvm.org/D141670
2023-01-16 10:09:18 +01:00
Viktoriia Bakalova
81c3739156 [include-cleaner] Use expansion locations for macros.
Use expansion locations for target symbol decls when finding headers for macros.
Fix: https://github.com/llvm/llvm-project/issues/59392
Differential Revision: https://reviews.llvm.org/D139716
2022-12-19 14:18:16 +00:00
Haojian Wu
e864749d4d [include-cleaner] Add a newline at end of the file, NFC 2022-12-12 15:29:27 +01:00
Haojian Wu
0cf8885144 [include-cleaner] Add self-contained file support for PragmaIncludes.
And use it findHeaders. findHeaders now finds all header candidates
given a symbol location (these headers will be attached with proper
signals, in a followup patch).

Differential Revision: https://reviews.llvm.org/D137698
2022-11-18 13:52:30 +01:00
Sam McCall
2675773258 [include-cleaner] add macro symbols and implicit refs to HTML report
Demo: 8c5c5ad927/ASTTests.html

Differential Revision: https://reviews.llvm.org/D137677
2022-11-17 17:29:41 +01:00
Haojian Wu
e000c2bce7 [include-cleaner] NFC, move the macro location fixme to findHeaders. 2022-11-11 14:55:29 +01:00
Sam McCall
7943169273 [clang-include-cleaner] make SymbolLocation a real class, move FindHeaders
- replace SymbolLocation std::variant with enum-exposing version similar to
  those in types.cpp. There's no appropriate implementation file, added
  LocateSymbol.cpp in anticipation of locateDecl/locateMacro.
- FindHeaders is not part of the public Analysis interface, so should not
  be implemented/tested there (just code organization)
- rename findIncludeHeaders->findHeaders to avoid confusion with Include concept

Differential Revision: https://reviews.llvm.org/D137825
2022-11-11 13:41:54 +01:00