CXCursor.h revision b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0
116c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek//===- CXCursor.h - Routines for manipulating CXCursors -------------------===//
216c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek//
316c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek//                     The LLVM Compiler Infrastructure
416c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek//
516c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek// This file is distributed under the University of Illinois Open Source
616c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek// License. See LICENSE.TXT for details.
716c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek//
816c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek//===----------------------------------------------------------------------===//
916c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek//
1016c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek// This file defines routines for manipulating CXCursors.
1116c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek//
1216c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek//===----------------------------------------------------------------------===//
1316c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek
1416c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek#ifndef LLVM_CLANG_CXCURSOR_H
1516c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek#define LLVM_CLANG_CXCursor_H
1616c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek
1716c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek#include "clang-c/Index.h"
182e331b938b38057e333fab0ba841130ea8467794Douglas Gregor#include "clang/Basic/SourceLocation.h"
192e331b938b38057e333fab0ba841130ea8467794Douglas Gregor#include <utility>
2016c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek
2116c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremeneknamespace clang {
2216c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek
23f46034af49435a4d1a0085a4738343122aeb6521Douglas Gregorclass ASTContext;
24b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregorclass ASTUnit;
2516c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenekclass Decl;
26283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregorclass Expr;
27283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregorclass NamedDecl;
282e331b938b38057e333fab0ba841130ea8467794Douglas Gregorclass ObjCInterfaceDecl;
2978db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregorclass ObjCProtocolDecl;
3016c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenekclass Stmt;
3116c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek
3216c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremeneknamespace cxcursor {
3316c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek
345bfb8c128c2ac8eb4032afc180cdc400a0f953caDouglas GregorCXCursor MakeCXCursorInvalid(CXCursorKind K);
35b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas GregorCXCursor MakeCXCursor(clang::Stmt *S, clang::Decl *Parent, ASTUnit *TU);
36b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas GregorCXCursor MakeCXCursor(clang::Decl *D, ASTUnit *TU);
3716c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek
382e331b938b38057e333fab0ba841130ea8467794Douglas Gregor/// \brief Create an Objective-C superclass reference at the given location.
392e331b938b38057e333fab0ba841130ea8467794Douglas GregorCXCursor MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super,
40b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor                                     SourceLocation Loc,
41b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor                                     ASTUnit *TU);
422e331b938b38057e333fab0ba841130ea8467794Douglas Gregor
432e331b938b38057e333fab0ba841130ea8467794Douglas Gregor/// \brief Unpack an ObjCSuperClassRef cursor into the interface it references
442e331b938b38057e333fab0ba841130ea8467794Douglas Gregor/// and optionally the location where the reference occurred.
452e331b938b38057e333fab0ba841130ea8467794Douglas Gregorstd::pair<ObjCInterfaceDecl *, SourceLocation>
4678db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor  getCursorObjCSuperClassRef(CXCursor C);
4778db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor
4878db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor/// \brief Create an Objective-C protocol reference at the given location.
49b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas GregorCXCursor MakeCursorObjCProtocolRef(ObjCProtocolDecl *Proto, SourceLocation Loc,
50b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor                                   ASTUnit *TU);
5178db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor
5278db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor/// \brief Unpack an ObjCProtocolRef cursor into the protocol it references
5378db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor/// and optionally the location where the reference occurred.
5478db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregorstd::pair<ObjCProtocolDecl *, SourceLocation>
5578db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor  getCursorObjCProtocolRef(CXCursor C);
562e331b938b38057e333fab0ba841130ea8467794Douglas Gregor
571adb082a709f7b588f03672999294e061234b2cfDouglas Gregor/// \brief Create an Objective-C class reference at the given location.
58b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas GregorCXCursor MakeCursorObjCClassRef(ObjCInterfaceDecl *Class, SourceLocation Loc,
59b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor                                ASTUnit *TU);
601adb082a709f7b588f03672999294e061234b2cfDouglas Gregor
611adb082a709f7b588f03672999294e061234b2cfDouglas Gregor/// \brief Unpack an ObjCClassRef cursor into the class it references
621adb082a709f7b588f03672999294e061234b2cfDouglas Gregor/// and optionally the location where the reference occurred.
631adb082a709f7b588f03672999294e061234b2cfDouglas Gregorstd::pair<ObjCInterfaceDecl *, SourceLocation>
641adb082a709f7b588f03672999294e061234b2cfDouglas Gregor  getCursorObjCClassRef(CXCursor C);
651adb082a709f7b588f03672999294e061234b2cfDouglas Gregor
66283cae37b03047c14ef918503bc46b08405c3b69Douglas GregorDecl *getCursorDecl(CXCursor Cursor);
67283cae37b03047c14ef918503bc46b08405c3b69Douglas GregorExpr *getCursorExpr(CXCursor Cursor);
68283cae37b03047c14ef918503bc46b08405c3b69Douglas GregorStmt *getCursorStmt(CXCursor Cursor);
69f46034af49435a4d1a0085a4738343122aeb6521Douglas GregorASTContext &getCursorContext(CXCursor Cursor);
70b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas GregorASTUnit *getCursorASTUnit(CXCursor Cursor);
71283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor
72283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregorbool operator==(CXCursor X, CXCursor Y);
73283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor
74283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregorinline bool operator!=(CXCursor X, CXCursor Y) {
75283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor  return !(X == Y);
76283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor}
77283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor
7816c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek}} // end namespace: clang::cxcursor
7916c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek
8016c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek#endif
81