Commit Graph

4156 Commits

Author SHA1 Message Date
Jonas Toth 4b59a1fe29 Use the standard Duration factory matcher
Summary: A new check came in over the weekend; it should use our existing infrastructure for matching `absl::Duration` factories.

Patch by hwright.

Reviewers: JonasToth

Reviewed By: JonasToth

Subscribers: astrelni

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D55541

llvm-svn: 348842
2018-12-11 12:45:51 +00:00
Jonas Toth fe7592d48e [clang-tidy] NFC Consolidate test absl::Time implementation
Summary: Several tests re-implement these same prototypes (differently), so we can put them in a common location.

Patch by hwright.

Reviewers: JonasToth

Reviewed By: JonasToth

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D55540

llvm-svn: 348840
2018-12-11 12:42:17 +00:00
Jonas Toth e740145e19 [clang-tidy] insert release notes for new checkers alphabetically
Summary:
Almost all code review comments on new checkers {D55433} {D48866} {D54349} seem to ask for the release notes to be added alphabetically, plus I've seen commits by @Eugene.Zelenko reordering the lists

Make add_new_check.py add those release notes alphabetically based on checker name

If include-fixer section is seen add it at the end

Minor change in the message format to prevent double newlines added before the checker.

Do the tools themselves have unit tests? (sorry new to this game)

- Tested adding new checker at the beginning
- Tested on adding new checker in the middle
- Tested on empty ReleasesNotes.rst (as we would see after RC)

Patch by MyDeveloperDay.

Reviewers: alexfh, JonasToth, curdeius, aaron.ballman, benhamilton, hokein

Reviewed By: JonasToth

Subscribers: cfe-commits, xazax.hun, Eugene.Zelenko

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D55508

llvm-svn: 348793
2018-12-10 19:41:53 +00:00
Eugene Zelenko 7bde7265f2 [Documentation] Alphabetical order in new checks list.
llvm-svn: 348666
2018-12-08 00:07:34 +00:00
Eric Fiselier 2bbbd8be24 [clang-tidy]: Abseil: new check 'abseil-upgrade-duration-conversions'
Patch by Alex Strelnikov.
Reviewed as D53830

Introduce a new check to upgrade user code based on upcoming API breaking changes to absl::Duration.

The check finds calls to arithmetic operators and factory functions for absl::Duration that rely on
an implicit user defined conversion to int64_t. These cases will no longer compile after proposed
changes are released. Suggested fixes explicitly cast the argument int64_t.

llvm-svn: 348633
2018-12-07 20:03:03 +00:00
Haojian Wu 75f6caddab [clang-tidy] Remove duplicated getText implementation, NFC
llvm-svn: 348583
2018-12-07 11:25:37 +00:00
Ilya Biryukov f30c4ad325 [clangd] Remove the test that sometimes deadlocks
Will figure out how to properly rewrite it and recommit.

llvm-svn: 348490
2018-12-06 15:14:11 +00:00
Haojian Wu a44eb93a4b [clangd] Update the test code
I forgot to update it in the last round of code review.

llvm-svn: 348478
2018-12-06 10:22:48 +00:00
Haojian Wu ec3d02013f [clangd] C++ API for emitting file status.
Introduce clangd C++ API to emit the current status of file.

llvm-svn: 348475
2018-12-06 09:41:04 +00:00
Haojian Wu e3fa82fcde [clangd] Fix a typo in TUSchedulerTests
Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D55312

llvm-svn: 348467
2018-12-06 08:55:24 +00:00
Ilya Biryukov 44a40046c8 Move detection of libc++ include dirs to Driver on MacOS
Summary:
The intention is to make the tools replaying compilations from 'compile_commands.json'
(clang-tidy, clangd, etc.) find the same standard library as the original compiler
specified in 'compile_commands.json'.

Previously, the library detection logic was in the frontend (InitHeaderSearch.cpp) and relied
on the value of resource dir as an approximation of the compiler install dir. The new logic
uses the actual compiler install dir and is performed in the driver. This is consistent with
the C++ standard library detection on other platforms and allows to override the resource dir
in the tools using the compile_commands.json without altering the
standard library detection mechanism. The tools have to override the resource dir to make sure
they use a consistent version of the builtin headers.

There is still logic in InitHeaderSearch that attemps to add the absolute includes for the
the C++ standard library, so we keep passing the -stdlib=libc++ from the driver to the frontend
via cc1 args to avoid breaking that. In the long run, we should move this logic to the driver too,
but it could potentially break the library detection on other systems, so we don't tackle it in this
patch to keep its scope manageable.

This is a second attempt to fix the issue, first one was commited in r346652 and reverted in r346675.
The original fix relied on an ad-hoc propagation (bypassing the cc1 flags) of the install dir from the
driver to the frontend's HeaderSearchOptions. Unsurpisingly, the propagation was incomplete, it broke
the libc++ detection in clang itself, which caused LLDB tests to break.

The LLDB tests pass with new fix.

Reviewers: JDevlieghere, arphaman, EricWF

Reviewed By: arphaman

Subscribers: mclow.lists, ldionne, dexonsmith, ioeric, christof, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D54630

llvm-svn: 348365
2018-12-05 14:24:14 +00:00
Kadir Cetinkaya 6f9b204261 [clangd] Dont provide locations for non-existent files.
Summary:
We were getting assertion errors when we had bad file names, instead we
should skip those.

Reviewers: hokein

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D55275

llvm-svn: 348359
2018-12-05 11:57:15 +00:00
Mikael Holmen 18e800f0dd Fix compilation error when using clang 3.6.0
llvm-svn: 348357
2018-12-05 11:29:27 +00:00
Jonas Toth 71a29aa947 Revert "[clang-tidy] new check: bugprone-branch-clone"
The patch broke on buildbot with assertion-failure. Revert until this
is figured out.

llvm-svn: 348344
2018-12-05 09:34:18 +00:00
Jonas Toth cd207f1552 [clang-tidy] new check: bugprone-branch-clone
Summary:
Implement a check for detecting if/else if/else chains where two or more
branches are Type I clones of each other (that is, they contain identical code)
and for detecting switch statements where two or more consecutive branches are
Type I clones of each other.

Patch by donat.nagy.

Reviewers: alexfh, hokein, aaron.ballman, JonasToth

Reviewed By: JonasToth

Subscribers: MTC, lebedev.ri, whisperity, xazax.hun, Eugene.Zelenko, mgorny, rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D54757

llvm-svn: 348343
2018-12-05 09:16:25 +00:00
Jonas Toth c361e0d627 Fix a false positive in misplaced-widening-cast
Summary:
bugprone-misplaced-widening-cast check
used to give a false warning to the
following example.

 enum DaysEnum{
    MON = 0,
    TUE = 1
    };

 day = (DaysEnum)(day + 1);
 //warning: either cast from 'int' to 'DaysEnum' is ineffective...

But i think int to enum cast is not widening neither ineffective.

Patch by dkrupp.

Reviewers: JonasToth, alexfh

Reviewed By: alexfh

Subscribers: rnkovacs, Szelethus, gamesh411, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D55255

llvm-svn: 348341
2018-12-05 08:29:56 +00:00
Stephane Moore af4755aca8 [clang-tidy/checks] Update objc-property-declaration check to allow arbitrary acronyms and initialisms 🔧
Summary:
§1 Description

This changes the objc-property-declaration check to allow arbitrary acronyms and initialisms instead of using whitelisted acronyms. In Objective-C it is relatively common to use project prefixes in property names for the purposes of disambiguation. For example, the CIColor¹ and CGColor² properties on UIColor both represent symbol prefixes being used in proeprty names outside of Apple's accepted acronyms³. The union of Apple's accepted acronyms and all symbol prefixes that might be used for disambiguation in property declarations effectively allows for any arbitrary sequence of capital alphanumeric characters to be acceptable in property declarations. This change updates the check accordingly.

The test variants with custom configurations are deleted as part of this change because their configurations no longer impact behavior. The acronym configurations are currently preserved for backwards compatibility of check configuration.

[1] https://developer.apple.com/documentation/uikit/uicolor/1621951-cicolor?language=objc
[2] https://developer.apple.com/documentation/uikit/uicolor/1621954-cgcolor?language=objc
[3] https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/APIAbbreviations.html#//apple_ref/doc/uid/20001285-BCIHCGAE

§2 Test Notes

Changes verified by:
• Running clang-tidy unit tests.
• Used check_clang_tidy.py to verify expected output of processing objc-property-declaration.m

Reviewers: benhamilton, Wizard

Reviewed By: benhamilton

Subscribers: jfb, cfe-commits

Differential Revision: https://reviews.llvm.org/D51832

llvm-svn: 348331
2018-12-05 03:44:03 +00:00
George Karpenkov d499725b8f [clang-query] Continue if compilation command not found for some files
When searching for a code pattern in an entire project with a
compilation database it's tempting to run

```
clang-query **.cpp
```

And yet, that often breaks because some files are just not in the
compilation database: tests, sample code, etc..
clang-query should not stop when encountering such cases.

Differential Revision: https://reviews.llvm.org/D51183

llvm-svn: 348328
2018-12-05 02:02:40 +00:00
Stephane Moore f6d96e0f98 [clang-tidy] Ignore namespaced and C++ member functions in google-objc-function-naming check 🙈
Summary: The google-objc-function-naming check applies to functions that are not namespaced and should not be applied to C++ member functions. Such function declarations should be ignored by the check to avoid false positives in Objective-C++ sources.

Reviewers: benhamilton, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Differential Revision: https://reviews.llvm.org/D55101

llvm-svn: 348317
2018-12-04 23:40:42 +00:00
Eugene Zelenko 86c804d3f8 [Documentation] Make options section in Clang-tidy readability-uppercase-literal-suffix consistent with other checks.
llvm-svn: 348302
2018-12-04 21:19:08 +00:00
Simon Pilgrim 2d12d810f4 Fix "array must be initialized with a brace-enclosed initializer" build error.
Try to fix clang-bpf-build buildbot.

llvm-svn: 348262
2018-12-04 14:07:29 +00:00
Kadir Cetinkaya 219c0fae5c [clangd] Partition include graph on auto-index.
Summary:
Partitions include graphs in auto-index so that each shards contains
only part of the include graph related to itself.

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D55062

llvm-svn: 348252
2018-12-04 11:31:57 +00:00
Eugene Zelenko 1dbbc5f640 [Documentation] Fix formatting and wrap up to 80 characters in Clang-tidy readability-uppercase-literal-suffix documentation.
llvm-svn: 348202
2018-12-03 22:35:40 +00:00
Zachary Turner aa2711f1f8 Fix compilation failure on Windows.
This was introduced earlier but apparently used an incorrect
class name so it doesn't compile on Windows.

llvm-svn: 348176
2018-12-03 19:59:00 +00:00
Jonas Toth 3f51ee19ae [clang-tidy] Fix unordered_map failure with specializing std::hash<> and remove previous wrong attempt at doing so
llvm-svn: 348172
2018-12-03 19:41:04 +00:00
Jonas Toth 00f1d76738 [clang-tidy] Recommit: Add the abseil-duration-comparison check
Summary:
This check finds instances where Duration values are being converted to a numeric value in a comparison expression, and suggests that the conversion happen on the other side of the expression to a Duration.  See documentation for examples.

This also shuffles some code around so that the new check may perform in sone step simplifications also caught by other checks.
Compilation is unbroken, because the hash-function is now directly
specified for std::unordered_map, as 'enum class' does not compile as
key (seamingly only on some compilers).

Patch by hwright.

Reviewers: aaron.ballman, JonasToth, alexfh, hokein

Reviewed By: JonasToth

Subscribers: sammccall, Eugene.Zelenko, xazax.hun, cfe-commits, mgorny

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D54737

llvm-svn: 348169
2018-12-03 19:22:08 +00:00
Jonas Toth b77711e297 Revert "[clang-tidy] Add the abseil-duration-comparison check"
This commit broke buildbots and needs adjustments.

llvm-svn: 348165
2018-12-03 18:59:27 +00:00
Jonas Toth 5da1825ebc [clang-tidy] Add the abseil-duration-comparison check
Summary:
This check finds instances where Duration values are being converted to a numeric value in a comparison expression, and suggests that the conversion happen on the other side of the expression to a Duration.  See documentation for examples.

This also shuffles some code around so that the new check may perform in sone step simplifications also caught by other checks.

Patch by hwright.

Reviewers: aaron.ballman, JonasToth, alexfh, hokein

Reviewed By: JonasToth

Subscribers: sammccall, Eugene.Zelenko, xazax.hun, cfe-commits, mgorny

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D54737

llvm-svn: 348161
2018-12-03 18:35:56 +00:00
Ilya Biryukov 1712bc7640 [clangd] Avoid memory-mapping files on Windows
Summary:
Memory-mapping files on Windows leads to them being locked and prevents
editors from saving changes to those files on disk. This is fine for the
compiler, but not acceptable for an interactive tool like clangd.
Therefore, we choose to avoid using memory-mapped files on Windows.

Reviewers: hokein, kadircet

Reviewed By: kadircet

Subscribers: yvvan, zturner, nik, malaperle, mgorny, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D55139

llvm-svn: 348147
2018-12-03 15:21:49 +00:00
Haojian Wu 7800dbe157 [clangd] Fix a stale comment, NFC.
llvm-svn: 348133
2018-12-03 13:16:04 +00:00
Haojian Wu dd61ccbb70 [clangd] Get rid of AST matchers in CodeComplete, NFC
Summary:
The isIndexedForCodeCompletion is called in the code patch of
SymbolCollector.

Reviewers: kadircet

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D55206

llvm-svn: 348130
2018-12-03 12:53:19 +00:00
Fangrui Song 23b123f675 [clangd] Recommit the "AnyScope" changes in requests.json by rCTE347753 (reverted by rCTE347792)
This fixes IndexBenchmark tests.

llvm-svn: 348066
2018-12-01 01:57:15 +00:00
Kadir Cetinkaya 5399552da1 [clangd] Populate include graph during static indexing action.
Summary:
This is the second part for introducing include hierarchy into index
files produced by clangd. You can see the base patch that introduces structures
and discusses the future of the patches in D54817

Reviewers: ilya-biryukov

Subscribers: mgorny, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D54999

llvm-svn: 348005
2018-11-30 16:59:00 +00:00
Eric Liu 5ac37f495a [clangd] Penalize destructor and overloaded operators in code completion.
Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D55061

llvm-svn: 347983
2018-11-30 11:17:15 +00:00
Eric Liu b1317fa8df [clangd] Drop injected class name when class scope is not explicitly specified.
Summary: E.g. allow injected "A::A" in `using A::A^` but not in "A^".

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D55065

llvm-svn: 347982
2018-11-30 11:12:40 +00:00
Haojian Wu 260f83c426 [clangd] Bump vscode-clangd v0.0.8
llvm-svn: 347969
2018-11-30 09:18:31 +00:00
Haojian Wu a5f6a93889 [clangd] Fix junk output in clangd vscode plugin
Summary:
When using the vscode clangd plugin, lots and lots of junk output is printed to the output window, which constantly reopens itself.
Example output:

I[11:13:17.733] <-- textDocument/codeAction(4)
I[11:13:17.733] --> reply:textDocument/codeAction(4) 0 ms
I[11:13:17.937] <-- textDocument/codeAction(5)
I[11:13:17.937] --> reply:textDocument/codeAction(5) 0 ms
I[11:13:18.557] <-- textDocument/hover(6)
I[11:13:18.606] --> reply:textDocument/hover(6) 48 ms

