[PATCH] D28955: [analyzer] Enable support for symbolic extension/truncation

2017-01-20 Thread Ryan Govostes via Phabricator via cfe-commits
rgov added a comment.

Are all the changes here related to the extension/truncation support, for 
instance the changes to `test/Analysis/malloc.c`? Can you move misc. cleanup 
changes to another review?


https://reviews.llvm.org/D28955



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28952: [analyzer] Add new Z3 constraint manager backend

2017-01-20 Thread Ryan Govostes via Phabricator via cfe-commits
rgov added a comment.

Do you think you could upload the patch omitting all of the test case changes 
for now? Maybe include one as an example but it seems to be just adding 
`%z3_cc1` so we don't need to see all of them right now.

The KLEE project has a useful abstraction layer around multiple bitvector 
solvers (Boolector, CVC4, STP, and Z3). It's also used by Souper, another 
LLVM-based project. I would encourage you to consider using that rather than 
interacting directly with a specific solver.

For what it's worth, here's my attempt 

 at integrating STP.


https://reviews.llvm.org/D28952



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21675: New ODR checker for modules

2017-01-20 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu added a comment.

After changing the ODRHash class a bit, the new performance numbers are 3% in 
debug and 1-1.5% in release builds.


https://reviews.llvm.org/D21675



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r292694 - [NVPTX] Auto-upgrade some NVPTX intrinsics to LLVM target-generic code.

2017-01-20 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Fri Jan 20 19:00:32 2017
New Revision: 292694

URL: http://llvm.org/viewvc/llvm-project?rev=292694=rev
Log:
[NVPTX] Auto-upgrade some NVPTX intrinsics to LLVM target-generic code.

Summary:
Specifically, we upgrade llvm.nvvm.:

 * brev{32,64}
 * clz.{i,ll}
 * popc.{i,ll}
 * abs.{i,ll}
 * {min,max}.{i,ll,u,ull}
 * h2f

These either map directly to an existing LLVM target-generic
intrinsic or map to a simple LLVM target-generic idiom.

In all cases, we check that the code we generate is lowered to PTX as we
expect.

These builtins don't need to be backfilled in clang: They're not
accessible to user code from nvcc.

Reviewers: tra

Subscribers: majnemer, cfe-commits, llvm-commits, jholewinski

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def

Modified: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def?rev=292694=292693=292694=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def Fri Jan 20 19:00:32 2017
@@ -64,24 +64,10 @@ BUILTIN(__nvvm_read_ptx_sreg_pm3, "i", "
 
 // MISC
 
-BUILTIN(__nvvm_clz_i, "ii", "")
-BUILTIN(__nvvm_clz_ll, "iLLi", "")
-BUILTIN(__nvvm_popc_i, "ii", "")
-BUILTIN(__nvvm_popc_ll, "iLLi", "")
 BUILTIN(__nvvm_prmt, "UiUiUiUi", "")
 
 // Min Max
 
-BUILTIN(__nvvm_min_i, "iii", "")
-BUILTIN(__nvvm_min_ui, "UiUiUi", "")
-BUILTIN(__nvvm_min_ll, "LLiLLiLLi", "")
-BUILTIN(__nvvm_min_ull, "ULLiULLiULLi", "")
-
-BUILTIN(__nvvm_max_i, "iii", "")
-BUILTIN(__nvvm_max_ui, "UiUiUi", "")
-BUILTIN(__nvvm_max_ll, "LLiLLiLLi", "")
-BUILTIN(__nvvm_max_ull, "ULLiULLiULLi", "")
-
 BUILTIN(__nvvm_fmax_ftz_f, "fff",  "")
 BUILTIN(__nvvm_fmax_f, "fff",  "")
 BUILTIN(__nvvm_fmin_ftz_f, "fff",  "")
@@ -133,11 +119,6 @@ BUILTIN(__nvvm_div_rz_d,  "ddd", "")
 BUILTIN(__nvvm_div_rm_d,  "ddd", "")
 BUILTIN(__nvvm_div_rp_d,  "ddd", "")
 
-// Brev
-
-BUILTIN(__nvvm_brev32, "UiUi", "")
-BUILTIN(__nvvm_brev64, "ULLiULLi", "")
-
 // Sad
 
 BUILTIN(__nvvm_sad_i, "", "")
@@ -155,9 +136,6 @@ BUILTIN(__nvvm_ceil_d, "dd", "")
 
 // Abs
 
-BUILTIN(__nvvm_abs_i, "ii", "")
-BUILTIN(__nvvm_abs_ll, "LLiLLi", "")
-
 BUILTIN(__nvvm_fabs_ftz_f, "ff", "")
 BUILTIN(__nvvm_fabs_f, "ff", "")
 BUILTIN(__nvvm_fabs_d, "dd", "")
@@ -385,8 +363,6 @@ BUILTIN(__nvvm_ull2d_rp, "dULLi", "")
 BUILTIN(__nvvm_f2h_rn_ftz, "Usf", "")
 BUILTIN(__nvvm_f2h_rn, "Usf", "")
 
-BUILTIN(__nvvm_h2f, "fUs", "")
-
 // Bitcast
 
 BUILTIN(__nvvm_bitcast_f2i, "if", "")


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28793: [NVPTX] Auto-upgrade some NVPTX intrinsics to LLVM target-generic code.

2017-01-20 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292694: [NVPTX] Auto-upgrade some NVPTX intrinsics to LLVM 
target-generic code. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D28793?vs=85206=85221#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28793

Files:
  cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
  llvm/trunk/include/llvm/IR/IntrinsicsNVVM.td
  llvm/trunk/lib/IR/AutoUpgrade.cpp
  llvm/trunk/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/trunk/test/Assembler/auto_upgrade_nvvm_intrinsics.ll

Index: llvm/trunk/lib/IR/AutoUpgrade.cpp
===
--- llvm/trunk/lib/IR/AutoUpgrade.cpp
+++ llvm/trunk/lib/IR/AutoUpgrade.cpp
@@ -14,6 +14,7 @@
 //===--===//
 
 #include "llvm/IR/AutoUpgrade.h"
+#include "llvm/ADT/StringSwitch.h"
 #include "llvm/IR/CFG.h"
 #include "llvm/IR/CallSite.h"
 #include "llvm/IR/Constants.h"
@@ -204,7 +205,38 @@
 }
 break;
   }
+  case 'n': {
+if (Name.startswith("nvvm.")) {
+  Name = Name.substr(5);
+
+  // The following nvvm intrinsics correspond exactly to an LLVM intrinsic.
+  Intrinsic::ID IID = StringSwitch(Name)
+  .Cases("brev32", "brev64", Intrinsic::bitreverse)
+  .Case("clz.i", Intrinsic::ctlz)
+  .Case("popc.i", Intrinsic::ctpop)
+  .Default(Intrinsic::not_intrinsic);
+  if (IID != Intrinsic::not_intrinsic && F->arg_size() == 1) {
+NewFn = Intrinsic::getDeclaration(F->getParent(), IID,
+  {F->getReturnType()});
+return true;
+  }
 
+  // The following nvvm intrinsics correspond exactly to an LLVM idiom, but
+  // not to an intrinsic alone.  We expand them in UpgradeIntrinsicCall.
+  //
+  // TODO: We could add lohi.i2d.
+  bool Expand = StringSwitch(Name)
+.Cases("abs.i", "abs.ll", true)
+.Cases("clz.ll", "popc.ll", "h2f", true)
+.Cases("max.i", "max.ll", "max.ui", "max.ull", true)
+.Cases("min.i", "min.ll", "min.ui", "min.ull", true)
+.Default(false);
+  if (Expand) {
+NewFn = nullptr;
+return true;
+  }
+}
+  }
   case 'o':
 // We only need to change the name to match the mangling including the
 // address space.
@@ -753,6 +785,9 @@
 bool IsX86 = Name.startswith("x86.");
 if (IsX86)
   Name = Name.substr(4);
+bool IsNVVM = Name.startswith("nvvm.");
+if (IsNVVM)
+  Name = Name.substr(5);
 
 if (IsX86 && Name.startswith("sse4a.movnt.")) {
   Module *M = F->getParent();
@@ -1727,6 +1762,50 @@
{ CI->getArgOperand(0), CI->getArgOperand(1) });
   Rep = EmitX86Select(Builder, CI->getArgOperand(3), Rep,
   CI->getArgOperand(2));
+} else if (IsNVVM && (Name == "abs.i" || Name == "abs.ll")) {
+  Value *Arg = CI->getArgOperand(0);
+  Value *Neg = Builder.CreateNeg(Arg, "neg");
+  Value *Cmp = Builder.CreateICmpSGE(
+  Arg, llvm::Constant::getNullValue(Arg->getType()), "abs.cond");
+  Rep = Builder.CreateSelect(Cmp, Arg, Neg, "abs");
+} else if (IsNVVM && (Name == "max.i" || Name == "max.ll" ||
+  Name == "max.ui" || Name == "max.ull")) {
+  Value *Arg0 = CI->getArgOperand(0);
+  Value *Arg1 = CI->getArgOperand(1);
+  Value *Cmp = Name.endswith(".ui") || Name.endswith(".ull")
+   ? Builder.CreateICmpUGE(Arg0, Arg1, "max.cond")
+   : Builder.CreateICmpSGE(Arg0, Arg1, "max.cond");
+  Rep = Builder.CreateSelect(Cmp, Arg0, Arg1, "max");
+} else if (IsNVVM && (Name == "min.i" || Name == "min.ll" ||
+  Name == "min.ui" || Name == "min.ull")) {
+  Value *Arg0 = CI->getArgOperand(0);
+  Value *Arg1 = CI->getArgOperand(1);
+  Value *Cmp = Name.endswith(".ui") || Name.endswith(".ull")
+   ? Builder.CreateICmpULE(Arg0, Arg1, "min.cond")
+   : Builder.CreateICmpSLE(Arg0, Arg1, "min.cond");
+  Rep = Builder.CreateSelect(Cmp, Arg0, Arg1, "min");
+} else if (IsNVVM && Name == "clz.ll") {
+  // llvm.nvvm.clz.ll returns an i32, but llvm.ctlz.i64 and returns an i64.
+  Value *Arg = CI->getArgOperand(0);
+  Value *Ctlz = Builder.CreateCall(
+  Intrinsic::getDeclaration(F->getParent(), Intrinsic::ctlz,
+{Arg->getType()}),
+  {Arg, Builder.getFalse()}, "ctlz");
+  Rep = Builder.CreateTrunc(Ctlz, Builder.getInt32Ty(), "ctlz.trunc");
+} else if (IsNVVM && Name == "popc.ll") {
+  // llvm.nvvm.popc.ll returns an i32, but llvm.ctpop.i64 and returns an
+  // i64.
+  Value 

[libcxx] r292689 - Fix recent build errors

2017-01-20 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan 20 18:57:29 2017
New Revision: 292689

URL: http://llvm.org/viewvc/llvm-project?rev=292689=rev
Log:
Fix recent build errors

Modified:

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp

libcxx/trunk/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp
libcxx/trunk/test/support/poisoned_hash_helper.hpp

Modified: 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp?rev=292689=292688=292689=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
 Fri Jan 20 18:57:29 2017
@@ -46,13 +46,16 @@ void test_disabled_with_deleter() {
   test_hash_disabled_for_type();
 }
 
+namespace std {
+
 template 
-struct std::hash>> {
-  size_t operator()(min_pointer> p) const 
{
+struct hash<::min_pointer>> {
+  size_t operator()(::min_pointer> p) 
const {
 if (!p) return 0;
 return std::hash{}(std::addressof(*p));
   }
 };
+}
 
 struct A {};
 

Modified: 
libcxx/trunk/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp?rev=292689=292688=292689=diff
==
--- 
libcxx/trunk/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp
 Fri Jan 20 18:57:29 2017
@@ -30,7 +30,9 @@ int main()
 static_assert((std::is_same::value), "" );
 static_assert((std::is_same::value), 
"" );
   }
+#if TEST_STD_VER >= 11
   {
 test_hash_enabled_for_type(std::type_index(typeid(int)));
   }
+#endif
 }

Modified: libcxx/trunk/test/support/poisoned_hash_helper.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/poisoned_hash_helper.hpp?rev=292689=292688=292689=diff
==
--- libcxx/trunk/test/support/poisoned_hash_helper.hpp (original)
+++ libcxx/trunk/test/support/poisoned_hash_helper.hpp Fri Jan 20 18:57:29 2017
@@ -163,7 +163,7 @@ void test_hash_enabled(InputKey const& k
   static_assert(can_hash(), "");
   static_assert(can_hash(), "");
 
-  const Hash h;
+  const Hash h{};
   assert(h(key) == h(key));
 
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27872: [APFloat] Switch from (PPCDoubleDoubleImpl, IEEEdouble) layout to (IEEEdouble, IEEEdouble)

2017-01-20 Thread Tim Shen via Phabricator via cfe-commits
timshen added inline comments.



Comment at: llvm/include/llvm/ADT/APFloat.h:1039
+  /// \brief Operator+ overload which provides the default
+  /// \c nmNearestTiesToEven rounding mode and *no* error checking.
   APFloat operator+(const APFloat ) const {

echristo wrote:
> What's with the no error checking. Also, unless my font kerning is terrible 
> you have nmNearestTiesToEven versus rmNearestTiesToEven.
That original IEEEFloat does so. I think it's reasonable, since the operators 
are mostly for convenience, while a serious user should use 
add/subtract/multiply/divide.

Fixed the typo.


https://reviews.llvm.org/D27872



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27872: [APFloat] Switch from (PPCDoubleDoubleImpl, IEEEdouble) layout to (IEEEdouble, IEEEdouble)

2017-01-20 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 85217.
timshen marked 2 inline comments as done.
timshen added a comment.

Stylish changes.


https://reviews.llvm.org/D27872

Files:
  clang/test/CodeGen/ppc64-complex-parms.c
  llvm/include/llvm/ADT/APFloat.h
  llvm/lib/Support/APFloat.cpp
  llvm/test/CodeGen/PowerPC/fp128-bitcast-after-operation.ll
  llvm/unittests/ADT/APFloatTest.cpp

Index: llvm/unittests/ADT/APFloatTest.cpp
===
--- llvm/unittests/ADT/APFloatTest.cpp
+++ llvm/unittests/ADT/APFloatTest.cpp
@@ -9,6 +9,7 @@
 
 #include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/raw_ostream.h"
@@ -3181,7 +3182,7 @@
   0x7948ull, 0ull, APFloat::fcInfinity,
   APFloat::rmNearestTiesToEven),
   // TODO: change the 4th 0x75ee to 0x75ef when
-  // PPCDoubleDoubleImpl is gone.
+  // semPPCDoubleDoubleLegacy is gone.
   // LDBL_MAX + (1.01... >> (1023 - 106) + (1.111...0 >> (1023 -
   // 160))) = fcNormal
   std::make_tuple(0x7fefull, 0x7c8eull,
@@ -3234,14 +3235,14 @@
   0x3ff0ull, 0x0001ull,
   APFloat::rmNearestTiesToEven),
   // TODO: change 0xf950 to 0xf940, when
-  // PPCDoubleDoubleImpl is gone.
+  // semPPCDoubleDoubleLegacy is gone.
   // (DBL_MAX - 1 << (1023 - 105)) + (1 << (1023 - 53) + 0) = DBL_MAX +
   // 1.1... << (1023 - 52)
   std::make_tuple(0x7fefull, 0xf950ull,
   0x7c90ull, 0, 0x7fefull,
   0x7c8eull, APFloat::rmNearestTiesToEven),
   // TODO: change 0xf950 to 0xf940, when
-  // PPCDoubleDoubleImpl is gone.
+  // semPPCDoubleDoubleLegacy is gone.
   // (1 << (1023 - 53) + 0) + (DBL_MAX - 1 << (1023 - 105)) = DBL_MAX +
   // 1.1... << (1023 - 52)
   std::make_tuple(0x7c90ull, 0, 0x7fefull,
@@ -3262,7 +3263,7 @@
 << formatv("({0:x} + {1:x}) + ({2:x} + {3:x})", Op1[0], Op1[1], Op2[0],
Op2[1])
.str();
-EXPECT_EQ(Expected[1], A1.getSecondFloat().bitcastToAPInt().getRawData()[0])
+EXPECT_EQ(Expected[1], A1.bitcastToAPInt().getRawData()[1])
 << formatv("({0:x} + {1:x}) + ({2:x} + {3:x})", Op1[0], Op1[1], Op2[0],
Op2[1])
.str();
@@ -3296,7 +3297,7 @@
 << formatv("({0:x} + {1:x}) - ({2:x} + {3:x})", Op1[0], Op1[1], Op2[0],
Op2[1])
.str();
-EXPECT_EQ(Expected[1], A1.getSecondFloat().bitcastToAPInt().getRawData()[0])
+EXPECT_EQ(Expected[1], A1.bitcastToAPInt().getRawData()[1])
 << formatv("({0:x} + {1:x}) - ({2:x} + {3:x})", Op1[0], Op1[1], Op2[0],
Op2[1])
.str();
@@ -3496,12 +3497,53 @@
 APFloat A1(APFloat::PPCDoubleDouble(), APInt(128, 2, Op1));
 APFloat A2(APFloat::PPCDoubleDouble(), APInt(128, 2, Op2));
 EXPECT_EQ(Expected, A1.compare(A2))
-<< formatv("({0:x} + {1:x}) - ({2:x} + {3:x})", Op1[0], Op1[1], Op2[0],
+<< formatv("compare(({0:x} + {1:x}), ({2:x} + {3:x}))", Op1[0], Op1[1],
+   Op2[0], Op2[1])
+   .str();
+  }
+}
+
+TEST(APFloatTest, PPCDoubleDoubleBitwiseIsEqual) {
+  using DataType = std::tuple;
+
+  DataType Data[] = {
+  // (1 + 0) = (1 + 0)
+  std::make_tuple(0x3ff0ull, 0, 0x3ff0ull, 0, true),
+  // (1 + 0) != (1.00...1 + 0)
+  std::make_tuple(0x3ff0ull, 0, 0x3ff1ull, 0,
+  false),
+  // NaN = NaN
+  std::make_tuple(0x7ff8ull, 0, 0x7ff8ull, 0, true),
+  // NaN != NaN with a different bit pattern
+  std::make_tuple(0x7ff8ull, 0, 0x7ff8ull,
+  0x3ff0ull, false),
+  // Inf = Inf
+  std::make_tuple(0x7ff0ull, 0, 0x7ff0ull, 0, true),
+  };
+
+  for (auto Tp : Data) {
+uint64_t Op1[2], Op2[2];
+bool Expected;
+std::tie(Op1[0], Op1[1], Op2[0], Op2[1], Expected) = Tp;
+
+APFloat A1(APFloat::PPCDoubleDouble(), APInt(128, 2, Op1));
+APFloat A2(APFloat::PPCDoubleDouble(), APInt(128, 2, Op2));
+EXPECT_EQ(Expected, A1.bitwiseIsEqual(A2))
+<< formatv("({0:x} + {1:x}) = ({2:x} + {3:x})", Op1[0], Op1[1], Op2[0],
Op2[1])
.str();
   }
 }
 
+TEST(APFloatTest, PPCDoubleDoubleHashValue) {
+  uint64_t Data1[] = {0x3ff1ull, 0x0001ull};
+  uint64_t Data2[] = {0x3ff1ull, 0};
+  // The hash values are 

[libcxx] r292684 - Implement P0513R0 - "Poisoning the Hash"

2017-01-20 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan 20 18:02:12 2017
New Revision: 292684

URL: http://llvm.org/viewvc/llvm-project?rev=292684=rev
Log:
Implement P0513R0 - "Poisoning the Hash"

Summary:
Exactly what the title says.

This patch also adds a `std::hash` specialization in C++17, but it 
was not added by this paper and I can't find the actual paper that adds it.

See http://wg21.link/P0513R0 for more info.

If there are no comments in the next couple of days I'll commit this

Reviewers: mclow.lists, K-ballo, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits

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

Added:
libcxx/trunk/test/std/containers/sequences/vector.bool/enabled_hash.pass.cpp
libcxx/trunk/test/std/diagnostics/syserr/syserr.hash/enabled_hash.pass.cpp
libcxx/trunk/test/std/strings/basic.string.hash/enabled_hashes.pass.cpp

libcxx/trunk/test/std/strings/string.view/string.view.hash/enabled_hashes.pass.cpp

libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/enabled_hashes.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/unord.hash/enabled_hashes.pass.cpp

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/enabled_hash.pass.cpp
libcxx/trunk/test/std/utilities/optional/optional.hash/enabled_hash.pass.cpp

libcxx/trunk/test/std/utilities/template.bitset/bitset.hash/enabled_hash.pass.cpp

libcxx/trunk/test/std/utilities/type.index/type.index.hash/enabled_hash.pass.cpp
libcxx/trunk/test/std/utilities/variant/variant.hash/enabled_hash.pass.cpp
libcxx/trunk/test/support/poisoned_hash_helper.hpp
libcxx/trunk/test/support/test.support/test_poisoned_hash_helper.pass.cpp
Modified:
libcxx/trunk/include/__functional_base
libcxx/trunk/include/functional
libcxx/trunk/include/memory
libcxx/trunk/include/new
libcxx/trunk/include/optional
libcxx/trunk/include/utility
libcxx/trunk/include/variant
libcxx/trunk/test/libcxx/test/config.py

libcxx/trunk/test/std/strings/string.view/string.view.hash/string_view.pass.cpp

libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
libcxx/trunk/test/std/utilities/optional/optional.hash/hash.pass.cpp

libcxx/trunk/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp
libcxx/trunk/test/std/utilities/variant/variant.hash/hash.pass.cpp
libcxx/trunk/test/support/deleter_types.h
libcxx/trunk/test/support/min_allocator.h
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/__functional_base
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__functional_base?rev=292684=292683=292684=diff
==
--- libcxx/trunk/include/__functional_base (original)
+++ libcxx/trunk/include/__functional_base Fri Jan 20 18:02:12 2017
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -23,13 +24,6 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-template 
-struct _LIBCPP_TEMPLATE_VIS unary_function
-{
-typedef _Argargument_type;
-typedef _Result result_type;
-};
-
 template 
 struct _LIBCPP_TEMPLATE_VIS binary_function
 {

Modified: libcxx/trunk/include/functional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/functional?rev=292684=292683=292684=diff
==
--- libcxx/trunk/include/functional (original)
+++ libcxx/trunk/include/functional Fri Jan 20 18:02:12 2017
@@ -485,6 +485,7 @@ POLICY:  For non-variadic implementation
 #include 
 #include 
 #include 
+#include 
 
 #include <__functional_base>
 
@@ -2339,247 +2340,6 @@ bind(_Fp&& __f, _BoundArgs&&... __bound_
 
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash
-: public unary_function
-{
-_LIBCPP_INLINE_VISIBILITY
-size_t operator()(bool __v) const _NOEXCEPT {return 
static_cast(__v);}
-};
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash
-: public unary_function
-{
-_LIBCPP_INLINE_VISIBILITY
-size_t operator()(char __v) const _NOEXCEPT {return 
static_cast(__v);}
-};
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash
-: public unary_function
-{
-_LIBCPP_INLINE_VISIBILITY
-size_t operator()(signed char __v) const _NOEXCEPT {return 
static_cast(__v);}
-};
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash
-: public unary_function
-{
-_LIBCPP_INLINE_VISIBILITY
-size_t operator()(unsigned char __v) const _NOEXCEPT {return 
static_cast(__v);}
-};
-
-#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash
-  

[PATCH] D28938: Implement P0513R0 - "Poisoning the Hash"

2017-01-20 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

I feel comfortable with this in its current state.


https://reviews.llvm.org/D28938



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27257: [CodeCompletion] Ensure that ObjC root class completes instance methods from protocols and categories as well

2017-01-20 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

How does this interact (if at all) with classes annotated with  
`__attribute__((objc_root_class))`?




Comment at: lib/Sema/SemaCodeComplete.cpp:5259
SelIdents, CurContext, Selectors,
AllowSameLength, Results, false);
 

`false` -> `false /*IsRootClass*/`


Repository:
  rL LLVM

https://reviews.llvm.org/D27257



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28849: [compiler-rt] [test] Fix page address logic in clear_cache_test

2017-01-20 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 85208.
mgorny marked an inline comment as done.
mgorny added a comment.

Fixed the missing change. Also created a local variable to avoid calling the 
sysconf three times.


https://reviews.llvm.org/D28849

Files:
  test/builtins/Unit/clear_cache_test.c


Index: test/builtins/Unit/clear_cache_test.c
===
--- test/builtins/Unit/clear_cache_test.c
+++ test/builtins/Unit/clear_cache_test.c
@@ -18,9 +18,20 @@
 if (!FlushInstructionCache(GetCurrentProcess(), start, end-start))
 exit(1);
 }
+
+static uintptr_t get_page_size() {
+SYSTEM_INFO si;
+GetSystemInfo();
+return si.dwPageSize;
+}
 #else
+#include 
 #include 
 extern void __clear_cache(void* start, void* end);
+
+static uintptr_t get_page_size() {
+return sysconf(_SC_PAGE_SIZE);
+}
 #endif
 
 
@@ -56,8 +67,9 @@
 int main()
 {
 // make executable the page containing execution_buffer 
-char* start = (char*)((uintptr_t)execution_buffer & (-4095));
-char* end = (char*)((uintptr_t)(_buffer[128+4096]) & (-4095));
+uintptr_t page_size = get_page_size();
+char* start = (char*)((uintptr_t)execution_buffer & (-page_size));
+char* end = (char*)((uintptr_t)(_buffer[128+page_size]) & 
(-page_size));
 #if defined(_WIN32)
 DWORD dummy_oldProt;
 MEMORY_BASIC_INFORMATION b;


Index: test/builtins/Unit/clear_cache_test.c
===
--- test/builtins/Unit/clear_cache_test.c
+++ test/builtins/Unit/clear_cache_test.c
@@ -18,9 +18,20 @@
 if (!FlushInstructionCache(GetCurrentProcess(), start, end-start))
 exit(1);
 }
+
+static uintptr_t get_page_size() {
+SYSTEM_INFO si;
+GetSystemInfo();
+return si.dwPageSize;
+}
 #else
+#include 
 #include 
 extern void __clear_cache(void* start, void* end);
+
+static uintptr_t get_page_size() {
+return sysconf(_SC_PAGE_SIZE);
+}
 #endif
 
 
@@ -56,8 +67,9 @@
 int main()
 {
 // make executable the page containing execution_buffer 
-char* start = (char*)((uintptr_t)execution_buffer & (-4095));
-char* end = (char*)((uintptr_t)(_buffer[128+4096]) & (-4095));
+uintptr_t page_size = get_page_size();
+char* start = (char*)((uintptr_t)execution_buffer & (-page_size));
+char* end = (char*)((uintptr_t)(_buffer[128+page_size]) & (-page_size));
 #if defined(_WIN32)
 DWORD dummy_oldProt;
 MEMORY_BASIC_INFORMATION b;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28793: [NVPTX] Auto-upgrade some NVPTX intrinsics to LLVM target-generic code.

2017-01-20 Thread Justin Lebar via Phabricator via cfe-commits
jlebar updated this revision to Diff 85206.
jlebar added a comment.

Get rid of h2f intrinsics.

Thank you for the careful reviews, Art.


https://reviews.llvm.org/D28793

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/test/Assembler/auto_upgrade_nvvm_intrinsics.ll

Index: llvm/test/Assembler/auto_upgrade_nvvm_intrinsics.ll
===
--- /dev/null
+++ llvm/test/Assembler/auto_upgrade_nvvm_intrinsics.ll
@@ -0,0 +1,102 @@
+; Test to make sure NVVM intrinsics are automatically upgraded.
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+; RUN: verify-uselistorder %s
+
+declare i32 @llvm.nvvm.brev32(i32)
+declare i64 @llvm.nvvm.brev64(i64)
+declare i32 @llvm.nvvm.clz.i(i32)
+declare i32 @llvm.nvvm.clz.ll(i64)
+declare i32 @llvm.nvvm.popc.i(i32)
+declare i32 @llvm.nvvm.popc.ll(i64)
+declare float @llvm.nvvm.h2f(i16)
+
+declare i32 @llvm.nvvm.abs.i(i32)
+declare i64 @llvm.nvvm.abs.ll(i64)
+
+declare i32 @llvm.nvvm.max.i(i32, i32)
+declare i64 @llvm.nvvm.max.ll(i64, i64)
+declare i32 @llvm.nvvm.max.ui(i32, i32)
+declare i64 @llvm.nvvm.max.ull(i64, i64)
+declare i32 @llvm.nvvm.min.i(i32, i32)
+declare i64 @llvm.nvvm.min.ll(i64, i64)
+declare i32 @llvm.nvvm.min.ui(i32, i32)
+declare i64 @llvm.nvvm.min.ull(i64, i64)
+
+; CHECK-LABEL: @simple_upgrade
+define void @simple_upgrade(i32 %a, i64 %b, i16 %c) {
+; CHECK: call i32 @llvm.bitreverse.i32(i32 %a)
+  %r1 = call i32 @llvm.nvvm.brev32(i32 %a)
+
+; CHECK: call i64 @llvm.bitreverse.i64(i64 %b)
+  %r2 = call i64 @llvm.nvvm.brev64(i64 %b)
+
+; CHECK: call i32 @llvm.ctlz.i32(i32 %a, i1 false)
+  %r3 = call i32 @llvm.nvvm.clz.i(i32 %a)
+
+; CHECK: [[clz:%[a-zA-Z0-9.]+]] = call i64 @llvm.ctlz.i64(i64 %b, i1 false)
+; CHECK: trunc i64 [[clz]] to i32
+  %r4 = call i32 @llvm.nvvm.clz.ll(i64 %b)
+
+; CHECK: call i32 @llvm.ctpop.i32(i32 %a)
+  %r5 = call i32 @llvm.nvvm.popc.i(i32 %a)
+
+; CHECK: [[popc:%[a-zA-Z0-9.]+]] = call i64 @llvm.ctpop.i64(i64 %b)
+; CHECK: trunc i64 [[popc]] to i32
+  %r6 = call i32 @llvm.nvvm.popc.ll(i64 %b)
+
+; CHECK: call float @llvm.convert.from.fp16.f32(i16 %c)
+  %r7 = call float @llvm.nvvm.h2f(i16 %c)
+  ret void
+}
+
+; CHECK-LABEL @abs
+define void @abs(i32 %a, i64 %b) {
+; CHECK-DAG: [[negi:%[a-zA-Z0-9.]+]] = sub i32 0, %a
+; CHECK-DAG: [[cmpi:%[a-zA-Z0-9.]+]] = icmp sge i32 %a, 0
+; CHECK: select i1 [[cmpi]], i32 %a, i32 [[negi]]
+  %r1 = call i32 @llvm.nvvm.abs.i(i32 %a)
+
+; CHECK-DAG: [[negll:%[a-zA-Z0-9.]+]] = sub i64 0, %b
+; CHECK-DAG: [[cmpll:%[a-zA-Z0-9.]+]] = icmp sge i64 %b, 0
+; CHECK: select i1 [[cmpll]], i64 %b, i64 [[negll]]
+  %r2 = call i64 @llvm.nvvm.abs.ll(i64 %b)
+
+  ret void
+}
+
+; CHECK-LABEL: @min_max
+define void @min_max(i32 %a1, i32 %a2, i64 %b1, i64 %b2) {
+; CHECK: [[maxi:%[a-zA-Z0-9.]+]] = icmp sge i32 %a1, %a2
+; CHECK: select i1 [[maxi]], i32 %a1, i32 %a2
+  %r1 = call i32 @llvm.nvvm.max.i(i32 %a1, i32 %a2)
+
+; CHECK: [[maxll:%[a-zA-Z0-9.]+]] = icmp sge i64 %b1, %b2
+; CHECK: select i1 [[maxll]], i64 %b1, i64 %b2
+  %r2 = call i64 @llvm.nvvm.max.ll(i64 %b1, i64 %b2)
+
+; CHECK: [[maxui:%[a-zA-Z0-9.]+]] = icmp uge i32 %a1, %a2
+; CHECK: select i1 [[maxui]], i32 %a1, i32 %a2
+  %r3 = call i32 @llvm.nvvm.max.ui(i32 %a1, i32 %a2)
+
+; CHECK: [[maxull:%[a-zA-Z0-9.]+]] = icmp uge i64 %b1, %b2
+; CHECK: select i1 [[maxull]], i64 %b1, i64 %b2
+  %r4 = call i64 @llvm.nvvm.max.ull(i64 %b1, i64 %b2)
+
+; CHECK: [[mini:%[a-zA-Z0-9.]+]] = icmp sle i32 %a1, %a2
+; CHECK: select i1 [[mini]], i32 %a1, i32 %a2
+  %r5 = call i32 @llvm.nvvm.min.i(i32 %a1, i32 %a2)
+
+; CHECK: [[minll:%[a-zA-Z0-9.]+]] = icmp sle i64 %b1, %b2
+; CHECK: select i1 [[minll]], i64 %b1, i64 %b2
+  %r6 = call i64 @llvm.nvvm.min.ll(i64 %b1, i64 %b2)
+
+; CHECK: [[minui:%[a-zA-Z0-9.]+]] = icmp ule i32 %a1, %a2
+; CHECK: select i1 [[minui]], i32 %a1, i32 %a2
+  %r7 = call i32 @llvm.nvvm.min.ui(i32 %a1, i32 %a2)
+
+; CHECK: [[minull:%[a-zA-Z0-9.]+]] = icmp ule i64 %b1, %b2
+; CHECK: select i1 [[minull]], i64 %b1, i64 %b2
+  %r8 = call i64 @llvm.nvvm.min.ull(i64 %b1, i64 %b2)
+
+  ret void
+}
Index: llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
===
--- llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
+++ llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
@@ -187,43 +187,13 @@
 // MISC
 //
 
-def INT_NVVM_CLZ_I : F_MATH_1<"clz.b32 \t$dst, $src0;", Int32Regs, Int32Regs,
-  int_nvvm_clz_i>;
-def INT_NVVM_CLZ_LL : F_MATH_1<"clz.b64 \t$dst, $src0;", Int32Regs, Int64Regs,
-  int_nvvm_clz_ll>;
-
-def INT_NVVM_POPC_I : F_MATH_1<"popc.b32 \t$dst, $src0;", Int32Regs, Int32Regs,
-  int_nvvm_popc_i>;
-def INT_NVVM_POPC_LL : F_MATH_1<"popc.b64 \t$dst, $src0;", Int32Regs, Int64Regs,
-  int_nvvm_popc_ll>;
-
 def INT_NVVM_PRMT : F_MATH_3<"prmt.b32 \t$dst, $src0, $src1, $src2;", Int32Regs,
   Int32Regs, Int32Regs, Int32Regs, int_nvvm_prmt>;
 
 //
 // Min 

[PATCH] D28974: [Basic] Remove the 32-bit x86 and ARM targets for Fuchsia

2017-01-20 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292671: [Basic] Remove the 32-bit x86 and ARM targets for 
Fuchsia (authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D28974?vs=85199=85205#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28974

Files:
  cfe/trunk/lib/Basic/Targets.cpp


Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -8604,8 +8604,6 @@
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
-case llvm::Triple::Fuchsia:
-  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
 case llvm::Triple::OpenBSD:
@@ -8642,8 +8640,6 @@
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
-case llvm::Triple::Fuchsia:
-  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
 case llvm::Triple::OpenBSD:
@@ -8879,8 +8875,6 @@
   return new BitrigI386TargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
-case llvm::Triple::Fuchsia:
-  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::KFreeBSD:
   return new KFreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::Minix:


Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -8604,8 +8604,6 @@
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
-case llvm::Triple::Fuchsia:
-  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
 case llvm::Triple::OpenBSD:
@@ -8642,8 +8640,6 @@
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
-case llvm::Triple::Fuchsia:
-  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
 case llvm::Triple::OpenBSD:
@@ -8879,8 +8875,6 @@
   return new BitrigI386TargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
-case llvm::Triple::Fuchsia:
-  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::KFreeBSD:
   return new KFreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::Minix:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r292671 - [Basic] Remove the 32-bit x86 and ARM targets for Fuchsia

2017-01-20 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Fri Jan 20 16:53:38 2017
New Revision: 292671

URL: http://llvm.org/viewvc/llvm-project?rev=292671=rev
Log:
[Basic] Remove the 32-bit x86 and ARM targets for Fuchsia

The 32-bit architectures are no longer supported by Fuchsia.

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=292671=292670=292671=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Jan 20 16:53:38 2017
@@ -8604,8 +8604,6 @@ static TargetInfo *AllocateTarget(const
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
-case llvm::Triple::Fuchsia:
-  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
 case llvm::Triple::OpenBSD:
@@ -8642,8 +8640,6 @@ static TargetInfo *AllocateTarget(const
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
-case llvm::Triple::Fuchsia:
-  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
 case llvm::Triple::OpenBSD:
@@ -8879,8 +8875,6 @@ static TargetInfo *AllocateTarget(const
   return new BitrigI386TargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
-case llvm::Triple::Fuchsia:
-  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::KFreeBSD:
   return new KFreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::Minix:


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28974: [Basic] Remove the 32-bit x86 and ARM targets for Fuchsia

2017-01-20 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


Repository:
  rL LLVM

https://reviews.llvm.org/D28974



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28974: [Basic] Remove the 32-bit x86 and ARM targets for Fuchsia

2017-01-20 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
Herald added subscribers: rengolin, aemerson.

The 32-bit architectures are no longer supported by Fuchsia.


Repository:
  rL LLVM

https://reviews.llvm.org/D28974

Files:
  lib/Basic/Targets.cpp


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -8604,8 +8604,6 @@
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
-case llvm::Triple::Fuchsia:
-  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
 case llvm::Triple::OpenBSD:
@@ -8642,8 +8640,6 @@
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
-case llvm::Triple::Fuchsia:
-  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
 case llvm::Triple::OpenBSD:
@@ -8879,8 +8875,6 @@
   return new BitrigI386TargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
-case llvm::Triple::Fuchsia:
-  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::KFreeBSD:
   return new KFreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::Minix:


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -8604,8 +8604,6 @@
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
-case llvm::Triple::Fuchsia:
-  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
 case llvm::Triple::OpenBSD:
@@ -8642,8 +8640,6 @@
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
-case llvm::Triple::Fuchsia:
-  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
 case llvm::Triple::OpenBSD:
@@ -8879,8 +8875,6 @@
   return new BitrigI386TargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
-case llvm::Triple::Fuchsia:
-  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::KFreeBSD:
   return new KFreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::Minix:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28843: IRGen: Start using the WriteThinLTOBitcode pass.

2017-01-20 Thread Peter Collingbourne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292662: IRGen: Start using the WriteThinLTOBitcode pass. 
(authored by pcc).

Changed prior to commit:
  https://reviews.llvm.org/D28843?vs=84907=85198#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28843

Files:
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/test/CMakeLists.txt
  cfe/trunk/test/CodeGenCXX/type-metadata-thinlto.cpp


Index: cfe/trunk/test/CodeGenCXX/type-metadata-thinlto.cpp
===
--- cfe/trunk/test/CodeGenCXX/type-metadata-thinlto.cpp
+++ cfe/trunk/test/CodeGenCXX/type-metadata-thinlto.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -flto=thin -flto-unit -triple x86_64-unknown-linux 
-fvisibility hidden -emit-llvm-bc -o %t %s
+// RUN: llvm-modextract -o - -n 1 %t | llvm-dis | FileCheck %s
+
+// CHECK: @_ZTV1A = linkonce_odr
+class A {
+  virtual void f() {}
+};
+
+A *f() {
+  return new A;
+}
Index: cfe/trunk/test/CMakeLists.txt
===
--- cfe/trunk/test/CMakeLists.txt
+++ cfe/trunk/test/CMakeLists.txt
@@ -80,6 +80,7 @@
 llc
 llvm-bcanalyzer
 llvm-dis
+llvm-modextract
 llvm-nm
 llvm-objdump
 llvm-profdata
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -689,9 +689,11 @@
 break;
 
   case Backend_EmitBC:
-PerModulePasses.add(createBitcodeWriterPass(
-*OS, CodeGenOpts.EmitLLVMUseLists, CodeGenOpts.EmitSummaryIndex,
-CodeGenOpts.EmitSummaryIndex));
+if (CodeGenOpts.EmitSummaryIndex)
+  PerModulePasses.add(createWriteThinLTOBitcodePass(*OS));
+else
+  PerModulePasses.add(
+  createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists));
 break;
 
   case Backend_EmitLL:


Index: cfe/trunk/test/CodeGenCXX/type-metadata-thinlto.cpp
===
--- cfe/trunk/test/CodeGenCXX/type-metadata-thinlto.cpp
+++ cfe/trunk/test/CodeGenCXX/type-metadata-thinlto.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -flto=thin -flto-unit -triple x86_64-unknown-linux -fvisibility hidden -emit-llvm-bc -o %t %s
+// RUN: llvm-modextract -o - -n 1 %t | llvm-dis | FileCheck %s
+
+// CHECK: @_ZTV1A = linkonce_odr
+class A {
+  virtual void f() {}
+};
+
+A *f() {
+  return new A;
+}
Index: cfe/trunk/test/CMakeLists.txt
===
--- cfe/trunk/test/CMakeLists.txt
+++ cfe/trunk/test/CMakeLists.txt
@@ -80,6 +80,7 @@
 llc
 llvm-bcanalyzer
 llvm-dis
+llvm-modextract
 llvm-nm
 llvm-objdump
 llvm-profdata
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -689,9 +689,11 @@
 break;
 
   case Backend_EmitBC:
-PerModulePasses.add(createBitcodeWriterPass(
-*OS, CodeGenOpts.EmitLLVMUseLists, CodeGenOpts.EmitSummaryIndex,
-CodeGenOpts.EmitSummaryIndex));
+if (CodeGenOpts.EmitSummaryIndex)
+  PerModulePasses.add(createWriteThinLTOBitcodePass(*OS));
+else
+  PerModulePasses.add(
+  createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists));
 break;
 
   case Backend_EmitLL:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r292662 - IRGen: Start using the WriteThinLTOBitcode pass.

2017-01-20 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Fri Jan 20 16:39:16 2017
New Revision: 292662

URL: http://llvm.org/viewvc/llvm-project?rev=292662=rev
Log:
IRGen: Start using the WriteThinLTOBitcode pass.

This is the final change necessary to support CFI with ThinLTO.

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

Added:
cfe/trunk/test/CodeGenCXX/type-metadata-thinlto.cpp
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=292662=292661=292662=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Jan 20 16:39:16 2017
@@ -689,9 +689,11 @@ void EmitAssemblyHelper::EmitAssembly(Ba
 break;
 
   case Backend_EmitBC:
-PerModulePasses.add(createBitcodeWriterPass(
-*OS, CodeGenOpts.EmitLLVMUseLists, CodeGenOpts.EmitSummaryIndex,
-CodeGenOpts.EmitSummaryIndex));
+if (CodeGenOpts.EmitSummaryIndex)
+  PerModulePasses.add(createWriteThinLTOBitcodePass(*OS));
+else
+  PerModulePasses.add(
+  createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists));
 break;
 
   case Backend_EmitLL:

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=292662=292661=292662=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Fri Jan 20 16:39:16 2017
@@ -80,6 +80,7 @@ if( NOT CLANG_BUILT_STANDALONE )
 llc
 llvm-bcanalyzer
 llvm-dis
+llvm-modextract
 llvm-nm
 llvm-objdump
 llvm-profdata

Added: cfe/trunk/test/CodeGenCXX/type-metadata-thinlto.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/type-metadata-thinlto.cpp?rev=292662=auto
==
--- cfe/trunk/test/CodeGenCXX/type-metadata-thinlto.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/type-metadata-thinlto.cpp Fri Jan 20 16:39:16 2017
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -flto=thin -flto-unit -triple x86_64-unknown-linux 
-fvisibility hidden -emit-llvm-bc -o %t %s
+// RUN: llvm-modextract -o - -n 1 %t | llvm-dis | FileCheck %s
+
+// CHECK: @_ZTV1A = linkonce_odr
+class A {
+  virtual void f() {}
+};
+
+A *f() {
+  return new A;
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28973: Supresses misc-move-constructor-init warning for const fields.

2017-01-20 Thread CJ DiMeglio via Phabricator via cfe-commits
lethalantidote created this revision.

Supresses misc-move-constructor init warning for const fields.


https://reviews.llvm.org/D28973

Files:
  clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp
  clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp


Index: clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp
===
--- clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp
+++ clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp
@@ -84,6 +84,11 @@
   N(N &) : Mem(move(RHS.Mem)) {}
 };
 
+struct O {
+  O(O&& other) : b(other.b) {} // ok
+  const B b;
+}
+
 struct Movable {
   Movable(Movable &&) = default;
   Movable(const Movable &) = default;
Index: clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp
@@ -57,6 +57,9 @@
   if (QT.isTriviallyCopyableType(*Result.Context))
 return;
 
+  if (QT.isConstQualified())
+return;
+
   const auto *RD = QT->getAsCXXRecordDecl();
   if (RD && RD->isTriviallyCopyable())
 return;


Index: clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp
===
--- clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp
+++ clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp
@@ -84,6 +84,11 @@
   N(N &) : Mem(move(RHS.Mem)) {}
 };
 
+struct O {
+  O(O&& other) : b(other.b) {} // ok
+  const B b;
+}
+
 struct Movable {
   Movable(Movable &&) = default;
   Movable(const Movable &) = default;
Index: clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp
@@ -57,6 +57,9 @@
   if (QT.isTriviallyCopyableType(*Result.Context))
 return;
 
+  if (QT.isConstQualified())
+return;
+
   const auto *RD = QT->getAsCXXRecordDecl();
   if (RD && RD->isTriviallyCopyable())
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D28931: Disable aligned new/delete on Apple platforms without posix_memalign

2017-01-20 Thread Richard Smith via cfe-commits
On 20 January 2017 at 11:53, Eric Fiselier via Phabricator <
revi...@reviews.llvm.org> wrote:

> EricWF added a comment.
>
> @rsmith I looked for an alternative provider for aligned allocation but
> couldn't find one, which is quite unfortunate. Is this going to mess up the
> `__libcpp_version` detection Clang does?
>

We've not started doing that (yet); there are issues with handling separate
preprocessing use cases that we need to figure out how to address first.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r292659 - [Altivec] Change vec_sl to a << (b % (sizeof(a) * 8))

2017-01-20 Thread Tim Shen via cfe-commits
Author: timshen
Date: Fri Jan 20 16:05:33 2017
New Revision: 292659

URL: http://llvm.org/viewvc/llvm-project?rev=292659=rev
Log:
[Altivec] Change vec_sl to a << (b % (sizeof(a) * 8))

For a << b (as original vec_sl does), if b >= sizeof(a) * 8, the
behavior is undefined. However, Power instructions do define the
behavior, which is equivalent to a << (b % (sizeof(a) * 8)).

This patch changes altivec.h to use a << (b % (sizeof(a) * 8)), to
ensure the consistent semantic of the instructions. Then it combines
the generated multiple instructions back to a single shift.

This patch handles left shift only. Right shift, on the other hand, is
more complicated, considering arithematic/logical right shift.

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

Modified:
cfe/trunk/lib/Headers/altivec.h
cfe/trunk/test/CodeGen/builtins-ppc-altivec.c

Modified: cfe/trunk/lib/Headers/altivec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/altivec.h?rev=292659=292658=292659=diff
==
--- cfe/trunk/lib/Headers/altivec.h (original)
+++ cfe/trunk/lib/Headers/altivec.h Fri Jan 20 16:05:33 2017
@@ -8045,45 +8045,51 @@ static __inline__ vector float __ATTRS_o
 
 /* vec_sl */
 
-static __inline__ vector signed char __ATTRS_o_ai
-vec_sl(vector signed char __a, vector unsigned char __b) {
-  return __a << (vector signed char)__b;
-}
-
+// vec_sl does modulo arithmetic on __b first, so __b is allowed to be more
+// than the length of __a.
 static __inline__ vector unsigned char __ATTRS_o_ai
 vec_sl(vector unsigned char __a, vector unsigned char __b) {
-  return __a << __b;
+  return __a << (__b %
+ (vector unsigned char)(sizeof(unsigned char) * __CHAR_BIT__));
 }
 
-static __inline__ vector short __ATTRS_o_ai vec_sl(vector short __a,
-   vector unsigned short __b) {
-  return __a << (vector short)__b;
+static __inline__ vector signed char __ATTRS_o_ai
+vec_sl(vector signed char __a, vector unsigned char __b) {
+  return (vector signed char)vec_sl((vector unsigned char)__a, __b);
 }
 
 static __inline__ vector unsigned short __ATTRS_o_ai
 vec_sl(vector unsigned short __a, vector unsigned short __b) {
-  return __a << __b;
+  return __a << (__b % (vector unsigned short)(sizeof(unsigned short) *
+   __CHAR_BIT__));
 }
 
-static __inline__ vector int __ATTRS_o_ai vec_sl(vector int __a,
- vector unsigned int __b) {
-  return __a << (vector int)__b;
+static __inline__ vector short __ATTRS_o_ai vec_sl(vector short __a,
+   vector unsigned short __b) {
+  return (vector short)vec_sl((vector unsigned short)__a, __b);
 }
 
 static __inline__ vector unsigned int __ATTRS_o_ai
 vec_sl(vector unsigned int __a, vector unsigned int __b) {
-  return __a << __b;
+  return __a << (__b %
+ (vector unsigned int)(sizeof(unsigned int) * __CHAR_BIT__));
 }
 
-#ifdef __POWER8_VECTOR__
-static __inline__ vector signed long long __ATTRS_o_ai
-vec_sl(vector signed long long __a, vector unsigned long long __b) {
-  return __a << (vector long long)__b;
+static __inline__ vector int __ATTRS_o_ai vec_sl(vector int __a,
+ vector unsigned int __b) {
+  return (vector int)vec_sl((vector unsigned int)__a, __b);
 }
 
+#ifdef __POWER8_VECTOR__
 static __inline__ vector unsigned long long __ATTRS_o_ai
 vec_sl(vector unsigned long long __a, vector unsigned long long __b) {
-  return __a << __b;
+  return __a << (__b % (vector unsigned long long)(sizeof(unsigned long long) *
+   __CHAR_BIT__));
+}
+
+static __inline__ vector long long __ATTRS_o_ai
+vec_sl(vector long long __a, vector unsigned long long __b) {
+  return (vector long long)vec_sl((vector unsigned long long)__a, __b);
 }
 #endif
 

Modified: cfe/trunk/test/CodeGen/builtins-ppc-altivec.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-altivec.c?rev=292659=292658=292659=diff
==
--- cfe/trunk/test/CodeGen/builtins-ppc-altivec.c (original)
+++ cfe/trunk/test/CodeGen/builtins-ppc-altivec.c Fri Jan 20 16:05:33 2017
@@ -3419,28 +3419,40 @@ void test6() {
 
   /* vec_sl */
   res_vsc = vec_sl(vsc, vuc);
-// CHECK: shl <16 x i8>
-// CHECK-LE: shl <16 x i8>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: shl <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: shl <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vuc = vec_sl(vuc, vuc);
-// CHECK: shl <16 x i8>
-// CHECK-LE: shl <16 x i8>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: shl <16 x i8> 

[PATCH] D28037: [Altivec] Change vec_sl to a << (b % (sizeof(a) * 8))

2017-01-20 Thread Tim Shen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292659: [Altivec] Change vec_sl to a << (b % (sizeof(a) * 
8)) (authored by timshen).

Changed prior to commit:
  https://reviews.llvm.org/D28037?vs=83140=85194#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28037

Files:
  cfe/trunk/lib/Headers/altivec.h
  cfe/trunk/test/CodeGen/builtins-ppc-altivec.c

Index: cfe/trunk/lib/Headers/altivec.h
===
--- cfe/trunk/lib/Headers/altivec.h
+++ cfe/trunk/lib/Headers/altivec.h
@@ -8045,45 +8045,51 @@
 
 /* vec_sl */
 
-static __inline__ vector signed char __ATTRS_o_ai
-vec_sl(vector signed char __a, vector unsigned char __b) {
-  return __a << (vector signed char)__b;
-}
-
+// vec_sl does modulo arithmetic on __b first, so __b is allowed to be more
+// than the length of __a.
 static __inline__ vector unsigned char __ATTRS_o_ai
 vec_sl(vector unsigned char __a, vector unsigned char __b) {
-  return __a << __b;
+  return __a << (__b %
+ (vector unsigned char)(sizeof(unsigned char) * __CHAR_BIT__));
 }
 
-static __inline__ vector short __ATTRS_o_ai vec_sl(vector short __a,
-   vector unsigned short __b) {
-  return __a << (vector short)__b;
+static __inline__ vector signed char __ATTRS_o_ai
+vec_sl(vector signed char __a, vector unsigned char __b) {
+  return (vector signed char)vec_sl((vector unsigned char)__a, __b);
 }
 
 static __inline__ vector unsigned short __ATTRS_o_ai
 vec_sl(vector unsigned short __a, vector unsigned short __b) {
-  return __a << __b;
+  return __a << (__b % (vector unsigned short)(sizeof(unsigned short) *
+   __CHAR_BIT__));
 }
 
-static __inline__ vector int __ATTRS_o_ai vec_sl(vector int __a,
- vector unsigned int __b) {
-  return __a << (vector int)__b;
+static __inline__ vector short __ATTRS_o_ai vec_sl(vector short __a,
+   vector unsigned short __b) {
+  return (vector short)vec_sl((vector unsigned short)__a, __b);
 }
 
 static __inline__ vector unsigned int __ATTRS_o_ai
 vec_sl(vector unsigned int __a, vector unsigned int __b) {
-  return __a << __b;
+  return __a << (__b %
+ (vector unsigned int)(sizeof(unsigned int) * __CHAR_BIT__));
 }
 
-#ifdef __POWER8_VECTOR__
-static __inline__ vector signed long long __ATTRS_o_ai
-vec_sl(vector signed long long __a, vector unsigned long long __b) {
-  return __a << (vector long long)__b;
+static __inline__ vector int __ATTRS_o_ai vec_sl(vector int __a,
+ vector unsigned int __b) {
+  return (vector int)vec_sl((vector unsigned int)__a, __b);
 }
 
+#ifdef __POWER8_VECTOR__
 static __inline__ vector unsigned long long __ATTRS_o_ai
 vec_sl(vector unsigned long long __a, vector unsigned long long __b) {
-  return __a << __b;
+  return __a << (__b % (vector unsigned long long)(sizeof(unsigned long long) *
+   __CHAR_BIT__));
+}
+
+static __inline__ vector long long __ATTRS_o_ai
+vec_sl(vector long long __a, vector unsigned long long __b) {
+  return (vector long long)vec_sl((vector unsigned long long)__a, __b);
 }
 #endif
 
Index: cfe/trunk/test/CodeGen/builtins-ppc-altivec.c
===
--- cfe/trunk/test/CodeGen/builtins-ppc-altivec.c
+++ cfe/trunk/test/CodeGen/builtins-ppc-altivec.c
@@ -3419,28 +3419,40 @@
 
   /* vec_sl */
   res_vsc = vec_sl(vsc, vuc);
-// CHECK: shl <16 x i8>
-// CHECK-LE: shl <16 x i8>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: shl <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: shl <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vuc = vec_sl(vuc, vuc);
-// CHECK: shl <16 x i8>
-// CHECK-LE: shl <16 x i8>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: shl <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: shl <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vs  = vec_sl(vs, vus);
-// CHECK: shl <8 x i16>
-// CHECK-LE: shl <8 x i16>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <8 x i16> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: shl <8 x i16> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <8 x i16> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: shl <8 x i16> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vus = vec_sl(vus, vus);
-// CHECK: shl <8 x i16>
-// CHECK-LE: shl <8 x i16>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <8 x i16> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: shl <8 x i16> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <8 x i16> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: shl <8 x i16> {{[0-9a-zA-Z%.]+}}, 

[PATCH] D28037: [Altivec] Change vec_sl to a << (b % (sizeof(a) * 8))

2017-01-20 Thread Tim Shen via Phabricator via cfe-commits
timshen added a comment.

In https://reviews.llvm.org/D28037#652021, @echristo wrote:

> Going to commit this?


I'd like to commit https://reviews.llvm.org/D28329 first. If we commit this 
now, the normal code will be slower.


https://reviews.llvm.org/D28037



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D28037: [Altivec] Change vec_sl to a << (b % (sizeof(a) * 8))

2017-01-20 Thread Eric Christopher via cfe-commits
Please go ahead and commit, we'll worry about speed after correctness.

-eric

On Fri, Jan 20, 2017 at 2:10 PM Tim Shen via Phabricator <
revi...@reviews.llvm.org> wrote:

> timshen added a comment.
>
> In https://reviews.llvm.org/D28037#652021, @echristo wrote:
>
> > Going to commit this?
>
>
> I'd like to commit https://reviews.llvm.org/D28329 first. If we commit
> this now, the normal code will be slower.
>
>
> https://reviews.llvm.org/D28037
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28793: [NVPTX] Auto-upgrade some NVPTX intrinsics to LLVM target-generic code.

2017-01-20 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

There are couple of bits to be deleted. LGTM otherwise.




Comment at: llvm/include/llvm/IR/IntrinsicsNVVM.td:671-672
 
   def int_nvvm_h2f : GCCBuiltin<"__nvvm_h2f">,
   Intrinsic<[llvm_float_ty], [llvm_i16_ty], [IntrNoMem]>;
 

This one should be gone, too.



Comment at: llvm/lib/Target/NVPTX/NVPTXIntrinsics.td:770-771
 
 def : Pat<(int_nvvm_h2f Int16Regs:$a),
   (CVT_f32_f16 (BITCONVERT_16_I2F Int16Regs:$a), CvtNONE)>;
 

Same here.


https://reviews.llvm.org/D28793



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28037: [Altivec] Change vec_sl to a << (b % (sizeof(a) * 8))

2017-01-20 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

Going to commit this?


https://reviews.llvm.org/D28037



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Chance of disturbances in access llvm lab today

2017-01-20 Thread Galina Kistanova via cfe-commits
Hello everyone,

We continue to works on llvm lab network.
There is small chance of disturbances in access llvm lab today.

Thank you for understanding.

Thanks

Galina
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28793: [NVPTX] Auto-upgrade some NVPTX intrinsics to LLVM target-generic code.

2017-01-20 Thread Justin Lebar via Phabricator via cfe-commits
jlebar updated this revision to Diff 85189.
jlebar marked an inline comment as done.
jlebar added a comment.

Address tra's review comments.

> Perhaps we should add the list of such intrinsics and what happens to them in 
> a comment section in NVPTXIntrinsics.td.

sgtm, done.


https://reviews.llvm.org/D28793

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/test/Assembler/auto_upgrade_nvvm_intrinsics.ll

Index: llvm/test/Assembler/auto_upgrade_nvvm_intrinsics.ll
===
--- /dev/null
+++ llvm/test/Assembler/auto_upgrade_nvvm_intrinsics.ll
@@ -0,0 +1,102 @@
+; Test to make sure NVVM intrinsics are automatically upgraded.
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+; RUN: verify-uselistorder %s
+
+declare i32 @llvm.nvvm.brev32(i32)
+declare i64 @llvm.nvvm.brev64(i64)
+declare i32 @llvm.nvvm.clz.i(i32)
+declare i32 @llvm.nvvm.clz.ll(i64)
+declare i32 @llvm.nvvm.popc.i(i32)
+declare i32 @llvm.nvvm.popc.ll(i64)
+declare float @llvm.nvvm.h2f(i16)
+
+declare i32 @llvm.nvvm.abs.i(i32)
+declare i64 @llvm.nvvm.abs.ll(i64)
+
+declare i32 @llvm.nvvm.max.i(i32, i32)
+declare i64 @llvm.nvvm.max.ll(i64, i64)
+declare i32 @llvm.nvvm.max.ui(i32, i32)
+declare i64 @llvm.nvvm.max.ull(i64, i64)
+declare i32 @llvm.nvvm.min.i(i32, i32)
+declare i64 @llvm.nvvm.min.ll(i64, i64)
+declare i32 @llvm.nvvm.min.ui(i32, i32)
+declare i64 @llvm.nvvm.min.ull(i64, i64)
+
+; CHECK-LABEL: @simple_upgrade
+define void @simple_upgrade(i32 %a, i64 %b, i16 %c) {
+; CHECK: call i32 @llvm.bitreverse.i32(i32 %a)
+  %r1 = call i32 @llvm.nvvm.brev32(i32 %a)
+
+; CHECK: call i64 @llvm.bitreverse.i64(i64 %b)
+  %r2 = call i64 @llvm.nvvm.brev64(i64 %b)
+
+; CHECK: call i32 @llvm.ctlz.i32(i32 %a, i1 false)
+  %r3 = call i32 @llvm.nvvm.clz.i(i32 %a)
+
+; CHECK: [[clz:%[a-zA-Z0-9.]+]] = call i64 @llvm.ctlz.i64(i64 %b, i1 false)
+; CHECK: trunc i64 [[clz]] to i32
+  %r4 = call i32 @llvm.nvvm.clz.ll(i64 %b)
+
+; CHECK: call i32 @llvm.ctpop.i32(i32 %a)
+  %r5 = call i32 @llvm.nvvm.popc.i(i32 %a)
+
+; CHECK: [[popc:%[a-zA-Z0-9.]+]] = call i64 @llvm.ctpop.i64(i64 %b)
+; CHECK: trunc i64 [[popc]] to i32
+  %r6 = call i32 @llvm.nvvm.popc.ll(i64 %b)
+
+; CHECK: call float @llvm.convert.from.fp16.f32(i16 %c)
+  %r7 = call float @llvm.nvvm.h2f(i16 %c)
+  ret void
+}
+
+; CHECK-LABEL @abs
+define void @abs(i32 %a, i64 %b) {
+; CHECK-DAG: [[negi:%[a-zA-Z0-9.]+]] = sub i32 0, %a
+; CHECK-DAG: [[cmpi:%[a-zA-Z0-9.]+]] = icmp sge i32 %a, 0
+; CHECK: select i1 [[cmpi]], i32 %a, i32 [[negi]]
+  %r1 = call i32 @llvm.nvvm.abs.i(i32 %a)
+
+; CHECK-DAG: [[negll:%[a-zA-Z0-9.]+]] = sub i64 0, %b
+; CHECK-DAG: [[cmpll:%[a-zA-Z0-9.]+]] = icmp sge i64 %b, 0
+; CHECK: select i1 [[cmpll]], i64 %b, i64 [[negll]]
+  %r2 = call i64 @llvm.nvvm.abs.ll(i64 %b)
+
+  ret void
+}
+
+; CHECK-LABEL: @min_max
+define void @min_max(i32 %a1, i32 %a2, i64 %b1, i64 %b2) {
+; CHECK: [[maxi:%[a-zA-Z0-9.]+]] = icmp sge i32 %a1, %a2
+; CHECK: select i1 [[maxi]], i32 %a1, i32 %a2
+  %r1 = call i32 @llvm.nvvm.max.i(i32 %a1, i32 %a2)
+
+; CHECK: [[maxll:%[a-zA-Z0-9.]+]] = icmp sge i64 %b1, %b2
+; CHECK: select i1 [[maxll]], i64 %b1, i64 %b2
+  %r2 = call i64 @llvm.nvvm.max.ll(i64 %b1, i64 %b2)
+
+; CHECK: [[maxui:%[a-zA-Z0-9.]+]] = icmp uge i32 %a1, %a2
+; CHECK: select i1 [[maxui]], i32 %a1, i32 %a2
+  %r3 = call i32 @llvm.nvvm.max.ui(i32 %a1, i32 %a2)
+
+; CHECK: [[maxull:%[a-zA-Z0-9.]+]] = icmp uge i64 %b1, %b2
+; CHECK: select i1 [[maxull]], i64 %b1, i64 %b2
+  %r4 = call i64 @llvm.nvvm.max.ull(i64 %b1, i64 %b2)
+
+; CHECK: [[mini:%[a-zA-Z0-9.]+]] = icmp sle i32 %a1, %a2
+; CHECK: select i1 [[mini]], i32 %a1, i32 %a2
+  %r5 = call i32 @llvm.nvvm.min.i(i32 %a1, i32 %a2)
+
+; CHECK: [[minll:%[a-zA-Z0-9.]+]] = icmp sle i64 %b1, %b2
+; CHECK: select i1 [[minll]], i64 %b1, i64 %b2
+  %r6 = call i64 @llvm.nvvm.min.ll(i64 %b1, i64 %b2)
+
+; CHECK: [[minui:%[a-zA-Z0-9.]+]] = icmp ule i32 %a1, %a2
+; CHECK: select i1 [[minui]], i32 %a1, i32 %a2
+  %r7 = call i32 @llvm.nvvm.min.ui(i32 %a1, i32 %a2)
+
+; CHECK: [[minull:%[a-zA-Z0-9.]+]] = icmp ule i64 %b1, %b2
+; CHECK: select i1 [[minull]], i64 %b1, i64 %b2
+  %r8 = call i64 @llvm.nvvm.min.ull(i64 %b1, i64 %b2)
+
+  ret void
+}
Index: llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
===
--- llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
+++ llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
@@ -187,43 +187,13 @@
 // MISC
 //
 
-def INT_NVVM_CLZ_I : F_MATH_1<"clz.b32 \t$dst, $src0;", Int32Regs, Int32Regs,
-  int_nvvm_clz_i>;
-def INT_NVVM_CLZ_LL : F_MATH_1<"clz.b64 \t$dst, $src0;", Int32Regs, Int64Regs,
-  int_nvvm_clz_ll>;
-
-def INT_NVVM_POPC_I : F_MATH_1<"popc.b32 \t$dst, $src0;", Int32Regs, Int32Regs,
-  int_nvvm_popc_i>;
-def INT_NVVM_POPC_LL : F_MATH_1<"popc.b64 \t$dst, $src0;", Int32Regs, Int64Regs,
-  int_nvvm_popc_ll>;
-
 def 

Re: [libcxxabi] r292638 - Fix catch_reference_nullptr.pass.cpp test for GCC.

2017-01-20 Thread Renato Golin via cfe-commits
On 20 January 2017 at 19:46, Eric Fiselier  wrote:
> This patch fixes a libc++abi test failure when compiled with GCC 5, 6, or 7.
> We should merge this into 4.0 to help get `check-all` clean.

Hi Eric,

All good on my side, pass with GCC 5.4 and 6.3.

Can you attach all commits that need to be backported into a bug
against PR31622?

We should probably squash them all before merge.

cheers,
--reanto
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r291905 - [Sema] Add warning for unused lambda captures

2017-01-20 Thread Nico Weber via cfe-commits
This warns about code like

  constexpr int foo = 4;
  []() { use(foo); }

That's correct, but removing  then makes MSVC complain about this code
like "error C3493: 'foo' cannot be implicitly captured because no default
capture mode has been specified". A workaround is to make foo static const
instead of constexpr.

This seems like an MSVC bug, but it's still a bit annoying that clang now
suggests doing things that won't build in other compilers. Any ideas what
to do about this?

On Fri, Jan 13, 2017 at 10:01 AM, Malcolm Parsons via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: malcolm.parsons
> Date: Fri Jan 13 09:01:06 2017
> New Revision: 291905
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291905=rev
> Log:
> [Sema] Add warning for unused lambda captures
>
> Summary:
> Warn when a lambda explicitly captures something that is not used in its
> body.
>
> The warning is part of -Wunused and can be enabled with
> -Wunused-lambda-capture.
>
> Reviewers: rsmith, arphaman, jbcoe, aaron.ballman
>
> Subscribers: Quuxplusone, arphaman, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D28467
>
> Added:
> cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Sema/ScopeInfo.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaExprCXX.cpp
> cfe/trunk/lib/Sema/SemaLambda.cpp
> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp
> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp
> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp
> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp
> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp
> cfe/trunk/test/SemaCXX/uninitialized.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/DiagnosticGroups.td?rev=291905=291904=291905=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jan 13 09:01:06
> 2017
> @@ -480,6 +480,7 @@ def UnusedFunction : DiagGroup<"unused-f
>  def UnusedMemberFunction : DiagGroup<"unused-member-function",
>   [UnneededMemberFunction]>;
>  def UnusedLabel : DiagGroup<"unused-label">;
> +def UnusedLambdaCapture : DiagGroup<"unused-lambda-capture">;
>  def UnusedParameter : DiagGroup<"unused-parameter">;
>  def UnusedResult : DiagGroup<"unused-result">;
>  def PotentiallyEvaluatedExpression : DiagGroup<"potentially-
> evaluated-expression">;
> @@ -617,8 +618,9 @@ def Unused : DiagGroup<"unused",
> [UnusedArgument, UnusedFunction, UnusedLabel,
>  // UnusedParameter, (matches GCC's behavior)
>  // UnusedMemberFunction, (clean-up llvm before
> enabling)
> -UnusedPrivateField, UnusedLocalTypedef,
> -UnusedValue, UnusedVariable, UnusedPropertyIvar]>,
> +UnusedPrivateField, UnusedLambdaCapture,
> +UnusedLocalTypedef, UnusedValue, UnusedVariable,
> +UnusedPropertyIvar]>,
>  DiagCategory<"Unused Entity Issue">;
>
>  // Format settings.
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticSemaKinds.td?rev=291905=291904=291905=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jan 13
> 09:01:06 2017
> @@ -316,6 +316,9 @@ def warn_unneeded_member_function : Warn
>InGroup, DefaultIgnore;
>  def warn_unused_private_field: Warning<"private field %0 is not used">,
>InGroup, DefaultIgnore;
> +def warn_unused_lambda_capture: Warning<"lambda capture %0 is not "
> +  "%select{used|required to be captured for use in an unevaluated
> context}1">,
> +  InGroup, DefaultIgnore;
>
>  def warn_parameter_size: Warning<
>"%0 is a large (%1 bytes) pass-by-value argument; "
>
> Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Sema/ScopeInfo.h?rev=291905=291904=291905=diff
> 
> ==
> --- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
> +++ cfe/trunk/include/clang/Sema/ScopeInfo.h Fri Jan 13 09:01:06 2017
> @@ -452,6 +452,14 @@ public:
>  /// non-static data member that would hold the capture.
>  QualType CaptureType;
>
> +/// \brief 

Re: r292590 - [OPENMP] Fix for PR31643: Clang crashes when compiling code on Windows

2017-01-20 Thread Alexey Bataev via cfe-commits
Yes, the crash may happen only on CodeGenFunction destruction

Best regards,
Alexey Bataev

21 ???. 2017 ?., ? 0:04, Reid Kleckner 
> ???(?):

Thanks! Does this match the logic for starting a function in OpenMP?

Also, the test shouldn't have REQUIRES: x86-registered-target.

On Fri, Jan 20, 2017 at 12:57 AM, Alexey Bataev via cfe-commits 
> wrote:
Author: abataev
Date: Fri Jan 20 02:57:28 2017
New Revision: 292590

URL: http://llvm.org/viewvc/llvm-project?rev=292590=rev
Log:
[OPENMP] Fix for PR31643: Clang crashes when compiling code on Windows
with SEH and openmp

In some cituations (during codegen for Windows SEH constructs)
CodeGenFunction instance may have CurFn equal to nullptr. OpenMP related
code does not expect such situation during cleanup.

Added:
cfe/trunk/test/OpenMP/openmp_seh.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=292590=292589=292590=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Jan 20 02:57:28 2017
@@ -112,9 +112,8 @@ CodeGenFunction::~CodeGenFunction() {
   if (FirstBlockInfo)
 destroyBlockInfos(FirstBlockInfo);

-  if (getLangOpts().OpenMP) {
+  if (getLangOpts().OpenMP && CurFn)
 CGM.getOpenMPRuntime().functionFinished(*this);
-  }
 }

 CharUnits CodeGenFunction::getNaturalPointeeTypeAlignment(QualType T,

Added: cfe/trunk/test/OpenMP/openmp_seh.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/openmp_seh.c?rev=292590=auto
==
--- cfe/trunk/test/OpenMP/openmp_seh.c (added)
+++ cfe/trunk/test/OpenMP/openmp_seh.c Fri Jan 20 02:57:28 2017
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -verify -triple x86_64-pc-windows-msvc19.0.0 -fopenmp 
-fms-compatibility -x c++ -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+// REQUIRES: x86-registered-target
+extern "C" {
+void __cpuid(int[4], int);
+}
+
+// CHECK-LABEL: @main
+int main(void) {
+  __try {
+int info[4];
+__cpuid(info, 1);
+  } __except (1) {
+  }
+
+  return 0;
+}
+


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r292590 - [OPENMP] Fix for PR31643: Clang crashes when compiling code on Windows

2017-01-20 Thread Reid Kleckner via cfe-commits
Thanks! Does this match the logic for starting a function in OpenMP?

Also, the test shouldn't have REQUIRES: x86-registered-target.

On Fri, Jan 20, 2017 at 12:57 AM, Alexey Bataev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: abataev
> Date: Fri Jan 20 02:57:28 2017
> New Revision: 292590
>
> URL: http://llvm.org/viewvc/llvm-project?rev=292590=rev
> Log:
> [OPENMP] Fix for PR31643: Clang crashes when compiling code on Windows
> with SEH and openmp
>
> In some cituations (during codegen for Windows SEH constructs)
> CodeGenFunction instance may have CurFn equal to nullptr. OpenMP related
> code does not expect such situation during cleanup.
>
> Added:
> cfe/trunk/test/OpenMP/openmp_seh.c
> Modified:
> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CodeGenFunction.cpp?rev=292590=292589=292590=diff
> 
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Jan 20 02:57:28 2017
> @@ -112,9 +112,8 @@ CodeGenFunction::~CodeGenFunction() {
>if (FirstBlockInfo)
>  destroyBlockInfos(FirstBlockInfo);
>
> -  if (getLangOpts().OpenMP) {
> +  if (getLangOpts().OpenMP && CurFn)
>  CGM.getOpenMPRuntime().functionFinished(*this);
> -  }
>  }
>
>  CharUnits CodeGenFunction::getNaturalPointeeTypeAlignment(QualType T,
>
> Added: cfe/trunk/test/OpenMP/openmp_seh.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/
> openmp_seh.c?rev=292590=auto
> 
> ==
> --- cfe/trunk/test/OpenMP/openmp_seh.c (added)
> +++ cfe/trunk/test/OpenMP/openmp_seh.c Fri Jan 20 02:57:28 2017
> @@ -0,0 +1,18 @@
> +// RUN: %clang_cc1 -verify -triple x86_64-pc-windows-msvc19.0.0 -fopenmp
> -fms-compatibility -x c++ -emit-llvm %s -o - | FileCheck %s
> +// expected-no-diagnostics
> +// REQUIRES: x86-registered-target
> +extern "C" {
> +void __cpuid(int[4], int);
> +}
> +
> +// CHECK-LABEL: @main
> +int main(void) {
> +  __try {
> +int info[4];
> +__cpuid(info, 1);
> +  } __except (1) {
> +  }
> +
> +  return 0;
> +}
> +
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r292522 - Don't inline dllimport functions referencing non-imported methods

2017-01-20 Thread Reid Kleckner via cfe-commits
The first Chrome DLL build with this change is crashing during compilation:
https://build.chromium.org/p/chromium.fyi/builders/ClangToTWin64%28dll%29/builds/8380/

The previous build fails with a link error, so the revision range for the
new crash is 292501 - 292526.

Only the DLL builders are affected, so I think it's very likely that this
is the culprit. I speculatively reverted it in r292643.

On Thu, Jan 19, 2017 at 1:33 PM, Hans Wennborg via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: hans
> Date: Thu Jan 19 15:33:13 2017
> New Revision: 292522
>
> URL: http://llvm.org/viewvc/llvm-project?rev=292522=rev
> Log:
> Don't inline dllimport functions referencing non-imported methods
>
> This is another follow-up to r246338. I had assumed methods were already
> handled by the AST visitor, but turns out they weren't.
>
> Modified:
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> cfe/trunk/test/CodeGenCXX/dllimport.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CodeGenModule.cpp?rev=292522=292521=292522=diff
> 
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Jan 19 15:33:13 2017
> @@ -1751,6 +1751,11 @@ namespace {
>SafeToInline = E->getConstructor()->hasAttr();
>return SafeToInline;
>  }
> +bool VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
> +  CXXMethodDecl *M = E->getMethodDecl();
> +  SafeToInline = M->hasAttr();
> +  return SafeToInline;
> +}
>  bool VisitCXXDeleteExpr(CXXDeleteExpr *E) {
>SafeToInline = E->getOperatorDelete()->hasAttr();
>return SafeToInline;
>
> Modified: cfe/trunk/test/CodeGenCXX/dllimport.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> CodeGenCXX/dllimport.cpp?rev=292522=292521=292522=diff
> 
> ==
> --- cfe/trunk/test/CodeGenCXX/dllimport.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/dllimport.cpp Thu Jan 19 15:33:13 2017
> @@ -26,6 +26,7 @@ struct ExplicitSpec_NotImported {};
>  #define USEVARTYPE(type, var) type UNIQ(use)() { return var; }
>  #define USEVAR(var) USEVARTYPE(int, var)
>  #define USE(func) void UNIQ(use)() { func(); }
> +#define USE1(func) void UNIQ(use)() { func(nullptr); }
>  #define USEMEMFUNC(class, func) void (class::*UNIQ(use)())() { return
> ::func; }
>  #define USESTATICMEMFUNC(class, func) void (*UNIQ(use)())() { return
> ::func; }
>  #define USECLASS(class) void UNIQ(USE)() { class x; }
> @@ -316,10 +317,13 @@ namespace ns { __declspec(dllimport) voi
>  USE(ns::externalFunc)
>
>  // A dllimport function referencing non-imported vars or functions must
> not be available_externally.
> +
>  __declspec(dllimport) int ImportedVar;
>  int NonImportedVar;
>  __declspec(dllimport) int ImportedFunc();
>  int NonImportedFunc();
> +struct ClassWithNonImportedMethod { int f(); };
> +
>  __declspec(dllimport) inline int ReferencingImportedVar() { return
> ImportedVar; }
>  // MO1-DAG: define available_externally dllimport i32
> @"\01?ReferencingImportedVar@@YAHXZ"
>  __declspec(dllimport) inline int ReferencingNonImportedVar() { return
> NonImportedVar; }
> @@ -328,10 +332,13 @@ __declspec(dllimport) inline int Referen
>  // MO1-DAG: define available_externally dllimport i32
> @"\01?ReferencingImportedFunc@@YAHXZ"
>  __declspec(dllimport) inline int ReferencingNonImportedFunc() { return
> NonImportedFunc(); }
>  // MO1-DAG: declare dllimport i32 @"\01?ReferencingNonImportedFunc@@
> YAHXZ"()
> +__declspec(dllimport) inline int 
> ReferencingNonImportedMethod(ClassWithNonImportedMethod
> *x) { return x->f(); }
> +// MO1-DAG: declare dllimport i32 @"\01?ReferencingNonImportedMethod
>  USE(ReferencingImportedVar)
>  USE(ReferencingNonImportedVar)
>  USE(ReferencingImportedFunc)
>  USE(ReferencingNonImportedFunc)
> +USE1(ReferencingNonImportedMethod)
>  // References to operator new and delete count too, despite not being
> DeclRefExprs.
>  __declspec(dllimport) inline int *ReferencingNonImportedNew() { return
> new int[2]; }
>  // MO1-DAG: declare dllimport i32* @"\01?ReferencingNonImportedNew@@
> YAPAHXZ"
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r292643 - Revert "Don't inline dllimport functions referencing non-imported methods"

2017-01-20 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Jan 20 14:44:50 2017
New Revision: 292643

URL: http://llvm.org/viewvc/llvm-project?rev=292643=rev
Log:
Revert "Don't inline dllimport functions referencing non-imported methods"

This reverts commit r292522. It appears to be causing crashes in builds
using dllimport.

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCXX/dllimport.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=292643=292642=292643=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Jan 20 14:44:50 2017
@@ -1751,11 +1751,6 @@ namespace {
   SafeToInline = E->getConstructor()->hasAttr();
   return SafeToInline;
 }
-bool VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
-  CXXMethodDecl *M = E->getMethodDecl();
-  SafeToInline = M->hasAttr();
-  return SafeToInline;
-}
 bool VisitCXXDeleteExpr(CXXDeleteExpr *E) {
   SafeToInline = E->getOperatorDelete()->hasAttr();
   return SafeToInline;

Modified: cfe/trunk/test/CodeGenCXX/dllimport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllimport.cpp?rev=292643=292642=292643=diff
==
--- cfe/trunk/test/CodeGenCXX/dllimport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllimport.cpp Fri Jan 20 14:44:50 2017
@@ -26,7 +26,6 @@ struct ExplicitSpec_NotImported {};
 #define USEVARTYPE(type, var) type UNIQ(use)() { return var; }
 #define USEVAR(var) USEVARTYPE(int, var)
 #define USE(func) void UNIQ(use)() { func(); }
-#define USE1(func) void UNIQ(use)() { func(nullptr); }
 #define USEMEMFUNC(class, func) void (class::*UNIQ(use)())() { return 
::func; }
 #define USESTATICMEMFUNC(class, func) void (*UNIQ(use)())() { return 
::func; }
 #define USECLASS(class) void UNIQ(USE)() { class x; }
@@ -317,13 +316,10 @@ namespace ns { __declspec(dllimport) voi
 USE(ns::externalFunc)
 
 // A dllimport function referencing non-imported vars or functions must not be 
available_externally.
-
 __declspec(dllimport) int ImportedVar;
 int NonImportedVar;
 __declspec(dllimport) int ImportedFunc();
 int NonImportedFunc();
-struct ClassWithNonImportedMethod { int f(); };
-
 __declspec(dllimport) inline int ReferencingImportedVar() { return 
ImportedVar; }
 // MO1-DAG: define available_externally dllimport i32 
@"\01?ReferencingImportedVar@@YAHXZ"
 __declspec(dllimport) inline int ReferencingNonImportedVar() { return 
NonImportedVar; }
@@ -332,13 +328,10 @@ __declspec(dllimport) inline int Referen
 // MO1-DAG: define available_externally dllimport i32 
@"\01?ReferencingImportedFunc@@YAHXZ"
 __declspec(dllimport) inline int ReferencingNonImportedFunc() { return 
NonImportedFunc(); }
 // MO1-DAG: declare dllimport i32 @"\01?ReferencingNonImportedFunc@@YAHXZ"()
-__declspec(dllimport) inline int 
ReferencingNonImportedMethod(ClassWithNonImportedMethod *x) { return x->f(); }
-// MO1-DAG: declare dllimport i32 @"\01?ReferencingNonImportedMethod
 USE(ReferencingImportedVar)
 USE(ReferencingNonImportedVar)
 USE(ReferencingImportedFunc)
 USE(ReferencingNonImportedFunc)
-USE1(ReferencingNonImportedMethod)
 // References to operator new and delete count too, despite not being 
DeclRefExprs.
 __declspec(dllimport) inline int *ReferencingNonImportedNew() { return new 
int[2]; }
 // MO1-DAG: declare dllimport i32* @"\01?ReferencingNonImportedNew@@YAPAHXZ"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28478: Check for musl-libc's max_align_t in addition to other variants.

2017-01-20 Thread David L. Jones via Phabricator via cfe-commits
dlj added a comment.

Ping?


https://reviews.llvm.org/D28478



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28477: Add LF_ prefix to LibFunc enums in TargetLibraryInfo.

2017-01-20 Thread David L. Jones via Phabricator via cfe-commits
dlj added a comment.

Ping?


https://reviews.llvm.org/D28477



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28007: Switch TableGen to emit calls to ASTRecordReader for AttrPCHRead.

2017-01-20 Thread David L. Jones via Phabricator via cfe-commits
dlj added a comment.

Ping?


https://reviews.llvm.org/D28007



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r292639 - Revert r292508 given that we intend to remove driver options for cxx modules.

2017-01-20 Thread Manman Ren via cfe-commits
Author: mren
Date: Fri Jan 20 14:03:00 2017
New Revision: 292639

URL: http://llvm.org/viewvc/llvm-project?rev=292639=rev
Log:
Revert r292508 given that we intend to remove driver options for cxx modules.

Removed:
cfe/trunk/test/Modules/check-syntax.mm
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseObjc.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=292639=292638=292639=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Jan 20 14:03:00 
2017
@@ -243,10 +243,7 @@ def err_expected_property_name : Error<"
 
 def err_unexpected_at : Error<"unexpected '@' in program">;
 def err_atimport : Error<
-  "use of '@import' when modules are disabled">;
-def err_atimport_cxx : Error<
-  "use of '@import' when C++ modules are disabled, consider using fmodules "
-  "and fcxx-modules">;
+"use of '@import' when modules are disabled">;
 
 def err_invalid_reference_qualifier_application : Error<
   "'%0' qualifier may not be applied to a reference">;

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=292639=292638=292639=diff
==
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Fri Jan 20 14:03:00 2017
@@ -83,10 +83,7 @@ Parser::DeclGroupPtrTy Parser::ParseObjC
   case tok::objc_import:
 if (getLangOpts().Modules || getLangOpts().DebuggerSupport)
   return ParseModuleImport(AtLoc);
-if (getLangOpts().CPlusPlus)
-  Diag(AtLoc, diag::err_atimport_cxx);
-else
-  Diag(AtLoc, diag::err_atimport);
+Diag(AtLoc, diag::err_atimport);
 SkipUntil(tok::semi);
 return Actions.ConvertDeclToDeclGroup(nullptr);
   default:

Removed: cfe/trunk/test/Modules/check-syntax.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/check-syntax.mm?rev=292638=auto
==
--- cfe/trunk/test/Modules/check-syntax.mm (original)
+++ cfe/trunk/test/Modules/check-syntax.mm (removed)
@@ -1,5 +0,0 @@
-// RUN: not %clang -fmodules -fno-cxx-modules -fsyntax-only %s 2>&1 | 
FileCheck %s
-// rdar://19399671
-
-// CHECK: use of '@import' when C++ modules are disabled
-@import Foundation;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28938: Implement P0513R0 - "Poisoning the Hash"

2017-01-20 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 85172.
EricWF added a comment.

- Fix bitset test that was overflowing the stack.
- Add tests that basic_string_view hashes to the same value as an equivalent 
basic_string.


https://reviews.llvm.org/D28938

Files:
  include/__functional_base
  include/functional
  include/memory
  include/new
  include/optional
  include/utility
  include/variant
  test/libcxx/test/config.py
  test/std/containers/sequences/vector.bool/enabled_hash.pass.cpp
  test/std/diagnostics/syserr/syserr.hash/enabled_hash.pass.cpp
  test/std/strings/basic.string.hash/enabled_hashes.pass.cpp
  test/std/strings/string.view/string.view.hash/enabled_hashes.pass.cpp
  test/std/strings/string.view/string.view.hash/string_view.pass.cpp
  
test/std/thread/thread.threads/thread.thread.class/thread.thread.id/enabled_hashes.pass.cpp
  
test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp
  test/std/utilities/function.objects/unord.hash/enabled_hashes.pass.cpp
  
test/std/utilities/memory/util.smartptr/util.smartptr.hash/enabled_hash.pass.cpp
  
test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp
  
test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
  test/std/utilities/optional/optional.hash/enabled_hash.pass.cpp
  test/std/utilities/optional/optional.hash/hash.pass.cpp
  test/std/utilities/template.bitset/bitset.hash/enabled_hash.pass.cpp
  test/std/utilities/type.index/type.index.hash/enabled_hash.pass.cpp
  test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp
  test/std/utilities/variant/variant.hash/enabled_hash.pass.cpp
  test/std/utilities/variant/variant.hash/hash.pass.cpp
  test/support/deleter_types.h
  test/support/min_allocator.h
  test/support/poisoned_hash_helper.hpp
  test/support/test.support/test_poisoned_hash_helper.pass.cpp
  www/cxx1z_status.html

Index: www/cxx1z_status.html
===
--- www/cxx1z_status.html
+++ www/cxx1z_status.html
@@ -136,7 +136,7 @@
 	http://wg21.link/P0508R0;>P0508R0LWGWording for GB 58 - structured bindings for node_handlesIssaquah
 	http://wg21.link/P0509R1;>P0509R1LWGUpdating “Restrictions on exception handling”IssaquahNothing to don/a
 	http://wg21.link/P0510R0;>P0510R0LWGDisallowing references, incomplete types, arrays, and empty variantsIssaquahComplete4.0
-	http://wg21.link/P0513R0;>P0513R0LWGPoisoning the HashIssaquah
+	http://wg21.link/P0513R0;>P0513R0LWGPoisoning the HashIssaquahComplete5.0
 	http://wg21.link/P0516R0;>P0516R0LWGClarify That shared_future’s Copy Operations have Wide ContractsIssaquahComplete4.0
 	http://wg21.link/P0517R0;>P0517R0LWGMake future_error ConstructibleIssaquahComplete4.0
 	http://wg21.link/P0521R0;>P0521R0LWGProposed Resolution for CA 14 (shared_ptr use_count/unique)IssaquahNothing to don/a
Index: test/support/test.support/test_poisoned_hash_helper.pass.cpp
===
--- /dev/null
+++ test/support/test.support/test_poisoned_hash_helper.pass.cpp
@@ -0,0 +1,30 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// Test that the header `poisoned_hash_helper.hpp` doesn't include any
+// headers that provide hash specializations. This is required so that the
+// 'test_library_hash_specializations_available()' function returns false
+// by default, unless a STL header providing hash has already been included.
+
+#include "poisoned_hash_helper.hpp"
+
+template 
+constexpr bool is_complete_imp(int) { return true; }
+template  constexpr bool is_complete_imp(long) { return false; }
+template  constexpr bool is_complete() { return is_complete_imp(0); }
+
+template  struct has_complete_hash {
+  enum { value = is_complete() };
+};
+
+int main() {
+  static_assert(LibraryHashTypes::assertTrait(), "");
+}
Index: test/support/poisoned_hash_helper.hpp
===
--- /dev/null
+++ test/support/poisoned_hash_helper.hpp
@@ -0,0 +1,244 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+#ifndef SUPPORT_POISONED_HASH_HELPER_HPP
+#define SUPPORT_POISONED_HASH_HELPER_HPP
+
+#include 
+#include 
+
+#include "test_macros.h"
+
+#if TEST_STD_VER < 11
+#error 

[PATCH] D28931: Disable aligned new/delete on Apple platforms without posix_memalign

2017-01-20 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

@rsmith I looked for an alternative provider for aligned allocation but 
couldn't find one, which is quite unfortunate. Is this going to mess up the 
`__libcpp_version` detection Clang does?


https://reviews.llvm.org/D28931



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxxabi] r292638 - Fix catch_reference_nullptr.pass.cpp test for GCC.

2017-01-20 Thread Eric Fiselier via cfe-commits
This patch fixes a libc++abi test failure when compiled with GCC 5, 6, or 7.
We should merge this into 4.0 to help get `check-all` clean.

/Eric

On Fri, Jan 20, 2017 at 12:34 PM, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Fri Jan 20 13:34:19 2017
> New Revision: 292638
>
> URL: http://llvm.org/viewvc/llvm-project?rev=292638=rev
> Log:
> Fix catch_reference_nullptr.pass.cpp test for GCC.
>
> This test contained an implicit conversion from nullptr to bool.
> Clang warns about this but the test had supressed that warning.
> However GCC diagnoses the same code as an error and requires
> -fpermissive to accept it.
>
> This patch fixes both the warning and the error by explicitly
> converting the pointer to bool.
>
> Modified:
> libcxxabi/trunk/test/catch_reference_nullptr.pass.cpp
>
> Modified: libcxxabi/trunk/test/catch_reference_nullptr.pass.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/
> catch_reference_nullptr.pass.cpp?rev=292638=292637=292638=diff
> 
> ==
> --- libcxxabi/trunk/test/catch_reference_nullptr.pass.cpp (original)
> +++ libcxxabi/trunk/test/catch_reference_nullptr.pass.cpp Fri Jan 20
> 13:34:19 2017
> @@ -12,12 +12,6 @@
>  #include 
>  #include 
>
> -// Clang emits a warning on converting an object of type nullptr_t to
> bool,
> -// even in generic code. Suppress it.
> -#if defined(__clang__)
> -#pragma clang diagnostic ignored "-Wnull-conversion"
> -#endif
> -
>  struct A {};
>
>  template
> @@ -25,7 +19,7 @@ static void catch_nullptr_test() {
>try {
>  throw nullptr;
>} catch (T ) {
> -assert(CanCatchNullptr && !p);
> +assert(CanCatchNullptr && !static_cast(p));
>} catch (...) {
>  assert(!CanCatchNullptr);
>}
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r292638 - Fix catch_reference_nullptr.pass.cpp test for GCC.

2017-01-20 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan 20 13:34:19 2017
New Revision: 292638

URL: http://llvm.org/viewvc/llvm-project?rev=292638=rev
Log:
Fix catch_reference_nullptr.pass.cpp test for GCC.

This test contained an implicit conversion from nullptr to bool.
Clang warns about this but the test had supressed that warning.
However GCC diagnoses the same code as an error and requires
-fpermissive to accept it.

This patch fixes both the warning and the error by explicitly
converting the pointer to bool.

Modified:
libcxxabi/trunk/test/catch_reference_nullptr.pass.cpp

Modified: libcxxabi/trunk/test/catch_reference_nullptr.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/catch_reference_nullptr.pass.cpp?rev=292638=292637=292638=diff
==
--- libcxxabi/trunk/test/catch_reference_nullptr.pass.cpp (original)
+++ libcxxabi/trunk/test/catch_reference_nullptr.pass.cpp Fri Jan 20 13:34:19 
2017
@@ -12,12 +12,6 @@
 #include 
 #include 
 
-// Clang emits a warning on converting an object of type nullptr_t to bool,
-// even in generic code. Suppress it.
-#if defined(__clang__)
-#pragma clang diagnostic ignored "-Wnull-conversion"
-#endif
-
 struct A {};
 
 template
@@ -25,7 +19,7 @@ static void catch_nullptr_test() {
   try {
 throw nullptr;
   } catch (T ) {
-assert(CanCatchNullptr && !p);
+assert(CanCatchNullptr && !static_cast(p));
   } catch (...) {
 assert(!CanCatchNullptr);
   }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r292637 - [docs] Regenerate DiagnosticsReference.rst. We don't have automatic generation of this set up server-side yet.

2017-01-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jan 20 13:27:09 2017
New Revision: 292637

URL: http://llvm.org/viewvc/llvm-project?rev=292637=rev
Log:
[docs] Regenerate DiagnosticsReference.rst. We don't have automatic generation 
of this set up server-side yet.

Modified:
cfe/trunk/docs/DiagnosticsReference.rst

Modified: cfe/trunk/docs/DiagnosticsReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/DiagnosticsReference.rst?rev=292637=292636=292637=diff
==
--- cfe/trunk/docs/DiagnosticsReference.rst (original)
+++ cfe/trunk/docs/DiagnosticsReference.rst Fri Jan 20 13:27:09 2017
@@ -251,6 +251,28 @@ Some of the diagnostics controlled by th
 Controls `-Wmost`_, `-Wparentheses`_, `-Wswitch`_, `-Wswitch-bool`_.
 
 
+-Walloca-with-align-alignof
+---
+This diagnostic is enabled by default.
+
+**Diagnostic text:**
+
+++
+|:warning:`warning:` |nbsp| :diagtext:`second argument to 
\_\_builtin\_alloca\_with\_align is supposed to be in bits`|
+++
+
+
+-Wambiguous-delete
+--
+This diagnostic is enabled by default.
+
+**Diagnostic text:**
+
++--+
+|:warning:`warning:` |nbsp| :diagtext:`multiple suitable` |nbsp| 
:placeholder:`A` |nbsp| :diagtext:`functions for` |nbsp| 
:placeholder:`B`:diagtext:`; no 'operator delete' function will be invoked if 
initialization throws an exception`|
++--+
+
+
 -Wambiguous-ellipsis
 
 This diagnostic is enabled by default.
@@ -482,7 +504,24 @@ This diagnostic is enabled by default.
 
 -Wasm
 -
-Synonym for `-Wasm-operand-widths`_.
+This diagnostic is enabled by default.
+
+Controls `-Wasm-ignored-qualifier`_, `-Wasm-operand-widths`_.
+
+
+-Wasm-ignored-qualifier
+---
+This diagnostic is enabled by default.
+
+**Diagnostic text:**
+
++--+
+|:warning:`warning:` |nbsp| :diagtext:`ignored` |nbsp| :placeholder:`A` |nbsp| 
:diagtext:`qualifier on asm`|
++--+
+
++-+
+|:warning:`warning:` |nbsp| :diagtext:`meaningless 'volatile' on asm outside 
function`|
++-+
 
 
 -Wasm-operand-widths
@@ -697,21 +736,6 @@ This diagnostic is enabled by default.
 
+---+
 
 
--Wbad-array-new-length
---
-This diagnostic is enabled by default.
-
-**Diagnostic text:**
-
-++
-|:warning:`warning:` |nbsp| :diagtext:`array is too large (`:placeholder:`A` 
|nbsp| :diagtext:`elements)`|
-++
-
-+-+
-|:warning:`warning:` |nbsp| :diagtext:`array size is negative`|
-+-+
-
-
 -Wbad-function-cast
 ---
 **Diagnostic text:**
@@ -768,9 +792,9 @@ This diagnostic is enabled by default.
 
 **Diagnostic text:**
 
-+---+
-|:warning:`warning:` |nbsp| :diagtext:`implicit truncation from` |nbsp| 
:placeholder:`C` |nbsp| :diagtext:`to bitfield changes value from` |nbsp| 
:placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B`|
-+---+
+++
+|:warning:`warning:` |nbsp| :diagtext:`implicit 

Re: [libcxx] r292607 - Don't default older GCC's to C++17, but C++14 or C++11 instead

2017-01-20 Thread Eric Fiselier via cfe-commits
We should merge this patch into the 4.0 release branch. It is needed to
make "check-all" pass when using GCC 4, 5 and 6.

/Eric

On Fri, Jan 20, 2017 at 5:54 AM, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Fri Jan 20 06:54:45 2017
> New Revision: 292607
>
> URL: http://llvm.org/viewvc/llvm-project?rev=292607=rev
> Log:
> Don't default older GCC's to C++17, but C++14 or C++11 instead
>
> Modified:
> libcxx/trunk/test/libcxx/test/config.py
>
> Modified: libcxx/trunk/test/libcxx/test/config.py
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/
> libcxx/test/config.py?rev=292607=292606=292607=diff
> 
> ==
> --- libcxx/trunk/test/libcxx/test/config.py (original)
> +++ libcxx/trunk/test/libcxx/test/config.py Fri Jan 20 06:54:45 2017
> @@ -423,6 +423,15 @@ class Configuration(object):
>  if not std:
>  # Choose the newest possible language dialect if none is
> given.
>  possible_stds = ['c++1z', 'c++14', 'c++11', 'c++03']
> +if self.cxx.type == 'gcc':
> +maj_v, _, _ = self.cxx.version
> +maj_v = int(maj_v)
> +if maj_v < 7:
> +possible_stds.remove('c++1z')
> +# FIXME: How many C++14 tests actually fail under GCC 5
> and 6?
> +# Should we XFAIL them individually instead?
> +if maj_v <= 6:
> +possible_stds.remove('c++14')
>  for s in possible_stds:
>  if self.cxx.hasCompileFlag('-std=%s' % s):
>  std = s
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r292636 - AMDGPU: Add builtin for getreg intrinsic

2017-01-20 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Fri Jan 20 13:24:22 2017
New Revision: 292636

URL: http://llvm.org/viewvc/llvm-project?rev=292636=rev
Log:
AMDGPU: Add builtin for getreg intrinsic

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=292636=292635=292636=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Fri Jan 20 13:24:22 2017
@@ -35,6 +35,7 @@ BUILTIN(__builtin_amdgcn_workitem_id_z,
 
//===--===//
 // Instruction builtins.
 
//===--===//
+BUILTIN(__builtin_amdgcn_s_getreg, "UiIi", "n")
 BUILTIN(__builtin_amdgcn_s_barrier, "v", "n")
 BUILTIN(__builtin_amdgcn_wave_barrier, "v", "n")
 BUILTIN(__builtin_amdgcn_div_scale, "dddbb*", "n")

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=292636=292635=292636=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Fri Jan 20 13:24:22 2017
@@ -371,6 +371,17 @@ void test_get_group_id(int d, global int
}
 }
 
+// CHECK-LABEL: @test_s_getreg(
+// CHECK: tail call i32 @llvm.amdgcn.s.getreg(i32 0)
+// CHECK: tail call i32 @llvm.amdgcn.s.getreg(i32 1)
+// CHECK: tail call i32 @llvm.amdgcn.s.getreg(i32 65535)
+void test_s_getreg(volatile global uint *out)
+{
+  *out = __builtin_amdgcn_s_getreg(0);
+  *out = __builtin_amdgcn_s_getreg(1);
+  *out = __builtin_amdgcn_s_getreg(65535);
+}
+
 // CHECK-LABEL: @test_get_local_id(
 // CHECK: tail call i32 @llvm.amdgcn.workitem.id.x(), !range 
[[WI_RANGE:![0-9]*]]
 // CHECK: tail call i32 @llvm.amdgcn.workitem.id.y(), !range [[WI_RANGE]]

Modified: cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl?rev=292636=292635=292636=diff
==
--- cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl (original)
+++ cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl Fri Jan 20 13:24:22 2017
@@ -62,3 +62,8 @@ void test_ds_swizzle(global int* out, in
 {
   *out = __builtin_amdgcn_ds_swizzle(a, b); // expected-error {{argument to 
'__builtin_amdgcn_ds_swizzle' must be a constant integer}}
 }
+
+void test_s_getreg(global int* out, int a)
+{
+  *out = __builtin_amdgcn_s_getreg(a); // expected-error {{argument to 
'__builtin_amdgcn_s_getreg' must be a constant integer}}
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: r292568 - [test] Remove an unwanted match for `UNSUPPORTED:`.

2017-01-20 Thread Robinson, Paul via cfe-commits
I'd call this a bug in lit; it shouldn't be matching partial tokens.
--paulr

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of
> Greg Parker via cfe-commits
> Sent: Thursday, January 19, 2017 6:12 PM
> To: cfe-commits@lists.llvm.org
> Subject: r292568 - [test] Remove an unwanted match for `UNSUPPORTED:`.
> 
> Author: gparker
> Date: Thu Jan 19 20:12:22 2017
> New Revision: 292568
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=292568=rev
> Log:
> [test] Remove an unwanted match for `UNSUPPORTED:`.
> 
> Modified:
> cfe/trunk/test/Driver/embed-bitcode.c
> 
> Modified: cfe/trunk/test/Driver/embed-bitcode.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/embed-
> bitcode.c?rev=292568=292567=292568=diff
> ==
> 
> --- cfe/trunk/test/Driver/embed-bitcode.c (original)
> +++ cfe/trunk/test/Driver/embed-bitcode.c Thu Jan 19 20:12:22 2017
> @@ -51,5 +51,5 @@
>  // CHECK-NO-LINKER-NOT: -bitcode_bundle
> 
>  // RUN: %clang -target armv7-apple-darwin -miphoneos-version-min=5.0 %s -
> fembed-bitcode -### 2>&1 | \
> -// RUN:   FileCheck %s -check-prefix=CHECK-PLATFORM-UNSUPPORTED
> -// CHECK-PLATFORM-UNSUPPORTED: -fembed-bitcode is not supported on
> versions of iOS prior to 6.0
> +// RUN:   FileCheck %s -check-prefix=CHECK-PLATFORM-NOTSUPPORTED
> +// CHECK-PLATFORM-NOTSUPPORTED: -fembed-bitcode is not supported on
> versions of iOS prior to 6.0
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r292635 - [Sema] Remove dead typedef

2017-01-20 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Jan 20 13:04:01 2017
New Revision: 292635

URL: http://llvm.org/viewvc/llvm-project?rev=292635=rev
Log:
[Sema] Remove dead typedef

Modified:
cfe/trunk/include/clang/Sema/Sema.h

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=292635=292634=292635=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Jan 20 13:04:01 2017
@@ -3207,7 +3207,6 @@ public:
  bool IsProtocolMethodDecl);
 
   typedef llvm::SmallPtrSet SelectorSet;
-  typedef llvm::DenseMap ProtocolsMethodsMap;
 
   /// CheckImplementationIvars - This routine checks if the instance variables
   /// listed in the implelementation match those listed in the interface.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28832: Improve redefinition errors pointing to the same header.

2017-01-20 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Thanks Vassil.

@rsmith is this ok for you?


https://reviews.llvm.org/D28832



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r292632 - Fix actually-reachable llvm_unreachable.

2017-01-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jan 20 12:50:12 2017
New Revision: 292632

URL: http://llvm.org/viewvc/llvm-project?rev=292632=rev
Log:
Fix actually-reachable llvm_unreachable.

Modified:
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle.cpp

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=292632=292631=292632=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Fri Jan 20 12:50:12 2017
@@ -3043,6 +3043,7 @@ void CXXNameMangler::mangleType(const De
   //   ::= Te  # dependent elaborated type specifier 
using
   // # 'enum'
   switch (T->getKeyword()) {
+case ETK_None:
 case ETK_Typename:
   break;
 case ETK_Struct:
@@ -3056,8 +3057,6 @@ void CXXNameMangler::mangleType(const De
 case ETK_Enum:
   Out << "Te";
   break;
-default:
-  llvm_unreachable("unexpected keyword for dependent type name");
   }
   // Typename types are always nested
   Out << 'N';

Modified: cfe/trunk/test/CodeGenCXX/mangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle.cpp?rev=292632=292631=292632=diff
==
--- cfe/trunk/test/CodeGenCXX/mangle.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle.cpp Fri Jan 20 12:50:12 2017
@@ -1125,3 +1125,14 @@ namespace test57 {
   // CHECK-LABEL: @_ZN6test571fILi0EEEvDTplcldtL_ZNS_1xEE1fIXLi0T_E
   template void f<0>(int);
 }
+
+namespace test58 {
+  struct State {
+   bool m_fn1();
+  } a;
+  template  struct identity_ { typedef T type; };
+  struct A {
+   template  A(T, bool (identity_::type::*)());
+  };
+  void fn1() { A(a, ::m_fn1); }
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28946: [analyzer] Fix memory space for block-captured static locals.

2017-01-20 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

LGTM!

It would be good to get this into the clang 4.0 svn branch, too. I think Hans 
Wennborg is managing this. See 
http://clang-developers.42468.n3.nabble.com/4-0-0-Release-The-branch-is-here-the-release-process-starts-td4054864.html.


https://reviews.llvm.org/D28946



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r292508 - Module: Improve diagnostic message when cxx modules are disabled and @import is used in Objective CXX.

2017-01-20 Thread Richard Smith via cfe-commits
On 20 Jan 2017 9:49 am, "Manman Ren"  wrote:



On Thu, Jan 19, 2017 at 1:27 PM, Richard Smith 
wrote:

> On 19 Jan 2017 11:16 am, "Manman Ren via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: mren
> Date: Thu Jan 19 13:05:55 2017
> New Revision: 292508
>
> URL: http://llvm.org/viewvc/llvm-project?rev=292508=rev
> Log:
> Module: Improve diagnostic message when cxx modules are disabled and
> @import is used in Objective CXX.
>
> rdar://problem/19399671
>
> Added:
> cfe/trunk/test/Modules/check-syntax.mm
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
> cfe/trunk/lib/Parse/ParseObjc.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
> Basic/DiagnosticParseKinds.td?rev=292508=292507=292508=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Thu Jan 19
> 13:05:55 2017
> @@ -243,7 +243,10 @@ def err_expected_property_name : Error<"
>
>  def err_unexpected_at : Error<"unexpected '@' in program">;
>  def err_atimport : Error<
> -"use of '@import' when modules are disabled">;
> +  "use of '@import' when modules are disabled">;
> +def err_atimport_cxx : Error<
> +  "use of '@import' when C++ modules are disabled, consider using
> fmodules "
> +  "and fcxx-modules">;
>
>
> Please add a hyphen before fmodules. There's also no reason to suggest
> -fcxx-modules; modules support for C++ is controlled by -fmodules nowadays.
>
> I also don't think it makes sense to have different diagnostics for C and
> C++ mode; we should suggest the -fmodules flag in either case.
>

Hi Richard,

This is an internal patch that I am upstreaming to open source. Internally
at Apple, modules support for C++ is off by default, users need to use
-fcxx-modules to turn it on. So when they use -fmodules without
-fcxx-modules, they will get a confusing error saying modules are disabled.

Open source, the testing case in this commit uses driver option
-fno-cxx-modules, in this case, it makes sense to call out c++ modules so
users know to remove -fno-cxx-modules.


I think it's time to remove -fno-cxx-modules entirely from upstream. If we
don't, I don't think it makes any sense to mention that flag unless the
user actually specified it.

Let me know your thoughts,
Manman


>
>  def err_invalid_reference_qualifier_application : Error<
>"'%0' qualifier may not be applied to a reference">;
>
> Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Pars
> eObjc.cpp?rev=292508=292507=292508=diff
> 
> ==
> --- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu Jan 19 13:05:55 2017
> @@ -83,7 +83,10 @@ Parser::DeclGroupPtrTy Parser::ParseObjC
>case tok::objc_import:
>  if (getLangOpts().Modules || getLangOpts().DebuggerSupport)
>return ParseModuleImport(AtLoc);
> -Diag(AtLoc, diag::err_atimport);
> +if (getLangOpts().CPlusPlus)
> +  Diag(AtLoc, diag::err_atimport_cxx);
> +else
> +  Diag(AtLoc, diag::err_atimport);
>  SkipUntil(tok::semi);
>  return Actions.ConvertDeclToDeclGroup(nullptr);
>default:
>
> Added: cfe/trunk/test/Modules/check-syntax.mm
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/c
> heck-syntax.mm?rev=292508=auto
> 
> ==
> --- cfe/trunk/test/Modules/check-syntax.mm (added)
> +++ cfe/trunk/test/Modules/check-syntax.mm Thu Jan 19 13:05:55 2017
> @@ -0,0 +1,5 @@
> +// RUN: not %clang -fmodules -fno-cxx-modules -fsyntax-only %s 2>&1 |
> FileCheck %s
> +// rdar://19399671
> +
> +// CHECK: use of '@import' when C++ modules are disabled
> +@import Foundation;
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28933: Revert the return type for `emplace_(back|front)` to `void` in C++14 and before

2017-01-20 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

I hate that we have to conditionalize this change at all, but your changes LGTM.


https://reviews.llvm.org/D28933



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28080: [Docs][OpenCL] Added OpenCL feature description to user manual.

2017-01-20 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

@pekka.jaaskelainen, I just compiled the release 4.0 branch and it all works 
for me as expected:
clang -cc1 -triple spir64-unknown-unknown test.cl
clang  -target spir64-unknown-unknown test.cl


https://reviews.llvm.org/D28080



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28514: [CodeCompletion] Reset the hidden declaration obtained after lookup when caching UsingShadowDecls

2017-01-20 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

If they are equal, the loop can continue because a UsingDecl doesn't hide a 
UsingShadowDecl that is tied to it.


Repository:
  rL LLVM

https://reviews.llvm.org/D28514



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28514: [CodeCompletion] Reset the hidden declaration obtained after lookup when caching UsingShadowDecls

2017-01-20 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In the example I showed, wouldn't the DeclContext for all the UsingDecls and 
UsingShadowDecls be the FunctionDecl for foo1? Maybe you can check whether 
UsingShadowDecl::getUsingDecl() (which returns the UsingDecl which is tied to 
the UsingShadowDecl) is equal to the UsingDecl instead?


Repository:
  rL LLVM

https://reviews.llvm.org/D28514



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28835: [coroutines] NFC: Refactor Sema::CoroutineBodyStmt construction.

2017-01-20 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov added a comment.

@rsmith, Looking good?


https://reviews.llvm.org/D28835



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28793: [NVPTX] Auto-upgrade some NVPTX intrinsics to LLVM target-generic code.

2017-01-20 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Now that we've removed ton of @llvm.nvvm intrinsics from .td files, we have no 
easy way to tell that we still do support these intrinsics (mostly for the sake 
of libdevice?) by upgrading them.
Perhaps we should add the list of such intrinsics and what happens to them in a 
comment section in NVPTXIntrinsics.td.




Comment at: llvm/include/llvm/IR/IntrinsicsNVVM.td:207
-
-  def int_nvvm_brev32 : GCCBuiltin<"__nvvm_brev32">,
-  Intrinsic<[llvm_i32_ty], [llvm_i32_ty], [IntrNoMem]>;

There are still remnants of __nvvm_{brev,abs,clz,...} in 
include/clang/Basic/BuiltinsNVPTX.def
Now that llvm does not provide them, they should be removed from clang as well, 
IMO. 


https://reviews.llvm.org/D28793



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r292508 - Module: Improve diagnostic message when cxx modules are disabled and @import is used in Objective CXX.

2017-01-20 Thread Manman Ren via cfe-commits
On Thu, Jan 19, 2017 at 1:27 PM, Richard Smith 
wrote:

> On 19 Jan 2017 11:16 am, "Manman Ren via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: mren
> Date: Thu Jan 19 13:05:55 2017
> New Revision: 292508
>
> URL: http://llvm.org/viewvc/llvm-project?rev=292508=rev
> Log:
> Module: Improve diagnostic message when cxx modules are disabled and
> @import is used in Objective CXX.
>
> rdar://problem/19399671
>
> Added:
> cfe/trunk/test/Modules/check-syntax.mm
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
> cfe/trunk/lib/Parse/ParseObjc.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
> Basic/DiagnosticParseKinds.td?rev=292508=292507=292508=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Thu Jan 19
> 13:05:55 2017
> @@ -243,7 +243,10 @@ def err_expected_property_name : Error<"
>
>  def err_unexpected_at : Error<"unexpected '@' in program">;
>  def err_atimport : Error<
> -"use of '@import' when modules are disabled">;
> +  "use of '@import' when modules are disabled">;
> +def err_atimport_cxx : Error<
> +  "use of '@import' when C++ modules are disabled, consider using
> fmodules "
> +  "and fcxx-modules">;
>
>
> Please add a hyphen before fmodules. There's also no reason to suggest
> -fcxx-modules; modules support for C++ is controlled by -fmodules nowadays.
>
> I also don't think it makes sense to have different diagnostics for C and
> C++ mode; we should suggest the -fmodules flag in either case.
>

Hi Richard,

This is an internal patch that I am upstreaming to open source. Internally
at Apple, modules support for C++ is off by default, users need to use
-fcxx-modules to turn it on. So when they use -fmodules without
-fcxx-modules, they will get a confusing error saying modules are disabled.

Open source, the testing case in this commit uses driver option
-fno-cxx-modules, in this case, it makes sense to call out c++ modules so
users know to remove -fno-cxx-modules.

Let me know your thoughts,
Manman


>
>  def err_invalid_reference_qualifier_application : Error<
>"'%0' qualifier may not be applied to a reference">;
>
> Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Pars
> eObjc.cpp?rev=292508=292507=292508=diff
> 
> ==
> --- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu Jan 19 13:05:55 2017
> @@ -83,7 +83,10 @@ Parser::DeclGroupPtrTy Parser::ParseObjC
>case tok::objc_import:
>  if (getLangOpts().Modules || getLangOpts().DebuggerSupport)
>return ParseModuleImport(AtLoc);
> -Diag(AtLoc, diag::err_atimport);
> +if (getLangOpts().CPlusPlus)
> +  Diag(AtLoc, diag::err_atimport_cxx);
> +else
> +  Diag(AtLoc, diag::err_atimport);
>  SkipUntil(tok::semi);
>  return Actions.ConvertDeclToDeclGroup(nullptr);
>default:
>
> Added: cfe/trunk/test/Modules/check-syntax.mm
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/
> check-syntax.mm?rev=292508=auto
> 
> ==
> --- cfe/trunk/test/Modules/check-syntax.mm (added)
> +++ cfe/trunk/test/Modules/check-syntax.mm Thu Jan 19 13:05:55 2017
> @@ -0,0 +1,5 @@
> +// RUN: not %clang -fmodules -fno-cxx-modules -fsyntax-only %s 2>&1 |
> FileCheck %s
> +// rdar://19399671
> +
> +// CHECK: use of '@import' when C++ modules are disabled
> +@import Foundation;
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28299: Module: use PCMCache to manage memory buffers for pcm files.

2017-01-20 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir accepted this revision.
benlangmuir added a comment.
This revision is now accepted and ready to land.

Sorry for the delay, I though you were still iterating with @aprantl for some 
reason.  LGTM


https://reviews.llvm.org/D28299



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28514: [CodeCompletion] Reset the hidden declaration obtained after lookup when caching UsingShadowDecls

2017-01-20 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 85151.
arphaman added a comment.

Ensure that the UsingShadowDecl and UsingDecl are in the same DeclContext.


Repository:
  rL LLVM

https://reviews.llvm.org/D28514

Files:
  lib/Sema/SemaLookup.cpp
  test/Index/complete-cached-globals.cpp


Index: test/Index/complete-cached-globals.cpp
===
--- /dev/null
+++ test/Index/complete-cached-globals.cpp
@@ -0,0 +1,25 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+namespace SomeNamespace {
+class SomeClass {
+};
+void SomeFunction();
+}
+
+using SomeNamespace::SomeClass;
+using SomeNamespace::SomeFunction;
+
+static void foo() {
+  return;
+}
+
+// rdar://23454249
+
+// RUN: c-index-test -code-completion-at=%s:14:3 %s | FileCheck 
-check-prefix=CHECK-CC1 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test 
-code-completion-at=%s:14:3 %s | FileCheck -check-prefix=CHECK-CC1 %s
+
+// CHECK-CC1: ClassDecl:{TypedText SomeClass} (50)
+// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText SomeFunction}{LeftParen 
(}{RightParen )} (50)
+// CHECK-CC1-NOT: {Text SomeNamespace::}{TypedText SomeClass}
+// CHECK-CC1-NOT: {Text SomeNamespace::}{TypedText SomeFunction}
Index: lib/Sema/SemaLookup.cpp
===
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -3428,6 +3428,12 @@
   SM == ShadowMaps.rbegin())
 continue;
 
+  // A shadow declaration that's created by a resolved using declaration
+  // is not hidden by the using declaration in the same scope.
+  if (isa(ND) && isa(D) &&
+  D->getDeclContext() == ND->getDeclContext())
+continue;
+
   // We've found a declaration that hides this one.
   return D;
 }


Index: test/Index/complete-cached-globals.cpp
===
--- /dev/null
+++ test/Index/complete-cached-globals.cpp
@@ -0,0 +1,25 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+namespace SomeNamespace {
+class SomeClass {
+};
+void SomeFunction();
+}
+
+using SomeNamespace::SomeClass;
+using SomeNamespace::SomeFunction;
+
+static void foo() {
+  return;
+}
+
+// rdar://23454249
+
+// RUN: c-index-test -code-completion-at=%s:14:3 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:14:3 %s | FileCheck -check-prefix=CHECK-CC1 %s
+
+// CHECK-CC1: ClassDecl:{TypedText SomeClass} (50)
+// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText SomeFunction}{LeftParen (}{RightParen )} (50)
+// CHECK-CC1-NOT: {Text SomeNamespace::}{TypedText SomeClass}
+// CHECK-CC1-NOT: {Text SomeNamespace::}{TypedText SomeFunction}
Index: lib/Sema/SemaLookup.cpp
===
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -3428,6 +3428,12 @@
   SM == ShadowMaps.rbegin())
 continue;
 
+  // A shadow declaration that's created by a resolved using declaration
+  // is not hidden by the using declaration in the same scope.
+  if (isa(ND) && isa(D) &&
+  D->getDeclContext() == ND->getDeclContext())
+continue;
+
   // We've found a declaration that hides this one.
   return D;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28514: [CodeCompletion] Reset the hidden declaration obtained after lookup when caching UsingShadowDecls

2017-01-20 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D28514#651675, @ahatanak wrote:

> This is not invalid:
>
>   namespace Foo {
>   class C { };
>   }
>   namespace Bar { class C { }; }
>  
>   void foo1() {
>   using Foo::C;
>   {
>   using Bar::C;
>   }
>   }
>


I see, that could happen if the previous UsingShadow is in an outer scope. Yes, 
I guess then Foo::C using decl should hide Bar::C using shadow decl. I'll post 
the patch which checks that the two decls have the same decl context (should be 
faster than checking if a using shadow decl is contained in a using decl).


Repository:
  rL LLVM

https://reviews.llvm.org/D28514



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28514: [CodeCompletion] Reset the hidden declaration obtained after lookup when caching UsingShadowDecls

2017-01-20 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

This is not invalid:

  namespace Foo {
  class C { };
  }
  namespace Bar { class C { }; }
  
  void foo1() {
  using Foo::C;
  {
  using Bar::C;
  }
  }


Repository:
  rL LLVM

https://reviews.llvm.org/D28514



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28514: [CodeCompletion] Reset the hidden declaration obtained after lookup when caching UsingShadowDecls

2017-01-20 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

I had something like the following code in mind  (which is not invalid). Does 
usingdecl Bar::C hide Foo::C ?

  namespace Foo {
  class C { };
  }
  namespace Bar { class C { }; }
  
  using Foo::C;
  {
  using Bar::C;
  }




Repository:
  rL LLVM

https://reviews.llvm.org/D28514



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28514: [CodeCompletion] Reset the hidden declaration obtained after lookup when caching UsingShadowDecls

2017-01-20 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Sema/SemaLookup.cpp:3433
+  // is not hidden by the using declaration.
+  if (isa(ND) && isa(D))
+continue;

ahatanak wrote:
> Do we have to check that ND's UsingDecl is equal to D? Or we don't have to 
> worry about it?
I don't think a check like that would be necessary from what I've observed so 
far. I believe a `UsingShadowDecl` could have been hidden previously by a 
different `UsingDecl`, but that can happen only in invalid code, like in the 
example below:

```
namespace Foo {
class C { };
}
namespace Bar { class C { }; }
using Foo::C;
using Bar::C;
```

I don't think it would make sense for Bar::C using decl to hide Foo::C using 
shadow decl.


Repository:
  rL LLVM

https://reviews.llvm.org/D28514



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28771: [Analyzer] Various fixes for the IteratorPastEnd checker

2017-01-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Thanks for the update, most welcome!




Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:234
+if (Call.getNumArgs() >= 1) {
+  const auto  = static_cast(Call);
+  handleRandomIncrOrDecr(C, Func->getOverloadedOperator(),

We usually write these as
```
const auto *InstCall = cast();
```
Mostly because our custom `cast<>` has an assertion inside.



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:514
+CheckerContext , OverloadedOperatorKind Op, const SVal ,
+const SVal , const SVal , QualType RValType,
+bool PreCheck) const {

I'd suggest renaming the parameters to "LHS" and "RHS" or something like that, 
so that not to confuse those with "lvalue" and "rvalue".



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:530
+  auto value = RVal;
+  if (auto loc = value.getAs()) {
+value = State->getRawSVal(*loc);

Is there a test case for this hack?

I'd also consider inspecting the AST (probably before passing the values to 
`handleRandomIncrOrDecr()`) and making the decision based on that. Because even 
though this pattern ("if a value is a loc and we expect a nonloc, do an extra 
dereference") is present in many places in the analyzer, in most of these 
places it doesn't work correctly (what if we try to discriminate between `int*` 
and `int*&`?).



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:553
+
+  // When increasing by positive or decreasing by negative an iterator past its
+  // end, then it is a bug. We check for bugs before the operator call.

I think incrementing `end()` by `0` is not a bug (?)


https://reviews.llvm.org/D28771



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28349: [Frontend] The macro that describes the Objective-C bool type should be defined in C as well

2017-01-20 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292617: [Frontend] The macro that describes the Objective-C 
bool type should (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D28349?vs=83354=85143#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28349

Files:
  cfe/trunk/lib/Frontend/InitPreprocessor.cpp
  cfe/trunk/test/Frontend/objc-bool-is-bool.m
  cfe/trunk/test/Preprocessor/init.c


Index: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
===
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp
@@ -593,9 +593,6 @@
 Builder.defineMacro("OBJC_ZEROCOST_EXCEPTIONS");
 }
 
-Builder.defineMacro("__OBJC_BOOL_IS_BOOL",
-Twine(TI.useSignedCharForObjCBool() ? "0" : "1"));
-
 if (LangOpts.getGC() != LangOptions::NonGC)
   Builder.defineMacro("__OBJC_GC__");
 
@@ -626,6 +623,11 @@
 Builder.defineMacro("IB_DESIGNABLE", "");
   }
 
+  // Define a macro that describes the Objective-C boolean type even for C
+  // and C++ since BOOL can be used from non Objective-C code.
+  Builder.defineMacro("__OBJC_BOOL_IS_BOOL",
+  Twine(TI.useSignedCharForObjCBool() ? "0" : "1"));
+
   if (LangOpts.CPlusPlus)
 InitializeCPlusPlusFeatureTestMacros(LangOpts, Builder);
 
Index: cfe/trunk/test/Frontend/objc-bool-is-bool.m
===
--- cfe/trunk/test/Frontend/objc-bool-is-bool.m
+++ cfe/trunk/test/Frontend/objc-bool-is-bool.m
@@ -1,13 +1,13 @@
 // RUN: %clang_cc1 -fsyntax-only -E -dM -triple=armv7k-apple-watchos %s | 
FileCheck --check-prefix=BOOL %s
 // RUN: %clang_cc1 -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 %s | 
FileCheck --check-prefix=CHAR %s
-// RUN: %clang_cc1 -x c -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 %s 
| FileCheck --check-prefix=NONE %s
+// RUN: %clang_cc1 -x c -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 %s 
| FileCheck --check-prefix=CHAR %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -E -dM 
-triple=x86_64-apple-darwin16 %s | FileCheck --check-prefix=CHAR %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 
%s | FileCheck --check-prefix=CHAR %s
 
 // rdar://21170440
 
 // BOOL: #define __OBJC_BOOL_IS_BOOL 1
 // BOOL-NOT: #define __OBJC_BOOL_IS_BOOL 0
 
 // CHAR: #define __OBJC_BOOL_IS_BOOL 0
 // CHAR-NOT: #define __OBJC_BOOL_IS_BOOL 1
-
-// NONE-NOT: __OBJC_BOOL_IS_BOOL
Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -8705,6 +8705,7 @@
 // WEBASSEMBLY32-NEXT:#define __LONG_MAX__ 2147483647L
 // WEBASSEMBLY32-NOT:#define __LP64__
 // WEBASSEMBLY32-NEXT:#define __NO_INLINE__ 1
+// WEBASSEMBLY32-NEXT:#define __OBJC_BOOL_IS_BOOL 0
 // WEBASSEMBLY32-NEXT:#define __ORDER_BIG_ENDIAN__ 4321
 // WEBASSEMBLY32-NEXT:#define __ORDER_LITTLE_ENDIAN__ 1234
 // WEBASSEMBLY32-NEXT:#define __ORDER_PDP_ENDIAN__ 3412
@@ -9020,6 +9021,7 @@
 // WEBASSEMBLY64-NEXT:#define __LONG_MAX__ 9223372036854775807L
 // WEBASSEMBLY64-NEXT:#define __LP64__ 1
 // WEBASSEMBLY64-NEXT:#define __NO_INLINE__ 1
+// WEBASSEMBLY64-NEXT:#define __OBJC_BOOL_IS_BOOL 0
 // WEBASSEMBLY64-NEXT:#define __ORDER_BIG_ENDIAN__ 4321
 // WEBASSEMBLY64-NEXT:#define __ORDER_LITTLE_ENDIAN__ 1234
 // WEBASSEMBLY64-NEXT:#define __ORDER_PDP_ENDIAN__ 3412


Index: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
===
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp
@@ -593,9 +593,6 @@
 Builder.defineMacro("OBJC_ZEROCOST_EXCEPTIONS");
 }
 
-Builder.defineMacro("__OBJC_BOOL_IS_BOOL",
-Twine(TI.useSignedCharForObjCBool() ? "0" : "1"));
-
 if (LangOpts.getGC() != LangOptions::NonGC)
   Builder.defineMacro("__OBJC_GC__");
 
@@ -626,6 +623,11 @@
 Builder.defineMacro("IB_DESIGNABLE", "");
   }
 
+  // Define a macro that describes the Objective-C boolean type even for C
+  // and C++ since BOOL can be used from non Objective-C code.
+  Builder.defineMacro("__OBJC_BOOL_IS_BOOL",
+  Twine(TI.useSignedCharForObjCBool() ? "0" : "1"));
+
   if (LangOpts.CPlusPlus)
 InitializeCPlusPlusFeatureTestMacros(LangOpts, Builder);
 
Index: cfe/trunk/test/Frontend/objc-bool-is-bool.m
===
--- cfe/trunk/test/Frontend/objc-bool-is-bool.m
+++ cfe/trunk/test/Frontend/objc-bool-is-bool.m
@@ -1,13 +1,13 @@
 // RUN: %clang_cc1 -fsyntax-only -E -dM -triple=armv7k-apple-watchos %s | FileCheck --check-prefix=BOOL %s
 // RUN: %clang_cc1 -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 %s | FileCheck --check-prefix=CHAR %s
-// RUN: %clang_cc1 -x c -fsyntax-only 

r292617 - [Frontend] The macro that describes the Objective-C bool type should

2017-01-20 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Jan 20 10:48:25 2017
New Revision: 292617

URL: http://llvm.org/viewvc/llvm-project?rev=292617=rev
Log:
[Frontend] The macro that describes the Objective-C bool type should
be defined for non Objective-C code as well

rdar://29794915

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

Modified:
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Frontend/objc-bool-is-bool.m
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=292617=292616=292617=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Fri Jan 20 10:48:25 2017
@@ -593,9 +593,6 @@ static void InitializePredefinedMacros(c
 Builder.defineMacro("OBJC_ZEROCOST_EXCEPTIONS");
 }
 
-Builder.defineMacro("__OBJC_BOOL_IS_BOOL",
-Twine(TI.useSignedCharForObjCBool() ? "0" : "1"));
-
 if (LangOpts.getGC() != LangOptions::NonGC)
   Builder.defineMacro("__OBJC_GC__");
 
@@ -626,6 +623,11 @@ static void InitializePredefinedMacros(c
 Builder.defineMacro("IB_DESIGNABLE", "");
   }
 
+  // Define a macro that describes the Objective-C boolean type even for C
+  // and C++ since BOOL can be used from non Objective-C code.
+  Builder.defineMacro("__OBJC_BOOL_IS_BOOL",
+  Twine(TI.useSignedCharForObjCBool() ? "0" : "1"));
+
   if (LangOpts.CPlusPlus)
 InitializeCPlusPlusFeatureTestMacros(LangOpts, Builder);
 

Modified: cfe/trunk/test/Frontend/objc-bool-is-bool.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/objc-bool-is-bool.m?rev=292617=292616=292617=diff
==
--- cfe/trunk/test/Frontend/objc-bool-is-bool.m (original)
+++ cfe/trunk/test/Frontend/objc-bool-is-bool.m Fri Jan 20 10:48:25 2017
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -fsyntax-only -E -dM -triple=armv7k-apple-watchos %s | 
FileCheck --check-prefix=BOOL %s
 // RUN: %clang_cc1 -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 %s | 
FileCheck --check-prefix=CHAR %s
-// RUN: %clang_cc1 -x c -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 %s 
| FileCheck --check-prefix=NONE %s
+// RUN: %clang_cc1 -x c -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 %s 
| FileCheck --check-prefix=CHAR %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -E -dM 
-triple=x86_64-apple-darwin16 %s | FileCheck --check-prefix=CHAR %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 
%s | FileCheck --check-prefix=CHAR %s
 
 // rdar://21170440
 
@@ -9,5 +11,3 @@
 
 // CHAR: #define __OBJC_BOOL_IS_BOOL 0
 // CHAR-NOT: #define __OBJC_BOOL_IS_BOOL 1
-
-// NONE-NOT: __OBJC_BOOL_IS_BOOL

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=292617=292616=292617=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Fri Jan 20 10:48:25 2017
@@ -8705,6 +8705,7 @@
 // WEBASSEMBLY32-NEXT:#define __LONG_MAX__ 2147483647L
 // WEBASSEMBLY32-NOT:#define __LP64__
 // WEBASSEMBLY32-NEXT:#define __NO_INLINE__ 1
+// WEBASSEMBLY32-NEXT:#define __OBJC_BOOL_IS_BOOL 0
 // WEBASSEMBLY32-NEXT:#define __ORDER_BIG_ENDIAN__ 4321
 // WEBASSEMBLY32-NEXT:#define __ORDER_LITTLE_ENDIAN__ 1234
 // WEBASSEMBLY32-NEXT:#define __ORDER_PDP_ENDIAN__ 3412
@@ -9020,6 +9021,7 @@
 // WEBASSEMBLY64-NEXT:#define __LONG_MAX__ 9223372036854775807L
 // WEBASSEMBLY64-NEXT:#define __LP64__ 1
 // WEBASSEMBLY64-NEXT:#define __NO_INLINE__ 1
+// WEBASSEMBLY64-NEXT:#define __OBJC_BOOL_IS_BOOL 0
 // WEBASSEMBLY64-NEXT:#define __ORDER_BIG_ENDIAN__ 4321
 // WEBASSEMBLY64-NEXT:#define __ORDER_LITTLE_ENDIAN__ 1234
 // WEBASSEMBLY64-NEXT:#define __ORDER_PDP_ENDIAN__ 3412


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28954: [analyzer] Add support for symbolic float expressions

2017-01-20 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added a comment.

- This patch introduces a virtual overloaded `llvm::APFloat getSymVal()` for 
returning the value of known floating-point constants. In the long term, both 
`getSymVal()` functions should probably be refactored to return something like 
a `llvm::Con
- There are also long-term issues with the flexibility of the `SymExpr` class. 
Currently, this patch adds two `SymFloatExpr` and `FloatSymExpr` subclasses, 
but this isn't expressive enough for certain types of symbolic queries. For 
example, the current implementation checks whether a floating-point value is 
`NaN` by comparing whether `V == V`, which should only be false for `NaN`. It 
would be better to add support for special queries for whether a value is NaN, 
positive infinity, negative infinity, etc.


https://reviews.llvm.org/D28954



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28952: [analyzer] Add new Z3 constraint manager backend

2017-01-20 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added a comment.

This is a fairly large patch, but the core of it is the actual implementation 
of the Z3 constraint solver backend. In its current form, the backend is 
implemented as a Clang plugin,  but I also have a git commit that has it inside 
the static analyzer. The non-plugin approach makes testing easier, by avoiding 
the introduction of new `%z3` and %z3_cc1` variables in `lit.cfg` and modifying 
all the testcases to load in the Z3 constraint manager plugin.

1. The testcase `Analysis/unsupported-types.c` currently fails, because when 
using the constraint manager as a Clang plugin, somehow a copy of 
`llvm::APFloat` is getting compiled into the shared library. Thus, comparisons 
of `()` against `::APFloat::x87DoubleExtended()` or 
`::APFloat::PPCDoubleDouble()` are always failing, which causes a 
subsequent assertion error. When testing the non-plugin implementation, it 
works fine.
2. The testcase `Analysis/reference.cpp` currently fails, because the 
`RangeConstraintManager` has an internal optimization that assumes references 
are known to be non-zero (see RangeConstraintManager.cpp:422). This 
optimization is probably in the wrong place, and should be moved into the 
analyzer and out of the constraint solver.
3. The testcase `Analysis/ptr-arith.c` currently fails, because handling of 
`ptrdiff_t` is somewhat tricky. This constraint manager interface maps 
`ptrdiff_t` to a signed bitvector in Z3, and pointers to unsigned bitvectors in 
Z3. However, since this testcase compares the pointer values both directly and 
indirectly via `ptrdiff_t`, if `a < b` is true using a signed comparison, the 
same is not necessarily true using an unsigned comparison.
4. Because of the divergence in capabilities between this and the existing 
constraint manager, the follow-up child patches that add support for additional 
features will probably cause problems for the existing constraint manager. I 
haven't fully tested that, but there is an issue of how to update the testsuite 
results without duplicating most of the existing testcases for each constraint 
manager backend.
5. Since this constraint manager uses Z3, the plugin links against the Z3 
shared library. I believe this should be fine since Z3 is under a MIT license, 
but I'm not really familiar with any licensing issues.
6. This plugin requires Z3 4.5.0 or later. I'm not sure if this is available in 
any distribution package repositories, so it may be necessary to build from 
source.


https://reviews.llvm.org/D28952



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D28943: [clang-format] Remove redundant test in style-on-command-line.cpp

2017-01-20 Thread Antonio Maiorano via cfe-commits
On Fri, 20 Jan 2017 at 11:26 Eric Liu via Phabricator <
revi...@reviews.llvm.org> wrote:

ioeric added a comment.

In https://reviews.llvm.org/D28943#651536, @amaiorano wrote:

> In https://reviews.llvm.org/D28943#651489, @ioeric wrote:
>
> > In https://reviews.llvm.org/D28943#651488, @amaiorano wrote:
> >
> > > In https://reviews.llvm.org/D28943#651470, @ioeric wrote:
> > >
> > > > @amaiorano: The test itself is correct. It's just that this test
failed in our internal test. We could've fixed it internally, but the fix
would be ugly. Since the intended behavior is already covered in the case
above it, and it's really just checking the default fallback style is LLVM,
which is not related to the original change, I think it makes sense to get
rid of the case. Hope you don't mind :)
> > >
> > >
> > > Of course I don't mind :) Why did it fail your internal tests, btw?
Just curious. Was it something I could've detected myself?
> >
> >
> > Probably not... it's just that our default fallback style is "Google"
instead of "LLVM".
>
>
> (I replied the following by email, but I'm not sure where it went...
posting it here instead)
>
> You mean you build a modified version of clang-format where Style is
initialized to getGoogleStyle()?
>
> I had wondered whether adding a "defaultStyle" argument might be useful,
specifically in the case where you want to pass in yaml that simply tweaks
the default style, but I figured it's not much harder to pass in
"BasedOnStyle" in the yaml.


No.. we set both default style and default fallback style (tool options) to
"google" in our build.


How do you do that? I'm trying to understand how running that specific test
failed for you guys. What I'm getting is that my test would not explicitly
set fallback-style and assume it would use LLVM, but you're saying on your
end, there's a way to set the fallback-style otherwise (you wrote "tools
options", but I'm not sure what that means). Sorry for being pedantic :)


I don't see why "defaultStyle" would be useful. I think having the existing
"style" and "fallback-style" options is sufficient (and already a bit
confusing).


I agree completely.




Repository:
  rL LLVM

https://reviews.llvm.org/D28943
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28943: [clang-format] Remove redundant test in style-on-command-line.cpp

2017-01-20 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

In https://reviews.llvm.org/D28943#651536, @amaiorano wrote:

> In https://reviews.llvm.org/D28943#651489, @ioeric wrote:
>
> > In https://reviews.llvm.org/D28943#651488, @amaiorano wrote:
> >
> > > In https://reviews.llvm.org/D28943#651470, @ioeric wrote:
> > >
> > > > @amaiorano: The test itself is correct. It's just that this test failed 
> > > > in our internal test. We could've fixed it internally, but the fix 
> > > > would be ugly. Since the intended behavior is already covered in the 
> > > > case above it, and it's really just checking the default fallback style 
> > > > is LLVM, which is not related to the original change, I think it makes 
> > > > sense to get rid of the case. Hope you don't mind :)
> > >
> > >
> > > Of course I don't mind :) Why did it fail your internal tests, btw? Just 
> > > curious. Was it something I could've detected myself?
> >
> >
> > Probably not... it's just that our default fallback style is "Google" 
> > instead of "LLVM".
>
>
> (I replied the following by email, but I'm not sure where it went... posting 
> it here instead)
>
> You mean you build a modified version of clang-format where Style is 
> initialized to getGoogleStyle()?
>
> I had wondered whether adding a "defaultStyle" argument might be useful, 
> specifically in the case where you want to pass in yaml that simply tweaks 
> the default style, but I figured it's not much harder to pass in 
> "BasedOnStyle" in the yaml.


No.. we set both default style and default fallback style (tool options) to 
"google" in our build.

I don't see why "defaultStyle" would be useful. I think having the existing 
"style" and "fallback-style" options is sufficient (and already a bit 
confusing).


Repository:
  rL LLVM

https://reviews.llvm.org/D28943



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r292562 - clang-format: fix fallback style set to "none" not always formatting

2017-01-20 Thread Antonio Maiorano via cfe-commits
Hello Mikael,

Did you try again with the removal of the redundant test (D28943)?


On Fri, 20 Jan 2017 at 08:34 Mikael Holmén 
wrote:

> Hi,
>
> On 01/20/2017 02:20 PM, Antonio Maiorano wrote:
> > Hi Mikael,
> >
> > Just to be sure, did you build clang-format before running this test?
>
> Yes I did. I compiled a clean trunk, ran the test, got the failure.
>
> >
> > Possibly related, one of the tests I added was just removed for being
> > redundant:
> > https://reviews.llvm.org/D28943
>
> Aha. I can't say I understand what's going on there, I don't even know
> how to change the default fallback style or what it is :)
>
> Regards,
>
> Mikael
>
> >
> >
> > On Fri, Jan 20, 2017 at 7:50 AM Mikael Holmén
> > > wrote:
> >
> > Hi Antonio,
> >
> >
> >
> > The test case
> >
> >
> >
> > Clang :: Format/style-on-command-line.cpp
> >
> >
> >
> > fails for me since this commit.
> >
> >
> >
> > test/Format/style-on-command-line.cpp:40:13: error: expected string
> not
> >
> > found in input
> >
> > // CHECK10: {{^int\* i;$}}
> >
> >  ^
> >
> > :1:1: note: scanning from here
> >
> > // RUN: clang-format -style="{BasedOnStyle: Google, IndentWidth: 8}"
> > %s |
> >
> > ^
> >
> > :61:16: note: possible intended match here
> >
> >// CHECK10: {{^int\* i;$}}
> >
> > ^
> >
> >
> >
> > I suppose it works for you... Any idea what the problem can be?
> >
> >
> >
> > Regards,
> >
> > Mikael
> >
> >
> > On 01/20/2017 02:22 AM, Antonio Maiorano via cfe-commits wrote:
> >
> > > Author: amaiorano
> >
> > > Date: Thu Jan 19 19:22:42 2017
> >
> > > New Revision: 292562
> >
> > >
> >
> > > URL: http://llvm.org/viewvc/llvm-project?rev=292562=rev
> >
> > > Log:
> >
> > > clang-format: fix fallback style set to "none" not always
> formatting
> >
> > >
> >
> > > This fixes clang-format not formatting if fallback-style is
> > explicitly set to
> >
> > > "none", and either a config file is found or YAML is passed in
> > without a
> >
> > > "BasedOnStyle". With this change, passing "none" in these cases
> > will have no
> >
> > > affect, and LLVM style will be used as the base style.
> >
> > >
> >
> > > Differential Revision: https://reviews.llvm.org/D28844
> >
> > >
> >
> > > Modified:
> >
> > > cfe/trunk/lib/Format/Format.cpp
> >
> > > cfe/trunk/test/Format/style-on-command-line.cpp
> >
> > > cfe/trunk/unittests/Format/FormatTest.cpp
> >
> > >
> >
> > > Modified: cfe/trunk/lib/Format/Format.cpp
> >
> > > URL:
> >
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=292562=292561=292562=diff
> >
> > >
> >
>  
> ==
> >
> > > --- cfe/trunk/lib/Format/Format.cpp (original)
> >
> > > +++ cfe/trunk/lib/Format/Format.cpp Thu Jan 19 19:22:42 2017
> >
> > > @@ -1888,8 +1888,8 @@ static FormatStyle::LanguageKind getLang
> >
> > >  }
> >
> > >
> >
> > >  llvm::Expected getStyle(StringRef StyleName,
> > StringRef FileName,
> >
> > > - StringRef FallbackStyle,
> > StringRef Code,
> >
> > > - vfs::FileSystem *FS) {
> >
> > > + StringRef FallbackStyleName,
> >
> > > + StringRef Code,
> > vfs::FileSystem *FS) {
> >
> > >if (!FS) {
> >
> > >  FS = vfs::getRealFileSystem().get();
> >
> > >}
> >
> > > @@ -1903,9 +1903,9 @@ llvm::Expected getStyle(Str
> >
> > >(Code.contains("\n- (") || Code.contains("\n+ (")))
> >
> > >  Style.Language = FormatStyle::LK_ObjC;
> >
> > >
> >
> > > -  // FIXME: If FallbackStyle is explicitly "none", format is
> > disabled.
> >
> > > -  if (!getPredefinedStyle(FallbackStyle, Style.Language, ))
> >
> > > -return make_string_error("Invalid fallback style \"" +
> > FallbackStyle.str());
> >
> > > +  FormatStyle FallbackStyle = getNoStyle();
> >
> > > +  if (!getPredefinedStyle(FallbackStyleName, Style.Language,
> > ))
> >
> > > +return make_string_error("Invalid fallback style \"" +
> > FallbackStyleName);
> >
> > >
> >
> > >if (StyleName.startswith("{")) {
> >
> > >  // Parse YAML/JSON style from the command line.
> >
> > > @@ -1977,7 +1977,7 @@ llvm::Expected getStyle(Str
> >
> > >  return make_string_error("Configuration file(s) do(es) not
> > support " +
> >
> > >   getLanguageName(Style.Language) + ":
> " +
> >
> > >   UnsuitableConfigFiles);
> >
> > > -  return Style;
> >
> > > +  return FallbackStyle;
> >
> > >  }
> 

[PATCH] D28955: [analyzer] Enable support for symbolic extension/truncation

2017-01-20 Thread Dominic Chen via Phabricator via cfe-commits
ddcc created this revision.

With the Z3 constraint manager, symbolic extension and truncation of variables 
can be fully reasoned about.


https://reviews.llvm.org/D28955

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp
  lib/StaticAnalyzer/Core/ProgramState.cpp
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  lib/StaticAnalyzer/Core/Store.cpp
  test/Analysis/bool-assignment.c
  test/Analysis/dead-stores.m
  test/Analysis/explain-svals.cpp
  test/Analysis/malloc.c
  test/Analysis/misc-ps-eager-assume.m
  test/Analysis/std-c-library-functions.c

Index: test/Analysis/std-c-library-functions.c
===
--- test/Analysis/std-c-library-functions.c
+++ test/Analysis/std-c-library-functions.c
@@ -146,7 +146,7 @@
 void test_isgraph_isprint(int x) {
   char y = x;
   if (isgraph(y))
-clang_analyzer_eval(isprint(x)); // expected-warning{{TRUE}}
+clang_analyzer_eval(isprint(y)); // expected-warning{{TRUE}}
 }
 
 int isdigit(int);
Index: test/Analysis/misc-ps-eager-assume.m
===
--- test/Analysis/misc-ps-eager-assume.m
+++ test/Analysis/misc-ps-eager-assume.m
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 %z3_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks %s -analyzer-eagerly-assume
-// expected-no-diagnostics
 
 // Delta-reduced header stuff (needed for test cases).
 typedef signed char BOOL;
@@ -56,7 +55,7 @@
 void handle_symbolic_cast_in_condition(void) {
   NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
 
-  BOOL needsAnArray = [@"aString" isEqualToString:@"anotherString"];
+  BOOL needsAnArray = [@"aString" isEqualToString:@"anotherString"]; // expected-warning {{Assignment of a non-Boolean value}}
   NSMutableArray* array = needsAnArray ? [[NSMutableArray alloc] init] : 0;
   if(needsAnArray)
 [array release];
Index: test/Analysis/malloc.c
===
--- test/Analysis/malloc.c
+++ test/Analysis/malloc.c
@@ -1656,13 +1656,13 @@
 void testOffsetPassedToStrlen() {
   char * string = malloc(sizeof(char)*10);
   string += 1;
-  int length = strlen(string); // expected-warning {{Potential leak of memory pointed to by 'string'}}
+  size_t length = strlen(string); // expected-warning {{Potential leak of memory pointed to by 'string'}}
 }
 
 void testOffsetPassedToStrlenThenFree() {
   char * string = malloc(sizeof(char)*10);
   string += 1;
-  int length = strlen(string);
+  size_t length = strlen(string);
   free(string); // expected-warning {{Argument to free() is offset by 1 byte from the start of memory allocated by malloc()}}
 }
 
@@ -1705,7 +1705,7 @@
 }
 
 char *dupstrNoWarn(const char *s) {
-  const int len = strlen(s);
+  const size_t len = strlen(s);
   char *p = (char*) smallocNoWarn(len + 1);
   strcpy(p, s); // no-warning
   return p;
@@ -1721,7 +1721,7 @@
 }
 
 char *dupstrWarn(const char *s) {
-  const int len = strlen(s);
+  const size_t len = strlen(s);
   char *p = (char*) smallocWarn(len + 1);
   strcpy(p, s); // expected-warning{{String copy function overflows destination buffer}}
   return p;
Index: test/Analysis/explain-svals.cpp
===
--- test/Analysis/explain-svals.cpp
+++ test/Analysis/explain-svals.cpp
@@ -41,11 +41,11 @@
 
 void test_2(char *ptr, int ext) {
   clang_analyzer_explain((void *) "asdf"); // expected-warning-re^pointer to element of type 'char' with index 0 of string literal "asdf"$
-  clang_analyzer_explain(strlen(ptr)); // expected-warning-re^metadata of type 'unsigned long' tied to pointee of argument 'ptr'$
+  clang_analyzer_explain(strlen(ptr)); // expected-warning-re^cast of type 'int' of metadata of type 'unsigned long' tied to pointee of argument 'ptr'$
   clang_analyzer_explain(conjure()); // expected-warning-re^symbol of type 'int' conjured at statement 'conjure\(\)'$
   clang_analyzer_explain(glob); // expected-warning-re^value derived from \(symbol of type 'int' conjured at statement 'conjure\(\)'\) for global variable 'glob'$
   clang_analyzer_explain(glob_ptr); // expected-warning-re^value derived from \(symbol of type 'int' conjured at statement 'conjure\(\)'\) for global variable 'glob_ptr'$
-  clang_analyzer_explain(clang_analyzer_getExtent(ptr)); // expected-warning-re^extent of pointee of argument 'ptr'$
+  clang_analyzer_explain(clang_analyzer_getExtent(ptr)); // expected-warning-re^cast of type 'int' of extent of pointee of argument 'ptr'$
   int *x = new int[ext];
   clang_analyzer_explain(x); // expected-warning-re^pointer to element of type 'int' with index 0 of heap segment that starts at symbol of type 'int \*' conjured at statement 'new int 

[PATCH] D28954: [analyzer] Add support for symbolic float expressions

2017-01-20 Thread Dominic Chen via Phabricator via cfe-commits
ddcc created this revision.
Herald added a subscriber: mgorny.

With the Z3 constraint manager, symbolic floating-point constraints can also be 
reasoned about. This commit includes a basic floating-point checker for domain 
errors with math functions.


https://reviews.llvm.org/D28954

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SVals.def
  include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  include/clang/StaticAnalyzer/Core/PathSensitive/Symbols.def
  lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/FloatingPointMath.cpp
  lib/StaticAnalyzer/Core/BasicValueFactory.cpp
  lib/StaticAnalyzer/Core/Environment.cpp
  lib/StaticAnalyzer/Core/ProgramState.cpp
  lib/StaticAnalyzer/Core/RegionStore.cpp
  lib/StaticAnalyzer/Core/SValBuilder.cpp
  lib/StaticAnalyzer/Core/SVals.cpp
  lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  lib/StaticAnalyzer/Core/SymbolManager.cpp
  test/Analysis/diagnostics/macros.cpp
  test/Analysis/float-rules.c
  test/Analysis/float.c
  test/Analysis/inline.cpp
  test/Analysis/operator-calls.cpp
  tools/z3-constraint-manager/Z3ConstraintManager.cpp

Index: tools/z3-constraint-manager/Z3ConstraintManager.cpp
===
--- tools/z3-constraint-manager/Z3ConstraintManager.cpp
+++ tools/z3-constraint-manager/Z3ConstraintManager.cpp
@@ -77,6 +77,12 @@
 
 Z3_ast Assign = Z3_model_get_const_interp(Z3Expr::ZC, Model, Func);
 Z3_sort Sort = Z3_get_sort(Z3Expr::ZC, Assign);
+if (Z3_get_sort_kind(Z3Expr::ZC, Sort) == Z3_FLOATING_POINT_SORT) {
+  llvm::APFloat Float(llvm::APFloat::Bogus());
+  if (!Z3Expr::toAPFloat(Sort, Assign, Float, false))
+return false;
+  return BasicValueFactory::Convert(Int, Float);
+}
 return Z3Expr::toAPSInt(Sort, Assign, Int, true);
   }
 
@@ -88,6 +94,12 @@
 
 Z3_ast Assign = Z3_model_get_const_interp(Z3Expr::ZC, Model, Func);
 Z3_sort Sort = Z3_get_sort(Z3Expr::ZC, Assign);
+if (Z3_get_sort_kind(Z3Expr::ZC, Sort) != Z3_FLOATING_POINT_SORT) {
+  llvm::APSInt Int;
+  if (!Z3Expr::toAPSInt(Sort, Assign, Int, false))
+return false;
+  return BasicValueFactory::Convert(Float, Int);
+}
 return Z3Expr::toAPFloat(Sort, Assign, Float, true);
   }
 
@@ -617,8 +629,8 @@
 }; // end class Z3Expr
 
 void Z3ErrorHandler(Z3_context Context, Z3_error_code Error) {
-  llvm::report_fatal_error("Z3 error: " +
-   llvm::Twine(Z3_get_error_msg_ex(Context, Error)));
+  llvm::report_fatal_error(
+  "Z3 error: " + llvm::Twine(Z3_get_error_msg_ex(Context, Error)));
 }
 
 Z3_context Z3Expr::ZC;
@@ -660,6 +672,9 @@
   const llvm::APSInt *getSymVal(ProgramStateRef State,
 SymbolRef Sym) const override;
 
+  const llvm::APFloat *getSymFloatVal(ProgramStateRef State,
+  SymbolRef Sym) const override;
+
   ProgramStateRef removeDeadBindings(ProgramStateRef St,
  SymbolReaper ) override;
 
@@ -740,6 +755,10 @@
   // Helper functions.
   //===--===//
 
+  // Recover the QualType of an APFloat.
+  // TODO: Refactor to put elsewhere
+  QualType getAPFloatType(const llvm::APFloat ) const;
+
   // Recover the QualType of an APSInt.
   // TODO: Refactor to put elsewhere
   QualType getAPSIntType(const llvm::APSInt ) const;
@@ -765,6 +784,11 @@
   void doFloatTypeConversion(T , QualType , T ,
  QualType ) const;
 
+  // Callback function for doCast parameter on APFloat type.
+  static llvm::APFloat castAPFloat(const llvm::APFloat , QualType ToTy,
+   uint64_t ToWidth, QualType FromTy,
+   uint64_t FromWidth);
+
   // Callback function for doCast parameter on APSInt type.
   static llvm::APSInt castAPSInt(const llvm::APSInt , QualType ToTy,
  uint64_t ToWidth, QualType FromTy,
@@ -853,6 +877,10 @@
 Sym = SIE->getLHS();
   } else if (const IntSymExpr *ISE = dyn_cast(BSE)) {
 Sym = ISE->getRHS();
+  } else if (const SymFloatExpr *SFE = dyn_cast(BSE)) {
+Sym = SFE->getLHS();
+  } else if (const FloatSymExpr *FSE = dyn_cast(BSE)) {
+Sym = FSE->getRHS();
   } else if (const SymSymExpr *SSM = dyn_cast(BSE)) {
 return canReasonAbout(nonloc::SymbolVal(SSM->getLHS())) &&
canReasonAbout(nonloc::SymbolVal(SSM->getRHS()));
@@ -889,6 

[PATCH] D28953: [analyzer] Eliminate analyzer limitations on symbolic constraint generation

2017-01-20 Thread Dominic Chen via Phabricator via cfe-commits
ddcc updated this revision to Diff 85139.
ddcc added a comment.

Fix rebase


https://reviews.llvm.org/D28953

Files:
  include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  lib/StaticAnalyzer/Core/SValBuilder.cpp
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/bitwise-ops.c
  test/Analysis/conditional-path-notes.c
  test/Analysis/explain-svals.cpp
  test/Analysis/std-c-library-functions.c

Index: test/Analysis/std-c-library-functions.c
===
--- test/Analysis/std-c-library-functions.c
+++ test/Analysis/std-c-library-functions.c
@@ -57,8 +57,7 @@
   size_t y = fread(buf, sizeof(int), 10, fp);
   clang_analyzer_eval(y <= 10); // expected-warning{{TRUE}}
   size_t z = fwrite(buf, sizeof(int), y, fp);
-  // FIXME: should be TRUE once symbol-symbol constraint support is improved.
-  clang_analyzer_eval(z <= y); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(z <= y); // expected-warning{{TRUE}}
 }
 
 ssize_t getline(char **, size_t *, FILE *);
Index: test/Analysis/explain-svals.cpp
===
--- test/Analysis/explain-svals.cpp
+++ test/Analysis/explain-svals.cpp
@@ -69,7 +69,7 @@
   static int stat;
   clang_analyzer_explain(x + 1); // expected-warning-re^\(argument 'x'\) \+ 1$
   clang_analyzer_explain(1 + y); // expected-warning-re^\(argument 'y'\) \+ 1$
-  clang_analyzer_explain(x + y); // expected-warning-re^unknown value$
+  clang_analyzer_explain(x + y); // expected-warning-re^\(argument 'x'\) \+ \(argument 'y'\)$
   clang_analyzer_explain(z); // expected-warning-re^undefined value$
   clang_analyzer_explain(); // expected-warning-re^pointer to local variable 'z'$
   clang_analyzer_explain(stat); // expected-warning-re^signed 32-bit integer '0'$
Index: test/Analysis/conditional-path-notes.c
===
--- test/Analysis/conditional-path-notes.c
+++ test/Analysis/conditional-path-notes.c
@@ -77,7 +77,8 @@
 
 void testNonDiagnosableBranchArithmetic(int a, int b) {
   if (a - b) {
-// expected-note@-1 {{Taking true branch}}
+// expected-note@-1 {{Assuming the condition is true}}
+// expected-note@-2 {{Taking true branch}}
 *(volatile int *)0 = 1; // expected-warning{{Dereference of null pointer}}
 // expected-note@-1 {{Dereference of null pointer}}
   }
@@ -1573,12 +1574,75 @@
 // CHECK-NEXT: end
 // CHECK-NEXT:  
 // CHECK-NEXT:   
-// CHECK-NEXT:line81
+// CHECK-NEXT:line79
+// CHECK-NEXT:col7
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line79
+// CHECK-NEXT:col7
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT:   
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindevent
+// CHECK-NEXT:  location
+// CHECK-NEXT:  
+// CHECK-NEXT:   line79
+// CHECK-NEXT:   col7
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  ranges
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  line79
+// CHECK-NEXT:  col7
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  line79
+// CHECK-NEXT:  col11
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT:
+// CHECK-NEXT:  
+// CHECK-NEXT:  depth0
+// CHECK-NEXT:  extended_message
+// CHECK-NEXT:  Assuming the condition is true
+// CHECK-NEXT:  message
+// CHECK-NEXT:  Assuming the condition is true
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindcontrol
+// CHECK-NEXT:  edges
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: start
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:line79
+// CHECK-NEXT:col7
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line79
+// CHECK-NEXT:col7
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT: end
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:line82
 // CHECK-NEXT:col5
 // CHECK-NEXT:file0
 // CHECK-NEXT:   
 // CHECK-NEXT:   
-// CHECK-NEXT:line81
+// CHECK-NEXT:line82
 // CHECK-NEXT:col5
 // CHECK-NEXT:file0
 // CHECK-NEXT:   
@@ -1594,25 +1658,25 @@
 // CHECK-NEXT: start
 // CHECK-NEXT:  
 // CHECK-NEXT:   
-// CHECK-NEXT:line81
+// CHECK-NEXT:line82
 // CHECK-NEXT:col5
 // CHECK-NEXT:file0
 // CHECK-NEXT:   
 // 

[PATCH] D26061: [analyzer] Refactor and simplify SimpleConstraintManager

2017-01-20 Thread Dominic Chen via Phabricator via cfe-commits
ddcc updated this revision to Diff 85136.
ddcc added a comment.

Rebase


https://reviews.llvm.org/D26061

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h
  lib/StaticAnalyzer/Core/CMakeLists.txt
  lib/StaticAnalyzer/Core/ConstraintManager.cpp
  lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  lib/StaticAnalyzer/Core/RangedConstraintManager.h
  lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
  lib/StaticAnalyzer/Core/SimpleConstraintManager.h

Index: lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
@@ -7,12 +7,12 @@
 //
 //===--===//
 //
-//  This file defines SimpleConstraintManager, a class that holds code shared
-//  between BasicConstraintManager and RangeConstraintManager.
+//  This file defines SimpleConstraintManager, a class that provides a
+//  simplified constraint manager interface, compared to ConstraintManager.
 //
 //===--===//
 
-#include "SimpleConstraintManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
@@ -23,48 +23,6 @@
 
 SimpleConstraintManager::~SimpleConstraintManager() {}
 
-bool SimpleConstraintManager::canReasonAbout(SVal X) const {
-  Optional SymVal = X.getAs();
-  if (SymVal && SymVal->isExpression()) {
-const SymExpr *SE = SymVal->getSymbol();
-
-if (const SymIntExpr *SIE = dyn_cast(SE)) {
-  switch (SIE->getOpcode()) {
-  // We don't reason yet about bitwise-constraints on symbolic values.
-  case BO_And:
-  case BO_Or:
-  case BO_Xor:
-return false;
-  // We don't reason yet about these arithmetic constraints on
-  // symbolic values.
-  case BO_Mul:
-  case BO_Div:
-  case BO_Rem:
-  case BO_Shl:
-  case BO_Shr:
-return false;
-  // All other cases.
-  default:
-return true;
-  }
-}
-
-if (const SymSymExpr *SSE = dyn_cast(SE)) {
-  if (BinaryOperator::isComparisonOp(SSE->getOpcode())) {
-// We handle Loc <> Loc comparisons, but not (yet) NonLoc <> NonLoc.
-if (Loc::isLocType(SSE->getLHS()->getType())) {
-  assert(Loc::isLocType(SSE->getRHS()->getType()));
-  return true;
-}
-  }
-}
-
-return false;
-  }
-
-  return true;
-}
-
 ProgramStateRef SimpleConstraintManager::assume(ProgramStateRef State,
 DefinedSVal Cond,
 bool Assumption) {
@@ -92,23 +50,6 @@
   return State;
 }
 
-ProgramStateRef
-SimpleConstraintManager::assumeAuxForSymbol(ProgramStateRef State,
-SymbolRef Sym, bool Assumption) {
-  BasicValueFactory  = getBasicVals();
-  QualType T = Sym->getType();
-
-  // None of the constraint solvers currently support non-integer types.
-  if (!T->isIntegralOrEnumerationType())
-return State;
-
-  const llvm::APSInt  = BVF.getValue(0, T);
-  if (Assumption)
-return assumeSymNE(State, Sym, zero, zero);
-  else
-return assumeSymEQ(State, Sym, zero, zero);
-}
-
 ProgramStateRef SimpleConstraintManager::assumeAux(ProgramStateRef State,
NonLoc Cond,
bool Assumption) {
@@ -118,7 +59,8 @@
   if (!canReasonAbout(Cond)) {
 // Just add the constraint to the expression without trying to simplify.
 SymbolRef Sym = Cond.getAsSymExpr();
-return assumeAuxForSymbol(State, Sym, Assumption);
+assert(Sym);
+return assumeSymUnsupported(State, Sym, Assumption);
   }
 
   switch (Cond.getSubKind()) {
@@ -129,51 +71,7 @@
 nonloc::SymbolVal SV = Cond.castAs();
 SymbolRef Sym = SV.getSymbol();
 assert(Sym);
-
-// Handle SymbolData.
-if (!SV.isExpression()) {
-  return assumeAuxForSymbol(State, Sym, Assumption);
-
-  // Handle symbolic expression.
-} else if (const SymIntExpr *SE = dyn_cast(Sym)) {
-  // We can only simplify expressions whose RHS is an integer.
-
-  BinaryOperator::Opcode Op = SE->getOpcode();
-  if (BinaryOperator::isComparisonOp(Op)) {
-if (!Assumption)
-  Op = BinaryOperator::negateComparisonOp(Op);
-
-return assumeSymRel(State, SE->getLHS(), Op, SE->getRHS());
-  }
-
-} else if (const SymSymExpr *SSE = dyn_cast(Sym)) {
-  // Translate "a != b" to "(b - a) != 0".
- 

[PATCH] D25817: [Sema] Improve the error diagnostic for dot destructor calls on pointer objects

2017-01-20 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292615: [Sema] Improve the error diagnostic for dot 
destructor calls on pointer objects (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D25817?vs=75712=85135#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25817

Files:
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/test/CXX/special/class.dtor/p10-0x.cpp
  cfe/trunk/test/FixIt/fixit.cpp
  cfe/trunk/test/FixIt/no-fixit.cpp
  cfe/trunk/test/SemaCXX/pseudo-destructors.cpp

Index: cfe/trunk/test/SemaCXX/pseudo-destructors.cpp
===
--- cfe/trunk/test/SemaCXX/pseudo-destructors.cpp
+++ cfe/trunk/test/SemaCXX/pseudo-destructors.cpp
@@ -89,3 +89,26 @@
 void AliasTemplate(int *p) {
   p->~Id();
 }
+
+namespace dotPointerAccess {
+struct Base {
+  virtual ~Base() {}
+};
+
+struct Derived : Base {
+  ~Derived() {}
+};
+
+void test() {
+  Derived d;
+  static_cast().~Base(); // expected-error {{member reference type 'dotPointerAccess::Base *' is a pointer; did you mean to use '->'}}
+  d->~Derived(); // expected-error {{member reference type 'dotPointerAccess::Derived' is not a pointer; did you mean to use '.'}}
+}
+
+typedef Derived *Foo;
+
+void test2(Foo d) {
+  d.~Foo(); // This is ok
+  d.~Derived(); // expected-error {{member reference type 'Foo' (aka 'dotPointerAccess::Derived *') is a pointer; did you mean to use '->'}}
+}
+}
Index: cfe/trunk/test/CXX/special/class.dtor/p10-0x.cpp
===
--- cfe/trunk/test/CXX/special/class.dtor/p10-0x.cpp
+++ cfe/trunk/test/CXX/special/class.dtor/p10-0x.cpp
@@ -33,7 +33,7 @@
  expected-error{{the type of object expression ('int') does not match the type being destroyed ('decltype(intp())' (aka 'int *')) in pseudo-destructor expression}}
   i.~decltype(intp())(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('decltype(intp())' (aka 'int *')) in pseudo-destructor expression}}
   pi->~decltype(int())();
-  pi.~decltype(int())(); // expected-error{{the type of object expression ('int *') does not match the type being destroyed ('decltype(int())' (aka 'int')) in pseudo-destructor expression}}
+  pi.~decltype(int())(); // expected-error{{member reference type 'int *' is a pointer; did you mean to use '->'?}}
   pi.~decltype(intp())();
   pi->~decltype(intp())(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('decltype(intp())' (aka 'int *')) in pseudo-destructor expression}}
 }
Index: cfe/trunk/test/FixIt/no-fixit.cpp
===
--- cfe/trunk/test/FixIt/no-fixit.cpp
+++ cfe/trunk/test/FixIt/no-fixit.cpp
@@ -11,3 +11,15 @@
 (void)
   }
 } x;
+
+namespace dotPointerDestructor {
+
+struct Bar {
+  ~Bar() = delete;
+};
+
+void bar(Bar *o) {
+  o.~Bar(); // no fixit
+}
+
+}
Index: cfe/trunk/test/FixIt/fixit.cpp
===
--- cfe/trunk/test/FixIt/fixit.cpp
+++ cfe/trunk/test/FixIt/fixit.cpp
@@ -409,3 +409,14 @@
 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:26-[[@LINE-1]]:26}:"{}"
 int use_czi = czi.a;
 
+namespace dotPointerDestructor {
+
+struct Bar {
+  ~Bar();
+};
+
+void bar(Bar *o) {
+  o.~Bar(); // expected-error {{member reference type 'dotPointerDestructor::Bar *' is a pointer; did you mean to use '->'}}
+}  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:4-[[@LINE-1]]:5}:"->"
+
+}
Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -6403,6 +6403,23 @@
   return false;
 }
 
+/// \brief Check if it's ok to try and recover dot pseudo destructor calls on
+/// pointer objects.
+static bool
+canRecoverDotPseudoDestructorCallsOnPointerObjects(Sema ,
+   QualType DestructedType) {
+  // If this is a record type, check if its destructor is callable.
+  if (auto *RD = DestructedType->getAsCXXRecordDecl()) {
+if (CXXDestructorDecl *D = SemaRef.LookupDestructor(RD))
+  return SemaRef.CanUseDecl(D, /*TreatUnavailableAsInvalid=*/false);
+return false;
+  }
+
+  // Otherwise, check if it's a type for which it's valid to use a pseudo-dtor.
+  return DestructedType->isDependentType() || DestructedType->isScalarType() ||
+ DestructedType->isVectorType();
+}
+
 ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base,
SourceLocation OpLoc,
tok::TokenKind OpKind,
@@ -6437,15 +6454,36 @@
   = DestructedTypeInfo->getTypeLoc().getLocalSourceRange().getBegin();
 if (!DestructedType->isDependentType() && !ObjectType->isDependentType()) {
   if 

r292615 - [Sema] Improve the error diagnostic for dot destructor calls on pointer objects

2017-01-20 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Jan 20 09:38:58 2017
New Revision: 292615

URL: http://llvm.org/viewvc/llvm-project?rev=292615=rev
Log:
[Sema] Improve the error diagnostic for dot destructor calls on pointer objects

This commit improves the mismatched destructor type error by detecting when the
destructor call has used a '.' instead of a '->' on a pointer to the destructed
type. The diagnostic now suggests to use '->' instead of '.', and adds a fixit
where appropriate.

rdar://28766702

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

Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/CXX/special/class.dtor/p10-0x.cpp
cfe/trunk/test/FixIt/fixit.cpp
cfe/trunk/test/FixIt/no-fixit.cpp
cfe/trunk/test/SemaCXX/pseudo-destructors.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=292615=292614=292615=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Jan 20 09:38:58 2017
@@ -6403,6 +6403,23 @@ static bool CheckArrow(Sema& S, QualType
   return false;
 }
 
+/// \brief Check if it's ok to try and recover dot pseudo destructor calls on
+/// pointer objects.
+static bool
+canRecoverDotPseudoDestructorCallsOnPointerObjects(Sema ,
+   QualType DestructedType) {
+  // If this is a record type, check if its destructor is callable.
+  if (auto *RD = DestructedType->getAsCXXRecordDecl()) {
+if (CXXDestructorDecl *D = SemaRef.LookupDestructor(RD))
+  return SemaRef.CanUseDecl(D, /*TreatUnavailableAsInvalid=*/false);
+return false;
+  }
+
+  // Otherwise, check if it's a type for which it's valid to use a pseudo-dtor.
+  return DestructedType->isDependentType() || DestructedType->isScalarType() ||
+ DestructedType->isVectorType();
+}
+
 ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base,
SourceLocation OpLoc,
tok::TokenKind OpKind,
@@ -6437,15 +6454,36 @@ ExprResult Sema::BuildPseudoDestructorEx
   = DestructedTypeInfo->getTypeLoc().getLocalSourceRange().getBegin();
 if (!DestructedType->isDependentType() && !ObjectType->isDependentType()) {
   if (!Context.hasSameUnqualifiedType(DestructedType, ObjectType)) {
-Diag(DestructedTypeStart, diag::err_pseudo_dtor_type_mismatch)
-  << ObjectType << DestructedType << Base->getSourceRange()
-  << DestructedTypeInfo->getTypeLoc().getLocalSourceRange();
-
-// Recover by setting the destructed type to the object type.
-DestructedType = ObjectType;
-DestructedTypeInfo = Context.getTrivialTypeSourceInfo(ObjectType,
-   
DestructedTypeStart);
-Destructed = PseudoDestructorTypeStorage(DestructedTypeInfo);
+// Detect dot pseudo destructor calls on pointer objects, e.g.:
+//   Foo *foo;
+//   foo.~Foo();
+if (OpKind == tok::period && ObjectType->isPointerType() &&
+Context.hasSameUnqualifiedType(DestructedType,
+   ObjectType->getPointeeType())) {
+  auto Diagnostic =
+  Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
+  << ObjectType << /*IsArrow=*/0 << Base->getSourceRange();
+
+  // Issue a fixit only when the destructor is valid.
+  if (canRecoverDotPseudoDestructorCallsOnPointerObjects(
+  *this, DestructedType))
+Diagnostic << FixItHint::CreateReplacement(OpLoc, "->");
+
+  // Recover by setting the object type to the destructed type and the
+  // operator to '->'.
+  ObjectType = DestructedType;
+  OpKind = tok::arrow;
+} else {
+  Diag(DestructedTypeStart, diag::err_pseudo_dtor_type_mismatch)
+  << ObjectType << DestructedType << Base->getSourceRange()
+  << DestructedTypeInfo->getTypeLoc().getLocalSourceRange();
+
+  // Recover by setting the destructed type to the object type.
+  DestructedType = ObjectType;
+  DestructedTypeInfo =
+  Context.getTrivialTypeSourceInfo(ObjectType, 
DestructedTypeStart);
+  Destructed = PseudoDestructorTypeStorage(DestructedTypeInfo);
+}
   } else if (DestructedType.getObjCLifetime() !=
 ObjectType.getObjCLifetime()) {
 

Modified: cfe/trunk/test/CXX/special/class.dtor/p10-0x.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/special/class.dtor/p10-0x.cpp?rev=292615=292614=292615=diff
==
--- cfe/trunk/test/CXX/special/class.dtor/p10-0x.cpp (original)
+++ cfe/trunk/test/CXX/special/class.dtor/p10-0x.cpp Fri 

Re: [libcxx] r292582 - Still expose std::align_val_t in C++17 even if we don't have aligned new/delete.

2017-01-20 Thread Marshall Clow via cfe-commits
On Thu, Jan 19, 2017 at 10:40 PM, Eric Fiselier  wrote:

> Hi All,
>
> This patch addresses issues introduced by r292564. Specifically it makes
> `align_val_t.pass.cpp` pass in C++17 even if the system
> doesn't support aligned new/delete.
>
> Because r292564 was merged into 4.0, this should be as well.
>
> @Marshall can you OK this?
>

Yes. I am OK with this.

-- Marshall


>
> /Eric
>
> On Thu, Jan 19, 2017 at 11:27 PM, Eric Fiselier via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ericwf
>> Date: Fri Jan 20 00:27:34 2017
>> New Revision: 292582
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=292582=rev
>> Log:
>> Still expose std::align_val_t in C++17 even if we don't have aligned
>> new/delete.
>>
>> r292564 disabled the aligned new/delete overloads on platforms without
>> posix_memalign. Unfortunately that patch also disabled the  align_val_t
>> definition in C++17 as well.
>>
>> This patch causes align_val_t to be exposed in C++17 regardless
>> of if we have the new/delete overloads.
>>
>> Modified:
>> libcxx/trunk/include/new
>>
>> Modified: libcxx/trunk/include/new
>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/new
>> ?rev=292582=292581=292582=diff
>> 
>> ==
>> --- libcxx/trunk/include/new (original)
>> +++ libcxx/trunk/include/new Fri Jan 20 00:27:34 2017
>> @@ -145,7 +145,7 @@ public:
>>
>>  #endif  // defined(_LIBCPP_BUILDING_NEW) || (_LIBCPP_STD_VER > 11)
>>
>> -#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
>> +#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) || _LIBCPP_STD_VER > 14
>>  #ifndef _LIBCPP_CXX03_LANG
>>  enum class _LIBCPP_ENUM_VIS align_val_t : size_t { };
>>  #else
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28729: [clang-tidy] Add -enable-alpha-checks command

2017-01-20 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

Ok, I didn't know that it is this easy to run alpha checks from clang.


https://reviews.llvm.org/D28729



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27710: [analyzer] Prohibit ExplodedGraph's edges duplicating

2017-01-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.



In https://reviews.llvm.org/D27710#650396, @ilya-palachev wrote:

> I don't understand why the following test passes, because each of two 
> checkers: `MallocChecker` and `SimpleStreamChecker` are using 
> `generateNonFatalErrorNode` method:


That's because error nodes generated by different checkers have different 
program point, because they have different program point tags, because //their 
tag is the checker// that throws the report.

I'm referring to this funny code in Checker.h:473:

  class CheckerBase : public ProgramPointTag



In https://reviews.llvm.org/D27710#650396, @ilya-palachev wrote:

> > As Artem points out, the checkers in tree do not create a node for every 
> > bug reported - there is no reason to do that.
>
> Yes... But why does `generateNonFatalErrorNode` return `nullptr` in case when 
> the node already exists? Isn't it designed so that to prevent multiple 
> reports being thrown for the same node? If so, then the code contains a lot 
> of such checks.


I do not have a certain answer (i.e. bugs me as well), but this behavior allows 
knowing if this checker has already reported a bug on a different path that 
leads to the same predecessor node and therefore to the same error node.

So the use-case i'm a bit worried about is when a checker finds the same error 
node on a different path and suddenly wants to throw a different report (by bug 
kind). But i think it's normally impossible because the checker is never, in 
any callback, aware of the path it took before reaching the predecessor node, 
only the node itself.

I think i lost track of the original question's discussion>< Do we still 
believe that duplicated edges are a problem?


Repository:
  rL LLVM

https://reviews.llvm.org/D27710



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28943: [clang-format] Remove redundant test in style-on-command-line.cpp

2017-01-20 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

In https://reviews.llvm.org/D28943#651489, @ioeric wrote:

> In https://reviews.llvm.org/D28943#651488, @amaiorano wrote:
>
> > In https://reviews.llvm.org/D28943#651470, @ioeric wrote:
> >
> > > @amaiorano: The test itself is correct. It's just that this test failed 
> > > in our internal test. We could've fixed it internally, but the fix would 
> > > be ugly. Since the intended behavior is already covered in the case above 
> > > it, and it's really just checking the default fallback style is LLVM, 
> > > which is not related to the original change, I think it makes sense to 
> > > get rid of the case. Hope you don't mind :)
> >
> >
> > Of course I don't mind :) Why did it fail your internal tests, btw? Just 
> > curious. Was it something I could've detected myself?
>
>
> Probably not... it's just that our default fallback style is "Google" instead 
> of "LLVM".


(I replied the following by email, but I'm not sure where it went... posting it 
here instead)

You mean you build a modified version of clang-format where Style is 
initialized to getGoogleStyle()?

I had wondered whether adding a "defaultStyle" argument might be useful, 
specifically in the case where you want to pass in yaml that simply tweaks the 
default style, but I figured it's not much harder to pass in "BasedOnStyle" in 
the yaml.


Repository:
  rL LLVM

https://reviews.llvm.org/D28943



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r292562 - clang-format: fix fallback style set to "none" not always formatting

2017-01-20 Thread Mikael Holmén via cfe-commits

Hi,

On 01/20/2017 02:20 PM, Antonio Maiorano wrote:

Hi Mikael,

Just to be sure, did you build clang-format before running this test?


Yes I did. I compiled a clean trunk, ran the test, got the failure.



Possibly related, one of the tests I added was just removed for being
redundant:
https://reviews.llvm.org/D28943


Aha. I can't say I understand what's going on there, I don't even know 
how to change the default fallback style or what it is :)


Regards,

Mikael




On Fri, Jan 20, 2017 at 7:50 AM Mikael Holmén
> wrote:

Hi Antonio,



The test case



Clang :: Format/style-on-command-line.cpp



fails for me since this commit.



test/Format/style-on-command-line.cpp:40:13: error: expected string not

found in input

// CHECK10: {{^int\* i;$}}

 ^

:1:1: note: scanning from here

// RUN: clang-format -style="{BasedOnStyle: Google, IndentWidth: 8}"
%s |

^

:61:16: note: possible intended match here

   // CHECK10: {{^int\* i;$}}

^



I suppose it works for you... Any idea what the problem can be?



Regards,

Mikael


On 01/20/2017 02:22 AM, Antonio Maiorano via cfe-commits wrote:

> Author: amaiorano

> Date: Thu Jan 19 19:22:42 2017

> New Revision: 292562

>

> URL: http://llvm.org/viewvc/llvm-project?rev=292562=rev

> Log:

> clang-format: fix fallback style set to "none" not always formatting

>

> This fixes clang-format not formatting if fallback-style is
explicitly set to

> "none", and either a config file is found or YAML is passed in
without a

> "BasedOnStyle". With this change, passing "none" in these cases
will have no

> affect, and LLVM style will be used as the base style.

>

> Differential Revision: https://reviews.llvm.org/D28844

>

> Modified:

> cfe/trunk/lib/Format/Format.cpp

> cfe/trunk/test/Format/style-on-command-line.cpp

> cfe/trunk/unittests/Format/FormatTest.cpp

>

> Modified: cfe/trunk/lib/Format/Format.cpp

> URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=292562=292561=292562=diff

>

==

> --- cfe/trunk/lib/Format/Format.cpp (original)

> +++ cfe/trunk/lib/Format/Format.cpp Thu Jan 19 19:22:42 2017

> @@ -1888,8 +1888,8 @@ static FormatStyle::LanguageKind getLang

>  }

>

>  llvm::Expected getStyle(StringRef StyleName,
StringRef FileName,

> - StringRef FallbackStyle,
StringRef Code,

> - vfs::FileSystem *FS) {

> + StringRef FallbackStyleName,

> + StringRef Code,
vfs::FileSystem *FS) {

>if (!FS) {

>  FS = vfs::getRealFileSystem().get();

>}

> @@ -1903,9 +1903,9 @@ llvm::Expected getStyle(Str

>(Code.contains("\n- (") || Code.contains("\n+ (")))

>  Style.Language = FormatStyle::LK_ObjC;

>

> -  // FIXME: If FallbackStyle is explicitly "none", format is
disabled.

> -  if (!getPredefinedStyle(FallbackStyle, Style.Language, ))

> -return make_string_error("Invalid fallback style \"" +
FallbackStyle.str());

> +  FormatStyle FallbackStyle = getNoStyle();

> +  if (!getPredefinedStyle(FallbackStyleName, Style.Language,
))

> +return make_string_error("Invalid fallback style \"" +
FallbackStyleName);

>

>if (StyleName.startswith("{")) {

>  // Parse YAML/JSON style from the command line.

> @@ -1977,7 +1977,7 @@ llvm::Expected getStyle(Str

>  return make_string_error("Configuration file(s) do(es) not
support " +

>   getLanguageName(Style.Language) + ": " +

>   UnsuitableConfigFiles);

> -  return Style;

> +  return FallbackStyle;

>  }

>

>  } // namespace format

>

> Modified: cfe/trunk/test/Format/style-on-command-line.cpp

> URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/style-on-command-line.cpp?rev=292562=292561=292562=diff

>

==

> --- cfe/trunk/test/Format/style-on-command-line.cpp (original)

> +++ cfe/trunk/test/Format/style-on-command-line.cpp Thu Jan 19
19:22:42 2017

> @@ -11,6 +11,21 @@

>  // RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s
| FileCheck -strict-whitespace -check-prefix=CHECK7 %s

>  // RUN: clang-format -style="{BasedOnStyle: LLVM,
PointerBindsToType: true}" %s | FileCheck -strict-whitespace
-check-prefix=CHECK8 %s

>  // RUN: clang-format 

Re: [PATCH] D28943: [clang-format] Remove redundant test in style-on-command-line.cpp

2017-01-20 Thread Antonio Maiorano via cfe-commits
You mean you build a modified version of clang-format where Style is
initialized to getGoogleStyle()?

I had wondered whether adding a -defaultStyle argument might be useful,
specifically in the case where you want to pass in yaml that simply tweaks
the default style, but I figured it's not much harder to pass in
"BasedOnStyle" in the yaml.

On Fri, Jan 20, 2017 at 8:17 AM Eric Liu via Phabricator <
revi...@reviews.llvm.org> wrote:

> ioeric added a comment.
>
>
>
> In https://reviews.llvm.org/D28943#651488, @amaiorano wrote:
>
>
>
> > In https://reviews.llvm.org/D28943#651470, @ioeric wrote:
>
> >
>
> > > @amaiorano: The test itself is correct. It's just that this test
> failed in our internal test. We could've fixed it internally, but the fix
> would be ugly. Since the intended behavior is already covered in the case
> above it, and it's really just checking the default fallback style is LLVM,
> which is not related to the original change, I think it makes sense to get
> rid of the case. Hope you don't mind :)
>
> >
>
> >
>
> > Of course I don't mind :) Why did it fail your internal tests, btw? Just
> curious. Was it something I could've detected myself?
>
>
>
>
>
> Probably not... it's just that our default fallback style is "Google"
> instead of "LLVM".
>
>
>
>
>
> Repository:
>
>   rL LLVM
>
>
>
> https://reviews.llvm.org/D28943
>
>
>
>
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28946: [analyzer] Fix memory space for block-captured static locals.

2017-01-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.

When a block that is being analyzed as top-level captures static local 
variables declared in a function (which itself is not being analyzed) 
surrounding the block, it puts such variables into the unknown memory space, 
similarly to the stack locals of those functions (that may have been moved to 
the heap by the time the block starts executing).

However, because blocks don't move such variables to the heap, but capture them 
by reference instead, we are quite sure that we should put those into the 
static memspace.

This patch fixes a false positive in MacOSXAPIChecker.


https://reviews.llvm.org/D28946

Files:
  lib/StaticAnalyzer/Core/MemRegion.cpp
  test/Analysis/dispatch-once.m

Index: test/Analysis/dispatch-once.m
===
--- test/Analysis/dispatch-once.m
+++ test/Analysis/dispatch-once.m
@@ -107,3 +107,10 @@
   };
   dispatch_once(, ^{}); // expected-warning{{Call to 'dispatch_once' uses the block variable 'once' for the predicate value.}}
 }
+
+void test_static_var_from_outside_block() {
+  static dispatch_once_t once;
+  ^{
+dispatch_once(, ^{}); // no-warning
+  };
+}
Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -776,6 +776,22 @@
   return (const StackFrameContext *)nullptr;
 }
 
+static CanQualType getBlockPointerType(const BlockDecl *BD, ASTContext ) {
+  // FIXME: The fallback type here is totally bogus -- though it should
+  // never be queried, it will prevent uniquing with the real
+  // BlockCodeRegion. Ideally we'd fix the AST so that we always had a
+  // signature.
+  QualType T;
+  if (const TypeSourceInfo *TSI = BD->getSignatureAsWritten())
+T = TSI->getType();
+  if (T.isNull())
+T = C.VoidTy;
+  if (!T->getAs())
+T = C.getFunctionNoProtoType(T);
+  T = C.getBlockPointerType(T);
+  return C.getCanonicalType(T);
+}
+
 const VarRegion* MemRegionManager::getVarRegion(const VarDecl *D,
 const LocationContext *LC) {
   const MemRegion *sReg = nullptr;
@@ -803,7 +819,7 @@
 sReg = getGlobalsRegion();
 }
 
-  // Finally handle static locals.
+  // Finally handle locals.
   } else {
 // FIXME: Once we implement scope handling, we will need to properly lookup
 // 'D' to the proper LocationContext.
@@ -816,9 +832,22 @@
 
 const StackFrameContext *STC = V.get();
 
-if (!STC)
-  sReg = getUnknownRegion();
-else {
+if (!STC) {
+  if (D->isStaticLocal()) {
+const CodeTextRegion *fReg = nullptr;
+if (const auto *ND = dyn_cast(DC))
+  fReg = getFunctionCodeRegion(ND);
+else if (const auto *BD = dyn_cast(DC))
+  fReg = getBlockCodeRegion(BD, getBlockPointerType(BD, getContext()),
+LC->getAnalysisDeclContext());
+assert(fReg && "Unable to determine code region for a static local!");
+sReg = getGlobalsRegion(MemRegion::StaticGlobalSpaceRegionKind, fReg);
+  } else {
+// We're looking at a block-captured local variable, which may be either
+// still local, or already moved to the heap. So we're not sure.
+sReg = getUnknownRegion();
+  }
+} else {
   if (D->hasLocalStorage()) {
 sReg = isa(D) || isa(D)
? static_cast(getStackArgumentsRegion(STC))
@@ -831,22 +860,9 @@
   sReg = getGlobalsRegion(MemRegion::StaticGlobalSpaceRegionKind,
   getFunctionCodeRegion(cast(STCD)));
 else if (const BlockDecl *BD = dyn_cast(STCD)) {
-  // FIXME: The fallback type here is totally bogus -- though it should
-  // never be queried, it will prevent uniquing with the real
-  // BlockCodeRegion. Ideally we'd fix the AST so that we always had a
-  // signature.
-  QualType T;
-  if (const TypeSourceInfo *TSI = BD->getSignatureAsWritten())
-T = TSI->getType();
-  if (T.isNull())
-T = getContext().VoidTy;
-  if (!T->getAs())
-T = getContext().getFunctionNoProtoType(T);
-  T = getContext().getBlockPointerType(T);
-
   const BlockCodeRegion *BTR =
-getBlockCodeRegion(BD, C.getCanonicalType(T),
-   STC->getAnalysisDeclContext());
+  getBlockCodeRegion(BD, getBlockPointerType(BD, getContext()),
+ STC->getAnalysisDeclContext());
   sReg = getGlobalsRegion(MemRegion::StaticGlobalSpaceRegionKind,
   BTR);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r292562 - clang-format: fix fallback style set to "none" not always formatting

2017-01-20 Thread Antonio Maiorano via cfe-commits
Hi Mikael,

Just to be sure, did you build clang-format before running this test?

Possibly related, one of the tests I added was just removed for being
redundant:
https://reviews.llvm.org/D28943


On Fri, Jan 20, 2017 at 7:50 AM Mikael Holmén 
wrote:

> Hi Antonio,
>
>
>
> The test case
>
>
>
> Clang :: Format/style-on-command-line.cpp
>
>
>
> fails for me since this commit.
>
>
>
> test/Format/style-on-command-line.cpp:40:13: error: expected string not
>
> found in input
>
> // CHECK10: {{^int\* i;$}}
>
>  ^
>
> :1:1: note: scanning from here
>
> // RUN: clang-format -style="{BasedOnStyle: Google, IndentWidth: 8}" %s |
>
> ^
>
> :61:16: note: possible intended match here
>
>// CHECK10: {{^int\* i;$}}
>
> ^
>
>
>
> I suppose it works for you... Any idea what the problem can be?
>
>
>
> Regards,
>
> Mikael
>
>
> On 01/20/2017 02:22 AM, Antonio Maiorano via cfe-commits wrote:
>
> > Author: amaiorano
>
> > Date: Thu Jan 19 19:22:42 2017
>
> > New Revision: 292562
>
> >
>
> > URL: http://llvm.org/viewvc/llvm-project?rev=292562=rev
>
> > Log:
>
> > clang-format: fix fallback style set to "none" not always formatting
>
> >
>
> > This fixes clang-format not formatting if fallback-style is explicitly
> set to
>
> > "none", and either a config file is found or YAML is passed in without a
>
> > "BasedOnStyle". With this change, passing "none" in these cases will
> have no
>
> > affect, and LLVM style will be used as the base style.
>
> >
>
> > Differential Revision: https://reviews.llvm.org/D28844
>
> >
>
> > Modified:
>
> > cfe/trunk/lib/Format/Format.cpp
>
> > cfe/trunk/test/Format/style-on-command-line.cpp
>
> > cfe/trunk/unittests/Format/FormatTest.cpp
>
> >
>
> > Modified: cfe/trunk/lib/Format/Format.cpp
>
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=292562=292561=292562=diff
>
> >
> ==
>
> > --- cfe/trunk/lib/Format/Format.cpp (original)
>
> > +++ cfe/trunk/lib/Format/Format.cpp Thu Jan 19 19:22:42 2017
>
> > @@ -1888,8 +1888,8 @@ static FormatStyle::LanguageKind getLang
>
> >  }
>
> >
>
> >  llvm::Expected getStyle(StringRef StyleName, StringRef
> FileName,
>
> > - StringRef FallbackStyle, StringRef
> Code,
>
> > - vfs::FileSystem *FS) {
>
> > + StringRef FallbackStyleName,
>
> > + StringRef Code, vfs::FileSystem
> *FS) {
>
> >if (!FS) {
>
> >  FS = vfs::getRealFileSystem().get();
>
> >}
>
> > @@ -1903,9 +1903,9 @@ llvm::Expected getStyle(Str
>
> >(Code.contains("\n- (") || Code.contains("\n+ (")))
>
> >  Style.Language = FormatStyle::LK_ObjC;
>
> >
>
> > -  // FIXME: If FallbackStyle is explicitly "none", format is disabled.
>
> > -  if (!getPredefinedStyle(FallbackStyle, Style.Language, ))
>
> > -return make_string_error("Invalid fallback style \"" +
> FallbackStyle.str());
>
> > +  FormatStyle FallbackStyle = getNoStyle();
>
> > +  if (!getPredefinedStyle(FallbackStyleName, Style.Language,
> ))
>
> > +return make_string_error("Invalid fallback style \"" +
> FallbackStyleName);
>
> >
>
> >if (StyleName.startswith("{")) {
>
> >  // Parse YAML/JSON style from the command line.
>
> > @@ -1977,7 +1977,7 @@ llvm::Expected getStyle(Str
>
> >  return make_string_error("Configuration file(s) do(es) not support
> " +
>
> >   getLanguageName(Style.Language) + ": " +
>
> >   UnsuitableConfigFiles);
>
> > -  return Style;
>
> > +  return FallbackStyle;
>
> >  }
>
> >
>
> >  } // namespace format
>
> >
>
> > Modified: cfe/trunk/test/Format/style-on-command-line.cpp
>
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/style-on-command-line.cpp?rev=292562=292561=292562=diff
>
> >
> ==
>
> > --- cfe/trunk/test/Format/style-on-command-line.cpp (original)
>
> > +++ cfe/trunk/test/Format/style-on-command-line.cpp Thu Jan 19 19:22:42
> 2017
>
> > @@ -11,6 +11,21 @@
>
> >  // RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s |
> FileCheck -strict-whitespace -check-prefix=CHECK7 %s
>
> >  // RUN: clang-format -style="{BasedOnStyle: LLVM, PointerBindsToType:
> true}" %s | FileCheck -strict-whitespace -check-prefix=CHECK8 %s
>
> >  // RUN: clang-format -style="{BasedOnStyle: WebKit, PointerBindsToType:
> false}" %s | FileCheck -strict-whitespace -check-prefix=CHECK9 %s
>
> > +
>
> > +// Fallback style tests
>
> > +// RUN: rm %T/_clang-format
>
> > +// Test no config file found, WebKit fallback style is applied
>
> > +// RUN: clang-format -style=file -fallback-style=WebKit
> -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace
> -check-prefix=CHECK10 %s
>
> > +// Test no config 

[PATCH] D28943: [clang-format] Remove redundant test in style-on-command-line.cpp

2017-01-20 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

In https://reviews.llvm.org/D28943#651488, @amaiorano wrote:

> In https://reviews.llvm.org/D28943#651470, @ioeric wrote:
>
> > @amaiorano: The test itself is correct. It's just that this test failed in 
> > our internal test. We could've fixed it internally, but the fix would be 
> > ugly. Since the intended behavior is already covered in the case above it, 
> > and it's really just checking the default fallback style is LLVM, which is 
> > not related to the original change, I think it makes sense to get rid of 
> > the case. Hope you don't mind :)
>
>
> Of course I don't mind :) Why did it fail your internal tests, btw? Just 
> curious. Was it something I could've detected myself?


Probably not... it's just that our default fallback style is "Google" instead 
of "LLVM".


Repository:
  rL LLVM

https://reviews.llvm.org/D28943



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28943: [clang-format] Remove redundant test in style-on-command-line.cpp

2017-01-20 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

In https://reviews.llvm.org/D28943#651470, @ioeric wrote:

> @amaiorano: The test itself is correct. It's just that this test failed in 
> our internal test. We could've fixed it internally, but the fix would be 
> ugly. Since the intended behavior is already covered in the case above it, 
> and it's really just checking the default fallback style is LLVM, which is 
> not related to the original change, I think it makes sense to get rid of the 
> case. Hope you don't mind :)


Of course I don't mind :) Why did it fail your internal tests, btw? Just 
curious. Was it something I could've detected myself?


Repository:
  rL LLVM

https://reviews.llvm.org/D28943



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r292607 - Don't default older GCC's to C++17, but C++14 or C++11 instead

2017-01-20 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan 20 06:54:45 2017
New Revision: 292607

URL: http://llvm.org/viewvc/llvm-project?rev=292607=rev
Log:
Don't default older GCC's to C++17, but C++14 or C++11 instead

Modified:
libcxx/trunk/test/libcxx/test/config.py

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=292607=292606=292607=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Fri Jan 20 06:54:45 2017
@@ -423,6 +423,15 @@ class Configuration(object):
 if not std:
 # Choose the newest possible language dialect if none is given.
 possible_stds = ['c++1z', 'c++14', 'c++11', 'c++03']
+if self.cxx.type == 'gcc':
+maj_v, _, _ = self.cxx.version
+maj_v = int(maj_v)
+if maj_v < 7:
+possible_stds.remove('c++1z')
+# FIXME: How many C++14 tests actually fail under GCC 5 and 6?
+# Should we XFAIL them individually instead?
+if maj_v <= 6:
+possible_stds.remove('c++14')
 for s in possible_stds:
 if self.cxx.hasCompileFlag('-std=%s' % s):
 std = s


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: PATCH: re-enable OpenCL extensions

2017-01-20 Thread Kalle Raiskila via cfe-commits



On 19.01.2017 23:43, Liu, Yaxun (Sam) wrote:

I think the supported extensions for a target should be as accurate as 
possible, for it to be useful. Setting all
extensions to be supported on all targets will defeat its purpose.


I agree on the first part, but arrive at the exact opposite result :)
At least ARM, AARch64, PowerPC and MIPS suffer from this now (i.e. the ones 
someone even tried to compile pocl on).
And OCL-C being a front-end option, and OpenCL a stand-alone library, there 
isn't too much backend target specific
stuff going on.


I recommend to introduce "pocl" as an environment in the triple and add 
supported OpenCL extensions for different
targets based on that.


This does sound like something we should consider. This would at the same time allow for development on the experimental 
backends.



-Original Message- From: Anastasia Stulova 
[mailto:anastasia.stul...@arm.com] Sent: Thursday, January 19,


 Do you think this can be solved instead with the new " -cl-ext=" option:

http://clang.llvm.org/docs/UsersManual.html#opencl-specific-options


I'll have to have a better, second look at this, thanks. If it don't, I'll file 
bug reports :)


thanks,
kalle
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r292606 - Revert "Don't default older GCC's to C++17, but C++14 or C++11 instead"

2017-01-20 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan 20 06:52:59 2017
New Revision: 292606

URL: http://llvm.org/viewvc/llvm-project?rev=292606=rev
Log:
Revert "Don't default older GCC's to C++17, but C++14 or C++11 instead"

The commit isn't quite right, and I want to only have to merge one
commit into 4.0

Modified:
libcxx/trunk/test/libcxx/test/config.py

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=292606=292605=292606=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Fri Jan 20 06:52:59 2017
@@ -423,14 +423,6 @@ class Configuration(object):
 if not std:
 # Choose the newest possible language dialect if none is given.
 possible_stds = ['c++1z', 'c++14', 'c++11', 'c++03']
-if self.cxx.type == 'gcc':
-maj_v, _, _ = self.cxx.version
-maj_v = int(maj_v)
-if maj_v < 7:
-possible_stds.remove('c++1z')
-# FIXME: How many C++14 tests actually fail under GCC 5 and 6?
-if maj_v <= 5:
-possible_stds.remove('c++14')
 for s in possible_stds:
 if self.cxx.hasCompileFlag('-std=%s' % s):
 std = s


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r292605 - Don't default older GCC's to C++17, but C++14 or C++11 instead

2017-01-20 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan 20 06:46:57 2017
New Revision: 292605

URL: http://llvm.org/viewvc/llvm-project?rev=292605=rev
Log:
Don't default older GCC's to C++17, but C++14 or C++11 instead

Modified:
libcxx/trunk/test/libcxx/test/config.py

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=292605=292604=292605=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Fri Jan 20 06:46:57 2017
@@ -423,6 +423,14 @@ class Configuration(object):
 if not std:
 # Choose the newest possible language dialect if none is given.
 possible_stds = ['c++1z', 'c++14', 'c++11', 'c++03']
+if self.cxx.type == 'gcc':
+maj_v, _, _ = self.cxx.version
+maj_v = int(maj_v)
+if maj_v < 7:
+possible_stds.remove('c++1z')
+# FIXME: How many C++14 tests actually fail under GCC 5 and 6?
+if maj_v <= 5:
+possible_stds.remove('c++14')
 for s in possible_stds:
 if self.cxx.hasCompileFlag('-std=%s' % s):
 std = s


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28943: [clang-format] Remove redundant test in style-on-command-line.cpp

2017-01-20 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292604: [clang-format] Remove redundant test in 
style-on-command-line.cpp (authored by krasimir).

Changed prior to commit:
  https://reviews.llvm.org/D28943?vs=85117=85122#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28943

Files:
  cfe/trunk/test/Format/style-on-command-line.cpp


Index: cfe/trunk/test/Format/style-on-command-line.cpp
===
--- cfe/trunk/test/Format/style-on-command-line.cpp
+++ cfe/trunk/test/Format/style-on-command-line.cpp
@@ -16,15 +16,13 @@
 // RUN: rm %T/_clang-format
 // Test no config file found, WebKit fallback style is applied
 // RUN: clang-format -style=file -fallback-style=WebKit 
-assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace 
-check-prefix=CHECK10 %s
-// Test no config file and no fallback style, LLVM style is applied
-// RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s 2>&1 | 
FileCheck -strict-whitespace -check-prefix=CHECK11 %s
 // Test no config file and fallback style "none", no formatting is applied
-// RUN: clang-format -style=file -fallback-style=none 
-assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace 
-check-prefix=CHECK12 %s
+// RUN: clang-format -style=file -fallback-style=none 
-assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace 
-check-prefix=CHECK11 %s
 // Test config file with no based style, and fallback style "none", formatting 
is applied
 // RUN: printf "IndentWidth: 6\n" > %T/_clang-format
-// RUN: clang-format -style=file -fallback-style=none 
-assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace 
-check-prefix=CHECK13 %s
+// RUN: clang-format -style=file -fallback-style=none 
-assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace 
-check-prefix=CHECK12 %s
 // Test yaml with no based style, and fallback style "none", LLVM formatting 
applied
-// RUN: clang-format -style="{IndentWidth: 7}" -fallback-style=none %s | 
FileCheck -strict-whitespace -check-prefix=CHECK14 %s
+// RUN: clang-format -style="{IndentWidth: 7}" -fallback-style=none %s | 
FileCheck -strict-whitespace -check-prefix=CHECK13 %s
 
 void f() {
 // CHECK1: {{^int\* i;$}}
@@ -38,10 +36,9 @@
 // CHECK8: {{^  int\* i;$}}
 // CHECK9: {{^int \*i;$}}
 // CHECK10: {{^int\* i;$}}
-// CHECK11: {{^  int \*i;$}}
-// CHECK12: {{^int\*i;$}}
-// CHECK13: {{^  int \*i;$}}
-// CHECK14: {{^   int \*i;$}}
+// CHECK11: {{^int\*i;$}}
+// CHECK12: {{^  int \*i;$}}
+// CHECK13: {{^   int \*i;$}}
 int*i;
 int j;
 }


Index: cfe/trunk/test/Format/style-on-command-line.cpp
===
--- cfe/trunk/test/Format/style-on-command-line.cpp
+++ cfe/trunk/test/Format/style-on-command-line.cpp
@@ -16,15 +16,13 @@
 // RUN: rm %T/_clang-format
 // Test no config file found, WebKit fallback style is applied
 // RUN: clang-format -style=file -fallback-style=WebKit -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK10 %s
-// Test no config file and no fallback style, LLVM style is applied
-// RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK11 %s
 // Test no config file and fallback style "none", no formatting is applied
-// RUN: clang-format -style=file -fallback-style=none -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK12 %s
+// RUN: clang-format -style=file -fallback-style=none -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK11 %s
 // Test config file with no based style, and fallback style "none", formatting is applied
 // RUN: printf "IndentWidth: 6\n" > %T/_clang-format
-// RUN: clang-format -style=file -fallback-style=none -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK13 %s
+// RUN: clang-format -style=file -fallback-style=none -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK12 %s
 // Test yaml with no based style, and fallback style "none", LLVM formatting applied
-// RUN: clang-format -style="{IndentWidth: 7}" -fallback-style=none %s | FileCheck -strict-whitespace -check-prefix=CHECK14 %s
+// RUN: clang-format -style="{IndentWidth: 7}" -fallback-style=none %s | FileCheck -strict-whitespace -check-prefix=CHECK13 %s
 
 void f() {
 // CHECK1: {{^int\* i;$}}
@@ -38,10 +36,9 @@
 // CHECK8: {{^  int\* i;$}}
 // CHECK9: {{^int \*i;$}}
 // CHECK10: {{^int\* i;$}}
-// CHECK11: {{^  int \*i;$}}
-// CHECK12: {{^int\*i;$}}
-// CHECK13: {{^  int \*i;$}}
-// CHECK14: {{^   int \*i;$}}
+// CHECK11: {{^int\*i;$}}
+// CHECK12: {{^  int \*i;$}}
+// CHECK13: {{^   int \*i;$}}
 int*i;
 int j;
 }
___
cfe-commits mailing list

r292604 - [clang-format] Remove redundant test in style-on-command-line.cpp

2017-01-20 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Fri Jan 20 06:39:05 2017
New Revision: 292604

URL: http://llvm.org/viewvc/llvm-project?rev=292604=rev
Log:
[clang-format] Remove redundant test in style-on-command-line.cpp

Summary:
rL292562 added a fix to always format if the fallback style is set to "none".
In test/Format/style-on-command-line.cpp:19 is redundant, since -fallback-style
has a default value of LLVM set in ClangFormat.cpp:72.

@amaiorano: I believe that the rest of the test cases still cover your change in
case the fallback style is explicitly set to "none". Please, if this is not the
case, initiate a discussion.

Reviewers: ioeric, bkramer

Reviewed By: ioeric

Subscribers: cfe-commits, klimek, amaiorano

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

Modified:
cfe/trunk/test/Format/style-on-command-line.cpp

Modified: cfe/trunk/test/Format/style-on-command-line.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/style-on-command-line.cpp?rev=292604=292603=292604=diff
==
--- cfe/trunk/test/Format/style-on-command-line.cpp (original)
+++ cfe/trunk/test/Format/style-on-command-line.cpp Fri Jan 20 06:39:05 2017
@@ -16,15 +16,13 @@
 // RUN: rm %T/_clang-format
 // Test no config file found, WebKit fallback style is applied
 // RUN: clang-format -style=file -fallback-style=WebKit 
-assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace 
-check-prefix=CHECK10 %s
-// Test no config file and no fallback style, LLVM style is applied
-// RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s 2>&1 | 
FileCheck -strict-whitespace -check-prefix=CHECK11 %s
 // Test no config file and fallback style "none", no formatting is applied
-// RUN: clang-format -style=file -fallback-style=none 
-assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace 
-check-prefix=CHECK12 %s
+// RUN: clang-format -style=file -fallback-style=none 
-assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace 
-check-prefix=CHECK11 %s
 // Test config file with no based style, and fallback style "none", formatting 
is applied
 // RUN: printf "IndentWidth: 6\n" > %T/_clang-format
-// RUN: clang-format -style=file -fallback-style=none 
-assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace 
-check-prefix=CHECK13 %s
+// RUN: clang-format -style=file -fallback-style=none 
-assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace 
-check-prefix=CHECK12 %s
 // Test yaml with no based style, and fallback style "none", LLVM formatting 
applied
-// RUN: clang-format -style="{IndentWidth: 7}" -fallback-style=none %s | 
FileCheck -strict-whitespace -check-prefix=CHECK14 %s
+// RUN: clang-format -style="{IndentWidth: 7}" -fallback-style=none %s | 
FileCheck -strict-whitespace -check-prefix=CHECK13 %s
 
 void f() {
 // CHECK1: {{^int\* i;$}}
@@ -38,10 +36,9 @@ void f() {
 // CHECK8: {{^  int\* i;$}}
 // CHECK9: {{^int \*i;$}}
 // CHECK10: {{^int\* i;$}}
-// CHECK11: {{^  int \*i;$}}
-// CHECK12: {{^int\*i;$}}
-// CHECK13: {{^  int \*i;$}}
-// CHECK14: {{^   int \*i;$}}
+// CHECK11: {{^int\*i;$}}
+// CHECK12: {{^  int \*i;$}}
+// CHECK13: {{^   int \*i;$}}
 int*i;
 int j;
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r292562 - clang-format: fix fallback style set to "none" not always formatting

2017-01-20 Thread Mikael Holmén via cfe-commits

Hi Antonio,

The test case

Clang :: Format/style-on-command-line.cpp

fails for me since this commit.

test/Format/style-on-command-line.cpp:40:13: error: expected string not 
found in input

// CHECK10: {{^int\* i;$}}
^
:1:1: note: scanning from here
// RUN: clang-format -style="{BasedOnStyle: Google, IndentWidth: 8}" %s |
^
:61:16: note: possible intended match here
  // CHECK10: {{^int\* i;$}}
   ^

I suppose it works for you... Any idea what the problem can be?

Regards,
Mikael

On 01/20/2017 02:22 AM, Antonio Maiorano via cfe-commits wrote:

Author: amaiorano
Date: Thu Jan 19 19:22:42 2017
New Revision: 292562

URL: http://llvm.org/viewvc/llvm-project?rev=292562=rev
Log:
clang-format: fix fallback style set to "none" not always formatting

This fixes clang-format not formatting if fallback-style is explicitly set to
"none", and either a config file is found or YAML is passed in without a
"BasedOnStyle". With this change, passing "none" in these cases will have no
affect, and LLVM style will be used as the base style.

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

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/test/Format/style-on-command-line.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=292562=292561=292562=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Thu Jan 19 19:22:42 2017
@@ -1888,8 +1888,8 @@ static FormatStyle::LanguageKind getLang
 }

 llvm::Expected getStyle(StringRef StyleName, StringRef FileName,
- StringRef FallbackStyle, StringRef Code,
- vfs::FileSystem *FS) {
+ StringRef FallbackStyleName,
+ StringRef Code, vfs::FileSystem *FS) {
   if (!FS) {
 FS = vfs::getRealFileSystem().get();
   }
@@ -1903,9 +1903,9 @@ llvm::Expected getStyle(Str
   (Code.contains("\n- (") || Code.contains("\n+ (")))
 Style.Language = FormatStyle::LK_ObjC;

-  // FIXME: If FallbackStyle is explicitly "none", format is disabled.
-  if (!getPredefinedStyle(FallbackStyle, Style.Language, ))
-return make_string_error("Invalid fallback style \"" + 
FallbackStyle.str());
+  FormatStyle FallbackStyle = getNoStyle();
+  if (!getPredefinedStyle(FallbackStyleName, Style.Language, ))
+return make_string_error("Invalid fallback style \"" + FallbackStyleName);

   if (StyleName.startswith("{")) {
 // Parse YAML/JSON style from the command line.
@@ -1977,7 +1977,7 @@ llvm::Expected getStyle(Str
 return make_string_error("Configuration file(s) do(es) not support " +
  getLanguageName(Style.Language) + ": " +
  UnsuitableConfigFiles);
-  return Style;
+  return FallbackStyle;
 }

 } // namespace format

Modified: cfe/trunk/test/Format/style-on-command-line.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/style-on-command-line.cpp?rev=292562=292561=292562=diff
==
--- cfe/trunk/test/Format/style-on-command-line.cpp (original)
+++ cfe/trunk/test/Format/style-on-command-line.cpp Thu Jan 19 19:22:42 2017
@@ -11,6 +11,21 @@
 // RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s | FileCheck 
-strict-whitespace -check-prefix=CHECK7 %s
 // RUN: clang-format -style="{BasedOnStyle: LLVM, PointerBindsToType: true}" 
%s | FileCheck -strict-whitespace -check-prefix=CHECK8 %s
 // RUN: clang-format -style="{BasedOnStyle: WebKit, PointerBindsToType: 
false}" %s | FileCheck -strict-whitespace -check-prefix=CHECK9 %s
+
+// Fallback style tests
+// RUN: rm %T/_clang-format
+// Test no config file found, WebKit fallback style is applied
+// RUN: clang-format -style=file -fallback-style=WebKit -assume-filename=%T/foo.cpp < 
%s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK10 %s
+// Test no config file and no fallback style, LLVM style is applied
+// RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s 2>&1 | 
FileCheck -strict-whitespace -check-prefix=CHECK11 %s
+// Test no config file and fallback style "none", no formatting is applied
+// RUN: clang-format -style=file -fallback-style=none -assume-filename=%T/foo.cpp < 
%s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK12 %s
+// Test config file with no based style, and fallback style "none", formatting 
is applied
+// RUN: printf "IndentWidth: 6\n" > %T/_clang-format
+// RUN: clang-format -style=file -fallback-style=none -assume-filename=%T/foo.cpp < 
%s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK13 %s
+// Test yaml with no based style, and fallback style "none", LLVM formatting 
applied
+// RUN: clang-format -style="{IndentWidth: 7}" 

[PATCH] D28943: [clang-format] Remove redundant test in style-on-command-line.cpp

2017-01-20 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

@amaiorano: The test itself is correct. It's just that this test failed in our 
internal test. We could've fixed it internally, but the fix would be ugly. 
Since the intended behavior is already covered in the case above it, and it's 
really just checking the default fallback style is LLVM, which is not related 
to the original change, I think it makes sense to get rid of the case. Hope you 
don't mind :)


https://reviews.llvm.org/D28943



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28941: Remove 'RUN: false' from Driver/response-file.c

2017-01-20 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292600: Remove 'RUN: false' from Driver/response-file.c 
(authored by krasimir).

Changed prior to commit:
  https://reviews.llvm.org/D28941?vs=85111=85114#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28941

Files:
  cfe/trunk/test/Driver/response-file.c


Index: cfe/trunk/test/Driver/response-file.c
===
--- cfe/trunk/test/Driver/response-file.c
+++ cfe/trunk/test/Driver/response-file.c
@@ -1,7 +1,5 @@
 // REQUIRES: long_tests
 
-// RUN: false
-
 // Check that clang is able to process short response files
 // Since this is a short response file, clang must not use a response file
 // to pass its parameters to other tools. This is only necessary for a large


Index: cfe/trunk/test/Driver/response-file.c
===
--- cfe/trunk/test/Driver/response-file.c
+++ cfe/trunk/test/Driver/response-file.c
@@ -1,7 +1,5 @@
 // REQUIRES: long_tests
 
-// RUN: false
-
 // Check that clang is able to process short response files
 // Since this is a short response file, clang must not use a response file
 // to pass its parameters to other tools. This is only necessary for a large
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r292600 - Remove 'RUN: false' from Driver/response-file.c

2017-01-20 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Fri Jan 20 05:06:58 2017
New Revision: 292600

URL: http://llvm.org/viewvc/llvm-project?rev=292600=rev
Log:
Remove 'RUN: false' from Driver/response-file.c

Summary:
It seems that rL292518 introduced a RUN: false, but the continuation rL292545
forgot to remove it back.

This has flown under the radar, because it's a long test and doesn't get
executed by default during sanity testing.

To test:
$ cd llvm_build
$ ./bin/llvm-lit --param run_long_tests=true 
tools/clang/test/Driver/response-file.c

@rsmith: have a look if this change is OK please.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits, rsmith

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

Modified:
cfe/trunk/test/Driver/response-file.c

Modified: cfe/trunk/test/Driver/response-file.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/response-file.c?rev=292600=292599=292600=diff
==
--- cfe/trunk/test/Driver/response-file.c (original)
+++ cfe/trunk/test/Driver/response-file.c Fri Jan 20 05:06:58 2017
@@ -1,7 +1,5 @@
 // REQUIRES: long_tests
 
-// RUN: false
-
 // Check that clang is able to process short response files
 // Since this is a short response file, clang must not use a response file
 // to pass its parameters to other tools. This is only necessary for a large


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28941: Remove 'RUN: false' from Driver/response-file.c

2017-01-20 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

@bkramer: yes, it passes with RUN: false removed


https://reviews.llvm.org/D28941



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >