diff options
author | Paul Hoad <mydeveloperday@gmail.com> | 2019-10-10 17:54:47 +0000 |
---|---|---|
committer | Paul Hoad <mydeveloperday@gmail.com> | 2019-10-10 17:54:47 +0000 |
commit | 3b4c8f6807123c5e4d5a84f560599c9585ccb471 (patch) | |
tree | 48a2790cc93f63e86db6e2e231a9f26ed2b7e8fe | |
parent | 4c145df6a7fbf643dc9483c2945aae44e58f5920 (diff) | |
download | bcm5719-llvm-3b4c8f6807123c5e4d5a84f560599c9585ccb471.tar.gz bcm5719-llvm-3b4c8f6807123c5e4d5a84f560599c9585ccb471.zip |
[clang-format] throws an incorrect assertion in consumeToken() formatting the MSVC stl
Summary:
An incorrect assertion is thrown when clang-formatting MSVC's STL library
```
Assertion failed: !Line.startsWith(tok::hash), file C:/llvm/llvm-project/clang/lib/Format/TokenAnnotator.cpp, line 847
Stack dump:
0. Program arguments: C:\llvm\build\bin\clang-format.exe -i -n ./stl/inc/xkeycheck.h
```
```
Enable warning C4005 to find the forbidden define.
```
Reviewers: mitchell-stellar, STL_MSFT, klimek, krasimir
Reviewed By: mitchell-stellar
Subscribers: cfe-commits
Tags: #clang-format, #clang-tools-extra, #clang
Differential Revision: https://reviews.llvm.org/D68707
llvm-svn: 374399
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 1 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 12 |
2 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 88f74681229..9823a5af9c1 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -845,7 +845,6 @@ private: break; case tok::kw_if: case tok::kw_while: - assert(!Line.startsWith(tok::hash)); if (Tok->is(tok::kw_if) && CurrentToken && CurrentToken->isOneOf(tok::kw_constexpr, tok::identifier)) next(); diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index dde065ad818..b0d7f08892e 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -14723,6 +14723,12 @@ TEST_F(FormatTest, NotCastRPaen) { verifyFormat("auto operator delete(int &) final"); } -} // end namespace -} // end namespace format -} // end namespace clang +TEST_F(FormatTest, STLWhileNotDefineChed) { + verifyFormat("#if defined(while)\n" + "#define while EMIT WARNING C4005\n" + "#endif // while"); +} + +} // namespace +} // namespace format +} // namespace clang |