[PATCH] D30214: [Driver] Search for libc++ headers in ResourceDir

2017-03-02 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld abandoned this revision.
Hahnfeld added a comment.

http://lists.llvm.org/pipermail/cfe-dev/2017-January/052512.html suggested to 
install runtime libraries (like libomp, but I think libc++ in certain cases may 
fall under the same category) to ResourceDir and I wanted the headers to be 
co-located. However, I can live with installing them to normal include


https://reviews.llvm.org/D30214



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


[PATCH] D30547: [clang-tidy] Forwarding reference overload in constructors

2017-03-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp:23
+AST_MATCHER(QualType, isEnableIf) {
+  auto checkTemplate = [](const TemplateSpecializationType *Spec) {
+if (!Spec || !Spec->getTemplateName().getAsTemplateDecl()) {

This should be `CheckTemplate` per our usual coding conventions.



Comment at: clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp:39
+  // Case: type parameter dependent (enable_if).
+  if (auto Dependent = BaseType->getAs()) {
+BaseType = Dependent->getQualifier()->getAsType();

Please use `auto *` (or `const auto ``).



Comment at: clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp:44
+return true; // Case: enable_if_t< >.
+  } else if (auto Elaborated = BaseType->getAs()) {
+if (auto Qualifier = Elaborated->getQualifier()->getAsType()) {

Same here.



Comment at: clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp:119
+  if (const auto *Ctor = Result.Nodes.getNodeAs("ctor")) {
+auto Iter = Ctor->param_begin();
+for (++Iter; Iter != Ctor->param_end(); ++Iter) {

I think this can be lowered into the for loop as `auto Iter = 
Ctor->param_begin() + 1`.


Repository:
  rL LLVM

https://reviews.llvm.org/D30547



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


[PATCH] D30111: [clang-format] Add a test to check at once all the Mozilla coding style

2017-03-02 Thread Daniel Jasper via Phabricator via cfe-commits
djasper requested changes to this revision.
djasper added a comment.
This revision now requires changes to proceed.

So, while it might be convenient to view this all in one file, a test here is 
not convenient for me (or presumably other clang-format developers) to work 
with. You can make a pretty much 1:1 copy of it using a raw string literal in 
unittests. However, I don't think this is actually a good idea.

Over the years of working on clang-format we have discovered that you really 
need unittests and try to make them as specific about what you are trying to 
test as possible. There are many things in you patch, where you test really 
complex expressions that:

- I can envision arbitrary other changes to formatting that you wouldn't care 
about.
- Are much harder to debug for the specific issue than necessary, i.e. if 
something breaks, I'd have to reduce the test case further.

In general, I think this test adds very little on top of unittests we have for 
each single thing you configure in Mozilla style. I think the value added is 
that the combination of style flags used for Mozilla does work. But for that, 
really create a unittest that tests all the aspects of Mozilla style you care 
about with individual verifyFormat.. statements.


https://reviews.llvm.org/D30111



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


[PATCH] D29704: [XRay] [clang] Allow logging the first argument of a function call.

2017-03-02 Thread Martin Pelikán via Phabricator via cfe-commits
pelikan updated this revision to Diff 90431.
pelikan marked an inline comment as done.
pelikan added a comment.

- clarify comment and rename variable so it'll all fit.


https://reviews.llvm.org/D29704

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/CodeGenFunction.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/xray-log-args.cpp
  test/Sema/xray-log-args-oob.c
  test/Sema/xray-log-args-oob.cpp

Index: test/Sema/xray-log-args-oob.cpp
===
--- /dev/null
+++ test/Sema/xray-log-args-oob.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c++11 -x c++
+void foo [[clang::xray_log_args(1)]] (int);
+struct [[clang::xray_log_args(1)]] a { int x; }; // expected-warning {{'xray_log_args' attribute only applies to functions and methods}}
+
+void fop [[clang::xray_log_args(1)]] (); // expected-error {{'xray_log_args' attribute parameter 1 is out of bounds}}
+
+void foq [[clang::xray_log_args(-1)]] (); // expected-error {{'xray_log_args' attribute parameter 1 is out of bounds}}
+
+void fos [[clang::xray_log_args(0)]] (); // expected-error {{'xray_log_args' attribute parameter 1 is out of bounds}}
Index: test/Sema/xray-log-args-oob.c
===
--- /dev/null
+++ test/Sema/xray-log-args-oob.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c11
+void foo(int) __attribute__((xray_log_args(1)));
+struct __attribute__((xray_log_args(1))) a { int x; }; // expected-warning {{'xray_log_args' attribute only applies to functions and methods}}
+
+void fop() __attribute__((xray_log_args(1))); // expected-error {{'xray_log_args' attribute parameter 1 is out of bounds}}
+
+void foq() __attribute__((xray_log_args(-1))); // expected-error {{'xray_log_args' attribute parameter 1 is out of bounds}}
+
+void fos() __attribute__((xray_log_args(0))); // expected-error {{'xray_log_args' attribute parameter 1 is out of bounds}}
Index: test/CodeGen/xray-log-args.cpp
===
--- /dev/null
+++ test/CodeGen/xray-log-args.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument,clang::xray_log_args(1)]] void foo(int a) {
+// CHECK: define void @_Z3fooi(i32 %a) #0
+};
+
+[[clang::xray_log_args(1)]] void bar(int a) {
+// CHECK: define void @_Z3bari(i32 %a) #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"{{.*}}"xray-log-args"="1"
+// CHECK-NOT: #1 = {{.*}}"xray-log-args"="1"
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4424,6 +4424,19 @@
 Attr.getAttributeSpellingListIndex()));
 }
 
+static void handleXRayLogArgsAttr(Sema , Decl *D,
+  const AttributeList ) {
+  uint64_t ArgCount;
+  if (!checkFunctionOrMethodParameterIndex(S, D, Attr, 1, Attr.getArgAsExpr(0),
+   ArgCount))
+return;
+
+  // ArgCount isn't a parameter index [0;n), it's a count [1;n] - hence + 1.
+  D->addAttr(::new (S.Context)
+ XRayLogArgsAttr(Attr.getRange(), S.Context, ++ArgCount,
+ Attr.getAttributeSpellingListIndex()));
+}
+
 //===--===//
 // Checker-specific attribute handlers.
 //===--===//
@@ -6285,6 +6298,9 @@
   case AttributeList::AT_XRayInstrument:
 handleSimpleAttribute(S, D, Attr);
 break;
+  case AttributeList::AT_XRayLogArgs:
+handleXRayLogArgsAttr(S, D, Attr);
+break;
   }
 }
 
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -779,6 +779,10 @@
 Fn->addFnAttr("function-instrument", "xray-always");
   if (XRayAttr->neverXRayInstrument())
 Fn->addFnAttr("function-instrument", "xray-never");
+  if (const auto *LogArgs = D->getAttr()) {
+Fn->addFnAttr("xray-log-args",
+  llvm::utostr(LogArgs->getArgumentCount()));
+  }
 } else {
   Fn->addFnAttr(
   "xray-instruction-threshold",
Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -2862,13 +2862,15 @@
 
 def XRayDocs : Documentation {
   let Category = DocCatFunction;
-  let Heading = "xray_always_instrument (clang::xray_always_instrument), xray_never_instrument (clang::xray_never_instrument)";
+  let Heading = 

[libcxx] r296854 - Clean up more usages of _LIBCPP_HAS_NO_RVALUE_REFERENCES

2017-03-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Mar  2 21:43:25 2017
New Revision: 296854

URL: http://llvm.org/viewvc/llvm-project?rev=296854=rev
Log:
Clean up more usages of _LIBCPP_HAS_NO_RVALUE_REFERENCES

Modified:

libcxx/trunk/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp

libcxx/trunk/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp

libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp

libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp

libcxx/trunk/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp

libcxx/trunk/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.unique_future/move_assign.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.unique_future/move_ctor.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp

libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp

libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp

Modified: 
libcxx/trunk/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op%3D/rv_value.pass.cpp?rev=296854=296853=296854=diff
==
--- 
libcxx/trunk/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp
 Thu Mar  2 21:43:25 2017
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03
+
 // 
 
 // back_insert_iterator
@@ -17,8 +19,6 @@
 
 #include 
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
 #include 
 #include 
 #include 
@@ -32,11 +32,7 @@ test(C c)
 assert(c.back() == typename C::value_type());
 }
 
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
 int main()
 {
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 test(std::vector());
-#endif
 }

Modified: 
libcxx/trunk/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op%3D/rv_value.pass.cpp?rev=296854=296853=296854=diff
==
--- 
libcxx/trunk/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp
 Thu Mar  2 21:43:25 2017
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03
+
 // 
 
 // front_insert_iterator
@@ -15,9 +17,6 @@
 //   operator=(Cont::value_type&& value);
 
 #include 
-
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
 #include 
 #include 
 #include 
@@ -31,11 +30,7 @@ test(C c)
 assert(c.front() == typename C::value_type());
 }
 
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
 int main()
 {
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 test(std::list());
-#endif
 }

Modified: 
libcxx/trunk/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op%3D/rv_value.pass.cpp?rev=296854=296853=296854=diff
==
--- 
libcxx/trunk/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp
 Thu Mar  2 21:43:25 2017
@@ -7,6 +7,8 @@
 //
 

[libcxx] r296851 - Fix sign-compare warning in test; Oddly this only appears on OS X

2017-03-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Mar  2 20:02:07 2017
New Revision: 296851

URL: http://llvm.org/viewvc/llvm-project?rev=296851=rev
Log:
Fix sign-compare warning in test; Oddly this only appears on OS X

Modified:

libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp?rev=296851=296850=296851=diff
==
--- 
libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp
 Thu Mar  2 20:02:07 2017
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03
+
 // 
 
 // forward_list(forward_list&& x, const allocator_type& a);
@@ -21,7 +23,6 @@
 
 int main()
 {
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 {
 typedef MoveOnly T;
 typedef test_allocator A;
@@ -33,7 +34,7 @@ int main()
 unsigned n = 0;
 for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
 assert(*i == n);
-assert(n == std::end(t) - std::begin(t));
+assert(n == static_cast(std::end(t) - std::begin(t)));
 assert(c0.empty());
 assert(c.get_allocator() == A(10));
 }
@@ -48,11 +49,10 @@ int main()
 unsigned n = 0;
 for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
 assert(*i == n);
-assert(n == std::end(t) - std::begin(t));
+assert(n == static_cast(std::end(t) - std::begin(t)));
 assert(!c0.empty());
 assert(c.get_allocator() == A(9));
 }
-#if TEST_STD_VER >= 11
 {
 typedef MoveOnly T;
 typedef min_allocator A;
@@ -64,10 +64,8 @@ int main()
 unsigned n = 0;
 for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
 assert(*i == n);
-assert(n == std::end(t) - std::begin(t));
+assert(n == static_cast(std::end(t) - std::begin(t)));
 assert(c0.empty());
 assert(c.get_allocator() == A());
 }
-#endif
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 }


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


[PATCH] D30341: [analyzer] clarify error messages about uninitialized function arguments

2017-03-02 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp:211
   // Generate a report for this bug.
-  StringRef Desc =
-  describeUninitializedArgumentInCall(Call, IsFirstArgument);
+  std::string Desc =
+  describeUninitializedArgumentInCall(Call, ArgumentNumber);

danielmarjamaki wrote:
> zaks.anna wrote:
> > danielmarjamaki wrote:
> > > zaks.anna wrote:
> > > > Have you considered using  llvm::raw_svector_ostream here as well as 
> > > > passing it an argument to describeUninitializedArgumentInCall? For 
> > > > example, see  MallocChecker.cpp.
> > > I changed so describeUninitializedArgumentInCall() returns an llvm::Twine 
> > > instead of std::string. hope you like it.
> > > 
> > I do not think it's safe to use llvm:Twine here. See 
> > http://llvm.org/docs/ProgrammersManual.html#the-twine-class
> > 
> > How about using llvm::raw_svector_ostream as I suggested?
> sure I can use llvm::raw_svector_ostream instead. I can try to update the 
> patch soon.
> 
> I just wonder how it is unsafe. I did consider if llvm::Twine would be safe. 
> Is there a particular return that you can point out? The function mostly 
> returns constant string literals. Those should be safe right? Then the 
> function also have a few returns like this:
> ```
> return llvm::Twine(ArgumentNumber + 1) +
>llvm::getOrdinalSuffix(ArgumentNumber + 1) +
>" function call argument is an uninitialized value";
> ```
> Yes we need to be careful for such code. However since 
> llvm::getOrdinalSuffix() returns a StringRef this particular code should be 
> safe right?
> 
> When the stream is used I have to tweak each return statement. I thought that 
> was a bit unfortunate. But it's not a biggie.
> 
After some more reading in the llvm::Twine docs I am also thinking that I 
misuse it. so I will change the code.


Repository:
  rL LLVM

https://reviews.llvm.org/D30341



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


[PATCH] D30406: [Analyzer] Add support for displaying cross-file diagnostic paths in HTML output

2017-03-02 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

>   I’ve added the single file output option but I would like to keep the 
> multi-file option default

This sounds good to me! I agree that this is a very useful addition.


https://reviews.llvm.org/D30406



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


[PATCH] D30551: [AMDGPU] Add builtin functions readlane ds_permute mov_dpp

2017-03-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 90399.
yaxunl added a comment.

Make some arguments constant.


https://reviews.llvm.org/D30551

Files:
  include/clang/Basic/BuiltinsAMDGPU.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGenOpenCL/builtins-amdgcn.cl
  test/SemaOpenCL/builtins-amdgcn-error.cl

Index: test/SemaOpenCL/builtins-amdgcn-error.cl
===
--- test/SemaOpenCL/builtins-amdgcn-error.cl
+++ test/SemaOpenCL/builtins-amdgcn-error.cl
@@ -92,3 +92,11 @@
 {
   *out = __builtin_amdgcn_s_getreg(a); // expected-error {{argument to '__builtin_amdgcn_s_getreg' must be a constant integer}}
 }
+
+void test_mov_dpp(global int* out, int a, int b, int c, int d, bool e)
+{
+  *out = __builtin_amdgcn_mov_dpp(a, b, 0, 0, false); // expected-error {{argument to '__builtin_amdgcn_mov_dpp' must be a constant integer}}
+  *out = __builtin_amdgcn_mov_dpp(a, 0, c, 0, false); // expected-error {{argument to '__builtin_amdgcn_mov_dpp' must be a constant integer}}
+  *out = __builtin_amdgcn_mov_dpp(a, 0, 0, d, false); // expected-error {{argument to '__builtin_amdgcn_mov_dpp' must be a constant integer}}
+  *out = __builtin_amdgcn_mov_dpp(a, 0, 0, 0, e); // expected-error {{argument to '__builtin_amdgcn_mov_dpp' must be a constant integer}}
+}
Index: test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn.cl
+++ test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -235,6 +235,41 @@
   *out = __builtin_amdgcn_ds_swizzle(a, 32);
 }
 
+// CHECK-LABEL: @test_ds_permute
+// CHECK: call i32 @llvm.amdgcn.ds.permute.i32(i32 %a, i32 %b)
+void test_ds_permute(global int* out, int a, int b)
+{
+  *out = __builtin_amdgcn_ds_permute(a, b);
+}
+
+// CHECK-LABEL: @test_ds_bpermute
+// CHECK: call i32 @llvm.amdgcn.ds.bpermute.i32(i32 %a, i32 %b)
+void test_ds_bpermute(global int* out, int a, int b)
+{
+  *out = __builtin_amdgcn_ds_bpermute(a, b);
+}
+
+// CHECK-LABEL: @test_readfirstlane
+// CHECK: call i32 @llvm.amdgcn.readfirstlane(i32 %a)
+void test_readfirstlane(global int* out, int a)
+{
+  *out = __builtin_amdgcn_readfirstlane(a);
+}
+
+// CHECK-LABEL: @test_readlane
+// CHECK: call i32 @llvm.amdgcn.readlane(i32 %a, i32 %b)
+void test_readlane(global int* out, int a, int b)
+{
+  *out = __builtin_amdgcn_readlane(a, b);
+}
+
+// CHECK-LABEL: @test_mov_dpp
+// CHECK: call i32 @llvm.amdgcn.mov.dpp.i32(i32 %src, i32 0, i32 0, i32 0, i1 false)
+void test_mov_dpp(global int* out, int src)
+{
+  *out = __builtin_amdgcn_mov_dpp(src, 0, 0, 0, false);
+}
+
 // CHECK-LABEL: @test_fcmp_f32
 // CHECK: call i64 @llvm.amdgcn.fcmp.f32(float %a, float %b, i32 5)
 void test_fcmp_f32(global ulong* out, float a, float b)
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -8388,6 +8388,22 @@
 
   case AMDGPU::BI__builtin_amdgcn_ds_swizzle:
 return emitBinaryBuiltin(*this, E, Intrinsic::amdgcn_ds_swizzle);
+  case AMDGPU::BI__builtin_amdgcn_ds_permute:
+return emitBinaryBuiltin(*this, E, Intrinsic::amdgcn_ds_permute);
+  case AMDGPU::BI__builtin_amdgcn_ds_bpermute:
+return emitBinaryBuiltin(*this, E, Intrinsic::amdgcn_ds_bpermute);
+  case AMDGPU::BI__builtin_amdgcn_readfirstlane:
+return emitUnaryBuiltin(*this, E, Intrinsic::amdgcn_readfirstlane);
+  case AMDGPU::BI__builtin_amdgcn_readlane:
+return emitBinaryBuiltin(*this, E, Intrinsic::amdgcn_readlane);
+  case AMDGPU::BI__builtin_amdgcn_mov_dpp: {
+llvm::SmallVector Args;
+for (unsigned I = 0; I != 5; ++I)
+  Args.push_back(EmitScalarExpr(E->getArg(I)));
+Value *F = CGM.getIntrinsic(Intrinsic::amdgcn_mov_dpp,
+Args[0]->getType());
+return Builder.CreateCall(F, Args);
+  }
   case AMDGPU::BI__builtin_amdgcn_div_fixup:
   case AMDGPU::BI__builtin_amdgcn_div_fixupf:
   case AMDGPU::BI__builtin_amdgcn_div_fixuph:
Index: include/clang/Basic/BuiltinsAMDGPU.def
===
--- include/clang/Basic/BuiltinsAMDGPU.def
+++ include/clang/Basic/BuiltinsAMDGPU.def
@@ -86,6 +86,11 @@
 BUILTIN(__builtin_amdgcn_fcmp, "LUiddIi", "nc")
 BUILTIN(__builtin_amdgcn_fcmpf, "LUiffIi", "nc")
 BUILTIN(__builtin_amdgcn_ds_swizzle, "iiIi", "nc")
+BUILTIN(__builtin_amdgcn_ds_permute, "iii", "nc")
+BUILTIN(__builtin_amdgcn_ds_bpermute, "iii", "nc")
+BUILTIN(__builtin_amdgcn_readfirstlane, "ii", "nc")
+BUILTIN(__builtin_amdgcn_readlane, "iii", "nc")
+BUILTIN(__builtin_amdgcn_mov_dpp, "iiIiIiIiIb", "nc")
 BUILTIN(__builtin_amdgcn_fmed3f, "", "nc")
 
 //===--===//
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30406: [Analyzer] Add support for displaying cross-file diagnostic paths in HTML output

2017-03-02 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich added inline comments.



Comment at: lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp:211
+
+  if (I + 1 != E) {
+os << "getHashValue()

Is there a cleaner way to do these two comparisons?


https://reviews.llvm.org/D30406



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


[PATCH] D30406: [Analyzer] Add support for displaying cross-file diagnostic paths in HTML output

2017-03-02 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich updated this revision to Diff 90417.
vlad.tsyrklevich edited the summary of this revision.
vlad.tsyrklevich added a comment.

Updated the formatting to make the file split more obvious (padding/line break 
height) and added simple navigation across files, example here: 
https://rawgit.com/vlad902/4aaa4e5e7a777b7098337370791352d7/raw/fc88cef667935e1eeae492b15590c18516e645dd/report.html

@NoQ: I had not thought about deduplication. I looked at scan-build and it 
looks like it currently de-dups based on MD5 matches of the HTML files. The 
simple case of multi-file reports with the same MD5 (e.g. because of repeated 
compilations of a single file during a build) being deduplicated still works 
correctly.

I also looked at what would happen if two separate C files include a common 
header file that only generates a report with -analyzer-opt-analyze-headers 
specified (e.g. if the path originates in the header file and doesn’t traverse 
the main C file at all.) This generated zero reports! My logic assumed the main 
file would always be included in the path and threw away 
-analyzer-opt-analyze-headers reports incorrectly. I was able to fix the logic 
such that these reports are correctly generated and also properly deduplicated 
by structuring the reports such that the main C file source is not included if 
it’s not traversed in the path.

@zaks.anna: I’ve added the single file output option but I would like to keep 
the multi-file option default—I suspect there are very few users parsing the 
HTML manually when plist is available and I’d like to ensure people don’t miss 
any results or have to dig into the source to understand they needed something 
other than the default output setting. What do you think?


https://reviews.llvm.org/D30406

Files:
  include/clang/StaticAnalyzer/Core/Analyses.def
  lib/Rewrite/HTMLRewrite.cpp
  lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  test/Analysis/diagnostics/diag-cross-file-boundaries.c
  test/Analysis/diagnostics/diag-cross-file-boundaries.h
  test/Analysis/html-diag-singlefile.c
  test/Analysis/html-diag-singlefile.h
  test/Analysis/html-diags-analyze-headers.c
  test/Analysis/html-diags-analyze-headers.h
  test/Analysis/html-diags-multifile.c
  test/Analysis/html-diags.c
  test/Coverage/html-diagnostics.c
  test/Coverage/html-multifile-diagnostics.c
  test/Coverage/html-multifile-diagnostics.h
  www/analyzer/open_projects.html

Index: www/analyzer/open_projects.html
===
--- www/analyzer/open_projects.html
+++ www/analyzer/open_projects.html
@@ -107,13 +107,6 @@
 
   Bug Reporting 
   
-Add support for displaying cross-file diagnostic paths in HTML output
-(used by scan-build).
-Currently scan-build output does not display reports that span 
-multiple files. The main problem is that we do not have a good format to
-display such paths in HTML output. (Difficulty: Medium) 
-
-
 Refactor path diagnostic generation in http://clang.llvm.org/doxygen/BugReporter_8cpp_source.html;>BugReporter.cpp.
 It would be great to have more code reuse between "Minimal" and 
 "Extensive" PathDiagnostic generation algorithms. One idea is to create an 
Index: test/Coverage/html-multifile-diagnostics.h
===
--- /dev/null
+++ test/Coverage/html-multifile-diagnostics.h
@@ -0,0 +1,3 @@
+void f1(int *ptr) {
+  *ptr = 0;
+}
Index: test/Coverage/html-multifile-diagnostics.c
===
--- /dev/null
+++ test/Coverage/html-multifile-diagnostics.c
@@ -0,0 +1,21 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %t %s
+// RUN: find %t -name "*.html" -exec cat "{}" ";" | FileCheck %s
+
+// REQUIRES: staticanalyzer
+
+// CHECK: Annotated Source Code
+
+// Make sure it's generated as multi-file HTML output
+// CHECK: {{.*}}html-multifile-diagnostics.c
+// CHECK: {{.*}}html-multifile-diagnostics.h
+
+// Without tweaking expr, the expr would hit to the line below
+// emitted to the output as comment.
+// CHECK: {{[D]ereference of null pointer}}
+
+#include "html-multifile-diagnostics.h"
+
+void f0() {
+  f1((int*)0);
+}
Index: test/Coverage/html-diagnostics.c
===
--- test/Coverage/html-diagnostics.c
+++ test/Coverage/html-diagnostics.c
@@ -1,11 +1,18 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %t %s
 // RUN: find %t -name "*.html" -exec cat "{}" ";" | FileCheck %s
+//
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -analyze -analyzer-output=html-single-file -analyzer-checker=core -o %t %s
+// RUN: find %t -name "*.html" -exec cat "{}" ";" | FileCheck %s
 
 // REQUIRES: staticanalyzer
 
 // CHECK: Annotated Source Code
 
+// Make sure it's not generated as a multi-file HTML output
+// CHECK-NOT: {{.*}}
+
 // Without 

[PATCH] D30518: Fix msc-version.c test to handle _MSC_VER=1910

2017-03-02 Thread Dave Bartolomeo via Phabricator via cfe-commits
DaveBartolomeo closed this revision.
DaveBartolomeo added a comment.

269843


https://reviews.llvm.org/D30518



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


r296843 - Fix msc-version.c test to handle _MSC_VER=1910

2017-03-02 Thread Dave Bartolomeo via cfe-commits
Author: dbartol
Date: Thu Mar  2 18:08:55 2017
New Revision: 296843

URL: http://llvm.org/viewvc/llvm-project?rev=296843=rev
Log:
Fix msc-version.c test to handle _MSC_VER=1910

Previously, VC++ has always set _MSC_VER to a four-digit value with the two 
least significant digits set to zero. Visual Studio 2017, however, sets 
_MSC_VER=1910, and we expect to update the least significant digit as we 
release major updates for VS 2017. This patch fixes the msc-version.c test to 
handle non-zero values in the two least significant digits of _MSC_VER.

Modified:
cfe/trunk/test/Driver/msc-version.c

Modified: cfe/trunk/test/Driver/msc-version.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/msc-version.c?rev=296843=296842=296843=diff
==
--- cfe/trunk/test/Driver/msc-version.c (original)
+++ cfe/trunk/test/Driver/msc-version.c Thu Mar  2 18:08:55 2017
@@ -63,4 +63,4 @@
 
 // CHECK-MS-EXTENSIONS: _MSC_BUILD 1
 // CHECK-MS-EXTENSIONS: _MSC_FULL_VER {{.+}}
-// CHECK-MS-EXTENSIONS: _MSC_VER {{..}}00
+// CHECK-MS-EXTENSIONS: _MSC_VER {{}}


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


[PATCH] D30373: [analyzer] NFC: Update test infrastructure to support multiple constraint managers

2017-03-02 Thread Dominic Chen via Phabricator via cfe-commits
ddcc reopened this revision.
ddcc added a comment.
This revision is now accepted and ready to land.

Made a mistake with the last commit, I believe this should be fine now?


Repository:
  rL LLVM

https://reviews.llvm.org/D30373



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


[PATCH] D30551: [AMDGPU] Add builtin functions readlane ds_permute mov_dpp

2017-03-02 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In https://reviews.llvm.org/D30551#691149, @b-sumner wrote:

> mov_dpp should be under the VI+ comment


Also should be made to use TARGET_BUILTIN and dependent on dpp feature


https://reviews.llvm.org/D30551



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


[libcxx] r296840 - Work around test failure on 32 bit OS X

2017-03-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Mar  2 17:18:40 2017
New Revision: 296840

URL: http://llvm.org/viewvc/llvm-project?rev=296840=rev
Log:
Work around test failure on 32 bit OS X

Modified:

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp?rev=296840=296839=296840=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp
 Thu Mar  2 17:18:40 2017
@@ -29,16 +29,22 @@ test(S s, typename S::size_type pos1, ty
  SV sv, typename S::size_type pos2, typename S::size_type n2,
  S expected)
 {
+typedef typename S::size_type SizeT;
 static_assert((!std::is_same::value), "");
-const typename S::size_type old_size = s.size();
+
+// String and string_view may not always share the same size type,
+// but both types should have the same size (ex. int vs long)
+static_assert(sizeof(SizeT) == sizeof(typename SV::size_type), "");
+
+const SizeT old_size = s.size();
 S s0 = s;
 if (pos1 <= old_size && pos2 <= sv.size())
 {
 s.replace(pos1, n1, sv, pos2, n2);
 LIBCPP_ASSERT(s.__invariants());
 assert(s == expected);
-typename S::size_type xlen = std::min(n1, old_size - pos1);
-typename S::size_type rlen = std::min(n2, sv.size() - pos2);
+SizeT xlen = std::min(n1, old_size - pos1);
+SizeT rlen = std::min(n2, sv.size() - pos2);
 assert(s.size() == old_size - xlen + rlen);
 }
 #ifndef TEST_HAS_NO_EXCEPTIONS
@@ -64,16 +70,17 @@ test_npos(S s, typename S::size_type pos
   SV sv, typename S::size_type pos2,
   S expected)
 {
+typedef typename S::size_type SizeT;
 static_assert((!std::is_same::value), "");
-const typename S::size_type old_size = s.size();
+const SizeT old_size = s.size();
 S s0 = s;
 if (pos1 <= old_size && pos2 <= sv.size())
 {
 s.replace(pos1, n1, sv, pos2);
 LIBCPP_ASSERT(s.__invariants());
 assert(s == expected);
-typename S::size_type xlen = std::min(n1, old_size - pos1);
-typename S::size_type rlen = std::min(S::npos, sv.size() - pos2);
+SizeT xlen = std::min(n1, old_size - pos1);
+SizeT rlen = std::min(S::npos, sv.size() - pos2);
 assert(s.size() == old_size - xlen + rlen);
 }
 #ifndef TEST_HAS_NO_EXCEPTIONS


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


[PATCH] D30551: [AMDGPU] Add builtin functions readlane ds_permute mov_dpp

2017-03-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:8391-8398
+  case AMDGPU::BI__builtin_amdgcn_ds_permute:
+return emitBinaryBuiltin(*this, E, Intrinsic::amdgcn_ds_permute);
+  case AMDGPU::BI__builtin_amdgcn_ds_bpermute:
+return emitBinaryBuiltin(*this, E, Intrinsic::amdgcn_ds_bpermute);
+  case AMDGPU::BI__builtin_amdgcn_readfirstlane:
+return emitUnaryBuiltin(*this, E, Intrinsic::amdgcn_readfirstlane);
+  case AMDGPU::BI__builtin_amdgcn_readlane:

arsenm wrote:
> Since these don't have mangling, you could add GCCBuiltin to the intrinsic 
> definition and then you wouldn't need these to be handled here
If I remove these, there will be error:

cannot compile this builtin function yet





https://reviews.llvm.org/D30551



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


[PATCH] D30551: [AMDGPU] Add builtin functions readlane ds_permute mov_dpp

2017-03-02 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:8391-8398
+  case AMDGPU::BI__builtin_amdgcn_ds_permute:
+return emitBinaryBuiltin(*this, E, Intrinsic::amdgcn_ds_permute);
+  case AMDGPU::BI__builtin_amdgcn_ds_bpermute:
+return emitBinaryBuiltin(*this, E, Intrinsic::amdgcn_ds_bpermute);
+  case AMDGPU::BI__builtin_amdgcn_readfirstlane:
+return emitUnaryBuiltin(*this, E, Intrinsic::amdgcn_readfirstlane);
+  case AMDGPU::BI__builtin_amdgcn_readlane:

yaxunl wrote:
> arsenm wrote:
> > Since these don't have mangling, you could add GCCBuiltin to the intrinsic 
> > definition and then you wouldn't need these to be handled here
> If I remove these, there will be error:
> 
> cannot compile this builtin function yet
> 
> 
> 
Yes, the GCCBuiltin isn't on the intrinsic declaration in llvm. If you fix that 
you shouldn't see that


https://reviews.llvm.org/D30551



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


[PATCH] D30551: [AMDGPU] Add builtin functions readlane ds_permute mov_dpp

2017-03-02 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added a comment.

mov_dpp should be under the VI+ comment


https://reviews.llvm.org/D30551



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


[PATCH] D30373: [analyzer] NFC: Update test infrastructure to support multiple constraint managers

2017-03-02 Thread Dominic Chen via Phabricator via cfe-commits
ddcc reopened this revision.
ddcc added a comment.
This revision is now accepted and ready to land.

You're right about the failure being specific to Windows, I'll roll back to the 
original implementation in `lit.local.cfg` and just skip on Windows.


Repository:
  rL LLVM

https://reviews.llvm.org/D30373



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


[PATCH] D30551: [AMDGPU] Add builtin functions readlane ds_permute mov_dpp

2017-03-02 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:8391-8398
+  case AMDGPU::BI__builtin_amdgcn_ds_permute:
+return emitBinaryBuiltin(*this, E, Intrinsic::amdgcn_ds_permute);
+  case AMDGPU::BI__builtin_amdgcn_ds_bpermute:
+return emitBinaryBuiltin(*this, E, Intrinsic::amdgcn_ds_bpermute);
+  case AMDGPU::BI__builtin_amdgcn_readfirstlane:
+return emitUnaryBuiltin(*this, E, Intrinsic::amdgcn_readfirstlane);
+  case AMDGPU::BI__builtin_amdgcn_readlane:

Since these don't have mangling, you could add GCCBuiltin to the intrinsic 
definition and then you wouldn't need these to be handled here


https://reviews.llvm.org/D30551



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


[PATCH] D30341: [analyzer] clarify error messages about uninitialized function arguments

2017-03-02 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp:211
   // Generate a report for this bug.
-  StringRef Desc =
-  describeUninitializedArgumentInCall(Call, IsFirstArgument);
+  std::string Desc =
+  describeUninitializedArgumentInCall(Call, ArgumentNumber);

zaks.anna wrote:
> danielmarjamaki wrote:
> > zaks.anna wrote:
> > > Have you considered using  llvm::raw_svector_ostream here as well as 
> > > passing it an argument to describeUninitializedArgumentInCall? For 
> > > example, see  MallocChecker.cpp.
> > I changed so describeUninitializedArgumentInCall() returns an llvm::Twine 
> > instead of std::string. hope you like it.
> > 
> I do not think it's safe to use llvm:Twine here. See 
> http://llvm.org/docs/ProgrammersManual.html#the-twine-class
> 
> How about using llvm::raw_svector_ostream as I suggested?
sure I can use llvm::raw_svector_ostream instead. I can try to update the patch 
soon.

I just wonder how it is unsafe. I did consider if llvm::Twine would be safe. Is 
there a particular return that you can point out? The function mostly returns 
constant string literals. Those should be safe right? Then the function also 
have a few returns like this:
```
return llvm::Twine(ArgumentNumber + 1) +
   llvm::getOrdinalSuffix(ArgumentNumber + 1) +
   " function call argument is an uninitialized value";
```
Yes we need to be careful for such code. However since llvm::getOrdinalSuffix() 
returns a StringRef this particular code should be safe right?

When the stream is used I have to tweak each return statement. I thought that 
was a bit unfortunate. But it's not a biggie.



Repository:
  rL LLVM

https://reviews.llvm.org/D30341



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


[libcxx] r296831 - remove max_size() extension from polymorphic_allocator. It is unneeded

2017-03-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Mar  2 16:10:14 2017
New Revision: 296831

URL: http://llvm.org/viewvc/llvm-project?rev=296831=rev
Log:
remove max_size() extension from polymorphic_allocator. It is unneeded

Removed:

libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp
Modified:
libcxx/trunk/include/experimental/memory_resource

Modified: libcxx/trunk/include/experimental/memory_resource
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/memory_resource?rev=296831=296830=296831=diff
==
--- libcxx/trunk/include/experimental/memory_resource (original)
+++ libcxx/trunk/include/experimental/memory_resource Thu Mar  2 16:10:14 2017
@@ -181,7 +181,7 @@ public:
 // 8.6.3, memory.polymorphic.allocator.mem
 _LIBCPP_INLINE_VISIBILITY
 _ValueType* allocate(size_t __n) {
-if (__n > max_size()) {
+if (__n > __max_size()) {
 __throw_length_error(
 
"std::experimental::pmr::polymorphic_allocator::allocate(size_t n)"
 " 'n' exceeds maximum supported size");
@@ -193,7 +193,7 @@ public:
 
 _LIBCPP_INLINE_VISIBILITY
 void deallocate(_ValueType * __p, size_t __n) _NOEXCEPT {
-_LIBCPP_ASSERT(__n <= max_size(),
+_LIBCPP_ASSERT(__n <= __max_size(),
"deallocate called for size which exceeds max_size()");
 __res_->deallocate(__p, __n * sizeof(_ValueType), alignof(_ValueType));
 }
@@ -266,10 +266,6 @@ public:
 { __p->~_Tp(); }
 
 _LIBCPP_INLINE_VISIBILITY
-size_t max_size() const _NOEXCEPT
-{ return numeric_limits::max() / sizeof(value_type); }
-
-_LIBCPP_INLINE_VISIBILITY
 polymorphic_allocator
 select_on_container_copy_construction() const _NOEXCEPT
 { return polymorphic_allocator(); }
@@ -309,6 +305,10 @@ private:
 return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., resource());
 }
 
+_LIBCPP_INLINE_VISIBILITY
+size_t __max_size() const _NOEXCEPT
+{ return numeric_limits::max() / sizeof(value_type); }
+
 memory_resource * __res_;
 };
 

Removed: 
libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp?rev=296830=auto
==
--- 
libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp
 (removed)
@@ -1,65 +0,0 @@
-//===--===//
-//
-// 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.
-//
-//===--===//
-
-// REQUIRES: c++experimental
-// UNSUPPORTED: c++98, c++03
-
-// 
-
-// template  class polymorphic_allocator
-
-// EXTENSION
-// std::size_t polymorphic_allocator::max_size() const noexcept
-
-#include 
-#include 
-#include 
-
-#include "test_memory_resource.hpp"
-
-namespace ex = std::experimental::pmr;
-
-template 
-std::size_t getMaxSize() {
-using T = typename std::aligned_storage::type;
-static_assert(sizeof(T) == S, "Required for test");
-return ex::polymorphic_allocator{}.max_size();
-}
-
-template 
-std::size_t getMaxSize() {
-using T = typename std::aligned_storage::type;
-static_assert(sizeof(T) == S, "Required for test");
-return ex::polymorphic_allocator{}.max_size();
-}
-
-int main()
-{
-{
-using Alloc = ex::polymorphic_allocator;
-using Traits = std::allocator_traits;
-const Alloc a;
-static_assert(std::is_same::value, "");
-static_assert(noexcept(a.max_size()), "");
-}
-{
-constexpr std::size_t Max = std::numeric_limits::max();
-assert(getMaxSize<1>()== Max);
-assert(getMaxSize<2>()== Max / 2);
-assert(getMaxSize<4>()== Max / 4);
-assert(getMaxSize<8>()== Max / 8);
-assert(getMaxSize<16>()   == Max / 16);
-assert(getMaxSize<32>()   == Max / 32);
-assert(getMaxSize<64>()   == Max / 64);
-assert(getMaxSize<1024>() == Max / 1024);
-
-assert((getMaxSize<6,  2>() == Max / 6));
-assert((getMaxSize<12, 4>() == Max / 12));
-}
-}


___
cfe-commits mailing list

[libcxx] r296830 - Fix libc++ test experimental/algorithms/alg.random.sample/sample.pass.cpp when ran in c++11 mode 32 bits

2017-03-02 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Thu Mar  2 16:08:42 2017
New Revision: 296830

URL: http://llvm.org/viewvc/llvm-project?rev=296830=rev
Log:
Fix libc++ test experimental/algorithms/alg.random.sample/sample.pass.cpp when 
ran in c++11 mode 32 bits

Modified:

libcxx/trunk/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp?rev=296830=296829=296830=diff
==
--- 
libcxx/trunk/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp 
Thu Mar  2 16:08:42 2017
@@ -58,19 +58,23 @@ void test() {
   const unsigned os = Expectations::os;
   SampleItem oa[os];
   const int *oa1 = Expectations::oa1;
+  ((void)oa1); // Prevent unused warning
   const int *oa2 = Expectations::oa2;
+  ((void)oa2); // Prevent unused warning
   std::minstd_rand g;
   SampleIterator end;
   end = std::experimental::sample(PopulationIterator(ia),
   PopulationIterator(ia + is),
   SampleIterator(oa), os, g);
-  assert(end.base() - oa == std::min(os, is));
-  assert(std::equal(oa, oa + os, oa1));
+  assert(static_cast(end.base() - oa) == std::min(os, is));
+  // sample() is deterministic but non-reproducible;
+  // its results can vary between implementations.
+  LIBCPP_ASSERT(std::equal(oa, oa + os, oa1));
   end = std::experimental::sample(PopulationIterator(ia),
   PopulationIterator(ia + is),
   SampleIterator(oa), os, std::move(g));
-  assert(end.base() - oa == std::min(os, is));
-  assert(std::equal(oa, oa + os, oa2));
+  assert(static_cast(end.base() - oa) == std::min(os, is));
+  LIBCPP_ASSERT(std::equal(oa, oa + os, oa2));
 }
 
 template