[clang-format] Assertion failure on `(A*B*)`
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Assertion failure when trying to format the following code:
bug.h:
```cpp
(A*B*)
```
```console
$ clang-format -style=LLVM bug.h
Assertion failed: ((!TypeIsFinalized || T == Type) && "Please use overwriteFixedType to change a fixed type."), function setType, file FormatToken.h, line 469.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: clang-format -style=LLVM bug.h
...
#7 clang::format::FormatTokenLexer::getNextToken() (.cold.10)
#8 clang::format::(anonymous namespace)::AnnotatingParser::next()
#9 clang::format::(anonymous namespace)::AnnotatingParser::parseParens(bool)
#10 clang::format::(anonymous namespace)::AnnotatingParser::consumeToken()
#11 clang::format::(anonymous namespace)::AnnotatingParser::parseLine()
#12 clang::format::TokenAnnotator::annotate(clang::format::AnnotatedLine&)
#13 clang::format::TokenAnalyzer::process(bool)
#14 clang::format::guessLanguage(llvm::StringRef, llvm::StringRef)
#15 clang::format::getStyle(llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::vfs::FileSystem*, bool, void (*)(llvm::SMDiagnostic const&, void*))
#16 clang::format::format(llvm::StringRef, bool)
#17 main
```
Contributor guide
Research direction
Start by reproducing the crash with `clang-format -style=LLVM bug.h` using `(A*B*)`, then inspect the assertion in FormatToken.h at line 469 and the listed clang::format parser stack entries. Done means clang-format no longer asserts on this input and produces formatted output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100