diff options
author | Daniel Grumberg <dgrumberg@apple.com> | 2024-04-24 13:53:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-24 13:53:29 +0100 |
commit | 2bcbe40f8a1c6cc9a256711261d8aa8fde50f7b3 (patch) | |
tree | 20b6d18e90f5514502d98c84879182e8143d3973 /clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp | |
parent | d3f6c2c5a76ed4eafd1ef76bd64cb01c8934c914 (diff) | |
download | llvm-2bcbe40f8a1c6cc9a256711261d8aa8fde50f7b3.zip llvm-2bcbe40f8a1c6cc9a256711261d8aa8fde50f7b3.tar.gz llvm-2bcbe40f8a1c6cc9a256711261d8aa8fde50f7b3.tar.bz2 |
[clang][ExtractAPI] Fix handling of anonymous TagDecls (#87772)
This changes the handling of anonymous TagDecls to the following rules:
- If the TagDecl is embedded in the declaration for some VarDecl (this
is the only possibility for RecordDecls), then pretend the child decls
belong to the VarDecl
- If it's an EnumDecl proceed as we did previously, i.e., embed it in
the enclosing DeclContext.
Additionally this fixes a few issues with declaration fragments not
consistently including "{ ... }" for anonymous TagDecls. To make testing
these additions easier this patch fixes some text declaration fragments
merging issues and updates tests accordingly.
rdar://121436298
Diffstat (limited to 'clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp')
-rw-r--r-- | clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp index 8b1dcb4..34278b5 100644 --- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp +++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp @@ -667,6 +667,14 @@ bool SymbolGraphSerializer::shouldSkip(const APIRecord *Record) const { if (Record->Availability.isUnconditionallyUnavailable()) return true; + // Filter out symbols without a name as we can generate correct symbol graphs + // for them. In practice these are anonymous record types that aren't attached + // to a declaration. + if (auto *Tag = dyn_cast<TagRecord>(Record)) { + if (Tag->IsEmbeddedInVarDeclarator) + return true; + } + // Filter out symbols prefixed with an underscored as they are understood to // be symbols clients should not use. if (Record->Name.starts_with("_")) |