diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2018-04-17 09:19:48 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2018-04-19 12:43:14 +0000 |
commit | ae67eb7103b782deb5dda308e19d6f8e68e31ae2 (patch) | |
tree | e1b5fe90dac948468cbe564977efeac8c88219a9 /tools | |
parent | 0e746072ed897a85b4f533ab050b9f506941a097 (diff) |
[backported/clang-7][libclang] Support querying whether a declaration is invalid
------------------------------------------------------------------------
* Enables fix for https://bugreports.qt.io/browse/QTCREATORBUG-18686
------------------------------------------------------------------------
This is useful for e.g. highlighting purposes in an IDE.
Note: First version of this patch was reverted due to failing tests in
opencl-types.cl with -target ppc64le-unknown-linux. These tests are
adapted now.
Patch by Nikolai Kosjar.
Differential Revision: https://reviews.llvm.org/D40072
Change-Id: Iac9d51f729bda7493c56d4d14f9bc1ff2891b465
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
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 99f05669b6..c5e345ef6a 100644 --- a/tools/c-index-test/c-index-test.c +++ b/tools/c-index-test/c-index-test.c @@ -812,6 +812,8 @@ static void PrintCursor(CXCursor Cursor, const char *CommentSchemaFile) { printf(" (variadic)"); if (clang_Cursor_isObjCOptional(Cursor)) printf(" (@optional)"); + if (clang_isInvalidDeclaration(Cursor)) + printf(" (invalid)"); switch (clang_getCursorExceptionSpecificationType(Cursor)) { diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 66b6edc8b1..429fca3474 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -5437,6 +5437,15 @@ unsigned clang_isDeclaration(enum CXCursorKind K) { (K >= CXCursor_FirstExtraDecl && K <= CXCursor_LastExtraDecl); } +unsigned clang_isInvalidDeclaration(CXCursor C) { + if (clang_isDeclaration(C.kind)) { + if (const Decl *D = getCursorDecl(C)) + return D->isInvalidDecl(); + } + + return 0; +} + unsigned clang_isReference(enum CXCursorKind K) { return K >= CXCursor_FirstRef && K <= CXCursor_LastRef; } diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports index bf95b97073..5d1b0224ef 100644 --- a/tools/libclang/libclang.exports +++ b/tools/libclang/libclang.exports @@ -291,6 +291,7 @@ clang_isAttribute clang_isConstQualifiedType clang_isCursorDefinition clang_isDeclaration +clang_isInvalidDeclaration clang_isExpression clang_isFileMultipleIncludeGuarded clang_isFunctionTypeVariadic |