This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Fix infinite recursion in printing macros
ClosedPublic

Authored by bruntib on Feb 7 2019, 7:09 AM.

Details

Summary

#define f(y) x
#define x f(x)
int main() { x; }

This example results a compilation error since "x" in the first line was not defined earlier. However, the macro expression printer goes to an infinite recursion on this example.

Diff Detail

Repository
rL LLVM

Event Timeline

bruntib created this revision.Feb 7 2019, 7:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2019, 7:09 AM

Is there a chance of obtaining a testcase for this? I would very strongly prefer one.

Szelethus requested changes to this revision.Feb 7 2019, 8:08 AM
This revision now requires changes to proceed.Feb 7 2019, 8:08 AM
bruntib updated this revision to Diff 189670.Mar 7 2019, 2:34 AM

I added a test case for this recursive case. There is also a TODO in the code indicating the place where an additional fix will be required.

Szelethus accepted this revision.Mar 7 2019, 2:47 AM

Well, yea, getting rid of a crash is great, it's kind of bummer that can't expand the macro properly in the testfile. I really fear that we need a far greater overhaul of this entire effort to support them properly -- which should be the task of another patch.

Thanks!

This revision is now accepted and ready to land.Mar 7 2019, 2:47 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMar 8 2019, 8:25 AM