diff options
author | Emilia Kond <emilia@rymiel.space> | 2024-10-22 13:36:28 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-22 13:36:28 +0300 |
commit | aea60ab94db4729bad17daa86ccfc411d48a1699 (patch) | |
tree | 542aab40df6669fb8b38129b30f6d173024dd52a /clang/lib/Format/UnwrappedLineParser.cpp | |
parent | 11c818816d0558408eb966238bd9df5f54ac5fd0 (diff) | |
download | llvm-aea60ab94db4729bad17daa86ccfc411d48a1699.zip llvm-aea60ab94db4729bad17daa86ccfc411d48a1699.tar.gz llvm-aea60ab94db4729bad17daa86ccfc411d48a1699.tar.bz2 |
[clang-format] Make bitwise and imply requires clause (#110942)
This patch adjusts the requires clause/expression parser to imply a
requires clause if it is preceded by a bitwise and operator `&`, and
assume it is a reference qualifier. The justification is that bitwise
operations should not be used for requires expressions.
This is a band-aid fix. The real problems lie in the lookahead heuristic
in the same method. It may be worth it to rewrite that whole heuristic
to track more state in the future, instead of just blindly marching
forward across multiple unrelated definitions, since right now, the
definition following the one with the requires clause can influence
whether the heuristic chooses clause or expression.
Fixes https://github.com/llvm/llvm-project/issues/110485
Diffstat (limited to 'clang/lib/Format/UnwrappedLineParser.cpp')
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 4a51099..0b74889 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -3484,10 +3484,10 @@ bool UnwrappedLineParser::parseRequires() { case tok::r_paren: case tok::kw_noexcept: case tok::kw_const: + case tok::amp: // This is a requires clause. parseRequiresClause(RequiresToken); return true; - case tok::amp: case tok::ampamp: { // This can be either: // if (... && requires (T t) ...) |