[clang][extract-api] Add support for typedefs
authorDaniel Grumberg <dgrumberg@apple.com>
Fri, 1 Apr 2022 18:14:23 +0000 (19:14 +0100)
committerDaniel Grumberg <dgrumberg@apple.com>
Wed, 6 Apr 2022 18:14:05 +0000 (19:14 +0100)
commit9fc45ca00a19336c0724631aa1b1985dd4f4d536
tree4c3464c52f2079530bccc5c34a14a7a97bcb6012
parent482fad4a3fcb013aa19e97661e3d66583d026bb8
[clang][extract-api] Add support for typedefs

Typedef records consist of the symbol associated with the underlying
TypedefDecl and a SymbolReference to the underlying type. Additionally
typedefs for anonymous TagTypes use the typedef'd name as the symbol
name in their respective records and USRs. As a result the declaration
fragments for the anonymous TagType are those for the associated
typedef. This means that when the user is defining a typedef to a
typedef to a anonymous type, we use a reference the anonymous TagType
itself and do not emit the typedef to the anonymous type in the
generated symbol graph, including in the type destination of further
typedef symbol records.

Differential Revision: https://reviews.llvm.org/D123019
13 files changed:
clang/include/clang/ExtractAPI/API.h
clang/include/clang/ExtractAPI/DeclarationFragments.h
clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
clang/lib/ExtractAPI/API.cpp
clang/lib/ExtractAPI/CMakeLists.txt
clang/lib/ExtractAPI/DeclarationFragments.cpp
clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
clang/lib/ExtractAPI/TypedefUnderlyingTypeResolver.cpp [new file with mode: 0644]
clang/lib/ExtractAPI/TypedefUnderlyingTypeResolver.h [new file with mode: 0644]
clang/test/ExtractAPI/typedef.c [new file with mode: 0644]
clang/test/ExtractAPI/typedef_anonymous_record.c [new file with mode: 0644]
clang/test/ExtractAPI/typedef_chain.c [new file with mode: 0644]