summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaCodeComplete.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [CodeCompletion] Code complete the missing C++11 keywordsAlex Lorenz2017-02-131-11/+74
| | | | | | | | | | | | | | | | | | | | | | | | This commit adds context sensitive code completion support for the C++11 keywords that currently don't have completion results. The following keywords are supported by this patch: alignas constexpr static_assert noexcept (as a function/method qualifier) thread_local The following special identifiers are also supported: final (as a method qualifier or class qualifier) override rdar://29219185 Differential Revision: https://reviews.llvm.org/D28286 llvm-svn: 295001
* P0091R3: Implement basic parsing support for C++17 deduction-guides.Richard Smith2017-02-071-0/+1
| | | | | | | | | | | We model deduction-guides as functions with a new kind of name that identifies the template whose deduction they guide; the bulk of this patch is adding the new name kind. This gives us a clean way to attach an extensible list of guides to a class template in a way that doesn't require any special handling in AST files etc (and we're going to need these functions we come to performing deduction). llvm-svn: 294266
* [CodeCompletion] Ensure that ObjC root class completes instanceAlex Lorenz2017-01-241-30/+28
| | | | | | | | | | | | | | | methods from protocols and categories as well Code completion results for class methods already include instance methods from Objective-C root classes. This commit ensures that the results also include instance methods from protocols that the root class implements and root class categories as well. rdar://28012953 Differential Revision: https://reviews.llvm.org/D27257 llvm-svn: 292932
* [CodeCompletion] Block property setters: Use dynamic priority heuristicAlex Lorenz2017-01-061-1/+9
| | | | | | | | | | | | | | Now when completing blocks properties that return void the block call completion result shows up before the setter, otherwise the setter completion shows up before the block call completion. We normally want to use the result of the block call, so one typically wouldn't call a block that returns a non-void type in a standalone statement. rdar://28846153 Differential Revision: https://reviews.llvm.org/D26034 llvm-svn: 291232
* [CodeCompletion] Autocomplete NS_DESIGNATED_INITIALIZER in initializersAlex Lorenz2017-01-031-0/+17
| | | | | | | | | | with arguments rdar://21014571 Differential Revision: https://reviews.llvm.org/D27039 llvm-svn: 290879
* [CodeCompletion][ObjC] Use a parameterized NSSet return type forAlex Lorenz2016-12-081-1/+1
| | | | | | | | keyPathsForValuesAffecting* KVO completion results rdar://23791701 llvm-svn: 289068
* [CodeCompletion] Provide Objective-C class property completion resultsAlex Lorenz2016-12-081-33/+80
| | | | | | | | | | | | This commit provides class property code completion results. It supports explicit and implicit class properties, but the special block completion is done only for explicit properties right now. rdar://25636195 Differential Revision: https://reviews.llvm.org/D27053 llvm-svn: 289058
* [CodeCompletion] Fix incorrect Objective-C block parameter formattingAlex Lorenz2016-11-231-4/+8
| | | | | | | | | | This commit fixes an incorrectly formatted Objective-C block parameter placeholder in a code completion result. The incorrect parameter had a redundant leading parenthesis. rdar://25224416 llvm-svn: 287771
* [CodeCompletion] Show block invocation results for block property settersAlex Lorenz2016-11-091-34/+91
| | | | | | | | | | | | This commit changes the code completion results for block property setters: The default block property result is now a block invocation rather than a simple property reference. rdar://28846196 Differential Revision: https://reviews.llvm.org/D26071 llvm-svn: 286363
* [index] Expose FriendDeclOlivier Goffart2016-11-041-0/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D26285 llvm-svn: 285984
* Remove no-op checks for a null CodeCompleter. We have alreadyChandler Carruth2016-11-041-2/+2
| | | | | | | | | | | | dereferenced the pointer at this point, and these routines are exclusively called after the parser encounters a code completion token. Other code completion routines called at that point do not check for null either, so this is clearly the current invariant expected in the code. This fixes another PVS-Studio found issue. llvm-svn: 285980
* [CodeCompletion] Add a block property setter completion resultAlex Lorenz2016-10-181-22/+67
| | | | | | | | | | | | | | | | | | This commit changes code completion results for Objective-C block properties: clang now suggests an additional completion result that displays the block property together with '=' and the block literal placeholder for the appropriate readwrite block properties. This commit uses a simple heuristic to determine when it's appropriate to suggest a setter completion for block properties: the additional block setter completion is provided iff the member access that's being completed is a standalone statement. rdar://28481726 Differential Revision: https://reviews.llvm.org/D25520 llvm-svn: 284472
* [CodeCompletion][NFC] Extract a function that formats block placeholders.Alex Lorenz2016-10-181-12/+35
| | | | | | | | | | This commit extracts a new function named `formatBlockPlaceholder` from the function `FormatFunctionParameter` so that it can be reused in follow-up commits that improve code completion for block property setters. Differential Revision: https://reviews.llvm.org/D25519 llvm-svn: 284468
* [CodeCompletion][NFC] Extract a function that looks for block decl type locs.Alex Lorenz2016-10-181-37/+50
| | | | | | | | | | This commit extracts a new function named `findTypeLocationForBlockDecl` from the function `FormatFunctionParameter` so that it can be reused in follow-up commits that improve code completion for block property setters. Differential Revision: https://reviews.llvm.org/D25519 llvm-svn: 284467
* [CodeCompletion] Show protocol properties that are accessed through qualified idAlex Lorenz2016-10-121-11/+12
| | | | | | | | | | | | This commit improves code completion for properties that are declared in Objective-C protocols by making sure that properties show up in completions when they are accessed through a qualified id. rdar://24426041 Differential Revision: https://reviews.llvm.org/D25436 llvm-svn: 284007
* [CodeCompletion] Allow system headers providing private symbols with a ↵Argyrios Kyrtzidis2016-07-011-13/+30
| | | | | | | | single underscore. rdar://24677150 llvm-svn: 274314
* Use more ArrayRefsDavid Majnemer2016-06-241-2/+2
| | | | | | No functional change is intended, just a small refactoring. llvm-svn: 273647
* CIndex: add support for static_assertOlivier Goffart2016-06-091-0/+1
| | | | | | Differential Revision: http://reviews.llvm.org/D18080 llvm-svn: 272273
* Make Sema::getPrintingPolicy less ridiculously expensive. This used to performRichard Smith2016-05-191-1/+0
| | | | | | | | | | an identifier table lookup, *and* copy the LangOptions (including various std::vector<std::string>s). Twice. We call this function once each time we start parsing a declaration specifier sequence, and once for each call to Sema::Diag. This reduces the compile time for a sample .c file from the linux kernel by 20%. llvm-svn: 270009
* Prune four superfluous ExternalSemaSource.h includes and one forward ↵Yaron Keren2016-05-131-1/+0
| | | | | | | | declaration in Sema.h where ExternalSemaSource.h was already included due to ExternalSemaSource:: member uses. llvm-svn: 269423
* [MSVC] Implementation of __unaligned as a proper type qualifierAndrey Bokhanko2016-05-111-0/+3
| | | | | | | | | | | This patch implements __unaligned (MS extension) as a proper type qualifier (before that, it was implemented as an ignored attribute). It also fixes PR27367 and PR27666. Differential Revision: http://reviews.llvm.org/D20103 llvm-svn: 269220
* Revert r268727, it caused PR27666.Nico Weber2016-05-061-3/+0
| | | | llvm-svn: 268736
* [MSVC] Implementation of __unaligned as a proper type qualifierAndrey Bokhanko2016-05-061-0/+3
| | | | | | | | | | | This patch implements __unaligned (MS extension) as a proper type qualifier (before that, it was implemented as an ignored attribute). It also fixes PR27367. Differential Revision: http://reviews.llvm.org/D19654 llvm-svn: 268727
* Revert r266415, it broke parsing SDK headers (PR27367).Nico Weber2016-04-151-3/+0
| | | | llvm-svn: 266431
* [MSVC Compat] Implementation of __unaligned (MS extension) as a type qualifierAndrey Bokhanko2016-04-151-0/+3
| | | | | | | | | | | This patch implements __unaligned as a type qualifier; before that, it was modeled as an attribute. Proper mangling of __unaligned is implemented as well. Some OpenCL code/tests are tangenially affected, as they relied on existing number and sizes of type qualifiers. Differential Revision: http://reviews.llvm.org/D18596 llvm-svn: 266415
* [Parse] Code complete expressions in bracket declarators.Benjamin Kramer2016-02-181-0/+4
| | | | | | | | | | Currently we return no results when completing inside of the brackets in a 'char foo[]' declaration. Let the generic expression completion code handle it instead. We could get fancier here (e.g. filter non-constant expressions in contexts where VLAs are not allowed), but it's a strict improvement over the existing version. llvm-svn: 261217
* Class Property: class property and instance property can have the same name.Manman Ren2016-01-281-3/+3
| | | | | | | | | | | | | | | | | | | Add "enum ObjCPropertyQueryKind" to a few APIs that used to only take the name of the property: ObjCPropertyDecl::findPropertyDecl, ObjCContainerDecl::FindPropertyDeclaration, ObjCInterfaceDecl::FindPropertyVisibleInPrimaryClass, ObjCImplDecl::FindPropertyImplDecl, and Sema::ActOnPropertyImplDecl. ObjCPropertyQueryKind currently has 3 values: OBJC_PR_query_unknown, OBJC_PR_query_instance, OBJC_PR_query_class This extra parameter specifies that we are looking for an instance property with the given name, or a class property with the given name, or any property with the given name (if both exist, the instance property will be returned). rdar://23891898 llvm-svn: 259070
* Use instance_properties instead of properties. NFC.Manman Ren2016-01-261-2/+2
| | | | | | | | | | | All current properties are instance properties. This is the second patch in a series of patches to support class properties in addition to instance properties in objective-c. rdar://23891898 llvm-svn: 258824
* Model NamespaceAliasDecls as having their nominated namespace as an underlyingRichard Smith2015-12-291-10/+7
| | | | | | | | | | | | | declaration. This fixes an issue where we would reject (due to a claimed ambiguity) a case where lookup finds multiple NamespaceAliasDecls from different scopes that nominate the same namespace. The C++ standard doesn't make it clear that such a case is in fact valid (which I'm working on fixing), but there are no relevant rules that distinguish using declarations and namespace alias declarations here, so it makes sense to treat them the same way. llvm-svn: 256601
* [Sema] ArrayRef-ize ParseObjCStringLiteral and ↵Craig Topper2015-12-241-5/+5
| | | | | | CodeCompleteObjCProtocolReferences. NFC llvm-svn: 256397
* Split RequireCompleteType into a function that actually requires that the typeRichard Smith2015-12-181-2/+2
| | | | | | | | | | | | | | | | | | | is complete (with an error produced if not) and a function that merely queries whether the type is complete. Either way we'll trigger instantiation if necessary, but only the former will diagnose and recover from missing module imports. The intent of this change is to prevent a class of bugs where code would call RequireCompleteType(..., 0) and then ignore the result. With modules, we must check the return value and use it to determine whether the definition of the type is visible. This also fixes a debug info quality issue: calls to isCompleteType do not trigger the emission of debug information for a type in limited-debug-info mode. This allows us to avoid emitting debug information for type definitions in more cases where we believe it is safe to do so. llvm-svn: 256049
* [Sema] Use getLangOpts in Sema instead of Preprocessor. Call getTargetInfo ↵Craig Topper2015-11-151-3/+3
| | | | | | on the AST context instead of Preprocessor. NFC llvm-svn: 253175
* [libclang] Visit TypeAliasTemplateDeclSergey Kalinichev2015-11-151-0/+1
| | | | | | | | This makes TypeAliasTemplateDecl accessible via LibClang and python bindings Differential Revision: http://reviews.llvm.org/D13844 llvm-svn: 253166
* Define weak and __weak to mean ARC-style weak references, even in MRC.John McCall2015-10-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, __weak was silently accepted and ignored in MRC mode. That makes this a potentially source-breaking change that we have to roll out cautiously. Accordingly, for the time being, actual support for __weak references in MRC is experimental, and the compiler will reject attempts to actually form such references. The intent is to eventually enable the feature by default in all non-GC modes. (It is, of course, incompatible with ObjC GC's interpretation of __weak.) If you like, you can enable this feature with -Xclang -fobjc-weak but like any -Xclang option, this option may be removed at any point, e.g. if/when it is eventually enabled by default. This patch also enables the use of the ARC __unsafe_unretained qualifier in MRC. Unlike __weak, this is being enabled immediately. Since variables are essentially __unsafe_unretained by default in MRC, the only practical uses are (1) communication and (2) changing the default behavior of by-value block capture. As an implementation matter, this means that the ObjC ownership qualifiers may appear in any ObjC language mode, and so this patch removes a number of checks for getLangOpts().ObjCAutoRefCount that were guarding the processing of these qualifiers. I don't expect this to be a significant drain on performance; it may even be faster to just check for these qualifiers directly on a type (since it's probably in a register anyway) than to do N dependent loads to grab the LangOptions. rdar://9674298 llvm-svn: 251041
* [code-completion] Strip outer nullability annotations when completing method ↵Argyrios Kyrtzidis2015-07-241-3/+6
| | | | | | | | | | | | implementations. The outer nullability is transferred from the declaration to the implementation so including them is redundant. The inner ones are not transferred so they are kept to match the exact types. When we transfer the inner ones as well adding them in the implementation will become redundant and we should strip those as well. rdar://21737451 llvm-svn: 243119
* [CodeCompletion] Don't crash on member inits of templated constructors.Benjamin Kramer2015-07-091-3/+7
| | | | | | | Also fixes a crash (on invalid) member functions with a colon initializer. PR23948. llvm-svn: 241811
* [libclang] Replace ObjC generic parameters when code-completing method ↵Douglas Gregor2015-07-071-1/+4
| | | | | | | | implementations. rdar://20643768 llvm-svn: 241559
* [libclang] Fix code-completion of block parameters that are marked with ↵Douglas Gregor2015-07-071-0/+5
| | | | | | | | nullability specifier. rdar://20755276 llvm-svn: 241558
* [libclang] Replace ObjC generic parameters in code-completion results.Douglas Gregor2015-07-071-38/+75
| | | | | | rdar://19369529 llvm-svn: 241557
* Parsing, semantic analysis, and AST for Objective-C type parameters.Douglas Gregor2015-07-071-1/+3
| | | | | | | | | | | | | | | | | | | | Produce type parameter declarations for Objective-C type parameters, and attach lists of type parameters to Objective-C classes, categories, forward declarations, and extensions as appropriate. Perform semantic analysis of type bounds for type parameters, both in isolation and across classes/categories/extensions to ensure consistency. Also handle (de-)serialization of Objective-C type parameter lists, along with sundry other things one must do to add a new declaration to Clang. Note that Objective-C type parameters are typedef name declarations, like typedefs and C++11 type aliases, in support of type erasure. Part of rdar://problem/6294649. llvm-svn: 241541
* Replace __double_underscored type nullability qualifiers with ↵Douglas Gregor2015-06-241-3/+3
| | | | | | | | | | | | | | | | _Uppercase_underscored Addresses a conflict with glibc's __nonnull macro by renaming the type nullability qualifiers as follows: __nonnull -> _Nonnull __nullable -> _Nullable __null_unspecified -> _Null_unspecified This is the major part of rdar://problem/21530726, but does not yet provide the Darwin-specific behavior for the old names. llvm-svn: 240596
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-2/+2
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-2/+2
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* Code completion for nullability type specifiers.Douglas Gregor2015-06-191-13/+58
| | | | | | Another part of rdar://problem/18868820. llvm-svn: 240159
* Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial typesBenjamin Kramer2015-05-291-3/+1
| | | | | | | | | | | | | | | | | | | | If the type isn't trivially moveable emplace can skip a potentially expensive move. It also saves a couple of characters. Call sites were found with the ASTMatcher + some semi-automated cleanup. memberCallExpr( argumentCountIs(1), callee(methodDecl(hasName("push_back"))), on(hasType(recordDecl(has(namedDecl(hasName("emplace_back")))))), hasArgument(0, bindTemporaryExpr( hasType(recordDecl(hasNonTrivialDestructor())), has(constructExpr()))), unless(isInTemplateInstantiation())) No functional change intended. llvm-svn: 238601
* [modules] Stop trying to fake up a linear MacroDirective history.Richard Smith2015-04-291-28/+21
| | | | | | | | | | | | | | Modules builds fundamentally have a non-linear macro history. In the interest of better source fidelity, represent the macro definition information faithfully: we have a linear macro directive history within each module, and at any point we have a unique "latest" local macro directive and a collection of visible imported directives. This also removes the attendent complexity of attempting to create a correct MacroDirective history (which we got wrong in the general case). No functionality change intended. llvm-svn: 236176
* [modules] Determine the set of macros exported by a submodule at the end of ↵Richard Smith2015-04-231-1/+1
| | | | | | | | | | | that submodule. Previously we'd defer this determination until writing the AST, which doesn't allow us to use this information when building other submodules of the same module. This change also allows us to use a uniform mechanism for writing module macro records, independent of whether they are local or imported. llvm-svn: 235614
* [libclang] Fix crash when code-completing inside constructor initializer for ↵Argyrios Kyrtzidis2015-03-131-1/+7
| | | | | | | | a builtin type. rdar://20149746 llvm-svn: 232145
* Cleanup: remove artificial division between lookup results and const lookupRichard Smith2015-02-211-2/+2
| | | | | | | results. No-one was ever modifying a lookup result, and it would not be reasonable to do so. llvm-svn: 230123
* Sema: Turn some applicable functions static. NBC.Francisco Lopes da Silva2015-01-291-9/+10
| | | | llvm-svn: 227418
OpenPOWER on IntegriCloud