Skip to content

Commit b3ec140

Browse files
committed
Apply clang-format
1 parent 845ed68 commit b3ec140

File tree

2 files changed

+35
-32
lines changed

2 files changed

+35
-32
lines changed

llvm/lib/FileCheck/FileCheck.cpp

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ Expected<std::string> NumericSubstitution::getResultRegex() const {
276276

277277
Expected<std::string> NumericSubstitution::getResultForDiagnostics() const {
278278
// The "regex" returned by getResultRegex() is just a numeric value
279-
// like '42', '0x2A', '-17', 'DEADBEEF' etc. This is already suitable for use in diagnostics.
279+
// like '42', '0x2A', '-17', 'DEADBEEF' etc. This is already suitable for use
280+
// in diagnostics.
280281
Expected<std::string> Literal = getResultRegex();
281282
if (!Literal)
282283
return Literal;
@@ -293,35 +294,35 @@ Expected<std::string> StringSubstitution::getResultRegex() const {
293294
}
294295

295296
Expected<std::string> StringSubstitution::getResultForDiagnostics() const {
296-
Expected<StringRef> VarVal = Context->getPatternVarValue(FromStr);
297-
if (!VarVal)
298-
return VarVal.takeError();
299-
300-
std::string Result;
301-
Result.reserve(VarVal->size() + 2);
302-
raw_string_ostream OS(Result);
303-
304-
OS << '"';
305-
// Escape the string if it contains any characters that
306-
// make it hard to read, such as tabs, newlines, quotes, and non-printable characters.
307-
// These are the characters that are escaped by write_escaped(),
308-
// except we do not include backslashes, because they are
309-
// common in Windows paths and escaping them would make the output
310-
// harder to read.
311-
// However, when we do escape, backslashes are escaped as well,
312-
// otherwise the output would be ambiguous.
313-
const bool NeedsEscaping = llvm::any_of(*VarVal, [](char C) {
314-
return C == '\t' || C == '\n' || C == '"' || !isPrint(C);
315-
});
316-
if (NeedsEscaping)
317-
OS.write_escaped(*VarVal);
318-
else
319-
OS << *VarVal;
320-
OS << '"';
321-
if (NeedsEscaping)
322-
OS << " (escaped value)";
323-
324-
return Result;
297+
Expected<StringRef> VarVal = Context->getPatternVarValue(FromStr);
298+
if (!VarVal)
299+
return VarVal.takeError();
300+
301+
std::string Result;
302+
Result.reserve(VarVal->size() + 2);
303+
raw_string_ostream OS(Result);
304+
305+
OS << '"';
306+
// Escape the string if it contains any characters that
307+
// make it hard to read, such as tabs, newlines, quotes, and non-printable
308+
// characters. These are the characters that are escaped by write_escaped(),
309+
// except we do not include backslashes, because they are
310+
// common in Windows paths and escaping them would make the output
311+
// harder to read.
312+
// However, when we do escape, backslashes are escaped as well,
313+
// otherwise the output would be ambiguous.
314+
const bool NeedsEscaping = llvm::any_of(*VarVal, [](char C) {
315+
return C == '\t' || C == '\n' || C == '"' || !isPrint(C);
316+
});
317+
if (NeedsEscaping)
318+
OS.write_escaped(*VarVal);
319+
else
320+
OS << *VarVal;
321+
OS << '"';
322+
if (NeedsEscaping)
323+
OS << " (escaped value)";
324+
325+
return Result;
325326
}
326327

327328
bool Pattern::isValidVarNameStart(char C) { return C == '_' || isAlpha(C); }
@@ -1252,7 +1253,8 @@ void Pattern::printSubstitutions(const SourceMgr &SM, StringRef Buffer,
12521253
SmallString<256> Msg;
12531254
raw_svector_ostream OS(Msg);
12541255

1255-
Expected<std::string> MatchedValue = Substitution->getResultForDiagnostics();
1256+
Expected<std::string> MatchedValue =
1257+
Substitution->getResultForDiagnostics();
12561258
// Substitution failures are handled in printNoMatch().
12571259
if (!MatchedValue) {
12581260
consumeError(MatchedValue.takeError());

llvm/lib/FileCheck/FileCheckImpl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,8 @@ class StringSubstitution : public Substitution {
387387
Expected<std::string> getResultRegex() const override;
388388

389389
/// \returns the text that the string variable in this substitution matched
390-
/// when defined, in a form suitable for diagnostics, or an error if the variable is undefined.
390+
/// when defined, in a form suitable for diagnostics, or an error if the
391+
/// variable is undefined.
391392
Expected<std::string> getResultForDiagnostics() const override;
392393
};
393394

0 commit comments

Comments
 (0)