Skip to content
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

M3.macroDefinitions problems #15

Closed
jmerle opened this issue May 14, 2020 · 2 comments
Closed

M3.macroDefinitions problems #15

jmerle opened this issue May 14, 2020 · 2 comments

Comments

@jmerle
Copy link

jmerle commented May 14, 2020

I just updated all my Eclipse plugins and noticed some errors in code that uses M3.macroDefinitions. It seems that the changes in 730b96d created some bugs:

  • M3.macroDefinitions now contains macro expansions instead of definitions (presumably caused by the change of Stream.of(tu.getMacroDefinitions()) to Stream.of(tu.getMacroExpansions())).
  • M3.macroDefinitions now contains a rel[loc src, loc macro] instead of the rel[loc macro, loc src] it used to be, even though the M3.rsc file still says it should be a rel[loc macro, loc src].
@jmerle
Copy link
Author

jmerle commented May 14, 2020

Here's a small example:

module MacroDefinitions

import IO;
import lang::cpp::M3;

void main() {
	tempFile = |tmp:///definitions.c|;
	
	writeFile(tempFile, "#define SOME_CONSTANT 42
						'
						'int main() {
						'    int value = SOME_CONSTANT;
						'    return 0;
						'}");
	
	model = createM3FromCppFile(tempFile);
	
	println("model.macroDefinitions:");
	iprintln(model.macroDefinitions);
	
	println("model.macroExpansions:");
	iprintln(model.macroExpansions);
}

Outputs:

model.macroDefinitions:
{<|tmp:///definitions.c|(58,13),|cpp+macro:///SOME_CONSTANT|>}
model.macroExpansions:
{<|tmp:///definitions.c|(58,13),|cpp+macro:///SOME_CONSTANT|>}

Before the commit I linked model.macroDefinitions would contain {<|cpp+macro:///SOME_CONSTANT|,|tmp:///definitions.c|(0,24)>}, where the second location's offset and length are set to enclose #define SOME_CONSTANT 42.

@rodinaarssen
Copy link
Member

Hi Jmerle. Thanks for the detailed report! I seem to have been a bit over-eager in copying. Please let me know if you still encounter anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants