[libclang] Restore old clang_Cursor_isAnonymous behaviour
authorIvan Donchevskii <yv.ivan@gmail.com>
Mon, 29 Apr 2019 13:44:07 +0000 (13:44 +0000)
committerIvan Donchevskii <yv.ivan@gmail.com>
Mon, 29 Apr 2019 13:44:07 +0000 (13:44 +0000)
commit50be573ed207baa477e209cf9e8b247ddd402bc5
tree779ac3518b92a420bbe4a1c9cb3f015cef7ab6ba
parent5a33047022ca4b7863be05b4be75678d5c0a44ee
[libclang] Restore old clang_Cursor_isAnonymous behaviour

D54996 Changed the behaviour of clang_Cursor_isAnonymous, but there is no alternative available to get the old behaviour in some cases, which is essential for determining if a record is syntactically accessible, e.g.

struct {
  int x;
  int y;
} foo;

struct {
  struct {
    int x;
    int y;
  };
} bar;

void fun(struct { int x; int y; } *param);
The only 'anonymous' struct here is the one nested in bar, since there is
no way to reference the struct itself, only the fields within. Though the
anonymity applies to the instance itself, not the type.

To avoid confusion, I have added a new function called clang_Cursor_isAnonymousRecordDecl
which has the old behaviour of clang_Cursor_isAnonymous (and updated the doc
for the latter as well, which was seemingly forgotten).

Patch by Jorn Vernee.

Differential Revision: https://reviews.llvm.org/D61232

llvm-svn: 359448
clang/include/clang-c/Index.h
clang/test/Index/print-type.c
clang/tools/c-index-test/c-index-test.c
clang/tools/libclang/CXType.cpp