Commit Graph

77 Commits

Author SHA1 Message Date
Tim Northover 19ae1175ae Fix FileCheck --check-prefix lines.
Various tests had sprung up over the years which had --check-prefix=ABC on the
RUN line, but "CHECK-ABC:" later on. This happened to work before, but was
strictly incorrect. FileCheck is getting stricter soon though.

Patch by Ron Ofir.

llvm-svn: 188174
2013-08-12 12:51:05 +00:00
Richard Smith 1ab34b3ad5 PR14381: Never skip constexpr function bodies when code-completing. We may need
them in order to parse the rest of the file.

llvm-svn: 168327
2012-11-19 21:13:18 +00:00
Argyrios Kyrtzidis 9ae3956f22 [libclang] Remove the ParentKind cursor kind from code-completion results.
This is to reduce dependency to cursors for the code-completion results.

llvm-svn: 164705
2012-09-26 16:39:56 +00:00
Alexander Kornienko 1d26c02722 Macro history (de-)serialization. Deserialization currently reads only the latest macro definition. Needs more work.
Summary: Passes all tests (+ the new one with code completion), but needs a thorough review in part related to modules.

Reviewers: doug.gregor

Reviewed By: alexfh

CC: cfe-commits, rsmith

Differential Revision: http://llvm-reviews.chandlerc.com/D41

llvm-svn: 164610
2012-09-25 17:18:14 +00:00
Douglas Gregor e3eb777415 Make the spacing of the code completion result for NSDictionary
literals match the spacing introduced by the ObjC modernizer. Fixes
the rest of <rdar://problem/11889572>.

llvm-svn: 162084
2012-08-17 05:40:05 +00:00
Peter Collingbourne 6b4fdc25d3 Fix an assertion failure when code completing an auto variable's initialiser.
llvm-svn: 160857
2012-07-27 12:56:09 +00:00
Douglas Gregor 951de307e4 Remove unnecessary spacing around Objective-C object literal code
completions. Fixes <rdar://problem/11889572>.

llvm-svn: 160407
2012-07-17 23:24:47 +00:00
Dmitri Gribenko 3292d06a1b Add a new libclang completion API to get brief documentation comment that is
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-07-02 17:35:10 +00:00
Jordan Rose 9da05858b4 [completion] Add completions for @"..." and @(...), and tidy up @[] and @{}.
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-15 18:19:56 +00:00
Nick Lewycky 247b4d54ed Add 'env' in hopes of making this test pass on Windows.
llvm-svn: 154785
2012-04-16 03:22:35 +00:00
Nick Lewycky 2bd0ab2b11 Implement the all_lookups_iterator for PCH as a follow-up to r153970. This
includes a patch from Matthias Kleine with a regression testcase!

Adds a new iterator 'data_iterator' to OnDiskHashTable which doesn't try to
reconstruct the external_key from the internal_key, which is useful for traits
that don't store enough information to do that mapping in their key. Also
deletes the 'item_iterator' from OnDiskHashTable as dead code.

llvm-svn: 154784
2012-04-16 02:51:46 +00:00
Douglas Gregor e5c79d5ea8 Provide result types for code completions that describe built-in
expressions (this, sizeof, etc.).

llvm-svn: 142424
2011-10-18 21:20:17 +00:00
Argyrios Kyrtzidis 5cec2aea3f Support code-completion for C++ inline methods and ObjC buffering methods.
Previously we would cut off the source file buffer at the code-completion
point; this impeded code-completion inside C++ inline methods and,
recently, with buffering ObjC methods.

Have the code-completion inserted into the source buffer so that it can
be buffered along with a method body. When we actually hit the code-completion
point the cut-off lexing or parsing.

Fixes rdar://10056932&8319466

llvm-svn: 139086
2011-09-04 03:32:15 +00:00
Argyrios Kyrtzidis 7d94c9277a Fix an assertion when code-completing, rdar://9288730 & http://llvm.org/PR9728.
llvm-svn: 130042
2011-04-23 01:04:12 +00:00
Douglas Gregor c05f657d83 Don't suggest dynamic_cast or typeid as code completion results when
RTTI is disabled. Similarly, don't suggest throw or try as code
completion results when C++ exceptions are disabled. Fixes
<rdar://problem/9193560>.

llvm-svn: 129346
2011-04-12 02:47:21 +00:00
Douglas Gregor 9c7bd2f535 Don't crash when code-completing after "#include <". It would be far
better to actually produce a decent set of completions by checking the
system include paths, but not today. Fixes PR8744.

llvm-svn: 121431
2010-12-09 23:35:36 +00:00
Douglas Gregor 928479e727 Revert the fix for PR8013.
That bug concerned the well-formedness of code such as (&ovl)(a, b,
c). GCC rejects the code, while EDG accepts it. On further study of the
standard, I see no support for EDG's position: in particular, C++
[over.over] does not list this as a context where we can take the
address of an overloaded function, C++ [over.call.func] does not
reference the address-of operator at any point, and C++ [expr.call]
claims that the function argument in a call is either a function
lvalue or a pointer-to-function; (&ovl) is neither.

llvm-svn: 118620
2010-11-09 20:03:54 +00:00
Douglas Gregor 8f225bb508 Handle overload resolution when calling an overloaded function set
with, e.g., (&f)(a, b, c). Fixes PR8013.

llvm-svn: 118508
2010-11-09 16:13:15 +00:00
Dan Gohman 2f76cd756a Add support for code completion on stdin.
llvm-svn: 117414
2010-10-26 23:21:25 +00:00
Douglas Gregor 8ed5b77008 Fix the mapping of vertical-space cursor kinds to produce a newline,
rather than a space.

llvm-svn: 116097
2010-10-08 20:39:29 +00:00
Douglas Gregor 400f59763b When provide code completions for a variadic Objective-C method
declaration send or a variadic function call, collapse the ", ..."
into the parameter before it, so that we don't get a second
placeholder.

llvm-svn: 112579
2010-08-31 05:13:43 +00:00
Douglas Gregor 85b5063f2c When performing code completion for a case statement in a switch whose
condition is not of enumeration type, provide code-completion results
containing all values of integral or enumeral type.

llvm-svn: 109677
2010-07-28 21:50:18 +00:00
Douglas Gregor 9f1570d993 Only filter out names reserved for the implementation (e.g., __blah or
_Foo) from code-completion results when they come from a system
header.

llvm-svn: 108338
2010-07-14 17:44:04 +00:00
Douglas Gregor f4c33349b5 Make -code-completion-patterns only cover multi-line code
completions. Plus, tweak a few completion patterns to better reflect
the language grammar.

llvm-svn: 104905
2010-05-28 00:22:41 +00:00
Douglas Gregor f64acca2f5 Only enable code patterns (e.g., try { statements } catch (...) {
statements }) in the code-completion results if explicitly requested.

llvm-svn: 104637
2010-05-25 21:41:55 +00:00
Chris Lattner 561aabd943 when code completing inside a C-style block comment, don't emit errors about
a missing */ since we truncated the file.

This fixes rdar://7948776

llvm-svn: 103913
2010-05-16 19:54:05 +00:00
Douglas Gregor c01890e1cc When code completion produces an overload set as its results (e.g.,
while we're completing in the middle of a function call), also produce
"ordinary" name results that show what can be typed at that point.

llvm-svn: 100558
2010-04-06 20:19:47 +00:00
Douglas Gregor 2cb6c30673 Do not produce semicolons at the end of code-completion results
llvm-svn: 100557
2010-04-06 20:11:37 +00:00
Douglas Gregor 285560929f Only prove macros as code-completion results when we're in a case
statement or for ordinary names. This means that we won't show macros
when completing, e.g., member expressions such as "p->".

llvm-svn: 100555
2010-04-06 20:02:15 +00:00
John McCall 85f9055955 When pretty-printing tag types, only print the tag if we're in C (and
therefore not creating ElaboratedTypes, which are still pretty-printed
with the written tag).

Most of these testcase changes were done by script, so don't feel too
sorry for my fingers.

llvm-svn: 98149
2010-03-10 11:27:22 +00:00
Douglas Gregor ff59f676d0 Teach code-completion to deal with calls to functions without prototypes.
llvm-svn: 94076
2010-01-21 15:46:19 +00:00
Douglas Gregor 52ce62f069 Improve the sorting of code-completion results. We now always sort by
the "typed" text, first, then take into account
nested-name-specifiers, name hiding, etc. This means that the
resulting sort is actually alphabetical :)

llvm-svn: 93370
2010-01-13 23:24:38 +00:00
Douglas Gregor 504a6ae83e Improve code completion by introducing patterns for the various C and
C++ grammatical constructs that show up in top-level (namespace-level)
declarations, member declarations, template declarations, statements,
expressions, conditions, etc. For example, we now provide a pattern
for

  static_cast<type>(expr)

when we can have an expression, or

  using namespace identifier;

