Commit Graph

4722 Commits

Author SHA1 Message Date
Ilya Biryukov 04112ecd41 [clangd] Return TextEdits from ClangdServer::applyTweak
Summary:
Instead of `tooling::Replacements`. So that embedders do not need to store
the contents of the file.

This also aligns better with `ClangdServer::rename`.

Reviewers: kadircet, hokein

Reviewed By: hokein

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 363150
2019-06-12 12:03:24 +00:00
Nikolai Kosjar f6efac67e1 [clangd] Fix typo in GUARDED_BY()
Reviewers: ilya-biryukov, kadircet, sammccall

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

Tags: #clang

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

llvm-svn: 363139
2019-06-12 11:01:19 +00:00
Dmitri Gribenko cf7d768351 Fixed a crash in misc-redundant-expression ClangTidy checker
Summary: It was trying to pass a dependent expression into constant evaluator.

Reviewers: ilya-biryukov

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 363133
2019-06-12 08:40:53 +00:00
Nikolai Kosjar be8d03a512 [clang-tidy] Fix invalid read on destruction
...in case the clang tidy plugin is linked into the clang binary.

Valgrind's memcheck reports:

8949== Invalid read ==8866== Invalid read of size 4
8866== at 0x164D248B: fetch_sub (atomic_base.h:524)
8866== by 0x164D248B: llvm::ThreadSafeRefCountedBase<clang::ast_matchers::internal::DynMatcherInterface>::Release() const (IntrusiveRefCntPtr.h:98)
8866== by 0x164CE16C: llvm::IntrusiveRefCntPtrInfo<clang::ast_matchers::internal::DynMatcherInterface>::release(clang::ast_matchers::internal::DynMatcherInterface*) (IntrusiveRefCntPtr.h:127)
8866== by 0x164C8D5C: llvm::IntrusiveRefCntPtr<clang::ast_matchers::internal::DynMatcherInterface>::release() (IntrusiveRefCntPtr.h:190)
8866== by 0x164C3B87: llvm::IntrusiveRefCntPtr<clang::ast_matchers::internal::DynMatcherInterface>::~IntrusiveRefCntPtr() (IntrusiveRefCntPtr.h:157)
8866== by 0x164BB4F1: clang::ast_matchers::internal::DynTypedMatcher::~DynTypedMatcher() (ASTMatchersInternal.h:341)
8866== by 0x164BB529: clang::ast_matchers::internal::Matcher<clang::QualType>::~Matcher() (ASTMatchersInternal.h:496)
8866== by 0xD7AE614: __cxa_finalize (cxa_finalize.c:83)
8866== by 0x164B3082: ??? (in /d2/llvm/8/qtc/builds/DebugShared/lib/libclangTidyModernizeModule.so.8)
8866== by 0x4010B72: _dl_fini (dl-fini.c:138)
8866== by 0xD7AE040: __run_exit_handlers (exit.c:108)
8866== by 0xD7AE139: exit (exit.c:139)
8866== by 0xD78CB9D: (below main) (libc-start.c:344)
8866== Address 0x19dd9bc8 is 8 bytes inside a block of size 16 free'd
8866== at 0x4C3123B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
8866== by 0x1469BB99: clang::ast_matchers::internal::(anonymous namespace)::TrueMatcherImpl::~TrueMatcherImpl() (ASTMatchersInternal.cpp:126)
8866== by 0x1469BBC5: llvm::object_deleter<clang::ast_matchers::internal::(anonymous namespace)::TrueMatcherImpl>::call(void*) (ManagedStatic.h:30)
8866== by 0x9ABFF26: llvm::ManagedStaticBase::destroy() const (ManagedStatic.cpp:72)
8866== by 0x9ABFF94: llvm::llvm_shutdown() (ManagedStatic.cpp:84)
8866== by 0x9A65232: llvm::InitLLVM::~InitLLVM() (InitLLVM.cpp:52)
8866== by 0x14B0C8: main (driver.cpp:323)
8866== Block was alloc'd at
8866== at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
8866== by 0x1469BB36: llvm::object_creator<clang::ast_matchers::internal::(anonymous namespace)::TrueMatcherImpl>::call() (ManagedStatic.h:24)
8866== by 0x9ABFD99: llvm::ManagedStaticBase::RegisterManagedStatic(void* (*)(), void (*)(void*)) const (ManagedStatic.cpp:42)
8866== by 0x1469B5DF: llvm::ManagedStatic<clang::ast_matchers::internal::(anonymous namespace)::TrueMatcherImpl, llvm::object_creator<clang::ast_matchers::internal::(anonymous namespace)::TrueMatcherImpl>, llvm::object_deleter<clang::ast_matchers::internal::(anonymous namespace)::TrueMatcherImpl> >::operator*() (ManagedStatic.h:67)
8866== by 0x14698F9D: clang::ast_matchers::internal::DynTypedMatcher::trueMatcher(clang::ast_type_traits::ASTNodeKind) (ASTMatchersInternal.cpp:195)
8866== by 0x164C9D3B: _ZNK5clang12ast_matchers8internal11TrueMatchercvNS1_7MatcherIT_EEINS_8QualTypeEEEv (ASTMatchersInternal.h:1247)
8866== by 0x16501458: __static_initialization_and_destruction_0(int, int) (LoopConvertCheck.cpp:48)
8866== by 0x16501976: _GLOBAL__sub_I_LoopConvertCheck.cpp (LoopConvertCheck.cpp:920)
8866== by 0x4010732: call_init (dl-init.c:72)
8866== by 0x4010732: _dl_init (dl-init.c:119)
8866== by 0x40010C9: ??? (in /lib/x86_64-linux-gnu/ld-2.27.so)

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

llvm-svn: 363068
2019-06-11 14:19:09 +00:00
Clement Courbet f63feaf3c2 [clang-tidy] Fix typo in bugprone-string-constructor.
s/bigger then/bigger than/

llvm-svn: 363053
2019-06-11 12:12:06 +00:00
Dmitri Gribenko be20daa8eb Fixed google-readability-casting test to work in c++17
Summary: Fixed google-readability-casting.cpp to get tests working in c++17

Reviewers: gribozavr, hokein

Reviewed By: gribozavr

Subscribers: cfe-commits

Tags: #clang

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

Patch by Shaurya Gupta.

llvm-svn: 363047
2019-06-11 10:59:22 +00:00
Haojian Wu b011ee8ae8 [clangd] Add missing header guard.
llvm-svn: 363037
2019-06-11 08:50:35 +00:00
Mikael Holmen e2acbeb94c [clangd] Fix gcc warning by removing extra ";"
llvm-svn: 363034
2019-06-11 06:02:01 +00:00
Sam McCall c920c37361 [clangd] Remove old hidden -use-dex-index flag
llvm-svn: 362978
2019-06-10 20:38:16 +00:00
Sam McCall 25c6257ba0 [clangd] Revamp textDocument/onTypeFormatting.
Summary:
The existing implementation (which triggers on }) is fairly simple and
has flaws:
 - doesn't trigger frequently/regularly enough (particularly in editors that type the }
 for you)
 - often reformats too much code around the edit
 - has jarring cases that I don't have clear ideas for fixing

This implementation is designed to trigger on newline, which feels to me more
intuitive than } or ;.
It does have allow for reformatting after other characters - it has a
basic behavior and a model for adding specialized behavior for
particular characters. But at least initially I'd stick to advertising
\n in the capabilities.

This also handles comment splitting: when you insert a line break inside
a line comment, it will make the new line into an aligned line comment.

Working on tests, but want people to patch it in and try it - it's hard to
see if "feel" is right purely by looking at a test.

Reviewers: ilya-biryukov, hokein

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

Tags: #clang

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

llvm-svn: 362939
2019-06-10 14:26:21 +00:00
Sam McCall 149786d5b7 [clangd] Stop marshalling/requiring FormattingOptions. We never did anything with them.
llvm-svn: 362934
2019-06-10 13:01:49 +00:00
Ilya Biryukov a7a1147d4f [clangd] Return empty results on spurious completion triggers
Summary:
We currently return an error, this causes `coc.nvim` and VSCode to
show an error message in the logs.

Returning empty list of completions allows to avod the error message
without altering other user-visible behavior.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

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

llvm-svn: 362811
2019-06-07 16:24:38 +00:00
Haojian Wu a4f5a2ad1f [clang-tidy] Another attempt to fix misc-redundant-expression check.
Correct the fix of rL3627011, the isValueDependent guard was added in a wrong place in rL362701.

llvm-svn: 362706
2019-06-06 13:43:38 +00:00
Nikolai Kosjar 60e1296a9a [clang-tidy] Make the plugin honor NOLINT
Instantiate a ClangTidyDiagnosticConsumer also for the plugin case and
let it forward the diagnostics to the external diagnostic engine that is
already in place.

One minor difference to the clang-tidy executable case is that the
compiler checks/diagnostics are referred to with their original name.
For example, for -Wunused-variable the plugin will refer to the check as
"-Wunused-variable" while the clang-tidy executable will refer to that
as "clang-diagnostic- unused-variable". This is because the compiler
diagnostics never reach ClangTidyDiagnosticConsumer.

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

