blob: 546dd7f485433c480f095a4866f508bc2ea94803 [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;
Douglas Gregorfed36b12010-01-20 23:57:43 +000024class ASTUnit;
Ted Kremenek87553c42010-01-15 20:35:54 +000025class Decl;
Douglas Gregorc58d05b2010-01-15 21:56:13 +000026class Expr;
27class NamedDecl;
Douglas Gregor6c8959b2010-01-16 14:00:32 +000028class ObjCInterfaceDecl;
Douglas Gregoref6eb842010-01-16 15:44:18 +000029class ObjCProtocolDecl;
Ted Kremenek87553c42010-01-15 20:35:54 +000030class Stmt;
Douglas Gregor93f89952010-01-21 16:28:34 +000031class TypeDecl;
Ted Kremenek87553c42010-01-15 20:35:54 +000032
33namespace cxcursor {
34
Douglas Gregor58552bc2010-01-20 23:34:41 +000035CXCursor MakeCXCursorInvalid(CXCursorKind K);
Douglas Gregorfed36b12010-01-20 23:57:43 +000036CXCursor MakeCXCursor(clang::Stmt *S, clang::Decl *Parent, ASTUnit *TU);
37CXCursor MakeCXCursor(clang::Decl *D, ASTUnit *TU);
Ted Kremenek87553c42010-01-15 20:35:54 +000038
Douglas Gregor6c8959b2010-01-16 14:00:32 +000039/// \brief Create an Objective-C superclass reference at the given location.
40CXCursor MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super,
Douglas Gregorfed36b12010-01-20 23:57:43 +000041 SourceLocation Loc,
42 ASTUnit *TU);
Douglas Gregor6c8959b2010-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 Gregoref6eb842010-01-16 15:44:18 +000047 getCursorObjCSuperClassRef(CXCursor C);
48
49/// \brief Create an Objective-C protocol reference at the given location.
Douglas Gregorfed36b12010-01-20 23:57:43 +000050CXCursor MakeCursorObjCProtocolRef(ObjCProtocolDecl *Proto, SourceLocation Loc,
51 ASTUnit *TU);
Douglas Gregoref6eb842010-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 Gregor6c8959b2010-01-16 14:00:32 +000057
Douglas Gregor46d66142010-01-16 17:14:40 +000058/// \brief Create an Objective-C class reference at the given location.
Douglas Gregorfed36b12010-01-20 23:57:43 +000059CXCursor MakeCursorObjCClassRef(ObjCInterfaceDecl *Class, SourceLocation Loc,
60 ASTUnit *TU);
Douglas Gregor46d66142010-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 Gregor93f89952010-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 Gregorc58d05b2010-01-15 21:56:13 +000074Decl *getCursorDecl(CXCursor Cursor);
75Expr *getCursorExpr(CXCursor Cursor);
76Stmt *getCursorStmt(CXCursor Cursor);
Douglas Gregor7ecd0202010-01-18 23:41:10 +000077ASTContext &getCursorContext(CXCursor Cursor);
Douglas Gregorfed36b12010-01-20 23:57:43 +000078ASTUnit *getCursorASTUnit(CXCursor Cursor);
Douglas Gregorc58d05b2010-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 Kremenek87553c42010-01-15 20:35:54 +000086}} // end namespace: clang::cxcursor
87
88#endif