llvm::GlobPattern

Glob pattern matcher similar to bash with some key differences.

Synopsis

Declared in <llvm/Support/GlobPattern.h>

class GlobPattern;

Description

This class implements a glob pattern matcher similar to the one found in bash, but with some key differences. Namely, that * matches all characters and does not exclude path separators.

* ? matches a single character. * * matches zero or more characters. * [<chars>] matches one character in the bracket. Character ranges, e.g., [a-z], and negative sets via ab or [!ab] are also supported. * {<glob>,...} matches one of the globs in the list. Nested brace expansions are not supported. If MaxSubPatterns is empty then brace expansions are not supported and characters {,} are treated as literals. * escapes the next character so it is treated as a literal.

Some known edge cases are: * The literal ] is allowed as the first character in a character class, i.e., []] is valid and matches the literal ]. * The empty character class, i.e., [], is invalid. * Empty or singleton brace expansions, e.g., {}, {a}, are invalid. * The literals } and , that are not inside a brace expansion are taken as literals, e.g., ,} is valid but { is not.

Examples: * *[/]foo.{c,cpp}] will match (unix or windows) paths to files named foo.c or foo.cpp. * Z{N,NK,}S[]tabsoid] will match mangled C++ standard library functions.

Member Functions

NameDescription
isTrivialMatchAll Return true if this pattern is the trivial match-all pattern "*".
longest_substr Return the longest plain substring between the pattern prefix and suffix.
match Return true if S matches this glob pattern.
prefix Return the plain (literal) prefix of the pattern.
suffix Return the plain (literal) suffix of the pattern.

Static Member Functions

NameDescription
create Create a GlobPattern from the given pattern string.