summaryrefslogtreecommitdiff
path: root/clang-tools-extra/include-cleaner
Commit message (Collapse)AuthorAgeFilesLines
* [include-cleaner] Unify behaviour for static & instance membersKadir Cetinkaya2023-04-182-2/+15
| | | | | | Fixes https://github.com/llvm/llvm-project/issues/62185 Differential Revision: https://reviews.llvm.org/D148552
* [include-cleaner] Handle incomplete template specializationsKadir Cetinkaya2023-04-132-3/+14
| | | | | | | Instantiation pattern is null for incomplete template types and using specializaiton decl results in not seeing re-declarations. Differential Revision: https://reviews.llvm.org/D148158
* [icnlude-cleaner] Fix dandling pointers in testsKadir Cetinkaya2023-04-121-29/+21
|
* [include-cleaner] Improve handling for templatesKadir Cetinkaya2023-04-123-24/+205
| | | | | | | | | | | Principal here is: - Making sure each template instantiation implies use of the most specialized template. As explicit instantiations/specializations are not redeclarations of the primary template. - Introducing a use from explicit instantions/specializaitons to the primary template, as they're required but not traversed as part of the RAV. Differential Revision: https://reviews.llvm.org/D148112
* [include-cleaner] Only ignore builtins without a headerKadir Cetinkaya2023-04-044-34/+65
| | | | | | | | | | | 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
* [include-cleaner] Treat member operator calls as implicitKadir Cetinkaya2023-04-032-5/+6
| | | | | | 26ff268b80c589fd9f71c1c214af77cd972642ca treated member operator calls as explicit, while trying to treat them the same way as regular member expressions, which should've been implicit.
* [include-cleaner] Report references to operator calls as implicitKadir Cetinkaya2023-04-032-11/+25
| | | | | | | Missing these references can result in false negatives in the used-ness analysis and break builds. Differential Revision: https://reviews.llvm.org/D147144
* [include-cleaner] Ignore builtin symbols in the WalkAST.Haojian Wu2023-03-302-0/+10
| | | | | | | | | | | | | There is no need to add headers for builtin symbols. Additionally, there is a bonus benefit which help eliminate some bugs -- builtin functions are modeled as implicit FunctionDecls in the clang AST, which results in them being treated as normal FunctionDecls in the implementation of the include-cleaner (going through the path: ast-node -> decl -> source location -> header). And, the source location of these built-in symbols' AST nodes is not precise (e.g. points to the first call site), which leads to subtle behavior that inserts a header of the call site. Differential Revision: https://reviews.llvm.org/D147213
* [include-cleaner] Visit the VarDecl in ASTWalker.Haojian Wu2023-03-293-9/+29
| | | | | | Fixes https://github.com/clangd/clangd/issues/1554 Differential Revision: https://reviews.llvm.org/D147135
* [clangd] Use expansion location for missing include diagnostics.Viktoriia Bakalova2023-03-271-2/+3
| | | | Differential Revision: https://reviews.llvm.org/D146727
* [include-cleaner] Fix crash on unresolved headersKadir Cetinkaya2023-03-262-46/+66
| | | | | | | | | Make sure unresolved headers are not analyzed as part of unused includes. Also introduces a testing fixture for analyze tests Differential Revision: https://reviews.llvm.org/D146916
* [include-cleaner] Attribute references to explicit specializationsKadir Cetinkaya2023-03-242-8/+61
| | | | | | Fixes https://github.com/llvm/llvm-project/issues/61652 Differential Revision: https://reviews.llvm.org/D146732
* [clangd] Add provider info on symbol hover.Viktoriia Bakalova2023-03-232-7/+11
| | | | Differential Revision: https://reviews.llvm.org/D144976
* [IncludeCleaner][clangd] Mark umbrella headers as users of privateKadir Cetinkaya2023-03-232-13/+47
| | | | | | Private headers inside umbrella files shouldn't be marked as unused. Differential Revision: https://reviews.llvm.org/D146406
* [clang] Fix a UsingTemplate regression after ↵Haojian Wu2023-03-161-0/+7
| | | | | | | | | | | 3e78fa860235431323aaf08c8fa922d75a7cfffa TemplateName::getAsTemplateDecl() returns the underlying TemplateDecl for a UsingTemplate kind template name. We should respect that in the Profile method otherwise we might desugar the template name unexpectedly (e.g. for template argument deduction with deduciton guides). Differential Revision: https://reviews.llvm.org/D146202
* [clang-tools-extra] Use *{Set,Map}::contains (NFC)Kazu Hirata2023-03-142-2/+2
|
* [IncludeCleaner][NFC] Dont rely on implicit conversion of StringRefKadir Cetinkaya2023-03-141-7/+3
| | | | Fixes https://github.com/llvm/llvm-project/issues/61221
* Re-land [clangd] Add support for missing includes analysis.Viktoriia Bakalova2023-03-082-2/+4
| | | | | | This reverts commit fd8c9ef20a9519dccd5b8178b29ed4574285d36f. Differential Revision: https://reviews.llvm.org/D145577
* Revert "Re-land [clangd] Add support for missing includes analysis."Viktoriia Bakalova2023-03-082-4/+2
| | | | This reverts commit 85a5c17b66768353b7fff717904e42805bb6a547.
* Revert "Revert "Re-land [clangd] Add support for missing includes analysis.""Viktoriia Bakalova2023-03-082-2/+4
| | | | This reverts commit 9814b4d07f614e83e7a244f74fc562f2b5cc9b15.
* Revert "Re-land [clangd] Add support for missing includes analysis."Viktoriia Bakalova2023-03-082-4/+2
| | | | This reverts commit 85a5c17b66768353b7fff717904e42805bb6a547.
* Re-land [clangd] Add support for missing includes analysis.Viktoriia Bakalova2023-03-082-2/+4
| | | | This reverts commit 2eb5ac99a76dbbf8ac68c538211fabeaa5ac0bfd.
* Revert "[clangd] Add support for missing includes analysis."Nico Weber2023-03-072-4/+2
| | | | | This reverts commit 38b9fb5a129db3e086610d53b534833273c5b4d0. Breaks tests on Windows, see comments on https://reviews.llvm.org/D143496
* [clangd] Add support for missing includes analysis.Viktoriia Bakalova2023-03-072-2/+4
| | | | Differential Revision: https://reviews.llvm.org/D143496
* [include-cleaner] Fix a crash on non-identifier-name symbols.Haojian Wu2023-03-062-1/+9
| | | | Differential Revision: https://reviews.llvm.org/D145364
* [include-cleaner] Fix an unintended early return when checking theHaojian Wu2023-02-271-2/+3
| | | | incompatible flags in the CLI tool.
* [include-cleaner] Dont pass llvm::StringRef to gtest APIsKadir Cetinkaya2023-02-231-1/+1
| | | | Fixes https://github.com/llvm/llvm-project/issues/60884.
* [include-cleaner] Always treat constructor calls as implicitKadir Cetinkaya2023-02-232-3/+9
| | | | | | | | | | | Treating constructor calls when the type name isn't explicitly spelled can cause spurious results, so turn them into implicit references. This doesn't change the behaviour for constructor calls that explicitly spell the type name, as we should see a reference through the typeloc. Fixes https://github.com/llvm/llvm-project/issues/60812 Differential Revision: https://reviews.llvm.org/D144582
* [include-cleaner] Check macros against stdlib databaseKadir Cetinkaya2023-02-232-4/+19
| | | | Differential Revision: https://reviews.llvm.org/D144579
* [include-cleaner] Better support ambiguous std symbolsHaojian Wu2023-02-142-25/+126
| | | | | | | 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
* Revert "[clang] Build UsingType for elaborated type specifiers."Haojian Wu2023-01-261-3/+0
| | | | | | | | | | | | | | | | | | This reverts commit e70ca7b35319a3621f9d9c6475926428f8c5c000 and the followup patch "[clang] Fix the location of UsingTypeLoc" (ebbeb164c25a40cb6ba9c6b18dce5dcd06c0bb07). The patch causes an incorrect lookup result: ``` namespace ns { struct Foo { };} using ns::Foo; void test() { struct Foo { } k; // the type of k refers to ns::Foo, rather than the local Foo! } ```
* Silence an MSVC "not all control paths return" warning; NFCAaron Ballman2023-01-231-0/+1
|
* [include-cleaner] Ranking of providers based on hintsKadir Cetinkaya2023-01-2311-105/+624
| | | | | | Introduce signals to rank providers of a symbol. Differential Revision: https://reviews.llvm.org/D139921
* [clang] Build UsingType for elaborated type specifiers.Haojian Wu2023-01-191-0/+3
| | | | | | | | | | | | | | | | Support building UsingType for elaborated type specifiers: ``` namespace ns { class Foo {}; } using ns::Foo; // The TypeLoc of `Foo` below should be a ElaboratedTypeLoc with an // inner UsingTypeLoc rather than the underlying `CXXRecordTypeLoc` class Foo foo; ``` Differential Revision: https://reviews.llvm.org/D141280
* [include-cleaner] FindHeaders respects IWYU export pragma for standard headers.Haojian Wu2023-01-165-13/+88
| | | | | | Fixes https://github.com/llvm/llvm-project/issues/59927 Differential Revision: https://reviews.llvm.org/D141670
* [include-cleaner] Remove a stale FIXME.Haojian Wu2023-01-131-2/+0
| | | | This FIXME was addressed in 0e545816a9e582af29ea4b9441fea8ed376cf52a.
* [test] Split out Annotations from `TestingSupport`Jordan Rupprecht2023-01-126-5/+6
| | | | | | | | The Annotations helper class does not have a gtest or gmock dependency, but because it's bundled with the rest of TestingSupport, it gets one. By splitting it out, a target can use it without being forced to use LLVM's copy of gtest. Reviewed By: GMNGeoffrey, sammccall, gribozavr2 Differential Revision: https://reviews.llvm.org/D141175
* [include-cleaner] Treat a constructor call as a use of the class type.Haojian Wu2023-01-122-4/+5
| | | | | | Per the discussion in https://github.com/llvm/llvm-project/issues/59916. Differential Revision: https://reviews.llvm.org/D141592
* [include-cleaner] Improve header spelling in the presence of linksSam McCall2023-01-112-15/+17
| | | | | | | | | | | | | | | | | | | | | | | | HeaderSearch uses FileEntry::getName() to determine the best spelling of a header. FileEntry::getName() is now the name of the *last* retrieved ref. This means that when FileManager::getFile() hits an existing inode through a new path, it changes the spelling of that header. In the absence of explicit logic to track the preferred name(s) of header files, we should avoid gratuitously calling getFile() with paths different than how the header was originally included, such as the result of realpath(). The originally-specified path should be fine here: - if the same filemanager is being used for record/analysis, we'll hit the filename cache - if a different filemanager is being used e.g. preamble scenario, we should get the same result unless either the working directory has changed (which it shouldn't, else many other things will fail) or the file has gone/changed inode (in which case the old method doesn't work either) Needless to say this is fragile, but talking to @kadircet offline, it's good enough for our purposes for now. Differential Revision: https://reviews.llvm.org/D141478
* Move from llvm::makeArrayRef to ArrayRef deduction guides - last partserge-sans-paille2023-01-101-1/+1
| | | | | | | This is a follow-up to https://reviews.llvm.org/D140896, split into several parts as it touches a lot of files. Differential Revision: https://reviews.llvm.org/D141298
* [include-cleaner] Don't count references to operators as usesHaojian Wu2023-01-092-0/+24
| | | | | | Fixes https://github.com/llvm/llvm-project/issues/59655 Differential Revision: https://reviews.llvm.org/D140551
* [include-cleaner] Filter template instantiations from AST roots.Viktoriia Bakalova2023-01-092-1/+37
| | | | | Fix: https://github.com/llvm/llvm-project/issues/59825 Differential Revision: https://reviews.llvm.org/D141271
* [include-cleaner] Respect IWYU pragmas during analyzeKadir Cetinkaya2022-12-202-7/+12
| | | | | | Fixes https://github.com/llvm/llvm-project/issues/59541. Differential Revision: https://reviews.llvm.org/D140380
* [Clang] Prepare for llvm::Optional becoming std::optional.Benjamin Kramer2022-12-201-4/+4
| | | | | | | | | | | The needed tweaks are mostly trivial, the one nasty bit is Clang's usage of OptionalStorage. To keep this working old Optional stays around as clang::CustomizableOptional, with the default Storage removed. Optional<File/DirectoryEntryRef> is replaced with a typedef. I tested this with GCC 7.5, the oldest supported GCC I had around. Differential Revision: https://reviews.llvm.org/D140332
* [include-cleaner] Base-type usage from member exprs is implicit.Haojian Wu2022-12-192-20/+20
| | | | | | Per the discussion on https://reviews.llvm.org/D140095#inline-1352956 Differential Revision: https://reviews.llvm.org/D140284
* [include-cleaner] Use expansion locations for macros.Viktoriia Bakalova2022-12-192-3/+63
| | | | | | 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
* [include-cleaner] Handle dependent type members in AST.Viktoriia Bakalova2022-12-192-0/+11
| | | | | | | Handles dependent type members in AST. Fix: https://github.com/llvm/llvm-project/issues/59354 Differential Revision: https://reviews.llvm.org/D139409
* [include-cleaner] Fix a missing review comment.Haojian Wu2022-12-191-2/+2
| | | | I forgot to add the change to the commit when committing.
* [include-cleaner] Fix the member-expr-access usage for sugar type.Haojian Wu2022-12-192-25/+65
| | | | | | Fixes https://github.com/llvm/llvm-project/issues/59533 Differential Revision: https://reviews.llvm.org/D140095
* Revert "[clang] Convert OptionalFileEntryRefDegradesToFileEntryPtr to ↵Krzysztof Parzyszek2022-12-181-3/+2
| | | | | | | | | | | | | | | std::optional" This reverts commit 8f0df9f3bbc6d7f3d5cbfd955c5ee4404c53a75d. The Optional*RefDegradesTo*EntryPtr types want to keep the same size as the underlying type, which std::optional doesn't guarantee. For use with llvm::Optional, they define their own storage class, and there is no way to do that in std::optional. On top of that, that commit broke builds with older GCCs, where std::optional was not trivially copyable (static_assert in the clang sources was failing).