annotate include/llvm/Support/GlobPattern.h @ 121:803732b1fca8

LLVM 5.0
author kono
date Fri, 27 Oct 2017 17:07:41 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
121
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
1 //===-- GlobPattern.h - glob pattern matcher implementation -*- C++ -*-----===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
2 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
3 // The LLVM Compiler Infrastructure
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
4 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
5 // This file is distributed under the University of Illinois Open Source
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
6 // License. See LICENSE.TXT for details.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
7 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
8 //===----------------------------------------------------------------------===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
9 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
10 // This file implements a glob pattern matcher. The glob pattern is the
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
11 // rule used by the shell.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
12 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
13 //===----------------------------------------------------------------------===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
14
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
15 #ifndef LLVM_SUPPORT_GLOB_PATTERN_H
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
16 #define LLVM_SUPPORT_GLOB_PATTERN_H
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
17
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
18 #include "llvm/ADT/BitVector.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
19 #include "llvm/ADT/Optional.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
20 #include "llvm/ADT/StringRef.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
21 #include "llvm/Support/Error.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
22 #include <vector>
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
23
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
24 // This class represents a glob pattern. Supported metacharacters
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
25 // are "*", "?", "[<chars>]" and "[^<chars>]".
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
26 namespace llvm {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
27 class BitVector;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
28 template <typename T> class ArrayRef;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
29
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
30 class GlobPattern {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
31 public:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
32 static Expected<GlobPattern> create(StringRef Pat);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
33 bool match(StringRef S) const;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
34
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
35 private:
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
36 bool matchOne(ArrayRef<BitVector> Pat, StringRef S) const;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
37
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
38 // Parsed glob pattern.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
39 std::vector<BitVector> Tokens;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
40
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
41 // The following members are for optimization.
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
42 Optional<StringRef> Exact;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
43 Optional<StringRef> Prefix;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
44 Optional<StringRef> Suffix;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
45 };
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
46 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
47
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
48 #endif // LLVM_SUPPORT_GLOB_PATTERN_H