[lld] efa833d - [ELF] Simplify readExpr. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 20 14:37:00 PDT 2024


Author: Fangrui Song
Date: 2024-07-20T14:36:55-07:00
New Revision: efa833dd0f47a4f65df8c64dc145e06d8fb286f2

URL: https://github.com/llvm/llvm-project/commit/efa833dd0f47a4f65df8c64dc145e06d8fb286f2
DIFF: https://github.com/llvm/llvm-project/commit/efa833dd0f47a4f65df8c64dc145e06d8fb286f2.diff

LOG: [ELF] Simplify readExpr. NFC

Added: 
    

Modified: 
    lld/ELF/ScriptParser.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index 92f4bb41cd68f..f20de5e2fb4fb 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -1182,10 +1182,8 @@ SymbolAssignment *ScriptParser::readSymbolAssignment(StringRef name) {
 Expr ScriptParser::readExpr() {
   // Our lexer is context-aware. Set the in-expression bit so that
   // they apply 
diff erent tokenization rules.
-  bool orig = inExpr;
-  inExpr = true;
+  SaveAndRestore saved(inExpr, true);
   Expr e = readExpr1(readPrimary(), 0);
-  inExpr = orig;
   return e;
 }
 
@@ -1251,9 +1249,9 @@ Expr ScriptParser::readExpr1(Expr lhs, int minPrec) {
     StringRef op1 = peek();
     if (precedence(op1) < minPrec)
       break;
-    if (consume("?"))
-      return readTernary(lhs);
     skip();
+    if (op1 == "?")
+      return readTernary(lhs);
     Expr rhs = readPrimary();
 
     // Evaluate the remaining part of the expression first if the


        


More information about the llvm-commits mailing list