summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/refactor
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Revert define-inline action changes to un-break windows build-botsKadir Cetinkaya2019-10-254-404/+4
|
* Fix compilation error in clangd/refactor/tweaks/ExpandAutoType.cppKadir Cetinkaya2019-10-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Summary: During the compilation of the `clangd/refactor/tweaks/ExpandAutoType.cpp`, MSVC returns the following error: llvm-monorepo\llvm\tools\clang\tools\extra\clangd\refactor\tweaks\ExpandAutoType.cpp(85): error C2146: syntax error: missing ')' before identifier 'and' llvm-monorepo\llvm\tools\clang\tools\extra\clangd\refactor\tweaks\ExpandAutoType.cpp(85): error C2065: 'and': undeclared identifier llvm-monorepo\llvm\tools\clang\tools\extra\clangd\refactor\tweaks\ExpandAutoType.cpp(86): error C2143: syntax error: missing ';' before '<template-id>' llvm-monorepo\llvm\tools\clang\tools\extra\clangd\refactor\tweaks\ExpandAutoType.cpp(73): fatal error C1075: '{': no matching token found So, && must be used instead of `and`. Patch By Pavel Samolysov (@psamolysov) ! Reviewers: kadircet Reviewed By: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D69427
* [clangd] Store Index in Tweak::SelectionKadir Cetinkaya2019-10-252-4/+10
| | | | | | | | | | | | | | | | Summary: Incoming define out-of-line tweak requires access to index. This patch simply propogates the index in ClangdServer to Tweak::Selection while passing the AST. Also updates TweakTest to accommodate this change. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69165
* [clangd] DefineInline action apply logic with fully qualified namesKadir Cetinkaya2019-10-251-4/+183
| | | | | | | | | | | | Summary: Initial version of DefineInline action that will fully qualify every name inside function body. Reviewers: sammccall, ilya-biryukov, hokein Tags: #clang Differential Revision: https://reviews.llvm.org/D66647
* [clangd] DefineInline action availability checksKadir Cetinkaya2019-10-252-0/+215
| | | | | | | | | | | | Summary: Introduces DefineInline action and initial version of availability checks. Reviewers: sammccall, ilya-biryukov, hokein Tags: #clang Differential Revision: https://reviews.llvm.org/D65433
* [clangd] Add the missing dependency on `clangLex`.Michael Liao2019-10-161-0/+1
| | | | llvm-svn: 375039
* [clangd] Add RemoveUsingNamespace tweak.Utkarsh Saxena2019-10-162-0/+207
| | | | | | | | | | | | | | | | | | Summary: Removes the 'using namespace' under the cursor and qualifies all accesses in the current file. E.g.: using namespace std; vector<int> foo(std::map<int, int>); Would become: std::vector<int> foo(std::map<int, int>); Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68562 llvm-svn: 374982
* [clangd] Disable expand auto on decltype(auto)Ilya Biryukov2019-10-081-1/+3
| | | | | | | | | | | | | | | | Summary: Applying it produces incorrect code at the moment. Reviewers: sammccall Reviewed By: sammccall Subscribers: kuhnel, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68630 llvm-svn: 374048
* [Clangd] ExtractFunction: Don't extract body of enclosing function.Shaurya Gupta2019-10-021-8/+21
| | | | | | | | | | | | | | | | | | | Summary: This patch disable extraction of the body of the enclosing function. `void f() [[{}]]` Extracting this CompoundStmt would leave the enclosing function without a body. Reviewers: sammccall, kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68245 llvm-svn: 373472
* [Clangd] Ensure children are always RootStmt in ExtractFunction (Fixes #153)Shaurya Gupta2019-10-021-4/+14
| | | | | | | | | | | | | | | | | | Summary: We weren't always checking if children are RootStmts in ExtractFunction. For `void f([[int a]]);`, the ParmVarDecl appeared as a RootStmt since we didn't perform the check and ended up being casted to a (null) Stmt. Reviewers: sammccall, kadircet Subscribers: kristof.beyls, ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68182 llvm-svn: 373471
* [clangd] Bail out early if we are sure that the symbol is used outside of ↵Haojian Wu2019-10-021-1/+5
| | | | | | | | | | | | | | | | | | the file. Summary: This would reduce the false positive when the static index is in an unavailable state, e.g. background index is not finished. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68325 llvm-svn: 373444
* [clangd] SelectionTree should mark a node as fully-selected if the only ↵Sam McCall2019-10-021-6/+3
| | | | | | | | | | | | | | | | | | | claimed tokens were early-claimed. Summary: Previously they would be marked as partially-selected based on the early claim, and never updated as no more tokens were claimed. This affects simple VarDecls like "int x". Reviewers: SureYeaah Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66872 llvm-svn: 373442
* [clangd] Fix a crash when renaming operator.Haojian Wu2019-09-161-0/+4
| | | | | | | | | | | | | | | | | | | | Summary: The renamelib uses a tricky way to calculate the end location by relying on decl name, this is incorrect for the overloaded operator (the name is "operator++" instead of "++"), which will cause out-of-file offset. We also disable renaming operator symbol, this case is tricky, and renamelib doesnt handle it properly. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67607 llvm-svn: 371971
* [clangd] Support multifile edits as output of TweaksKadir Cetinkaya2019-09-099-22/+66
| | | | | | | | | | | | | | | | | | | | Summary: First patch for propogating multifile changes from tweak outputs to LSP WorkspaceEdits. Uses SM to convert tooling::Replacements to TextEdits. Errors out if there are any inconsistencies between the draft version and the version generated the edits. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66637 llvm-svn: 371392
* [clangd] Remove macro-expansion-location from getBeginningOfIdentifier. ↵Sam McCall2019-09-041-2/+3
| | | | | | Inline into relevant callsites. NFC llvm-svn: 370869
* [clangd] Rename ClangdUnit.h -> ParsedAST.h. NFCSam McCall2019-09-046-6/+6
| | | | | | | | | | This much better reflects what is (now) in this header. Maybe a rename to ParsedTU would be an improvement, but that's a much more invasive change and life is too short. ClangdUnit is dead, long live ClangdUnitTests! llvm-svn: 370862
* [clangd] Move getBeginningOfIdentifier from ClangdUnit to SourceCode. Drop ↵Sam McCall2019-09-032-3/+7
| | | | | | dependencies on ClangdUnit from some headers. NFC llvm-svn: 370768
* [Clangd] ExtractFunction Added checks for broken control flowShaurya Gupta2019-08-301-13/+59
| | | | | | | | | | | | | | | | 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
* [Clangd] NFC: Added fixme for checking for local/anonymous types for ↵Shaurya Gupta2019-08-291-0/+1
| | | | | | extracted parameters llvm-svn: 370372
* Fix MSVC "not all control paths return a value" warning. NFCI.Simon Pilgrim2019-08-291-0/+1
| | | | llvm-svn: 370343
* [clangd] Fix ExtractFunction dependenciesHeejin Ahn2019-08-281-0/+1
| | | | | | | | | | | | | | 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
* [Clangd] Initial version of ExtractFunctionShaurya Gupta2019-08-282-0/+606
| | | | | | | | | | | | | | | | | | | 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
* [clang-tools-extra] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-1/+1
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368944
* [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] Disallow extraction of expression-statements.Sam McCall2019-08-091-48/+77
| | | | | | | | | | | | | | | | | | | | | 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 raw rename functions to implement the rename.Haojian Wu2019-08-091-60/+45
| | | | | | | | | | | | | | | | | | | | | | | 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] Ignore semicolons, whitespace, and comments in SelectionTree.Sam McCall2019-07-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Whitespace and comments are a clear bugfix: selecting some comments/space near a statement doesn't mean you're selecting the surrounding block. Semicolons are less obvious, but for similar reasons: these tokens aren't actually claimed by any AST node (usually), so an AST-based model like SelectionTree shouldn't take them into account. Callers may still sometimes care about semis of course: - when the selection is an expr with a non-expr parent, selection of the semicolon indicates intent to select the statement. - when a statement with a trailing semi is selected, we need to know its range to ensure it can be removed. SelectionTree may or may not play a role here, but these are separate questions from its core function of describing which AST nodes were selected. The mechanism here is the TokenBuffer from syntax-trees. We use it in a fairly low-level way (just to get boundaries of raw spelled tokens). The actual mapping of AST nodes to coordinates continues to use the (fairly mature) SourceLocation based logic. TokenBuffer/Syntax trees don't currently offer an alternative to getFileRange(), I think. Reviewers: SureYeaah, kadircet Subscribers: MaskRay, jkorous, arphaman, cfe-commits, ilya-biryukov Tags: #clang Differential Revision: https://reviews.llvm.org/D65486 llvm-svn: 367453
* [clangd] Fix a regression in rL366996.Haojian Wu2019-07-301-7/+5
| | | | | | | | | | | | | | Summary: That patch made the tweak always annotate the whole file by accident. Reviewers: jvikstrom Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65443 llvm-svn: 367313
* [clangd] Support extraction of binary "subexpressions" like a + [[b + c]].Sam McCall2019-07-261-16/+157
| | | | | | | | | | | | | | | | | | | | | Summary: These aren't formally subexpressions in C++, in this case + is left-associative. However informally +, *, etc are usually (mathematically) associative and users consider these subexpressions. We detect these and in simple cases support extracting the partial expression. As well as builtin associative operators, we assume that overloads of them are associative and support those too. Reviewers: SureYeaah Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65139 llvm-svn: 367121
* [Clangd] Disable ExtractVariable for all types of assignmentsShaurya Gupta2019-07-261-1/+1
| | | | | | | | | | | | Reviewers: sammccall, kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65332 llvm-svn: 367113
* [clangd] Fix the annotate tweak after rL366893Haojian Wu2019-07-251-17/+23
| | | | | | | | | | | | | | | | | | Summary: After rL366893, the annoate tweak is not activated when we select the whole file (the commonAncestor is TUDecl but we intend to return null). This patch fixes this, and also avoid traversing the TUDecl. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65210 llvm-svn: 366996
* [clangd] SelectionTree treats TranslationUnitDecl (mostly) consistently with ↵Sam McCall2019-07-241-3/+1
| | | | | | | | | | | | | | | | | | | | | | | other containers. Summary: Previously TranslationUnitDecl would never be selected. This means root() is never null, and returns a reference. commonAncestor() is in principle never null also, but returning TUDecl here requires tweaks to be careful not to traverse it (this was already possible when selecting multiple top-level decls, and there are associated bugs!) Instead, never allow commonAncestor() to return TUDecl, return null instead. Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65101 llvm-svn: 366893
* [clangd] Update a stale comment, NFC.Haojian Wu2019-07-241-1/+1
| | | | llvm-svn: 366875
* [Clangd] Fixed ExtractVariable for certain types of ExprsShaurya Gupta2019-07-241-27/+84
| | | | | | | | | | | | | | | | | | Summary: - Modified ExtractVariable for extraction of MemberExpr, DeclRefExpr and Assignment Expr - Removed extraction from label statements. - Fixed unittests Reviewers: sammccall, kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64717 llvm-svn: 366869
* [clangd] cleanup: unify the implemenation of checking a location is inside ↵Haojian Wu2019-07-191-2/+1
| | | | | | | | | | | | | | | | main file. Summary: We have variant implementations in the codebase, this patch unifies them. Reviewers: ilya-biryukov, kadircet Subscribers: MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64915 llvm-svn: 366541
* [Clangd] NFC: Fixed tweaks CMakeLists order to alphabeticalShaurya Gupta2019-07-181-2/+2
| | | | llvm-svn: 366452
* [Clangd] Changed ExtractVariable to only work on non empty selectionsShaurya Gupta2019-07-183-2/+9
| | | | | | | | | | | | | | | | Summary: - For now, we don't trigger in any case if it's an empty selection - Fixed unittests Reviewers: kadircet, sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64912 llvm-svn: 366451
* [clangd] Disable DumpRecordLayout by default per ↵Sam McCall2019-07-181-0/+5
| | | | | | https://bugs.llvm.org/show_bug.cgi?id=42670 llvm-svn: 366443
* [clangd] Move the expandAuto tweak from global namespace into annoymous ↵Haojian Wu2019-07-121-1/+3
| | | | | | namespace. llvm-svn: 365885
* [clangd] Don't run the prepare for tweaks that are disabled.Haojian Wu2019-07-122-5/+9
| | | | | | | | | | | | | | Summary: Previously, we ran the prepare, even for the tweaks that are disabled. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64565 llvm-svn: 365882
* [clangd] Implementation of auto type expansion.Sam McCall2019-07-112-0/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add a tweak for clangd to replace an auto keyword to the deduced type. This way a user can declare something with auto and then have the IDE/clangd replace auto with whatever type clangd thinks it is. In case of long/complext types this makes is reduces writing effort for the user. The functionality is similar to the hover over the auto keyword. Example (from the header): ``` /// Before: /// auto x = Something(); /// ^^^^ /// After: /// MyClass x = Something(); /// ^^^^^^^ ``` Patch by kuhnel! (Christian Kühnel) Differential Revision: https://reviews.llvm.org/D62855 llvm-svn: 365792
* [clangd] Fix an assertion crash in "ExtractVariable" tweakHaojian Wu2019-07-111-1/+1
| | | | | | | | | | | | | | | | Summary: GetTypePtr requires that the type should not be null, otherwise we hit an assertion, we should use getTypePtrOrNull instead. Reviewers: sammccall, SureYeaah Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64556 llvm-svn: 365763
* Fixed assertionShaurya Gupta2019-07-091-1/+1
| | | | llvm-svn: 365460
* dummy variable extraction on a function scopeShaurya Gupta2019-07-092-0/+244
| | | | | | | | | | | | | | | | | | | Summary: - Added extraction to a dummy variable - using auto for the dummy variable type for now - Works on a function scope - Adding braces to create a compound statement not supported yet - added unit tests Reviewers: sammccall, kadircet Subscribers: mgorny, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63773 llvm-svn: 365453
* [clangd] A code tweak to expand a macroIlya Biryukov2019-07-082-0/+138
| | | | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61681 llvm-svn: 365331
* [clangd] Some tweaks on semantic highlighting lookuptable.Haojian Wu2019-07-041-9/+0
| | | | | | | | | | | | | | | | Summary: - move toTextMateScope to SemanticHighlighting.h; - move the buildLookupTable to LSP layer (as LSP requires such form); Reviewers: sammccall, jvikstrom Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64202 llvm-svn: 365135
* [clangd] Add a hidden tweak to annotate all highlighting tokens of the file.Haojian Wu2019-07-042-0/+83
| | | | | | | | | | | | Reviewers: sammccall, jvikstrom Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64137 llvm-svn: 365130
* [clangd] Show better message when we rename macros.Haojian Wu2019-07-011-18/+25
| | | | | | | | | | | | | | | | | | Summary: Previously, when we rename a macro, we get an error message of "there is no symbol found". This patch improves the message of this case (as we don't support macros). Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63922 llvm-svn: 364735
* [clangd] Fix a case where we fail to detect a header-declared symbol in rename.Haojian Wu2019-06-271-12/+13
| | | | | | | | | | | | | | | | | | | | | | | | 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
* [clangd] Don't rename the namespace.Haojian Wu2019-06-261-0/+5
| | | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud