[llvm-bugs] [Bug 32438] New: clang-format: crash in NamespaceEndCommentsFixer

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Mar 27 13:43:00 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=32438

            Bug ID: 32438
           Summary: clang-format: crash in NamespaceEndCommentsFixer
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: m.gehre at gmx.de
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Created attachment 18179
  --> https://bugs.llvm.org/attachment.cgi?id=18179&action=edit
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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170327/2ed7ea31/attachment.html>


More information about the llvm-bugs mailing list