This revision was automatically updated to reflect the committed changes. Closed by commit rG8dab45274000: [clang-format] Disallow requires clauses to become function declarations (authored by rymiel).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D134052/new/ https://reviews.llvm.org/D134052 Files: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/TokenAnnotatorTest.cpp Index: clang/unittests/Format/TokenAnnotatorTest.cpp =================================================================== --- clang/unittests/Format/TokenAnnotatorTest.cpp +++ clang/unittests/Format/TokenAnnotatorTest.cpp @@ -737,6 +737,16 @@ BaseTokenCount = 26; TestRequires(__LINE__); + BaseCode = "template<typename T>\n" + "T foo();"; + ConstrainedCode = "template<typename T>\n" + " requires(Foo<T>)\n" + "T foo();"; + BaseTokenCount = 11; + RequiresTokenCount = 7; + PrefixTokenCount = 5; + TestRequires(__LINE__); + BaseCode = "template<typename T>\n" "Bar(T) -> Bar<typename T::I>;"; ConstrainedCode = "template<typename T>\n" Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -1110,7 +1110,7 @@ !Contexts.back().IsExpression && !Line.startsWith(TT_ObjCProperty) && !Tok->isOneOf(TT_TypeDeclarationParen, TT_RequiresExpressionLParen) && (!Tok->Previous || - !Tok->Previous->isOneOf(tok::kw___attribute, + !Tok->Previous->isOneOf(tok::kw___attribute, TT_RequiresClause, TT_LeadingJavaAnnotation))) { Line.MightBeFunctionDecl = true; }
Index: clang/unittests/Format/TokenAnnotatorTest.cpp =================================================================== --- clang/unittests/Format/TokenAnnotatorTest.cpp +++ clang/unittests/Format/TokenAnnotatorTest.cpp @@ -737,6 +737,16 @@ BaseTokenCount = 26; TestRequires(__LINE__); + BaseCode = "template<typename T>\n" + "T foo();"; + ConstrainedCode = "template<typename T>\n" + " requires(Foo<T>)\n" + "T foo();"; + BaseTokenCount = 11; + RequiresTokenCount = 7; + PrefixTokenCount = 5; + TestRequires(__LINE__); + BaseCode = "template<typename T>\n" "Bar(T) -> Bar<typename T::I>;"; ConstrainedCode = "template<typename T>\n" Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -1110,7 +1110,7 @@ !Contexts.back().IsExpression && !Line.startsWith(TT_ObjCProperty) && !Tok->isOneOf(TT_TypeDeclarationParen, TT_RequiresExpressionLParen) && (!Tok->Previous || - !Tok->Previous->isOneOf(tok::kw___attribute, + !Tok->Previous->isOneOf(tok::kw___attribute, TT_RequiresClause, TT_LeadingJavaAnnotation))) { Line.MightBeFunctionDecl = true; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits