Commit Graph

560 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis 45e8cf5732 [libclang] When pointing at a macro expansion inside a macro argument,
return a cursor for the inner macro.

llvm-svn: 140207
2011-09-20 23:27:33 +00:00
Argyrios Kyrtzidis b4199b659b For SourceManager::isBeforeInTranslationUnit, a location pointing
inside a macro argument should be regarded as coming before
the location of the expanded tokens.

llvm-svn: 140053
2011-09-19 20:39:57 +00:00
Argyrios Kyrtzidis 03c40c5182 [PCH] Overhaul how preprocessed entities are [de]serialized.
-Use an array of offsets for all preprocessed entities
-Get rid of the separate array of offsets for just macro definitions;
 for references to macro definitions use an index inside the preprocessed
 entities array.
-Deserialize each preprocessed entity lazily, at first request; not in bulk.

Paves the way for binary searching of preprocessed entities that will offer
efficiency and will simplify things on the libclang side a lot.

llvm-svn: 139809
2011-09-15 18:02:56 +00:00
Argyrios Kyrtzidis 4c2131a775 [libclang] Correct annotation and taking of cursor for objc class references
inside the IBOutletCollection attribute.

llvm-svn: 139621
2011-09-13 18:49:56 +00:00
Argyrios Kyrtzidis 2cb4e3c554 [libclang]
-Allow cursor visitation of an attribute using its source range
-Add C++ 'final' and 'override' attributes as cursor kinds
-Simplify the logic that marks 'final' and 'override' attributes as tokens.

llvm-svn: 139609
2011-09-13 17:39:31 +00:00
Argyrios Kyrtzidis 01e3c590ae [libclang] For getDeclFromExpr in CIndex.cpp, associate the decl of
a DeclRefExpr, MemberExpr, etc. with a CastExpr if it is ImplicitCast,
since the implicit cast is the one that is invisible in source code.

llvm-svn: 139547
2011-09-12 22:17:26 +00:00
Argyrios Kyrtzidis 14c32e8894 [libclang] In ASTUnit::Parse copy the CompilerInvocation object instead of
modifying directly for the preamble.

This avoids an awful, hard to find, bug where "PreprocessorOpts.DisablePCHValidation = true"
would be persistent for subsequent reparses of the translation unit which would result
in defines, present in command-line but not in the PCH, being ignored.

Fixes rdar://9615399.

llvm-svn: 139512
2011-09-12 18:09:38 +00:00
Douglas Gregor 98c05b286c Kill of the Decl::PCHLevel field entirely. We now only need to know
whether a Decl was deserialized from an AST file (any AST file).

llvm-svn: 139438
2011-09-10 00:09:20 +00:00
Argyrios Kyrtzidis 80f78b961a [libclang] Fix annotation and getting a "macro expansion" cursor
for a builtin macro expansion.

llvm-svn: 139298
2011-09-08 17:18:41 +00:00
Argyrios Kyrtzidis b914e3bc5c Handle a code-completion token being passed to the macro stringify operator.
Fixes http://llvm.org/PR10826.

llvm-svn: 139087
2011-09-04 03:32:19 +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
Francois Pichet 0274487d97 Enable -fdelayed-template-parsing by default on Win32.
I had to force -fno-delayed-template-parsing on some Index tests because delayed template parsing will change the output of some tests.

llvm-svn: 138942
2011-09-01 16:38:08 +00:00
Fariborz Jahanian bd0642fede objective-c - This patch buffers method implementations
and does the Sema on their body after the entire 
class/category @implementation is seen. This change allows messaging 
of forward private methods, as well as, access to 
synthesized ivars of properties with foward synthesize
declarations; among others. In effect, this patch removes
several restrictions placed on objective-c due to in-place
semantics processing of methods.
This is part of // rdar://8843851.

llvm-svn: 138865
2011-08-31 17:37:55 +00:00
Argyrios Kyrtzidis 440f954d6f [libclang] Fix getting a cursor that points inside tag definition that is part
of a type specifier.

