//===-- GlobPattern.cpp - Glob pattern matcher implementation -------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file implements a glob pattern matcher. // //===----------------------------------------------------------------------===// #include "llvm/Support/GlobPattern.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Errc.h" usingnamespacellvm; // Expands character ranges and returns a bitmap. // For example, "a-cf-hz" is expanded to "abcfghz". static Expected<BitVector> expand(StringRef S, StringRef Original) { … } // Identify brace expansions in S and return the list of patterns they expand // into. static Expected<SmallVector<std::string, 1>> parseBraceExpansions(StringRef S, std::optional<size_t> MaxSubPatterns) { … } Expected<GlobPattern> GlobPattern::create(StringRef S, std::optional<size_t> MaxSubPatterns) { … } Expected<GlobPattern::SubGlobPattern> GlobPattern::SubGlobPattern::create(StringRef S) { … } bool GlobPattern::match(StringRef S) const { … } // Factor the pattern into segments split by '*'. The segment is matched // sequentianlly by finding the first occurrence past the end of the previous // match. bool GlobPattern::SubGlobPattern::match(StringRef Str) const { … }