HazardyKnusperkeks created this revision. HazardyKnusperkeks added reviewers: owenpan, curdeius, MyDeveloperDay. HazardyKnusperkeks added a project: clang-format. HazardyKnusperkeks requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Obviously not implemented yet. For https://github.com/llvm/llvm-project/issues/53864 I need to get the end of the requires clause at the end of the nested template. But `parseBracedList()` just ends on the first `>` it finds. Simply extending it the be recursive on `<` wouldn't work, since we have to determine if `<` is a `less` or a template opener. Analogous for `>`. Currently we have `TokenAnnotator::parseAngle` to deal with this stuff. Including `// FIXME: This is getting out of hand, write a decent parser.` So my proposal is to add this parsing in `UnwrappedLineParser` and set `TT_TemplateOpener` and `TT_TempalteCloser` already there. This is going to be a huge change, so I ask for your opinion before I put a lot of effort into that. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D120034 Files: clang/lib/Format/UnwrappedLineParser.cpp clang/lib/Format/UnwrappedLineParser.h Index: clang/lib/Format/UnwrappedLineParser.h =================================================================== --- clang/lib/Format/UnwrappedLineParser.h +++ clang/lib/Format/UnwrappedLineParser.h @@ -118,6 +118,7 @@ tok::TokenKind ClosingBraceKind = tok::r_brace); void parseParens(TokenType AmpAmpTokenType = TT_Unknown); void parseSquare(bool LambdaIntroducer = false); + void parseTemplateArguments(); void keepAncestorBraces(); FormatToken *parseIfThenElse(IfStmtKind *IfKind, bool KeepBraces = false); void parseTryCatch(); Index: clang/lib/Format/UnwrappedLineParser.cpp =================================================================== --- clang/lib/Format/UnwrappedLineParser.cpp +++ clang/lib/Format/UnwrappedLineParser.cpp @@ -2289,6 +2289,21 @@ } while (!eof()); } +/// \brief Parses a template arguments, that is from the opening < to the +/// closing >. Returns when it succesfully read the template arguments or +/// detected that it's not a template argument list. +void clang::format::UnwrappedLineParser::parseTemplateArguments() { + assert(FormatTok->is(tok::less) && "'<' expected."); + assert(FormatTok->is(TT_Unknown) && "Type already set on '<'"); + auto OpeningAngle = FormatTok; + nextToken(); + + + do { + //Do stuff + } while (!eof()); +} + void UnwrappedLineParser::keepAncestorBraces() { if (!Style.RemoveBracesLLVM) return;
Index: clang/lib/Format/UnwrappedLineParser.h =================================================================== --- clang/lib/Format/UnwrappedLineParser.h +++ clang/lib/Format/UnwrappedLineParser.h @@ -118,6 +118,7 @@ tok::TokenKind ClosingBraceKind = tok::r_brace); void parseParens(TokenType AmpAmpTokenType = TT_Unknown); void parseSquare(bool LambdaIntroducer = false); + void parseTemplateArguments(); void keepAncestorBraces(); FormatToken *parseIfThenElse(IfStmtKind *IfKind, bool KeepBraces = false); void parseTryCatch(); Index: clang/lib/Format/UnwrappedLineParser.cpp =================================================================== --- clang/lib/Format/UnwrappedLineParser.cpp +++ clang/lib/Format/UnwrappedLineParser.cpp @@ -2289,6 +2289,21 @@ } while (!eof()); } +/// \brief Parses a template arguments, that is from the opening < to the +/// closing >. Returns when it succesfully read the template arguments or +/// detected that it's not a template argument list. +void clang::format::UnwrappedLineParser::parseTemplateArguments() { + assert(FormatTok->is(tok::less) && "'<' expected."); + assert(FormatTok->is(TT_Unknown) && "Type already set on '<'"); + auto OpeningAngle = FormatTok; + nextToken(); + + + do { + //Do stuff + } while (!eof()); +} + void UnwrappedLineParser::keepAncestorBraces() { if (!Style.RemoveBracesLLVM) return;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits