Commit Graph

5094 Commits

Author SHA1 Message Date
Daniel Sanders 0cdb04c3cf Make add_new_check.py's insertion of registerCheck<> match the sort order
Summary:
Following on from review comments in D65919 about the ordering
of the registerCheck<> calls. Sort based on the check name which might
be on the line after the registerCheck<>

Reviewers: aaron.ballman

Subscribers: cfe-commits, llvm-commits

Tags: #clang

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

llvm-svn: 370527
2019-08-30 20:47:02 +00:00
Daniel Sanders 5b4f640499 [clang-tidy] Add llvm-prefer-register-over-unsigned to clang-tidy
Summary:
This clang-tidy check is looking for unsigned integer variables whose initializer
starts with an implicit cast from llvm::Register and changes the type of the
variable to llvm::Register (dropping the llvm:: where possible).

Reviewers: arsenm, bogner

Subscribers: jholewinski, MatzeB, qcolombet, dschuff, jyknight, dylanmckay, sdardis, nemanjai, jvesely, wdng, nhaehnle, mgorny, sbc100, jgravelle-google, kristof.beyls, hiraditya, aheejin, kbarton, fedor.sergeev, javed.absar, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, tpr, PkmX, jocewei, jsji, Petar.Avramovic, asbirlea, Jim, s.egerton, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

llvm-svn: 370512
2019-08-30 20:01:59 +00:00
Johan Vikstrom becbdc66dc [clangd] Add highlighting for macro expansions.
Summary: https://github.com/clangd/clangd/issues/134

Reviewers: hokein, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 370482
2019-08-30 15:47:27 +00:00
Johan Vikstrom 268f45bfb8 [clangd] Added highlighting for structured bindings.
Summary: Structured bindings are in a BindingDecl. The decl the declRefExpr points to are the BindingDecls. So this adds an additional if statement in the addToken function to highlight them.

Reviewers: hokein, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 370473
2019-08-30 14:07:05 +00:00
Shaurya Gupta 3b08a61f7e [Clangd] ExtractFunction Added checks for broken control flow
Summary:
- Added checks for broken control flow
- Added unittests

Reviewers: sammccall, kadircet

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

Tags: #clang

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

llvm-svn: 370455
2019-08-30 09:57:56 +00:00
Johan Vikstrom 84b4c4a495 [clangd] Collecting main file macro expansion locations in ParsedAST.
Summary: TokenBuffer does not collect macro expansions inside macro arguments which is needed for semantic higlighting. Therefore collects macro expansions in the main file in a PPCallback when building the ParsedAST instead.

Reviewers: hokein, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 370452
2019-08-30 09:33:27 +00:00
Dmitri Gribenko b22804b354 [Tooling] Migrated APIs that take ownership of objects to unique_ptr
Subscribers: jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 370451
2019-08-30 09:29:34 +00:00
Haojian Wu 0491d13ca5 [clangd] Add .vscode-test to .gitignore.
Reviewers: jvikstrom

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

Tags: #clang

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

llvm-svn: 370446
2019-08-30 09:06:18 +00:00
Nathan Ridge bd0f840f83 [clangd] Add distinct highlightings for static fields and methods
Reviewers: hokein, ilya-biryukov, jvikstrom

Reviewed By: hokein

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

Tags: #clang

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

llvm-svn: 370429
2019-08-30 03:37:24 +00:00
Dmitri Gribenko 907452107d Changed FrontendActionFactory::create to return a std::unique_ptr
Subscribers: jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 370379
2019-08-29 16:38:36 +00:00
Shaurya Gupta 6a801454f1 [Clangd] NFC: Added fixme for checking for local/anonymous types for extracted parameters
llvm-svn: 370372
2019-08-29 15:11:59 +00:00
Haojian Wu 1a28e11892 [clangd] Update out-of-date links in readme, NFC.
llvm-svn: 370371
2019-08-29 14:57:32 +00:00
Kadir Cetinkaya 1c4cd49608 [clangd][NFC] Update background-index command line description
Summary:
We didn't change this in D64019 just in case we revert it back.
Deleting it now.

Reviewers: hokein, sammccall

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

Tags: #clang

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

llvm-svn: 370367
2019-08-29 14:38:02 +00:00
Simon Pilgrim 46b346ea7b Fix MSVC "not all control paths return a value" warning. NFCI.
llvm-svn: 370343
2019-08-29 12:37:02 +00:00
Dmitri Gribenko 349ef2f2f9 [Index] Added a ShouldSkipFunctionBody callback to libIndex, and refactored clients to use it instead of inventing their own solution
Subscribers: jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 370338
2019-08-29 11:47:34 +00:00
Dmitri Gribenko 8d32053f11 [Index] Stopped wrapping FrontendActions in libIndex and its users
Exposed a new function, createIndexingASTConsumer, that creates an
ASTConsumer. ASTConsumers compose well.

Removed wrapping functionality from createIndexingAction.

llvm-svn: 370337
2019-08-29 11:43:05 +00:00
Johan Vikstrom 4683eec2d3 [clangd] Update themeRuleMatcher when color theme changes in vscode extension.
Summary:
Add event listener that listens to configuration changes and reloads the ThemeRuleMatcher when the theme changes.

Right now it will not recolor the files, depends on the colorizer CL for that.

Reviewers: hokein, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 370305
2019-08-29 08:40:17 +00:00
Sam McCall d792204288 Reland "[clangd] Migrate last tweak tests to TweakTesting.h and remove old helpers. NFC"
This reverts commit 3dcf55aa45bad800533b36b70a14ebeb2b84e219, and avoids
use of multiline raw strings in macro calls.

llvm-svn: 370304
2019-08-29 08:20:48 +00:00
Heejin Ahn 660efa596f [clangd] Fix ExtractFunction dependencies
Summary: Without these dependencies, builds with `-DBUILD_SHARED_LIBS=ON` fail.

Reviewers: SureYeaah

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

Tags: #clang

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

llvm-svn: 370273
2019-08-28 23:17:38 +00:00
Sam McCall 7bb847478b Revert "[clangd] Migrate last tweak tests to TweakTesting.h and remove old helpers. NFC"
This reverts commit 8f85685b5c, which
breaks on old gcc that have the macro + raw strings bug.

llvm-svn: 370262
2019-08-28 21:05:49 +00:00
Shaurya Gupta bf4773485e [Clangd] Initial version of ExtractFunction
Summary:
- Only works for extraction from free functions
- Basic analysis of the code being extracted.
- Extract to void function
- Bail out if extracting a return, continue or break.
- Doesn't hoist decls yet

Reviewers: kadircet, sammccall

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

Tags: #clang

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

llvm-svn: 370249
2019-08-28 19:34:17 +00:00
Sam McCall 8f85685b5c [clangd] Migrate last tweak tests to TweakTesting.h and remove old helpers. NFC
llvm-svn: 370229
2019-08-28 16:41:22 +00:00
Haojian Wu 92e09b2f56 [clangd][vscode] Don't leak the resources
Summary: We miss a few places where we need to add them to the subscriptions.

Reviewers: jvikstrom

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

Tags: #clang

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

llvm-svn: 370218
2019-08-28 15:09:04 +00:00
Johan Vikstrom 2dddf3e4ff [clangd] Cleans up the semantic highlighting resources if clangd stops.
Summary: Disposes of the vscode listeners when clangd crashes and reuses the old highlighter when it restarts. The reason for reusing the highlighter is because this way the highlightings will not disappear as we won't have to dispose of them.

Reviewers: hokein, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 370202
2019-08-28 13:46:22 +00:00
Haojian Wu d1a24bab3a [clang-tidy] Fix the potential infinite loop in recordIsTriviallyDefaultConstructible.
Summary:
The recordIsTriviallyDefaultConstructible may cause an infinite loop when
running on an ill-formed decl.

Reviewers: gribozavr

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

Tags: #clang

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

llvm-svn: 370200
2019-08-28 13:45:53 +00:00
Sam McCall 9004c077c0 [clang-tidy] readability-identifier-naming shouldn't complain about CRTP pseudo-overrides
Reviewers: ilya-biryukov

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 370193
2019-08-28 12:08:57 +00:00
Sam McCall ab6594575a [clangd] Fix SelectionTree to allow selection range expression in foreach loops.
Reviewers: hokein

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

Tags: #clang

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

llvm-svn: 370191
2019-08-28 12:05:12 +00:00
Ilya Biryukov d73ac96d80 [clangd] Surface errors from command-line parsing
Summary:
Those errors are exposed at the first character of a file,
for a lack of a better place.

Previously, all errors were stored inside the AST and report
accordingly. However, errors in command-line argument parsing could
result in failure to produce the AST, so we need an alternative ways to
report those errors.

We take the following approach in this patch:
  - buildCompilerInvocation() now requires an explicit DiagnosticConsumer.
  - TUScheduler and TestTU now collect the diagnostics produced when
    parsing command line arguments.
    If pasing of the AST failed, diagnostics are reported via a new
    ParsingCallbacks::onFailedAST method.
    If parsing of the AST succeeded, any errors produced during
    command-line parsing are stored alongside the AST inside the
    ParsedAST instance and reported as previously by calling the
    ParsingCallbacks::onMainAST method;
  - The client code that uses ClangdServer's DiagnosticConsumer
    does not need to change, it will receive new diagnostics in the
    onDiagnosticsReady() callback

Errors produced when parsing command-line arguments are collected using
the same StoreDiags class that is used to collect all other errors. They
are recognized by their location being invalid. IIUC, the location is
invalid as there is no source manager at this point, it is created at a
later stage.

Although technically we might also get diagnostics that mention the
command-line arguments FileID with after the source manager was created
(and they have valid source locations), we choose to not handle those
and they are dropped as not coming from the main file. AFAICT, those
diagnostics should always be notes, therefore it's safe to drop them
without loosing too much information.

Reviewers: kadircet

Reviewed By: kadircet

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

Tags: #clang

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

llvm-svn: 370177
2019-08-28 09:24:55 +00:00
Fangrui Song 180380651c [clang-doc] Use llvm::createStringError and canonicalize error messages
"Bad block found.\n" -> "bad block found"

The lower cased form with no full stop or newline is more common in LLVM
tools.

Reviewed By: juliehockett

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

llvm-svn: 370155
2019-08-28 02:56:03 +00:00
Nathan Ridge 86a4a530f4 [clangd] Add a distinct highlighting for local variables
Summary:
It's useful to be able to distinguish local variables from namespace
scope variables.

Reviewers: hokein, jvikstrom

Reviewed By: hokein

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

Tags: #clang

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

llvm-svn: 370103
2019-08-27 19:39:11 +00:00
Alex Lorenz 559ae14c9b Remove clang-tidy-vs from clang-tools-extra (PR41791)
The clang-tidy-vs visual studio plugin in clang-tools-extra contains a
security vulnerability in the YamlDotNet package [1]. I posted to cfe-dev [2],
asking if there was anyone who was interested in updating the the plugin
to address the vulnerability. Reid mentioned that Zach (the original committer),
said that there's another plugin (Clang Power Tools) that provides clang-tidy support,
with additional extra features, so it would be ok to remove clang-tidy-vs.

This commit removes the plugin to address the security vulnerability, and adds
a section to the release notes that mentions that the plugin was removed, and
suggests to use Clang Power Tools.

Fixes PR 41791.

[1]: https://nvd.nist.gov/vuln/detail/CVE-2018-1000210
[2]: http://lists.llvm.org/pipermail/cfe-dev/2019-August/063196.html

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

llvm-svn: 370096
2019-08-27 18:36:08 +00:00
Alex Lorenz 1c8a4b7204 Use FileEntryRef for PPCallbacks::HasInclude
This fixes the issue where a filename dependendency was missing if the file that
was referenced with __has_include() was accessed through a symlink in an earlier run,
if the file manager was reused between runs.

llvm-svn: 370081
2019-08-27 17:32:42 +00:00
Dmitri Gribenko 3d5f48dc7f Refactor GlobList from an ad-hoc linked list to a vector
Summary: I think it makes method implementations more obvious.

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 370039
2019-08-27 10:56:13 +00:00
Ilya Biryukov 999e4c4793 [Driver] Add an option for createInvocationFromCommandLine to recover on errors
Summary:
Previously, it would always return nullptr on any error.
This change adds a parameter, controlling whether the function should
attempt to return a non-null result even if unknown arguments (or other
errors were encountered).

The new behavior is only used in clangd.

Considered an alternative of changing the return value instead of adding
a new parameter, but that would require updating all callsites. Settled
with the parameter to minimize the code changes.

Reviewers: gribozavr

Reviewed By: gribozavr

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

Tags: #clang

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

llvm-svn: 370033
2019-08-27 10:02:18 +00:00
Sam McCall 37a188b6e8 [clangd] Fix for r370029 test that got left in my client
llvm-svn: 370030
2019-08-27 09:27:00 +00:00
Sam McCall c791d85b12 [clangd] Fix toHalfOpenFileRange where start/end endpoints are in different files due to #include
Summary: https://github.com/clangd/clangd/issues/129

Reviewers: SureYeaah

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

Tags: #clang

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

llvm-svn: 370029
2019-08-27 08:44:06 +00:00
Dmitri Gribenko fd2315ce21 GlobList: added a clear test for pattern priority
Summary:
The last glob that matches the string decides whether that string is
included or excluded.

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 370028
2019-08-27 08:42:42 +00:00
Sam McCall 049bb913e2 Revert "[clangd] Release notes" (wrong branch)
This reverts commit 51029e5c15.

llvm-svn: 370022
2019-08-27 06:58:05 +00:00
Alex Lorenz 6a808d5a83 Fix clangd's IndexAction for FileSkipped API update
llvm-svn: 370004
2019-08-27 01:36:00 +00:00
Alex Lorenz 67d25fede9 Use FileEntryRef for PPCallbacks::FileSkipped
This fixes the issue where a filename dependendency was missing if the file that
was skipped was included through a symlink in an earlier run, if the file
manager was reused between runs.

llvm-svn: 369998
2019-08-27 01:03:25 +00:00
Sam McCall 51029e5c15 [clangd] Release notes
llvm-svn: 369934
2019-08-26 17:47:44 +00:00
Julie Hockett 72e1f7f960 [clang-doc] Switch Generator::CreateResources to use llvm::Error
Differential Revision: https://reviews.llvm.org/D66502

llvm-svn: 369925
2019-08-26 16:39:48 +00:00
Kadir Cetinkaya 3877aa1660 [clangd] Fix docs
llvm-svn: 369920
2019-08-26 16:01:07 +00:00
Dmitri Gribenko a6fed93f0d Moved GlobList into a separate header file
Summary:
It is a separate abstraction that is used in more contexts than just
a helper for ClangTidyDiagnosticConsumer.

Subscribers: mgorny, cfe-commits

Tags: #clang

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

llvm-svn: 369918
2019-08-26 15:44:32 +00:00
Kadir Cetinkaya 3aeed0fd5a [clangd] Add docs for configuration knobs in clangd
Summary:
This is a first step in documenting different configuration knobs we
have in clangd.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 369917
2019-08-26 15:42:16 +00:00
Yitzhak Mandelbaum 0cd4ab91ab [clang-tidy][NFC] Qualify `makeRule` call in test, for consistency with other calls.
One call `makeRule` is unqualified (and unintentionally relying on ADL to
resolve correctly). This revision qualifies that call for consistency and to
drop use of ADL.

llvm-svn: 369915
2019-08-26 15:27:05 +00:00
Yitzhak Mandelbaum 640230cc97 [clang-tidy] TransformerClangTidyCheck: change choice of location for diagnostic message.
Summary:
This patch changes the location specified to the
`ClangTidyCheck::diag()`. Currently, the beginning of the matched range is
used. This patch uses the beginning of the first fix's range.  This change both
simplifies the code and (hopefully) gives a more intuitive result: the reported
location aligns with the fix(es) provided, rather than the (arbitrary) range of
the rule's match.

N.B. this patch will break the line offset numbers in lit tests if the first fix
is not at the beginning of the match.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 369914
2019-08-26 15:17:29 +00:00
Johan Vikstrom 1c9aa70b04 [clangd] Handling text editor/document lifetimes in vscode extension.
Summary:
Just reapplies highlightings for all files when visible text editors change. Could find the correct text editor that should be reapplied but going for a simple implementation instead.
Removes the associated highlighting entry from the Colorizer when a text document is closed.

Reviewers: hokein, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 369911
2019-08-26 13:56:45 +00:00
Johan Vikstrom 3b6d7040cf [clangd] Added a colorizer to the vscode extension.
Summary:
Adds the main colorizer component. It colorizes every time clangd sends a publishSemanticHighlighting notification.
Every time it colorizes it does a full recolorization (removes all decorations from the editor and applies new ones). The reason for this is that all ranges for the same scope share a TextEditorDecorationType. This is due to TextEditorDecorationTypes being very expensive to create. The prototype used one DecorationType per range but that ran into very big performance problems (it took >100 ms to apply 600 lines of highlightings which froze the editor).

This version does not share the problem of being extremly slow, but there is probably potential to optimize it even more.

No document/texteditor lifecycle management code in this CL, that will come in the next one.

Reviewers: hokein, ilya-biryukov

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

Tags: #clang

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

llvm-svn: 369893
2019-08-26 11:36:11 +00:00
Haojian Wu 0a6000f2cb [clangd] Send highlighting diff beyond the end of the file.
Summary: This would make the client life (tracking the changes) easier.

Reviewers: jvikstrom

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

Tags: #clang

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

llvm-svn: 369884
2019-08-26 08:38:45 +00:00