Commit Graph

4786 Commits

Author SHA1 Message Date
Julie Hockett d900ef0a5b [clang-doc] Handle anonymous namespaces
Improves output for anonymous decls, and updates the '--public' flag to exclude everything under an anonymous namespace.

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

llvm-svn: 364674
2019-06-28 19:07:56 +00:00
Julie Hockett 93a290fdc9 [clang-doc] De-duplicate comments and locations
De-duplicate comments and declaration locations in reduce function.
When two files include the same header file, this file's content is mapped
twice causing comments and locations to be duplicated after the reduce stage.

Committed on behalf of Diego Astiazarán (diegoaat97@gmail.com).

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

llvm-svn: 364670
2019-06-28 18:17:58 +00:00
Julie Hockett 021d2f2093 Update CODE_OWNERS.txt for clang-doc
Differential Revision: https://reviews.llvm.org/D63734

llvm-svn: 364663
2019-06-28 17:32:26 +00:00
Johan Vikstrom 6b8a2515ba [clangd] Emit semantic highlighting tokens when the main AST is built.
Differential Revision: https://reviews.llvm.org/D63821

llvm-svn: 364551
2019-06-27 15:13:03 +00:00
Haojian Wu 93a825c8fb [clangd] Fix a case where we fail to detect a header-declared symbol in rename.
Summary:
Failing case:

```
 #include "foo.h"
 void fo^o() {}
```

getRenameDecl() returns the decl of the symbol under the cursor (which is
in the current main file), instead, we use the canonical decl to determine
whether a symbol is declared in #included header.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 364537
2019-06-27 13:24:10 +00:00
Mikael Holmen 79dc930c13 [clang-tidy] Fix NDEBUG build [NFC]
llvm-svn: 364535
2019-06-27 12:47:57 +00:00
Haojian Wu cbab10099d [clangd] No need to setTraversalScope in SemanticHighlighting.
Summary:
We have already set it when the AST is being built, and setting TraversalScope
is not free (it will clear the cache, which is expensive to build).

Reviewers: jvikstrom

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

Tags: #clang

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

llvm-svn: 364528
2019-06-27 12:22:18 +00:00
Sam McCall 5cd77f98a1 [clangd] Address limitations in SelectionTree:
Summary:
 - nodes can have special-cased hit ranges including "holes" (FunctionTypeLoc in void foo())
 - token conflicts between siblings (int a,b;) are resolved in favor of left sibling
 - parent/child overlap is handled statefully rather than explicitly by comparing parent/child
   ranges (this lets us share a mechanism with sibling conflicts)

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 364519
2019-06-27 11:17:13 +00:00
JF Bastien 0e82895826 BitStream reader: propagate errors
The bitstream reader handles errors poorly. This has two effects:

 * Bugs in file handling (especially modules) manifest as an "unexpected end of
   file" crash
 * Users of clang as a library end up aborting because the code unconditionally
   calls `report_fatal_error`

The bitstream reader should be more resilient and return Expected / Error as
soon as an error is encountered, not way late like it does now. This patch
starts doing so and adopting the error handling where I think it makes sense.
There's plenty more to do: this patch propagates errors to be minimally useful,
and follow-ups will propagate them further and improve diagnostics.

https://bugs.llvm.org/show_bug.cgi?id=42311
<rdar://problem/33159405>

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

llvm-svn: 364464
2019-06-26 19:50:12 +00:00
Yitzhak Mandelbaum 039af0ea03 [clang-tidy] Generalize TransformerClangTidyCheck to take a rule generator.
Summary: Tidy check behavior often depends on language and/or clang-tidy options. This revision allows a user of TranformerClangTidyCheck to pass rule _generator_ in place of a rule, where the generator takes both the language and clang-tidy options. Additionally, the generator returns an `Optional` to allow for the case where the check is deemed irrelevant/disable based on those options.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 364442
2019-06-26 16:04:38 +00:00
Yitzhak Mandelbaum 83b1580e1b [clang-tidy] Fix ClangTidyTest to initialize context before checks.
Summary:
Currently, `clang::tidy::test::runCheckOnCode()` constructs the check
instances *before* initializing the ClangTidyContext. This ordering causes
problems when the check's constructor accesses the context, for example, through
`getLangOpts()`.

