Commit Graph

5040 Commits

Author SHA1 Message Date
Haojian Wu bc01f48da3 [clangd] Link more clang-tidy modules to clangd
Summary: There are two new clang-tidy modules being added recently.

Reviewers: sammccall, jdoerfert

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

Tags: #clang

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

llvm-svn: 369741
2019-08-23 09:13:23 +00:00
Haojian Wu c4905a232c [clang-tidy] Don't emit google-runtime-references warning for functions defined in macros.
Summary:
The macro are usually defined in the common/base headers which are hard
for normal users to modify it.

Reviewers: gribozavr, alexfh

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 369739
2019-08-23 08:47:27 +00:00
Benjamin Kramer b3a991df3c Fight a bit against global initializers. NFC.
llvm-svn: 369695
2019-08-22 19:43:27 +00:00
Benjamin Kramer 15ee5ba6e7 [clangd] Fold string copy into lambda capture. NFC.
llvm-svn: 369679
2019-08-22 18:09:46 +00:00
Shaurya Gupta 1a28a06ebe [Clangd] Tweaktesting replace toString with consumeError
llvm-svn: 369676
2019-08-22 17:36:31 +00:00
Benjamin Kramer d5aecb9486 Retire llvm::less/equal in favor of C++14 std::less<>/equal_to<>.
llvm-svn: 369674
2019-08-22 17:31:59 +00:00
Shaurya Gupta 5ee01ef1e5 Fixed Missing Expected error handling
llvm-svn: 369666
2019-08-22 16:42:42 +00:00
Haojian Wu 08d93f1ed3 [clangd] Send suppported codeActionKinds to the client.
Summary:
This would make client know which codeActionKinds that clangd may
return.

VSCode will add a new entry "Refactor..." (which shows all
refactoring-kind code actions) in the right-click menu.

Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 369656
2019-08-22 14:53:45 +00:00
Dmitri Gribenko 282dc72c8b Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

  for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done

[This is analogous to LLVM r331272 and CFE r331834]

Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits

Tags: #clang

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

llvm-svn: 369643
2019-08-22 11:32:57 +00:00
Haojian Wu 35038c914c [clangd] The ClangdServer::EnableHiddenFeatures is not used any more.
Remove it.

llvm-svn: 369631
2019-08-22 09:01:04 +00:00
Yuanfang Chen 08ff5df49c Fix documentation build after rL369568
llvm-svn: 369578
2019-08-21 20:59:16 +00:00
Yuanfang Chen f24c1e6b51 [clang-tidy] Check for dynamically initialized statics in headers.
Finds instances where variables with static storage are initialized dynamically in header files.

Reviewed By: aaron.ballman, alexfh

Patch by Charles Zhang!

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

llvm-svn: 369568
2019-08-21 20:00:01 +00:00
Haojian Wu 65c58a902d [clangd] Ignore implicit conversion-operator nodes in find refs.
Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 369514
2019-08-21 10:54:19 +00:00
Haojian Wu 0e8e4b09d2 [clangd] Fix one testcase in XRefsTests.
Summary:
The test didn't test anything actually -- it used "[]" as annotation which should be
"[[]]".

This patch also fixes a bug in XRef where we may return duplicated refs.

Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 369387
2019-08-20 14:07:27 +00:00
Ilya Biryukov 30c86b64da [clangd] Skip function bodies inside processed files while indexing
Summary:
This significantly improves performance of background indexing.

We do not collect references and declarations inside the processed
files, so this does not affect the final indexing results.

The idea is borrowed from libclang, which has a similar optimization in
its indexing functionality.

Measurements show a nice decrease in indexing time, up to ~40% for
building the whole index. These are not proper benchmarks, so one should
not rely on these results too much.

1. Rebuilding the whole index for LLVM:
  - Before. Total time: 14m58s.
    ./bin/clangd -pch-storage=memory < ./clangd.input  23917.67s user 515.86s system 2718% cpu 14:58.68 total
  - After. Total time: 8m41s.
    ./bin/clangd -pch-storage=memory < ./clangd.input  13627.29s user 288.10s system 2672% cpu 8:40.67 total

2. Rebuilding index after removing shards matching '*clangd*' (case-insensitively):
  - Before. Total time: 30s.
    ./bin/clangd -pch-storage=memory < ./clangd.input  130.94s user 6.82s system 452% cpu 30.423 total
  - After. Total time: 26s.
    ./bin/clangd -pch-storage=memory < ./clangd.input  80.51s user 5.40s system 333% cpu 25.777 total

Reviewers: kadircet, sammccall

Reviewed By: kadircet

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 369349
2019-08-20 08:54:30 +00:00
Richard Trieu 8f9e489a66 Fix typo. "piont" => "point"
Found by Chris Morris (cwmorris).

llvm-svn: 369316
2019-08-20 00:28:21 +00:00
Johan Vikstrom f497da3041 [clangd] Added highlighting for tokens that are macro arguments.
Summary:
Adds semantic highlighting for tokens that are a macro argument.
Example:
```
D_V(SomeVar);
```
The "SomeVar" inside the macro is highlighted as a variable now.

Tokens that are in a macro body expansion are ignored in this patch for three reasons.
* The spelling loc is inside the macro "definition" meaning it would highlight inside the macro definition (could probably easily be fixed by using getExpansionLoc instead of getSpellingLoc?)
* If wanting to highlight the macro definition this could create duplicate tokens. And if the tokens are of different types there would be conflicts (tokens in the same range but with different types). Say a macro defines some name and both a variable declaration and a function use this, there would be two tokens in the macro definition but one with Kind "Variable" and the other with Kind "Function".
* Thirdly, macro body expansions could come from a file that is not the main file (easily fixed, just check that the Loc is in the main file and not even a problem if we wanted to highlight the actual macro "invocation")

Reviewers: hokein, sammccall, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 369275
2019-08-19 16:27:49 +00:00
Johan Vikstrom 17587b36d1 [clangd] Added special HighlightingKind for function parameters.
Summary: This means that function parameters are no longer highlighted as variable.other.cpp but instead as variable.parameter.cpp which is the more "correct" TextMate scope for them.

Reviewers: hokein, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 369238
2019-08-19 07:51:39 +00:00
Nathan Ridge dfe5f3eb0a [clangd] Update features table in the docs with links to LSP extension proposals
Also update the semantic coloring entry to reflect it being supported in
clangd now.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 369229
2019-08-19 05:11:15 +00:00
Diego Astiazaran ee6700f697 [clang-doc] Fix casting not working in gcc 5.4.0
An implicit cast of std::string to llvm::SmallString<> was breaking GCC 5.4.0 builder.
A pair using llvm::SmallString<> now uses std::string.

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

llvm-svn: 369182
2019-08-17 01:45:03 +00:00
Diego Astiazaran 3550da79ec [clang-doc] Redesign of generated HTML files
The new design includes a header (contains the project name), a main section, and a footer.
The main section is divided into three subsections. Left, middle, right. The left section contains the general index, the middle contains the info's data, and the right contains the index for the info's content.
The CSS has been updated.
A flag --project-name is added.
The Attributes attribute of the TagNode struct is now a vector of pairs because these attributes should be rendered in the insertion order.
The functions (cpp and js) that converts an Index tree structure into HTML were slightly modified; the first ul tag created is now a ol tag. The inner lists are still ul.

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

llvm-svn: 369139
2019-08-16 18:38:11 +00:00
Diego Astiazaran b46131e5c3 [clang-doc] Fix records in global namespace
When a Record is declared in the global namespace, clang-doc serializes
it as a child of the global namespace, so the global namespace is now
one if its parent namespaces. This namespace was not being included in
the list of namespaces of the Info causing paths to be incorrect and the
index rendered incorrectly.
Affected tests have been fixed.

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

llvm-svn: 369123
2019-08-16 16:10:32 +00:00
Haojian Wu 427762f03d [clangd] suppress -Wparentheses warning: suggest parentheses around ‘&&’ within ‘||’
llvm-svn: 369105
2019-08-16 13:20:51 +00:00
Ilya Biryukov 12864001a6 [clangd] Simplify code of ClangdLSPServer::onCommand
Summary:
By inlining a complicated lambda into its single call-site.

Also ensure we call Reply() exactly once even if tweaks return both
ShowMessage and ApplyEdit effects.

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

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

llvm-svn: 369100
2019-08-16 12:46:41 +00:00
Johan Vikstrom 71ae2bf302 [clangd] Added highlighting for non type templates.
Summary: Non type templates were not being highlighted. This highlights
them as TemplateParameters.

Reviewers: hokein, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 369090
2019-08-16 09:30:21 +00:00
Ilya Biryukov b3c2f5d2ee [clangd] Remove Bind, use C++14 lambda captures instead. NFC
llvm-svn: 369089
2019-08-16 09:20:01 +00:00
Stephane Moore a53cce943d [clang-tidy] Migrate objc-super-self to use isDerivedFrom 🚛
Summary:
This migrates objc-super-self to `isDerivedFrom` as it now supports
matching Objective-C interface declarations.

Test Notes:
Ran clang tools tests.

Reviewers: aaron.ballman, gribozavr

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 369081
2019-08-16 02:27:58 +00:00
Csaba Dabis a079a42708 [analyzer] Analysis: Silence checkers
Summary:
This patch introduces a new `analyzer-config` configuration:
`-analyzer-config silence-checkers`
which could be used to silence the given checkers.

It accepts a semicolon separated list, packed into quotation marks, e.g:
`-analyzer-config silence-checkers="core.DivideZero;core.NullDereference"`

It could be used to "disable" core checkers, so they model the analysis as
before, just if some of them are too noisy it prevents to emit reports.

This patch also adds support for that new option to the scan-build.
Passing the option `-disable-checker core.DivideZero` to the scan-build
will be transferred to `-analyzer-config silence-checkers=core.DivideZero`.

Reviewed By: NoQ, Szelethus

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

llvm-svn: 369078
2019-08-16 01:53:14 +00:00
Stephane Moore 8c90c1d2d5 [clang-tidy] Migrate objc-forbidden-subclassing to use isDerivedFrom 🚛
Summary:
This migrates objc-forbidden-subclassing to `isDerivedFrom` as it now
supports matching Objective-C interface declarations.

Test Notes:
Ran clang tools tests.

Reviewers: aaron.ballman, gribozavr

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 369076
2019-08-16 01:52:17 +00:00
Diego Astiazaran ba3d595f93 [clang-doc] Serialize inherited attributes and methods
clang-doc now serializes the inherited attributes and methods, not only the name of the base class.
All inherited are tracked, if B:A and C:B, info of A is included in C.
This data is stored in attribute Bases in a RecordInfo.
Previously tracked inheritance data, stored in Parents and VParents, hasn't been removed to reduce review load.

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

llvm-svn: 369075
2019-08-16 00:10:49 +00:00
Diego Astiazaran b7bb9fb28f [clang-doc] Sort index elements case insensitive
Implement logic to compare the references of the index case insensitive.

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

llvm-svn: 369068
2019-08-15 23:32:12 +00:00
Diego Astiazaran 77dc05b945 [clang-doc] Fix use of source-root flag
The value, if any, of --source-root flag was not being used.
This has been fixed and the logic was moved to the ClangDocContext
contructor.

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

llvm-svn: 369065
2019-08-15 23:20:42 +00:00
Diego Astiazaran 6a29ae4bde [clang-doc] Fix bitcode writer for access specifiers
Bitcode writer was not emitting the corresponding record for the Access attribute of a FunctionInfo. This has been added.
AS_none was being used as the default value for any AcesssSpecifier attribute
(in FunctionInfo and MemberTypeInfo), this has been changed to AS_public
because this is the enum value that evaluates to 0.
The bitcode writer doesn't write values that are 0 so if an attribute
was set to AS_public, this value is not written and after reading the
bitcode it would have the default value which is AS_none. This is why
the default value is now AS_public.

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

llvm-svn: 369063
2019-08-15 23:04:27 +00:00
Benjamin Kramer 9880b5dd21 [clangd] Don't use Bind() where C++14 move capture works
llvm-svn: 369005
2019-08-15 14:16:06 +00:00
Benjamin Kramer e1bc32bddf [clangd] llvm::integer_sequence -> std::integer_sequence.
llvm-svn: 368991
2019-08-15 11:09:22 +00:00
Benjamin Kramer 37508d3dd9 Replace llvm::integer_sequence and friends with the C++14 standard version
The implementation in libc++ takes O(1) compile time, ours was O(n).

llvm-svn: 368990
2019-08-15 10:56:05 +00:00
Jonas Devlieghere 1c705d9c53 [clang-tools-extra] Migrate llvm::make_unique to std::make_unique
Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances across the monorepo.

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

llvm-svn: 368944
2019-08-14 23:52:23 +00:00
Diego Astiazaran 6169a73088 [clang-doc] Add missing check in tests
Path is now checked when comparing two Infos in the unit tests.

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

llvm-svn: 368912
2019-08-14 20:19:33 +00:00
Haojian Wu bcd4d59a14 [clangd][vscode] Surface the error when applying tweaks fails
Summary:
The current behavior for a failed request is just to log it in the
output panel. When applyTweak fails for whatever reason, users usually don't get
informed (unless they open the output panel and dig the log).

this patch is to surface these errors by prompting up a message diag.

Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 368851
2019-08-14 13:38:52 +00:00
Ilya Biryukov 38fa1a9168 [clangd] Print qualifiers of out-of-line definitions in document outline
Summary: To improve the UX around navigating and searching through the results.

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

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

llvm-svn: 368842
2019-08-14 12:51:04 +00:00
Shaurya Gupta d81a869876 [Clangd] NFC: Fixed comment typo
llvm-svn: 368841
2019-08-14 12:40:09 +00:00
Johan Vikstrom 9fa2599e9b [clangd] Loading TokenColorRules as a class mapping the rules to their associated clangd TextMate scope index.
Summary: Loads a mapping of the clangd scope lookup table scopes to the most specific rule with the highest "precedence" on initialize. Preprocesses into a class so it's simple/fast to access when doing the actual coloring later.

Reviewers: hokein, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 368834
2019-08-14 12:11:58 +00:00
Ilya Biryukov 928bf19b65 [clangd] Fix typos and grammar in a comment. NFC
llvm-svn: 368824
2019-08-14 10:49:32 +00:00
Yitzhak Mandelbaum 1896a31dd3 [clang-tidy] Update `TransformerClangTidyCheck` to use new `buildMatchers` functionality.
Summary:
`buildMatchers` is the new, more general way to extract the matcher from a rule.
This change migrates the code to use it instead of `buildMatcher`.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 368700
2019-08-13 14:48:13 +00:00
Diego Astiazaran e27f778a19 [clang-doc] Generate HTML links for children namespaces/records
Path is now stored in the references to the child while serializing,
then this path is used to generate the relative path in the HTML
generator.
Now some references have paths and some don't so in the reducing phase,
references are now properly merged checking for empty attributes.
Tests added for HTML and YAML generators, merging and serializing.
computeRelativePath function had a bug when the filepath is part of the
given directory; it returned a path that starts with a separator. This
has been fixed.

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

llvm-svn: 368602
2019-08-12 18:42:46 +00:00
Sam McCall 6a3c2c84be [clangd] Refactor computation of extracted expr in ExtractVariable tweak. NFC
Summary:
This takes this logic out of the Tweak class, and simplifies the signature of
the function where the main logic is.

The goal is to make it easier to turn into a loop like:

  for (current = N; current and current->parent are both expr; current = current->parent)
    if (suitable(current))
      return current;
  return null;

Reviewers: SureYeaah

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

Tags: #clang

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

llvm-svn: 368590
2019-08-12 17:05:35 +00:00
Ilya Biryukov 119d1c278c [clangd] Separate chunks with a space when rendering markdown
Summary:
This results in better rendering of resulting markdown.

Especially noticeable in coc.nvim that does not have a visible horizontal
spaces around inline code blocks. More details and a screenshot from
coc.nvim can be found in https://github.com/clangd/clangd/issues/95.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

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

llvm-svn: 368581
2019-08-12 14:35:30 +00:00
Johan Vikstrom 020eea0c16 [clangd] Added the vscode SemanticHighlighting feature code but did not enable it in the client.
Summary: Added the code for the StaticFeature that must be registered to the client. Also decoding the notification data into objects. Did not register it to the client yet.

Reviewers: hokein, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 368568
2019-08-12 13:33:43 +00:00
Johan Vikstrom cbe3ed552f [clangd] Remove highlightings coming from non topLevelDecls from included files.
Summary: It is possible to write include code from other files so that the decls from there do not become topLevelDecls (For example by including methods for a class). These Decls are not filtered by topLevelDecls and therefore SemanticHighlighting must manually check that every SLoc belongs in the main file. Otherwise there can be highlightings appearing in places where they should not.

Reviewers: hokein, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 368563
2019-08-12 13:01:11 +00:00
Haojian Wu d614a65d85 [clangd] Drop diags from non-written #include.
Summary: This would fix that we show weird diagnostics on random lines of the main file.

Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 368549
2019-08-12 09:35:04 +00:00