e.g. for:

typedef struct _MyS {
  int foo;
} MyS;

pointing at field 'foo' would give a cursor for the typedef declaration 'MyS'
instead of the field.

llvm-svn: 138593
2011-08-25 22:24:47 +00:00
Fariborz Jahanian 8d382dc781 Restore patch I reversed in r138040. Known buildbot
failures are resolved.

llvm-svn: 138234
2011-08-22 15:54:49 +00:00
Fariborz Jahanian 9a3b269ea1 Revers r138040. Need to look at a few buildbot failures.
llvm-svn: 138049
2011-08-19 18:02:47 +00:00
Fariborz Jahanian d6d866d6fa objective-c: Bring objective-c handling of decl context
to modernity. Instead of passing down individual
context objects from parser to sema, establish decl
context in parser and have sema access current context
as needed. I still need to take of Doug's comment for
minor cleanups.

llvm-svn: 138040
2011-08-19 16:06:57 +00:00
Argyrios Kyrtzidis 75f6cd2b79 [libclang] Support code-completion inside macro arguments.
llvm-svn: 137973
2011-08-18 19:41:28 +00:00
Argyrios Kyrtzidis 035674d33c [libclang] Annotate correctly macro argument tokens.
llvm-svn: 137961
2011-08-18 18:03:34 +00:00
Argyrios Kyrtzidis 85a14bbd31 For the MacroExpands preprocessor callback, also pass the SourceRange
of expansion (for function macros it includes the right paren).

llvm-svn: 137909
2011-08-18 01:05:45 +00:00
Argyrios Kyrtzidis 004df6e053 Mark objc methods that are implicitly declared for properties (not user-declared) as implicit.
This results in libclang ignoring such methods.

llvm-svn: 137852
2011-08-17 19:25:08 +00:00
Argyrios Kyrtzidis 6f5bd2f630 [libclang] Make clang_getCursor able to handle locations that point inside macro arguments.
e.g. for:

\define INVOKE(METHOD, CLASS) [CLASS METHOD]

void test2() {
  INVOKE(meth, MyClass);
}

Pointing at 'meth' will give a CXCursor_ObjCMessageExpr and pointing at 'MyClass'
will give a CXCursor_ObjCClassRef.

llvm-svn: 137796
2011-08-17 00:31:25 +00:00
Argyrios Kyrtzidis e593e7fe6f Fix tests for non-darwin hosts.
llvm-svn: 137688
2011-08-15 23:43:33 +00:00
Argyrios Kyrtzidis 2c7f4f133f [libclang] Require explicit cursor visitation for all TypeLocs (compilation will
fail if a TypeLoc kind is not handled) and handle DecltypeTypeLoc and InjectedClassNameTypeLoc.

llvm-svn: 137670
2011-08-15 22:40:24 +00:00
Argyrios Kyrtzidis 5ef35b7ce2 Fix the buildbot test.
llvm-svn: 137660
2011-08-15 21:45:01 +00:00
Argyrios Kyrtzidis 48ff9a0bd5 [libclang] Handle AttributedTypeLoc for cursor visitation. Fixes rdar://9535717.
llvm-svn: 137634
2011-08-15 18:44:43 +00:00
Argyrios Kyrtzidis 5431380dd4 [libclang] When pointing at an objc property don't return a cursor that points at the
synthesized method for the property. rdar://9771715

llvm-svn: 137248
2011-08-10 21:12:04 +00:00
Abramo Bagnara ff371acaa4 Fixed FieldDecl source range.
llvm-svn: 136963
2011-08-05 08:02:55 +00:00
Douglas Gregor 3f35bb2d15 Add a new libclang API to return a CXCompletionString for an arbitrary
cursor, from Connor Wakamo! Addresses <rdar://problem/9087798>.

llvm-svn: 136911
2011-08-04 20:04:59 +00:00
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