This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG20a3fb9740dd: [Clang] Fix how ReadMacroParameterList handles comments in macro parameter-list… (authored by shafik). Herald added a project: clang. Herald added a subscriber: cfe-commits.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144511/new/ https://reviews.llvm.org/D144511 Files: clang/docs/ReleaseNotes.rst clang/lib/Lex/PPDirectives.cpp clang/test/Preprocessor/comment_save_macro.c Index: clang/test/Preprocessor/comment_save_macro.c =================================================================== --- clang/test/Preprocessor/comment_save_macro.c +++ clang/test/Preprocessor/comment_save_macro.c @@ -1,13 +1,28 @@ // RUN: %clang_cc1 -E -C %s | FileCheck -check-prefix=CHECK-C -strict-whitespace %s // CHECK-C: boo bork bar // zot +// CHECK-C: ( 0 ); +// CHECK-C: ( 0,1,2 ); +// CHECK-C: ( 0,1,2 ); // RUN: %clang_cc1 -E -CC %s | FileCheck -check-prefix=CHECK-CC -strict-whitespace %s // CHECK-CC: boo bork /* blah*/ bar // zot +// CHECK-CC: (/**/0/**/); +// CHECK-CC: (/**/0,1,2/**/); +// CHECK-CC: (/**/0,1,2/**/); // RUN: %clang_cc1 -E %s | FileCheck -strict-whitespace %s // CHECK: boo bork bar +// CHECK: ( 0 ); +// CHECK: ( 0,1,2 ); +// CHECK: ( 0,1,2 ); #define FOO bork // blah boo FOO bar // zot +#define M(/**/x/**/) (/**/x/**/) +M(0); +#define M2(/**/.../**/) (/**/__VA_ARGS__/**/) +M2(0,1,2); +#define M3(/**/x.../**/) (/**/x/**/) +M3(0,1,2); Index: clang/lib/Lex/PPDirectives.cpp =================================================================== --- clang/lib/Lex/PPDirectives.cpp +++ clang/lib/Lex/PPDirectives.cpp @@ -2643,7 +2643,7 @@ SmallVector<IdentifierInfo*, 32> Parameters; while (true) { - LexUnexpandedToken(Tok); + LexUnexpandedNonComment(Tok); switch (Tok.getKind()) { case tok::r_paren: // Found the end of the parameter list. @@ -2664,7 +2664,7 @@ } // Lex the token after the identifier. - LexUnexpandedToken(Tok); + LexUnexpandedNonComment(Tok); if (Tok.isNot(tok::r_paren)) { Diag(Tok, diag::err_pp_missing_rparen_in_macro_def); return true; @@ -2698,7 +2698,7 @@ Parameters.push_back(II); // Lex the token after the identifier. - LexUnexpandedToken(Tok); + LexUnexpandedNonComment(Tok); switch (Tok.getKind()) { default: // #define X(A B @@ -2714,7 +2714,7 @@ Diag(Tok, diag::ext_named_variadic_macro); // Lex the token after the identifier. - LexUnexpandedToken(Tok); + LexUnexpandedNonComment(Tok); if (Tok.isNot(tok::r_paren)) { Diag(Tok, diag::err_pp_missing_rparen_in_macro_def); return true; Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -254,6 +254,9 @@ requires on lambdas when not allowed, which we previously missed. (`#61748 <https://github.com/llvm/llvm-project/issues/61748>`_) - Fix confusing diagnostic for incorrect use of qualified concepts names. +- Fix handling of comments in function like macros so they are ignored in -CC + mode. + (`#60887 <https://github.com/llvm/llvm-project/issues/60887>`_) Bug Fixes to Compiler Builtins
Index: clang/test/Preprocessor/comment_save_macro.c =================================================================== --- clang/test/Preprocessor/comment_save_macro.c +++ clang/test/Preprocessor/comment_save_macro.c @@ -1,13 +1,28 @@ // RUN: %clang_cc1 -E -C %s | FileCheck -check-prefix=CHECK-C -strict-whitespace %s // CHECK-C: boo bork bar // zot +// CHECK-C: ( 0 ); +// CHECK-C: ( 0,1,2 ); +// CHECK-C: ( 0,1,2 ); // RUN: %clang_cc1 -E -CC %s | FileCheck -check-prefix=CHECK-CC -strict-whitespace %s // CHECK-CC: boo bork /* blah*/ bar // zot +// CHECK-CC: (/**/0/**/); +// CHECK-CC: (/**/0,1,2/**/); +// CHECK-CC: (/**/0,1,2/**/); // RUN: %clang_cc1 -E %s | FileCheck -strict-whitespace %s // CHECK: boo bork bar +// CHECK: ( 0 ); +// CHECK: ( 0,1,2 ); +// CHECK: ( 0,1,2 ); #define FOO bork // blah boo FOO bar // zot +#define M(/**/x/**/) (/**/x/**/) +M(0); +#define M2(/**/.../**/) (/**/__VA_ARGS__/**/) +M2(0,1,2); +#define M3(/**/x.../**/) (/**/x/**/) +M3(0,1,2); Index: clang/lib/Lex/PPDirectives.cpp =================================================================== --- clang/lib/Lex/PPDirectives.cpp +++ clang/lib/Lex/PPDirectives.cpp @@ -2643,7 +2643,7 @@ SmallVector<IdentifierInfo*, 32> Parameters; while (true) { - LexUnexpandedToken(Tok); + LexUnexpandedNonComment(Tok); switch (Tok.getKind()) { case tok::r_paren: // Found the end of the parameter list. @@ -2664,7 +2664,7 @@ } // Lex the token after the identifier. - LexUnexpandedToken(Tok); + LexUnexpandedNonComment(Tok); if (Tok.isNot(tok::r_paren)) { Diag(Tok, diag::err_pp_missing_rparen_in_macro_def); return true; @@ -2698,7 +2698,7 @@ Parameters.push_back(II); // Lex the token after the identifier. - LexUnexpandedToken(Tok); + LexUnexpandedNonComment(Tok); switch (Tok.getKind()) { default: // #define X(A B @@ -2714,7 +2714,7 @@ Diag(Tok, diag::ext_named_variadic_macro); // Lex the token after the identifier. - LexUnexpandedToken(Tok); + LexUnexpandedNonComment(Tok); if (Tok.isNot(tok::r_paren)) { Diag(Tok, diag::err_pp_missing_rparen_in_macro_def); return true; Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -254,6 +254,9 @@ requires on lambdas when not allowed, which we previously missed. (`#61748 <https://github.com/llvm/llvm-project/issues/61748>`_) - Fix confusing diagnostic for incorrect use of qualified concepts names. +- Fix handling of comments in function like macros so they are ignored in -CC + mode. + (`#60887 <https://github.com/llvm/llvm-project/issues/60887>`_) Bug Fixes to Compiler Builtins
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits