[Preprocessor] Always discard body of #define if we failed to parse it
authorIlya Biryukov <ibiryukov@google.com>
Thu, 1 Aug 2019 09:10:37 +0000 (09:10 +0000)
committerIlya Biryukov <ibiryukov@google.com>
Thu, 1 Aug 2019 09:10:37 +0000 (09:10 +0000)
commitb455fc429fe93247b9f88cfe0b659dd899f5c059
treee9be83cf1fb8e79462f88f401f388735b9c8dca7
parente5b5742eed388be582410973e82df3d93752e174
[Preprocessor] Always discard body of #define if we failed to parse it

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.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D65517

llvm-svn: 367530
clang/lib/Lex/PPDirectives.cpp
clang/test/Preprocessor/stringize_skipped.c [new file with mode: 0644]
clang/unittests/Tooling/Syntax/TokensTest.cpp