[llvm-bugs] [Bug 43621] New: [clang-format] throws an incorrect assertion in consumeToken() formatting the MSVC stl

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Oct 9 07:46:37 PDT 2019


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

            Bug ID: 43621
           Summary: [clang-format] throws an incorrect assertion in
                    consumeToken() formatting the MSVC stl
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mydeveloperday at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

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

-- 
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/20191009/1409b249/attachment-0001.html>


More information about the llvm-bugs mailing list