Commit Graph

505 Commits

Author SHA1 Message Date
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
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