aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaCodeComplete.cpp
AgeCommit message (Collapse)AuthorFilesLines
2019-01-31[CodeComplete] Propagate preferred types through parser in more casesIlya Biryukov1-112/+199
Preferred types are used by code completion for ranking. This commit considerably increases the number of points in code where those types are propagated. In order to avoid complicating signatures of Parser's methods, a preferred type is kept as a member variable in the parser and updated during parsing. Differential revision: https://reviews.llvm.org/D56723 llvm-svn: 352788
2019-01-28Rename getTypeQualifiers to getMethodQualifiers.Anastasia Stulova1-5/+5
Use more descriptive name for the method qualifiers getter. Differential Revision: https://reviews.llvm.org/D56792 llvm-svn: 352349
2019-01-24[CodeComplete] [clangd] Fix crash on ValueDecl with a null typeIlya Biryukov1-1/+2
Reviewers: kadircet Reviewed By: kadircet Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D57093 llvm-svn: 352040
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-12-21[Sema][NFC] Fix Wimplicit-fallthrough warning in getCursorKindForDeclBruno Ricci1-0/+1
All cases are covered so add an llvm_unreachable. NFC. llvm-svn: 349933
2018-12-19[CodeComplete] Properly determine qualifiers of 'this' in a lambdaIlya Biryukov1-5/+3
Summary: The clang used to pick up the qualifiers of the lamba's call operator (which is always const) and fail to show non-const methods of 'this' in completion results. Reviewers: kadircet Reviewed By: kadircet Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55885 llvm-svn: 349655
2018-12-13[CodeComplete] Temporarily disable failing assertionIlya Biryukov1-1/+2
Found the case in the clang codebase where the assertion fires. To avoid crashing assertion-enabled builds before I re-add the missing operation. Will restore the assertion alongside the upcoming fix. llvm-svn: 349061
2018-12-13[CodeComplete] Fill preferred type on binary expressionsIlya Biryukov1-3/+80
Reviewers: kadircet Reviewed By: kadircet Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D55648 llvm-svn: 349053
2018-12-13[CodeComplete] Set preferred type to bool on conditionsIlya Biryukov1-2/+4
Reviewers: kadircet Reviewed By: kadircet Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55431 llvm-svn: 349050
2018-12-13[OpenCL] Add generic AS to 'this' pointerMikael Nilsson1-7/+5
Address spaces are cast into generic before invoking the constructor. Added support for a trailing Qualifiers object in FunctionProtoType. Note: This recommits the previously reverted patch, but now it is commited together with a fix for lldb. Differential Revision: https://reviews.llvm.org/D54862 llvm-svn: 349019
2018-12-12Revert "[OpenCL] Add generic AS to 'this' pointer"Mikael Nilsson1-5/+7
Reverting because the patch broke lldb. llvm-svn: 348931
2018-12-12[OpenCL] Add generic AS to 'this' pointerMikael Nilsson1-7/+5
Address spaces are cast into generic before invoking the constructor. Added support for a trailing Qualifiers object in FunctionProtoType. Differential Revision: https://reviews.llvm.org/D54862 llvm-svn: 348927
2018-12-05[CodeComplete] Fix a crash in access checks of inner classesIlya Biryukov1-10/+31
Summary: The crash was introduced in r348135. Reviewers: kadircet Reviewed By: kadircet Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55260 llvm-svn: 348387
2018-12-03[CodeComplete] Cleanup access checking in code completionIlya Biryukov1-31/+40
Summary: Also fixes a crash (see the added 'accessibility-crash.cpp' test). Reviewers: ioeric, kadircet Reviewed By: kadircet Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55124 llvm-svn: 348135
2018-11-24[CodeComplete] Delete unused variable in rC342449Fangrui Song1-1/+0
llvm-svn: 347508
2018-11-24[CodeComplete] Format SemaCodeComplete.cpp and improve code consistencyFangrui Song1-1187/+1135
There are some mis-indented places and missing spaces here and there. Just format the whole file. Also, newer code (from 2014 onwards) in this file prefers const auto *X = dyn_cast to not repeat the Decl type name. Make other occurrences consistent. Remove two anonymous namespaces that are not very necessary: 1) a typedef 2) a local function (should use static) llvm-svn: 347507
2018-11-20[CodeComplete] Penalize inherited ObjC properties for auto-completionSam McCall1-21/+36
Summary: Similar to auto-completion for ObjC methods, inherited properties should be penalized / direct class and category properties should be prioritized. Note that currently, the penalty for using a result from a base class (CCD_InBaseClass) is equal to the penalty for using a method as a property (CCD_MethodAsProperty). Reviewers: jkorous, sammccall, akyrtzi, arphaman, benlangmuir Reviewed By: sammccall, akyrtzi Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53900 llvm-svn: 347352
2018-11-07[CodeComplete] Do not complete self-initializationsIlya Biryukov1-1/+6
Summary: Removes references to initialized variable from the following completions: int x = ^; Handles only the trivial cases where the variable name is completed immediately at the start of initializer or assignment, more complicated cases aren't covered, e.g. these completions still contain 'x': // More complicated expressions. int x = foo(^); int x = 10 + ^; // Other kinds of initialization. int x{^}; int x(^); // Constructor initializers. struct Foo { Foo() : x(^) {} int x; }; We should address those in the future, but they are outside of the scope of this initial change. Reviewers: sammccall Reviewed By: sammccall Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D54156 llvm-svn: 346301
2018-11-01[clang] Improve ctor initializer completions.Kadir Cetinkaya1-42/+82
Summary: Instead of providing generic "args" for member and base class initializers, tries to fetch relevant constructors and show their signatures. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: ZaMaZaN4iK, eraman, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53654 llvm-svn: 345844
2018-10-30NFC: Remove the ObjC1/ObjC2 distinction from clang (and related projects)Erik Pilkington1-16/+16
We haven't supported compiling ObjC1 for a long time (and never will again), so there isn't any reason to keep these separate. This patch replaces LangOpts::ObjC1 and LangOpts::ObjC2 with LangOpts::ObjC. Differential revision: https://reviews.llvm.org/D53547 llvm-svn: 345637
2018-10-24[clang] Introduce new completion context typesKadir Cetinkaya1-9/+15
Summary: New name suggestions were being used in places where existing names should have been used, this patch tries to fix some of those situations. Reviewers: sammccall Reviewed By: sammccall Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53191 llvm-svn: 345152
2018-10-24[CodeComplete] Expose InBaseClass signal in code completion results.Eric Liu1-5/+10
Summary: No new tests as the existing tests for result priority should give us coverage. Also as the new flag is trivial enough, I'm reluctant to plumb the flag to c-index-test output. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D53635 llvm-svn: 345135
2018-10-23[clang] Fix a null pointer dereference.Kadir Cetinkaya1-0/+3
Summary: Sometimes expression inside switch statement can be invalid, for example type might be incomplete. In those cases code were causing a null pointer dereference. This patch fixes that. Reviewers: sammccall, ioeric, hokein Reviewed By: sammccall Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53561 llvm-svn: 345029
2018-10-22[CodeComplete] Fix accessibility of protected members when accessing members ↵Eric Liu1-4/+11
implicitly. Reviewers: ilya-biryukov Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53369 llvm-svn: 344889
2018-10-15[CodeComplete] Make sure keyword 'template' is added even when code pattern ↵Eric Liu1-0/+4
is disabled. Reviewers: sammccall, hokein Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53284 llvm-svn: 344509
2018-10-10Lift VFS from clang to llvm (NFC)Jonas Devlieghere1-1/+1
This patch moves the virtual file system form clang to llvm so it can be used by more projects. Concretely the patch: - Moves VirtualFileSystem.{h|cpp} from clang/Basic to llvm/Support. - Moves the corresponding unit test from clang to llvm. - Moves the vfs namespace from clang::vfs to llvm::vfs. - Formats the lines affected by this change, mostly this is the result of the added llvm namespace. RFC on the mailing list: http://lists.llvm.org/pipermail/llvm-dev/2018-October/126657.html Differential revision: https://reviews.llvm.org/D52783 llvm-svn: 344140
2018-10-10[CodeComplete] Fix crash when completing params function declarations.Sam McCall1-1/+2
Summary: In a decl like `int AA(BB cc)` where BB isn't defined, we end up trying to parse `BB cc` as an expression (vexing parse) and end up triggering the parser's "recovery-in-function" completion with no actual function scope. This patch avoids the assumption that such a scope exists in this context. Reviewers: kadircet Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D53070 llvm-svn: 344133
2018-10-02[CodeComplete] Re-fix accessibilty of protected members from base class.Eric Liu1-5/+18
Summary: The initial fix (r337453) had bug and was partially reverted (r338255). This simplies the original fix by explicitly passing the naming class to the completion consumer. Reviewers: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52647 llvm-svn: 343575
2018-10-02[clang] Implement Override Suggestions in Sema.Kadir Cetinkaya1-2/+99
Summary: In clangd we had a new type of completion suggestions for cpp class/struct/unions that will show override signatures for virtual methods in base classes. This patch implements it in sema because it is hard to deduce more info about completion token outside of Sema and handle itchy cases. See the patch D50898 for more info on the functionality. In addition to above patch this one also converts the suggestion into a CK_Pattern with whole insertion text as the name of the suggestion and factors out CodeCompletionString generation for declerations so that it can be re-used by others. Reviewers: ioeric, ilya-biryukov Reviewed By: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52225 llvm-svn: 343568
2018-10-01[CodeComplete] #include completion treats -I as non-system (require ↵Sam McCall1-1/+1
header-like extension). llvm-svn: 343457
2018-09-19[Sema] Do not load macros from preamble when LoadExternal is false.Eric Liu1-13/+16
Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52079 llvm-svn: 342528
2018-09-18[CodeComplete] Add completions for filenames in #include directives.Sam McCall1-0/+111
Summary: The dir component ("somedir" in #include <somedir/fo...>) is considered fixed. We append "foo" to each directory on the include path, and then list its files. Completions are of the forms: #include <somedir/fo^ foo.h> fox/ The filter is set to the filename part ("fo"), so fuzzy matching can be applied to the filename only. No fancy scoring/priorities are set, and no information is added to CodeCompleteResult to make smart scoring possible. Could be in future. Reviewers: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52076 llvm-svn: 342449
2018-09-11[CodeCompletion] Enable signature help when initializing class/struct/union ↵Kadir Cetinkaya1-0/+19
members. Summary: Factors out member decleration gathering and uses it in parsing to call signature help. Doesn't support signature help for base class constructors, the code was too coupled with diagnostic handling, but still can be factored out but just needs more afford. Reviewers: sammccall, ilya-biryukov, ioeric Reviewed By: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51917 llvm-svn: 341949
2018-09-07[CodeComplete] Clearly distinguish signature help and code completion.Ilya Biryukov1-40/+29
Summary: Code completion in clang is actually a mix of two features: - Code completion is a familiar feature. Results are exposed via the CodeCompleteConsumer::ProcessCodeCompleteResults callback. - Signature help figures out if the current expression is an argument of some function call and shows corresponding signatures if so. Results are exposed via CodeCompleteConsumer::ProcessOverloadCandidates. This patch refactors the implementation to untangle those two from each other and makes some naming tweaks to avoid confusion when reading the code. The refactoring is required for signature help fixes, see D51038. The only intended behavior change is the order of callbacks. ProcessOverloadCandidates is now called before ProcessCodeCompleteResults. Reviewers: sammccall, kadircet Reviewed By: sammccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51782 llvm-svn: 341660
2018-09-05[Sema] Store MacroInfo in CodeCompletionResult for macro results.Eric Liu1-7/+7
Summary: This provides information about the macro definition. For example, it can be used to compute macro USRs. Reviewers: sammccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51675 llvm-svn: 341476
2018-08-30[CodeComplete] Report location of opening parens for signature helpIlya Biryukov1-11/+13
Summary: Used in clangd. Reviewers: sammccall Reviewed By: sammccall Subscribers: ioeric, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D51436 llvm-svn: 341063
2018-07-30[CodeComplete] Fix the crash in code completion on access checkingIlya Biryukov1-28/+2
Started crashing in r337453. See the added test case for the crash repro. The fix reverts part of r337453 that causes the crash and does not actually break anything when reverted. llvm-svn: 338255
2018-07-26Refactor checking of switch conditions and case values.Richard Smith1-1/+1
Check each case value in turn while parsing it, performing the conversion to the switch type within the context of the expression itself. This will become necessary in order to properly handle cleanups for temporaries created as part of the case label (in an upcoming patch). For now it's just good hygiene. This necessitates moving the checking for the switch condition itself to earlier, so that the destination type is available when checking the case labels. As a nice side-effect, we get slightly improved diagnostic quality and error recovery by separating the case expression checking from the case statement checking and from tracking whether there are discarded case labels. llvm-svn: 338056
2018-07-19[CodeComplete] Fix accessibilty of protected members from base class.Eric Liu1-2/+27
Summary: Currently, protected members from base classes are marked as inaccessible when completing in derived class. This patch fixes the problem by setting the naming class correctly when looking up results in base class according to [11.2.p5]. Reviewers: aaron.ballman, sammccall, rsmith Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49421 llvm-svn: 337453
2018-07-11[clangd] Uprank delcarations when "using q::name" is present in the main fileKirill Bobyrev1-14/+15
Having `using qualified::name;` for some symbol is an important signal for clangd code completion as the user is more likely to use such symbol. This patch helps to uprank the relevant symbols by saving UsingShadowDecl in the new field of CodeCompletionResult and checking whether the corresponding UsingShadowDecl is located in the main file later in ClangD code completion routine. While the relative importance of such signal is a subject to change in the future, this patch simply bumps DeclProximity score to the value of 1.0 which should be enough for now. The patch was tested using `$ ninja check-clang check-clang-tools` No unexpected failures were noticed after running the relevant testsets. Reviewers: sammccall, ioeric Subscribers: MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D49012 llvm-svn: 336810
2018-07-06[SemaCodeComplete] Expose a method to create CodeCompletionString for macros.Eric Liu1-44/+49
Summary: The method only takes PPreprocessor and don't require structures that might not be available (e.g. Sema and ASTContext) when CodeCompletionString needs to be generated for macros. Reviewers: sammccall Reviewed By: sammccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D48973 llvm-svn: 336427
2018-07-05[NFS] Wipe trailing whitespacesKirill Bobyrev1-740/+740
This patch is a preparation for another one containing meaningful changes. This patch simply removes trailing whitespaces in few files affected by the upcoming patch and reformats llvm-svn: 336330
2018-07-04[SemaCodeComplete] Make sure visited contexts are passed to completion ↵Eric Liu1-107/+75
results handler. Reviewers: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D48917 llvm-svn: 336255
2018-05-25Optionally add code completion results for arrow instead of dotIvan Donchevskii1-82/+120
Currently getting such completions requires source correction, reparsing and calling completion again. And if it shows no results and rollback is required then it costs one more reparse. With this change it's possible to get all results which can be later filtered to split changes which require correction. Differential Revision: https://reviews.llvm.org/D41537 llvm-svn: 333272
2018-05-24Switch a couple of users of LangOpts::GNUMode to the more appropriate ↵Richard Smith1-2/+2
LangOpts::GNUKeywords. llvm-svn: 333233
2018-05-16[CodeComplete] Expose helpers to get RawComment of completion result.Ilya Biryukov1-30/+62
Summary: Used in clangd, see D45999. Reviewers: sammccall, hokein, ioeric, arphaman Reviewed By: sammccall Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D46001 llvm-svn: 332457
2018-05-14[CodeComplete] Provide completion in decls even for incomplete typesIlya Biryukov1-4/+2
Summary: This change fixes lack of completions in the following case ('^'designates completion points) : void f(^); struct Incomplete; Incomplete g(^); Reviewers: bkramer, aaron.ballman, sammccall Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D46639 llvm-svn: 332244
2018-05-09Remove \brief commands from doxygen comments.Adrian Prantl1-89/+89
This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
2018-04-06Fix typos in clangAlexander Kornienko1-1/+1
Found via codespell -q 3 -I ../clang-whitelist.txt Where whitelist consists of: archtype cas classs checkk compres definit frome iff inteval ith lod methode nd optin ot pres statics te thru Patch by luzpaz! (This is a subset of D44188 that applies cleanly with a few files that have dubious fixes reverted.) Differential revision: https://reviews.llvm.org/D44188 llvm-svn: 329399
2018-03-01Remove redundant casts. NFCGeorge Burgess IV1-5/+5
So I wrote a clang-tidy check to lint out redundant `isa`, `cast`, and `dyn_cast`s for fun. This is a portion of what it found for clang; I plan to do similar cleanups in LLVM and other subprojects when I find time. Because of the volume of changes, I explicitly avoided making any change that wasn't highly local and obviously correct to me (e.g. we still have a number of foo(cast<Bar>(baz)) that I didn't touch, since overloading is a thing and the cast<Bar> did actually change the type -- just up the class hierarchy). I also tried to leave the types we were cast<>ing to somewhere nearby, in cases where it wasn't locally obvious what we were dealing with before. llvm-svn: 326416