diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp index a955c3bca337f..8ecbd3c5a2cc4 100644 --- a/clang/lib/Basic/Diagnostic.cpp +++ b/clang/lib/Basic/Diagnostic.cpp @@ -532,7 +532,7 @@ WarningsSpecialCaseList::create(const llvm::MemoryBuffer &Input, void WarningsSpecialCaseList::processSections(DiagnosticsEngine &Diags) { static constexpr auto WarningFlavor = clang::diag::Flavor::WarningOrError; - for (const auto &SectionEntry : Sections) { + for (const auto &SectionEntry : sections()) { StringRef DiagGroup = SectionEntry.SectionStr; if (DiagGroup == "*") { // Drop the default section introduced by special case list, we only diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp index 8481deffe2a7b..9cb118893a0d9 100644 --- a/clang/lib/Basic/ProfileList.cpp +++ b/clang/lib/Basic/ProfileList.cpp @@ -32,10 +32,10 @@ class ProfileSpecialCaseList : public llvm::SpecialCaseList { createOrDie(const std::vector &Paths, llvm::vfs::FileSystem &VFS); - bool isEmpty() const { return Sections.empty(); } + bool isEmpty() const { return sections().empty(); } bool hasPrefix(StringRef Prefix) const { - for (const auto &It : Sections) + for (const auto &It : sections()) if (It.Entries.count(Prefix) > 0) return true; return false; diff --git a/clang/lib/Basic/SanitizerSpecialCaseList.cpp b/clang/lib/Basic/SanitizerSpecialCaseList.cpp index 792000b545fb8..56f551628cf89 100644 --- a/clang/lib/Basic/SanitizerSpecialCaseList.cpp +++ b/clang/lib/Basic/SanitizerSpecialCaseList.cpp @@ -38,7 +38,7 @@ SanitizerSpecialCaseList::createOrDie(const std::vector &Paths, } void SanitizerSpecialCaseList::createSanitizerSections() { - for (const auto &S : Sections) { + for (const auto &S : sections()) { SanitizerMask Mask; #define SANITIZER(NAME, ID) \ diff --git a/llvm/include/llvm/Support/SpecialCaseList.h b/llvm/include/llvm/Support/SpecialCaseList.h index d8dd1c4ec4bbc..c7a10e34618d7 100644 --- a/llvm/include/llvm/Support/SpecialCaseList.h +++ b/llvm/include/llvm/Support/SpecialCaseList.h @@ -12,6 +12,7 @@ #ifndef LLVM_SUPPORT_SPECIALCASELIST_H #define LLVM_SUPPORT_SPECIALCASELIST_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringMap.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/GlobPattern.h" @@ -118,6 +119,7 @@ class SpecialCaseList { SpecialCaseList(SpecialCaseList const &) = delete; SpecialCaseList &operator=(SpecialCaseList const &) = delete; +private: /// Represents a set of globs and their line numbers class Matcher { public: @@ -161,6 +163,7 @@ class SpecialCaseList { using SectionEntries = StringMap>; +protected: struct Section { Section(StringRef Str, unsigned FileIdx) : SectionStr(Str), FileIdx(FileIdx) {}; @@ -187,6 +190,9 @@ class SpecialCaseList { findMatcher(StringRef Prefix, StringRef Category) const; }; + ArrayRef sections() const { return Sections; } + +private: std::vector
Sections; LLVM_ABI Expected
addSection(StringRef SectionStr,