This is an archive of the discontinued LLVM Phabricator instance.

[Preprocessor] Always discard body of #define if we failed to parse it
ClosedPublic

Authored by ilya-biryukov on Jul 31 2019, 7:59 AM.

Details

Summary

Preivously we would only discard it if we failed to parse parameter lists.
If we do not consume the body, parser sees tokens inside directive. In
turn, this leads to spurious diagnostics and a crash in TokenBuffer, see
the added tests.

Event Timeline

ilya-biryukov created this revision.Jul 31 2019, 7:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 31 2019, 7:59 AM
ilya-biryukov edited the summary of this revision. (Show Details)Jul 31 2019, 9:53 AM
sammccall accepted this revision.Jul 31 2019, 10:23 AM

LG, though I'm obviously not an expert here. Thanks for tracking this down!

clang/lib/Lex/PPDirectives.cpp
2405

nit: "if we are still waiting for eod"? (to avoid inverting the sense)

This revision is now accepted and ready to land.Jul 31 2019, 10:23 AM
ilya-biryukov marked an inline comment as done.
  • Update a comment
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 1 2019, 2:10 AM

@hans, could you please merge rL367530 into the release?

hans added a comment.Aug 1 2019, 2:50 AM

@hans, could you please merge rL367530 into the release?

Sure! Let's have it bake in trunk for a bit, and then I'll merge it.

SG, just wanted to make sure it's on your list ;-)

hans added a comment.Aug 2 2019, 6:39 AM

SG, just wanted to make sure it's on your list ;-)

Merged in r367681.