Commit Graph

3223 Commits

Author SHA1 Message Date
Eugene Zelenko b7a747e6a3 [Documentation] Fix formatting and order in Release Notes for recent changes in modernize-use-auto.
llvm-svn: 329833
2018-04-11 18:03:57 +00:00
Malcolm Parsons 7c3e14b63b [clang-apply-replacements] Convert tooling::Replacements to tooling::AtomicChange for conflict resolving of changes, code cleanup, and code formatting.
Summary:
By converting Replacements by AtomicChange, clang-apply-replacements is able like clang-tidy to automatically cleanup and format changes.
This should permits to close this ticket: https://bugs.llvm.org/show_bug.cgi?id=35051 and attempt to follow hints from https://reviews.llvm.org/D43500 comments.

Reviewers: klimek, ioeric

Reviewed By: ioeric

Subscribers: malcolm.parsons, mgorny, cfe-commits

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

Patch by Jeremy Demeule.

llvm-svn: 329813
2018-04-11 14:39:17 +00:00
Jonas Toth 057f5a1259 [clang-tidy] fix buildbots from hicpp-signed-bitwise
The applied patch to diagnose assignment operators introduced
breakage on some architectures. This patch tries to rectify that.

llvm-svn: 329790
2018-04-11 10:22:25 +00:00
Jonas Toth 0f5f41df93 [clang-tidy] add missing assignment operations in hicpp-signed-bitwise
This patch resolves the bug https://bugs.llvm.org/show_bug.cgi?id=36963.

- implement missing assignment operators for hicpp-signed-bitwise
- mention fix in release notes

Reviewers:
aaron.ballman, hokein, alexfh

Differential: https://reviews.llvm.org/D45414
llvm-svn: 329789
2018-04-11 09:53:08 +00:00
George Burgess IV 3b151b2189 [clang-tidy] Add a `android-comparison-in-temp-failure-retry` check
This check attempts to catch buggy uses of the `TEMP_FAILURE_RETRY`
macro, which is provided by both Bionic and glibc.

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

llvm-svn: 329759
2018-04-10 21:22:22 +00:00
Roman Lebedev 9f742bc2e9 [clang-tidy] Unbreak run-clang-tidy.cpp test (modernize-use-auto.MinTypeNameLength)
Again, refs. D45405, rL329730.

llvm-svn: 329756
2018-04-10 20:59:27 +00:00
Roman Lebedev feaaa8c7a0 [clang-tidy][modernize]: don't forget to actually link to Tooling.
Fixes build for me:

[1/5] Linking CXX shared library lib/libclangTidyModernizeModule.so.7svn
FAILED: lib/libclangTidyModernizeModule.so.7svn
<...>
/usr/local/bin/ld.lld: error: undefined symbol: clang::tooling::fixit::internal::getText(clang::SourceRange, clang::ASTContext const&)
>>> referenced by UseAutoCheck.cpp
>>>               tools/clang/tools/extra/clang-tidy/modernize/CMakeFiles/clangTidyModernizeModule.dir/UseAutoCheck.cpp.o:(clang::tidy::modernize::UseAutoCheck::replaceExpr(clang::DeclStmt const*, clang::ASTContext*, llvm::function_ref<clang::QualType (clang::Expr const*)>, llvm::StringRef))


Refs. D45405, rL329730.

llvm-svn: 329750
2018-04-10 20:07:06 +00:00
Roman Lebedev 6bd27152e1 [clang-tidy][Fuchsia]: don't forget to actually link to Google Module.
Fixes build for me:

[1/7] Linking CXX shared library lib/libclangTidyFuchsiaModule.so.7svn
FAILED: lib/libclangTidyFuchsiaModule.so.7svn
<...>
/usr/local/bin/ld.lld: error: undefined symbol: clang::tidy::google::build::UnnamedNamespaceInHeaderCheck::UnnamedNamespaceInHeaderCheck(llvm::StringRef, clang::tidy::ClangTidyContext*)
>>> referenced by FuchsiaTidyModule.cpp
>>>               tools/clang/tools/extra/clang-tidy/fuchsia/CMakeFiles/clangTidyFuchsiaModule.dir/FuchsiaTidyModule.cpp.o:(std::_Function_handler<clang::tidy::ClangTidyCheck* (llvm::StringRef, clang::tidy::ClangTidyContext*), void clang::tidy::ClangTidyCheckFactories::registerCheck<clang::tidy::google::build::UnnamedNamespaceInHeaderCheck>(llvm::StringRef)::'lambda'(llvm::StringRef, clang::tidy::ClangTidyContext*)>::_M_invoke(std::_Any_data const&, llvm::StringRef&&, clang::tidy::ClangTidyContext*&&))

Refs. D45447, rCTE329720

llvm-svn: 329749
2018-04-10 20:07:02 +00:00
Zinovy Nis 032cc77b37 [clang-tidy] [modernize-use-auto] Fix members initialization order
llvm-svn: 329740
2018-04-10 18:56:29 +00:00
Zinovy Nis e68c7fa1e5 [clang-tidy] [modernize-use-auto] Add a threshold for minimal type name length to be replaced with 'auto'
The threshold option is 'MinTypeNameLength' with default value '5'. 
With MinTypeNameLength == 5 'int'/'bool' and 'const int'/'const bool' 
will not be converted to 'auto', while 'unsigned' will be. 

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

llvm-svn: 329730
2018-04-10 18:05:24 +00:00
Marc-Andre Laperle 90a937e3e1 [clangd] Use operator<< to prevent printers issues in Gtest
Summary:
It is possible that there will be two different instantiations of
the printer template for a given type and some tests could end up calling the
wrong (default) one. For example, it was seen in CodeCompleteTests.cpp when
printing CompletionItems that it would use the wrong printer because the default
is also instantiated in ClangdTests.cpp.

With this change, objects that were previously printed with a custom Printer now
get printed through the operator<< which is declared alongside the class.
This rule of the thumb should make it less error-prone.

Reviewers: simark, ilya-biryukov, sammccall

Reviewed By: simark, ilya-biryukov, sammccall

Subscribers: bkramer, hokein, sammccall, klimek, ilya-biryukov, jkorous-apple, ioeric, MaskRay, cfe-commits

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

llvm-svn: 329725
2018-04-10 17:34:46 +00:00
Julie Hockett 8c1ee67c3f [clang-tidy] Adding alias for anon namespaces in header (fuchsia module)
Adding alias to google-build-namespaces to the Fuchsia module (checks
for anonymous namespaces in headers).

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

llvm-svn: 329720
2018-04-10 16:53:51 +00:00
Nico Weber 0da2290958 s/LLVM_ON_WIN32/_WIN32/, clang-tools-extra
LLVM_ON_WIN32 is set exactly with MSVC and MinGW (but not Cygwin) in
HandleLLVMOptions.cmake, which is where _WIN32 defined too.  Just use the
default macro instead of a reinvented one.

See thread "Replacing LLVM_ON_WIN32 with just _WIN32" on llvm-dev and cfe-dev.
No intended behavior change.

llvm-svn: 329695
2018-04-10 13:14:03 +00:00
Michal Gorny 698fdfab75 [cmake] Include LLVMTestingSupport when doing stand-alone build
Explicitly include and build lib/Testing/Support from LLVM sources when
doing a stand-alone build. This is necessary since clangd tests started
to depend on LLVMTestingSupport library which is neither installed
by LLVM, nor built by clang itself.

Since completely separate build of clang-tools-extra is not supported,
this relies on variables set by clang CMakeLists.

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

