[all-commits] [llvm/llvm-project] ea99c8: Permit __VA_OPT__ in all language modes and allow ...

Richard Smith via All-commits all-commits at lists.llvm.org
Wed Jan 27 15:52:59 PST 2021


  Branch: refs/heads/release/12.x
  Home:   https://github.com/llvm/llvm-project
  Commit: ea99c885a63de9af673a5e5cd51f44fb70c83c1b
      https://github.com/llvm/llvm-project/commit/ea99c885a63de9af673a5e5cd51f44fb70c83c1b
  Author: Richard Smith <richard at metafoo.co.uk>
  Date:   2021-01-27 (Wed, 27 Jan 2021)

  Changed paths:
    M clang/include/clang/Lex/Preprocessor.h
    M clang/include/clang/Lex/VariadicMacroSupport.h
    M clang/lib/Lex/PPDirectives.cpp
    M clang/lib/Lex/PPExpressions.cpp
    M clang/lib/Lex/PPMacroExpansion.cpp
    M clang/lib/Lex/Preprocessor.cpp
    M clang/test/Preprocessor/macro_vaopt_check.cpp
    M clang/test/Preprocessor/macro_vaopt_expand.cpp

  Log Message:
  -----------
  Permit __VA_OPT__ in all language modes and allow it to be detected with #ifdef.

These changes are intended to give code a path to move away from the GNU
,##__VA_ARGS__ extension, which is non-conforming in some situations and
which we'd like to disable in our conforming mode in those cases.

(cherry picked from commit 0436ec2128c9775ba13b0308937238fc79673fdd)


  Commit: 9ea2a107ca4055a3a4960cb6dffb84b7f43bd8ea
      https://github.com/llvm/llvm-project/commit/9ea2a107ca4055a3a4960cb6dffb84b7f43bd8ea
  Author: Richard Smith <richard at metafoo.co.uk>
  Date:   2021-01-27 (Wed, 27 Jan 2021)

  Changed paths:
    M clang/include/clang/Lex/Preprocessor.h
    M clang/lib/Lex/PPDirectives.cpp
    M clang/lib/Lex/PPExpressions.cpp
    M clang/lib/Lex/PPMacroExpansion.cpp
    M clang/lib/Lex/Preprocessor.cpp
    M clang/test/Preprocessor/macro_vaopt_check.cpp

  Log Message:
  -----------
  Don't allow __VA_OPT__ to be detected by #ifdef.

More study has discovered this to not actually be useful: because
current C++20 implementations reject `#ifdef __VA_OPT__`, this can't
really be used as a feature-test mechanism. And it's not too hard to
detect __VA_OPT__ without this, for example:

  #define THIRD_ARG(a, b, c, ...) c
  #define HAS_VA_OPT(...) THIRD_ARG(__VA_OPT__(,), 1, 0, )
  #if HAS_VA_OPT(?)

Partially reverts 0436ec2128c9775ba13b0308937238fc79673fdd.

(cherry picked from commit 5dfa37a76153f2a18ac7fe30721cc1332b672ea2)


Compare: https://github.com/llvm/llvm-project/compare/d64226e8fab8...9ea2a107ca40


More information about the All-commits mailing list