Commit Graph

3979 Commits

Author SHA1 Message Date
Erik Pilkington fa98390b3c NFC: Remove the ObjC1/ObjC2 distinction from clang (and related projects)
We haven't supported compiling ObjC1 for a long time (and never will again), so
there isn't any reason to keep these separate. This patch replaces
LangOpts::ObjC1 and LangOpts::ObjC2 with LangOpts::ObjC.

Differential revision: https://reviews.llvm.org/D53547

llvm-svn: 345637
2018-10-30 20:31:30 +00:00
Roman Lebedev c367ba1923 [clang-tidy] cppcoreguidelines-macro-usage: print macro names
Summary:
The macro may not have location (or more generally, the location may not exist),
e.g. if it originates from compiler's command-line.

The check complains on all the macros, even those without the location info.
Which means, it only says it does not like it. What is 'it'? I have no idea.
If we don't print the name, then there is no way to deal with that situation.

And in general, not printing name here forces the user to try to understand,
given, the macro definition location, what is the macro name?
This isn't fun.

Also, ignores-by-default the macros originating from command-line,
with an option to not ignore those.

I suspect some more issues may crop up later.

Reviewers: JonasToth, aaron.ballman, hokein, xazax.hun, alexfh

Reviewed By: JonasToth, aaron.ballman

Subscribers: nemanjai, kbarton, rnkovacs, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 345610
2018-10-30 15:52:36 +00:00
Kadir Cetinkaya 6675be8747 [clangd] Use thread pool for background indexing.
Reviewers: sammccall, ioeric

Reviewed By: sammccall

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

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

llvm-svn: 345590
2018-10-30 12:13:27 +00:00
Stephen Kelly a49fe5d878 [clang-query] Add non-exclusive output API
Summary:
Add granular options for AST dumping, text printing and diagnostics.

This makes it possible to

* Have both diag and dump active at once
* Extend the output with other queryable content in the future.

Reviewers: aaron.ballman, pcc, ioeric, ilya-biryukov, klimek, sammccall

Reviewed By: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 345522
2018-10-29 18:59:56 +00:00
Bruno Ricci 17ff026b73 [AST] Refactor PredefinedExpr
Make the following changes to PredefinedExpr:

1. Move PredefinedExpr below StringLiteral so that it can use its definition.
2. Rename IdentType to IdentKind to be more in line with clang's conventions,
   and propagate the change to its users.
3. Move the location and the IdentKind into the newly available space of
   the bit-fields of Stmt.
4. Only store the function name when needed. When parsing all of Boost,
   of the 1357 PredefinedExpr 919 have no function name.

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

Reviewed By: rjmccall

llvm-svn: 345460
2018-10-27 19:21:19 +00:00
Julie Hockett 9e22b4c76d [clang-doc] Switch to default to all-TUs executor
Since we generally want to document a whole project, not just one file.

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

llvm-svn: 345418
2018-10-26 19:11:34 +00:00
Roman Lebedev 08701ec753 [clang-tidy] Re-commit: Add new 'readability-uppercase-literal-suffix' check (CERT DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4)
Summary:
Detects when the integral literal or floating point (decimal or hexadecimal)
literal has non-uppercase suffix, and suggests to make the suffix uppercase,
with fix-it.

All valid combinations of suffixes are supported.

```
  auto x = 1;  // OK, no suffix.

  auto x = 1u; // warning: integer literal suffix 'u' is not upper-case

  auto x = 1U; // OK, suffix is uppercase.

  ...
```

This is a re-commit, the original was reverted by me in
rL345305 due to discovered bugs. (implicit code, template instantiation)
Tests were added, and the bugs were fixed.
I'm unable to find any further bugs, hopefully there aren't any..

References:
* [[ https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152241 | CERT DCL16-C ]]
* MISRA C:2012, 7.3 - The lowercase character "l" shall not be used in a literal suffix
* MISRA C++:2008, 2-13-4 - Literal suffixes shall be upper case

Reviewers: JonasToth, aaron.ballman, alexfh, hokein, xazax.hun

Reviewed By: aaron.ballman

Subscribers: Eugene.Zelenko, mgorny, rnkovacs, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 345381
2018-10-26 13:09:27 +00:00
Roman Lebedev 5aa945e7ac [clang-tidy] Revert my readability-uppercase-literal-suffix check.
There are some lurking issues with the handling of the SourceManager.
Somehow sometimes we end up extracting completely wrong
portions of the source buffer.

Reverts r344772, r44760, r344758, r344755.

llvm-svn: 345305
2018-10-25 19:44:51 +00:00
Sam McCall 6d4eb46d0c [clangd] workspace/symbol should be async, it reads from the index.
Summary:
To enable this, TUScheduler has to provide a way to run async tasks without
needing a preamble or AST!

Reviewers: ilya-biryukov

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

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

llvm-svn: 345268
2018-10-25 14:19:14 +00:00
Sam McCall bc90461818 [clangd] Clean up LSP structs around configuration. NFC, no protocol changes.
- align struct names/comments with LSP, remove redundant "clangd" prefixes.
 - don't map config structs as Optional<> when their presence/absence
   doesn't signal anything and all fields must have sensible "absent" values
 - be more lax around parsing of 'any'-typed messages

llvm-svn: 345235
2018-10-25 04:22:52 +00:00
Sam McCall 56531e7f42 [clangd] Remove unused CDB function. NFC
llvm-svn: 345233
2018-10-25 02:25:44 +00:00
Sam McCall 4b86bb04fa [clangd] Fix -compile-commands-dir flag, broken in r345031
llvm-svn: 345232
2018-10-25 02:22:53 +00:00
Sam McCall fd7d341b43 [clangd] Don't invalidate LSP-set compile commands when closing a file.
Summary:
It doesn't make much sense: setting them is not coupled to opening the file,
it's an asynchronous notification.

I don't think this is a breaking change - this behavior is hard to observe!

Reviewers: ilya-biryukov

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

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

llvm-svn: 345231
2018-10-25 02:04:30 +00:00
Douglas Yung 617eba1b1b Fix test to work on Windows.
llvm-svn: 345229
2018-10-25 01:21:08 +00:00
Stephen Kelly 70d771714e [clang-query] Refactor Output settings to booleans
Summary: This will make it possible to add non-exclusive mode output.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 345194
2018-10-24 20:33:55 +00:00
Stephen Kelly 51707b21a0 [clang-query] Add 'detailed-ast' output as an alias for 'dump'
Summary: Future development can then dump other content than AST.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 345193
2018-10-24 20:33:45 +00:00
Stephen Kelly 4c3d7a969a [clang-query] Re-word command help
Summary:
This will make it possible to easily

* Add new commands which accept <feature> parameters
* Extend the list of features

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 345192
2018-10-24 20:33:14 +00:00
Heejin Ahn d00d449f8e [clant-tidy] abseil: Add clangTooling to CMakeLists.txt
Without this, builds with `-DBUILD_SHARED_LIBS=ON` fail.

llvm-svn: 345191
2018-10-24 20:31:58 +00:00
Simon Pilgrim 5369168983 Fix MSVC "truncation from 'double' to 'float'" warnings. NFCI.
llvm-svn: 345184
2018-10-24 19:31:24 +00:00
Jonas Toth 618c0bc363 [clang-tidy] Add the abseil-duration-factory-float check
Summary:
This check finds cases where calls to an absl::Duration factory could use the more efficient integer overload.

For example:
// Original - Providing a floating-point literal.
absl::Duration d = absl::Seconds(10.0);

// Suggested - Use an integer instead.
absl::Duration d = absl::Seconds(10);

Patch by hwright.

Reviewers: alexfh, hokein, aaron.ballman, JonasToth

Reviewed By: hokein, JonasToth

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

Tags: #clang-tools-extra

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

llvm-svn: 345167
2018-10-24 17:40:50 +00:00
Kadir Cetinkaya b915790385 [clangd] Do not query index for new name completions.
Reviewers: sammccall

Reviewed By: sammccall

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

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

llvm-svn: 345153
2018-10-24 15:24:29 +00:00
Sam McCall d7babe4e12 [clangd] When replying, log the method name and latency.
Summary:
This information is strictly available in the log (you can find the original
call) but it makes the log easier to follow in practice.

Reviewers: kadircet

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

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

llvm-svn: 345150
2018-10-24 15:18:40 +00:00
Sam McCall e2f3a7348d [clangd] Ensure that we reply to each call exactly once. NFC (I think!)
Summary:
In debug builds, getting this wrong will trigger asserts.
In production builds, it will send an error reply if none was sent,
and drop redundant replies. (And log).

No tests because this is always a programming error.
(We did have some cases of this, but I fixed them with the new dispatcher).

Reviewers: ioeric

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

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

llvm-svn: 345144
2018-10-24 14:26:26 +00:00
Sam McCall e8437cbf5e [clangd] Don't show base class versions of members as completions.
Summary:
These are available via qualifiers, but signal to noise level is low.
Keep required quailifier machinery around though, for cross-ns completion.

Reviewers: ioeric

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

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

llvm-svn: 345141
2018-10-24 13:51:44 +00:00
Eric Liu 52a11b5662 [clangd] Downrank members from base class
Reviewers: sammccall, ilya-biryukov

Reviewed By: sammccall

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

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

llvm-svn: 345140
2018-10-24 13:45:17 +00:00
Haojian Wu 40d5684d41 [clangd] Hide position line and column fields.
Reviewers: sammccall

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

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

llvm-svn: 345134
2018-10-24 12:56:41 +00:00
Ilya Biryukov 5a74a9cf5f [clangd] Simplify auto hover
Summary:
Use helper from clang. Also fixes some weird corner cases, e.g.
    auto (*foo)() = bar;

Reviewers: kadircet, hokein

Reviewed By: kadircet, hokein

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

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

llvm-svn: 345128
2018-10-24 10:09:34 +00:00
Ilya Biryukov ad430c6ac4 [clangd] Remove outdated comment-out code. NFC
llvm-svn: 345126
2018-10-24 09:47:24 +00:00
Ilya Biryukov b551837a6c [clangd] Fix a link in documentation. NFC
llvm-svn: 345125
2018-10-24 09:00:30 +00:00
Sam McCall 16e7070e3e [clangd] Embed fixes as CodeAction, instead of clangd_fixes. Clean up serialization.
Summary:
CodeAction provides us with a standard way of representing fixes inline, so
use it, replacing our existing ad-hoc extension.

After this, it's easy to serialize diagnostics using the structured
toJSON/Protocol.h mechanism rather than assembling JSON ad-hoc.

Reviewers: hokein, arphaman

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

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

llvm-svn: 345119
2018-10-24 07:59:38 +00:00
Sam McCall 668ac94ba4 [clangd] Truncate SymbolID to 16 bytes.
Summary:
The goal is 8 bytes, which has a nonzero risk of collisions with huge indexes.
This patch should shake out any issues with truncation at all, we can lower
further later.

Reviewers: ioeric

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

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

llvm-svn: 345113
2018-10-24 06:58:42 +00:00
Alexander Kornienko 3885b49b8e [clang-tidy] Add a separate section for NOLINT(NEXTLINE)? doc.
llvm-svn: 345049
2018-10-23 16:48:16 +00:00
Sam McCall d1c9d1163b [clangd] Lazily create CDB, remove setCompileCommandsDir.
Summary:
The only way to actually set the directory is at initialize time,
so now CDB is lazy we can pass it to the constructor.

Reviewers: hokein

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

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

llvm-svn: 345031
2018-10-23 14:19:54 +00:00
Sam McCall 2172ee931c [clangd] Remove caching of compilation database commands.
Summary:
The CDB implementations used in open-source code are fast, and our private
slow CDB will soon do the relevant caching itself.

Simplifying the GlobalCDB layer in clangd is important to get auto-index
implemented at the right layer.

Reviewers: ioeric, ilya-biryukov

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

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

llvm-svn: 345024
2018-10-23 13:14:02 +00:00
Sam McCall f01ad10a36 [clangd] Support passing a relative path to -compile-commands-dir
Summary: This is useful when using clangd with CMake based projects in Visual Studio Code since when using CMake the `compile_commands.json` file is usually located in a `build` subdirectory which isn't a parent directory of the source files. Allowing passing relative paths to -compile-commands-dir allows specifying `clangd.arguments = ["-compile-commands-dir=build"]` in VSCode's settings file and having it work for each CMake based project that uses the `build` subdirectory as the build directory (instead of having to specify the absolute path to the compile commands directory for each separate project in VSCode's settings).

Patch by Daan De Meyer!

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang-tools-extra

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

llvm-svn: 345022
2018-10-23 11:54:36 +00:00
Sam McCall 7189112951 Fix range length comparison in DraftStore::UpdateDraft when Unicode characters are removed from the document
Summary:
See http://lists.llvm.org/pipermail/clangd-dev/2018-October/000171.html for context.

I kept the error (instead of downgrading to a log message) since the range lengths differing does indicate either a bug in the client or server range calculation or the buffers being out of sync (which both seems serious enough to me to be an error). If any existing clients aside from VSCode break they should only break when accidentally typing a Unicode character which should only be a minor nuisance for a little while until the bug is fixed in the respective client.

Patch by Daan De Meyer!

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang-tools-extra

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

llvm-svn: 345020
2018-10-23 11:51:53 +00:00
Benjamin Kramer 38bffd6a0f [clang-tidy] Fix typo abls->absl.
llvm-svn: 344968
2018-10-22 22:43:17 +00:00
Jonas Toth 74f201c37e [clang-tidy] tryfix windows build
llvm-svn: 344947
2018-10-22 20:29:15 +00:00
Eugene Zelenko 8eb4fc5c3b [Documentation] Fix grammar related to Clang-tidy cppcoreguidelines-macro-usage.
llvm-svn: 344943
2018-10-22 19:55:52 +00:00
Jonas Toth 552b62ed1f [clang-tidy] implement cppcoreguidelines macro rules
Summary:
In short macros are discouraged by multiple rules (and sometimes reference randomly). [Enum.1], [ES.30], [ES.31]
This check allows only headerguards and empty macros for annotation.

Reviewers: aaron.ballman, hokein

Reviewed By: aaron.ballman

Subscribers: jbcoe, Eugene.Zelenko, klimek, nemanjai, mgorny, xazax.hun, kbarton, cfe-commits

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

llvm-svn: 344940
2018-10-22 19:20:01 +00:00
Eric Liu 0b70a87480 [clangd] Support URISchemes configuration in BackgroundIndex.
Reviewers: sammccall

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

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

llvm-svn: 344912
2018-10-22 15:37:58 +00:00
Eric Liu c6c894b88f [change-namespace] Enhance detection of conflicting namespaces.
Summary:
For example:
```
namespace util { class Base; }

namespace new {
namespace util { class Internal; }
}

namespace old {
util::Base b1;
}
```

When changing `old::` to `new::`, `util::` in namespace "new::" will conflict
with "new::util::" unless a leading "::" is added.

Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 344897
2018-10-22 12:48:49 +00:00
Miklos Vajna 612278625e ReleaseNotes: move readability-redundant-smartptr-get part down below new checks
llvm-svn: 344885
2018-10-22 06:36:30 +00:00
Miklos Vajna e967a12733 [clang-tidy] add IgnoreMacros option to readability-redundant-smartptr-get
And also enable it by default to be consistent with e.g. modernize-use-using.

This helps e.g. when running this check on client code where the macro is
provided by the system, so there is no easy way to modify it.

Reviewed By: JonasToth

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

llvm-svn: 344871
2018-10-21 19:16:25 +00:00
Sam McCall 45b2754097 [clangd] Fix unqualified make_unique after r344850. NFC
llvm-svn: 344858
2018-10-20 17:40:12 +00:00
Akira Hatanaka aca3a9f03f Check that __MAC_OS_X_VERSION_MIN_REQUIRED is defined before checking
whether it is too old.

llvm-svn: 344856
2018-10-20 17:35:50 +00:00
Sam McCall c008af6466 [clangd] Namespace style cleanup in cpp files. NFC.
Standardize on the most common namespace setup in our *.cpp files:
  using namespace llvm;
  namespace clang {
  namespace clangd {
  void foo(StringRef) { ... }
And remove redundant llvm:: qualifiers. (Except for cases like
make_unique where this causes problems with std:: and ADL).

This choice is pretty arbitrary, but some broad consistency is nice.
This is going to conflict with everything. Sorry :-/

Squash the other configurations:

A)
  using namespace llvm;
  using namespace clang;
  using namespace clangd;
  void clangd::foo(StringRef);
This is in some of the older files. (It prevents accidentally defining a
new function instead of one in the header file, for what that's worth).

B)
  namespace clang {
  namespace clangd {
  void foo(llvm::StringRef) { ... }
This is fine, but in practice the using directive often gets added over time.

C)
  namespace clang {
  namespace clangd {
  using namespace llvm; // inside the namespace
This was pretty common, but is a bit misleading: name lookup preferrs
clang::clangd::foo > clang::foo > llvm:: foo (no matter where the using
directive is).

llvm-svn: 344850
2018-10-20 15:30:37 +00:00
Simon Pilgrim 15ee23fc40 Fix MSVC "truncation from 'double' to 'float'" warning. NFCI.
llvm-svn: 344845
2018-10-20 13:20:26 +00:00
Simon Pilgrim ad28838111 Fix MSVC "not all control paths return a value" warning. NFCI.
llvm-svn: 344844
2018-10-20 13:18:49 +00:00
Stephen Kelly 4a5b01ddd7 [clang-query] Add option to print matcher expression
Summary:
This is useful if using clang-query -f with a file containing multiple
matchers.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 344840
2018-10-20 09:13:59 +00:00