llvm-svn: 329594
2018-04-09 17:08:14 +00:00
Haojian Wu b0847554b5 [clangd] Bump v0.0.6 for vscode-clangd.
llvm-svn: 329583
2018-04-09 15:37:09 +00:00
Sam McCall 307c4837cc [clang] Use compile-command interpolation to provide commands for header files.
Summary: This uses the inferring wrapper introduced in D45006.

Subscribers: klimek, ilya-biryukov, jkorous-apple, ioeric, cfe-commits

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

llvm-svn: 329582
2018-04-09 15:22:08 +00:00
Alexander Kornienko c3ad02e840 [clang-tidy] Return non-zero exit code for clang errors.
Summary:
Updated tests broken by this change.
Fixes https://bugs.llvm.org/show_bug.cgi?id=27628

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: klimek, xazax.hun, cfe-commits

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

llvm-svn: 329579
2018-04-09 15:12:10 +00:00
Haojian Wu e9a5a2f10c [clangd] Allow using customized include path in URI.
Summary:
Calculating the include path from absolute file path does not always
work for all build system, e.g. bazel uses symlink as the build working
directory. The absolute file path from editor and clang is diverged from
each other. We need to address it properly in build sysmtem integration.

This patch worksarounds the issue by providing a hook in URI which allows
clients to provide their customized include path.

Reviewers: sammccall

Subscribers: klimek, ilya-biryukov, jkorous-apple, ioeric, MaskRay, cfe-commits

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

llvm-svn: 329578
2018-04-09 15:09:44 +00:00
Marc-Andre Laperle c1d6b5e458 [clangd-vscode] Update VScode dependencies
Summary:
This allows the extension to work with LSP 3.0 and is useful for testing.

Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>

Reviewers: ilya-biryukov

Subscribers: hokein, klimek, ilya-biryukov, jkorous-apple, ioeric, MaskRay, cfe-commits

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

llvm-svn: 329574
2018-04-09 14:32:12 +00:00
Sam McCall b9d57118fb [clangd] Adapt index interfaces to D45014, and fix the old bugs.
Summary:
Fix bugs:
- don't count occurrences of decls where we don't spell the name
- findDefinitions at MACRO(^X) goes to the definition of MACRO

Subscribers: klimek, ilya-biryukov, jkorous-apple, ioeric, MaskRay, cfe-commits

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