This revision moves the construction to after the context initialization, which
follows the pattern used in the clang tidy tool itself.

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 364435
2019-06-26 15:04:33 +00:00
Johan Vikstrom 09bc665766 [clangd] Added functionality for getting semantic highlights for variable and function declarations
llvm-svn: 364421
2019-06-26 13:08:36 +00:00
Kadir Cetinkaya eb6e16ce63 [clangd] Disable failing unittest on non-x86 platforms
llvm-svn: 364413
2019-06-26 11:52:20 +00:00
Haojian Wu 442a120567 [clangd] Don't rename the namespace.
Summary:
Also fix a small bug -- the extra argument "-xc++" doesn't overwrite the
language if the argument is present after the file name in the compiler
command.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 364392
2019-06-26 08:10:26 +00:00
Kadir Cetinkaya 8bfe0fc1d9 [clangd] Add Value field to HoverInfo
Summary:
Put a symbols value information which is deduced from initializer
expression into HoverInfo struct.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 364390
2019-06-26 08:00:24 +00:00
Kadir Cetinkaya 256247cfb7 [clangd] Enable extraction of system includes from custom toolchains
Summary:
Some custom toolchains come with their own header files and compiler
drivers. Those compiler drivers implicitly know about include search path for
those headers. This patch aims to extract that information from drivers and add
it to the command line when invoking clang frontend.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 364389
2019-06-26 07:45:27 +00:00
Kadir Cetinkaya 84f7377dd9 [clangd] Link and initialize target infos
llvm-svn: 364387
2019-06-26 07:39:14 +00:00
Nikolai Kosjar 181f252d53 [clang-tidy] Update documentation for Qt Creator integration.
Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 364315
2019-06-25 13:50:09 +00:00
Sam McCall 79f7831aa7 [clangd] Fix NestedNameSpecifierLoc in SelectionTree
Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 364284
2019-06-25 09:36:09 +00:00
Haojian Wu 7276a446ce [clangd] Narrow rename to local symbols.
Summary:
Previously, we performed rename for all kinds of symbols (local, global).

This patch narrows the scope by only renaming symbols not being used
outside of the main file (with index asisitance). Renaming global
symbols is not supported at the moment (return an error).

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 364283
2019-06-25 08:43:17 +00:00
Haojian Wu 92c3257477 [clangd] Cleanup the duplicated getTokenRange.
Summary:
Also lift it to SourceCode.h, so that it can be used in other places
(semantic code highlighting).

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 364280
2019-06-25 08:01:46 +00:00
Julie Hockett b1f01e27ec [clang-doc] Add basic support for templates and typedef
In serialize::parseBases(...), when a base record is a template
specialization, the specialization was used as the parent. It should be
the base template so there is only one file generated for this record.
When the specialized template is implicitly declared the reference USR
corresponded to the GlobalNamespace's USR, this will now be the base
template's USR.

More information about templates will be added later.

In serialize::emiInfo(RecorDecl*, ...), typedef records were not handled
and the name was empty. This is now handled and a IsTypeDef attribute is
added to RecordInfo struct.

In serialize::emitInfo(CXXMethodDecl*, ...), template specialization is
handled like in serialize::parseBases(...).

Bitcode writer and reader are modified to handle the new attribute of
RecordInfo.

Submitted on behalf of Diego Astiazarán (diegoaat97@gmail.com)
Differential Revision: https://reviews.llvm.org/D63367

llvm-svn: 364222
2019-06-24 19:31:02 +00:00
Sam McCall ca89eb5f9c [clangd] Improve SelectionTree string representation
llvm-svn: 364180
2019-06-24 13:01:28 +00:00
Douglas Yung c900c46d77 [NFC] Marking test added in r363975 as unsupported on Windows.
This test references a path that does not exist on Windows causing
it to emit different output from what was expected leading to a
failure when run on Windows.