llvm-svn: 362702
2019-06-06 13:13:27 +00:00
Haojian Wu df95e6109e [clang-tidy] Fix an assertion failure in misc-redundant-expression.
Summary:
The assertion "isIntegerConstantExpr" is triggered in the
isIntegerConstantExpr(), we should not call it if the expression is value
dependent.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 362701
2019-06-06 12:58:48 +00:00
Ilya Biryukov 54eeb3f40a [clangd] Remove unused signature help quality signal. NFC
ContainsActiveParameter is not used anywhere, set incorrectly (see the
removed FIXME) and has no unit tests.
Removing it to simplify the code.

llvm-svn: 362686
2019-06-06 08:32:25 +00:00
Haojian Wu 448acbc06f [clang-tidy] Fix make-unique tests on C++2a.
Summary:
These test cases are illgal in C++2a ("new Foo{}" needs to see the
default constructor), so move them to the C++14-only tests.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 362679
2019-06-06 07:48:55 +00:00
George Burgess IV 5b2a85d0de android: add a close-on-exec check on pipe()
On Android, pipe() is better to be replaced by pipe2() with O_CLOEXEC
flag to avoid file descriptor leakage.

Patch by Jian Cai!

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

llvm-svn: 362673
2019-06-06 05:21:45 +00:00
George Burgess IV 3da331b456 android: add a close-on-exec check on pipe2()
On Android, pipe2() is better to set O_CLOEXEC flag to avoid file
descriptor leakage.

Patch by Jian Cai!

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

llvm-svn: 362672
2019-06-06 05:21:39 +00:00
Ilya Biryukov 2df387b057 [clangd] Minor cleanup. NFC
Removed unused using declaration from TweakTests.cpp

llvm-svn: 362517
2019-06-04 16:19:11 +00:00
Kadir Cetinkaya a7f9f42d28 [clangd] Also apply adjustArguments when returning fallback commands
Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 362496
2019-06-04 13:38:36 +00:00
Simon Pilgrim 5b41fe58de Fix -Wparentheses warning. NFCI.
llvm-svn: 362491
2019-06-04 11:31:45 +00:00
Simon Pilgrim 5f7c20e279 Fix Wshadow warning
llvm-svn: 362489
2019-06-04 11:11:51 +00:00
Ilya Biryukov 4ef0f82b71 [clangd] Support offsets for parameters in signatureHelp
Summary: Added to LSP in version 3.14

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

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

llvm-svn: 362481
2019-06-04 09:36:59 +00:00
Ilya Biryukov 65de43bc8b [clangd] Fix a crash when clang-tidy is disabled
llvm-svn: 362469
2019-06-04 07:19:11 +00:00
Nathan Ridge 73e6f47da2 [clangd] SymbolCollector support for relations
Summary:
The only relation currently collected is RelationBaseOf, because this is
all we need for type hierarchy subtypes. Additional relations can be
collected in the future as the need arises.

This patch builds on D59407 and D62459.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 362467
2019-06-04 04:25:44 +00:00
Ilya Biryukov 1a44584588 [CodeComplete] Add a bit more whitespace to completed patterns
Summary:
E.g. we now turn `while(<#cond#>){` into `while (<#cond#>) {`

This slightly improves the final output. Should not affect clients that
format the result on their own.

Reviewers: gribozavr

Reviewed By: gribozavr

Subscribers: jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 362363
2019-06-03 08:34:25 +00:00
Haojian Wu ceb0cc54f9 [clang-tidy] Fix make-unique check to work in C++17 mode.
Summary:
Previously, we intended to omit the check fix to the case when constructor has
any braced-init-list argument. But the HasListInitializedArgument was not
correct to handle all cases (Foo(Bar{1, 2}) will return false in C++14
mode).

This patch fixes it, corrects the tests, and makes the check to run at C++17 mode.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 362361
2019-06-03 08:14:15 +00:00
Nathan Ridge 92524f9bf8 [clangd] Serialization support for RelationSlab
Summary: This builds on D59407 to provide YAML and RIFF serialization support.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 362353
2019-06-03 05:07:52 +00:00
Nathan Ridge 3fc299df3d [clangd] Add RelationSlab
Summary:
RelationSlab is a new index data structure that stores relations between
symbols.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 362352
2019-06-03 04:55:46 +00:00
Stephane Moore ec1982f07f Revise the google-objc-global-variable-declaration check to match the style guide.
Summary:
Revise the google-objc-global-variable-declaration check to match the style guide.

This commit updates the check as follows:
(1) Do not emit fixes for extern global constants.
(2) Allow the second character of prefixes for constants to be numeric (the new guideline is that global constants should generally be named with a prefix that begins with a capital letter followed by one or more capital letters or numbers).

https://google.github.io/styleguide/objcguide.html#prefixes

This is an amended re-submission of https://reviews.llvm.org/rG12e3726fadb0b2a4d8aeed0a2817b5159f9d029d.

Contributed By: yaqiji

Reviewers: Wizard, benhamilton, stephanemoore

Reviewed By: benhamilton, stephanemoore

Subscribers: mgorny, cfe-commits, yaqiji

Tags: #clang

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

llvm-svn: 362279
2019-05-31 23:41:15 +00:00
Haojian Wu 488c509d45 [clangd] Add missing license for rename.cpp, NFC.
llvm-svn: 362226
2019-05-31 14:38:16 +00:00
Nathan Ridge b2f45ac299 [clangd] clang-format SymbolCollector.cpp
llvm-svn: 362176
2019-05-30 23:54:43 +00:00
Chris Bieneman 760a9ee63c Support codesigning bundles and forcing
Summary:
Clangd's framework is assembled by copying binaries from the lib and bin directories into a bundle shape. This results in an invalid bundle code signature because the signature only applies to the binaries not the resources.

This patch adds two new options to `llvm_codesign` to enable re-signing the library and XPC service as bundles.

The `BUNDLE_PATH` option allow specifying an explicit path to codesign, which enables signing bundles which aren't generated using CMake's `FRAMEWORK` or `BUNDLE` target properties.

The `FORCE` option allows re-signing binaries that have already been signed. This is required for how clangd exposes the clangd library and tools as both XPC and non-XPC services using the same binary.

Reviewers: jkorous, bogner

Reviewed By: bogner

Subscribers: mgorny, ilya-biryukov, dexonsmith, arphaman, kadircet, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

llvm-svn: 362169
2019-05-30 22:25:48 +00:00
Ilya Biryukov f6faa382f3 [Index] Compute correct symbol kind for variable templates
Summary:
The index library itself seems to never pass variable templates as
input, however clangd does.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 361996
2019-05-29 17:49:30 +00:00
Ilya Biryukov c450874cb8 [clangd] Map typedefs to the same LSP completion kind as VSCode
For consistency and, more importantly, to get a nicer icon for those in VSCode.

llvm-svn: 361969
2019-05-29 15:10:19 +00:00
Haojian Wu 228b130a4b [clangd] Fix buildbot error.
llvm-svn: 361960
2019-05-29 14:11:53 +00:00
Haojian Wu 4c5a0d1683 [clangd] Remove the whitelist std symbols in CanonicalIncludes.
Summary: These symbols have been included via StdSymbolMap.inc.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 361952
2019-05-29 12:08:11 +00:00
Haojian Wu 78c5fa97eb [clangd] Another improvement for std include mapping.
Summary:
Improve the way of checking a symbol name is in the first cell. The previous way
is not very robost for cases where a cell lists multiple symbols (e.g. int8_t).

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 361951
2019-05-29 12:03:41 +00:00
Ilya Biryukov bf559a7f3f [Index] Correctly set symbol kind of IndirectFieldDecl
Summary: The kind has been 'unknown' before, now it is 'field'.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 361941
2019-05-29 10:11:14 +00:00
Ilya Biryukov f9169d0896 [clangd] Represent Hover result using FormattedString
Reviewers: sammccall, kadircet

Reviewed By: kadircet

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

Tags: #clang

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

llvm-svn: 361940
2019-05-29 10:01:00 +00:00
Stephane Moore 9ac757bf09 Rollback "Revise the google-objc-global-variable-declaration check to match the style guide." 💥
The change introduced new test failures.

Phabricator URL of original commit: https://reviews.llvm.org/rG12e3726fadb0b2a4d8aeed0a2817b5159f9d029d

llvm-svn: 361914
2019-05-29 02:23:32 +00:00
Stephane Moore 12e3726fad Revise the google-objc-global-variable-declaration check to match the style guide.
Summary:
Revise the google-objc-global-variable-declaration check to match the style guide.

This commit updates the check as follows:
(1) Do not emit fixes for extern global constants.
(2) Allow the second character of prefixes for constants to be numeric (the new guideline is that global constants should generally be named with a prefix that begins with a capital letter followed by one or more capital letters or numbers).

https://google.github.io/styleguide/objcguide.html#prefixes

Contributed by yaqiji.

Reviewers: Wizard, benhamilton, stephanemoore

Reviewed By: benhamilton, stephanemoore

Subscribers: mgorny, cfe-commits, yaqiji

Tags: #clang

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

llvm-svn: 361907
2019-05-29 01:36:23 +00:00
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