]> granicus.if.org Git - clang/commit
[libclang] Fix cursors for functions with trailing return type
authorIvan Donchevskii <ivan.donchevskii@qt.io>
Wed, 3 Jan 2018 14:35:48 +0000 (14:35 +0000)
committerIvan Donchevskii <ivan.donchevskii@qt.io>
Wed, 3 Jan 2018 14:35:48 +0000 (14:35 +0000)
commit6387c4574ec668f75713af89c72cb8f37d8e3469
treee30269c308a8a730e840b8d5fdaa6f3626859942
parent9db9336933a8a29170ed23a0dafa2d53ceb399c8
[libclang] Fix cursors for functions with trailing return type

This one was rolled back as follow-up to the failing commit.
Second try.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321709 91177308-0d34-0410-b5e6-96231b3b80d8
test/Index/annotate-tokens.cpp
tools/libclang/CIndex.cpp