CXCursor.cpp revision 6931900f43cea558c6974075256c07728dbfecc6
116c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek//===- CXCursor.cpp - 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// 102e331b938b38057e333fab0ba841130ea8467794Douglas Gregor// This file defines routines for manipulating CXCursors. It should be the 112e331b938b38057e333fab0ba841130ea8467794Douglas Gregor// only file that has internal knowledge of the encoding of the data in 122e331b938b38057e333fab0ba841130ea8467794Douglas Gregor// CXCursor. 1316c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek// 1416c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek//===----------------------------------------------------------------------===// 1516c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek 1616c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek#include "CXCursor.h" 177eaa8ae8692c5cd3eed8cb334fe5346470522091Douglas Gregor#include "clang/Frontend/ASTUnit.h" 1816c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek#include "clang/AST/Decl.h" 196931900f43cea558c6974075256c07728dbfecc6Douglas Gregor#include "clang/AST/DeclCXX.h" 20283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor#include "clang/AST/DeclObjC.h" 21283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor#include "clang/AST/Expr.h" 22edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek#include "llvm/Support/ErrorHandling.h" 2316c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek 2416c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenekusing namespace clang; 2516c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek 265bfb8c128c2ac8eb4032afc180cdc400a0f953caDouglas GregorCXCursor cxcursor::MakeCXCursorInvalid(CXCursorKind K) { 275bfb8c128c2ac8eb4032afc180cdc400a0f953caDouglas Gregor assert(K >= CXCursor_FirstInvalid && K <= CXCursor_LastInvalid); 285bfb8c128c2ac8eb4032afc180cdc400a0f953caDouglas Gregor CXCursor C = { K, { 0, 0, 0 } }; 295bfb8c128c2ac8eb4032afc180cdc400a0f953caDouglas Gregor return C; 3016c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek} 3116c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek 32edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenekstatic CXCursorKind GetCursorKind(Decl *D) { 3354d67caeee4fdce81f07163832f1163d5f2af5d2Daniel Dunbar assert(D && "Invalid arguments!"); 34edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek switch (D->getKind()) { 3570ee54258035c860ebc71f7e5f803b74f3186889Ted Kremenek case Decl::Enum: return CXCursor_EnumDecl; 3670ee54258035c860ebc71f7e5f803b74f3186889Ted Kremenek case Decl::EnumConstant: return CXCursor_EnumConstantDecl; 3770ee54258035c860ebc71f7e5f803b74f3186889Ted Kremenek case Decl::Field: return CXCursor_FieldDecl; 38edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek case Decl::Function: 39b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor return CXCursor_FunctionDecl; 40edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek case Decl::ObjCCategory: return CXCursor_ObjCCategoryDecl; 41b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor case Decl::ObjCCategoryImpl: return CXCursor_ObjCCategoryImplDecl; 4270ee54258035c860ebc71f7e5f803b74f3186889Ted Kremenek case Decl::ObjCClass: 4370ee54258035c860ebc71f7e5f803b74f3186889Ted Kremenek // FIXME 44301221313be4f97327e931ead9794dd3a8bce160Douglas Gregor return CXCursor_UnexposedDecl; 456483a773db4d0ea3ab15de5801abe504c1dbc204Ted Kremenek case Decl::ObjCForwardProtocol: 466483a773db4d0ea3ab15de5801abe504c1dbc204Ted Kremenek // FIXME 47301221313be4f97327e931ead9794dd3a8bce160Douglas Gregor return CXCursor_UnexposedDecl; 48b699866820102a69d83d6ac6941985c5ef4e8c40Douglas Gregor case Decl::ObjCImplementation: return CXCursor_ObjCImplementationDecl; 49edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek case Decl::ObjCInterface: return CXCursor_ObjCInterfaceDecl; 5070ee54258035c860ebc71f7e5f803b74f3186889Ted Kremenek case Decl::ObjCIvar: return CXCursor_ObjCIvarDecl; 5170ee54258035c860ebc71f7e5f803b74f3186889Ted Kremenek case Decl::ObjCMethod: 5270ee54258035c860ebc71f7e5f803b74f3186889Ted Kremenek return cast<ObjCMethodDecl>(D)->isInstanceMethod() 5370ee54258035c860ebc71f7e5f803b74f3186889Ted Kremenek ? CXCursor_ObjCInstanceMethodDecl : CXCursor_ObjCClassMethodDecl; 548bd5a69999cfd06b6b5a58fdd04e4f802b2df5a4Ted Kremenek case Decl::CXXMethod: return CXCursor_CXXMethod; 5501829d3afafdfd355cbe93537bc408aeeed964c6Douglas Gregor case Decl::CXXConstructor: return CXCursor_Constructor; 5601829d3afafdfd355cbe93537bc408aeeed964c6Douglas Gregor case Decl::CXXDestructor: return CXCursor_Destructor; 5701829d3afafdfd355cbe93537bc408aeeed964c6Douglas Gregor case Decl::CXXConversion: return CXCursor_ConversionFunction; 5810fa3ccf087e167123fdb0a5e1313c7106c3c1fcTed Kremenek case Decl::ObjCProperty: return CXCursor_ObjCPropertyDecl; 59edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek case Decl::ObjCProtocol: return CXCursor_ObjCProtocolDecl; 6070ee54258035c860ebc71f7e5f803b74f3186889Ted Kremenek case Decl::ParmVar: return CXCursor_ParmDecl; 61edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek case Decl::Typedef: return CXCursor_TypedefDecl; 62edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek case Decl::Var: return CXCursor_VarDecl; 638f06e0e9fec3ca501e5fb129f413adbfc88e82f8Ted Kremenek case Decl::Namespace: return CXCursor_Namespace; 646931900f43cea558c6974075256c07728dbfecc6Douglas Gregor case Decl::NamespaceAlias: return CXCursor_NamespaceAlias; 65fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor case Decl::TemplateTypeParm: return CXCursor_TemplateTypeParameter; 66fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor case Decl::NonTypeTemplateParm:return CXCursor_NonTypeTemplateParameter; 67fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor case Decl::TemplateTemplateParm:return CXCursor_TemplateTemplateParameter; 68fe72e9ceeae6cc8669cd8bb722425300190638eaDouglas Gregor case Decl::FunctionTemplate: return CXCursor_FunctionTemplate; 6939d6f07b056c31e1e6b5946165ed4b23e7887f22Douglas Gregor case Decl::ClassTemplate: return CXCursor_ClassTemplate; 7074dbe640021d96a8dbb85c592471c04449ade81cDouglas Gregor case Decl::ClassTemplatePartialSpecialization: 7174dbe640021d96a8dbb85c592471c04449ade81cDouglas Gregor return CXCursor_ClassTemplatePartialSpecialization; 7239d6f07b056c31e1e6b5946165ed4b23e7887f22Douglas Gregor 73edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek default: 74edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek if (TagDecl *TD = dyn_cast<TagDecl>(D)) { 75edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek switch (TD->getTagKind()) { 766931900f43cea558c6974075256c07728dbfecc6Douglas Gregor case TTK_Struct: return CXCursor_StructDecl; 776931900f43cea558c6974075256c07728dbfecc6Douglas Gregor case TTK_Class: return CXCursor_ClassDecl; 786931900f43cea558c6974075256c07728dbfecc6Douglas Gregor case TTK_Union: return CXCursor_UnionDecl; 796931900f43cea558c6974075256c07728dbfecc6Douglas Gregor case TTK_Enum: return CXCursor_EnumDecl; 80edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek } 81edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek } 82301221313be4f97327e931ead9794dd3a8bce160Douglas Gregor 83301221313be4f97327e931ead9794dd3a8bce160Douglas Gregor return CXCursor_UnexposedDecl; 84edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek } 85edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek 86edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek llvm_unreachable("Invalid Decl"); 87edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek return CXCursor_NotImplemented; 88edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek} 89edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek 90e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenekstatic CXCursorKind GetCursorKind(const Attr *A) { 91e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek assert(A && "Invalid arguments!"); 92e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek switch (A->getKind()) { 93e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek default: break; 94387475d0c18aaeb022108de9d33b6c9fb7998843Sean Hunt case attr::IBAction: return CXCursor_IBActionAttr; 95387475d0c18aaeb022108de9d33b6c9fb7998843Sean Hunt case attr::IBOutlet: return CXCursor_IBOutletAttr; 96387475d0c18aaeb022108de9d33b6c9fb7998843Sean Hunt case attr::IBOutletCollection: return CXCursor_IBOutletCollectionAttr; 97e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek } 98e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek 99e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek return CXCursor_UnexposedAttr; 100e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek} 101e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek 102e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted KremenekCXCursor cxcursor::MakeCXCursor(const Attr *A, Decl *Parent, ASTUnit *TU) { 103e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek assert(A && Parent && TU && "Invalid arguments!"); 104e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek CXCursor C = { GetCursorKind(A), { Parent, (void*)A, TU } }; 105e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek return C; 106e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek} 107e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek 108b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas GregorCXCursor cxcursor::MakeCXCursor(Decl *D, ASTUnit *TU) { 10954d67caeee4fdce81f07163832f1163d5f2af5d2Daniel Dunbar assert(D && TU && "Invalid arguments!"); 110b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor CXCursor C = { GetCursorKind(D), { D, 0, TU } }; 1115bfb8c128c2ac8eb4032afc180cdc400a0f953caDouglas Gregor return C; 112edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek} 113edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek 114b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas GregorCXCursor cxcursor::MakeCXCursor(Stmt *S, Decl *Parent, ASTUnit *TU) { 11554d67caeee4fdce81f07163832f1163d5f2af5d2Daniel Dunbar assert(S && TU && "Invalid arguments!"); 11697b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor CXCursorKind K = CXCursor_NotImplemented; 11797b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor 11897b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor switch (S->getStmtClass()) { 11997b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::NoStmtClass: 12097b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor break; 12197b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor 12297b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::NullStmtClass: 12397b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CompoundStmtClass: 12497b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CaseStmtClass: 12597b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::DefaultStmtClass: 12697b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::LabelStmtClass: 12797b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::IfStmtClass: 12897b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::SwitchStmtClass: 12997b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::WhileStmtClass: 13097b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::DoStmtClass: 13197b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ForStmtClass: 13297b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::GotoStmtClass: 13397b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::IndirectGotoStmtClass: 13497b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ContinueStmtClass: 13597b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::BreakStmtClass: 13697b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ReturnStmtClass: 13797b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::DeclStmtClass: 13897b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::SwitchCaseClass: 13997b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::AsmStmtClass: 14097b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ObjCAtTryStmtClass: 14197b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ObjCAtCatchStmtClass: 14297b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ObjCAtFinallyStmtClass: 14397b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ObjCAtThrowStmtClass: 14497b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ObjCAtSynchronizedStmtClass: 14597b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ObjCForCollectionStmtClass: 14697b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXCatchStmtClass: 14797b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXTryStmtClass: 14897b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor K = CXCursor_UnexposedStmt; 14997b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor break; 15097b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor 15197b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::PredefinedExprClass: 15297b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::IntegerLiteralClass: 15397b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::FloatingLiteralClass: 15497b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ImaginaryLiteralClass: 15597b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::StringLiteralClass: 15697b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CharacterLiteralClass: 15797b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ParenExprClass: 1588ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor case Stmt::UnaryOperatorClass: 1598ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor case Stmt::OffsetOfExprClass: 16097b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::SizeOfAlignOfExprClass: 16197b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ArraySubscriptExprClass: 16297b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::BinaryOperatorClass: 16397b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CompoundAssignOperatorClass: 16497b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ConditionalOperatorClass: 16597b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ImplicitCastExprClass: 16697b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CStyleCastExprClass: 16797b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CompoundLiteralExprClass: 16897b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ExtVectorElementExprClass: 16997b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::InitListExprClass: 17097b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::DesignatedInitExprClass: 17197b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ImplicitValueInitExprClass: 17297b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ParenListExprClass: 17397b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::VAArgExprClass: 17497b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::AddrLabelExprClass: 17597b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::StmtExprClass: 17697b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::TypesCompatibleExprClass: 17797b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ChooseExprClass: 17897b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::GNUNullExprClass: 17997b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXStaticCastExprClass: 18097b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXDynamicCastExprClass: 18197b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXReinterpretCastExprClass: 18297b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXConstCastExprClass: 18397b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXFunctionalCastExprClass: 18497b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXTypeidExprClass: 18597b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXBoolLiteralExprClass: 18697b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXNullPtrLiteralExprClass: 18797b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXThisExprClass: 18897b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXThrowExprClass: 18997b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXDefaultArgExprClass: 190ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor case Stmt::CXXScalarValueInitExprClass: 19197b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXNewExprClass: 19297b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXDeleteExprClass: 19397b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXPseudoDestructorExprClass: 19497b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::UnresolvedLookupExprClass: 19597b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::UnaryTypeTraitExprClass: 19697b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::DependentScopeDeclRefExprClass: 19797b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXBindTemporaryExprClass: 198eb60edffa147e061278c436e513b0df9b4c4e7f6Anders Carlsson case Stmt::CXXBindReferenceExprClass: 19997b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXExprWithTemporariesClass: 20097b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXUnresolvedConstructExprClass: 20197b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXDependentScopeMemberExprClass: 20297b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::UnresolvedMemberExprClass: 20397b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ObjCStringLiteralClass: 20497b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ObjCEncodeExprClass: 20597b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ObjCSelectorExprClass: 20697b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ObjCProtocolExprClass: 20797b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ObjCImplicitSetterGetterRefExprClass: 20897b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ObjCSuperExprClass: 20997b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ObjCIsaExprClass: 21097b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ShuffleVectorExprClass: 21197b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::BlockExprClass: 21297b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor K = CXCursor_UnexposedExpr; 21397b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor break; 21497b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::DeclRefExprClass: 21597b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::BlockDeclRefExprClass: 21697b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor // FIXME: UnresolvedLookupExpr? 21797b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor // FIXME: DependentScopeDeclRefExpr? 21897b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor K = CXCursor_DeclRefExpr; 21997b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor break; 22097b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor 22197b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::MemberExprClass: 22297b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ObjCIvarRefExprClass: 22397b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ObjCPropertyRefExprClass: 22497b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor // FIXME: UnresolvedMemberExpr? 22597b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor // FIXME: CXXDependentScopeMemberExpr? 22697b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor K = CXCursor_MemberRefExpr; 22797b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor break; 22897b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor 22997b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CallExprClass: 23097b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXOperatorCallExprClass: 23197b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXMemberCallExprClass: 23297b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXConstructExprClass: 23397b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXTemporaryObjectExprClass: 23497b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor // FIXME: CXXUnresolvedConstructExpr 23597b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor // FIXME: ObjCImplicitSetterGetterRefExpr? 23697b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor K = CXCursor_CallExpr; 23797b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor break; 23897b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor 23997b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ObjCMessageExprClass: 24097b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor K = CXCursor_ObjCMessageExpr; 24197b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor break; 24297b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor } 24397b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor 244b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor CXCursor C = { K, { Parent, S, TU } }; 24597b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor return C; 24697b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor} 24797b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor 2482e331b938b38057e333fab0ba841130ea8467794Douglas GregorCXCursor cxcursor::MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super, 249b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor SourceLocation Loc, 250b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor ASTUnit *TU) { 25154d67caeee4fdce81f07163832f1163d5f2af5d2Daniel Dunbar assert(Super && TU && "Invalid arguments!"); 2522e331b938b38057e333fab0ba841130ea8467794Douglas Gregor void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); 253b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor CXCursor C = { CXCursor_ObjCSuperClassRef, { Super, RawLoc, TU } }; 2542e331b938b38057e333fab0ba841130ea8467794Douglas Gregor return C; 2552e331b938b38057e333fab0ba841130ea8467794Douglas Gregor} 2562e331b938b38057e333fab0ba841130ea8467794Douglas Gregor 2572e331b938b38057e333fab0ba841130ea8467794Douglas Gregorstd::pair<ObjCInterfaceDecl *, SourceLocation> 2582e331b938b38057e333fab0ba841130ea8467794Douglas Gregorcxcursor::getCursorObjCSuperClassRef(CXCursor C) { 2592e331b938b38057e333fab0ba841130ea8467794Douglas Gregor assert(C.kind == CXCursor_ObjCSuperClassRef); 2602e331b938b38057e333fab0ba841130ea8467794Douglas Gregor return std::make_pair(static_cast<ObjCInterfaceDecl *>(C.data[0]), 2612e331b938b38057e333fab0ba841130ea8467794Douglas Gregor SourceLocation::getFromRawEncoding( 2622e331b938b38057e333fab0ba841130ea8467794Douglas Gregor reinterpret_cast<uintptr_t>(C.data[1]))); 2632e331b938b38057e333fab0ba841130ea8467794Douglas Gregor} 2642e331b938b38057e333fab0ba841130ea8467794Douglas Gregor 26578db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas GregorCXCursor cxcursor::MakeCursorObjCProtocolRef(ObjCProtocolDecl *Super, 266b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor SourceLocation Loc, 267b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor ASTUnit *TU) { 26854d67caeee4fdce81f07163832f1163d5f2af5d2Daniel Dunbar assert(Super && TU && "Invalid arguments!"); 26978db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); 270b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor CXCursor C = { CXCursor_ObjCProtocolRef, { Super, RawLoc, TU } }; 27178db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor return C; 27278db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor} 27378db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor 27478db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregorstd::pair<ObjCProtocolDecl *, SourceLocation> 27578db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregorcxcursor::getCursorObjCProtocolRef(CXCursor C) { 27678db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor assert(C.kind == CXCursor_ObjCProtocolRef); 27778db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor return std::make_pair(static_cast<ObjCProtocolDecl *>(C.data[0]), 27878db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor SourceLocation::getFromRawEncoding( 27978db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor reinterpret_cast<uintptr_t>(C.data[1]))); 28078db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor} 28178db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor 2821adb082a709f7b588f03672999294e061234b2cfDouglas GregorCXCursor cxcursor::MakeCursorObjCClassRef(ObjCInterfaceDecl *Class, 283b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor SourceLocation Loc, 284b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor ASTUnit *TU) { 285ebfa339321f8a4df9d5011e591a615d5765107d5Ted Kremenek // 'Class' can be null for invalid code. 286ebfa339321f8a4df9d5011e591a615d5765107d5Ted Kremenek if (!Class) 287ebfa339321f8a4df9d5011e591a615d5765107d5Ted Kremenek return MakeCXCursorInvalid(CXCursor_InvalidCode); 288ebfa339321f8a4df9d5011e591a615d5765107d5Ted Kremenek assert(TU && "Invalid arguments!"); 2891adb082a709f7b588f03672999294e061234b2cfDouglas Gregor void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); 290b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor CXCursor C = { CXCursor_ObjCClassRef, { Class, RawLoc, TU } }; 2911adb082a709f7b588f03672999294e061234b2cfDouglas Gregor return C; 2921adb082a709f7b588f03672999294e061234b2cfDouglas Gregor} 2931adb082a709f7b588f03672999294e061234b2cfDouglas Gregor 2941adb082a709f7b588f03672999294e061234b2cfDouglas Gregorstd::pair<ObjCInterfaceDecl *, SourceLocation> 2951adb082a709f7b588f03672999294e061234b2cfDouglas Gregorcxcursor::getCursorObjCClassRef(CXCursor C) { 2961adb082a709f7b588f03672999294e061234b2cfDouglas Gregor assert(C.kind == CXCursor_ObjCClassRef); 2971adb082a709f7b588f03672999294e061234b2cfDouglas Gregor return std::make_pair(static_cast<ObjCInterfaceDecl *>(C.data[0]), 2981adb082a709f7b588f03672999294e061234b2cfDouglas Gregor SourceLocation::getFromRawEncoding( 2991adb082a709f7b588f03672999294e061234b2cfDouglas Gregor reinterpret_cast<uintptr_t>(C.data[1]))); 3001adb082a709f7b588f03672999294e061234b2cfDouglas Gregor} 3011adb082a709f7b588f03672999294e061234b2cfDouglas Gregor 3027d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas GregorCXCursor cxcursor::MakeCursorTypeRef(TypeDecl *Type, SourceLocation Loc, 3037d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor ASTUnit *TU) { 30454d67caeee4fdce81f07163832f1163d5f2af5d2Daniel Dunbar assert(Type && TU && "Invalid arguments!"); 3057d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); 3067d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor CXCursor C = { CXCursor_TypeRef, { Type, RawLoc, TU } }; 3077d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor return C; 3087d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor} 3097d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor 3107d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregorstd::pair<TypeDecl *, SourceLocation> 3117d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregorcxcursor::getCursorTypeRef(CXCursor C) { 3127d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor assert(C.kind == CXCursor_TypeRef); 3137d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor return std::make_pair(static_cast<TypeDecl *>(C.data[0]), 3147d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor SourceLocation::getFromRawEncoding( 3157d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor reinterpret_cast<uintptr_t>(C.data[1]))); 3167d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor} 3177d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor 3180b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas GregorCXCursor cxcursor::MakeCursorTemplateRef(TemplateDecl *Template, 3190b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor SourceLocation Loc, ASTUnit *TU) { 3200b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor assert(Template && TU && "Invalid arguments!"); 3210b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); 3220b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor CXCursor C = { CXCursor_TemplateRef, { Template, RawLoc, TU } }; 3230b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor return C; 3240b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor} 3250b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor 3260b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregorstd::pair<TemplateDecl *, SourceLocation> 3270b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregorcxcursor::getCursorTemplateRef(CXCursor C) { 3280b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor assert(C.kind == CXCursor_TemplateRef); 3290b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor return std::make_pair(static_cast<TemplateDecl *>(C.data[0]), 3300b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor SourceLocation::getFromRawEncoding( 3310b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor reinterpret_cast<uintptr_t>(C.data[1]))); 3320b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor} 3330b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor 3346931900f43cea558c6974075256c07728dbfecc6Douglas GregorCXCursor cxcursor::MakeCursorNamespaceRef(NamedDecl *NS, SourceLocation Loc, 3356931900f43cea558c6974075256c07728dbfecc6Douglas Gregor ASTUnit *TU) { 3366931900f43cea558c6974075256c07728dbfecc6Douglas Gregor 3376931900f43cea558c6974075256c07728dbfecc6Douglas Gregor assert(NS && (isa<NamespaceDecl>(NS) || isa<NamespaceAliasDecl>(NS)) && TU && 3386931900f43cea558c6974075256c07728dbfecc6Douglas Gregor "Invalid arguments!"); 3396931900f43cea558c6974075256c07728dbfecc6Douglas Gregor void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); 3406931900f43cea558c6974075256c07728dbfecc6Douglas Gregor CXCursor C = { CXCursor_NamespaceRef, { NS, RawLoc, TU } }; 3416931900f43cea558c6974075256c07728dbfecc6Douglas Gregor return C; 3426931900f43cea558c6974075256c07728dbfecc6Douglas Gregor} 3436931900f43cea558c6974075256c07728dbfecc6Douglas Gregor 3446931900f43cea558c6974075256c07728dbfecc6Douglas Gregorstd::pair<NamedDecl *, SourceLocation> 3456931900f43cea558c6974075256c07728dbfecc6Douglas Gregorcxcursor::getCursorNamespaceRef(CXCursor C) { 3466931900f43cea558c6974075256c07728dbfecc6Douglas Gregor assert(C.kind == CXCursor_NamespaceRef); 3476931900f43cea558c6974075256c07728dbfecc6Douglas Gregor return std::make_pair(static_cast<NamedDecl *>(C.data[0]), 3486931900f43cea558c6974075256c07728dbfecc6Douglas Gregor SourceLocation::getFromRawEncoding( 3496931900f43cea558c6974075256c07728dbfecc6Douglas Gregor reinterpret_cast<uintptr_t>(C.data[1]))); 3506931900f43cea558c6974075256c07728dbfecc6Douglas Gregor} 3516931900f43cea558c6974075256c07728dbfecc6Douglas Gregor 3523064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed KremenekCXCursor cxcursor::MakeCursorCXXBaseSpecifier(CXXBaseSpecifier *B, ASTUnit *TU){ 3533064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek CXCursor C = { CXCursor_CXXBaseSpecifier, { B, 0, TU } }; 3543064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek return C; 3553064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek} 3563064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek 3573064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed KremenekCXXBaseSpecifier *cxcursor::getCursorCXXBaseSpecifier(CXCursor C) { 3583064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek assert(C.kind == CXCursor_CXXBaseSpecifier); 3593064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek return static_cast<CXXBaseSpecifier*>(C.data[0]); 3603064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek} 3613064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek 3629f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas GregorCXCursor cxcursor::MakePreprocessingDirectiveCursor(SourceRange Range, 3639f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor ASTUnit *TU) { 3649f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor CXCursor C = { CXCursor_PreprocessingDirective, 3659f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor { reinterpret_cast<void *>(Range.getBegin().getRawEncoding()), 3669f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor reinterpret_cast<void *>(Range.getEnd().getRawEncoding()), 3679f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor TU } 3689f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor }; 3699f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor return C; 3709f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor} 3719f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor 3729f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas GregorSourceRange cxcursor::getCursorPreprocessingDirective(CXCursor C) { 3739f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor assert(C.kind == CXCursor_PreprocessingDirective); 3749f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor return SourceRange(SourceLocation::getFromRawEncoding( 3759f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor reinterpret_cast<uintptr_t> (C.data[0])), 3764807231938d8aff28de09f78f301f9ba5845e5e4Douglas Gregor SourceLocation::getFromRawEncoding( 3774807231938d8aff28de09f78f301f9ba5845e5e4Douglas Gregor reinterpret_cast<uintptr_t> (C.data[1]))); 3784807231938d8aff28de09f78f301f9ba5845e5e4Douglas Gregor} 3794807231938d8aff28de09f78f301f9ba5845e5e4Douglas Gregor 380572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas GregorCXCursor cxcursor::MakeMacroDefinitionCursor(MacroDefinition *MI, ASTUnit *TU) { 381572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas Gregor CXCursor C = { CXCursor_MacroDefinition, { MI, 0, TU } }; 382572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas Gregor return C; 383572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas Gregor} 384572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas Gregor 385572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas GregorMacroDefinition *cxcursor::getCursorMacroDefinition(CXCursor C) { 386572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas Gregor assert(C.kind == CXCursor_MacroDefinition); 387572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas Gregor return static_cast<MacroDefinition *>(C.data[0]); 388572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas Gregor} 389572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas Gregor 3904ae8f298b1ea51b4c2234f9148e2e4349c9bdd23Douglas GregorCXCursor cxcursor::MakeMacroInstantiationCursor(MacroInstantiation *MI, 3914807231938d8aff28de09f78f301f9ba5845e5e4Douglas Gregor ASTUnit *TU) { 3924ae8f298b1ea51b4c2234f9148e2e4349c9bdd23Douglas Gregor CXCursor C = { CXCursor_MacroInstantiation, { MI, 0, TU } }; 3934807231938d8aff28de09f78f301f9ba5845e5e4Douglas Gregor return C; 3944807231938d8aff28de09f78f301f9ba5845e5e4Douglas Gregor} 3954807231938d8aff28de09f78f301f9ba5845e5e4Douglas Gregor 3964ae8f298b1ea51b4c2234f9148e2e4349c9bdd23Douglas GregorMacroInstantiation *cxcursor::getCursorMacroInstantiation(CXCursor C) { 3974807231938d8aff28de09f78f301f9ba5845e5e4Douglas Gregor assert(C.kind == CXCursor_MacroInstantiation); 3984ae8f298b1ea51b4c2234f9148e2e4349c9bdd23Douglas Gregor return static_cast<MacroInstantiation *>(C.data[0]); 3999f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor} 4009f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor 401283cae37b03047c14ef918503bc46b08405c3b69Douglas GregorDecl *cxcursor::getCursorDecl(CXCursor Cursor) { 402283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor return (Decl *)Cursor.data[0]; 403283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor} 404283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor 405283cae37b03047c14ef918503bc46b08405c3b69Douglas GregorExpr *cxcursor::getCursorExpr(CXCursor Cursor) { 406283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor return dyn_cast_or_null<Expr>(getCursorStmt(Cursor)); 407283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor} 408283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor 409283cae37b03047c14ef918503bc46b08405c3b69Douglas GregorStmt *cxcursor::getCursorStmt(CXCursor Cursor) { 41078db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor if (Cursor.kind == CXCursor_ObjCSuperClassRef || 4111adb082a709f7b588f03672999294e061234b2cfDouglas Gregor Cursor.kind == CXCursor_ObjCProtocolRef || 4121adb082a709f7b588f03672999294e061234b2cfDouglas Gregor Cursor.kind == CXCursor_ObjCClassRef) 4132e331b938b38057e333fab0ba841130ea8467794Douglas Gregor return 0; 4142e331b938b38057e333fab0ba841130ea8467794Douglas Gregor 415283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor return (Stmt *)Cursor.data[1]; 416283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor} 417283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor 41895f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted KremenekAttr *cxcursor::getCursorAttr(CXCursor Cursor) { 41995f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek return (Attr *)Cursor.data[1]; 42095f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek} 42195f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek 422f46034af49435a4d1a0085a4738343122aeb6521Douglas GregorASTContext &cxcursor::getCursorContext(CXCursor Cursor) { 423b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor return getCursorASTUnit(Cursor)->getASTContext(); 424b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor} 42597b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor 426b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas GregorASTUnit *cxcursor::getCursorASTUnit(CXCursor Cursor) { 427b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor return static_cast<ASTUnit *>(Cursor.data[2]); 428283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor} 429283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor 430283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregorbool cxcursor::operator==(CXCursor X, CXCursor Y) { 431283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor return X.kind == Y.kind && X.data[0] == Y.data[0] && X.data[1] == Y.data[1] && 432283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor X.data[2] == Y.data[2]; 4332e331b938b38057e333fab0ba841130ea8467794Douglas Gregor} 434