summaryrefslogtreecommitdiff
path: root/clang-tools-extra
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Log diagnostics if we failed to create a preamble.Sam McCall2022-12-011-0/+6
| | | | | | | | | | Really we want these to be shown to the client, but the path to do so involves storing them in Bandaid for https://github.com/clangd/clangd/issues/1408 See https://github.com/clangd/clangd/issues/1399 for motivation Differential Revision: https://reviews.llvm.org/D139088
* [include-cleaner] Use RAV instead of ASTMatchers in LocateSymbolTestKadir Cetinkaya2022-12-012-24/+18
| | | | | | | ASTMatchers are pulling in lots of dependencies that we don't really need for just finding a decl based on name. So use a simple RAV instead. Differential Revision: https://reviews.llvm.org/D139093
* [include-cleaner] Attempt two at fixing buildbotsKadir Cetinkaya2022-12-011-0/+1
|
* [include-cleaner] Fix buildKadir Cetinkaya2022-12-011-0/+1
|
* [include-cleaner] Introduce symbol to location mappingKadir Cetinkaya2022-12-014-3/+169
| | | | | | | | | | | | Creates a one to many mapping, by returning all the possible locations providing a symbol. Also includes an "is definition" signal for the location, that can be used for ranking afterwards. This also takes care of stdlib symbols by having a variant of locations. Depends on D135859. Differential Revision: https://reviews.llvm.org/D135953
* [clang-tidy] Add misc-use-anonymous-namespace checkCarlos Galvez2022-12-018-0/+228
| | | | Differential Revision: https://reviews.llvm.org/D137340
* [clang-tidy] Suppress google-objc-avoid-throwing-exception in system macros 🫢Stephane Moore2022-11-304-1/+45
| | | | | | | | | | | | | | | | | | The google-objc-avoid-throwing-exception check enforces the Google Objective-C Style Guide's prohibition on throwing exceptions in user code but the check incorrectly triggers findings for code emitted from system headers. This commit suppresses any findings that do not have valid locations or are emitted from macros in system headers. Avoid Throwing Exceptions, Google Objective-C Style Guide: https://github.com/google/styleguide/blob/gh-pages/objcguide.md#avoid-throwing-exceptions Test Notes: Ran clang-tidy lit tests. Reviewed By: gribozavr2 Differential Revision: https://reviews.llvm.org/D137738
* [include-cleaner] Move RecordedPP::RecordedIncludes -> Includes in Types.h. NFCSam McCall2022-11-309-99/+122
| | | | | | | | Requiring everything that wants to match Includes to depend on Record is weird. This isn't lightweight enough that it feels perfect in Types, could be its own header instead. But pragmatically it doesn't add bad deps, and is widely used. Differential Revision: https://reviews.llvm.org/D139014
* [include-cleaner] Record whether includes are spelled with <angle> quotesSam McCall2022-11-305-3/+13
| | | | | | | | | This is needed to accurately remove headers with tooling::IncludeHeaders in the rare cases where <foo> and "foo" resolve to something different. This is also nice to have in HTML report and command-line -print=changes output. Differential Revision: https://reviews.llvm.org/D139018
* [include-cleaner] don't clang-format tests. NFCSam McCall2022-11-301-0/+1
|
* [clang-doc] Fix warnings about lock_guardPetr Hosek2022-11-301-2/+2
| | | | | | | | Fixes a warning about a potentially unsupported template argument deduction by explicitly specifying the template type in std::lock_guard. Patch By: brettw Differential Revision: https://reviews.llvm.org/D138961
* [clang-doc] Move file layout to the generators.Brett Wilson2022-11-297-82/+196
| | | | | | | | | | | | | | | | | | | | | | | | Previously file naming and directory layout was handled on a per Info object basis by ClangDocMain and the generators blindly wrote to the files given. This means all generators must use the same file layout and caused problems where multiple objects mapped to the same file. The object collision problem happens most easily with template specializations because the template parameters are not part of the "name". This patch moves the responsibility for output file organization to the generators. Currently HTML and MD use the same structure as before. But they now collect all objects that map to a given file and combine them, avoiding the corruption problems. Converts the YAML generator to naming files based on USR in one directory. This is easier for downstream tools to manage and avoids the naming problems with template specializations. Since this change requires backward-incompatible output changes to referenced files anyway (since each one is now an array), this is a good time to introduce this change. Differential Revision: https://reviews.llvm.org/D138073
* [Clang] Implement CWG2654: Un-deprecation of compound volatile assignmentsCorentin Jabot2022-11-291-1/+0
| | | | | | Reviewed By: #clang-language-wg, erichkeane Differential Revision: https://reviews.llvm.org/D138918
* [include-cleaner] Implement IWYU begin_keep/end_keep pragma support.Viktoriia Bakalova2022-11-292-42/+85
| | | | | | Implement support for begin_keep/end_keep pragmas. Differential Revision: https://reviews.llvm.org/D138797
* [include-cleaner] Fix -Woverloaded-virtual warning, NFC.Haojian Wu2022-11-291-1/+2
|
* [Support] Move getHostNumPhysicalCores to Threading.hArchibald Elliott2022-11-291-5/+1
| | | | | | | | | | | | | | | | This change is focussed on simplifying `Support/Host.h` to only do target detection. In this case, this function is close in usage to existing functions in `Support/Threading.h`, so I moved it into there. The function is also renamed to `llvm::get_physical_cores()` to match the style of threading's functions. The big change here is that now if you have threading disabled, `llvm::get_physical_cores()` will return -1, as if it had not been able to work out the right info. This is due to how Threading.cpp includes OS-specific code/headers. This seems ok, as if threading is disabled, LLVM should not need to know the number of physical cores. Differential Revision: https://reviews.llvm.org/D137836
* [clangd] Heuristic to avoid desync if editors are confused about newline-at-eofSam McCall2022-11-292-0/+74
| | | | | | | | | | | | | | | As strange as it seems to our files-are-strings view of the world, some editors that treat files as arrays of lines can get confused about whether the last line has a newline or not. The consequences of failing to handle a bad incremental update are catastrophic. If an update would be valid except for a missing newline at end of file, pretend one exists. This fixes problems still present in neovim where deleting all text often leads to a desync shortly afterwards: https://github.com/neovim/neovim/issues/17085 Differential Revision: https://reviews.llvm.org/D135508
* Update wrong Unicode code point in confusable-identifiers.rstRaul Ferrando2022-11-281-1/+1
| | | | | | | | | | | In confusable-identifiers.rst the description refers to wrong Unicode code point. The shown code point is U+1D41F, not U+1234. Updated the code point and it's description. Fixes #58934 Differential Revision: https://reviews.llvm.org/D138838
* [clangd] Fix broken call missed in D138780Sam McCall2022-11-281-1/+2
|
* [clangd] Add script to maintain list of fast clang-tidy checksSam McCall2022-11-283-0/+476
| | | | | | | | | The plan is to intersect this list with the checks selected per config. This is not yet done, but the initial list is checked in as a baseline. https://github.com/clangd/clangd/issues/1337 Differential Revision: https://reviews.llvm.org/D138491
* [include-cleaner] Merge 2 parseIWYUPragma impls in libToolingInclusionsSam McCall2022-11-284-47/+4
| | | | | | | | | | | Based on include-cleaner's version, but: - remove assert that can fail for input `/\<newline>* */` - assert was also checking the wrong condition: that the prefix *differed* from either `//` or from `/*`. Avoid use of strncmp where we can. - add a comment that the brittleness of the text matching is intentional Differential Revision: https://reviews.llvm.org/D138780
* [include-cleaner] Fix walkUsed only report a single macro ref.Haojian Wu2022-11-281-2/+1
|
* [include-cleaner] Capture private headers in PragmaIncludes.Viktoriia Bakalova2022-11-283-15/+38
| | | | | | | | Save file IDs of IWYU private headers and report them as private. Reviewed By: hokein Differential Revision: https://reviews.llvm.org/D138678
* [include-cleaner] Fix a warningKazu Hirata2022-11-251-5/+5
| | | | | | | | This patch fixes: clang-tools-extra/include-cleaner/lib/HTMLReport.cpp:240:51: error: missing field 'Locations' initializer [-Werror,-Wmissing-field-initializers]
* [clang-tidy] Ignore cxxRewrittenBinaryOperator in defaulted function decls ↵Jens Massberg2022-11-252-3/+42
| | | | | | | | | | | | | | | | | in modernize-use-nullptr The check has produced false positives when checking the default implementation of the spaceship operator. The default implementation should be skipped by the check. Modified the existing test so that the check runs into the bug without this fix and add another test case. Fixes #53961. Patch by Jens Massberg. Reviewed By: ilya-biryukov Differential Revision: https://reviews.llvm.org/D138701
* Revert "[Support] Move getHostNumPhysicalCores to Threading.h"Florian Hahn2022-11-251-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 5577207d6d3e0642ea047a8dfbfcf3ad372a7f25. This breaks building LLVM on recent macOS. Error messages below: llvm/lib/Support/Threading.cpp:190:3: error: use of undeclared identifier 'sysctlbyname' sysctlbyname("hw.physicalcpu", &count, &len, NULL, 0); ^ llvm/lib/Support/Threading.cpp:193:13: error: use of undeclared identifier 'CTL_HW' nm[0] = CTL_HW; ^ llvm/lib/Support/Threading.cpp:194:13: error: use of undeclared identifier 'HW_AVAILCPU' nm[1] = HW_AVAILCPU; ^ llvm/lib/Support/Threading.cpp:195:5: error: use of undeclared identifier 'sysctl' sysctl(nm, 2, &count, &len, NULL, 0); ^
* [Support] Move getHostNumPhysicalCores to Threading.hArchibald Elliott2022-11-251-5/+1
| | | | | | | | | | This change is focussed on simplifying `Support/Host.h` to only do target detection. In this case, this function is close in usage to existing functions in `Support/Threading.h`, so I moved it into there. The function is also renamed to `llvm::get_physical_cores()` to match the style of threading's functions. Differential Revision: https://reviews.llvm.org/D137836
* [include-cleaner] Make HTMLReport impl simpler/safer. NFCSam McCall2022-11-251-77/+70
| | | | | | | Targets and Refs are 1:1, so merge them. Don't sort Refs array we keep indices into. (Currently we're done using those indices by the time we sort, but this is fragile)
* [include-cleaner] HTMLReport shows headers that would be insertedSam McCall2022-11-253-22/+96
| | | | | | | | | | | | Demo: https://htmlpreview.github.io/?https://gist.githubusercontent.com/sam-mccall/9730f933a2cf2e003365520b6636f731/raw/7911d8251ceab7c244e0510285105027cd0a9403/PathMapping.cpp.html Header insertion doesn't actually work that well (not this patch's fault): - we don't have ranking of locations/headers yet, so inserted header is pretty random - on my system, we get a lot of absolute "/usr/bin/../include/..." paths. This is a HeaderSearch bug introduced in D60873 that I'll send a fix for Differential Revision: https://reviews.llvm.org/D138676
* [include-cleaner] Show details for #include directives (used/unused)Sam McCall2022-11-243-21/+116
| | | | Differential Revision: https://reviews.llvm.org/D138649
* [include-cleaner] Make Symbol (and Macro) hashable.Sam McCall2022-11-241-1/+35
| | | | | | | For now, we decided not to add operator< or handle other variants. (If we do so in future we may want to extract a base class). Differential Revision: https://reviews.llvm.org/D138648
* [include-cleaner] Record macro references in #ifdef clause.Viktoriia Bakalova2022-11-242-6/+85
| | | | | | | | Records macro references in #ifdef clauses as ambiguous. Reviewed By: hokein Differential Revision: https://reviews.llvm.org/D138559
* [include-cleaner] Remove an unused local variable, NFC.Haojian Wu2022-11-241-1/+0
|
* Use std::nullopt_t instead of NoneType (NFC)Kazu Hirata2022-11-232-2/+2
| | | | | | | | | | | | | | | | This patch replaces those occurrences of NoneType that would trigger an error if the definition of NoneType were missing in None.h. To keep this patch focused, I am deliberately not replacing None with std::nullopt in this patch or updating comments. They will be addressed in subsequent patches. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716 Differential Revision: https://reviews.llvm.org/D138539
* [include-cleaner] Show includes matched by refs in HTML report.Sam McCall2022-11-233-19/+54
| | | | | | Demo: https://htmlpreview.github.io/?https://gist.githubusercontent.com/sam-mccall/ecee6869e37af3db28089b64d8dce806/raw/8736e64c45af411e2c2d72adaed2dfc4410a5b36/ASTTests.html%25202 Differential Revision: https://reviews.llvm.org/D138219
* Revert "[clang-doc] Move file layout to the generators."Paul Kirth2022-11-227-196/+82
| | | | | | | This reverts commit f8a469fc572778d05b72f34a772082cf3abd3cda. The test in single-file-public.cpp breaks on Mac, due to an unknown regextype in the find command.
* [clang-doc] Move file layout to the generators.Brett Wilson2022-11-227-82/+196
| | | | | | | | | | | | | | | | | | | | | | | | Previously file naming and directory layout was handled on a per Info object basis by ClangDocMain and the generators blindly wrote to the files given. This means all generators must use the same file layout and caused problems where multiple objects mapped to the same file. The object collision problem happens most easily with template specializations because the template parameters are not part of the "name". This patch moves the responsibility for output file organization to the generators. Currently HTML and MD use the same structure as before. But they now collect all objects that map to a given file and combine them, avoiding the corruption problems. Converts the YAML generator to naming files based on USR in one directory. This is easier for downstream tools to manage and avoids the naming problems with template specializations. Since this change requires backward-incompatible output changes to referenced files anyway (since each one is now an array), this is a good time to introduce this change. Differential Revision: https://reviews.llvm.org/D138073
* Don't use Optional::getPointer (NFC)Kazu Hirata2022-11-217-21/+19
| | | | | | | | | | | | | Since std::optional does not offer getPointer(), this patch replaces X.getPointer() with &*X to make the migration from llvm::Optional to std::optional easier. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716 Differential Revision: https://reviews.llvm.org/D138466
* [clangd] Mark "override" and "final" as modifiersChristian Kandeler2022-11-213-0/+23
| | | | | | | | | | | ... in semantic highlighting. These specifiers cannot be identified by simple lexing (since e.g. variables with these names can legally be declared), which means they should be semantic tokens. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D137943
* [clangd] Add option to skip per-location checks.Sam McCall2022-11-211-1/+8
| | | | This avoids a slow step after timing tidy checks for https://github.com/clangd/clangd/issues/1337
* [clangd] Move --check options into Check.cpp. Add --check-completion.Sam McCall2022-11-212-51/+41
| | | | | | This is less plumbing and clutter in ClangdMain.cpp. Having --check-lines imply completion was just about minimizing plumbing I think, so make that explicit.
* [clangd] Extend --check to time clang-tidy checks, so we can block slow onesSam McCall2022-11-211-0/+115
| | | | | | | | | | misc-const-correctness is so catastrophically slow that we need to block it from running. But we need a way to detect this without breaking users first. This is part of a plan to run only fast checks by default. More details in https://github.com/clangd/clangd/issues/1337 Differential Revision: https://reviews.llvm.org/D136082
* [clang-tidy] Remove a duplicated if-branch in the unused-using-declHaojian Wu2022-11-181-3/+0
| | | | check, NFC
* [Support] Add support for attaching payloads to points and rangesTom Praschan2022-11-182-10/+55
| | | | | | | | | | | | | | This is useful where tests previously encoded information in the name names of ranges and points. Currently, this is pretty limited because names consist of only alphanumeric characters and '_'. With this patch, we can keep the names simple and attach optional payloads to ranges and points instead. The new syntax should be fully backwards compatible (if I haven't missed anything). I tested this against clangd unit tests and everything still passes. Differential Revision: https://reviews.llvm.org/D137909
* [include-cleaner] Add self-contained file support for PragmaIncludes.Haojian Wu2022-11-187-62/+190
| | | | | | | | 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
* [include-cleaner] Fix building with LLVM_LINK_LLVM_DYLIB=ON on mingwMartin Storsjö2022-11-181-1/+3
| | | | | | | | | | | | Make sure to use clang_target_link_libraries, which skips linking against libraries and links against libclang-cpp instead, if LLVM_LINK_LLVM_DYLIB is enabled. This fixes errors like these: ld.lld: error: duplicate symbol: clang::PPCallbacks::~PPCallbacks() >>> defined at libclangLex.a(PPCallbacks.cpp.obj) >>> defined at libclang-cpp.dll
* [CMake] Remove a duplicate clangLex entryFangrui Song2022-11-181-1/+0
|
* [include-cleaner] Fix -DBUILD_SHARED_LIBS=on buildFangrui Song2022-11-182-0/+2
| | | | | | | and apply an include-cleaner fix for the tool itself:) addPPCallbacks requires the vtable of PPChainedCallbacks and needs a clangLex dependency.
* [include-cleaner] Fix the build of include-cleaner with LLVM_BUILD_LLVM_DYLIB=ONAlexander Shaposhnikov2022-11-181-0/+1
|
* [clang-tidy] Fix misc-unused-using-decls for user-defined literalsv1nh1shungry2022-11-172-0/+8
| | | | | | | | | Current version complains unused using-declaration even if the target user-defined literal is used. Reviewed By: ymandel Differential Revision: https://reviews.llvm.org/D138204