Commit Graph

1403 Commits

Author SHA1 Message Date
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
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
Julie Hockett 6e79ac5339 [clang-tidy] Marking hicpp-no-assembler-msvc unsupported on Windows
After changes to lit.site.cfg.in, the test is now running (and failing)
on windows, so temporarily marking it unsupported. See PR36855 for more
details.

llvm-svn: 328127
2018-03-21 18:03:41 +00:00
Jonas Toth bf50a7f880 [clang-tidy] Resubmit hicpp-multiway-paths-covered without breaking test
The original check did break the green buildbot in the sanitizer build.
It took a while to redroduce and understand the issue.

There occured a stackoverflow while parsing the AST. The testcase with
256 case labels was the problem because each case label added another
stackframe. It seemed that the issue occured only in 'RelWithDebInfo' builds
and not in normal sanitizer builds.

To simplify the matchers the recognition for the different kinds of switch
statements has been moved into a seperate function and will not be done with
ASTMatchers. This is an attempt to reduce recursion and stacksize as well.

The new check removed this big testcase. Covering all possible values is still
implemented for bitfields and works there. The same logic on integer types
will lead to the issue.

Running it over LLVM gives the following results:


Differential: https://reviews.llvm.org/D40737
llvm-svn: 328107
2018-03-21 15:34:15 +00:00
Alexander Kornienko 670c6315ac [clang-tidy][modernize-make-unique] Checks c++14 flag before using std::make_unique
Summary: For a c++11 code, the clang-tidy rule "modernize-make-unique" should return immediately, as std::make_unique is not supported.

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

Reviewed By: hokein, aaron.ballman, alexfh

Subscribers: Quuxplusone, xazax.hun, cfe-commits

Tags: #clang-tools-extra

Patch by Frederic Tingaud!

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

llvm-svn: 328101
2018-03-21 14:39:24 +00:00
Petr Hosek 98c1aefdff Revert "[lit] Adding config initialization to lit tests in clang-tools-extra"
This reverts commit r328060 because a test that was inteded to run on
Windows but never ran before due to the missing config initialization
is now being executed and is failing.

llvm-svn: 328069
2018-03-21 02:28:22 +00:00
Julie Hockett bb059deacb [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.

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

llvm-svn: 328060
2018-03-20 23:22:50 +00:00
Douglas Yung 2ecc0d3954 Fixup test to explicitly use -fexceptions since exceptions are disabled by default on the PS4 target.
llvm-svn: 327911
2018-03-19 21:22:58 +00:00
Haojian Wu 4f3eecdf87 [clang-move] Fix the failing test caused by changes in clang-format.
llvm-svn: 327887
2018-03-19 19:13:03 +00:00
Fangrui Song db937c9e45 [clang-move] Fix move-used-helper-decls.cpp test.
llvm-svn: 327885
2018-03-19 19:05:53 +00:00
Miklos Vajna 10fe9bc79e run-clang-tidy: forward clang-tidy exit status
Exit with a non-zero value in case any of the underlying clang-tidy
invocations exit with a non-zero value.

This is useful in case WarningsAsErrors is enabled for some of the
checks: if any of those checks find something, the exit status now
reflects that.

Also add the ability to use run-clang-tidy.py via lit, and assert that
the exit code is not 0 when modernize-use-auto is triggered
intentionally.

Reviewers: alexfh, aaron.ballman

Reviewed By: aaron.ballman

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

llvm-svn: 327854
2018-03-19 14:43:59 +00:00
Alexander Kornienko fcefdb877c [clang-tidy] New check bugprone-unused-return-value
Summary:
Detects function calls where the return value is unused.

Checked functions can be configured.

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

Reviewed By: alexfh, aaron.ballman

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

Tags: #clang-tools-extra

Patch by Kalle Huttunen!

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

llvm-svn: 327833
2018-03-19 13:02:32 +00:00
Alexander Kornienko 67112853c2 [clang-tidy] rename_check.py misc-unused-raii bugprone-unused-raii --check_class_name=UnusedRAIICheck
llvm-svn: 327610
2018-03-15 08:27:42 +00:00
Alexander Kornienko 68fb65f413 [clang-tidy] rename_check.py misc-sizeof-container bugprone-sizeof-container
llvm-svn: 327608
2018-03-15 08:26:47 +00:00
Alexander Kornienko 3273888536 [clang-tidy] rename_check.py misc-sizeof-expression bugprone-sizeof-expression
llvm-svn: 327607
2018-03-15 08:26:19 +00:00
Alexander Kornienko 7ff6076129 [clang-tidy] rename_check.py {misc,bugprone}-macro-parentheses
llvm-svn: 327606
2018-03-15 08:25:39 +00:00
Julie Hockett b6f7c934ac [clang-tidy] Add Zircon module to clang-tidy
Adding a Zircon module to clang-tidy for checks specific to the Zircon
kernel, and adding a checker to fuchsia-zx (for zircon) to flag instances
where specific objects are temporarily created.

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

llvm-svn: 327590
2018-03-14 23:47:50 +00:00
Julie Hockett 729d9f868b Revert "Reland "[clang-doc] Setup clang-doc frontend framework""
This reverts commit r327295 since it was causing the Windows bots to
fail.

llvm-svn: 327346
2018-03-12 23:23:24 +00:00
Julie Hockett 93be22f418 Reland "[clang-doc] Setup clang-doc frontend framework"
There was a missing newline in the docs, and a static_assert that needed
to be a normal assert.

llvm-svn: 327295
2018-03-12 17:05:14 +00:00
Ilya Biryukov 71028b83e7 [clangd] Revamp handling of diagnostics.
Summary:
The new implementation attaches notes to diagnostic message and shows
the original diagnostics in the message of the note.

Reviewers: hokein, ioeric, sammccall

Reviewed By: sammccall

Subscribers: klimek, mgorny, cfe-commits, jkorous-apple

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

llvm-svn: 327282
2018-03-12 15:28:22 +00:00
Haojian Wu 06eeb5c00f [clangd] Fix failing lit test.
This test is missed in r327129.

llvm-svn: 327131
2018-03-09 14:16:46 +00:00
Haojian Wu 40571b7c1c [clang-tidy] Add check: replace string::find(...) == 0 with absl::StartsWith
Patch by Niko Weh!

Reviewers: hokein

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

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

llvm-svn: 327111
2018-03-09 10:47:14 +00:00
Julie Hockett c8922c16fb Revert "[clang-doc] Setup clang-doc frontend framework"
This reverts commit r327102, since it was breaking the linux-abi-test on
x86.

llvm-svn: 327103
2018-03-09 03:47:18 +00:00
Julie Hockett 671812462a [clang-doc] Setup clang-doc frontend framework
Setting up the mapper part of the frontend framework for a clang-doc
tool. It creates a series of relevant matchers for declarations, and
uses the ToolExecutor to traverse the AST and extract the matching
declarations and comments. The mapper serializes the extracted
information to individual records for reducing and eventually doc
generation.

For a more detailed overview of the tool, see the design document on the
mailing list: http://lists.llvm.org/pipermail/cfe-dev/2017-December/056203.html

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

llvm-svn: 327102
2018-03-09 03:16:39 +00:00
Fangrui Song c0e768df90 [clang-tidy] Add "portability" module and rename readability-simd-intrinsics to portability-simd-intrinsics
Reviewers: alexfh

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

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

llvm-svn: 326909
2018-03-07 16:57:42 +00:00
Ilya Biryukov 53d6d9369b [clangd] Don't end completion item labels with '::'
llvm-svn: 326809
2018-03-06 16:45:21 +00:00
Haojian Wu 0dc8fd7460 [clang-tidy] Fix one corner case in make-unique check.
Summary:
Previously, we tried to cover all "std::initializer_list" implicit conversion
cases in the code, but there are some corner cases that not covered (see
newly-added test in the patch).

Sipping all implicit AST nodes is a better way to filter out all these cases.

Reviewers: ilya-biryukov

Subscribers: klimek, xazax.hun, cfe-commits

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

llvm-svn: 326799
2018-03-06 14:34:35 +00:00
Aaron Ballman ada5234b6e Adds a clang-tidy test for a failing assertion in the misc-misplaced-const check.
The test case previously triggered an assertion in the AST matchers because the QualType being matched is invalid. That is no longer the case after r326604.

llvm-svn: 326605
2018-03-02 19:14:34 +00:00
Alexander Kornienko eb9d944419 [clang-tidy] Another batch of checks to rename from misc- to bugprone-.
Summary:
clang-tidy/rename_check.py {misc,bugprone}-suspicious-semicolon
clang-tidy/rename_check.py {misc,bugprone}-suspicious-string-compare
clang-tidy/rename_check.py {misc,bugprone}-swapped-arguments
clang-tidy/rename_check.py {misc,bugprone}-undelegated-constructor --check_class_name UndelegatedConstructor

Reviewers: hokein, sammccall, aaron.ballman

Subscribers: klimek, mgorny, xazax.hun, cfe-commits

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

llvm-svn: 326386
2018-02-28 23:47:15 +00:00
Alexander Kornienko cb6d320345 Rename more checks from misc- to bugprone-.
Summary:
clang-tidy/rename_check.py {misc,bugprone}-string-integer-assignment
clang-tidy/rename_check.py {misc,bugprone}-string-literal-with-embedded-nul
clang-tidy/rename_check.py {misc,bugprone}-suspicious-enum-usage
clang-tidy/rename_check.py {misc,bugprone}-suspicious-missing-comma

Reviewers: hokein, sammccall, aaron.ballman

Subscribers: klimek, cfe-commits, mgorny

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

llvm-svn: 326384
2018-02-28 23:30:29 +00:00
Eric Liu 771daeda32 [clangd] Try to fix failures on clang-x64-ninja-win7 build bot.
llvm-svn: 326365
2018-02-28 20:31:00 +00:00
Alexander Kornienko a1a2933634 Rename a few checks from misc- to bugprone-.
Summary:
rename_check.py {misc,bugprone}-forwarding-reference-overload
rename_check.py {misc,bugprone}-macro-repeated-side-effects
rename_check.py {misc,bugprone}-lambda-function-name
rename_check.py {misc,bugprone}-misplaced-widening-cast

Reviewers: hokein, sammccall, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: klimek, cfe-commits, mgorny

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

llvm-svn: 326327
2018-02-28 14:47:20 +00:00
Alexander Kornienko a94a4308e1 [clang-tidy] Add a test for readability-implicit-bool-conversion with bitfields.
llvm-svn: 326314
2018-02-28 10:30:25 +00:00
Eric Liu 6c8e858551 [clangd] don't insert new includes if either original header or canonical header is already included.
Summary:
Changes:
o Store both the original header and the canonical header in LSP command.
o Also check that both original and canonical headers are not already included
by comparing both resolved header path and written literal includes.

This addresses the use case where private IWYU pragma is defined in a private
header while it would still be preferrable to include the private header, in the
internal implementation file. If we have seen that the priviate header is already
included, we don't try to insert the canonical include.

Reviewers: sammccall

Reviewed By: sammccall

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

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

llvm-svn: 326070
2018-02-26 08:32:13 +00:00
Yan Zhang 2d83647007 [clang-tidy/google] Improve the Objective-C global variable declaration check 🔧
Summary:
The current Objective-C global variable declaration check restricts naming that is permitted by the Google Objective-C style guide.

The Objective-C style guide states the following:
"Global and file scope constants should have an appropriate prefix. [...] Constants may use a lowercase k prefix when appropriate"
http://google.github.io/styleguide/objcguide#constants

This change fixes the check to allow two or more capital letters as an appropriate prefix. This change intentionally avoids making a decision regarding whether to flag constants that use a two letter prefix (two letter prefixes are reserved by Apple¹ but many projects seem to violate this guideline).

This change eliminates an important category of false positives (constants prefixed with '[A-Z]{2,}') at the cost of introducing a less important category of false negatives (constants prefixed with only '[A-Z]'). The false positives are observed in standard recommended code while the false negatives occur in non-standard unrecommended code. The number of eliminated false positives is expected to be significantly larger than the number of exposed false negatives.

❧

(1)
"Two-letter prefixes like these are reserved by Apple for use in framework classes."
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Conventions/Conventions.html

Reviewers: aaron.ballman, Wizard, hokein, benhamilton

Reviewed By: aaron.ballman, Wizard

Subscribers: aaron.ballman, cfe-commits

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

llvm-svn: 326046
2018-02-25 04:11:26 +00:00
Gabor Horvath 76e5023dd3 [clang-tidy] Replace the usage of std::uncaught_exception with std::uncaught_exceptions
Patch by: Daniel Kolozsvari!

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

llvm-svn: 325572
2018-02-20 10:48:38 +00:00
Marc-Andre Laperle 3e618ed8f0 [clangd] Implement textDocument/hover
Summary: Implemention of textDocument/hover as described in LSP definition.

This patch adds a basic Hover implementation.  When hovering a variable,
function, method or namespace, clangd will return a text containing the
declaration's scope, as well as the declaration of the hovered entity.
For example, for a variable:

  Declared in class Foo::Bar

  int hello = 2

For macros, the macro definition is returned.

This patch doesn't include:

- markdown support (the client I use doesn't support it yet)
- range support (optional in the Hover response)
- comments associated to variables/functions/classes

They are kept as future work to keep this patch simpler.

I added tests in XRefsTests.cpp.  hover.test contains one simple
smoketest to make sure the feature works from a black box perspective.

Reviewers: malaperle, krasimir, bkramer, ilya-biryukov

Subscribers: sammccall, mgrang, klimek, rwols, ilya-biryukov, arphaman, cfe-commits

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

Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
Signed-off-by: William Enright <william.enright@polymtl.ca>
llvm-svn: 325395
2018-02-16 21:38:15 +00:00
Eric Liu c5105f9e3c [clangd] collect symbol #include & insert #include in global code completion.
Summary:
o Collect suitable #include paths for index symbols. This also does smart mapping
for STL symbols and IWYU pragma (code borrowed from include-fixer).
o For global code completion, add a command for inserting new #include in each code
completion item.

Reviewers: sammccall

Reviewed By: sammccall

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

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

llvm-svn: 325343
2018-02-16 14:15:55 +00:00
Fangrui Song 258a959084 [clang-tidy] Add `readability-simd-intrinsics` check.
Summary:
Many architectures provide SIMD operations (e.g. x86 SSE/AVX, Power AltiVec/VSX,
ARM NEON). It is common that SIMD code implementing the same algorithm, is
written in multiple target-dispatching pieces to optimize for different
architectures or micro-architectures.

The C++ standard proposal P0214 and its extensions cover many common SIMD
operations. By migrating from target-dependent intrinsics to P0214 operations,
the SIMD code can be simplified and pieces for different targets can be unified.

Refer to http://wg21.link/p0214 for introduction and motivation for the
data-parallel standard library.

Subscribers: klimek, aemerson, mgorny, xazax.hun, kristof.beyls, hintonda, cfe-commits

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

llvm-svn: 325272
2018-02-15 17:56:43 +00:00
Sam McCall bf472fde57 [clangd] Use explicit env in test to make lit+windows happy. NFC
llvm-svn: 325257
2018-02-15 16:20:33 +00:00
Ilya Biryukov 23bc73b626 [clangd] Enable snippet completion based on client capabilities.
Summary: And remove -enable-snippets flag.

Reviewers: hokein, ioeric, sammccall

Reviewed By: ioeric

Subscribers: klimek, jkorous-apple, cfe-commits

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

llvm-svn: 325242
2018-02-15 14:32:57 +00:00
Gabor Horvath 387d0005e0 [clang-tidy] Make a test pass on platforms where exceptions disabled by default.
llvm-svn: 325225
2018-02-15 09:24:55 +00:00
Gabor Horvath c23f924b75 [clang-tidy] New checker for exceptions that are created but not thrown
Patch by: Kristof Umann

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

llvm-svn: 325222
2018-02-15 09:08:51 +00:00
Sam McCall 7929d006d7 [clangd] Fix tracing now that spans lifetimes can overlap on a thread.
Summary:
The chrome trace viewer requires events within a thread to strictly nest.
So we need to record the lifetime of the Span objects, not the contexts.

But we still want to show the relationship between spans where a context crosses
threads, so do this with flow events (i.e. arrows).

Before: https://photos.app.goo.gl/q4Dd9u9xtelaXk1v1
After: https://photos.app.goo.gl/5RNLmAMLZR3unvY83

(This could stand some further improvement, in particular I think we want a
container span whenever we schedule work on a thread. But that's another patch)

Reviewers: ioeric

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

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

llvm-svn: 325220
2018-02-15 08:40:54 +00:00
Sam McCall ed2717ad33 [clangd] Configure clangd tracing with CLANGD_TRACE env instead of -trace flag
llvm-svn: 325097
2018-02-14 03:20:07 +00:00
Julie Hockett 9a26bf935c [clang-tidy] Update fuchsia-multiple-inheritance to not fail
Updating the fuchsia-multiple-inheritance to gracefully handle unknown
record types (e.g. templatized classes) by simply continuing, rather
than asserting and failing.

Fixes PR36052.

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

llvm-svn: 325015
2018-02-13 15:40:40 +00:00
Saleem Abdulrasool 16d26f6f94 test: use target triple for the test
Now that `pragma comment` is also used on ELF-ish targets with a
restricted set of options, we need to specify the full target here for
the test.

llvm-svn: 324441
2018-02-07 02:27:34 +00:00