Commit Graph

531 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis 4c6efa62e0 [libclang] Annotation of parameters that got default args from a previous declarations was
broken because the end location of the parameter was the end location of the default arg,
resulting in a source range that could begin in one file and end in another.

llvm-svn: 136572
2011-07-30 17:23:26 +00:00
Douglas Gregor 4ecb7209bf Add code completion to produce "else" blocks after an "if"
statement. Fixes <rdar://problem/9229438>.

llvm-svn: 136564
2011-07-30 08:36:53 +00:00
Douglas Gregor 0c50531a46 When producing code completion results for variadic macros, fold the
variadic bit (", ..." or ", args...") into the prior placeholder, like
we do with functions and methods. Fixes <rdar://problem/9740808>.

llvm-svn: 136563
2011-07-30 08:17:44 +00:00
Douglas Gregor 8f08d74ee5 Add the various parameter-passing keywords for Distributed Objects
(such as in, inout, byref, and oneway) to code completion
results. Fixes <rdar://problem/8844158>.

llvm-svn: 136562
2011-07-30 07:55:26 +00:00
Douglas Gregor 2c595adf2e When performing code completion after at @interface, allow both
already-defined and forward-declared results. Already-defined results
are fine because they could be the start of a category. Fixes
<rdar://problem/9811691>.

llvm-svn: 136559
2011-07-30 06:55:39 +00:00
Douglas Gregor ea777403f9 Add new libclang API, clang_codeCompleteGetObjCSelector(), which
provides the partial Objective-C selector used in a code
completion. From Connor Wakamo!

llvm-svn: 136084
2011-07-26 15:24:30 +00:00
Douglas Gregor c1679ecf3b Added clang_getCursorReferenceNameRange to libclang to to retrieve parts of
a cursor reference, from Erik Verbruggen!

llvm-svn: 135920
2011-07-25 17:48:11 +00:00
Douglas Gregor 63745d5935 New libclang API to expose container type for code completion, from
Connor Wakamo!

llvm-svn: 135651
2011-07-21 01:05:26 +00:00
Douglas Gregor 925296b4c2 Revamp the SourceManager to separate the representation of parsed
source locations from source locations loaded from an AST/PCH file.

Previously, loading an AST/PCH file involved carefully pre-allocating
space at the beginning of the source manager for the source locations
and FileIDs that correspond to the prefix, and then appending the
source locations/FileIDs used for parsing the remaining translation
unit. This design forced us into loading PCH files early, as a prefix,
whic has become a rather significant limitation.

This patch splits the SourceManager space into two parts: for source
location "addresses", the lower values (growing upward) are used to
describe parsed code, while upper values (growing downward) are used
for source locations loaded from AST/PCH files. Similarly, positive
FileIDs are used to describe parsed code while negative FileIDs are
used to file/macro locations loaded from AST/PCH files. As a result,
we can load PCH/AST files even during parsing, making various
improvemnts in the future possible, e.g., teaching #include <foo.h> to
look for and load <foo.h.gch> if it happens to be already available.

This patch was originally written by Sebastian Redl, then brought
forward to the modern age by Jonathan Turner, and finally
polished/finished by me to be committed.

llvm-svn: 135484
2011-07-19 16:10:42 +00:00
Douglas Gregor 397745e540 When creating a property in a class extension, make sure to check its
attributes. Fixes <rdar://problem/9561076>.

llvm-svn: 135273
2011-07-15 15:30:21 +00:00
Chandler Carruth 9e4704ab07 Update all of the libclang code corresponding to the preprocessor
MacroInstantiation -> MacroExpansion rename. Internally, everything is
switched.

Introduce a new cursor kind enum with the new name, but retain the old
name as an alias so that we don't break backwards compatibility.

Also update the debug printing routine to use 'macro expansions' as its
explicitly not guaranteed to be stable, and mechanically switch the test
cases over to that.

llvm-svn: 135140
2011-07-14 08:41:15 +00:00
Douglas Gregor 2132584d36 Introduce a new libclang aPI function,
clang_codeCompleteGetContexts(), that provides the client with
information about the context in which code completion has occurred
and what kinds of entities make sense as completions at that
point. Patch by Connor Wakamo!

llvm-svn: 134615
2011-07-07 16:03:39 +00:00
Douglas Gregor 8a60bbe13f Keep track of when "unrecoverable" errors occur, then allow
clang_saveTranslationUnit() to save a PCH file if the only errors it
contains are recoverable errors. Fixes <rdar://problem/9727804>.

llvm-svn: 134503
2011-07-06 17:40:26 +00:00
Argyrios Kyrtzidis d289104e29 [libclang] Avoid having the cursor of an expression replace the declaration cursor
when the expression source range overlaps the declaration range.

This can happen for C++ constructor expressions whose range generally
include the variable declaration, e.g.:

  MyCXXClass foo; // Make sure pointing at 'foo' returns a VarDecl cursor.

