This is an archive of the discontinued LLVM Phabricator instance.

[flang] Rework preprocessing of stringification
ClosedPublic

Authored by klausler on Sep 14 2020, 4:10 PM.

Details

Summary

Hew more closely to the C17 standard; perform macro replacement
of arguments to function-like macros unless they're being stringified
(if that's a word) or pasted. Test with a model "assert" macro idiom that
exposed the problem.

Diff Detail

Event Timeline

klausler created this revision.Sep 14 2020, 4:10 PM
Herald added a project: Restricted Project. · View Herald Transcript
klausler requested review of this revision.Sep 14 2020, 4:10 PM
PeteSteinfeld accepted this revision.Sep 14 2020, 6:07 PM

All builds, tests, and looks good.

This revision is now accepted and ready to land.Sep 14 2020, 6:07 PM

Is this a documented assert idiom? Wouldn't macro expansion occur if STR(x) did not immediately apply the stringification (but instead expanded to an invocation of another macro)?

klausler updated this revision to Diff 292601.Sep 17 2020, 1:14 PM
klausler retitled this revision from [flang] Preprocessor's stringifying operator (#x) must replace macros to [flang] Rework preprocessing of stringification.
klausler edited the summary of this revision. (Show Details)

Fix was wrong -- it masked the actual problem rather than solving it. Here's a second take.

PeteSteinfeld accepted this revision.Sep 17 2020, 1:24 PM

Things still build, test, and look good.

This revision was automatically updated to reflect the committed changes.