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