Skip to content

Commit 74f843d

Browse files
committed
[ELF] Replace unquote(next()) with readName. NFC
1 parent 0d8bc10 commit 74f843d

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

lld/ELF/ScriptParser.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class ScriptParser final : ScriptLexer {
123123
Expr combine(StringRef op, Expr l, Expr r);
124124
Expr readExpr();
125125
Expr readExpr1(Expr lhs, int minPrec);
126-
StringRef readParenLiteral();
126+
StringRef readParenName();
127127
Expr readPrimary();
128128
Expr readTernary(Expr cond);
129129
Expr readParenExpr();
@@ -383,9 +383,9 @@ void ScriptParser::readAsNeeded() {
383383
void ScriptParser::readEntry() {
384384
// -e <symbol> takes predecence over ENTRY(<symbol>).
385385
expect("(");
386-
StringRef tok = next();
386+
StringRef name = readName();
387387
if (config->entry.empty())
388-
config->entry = unquote(tok);
388+
config->entry = name;
389389
expect(")");
390390
}
391391

@@ -435,9 +435,9 @@ void ScriptParser::readInput() {
435435
void ScriptParser::readOutput() {
436436
// -o <file> takes predecence over OUTPUT(<file>).
437437
expect("(");
438-
StringRef tok = next();
438+
StringRef name = readName();
439439
if (config->outputFile.empty())
440-
config->outputFile = unquote(tok);
440+
config->outputFile = name;
441441
expect(")");
442442
}
443443

@@ -1300,7 +1300,7 @@ Expr ScriptParser::getPageSize() {
13001300
}
13011301

13021302
Expr ScriptParser::readConstant() {
1303-
StringRef s = readParenLiteral();
1303+
StringRef s = readParenName();
13041304
if (s == "COMMONPAGESIZE")
13051305
return getPageSize();
13061306
if (s == "MAXPAGESIZE")
@@ -1416,11 +1416,11 @@ std::pair<uint64_t, uint64_t> ScriptParser::readInputSectionFlags() {
14161416
return std::make_pair(withFlags, withoutFlags);
14171417
}
14181418

1419-
StringRef ScriptParser::readParenLiteral() {
1419+
StringRef ScriptParser::readParenName() {
14201420
expect("(");
14211421
bool orig = inExpr;
14221422
inExpr = false;
1423-
StringRef tok = next();
1423+
StringRef tok = readName();
14241424
inExpr = orig;
14251425
expect(")");
14261426
return tok;
@@ -1469,7 +1469,7 @@ Expr ScriptParser::readPrimary() {
14691469
};
14701470
}
14711471
if (tok == "ADDR") {
1472-
StringRef name = unquote(readParenLiteral());
1472+
StringRef name = readParenName();
14731473
OutputSection *osec = &script->getOrCreateOutputSection(name)->osec;
14741474
osec->usedInExpression = true;
14751475
return [=]() -> ExprValue {
@@ -1494,7 +1494,7 @@ Expr ScriptParser::readPrimary() {
14941494
};
14951495
}
14961496
if (tok == "ALIGNOF") {
1497-
StringRef name = unquote(readParenLiteral());
1497+
StringRef name = readParenName();
14981498
OutputSection *osec = &script->getOrCreateOutputSection(name)->osec;
14991499
return [=] {
15001500
checkIfExists(*osec, location);
@@ -1536,7 +1536,7 @@ Expr ScriptParser::readPrimary() {
15361536
return [=] { return alignToPowerOf2(script->getDot(), config->maxPageSize); };
15371537
}
15381538
if (tok == "DEFINED") {
1539-
StringRef name = unquote(readParenLiteral());
1539+
StringRef name = readParenName();
15401540
// Return 1 if s is defined. If the definition is only found in a linker
15411541
// script, it must happen before this DEFINED.
15421542
auto order = ctx.scriptSymOrderCounter++;
@@ -1547,15 +1547,15 @@ Expr ScriptParser::readPrimary() {
15471547
};
15481548
}
15491549
if (tok == "LENGTH") {
1550-
StringRef name = readParenLiteral();
1550+
StringRef name = readParenName();
15511551
if (script->memoryRegions.count(name) == 0) {
15521552
setError("memory region not defined: " + name);
15531553
return [] { return 0; };
15541554
}
15551555
return script->memoryRegions[name]->length;
15561556
}
15571557
if (tok == "LOADADDR") {
1558-
StringRef name = unquote(readParenLiteral());
1558+
StringRef name = readParenName();
15591559
OutputSection *osec = &script->getOrCreateOutputSection(name)->osec;
15601560
osec->usedInExpression = true;
15611561
return [=] {
@@ -1583,7 +1583,7 @@ Expr ScriptParser::readPrimary() {
15831583
return [=] { return std::max(a().getValue(), b().getValue()); };
15841584
}
15851585
if (tok == "ORIGIN") {
1586-
StringRef name = readParenLiteral();
1586+
StringRef name = readParenName();
15871587
if (script->memoryRegions.count(name) == 0) {
15881588
setError("memory region not defined: " + name);
15891589
return [] { return 0; };
@@ -1599,7 +1599,7 @@ Expr ScriptParser::readPrimary() {
15991599
return [=] { return e(); };
16001600
}
16011601
if (tok == "SIZEOF") {
1602-
StringRef name = unquote(readParenLiteral());
1602+
StringRef name = readParenName();
16031603
OutputSection *cmd = &script->getOrCreateOutputSection(name)->osec;
16041604
// Linker script does not create an output section if its content is empty.
16051605
// We want to allow SIZEOF(.foo) where .foo is a section which happened to

0 commit comments

Comments
 (0)