Re: [PATCH] D16948: [libcxx] Filesystem TS -- Complete

2016-05-30 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In http://reviews.llvm.org/D16948#444006, @rmaprath wrote:

> In http://reviews.llvm.org/D16948#443999, @EricWF wrote:
>
> > I installed a Fedora 23 system and ran the test suite and I didn't see any 
> > of the same failures. It must be something other than the distro.
> >  Are you using an odd filesystem? Or maybe it could be your system locale?
>
>
> I suspect so. Ran the latest patch just now and I'm still seeing the 
> remaining failures.
>
> Btw, when do you plan to land this? I'm a bit tight as we are on the run-up 
> to a release. I will investigate my failures offline, but I don't think it 
> should be blocking you (given that you've got them working on fedora 23). 
> Mind you fedora 20 is a bit old.
>
> / Asiri


I don't have an odd filesystem btw, I've let fedora manage the partitioning 
etc. (LVM stuff - I don't know much). Other than that, I have an SSD (but don't 
think it can affect these tests).

/ Asiri


http://reviews.llvm.org/D16948



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


Re: [PATCH] D16948: [libcxx] Filesystem TS -- Complete

2016-05-30 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In http://reviews.llvm.org/D16948#444006, @rmaprath wrote:

> In http://reviews.llvm.org/D16948#443999, @EricWF wrote:
>
> > I installed a Fedora 23 system and ran the test suite and I didn't see any 
> > of the same failures. It must be something other than the distro.
> >  Are you using an odd filesystem? Or maybe it could be your system locale?
>
>
> I suspect so. Ran the latest patch just now and I'm still seeing the 
> remaining failures.
>
> Btw, when do you plan to land this? I'm a bit tight as we are on the run-up 
> to a release. I will investigate my failures offline, but I don't think it 
> should be blocking you (given that you've got them working on fedora 23). 
> Mind you fedora 20 is a bit old.
>
> / Asiri


I have no immediate plans to land it. I'm going to try and get some eyeballs on 
it and some other people to try it first. If it lands and starts causing large 
amounts of failures it's going to be a headache and likely get reverted.


http://reviews.llvm.org/D16948



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


Re: [PATCH] D16948: [libcxx] Filesystem TS -- Complete

2016-05-30 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In http://reviews.llvm.org/D16948#443999, @EricWF wrote:

> I installed a Fedora 23 system and ran the test suite and I didn't see any of 
> the same failures. It must be something other than the distro.
>  Are you using an odd filesystem? Or maybe it could be your system locale?


I suspect so. Ran the latest patch just now and I'm still seeing the remaining 
failures.

Btw, when do you plan to land this? I'm a bit tight as we are on the run-up to 
a release. I will investigate my failures offline, but I don't think it should 
be blocking you (given that you've got them working on fedora 23). Mind you 
fedora 20 is a bit old.

/ Asiri


http://reviews.llvm.org/D16948



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


Re: [PATCH] D16948: [libcxx] Filesystem TS -- Complete

2016-05-30 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In http://reviews.llvm.org/D16948#443945, @rmaprath wrote:

> In http://reviews.llvm.org/D16948#443942, @EricWF wrote:
>
> > In http://reviews.llvm.org/D16948#443941, @rmaprath wrote:
> >
> > > I'm seeing a few failures on my Fedora 20 system. Will go through these 
> > > tomorrow.
> >
> >
> > If you want to just send me the raw ouput I'll go over them tonight.
>
>
> This is from a default (without extra cmake options) build: 
> https://dl.dropboxusercontent.com/u/12212624/Other/filesystem_libcxx_results_fedora20.log
>
> Some of them look obvious. For the rest, let me know if I can get you more 
> info, I can debug tomorrow evening.


I installed a Fedora 23 system and ran the test suite and I didn't see any of 
the same failures. It must be something other than the distro.
Are you using an odd filesystem? Or maybe it could be your system locale?


http://reviews.llvm.org/D16948



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


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-30 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In http://reviews.llvm.org/D20677#443997, @rmaprath wrote:

> Thanks Eric.
>
> I think I noted a few other `assert(true)` statements elsewhere (with similar 
> application), will update those separately.
>
> Btw, do you use some systematic way to detect ABI breakages? I've only bumped 
> into http://lvc.github.io/abi-compliance-checker/ but didn't go as far as 
> setting it up.


Not really, the two primary ways I try to detect ABI breakage are using:

- the scripts under `libcxx/utils/sym_check/`. They provide a way to diff the 
symbols between two dylibs `sym_diff.py old-lib.so new-lib.so`.
- Compiling against an old library and swapping in a new library at runtime.

I also used libabigail for a while but it was a bit too noisy with false 
positives. It may be better now though.

> / Asiri





http://reviews.llvm.org/D20677



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


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-30 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

Thanks Eric.

I think I noted a few other `assert(true)` statements elsewhere (with similar 
application), will update those separately.

Btw, do you use some systematic way to detect ABI breakages? I've only bumped 
into http://lvc.github.io/abi-compliance-checker/ but didn't go as far as 
setting it up.

/ Asiri


http://reviews.llvm.org/D20677



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


r271251 - [MSVC] Fix stack overflow in unqualified type lookup logic, by Will

2016-05-30 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue May 31 01:21:27 2016
New Revision: 271251

URL: http://llvm.org/viewvc/llvm-project?rev=271251&view=rev
Log:
[MSVC] Fix stack overflow in unqualified type lookup logic, by Will
Wilson.

An unqualified lookup for in base classes may cause stack overflow if
the base class is a specialization of current class.
Patch by Will Wilson.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaTemplate/ms-lookup-template-base-classes.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=271251&r1=271250&r2=271251&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue May 31 01:21:27 2016
@@ -163,11 +163,17 @@ lookupUnqualifiedTypeNameInBase(Sema &S,
   auto *TD = TST->getTemplateName().getAsTemplateDecl();
   if (!TD)
 continue;
-  auto *BasePrimaryTemplate =
-  dyn_cast_or_null(TD->getTemplatedDecl());
-  if (!BasePrimaryTemplate)
-continue;
-  BaseRD = BasePrimaryTemplate;
+  if (auto *BasePrimaryTemplate =
+  dyn_cast_or_null(TD->getTemplatedDecl())) {
+if (BasePrimaryTemplate->getCanonicalDecl() != RD->getCanonicalDecl())
+  BaseRD = BasePrimaryTemplate;
+else if (auto *CTD = dyn_cast(TD)) {
+  if (const ClassTemplatePartialSpecializationDecl *PS =
+  CTD->findPartialSpecialization(Base.getType()))
+if (PS->getCanonicalDecl() != RD->getCanonicalDecl())
+  BaseRD = PS;
+}
+  }
 }
 if (BaseRD) {
   for (NamedDecl *ND : BaseRD->lookup(&II)) {

Modified: cfe/trunk/test/SemaTemplate/ms-lookup-template-base-classes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/ms-lookup-template-base-classes.cpp?rev=271251&r1=271250&r2=271251&view=diff
==
--- cfe/trunk/test/SemaTemplate/ms-lookup-template-base-classes.cpp (original)
+++ cfe/trunk/test/SemaTemplate/ms-lookup-template-base-classes.cpp Tue May 31 
01:21:27 2016
@@ -603,3 +603,32 @@ struct Base {
 template struct UseUnqualifiedTypeNames;
 struct BadBase { };
 template struct UseUnqualifiedTypeNames; // expected-note-re 2 {{in 
instantiation {{.*}} requested here}}
+
+namespace partial_template_lookup {
+
+class Bar;
+class Spare;
+
+template 
+class FooTemplated;
+
+class FooBase {
+public:
+  typedef int BaseTypedef;
+};
+
+// Partial template spec (unused)
+template 
+class FooTemplated {};
+
+// Partial template spec (used)
+template 
+class FooTemplated : public FooBase {};
+
+// Full template spec
+template 
+class FooTemplated : public FooTemplated {
+public:
+  BaseTypedef Member; // expected-warning {{unqualified lookup}}
+};
+}


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


r271250 - [X86] Use unaligned load intrinsics to implement other intrinsics instead of manually creating the unaligned load.

2016-05-30 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue May 31 00:49:13 2016
New Revision: 271250

URL: http://llvm.org/viewvc/llvm-project?rev=271250&view=rev
Log:
[X86] Use unaligned load intrinsics to implement other intrinsics instead of 
manually creating the unaligned load.

Modified:
cfe/trunk/lib/Headers/avxintrin.h

Modified: cfe/trunk/lib/Headers/avxintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avxintrin.h?rev=271250&r1=271249&r2=271250&view=diff
==
--- cfe/trunk/lib/Headers/avxintrin.h (original)
+++ cfe/trunk/lib/Headers/avxintrin.h Tue May 31 00:49:13 2016
@@ -2813,35 +2813,22 @@ _mm256_castsi128_si256(__m128i __a)
 static __inline __m256 __DEFAULT_FN_ATTRS
 _mm256_loadu2_m128(float const *__addr_hi, float const *__addr_lo)
 {
-  struct __loadu_ps {
-__m128 __v;
-  } __attribute__((__packed__, __may_alias__));
-
-  __m256 __v256 = _mm256_castps128_ps256(((struct __loadu_ps*)__addr_lo)->__v);
-  return _mm256_insertf128_ps(__v256, ((struct __loadu_ps*)__addr_hi)->__v, 1);
+  __m256 __v256 = _mm256_castps128_ps256(_mm_loadu_ps(__addr_lo));
+  return _mm256_insertf128_ps(__v256, _mm_loadu_ps(__addr_hi), 1);
 }
 
 static __inline __m256d __DEFAULT_FN_ATTRS
 _mm256_loadu2_m128d(double const *__addr_hi, double const *__addr_lo)
 {
-  struct __loadu_pd {
-__m128d __v;
-  } __attribute__((__packed__, __may_alias__));
-
-  __m256d __v256 = _mm256_castpd128_pd256(((struct 
__loadu_pd*)__addr_lo)->__v);
-  return _mm256_insertf128_pd(__v256, ((struct __loadu_pd*)__addr_hi)->__v, 1);
+  __m256d __v256 = _mm256_castpd128_pd256(_mm_loadu_pd(__addr_lo));
+  return _mm256_insertf128_pd(__v256, _mm_loadu_pd(__addr_hi), 1);
 }
 
 static __inline __m256i __DEFAULT_FN_ATTRS
 _mm256_loadu2_m128i(__m128i const *__addr_hi, __m128i const *__addr_lo)
 {
-  struct __loadu_si128 {
-__m128i __v;
-  } __attribute__((__packed__, __may_alias__));
-  __m256i __v256 = _mm256_castsi128_si256(
-((struct __loadu_si128*)__addr_lo)->__v);
-  return _mm256_insertf128_si256(__v256,
- ((struct __loadu_si128*)__addr_hi)->__v, 1);
+  __m256i __v256 = _mm256_castsi128_si256(_mm_loadu_si128(__addr_lo));
+  return _mm256_insertf128_si256(__v256, _mm_loadu_si128(__addr_hi), 1);
 }
 
 /* SIMD store ops (unaligned) */


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


Re: [PATCH] D16948: [libcxx] Filesystem TS -- Complete

2016-05-30 Thread Eric Fiselier via cfe-commits
EricWF marked 6 inline comments as done.
EricWF added a comment.

@majnemer Thanks for looking at this!



Comment at: include/experimental/filesystem:610
@@ +609,3 @@
+static void __append_range(string& __dest, _Iter __b, _Iter __e) {
+// TODO(EricWF) We get better allocation behavior here if we don't
+// provide the same exception safety guarantees as string.append.

majnemer wrote:
> Do we typically put names in TODOs?
IDK. I normally do?


Comment at: include/experimental/filesystem:672
@@ +671,3 @@
+
+// TODO
+template  TODO?
I'll clarify that. I have no idea how to implement the locale conversions. I 
was going to wait until most of filesystem landed before worrying about them.


Comment at: src/experimental/directory_iterator.cpp:100
@@ +99,3 @@
+close();
+//__entry_ = {};
+return false;

majnemer wrote:
> Why is this commented out?
It should be removed. After the stream is closed the __entry_ member is never 
referenced again. 


Comment at: src/experimental/operations.cpp:127-128
@@ +126,4 @@
+
+bool stat_equivalent(struct ::stat& st1, struct ::stat& st2) {
+return (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino);
+}

majnemer wrote:
> What sort of logic is this trying to determine?
If two paths resolve the the same file according to 
https://rawgit.com/cplusplus/filesystem-ts/develop/working-draft.html#equivalent.


Comment at: src/experimental/operations.cpp:354-355
@@ +353,4 @@
+if (ec) ec->clear();
+if (::mkdir(p.c_str(), static_cast(perms::all)) == 0)
+return true;
+if (errno != EEXIST || !is_directory(p))

majnemer wrote:
> Any reason why `mkdir` isn't wrapped like the other fs calls?
There are plenty of other fs calls that aren't wrapped.  The wrapped ones are 
because they are used in a bunch of places.


Comment at: src/experimental/operations.cpp:381
@@ +380,3 @@
+std::error_code *ec){
+if (::symlink(from.c_str(), to.c_str()) != 0)
+set_or_throw(ec, "create_directory_symlink", from, to);

majnemer wrote:
> Hmm, why compare against zero instead of -1?
Probably an oversight.


Comment at: src/experimental/operations.cpp:403
@@ +402,3 @@
+path __current_path(std::error_code *ec) {
+auto size = ::pathconf(".", _PC_PATH_MAX);
+_LIBCPP_ASSERT(size >= 0, "pathconf returned a 0 as max size");

majnemer wrote:
> Hmm, SUSv4 says:
> > The value returned for the variable {PATH_MAX} indicates the longest 
> > relative pathname that could be given if the specified directory is the 
> > current working directory of the process.
> 
> However, you want an absolute path relative to the root directory right?
Yes, but that language confuses me. If I'm not mistaken the longest relative 
pathname for the CWD is going to be longer than the absolute one, since it's 
easy to take an absolute path and add "./././././././" and still refer to the 
same directory.

FYI this code also appears in tho opergroup spec for `getcwd`.
http://pubs.opengroup.org/onlinepubs/009695399/functions/getcwd.html


Comment at: src/experimental/operations.cpp:506-532
@@ +505,29 @@
+std::error_code m_ec;
+#if !defined(__APPLE__)
+using namespace std::chrono;
+auto dur_since_epoch = new_time.time_since_epoch();
+auto sec_since_epoch = duration_cast(dur_since_epoch);
+auto ns_since_epoch = duration_cast(dur_since_epoch - 
sec_since_epoch);
+struct ::timespec tbuf[2];
+tbuf[0].tv_sec = 0;
+tbuf[0].tv_nsec = UTIME_OMIT;
+tbuf[1].tv_sec = sec_since_epoch.count();
+tbuf[1].tv_nsec = ns_since_epoch.count();
+
+if (::utimensat(AT_FDCWD, p.c_str(), tbuf, 0) == -1) {
+m_ec = detail::capture_errno();
+}
+#else
+using Clock = file_time_type::clock;
+struct ::stat st;
+detail::posix_stat(p, st, &m_ec);
+if (!m_ec) {
+::utimbuf tbuf;
+tbuf.actime = st.st_atime;
+tbuf.modtime = Clock::to_time_t(new_time);
+if (::utime(p.c_str(), &tbuf) == -1) {
+m_ec = detail::capture_errno();
+}
+}
+#endif
+if (m_ec)

majnemer wrote:
> I'd suggest you swap these two blocks around.  This way we don't need to add 
> more conjunctions if we add more special cases.
Ack.


Comment at: src/experimental/operations.cpp:528
@@ +527,3 @@
+tbuf.modtime = Clock::to_time_t(new_time);
+if (::utime(p.c_str(), &tbuf) == -1) {
+m_ec = detail::capture_errno();

majnemer wrote:
> Isn't `utime` deprecated?  I'd suggest using `utimes`.
If I'm not mistaken `utimes` is legacy, not `utime`. Also note that `utimensat` 
is used on all platforms except for apple, for which this is the fallback 
implementation.

===

Re: [PATCH] Fix stack overflow in MSVC unqualified type lookup logic

2016-05-30 Thread Will Wilson via cfe-commits
Hi Alexey,

On 31 May 2016 at 12:25, Alexey Bataev  wrote:

> Hi Will,
> Thanks for the report and sorry for a delay with answer. Generally, your
> patch looks good with some small nits. I can fix some minor issues like
> extra braces etc. and commit it if you don't mind.
>

Sure thing. Commit away!

Thanks,
Will.

-- 
*Indefiant *: http://www.indefiant.com
Home of Recode : Runtime C++ Editing for VS
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r271249 - Mark LWG issue 2520 as complete

2016-05-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May 30 23:27:57 2016
New Revision: 271249

URL: http://llvm.org/viewvc/llvm-project?rev=271249&view=rev
Log:
Mark LWG issue 2520 as complete

Modified:

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp

libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp?rev=271249&r1=271248&r2=271249&view=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp
 Mon May 30 23:27:57 2016
@@ -55,4 +55,10 @@ int main()
 assert(s.get_deleter().state() == 5);
 }
 assert(A::count == 0);
+{
+Deleter d;
+std::unique_ptr s(nullptr, d);
+assert(s.get() == nullptr);
+assert(s.get_deleter().state() == 5);
+}
 }

Modified: 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp?rev=271249&r1=271248&r2=271249&view=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp
 Mon May 30 23:27:57 2016
@@ -57,4 +57,9 @@ int main()
 assert(s.get_deleter().state() == 6);
 }
 assert(A::count == 0);
+{
+Deleter d;
+std::unique_ptr s(nullptr, d);
+assert(s.get() == nullptr);
+}
 }

Modified: 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp?rev=271249&r1=271248&r2=271249&view=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp
 Mon May 30 23:27:57 2016
@@ -55,4 +55,9 @@ int main()
 assert(s.get_deleter().state() == 5);
 }
 assert(A::count == 0);
+{
+Deleter d;
+std::unique_ptr s(nullptr, d);
+assert(s.get() == nullptr);
+}
 }

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=271249&r1=271248&r2=271249&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Mon May 30 23:27:57 2016
@@ -206,7 +206,7 @@
http://cplusplus.github.io/LWG/lwg-defects.html#2276";>2276Missing
 requirement on 
std::promise::set_exceptionJacksonvilleComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2296";>2296std::addressof
 should be constexprJacksonvilleComplete (Clang 
Only)
http://cplusplus.github.io/LWG/lwg-defects.html#2450";>2450(greater|less|greater_equal|less_equal)
 do not yield a total order for pointersJacksonville
-   http://cplusplus.github.io/LWG/lwg-defects.html#2520";>2520N4089
 broke initializing unique_ptr from a 
nullptrJacksonville
+   http://cplusplus.github.io/LWG/lwg-defects.html#2520";>2520N4089
 broke initializing unique_ptr from a 
nullptrJacksonvilleComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2522";>2522[fund.ts.v2]
 Contradiction in set_default_resource 
specificationJacksonvilleComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2523";>2523std::promise
 synopsis shows two set_value_at_thread_exit()'s for no apparent 
reasonJacksonvilleComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2537";>2537Constructors
 for priority_queue taking allocators should call 
make_heapJacksonvilleComplete


___

Re: [PATCH] Fix stack overflow in MSVC unqualified type lookup logic

2016-05-30 Thread Alexey Bataev via cfe-commits
Hi Will,
Thanks for the report and sorry for a delay with answer. Generally, your patch 
looks good with some small nits. I can fix some minor issues like extra braces 
etc. and commit it if you don't mind.

Best regards,
Alexey Bataev
=
Software Engineer
Intel Compiler Team

28.05.2016 7:56, Will Wilson пишет:
Hi Alexey,

A customer encountered a stack overflow in the code from r229817. I've created 
a small repro for testing the issue and a fix. The fix should also better deal 
with lookup into partially specialized base templates.

Test case included and tested against latest trunk.

Let me know if it looks acceptable!

Cheers,
Will.

--
Indefiant : http://www.indefiant.com
Home of Recode : Runtime C++ Editing for VS

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


Re: [PATCH] D16948: [libcxx] Filesystem TS -- Complete

2016-05-30 Thread David Majnemer via cfe-commits
majnemer added a subscriber: majnemer.


Comment at: include/experimental/filesystem:610
@@ +609,3 @@
+static void __append_range(string& __dest, _Iter __b, _Iter __e) {
+// TODO(EricWF) We get better allocation behavior here if we don't
+// provide the same exception safety guarantees as string.append.

Do we typically put names in TODOs?


Comment at: include/experimental/filesystem:672
@@ +671,3 @@
+
+// TODO
+template clear();
+if (::mkdir(p.c_str(), static_cast(perms::all)) == 0)
+return true;
+if (errno != EEXIST || !is_directory(p))

Any reason why `mkdir` isn't wrapped like the other fs calls?


Comment at: src/experimental/operations.cpp:381
@@ +380,3 @@
+std::error_code *ec){
+if (::symlink(from.c_str(), to.c_str()) != 0)
+set_or_throw(ec, "create_directory_symlink", from, to);

Hmm, why compare against zero instead of -1?


Comment at: src/experimental/operations.cpp:403
@@ +402,3 @@
+path __current_path(std::error_code *ec) {
+auto size = ::pathconf(".", _PC_PATH_MAX);
+_LIBCPP_ASSERT(size >= 0, "pathconf returned a 0 as max size");

Hmm, SUSv4 says:
> The value returned for the variable {PATH_MAX} indicates the longest relative 
> pathname that could be given if the specified directory is the current 
> working directory of the process.

However, you want an absolute path relative to the root directory right?


Comment at: src/experimental/operations.cpp:506-532
@@ +505,29 @@
+std::error_code m_ec;
+#if !defined(__APPLE__)
+using namespace std::chrono;
+auto dur_since_epoch = new_time.time_since_epoch();
+auto sec_since_epoch = duration_cast(dur_since_epoch);
+auto ns_since_epoch = duration_cast(dur_since_epoch - 
sec_since_epoch);
+struct ::timespec tbuf[2];
+tbuf[0].tv_sec = 0;
+tbuf[0].tv_nsec = UTIME_OMIT;
+tbuf[1].tv_sec = sec_since_epoch.count();
+tbuf[1].tv_nsec = ns_since_epoch.count();
+
+if (::utimensat(AT_FDCWD, p.c_str(), tbuf, 0) == -1) {
+m_ec = detail::capture_errno();
+}
+#else
+using Clock = file_time_type::clock;
+struct ::stat st;
+detail::posix_stat(p, st, &m_ec);
+if (!m_ec) {
+::utimbuf tbuf;
+tbuf.actime = st.st_atime;
+tbuf.modtime = Clock::to_time_t(new_time);
+if (::utime(p.c_str(), &tbuf) == -1) {
+m_ec = detail::capture_errno();
+}
+}
+#endif
+if (m_ec)

I'd suggest you swap these two blocks around.  This way we don't need to add 
more conjunctions if we add more special cases.


Comment at: src/experimental/operations.cpp:528
@@ +527,3 @@
+tbuf.modtime = Clock::to_time_t(new_time);
+if (::utime(p.c_str(), &tbuf) == -1) {
+m_ec = detail::capture_errno();

Isn't `utime` deprecated?  I'd suggest using `utimes`.


Comment at: src/experimental/operations.cpp:659
@@ +658,3 @@
+struct statvfs m_svfs;
+//if we fail but don't throw
+if (::statvfs(p.c_str(), &m_svfs) == -1)  {

Formatting?


Comment at: src/experimental/operations.cpp:663
@@ +662,3 @@
+si.capacity = si.free = si.available =
+static_cast(-1);
+return si;

Why not use `uintmax_t` instead of `decltype(si.free)` ?


Comment at: src/experimental/operations.cpp:667-669
@@ +666,5 @@
+if (ec) ec->clear();
+si.capacity =   m_svfs.f_blocks * m_svfs.f_frsize;
+si.free =   m_svfs.f_bfree  * m_svfs.f_frsize;
+si.available =  m_svfs.f_bavail * m_svfs.f_frsize;
+return si;

Does the standard give any guidance if this calculation overflows?


Comment at: src/experimental/operations.cpp:687
@@ +686,3 @@
+path __temp_directory_path(std::error_code *ec) {
+const char* env_paths[] = {"TMPDIR", "TMP", "TEMP", "TEMPDIR"};
+const char* ret = nullptr;

Why all these environment variables?


Comment at: src/experimental/operations.cpp:705-707
@@ +704,5 @@
+
+//since the specification of absolute in the current specification
+// this implementation is designed after the sample implementation
+// using the sample table as a guide
+path absolute(const path& p, const path& base) {

Formatting?


http://reviews.llvm.org/D16948



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


Re: [PATCH] D20709: Support ARM subtarget feature +long64

2016-05-30 Thread Stephen Hines via cfe-commits
srhines added a comment.

In http://reviews.llvm.org/D20709#443536, @kristof.beyls wrote:

> Hi Pirama,
>
> My understanding is that this introduces (yet another) ARM 32 bit ABI variant 
> - in this case with longs being 64 bit.
>  My understanding is also that this is the ABI that is used in Renderscript, 
> and this patch helps to remove local patches that currently live in the 
> Renderscript toolchain downstream only.


Correct. This is only used by RenderScript, and unfortunately can't be done any 
differently. We had hoped to just predicate this with our own LangOpt (the 
patch that adds the RenderScript LangOpt is coming soon), but unfortunately, at 
the point where LangOpts are being parsed, the target machine already has the 
size and alignment of long specified (and it can't change).

> I think it's good not to need downstream patches for a Renderscript toolchain.


Same here, although these patches seem so small that I don't want to introduce 
too much trouble in upstream. If there isn't a nice way to clean this up, I 
would be fine with this amount of divergence, since it really doesn't impact 
our ability to update LLVM (and again, the feature is only used by 
RenderScript).

> In effect, this introduces another abi variant.

>  I'm wondering if the abi variant should be controlled using a triple, just 
> like e.g. the hard float vs. soft float abi variants also get controlled via 
> a triple?


We can't unfortunately control this via a separate triple because RenderScript 
has (and always) will use the ARM triple. This really only affects the frontend 
for RenderScript, since RS doesn't allow the full libc runtime. That is why the 
LLVM side of this patch has no tests (because there is nothing there, and we 
only need the option recognized or the backend generates warnings about an 
unsupported flag - perhaps there is a better way to suppress that, but at the 
time that I fixed this years ago, I think my only option was to add it in both 
places).

> Tim, do you happen to have insights on this?

> 

> Thanks,

> 

> Kristof





http://reviews.llvm.org/D20709



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


[libcxx] r271248 - Add tests that got missed in r271247.

2016-05-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May 30 20:51:34 2016
New Revision: 271248

URL: http://llvm.org/viewvc/llvm-project?rev=271248&view=rev
Log:
Add tests that got missed in r271247.

Added:
libcxx/trunk/test/libcxx/thread/futures/futures.promise/

libcxx/trunk/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp

libcxx/trunk/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp

Added: 
libcxx/trunk/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp?rev=271248&view=auto
==
--- 
libcxx/trunk/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp 
(added)
+++ 
libcxx/trunk/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp 
Mon May 30 20:51:34 2016
@@ -0,0 +1,53 @@
+//===--===//
+//
+// 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: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++98, c++03
+
+// 
+
+// class promise
+
+// void set_exception(exception_ptr p);
+// Test that a null exception_ptr is diagnosed.
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? ((void)0) : throw 42)
+
+#define _LIBCPP_DEBUG 0
+#include 
+#include 
+#include 
+#include 
+
+
+int main()
+{
+{
+typedef int T;
+std::promise p;
+try {
+p.set_exception(std::exception_ptr());
+assert(false);
+} catch (int const& value) {
+assert(value == 42);
+}
+}
+{
+typedef int& T;
+std::promise p;
+try {
+p.set_exception(std::exception_ptr());
+assert(false);
+} catch (int const& value) {
+assert(value == 42);
+}
+}
+}

Added: 
libcxx/trunk/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp?rev=271248&view=auto
==
--- 
libcxx/trunk/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
 (added)
+++ 
libcxx/trunk/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
 Mon May 30 20:51:34 2016
@@ -0,0 +1,53 @@
+//===--===//
+//
+// 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: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++98, c++03
+
+// 
+
+// class promise
+
+// void set_exception_on_thread_exit(exception_ptr p);
+// Test that a null exception_ptr is diagnosed.
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? ((void)0) : throw 42)
+
+#define _LIBCPP_DEBUG 0
+#include 
+#include 
+#include 
+#include 
+
+
+int main()
+{
+{
+typedef int T;
+std::promise p;
+try {
+p.set_exception_at_thread_exit(std::exception_ptr());
+assert(false);
+} catch (int const& value) {
+assert(value == 42);
+}
+}
+{
+typedef int& T;
+std::promise p;
+try {
+p.set_exception_at_thread_exit(std::exception_ptr());
+assert(false);
+} catch (int const& value) {
+assert(value == 42);
+}
+}
+}


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


[libcxx] r271247 - Mark LWG issue 2276 as complete. Add _LIBCPP_ASSERTS for it

2016-05-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May 30 20:50:55 2016
New Revision: 271247

URL: http://llvm.org/viewvc/llvm-project?rev=271247&view=rev
Log:
Mark LWG issue 2276 as complete. Add _LIBCPP_ASSERTS for it

Modified:
libcxx/trunk/include/future
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/future
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/future?rev=271247&r1=271246&r2=271247&view=diff
==
--- libcxx/trunk/include/future (original)
+++ libcxx/trunk/include/future Mon May 30 20:50:55 2016
@@ -1514,6 +1514,7 @@ template 
 void
 promise<_Rp>::set_exception_at_thread_exit(exception_ptr __p)
 {
+_LIBCPP_ASSERT( __p != nullptr, "promise::set_exception_at_thread_exit: 
received nullptr" );
 if (__state_ == nullptr)
 __throw_future_error(future_errc::no_state);
 __state_->set_exception_at_thread_exit(__p);
@@ -1649,6 +1650,7 @@ template 
 void
 promise<_Rp&>::set_exception_at_thread_exit(exception_ptr __p)
 {
+_LIBCPP_ASSERT( __p != nullptr, "promise::set_exception_at_thread_exit: 
received nullptr" );
 if (__state_ == nullptr)
 __throw_future_error(future_errc::no_state);
 __state_->set_exception_at_thread_exit(__p);

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=271247&r1=271246&r2=271247&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Mon May 30 20:50:55 2016
@@ -203,7 +203,7 @@
http://cplusplus.github.io/LWG/lwg-defects.html#2495";>2495There
 is no such thing as an Exception Safety 
elementKonaComplete

http://cplusplus.github.io/LWG/lwg-defects.html#2192";>2192Validity
 and return type of std::abs(0u) is 
unclearJacksonville
-   http://cplusplus.github.io/LWG/lwg-defects.html#2276";>2276Missing
 requirement on 
std::promise::set_exceptionJacksonville
+   http://cplusplus.github.io/LWG/lwg-defects.html#2276";>2276Missing
 requirement on 
std::promise::set_exceptionJacksonvilleComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2296";>2296std::addressof
 should be constexprJacksonvilleComplete (Clang 
Only)
http://cplusplus.github.io/LWG/lwg-defects.html#2450";>2450(greater|less|greater_equal|less_equal)
 do not yield a total order for pointersJacksonville
http://cplusplus.github.io/LWG/lwg-defects.html#2520";>2520N4089
 broke initializing unique_ptr from a 
nullptrJacksonville


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


r271246 - [AVX512] Emit generic masked store instrinsics instead of using x86 specific intrinsics.

2016-05-30 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon May 30 20:50:10 2016
New Revision: 271246

URL: http://llvm.org/viewvc/llvm-project?rev=271246&view=rev
Log:
[AVX512] Emit generic masked store instrinsics instead of using x86 specific 
intrinsics.

This will allow us to remove the x86 instrinics from the backend.

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/avx512bw-builtins.c
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/CodeGen/avx512vl-builtins.c
cfe/trunk/test/CodeGen/avx512vlbw-builtins.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=271246&r1=271245&r2=271246&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon May 30 20:50:10 2016
@@ -6277,6 +6277,38 @@ BuildVector(ArrayRef Ops)
   return Result;
 }
 
+static Value *EmitX86MaskedStore(CodeGenFunction &CGF,
+ SmallVectorImpl &Ops,
+ unsigned Align) {
+  // Cast the pointer to right type.
+  Ops[0] = CGF.Builder.CreateBitCast(Ops[0],
+   
llvm::PointerType::getUnqual(Ops[1]->getType()));
+
+  // If the mask is all ones just emit a regular store.
+  if (const auto *C = dyn_cast(Ops[2]))
+if (C->isAllOnesValue())
+  return CGF.Builder.CreateAlignedStore(Ops[1], Ops[0], Align);
+
+  // Convert the mask from an integer type to a vector of i1.
+  unsigned NumElts = Ops[1]->getType()->getVectorNumElements();
+  llvm::VectorType *MaskTy = llvm::VectorType::get(CGF.Builder.getInt1Ty(),
+ cast(Ops[2]->getType())->getBitWidth());
+  Ops[2] = CGF.Builder.CreateBitCast(Ops[2], MaskTy);
+
+  // If we have less than 8 elements, then the starting mask was an i8 and
+  // we need to extract down to the right number of elements.
+  if (NumElts < 8) {
+int Indices[4];
+for (unsigned i = 0; i != NumElts; ++i)
+  Indices[i] = i;
+Ops[2] = CGF.Builder.CreateShuffleVector(Ops[2], Ops[2],
+ makeArrayRef(Indices, NumElts),
+ "extract");
+  }
+
+  return CGF.Builder.CreateMaskedStore(Ops[1], Ops[0], Align, Ops[2]);
+}
+
 Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
const CallExpr *E) {
   if (BuiltinID == X86::BI__builtin_ms_va_start ||
@@ -6500,6 +6532,42 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 Ops.push_back(Mlo);
 return Builder.CreateCall(CGM.getIntrinsic(ID), Ops);
   }
+  case X86::BI__builtin_ia32_storedqudi128_mask:
+  case X86::BI__builtin_ia32_storedqusi128_mask:
+  case X86::BI__builtin_ia32_storedquhi128_mask:
+  case X86::BI__builtin_ia32_storedquqi128_mask:
+  case X86::BI__builtin_ia32_storeupd128_mask:
+  case X86::BI__builtin_ia32_storeups128_mask:
+  case X86::BI__builtin_ia32_storedqudi256_mask:
+  case X86::BI__builtin_ia32_storedqusi256_mask:
+  case X86::BI__builtin_ia32_storedquhi256_mask:
+  case X86::BI__builtin_ia32_storedquqi256_mask:
+  case X86::BI__builtin_ia32_storeupd256_mask:
+  case X86::BI__builtin_ia32_storeups256_mask:
+  case X86::BI__builtin_ia32_storedqudi512_mask:
+  case X86::BI__builtin_ia32_storedqusi512_mask:
+  case X86::BI__builtin_ia32_storedquhi512_mask:
+  case X86::BI__builtin_ia32_storedquqi512_mask:
+  case X86::BI__builtin_ia32_storeupd512_mask:
+  case X86::BI__builtin_ia32_storeups512_mask:
+return EmitX86MaskedStore(*this, Ops, 1);
+
+  case X86::BI__builtin_ia32_movdqa32store128_mask:
+  case X86::BI__builtin_ia32_movdqa64store128_mask:
+  case X86::BI__builtin_ia32_storeaps128_mask:
+  case X86::BI__builtin_ia32_storeapd128_mask:
+  case X86::BI__builtin_ia32_movdqa32store256_mask:
+  case X86::BI__builtin_ia32_movdqa64store256_mask:
+  case X86::BI__builtin_ia32_storeaps256_mask:
+  case X86::BI__builtin_ia32_storeapd256_mask:
+  case X86::BI__builtin_ia32_movdqa32store512_mask:
+  case X86::BI__builtin_ia32_movdqa64store512_mask:
+  case X86::BI__builtin_ia32_storeaps512_mask:
+  case X86::BI__builtin_ia32_storeapd512_mask: {
+unsigned Align =
+  getContext().getTypeAlignInChars(E->getArg(1)->getType()).getQuantity();
+return EmitX86MaskedStore(*this, Ops, Align);
+  }
   case X86::BI__builtin_ia32_storehps:
   case X86::BI__builtin_ia32_storelps: {
 llvm::Type *PtrTy = llvm::PointerType::getUnqual(Int64Ty);

Modified: cfe/trunk/test/CodeGen/avx512bw-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512bw-builtins.c?rev=271246&r1=271245&r2=271246&view=diff
==
--- cfe/trunk/test/CodeGen/avx512bw-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512bw-builtins.c Mon May 30 20:50:10 2016
@@ -1348,7 +1348,7 @@ __m512i test_mm512_maskz_loadu_epi8(__mm
 }
 vo

Re: [PATCH] D16948: [libcxx] Filesystem TS -- Complete

2016-05-30 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Thanks. I fixed the missing include causing most of the failures. Please update 
me when you can with new results.


http://reviews.llvm.org/D16948



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


Re: [PATCH] D16948: [libcxx] Filesystem TS -- Complete

2016-05-30 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In http://reviews.llvm.org/D16948#443942, @EricWF wrote:

> In http://reviews.llvm.org/D16948#443941, @rmaprath wrote:
>
> > I'm seeing a few failures on my Fedora 20 system. Will go through these 
> > tomorrow.
>
>
> If you want to just send me the raw ouput I'll go over them tonight.


This is from a default (without extra cmake options) build: 
https://dl.dropboxusercontent.com/u/12212624/Other/filesystem_libcxx_results_fedora20.log

Some of them look obvious. For the rest, let me know if I can get you more 
info, I can debug tomorrow evening.

/ Asiri


http://reviews.llvm.org/D16948



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


[libcxx] r271241 - Mark LWG issue 2537 as complete

2016-05-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May 30 20:11:20 2016
New Revision: 271241

URL: http://llvm.org/viewvc/llvm-project?rev=271241&view=rev
Log:
Mark LWG issue 2537 as complete

Modified:

libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp?rev=271241&r1=271240&r2=271241&view=diff
==
--- 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp
 Mon May 30 20:11:20 2016
@@ -16,6 +16,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "test_allocator.h"
 
 template 
@@ -41,11 +42,11 @@ struct test
 : base(comp, a) {}
 test(const value_compare& comp, const container_type& c,
 const test_allocator& a) : base(comp, c, a) {}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if TEST_STD_VER >= 11 // testing rvalue constructor
 test(const value_compare& comp, container_type&& c,
  const test_allocator& a) : base(comp, std::move(c), a) {}
 test(test&& q, const test_allocator& a) : base(std::move(q), a) {}
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
 test_allocator get_allocator() {return c.get_allocator();}
 
 using base::c;

Modified: 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp?rev=271241&r1=271240&r2=271241&view=diff
==
--- 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp
 Mon May 30 20:11:20 2016
@@ -16,6 +16,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "test_allocator.h"
 
 template 
@@ -41,11 +42,11 @@ struct test
 : base(comp, a) {}
 test(const value_compare& comp, const container_type& c,
 const test_allocator& a) : base(comp, c, a) {}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if TEST_STD_VER >= 11 // testing rvalue ctor
 test(const value_compare& comp, container_type&& c,
  const test_allocator& a) : base(comp, std::move(c), a) {}
 test(test&& q, const test_allocator& a) : base(std::move(q), a) {}
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
 test_allocator get_allocator() {return c.get_allocator();}
 
 using base::c;

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=271241&r1=271240&r2=271241&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Mon May 30 20:11:20 2016
@@ -209,7 +209,7 @@
http://cplusplus.github.io/LWG/lwg-defects.html#2520";>2520N4089
 broke initializing unique_ptr from a 
nullptrJacksonville
http://cplusplus.github.io/LWG/lwg-defects.html#2522";>2522[fund.ts.v2]
 Contradiction in set_default_resource 
specificationJacksonvilleComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2523";>2523std::promise
 synopsis shows two set_value_at_thread_exit()'s for no apparent 
reasonJacksonvilleComplete
-   http://cplusplus.github.io/LWG/lwg-defects.html#2537";>2537Constructors
 for priority_queue taking allocators should call 
make_heapJacksonville
+   http://cplusplus.github.io/LWG/lwg-defects.html#2537";>2537Constructors
 for priority_queue taking allocators should call 
make_heapJacksonvilleComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2539";>2539[fund.ts.v2]
 invocation_trait definition definition doesn't work for surrogate 
call functionsJacksonville
http://cplusplus.github.io/LWG/lwg-defects.html#2545";>2545Simplify
 wording for bind without explicitly specified return 
typeJacksonville
http://cplusplus.github.io/LWG/lwg-defects.html#2557";>2557Logical
 operator traits are broken in the zero-argument 
caseJacksonvilleComplete


___
cfe-commits mailing list
cfe-commits@lists.

[libcxx] r271240 - Mark LWG issue #2585 as complete

2016-05-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May 30 20:03:07 2016
New Revision: 271240

URL: http://llvm.org/viewvc/llvm-project?rev=271240&view=rev
Log:
Mark LWG issue #2585 as complete

Modified:

libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: 
libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp?rev=271240&r1=271239&r2=271240&view=diff
==
--- 
libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp
 Mon May 30 20:03:07 2016
@@ -14,9 +14,14 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "DefaultOnly.h"
 #include "min_allocator.h"
 
+#if TEST_STD_VER >= 11
+#include "container_test_types.h"
+#endif
+
 int main()
 {
 {
@@ -49,7 +54,7 @@ int main()
 assert(*next(c.begin(), 4) == 10);
 assert(*next(c.begin(), 5) == 10);
 }
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
 {
 typedef int T;
 typedef std::forward_list> C;
@@ -80,5 +85,19 @@ int main()
 assert(*next(c.begin(), 4) == 10);
 assert(*next(c.begin(), 5) == 10);
 }
+{
+// Test that the allocator's construct method is being used to
+// construct the new elements and that it's called exactly N times.
+typedef int T;
+typedef std::forward_list> 
Container;
+ConstructController* cc = getConstructController();
+cc->reset();
+{
+Container c;
+cc->expect(6);
+c.resize(6, 42);
+assert(!cc->unchecked());
+}
+}
 #endif
 }

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=271240&r1=271239&r2=271240&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Mon May 30 20:03:07 2016
@@ -228,7 +228,7 @@
http://cplusplus.github.io/LWG/lwg-defects.html#2581";>2581Specialization
 of  variable templates should be 
prohibitedJacksonvilleComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2582";>2582§[res.on.functions]/2's
 prohibition against incomplete types shouldn't apply to type 
traitsJacksonville
http://cplusplus.github.io/LWG/lwg-defects.html#2583";>2583There
 is no way to supply an allocator for basic_string(str, 
pos)JacksonvilleComplete
-   http://cplusplus.github.io/LWG/lwg-defects.html#2585";>2585forward_list::resize(size_type,
 const value_type&) effects 
incorrectJacksonville
+   http://cplusplus.github.io/LWG/lwg-defects.html#2585";>2585forward_list::resize(size_type,
 const value_type&) effects 
incorrectJacksonvilleComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2586";>2586Wrong
 value category used in 
scoped_allocator_adaptor::construct()Jacksonville
http://cplusplus.github.io/LWG/lwg-defects.html#2590";>2590Aggregate
 initialization for 
std::arrayJacksonvilleComplete
 


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


Re: [PATCH] D16948: [libcxx] Filesystem TS -- Complete

2016-05-30 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In http://reviews.llvm.org/D16948#443941, @rmaprath wrote:

> I'm seeing a few failures on my Fedora 20 system. Will go through these 
> tomorrow.


If you want to just send me the raw ouput I'll go over them tonight.


http://reviews.llvm.org/D16948



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


Re: [PATCH] D16948: [libcxx] Filesystem TS -- Complete

2016-05-30 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

I'm seeing a few failures on my Fedora 20 system. Will go through these 
tomorrow.


http://reviews.llvm.org/D16948



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


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-30 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

Just for reference here is a list of symbols which have been removed:

https://gist.github.com/EricWF/bf00dbc5fccc78b779f8d260727a0710

LGTM. Your free to submit it after addressing the inline comments.



Comment at: test/cxa_bad_cast.pass.cpp:40
@@ +39,3 @@
+} catch (std::bad_cast) {
+assert(true);
+} catch (...) {

return 0;


Comment at: test/cxa_bad_cast.pass.cpp:45
@@ +44,3 @@
+#endif
+return 0;
+}

return 1;


Comment at: test/cxa_bad_typeid.pass.cpp:39
@@ +38,3 @@
+} catch (std::bad_typeid) {
+assert(true);
+} catch (...) {

return 0 here instead. "assert(true)" is pretty much un-observable.


Comment at: test/cxa_bad_typeid.pass.cpp:44
@@ +43,3 @@
+#endif
+return 0;
+}

This should return non-zero.


Comment at: test/noexception1.pass.cpp:26
@@ +25,3 @@
+int main ()
+{
+std::set_terminate(my_terminate);

Before setting the terminate handling call the function once with null to make 
sure it returns.


Comment at: test/noexception2.pass.cpp:26
@@ +25,3 @@
+int main ()
+{
+std::set_terminate(my_terminate);

Before setting the terminate handling call the function once with null to make 
sure it returns.


Comment at: test/noexception3.pass.cpp:27
@@ +26,3 @@
+{
+std::set_terminate(my_terminate);
+__cxxabiv1::__cxa_rethrow_primary_exception((void*) &gCounter);

Before setting the terminate handling call the function once with null to make 
sure it returns.


http://reviews.llvm.org/D20677



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


Re: [PATCH] D20277: [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const value parameter can be moved.

2016-05-30 Thread Felix Berger via cfe-commits
flx added a comment.

Alex, Sam, could you take another look? It'd be great to get this change in to 
make the check more useful.


http://reviews.llvm.org/D20277



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


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-30 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Nevermind. I figured out why it wasn't working. Phab didn't know the libc++ 
patch was in a different repo and so it wouldn't apply the patch.


http://reviews.llvm.org/D20677



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


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-30 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

For some reason I'm having trouble applying your patch. Could you please upload 
it with more context? (ie git diff -U999 or similar)


http://reviews.llvm.org/D20677



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


Re: [PATCH] D20010: [clang-tidy] UnnecessaryCopyInitialization - Extend to trigger on non-const "this" object argument if it is not modified

2016-05-30 Thread Felix Berger via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271239: [clang-tidy] UnnecessaryCopyInitialization - Extend 
to trigger on non-const… (authored by flx).

Changed prior to commit:
  http://reviews.llvm.org/D20010?vs=58181&id=59010#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20010

Files:
  
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.h
  
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization.cpp

Index: clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.h
===
--- clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.h
+++ clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.h
@@ -33,7 +33,8 @@
 
 private:
   void handleCopyFromMethodReturn(const VarDecl &Var, const Stmt &BlockStmt,
-  bool IssueFix, ASTContext &Context);
+  bool IssueFix, const VarDecl *ObjectArg,
+  ASTContext &Context);
   void handleCopyFromLocalVar(const VarDecl &NewVar, const VarDecl &OldVar,
   const Stmt &BlockStmt, bool IssueFix,
   ASTContext &Context);
Index: clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
===
--- clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -38,14 +38,15 @@
 unless(allOf(pointerType(), unless(pointerType(pointee(
 qualType(isConstQualified(;
 
-  // Match method call expressions where the this argument is a const
-  // type or const reference. This returned const reference is highly likely to
-  // outlive the local const reference of the variable being declared.
-  // The assumption is that the const reference being returned either points
-  // to a global static variable or to a member of the called object.
-  auto ConstRefReturningMethodCallOfConstParam = cxxMemberCallExpr(
+  // Match method call expressions where the `this` argument is only used as
+  // const, this will be checked in `check()` part. This returned const
+  // reference is highly likely to outlive the local const reference of the
+  // variable being declared. The assumption is that the const reference being
+  // returned either points to a global static variable or to a member of the
+  // called object.
+  auto ConstRefReturningMethodCall = cxxMemberCallExpr(
   callee(cxxMethodDecl(returns(ConstReference))),
-  on(declRefExpr(to(varDecl(hasType(qualType(ConstOrConstReference)));
+  on(declRefExpr(to(varDecl().bind("objectArg");
   auto ConstRefReturningFunctionCall =
   callExpr(callee(functionDecl(returns(ConstReference))),
unless(callee(cxxMethodDecl(;
@@ -68,7 +69,7 @@
 
   Finder->addMatcher(
   localVarCopiedFrom(anyOf(ConstRefReturningFunctionCall,
-   ConstRefReturningMethodCallOfConstParam)),
+   ConstRefReturningMethodCall)),
   this);
 
   Finder->addMatcher(localVarCopiedFrom(declRefExpr(
@@ -80,6 +81,7 @@
 const MatchFinder::MatchResult &Result) {
   const auto *NewVar = Result.Nodes.getNodeAs("newVarDecl");
   const auto *OldVar = Result.Nodes.getNodeAs("oldVarDecl");
+  const auto *ObjectArg = Result.Nodes.getNodeAs("objectArg");
   const auto *BlockStmt = Result.Nodes.getNodeAs("blockStmt");
   const auto *CtorCall = Result.Nodes.getNodeAs("ctorCall");
   // Do not propose fixes if the DeclStmt has multiple VarDecls or in macros
@@ -96,19 +98,23 @@
   return;
 
   if (OldVar == nullptr) {
-handleCopyFromMethodReturn(*NewVar, *BlockStmt, IssueFix, *Result.Context);
+handleCopyFromMethodReturn(*NewVar, *BlockStmt, IssueFix, ObjectArg,
+   *Result.Context);
   } else {
 handleCopyFromLocalVar(*NewVar, *OldVar, *BlockStmt, IssueFix,
*Result.Context);
   }
 }
 
 void UnnecessaryCopyInitialization::handleCopyFromMethodReturn(
 const VarDecl &Var, const Stmt &BlockStmt, bool IssueFix,
-ASTContext &Context) {
+const VarDecl *ObjectArg, ASTContext &Context) {
   bool IsConstQualified = Var.getType().isConstQualified();
   if (!IsConstQualified && !isOnlyUsedAsConst(Var, BlockStmt, Context))
 return;
+  if (ObjectArg != nullptr &&
+  !isOnlyUsedAsConst(*ObjectArg, BlockStmt, Context))
+return;
 
   auto Diagnostic =
   diag(Var.getLocation(),
Index: clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization.cpp
===

[clang-tools-extra] r271239 - [clang-tidy] UnnecessaryCopyInitialization - Extend to trigger on non-const "this" object argument if it is not modified.

2016-05-30 Thread Felix Berger via cfe-commits
Author: flx
Date: Mon May 30 19:25:57 2016
New Revision: 271239

URL: http://llvm.org/viewvc/llvm-project?rev=271239&view=rev
Log:
[clang-tidy] UnnecessaryCopyInitialization - Extend to trigger on non-const 
"this" object argument if it is not modified.

Summary:

Also trigger the check in the following case:

void foo() {
  ExpensiveToCopy Obj;
  const auto UnnecessaryCopy = Obj.constReference();
  Obj.onlyUsedAsConst();
}

i.e. when the object the method is called on is not const but is never
modified.

Reviewers: alexfh, fowles

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D20010

Modified:

clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.cpp

clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.h

clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.cpp?rev=271239&r1=271238&r2=271239&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
 Mon May 30 19:25:57 2016
@@ -38,14 +38,15 @@ void UnnecessaryCopyInitialization::regi
 unless(allOf(pointerType(), unless(pointerType(pointee(
 qualType(isConstQualified(;
 
-  // Match method call expressions where the this argument is a const
-  // type or const reference. This returned const reference is highly likely to
-  // outlive the local const reference of the variable being declared.
-  // The assumption is that the const reference being returned either points
-  // to a global static variable or to a member of the called object.
-  auto ConstRefReturningMethodCallOfConstParam = cxxMemberCallExpr(
+  // Match method call expressions where the `this` argument is only used as
+  // const, this will be checked in `check()` part. This returned const
+  // reference is highly likely to outlive the local const reference of the
+  // variable being declared. The assumption is that the const reference being
+  // returned either points to a global static variable or to a member of the
+  // called object.
+  auto ConstRefReturningMethodCall = cxxMemberCallExpr(
   callee(cxxMethodDecl(returns(ConstReference))),
-  on(declRefExpr(to(varDecl(hasType(qualType(ConstOrConstReference)));
+  on(declRefExpr(to(varDecl().bind("objectArg");
   auto ConstRefReturningFunctionCall =
   callExpr(callee(functionDecl(returns(ConstReference))),
unless(callee(cxxMethodDecl(;
@@ -68,7 +69,7 @@ void UnnecessaryCopyInitialization::regi
 
   Finder->addMatcher(
   localVarCopiedFrom(anyOf(ConstRefReturningFunctionCall,
-   ConstRefReturningMethodCallOfConstParam)),
+   ConstRefReturningMethodCall)),
   this);
 
   Finder->addMatcher(localVarCopiedFrom(declRefExpr(
@@ -80,6 +81,7 @@ void UnnecessaryCopyInitialization::chec
 const MatchFinder::MatchResult &Result) {
   const auto *NewVar = Result.Nodes.getNodeAs("newVarDecl");
   const auto *OldVar = Result.Nodes.getNodeAs("oldVarDecl");
+  const auto *ObjectArg = Result.Nodes.getNodeAs("objectArg");
   const auto *BlockStmt = Result.Nodes.getNodeAs("blockStmt");
   const auto *CtorCall = Result.Nodes.getNodeAs("ctorCall");
   // Do not propose fixes if the DeclStmt has multiple VarDecls or in macros
@@ -96,7 +98,8 @@ void UnnecessaryCopyInitialization::chec
   return;
 
   if (OldVar == nullptr) {
-handleCopyFromMethodReturn(*NewVar, *BlockStmt, IssueFix, *Result.Context);
+handleCopyFromMethodReturn(*NewVar, *BlockStmt, IssueFix, ObjectArg,
+   *Result.Context);
   } else {
 handleCopyFromLocalVar(*NewVar, *OldVar, *BlockStmt, IssueFix,
*Result.Context);
@@ -105,10 +108,13 @@ void UnnecessaryCopyInitialization::chec
 
 void UnnecessaryCopyInitialization::handleCopyFromMethodReturn(
 const VarDecl &Var, const Stmt &BlockStmt, bool IssueFix,
-ASTContext &Context) {
+const VarDecl *ObjectArg, ASTContext &Context) {
   bool IsConstQualified = Var.getType().isConstQualified();
   if (!IsConstQualified && !isOnlyUsedAsConst(Var, BlockStmt, Context))
 return;
+  if (ObjectArg != nullptr &&
+  !isOnlyUsedAsConst(*ObjectArg, BlockStmt, Context))
+return;
 
   auto Diagnostic =
   diag(Var.getLocation(),

Modified: 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.h?rev=271239&r1=27

[libcxx] r271238 - Mark LWG issue 2565 as complete. Update the tests to check it.

2016-05-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May 30 19:23:31 2016
New Revision: 271238

URL: http://llvm.org/viewvc/llvm-project?rev=271238&view=rev
Log:
Mark LWG issue 2565 as complete. Update the tests to check it.

Added:

libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp
Removed:

libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp
Modified:

libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp?rev=271238&r1=271237&r2=271238&view=diff
==
--- 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
 Mon May 30 19:23:31 2016
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03
+
 // 
 
 // class function
@@ -14,8 +16,10 @@
 // template function(allocator_arg_t, const A&, function&&);
 
 #include 
+#include 
 #include 
 
+#include "test_macros.h"
 #include "min_allocator.h"
 #include "count_new.hpp"
 
@@ -46,23 +50,57 @@ public:
 
 int A::count = 0;
 
+int g(int) { return 0; }
+
 int main()
 {
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 assert(globalMemCounter.checkOutstandingNewEq(0));
 {
-std::function f = A();
-assert(A::count == 1);
-assert(globalMemCounter.checkOutstandingNewEq(1));
-assert(f.target());
-assert(f.target() == 0);
-std::function f2(std::allocator_arg, bare_allocator(), 
std::move(f));
-assert(A::count == 1);
-assert(globalMemCounter.checkOutstandingNewEq(1));
-assert(f2.target());
-assert(f2.target() == 0);
-assert(f.target() == 0);
-assert(f.target() == 0);
+std::function f = A();
+assert(A::count == 1);
+assert(globalMemCounter.checkOutstandingNewEq(1));
+assert(f.target());
+assert(f.target() == 0);
+std::function f2(std::allocator_arg, bare_allocator(), 
std::move(f));
+assert(A::count == 1);
+assert(globalMemCounter.checkOutstandingNewEq(1));
+assert(f2.target());
+assert(f2.target() == 0);
+assert(f.target() == 0);
+assert(f.target() == 0);
+}
+assert(globalMemCounter.checkOutstandingNewEq(0));
+{
+// Test that moving a function constructed from a reference wrapper
+// is done without allocating.
+DisableAllocationGuard g;
+using Ref = std::reference_wrapper;
+A a;
+Ref aref(a);
+std::function f(aref);
+assert(A::count == 1);
+assert(f.target() == nullptr);
+assert(f.target());
+std::function f2(std::allocator_arg, std::allocator{},
+   std::move(f));
+assert(A::count == 1);
+assert(f2.target() == nullptr);
+assert(f2.target());
+assert(f.target()); // f is unchanged because the target is small
+}
+{
+// Test that moving a function constructed from a function pointer
+// is done without allocating
+DisableAllocationGuard guard;
+using Ptr = int(*)(int);
+Ptr p = g;
+std::function f(p);
+assert(f.target() == nullptr);
+assert(f.target());
+std::function f2(std::allocator_arg, std::allocator(),
+   std::move(f));
+assert(f2.target() == nullptr);
+assert(f2.target());
+assert(f.target()); // f is unchanged because the target is small
 }
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 }

Removed: 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp?rev=271237&view=auto
==
--- 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp
 (removed)
@@ -1,118 +0,0 @@
-//===--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and

Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-30 Thread Asiri Rathnayake via cfe-commits
rmaprath marked 6 inline comments as done.
rmaprath added a comment.

http://reviews.llvm.org/D20677



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


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-30 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 59009.
rmaprath added a comment.

Addressed review comments from @EricWF:

- Addressed the nits
- Disabled `backtrace_test.pass.cpp` for the moment, need to check if using 
`_Unwind_backtrace` with no unwinding tables (-fno-exceptions) makes sense
- Enabled a small part of `test_vector1.pass.cpp`, most of this test and other 
vector tests are to do with how exceptions are dealt with
- Added tests for the new functions introduced to `cxa_noexceptions.cpp`. These 
are mostly trivial.
- Added tests for the `__cxa_bad_cast` and `__cxa_bad_typeid` functions. Could 
not manage to invoke `__cxa_throw_bad_array_new_length`, which does not seem to 
work like documented in [1]. Need to take this offline.

[1] http://en.cppreference.com/w/cpp/memory/new/bad_array_new_length


http://reviews.llvm.org/D20677

Files:
  CMakeLists.txt
  src/CMakeLists.txt
  src/cxa_aux_runtime.cpp
  src/cxa_handlers.cpp
  src/cxa_new_delete.cpp
  src/cxa_noexception.cpp
  test/CMakeLists.txt
  test/backtrace_test.pass.cpp
  test/catch_array_01.pass.cpp
  test/catch_array_02.pass.cpp
  test/catch_class_01.pass.cpp
  test/catch_class_02.pass.cpp
  test/catch_class_03.pass.cpp
  test/catch_class_04.pass.cpp
  test/catch_const_pointer_nullptr.pass.cpp
  test/catch_function_01.pass.cpp
  test/catch_function_02.pass.cpp
  test/catch_in_noexcept.pass.cpp
  test/catch_member_data_pointer_01.pass.cpp
  test/catch_member_function_pointer_01.pass.cpp
  test/catch_member_pointer_nullptr.pass.cpp
  test/catch_multi_level_pointer.pass.cpp
  test/catch_pointer_nullptr.pass.cpp
  test/catch_pointer_reference.pass.cpp
  test/catch_ptr.pass.cpp
  test/catch_ptr_02.pass.cpp
  test/cxa_bad_cast.pass.cpp
  test/cxa_bad_typeid.pass.cpp
  test/incomplete_type.sh.cpp
  test/inherited_exception.pass.cpp
  test/libcxxabi/test/config.py
  test/lit.site.cfg.in
  test/noexception1.pass.cpp
  test/noexception2.pass.cpp
  test/noexception3.pass.cpp
  test/noexception4.pass.cpp
  test/test_aux_runtime.pass.cpp
  test/test_aux_runtime_op_array_new.pass.cpp
  test/test_guard.pass.cpp
  test/test_vector1.pass.cpp
  test/test_vector2.pass.cpp
  test/test_vector3.pass.cpp
  test/uncaught_exceptions.pass.cpp
  test/unwind_01.pass.cpp
  test/unwind_02.pass.cpp
  test/unwind_03.pass.cpp
  test/unwind_04.pass.cpp
  test/unwind_05.pass.cpp
  test/unwind_06.pass.cpp

Index: test/unwind_06.pass.cpp
===
--- test/unwind_06.pass.cpp
+++ test/unwind_06.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_05.pass.cpp
===
--- test/unwind_05.pass.cpp
+++ test/unwind_05.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_04.pass.cpp
===
--- test/unwind_04.pass.cpp
+++ test/unwind_04.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_03.pass.cpp
===
--- test/unwind_03.pass.cpp
+++ test/unwind_03.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_02.pass.cpp
===
--- test/unwind_02.pass.cpp
+++ test/unwind_02.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 
 struct A
Index: test/unwind_01.pass.cpp
===
--- test/unwind_01.pass.cpp
+++ test/unwind_01.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 
 struct A
Index: test/uncaught_exceptions.pass.cpp
===
--- test/uncaught_exceptions.pass.cpp
+++ test/uncaught_exceptions.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/test_vector3.pass.cpp
===
--- test/test_vector3.pass.cpp
+++ test/test_vector3.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+/

[libcxx] r271237 - Make string_view work with -fno-exceptions and get tests passing.

2016-05-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May 30 18:53:19 2016
New Revision: 271237

URL: http://llvm.org/viewvc/llvm-project?rev=271237&view=rev
Log:
Make string_view work with -fno-exceptions and get tests passing.

Modified:
libcxx/trunk/include/experimental/string_view

libcxx/trunk/test/std/experimental/string.view/string.view.access/at.pass.cpp

libcxx/trunk/test/std/experimental/string.view/string.view.comparison/opeq.string_view.string.pass.cpp

libcxx/trunk/test/std/experimental/string.view/string.view.ops/compare.pointer_size.pass.cpp

libcxx/trunk/test/std/experimental/string.view/string.view.ops/compare.size_size_sv.pass.cpp

libcxx/trunk/test/std/experimental/string.view/string.view.ops/compare.size_size_sv_pointer_size.pass.cpp

libcxx/trunk/test/std/experimental/string.view/string.view.ops/compare.size_size_sv_size_size.pass.cpp
libcxx/trunk/test/std/experimental/string.view/string.view.ops/copy.pass.cpp

libcxx/trunk/test/std/experimental/string.view/string.view.ops/substr.pass.cpp

Modified: libcxx/trunk/include/experimental/string_view
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/string_view?rev=271237&r1=271236&r2=271237&view=diff
==
--- libcxx/trunk/include/experimental/string_view (original)
+++ libcxx/trunk/include/experimental/string_view Mon May 30 18:53:19 2016
@@ -180,6 +180,7 @@ namespace std {
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include <__debug>
@@ -280,7 +281,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 const_reference at(size_type __pos) const
 {
 return __pos >= size()
-? (throw out_of_range("string_view::at"), __data[0])
+? (__libcpp_throw(out_of_range("string_view::at")), __data[0])
 : __data[__pos];
 }
 
@@ -351,7 +352,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
 {
 if ( __pos > size())
-throw out_of_range("string_view::copy");
+__libcpp_throw(out_of_range("string_view::copy"));
 size_type __rlen = _VSTD::min( __n, size() - __pos );
 _VSTD::copy_n(begin() + __pos, __rlen, __s );
 return __rlen;
@@ -365,7 +366,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 // size_type __rlen = _VSTD::min( __n, size() - __pos );
 // return basic_string_view(data() + __pos, __rlen);
 return __pos > size()
-? throw out_of_range("string_view::substr")
+? (__libcpp_throw((out_of_range("string_view::substr"))), 
basic_string_view())
 : basic_string_view(data() + __pos, _VSTD::min(__n, size() - 
__pos));
 }
 

Modified: 
libcxx/trunk/test/std/experimental/string.view/string.view.access/at.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/string.view/string.view.access/at.pass.cpp?rev=271237&r1=271236&r2=271237&view=diff
==
--- 
libcxx/trunk/test/std/experimental/string.view/string.view.access/at.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/experimental/string.view/string.view.access/at.pass.cpp 
Mon May 30 18:53:19 2016
@@ -10,7 +10,7 @@
 // NOTE: Older versions of clang have a bug where they fail to evalute
 // string_view::at as a constant expression.
 // XFAIL: clang-3.4, clang-3.3
-// XFAIL: libcpp-no-exceptions
+
 
 // 
 
@@ -20,6 +20,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 template 
 void test ( const CharT *s, size_t len ) {
 std::experimental::basic_string_view sv ( s, len );
@@ -27,11 +29,13 @@ void test ( const CharT *s, size_t len )
 for ( size_t i = 0; i < len; ++i ) {
 assert (  sv.at(i) == s[i] );
 assert ( &sv.at(i) == s + i );
-}
+}
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try { sv.at(len); } catch ( const std::out_of_range & ) { return ; }
 assert ( false );
-}
+#endif
+}
 
 int main () {
 test ( "ABCDE", 5 );
@@ -40,7 +44,7 @@ int main () {
 test ( L"ABCDE", 5 );
 test ( L"a", 1 );
 
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
 test ( u"ABCDE", 5 );
 test ( u"a", 1 );
 
@@ -48,7 +52,7 @@ int main () {
 test ( U"a", 1 );
 #endif
 
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
 {
 constexpr std::experimental::basic_string_view sv ( "ABC", 2 );
 static_assert ( sv.length() ==  2,  "" );

Modified: 
libcxx/trunk/test/std/experimental/string.view/string.view.comparison/opeq.string_view.string.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/string.view/string.view.comparison/opeq.string_view.string.pass.cpp?rev=271237&r1=271236&r2=271237&view=diff
==
--- 
libcxx/trunk/test/std/experimental/string

Re: r271211 - CodeGen: tweak CFConstantStrings for COFF and ELF

2016-05-30 Thread Rafael Espíndola via cfe-commits
On 30 May 2016 at 16:48, Saleem Abdulrasool  wrote:
> On Mon, May 30, 2016 at 12:54 PM, Rafael Espíndola
>  wrote:
>>
>> Why .rodata.cfstring? Which linker treats that specially?
>
>
> Its mimicking the fact that the CF macros tried to place the structures in
> their own section.  This would technically allow a linker to coalesce the
> CFString structures (though, AFAIK, none do atm ... perhaps lld should be
> the first!).  In the worst case, this will just get collapsed into the
> .rodata section, so its no worse off.

BTW, if this is to be coalesced, I think the ELF way to do it would be
to mark the section SHF_MERGE and propose a new SHF_CFSTRING section
flag.

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


[libcxx] r271235 - Cleanup error handling when TLS creation fails

2016-05-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May 30 18:15:19 2016
New Revision: 271235

URL: http://llvm.org/viewvc/llvm-project?rev=271235&view=rev
Log:
Cleanup error handling when TLS creation fails

Modified:
libcxx/trunk/include/thread

Modified: libcxx/trunk/include/thread
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/thread?rev=271235&r1=271234&r2=271235&view=diff
==
--- libcxx/trunk/include/thread (original)
+++ libcxx/trunk/include/thread Mon May 30 18:15:19 2016
@@ -176,11 +176,9 @@ __thread_specific_ptr<_Tp>::__thread_spe
 int __ec = __libcpp_tl_create(
 &__key_,
 &__thread_specific_ptr::__at_thread_exit);
-#ifndef _LIBCPP_NO_EXCEPTIONS
 if (__ec)
-throw system_error(error_code(__ec, system_category()),
+__throw_system_error(__ec,
"__thread_specific_ptr construction failed");
-#endif
 }
 
 template 


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


[libcxx] r271231 - Mark LWG issue #2522 as complete

2016-05-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May 30 16:30:46 2016
New Revision: 271231

URL: http://llvm.org/viewvc/llvm-project?rev=271231&view=rev
Log:
Mark LWG issue #2522 as complete

Modified:
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=271231&r1=271230&r2=271231&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Mon May 30 16:30:46 2016
@@ -207,7 +207,7 @@
http://cplusplus.github.io/LWG/lwg-defects.html#2296";>2296std::addressof
 should be constexprJacksonvilleComplete (Clang 
Only)
http://cplusplus.github.io/LWG/lwg-defects.html#2450";>2450(greater|less|greater_equal|less_equal)
 do not yield a total order for pointersJacksonville
http://cplusplus.github.io/LWG/lwg-defects.html#2520";>2520N4089
 broke initializing unique_ptr from a 
nullptrJacksonville
-   http://cplusplus.github.io/LWG/lwg-defects.html#2522";>2522[fund.ts.v2]
 Contradiction in set_default_resource 
specificationJacksonville
+   http://cplusplus.github.io/LWG/lwg-defects.html#2522";>2522[fund.ts.v2]
 Contradiction in set_default_resource 
specificationJacksonvilleComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2523";>2523std::promise
 synopsis shows two set_value_at_thread_exit()'s for no apparent 
reasonJacksonvilleComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2537";>2537Constructors
 for priority_queue taking allocators should call 
make_heapJacksonville
http://cplusplus.github.io/LWG/lwg-defects.html#2539";>2539[fund.ts.v2]
 invocation_trait definition definition doesn't work for surrogate 
call functionsJacksonville


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


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-30 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Looking good. I would like to see some tests for the methods we have specificly 
defined to have behavior in -fno-exceptions mode.



Comment at: src/cxa_noexception.cpp:27
@@ +26,3 @@
+
+_LIBCXXABI_FUNC_VIS void
+__cxa_increment_exception_refcount(void *thrown_object) throw() {

I think either all of the functions in this file should have 
`_LIBCXXABI_FUNC_VIS` or none of them should. My preference is none since the 
declarations should have them.


Comment at: src/cxa_noexception.cpp:29
@@ +28,3 @@
+__cxa_increment_exception_refcount(void *thrown_object) throw() {
+if (thrown_object != NULL)
+std::terminate();

nit: nullptr


Comment at: src/cxa_noexception.cpp:45
@@ +44,3 @@
+void
+__cxa_rethrow_primary_exception(void*) { return; }
+

I think we should terminate if `void*` is non-null.


Comment at: test/backtrace_test.pass.cpp:19
@@ -19,2 +19,2 @@
 }
 

Does this test have any value in -fno-exceptions mode?


Comment at: test/libcxxabi/test/config.py:46
@@ +45,3 @@
+if self.get_lit_bool('enable_exceptions', True):
+self.cxx.compile_flags += ['-funwind-tables', 
'-DLIBCXXABI_ENABLE_EXCEPTIONS']
+else:

Nit: I would prefer `LIBCXXABI_HAS_NO_EXCEPTIONS` since the default should be 
on. The fact that a macro is missing shouldn't disable half the tests.


Comment at: test/test_vector1.pass.cpp:8
@@ -7,3 +7,3 @@
 //
 
//===--===//
 

Don't you want these tests to run? They aren't part of the exception API AFAIK.


Comment at: test/uncaught_exceptions.pass.cpp:10
@@ -9,1 +9,3 @@
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+

We provided a different implementation so we should test it, not disable the 
test.


http://reviews.llvm.org/D20677



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


[PATCH] D20800: Make placeholders constexpr in C++17

2016-05-30 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added a reviewer: mclow.lists.
EricWF added a subscriber: cfe-commits.

Implement LWG issue #2488 
(http://cplusplus.github.io/LWG/lwg-defects.html#2488).



http://reviews.llvm.org/D20800

Files:
  include/functional
  src/bind.cpp
  
test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp
  www/cxx1z_status.html

Index: www/cxx1z_status.html
===
--- www/cxx1z_status.html
+++ www/cxx1z_status.html
@@ -161,7 +161,7 @@
 	http://cplusplus.github.io/LWG/lwg-defects.html#2467";>2467is_always_equal has slightly inconsistent defaultLenexaComplete
 	http://cplusplus.github.io/LWG/lwg-defects.html#2470";>2470Allocator's destroy function should be allowed to fail to instantiateLenexaComplete
 	http://cplusplus.github.io/LWG/lwg-defects.html#2482";>2482[c.strings] Table 73 mentions nonexistent functionsLenexaComplete
-	http://cplusplus.github.io/LWG/lwg-defects.html#2488";>2488Placeholders should be allowed and encouraged to be constexprLenexa
+	http://cplusplus.github.io/LWG/lwg-defects.html#2488";>2488Placeholders should be allowed and encouraged to be constexprLenexaComplete
  	
 	http://cplusplus.github.io/LWG/lwg-defects.html#1169";>1169num_get not fully compatible with strto*Kona
 	http://cplusplus.github.io/LWG/lwg-defects.html#2072";>2072Unclear wording about capacity of temporary buffersKonaComplete
Index: test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp
===
--- test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp
+++ test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp
@@ -10,10 +10,29 @@
 // 
 
 // placeholders
+// The placeholders are constexpr in C++17 and beyond
 
 #include 
 #include 
 
+#include "test_macros.h"
+
+#if TEST_STD_VER > 14
+template 
+constexpr bool constexpr_test(const T& t)
+{
+// Test default constructible.
+T t2;
+((void)t2);
+// Test copy constructible.
+T t3 = t;
+((void)t3);
+static_assert(std::is_nothrow_copy_constructible::value, "");
+static_assert(std::is_nothrow_move_constructible::value, "");
+return true;
+}
+#endif
+
 template 
 void
 test(const T& t)
@@ -40,4 +59,16 @@
 test(std::placeholders::_8);
 test(std::placeholders::_9);
 test(std::placeholders::_10);
+#if TEST_STD_VER > 14
+static_assert(constexpr_test(std::placeholders::_1));
+static_assert(constexpr_test(std::placeholders::_2));
+static_assert(constexpr_test(std::placeholders::_3));
+static_assert(constexpr_test(std::placeholders::_4));
+static_assert(constexpr_test(std::placeholders::_5));
+static_assert(constexpr_test(std::placeholders::_6));
+static_assert(constexpr_test(std::placeholders::_7));
+static_assert(constexpr_test(std::placeholders::_8));
+static_assert(constexpr_test(std::placeholders::_9));
+static_assert(constexpr_test(std::placeholders::_10));
+#endif
 }
Index: src/bind.cpp
===
--- src/bind.cpp
+++ src/bind.cpp
@@ -7,6 +7,7 @@
 //
 //===--===//
 
+#define _LIBCPP_BUILDING_BIND
 #include "functional"
 
 _LIBCPP_BEGIN_NAMESPACE_STD
Index: include/functional
===
--- include/functional
+++ include/functional
@@ -1978,6 +1978,7 @@
 
 template  struct __ph {};
 
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_BUILDING_BIND)
 _LIBCPP_FUNC_VIS extern __ph<1>   _1;
 _LIBCPP_FUNC_VIS extern __ph<2>   _2;
 _LIBCPP_FUNC_VIS extern __ph<3>   _3;
@@ -1988,6 +1989,18 @@
 _LIBCPP_FUNC_VIS extern __ph<8>   _8;
 _LIBCPP_FUNC_VIS extern __ph<9>   _9;
 _LIBCPP_FUNC_VIS extern __ph<10> _10;
+#else
+constexpr __ph<1>   _1;
+constexpr __ph<2>   _2;
+constexpr __ph<3>   _3;
+constexpr __ph<4>   _4;
+constexpr __ph<5>   _5;
+constexpr __ph<6>   _6;
+constexpr __ph<7>   _7;
+constexpr __ph<8>   _8;
+constexpr __ph<9>   _9;
+constexpr __ph<10> _10;
+#endif
 
 }  // placeholders
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20784: [libcxx][libcxxabi] Decouple no-exceptions libcpp variant from cxa_exception.cpp and cxa_personality.cpp of libcxxabi

2016-05-30 Thread Asiri Rathnayake via cfe-commits
rmaprath abandoned this revision.
rmaprath added a comment.

Updated http://reviews.llvm.org/D20677 with the necessary changes. This patch 
is no longer required.


http://reviews.llvm.org/D20784



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


Re: [PATCH] D20798: clang-format: [JS] Sort imported symbols.

2016-05-30 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 59001.
mprobst added a comment.

- extract method for readability


http://reviews.llvm.org/D20798

Files:
  lib/Format/Format.cpp
  lib/Format/SortJavaScriptImports.cpp
  unittests/Format/SortImportsTestJS.cpp

Index: unittests/Format/SortImportsTestJS.cpp
===
--- unittests/Format/SortImportsTestJS.cpp
+++ unittests/Format/SortImportsTestJS.cpp
@@ -101,6 +101,13 @@
  "import {sym1 as alias1} from 'b';\n");
 }
 
+TEST_F(SortImportsTestJS, SortSymbols) {
+  verifySort("import {sym1, sym2 as a, sym3} from 'b';\n",
+ "import {sym2 as a, sym1, sym3} from 'b';\n");
+  verifySort("import {sym1 /* important! */, /*!*/ sym2 as a} from 'b';\n",
+ "import {/*!*/ sym2 as a, sym1 /* important! */} from 'b';\n");
+}
+
 TEST_F(SortImportsTestJS, GroupImports) {
   verifySort("import {a} from 'absolute';\n"
  "\n"
Index: lib/Format/SortJavaScriptImports.cpp
===
--- lib/Format/SortJavaScriptImports.cpp
+++ lib/Format/SortJavaScriptImports.cpp
@@ -25,6 +25,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Debug.h"
+#include 
 #include 
 
 #define DEBUG_TYPE "format-formatter"
@@ -40,6 +41,11 @@
 struct JsImportedSymbol {
   StringRef Symbol;
   StringRef Alias;
+  SourceRange Range;
+
+  bool operator==(const JsImportedSymbol &RHS) const {
+return Symbol == RHS.Symbol && Alias == RHS.Alias;
+  }
 };
 
 // An ES6 module reference.
@@ -139,23 +145,14 @@
  [&](unsigned LHSI, unsigned RHSI) {
return References[LHSI] < References[RHSI];
  });
-// FIXME: Pull this into a common function.
-bool OutOfOrder = false;
-for (unsigned i = 0, e = Indices.size(); i != e; ++i) {
-  if (i != Indices[i]) {
-OutOfOrder = true;
-break;
-  }
-}
-if (!OutOfOrder)
-  return Result;
+bool ReferencesInOrder = std::is_sorted(Indices.begin(), Indices.end());
 
-// Replace all existing import/export statements.
 std::string ReferencesText;
+bool SymbolsInOrder = true;
 for (unsigned i = 0, e = Indices.size(); i != e; ++i) {
   JsModuleReference Reference = References[Indices[i]];
-  StringRef ReferenceStmt = getSourceText(Reference.Range);
-  ReferencesText += ReferenceStmt;
+  if (appendReference(ReferencesText, Reference))
+SymbolsInOrder = false;
   if (i + 1 < e) {
 // Insert breaks between imports and exports.
 ReferencesText += "\n";
@@ -167,6 +164,11 @@
   ReferencesText += "\n";
   }
 }
+
+if (ReferencesInOrder && SymbolsInOrder) {
+  return Result;
+}
+
 // Separate references from the main code body of the file.
 if (FirstNonImportLine && FirstNonImportLine->First->NewlinesBefore < 2)
   ReferencesText += "\n";
@@ -211,10 +213,44 @@
   }
 
   StringRef getSourceText(SourceRange Range) {
+return getSourceText(Range.getBegin(), Range.getEnd());
+  }
+
+  StringRef getSourceText(SourceLocation Begin, SourceLocation End) {
 const SourceManager &SM = Env.getSourceManager();
-return FileContents.substr(SM.getFileOffset(Range.getBegin()),
-   SM.getFileOffset(Range.getEnd()) -
-   SM.getFileOffset(Range.getBegin()));
+return FileContents.substr(SM.getFileOffset(Begin),
+   SM.getFileOffset(End) - SM.getFileOffset(Begin));
+  }
+
+  // Appends ``Reference`` to ``Buffer``, returning true if text within the
+  // ``Reference`` changed (e.g. symbol order).
+  bool appendReference(std::string &Buffer, JsModuleReference &Reference) {
+// Sort the individual symbols within the import.
+// E.g. `import {b, a} from 'x';` -> `import {a, b} from 'x';`
+SmallVector Symbols = Reference.Symbols;
+std::stable_sort(Symbols.begin(), Symbols.end(),
+ [&](JsImportedSymbol LHS, JsImportedSymbol RHS) {
+   return LHS.Symbol < RHS.Symbol;
+ });
+if (Symbols == Reference.Symbols) {
+  // No change in symbol order.
+  StringRef ReferenceStmt = getSourceText(Reference.Range);
+  Buffer += ReferenceStmt;
+  return false;
+}
+// Stitch together the module reference start...
+SourceLocation SymbolsStart = Reference.Symbols.front().Range.getBegin();
+SourceLocation SymbolsEnd = Reference.Symbols.back().Range.getEnd();
+Buffer += getSourceText(Reference.Range.getBegin(), SymbolsStart);
+// ... then the references in order ...
+for (JsImportedSymbol *I = Symbols.begin(), *E = Symbols.end(); I != E;) {
+  Buffer += getSourceText(I->Range);
+  if (++I != E)
+Buffer += ",";
+}
+// ... followed by the module reference end.
+Buffer += getSourceText(SymbolsEnd,

Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-30 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 59000.
rmaprath added a comment.

Addressing review comments from @EricWF:

- Rather than explicitly decoupling the no-exceptions `libc++` library from the 
`__cxa_*` routines (http://reviews.llvm.org/D20784), provide a placeholder 
implementation of those functions within the no-exceptions `libc++abi` library. 
We still have some symbols like `__cxa_throw` removed from the no-exceptions 
`libc++abi` library (those symbols are generated from the compiler, rather than 
found in the library), so the original requirement of not allowing linking 
with-exceptions code with no-exceptions `libc++abi` library is satisfied.


http://reviews.llvm.org/D20677

Files:
  CMakeLists.txt
  src/CMakeLists.txt
  src/cxa_aux_runtime.cpp
  src/cxa_handlers.cpp
  src/cxa_new_delete.cpp
  src/cxa_noexception.cpp
  test/CMakeLists.txt
  test/backtrace_test.pass.cpp
  test/catch_array_01.pass.cpp
  test/catch_array_02.pass.cpp
  test/catch_class_01.pass.cpp
  test/catch_class_02.pass.cpp
  test/catch_class_03.pass.cpp
  test/catch_class_04.pass.cpp
  test/catch_const_pointer_nullptr.pass.cpp
  test/catch_function_01.pass.cpp
  test/catch_function_02.pass.cpp
  test/catch_in_noexcept.pass.cpp
  test/catch_member_data_pointer_01.pass.cpp
  test/catch_member_function_pointer_01.pass.cpp
  test/catch_member_pointer_nullptr.pass.cpp
  test/catch_multi_level_pointer.pass.cpp
  test/catch_pointer_nullptr.pass.cpp
  test/catch_pointer_reference.pass.cpp
  test/catch_ptr.pass.cpp
  test/catch_ptr_02.pass.cpp
  test/incomplete_type.sh.cpp
  test/inherited_exception.pass.cpp
  test/libcxxabi/test/config.py
  test/lit.site.cfg.in
  test/test_aux_runtime.pass.cpp
  test/test_aux_runtime_op_array_new.pass.cpp
  test/test_guard.pass.cpp
  test/test_vector1.pass.cpp
  test/test_vector2.pass.cpp
  test/test_vector3.pass.cpp
  test/uncaught_exceptions.pass.cpp
  test/unwind_01.pass.cpp
  test/unwind_02.pass.cpp
  test/unwind_03.pass.cpp
  test/unwind_04.pass.cpp
  test/unwind_05.pass.cpp
  test/unwind_06.pass.cpp

Index: test/unwind_06.pass.cpp
===
--- test/unwind_06.pass.cpp
+++ test/unwind_06.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_05.pass.cpp
===
--- test/unwind_05.pass.cpp
+++ test/unwind_05.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_04.pass.cpp
===
--- test/unwind_04.pass.cpp
+++ test/unwind_04.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_03.pass.cpp
===
--- test/unwind_03.pass.cpp
+++ test/unwind_03.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_02.pass.cpp
===
--- test/unwind_02.pass.cpp
+++ test/unwind_02.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 
 struct A
Index: test/unwind_01.pass.cpp
===
--- test/unwind_01.pass.cpp
+++ test/unwind_01.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 
 struct A
Index: test/uncaught_exceptions.pass.cpp
===
--- test/uncaught_exceptions.pass.cpp
+++ test/uncaught_exceptions.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/test_vector3.pass.cpp
===
--- test/test_vector3.pass.cpp
+++ test/test_vector3.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include "cxxabi.h"
 
 #include 
Index: test/test_vector2.pass.cpp
===
--- test/test_vector2.pass.cpp
+++ test/test_vector2.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--

[PATCH] D20799: Add C++17 std::not_fn negator.

2016-05-30 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added a reviewer: mclow.lists.
EricWF added a subscriber: cfe-commits.

Exactly what it sounds like.

I plan to commit this in a couple of days assuming no objections.

http://reviews.llvm.org/D20799

Files:
  include/functional
  test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp
  www/cxx1z_status.html

Index: www/cxx1z_status.html
===
--- www/cxx1z_status.html
+++ www/cxx1z_status.html
@@ -83,7 +83,7 @@
 	http://wg21.link/P0220R1";>P0220R1LWGAdopt Library Fundamentals V1 TS Components for C++17Jacksonville
 	http://wg21.link/P0218R1";>P0218R1LWGAdopt the File System TS for C++17Jacksonville	
 	http://wg21.link/P0033R1";>P0033R1LWGRe-enabling shared_from_thisJacksonville
-	http://wg21.link/P0005R4";>P0005R4LWGAdopt not_fn from Library Fundamentals 2 for C++17Jacksonville
+	http://wg21.link/P0005R4";>P0005R4LWGAdopt not_fn from Library Fundamentals 2 for C++17JacksonvilleComplete3.9
 	http://wg21.link/P0152R1";>P0152R1LWGconstexpr atomic::is_always_lock_freeJacksonvilleComplete3.9
 	http://wg21.link/P0185R1";>P0185R1LWGAdding [nothrow-]swappable traitsJacksonvilleComplete3.9
 	http://wg21.link/P0253R1";>P0253R1LWGFixing a design mistake in the searchers interfaceJacksonvilleComplete3.9
Index: test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp
===
--- /dev/null
+++ test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp
@@ -0,0 +1,459 @@
+//===--===//
+//
+// 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, c++11, c++14
+
+// template  unspecified not_fn(F&& f);
+
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+#include "type_id.h"
+
+
+///
+//   CALLABLE TEST TYPES
+///
+
+bool returns_true() { return true; }
+
+template 
+struct MoveOnlyCallable {
+  MoveOnlyCallable(MoveOnlyCallable const&) = delete;
+  MoveOnlyCallable(MoveOnlyCallable&& other)
+  : value(other.value)
+  { other.value = !other.value; }
+
+  template 
+  Ret operator()(Args&&...) { return Ret{value}; }
+
+  explicit MoveOnlyCallable(bool x) : value(x) {}
+  Ret value;
+};
+
+template 
+struct CopyCallable {
+  CopyCallable(CopyCallable const& other)
+  : value(other.value) {}
+
+  CopyCallable(CopyCallable&& other)
+  : value(other.value) { other.value = !other.value; }
+
+  template 
+  Ret operator()(Args&&...) { return Ret{value}; }
+
+  explicit CopyCallable(bool x) : value(x)  {}
+  Ret value;
+};
+
+struct CopyAssignableWrapper {
+  CopyAssignableWrapper(CopyAssignableWrapper const&) = default;
+  CopyAssignableWrapper(CopyAssignableWrapper&&) = default;
+  CopyAssignableWrapper& operator=(CopyAssignableWrapper const&) = default;
+  CopyAssignableWrapper& operator=(CopyAssignableWrapper &&) = default;
+
+  template 
+  bool operator()(Args&&...) { return value; }
+
+  explicit CopyAssignableWrapper(bool x) : value(x) {}
+  bool value;
+};
+
+
+struct MoveAssignableWrapper {
+  MoveAssignableWrapper(MoveAssignableWrapper const&) = delete;
+  MoveAssignableWrapper(MoveAssignableWrapper&&) = default;
+  MoveAssignableWrapper& operator=(MoveAssignableWrapper const&) = delete;
+  MoveAssignableWrapper& operator=(MoveAssignableWrapper &&) = default;
+
+  template 
+  bool operator()(Args&&...) { return value; }
+
+  explicit MoveAssignableWrapper(bool x) : value(x) {}
+  bool value;
+};
+
+struct MemFunCallable {
+  explicit MemFunCallable(bool x) : value(x) {}
+
+  bool return_value() const { return value; }
+  bool return_value_nc() { return value; }
+  bool value;
+};
+
+enum CallType {
+  CT_None,
+  CT_Const,
+  CT_NonConst
+};
+
+struct ForwardingCallObject {
+
+  template 
+  bool operator()(Args&&... args) & {
+  set_call(CT_NonConst);
+  return true;
+  }
+
+  template 
+  bool operator()(Args&&... args) const & {
+  set_call(CT_Const);
+  return true;
+  }
+
+  // Don't allow the call operator to be invoked as an rvalue.
+  template 
+  bool operator()(Args&&... args) && = delete;
+
+  template 
+  bool operator()(Args&&... args) const && = delete;
+
+  template 
+  static void set_call(CallType type) {
+  assert(last_call_type == CT_None);
+  assert(last_call_args == nullptr);
+  last_call_type = type;
+  last_call_args = &makeArgumentID();
+  }
+
+  template 
+  static bool check_call(CallType type) {
+  bool result =
+   last_call_type == type
+&& last_

Re: r271211 - CodeGen: tweak CFConstantStrings for COFF and ELF

2016-05-30 Thread Saleem Abdulrasool via cfe-commits
On Mon, May 30, 2016 at 12:54 PM, Rafael Espíndola <
rafael.espind...@gmail.com> wrote:

> Why .rodata.cfstring? Which linker treats that specially?
>

Its mimicking the fact that the CF macros tried to place the structures in
their own section.  This would technically allow a linker to coalesce the
CFString structures (though, AFAIK, none do atm ... perhaps lld should be
the first!).  In the worst case, this will just get collapsed into the
.rodata section, so its no worse off.


> On 30 May 2016 at 12:23, Saleem Abdulrasool via cfe-commits
>  wrote:
> > Author: compnerd
> > Date: Mon May 30 11:23:07 2016
> > New Revision: 271211
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=271211&view=rev
> > Log:
> > CodeGen: tweak CFConstantStrings for COFF and ELF
> >
> > Adjust the constant CFString emission to emit into more appropriate
> sections on
> > ELF and COFF targets.  It would previously try to use MachO section names
> > irrespective of the file format.
> >
> > Added:
> > cfe/trunk/test/CodeGen/CFStrings.c
> > Modified:
> > cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> >
> > Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=271211&r1=271210&r2=271211&view=diff
> >
> ==
> > --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
> > +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon May 30 11:23:07 2016
> > @@ -3092,19 +3092,19 @@ CodeGenModule::GetAddrOfConstantCFString
> >llvm::Constant *Zero = llvm::Constant::getNullValue(Int32Ty);
> >llvm::Constant *Zeros[] = { Zero, Zero };
> >llvm::Value *V;
> > -
> > +
> >// If we don't already have it, get __CFConstantStringClassReference.
> >if (!CFConstantStringClassRef) {
> >  llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy);
> >  Ty = llvm::ArrayType::get(Ty, 0);
> > -llvm::Constant *GV = CreateRuntimeVariable(Ty,
> > -
>  "__CFConstantStringClassReference");
> > +llvm::Constant *GV =
> > +CreateRuntimeVariable(Ty, "__CFConstantStringClassReference");
> >  // Decay array -> ptr
> >  V = llvm::ConstantExpr::getGetElementPtr(Ty, GV, Zeros);
> >  CFConstantStringClassRef = V;
> > -  }
> > -  else
> > +  } else {
> >  V = CFConstantStringClassRef;
> > +  }
> >
> >QualType CFTy = getContext().getCFConstantStringType();
> >
> > @@ -3117,8 +3117,8 @@ CodeGenModule::GetAddrOfConstantCFString
> >
> >// Flags.
> >llvm::Type *Ty = getTypes().ConvertType(getContext().UnsignedIntTy);
> > -  Fields[1] = isUTF16 ? llvm::ConstantInt::get(Ty, 0x07d0) :
> > -llvm::ConstantInt::get(Ty, 0x07C8);
> > +  Fields[1] = isUTF16 ? llvm::ConstantInt::get(Ty, 0x07d0)
> > +  : llvm::ConstantInt::get(Ty, 0x07C8);
> >
> >// String pointer.
> >llvm::Constant *C = nullptr;
> > @@ -3139,18 +3139,17 @@ CodeGenModule::GetAddrOfConstantCFString
> >GV->setUnnamedAddr(true);
> >// Don't enforce the target's minimum global alignment, since the
> only use
> >// of the string is via this class initializer.
> > -  // FIXME: We set the section explicitly to avoid a bug in ld64 224.1.
> Without
> > -  // it LLVM can merge the string with a non unnamed_addr one during
> LTO. Doing
> > -  // that changes the section it ends in, which surprises ld64.
> > -  if (isUTF16) {
> > -CharUnits Align =
> getContext().getTypeAlignInChars(getContext().ShortTy);
> > -GV->setAlignment(Align.getQuantity());
> > -GV->setSection("__TEXT,__ustring");
> > -  } else {
> > -CharUnits Align =
> getContext().getTypeAlignInChars(getContext().CharTy);
> > -GV->setAlignment(Align.getQuantity());
> > -GV->setSection("__TEXT,__cstring,cstring_literals");
> > -  }
> > +  CharUnits Align = isUTF16
> > +?
> getContext().getTypeAlignInChars(getContext().ShortTy)
> > +:
> getContext().getTypeAlignInChars(getContext().CharTy);
> > +  GV->setAlignment(Align.getQuantity());
> > +
> > +  // FIXME: We set the section explicitly to avoid a bug in ld64 224.1.
> > +  // Without it LLVM can merge the string with a non unnamed_addr one
> during
> > +  // LTO.  Doing that changes the section it ends in, which surprises
> ld64.
> > +  if (getTarget().getTriple().getObjectFormat() == llvm::Triple::MachO)
> > +GV->setSection(isUTF16 ? "__TEXT,__ustring"
> > +   : "__TEXT,__cstring,cstring_literals");
> >
> >// String.
> >Fields[2] =
> > @@ -3171,8 +3170,20 @@ CodeGenModule::GetAddrOfConstantCFString
> >GV = new llvm::GlobalVariable(getModule(), C->getType(), true,
> >  llvm::GlobalVariable::PrivateLinkage, C,
> >  "_unnamed_cfstring_");
> > -  GV->setSection("__DATA,__cfstring");
> >GV->setAlignment(Alignment.getQuantity());
> > +  switch (getTarget().getTriple().getObjectFormat())

Re: [PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().

2016-05-30 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 58993.
ioeric added a comment.

- Removed inline from isHeaderInsertion.


http://reviews.llvm.org/D20734

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  unittests/Format/CleanupTest.cpp

Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -281,6 +281,331 @@
   EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
 }
 
+TEST_F(CleanUpReplacementsTest, NoExistingIncludeWithoutDefine) {
+  std::string Code = "int main() {}";
+  std::string Expected = "#include \"a.h\"\n"
+ "int main() {}";
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(
+  tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"a.h\""));
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces));
+}
+
+TEST_F(CleanUpReplacementsTest, NoExistingIncludeWithDefine) {
+  std::string Code = "#ifndef __A_H__\n"
+ "#define __A_H__\n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+  std::string Expected = "#ifndef __A_H__\n"
+ "#define __A_H__\n"
+ "#include \"b.h\"\n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(
+  tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"b.h\""));
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces));
+}
+
+TEST_F(CleanUpReplacementsTest, InsertBeforeCategoryWithLowerPriority) {
+  std::string Code = "#ifndef __A_H__\n"
+ "#define __A_H__\n"
+ "\n"
+ "\n"
+ "\n"
+ "#include \n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+  std::string Expected = "#ifndef __A_H__\n"
+ "#define __A_H__\n"
+ "\n"
+ "\n"
+ "\n"
+ "#include \"a.h\"\n"
+ "#include \n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(
+  tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"a.h\""));
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces));
+}
+
+TEST_F(CleanUpReplacementsTest, InsertAfterMainHeader) {
+  std::string Code = "#include \"fix.h\"\n"
+ "\n"
+ "int main() {}";
+  std::string Expected = "#include \"fix.h\"\n"
+ "#include \n"
+ "\n"
+ "int main() {}";
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include "));
+  format::FormatStyle Style =
+  format::getGoogleStyle(format::FormatStyle::LanguageKind::LK_Cpp);
+  auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces));
+}
+
+TEST_F(CleanUpReplacementsTest, InsertBeforeSystemHeaderLLVM) {
+  std::string Code = "#include \n"
+ "\n"
+ "int main() {}";
+  std::string Expected = "#include \"z.h\"\n"
+ "#include \n"
+ "\n"
+ "int main() {}";
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(
+  tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"z.h\""));
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces));
+}
+
+TEST_F(CleanUpReplacementsTest, InsertAfterSystemHeaderGoogle) {
+  std::string Code = "#include \n"
+ "\n"
+ "int main() {}";
+  std::string Expected = "#include \n"
+ "#include \"z.h\"\n"
+ "\n"
+ "int main() {}";
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replace

Re: [PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().

2016-05-30 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 58992.
ioeric marked 3 inline comments as done.
ioeric added a comment.

- Addressed reviewer's comments.


http://reviews.llvm.org/D20734

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  unittests/Format/CleanupTest.cpp

Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -281,6 +281,331 @@
   EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
 }
 
+TEST_F(CleanUpReplacementsTest, NoExistingIncludeWithoutDefine) {
+  std::string Code = "int main() {}";
+  std::string Expected = "#include \"a.h\"\n"
+ "int main() {}";
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(
+  tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"a.h\""));
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces));
+}
+
+TEST_F(CleanUpReplacementsTest, NoExistingIncludeWithDefine) {
+  std::string Code = "#ifndef __A_H__\n"
+ "#define __A_H__\n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+  std::string Expected = "#ifndef __A_H__\n"
+ "#define __A_H__\n"
+ "#include \"b.h\"\n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(
+  tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"b.h\""));
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces));
+}
+
+TEST_F(CleanUpReplacementsTest, InsertBeforeCategoryWithLowerPriority) {
+  std::string Code = "#ifndef __A_H__\n"
+ "#define __A_H__\n"
+ "\n"
+ "\n"
+ "\n"
+ "#include \n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+  std::string Expected = "#ifndef __A_H__\n"
+ "#define __A_H__\n"
+ "\n"
+ "\n"
+ "\n"
+ "#include \"a.h\"\n"
+ "#include \n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(
+  tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"a.h\""));
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces));
+}
+
+TEST_F(CleanUpReplacementsTest, InsertAfterMainHeader) {
+  std::string Code = "#include \"fix.h\"\n"
+ "\n"
+ "int main() {}";
+  std::string Expected = "#include \"fix.h\"\n"
+ "#include \n"
+ "\n"
+ "int main() {}";
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include "));
+  format::FormatStyle Style =
+  format::getGoogleStyle(format::FormatStyle::LanguageKind::LK_Cpp);
+  auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces));
+}
+
+TEST_F(CleanUpReplacementsTest, InsertBeforeSystemHeaderLLVM) {
+  std::string Code = "#include \n"
+ "\n"
+ "int main() {}";
+  std::string Expected = "#include \"z.h\"\n"
+ "#include \n"
+ "\n"
+ "int main() {}";
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(
+  tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"z.h\""));
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces));
+}
+
+TEST_F(CleanUpReplacementsTest, InsertAfterSystemHeaderGoogle) {
+  std::string Code = "#include \n"
+ "\n"
+ "int main() {}";
+  std::string Expected = "#include \n"
+ "#include \"z.h\"\n"
+ "\n"
+ "int main() {}";
+  Context.createInMemoryFile("fix.cpp", Code);

Re: [PATCH] D20133: [OpenCL] Fix __builtin_astype for vec3 types.

2016-05-30 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 58991.
yaxunl marked 5 inline comments as done.
yaxunl added a comment.

Fix variable capitalization and indentation.


http://reviews.llvm.org/D20133

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGenOpenCL/as_type.cl

Index: test/CodeGenOpenCL/as_type.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/as_type.cl
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple spir-unknown-unknown -o - | FileCheck %s
+
+typedef __attribute__(( ext_vector_type(3) )) char char3;
+typedef __attribute__(( ext_vector_type(4) )) char char4;
+typedef __attribute__(( ext_vector_type(16) )) char char16;
+typedef __attribute__(( ext_vector_type(3) )) int int3;
+
+//CHECK: define spir_func <3 x i8> @f1(<4 x i8> %[[x:.*]])
+//CHECK: %[[astype:.*]] = shufflevector <4 x i8> %[[x]], <4 x i8> undef, <3 x i32> 
+//CHECK: ret <3 x i8> %[[astype]]
+char3 f1(char4 x) {
+  return  __builtin_astype(x, char3);
+}
+
+//CHECK: define spir_func <4 x i8> @f2(<3 x i8> %[[x:.*]])
+//CHECK: %[[astype:.*]] = shufflevector <3 x i8> %[[x]], <3 x i8> undef, <4 x i32> 
+//CHECK: ret <4 x i8> %[[astype]]
+char4 f2(char3 x) {
+  return __builtin_astype(x, char4);
+}
+
+//CHECK: define spir_func <3 x i8> @f3(i32 %[[x:.*]])
+//CHECK: %[[cast:.*]] = bitcast i32 %[[x]] to <4 x i8>
+//CHECK: %[[astype:.*]] = shufflevector <4 x i8> %[[cast]], <4 x i8> undef, <3 x i32> 
+//CHECK: ret <3 x i8> %[[astype]]
+char3 f3(int x) {
+  return __builtin_astype(x, char3);
+}
+
+//CHECK: define spir_func <4 x i8> @f4(i32 %[[x:.*]])
+//CHECK: %[[astype:.*]] = bitcast i32 %[[x]] to <4 x i8>
+//CHECK: ret <4 x i8> %[[astype]]
+char4 f4(int x) {
+  return __builtin_astype(x, char4);
+}
+
+//CHECK: define spir_func i32 @f5(<3 x i8> %[[x:.*]])
+//CHECK: %[[shuffle:.*]] = shufflevector <3 x i8> %[[x]], <3 x i8> undef, <4 x i32> 
+//CHECK: %[[astype:.*]] = bitcast <4 x i8> %[[shuffle]] to i32
+//CHECK: ret i32 %[[astype]]
+int f5(char3 x) {
+  return __builtin_astype(x, int);
+}
+
+//CHECK: define spir_func i32 @f6(<4 x i8> %[[x:.*]])
+//CHECK: %[[astype]] = bitcast <4 x i8> %[[x]] to i32
+//CHECK: ret i32 %[[astype]]
+int f6(char4 x) {
+  return __builtin_astype(x, int);
+}
+
+//CHECK: define spir_func <3 x i8> @f7(<3 x i8> %[[x:.*]])
+//CHECK: ret <3 x i8> %[[x]]
+char3 f7(char3 x) {
+  return __builtin_astype(x, char3);
+}
+
+//CHECK: define spir_func <3 x i32> @f8(<16 x i8> %[[x:.*]])
+//CHECK: %[[cast:.*]] = bitcast <16 x i8> %[[x]] to <4 x i32>
+//CHECK: %[[astype:.*]] = shufflevector <4 x i32> %[[cast]], <4 x i32> undef, <3 x i32> 
+//CHECK: ret <3 x i32> %[[astype]]
+int3 f8(char16 x) {
+  return __builtin_astype(x, int3);
+}
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -3382,50 +3382,48 @@
   return CGF.EmitBlockLiteral(block);
 }
 
+// Convert a vec3 to vec4, or vice versa.
+static Value *ConvertVec3AndVec4(CGBuilderTy &Builder, CodeGenFunction &CGF,
+ Value *Src, unsigned NumElementsDst) {
+  llvm::Value *UnV = llvm::UndefValue::get(Src->getType());
+  SmallVector Args;
+  Args.push_back(Builder.getInt32(0));
+  Args.push_back(Builder.getInt32(1));
+  Args.push_back(Builder.getInt32(2));
+  if (NumElementsDst == 4)
+Args.push_back(llvm::UndefValue::get(CGF.Int32Ty));
+  llvm::Constant *Mask = llvm::ConstantVector::get(Args);
+  return Builder.CreateShuffleVector(Src, UnV, Mask);
+}
+
 Value *ScalarExprEmitter::VisitAsTypeExpr(AsTypeExpr *E) {
   Value *Src  = CGF.EmitScalarExpr(E->getSrcExpr());
   llvm::Type *DstTy = ConvertType(E->getType());
 
-  // Going from vec4->vec3 or vec3->vec4 is a special case and requires
-  // a shuffle vector instead of a bitcast.
   llvm::Type *SrcTy = Src->getType();
-  if (isa(DstTy) && isa(SrcTy)) {
-unsigned numElementsDst = cast(DstTy)->getNumElements();
-unsigned numElementsSrc = cast(SrcTy)->getNumElements();
-if ((numElementsDst == 3 && numElementsSrc == 4)
-|| (numElementsDst == 4 && numElementsSrc == 3)) {
-
-
-  // In the case of going from int4->float3, a bitcast is needed before
-  // doing a shuffle.
-  llvm::Type *srcElemTy =
-  cast(SrcTy)->getElementType();
-  llvm::Type *dstElemTy =
-  cast(DstTy)->getElementType();
-
-  if ((srcElemTy->isIntegerTy() && dstElemTy->isFloatTy())
-  || (srcElemTy->isFloatTy() && dstElemTy->isIntegerTy())) {
-// Create a float type of the same size as the source or destination.
-llvm::VectorType *newSrcTy = llvm::VectorType::get(dstElemTy,
- numElementsSrc);
-
-Src = Builder.CreateBitCast(Src, newSrcTy, "astypeCast");
-  }
-
-  llvm::Value *UnV = llvm::UndefValue::get(Src->getType());
-
-  SmallVector Args;
-  Args.push_back(Builder.getInt32(0));
-  Args.push_back(Bui

Re: [PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().

2016-05-30 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: lib/Format/Format.cpp:1550
@@ +1549,3 @@
+  HeaderInsertionReplaces =
+  fixCppIncludeInsertions(Code, HeaderInsertionReplaces, Style);
+  NewReplaces.insert(HeaderInsertionReplaces.begin(),

djasper wrote:
> So, not knowing anything of it, what's the difference between 
> fixCppIncludeInsertions and fixInsertionReplacements and when do you need to 
> call what. To me the fact that it's that difficult to find a name for it is 
> telling..
> 
> Also, I still don't understand why you think it is better to separate the two 
> functions. In that way you are currently implementing it, it is certainly 
> less efficient. You are always copying all the replacements, which (in the 
> way you are doing it) is O(N lg N), even if there isn't a single header 
> insertion. Maybe at least use set_difference (similar to what I am showing 
> below).
> 
> So, how I would structure it:
> 
> - Pull out a function isHeaderInsertion(const Replacement &). Easy naming, 
> good to pull this functionality out.
> - At the start of fixCppIncludeInsertions, write:
> 
> 
> ```
> tooling::Replacements HeaderInsertions;
> for (const auto &R : Replaces)
>   if (isHeaderInsertion(R))
> HeaderInsertions.insert(R);
> if (HeaderInsertions.empty())
>   return Replaces;
> 
> tooling::Replacements Result;
> std::set_difference(Replaces.begin(), Replaces.end(),
> HeaderInsertions.begin(), HeaderInsertions.end(),
> Result.begin());
> 
> ```  
> - Do what the function currently does with HeaderInsertions and add the 
> results back to Result.
I really appreciate the way you structure it, which does make the code clearer. 

Just one coveat: `std::set_difference()` is not applicable on `Replacements` 
since it calls `std::copy()` on `Replacement`, which `Replacement` does not 
support.

I think another way to approach it would be to delete header insertion 
replacement and insert new replacements back if we can assume that there are 
only few header insertion replacements.  


http://reviews.llvm.org/D20734



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


Re: [PATCH] D20784: [libcxx][libcxxabi] Decouple no-exceptions libcpp variant from cxa_exception.cpp and cxa_personality.cpp of libcxxabi

2016-05-30 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In http://reviews.llvm.org/D20784#443708, @EricWF wrote:

> I don't like the direction of this patch, and it seems like the wrong 
> direction for what your trying to achieve as well.
>  If your trying to support a system with two variants of libc++abi, one that 
> throws and the other that does not, then you'll want libc++ to remain 
> unmodified so it can depend on the selected libc++abi to provide the correct 
> exception handling behavior.


We do not allow linking a with-exceptions `libc++` library with a no-exceptions 
`libc++abi` library, that is not a use-case for us. We have either 
with-exceptions libraries or no-exceptions libraries, there is no overlap. This 
is why I went with the current approach (modify the no-exceptions libc++ 
variant to match the no-exceptions libc++abi variant).

Note that our use-case is about code-size, we do not want exception handling 
routines (as well as exception tables) in our final image. We are not after a 
system where you can swap out the exceptions behaviour. Sorry if I wasn't clear 
about this.

> I think these particular symbols should always be defined within libc++abi 
> (sorry if I said otherwise earlier, I didn't understand the implementation). 
> The -fno-exceptions build of libc++abi can build these symbols with very 
> simple definitions that is detached from the rest of the exception handling 
> machinery.

> 

> My preference would be to create a new file 
> `cxa_no_exception_definitions.cpp` (bike shedding welcome) which  builds 
> inplace of `cxa_exception.cpp` and contains definitions for these symbols. 
> For example.

> 

> - `__cxa_uncaugh_exception()`/`__cxa_uncaught_exceptions()` always returns 
> zero.

> - `__cxa_decrement_exception_refcount(ptr)`/`__cxa_increment_refcount(ptr)` 
> terminate if `ptr != nullptr`.

> - `__cxa_primary_exception()` returns nullptr.

> - `__cxa_rethrow_primary_exception(ptr)` returns as to hit the terminate call 
> in libc++.

> 

>   This way we are not conflating building libc++ without exceptions with 
> building libc++ against an ABI library which doesn't provide the exception 
> handling API.


That too would work for us. I agree this is a bit more cleaner since it does 
not involve changes to `libc++`, so I will spin a patch for it on top of 
http://reviews.llvm.org/D20677.

/ Asiri


http://reviews.llvm.org/D20784



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


Re: r271211 - CodeGen: tweak CFConstantStrings for COFF and ELF

2016-05-30 Thread Rafael Espíndola via cfe-commits
Why .rodata.cfstring? Which linker treats that specially?

On 30 May 2016 at 12:23, Saleem Abdulrasool via cfe-commits
 wrote:
> Author: compnerd
> Date: Mon May 30 11:23:07 2016
> New Revision: 271211
>
> URL: http://llvm.org/viewvc/llvm-project?rev=271211&view=rev
> Log:
> CodeGen: tweak CFConstantStrings for COFF and ELF
>
> Adjust the constant CFString emission to emit into more appropriate sections 
> on
> ELF and COFF targets.  It would previously try to use MachO section names
> irrespective of the file format.
>
> Added:
> cfe/trunk/test/CodeGen/CFStrings.c
> Modified:
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=271211&r1=271210&r2=271211&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon May 30 11:23:07 2016
> @@ -3092,19 +3092,19 @@ CodeGenModule::GetAddrOfConstantCFString
>llvm::Constant *Zero = llvm::Constant::getNullValue(Int32Ty);
>llvm::Constant *Zeros[] = { Zero, Zero };
>llvm::Value *V;
> -
> +
>// If we don't already have it, get __CFConstantStringClassReference.
>if (!CFConstantStringClassRef) {
>  llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy);
>  Ty = llvm::ArrayType::get(Ty, 0);
> -llvm::Constant *GV = CreateRuntimeVariable(Ty,
> -   
> "__CFConstantStringClassReference");
> +llvm::Constant *GV =
> +CreateRuntimeVariable(Ty, "__CFConstantStringClassReference");
>  // Decay array -> ptr
>  V = llvm::ConstantExpr::getGetElementPtr(Ty, GV, Zeros);
>  CFConstantStringClassRef = V;
> -  }
> -  else
> +  } else {
>  V = CFConstantStringClassRef;
> +  }
>
>QualType CFTy = getContext().getCFConstantStringType();
>
> @@ -3117,8 +3117,8 @@ CodeGenModule::GetAddrOfConstantCFString
>
>// Flags.
>llvm::Type *Ty = getTypes().ConvertType(getContext().UnsignedIntTy);
> -  Fields[1] = isUTF16 ? llvm::ConstantInt::get(Ty, 0x07d0) :
> -llvm::ConstantInt::get(Ty, 0x07C8);
> +  Fields[1] = isUTF16 ? llvm::ConstantInt::get(Ty, 0x07d0)
> +  : llvm::ConstantInt::get(Ty, 0x07C8);
>
>// String pointer.
>llvm::Constant *C = nullptr;
> @@ -3139,18 +3139,17 @@ CodeGenModule::GetAddrOfConstantCFString
>GV->setUnnamedAddr(true);
>// Don't enforce the target's minimum global alignment, since the only use
>// of the string is via this class initializer.
> -  // FIXME: We set the section explicitly to avoid a bug in ld64 224.1. 
> Without
> -  // it LLVM can merge the string with a non unnamed_addr one during LTO. 
> Doing
> -  // that changes the section it ends in, which surprises ld64.
> -  if (isUTF16) {
> -CharUnits Align = getContext().getTypeAlignInChars(getContext().ShortTy);
> -GV->setAlignment(Align.getQuantity());
> -GV->setSection("__TEXT,__ustring");
> -  } else {
> -CharUnits Align = getContext().getTypeAlignInChars(getContext().CharTy);
> -GV->setAlignment(Align.getQuantity());
> -GV->setSection("__TEXT,__cstring,cstring_literals");
> -  }
> +  CharUnits Align = isUTF16
> +? 
> getContext().getTypeAlignInChars(getContext().ShortTy)
> +: 
> getContext().getTypeAlignInChars(getContext().CharTy);
> +  GV->setAlignment(Align.getQuantity());
> +
> +  // FIXME: We set the section explicitly to avoid a bug in ld64 224.1.
> +  // Without it LLVM can merge the string with a non unnamed_addr one during
> +  // LTO.  Doing that changes the section it ends in, which surprises ld64.
> +  if (getTarget().getTriple().getObjectFormat() == llvm::Triple::MachO)
> +GV->setSection(isUTF16 ? "__TEXT,__ustring"
> +   : "__TEXT,__cstring,cstring_literals");
>
>// String.
>Fields[2] =
> @@ -3171,8 +3170,20 @@ CodeGenModule::GetAddrOfConstantCFString
>GV = new llvm::GlobalVariable(getModule(), C->getType(), true,
>  llvm::GlobalVariable::PrivateLinkage, C,
>  "_unnamed_cfstring_");
> -  GV->setSection("__DATA,__cfstring");
>GV->setAlignment(Alignment.getQuantity());
> +  switch (getTarget().getTriple().getObjectFormat()) {
> +  case llvm::Triple::UnknownObjectFormat:
> +llvm_unreachable("unknown file format");
> +  case llvm::Triple::COFF:
> +GV->setSection(".rdata.cfstring");
> +break;
> +  case llvm::Triple::ELF:
> +GV->setSection(".rodata.cfstring");
> +break;
> +  case llvm::Triple::MachO:
> +GV->setSection("__DATA,__cfstring");
> +break;
> +  }
>Entry.second = GV;
>
>return ConstantAddress(GV, Alignment);
>
> Added: cfe/trunk/test/CodeGen/CFStrings.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/CFStrings.c?rev=271211&view=auto
> =

r271227 - [X86] Ensure load/store tests unaligned pointers really are align 1

2016-05-30 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Mon May 30 14:20:55 2016
New Revision: 271227

URL: http://llvm.org/viewvc/llvm-project?rev=271227&view=rev
Log:
[X86] Ensure load/store tests unaligned pointers really are align 1

Modified:
cfe/trunk/test/CodeGen/avx-builtins.c
cfe/trunk/test/CodeGen/sse-builtins.c
cfe/trunk/test/CodeGen/sse2-builtins.c

Modified: cfe/trunk/test/CodeGen/avx-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx-builtins.c?rev=271227&r1=271226&r2=271227&view=diff
==
--- cfe/trunk/test/CodeGen/avx-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx-builtins.c Mon May 30 14:20:55 2016
@@ -473,27 +473,27 @@ __m256i test_mm256_load_si256(__m256i* A
 
 __m256d test_mm256_loadu_pd(double* A) {
   // CHECK-LABEL: test_mm256_loadu_pd
-  // CHECK: load <4 x double>, <4 x double>* %{{.*}}, align 1
+  // CHECK: load <4 x double>, <4 x double>* %{{.*}}, align 1{{$}}
   return _mm256_loadu_pd(A);
 }
 
 __m256 test_mm256_loadu_ps(float* A) {
   // CHECK-LABEL: test_mm256_loadu_ps
-  // CHECK: load <8 x float>, <8 x float>* %{{.*}}, align 1
+  // CHECK: load <8 x float>, <8 x float>* %{{.*}}, align 1{{$}}
   return _mm256_loadu_ps(A);
 }
 
 __m256i test_mm256_loadu_si256(__m256i* A) {
   // CHECK-LABEL: test_mm256_loadu_si256
-  // CHECK: load <4 x i64>, <4 x i64>* %{{.+}}, align 1
+  // CHECK: load <4 x i64>, <4 x i64>* %{{.+}}, align 1{{$}}
   return _mm256_loadu_si256(A);
 }
 
 __m256 test_mm256_loadu2_m128(float* A, float* B) {
   // CHECK-LABEL: test_mm256_loadu2_m128
-  // CHECK: load <4 x float>, <4 x float>* %{{.*}}, align 1
+  // CHECK: load <4 x float>, <4 x float>* %{{.*}}, align 1{{$}}
   // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <8 x i32> 

-  // CHECK: load <4 x float>, <4 x float>* %{{.*}}, align 1
+  // CHECK: load <4 x float>, <4 x float>* %{{.*}}, align 1{{$}}
   // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <8 x i32> 

   // CHECK: shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <8 x i32> 

   return _mm256_loadu2_m128(A, B);
@@ -501,9 +501,9 @@ __m256 test_mm256_loadu2_m128(float* A,
 
 __m256d test_mm256_loadu2_m128d(double* A, double* B) {
   // CHECK-LABEL: test_mm256_loadu2_m128d
-  // CHECK: load <2 x double>, <2 x double>* %{{.*}}, align 1
+  // CHECK: load <2 x double>, <2 x double>* %{{.*}}, align 1{{$}}
   // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <4 x 
i32> 
-  // CHECK: load <2 x double>, <2 x double>* %{{.*}}, align 1
+  // CHECK: load <2 x double>, <2 x double>* %{{.*}}, align 1{{$}}
   // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <4 x 
i32> 
   // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x 
i32> 
   return _mm256_loadu2_m128d(A, B);
@@ -511,9 +511,9 @@ __m256d test_mm256_loadu2_m128d(double*
 
 __m256i test_mm256_loadu2_m128i(__m128i* A, __m128i* B) {
   // CHECK-LABEL: test_mm256_loadu2_m128i
-  // CHECK: load <2 x i64>, <2 x i64>* %{{.*}}, align 1
+  // CHECK: load <2 x i64>, <2 x i64>* %{{.*}}, align 1{{$}}
   // CHECK: shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <4 x i32> 
-  // CHECK: load <2 x i64>, <2 x i64>* %{{.*}}, align 1
+  // CHECK: load <2 x i64>, <2 x i64>* %{{.*}}, align 1{{$}}
   // CHECK: shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <4 x i32> 
   // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> 
   return _mm256_loadu2_m128i(A, B);

Modified: cfe/trunk/test/CodeGen/sse-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse-builtins.c?rev=271227&r1=271226&r2=271227&view=diff
==
--- cfe/trunk/test/CodeGen/sse-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse-builtins.c Mon May 30 14:20:55 2016
@@ -346,7 +346,7 @@ __m128 test_mm_load_ps1(float* y) {
 
 __m128 test_mm_load_ss(float* y) {
   // CHECK-LABEL: test_mm_load_ss
-  // CHECK: load float, float* {{.*}}, align 1
+  // CHECK: load float, float* {{.*}}, align 1{{$}}
   // CHECK: insertelement <4 x float> undef, float %{{.*}}, i32 0
   // CHECK: insertelement <4 x float> %{{.*}}, float 0.00e+00, i32 1
   // CHECK: insertelement <4 x float> %{{.*}}, float 0.00e+00, i32 2
@@ -389,7 +389,7 @@ __m128 test_mm_loadr_ps(float* A) {
 
 __m128 test_mm_loadu_ps(float* A) {
   // CHECK-LABEL: test_mm_loadu_ps
-  // CHECK: load <4 x float>, <4 x float>* %{{.*}}, align 1
+  // CHECK: load <4 x float>, <4 x float>* %{{.*}}, align 1{{$}}
   return _mm_loadu_ps(A);
 }
 

Modified: cfe/trunk/test/CodeGen/sse2-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse2-builtins.c?rev=271227&r1=271226&r2=271227&view=diff
==
--- cfe/trunk/test/CodeGen/sse2-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse2-builtins.c Mon May 30 14:20:55 2016
@@ -604,7

[PATCH] D20798: clang-format: [JS] Sort imported symbols.

2016-05-30 Thread Martin Probst via cfe-commits
mprobst created this revision.
mprobst added a reviewer: djasper.
mprobst added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

E.g. sort `import {b, a} from 'x';` into `import {a, b} from 'x';`.

http://reviews.llvm.org/D20798

Files:
  lib/Format/Format.cpp
  lib/Format/SortJavaScriptImports.cpp
  unittests/Format/SortImportsTestJS.cpp

Index: unittests/Format/SortImportsTestJS.cpp
===
--- unittests/Format/SortImportsTestJS.cpp
+++ unittests/Format/SortImportsTestJS.cpp
@@ -101,6 +101,13 @@
  "import {sym1 as alias1} from 'b';\n");
 }
 
+TEST_F(SortImportsTestJS, SortSymbols) {
+  verifySort("import {sym1, sym2 as a, sym3} from 'b';\n",
+ "import {sym2 as a, sym1, sym3} from 'b';\n");
+  verifySort("import {sym1 /* important! */, /*!*/ sym2 as a} from 'b';\n",
+ "import {/*!*/ sym2 as a, sym1 /* important! */} from 'b';\n");
+}
+
 TEST_F(SortImportsTestJS, GroupImports) {
   verifySort("import {a} from 'absolute';\n"
  "\n"
Index: lib/Format/SortJavaScriptImports.cpp
===
--- lib/Format/SortJavaScriptImports.cpp
+++ lib/Format/SortJavaScriptImports.cpp
@@ -25,6 +25,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Debug.h"
+#include 
 #include 
 
 #define DEBUG_TYPE "format-formatter"
@@ -40,6 +41,11 @@
 struct JsImportedSymbol {
   StringRef Symbol;
   StringRef Alias;
+  SourceRange Range;
+
+  bool operator==(const JsImportedSymbol &RHS) const {
+return Symbol == RHS.Symbol && Alias == RHS.Alias;
+  }
 };
 
 // An ES6 module reference.
@@ -139,23 +145,41 @@
  [&](unsigned LHSI, unsigned RHSI) {
return References[LHSI] < References[RHSI];
  });
-// FIXME: Pull this into a common function.
-bool OutOfOrder = false;
-for (unsigned i = 0, e = Indices.size(); i != e; ++i) {
-  if (i != Indices[i]) {
-OutOfOrder = true;
-break;
-  }
-}
-if (!OutOfOrder)
-  return Result;
+bool ReferencesInOrder = std::is_sorted(Indices.begin(), Indices.end());
 
-// Replace all existing import/export statements.
 std::string ReferencesText;
+bool SymbolsInOrder = true;
 for (unsigned i = 0, e = Indices.size(); i != e; ++i) {
   JsModuleReference Reference = References[Indices[i]];
-  StringRef ReferenceStmt = getSourceText(Reference.Range);
-  ReferencesText += ReferenceStmt;
+  // Sort the individual symbols within the import.
+  // E.g. `import {b, a} from 'x';` -> `import {a, b} from 'x';`
+  SmallVector Symbols = Reference.Symbols;
+  std::stable_sort(Symbols.begin(), Symbols.end(),
+   [&](JsImportedSymbol LHS, JsImportedSymbol RHS) {
+ return LHS.Symbol < RHS.Symbol;
+   });
+  if (Symbols == Reference.Symbols) {
+// No change in symbol order.
+StringRef ReferenceStmt = getSourceText(Reference.Range);
+ReferencesText += ReferenceStmt;
+  } else {
+// Stitch together the module reference start...
+SymbolsInOrder = false;
+SourceLocation SymbolsStart =
+Reference.Symbols.front().Range.getBegin();
+SourceLocation SymbolsEnd = Reference.Symbols.back().Range.getEnd();
+ReferencesText +=
+getSourceText(Reference.Range.getBegin(), SymbolsStart);
+// ... then the references in order ...
+for (JsImportedSymbol *I = Symbols.begin(), *E = Symbols.end();
+ I != E;) {
+  ReferencesText += getSourceText(I->Range);
+  if (++I != E)
+ReferencesText += ",";
+}
+// ... followed by the module reference end.
+ReferencesText += getSourceText(SymbolsEnd, Reference.Range.getEnd());
+  }
   if (i + 1 < e) {
 // Insert breaks between imports and exports.
 ReferencesText += "\n";
@@ -167,6 +191,11 @@
   ReferencesText += "\n";
   }
 }
+
+if (ReferencesInOrder && SymbolsInOrder) {
+  return Result;
+}
+
 // Separate references from the main code body of the file.
 if (FirstNonImportLine && FirstNonImportLine->First->NewlinesBefore < 2)
   ReferencesText += "\n";
@@ -211,10 +240,13 @@
   }
 
   StringRef getSourceText(SourceRange Range) {
+return getSourceText(Range.getBegin(), Range.getEnd());
+  }
+
+  StringRef getSourceText(SourceLocation Begin, SourceLocation End) {
 const SourceManager &SM = Env.getSourceManager();
-return FileContents.substr(SM.getFileOffset(Range.getBegin()),
-   SM.getFileOffset(Range.getEnd()) -
-   SM.getFileOffset(Range.getBegin()));
+return FileContents.substr(SM.getFileOffset(Begin),
+   SM.getFileOffset(End) - SM.getFile

Re: [PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().

2016-05-30 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: lib/Format/Format.cpp:1284
@@ +1283,3 @@
+  // if \p CheckMainHeader is true and \p IncludeName is a main header, returns
+  // 0. Otherwise, returns INT_MAX if \p IncludeName does not match any 
category
+  // pattern.

Nit: Otherwise, returns the priority of the matching category or INT_MAX.


Comment at: lib/Format/Format.cpp:1503
@@ +1502,3 @@
+  //  - to the beginning of the file.
+  for (auto Iter = ++Priorities.begin(), E = Priorities.end(); Iter != E;
+   ++Iter)

nit: I think you should be using "I" and "E".


Comment at: lib/Format/Format.cpp:1508
@@ +1507,3 @@
+  --Prev;
+  CategoryEndOffsets[*Iter] = CategoryEndOffsets[*Prev];
+}

Can you just use "std::prev(I)" instead of Prev?


Comment at: lib/Format/Format.cpp:1550
@@ +1549,3 @@
+  HeaderInsertionReplaces =
+  fixCppIncludeInsertions(Code, HeaderInsertionReplaces, Style);
+  NewReplaces.insert(HeaderInsertionReplaces.begin(),

So, not knowing anything of it, what's the difference between 
fixCppIncludeInsertions and fixInsertionReplacements and when do you need to 
call what. To me the fact that it's that difficult to find a name for it is 
telling..

Also, I still don't understand why you think it is better to separate the two 
functions. In that way you are currently implementing it, it is certainly less 
efficient. You are always copying all the replacements, which (in the way you 
are doing it) is O(N lg N), even if there isn't a single header insertion. 
Maybe at least use set_difference (similar to what I am showing below).

So, how I would structure it:

- Pull out a function isHeaderInsertion(const Replacement &). Easy naming, good 
to pull this functionality out.
- At the start of fixCppIncludeInsertions, write:


```
tooling::Replacements HeaderInsertions;
for (const auto &R : Replaces)
  if (isHeaderInsertion(R))
HeaderInsertions.insert(R);
if (HeaderInsertions.empty())
  return Replaces;

tooling::Replacements Result;
std::set_difference(Replaces.begin(), Replaces.end(),
HeaderInsertions.begin(), HeaderInsertions.end(),
Result.begin());

```  
- Do what the function currently does with HeaderInsertions and add the results 
back to Result.


http://reviews.llvm.org/D20734



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


Re: [PATCH] D16989: Change interpretation of function definition in friend declaration of template class.

2016-05-30 Thread Serge Pavlov via cfe-commits
sepavloff marked 2 inline comments as done.
sepavloff added a comment.

In http://reviews.llvm.org/D16989#432282, @rsmith wrote:

> Please also add some testcases for the corresponding case for a friend 
> function template:
>
>   template void f();
>   template struct A {
> template void f() {}
>   };
>   template struct B {
> template void f() {}
>   };
>   A a;
>   B b; // ill-formed


Templates follow very different path. In the code you provided definitions for 
functions `f` are not generated, because they are not used, so diagnostics of 
such cases require special processing. Patch for template friends will be 
prepared soon.


http://reviews.llvm.org/D16989



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


Re: [PATCH] D16989: Change interpretation of function definition in friend declaration of template class.

2016-05-30 Thread Serge Pavlov via cfe-commits
sepavloff updated this revision to Diff 58983.
sepavloff added a comment.

Updated patch


http://reviews.llvm.org/D16989

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/PR25848.cpp
  test/SemaCXX/friend2.cpp

Index: test/SemaCXX/friend2.cpp
===
--- /dev/null
+++ test/SemaCXX/friend2.cpp
@@ -0,0 +1,145 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+// If a friend function is defined in several non-template classes,
+// it is an error.
+
+void func1(int);
+struct C1a {
+  friend void func1(int) {}  // expected-note{{previous definition is here}}
+};
+struct C1b {
+  friend void func1(int) {}  // expected-error{{redefinition of 'func1'}}
+};
+
+
+// If a friend function is defined in both non-template and template
+// classes it is an error only if the template is instantiated.
+
+void func2(int);
+struct C2a {
+  friend void func2(int) {}
+};
+template struct C2b {
+  friend void func2(int) {}
+};
+
+void func3(int);
+struct C3a {
+  friend void func3(int) {}  // expected-note{{previous definition is here}}
+};
+template struct C3b {
+  friend void func3(int) {}  // expected-error{{redefinition of 'func3'}}
+};
+C3b c3;  // expected-note{{in instantiation of template class 'C3b' requested here}}
+
+
+// If a friend function is defined in several template classes it is an error
+// only if several templates are instantiated.
+
+void func4(int);
+template struct C4a {
+  friend void func4(int) {}
+};
+template struct C4b {
+  friend void func4(int) {}
+};
+
+
+void func5(int);
+template struct C5a {
+  friend void func5(int) {}
+};
+template struct C5b {
+  friend void func5(int) {}
+};
+C5a c5a;
+
+void func6(int);
+template struct C6a {
+  friend void func6(int) {}  // expected-note{{previous definition is here}}
+};
+template struct C6b {
+  friend void func6(int) {}  // expected-error{{redefinition of 'func6'}}
+};
+C6a c6a;
+C6b c6b;  // expected-note{{in instantiation of template class 'C6b' requested here}}
+
+void func7(int);
+template struct C7 {
+  friend void func7(int) {}  // expected-error{{redefinition of 'func7'}}
+ // expected-note@-1{{previous definition is here}}
+};
+C7 c7a;
+C7 c7b;  // expected-note{{in instantiation of template class 'C7' requested here}}
+
+
+// Even if clases are not instantiated and hence friend functions defined in them are not
+// available, their declarations can be checked.
+
+void func8(int);  // expected-note{{previous declaration is here}}
+template struct C8a {
+  friend long func8(int);  // expected-error{{functions that differ only in their return type cannot be overloaded}}
+};
+
+void func9(int);  // expected-note{{previous declaration is here}}
+template struct C9a {
+  friend int func9(int);  // expected-error{{functions that differ only in their return type cannot be overloaded}}
+};
+
+void func10(int);  // expected-note{{previous declaration is here}}
+template struct C10a {
+  friend int func10(int);  // expected-error{{functions that differ only in their return type cannot be overloaded}}
+};
+
+
+namespace pr22307 {
+
+struct t {
+  friend int leak(t);
+};
+
+template
+struct m {
+  friend int leak(t) { return sizeof(v); }  // expected-error{{redefinition of 'leak'}} expected-note{{previous definition is here}}
+};
+
+template struct m;
+template struct m;  // expected-note{{in instantiation of template class 'pr22307::m' requested here}}
+
+int main() {
+  leak(t());
+}
+
+}
+
+namespace pr17923 {
+
+void f(unsigned long long);
+
+template struct X {
+  friend void f(unsigned long long) {
+ T t;
+  }
+};
+
+int main() { f(1234); }
+
+}
+
+namespace pr17923a {
+
+int get();
+
+template< int value >
+class set {
+  friend int get()
+{ return value; } // return 0; is OK
+};
+
+template class set< 5 >;
+
+int main() {
+  get();
+}
+
+}
Index: test/SemaCXX/PR25848.cpp
===
--- /dev/null
+++ test/SemaCXX/PR25848.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A;
+
+inline int g();  // expected-warning{{inline function 'g' is not defined}}
+
+template
+struct R {
+  friend int g() {
+return M;
+  }
+};
+
+void m() {
+  g();  // expected-note{{used here}}
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8563,6 +8563,29 @@
   return NewFD;
 }
 
+/// \brief Checks if the new declaration declared in dependent context must be
+/// put in the same redeclaration chain as the specified declaration.
+///
+/// \param D Declaration that is checked.
+/// \param PrevDecl Previous declaration found with proper lookup method for the
+/// same declaration name.
+/// \returns True if D must be added to the redeclaration chain which PrevDecl
+///  belongs to.
+///
+bool Sema::shouldLinkDependentDeclWithPrevious

Re: [PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().

2016-05-30 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: lib/Format/Format.cpp:1550
@@ +1549,3 @@
+// Insert #include directives into the correct blocks.
+tooling::Replacements fixHeaderInsertions(StringRef Code,
+  const tooling::Replacements 
&Replaces,

djasper wrote:
> Hm.. Not happy with the naming. There is no real difference between 
> fixHeaderInsertions and fixCppIncludeInsertions. You could argue that the 
> "Cpp" part is the difference, but the actual difference is that one iterates 
> over an entire set of replacements whereas the other only modifies header 
> insertions.
> 
> I think I'd just merge the two functions, but that probably also ties back to 
> my wish not to separate out the two replacement sets ;-).
How about `fixInsertionReplacements`?


http://reviews.llvm.org/D20734



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


Re: [PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().

2016-05-30 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 58982.
ioeric marked 16 inline comments as done.
ioeric added a comment.

- Addressed reviewers' comments.


http://reviews.llvm.org/D20734

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  unittests/Format/CleanupTest.cpp

Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -281,6 +281,331 @@
   EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
 }
 
+TEST_F(CleanUpReplacementsTest, NoExistingIncludeWithoutDefine) {
+  std::string Code = "int main() {}";
+  std::string Expected = "#include \"a.h\"\n"
+ "int main() {}";
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(
+  tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"a.h\""));
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces));
+}
+
+TEST_F(CleanUpReplacementsTest, NoExistingIncludeWithDefine) {
+  std::string Code = "#ifndef __A_H__\n"
+ "#define __A_H__\n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+  std::string Expected = "#ifndef __A_H__\n"
+ "#define __A_H__\n"
+ "#include \"b.h\"\n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(
+  tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"b.h\""));
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces));
+}
+
+TEST_F(CleanUpReplacementsTest, InsertBeforeCategoryWithLowerPriority) {
+  std::string Code = "#ifndef __A_H__\n"
+ "#define __A_H__\n"
+ "\n"
+ "\n"
+ "\n"
+ "#include \n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+  std::string Expected = "#ifndef __A_H__\n"
+ "#define __A_H__\n"
+ "\n"
+ "\n"
+ "\n"
+ "#include \"a.h\"\n"
+ "#include \n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(
+  tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"a.h\""));
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces));
+}
+
+TEST_F(CleanUpReplacementsTest, InsertAfterMainHeader) {
+  std::string Code = "#include \"fix.h\"\n"
+ "\n"
+ "int main() {}";
+  std::string Expected = "#include \"fix.h\"\n"
+ "#include \n"
+ "\n"
+ "int main() {}";
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include "));
+  format::FormatStyle Style =
+  format::getGoogleStyle(format::FormatStyle::LanguageKind::LK_Cpp);
+  auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces));
+}
+
+TEST_F(CleanUpReplacementsTest, InsertBeforeSystemHeaderLLVM) {
+  std::string Code = "#include \n"
+ "\n"
+ "int main() {}";
+  std::string Expected = "#include \"z.h\"\n"
+ "#include \n"
+ "\n"
+ "int main() {}";
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(
+  tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"z.h\""));
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces));
+}
+
+TEST_F(CleanUpReplacementsTest, InsertAfterSystemHeaderGoogle) {
+  std::string Code = "#include \n"
+ "\n"
+ "int main() {}";
+  std::string Expected = "#include \n"
+ "#include \"z.h\"\n"
+ "\n"
+ "int main() {}";
+  Context.createInMemoryFile("fix.cpp", Code)

r271221 - CodeGen: address post-commit review comments

2016-05-30 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon May 30 13:26:06 2016
New Revision: 271221

URL: http://llvm.org/viewvc/llvm-project?rev=271221&view=rev
Log:
CodeGen: address post-commit review comments

David Majnemer pointed out that isOSBinFormatMachO is more compact.  NFC.

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=271221&r1=271220&r2=271221&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon May 30 13:26:06 2016
@@ -3147,7 +3147,7 @@ CodeGenModule::GetAddrOfConstantCFString
   // FIXME: We set the section explicitly to avoid a bug in ld64 224.1.
   // Without it LLVM can merge the string with a non unnamed_addr one during
   // LTO.  Doing that changes the section it ends in, which surprises ld64.
-  if (getTarget().getTriple().getObjectFormat() == llvm::Triple::MachO)
+  if (getTarget().getTriple().isOSBinFormatMachO())
 GV->setSection(isUTF16 ? "__TEXT,__ustring"
: "__TEXT,__cstring,cstring_literals");
 


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


r271219 - [X86][SSE] Added missing tests (merge failure)

2016-05-30 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Mon May 30 12:58:38 2016
New Revision: 271219

URL: http://llvm.org/viewvc/llvm-project?rev=271219&view=rev
Log:
[X86][SSE] Added missing tests (merge failure)

Differential Revision: http://reviews.llvm.org/D20617

Modified:
cfe/trunk/test/CodeGen/sse-builtins.c

Modified: cfe/trunk/test/CodeGen/sse-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse-builtins.c?rev=271219&r1=271218&r2=271219&view=diff
==
--- cfe/trunk/test/CodeGen/sse-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse-builtins.c Mon May 30 12:58:38 2016
@@ -651,8 +651,7 @@ void test_mm_store_ps(float* x, __m128 y
 void test_mm_store_ps1(float* x, __m128 y) {
   // CHECK-LABEL: test_mm_store_ps1
   // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> 
zeroinitializer
-  // CHECK: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 1{{$}}
-  // CHECK-NEXT: ret void
+  // CHECK: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 16
   _mm_store_ps1(x, y);
 }
 
@@ -666,8 +665,7 @@ void test_mm_store_ss(float* x, __m128 y
 void test_mm_store1_ps(float* x, __m128 y) {
   // CHECK-LABEL: test_mm_store1_ps
   // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> 
zeroinitializer
-  // CHECK: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 1{{$}}
-  // CHECK-NEXT: ret void
+  // CHECK: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 16
   _mm_store1_ps(x, y);
 }
 


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


Re: [PATCH] D20617: [X86][SSE] _mm_store1_ps/_mm_store1_pd should require an aligned pointer

2016-05-30 Thread Simon Pilgrim via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271218: [X86][SSE] _mm_store1_ps/_mm_store1_pd should 
require an aligned pointer (authored by RKSimon).

Changed prior to commit:
  http://reviews.llvm.org/D20617?vs=58397&id=58979#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20617

Files:
  cfe/trunk/lib/Headers/emmintrin.h
  cfe/trunk/lib/Headers/xmmintrin.h
  cfe/trunk/test/CodeGen/sse2-builtins.c

Index: cfe/trunk/test/CodeGen/sse2-builtins.c
===
--- cfe/trunk/test/CodeGen/sse2-builtins.c
+++ cfe/trunk/test/CodeGen/sse2-builtins.c
@@ -1205,6 +1205,13 @@
   _mm_store_pd(A, B);
 }
 
+void test_mm_store_pd1(double* x, __m128d y) {
+  // CHECK-LABEL: test_mm_store_pd1
+  // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x 
i32> zeroinitializer
+  // CHECK: store <2 x double> %{{.*}}, <2 x double>* {{.*}}, align 16
+  _mm_store_pd1(x, y);
+}
+
 void test_mm_store_sd(double* A, __m128d B) {
   // CHECK-LABEL: test_mm_store_sd
   // CHECK: extractelement <2 x double> %{{.*}}, i32 0
@@ -1220,9 +1227,8 @@
 
 void test_mm_store1_pd(double* x, __m128d y) {
   // CHECK-LABEL: test_mm_store1_pd
-  // CHECK: extractelement <2 x double> %{{.*}}, i32 0
-  // CHECK: store {{.*}} double* {{.*}}, align 1{{$}}
-  // CHECK: store {{.*}} double* {{.*}}, align 1{{$}}
+  // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x 
i32> zeroinitializer
+  // CHECK: store <2 x double> %{{.*}}, <2 x double>* %{{.*}}, align 16
   _mm_store1_pd(x, y);
 }
 
Index: cfe/trunk/lib/Headers/emmintrin.h
===
--- cfe/trunk/lib/Headers/emmintrin.h
+++ cfe/trunk/lib/Headers/emmintrin.h
@@ -588,19 +588,22 @@
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS
+_mm_store_pd(double *__dp, __m128d __a)
+{
+  *(__m128d*)__dp = __a;
+}
+
+static __inline__ void __DEFAULT_FN_ATTRS
 _mm_store1_pd(double *__dp, __m128d __a)
 {
-  struct __mm_store1_pd_struct {
-double __u[2];
-  } __attribute__((__packed__, __may_alias__));
-  ((struct __mm_store1_pd_struct*)__dp)->__u[0] = __a[0];
-  ((struct __mm_store1_pd_struct*)__dp)->__u[1] = __a[0];
+  __a = __builtin_shufflevector((__v2df)__a, (__v2df)__a, 0, 0);
+  _mm_store_pd(__dp, __a);
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS
-_mm_store_pd(double *__dp, __m128d __a)
+_mm_store_pd1(double *__dp, __m128d __a)
 {
-  *(__m128d *)__dp = __a;
+  return _mm_store1_pd(__dp, __a);
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS
Index: cfe/trunk/lib/Headers/xmmintrin.h
===
--- cfe/trunk/lib/Headers/xmmintrin.h
+++ cfe/trunk/lib/Headers/xmmintrin.h
@@ -1593,22 +1593,22 @@
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS
-_mm_store1_ps(float *__p, __m128 __a)
+_mm_store_ps(float *__p, __m128 __a)
 {
-  __a = __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 0, 0, 0, 0);
-  _mm_storeu_ps(__p, __a);
+  *(__m128*)__p = __a;
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS
-_mm_store_ps1(float *__p, __m128 __a)
+_mm_store1_ps(float *__p, __m128 __a)
 {
-return _mm_store1_ps(__p, __a);
+  __a = __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 0, 0, 0, 0);
+  _mm_store_ps(__p, __a);
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS
-_mm_store_ps(float *__p, __m128 __a)
+_mm_store_ps1(float *__p, __m128 __a)
 {
-  *(__m128 *)__p = __a;
+  return _mm_store1_ps(__p, __a);
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS


Index: cfe/trunk/test/CodeGen/sse2-builtins.c
===
--- cfe/trunk/test/CodeGen/sse2-builtins.c
+++ cfe/trunk/test/CodeGen/sse2-builtins.c
@@ -1205,6 +1205,13 @@
   _mm_store_pd(A, B);
 }
 
+void test_mm_store_pd1(double* x, __m128d y) {
+  // CHECK-LABEL: test_mm_store_pd1
+  // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x i32> zeroinitializer
+  // CHECK: store <2 x double> %{{.*}}, <2 x double>* {{.*}}, align 16
+  _mm_store_pd1(x, y);
+}
+
 void test_mm_store_sd(double* A, __m128d B) {
   // CHECK-LABEL: test_mm_store_sd
   // CHECK: extractelement <2 x double> %{{.*}}, i32 0
@@ -1220,9 +1227,8 @@
 
 void test_mm_store1_pd(double* x, __m128d y) {
   // CHECK-LABEL: test_mm_store1_pd
-  // CHECK: extractelement <2 x double> %{{.*}}, i32 0
-  // CHECK: store {{.*}} double* {{.*}}, align 1{{$}}
-  // CHECK: store {{.*}} double* {{.*}}, align 1{{$}}
+  // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x i32> zeroinitializer
+  // CHECK: store <2 x double> %{{.*}}, <2 x double>* %{{.*}}, align 16
   _mm_store1_pd(x, y);
 }
 
Index: cfe/trunk/lib/Headers/emmintrin.h
===
--- cfe/trunk/lib/Headers/emmintrin.h
+++ cfe/trunk/lib/Headers/emmintrin.h
@@ -588,19 +588,22 @@
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS
+_mm_store_pd(double *__dp, __m128d __a)
+{
+  *(_

r271218 - [X86][SSE] _mm_store1_ps/_mm_store1_pd should require an aligned pointer

2016-05-30 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Mon May 30 12:55:25 2016
New Revision: 271218

URL: http://llvm.org/viewvc/llvm-project?rev=271218&view=rev
Log:
[X86][SSE] _mm_store1_ps/_mm_store1_pd should require an aligned pointer

According to the gcc headers, intel intrinsics docs and msdn codegen the 
_mm_store1_pd (and its _mm_store_pd1 equivalent) should use an aligned pointer 
- the clang headers are the only implementation I can find that assume 
non-aligned stores (by storing with _mm_storeu_pd).

Additionally, according to the intel intrinsics docs and msdn codegen the 
_mm_store1_ps (_mm_store_ps1) requires a similarly aligned pointer.

This patch raises the alignment requirements to match the other implementations 
by calling _mm_store_ps/_mm_store_pd instead.

I've also added the missing _mm_store_pd1 intrinsic (which maps to 
_mm_store1_pd like _mm_store_ps1 does to _mm_store1_ps).

As a followup I'll update the llvm fast-isel tests to match this codegen.

Differential Revision: http://reviews.llvm.org/D20617

Modified:
cfe/trunk/lib/Headers/emmintrin.h
cfe/trunk/lib/Headers/xmmintrin.h
cfe/trunk/test/CodeGen/sse2-builtins.c

Modified: cfe/trunk/lib/Headers/emmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/emmintrin.h?rev=271218&r1=271217&r2=271218&view=diff
==
--- cfe/trunk/lib/Headers/emmintrin.h (original)
+++ cfe/trunk/lib/Headers/emmintrin.h Mon May 30 12:55:25 2016
@@ -588,19 +588,22 @@ _mm_store_sd(double *__dp, __m128d __a)
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS
+_mm_store_pd(double *__dp, __m128d __a)
+{
+  *(__m128d*)__dp = __a;
+}
+
+static __inline__ void __DEFAULT_FN_ATTRS
 _mm_store1_pd(double *__dp, __m128d __a)
 {
-  struct __mm_store1_pd_struct {
-double __u[2];
-  } __attribute__((__packed__, __may_alias__));
-  ((struct __mm_store1_pd_struct*)__dp)->__u[0] = __a[0];
-  ((struct __mm_store1_pd_struct*)__dp)->__u[1] = __a[0];
+  __a = __builtin_shufflevector((__v2df)__a, (__v2df)__a, 0, 0);
+  _mm_store_pd(__dp, __a);
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS
-_mm_store_pd(double *__dp, __m128d __a)
+_mm_store_pd1(double *__dp, __m128d __a)
 {
-  *(__m128d *)__dp = __a;
+  return _mm_store1_pd(__dp, __a);
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS

Modified: cfe/trunk/lib/Headers/xmmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/xmmintrin.h?rev=271218&r1=271217&r2=271218&view=diff
==
--- cfe/trunk/lib/Headers/xmmintrin.h (original)
+++ cfe/trunk/lib/Headers/xmmintrin.h Mon May 30 12:55:25 2016
@@ -1593,22 +1593,22 @@ _mm_storeu_ps(float *__p, __m128 __a)
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS
-_mm_store1_ps(float *__p, __m128 __a)
+_mm_store_ps(float *__p, __m128 __a)
 {
-  __a = __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 0, 0, 0, 0);
-  _mm_storeu_ps(__p, __a);
+  *(__m128*)__p = __a;
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS
-_mm_store_ps1(float *__p, __m128 __a)
+_mm_store1_ps(float *__p, __m128 __a)
 {
-return _mm_store1_ps(__p, __a);
+  __a = __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 0, 0, 0, 0);
+  _mm_store_ps(__p, __a);
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS
-_mm_store_ps(float *__p, __m128 __a)
+_mm_store_ps1(float *__p, __m128 __a)
 {
-  *(__m128 *)__p = __a;
+  return _mm_store1_ps(__p, __a);
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS

Modified: cfe/trunk/test/CodeGen/sse2-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse2-builtins.c?rev=271218&r1=271217&r2=271218&view=diff
==
--- cfe/trunk/test/CodeGen/sse2-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse2-builtins.c Mon May 30 12:55:25 2016
@@ -1205,6 +1205,13 @@ void test_mm_store_pd(double* A, __m128d
   _mm_store_pd(A, B);
 }
 
+void test_mm_store_pd1(double* x, __m128d y) {
+  // CHECK-LABEL: test_mm_store_pd1
+  // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x 
i32> zeroinitializer
+  // CHECK: store <2 x double> %{{.*}}, <2 x double>* {{.*}}, align 16
+  _mm_store_pd1(x, y);
+}
+
 void test_mm_store_sd(double* A, __m128d B) {
   // CHECK-LABEL: test_mm_store_sd
   // CHECK: extractelement <2 x double> %{{.*}}, i32 0
@@ -1220,9 +1227,8 @@ void test_mm_store_si128(__m128i* A, __m
 
 void test_mm_store1_pd(double* x, __m128d y) {
   // CHECK-LABEL: test_mm_store1_pd
-  // CHECK: extractelement <2 x double> %{{.*}}, i32 0
-  // CHECK: store {{.*}} double* {{.*}}, align 1{{$}}
-  // CHECK: store {{.*}} double* {{.*}}, align 1{{$}}
+  // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x 
i32> zeroinitializer
+  // CHECK: store <2 x double> %{{.*}}, <2 x double>* %{{.*}}, align 16
   _mm_store1_pd(x, y);
 }
 


___
cfe-commits mailing list
cfe-commits@lists.llv

Re: [PATCH] D20133: [OpenCL] Fix __builtin_astype for vec3 types.

2016-05-30 Thread Yaxun Liu via cfe-commits
yaxunl marked 7 inline comments as done.


Comment at: lib/CodeGen/CGExprScalar.cpp:3420
@@ -3407,35 +3419,3 @@
   llvm::Type *SrcTy = Src->getType();
-  if (isa(DstTy) && isa(SrcTy)) {
-unsigned numElementsDst = cast(DstTy)->getNumElements();
-unsigned numElementsSrc = cast(SrcTy)->getNumElements();
-if ((numElementsDst == 3 && numElementsSrc == 4)
-|| (numElementsDst == 4 && numElementsSrc == 3)) {
-
-
-  // In the case of going from int4->float3, a bitcast is needed before
-  // doing a shuffle.
-  llvm::Type *srcElemTy =
-  cast(SrcTy)->getElementType();
-  llvm::Type *dstElemTy =
-  cast(DstTy)->getElementType();
-
-  if ((srcElemTy->isIntegerTy() && dstElemTy->isFloatTy())
-  || (srcElemTy->isFloatTy() && dstElemTy->isIntegerTy())) {
-// Create a float type of the same size as the source or destination.
-llvm::VectorType *newSrcTy = llvm::VectorType::get(dstElemTy,
- 
numElementsSrc);
-
-Src = Builder.CreateBitCast(Src, newSrcTy, "astypeCast");
-  }
-
-  llvm::Value *UnV = llvm::UndefValue::get(Src->getType());
-
-  SmallVector Args;
-  Args.push_back(Builder.getInt32(0));
-  Args.push_back(Builder.getInt32(1));
-  Args.push_back(Builder.getInt32(2));
-
-  if (numElementsDst == 4)
-Args.push_back(llvm::UndefValue::get(CGF.Int32Ty));
-
-  llvm::Constant *Mask = llvm::ConstantVector::get(Args);
+  unsigned numElementsSrc = isa(SrcTy) ?
+cast(SrcTy)->getNumElements() : 0;

Anastasia wrote:
> So this code no longer applies to just vectors?
Right. The issue happens when converting vec3 type to/from non-vector types.


Comment at: lib/CodeGen/CGExprScalar.cpp:3427
@@ +3426,3 @@
+  // vector to get a vec4, then a bitcast if the target type is different.
+  if (numElementsSrc == 3 && numElementsDst != 3) {
+Src = ConvertVec3AndVec4(Builder, CGF, Src, 4);

Anastasia wrote:
> Should we check numElementsDst == 4 (the same above)?
No. Special handling is needed not just for conversion between vec3/vec4 types, 
but also between vec3 and non-vector types.


Comment at: lib/CodeGen/CGExprScalar.cpp:3428
@@ +3427,3 @@
+  if (numElementsSrc == 3 && numElementsDst != 3) {
+Src = ConvertVec3AndVec4(Builder, CGF, Src, 4);
+Src = Builder.CreateBitCast(Src, DstTy);

Anastasia wrote:
> I am not sure why is this chosen to be this way?
> 
> If I check the OpenCL spec for type reinterpreting it doesn't seem to require 
> shuffle vector. Also s6.2.4.2 says: 
>   "It is an error to use as_type() or as_typen() operator to reinterpret data 
> to a type of a different number of bytes."
> 
> The only valid conversion according to the spec seems to be vec4->vec3:
> 
>   "When the operand and result type contain a different number of elements, 
> the result shall be implementation-defined except if the operand is a 
> 4-component vector and the result is a 3-component vector."
> 
> This change is affecting non-OpenCL code too. Is this reasonable approach for 
> other vector implementations?
This change only affects OpenCL code since __builtin_astype is defined as a 
keyword for OpenCL only.

According to OpenCL spec v1.1 s6.1.5, vec3 type has the same size as vec4 type, 
so it is allowed to be converted to any other types which have the same size as 
vec4 type.


Comment at: lib/CodeGen/CGExprScalar.cpp:3429
@@ +3428,3 @@
+Src = ConvertVec3AndVec4(Builder, CGF, Src, 4);
+Src = Builder.CreateBitCast(Src, DstTy);
+Src->setName("astype");

Anastasia wrote:
> I think we only need bitcast if type don't match?
Builder.CreateBitCast automatically handle this.


Comment at: test/CodeGenOpenCL/as_type.cl:7
@@ +6,3 @@
+typedef __attribute__(( ext_vector_type(3) )) int int3;
+
+//CHECK: define spir_func <3 x i8> @f1(<4 x i8> %[[x:.*]])

Anastasia wrote:
> Should this be disallowed by the frontend -? according to the spec s6.2.4.2:
> 
>   "It is an error to use as_type() or as_typen() operator to reinterpret data 
> to a type of a different number of bytes."
According to the spec v1.1 s6.1.5, vec3 type has the same size as vec4 type, so 
it is allowed to be converted to other types which have the same size as vec4 
type.


http://reviews.llvm.org/D20133



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


Re: [PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().

2016-05-30 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: include/clang/Format/Format.h:778
@@ -776,1 +777,3 @@
+/// replacement corresponding to the header insertion has offset UINT_MAX (i.e.
+/// -1U).
 tooling::Replacements

Why don't we just stick with UINT_MAX everywhere?


Comment at: lib/Format/Format.cpp:1457
@@ +1456,3 @@
+  IncludeCategoryManager Categories(Style, FileName);
+  int MaxPriority = 0;
+  for (const auto &Category : Style.IncludeCategories)

Unused


Comment at: lib/Format/Format.cpp:1466
@@ +1465,3 @@
+  // Add 0 for main header and INT_MAX for headers that are not in any 
category.
+  std::vector Priorities = {0, INT_MAX};
+  for (const auto &Category : Style.IncludeCategories)

Why not just a set?


Comment at: lib/Format/Format.cpp:1488
@@ +1487,3 @@
+Offset += Line.size() + 1;
+// FIXME: make header guard matching more strict, e.g. consider #ifndef.
+if (AfterHeaderGuard == 0 && DefineRegex.match(Line))

nit: s/more strict/stricter/


Comment at: lib/Format/Format.cpp:1494
@@ +1493,3 @@
+  // Set EndOffset of each category that is not set yet to be the end of the
+  // last category with higher priority. If there is no category with higher
+  // priority, then we look for the next block with lower category; if such

Are you sure that this is what's implemented? The way I see it is:
- Ensure that EndOffset[Highest] is always populated.
- If EndOffset[Priority] isn't set, use the next higher value that is set, up 
to EndOffset[Highest].


Comment at: lib/Format/Format.cpp:1513
@@ +1512,3 @@
+} else {
+  // Insert a new line after header guard.
+  // FIXME: since the new line and the end offset are both set to

I'd leave all of this logic out. This only affects headers with no current 
#includes, which is rare to begin with and on top of that, this is more to do 
with whether or not we want to automatically add new lines between the 
different blocks. As it currently is, this would do both:

  #define HEADER_GUARD

  #include  // inserted

and

  #define HEADER_GUARD
  #include  // inserted
  #include 

Which might be the right behavior, but I think this is the wrong place to worry 
about it. In the long run, we should probably make clang-format inserted empty 
lines around the #include blocks if desired.


Comment at: lib/Format/Format.cpp:1525
@@ +1524,3 @@
+  }
+  for (int I = 1, E = Priorities.size(); I != E; I++)
+if (CategoryEndOffsets.find(Priorities[I]) == CategoryEndOffsets.end())

Add a comment:

  // By this point, CategoryEndOffset[Highest] is always set appropriately:
  //  - to an appropriate location before/after existing #includes, or
  //  - to right after the header guard, or
  //  - to the beginning of the file.


Comment at: lib/Format/Format.cpp:1531
@@ +1530,3 @@
+auto IncludeDirective = R.getReplacementText();
+if (!IncludeRegex.match(IncludeDirective, &Matches)) {
+  llvm::errs() << IncludeDirective

This should be done together with the check for the offset being -1u. 
Eventually we are going to have something else that we are going to insert 
(e.g. using declarations) and we don't want to confuse those. And even more so, 
if all replacements at offset -1u are not #includes, we don't need to execute 
most of this function.


Comment at: lib/Format/Format.cpp:1538
@@ +1537,3 @@
+int Category =
+Categories.getIncludePriority(IncludeName, /*CheckMainHeader=*/false);
+Offset = CategoryEndOffsets[Category];

Why is CheckMainHeader false?


Comment at: lib/Format/Format.cpp:1541
@@ +1540,3 @@
+std::string NewInclude =
+(!IncludeDirective.endswith("\n"))
+? (IncludeDirective + "\n").str()

No parentheses.


Comment at: lib/Format/Format.cpp:1550
@@ +1549,3 @@
+// Insert #include directives into the correct blocks.
+tooling::Replacements fixHeaderInsertions(StringRef Code,
+  const tooling::Replacements 
&Replaces,

Hm.. Not happy with the naming. There is no real difference between 
fixHeaderInsertions and fixCppIncludeInsertions. You could argue that the "Cpp" 
part is the difference, but the actual difference is that one iterates over an 
entire set of replacements whereas the other only modifies header insertions.

I think I'd just merge the two functions, but that probably also ties back to 
my wish not to separate out the two replacement sets ;-).


http://reviews.llvm.org/D20734



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


[PATCH] D20795: Added ASTStructure for analyzing the structure of Stmts.

2016-05-30 Thread Raphael Isemann via cfe-commits
teemperor created this revision.
teemperor added reviewers: v.g.vassilev, zaks.anna.
teemperor added a subscriber: cfe-commits.

The ASTStructure class generates data for performant searching Stmts with 
similar structure.

http://reviews.llvm.org/D20795

Files:
  include/clang/AST/ASTStructure.h
  include/clang/Basic/SourceManager.h
  lib/AST/ASTStructure.cpp
  lib/AST/CMakeLists.txt
  lib/Sema/SemaChecking.cpp
  unittests/AST/ASTStructureTest.cpp
  unittests/AST/CMakeLists.txt

Index: unittests/AST/CMakeLists.txt
===
--- unittests/AST/CMakeLists.txt
+++ unittests/AST/CMakeLists.txt
@@ -5,6 +5,7 @@
 add_clang_unittest(ASTTests
   ASTContextParentMapTest.cpp
   ASTImporterTest.cpp
+  ASTStructureTest.cpp
   ASTTypeTraitsTest.cpp
   ASTVectorTest.cpp
   CommentLexer.cpp
Index: unittests/AST/ASTStructureTest.cpp
===
--- /dev/null
+++ unittests/AST/ASTStructureTest.cpp
@@ -0,0 +1,679 @@
+//===- unittests/AST/ASTStructureTest.cpp --- AST structure hasing tests-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file contains tests for ASTStructure.
+//
+//===--===//
+
+#include "gtest/gtest.h"
+#include "clang/AST/ASTStructure.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Tooling/Tooling.h"
+
+using namespace clang;
+
+class FunctionFinder : public RecursiveASTVisitor {
+  std::string FunctionName;
+  FunctionDecl *FoundFunction = nullptr;
+
+public:
+  FunctionFinder(const std::string &FunctionName)
+  : FunctionName(FunctionName) {}
+
+  FunctionDecl *getDecl() { return FoundFunction; }
+
+  bool VisitFunctionDecl(FunctionDecl *D) {
+if (D->getQualifiedNameAsString() == FunctionName) {
+  FoundFunction = D;
+  return false;
+}
+return true;
+  }
+};
+
+// Returns true if the declaration with the given qualified name
+// is hashed when processing the given code.
+bool isHashed(const std::string &DeclName, const std::string &code) {
+  auto ASTUnit = tooling::buildASTFromCode(code);
+  ASTContext &ASTContext = ASTUnit->getASTContext();
+
+  auto Hash = ASTStructure(ASTUnit->getASTContext());
+
+  FunctionFinder Finder(DeclName);
+  Finder.TraverseTranslationUnitDecl(ASTContext.getTranslationUnitDecl());
+
+  assert(Finder.getDecl());
+  return Hash.findHash(Finder.getDecl()->getBody()).Success;
+}
+
+class FindStmt : public RecursiveASTVisitor {
+  Stmt::StmtClass NeededStmtClass;
+  Stmt *FoundStmt = nullptr;
+
+public:
+  FindStmt(Stmt::StmtClass NeededStmtClass)
+  : NeededStmtClass(NeededStmtClass) {}
+
+  Stmt *getStmt() { return FoundStmt; }
+
+  bool VisitStmt(Stmt *S) {
+if (S->getStmtClass() == NeededStmtClass) {
+  FoundStmt = S;
+  return false;
+}
+return true;
+  }
+};
+
+// Returns true if any Stmt with the given class
+// is hashed when processing the given code.
+bool isHashed(Stmt::StmtClass NeededStmtClass, const std::string &code) {
+  auto ASTUnit = tooling::buildASTFromCode(code);
+  ASTContext &ASTContext = ASTUnit->getASTContext();
+
+  auto Hash = ASTStructure(ASTUnit->getASTContext());
+
+  FindStmt Finder(NeededStmtClass);
+  Finder.TraverseTranslationUnitDecl(ASTContext.getTranslationUnitDecl());
+
+  assert(Finder.getStmt());
+  return Hash.findHash(Finder.getStmt()).Success;
+}
+
+// Returns true if the Decls with the given qualified names
+// have similar structure according to ASTStructure.
+bool compareStructure(const std::string &DeclNameA,
+  const std::string &DeclNameB, const std::string &codeA,
+  const std::string &codeB) {
+  auto ASTUnitA = tooling::buildASTFromCodeWithArgs(
+  codeA, {"-std=c++1z", "-fms-extensions"});
+  auto ASTUnitB = tooling::buildASTFromCodeWithArgs(
+  codeB, {"-std=c++1z", "-fms-extensions"});
+
+  auto HashA = ASTStructure(ASTUnitA->getASTContext());
+  auto HashB = ASTStructure(ASTUnitB->getASTContext());
+
+  auto &ASTContextA = ASTUnitA->getASTContext();
+  auto &ASTContextB = ASTUnitB->getASTContext();
+
+  FunctionFinder FinderA(DeclNameA);
+  FinderA.TraverseTranslationUnitDecl(ASTContextA.getTranslationUnitDecl());
+  assert(FinderA.getDecl());
+
+  FunctionFinder FinderB(DeclNameB);
+  FinderB.TraverseTranslationUnitDecl(ASTContextB.getTranslationUnitDecl());
+  assert(FinderB.getDecl());
+
+  auto HashSearchA = HashA.findHash(FinderA.getDecl()->getBody());
+  auto HashSearchB = HashB.findHash(FinderB.getDecl()->getBody());
+  assert(HashSearchA.Success);
+  assert(HashSearchB.Success);
+  return HashSearchA.Hash == HashSearchB.Hash;
+}
+
+// Returns true if the given Stmts
+// have similar structure acc

Re: [PATCH] D20791: Support SOURCE_DATE_EPOCH environment variable

2016-05-30 Thread Ed Maste via cfe-commits
emaste updated this revision to Diff 58977.
emaste added a comment.

Use gmtime to report in UTC when `SOURCE_DATE_EPOCH` is set. This follows GCC 
and makes sense given the purpose of `SOURCE_DATE_EPOCH`.

For reference here is discussion on the GCC list when this was introduced 
there: https://gcc.gnu.org/ml/gcc-patches/2015-06/msg02210.html


http://reviews.llvm.org/D20791

Files:
  lib/Lex/PPMacroExpansion.cpp

Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -1013,8 +1013,16 @@
 /// the identifier tokens inserted.
 static void ComputeDATE_TIME(SourceLocation &DATELoc, SourceLocation &TIMELoc,
  Preprocessor &PP) {
-  time_t TT = time(nullptr);
-  struct tm *TM = localtime(&TT);
+  time_t TT;
+  struct tm *TM;
+  const char *envValue = getenv("SOURCE_DATE_EPOCH");
+  if (envValue != nullptr) {
+TT = strtol(envValue, nullptr, 10);
+TM = gmtime(&TT);
+  } else {
+TT = time(nullptr);
+TM = localtime(&TT);
+  }
 
   static const char * const Months[] = {
 "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"


Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -1013,8 +1013,16 @@
 /// the identifier tokens inserted.
 static void ComputeDATE_TIME(SourceLocation &DATELoc, SourceLocation &TIMELoc,
  Preprocessor &PP) {
-  time_t TT = time(nullptr);
-  struct tm *TM = localtime(&TT);
+  time_t TT;
+  struct tm *TM;
+  const char *envValue = getenv("SOURCE_DATE_EPOCH");
+  if (envValue != nullptr) {
+TT = strtol(envValue, nullptr, 10);
+TM = gmtime(&TT);
+  } else {
+TT = time(nullptr);
+TM = localtime(&TT);
+  }
 
   static const char * const Months[] = {
 "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20630: [OpenCL] Allow -std={cl|CL}{|1.1|1.2|2.0} in driver

2016-05-30 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 58978.
yaxunl added a comment.

Revised as Richard suggested.


http://reviews.llvm.org/D20630

Files:
  include/clang/Frontend/LangStandards.def
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/opencl.cl
  test/Frontend/stdlang.c

Index: test/Frontend/stdlang.c
===
--- test/Frontend/stdlang.c
+++ test/Frontend/stdlang.c
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -x cuda -std=c++11 -DCUDA %s
 // RUN: %clang_cc1 -x cl -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=cl -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=cl1.1 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=cl1.2 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=cl2.0 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.1 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 -DOPENCL %s
Index: test/Driver/opencl.cl
===
--- /dev/null
+++ test/Driver/opencl.cl
@@ -0,0 +1,15 @@
+// RUN: %clang %s
+// RUN: %clang -std=cl %s
+// RUN: %clang -std=cl1.1 %s
+// RUN: %clang -std=cl1.2 %s
+// RUN: %clang -std=cl2.0 %s
+// RUN: %clang -std=CL %s
+// RUN: %clang -std=CL1.1 %s
+// RUN: %clang -std=CL1.2 %s
+// RUN: %clang -std=CL2.0 %s
+// RUN: not %clang_cc1 -std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
+// RUN: not %clang_cc1 -std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
+// CHECK-C99: error: invalid argument '-std=c99' not allowed with 'OpenCL'
+// CHECK-INVALID: error: invalid value 'invalid' in '-std=invalid'
+
+kernel void func(void);
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1447,6 +1447,13 @@
 Opts.AddVFSOverlayFile(A->getValue());
 }
 
+bool isOpenCL(LangStandard::Kind LangStd) {
+  return LangStd == LangStandard::lang_opencl
+|| LangStd == LangStandard::lang_opencl11
+|| LangStd == LangStandard::lang_opencl12
+|| LangStd == LangStandard::lang_opencl20;
+}
+
 void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
  const llvm::Triple &T,
  LangStandard::Kind LangStd) {
@@ -1511,7 +1518,7 @@
   Opts.ImplicitInt = Std.hasImplicitInt();
 
   // Set OpenCL Version.
-  Opts.OpenCL = LangStd == LangStandard::lang_opencl || IK == IK_OpenCL;
+  Opts.OpenCL = isOpenCL(LangStd) || IK == IK_OpenCL;
   if (LangStd == LangStandard::lang_opencl)
 Opts.OpenCLVersion = 100;
   else if (LangStd == LangStandard::lang_opencl11)
@@ -1577,6 +1584,8 @@
 LangStd = llvm::StringSwitch(A->getValue())
 #define LANGSTANDARD(id, name, desc, features) \
   .Case(name, LangStandard::lang_##id)
+#define LANGSTANDARD_ALIAS(id, alias) \
+  .Case(alias, LangStandard::lang_##id)
 #include "clang/Frontend/LangStandards.def"
   .Default(LangStandard::lang_unspecified);
 if (LangStd == LangStandard::lang_unspecified)
@@ -1604,8 +1613,9 @@
 << A->getAsString(Args) << "C++/ObjC++";
 break;
   case IK_OpenCL:
-Diags.Report(diag::err_drv_argument_not_allowed_with)
-  << A->getAsString(Args) << "OpenCL";
+if (!isOpenCL(LangStd))
+  Diags.Report(diag::err_drv_argument_not_allowed_with)
+<< A->getAsString(Args) << "OpenCL";
 break;
   case IK_CUDA:
   case IK_PreprocessedCuda:
@@ -1624,10 +1634,10 @@
   if (const Arg *A = Args.getLastArg(OPT_cl_std_EQ)) {
 LangStandard::Kind OpenCLLangStd
 = llvm::StringSwitch(A->getValue())
-.Case("CL", LangStandard::lang_opencl)
-.Case("CL1.1", LangStandard::lang_opencl11)
-.Case("CL1.2", LangStandard::lang_opencl12)
-.Case("CL2.0", LangStandard::lang_opencl20)
+.Cases("cl", "CL", LangStandard::lang_opencl)
+.Cases("cl1.1", "CL1.1", LangStandard::lang_opencl11)
+.Cases("cl1.2", "CL1.2", LangStandard::lang_opencl12)
+.Cases("cl2.0", "CL2.0", LangStandard::lang_opencl20)
 .Default(LangStandard::lang_unspecified);
 
 if (OpenCLLangStd == LangStandard::lang_unspecified) {
Index: include/clang/Frontend/LangStandards.def
===
--- include/clang/Frontend/LangStandards.def
+++ include/clang/Frontend/LangStandards.def
@@ -19,6 +19,14 @@
 /// \param FEATURES - The standard features as flags, these are enums from the
 /// clang::frontend namespace, which is assumed to be be available.
 
+/// LANGSTANDARD_ALIAS(IDENT, ALIAS)
+/// \param IDENT - The name of the standard as a C++ identifier.
+/// \param ALIAS - The alias of the standard.
+
+#ifndef LANGSTANDARD_ALIAS
+#define LANGSTANDARD_ALIAS(IDENT, ALIAS)
+#endif
+
 // C89-ish modes.
 LANGSTANDARD(c89, "c89",
  "ISO C 1990",
@@ -135,19 +143,26 @@
 LANGSTANDARD(opencl, "cl",
  "OpenC

Re: [PATCH] D20784: [libcxx][libcxxabi] Decouple no-exceptions libcpp variant from cxa_exception.cpp and cxa_personality.cpp of libcxxabi

2016-05-30 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

I don't like the direction of this patch, and it seems like the wrong direction 
for what your trying to achieve as well.
If your trying to support a system with two variants of libc++abi, one that 
throws and the other that does not, then you'll want libc++ to remain 
unmodified so it can depend on the selected libc++abi to provide the correct 
exception handling behavior.

I think these particular symbols should always be defined within libc++abi 
(sorry if I said otherwise earlier, I didn't understand the implementation). 
The -fno-exceptions build of libc++abi can build these symbols with very simple 
definitions that is detached from the rest of the exception handling machinery.

My preference would be to create a new file `cxa_no_exception_definitions.cpp` 
(bike shedding welcome) which  builds inplace of `cxa_exception.cpp` and 
contains definitions for these symbols. For example.

- `__cxa_uncaugh_exception()`/`__cxa_uncaught_exceptions()` always returns zero.
- `__cxa_decrement_exception_refcount(ptr)`/`__cxa_increment_refcount(ptr)` 
terminate if `ptr != nullptr`.
- `__cxa_primary_exception()` returns nullptr.
- `__cxa_rethrow_primary_exception(ptr)` returns as to hit the terminate call 
in libc++.

This way we are not conflating building libc++ without exceptions with building 
libc++ against an ABI library which doesn't provide the exception handling API.


http://reviews.llvm.org/D20784



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


Re: [PATCH] D20794: [CUDA] Fix order of vectorized ldg intrinsics' elements.

2016-05-30 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271215: [CUDA] Fix order of vectorized ldg intrinsics' 
elements. (authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D20794?vs=58972&id=58976#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20794

Files:
  cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h

Index: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
@@ -74,10 +74,10 @@
   typedef char c4 __attribute__((ext_vector_type(4)));
   c4 rv = __nvvm_ldg_c4(reinterpret_cast(ptr));
   char4 ret;
-  ret.w = rv[0];
-  ret.x = rv[1];
-  ret.y = rv[2];
-  ret.z = rv[3];
+  ret.x = rv[0];
+  ret.y = rv[1];
+  ret.z = rv[2];
+  ret.w = rv[3];
   return ret;
 }
 inline __device__ short2 __ldg(const short2 *ptr) {
@@ -92,10 +92,10 @@
   typedef short s4 __attribute__((ext_vector_type(4)));
   s4 rv = __nvvm_ldg_s4(reinterpret_cast(ptr));
   short4 ret;
-  ret.w = rv[0];
-  ret.x = rv[1];
-  ret.y = rv[2];
-  ret.z = rv[3];
+  ret.x = rv[0];
+  ret.y = rv[1];
+  ret.z = rv[2];
+  ret.w = rv[3];
   return ret;
 }
 inline __device__ int2 __ldg(const int2 *ptr) {
@@ -110,10 +110,10 @@
   typedef int i4 __attribute__((ext_vector_type(4)));
   i4 rv = __nvvm_ldg_i4(reinterpret_cast(ptr));
   int4 ret;
-  ret.w = rv[0];
-  ret.x = rv[1];
-  ret.y = rv[2];
-  ret.z = rv[3];
+  ret.x = rv[0];
+  ret.y = rv[1];
+  ret.z = rv[2];
+  ret.w = rv[3];
   return ret;
 }
 inline __device__ longlong2 __ldg(const longlong2 *ptr) {
@@ -137,10 +137,10 @@
   typedef unsigned char uc4 __attribute__((ext_vector_type(4)));
   uc4 rv = __nvvm_ldg_uc4(reinterpret_cast(ptr));
   uchar4 ret;
-  ret.w = rv[0];
-  ret.x = rv[1];
-  ret.y = rv[2];
-  ret.z = rv[3];
+  ret.x = rv[0];
+  ret.y = rv[1];
+  ret.z = rv[2];
+  ret.w = rv[3];
   return ret;
 }
 inline __device__ ushort2 __ldg(const ushort2 *ptr) {
@@ -155,10 +155,10 @@
   typedef unsigned short us4 __attribute__((ext_vector_type(4)));
   us4 rv = __nvvm_ldg_us4(reinterpret_cast(ptr));
   ushort4 ret;
-  ret.w = rv[0];
-  ret.x = rv[1];
-  ret.y = rv[2];
-  ret.z = rv[3];
+  ret.x = rv[0];
+  ret.y = rv[1];
+  ret.z = rv[2];
+  ret.w = rv[3];
   return ret;
 }
 inline __device__ uint2 __ldg(const uint2 *ptr) {
@@ -173,10 +173,10 @@
   typedef unsigned int ui4 __attribute__((ext_vector_type(4)));
   ui4 rv = __nvvm_ldg_ui4(reinterpret_cast(ptr));
   uint4 ret;
-  ret.w = rv[0];
-  ret.x = rv[1];
-  ret.y = rv[2];
-  ret.z = rv[3];
+  ret.x = rv[0];
+  ret.y = rv[1];
+  ret.z = rv[2];
+  ret.w = rv[3];
   return ret;
 }
 inline __device__ ulonglong2 __ldg(const ulonglong2 *ptr) {
@@ -200,10 +200,10 @@
   typedef float f4 __attribute__((ext_vector_type(4)));
   f4 rv = __nvvm_ldg_f4(reinterpret_cast(ptr));
   float4 ret;
-  ret.w = rv[0];
-  ret.x = rv[1];
-  ret.y = rv[2];
-  ret.z = rv[3];
+  ret.x = rv[0];
+  ret.y = rv[1];
+  ret.z = rv[2];
+  ret.w = rv[3];
   return ret;
 }
 inline __device__ double2 __ldg(const double2 *ptr) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r271215 - [CUDA] Fix order of vectorized ldg intrinsics' elements.

2016-05-30 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Mon May 30 12:12:55 2016
New Revision: 271215

URL: http://llvm.org/viewvc/llvm-project?rev=271215&view=rev
Log:
[CUDA] Fix order of vectorized ldg intrinsics' elements.

Summary: The order is [x, y, z, w], not [w, x, y, z].

Subscribers: cfe-commits, tra

Differential Revision: http://reviews.llvm.org/D20794

Modified:
cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h

Modified: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h?rev=271215&r1=271214&r2=271215&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h Mon May 30 12:12:55 2016
@@ -74,10 +74,10 @@ inline __device__ char4 __ldg(const char
   typedef char c4 __attribute__((ext_vector_type(4)));
   c4 rv = __nvvm_ldg_c4(reinterpret_cast(ptr));
   char4 ret;
-  ret.w = rv[0];
-  ret.x = rv[1];
-  ret.y = rv[2];
-  ret.z = rv[3];
+  ret.x = rv[0];
+  ret.y = rv[1];
+  ret.z = rv[2];
+  ret.w = rv[3];
   return ret;
 }
 inline __device__ short2 __ldg(const short2 *ptr) {
@@ -92,10 +92,10 @@ inline __device__ short4 __ldg(const sho
   typedef short s4 __attribute__((ext_vector_type(4)));
   s4 rv = __nvvm_ldg_s4(reinterpret_cast(ptr));
   short4 ret;
-  ret.w = rv[0];
-  ret.x = rv[1];
-  ret.y = rv[2];
-  ret.z = rv[3];
+  ret.x = rv[0];
+  ret.y = rv[1];
+  ret.z = rv[2];
+  ret.w = rv[3];
   return ret;
 }
 inline __device__ int2 __ldg(const int2 *ptr) {
@@ -110,10 +110,10 @@ inline __device__ int4 __ldg(const int4
   typedef int i4 __attribute__((ext_vector_type(4)));
   i4 rv = __nvvm_ldg_i4(reinterpret_cast(ptr));
   int4 ret;
-  ret.w = rv[0];
-  ret.x = rv[1];
-  ret.y = rv[2];
-  ret.z = rv[3];
+  ret.x = rv[0];
+  ret.y = rv[1];
+  ret.z = rv[2];
+  ret.w = rv[3];
   return ret;
 }
 inline __device__ longlong2 __ldg(const longlong2 *ptr) {
@@ -137,10 +137,10 @@ inline __device__ uchar4 __ldg(const uch
   typedef unsigned char uc4 __attribute__((ext_vector_type(4)));
   uc4 rv = __nvvm_ldg_uc4(reinterpret_cast(ptr));
   uchar4 ret;
-  ret.w = rv[0];
-  ret.x = rv[1];
-  ret.y = rv[2];
-  ret.z = rv[3];
+  ret.x = rv[0];
+  ret.y = rv[1];
+  ret.z = rv[2];
+  ret.w = rv[3];
   return ret;
 }
 inline __device__ ushort2 __ldg(const ushort2 *ptr) {
@@ -155,10 +155,10 @@ inline __device__ ushort4 __ldg(const us
   typedef unsigned short us4 __attribute__((ext_vector_type(4)));
   us4 rv = __nvvm_ldg_us4(reinterpret_cast(ptr));
   ushort4 ret;
-  ret.w = rv[0];
-  ret.x = rv[1];
-  ret.y = rv[2];
-  ret.z = rv[3];
+  ret.x = rv[0];
+  ret.y = rv[1];
+  ret.z = rv[2];
+  ret.w = rv[3];
   return ret;
 }
 inline __device__ uint2 __ldg(const uint2 *ptr) {
@@ -173,10 +173,10 @@ inline __device__ uint4 __ldg(const uint
   typedef unsigned int ui4 __attribute__((ext_vector_type(4)));
   ui4 rv = __nvvm_ldg_ui4(reinterpret_cast(ptr));
   uint4 ret;
-  ret.w = rv[0];
-  ret.x = rv[1];
-  ret.y = rv[2];
-  ret.z = rv[3];
+  ret.x = rv[0];
+  ret.y = rv[1];
+  ret.z = rv[2];
+  ret.w = rv[3];
   return ret;
 }
 inline __device__ ulonglong2 __ldg(const ulonglong2 *ptr) {
@@ -200,10 +200,10 @@ inline __device__ float4 __ldg(const flo
   typedef float f4 __attribute__((ext_vector_type(4)));
   f4 rv = __nvvm_ldg_f4(reinterpret_cast(ptr));
   float4 ret;
-  ret.w = rv[0];
-  ret.x = rv[1];
-  ret.y = rv[2];
-  ret.z = rv[3];
+  ret.x = rv[0];
+  ret.y = rv[1];
+  ret.z = rv[2];
+  ret.w = rv[3];
   return ret;
 }
 inline __device__ double2 __ldg(const double2 *ptr) {


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


r271214 - [X86] Replace unaligned store builtins in SSE/AVX intrinsic files with code that will compile to a native unaligned store. Remove the builtins since they are no longer used.

2016-05-30 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon May 30 12:10:30 2016
New Revision: 271214

URL: http://llvm.org/viewvc/llvm-project?rev=271214&view=rev
Log:
[X86] Replace unaligned store builtins in SSE/AVX intrinsic files with code 
that will compile to a native unaligned store. Remove the builtins since they 
are no longer used.

Intrinsics will be removed from llvm in a future commit.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avxintrin.h
cfe/trunk/lib/Headers/emmintrin.h
cfe/trunk/lib/Headers/xmmintrin.h
cfe/trunk/test/CodeGen/avx-builtins.c
cfe/trunk/test/CodeGen/builtins-x86.c
cfe/trunk/test/CodeGen/sse-builtins.c
cfe/trunk/test/CodeGen/sse2-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=271214&r1=271213&r2=271214&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon May 30 12:10:30 2016
@@ -306,7 +306,6 @@ TARGET_BUILTIN(__builtin_ia32_ldmxcsr, "
 TARGET_BUILTIN(__builtin_ia32_stmxcsr, "Ui", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cvtss2si, "iV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cvtss2si64, "LLiV4f", "", "sse")
-TARGET_BUILTIN(__builtin_ia32_storeups, "vf*V4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_storehps, "vV2i*V4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_storelps, "vV2i*V4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_movmskps, "iV4f", "", "sse")
@@ -320,7 +319,6 @@ TARGET_BUILTIN(__builtin_ia32_sqrtps, "V
 TARGET_BUILTIN(__builtin_ia32_sqrtss, "V4fV4f", "", "sse")
 
 TARGET_BUILTIN(__builtin_ia32_maskmovdqu, "vV16cV16cc*", "", "sse2")
-TARGET_BUILTIN(__builtin_ia32_storeupd, "vd*V2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_movmskpd, "iV2d", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pmovmskb128, "iV16c", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_movnti, "vi*i", "", "sse2")
@@ -342,7 +340,6 @@ TARGET_BUILTIN(__builtin_ia32_clflush, "
 TARGET_BUILTIN(__builtin_ia32_lfence, "v", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_mfence, "v", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pause, "v", "", "sse2")
-TARGET_BUILTIN(__builtin_ia32_storedqu, "vc*V16c", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pmuludq128, "V2LLiV4iV4i", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_psraw128, "V8sV8sV8s", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_psrad128, "V4iV4iV4i", "", "sse2")
@@ -494,9 +491,6 @@ TARGET_BUILTIN(__builtin_ia32_vzeroall,
 TARGET_BUILTIN(__builtin_ia32_vzeroupper, "v", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_vbroadcastf128_pd256, "V4dV2dC*", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_vbroadcastf128_ps256, "V8fV4fC*", "", "avx")
-TARGET_BUILTIN(__builtin_ia32_storeupd256, "vd*V4d", "", "avx")
-TARGET_BUILTIN(__builtin_ia32_storeups256, "vf*V8f", "", "avx")
-TARGET_BUILTIN(__builtin_ia32_storedqu256, "vc*V32c", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_lddqu256, "V32ccC*", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_movntdq256, "vV4LLi*V4LLi", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_movntpd256, "vd*V4d", "", "avx")

Modified: cfe/trunk/lib/Headers/avxintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avxintrin.h?rev=271214&r1=271213&r2=271214&view=diff
==
--- cfe/trunk/lib/Headers/avxintrin.h (original)
+++ cfe/trunk/lib/Headers/avxintrin.h Mon May 30 12:10:30 2016
@@ -2386,13 +2386,19 @@ _mm256_store_ps(float *__p, __m256 __a)
 static __inline void __DEFAULT_FN_ATTRS
 _mm256_storeu_pd(double *__p, __m256d __a)
 {
-  __builtin_ia32_storeupd256(__p, (__v4df)__a);
+  struct __storeu_pd {
+__m256d __v;
+  } __attribute__((__packed__, __may_alias__));
+  ((struct __storeu_pd*)__p)->__v = __a;
 }
 
 static __inline void __DEFAULT_FN_ATTRS
 _mm256_storeu_ps(float *__p, __m256 __a)
 {
-  __builtin_ia32_storeups256(__p, (__v8sf)__a);
+  struct __storeu_ps {
+__m256 __v;
+  } __attribute__((__packed__, __may_alias__));
+  ((struct __storeu_ps*)__p)->__v = __a;
 }
 
 static __inline void __DEFAULT_FN_ATTRS
@@ -2404,7 +2410,10 @@ _mm256_store_si256(__m256i *__p, __m256i
 static __inline void __DEFAULT_FN_ATTRS
 _mm256_storeu_si256(__m256i *__p, __m256i __a)
 {
-  __builtin_ia32_storedqu256((char *)__p, (__v32qi)__a);
+  struct __storeu_si256 {
+__m256i __v;
+  } __attribute__((__packed__, __may_alias__));
+  ((struct __storeu_si256*)__p)->__v = __a;
 }
 
 /* Conditional load ops */
@@ -2842,9 +2851,9 @@ _mm256_storeu2_m128(float *__addr_hi, fl
   __m128 __v128;
 
   __v128 = _mm256_castps256_ps128(__a);
-  __builtin_ia32_storeups(__addr_lo, __v128);
+  _mm_storeu_ps(__addr_lo, __v128);
   __v128 = _mm256_extractf128_ps(__a, 1);
-  __builtin_ia32_storeups(__addr_hi, __v128);
+  _mm_storeu_ps(__addr_hi, __v128);
 }
 
 static __inline void __DEFAULT_FN_ATTRS
@@ -2853,9 +2862,9 @@ 

Re: [PATCH] D20621: [include-fixer] Create a mode in vim integration to show multiple potential headers.

2016-05-30 Thread Benjamin Kramer via cfe-commits
bkramer added inline comments.


Comment at: include-fixer/IncludeFixer.h:71
@@ +70,3 @@
+/// \param FirstIncludeOffset The insertion point for new include directives.
+/// -1U(UINT_MAX) indicates uninitialization, which will insert the header at
+/// first line. If there is no #include block in the Code, it will create a

I think you can drop the part about 'uninitialization' from this comment.


Comment at: include-fixer/IncludeFixer.h:79
@@ +78,3 @@
+StringRef Code, StringRef FilePath, StringRef Header,
+unsigned FirstIncludeOffset=-1U,
+const clang::format::FormatStyle &Style=clang::format::getLLVMStyle());

This doesn't look clang-formatted :p


http://reviews.llvm.org/D20621



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


Re: [PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().

2016-05-30 Thread Benjamin Kramer via cfe-commits
bkramer added inline comments.


Comment at: lib/Format/Format.cpp:1283
@@ +1282,3 @@
+  // Returns the priority of the category which \p IncludeName belongs to, and
+  // if \p CheckMainHeader is true and \p IncldueName is a
+  // main header, returns 0. Otherwise, returns INT_MAX if \p IncludeName does

Typo: IncldueName


Comment at: lib/Format/Format.cpp:1503
@@ +1502,3 @@
+  // we set its EndOffset to be AfterHeaderGuard. With this setup, the category
+  // with the highest priority has been intialized so that all other categories
+  // can find a category with higher priority and initialized EndOffset.

Typo: intialized


http://reviews.llvm.org/D20734



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


[PATCH] D20794: [CUDA] Fix order of vectorized ldg intrinsics' elements.

2016-05-30 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added subscribers: tra, cfe-commits.

The order is [x, y, z, w], not [w, x, y, z].

http://reviews.llvm.org/D20794

Files:
  lib/Headers/__clang_cuda_intrinsics.h

Index: lib/Headers/__clang_cuda_intrinsics.h
===
--- lib/Headers/__clang_cuda_intrinsics.h
+++ lib/Headers/__clang_cuda_intrinsics.h
@@ -74,10 +74,10 @@
   typedef char c4 __attribute__((ext_vector_type(4)));
   c4 rv = __nvvm_ldg_c4(reinterpret_cast(ptr));
   char4 ret;
-  ret.w = rv[0];
-  ret.x = rv[1];
-  ret.y = rv[2];
-  ret.z = rv[3];
+  ret.x = rv[0];
+  ret.y = rv[1];
+  ret.z = rv[2];
+  ret.w = rv[3];
   return ret;
 }
 inline __device__ short2 __ldg(const short2 *ptr) {
@@ -92,10 +92,10 @@
   typedef short s4 __attribute__((ext_vector_type(4)));
   s4 rv = __nvvm_ldg_s4(reinterpret_cast(ptr));
   short4 ret;
-  ret.w = rv[0];
-  ret.x = rv[1];
-  ret.y = rv[2];
-  ret.z = rv[3];
+  ret.x = rv[0];
+  ret.y = rv[1];
+  ret.z = rv[2];
+  ret.w = rv[3];
   return ret;
 }
 inline __device__ int2 __ldg(const int2 *ptr) {
@@ -110,10 +110,10 @@
   typedef int i4 __attribute__((ext_vector_type(4)));
   i4 rv = __nvvm_ldg_i4(reinterpret_cast(ptr));
   int4 ret;
-  ret.w = rv[0];
-  ret.x = rv[1];
-  ret.y = rv[2];
-  ret.z = rv[3];
+  ret.x = rv[0];
+  ret.y = rv[1];
+  ret.z = rv[2];
+  ret.w = rv[3];
   return ret;
 }
 inline __device__ longlong2 __ldg(const longlong2 *ptr) {
@@ -137,10 +137,10 @@
   typedef unsigned char uc4 __attribute__((ext_vector_type(4)));
   uc4 rv = __nvvm_ldg_uc4(reinterpret_cast(ptr));
   uchar4 ret;
-  ret.w = rv[0];
-  ret.x = rv[1];
-  ret.y = rv[2];
-  ret.z = rv[3];
+  ret.x = rv[0];
+  ret.y = rv[1];
+  ret.z = rv[2];
+  ret.w = rv[3];
   return ret;
 }
 inline __device__ ushort2 __ldg(const ushort2 *ptr) {
@@ -155,10 +155,10 @@
   typedef unsigned short us4 __attribute__((ext_vector_type(4)));
   us4 rv = __nvvm_ldg_us4(reinterpret_cast(ptr));
   ushort4 ret;
-  ret.w = rv[0];
-  ret.x = rv[1];
-  ret.y = rv[2];
-  ret.z = rv[3];
+  ret.x = rv[0];
+  ret.y = rv[1];
+  ret.z = rv[2];
+  ret.w = rv[3];
   return ret;
 }
 inline __device__ uint2 __ldg(const uint2 *ptr) {
@@ -173,10 +173,10 @@
   typedef unsigned int ui4 __attribute__((ext_vector_type(4)));
   ui4 rv = __nvvm_ldg_ui4(reinterpret_cast(ptr));
   uint4 ret;
-  ret.w = rv[0];
-  ret.x = rv[1];
-  ret.y = rv[2];
-  ret.z = rv[3];
+  ret.x = rv[0];
+  ret.y = rv[1];
+  ret.z = rv[2];
+  ret.w = rv[3];
   return ret;
 }
 inline __device__ ulonglong2 __ldg(const ulonglong2 *ptr) {
@@ -200,10 +200,10 @@
   typedef float f4 __attribute__((ext_vector_type(4)));
   f4 rv = __nvvm_ldg_f4(reinterpret_cast(ptr));
   float4 ret;
-  ret.w = rv[0];
-  ret.x = rv[1];
-  ret.y = rv[2];
-  ret.z = rv[3];
+  ret.x = rv[0];
+  ret.y = rv[1];
+  ret.z = rv[2];
+  ret.w = rv[3];
   return ret;
 }
 inline __device__ double2 __ldg(const double2 *ptr) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r271212 - test: add explicit targets for some tests

2016-05-30 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon May 30 11:36:48 2016
New Revision: 271212

URL: http://llvm.org/viewvc/llvm-project?rev=271212&view=rev
Log:
test: add explicit targets for some tests

These tests currently expect MachO section names and do not provide a target.
Explicitly provide one.

Modified:
cfe/trunk/test/CodeGen/CFStrings.c
cfe/trunk/test/CodeGen/cfstring.c
cfe/trunk/test/CodeGenObjC/2009-08-05-utf16.m
cfe/trunk/test/CodeGenObjC/constant-strings.m

Modified: cfe/trunk/test/CodeGen/CFStrings.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/CFStrings.c?rev=271212&r1=271211&r2=271212&view=diff
==
--- cfe/trunk/test/CodeGen/CFStrings.c (original)
+++ cfe/trunk/test/CodeGen/CFStrings.c Mon May 30 11:36:48 2016
@@ -1,3 +1,5 @@
+// REQUIRES: arm-registered-target,x86-registered-target
+
 // RUN: %clang_cc1 -triple thumbv7-windows -S -emit-llvm %s -o - | FileCheck 
%s -check-prefix CHECK-COFF
 // RUN: %clang_cc1 -triple i686-windows -S -emit-llvm %s -o - | FileCheck %s 
-check-prefix CHECK-COFF
 // RUN: %clang_cc1 -triple x86_64-windows -S -emit-llvm %s -o - | FileCheck %s 
-check-prefix CHECK-COFF

Modified: cfe/trunk/test/CodeGen/cfstring.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cfstring.c?rev=271212&r1=271211&r2=271212&view=diff
==
--- cfe/trunk/test/CodeGen/cfstring.c (original)
+++ cfe/trunk/test/CodeGen/cfstring.c Mon May 30 11:36:48 2016
@@ -1,9 +1,11 @@
-// RUN: %clang_cc1 -emit-llvm %s -o %t
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -triple x86_64-macho -emit-llvm %s -o %t
 
 // : Check that the backing store of CFStrings are
 // constant with the -fwritable-strings flag.
 //
-// RUN: %clang_cc1 -fwritable-strings -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-macho -fwritable-strings -emit-llvm %s -o - 
| FileCheck %s
 //
 // CHECK: @.str = private unnamed_addr constant [14 x i8] c"Hello, World!\00", 
section "__TEXT,__cstring,cstring_literals", align 1
 // CHECK: @.str.1 = private unnamed_addr constant [7 x i8] c"yo joe\00", 
section "__TEXT,__cstring,cstring_literals", align 1

Modified: cfe/trunk/test/CodeGenObjC/2009-08-05-utf16.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/2009-08-05-utf16.m?rev=271212&r1=271211&r2=271212&view=diff
==
--- cfe/trunk/test/CodeGenObjC/2009-08-05-utf16.m (original)
+++ cfe/trunk/test/CodeGenObjC/2009-08-05-utf16.m Mon May 30 11:36:48 2016
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -emit-llvm -w -x objective-c %s -o - | FileCheck %s
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -triple x86_64-macho -emit-llvm -w -x objective-c %s -o - | 
FileCheck %s
 // rdar://7095855 rdar://7115749
 
 // CHECK: private unnamed_addr constant [6 x i16] [i16 105, i16 80, i16 111, 
i16 100, i16 8482, i16 0], section "__TEXT,__ustring", align 2

Modified: cfe/trunk/test/CodeGenObjC/constant-strings.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/constant-strings.m?rev=271212&r1=271211&r2=271212&view=diff
==
--- cfe/trunk/test/CodeGenObjC/constant-strings.m (original)
+++ cfe/trunk/test/CodeGenObjC/constant-strings.m Mon May 30 11:36:48 2016
@@ -1,15 +1,17 @@
-// RUN: %clang_cc1 -emit-llvm -o %t %s
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -triple x86_64-macho -emit-llvm -o %t %s
 // RUN: FileCheck --check-prefix=CHECK-NEXT < %t %s
 
 // Check that we set alignment 1 on the string.
 //
 // CHECK-NEXT: @.str = {{.*}}constant [13 x i8] c"Hello World!\00", section 
"__TEXT,__cstring,cstring_literals", align 1
 
-// RUN: %clang_cc1 -fobjc-runtime=gcc -emit-llvm -o %t %s
+// RUN: %clang_cc1 -triple x86_64-macho -fobjc-runtime=gcc -emit-llvm -o %t %s
 // RUN: FileCheck --check-prefix=CHECK-GNU < %t %s
 // CHECK-GNU: NXConstantString
 
-// RUN: %clang_cc1 -fobjc-runtime=gcc -fconstant-string-class NSConstantString 
-emit-llvm -o %t %s
+// RUN: %clang_cc1 -triple x86_64-macho -fobjc-runtime=gcc 
-fconstant-string-class NSConstantString -emit-llvm -o %t %s
 // RUN: FileCheck --check-prefix=CHECK-GNU-WITH-CLASS < %t %s
 // CHECK-GNU-WITH-CLASS: NSConstantString
 id a = @"Hello World!";


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


Re: [PATCH] D20660: Remove `auto_ptr` in C++17.

2016-05-30 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

FYI I have a LIT change out for review that adds "// REQUIRES-ANY: [...]" which 
would be subtle for use in this patch.

http://reviews.llvm.org/D20757


http://reviews.llvm.org/D20660



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


r271211 - CodeGen: tweak CFConstantStrings for COFF and ELF

2016-05-30 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon May 30 11:23:07 2016
New Revision: 271211

URL: http://llvm.org/viewvc/llvm-project?rev=271211&view=rev
Log:
CodeGen: tweak CFConstantStrings for COFF and ELF

Adjust the constant CFString emission to emit into more appropriate sections on
ELF and COFF targets.  It would previously try to use MachO section names
irrespective of the file format.

Added:
cfe/trunk/test/CodeGen/CFStrings.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=271211&r1=271210&r2=271211&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon May 30 11:23:07 2016
@@ -3092,19 +3092,19 @@ CodeGenModule::GetAddrOfConstantCFString
   llvm::Constant *Zero = llvm::Constant::getNullValue(Int32Ty);
   llvm::Constant *Zeros[] = { Zero, Zero };
   llvm::Value *V;
-  
+
   // If we don't already have it, get __CFConstantStringClassReference.
   if (!CFConstantStringClassRef) {
 llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy);
 Ty = llvm::ArrayType::get(Ty, 0);
-llvm::Constant *GV = CreateRuntimeVariable(Ty,
-   "__CFConstantStringClassReference");
+llvm::Constant *GV =
+CreateRuntimeVariable(Ty, "__CFConstantStringClassReference");
 // Decay array -> ptr
 V = llvm::ConstantExpr::getGetElementPtr(Ty, GV, Zeros);
 CFConstantStringClassRef = V;
-  }
-  else
+  } else {
 V = CFConstantStringClassRef;
+  }
 
   QualType CFTy = getContext().getCFConstantStringType();
 
@@ -3117,8 +3117,8 @@ CodeGenModule::GetAddrOfConstantCFString
 
   // Flags.
   llvm::Type *Ty = getTypes().ConvertType(getContext().UnsignedIntTy);
-  Fields[1] = isUTF16 ? llvm::ConstantInt::get(Ty, 0x07d0) :
-llvm::ConstantInt::get(Ty, 0x07C8);
+  Fields[1] = isUTF16 ? llvm::ConstantInt::get(Ty, 0x07d0)
+  : llvm::ConstantInt::get(Ty, 0x07C8);
 
   // String pointer.
   llvm::Constant *C = nullptr;
@@ -3139,18 +3139,17 @@ CodeGenModule::GetAddrOfConstantCFString
   GV->setUnnamedAddr(true);
   // Don't enforce the target's minimum global alignment, since the only use
   // of the string is via this class initializer.
-  // FIXME: We set the section explicitly to avoid a bug in ld64 224.1. Without
-  // it LLVM can merge the string with a non unnamed_addr one during LTO. Doing
-  // that changes the section it ends in, which surprises ld64.
-  if (isUTF16) {
-CharUnits Align = getContext().getTypeAlignInChars(getContext().ShortTy);
-GV->setAlignment(Align.getQuantity());
-GV->setSection("__TEXT,__ustring");
-  } else {
-CharUnits Align = getContext().getTypeAlignInChars(getContext().CharTy);
-GV->setAlignment(Align.getQuantity());
-GV->setSection("__TEXT,__cstring,cstring_literals");
-  }
+  CharUnits Align = isUTF16
+? 
getContext().getTypeAlignInChars(getContext().ShortTy)
+: 
getContext().getTypeAlignInChars(getContext().CharTy);
+  GV->setAlignment(Align.getQuantity());
+
+  // FIXME: We set the section explicitly to avoid a bug in ld64 224.1.
+  // Without it LLVM can merge the string with a non unnamed_addr one during
+  // LTO.  Doing that changes the section it ends in, which surprises ld64.
+  if (getTarget().getTriple().getObjectFormat() == llvm::Triple::MachO)
+GV->setSection(isUTF16 ? "__TEXT,__ustring"
+   : "__TEXT,__cstring,cstring_literals");
 
   // String.
   Fields[2] =
@@ -3171,8 +3170,20 @@ CodeGenModule::GetAddrOfConstantCFString
   GV = new llvm::GlobalVariable(getModule(), C->getType(), true,
 llvm::GlobalVariable::PrivateLinkage, C,
 "_unnamed_cfstring_");
-  GV->setSection("__DATA,__cfstring");
   GV->setAlignment(Alignment.getQuantity());
+  switch (getTarget().getTriple().getObjectFormat()) {
+  case llvm::Triple::UnknownObjectFormat:
+llvm_unreachable("unknown file format");
+  case llvm::Triple::COFF:
+GV->setSection(".rdata.cfstring");
+break;
+  case llvm::Triple::ELF:
+GV->setSection(".rodata.cfstring");
+break;
+  case llvm::Triple::MachO:
+GV->setSection("__DATA,__cfstring");
+break;
+  }
   Entry.second = GV;
 
   return ConstantAddress(GV, Alignment);

Added: cfe/trunk/test/CodeGen/CFStrings.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/CFStrings.c?rev=271211&view=auto
==
--- cfe/trunk/test/CodeGen/CFStrings.c (added)
+++ cfe/trunk/test/CodeGen/CFStrings.c Mon May 30 11:23:07 2016
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple thumbv7-windows -S -emit-llvm %s -o - | FileCheck 
%s -check-prefix CHECK-COFF
+// RUN: %clang_cc1 -triple i686-windows -S

Re: [PATCH] D19165: [clang-tidy] Add modernize-increment-bool check.

2016-05-30 Thread Marek Sokołowski via cfe-commits
mnbvmar updated this revision to Diff 58940.
mnbvmar added a comment.

Clang-formatted code.
Added a simple macro test.
Resolved @Prazek's issues.


http://reviews.llvm.org/D19165

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/IncrementBoolCheck.cpp
  clang-tidy/modernize/IncrementBoolCheck.h
  clang-tidy/modernize/ModernizeTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-increment-bool.rst
  test/clang-tidy/modernize-increment-bool.cpp

Index: test/clang-tidy/modernize-increment-bool.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-increment-bool.cpp
@@ -0,0 +1,59 @@
+// RUN: %check_clang_tidy %s modernize-increment-bool %t
+
+#define INCR(var) ((var)++)
+
+template 
+T &f(T &x) { return x; }
+
+template 
+void g() {
+  T x;
+  x++;
+
+  bool y;
+  y++;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: bool incrementation is deprecated, use assignment
+  // CHECK-FIXES: y = true;
+}
+
+int main() {
+  bool b1 = false, b2 = false, b3 = false;
+
+  b1++;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: bool incrementation is deprecated, use assignment
+  // CHECK-FIXES: b1 = true;
+
+  bool b4 = f(b1)++;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: bool incrementation is deprecated, use assignment
+
+  bool b5 = ++f(b1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: bool incrementation is deprecated, use assignment
+  // CHECK-FIXES: bool b5 = (f(b1) = true);
+
+  (b1 = false)++;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: bool incrementation is deprecated, use assignment
+  // CHECK-FIXES: (b1 = false) = true;
+
+  (b1 = b2 = false)++;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: bool incrementation is deprecated, use assignment
+  // CHECK-FIXES: (b1 = b2 = false) = true;
+
+  ++(b1 = b2 = false);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: bool incrementation is deprecated, use assignment
+  // CHECK-FIXES: (b1 = b2 = false) = true;
+
+  b3 = b1++ && b2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: bool incrementation is deprecated, use assignment
+
+  b3 = ++(b1 |= b4) && b3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: bool incrementation is deprecated, use assignment
+  // CHECK-FIXES: b3 = ((b1 |= b4) = true) && b3;
+
+  int x = 8;
+  x++;
+
+  INCR(b1);
+
+  g();
+  g();
+}
Index: docs/clang-tidy/checks/modernize-increment-bool.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-increment-bool.rst
@@ -0,0 +1,54 @@
+.. title:: clang-tidy - modernize-increment-bool
+
+modernize-increment-bool
+
+
+This check detects the deprecated boolean type incrementation, and wherever possible,
+converts it into truth assignment.
+
+C++17 forbids this behavior. Before C++17 this was equivalent to setting the variable
+to true.
+
+
+Example
+---
+
+Original:
+
+.. code-block:: c++
+
+  bool variable = false;
+  variable++;
+  ++variable;
+
+  bool another = ++variable;
+  bool third = ++variable && another;
+
+After applying the check:
+
+.. code-block:: c++
+
+  bool variable = false;
+  variable = true;
+  variable = true;  /* Both postfix and prefix incrementations are supported. */
+
+  bool another = (variable = true);
+  bool third = (variable = true) && another;
+
+
+Limitations
+---
+
+When postfix boolean incrementation is not the outermost operation done in the instruction,
+tool will not repair the problem (the fix would have to append some instructions after the
+statement). For example:
+
+.. code-block:: c++
+
+  bool first = false, second;
+  second = first++;
+
+  // Equivalent to:
+  second = false;
+  first = true;
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -91,6 +91,7 @@
misc-unused-using-decls
misc-virtual-near-miss
modernize-deprecated-headers
+   modernize-increment-bool
modernize-loop-convert
modernize-make-shared
modernize-make-unique
Index: clang-tidy/modernize/ModernizeTidyModule.cpp
===
--- clang-tidy/modernize/ModernizeTidyModule.cpp
+++ clang-tidy/modernize/ModernizeTidyModule.cpp
@@ -11,6 +11,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "DeprecatedHeadersCheck.h"
+#include "IncrementBoolCheck.h"
 #include "LoopConvertCheck.h"
 #include "MakeSharedCheck.h"
 #include "MakeUniqueCheck.h"
@@ -35,6 +36,8 @@
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
 CheckFactories.registerCheck(
 "modernize-deprecated-headers");
+CheckFactories.registerCheck(
+"modernize-increment-bool");
 CheckFactories.registerCheck("modernize-loop-convert");
 CheckFactories.registerCheck("modernize-make-shared");
 CheckFactories.registerCheck("

Re: [PATCH] D20714: [Clang-tidy] Fix some Include What You Use warnings; other minor fixes

2016-05-30 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

drive-by



Comment at: clang-tidy/ClangTidy.cpp:24
@@ -24,2 +23,3 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/Frontend/ASTConsumers.h"
+#include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/FileManager.h"

This one is for sure included by 'clang/Basic/Diagnostic.h'.


Comment at: clang-tidy/ClangTidy.h:17
@@ -16,4 +16,3 @@
 #include "clang/Basic/Diagnostic.h"
-#include "clang/Basic/SourceManager.h"
-#include "clang/Tooling/Refactoring.h"
-#include "llvm/ADT/StringExtras.h"
+#include "clang/Basic/DiagnosticIDs.h"
+#include "clang/Basic/LangOptions.h"

This one is for sure included by 'clang/Basic/Diagnostic.h'.


Comment at: clang-tidy/ClangTidyDiagnosticConsumer.h:17
@@ -14,1 +16,3 @@
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticIDs.h"
+#include "clang/Basic/LangOptions.h"

This one is for sure included by 'clang/Basic/Diagnostic.h'.


Comment at: clang-tidy/ClangTidyModule.h:13
@@ -12,3 +12,3 @@
 
 #include "ClangTidy.h"
 #include "llvm/ADT/StringRef.h"

There is an issue with includes ordering here and/or line 20.


Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:15
@@ -14,1 +14,3 @@
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"

There is always the tradeoff between including separate files, or including 
AST.h

I'm not sure I prefer expanding them.
alexfh? toughs?


Comment at: clang-tidy/utils/OptionsUtils.cpp:1
@@ -1,2 +1,2 @@
 //===--- DanglingHandleCheck.cpp - 
clang-tidy--===//
 //

Could you fix this 'DanglingHandleCheck.cpp' -> 'OptionsUtils.cpp'



Repository:
  rL LLVM

http://reviews.llvm.org/D20714



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


Re: [PATCH] D20621: [include-fixer] Create a mode in vim integration to show multiple potential headers.

2016-05-30 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: include-fixer/IncludeFixer.h:80
@@ +79,3 @@
+unsigned FirstIncludeOffset=-1U,
+const clang::format::FormatStyle &Style=clang::format::getLLVMStyle());
+

Using a default argument in `Style` can simplify the code in some cases, for 
example in the Unittest. @klimek might have idea? 


http://reviews.llvm.org/D20621



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


[clang-tools-extra] r271210 - [clang-tidy] Remove redundant quote in add_new_check script

2016-05-30 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Mon May 30 10:42:08 2016
New Revision: 271210

URL: http://llvm.org/viewvc/llvm-project?rev=271210&view=rev
Log:
[clang-tidy] Remove redundant quote in add_new_check script

Summary:
Remove redundant quote.
These quotes were added here: http://reviews.llvm.org/D20766

Reviewers: bkramer

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D20792

Modified:
clang-tools-extra/trunk/clang-tidy/add_new_check.py

Modified: clang-tools-extra/trunk/clang-tidy/add_new_check.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/add_new_check.py?rev=271210&r1=271209&r2=271210&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py (original)
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py Mon May 30 10:42:08 2016
@@ -137,7 +137,7 @@ void %(check_name)s::check(const MatchFi
   const auto *MatchedDecl = Result.Nodes.getNodeAs("x");
   if (MatchedDecl->getName().startswith("awesome_"))
 return;
-  diag(MatchedDecl->getLocation(), "function '%%0' is insufficiently awesome")
+  diag(MatchedDecl->getLocation(), "function %%0 is insufficiently awesome")
   << MatchedDecl
   << FixItHint::CreateInsertion(MatchedDecl->getLocation(), "awesome_");
 }


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


Re: [PATCH] D20792: [clang-tidy] Remove redundant quote in add_new_check script

2016-05-30 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 58969.
etienneb added a comment.

nits


http://reviews.llvm.org/D20792

Files:
  clang-tidy/add_new_check.py

Index: clang-tidy/add_new_check.py
===
--- clang-tidy/add_new_check.py
+++ clang-tidy/add_new_check.py
@@ -137,7 +137,7 @@
   const auto *MatchedDecl = Result.Nodes.getNodeAs("x");
   if (MatchedDecl->getName().startswith("awesome_"))
 return;
-  diag(MatchedDecl->getLocation(), "function '%%0' is insufficiently awesome")
+  diag(MatchedDecl->getLocation(), "function %%0 is insufficiently awesome")
   << MatchedDecl
   << FixItHint::CreateInsertion(MatchedDecl->getLocation(), "awesome_");
 }


Index: clang-tidy/add_new_check.py
===
--- clang-tidy/add_new_check.py
+++ clang-tidy/add_new_check.py
@@ -137,7 +137,7 @@
   const auto *MatchedDecl = Result.Nodes.getNodeAs("x");
   if (MatchedDecl->getName().startswith("awesome_"))
 return;
-  diag(MatchedDecl->getLocation(), "function '%%0' is insufficiently awesome")
+  diag(MatchedDecl->getLocation(), "function %%0 is insufficiently awesome")
   << MatchedDecl
   << FixItHint::CreateInsertion(MatchedDecl->getLocation(), "awesome_");
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20792: [clang-tidy] Remove redundant quote in add_new_check script

2016-05-30 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg, thanks!


http://reviews.llvm.org/D20792



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


[PATCH] D20792: [clang-tidy] Remove redundant quote in add_new_check script

2016-05-30 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added a reviewer: bkramer.
etienneb added a subscriber: cfe-commits.

Remove redundant quote.
These quotes were added here: http://reviews.llvm.org/D20766

http://reviews.llvm.org/D20792

Files:
  clang-tidy/add_new_check.py
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp

Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -41,11 +41,11 @@
   if (const auto *Using = Result.Nodes.getNodeAs("using")) {
 // Ignores using-declarations defined in macros.
 if (Using->getLocation().isMacroID())
-  return ;
+  return;
 
 // Ignores using-declarations defined in class definition.
 if (isa(Using->getDeclContext()))
-  return ;
+  return;
 
 UsingDeclContext Context(Using);
 Context.UsingDeclRange = CharSourceRange::getCharRange(
Index: clang-tidy/add_new_check.py
===
--- clang-tidy/add_new_check.py
+++ clang-tidy/add_new_check.py
@@ -137,7 +137,7 @@
   const auto *MatchedDecl = Result.Nodes.getNodeAs("x");
   if (MatchedDecl->getName().startswith("awesome_"))
 return;
-  diag(MatchedDecl->getLocation(), "function '%%0' is insufficiently awesome")
+  diag(MatchedDecl->getLocation(), "function %%0 is insufficiently awesome")
   << MatchedDecl
   << FixItHint::CreateInsertion(MatchedDecl->getLocation(), "awesome_");
 }


Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -41,11 +41,11 @@
   if (const auto *Using = Result.Nodes.getNodeAs("using")) {
 // Ignores using-declarations defined in macros.
 if (Using->getLocation().isMacroID())
-  return ;
+  return;
 
 // Ignores using-declarations defined in class definition.
 if (isa(Using->getDeclContext()))
-  return ;
+  return;
 
 UsingDeclContext Context(Using);
 Context.UsingDeclRange = CharSourceRange::getCharRange(
Index: clang-tidy/add_new_check.py
===
--- clang-tidy/add_new_check.py
+++ clang-tidy/add_new_check.py
@@ -137,7 +137,7 @@
   const auto *MatchedDecl = Result.Nodes.getNodeAs("x");
   if (MatchedDecl->getName().startswith("awesome_"))
 return;
-  diag(MatchedDecl->getLocation(), "function '%%0' is insufficiently awesome")
+  diag(MatchedDecl->getLocation(), "function %%0 is insufficiently awesome")
   << MatchedDecl
   << FixItHint::CreateInsertion(MatchedDecl->getLocation(), "awesome_");
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20621: [include-fixer] Create a mode in vim integration to show multiple potential headers.

2016-05-30 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 58964.
hokein marked an inline comment as done.
hokein added a comment.

Use format::getStyle to get clang-format style.


http://reviews.llvm.org/D20621

Files:
  include-fixer/IncludeFixer.cpp
  include-fixer/IncludeFixer.h
  include-fixer/IncludeFixerContext.h
  include-fixer/tool/ClangIncludeFixer.cpp
  include-fixer/tool/clang-include-fixer.py
  test/include-fixer/commandline_options.cpp
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -70,11 +70,16 @@
   SymbolIndexMgr->addSymbolIndex(
   llvm::make_unique(Symbols));
 
-  std::set Headers;
-  std::vector Replacements;
-  IncludeFixerActionFactory Factory(*SymbolIndexMgr, Headers, Replacements,
-"llvm");
+  IncludeFixerContext FixerContext;
+  IncludeFixerActionFactory Factory(*SymbolIndexMgr, FixerContext, "llvm");
+
   runOnCode(&Factory, Code, "input.cc", ExtraArgs);
+  std::vector Replacements;
+  if (!FixerContext.Headers.empty()) {
+Replacements = clang::include_fixer::createInsertHeaderReplacements(
+Code, "input.cc", FixerContext.Headers.front(),
+FixerContext.FirstIncludeOffset);
+  }
   clang::RewriterTestContext Context;
   clang::FileID ID = Context.createInMemoryFile("input.cc", Code);
   clang::tooling::applyAllReplacements(Replacements, Context.Rewrite);
Index: test/include-fixer/commandline_options.cpp
===
--- /dev/null
+++ test/include-fixer/commandline_options.cpp
@@ -0,0 +1,12 @@
+// REQUIRES: shell
+// RUN: sed -e 's#//.*$##' %s > %t.cpp
+// RUN: clang-include-fixer -db=fixed -input='foo= "foo.h","bar.h"' -output-headers %t.cpp -- | FileCheck %s -check-prefix=CHECK-HEADERS
+// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='"foo.h"' %t.cpp | FileCheck %s -check-prefix=CHECK
+//
+// CHECK-HEADERS: "foo.h"
+// CHECK-HEADERS: "bar.h"
+//
+// CHECK: #include "foo.h"
+// CHECK: foo f;
+
+foo f;
Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -18,7 +18,6 @@
 import argparse
 import difflib
 import subprocess
-import sys
 import vim
 
 # set g:clang_include_fixer_path to the path to clang-include-fixer if it is not
@@ -28,6 +27,39 @@
 if vim.eval('exists("g:clang_include_fixer_path")') == "1":
   binary = vim.eval('g:clang_include_fixer_path')
 
+maximum_suggested_headers=3
+if vim.eval('exists("g:clang_include_fixer_maximum_suggested_headers")') == "1":
+  maximum_suggested_headers = max(
+  1,
+  vim.eval('g:clang_include_fixer_maximum_suggested_headers'))
+
+
+def ShowDialog(message, choices, default_choice_index=0):
+  to_eval = "confirm('{0}', '{1}', '{2}')".format(message,
+  choices,
+  default_choice_index)
+  return int(vim.eval(to_eval));
+
+
+def execute(command, text):
+  p = subprocess.Popen(command,
+   stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+   stdin=subprocess.PIPE)
+  return p.communicate(input=text)
+
+
+def InsertHeaderToVimBuffer(header, text):
+  command = [binary, "-stdin", "-insert-header="+header,
+ vim.current.buffer.name]
+  stdout, stderr = execute(command, text)
+  if stdout:
+lines = stdout.splitlines()
+sequence = difflib.SequenceMatcher(None, vim.current.buffer, lines)
+for op in reversed(sequence.get_opcodes()):
+  if op[0] is not 'equal':
+vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]]
+
+
 def main():
   parser = argparse.ArgumentParser(
   description='Vim integration for clang-include-fixer')
@@ -41,24 +73,36 @@
   buf = vim.current.buffer
   text = '\n'.join(buf)
 
-  # Call clang-include-fixer.
-  command = [binary, "-stdin", "-db="+args.db, "-input="+args.input,
+  # Run command to get all headers.
+  command = [binary, "-stdin", "-output-headers", "-db="+args.db, "-input="+args.input, "-debug",
  vim.current.buffer.name]
-  p = subprocess.Popen(command,
-   stdout=subprocess.PIPE, stderr=subprocess.PIPE,
-   stdin=subprocess.PIPE)
-  stdout, stderr = p.communicate(input=text)
+  stdout, stderr = execute(command, text)
+  lines = stdout.splitlines()
+  if len(lines) < 2:
+print "No header is included.\n"
+return
 
-  # If successful, replace buffer contents.
-  if stderr:
-print stderr
+  # The first line is the symbol name.
+  symbol = lines[0]
+  # If there is only one suggested header, insert it directly.
+  if len(lines) == 2 or maximum_suggested_headers == 1:
+InsertHeaderToVimBuffer(li

r271208 - [ASTMatchers] Add support of hasCondition for SwitchStmt.

2016-05-30 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Mon May 30 10:25:25 2016
New Revision: 271208

URL: http://llvm.org/viewvc/llvm-project?rev=271208&view=rev
Log:
[ASTMatchers] Add support of hasCondition for SwitchStmt.

Summary:
The switch statement could be added to the hasCondition matcher.

Example:
```
clang-query> match switchStmt(hasCondition(ignoringImpCasts(declRefExpr(
```

Output:
```
Match #1:

Binding for "root":
SwitchStmt 0x2f9b528 
|-<<>>
|-ImplicitCastExpr 0x2f9b510  'int' 
| `-ImplicitCastExpr 0x2f9b4f8  'enum Color' 
|   `-DeclRefExpr 0x2f9b4d0  'enum Color' lvalue Var 0x2f9a118 'C' 
'enum Color'
`-CompoundStmt 0x2f9b610 
  |-CaseStmt 0x2f9b578 
  | |-ImplicitCastExpr 0x2f9b638  'int' 
  | | `-DeclRefExpr 0x2f9b550  'enum Size' EnumConstant 0x2f99e40 
'Small' 'enum Size'
  | |-<<>>
  | `-ReturnStmt 0x2f9b5d0 
  |   `-IntegerLiteral 0x2f9b5b0  'int' 1
  `-DefaultStmt 0x2f9b5f0 
`-BreakStmt 0x2f9b5e8 

1 match.
```

Reviewers: aaron.ballman, sbenza, klimek

Subscribers: klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D20767

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=271208&r1=271207&r2=271208&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Mon May 30 10:25:25 2016
@@ -3536,9 +3536,9 @@ Usable as: Any Matcher
 
 
 
-MatcherAbstractConditionalOperator>hasConditionMatcherExpr> 
InnerMatcher
-Matches the condition 
expression of an if statement, for loop,
-or conditional operator.
+MatcherAbstractConditionalOperator>hasConditionMatcherExpr> 
InnerMatcher
+Matches the condition 
expression of an if statement, for loop,
+switch statement or conditional operator.
 
 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true
   if (true) {}
@@ -4293,7 +4293,7 @@ with compoundStmt()
 
 MatcherDoStmt>hasConditionMatcherExpr> 
InnerMatcher
 Matches the condition 
expression of an if statement, for loop,
-or conditional operator.
+switch statement or conditional operator.
 
 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true
   if (true) {}
@@ -4476,7 +4476,7 @@ with compoundStmt()
 
 MatcherForStmt>hasConditionMatcherExpr> 
InnerMatcher
 Matches the condition 
expression of an if statement, for loop,
-or conditional operator.
+switch statement or conditional operator.
 
 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true
   if (true) {}
@@ -4554,7 +4554,7 @@ cxxMethodDecl(returns(asString("int")))
 
 MatcherIfStmt>hasConditionMatcherExpr> 
InnerMatcher
 Matches the condition 
expression of an if statement, for loop,
-or conditional operator.
+switch statement or conditional operator.
 
 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true
   if (true) {}
@@ -5052,6 +5052,15 @@ switchStmt(forEachSwitchCase(caseStmt().
 
 
 
+MatcherSwitchStmt>hasConditionMatcherExpr> 
InnerMatcher
+Matches the condition 
expression of an if statement, for loop,
+switch statement or conditional operator.
+
+Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true
+  if (true) {}
+
+
+
 MatcherTagType>hasDeclarationMatcherDecl>  
InnerMatcher
 Matches a node if 
the declaration associated with that node
 matches the given matcher.
@@ -5385,7 +5394,7 @@ with compoundStmt()
 
 MatcherWhileStmt>hasConditionMatcherExpr> 
InnerMatcher
 Matches the condition 
expression of an if statement, for loop,
-or conditional operator.
+switch statement or conditional operator.
 
 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true
   if (true) {}

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm

Re: [clang-tools-extra] r271207 - [clang-tidy] Fix script adding new clang-tidy check

2016-05-30 Thread Benjamin Kramer via cfe-commits
On Mon, May 30, 2016 at 5:05 PM, Etienne Bergeron via cfe-commits
 wrote:
> Author: etienneb
> Date: Mon May 30 10:05:10 2016
> New Revision: 271207
>
> URL: http://llvm.org/viewvc/llvm-project?rev=271207&view=rev
> Log:
> [clang-tidy] Fix script adding new clang-tidy check
>
> Summary:
> The `getName()` call is useless. It's better to show a better example
> as tutorial.
>
> Reviewers: alexfh
>
> Subscribers: cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D20766
>
> Modified:
> clang-tools-extra/trunk/clang-tidy/add_new_check.py
>
> Modified: clang-tools-extra/trunk/clang-tidy/add_new_check.py
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/add_new_check.py?rev=271207&r1=271206&r2=271207&view=diff
> ==
> --- clang-tools-extra/trunk/clang-tidy/add_new_check.py (original)
> +++ clang-tools-extra/trunk/clang-tidy/add_new_check.py Mon May 30 10:05:10 
> 2016
> @@ -138,7 +138,7 @@ void %(check_name)s::check(const MatchFi
>if (MatchedDecl->getName().startswith("awesome_"))
>  return;
>diag(MatchedDecl->getLocation(), "function '%%0' is insufficiently 
> awesome")
> -  << MatchedDecl->getName()
> +  << MatchedDecl

Won't you get duplicated ' now?

><< FixItHint::CreateInsertion(MatchedDecl->getLocation(), "awesome_");
>  }
>
>
>
> ___
> 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: [PATCH] D18821: Add bugprone-bool-to-integer-conversion

2016-05-30 Thread Piotr Padlewski via cfe-commits
Prazek updated this revision to Diff 58961.
Prazek added a comment.

aborting with virtual functions


http://reviews.llvm.org/D18821

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/bugprone/BoolToIntegerConversionCheck.cpp
  clang-tidy/bugprone/BoolToIntegerConversionCheck.h
  clang-tidy/bugprone/BugProneModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-bool-to-integer-conversion.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/bugprone-bool-to-integer-conversion.cpp

Index: test/clang-tidy/bugprone-bool-to-integer-conversion.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-bool-to-integer-conversion.cpp
@@ -0,0 +1,217 @@
+// RUN: %check_clang_tidy %s bugprone-bool-to-integer-conversion %t
+
+const int is42Answer = true;
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: implicitly converting bool literal to 'int'; use integer literal instead [bugprone-bool-to-integer-conversion]
+// CHECK-FIXES: const int is42Answer = 1;{{$}}
+
+volatile int noItsNot = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: implicitly converting bool literal to 'int'; {{..}}
+// CHECK-FIXES: volatile int noItsNot = 0;{{$}}
+int a = 42;
+int az = a;
+
+long long ll = true;
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: implicitly converting bool literal to 'long long';{{..}}
+// CHECK-FIXES: long long ll = 1;{{$}}
+
+void fun(int) {}
+#define ONE true
+
+// No fixup for macros.
+int one = ONE;
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: implicitly converting bool literal to 'int'; use integer literal instead [bugprone-bool-to-integer-conversion]
+
+void test() {
+  fun(ONE);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: implicitly converting bool{{..}}
+
+  fun(42);
+  fun(true);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: implicitly {{..}}
+// CHECK-FIXES: fun(1);{{$}}
+}
+
+char c = true;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: implicitly {{..}}
+// CHECK-FIXES: char c = 1;
+
+float f = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: implicitly converting bool literal to 'float';{{..}}
+// CHECK-FIXES: float f = 0;
+
+struct Blah {
+  Blah(int blah) { }
+};
+
+const int &ref = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: implicitly converting bool literal to 'int'{{..}}
+// CHECK-FIXES: const int &ref = 0;
+
+Blah bla = true;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: implicitly converting bool literal to 'int'{{..}}
+// CHECK-FIXES: Blah bla = 1;
+
+Blah bla2 = 1;
+
+char c2 = 1;
+char c3 = '0';
+bool b = true;
+
+// Don't warn of bitfields of size 1. Unfortunately we can't just
+// change type of flag to bool, because some compilers like MSVC doesn't
+// pack bitfields of different types.
+struct BitFields {
+  BitFields() : a(true), flag(false) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: implicitly converting
+// CHECK-FIXES: BitFields() : a(1), flag(false) {}
+
+  unsigned a : 3;
+  unsigned flag : 1;
+};
+
+struct some_struct {
+  bool p;
+  int z;
+};
+
+void testBitFields() {
+  BitFields b;
+  b.flag = true;
+  b.a = true;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: implicitly converting
+// CHECK-FIXES: b.a = 1;
+
+  b.flag |= true;
+  some_struct s;
+  s.p |= true;
+  s.z |= true;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: implicitly converting
+// CHECK-FIXES: s.z |= 1;
+}
+
+bool returnsBool() { return true; }
+
+void test_operators() {
+  bool p = false;
+  if (p == false) {
+
+  }
+  int z = 1;
+  if (z == true) {
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: implicitly converting
+// CHECK-FIXES: if (z == 1) {
+
+  }
+  bool p2 = false != p;
+
+  int z2 = z - true;
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: implicitly converting
+// CHECK-FIXES: int z2 = z - 1;
+
+  bool p3 = z + true;
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: implicitly converting
+// CHECK-FIXES: bool p3 = z + 1;
+
+  if(true && p == false) {}
+  if (returnsBool() == false) {}
+}
+
+bool ok() {
+  return true;
+  {
+return false;
+  }
+  bool z;
+  return z;
+}
+
+int change_type();
+// CHECK-FIXES: bool change_type();
+
+// This function returns only bools
+int change_type() {
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function has return type 'int' but returns only bools [bugprone-bool-to-integer-conversion]
+  // CHECK-FIXES: bool change_type() {
+
+  bool p;
+  return p;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: note: converting bool to 'int' here
+
+  return true;
+  {
+return false;
+  }
+  return ok();
+}
+
+int change_type(int);
+
+char change_type2() {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function has return type 'char' but returns only bools [bugprone-bool-to-integer-conversion]
+  // CHECK-FIXES: bool change_type2() {
+
+  bool z;
+  return z;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: note: converting bool to 'char' here
+

[PATCH] D20791: Support SOURCE_DATE_EPOCH environment variable

2016-05-30 Thread Ed Maste via cfe-commits
emaste created this revision.
emaste added a subscriber: cfe-commits.

`SOURCE_DATE_EPOCH` specifies a UNIX timestamp (number of seconds since 01 Jan 
1970 00:00:00 UTC) to be used as the timestamp input for build processes e.g. 
`__DATE__` and `__TIME__`

See https://reproducible-builds.org/specs/source-date-epoch/ for details, and 
GCC support at https://gcc.gnu.org/onlinedocs/cpp/Environment-Variables.html.




http://reviews.llvm.org/D20791

Files:
  lib/Lex/PPMacroExpansion.cpp

Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -1013,7 +1013,12 @@
 /// the identifier tokens inserted.
 static void ComputeDATE_TIME(SourceLocation &DATELoc, SourceLocation &TIMELoc,
  Preprocessor &PP) {
-  time_t TT = time(nullptr);
+  time_t TT;
+  const char *envValue = getenv("SOURCE_DATE_EPOCH");
+  if (envValue != nullptr)
+TT = strtol(envValue, nullptr, 10);
+  else
+TT = time(nullptr);
   struct tm *TM = localtime(&TT);
 
   static const char * const Months[] = {


Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -1013,7 +1013,12 @@
 /// the identifier tokens inserted.
 static void ComputeDATE_TIME(SourceLocation &DATELoc, SourceLocation &TIMELoc,
  Preprocessor &PP) {
-  time_t TT = time(nullptr);
+  time_t TT;
+  const char *envValue = getenv("SOURCE_DATE_EPOCH");
+  if (envValue != nullptr)
+TT = strtol(envValue, nullptr, 10);
+  else
+TT = time(nullptr);
   struct tm *TM = localtime(&TT);
 
   static const char * const Months[] = {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20383: PCH + Module: make sure we write out macros associated with builtin identifiers

2016-05-30 Thread Doug Gregor via cfe-commits
doug.gregor added a comment.

Yeah, this looks like the right approach. PCH follows the same rules as modules 
when it comes to newer information shadowing imported information.


http://reviews.llvm.org/D20383



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


[clang-tools-extra] r271207 - [clang-tidy] Fix script adding new clang-tidy check

2016-05-30 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Mon May 30 10:05:10 2016
New Revision: 271207

URL: http://llvm.org/viewvc/llvm-project?rev=271207&view=rev
Log:
[clang-tidy] Fix script adding new clang-tidy check

Summary:
The `getName()` call is useless. It's better to show a better example
as tutorial.

Reviewers: alexfh

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D20766

Modified:
clang-tools-extra/trunk/clang-tidy/add_new_check.py

Modified: clang-tools-extra/trunk/clang-tidy/add_new_check.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/add_new_check.py?rev=271207&r1=271206&r2=271207&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py (original)
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py Mon May 30 10:05:10 2016
@@ -138,7 +138,7 @@ void %(check_name)s::check(const MatchFi
   if (MatchedDecl->getName().startswith("awesome_"))
 return;
   diag(MatchedDecl->getLocation(), "function '%%0' is insufficiently awesome")
-  << MatchedDecl->getName()
+  << MatchedDecl
   << FixItHint::CreateInsertion(MatchedDecl->getLocation(), "awesome_");
 }
 


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


Re: [PATCH] D20766: [clang-tidy] Fix script adding new clang-tidy check

2016-05-30 Thread Etienne Bergeron via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271207: [clang-tidy] Fix script adding new clang-tidy check 
(authored by etienneb).

Changed prior to commit:
  http://reviews.llvm.org/D20766?vs=58878&id=58958#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20766

Files:
  clang-tools-extra/trunk/clang-tidy/add_new_check.py

Index: clang-tools-extra/trunk/clang-tidy/add_new_check.py
===
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py
@@ -138,7 +138,7 @@
   if (MatchedDecl->getName().startswith("awesome_"))
 return;
   diag(MatchedDecl->getLocation(), "function '%%0' is insufficiently awesome")
-  << MatchedDecl->getName()
+  << MatchedDecl
   << FixItHint::CreateInsertion(MatchedDecl->getLocation(), "awesome_");
 }
 


Index: clang-tools-extra/trunk/clang-tidy/add_new_check.py
===
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py
@@ -138,7 +138,7 @@
   if (MatchedDecl->getName().startswith("awesome_"))
 return;
   diag(MatchedDecl->getLocation(), "function '%%0' is insufficiently awesome")
-  << MatchedDecl->getName()
+  << MatchedDecl
   << FixItHint::CreateInsertion(MatchedDecl->getLocation(), "awesome_");
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20790: [Clang][Intrinsics][avx512] Adding round cvt to clang

2016-05-30 Thread michael zuckerman via cfe-commits
m_zuckerman updated this revision to Diff 58957.

http://reviews.llvm.org/D20790

Files:
  lib/Headers/avx512fintrin.h
  test/CodeGen/avx512f-builtins.c

Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -3103,6 +3103,140 @@
   // CHECK: @llvm.x86.avx512.cvttss2usi64
   return _mm_cvttss_u64(__A); 
 }
+
+__m512 test_mm512_mask_cvt_roundepi32_ps(__m512 __W, __mmask16 __U, __m512i __A)
+{
+  // CHECK-LABEL: @test_mm512_mask_cvt_roundepi32_ps
+  // CHECK: @llvm.x86.avx512.mask.cvtdq2ps.512
+  return _mm512_mask_cvt_roundepi32_ps(__W, __U, __A, 4);
+}
+
+__m512 test_mm512_maskz_cvt_roundepi32_ps(__mmask16 __U, __m512i __A)
+{
+  // CHECK-LABEL: @test_mm512_maskz_cvt_roundepi32_ps
+  // CHECK: @llvm.x86.avx512.mask.cvtdq2ps.512
+  return _mm512_maskz_cvt_roundepi32_ps(__U, __A, 4);
+}
+
+__m512 test_mm512_mask_cvt_roundepu32_ps(__m512 __W, __mmask16 __U, __m512i __A)
+{
+  // CHECK-LABEL: @test_mm512_mask_cvt_roundepu32_ps
+  // CHECK: @llvm.x86.avx512.mask.cvtudq2ps.512
+  return _mm512_mask_cvt_roundepu32_ps(__W, __U, __A, 4);
+}
+
+__m512 test_mm512_maskz_cvt_roundepu32_ps(__mmask16 __U, __m512i __A)
+{
+  // CHECK-LABEL: @test_mm512_maskz_cvt_roundepu32_ps
+  // CHECK: @llvm.x86.avx512.mask.cvtudq2ps.512
+  return _mm512_maskz_cvt_roundepu32_ps(__U , __A, 4);
+}
+
+__m256 test_mm512_mask_cvt_roundpd_ps(__m256 W, __mmask8 U, __m512d A)
+{
+  // CHECK-LABEL: @test_mm512_mask_cvt_roundpd_ps
+  // CHECK: @llvm.x86.avx512.mask.cvtpd2ps.512
+  return _mm512_mask_cvt_roundpd_ps(W, U, A, 4);
+}
+
+__m256 test_mm512_maskz_cvt_roundpd_ps(__mmask8 U, __m512d A)
+{
+  // CHECK-LABEL: @test_mm512_maskz_cvt_roundpd_ps
+  // CHECK: @llvm.x86.avx512.mask.cvtpd2ps.512
+  return _mm512_maskz_cvt_roundpd_ps(U, A, 4);
+}
+
+__m256i test_mm512_cvtt_roundpd_epi32(__m512d A)
+{
+  // CHECK-LABEL: @test_mm512_cvtt_roundpd_epi32
+  // CHECK: @llvm.x86.avx512.mask.cvttpd2dq.512
+  return _mm512_cvtt_roundpd_epi32(A, 4);
+}
+
+__m256i test_mm512_mask_cvtt_roundpd_epi32(__m256i W, __mmask8 U, __m512d A)
+{
+  // CHECK-LABEL: @test_mm512_mask_cvtt_roundpd_epi32
+  // CHECK: @llvm.x86.avx512.mask.cvttpd2dq.512
+  return _mm512_mask_cvtt_roundpd_epi32(W, U, A, 4);
+}
+
+__m256i test_mm512_maskz_cvtt_roundpd_epi32(__mmask8 U, __m512d A)
+{
+  // CHECK-LABEL: @test_mm512_maskz_cvtt_roundpd_epi32
+  // CHECK: @llvm.x86.avx512.mask.cvttpd2dq.512
+  return _mm512_maskz_cvtt_roundpd_epi32(U, A, 4);
+}
+
+__m512i test_mm512_mask_cvtt_roundps_epi32(__m512i W, __mmask16 U, __m512 A)
+{
+  // CHECK-LABEL: @test_mm512_mask_cvtt_roundps_epi32
+  // CHECK: @llvm.x86.avx512.mask.cvttps2dq.512
+  return _mm512_mask_cvtt_roundps_epi32(W, U, A, 4);
+}
+
+__m512i test_mm512_maskz_cvtt_roundps_epi32(__mmask16 U, __m512 A)
+{
+  // CHECK-LABEL: @test_mm512_maskz_cvtt_roundps_epi32
+  // CHECK: @llvm.x86.avx512.mask.cvttps2dq.512
+  return _mm512_maskz_cvtt_roundps_epi32(U, A, 4);
+}
+
+__m512i test_mm512_mask_cvt_roundps_epi32(__m512i __W, __mmask16 __U, __m512 __A)
+{
+  // CHECK-LABEL: @test_mm512_mask_cvt_roundps_epi32
+  // CHECK: @llvm.x86.avx512.mask.cvtps2dq.512
+  return _mm512_mask_cvt_roundps_epi32(__W, __U, __A, 4);
+}
+
+__m512i test_mm512_maskz_cvt_roundps_epi32(__mmask16 __U, __m512 __A)
+{
+  // CHECK-LABEL: @test_mm512_maskz_cvt_roundps_epi32
+  // CHECK: @llvm.x86.avx512.mask.cvtps2dq.512
+  return _mm512_maskz_cvt_roundps_epi32(__U, __A, 4);
+}
+
+__m256i test_mm512_mask_cvt_roundpd_epi32(__m256i W, __mmask8 U, __m512d A)
+{
+  // CHECK-LABEL: @test_mm512_mask_cvt_roundpd_epi32
+  // CHECK: @llvm.x86.avx512.mask.cvtpd2dq.512
+  return _mm512_mask_cvt_roundpd_epi32(W, U, A, 4);
+}
+
+__m256i test_mm512_maskz_cvt_roundpd_epi32(__mmask8 U, __m512d A)
+{
+  // CHECK-LABEL: @test_mm512_maskz_cvt_roundpd_epi32
+  // CHECK: @llvm.x86.avx512.mask.cvtpd2dq.512
+  return _mm512_maskz_cvt_roundpd_epi32(U, A, 4);
+}
+
+__m512i test_mm512_mask_cvt_roundps_epu32(__m512i __W, __mmask16 __U, __m512 __A)
+{
+  // CHECK-LABEL: @test_mm512_mask_cvt_roundps_epu32
+  // CHECK: @llvm.x86.avx512.mask.cvtps2udq.512
+  return _mm512_mask_cvt_roundps_epu32(__W, __U, __A, 4);
+}
+
+__m512i test_mm512_maskz_cvt_roundps_epu32(__mmask16 __U, __m512 __A)
+{
+  // CHECK-LABEL: @test_mm512_maskz_cvt_roundps_epu32
+  // CHECK: @llvm.x86.avx512.mask.cvtps2udq.512
+  return _mm512_maskz_cvt_roundps_epu32(__U, __A, 4);
+}
+
+__m256i test_mm512_mask_cvt_roundpd_epu32(__m256i W, __mmask8 U, __m512d A)
+{
+  // CHECK-LABEL: @test_mm512_mask_cvt_roundpd_epu32
+  // CHECK: @llvm.x86.avx512.mask.cvtpd2udq.512
+  return _mm512_mask_cvt_roundpd_epu32(W, U, A, 4);
+}
+
+__m256i test_mm512_maskz_cvt_roundpd_epu32(__mmask8 U, __m512d A) 
+{
+  // CHECK-LABEL: @test_mm512_maskz_cvt_roundpd_epu32
+  // CHECK: @llvm.x86.avx512.mask.cvtpd2udq.512
+  return _mm512_maskz_cvt_roundpd_epu32(U, A, 4);
+}
+
 __m512 test_mm512_mask2_permutex2var_ps(__m512 __A, __m512i

[PATCH] D20790: [Clang][Intrinsics][avx512] Adding round cvt to clang

2016-05-30 Thread michael zuckerman via cfe-commits
m_zuckerman created this revision.
m_zuckerman added reviewers: AsafBadouh, igorb, delena.
m_zuckerman added a subscriber: cfe-commits.

http://reviews.llvm.org/D20790

Files:
  lib/Headers/avx512fintrin.h
  test/CodeGen/avx512f-builtins.c

Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -3103,6 +3103,140 @@
   // CHECK: @llvm.x86.avx512.cvttss2usi64
   return _mm_cvttss_u64(__A); 
 }
+
+__m512 test_mm512_mask_cvt_roundepi32_ps(__m512 __W, __mmask16 __U, __m512i __A)
+{
+  // CHECK-LABEL: @test_mm512_mask_cvt_roundepi32_ps
+  // CHECK: @llvm.x86.avx512.mask.cvtdq2ps.512
+  return _mm512_mask_cvt_roundepi32_ps(__W,__U,__A,4);
+}
+
+__m512 test_mm512_maskz_cvt_roundepi32_ps(__mmask16 __U, __m512i __A)
+{
+  // CHECK-LABEL: @test_mm512_maskz_cvt_roundepi32_ps
+  // CHECK: @llvm.x86.avx512.mask.cvtdq2ps.512
+  return _mm512_maskz_cvt_roundepi32_ps(__U,__A,4);
+}
+
+__m512 test_mm512_mask_cvt_roundepu32_ps(__m512 __W, __mmask16 __U,__m512i __A)
+{
+  // CHECK-LABEL: @test_mm512_mask_cvt_roundepu32_ps
+  // CHECK: @llvm.x86.avx512.mask.cvtudq2ps.512
+  return _mm512_mask_cvt_roundepu32_ps(__W,__U,__A,4);
+}
+
+__m512 test_mm512_maskz_cvt_roundepu32_ps(__mmask16 __U,__m512i __A)
+{
+  // CHECK-LABEL: @test_mm512_maskz_cvt_roundepu32_ps
+  // CHECK: @llvm.x86.avx512.mask.cvtudq2ps.512
+  return _mm512_maskz_cvt_roundepu32_ps(__U,__A,4);
+}
+
+__m256 test_mm512_mask_cvt_roundpd_ps(__m256 W, __mmask8 U,__m512d A)
+{
+  // CHECK-LABEL: @test_mm512_mask_cvt_roundpd_ps
+  // CHECK: @llvm.x86.avx512.mask.cvtpd2ps.512
+  return _mm512_mask_cvt_roundpd_ps(W,U,A,4);
+}
+
+__m256 test_mm512_maskz_cvt_roundpd_ps(__mmask8 U, __m512d A)
+{
+  // CHECK-LABEL: @test_mm512_maskz_cvt_roundpd_ps
+  // CHECK: @llvm.x86.avx512.mask.cvtpd2ps.512
+  return _mm512_maskz_cvt_roundpd_ps(U,A,4);
+}
+
+__m256i test_mm512_cvtt_roundpd_epi32(__m512d A)
+{
+  // CHECK-LABEL: @test_mm512_cvtt_roundpd_epi32
+  // CHECK: @llvm.x86.avx512.mask.cvttpd2dq.512
+  return _mm512_cvtt_roundpd_epi32(A,4);
+}
+
+__m256i test_mm512_mask_cvtt_roundpd_epi32(__m256i W, __mmask8 U, __m512d A)
+{
+  // CHECK-LABEL: @test_mm512_mask_cvtt_roundpd_epi32
+  // CHECK: @llvm.x86.avx512.mask.cvttpd2dq.512
+  return _mm512_mask_cvtt_roundpd_epi32(W,U,A,4);
+}
+
+__m256i test_mm512_maskz_cvtt_roundpd_epi32(__mmask8 U, __m512d A)
+{
+  // CHECK-LABEL: @test_mm512_maskz_cvtt_roundpd_epi32
+  // CHECK: @llvm.x86.avx512.mask.cvttpd2dq.512
+  return _mm512_maskz_cvtt_roundpd_epi32(U,A,4);
+}
+
+__m512i test_mm512_mask_cvtt_roundps_epi32(__m512i W,__mmask16 U, __m512 A)
+{
+  // CHECK-LABEL: @test_mm512_mask_cvtt_roundps_epi32
+  // CHECK: @llvm.x86.avx512.mask.cvttps2dq.512
+  return _mm512_mask_cvtt_roundps_epi32(W,U,A,4);
+}
+
+__m512i test_mm512_maskz_cvtt_roundps_epi32(__mmask16 U, __m512 A)
+{
+  // CHECK-LABEL: @test_mm512_maskz_cvtt_roundps_epi32
+  // CHECK: @llvm.x86.avx512.mask.cvttps2dq.512
+  return _mm512_maskz_cvtt_roundps_epi32(U,A,4);
+}
+
+__m512i test_mm512_mask_cvt_roundps_epi32(__m512i __W,__mmask16 __U,__m512 __A)
+{
+  // CHECK-LABEL: @test_mm512_mask_cvt_roundps_epi32
+  // CHECK: @llvm.x86.avx512.mask.cvtps2dq.512
+  return _mm512_mask_cvt_roundps_epi32(__W,__U,__A,4);
+}
+
+__m512i test_mm512_maskz_cvt_roundps_epi32(__mmask16 __U, __m512 __A)
+{
+  // CHECK-LABEL: @test_mm512_maskz_cvt_roundps_epi32
+  // CHECK: @llvm.x86.avx512.mask.cvtps2dq.512
+  return _mm512_maskz_cvt_roundps_epi32(__U,__A,4);
+}
+
+__m256i test_mm512_mask_cvt_roundpd_epi32(__m256i W,__mmask8 U,__m512d A)
+{
+  // CHECK-LABEL: @test_mm512_mask_cvt_roundpd_epi32
+  // CHECK: @llvm.x86.avx512.mask.cvtpd2dq.512
+  return _mm512_mask_cvt_roundpd_epi32(W,U,A,4);
+}
+
+__m256i test_mm512_maskz_cvt_roundpd_epi32(__mmask8 U, __m512d A)
+{
+  // CHECK-LABEL: @test_mm512_maskz_cvt_roundpd_epi32
+  // CHECK: @llvm.x86.avx512.mask.cvtpd2dq.512
+  return _mm512_maskz_cvt_roundpd_epi32(U,A,4);
+}
+
+__m512i test_mm512_mask_cvt_roundps_epu32(__m512i __W,__mmask16 __U,__m512 __A)
+{
+  // CHECK-LABEL: @test_mm512_mask_cvt_roundps_epu32
+  // CHECK: @llvm.x86.avx512.mask.cvtps2udq.512
+  return _mm512_mask_cvt_roundps_epu32(__W,__U,__A,4);
+}
+
+__m512i test_mm512_maskz_cvt_roundps_epu32(__mmask16 __U,__m512 __A)
+{
+  // CHECK-LABEL: @test_mm512_maskz_cvt_roundps_epu32
+  // CHECK: @llvm.x86.avx512.mask.cvtps2udq.512
+  return _mm512_maskz_cvt_roundps_epu32(__U,__A, 4);
+}
+
+__m256i test_mm512_mask_cvt_roundpd_epu32(__m256i W, __mmask8 U, __m512d A)
+{
+  // CHECK-LABEL: @test_mm512_mask_cvt_roundpd_epu32
+  // CHECK: @llvm.x86.avx512.mask.cvtpd2udq.512
+  return _mm512_mask_cvt_roundpd_epu32(W,U,A,4);
+}
+
+__m256i test_mm512_maskz_cvt_roundpd_epu32(__mmask8 U, __m512d A) 
+{
+  // CHECK-LABEL: @test_mm512_maskz_cvt_roundpd_epu32
+  // CHECK: @llvm.x86.avx512.mask.cvtpd2udq.512
+  return _mm512_maskz_cvt_roundpd_epu32(U, A, 4);
+}
+
 __m512 test_mm512_mask2_per

Re: [PATCH] D20621: [include-fixer] Create a mode in vim integration to show multiple potential headers.

2016-05-30 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: include-fixer/IncludeFixer.h:80
@@ +79,3 @@
+unsigned FirstIncludeOffset=-1U,
+const clang::format::FormatStyle &Style=clang::format::getLLVMStyle());
+

I don't see why we'd want Style to be optional.


Comment at: include-fixer/tool/ClangIncludeFixer.cpp:110
@@ +109,3 @@
+  format::FormatStyle InsertStyle;
+  format::getPredefinedStyle(Style, format::FormatStyle::LK_Cpp, &InsertStyle);
+

We might still want to use `clang::format::getStyle("file", FilePath, 
FallbackStyle);`, which will use format style defined in clang-format config 
file in the path, if such config file exists. `Style` option is just a fallback 
style.


http://reviews.llvm.org/D20621



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


Re: [PATCH] D20621: [include-fixer] Create a mode in vim integration to show multiple potential headers.

2016-05-30 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 58955.
hokein marked an inline comment as done.
hokein added a comment.

Refactor createReplacementsForHeaders.


http://reviews.llvm.org/D20621

Files:
  include-fixer/IncludeFixer.cpp
  include-fixer/IncludeFixer.h
  include-fixer/IncludeFixerContext.h
  include-fixer/tool/ClangIncludeFixer.cpp
  include-fixer/tool/clang-include-fixer.py
  test/include-fixer/commandline_options.cpp
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -70,11 +70,16 @@
   SymbolIndexMgr->addSymbolIndex(
   llvm::make_unique(Symbols));
 
-  std::set Headers;
-  std::vector Replacements;
-  IncludeFixerActionFactory Factory(*SymbolIndexMgr, Headers, Replacements,
-"llvm");
+  IncludeFixerContext FixerContext;
+  IncludeFixerActionFactory Factory(*SymbolIndexMgr, FixerContext, "llvm");
+
   runOnCode(&Factory, Code, "input.cc", ExtraArgs);
+  std::vector Replacements;
+  if (!FixerContext.Headers.empty()) {
+Replacements = clang::include_fixer::createInsertHeaderReplacements(
+Code, "input.cc", FixerContext.Headers.front(),
+FixerContext.FirstIncludeOffset);
+  }
   clang::RewriterTestContext Context;
   clang::FileID ID = Context.createInMemoryFile("input.cc", Code);
   clang::tooling::applyAllReplacements(Replacements, Context.Rewrite);
Index: test/include-fixer/commandline_options.cpp
===
--- /dev/null
+++ test/include-fixer/commandline_options.cpp
@@ -0,0 +1,12 @@
+// REQUIRES: shell
+// RUN: sed -e 's#//.*$##' %s > %t.cpp
+// RUN: clang-include-fixer -db=fixed -input='foo= "foo.h","bar.h"' -output-headers %t.cpp -- | FileCheck %s -check-prefix=CHECK-HEADERS
+// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='"foo.h"' %t.cpp | FileCheck %s -check-prefix=CHECK
+//
+// CHECK-HEADERS: "foo.h"
+// CHECK-HEADERS: "bar.h"
+//
+// CHECK: #include "foo.h"
+// CHECK: foo f;
+
+foo f;
Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -18,7 +18,6 @@
 import argparse
 import difflib
 import subprocess
-import sys
 import vim
 
 # set g:clang_include_fixer_path to the path to clang-include-fixer if it is not
@@ -28,6 +27,39 @@
 if vim.eval('exists("g:clang_include_fixer_path")') == "1":
   binary = vim.eval('g:clang_include_fixer_path')
 
+maximum_suggested_headers=3
+if vim.eval('exists("g:clang_include_fixer_maximum_suggested_headers")') == "1":
+  maximum_suggested_headers = max(
+  1,
+  vim.eval('g:clang_include_fixer_maximum_suggested_headers'))
+
+
+def ShowDialog(message, choices, default_choice_index=0):
+  to_eval = "confirm('{0}', '{1}', '{2}')".format(message,
+  choices,
+  default_choice_index)
+  return int(vim.eval(to_eval));
+
+
+def execute(command, text):
+  p = subprocess.Popen(command,
+   stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+   stdin=subprocess.PIPE)
+  return p.communicate(input=text)
+
+
+def InsertHeaderToVimBuffer(header, text):
+  command = [binary, "-stdin", "-insert-header="+header,
+ vim.current.buffer.name]
+  stdout, stderr = execute(command, text)
+  if stdout:
+lines = stdout.splitlines()
+sequence = difflib.SequenceMatcher(None, vim.current.buffer, lines)
+for op in reversed(sequence.get_opcodes()):
+  if op[0] is not 'equal':
+vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]]
+
+
 def main():
   parser = argparse.ArgumentParser(
   description='Vim integration for clang-include-fixer')
@@ -41,24 +73,36 @@
   buf = vim.current.buffer
   text = '\n'.join(buf)
 
-  # Call clang-include-fixer.
-  command = [binary, "-stdin", "-db="+args.db, "-input="+args.input,
+  # Run command to get all headers.
+  command = [binary, "-stdin", "-output-headers", "-db="+args.db, "-input="+args.input, "-debug",
  vim.current.buffer.name]
-  p = subprocess.Popen(command,
-   stdout=subprocess.PIPE, stderr=subprocess.PIPE,
-   stdin=subprocess.PIPE)
-  stdout, stderr = p.communicate(input=text)
+  stdout, stderr = execute(command, text)
+  lines = stdout.splitlines()
+  if len(lines) < 2:
+print "No header is included.\n"
+return
 
-  # If successful, replace buffer contents.
-  if stderr:
-print stderr
+  # The first line is the symbol name.
+  symbol = lines[0]
+  # If there is only one suggested header, insert it directly.
+  if len(lines) == 2 or maximum_suggested_headers == 1:
+InsertHeaderToVimBuffer(lines[1], t

Re: r269670 - [OpenCL] Add supported OpenCL extensions to target info.

2016-05-30 Thread Jeroen Ketema via cfe-commits

Hi Anastasia,

My apologies for my slow reply. My main issue was that the defaults have 
changed, which is somewhat annoying. However, digging deeper into this I’m 
noticing two serious problems:

* When I do:

#pragma OPENCL EXTENSION cl_khr_fp16 : disable

the cl_khr_fp16 macro stays defined in code I compile down to the SPIR target, 
which means I cannot do conditional compilation based on which extensions are 
enabled/disabled. This means I now need to start pulling additional manual 
tricks to do conditional compilation of half precision code.

* If I understand the patch correctly, it allows me to enable extensions for 
targets that do not support it. There does not seem a check against the 
initially enabled extensions, just a check for what is or isn’t supported in a 
particular version of OpenCL. This means I can now, e.g., enable sharing with 
Direct3D 11 for the nvptx target even though this target does not support this 
functionality.

On top of the above, I do not understand why this patch introduces code for 
extensions like ICD, which is an OpenCL API concept and not a OpenCL C concept.

Jeroen

> On 20 May 2016, at 21:01, Anastasia Stulova  wrote:
> 
> Thanks Sam!
> 
> @Jeroen, could you give us more details about your problem.
> 
> Anastasia
> 
> -Original Message-
> From: Liu, Yaxun (Sam) [mailto:yaxun@amd.com] 
> Sent: 20 May 2016 20:52
> To: Anastasia Stulova; Jeroen Ketema
> Cc: Clang Commits; nd
> Subject: RE: r269670 - [OpenCL] Add supported OpenCL extensions to target 
> info.
> 
> I think this feature can be implemented by keeping a record of enabled OpenCL 
> extensions by user's program.
> 
> For optional core feature cl_khr_fp64, we just need to detect if double type 
> is used by user's program.
> 
> Sam
> 
> -Original Message-
> From: Liu, Yaxun (Sam)
> Sent: Friday, May 20, 2016 3:45 PM
> To: 'Anastasia Stulova' ; Jeroen Ketema 
> 
> Cc: Clang Commits ; nd 
> Subject: RE: r269670 - [OpenCL] Add supported OpenCL extensions to target 
> info.
> 
> Currently Clang does not emit opencl.used.extensions metadata, so the issue 
> mentioned does not exist.
> 
> Also extensions supported by a target and extensions used by an OpenCL 
> program is different concept.
> 
> I'd say Clang currently miss a feature to detect used extensions and emit the 
> metadata.
> 
> Sam
> 
> -Original Message-
> From: Anastasia Stulova [mailto:anastasia.stul...@arm.com]
> Sent: Friday, May 20, 2016 3:23 PM
> To: Liu, Yaxun (Sam) ; Jeroen Ketema 
> 
> Cc: Clang Commits ; nd 
> Subject: Re: r269670 - [OpenCL] Add supported OpenCL extensions to target 
> info.
> 
> Hi Sam,
> 
> Has this been addressed?
> 
> @Jeroen, as far as I am aware adding supported extensions is completely new 
> to Clang and shouldn't be braking any existing functionality that are related 
> to that. Could you elaborate on the problem. Would creating new Clang target 
> help? Otherwise, do you have any other proposal for the solution?
> 
> Thanks,
> Anastasia
> 
> 
> 
> From: cfe-commits  on behalf of Jeroen 
> Ketema via cfe-commits 
> Sent: 17 May 2016 12:49
> To: Yaxun Liu via cfe-commits
> Subject: Re: r269670 - [OpenCL] Add supported OpenCL extensions to target 
> info.
> 
> Hi,
> 
> The below commit enables all OpenCL extensions for the SPIR target by 
> default. This incorrect, as SPIR allows you to specify which extensions are 
> enabled/disabled its metadata. This means that any SPIR generated by Clang 
> may now be rejected by specific OpenCL platforms, because they might not 
> support all extensions.
> 
> If possible I would like to see this commit reverted until that problem has 
> been addressed.
> 
> Regards,
> 
> Jeroen
> 
>> On 16 May 2016, at 18:06, Yaxun Liu via cfe-commits > lists.llvm.org> wrote:
>> 
>> Author: yaxunl
>> Date: Mon May 16 12:06:34 2016
>> New Revision: 269670
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=269670&view=rev
>> Log:
>> [OpenCL] Add supported OpenCL extensions to target info.
>> 
>> Add supported OpenCL extensions to target info. It serves as default values 
>> to save the users of the burden setting each supported extensions and 
>> optional core features in command line.
>> 
>> Re-commit after fixing build error due to missing override attribute.
>> 
>> Differential Revision: http://reviews.llvm.org/D19484
>> 
>> Added:
>>  cfe/trunk/include/clang/Basic/OpenCLOptions.h
>>  cfe/trunk/test/SemaOpenCL/extensions.cl
>> Removed:
>>  cfe/trunk/test/SemaOpenCL/extension-fp64-cl1.1.cl
>>  cfe/trunk/test/SemaOpenCL/extension-fp64.cl
>>  cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl1.2.cl
>>  cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl2.0.cl
>> Modified:
>>  cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
>>  cfe/trunk/include/clang/Basic/LangOptions.h
>>  cfe/trunk/include/clang/Basic/OpenCLExtensions.def
>>  cfe/trunk/include/clang/Basic/TargetInfo.h
>>  cfe/trunk/include/clang/Basic/TargetOptions.h
>>  cfe/

Re: [PATCH] D20618: [Clang][avx512][builtin] Adding missing intrinsics for cvt

2016-05-30 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271205: [Clang][avx512][builtin] Adding missing intrinsics 
for cvt (authored by mzuckerm).

Changed prior to commit:
  http://reviews.llvm.org/D20618?vs=58405&id=58953#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20618

Files:
  cfe/trunk/lib/Headers/avx512fintrin.h
  cfe/trunk/test/CodeGen/avx512f-builtins.c

Index: cfe/trunk/lib/Headers/avx512fintrin.h
===
--- cfe/trunk/lib/Headers/avx512fintrin.h
+++ cfe/trunk/lib/Headers/avx512fintrin.h
@@ -3792,6 +3792,16 @@
   _MM_FROUND_CUR_DIRECTION);
 }
 
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_maskz_cvtps_epu32 ( __mmask16 __U, __m512 __A)
+{
+  return (__m512i) __builtin_ia32_cvtps2udq512_mask ((__v16sf) __A,
+  (__v16si) 
+  _mm512_setzero_si512 (),
+  (__mmask16) __U ,
+  _MM_FROUND_CUR_DIRECTION);
+}
+
 #define _mm512_cvt_roundpd_epu32(A, R) __extension__ ({ \
   (__m256i)__builtin_ia32_cvtpd2udq512_mask((__v8df)(__m512d)(A), \
 (__v8si)_mm256_setzero_si256(), \
Index: cfe/trunk/test/CodeGen/avx512f-builtins.c
===
--- cfe/trunk/test/CodeGen/avx512f-builtins.c
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c
@@ -6411,6 +6411,12 @@
   // CHECK: @llvm.x86.avx512.mask.cvtps2udq.512
   return _mm512_mask_cvtps_epu32( __W, __U, __A);
 }
+__m512i test_mm512_maskz_cvtps_epu32 (__mmask16 __U, __m512 __A)
+{
+  // CHECK-LABEL: @test_mm512_maskz_cvtps_epu32
+  // CHECK: @llvm.x86.avx512.mask.cvtps2udq.512
+  return _mm512_maskz_cvtps_epu32( __U, __A);
+}
 
 __m512d test_mm512_mask_max_pd (__m512d __W, __mmask8 __U, __m512d __A, 
__m512d __B)
 {


Index: cfe/trunk/lib/Headers/avx512fintrin.h
===
--- cfe/trunk/lib/Headers/avx512fintrin.h
+++ cfe/trunk/lib/Headers/avx512fintrin.h
@@ -3792,6 +3792,16 @@
   _MM_FROUND_CUR_DIRECTION);
 }
 
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_maskz_cvtps_epu32 ( __mmask16 __U, __m512 __A)
+{
+  return (__m512i) __builtin_ia32_cvtps2udq512_mask ((__v16sf) __A,
+  (__v16si) 
+  _mm512_setzero_si512 (),
+  (__mmask16) __U ,
+  _MM_FROUND_CUR_DIRECTION);
+}
+
 #define _mm512_cvt_roundpd_epu32(A, R) __extension__ ({ \
   (__m256i)__builtin_ia32_cvtpd2udq512_mask((__v8df)(__m512d)(A), \
 (__v8si)_mm256_setzero_si256(), \
Index: cfe/trunk/test/CodeGen/avx512f-builtins.c
===
--- cfe/trunk/test/CodeGen/avx512f-builtins.c
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c
@@ -6411,6 +6411,12 @@
   // CHECK: @llvm.x86.avx512.mask.cvtps2udq.512
   return _mm512_mask_cvtps_epu32( __W, __U, __A);
 }
+__m512i test_mm512_maskz_cvtps_epu32 (__mmask16 __U, __m512 __A)
+{
+  // CHECK-LABEL: @test_mm512_maskz_cvtps_epu32
+  // CHECK: @llvm.x86.avx512.mask.cvtps2udq.512
+  return _mm512_maskz_cvtps_epu32( __U, __A);
+}
 
 __m512d test_mm512_mask_max_pd (__m512d __W, __mmask8 __U, __m512d __A, __m512d __B)
 {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r271205 - [Clang][avx512][builtin] Adding missing intrinsics for cvt

2016-05-30 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon May 30 08:22:12 2016
New Revision: 271205

URL: http://llvm.org/viewvc/llvm-project?rev=271205&view=rev
Log:
[Clang][avx512][builtin] Adding missing intrinsics for cvt


Differential Revision: http://reviews.llvm.org/D20618



Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=271205&r1=271204&r2=271205&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Mon May 30 08:22:12 2016
@@ -3792,6 +3792,16 @@ _mm512_mask_cvtps_epu32 (__m512i __W, __
   _MM_FROUND_CUR_DIRECTION);
 }
 
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_maskz_cvtps_epu32 ( __mmask16 __U, __m512 __A)
+{
+  return (__m512i) __builtin_ia32_cvtps2udq512_mask ((__v16sf) __A,
+  (__v16si) 
+  _mm512_setzero_si512 (),
+  (__mmask16) __U ,
+  _MM_FROUND_CUR_DIRECTION);
+}
+
 #define _mm512_cvt_roundpd_epu32(A, R) __extension__ ({ \
   (__m256i)__builtin_ia32_cvtpd2udq512_mask((__v8df)(__m512d)(A), \
 (__v8si)_mm256_setzero_si256(), \

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=271205&r1=271204&r2=271205&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Mon May 30 08:22:12 2016
@@ -6411,6 +6411,12 @@ __m512i test_mm512_mask_cvtps_epu32 (__m
   // CHECK: @llvm.x86.avx512.mask.cvtps2udq.512
   return _mm512_mask_cvtps_epu32( __W, __U, __A);
 }
+__m512i test_mm512_maskz_cvtps_epu32 (__mmask16 __U, __m512 __A)
+{
+  // CHECK-LABEL: @test_mm512_maskz_cvtps_epu32
+  // CHECK: @llvm.x86.avx512.mask.cvtps2udq.512
+  return _mm512_maskz_cvtps_epu32( __U, __A);
+}
 
 __m512d test_mm512_mask_max_pd (__m512d __W, __mmask8 __U, __m512d __A, 
__m512d __B)
 {


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


Re: [PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().

2016-05-30 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: lib/Format/Format.cpp:1551
@@ +1550,3 @@
+return Replaces;
+  tooling::Replacements HeaderInsertionReplaces;
+  tooling::Replacements NewReplaces;

djasper wrote:
> Why do you split out all the header insertion replacements here instead of 
> just ignoring the ones that aren't header insertions in 
> fixCppIncludeInsertions?
I think this enables us to exit early in `fixCppIncludeInsertions` if there is 
no header insertion replacement at all. Also, it is easier to split out header 
insertion replacements and then merge fixed replacements with other 
replacements instead of doing this in place, which IMO might not be more 
efficient since there are still set deletion and insertion for each header 
insertion replacement.


http://reviews.llvm.org/D20734



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


Re: [PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().

2016-05-30 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 58952.
ioeric marked 9 inline comments as done.
ioeric added a comment.

- Addressed reviewer's comments.


http://reviews.llvm.org/D20734

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  unittests/Format/CleanupTest.cpp

Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -281,6 +281,323 @@
   EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
 }
 
+TEST_F(CleanUpReplacementsTest, NoExistingIncludeWithoutDefine) {
+  std::string Code = "int main() {}";
+  std::string Expected = "#include \"a.h\"\n"
+ "int main() {}";
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement("fix.cpp", -1U, 0, "#include \"a.h\""));
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces));
+}
+
+TEST_F(CleanUpReplacementsTest, NoExistingIncludeWithDefine) {
+  std::string Code = "#ifndef __A_H__\n"
+ "#define __A_H__\n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+  std::string Expected = "#ifndef __A_H__\n"
+ "#define __A_H__\n"
+ "\n"
+ "#include \"b.h\"\n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement("fix.cpp", -1U, 0, "#include \"b.h\""));
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces));
+}
+
+TEST_F(CleanUpReplacementsTest, InsertBeforeCategoryWithLowerPriority) {
+  std::string Code = "#ifndef __A_H__\n"
+ "#define __A_H__\n"
+ "\n"
+ "\n"
+ "\n"
+ "#include \n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+  std::string Expected = "#ifndef __A_H__\n"
+ "#define __A_H__\n"
+ "\n"
+ "\n"
+ "\n"
+ "#include \"a.h\"\n"
+ "#include \n"
+ "class A {};\n"
+ "#define MMM 123\n"
+ "#endif";
+
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement("fix.cpp", -1U, 0, "#include \"a.h\""));
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces));
+}
+
+TEST_F(CleanUpReplacementsTest, InsertAfterMainHeader) {
+  std::string Code = "#include \"fix.h\"\n"
+ "\n"
+ "int main() {}";
+  std::string Expected = "#include \"fix.h\"\n"
+ "#include \n"
+ "\n"
+ "int main() {}";
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement("fix.cpp", -1U, 0, "#include "));
+  format::FormatStyle Style =
+  format::getGoogleStyle(format::FormatStyle::LanguageKind::LK_Cpp);
+  auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces));
+}
+
+TEST_F(CleanUpReplacementsTest, InsertBeforeSystemHeaderLLVM) {
+  std::string Code = "#include \n"
+ "\n"
+ "int main() {}";
+  std::string Expected = "#include \"z.h\"\n"
+ "#include \n"
+ "\n"
+ "int main() {}";
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement("fix.cpp", -1U, 0, "#include \"z.h\""));
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces));
+}
+
+TEST_F(CleanUpReplacementsTest, InsertAfterSystemHeaderGoogle) {
+  std::string Code = "#include \n"
+ "\n"
+ "int main() {}";
+  std::string Expected = "#include \n"
+ "#include \"z.h\"\n"
+ "\n"
+ "int main() {}";
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements 

r271204 - [OPENMP 4.5] Additional codegen for statically scheduled loops with

2016-05-30 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon May 30 08:05:14 2016
New Revision: 271204

URL: http://llvm.org/viewvc/llvm-project?rev=271204&view=rev
Log:
[OPENMP 4.5] Additional codegen for statically scheduled loops with
'simd' modifier.

Runtime library defines new schedule constant kmp_sch_static_balanced_chunked = 
45 for static loop-based directives  static with chunk adjustment (e.g., simd). 
Added codegen for this kind of schedule.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/for_simd_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=271204&r1=271203&r2=271204&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Mon May 30 08:05:14 2016
@@ -488,6 +488,8 @@ enum OpenMPSchedType {
   OMP_sch_guided_chunked = 36,
   OMP_sch_runtime = 37,
   OMP_sch_auto = 38,
+  /// static with chunk adjustment (e.g., simd)
+  OMP_sch_static_balanced_chunked   = 45,
   /// \brief Lower bound for 'ordered' versions.
   OMP_ord_lower = 64,
   OMP_ord_static_chunked = 65,
@@ -2409,27 +2411,38 @@ bool CGOpenMPRuntime::isDynamic(OpenMPSc
 static int addMonoNonMonoModifier(OpenMPSchedType Schedule,
   OpenMPScheduleClauseModifier M1,
   OpenMPScheduleClauseModifier M2) {
+  int Modifier = 0;
   switch (M1) {
   case OMPC_SCHEDULE_MODIFIER_monotonic:
-return Schedule | OMP_sch_modifier_monotonic;
+Modifier = OMP_sch_modifier_monotonic;
+break;
   case OMPC_SCHEDULE_MODIFIER_nonmonotonic:
-return Schedule | OMP_sch_modifier_nonmonotonic;
+Modifier = OMP_sch_modifier_nonmonotonic;
+break;
   case OMPC_SCHEDULE_MODIFIER_simd:
+if (Schedule == OMP_sch_static_chunked)
+  Schedule = OMP_sch_static_balanced_chunked;
+break;
   case OMPC_SCHEDULE_MODIFIER_last:
   case OMPC_SCHEDULE_MODIFIER_unknown:
 break;
   }
   switch (M2) {
   case OMPC_SCHEDULE_MODIFIER_monotonic:
-return Schedule | OMP_sch_modifier_monotonic;
+Modifier = OMP_sch_modifier_monotonic;
+break;
   case OMPC_SCHEDULE_MODIFIER_nonmonotonic:
-return Schedule | OMP_sch_modifier_nonmonotonic;
+Modifier = OMP_sch_modifier_nonmonotonic;
+break;
   case OMPC_SCHEDULE_MODIFIER_simd:
+if (Schedule == OMP_sch_static_chunked)
+  Schedule = OMP_sch_static_balanced_chunked;
+break;
   case OMPC_SCHEDULE_MODIFIER_last:
   case OMPC_SCHEDULE_MODIFIER_unknown:
 break;
   }
-  return Schedule;
+  return Schedule | Modifier;
 }
 
 void CGOpenMPRuntime::emitForDispatchInit(CodeGenFunction &CGF,
@@ -2444,7 +2457,8 @@ void CGOpenMPRuntime::emitForDispatchIni
   getRuntimeSchedule(ScheduleKind.Schedule, Chunk != nullptr, Ordered);
   assert(Ordered ||
  (Schedule != OMP_sch_static && Schedule != OMP_sch_static_chunked &&
-  Schedule != OMP_ord_static && Schedule != OMP_ord_static_chunked));
+  Schedule != OMP_ord_static && Schedule != OMP_ord_static_chunked &&
+  Schedule != OMP_sch_static_balanced_chunked));
   // Call __kmpc_dispatch_init(
   //  ident_t *loc, kmp_int32 tid, kmp_int32 schedule,
   //  kmp_int[32|64] lower, kmp_int[32|64] upper,
@@ -2476,6 +2490,7 @@ static void emitForStaticInitCall(
 
assert(!Ordered);
assert(Schedule == OMP_sch_static || Schedule == OMP_sch_static_chunked ||
+  Schedule == OMP_sch_static_balanced_chunked ||
   Schedule == OMP_ord_static || Schedule == OMP_ord_static_chunked ||
   Schedule == OMP_dist_sch_static ||
   Schedule == OMP_dist_sch_static_chunked);
@@ -2493,6 +2508,7 @@ static void emitForStaticInitCall(
Chunk = CGF.Builder.getIntN(IVSize, 1);
} else {
  assert((Schedule == OMP_sch_static_chunked ||
+ Schedule == OMP_sch_static_balanced_chunked ||
  Schedule == OMP_ord_static_chunked ||
  Schedule == OMP_dist_sch_static_chunked) &&
 "expected static chunked schedule");

Modified: cfe/trunk/test/OpenMP/for_simd_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_simd_codegen.cpp?rev=271204&r1=271203&r2=271204&view=diff
==
--- cfe/trunk/test/OpenMP/for_simd_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/for_simd_codegen.cpp Mon May 30 08:05:14 2016
@@ -362,7 +362,7 @@ template  T tfoo(T
 
 template 
 int templ1(T a, T *z) {
-  #pragma omp for simd collapse(N)
+  #pragma omp for simd collapse(N) schedule(simd: static, N)
   for (int i = 0; i < N * 2; i++) {
 for (long long j = 0; j < (N + N + N + N); j += 2) {
   z[i + j] = a + tfoo(i + j);
@@ -373,7 +373,7 @@ int templ1(T a, T *z) {
 
 // Instatiation templ1
 // CHECK-LABEL: define {{.*i32}} @{{.*}}templ1{{.*}}(float {{.+}}, floa

  1   2   >