This revision was automatically updated to reflect the committed changes. Closed by commit rG50999e82e884: [clang-format] Space between attribute closing parenthesis and qualified type… (authored by curdeius).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D117894/new/ https://reviews.llvm.org/D117894 Files: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -10028,6 +10028,7 @@ verifyFormat("SomeType s __attribute__((unused)) (InitValue);"); verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa __attribute__((unused))\n" "aaaaaaaaaaaaaaaaaaaaaaa(int i);"); + verifyFormat("__attribute__((nodebug)) ::qualified_type f();"); FormatStyle AfterType = getLLVMStyle(); AfterType.AlwaysBreakAfterReturnType = FormatStyle::RTBS_All; verifyFormat("__attribute__((nodebug)) void\n" @@ -10131,6 +10132,7 @@ verifyFormat("class [[nodiscard]] f {\npublic:\n f() {}\n}"); verifyFormat("class [[deprecated(\"so sorry\")]] f {\npublic:\n f() {}\n}"); verifyFormat("class [[gnu::unused]] f {\npublic:\n f() {}\n}"); + verifyFormat("[[nodiscard]] ::qualified_type f();"); // Make sure we do not mistake attributes for array subscripts. verifyFormat("int a() {}\n" Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -3339,6 +3339,9 @@ if (Left.is(tok::ellipsis) && Right.is(tok::identifier) && Line.First->is(Keywords.kw_import)) return false; + // Space in __attribute__((attr)) ::type. + if (Left.is(TT_AttributeParen) && Right.is(tok::coloncolon)) + return true; if (Left.is(tok::kw_operator)) return Right.is(tok::coloncolon);
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -10028,6 +10028,7 @@ verifyFormat("SomeType s __attribute__((unused)) (InitValue);"); verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa __attribute__((unused))\n" "aaaaaaaaaaaaaaaaaaaaaaa(int i);"); + verifyFormat("__attribute__((nodebug)) ::qualified_type f();"); FormatStyle AfterType = getLLVMStyle(); AfterType.AlwaysBreakAfterReturnType = FormatStyle::RTBS_All; verifyFormat("__attribute__((nodebug)) void\n" @@ -10131,6 +10132,7 @@ verifyFormat("class [[nodiscard]] f {\npublic:\n f() {}\n}"); verifyFormat("class [[deprecated(\"so sorry\")]] f {\npublic:\n f() {}\n}"); verifyFormat("class [[gnu::unused]] f {\npublic:\n f() {}\n}"); + verifyFormat("[[nodiscard]] ::qualified_type f();"); // Make sure we do not mistake attributes for array subscripts. verifyFormat("int a() {}\n" Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -3339,6 +3339,9 @@ if (Left.is(tok::ellipsis) && Right.is(tok::identifier) && Line.First->is(Keywords.kw_import)) return false; + // Space in __attribute__((attr)) ::type. + if (Left.is(TT_AttributeParen) && Right.is(tok::coloncolon)) + return true; if (Left.is(tok::kw_operator)) return Right.is(tok::coloncolon);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits