Commit Graph

4729 Commits

Author SHA1 Message Date
Sam McCall 81748bae47 [clangd] Add SourceManager accessor to ParsedAST. NFC
llvm-svn: 361883
2019-05-28 21:52:34 +00:00
Joel E. Denny 91f8066d1d [OpenMP] Set pragma start loc to `#pragma` loc
This patch adjusts `PragmaOpenMPHandler` to set the location of
`tok::annot_pragma_openmp` to the `#pragma` location instead of the
`omp` location so that the former becomes the start location of the
OpenMP AST node.  This can be useful when, for example, rewriting a
directive using Clang's Rewrite facility.  Most of this patch updates
tests for changes to locations in diagnostics and `-ast-dump` output.

Reviewed By: ABataev, lebedev.ri, Meinersbur, aaron.ballman

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

llvm-svn: 361867
2019-05-28 19:27:19 +00:00
Ilya Biryukov 800db530d9 [clangd] Fix test output for r361841
llvm-svn: 361846
2019-05-28 16:28:27 +00:00
Ilya Biryukov 8534675cef [clangd] Place cursor better after completing patterns
Summary:
By producing the $0 marker in the snippets at the last placeholder.
This produces nicer results in most cases, e.g. for
   namespace <#name#> {
     <#decls#>
   }

we now produce ${0:decls} instead of ${2:decls} and the final cursor
placement is more convenient.

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

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

llvm-svn: 361841
2019-05-28 15:33:37 +00:00
Haojian Wu eb006d3268 [clang-tidy] Fix description for misc-definitions-in-headers.
Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 361834
2019-05-28 14:50:42 +00:00
Haojian Wu dfc0ca0c80 [clang-tidy] Verify fix description for misc-unused-using-decl.
Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 361833
2019-05-28 14:47:39 +00:00
Ilya Biryukov b4a394506c [clangd] Compute expected type for templates
Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

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

llvm-svn: 361823
2019-05-28 13:56:21 +00:00
Haojian Wu 2255b31cec [clang-tidy] Fix null pointer dereference in readability-identifier-naming
Summary:
readability-identifier-naming causes a null pointer dereference when checking an identifier introduced by a structured binding whose right hand side is an undeclared identifier.

Running the check on a file that is just the following results in a crash:
```
auto [left] = right;
```

Patch by Mark Stegeman!

Reviewers: alexfh, hokein, aaron.ballman, JonasToth

Reviewed By: hokein, aaron.ballman

Subscribers: madsravn, xazax.hun, cfe-commits

Tags: #clang-tools-extra, #clang

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

llvm-svn: 361809
2019-05-28 11:54:01 +00:00
Kadir Cetinkaya c6578eefdd [clangd] Introduce a structured hover response
Summary:
Change ClangdServer layer to output a structured response for Hover,
which can be rendered by client according to their needs.

Reviewers: sammccall, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 361803
2019-05-28 10:29:58 +00:00
Ilya Biryukov d12f48beda [clangd] Never end command-line flag description with a period. NFC
For consistency. Not having a period at the end is much more common and
seems to be the preferred style for command-line options.

llvm-svn: 361800
2019-05-28 09:31:27 +00:00
Ilya Biryukov 536a62d007 [clangd] Rename -run-synchronously to -sync
llvm-svn: 361798
2019-05-28 09:20:57 +00:00
Haojian Wu c11de5eada [clang-tidy] Fix unused-variable warning after r361647.
Summary:
A range-for was added in r361647 where the range variable was only used in an
assertion.  As a result, it warned for Release builds. This revision
restructures the assertion to avoid the problem.

Patch by Yitzhak Mandelbaum.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: xazax.hun, cfe-commits

Tags: #clang-tools-extra, #clang

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

llvm-svn: 361749
2019-05-27 08:09:02 +00:00
Mads Ravn bd324fa227 DeleteNullPointerCheck now deletes until the end brace of the condition.
Patch by Jonathan Camilleri

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

llvm-svn: 361735
2019-05-26 17:00:38 +00:00
Heejin Ahn e6e038c322 [clangd] tweaks: Add clangBasic dependency to LINK_LIBS
This is necessary to make builds with `-DBUILD_SHARED_LIBS=ON` work.

llvm-svn: 361687
2019-05-25 01:35:14 +00:00
Nico Weber bab1d8edcf Rename clangToolingRefactor to clangToolingRefactoring for consistency with its directory
See "[cfe-dev] The name of clang/lib/Tooling/Refactoring".

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

llvm-svn: 361684
2019-05-25 00:27:19 +00:00
Yitzhak Mandelbaum 5b33554319 [clang-tidy] In TransformerClangTidyCheck, require Explanation field.
Summary:
In general, the `Explanation` field is optional in `RewriteRule` cases. But,
because the primary purpose of clang-tidy checks is to provide users with
diagnostics, we assume that a missing explanation is a bug.  This change adds an
assertion that checks all cases for an explanation, and updates the code to rely
on that assertion correspondingly.

Reviewers: ilya-biryukov

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 361647
2019-05-24 16:32:03 +00:00
Dmitri Gribenko b7f2a2b4c0 Make cppcoreguidelines-pro-type-member-init-use-assignment.cpp pass on platforms where char is unsigned
The other options are to completely specify the triple (reduces test
coverage), or to specify a regex that allows either '0' or '0U' for char
initializers, however, that relaxes the test.

llvm-svn: 361629
2019-05-24 10:50:15 +00:00
Dmitri Gribenko f2d5b7a4fa Made cppcoreguidelines-pro-type-member-init-use-assignment run in all language modes
llvm-svn: 361628
2019-05-24 10:39:00 +00:00
Ilya Biryukov 0f748e6e9b [clangd] Limit the size of synthesized fix message
Summary: A temporary workaround until we figure out a better way to present fixes.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 361625
2019-05-24 10:26:23 +00:00
Ilya Biryukov cabab29af2 [CodeComplete] Filter override completions by function name
Summary:
We put only part of the signature starting with a function name into "typed text"
chunks now, previously the whole signature was "typed text".

This leads to meaningful fuzzy match scores, giving better signals to
compare with other completion items.

Ideally, we would not display the result type to the user, but that requires adding
a new kind of completion chunk.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 361623
2019-05-24 10:18:39 +00:00
Simon Pilgrim c472f7b010 Fix sphinx "Malformed option description" warning
llvm-svn: 361616
2019-05-24 09:31:32 +00:00
Matthias Gehre b087129b5d [clang-tidy] Add option "LiteralInitializers" to cppcoreguidelines-pro-type-member-init
Differential Revision: D24892

llvm-svn: 361601
2019-05-24 05:46:57 +00:00
Tamas Zolnai dab31924e9 [clang-tidy]: Add cert-oop54-cpp alias for bugprone-unhandled-self-assignment
Summary:
Added WarnOnlyIfThisHasSuspiciousField option to allow
to catch any copy assignment operator independently from
the container class's fields.
Added the cert alias using this option.

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

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

Tags: #clang

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

llvm-svn: 361550
2019-05-23 20:29:04 +00:00
Simon Pilgrim 30905a375e Fix sphinx unknown document error
llvm-svn: 361545
2019-05-23 20:07:27 +00:00
Ilya Biryukov 346758407e [Index] Fix reported references in presence of template type aliases
Summary: See the added test for an example.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 361511
2019-05-23 16:48:47 +00:00
Kadir Cetinkaya fb6ee67ab1 [clangd] Also update package-lock.json
llvm-svn: 361488
2019-05-23 12:02:14 +00:00
Dmitri Gribenko 1520dafa20 [clang-tidy] New check calling out uses of +new in Objective-C code
Summary:
Google's Objective-C style guide forbids calling or overriding +new to instantiate objects. This check warns on violations.

Style guide reference: https://google.github.io/styleguide/objcguide.html#do-not-use-new

Patch by Michael Wyman.

Reviewers: benhamilton, aaron.ballman, JonasToth, gribozavr, ilya-biryukov, stephanemoore, mwyman

Reviewed By: aaron.ballman, gribozavr, stephanemoore, mwyman

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

Tags: #clang, #clang-tools-extra

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

llvm-svn: 361487
2019-05-23 12:01:26 +00:00
Kadir Cetinkaya 7d230d2661 [clangd] Bump vscode extension version
llvm-svn: 361486
2019-05-23 11:58:03 +00:00
Kadir Cetinkaya b970fd7188 [clangd-vscode] Do not customize uri converters in vscode
Summary:
Clangd is already resolving symlinks on the server side, therefore
there is no more need to handle it in client side. This was also resulting in
breakages whenever index contained a symbol coming from a non-existent file(like
a generated file), e.g. during workspace symbols whole response was dropped
since stat had failed.

Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 361475
2019-05-23 09:58:29 +00:00
Ilya Biryukov eee5d425c1 [clangd-vscode] Bump versions dependencies. NFC
Result of running 'npm audit fix', which tracks security vulnerabilities.

llvm-svn: 361464
2019-05-23 08:06:24 +00:00
George Burgess IV 3d68a38be8 Remove unnecessary const&s; NFC
It's uncommon to rely on temporary lifetime extension when having a
regular, non-`const&` value behaves identically. Since `Twine::str`
and `buildFixMsgForStringFlag` both return regular `std::string`s,
there's seemingly no point in having `const&` here.

llvm-svn: 361457
2019-05-23 02:52:39 +00:00
Yitzhak Mandelbaum 9df7ce596b [clang-tidy] Add support for writing a check as a Transformer rewrite rule.
This revision introduces an adaptor from Transformer's rewrite rules
(`clang::tooling::RewriteRule`) to `ClangTidyCheck`.  For example, given a
RewriteRule `MyCheckAsRewriteRule`, it lets one define a tidy check as follows:

```
class MyTidyCheck : public TransformerClangTidyCheck {
 public:
  MyTidyCheck(StringRef Name, ClangTidyContext *Context)
      : TransformerClangTidyCheck(MyCheckAsRewriteRule, Name, Context) {}
};
```

Reviewers: aaron.ballman

Subscribers: mgorny, xazax.hun, cfe-commits, ilya-biryukov

Tags: #clang

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

llvm-svn: 361418
2019-05-22 18:56:18 +00:00
Kadir Cetinkaya eae2c64932 [clangd] improve help message for limit-results
Summary: Make it clear that the default is 100.

Patch by Brennan Vincent(@umanwizard)!

Reviewers: #clang-tools-extra, kadircet

Reviewed By: kadircet

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

Tags: #clang

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

llvm-svn: 361388
2019-05-22 14:19:40 +00:00
Don Hinton 24d27689bc [clang-tidy] remove default header-filter for run-clang-tidy
Summary:
run-clang-tidy.py was enforcing '-header-filter' parameter with an
unfortunate default value when none was given. Thus, leading to
overwritten clang-tidy configuration (e.g. from .clang-tidy).

This change removes the default value for '-header-filter' resulting in
the default behaviour of clang-tidy itself.

Fixes PR#41426

Reviewed By: hintonda

Patch by Torbjörn Klatt!

Tags: #clang-tools-extra, #clang

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

llvm-svn: 361344
2019-05-22 01:01:11 +00:00
Sam McCall 0321b370f2 [clangd] Turn no-parse-completion on by when preamble isn't ready. Add flag to force it.
Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 361258
2019-05-21 13:40:31 +00:00
Sam McCall a1b5780ec1 [clangd] Add tweak to convert normal to raw string literal, when it contains escapes.
Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 361252
2019-05-21 13:04:24 +00:00
Adam Balogh 5f3deb9bb5 [clang-tidy] New option for misc-throw-by-value-catch-by-reference
Catching trivial objects by value is not dangerous but may be
inefficient if they are too large. This patch adds an option
`WarnOnLargeObject` to the checker to also warn if such an object
is caught by value. An object is considered as "large" if its
size is greater than `MaxSize` which is another option. Default
value is the machine word of the architecture (size of the type
`size_t`).

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

llvm-svn: 361225
2019-05-21 07:25:06 +00:00
Ilya Biryukov 7e6b6ea877 [clangd] Make it possible to use VFS from parsing for getting tidy options
Summary:
To give an option for clangd embedders with snapshotted filesystem to
read config files from exact snapshots, possibly loosing some
performance from caching capabilities of the current implementations.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

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

llvm-svn: 361178
2019-05-20 17:30:46 +00:00
Dmitri Gribenko 1e593f342f Disable the modernize-use-trailing-return-type.cpp test in C++2a mode
It is performing a use-of-uninitialized-value, as detected by MSan.

llvm-svn: 361163
2019-05-20 15:12:12 +00:00
Ilya Biryukov 03a7353fa0 [clangd] Fix naming warning from clang-tidy. NFC
Also remove newlines and braces.

llvm-svn: 361147
2019-05-20 12:17:36 +00:00
Tamas Zolnai 11fa0ee8f4 [clang-tidy] Sort this list alphabetically
llvm-svn: 361138
2019-05-20 10:37:42 +00:00
Dmitri Gribenko cb18647b19 Run ClangTidy tests in all C++ language modes
Summary:
I inspected every test and did one of the following:

- changed the test to run in all language modes,

- added a comment explaining why the test is only applicable in a
  certain mode,

- limited the test to language modes where it passes and added a FIXME
  to fix the checker or the test.

Reviewers: alexfh, lebedev.ri

Subscribers: nemanjai, kbarton, arphaman, jdoerfert, lebedev.ri, cfe-commits

Tags: #clang

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

llvm-svn: 361131
2019-05-20 09:26:47 +00:00
Fangrui Song cb4b3e5cb4 [clangd] Respect WarningsAsErrors configuration for clang-tidy
This completes the fix for https://bugs.llvm.org/show_bug.cgi?id=41218.

Reviewed By: sammccall

Patch by Nathan Ridge!

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

llvm-svn: 361113
2019-05-19 04:19:14 +00:00
Fangrui Song c2aded5017 [clangd] Respect clang-tidy suppression comments
This partially fixes https://bugs.llvm.org/show_bug.cgi?id=41218.

Reviewed By: sammccall

Patch by Nathan Ridge!

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

llvm-svn: 361112
2019-05-19 04:06:52 +00:00
Ilya Biryukov 929af67361 [Lex] Allow to consume tokens while preprocessing
Summary:
By adding a hook to consume all tokens produced by the preprocessor.
The intention of this change is to make it possible to consume the
expanded tokens without re-runnig the preprocessor with minimal changes
to the preprocessor and minimal performance penalty when preprocessing
without recording the tokens.

The added hook is very low-level and reconstructing the expanded token
stream requires more work in the client code, the actual algorithm to
collect the tokens using this hook can be found in the follow-up change.

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: eraman, nemanjai, kbarton, jsji, riccibruno, cfe-commits

Tags: #clang

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

llvm-svn: 361007
2019-05-17 09:32:05 +00:00
Jonas Toth f12c9730ef [clang-tidy] Removed superfluous and slightly annoying newlines in run-clang-tidy's output.
Summary: The output of clang-tidy itself already has enough newlines, so the resulting output is more in line with the usual compiler output.

Patch by svenpanne.

Reviewers: alexfh, JonasToth

Reviewed By: JonasToth

Subscribers: JonasToth, cfe-commits

Tags: #clang

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

llvm-svn: 360883
2019-05-16 12:39:22 +00:00
Jonas Toth 792dc04166 [clang-tidy] Handle member variables in readability-simplify-boolean-expr
- Add readability-simplify-boolean-expr test cases for member variables
Fixes PR40179

Patch by LegalizeAdulthood.

Reviewers: alexfh, hokein, aaron.ballman, JonasToth

Reviewed By: JonasToth

Subscribers: jdoerfert, xazax.hun, cfe-commits

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

llvm-svn: 360882
2019-05-16 12:35:00 +00:00
Jonas Toth 3cbf3c8412 [clang-tidy] Do not list enabled checks when -quiet is given to run-clang-tidy.
Summary: When run-clang-tidy is given the -quiet flag, do not output the potentially hundreds of enabled check names at the beginning.

Patch by svenpanne.

Reviewers: alexfh, JonasToth

Reviewed By: JonasToth

Subscribers: JonasToth, cfe-commits

Tags: #clang

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

llvm-svn: 360869
2019-05-16 09:22:39 +00:00
Don Hinton 4c50e64fc5 [clang-tidy] Recommit r360785 "modernize-loop-convert: impl const cast iter" with correct attribution
Summary:
modernize-loop-convert was not detecting implicit casts to
const_iterator as convertible to range-based loops:

    std::vector<int> vec{1,2,3,4}
    for(std::vector<int>::const_iterator i = vec.begin();
        i != vec.end();
        ++i) { }

Thanks to Don Hinton for advice.

As well, this change adds a note for this check's applicability to code
targeting OpenMP prior version 5 as this check will continue breaking
compilation with `-fopenmp`. Thanks to Roman Lebedev for pointing this
out.

Fixes PR#35082

Patch by Torbjörn Klatt!

Reviewed By: hintonda

Tags: #clang-tools-extra, #clang

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

llvm-svn: 360788
2019-05-15 17:47:51 +00:00
Don Hinton 4ecb581188 Revert [clang-tidy] modernize-loop-convert: impl const cast iter
This reverts r360785 (git commit 42d28be802)

llvm-svn: 360787
2019-05-15 17:36:54 +00:00
Don Hinton 42d28be802 [clang-tidy] modernize-loop-convert: impl const cast iter
Summary:
modernize-loop-convert was not detecting implicit casts to
const_iterator as convertible to range-based loops:

    std::vector<int> vec{1,2,3,4}
    for(std::vector<int>::const_iterator i = vec.begin();
        i != vec.end();
        ++i) { }

Thanks to Don Hinton for advice.

As well, this change adds a note for this check's applicability to code
targeting OpenMP prior to version 5 as this check will continue breaking
compilation with `-fopenmp`. Thanks to Roman Lebedev for pointing this
out.

Fixes PR#35082

Reviewed By: hintonda

Tags: #clang-tools-extra, #clang

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

llvm-svn: 360785
2019-05-15 16:58:58 +00:00
Kristof Umann 7f7dd09001 [clang-tidy] new check: bugprone-branch-clone
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 Donát Nagy!

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

llvm-svn: 360779
2019-05-15 15:06:25 +00:00
Matthias Gehre 094584cd52 [clang-tidy] Fix invalid fixit for readability-static-accessed-through-instance (bug 40544)
Summary:
Fixed https://bugs.llvm.org/show_bug.cgi?id=40544
Before, we would generate a fixit like `(anonymous namespace)::Foo::fun();` for
the added test case.

Reviewers: aaron.ballman, alexfh, xazax.hun

Subscribers: rnkovacs, cfe-commits

Tags: #clang, #clang-tools-extra

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

llvm-svn: 360698
2019-05-14 18:23:10 +00:00
Matthias Gehre 5f9afe953d [clang-tidy] readability-redundant-declaration: fix false positive with C "extern inline"
Summary:
readability-redundant-declaration was diagnosing a redundant declaration
on "extern inline void f();", which is needed in C code to force an external definition
of the inline function f. (This is different to how inline behaves in C++).

Reviewers: alexfh, danielmarjamaki

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 360613
2019-05-13 19:21:57 +00:00
Tamas Zolnai de7a30cb0a [clang-tidy] new check: bugprone-unhandled-self-assignment
Summary:
This check searches for copy assignment operators which might not handle self-assignment properly. There are three patterns of
handling a self assignment situation: self check, copy-and-swap or the less common copy-and-move. The new check warns if none of
these patterns is found in a user defined implementation.

See also:
OOP54-CPP. Gracefully handle self-copy assignment
https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP54-CPP.+Gracefully+handle+self-copy+assignment

Reviewers: JonasToth, alexfh, hokein, aaron.ballman

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

Tags: #clang, #clang-tools-extra

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

llvm-svn: 360540
2019-05-12 12:23:56 +00:00
Aaron Ballman cc55804be0 Removing an unused member variable; NFC.
llvm-svn: 360451
2019-05-10 18:29:10 +00:00
Don Hinton b75e7eae17 [clang-tidy] Change the namespace for llvm checkers from 'llvm' to 'llvm_check'
Summary:
Change the namespace for llvm checkers from 'llvm' to
'llvm_check', and modify add_new_check.py and rename_check.py to
support the new namespace. Checker, file, and directory names remain
unchanged.

Used new version of rename_check.py to make the change in existing
llvm checkers, but had to fix LLVMTidyModule.cpp and
LLVMModuleTest.cpp by hand.

The changes made by rename_check.py are idempotent, so if accidentally
run multiple times, it won't do anything.

Reviewed By: aaron.ballman

Tags: #clang, #clang-tools-extra

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

llvm-svn: 360450
2019-05-10 18:27:09 +00:00
Aaron Ballman 61c0daa007 Recommit r360345 with fixes (was reverted in r360348).
Add the modernize-use-trailing-return check to rewrite function signatures to use trailing return types.

Patch by Bernhard Manfred Gruber.

llvm-svn: 360438
2019-05-10 16:24:28 +00:00
Dmitri Gribenko 4bf8632c45 check_clang_tidy.py now passes `-format-style=none` to clang_tidy
Summary:
If the test does not specify a formatting style, force "none"; otherwise
autodetection logic can discover a ".clang-tidy" file that is not
related to the test.

Reviewers: alexfh

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 360358
2019-05-09 17:08:10 +00:00
Kadir Cetinkaya 40177ac6d1 [clangd] Bump index version and get rid of wrong assertion
Summary:
After rL360344, BackgroundIndex expects symbols with zero refcounts.
Therefore existing index files are no longer valid.

Assertion regarding finding target of a reference was wrong, since
background-index might still be going on or we might've loaded only some part of
the shards and might be missing the declaring shards for the symbol.

Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 360349
2019-05-09 15:07:53 +00:00
Aaron Ballman 0268083329 Revert r360345 and r360346, as they are not passing the testbots.
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/48063/steps/test/logs/stdio

llvm-svn: 360348
2019-05-09 15:06:41 +00:00
Aaron Ballman f58a5c8803 Fixing a link in the release notes to appease the Sphinx bot.
llvm-svn: 360346
2019-05-09 15:00:38 +00:00
Aaron Ballman 8e015b2e94 Add the modernize-use-trailing-return check to rewrite function signatures to use trailing return types.
Patch by Bernhard Manfred Gruber.

llvm-svn: 360345
2019-05-09 14:48:17 +00:00
Kadir Cetinkaya 70674549f1 [clangd] Count number of references while merging RefSlabs inside FileIndex
Summary:
For counting number of references clangd was relying on merging every
duplication of a symbol. Unfortunately this does not apply to FileIndex(and one
of its users' BackgroundIndex), since we get rid of duplication by simply
dropping symbols coming from non-canonical locations. So only one or two(coming
from canonical declaration header and defined source file, if exists)
replications of the same symbol reaches merging step.

This patch changes reference counting logic to rather count number of different
RefSlabs a given SymbolID exists.

Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 360344
2019-05-09 14:22:07 +00:00
Ilya Biryukov 2612bac747 [clangd] Fix a TSAN warning in TUSchedulerTests
llvm-svn: 360336
2019-05-09 12:21:28 +00:00
Mikael Holmen a186edbc00 Fix gcc compilation warning in test case [NFC]
Without this, gcc (7.4) complains with

../tools/clang/tools/extra/clangd/unittests/PrintASTTests.cpp:99:28: error: ISO C++11 requires at least one argument for the "..." in a variadic macro [-Werror]
                         })));
                            ^

llvm-svn: 360334
2019-05-09 12:12:35 +00:00
Ilya Biryukov db68b104d8 [clangd] Use AsyncTaskRunner in BackgroundIndex instead of std::thread
Summary:
To unify the way we create threads in clangd.
This should simplify landing D50993.

Reviewers: kadircet

Reviewed By: kadircet

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

Tags: #clang

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

llvm-svn: 360332
2019-05-09 12:04:07 +00:00
Artem Dergachev 9820d04dbc [clang-tidy] Update documentation on ReSharper integration.
It's now possible to set custom clang-tidy binary.

Patch by Alexander Zaitsev!

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

llvm-svn: 360277
2019-05-08 18:12:12 +00:00
Dmitri Gribenko 1902bd9da0 Documentation for bugprone-inaccurate-erase: added an example of a bug that this checker catches
Reviewers: alexfh

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 360247
2019-05-08 12:02:31 +00:00
Ilya Biryukov 4c32d4fd9f [clang-tidy] Do not show incorrect fix in modernize-make-unique
Summary:
The case when initialize_list hides behind an implicit case was not
handled before.

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 360231
2019-05-08 08:52:18 +00:00
Ilya Biryukov 5b0872fcfd [clangd] Introduce intermediate representation of formatted text
Summary: That can render to markdown or plain text. Used for findHover requests.

Reviewers: malaperle, sammccall, kadircet

Reviewed By: sammccall

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

Tags: #clang

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

llvm-svn: 360151
2019-05-07 14:18:18 +00:00
Sam McCall b9ec3e9370 [clangd] Oops, switchSourceHeader still needs to return a URI.
Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 360121
2019-05-07 08:30:32 +00:00
Sam McCall 111fe84bbc [clangd] switchSourceHeader uses null not empty string as sentinel.
As far as I can see, only theia actually implements this, and it expects null.

llvm-svn: 360119
2019-05-07 07:55:35 +00:00
Sam McCall e04799fbe3 [clangd] Add test that r360116 accidentally fixed a duplicate-edits bug in rename. NFC
llvm-svn: 360118
2019-05-07 07:45:41 +00:00
Sam McCall c094912ae5 [clangd] Move Rename into its own file, and add unit test. NFC
Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 360116
2019-05-07 07:11:56 +00:00
Sam McCall b9de3eb9eb [clangd] add CLANG_ENABLE_CLANGD option to build clangd. Require threads.
Reviewers: gribozavr

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

Tags: #clang

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

llvm-svn: 360115
2019-05-07 07:05:47 +00:00
Adam Balogh ecd1a82ee2 [clang-tidy] Extend bugprone-sizeof-expression to check sizeof(pointers to structures)
Accidentally taking the size of a struct-pointer type or a value of this type
is more common than explicitly using the & operator for the value. This patch
extends the check to include these cases.

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

llvm-svn: 360114
2019-05-07 06:16:02 +00:00
Sam McCall 8940f46880 [clangd] Expose whether no-compile completion was used.
Summary: Embedding clients want to experiment with showing such results in e.g. a different color.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 360039
2019-05-06 12:03:26 +00:00
Adam Balogh 62468003ef [clang-tidy] Extend bugprone-sizeof-expression check to detect sizeof misuse in pointer arithmetic
Some programmers tend to forget that subtracting two pointers results in the
difference between them in number of elements of the pointee type instead of
bytes. This leads to codes such as `size_t size = (p - q) / sizeof(int)` where
`p` and `q` are of type `int*`. Or similarily, `if (p - q < buffer_size *
sizeof(int)) { ... }`. This patch extends `bugprone-sizeof-expression` to
detect such cases.

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

llvm-svn: 360032
2019-05-06 10:41:37 +00:00
Sam McCall 9fb22b2c86 [clangd] Boost code completion results that were named in the last few lines.
Summary:
The hope is this will catch a few patterns with repetition:

  SomeClass* S = ^SomeClass::Create()

  int getFrobnicator() { return ^frobnicator_; }

  // discard the factory, it's no longer valid.
  ^MyFactory.reset();

Without triggering antipatterns too often:

  return Point(x.first, x.^second);

I'm going to gather some data on whether this turns out to be a win overall.

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

Tags: #clang

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

llvm-svn: 360030
2019-05-06 10:25:10 +00:00
Ilya Biryukov 3ab77491dd [clangd] Qualify uses of ::testing everywhere. NFC
Add an initial '::' qualifier to all usages of 'testing' namespace that
did not have one.

The goal is to make our code style in tests more consistent.

llvm-svn: 360026
2019-05-06 10:08:47 +00:00
Sam McCall 949d69f5cf [clangd] Always call getFormatStyleForFile().
This means "format" will no longer return an error if the -fallback-style flag
is invalid, it will log and use LLVM style. This doesn't really matter.

Also document the dependence on global variables. (This patch is a
compromise - it's probably not worth actually avoiding the globals).

llvm-svn: 360020
2019-05-06 08:39:17 +00:00
Sam McCall fb60758004 [clangd] Support -fallback-style, similar to clang-format.
Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 360016
2019-05-06 08:11:59 +00:00
Richard Smith 9d4bb51f57 Fix test to avoid assuming clang will diagnose problems in unreachable code.
llvm-svn: 360009
2019-05-06 04:07:30 +00:00
Richard Smith 96d2735045 Fix up after r360006.
llvm-svn: 360007
2019-05-06 04:00:45 +00:00
Roman Lebedev ee1431072e [clang-tidy] openmp-exception-escape check: point to the structured-block
I'm not sure what i was thinking when i wrote it to point at the directive.
It's at the very least confusing, and in the `for` is very misleading.

We should point at the actual Stmt out of which the exception escapes,
to highlight where it should be fixed e.g. via adding try-catch block.

Yes, this breaks existing NOLINT, which is why this change needs to
happen now, not any later.

llvm-svn: 360002
2019-05-05 21:26:32 +00:00
Sam McCall ec026532d6 [clangd] Fix header-guard check for include insertion, and don't index header guards.
Summary:
Both of these attempt to check whether a header guard exists while parsing the
file. However the file is only marked as guarded once clang finishes processing
it. We defer the checks and work until SymbolCollector::finish().

This is ugly and ad-hoc, deferring *all* work might be cleaner.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 359880
2019-05-03 13:17:29 +00:00
Dmitri Gribenko b641b914a3 Added an AST matcher for declarations that are in the `std` namespace
Reviewers: alexfh

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 359876
2019-05-03 12:50:00 +00:00
Kadir Cetinkaya 50c3e8cb40 [clangd] Also perform merging for symbol definitions
Summary:
clangd currently prefers declarations from codegen files. This patch
implements that behavior for definition locations. If we have definiton
locations both coming from AST and index, clangd will perform a merging to show
the codegen file if that's the case.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 359874
2019-05-03 12:11:14 +00:00
Ilya Biryukov d020f270d6 [clangd] Minor code style cleanups in Protocol.h. NFC
- Remove a parameter name that was misspelled (OS used for non-stream
  parameter)
- Declare operator == (TextEdit, TextEdit) outside the struct, for
  consistency with other user-declared ops in our code.
- Fix naming style of a parameter.

llvm-svn: 359866
2019-05-03 08:03:21 +00:00
Jan Korous f90458b389 [clangd][xpc] Cannonicalize value of CLANGD_BUILD_XPC before caching
llvm-svn: 359824
2019-05-02 20:32:56 +00:00
Florian Gross e25a0e9510 Fixed: Duck-typing in readability-redundant-smartptr-get didn't catch MSVC STL smart pointers.
Differential Revision: https://reviews.llvm.org/D61209

llvm-svn: 359801
2019-05-02 16:41:28 +00:00
Sam McCall 1b29dec05f Reapply r359778: [clangd] Fix code completion of macros defined in the preamble region of the main file.
The bad assert has been removed, and updateOutOfDateIdentifier has been guarded.
This reverts commit r359796.

llvm-svn: 359799
2019-05-02 16:12:36 +00:00
Simon Pilgrim 73c44e45ec Revert rL359778 : [clangd] Fix code completion of macros defined in the preamble region of the main file.
Summary:
This is a tricky case (we baked the assumption that symbols come from
the preamble xor mainfile pretty deeply) and the fix is a bit of a hack:
We look at the code to guess the macro names, and deserialize them from
the preamble "by hand".

Reviewers: ilya-biryukov

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D60937
........
Fix buildbots http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/47684/

llvm-svn: 359796
2019-05-02 15:47:33 +00:00
Sam McCall 929f639eb8 [clangd] Fix code completion of macros defined in the preamble region of the main file.
Summary:
This is a tricky case (we baked the assumption that symbols come from
the preamble xor mainfile pretty deeply) and the fix is a bit of a hack:
We look at the code to guess the macro names, and deserialize them from
the preamble "by hand".

Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 359778
2019-05-02 11:06:44 +00:00
Sam McCall 15b89df9da [clangd] Improvements to header mapping: more precise parsing of cppreference symbol pages.
Summary:
Previously we were just jumping from the symbol index to the symbol page, and
grabbing all the headers mentioned there. But the page often lists multiple
symbols, and so we got false positives and thus ambiguities (which were dropped).

Now we look at which declarations are for the symbol we want, and prefer headers
listed above that symbol. If there are none, we fall back to the old behavior.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 359771
2019-05-02 09:34:30 +00:00
Sam McCall 553c139fc3 [clangd] Standard library mapping: prefer "primary" versions of functions over variants.
Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 359770
2019-05-02 09:31:24 +00:00
Sam McCall c9f5220af9 [clangd] Restore conventional names for lit configs, and .in/.py split. Fix build_mode indirection.
llvm-svn: 359763
2019-05-02 08:00:39 +00:00
Fangrui Song e54a93fe6f [clangd] Delete an unused declaration
llvm-svn: 359674
2019-05-01 12:16:37 +00:00
Sam McCall 5b54006be6 [clangd] gen_std uses multiprocessing pool to be fast. While here, log ambiguous symbols. NFC
llvm-svn: 359564
2019-04-30 14:21:10 +00:00