Skip to content

clang-format crashes when formatting "requires" argument after #if-#else #54019

@owenca

Description

@owenca

@HazardyKnusperkeks, I got some requires-related crashes when formatting .cpp files under clang/test/. Below is one (which I reduced to the bare minimum) of them:

$ cat .clang-format
BasedOnStyle: LLVM
$ clang-format --version
clang-format version 15.0.0 (https://github.com/llvm/llvm-project 77e60bc42c48e16d646488d43210b1630cd4db49)
$ clang-format
#if 0
#else
foo();
#endif
bar(requires);
Assertion failed: (RequiresToken->getType() == TT_Unknown), function parseRequiresExpression, file UnwrappedLineParser.cpp, line 3022.
...

Metadata

Metadata

Labels

bugIndicates an unexpected problem or unintended behaviorclang-formatconfirmedVerified by a second partycrashPrefer [crash-on-valid] or [crash-on-invalid]

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions