Commit Graph

4456 Commits

Author SHA1 Message Date
Zinovy Nis 72bb9a65d6 Reland r356547 after fixing the YAML module missing issue.
[clang-tidy] Parallelize clang-tidy-diff.py

This patch has 2 rationales:

- large patches lead to long command lines and often cause max command line length restrictions imposed by OS;
- clang-tidy runs on modified files are independent and can be done in parallel, the same as done for run-clang-tidy.

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

llvm-svn: 356649
2019-03-21 08:32:07 +00:00
Douglas Yung 6452ba4786 Revert "Reland r356547 after fixing the tests for Linux."
This reverts commit 538fb72226 (r356565).

This is still breaking a build bot:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/45557

llvm-svn: 356630
2019-03-20 23:21:43 +00:00
Stephane Moore 5f70c473c9 [clang-tidy] Disable google-runtime-int in Objective-C++ 🔓
Summary:
In contrast to Google C++, Objective-C often uses built-in integer types
other than `int`. In fact, the Objective-C runtime itself defines the
types NSInteger¹ and NSUInteger² which are variant types depending on
the target architecture. The Objective-C style guide indicates that
usage of system types with variant sizes is appropriate when handling
values provided by system interfaces³. Objective-C++ is commonly the
result of conversion from Objective-C to Objective-C++ for the purpose
of integrating C++ functionality. The opposite of Objective-C++ being
used to expose Objective-C functionality to C++ is less common,
potentially because Objective-C has a signficantly more uneven presence
on different platforms compared to C++. This generally predisposes
Objective-C++ to commonly being more Objective-C than C++. Forcing
Objective-C++ developers to perform conversions between variant system types
and fixed size integer types depending on target architecture when
Objective-C++ commonly uses variant system types from Objective-C is
likely to lead to more bugs and overhead than benefit. For that reason,
this change proposes to disable google-runtime-int in Objective-C++.

[1] https://developer.apple.com/documentation/objectivec/nsinteger?language=objc
[2] https://developer.apple.com/documentation/objectivec/nsuinteger?language=objc
[3] "Types long, NSInteger, NSUInteger, and CGFloat vary in size between
32- and 64-bit builds. Use of these types is appropriate when handling
values exposed by system interfaces, but they should be avoided for most
other computations."
https://github.com/google/styleguide/blob/gh-pages/objcguide.md#types-with-inconsistent-sizes

Subscribers: xazax.hun, jdoerfert, cfe-commits

Tags: #clang

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

llvm-svn: 356627
2019-03-20 23:05:00 +00:00
Jordan Rupprecht ce3d670097 Revert "[clangd] Print arguments in template specializations"
This reverts commit 44a63f6a15. It segfaults on an internal test case (will follow up off thread).

llvm-svn: 356623
2019-03-20 22:51:56 +00:00
Zinovy Nis af88175704 [clang-tidy] Fix redundant check breaking the test on many platforms.
Differential Revision: https://reviews.llvm.org/D57662

llvm-svn: 356589
2019-03-20 18:37:04 +00:00
Nico Weber 9920b98c71 gn build: Add build files for some clang-tools-extra
Adds clang-change-namespace, clang-move, clang-query,
clang-reorder-fields.

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

llvm-svn: 356567
2019-03-20 16:14:16 +00:00
Zinovy Nis 538fb72226 Reland r356547 after fixing the tests for Linux.
[clang-tidy] Parallelize clang-tidy-diff.py

This patch has 2 rationales:

- large patches lead to long command lines and often cause max command line length restrictions imposed by OS;
- clang-tidy runs on modified files are independent and can be done in parallel, the same as done for run-clang-tidy.

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

llvm-svn: 356565
2019-03-20 15:50:26 +00:00
Simon Pilgrim 2b70dcd2ef Revert rL356547 : [clang-tidy] Cosmetic fix
Differential Revision: https://reviews.llvm.org/D57662
........
[clang-tidy] Parallelize clang-tidy-diff.py

This patch has 2 rationales:

- large patches lead to long command lines and often cause max command line length restrictions imposed by OS;
- clang-tidy runs on modified files are independent and can be done in parallel, the same as done for run-clang-tidy.

Differential Revision: https://reviews.llvm.org/D57662
........
Reverted to fix buildbot: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/45547/steps/test/logs/stdio

llvm-svn: 356553
2019-03-20 13:24:33 +00:00
Zinovy Nis 4bfe83679d [clang-tidy] Cosmetic fix
Differential Revision: https://reviews.llvm.org/D57662

llvm-svn: 356548
2019-03-20 11:34:29 +00:00
Zinovy Nis d3939d2013 [clang-tidy] Parallelize clang-tidy-diff.py
This patch has 2 rationales:

- large patches lead to long command lines and often cause max command line length restrictions imposed by OS;
- clang-tidy runs on modified files are independent and can be done in parallel, the same as done for run-clang-tidy.

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

llvm-svn: 356547
2019-03-20 11:30:05 +00:00
Kadir Cetinkaya 44a63f6a15 [clangd] Print arguments in template specializations
Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 356541
2019-03-20 09:43:38 +00:00
Kadir Cetinkaya 8665802202 [clangd] Add support for type hierarchy (super types only for now)
Summary:
Patch by Nathan Ridge(@nridge)!

This is an LSP extension proposed here:
https://github.com/Microsoft/vscode-languageserver-node/pull/426

An example client implementation can be found here:
https://github.com/theia-ide/theia/pull/3802

Reviewers: kadircet, sammccall

Reviewed By: kadircet

Subscribers: jdoerfert, sammccall, cfe-commits, mgorny, dschaefer, simark, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet

Tags: #clang

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

llvm-svn: 356445
2019-03-19 09:27:04 +00:00
Fangrui Song 560a45a3c4 [pp-trace] Delete -ignore and add a new option -callbacks
Summary:
-ignore specifies a list of PP callbacks to ignore. It cannot express a
whitelist, which may be more useful than a blacklist.
Add a new option -callbacks to replace it.

-ignore= (default) => -callbacks='*' (default)
-ignore=FileChanged,FileSkipped => -callbacks='*,-FileChanged,-FileSkipped'

-callbacks='Macro*' : print only MacroDefined,MacroExpands,MacroUndefined,...

Reviewers: juliehockett, aaron.ballman, alexfh, ioeric

Reviewed By: aaron.ballman

Subscribers: nemanjai, kbarton, jsji, cfe-commits

Tags: #clang

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

llvm-svn: 356366
2019-03-18 13:30:17 +00:00
Ilya Biryukov a06b467ddc [clangd] Remove includes of "gmock-matchers.h". NFC
For consistency with most of the test code.

llvm-svn: 356264
2019-03-15 14:30:07 +00:00
Ilya Biryukov 373bee85c2 [clangd] Tune the fuzzy-matching algorithm
Summary:
To reduce the gap between prefix and initialism matches.

The motivation is producing better scoring in one particular example,
but the change does not seem to cause large regressions in other cases.

The examples is matching 'up' against 'unique_ptr' and 'upper_bound'.
Before the change, we had:
  - "[u]nique_[p]tr" with a score of 0.3,
  - "[up]per_bound" with a score of 1.0.

A 3x difference meant that symbol quality signals were almost always ignored
and 'upper_bound' was always ranked higher.

However, intuitively, the match scores should be very close for the two.

After the change we have the following scores:
- "[u]nique_[p]tr" with a score of 0.75,
- "[up]per_bound" with a score of 1.0.

Reviewers: ioeric

Reviewed By: ioeric

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

Tags: #clang

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

llvm-svn: 356261
2019-03-15 14:00:49 +00:00
Nico Weber 5f5a74582f Rename directory housing clang-change-namespace to be eponymous
Makes the name of this directory consistent with the names of the other
directories in clang-tools-extra.

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

llvm-svn: 356254
2019-03-15 11:54:01 +00:00
Yan Zhang 787a773498 Fixed global constant/variable naming check on C++ class for ObjC++ files.
Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 356220
2019-03-15 00:17:41 +00:00
Reid Kleckner 0f56b22614 Add PragmaHandler for MSVC pragma execution_character_set
__pragma(execution_character_set(push, "UTF-8")) is used in
TraceLoggingProvider.h. This commit implements a no-op handler for
compatability, similar to how the flag -fexec_charset is handled.

Patch by Matt Gardner!

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

llvm-svn: 356185
2019-03-14 18:12:17 +00:00
Hyrum Wright 4199a73cee [clang-tidy] Add additional patterns to the abseil-duration-unnecessary-conversion check.
Differential Revision: https://reviews.llvm.org/D59183

llvm-svn: 356141
2019-03-14 13:38:16 +00:00
Haojian Wu 7f51b5dc32 [clangd] Using symbol name to map includes for STL symbols.
Summary:
Using suffix path mapping relies on the STL implementations, and it is
not portable. This patch is using symbol name mapping, which should
work with different STL implementations, fix clangd/clangd#9.

To generate the symbol mapping, we parse the cppreference symbol index
page to build a lookup table.

The mapping is not completed, a few TODOs:
  - support symbols from different headers (e.g. std::move)
  - support STL macros
  - support symbols from std's sub-namespaces (e.g. chrono)

Reviewers: ioeric, jfb, serge-sans-paille

Reviewed By: ioeric

Subscribers: sammccall, klimek, ilya-biryukov, ioeric, MaskRay, jkorous, mgrang, arphaman, kadircet, jfb, jdoerfert, cfe-commits

Tags: #clang-tools-extra, #clang

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

llvm-svn: 356134
2019-03-14 11:25:26 +00:00
Haojian Wu 1f28a4a17f [clangd] Fix an out-of-date FIXME, NFC.
llvm-svn: 356127
2019-03-14 10:01:07 +00:00
Haojian Wu 7ce0d6cc33 [clangd] Build Dex index after loading all shards in BackgroundIndex.
Summary:
Currently after loadding all shards, we use MemIndex which has poor query
performance, we should use Dex.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 356126
2019-03-14 09:57:10 +00:00
Kadir Cetinkaya d9c174648e [clangd] Store explicit template specializations in index for code navigation purposes
Summary:
This introduces ~4k new symbols, and ~10k refs for LLVM. We need that
information for providing better code navigation support:
- When references for a class template is requested, we should return these specializations as well.
- When children of a specialization is requested, we should be able to query for those symbols(instead of just class template)

Number of symbols: 378574 -> 382784
Number of refs: 5098857 -> 5110689

Reviewers: hokein, gribozavr

Reviewed By: gribozavr

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

Tags: #clang

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

llvm-svn: 356125
2019-03-14 08:35:17 +00:00
Haojian Wu 529bdcd7ce [clangd] Fix a typo in doc.
llvm-svn: 356055
2019-03-13 15:22:31 +00:00
Kadir Cetinkaya 3d8e289f71 [clangd] Default initialize SymInfo
llvm-svn: 356032
2019-03-13 08:42:15 +00:00
Paul Hoad d74c055fe6 Revert "[clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present"
This reverts commit b358cbb9b78389e20f7be36e1a98e26515c3ecce.

llvm-svn: 356030
2019-03-13 08:15:03 +00:00
Paul Hoad 6d294f28e9 [clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present
Summary:
Addressing: PR25010 - https://bugs.llvm.org/show_bug.cgi?id=25010

Code like:

```
    if(true) var++;
    else  {
        var--;
    }
```

is reformatted to be

```
  if (true)
    var++;
  else {
    var--;
  }
```

Even when `AllowShortIfStatementsOnASingleLine` is true

The following revision comes from a +1'd suggestion in the PR to support AllowShortIfElseStatementsOnASingleLine

This suppresses the clause prevents the merging of the if when there is a compound else

Reviewers: klimek, djasper, JonasToth, alexfh, krasimir, reuk
Reviewed By: reuk
Subscribers: reuk, Higuoxing, jdoerfert, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D59087

llvm-svn: 356029
2019-03-13 08:07:46 +00:00
Haojian Wu 42810363de [clang-tidy] NOLINT support for "clang-diagnostic-*".
Reviewers: alexfh, aaron.ballman

Reviewed By: alexfh

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 355934
2019-03-12 16:11:46 +00:00
Hyrum Wright 1603447b03 [clang-tidy] Add the abseil-time-compare check
This is an analog of the abseil-duration-comparison check, but for the
absl::Time domain. It has a similar implementation and tests.

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

llvm-svn: 355835
2019-03-11 16:47:45 +00:00
Kadir Cetinkaya a7cdfd9cb5 [clangd] Respect Origin option in createStaticIndexingAction
Summary:
Currently createStaticIndexingAction always set Origin to Static, which
makes it hard to change it later on by different indexers(One needs to go over
each symbol making a new copy).

This patch changes that behavior to rather respect it if set by user.

Reviewers: ioeric

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

Tags: #clang

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

llvm-svn: 355820
2019-03-11 11:01:14 +00:00
Haojian Wu 5bca7ff98a [clangd] Add TOC section to clangd doc.
Reviewers: gribozavr

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

Tags: #clang

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

llvm-svn: 355811
2019-03-11 08:45:56 +00:00
Hyrum Wright 8172a0a5f4 [clang-tidy] NFC: Negate the name and semantics of the isNotInMacro function.
This function is always used in a context where its result was also
negated, which made for confusing naming and code.

llvm-svn: 355702
2019-03-08 15:37:15 +00:00
Kadir Cetinkaya 890dfddef0 [clangd] Remove ./ and ../ in the file paths
Reviewers: hokein

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

Tags: #clang

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

llvm-svn: 355681
2019-03-08 09:57:33 +00:00
Haojian Wu f07a3fd500 [clangd] Redirect clangd page.
Reviewers: gribozavr

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

Tags: #clang

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

llvm-svn: 355680
2019-03-08 09:56:42 +00:00
Kadir Cetinkaya 017cc6c190 [clangd] Make sure constructors do not reference class
Reviewers: gribozavr

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

Tags: #clang

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

llvm-svn: 355679
2019-03-08 09:54:37 +00:00
Haojian Wu f334231176 [clangd] Deduplicate Refs on the fly.
Summary:
Currently, we only do deduplication when we flush final results. We may
have huge duplications (refs from headers) during the indexing period (running
clangd-indexer on Chromium).

With this change, clangd-indexer can index the whole chromium projects
(48 threads, 40 GB peak memory usage).

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 355676
2019-03-08 09:26:30 +00:00
Kadir Cetinkaya 65944ab50d [clangd] Adjust compile commands to be applicable for tooling
Summary:
As can be seen in https://github.com/llvm-mirror/clang/blob/master/lib/Tooling/Tooling.cpp#L385
clang tool invocations adjust commands normally like this. In clangd we have
different code paths for invoking a frontend action(preamble builds, ast builds,
background index, clangd-indexer) they all work on the same GlobalCompilationDatabase
abstraction, but later on are subject to different modifications.

This patch makes sure all of the clangd actions make use of the same compile
commands before invocation.

Enables background-index to work on chromium codebase(since they had dependency
file output in their compile commands).

Reviewers: gribozavr, hokein

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

Tags: #clang

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

llvm-svn: 355669
2019-03-08 08:38:25 +00:00
Haojian Wu ea18b36a6d [clangd] Strip plugin arguments in clangd-indexer.
Summary: This would allow clangd-indexer runs on chromium repo.

Reviewers: kadircet

Reviewed By: kadircet

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

Tags: #clang

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

llvm-svn: 355599
2019-03-07 14:47:17 +00:00
Haojian Wu 24a8f1ccb9 [clangd] Add Source to clangd::Diagnostic.
Summary:
clangd embedder can distinguish diagnostics from clang or clang-tidy.

Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 355493
2019-03-06 10:51:38 +00:00
Alexander Kornienko 401997db92 [clang-tidy] Fix bugprone-string-constructor crash
llvm-svn: 355401
2019-03-05 14:09:57 +00:00
Shoaib Meenai 5be71faf4b [build] Rename clang-headers to clang-resource-headers
Summary:
The current install-clang-headers target installs clang's resource
directory headers. This is different from the install-llvm-headers
target, which installs LLVM's API headers. We want to introduce the
corresponding target to clang, and the natural name for that new target
would be install-clang-headers. Rename the existing target to
install-clang-resource-headers to free up the install-clang-headers name
for the new target, following the discussion on cfe-dev [1].

I didn't find any bots on zorg referencing install-clang-headers. I'll
send out another PSA to cfe-dev to accompany this rename.

[1] http://lists.llvm.org/pipermail/cfe-dev/2019-February/061365.html

Reviewers: beanz, phosek, tstellar, rnk, dim, serge-sans-paille

Subscribers: mgorny, javed.absar, jdoerfert, #sanitizers, openmp-commits, lldb-commits, cfe-commits, llvm-commits

Tags: #clang, #sanitizers, #lldb, #openmp, #llvm

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

llvm-svn: 355340
2019-03-04 21:19:53 +00:00
Eric Liu 9f7a767a81 [clangd] Enable SuggestMissingIncludes by default.
Summary: This seems to work stably now. Turn on by default.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 355200
2019-03-01 14:17:55 +00:00
Fangrui Song ffe9f00cfe Fix file headers. NFC
llvm-svn: 355188
2019-03-01 09:52:53 +00:00
Paul Hoad 68f5e5456f [clang-tidy] add OverrideMacro to modernize-use-override check
Summary:
The usefulness of **modernize-use-override** can be reduced if you have to live in an environment where you support multiple compilers, some of which sadly are not yet fully C++11 compliant

some codebases have to use override as a macro OVERRIDE e.g.

```
// GCC 4.7 supports explicit virtual overrides when C++11 support is enabled.
```

This allows code to be compiled with C++11 compliant compilers and get warnings and errors that clang, MSVC,gcc can give, while still allowing other legacy pre C++11 compilers to compile the code. This can be an important step towards modernizing C++ code whilst living in a legacy codebase.

When it comes to clang tidy, the use of the **modernize-use-override** is one of the most useful checks, but the messages reported are inaccurate for that codebase if the standard approach is to use the macros OVERRIDE and/or FINAL.

When combined with fix-its that introduce the C++11 override keyword, they become fatal, resulting in the modernize-use-override check being turned off to prevent the introduction of such errors.

This revision, allows the possibility for the replacement **override **to be a macro instead, Allowing the clang-tidy check to be run on  both pre and post C++11 code, and allowing fix-its to be applied.

Reviewers: alexfh, JonasToth, hokein, Eugene.Zelenko, aaron.ballman

Reviewed By: alexfh, JonasToth

Subscribers: lewmpk, malcolm.parsons, jdoerfert, xazax.hun, cfe-commits, llvm-commits

Tags: #clang-tools-extra

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

llvm-svn: 355132
2019-02-28 20:00:48 +00:00
Jonas Toth ab10947b34 [clang-tidy] fix documentation link in list of clang-tidy checks
llvm-svn: 355108
2019-02-28 17:53:51 +00:00
Jonas Toth 5fbeff797a [clang-tidy] redirection in list of checks adjusted
llvm-svn: 355102
2019-02-28 15:56:40 +00:00
Jonas Toth ed571d77d2 [clang-tidy] include cppcoreguidelines-explicit-virtual-functions in list of checks and fix redirection
llvm-svn: 355100
2019-02-28 15:47:10 +00:00
Jonas Toth 3a24cb00eb [clang-tidy] documentation fixing the actual correct file
llvm-svn: 355098
2019-02-28 15:39:47 +00:00
Jonas Toth eae176f142 [clang-tidy] tryfix documenation continued
llvm-svn: 355097
2019-02-28 15:28:36 +00:00
Jonas Toth df58719979 [clang-tidy] another issue in documentation, double empty line seemed to confuse code-block
llvm-svn: 355095
2019-02-28 15:18:54 +00:00