]> granicus.if.org Git - clang/commit
[clang-format] fix crash involving invalid preprocessor line
authorKrasimir Georgiev <krasimir@google.com>
Thu, 8 Aug 2019 11:56:18 +0000 (11:56 +0000)
committerKrasimir Georgiev <krasimir@google.com>
Thu, 8 Aug 2019 11:56:18 +0000 (11:56 +0000)
commit4579bbc8bd0bf203c0ed98fc2b321ee2996b02d3
tree7169da38e22893f12f056c7680cec0f05102fbc8
parentf4d08425a85cf030a86f4895c3cf5d39b91a4fd0
[clang-format] fix crash involving invalid preprocessor line

Summary:
This (invalid) fragment is crashing clang-format:
```
#if 1
int x;
#elif
int y;
#endif
```

The reason being that the parser expects a token after `#elif`, and the
subsequent parsing of the next line does not check if `CurrentToken` is null.

Reviewers: gribozavr

Reviewed By: gribozavr

Subscribers: cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368280 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp