Commit Graph

531 Commits

Author SHA1 Message Date
Abramo Bagnara 4a8cda8556 Fixed end source location for LinkageSpecDecl.
llvm-svn: 126943
2011-03-03 14:52:38 +00:00
Douglas Gregor 6471db0749 Force CaseStmt to store its child statements in source-code order,
which is important for libclang's token-annotation and
where's-my-cursor functionality. Fixes <rdar://problem/9004439>.

llvm-svn: 126887
2011-03-02 21:45:00 +00:00
Douglas Gregor 25b7e05b72 Fix the source range for a member access expression that includes a
nested-name-specifier and improve the detection of implicit 'this'
bases. Fixes <rdar://problem/8750392>.

llvm-svn: 126880
2011-03-02 21:06:53 +00:00
Douglas Gregor 64f38ae7ee Teach libclang how to visit the children of a C++ base-class specifier
(i.e., the TypeLoc describing the base class type).

llvm-svn: 126861
2011-03-02 19:17:03 +00:00
Douglas Gregor 9d80212115 Push nested-name-specifier source location information into template
template arguments. I believe that this is the last place in the AST
where we were storing a source range for a nested-name-specifier
rather than a proper nested-name-specifier location structure. (Yay!)

There is still a lot of cleanup to do in the TreeTransform, which
doesn't take advantage of nested-name-specifiers with source-location
information everywhere it could.

llvm-svn: 126844
2011-03-02 17:09:35 +00:00
Douglas Gregor e7c2065379 Push nested-name-specifier source-location information into dependent
template specialization types. This also required some parser tweaks,
since we were losing track of the nested-name-specifier's source
location information in several places in the parser. Other notable
changes this required:

  - Sema::ActOnTagTemplateIdType now type-checks and forms the
    appropriate type nodes (+ source-location information) for an
    elaborated-type-specifier ending in a template-id. Previously, we
    used a combination of ActOnTemplateIdType and
    ActOnTagTemplateIdType that resulted in an ElaboratedType wrapped
    around a DependentTemplateSpecializationType, which duplicated the
    keyword ("class", "struct", etc.) and nested-name-specifier
    storage.

  - Sema::ActOnTemplateIdType now gets a nested-name-specifier, which
    it places into the returned type-source location information.

  - Sema::ActOnDependentTag now creates types with source-location
    information.

llvm-svn: 126808
2011-03-02 00:47:37 +00:00
Douglas Gregor a7a795bed1 Push nested-name-specifier source-location information into dependent
template specialization types. There are still a few rough edges to
clean up with some of the parser actions dropping
nested-name-specifiers too early.

llvm-svn: 126776
2011-03-01 20:11:18 +00:00
Douglas Gregor 844cb50266 Reinstate the introduction of source-location information for
nested-name-speciciers within elaborated type names, e.g.,
 
  enum clang::NestedNameSpecifier::SpecifierKind

Fixes in this iteration include:

  (1) Compute the type-source range properly for a dependent template
  specialization type that starts with "template template-id ::", as
  in a member access expression

    dep->template f<T>::f()

  This is a latent bug I triggered with this change (because now we're
  checking the computed source ranges for dependent template
  specialization types). But the real problem was...

  (2) Make sure to set the qualifier range on a dependent template
  specialization type appropriately. This will go away once we push
  nested-name-specifier locations into dependent template
  specialization types, but it was the source of the
  valgrind errors on the buildbots.
  

llvm-svn: 126765
2011-03-01 18:12:44 +00:00
Douglas Gregor b3a58b08e0 Revert r126748, my second attempt at nested-name-specifier source
location information for elaborated types. *sigh*

llvm-svn: 126753
2011-03-01 17:25:47 +00:00
Douglas Gregor bf5fe47b12 Reinstate r126737, extending the generation of type-source location
information for qualifier type names throughout the parser to address
several problems.

The commit message from r126737:

Push nested-name-specifier source location information into elaborated
name types, e.g., "enum clang::NestedNameSpecifier::SpecifierKind".

Aside from the normal changes, this also required some tweaks to the
parser. Essentially, when we're looking at a type name (via
getTypeName()) specifically for the purpose of creating an annotation
token, we pass down the flag that asks for full type-source location
information to be stored within the returned type. That way, we retain
source-location information involving nested-name-specifiers rather
than trying to reconstruct that information later, long after it's
been lost in the parser.

With this change, test/Index/recursive-cxx-member-calls.cpp is showing
much improved results again, since that code has lots of
nested-name-specifiers.

llvm-svn: 126748
2011-03-01 16:31:39 +00:00
Douglas Gregor 62a60c50f4 Revert r126737, the most recent nested-name-specifier location change, for buildbot breakage.
llvm-svn: 126746
2011-03-01 15:34:37 +00:00
Douglas Gregor 9720642c68 Push nested-name-specifier source location information into elaborated
name types, e.g., "enum clang::NestedNameSpecifier::SpecifierKind".

Aside from the normal changes, this also required some tweaks to the
parser. Essentially, when we're looking at a type name (via
getTypeName()) specifically for the purpose of creating an annotation
token, we pass down the flag that asks for full type-source location
information to be stored within the returned type. That way, we retain
source-location information involving nested-name-specifiers rather
than trying to reconstruct that information later, long after it's
been lost in the parser.

With this change, test/Index/recursive-cxx-member-calls.cpp is showing
much improved results again, since that code has lots of
nested-name-specifiers.

llvm-svn: 126737
2011-03-01 03:11:17 +00:00
Douglas Gregor 3d0da5f5dd Push nested-name-specifier source location information into
DependentNameTypeLoc. Teach the recursive AST visitor and libclang how to
walk DependentNameTypeLoc nodes.

Also, teach libclang about TypedefDecl source ranges, so that we get
those. The massive churn in test/Index/recursive-cxx-member-calls.cpp
is a good thing: we're annotating a lot more of this test correctly
now.

llvm-svn: 126729
2011-03-01 01:34:45 +00:00
Douglas Gregor ea972d3faa Push nested-name-specifier location information into DeclRefExpr and
MemberExpr, the last of the expressions with qualifiers!

llvm-svn: 126688
2011-02-28 21:54:11 +00:00
Douglas Gregor 0da1d43e16 Push nested-name-specifier source location information into
UnresolvedLookupExpr and UnresolvedMemberExpr.

Also, improve the computation that checks whether the base of a member
expression (either unresolved or dependent-scoped) is implicit. The
previous check didn't cover all of the cases we use in our
representation, which threw off source-location information for these
expressions (which, in turn, caused some breakage in libclang's token
annotation). 

llvm-svn: 126681
2011-02-28 20:01:57 +00:00
Douglas Gregor a6ce608b97 Push nested-name-specifier source-location information into
pseudo-destructor expressions. Also, clean up some
template-instantiation and type-checking issues with
pseudo-destructors.

llvm-svn: 126498
2011-02-25 18:19:59 +00:00
Douglas Gregor c05ba2ef12 Push nested-name-specifier source location information into namespace
aliases.

llvm-svn: 126496
2011-02-25 17:08:07 +00:00
Douglas Gregor 12441b3bc5 Push nested-name-specifier source location information into using directives.
llvm-svn: 126489
2011-02-25 16:33:46 +00:00
Douglas Gregor f29ba48c7f Direct testing of source-location information on using declarations, via libclang
llvm-svn: 126487
2011-02-25 16:13:46 +00:00
Douglas Gregor 144548072d Use NestedNameSpecifierLoc within out-of-line variables, function, and
tag definitions. Also, add support for template instantiation of
NestedNameSpecifierLocs.

llvm-svn: 126470
2011-02-25 02:25:35 +00:00
Douglas Gregor a9d87bc6ac Update UsingDecl, UnresolvedUsingTypenameDecl, and
UnresolvedUsingValueDecl to use NestedNameSpecifierLoc rather than the
extremely-lossy NestedNameSpecifier/SourceRange pair it used to use,
improving source-location information.

Various infrastructure updates to support NestedNameSpecifierLoc:
  - AST/PCH (de-)serialization
  - Recursive AST visitor
  - libclang traversal (including the first tests of this
    functionality)

llvm-svn: 126459
2011-02-25 00:36:19 +00:00
Douglas Gregor 3a69eafa88 When code-completing a case statement for a switch on a value of
enumeration type, prioritize the enumeration constants and don't
provide completions for any other expressions. Fixes <rdar://problem/7283668>.

llvm-svn: 125991
2011-02-18 23:30:37 +00:00
Douglas Gregor af2a6ae429 Selector::getIdentifierInfoForSlot() can return NULL values, a fact
that was ignored in a few places (most notably, code
completion). Introduce Selector::getNameForSlot() for the common case
where we only care about the name. Audit all uses of
getIdentifierInfoForSlot(), switching many over to getNameForSlot(),
fixing a few crashers.

Fixed <rdar://problem/8939352>, a code-completion crasher.

llvm-svn: 125977
2011-02-18 22:29:55 +00:00
Douglas Gregor b0f2ea9e9e When printing a qualified type, look through a substituted template
parameter type to see what's behind it, so that we don't end up
printing silly things like "float const *" when "const float *" would
make more sense. Also, replace the pile of "isa" tests with a simple
switch enumerating all of the cases, making a few more obvious cases
use prefix qualifiers.

llvm-svn: 125729
2011-02-17 06:52:25 +00:00
Douglas Gregor 9c1f1bfedc When Parser::ParseExpressionList isn't given a completer, fall back to
normal "expression" completion. Fixes the most annoying
code-completion bug I've found.

llvm-svn: 125715
2011-02-17 03:09:23 +00:00
Douglas Gregor 669a25aec3 Implement code completion results for the Objective-C Key-Value Coding
(KVC) and Key-Value Observing (KVO) protocols.

llvm-svn: 125696
2011-02-17 00:22:45 +00:00
Douglas Gregor 042465709f When searching for visible declarations (e.g., for code completion),
be sure to look at all of the Objective-C class declarations within a
@class. Fixes <rdar://problem/8876207>.

llvm-svn: 125635
2011-02-16 01:39:26 +00:00
Douglas Gregor b5f1e46d30 When trying to provide a code completion item for a call to "super" in
Objective-C, also look in the categories and class extensions of our
superclasses. Fixes <rdar://problem/8853540>.

llvm-svn: 125628
2011-02-16 00:51:18 +00:00
Douglas Gregor 24bbc46208 Teach code completion to cope with block types written without a
prototype, e.g., ^() rather than ^(void). Fixes
<rdar://problem/8875712>.

llvm-svn: 125608
2011-02-15 22:37:09 +00:00
Douglas Gregor f34a6f0fef Implement a special code-completion pattern for "IBAction". Fixes
<rdar://problem/8767704>.

llvm-svn: 125604
2011-02-15 22:19:42 +00:00
Douglas Gregor 8003924d10 When code-completing within a list of declaration specifiers,
separately handle the case of a local declaration-specifier list,
including all types in the set of options. Fixes
<rdar://problem/8790735> and <rdar://problem/8662831>.

llvm-svn: 125594
2011-02-15 20:33:25 +00:00
Douglas Gregor d39ae3eec8 When we encounter an Objective-C class name in an expression, followed
by the code completion token, treat this as a class message send where
the opening square bracket is missing. Fixes <rdar://problem/6970911>.

llvm-svn: 125587
2011-02-15 19:17:31 +00:00
Argyrios Kyrtzidis 9fdd25492c When reading the AST, delay loading of the redeclaration chain to avoid deeply nested calls.
Temporarily set the first (canonical) declaration as the previous one, which is the one that
matters, and mark the real previous DeclID to be loaded & attached later on.

Fixes rdar://8956193.

llvm-svn: 125434
2011-02-12 07:50:47 +00:00
Ted Kremenek 359c4a1369 Don't crash when generating USRs for ObjC methods in protocols.
llvm-svn: 124920
2011-02-05 01:10:26 +00:00
Ted Kremenek 05edf944c0 USRs for Objective-C methods use the USR of the @interface as their base, not the USR of the class category or extension.
llvm-svn: 124859
2011-02-04 07:13:40 +00:00
Douglas Gregor 149239651d If any Fix-Its attached to a diagnostic have invalid source locations
or source locations that refer into a macro instantiation, delete all
of the Fix-Its on that diagnostic.

llvm-svn: 124833
2011-02-03 23:41:12 +00:00
Douglas Gregor 9c2e896d62 Test for previous commit
llvm-svn: 124385
2011-01-27 18:39:26 +00:00
Douglas Gregor 56a6380cb7 Add libclang functions to determine the const/volatile/restrict
qualifiers on a CXType. Patch from Stefan Seefeld, test by me.

llvm-svn: 124377
2011-01-27 16:27:11 +00:00
Douglas Gregor 62c3134629 Eliminate the use of getTypeForDecl from clang_getCursorType() and
clang_getDeclObjCTypeEncoding(); use ASTContext's methods instead,
which will (lazily) create the type as needed. Otherwise, we can end
up with null QualTypes.

llvm-svn: 124133
2011-01-24 18:44:28 +00:00
Douglas Gregor 54bce44895 Teach libclang to generate USRs containing parameter packs and pack expansions.
llvm-svn: 123848
2011-01-19 20:50:07 +00:00
Douglas Gregor 557f05c2d2 Teach libclang about SizeOfPackExpr.
llvm-svn: 123846
2011-01-19 20:34:17 +00:00
Douglas Gregor 345c1bcb80 Don't silently drop warning flags passed in to
clang_createTranslationUnitFromSourceFile().

llvm-svn: 123793
2011-01-19 01:02:47 +00:00
Douglas Gregor 4478f858b5 Add the location of the right parenthesis of a C++ named cast
(static_cast, dynamic_cast, reinterpret_cast, or const_cast) to
improve source-location information. Fixes PR8960.

llvm-svn: 123336
2011-01-12 22:41:29 +00:00
Fariborz Jahanian 3aa19e9a70 Fold -fobjc-nonfragile-abi2 into -fobjc-nonfragile-abi.
// rdar://8818375

llvm-svn: 122831
2011-01-04 20:05:20 +00:00
Argyrios Kyrtzidis d5756a609d When in code-completion, skip obj-c method bodies for speed up.
llvm-svn: 122781
2011-01-03 22:33:06 +00:00
Argyrios Kyrtzidis 76dbe8c800 Speed up code-completion by skipping function bodies.
When we are in code-completion mode, skip parsing of all function bodies except the one where the
code-completion point resides.

For big .cpp files like 'SemaExpr.cpp' the improvement makes a huge difference, in some cases cutting down
code-completion time -62% !

We don't get diagnostics for the bodies though, so modify the code-completion tests that check for errors.

See rdar://8814203.

llvm-svn: 122765
2011-01-03 19:44:02 +00:00
Douglas Gregor fd4da71343 When determining which preprocessed entities to traverse in libclang,
take into account the region of interest. Otherwise, we may fail to
traverse some important preprocessed entity cursors. 
Fixes <rdar://problem/8554072>.

llvm-svn: 122350
2010-12-21 19:07:48 +00:00
Douglas Gregor 95082d0b0a Fix test to be platform-agnostic
llvm-svn: 122348
2010-12-21 17:52:09 +00:00
Douglas Gregor 87e927520d Fix a major inconsistency in the representation of Objective-C
classes, categories, protocols, and class extensions, where the
methods and properties of these entities would be inserted into the
DeclContext in an ordering that doesn't necessarily reflect source
order. The culprits were Sema::ActOnMethodDeclaration(), which did not
perform the insertion of the just-created method declaration into
the DeclContext for these Objective-C entities, and
Sema::ActOnAtEnd(), which inserted all method declarations at the
*end* of the DeclContext. 

With this fix in hand, clean up the code-completion actions for
property setters/getters that worked around this brokenness in the AST.

Fixes <rdar://problem/8062781>, where this problem manifested as poor
token-annotation information, but this would have struck again in many
other places.

llvm-svn: 122347
2010-12-21 17:34:17 +00:00
Douglas Gregor 70226dada0 Implement BlockDecl::getSourceRange(). The bogus source-range
information caused token-annotation to fail in funny ways. Fixes
<rdar://problem/8595386>.

llvm-svn: 122338
2010-12-21 16:27:07 +00:00
Chris Lattner 6cc8fe9356 add missing newlines at end of file.
llvm-svn: 122309
2010-12-21 02:36:58 +00:00
Douglas Gregor 4e2749193b Swap the order of the condition and body of a do-while statement in
the AST, so that we visit them in source order. Fixes <rdar://problem/8779113>.

llvm-svn: 122062
2010-12-17 16:18:04 +00:00
Abramo Bagnara 166cfa3a42 Avoid to emit redundant implicit cast for enum constants init expressions.
llvm-svn: 122056
2010-12-17 12:21:11 +00:00
Douglas Gregor 3046b4d72f In clang_getCursor(), don't override a preprocessing cursor within
another preprocessing cursor, since we want the outermost one.

llvm-svn: 121470
2010-12-10 07:23:11 +00:00
Douglas Gregor b888acf413 Eliminate duplicate code completions for properties.
llvm-svn: 121424
2010-12-09 23:01:55 +00:00
Douglas Gregor a3b23b025b Don't walk the translation unit context to produce protocol names when
global code completions are disabled (e.g., because they are
cached). Also, make sure that forward-declared protocols are visited
when we look for all visible names within a declaration context.

Previously, we would end up with duplicate completions for protocols.

llvm-svn: 121416
2010-12-09 21:44:02 +00:00
Francois Pichet cf7731b40b Fix bug where annotate tokens was not working for BinaryTypeTraitExpr.
CIndex's EnqueueVisitor must visit elements backward apparently.

llvm-svn: 121247
2010-12-08 09:11:05 +00:00
Francois Pichet c247e1a119 Fix test that didn't really test anything.
llvm-svn: 121246
2010-12-08 09:04:37 +00:00
Douglas Gregor f88e35ba0b When using a precompiled preamble with detailed preprocessing records,
trap the serialized preprocessing records (macro definitions, macro
instantiations, macro definitions) from the generation of the
precompiled preamble, then replay those when walking the list of
preprocessed entities. This eliminates a bug where clang_getCursor()
wasn't able to find preprocessed-entity cursors in the preamble.

llvm-svn: 120396
2010-11-30 06:16:57 +00:00
Douglas Gregor a750e8e6d8 Extend the libclang diagnostic API to provide information about the
option name, category ID, and category name corresponding to a diagnostic.

llvm-svn: 119802
2010-11-19 16:18:16 +00:00
Douglas Gregor b4a7c0385d Do not produce "purely informative" code completion results for
Objective-C message sends, which have only whitespace in their
TypedText chunk. Such results have no purpose.

