aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/clang-doc/BitcodeWriter.h
AgeCommit message (Collapse)AuthorFilesLines
10 days[clang-doc] refactor JSON for better Mustache compatibility (#149588)Erick Velez1-0/+1
This patch contains changes for the JSON generator that will enable compatibility with Mustache templates, like booleans to check for the existence and bounds of arrays to avoid duplication.
2025-07-11[clang-doc] Serialize record files with mangled name (#148021)Erick Velez1-0/+1
This patch changes JSON file serialization. Now, files are serialized to a single directory instead of nesting them based on namespaces. The global namespace retains the "index.json" name. This solves the problem of class template specializations being serialized to the same file as its base template. This is also planned as part of future integration with the Mustache generator which will consume the JSON files.
2025-06-30[clang-doc] serialize friends (#146165)Erick Velez1-1/+5
Parse friends into a new FriendInfo and serialize them in JSON. We keep track of the friend declaration's template and function information if applicable.
2025-06-27[clang-doc] serialize IsBuiltIn and IsTemplate for types (#146149)Erick Velez1-0/+6
IsBuiltIn and IsTemplate were being emitted as their default values.
2025-06-24[clang-doc] document global variables (#145070)Erick Velez1-0/+6
Visit and map VarDecls to document variables declared in namespace scope.
2025-06-20[clang-doc] add support for concepts (#144430)Erick Velez1-1/+11
Add support for documenting concepts. This handles concepts and constraints on function and class templates. Atomic constraints are not considered yet. We don't order constraints based on their conjunctive or disjunctive properties.
2025-04-18[clang-doc] Handle static members and functions (#135457)Paul Kirth1-0/+2
clang-doc didn't visit VarDecl, and hence never collected info from class statics members and functions. Fixes #59813.
2022-12-08[clang-doc] Add template support.Brett Wilson1-2/+10
Reads template information from the AST and adds template parameters and specialization information to the corresponding clang-doc structures. Add a "QualName" to the Reference struct which includes the full qualified type name. The Reference object represents a link in the HTML/MD generators so is based on the unqualified name. But this does not encode C-V qualifiers or template information that decorate the name. The new QualName member encodes all of this information and also makes it easier for the generators or downsteam YAML consumers to generate the full name (before they had to process the "Path"). In test code that was changed, remove made-up paths to built-in types like "int". In addition to slightnly cleaning up the code, these types do not have paths in real execution, and generating incorrect references to nonexistant data may complicate future changes in the generators. Convert llvm::Optional to std::optional (YAML library requires this for the new usage, and this makes everything consistent according to the llvm::Optional -> std::optional transition). Differential Revision: https://reviews.llvm.org/D139154
2022-12-07Revert "[clang-doc] Add template support."Brett Wilson1-10/+2
Causes a build failure in YAML specializations. This reverts commit 0f6dbb5f164662c3e6a167a89e7a89f07c60e32b.
2022-12-07[clang-doc] Add template support.Brett Wilson1-2/+10
Reads template information from the AST and adds template parameters and specialization information to the corresponding clang-doc structures. Add a "QualName" to the Reference struct which includes the full qualified type name. The Reference object represents a link in the HTML/MD generators so is based on the unqualified name. But this does not encode C-V qualifiers or template information that decorate the name. The new QualName member encodes all of this information and also makes it easier for the generators or downsteam YAML consumers to generate the full name (before they had to process the "Path"). In test code that was changed, remove made-up paths to built-in types like "int". In addition to slightnly cleaning up the code, these types do not have paths in real execution, and generating incorrect references to nonexistant data may complicate future changes in the generators. Differential Revision: https://reviews.llvm.org/D139154
2022-10-14[clang-doc] Add typedef/using information.Brett Wilson1-1/+7
Read typedef and "using" type alias declarations and serialize into the internal structures. Emit this information in the YAML output. The HTML and MD generators are unchanged. Separate out the logic to create the parent namespace or record object and insert the newly created child into it. This logic was previously duplicated for every "info" type and is now shared. To help this, a struct containing the child vectors was separated out so children can be added generically and without having too many templates. A small change was made to populateParentNamespaces() to allow using types that aren't themselves DeclContexts (typedefs are the first example of this). Differential Revision: https://reviews.llvm.org/D134371
2022-09-27Revert "[clang-doc] Add typedef/using information."Haowei Wu1-7/+1
This reverts commit eed22583fd78d4d657fb70b99e62fbdc1f83b8f9, which breaks clang build with -Werror.
2022-09-27[clang-doc] Add typedef/using information.Brett Wilson1-1/+7
Read typedef and "using" type alias declarations and serialize into the internal structures. Emit this information in the YAML output. The HTML and MD generators are unchanged. Separate out the logic to create the parent namespace or record object and insert the newly created child into it. This logic was previously duplicated for every "info" type and is now shared. To help this, a struct containing the child vectors was separated out so children can be added generically and without having too many templates. A small change was made to populateParentNamespaces() to allow using types that aren't themselves DeclContexts (typedefs are the first example of this). Reviewed By: paulkirth, haowei Differential Revision: https://reviews.llvm.org/D134371
2022-09-27[clang-doc] Clean up *Info constructors.Brett Wilson1-1/+0
The *Info object (for the copy of the AST") constructors had many duplicated variants. Many of the variants seemed to be in an attempt to avoid default arguments. But default arguments are not prohibited and using them allows most of the variants to be removed which improves readability. Remove the IsInGlobalNamespace flag on a Reference. This is set when the path is empty, and only read once in the HTML generator with the identical condition. The constructor cleanup exposed a problem where this was set to false when the constructor with no path was used, but true when the path was set to empty. There should be no observable change with the exception that IsInGlobalNamespace is no longer emitted in YAML. Reviewed By: paulkirth, haowei Differential Revision: https://reviews.llvm.org/D134235
2022-09-19[clang-doc] Add support for explicitly typed enumsBrett Wilson1-1/+7
Add support for explicitly typed enums: enum Foo : unsigned { ... }; to the internal representation and to the YAML output. Add support for getting the value of an enum constant, as well as accessing the original expression that produced it. This changes the YAML output of enums from an array of strings for the enum members to an array of dictionaries. These dictionaries now report the name, value, and original expression. The markdown and HTML outputs are unchanged, they still output the name from the new enhanced internal schema. Reviewed By: paulkirth Differential Revision: https://reviews.llvm.org/D134055
2022-09-16[clang-doc] Support default args for functions.Brett Wilson1-0/+1
Adds support for default arguments in the internal representation and reads these values from the source. Implements writing these values to YAML but does not implement this for the HTML or markdown outputs. Reviewed By: paulkirth Differential Revision: https://reviews.llvm.org/D133732
2019-08-23[clang-doc] Bump BitcodeWriter max line number to 32UJulie Hockett1-1/+1
PR43039 reports hitting the assert on a very large file, so bumping this to allow for larger files. Differential Revision: https://reviews.llvm.org/D66681 llvm-svn: 369811
2019-08-16[clang-doc] Serialize inherited attributes and methodsDiego Astiazaran1-1/+10
clang-doc now serializes the inherited attributes and methods, not only the name of the base class. All inherited are tracked, if B:A and C:B, info of A is included in C. This data is stored in attribute Bases in a RecordInfo. Previously tracked inheritance data, stored in Parents and VParents, hasn't been removed to reduce review load. Differential revision: https://reviews.llvm.org/D66238 llvm-svn: 369075
2019-08-06[clang-doc] Fix link generationDiego Astiazaran1-0/+1
Before making a link to a reference it is required to check that the reference has a path (eg. primitives won't have paths). This was done by checking if the path was empty; that worked because when generating paths the outdirectory was included, so if the path was assigned it had that outdirectory at least. The path generation was changed, it's now only the composite of the namespaces without the outdirectory. So if the info is in the global namespace the path would be empty and the old check wouldn't work as expected. A new attribute has been added to the Reference struct that indicates if the info's parent is the global namespace. Paths generation now fails if the path is empty and if the info is not in the global namespace. Differential Revision: https://reviews.llvm.org/D64958 llvm-svn: 367958
2019-07-12[clang-doc] Add html links to referencesJulie Hockett1-0/+3
<a> tags are added for the parents and members of records and return type and params of functions. The link redirects to the reference's info file. The directory path where each info file will be saved is now generated in the serialization phase and stored as an attribute in each Info. Bitcode writer and reader were modified to handle the new attributes. Committed on behalf of Diego Astiazarán (diegoaat97@gmail.com). Differential Revision: https://reviews.llvm.org/D63663 llvm-svn: 365937
2019-07-03[Bitcode] Move Bitstream to a separate libraryFrancis Visoiu Mistrih1-1/+1
This moves Bitcode/Bitstream*, Bitcode/BitCodes.h to Bitstream/. This is needed to avoid a circular dependency when using the bitstream code for parsing optimization remarks. Since Bitcode uses Core for the IR part: libLLVMRemarks -> Bitcode -> Core and Core uses libLLVMRemarks to generate remarks (see IR/RemarkStreamer.cpp): Core -> libLLVMRemarks we need to separate the Bitstream and Bitcode part. For clang-doc, it seems that it doesn't need the whole bitcode layer, so I updated the CMake to only use the bitstream part. Differential Revision: https://reviews.llvm.org/D63899 llvm-svn: 365091
2019-06-26BitStream reader: propagate errorsJF Bastien1-1/+1
The bitstream reader handles errors poorly. This has two effects: * Bugs in file handling (especially modules) manifest as an "unexpected end of file" crash * Users of clang as a library end up aborting because the code unconditionally calls `report_fatal_error` The bitstream reader should be more resilient and return Expected / Error as soon as an error is encountered, not way late like it does now. This patch starts doing so and adopting the error handling where I think it makes sense. There's plenty more to do: this patch propagates errors to be minimally useful, and follow-ups will propagate them further and improve diagnostics. https://bugs.llvm.org/show_bug.cgi?id=42311 <rdar://problem/33159405> Differential Revision: https://reviews.llvm.org/D63518 llvm-svn: 364464
2019-06-24[clang-doc] Add basic support for templates and typedefJulie Hockett1-0/+1
In serialize::parseBases(...), when a base record is a template specialization, the specialization was used as the parent. It should be the base template so there is only one file generated for this record. When the specialized template is implicitly declared the reference USR corresponded to the GlobalNamespace's USR, this will now be the base template's USR. More information about templates will be added later. In serialize::emiInfo(RecorDecl*, ...), typedef records were not handled and the name was empty. This is now handled and a IsTypeDef attribute is added to RecordInfo struct. In serialize::emitInfo(CXXMethodDecl*, ...), template specialization is handled like in serialize::parseBases(...). Bitcode writer and reader are modified to handle the new attribute of RecordInfo. Submitted on behalf of Diego Astiazarán (diegoaat97@gmail.com) Differential Revision: https://reviews.llvm.org/D63367 llvm-svn: 364222
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-09-29[cxx2a] Fix warning triggered by r343285Vitaly Buka1-1/+0
llvm-svn: 343369
2018-08-02Reland "[clang-doc] Refactoring mapper to map by scope"Julie Hockett1-9/+17
Relanding with a minor change to prevent an assertion on release bots. The result of this adjusted mapper pass is that all Function and Enum infos are absorbed into the info of their enclosing scope (i.e. the class or namespace in which they are defined). Namespace and Record infos are passed along to the final output, but the second pass creates a reference to each in its parent scope. As a result, the top-level final outputs are Namespaces and Records. Differential Revision: https://reviews.llvm.org/D48341 llvm-svn: 338763
2018-08-02Revert "[clang-doc] Refactoring mapper to map by scope"Julie Hockett1-17/+9
This reverts commit r338738 as it's breaking the bots. llvm-svn: 338748
2018-08-02[clang-doc] Refactoring mapper to map by scopeJulie Hockett1-9/+17
The result of this adjusted mapper pass is that all Function and Enum infos are absorbed into the info of their enclosing scope (i.e. the class or namespace in which they are defined). Namespace and Record infos are passed along to the final output, but the second pass creates a reference to each in its parent scope. As a result, the top-level final outputs are Namespaces and Records. llvm-svn: 338738
2018-06-04[clang-doc] Implement reducer portion of the frontend frameworkJulie Hockett1-8/+6
Implements a simple, in-memory reducer for the mapped output of the initial tool. This creates a collection object for storing the deduplicated infos on each declaration, and populates that from the mapper output. The collection object is serialized to LLVM bitstream. On reading each serialized output, it checks to see if a merge is necessary and if so, merges the new info with the existing info (prefering the existing one if conflicts exist). For a more detailed overview of the tool, see the design document on the mailing list: http://lists.llvm.org/pipermail/cfe-dev/2017-December/056203.html Differential Revision: https://reviews.llvm.org/D43341 llvm-svn: 333932
2018-05-04[clang-doc] Attaching a name to reference dataJulie Hockett1-14/+17
This adds the name of the referenced decl, in addition to its USR, to the saved data, so that the backend can look at an info in isolation and still be able to construct a human-readable name for it. Differential Revision: https://reviews.llvm.org/D46281 llvm-svn: 331539
2018-03-22[clang-doc] Reland "[clang-doc] Setup clang-doc frontend framework"Julie Hockett1-0/+201
Fixed windows release build tests. llvm-svn: 328270
2018-03-22Revert "[clang-doc] Reland "[clang-doc] Setup clang-doc frontend framework""Julie Hockett1-201/+0
This reverts commit r328150 until we can fix the test that are failing on the Windows release build. llvm-svn: 328172
2018-03-21[clang-doc] Reland "[clang-doc] Setup clang-doc frontend framework"Julie Hockett1-0/+201
Fixing the the failing Windows tests. llvm-svn: 328150
2018-03-12Revert "Reland "[clang-doc] Setup clang-doc frontend framework""Julie Hockett1-201/+0
This reverts commit r327295 since it was causing the Windows bots to fail. llvm-svn: 327346
2018-03-12Reland "[clang-doc] Setup clang-doc frontend framework"Julie Hockett1-0/+201
There was a missing newline in the docs, and a static_assert that needed to be a normal assert. llvm-svn: 327295
2018-03-09Revert "[clang-doc] Setup clang-doc frontend framework"Julie Hockett1-201/+0
This reverts commit r327102, since it was breaking the linux-abi-test on x86. llvm-svn: 327103
2018-03-09[clang-doc] Setup clang-doc frontend frameworkJulie Hockett1-0/+201
Setting up the mapper part of the frontend framework for a clang-doc tool. It creates a series of relevant matchers for declarations, and uses the ToolExecutor to traverse the AST and extract the matching declarations and comments. The mapper serializes the extracted information to individual records for reducing and eventually doc generation. For a more detailed overview of the tool, see the design document on the mailing list: http://lists.llvm.org/pipermail/cfe-dev/2017-December/056203.html Differential Revision: https://reviews.llvm.org/D41102 llvm-svn: 327102