[all-commits] [llvm/llvm-project] 7cd441: [clang][NFC] Wrap TYPE_SWITCH in "do while (0)" in...

Owen via All-commits all-commits at lists.llvm.org
Mon Jan 24 09:05:48 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7cd441ff537e00c743236658bfbcfc16c30ce031
      https://github.com/llvm/llvm-project/commit/7cd441ff537e00c743236658bfbcfc16c30ce031
  Author: Owen Pan <owenpiano at gmail.com>
  Date:   2022-01-24 (Mon, 24 Jan 2022)

  Changed paths:
    M clang/lib/AST/Interp/PrimType.h

  Log Message:
  -----------
  [clang][NFC] Wrap TYPE_SWITCH in "do while (0)" in the interpreter

Wraps the expansions of TYPE_SWITCH and COMPOSITE_TYPE_SWITCH in
the constexpr interpreter with "do { ... } while (0)" so that these
macros can be used like this:

if (llvm::Optional<PrimType> T = Ctx.classify(FieldTy))
  TYPE_SWITCH(*T, Ok &= ReturnValue<T>(FP.deref<T>(), Value));
else
  Ok &= Composite(FieldTy, FP, Value);

This bug was found while testing D116316. See also review comment:
https://reviews.llvm.org/D64146?id=208520#inline-584131

Also cleaned up the macro definitions by removing the superfluous
do-while statements and removed the unused INT_TPYE_SWITCH macro.

Differential Revision: https://reviews.llvm.org/D117301




More information about the All-commits mailing list