Skip to content

Implement conservative subset of --translate-const-macros #1295

@fw-immunant

Description

@fw-immunant

--translate-const-macros in its full generality is very hard to implement, because it's quite difficult to determine if nontrivial expessions will be const-safe; see this comment. It seems like it may not be worth the effort to make the implementation much more complex because it will never cover all possible uses of even non-function-like C macros.

That said, it's annoying that we don't have a way to pick the low-hanging fruit here without attempting to tackle the thornier issues. We should implement a minimal implementation of similar functionality that handles #define NAME literal and then in a follow-up expand to handle a minimal conservative subset of expressions such as variable references and binary/unary/paren expressions. By staying extremely conservative we can sidestep the const safety question entirely for now.

We might implement this as a mode/argument for the existing --translate-const-macros flag, but in any case we want whatever we come up with to be enabled by default, which means it needs solid testing.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions