Commit Graph

88 Commits

Author SHA1 Message Date
Daniel Dunbar 5d02e0bd8a Simplify libIndex Makefile, which doesn't need to worry about altivec support.
llvm-svn: 105639
2010-06-08 20:57:18 +00:00
Daniel Dunbar ee6b692551 Makefiles: Set Clang CPP compiler flags in a single location, instead of scattered throughout the project Makefiles.
llvm-svn: 105638
2010-06-08 20:44:43 +00:00
Daniel Dunbar e6c1daa8fd Makefile: Switch Clang Makefiles to always include the top-level Clang Makefile.
- This eliminates most dependencies on how Clang is installed relative to LLVM.

llvm-svn: 105637
2010-06-08 20:34:18 +00:00
Abramo Bagnara 1108e7b873 Renamed misleading getSourceRange -> getLocalSourceRange and getFullSourceRange -> getSourceRange for TypeLoc.
llvm-svn: 104220
2010-05-20 10:00:11 +00:00
John McCall 8b07ec253d Substantially alter the design of the Objective C type AST by introducing
ObjCObjectType, which is basically just a pair of
  one of {primitive-id, primitive-Class, user-defined @class}
with
  a list of protocols.
An ObjCObjectPointerType is therefore just a pointer which always points to
one of these types (possibly sugared).  ObjCInterfaceType is now just a kind
of ObjCObjectType which happens to not carry any protocols.

Alter a rather large number of use sites to use ObjCObjectType instead of
ObjCInterfaceType.  Store an ObjCInterfaceType as a pointer on the decl rather
than hashing them in a FoldingSet.  Remove some number of methods that are no
longer used, at least after this patch.

By simplifying ObjCObjectPointerType, we are now able to easily remove and apply
pointers to Objective-C types, which is crucial for a certain kind of ObjC++
metaprogramming common in WebKit.

llvm-svn: 103870
2010-05-15 11:32:37 +00:00
Douglas Gregor 9a12919421 Overhaul the AST representation of Objective-C message send
expressions, to improve source-location information, clarify the
actual receiver of the message, and pave the way for proper C++
support. The ObjCMessageExpr node represents four different kinds of
message sends in a single AST node:

  1) Send to a object instance described by an expression (e.g., [x method:5])
  2) Send to a class described by the class name (e.g., [NSString method:5])
  3) Send to a superclass class (e.g, [super method:5] in class method)
  4) Send to a superclass instance (e.g., [super method:5] in instance method)

Previously these four cases where tangled together. Now, they have
more distinct representations. Specific changes:

  1) Unchanged; the object instance is represented by an Expr*.

  2) Previously stored the ObjCInterfaceDecl* referring to the class
  receiving the message. Now stores a TypeSourceInfo* so that we know
  how the class was spelled. This both maintains typedef information
  and opens the door for more complicated C++ types (e.g., dependent
  types). There was an alternative, unused representation of these
  sends by naming the class via an IdentifierInfo *. In practice, we
  either had an ObjCInterfaceDecl *, from which we would get the
  IdentifierInfo *, or we fell into the case below...

  3) Previously represented by a class message whose IdentifierInfo *
  referred to "super". Sema and CodeGen would use isStr("super") to
  determine if they had a send to super. Now represented as a
  "class super" send, where we have both the location of the "super"
  keyword and the ObjCInterfaceDecl* of the superclass we're
  targetting (statically).

  4) Previously represented by an instance message whose receiver is a
  an ObjCSuperExpr, which Sema and CodeGen would check for via
  isa<ObjCSuperExpr>(). Now represented as an "instance super" send,
  where we have both the location of the "super" keyword and the
  ObjCInterfaceDecl* of the superclass we're targetting
  (statically). Note that ObjCSuperExpr only has one remaining use in
  the AST, which is for "super.prop" references.

The new representation of ObjCMessageExpr is 2 pointers smaller than
the old one, since it combines more storage. It also eliminates a leak
when we loaded message-send expressions from a precompiled header. The
representation also feels much cleaner to me; comments welcome!

This patch attempts to maintain the same semantics we previously had
with Objective-C message sends. In several places, there are massive
changes that boil down to simply replacing a nested-if structure such
as:

  if (message has a receiver expression) {
    // instance message
    if (isa<ObjCSuperExpr>(...)) {
     // send to super
    } else {
     // send to an object
   }
  } else {
    // class message
    if (name->isStr("super")) {
      // class send to super
    } else {
      // send to class
    }
  }

with a switch

  switch (E->getReceiverKind()) {
  case ObjCMessageExpr::SuperInstance: ...
  case ObjCMessageExpr::Instance: ...
  case ObjCMessageExpr::SuperClass: ...
  case ObjCMessageExpr::Class:...
  }

There are quite a few places (particularly in the checkers) where
send-to-super is effectively ignored. I've placed FIXMEs in most of
them, and attempted to address send-to-super in a reasonable way. This
could use some review.

llvm-svn: 101972
2010-04-21 00:45:42 +00:00
Benjamin Kramer b11416d061 Add raw_ostream operators to NamedDecl for convenience. Switch over all users of getNameAsString on a stream.
The next step is to print the name directly into the stream, avoiding a temporary std::string copy.

llvm-svn: 101632
2010-04-17 09:33:03 +00:00
Jeffrey Yasskin f6442f80cb Allow users to set CPPFLAGS and CXXFLAGS on the make command line.
Tested: make CPPFLAGS=-m64 CXXFLAGS=-m64 -j8 && (cd tools/clang;make test)
llvm-svn: 98399
2010-03-12 22:55:16 +00:00
Kovarththanan Rajaratnam 47b55969c3 Cleanup using StringRef
llvm-svn: 98339
2010-03-12 09:33:31 +00:00
Douglas Gregor de4827dd34 Extend ObjCMessageExpr for class method sends with the source location
of the class name.

llvm-svn: 97943
2010-03-08 16:40:19 +00:00
Chris Lattner 0bcc858a2b -fno-rtti is now the default.
llvm-svn: 94379
2010-01-24 20:43:31 +00:00
Douglas Gregor 082c3e69eb Add -cursor-at=file:line:column command line option to c-index-test,
to directly check the results of clang_getCursor(). Also, start
migrating some index-test tests over to c-index test [*] and some
grep-using tests over to FileCheck.

llvm-svn: 93537
2010-01-15 19:40:17 +00:00
Ted Kremenek 54ad1ab56f Add the BlockDecl to the DeclContext.
llvm-svn: 90808
2009-12-07 22:01:30 +00:00
John McCall bcd035061d DeclaratorInfo -> TypeSourceInfo. Makes an effort to rename associated variables,
but the results are imperfect.

For posterity, I did:

cat <<EOF > $cmdfile
s/DeclaratorInfo/TypeSourceInfo/g
s/DInfo/TInfo/g
s/TypeTypeSourceInfo/TypeSourceInfo/g
s/SourceTypeSourceInfo/TypeSourceInfo/g
EOF

find lib -name '*.cpp' -not -path 'lib/Parse/*' -exec sed -i '' -f $cmdfile '{}' \;
find lib -name '*.h' -exec sed -i '' -f $cmdfile '{}' \;
find include -name '*.h' -not -path 'include/clang/Parse/*' -not -path 'include/clang/Basic/*' -exec sed -i '' -f $cmdfile '{}' \;

llvm-svn: 90743
2009-12-07 02:54:59 +00:00
Daniel Dunbar 98f2067ca4 Update CMake for CallGraph.cpp move.
llvm-svn: 90443
2009-12-03 09:14:19 +00:00
Daniel Dunbar 19a30ca8c0 Fix layering violation by moving Analysis/CallGraph to Index
llvm-svn: 90424
2009-12-03 07:20:04 +00:00
Benjamin Kramer 337e3a5fea Remove remaining VISIBILITY_HIDDEN from anonymous namespaces.
llvm-svn: 90044
2009-11-28 19:45:26 +00:00
Ted Kremenek 0469b7ea00 Add special clang_getCursor() support for @class. Handles <rdar://problem/7383421>.
llvm-svn: 89183
2009-11-18 02:02:52 +00:00
Douglas Gregor 120f6a6675 Silence some warnings produced by Clang, and add a missing header
llvm-svn: 89051
2009-11-17 06:14:37 +00:00
John McCall 4c98fd8953 Preserve type source information in sizeof/alignof expressions, and pass it
through to indexing.

llvm-svn: 86018
2009-11-04 07:28:41 +00:00
Steve Naroff 58bd62d190 Remove _clang_initCXLookupHint() and _clang_getCursorWithHint(). Related to <rdar://problem/7310688>.
Localize the optimization to ResolveLocationInAST(). The last valid AST location is now stored with ASTUnit. There still isn't optimal, however it's an improvement (with a much cleaner API). Having the client manage an "hint" is error prone and complex.

I wanted to land the major changes before finishing up the optimizations. 

llvm-svn: 85425
2009-10-28 20:44:47 +00:00
John McCall 703a3f8a7b Preserve type source information in TypedefDecls. Preserve it across
template instantiation.  Preserve it through PCH.  Show it off to the indexer.

I'm healthily ignoring the vector type cases because we don't have a sensible
TypeLoc implementation for them anyway.

llvm-svn: 84994
2009-10-24 08:00:42 +00:00
John McCall fc93cf9777 When building types from declarators, instead of building two types (one for
the DeclaratorInfo, one for semantic analysis), just build a single type whose
canonical type will reflect the semantic analysis (assuming the type is
well-formed, of course).

To make that work, make a few changes to the type system:
* allow the nominal pointee type of a reference type to be a (possibly sugared)
  reference type.  Also, preserve the original spelling of the reference type.
  Both of these can be ignored on canonical reference types.
* Remove ObjCProtocolListType and preserve the associated source information on
  the various ObjC TypeLocs.  Preserve the spelling of protocol lists except in
  the canonical form.
* Preserve some level of source type structure on parameter types, but
  canonicalize on the canonical function type.  This is still a WIP.

Drops code size, makes strides towards accurate source location representation,
slight (~1.7%) progression on Cocoa.h because of complexity drop.

llvm-svn: 84907
2009-10-22 22:37:11 +00:00
Steve Naroff 20bad0b7c6 Extend clang_getCursor() to take a 'relativeDecl' argument (so speed up searching). Without a 'relativeDecl', the algorithm is n-squared. For example, running the following command on 'Large.m' takes hours without a 'relatvieDecl'.
snaroff% time ../../Debug/bin/c-index-test Large.ast all > Large.out
snaroff% cat Large.m
#import <Cocoa/Cocoa.h>
#import <QuickTime/QuickTime.h>
#import <OpenGL/OpenGL.h>

With a 'relativeDecl', it takes <30 seconds:-)

llvm-svn: 84760
2009-10-21 13:56:23 +00:00
Daniel Dunbar 2c422dc9ca Move clients to use IdentifierInfo::getNameStart() instead of getName()
llvm-svn: 84436
2009-10-18 20:26:12 +00:00
John McCall 1700197e65 Clone the full Type hierarchy into the TypeLoc hierarchy. Normalize
TypeLoc class names to be $(Type classname)Loc.  Rewrite the visitor.
Provide skeleton implementations for all the new TypeLocs.

Handle all cases in PCH.  Handle a few more cases when inserting
location information in SemaType.

It should be extremely straightforward to add new location information
to existing TypeLoc objects now.

