Ted Kremenek | 16c440a | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 1 | //===- CXCursor.cpp - Routines for manipulating CXCursors -----------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Douglas Gregor | 2e331b9 | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 10 | // This file defines routines for manipulating CXCursors. It should be the |
| 11 | // only file that has internal knowledge of the encoding of the data in |
| 12 | // CXCursor. |
Ted Kremenek | 16c440a | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
Ted Kremenek | 0a90d32 | 2010-11-17 23:24:11 +0000 | [diff] [blame] | 16 | #include "CXTranslationUnit.h" |
Ted Kremenek | 16c440a | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 17 | #include "CXCursor.h" |
Ted Kremenek | ed12273 | 2010-11-16 01:56:27 +0000 | [diff] [blame] | 18 | #include "CXString.h" |
Chandler Carruth | f59edb9 | 2012-12-04 09:25:21 +0000 | [diff] [blame] | 19 | #include "CXType.h" |
| 20 | #include "clang-c/Index.h" |
Ted Kremenek | 16c440a | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 21 | #include "clang/AST/Decl.h" |
Douglas Gregor | 6931900 | 2010-08-31 23:48:11 +0000 | [diff] [blame] | 22 | #include "clang/AST/DeclCXX.h" |
Douglas Gregor | 283cae3 | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 23 | #include "clang/AST/DeclObjC.h" |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 24 | #include "clang/AST/DeclTemplate.h" |
Douglas Gregor | 283cae3 | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 25 | #include "clang/AST/Expr.h" |
Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 26 | #include "clang/AST/ExprCXX.h" |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 27 | #include "clang/AST/ExprObjC.h" |
Chandler Carruth | f59edb9 | 2012-12-04 09:25:21 +0000 | [diff] [blame] | 28 | #include "clang/Frontend/ASTUnit.h" |
Ted Kremenek | edc8aa6 | 2010-01-16 00:36:30 +0000 | [diff] [blame] | 29 | #include "llvm/Support/ErrorHandling.h" |
Ted Kremenek | 16c440a | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 30 | |
| 31 | using namespace clang; |
Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 32 | using namespace cxcursor; |
Ted Kremenek | 16c440a | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 33 | |
Ted Kremenek | bbf66ca | 2012-04-30 19:06:49 +0000 | [diff] [blame] | 34 | CXCursor cxcursor::MakeCXCursorInvalid(CXCursorKind K, CXTranslationUnit TU) { |
Douglas Gregor | 5bfb8c1 | 2010-01-20 23:34:41 +0000 | [diff] [blame] | 35 | assert(K >= CXCursor_FirstInvalid && K <= CXCursor_LastInvalid); |
Ted Kremenek | bbf66ca | 2012-04-30 19:06:49 +0000 | [diff] [blame] | 36 | CXCursor C = { K, 0, { 0, 0, TU } }; |
Douglas Gregor | 5bfb8c1 | 2010-01-20 23:34:41 +0000 | [diff] [blame] | 37 | return C; |
Ted Kremenek | 16c440a | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 38 | } |
| 39 | |
Ted Kremenek | e77f443 | 2010-02-18 03:09:07 +0000 | [diff] [blame] | 40 | static CXCursorKind GetCursorKind(const Attr *A) { |
| 41 | assert(A && "Invalid arguments!"); |
| 42 | switch (A->getKind()) { |
| 43 | default: break; |
Sean Hunt | 387475d | 2010-06-16 23:43:53 +0000 | [diff] [blame] | 44 | case attr::IBAction: return CXCursor_IBActionAttr; |
| 45 | case attr::IBOutlet: return CXCursor_IBOutletAttr; |
| 46 | case attr::IBOutletCollection: return CXCursor_IBOutletCollectionAttr; |
Argyrios Kyrtzidis | 6639e92 | 2011-09-13 17:39:31 +0000 | [diff] [blame] | 47 | case attr::Final: return CXCursor_CXXFinalAttr; |
| 48 | case attr::Override: return CXCursor_CXXOverrideAttr; |
Erik Verbruggen | 5f1c822 | 2011-10-13 09:41:32 +0000 | [diff] [blame] | 49 | case attr::Annotate: return CXCursor_AnnotateAttr; |
Argyrios Kyrtzidis | 84b7964 | 2011-12-06 22:05:01 +0000 | [diff] [blame] | 50 | case attr::AsmLabel: return CXCursor_AsmLabelAttr; |
Ted Kremenek | e77f443 | 2010-02-18 03:09:07 +0000 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | return CXCursor_UnexposedAttr; |
| 54 | } |
| 55 | |
Dmitri Gribenko | 05756dc | 2013-01-14 00:46:27 +0000 | [diff] [blame] | 56 | CXCursor cxcursor::MakeCXCursor(const Attr *A, const Decl *Parent, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 57 | CXTranslationUnit TU) { |
Ted Kremenek | e77f443 | 2010-02-18 03:09:07 +0000 | [diff] [blame] | 58 | assert(A && Parent && TU && "Invalid arguments!"); |
Dmitri Gribenko | 3315618 | 2013-01-11 21:06:06 +0000 | [diff] [blame] | 59 | CXCursor C = { GetCursorKind(A), 0, { Parent, A, TU } }; |
Ted Kremenek | e77f443 | 2010-02-18 03:09:07 +0000 | [diff] [blame] | 60 | return C; |
| 61 | } |
| 62 | |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 63 | CXCursor cxcursor::MakeCXCursor(const Decl *D, CXTranslationUnit TU, |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 64 | SourceRange RegionOfInterest, |
Ted Kremenek | 007a7c9 | 2010-11-01 23:26:51 +0000 | [diff] [blame] | 65 | bool FirstInDeclGroup) { |
Daniel Dunbar | 54d67ca | 2010-01-25 00:40:30 +0000 | [diff] [blame] | 66 | assert(D && TU && "Invalid arguments!"); |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 67 | |
| 68 | CXCursorKind K = getCursorKindForDecl(D); |
| 69 | |
| 70 | if (K == CXCursor_ObjCClassMethodDecl || |
| 71 | K == CXCursor_ObjCInstanceMethodDecl) { |
| 72 | int SelectorIdIndex = -1; |
| 73 | // Check if cursor points to a selector id. |
| 74 | if (RegionOfInterest.isValid() && |
| 75 | RegionOfInterest.getBegin() == RegionOfInterest.getEnd()) { |
| 76 | SmallVector<SourceLocation, 16> SelLocs; |
| 77 | cast<ObjCMethodDecl>(D)->getSelectorLocs(SelLocs); |
| 78 | SmallVector<SourceLocation, 16>::iterator |
| 79 | I=std::find(SelLocs.begin(), SelLocs.end(),RegionOfInterest.getBegin()); |
| 80 | if (I != SelLocs.end()) |
| 81 | SelectorIdIndex = I - SelLocs.begin(); |
| 82 | } |
| 83 | CXCursor C = { K, SelectorIdIndex, |
| 84 | { D, (void*)(intptr_t) (FirstInDeclGroup ? 1 : 0), TU }}; |
| 85 | return C; |
| 86 | } |
| 87 | |
| 88 | CXCursor C = { K, 0, { D, (void*)(intptr_t) (FirstInDeclGroup ? 1 : 0), TU }}; |
Douglas Gregor | 5bfb8c1 | 2010-01-20 23:34:41 +0000 | [diff] [blame] | 89 | return C; |
Ted Kremenek | edc8aa6 | 2010-01-16 00:36:30 +0000 | [diff] [blame] | 90 | } |
| 91 | |
Dmitri Gribenko | 05756dc | 2013-01-14 00:46:27 +0000 | [diff] [blame] | 92 | CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent, |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 93 | CXTranslationUnit TU, |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 94 | SourceRange RegionOfInterest) { |
Daniel Dunbar | 54d67ca | 2010-01-25 00:40:30 +0000 | [diff] [blame] | 95 | assert(S && TU && "Invalid arguments!"); |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 96 | CXCursorKind K = CXCursor_NotImplemented; |
| 97 | |
| 98 | switch (S->getStmtClass()) { |
| 99 | case Stmt::NoStmtClass: |
| 100 | break; |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 101 | |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 102 | case Stmt::CaseStmtClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 103 | K = CXCursor_CaseStmt; |
| 104 | break; |
| 105 | |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 106 | case Stmt::DefaultStmtClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 107 | K = CXCursor_DefaultStmt; |
| 108 | break; |
| 109 | |
| 110 | case Stmt::IfStmtClass: |
| 111 | K = CXCursor_IfStmt; |
| 112 | break; |
| 113 | |
| 114 | case Stmt::SwitchStmtClass: |
| 115 | K = CXCursor_SwitchStmt; |
| 116 | break; |
| 117 | |
| 118 | case Stmt::WhileStmtClass: |
| 119 | K = CXCursor_WhileStmt; |
| 120 | break; |
| 121 | |
| 122 | case Stmt::DoStmtClass: |
| 123 | K = CXCursor_DoStmt; |
| 124 | break; |
| 125 | |
| 126 | case Stmt::ForStmtClass: |
| 127 | K = CXCursor_ForStmt; |
| 128 | break; |
| 129 | |
| 130 | case Stmt::GotoStmtClass: |
| 131 | K = CXCursor_GotoStmt; |
| 132 | break; |
| 133 | |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 134 | case Stmt::IndirectGotoStmtClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 135 | K = CXCursor_IndirectGotoStmt; |
| 136 | break; |
| 137 | |
| 138 | case Stmt::ContinueStmtClass: |
| 139 | K = CXCursor_ContinueStmt; |
| 140 | break; |
| 141 | |
| 142 | case Stmt::BreakStmtClass: |
| 143 | K = CXCursor_BreakStmt; |
| 144 | break; |
| 145 | |
| 146 | case Stmt::ReturnStmtClass: |
| 147 | K = CXCursor_ReturnStmt; |
| 148 | break; |
| 149 | |
Chad Rosier | df5faf5 | 2012-08-25 00:11:56 +0000 | [diff] [blame] | 150 | case Stmt::GCCAsmStmtClass: |
| 151 | K = CXCursor_GCCAsmStmt; |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 152 | break; |
Chad Rosier | 8cd64b4 | 2012-06-11 20:47:18 +0000 | [diff] [blame] | 153 | |
| 154 | case Stmt::MSAsmStmtClass: |
| 155 | K = CXCursor_MSAsmStmt; |
| 156 | break; |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 157 | |
| 158 | case Stmt::ObjCAtTryStmtClass: |
| 159 | K = CXCursor_ObjCAtTryStmt; |
| 160 | break; |
| 161 | |
| 162 | case Stmt::ObjCAtCatchStmtClass: |
| 163 | K = CXCursor_ObjCAtCatchStmt; |
| 164 | break; |
| 165 | |
| 166 | case Stmt::ObjCAtFinallyStmtClass: |
| 167 | K = CXCursor_ObjCAtFinallyStmt; |
| 168 | break; |
| 169 | |
| 170 | case Stmt::ObjCAtThrowStmtClass: |
| 171 | K = CXCursor_ObjCAtThrowStmt; |
| 172 | break; |
| 173 | |
| 174 | case Stmt::ObjCAtSynchronizedStmtClass: |
| 175 | K = CXCursor_ObjCAtSynchronizedStmt; |
| 176 | break; |
| 177 | |
| 178 | case Stmt::ObjCAutoreleasePoolStmtClass: |
| 179 | K = CXCursor_ObjCAutoreleasePoolStmt; |
| 180 | break; |
| 181 | |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 182 | case Stmt::ObjCForCollectionStmtClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 183 | K = CXCursor_ObjCForCollectionStmt; |
| 184 | break; |
| 185 | |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 186 | case Stmt::CXXCatchStmtClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 187 | K = CXCursor_CXXCatchStmt; |
| 188 | break; |
| 189 | |
| 190 | case Stmt::CXXTryStmtClass: |
| 191 | K = CXCursor_CXXTryStmt; |
| 192 | break; |
| 193 | |
| 194 | case Stmt::CXXForRangeStmtClass: |
| 195 | K = CXCursor_CXXForRangeStmt; |
| 196 | break; |
| 197 | |
John Wiegley | 28bbe4b | 2011-04-28 01:08:34 +0000 | [diff] [blame] | 198 | case Stmt::SEHTryStmtClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 199 | K = CXCursor_SEHTryStmt; |
| 200 | break; |
| 201 | |
John Wiegley | 28bbe4b | 2011-04-28 01:08:34 +0000 | [diff] [blame] | 202 | case Stmt::SEHExceptStmtClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 203 | K = CXCursor_SEHExceptStmt; |
| 204 | break; |
| 205 | |
John Wiegley | 28bbe4b | 2011-04-28 01:08:34 +0000 | [diff] [blame] | 206 | case Stmt::SEHFinallyStmtClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 207 | K = CXCursor_SEHFinallyStmt; |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 208 | break; |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 209 | |
John Wiegley | 21ff2e5 | 2011-04-28 00:16:57 +0000 | [diff] [blame] | 210 | case Stmt::ArrayTypeTraitExprClass: |
Tanya Lattner | 61eee0c | 2011-06-04 00:47:47 +0000 | [diff] [blame] | 211 | case Stmt::AsTypeExprClass: |
Eli Friedman | 276b061 | 2011-10-11 02:20:01 +0000 | [diff] [blame] | 212 | case Stmt::AtomicExprClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 213 | case Stmt::BinaryConditionalOperatorClass: |
| 214 | case Stmt::BinaryTypeTraitExprClass: |
Douglas Gregor | 4ca8ac2 | 2012-02-24 07:38:34 +0000 | [diff] [blame] | 215 | case Stmt::TypeTraitExprClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 216 | case Stmt::CXXBindTemporaryExprClass: |
| 217 | case Stmt::CXXDefaultArgExprClass: |
| 218 | case Stmt::CXXScalarValueInitExprClass: |
| 219 | case Stmt::CXXUuidofExprClass: |
| 220 | case Stmt::ChooseExprClass: |
| 221 | case Stmt::DesignatedInitExprClass: |
| 222 | case Stmt::ExprWithCleanupsClass: |
| 223 | case Stmt::ExpressionTraitExprClass: |
| 224 | case Stmt::ExtVectorElementExprClass: |
| 225 | case Stmt::ImplicitCastExprClass: |
| 226 | case Stmt::ImplicitValueInitExprClass: |
| 227 | case Stmt::MaterializeTemporaryExprClass: |
| 228 | case Stmt::ObjCIndirectCopyRestoreExprClass: |
| 229 | case Stmt::OffsetOfExprClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 230 | case Stmt::ParenListExprClass: |
| 231 | case Stmt::PredefinedExprClass: |
| 232 | case Stmt::ShuffleVectorExprClass: |
| 233 | case Stmt::UnaryExprOrTypeTraitExprClass: |
| 234 | case Stmt::UnaryTypeTraitExprClass: |
| 235 | case Stmt::VAArgExprClass: |
Ted Kremenek | b3f7542 | 2012-03-06 20:06:06 +0000 | [diff] [blame] | 236 | case Stmt::ObjCArrayLiteralClass: |
| 237 | case Stmt::ObjCDictionaryLiteralClass: |
Patrick Beard | eb382ec | 2012-04-19 00:25:12 +0000 | [diff] [blame] | 238 | case Stmt::ObjCBoxedExprClass: |
Ted Kremenek | b3f7542 | 2012-03-06 20:06:06 +0000 | [diff] [blame] | 239 | case Stmt::ObjCSubscriptRefExprClass: |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 240 | K = CXCursor_UnexposedExpr; |
| 241 | break; |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 242 | |
John McCall | 4b9c2d2 | 2011-11-06 09:01:30 +0000 | [diff] [blame] | 243 | case Stmt::OpaqueValueExprClass: |
| 244 | if (Expr *Src = cast<OpaqueValueExpr>(S)->getSourceExpr()) |
| 245 | return MakeCXCursor(Src, Parent, TU, RegionOfInterest); |
| 246 | K = CXCursor_UnexposedExpr; |
| 247 | break; |
| 248 | |
| 249 | case Stmt::PseudoObjectExprClass: |
| 250 | return MakeCXCursor(cast<PseudoObjectExpr>(S)->getSyntacticForm(), |
| 251 | Parent, TU, RegionOfInterest); |
| 252 | |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 253 | case Stmt::CompoundStmtClass: |
| 254 | K = CXCursor_CompoundStmt; |
| 255 | break; |
Richard Smith | 534986f | 2012-04-14 00:33:13 +0000 | [diff] [blame] | 256 | |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 257 | case Stmt::NullStmtClass: |
| 258 | K = CXCursor_NullStmt; |
| 259 | break; |
Richard Smith | 534986f | 2012-04-14 00:33:13 +0000 | [diff] [blame] | 260 | |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 261 | case Stmt::LabelStmtClass: |
| 262 | K = CXCursor_LabelStmt; |
| 263 | break; |
Richard Smith | 534986f | 2012-04-14 00:33:13 +0000 | [diff] [blame] | 264 | |
| 265 | case Stmt::AttributedStmtClass: |
| 266 | K = CXCursor_UnexposedStmt; |
| 267 | break; |
| 268 | |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 269 | case Stmt::DeclStmtClass: |
| 270 | K = CXCursor_DeclStmt; |
| 271 | break; |
Richard Smith | 534986f | 2012-04-14 00:33:13 +0000 | [diff] [blame] | 272 | |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 273 | case Stmt::IntegerLiteralClass: |
| 274 | K = CXCursor_IntegerLiteral; |
| 275 | break; |
| 276 | |
| 277 | case Stmt::FloatingLiteralClass: |
| 278 | K = CXCursor_FloatingLiteral; |
| 279 | break; |
| 280 | |
| 281 | case Stmt::ImaginaryLiteralClass: |
| 282 | K = CXCursor_ImaginaryLiteral; |
| 283 | break; |
| 284 | |
| 285 | case Stmt::StringLiteralClass: |
| 286 | K = CXCursor_StringLiteral; |
| 287 | break; |
| 288 | |
| 289 | case Stmt::CharacterLiteralClass: |
| 290 | K = CXCursor_CharacterLiteral; |
| 291 | break; |
| 292 | |
| 293 | case Stmt::ParenExprClass: |
| 294 | K = CXCursor_ParenExpr; |
| 295 | break; |
| 296 | |
| 297 | case Stmt::UnaryOperatorClass: |
| 298 | K = CXCursor_UnaryOperator; |
| 299 | break; |
Richard Smith | 534986f | 2012-04-14 00:33:13 +0000 | [diff] [blame] | 300 | |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 301 | case Stmt::CXXNoexceptExprClass: |
| 302 | K = CXCursor_UnaryExpr; |
| 303 | break; |
| 304 | |
| 305 | case Stmt::ArraySubscriptExprClass: |
| 306 | K = CXCursor_ArraySubscriptExpr; |
| 307 | break; |
| 308 | |
| 309 | case Stmt::BinaryOperatorClass: |
| 310 | K = CXCursor_BinaryOperator; |
| 311 | break; |
| 312 | |
| 313 | case Stmt::CompoundAssignOperatorClass: |
| 314 | K = CXCursor_CompoundAssignOperator; |
| 315 | break; |
| 316 | |
| 317 | case Stmt::ConditionalOperatorClass: |
| 318 | K = CXCursor_ConditionalOperator; |
| 319 | break; |
| 320 | |
| 321 | case Stmt::CStyleCastExprClass: |
| 322 | K = CXCursor_CStyleCastExpr; |
| 323 | break; |
| 324 | |
| 325 | case Stmt::CompoundLiteralExprClass: |
| 326 | K = CXCursor_CompoundLiteralExpr; |
| 327 | break; |
| 328 | |
| 329 | case Stmt::InitListExprClass: |
| 330 | K = CXCursor_InitListExpr; |
| 331 | break; |
| 332 | |
| 333 | case Stmt::AddrLabelExprClass: |
| 334 | K = CXCursor_AddrLabelExpr; |
| 335 | break; |
| 336 | |
| 337 | case Stmt::StmtExprClass: |
| 338 | K = CXCursor_StmtExpr; |
| 339 | break; |
| 340 | |
| 341 | case Stmt::GenericSelectionExprClass: |
| 342 | K = CXCursor_GenericSelectionExpr; |
| 343 | break; |
| 344 | |
| 345 | case Stmt::GNUNullExprClass: |
| 346 | K = CXCursor_GNUNullExpr; |
| 347 | break; |
| 348 | |
| 349 | case Stmt::CXXStaticCastExprClass: |
| 350 | K = CXCursor_CXXStaticCastExpr; |
| 351 | break; |
| 352 | |
| 353 | case Stmt::CXXDynamicCastExprClass: |
| 354 | K = CXCursor_CXXDynamicCastExpr; |
| 355 | break; |
| 356 | |
| 357 | case Stmt::CXXReinterpretCastExprClass: |
| 358 | K = CXCursor_CXXReinterpretCastExpr; |
| 359 | break; |
| 360 | |
| 361 | case Stmt::CXXConstCastExprClass: |
| 362 | K = CXCursor_CXXConstCastExpr; |
| 363 | break; |
| 364 | |
| 365 | case Stmt::CXXFunctionalCastExprClass: |
| 366 | K = CXCursor_CXXFunctionalCastExpr; |
| 367 | break; |
| 368 | |
| 369 | case Stmt::CXXTypeidExprClass: |
| 370 | K = CXCursor_CXXTypeidExpr; |
| 371 | break; |
| 372 | |
| 373 | case Stmt::CXXBoolLiteralExprClass: |
| 374 | K = CXCursor_CXXBoolLiteralExpr; |
| 375 | break; |
| 376 | |
| 377 | case Stmt::CXXNullPtrLiteralExprClass: |
| 378 | K = CXCursor_CXXNullPtrLiteralExpr; |
| 379 | break; |
| 380 | |
| 381 | case Stmt::CXXThisExprClass: |
| 382 | K = CXCursor_CXXThisExpr; |
| 383 | break; |
| 384 | |
| 385 | case Stmt::CXXThrowExprClass: |
| 386 | K = CXCursor_CXXThrowExpr; |
| 387 | break; |
| 388 | |
| 389 | case Stmt::CXXNewExprClass: |
| 390 | K = CXCursor_CXXNewExpr; |
| 391 | break; |
| 392 | |
| 393 | case Stmt::CXXDeleteExprClass: |
| 394 | K = CXCursor_CXXDeleteExpr; |
| 395 | break; |
| 396 | |
| 397 | case Stmt::ObjCStringLiteralClass: |
| 398 | K = CXCursor_ObjCStringLiteral; |
| 399 | break; |
| 400 | |
| 401 | case Stmt::ObjCEncodeExprClass: |
| 402 | K = CXCursor_ObjCEncodeExpr; |
| 403 | break; |
| 404 | |
| 405 | case Stmt::ObjCSelectorExprClass: |
| 406 | K = CXCursor_ObjCSelectorExpr; |
| 407 | break; |
| 408 | |
| 409 | case Stmt::ObjCProtocolExprClass: |
| 410 | K = CXCursor_ObjCProtocolExpr; |
| 411 | break; |
Ted Kremenek | b3f7542 | 2012-03-06 20:06:06 +0000 | [diff] [blame] | 412 | |
| 413 | case Stmt::ObjCBoolLiteralExprClass: |
| 414 | K = CXCursor_ObjCBoolLiteralExpr; |
| 415 | break; |
| 416 | |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 417 | case Stmt::ObjCBridgedCastExprClass: |
| 418 | K = CXCursor_ObjCBridgedCastExpr; |
| 419 | break; |
| 420 | |
| 421 | case Stmt::BlockExprClass: |
| 422 | K = CXCursor_BlockExpr; |
| 423 | break; |
| 424 | |
| 425 | case Stmt::PackExpansionExprClass: |
| 426 | K = CXCursor_PackExpansionExpr; |
| 427 | break; |
| 428 | |
| 429 | case Stmt::SizeOfPackExprClass: |
| 430 | K = CXCursor_SizeOfPackExpr; |
| 431 | break; |
| 432 | |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 433 | case Stmt::DeclRefExprClass: |
| 434 | case Stmt::DependentScopeDeclRefExprClass: |
John McCall | 91a5755 | 2011-07-15 05:09:51 +0000 | [diff] [blame] | 435 | case Stmt::SubstNonTypeTemplateParmExprClass: |
Douglas Gregor | c7793c7 | 2011-01-15 01:15:58 +0000 | [diff] [blame] | 436 | case Stmt::SubstNonTypeTemplateParmPackExprClass: |
Richard Smith | 9a4db03 | 2012-09-12 00:56:43 +0000 | [diff] [blame] | 437 | case Stmt::FunctionParmPackExprClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 438 | case Stmt::UnresolvedLookupExprClass: |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 439 | K = CXCursor_DeclRefExpr; |
| 440 | break; |
| 441 | |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 442 | case Stmt::CXXDependentScopeMemberExprClass: |
| 443 | case Stmt::CXXPseudoDestructorExprClass: |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 444 | case Stmt::MemberExprClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 445 | case Stmt::ObjCIsaExprClass: |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 446 | case Stmt::ObjCIvarRefExprClass: |
| 447 | case Stmt::ObjCPropertyRefExprClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 448 | case Stmt::UnresolvedMemberExprClass: |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 449 | K = CXCursor_MemberRefExpr; |
| 450 | break; |
| 451 | |
| 452 | case Stmt::CallExprClass: |
| 453 | case Stmt::CXXOperatorCallExprClass: |
| 454 | case Stmt::CXXMemberCallExprClass: |
Peter Collingbourne | e08ce65 | 2011-02-09 21:07:24 +0000 | [diff] [blame] | 455 | case Stmt::CUDAKernelCallExprClass: |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 456 | case Stmt::CXXConstructExprClass: |
| 457 | case Stmt::CXXTemporaryObjectExprClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 458 | case Stmt::CXXUnresolvedConstructExprClass: |
Richard Smith | 9fcce65 | 2012-03-07 08:35:16 +0000 | [diff] [blame] | 459 | case Stmt::UserDefinedLiteralClass: |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 460 | K = CXCursor_CallExpr; |
| 461 | break; |
| 462 | |
Douglas Gregor | 011d8b9 | 2012-02-15 00:54:55 +0000 | [diff] [blame] | 463 | case Stmt::LambdaExprClass: |
| 464 | K = CXCursor_LambdaExpr; |
| 465 | break; |
| 466 | |
Douglas Gregor | ba0513d | 2011-10-25 01:33:02 +0000 | [diff] [blame] | 467 | case Stmt::ObjCMessageExprClass: { |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 468 | K = CXCursor_ObjCMessageExpr; |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 469 | int SelectorIdIndex = -1; |
| 470 | // Check if cursor points to a selector id. |
| 471 | if (RegionOfInterest.isValid() && |
| 472 | RegionOfInterest.getBegin() == RegionOfInterest.getEnd()) { |
| 473 | SmallVector<SourceLocation, 16> SelLocs; |
| 474 | cast<ObjCMessageExpr>(S)->getSelectorLocs(SelLocs); |
| 475 | SmallVector<SourceLocation, 16>::iterator |
| 476 | I=std::find(SelLocs.begin(), SelLocs.end(),RegionOfInterest.getBegin()); |
| 477 | if (I != SelLocs.end()) |
| 478 | SelectorIdIndex = I - SelLocs.begin(); |
| 479 | } |
| 480 | CXCursor C = { K, 0, { Parent, S, TU } }; |
| 481 | return getSelectorIdentifierCursor(SelectorIdIndex, C); |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 482 | } |
Douglas Gregor | ba0513d | 2011-10-25 01:33:02 +0000 | [diff] [blame] | 483 | |
| 484 | case Stmt::MSDependentExistsStmtClass: |
| 485 | K = CXCursor_UnexposedStmt; |
| 486 | break; |
| 487 | } |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 488 | |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 489 | CXCursor C = { K, 0, { Parent, S, TU } }; |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 490 | return C; |
| 491 | } |
| 492 | |
Douglas Gregor | 2e331b9 | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 493 | CXCursor cxcursor::MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super, |
Douglas Gregor | b2cd487 | 2010-01-20 23:57:43 +0000 | [diff] [blame] | 494 | SourceLocation Loc, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 495 | CXTranslationUnit TU) { |
Daniel Dunbar | 54d67ca | 2010-01-25 00:40:30 +0000 | [diff] [blame] | 496 | assert(Super && TU && "Invalid arguments!"); |
Douglas Gregor | 2e331b9 | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 497 | void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 498 | CXCursor C = { CXCursor_ObjCSuperClassRef, 0, { Super, RawLoc, TU } }; |
Douglas Gregor | 2e331b9 | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 499 | return C; |
| 500 | } |
| 501 | |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 502 | std::pair<const ObjCInterfaceDecl *, SourceLocation> |
Douglas Gregor | 2e331b9 | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 503 | cxcursor::getCursorObjCSuperClassRef(CXCursor C) { |
| 504 | assert(C.kind == CXCursor_ObjCSuperClassRef); |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 505 | return std::make_pair(static_cast<const ObjCInterfaceDecl *>(C.data[0]), |
Douglas Gregor | 2e331b9 | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 506 | SourceLocation::getFromRawEncoding( |
| 507 | reinterpret_cast<uintptr_t>(C.data[1]))); |
| 508 | } |
| 509 | |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 510 | CXCursor cxcursor::MakeCursorObjCProtocolRef(const ObjCProtocolDecl *Proto, |
Douglas Gregor | b2cd487 | 2010-01-20 23:57:43 +0000 | [diff] [blame] | 511 | SourceLocation Loc, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 512 | CXTranslationUnit TU) { |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 513 | assert(Proto && TU && "Invalid arguments!"); |
Douglas Gregor | 78db0cd | 2010-01-16 15:44:18 +0000 | [diff] [blame] | 514 | void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); |
Dmitri Gribenko | 3315618 | 2013-01-11 21:06:06 +0000 | [diff] [blame] | 515 | CXCursor C = { CXCursor_ObjCProtocolRef, 0, { Proto, RawLoc, TU } }; |
Douglas Gregor | 78db0cd | 2010-01-16 15:44:18 +0000 | [diff] [blame] | 516 | return C; |
| 517 | } |
| 518 | |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 519 | std::pair<const ObjCProtocolDecl *, SourceLocation> |
Douglas Gregor | 78db0cd | 2010-01-16 15:44:18 +0000 | [diff] [blame] | 520 | cxcursor::getCursorObjCProtocolRef(CXCursor C) { |
| 521 | assert(C.kind == CXCursor_ObjCProtocolRef); |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 522 | return std::make_pair(static_cast<const ObjCProtocolDecl *>(C.data[0]), |
Douglas Gregor | 78db0cd | 2010-01-16 15:44:18 +0000 | [diff] [blame] | 523 | SourceLocation::getFromRawEncoding( |
| 524 | reinterpret_cast<uintptr_t>(C.data[1]))); |
| 525 | } |
| 526 | |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 527 | CXCursor cxcursor::MakeCursorObjCClassRef(const ObjCInterfaceDecl *Class, |
Douglas Gregor | b2cd487 | 2010-01-20 23:57:43 +0000 | [diff] [blame] | 528 | SourceLocation Loc, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 529 | CXTranslationUnit TU) { |
Ted Kremenek | ebfa339 | 2010-03-19 20:39:03 +0000 | [diff] [blame] | 530 | // 'Class' can be null for invalid code. |
| 531 | if (!Class) |
| 532 | return MakeCXCursorInvalid(CXCursor_InvalidCode); |
| 533 | assert(TU && "Invalid arguments!"); |
Douglas Gregor | 1adb082 | 2010-01-16 17:14:40 +0000 | [diff] [blame] | 534 | void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); |
Dmitri Gribenko | 3315618 | 2013-01-11 21:06:06 +0000 | [diff] [blame] | 535 | CXCursor C = { CXCursor_ObjCClassRef, 0, { Class, RawLoc, TU } }; |
Douglas Gregor | 1adb082 | 2010-01-16 17:14:40 +0000 | [diff] [blame] | 536 | return C; |
| 537 | } |
| 538 | |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 539 | std::pair<const ObjCInterfaceDecl *, SourceLocation> |
Douglas Gregor | 1adb082 | 2010-01-16 17:14:40 +0000 | [diff] [blame] | 540 | cxcursor::getCursorObjCClassRef(CXCursor C) { |
| 541 | assert(C.kind == CXCursor_ObjCClassRef); |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 542 | return std::make_pair(static_cast<const ObjCInterfaceDecl *>(C.data[0]), |
Douglas Gregor | 1adb082 | 2010-01-16 17:14:40 +0000 | [diff] [blame] | 543 | SourceLocation::getFromRawEncoding( |
| 544 | reinterpret_cast<uintptr_t>(C.data[1]))); |
| 545 | } |
| 546 | |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 547 | CXCursor cxcursor::MakeCursorTypeRef(const TypeDecl *Type, SourceLocation Loc, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 548 | CXTranslationUnit TU) { |
Daniel Dunbar | 54d67ca | 2010-01-25 00:40:30 +0000 | [diff] [blame] | 549 | assert(Type && TU && "Invalid arguments!"); |
Douglas Gregor | 7d0d40e | 2010-01-21 16:28:34 +0000 | [diff] [blame] | 550 | void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); |
Dmitri Gribenko | 3315618 | 2013-01-11 21:06:06 +0000 | [diff] [blame] | 551 | CXCursor C = { CXCursor_TypeRef, 0, { Type, RawLoc, TU } }; |
Douglas Gregor | 7d0d40e | 2010-01-21 16:28:34 +0000 | [diff] [blame] | 552 | return C; |
| 553 | } |
| 554 | |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 555 | std::pair<const TypeDecl *, SourceLocation> |
Douglas Gregor | 7d0d40e | 2010-01-21 16:28:34 +0000 | [diff] [blame] | 556 | cxcursor::getCursorTypeRef(CXCursor C) { |
| 557 | assert(C.kind == CXCursor_TypeRef); |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 558 | return std::make_pair(static_cast<const TypeDecl *>(C.data[0]), |
Douglas Gregor | 7d0d40e | 2010-01-21 16:28:34 +0000 | [diff] [blame] | 559 | SourceLocation::getFromRawEncoding( |
| 560 | reinterpret_cast<uintptr_t>(C.data[1]))); |
| 561 | } |
| 562 | |
Argyrios Kyrtzidis | b395c63 | 2011-11-18 00:26:51 +0000 | [diff] [blame] | 563 | CXCursor cxcursor::MakeCursorTemplateRef(const TemplateDecl *Template, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 564 | SourceLocation Loc, |
| 565 | CXTranslationUnit TU) { |
Douglas Gregor | 0b36e61 | 2010-08-31 20:37:03 +0000 | [diff] [blame] | 566 | assert(Template && TU && "Invalid arguments!"); |
| 567 | void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); |
Dmitri Gribenko | 3315618 | 2013-01-11 21:06:06 +0000 | [diff] [blame] | 568 | CXCursor C = { CXCursor_TemplateRef, 0, { Template, RawLoc, TU } }; |
Douglas Gregor | 0b36e61 | 2010-08-31 20:37:03 +0000 | [diff] [blame] | 569 | return C; |
| 570 | } |
| 571 | |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 572 | std::pair<const TemplateDecl *, SourceLocation> |
Douglas Gregor | 0b36e61 | 2010-08-31 20:37:03 +0000 | [diff] [blame] | 573 | cxcursor::getCursorTemplateRef(CXCursor C) { |
| 574 | assert(C.kind == CXCursor_TemplateRef); |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 575 | return std::make_pair(static_cast<const TemplateDecl *>(C.data[0]), |
Douglas Gregor | 0b36e61 | 2010-08-31 20:37:03 +0000 | [diff] [blame] | 576 | SourceLocation::getFromRawEncoding( |
| 577 | reinterpret_cast<uintptr_t>(C.data[1]))); |
| 578 | } |
| 579 | |
Argyrios Kyrtzidis | b395c63 | 2011-11-18 00:26:51 +0000 | [diff] [blame] | 580 | CXCursor cxcursor::MakeCursorNamespaceRef(const NamedDecl *NS, |
| 581 | SourceLocation Loc, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 582 | CXTranslationUnit TU) { |
Douglas Gregor | 6931900 | 2010-08-31 23:48:11 +0000 | [diff] [blame] | 583 | |
| 584 | assert(NS && (isa<NamespaceDecl>(NS) || isa<NamespaceAliasDecl>(NS)) && TU && |
| 585 | "Invalid arguments!"); |
| 586 | void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); |
Dmitri Gribenko | 3315618 | 2013-01-11 21:06:06 +0000 | [diff] [blame] | 587 | CXCursor C = { CXCursor_NamespaceRef, 0, { NS, RawLoc, TU } }; |
Douglas Gregor | 6931900 | 2010-08-31 23:48:11 +0000 | [diff] [blame] | 588 | return C; |
| 589 | } |
| 590 | |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 591 | std::pair<const NamedDecl *, SourceLocation> |
Douglas Gregor | 6931900 | 2010-08-31 23:48:11 +0000 | [diff] [blame] | 592 | cxcursor::getCursorNamespaceRef(CXCursor C) { |
| 593 | assert(C.kind == CXCursor_NamespaceRef); |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 594 | return std::make_pair(static_cast<const NamedDecl *>(C.data[0]), |
Douglas Gregor | 6931900 | 2010-08-31 23:48:11 +0000 | [diff] [blame] | 595 | SourceLocation::getFromRawEncoding( |
| 596 | reinterpret_cast<uintptr_t>(C.data[1]))); |
| 597 | } |
| 598 | |
Douglas Gregor | 011d8b9 | 2012-02-15 00:54:55 +0000 | [diff] [blame] | 599 | CXCursor cxcursor::MakeCursorVariableRef(const VarDecl *Var, SourceLocation Loc, |
| 600 | CXTranslationUnit TU) { |
| 601 | |
| 602 | assert(Var && TU && "Invalid arguments!"); |
| 603 | void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); |
Dmitri Gribenko | 3315618 | 2013-01-11 21:06:06 +0000 | [diff] [blame] | 604 | CXCursor C = { CXCursor_VariableRef, 0, { Var, RawLoc, TU } }; |
Douglas Gregor | 011d8b9 | 2012-02-15 00:54:55 +0000 | [diff] [blame] | 605 | return C; |
| 606 | } |
| 607 | |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 608 | std::pair<const VarDecl *, SourceLocation> |
Douglas Gregor | 011d8b9 | 2012-02-15 00:54:55 +0000 | [diff] [blame] | 609 | cxcursor::getCursorVariableRef(CXCursor C) { |
| 610 | assert(C.kind == CXCursor_VariableRef); |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 611 | return std::make_pair(static_cast<const VarDecl *>(C.data[0]), |
Douglas Gregor | 011d8b9 | 2012-02-15 00:54:55 +0000 | [diff] [blame] | 612 | SourceLocation::getFromRawEncoding( |
| 613 | reinterpret_cast<uintptr_t>(C.data[1]))); |
| 614 | } |
| 615 | |
Argyrios Kyrtzidis | b395c63 | 2011-11-18 00:26:51 +0000 | [diff] [blame] | 616 | CXCursor cxcursor::MakeCursorMemberRef(const FieldDecl *Field, SourceLocation Loc, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 617 | CXTranslationUnit TU) { |
Douglas Gregor | a67e03f | 2010-09-09 21:42:20 +0000 | [diff] [blame] | 618 | |
| 619 | assert(Field && TU && "Invalid arguments!"); |
| 620 | void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); |
Dmitri Gribenko | 3315618 | 2013-01-11 21:06:06 +0000 | [diff] [blame] | 621 | CXCursor C = { CXCursor_MemberRef, 0, { Field, RawLoc, TU } }; |
Douglas Gregor | a67e03f | 2010-09-09 21:42:20 +0000 | [diff] [blame] | 622 | return C; |
| 623 | } |
| 624 | |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 625 | std::pair<const FieldDecl *, SourceLocation> |
Douglas Gregor | a67e03f | 2010-09-09 21:42:20 +0000 | [diff] [blame] | 626 | cxcursor::getCursorMemberRef(CXCursor C) { |
| 627 | assert(C.kind == CXCursor_MemberRef); |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 628 | return std::make_pair(static_cast<const FieldDecl *>(C.data[0]), |
Douglas Gregor | a67e03f | 2010-09-09 21:42:20 +0000 | [diff] [blame] | 629 | SourceLocation::getFromRawEncoding( |
| 630 | reinterpret_cast<uintptr_t>(C.data[1]))); |
| 631 | } |
| 632 | |
Argyrios Kyrtzidis | 2957e6f | 2011-11-22 07:24:51 +0000 | [diff] [blame] | 633 | CXCursor cxcursor::MakeCursorCXXBaseSpecifier(const CXXBaseSpecifier *B, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 634 | CXTranslationUnit TU){ |
Dmitri Gribenko | 3315618 | 2013-01-11 21:06:06 +0000 | [diff] [blame] | 635 | CXCursor C = { CXCursor_CXXBaseSpecifier, 0, { B, 0, TU } }; |
Ted Kremenek | 3064ef9 | 2010-08-27 21:34:58 +0000 | [diff] [blame] | 636 | return C; |
| 637 | } |
| 638 | |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 639 | const CXXBaseSpecifier *cxcursor::getCursorCXXBaseSpecifier(CXCursor C) { |
Ted Kremenek | 3064ef9 | 2010-08-27 21:34:58 +0000 | [diff] [blame] | 640 | assert(C.kind == CXCursor_CXXBaseSpecifier); |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 641 | return static_cast<const CXXBaseSpecifier*>(C.data[0]); |
Ted Kremenek | 3064ef9 | 2010-08-27 21:34:58 +0000 | [diff] [blame] | 642 | } |
| 643 | |
Douglas Gregor | 9f1e3ff | 2010-03-18 00:42:48 +0000 | [diff] [blame] | 644 | CXCursor cxcursor::MakePreprocessingDirectiveCursor(SourceRange Range, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 645 | CXTranslationUnit TU) { |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 646 | CXCursor C = { CXCursor_PreprocessingDirective, 0, |
Douglas Gregor | 9f1e3ff | 2010-03-18 00:42:48 +0000 | [diff] [blame] | 647 | { reinterpret_cast<void *>(Range.getBegin().getRawEncoding()), |
| 648 | reinterpret_cast<void *>(Range.getEnd().getRawEncoding()), |
| 649 | TU } |
| 650 | }; |
| 651 | return C; |
| 652 | } |
| 653 | |
| 654 | SourceRange cxcursor::getCursorPreprocessingDirective(CXCursor C) { |
| 655 | assert(C.kind == CXCursor_PreprocessingDirective); |
Argyrios Kyrtzidis | ee0f84f | 2011-09-26 08:01:41 +0000 | [diff] [blame] | 656 | SourceRange Range = SourceRange(SourceLocation::getFromRawEncoding( |
Douglas Gregor | 9f1e3ff | 2010-03-18 00:42:48 +0000 | [diff] [blame] | 657 | reinterpret_cast<uintptr_t> (C.data[0])), |
| 658 | SourceLocation::getFromRawEncoding( |
| 659 | reinterpret_cast<uintptr_t> (C.data[1]))); |
Argyrios Kyrtzidis | ee0f84f | 2011-09-26 08:01:41 +0000 | [diff] [blame] | 660 | ASTUnit *TU = getCursorASTUnit(C); |
| 661 | return TU->mapRangeFromPreamble(Range); |
Douglas Gregor | 9f1e3ff | 2010-03-18 00:42:48 +0000 | [diff] [blame] | 662 | } |
| 663 | |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 664 | CXCursor cxcursor::MakeMacroDefinitionCursor(const MacroDefinition *MI, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 665 | CXTranslationUnit TU) { |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 666 | CXCursor C = { CXCursor_MacroDefinition, 0, { MI, 0, TU } }; |
Douglas Gregor | 572feb2 | 2010-03-18 18:04:21 +0000 | [diff] [blame] | 667 | return C; |
| 668 | } |
| 669 | |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 670 | const MacroDefinition *cxcursor::getCursorMacroDefinition(CXCursor C) { |
Douglas Gregor | 572feb2 | 2010-03-18 18:04:21 +0000 | [diff] [blame] | 671 | assert(C.kind == CXCursor_MacroDefinition); |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 672 | return static_cast<const MacroDefinition *>(C.data[0]); |
Douglas Gregor | 572feb2 | 2010-03-18 18:04:21 +0000 | [diff] [blame] | 673 | } |
| 674 | |
Chandler Carruth | 9e5bb85 | 2011-07-14 08:20:46 +0000 | [diff] [blame] | 675 | CXCursor cxcursor::MakeMacroExpansionCursor(MacroExpansion *MI, |
| 676 | CXTranslationUnit TU) { |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 677 | CXCursor C = { CXCursor_MacroExpansion, 0, { MI, 0, TU } }; |
Douglas Gregor | 4807231 | 2010-03-18 15:23:44 +0000 | [diff] [blame] | 678 | return C; |
| 679 | } |
| 680 | |
Argyrios Kyrtzidis | 664b06f | 2013-01-07 19:16:25 +0000 | [diff] [blame] | 681 | CXCursor cxcursor::MakeMacroExpansionCursor(MacroDefinition *MI, |
| 682 | SourceLocation Loc, |
| 683 | CXTranslationUnit TU) { |
| 684 | assert(Loc.isValid()); |
| 685 | CXCursor C = { CXCursor_MacroExpansion, 0, { MI, Loc.getPtrEncoding(), TU } }; |
| 686 | return C; |
| 687 | } |
| 688 | |
| 689 | const IdentifierInfo *cxcursor::MacroExpansionCursor::getName() const { |
| 690 | if (isPseudo()) |
| 691 | return getAsMacroDefinition()->getName(); |
| 692 | return getAsMacroExpansion()->getName(); |
| 693 | } |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 694 | const MacroDefinition *cxcursor::MacroExpansionCursor::getDefinition() const { |
Argyrios Kyrtzidis | 664b06f | 2013-01-07 19:16:25 +0000 | [diff] [blame] | 695 | if (isPseudo()) |
| 696 | return getAsMacroDefinition(); |
| 697 | return getAsMacroExpansion()->getDefinition(); |
| 698 | } |
| 699 | SourceRange cxcursor::MacroExpansionCursor::getSourceRange() const { |
| 700 | if (isPseudo()) |
| 701 | return getPseudoLoc(); |
| 702 | return getAsMacroExpansion()->getSourceRange(); |
Douglas Gregor | 4807231 | 2010-03-18 15:23:44 +0000 | [diff] [blame] | 703 | } |
| 704 | |
Douglas Gregor | ecdcb88 | 2010-10-20 22:00:55 +0000 | [diff] [blame] | 705 | CXCursor cxcursor::MakeInclusionDirectiveCursor(InclusionDirective *ID, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 706 | CXTranslationUnit TU) { |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 707 | CXCursor C = { CXCursor_InclusionDirective, 0, { ID, 0, TU } }; |
Douglas Gregor | ecdcb88 | 2010-10-20 22:00:55 +0000 | [diff] [blame] | 708 | return C; |
| 709 | } |
| 710 | |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 711 | const InclusionDirective *cxcursor::getCursorInclusionDirective(CXCursor C) { |
Douglas Gregor | ecdcb88 | 2010-10-20 22:00:55 +0000 | [diff] [blame] | 712 | assert(C.kind == CXCursor_InclusionDirective); |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 713 | return static_cast<const InclusionDirective *>(C.data[0]); |
Douglas Gregor | ecdcb88 | 2010-10-20 22:00:55 +0000 | [diff] [blame] | 714 | } |
| 715 | |
Douglas Gregor | 36897b0 | 2010-09-10 00:22:18 +0000 | [diff] [blame] | 716 | CXCursor cxcursor::MakeCursorLabelRef(LabelStmt *Label, SourceLocation Loc, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 717 | CXTranslationUnit TU) { |
Douglas Gregor | 36897b0 | 2010-09-10 00:22:18 +0000 | [diff] [blame] | 718 | |
| 719 | assert(Label && TU && "Invalid arguments!"); |
| 720 | void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 721 | CXCursor C = { CXCursor_LabelRef, 0, { Label, RawLoc, TU } }; |
Douglas Gregor | 36897b0 | 2010-09-10 00:22:18 +0000 | [diff] [blame] | 722 | return C; |
| 723 | } |
| 724 | |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 725 | std::pair<const LabelStmt *, SourceLocation> |
Douglas Gregor | 36897b0 | 2010-09-10 00:22:18 +0000 | [diff] [blame] | 726 | cxcursor::getCursorLabelRef(CXCursor C) { |
| 727 | assert(C.kind == CXCursor_LabelRef); |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 728 | return std::make_pair(static_cast<const LabelStmt *>(C.data[0]), |
Douglas Gregor | 36897b0 | 2010-09-10 00:22:18 +0000 | [diff] [blame] | 729 | SourceLocation::getFromRawEncoding( |
| 730 | reinterpret_cast<uintptr_t>(C.data[1]))); |
| 731 | } |
| 732 | |
Dmitri Gribenko | e22339c | 2013-01-23 17:25:27 +0000 | [diff] [blame] | 733 | CXCursor cxcursor::MakeCursorOverloadedDeclRef(const OverloadExpr *E, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 734 | CXTranslationUnit TU) { |
Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 735 | assert(E && TU && "Invalid arguments!"); |
| 736 | OverloadedDeclRefStorage Storage(E); |
| 737 | void *RawLoc = reinterpret_cast<void *>(E->getNameLoc().getRawEncoding()); |
| 738 | CXCursor C = { |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 739 | CXCursor_OverloadedDeclRef, 0, |
Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 740 | { Storage.getOpaqueValue(), RawLoc, TU } |
| 741 | }; |
| 742 | return C; |
| 743 | } |
| 744 | |
Dmitri Gribenko | e22339c | 2013-01-23 17:25:27 +0000 | [diff] [blame] | 745 | CXCursor cxcursor::MakeCursorOverloadedDeclRef(const Decl *D, |
Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 746 | SourceLocation Loc, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 747 | CXTranslationUnit TU) { |
Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 748 | assert(D && TU && "Invalid arguments!"); |
| 749 | void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); |
| 750 | OverloadedDeclRefStorage Storage(D); |
| 751 | CXCursor C = { |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 752 | CXCursor_OverloadedDeclRef, 0, |
Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 753 | { Storage.getOpaqueValue(), RawLoc, TU } |
| 754 | }; |
| 755 | return C; |
| 756 | } |
| 757 | |
| 758 | CXCursor cxcursor::MakeCursorOverloadedDeclRef(TemplateName Name, |
| 759 | SourceLocation Loc, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 760 | CXTranslationUnit TU) { |
Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 761 | assert(Name.getAsOverloadedTemplate() && TU && "Invalid arguments!"); |
| 762 | void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); |
| 763 | OverloadedDeclRefStorage Storage(Name.getAsOverloadedTemplate()); |
| 764 | CXCursor C = { |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 765 | CXCursor_OverloadedDeclRef, 0, |
Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 766 | { Storage.getOpaqueValue(), RawLoc, TU } |
| 767 | }; |
| 768 | return C; |
| 769 | } |
| 770 | |
| 771 | std::pair<cxcursor::OverloadedDeclRefStorage, SourceLocation> |
| 772 | cxcursor::getCursorOverloadedDeclRef(CXCursor C) { |
| 773 | assert(C.kind == CXCursor_OverloadedDeclRef); |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 774 | return std::make_pair(OverloadedDeclRefStorage::getFromOpaqueValue( |
| 775 | const_cast<void *>(C.data[0])), |
Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 776 | SourceLocation::getFromRawEncoding( |
| 777 | reinterpret_cast<uintptr_t>(C.data[1]))); |
| 778 | } |
| 779 | |
Dmitri Gribenko | e22339c | 2013-01-23 17:25:27 +0000 | [diff] [blame] | 780 | const Decl *cxcursor::getCursorDecl(CXCursor Cursor) { |
| 781 | return static_cast<const Decl *>(Cursor.data[0]); |
Douglas Gregor | 283cae3 | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 782 | } |
| 783 | |
Dmitri Gribenko | ff74f96 | 2013-01-26 15:29:08 +0000 | [diff] [blame] | 784 | const Expr *cxcursor::getCursorExpr(CXCursor Cursor) { |
Douglas Gregor | 283cae3 | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 785 | return dyn_cast_or_null<Expr>(getCursorStmt(Cursor)); |
| 786 | } |
| 787 | |
Dmitri Gribenko | ff74f96 | 2013-01-26 15:29:08 +0000 | [diff] [blame] | 788 | const Stmt *cxcursor::getCursorStmt(CXCursor Cursor) { |
Douglas Gregor | 78db0cd | 2010-01-16 15:44:18 +0000 | [diff] [blame] | 789 | if (Cursor.kind == CXCursor_ObjCSuperClassRef || |
Douglas Gregor | 1adb082 | 2010-01-16 17:14:40 +0000 | [diff] [blame] | 790 | Cursor.kind == CXCursor_ObjCProtocolRef || |
| 791 | Cursor.kind == CXCursor_ObjCClassRef) |
Douglas Gregor | 2e331b9 | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 792 | return 0; |
| 793 | |
Dmitri Gribenko | ff74f96 | 2013-01-26 15:29:08 +0000 | [diff] [blame] | 794 | return static_cast<const Stmt *>(Cursor.data[1]); |
Douglas Gregor | 283cae3 | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 795 | } |
| 796 | |
Dmitri Gribenko | 7d91438 | 2013-01-26 18:08:08 +0000 | [diff] [blame^] | 797 | const Attr *cxcursor::getCursorAttr(CXCursor Cursor) { |
| 798 | return static_cast<const Attr *>(Cursor.data[1]); |
Ted Kremenek | 95f3355 | 2010-08-26 01:42:22 +0000 | [diff] [blame] | 799 | } |
| 800 | |
Argyrios Kyrtzidis | 8ccac3d | 2011-06-29 22:20:07 +0000 | [diff] [blame] | 801 | Decl *cxcursor::getCursorParentDecl(CXCursor Cursor) { |
Bill Wendling | 6965266 | 2013-01-23 08:58:23 +0000 | [diff] [blame] | 802 | return static_cast<Decl*>(const_cast<void*>(Cursor.data[0])); |
Argyrios Kyrtzidis | 8ccac3d | 2011-06-29 22:20:07 +0000 | [diff] [blame] | 803 | } |
| 804 | |
Douglas Gregor | f46034a | 2010-01-18 23:41:10 +0000 | [diff] [blame] | 805 | ASTContext &cxcursor::getCursorContext(CXCursor Cursor) { |
Douglas Gregor | b2cd487 | 2010-01-20 23:57:43 +0000 | [diff] [blame] | 806 | return getCursorASTUnit(Cursor)->getASTContext(); |
| 807 | } |
Douglas Gregor | f46034a | 2010-01-18 23:41:10 +0000 | [diff] [blame] | 808 | |
Douglas Gregor | b2cd487 | 2010-01-20 23:57:43 +0000 | [diff] [blame] | 809 | ASTUnit *cxcursor::getCursorASTUnit(CXCursor Cursor) { |
Dmitri Gribenko | 46f9252 | 2013-01-11 19:28:44 +0000 | [diff] [blame] | 810 | CXTranslationUnit TU = getCursorTU(Cursor); |
Argyrios Kyrtzidis | 4451746 | 2011-12-09 00:17:49 +0000 | [diff] [blame] | 811 | if (!TU) |
| 812 | return 0; |
| 813 | return static_cast<ASTUnit *>(TU->TUData); |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 814 | } |
| 815 | |
| 816 | CXTranslationUnit cxcursor::getCursorTU(CXCursor Cursor) { |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 817 | return static_cast<CXTranslationUnit>(const_cast<void*>(Cursor.data[2])); |
Douglas Gregor | 283cae3 | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 818 | } |
| 819 | |
Argyrios Kyrtzidis | e15db6f | 2012-05-09 16:12:57 +0000 | [diff] [blame] | 820 | void cxcursor::getOverriddenCursors(CXCursor cursor, |
| 821 | SmallVectorImpl<CXCursor> &overridden) { |
| 822 | assert(clang_isDeclaration(cursor.kind)); |
Argyrios Kyrtzidis | 21c3607 | 2012-10-09 01:23:50 +0000 | [diff] [blame] | 823 | const NamedDecl *D = dyn_cast_or_null<NamedDecl>(getCursorDecl(cursor)); |
Argyrios Kyrtzidis | e15db6f | 2012-05-09 16:12:57 +0000 | [diff] [blame] | 824 | if (!D) |
| 825 | return; |
| 826 | |
Argyrios Kyrtzidis | e15db6f | 2012-05-09 16:12:57 +0000 | [diff] [blame] | 827 | CXTranslationUnit TU = getCursorTU(cursor); |
Argyrios Kyrtzidis | 21c3607 | 2012-10-09 01:23:50 +0000 | [diff] [blame] | 828 | SmallVector<const NamedDecl *, 8> OverDecls; |
| 829 | D->getASTContext().getOverriddenMethods(D, OverDecls); |
Argyrios Kyrtzidis | e15db6f | 2012-05-09 16:12:57 +0000 | [diff] [blame] | 830 | |
Argyrios Kyrtzidis | 21c3607 | 2012-10-09 01:23:50 +0000 | [diff] [blame] | 831 | for (SmallVector<const NamedDecl *, 8>::iterator |
| 832 | I = OverDecls.begin(), E = OverDecls.end(); I != E; ++I) { |
Dmitri Gribenko | 05756dc | 2013-01-14 00:46:27 +0000 | [diff] [blame] | 833 | overridden.push_back(MakeCXCursor(*I, TU)); |
Argyrios Kyrtzidis | e15db6f | 2012-05-09 16:12:57 +0000 | [diff] [blame] | 834 | } |
| 835 | } |
| 836 | |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 837 | std::pair<int, SourceLocation> |
| 838 | cxcursor::getSelectorIdentifierIndexAndLoc(CXCursor cursor) { |
| 839 | if (cursor.kind == CXCursor_ObjCMessageExpr) { |
| 840 | if (cursor.xdata != -1) |
| 841 | return std::make_pair(cursor.xdata, |
| 842 | cast<ObjCMessageExpr>(getCursorExpr(cursor)) |
| 843 | ->getSelectorLoc(cursor.xdata)); |
| 844 | } else if (cursor.kind == CXCursor_ObjCClassMethodDecl || |
| 845 | cursor.kind == CXCursor_ObjCInstanceMethodDecl) { |
| 846 | if (cursor.xdata != -1) |
| 847 | return std::make_pair(cursor.xdata, |
| 848 | cast<ObjCMethodDecl>(getCursorDecl(cursor)) |
| 849 | ->getSelectorLoc(cursor.xdata)); |
| 850 | } |
| 851 | |
| 852 | return std::make_pair(-1, SourceLocation()); |
| 853 | } |
| 854 | |
| 855 | CXCursor cxcursor::getSelectorIdentifierCursor(int SelIdx, CXCursor cursor) { |
| 856 | CXCursor newCursor = cursor; |
| 857 | |
| 858 | if (cursor.kind == CXCursor_ObjCMessageExpr) { |
| 859 | if (SelIdx == -1 || |
| 860 | unsigned(SelIdx) >= cast<ObjCMessageExpr>(getCursorExpr(cursor)) |
| 861 | ->getNumSelectorLocs()) |
| 862 | newCursor.xdata = -1; |
| 863 | else |
| 864 | newCursor.xdata = SelIdx; |
| 865 | } else if (cursor.kind == CXCursor_ObjCClassMethodDecl || |
| 866 | cursor.kind == CXCursor_ObjCInstanceMethodDecl) { |
| 867 | if (SelIdx == -1 || |
| 868 | unsigned(SelIdx) >= cast<ObjCMethodDecl>(getCursorDecl(cursor)) |
| 869 | ->getNumSelectorLocs()) |
| 870 | newCursor.xdata = -1; |
| 871 | else |
| 872 | newCursor.xdata = SelIdx; |
| 873 | } |
| 874 | |
| 875 | return newCursor; |
| 876 | } |
| 877 | |
| 878 | CXCursor cxcursor::getTypeRefCursor(CXCursor cursor) { |
| 879 | if (cursor.kind != CXCursor_CallExpr) |
| 880 | return cursor; |
| 881 | |
| 882 | if (cursor.xdata == 0) |
| 883 | return cursor; |
| 884 | |
Dmitri Gribenko | ff74f96 | 2013-01-26 15:29:08 +0000 | [diff] [blame] | 885 | const Expr *E = getCursorExpr(cursor); |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 886 | TypeSourceInfo *Type = 0; |
Dmitri Gribenko | ff74f96 | 2013-01-26 15:29:08 +0000 | [diff] [blame] | 887 | if (const CXXUnresolvedConstructExpr * |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 888 | UnCtor = dyn_cast<CXXUnresolvedConstructExpr>(E)) { |
| 889 | Type = UnCtor->getTypeSourceInfo(); |
Dmitri Gribenko | ff74f96 | 2013-01-26 15:29:08 +0000 | [diff] [blame] | 890 | } else if (const CXXTemporaryObjectExpr *Tmp = |
| 891 | dyn_cast<CXXTemporaryObjectExpr>(E)){ |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 892 | Type = Tmp->getTypeSourceInfo(); |
| 893 | } |
| 894 | |
| 895 | if (!Type) |
| 896 | return cursor; |
| 897 | |
| 898 | CXTranslationUnit TU = getCursorTU(cursor); |
| 899 | QualType Ty = Type->getType(); |
| 900 | TypeLoc TL = Type->getTypeLoc(); |
| 901 | SourceLocation Loc = TL.getBeginLoc(); |
| 902 | |
| 903 | if (const ElaboratedType *ElabT = Ty->getAs<ElaboratedType>()) { |
| 904 | Ty = ElabT->getNamedType(); |
| 905 | ElaboratedTypeLoc ElabTL = cast<ElaboratedTypeLoc>(TL); |
| 906 | Loc = ElabTL.getNamedTypeLoc().getBeginLoc(); |
| 907 | } |
| 908 | |
| 909 | if (const TypedefType *Typedef = Ty->getAs<TypedefType>()) |
| 910 | return MakeCursorTypeRef(Typedef->getDecl(), Loc, TU); |
| 911 | if (const TagType *Tag = Ty->getAs<TagType>()) |
| 912 | return MakeCursorTypeRef(Tag->getDecl(), Loc, TU); |
| 913 | if (const TemplateTypeParmType *TemplP = Ty->getAs<TemplateTypeParmType>()) |
| 914 | return MakeCursorTypeRef(TemplP->getDecl(), Loc, TU); |
| 915 | |
| 916 | return cursor; |
| 917 | } |
| 918 | |
Douglas Gregor | 283cae3 | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 919 | bool cxcursor::operator==(CXCursor X, CXCursor Y) { |
| 920 | return X.kind == Y.kind && X.data[0] == Y.data[0] && X.data[1] == Y.data[1] && |
| 921 | X.data[2] == Y.data[2]; |
Douglas Gregor | 2e331b9 | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 922 | } |
Ted Kremenek | 007a7c9 | 2010-11-01 23:26:51 +0000 | [diff] [blame] | 923 | |
| 924 | // FIXME: Remove once we can model DeclGroups and their appropriate ranges |
| 925 | // properly in the ASTs. |
| 926 | bool cxcursor::isFirstInDeclGroup(CXCursor C) { |
| 927 | assert(clang_isDeclaration(C.kind)); |
| 928 | return ((uintptr_t) (C.data[1])) != 0; |
| 929 | } |
| 930 | |
Ted Kremenek | eca099b | 2010-12-08 23:43:14 +0000 | [diff] [blame] | 931 | //===----------------------------------------------------------------------===// |
Argyrios Kyrtzidis | b0d6eaa | 2011-09-27 00:30:30 +0000 | [diff] [blame] | 932 | // libclang CXCursor APIs |
| 933 | //===----------------------------------------------------------------------===// |
| 934 | |
Argyrios Kyrtzidis | fa865df | 2011-09-27 04:14:36 +0000 | [diff] [blame] | 935 | extern "C" { |
| 936 | |
| 937 | int clang_Cursor_isNull(CXCursor cursor) { |
| 938 | return clang_equalCursors(cursor, clang_getNullCursor()); |
| 939 | } |
| 940 | |
Argyrios Kyrtzidis | b0d6eaa | 2011-09-27 00:30:30 +0000 | [diff] [blame] | 941 | CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor cursor) { |
| 942 | return getCursorTU(cursor); |
| 943 | } |
| 944 | |
Argyrios Kyrtzidis | d98ef9a | 2012-04-11 19:32:19 +0000 | [diff] [blame] | 945 | int clang_Cursor_getNumArguments(CXCursor C) { |
| 946 | if (clang_isDeclaration(C.kind)) { |
Dmitri Gribenko | e22339c | 2013-01-23 17:25:27 +0000 | [diff] [blame] | 947 | const Decl *D = cxcursor::getCursorDecl(C); |
Argyrios Kyrtzidis | d98ef9a | 2012-04-11 19:32:19 +0000 | [diff] [blame] | 948 | if (const ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(D)) |
| 949 | return MD->param_size(); |
| 950 | if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D)) |
| 951 | return FD->param_size(); |
| 952 | } |
| 953 | |
| 954 | return -1; |
| 955 | } |
| 956 | |
| 957 | CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i) { |
| 958 | if (clang_isDeclaration(C.kind)) { |
Dmitri Gribenko | e22339c | 2013-01-23 17:25:27 +0000 | [diff] [blame] | 959 | const Decl *D = cxcursor::getCursorDecl(C); |
| 960 | if (const ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(D)) { |
Argyrios Kyrtzidis | d98ef9a | 2012-04-11 19:32:19 +0000 | [diff] [blame] | 961 | if (i < MD->param_size()) |
| 962 | return cxcursor::MakeCXCursor(MD->param_begin()[i], |
| 963 | cxcursor::getCursorTU(C)); |
Dmitri Gribenko | e22339c | 2013-01-23 17:25:27 +0000 | [diff] [blame] | 964 | } else if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D)) { |
Argyrios Kyrtzidis | d98ef9a | 2012-04-11 19:32:19 +0000 | [diff] [blame] | 965 | if (i < FD->param_size()) |
| 966 | return cxcursor::MakeCXCursor(FD->param_begin()[i], |
| 967 | cxcursor::getCursorTU(C)); |
| 968 | } |
| 969 | } |
| 970 | |
| 971 | return clang_getNullCursor(); |
| 972 | } |
| 973 | |
Argyrios Kyrtzidis | fa865df | 2011-09-27 04:14:36 +0000 | [diff] [blame] | 974 | } // end: extern "C" |
| 975 | |
Argyrios Kyrtzidis | b0d6eaa | 2011-09-27 00:30:30 +0000 | [diff] [blame] | 976 | //===----------------------------------------------------------------------===// |
Ted Kremenek | eca099b | 2010-12-08 23:43:14 +0000 | [diff] [blame] | 977 | // CXCursorSet. |
| 978 | //===----------------------------------------------------------------------===// |
| 979 | |
| 980 | typedef llvm::DenseMap<CXCursor, unsigned> CXCursorSet_Impl; |
| 981 | |
| 982 | static inline CXCursorSet packCXCursorSet(CXCursorSet_Impl *setImpl) { |
| 983 | return (CXCursorSet) setImpl; |
| 984 | } |
| 985 | static inline CXCursorSet_Impl *unpackCXCursorSet(CXCursorSet set) { |
| 986 | return (CXCursorSet_Impl*) set; |
| 987 | } |
| 988 | namespace llvm { |
Ted Kremenek | da6fb69 | 2010-12-09 00:33:41 +0000 | [diff] [blame] | 989 | template<> struct DenseMapInfo<CXCursor> { |
Ted Kremenek | eca099b | 2010-12-08 23:43:14 +0000 | [diff] [blame] | 990 | public: |
| 991 | static inline CXCursor getEmptyKey() { |
| 992 | return MakeCXCursorInvalid(CXCursor_InvalidFile); |
| 993 | } |
| 994 | static inline CXCursor getTombstoneKey() { |
| 995 | return MakeCXCursorInvalid(CXCursor_NoDeclFound); |
| 996 | } |
| 997 | static inline unsigned getHashValue(const CXCursor &cursor) { |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 998 | return llvm::DenseMapInfo<std::pair<const void *, const void *> > |
Ted Kremenek | eca099b | 2010-12-08 23:43:14 +0000 | [diff] [blame] | 999 | ::getHashValue(std::make_pair(cursor.data[0], cursor.data[1])); |
| 1000 | } |
| 1001 | static inline bool isEqual(const CXCursor &x, const CXCursor &y) { |
| 1002 | return x.kind == y.kind && |
| 1003 | x.data[0] == y.data[0] && |
| 1004 | x.data[1] == y.data[1]; |
| 1005 | } |
| 1006 | }; |
| 1007 | } |
| 1008 | |
| 1009 | extern "C" { |
| 1010 | CXCursorSet clang_createCXCursorSet() { |
| 1011 | return packCXCursorSet(new CXCursorSet_Impl()); |
| 1012 | } |
| 1013 | |
| 1014 | void clang_disposeCXCursorSet(CXCursorSet set) { |
| 1015 | delete unpackCXCursorSet(set); |
| 1016 | } |
| 1017 | |
| 1018 | unsigned clang_CXCursorSet_contains(CXCursorSet set, CXCursor cursor) { |
| 1019 | CXCursorSet_Impl *setImpl = unpackCXCursorSet(set); |
| 1020 | if (!setImpl) |
| 1021 | return 0; |
| 1022 | return setImpl->find(cursor) == setImpl->end(); |
| 1023 | } |
| 1024 | |
Anders Carlsson | e8b3de0 | 2010-12-09 01:00:12 +0000 | [diff] [blame] | 1025 | unsigned clang_CXCursorSet_insert(CXCursorSet set, CXCursor cursor) { |
Ted Kremenek | eca099b | 2010-12-08 23:43:14 +0000 | [diff] [blame] | 1026 | // Do not insert invalid cursors into the set. |
| 1027 | if (cursor.kind >= CXCursor_FirstInvalid && |
| 1028 | cursor.kind <= CXCursor_LastInvalid) |
| 1029 | return 1; |
| 1030 | |
| 1031 | CXCursorSet_Impl *setImpl = unpackCXCursorSet(set); |
| 1032 | if (!setImpl) |
| 1033 | return 1; |
| 1034 | unsigned &entry = (*setImpl)[cursor]; |
| 1035 | unsigned flag = entry == 0 ? 1 : 0; |
| 1036 | entry = 1; |
| 1037 | return flag; |
| 1038 | } |
Douglas Gregor | 8fa0a80 | 2011-08-04 20:04:59 +0000 | [diff] [blame] | 1039 | |
| 1040 | CXCompletionString clang_getCursorCompletionString(CXCursor cursor) { |
| 1041 | enum CXCursorKind kind = clang_getCursorKind(cursor); |
| 1042 | if (clang_isDeclaration(kind)) { |
Dmitri Gribenko | e22339c | 2013-01-23 17:25:27 +0000 | [diff] [blame] | 1043 | const Decl *decl = getCursorDecl(cursor); |
| 1044 | if (const NamedDecl *namedDecl = dyn_cast_or_null<NamedDecl>(decl)) { |
Douglas Gregor | 8fa0a80 | 2011-08-04 20:04:59 +0000 | [diff] [blame] | 1045 | ASTUnit *unit = getCursorASTUnit(cursor); |
Argyrios Kyrtzidis | 5e192a7 | 2012-01-17 02:15:54 +0000 | [diff] [blame] | 1046 | CodeCompletionResult Result(namedDecl); |
| 1047 | CodeCompletionString *String |
| 1048 | = Result.CreateCodeCompletionString(unit->getASTContext(), |
| 1049 | unit->getPreprocessor(), |
Argyrios Kyrtzidis | 28a83f5 | 2012-04-10 17:23:48 +0000 | [diff] [blame] | 1050 | unit->getCodeCompletionTUInfo().getAllocator(), |
Dmitri Gribenko | d99ef53 | 2012-07-02 17:35:10 +0000 | [diff] [blame] | 1051 | unit->getCodeCompletionTUInfo(), |
| 1052 | true); |
Argyrios Kyrtzidis | 5e192a7 | 2012-01-17 02:15:54 +0000 | [diff] [blame] | 1053 | return String; |
Douglas Gregor | 8fa0a80 | 2011-08-04 20:04:59 +0000 | [diff] [blame] | 1054 | } |
| 1055 | } |
| 1056 | else if (kind == CXCursor_MacroDefinition) { |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 1057 | const MacroDefinition *definition = getCursorMacroDefinition(cursor); |
Douglas Gregor | 8fa0a80 | 2011-08-04 20:04:59 +0000 | [diff] [blame] | 1058 | const IdentifierInfo *MacroInfo = definition->getName(); |
| 1059 | ASTUnit *unit = getCursorASTUnit(cursor); |
Dmitri Gribenko | b395847 | 2013-01-14 00:36:42 +0000 | [diff] [blame] | 1060 | CodeCompletionResult Result(MacroInfo); |
Argyrios Kyrtzidis | 5e192a7 | 2012-01-17 02:15:54 +0000 | [diff] [blame] | 1061 | CodeCompletionString *String |
| 1062 | = Result.CreateCodeCompletionString(unit->getASTContext(), |
| 1063 | unit->getPreprocessor(), |
Argyrios Kyrtzidis | 28a83f5 | 2012-04-10 17:23:48 +0000 | [diff] [blame] | 1064 | unit->getCodeCompletionTUInfo().getAllocator(), |
Dmitri Gribenko | d99ef53 | 2012-07-02 17:35:10 +0000 | [diff] [blame] | 1065 | unit->getCodeCompletionTUInfo(), |
| 1066 | false); |
Argyrios Kyrtzidis | 5e192a7 | 2012-01-17 02:15:54 +0000 | [diff] [blame] | 1067 | return String; |
Douglas Gregor | 8fa0a80 | 2011-08-04 20:04:59 +0000 | [diff] [blame] | 1068 | } |
| 1069 | return NULL; |
| 1070 | } |
Ted Kremenek | 8eece46 | 2012-04-30 19:33:45 +0000 | [diff] [blame] | 1071 | } // end: extern C. |
Ted Kremenek | bbf66ca | 2012-04-30 19:06:49 +0000 | [diff] [blame] | 1072 | |
| 1073 | namespace { |
| 1074 | struct OverridenCursorsPool { |
Dmitri Gribenko | cfa88f8 | 2013-01-12 19:30:44 +0000 | [diff] [blame] | 1075 | typedef SmallVector<CXCursor, 2> CursorVec; |
Ted Kremenek | bbf66ca | 2012-04-30 19:06:49 +0000 | [diff] [blame] | 1076 | std::vector<CursorVec*> AllCursors; |
| 1077 | std::vector<CursorVec*> AvailableCursors; |
| 1078 | |
| 1079 | ~OverridenCursorsPool() { |
| 1080 | for (std::vector<CursorVec*>::iterator I = AllCursors.begin(), |
| 1081 | E = AllCursors.end(); I != E; ++I) { |
| 1082 | delete *I; |
| 1083 | } |
| 1084 | } |
| 1085 | }; |
| 1086 | } |
| 1087 | |
| 1088 | void *cxcursor::createOverridenCXCursorsPool() { |
| 1089 | return new OverridenCursorsPool(); |
| 1090 | } |
| 1091 | |
| 1092 | void cxcursor::disposeOverridenCXCursorsPool(void *pool) { |
| 1093 | delete static_cast<OverridenCursorsPool*>(pool); |
| 1094 | } |
Ted Kremenek | 8eece46 | 2012-04-30 19:33:45 +0000 | [diff] [blame] | 1095 | |
| 1096 | extern "C" { |
Ted Kremenek | bbf66ca | 2012-04-30 19:06:49 +0000 | [diff] [blame] | 1097 | void clang_getOverriddenCursors(CXCursor cursor, |
| 1098 | CXCursor **overridden, |
| 1099 | unsigned *num_overridden) { |
| 1100 | if (overridden) |
| 1101 | *overridden = 0; |
| 1102 | if (num_overridden) |
| 1103 | *num_overridden = 0; |
| 1104 | |
| 1105 | CXTranslationUnit TU = cxcursor::getCursorTU(cursor); |
| 1106 | |
| 1107 | if (!overridden || !num_overridden || !TU) |
| 1108 | return; |
| 1109 | |
| 1110 | if (!clang_isDeclaration(cursor.kind)) |
| 1111 | return; |
| 1112 | |
| 1113 | OverridenCursorsPool &pool = |
| 1114 | *static_cast<OverridenCursorsPool*>(TU->OverridenCursorsPool); |
| 1115 | |
| 1116 | OverridenCursorsPool::CursorVec *Vec = 0; |
| 1117 | |
| 1118 | if (!pool.AvailableCursors.empty()) { |
| 1119 | Vec = pool.AvailableCursors.back(); |
| 1120 | pool.AvailableCursors.pop_back(); |
| 1121 | } |
| 1122 | else { |
| 1123 | Vec = new OverridenCursorsPool::CursorVec(); |
| 1124 | pool.AllCursors.push_back(Vec); |
| 1125 | } |
| 1126 | |
| 1127 | // Clear out the vector, but don't free the memory contents. This |
| 1128 | // reduces malloc() traffic. |
| 1129 | Vec->clear(); |
| 1130 | |
| 1131 | // Use the first entry to contain a back reference to the vector. |
| 1132 | // This is a complete hack. |
| 1133 | CXCursor backRefCursor = MakeCXCursorInvalid(CXCursor_InvalidFile, TU); |
| 1134 | backRefCursor.data[0] = Vec; |
| 1135 | assert(cxcursor::getCursorTU(backRefCursor) == TU); |
| 1136 | Vec->push_back(backRefCursor); |
| 1137 | |
| 1138 | // Get the overriden cursors. |
| 1139 | cxcursor::getOverriddenCursors(cursor, *Vec); |
| 1140 | |
| 1141 | // Did we get any overriden cursors? If not, return Vec to the pool |
| 1142 | // of available cursor vectors. |
| 1143 | if (Vec->size() == 1) { |
| 1144 | pool.AvailableCursors.push_back(Vec); |
| 1145 | return; |
| 1146 | } |
| 1147 | |
| 1148 | // Now tell the caller about the overriden cursors. |
| 1149 | assert(Vec->size() > 1); |
| 1150 | *overridden = &((*Vec)[1]); |
| 1151 | *num_overridden = Vec->size() - 1; |
| 1152 | } |
| 1153 | |
| 1154 | void clang_disposeOverriddenCursors(CXCursor *overridden) { |
| 1155 | if (!overridden) |
| 1156 | return; |
| 1157 | |
| 1158 | // Use pointer arithmetic to get back the first faux entry |
| 1159 | // which has a back-reference to the TU and the vector. |
| 1160 | --overridden; |
| 1161 | OverridenCursorsPool::CursorVec *Vec = |
Dmitri Gribenko | 67812b2 | 2013-01-11 21:01:49 +0000 | [diff] [blame] | 1162 | static_cast<OverridenCursorsPool::CursorVec *>( |
| 1163 | const_cast<void *>(overridden->data[0])); |
Ted Kremenek | bbf66ca | 2012-04-30 19:06:49 +0000 | [diff] [blame] | 1164 | CXTranslationUnit TU = getCursorTU(*overridden); |
| 1165 | |
| 1166 | assert(Vec && TU); |
| 1167 | |
| 1168 | OverridenCursorsPool &pool = |
| 1169 | *static_cast<OverridenCursorsPool*>(TU->OverridenCursorsPool); |
| 1170 | |
| 1171 | pool.AvailableCursors.push_back(Vec); |
| 1172 | } |
Argyrios Kyrtzidis | f39a7ae | 2012-07-02 23:54:36 +0000 | [diff] [blame] | 1173 | |
| 1174 | int clang_Cursor_isDynamicCall(CXCursor C) { |
| 1175 | const Expr *E = 0; |
| 1176 | if (clang_isExpression(C.kind)) |
| 1177 | E = getCursorExpr(C); |
| 1178 | if (!E) |
| 1179 | return 0; |
| 1180 | |
| 1181 | if (const ObjCMessageExpr *MsgE = dyn_cast<ObjCMessageExpr>(E)) |
| 1182 | return MsgE->getReceiverKind() == ObjCMessageExpr::Instance; |
| 1183 | |
| 1184 | const MemberExpr *ME = 0; |
| 1185 | if (isa<MemberExpr>(E)) |
| 1186 | ME = cast<MemberExpr>(E); |
| 1187 | else if (const CallExpr *CE = dyn_cast<CallExpr>(E)) |
| 1188 | ME = dyn_cast_or_null<MemberExpr>(CE->getCallee()); |
| 1189 | |
| 1190 | if (ME) { |
| 1191 | if (const CXXMethodDecl * |
| 1192 | MD = dyn_cast_or_null<CXXMethodDecl>(ME->getMemberDecl())) |
| 1193 | return MD->isVirtual() && !ME->hasQualifier(); |
| 1194 | } |
| 1195 | |
| 1196 | return 0; |
| 1197 | } |
| 1198 | |
Argyrios Kyrtzidis | e4a990f | 2012-11-01 02:01:34 +0000 | [diff] [blame] | 1199 | CXType clang_Cursor_getReceiverType(CXCursor C) { |
| 1200 | CXTranslationUnit TU = cxcursor::getCursorTU(C); |
| 1201 | const Expr *E = 0; |
| 1202 | if (clang_isExpression(C.kind)) |
| 1203 | E = getCursorExpr(C); |
| 1204 | |
| 1205 | if (const ObjCMessageExpr *MsgE = dyn_cast_or_null<ObjCMessageExpr>(E)) |
| 1206 | return cxtype::MakeCXType(MsgE->getReceiverType(), TU); |
| 1207 | |
| 1208 | return cxtype::MakeCXType(QualType(), TU); |
| 1209 | } |
| 1210 | |
Ted Kremenek | eca099b | 2010-12-08 23:43:14 +0000 | [diff] [blame] | 1211 | } // end: extern "C" |