[PATCH] D68481: [clang-format] [PR27004] omits leading space for noexcept when formatting operator delete()
MyDeveloperDay via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 5 03:05:30 PDT 2019
MyDeveloperDay updated this revision to Diff 223369.
MyDeveloperDay marked 2 inline comments as done.
MyDeveloperDay added a comment.
Add additional override and final keywords
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68481/new/
https://reviews.llvm.org/D68481
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
@@ -14678,6 +14678,33 @@
*/
}
+TEST_F(FormatTest, NotCastRPaen) {
+
+ verifyFormat("void operator++(int) noexcept;");
+ verifyFormat("void operator++(int &) noexcept;");
+ verifyFormat("void operator delete(void *, std::size_t, const std::nothrow_t "
+ "&) noexcept;");
+ verifyFormat(
+ "void operator delete(std::size_t, const std::nothrow_t &) noexcept;");
+ verifyFormat("void operator delete(const std::nothrow_t &) noexcept;");
+ verifyFormat("void operator delete(std::nothrow_t &) noexcept;");
+ verifyFormat("void operator delete(nothrow_t &) noexcept;");
+ verifyFormat("void operator delete(foo &) noexcept;");
+ verifyFormat("void operator delete(foo) noexcept;");
+ verifyFormat("void operator delete(int) noexcept;");
+ verifyFormat("void operator delete(int &) noexcept;");
+ verifyFormat("void operator delete(int &) volatile noexcept;");
+ verifyFormat("void operator delete(int &) const");
+ verifyFormat("void operator delete(int &) = default");
+ verifyFormat("void operator delete(int &) = delete");
+ verifyFormat("void operator delete(int &) [[noreturn]]");
+ verifyFormat("void operator delete(int &) throw();");
+ verifyFormat("void operator delete(int &) throw(int);");
+ verifyFormat("auto operator delete(int &) -> int;");
+ verifyFormat("auto operator delete(int &) override");
+ verifyFormat("auto operator delete(int &) final");
+}
+
} // end namespace
} // end namespace format
} // end namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1611,6 +1611,13 @@
if (Tok.Next->is(tok::question))
return false;
+ // Functions which end with decorations like volatile, noexcept are unlikely
+ // to be casts.
+ if (Tok.Next->isOneOf(tok::kw_noexcept, tok::kw_volatile, tok::kw_const,
+ tok::kw_throw, tok::l_square, tok::arrow,
+ Keywords.kw_override, Keywords.kw_final))
+ return false;
+
// As Java has no function types, a "(" after the ")" likely means that this
// is a cast.
if (Style.Language == FormatStyle::LK_Java && Tok.Next->is(tok::l_paren))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68481.223369.patch
Type: text/x-patch
Size: 2478 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191005/b9ad3bfd/attachment.bin>
More information about the cfe-commits
mailing list