This should prevent that from happening.

Patch by James Findley!

Reviewers: ioeric, ilya-biryukov, hokein

Reviewed By: ioeric

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D55052

llvm-svn: 347968
2018-11-30 09:14:52 +00:00
Aaron Ballman 3e3696bf46 Adding a FIXME test to document an area for improvement with the cert-err58-cpp check; NFC.
llvm-svn: 347860
2018-11-29 12:45:50 +00:00
Eugene Zelenko 54c82d3642 [Documentation] Try to fix build failure in cppcoreguidelines-narrowing-conversions documentation
llvm-svn: 347825
2018-11-29 02:13:25 +00:00
Matthew Voss bc5679eaff Ensure that test clang-tidy/export-relpath.cpp works with Windows path separators.
llvm-svn: 347815
2018-11-28 22:16:18 +00:00
Matthew Voss 2c8a054310 Revert "[clang-tools-extra] r347753 - [clangd] Build and test IndexBenchmark in check-clangd"
This revision was causing failures on the buildbots, and our internal CI.

See: http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/20856
llvm-svn: 347792
2018-11-28 18:48:32 +00:00
Aaron Ballman e0fddb4e56 Fix false positive with lambda assignments in cert-err58-cpp.
This check is about preventing exceptions from being thrown before main() executes, and assigning a lambda (rather than calling it) to a global object cannot throw any exceptions.

llvm-svn: 347761
2018-11-28 15:04:38 +00:00
Ilya Biryukov 8a0a5a3197 [clang-tidy] Added a test -export-fixes with relative paths.
Summary: A test for D51864.

Reviewers: ioeric, steveire

Reviewed By: steveire

Subscribers: xazax.hun, cfe-commits

Differential Revision: https://reviews.llvm.org/D51865

llvm-svn: 347760
2018-11-28 14:43:26 +00:00
Hans Wennborg cab8dd692e Re-commit r347419 "Update call to EvaluateAsInt() to the new syntax."
llvm-svn: 347757
2018-11-28 14:04:26 +00:00
Eric Liu 1208240ac9 [clangd] Fix test broken in r347754.
llvm-svn: 347755
2018-11-28 14:00:09 +00:00
Eric Liu e9a33b7ece [clangd] Less penalty for cross-namespace completions.
llvm-svn: 347754
2018-11-28 13:45:25 +00:00
Haojian Wu 90754ef22a [clangd] Build and test IndexBenchmark in check-clangd
Summary:
Include IndexBenchmark in check-clangd to make sure we won't forget to update
it when doing breaking changes; also fix an out-of-date test input.

Reviewers: ilya-biryukov

Subscribers: mgorny, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D54998

llvm-svn: 347753
2018-11-28 13:31:05 +00:00
Aaron Ballman dda6290f16 Fix a false-positive with cert-err58-cpp.
If a variable is declared constexpr then its initializer needs to be a constant expression, and thus, cannot throw. This check is about not throwing exceptions before main() runs, and so it doesn't apply if the initializer cannot throw. This silences the diagnostic when initializing a constexpr variable and fixes PR35457.

llvm-svn: 347745
2018-11-28 11:57:13 +00:00
Eric Liu 4d814a93e5 [clangd] Canonicalize file path in URIForFile.
Summary:
File paths in URIForFile can come from index or local AST. Path from
index goes through URI transformation and the final path is resolved by URI
scheme and could be potentially different from the original path. Hence, we
should do the same transformation for all paths. We do this in URIForFile, which
now converts a path to URI and back to a canonicalized path.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D54845

llvm-svn: 347739
2018-11-28 10:30:42 +00:00
Jan Korous 613c80d22f [clangd] Fix backward-compatibility - follow-up to textDocument/SymbolInfo
Apparently clang 3.6 couldn't build the preceding patch.

llvm-svn: 347738
2018-11-28 10:24:07 +00:00