llvm-svn: 329571
2018-04-09 14:28:52 +00:00
Philipp Stephani f8ff2ef966 Improve completion experience for headers
Summary: When calling `completing-read', we should provide a default to prevent the behavior described in https://github.com/DarwinAwardWinner/ido-completing-read-plus#why-does-ret-sometimes-not-select-the-first-completion-on-the-list--why-is-there-an-empty-entry-at-the-beginning-of-the-completion-list--what-happened-to-old-style-default-selection.  Also, don't use an assertion to check whether the user selected a header; raise a proper signal instead.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 329566
2018-04-09 13:31:44 +00:00
Chandler Carruth 324edae831 Fix unused variable warning.
llvm-svn: 329550
2018-04-09 07:26:42 +00:00
Zinovy Nis be119ca712 [clang-tidy] Fix compilation for MSVS@PSP4 for ParentVirtualCallCheck.cpp
There's an error for PSP4 platform only: 
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\algorithm(95): 
error C2719: '_Pred': formal parameter with requested alignment of 8 won't be aligned

llvm-svn: 329495
2018-04-07 11:22:01 +00:00
Zinovy Nis a093b160dc [clang-tidy] One more fix compilation for ParentVirtualCallCheck.cpp: find_if predicate
llvm-svn: 329454
2018-04-06 21:00:18 +00:00
Zinovy Nis 7e9745dd4c [clang-tidy] Fix compilation for ParentVirtualCallCheck.cpp
llvm-svn: 329452
2018-04-06 20:39:23 +00:00
Zinovy Nis 95ea1b05fd [clang-tidy] Check if grand-..parent's virtual method was called instead of overridden parent's.
class A {...int virtual foo() {...}...}; 
class B: public A {...int foo() override {...}...}; 
class C: public B {...int foo() override {... A::foo()...}};
                                              ^^^^^^^^ warning: qualified name A::foo refers to a member overridden in subclass; did you mean 'B'? [bugprone-parent-virtual-call] 

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

llvm-svn: 329448
2018-04-06 20:02:50 +00:00
George Burgess IV e0c2c49a15 [clang-tidy] Sort includes; NFC
llvm-svn: 329428
2018-04-06 17:22:36 +00:00
Sam McCall c8de52ed15 [clangd] move comment to the right place. NFC
llvm-svn: 329380
2018-04-06 07:48:21 +00:00
Benjamin Kramer be92ce14e1 [clang-tidy] Remove google-runtime-member-string-references
This is triggering on a pattern that's both too broad (const
std::string& members can be used safely) and too narrow (std::string is
not the only class with this problem). It has a very low true positive
rate, just remove it until we find a better solution for dangling string
references.

llvm-svn: 329292
2018-04-05 14:51:01 +00:00
Alexander Kornienko b1c746ef04 [clang-tidy] Rename -warnings-as-errors tests. NFC.
The tests will be more discoverable with proper names.

llvm-svn: 329182
2018-04-04 12:40:00 +00:00
Sam McCall ba3c02e461 [clangd] synthesize fix message when the diagnostic doesn't provide one.
Summary:
Currently if a fix is attached directly to a diagnostic, we repeat the
diagnostic message as the fix message. From eyeballing the top diagnostics,
it seems describing the textual replacement would be much clearer.

e.g.
error: use of undeclared identifier 'goo'; did you mean 'foo'?
action before: use of undeclared identifier 'goo'; did you mean 'foo'?
action after: change 'goo' to 'foo'

Reviewers: ilya-biryukov

Subscribers: klimek, jkorous-apple, ioeric, MaskRay, cfe-commits

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

llvm-svn: 329090
2018-04-03 17:35:57 +00:00
Haojian Wu dc62da4e0b [clang-tidy] Check for sizeof that call functions
Summary:
A common mistake that I have found in our codebase is calling a function to get an integer or enum that represents the type such as:

```
int numBytes = numElements * sizeof(x.GetType());
```

So this extends the `sizeof` check to check for these cases. There is also a `WarnOnSizeOfCall` option so it can be disabled.

Patch by Paul Fultz II!

Reviewers: hokein, alexfh, aaron.ballman, ilya-biryukov

Reviewed By: alexfh

Subscribers: lebedev.ri, xazax.hun, jkorous-apple, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 329073
2018-04-03 15:10:24 +00:00
Simon Dardis a826ca7079 [clangd][cmake] Provide libatomic when there is no native support for 64bit atomics
This addresses a persistent failure on clang-cmake-mips buildbot.

Reviewers: ioeric

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

llvm-svn: 329053
2018-04-03 09:40:07 +00:00
Mike Edwards ac6a6577d9 Revert r328932 as it caused Windows and MacOS bot failures.
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/43991/

llvm-svn: 328997
2018-04-02 18:02:36 +00:00
Zinovy Nis c16815ca8a [clang-tidy] Define __clang_analyzer__ macro for clang-tidy for compatibility with clang static analyzer
This macro is widely used in many well-known projects, ex. Chromium.
But it's not set for clang-tidy, so for ex. DCHECK in Chromium is not considered as [[no-return]], and a lot of false-positive warnings about nullptr dereferenced are emitted.
This patch fixes the issue by explicitly added macro definition.

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

llvm-svn: 328932
2018-04-01 11:51:57 +00:00
Fangrui Song 943e12e1c5 [clangd] Fix repeated word typo. NFC
llvm-svn: 328819
2018-03-29 20:03:16 +00:00
Marc-Andre Laperle 20c5e14ae1 [clangd] Mark "Source Hover" as implemented in the docs
Summary: Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>

Reviewers: simark

Reviewed By: simark

Subscribers: klimek, ilya-biryukov, ioeric, MaskRay, cfe-commits

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

llvm-svn: 328792
2018-03-29 14:49:21 +00:00
Reid Kleckner 93e2228648 Attempt to fix clangd test on Windows by wildcarding drive letters
llvm-svn: 328645
2018-03-27 17:44:12 +00:00
Krasimir Georgiev 20505898cb [clang-move] Fix test failing due to clang-format change
r328621 reverted the removal of empty lines before the closing `}` in
namespaces.

llvm-svn: 328622
2018-03-27 13:39:33 +00:00
Julie Hockett 9345d982d0 [clang-doc] Removing -Wunused-variable warning
Warning was appearing in release with debug info build, this removes it.

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

llvm-svn: 328588
2018-03-26 22:37:31 +00:00
Simon Marchi 9808262ede [clangd] Support incremental document syncing
Summary:
This patch adds support for incremental document syncing, as described
in the LSP spec.  The protocol specifies ranges in terms of Position (a
line and a character), and our drafts are stored as plain strings.  So I
see two things that may not be super efficient for very large files:

- Converting a Position to an offset (the positionToOffset function)
  requires searching for end of lines until we reach the desired line.
- When we update a range, we construct a new string, which implies
  copying the whole document.

However, for the typical size of a C++ document and the frequency of
update (at which a user types), it may not be an issue.  This patch aims
at getting the basic feature in, and we can always improve it later if
we find it's too slow.

Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>

Reviewers: malaperle, ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: MaskRay, klimek, mgorny, ilya-biryukov, jkorous-apple, ioeric, cfe-commits

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

llvm-svn: 328500
2018-03-26 14:41:40 +00:00
Jonathan Coe 96d81916b0 [clang-tidy] Enable Python 3 support for add_new_check.py
Summary: In Python 3, filters are lazily evaluated and strings are not bytes.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: xazax.hun, cfe-commits

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

llvm-svn: 328418
2018-03-24 10:49:17 +00:00
Jordan Rose 9d0d2ac327 Fix misuse of llvm::YAML in clangd test.
Caught by LLVM r328345!

llvm-svn: 328354
2018-03-23 19:16:07 +00:00
Ilya Biryukov 976b6975e4 [clangd] Remove 'static' from a function inside anonymous ns. NFC
llvm-svn: 328302
2018-03-23 10:39:15 +00:00
Julie Hockett e975a473b7 [clang-doc] Reland "[clang-doc] Setup clang-doc frontend framework"
Fixed windows release build tests.

llvm-svn: 328270
2018-03-22 23:34:46 +00:00
Alexander Kornienko 301faac18b clang-tidy, modularize: return non-zero exit code on errors
When no inputs given, the tools should not only produce the help message, but
also return a non-zero exit code. Fixed tests accordingly.

llvm-svn: 328199
2018-03-22 14:18:20 +00:00
Julie Hockett 2a0373a2db Revert "[clang-doc] Reland "[clang-doc] Setup clang-doc frontend framework""
This reverts commit r328150 until we can fix the test that are failing
on the Windows release build.

llvm-svn: 328172
2018-03-22 02:05:51 +00:00
Julie Hockett 1442a5dd3a [clang-doc] Reland "[clang-doc] Setup clang-doc frontend framework"
Fixing the the failing Windows tests.

llvm-svn: 328150
2018-03-21 21:21:45 +00:00
Jan Korous cd0efec2b4 [clangd][nfc] Correct header name in comment
llvm-svn: 328149
2018-03-21 21:04:10 +00:00
Julie Hockett 6f22226d6c Reland "[lit] Adding config initialization to lit tests in clang-tools-extra"
Adding the config initialization to clang-tools-extra so that tests that
use REQUIRES, UNSUPPORTED, and XFAIL based on platform or target triple
work properly.

llvm-svn: 328131
2018-03-21 18:50:26 +00:00