Index: clang/lib/Format/DefinitionBlockSeparator.cpp =================================================================== --- clang/lib/Format/DefinitionBlockSeparator.cpp +++ clang/lib/Format/DefinitionBlockSeparator.cpp @@ -143,8 +143,10 @@ if (LikelyDefinition(OperateLine)) return false; - if (OperateLine->First->is(tok::comment)) + if (const auto *Tok = OperateLine->First; + Tok->is(tok::comment) && !isClangFormatOn(Tok->TokenText)) { return true; + } // A single line identifier that is not in the last line. if (OperateLine->First->is(tok::identifier) && Index: clang/unittests/Format/DefinitionBlockSeparatorTest.cpp =================================================================== --- clang/unittests/Format/DefinitionBlockSeparatorTest.cpp +++ clang/unittests/Format/DefinitionBlockSeparatorTest.cpp @@ -283,6 +283,15 @@ TEST_F(DefinitionBlockSeparatorTest, Always) { FormatStyle Style = getLLVMStyle(); Style.SeparateDefinitionBlocks = FormatStyle::SDS_Always; + + verifyFormat("// clang-format off\n" + "template\n" + "concept C = not A>;\n" + "// clang-format on\n" + "\n" + "struct E {};", + Style); + std::string Prefix = "namespace {\n"; std::string Infix = "\n" "// Enum test1\n"