[llvm] [cmake] Add possibility to use ChooseMSVCCRT.cmake when include LLVM library
[llvm-core.git] / include / llvm / Support / GlobPattern.h
blob66a4cd94c12ada304d7e9d19ce65737ca08abbce
1 //===-- GlobPattern.h - glob pattern matcher implementation -*- C++ -*-----===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements a glob pattern matcher. The glob pattern is the
10 // rule used by the shell.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_SUPPORT_GLOB_PATTERN_H
15 #define LLVM_SUPPORT_GLOB_PATTERN_H
17 #include "llvm/ADT/BitVector.h"
18 #include "llvm/ADT/Optional.h"
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/Support/Error.h"
21 #include <vector>
23 // This class represents a glob pattern. Supported metacharacters
24 // are "*", "?", "[<chars>]" and "[^<chars>]".
25 namespace llvm {
26 class BitVector;
27 template <typename T> class ArrayRef;
29 class GlobPattern {
30 public:
31 static Expected<GlobPattern> create(StringRef Pat);
32 bool match(StringRef S) const;
34 private:
35 bool matchOne(ArrayRef<BitVector> Pat, StringRef S) const;
37 // Parsed glob pattern.
38 std::vector<BitVector> Tokens;
40 // The following members are for optimization.
41 Optional<StringRef> Exact;
42 Optional<StringRef> Prefix;
43 Optional<StringRef> Suffix;
47 #endif // LLVM_SUPPORT_GLOB_PATTERN_H