Index: include/clang-c/Index.h =================================================================== --- include/clang-c/Index.h +++ include/clang-c/Index.h @@ -29,13 +29,13 @@ * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes. * * The policy about the libclang API was always to keep it source and ABI - * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. - */ -#define CINDEX_VERSION_MAJOR 0 -#define CINDEX_VERSION_MINOR 45 - -#define CINDEX_VERSION_ENCODE(major, minor) ( \ - ((major) * 10000) \ + * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. + */ +#define CINDEX_VERSION_MAJOR 0 +#define CINDEX_VERSION_MINOR 46 + +#define CINDEX_VERSION_ENCODE(major, minor) ( \ + ((major) * 10000) \ + ((minor) * 1)) #define CINDEX_VERSION CINDEX_VERSION_ENCODE( \ @@ -2638,12 +2638,22 @@ /** * \brief Determine whether the given cursor kind represents a declaration. - */ -CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); - -/** - * \brief Determine whether the given cursor kind represents a simple - * reference. + */ +CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); + +/** + * \brief Determine whether the given declaration is invalid. + * + * A declaration is invalid if it could not be parsed successfully. + * + * \returns non-zero if the cursor represents a declaration and it is + * invalid, otherwise NULL. + */ +CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor); + +/** + * \brief Determine whether the given cursor kind represents a simple + * reference. * * Note that other kinds of cursors (such as expressions) can also refer to * other cursors. Use clang_getCursorReferenced() to determine whether a Index: test/Index/print-type-size.cpp =================================================================== --- test/Index/print-type-size.cpp +++ test/Index/print-type-size.cpp @@ -1,14 +1,14 @@ // from SemaCXX/class-layout.cpp // RUN: c-index-test -test-print-type-size %s -target x86_64-pc-linux-gnu | FileCheck -check-prefix=CHECK64 %s // RUN: c-index-test -test-print-type-size %s -target i386-apple-darwin9 | FileCheck -check-prefix=CHECK32 %s - -namespace basic { - -// CHECK64: VarDecl=v:[[@LINE+2]]:6 (Definition) [type=void] [typekind=Void] -// CHECK32: VarDecl=v:[[@LINE+1]]:6 (Definition) [type=void] [typekind=Void] -void v; - -// CHECK64: VarDecl=v1:[[@LINE+2]]:7 (Definition) [type=void *] [typekind=Pointer] [sizeof=8] [alignof=8] + +namespace basic { + +// CHECK64: VarDecl=v:[[@LINE+2]]:6 (Definition) (invalid) [type=void] [typekind=Void] +// CHECK32: VarDecl=v:[[@LINE+1]]:6 (Definition) (invalid) [type=void] [typekind=Void] +void v; + +// CHECK64: VarDecl=v1:[[@LINE+2]]:7 (Definition) [type=void *] [typekind=Pointer] [sizeof=8] [alignof=8] // CHECK32: VarDecl=v1:[[@LINE+1]]:7 (Definition) [type=void *] [typekind=Pointer] [sizeof=4] [alignof=4] void *v1; Index: tools/c-index-test/c-index-test.c =================================================================== --- tools/c-index-test/c-index-test.c +++ tools/c-index-test/c-index-test.c @@ -809,12 +809,14 @@ if (clang_EnumDecl_isScoped(Cursor)) printf(" (scoped)"); if (clang_Cursor_isVariadic(Cursor)) - printf(" (variadic)"); - if (clang_Cursor_isObjCOptional(Cursor)) - printf(" (@optional)"); - - switch (clang_getCursorExceptionSpecificationType(Cursor)) - { + printf(" (variadic)"); + if (clang_Cursor_isObjCOptional(Cursor)) + printf(" (@optional)"); + if (clang_isInvalidDeclaration(Cursor)) + printf(" (invalid)"); + + switch (clang_getCursorExceptionSpecificationType(Cursor)) + { case CXCursor_ExceptionSpecificationKind_None: break; Index: tools/libclang/CIndex.cpp =================================================================== --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -5418,12 +5418,21 @@ unsigned clang_isDeclaration(enum CXCursorKind K) { return (K >= CXCursor_FirstDecl && K <= CXCursor_LastDecl) || - (K >= CXCursor_FirstExtraDecl && K <= CXCursor_LastExtraDecl); -} - -unsigned clang_isReference(enum CXCursorKind K) { - return K >= CXCursor_FirstRef && K <= CXCursor_LastRef; -} + (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; +} unsigned clang_isExpression(enum CXCursorKind K) { return K >= CXCursor_FirstExpr && K <= CXCursor_LastExpr; Index: tools/libclang/libclang.exports =================================================================== --- tools/libclang/libclang.exports +++ tools/libclang/libclang.exports @@ -288,12 +288,13 @@ clang_index_setClientContainer clang_index_setClientEntity clang_isAttribute -clang_isConstQualifiedType -clang_isCursorDefinition -clang_isDeclaration -clang_isExpression -clang_isFileMultipleIncludeGuarded -clang_isFunctionTypeVariadic +clang_isConstQualifiedType +clang_isCursorDefinition +clang_isDeclaration +clang_isInvalidDeclaration +clang_isExpression +clang_isFileMultipleIncludeGuarded +clang_isFunctionTypeVariadic clang_isInvalid clang_isPODType clang_isPreprocessing