[all-commits] [llvm/llvm-project] 5dfa37: Don't allow __VA_OPT__ to be detected by #ifdef.

Richard Smith via All-commits all-commits at lists.llvm.org
Wed Jan 27 13:34:45 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5dfa37a76153f2a18ac7fe30721cc1332b672ea2
      https://github.com/llvm/llvm-project/commit/5dfa37a76153f2a18ac7fe30721cc1332b672ea2
  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.




More information about the All-commits mailing list