aboutsummaryrefslogtreecommitdiff
path: root/tools/CIndex/CXCursor.cpp
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-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-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-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-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-18Expose macro definitions as CIndex cursors. These can still only beDouglas Gregor
generated by clang_annotateTokens(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98837 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18Introduce the notion of a "preprocessing record", which keeps track ofDouglas Gregor
the macro definitions and macro instantiations that are found during preprocessing. Preprocessing records are *not* generated by default; rather, we provide a PPCallbacks subclass that hooks into the existing callback mechanism to record this activity. The only client of preprocessing records is CIndex, which keeps track of macro definitions and instantations so that they can be exposed via cursors. At present, only token annotation uses these facilities, and only for macro instantiations; both will change in the near future. However, with this change, token annotation properly annotates macro instantiations that do not produce any tokens and instantiations of macros that are later undef'd, improving our consistency. Preprocessing directives that are not macro definitions are still handled by clang_annotateTokens() via re-lexing, so that we don't have to track every preprocessing directive in the preprocessing record. Performance impact of preprocessing records is still TBD, although it is limited to CIndex and therefore out of the path of the main compiler. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98836 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18More token-annotation experimentation, preprocessing the annotatedDouglas Gregor
token sequence to detect macro instantiations (that produce at least token). WIP. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98826 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18Experimental stab at using relexing to identify preprocessorDouglas Gregor
directives while annotating tokens in CIndex. This functionality should probably be factored out of this routine, but we're not there yet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98786 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18Start adding cursor kinds for attributes, with first exposingTed Kremenek
IBActionAttr and IBOutletAttr respectively. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96563 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-03Remove abstract expression kinds from the StmtClass enum. Update a few usersJohn McCall
appropriately. Call out a few missing cases in the expression mangler. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95176 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29Add an CXXBindReferenceExpr (not used just yet).Anders Carlsson
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94791 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-25CIndex: Don't crash when visitor passes null child statements, and sprinkle someDaniel Dunbar
asserts in cursor construction functions to make this more obvious. Doug, please check. c-index-test would previously crash on this code: -- for(;;) {} -- Do we need a custom visit of the for statement to cover the variable declarations? git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94391 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21Introduce type references into the C API, capturing references toDouglas Gregor
typedefs only (for now). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94078 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20Stash a CXXUnit pointer into each cursor. This allows us to simplifyDouglas Gregor
the interface to clang_visitChildren() by eliminating the CXTranslationUnit pointer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94051 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20Eliminate the MakeCXCursor routines that require their callers to know too ↵Douglas Gregor
much about the cursor's storage git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94049 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20Introduce a special cursor kind for the translation unit, to serve asDouglas Gregor
the root of the conceptual cursor hierarchy (just like we do with declarations). This will be used when we get to unify clang_loadTranslationUnit() and clang_loadDeclaration() into something more generally useful. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93954 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19Kill CXCursor_ObjCSelectorRef, CXCursor_VarRef, CXCursor_FunctionRef,Douglas Gregor
and CXCursor_EnumConstantRef; they've been subsumed by expression references, which do a much nicer job. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93947 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19Extend the CIndex API with direct support for expressions andDouglas Gregor
statements, moving some of the more unnatural kinds of references (VarRef, EnumConstantRef, etc.) over to the expressions. We can now poke at arbitrary expressions and statements with, e.g., clang_getCursor() and get back useful information (e.g., source ranges). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93946 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19Kill the unused and unnecessary CXCursor_MemberRef, twin to theDouglas Gregor
now-dead CXCursor_ObjCIvarRef. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93928 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19Kill CXCursor_ObjCIvarRef. Such cursors could never be created, andDouglas Gregor
have been marked for death for a while. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93927 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19Introduce the notion of an "unexposed" declaration into the CIndexDouglas Gregor
API. This is a catch-all for any declaration known to Clang but not specifically part of the CIndex API. We'll use the same approach with expressions, statements, references, etc., as needed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93924 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19Eliminate cursor kinds used to express definitions. Instead, provideDouglas Gregor
CIndex functions that (1) map from a reference or declaration to the corresponding definition, if available, and (2) determine whether a given declaration cursor is also a definition. This eliminates a lot of duplication in the cursor kinds, and maps more closely to the Clang ASTs. This is another API + ABI breaker with no deprecation. Yay, progress. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93893 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18Teach clang_getCursorLocation() to return the locations of referencesDouglas Gregor
rather than the locations that refer to. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93812 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18Explicitly not handle ObjCForwardProtocolDecl in GetCursorKind().Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93779 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-16Give ObjCClassRef cursors a sane representation, which is encapsulatedDouglas Gregor
in CXCursor.cpp. With this sane representation, fix the class reference that is part of Objective-C category declarations so that the cursor's location matches up with the reference, not the class being referred to. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93640 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-16Use a sane encoding for CXCursor_ObjCProtocolRef, using the actualDouglas Gregor
source locations where the protocols were referenced rather than the location of some random enclosing declaration. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93637 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-16Give CXCursor_ObjCSuperClassRef a sane encoding, which is only knownDouglas Gregor
to CXCursor.cpp. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93634 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-16Add mapping from ObjCPropertDecl to CXCursorKind.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93623 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-16Remove TranslateKind and centralize Decl -> CXCursorKind in GetCursorKind(). ↵Ted Kremenek
This revealed a bunch of inconsistencies in how CXCursorKinds were being computed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93618 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-16Migrate Decl* -> cursorkind logic into CXCursor.cpp, and drastically tighten ↵Ted Kremenek
TUVisitor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93599 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15Make CXCursor's data opaque.Douglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93561 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15Add CXCursor.[h,cpp]. These files will centralize the logic for ↵Ted Kremenek
creating/probing CXCursors. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93547 91177308-0d34-0410-b5e6-96231b3b80d8