-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[NFC] Fix evaluation order dependency in call arguments #141366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NFC] Fix evaluation order dependency in call arguments #141366
Conversation
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/
@llvm/pr-subscribers-backend-arm Author: Michael Jabbour (michael-jabbour-sonarsource) ChangesThe code in The fix separates the calls to establish explicit sequencing, ensuring This issue was detected by the CFamily analyzer for SonarQube. I'm happy to provide any additional information or clarification as needed. Full diff: https://github.com/llvm/llvm-project/pull/141366.diff 1 Files Affected:
diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
index 85b107c6085d3..ee3dc7d8a3618 100644
--- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -11788,9 +11788,8 @@ bool ARMAsmParser::parseDirectiveReq(StringRef Name, SMLoc L) {
Parser.Lex(); // Eat the '.req' token.
MCRegister Reg;
SMLoc SRegLoc, ERegLoc;
- if (check(parseRegister(Reg, SRegLoc, ERegLoc), SRegLoc,
- "register name expected") ||
- parseEOL())
+ const bool parseResult = parseRegister(Reg, SRegLoc, ERegLoc);
+ if (check(parseResult, SRegLoc, "register name expected") || parseEOL())
return true;
if (RegisterReqs.insert(std::make_pair(Name, Reg)).first->second != Reg)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. LGTM
Thanks for the quick review! Feel free to merge this as I don't have commit access myself 😄 |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/88/builds/12116 Here is the relevant piece of the build log for the reference
|
The code in
ARMAsmParser::parseDirectiveReq
passes bothparseRegister(Reg, SRegLoc, ERegLoc)
andSRegLoc
as arguments tocheck()
. Since function arguments are indeterminately sequenced per C++17 [expr.call]/5, a compiler can evaluateSRegLoc
beforeparseRegister()
executes. This meanscheck()
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. I'm happy to provide any additional information or clarification as needed.