llvm-svn: 84386
2009-10-18 01:05:36 +00:00
Douglas Gregor 01249503fe Installation of Clang libraries and headers, from Axel Naumann!
llvm-svn: 83582
2009-10-08 22:15:31 +00:00
Argyrios Kyrtzidis 8da9ce6328 Pull TypeLocVisitor into its own header file.
llvm-svn: 83112
2009-09-29 21:27:32 +00:00
Argyrios Kyrtzidis 4361bc1b43 Keep track of type references in DeclReferenceMap.
llvm-svn: 83111
2009-09-29 21:26:53 +00:00
Argyrios Kyrtzidis 9c28a3d13c In ASTVisitor, call the correct base methods.
llvm-svn: 83110
2009-09-29 21:26:35 +00:00
Argyrios Kyrtzidis f881301d3a Resolve a source location inside the return type of a functon.
llvm-svn: 83101
2009-09-29 19:58:16 +00:00
Argyrios Kyrtzidis 05677cae08 Resolve a source location that is inside a type declarator.
llvm-svn: 83098
2009-09-29 19:45:41 +00:00
Argyrios Kyrtzidis 4cbe85904c Modify ASTLocation and apart from being a Decl or Stmt, allow it to also be:
-A NamedDecl reference
-A TypeLoc

llvm-svn: 83095
2009-09-29 19:44:27 +00:00
Argyrios Kyrtzidis 81aba1fe53 Add more const-goodness to ASTLocation.
llvm-svn: 83087
2009-09-29 19:39:53 +00:00
Mike Stump 11289f4280 Remove tabs, and whitespace cleanups.
llvm-svn: 81346
2009-09-09 15:08:12 +00:00
Douglas Gregor 76d8c5725f Don't install Clang libraries.
llvm-svn: 79824
2009-08-23 05:02:18 +00:00
Argyrios Kyrtzidis 260a4703a9 For a CXXOperatorCallExpr, fix the order that StmtLocResolver uses to check subexpressions.
llvm-svn: 77713
2009-07-31 19:02:11 +00:00
Ted Kremenek 118cef36b8 Lexically order files.
llvm-svn: 77607
2009-07-30 17:41:23 +00:00
Argyrios Kyrtzidis fc2ed30ab8 Fix Selector <-> GlobalSelector conversion.
llvm-svn: 77575
2009-07-30 03:42:08 +00:00
Eli Friedman 13ddd8514f Fix gcc warning.
llvm-svn: 77555
2009-07-30 00:11:31 +00:00
Argyrios Kyrtzidis bd92767014 Add support for ObjC message expressions, in the Analyzer:
-Accept an ObjC method and find all message expressions that this method may respond to.
-Accept an ObjC message expression and find all methods that may respond to it.

llvm-svn: 77551
2009-07-30 00:03:55 +00:00
Argyrios Kyrtzidis ce60c5ea60 Update CMake.
llvm-svn: 77548
2009-07-30 00:02:19 +00:00
Argyrios Kyrtzidis 2eff90515f Support ObjC methods as Entities.
llvm-svn: 77547
2009-07-29 23:41:46 +00:00
Argyrios Kyrtzidis d70a92139f Index the selectors and provide the translation units that contain them
through the IndexProvider.

llvm-svn: 77543
2009-07-29 23:41:18 +00:00
Argyrios Kyrtzidis b8470e4f75 Introduce SelectorMap whose purpose is to map selectors to objc methods and message exprs,
inside a particular ASTContext.

llvm-svn: 77541
2009-07-29 23:40:58 +00:00
Argyrios Kyrtzidis 34be01b9f4 Find references inside blocks.
llvm-svn: 77540
2009-07-29 23:40:48 +00:00
Argyrios Kyrtzidis c3deb79049 Use helper class ASTVisitor to fully traverse an AST.
llvm-svn: 77539
2009-07-29 23:40:39 +00:00
Argyrios Kyrtzidis d219a9a763 Introduce the GlobalSelector class in the Indexing library.
GlobalSelector is an ASTContext-independent way to refer to Objective C selectors.

llvm-svn: 77538
2009-07-29 23:40:32 +00:00
Argyrios Kyrtzidis ca8a0e24cb Use an IdentifierTable for names used for Entities.
llvm-svn: 77537
2009-07-29 23:40:21 +00:00
Argyrios Kyrtzidis 91d3df0b53 -Introduce the idx::Analyzer class used for getting indexing information, like finding
references of a declaration across translation units.

-Modify the index-test tool to use it.

llvm-svn: 77536
2009-07-29 23:40:14 +00:00