rdar://9124499.

llvm-svn: 133930
2011-06-27 19:42:23 +00:00
Argyrios Kyrtzidis 66cd1dacbc [libclang] Avoid having the cursor of an expression "overwrite" the annotation of the
variable declaration that it belongs to.

This can happen for C++ constructor expressions whose range generally
include the variable declaration, e.g.:

  MyCXXClass foo; // Make sure we don't annotate 'foo' as a CallExpr cursor.

rdar://9124499.

llvm-svn: 133929
2011-06-27 19:42:20 +00:00
John McCall 31168b077c Automatic Reference Counting.
Language-design credit goes to a lot of people, but I particularly want
to single out Blaine Garst and Patrick Beard for their contributions.

Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself,
in no particular order.

llvm-svn: 133103
2011-06-15 23:02:42 +00:00
Fariborz Jahanian bf31c4e4ca Update Indexer test for new 'atomic' keyword.
llvm-svn: 132918
2011-06-13 16:42:02 +00:00
Fariborz Jahanian 1c2d29e3c3 Add code completetion code for the new 'atomic' attribute
keyword in objc property decl.

llvm-svn: 132877
2011-06-11 17:14:27 +00:00
Douglas Gregor 4cd65962dc Expose @synthesize and @dynamic via their own cursor kinds in
libclang. Fixes <rdar://problem/9537904>.

llvm-svn: 132603
2011-06-03 23:08:58 +00:00
Douglas Gregor 857bcdaf03 Tweak code completions for Objective-C Key-Value Observing. The
+keyPathsForValuesAffecting<Key> completion was mislabeled as an
instance method, and +automaticallyNotifiesObserversOf<Key> was
missing entirely. Fixes <rdar://problem/9516762>.

llvm-svn: 132452
2011-06-02 04:02:27 +00:00
Douglas Gregor a8d0c774da Add c-index-test printing and tests for static and virtual method
query functions, from Erik Verbruggen!

llvm-svn: 131295
2011-05-13 15:54:42 +00:00
Douglas Gregor 998caead70 Introduce a new libclang parsing flag,
CXTranslationUnit_NestedMacroInstantiations, which indicates whether
we want to see "nested" macro instantiations (e.g., those that occur
inside other macro instantiations) within the detailed preprocessing
record. Many clients (e.g., those that only care about visible tokens)
don't care about this information, and in code that uses preprocessor
metaprogramming, this information can have a very high cost.

Addresses <rdar://problem/9389320>.

llvm-svn: 130990
2011-05-06 16:33:08 +00:00
Douglas Gregor 951471482c When providing code completions for an Objective-C property access,
also include methods with zero-argument selectors. Implements
<rdar://problem/9048332>.

llvm-svn: 130922
2011-05-05 15:50:42 +00:00
Douglas Gregor d4a8cede47 When adding KVC code completions, keep track of all of the selectors
that we've previously seen, both in declared methods and from previous
KVC completions, to eliminate duplicates. Fixes <rdar://problem/9162207>.

llvm-svn: 130890
2011-05-04 23:50:46 +00:00
Douglas Gregor 37aa4938c8 Introduce a new libclang API, clang_isFileMultipleIncludeGuarded(),
which determines whether a particular file is actually a header that
is intended to be guarded from multiple inclusions within the same
translation unit.

llvm-svn: 130808
2011-05-04 00:14:37 +00:00
Ted Kremenek 9c10d0a3ce Use the canonical decl when generating the locations for USRs.
llvm-svn: 130748
2011-05-03 01:33:35 +00:00
Chandler Carruth 73aa8f7027 Based on the new information in the AST provided by r130628, write
3 lines of code and improve a bunch of information in the libclang view
of the code.

Updates the two tests that exercise this with the new data, checking
that each new source location actually points back to the declared
template parameter.

llvm-svn: 130656
2011-05-01 09:53:37 +00:00
Argyrios Kyrtzidis fddbcfbec4 Don't waste memory if the initializer expression is empty.
llvm-svn: 130420
2011-04-28 18:53:55 +00:00
Fariborz Jahanian c057794adb Fixes an instance method meta-data generation bug in
ObjC NeXt runtime where method pointer registered in
metadata belongs to an unrelated method. Ast part of this fix,
I turned at @end missing warning (for class
implementations) into an error as we can never
be sure that meta-data being generated is correct.
// rdar://9072317

llvm-svn: 130019
2011-04-22 22:02:28 +00:00
Argyrios Kyrtzidis b2ed28ea4b For
double data[20000000] = {0};

we would blow out the memory by creating 20M Exprs to fill out the initializer.

To fix this, if the initializer list initializes an array with more elements than
there are initializers in the list, have InitListExpr store a single 'ArrayFiller' expression
that specifies an expression to be used for value initialization of the rest of the elements.

Fixes rdar://9275920.

llvm-svn: 129896
2011-04-21 00:27:41 +00:00
Douglas Gregor 07542c5b2d When translating a Clang source range into a libclang source range,
adjust the a ending macro location to the end of the instantiation
location before adjusting it to the end of the token. Fixes
<rdar://problem/9021561>.

llvm-svn: 129872
2011-04-20 21:16:21 +00:00
Douglas Gregor 6c7a9eec42 When providing code completions of ivar names for a property
implementation such as

  @synthesize Prop1 = 

Give priority to ivars whose type matches or closely matches the
property type (as we do for several other kinds of
results). Additionally, if there is an ivar with the same name as the
property, or differs only due to a _ prefix or suffix, give that ivar
a priority bump. Finally, verify that this search is properly
returning ivars within class extensions and implementations
(<rdar://problem/8488854>).

llvm-svn: 129699
2011-04-18 14:40:46 +00:00
Douglas Gregor 331faa0f73 When producing code completion results for the Objective-C property
implementation 

  @synthesize <property> = 

also produce a completion for a to-be-synthesized ivar named
_<property>.

llvm-svn: 129697
2011-04-18 14:13:53 +00:00
Douglas Gregor af670a81e9 When determining the "usage" type of a declaration for the purposes of code
completion, look through block pointer and function pointer types to the
result type of the block/function. Fixes <rdar://problem/9282583>.

llvm-svn: 129535
2011-04-14 20:33:34 +00:00
Chandler Carruth f20ec92331 Apply a bug-fix patch from Marcin Kowalczyk to the source locations for
a couple of operator overloads which form interesting expressions in the
AST.

I added test cases for both bugs with the c-index-test's token
annotation feature. Also, thanks to John McCall for confirming that this
is the correct solution.

llvm-svn: 128768
2011-04-02 09:47:38 +00:00
Argyrios Kyrtzidis bbbeea11a8 For Diagnostic::Reset() also reset the state related to #pragma diagnostic. Fixes rdar://9170766.
llvm-svn: 128346
2011-03-26 18:58:17 +00:00
Douglas Gregor c2b97994ea When libclang visits a translation unit via clang_visitChildren(),
walk the preprocessing record *before* walking the declarations, so
they we pretend that we actually respect the phases of translation.

We still walk the preprocessing record after the declarations when
performing token annotation or finding the cursor at a location, since
those routines depend on those semantics.

Fixes <rdar://problem/9137195>.

llvm-svn: 127776
2011-03-16 23:23:30 +00:00
Abramo Bagnara 9875a3ce70 Use ElaboratedType also for C.
llvm-svn: 127755
2011-03-16 20:16:18 +00:00
Ted Kremenek 6f7008dcb6 c-index-test shouldn't crash when a goto has no matching label. Fixes <rdar://problem/9123493>.
llvm-svn: 127711
2011-03-15 23:47:49 +00:00
Abramo Bagnara 5e152ce3fe Fixed type and declaration source range in presence of typeQuals.
llvm-svn: 127535
2011-03-12 11:02:00 +00:00
Douglas Gregor f2f0806f71 Teach libclang's token-annotation logic about context-sensitive
keywords for Objective-C+ and C++0x. 

llvm-svn: 127253
2011-03-08 17:10:18 +00:00
Abramo Bagnara ea94788cf4 Fixed source range for StaticAssertDecl and LinkageSpecDecl. Fixed source range for declarations using postfix types.
llvm-svn: 127251
2011-03-08 16:41:52 +00:00
Abramo Bagnara b5545be14b Fixed NamespaceDecl source range.
llvm-svn: 127242
2011-03-08 12:38:20 +00:00
Abramo Bagnara dff1930bf7 Fixed source range for all DeclaratorDecl's.
llvm-svn: 127225
2011-03-08 08:55:46 +00:00
Abramo Bagnara b3185b00c5 Fixed TypedefDecl and TemplateTypeParameter source range.
llvm-svn: 127119
2011-03-06 15:48:19 +00:00
Abramo Bagnara a0935267dc Fixed source range for ClassTemplateSpecializationDecl.
llvm-svn: 126999
2011-03-04 14:20:30 +00:00
Abramo Bagnara 23485e04be Improved TemplateTypeParmDecl end location.
llvm-svn: 126996
2011-03-04 12:42:03 +00:00
Abramo Bagnara e15d553663 Fixed end location of NonTypeTemplateParamDecl.
llvm-svn: 126994
2011-03-04 11:03:48 +00:00
Douglas Gregor bd6b4447a7 Finish updated test
llvm-svn: 126948
2011-03-03 17:22:06 +00:00
Douglas Gregor e29139c77d Eliminate redundant nested-name-specifiers on
TemplateSpecializationTypes, which also fixes PR9388.

llvm-svn: 126946
2011-03-03 17:04:51 +00:00