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 |
| 15 | #define LLVM_CLANG_CXCursor_H |
| 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 | 87553c4 | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 25 | class Decl; |
Douglas Gregor | c58d05b | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 26 | class Expr; |
| 27 | class NamedDecl; |
Douglas Gregor | 6c8959b | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 28 | class ObjCInterfaceDecl; |
Douglas Gregor | ef6eb84 | 2010-01-16 15:44:18 +0000 | [diff] [blame] | 29 | class ObjCProtocolDecl; |
Ted Kremenek | 87553c4 | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 30 | class Stmt; |
| 31 | |
| 32 | namespace cxcursor { |
| 33 | |
Douglas Gregor | 58552bc | 2010-01-20 23:34:41 +0000 | [diff] [blame] | 34 | CXCursor MakeCXCursorInvalid(CXCursorKind K); |
Douglas Gregor | fed36b1 | 2010-01-20 23:57:43 +0000 | [diff] [blame^] | 35 | CXCursor MakeCXCursor(clang::Stmt *S, clang::Decl *Parent, ASTUnit *TU); |
| 36 | CXCursor MakeCXCursor(clang::Decl *D, ASTUnit *TU); |
Ted Kremenek | 87553c4 | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 37 | |
Douglas Gregor | 6c8959b | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 38 | /// \brief Create an Objective-C superclass reference at the given location. |
| 39 | CXCursor MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super, |
Douglas Gregor | fed36b1 | 2010-01-20 23:57:43 +0000 | [diff] [blame^] | 40 | SourceLocation Loc, |
| 41 | ASTUnit *TU); |
Douglas Gregor | 6c8959b | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 42 | |
| 43 | /// \brief Unpack an ObjCSuperClassRef cursor into the interface it references |
| 44 | /// and optionally the location where the reference occurred. |
| 45 | std::pair<ObjCInterfaceDecl *, SourceLocation> |
Douglas Gregor | ef6eb84 | 2010-01-16 15:44:18 +0000 | [diff] [blame] | 46 | getCursorObjCSuperClassRef(CXCursor C); |
| 47 | |
| 48 | /// \brief Create an Objective-C protocol reference at the given location. |
Douglas Gregor | fed36b1 | 2010-01-20 23:57:43 +0000 | [diff] [blame^] | 49 | CXCursor MakeCursorObjCProtocolRef(ObjCProtocolDecl *Proto, SourceLocation Loc, |
| 50 | ASTUnit *TU); |
Douglas Gregor | ef6eb84 | 2010-01-16 15:44:18 +0000 | [diff] [blame] | 51 | |
| 52 | /// \brief Unpack an ObjCProtocolRef cursor into the protocol it references |
| 53 | /// and optionally the location where the reference occurred. |
| 54 | std::pair<ObjCProtocolDecl *, SourceLocation> |
| 55 | getCursorObjCProtocolRef(CXCursor C); |
Douglas Gregor | 6c8959b | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 56 | |
Douglas Gregor | 46d6614 | 2010-01-16 17:14:40 +0000 | [diff] [blame] | 57 | /// \brief Create an Objective-C class reference at the given location. |
Douglas Gregor | fed36b1 | 2010-01-20 23:57:43 +0000 | [diff] [blame^] | 58 | CXCursor MakeCursorObjCClassRef(ObjCInterfaceDecl *Class, SourceLocation Loc, |
| 59 | ASTUnit *TU); |
Douglas Gregor | 46d6614 | 2010-01-16 17:14:40 +0000 | [diff] [blame] | 60 | |
| 61 | /// \brief Unpack an ObjCClassRef cursor into the class it references |
| 62 | /// and optionally the location where the reference occurred. |
| 63 | std::pair<ObjCInterfaceDecl *, SourceLocation> |
| 64 | getCursorObjCClassRef(CXCursor C); |
| 65 | |
Douglas Gregor | c58d05b | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 66 | Decl *getCursorDecl(CXCursor Cursor); |
| 67 | Expr *getCursorExpr(CXCursor Cursor); |
| 68 | Stmt *getCursorStmt(CXCursor Cursor); |
Douglas Gregor | 7ecd020 | 2010-01-18 23:41:10 +0000 | [diff] [blame] | 69 | ASTContext &getCursorContext(CXCursor Cursor); |
Douglas Gregor | fed36b1 | 2010-01-20 23:57:43 +0000 | [diff] [blame^] | 70 | ASTUnit *getCursorASTUnit(CXCursor Cursor); |
Douglas Gregor | c58d05b | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 71 | |
| 72 | bool operator==(CXCursor X, CXCursor Y); |
| 73 | |
| 74 | inline bool operator!=(CXCursor X, CXCursor Y) { |
| 75 | return !(X == Y); |
| 76 | } |
| 77 | |
Ted Kremenek | 87553c4 | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 78 | }} // end namespace: clang::cxcursor |
| 79 | |
| 80 | #endif |