blob: a924a0e7bac83cdf67273cc63e4825019938518b [file] [log] [blame]
Ted Kremenek87553c42010-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
15#define LLVM_CLANG_CXCursor_H
16
17#include "clang-c/Index.h"
Douglas Gregor6c8959b2010-01-16 14:00:32 +000018#include "clang/Basic/SourceLocation.h"
19#include <utility>
Ted Kremenek87553c42010-01-15 20:35:54 +000020
21namespace clang {
22
Douglas Gregor7ecd0202010-01-18 23:41:10 +000023class ASTContext;
Ted Kremenek87553c42010-01-15 20:35:54 +000024class Decl;
Douglas Gregorc58d05b2010-01-15 21:56:13 +000025class Expr;
26class NamedDecl;
Douglas Gregor6c8959b2010-01-16 14:00:32 +000027class ObjCInterfaceDecl;
Douglas Gregoref6eb842010-01-16 15:44:18 +000028class ObjCProtocolDecl;
Ted Kremenek87553c42010-01-15 20:35:54 +000029class Stmt;
30
31namespace cxcursor {
32
33CXCursor MakeCXCursor(CXCursorKind K, clang::Decl *D);
Douglas Gregor7ecd0202010-01-18 23:41:10 +000034CXCursor MakeCXCursor(CXCursorKind K, clang::Decl *D, clang::Stmt *S,
35 ASTContext &Context);
Ted Kremenekc2aa0f12010-01-16 00:36:30 +000036CXCursor MakeCXCursor(clang::Decl *D);
Ted Kremenek87553c42010-01-15 20:35:54 +000037
Douglas Gregor6c8959b2010-01-16 14:00:32 +000038/// \brief Create an Objective-C superclass reference at the given location.
39CXCursor 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.
44std::pair<ObjCInterfaceDecl *, SourceLocation>
Douglas Gregoref6eb842010-01-16 15:44:18 +000045 getCursorObjCSuperClassRef(CXCursor C);
46
47/// \brief Create an Objective-C protocol reference at the given location.
48CXCursor 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.
52std::pair<ObjCProtocolDecl *, SourceLocation>
53 getCursorObjCProtocolRef(CXCursor C);
Douglas Gregor6c8959b2010-01-16 14:00:32 +000054
Douglas Gregor46d66142010-01-16 17:14:40 +000055/// \brief Create an Objective-C class reference at the given location.
56CXCursor 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.
60std::pair<ObjCInterfaceDecl *, SourceLocation>
61 getCursorObjCClassRef(CXCursor C);
62
Douglas Gregorc58d05b2010-01-15 21:56:13 +000063Decl *getCursorDecl(CXCursor Cursor);
64Expr *getCursorExpr(CXCursor Cursor);
65Stmt *getCursorStmt(CXCursor Cursor);
Douglas Gregor7ecd0202010-01-18 23:41:10 +000066ASTContext &getCursorContext(CXCursor Cursor);
Douglas Gregorc58d05b2010-01-15 21:56:13 +000067
68bool operator==(CXCursor X, CXCursor Y);
69
70inline bool operator!=(CXCursor X, CXCursor Y) {
71 return !(X == Y);
72}
73
Ted Kremenek87553c42010-01-15 20:35:54 +000074}} // end namespace: clang::cxcursor
75
76#endif