clang-tools  14.0.0git
GlobList.h
Go to the documentation of this file.
1 //===--- GlobList.h ---------------------------------------------*- 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 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GLOBLIST_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GLOBLIST_H
11 
12 #include "clang/Basic/LLVM.h"
13 #include "llvm/ADT/SmallVector.h"
14 #include "llvm/ADT/StringRef.h"
15 #include "llvm/Support/Regex.h"
16 
17 namespace clang {
18 namespace tidy {
19 
20 /// Read-only set of strings represented as a list of positive and negative
21 /// globs.
22 ///
23 /// Positive globs add all matched strings to the set, negative globs remove
24 /// them in the order of appearance in the list.
25 class GlobList {
26 public:
27  /// \p Globs is a comma-separated list of globs (only the '*' metacharacter is
28  /// supported) with an optional '-' prefix to denote exclusion.
29  ///
30  /// An empty \p Globs string is interpreted as one glob that matches an empty
31  /// string.
32  ///
33  /// \p KeepNegativeGlobs a bool flag indicating whether to keep negative
34  /// globs from \p Globs or not. When false, negative globs are simply ignored.
35  GlobList(StringRef Globs, bool KeepNegativeGlobs = true);
36 
37  /// Returns \c true if the pattern matches \p S. The result is the last
38  /// matching glob's Positive flag.
39  bool contains(StringRef S) const;
40 
41 private:
42 
43  struct GlobListItem {
44  bool IsPositive;
45  llvm::Regex Regex;
46  };
47  SmallVector<GlobListItem, 0> Items;
48 };
49 
50 } // end namespace tidy
51 } // end namespace clang
52 
53 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GLOBLIST_H
clang::tidy::GlobList
Read-only set of strings represented as a list of positive and negative globs.
Definition: GlobList.h:25
clang::tidy::GlobList::GlobList
GlobList(StringRef Globs, bool KeepNegativeGlobs=true)
Globs is a comma-separated list of globs (only the '*' metacharacter is supported) with an optional '...
Definition: GlobList.cpp:45
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::tidy::GlobList::contains
bool contains(StringRef S) const
Returns true if the pattern matches S.
Definition: GlobList.cpp:56