blob: ff474edade4587d66d40e52a429a79403c110f14 [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
15#define LLVM_CLANG_CXCursor_H
16
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
23class Decl;
Douglas Gregor283cae32010-01-15 21:56:13 +000024class Expr;
25class NamedDecl;
Douglas Gregor2e331b92010-01-16 14:00:32 +000026class ObjCInterfaceDecl;
Douglas Gregor78db0cd2010-01-16 15:44:18 +000027class ObjCProtocolDecl;
Ted Kremenek16c440a2010-01-15 20:35:54 +000028class Stmt;
29
30namespace cxcursor {
31
32CXCursor MakeCXCursor(CXCursorKind K, clang::Decl *D);
33CXCursor MakeCXCursor(CXCursorKind K, clang::Decl *D, clang::Stmt *S);
Ted Kremenekedc8aa62010-01-16 00:36:30 +000034CXCursor MakeCXCursor(clang::Decl *D);
Ted Kremenek16c440a2010-01-15 20:35:54 +000035
Douglas Gregor2e331b92010-01-16 14:00:32 +000036/// \brief Create an Objective-C superclass reference at the given location.
37CXCursor 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.
42std::pair<ObjCInterfaceDecl *, SourceLocation>
Douglas Gregor78db0cd2010-01-16 15:44:18 +000043 getCursorObjCSuperClassRef(CXCursor C);
44
45/// \brief Create an Objective-C protocol reference at the given location.
46CXCursor 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.
50std::pair<ObjCProtocolDecl *, SourceLocation>
51 getCursorObjCProtocolRef(CXCursor C);
Douglas Gregor2e331b92010-01-16 14:00:32 +000052
Douglas Gregor1adb0822010-01-16 17:14:40 +000053/// \brief Create an Objective-C class reference at the given location.
54CXCursor 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.
58std::pair<ObjCInterfaceDecl *, SourceLocation>
59 getCursorObjCClassRef(CXCursor C);
60
Douglas Gregor283cae32010-01-15 21:56:13 +000061Decl *getCursorDecl(CXCursor Cursor);
62Expr *getCursorExpr(CXCursor Cursor);
63Stmt *getCursorStmt(CXCursor Cursor);
64Decl *getCursorReferringDecl(CXCursor Cursor);
Douglas Gregor283cae32010-01-15 21:56:13 +000065
66bool operator==(CXCursor X, CXCursor Y);
67
68inline bool operator!=(CXCursor X, CXCursor Y) {
69 return !(X == Y);
70}
71
Ted Kremenek16c440a2010-01-15 20:35:54 +000072}} // end namespace: clang::cxcursor
73
74#endif