[PATCH] D25266: Add a static_assert to enforce that parameters to llvm::format() are not totally unsafe

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 5 09:04:35 PDT 2016


mehdi_amini added a comment.

This is also catching existing latent bugs in the codebase:

  In file included from /llvm-project/llvm/lib/Target/PowerPC/PPCVSXSwapRemoval.cpp:55:
  /llvm-project/llvm/include/llvm/Support/Format.h:82:3: error: static_assert failed "format can't be used with non fundamental / non pointer type"
    static_assert(std::is_scalar<Arg>::value,
    ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~
  /llvm-project/llvm/include/llvm/Support/Format.h:105:5: note: in instantiation of template class 'llvm::validate_format_parameters<llvm::StringRef>' requested here
      validate_format_parameters<Ts...>();
      ^
  /llvm-project/llvm/include/llvm/Support/Format.h:124:10: note: in instantiation of member function 'llvm::format_object<llvm::StringRef>::format_object' requested here
    return format_object<Ts...>(Fmt, Vals...);
           ^
  /llvm-project/llvm/lib/Target/PowerPC/PPCVSXSwapRemoval.cpp:965:21: note: in instantiation of function template specialization 'llvm::format<llvm::StringRef>' requested here
      DEBUG(dbgs() << format("  %14s  ", TII->getName(MI->getOpcode())));


https://reviews.llvm.org/D25266





More information about the llvm-commits mailing list