llvm-svn: 119569
2010-11-17 21:36:08 +00:00
Douglas Gregor 30313cbb80 When libclang is walking a member access expression, don't walk into
an implicit "this"; it causes clang_getCursor() to find the implicit
"this" expression (which isn't written in the source!) rather than the
actual member.

llvm-svn: 119516
2010-11-17 17:15:08 +00:00
Douglas Gregor 29ee422861 When comparing the source range of a declaration against the region of
interest (e.g., as used by clang_getCursor()), count the
decl-specifier-seq as part of the source range, as we do for
clang_annotateTokens(). Makes clang_getCursor() work properly for the
result types of functions, for example.

llvm-svn: 119514
2010-11-17 17:14:07 +00:00
Douglas Gregor b1b71e50a0 For an Objective-C @synthesize statement, e.g.,
@synthesize foo = _foo;

keep track of the location of the ivar ("_foo"). Teach libclang to
visit the ivar as a member reference.

llvm-svn: 119447
2010-11-17 01:03:52 +00:00
Douglas Gregor 68dbaead7b Fix source-range information for Objective-C properties. Previously,
we were just getting a range covering only the property name, which is
certainly not correct (and broke token annotation, among other
things). 

Also, teach libclang about the relationship between
@synthesize/@dynamic and @property, so we get property name and
cursor-reference information for @synthesize and @dynamic.

llvm-svn: 119409
2010-11-17 00:13:31 +00:00
Ted Kremenek bb437a6999 Fix use of an uninitialized SourceLocation because DeclarationNameLoc failed to completely zero-initialize itself.
Now we explicitly memset all of its values.

This bug was uncovered by the 'Index/recursive-cxx-member-calls.cpp', which exhibited an assertion
on an i386 darwin build of clang.  Adding this test case back since the assertion is now resolved.

llvm-svn: 118881
2010-11-12 04:25:07 +00:00
Ted Kremenek b76f2402b0 Temporarily remove this test. It is causing an assertion failure in the builtbot.
llvm-svn: 118785
2010-11-11 08:17:57 +00:00
Ted Kremenek c7a5bae597 Annotate tokens in a separate thread to avoid blowing out stack space. While the CursorVisitor
is gradually becoming more data recursive, AnnotateTokensVisitor does its own recursive call
within the visitor that can still blow out the stack.  This can potentially be reworked to avoid this,
but for now just do token annotation on a separate thread.

llvm-svn: 118783
2010-11-11 08:05:23 +00:00
Ted Kremenek 92209a45b9 Generalize data-recursive visitation in CursorVisitor to also handle MemberExprs
and CXXCallMemberExprs.  This scheme is hopefully general enough to extend to the
rest of the visitor if necessary.

llvm-svn: 118782
2010-11-11 08:05:18 +00:00
Douglas Gregor 44c6ee7729 Improve ASTUnit's capture of diagnostics so that the
diagnostic-capturing client lives as long as the ASTUnit itself
does. Otherwise, we can end up with crashes when we get a diagnostic
outside of parsing/code completion. The circumstances under which this
happen are really hard to reproduce, because a file needs to change
from under us.

llvm-svn: 118751
2010-11-11 00:39:14 +00:00
Argyrios Kyrtzidis 2703bebc58 Replace UsingDecl's SmallPtrSet of UsingShadowDecls with a linked list to avoid leaking memory.
Fixes rdar://8649963.

llvm-svn: 118674
2010-11-10 05:40:41 +00:00
Douglas Gregor 229bebdeb5 ntroduce clang_getSpellingLocation() into libclang, to provide the
location where we're spelling a token even within a
macro. clang_getInstantiationLocation() tells where we instantiated
the macro.

I'm still not thrilled with the CXSourceLocation/CXSourceRange APIs,
since they gloss over macro-instantiation information.

Take 2: this time, adjusted tests appropriately and used a "simple"
approach to the spelling location.

llvm-svn: 118495
2010-11-09 06:24:54 +00:00
Douglas Gregor 12a610d1fa Revert r118492, which didn't update all of its tests accordingly
llvm-svn: 118494
2010-11-09 05:52:02 +00:00
Douglas Gregor d1ea3f0d29 Introduce clang_getSpellingLocation() into libclang, to provide the
location where we're spelling a token even within a
macro. clang_getInstantiationLocation() tells where we instantiated
the macro.

I'm still not thrilled with the CXSourceLocation/CXSourceRange APIs,
since they gloss over macro-instantiation information.

llvm-svn: 118492
2010-11-09 05:28:47 +00:00
Douglas Gregor 2927c0c817 Teach code completion not to include out-of-line declarations and
definitions in its results. The original declarations will be visible
wherever they are declared.

llvm-svn: 118484
2010-11-09 03:59:40 +00:00
Ted Kremenek 15c1e368bb Add CursorVisitor::VisitBinaryOperator() to explicitly handle the case where we can blow out the stack due
to deeply nested BinaryOperators.  This is done by turning the explicit recursion into being data recursive.

Fixes: <rdar://problem/8289205>
llvm-svn: 118444
2010-11-08 21:14:15 +00:00
Douglas Gregor dc520b0f08 If an instance method messages is sending to an expression of type Class,
and we statically can compute a bound on the actual type (e.g.,
because it's a send to the the magic "class" instance method), code
complete as if we were performing a class message send to that class.

llvm-svn: 118443
2010-11-08 21:12:30 +00:00
Douglas Gregor 16443fdd31 Teach clang_getCursorReferenced() that a
CXXConstructorExpr/CXXTemporaryObjectExpr references the constructor
it calls. Then, tweak clang_getCursor() to prefer such a call over a
type reference to the type being called.

llvm-svn: 118297
2010-11-05 21:11:19 +00:00
Douglas Gregor 15417cfa56 Improve source-location information for CXXConstructExpr nodes, by
ensuring that they cover all of their child nodes. There's still a
clang_getCursor()-related issue with CXXFunctionalCastExprs with
CXXConstructExprs as children (see FIXME in the test case); I'll look
at that separately.

llvm-svn: 118132
2010-11-03 00:35:38 +00:00
Ted Kremenek d40a439067 Hack to workaround deficiency in ObjC ASTs. Functions and variables may be declared
within an @implementation, but we have no way to record that information in the AST.
This may cause CursorVisitor to miss these Decls when doing a AST walk.

Fixes <rdar://problem/8595462>.

llvm-svn: 118109
2010-11-02 23:10:24 +00:00
Douglas Gregor 05fcf84d14 Teach code completion to provide property results when the property
can be used to automatically synthesize an ivar.

llvm-svn: 118052
2010-11-02 20:36:02 +00:00
Ted Kremenek 818e5c1839 Encapsulate within CXCursor the notion of whether a VarDecl* is the first Decl in a DeclGroup. We use this
to recover some context that is currently not modeled directly in the AST.  Currently VarDecl's cannot
properly determine their source range because they have no context on whether or not they appear in a DeclGroup.
For the meantime, this bandaid suffices in libclang since that is where the correct SourceRange is directly needed.

Fixes <rdar://problem/8595749>.

llvm-svn: 117973
2010-11-01 23:26:51 +00:00
Chandler Carruth 0171815ae1 Improve the tracking of source locations for parentheses in constructor calls.
This adds them where missing, and traces them through PCH. We fix at least one
bug in the extents found by the Index library, and make a lot of refactoring
tools which care about the exact formulation of a constructor call easier to
write. Also some minor cleanups to more consistently follow the friend pattern
instead of the setter pattern when rebuilding a serialized AST.

Patch originally by Samuel Benzaquen.

llvm-svn: 117254
2010-10-25 08:47:36 +00:00
Douglas Gregor 263803a6cd Teach clang_getCursorReferenced() and friends about BlockDeclRefExprs.
llvm-svn: 117167
2010-10-22 22:24:08 +00:00
John McCall 457a04e3ce Substantially revise how clang computes the visibility of a declaration to
more closely parallel the computation of linkage.  This gets us to a state
much closer to what gcc emits, modulo bugs, which will undoubtedly arise in
abundance.

llvm-svn: 117147
2010-10-22 21:05:15 +00:00
Douglas Gregor 12a6c9e441 Update clang_getCursor() test to check searches on include directives
llvm-svn: 117063
2010-10-21 20:55:34 +00:00
Douglas Gregor adfdccf1f3 Improve the implementation of libclang's token-annotation logic for
entities in the preprocessing record. Previously, we would only end up
getting the first token of a preprocessing record annotated
correctly. For example, given

  #include "foo.h"

we would only get the '#' annotated as an inclusion directive; the
'include' and '"foo.h"' tokens would be given the general 'processing
directive' annotation.

Now, we get proper annotations for entities in the preprocessing
record.

llvm-svn: 117001
2010-10-21 06:10:04 +00:00
Douglas Gregor 796d76a663 Extend the preprocessing record and libclang with support for
inclusion directives, keeping track of every #include, #import,
etc. in the translation unit. We keep track of the source location and
kind of the inclusion, how the file name was spelled, and the
underlying file to which the inclusion resolved.

llvm-svn: 116952
2010-10-20 22:00:55 +00:00
Douglas Gregor 0787b3224d Tweak code-completion result priorities, so that exact and similar
type matches have a bigger impact. The impetus for this change was
that, when initializing an enumeration value, we want enumerators of
that enumeration type to have a higher priority than, e.g., unrelated
local variables.

llvm-svn: 116774
2010-10-19 00:03:23 +00:00
Douglas Gregor c769d6e007 Fix the translation of the PCC_ForInit code-completion context for
C++/C99/Objective-C, so that we properly include types. This fix
affects global caching of code-completion results; without caching,
the behavior was already correct.

llvm-svn: 116757
2010-10-18 22:01:46 +00:00
Douglas Gregor 643c330b91 Provide code completion for types after the '^' that starts a block
literal. 

llvm-svn: 116754
2010-10-18 21:34:55 +00:00
Douglas Gregor 8e3e8743fb Introduce code completion results for Objective-C methods, both when
declaring methods and when sending messages to them, by bringing all
of the selector into TypedCheck chunks in the completion result. This
way, we can improve the sorting of these results to account for the
full selector name rather than just the first chunk.

llvm-svn: 116746
2010-10-18 21:05:04 +00:00
Douglas Gregor 1b035bbe3a When providing code completions of Objective-C method declarations
(after - or +), always traverse superclasses and all categories. The
programmer may want to complete a method from *anywhere*.

llvm-svn: 116723
2010-10-18 18:21:28 +00:00
Andrew Trick 6c8ce5c8b5 Reverting r116493: removes a test that failed on clang selfhost and msvc
llvm-svn: 116522
2010-10-14 21:41:16 +00:00
David Chisnall a9d40ee0ab Test case for r116439
llvm-svn: 116493
2010-10-14 18:15:20 +00:00
Douglas Gregor 7bb8af613c When we load an ASTUnit from command-line arguments, hold on to the
diagnostics produced by the driver itself. Previously, we were
allowing these to either be dropped or to slip through to stderr.

Fixes <rdar://problem/7595339>.

llvm-svn: 116285
2010-10-12 00:50:20 +00:00
Douglas Gregor 21d0e5a06c This test should now work on windows, since we're no longer using temporary files badly
llvm-svn: 116261
2010-10-11 23:18:55 +00:00
Douglas Gregor 36e3b5c79e Switch c-index-test from clang_codeComplete() over to
clang_codeCompleteAt(). This uncovered a few issues with the latter:

  - ASTUnit wasn't saving/restoring diagnostic state appropriately between
    reparses and code completions.
  - "Overload" completions weren't being passed through to the client

llvm-svn: 116241
2010-10-11 21:37:58 +00:00
Douglas Gregor 7845f1e80e Eliminate clang_setUseExternalASTGeneration() from libclang. Between
improvements to the compiler and the introduction of crash recovery,
it no longer makes sense to allow this mode. Moreover, this eliminates
one use of the "clang" executable from within libclang; we'd like them
all to go away.

llvm-svn: 116207
2010-10-11 16:52:23 +00:00
Douglas Gregor aca68323f3 Remove a rogue typo
llvm-svn: 115618
2010-10-05 14:58:05 +00:00