MyDeveloperDay created this revision. MyDeveloperDay added reviewers: HazardyKnusperkeks, curdeius. MyDeveloperDay added projects: clang, clang-format. MyDeveloperDay requested review of this revision.
https://bugs.llvm.org/show_bug.cgi?id=52527 The follow patch ensures there is always a space between * and /* to prevent transforming void foo(* /* comment */)(int bar); info void foo(*/* comment */)(int bar); Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D114142 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 @@ -9439,6 +9439,8 @@ verifyFormat("void f() { &(*I).first; }"); verifyIndependentOfContext("f(b * /* confusing comment */ ++c);"); + verifyFormat("f(* /* confusing comment */ foo);"); + verifyFormat("void (* /*deleter*/)(const Slice &key, void *value)"); verifyFormat( "int *MyValues = {\n" " *A, // Operator detection might be confused by the '{'\n" Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -3213,6 +3213,12 @@ }; if (Right.Tok.getIdentifierInfo() && Left.Tok.getIdentifierInfo()) return true; // Never ever merge two identifiers. + + // Leave a space between * and /* to avoid C4138 `comment end` found outside + // of comment. + if (Left.is(tok::star) && Right.is(TT_BlockComment)) + return true; + if (Style.isCpp()) { 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 @@ -9439,6 +9439,8 @@ verifyFormat("void f() { &(*I).first; }"); verifyIndependentOfContext("f(b * /* confusing comment */ ++c);"); + verifyFormat("f(* /* confusing comment */ foo);"); + verifyFormat("void (* /*deleter*/)(const Slice &key, void *value)"); verifyFormat( "int *MyValues = {\n" " *A, // Operator detection might be confused by the '{'\n" Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -3213,6 +3213,12 @@ }; if (Right.Tok.getIdentifierInfo() && Left.Tok.getIdentifierInfo()) return true; // Never ever merge two identifiers. + + // Leave a space between * and /* to avoid C4138 `comment end` found outside + // of comment. + if (Left.is(tok::star) && Right.is(TT_BlockComment)) + return true; + if (Style.isCpp()) { 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