diff options
Diffstat (limited to 'contrib/llvm/lib/Support/SpecialCaseList.cpp')
-rw-r--r-- | contrib/llvm/lib/Support/SpecialCaseList.cpp | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/contrib/llvm/lib/Support/SpecialCaseList.cpp b/contrib/llvm/lib/Support/SpecialCaseList.cpp index 21e43c5..785cc60 100644 --- a/contrib/llvm/lib/Support/SpecialCaseList.cpp +++ b/contrib/llvm/lib/Support/SpecialCaseList.cpp @@ -48,10 +48,10 @@ struct SpecialCaseList::Entry { SpecialCaseList::SpecialCaseList() : Entries() {} -SpecialCaseList *SpecialCaseList::create( - const StringRef Path, std::string &Error) { +std::unique_ptr<SpecialCaseList> SpecialCaseList::create(StringRef Path, + std::string &Error) { if (Path.empty()) - return new SpecialCaseList(); + return std::unique_ptr<SpecialCaseList>(new SpecialCaseList()); ErrorOr<std::unique_ptr<MemoryBuffer>> FileOrErr = MemoryBuffer::getFile(Path); if (std::error_code EC = FileOrErr.getError()) { @@ -61,17 +61,17 @@ SpecialCaseList *SpecialCaseList::create( return create(FileOrErr.get().get(), Error); } -SpecialCaseList *SpecialCaseList::create( - const MemoryBuffer *MB, std::string &Error) { +std::unique_ptr<SpecialCaseList> SpecialCaseList::create(const MemoryBuffer *MB, + std::string &Error) { std::unique_ptr<SpecialCaseList> SCL(new SpecialCaseList()); if (!SCL->parse(MB, Error)) return nullptr; - return SCL.release(); + return SCL; } -SpecialCaseList *SpecialCaseList::createOrDie(const StringRef Path) { +std::unique_ptr<SpecialCaseList> SpecialCaseList::createOrDie(StringRef Path) { std::string Error; - if (SpecialCaseList *SCL = create(Path, Error)) + if (auto SCL = create(Path, Error)) return SCL; report_fatal_error(Error); } @@ -103,18 +103,6 @@ bool SpecialCaseList::parse(const MemoryBuffer *MB, std::string &Error) { std::string Regexp = SplitRegexp.first; StringRef Category = SplitRegexp.second; - // Backwards compatibility. - if (Prefix == "global-init") { - Prefix = "global"; - Category = "init"; - } else if (Prefix == "global-init-type") { - Prefix = "type"; - Category = "init"; - } else if (Prefix == "global-init-src") { - Prefix = "src"; - Category = "init"; - } - // See if we can store Regexp in Strings. if (Regex::isLiteralERE(Regexp)) { Entries[Prefix][Category].Strings.insert(Regexp); @@ -157,8 +145,8 @@ bool SpecialCaseList::parse(const MemoryBuffer *MB, std::string &Error) { SpecialCaseList::~SpecialCaseList() {} -bool SpecialCaseList::inSection(const StringRef Section, const StringRef Query, - const StringRef Category) const { +bool SpecialCaseList::inSection(StringRef Section, StringRef Query, + StringRef Category) const { StringMap<StringMap<Entry> >::const_iterator I = Entries.find(Section); if (I == Entries.end()) return false; StringMap<Entry>::const_iterator II = I->second.find(Category); |