blob: 5f81c8a17315d9243d1e671c4b21112de0f8179b [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;
31
32namespace cxcursor {
33
Douglas Gregor58552bc2010-01-20 23:34:41 +000034CXCursor MakeCXCursorInvalid(CXCursorKind K);
Douglas Gregorfed36b12010-01-20 23:57:43 +000035CXCursor MakeCXCursor(clang::Stmt *S, clang::Decl *Parent, ASTUnit *TU);
36CXCursor MakeCXCursor(clang::Decl *D, ASTUnit *TU);
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,
Douglas Gregorfed36b12010-01-20 23:57:43 +000040 SourceLocation Loc,
41 ASTUnit *TU);
Douglas Gregor6c8959b2010-01-16 14:00:32 +000042
43/// \brief Unpack an ObjCSuperClassRef cursor into the interface it references
44/// and optionally the location where the reference occurred.
45std::pair<ObjCInterfaceDecl *, SourceLocation>
Douglas Gregoref6eb842010-01-16 15:44:18 +000046 getCursorObjCSuperClassRef(CXCursor C);
47
48/// \brief Create an Objective-C protocol reference at the given location.
Douglas Gregorfed36b12010-01-20 23:57:43 +000049CXCursor MakeCursorObjCProtocolRef(ObjCProtocolDecl *Proto, SourceLocation Loc,
50 ASTUnit *TU);
Douglas Gregoref6eb842010-01-16 15:44:18 +000051
52/// \brief Unpack an ObjCProtocolRef cursor into the protocol it references
53/// and optionally the location where the reference occurred.
54std::pair<ObjCProtocolDecl *, SourceLocation>
55 getCursorObjCProtocolRef(CXCursor C);
Douglas Gregor6c8959b2010-01-16 14:00:32 +000056
Douglas Gregor46d66142010-01-16 17:14:40 +000057/// \brief Create an Objective-C class reference at the given location.
Douglas Gregorfed36b12010-01-20 23:57:43 +000058CXCursor MakeCursorObjCClassRef(ObjCInterfaceDecl *Class, SourceLocation Loc,
59 ASTUnit *TU);
Douglas Gregor46d66142010-01-16 17:14:40 +000060
61/// \brief Unpack an ObjCClassRef cursor into the class it references
62/// and optionally the location where the reference occurred.
63std::pair<ObjCInterfaceDecl *, SourceLocation>
64 getCursorObjCClassRef(CXCursor C);
65
Douglas Gregorc58d05b2010-01-15 21:56:13 +000066Decl *getCursorDecl(CXCursor Cursor);
67Expr *getCursorExpr(CXCursor Cursor);
68Stmt *getCursorStmt(CXCursor Cursor);
Douglas Gregor7ecd0202010-01-18 23:41:10 +000069ASTContext &getCursorContext(CXCursor Cursor);
Douglas Gregorfed36b12010-01-20 23:57:43 +000070ASTUnit *getCursorASTUnit(CXCursor Cursor);
Douglas Gregorc58d05b2010-01-15 21:56:13 +000071
72bool operator==(CXCursor X, CXCursor Y);
73
74inline bool operator!=(CXCursor X, CXCursor Y) {
75 return !(X == Y);
76}
77
Ted Kremenek87553c42010-01-15 20:35:54 +000078}} // end namespace: clang::cxcursor
79
80#endif