aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/clang-doc/BitcodeReader.cpp
AgeCommit message (Collapse)AuthorFilesLines
6 days[clang-doc] refactor JSON for better Mustache compatibility (#149588)Erick Velez1-0/+2
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/+2
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-07-03[clang-doc] add namespace references to VarInfo (#146964)Erick Velez1-0/+11
VarInfo was missing its addReference specialization. This causes errors when a VarInfo is inside a namespace that isn't the global namespace.
2025-06-30[clang-doc] serialize friends (#146165)Erick Velez1-0/+46
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-1/+17
IsBuiltIn and IsTemplate were being emitted as their default values.
2025-06-26[clang-doc] refactor BitcodeReader::readSubBlock (#145835)Erick Velez1-75/+56
Reduce boilerplate code in readSubBlock by creating a callable from a higher-order lambda based on the block's add need.
2025-06-24[clang-doc] document global variables (#145070)Erick Velez1-0/+40
Visit and map VarDecls to document variables declared in namespace scope.
2025-06-20[clang-doc] add support for concepts (#144430)Erick Velez1-0/+73
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-06-13[clang-doc] remove default label on some switches (#143919)Erick Velez1-3/+1
LLVM style prefers no default label on fully covered switches to warn if new enums are added. This patch removes the default label for that purpose or uses IT_default instead of default if that was the only enum not covered.
2025-06-07Refactor clang doc comment structure (#142273)Samarth Narang1-1/+5
This patch refactors CommentKind handling in clang-doc by introducing a strongly typed enum class for better type safety and clarity. It updates all relevant places, including YAML traits and serialization, to work with the new enum. Additionally, it enhances the Mustache-based HTML generation by fully supporting all comment kinds, ensuring accurate structured rendering of comment blocks. The changes simplify future maintenance, improve robustness by eliminating unchecked defaults, and ensure consistency between generators. Fixes https://github.com/llvm/llvm-project/issues/142083
2025-06-03[clang-doc] Reenable time trace support (#141139)Paul Kirth1-0/+8
This patch re-enables -ftime-trace support in clang-doc. Initial support in #97644 was reverted, and never relanded. This patch adds back the command line option, and leverages the RAII tracing infrastructure more thoroughly.
2025-04-29[clang-doc] Add start and end line numbers (#137732)Paul Kirth1-2/+4
This patch adds start and end line numbers to clang-doc. Currently clang-doc only encodes the start line numbers of records, struct, etc. This patch adds start and end line number to clang-doc bitcode which is passed to the generator. This will be used by the mustache backend to generate line ranges. Based on the orginal patch in #135081. Co-author: Paul Kirth <paulkirth@google.com> Co-authored-by: PeterChou1 <peter.chou@mail.utoronto.ca>
2025-04-19[clang-doc] Fix warningsKazu Hirata1-14/+0
This patch fixes: clang-tools-extra/clang-doc/BitcodeReader.cpp:47:20: error: unused function 'decodeRecord' [-Werror,-Wunused-function] clang-tools-extra/clang-doc/BitcodeReader.cpp:437:31: error: unused function 'getCommentInfo<std::unique_ptr<clang::doc::CommentInfo> &>' [-Werror,-Wunused-function]
2025-04-18[clang-doc][NFC] Prefer static functions for internal APIs (#136391)Paul Kirth1-61/+67
Additionally moving the declarations from Generator.cpp prevents misc-use-internal-linkage warnings from clang-tidy. We fix those here too, since the static functions are part of the same diagnostic
2025-04-18[clang-doc][NFC] Avoid else after return (#136389)Paul Kirth1-3/+2
2025-04-18[clang-doc][NFC] Avoid C-style casts (#136390)Paul Kirth1-3/+3
2025-04-18[clang-doc] Handle static members and functions (#135457)Paul Kirth1-0/+4
clang-doc didn't visit VarDecl, and hence never collected info from class statics members and functions. Fixes #59813.
2024-08-16[clang-doc] add support for enums comments in html generation (#101282)PeterChou11-0/+4
Part of https://github.com/llvm/llvm-project/issues/101129 This patch adds support for attaching comments to enums for HTML in clang-doc. It changes the enum generation to table tags where as perviously we're using lists which is more in line with what other doc generators are doing. It also gives clang-doc the ability to show user specified enum values
2024-07-23Revert "[clang-doc] add ftime profiling" (#100251)PeterChou11-8/+0
This broke the build due to failing some clang-tidy checks: https://lab.llvm.org/buildbot/#/builders/145/builds/789
2024-07-23[clang-doc] add ftime profiling (#97644)PeterChou11-0/+8
this patches adds ftime-tracing option for clang-doc which was what I used to profile the performance problems we had with clang-doc generating the llvm docs. - ftime-trace produces a time profiler json file called clang-doc-tracing.json
2023-11-03[clang-doc] Fix a warningKazu Hirata1-3/+2
This patch fixes: clang-tools-extra/clang-doc/BitcodeReader.cpp:78:3: error: default label in switch which covers all enumeration values [-Werror,-Wcovered-switch-default]
2023-11-03[clang][NFC] Refactor `TagTypeKind` (#71160)Vlad Serebrennikov1-7/+7
This patch converts TagTypeKind into scoped enum. Among other benefits, this allows us to forward-declare it where necessary.
2022-12-08[clang-doc] Add template support.Brett Wilson1-0/+85
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-07[Bitcode(Reader|Writer)] Convert Optional to std::optionalKrzysztof Parzyszek1-2/+1
2022-12-07Revert "[clang-doc] Add template support."Brett Wilson1-85/+0
Causes a build failure in YAML specializations. This reverts commit 0f6dbb5f164662c3e6a167a89e7a89f07c60e32b.
2022-12-07[clang-doc] Add template support.Brett Wilson1-0/+85
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-12-06[YAML] Convert Optional to std::optionalKrzysztof Parzyszek1-1/+2
2022-10-25[clang-doc] Fix typedef/using output.Brett Wilson1-10/+9
Provides an initializer for the TypedefInfo.IsUsing member. Previously this member was uninitialized and would produce random output. Adds the Description (code comments) to the bitcode reader/writer. Previously the typedef/using descriptions were lost during the bitcode round-trip. Adds a test for this. Differential Revision: https://reviews.llvm.org/D136638
2022-10-14[clang-doc] Add typedef/using information.Brett Wilson1-18/+61
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-61/+18
This reverts commit eed22583fd78d4d657fb70b99e62fbdc1f83b8f9, which breaks clang build with -Werror.
2022-09-27[clang-doc] Add typedef/using information.Brett Wilson1-18/+61
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-2/+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-4/+42
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/+2
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
2022-08-11[clang-doc] Read docstrings for record membersBrett Wilson1-0/+5
Struct/class data members did not have the comments associated with them. This adds that information to the MemberTypeInfo class and emits it in the YAML. This does not update the frontends yet. Reviewed By: paulkirth Differential Revision: https://reviews.llvm.org/D131298
2021-09-24[clang-doc] Pass Record argument by const-ref. NFCI.Simon Pilgrim1-22/+27
Record is a SmallVector<uint64_t, 1024> - we really need to avoid passing this by value. Avoid unnecessary big copies, reported by coverity.
2019-08-28[clang-doc] Use llvm::createStringError and canonicalize error messagesFangrui Song1-83/+73
"Bad block found.\n" -> "bad block found" The lower cased form with no full stop or newline is more common in LLVM tools. Reviewed By: juliehockett Differential Revision: https://reviews.llvm.org/D66783 llvm-svn: 370155
2019-08-16[clang-doc] Serialize inherited attributes and methodsDiego Astiazaran1-0/+43
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-14[clang-tools-extra] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere1-2/+2
Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368944
2019-08-09[clang-format] Add link to source code in file definitionsDiego Astiazaran1-2/+2
Two command line options have been added to clang-doc. --repository=<string> - URL of repository that hosts code; used for links to definition locations. --source-root=<string> - Directory where processed files are stored. Links to definition locations will only be generated if the file is in this dir. If the file is in the source-root and a repository options is passed; a link to the source code will be rendered by the HTML generator. Differential Revision: https://reviews.llvm.org/D65483 llvm-svn: 368460
2019-08-06[clang-doc] Fix link generationDiego Astiazaran1-0/+2
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-1/+7
<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-05Bitstream reader: Fix undefined behavior seen after rL364464Bjorn Pettersson1-7/+8
Summary: After rL364464 the following tests started to fail when running the clang-doc tests with an ubsan instrumented build of clang-doc: Clang Tools :: clang-doc/single-file-public.cpp Extra Tools Unit Tests :: clang-doc/./ClangDocTests/BitcodeTest.emitEnumInfoBitcode Extra Tools Unit Tests :: clang-doc/./ClangDocTests/BitcodeTest.emitMethodInfoBitcode Extra Tools Unit Tests :: clang-doc/./ClangDocTests/BitcodeTest.emitRecordInfoBitcode Extra Tools Unit Tests :: clang-doc/./ClangDocTests/SerializeTest.emitInfoWithCommentBitcode We need to check that the read value is in range for being casted to the llvm::bitc::FixedAbbrevIDs enum, before the cast in ClangDocBitcodeReader::skipUntilRecordOrBlock. SerializedDiagnosticReader::skipUntilRecordOrBlock was updated in the same way. Reviewers: jfb Reviewed By: jfb Subscribers: Bigcheese, vsapsai, bruno, ilya-biryukov, dexonsmith, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64262 llvm-svn: 365239
2019-06-26BitStream reader: propagate errorsJF Bastien1-26/+60
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/+2
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-08-15[clang-doc] Explicitly cast to unique_ptrJulie Hockett1-1/+1
Older compilers don't like the implicit cast & move when returning a unique_ptr to an llvm::Expected type. llvm-svn: 339785
2018-08-15Reland "[clang-doc] Updating BitcodeReader to use llvm::Error""Julie Hockett1-200/+247
With explicit unique_ptr casts so that bots with older compilers don't break. llvm-svn: 339783
2018-08-13Revert "[clang-doc] Updating BitcodeReader to use llvm::Error"Julie Hockett1-247/+200
This reverts commit r339617 for breaking bots. llvm-svn: 339620
2018-08-13[clang-doc] Updating BitcodeReader to use llvm::ErrorJulie Hockett1-200/+247
llvm-svn: 339617