llvm-svn: 364120
2019-06-22 01:09:00 +00:00
Matthias Gehre eeb3f99d23 [clang-tidy] misc-unused-parameters: don't comment out parameter name for C code
Summary: The fixit `int square(int /*num*/)` yields `error: parameter name omitted` for C code. Enable it only for C++ code.

Reviewers: klimek, ilya-biryukov, lebedev.ri, aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 364106
2019-06-21 21:30:25 +00:00
Reid Kleckner b250a62a51 Quote path to Python executable in case it has spaces
These days Python 3 is typically installed into C:/Program Files, so
cope with that.

Similar to r364077 in compiler-rt.

llvm-svn: 364087
2019-06-21 18:17:04 +00:00
Haojian Wu 34f5188d0f [clangd] Add include-mapping for C symbols.
Summary:
This resolves the issue of introducing c++-style includes for C files.

- refactor the gen_std.py, make it reusable for parsing C symbols.
- add a language mode to the mapping method to use different mapping for
  C and C++ files.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 364044
2019-06-21 13:32:18 +00:00
Haojian Wu 38a2f50070 [clang-tidy] Fix a typo in the doc.
llvm-svn: 364010
2019-06-21 07:58:19 +00:00
Kadir Cetinkaya b9b1aaf07d [clang-tidy] Move test files of rL363975 into Inputs directory
llvm-svn: 364008
2019-06-21 07:54:27 +00:00
Serge Guelton 60ca31a7dd [clang-tidy] Fail gracefully upon empty database fields
Fix bz#42281

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

llvm-svn: 363975
2019-06-20 20:25:59 +00:00
Nathan Ridge 8df5f444a2 [clangd] Include the diagnostics's code when comparing diagnostics
Summary: This fixes https://github.com/clangd/clangd/issues/60

Reviewers: kadircet

Reviewed By: kadircet

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

Tags: #clang

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

llvm-svn: 363889
2019-06-19 23:11:02 +00:00
Ilya Biryukov 482269b9fa [clangd] Consume error returned by cleanupAndFormat
When called by ClangdServer::applyTweak.
No idea how to actually trigger this in practice, so no tests.

llvm-svn: 363844
2019-06-19 17:30:02 +00:00
Ilya Biryukov a7acc7e855 [clangd] Format changes produced by rename
Reviewers: hokein, kadircet, sammccall

Reviewed By: kadircet

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 363843
2019-06-19 17:25:24 +00:00
Ilya Biryukov d0aa6c58be [clangd] Collect tokens of main files when building the AST
Summary:
The first use of this is a code tweak to expand macro calls.
Will later be used to build syntax trees.

The memory overhead is small as we only store tokens of the main file.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

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

llvm-svn: 363803
2019-06-19 14:03:19 +00:00
Haojian Wu 982a1cf028 [clangd] Correct the MessageType enum values.
llvm-svn: 363798
2019-06-19 13:14:59 +00:00
Sam McCall 08372eb73b Revert "[clangd] Return vector<TextEdit> from applyTweak. NFC"
This reverts commit r363691.

llvm-svn: 363766
2019-06-19 07:29:10 +00:00
Sam McCall 38047dbca4 [clangd] Add ClangdServer accessor for buffer contents
llvm-svn: 363765
2019-06-19 07:29:05 +00:00
Douglas Yung c4d5c37285 [TEST] Fix test on Windows by looking for substrings rather than a regex
since the escaping of special characters appears to break on Windows.

llvm-svn: 363761
2019-06-19 03:02:33 +00:00
Aaron Puchert 44940048dd Fix more tests after r363749
Apparently -Wmissing-prototypes is used for quite a few integration
tests.

llvm-svn: 363760
2019-06-19 01:54:05 +00:00
Julie Hockett d9b3d08a9a [clang-tidy] Split fuchsia-default-arguments
Splits fuchsia-default-arguments check into two checks. fuchsia-default-arguments-calls warns if a function or method is called with default arguments. fuchsia-default-arguments-declarations warns if a function or method is declared with default parameters.

Committed on behalf of @diegoast (Diego Astiazarán).

Resolves b38051.

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

llvm-svn: 363712
2019-06-18 18:07:33 +00:00
Ilya Biryukov df9ee08b64 [clangd] Return vector<TextEdit> from applyTweak. NFC
For the same reasons as r363150, which got overwritten by changes in
r363680.

Sending without review to unbreak our integrate.

llvm-svn: 363691
2019-06-18 15:15:41 +00:00
Haojian Wu 9483bcf781 [clangd] Remove the extra ";", NFC
llvm-svn: 363681
2019-06-18 13:52:00 +00:00
Sam McCall 395fde753c [clangd] Add hidden tweaks to dump AST/selection.
Summary:
This introduces a few new concepts:
 - tweaks have an Intent (they don't all advertise as refactorings)
 - tweaks may produce messages (for ShowMessage notification). Generalized
   Replacements -> Effect.
 - tweaks (and other features) may be hidden (clangd -hidden-features flag).
   We may choose to promote these one day. I'm not sure they're worth their own
   feature flags though.

Verified it in vim-clangd (not yet open source), curious if the UI is ok in VSCode.

Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 363680
2019-06-18 13:37:54 +00:00
Sam McCall 8d41294c18 [clangd] Add a capability to enable completions with fixes.
Reviewers: ilya-biryukov

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

Tags: #clang

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

llvm-svn: 363664
2019-06-18 11:57:26 +00:00
Haojian Wu 8ddf31bc33 [clangd] Parse files without extensions if we don't have a compile command.
Summary: This would enable clangd for C++ standard library files.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 363663
2019-06-18 11:54:17 +00:00
Haojian Wu 40fdd7a643 [clangd] Detect C++ language based on well-known file path in vscode extension
Summary:
Matching the "C++" pattern on the first line of the file doesn't cover
all cases, MSVC C++ headers doesn't have such pattern. This patch
introduce a new heuristic to detect language based on the file path.

MSVC C++ standard headers are in the directory like
"c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\include"

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 363662
2019-06-18 11:53:14 +00:00
Haojian Wu b5ce4e5ea3 [clangd] Perform merge for main file symbols.
Summary:
Previously, we randomly pick one main file symbol in dynamic index, we
may loose the ideal symbol (with definition location) in the index.

It fixes the issue where sometimes we fail to go to the symbol definition, see:

1. call go-to-decl on Foo in Foo.cpp
2. jump to Foo.h, call go-to-def on Foo in Foo.h

we can't go back to Foo.cpp -- because we open Foo.cpp, Foo.h in clangd, both
files have Foo symbol (one with def&decl, one with decl only), we randomely
choose one.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 363568
2019-06-17 14:49:18 +00:00
Haojian Wu 7dc917603b [clangd] Bump vscode-clangd v0.0.15.
CHANGELOG:
- support detecting C++ language from first line (`-*- C++ -*-`) of the file.

llvm-svn: 363555
2019-06-17 13:18:24 +00:00
Haojian Wu d53027697c [clangd] Detect C++ for extension-less source files in vscode extension
Summary:
Extend our extension to support detecting these files as C++ files based on the first
line (`-*- C++ -*-`), it will make clangd work on C++ standard headers
(e.g. iostream).

We use the contributes.languages[1] to enrich the builtin VScode C++
support.

[1]: https://code.visualstudio.com/api/references/contribution-points#contributes.languages

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 363554
2019-06-17 12:59:14 +00:00
Don Hinton 9d8c94dfd7 [docs] Fix another bot warning by adding a blank line to separate the `option::` command from the text below.
llvm-svn: 363520
2019-06-16 18:41:31 +00:00