CXCursor.cpp revision 5f1c822def3efffe1d8f7299fbbbc3b1cdd4833d
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 160a90d32523bfe5fa63e11b648686c9699f786d15Ted Kremenek#include "CXTranslationUnit.h" 1716c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek#include "CXCursor.h" 18ed122735639d83c10f18c28c7fd117bfcd0f62cbTed Kremenek#include "CXString.h" 197eaa8ae8692c5cd3eed8cb334fe5346470522091Douglas Gregor#include "clang/Frontend/ASTUnit.h" 2016c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek#include "clang/AST/Decl.h" 216931900f43cea558c6974075256c07728dbfecc6Douglas Gregor#include "clang/AST/DeclCXX.h" 22283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor#include "clang/AST/DeclObjC.h" 23aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis#include "clang/AST/DeclTemplate.h" 24283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor#include "clang/AST/Expr.h" 251f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor#include "clang/AST/ExprCXX.h" 26aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis#include "clang/AST/ExprObjC.h" 27007a7c9d8dcdb2e9cd94b6075108bfc4c90e6ccdTed Kremenek#include "clang-c/Index.h" 28edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek#include "llvm/Support/ErrorHandling.h" 2916c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek 3016c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenekusing namespace clang; 311f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregorusing namespace cxcursor; 3216c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek 335bfb8c128c2ac8eb4032afc180cdc400a0f953caDouglas GregorCXCursor cxcursor::MakeCXCursorInvalid(CXCursorKind K) { 345bfb8c128c2ac8eb4032afc180cdc400a0f953caDouglas Gregor assert(K >= CXCursor_FirstInvalid && K <= CXCursor_LastInvalid); 35aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor C = { K, 0, { 0, 0, 0 } }; 365bfb8c128c2ac8eb4032afc180cdc400a0f953caDouglas Gregor return C; 3716c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek} 3816c440a377b7ec8b722a2e2c7c864f75c95bd305Ted Kremenek 39e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenekstatic CXCursorKind GetCursorKind(const Attr *A) { 40e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek assert(A && "Invalid arguments!"); 41e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek switch (A->getKind()) { 42e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek default: break; 43387475d0c18aaeb022108de9d33b6c9fb7998843Sean Hunt case attr::IBAction: return CXCursor_IBActionAttr; 44387475d0c18aaeb022108de9d33b6c9fb7998843Sean Hunt case attr::IBOutlet: return CXCursor_IBOutletAttr; 45387475d0c18aaeb022108de9d33b6c9fb7998843Sean Hunt case attr::IBOutletCollection: return CXCursor_IBOutletCollectionAttr; 466639e9255489ad8e10278d5658fdd4b3c0e1e4cdArgyrios Kyrtzidis case attr::Final: return CXCursor_CXXFinalAttr; 476639e9255489ad8e10278d5658fdd4b3c0e1e4cdArgyrios Kyrtzidis case attr::Override: return CXCursor_CXXOverrideAttr; 485f1c822def3efffe1d8f7299fbbbc3b1cdd4833dErik Verbruggen case attr::Annotate: return CXCursor_AnnotateAttr; 49e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek } 50e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek 51e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek return CXCursor_UnexposedAttr; 52e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek} 53e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek 54a60ed47da13393796d8552b9fdca12abbb3eea42Ted KremenekCXCursor cxcursor::MakeCXCursor(const Attr *A, Decl *Parent, 55a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek CXTranslationUnit TU) { 56e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek assert(A && Parent && TU && "Invalid arguments!"); 57aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor C = { GetCursorKind(A), 0, { Parent, (void*)A, TU } }; 58e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek return C; 59e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek} 60e77f443dbca8cdc23e5aa94a2653367e4a7cbe47Ted Kremenek 61a60ed47da13393796d8552b9fdca12abbb3eea42Ted KremenekCXCursor cxcursor::MakeCXCursor(Decl *D, CXTranslationUnit TU, 62aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis SourceRange RegionOfInterest, 63007a7c9d8dcdb2e9cd94b6075108bfc4c90e6ccdTed Kremenek bool FirstInDeclGroup) { 6454d67caeee4fdce81f07163832f1163d5f2af5d2Daniel Dunbar assert(D && TU && "Invalid arguments!"); 65aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis 66aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursorKind K = getCursorKindForDecl(D); 67aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis 68aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis if (K == CXCursor_ObjCClassMethodDecl || 69aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis K == CXCursor_ObjCInstanceMethodDecl) { 70aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis int SelectorIdIndex = -1; 71aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis // Check if cursor points to a selector id. 72aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis if (RegionOfInterest.isValid() && 73aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis RegionOfInterest.getBegin() == RegionOfInterest.getEnd()) { 74aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis SmallVector<SourceLocation, 16> SelLocs; 75aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis cast<ObjCMethodDecl>(D)->getSelectorLocs(SelLocs); 76aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis SmallVector<SourceLocation, 16>::iterator 77aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis I=std::find(SelLocs.begin(), SelLocs.end(),RegionOfInterest.getBegin()); 78aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis if (I != SelLocs.end()) 79aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis SelectorIdIndex = I - SelLocs.begin(); 80aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis } 81aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor C = { K, SelectorIdIndex, 82aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis { D, (void*)(intptr_t) (FirstInDeclGroup ? 1 : 0), TU }}; 83aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis return C; 84aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis } 85aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis 86aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor C = { K, 0, { D, (void*)(intptr_t) (FirstInDeclGroup ? 1 : 0), TU }}; 875bfb8c128c2ac8eb4032afc180cdc400a0f953caDouglas Gregor return C; 88edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek} 89edc8aa68ef91aeea686c5aadf64ef902c38318ddTed Kremenek 90aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios KyrtzidisCXCursor cxcursor::MakeCXCursor(Stmt *S, Decl *Parent, CXTranslationUnit TU, 91aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis SourceRange RegionOfInterest) { 9254d67caeee4fdce81f07163832f1163d5f2af5d2Daniel Dunbar assert(S && TU && "Invalid arguments!"); 9397b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor CXCursorKind K = CXCursor_NotImplemented; 9497b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor 9597b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor switch (S->getStmtClass()) { 9697b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::NoStmtClass: 9797b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor break; 9842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 9997b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CaseStmtClass: 10042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_CaseStmt; 10142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 10242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 10397b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::DefaultStmtClass: 10442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_DefaultStmt; 10542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 10642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 10742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::IfStmtClass: 10842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_IfStmt; 10942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 11042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 11142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::SwitchStmtClass: 11242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_SwitchStmt; 11342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 11442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 11542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::WhileStmtClass: 11642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_WhileStmt; 11742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 11842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 11942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::DoStmtClass: 12042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_DoStmt; 12142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 12242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 12342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ForStmtClass: 12442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_ForStmt; 12542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 12642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 12742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::GotoStmtClass: 12842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_GotoStmt; 12942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 13042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 13197b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::IndirectGotoStmtClass: 13242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_IndirectGotoStmt; 13342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 13442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 13542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ContinueStmtClass: 13642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_ContinueStmt; 13742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 13842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 13942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::BreakStmtClass: 14042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_BreakStmt; 14142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 14242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 14342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ReturnStmtClass: 14442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_ReturnStmt; 14542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 14642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 14742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::AsmStmtClass: 14842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_AsmStmt; 14942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 15042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 15142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ObjCAtTryStmtClass: 15242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_ObjCAtTryStmt; 15342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 15442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 15542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ObjCAtCatchStmtClass: 15642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_ObjCAtCatchStmt; 15742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 15842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 15942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ObjCAtFinallyStmtClass: 16042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_ObjCAtFinallyStmt; 16142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 16242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 16342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ObjCAtThrowStmtClass: 16442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_ObjCAtThrowStmt; 16542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 16642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 16742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ObjCAtSynchronizedStmtClass: 16842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_ObjCAtSynchronizedStmt; 16942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 17042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 17142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ObjCAutoreleasePoolStmtClass: 17242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_ObjCAutoreleasePoolStmt; 17342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 17442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 17597b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ObjCForCollectionStmtClass: 17642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_ObjCForCollectionStmt; 17742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 17842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 17997b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXCatchStmtClass: 18042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_CXXCatchStmt; 18142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 18242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 18342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CXXTryStmtClass: 18442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_CXXTryStmt; 18542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 18642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 18742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CXXForRangeStmtClass: 18842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_CXXForRangeStmt; 18942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 19042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 19128bbe4b8acc338476fe0825769b41fb32b423c72John Wiegley case Stmt::SEHTryStmtClass: 19242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_SEHTryStmt; 19342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 19442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 19528bbe4b8acc338476fe0825769b41fb32b423c72John Wiegley case Stmt::SEHExceptStmtClass: 19642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_SEHExceptStmt; 19742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 19842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 19928bbe4b8acc338476fe0825769b41fb32b423c72John Wiegley case Stmt::SEHFinallyStmtClass: 20042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_SEHFinallyStmt; 20142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 20242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 20342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ArrayTypeTraitExprClass: 20442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::AsTypeExprClass: 205276b061970939293f1abaf694bd3ef05b2cbda79Eli Friedman case Stmt::AtomicExprClass: 20642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::BinaryConditionalOperatorClass: 20742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::BinaryTypeTraitExprClass: 20842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CXXBindTemporaryExprClass: 20942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CXXDefaultArgExprClass: 21042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CXXScalarValueInitExprClass: 21142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CXXUuidofExprClass: 21242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ChooseExprClass: 21342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::DesignatedInitExprClass: 21442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ExprWithCleanupsClass: 21542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ExpressionTraitExprClass: 21642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ExtVectorElementExprClass: 21742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ImplicitCastExprClass: 21842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ImplicitValueInitExprClass: 21903e80030515c800d1ab44125b9052dfffd1bd04cDouglas Gregor case Stmt::MaterializeTemporaryExprClass: 22042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ObjCIndirectCopyRestoreExprClass: 22142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::OffsetOfExprClass: 22242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::OpaqueValueExprClass: 22342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ParenListExprClass: 22442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::PredefinedExprClass: 22542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ShuffleVectorExprClass: 22642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::UnaryExprOrTypeTraitExprClass: 22742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::UnaryTypeTraitExprClass: 22842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::VAArgExprClass: 22942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_UnexposedExpr; 23042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 23142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 23242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CompoundStmtClass: 23342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_CompoundStmt; 23497b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor break; 23597b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor 23642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::NullStmtClass: 23742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_NullStmt; 23836897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor break; 23936897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor 24042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::LabelStmtClass: 24142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_LabelStmt; 24242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 24342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 24442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::DeclStmtClass: 24542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_DeclStmt; 24642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 24742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 24842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::IntegerLiteralClass: 24942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_IntegerLiteral; 25042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 25142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 25242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::FloatingLiteralClass: 25342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_FloatingLiteral; 25442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 25542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 25642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ImaginaryLiteralClass: 25742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_ImaginaryLiteral; 25842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 25942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 26042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::StringLiteralClass: 26142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_StringLiteral; 26242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 26342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 26442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CharacterLiteralClass: 26542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_CharacterLiteral; 26642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 26742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 26842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ParenExprClass: 26942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_ParenExpr; 27042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 27142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 2728ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor case Stmt::UnaryOperatorClass: 27342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_UnaryOperator; 27442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 27542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 27642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CXXNoexceptExprClass: 27742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_UnaryExpr; 27842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 27942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 28042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ArraySubscriptExprClass: 28142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_ArraySubscriptExpr; 28242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 28342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 28442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::BinaryOperatorClass: 28542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_BinaryOperator; 28642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 28742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 28897b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CompoundAssignOperatorClass: 28942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_CompoundAssignOperator; 29042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 29142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 29242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ConditionalOperatorClass: 29342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_ConditionalOperator; 29442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 29542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 29697b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CStyleCastExprClass: 29742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_CStyleCastExpr; 29842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 29942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 30042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CompoundLiteralExprClass: 30142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_CompoundLiteralExpr; 30242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 30342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 30442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::InitListExprClass: 30542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_InitListExpr; 30642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 30742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 30842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::AddrLabelExprClass: 30942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_AddrLabelExpr; 31042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 31142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 31242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::StmtExprClass: 31342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_StmtExpr; 31442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 31542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 316f111d935722ed488144600cea5ed03a6b5069e8fPeter Collingbourne case Stmt::GenericSelectionExprClass: 31742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_GenericSelectionExpr; 31842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 31942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 32042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::GNUNullExprClass: 32142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_GNUNullExpr; 32242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 32342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 32442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CXXStaticCastExprClass: 32542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_CXXStaticCastExpr; 32642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 32742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 32842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CXXDynamicCastExprClass: 32942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_CXXDynamicCastExpr; 33042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 33142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 33242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CXXReinterpretCastExprClass: 33342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_CXXReinterpretCastExpr; 33442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 33542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 33642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CXXConstCastExprClass: 33742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_CXXConstCastExpr; 33842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 33942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 34097b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXFunctionalCastExprClass: 34142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_CXXFunctionalCastExpr; 34242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 34342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 34442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CXXTypeidExprClass: 34542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_CXXTypeidExpr; 34642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 34742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 34842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CXXBoolLiteralExprClass: 34942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_CXXBoolLiteralExpr; 35042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 35142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 35242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CXXNullPtrLiteralExprClass: 35342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_CXXNullPtrLiteralExpr; 35442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 35542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 35642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CXXThisExprClass: 35742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_CXXThisExpr; 35842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 35942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 36042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CXXThrowExprClass: 36142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_CXXThrowExpr; 36242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 36342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 36442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CXXNewExprClass: 36542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_CXXNewExpr; 36642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 36742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 36842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CXXDeleteExprClass: 36942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_CXXDeleteExpr; 37042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 37142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 37242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ObjCStringLiteralClass: 37342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_ObjCStringLiteral; 37442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 37542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 37642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ObjCEncodeExprClass: 37742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_ObjCEncodeExpr; 37842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 37942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 38042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ObjCSelectorExprClass: 38142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_ObjCSelectorExpr; 38242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 38342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 38442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ObjCProtocolExprClass: 38542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_ObjCProtocolExpr; 38642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 38742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 388f85e193739c953358c865005855253af4f68a497John McCall case Stmt::ObjCBridgedCastExprClass: 38942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_ObjCBridgedCastExpr; 39042b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 39142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 39242b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::BlockExprClass: 39342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_BlockExpr; 39442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 39542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 396be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor case Stmt::PackExpansionExprClass: 39742b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_PackExpansionExpr; 39842b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor break; 39942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 400ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor case Stmt::SizeOfPackExprClass: 40142b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor K = CXCursor_SizeOfPackExpr; 40297b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor break; 40342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor 40497b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::BlockDeclRefExprClass: 40542b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::DeclRefExprClass: 40642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::DependentScopeDeclRefExprClass: 40791a5755ad73c5dc1dfb167e448fdd74e75a6df56John McCall case Stmt::SubstNonTypeTemplateParmExprClass: 408c7793c73ba8a343de3f2552d984851985a46f159Douglas Gregor case Stmt::SubstNonTypeTemplateParmPackExprClass: 40942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::UnresolvedLookupExprClass: 41097b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor K = CXCursor_DeclRefExpr; 41197b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor break; 41297b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor 41342b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CXXDependentScopeMemberExprClass: 41442b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CXXPseudoDestructorExprClass: 41597b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::MemberExprClass: 41642b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::ObjCIsaExprClass: 41797b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ObjCIvarRefExprClass: 41897b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ObjCPropertyRefExprClass: 41942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::UnresolvedMemberExprClass: 42097b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor K = CXCursor_MemberRefExpr; 42197b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor break; 42297b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor 42397b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CallExprClass: 42497b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXOperatorCallExprClass: 42597b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXMemberCallExprClass: 426e08ce650a2b02410eddd1f60a4aa6b3d4be71e73Peter Collingbourne case Stmt::CUDAKernelCallExprClass: 42797b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXConstructExprClass: 42897b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::CXXTemporaryObjectExprClass: 42942b2984771a7fd1b17c78bbb2c59fed3db2f1960Douglas Gregor case Stmt::CXXUnresolvedConstructExprClass: 43097b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor K = CXCursor_CallExpr; 43197b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor break; 43297b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor 43397b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor case Stmt::ObjCMessageExprClass: 43497b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor K = CXCursor_ObjCMessageExpr; 435aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis int SelectorIdIndex = -1; 436aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis // Check if cursor points to a selector id. 437aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis if (RegionOfInterest.isValid() && 438aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis RegionOfInterest.getBegin() == RegionOfInterest.getEnd()) { 439aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis SmallVector<SourceLocation, 16> SelLocs; 440aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis cast<ObjCMessageExpr>(S)->getSelectorLocs(SelLocs); 441aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis SmallVector<SourceLocation, 16>::iterator 442aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis I=std::find(SelLocs.begin(), SelLocs.end(),RegionOfInterest.getBegin()); 443aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis if (I != SelLocs.end()) 444aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis SelectorIdIndex = I - SelLocs.begin(); 445aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis } 446aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor C = { K, 0, { Parent, S, TU } }; 447aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis return getSelectorIdentifierCursor(SelectorIdIndex, C); 44897b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor } 44997b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor 450aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor C = { K, 0, { Parent, S, TU } }; 45197b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor return C; 45297b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor} 45397b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor 4542e331b938b38057e333fab0ba841130ea8467794Douglas GregorCXCursor cxcursor::MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super, 455b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor SourceLocation Loc, 456a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek CXTranslationUnit TU) { 45754d67caeee4fdce81f07163832f1163d5f2af5d2Daniel Dunbar assert(Super && TU && "Invalid arguments!"); 4582e331b938b38057e333fab0ba841130ea8467794Douglas Gregor void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); 459aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor C = { CXCursor_ObjCSuperClassRef, 0, { Super, RawLoc, TU } }; 4602e331b938b38057e333fab0ba841130ea8467794Douglas Gregor return C; 4612e331b938b38057e333fab0ba841130ea8467794Douglas Gregor} 4622e331b938b38057e333fab0ba841130ea8467794Douglas Gregor 4632e331b938b38057e333fab0ba841130ea8467794Douglas Gregorstd::pair<ObjCInterfaceDecl *, SourceLocation> 4642e331b938b38057e333fab0ba841130ea8467794Douglas Gregorcxcursor::getCursorObjCSuperClassRef(CXCursor C) { 4652e331b938b38057e333fab0ba841130ea8467794Douglas Gregor assert(C.kind == CXCursor_ObjCSuperClassRef); 4662e331b938b38057e333fab0ba841130ea8467794Douglas Gregor return std::make_pair(static_cast<ObjCInterfaceDecl *>(C.data[0]), 4672e331b938b38057e333fab0ba841130ea8467794Douglas Gregor SourceLocation::getFromRawEncoding( 4682e331b938b38057e333fab0ba841130ea8467794Douglas Gregor reinterpret_cast<uintptr_t>(C.data[1]))); 4692e331b938b38057e333fab0ba841130ea8467794Douglas Gregor} 4702e331b938b38057e333fab0ba841130ea8467794Douglas Gregor 47178db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas GregorCXCursor cxcursor::MakeCursorObjCProtocolRef(ObjCProtocolDecl *Super, 472b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor SourceLocation Loc, 473a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek CXTranslationUnit TU) { 47454d67caeee4fdce81f07163832f1163d5f2af5d2Daniel Dunbar assert(Super && TU && "Invalid arguments!"); 47578db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); 476aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor C = { CXCursor_ObjCProtocolRef, 0, { Super, RawLoc, TU } }; 47778db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor return C; 47878db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor} 47978db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor 48078db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregorstd::pair<ObjCProtocolDecl *, SourceLocation> 48178db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregorcxcursor::getCursorObjCProtocolRef(CXCursor C) { 48278db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor assert(C.kind == CXCursor_ObjCProtocolRef); 48378db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor return std::make_pair(static_cast<ObjCProtocolDecl *>(C.data[0]), 48478db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor SourceLocation::getFromRawEncoding( 48578db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor reinterpret_cast<uintptr_t>(C.data[1]))); 48678db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor} 48778db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor 4881adb082a709f7b588f03672999294e061234b2cfDouglas GregorCXCursor cxcursor::MakeCursorObjCClassRef(ObjCInterfaceDecl *Class, 489b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor SourceLocation Loc, 490a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek CXTranslationUnit TU) { 491ebfa339321f8a4df9d5011e591a615d5765107d5Ted Kremenek // 'Class' can be null for invalid code. 492ebfa339321f8a4df9d5011e591a615d5765107d5Ted Kremenek if (!Class) 493ebfa339321f8a4df9d5011e591a615d5765107d5Ted Kremenek return MakeCXCursorInvalid(CXCursor_InvalidCode); 494ebfa339321f8a4df9d5011e591a615d5765107d5Ted Kremenek assert(TU && "Invalid arguments!"); 4951adb082a709f7b588f03672999294e061234b2cfDouglas Gregor void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); 496aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor C = { CXCursor_ObjCClassRef, 0, { Class, RawLoc, TU } }; 4971adb082a709f7b588f03672999294e061234b2cfDouglas Gregor return C; 4981adb082a709f7b588f03672999294e061234b2cfDouglas Gregor} 4991adb082a709f7b588f03672999294e061234b2cfDouglas Gregor 5001adb082a709f7b588f03672999294e061234b2cfDouglas Gregorstd::pair<ObjCInterfaceDecl *, SourceLocation> 5011adb082a709f7b588f03672999294e061234b2cfDouglas Gregorcxcursor::getCursorObjCClassRef(CXCursor C) { 5021adb082a709f7b588f03672999294e061234b2cfDouglas Gregor assert(C.kind == CXCursor_ObjCClassRef); 5031adb082a709f7b588f03672999294e061234b2cfDouglas Gregor return std::make_pair(static_cast<ObjCInterfaceDecl *>(C.data[0]), 5041adb082a709f7b588f03672999294e061234b2cfDouglas Gregor SourceLocation::getFromRawEncoding( 5051adb082a709f7b588f03672999294e061234b2cfDouglas Gregor reinterpret_cast<uintptr_t>(C.data[1]))); 5061adb082a709f7b588f03672999294e061234b2cfDouglas Gregor} 5071adb082a709f7b588f03672999294e061234b2cfDouglas Gregor 5087d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas GregorCXCursor cxcursor::MakeCursorTypeRef(TypeDecl *Type, SourceLocation Loc, 509a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek CXTranslationUnit TU) { 51054d67caeee4fdce81f07163832f1163d5f2af5d2Daniel Dunbar assert(Type && TU && "Invalid arguments!"); 5117d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); 512aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor C = { CXCursor_TypeRef, 0, { Type, RawLoc, TU } }; 5137d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor return C; 5147d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor} 5157d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor 5167d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregorstd::pair<TypeDecl *, SourceLocation> 5177d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregorcxcursor::getCursorTypeRef(CXCursor C) { 5187d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor assert(C.kind == CXCursor_TypeRef); 5197d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor return std::make_pair(static_cast<TypeDecl *>(C.data[0]), 5207d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor SourceLocation::getFromRawEncoding( 5217d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor reinterpret_cast<uintptr_t>(C.data[1]))); 5227d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor} 5237d0d40e58807f73e06ff5eb637a48e9f978b0e2aDouglas Gregor 5240b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas GregorCXCursor cxcursor::MakeCursorTemplateRef(TemplateDecl *Template, 525a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek SourceLocation Loc, 526a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek CXTranslationUnit TU) { 5270b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor assert(Template && TU && "Invalid arguments!"); 5280b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); 529aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor C = { CXCursor_TemplateRef, 0, { Template, RawLoc, TU } }; 5300b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor return C; 5310b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor} 5320b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor 5330b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregorstd::pair<TemplateDecl *, SourceLocation> 5340b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregorcxcursor::getCursorTemplateRef(CXCursor C) { 5350b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor assert(C.kind == CXCursor_TemplateRef); 5360b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor return std::make_pair(static_cast<TemplateDecl *>(C.data[0]), 5370b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor SourceLocation::getFromRawEncoding( 5380b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor reinterpret_cast<uintptr_t>(C.data[1]))); 5390b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor} 5400b36e614aa19df72885d5e0de996f7fbb9874ec3Douglas Gregor 5416931900f43cea558c6974075256c07728dbfecc6Douglas GregorCXCursor cxcursor::MakeCursorNamespaceRef(NamedDecl *NS, SourceLocation Loc, 542a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek CXTranslationUnit TU) { 5436931900f43cea558c6974075256c07728dbfecc6Douglas Gregor 5446931900f43cea558c6974075256c07728dbfecc6Douglas Gregor assert(NS && (isa<NamespaceDecl>(NS) || isa<NamespaceAliasDecl>(NS)) && TU && 5456931900f43cea558c6974075256c07728dbfecc6Douglas Gregor "Invalid arguments!"); 5466931900f43cea558c6974075256c07728dbfecc6Douglas Gregor void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); 547aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor C = { CXCursor_NamespaceRef, 0, { NS, RawLoc, TU } }; 5486931900f43cea558c6974075256c07728dbfecc6Douglas Gregor return C; 5496931900f43cea558c6974075256c07728dbfecc6Douglas Gregor} 5506931900f43cea558c6974075256c07728dbfecc6Douglas Gregor 5516931900f43cea558c6974075256c07728dbfecc6Douglas Gregorstd::pair<NamedDecl *, SourceLocation> 5526931900f43cea558c6974075256c07728dbfecc6Douglas Gregorcxcursor::getCursorNamespaceRef(CXCursor C) { 5536931900f43cea558c6974075256c07728dbfecc6Douglas Gregor assert(C.kind == CXCursor_NamespaceRef); 5546931900f43cea558c6974075256c07728dbfecc6Douglas Gregor return std::make_pair(static_cast<NamedDecl *>(C.data[0]), 5556931900f43cea558c6974075256c07728dbfecc6Douglas Gregor SourceLocation::getFromRawEncoding( 5566931900f43cea558c6974075256c07728dbfecc6Douglas Gregor reinterpret_cast<uintptr_t>(C.data[1]))); 5576931900f43cea558c6974075256c07728dbfecc6Douglas Gregor} 5586931900f43cea558c6974075256c07728dbfecc6Douglas Gregor 559a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas GregorCXCursor cxcursor::MakeCursorMemberRef(FieldDecl *Field, SourceLocation Loc, 560a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek CXTranslationUnit TU) { 561a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor 562a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor assert(Field && TU && "Invalid arguments!"); 563a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); 564aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor C = { CXCursor_MemberRef, 0, { Field, RawLoc, TU } }; 565a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor return C; 566a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor} 567a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor 568a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregorstd::pair<FieldDecl *, SourceLocation> 569a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregorcxcursor::getCursorMemberRef(CXCursor C) { 570a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor assert(C.kind == CXCursor_MemberRef); 571a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor return std::make_pair(static_cast<FieldDecl *>(C.data[0]), 572a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor SourceLocation::getFromRawEncoding( 573a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor reinterpret_cast<uintptr_t>(C.data[1]))); 574a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor} 575a67e03fdf1ae8a1f92463a307d0b6281f1161f40Douglas Gregor 576a60ed47da13393796d8552b9fdca12abbb3eea42Ted KremenekCXCursor cxcursor::MakeCursorCXXBaseSpecifier(CXXBaseSpecifier *B, 577a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek CXTranslationUnit TU){ 578aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor C = { CXCursor_CXXBaseSpecifier, 0, { B, 0, TU } }; 5793064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek return C; 5803064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek} 5813064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek 5823064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed KremenekCXXBaseSpecifier *cxcursor::getCursorCXXBaseSpecifier(CXCursor C) { 5833064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek assert(C.kind == CXCursor_CXXBaseSpecifier); 5843064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek return static_cast<CXXBaseSpecifier*>(C.data[0]); 5853064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek} 5863064ef9e604d19a0cfd0d8e3ed3055bfd83f88fdTed Kremenek 5879f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas GregorCXCursor cxcursor::MakePreprocessingDirectiveCursor(SourceRange Range, 588a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek CXTranslationUnit TU) { 589aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor C = { CXCursor_PreprocessingDirective, 0, 5909f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor { reinterpret_cast<void *>(Range.getBegin().getRawEncoding()), 5919f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor reinterpret_cast<void *>(Range.getEnd().getRawEncoding()), 5929f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor TU } 5939f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor }; 5949f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor return C; 5959f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor} 5969f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor 5979f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas GregorSourceRange cxcursor::getCursorPreprocessingDirective(CXCursor C) { 5989f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor assert(C.kind == CXCursor_PreprocessingDirective); 599ee0f84fc84ed7de7975e102668d8e53a778f7a8cArgyrios Kyrtzidis SourceRange Range = SourceRange(SourceLocation::getFromRawEncoding( 6009f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor reinterpret_cast<uintptr_t> (C.data[0])), 6014807231938d8aff28de09f78f301f9ba5845e5e4Douglas Gregor SourceLocation::getFromRawEncoding( 6024807231938d8aff28de09f78f301f9ba5845e5e4Douglas Gregor reinterpret_cast<uintptr_t> (C.data[1]))); 603ee0f84fc84ed7de7975e102668d8e53a778f7a8cArgyrios Kyrtzidis ASTUnit *TU = getCursorASTUnit(C); 604ee0f84fc84ed7de7975e102668d8e53a778f7a8cArgyrios Kyrtzidis return TU->mapRangeFromPreamble(Range); 6054807231938d8aff28de09f78f301f9ba5845e5e4Douglas Gregor} 6064807231938d8aff28de09f78f301f9ba5845e5e4Douglas Gregor 607a60ed47da13393796d8552b9fdca12abbb3eea42Ted KremenekCXCursor cxcursor::MakeMacroDefinitionCursor(MacroDefinition *MI, 608a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek CXTranslationUnit TU) { 609aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor C = { CXCursor_MacroDefinition, 0, { MI, 0, TU } }; 610572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas Gregor return C; 611572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas Gregor} 612572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas Gregor 613572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas GregorMacroDefinition *cxcursor::getCursorMacroDefinition(CXCursor C) { 614572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas Gregor assert(C.kind == CXCursor_MacroDefinition); 615572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas Gregor return static_cast<MacroDefinition *>(C.data[0]); 616572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas Gregor} 617572feb2a190b5e8b04fb06c4ac50ee0f61e93ff0Douglas Gregor 6189e5bb85ac899eeab7c21b5ff9030c3da6ff4837bChandler CarruthCXCursor cxcursor::MakeMacroExpansionCursor(MacroExpansion *MI, 6199e5bb85ac899eeab7c21b5ff9030c3da6ff4837bChandler Carruth CXTranslationUnit TU) { 620aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor C = { CXCursor_MacroExpansion, 0, { MI, 0, TU } }; 6214807231938d8aff28de09f78f301f9ba5845e5e4Douglas Gregor return C; 6224807231938d8aff28de09f78f301f9ba5845e5e4Douglas Gregor} 6234807231938d8aff28de09f78f301f9ba5845e5e4Douglas Gregor 6249e5bb85ac899eeab7c21b5ff9030c3da6ff4837bChandler CarruthMacroExpansion *cxcursor::getCursorMacroExpansion(CXCursor C) { 6259b2a0ac970a077bdc0bf08c6c682f80ad733c892Chandler Carruth assert(C.kind == CXCursor_MacroExpansion); 6269e5bb85ac899eeab7c21b5ff9030c3da6ff4837bChandler Carruth return static_cast<MacroExpansion *>(C.data[0]); 6279f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor} 6289f1e3ff3b3095967e2b92b57a53524e2d6bb141cDouglas Gregor 629ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas GregorCXCursor cxcursor::MakeInclusionDirectiveCursor(InclusionDirective *ID, 630a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek CXTranslationUnit TU) { 631aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor C = { CXCursor_InclusionDirective, 0, { ID, 0, TU } }; 632ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor return C; 633ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor} 634ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor 635ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas GregorInclusionDirective *cxcursor::getCursorInclusionDirective(CXCursor C) { 636ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor assert(C.kind == CXCursor_InclusionDirective); 637ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor return static_cast<InclusionDirective *>(C.data[0]); 638ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor} 639ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor 64036897b05ca2886e287f01802614bc10cbadcec22Douglas GregorCXCursor cxcursor::MakeCursorLabelRef(LabelStmt *Label, SourceLocation Loc, 641a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek CXTranslationUnit TU) { 64236897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor 64336897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor assert(Label && TU && "Invalid arguments!"); 64436897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); 645aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor C = { CXCursor_LabelRef, 0, { Label, RawLoc, TU } }; 64636897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor return C; 64736897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor} 64836897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor 64936897b05ca2886e287f01802614bc10cbadcec22Douglas Gregorstd::pair<LabelStmt*, SourceLocation> 65036897b05ca2886e287f01802614bc10cbadcec22Douglas Gregorcxcursor::getCursorLabelRef(CXCursor C) { 65136897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor assert(C.kind == CXCursor_LabelRef); 65236897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor return std::make_pair(static_cast<LabelStmt *>(C.data[0]), 65336897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor SourceLocation::getFromRawEncoding( 65436897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor reinterpret_cast<uintptr_t>(C.data[1]))); 65536897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor} 65636897b05ca2886e287f01802614bc10cbadcec22Douglas Gregor 6571f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas GregorCXCursor cxcursor::MakeCursorOverloadedDeclRef(OverloadExpr *E, 658a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek CXTranslationUnit TU) { 6591f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor assert(E && TU && "Invalid arguments!"); 6601f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor OverloadedDeclRefStorage Storage(E); 6611f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor void *RawLoc = reinterpret_cast<void *>(E->getNameLoc().getRawEncoding()); 6621f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor CXCursor C = { 663aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor_OverloadedDeclRef, 0, 6641f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor { Storage.getOpaqueValue(), RawLoc, TU } 6651f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor }; 6661f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor return C; 6671f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor} 6681f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor 6691f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas GregorCXCursor cxcursor::MakeCursorOverloadedDeclRef(Decl *D, 6701f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor SourceLocation Loc, 671a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek CXTranslationUnit TU) { 6721f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor assert(D && TU && "Invalid arguments!"); 6731f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); 6741f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor OverloadedDeclRefStorage Storage(D); 6751f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor CXCursor C = { 676aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor_OverloadedDeclRef, 0, 6771f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor { Storage.getOpaqueValue(), RawLoc, TU } 6781f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor }; 6791f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor return C; 6801f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor} 6811f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor 6821f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas GregorCXCursor cxcursor::MakeCursorOverloadedDeclRef(TemplateName Name, 6831f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor SourceLocation Loc, 684a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek CXTranslationUnit TU) { 6851f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor assert(Name.getAsOverloadedTemplate() && TU && "Invalid arguments!"); 6861f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); 6871f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor OverloadedDeclRefStorage Storage(Name.getAsOverloadedTemplate()); 6881f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor CXCursor C = { 689aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor_OverloadedDeclRef, 0, 6901f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor { Storage.getOpaqueValue(), RawLoc, TU } 6911f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor }; 6921f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor return C; 6931f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor} 6941f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor 6951f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregorstd::pair<cxcursor::OverloadedDeclRefStorage, SourceLocation> 6961f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregorcxcursor::getCursorOverloadedDeclRef(CXCursor C) { 6971f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor assert(C.kind == CXCursor_OverloadedDeclRef); 6981f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor return std::make_pair(OverloadedDeclRefStorage::getFromOpaqueValue(C.data[0]), 6991f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor SourceLocation::getFromRawEncoding( 7001f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor reinterpret_cast<uintptr_t>(C.data[1]))); 7011f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor} 7021f60d9ea523fc321d811fe880ba9a1ec74fa8f9bDouglas Gregor 703283cae37b03047c14ef918503bc46b08405c3b69Douglas GregorDecl *cxcursor::getCursorDecl(CXCursor Cursor) { 704283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor return (Decl *)Cursor.data[0]; 705283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor} 706283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor 707283cae37b03047c14ef918503bc46b08405c3b69Douglas GregorExpr *cxcursor::getCursorExpr(CXCursor Cursor) { 708283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor return dyn_cast_or_null<Expr>(getCursorStmt(Cursor)); 709283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor} 710283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor 711283cae37b03047c14ef918503bc46b08405c3b69Douglas GregorStmt *cxcursor::getCursorStmt(CXCursor Cursor) { 71278db0cdd49ec24034a5b2a4210fcda03a0919a81Douglas Gregor if (Cursor.kind == CXCursor_ObjCSuperClassRef || 7131adb082a709f7b588f03672999294e061234b2cfDouglas Gregor Cursor.kind == CXCursor_ObjCProtocolRef || 7141adb082a709f7b588f03672999294e061234b2cfDouglas Gregor Cursor.kind == CXCursor_ObjCClassRef) 7152e331b938b38057e333fab0ba841130ea8467794Douglas Gregor return 0; 7162e331b938b38057e333fab0ba841130ea8467794Douglas Gregor 717283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor return (Stmt *)Cursor.data[1]; 718283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor} 719283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor 72095f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted KremenekAttr *cxcursor::getCursorAttr(CXCursor Cursor) { 72195f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek return (Attr *)Cursor.data[1]; 72295f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek} 72395f33555a6d51b6537a9ed3968c3d1c2e4991b51Ted Kremenek 7248ccac3de1335f1cfd7cea56ba1cefcf0b724ce3fArgyrios KyrtzidisDecl *cxcursor::getCursorParentDecl(CXCursor Cursor) { 7258ccac3de1335f1cfd7cea56ba1cefcf0b724ce3fArgyrios Kyrtzidis return (Decl *)Cursor.data[0]; 7268ccac3de1335f1cfd7cea56ba1cefcf0b724ce3fArgyrios Kyrtzidis} 7278ccac3de1335f1cfd7cea56ba1cefcf0b724ce3fArgyrios Kyrtzidis 728f46034af49435a4d1a0085a4738343122aeb6521Douglas GregorASTContext &cxcursor::getCursorContext(CXCursor Cursor) { 729b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor return getCursorASTUnit(Cursor)->getASTContext(); 730b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas Gregor} 73197b9872d5775446cb8aca1380e437649fe848d91Douglas Gregor 732b2cd48756119f4d8d2a865b4b3e0e8efd02e26a0Douglas GregorASTUnit *cxcursor::getCursorASTUnit(CXCursor Cursor) { 733a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek return static_cast<ASTUnit *>(static_cast<CXTranslationUnit>(Cursor.data[2]) 734a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek ->TUData); 735a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek} 736a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek 737a60ed47da13393796d8552b9fdca12abbb3eea42Ted KremenekCXTranslationUnit cxcursor::getCursorTU(CXCursor Cursor) { 738a60ed47da13393796d8552b9fdca12abbb3eea42Ted Kremenek return static_cast<CXTranslationUnit>(Cursor.data[2]); 739283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor} 740283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor 741b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidisstatic void CollectOverriddenMethods(CXTranslationUnit TU, 742b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis DeclContext *Ctx, 743b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis ObjCMethodDecl *Method, 744b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis SmallVectorImpl<CXCursor> &Methods) { 745b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis if (!Ctx) 746b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis return; 747b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis 748b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis // If we have a class or category implementation, jump straight to the 749b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis // interface. 750b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis if (ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(Ctx)) 751b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis return CollectOverriddenMethods(TU, Impl->getClassInterface(), 752b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis Method, Methods); 753b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis 754b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis ObjCContainerDecl *Container = dyn_cast<ObjCContainerDecl>(Ctx); 755b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis if (!Container) 756b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis return; 757b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis 758b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis // Check whether we have a matching method at this level. 759b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis if (ObjCMethodDecl *Overridden = Container->getMethod(Method->getSelector(), 760b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis Method->isInstanceMethod())) 761b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis if (Method != Overridden) { 762b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis // We found an override at this level; there is no need to look 763b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis // into other protocols or categories. 764b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis Methods.push_back(MakeCXCursor(Overridden, TU)); 765b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis return; 766b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis } 767b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis 768b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis if (ObjCProtocolDecl *Protocol = dyn_cast<ObjCProtocolDecl>(Container)) { 769b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis for (ObjCProtocolDecl::protocol_iterator P = Protocol->protocol_begin(), 770b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis PEnd = Protocol->protocol_end(); 771b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis P != PEnd; ++P) 772b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis CollectOverriddenMethods(TU, *P, Method, Methods); 773b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis } 774b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis 775b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis if (ObjCCategoryDecl *Category = dyn_cast<ObjCCategoryDecl>(Container)) { 776b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis for (ObjCCategoryDecl::protocol_iterator P = Category->protocol_begin(), 777b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis PEnd = Category->protocol_end(); 778b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis P != PEnd; ++P) 779b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis CollectOverriddenMethods(TU, *P, Method, Methods); 780b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis } 781b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis 782b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis if (ObjCInterfaceDecl *Interface = dyn_cast<ObjCInterfaceDecl>(Container)) { 783b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis for (ObjCInterfaceDecl::protocol_iterator P = Interface->protocol_begin(), 784b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis PEnd = Interface->protocol_end(); 785b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis P != PEnd; ++P) 786b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis CollectOverriddenMethods(TU, *P, Method, Methods); 787b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis 788b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis for (ObjCCategoryDecl *Category = Interface->getCategoryList(); 789b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis Category; Category = Category->getNextClassCategory()) 790b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis CollectOverriddenMethods(TU, Category, Method, Methods); 791b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis 792b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis // We only look into the superclass if we haven't found anything yet. 793b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis if (Methods.empty()) 794b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis if (ObjCInterfaceDecl *Super = Interface->getSuperClass()) 795b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis return CollectOverriddenMethods(TU, Super, Method, Methods); 796b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis } 797b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis} 798b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis 799b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidisvoid cxcursor::getOverriddenCursors(CXCursor cursor, 800b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis SmallVectorImpl<CXCursor> &overridden) { 801b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis if (!clang_isDeclaration(cursor.kind)) 802b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis return; 803b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis 804b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis Decl *D = getCursorDecl(cursor); 805b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis if (!D) 806b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis return; 807b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis 808b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis // Handle C++ member functions. 809b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis CXTranslationUnit TU = getCursorTU(cursor); 810b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis if (CXXMethodDecl *CXXMethod = dyn_cast<CXXMethodDecl>(D)) { 811b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis for (CXXMethodDecl::method_iterator 812b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis M = CXXMethod->begin_overridden_methods(), 813b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis MEnd = CXXMethod->end_overridden_methods(); 814b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis M != MEnd; ++M) 815b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis overridden.push_back(MakeCXCursor(const_cast<CXXMethodDecl*>(*M), TU)); 816b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis return; 817b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis } 818b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis 819b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(D); 820b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis if (!Method) 821b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis return; 822b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis 823b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis // Handle Objective-C methods. 824b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis CollectOverriddenMethods(TU, Method->getDeclContext(), Method, overridden); 825b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis} 826b11be041e4f05519a2eabf6a99429ba6110f1ca9Argyrios Kyrtzidis 827aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidisstd::pair<int, SourceLocation> 828aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidiscxcursor::getSelectorIdentifierIndexAndLoc(CXCursor cursor) { 829aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis if (cursor.kind == CXCursor_ObjCMessageExpr) { 830aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis if (cursor.xdata != -1) 831aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis return std::make_pair(cursor.xdata, 832aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis cast<ObjCMessageExpr>(getCursorExpr(cursor)) 833aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis ->getSelectorLoc(cursor.xdata)); 834aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis } else if (cursor.kind == CXCursor_ObjCClassMethodDecl || 835aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis cursor.kind == CXCursor_ObjCInstanceMethodDecl) { 836aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis if (cursor.xdata != -1) 837aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis return std::make_pair(cursor.xdata, 838aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis cast<ObjCMethodDecl>(getCursorDecl(cursor)) 839aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis ->getSelectorLoc(cursor.xdata)); 840aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis } 841aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis 842aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis return std::make_pair(-1, SourceLocation()); 843aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis} 844aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis 845aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios KyrtzidisCXCursor cxcursor::getSelectorIdentifierCursor(int SelIdx, CXCursor cursor) { 846aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXCursor newCursor = cursor; 847aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis 848aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis if (cursor.kind == CXCursor_ObjCMessageExpr) { 849aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis if (SelIdx == -1 || 850aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis unsigned(SelIdx) >= cast<ObjCMessageExpr>(getCursorExpr(cursor)) 851aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis ->getNumSelectorLocs()) 852aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis newCursor.xdata = -1; 853aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis else 854aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis newCursor.xdata = SelIdx; 855aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis } else if (cursor.kind == CXCursor_ObjCClassMethodDecl || 856aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis cursor.kind == CXCursor_ObjCInstanceMethodDecl) { 857aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis if (SelIdx == -1 || 858aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis unsigned(SelIdx) >= cast<ObjCMethodDecl>(getCursorDecl(cursor)) 859aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis ->getNumSelectorLocs()) 860aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis newCursor.xdata = -1; 861aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis else 862aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis newCursor.xdata = SelIdx; 863aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis } 864aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis 865aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis return newCursor; 866aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis} 867aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis 868aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios KyrtzidisCXCursor cxcursor::getTypeRefCursor(CXCursor cursor) { 869aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis if (cursor.kind != CXCursor_CallExpr) 870aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis return cursor; 871aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis 872aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis if (cursor.xdata == 0) 873aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis return cursor; 874aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis 875aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis Expr *E = getCursorExpr(cursor); 876aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis TypeSourceInfo *Type = 0; 877aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis if (CXXUnresolvedConstructExpr * 878aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis UnCtor = dyn_cast<CXXUnresolvedConstructExpr>(E)) { 879aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis Type = UnCtor->getTypeSourceInfo(); 880aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis } else if (CXXTemporaryObjectExpr *Tmp = dyn_cast<CXXTemporaryObjectExpr>(E)){ 881aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis Type = Tmp->getTypeSourceInfo(); 882aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis } 883aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis 884aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis if (!Type) 885aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis return cursor; 886aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis 887aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis CXTranslationUnit TU = getCursorTU(cursor); 888aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis QualType Ty = Type->getType(); 889aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis TypeLoc TL = Type->getTypeLoc(); 890aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis SourceLocation Loc = TL.getBeginLoc(); 891aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis 892aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis if (const ElaboratedType *ElabT = Ty->getAs<ElaboratedType>()) { 893aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis Ty = ElabT->getNamedType(); 894aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis ElaboratedTypeLoc ElabTL = cast<ElaboratedTypeLoc>(TL); 895aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis Loc = ElabTL.getNamedTypeLoc().getBeginLoc(); 896aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis } 897aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis 898aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis if (const TypedefType *Typedef = Ty->getAs<TypedefType>()) 899aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis return MakeCursorTypeRef(Typedef->getDecl(), Loc, TU); 900aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis if (const TagType *Tag = Ty->getAs<TagType>()) 901aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis return MakeCursorTypeRef(Tag->getDecl(), Loc, TU); 902aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis if (const TemplateTypeParmType *TemplP = Ty->getAs<TemplateTypeParmType>()) 903aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis return MakeCursorTypeRef(TemplP->getDecl(), Loc, TU); 904aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis 905aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis return cursor; 906aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis} 907aed123ec3cc37e457fe20a6158fdadf8849ad916Argyrios Kyrtzidis 908283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregorbool cxcursor::operator==(CXCursor X, CXCursor Y) { 909283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor return X.kind == Y.kind && X.data[0] == Y.data[0] && X.data[1] == Y.data[1] && 910283cae37b03047c14ef918503bc46b08405c3b69Douglas Gregor X.data[2] == Y.data[2]; 9112e331b938b38057e333fab0ba841130ea8467794Douglas Gregor} 912007a7c9d8dcdb2e9cd94b6075108bfc4c90e6ccdTed Kremenek 913007a7c9d8dcdb2e9cd94b6075108bfc4c90e6ccdTed Kremenek// FIXME: Remove once we can model DeclGroups and their appropriate ranges 914007a7c9d8dcdb2e9cd94b6075108bfc4c90e6ccdTed Kremenek// properly in the ASTs. 915007a7c9d8dcdb2e9cd94b6075108bfc4c90e6ccdTed Kremenekbool cxcursor::isFirstInDeclGroup(CXCursor C) { 916007a7c9d8dcdb2e9cd94b6075108bfc4c90e6ccdTed Kremenek assert(clang_isDeclaration(C.kind)); 917007a7c9d8dcdb2e9cd94b6075108bfc4c90e6ccdTed Kremenek return ((uintptr_t) (C.data[1])) != 0; 918007a7c9d8dcdb2e9cd94b6075108bfc4c90e6ccdTed Kremenek} 919007a7c9d8dcdb2e9cd94b6075108bfc4c90e6ccdTed Kremenek 920eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek//===----------------------------------------------------------------------===// 921b0d6eaa6b646c18c49923aefc76973801f561701Argyrios Kyrtzidis// libclang CXCursor APIs 922b0d6eaa6b646c18c49923aefc76973801f561701Argyrios Kyrtzidis//===----------------------------------------------------------------------===// 923b0d6eaa6b646c18c49923aefc76973801f561701Argyrios Kyrtzidis 924fa865df489fe68668c554dece36c68b4ce03920fArgyrios Kyrtzidisextern "C" { 925fa865df489fe68668c554dece36c68b4ce03920fArgyrios Kyrtzidis 926fa865df489fe68668c554dece36c68b4ce03920fArgyrios Kyrtzidisint clang_Cursor_isNull(CXCursor cursor) { 927fa865df489fe68668c554dece36c68b4ce03920fArgyrios Kyrtzidis return clang_equalCursors(cursor, clang_getNullCursor()); 928fa865df489fe68668c554dece36c68b4ce03920fArgyrios Kyrtzidis} 929fa865df489fe68668c554dece36c68b4ce03920fArgyrios Kyrtzidis 930b0d6eaa6b646c18c49923aefc76973801f561701Argyrios KyrtzidisCXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor cursor) { 931b0d6eaa6b646c18c49923aefc76973801f561701Argyrios Kyrtzidis return getCursorTU(cursor); 932b0d6eaa6b646c18c49923aefc76973801f561701Argyrios Kyrtzidis} 933b0d6eaa6b646c18c49923aefc76973801f561701Argyrios Kyrtzidis 934fa865df489fe68668c554dece36c68b4ce03920fArgyrios Kyrtzidis} // end: extern "C" 935fa865df489fe68668c554dece36c68b4ce03920fArgyrios Kyrtzidis 936b0d6eaa6b646c18c49923aefc76973801f561701Argyrios Kyrtzidis//===----------------------------------------------------------------------===// 937eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek// CXCursorSet. 938eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek//===----------------------------------------------------------------------===// 939eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek 940eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenektypedef llvm::DenseMap<CXCursor, unsigned> CXCursorSet_Impl; 941eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek 942eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenekstatic inline CXCursorSet packCXCursorSet(CXCursorSet_Impl *setImpl) { 943eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek return (CXCursorSet) setImpl; 944eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek} 945eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenekstatic inline CXCursorSet_Impl *unpackCXCursorSet(CXCursorSet set) { 946eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek return (CXCursorSet_Impl*) set; 947eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek} 948eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremeneknamespace llvm { 949da6fb69873079a0193ed8c9fa1d1b859d4f87b95Ted Kremenektemplate<> struct DenseMapInfo<CXCursor> { 950eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenekpublic: 951eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek static inline CXCursor getEmptyKey() { 952eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek return MakeCXCursorInvalid(CXCursor_InvalidFile); 953eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek } 954eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek static inline CXCursor getTombstoneKey() { 955eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek return MakeCXCursorInvalid(CXCursor_NoDeclFound); 956eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek } 957eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek static inline unsigned getHashValue(const CXCursor &cursor) { 958eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek return llvm::DenseMapInfo<std::pair<void*,void*> > 959eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek ::getHashValue(std::make_pair(cursor.data[0], cursor.data[1])); 960eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek } 961eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek static inline bool isEqual(const CXCursor &x, const CXCursor &y) { 962eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek return x.kind == y.kind && 963eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek x.data[0] == y.data[0] && 964eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek x.data[1] == y.data[1]; 965eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek } 966eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek}; 967eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek} 968eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek 969eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenekextern "C" { 970eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted KremenekCXCursorSet clang_createCXCursorSet() { 971eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek return packCXCursorSet(new CXCursorSet_Impl()); 972eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek} 973eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek 974eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenekvoid clang_disposeCXCursorSet(CXCursorSet set) { 975eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek delete unpackCXCursorSet(set); 976eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek} 977eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek 978eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenekunsigned clang_CXCursorSet_contains(CXCursorSet set, CXCursor cursor) { 979eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek CXCursorSet_Impl *setImpl = unpackCXCursorSet(set); 980eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek if (!setImpl) 981eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek return 0; 982eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek return setImpl->find(cursor) == setImpl->end(); 983eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek} 984eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek 985e8b3de090b9de3c27c5d381e767217ddb849d5d8Anders Carlssonunsigned clang_CXCursorSet_insert(CXCursorSet set, CXCursor cursor) { 986eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek // Do not insert invalid cursors into the set. 987eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek if (cursor.kind >= CXCursor_FirstInvalid && 988eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek cursor.kind <= CXCursor_LastInvalid) 989eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek return 1; 990eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek 991eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek CXCursorSet_Impl *setImpl = unpackCXCursorSet(set); 992eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek if (!setImpl) 993eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek return 1; 994eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek unsigned &entry = (*setImpl)[cursor]; 995eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek unsigned flag = entry == 0 ? 1 : 0; 996eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek entry = 1; 997eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek return flag; 998eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek} 9998fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor 10008fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas GregorCXCompletionString clang_getCursorCompletionString(CXCursor cursor) { 10018fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor enum CXCursorKind kind = clang_getCursorKind(cursor); 10028fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor if (clang_isDeclaration(kind)) { 10038fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor Decl *decl = getCursorDecl(cursor); 10048fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor if (isa<NamedDecl>(decl)) { 10058fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor NamedDecl *namedDecl = (NamedDecl *)decl; 10068fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor ASTUnit *unit = getCursorASTUnit(cursor); 10078fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor if (unit->hasSema()) { 10088fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor Sema &S = unit->getSema(); 10098fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor CodeCompletionAllocator *Allocator 10108fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor = unit->getCursorCompletionAllocator().getPtr(); 10118fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor CodeCompletionResult Result(namedDecl); 10128fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor CodeCompletionString *String 10138fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor = Result.CreateCodeCompletionString(S, *Allocator); 10148fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor return String; 10158fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor } 10168fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor } 10178fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor } 10188fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor else if (kind == CXCursor_MacroDefinition) { 10198fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor MacroDefinition *definition = getCursorMacroDefinition(cursor); 10208fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor const IdentifierInfo *MacroInfo = definition->getName(); 10218fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor ASTUnit *unit = getCursorASTUnit(cursor); 10228fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor if (unit->hasSema()) { 10238fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor Sema &S = unit->getSema(); 10248fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor CodeCompletionAllocator *Allocator 10258fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor = unit->getCursorCompletionAllocator().getPtr(); 1026eaf4fbab08b2636103b2da08412e33baff15ad2aDouglas Gregor CodeCompletionResult Result(const_cast<IdentifierInfo *>(MacroInfo)); 10278fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor CodeCompletionString *String 10288fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor = Result.CreateCodeCompletionString(S, *Allocator); 10298fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor return String; 10308fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor } 10318fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor } 10328fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor return NULL; 10338fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor} 10348fa0a80b4482ad94e82c4a19e23de17fd69140b5Douglas Gregor 1035eca099bdb0178d408d4f717c2e9627e0d0e673c6Ted Kremenek} // end: extern "C" 1036