diff options
author | Alex Lorenz <arphaman@gmail.com> | 2017-07-12 11:35:11 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2017-07-12 11:35:11 +0000 |
commit | 62dd545c92378c52cf04667f5432c837380eb239 (patch) | |
tree | e20340fae07a278e7a5538fe357560e8b78a29f6 /tools | |
parent | 2159be8cd5189f34b2f4dbca32e59a83d27e7ced (diff) |
[libclang] Support for querying whether an enum is scoped
This commit allows checking whether an enum declaration is scoped
through libclang and clang.cindex (Python).
Patch by Johann Klähn!
Differential Revision: https://reviews.llvm.org/D35187
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307771 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/c-index-test/c-index-test.c | 2 | ||||
-rw-r--r-- | tools/libclang/CIndex.cpp | 9 | ||||
-rw-r--r-- | tools/libclang/libclang.exports | 1 |
3 files changed, 12 insertions, 0 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c index 1e925569dd..cf3581e259 100644 --- a/tools/c-index-test/c-index-test.c +++ b/tools/c-index-test/c-index-test.c @@ -804,6 +804,8 @@ static void PrintCursor(CXCursor Cursor, const char *CommentSchemaFile) { printf(" (const)"); if (clang_CXXMethod_isPureVirtual(Cursor)) printf(" (pure)"); + if (clang_EnumDecl_isScoped(Cursor)) + printf(" (scoped)"); if (clang_Cursor_isVariadic(Cursor)) printf(" (variadic)"); if (clang_Cursor_isObjCOptional(Cursor)) diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 2cbca421c7..236f264c17 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -7807,6 +7807,15 @@ unsigned clang_CXXMethod_isVirtual(CXCursor C) { return (Method && Method->isVirtual()) ? 1 : 0; } +unsigned clang_EnumDecl_isScoped(CXCursor C) { + if (!clang_isDeclaration(C.kind)) + return 0; + + const Decl *D = cxcursor::getCursorDecl(C); + auto *Enum = dyn_cast_or_null<EnumDecl>(D); + return (Enum && Enum->isScoped()) ? 1 : 0; +} + //===----------------------------------------------------------------------===// // Attribute introspection. //===----------------------------------------------------------------------===// diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports index e78899e4c7..e0d178a529 100644 --- a/tools/libclang/libclang.exports +++ b/tools/libclang/libclang.exports @@ -12,6 +12,7 @@ clang_CXXMethod_isConst clang_CXXMethod_isPureVirtual clang_CXXMethod_isStatic clang_CXXMethod_isVirtual +clang_EnumDecl_isScoped clang_Cursor_getArgument clang_Cursor_getNumTemplateArguments clang_Cursor_getTemplateArgumentKind |