-
Notifications
You must be signed in to change notification settings - Fork 25
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
fix: EXLR flagged as error by plugin #121
fix: EXLR flagged as error by plugin #121
Conversation
Signed-off-by: Sweta Shah <swetas04@GMAIL.COM>
Signed-off-by: Sweta Shah <swetas04@GMAIL.COM>
parser_library/src/diagnostic.cpp
Outdated
{ | ||
return diagnostic_op(diagnostic_severity::warning, | ||
"D031", | ||
" Operand value must be relocatable symbol with instruction " + instr, |
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.
I think it would be more useful to report the operand we're generating the warning for instead of the instruction name + replace must with should as this is a warning.
parser_library/src/diagnostic.h
Outdated
@@ -439,6 +439,7 @@ struct diagnostic_op | |||
static diagnostic_op error_D023(const range& range); | |||
static diagnostic_op error_D024(const range& range, const std::string& type); | |||
static diagnostic_op warn_D025(const range& range, const std::string& type, const std::string& modifier); | |||
static diagnostic_op warn_D031(const range& range, const std::string& modifier); |
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.
reorder, please.
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.
Please add a test generating this message.
parser_library/src/diagnostic.h
Outdated
@@ -457,20 +458,20 @@ struct diagnostic_op | |||
|
|||
static diagnostic_op error_M112(const std::string& instr_name, const range& range); | |||
|
|||
static diagnostic_op error_M113(const std::string& instr_name, const range& range); |
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.
I think we should keep the original message ids, the messages relate to basically the same issues as before.
@@ -287,6 +287,13 @@ bool one_operand::check( | |||
} | |||
return true; | |||
} | |||
// simple operand with relocatable symbol or immediate value | |||
|
|||
if (to_check.identifier.type == machine_operand_type::RELOC_IMM && operand_identifier != "RELOC") |
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 basically reusing the operand_identifier
as an flag, right? I suggest introducing that flag instead.
@@ -36,7 +36,7 @@ TEST(diagnostics, overall_correctness) | |||
|
|||
ASSERT_EQ(a.parser().getNumberOfSyntaxErrors(), (size_t)0); | |||
|
|||
ASSERT_EQ(dynamic_cast<hlasm_plugin::parser_library::diagnosable*>(&a)->diags().size(), (size_t)0); | |||
ASSERT_EQ(dynamic_cast<hlasm_plugin::parser_library::diagnosable*>(&a)->diags().size(), (size_t)1); |
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.
ASSERT_EQ(dynamic_cast<hlasm_plugin::parser_library::diagnosable*>(&a)->diags().size(), (size_t)1); | |
ASSERT_EQ(dynamic_cast<hlasm_plugin::parser_library::diagnosable*>(&a)->diags().size(), (size_t)0); |
I suggest fixing the source instead.
@@ -236,7 +236,7 @@ TEST(diagnostics, mnemonics) | |||
|
|||
ASSERT_EQ(a.parser().getNumberOfSyntaxErrors(), (size_t)0); | |||
|
|||
ASSERT_EQ(dynamic_cast<hlasm_plugin::parser_library::diagnosable*>(&a)->diags().size(), (size_t)0); | |||
ASSERT_EQ(dynamic_cast<hlasm_plugin::parser_library::diagnosable*>(&a)->diags().size(), (size_t)20); |
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.
ASSERT_EQ(dynamic_cast<hlasm_plugin::parser_library::diagnosable*>(&a)->diags().size(), (size_t)20); | |
ASSERT_EQ(dynamic_cast<hlasm_plugin::parser_library::diagnosable*>(&a)->diags().size(), (size_t)0); |
The same here, we should be able to create jump targets that are far enough.
else if (res.value_kind() == context::symbol_value_kind::RELOC && type_hint | ||
&& *type_hint == checking::machine_operand_type::RELOC_IMM) | ||
{ | ||
return std::make_unique<checking::one_operand>("RELOC", res.get_reloc().offset()); |
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 code would accept instructions like:
RELOC LR 1,1
EXRL 1,RELOC+5
EXRL 1,RELOC+RELOC
The second one is definitely invalid, I am not sure about the first one.
We should generate this special operand only when the relocatable symbol is not complex (res.get_reloc().is_simple()
) and maybe even just when it is just a simple symbol (not sure about the latter).
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 exrl
takes the difference in halfwords (multiples of 2 bytes), so reloc+5
cannot be represented at all.
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.
OK, but RELOC+4
would be fine?
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.
yes, reloc+4
is ok.
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.
Length being multiple of 2 bytes holds true only for exrl instruction or for all instructions with relative addressing?
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.
as far as I know, it's for all reladdr operands.
Signed-off-by: Sweta Shah <swetas04@GMAIL.COM>
Signed-off-by: Sweta Shah <swetas04@GMAIL.COM>
if (lc.get_reloc().offset() > symb.get_reloc().offset()) | ||
return (left_->evaluate(info) - right_->evaluate(info)); | ||
else | ||
return (right_->evaluate(info) - left_->evaluate(info)); |
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.
I don't understand this part... relative address may very well be positive or negative.
I'd expect simply target-location
.
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.
Okay, thanks for pointing out. I misunderstood it as difference should be always positive value, will change it to target - location.
Co-authored-by: slavek-kucera <53339291+slavek-kucera@users.noreply.github.com>
…ithub.com/SWETAS04/che-che4z-lsp-for-hlasm into Fix_format_to_support_relocatable_symbols
Signed-off-by: Sweta Shah <swetas04@GMAIL.COM>
Signed-off-by: Sweta Shah <swetas04@GMAIL.COM>
{ | ||
// replaced operands are skipped being immediate values | ||
if (replaced.size() != 0 && replaced.at(position).first == position) | ||
if (!replaced.empty() && replaced.at(position).first == position) |
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.
I think this is wrong... The replaced
vector contains index, value
pairs, so if the replacement occurs at position 3, it contains a single pair 3,value
, so .at(3)
will throw.
Also there may be multiple replacements in a row, so this should probably be some kind of loop.
@michalbali256 - do you concur?
if (auto mnem_tmp = context::instruction::mnemonic_codes.find(*instruction); | ||
mnem_tmp != context::instruction::mnemonic_codes.end()) | ||
{ | ||
instruction_name = context::instruction::mnemonic_codes.at(*instruction).instruction->instr_name; | ||
replaced = context::instruction::mnemonic_codes.at(*instruction).replaced; | ||
} |
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 could be simplified a bit to something like
if (auto mnem_tmp = context::instruction::mnemonic_codes.find(*instruction); | |
mnem_tmp != context::instruction::mnemonic_codes.end()) | |
{ | |
instruction_name = context::instruction::mnemonic_codes.at(*instruction).instruction->instr_name; | |
replaced = context::instruction::mnemonic_codes.at(*instruction).replaced; | |
} | |
const machine_instruction* instr; | |
const std::vector<std::pair<size_t, size_t>>* replaced = nullptr; | |
if (auto mnem_tmp = context::instruction::mnemonic_codes.find(*instruction); | |
mnem_tmp != context::instruction::mnemonic_codes.end()) | |
{ | |
instr = mnem_tmp->instruction; | |
replaced = &mnem_tmp->replaced; | |
} | |
else | |
{ | |
instr = &context::instruction::machine_instructions.at(*instruction); | |
} |
but it needs to be properly incorporated into the rest of the code
…ithub.com/SWETAS04/che-che4z-lsp-for-hlasm into Fix_format_to_support_relocatable_symbols
…p-for-hlasm into Fix_format_to_support_relocatable_symbols
{ | ||
if (instruction->empty()) |
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.
when does this happen?
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.
There is a test "parse_bad_model" where it occurs
…p-for-hlasm into Fix_format_to_support_relocatable_symbols
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.
👍
parser_library/src/diagnostic.cpp
Outdated
{ | ||
return diagnostic_op(diagnostic_severity::error, | ||
"ME003", | ||
"Relative Immediate Operand value must be signed number of halfwords.", |
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 message implies to me, that the user should write a number as the argument.
"Relative Immediate Operand value must be signed number of halfwords.", | |
"Relative immediate operand must evaluate into a number of halfwords (must result in even number of bytes)", |
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.
maybe just Relative immediate operand must evaluate into an even offset
?
checking::address_state::UNRES, 0, 0, 0, checking::operand_state::ONE_OP); | ||
} | ||
} | ||
std::unique_ptr<checking::operand> check_operand( |
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.
could you rename this method? Now, it is not clear what is the difference between methods check_operand
and make_check_operand
Co-authored-by: Michal Bali <38988507+michalbali256@users.noreply.github.com>
…ithub.com/SWETAS04/che-che4z-lsp-for-hlasm into Fix_format_to_support_relocatable_symbols
Kudos, SonarCloud Quality Gate passed! |
🎉 This PR is included in version 0.14.0-beta.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 0.14.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This PR incudes a new operand type which accepts either a relocatable symbol or absolute immediate value( with a warning).
Other Instructions which suffer from the same problem are also changed.