[llvm] r283510 - Revert "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
Thu Oct 6 16:41:49 PDT 2016


Author: mehdi_amini
Date: Thu Oct  6 18:41:49 2016
New Revision: 283510

URL: http://llvm.org/viewvc/llvm-project?rev=283510&view=rev
Log:
Revert "Add a static_assert to enforce that parameters to llvm::format() are not totally unsafe"

This reverts commit r283509, clang is hitting the assert.

Modified:
    llvm/trunk/include/llvm/Support/Format.h
    llvm/trunk/lib/Target/PowerPC/PPCVSXSwapRemoval.cpp

Modified: llvm/trunk/include/llvm/Support/Format.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Format.h?rev=283510&r1=283509&r2=283510&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Format.h (original)
+++ llvm/trunk/include/llvm/Support/Format.h Thu Oct  6 18:41:49 2016
@@ -75,16 +75,6 @@ public:
 /// printed, this synthesizes the string into a temporary buffer provided and
 /// returns whether or not it is big enough.
 
-// Helper to validate that format() parameters are scalars or pointers.
-template <typename... Args> struct validate_format_parameters;
-template <typename Arg, typename... Args>
-struct validate_format_parameters<Arg, Args...> {
-  static_assert(std::is_scalar<Arg>::value,
-                "format can't be used with non fundamental / non pointer type");
-  validate_format_parameters() { validate_format_parameters<Args...>(); }
-};
-template <> struct validate_format_parameters<> {};
-
 template <typename... Ts>
 class format_object final : public format_object_base {
   std::tuple<Ts...> Vals;
@@ -101,9 +91,7 @@ class format_object final : public forma
 
 public:
   format_object(const char *fmt, const Ts &... vals)
-      : format_object_base(fmt), Vals(vals...) {
-    validate_format_parameters<Ts...>();
-  }
+      : format_object_base(fmt), Vals(vals...) {}
 
   int snprint(char *Buffer, unsigned BufferSize) const override {
     return snprint_tuple(Buffer, BufferSize, index_sequence_for<Ts...>());

Modified: llvm/trunk/lib/Target/PowerPC/PPCVSXSwapRemoval.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCVSXSwapRemoval.cpp?rev=283510&r1=283509&r2=283510&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCVSXSwapRemoval.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCVSXSwapRemoval.cpp Thu Oct  6 18:41:49 2016
@@ -962,8 +962,7 @@ void PPCVSXSwapRemoval::dumpSwapVector()
     DEBUG(dbgs() << format("%6d", ID));
     DEBUG(dbgs() << format("%6d", EC->getLeaderValue(ID)));
     DEBUG(dbgs() << format(" BB#%3d", MI->getParent()->getNumber()));
-    DEBUG(dbgs() << format("  %14s  ",
-                           TII->getName(MI->getOpcode()).str().c_str()));
+    DEBUG(dbgs() << format("  %14s  ", TII->getName(MI->getOpcode())));
 
     if (SwapVector[EntryIdx].IsLoad)
       DEBUG(dbgs() << "load ");




More information about the llvm-commits mailing list