Ted Kremenek | 87553c4 | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 1 | //===- CXCursor.h - Routines for manipulating CXCursors -------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines routines for manipulating CXCursors. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_CLANG_CXCURSOR_H |
Ted Kremenek | 6dc73bc | 2010-01-25 21:09:34 +0000 | [diff] [blame] | 15 | #define LLVM_CLANG_CXCURSOR_H |
Ted Kremenek | 87553c4 | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 16 | |
| 17 | #include "clang-c/Index.h" |
Douglas Gregor | 6c8959b | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 18 | #include "clang/Basic/SourceLocation.h" |
| 19 | #include <utility> |
Ted Kremenek | 87553c4 | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 20 | |
| 21 | namespace clang { |
| 22 | |
Douglas Gregor | 7ecd020 | 2010-01-18 23:41:10 +0000 | [diff] [blame] | 23 | class ASTContext; |
Douglas Gregor | fed36b1 | 2010-01-20 23:57:43 +0000 | [diff] [blame] | 24 | class ASTUnit; |
Ted Kremenek | bff3143 | 2010-02-18 03:09:07 +0000 | [diff] [blame] | 25 | class Attr; |
Ted Kremenek | 87553c4 | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 26 | class Decl; |
Douglas Gregor | c58d05b | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 27 | class Expr; |
| 28 | class NamedDecl; |
Douglas Gregor | 6c8959b | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 29 | class ObjCInterfaceDecl; |
Douglas Gregor | ef6eb84 | 2010-01-16 15:44:18 +0000 | [diff] [blame] | 30 | class ObjCProtocolDecl; |
Ted Kremenek | 87553c4 | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 31 | class Stmt; |
Douglas Gregor | 93f8995 | 2010-01-21 16:28:34 +0000 | [diff] [blame] | 32 | class TypeDecl; |
Ted Kremenek | 87553c4 | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 33 | |
| 34 | namespace cxcursor { |
| 35 | |
Ted Kremenek | bff3143 | 2010-02-18 03:09:07 +0000 | [diff] [blame] | 36 | CXCursor MakeCXCursor(const clang::Attr *A, clang::Decl *Parent, ASTUnit *TU); |
Douglas Gregor | fed36b1 | 2010-01-20 23:57:43 +0000 | [diff] [blame] | 37 | CXCursor MakeCXCursor(clang::Decl *D, ASTUnit *TU); |
Ted Kremenek | bff3143 | 2010-02-18 03:09:07 +0000 | [diff] [blame] | 38 | CXCursor MakeCXCursor(clang::Stmt *S, clang::Decl *Parent, ASTUnit *TU); |
| 39 | CXCursor MakeCXCursorInvalid(CXCursorKind K); |
Ted Kremenek | 87553c4 | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 40 | |
Douglas Gregor | 6c8959b | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 41 | /// \brief Create an Objective-C superclass reference at the given location. |
| 42 | CXCursor MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super, |
Douglas Gregor | fed36b1 | 2010-01-20 23:57:43 +0000 | [diff] [blame] | 43 | SourceLocation Loc, |
| 44 | ASTUnit *TU); |
Douglas Gregor | 6c8959b | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 45 | |
| 46 | /// \brief Unpack an ObjCSuperClassRef cursor into the interface it references |
| 47 | /// and optionally the location where the reference occurred. |
| 48 | std::pair<ObjCInterfaceDecl *, SourceLocation> |
Douglas Gregor | ef6eb84 | 2010-01-16 15:44:18 +0000 | [diff] [blame] | 49 | getCursorObjCSuperClassRef(CXCursor C); |
| 50 | |
| 51 | /// \brief Create an Objective-C protocol reference at the given location. |
Douglas Gregor | fed36b1 | 2010-01-20 23:57:43 +0000 | [diff] [blame] | 52 | CXCursor MakeCursorObjCProtocolRef(ObjCProtocolDecl *Proto, SourceLocation Loc, |
| 53 | ASTUnit *TU); |
Douglas Gregor | ef6eb84 | 2010-01-16 15:44:18 +0000 | [diff] [blame] | 54 | |
| 55 | /// \brief Unpack an ObjCProtocolRef cursor into the protocol it references |
| 56 | /// and optionally the location where the reference occurred. |
| 57 | std::pair<ObjCProtocolDecl *, SourceLocation> |
| 58 | getCursorObjCProtocolRef(CXCursor C); |
Douglas Gregor | 6c8959b | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 59 | |
Douglas Gregor | 46d6614 | 2010-01-16 17:14:40 +0000 | [diff] [blame] | 60 | /// \brief Create an Objective-C class reference at the given location. |
Douglas Gregor | fed36b1 | 2010-01-20 23:57:43 +0000 | [diff] [blame] | 61 | CXCursor MakeCursorObjCClassRef(ObjCInterfaceDecl *Class, SourceLocation Loc, |
| 62 | ASTUnit *TU); |
Douglas Gregor | 46d6614 | 2010-01-16 17:14:40 +0000 | [diff] [blame] | 63 | |
| 64 | /// \brief Unpack an ObjCClassRef cursor into the class it references |
| 65 | /// and optionally the location where the reference occurred. |
| 66 | std::pair<ObjCInterfaceDecl *, SourceLocation> |
| 67 | getCursorObjCClassRef(CXCursor C); |
| 68 | |
Douglas Gregor | 93f8995 | 2010-01-21 16:28:34 +0000 | [diff] [blame] | 69 | /// \brief Create a type reference at the given location. |
| 70 | CXCursor MakeCursorTypeRef(TypeDecl *Type, SourceLocation Loc, ASTUnit *TU); |
| 71 | |
| 72 | /// \brief Unpack a TypeRef cursor into the class it references |
| 73 | /// and optionally the location where the reference occurred. |
| 74 | std::pair<TypeDecl *, SourceLocation> getCursorTypeRef(CXCursor C); |
| 75 | |
Douglas Gregor | 92a524f | 2010-03-18 00:42:48 +0000 | [diff] [blame^] | 76 | /// \brief Create a preprocessing directive cursor. |
| 77 | CXCursor MakePreprocessingDirectiveCursor(SourceRange Range, ASTUnit *TU); |
| 78 | |
| 79 | /// \brief Unpack a given preprocessing directive to retrieve its source range. |
| 80 | SourceRange getCursorPreprocessingDirective(CXCursor C); |
| 81 | |
Douglas Gregor | c58d05b | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 82 | Decl *getCursorDecl(CXCursor Cursor); |
| 83 | Expr *getCursorExpr(CXCursor Cursor); |
| 84 | Stmt *getCursorStmt(CXCursor Cursor); |
Douglas Gregor | 7ecd020 | 2010-01-18 23:41:10 +0000 | [diff] [blame] | 85 | ASTContext &getCursorContext(CXCursor Cursor); |
Douglas Gregor | fed36b1 | 2010-01-20 23:57:43 +0000 | [diff] [blame] | 86 | ASTUnit *getCursorASTUnit(CXCursor Cursor); |
Douglas Gregor | c58d05b | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 87 | |
| 88 | bool operator==(CXCursor X, CXCursor Y); |
| 89 | |
| 90 | inline bool operator!=(CXCursor X, CXCursor Y) { |
| 91 | return !(X == Y); |
| 92 | } |
| 93 | |
Ted Kremenek | 87553c4 | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 94 | }} // end namespace: clang::cxcursor |
| 95 | |
| 96 | #endif |