Skip to content

Commit 8fe33a0

Browse files
[NFC] Fix evaluation order dependency in call arguments (#141366)
The code in `ARMAsmParser::parseDirectiveReq` passes both `parseRegister(Reg, SRegLoc, ERegLoc)` and `SRegLoc` as arguments to `check()`. Since function arguments are indeterminately sequenced per C++17 [expr.call]/5, a compiler can evaluate `SRegLoc` before `parseRegister()` executes. This means `check()` receives a null location instead of the actual parsed source location for error reporting. The fix separates the calls to establish explicit sequencing, ensuring `check()` receives the correct source location. This issue was detected by [the CFamily analyzer for SonarQube](https://www.sonarsource.com/knowledge/languages/cpp/). I'm happy to provide any additional information or clarification as needed.
1 parent 052c704 commit 8fe33a0

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11787,9 +11787,8 @@ bool ARMAsmParser::parseDirectiveReq(StringRef Name, SMLoc L) {
1178711787
Parser.Lex(); // Eat the '.req' token.
1178811788
MCRegister Reg;
1178911789
SMLoc SRegLoc, ERegLoc;
11790-
if (check(parseRegister(Reg, SRegLoc, ERegLoc), SRegLoc,
11791-
"register name expected") ||
11792-
parseEOL())
11790+
const bool parseResult = parseRegister(Reg, SRegLoc, ERegLoc);
11791+
if (check(parseResult, SRegLoc, "register name expected") || parseEOL())
1179311792
return true;
1179411793

1179511794
if (RegisterReqs.insert(std::make_pair(Name, Reg)).first->second != Reg)

0 commit comments

Comments
 (0)