Author: hans Date: Wed Jan 3 06:20:15 2018 New Revision: 321708 URL: http://llvm.org/viewvc/llvm-project?rev=321708&view=rev Log: Revert r321697 "[libclang] Support querying whether a declaration is invalid" and follow-ups.
This broke test/Index/opencl-types.cl on several buildbots: http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/3294 http://lab.llvm.org:8011/builders/clang-ppc64be-linux-multistage/builds/6498 http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/5239 > [libclang] Support querying whether a declaration is invalid > > This is useful for e.g. highlighting purposes in an IDE. > > Patch by Nikolai Kosjar. > > Differential Revision: https://reviews.llvm.org/D40072 Also reverting follow-ups that otherwise caused conflicts for the revert: r321700 "Fix line endings." r321701 "Fix more line endings." r321698 "[libclang] Fix cursors for functions with trailing return type" > For the function declaration > > auto foo5(Foo) -> Foo; > the parameter tokens were mapped to cursors representing the > FunctionDecl: > > Keyword: "auto" [1:1 - 1:5] FunctionDecl=test5:1:6 > Identifier: "test5" [1:6 - 1:11] FunctionDecl=test5:1:6 > Punctuation: "(" [1:11 - 1:12] FunctionDecl=test5:1:6 > Identifier: "X" [1:12 - 1:13] FunctionDecl=test5:1:6 // Ops, not a TypeRef > Punctuation: ")" [1:13 - 1:14] FunctionDecl=test5:1:6 > Punctuation: "->" [1:15 - 1:17] FunctionDecl=test5:1:6 > Identifier: "X" [1:18 - 1:19] TypeRef=struct X:7:8 > Punctuation: ";" [1:19 - 1:20] > > Fix this by ensuring that the trailing return type is not visited as > first. > > Patch by Nikolai Kosjar. > > Differential Revision: https://reviews.llvm.org/D40561 Modified: cfe/trunk/include/clang-c/Index.h cfe/trunk/test/Index/annotate-tokens.cpp cfe/trunk/test/Index/print-type-size.cpp cfe/trunk/tools/c-index-test/c-index-test.c cfe/trunk/tools/libclang/CIndex.cpp cfe/trunk/tools/libclang/libclang.exports Modified: cfe/trunk/include/clang-c/Index.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=321708&r1=321707&r2=321708&view=diff ============================================================================== --- cfe/trunk/include/clang-c/Index.h (original) +++ cfe/trunk/include/clang-c/Index.h Wed Jan 3 06:20:15 2018 @@ -32,7 +32,7 @@ * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. */ #define CINDEX_VERSION_MAJOR 0 -#define CINDEX_VERSION_MINOR 46 +#define CINDEX_VERSION_MINOR 45 #define CINDEX_VERSION_ENCODE(major, minor) ( \ ((major) * 10000) \ @@ -2642,16 +2642,6 @@ CINDEX_LINKAGE enum CXCursorKind clang_g 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. * Modified: cfe/trunk/test/Index/annotate-tokens.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-tokens.cpp?rev=321708&r1=321707&r2=321708&view=diff ============================================================================== --- cfe/trunk/test/Index/annotate-tokens.cpp (original) +++ cfe/trunk/test/Index/annotate-tokens.cpp Wed Jan 3 06:20:15 2018 @@ -37,9 +37,7 @@ class C { ~C(); }; -auto test5(X) -> X; - -// RUN: c-index-test -test-annotate-tokens=%s:1:1:41:1 %s -std=c++14 -fno-delayed-template-parsing | FileCheck %s +// RUN: c-index-test -test-annotate-tokens=%s:1:1:38:1 %s -fno-delayed-template-parsing | FileCheck %s // CHECK: Keyword: "struct" [1:1 - 1:7] StructDecl=bonk:1:8 (Definition) // CHECK: Identifier: "bonk" [1:8 - 1:12] StructDecl=bonk:1:8 (Definition) // CHECK: Punctuation: "{" [1:13 - 1:14] StructDecl=bonk:1:8 (Definition) @@ -186,14 +184,6 @@ auto test5(X) -> X; // CHECK: Punctuation: "}" [29:22 - 29:23] CompoundStmt= // CHECK: Punctuation: "~" [37:3 - 37:4] CXXDestructor=~C:37:3 // CHECK: Identifier: "C" [37:4 - 37:5] CXXDestructor=~C:37:3 -// CHECK: Keyword: "auto" [40:1 - 40:5] FunctionDecl=test5:40:6 -// CHECK: Identifier: "test5" [40:6 - 40:11] FunctionDecl=test5:40:6 -// CHECK: Punctuation: "(" [40:11 - 40:12] FunctionDecl=test5:40:6 -// CHECK: Identifier: "X" [40:12 - 40:13] TypeRef=struct X:7:8 -// CHECK: Punctuation: ")" [40:13 - 40:14] FunctionDecl=test5:40:6 -// CHECK: Punctuation: "->" [40:15 - 40:17] FunctionDecl=test5:40:6 -// CHECK: Identifier: "X" [40:18 - 40:19] TypeRef=struct X:7:8 -// CHECK: Punctuation: ";" [40:19 - 40:20] // RUN: env LIBCLANG_DISABLE_CRASH_RECOVERY=1 c-index-test -test-annotate-tokens=%s:32:1:32:13 %s | FileCheck %s -check-prefix=CHECK2 // CHECK2: Keyword: "if" [32:3 - 32:5] IfStmt= Modified: cfe/trunk/test/Index/print-type-size.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type-size.cpp?rev=321708&r1=321707&r2=321708&view=diff ============================================================================== --- cfe/trunk/test/Index/print-type-size.cpp (original) +++ cfe/trunk/test/Index/print-type-size.cpp Wed Jan 3 06:20:15 2018 @@ -4,8 +4,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] +// 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] Modified: cfe/trunk/tools/c-index-test/c-index-test.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=321708&r1=321707&r2=321708&view=diff ============================================================================== --- cfe/trunk/tools/c-index-test/c-index-test.c (original) +++ cfe/trunk/tools/c-index-test/c-index-test.c Wed Jan 3 06:20:15 2018 @@ -812,8 +812,6 @@ static void PrintCursor(CXCursor Cursor, printf(" (variadic)"); if (clang_Cursor_isObjCOptional(Cursor)) printf(" (@optional)"); - if (clang_isInvalidDeclaration(Cursor)) - printf(" (invalid)"); switch (clang_getCursorExceptionSpecificationType(Cursor)) { Modified: cfe/trunk/tools/libclang/CIndex.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=321708&r1=321707&r2=321708&view=diff ============================================================================== --- cfe/trunk/tools/libclang/CIndex.cpp (original) +++ cfe/trunk/tools/libclang/CIndex.cpp Wed Jan 3 06:20:15 2018 @@ -785,16 +785,6 @@ bool CursorVisitor::VisitDeclaratorDecl( return false; } -static bool HasTrailingReturnType(FunctionDecl *ND) { - const QualType Ty = ND->getType(); - if (const FunctionType *AFT = Ty->getAs<FunctionType>()) { - if (const FunctionProtoType *FT = dyn_cast<FunctionProtoType>(AFT)) - return FT->hasTrailingReturn(); - } - - return false; -} - /// \brief Compare two base or member initializers based on their source order. static int CompareCXXCtorInitializers(CXXCtorInitializer *const *X, CXXCtorInitializer *const *Y) { @@ -814,16 +804,14 @@ bool CursorVisitor::VisitFunctionDecl(Fu // written. This requires a bit of work. TypeLoc TL = TSInfo->getTypeLoc().IgnoreParens(); FunctionTypeLoc FTL = TL.getAs<FunctionTypeLoc>(); - const bool HasTrailingRT = HasTrailingReturnType(ND); // If we have a function declared directly (without the use of a typedef), // visit just the return type. Otherwise, just visit the function's type // now. - if ((FTL && !isa<CXXConversionDecl>(ND) && !HasTrailingRT && - Visit(FTL.getReturnLoc())) || + if ((FTL && !isa<CXXConversionDecl>(ND) && Visit(FTL.getReturnLoc())) || (!FTL && Visit(TL))) return true; - + // Visit the nested-name-specifier, if present. if (NestedNameSpecifierLoc QualifierLoc = ND->getQualifierLoc()) if (VisitNestedNameSpecifierLoc(QualifierLoc)) @@ -839,11 +827,7 @@ bool CursorVisitor::VisitFunctionDecl(Fu // Visit the function parameters, if we have a function type. if (FTL && VisitFunctionTypeLoc(FTL, true)) return true; - - // Visit the function's trailing return type. - if (FTL && HasTrailingRT && Visit(FTL.getReturnLoc())) - return true; - + // FIXME: Attributes? } @@ -5437,15 +5421,6 @@ unsigned clang_isDeclaration(enum CXCurs (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; } Modified: cfe/trunk/tools/libclang/libclang.exports URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.exports?rev=321708&r1=321707&r2=321708&view=diff ============================================================================== --- cfe/trunk/tools/libclang/libclang.exports (original) +++ cfe/trunk/tools/libclang/libclang.exports Wed Jan 3 06:20:15 2018 @@ -288,13 +288,12 @@ clang_index_isEntityObjCContainerKind clang_index_setClientContainer clang_index_setClientEntity clang_isAttribute -clang_isConstQualifiedType -clang_isCursorDefinition -clang_isDeclaration -clang_isInvalidDeclaration -clang_isExpression -clang_isFileMultipleIncludeGuarded -clang_isFunctionTypeVariadic +clang_isConstQualifiedType +clang_isCursorDefinition +clang_isDeclaration +clang_isExpression +clang_isFileMultipleIncludeGuarded +clang_isFunctionTypeVariadic clang_isInvalid clang_isPODType clang_isPreprocessing _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits