Skip to content

Commit bee799c

Browse files
[NFC] Fix evaluation order dependency in call arguments
The code assumes parseRegister() executes before the standalone SRegLoc argument to check(). Since function arguments are indeterminately sequenced per C++17 [expr.call]/5, check() may receive a null location instead of the actual parsed source location. Detected by the CFamily analyzer for SonarQube. https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/languages/c-family/overview/
1 parent dcef154 commit bee799c

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
@@ -11788,9 +11788,8 @@ bool ARMAsmParser::parseDirectiveReq(StringRef Name, SMLoc L) {
1178811788
Parser.Lex(); // Eat the '.req' token.
1178911789
MCRegister Reg;
1179011790
SMLoc SRegLoc, ERegLoc;
11791-
if (check(parseRegister(Reg, SRegLoc, ERegLoc), SRegLoc,
11792-
"register name expected") ||
11793-
parseEOL())
11791+
const bool parseResult = parseRegister(Reg, SRegLoc, ERegLoc);
11792+
if (check(parseResult, SRegLoc, "register name expected") || parseEOL())
1179411793
return true;
1179511794

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

0 commit comments

Comments
 (0)