This is an archive of the discontinued LLVM Phabricator instance.

[libclang] Return deduced type for auto type, not the one written in the source.
ClosedPublic

Authored by skalinichev on Aug 12 2015, 4:09 AM.

Details

Reviewers
klimek
akyrtzi
Summary

It used to work, but was accidentally broken by:

------------------------------------------------------------------------
r179769 | akirtzidis | 2013-04-18 20:41:15 +0400 (Thu, 18 Apr 2013) | 4 lines

[libclang] Report parameter array types as written in source, not decayed to pointer types.

Patch by Doug.
rdar://13684618
------------------------------------------------------------------------

The issue with decayed types was fixed by:

------------------------------------------------------------------------
r190796 | akirtzidis | 2013-09-16 21:26:23 +0400 (Mon, 16 Sep 2013) | 3 lines

[libclang] Don't report a DecayedType as "unexposed", report it as the original (as written) type.

Patch by Anders Waldenborg!
------------------------------------------------------------------------

So this patch partially reverts r179769, and adds more tests.

Test results (clang-test):
Expected Passes : 8287
Expected Failures : 13
Unsupported Tests : 142

This also fixes: https://llvm.org/bugs/show_bug.cgi?id=18669

Diff Detail

Event Timeline

skalinichev retitled this revision from to [libclang] Return deduced type for auto type, not the one written in the source..
skalinichev updated this object.
skalinichev added a reviewer: akyrtzi.
skalinichev added a subscriber: cfe-commits.
skalinichev updated this object.Aug 18 2015, 4:30 AM
kfunk added a subscriber: kfunk.Aug 20 2015, 3:56 AM

With this patch applied, class variables type is printed as <class>: http://i.imgur.com/CXHnjwJ.png

This is actually an unrelated issue (clang_getTypeDeclaration doesn't handle the auto type)

Using "c-index-test -test-print-type --std=c++14" on your example I get:
VarDecl=z ... [type=std::basic_string<char>] ...

So, as you can see, "z" has correct type.

Anyway here is a quick fix for clang_getTypeDeclaration (will create a review request for it later on): https://paste.kde.org/p1fiwhery

I can confirm that this patch fixes a number test cases found in ycmd (a code-completion server). Specifically these ones marked as 'sic'

So I'm in favour of this change :)

klimek accepted this revision.Aug 30 2015, 12:46 PM
klimek added a reviewer: klimek.
klimek added a subscriber: klimek.

As this doesn't break any old tests, and fixes a significant number of issues, LG.
Do you need me to submit?

This revision is now accepted and ready to land.Aug 30 2015, 12:46 PM

Yes, please submit it.

klimek closed this revision.Sep 3 2015, 9:13 AM

Submitted as r246778.

micbou added a subscriber: micbou.Nov 16 2015, 8:25 PM