summaryrefslogtreecommitdiffstats
path: root/clang/tools/CIndex
Commit message (Collapse)AuthorAgeFilesLines
* Rename 'CIndex' to 'libclang', since it has basically become our stable publicDaniel Dunbar2010-04-3015-5054/+0
| | | | | | (C) API, and will likely grow further in this direction in the future. llvm-svn: 102779
* Teach clang_getLocation() to cope with a NULL file argument.Douglas Gregor2010-04-301-2/+2
| | | | llvm-svn: 102748
* Add USR support for 'static inline' functions (which can be declared in ↵Ted Kremenek2010-04-291-5/+20
| | | | | | | | header files). Add USR support for 'static' functions and local variables, which can be handy for resolving named variables within a translation unit. llvm-svn: 102641
* Remove USRGenerator::VisitBlockDecl(). We don't need to generate USRs for ↵Ted Kremenek2010-04-291-7/+0
| | | | | | | | blocks, since they have no linkage and by definition are anonymous. llvm-svn: 102640
* Completely reimplement __builtin_offsetof, based on a patch by RobertoDouglas Gregor2010-04-282-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Amadini. This change introduces a new expression node type, OffsetOfExpr, that describes __builtin_offsetof. Previously, __builtin_offsetof was implemented using a unary operator whose subexpression involved various synthesized array-subscript and member-reference expressions, which was ugly and made it very hard to instantiate as a template. OffsetOfExpr represents the AST more faithfully, with proper type source information and a more compact representation. OffsetOfExpr also has support for dependent __builtin_offsetof expressions; it can be value-dependent, but will never be type-dependent (like sizeof or alignof). This commit introduces template instantiation for __builtin_offsetof as well. There are two major caveats to this patch: 1) CodeGen cannot handle the case where __builtin_offsetof is not a constant expression, so it produces an error. So, to avoid regressing in C, we retain the old UnaryOperator-based __builtin_offsetof implementation in C while using the shiny new OffsetOfExpr implementation in C++. The old implementation can go away once we have proper CodeGen support for this case, which we expect won't cause much trouble in C++. 2) __builtin_offsetof doesn't work well with non-POD class types, particularly when the designated field is found within a base class. I will address this in a subsequent patch. Fixes PR5880 and a bunch of assertions when building Boost.Python tests. llvm-svn: 102542
* Make TemplateDecl and ObjCContainerDecl abstractDouglas Gregor2010-04-221-4/+0
| | | | llvm-svn: 102145
* CXXNamedCastExpr is actually an abstract expression.Zhongxing Xu2010-04-211-1/+0
| | | | llvm-svn: 101994
* Overhaul the AST representation of Objective-C message sendDouglas Gregor2010-04-211-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix USRs for 'extern' variables declaration in functions/method bodies.Ted Kremenek2010-04-201-2/+34
| | | | | | | Fix USRs for @synthesize. Add more USR tests. llvm-svn: 101954
* Keep proper source location information for the type in an Objective-CDouglas Gregor2010-04-201-0/+6
| | | | | | @encode expression. llvm-svn: 101907
* Add raw_ostream operators to NamedDecl for convenience. Switch over all ↵Benjamin Kramer2010-04-171-3/+3
| | | | | | | | 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
* Send code completion data in json format.Ted Kremenek2010-04-171-7/+9
| | | | llvm-svn: 101586
* Remove unneeded assertion and don't return a null CXString.Ted Kremenek2010-04-171-3/+1
| | | | llvm-svn: 101585
* Rework USR generation for symbols with no linkage. Many of the USRs are now ↵Ted Kremenek2010-04-161-28/+64
| | | | | | | | | | shortened, and we now include the file name that declares the symbol with no linkage in the USR. USRs for such symbols are generated only in restructed cases, e.g., anonymous enum declarations, typedefs, etc. llvm-svn: 101542
* Convert libCIndex to use the new native EXPORTED_SYMBOL_FILE mechanism.Dan Gohman2010-04-164-83/+169
| | | | | | | | libCIndex also has a CMakeLists.txt file which has its own code for using the exports file. To preserve existing functionality, create a separate darwin-specific exports file for use by this CMakeLists.txt code. llvm-svn: 101440
* Better support USRs for anonymous enums, structs, by including the location ↵Ted Kremenek2010-04-151-3/+42
| | | | | | | | where the tag was declared. WIP. llvm-svn: 101403
* Do not generate USRs for declarations with 'no linkage' except for enums, ↵Ted Kremenek2010-04-151-7/+28
| | | | | | | | structs, typedefs. Those still need work to disambiguate them across translation units. llvm-svn: 101401
* Add optional timing logging for code completion results. This causes a UDP ↵Ted Kremenek2010-04-151-0/+87
| | | | | | | | | packet containing the time taken for the code completion to be sent to a designated server (which is specified using a compile-time -D flag). llvm-svn: 101326
* Add cursor kind for C++ methods.Ted Kremenek2010-04-132-0/+3
| | | | llvm-svn: 101193
* Add 'clang_getCursorLanguage' to return the "language" of the AST element ↵Ted Kremenek2010-04-122-0/+64
| | | | | | (e.g., distinguish between C and Objective-C language features). Currently this only returns results for declarations. llvm-svn: 101070
* Sort exports file.Ted Kremenek2010-04-121-3/+3
| | | | llvm-svn: 101069
* Prune includes.Benjamin Kramer2010-04-129-17/+22
| | | | llvm-svn: 101059
* Add initial USR support for macro definitions.Ted Kremenek2010-04-111-1/+11
| | | | llvm-svn: 100997
* Augment clang_getCursorUSR() to not always expect that clang_getCursorDecl() ↵Ted Kremenek2010-04-111-5/+11
| | | | | | | | does the right thing if the cursor is not a decl (such as in the case of macros). llvm-svn: 100996
* Add CIndex support for blocks.Ted Kremenek2010-04-111-2/+19
| | | | llvm-svn: 100989
* CIndex: move extractUSRSuffix out of extern "C" and simplify it.Benjamin Kramer2010-04-081-6/+4
| | | | llvm-svn: 100773
* Fix CIndex crash on invalid code reported in <rdar://problem/7833619>.Ted Kremenek2010-04-071-2/+3
| | | | llvm-svn: 100589
* Make Diagnostic reference-counted, which is simpler than jugglingDouglas Gregor2010-04-052-5/+6
| | | | | | maybe-ownership vs. ownership. llvm-svn: 100498
* Match MemoryBuffer API changes.Chris Lattner2010-04-051-3/+2
| | | | llvm-svn: 100484
* Clarify the ownership semantics of the Diagnostic object used byDouglas Gregor2010-04-051-9/+5
| | | | | | | | | ASTUnit. Previously, we would end up with use-after-free errors because the Diagnostic object would be creating in one place (say, CIndex) and its ownership would not be transferred into the ASTUnit. Fixes <rdar://problem/7818608>. llvm-svn: 100464
* Minor ASTUnit cleanups:Douglas Gregor2010-04-052-6/+6
| | | | | | | | - Rename "Diagnostics" and related to "StoredDiagnostics", to better capture what we're actually storing. - Move SourceManager and FileManager to the heap. llvm-svn: 100441
* Code completion results that refer to macros now get the cursor kindDouglas Gregor2010-04-051-1/+1
| | | | | | | of macro definitions when passed to CIndex. Add test for code completion of macros via CIndex. llvm-svn: 100431
* Reinstate my CodeModificationHint -> FixItHint renaming patch, withoutDouglas Gregor2010-03-311-1/+1
| | | | | | the C-only "optimization". llvm-svn: 100022
* Revert r100008, which inexplicably breaks the clang-i686-darwin10 builderDouglas Gregor2010-03-311-1/+1
| | | | llvm-svn: 100018
* Rename CodeModificationHint to FixItHint, since we've been using theDouglas Gregor2010-03-311-1/+1
| | | | | | | term "fix-it" everywhere and even *I* get tired of long names sometimes. No functionality change. llvm-svn: 100008
* Return translation units from clang_createTranslationUnitFromSource()Ted Kremenek2010-03-261-2/+1
| | | | | | if even they contain errors. llvm-svn: 99594
* Require that all Clang-based USRs start with the prefix 'c:' for the "USR ↵Ted Kremenek2010-03-251-6/+15
| | | | | | space". llvm-svn: 99475
* Make sure that we have File IDs for all of the unsaved files before weDouglas Gregor2010-03-241-0/+1
| | | | | | deserialize diagnostics. llvm-svn: 99426
* Use the cursor's ASTContext rather than the ASTContext computed from aDouglas Gregor2010-03-221-2/+2
| | | | | | | declaration, just in case invalid code makes the latter incorrect. This may be the cause behind <rdar://problem/7777070>. llvm-svn: 99179
* Use DEFINE_SYMBOL property to control dllexport/dllimportKovarththanan Rajaratnam2010-03-221-2/+2
| | | | llvm-svn: 99176
* Fix unused variable warning.Daniel Dunbar2010-03-201-2/+1
| | | | llvm-svn: 99021
* Optimize region-of-interest based cursor walks through theDouglas Gregor2010-03-201-6/+49
| | | | | | | | preprocessed entities by grouping preprocessed entities by file ID. This drastically improves performance of repeated clang_getCursor() calls local tests, although it is a bit ugly. llvm-svn: 99015
* Implement serialization and lazy deserialization of the preprocessingDouglas Gregor2010-03-191-24/+9
| | | | | | | | | | | | | | | | | | | | | | | | record (which includes all macro instantiations and definitions). As with all lay deserialization, this introduces a new external source (here, an external preprocessing record source) that loads all of the preprocessed entities prior to iterating over the entities. The preprocessing record is an optional part of the precompiled header that is disabled by default (enabled with -detailed-preprocessing-record). When the preprocessor given to the PCH writer has a preprocessing record, that record is written into the PCH file. When the PCH reader is given a PCH file that contains a preprocessing record, it will be lazily loaded (which, effectively, implicitly adds -detailed-preprocessing-record). This is the first case where we have sections of the precompiled header that are added/removed based on a compilation flag, which is unfortunate. However, this data consumes ~550k in the PCH file for Cocoa.h (out of ~9.9MB), and there is a non-trivial cost to gathering this detailed preprocessing information, so it's too expensive to turn on by default. In the future, we should investigate a better encoding of this information. llvm-svn: 99002
* Teach clang_getCursorKindSpelling() about CXCursor_InvalidCode.Ted Kremenek2010-03-191-0/+2
| | | | llvm-svn: 98982
* Make the CIndex API more resilient to being used on invalid code.Ted Kremenek2010-03-193-9/+29
| | | | llvm-svn: 98981
* Optionally store a PreprocessingRecord in the preprocessor itself, andDouglas Gregor2010-03-191-6/+9
| | | | | | tie its creation to a CC1 flag -detailed-preprocessing-record. llvm-svn: 98963
* Visit preprocessing elements (macro instantiations and macroDouglas Gregor2010-03-191-106/+48
| | | | | | | | definitions) as part of the translation unit, so that normal visitation, token-annotation, and cursor-at retrieval all see preprocessing elements. llvm-svn: 98935
* Revert 98907 since it is breaking buildbots.Bob Wilson2010-03-191-45/+106
| | | | | | | | --- Reverse-merging r98907 into '.': D test/Index/c-index-getCursor-pp.c U tools/CIndex/CIndex.cpp llvm-svn: 98929
* Visit preprocessing elements (macro instantiations and macroDouglas Gregor2010-03-191-106/+45
| | | | | | | | definitions) as part of the translation unit, so that normal visitation, token-annotation, and cursor-at retrieval all see preprocessing elements. llvm-svn: 98907
* Try to appease MSVC's standard libraryDouglas Gregor2010-03-181-0/+14
| | | | llvm-svn: 98878
OpenPOWER on IntegriCloud