Skip to content

Commit 8962743

Browse files
yoneymeta-codesync[bot]
authored andcommitted
Use raw string literals
Summary: Use raw string literals and clang-tidy check. Reviewed By: alexmalyshev Differential Revision: D83696398 fbshipit-source-id: b2e4c74610d71eb74caf56b8002d3a4e40737fbb
1 parent 05677b7 commit 8962743

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

cinderx/.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ InheritParentConfig: true
66

77
Checks: '
88
-facebook-hte-NullableReturn,
9+
modernize-raw-string-literal,
910
'

cinderx/Jit/lir/parser.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ Parser::Token Parser::getNextToken(const char* str) {
3838
{"E[A-DS][IPX]", kPhyReg},
3939
{"[A-DS][IPX]L?", kPhyReg},
4040
{"XMM[0-9]+", kPhyReg},
41-
{"\\[RBP[ ]?-[ ]?(\\d+)\\]", kStack},
41+
{R"(\[RBP[ ]?-[ ]?(\d+)\])", kStack},
4242
{"\\[(0x[0-9a-fA-F]+)\\]", kAddress},
43-
{"(\\d+)(\\(0x[0-9a-fA-F]+\\))?", kImmediate},
43+
{R"((\d+)(\(0x[0-9a-fA-F]+\))?)", kImmediate},
4444
{"BB%(\\d+)", kBasicBlockRef},
4545
{"[A-Za-z_][A-Za-z0-9_]+", kId},
4646
{"=", kEqual},
@@ -49,8 +49,8 @@ Parser::Token Parser::getNextToken(const char* str) {
4949
{"\\)", kParRight},
5050
{"#.*\n", kComment},
5151
{":[A-Za-z0-9]+", kDataType},
52-
{"\\[[^\\]]*\\]", kIndirect},
53-
{"\"[^\"]+\"", kStringLiteral}};
52+
{R"(\[[^\]]*\])", kIndirect},
53+
{R"("[^"]+")", kStringLiteral}};
5454

5555
std::cmatch m;
5656
for (auto& pattern : patterns) {
@@ -479,8 +479,8 @@ void Parser::parseIndirect(
479479
}
480480

481481
// parse index and multiplier
482-
std::regex index_reg = std::regex("\\+ %(\\d+):[0-9a-zA-Z]+( \\* (\\d+))?");
483-
std::regex index_phys = std::regex("\\+ (R[0-9A-Z]+):Object( \\* (\\d+))?");
482+
std::regex index_reg = std::regex(R"(\+ %(\d+):[0-9a-zA-Z]+( \* (\d+))?)");
483+
std::regex index_phys = std::regex(R"(\+ (R[0-9A-Z]+):Object( \* (\d+))?)");
484484
bool index_re_success = false;
485485
if (std::regex_search(token.begin(), token.end(), m, index_reg)) {
486486
auto index_id = std::stoll(m.str(1).c_str(), nullptr, 0);

cinderx/RuntimeTests/backend_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ BB %5 - preds: %6
797797
caller.sortBasicBlocks();
798798
ss << caller;
799799
// Replace the string literal address
800-
std::regex reg("\\d+\\(0x[0-9a-fA-F]+\\):Object, %21:Object, %20:Object");
800+
std::regex reg(R"(\d+\(0x[0-9a-fA-F]+\):Object, %21:Object, %20:Object)");
801801
std::string caller_str =
802802
regex_replace(ss.str(), reg, "string_literal, %21:Object, %20:Object");
803803
ASSERT_EQ(expected_caller, caller_str);
@@ -870,7 +870,7 @@ BB %5 - preds: %6
870870
caller->sortBasicBlocks();
871871
ss << *caller;
872872
// Replace the string literal address
873-
std::regex reg("\\d+\\(0x[0-9a-fA-F]+\\):Object, %21:Object, %20:Object");
873+
std::regex reg(R"(\d+\(0x[0-9a-fA-F]+\):Object, %21:Object, %20:Object)");
874874
std::string caller_str =
875875
regex_replace(ss.str(), reg, "string_literal, %21:Object, %20:Object");
876876
ASSERT_EQ(expected_caller, caller_str);

0 commit comments

Comments
 (0)