LLVM  6.0.0svn
GlobPattern.h
Go to the documentation of this file.
1 //===-- GlobPattern.h - glob pattern matcher implementation -*- C++ -*-----===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements a glob pattern matcher. The glob pattern is the
11 // rule used by the shell.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_SUPPORT_GLOB_PATTERN_H
16 #define LLVM_SUPPORT_GLOB_PATTERN_H
17 
18 #include "llvm/ADT/BitVector.h"
19 #include "llvm/ADT/Optional.h"
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/Support/Error.h"
22 #include <vector>
23 
24 // This class represents a glob pattern. Supported metacharacters
25 // are "*", "?", "[<chars>]" and "[^<chars>]".
26 namespace llvm {
27 class BitVector;
28 template <typename T> class ArrayRef;
29 
30 class GlobPattern {
31 public:
33  bool match(StringRef S) const;
34 
35 private:
36  bool matchOne(ArrayRef<BitVector> Pat, StringRef S) const;
37 
38  // Parsed glob pattern.
39  std::vector<BitVector> Tokens;
40 
41  // The following members are for optimization.
42  Optional<StringRef> Exact;
43  Optional<StringRef> Prefix;
44  Optional<StringRef> Suffix;
45 };
46 }
47 
48 #endif // LLVM_SUPPORT_GLOB_PATTERN_H
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
bool match(StringRef S) const
Tagged union holding either a T or a Error.
Definition: CachePruning.h:23
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
static Expected< GlobPattern > create(StringRef Pat)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49