Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -1893,6 +1893,14 @@ LeftOfParens = LeftOfParens->MatchingParen->Previous; } + // The Condition directly below this one will see the operator arguments + // as a (void *foo) cast. + // void operator delete(void *foo) ATTRIB; + if (LeftOfParens->Tok.getIdentifierInfo() && + LeftOfParens->is(tok::kw_delete) && LeftOfParens->Previous && + LeftOfParens->Previous->is(tok::kw_operator)) + return false; + // If there is an identifier (or with a few exceptions a keyword) right // before the parentheses, this is unlikely to be a cast. if (LeftOfParens->Tok.getIdentifierInfo() && Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -9459,6 +9459,9 @@ " new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa))\n" " typename aaaaaaaaaaaaaaaaaaaaaaaa();"); verifyFormat("delete[] h->p;"); + + verifyFormat("void operator delete(void *foo) ATTRIB;"); + verifyFormat("void operator new(void *foo) ATTRIB;"); } TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {