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" |
Douglas Gregor | 7eaa8ae | 2010-01-20 00:23:15 +0000 | [diff] [blame] | 19 | #include "clang/Frontend/ASTUnit.h" |
Ted Kremenek | 16c440a | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 20 | #include "clang/AST/Decl.h" |
Douglas Gregor | 6931900 | 2010-08-31 23:48:11 +0000 | [diff] [blame] | 21 | #include "clang/AST/DeclCXX.h" |
Douglas Gregor | 283cae3 | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 22 | #include "clang/AST/DeclObjC.h" |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 23 | #include "clang/AST/DeclTemplate.h" |
Douglas Gregor | 283cae3 | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 24 | #include "clang/AST/Expr.h" |
Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 25 | #include "clang/AST/ExprCXX.h" |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 26 | #include "clang/AST/ExprObjC.h" |
Ted Kremenek | 007a7c9 | 2010-11-01 23:26:51 +0000 | [diff] [blame] | 27 | #include "clang-c/Index.h" |
Ted Kremenek | edc8aa6 | 2010-01-16 00:36:30 +0000 | [diff] [blame] | 28 | #include "llvm/Support/ErrorHandling.h" |
Ted Kremenek | 16c440a | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 29 | |
| 30 | using namespace clang; |
Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 31 | using namespace cxcursor; |
Ted Kremenek | 16c440a | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 32 | |
Douglas Gregor | 5bfb8c1 | 2010-01-20 23:34:41 +0000 | [diff] [blame] | 33 | CXCursor cxcursor::MakeCXCursorInvalid(CXCursorKind K) { |
| 34 | assert(K >= CXCursor_FirstInvalid && K <= CXCursor_LastInvalid); |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 35 | CXCursor C = { K, 0, { 0, 0, 0 } }; |
Douglas Gregor | 5bfb8c1 | 2010-01-20 23:34:41 +0000 | [diff] [blame] | 36 | return C; |
Ted Kremenek | 16c440a | 2010-01-15 20:35:54 +0000 | [diff] [blame] | 37 | } |
| 38 | |
Ted Kremenek | e77f443 | 2010-02-18 03:09:07 +0000 | [diff] [blame] | 39 | static CXCursorKind GetCursorKind(const Attr *A) { |
| 40 | assert(A && "Invalid arguments!"); |
| 41 | switch (A->getKind()) { |
| 42 | default: break; |
Sean Hunt | 387475d | 2010-06-16 23:43:53 +0000 | [diff] [blame] | 43 | case attr::IBAction: return CXCursor_IBActionAttr; |
| 44 | case attr::IBOutlet: return CXCursor_IBOutletAttr; |
| 45 | case attr::IBOutletCollection: return CXCursor_IBOutletCollectionAttr; |
Argyrios Kyrtzidis | 6639e92 | 2011-09-13 17:39:31 +0000 | [diff] [blame] | 46 | case attr::Final: return CXCursor_CXXFinalAttr; |
| 47 | case attr::Override: return CXCursor_CXXOverrideAttr; |
Erik Verbruggen | 5f1c822 | 2011-10-13 09:41:32 +0000 | [diff] [blame] | 48 | case attr::Annotate: return CXCursor_AnnotateAttr; |
Ted Kremenek | e77f443 | 2010-02-18 03:09:07 +0000 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | return CXCursor_UnexposedAttr; |
| 52 | } |
| 53 | |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 54 | CXCursor cxcursor::MakeCXCursor(const Attr *A, Decl *Parent, |
| 55 | CXTranslationUnit TU) { |
Ted Kremenek | e77f443 | 2010-02-18 03:09:07 +0000 | [diff] [blame] | 56 | assert(A && Parent && TU && "Invalid arguments!"); |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 57 | CXCursor C = { GetCursorKind(A), 0, { Parent, (void*)A, TU } }; |
Ted Kremenek | e77f443 | 2010-02-18 03:09:07 +0000 | [diff] [blame] | 58 | return C; |
| 59 | } |
| 60 | |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 61 | CXCursor cxcursor::MakeCXCursor(Decl *D, CXTranslationUnit TU, |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 62 | SourceRange RegionOfInterest, |
Ted Kremenek | 007a7c9 | 2010-11-01 23:26:51 +0000 | [diff] [blame] | 63 | bool FirstInDeclGroup) { |
Daniel Dunbar | 54d67ca | 2010-01-25 00:40:30 +0000 | [diff] [blame] | 64 | assert(D && TU && "Invalid arguments!"); |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 65 | |
| 66 | CXCursorKind K = getCursorKindForDecl(D); |
| 67 | |
| 68 | if (K == CXCursor_ObjCClassMethodDecl || |
| 69 | K == CXCursor_ObjCInstanceMethodDecl) { |
| 70 | int SelectorIdIndex = -1; |
| 71 | // Check if cursor points to a selector id. |
| 72 | if (RegionOfInterest.isValid() && |
| 73 | RegionOfInterest.getBegin() == RegionOfInterest.getEnd()) { |
| 74 | SmallVector<SourceLocation, 16> SelLocs; |
| 75 | cast<ObjCMethodDecl>(D)->getSelectorLocs(SelLocs); |
| 76 | SmallVector<SourceLocation, 16>::iterator |
| 77 | I=std::find(SelLocs.begin(), SelLocs.end(),RegionOfInterest.getBegin()); |
| 78 | if (I != SelLocs.end()) |
| 79 | SelectorIdIndex = I - SelLocs.begin(); |
| 80 | } |
| 81 | CXCursor C = { K, SelectorIdIndex, |
| 82 | { D, (void*)(intptr_t) (FirstInDeclGroup ? 1 : 0), TU }}; |
| 83 | return C; |
| 84 | } |
| 85 | |
| 86 | CXCursor C = { K, 0, { D, (void*)(intptr_t) (FirstInDeclGroup ? 1 : 0), TU }}; |
Douglas Gregor | 5bfb8c1 | 2010-01-20 23:34:41 +0000 | [diff] [blame] | 87 | return C; |
Ted Kremenek | edc8aa6 | 2010-01-16 00:36:30 +0000 | [diff] [blame] | 88 | } |
| 89 | |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 90 | CXCursor cxcursor::MakeCXCursor(Stmt *S, Decl *Parent, CXTranslationUnit TU, |
| 91 | SourceRange RegionOfInterest) { |
Daniel Dunbar | 54d67ca | 2010-01-25 00:40:30 +0000 | [diff] [blame] | 92 | assert(S && TU && "Invalid arguments!"); |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 93 | CXCursorKind K = CXCursor_NotImplemented; |
| 94 | |
| 95 | switch (S->getStmtClass()) { |
| 96 | case Stmt::NoStmtClass: |
| 97 | break; |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 98 | |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 99 | case Stmt::CaseStmtClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 100 | K = CXCursor_CaseStmt; |
| 101 | break; |
| 102 | |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 103 | case Stmt::DefaultStmtClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 104 | K = CXCursor_DefaultStmt; |
| 105 | break; |
| 106 | |
| 107 | case Stmt::IfStmtClass: |
| 108 | K = CXCursor_IfStmt; |
| 109 | break; |
| 110 | |
| 111 | case Stmt::SwitchStmtClass: |
| 112 | K = CXCursor_SwitchStmt; |
| 113 | break; |
| 114 | |
| 115 | case Stmt::WhileStmtClass: |
| 116 | K = CXCursor_WhileStmt; |
| 117 | break; |
| 118 | |
| 119 | case Stmt::DoStmtClass: |
| 120 | K = CXCursor_DoStmt; |
| 121 | break; |
| 122 | |
| 123 | case Stmt::ForStmtClass: |
| 124 | K = CXCursor_ForStmt; |
| 125 | break; |
| 126 | |
| 127 | case Stmt::GotoStmtClass: |
| 128 | K = CXCursor_GotoStmt; |
| 129 | break; |
| 130 | |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 131 | case Stmt::IndirectGotoStmtClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 132 | K = CXCursor_IndirectGotoStmt; |
| 133 | break; |
| 134 | |
| 135 | case Stmt::ContinueStmtClass: |
| 136 | K = CXCursor_ContinueStmt; |
| 137 | break; |
| 138 | |
| 139 | case Stmt::BreakStmtClass: |
| 140 | K = CXCursor_BreakStmt; |
| 141 | break; |
| 142 | |
| 143 | case Stmt::ReturnStmtClass: |
| 144 | K = CXCursor_ReturnStmt; |
| 145 | break; |
| 146 | |
| 147 | case Stmt::AsmStmtClass: |
| 148 | K = CXCursor_AsmStmt; |
| 149 | break; |
| 150 | |
| 151 | case Stmt::ObjCAtTryStmtClass: |
| 152 | K = CXCursor_ObjCAtTryStmt; |
| 153 | break; |
| 154 | |
| 155 | case Stmt::ObjCAtCatchStmtClass: |
| 156 | K = CXCursor_ObjCAtCatchStmt; |
| 157 | break; |
| 158 | |
| 159 | case Stmt::ObjCAtFinallyStmtClass: |
| 160 | K = CXCursor_ObjCAtFinallyStmt; |
| 161 | break; |
| 162 | |
| 163 | case Stmt::ObjCAtThrowStmtClass: |
| 164 | K = CXCursor_ObjCAtThrowStmt; |
| 165 | break; |
| 166 | |
| 167 | case Stmt::ObjCAtSynchronizedStmtClass: |
| 168 | K = CXCursor_ObjCAtSynchronizedStmt; |
| 169 | break; |
| 170 | |
| 171 | case Stmt::ObjCAutoreleasePoolStmtClass: |
| 172 | K = CXCursor_ObjCAutoreleasePoolStmt; |
| 173 | break; |
| 174 | |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 175 | case Stmt::ObjCForCollectionStmtClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 176 | K = CXCursor_ObjCForCollectionStmt; |
| 177 | break; |
| 178 | |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 179 | case Stmt::CXXCatchStmtClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 180 | K = CXCursor_CXXCatchStmt; |
| 181 | break; |
| 182 | |
| 183 | case Stmt::CXXTryStmtClass: |
| 184 | K = CXCursor_CXXTryStmt; |
| 185 | break; |
| 186 | |
| 187 | case Stmt::CXXForRangeStmtClass: |
| 188 | K = CXCursor_CXXForRangeStmt; |
| 189 | break; |
| 190 | |
John Wiegley | 28bbe4b | 2011-04-28 01:08:34 +0000 | [diff] [blame] | 191 | case Stmt::SEHTryStmtClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 192 | K = CXCursor_SEHTryStmt; |
| 193 | break; |
| 194 | |
John Wiegley | 28bbe4b | 2011-04-28 01:08:34 +0000 | [diff] [blame] | 195 | case Stmt::SEHExceptStmtClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 196 | K = CXCursor_SEHExceptStmt; |
| 197 | break; |
| 198 | |
John Wiegley | 28bbe4b | 2011-04-28 01:08:34 +0000 | [diff] [blame] | 199 | case Stmt::SEHFinallyStmtClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 200 | K = CXCursor_SEHFinallyStmt; |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 201 | break; |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 202 | |
John Wiegley | 21ff2e5 | 2011-04-28 00:16:57 +0000 | [diff] [blame] | 203 | case Stmt::ArrayTypeTraitExprClass: |
Tanya Lattner | 61eee0c | 2011-06-04 00:47:47 +0000 | [diff] [blame] | 204 | case Stmt::AsTypeExprClass: |
Eli Friedman | 276b061 | 2011-10-11 02:20:01 +0000 | [diff] [blame] | 205 | case Stmt::AtomicExprClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 206 | case Stmt::BinaryConditionalOperatorClass: |
| 207 | case Stmt::BinaryTypeTraitExprClass: |
| 208 | case Stmt::CXXBindTemporaryExprClass: |
| 209 | case Stmt::CXXDefaultArgExprClass: |
| 210 | case Stmt::CXXScalarValueInitExprClass: |
| 211 | case Stmt::CXXUuidofExprClass: |
| 212 | case Stmt::ChooseExprClass: |
| 213 | case Stmt::DesignatedInitExprClass: |
| 214 | case Stmt::ExprWithCleanupsClass: |
| 215 | case Stmt::ExpressionTraitExprClass: |
| 216 | case Stmt::ExtVectorElementExprClass: |
| 217 | case Stmt::ImplicitCastExprClass: |
| 218 | case Stmt::ImplicitValueInitExprClass: |
| 219 | case Stmt::MaterializeTemporaryExprClass: |
| 220 | case Stmt::ObjCIndirectCopyRestoreExprClass: |
| 221 | case Stmt::OffsetOfExprClass: |
| 222 | case Stmt::OpaqueValueExprClass: |
| 223 | case Stmt::ParenListExprClass: |
| 224 | case Stmt::PredefinedExprClass: |
| 225 | case Stmt::ShuffleVectorExprClass: |
| 226 | case Stmt::UnaryExprOrTypeTraitExprClass: |
| 227 | case Stmt::UnaryTypeTraitExprClass: |
| 228 | case Stmt::VAArgExprClass: |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 229 | K = CXCursor_UnexposedExpr; |
| 230 | break; |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 231 | |
| 232 | case Stmt::CompoundStmtClass: |
| 233 | K = CXCursor_CompoundStmt; |
| 234 | break; |
Douglas Gregor | 36897b0 | 2010-09-10 00:22:18 +0000 | [diff] [blame] | 235 | |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 236 | case Stmt::NullStmtClass: |
| 237 | K = CXCursor_NullStmt; |
| 238 | break; |
| 239 | |
| 240 | case Stmt::LabelStmtClass: |
| 241 | K = CXCursor_LabelStmt; |
| 242 | break; |
| 243 | |
| 244 | case Stmt::DeclStmtClass: |
| 245 | K = CXCursor_DeclStmt; |
| 246 | break; |
| 247 | |
| 248 | case Stmt::IntegerLiteralClass: |
| 249 | K = CXCursor_IntegerLiteral; |
| 250 | break; |
| 251 | |
| 252 | case Stmt::FloatingLiteralClass: |
| 253 | K = CXCursor_FloatingLiteral; |
| 254 | break; |
| 255 | |
| 256 | case Stmt::ImaginaryLiteralClass: |
| 257 | K = CXCursor_ImaginaryLiteral; |
| 258 | break; |
| 259 | |
| 260 | case Stmt::StringLiteralClass: |
| 261 | K = CXCursor_StringLiteral; |
| 262 | break; |
| 263 | |
| 264 | case Stmt::CharacterLiteralClass: |
| 265 | K = CXCursor_CharacterLiteral; |
| 266 | break; |
| 267 | |
| 268 | case Stmt::ParenExprClass: |
| 269 | K = CXCursor_ParenExpr; |
| 270 | break; |
| 271 | |
| 272 | case Stmt::UnaryOperatorClass: |
| 273 | K = CXCursor_UnaryOperator; |
| 274 | break; |
| 275 | |
| 276 | case Stmt::CXXNoexceptExprClass: |
| 277 | K = CXCursor_UnaryExpr; |
| 278 | break; |
| 279 | |
| 280 | case Stmt::ArraySubscriptExprClass: |
| 281 | K = CXCursor_ArraySubscriptExpr; |
| 282 | break; |
| 283 | |
| 284 | case Stmt::BinaryOperatorClass: |
| 285 | K = CXCursor_BinaryOperator; |
| 286 | break; |
| 287 | |
| 288 | case Stmt::CompoundAssignOperatorClass: |
| 289 | K = CXCursor_CompoundAssignOperator; |
| 290 | break; |
| 291 | |
| 292 | case Stmt::ConditionalOperatorClass: |
| 293 | K = CXCursor_ConditionalOperator; |
| 294 | break; |
| 295 | |
| 296 | case Stmt::CStyleCastExprClass: |
| 297 | K = CXCursor_CStyleCastExpr; |
| 298 | break; |
| 299 | |
| 300 | case Stmt::CompoundLiteralExprClass: |
| 301 | K = CXCursor_CompoundLiteralExpr; |
| 302 | break; |
| 303 | |
| 304 | case Stmt::InitListExprClass: |
| 305 | K = CXCursor_InitListExpr; |
| 306 | break; |
| 307 | |
| 308 | case Stmt::AddrLabelExprClass: |
| 309 | K = CXCursor_AddrLabelExpr; |
| 310 | break; |
| 311 | |
| 312 | case Stmt::StmtExprClass: |
| 313 | K = CXCursor_StmtExpr; |
| 314 | break; |
| 315 | |
| 316 | case Stmt::GenericSelectionExprClass: |
| 317 | K = CXCursor_GenericSelectionExpr; |
| 318 | break; |
| 319 | |
| 320 | case Stmt::GNUNullExprClass: |
| 321 | K = CXCursor_GNUNullExpr; |
| 322 | break; |
| 323 | |
| 324 | case Stmt::CXXStaticCastExprClass: |
| 325 | K = CXCursor_CXXStaticCastExpr; |
| 326 | break; |
| 327 | |
| 328 | case Stmt::CXXDynamicCastExprClass: |
| 329 | K = CXCursor_CXXDynamicCastExpr; |
| 330 | break; |
| 331 | |
| 332 | case Stmt::CXXReinterpretCastExprClass: |
| 333 | K = CXCursor_CXXReinterpretCastExpr; |
| 334 | break; |
| 335 | |
| 336 | case Stmt::CXXConstCastExprClass: |
| 337 | K = CXCursor_CXXConstCastExpr; |
| 338 | break; |
| 339 | |
| 340 | case Stmt::CXXFunctionalCastExprClass: |
| 341 | K = CXCursor_CXXFunctionalCastExpr; |
| 342 | break; |
| 343 | |
| 344 | case Stmt::CXXTypeidExprClass: |
| 345 | K = CXCursor_CXXTypeidExpr; |
| 346 | break; |
| 347 | |
| 348 | case Stmt::CXXBoolLiteralExprClass: |
| 349 | K = CXCursor_CXXBoolLiteralExpr; |
| 350 | break; |
| 351 | |
| 352 | case Stmt::CXXNullPtrLiteralExprClass: |
| 353 | K = CXCursor_CXXNullPtrLiteralExpr; |
| 354 | break; |
| 355 | |
| 356 | case Stmt::CXXThisExprClass: |
| 357 | K = CXCursor_CXXThisExpr; |
| 358 | break; |
| 359 | |
| 360 | case Stmt::CXXThrowExprClass: |
| 361 | K = CXCursor_CXXThrowExpr; |
| 362 | break; |
| 363 | |
| 364 | case Stmt::CXXNewExprClass: |
| 365 | K = CXCursor_CXXNewExpr; |
| 366 | break; |
| 367 | |
| 368 | case Stmt::CXXDeleteExprClass: |
| 369 | K = CXCursor_CXXDeleteExpr; |
| 370 | break; |
| 371 | |
| 372 | case Stmt::ObjCStringLiteralClass: |
| 373 | K = CXCursor_ObjCStringLiteral; |
| 374 | break; |
| 375 | |
| 376 | case Stmt::ObjCEncodeExprClass: |
| 377 | K = CXCursor_ObjCEncodeExpr; |
| 378 | break; |
| 379 | |
| 380 | case Stmt::ObjCSelectorExprClass: |
| 381 | K = CXCursor_ObjCSelectorExpr; |
| 382 | break; |
| 383 | |
| 384 | case Stmt::ObjCProtocolExprClass: |
| 385 | K = CXCursor_ObjCProtocolExpr; |
| 386 | break; |
| 387 | |
| 388 | case Stmt::ObjCBridgedCastExprClass: |
| 389 | K = CXCursor_ObjCBridgedCastExpr; |
| 390 | break; |
| 391 | |
| 392 | case Stmt::BlockExprClass: |
| 393 | K = CXCursor_BlockExpr; |
| 394 | break; |
| 395 | |
| 396 | case Stmt::PackExpansionExprClass: |
| 397 | K = CXCursor_PackExpansionExpr; |
| 398 | break; |
| 399 | |
| 400 | case Stmt::SizeOfPackExprClass: |
| 401 | K = CXCursor_SizeOfPackExpr; |
| 402 | break; |
| 403 | |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 404 | case Stmt::BlockDeclRefExprClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 405 | case Stmt::DeclRefExprClass: |
| 406 | case Stmt::DependentScopeDeclRefExprClass: |
John McCall | 91a5755 | 2011-07-15 05:09:51 +0000 | [diff] [blame] | 407 | case Stmt::SubstNonTypeTemplateParmExprClass: |
Douglas Gregor | c7793c7 | 2011-01-15 01:15:58 +0000 | [diff] [blame] | 408 | case Stmt::SubstNonTypeTemplateParmPackExprClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 409 | case Stmt::UnresolvedLookupExprClass: |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 410 | K = CXCursor_DeclRefExpr; |
| 411 | break; |
| 412 | |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 413 | case Stmt::CXXDependentScopeMemberExprClass: |
| 414 | case Stmt::CXXPseudoDestructorExprClass: |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 415 | case Stmt::MemberExprClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 416 | case Stmt::ObjCIsaExprClass: |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 417 | case Stmt::ObjCIvarRefExprClass: |
| 418 | case Stmt::ObjCPropertyRefExprClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 419 | case Stmt::UnresolvedMemberExprClass: |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 420 | K = CXCursor_MemberRefExpr; |
| 421 | break; |
| 422 | |
| 423 | case Stmt::CallExprClass: |
| 424 | case Stmt::CXXOperatorCallExprClass: |
| 425 | case Stmt::CXXMemberCallExprClass: |
Peter Collingbourne | e08ce65 | 2011-02-09 21:07:24 +0000 | [diff] [blame] | 426 | case Stmt::CUDAKernelCallExprClass: |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 427 | case Stmt::CXXConstructExprClass: |
| 428 | case Stmt::CXXTemporaryObjectExprClass: |
Douglas Gregor | 42b2984 | 2011-10-05 19:00:14 +0000 | [diff] [blame] | 429 | case Stmt::CXXUnresolvedConstructExprClass: |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 430 | K = CXCursor_CallExpr; |
| 431 | break; |
| 432 | |
| 433 | case Stmt::ObjCMessageExprClass: |
| 434 | K = CXCursor_ObjCMessageExpr; |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 435 | int SelectorIdIndex = -1; |
| 436 | // Check if cursor points to a selector id. |
| 437 | if (RegionOfInterest.isValid() && |
| 438 | RegionOfInterest.getBegin() == RegionOfInterest.getEnd()) { |
| 439 | SmallVector<SourceLocation, 16> SelLocs; |
| 440 | cast<ObjCMessageExpr>(S)->getSelectorLocs(SelLocs); |
| 441 | SmallVector<SourceLocation, 16>::iterator |
| 442 | I=std::find(SelLocs.begin(), SelLocs.end(),RegionOfInterest.getBegin()); |
| 443 | if (I != SelLocs.end()) |
| 444 | SelectorIdIndex = I - SelLocs.begin(); |
| 445 | } |
| 446 | CXCursor C = { K, 0, { Parent, S, TU } }; |
| 447 | return getSelectorIdentifierCursor(SelectorIdIndex, C); |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 448 | } |
| 449 | |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 450 | CXCursor C = { K, 0, { Parent, S, TU } }; |
Douglas Gregor | 97b9872 | 2010-01-19 23:20:36 +0000 | [diff] [blame] | 451 | return C; |
| 452 | } |
| 453 | |
Douglas Gregor | 2e331b9 | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 454 | CXCursor cxcursor::MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super, |
Douglas Gregor | b2cd487 | 2010-01-20 23:57:43 +0000 | [diff] [blame] | 455 | SourceLocation Loc, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 456 | CXTranslationUnit TU) { |
Daniel Dunbar | 54d67ca | 2010-01-25 00:40:30 +0000 | [diff] [blame] | 457 | assert(Super && TU && "Invalid arguments!"); |
Douglas Gregor | 2e331b9 | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 458 | void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 459 | CXCursor C = { CXCursor_ObjCSuperClassRef, 0, { Super, RawLoc, TU } }; |
Douglas Gregor | 2e331b9 | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 460 | return C; |
| 461 | } |
| 462 | |
| 463 | std::pair<ObjCInterfaceDecl *, SourceLocation> |
| 464 | cxcursor::getCursorObjCSuperClassRef(CXCursor C) { |
| 465 | assert(C.kind == CXCursor_ObjCSuperClassRef); |
| 466 | return std::make_pair(static_cast<ObjCInterfaceDecl *>(C.data[0]), |
| 467 | SourceLocation::getFromRawEncoding( |
| 468 | reinterpret_cast<uintptr_t>(C.data[1]))); |
| 469 | } |
| 470 | |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 471 | CXCursor cxcursor::MakeCursorObjCProtocolRef(const ObjCProtocolDecl *Proto, |
Douglas Gregor | b2cd487 | 2010-01-20 23:57:43 +0000 | [diff] [blame] | 472 | SourceLocation Loc, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 473 | CXTranslationUnit TU) { |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 474 | assert(Proto && TU && "Invalid arguments!"); |
Douglas Gregor | 78db0cd | 2010-01-16 15:44:18 +0000 | [diff] [blame] | 475 | void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 476 | CXCursor C = { CXCursor_ObjCProtocolRef, 0, { (void*)Proto, RawLoc, TU } }; |
Douglas Gregor | 78db0cd | 2010-01-16 15:44:18 +0000 | [diff] [blame] | 477 | return C; |
| 478 | } |
| 479 | |
| 480 | std::pair<ObjCProtocolDecl *, SourceLocation> |
| 481 | cxcursor::getCursorObjCProtocolRef(CXCursor C) { |
| 482 | assert(C.kind == CXCursor_ObjCProtocolRef); |
| 483 | return std::make_pair(static_cast<ObjCProtocolDecl *>(C.data[0]), |
| 484 | SourceLocation::getFromRawEncoding( |
| 485 | reinterpret_cast<uintptr_t>(C.data[1]))); |
| 486 | } |
| 487 | |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 488 | CXCursor cxcursor::MakeCursorObjCClassRef(const ObjCInterfaceDecl *Class, |
Douglas Gregor | b2cd487 | 2010-01-20 23:57:43 +0000 | [diff] [blame] | 489 | SourceLocation Loc, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 490 | CXTranslationUnit TU) { |
Ted Kremenek | ebfa339 | 2010-03-19 20:39:03 +0000 | [diff] [blame] | 491 | // 'Class' can be null for invalid code. |
| 492 | if (!Class) |
| 493 | return MakeCXCursorInvalid(CXCursor_InvalidCode); |
| 494 | assert(TU && "Invalid arguments!"); |
Douglas Gregor | 1adb082 | 2010-01-16 17:14:40 +0000 | [diff] [blame] | 495 | void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 496 | CXCursor C = { CXCursor_ObjCClassRef, 0, { (void*)Class, RawLoc, TU } }; |
Douglas Gregor | 1adb082 | 2010-01-16 17:14:40 +0000 | [diff] [blame] | 497 | return C; |
| 498 | } |
| 499 | |
| 500 | std::pair<ObjCInterfaceDecl *, SourceLocation> |
| 501 | cxcursor::getCursorObjCClassRef(CXCursor C) { |
| 502 | assert(C.kind == CXCursor_ObjCClassRef); |
| 503 | return std::make_pair(static_cast<ObjCInterfaceDecl *>(C.data[0]), |
| 504 | SourceLocation::getFromRawEncoding( |
| 505 | reinterpret_cast<uintptr_t>(C.data[1]))); |
| 506 | } |
| 507 | |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 508 | CXCursor cxcursor::MakeCursorTypeRef(const TypeDecl *Type, SourceLocation Loc, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 509 | CXTranslationUnit TU) { |
Daniel Dunbar | 54d67ca | 2010-01-25 00:40:30 +0000 | [diff] [blame] | 510 | assert(Type && TU && "Invalid arguments!"); |
Douglas Gregor | 7d0d40e | 2010-01-21 16:28:34 +0000 | [diff] [blame] | 511 | void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 512 | CXCursor C = { CXCursor_TypeRef, 0, { (void*)Type, RawLoc, TU } }; |
Douglas Gregor | 7d0d40e | 2010-01-21 16:28:34 +0000 | [diff] [blame] | 513 | return C; |
| 514 | } |
| 515 | |
| 516 | std::pair<TypeDecl *, SourceLocation> |
| 517 | cxcursor::getCursorTypeRef(CXCursor C) { |
| 518 | assert(C.kind == CXCursor_TypeRef); |
| 519 | return std::make_pair(static_cast<TypeDecl *>(C.data[0]), |
| 520 | SourceLocation::getFromRawEncoding( |
| 521 | reinterpret_cast<uintptr_t>(C.data[1]))); |
| 522 | } |
| 523 | |
Douglas Gregor | 0b36e61 | 2010-08-31 20:37:03 +0000 | [diff] [blame] | 524 | CXCursor cxcursor::MakeCursorTemplateRef(TemplateDecl *Template, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 525 | SourceLocation Loc, |
| 526 | CXTranslationUnit TU) { |
Douglas Gregor | 0b36e61 | 2010-08-31 20:37:03 +0000 | [diff] [blame] | 527 | assert(Template && TU && "Invalid arguments!"); |
| 528 | void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 529 | CXCursor C = { CXCursor_TemplateRef, 0, { Template, RawLoc, TU } }; |
Douglas Gregor | 0b36e61 | 2010-08-31 20:37:03 +0000 | [diff] [blame] | 530 | return C; |
| 531 | } |
| 532 | |
| 533 | std::pair<TemplateDecl *, SourceLocation> |
| 534 | cxcursor::getCursorTemplateRef(CXCursor C) { |
| 535 | assert(C.kind == CXCursor_TemplateRef); |
| 536 | return std::make_pair(static_cast<TemplateDecl *>(C.data[0]), |
| 537 | SourceLocation::getFromRawEncoding( |
| 538 | reinterpret_cast<uintptr_t>(C.data[1]))); |
| 539 | } |
| 540 | |
Douglas Gregor | 6931900 | 2010-08-31 23:48:11 +0000 | [diff] [blame] | 541 | CXCursor cxcursor::MakeCursorNamespaceRef(NamedDecl *NS, SourceLocation Loc, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 542 | CXTranslationUnit TU) { |
Douglas Gregor | 6931900 | 2010-08-31 23:48:11 +0000 | [diff] [blame] | 543 | |
| 544 | assert(NS && (isa<NamespaceDecl>(NS) || isa<NamespaceAliasDecl>(NS)) && TU && |
| 545 | "Invalid arguments!"); |
| 546 | void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 547 | CXCursor C = { CXCursor_NamespaceRef, 0, { NS, RawLoc, TU } }; |
Douglas Gregor | 6931900 | 2010-08-31 23:48:11 +0000 | [diff] [blame] | 548 | return C; |
| 549 | } |
| 550 | |
| 551 | std::pair<NamedDecl *, SourceLocation> |
| 552 | cxcursor::getCursorNamespaceRef(CXCursor C) { |
| 553 | assert(C.kind == CXCursor_NamespaceRef); |
| 554 | return std::make_pair(static_cast<NamedDecl *>(C.data[0]), |
| 555 | SourceLocation::getFromRawEncoding( |
| 556 | reinterpret_cast<uintptr_t>(C.data[1]))); |
| 557 | } |
| 558 | |
Douglas Gregor | a67e03f | 2010-09-09 21:42:20 +0000 | [diff] [blame] | 559 | CXCursor cxcursor::MakeCursorMemberRef(FieldDecl *Field, SourceLocation Loc, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 560 | CXTranslationUnit TU) { |
Douglas Gregor | a67e03f | 2010-09-09 21:42:20 +0000 | [diff] [blame] | 561 | |
| 562 | assert(Field && TU && "Invalid arguments!"); |
| 563 | void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 564 | CXCursor C = { CXCursor_MemberRef, 0, { Field, RawLoc, TU } }; |
Douglas Gregor | a67e03f | 2010-09-09 21:42:20 +0000 | [diff] [blame] | 565 | return C; |
| 566 | } |
| 567 | |
| 568 | std::pair<FieldDecl *, SourceLocation> |
| 569 | cxcursor::getCursorMemberRef(CXCursor C) { |
| 570 | assert(C.kind == CXCursor_MemberRef); |
| 571 | return std::make_pair(static_cast<FieldDecl *>(C.data[0]), |
| 572 | SourceLocation::getFromRawEncoding( |
| 573 | reinterpret_cast<uintptr_t>(C.data[1]))); |
| 574 | } |
| 575 | |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 576 | CXCursor cxcursor::MakeCursorCXXBaseSpecifier(CXXBaseSpecifier *B, |
| 577 | CXTranslationUnit TU){ |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 578 | CXCursor C = { CXCursor_CXXBaseSpecifier, 0, { B, 0, TU } }; |
Ted Kremenek | 3064ef9 | 2010-08-27 21:34:58 +0000 | [diff] [blame] | 579 | return C; |
| 580 | } |
| 581 | |
| 582 | CXXBaseSpecifier *cxcursor::getCursorCXXBaseSpecifier(CXCursor C) { |
| 583 | assert(C.kind == CXCursor_CXXBaseSpecifier); |
| 584 | return static_cast<CXXBaseSpecifier*>(C.data[0]); |
| 585 | } |
| 586 | |
Douglas Gregor | 9f1e3ff | 2010-03-18 00:42:48 +0000 | [diff] [blame] | 587 | CXCursor cxcursor::MakePreprocessingDirectiveCursor(SourceRange Range, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 588 | CXTranslationUnit TU) { |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 589 | CXCursor C = { CXCursor_PreprocessingDirective, 0, |
Douglas Gregor | 9f1e3ff | 2010-03-18 00:42:48 +0000 | [diff] [blame] | 590 | { reinterpret_cast<void *>(Range.getBegin().getRawEncoding()), |
| 591 | reinterpret_cast<void *>(Range.getEnd().getRawEncoding()), |
| 592 | TU } |
| 593 | }; |
| 594 | return C; |
| 595 | } |
| 596 | |
| 597 | SourceRange cxcursor::getCursorPreprocessingDirective(CXCursor C) { |
| 598 | assert(C.kind == CXCursor_PreprocessingDirective); |
Argyrios Kyrtzidis | ee0f84f | 2011-09-26 08:01:41 +0000 | [diff] [blame] | 599 | SourceRange Range = SourceRange(SourceLocation::getFromRawEncoding( |
Douglas Gregor | 9f1e3ff | 2010-03-18 00:42:48 +0000 | [diff] [blame] | 600 | reinterpret_cast<uintptr_t> (C.data[0])), |
| 601 | SourceLocation::getFromRawEncoding( |
| 602 | reinterpret_cast<uintptr_t> (C.data[1]))); |
Argyrios Kyrtzidis | ee0f84f | 2011-09-26 08:01:41 +0000 | [diff] [blame] | 603 | ASTUnit *TU = getCursorASTUnit(C); |
| 604 | return TU->mapRangeFromPreamble(Range); |
Douglas Gregor | 9f1e3ff | 2010-03-18 00:42:48 +0000 | [diff] [blame] | 605 | } |
| 606 | |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 607 | CXCursor cxcursor::MakeMacroDefinitionCursor(MacroDefinition *MI, |
| 608 | CXTranslationUnit TU) { |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 609 | CXCursor C = { CXCursor_MacroDefinition, 0, { MI, 0, TU } }; |
Douglas Gregor | 572feb2 | 2010-03-18 18:04:21 +0000 | [diff] [blame] | 610 | return C; |
| 611 | } |
| 612 | |
| 613 | MacroDefinition *cxcursor::getCursorMacroDefinition(CXCursor C) { |
| 614 | assert(C.kind == CXCursor_MacroDefinition); |
| 615 | return static_cast<MacroDefinition *>(C.data[0]); |
| 616 | } |
| 617 | |
Chandler Carruth | 9e5bb85 | 2011-07-14 08:20:46 +0000 | [diff] [blame] | 618 | CXCursor cxcursor::MakeMacroExpansionCursor(MacroExpansion *MI, |
| 619 | CXTranslationUnit TU) { |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 620 | CXCursor C = { CXCursor_MacroExpansion, 0, { MI, 0, TU } }; |
Douglas Gregor | 4807231 | 2010-03-18 15:23:44 +0000 | [diff] [blame] | 621 | return C; |
| 622 | } |
| 623 | |
Chandler Carruth | 9e5bb85 | 2011-07-14 08:20:46 +0000 | [diff] [blame] | 624 | MacroExpansion *cxcursor::getCursorMacroExpansion(CXCursor C) { |
Chandler Carruth | 9b2a0ac | 2011-07-14 08:41:15 +0000 | [diff] [blame] | 625 | assert(C.kind == CXCursor_MacroExpansion); |
Chandler Carruth | 9e5bb85 | 2011-07-14 08:20:46 +0000 | [diff] [blame] | 626 | return static_cast<MacroExpansion *>(C.data[0]); |
Douglas Gregor | 4807231 | 2010-03-18 15:23:44 +0000 | [diff] [blame] | 627 | } |
| 628 | |
Douglas Gregor | ecdcb88 | 2010-10-20 22:00:55 +0000 | [diff] [blame] | 629 | CXCursor cxcursor::MakeInclusionDirectiveCursor(InclusionDirective *ID, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 630 | CXTranslationUnit TU) { |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 631 | CXCursor C = { CXCursor_InclusionDirective, 0, { ID, 0, TU } }; |
Douglas Gregor | ecdcb88 | 2010-10-20 22:00:55 +0000 | [diff] [blame] | 632 | return C; |
| 633 | } |
| 634 | |
| 635 | InclusionDirective *cxcursor::getCursorInclusionDirective(CXCursor C) { |
| 636 | assert(C.kind == CXCursor_InclusionDirective); |
| 637 | return static_cast<InclusionDirective *>(C.data[0]); |
| 638 | } |
| 639 | |
Douglas Gregor | 36897b0 | 2010-09-10 00:22:18 +0000 | [diff] [blame] | 640 | CXCursor cxcursor::MakeCursorLabelRef(LabelStmt *Label, SourceLocation Loc, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 641 | CXTranslationUnit TU) { |
Douglas Gregor | 36897b0 | 2010-09-10 00:22:18 +0000 | [diff] [blame] | 642 | |
| 643 | assert(Label && TU && "Invalid arguments!"); |
| 644 | void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 645 | CXCursor C = { CXCursor_LabelRef, 0, { Label, RawLoc, TU } }; |
Douglas Gregor | 36897b0 | 2010-09-10 00:22:18 +0000 | [diff] [blame] | 646 | return C; |
| 647 | } |
| 648 | |
| 649 | std::pair<LabelStmt*, SourceLocation> |
| 650 | cxcursor::getCursorLabelRef(CXCursor C) { |
| 651 | assert(C.kind == CXCursor_LabelRef); |
| 652 | return std::make_pair(static_cast<LabelStmt *>(C.data[0]), |
| 653 | SourceLocation::getFromRawEncoding( |
| 654 | reinterpret_cast<uintptr_t>(C.data[1]))); |
| 655 | } |
| 656 | |
Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 657 | CXCursor cxcursor::MakeCursorOverloadedDeclRef(OverloadExpr *E, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 658 | CXTranslationUnit TU) { |
Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 659 | assert(E && TU && "Invalid arguments!"); |
| 660 | OverloadedDeclRefStorage Storage(E); |
| 661 | void *RawLoc = reinterpret_cast<void *>(E->getNameLoc().getRawEncoding()); |
| 662 | CXCursor C = { |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 663 | CXCursor_OverloadedDeclRef, 0, |
Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 664 | { Storage.getOpaqueValue(), RawLoc, TU } |
| 665 | }; |
| 666 | return C; |
| 667 | } |
| 668 | |
| 669 | CXCursor cxcursor::MakeCursorOverloadedDeclRef(Decl *D, |
| 670 | SourceLocation Loc, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 671 | CXTranslationUnit TU) { |
Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 672 | assert(D && TU && "Invalid arguments!"); |
| 673 | void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); |
| 674 | OverloadedDeclRefStorage Storage(D); |
| 675 | CXCursor C = { |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 676 | CXCursor_OverloadedDeclRef, 0, |
Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 677 | { Storage.getOpaqueValue(), RawLoc, TU } |
| 678 | }; |
| 679 | return C; |
| 680 | } |
| 681 | |
| 682 | CXCursor cxcursor::MakeCursorOverloadedDeclRef(TemplateName Name, |
| 683 | SourceLocation Loc, |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 684 | CXTranslationUnit TU) { |
Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 685 | assert(Name.getAsOverloadedTemplate() && TU && "Invalid arguments!"); |
| 686 | void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding()); |
| 687 | OverloadedDeclRefStorage Storage(Name.getAsOverloadedTemplate()); |
| 688 | CXCursor C = { |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 689 | CXCursor_OverloadedDeclRef, 0, |
Douglas Gregor | 1f60d9e | 2010-09-13 22:52:57 +0000 | [diff] [blame] | 690 | { Storage.getOpaqueValue(), RawLoc, TU } |
| 691 | }; |
| 692 | return C; |
| 693 | } |
| 694 | |
| 695 | std::pair<cxcursor::OverloadedDeclRefStorage, SourceLocation> |
| 696 | cxcursor::getCursorOverloadedDeclRef(CXCursor C) { |
| 697 | assert(C.kind == CXCursor_OverloadedDeclRef); |
| 698 | return std::make_pair(OverloadedDeclRefStorage::getFromOpaqueValue(C.data[0]), |
| 699 | SourceLocation::getFromRawEncoding( |
| 700 | reinterpret_cast<uintptr_t>(C.data[1]))); |
| 701 | } |
| 702 | |
Douglas Gregor | 283cae3 | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 703 | Decl *cxcursor::getCursorDecl(CXCursor Cursor) { |
| 704 | return (Decl *)Cursor.data[0]; |
| 705 | } |
| 706 | |
| 707 | Expr *cxcursor::getCursorExpr(CXCursor Cursor) { |
| 708 | return dyn_cast_or_null<Expr>(getCursorStmt(Cursor)); |
| 709 | } |
| 710 | |
| 711 | Stmt *cxcursor::getCursorStmt(CXCursor Cursor) { |
Douglas Gregor | 78db0cd | 2010-01-16 15:44:18 +0000 | [diff] [blame] | 712 | if (Cursor.kind == CXCursor_ObjCSuperClassRef || |
Douglas Gregor | 1adb082 | 2010-01-16 17:14:40 +0000 | [diff] [blame] | 713 | Cursor.kind == CXCursor_ObjCProtocolRef || |
| 714 | Cursor.kind == CXCursor_ObjCClassRef) |
Douglas Gregor | 2e331b9 | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 715 | return 0; |
| 716 | |
Douglas Gregor | 283cae3 | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 717 | return (Stmt *)Cursor.data[1]; |
| 718 | } |
| 719 | |
Ted Kremenek | 95f3355 | 2010-08-26 01:42:22 +0000 | [diff] [blame] | 720 | Attr *cxcursor::getCursorAttr(CXCursor Cursor) { |
| 721 | return (Attr *)Cursor.data[1]; |
| 722 | } |
| 723 | |
Argyrios Kyrtzidis | 8ccac3d | 2011-06-29 22:20:07 +0000 | [diff] [blame] | 724 | Decl *cxcursor::getCursorParentDecl(CXCursor Cursor) { |
| 725 | return (Decl *)Cursor.data[0]; |
| 726 | } |
| 727 | |
Douglas Gregor | f46034a | 2010-01-18 23:41:10 +0000 | [diff] [blame] | 728 | ASTContext &cxcursor::getCursorContext(CXCursor Cursor) { |
Douglas Gregor | b2cd487 | 2010-01-20 23:57:43 +0000 | [diff] [blame] | 729 | return getCursorASTUnit(Cursor)->getASTContext(); |
| 730 | } |
Douglas Gregor | f46034a | 2010-01-18 23:41:10 +0000 | [diff] [blame] | 731 | |
Douglas Gregor | b2cd487 | 2010-01-20 23:57:43 +0000 | [diff] [blame] | 732 | ASTUnit *cxcursor::getCursorASTUnit(CXCursor Cursor) { |
Ted Kremenek | a60ed47 | 2010-11-16 08:15:36 +0000 | [diff] [blame] | 733 | return static_cast<ASTUnit *>(static_cast<CXTranslationUnit>(Cursor.data[2]) |
| 734 | ->TUData); |
| 735 | } |
| 736 | |
| 737 | CXTranslationUnit cxcursor::getCursorTU(CXCursor Cursor) { |
| 738 | return static_cast<CXTranslationUnit>(Cursor.data[2]); |
Douglas Gregor | 283cae3 | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 739 | } |
| 740 | |
Argyrios Kyrtzidis | b11be04 | 2011-10-06 07:00:46 +0000 | [diff] [blame] | 741 | static void CollectOverriddenMethods(CXTranslationUnit TU, |
| 742 | DeclContext *Ctx, |
| 743 | ObjCMethodDecl *Method, |
| 744 | SmallVectorImpl<CXCursor> &Methods) { |
| 745 | if (!Ctx) |
| 746 | return; |
| 747 | |
| 748 | // If we have a class or category implementation, jump straight to the |
| 749 | // interface. |
| 750 | if (ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(Ctx)) |
| 751 | return CollectOverriddenMethods(TU, Impl->getClassInterface(), |
| 752 | Method, Methods); |
| 753 | |
| 754 | ObjCContainerDecl *Container = dyn_cast<ObjCContainerDecl>(Ctx); |
| 755 | if (!Container) |
| 756 | return; |
| 757 | |
| 758 | // Check whether we have a matching method at this level. |
| 759 | if (ObjCMethodDecl *Overridden = Container->getMethod(Method->getSelector(), |
| 760 | Method->isInstanceMethod())) |
| 761 | if (Method != Overridden) { |
| 762 | // We found an override at this level; there is no need to look |
| 763 | // into other protocols or categories. |
| 764 | Methods.push_back(MakeCXCursor(Overridden, TU)); |
| 765 | return; |
| 766 | } |
| 767 | |
| 768 | if (ObjCProtocolDecl *Protocol = dyn_cast<ObjCProtocolDecl>(Container)) { |
| 769 | for (ObjCProtocolDecl::protocol_iterator P = Protocol->protocol_begin(), |
| 770 | PEnd = Protocol->protocol_end(); |
| 771 | P != PEnd; ++P) |
| 772 | CollectOverriddenMethods(TU, *P, Method, Methods); |
| 773 | } |
| 774 | |
| 775 | if (ObjCCategoryDecl *Category = dyn_cast<ObjCCategoryDecl>(Container)) { |
| 776 | for (ObjCCategoryDecl::protocol_iterator P = Category->protocol_begin(), |
| 777 | PEnd = Category->protocol_end(); |
| 778 | P != PEnd; ++P) |
| 779 | CollectOverriddenMethods(TU, *P, Method, Methods); |
| 780 | } |
| 781 | |
| 782 | if (ObjCInterfaceDecl *Interface = dyn_cast<ObjCInterfaceDecl>(Container)) { |
| 783 | for (ObjCInterfaceDecl::protocol_iterator P = Interface->protocol_begin(), |
| 784 | PEnd = Interface->protocol_end(); |
| 785 | P != PEnd; ++P) |
| 786 | CollectOverriddenMethods(TU, *P, Method, Methods); |
| 787 | |
| 788 | for (ObjCCategoryDecl *Category = Interface->getCategoryList(); |
| 789 | Category; Category = Category->getNextClassCategory()) |
| 790 | CollectOverriddenMethods(TU, Category, Method, Methods); |
| 791 | |
| 792 | // We only look into the superclass if we haven't found anything yet. |
| 793 | if (Methods.empty()) |
| 794 | if (ObjCInterfaceDecl *Super = Interface->getSuperClass()) |
| 795 | return CollectOverriddenMethods(TU, Super, Method, Methods); |
| 796 | } |
| 797 | } |
| 798 | |
| 799 | void cxcursor::getOverriddenCursors(CXCursor cursor, |
| 800 | SmallVectorImpl<CXCursor> &overridden) { |
| 801 | if (!clang_isDeclaration(cursor.kind)) |
| 802 | return; |
| 803 | |
| 804 | Decl *D = getCursorDecl(cursor); |
| 805 | if (!D) |
| 806 | return; |
| 807 | |
| 808 | // Handle C++ member functions. |
| 809 | CXTranslationUnit TU = getCursorTU(cursor); |
| 810 | if (CXXMethodDecl *CXXMethod = dyn_cast<CXXMethodDecl>(D)) { |
| 811 | for (CXXMethodDecl::method_iterator |
| 812 | M = CXXMethod->begin_overridden_methods(), |
| 813 | MEnd = CXXMethod->end_overridden_methods(); |
| 814 | M != MEnd; ++M) |
| 815 | overridden.push_back(MakeCXCursor(const_cast<CXXMethodDecl*>(*M), TU)); |
| 816 | return; |
| 817 | } |
| 818 | |
| 819 | ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(D); |
| 820 | if (!Method) |
| 821 | return; |
| 822 | |
| 823 | // Handle Objective-C methods. |
| 824 | CollectOverriddenMethods(TU, Method->getDeclContext(), Method, overridden); |
| 825 | } |
| 826 | |
Argyrios Kyrtzidis | aed123e | 2011-10-06 07:00:54 +0000 | [diff] [blame] | 827 | std::pair<int, SourceLocation> |
| 828 | cxcursor::getSelectorIdentifierIndexAndLoc(CXCursor cursor) { |
| 829 | if (cursor.kind == CXCursor_ObjCMessageExpr) { |
| 830 | if (cursor.xdata != -1) |
| 831 | return std::make_pair(cursor.xdata, |
| 832 | cast<ObjCMessageExpr>(getCursorExpr(cursor)) |
| 833 | ->getSelectorLoc(cursor.xdata)); |
| 834 | } else if (cursor.kind == CXCursor_ObjCClassMethodDecl || |
| 835 | cursor.kind == CXCursor_ObjCInstanceMethodDecl) { |
| 836 | if (cursor.xdata != -1) |
| 837 | return std::make_pair(cursor.xdata, |
| 838 | cast<ObjCMethodDecl>(getCursorDecl(cursor)) |
| 839 | ->getSelectorLoc(cursor.xdata)); |
| 840 | } |
| 841 | |
| 842 | return std::make_pair(-1, SourceLocation()); |
| 843 | } |
| 844 | |
| 845 | CXCursor cxcursor::getSelectorIdentifierCursor(int SelIdx, CXCursor cursor) { |
| 846 | CXCursor newCursor = cursor; |
| 847 | |
| 848 | if (cursor.kind == CXCursor_ObjCMessageExpr) { |
| 849 | if (SelIdx == -1 || |
| 850 | unsigned(SelIdx) >= cast<ObjCMessageExpr>(getCursorExpr(cursor)) |
| 851 | ->getNumSelectorLocs()) |
| 852 | newCursor.xdata = -1; |
| 853 | else |
| 854 | newCursor.xdata = SelIdx; |
| 855 | } else if (cursor.kind == CXCursor_ObjCClassMethodDecl || |
| 856 | cursor.kind == CXCursor_ObjCInstanceMethodDecl) { |
| 857 | if (SelIdx == -1 || |
| 858 | unsigned(SelIdx) >= cast<ObjCMethodDecl>(getCursorDecl(cursor)) |
| 859 | ->getNumSelectorLocs()) |
| 860 | newCursor.xdata = -1; |
| 861 | else |
| 862 | newCursor.xdata = SelIdx; |
| 863 | } |
| 864 | |
| 865 | return newCursor; |
| 866 | } |
| 867 | |
| 868 | CXCursor cxcursor::getTypeRefCursor(CXCursor cursor) { |
| 869 | if (cursor.kind != CXCursor_CallExpr) |
| 870 | return cursor; |
| 871 | |
| 872 | if (cursor.xdata == 0) |
| 873 | return cursor; |
| 874 | |
| 875 | Expr *E = getCursorExpr(cursor); |
| 876 | TypeSourceInfo *Type = 0; |
| 877 | if (CXXUnresolvedConstructExpr * |
| 878 | UnCtor = dyn_cast<CXXUnresolvedConstructExpr>(E)) { |
| 879 | Type = UnCtor->getTypeSourceInfo(); |
| 880 | } else if (CXXTemporaryObjectExpr *Tmp = dyn_cast<CXXTemporaryObjectExpr>(E)){ |
| 881 | Type = Tmp->getTypeSourceInfo(); |
| 882 | } |
| 883 | |
| 884 | if (!Type) |
| 885 | return cursor; |
| 886 | |
| 887 | CXTranslationUnit TU = getCursorTU(cursor); |
| 888 | QualType Ty = Type->getType(); |
| 889 | TypeLoc TL = Type->getTypeLoc(); |
| 890 | SourceLocation Loc = TL.getBeginLoc(); |
| 891 | |
| 892 | if (const ElaboratedType *ElabT = Ty->getAs<ElaboratedType>()) { |
| 893 | Ty = ElabT->getNamedType(); |
| 894 | ElaboratedTypeLoc ElabTL = cast<ElaboratedTypeLoc>(TL); |
| 895 | Loc = ElabTL.getNamedTypeLoc().getBeginLoc(); |
| 896 | } |
| 897 | |
| 898 | if (const TypedefType *Typedef = Ty->getAs<TypedefType>()) |
| 899 | return MakeCursorTypeRef(Typedef->getDecl(), Loc, TU); |
| 900 | if (const TagType *Tag = Ty->getAs<TagType>()) |
| 901 | return MakeCursorTypeRef(Tag->getDecl(), Loc, TU); |
| 902 | if (const TemplateTypeParmType *TemplP = Ty->getAs<TemplateTypeParmType>()) |
| 903 | return MakeCursorTypeRef(TemplP->getDecl(), Loc, TU); |
| 904 | |
| 905 | return cursor; |
| 906 | } |
| 907 | |
Douglas Gregor | 283cae3 | 2010-01-15 21:56:13 +0000 | [diff] [blame] | 908 | bool cxcursor::operator==(CXCursor X, CXCursor Y) { |
| 909 | return X.kind == Y.kind && X.data[0] == Y.data[0] && X.data[1] == Y.data[1] && |
| 910 | X.data[2] == Y.data[2]; |
Douglas Gregor | 2e331b9 | 2010-01-16 14:00:32 +0000 | [diff] [blame] | 911 | } |
Ted Kremenek | 007a7c9 | 2010-11-01 23:26:51 +0000 | [diff] [blame] | 912 | |
| 913 | // FIXME: Remove once we can model DeclGroups and their appropriate ranges |
| 914 | // properly in the ASTs. |
| 915 | bool cxcursor::isFirstInDeclGroup(CXCursor C) { |
| 916 | assert(clang_isDeclaration(C.kind)); |
| 917 | return ((uintptr_t) (C.data[1])) != 0; |
| 918 | } |
| 919 | |
Ted Kremenek | eca099b | 2010-12-08 23:43:14 +0000 | [diff] [blame] | 920 | //===----------------------------------------------------------------------===// |
Argyrios Kyrtzidis | b0d6eaa | 2011-09-27 00:30:30 +0000 | [diff] [blame] | 921 | // libclang CXCursor APIs |
| 922 | //===----------------------------------------------------------------------===// |
| 923 | |
Argyrios Kyrtzidis | fa865df | 2011-09-27 04:14:36 +0000 | [diff] [blame] | 924 | extern "C" { |
| 925 | |
| 926 | int clang_Cursor_isNull(CXCursor cursor) { |
| 927 | return clang_equalCursors(cursor, clang_getNullCursor()); |
| 928 | } |
| 929 | |
Argyrios Kyrtzidis | b0d6eaa | 2011-09-27 00:30:30 +0000 | [diff] [blame] | 930 | CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor cursor) { |
| 931 | return getCursorTU(cursor); |
| 932 | } |
| 933 | |
Argyrios Kyrtzidis | fa865df | 2011-09-27 04:14:36 +0000 | [diff] [blame] | 934 | } // end: extern "C" |
| 935 | |
Argyrios Kyrtzidis | b0d6eaa | 2011-09-27 00:30:30 +0000 | [diff] [blame] | 936 | //===----------------------------------------------------------------------===// |
Ted Kremenek | eca099b | 2010-12-08 23:43:14 +0000 | [diff] [blame] | 937 | // CXCursorSet. |
| 938 | //===----------------------------------------------------------------------===// |
| 939 | |
| 940 | typedef llvm::DenseMap<CXCursor, unsigned> CXCursorSet_Impl; |
| 941 | |
| 942 | static inline CXCursorSet packCXCursorSet(CXCursorSet_Impl *setImpl) { |
| 943 | return (CXCursorSet) setImpl; |
| 944 | } |
| 945 | static inline CXCursorSet_Impl *unpackCXCursorSet(CXCursorSet set) { |
| 946 | return (CXCursorSet_Impl*) set; |
| 947 | } |
| 948 | namespace llvm { |
Ted Kremenek | da6fb69 | 2010-12-09 00:33:41 +0000 | [diff] [blame] | 949 | template<> struct DenseMapInfo<CXCursor> { |
Ted Kremenek | eca099b | 2010-12-08 23:43:14 +0000 | [diff] [blame] | 950 | public: |
| 951 | static inline CXCursor getEmptyKey() { |
| 952 | return MakeCXCursorInvalid(CXCursor_InvalidFile); |
| 953 | } |
| 954 | static inline CXCursor getTombstoneKey() { |
| 955 | return MakeCXCursorInvalid(CXCursor_NoDeclFound); |
| 956 | } |
| 957 | static inline unsigned getHashValue(const CXCursor &cursor) { |
| 958 | return llvm::DenseMapInfo<std::pair<void*,void*> > |
| 959 | ::getHashValue(std::make_pair(cursor.data[0], cursor.data[1])); |
| 960 | } |
| 961 | static inline bool isEqual(const CXCursor &x, const CXCursor &y) { |
| 962 | return x.kind == y.kind && |
| 963 | x.data[0] == y.data[0] && |
| 964 | x.data[1] == y.data[1]; |
| 965 | } |
| 966 | }; |
| 967 | } |
| 968 | |
| 969 | extern "C" { |
| 970 | CXCursorSet clang_createCXCursorSet() { |
| 971 | return packCXCursorSet(new CXCursorSet_Impl()); |
| 972 | } |
| 973 | |
| 974 | void clang_disposeCXCursorSet(CXCursorSet set) { |
| 975 | delete unpackCXCursorSet(set); |
| 976 | } |
| 977 | |
| 978 | unsigned clang_CXCursorSet_contains(CXCursorSet set, CXCursor cursor) { |
| 979 | CXCursorSet_Impl *setImpl = unpackCXCursorSet(set); |
| 980 | if (!setImpl) |
| 981 | return 0; |
| 982 | return setImpl->find(cursor) == setImpl->end(); |
| 983 | } |
| 984 | |
Anders Carlsson | e8b3de0 | 2010-12-09 01:00:12 +0000 | [diff] [blame] | 985 | unsigned clang_CXCursorSet_insert(CXCursorSet set, CXCursor cursor) { |
Ted Kremenek | eca099b | 2010-12-08 23:43:14 +0000 | [diff] [blame] | 986 | // Do not insert invalid cursors into the set. |
| 987 | if (cursor.kind >= CXCursor_FirstInvalid && |
| 988 | cursor.kind <= CXCursor_LastInvalid) |
| 989 | return 1; |
| 990 | |
| 991 | CXCursorSet_Impl *setImpl = unpackCXCursorSet(set); |
| 992 | if (!setImpl) |
| 993 | return 1; |
| 994 | unsigned &entry = (*setImpl)[cursor]; |
| 995 | unsigned flag = entry == 0 ? 1 : 0; |
| 996 | entry = 1; |
| 997 | return flag; |
| 998 | } |
Douglas Gregor | 8fa0a80 | 2011-08-04 20:04:59 +0000 | [diff] [blame] | 999 | |
| 1000 | CXCompletionString clang_getCursorCompletionString(CXCursor cursor) { |
| 1001 | enum CXCursorKind kind = clang_getCursorKind(cursor); |
| 1002 | if (clang_isDeclaration(kind)) { |
| 1003 | Decl *decl = getCursorDecl(cursor); |
| 1004 | if (isa<NamedDecl>(decl)) { |
| 1005 | NamedDecl *namedDecl = (NamedDecl *)decl; |
| 1006 | ASTUnit *unit = getCursorASTUnit(cursor); |
| 1007 | if (unit->hasSema()) { |
| 1008 | Sema &S = unit->getSema(); |
| 1009 | CodeCompletionAllocator *Allocator |
| 1010 | = unit->getCursorCompletionAllocator().getPtr(); |
| 1011 | CodeCompletionResult Result(namedDecl); |
| 1012 | CodeCompletionString *String |
| 1013 | = Result.CreateCodeCompletionString(S, *Allocator); |
| 1014 | return String; |
| 1015 | } |
| 1016 | } |
| 1017 | } |
| 1018 | else if (kind == CXCursor_MacroDefinition) { |
| 1019 | MacroDefinition *definition = getCursorMacroDefinition(cursor); |
| 1020 | const IdentifierInfo *MacroInfo = definition->getName(); |
| 1021 | ASTUnit *unit = getCursorASTUnit(cursor); |
| 1022 | if (unit->hasSema()) { |
| 1023 | Sema &S = unit->getSema(); |
| 1024 | CodeCompletionAllocator *Allocator |
| 1025 | = unit->getCursorCompletionAllocator().getPtr(); |
Douglas Gregor | eaf4fba | 2011-08-10 16:34:38 +0000 | [diff] [blame] | 1026 | CodeCompletionResult Result(const_cast<IdentifierInfo *>(MacroInfo)); |
Douglas Gregor | 8fa0a80 | 2011-08-04 20:04:59 +0000 | [diff] [blame] | 1027 | CodeCompletionString *String |
| 1028 | = Result.CreateCodeCompletionString(S, *Allocator); |
| 1029 | return String; |
| 1030 | } |
| 1031 | } |
| 1032 | return NULL; |
| 1033 | } |
| 1034 | |
Ted Kremenek | eca099b | 2010-12-08 23:43:14 +0000 | [diff] [blame] | 1035 | } // end: extern "C" |