<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - [clang-format] throws an incorrect assertion in consumeToken() formatting the MSVC stl"
href="https://bugs.llvm.org/show_bug.cgi?id=43621">43621</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[clang-format] throws an incorrect assertion in consumeToken() formatting the MSVC stl
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Formatter
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mydeveloperday@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Logging an issue in which causes clang-format to incorrectly throw an assetion
$ find . \( -name '*.cpp' -o -name '*.h' \) -exec clang-format -i -n {} \;
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
#0 0x00007ff7872821a5 (C:\llvm\build\bin\clang-format.exe+0x421a5)
#1 0x00007ff8efdcda2d (C:\WINDOWS\System32\ucrtbase.dll+0x6da2d)
#2 0x00007ff8efdce901 (C:\WINDOWS\System32\ucrtbase.dll+0x6e901)
#3 0x00007ff8efdd0261 (C:\WINDOWS\System32\ucrtbase.dll+0x70261)
#4 0x00007ff8efdd0591 (C:\WINDOWS\System32\ucrtbase.dll+0x70591)
#5 0x00007ff7872d655e (C:\llvm\build\bin\clang-format.exe+0x9655e)
#6 0x00007ff7872db5a3 (C:\llvm\build\bin\clang-format.exe+0x9b5a3)
#7 0x00007ff7872d66a3 (C:\llvm\build\bin\clang-format.exe+0x966a3)
#8 0x00007ff7872dad24 (C:\llvm\build\bin\clang-format.exe+0x9ad24)
#9 0x00007ff7872dbd64 (C:\llvm\build\bin\clang-format.exe+0x9bd64)
#10 0x00007ff7872daaa5 (C:\llvm\build\bin\clang-format.exe+0x9aaa5)
#11 0x00007ff7872d4d2e (C:\llvm\build\bin\clang-format.exe+0x94d2e)
#12 0x00007ff7872e8654 (C:\llvm\build\bin\clang-format.exe+0xa8654)
#13 0x00007ff7872c192b (C:\llvm\build\bin\clang-format.exe+0x8192b)
#14 0x00007ff78724a9c9 (C:\llvm\build\bin\clang-format.exe+0xa9c9)
#15 0x00007ff78724dbe5 (C:\llvm\build\bin\clang-format.exe+0xdbe5)
#16 0x00007ff7873808a0 (C:\llvm\build\bin\clang-format.exe+0x1408a0)
#17 0x00007ff8efe77974 (C:\WINDOWS\System32\KERNEL32.DLL+0x17974)
#18 0x00007ff8f2caa271 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x6a271)
Assertion is throw here
C:/llvm/llvm-project/clang/lib/Format/TokenAnnotator.cpp, line 847
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();
if (CurrentToken && CurrentToken->is(tok::l_paren)) {
next();
if (!parseParens(/*LookForDecls=*/true))
return false;
}
break;
Because of the following code:
#if defined(while)
#define while EMIT WARNING C4005
#error The C++ Standard Library forbids macroizing the keyword "while". \
Enable warning C4005 to find the forbidden define.
#endif // while</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>