summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaCodeComplete.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "[OpenCL] Add generic AS to 'this' pointer"Mikael Nilsson2018-12-121-5/+7
| | | | | | Reverting because the patch broke lldb. llvm-svn: 348931
* [OpenCL] Add generic AS to 'this' pointerMikael Nilsson2018-12-121-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
* [CodeComplete] Fix a crash in access checks of inner classesIlya Biryukov2018-12-051-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
* [CodeComplete] Cleanup access checking in code completionIlya Biryukov2018-12-031-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
* [CodeComplete] Delete unused variable in rC342449Fangrui Song2018-11-241-1/+0
| | | | llvm-svn: 347508
* [CodeComplete] Format SemaCodeComplete.cpp and improve code consistencyFangrui Song2018-11-241-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
* [CodeComplete] Penalize inherited ObjC properties for auto-completionSam McCall2018-11-201-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
* [CodeComplete] Do not complete self-initializationsIlya Biryukov2018-11-071-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
* [clang] Improve ctor initializer completions.Kadir Cetinkaya2018-11-011-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
* NFC: Remove the ObjC1/ObjC2 distinction from clang (and related projects)Erik Pilkington2018-10-301-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
* [clang] Introduce new completion context typesKadir Cetinkaya2018-10-241-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
* [CodeComplete] Expose InBaseClass signal in code completion results.Eric Liu2018-10-241-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
* [clang] Fix a null pointer dereference.Kadir Cetinkaya2018-10-231-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
* [CodeComplete] Fix accessibility of protected members when accessing members ↵Eric Liu2018-10-221-4/+11
| | | | | | | | | | | | implicitly. Reviewers: ilya-biryukov Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53369 llvm-svn: 344889
* [CodeComplete] Make sure keyword 'template' is added even when code pattern ↵Eric Liu2018-10-151-0/+4
| | | | | | | | | | | | is disabled. Reviewers: sammccall, hokein Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53284 llvm-svn: 344509
* Lift VFS from clang to llvm (NFC)Jonas Devlieghere2018-10-101-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
* [CodeComplete] Fix crash when completing params function declarations.Sam McCall2018-10-101-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
* [CodeComplete] Re-fix accessibilty of protected members from base class.Eric Liu2018-10-021-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
* [clang] Implement Override Suggestions in Sema.Kadir Cetinkaya2018-10-021-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
* [CodeComplete] #include completion treats -I as non-system (require ↵Sam McCall2018-10-011-1/+1
| | | | | | header-like extension). llvm-svn: 343457
* [Sema] Do not load macros from preamble when LoadExternal is false.Eric Liu2018-09-191-13/+16
| | | | | | | | | | | | Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52079 llvm-svn: 342528
* [CodeComplete] Add completions for filenames in #include directives.Sam McCall2018-09-181-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
* [CodeCompletion] Enable signature help when initializing class/struct/union ↵Kadir Cetinkaya2018-09-111-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
* [CodeComplete] Clearly distinguish signature help and code completion.Ilya Biryukov2018-09-071-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
* [Sema] Store MacroInfo in CodeCompletionResult for macro results.Eric Liu2018-09-051-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
* [CodeComplete] Report location of opening parens for signature helpIlya Biryukov2018-08-301-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
* [CodeComplete] Fix the crash in code completion on access checkingIlya Biryukov2018-07-301-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
* Refactor checking of switch conditions and case values.Richard Smith2018-07-261-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
* [CodeComplete] Fix accessibilty of protected members from base class.Eric Liu2018-07-191-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
* [clangd] Uprank delcarations when "using q::name" is present in the main fileKirill Bobyrev2018-07-111-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
* [SemaCodeComplete] Expose a method to create CodeCompletionString for macros.Eric Liu2018-07-061-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
* [NFS] Wipe trailing whitespacesKirill Bobyrev2018-07-051-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
* [SemaCodeComplete] Make sure visited contexts are passed to completion ↵Eric Liu2018-07-041-107/+75
| | | | | | | | | | | | results handler. Reviewers: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D48917 llvm-svn: 336255
* Optionally add code completion results for arrow instead of dotIvan Donchevskii2018-05-251-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
* Switch a couple of users of LangOpts::GNUMode to the more appropriate ↵Richard Smith2018-05-241-2/+2
| | | | | | LangOpts::GNUKeywords. llvm-svn: 333233
* [CodeComplete] Expose helpers to get RawComment of completion result.Ilya Biryukov2018-05-161-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
* [CodeComplete] Provide completion in decls even for incomplete typesIlya Biryukov2018-05-141-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
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-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
* Fix typos in clangAlexander Kornienko2018-04-061-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
* Remove redundant casts. NFCGeorge Burgess IV2018-03-011-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
* [CodeComplete] Omit templated constructors from member list too.Sam McCall2018-01-221-3/+9
| | | | | | Also avoid printing a 'void' return type for constructor expressions. llvm-svn: 323148
* [Sema] Add visited contexts to CodeCompleteContextHaojian Wu2018-01-171-1/+10
| | | | | | | | | | | | | | | | | | | Summary: This would allow code completion clients to know which context is visited during Sema code completion. Also some changes: * add `EnteredContext` callback in VisibleDeclConsumer. * add a simple unittest for sema code completion (only for visited contexts at the moment). Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: mgorny, bkramer, cfe-commits Differential Revision: https://reviews.llvm.org/D42071 llvm-svn: 322661
* [CodeComplete] Add an option to omit results from the preamble.Sam McCall2018-01-121-23/+40
| | | | | | | | | | | | | | | | | | | | | | | Summary: Enumerating the contents of a namespace or global scope will omit any decls that aren't already loaded, instead of deserializing them from the PCH. This allows a fast hybrid code completion where symbols from headers are provided by an external index. (Sema already exposes the information needed to do a reasonabl job of filtering them). Clangd plans to implement this hybrid. This option is just a hint - callers still need to postfilter results if they want to *avoid* completing decls outside the main file. Reviewers: bkramer, ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D41989 llvm-svn: 322371
* Again reverting an attempt to convert the DeclSpec enums into scoped enums.Faisal Vali2018-01-011-1/+1
| | | | | | | | | | | | - reverts r321622, r321625, and r321626. - the use of bit-fields is still resulting in warnings - even though we can use static-asserts to harden the code and ensure the bit-fields are wide enough. The bots still complain of warnings being seen. - to silence the warnings requires specifying the bit-fields with the underlying enum type (as opposed to the enum type itself), which then requires lots of unnecessary static casts of each enumerator within DeclSpec to the underlying-type, which even though could be seen as implementation details, it does hamper readability - and given the additional litterings, makes me question the value of the change. So in short - I give up (for now at least). Sorry about the noise. llvm-svn: 321628
* [NFC] Modernize enums TypeSpecifierWidth, TypeSpecifierSign & ↵Faisal Vali2018-01-011-1/+1
| | | | | | | | | | | | TypeSpecifierType into scoped enums with underlying types. - Since these enums are used as bit-fields - for the bit-fields to be interpreted as unsigned, the underlying type must be specified as unsigned. Previous failed attempt - wherein I did not specify an underlying type - was the sum of: https://reviews.llvm.org/rC321614 https://reviews.llvm.org/rC321615 llvm-svn: 321622
* Revert r321614 and r321615Faisal Vali2018-01-011-1/+1
| | | | | | | | - the enum changes to TypeSpecifierType are breaking some tests - and will require a more careful integration. Sorry about rushing these changes - thought I could sneak them in prior to heading out for new years ;) llvm-svn: 321616
* [NFC] Modernize enums TypeSpecifierWidth, TypeSpecifierSign & ↵Faisal Vali2018-01-011-1/+1
| | | | | | | | TypeSpecifierType into scoped enums. llvm-svn: 321614
* [NFC] Modernize enum Declarator::TheContext to a type-safe scoped enum.Faisal Vali2017-12-291-2/+2
| | | | | | Note, we don't do any bitwise manipulations when using them. llvm-svn: 321546
* Silence a bunch of implicit fallthrough warningsAdrian Prantl2017-12-191-3/+3
| | | | llvm-svn: 321115
* Refactor overridden methods iteration to avoid double lookups.Benjamin Kramer2017-12-171-4/+1
| | | | | | Convert most uses to range-for loops. No functionality change intended. llvm-svn: 320954
OpenPOWER on IntegriCloud