<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: crash in NamespaceEndCommentsFixer"
href="https://bugs.llvm.org/show_bug.cgi?id=32438">32438</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang-format: crash in NamespaceEndCommentsFixer
</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>m.gehre@gmx.de
</td>
</tr>
<tr>
<th>CC</th>
<td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=18179" name="attach_18179" title="Reproducer">attachment 18179</a> <a href="attachment.cgi?id=18179&action=edit" title="Reproducer">[details]</a></span>
Reproducer
I get a SIGSEGV when running
clang-format a.cpp
on the following creduced a.cpp (attached)
template <int> struct a {};
struct a<bool{}> b() {
}
#define c inline
void d() {
}
The backtrace is as follows:
Program received signal SIGSEGV, Segmentation fault.
(anonymous namespace)::Token::is (this=0x0,
K=(anonymous namespace)::(anonymous namespace)::TokenKind::kw_namespace)
at ../tools/clang/include/clang/Lex/Token.h:94
94 bool is(tok::TokenKind K) const { return Kind == K; }
(gdb) bt
#0 (anonymous namespace)::Token::is (this=0x0,
K=(anonymous namespace)::(anonymous namespace)::TokenKind::kw_namespace)
at ../tools/clang/include/clang/Lex/Token.h:94
#1 0x000000000032be20 in (anonymous namespace)::(anonymous
namespace)::FormatToken::is (this=0x0,
Kind=(anonymous namespace)::(anonymous namespace)::TokenKind::kw_namespace)
at ../tools/clang/lib/Format/FormatToken.h:292
#2 0x000000000032c850 in (anonymous namespace)::(anonymous
namespace)::FormatToken::isNot<clang::tok::TokenKind> (this=0x0,
Kind=(anonymous namespace)::(anonymous namespace)::TokenKind::kw_namespace)
at ../tools/clang/lib/Format/FormatToken.h:308
#3 0x000000000036808a in (anonymous namespace)::(anonymous
namespace)::NamespaceEndCommentsFixer::analyze (this=0x7fffffffc0e0,
Annotator=..., AnnotatedLines=..., Tokens=...)
at ../tools/clang/lib/Format/NamespaceEndCommentsFixer.cpp:136
#4 0x00000000003744e5 in (anonymous namespace)::(anonymous
namespace)::TokenAnalyzer::process (
this=0x7fffffffc0e0) at ../tools/clang/lib/Format/TokenAnalyzer.cpp:110
#5 0x000000000031ab5f in operator() (this=0x7fffffffc838, Fixer=...)
at ../tools/clang/lib/Format/Format.cpp:1842
#6 0x000000000031a9e0 in (anonymous namespace)::(anonymous
namespace)::reformat (Style=..., Code=...,
Ranges=..., FileName=..., IncompleteFormat=0x7fffffffca9f)
at ../tools/clang/lib/Format/Format.cpp:1860
#7 0x00000000002c8159 in (anonymous namespace)::(anonymous namespace)::format
(FileName=...)
at ../tools/clang/tools/clang-format/ClangFormat.cpp:280
#8 0x00000000002c75dc in main (argc=2, argv=0x7fffffffddc8)
at ../tools/clang/tools/clang-format/ClangFormat.cpp:367
In tools/clang/lib/Format/NamespaceEndCommentsFixer.cpp:136,
NamespaceTok is null. I guess that would be the place to check for it.
I built from SVN, currently at 298877.</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>