summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Loading TokenColorRules as a class mapping the rules to their ↵Johan Vikstrom2019-08-142-3/+67
| | | | | | | | | | | | | | | | associated clangd TextMate scope index. Summary: Loads a mapping of the clangd scope lookup table scopes to the most specific rule with the highest "precedence" on initialize. Preprocesses into a class so it's simple/fast to access when doing the actual coloring later. Reviewers: hokein, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65856 llvm-svn: 368834
* [clangd] Fix typos and grammar in a comment. NFCIlya Biryukov2019-08-141-4/+4
| | | | llvm-svn: 368824
* [clang-tidy] Update `TransformerClangTidyCheck` to use new `buildMatchers` ↵Yitzhak Mandelbaum2019-08-131-1/+2
| | | | | | | | | | | | | | | | | | functionality. Summary: `buildMatchers` is the new, more general way to extract the matcher from a rule. This change migrates the code to use it instead of `buildMatcher`. Reviewers: gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65879 llvm-svn: 368700
* [clang-doc] Generate HTML links for children namespaces/recordsDiego Astiazaran2019-08-128-63/+117
| | | | | | | | | | | | | | | | Path is now stored in the references to the child while serializing, then this path is used to generate the relative path in the HTML generator. Now some references have paths and some don't so in the reducing phase, references are now properly merged checking for empty attributes. Tests added for HTML and YAML generators, merging and serializing. computeRelativePath function had a bug when the filepath is part of the given directory; it returned a path that starts with a separator. This has been fixed. Differential Revision: https://reviews.llvm.org/D65987 llvm-svn: 368602
* [clangd] Refactor computation of extracted expr in ExtractVariable tweak. NFCSam McCall2019-08-121-61/+66
| | | | | | | | | | | | | | | | | | | | | | | Summary: This takes this logic out of the Tweak class, and simplifies the signature of the function where the main logic is. The goal is to make it easier to turn into a loop like: for (current = N; current and current->parent are both expr; current = current->parent) if (suitable(current)) return current; return null; Reviewers: SureYeaah Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65333 llvm-svn: 368590
* [clangd] Separate chunks with a space when rendering markdownIlya Biryukov2019-08-122-4/+45
| | | | | | | | | | | | | | | | | | | | | Summary: This results in better rendering of resulting markdown. Especially noticeable in coc.nvim that does not have a visible horizontal spaces around inline code blocks. More details and a screenshot from coc.nvim can be found in https://github.com/clangd/clangd/issues/95. Reviewers: sammccall Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66086 llvm-svn: 368581
* [clangd] Added the vscode SemanticHighlighting feature code but did not ↵Johan Vikstrom2019-08-123-5/+115
| | | | | | | | | | | | | | | | enable it in the client. Summary: Added the code for the StaticFeature that must be registered to the client. Also decoding the notification data into objects. Did not register it to the client yet. Reviewers: hokein, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65998 llvm-svn: 368568
* [clangd] Remove highlightings coming from non topLevelDecls from included files.Johan Vikstrom2019-08-122-2/+25
| | | | | | | | | | | | | | Summary: It is possible to write include code from other files so that the decls from there do not become topLevelDecls (For example by including methods for a class). These Decls are not filtered by topLevelDecls and therefore SemanticHighlighting must manually check that every SLoc belongs in the main file. Otherwise there can be highlightings appearing in places where they should not. Reviewers: hokein, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66083 llvm-svn: 368563
* [clangd] Drop diags from non-written #include.Haojian Wu2019-08-122-2/+15
| | | | | | | | | | | | | | Summary: This would fix that we show weird diagnostics on random lines of the main file. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66074 llvm-svn: 368549
* [clangd] Highlighting auto variables as the deduced type.Johan Vikstrom2019-08-122-16/+40
| | | | | | | | | | | | | | | | | | Summary: Done in VisitDeclaratorDecl as the AutoTypeLoc is not deduced. Scoped to only work for variables. auto function return values need to be handled in a special way (separate patch for that). auto's that are in lambdas ar enot highlighted as we don't highlight their underlying type (it's a RecordDecl, but the name is not an identifier so it returns in addToken). Reviewers: hokein, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65996 llvm-svn: 368546
* [clangd] Disallow extraction of expression-statements.Sam McCall2019-08-095-54/+97
| | | | | | | | | | | | | | | | | | | | | Summary: I split out the "extract parent instead of this" logic from the "this isn't worth extracting" logic (now in eligibleForExtraction()), because I found it hard to reason about. While here, handle overloaded as well as builtin assignment operators. Also this uncovered a bug in getCallExpr() which I fixed. Reviewers: SureYeaah Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65337 llvm-svn: 368500
* clangd: use -j for background index poolSam McCall2019-08-093-9/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: clangd supports a -j option to limit the amount of threads to use for parsing TUs. However, when using -background-index (the default in later versions of clangd), the parallelism used by clangd defaults to the hardware_parallelisn, i.e. number of physical cores. On shared hardware environments, with large projects, this can significantly affect performance with no way to tune it down. This change makes the -j parameter apply equally to parsing and background index. It's not perfect, because the total number of threads is 2x the -j value, which may still be unexpected. But at least this change allows users to prevent clangd using all CPU cores. Reviewers: kadircet, sammccall Reviewed By: sammccall Subscribers: javed.absar, jfb, sammccall, ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66031 llvm-svn: 368498
* [clang-doc] Generate an HTML index fileDiego Astiazaran2019-08-091-1/+19
| | | | | | | | | clang-doc now generates a file that contains only an index to all the infos that can be used as the landing page for the generated website. Differential Revision: https://reviews.llvm.org/D65918 llvm-svn: 368484
* [clangd] Give absolute path to clang-tidy and include-fixer. HintPath should ↵Sam McCall2019-08-091-5/+6
| | | | | | always be absolute, some URI schemes care. llvm-svn: 368482
* [clang-format] Add link to source code in file definitionsDiego Astiazaran2019-08-0913-101/+238
| | | | | | | | | | | | | Two command line options have been added to clang-doc. --repository=<string> - URL of repository that hosts code; used for links to definition locations. --source-root=<string> - Directory where processed files are stored. Links to definition locations will only be generated if the file is in this dir. If the file is in the source-root and a repository options is passed; a link to the source code will be rendered by the HTML generator. Differential Revision: https://reviews.llvm.org/D65483 llvm-svn: 368460
* [clangd] Added highlighting for constructor initializers.Johan Vikstrom2019-08-092-0/+26
| | | | | | | | | | | | | | Summary: Constructor initializers were not being highlighted. This adds highlighting for them by using TraverseConstructorInitializer. Uses the Traverse* because there is no visit for CXXCtorInitializer. Reviewers: hokein, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66001 llvm-svn: 368434
* [clangd] Use raw rename functions to implement the rename.Haojian Wu2019-08-092-62/+47
| | | | | | | | | | | | | | | | | | | | | | | Summary: The API provided by refactoring lib doesn't provide enough flexibility to get clangd's rename to behave as we expect. Instead, we replace it with the low-level rename functions, which give us more control. Bonus: - performance, previously we visit the TU to find all occurrences, now we just visit top-level decls from main file; - fix a bug where we wrongly filter out the main file replacement due to the different relative/absolute file path; Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, jfb, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65936 llvm-svn: 368429
* [clangd] Fixed printTemplateSpecializationArgs not printing partial variable ↵Johan Vikstrom2019-08-093-1/+14
| | | | | | | | | | | | | | | | | | specialization arguments. Summary: printTemplateSpecializationArgs was not printing partial variable specialization args. This adds an additional If clause where we check if it's a VariableTemplatePartialSpecializationDecl and returns the ArgumentLocs if that's the case. Also adds tests for printTemplateSpecializationArgs in ASTTests.cpp. Reviewers: hokein, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65926 llvm-svn: 368403
* [AST] No longer visiting CXXMethodDecl bodies created by compiler when ↵Johan Vikstrom2019-08-091-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | method was default created. Summary: Clang generates function bodies and puts them in the AST for default methods if it is defaulted outside the class definition. ` struct A { A &operator=(A &&O); }; A &A::operator=(A &&O) = default; ` This will generate a function body for the `A &A::operator=(A &&O)` and put it in the AST. This body should not be visited if implicit code is not visited as it is implicit. This was causing SemanticHighlighting in clangd to generate duplicate tokens and putting them in weird places. Reviewers: hokein, ilya-biryukov, gribozavr Subscribers: mgorny, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65938 llvm-svn: 368402
* [clang-doc] Protect Index with mutex during reducing and generation stageDiego Astiazaran2019-08-081-0/+4
| | | | | | | | | | Idx in ClangDocContext instance was being modified by multiple threads causing a seg fault. A mutex is added to avoid this. Differential Revision: https://reviews.llvm.org/D65915 llvm-svn: 368313
* [clangd] Added semantic highlighting support for primitives.Johan Vikstrom2019-08-085-37/+51
| | | | | | | | | | | | | | | | Summary: Adds a new HighlightingKind "Primitive". Adds a special case for TypeLocs that have an underlying TypePtr that is are builtin types, adding them as primitives. The primary reason for this change is because otherwise typedefs that typedef primitives `typedef int A` would not get highlighted (so in the example `A` would not get any highlightings.) Reviewers: hokein, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65943 llvm-svn: 368291
* [clangd] Added an early return from VisitMemberExpr in SemanticHighlighting ↵Johan Vikstrom2019-08-082-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | if underlying MemberDecl is a CXXConversionDecl. Summary: Conversion operators contain invalid MemberLocs which caused SemanticHighlighting to emit a lot of error logs in large files as they can occur fairly often (for example converting StringRef to std string). As the only thing happening was a lot of error logs being emited there doesn't really seem to be any way to test this (no erroneous tokens are added). But emiting as many logs as were being emited is not wanted. This also adds a test to guard against regressions for highlightings disapearing from places where the conversion operators are used as their behaviour differ from the other CXXMethodDecls. Reviewers: hokein, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65928 llvm-svn: 368287
* [clangd] Don't include internal gtest header.Haojian Wu2019-08-081-1/+0
| | | | llvm-svn: 368283
* [clangd] Remove a function accidently being added in rL368261.Haojian Wu2019-08-081-20/+0
| | | | llvm-svn: 368282
* [clangd] Correct the documentation, NFC.Haojian Wu2019-08-081-1/+1
| | | | llvm-svn: 368277
* [clangd] Fix implicit template instatiations appearing as topLevelDecls.Johan Vikstrom2019-08-086-13/+163
| | | | | | | | | | | | | | Summary: The parser gives implicit template instantiations to the action's HandleTopLevelDecls callback. This makes semantic highlighting highlight these templated functions multiple times. Fixed by filtering on if a Decl is an implicit function/variable/class instantiation. Also added a testcase to semantic highlighting on this. Reviewers: hokein, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65510 llvm-svn: 368261
* [clang-doc] Add second index for sections within info's contentDiego Astiazaran2019-08-073-27/+179
| | | | | | | | | | | | This new index contains links to the main section of infos: Namespaces, Records, Functions, Enums, Members. Also to each child function or enum. Index is currently rendered on top of the info content, this will be fixed later with CSS. Depends on D65690. Differential Revision: https://reviews.llvm.org/D65030 llvm-svn: 368209
* [clang-doc] Parallelize reducing phaseDiego Astiazaran2019-08-071-52/+63
| | | | | | | | | | | Reduce phase has been parallelized and a execution time was reduced by 60% with this. The reading of bitcode (bitcode -> Info) was moved to this segment of code parallelized so it now happens just before reducing. Differential Revision: https://reviews.llvm.org/D65628 llvm-svn: 368206
* Code completion should not ignore default parameters in functions.Sam McCall2019-08-073-0/+61
| | | | | | | | | | | | | | | | | | | | Summary: Inorder to display the default arguments we must process the CK_Optional chunks of CodeCompletionString while creating the Signature. We do not create placeholders for default arguments. Reviewers: sammccall Reviewed By: sammccall Subscribers: jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65866 llvm-svn: 368186
* [clangd] Added a TextMate theme parser to the vscode extension.Johan Vikstrom2019-08-075-1/+167
| | | | | | | | | | | | | | | Summary: Adds a TextMate parser module to the vscode extension. It parses a theme into an array of a pair of TextMate scopes and text colors. Reviewers: hokein, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65738 llvm-svn: 368136
* [clang-doc] Fix paths of js in import tagsDiego Astiazaran2019-08-061-0/+2
| | | | | | | | HTML requires posix-style paths. Differential Revision: https://reviews.llvm.org/D65827 llvm-svn: 368087
* [clangd] Unfold SourceLocation flattening from findNameLoc in preparation ↵Sam McCall2019-08-067-33/+48
| | | | | | for adding more overloads. NFC llvm-svn: 368083
* [clang-doc] Add index in each info html fileDiego Astiazaran2019-08-0616-59/+431
| | | | | | | | | | | | An index structure is created while generating the output file for each info. This structure is parsed to JSON and written to a file in the output directory. The html for the index is not rendered by clang-doc. A Javascript file is included in the output directory, this will the JSON file and insert HTML elements into the file. Differential Revision: https://reviews.llvm.org/D65690 llvm-svn: 368070
* Fixed toHalfOpenFileRange assertion failShaurya Gupta2019-08-062-12/+61
| | | | | | | | | | | | | | Summary: - Added new function that gets Expansion range with both ends in the same file. - Fixes the crash at https://github.com/clangd/clangd/issues/113 Subscribers: ilya-biryukov, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65754 llvm-svn: 368058
* [clangd] Compute scopes eagerly in IncludeFixerIlya Biryukov2019-08-063-37/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Computing lazily leads to crashes. In particular, computing scopes may produce diagnostics (from inside template instantiations) and we currently do it when processing another diagnostic, which leads to crashes. Moreover, we remember and access 'Scope*' when computing scopes. This might lead to invalid memory access if the Scope is deleted by the time we run the delayed computation. We did not actually construct an example when this happens, though. From the VCS and review history, it seems the optimization was introduced in the initial version without a mention of any performance benchmarks justifying the performance gains. This led me to a conclusion that the optimization was premature, so removing it to avoid crashes seems like the right trade-off at that point. Reviewers: sammccall Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65796 llvm-svn: 368019
* [clang-doc] Fix link generationDiego Astiazaran2019-08-067-8/+26
| | | | | | | | | | | | | | | | | | | Before making a link to a reference it is required to check that the reference has a path (eg. primitives won't have paths). This was done by checking if the path was empty; that worked because when generating paths the outdirectory was included, so if the path was assigned it had that outdirectory at least. The path generation was changed, it's now only the composite of the namespaces without the outdirectory. So if the info is in the global namespace the path would be empty and the old check wouldn't work as expected. A new attribute has been added to the Reference struct that indicates if the info's parent is the global namespace. Paths generation now fails if the path is empty and if the info is not in the global namespace. Differential Revision: https://reviews.llvm.org/D64958 llvm-svn: 367958
* [clangd] Add a callback mechanism for handling responses from client.Haojian Wu2019-08-056-29/+201
| | | | | | | | | | | | | | | | | | | Summary: The callback will be invoked in clangd when we receive a reply from the client. This is a prerequisite of implementing a generic mechanism for chainable refactorings (e.g. extract variable and rename), this would allow server to trigger a new request to the LSP client after receiving a reply from the client. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65387 llvm-svn: 367845
* [clangd] Expose -offset-encoding=utf-32, which has been implemented for agesSam McCall2019-08-051-1/+3
| | | | llvm-svn: 367812
* [clangd] Fix error message with incorrect ↵Sam McCall2019-08-051-1/+1
| | | | | | TextDocumentcontentChangeEvent.rangeLength llvm-svn: 367811
* Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFCFangrui Song2019-08-058-8/+9
| | | | | | F_{None,Text,Append} are kept for compatibility since r334221. llvm-svn: 367800
* [clang-tidy] Add FixItHint for performance-noexcept-move-constructorZinovy Nis2019-08-042-2/+81
| | | | | | Differential Revision: https://reviews.llvm.org/D65104 llvm-svn: 367785
* [clang-doc] Update documentationDiego Astiazaran2019-08-032-11/+41
| | | | | | | | | HTML generator has been included in clang-tools-extra release notes. clang-doc documentation file has been updated. Differential Revision: https://reviews.llvm.org/D65622 llvm-svn: 367743
* [clang-doc] Add flag to continue after mapping errorsDiego Astiazaran2019-08-021-2/+13
| | | | | | | | | | The tool used to stop execution if there was an error in the mapping phase. It will now show the error but continue with the files that were mapped correctly if the flag is true. Differential revision: https://reviews.llvm.org/D65627 llvm-svn: 367729
* [clang-tidy] Adding static analyzer check to list of clang-tidy checksNathan Huckleberry2019-08-0286-0/+993
| | | | | | | | | | | | | | | | | | | Summary: Since clang-tidy supports use of the static analyzer there should be documentation of how to invoke the static analyzer checks. Reviewers: JonasToth, aaron.ballman, NoQ, Szelethus Reviewed By: aaron.ballman Subscribers: nickdesaulniers, lebedev.ri, jfb, NoQ, Eugene.Zelenko, xazax.hun, baloghadamsoftware, a.sidorin, Szelethus, donat.nagy, dkrupp, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64454 llvm-svn: 367694
* [clangd] Fix a crash when presenting values for HoverIlya Biryukov2019-08-022-1/+11
| | | | | | | | | | | | | | | | | | | Summary: We should pass the expression type, not a variable type when printing the resulting value. Variable type may be different from what the pretty-printing function expects, e.g. have references. Reviewers: sammccall Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65655 llvm-svn: 367687
* [clangd][vscode] clang-format the the extension code.Haojian Wu2019-08-025-99/+105
| | | | | | | | | | | | | | | | | | | | | Summary: As we are going to grow the extension in the near future, it is time to formalize the TS code format/style of our extension (although we'd lose the history). We use default options of clang-format: - 80 max line length - 2 space indent Reviewers: ilya-biryukov, sammccall, jvikstrom Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65657 llvm-svn: 367684
* Fix "not all control paths return a value" warning. NFCI.Simon Pilgrim2019-08-021-0/+1
| | | | llvm-svn: 367678
* [clangd] Remove bad assert: nothing relies on it, and the reasons it was ↵Sam McCall2019-08-021-3/+2
| | | | | | true no longer hold. llvm-svn: 367672
* [clangd] Add new helpers to make tweak tests scale better. Convert most ↵Sam McCall2019-08-024-365/+366
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tests. NFC Summary: TweakTests.cpp has some pretty good helpers added for the first few tweaks, but they have some limitations: - many assertion failures point at the wrong line - need lots of input/output tests, setup code is duplicated across both - local helpers make it hard to split the file as it grows The new helpers in TweakTests.h are based on old ones (same operations) but try to address these issues and generally make tests more terse while improving error messages. This patch converts everything except ExtractVariable (which is complex and has changes in flight, so will be converted later). It's LOC-neutral, despite not being able to get rid of the old helpers until ExtractVariable is done. Reviewers: ilya-biryukov Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65525 llvm-svn: 367667
* [clang-tools-extra] Adopt FileManager's error-returning APIsHarlan Haskins2019-08-0111-32/+41
| | | | | | | | The FileManager has been updated to return llvm::ErrorOr from getFile and getDirectory, this commit updates all the callers of those APIs from clang. llvm-svn: 367617
OpenPOWER on IntegriCloud