aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaCodeComplete.cpp
AgeCommit message (Collapse)AuthorFilesLines
2013-01-31When code completing in a statement, parenthesized expression, orDouglas Gregor1-1/+9
Objective-C message receiver, the user is as likely to want to write a type name as any other declaration, so give types the same priority as other declarations. Fixes <rdar://problem/12480600>. llvm-svn: 174038
2013-01-31Allow the computation of the base priority for a declaration code completion ↵Douglas Gregor1-19/+65
result to consider the completion context llvm-svn: 174037
2013-01-30Add "instancetype" as a code completion result for the return type ofDouglas Gregor1-0/+5
an Objective-C method. Fixes <rdar://problem/13069990>. llvm-svn: 173905
2013-01-30The instance methods of the root class of an Objective-C hieararchyDouglas Gregor1-2/+6
can be messaged via the metaclass. Provide code completions for this case. Fixes <rdar://problem/12560296>. llvm-svn: 173903
2013-01-23Use 'const Decl *' throughout code completion in SemaDmitri Gribenko1-116/+125
llvm-svn: 173277
2013-01-16Rework the traversal of Objective-C categories and extensions toDouglas Gregor1-27/+48
consider (sub)module visibility. The bulk of this change replaces myriad hand-rolled loops over the linked list of Objective-C categories/extensions attached to an interface declaration with loops using one of the four new category iterator kinds: visible_categories_iterator: Iterates over all visible categories and extensions, hiding any that have their "hidden" bit set. This is by far the most commonly used iterator. known_categories_iterator: Iterates over all categories and extensions, ignoring the "hidden" bit. This tends to be used for redeclaration-like traversals. visible_extensions_iterator: Iterates over all visible extensions, hiding any that have their "hidden" bit set. known_extensions_iterator: Iterates over all extensions, whether they are visible to normal name lookup or not. The effect of this change is that any uses of the visible_ iterators will respect module-import visibility. See the new tests for examples. Note that the old accessors for categories and extensions are gone; there are *Raw() forms for some of them, for those (few) areas of the compiler that have to manipulate the linked list of categories directly. This is generally discouraged. Part two of <rdar://problem/10634711>. llvm-svn: 172665
2013-01-12Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko1-1/+1
brought into 'clang' namespace by clang/Basic/LLVM.h llvm-svn: 172323
2013-01-11Constify parameter of clang::getCursorKindForDeclDmitri Gribenko1-2/+2
llvm-svn: 172249
2013-01-02s/CPlusPlus0x/CPlusPlus11/gRichard Smith1-5/+5
llvm-svn: 171367
2012-12-20Revert r170500. It over-zealously converted *ALL* things named Attributes, ↵Bill Wendling1-19/+19
which is wrong here. llvm-svn: 170721
2012-12-19Rename the 'Attributes' class to 'Attribute'. It's going to represent a ↵Bill Wendling1-19/+19
single attribute in the future. llvm-svn: 170500
2012-12-19Change DeclContextLookup(Const)Result to (Mutable)ArrayRef<NamedDecl*>, as ↵David Blaikie1-3/+4
per review discussion in r170365 This does limit these typedefs to being sequences, but no current usage requires them to be contiguous (we could expand this to a more general iterator pair range concept at some point). Also, it'd be nice if SmallVector were constructible directly from an ArrayRef but this is a bit tricky since ArrayRef depends on SmallVectorBaseImpl for the inverse conversion. (& generalizing over all range-like things, while nice, would require some nontrivial SFINAE I haven't thought about yet) llvm-svn: 170482
2012-12-04Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth1-6/+6
uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
2012-10-18From Vassil Vassilev: enable Sema to deal with multiple ExternalSemaSources.Axel Naumann1-3/+3
llvm-svn: 166208
2012-10-09If a macro has been #undef'd in a precompiled header, we still need toDouglas Gregor1-14/+12
write out the macro history for that macro. Similarly, we need to cope with reading a macro definition that has been #undef'd. Take advantage of this new ability so that global code-completion results can refer to #undef'd macros, rather than losing them entirely. For multiply defined/#undef'd macros, we will still get the wrong result, but it's better than getting no result. llvm-svn: 165502
2012-10-05[libclang] Introduce CXCursor_ModuleImportDecl cursor kind, used for a moduleArgyrios Kyrtzidis1-0/+3
import declaration. llvm-svn: 165277
2012-09-27[libclang] Always report a CXCursor_MacroDefinition for code-completionArgyrios Kyrtzidis1-1/+3
results for a macro name, not CXCursor_NotImplemented. llvm-svn: 164740
2012-09-26[libclang] Remove the ParentKind cursor kind from code-completion results.Argyrios Kyrtzidis1-1/+0
This is to reduce dependency to cursors for the code-completion results. llvm-svn: 164705
2012-09-06Remove unused typedefs. Found by gcc48.Roman Divacky1-12/+0
llvm-svn: 163327
2012-08-31Improved MSVC __interface support by adding first class support for it, ↵Joao Matos1-4/+9
instead of aliasing to "struct" which had some incorrect behaviour. Patch by David Robins. llvm-svn: 163013
2012-08-29Keep history of macro definitions and #undefsAlexander Kornienko1-1/+5
Summary: Summary: Keep history of macro definitions and #undefs with corresponding source locations, so that we can later find out all macros active in a specified source location. We don't save the history in PCH (no need currently). Memory overhead is about sizeof(void*)*3*<number of macro definitions and #undefs>+<in-memory size of all #undef'd macros> I've run a test on a file composed of 109 .h files from boost 1.49 on x86-64 linux. Stats before this patch: *** Preprocessor Stats: 73222 directives found: 19171 #define. 4345 #undef. #include/#include_next/#import: 5233 source files entered. 27 max include stack depth 19210 #if/#ifndef/#ifdef. 2384 #else/#elif. 6891 #endif. 408 #pragma. 14466 #if/#ifndef#ifdef regions skipped 80023/451669/1270 obj/fn/builtin macros expanded, 85724 on the fast path. 127145 token paste (##) operations performed, 11008 on the fast path. Preprocessor Memory: 5874615B total BumpPtr: 4399104 Macro Expanded Tokens: 417768 Predefines Buffer: 8135 Macros: 1048576 #pragma push_macro Info: 0 Poison Reasons: 1024 Comment Handlers: 8 Stats with this patch: ... Preprocessor Memory: 7541687B total BumpPtr: 6066176 Macro Expanded Tokens: 417768 Predefines Buffer: 8135 Macros: 1048576 #pragma push_macro Info: 0 Poison Reasons: 1024 Comment Handlers: 8 In my test increase in memory usage is about 1.7Mb, which is ~28% of initial preprocessor's memory usage and about 0.8% of clang's total VMM allocation. As for CPU overhead, it should only be noticeable when iterating over all macros, and should mostly consist of couple extra dereferences and one comparison per macro + skipping of #undef'd macros. It's less trivial to measure, though, as the preprocessor consumes a very small fraction of compilation time. Reviewers: doug.gregor, klimek, rsmith, djasper Reviewed By: doug.gregor CC: cfe-commits, chandlerc Differential Revision: http://llvm-reviews.chandlerc.com/D28 llvm-svn: 162810
2012-08-23Fix a bunch of -Wdocumentation warnings.Dmitri Gribenko1-1/+1
llvm-svn: 162452
2012-08-21Screw around with ObjCRuntime some more, changing theJohn McCall1-2/+1
diagnostics for bad deployment targets and adding a few more predicates. Includes a patch by Jonathan Schleifer to enable ARC for ObjFW. llvm-svn: 162252
2012-08-20Code-complete 'weak' for properties under ARC-with-weak-references (or GC)Jordan Rose1-10/+14
Also, suggest 'readonly' even if the property has been given an ownership attribute ('strong', 'weak', etc). This is used when properties are declared readonly in the public interface but readwrite in a class extension. <rdar://problem/11500004&11932285> llvm-svn: 162220
2012-08-17Make the spacing of the code completion result for NSDictionaryDouglas Gregor1-1/+0
literals match the spacing introduced by the ObjC modernizer. Fixes the rest of <rdar://problem/11889572>. llvm-svn: 162084
2012-08-11Attaching comments to declarations: find comment attached to any redeclarationDmitri Gribenko1-1/+1
Not only look for the comment near the declaration itself, but also walk the redeclaration chain: the previous declaration might have had a documentation comment. llvm-svn: 161722
2012-08-10Provide isConst/Volatile on CXXMethodDecl.David Blaikie1-3/+3
This also provides isConst/Volatile/Restrict on FunctionTypes to coalesce the implementation with other callers (& update those other callers). Patch contributed by Sam Panzer (panzer@google.com). llvm-svn: 161647
2012-07-17Remove unnecessary spacing around Objective-C object literal codeDouglas Gregor1-9/+3
completions. Fixes <rdar://problem/11889572>. llvm-svn: 160407
2012-07-02Add a new libclang completion API to get brief documentation comment that isDmitri Gribenko1-4/+14
attached to a declaration in the completion string. Since extracting comments isn't free, a new code completion option is introduced. A new code completion option that enables including brief comments into CodeCompletionString should be a, err, code completion option. But because ASTUnit caches global declarations during parsing before even completion consumer is created, the option is duplicated as a translation unit option (in both libclang and ASTUnit, like the option to cache code completion results). llvm-svn: 159539
2012-06-30Add support for the C11 _Alignof keyword.Jordan Rose1-0/+13
This behaves like the existing GNU __alignof and C++11 alignof keywords; most of the patch is simply adding the third token spelling to various places. llvm-svn: 159494
2012-06-17Documentation cleanup: fix two typos, rief -> brief and Descripts -> DescribesJames Dennett1-2/+2
llvm-svn: 158630
2012-06-15[completion] Add completions for @"..." and @(...), and tidy up @[] and @{}.Jordan Rose1-2/+20
Specifically, @[] and @{} didn't have a type associated with them; we now use "NSArray *" and "NSDictionary *", respectively. @"" has the type "NSString *". @(), unfortunately, has type "id", since it (currently) may be either an NSNumber or an NSString. Add a test for all the Objective-C at-expression completions. <rdar://problem/11507708&11507668&11507711> llvm-svn: 158533
2012-06-14Still more Doxygen documentation fixes:James Dennett1-3/+0
* Escape #, < and @ symbols where Doxygen would try to interpret them; * Fix several function param documentation where names had got out of sync; * Delete param documentation referring to parameters that no longer exist. llvm-svn: 158472
2012-06-14This makes SemaCodeComplete.cpp more Doxygen-friendly by changing theJames Dennett1-30/+31
OBJC_AT_KEYWORD_NAME take a string literal argument where previously its second argument was an unquoted token; macro invocations such as OBJC_AT_KEYWORD_NAME(NeedAt,{) confuse Doxygen's parser. While I'm wary of changing code (rather than just comments) to work around Doxygen's limitations, in this case the change makes the code more readable for human beings as well, and the macro derived no benefit from using the preprocessor's stringification operator, as it never has need of the unquoted token. I've also included a couple of trivial drive-by fixes to doc comments. llvm-svn: 158440
2012-06-12When code completion walks the members of a protocol or interface,Douglas Gregor1-13/+45
make sure that we walk the definition. Fixes <rdar://problem/11427742>. llvm-svn: 158357
2012-06-08Convert comments to proper Doxygen comments.Dmitri Gribenko1-3/+3
llvm-svn: 158241
2012-06-06Revert Decl's iterators back to pointer value_type rather than reference ↵David Blaikie1-12/+12
value_type In addition, I've made the pointer and reference typedef 'void' rather than T* just so they can't get misused. I would've omitted them entirely but std::distance likes them to be there even if it doesn't use them. This rolls back r155808 and r155869. Review by Doug Gregor incorporating feedback from Chandler Carruth. llvm-svn: 158104
2012-05-05Make BuiltinType::getName return a StringRef and introduce ↵Argyrios Kyrtzidis1-1/+1
BuiltinType::getNameAsCString to get a const char* if necessary. This avoids unnecessary conversions when we want to use the result of getName as a StringRef. Part of rdar://10796159 llvm-svn: 156227
2012-04-30clang_getCursorLexicalParent should return a translation unit cursor for ↵Douglas Gregor1-0/+1
declarations at the global scope, from Evan P. Fixes PR9083. llvm-svn: 155858
2012-04-30Remove the ref/value inconsistency in filter_decl_iterator.David Blaikie1-16/+16
filter_decl_iterator had a weird mismatch where both op* and op-> returned T* making it difficult to generalize this filtering behavior into a reusable library of any kind. This change errs on the side of value, making op-> return T* and op* return T&. (reviewed by Richard Smith) llvm-svn: 155808
2012-04-10Include the Objective-C parameter- and return-passing qualifiers whenDouglas Gregor1-5/+15
providing code completions for Objective-C method declarations. Fixes <rdar://problem/11164498>. llvm-svn: 154421
2012-04-10Don't include the ':' following code-completion suggestions forDouglas Gregor1-3/+6
'public', 'private', or 'protected', unless code completion patterns are enabled. Fixes <rdar://problem/11189132>. llvm-svn: 154413
2012-04-10[code-complete] Introduce CodeCompletionTUInfo which will be used for cachingArgyrios Kyrtzidis1-37/+114
code-completion related strings specific to a translation unit (ASTContext and related data) CodeCompletionAllocator does such limited caching, by caching the name assigned to a DeclContext*, but that is not the appropriate place since that object has a lifetime that can extend beyond that of an ASTContext. Introduce CodeCompletionTUInfo which will be always tied to a translation unit to do this kind of caching and move the caching of CodeCompletionAllocator into this object, and propagate it to all the places where it will be needed. The plan is to extend the caching where appropriate, using CodeCompletionTUInfo, to avoid re-calculating code-completion strings. Part of rdar://10796159. llvm-svn: 154408
2012-04-03Remove more redundant lookups. Add a new "all_lookups_iterator" which providesNick Lewycky1-9/+1
a view over the contents of a DeclContext without exposing the implementation details of the StoredDeclsMap. Use this in LookupVisibleDecls to find the visible declarations. Fixes PR12339! llvm-svn: 153970
2012-03-27Introduce a new libclang API to determine the parent context of a codeDouglas Gregor1-34/+22
completion item. For example, if the code completion itself represents a declaration in a namespace (say, std::vector), then this API retrieves the cursor kind and name of the namespace (std). Implements <rdar://problem/11121951>. llvm-svn: 153545
2012-03-26Move CodeCompletionBuilder's chunk adding methods out of line.Benjamin Kramer1-38/+31
This makes sense because chunk's ctor is also out of line and simplifies considerably when inlined with a constant parameter. Shrinks clang on i386-linux-Release+Asserts by 65k. llvm-svn: 153446
2012-03-13[Sema] Prefer to use ObjCInterfaceDecl's protocol_begin()/protocol_end() ↵Argyrios Kyrtzidis1-3/+2
iterators instead of ObjCInterfaceDecl::getReferencedProtocols(), because the iterators are safe to use even if the caller did not check that the interface is a definition. llvm-svn: 152597
2012-03-11Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie1-71/+71
(Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
2012-03-06Add clang support for new Objective-C literal syntax for NSDictionary, NSArray,Ted Kremenek1-0/+20
NSNumber, and boolean literals. This includes both Sema and Codegen support. Included is also support for new Objective-C container subscripting. My apologies for the large patch. It was very difficult to break apart. The patch introduces changes to the driver as well to cause clang to link in additional runtime support when needed to support the new language features. Docs are forthcoming to document the implementation and behavior of these features. llvm-svn: 152137
2012-02-25ArrayRef'ize various functions in the AST/Parser/Sema.Ahmed Charles1-19/+17
llvm-svn: 151447