Ted Kremenek | 585b318 | 2010-08-27 21:57:20 +0000 | [diff] [blame] | 1 | //===- CIndexCXX.cpp - Clang-C Source Indexing Library --------------------===// |
| 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 | // |
| 10 | // This file implements the libclang support for C++ cursors. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "CIndexer.h" |
| 15 | #include "CXCursor.h" |
| 16 | #include "CXType.h" |
| 17 | #include "clang/AST/DeclCXX.h" |
| 18 | |
| 19 | using namespace clang; |
| 20 | using namespace clang::cxstring; |
| 21 | |
| 22 | extern "C" { |
| 23 | |
| 24 | unsigned clang_isVirtualBase(CXCursor C) { |
| 25 | if (C.kind != CXCursor_CXXBaseSpecifier) |
| 26 | return 0; |
| 27 | |
| 28 | CXXBaseSpecifier *B = cxcursor::getCursorCXXBaseSpecifier(C); |
| 29 | return B->isVirtual(); |
| 30 | } |
| 31 | |
| 32 | enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor C) { |
| 33 | if (C.kind != CXCursor_CXXBaseSpecifier) |
| 34 | return CX_CXXInvalidAccessSpecifier; |
| 35 | |
| 36 | CXXBaseSpecifier *B = cxcursor::getCursorCXXBaseSpecifier(C); |
| 37 | switch (B->getAccessSpecifier()) { |
| 38 | case AS_public: return CX_CXXPublic; |
| 39 | case AS_protected: return CX_CXXProtected; |
| 40 | case AS_private: return CX_CXXPrivate; |
| 41 | case AS_none: return CX_CXXInvalidAccessSpecifier; |
| 42 | } |
| 43 | |
| 44 | // FIXME: Clang currently thinks this is reachable. |
| 45 | return CX_CXXInvalidAccessSpecifier; |
| 46 | } |
| 47 | |
| 48 | } // end extern "C" |