Ted Kremenek | 16c440a | 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 | 2e331b9 | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 18 | #include "clang/Basic/SourceLocation.h" |
| 19 | #include <utility> |
Ted Kremenek | 16c440a | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 20 | |
| 21 | namespace clang { |
| 22 | |
| 23 | class Decl; |
Douglas Gregor | 283cae3 | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 24 | class Expr; |
| 25 | class NamedDecl; |
Douglas Gregor | 2e331b9 | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 26 | class ObjCInterfaceDecl; |
Douglas Gregor | 78db0cd | 2010-01-16 15:44:18 +0000 | [diff] [blame] | 27 | class ObjCProtocolDecl; |
Ted Kremenek | 16c440a | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 28 | class Stmt; |
| 29 | |
| 30 | namespace cxcursor { |
| 31 | |
| 32 | CXCursor MakeCXCursor(CXCursorKind K, clang::Decl *D); |
| 33 | CXCursor MakeCXCursor(CXCursorKind K, clang::Decl *D, clang::Stmt *S); |
Ted Kremenek | edc8aa6 | 2010-01-16 00:36:30 +0000 | [diff] [blame] | 34 | CXCursor MakeCXCursor(clang::Decl *D); |
Ted Kremenek | 16c440a | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 35 | |
Douglas Gregor | 2e331b9 | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 36 | /// \brief Create an Objective-C superclass reference at the given location. |
| 37 | CXCursor MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super, |
| 38 | SourceLocation Loc); |
| 39 | |
| 40 | /// \brief Unpack an ObjCSuperClassRef cursor into the interface it references |
| 41 | /// and optionally the location where the reference occurred. |
| 42 | std::pair<ObjCInterfaceDecl *, SourceLocation> |
Douglas Gregor | 78db0cd | 2010-01-16 15:44:18 +0000 | [diff] [blame] | 43 | getCursorObjCSuperClassRef(CXCursor C); |
| 44 | |
| 45 | /// \brief Create an Objective-C protocol reference at the given location. |
| 46 | CXCursor MakeCursorObjCProtocolRef(ObjCProtocolDecl *Proto, SourceLocation Loc); |
| 47 | |
| 48 | /// \brief Unpack an ObjCProtocolRef cursor into the protocol it references |
| 49 | /// and optionally the location where the reference occurred. |
| 50 | std::pair<ObjCProtocolDecl *, SourceLocation> |
| 51 | getCursorObjCProtocolRef(CXCursor C); |
Douglas Gregor | 2e331b9 | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 52 | |
Douglas Gregor | 1adb082 | 2010-01-16 17:14:40 +0000 | [diff] [blame^] | 53 | /// \brief Create an Objective-C class reference at the given location. |
| 54 | CXCursor MakeCursorObjCClassRef(ObjCInterfaceDecl *Class, SourceLocation Loc); |
| 55 | |
| 56 | /// \brief Unpack an ObjCClassRef cursor into the class it references |
| 57 | /// and optionally the location where the reference occurred. |
| 58 | std::pair<ObjCInterfaceDecl *, SourceLocation> |
| 59 | getCursorObjCClassRef(CXCursor C); |
| 60 | |
Douglas Gregor | 283cae3 | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 61 | Decl *getCursorDecl(CXCursor Cursor); |
| 62 | Expr *getCursorExpr(CXCursor Cursor); |
| 63 | Stmt *getCursorStmt(CXCursor Cursor); |
| 64 | Decl *getCursorReferringDecl(CXCursor Cursor); |
Douglas Gregor | 283cae3 | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 65 | |
| 66 | bool operator==(CXCursor X, CXCursor Y); |
| 67 | |
| 68 | inline bool operator!=(CXCursor X, CXCursor Y) { |
| 69 | return !(X == Y); |
| 70 | } |
| 71 | |
Ted Kremenek | 16c440a | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 72 | }} // end namespace: clang::cxcursor |
| 73 | |
| 74 | #endif |