Commit Graph

4505 Commits

Author SHA1 Message Date
Alexander Kornienko 07ef786652 [clang-tidy] make getLangOpts return a const ref
llvm-svn: 357468
2019-04-02 11:31:56 +00:00
Ilya Biryukov bea52e5289 [clangd] Use capacity() instead of size() in RefSlab::bytes()
Patch by Nathan Ridge.

Reviewers: gribozavr

Reviewed By: gribozavr

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

Tags: #clang

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

llvm-svn: 357454
2019-04-02 08:24:37 +00:00
Reid Kleckner 1cd4216c75 Fix clangd unittest _WIN32 ifdef
WIN32 is not defined, _WIN32 is, use that instead.

llvm-svn: 357429
2019-04-01 21:16:17 +00:00
Sylvestre Ledru 7fb58e98f5 Spelling correction for docs for cppcoreguidelines-owning-memory
Summary: There's a typo in the docs, as mentioned in the title. Please see the diff.

Reviewers: JonasToth

Subscribers: sylvestre.ledru, nemanjai, kbarton, cfe-commits

Tags: #clang-tools-extra, #clang

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

llvm-svn: 357371
2019-03-31 21:53:00 +00:00
Nico Weber 76829d8928 gn build: Add build files for most clang-tools-extra unit tests
Differential Revision: https://reviews.llvm.org/D60038

llvm-svn: 357369
2019-03-31 16:49:54 +00:00
Nico Weber a28ee7ec4f Rename IncludeFixerTests to ClangIncludeFixerTests and ChangeNamespaceTests to ClangChangeNamespaceTests
Follow-up to r356897 and r356254.

llvm-svn: 357356
2019-03-30 23:09:10 +00:00
Alexander Kornienko 397ee70180 [clang-tidy] Fix PR28406
Fix the crash resulting from a careless use of getLocWithOffset. At the
beginning of a macro expansion it produces an invalid SourceLocation that causes
an assertion failure later on.

llvm-svn: 357312
2019-03-29 20:55:29 +00:00
Julie Hockett f64d4ec9be [clang-doc] Build as clang_tool
Instead of as clang_executable.

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

llvm-svn: 357274
2019-03-29 16:56:36 +00:00
Simon Pilgrim 945db0bef8 Fix MSVC "not all control paths return a value" warning. NFCI.
llvm-svn: 357253
2019-03-29 13:43:00 +00:00
Nico Weber 2a3f42c90d gn build: Add check-clang-tools to run clang-tools-extra lit tests
Only runs the clang-tools-extra lit tests; not yet the unit tests.

Add a build file for clangd-indexer too, since it's needed for
the tests.

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

llvm-svn: 357232
2019-03-29 02:49:13 +00:00
Nico Weber ef7b84231e Add .py extension to clang-tools-extra lit cfg files
Follow-up to r313892, which did this for clang and llvm.

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

llvm-svn: 357231
2019-03-29 02:46:31 +00:00
Sam McCall 4180a7cd83 Disable warnings when indexing as a standalone action.
Summary:
- we don't record the warnings at all
- we don't want to stop indexing if we hit error-limit due to warnings
- this allows some analyses to be skipped which can save some CPU

https://github.com/clangd/clangd/issues/24

Reviewers: hokein

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

Tags: #clang

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

llvm-svn: 357186
2019-03-28 17:07:28 +00:00
Nico Weber 5f3b38e173 gn build: Add some build files for clangd
Enough to build the clangd binaries, but this is still missing build
files for:
- fuzzer
- indexer
- index/dex/dexp
- benchmarks
- xpc

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

llvm-svn: 357182
2019-03-28 16:53:32 +00:00
Sam McCall 16cb94b65a [clangd] Update error message to fix tests after r357173
llvm-svn: 357175
2019-03-28 15:07:15 +00:00
Sam McCall 8b25d22880 [clangd] Support UTF-32 (i.e. codepoint) offsets.
Summary:
(Changes to UTF-8/UTF-16 here are NFC, moving things around to make the
cases more symmetrical)

Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 357173
2019-03-28 14:37:51 +00:00
Zinovy Nis f8b7269f98 [clang-tidy] Handle missing yaml module in run-clang-tidy.py
The Yaml module is missing on some systems and on many of clang buildbots. 
But the test for run-clang-tidy.py doesn't fail due to 'NOT' statement masking a python runtime error.

This patch conditionally imports and enables the yaml module only if it's present in the system. 
If not, then '-export-fixes' is disabled.

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

llvm-svn: 357114
2019-03-27 19:21:32 +00:00
Sam McCall a69698f45f [clangd] Support utf-8 offsets (rather than utf-16) as a protocol extension
Summary:
Still some pieces to go here: unit tests for new SourceCode functionality and
a command-line flag to force utf-8 mode. But wanted to get early feedback.

Reviewers: hokein

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

Tags: #clang

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

llvm-svn: 357102
2019-03-27 17:47:49 +00:00
Haojian Wu 566fba03de [clangd] Bump vscode-clangd v0.0.12.
CHANGELOG:
- add an explicit command to activate the extension.
- support .cu files (the extension is not activated for .cu files by default,
  you need to manually activate the extension).

llvm-svn: 357082
2019-03-27 16:01:25 +00:00
Haojian Wu 55beb2f549 [clangd] Fix the inconsistent code indent in vscode extension, NFC.
llvm-svn: 357078
2019-03-27 15:50:33 +00:00
Haojian Wu d44e201376 [clangd] Add activate command to the vscode extension.
Summary:
This would help minizime the annoying part of not activating the extension
for .cu file.

Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 357075
2019-03-27 15:41:59 +00:00
Duncan P. N. Exon Smith db8a742206 Basic: Return a reference from FileManager::getVirtualFileSystem, NFC
FileManager constructs a VFS in its constructor if it isn't passed one,
and there's no way to reset it.  Make that contract clear by returning a
reference from its accessor.

https://reviews.llvm.org/D59388

llvm-svn: 357038
2019-03-26 22:32:06 +00:00
Duncan P. N. Exon Smith 1da7eac87c Frontend: Remove CompilerInstance::VirtualFileSystem, NFC
Remove CompilerInstance::VirtualFileSystem and
CompilerInstance::setVirtualFileSystem, instead relying on the VFS in
the FileManager.  CompilerInstance and its clients already went to some
trouble to make these match.  Now they are guaranteed to match.

As part of this, I added a VFS parameter (defaults to nullptr) to
CompilerInstance::createFileManager, to avoid repeating construction
logic in clients that just wanted to customize the VFS.

https://reviews.llvm.org/D59377

llvm-svn: 357037
2019-03-26 22:18:52 +00:00
Jan Korous 2d000e395e [clangd][xpc][cmake] Respect explicit value of CLANGD_BUILD_XPC
We shouldn't prevent user from disabling XPC framework build on Darwin.
However, by keeping it on by default our CI systems also test
it by default on macOS.

Based on user request:
http://lists.llvm.org/pipermail/cfe-dev/2019-March/061778.html

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

llvm-svn: 356974
2019-03-26 03:48:25 +00:00
Nico Weber f797013015 Attempt to fix sphinx bot after r356897
llvm-svn: 356923
2019-03-25 16:50:24 +00:00
Ilya Biryukov ec5dbf5a7b [clangd] Add .cu files to VSCode extension
Summary:
clangd should be able to handle those with a proper compilation
database. However, users using 'nvcc' might start seeing spurious errors
in '.cu' files after this change.

My plan is to land and release this, but be ready to revert in
case of negative user feedback.

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

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

llvm-svn: 356916
2019-03-25 16:18:56 +00:00
Alexander Kornienko 6291868864 [clang-tidy] ClangTidy.h -> ClangTidyCheck.h
llvm-svn: 356902
2019-03-25 14:46:51 +00:00
Nico Weber 43356f56bd Rename directory housing clang-include-fixer to be eponymous
Makes the name of this directory consistent with the names of the other
directories in clang-tools-extra.

Similar to r356254. No intended behavior change.

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

llvm-svn: 356897
2019-03-25 14:09:10 +00:00
Haojian Wu 3c488d7eb3 [clangd] Add std subnamespace symbols to the symbol map.
Reviewers: ioeric, serge-sans-paille

Reviewed By: ioeric

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

Tags: #clang

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

llvm-svn: 356894
2019-03-25 13:14:10 +00:00
Haojian Wu 9ac2859cf2 [pp-trace] Use ClangTool in pp-trace, NFC
Summary:
This patch partially reverts the commit rL356849.

Unfortunately, tooling::createExecutorFromCommandLineArgs doesn't
corperate well with our internal infrastructure, which leads failing
lit tests. We use ClangTool at the moment, until we find a better
solution to smooth it.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: jdoerfert, cfe-commits

Tags: #clang

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

llvm-svn: 356893
2019-03-25 12:49:46 +00:00
Alexander Kornienko 478fc5c83e [clang-tidy] Switch checks to #include "ClangTidyCheck.h"
llvm-svn: 356892
2019-03-25 12:38:26 +00:00
Alexander Kornienko e9087fe75c [clang-tidy] Separate the check-facing interface
Summary:
Move ClangTidyCheck to a separate header/.cpp
Switch checks to #include "ClangTidyCheck.h"
Mention ClangTidyCheck.h in the docs

Reviewers: hokein, gribozavr, aaron.ballman

Reviewed By: hokein

Subscribers: mgorny, javed.absar, xazax.hun, arphaman, jdoerfert, llvm-commits, cfe-commits

Tags: #clang, #llvm

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

llvm-svn: 356890
2019-03-25 12:36:30 +00:00
Fangrui Song 62590fee89 [pp-trace] Try fixing MSVC C2248 after rCTE356849
llvm-svn: 356887
2019-03-25 11:40:11 +00:00
Ilya Biryukov 49c1071394 [clangd] Send empty diagnostics when a file is closed
Summary:
The LSP clients cannot know clangd will not send diagnostic updates
for closed files, so we send them an empty list of diagnostics to
avoid showing stale diagnostics for closed files in the UI, e.g. in the
"Problems" pane of VSCode.

Fixes PR41217.

Reviewers: hokein

Reviewed By: hokein

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

Tags: #clang

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

llvm-svn: 356880
2019-03-25 10:15:11 +00:00
Haojian Wu a5a4bb69c1 Add llvm:: qualifer to make_unique, NFC
To avoid potential "make_unique is ambiguous" compiler errors.

llvm-svn: 356878
2019-03-25 09:53:19 +00:00
Clement Courbet d8e78022c6 [clang-tidy] Fix more false positives for bugprone-string-integer-assignment
Summary:
And add various tests gleaned for our codebase.

See PR27723.

Reviewers: JonasToth, alexfh, xazax.hun

Subscribers: rnkovacs, jdoerfert, cfe-commits

Tags: #clang

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

llvm-svn: 356871
2019-03-25 08:18:00 +00:00
Fangrui Song 54ce1b18c5 [pp-trace] Delete redundant clang::
And clarify command line options

llvm-svn: 356851
2019-03-24 07:31:21 +00:00
Fangrui Song be860a04b6 [pp-trace] Wrap code in clang::pp_trace
llvm-svn: 356850
2019-03-24 07:21:32 +00:00
Fangrui Song 10f69948fb [pp-trace] Modernize the code
Use InitLLVM and WithColor
Delete PPTraceConsumer, add the callback in PPTraceAction
Migrae to tooling::createExecutorFromCommandLineArgs
Don't specialize empty OutputFileName

llvm-svn: 356849
2019-03-24 06:55:08 +00:00
Roman Lebedev 462446fd9a [clang-tidy] openmp-exception-escape - a new check
Summary:
Finally, we are here!

Analyzes OpenMP Structured Blocks and checks that no exception escapes
out of the Structured Block it was thrown in.

As per the OpenMP specification, structured block is an executable statement,
possibly compound, with a single entry at the top and a single exit at the
bottom. Which means, ``throw`` may not be used to to 'exit' out of the
structured block. If an exception is not caught in the same structured block
it was thrown in, the behaviour is undefined / implementation defined,
the program will likely terminate.

Reviewers: JonasToth, aaron.ballman, baloghadamsoftware, gribozavr

Reviewed By: aaron.ballman, gribozavr

Subscribers: mgorny, xazax.hun, rnkovacs, guansong, jdoerfert, cfe-commits, ABataev

Tags: #clang-tools-extra, #openmp, #clang

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

llvm-svn: 356802
2019-03-22 19:46:25 +00:00
Roman Lebedev cbbf92825f [clang-tidy] openmp-use-default-none - a new check
Summary:
Finds OpenMP directives that are allowed to contain `default` clause,
but either don't specify it, or the clause is specified but with the kind
other than `none`, and suggests to use `default(none)` clause.

Using `default(none)` clause changes the default variable visibility from
being implicitly determined, and thus forces developer to be explicit about the
desired data scoping for each variable.

Reviewers: JonasToth, aaron.ballman, xazax.hun, hokein, gribozavr

Reviewed By: JonasToth, aaron.ballman

Subscribers: jdoerfert, openmp-commits, klimek, sbenza, arphaman, Eugene.Zelenko, ABataev, mgorny, rnkovacs, guansong, cfe-commits

Tags: #clang-tools-extra, #openmp, #clang

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

llvm-svn: 356801
2019-03-22 19:46:12 +00:00
Roman Lebedev 819bedf3a1 [clang-tidy] A new OpenMP module
Summary:
Just the empty skeleton.
Previously reviewed as part of D57113.

Reviewers: JonasToth, aaron.ballman, alexfh, xazax.hun, hokein, gribozavr

Reviewed By: JonasToth, gribozavr

Subscribers: jdoerfert, mgorny, rnkovacs, guansong, arphaman, cfe-commits

Tags: #clang-tools-extra, #openmp, #clang

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

llvm-svn: 356800
2019-03-22 19:46:01 +00:00
Roman Lebedev d5ce57184a [NFC] ExceptionEscapeCheck: small refactoring
Summary:
D59466 wants to analyse the `Stmt`, and `ExceptionEscapeCheck` does not
have that as a possible entry point.
This simplifies addition of `Stmt` analysis entry point.

Reviewers: baloghadamsoftware, JonasToth, gribozavr

Reviewed By: gribozavr

Subscribers: rnkovacs, cfe-commits

Tags: #clang-tools-extra, #clang

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

llvm-svn: 356799
2019-03-22 19:45:51 +00:00
Alexander Kornienko b6c4db9981 [clang-tidy] Move all checks to the new registerPPCallbacks API
llvm-svn: 356796
2019-03-22 18:58:12 +00:00
Alexander Kornienko b719245a94 Fix clang-move test.
llvm-svn: 356795
2019-03-22 18:52:10 +00:00
Alexander Kornienko a0006211e2 [clang-tidy] anyOf(hasName(..), hasName(..)) -> hasAnyName
+ a minor style fix

llvm-svn: 356792
2019-03-22 18:37:45 +00:00
Alexander Kornienko 5e381fb11a [clangd] Call the new ClangTidyCheck::registerPPCallbacks overload
llvm-svn: 356788
2019-03-22 18:16:51 +00:00
Nico Weber 71ebc9eb0b Make clang-move use same file naming convention as other tools
In all the other clang-foo tools, the main library file is called
Foo.cpp and the file in the tool/ folder is called ClangFoo.cpp.
Do this for clang-move too.

No intended behavior change.

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

llvm-svn: 356780
2019-03-22 16:34:39 +00:00
Alexander Kornienko 1ae5c63f35 [clang-tidy] Fix a compiler warning.
Rename the Preprocessor field to fix the

  declaration of ‘std::unique_ptr<clang::Preprocessor> clang::tooling::ExpandModularHeadersPPCallbacks::Preprocessor’ changes the meaning of ‘Preprocessor’ from ‘class clang::Preprocessor’ [-fpermissive]

warning.

llvm-svn: 356756
2019-03-22 15:07:18 +00:00
Alexander Kornienko bbc89dcb29 [clang-tidy] Expand modular headers for PPCallbacks
Summary:
Add a way to expand modular headers for PPCallbacks. Checks can opt-in for this
expansion by overriding the new registerPPCallbacks virtual method and
registering their PPCallbacks in the preprocessor created for this specific
purpose.

Use module expansion in the readability-identifier-naming check

Reviewers: gribozavr, usaxena95, sammccall

Reviewed By: gribozavr

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

Tags: #clang, #clang-tools-extra

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

llvm-svn: 356750
2019-03-22 13:42:48 +00:00
Zinovy Nis 72bb9a65d6 Reland r356547 after fixing the YAML module missing issue.
[clang-tidy] Parallelize clang-tidy-diff.py

This patch has 2 rationales:

- large patches lead to long command lines and often cause max command line length restrictions imposed by OS;
- clang-tidy runs on modified files are independent and can be done in parallel, the same as done for run-clang-tidy.

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

llvm-svn: 356649
2019-03-21 08:32:07 +00:00