Commit Graph

119 Commits

Author SHA1 Message Date
David Blaikie bbafb8a745 Unify naming of LangOptions variable/get function across the Clang stack (Lex to AST).
The member variable is always "LangOpts" and the member function is always "getLangOpts".

Reviewed by Chris Lattner

llvm-svn: 152536
2012-03-11 07:00:24 +00:00
Anna Zaks b8b21e9b56 Unbreak the CMake builds following the CallGraph change.
llvm-svn: 151952
2012-03-02 23:18:45 +00:00
Anna Zaks fc5dfe9f7c [analyzer] Rename clang::CallGraph into clang::idx::CallGraph + rename
the corresponding files to avoid confusion.

This is a preparation to adding an AST-based call graph to Analysis. The
existing call graph works with indexer entries. We might be able to
refactor it to use the AST based graph in the future.

(Minimal testing here as the only example that uses the API has been
completely broken, does not compile.)

llvm-svn: 151950
2012-03-02 22:54:36 +00:00
David Blaikie e4d798f078 More dead code removal (using -Wunreachable-code)
llvm-svn: 148577
2012-01-20 21:50:17 +00:00
David Blaikie f47fa304a4 Remove unnecessary default cases in switches over enums.
This allows -Wswitch-enum to find switches that need updating when these enums are modified.

llvm-svn: 148281
2012-01-17 02:30:50 +00:00
Douglas Gregor 0b144e160a Replace all comparisons between ObjCInterfaceDecl pointers with calls
to declaresSameEntity(), as a baby step toward tracking forward
declarations of Objective-C classes precisely. Part of
<rdar://problem/10583531>.

llvm-svn: 146618
2011-12-15 00:29:59 +00:00
Benjamin Kramer b89514a9b8 Change operator<< for raw_ostream and NamedDecl to take a reference instead of a pointer.
Passing a pointer was a bad idea as it collides with the overload for void*.

llvm-svn: 141971
2011-10-14 18:45:37 +00:00
David Blaikie aa347f9392 Removing a bunch of dead returns/breaks after llvm_unreachables.
llvm-svn: 140407
2011-09-23 20:26:49 +00:00
David Blaikie 83d382b1ca Switch assert(0/false) llvm_unreachable.
llvm-svn: 140367
2011-09-23 05:06:16 +00:00
Chris Lattner 0e62c1cc0b remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports
them into the clang namespace.

llvm-svn: 135852
2011-07-23 10:55:15 +00:00
Chris Lattner 01cf8db38b now that we have a centralized place to do so, add some using declarations for
some common llvm types: stringref and smallvector.  This cleans up the codebase
quite a bit.

llvm-svn: 135576
2011-07-20 06:58:45 +00:00
Alexis Hunt 4a8ea1092a Modify some deleted function methods to better reflect reality:
- New isDefined() function checks for deletedness
 - isThisDeclarationADefinition checks for deletedness
 - New doesThisDeclarationHaveABody() does what
   isThisDeclarationADefinition() used to do
 - The IsDeleted bit is not propagated across redeclarations
 - isDeleted() now checks the canoncial declaration
 - New isDeletedAsWritten() does what it says on the tin.
 - isUserProvided() now correct (thanks Richard!)

This fixes the bug that we weren't catching

void foo() = delete;
void foo() {}

as being a redefinition.

llvm-svn: 131013
2011-05-06 20:44:56 +00:00
Richard Smith dda56e4b4a Support for C++11 (non-template) alias declarations.
llvm-svn: 129567
2011-04-15 14:24:37 +00:00
Chris Lattner 57540c5be0 fix a bunch of comment typos found by codespell. Patch by
Luis Felipe Strano Moraes!

llvm-svn: 129559
2011-04-15 05:22:18 +00:00
John McCall 8322c3a197 Give some convenient idiomatic accessors to Stmt::child_range and
Stmt::const_child_range, then make a bunch of places use them instead
of the individual iterator accessors.

llvm-svn: 125450
2011-02-13 04:07:26 +00:00
NAKAMURA Takumi 98dd73d66c CMake: LLVM_NO_RTTI must be obsolete now!
llvm-svn: 125275
2011-02-10 09:15:32 +00:00
Douglas Gregor 8f78579f9d Fix CMake clangIndex library dependencies, from Logan Chien
llvm-svn: 114336
2010-09-20 18:32:29 +00:00
Michael J. Spencer 09476212de Revert "CMake: Update to use standard CMake dependency tracking facilities instead"
This reverts commit r113631

Conflicts:

	CMakeLists.txt
	lib/CodeGen/CMakeLists.txt

llvm-svn: 113817
2010-09-13 23:54:41 +00:00
Michael J. Spencer 0881f4a367 CMake: Update to use standard CMake dependency tracking facilities instead
of whatever we were using before...

llvm-svn: 113631
2010-09-10 21:13:16 +00:00
Douglas Gregor c9199f522f Clean up CMake dependencies
llvm-svn: 113489
2010-09-09 15:44:58 +00:00
Douglas Gregor b2f0713ddc Clean up some of the CMake dependencies
llvm-svn: 113416
2010-09-08 21:40:53 +00:00
John McCall 8e7d656a4a De-memberify the VarDecl and FunctionDecl StorageClass enums.
This lets us remove Sema.h's dependency on Expr.h and Decl.h.

llvm-svn: 112156
2010-08-26 03:08:43 +00:00
Douglas Gregor 549c1cd2c5 Remove unused location-to-AST-node resolver. libclang's implementation supercedes it
llvm-svn: 108708
2010-07-19 16:18:30 +00:00
Chris Lattner ad4f38b1a9 BUILD_ARCHIVE is the default for libraries, no need to set it.
llvm-svn: 108633
2010-07-18 00:14:47 +00:00
Zhongxing Xu b525bce698 Collect function definitions in the Indexer when indexing through the ASTs.
Add an API to get an Entity associated with a name in the global namespace.

llvm-svn: 107642
2010-07-06 05:55:13 +00:00
Zhongxing Xu f894cfb44f Local variables have no linkage, make invalid Entities.
llvm-svn: 107630
2010-07-06 01:20:49 +00:00
Zhongxing Xu 1bbbc2e509 Refrase comments.
llvm-svn: 107607
2010-07-05 02:36:16 +00:00
Zhongxing Xu 74458782cc Although in C++ class name has external linkage, usually the definition of the
class is available in the same translation unit when it's needed. So we make 
all of them invalid Entity.

llvm-svn: 107606
2010-07-05 02:35:40 +00:00
Zhongxing Xu 57012ee70d Make FieldDecl an invalid Entity since it has no linkage.
llvm-svn: 107605
2010-07-05 02:31:16 +00:00
Zhongxing Xu 5776d439ca Indexer: make FieldDecl an internal Entity.
llvm-svn: 107604
2010-07-05 01:44:14 +00:00
Zhongxing Xu a74c22daec Change CallGraph::Prog to be a reference. idx::Program means to be a global object to the Index library.
llvm-svn: 107461
2010-07-02 06:39:46 +00:00
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