aboutsummaryrefslogtreecommitdiff
path: root/tools/CIndex
AgeCommit message (Collapse)Author
2010-04-30Rename 'CIndex' to 'libclang', since it has basically become our stable publicDaniel Dunbar
(C) API, and will likely grow further in this direction in the future. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102779 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-30Teach clang_getLocation() to cope with a NULL file argument.Douglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102748 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29Add USR support for 'static inline' functions (which can be declared in ↵Ted Kremenek
header files). Add USR support for 'static' functions and local variables, which can be handy for resolving named variables within a translation unit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102641 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29Remove USRGenerator::VisitBlockDecl(). We don't need to generate USRs for ↵Ted Kremenek
blocks, since they have no linkage and by definition are anonymous. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102640 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-28Completely reimplement __builtin_offsetof, based on a patch by RobertoDouglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-22Make TemplateDecl and ObjCContainerDecl abstractDouglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102145 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-21CXXNamedCastExpr is actually an abstract expression.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101994 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-21Overhaul the AST representation of Objective-C message sendDouglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101972 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-20Fix USRs for 'extern' variables declaration in functions/method bodies.Ted Kremenek
Fix USRs for @synthesize. Add more USR tests. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101954 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-20Keep proper source location information for the type in an Objective-CDouglas Gregor
@encode expression. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101907 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-17Add raw_ostream operators to NamedDecl for convenience. Switch over all ↵Benjamin Kramer
users of getNameAsString on a stream. The next step is to print the name directly into the stream, avoiding a temporary std::string copy. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101632 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-17Send code completion data in json format.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101586 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-17Remove unneeded assertion and don't return a null CXString.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101585 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-16Rework USR generation for symbols with no linkage. Many of the USRs are now ↵Ted Kremenek
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-16Convert libCIndex to use the new native EXPORTED_SYMBOL_FILE mechanism.Dan Gohman
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101440 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-15Better support USRs for anonymous enums, structs, by including the location ↵Ted Kremenek
where the tag was declared. WIP. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101403 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-15Do not generate USRs for declarations with 'no linkage' except for enums, ↵Ted Kremenek
structs, typedefs. Those still need work to disambiguate them across translation units. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101401 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-15Add optional timing logging for code completion results. This causes a UDP ↵Ted Kremenek
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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101326 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-13Add cursor kind for C++ methods.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101193 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-12Add 'clang_getCursorLanguage' to return the "language" of the AST element ↵Ted Kremenek
(e.g., distinguish between C and Objective-C language features). Currently this only returns results for declarations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101070 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-12Sort exports file.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101069 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-12Prune includes.Benjamin Kramer
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101059 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-11Add initial USR support for macro definitions.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100997 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-11Augment clang_getCursorUSR() to not always expect that clang_getCursorDecl() ↵Ted Kremenek
does the right thing if the cursor is not a decl (such as in the case of macros). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100996 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-11Add CIndex support for blocks.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100989 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-08CIndex: move extractUSRSuffix out of extern "C" and simplify it.Benjamin Kramer
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100773 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-07Fix CIndex crash on invalid code reported in <rdar://problem/7833619>.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100589 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-05Make Diagnostic reference-counted, which is simpler than jugglingDouglas Gregor
maybe-ownership vs. ownership. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100498 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-05Match MemoryBuffer API changes.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100484 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-05Clarify the ownership semantics of the Diagnostic object used byDouglas Gregor
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>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100464 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-05Minor ASTUnit cleanups:Douglas Gregor
- Rename "Diagnostics" and related to "StoredDiagnostics", to better capture what we're actually storing. - Move SourceManager and FileManager to the heap. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100441 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-05Code completion results that refer to macros now get the cursor kindDouglas Gregor
of macro definitions when passed to CIndex. Add test for code completion of macros via CIndex. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100431 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31Reinstate my CodeModificationHint -> FixItHint renaming patch, withoutDouglas Gregor
the C-only "optimization". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100022 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31Revert r100008, which inexplicably breaks the clang-i686-darwin10 builderDouglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100018 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31Rename CodeModificationHint to FixItHint, since we've been using theDouglas Gregor
term "fix-it" everywhere and even *I* get tired of long names sometimes. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100008 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-26Return translation units from clang_createTranslationUnitFromSource()Ted Kremenek
if even they contain errors. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99594 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-25Require that all Clang-based USRs start with the prefix 'c:' for the "USR ↵Ted Kremenek
space". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99475 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-24Make sure that we have File IDs for all of the unsaved files before weDouglas Gregor
deserialize diagnostics. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99426 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-22Use the cursor's ASTContext rather than the ASTContext computed from aDouglas Gregor
declaration, just in case invalid code makes the latter incorrect. This may be the cause behind <rdar://problem/7777070>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99179 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-22Use DEFINE_SYMBOL property to control dllexport/dllimportKovarththanan Rajaratnam
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99176 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-20Fix unused variable warning.Daniel Dunbar
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99021 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-20Optimize region-of-interest based cursor walks through theDouglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99015 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19Implement serialization and lazy deserialization of the preprocessingDouglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99002 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19Teach clang_getCursorKindSpelling() about CXCursor_InvalidCode.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98982 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19Make the CIndex API more resilient to being used on invalid code.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98981 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19Optionally store a PreprocessingRecord in the preprocessor itself, andDouglas Gregor
tie its creation to a CC1 flag -detailed-preprocessing-record. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98963 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19Visit preprocessing elements (macro instantiations and macroDouglas Gregor
definitions) as part of the translation unit, so that normal visitation, token-annotation, and cursor-at retrieval all see preprocessing elements. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98935 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19Revert 98907 since it is breaking buildbots.Bob Wilson
--- Reverse-merging r98907 into '.': D test/Index/c-index-getCursor-pp.c U tools/CIndex/CIndex.cpp git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98929 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19Visit preprocessing elements (macro instantiations and macroDouglas Gregor
definitions) as part of the translation unit, so that normal visitation, token-annotation, and cursor-at retrieval all see preprocessing elements. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98907 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18Try to appease MSVC's standard libraryDouglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98878 91177308-0d34-0410-b5e6-96231b3b80d8