mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-03-02 23:50:19 +00:00
libclang: add a function to check whether a member function is pure virtual
Patch by Seth Fowler. llvm-svn: 182139
This commit is contained in:
parent
858885578d
commit
62770bea4b
@ -2590,6 +2590,10 @@ functionList = [
|
||||
[Index, c_char_p],
|
||||
c_object_p),
|
||||
|
||||
("clang_CXXMethod_isPureVirtual",
|
||||
[Cursor],
|
||||
bool),
|
||||
|
||||
("clang_CXXMethod_isStatic",
|
||||
[Cursor],
|
||||
bool),
|
||||
|
@ -4034,6 +4034,12 @@ CINDEX_LINKAGE CXString clang_FullComment_getAsXML(CXComment Comment);
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Determine if a C++ member function or member function template is
|
||||
* pure virtual.
|
||||
*/
|
||||
CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C);
|
||||
|
||||
/**
|
||||
* \brief Determine if a C++ member function or member function template is
|
||||
* declared 'static'.
|
||||
|
@ -17,7 +17,14 @@ struct D : C {
|
||||
|
||||
void C::g() {}
|
||||
|
||||
struct E {
|
||||
virtual void h() = 0;
|
||||
template <typename T> void i(T);
|
||||
};
|
||||
|
||||
// RUN: c-index-test -test-load-source local %s | FileCheck %s
|
||||
// CHECK: overrides.cpp:11:16: CXXMethod=g:11:16 (virtual) [Overrides @7:16] Extent=[11:3 - 11:19]
|
||||
// CHECK: overrides.cpp:15:16: CXXMethod=f:15:16 (virtual) [Overrides @2:16, @6:16] Extent=[15:3 - 15:22]
|
||||
// CHECK: overrides.cpp:18:9: CXXMethod=g:18:9 (Definition) (virtual) [Overrides @7:16] Extent=[18:1 - 18:15]
|
||||
// CHECK: overrides.cpp:21:16: CXXMethod=h:21:16 (virtual) (pure) Extent=[21:3 - 21:23]
|
||||
// CHECK: overrides.cpp:22:30: FunctionTemplate=i:22:30 Extent=[22:3 - 22:34]
|
||||
|
@ -694,7 +694,8 @@ static void PrintCursor(CXCursor Cursor,
|
||||
printf(" (static)");
|
||||
if (clang_CXXMethod_isVirtual(Cursor))
|
||||
printf(" (virtual)");
|
||||
|
||||
if (clang_CXXMethod_isPureVirtual(Cursor))
|
||||
printf(" (pure)");
|
||||
if (clang_Cursor_isVariadic(Cursor))
|
||||
printf(" (variadic)");
|
||||
|
||||
|
@ -6118,6 +6118,20 @@ CXFile clang_Module_getTopLevelHeader(CXTranslationUnit TU,
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
extern "C" {
|
||||
unsigned clang_CXXMethod_isPureVirtual(CXCursor C) {
|
||||
if (!clang_isDeclaration(C.kind))
|
||||
return 0;
|
||||
|
||||
const CXXMethodDecl *Method = 0;
|
||||
const Decl *D = cxcursor::getCursorDecl(C);
|
||||
if (const FunctionTemplateDecl *FunTmpl =
|
||||
dyn_cast_or_null<FunctionTemplateDecl>(D))
|
||||
Method = dyn_cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl());
|
||||
else
|
||||
Method = dyn_cast_or_null<CXXMethodDecl>(D);
|
||||
return (Method && Method->isVirtual() && Method->isPure()) ? 1 : 0;
|
||||
}
|
||||
|
||||
unsigned clang_CXXMethod_isStatic(CXCursor C) {
|
||||
if (!clang_isDeclaration(C.kind))
|
||||
return 0;
|
||||
|
@ -2,6 +2,7 @@ clang_CXCursorSet_contains
|
||||
clang_CXCursorSet_insert
|
||||
clang_CXIndex_getGlobalOptions
|
||||
clang_CXIndex_setGlobalOptions
|
||||
clang_CXXMethod_isPureVirtual
|
||||
clang_CXXMethod_isStatic
|
||||
clang_CXXMethod_isVirtual
|
||||
clang_Cursor_getArgument
|
||||
|
Loading…
x
Reference in New Issue
Block a user