[llvm-branch-commits] [clang-tools-extra] [clang-doc][NFC] Introduce Vector and Array abstractions (PR #184870)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Mar 5 12:01:47 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tools-extra
Author: Paul Kirth (ilovepi)
<details>
<summary>Changes</summary>
Introduce OwningVec and OwningArray aliases for vector types we want to
eventually update for arena allocations.
---
Full diff: https://github.com/llvm/llvm-project/pull/184870.diff
1 Files Affected:
- (modified) clang-tools-extra/clang-doc/Representation.h (+24-16)
``````````diff
diff --git a/clang-tools-extra/clang-doc/Representation.h b/clang-tools-extra/clang-doc/Representation.h
index 4773b89255202..7174316faa726 100644
--- a/clang-tools-extra/clang-doc/Representation.h
+++ b/clang-tools-extra/clang-doc/Representation.h
@@ -32,6 +32,14 @@ namespace doc {
// to be eventually transitioned to bare pointers in an arena.
template <typename T> using OwnedPtr = std::unique_ptr<T>;
+// An abstraction for vectors that are populated and read sequentially.
+// To be eventually transitioned to llvm::ArrayRef for arena storage.
+template <typename T> using OwningArray = std::vector<T>;
+
+// An abstraction for lists that are dynamically managed (inserted/removed).
+// To be eventually transitioned to llvm::simple_ilist.
+template <typename T> using OwningVec = std::vector<T>;
+
// SHA1'd hash of a USR.
using SymbolID = std::array<uint8_t, 20>;
@@ -94,7 +102,7 @@ struct CommentInfo {
// the vector.
bool operator<(const CommentInfo &Other) const;
- std::vector<OwnedPtr<CommentInfo>>
+ OwningVec<OwnedPtr<CommentInfo>>
Children; // List of child comments for this CommentInfo.
SmallString<8> Direction; // Parameter direction (for (T)ParamCommand).
SmallString<16> Name; // Name of the comment (for Verbatim and HTML).
@@ -192,13 +200,13 @@ struct ScopeChildren {
//
// Namespaces are not syntactically valid as children of records, but making
// this general for all possible container types reduces code complexity.
- std::vector<Reference> Namespaces;
- std::vector<Reference> Records;
- std::vector<FunctionInfo> Functions;
- std::vector<EnumInfo> Enums;
- std::vector<TypedefInfo> Typedefs;
- std::vector<ConceptInfo> Concepts;
- std::vector<VarInfo> Variables;
+ OwningArray<Reference> Namespaces;
+ OwningArray<Reference> Records;
+ OwningArray<FunctionInfo> Functions;
+ OwningArray<EnumInfo> Enums;
+ OwningArray<TypedefInfo> Typedefs;
+ OwningArray<ConceptInfo> Concepts;
+ OwningArray<VarInfo> Variables;
void sort();
};
@@ -241,7 +249,7 @@ struct TemplateSpecializationInfo {
SymbolID SpecializationOf;
// Template parameters applying to the specialized record/function.
- std::vector<TemplateParamInfo> Params;
+ OwningArray<TemplateParamInfo> Params;
};
struct ConstraintInfo {
@@ -257,11 +265,11 @@ struct ConstraintInfo {
// or an explicit template specialization.
struct TemplateInfo {
// May be empty for non-partial specializations.
- std::vector<TemplateParamInfo> Params;
+ OwningArray<TemplateParamInfo> Params;
// Set when this is a specialization of another record/function.
std::optional<TemplateSpecializationInfo> Specialization;
- std::vector<ConstraintInfo> Constraints;
+ OwningArray<ConstraintInfo> Constraints;
};
// Info for field types.
@@ -296,7 +304,7 @@ struct MemberTypeInfo : public FieldTypeInfo {
Other.Description);
}
- std::vector<CommentInfo> Description;
+ OwningArray<CommentInfo> Description;
// Access level associated with this info (public, protected, private, none).
// AS_public is set as default because the bitcode writer requires the enum
@@ -381,7 +389,7 @@ struct Info {
InfoType IT = InfoType::IT_default;
// Comment description of this decl.
- std::vector<CommentInfo> Description;
+ OwningArray<CommentInfo> Description;
SmallVector<Context, 4> Contexts;
};
@@ -506,11 +514,11 @@ struct RecordInfo : public SymbolInfo {
llvm::SmallVector<Reference, 4>
VirtualParents; // List of virtual base/parent records.
- std::vector<BaseRecordInfo>
+ OwningArray<BaseRecordInfo>
Bases; // List of base/parent records; this includes inherited methods and
// attributes
- std::vector<FriendInfo> Friends;
+ OwningArray<FriendInfo> Friends;
ScopeChildren Children;
};
@@ -574,7 +582,7 @@ struct EnumValueInfo {
SmallString<16> ValueExpr;
/// Comment description of this field.
- std::vector<CommentInfo> Description;
+ OwningArray<CommentInfo> Description;
};
// TODO: Expand to allow for documenting templating.
``````````
</details>
https://github.com/llvm/llvm-project/pull/184870
More information about the llvm-branch-commits
mailing list