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