================ @@ -263,17 +261,36 @@ class alignas(8) Module { FileEntryRef Entry; }; - /// Information about a directory name as found in the module map - /// file. +private: + static const int NumHeaderKinds = HK_Excluded + 1; + // The begin index for a HeaderKind also acts the end index of HeaderKind - 1. + // The extra element at the end acts as the end index of the last HeaderKind. + unsigned HeaderKindBeginIndex[NumHeaderKinds + 1] = {}; + SmallVector<Header, 2> HeadersStorage; + +public: + ArrayRef<Header> getAllHeaders() const { return HeadersStorage; } + ArrayRef<Header> getHeaders(HeaderKind HK) const { + assert(HK < NumHeaderKinds && "Invalid Module::HeaderKind"); + auto BeginIt = HeadersStorage.begin() + HeaderKindBeginIndex[HK]; + auto EndIt = HeadersStorage.begin() + HeaderKindBeginIndex[HK + 1]; ---------------- cor3ntin wrote:
Could this not be `HK == NumHeaderKinds ? HeadersStorage.end() : HeadersStorage.begin() + HeaderKindBeginIndex[HK + 1];` ? https://github.com/llvm/llvm-project/pull/113395 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits