Skip to content

Commit c89566f

Browse files
committed
[ELF] Replace unquote(next()) with readName. NFC
1 parent 30ec2bf commit c89566f

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

lld/ELF/ScriptParser.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -405,22 +405,21 @@ void ScriptParser::readGroup() {
405405
}
406406

407407
void ScriptParser::readInclude() {
408-
StringRef tok = unquote(next());
409-
410-
if (!seen.insert(tok).second) {
408+
StringRef name = readName();
409+
if (!seen.insert(name).second) {
411410
setError("there is a cycle in linker script INCLUDEs");
412411
return;
413412
}
414413

415-
if (std::optional<std::string> path = searchScript(tok)) {
414+
if (std::optional<std::string> path = searchScript(name)) {
416415
if (std::optional<MemoryBufferRef> mb = readFile(*path)) {
417416
buffers.push_back(curBuf);
418417
curBuf = Buffer(*mb);
419418
mbs.push_back(*mb);
420419
}
421420
return;
422421
}
423-
setError("cannot find linker script " + tok);
422+
setError("cannot find linker script " + name);
424423
}
425424

426425
void ScriptParser::readInput() {
@@ -488,14 +487,14 @@ static std::pair<ELFKind, uint16_t> parseBfdName(StringRef s) {
488487
void ScriptParser::readOutputFormat() {
489488
expect("(");
490489

491-
StringRef s = unquote(next());
490+
StringRef s = readName();
492491
if (!consume(")")) {
493492
expect(",");
494-
StringRef tmp = unquote(next());
493+
StringRef tmp = readName();
495494
if (config->optEB)
496495
s = tmp;
497496
expect(",");
498-
tmp = unquote(next());
497+
tmp = readName();
499498
if (config->optEL)
500499
s = tmp;
501500
consume(")");
@@ -548,7 +547,7 @@ void ScriptParser::readPhdrs() {
548547

549548
void ScriptParser::readRegionAlias() {
550549
expect("(");
551-
StringRef alias = unquote(next());
550+
StringRef alias = readName();
552551
expect(",");
553552
StringRef name = next();
554553
expect(")");
@@ -562,9 +561,9 @@ void ScriptParser::readRegionAlias() {
562561

563562
void ScriptParser::readSearchDir() {
564563
expect("(");
565-
StringRef tok = next();
564+
StringRef name = readName();
566565
if (!config->nostdlib)
567-
config->searchPaths.push_back(unquote(tok));
566+
config->searchPaths.push_back(name);
568567
expect(")");
569568
}
570569

@@ -680,7 +679,7 @@ void ScriptParser::readTarget() {
680679
// for --format. We recognize only /^elf/ and "binary" in the linker
681680
// script as well.
682681
expect("(");
683-
StringRef tok = unquote(next());
682+
StringRef tok = readName();
684683
expect(")");
685684

686685
if (tok.starts_with("elf"))
@@ -766,7 +765,7 @@ SmallVector<SectionPattern, 0> ScriptParser::readInputSectionsList() {
766765
setError("section pattern is expected");
767766
break;
768767
}
769-
SectionMatcher.addPattern(unquote(next()));
768+
SectionMatcher.addPattern(readName());
770769
}
771770

772771
if (!SectionMatcher.empty())
@@ -860,7 +859,7 @@ Expr ScriptParser::readAssert() {
860859
expect("(");
861860
Expr e = readExpr();
862861
expect(",");
863-
StringRef msg = unquote(next());
862+
StringRef msg = readName();
864863
expect(")");
865864

866865
return [=] {
@@ -1392,11 +1391,11 @@ static std::optional<uint64_t> parseFlag(StringRef tok) {
13921391
// Example: SHF_EXECINSTR & !SHF_WRITE means with flag SHF_EXECINSTR and
13931392
// without flag SHF_WRITE.
13941393
std::pair<uint64_t, uint64_t> ScriptParser::readInputSectionFlags() {
1395-
uint64_t withFlags = 0;
1396-
uint64_t withoutFlags = 0;
1397-
expect("(");
1398-
while (!errorCount()) {
1399-
StringRef tok = unquote(next());
1394+
uint64_t withFlags = 0;
1395+
uint64_t withoutFlags = 0;
1396+
expect("(");
1397+
while (!errorCount()) {
1398+
StringRef tok = readName();
14001399
bool without = tok.consume_front("!");
14011400
if (std::optional<uint64_t> flag = parseFlag(tok)) {
14021401
if (without)

0 commit comments

Comments
 (0)