when we can have a using directive.

Also, improves the results of code completion at the beginning of a
top-level declaration. Previously, we would see value names (function
names, global variables, etc.); now we see types, namespace names,
etc., but no values.

llvm-svn: 93134
2010-01-10 23:08:15 +00:00
Douglas Gregor 9882a5aac6 Teach Preprocessor::macro_begin/macro_end to lazily load all macro
definitions from a precompiled header. This ensures that
code-completion with macro names behaves the same with or without
precompiled headers.

llvm-svn: 92497
2010-01-04 19:18:44 +00:00
Douglas Gregor b3fa919c2d Extend code-completion results with the type of each result
llvm-svn: 91702
2009-12-18 18:53:37 +00:00
Daniel Dunbar 8fbe78f6fc Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.
- This is designed to make it obvious that %clang_cc1 is a "test variable"
   which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it
   can be useful to redefine what gets run as 'clang -cc1' (for example, to set
   a default target).

llvm-svn: 91446
2009-12-15 20:14:24 +00:00
Fariborz Jahanian a01b67d7b0 Make tests use the new clang -cc1 flag.
llvm-svn: 91303
2009-12-14 18:00:56 +00:00
Douglas Gregor 0f622367d3 Add a function's cv-qualifiers to the code-completion results as an
informative chunk.

llvm-svn: 91139
2009-12-11 18:44:16 +00:00
Douglas Gregor 800f2f0ff0 Teach code completion to instantiate templates when it needs to
llvm-svn: 91138
2009-12-11 18:28:39 +00:00
Douglas Gregor 7078839b0e Member function templates can occur after . or ->
llvm-svn: 91137
2009-12-11 18:14:22 +00:00
Douglas Gregor 99fe2ad8c8 Tweak code-completion results by suppressing class template
specializations and class template partial specializations (they're
never named directly). Also, member access expressions only refer to
value declarations (fields, functions, enumerators, etc.) and
Objective-C property declarations; filter out everything else.

llvm-svn: 91133
2009-12-11 17:31:05 +00:00
Douglas Gregor 83c49b56fe Class template (partial) specializations should not show up in code completion results
llvm-svn: 91125
2009-12-11 16:18:54 +00:00
Douglas Gregor 45f83ee87d Improve code-completion results for the flags in an @property
declaration by providing patterns for "getter = <method>" and "setter
= <method>". As part of this, invented a new "pattern" result kind
that is merely a semantic string. The "pattern" result kind should
help with other kinds of code templates.

llvm-svn: 89277
2009-11-19 00:01:57 +00:00
Douglas Gregor bab2b3c70f Refactor code-completion support for message sends, collecting the
code to find and add Objective-C methods (starting at an
ObjCContainerDecl) into a single, static function. Also, make sure
that we search into the implementations of classes and categories to
find even more methods.

llvm-svn: 89163
2009-11-17 23:22:23 +00:00
Daniel Dunbar 34546ce43d Remove RUN: true lines.
llvm-svn: 86432
2009-11-08 01:47:25 +00:00
Daniel Dunbar 8b57697954 Eliminate &&s in tests.
- 'for i in $(find . -type f); do sed -e 's#\(RUN:.*[^ ]\) *&& *$#\1#g' $i | FileUpdate $i; done', for the curious.

llvm-svn: 86430
2009-11-08 01:45:36 +00:00
Steve Naroff eae650366d Add basic code completion support for ObjC messages.
Still a work in progress...

llvm-svn: 86323
2009-11-07 02:08:14 +00:00
Douglas Gregor 9eb7701dff Various improvements to Clang's code-completion infrastructure:
- Introduce more code-completion string "chunk" kinds that describe
  symbols, the actual text that the user is expected to type, etc.
  - Make the generation of macro results optional, since it can be
  slow
  - Make code-completion accessible through the C API, marshalling the
  code-completion results through a temporary file (ick) to maintain
  process separation.

The last doesn't have tests yet.

llvm-svn: 86306
2009-11-07 00:00:49 +00:00
Douglas Gregor f329c7c3c0 Include macros in code-completion results
llvm-svn: 85594
2009-10-30 16:50:04 +00:00
Steve Naroff 3b08630b06 - Fixup SortCodeCompleteResult() to properly sort keywords on Mac OS (compare was system dependent). Worked on Linux, failed on Mac OS (which caused the recently added testcase to fail on Linux).
- Sort results in testcase.

llvm-svn: 83597
2009-10-08 23:45:10 +00:00