-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[llvm-ml] Remove unsafe getCurrentSegmentOnly() call #123355
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
Conversation
|
@llvm/pr-subscribers-mc Author: Eric Astor (ericastor) ChangesThis call was made unsafe recently, but was not fixed in db48f1a (the commit that fixed the parallel code in AsmParser.cpp). Full diff: https://github.com/llvm/llvm-project/pull/123355.diff 1 Files Affected:
diff --git a/llvm/lib/MC/MCParser/MasmParser.cpp b/llvm/lib/MC/MCParser/MasmParser.cpp
index 78261c1f9fedb2..6c49a17180f27b 100644
--- a/llvm/lib/MC/MCParser/MasmParser.cpp
+++ b/llvm/lib/MC/MCParser/MasmParser.cpp
@@ -1454,7 +1454,7 @@ bool MasmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
}
bool MasmParser::checkForValidSection() {
- if (!ParsingMSInlineAsm && !getStreamer().getCurrentSectionOnly()) {
+ if (!ParsingMSInlineAsm && !getStreamer().getCurrentFragment()) {
Out.initSections(false, getTargetParser().getSTI());
return Error(getTok().getLoc(),
"expected section directive before assembly directive");
|
|
Could you add a test? |
|
Added tests as requested. |
|
The two commits intended to simplify MC internals. That said, I should be honest. I am deeply concerned with the state of MasmParser.cpp. I don't think it is reasonable to require contributors that refactor MC to understand |
| /// label "endproc" | ||
| bool COFFMasmParser::parseDirectiveProc(StringRef Directive, SMLoc Loc) { | ||
| if (!getStreamer().getCurrentFragment()) { | ||
| return Error(getTok().getLoc(), "expected section directive before '" + |
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.
The convention is to just state expected something and omit before directive .... The before directive information is obvious from the source line that is printed
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.
Revised accordingly.
I agree. To be honest, I was surprised the test suite didn't already cover this case, so this was definitely a mistake on my part. I'm just interested which tests (EDIT: for the base AsmParser) detected the issue with this refactor of MC, but I'm pleased to hear that they were broken and detected the issue before submission. In terms of reducing MasmParser.cpp... I agree that it could use a lot of cleanup. I would very much like to work on improving the test case coverage. Is there an easy way to get coverage reporting out of the LLVM test suite? I'm apparently not familiar with it, and since it's very much designed as more of an integration-test framework, I don't know any obvious tricks. |
| /// label "endproc" | ||
| bool COFFMasmParser::parseDirectiveProc(StringRef Directive, SMLoc Loc) { | ||
| if (!getStreamer().getCurrentFragment()) { | ||
| return Error(getTok().getLoc(), "expected section directive"); |
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.
omit braces for the single line simple statement
| @@ -0,0 +1,7 @@ | |||
| ; RUN: not llvm-ml -filetype=s %s /Fo /dev/null 2>&1 | FileCheck %s | |||
|
|
|||
| ; CHECK: :[[# @LINE + 1]]:1: error: expected section directive before 'PROC' directive | |||
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.
This is ok, but in the majority of tests we omit spaces beside +: LINE+1
This call was made unsafe recently, but was not fixed in db48f1a (the commit that fixed the parallel code in AsmParser.cpp).
Fixes #123189