Changeset View
Changeset View
Standalone View
Standalone View
llvm/trunk/include/llvm/Support/FileCheck.h
Show First 20 Lines • Show All 149 Lines • ▼ Show 20 Line(s) | 148 | explicit FileCheckPattern(Check::FileCheckType Ty, | |||
---|---|---|---|---|---|
150 | : Context(Context), CheckTy(Ty) {} | 150 | : Context(Context), CheckTy(Ty) {} | ||
151 | 151 | | |||
152 | /// Returns the location in source code. | 152 | /// Returns the location in source code. | ||
153 | SMLoc getLoc() const { return PatternLoc; } | 153 | SMLoc getLoc() const { return PatternLoc; } | ||
154 | 154 | | |||
155 | /// Returns the pointer to the global state for all patterns in this | 155 | /// Returns the pointer to the global state for all patterns in this | ||
156 | /// FileCheck instance. | 156 | /// FileCheck instance. | ||
157 | FileCheckPatternContext *getContext() const { return Context; } | 157 | FileCheckPatternContext *getContext() const { return Context; } | ||
158 | | ||||
158 | /// Return whether \p is a valid first character for a variable name. | 159 | /// Return whether \p is a valid first character for a variable name. | ||
159 | static bool isValidVarNameStart(char C); | 160 | static bool isValidVarNameStart(char C); | ||
160 | /// Verify that the string at the start of \p Str is a well formed variable. | 161 | /// Verify that the string at the start of \p Str is a well formed variable. | ||
161 | /// Return false if it is and set \p IsPseudo to indicate if it is a pseudo | 162 | /// Return false if it is and set \p IsPseudo to indicate if it is a pseudo | ||
162 | /// variable and \p TrailIdx to the position of the last character that is | 163 | /// variable and \p TrailIdx to the position of the last character that is | ||
163 | /// part of the variable name. Otherwise, only return true. | 164 | /// part of the variable name. Otherwise, only return true. | ||
164 | static bool parseVariable(StringRef Str, bool &IsPseudo, unsigned &TrailIdx); | 165 | static bool parseVariable(StringRef Str, bool &IsPseudo, unsigned &TrailIdx); | ||
166 | /// Parse a numeric expression involving pseudo variable \p Name with the | ||||
167 | /// string corresponding to the operation being performed in \p Trailer. | ||||
168 | /// Return whether parsing failed in which case errors are reported on \p SM. | ||||
169 | bool parseExpression(StringRef Name, StringRef Trailer, | ||||
170 | const SourceMgr &SM) const; | ||||
165 | bool ParsePattern(StringRef PatternStr, StringRef Prefix, SourceMgr &SM, | 171 | bool ParsePattern(StringRef PatternStr, StringRef Prefix, SourceMgr &SM, | ||
166 | unsigned LineNumber, const FileCheckRequest &Req); | 172 | unsigned LineNumber, const FileCheckRequest &Req); | ||
167 | size_t match(StringRef Buffer, size_t &MatchLen) const; | 173 | size_t match(StringRef Buffer, size_t &MatchLen) const; | ||
168 | /// Print value of successful substitutions or name of undefined pattern | 174 | /// Print value of successful substitutions or name of undefined pattern | ||
169 | /// variables preventing such a successful substitution. | 175 | /// variables preventing such a successful substitution. | ||
170 | void printVariableUses(const SourceMgr &SM, StringRef Buffer, | 176 | void printVariableUses(const SourceMgr &SM, StringRef Buffer, | ||
171 | SMRange MatchRange = None) const; | 177 | SMRange MatchRange = None) const; | ||
172 | void printFuzzyMatch(const SourceMgr &SM, StringRef Buffer, | 178 | void printFuzzyMatch(const SourceMgr &SM, StringRef Buffer, | ||
173 | std::vector<FileCheckDiag> *Diags) const; | 179 | std::vector<FileCheckDiag> *Diags) const; | ||
174 | 180 | | |||
175 | bool hasVariable() const { | 181 | bool hasVariable() const { | ||
176 | return !(VariableUses.empty() && VariableDefs.empty()); | 182 | return !(VariableUses.empty() && VariableDefs.empty()); | ||
177 | } | 183 | } | ||
178 | 184 | | |||
179 | Check::FileCheckType getCheckTy() const { return CheckTy; } | 185 | Check::FileCheckType getCheckTy() const { return CheckTy; } | ||
180 | 186 | | |||
181 | int getCount() const { return CheckTy.getCount(); } | 187 | int getCount() const { return CheckTy.getCount(); } | ||
182 | 188 | | |||
183 | private: | 189 | private: | ||
184 | bool AddRegExToRegEx(StringRef RS, unsigned &CurParen, SourceMgr &SM); | 190 | bool AddRegExToRegEx(StringRef RS, unsigned &CurParen, SourceMgr &SM); | ||
185 | void AddBackrefToRegEx(unsigned BackrefNum); | 191 | void AddBackrefToRegEx(unsigned BackrefNum); | ||
186 | unsigned computeMatchDistance(StringRef Buffer) const; | 192 | unsigned computeMatchDistance(StringRef Buffer) const; | ||
187 | bool EvaluateExpression(StringRef Expr, std::string &Value) const; | 193 | void evaluateExpression(StringRef Expr, std::string &Value) const; | ||
188 | size_t FindRegexVarEnd(StringRef Str, SourceMgr &SM); | 194 | size_t FindRegexVarEnd(StringRef Str, SourceMgr &SM); | ||
189 | }; | 195 | }; | ||
190 | 196 | | |||
191 | //===----------------------------------------------------------------------===// | 197 | //===----------------------------------------------------------------------===// | ||
192 | /// Summary of a FileCheck diagnostic. | 198 | /// Summary of a FileCheck diagnostic. | ||
193 | //===----------------------------------------------------------------------===// | 199 | //===----------------------------------------------------------------------===// | ||
194 | 200 | | |||
195 | struct FileCheckDiag { | 201 | struct FileCheckDiag { | ||
▲ Show 20 Lines • Show All 126 Lines • Show Last 20 Lines |