diff options
author | Hans Wennborg <hans@hanshq.net> | 2018-01-03 14:20:15 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2018-01-03 14:20:15 +0000 |
commit | fff458994e39cc8c1d5021e138ac45c25c286fe8 (patch) | |
tree | 6e3f6b049bf041e8c1bf86d3aada3dae0dbc97c9 /clang/tools/libclang/CIndex.cpp | |
parent | 46db78b74353f6976d4a8293f93ab51ef7fae550 (diff) | |
download | bcm5719-llvm-fff458994e39cc8c1d5021e138ac45c25c286fe8.tar.gz bcm5719-llvm-fff458994e39cc8c1d5021e138ac45c25c286fe8.zip |
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
llvm-svn: 321708
Diffstat (limited to 'clang/tools/libclang/CIndex.cpp')
-rw-r--r-- | clang/tools/libclang/CIndex.cpp | 31 |
1 files changed, 3 insertions, 28 deletions
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index 429fca34744..f4d347108c9 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -785,16 +785,6 @@ bool CursorVisitor::VisitDeclaratorDecl(DeclaratorDecl *DD) { 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(FunctionDecl *ND) { // 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(FunctionDecl *ND) { // 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 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; } |