From b5cdfa3d5f448b40fb9a8f2316d40adbe7bbd888 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Mon, 6 Oct 2025 17:17:31 -0300 Subject: [PATCH] don't mark unnamed classes as implementation defined These classes can appear as user written code and needs to be documented, as show in the new test case. In general, for implementation defined declarations, we can detect them as the clang AST exposes them as 'implicit', but this is possible for any declaration, and can be handled more generally. The new included exposes a different bug, where we don't attach the documentation provided for each member in a declarator, which clang does expose in the AST, but we seem to be ignoring it. Fixes #1035 --- src/lib/AST/ASTVisitor.cpp | 9 - .../golden-tests/symbols/record/unnamed.adoc | 123 ++++++++++++- .../golden-tests/symbols/record/unnamed.cpp | 10 ++ .../golden-tests/symbols/record/unnamed.html | 162 +++++++++++++++++- .../golden-tests/symbols/record/unnamed.xml | 42 +++++ 5 files changed, 333 insertions(+), 13 deletions(-) diff --git a/src/lib/AST/ASTVisitor.cpp b/src/lib/AST/ASTVisitor.cpp index bee3cd80f..a33826061 100644 --- a/src/lib/AST/ASTVisitor.cpp +++ b/src/lib/AST/ASTVisitor.cpp @@ -644,15 +644,6 @@ populate( RecordInfo& I, CXXRecordDecl const* D) { - // Unnamed structs and classes are implementation-defined - // or dependencies at best. There are never pages for them. - if (D->getIdentifier() == nullptr) - { - I.Extraction = mostSpecific( - ExtractionMode::ImplementationDefined, - I.Extraction); - } - if (D->getTypedefNameForAnonDecl()) { I.IsTypeDef = true; diff --git a/test-files/golden-tests/symbols/record/unnamed.adoc b/test-files/golden-tests/symbols/record/unnamed.adoc index d236692ff..ded90cd2b 100644 --- a/test-files/golden-tests/symbols/record/unnamed.adoc +++ b/test-files/golden-tests/symbols/record/unnamed.adoc @@ -4,13 +4,102 @@ [#index] == Global namespace +=== Types + +[cols=2] +|=== +| Name +| Description +| link:#_01record-01[`Unnamed struct`] +| +| link:#_01record-0f[`Unnamed struct`] +| A test unnamed class. +|=== + === Variables -[cols=1] +[cols=2] |=== | Name +| Description | link:#F[`F`] +| +| link:#x[`x`] +| A test variable named 'x' +| link:#y[`y`] +| A test variable named 'y' +|=== + +[#_01record-01] +== Unnamed struct + +=== Synopsis + +Declared in `<unnamed.cpp>` + +[source,cpp,subs="verbatim,replacements,macros,-callouts"] +---- +struct Unnamed struct; +---- + +=== Member Functions + +[cols=1] |=== +| Name +| link:#_01record-01-operator_call[`operator()`] +|=== + +[#_01record-01-operator_call] +== operator() + +=== Synopsis + +Declared in `<unnamed.cpp>` + +[source,cpp,subs="verbatim,replacements,macros,-callouts"] +---- +void +operator()() const; +---- + +[#_01record-0f] +== Unnamed struct + +A test unnamed class. + +=== Synopsis + +Declared in `<unnamed.cpp>` + +[source,cpp,subs="verbatim,replacements,macros,-callouts"] +---- +struct Unnamed struct; +---- + +=== Data Members + +[cols=2] +|=== +| Name +| Description +| link:#_01record-0f-a[`a`] +| A test field. +|=== + +[#_01record-0f-a] +== a + +A test field. + +=== Synopsis + +Declared in `<unnamed.cpp>` + +[source,cpp,subs="verbatim,replacements,macros,-callouts"] +---- +int a; +---- [#F] == F @@ -21,7 +110,37 @@ Declared in `<unnamed.cpp>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- -constexpr /* implementation-defined */ F = {}; +constexpr link:#_01record-01[] F = {}; +---- + +[#x] +== x + +A test variable named 'x' + +=== Synopsis + +Declared in `<unnamed.cpp>` + +[source,cpp,subs="verbatim,replacements,macros,-callouts"] +---- +extern +link:#_01record-0f[] x; +---- + +[#y] +== y + +A test variable named 'y' + +=== Synopsis + +Declared in `<unnamed.cpp>` + +[source,cpp,subs="verbatim,replacements,macros,-callouts"] +---- +extern +link:#_01record-0f[] y; ---- diff --git a/test-files/golden-tests/symbols/record/unnamed.cpp b/test-files/golden-tests/symbols/record/unnamed.cpp index 709c287a3..69efc0af5 100644 --- a/test-files/golden-tests/symbols/record/unnamed.cpp +++ b/test-files/golden-tests/symbols/record/unnamed.cpp @@ -2,3 +2,13 @@ constexpr struct { void operator()() const; } const F{}; + +/// A test unnamed class. +extern struct { + /// A test field. + int a; +} + /// A test variable named 'x' + x, + /// A test variable named 'y' + y; diff --git a/test-files/golden-tests/symbols/record/unnamed.html b/test-files/golden-tests/symbols/record/unnamed.html index be2bd36c9..161447e57 100644 --- a/test-files/golden-tests/symbols/record/unnamed.html +++ b/test-files/golden-tests/symbols/record/unnamed.html @@ -9,19 +9,137 @@

Reference

+

Types

+ + + + + + + + + + + + +
NameDescription
Unnamed struct
Unnamed struct A test unnamed class.
+

Variables

+ + + + + + + + + +
NameDescription
F
x A test variable named 'x'
y A test variable named 'y'
+ + +
+
+

+
+
+

Synopsis

+
+Declared in <unnamed.cpp>
+
+struct Unnamed struct;
+
+
+
+
+

Member Functions

+ + + + - +
Name
F
operator()
+ + +
+
+
+

::operator()

+
+
+

Synopsis

+
+Declared in <unnamed.cpp>
+
+void
+operator()() const;
+
+
+
+
+
+
+
+

+
+A test unnamed class. + +
+
+
+

Synopsis

+
+Declared in <unnamed.cpp>
+
+struct Unnamed struct;
+
+
+
+
+

Data Members

+ + + + + + + + + + + +
NameDescription
a A test field.
+ + + +
+
+
+

::a

+
+A test field. + +
+
+
+

Synopsis

+
+Declared in <unnamed.cpp>
+
+int a;
+
+
+
+
@@ -32,7 +150,47 @@

Synopsis

Declared in <unnamed.cpp>
-constexpr /* implementation-defined */ F = {};
+constexpr  F = {};
+
+
+
+
+
+
+
+

x

+
+A test variable named 'x' + +
+
+
+

Synopsis

+
+Declared in <unnamed.cpp>
+
+extern
+ x;
+
+
+
+
+
+
+
+

y

+
+A test variable named 'y' + +
+
+
+

Synopsis

+
+Declared in <unnamed.cpp>
+
+extern
+ y;
 
 
 
diff --git a/test-files/golden-tests/symbols/record/unnamed.xml b/test-files/golden-tests/symbols/record/unnamed.xml index c3280b32c..1e194ea3b 100644 --- a/test-files/golden-tests/symbols/record/unnamed.xml +++ b/test-files/golden-tests/symbols/record/unnamed.xml @@ -4,11 +4,53 @@ + + + + + + + + + + + A test unnamed class. + + + + + + + + A test field. + + + + + + + + + + A test variable named 'x' + + + + + + + + + + A test variable named 'y' + + +