blob: 30fb26c936bfed443e752ea54fde4587010a2c79 [file] [log] [blame]
Ted Kremenek16c440a2010-01-15 20:35:54 +00001//===- 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 Kremenek2cd10b02010-01-25 21:09:34 +000015#define LLVM_CLANG_CXCURSOR_H
Ted Kremenek16c440a2010-01-15 20:35:54 +000016
17#include "clang-c/Index.h"
Douglas Gregor2e331b92010-01-16 14:00:32 +000018#include "clang/Basic/SourceLocation.h"
19#include <utility>
Ted Kremenek16c440a2010-01-15 20:35:54 +000020
21namespace clang {
22
Douglas Gregorf46034a2010-01-18 23:41:10 +000023class ASTContext;
Douglas Gregorb2cd4872010-01-20 23:57:43 +000024class ASTUnit;
Ted Kremenek16c440a2010-01-15 20:35:54 +000025class Decl;
Douglas Gregor283cae32010-01-15 21:56:13 +000026class Expr;
27class NamedDecl;
Douglas Gregor2e331b92010-01-16 14:00:32 +000028class ObjCInterfaceDecl;
Douglas Gregor78db0cd2010-01-16 15:44:18 +000029class ObjCProtocolDecl;
Ted Kremenek16c440a2010-01-15 20:35:54 +000030class Stmt;
Douglas Gregor7d0d40e2010-01-21 16:28:34 +000031class TypeDecl;
Ted Kremenek16c440a2010-01-15 20:35:54 +000032
33namespace cxcursor {
34
Douglas Gregor5bfb8c12010-01-20 23:34:41 +000035CXCursor MakeCXCursorInvalid(CXCursorKind K);
Douglas Gregorb2cd4872010-01-20 23:57:43 +000036CXCursor MakeCXCursor(clang::Stmt *S, clang::Decl *Parent, ASTUnit *TU);
37CXCursor MakeCXCursor(clang::Decl *D, ASTUnit *TU);
Ted Kremenek16c440a2010-01-15 20:35:54 +000038
Douglas Gregor2e331b92010-01-16 14:00:32 +000039/// \brief Create an Objective-C superclass reference at the given location.
40CXCursor MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super,
Douglas Gregorb2cd4872010-01-20 23:57:43 +000041 SourceLocation Loc,
42 ASTUnit *TU);
Douglas Gregor2e331b92010-01-16 14:00:32 +000043
44/// \brief Unpack an ObjCSuperClassRef cursor into the interface it references
45/// and optionally the location where the reference occurred.
46std::pair<ObjCInterfaceDecl *, SourceLocation>
Douglas Gregor78db0cd2010-01-16 15:44:18 +000047 getCursorObjCSuperClassRef(CXCursor C);
48
49/// \brief Create an Objective-C protocol reference at the given location.
Douglas Gregorb2cd4872010-01-20 23:57:43 +000050CXCursor MakeCursorObjCProtocolRef(ObjCProtocolDecl *Proto, SourceLocation Loc,
51 ASTUnit *TU);
Douglas Gregor78db0cd2010-01-16 15:44:18 +000052
53/// \brief Unpack an ObjCProtocolRef cursor into the protocol it references
54/// and optionally the location where the reference occurred.
55std::pair<ObjCProtocolDecl *, SourceLocation>
56 getCursorObjCProtocolRef(CXCursor C);
Douglas Gregor2e331b92010-01-16 14:00:32 +000057
Douglas Gregor1adb0822010-01-16 17:14:40 +000058/// \brief Create an Objective-C class reference at the given location.
Douglas Gregorb2cd4872010-01-20 23:57:43 +000059CXCursor MakeCursorObjCClassRef(ObjCInterfaceDecl *Class, SourceLocation Loc,
60 ASTUnit *TU);
Douglas Gregor1adb0822010-01-16 17:14:40 +000061
62/// \brief Unpack an ObjCClassRef cursor into the class it references
63/// and optionally the location where the reference occurred.
64std::pair<ObjCInterfaceDecl *, SourceLocation>
65 getCursorObjCClassRef(CXCursor C);
66
Douglas Gregor7d0d40e2010-01-21 16:28:34 +000067/// \brief Create a type reference at the given location.
68CXCursor 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.
72std::pair<TypeDecl *, SourceLocation> getCursorTypeRef(CXCursor C);
73
Douglas Gregor283cae32010-01-15 21:56:13 +000074Decl *getCursorDecl(CXCursor Cursor);
75Expr *getCursorExpr(CXCursor Cursor);
76Stmt *getCursorStmt(CXCursor Cursor);
Douglas Gregorf46034a2010-01-18 23:41:10 +000077ASTContext &getCursorContext(CXCursor Cursor);
Douglas Gregorb2cd4872010-01-20 23:57:43 +000078ASTUnit *getCursorASTUnit(CXCursor Cursor);
Douglas Gregor283cae32010-01-15 21:56:13 +000079
80bool operator==(CXCursor X, CXCursor Y);
81
82inline bool operator!=(CXCursor X, CXCursor Y) {
83 return !(X == Y);
84}
85
Ted Kremenek16c440a2010-01-15 20:35:54 +000086}} // end namespace: clang::cxcursor
87
88#endif