[PATCH] D47201: [CUDA] Implement nv_weak attribute for functions

2018-05-31 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

Ping


Repository:
  rC Clang

https://reviews.llvm.org/D47201



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


[PATCH] D47394: [OpenMP][Clang][NVPTX] Replace bundling with partial linking for the OpenMP NVPTX device offloading toolchain

2018-05-31 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

In https://reviews.llvm.org/D47394#1118393, @gtbercea wrote:

> The error is related to lack of device linking, just like you explained two 
> paragraphs down. This is the error I get:
>
>   main.o: In function `__cuda_module_ctor':
>   main.cu:(.text+0x674): undefined reference to 
> `__cudaRegisterLinkedBinary__nv_c5b75865'
>


That's because I didn't implement linking for relocatable device code in CUDA, 
you have to use `nvcc` for that. Please see 
https://clang.llvm.org/docs/ReleaseNotes.html#cuda-support-in-clang and the 
original patch https://reviews.llvm.org/D42922.

> The **OpenMP NVPTX device offloading toolchain** has the advantage that it 
> already calls NVLINK (upstreamed a long time ago). This patch doesn't change 
> that. This patch "fixes" (for a lack of a better word) the way in which 
> objects are created on the device side. By adding the FATBINARY + CLANG++ 
> steps, I ensure that the existing call to NVLINK will be able to "detect" the 
> device-part of object files and archived object files (static libraries). 
> This is not a valid statement in today's compiler in which NVLINK would not 
> be able to do so when passed a static library.
> 
> In general, for offloading toolchains, I don't see the reliance on vendor 
> specific tools as a problem **if and only if** the calls to vendor-specific 
> tools remain confined to a device-speicifc toolchain. This patch respects 
> this condition. All the calls to CUDA tools in this patch are part of the 
> OpenMP NVPTX device offloading toolchain (which is an NVPTX device specific 
> toolchain).

I disagree in this context because this patch currently means that static 
archives will only work with NVPTX and there is no clear path how to "fix" 
things for other offloading targets. I'll try to work on my proposal over the 
next few days (sorry, very busy week...), maybe I can put together a prototype 
of my idea.


Repository:
  rC Clang

https://reviews.llvm.org/D47394



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


[PATCH] D47557: Filesystem tests: un-confuse write time

2018-05-31 Thread JF Bastien via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333723: Filesystem tests: un-confuse write time (authored by 
jfb, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D47557

Files:
  
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp


Index: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
===
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
@@ -32,7 +32,9 @@
 
 using namespace fs;
 
-std::pair GetTimes(path const& p) {
+struct Times { std::time_t access, write; };
+
+Times GetTimes(path const& p) {
 using Clock = file_time_type::clock;
 struct ::stat st;
 if (::stat(p.c_str(), ) == -1) {
@@ -48,11 +50,11 @@
 }
 
 std::time_t LastAccessTime(path const& p) {
-return GetTimes(p).first;
+return GetTimes(p).access;
 }
 
 std::time_t LastWriteTime(path const& p) {
-return GetTimes(p).second;
+return GetTimes(p).write;
 }
 
 std::pair GetSymlinkTimes(path const& p) {
@@ -228,11 +230,9 @@
 const path dir = env.create_dir("dir");
 
 const auto file_times = GetTimes(file);
-const std::time_t file_access_time = file_times.first;
-const std::time_t file_write_time = file_times.second;
+const std::time_t file_write_time = file_times.write;
 const auto dir_times = GetTimes(dir);
-const std::time_t dir_access_time = dir_times.first;
-const std::time_t dir_write_time = dir_times.second;
+const std::time_t dir_write_time = dir_times.write;
 
 file_time_type ftime = last_write_time(file);
 TEST_CHECK(Clock::to_time_t(ftime) == file_write_time);
@@ -253,9 +253,8 @@
 
 TEST_CHECK(ftime2 > ftime);
 TEST_CHECK(dtime2 > dtime);
-TEST_CHECK(LastAccessTime(file) == file_access_time ||
-   LastAccessTime(file) == Clock::to_time_t(ftime2));
-TEST_CHECK(LastAccessTime(dir) == dir_access_time);
+TEST_CHECK(LastWriteTime(file) == Clock::to_time_t(ftime2));
+TEST_CHECK(LastWriteTime(dir) == Clock::to_time_t(dtime2));
 }
 
 
@@ -301,7 +300,7 @@
 };
 for (const auto& TC : cases) {
 const auto old_times = GetTimes(TC.p);
-file_time_type old_time(Sec(old_times.second));
+file_time_type old_time(Sec(old_times.write));
 
 std::error_code ec = GetTestEC();
 last_write_time(TC.p, TC.new_time, ec);
@@ -318,7 +317,7 @@
 TEST_CHECK(got_time <= TC.new_time + Sec(1));
 TEST_CHECK(got_time >= TC.new_time - Sec(1));
 }
-TEST_CHECK(LastAccessTime(TC.p) == old_times.first);
+TEST_CHECK(LastAccessTime(TC.p) == old_times.access);
 }
 }
 }
@@ -348,10 +347,10 @@
 file_time_type  got_time = last_write_time(sym);
 std::time_t got_time_t = Clock::to_time_t(got_time);
 
-TEST_CHECK(got_time_t != old_times.second);
+TEST_CHECK(got_time_t != old_times.write);
 TEST_CHECK(got_time_t == new_time_t);
 TEST_CHECK(LastWriteTime(file) == new_time_t);
-TEST_CHECK(LastAccessTime(sym) == old_times.first);
+TEST_CHECK(LastAccessTime(sym) == old_times.access);
 TEST_CHECK(GetSymlinkTimes(sym) == old_sym_times);
 }
 


Index: libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
===
--- libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
+++ libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
@@ -32,7 +32,9 @@
 
 using namespace fs;
 
-std::pair GetTimes(path const& p) {
+struct Times { std::time_t access, write; };
+
+Times GetTimes(path const& p) {
 using Clock = file_time_type::clock;
 struct ::stat st;
 if (::stat(p.c_str(), ) == -1) {
@@ -48,11 +50,11 @@
 }
 
 std::time_t LastAccessTime(path const& p) {
-return GetTimes(p).first;
+return GetTimes(p).access;
 }
 
 std::time_t LastWriteTime(path const& p) {
-return GetTimes(p).second;
+return GetTimes(p).write;
 }
 
 std::pair GetSymlinkTimes(path const& p) {
@@ -228,11 +230,9 @@
 const path dir = env.create_dir("dir");
 
 const auto file_times = GetTimes(file);
-const std::time_t file_access_time = file_times.first;
-const std::time_t file_write_time = file_times.second;
+const std::time_t file_write_time = file_times.write;
 const auto dir_times = GetTimes(dir);
-const std::time_t dir_access_time = dir_times.first;
-const std::time_t dir_write_time = dir_times.second;
+const std::time_t dir_write_time = dir_times.write;
 
 

[libcxx] r333723 - Filesystem tests: un-confuse write time

2018-05-31 Thread JF Bastien via cfe-commits
Author: jfb
Date: Thu May 31 21:59:48 2018
New Revision: 333723

URL: http://llvm.org/viewvc/llvm-project?rev=333723=rev
Log:
Filesystem tests: un-confuse write time

Summary:
The filesystem test was confused about access versus write / modification time. 
The spec says:

  file_time_type last_write_time(const path& p, error_code& ec) noexcept;
  Returns: The time of last data modification of p, determined as if by the 
value of the POSIX stat structure member st_mtime obtained as if by POSIX 
stat(). The signature with argument ec returns file_time_type::min() if an 
error occurs.

The test was looking at st_atime, not st_mtime, when comparing the result from 
last_write_time. That was probably due to using a pair instead of naming things 
nicely or using types. I opted to rename things so it's clearer.

This used to cause test bot failures.



Reviewers: EricWF, mclow.lists, aemerson

Subscribers: christof, cfe-commits

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

Modified:

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp?rev=333723=333722=333723=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
 Thu May 31 21:59:48 2018
@@ -32,7 +32,9 @@
 
 using namespace fs;
 
-std::pair GetTimes(path const& p) {
+struct Times { std::time_t access, write; };
+
+Times GetTimes(path const& p) {
 using Clock = file_time_type::clock;
 struct ::stat st;
 if (::stat(p.c_str(), ) == -1) {
@@ -48,11 +50,11 @@ std::pair GetT
 }
 
 std::time_t LastAccessTime(path const& p) {
-return GetTimes(p).first;
+return GetTimes(p).access;
 }
 
 std::time_t LastWriteTime(path const& p) {
-return GetTimes(p).second;
+return GetTimes(p).write;
 }
 
 std::pair GetSymlinkTimes(path const& p) {
@@ -228,11 +230,9 @@ TEST_CASE(get_last_write_time_dynamic_en
 const path dir = env.create_dir("dir");
 
 const auto file_times = GetTimes(file);
-const std::time_t file_access_time = file_times.first;
-const std::time_t file_write_time = file_times.second;
+const std::time_t file_write_time = file_times.write;
 const auto dir_times = GetTimes(dir);
-const std::time_t dir_access_time = dir_times.first;
-const std::time_t dir_write_time = dir_times.second;
+const std::time_t dir_write_time = dir_times.write;
 
 file_time_type ftime = last_write_time(file);
 TEST_CHECK(Clock::to_time_t(ftime) == file_write_time);
@@ -253,9 +253,8 @@ TEST_CASE(get_last_write_time_dynamic_en
 
 TEST_CHECK(ftime2 > ftime);
 TEST_CHECK(dtime2 > dtime);
-TEST_CHECK(LastAccessTime(file) == file_access_time ||
-   LastAccessTime(file) == Clock::to_time_t(ftime2));
-TEST_CHECK(LastAccessTime(dir) == dir_access_time);
+TEST_CHECK(LastWriteTime(file) == Clock::to_time_t(ftime2));
+TEST_CHECK(LastWriteTime(dir) == Clock::to_time_t(dtime2));
 }
 
 
@@ -301,7 +300,7 @@ TEST_CASE(set_last_write_time_dynamic_en
 };
 for (const auto& TC : cases) {
 const auto old_times = GetTimes(TC.p);
-file_time_type old_time(Sec(old_times.second));
+file_time_type old_time(Sec(old_times.write));
 
 std::error_code ec = GetTestEC();
 last_write_time(TC.p, TC.new_time, ec);
@@ -318,7 +317,7 @@ TEST_CASE(set_last_write_time_dynamic_en
 TEST_CHECK(got_time <= TC.new_time + Sec(1));
 TEST_CHECK(got_time >= TC.new_time - Sec(1));
 }
-TEST_CHECK(LastAccessTime(TC.p) == old_times.first);
+TEST_CHECK(LastAccessTime(TC.p) == old_times.access);
 }
 }
 }
@@ -348,10 +347,10 @@ TEST_CASE(last_write_time_symlink_test)
 file_time_type  got_time = last_write_time(sym);
 std::time_t got_time_t = Clock::to_time_t(got_time);
 
-TEST_CHECK(got_time_t != old_times.second);
+TEST_CHECK(got_time_t != old_times.write);
 TEST_CHECK(got_time_t == new_time_t);
 TEST_CHECK(LastWriteTime(file) == new_time_t);
-TEST_CHECK(LastAccessTime(sym) == old_times.first);
+TEST_CHECK(LastAccessTime(sym) == old_times.access);
 TEST_CHECK(GetSymlinkTimes(sym) == old_sym_times);
 }
 


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


[PATCH] D47557: Filesystem tests: un-confuse write time

2018-05-31 Thread JF Bastien via Phabricator via cfe-commits
jfb updated this revision to Diff 149398.
jfb added a comment.

- Add back directory test


Repository:
  rCXX libc++

https://reviews.llvm.org/D47557

Files:
  
test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp


Index: 
test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
===
--- 
test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
+++ 
test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
@@ -32,7 +32,9 @@
 
 using namespace fs;
 
-std::pair GetTimes(path const& p) {
+struct Times { std::time_t access, write; };
+
+Times GetTimes(path const& p) {
 using Clock = file_time_type::clock;
 struct ::stat st;
 if (::stat(p.c_str(), ) == -1) {
@@ -48,11 +50,11 @@
 }
 
 std::time_t LastAccessTime(path const& p) {
-return GetTimes(p).first;
+return GetTimes(p).access;
 }
 
 std::time_t LastWriteTime(path const& p) {
-return GetTimes(p).second;
+return GetTimes(p).write;
 }
 
 std::pair GetSymlinkTimes(path const& p) {
@@ -228,11 +230,9 @@
 const path dir = env.create_dir("dir");
 
 const auto file_times = GetTimes(file);
-const std::time_t file_access_time = file_times.first;
-const std::time_t file_write_time = file_times.second;
+const std::time_t file_write_time = file_times.write;
 const auto dir_times = GetTimes(dir);
-const std::time_t dir_access_time = dir_times.first;
-const std::time_t dir_write_time = dir_times.second;
+const std::time_t dir_write_time = dir_times.write;
 
 file_time_type ftime = last_write_time(file);
 TEST_CHECK(Clock::to_time_t(ftime) == file_write_time);
@@ -253,9 +253,8 @@
 
 TEST_CHECK(ftime2 > ftime);
 TEST_CHECK(dtime2 > dtime);
-TEST_CHECK(LastAccessTime(file) == file_access_time ||
-   LastAccessTime(file) == Clock::to_time_t(ftime2));
-TEST_CHECK(LastAccessTime(dir) == dir_access_time);
+TEST_CHECK(LastWriteTime(file) == Clock::to_time_t(ftime2));
+TEST_CHECK(LastWriteTime(dir) == Clock::to_time_t(dtime2));
 }
 
 
@@ -301,7 +300,7 @@
 };
 for (const auto& TC : cases) {
 const auto old_times = GetTimes(TC.p);
-file_time_type old_time(Sec(old_times.second));
+file_time_type old_time(Sec(old_times.write));
 
 std::error_code ec = GetTestEC();
 last_write_time(TC.p, TC.new_time, ec);
@@ -318,7 +317,7 @@
 TEST_CHECK(got_time <= TC.new_time + Sec(1));
 TEST_CHECK(got_time >= TC.new_time - Sec(1));
 }
-TEST_CHECK(LastAccessTime(TC.p) == old_times.first);
+TEST_CHECK(LastAccessTime(TC.p) == old_times.access);
 }
 }
 }
@@ -348,10 +347,10 @@
 file_time_type  got_time = last_write_time(sym);
 std::time_t got_time_t = Clock::to_time_t(got_time);
 
-TEST_CHECK(got_time_t != old_times.second);
+TEST_CHECK(got_time_t != old_times.write);
 TEST_CHECK(got_time_t == new_time_t);
 TEST_CHECK(LastWriteTime(file) == new_time_t);
-TEST_CHECK(LastAccessTime(sym) == old_times.first);
+TEST_CHECK(LastAccessTime(sym) == old_times.access);
 TEST_CHECK(GetSymlinkTimes(sym) == old_sym_times);
 }
 


Index: test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
===
--- test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
+++ test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
@@ -32,7 +32,9 @@
 
 using namespace fs;
 
-std::pair GetTimes(path const& p) {
+struct Times { std::time_t access, write; };
+
+Times GetTimes(path const& p) {
 using Clock = file_time_type::clock;
 struct ::stat st;
 if (::stat(p.c_str(), ) == -1) {
@@ -48,11 +50,11 @@
 }
 
 std::time_t LastAccessTime(path const& p) {
-return GetTimes(p).first;
+return GetTimes(p).access;
 }
 
 std::time_t LastWriteTime(path const& p) {
-return GetTimes(p).second;
+return GetTimes(p).write;
 }
 
 std::pair GetSymlinkTimes(path const& p) {
@@ -228,11 +230,9 @@
 const path dir = env.create_dir("dir");
 
 const auto file_times = GetTimes(file);
-const std::time_t file_access_time = file_times.first;
-const std::time_t file_write_time = file_times.second;
+const std::time_t file_write_time = file_times.write;
 const auto dir_times = GetTimes(dir);
-const std::time_t dir_access_time = dir_times.first;
-const std::time_t dir_write_time = dir_times.second;
+const std::time_t dir_write_time = dir_times.write;
 
 file_time_type ftime = last_write_time(file);
 TEST_CHECK(Clock::to_time_t(ftime) == file_write_time);
@@ -253,9 +253,8 @@
 
 TEST_CHECK(ftime2 > ftime);
 TEST_CHECK(dtime2 > dtime);
-

[PATCH] D47618: __c11_atomic_load's _Atomic can be const

2018-05-31 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

Note that I don't touch the OpenCL __constant stuff, because the separate 
address space means this can be actually read-only, which means you can't 
cmpxchg for very wide reads.


Repository:
  rC Clang

https://reviews.llvm.org/D47618



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


[PATCH] D47618: __c11_atomic_load's _Atomic can be const

2018-05-31 Thread JF Bastien via Phabricator via cfe-commits
jfb created this revision.
jfb added a reviewer: rsmith.
Herald added a subscriber: cfe-commits.

C++11 onwards specs the non-member functions atomic_load and 
atomic_load_explicit as taking the atomic by const (potentially volatile) 
pointer. C11, in its infinite wisdom, decided to drop the const, and C17 will 
fix this with DR459 (the current draft forgot to fix B.16, but that’s not the 
normative part).

clang’s lib/Headers/stdatomic.h implements these as #define to the __c11_* 
equivalent, which are builtins with custom typecheck. Fix the typecheck.

https://reviews.llvm.org/D47613 takes care of the libc++ side.

Discussion: http://lists.llvm.org/pipermail/cfe-dev/2018-May/058129.html

rdar://problem/27426936


Repository:
  rC Clang

https://reviews.llvm.org/D47618

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/atomic-ops.c
  test/SemaOpenCL/atomic-ops.cl


Index: test/SemaOpenCL/atomic-ops.cl
===
--- test/SemaOpenCL/atomic-ops.cl
+++ test/SemaOpenCL/atomic-ops.cl
@@ -58,7 +58,7 @@
   __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(p, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(d, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_load(ci, memory_order_seq_cst, memory_scope_work_group); // 
expected-error {{address argument to atomic operation must be a pointer to 
non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic 
_Atomic(int) *') invalid)}}
+  __opencl_atomic_load(ci, memory_order_seq_cst, memory_scope_work_group);
 
   __opencl_atomic_store(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_store(p, 1, memory_order_seq_cst, memory_scope_work_group);
@@ -94,7 +94,7 @@
 
   __opencl_atomic_init(ci, 0); // expected-error {{address argument to atomic 
operation must be a pointer to non-const _Atomic type ('const __generic 
atomic_int *' (aka 'const __generic _Atomic(int) *') invalid)}}
   __opencl_atomic_store(ci, 0, memory_order_release, memory_scope_work_group); 
// expected-error {{address argument to atomic operation must be a pointer to 
non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic 
_Atomic(int) *') invalid)}}
-  __opencl_atomic_load(ci, memory_order_acquire, memory_scope_work_group); // 
expected-error {{address argument to atomic operation must be a pointer to 
non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic 
_Atomic(int) *') invalid)}}
+  __opencl_atomic_load(ci, memory_order_acquire, memory_scope_work_group);
 
   __opencl_atomic_init(, 456);
   __opencl_atomic_init(, (void*)0); // expected-warning{{incompatible 
pointer to integer conversion passing '__generic void *' to parameter of type 
'int'}}
Index: test/Sema/atomic-ops.c
===
--- test/Sema/atomic-ops.c
+++ test/Sema/atomic-ops.c
@@ -115,7 +115,7 @@
   __c11_atomic_load(i, memory_order_seq_cst);
   __c11_atomic_load(p, memory_order_seq_cst);
   __c11_atomic_load(d, memory_order_seq_cst);
-  __c11_atomic_load(ci, memory_order_seq_cst); // expected-error {{address 
argument to atomic operation must be a pointer to non-const _Atomic type 
('const _Atomic(int) *' invalid)}}
+  __c11_atomic_load(ci, memory_order_seq_cst);
 
   int load_n_1 = __atomic_load_n(I, memory_order_relaxed);
   int *load_n_2 = __atomic_load_n(P, memory_order_relaxed);
@@ -222,7 +222,7 @@
 
   __c11_atomic_init(ci, 0); // expected-error {{address argument to atomic 
operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' 
invalid)}}
   __c11_atomic_store(ci, 0, memory_order_release); // expected-error {{address 
argument to atomic operation must be a pointer to non-const _Atomic type 
('const _Atomic(int) *' invalid)}}
-  __c11_atomic_load(ci, memory_order_acquire); // expected-error {{address 
argument to atomic operation must be a pointer to non-const _Atomic type 
('const _Atomic(int) *' invalid)}}
+  __c11_atomic_load(ci, memory_order_acquire);
 
   // Ensure the  macros behave appropriately.
   atomic_int n = ATOMIC_VAR_INIT(123);
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -3357,7 +3357,7 @@
 << Ptr->getType() << Ptr->getSourceRange();
   return ExprError();
 }
-if (AtomTy.isConstQualified() ||
+if ((Form != Load && Form != LoadCopy && AtomTy.isConstQualified()) ||
 AtomTy.getAddressSpace() == LangAS::opencl_constant) {
   Diag(DRE->getLocStart(), diag::err_atomic_op_needs_non_const_atomic)
   << (AtomTy.isConstQualified() ? 0 : 1) << Ptr->getType()


Index: test/SemaOpenCL/atomic-ops.cl
===
--- test/SemaOpenCL/atomic-ops.cl
+++ test/SemaOpenCL/atomic-ops.cl
@@ -58,7 +58,7 @@
   

[PATCH] D47617: [Analyzer] Fix Z3 crash (PR37646)

2018-05-31 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich created this revision.
vlad.tsyrklevich added reviewers: george.karpenkov, NoQ, ddcc.
Herald added subscribers: cfe-commits, a.sidorin, szepet, xazax.hun.

Fix another Z3ConstraintManager crash, use fixAPSInt() to extend a
boolean APSInt.


Repository:
  rC Clang

https://reviews.llvm.org/D47617

Files:
  lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
  test/Analysis/pr37646.c


Index: test/Analysis/pr37646.c
===
--- /dev/null
+++ test/Analysis/pr37646.c
@@ -0,0 +1,11 @@
+// REQUIRES: z3
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core 
-analyzer-store=region -analyzer-constraints=z3 -verify %s
+// expected-no-diagnostics
+
+_Bool b;
+void c() {
+  _Bool a = b | 0;
+  for (;;)
+if (a)
+  ;
+}
Index: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -1211,8 +1211,10 @@
 if (!LHS || !RHS)
   return nullptr;
 
-llvm::APSInt ConvertedLHS = *LHS, ConvertedRHS = *RHS;
-QualType LTy = getAPSIntType(*LHS), RTy = getAPSIntType(*RHS);
+llvm::APSInt ConvertedLHS, ConvertedRHS;
+QualType LTy, RTy;
+std::tie(ConvertedLHS, LTy) = fixAPSInt(*LHS);
+std::tie(ConvertedRHS, RTy) = fixAPSInt(*RHS);
 doIntTypeConversion(
 ConvertedLHS, LTy, ConvertedRHS, RTy);
 return BV.evalAPSInt(BSE->getOpcode(), ConvertedLHS, ConvertedRHS);


Index: test/Analysis/pr37646.c
===
--- /dev/null
+++ test/Analysis/pr37646.c
@@ -0,0 +1,11 @@
+// REQUIRES: z3
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core -analyzer-store=region -analyzer-constraints=z3 -verify %s
+// expected-no-diagnostics
+
+_Bool b;
+void c() {
+  _Bool a = b | 0;
+  for (;;)
+if (a)
+  ;
+}
Index: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -1211,8 +1211,10 @@
 if (!LHS || !RHS)
   return nullptr;
 
-llvm::APSInt ConvertedLHS = *LHS, ConvertedRHS = *RHS;
-QualType LTy = getAPSIntType(*LHS), RTy = getAPSIntType(*RHS);
+llvm::APSInt ConvertedLHS, ConvertedRHS;
+QualType LTy, RTy;
+std::tie(ConvertedLHS, LTy) = fixAPSInt(*LHS);
+std::tie(ConvertedRHS, RTy) = fixAPSInt(*RHS);
 doIntTypeConversion(
 ConvertedLHS, LTy, ConvertedRHS, RTy);
 return BV.evalAPSInt(BSE->getOpcode(), ConvertedLHS, ConvertedRHS);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47586: Update NRVO logic to support early return (Attempt 2)

2018-05-31 Thread Taiju Tsuiki via Phabricator via cfe-commits
tzik added a reviewer: rsmith.
tzik added a comment.

rsmith: PTAL. This is the previous attempt  
plus a fix and a test.
The diff is SemaTemplateInstantiateDecl.cpp part that propagate disabled NRVO 
state to the instantiated local variable.
On the previous attempt, I left the local variable NRVO candidate on the 
template instnantiation, and following `computeNRVO` for the instantiated 
function template unexpectedly turned on NRVO for the candidate.


Repository:
  rC Clang

https://reviews.llvm.org/D47586



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


[PATCH] D46024: [clang-format] Add SpaceBeforeCpp11BracedList option.

2018-05-31 Thread Ross Kirsling via Phabricator via cfe-commits
rkirsling updated this revision to Diff 149395.
rkirsling added a comment.

Resolved another rebase conflict to keep this patch mergeable.


Repository:
  rC Clang

https://reviews.llvm.org/D46024

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -6977,6 +6977,67 @@
"  { \"c\", 2 }\n"
"};",
ExtraSpaces);
+
+  FormatStyle SpaceBeforeBrace = getLLVMStyle();
+  SpaceBeforeBrace.SpaceBeforeCpp11BracedList = true;
+  verifyFormat("vector x {1, 2, 3, 4};", SpaceBeforeBrace);
+  verifyFormat("vector x {\n"
+   "1,\n"
+   "2,\n"
+   "3,\n"
+   "4,\n"
+   "};",
+   SpaceBeforeBrace);
+  verifyFormat("vector x {{}, {}, {}, {}};", SpaceBeforeBrace);
+  verifyFormat("f({1, 2});", SpaceBeforeBrace);
+  verifyFormat("auto v = Foo {-1};", SpaceBeforeBrace);
+  verifyFormat("f({1, 2}, {{2, 3}, {4, 5}}, c, {d});", SpaceBeforeBrace);
+  verifyFormat("Class::Class : member {1, 2, 3} {}", SpaceBeforeBrace);
+  verifyFormat("new vector {1, 2, 3};", SpaceBeforeBrace);
+  verifyFormat("new int[3] {1, 2, 3};", SpaceBeforeBrace);
+  verifyFormat("new int {1};", SpaceBeforeBrace);
+  verifyFormat("return {arg1, arg2};", SpaceBeforeBrace);
+  verifyFormat("return {arg1, SomeType {parameter}};", SpaceBeforeBrace);
+  verifyFormat("int count = set {f(), g(), h()}.size();",
+   SpaceBeforeBrace);
+  verifyFormat("new T {arg1, arg2};", SpaceBeforeBrace);
+  verifyFormat("f(MyMap[{composite, key}]);", SpaceBeforeBrace);
+  verifyFormat("class Class {\n"
+   "  T member = {arg1, arg2};\n"
+   "};",
+   SpaceBeforeBrace);
+  verifyFormat("vector foo = {::SomeGlobalFunction()};",
+   SpaceBeforeBrace);
+  verifyFormat("const struct A a = {.a = 1, .b = 2};", SpaceBeforeBrace);
+  verifyFormat("const struct A a = {[0] = 1, [1] = 2};", SpaceBeforeBrace);
+  verifyFormat("static_assert(std::is_integral {} + 0, \"\");",
+   SpaceBeforeBrace);
+  verifyFormat("int a = std::is_integral {} + 0;", SpaceBeforeBrace);
+  verifyFormat("int foo(int i) { return fo1 {}(i); }", SpaceBeforeBrace);
+  verifyFormat("int foo(int i) { return fo1 {}(i); }", SpaceBeforeBrace);
+  verifyFormat("auto i = decltype(x) {};", SpaceBeforeBrace);
+  verifyFormat("std::vector v = {1, 0 /* comment */};",
+   SpaceBeforeBrace);
+  verifyFormat("Node n {1, Node {1000}, //\n"
+   "2};",
+   SpaceBeforeBrace);
+  verifyFormat("Aaaa aaa {\n"
+   "{\n"
+   ",\n"
+   "},\n"
+   "};",
+   SpaceBeforeBrace);
+  verifyFormat("class C : public D {\n"
+   "  SomeClass SC {2};\n"
+   "};",
+   SpaceBeforeBrace);
+  verifyFormat("class C : public A {\n"
+   "  class D : public B {\n"
+   "void f() { int i {2}; }\n"
+   "  };\n"
+   "};",
+   SpaceBeforeBrace);
+  verifyFormat("#define A {a, a},", SpaceBeforeBrace);
 }
 
 TEST_F(FormatTest, FormatsBracedListsInColumnLayout) {
@@ -10558,6 +10619,7 @@
   CHECK_PARSE_BOOL(SpaceAfterCStyleCast);
   CHECK_PARSE_BOOL(SpaceAfterTemplateKeyword);
   CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators);
+  CHECK_PARSE_BOOL(SpaceBeforeCpp11BracedList);
   CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon);
   CHECK_PARSE_BOOL(SpaceBeforeInheritanceColon);
   CHECK_PARSE_BOOL(SpaceBeforeRangeBasedForLoopColon);
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2548,6 +2548,9 @@
   if (Style.isCpp()) {
 if (Left.is(tok::kw_operator))
   return Right.is(tok::coloncolon);
+if (Right.is(tok::l_brace) && Right.BlockKind == BK_BracedInit &&
+!Left.opensScope() && Style.SpaceBeforeCpp11BracedList)
+  return true;
   } else if (Style.Language == FormatStyle::LK_Proto ||
  Style.Language == FormatStyle::LK_TextProto) {
 if (Right.is(tok::period) &&
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -428,6 +428,8 @@
Style.SpaceAfterTemplateKeyword);
 IO.mapOptional("SpaceBeforeAssignmentOperators",
Style.SpaceBeforeAssignmentOperators);
+IO.mapOptional("SpaceBeforeCpp11BracedList",
+   Style.SpaceBeforeCpp11BracedList);
 IO.mapOptional("SpaceBeforeCtorInitializerColon",

[PATCH] D47578: Do not enforce absolute path argv0 in windows

2018-05-31 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta marked an inline comment as done.
takuto.ikuta added a comment.

In https://reviews.llvm.org/D47578#1117874, @rnk wrote:

> I think this would be easy to unit test in 
> llvm/unittests/Support/CommandLine.cpp. We'd just check that the filename is 
> "SupportTests.exe" on Windows and the path is relative after calling this, I 
> guess. Right? Look at how ProgramTest.cpp does this to get a reasonable argv0:
>
>   sys::fs::getMainExecutable(TestMainArgv0, );
>   


Added test.

> 
> 
> In https://reviews.llvm.org/D47578#1117790, @takuto.ikuta wrote:
> 
>> In https://reviews.llvm.org/D47578#1117760, @amccarth wrote:
>>
>> > I was under the impression that some tools rely on the fact that arg[0] is 
>> > always expanded to an absolute path.  Does this work with lldb and its 
>> > test suite?
>>
>>
>> I tried, but there is no check-lldb target. Can I ask you what is the target 
>> name to run lldb test suite?
> 
> 
> The LLDB test suite isn't in very good shape on Windows. It is complicated to 
> set up and build, I don't want to block this fix on @takuto.ikuta setting up 
> that build environment. This is a Windows-only change, and I believe it makes 
> it more consistent with Linux, so as long as check-llvm, check-clang, and 
> check-lld pass, this should be relatively safe.

I confirmed that this patch passed check-llvm, check-clang and check-lld.

I tried to test lldb, but failed to build. lldb looks cannot be built with MSVC 
2017 15.7.2

  FAILED: tools/lldb/tools/lldb-mi/CMakeFiles/lldb-mi.dir/MIDriverMain.cpp.obj
  c:\src\chromium\src\third_party\llvm-build\Release+Asserts\bin\clang-cl.exe  
/nologo -DGTEST_HAS_RTTI=0 -DIMPORT_LIBLLDB -DLLDB_CONFIGURATION_RELEASE 
-DLLDB_DISABLE_CURSES -DLLDB_DISABLE_LIBEDIT -DLLDB_DISABLE_PYTHON 
-DLLDB_PYTHON_HOME=\"\" -DLLDB_USE_BUILTIN_DEMANGLER -DUNICODE 
-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS 
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_DEBUG_POINTER_IMPL="" 
-D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS 
-D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS -Itools\lldb\tools\lldb-mi 
-IC:\src\git\llvm-project-20170507\lldb\tools\lldb-mi -Itools\lldb\include 
-IC:\src\git\llvm-project-20170507\lldb\include -Iinclude 
-IC:\src\git\llvm-project-20170507\llvm\include 
-IC:\src\git\llvm-project-20170507\llvm\..\clang\include 
-Itools\lldb\..\clang\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:strictStrings 
/Oi /Zc:rvalueCast /Brepro /W4  -W -Wno-unused-parameter -Wwrite-strings 
-Wcast-qual -Wmissing-field-initializers -Wcovered-switch-default 
-Wdelete-non-virtual-dtor -Wstring-conversion -Wno-deprecated-declarations 
-Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register 
-Wno-vla-extension /MD /O2 /Ob2 /DNDEBUG   -wd4018 -wd4068 -wd4150 -wd4251 
-wd4521 -wd4530  /EHs-c- /GR- /showIncludes 
/Fotools\lldb\tools\lldb-mi\CMakeFiles\lldb-mi.dir\MIDriverMain.cpp.obj 
/Fdtools\lldb\tools\lldb-mi\CMakeFiles\lldb-mi.dir\ -c 
C:\src\git\llvm-project-20170507\lldb\tools\lldb-mi\MIDriverMain.cpp
  In file included from 
C:\src\git\llvm-project-20170507\lldb\tools\lldb-mi\MIDriverMain.cpp:37:
  C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Professional\VC\Tools\MSVC\14.14.26428\include\csignal(19,13):  
error: no member named 'sig_atomic_t' in the global namespace
  using _CSTD sig_atomic_t; using _CSTD raise; using _CSTD signal;
~ ^
  C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Professional\VC\Tools\MSVC\14.14.26428\include\csignal(19,39):  
error: no member named 'raise' in the global namespace
  using _CSTD sig_atomic_t; using _CSTD raise; using _CSTD signal;
  ~ ^
  C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Professional\VC\Tools\MSVC\14.14.26428\include\csignal(19,58):  
error: no member named 'signal' in the global namespace
  using _CSTD sig_atomic_t; using _CSTD raise; using _CSTD signal;
 ~ ^
  C:\src\git\llvm-project-20170507\lldb\tools\lldb-mi\MIDriverMain.cpp(74,10):  
error: use of undeclared identifier 'SIGINT'
signal(SIGINT, sigint_handler);
   ^
  C:\src\git\llvm-project-20170507\lldb\tools\lldb-mi\MIDriverMain.cpp(185,10): 
 error: use of undeclared identifier 'SIGINT'
signal(SIGINT, sigint_handler);
   ^
  5 errors generated.


https://reviews.llvm.org/D47578



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


[PATCH] D47578: Do not enforce absolute path argv0 in windows

2018-05-31 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta updated this revision to Diff 149394.
takuto.ikuta added a comment.

Add test and split function


https://reviews.llvm.org/D47578

Files:
  llvm/lib/Support/Windows/Process.inc
  llvm/unittests/Support/CommandLineTest.cpp

Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -13,6 +13,7 @@
 #include "llvm/ADT/Triple.h"
 #include "llvm/Config/config.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/StringSaver.h"
@@ -821,4 +822,22 @@
   EXPECT_TRUE(Errs.empty());
 }
 
+#ifdef _WIN32
+TEST(CommandLineTest, GetCommandLineArguments) {
+  int argc = __argc;
+  char **argv = __argv;
+
+  // GetCommandLineArguments is called in InitLLVM.
+  llvm::InitLLVM X(argc, argv);
+
+  EXPECT_EQ(llvm::sys::path::is_absolute(argv[0]),
+llvm::sys::path::is_absolute(__argv[0]));
+
+  EXPECT_TRUE(llvm::sys::path::filename(argv[0])
+  .equals_lower("supporttests.exe"))
+  << "Filename of test executable is "
+  << llvm::sys::path::filename(argv[0]);
+}
+#endif
+
 }  // anonymous namespace
Index: llvm/lib/Support/Windows/Process.inc
===
--- llvm/lib/Support/Windows/Process.inc
+++ llvm/lib/Support/Windows/Process.inc
@@ -209,9 +209,7 @@
 }
 
 static std::error_code ExpandShortFileName(const wchar_t *Arg,
-   SmallVectorImpl ,
-   BumpPtrAllocator ) {
-  SmallVector LongPath;
+   SmallVectorImpl ) {
   DWORD Length = GetLongPathNameW(Arg, LongPath.data(), LongPath.capacity());
   if (Length == 0)
 return mapWindowsError(GetLastError());
@@ -222,7 +220,53 @@
 return mapWindowsError(ERROR_INSUFFICIENT_BUFFER);
   }
   LongPath.set_size(Length);
-  return ConvertAndPushArg(LongPath.data(), Args, Alloc);
+  return std::error_code();
+}
+
+static std::error_code GetLongArgv0FullPath(const wchar_t *Argv0,
+SmallVectorImpl ) {
+  // The first argument may contain just the name of the executable (e.g.,
+  // "clang") rather than the full path, so swap it with the full path.
+  wchar_t ModuleName[MAX_PATH];
+  int Length = ::GetModuleFileNameW(NULL, ModuleName, MAX_PATH);
+  if (0 < Length && Length < MAX_PATH)
+Argv0 = ModuleName;
+
+  // If the first argument is a shortened (8.3) name (which is possible even
+  // if we got the module name), the driver will have trouble distinguishing it
+  // (e.g., clang.exe v. clang++.exe), so expand it now.
+  return ExpandShortFileName(Argv0, LongArgv0);
+}
+
+static std::error_code GetLongArgv0Path(const wchar_t *Argv0,
+SmallVectorImpl ) {
+  SmallVector UTF16LongArgv0Full;
+
+  std::error_code ec = GetLongArgv0FullPath(Argv0, UTF16LongArgv0Full);
+  if (ec)
+return ec;
+
+  // Replace filename in original argv0 with expanded filename.
+  // This may change argv0 like below,
+  // * clang -> clang.exe (just add extension)
+  // * CLANG_~1.EXE -> clang++.exe (extend shorname)
+  // This is for keeping relativeness of original argv0 path.
+  SmallVector UTF8LongArgv0Full;
+  ec = windows::UTF16ToUTF8(UTF16LongArgv0Full.data(), UTF16LongArgv0Full.size(),
+UTF8LongArgv0Full);
+  if (ec)
+return ec;
+
+  SmallVector UTF8Argv0;
+  ec = windows::UTF16ToUTF8(Argv0, wcslen(Argv0), UTF8Argv0);
+  if (ec)
+return ec;
+
+  sys::path::remove_filename(UTF8Argv0);
+  sys::path::append(UTF8Argv0, sys::path::filename(UTF8LongArgv0Full.data()));
+
+  return windows::UTF8ToUTF16(StringRef(UTF8Argv0.data(), UTF8Argv0.size()),
+  LongArgv0);
 }
 
 std::error_code
@@ -235,19 +279,11 @@
 return mapWindowsError(::GetLastError());
 
   Args.reserve(ArgCount);
-  std::error_code ec;
-
-  // The first argument may contain just the name of the executable (e.g.,
-  // "clang") rather than the full path, so swap it with the full path.
-  wchar_t ModuleName[MAX_PATH];
-  int Length = ::GetModuleFileNameW(NULL, ModuleName, MAX_PATH);
-  if (0 < Length && Length < MAX_PATH)
-UnicodeCommandLine[0] = ModuleName;
+  SmallVector LongArgv0;
+  std::error_code ec = GetLongArgv0Path(UnicodeCommandLine[0], LongArgv0);
 
-  // If the first argument is a shortened (8.3) name (which is possible even
-  // if we got the module name), the driver will have trouble distinguishing it
-  // (e.g., clang.exe v. clang++.exe), so expand it now.
-  ec = ExpandShortFileName(UnicodeCommandLine[0], Args, Alloc);
+  if (!ec)
+ec = ConvertAndPushArg(LongArgv0.data(), Args, Alloc);
 
   for (int i = 1; i < ArgCount && !ec; ++i) {
 ec = WildcardExpand(UnicodeCommandLine[i], Args, 

[PATCH] D47614: [WebAssembly] Hide new Wasm EH behind its feature flag

2018-05-31 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added inline comments.



Comment at: lib/CodeGen/CGException.cpp:322
   const EHPersonality  =
-  getCXXPersonality(getTarget().getTriple(), LangOpts);
+  getCXXPersonality(getTarget().getTriple(), LangOpts, getTarget());
   if ( == )

If the triple can be derived from target why not just pass that target?


Repository:
  rC Clang

https://reviews.llvm.org/D47614



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


[PATCH] D47607: [libcxx] Almost fix some UB in and

2018-05-31 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: libcxx/include/unordered_map:586
 union __hash_value_type
 {
 typedef _Key key_type;

`union` -> `class`


Repository:
  rCXX libc++

https://reviews.llvm.org/D47607



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


[PATCH] D47607: [libcxx] Almost fix some UB in and

2018-05-31 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

Overall this change seems reasonable to me. Thanks for working on this. 
Initially I was concerned we would hit issues optimizing const objects,
but I should have read your description first! Thanks for ensuring Clang 
doesn't optimize on this.

One other concern I have is if there will be any performance impact to using 
`launder` all the time, but better safe than sorry.

Other than the inline comments, this LGTM.




Comment at: libcxx/include/map:633
+#if _LIBCPP_STD_VER > 14
+return _VSTD::launder(this)->__cc;
+#else

rsmith wrote:
> Formally this should be `return *_VSTD::launder(>__cc);`, because 
> `this` must already point to an in-lifetime object or the member function 
> call would have been invalid.
`return *_VSTD::launder(_VSTD::addressof(this->__cc));` because ADL.



Comment at: libcxx/include/map:648
+_LIBCPP_INLINE_VISIBILITY
+__nc_ref_pair_type __ref()
+{

I think `__ref` can be private.



Comment at: libcxx/include/map:653
+}
+_LIBCPP_INLINE_VISIBILITY
+__nc_rref_pair_type __move()

Add a newline?



Comment at: libcxx/include/map:708
+public:
+value_type& __get_value() { return __cc; }
+const value_type& __get_value() const { return __cc; }

`_LIBCPP_INLINE_VISIBILITY` here and below it.



Comment at: libcxx/include/unordered_map:597
+public:
+value_type& __get_value()
+{

`_LIBCPP_INLINE_VISIBILITY`



Comment at: libcxx/include/unordered_map:606
+
+const value_type& __get_value() const
+{

`_LIBCPP_INLINE_VISIBILITY`



Comment at: libcxx/include/unordered_map:615
+
+__nc_ref_pair_type __ref()
+{

This can be private.



Comment at: libcxx/include/unordered_map:621
+
+__nc_rref_pair_type __move()
+{

`_LIBCPP_INLINE_VISIBILITY`



Comment at: libcxx/include/unordered_map:677
+public:
+value_type& __get_value() { return __cc; }
+const value_type& __get_value() const { return __cc; }

`_LIBCPP_INLINE_VISIBILITY`


Repository:
  rCXX libc++

https://reviews.llvm.org/D47607



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


r333719 - [analyzer] NFC: Track all constructed objects in a single state trait.

2018-05-31 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu May 31 18:59:48 2018
New Revision: 333719

URL: http://llvm.org/viewvc/llvm-project?rev=333719=rev
Log:
[analyzer] NFC: Track all constructed objects in a single state trait.

ExprEngine already maintains three internal program state traits to track
path-sensitive information related to object construction: pointer returned by
operator new, and pointer to temporary object for two different purposes - for
destruction and for lifetime extension. We'll need to add 2-3 more in a few
follow-up commits.

Merge these traits into one because they all essentially serve one purpose and
work similarly.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=333719=333718=333719=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Thu 
May 31 18:59:48 2018
@@ -753,68 +753,48 @@ private:
   /// determine the region into which an object will be constructed by \p CE.
   /// When the lookahead fails, a temporary region is returned, and the
   /// IsConstructorWithImproperlyModeledTargetRegion flag is set in \p 
CallOpts.
-  const MemRegion *getRegionForConstructedObject(const CXXConstructExpr *CE,
- ExplodedNode *Pred,
- const ConstructionContext *CC,
- EvalCallOptions );
-
-  /// Store the region of a C++ temporary object corresponding to a
-  /// CXXBindTemporaryExpr for later destruction.
-  static ProgramStateRef addInitializedTemporary(
-  ProgramStateRef State, const CXXBindTemporaryExpr *BTE,
-  const LocationContext *LC, const CXXTempObjectRegion *R);
+  SVal getLocationForConstructedObject(const CXXConstructExpr *CE,
+   ExplodedNode *Pred,
+   const ConstructionContext *CC,
+   EvalCallOptions );
+
+  /// Store the location of a C++ object corresponding to a statement
+  /// until the statement is actually encountered. For example, if a DeclStmt
+  /// has CXXConstructExpr as its initializer, the object would be considered
+  /// to be "under construction" between CXXConstructExpr and DeclStmt.
+  /// This allows, among other things, to keep bindings to variable's fields
+  /// made within the constructor alive until its declaration actually
+  /// goes into scope.
+  static ProgramStateRef addObjectUnderConstruction(
+  ProgramStateRef State, const Stmt *S,
+  const LocationContext *LC, SVal V);
+
+  /// Mark the object sa fully constructed, cleaning up the state trait
+  /// that tracks objects under construction.
+  static ProgramStateRef finishObjectConstruction(ProgramStateRef State,
+  const Stmt *S,
+  const LocationContext *LC);
+
+  /// If the given statement corresponds to an object under construction,
+  /// being part of its construciton context, retrieve that object's location.
+  static Optional getObjectUnderConstruction(ProgramStateRef State,
+   const Stmt *S,
+   const LocationContext *LC);
 
-  /// Check if all initialized temporary regions are clear for the given
-  /// context range (including FromLC, not including ToLC).
+  /// Check if all objects under construction have been fully constructed
+  /// for the given context range (including FromLC, not including ToLC).
   /// This is useful for assertions.
-  static bool areInitializedTemporariesClear(ProgramStateRef State,
- const LocationContext *FromLC,
- const LocationContext *ToLC);
-
-  /// Store the region of a C++ temporary object corresponding to a
-  /// CXXBindTemporaryExpr for later destruction.
-  static ProgramStateRef addTemporaryMaterialization(
-  ProgramStateRef State, const MaterializeTemporaryExpr *MTE,
-  const LocationContext *LC, const CXXTempObjectRegion *R);
-
-  /// Check if all temporary materialization regions are clear for the given
-  /// context range (including FromLC, not including ToLC).
-  /// This is useful for assertions.
-  static bool areTemporaryMaterializationsClear(ProgramStateRef 

[PATCH] D47303: [analyzer] NFC: Merge object construction related state traits into one.

2018-05-31 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333719: [analyzer] NFC: Track all constructed objects in a 
single state trait. (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47303?vs=148692=149391#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47303

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
@@ -753,68 +753,48 @@
   /// determine the region into which an object will be constructed by \p CE.
   /// When the lookahead fails, a temporary region is returned, and the
   /// IsConstructorWithImproperlyModeledTargetRegion flag is set in \p CallOpts.
-  const MemRegion *getRegionForConstructedObject(const CXXConstructExpr *CE,
- ExplodedNode *Pred,
- const ConstructionContext *CC,
- EvalCallOptions );
-
-  /// Store the region of a C++ temporary object corresponding to a
-  /// CXXBindTemporaryExpr for later destruction.
-  static ProgramStateRef addInitializedTemporary(
-  ProgramStateRef State, const CXXBindTemporaryExpr *BTE,
-  const LocationContext *LC, const CXXTempObjectRegion *R);
+  SVal getLocationForConstructedObject(const CXXConstructExpr *CE,
+   ExplodedNode *Pred,
+   const ConstructionContext *CC,
+   EvalCallOptions );
 
-  /// Check if all initialized temporary regions are clear for the given
-  /// context range (including FromLC, not including ToLC).
-  /// This is useful for assertions.
-  static bool areInitializedTemporariesClear(ProgramStateRef State,
- const LocationContext *FromLC,
- const LocationContext *ToLC);
-
-  /// Store the region of a C++ temporary object corresponding to a
-  /// CXXBindTemporaryExpr for later destruction.
-  static ProgramStateRef addTemporaryMaterialization(
-  ProgramStateRef State, const MaterializeTemporaryExpr *MTE,
-  const LocationContext *LC, const CXXTempObjectRegion *R);
+  /// Store the location of a C++ object corresponding to a statement
+  /// until the statement is actually encountered. For example, if a DeclStmt
+  /// has CXXConstructExpr as its initializer, the object would be considered
+  /// to be "under construction" between CXXConstructExpr and DeclStmt.
+  /// This allows, among other things, to keep bindings to variable's fields
+  /// made within the constructor alive until its declaration actually
+  /// goes into scope.
+  static ProgramStateRef addObjectUnderConstruction(
+  ProgramStateRef State, const Stmt *S,
+  const LocationContext *LC, SVal V);
+
+  /// Mark the object sa fully constructed, cleaning up the state trait
+  /// that tracks objects under construction.
+  static ProgramStateRef finishObjectConstruction(ProgramStateRef State,
+  const Stmt *S,
+  const LocationContext *LC);
+
+  /// If the given statement corresponds to an object under construction,
+  /// being part of its construciton context, retrieve that object's location.
+  static Optional getObjectUnderConstruction(ProgramStateRef State,
+   const Stmt *S,
+   const LocationContext *LC);
 
-  /// Check if all temporary materialization regions are clear for the given
-  /// context range (including FromLC, not including ToLC).
+  /// Check if all objects under construction have been fully constructed
+  /// for the given context range (including FromLC, not including ToLC).
   /// This is useful for assertions.
-  static bool areTemporaryMaterializationsClear(ProgramStateRef State,
-const LocationContext *FromLC,
-const LocationContext *ToLC);
+  static bool areAllObjectsFullyConstructed(ProgramStateRef State,
+const LocationContext *FromLC,
+const LocationContext *ToLC);
 
   /// Adds an initialized temporary and/or a materialization, whichever is
   /// necessary, by looking at the whole 

[PATCH] D47616: [CFG] [analyzer] Explain copy elision through construction contexts.

2018-05-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, 
rnkovacs.
Herald added subscribers: cfe-commits, baloghadamsoftware.

Copy elision occurs when

1. a temporary object (with its corresponding temporary object construction 
context) is constructed and
2. it is immediately copied or moved into any other object (with its own 
construction context, which can be any construction context).

Constructor on step 2 would then be called "elidable".

Copy elision consists in skipping ("eliding") the constructor on step 2 and 
performing the constructor on step 1 as if it was constructing the object of 
step 2. Additionally, destructors are skipped for the temporary object 
constructed on step 1.

The current patch modifies the temporary object construction context for 
constructor on step 1 to include information about the upcoming step 2. Only 
temporary object construction contexts would need to be updated because step 1 
always has a temporary object construction context.

The updated context will include both a reference to the elidable 
construct-expression of step 2 and the construction context of step 2. This 
will allow the analyzer to both skip the elidable constructor itself when it's 
encountered and compute the correct target region associated with step 2 while 
modeling step 1.

TOTHINK: whether "temporary object construction context with elision" should be 
a separate construction context sub-class.


Repository:
  rC Clang

https://reviews.llvm.org/D47616

Files:
  include/clang/Analysis/ConstructionContext.h
  lib/Analysis/CFG.cpp
  lib/Analysis/ConstructionContext.cpp
  test/Analysis/cfg-rich-constructors.cpp
  test/Analysis/temp-obj-dtors-cfg-output.cpp

Index: test/Analysis/temp-obj-dtors-cfg-output.cpp
===
--- test/Analysis/temp-obj-dtors-cfg-output.cpp
+++ test/Analysis/temp-obj-dtors-cfg-output.cpp
@@ -235,7 +235,7 @@
 // CHECK: Succs (1): B1
 // CHECK:   [B1]
 // WARNINGS: 1: A() (CXXConstructExpr, class A)
-// ANALYZER: 1: A() (CXXConstructExpr, [B1.2], [B1.4], class A)
+// ANALYZER: 1: A() (CXXConstructExpr, [B1.2], [B1.4], [B1.5], class A)
 // CHECK: 2: [B1.1] (BindTemporary)
 // CHECK: 3: [B1.2] (ImplicitCastExpr, NoOp, const class A)
 // CHECK: 4: [B1.3]
@@ -295,7 +295,7 @@
 // CHECK: Succs (1): B1
 // CHECK:   [B1]
 // WARNINGS: 1: A() (CXXConstructExpr, class A)
-// ANALYZER: 1: A() (CXXConstructExpr, [B1.2], [B1.4], class A)
+// ANALYZER: 1: A() (CXXConstructExpr, [B1.2], [B1.4], [B1.5], class A)
 // CHECK: 2: [B1.1] (BindTemporary)
 // CHECK: 3: [B1.2] (ImplicitCastExpr, NoOp, const class A)
 // CHECK: 4: [B1.3]
@@ -550,12 +550,12 @@
 // CHECK: Succs (2): B6 B5
 // CHECK:   [B8]
 // WARNINGS: 1: A() (CXXConstructExpr, class A)
-// ANALYZER: 1: A() (CXXConstructExpr, [B8.2], [B8.4], class A)
+// ANALYZER: 1: A() (CXXConstructExpr, [B8.2], [B8.4], [B8.5], class A)
 // CHECK: 2: [B8.1] (BindTemporary)
 // CHECK: 3: [B8.2] (ImplicitCastExpr, NoOp, const class A)
 // CHECK: 4: [B8.3]
 // WARNINGS: 5: [B8.4] (CXXConstructExpr, class A)
-// ANALYZER: 5: [B8.4] (CXXConstructExpr, [B8.6], [B7.3], class A)
+// ANALYZER: 5: [B8.4] (CXXConstructExpr, [B8.6], [B7.3], [B7.4], class A)
 // CHECK: 6: [B8.5] (BindTemporary)
 // CHECK: Preds (1): B10
 // CHECK: Succs (1): B7
@@ -570,13 +570,13 @@
 // CHECK: 7: [B9.6] (ImplicitCastExpr, NoOp, const class A)
 // CHECK: 8: [B9.7]
 // WARNINGS: 9: [B9.8] (CXXConstructExpr, class A)
-// ANALYZER: 9: [B9.8] (CXXConstructExpr, [B9.10], [B9.13], class A)
+// ANALYZER: 9: [B9.8] (CXXConstructExpr, [B9.10], [B9.13], [B9.14], class A)
 // CHECK:10: [B9.9] (BindTemporary)
 // CHECK:11: A([B9.10]) (CXXFunctionalCastExpr, ConstructorConversion, class A)
 // CHECK:12: [B9.11] (ImplicitCastExpr, NoOp, const class A)
 // CHECK:13: [B9.12]
 // WARNINGS:14: [B9.13] (CXXConstructExpr, class A)
-// ANALYZER:14: [B9.13] (CXXConstructExpr, [B9.15], [B7.3], class A)
+// ANALYZER:14: [B9.13] (CXXConstructExpr, [B9.15], [B7.3], [B7.4], class A)
 // CHECK:15: [B9.14] (BindTemporary)
 // CHECK: Preds (1): B10
 // CHECK: Succs (1): B7
@@ -680,7 +680,7 @@
 // CHECK: Succs (1): B0
 // CHECK:   [B4]
 // WARNINGS: 1: C() (CXXConstructExpr, struct C)
-// ANALYZER: 1: C() (CXXConstructExpr, [B4.2], [B4.4], struct C)
+// ANALYZER: 1: C() (CXXConstructExpr, [B4.2], [B4.4], [B4.5], struct C)
 // CHECK: 2: [B4.1] (BindTemporary)
 // CHECK: 3: [B4.2] (ImplicitCastExpr, NoOp, const struct C)
 // CHECK: 4: [B4.3]
@@ -733,7 +733,7 @@
 // CHECK: Succs (1): B0
 // CHECK:   [B3]
 // CXX98-WARNINGS: 1: D() (CXXConstructExpr, struct D)
-// CXX98-ANALYZER: 1: D() (CXXConstructExpr, [B3.3], struct D)
+// CXX98-ANALYZER: 1: D() (CXXConstructExpr, [B3.3], [B3.4], struct D)
 

r333718 - [Modules] Warning for module declarations lacking 'framework' qualifier

2018-05-31 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu May 31 18:26:18 2018
New Revision: 333718

URL: http://llvm.org/viewvc/llvm-project?rev=333718=rev
Log:
[Modules] Warning for module declarations lacking 'framework' qualifier

When a module declaration for a framework lacks the 'framework'
qualifier, the listed headers aren't found (because there's no
trigger for the special framework style path lookup) and the module
is silently not built. This leads to frameworks not being modularized
by accident, which is pretty bad.

Add a warning and suggest the user to add the 'framework' qualifier
when we can prove that it's the case.

rdar://problem/39193062

Added:
cfe/trunk/test/Modules/Inputs/incomplete-framework-module/
cfe/trunk/test/Modules/Inputs/incomplete-framework-module/Foo.framework/

cfe/trunk/test/Modules/Inputs/incomplete-framework-module/Foo.framework/Headers/

cfe/trunk/test/Modules/Inputs/incomplete-framework-module/Foo.framework/Headers/Foo.h

cfe/trunk/test/Modules/Inputs/incomplete-framework-module/Foo.framework/Headers/FooB.h

cfe/trunk/test/Modules/Inputs/incomplete-framework-module/Foo.framework/Modules/

cfe/trunk/test/Modules/Inputs/incomplete-framework-module/Foo.framework/Modules/module.modulemap
cfe/trunk/test/Modules/incomplete-framework-module.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/lib/Lex/ModuleMap.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=333718=333717=333718=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu May 31 18:26:18 2018
@@ -285,6 +285,8 @@ def IncompatiblePointerTypes
 [IncompatiblePointerTypesDiscardsQualifiers,
  IncompatibleFunctionPointerTypes]>;
 def IncompleteUmbrella : DiagGroup<"incomplete-umbrella">;
+def IncompleteFrameworkModuleDeclaration
+  : DiagGroup<"incomplete-framework-module-declaration">;
 def NonModularIncludeInFrameworkModule
   : DiagGroup<"non-modular-include-in-framework-module">;
 def NonModularIncludeInModule : DiagGroup<"non-modular-include-in-module",

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=333718=333717=333718=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Thu May 31 18:26:18 2018
@@ -694,6 +694,11 @@ def warn_mmap_mismatched_private_module_
   InGroup;
 def note_mmap_rename_top_level_private_module : Note<
   "rename '%0' to ensure it can be found by name">;
+def warn_mmap_incomplete_framework_module_declaration : Warning<
+  "skipping '%0' because module declaration of '%1' lacks the 'framework' 
qualifier">,
+  InGroup;
+def note_mmap_add_framework_keyword : Note<
+  "use 'framework module' to declare module '%0'">;
 
 def err_mmap_duplicate_header_attribute : Error<
   "header attribute '%0' specified multiple times">;

Modified: cfe/trunk/include/clang/Lex/ModuleMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=333718=333717=333718=diff
==
--- cfe/trunk/include/clang/Lex/ModuleMap.h (original)
+++ cfe/trunk/include/clang/Lex/ModuleMap.h Thu May 31 18:26:18 2018
@@ -303,8 +303,15 @@ private:
   Module *resolveModuleId(const ModuleId , Module *Mod, bool Complain) 
const;
 
   /// Add an unresolved header to a module.
+  ///
+  /// \param Mod The module in which we're adding the unresolved header
+  ///directive.
+  /// \param Header The unresolved header directive.
+  /// \param NeedsFramework If Mod is not a framework but a missing header 
would
+  ///be found in case Mod was, set it to true. False otherwise.
   void addUnresolvedHeader(Module *Mod,
-   Module::UnresolvedHeaderDirective Header);
+   Module::UnresolvedHeaderDirective Header,
+   bool );
 
   /// Look up the given header directive to find an actual header file.
   ///
@@ -312,14 +319,22 @@ private:
   /// \param Header The header directive to resolve.
   /// \param RelativePathName Filled in with the relative path name from the
   ///module to the resolved header.
+  /// \param NeedsFramework If M is not a framework but a missing header would
+  ///be found in case M was, set it to true. False otherwise.
   /// \return The resolved file, if any.
   const FileEntry *findHeader(Module *M,
   const Module::UnresolvedHeaderDirective ,

[PATCH] D47607: [libcxx] Almost fix some UB in and

2018-05-31 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: libcxx/include/map:617
 template 
 union __value_type
 {

This doesn't need to be a union any more; change to class?



Comment at: libcxx/include/map:633
+#if _LIBCPP_STD_VER > 14
+return _VSTD::launder(this)->__cc;
+#else

Formally this should be `return *_VSTD::launder(>__cc);`, because `this` 
must already point to an in-lifetime object or the member function call would 
have been invalid.


Repository:
  rCXX libc++

https://reviews.llvm.org/D47607



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


[PATCH] D47613: Mark __c11_atomic_load as const

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

LGTM.


Repository:
  rCXX libc++

https://reviews.llvm.org/D47613



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


[PATCH] D45517: [analyzer] False positive refutation with Z3

2018-05-31 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho added inline comments.



Comment at: 
include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h:183
+  virtual void reset() {}
+  virtual bool isModelFeasible() { return true; }
+  virtual void addRangeConstraints(ConstraintRangeTy) {}

george.karpenkov wrote:
> mikhail.ramalho wrote:
> > george.karpenkov wrote:
> > > Making those virtual does not make much sense to me.
> > > Returning `true` by default is not correct.
> > > When we are using the visitor, we should already know we have a 
> > > `Z3ConstraintsManager`, why can't we just use methods of that class?
> > Z3ConstraintManager is fully contained inside a .cpp file, so we need 
> > isModelFeasible and addRangeConstraints to be exposed via its base class.
> > 
> > Another solution is to split Z3ConstraintManager into a .h and a .cpp file 
> > and include the header. We would then be able to use it directly, instead 
> > of through a ConstraintManager object.
> > 
> > I honestly prefer the latter. What do you think?
> Yeah, I think we would need a header here.
> In general we try to avoid inheritance and virtual functions unless they are 
> very beneficial, and here they are not.
Cool, I'll create a separate patch for that then.


https://reviews.llvm.org/D45517



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


[PATCH] D47557: Filesystem tests: un-confuse write time

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

LGTM after addressing inline comments.




Comment at: 
test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp:257
+TEST_CHECK(LastWriteTime(file) == Clock::to_time_t(ftime2));
 }
 

What happened to the test for the directory? Can we add

```
TEST_CHECK(LastWriteTime(dir) == Clock::to_time_t(dtime2));
```


Repository:
  rCXX libc++

https://reviews.llvm.org/D47557



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


[PATCH] D47564: [Parse] Use CapturedStmt for @finally on MSVC

2018-05-31 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D47564#1118423, @smeenai wrote:

> In https://reviews.llvm.org/D47564#1118381, @rjmccall wrote:
>
> > That's an interesting idea.  I don't see any particular reason not to do it 
> > this way if you're willing to accept that it's never going to support the 
> > full control-flow possibilities of @finally.  You will need to add 
> > JumpDiagnostics logic to prevent branches out of the block, and I don't 
> > know how this will interact with attempts to throw an exception out.
>
>
> There's already some logic in CapturedStmt to prevent branches out of the 
> block:
>
> - Attempting to return will produce "cannot return from Objective-C @finally 
> statement"
> - Attempting to goto out of the block will result in "use of undeclared 
> label", which is a bad diagnostic (and should be improved), but it does error


Alright, that makes sense.

> It should be possible to add support for returns, at least; the idea we'd 
> discussed with @rnk was setting a flag in the captured function to indicate a 
> return having been executed, and then reading that flag outside the captured 
> function and acting on it appropriately. gotos would be more complicated, but 
> I think we could make them work if we really wanted to.
> 
> Throwing an exception out should just work, I think; the outlined function 
> will just participate normally in exception handling. Did you have a specific 
> case you were thinking of?

No, it was just a general question.  Have you gotten this to a point where it's 
testable?


Repository:
  rC Clang

https://reviews.llvm.org/D47564



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


[PATCH] D47564: [Parse] Use CapturedStmt for @finally on MSVC

2018-05-31 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In https://reviews.llvm.org/D47564#1118381, @rjmccall wrote:

> That's an interesting idea.  I don't see any particular reason not to do it 
> this way if you're willing to accept that it's never going to support the 
> full control-flow possibilities of @finally.  You will need to add 
> JumpDiagnostics logic to prevent branches out of the block, and I don't know 
> how this will interact with attempts to throw an exception out.


There's already some logic in CapturedStmt to prevent branches out of the block:

- Attempting to return will produce "cannot return from Objective-C @finally 
statement"
- Attempting to goto out of the block will result in "use of undeclared label", 
which is a bad diagnostic (and should be improved), but it does error

Are there any other branches you had in mind? I could add tests for them, 
perhaps, though it's also covered by `test/Sema/captured-statements.c`.

It should be possible to add support for returns, at least; the idea we'd 
discussed with @rnk was setting a flag in the captured function to indicate a 
return having been executed, and then reading that flag outside the captured 
function and acting on it appropriately. gotos would be more complicated, but I 
think we could make them work if we really wanted to.

Throwing an exception out should just work, I think; the outlined function will 
just participate normally in exception handling. Did you have a specific case 
you were thinking of?


Repository:
  rC Clang

https://reviews.llvm.org/D47564



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


[PATCH] D47614: [WebAssembly] Hide new Wasm EH behind its feature flag

2018-05-31 Thread Heejin Ahn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC333716: [WebAssembly] Hide new Wasm EH behind its feature 
flag (authored by aheejin, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47614?vs=149386=149387#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47614

Files:
  lib/CodeGen/CGException.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/wasm-eh.cpp


Index: test/CodeGenCXX/wasm-eh.cpp
===
--- test/CodeGenCXX/wasm-eh.cpp
+++ test/CodeGenCXX/wasm-eh.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions 
-fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
-// RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions 
-fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions 
-fexceptions -fcxx-exceptions -target-feature +exception-handling -emit-llvm -o 
- -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions 
-fexceptions -fcxx-exceptions -target-feature +exception-handling -emit-llvm -o 
- -std=c++11 | FileCheck %s
 
 void may_throw();
 void dont_throw() noexcept;
Index: lib/CodeGen/CGException.cpp
===
--- lib/CodeGen/CGException.cpp
+++ lib/CodeGen/CGException.cpp
@@ -154,30 +154,34 @@
 }
 
 static const EHPersonality (const llvm::Triple ,
-  const LangOptions ) {
+  const LangOptions ,
+  const TargetInfo ) {
   if (L.SjLjExceptions)
 return EHPersonality::GNU_CPlusPlus_SJLJ;
   if (L.DWARFExceptions)
 return EHPersonality::GNU_CPlusPlus;
   if (T.isWindowsMSVCEnvironment())
 return EHPersonality::MSVC_CxxFrameHandler3;
   if (L.SEHExceptions)
 return EHPersonality::GNU_CPlusPlus_SEH;
-  if (T.getArch() == llvm::Triple::wasm32 ||
-  T.getArch() == llvm::Triple::wasm64)
+  // Wasm EH is a non-MVP feature for now.
+  if (Target.hasFeature("exception-handling") &&
+  (T.getArch() == llvm::Triple::wasm32 ||
+   T.getArch() == llvm::Triple::wasm64))
 return EHPersonality::GNU_Wasm_CPlusPlus;
   return EHPersonality::GNU_CPlusPlus;
 }
 
 /// Determines the personality function to use when both C++
 /// and Objective-C exceptions are being caught.
 static const EHPersonality (const llvm::Triple ,
- const LangOptions ) {
+ const LangOptions ,
+ const TargetInfo ) {
   switch (L.ObjCRuntime.getKind()) {
   // In the fragile ABI, just use C++ exception handling and hope
   // they're not doing crazy exception mixing.
   case ObjCRuntime::FragileMacOSX:
-return getCXXPersonality(T, L);
+return getCXXPersonality(T, L, Target);
 
   // The ObjC personality defers to the C++ personality for non-ObjC
   // handlers.  Unlike the C++ case, we use the same personality
@@ -209,14 +213,16 @@
 const FunctionDecl *FD) {
   const llvm::Triple  = CGM.getTarget().getTriple();
   const LangOptions  = CGM.getLangOpts();
+  const TargetInfo  = CGM.getTarget();
 
   // Functions using SEH get an SEH personality.
   if (FD && FD->usesSEHTry())
 return getSEHPersonalityMSVC(T);
 
   if (L.ObjC1)
-return L.CPlusPlus ? getObjCXXPersonality(T, L) : getObjCPersonality(T, L);
-  return L.CPlusPlus ? getCXXPersonality(T, L) : getCPersonality(T, L);
+return L.CPlusPlus ? getObjCXXPersonality(T, L, Target)
+   : getObjCPersonality(T, L);
+  return L.CPlusPlus ? getCXXPersonality(T, L, Target) : getCPersonality(T, L);
 }
 
 const EHPersonality ::get(CodeGenFunction ) {
@@ -313,7 +319,7 @@
 
   const EHPersonality  = EHPersonality::get(*this, /*FD=*/nullptr);
   const EHPersonality  =
-  getCXXPersonality(getTarget().getTriple(), LangOpts);
+  getCXXPersonality(getTarget().getTriple(), LangOpts, getTarget());
   if ( == )
 return;
 
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -4102,7 +4102,8 @@
 
 void WebAssemblyCXXABI::emitBeginCatch(CodeGenFunction ,
const CXXCatchStmt *C) {
-  CGF.EHStack.pushCleanup(
-  NormalCleanup, cast(CGF.CurrentFuncletPad));
+  if (CGF.getTarget().hasFeature("exception-handling"))
+CGF.EHStack.pushCleanup(
+NormalCleanup, cast(CGF.CurrentFuncletPad));
   ItaniumCXXABI::emitBeginCatch(CGF, C);
 }


Index: test/CodeGenCXX/wasm-eh.cpp
===
--- test/CodeGenCXX/wasm-eh.cpp
+++ 

r333716 - [WebAssembly] Hide new Wasm EH behind its feature flag

2018-05-31 Thread Heejin Ahn via cfe-commits
Author: aheejin
Date: Thu May 31 18:01:37 2018
New Revision: 333716

URL: http://llvm.org/viewvc/llvm-project?rev=333716=rev
Log:
[WebAssembly] Hide new Wasm EH behind its feature flag

Summary:
clang's current wasm EH implementation is a non-MVP feature in progress.
We had a `-mexception-handling` wasm feature but were not using it. This
patch hides the non-MVP wasm EH behind a flag, so it does not affect
other code for now.

Reviewers: dschuff

Subscribers: sbc100, jgravelle-google, sunfish, cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/wasm-eh.cpp

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=333716=333715=333716=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Thu May 31 18:01:37 2018
@@ -154,7 +154,8 @@ static const EHPersonality 
 }
 
 static const EHPersonality (const llvm::Triple ,
-  const LangOptions ) {
+  const LangOptions ,
+  const TargetInfo ) {
   if (L.SjLjExceptions)
 return EHPersonality::GNU_CPlusPlus_SJLJ;
   if (L.DWARFExceptions)
@@ -163,8 +164,10 @@ static const EHPersonality 
 return EHPersonality::MSVC_CxxFrameHandler3;
   if (L.SEHExceptions)
 return EHPersonality::GNU_CPlusPlus_SEH;
-  if (T.getArch() == llvm::Triple::wasm32 ||
-  T.getArch() == llvm::Triple::wasm64)
+  // Wasm EH is a non-MVP feature for now.
+  if (Target.hasFeature("exception-handling") &&
+  (T.getArch() == llvm::Triple::wasm32 ||
+   T.getArch() == llvm::Triple::wasm64))
 return EHPersonality::GNU_Wasm_CPlusPlus;
   return EHPersonality::GNU_CPlusPlus;
 }
@@ -172,12 +175,13 @@ static const EHPersonality 
 /// Determines the personality function to use when both C++
 /// and Objective-C exceptions are being caught.
 static const EHPersonality (const llvm::Triple ,
- const LangOptions ) {
+ const LangOptions ,
+ const TargetInfo ) {
   switch (L.ObjCRuntime.getKind()) {
   // In the fragile ABI, just use C++ exception handling and hope
   // they're not doing crazy exception mixing.
   case ObjCRuntime::FragileMacOSX:
-return getCXXPersonality(T, L);
+return getCXXPersonality(T, L, Target);
 
   // The ObjC personality defers to the C++ personality for non-ObjC
   // handlers.  Unlike the C++ case, we use the same personality
@@ -209,14 +213,16 @@ const EHPersonality ::get(
 const FunctionDecl *FD) {
   const llvm::Triple  = CGM.getTarget().getTriple();
   const LangOptions  = CGM.getLangOpts();
+  const TargetInfo  = CGM.getTarget();
 
   // Functions using SEH get an SEH personality.
   if (FD && FD->usesSEHTry())
 return getSEHPersonalityMSVC(T);
 
   if (L.ObjC1)
-return L.CPlusPlus ? getObjCXXPersonality(T, L) : getObjCPersonality(T, L);
-  return L.CPlusPlus ? getCXXPersonality(T, L) : getCPersonality(T, L);
+return L.CPlusPlus ? getObjCXXPersonality(T, L, Target)
+   : getObjCPersonality(T, L);
+  return L.CPlusPlus ? getCXXPersonality(T, L, Target) : getCPersonality(T, L);
 }
 
 const EHPersonality ::get(CodeGenFunction ) {
@@ -313,7 +319,7 @@ void CodeGenModule::SimplifyPersonality(
 
   const EHPersonality  = EHPersonality::get(*this, /*FD=*/nullptr);
   const EHPersonality  =
-  getCXXPersonality(getTarget().getTriple(), LangOpts);
+  getCXXPersonality(getTarget().getTriple(), LangOpts, getTarget());
   if ( == )
 return;
 

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=333716=333715=333716=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Thu May 31 18:01:37 2018
@@ -4102,7 +4102,8 @@ ItaniumCXXABI::LoadVTablePtr(CodeGenFunc
 
 void WebAssemblyCXXABI::emitBeginCatch(CodeGenFunction ,
const CXXCatchStmt *C) {
-  CGF.EHStack.pushCleanup(
-  NormalCleanup, cast(CGF.CurrentFuncletPad));
+  if (CGF.getTarget().hasFeature("exception-handling"))
+CGF.EHStack.pushCleanup(
+NormalCleanup, cast(CGF.CurrentFuncletPad));
   ItaniumCXXABI::emitBeginCatch(CGF, C);
 }

Modified: cfe/trunk/test/CodeGenCXX/wasm-eh.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/wasm-eh.cpp?rev=333716=333715=333716=diff

[PATCH] D47614: [WebAssembly] Hide new Wasm EH behind its feature flag

2018-05-31 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin updated this revision to Diff 149386.
aheejin added a comment.

- Add a missing conditional statement. I'll still assume this as accepted


Repository:
  rC Clang

https://reviews.llvm.org/D47614

Files:
  lib/CodeGen/CGException.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/wasm-eh.cpp


Index: test/CodeGenCXX/wasm-eh.cpp
===
--- test/CodeGenCXX/wasm-eh.cpp
+++ test/CodeGenCXX/wasm-eh.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions 
-fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
-// RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions 
-fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions 
-fexceptions -fcxx-exceptions -target-feature +exception-handling -emit-llvm -o 
- -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions 
-fexceptions -fcxx-exceptions -target-feature +exception-handling -emit-llvm -o 
- -std=c++11 | FileCheck %s
 
 void may_throw();
 void dont_throw() noexcept;
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -4102,7 +4102,8 @@
 
 void WebAssemblyCXXABI::emitBeginCatch(CodeGenFunction ,
const CXXCatchStmt *C) {
-  CGF.EHStack.pushCleanup(
-  NormalCleanup, cast(CGF.CurrentFuncletPad));
+  if (CGF.getTarget().hasFeature("exception-handling"))
+CGF.EHStack.pushCleanup(
+NormalCleanup, cast(CGF.CurrentFuncletPad));
   ItaniumCXXABI::emitBeginCatch(CGF, C);
 }
Index: lib/CodeGen/CGException.cpp
===
--- lib/CodeGen/CGException.cpp
+++ lib/CodeGen/CGException.cpp
@@ -154,30 +154,34 @@
 }
 
 static const EHPersonality (const llvm::Triple ,
-  const LangOptions ) {
+  const LangOptions ,
+  const TargetInfo ) {
   if (L.SjLjExceptions)
 return EHPersonality::GNU_CPlusPlus_SJLJ;
   if (L.DWARFExceptions)
 return EHPersonality::GNU_CPlusPlus;
   if (T.isWindowsMSVCEnvironment())
 return EHPersonality::MSVC_CxxFrameHandler3;
   if (L.SEHExceptions)
 return EHPersonality::GNU_CPlusPlus_SEH;
-  if (T.getArch() == llvm::Triple::wasm32 ||
-  T.getArch() == llvm::Triple::wasm64)
+  // Wasm EH is a non-MVP feature for now.
+  if (Target.hasFeature("exception-handling") &&
+  (T.getArch() == llvm::Triple::wasm32 ||
+   T.getArch() == llvm::Triple::wasm64))
 return EHPersonality::GNU_Wasm_CPlusPlus;
   return EHPersonality::GNU_CPlusPlus;
 }
 
 /// Determines the personality function to use when both C++
 /// and Objective-C exceptions are being caught.
 static const EHPersonality (const llvm::Triple ,
- const LangOptions ) {
+ const LangOptions ,
+ const TargetInfo ) {
   switch (L.ObjCRuntime.getKind()) {
   // In the fragile ABI, just use C++ exception handling and hope
   // they're not doing crazy exception mixing.
   case ObjCRuntime::FragileMacOSX:
-return getCXXPersonality(T, L);
+return getCXXPersonality(T, L, Target);
 
   // The ObjC personality defers to the C++ personality for non-ObjC
   // handlers.  Unlike the C++ case, we use the same personality
@@ -209,14 +213,16 @@
 const FunctionDecl *FD) {
   const llvm::Triple  = CGM.getTarget().getTriple();
   const LangOptions  = CGM.getLangOpts();
+  const TargetInfo  = CGM.getTarget();
 
   // Functions using SEH get an SEH personality.
   if (FD && FD->usesSEHTry())
 return getSEHPersonalityMSVC(T);
 
   if (L.ObjC1)
-return L.CPlusPlus ? getObjCXXPersonality(T, L) : getObjCPersonality(T, L);
-  return L.CPlusPlus ? getCXXPersonality(T, L) : getCPersonality(T, L);
+return L.CPlusPlus ? getObjCXXPersonality(T, L, Target)
+   : getObjCPersonality(T, L);
+  return L.CPlusPlus ? getCXXPersonality(T, L, Target) : getCPersonality(T, L);
 }
 
 const EHPersonality ::get(CodeGenFunction ) {
@@ -313,7 +319,7 @@
 
   const EHPersonality  = EHPersonality::get(*this, /*FD=*/nullptr);
   const EHPersonality  =
-  getCXXPersonality(getTarget().getTriple(), LangOpts);
+  getCXXPersonality(getTarget().getTriple(), LangOpts, getTarget());
   if ( == )
 return;
 


Index: test/CodeGenCXX/wasm-eh.cpp
===
--- test/CodeGenCXX/wasm-eh.cpp
+++ test/CodeGenCXX/wasm-eh.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions 

[PATCH] D45517: [analyzer] False positive refutation with Z3

2018-05-31 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added inline comments.



Comment at: 
include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h:183
+  virtual void reset() {}
+  virtual bool isModelFeasible() { return true; }
+  virtual void addRangeConstraints(ConstraintRangeTy) {}

mikhail.ramalho wrote:
> george.karpenkov wrote:
> > Making those virtual does not make much sense to me.
> > Returning `true` by default is not correct.
> > When we are using the visitor, we should already know we have a 
> > `Z3ConstraintsManager`, why can't we just use methods of that class?
> Z3ConstraintManager is fully contained inside a .cpp file, so we need 
> isModelFeasible and addRangeConstraints to be exposed via its base class.
> 
> Another solution is to split Z3ConstraintManager into a .h and a .cpp file 
> and include the header. We would then be able to use it directly, instead of 
> through a ConstraintManager object.
> 
> I honestly prefer the latter. What do you think?
Yeah, I think we would need a header here.
In general we try to avoid inheritance and virtual functions unless they are 
very beneficial, and here they are not.



Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:2391
+if (!RefutationMgr->isModelFeasible())
+  BR.markInvalid("Infeasible constraints", N->getLocationContext());
+  }

mikhail.ramalho wrote:
> george.karpenkov wrote:
> > That would be checking all constraints in all nodes one by one. I thought 
> > the idea was to encode all constraints from the entire path and then check 
> > all of it.
> All the constraints are being added in the previous for loop, isModelFeasible 
> only calls check().
Ah right, I see we are inside of the branch when `pred_size() == 0`.
Sorry, I was wrong -- but could we move out this code to a private function 
(could also simply use static function to avoid polluting the header)?


https://reviews.llvm.org/D45517



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


[PATCH] D47614: [WebAssembly] Hide new Wasm EH behind its feature flag

2018-05-31 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin created this revision.
aheejin added reviewers: dschuff, majnemer.
Herald added subscribers: cfe-commits, sunfish, jgravelle-google, sbc100.

clang's current wasm EH implementation is a non-MVP feature in progress.
We had a `-mexception-handling` wasm feature but were not using it. This
patch hides the non-MVP wasm EH behind a flag, so it does not affect
other code for now.


Repository:
  rC Clang

https://reviews.llvm.org/D47614

Files:
  lib/CodeGen/CGException.cpp
  test/CodeGenCXX/wasm-eh.cpp


Index: test/CodeGenCXX/wasm-eh.cpp
===
--- test/CodeGenCXX/wasm-eh.cpp
+++ test/CodeGenCXX/wasm-eh.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions 
-fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
-// RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions 
-fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions 
-fexceptions -fcxx-exceptions -target-feature +exception-handling -emit-llvm -o 
- -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions 
-fexceptions -fcxx-exceptions -target-feature +exception-handling -emit-llvm -o 
- -std=c++11 | FileCheck %s
 
 void may_throw();
 void dont_throw() noexcept;
Index: lib/CodeGen/CGException.cpp
===
--- lib/CodeGen/CGException.cpp
+++ lib/CodeGen/CGException.cpp
@@ -154,30 +154,34 @@
 }
 
 static const EHPersonality (const llvm::Triple ,
-  const LangOptions ) {
+  const LangOptions ,
+  const TargetInfo ) {
   if (L.SjLjExceptions)
 return EHPersonality::GNU_CPlusPlus_SJLJ;
   if (L.DWARFExceptions)
 return EHPersonality::GNU_CPlusPlus;
   if (T.isWindowsMSVCEnvironment())
 return EHPersonality::MSVC_CxxFrameHandler3;
   if (L.SEHExceptions)
 return EHPersonality::GNU_CPlusPlus_SEH;
-  if (T.getArch() == llvm::Triple::wasm32 ||
-  T.getArch() == llvm::Triple::wasm64)
+  // Wasm EH is a non-MVP feature for now.
+  if (Target.hasFeature("exception-handling") &&
+  (T.getArch() == llvm::Triple::wasm32 ||
+   T.getArch() == llvm::Triple::wasm64))
 return EHPersonality::GNU_Wasm_CPlusPlus;
   return EHPersonality::GNU_CPlusPlus;
 }
 
 /// Determines the personality function to use when both C++
 /// and Objective-C exceptions are being caught.
 static const EHPersonality (const llvm::Triple ,
- const LangOptions ) {
+ const LangOptions ,
+ const TargetInfo ) {
   switch (L.ObjCRuntime.getKind()) {
   // In the fragile ABI, just use C++ exception handling and hope
   // they're not doing crazy exception mixing.
   case ObjCRuntime::FragileMacOSX:
-return getCXXPersonality(T, L);
+return getCXXPersonality(T, L, Target);
 
   // The ObjC personality defers to the C++ personality for non-ObjC
   // handlers.  Unlike the C++ case, we use the same personality
@@ -209,14 +213,16 @@
 const FunctionDecl *FD) {
   const llvm::Triple  = CGM.getTarget().getTriple();
   const LangOptions  = CGM.getLangOpts();
+  const TargetInfo  = CGM.getTarget();
 
   // Functions using SEH get an SEH personality.
   if (FD && FD->usesSEHTry())
 return getSEHPersonalityMSVC(T);
 
   if (L.ObjC1)
-return L.CPlusPlus ? getObjCXXPersonality(T, L) : getObjCPersonality(T, L);
-  return L.CPlusPlus ? getCXXPersonality(T, L) : getCPersonality(T, L);
+return L.CPlusPlus ? getObjCXXPersonality(T, L, Target)
+   : getObjCPersonality(T, L);
+  return L.CPlusPlus ? getCXXPersonality(T, L, Target) : getCPersonality(T, L);
 }
 
 const EHPersonality ::get(CodeGenFunction ) {
@@ -313,7 +319,7 @@
 
   const EHPersonality  = EHPersonality::get(*this, /*FD=*/nullptr);
   const EHPersonality  =
-  getCXXPersonality(getTarget().getTriple(), LangOpts);
+  getCXXPersonality(getTarget().getTriple(), LangOpts, getTarget());
   if ( == )
 return;
 


Index: test/CodeGenCXX/wasm-eh.cpp
===
--- test/CodeGenCXX/wasm-eh.cpp
+++ test/CodeGenCXX/wasm-eh.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
-// RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -target-feature +exception-handling -emit-llvm -o - -std=c++11 | FileCheck %s
+// RUN: 

r333715 - [Coverage] End deferred regions before labels, fixes PR35867

2018-05-31 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu May 31 17:37:13 2018
New Revision: 333715

URL: http://llvm.org/viewvc/llvm-project?rev=333715=rev
Log:
[Coverage] End deferred regions before labels, fixes PR35867

A deferred region should end before the start of a label, and should not
extend to the start of the label sub-statement.

Fixes llvm.org/PR35867.

Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
cfe/trunk/test/CoverageMapping/label.cpp

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=333715=333714=333715=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Thu May 31 17:37:13 2018
@@ -872,6 +872,7 @@ struct CounterCoverageMappingBuilder
 Counter LabelCount = getRegionCounter(S);
 SourceLocation Start = getStart(S);
 completeTopLevelDeferredRegion(LabelCount, Start);
+completeDeferred(LabelCount, Start);
 // We can't extendRegion here or we risk overlapping with our new region.
 handleFileExit(Start);
 pushRegion(LabelCount, Start);

Modified: cfe/trunk/test/CoverageMapping/label.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/label.cpp?rev=333715=333714=333715=diff
==
--- cfe/trunk/test/CoverageMapping/label.cpp (original)
+++ cfe/trunk/test/CoverageMapping/label.cpp Thu May 31 17:37:13 2018
@@ -69,3 +69,12 @@ int main() { // CHECK-NE
   test1(0);
   test2(2);
 }
+
+// CHECK-LABEL: _Z5test3v:
+#define a b
+void test3() {
+  if (0)
+goto b; // CHECK: Gap,File 0, [[@LINE]]:11 -> [[@LINE+1]]:1 = 
[[retnCount:#[0-9]+]]
+a: // CHECK-NEXT: Expansion,File 0, [[@LINE]]:1 -> [[@LINE]]:2 = [[retnCount]] 
(Expanded file = 1)
+  return; // CHECK-NEXT: File 0, [[@LINE-1]]:2 -> [[@LINE]]:9 = [[retnCount]]
+}


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


[PATCH] D47394: [OpenMP][Clang][NVPTX] Replace bundling with partial linking for the OpenMP NVPTX device offloading toolchain

2018-05-31 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

The error is related to lack of device linking, just like you explained two 
paragraphs down. This is the error I get:

  main.o: In function `__cuda_module_ctor':
  main.cu:(.text+0x674): undefined reference to 
`__cudaRegisterLinkedBinary__nv_c5b75865'

You nailed the problem on the head: the device linking step is the tricky bit.

The OpenMP toolchain has the advantage that it already calls NVLINK (upstreamed 
a long time ago). This patch doesn't change that. This patch "fixes" (for a 
lack of a better word) the way in which objects are created on the device side. 
By adding the FATBINARY + CLANG++ steps to the device toolchain, I ensure that 
the existing call to NVLINK will be able to "detect" the device-part of 
individual or archived objects. This is not a valid statement in today's 
compiler in which NVLINK would not be able to do so with archived objects 
(static libs).

In general, for offloading toolchains, I don't see the reliance on vendor 
specific tools as a problem **if and only if** the calls to vendor-specific 
tools remain confined to a device-speicifc toolchain. This patch respects this 
condition. All the calls to CUDA tools in this patch are part of the OpenMP 
NVPTX device offloading toolchain (which is an NVPTX device specific toolchain).

The only host-side change is the call to "ld -r" which replaces a call to the 
"openmp-offload-bundler" tool.


Repository:
  rC Clang

https://reviews.llvm.org/D47394



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


[PATCH] D46485: Add python tool to dump and construct header maps

2018-05-31 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Ping.

Without this patch, we would have to add binary header maps for tests in 
https://reviews.llvm.org/D47157 and https://reviews.llvm.org/D47301, which I 
would like to avoid.


https://reviews.llvm.org/D46485



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


r333712 - [WebAssembly] Update to the new names for the memory builtin functions.

2018-05-31 Thread Dan Gohman via cfe-commits
Author: djg
Date: Thu May 31 17:05:51 2018
New Revision: 333712

URL: http://llvm.org/viewvc/llvm-project?rev=333712=rev
Log:
[WebAssembly] Update to the new names for the memory builtin functions.

The WebAssembly committee has decided on the names `memory.size` and
`memory.grow` for the memory intrinsics, so update the clang builtin
functions to follow those names, keeping both sets of old names in place
for compatibility.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins-wasm.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def?rev=333712=333711=333712=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def Thu May 31 17:05:51 
2018
@@ -17,15 +17,16 @@
 // The format of this database matches clang/Basic/Builtins.def.
 
 // Query the current memory size, and increase the current memory size.
-// Note that mem.size is not "c" (readnone) because it must be sequenced
-// with respect to grow_memory calls.
-// These are the new proposed names, which aren't yet official. Use at your own
-// risk.
+// Note that memory.size is not "c" (readnone) because it must be sequenced
+// with respect to memory.grow calls.
+BUILTIN(__builtin_wasm_memory_size, "zIi", "n")
+BUILTIN(__builtin_wasm_memory_grow, "zIiz", "n")
+
+// These are the old names.
 BUILTIN(__builtin_wasm_mem_size, "zIi", "n")
 BUILTIN(__builtin_wasm_mem_grow, "zIiz", "n")
 
-// These are the existing names, which are currently official, but expected
-// to be deprecated in the future. They also lack the immediate field.
+// These are the old old names. They also lack the immediate field.
 BUILTIN(__builtin_wasm_current_memory, "z", "n")
 BUILTIN(__builtin_wasm_grow_memory, "zz", "n")
 

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=333712=333711=333712=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu May 31 17:05:51 2018
@@ -11221,6 +11221,21 @@ Value *CodeGenFunction::EmitNVPTXBuiltin
 Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
const CallExpr *E) {
   switch (BuiltinID) {
+  case WebAssembly::BI__builtin_wasm_memory_size: {
+llvm::Type *ResultType = ConvertType(E->getType());
+Value *I = EmitScalarExpr(E->getArg(0));
+Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_memory_size, ResultType);
+return Builder.CreateCall(Callee, I);
+  }
+  case WebAssembly::BI__builtin_wasm_memory_grow: {
+llvm::Type *ResultType = ConvertType(E->getType());
+Value *Args[] = {
+  EmitScalarExpr(E->getArg(0)),
+  EmitScalarExpr(E->getArg(1))
+};
+Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_memory_grow, ResultType);
+return Builder.CreateCall(Callee, Args);
+  }
   case WebAssembly::BI__builtin_wasm_mem_size: {
 llvm::Type *ResultType = ConvertType(E->getType());
 Value *I = EmitScalarExpr(E->getArg(0));

Modified: cfe/trunk/test/CodeGen/builtins-wasm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-wasm.c?rev=333712=333711=333712=diff
==
--- cfe/trunk/test/CodeGen/builtins-wasm.c (original)
+++ cfe/trunk/test/CodeGen/builtins-wasm.c Thu May 31 17:05:51 2018
@@ -4,36 +4,48 @@
 // RUN:   | FileCheck %s -check-prefix=WEBASSEMBLY64
 
 __SIZE_TYPE__ f0(void) {
+  return __builtin_wasm_memory_size(0);
+// WEBASSEMBLY32: call {{i.*}} @llvm.wasm.memory.size.i32(i32 0)
+// WEBASSEMBLY64: call {{i.*}} @llvm.wasm.memory.size.i64(i32 0)
+}
+
+__SIZE_TYPE__ f1(__SIZE_TYPE__ delta) {
+  return __builtin_wasm_memory_grow(0, delta);
+// WEBASSEMBLY32: call i32 @llvm.wasm.memory.grow.i32(i32 0, i32 %{{.*}})
+// WEBASSEMBLY64: call i64 @llvm.wasm.memory.grow.i64(i32 0, i64 %{{.*}})
+}
+
+__SIZE_TYPE__ f2(void) {
   return __builtin_wasm_mem_size(0);
 // WEBASSEMBLY32: call {{i.*}} @llvm.wasm.mem.size.i32(i32 0)
 // WEBASSEMBLY64: call {{i.*}} @llvm.wasm.mem.size.i64(i32 0)
 }
 
-__SIZE_TYPE__ f1(__SIZE_TYPE__ delta) {
+__SIZE_TYPE__ f3(__SIZE_TYPE__ delta) {
   return __builtin_wasm_mem_grow(0, delta);
 // WEBASSEMBLY32: call i32 @llvm.wasm.mem.grow.i32(i32 0, i32 %{{.*}})
 // WEBASSEMBLY64: call i64 @llvm.wasm.mem.grow.i64(i32 0, i64 %{{.*}})
 }
 
-__SIZE_TYPE__ f2(void) {
+__SIZE_TYPE__ f4(void) {
   return __builtin_wasm_current_memory();
 // WEBASSEMBLY32: call {{i.*}} @llvm.wasm.current.memory.i32()
 // WEBASSEMBLY64: call {{i.*}} @llvm.wasm.current.memory.i64()
 }
 
-__SIZE_TYPE__ 

[PATCH] D45517: [analyzer] False positive refutation with Z3

2018-05-31 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho added inline comments.



Comment at: 
include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h:183
+  virtual void reset() {}
+  virtual bool isModelFeasible() { return true; }
+  virtual void addRangeConstraints(ConstraintRangeTy) {}

george.karpenkov wrote:
> Making those virtual does not make much sense to me.
> Returning `true` by default is not correct.
> When we are using the visitor, we should already know we have a 
> `Z3ConstraintsManager`, why can't we just use methods of that class?
Z3ConstraintManager is fully contained inside a .cpp file, so we need 
isModelFeasible and addRangeConstraints to be exposed via its base class.

Another solution is to split Z3ConstraintManager into a .h and a .cpp file and 
include the header. We would then be able to use it directly, instead of 
through a ConstraintManager object.

I honestly prefer the latter. What do you think?


https://reviews.llvm.org/D45517



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


[PATCH] D47564: [Parse] Use CapturedStmt for @finally on MSVC

2018-05-31 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

That's an interesting idea.  I don't see any particular reason not to do it 
this way if you're willing to accept that it's never going to support the full 
control-flow possibilities of @finally.  You will need to add JumpDiagnostics 
logic to prevent branches out of the block, and I don't know how this will 
interact with attempts to throw an exception out.


Repository:
  rC Clang

https://reviews.llvm.org/D47564



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


[PATCH] D47613: Mark __c11_atomic_load as const

2018-05-31 Thread JF Bastien via Phabricator via cfe-commits
jfb created this revision.
jfb added reviewers: EricWF, mclow.lists.
Herald added subscribers: cfe-commits, christof.

C++11 onwards specs the non-member functions atomic_load and 
atomic_load_explicit as taking the atomic by const (potentially volatile) 
pointer. C11, in its infinite wisdom, decided to drop the const, and C17 will 
fix this with DR459 (the current draft forgot to fix B.16, but that’s not the 
normative part).

This patch fixes the libc++ version of the __c11_atomic_load builtins defined 
for GCC's compatibility sake.

Discussion: http://lists.llvm.org/pipermail/cfe-dev/2018-May/058129.html

rdar://problem/27426936


Repository:
  rCXX libc++

https://reviews.llvm.org/D47613

Files:
  include/atomic


Index: include/atomic
===
--- include/atomic
+++ include/atomic
@@ -698,16 +698,16 @@
 }
 
 template 
-static inline _Tp __c11_atomic_load(volatile _Atomic(_Tp)* __a,
+static inline _Tp __c11_atomic_load(const volatile _Atomic(_Tp)* __a,
 memory_order __order) {
   _Tp __ret;
   __atomic_load(&__a->__a_value, &__ret,
 __gcc_atomic::__to_gcc_order(__order));
   return __ret;
 }
 
 template 
-static inline _Tp __c11_atomic_load(_Atomic(_Tp)* __a, memory_order __order) {
+static inline _Tp __c11_atomic_load(const _Atomic(_Tp)* __a, memory_order 
__order) {
   _Tp __ret;
   __atomic_load(&__a->__a_value, &__ret,
 __gcc_atomic::__to_gcc_order(__order));


Index: include/atomic
===
--- include/atomic
+++ include/atomic
@@ -698,16 +698,16 @@
 }
 
 template 
-static inline _Tp __c11_atomic_load(volatile _Atomic(_Tp)* __a,
+static inline _Tp __c11_atomic_load(const volatile _Atomic(_Tp)* __a,
 memory_order __order) {
   _Tp __ret;
   __atomic_load(&__a->__a_value, &__ret,
 __gcc_atomic::__to_gcc_order(__order));
   return __ret;
 }
 
 template 
-static inline _Tp __c11_atomic_load(_Atomic(_Tp)* __a, memory_order __order) {
+static inline _Tp __c11_atomic_load(const _Atomic(_Tp)* __a, memory_order __order) {
   _Tp __ret;
   __atomic_load(&__a->__a_value, &__ret,
 __gcc_atomic::__to_gcc_order(__order));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45517: [analyzer] False positive refutation with Z3

2018-05-31 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added inline comments.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:925
 
+  void reset() override { Solver.reset(); }
+

mikhail.ramalho wrote:
> george.karpenkov wrote:
> > We don't need `reset` anymore.
> We don't need it but there's no reason to remove it, right? I might be useful 
> in the future.
We try to keep the code as small and as simple as possible so that it still 
achieves the task -- under that logic, unused methods should not be added.
I dislike `reset` in particular as it encourages stateful approach where the 
same instance is used for all queries, which increases the likelihood of bugs.


https://reviews.llvm.org/D45517



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


[PATCH] D47557: Filesystem tests: un-confuse write time

2018-05-31 Thread JF Bastien via Phabricator via cfe-commits
jfb updated this revision to Diff 149377.
jfb added a comment.

- Remove access time checks, simplify existing check, after talking to EricWF 
on IRC.


Repository:
  rCXX libc++

https://reviews.llvm.org/D47557

Files:
  
test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp


Index: 
test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
===
--- 
test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
+++ 
test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
@@ -32,7 +32,9 @@
 
 using namespace fs;
 
-std::pair GetTimes(path const& p) {
+struct Times { std::time_t access, write; };
+
+Times GetTimes(path const& p) {
 using Clock = file_time_type::clock;
 struct ::stat st;
 if (::stat(p.c_str(), ) == -1) {
@@ -48,11 +50,11 @@
 }
 
 std::time_t LastAccessTime(path const& p) {
-return GetTimes(p).first;
+return GetTimes(p).access;
 }
 
 std::time_t LastWriteTime(path const& p) {
-return GetTimes(p).second;
+return GetTimes(p).write;
 }
 
 std::pair GetSymlinkTimes(path const& p) {
@@ -228,11 +230,9 @@
 const path dir = env.create_dir("dir");
 
 const auto file_times = GetTimes(file);
-const std::time_t file_access_time = file_times.first;
-const std::time_t file_write_time = file_times.second;
+const std::time_t file_write_time = file_times.write;
 const auto dir_times = GetTimes(dir);
-const std::time_t dir_access_time = dir_times.first;
-const std::time_t dir_write_time = dir_times.second;
+const std::time_t dir_write_time = dir_times.write;
 
 file_time_type ftime = last_write_time(file);
 TEST_CHECK(Clock::to_time_t(ftime) == file_write_time);
@@ -253,9 +253,7 @@
 
 TEST_CHECK(ftime2 > ftime);
 TEST_CHECK(dtime2 > dtime);
-TEST_CHECK(LastAccessTime(file) == file_access_time ||
-   LastAccessTime(file) == Clock::to_time_t(ftime2));
-TEST_CHECK(LastAccessTime(dir) == dir_access_time);
+TEST_CHECK(LastWriteTime(file) == Clock::to_time_t(ftime2));
 }
 
 
@@ -301,7 +299,7 @@
 };
 for (const auto& TC : cases) {
 const auto old_times = GetTimes(TC.p);
-file_time_type old_time(Sec(old_times.second));
+file_time_type old_time(Sec(old_times.write));
 
 std::error_code ec = GetTestEC();
 last_write_time(TC.p, TC.new_time, ec);
@@ -318,7 +316,7 @@
 TEST_CHECK(got_time <= TC.new_time + Sec(1));
 TEST_CHECK(got_time >= TC.new_time - Sec(1));
 }
-TEST_CHECK(LastAccessTime(TC.p) == old_times.first);
+TEST_CHECK(LastAccessTime(TC.p) == old_times.access);
 }
 }
 }
@@ -348,10 +346,10 @@
 file_time_type  got_time = last_write_time(sym);
 std::time_t got_time_t = Clock::to_time_t(got_time);
 
-TEST_CHECK(got_time_t != old_times.second);
+TEST_CHECK(got_time_t != old_times.write);
 TEST_CHECK(got_time_t == new_time_t);
 TEST_CHECK(LastWriteTime(file) == new_time_t);
-TEST_CHECK(LastAccessTime(sym) == old_times.first);
+TEST_CHECK(LastAccessTime(sym) == old_times.access);
 TEST_CHECK(GetSymlinkTimes(sym) == old_sym_times);
 }
 


Index: test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
===
--- test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
+++ test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
@@ -32,7 +32,9 @@
 
 using namespace fs;
 
-std::pair GetTimes(path const& p) {
+struct Times { std::time_t access, write; };
+
+Times GetTimes(path const& p) {
 using Clock = file_time_type::clock;
 struct ::stat st;
 if (::stat(p.c_str(), ) == -1) {
@@ -48,11 +50,11 @@
 }
 
 std::time_t LastAccessTime(path const& p) {
-return GetTimes(p).first;
+return GetTimes(p).access;
 }
 
 std::time_t LastWriteTime(path const& p) {
-return GetTimes(p).second;
+return GetTimes(p).write;
 }
 
 std::pair GetSymlinkTimes(path const& p) {
@@ -228,11 +230,9 @@
 const path dir = env.create_dir("dir");
 
 const auto file_times = GetTimes(file);
-const std::time_t file_access_time = file_times.first;
-const std::time_t file_write_time = file_times.second;
+const std::time_t file_write_time = file_times.write;
 const auto dir_times = GetTimes(dir);
-const std::time_t dir_access_time = dir_times.first;
-const std::time_t dir_write_time = dir_times.second;
+const std::time_t dir_write_time = dir_times.write;
 
 file_time_type ftime = last_write_time(file);
 TEST_CHECK(Clock::to_time_t(ftime) == file_write_time);
@@ -253,9 +253,7 @@
 
 TEST_CHECK(ftime2 > ftime);
 TEST_CHECK(dtime2 > dtime);
-

[PATCH] D45517: [analyzer] False positive refutation with Z3

2018-05-31 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho added inline comments.



Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:2391
+if (!RefutationMgr->isModelFeasible())
+  BR.markInvalid("Infeasible constraints", N->getLocationContext());
+  }

george.karpenkov wrote:
> That would be checking all constraints in all nodes one by one. I thought the 
> idea was to encode all constraints from the entire path and then check all of 
> it.
All the constraints are being added in the previous for loop, isModelFeasible 
only calls check().



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:925
 
+  void reset() override { Solver.reset(); }
+

george.karpenkov wrote:
> We don't need `reset` anymore.
We don't need it but there's no reason to remove it, right? I might be useful 
in the future.


https://reviews.llvm.org/D45517



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


[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-05-31 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 149373.

https://reviews.llvm.org/D43667

Files:
  clang-doc/CMakeLists.txt
  clang-doc/Generators.cpp
  clang-doc/Generators.h
  clang-doc/Representation.h
  clang-doc/YAMLGenerator.cpp
  clang-doc/tool/ClangDocMain.cpp
  test/clang-doc/yaml-comments.cpp
  test/clang-doc/yaml-namespace.cpp
  test/clang-doc/yaml-record.cpp

Index: test/clang-doc/yaml-record.cpp
===
--- /dev/null
+++ test/clang-doc/yaml-record.cpp
@@ -0,0 +1,250 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: cat %t/docs/A.yaml | FileCheck %s --check-prefix=CHECK-A
+// RUN: cat %t/docs/Bc.yaml | FileCheck %s --check-prefix=CHECK-BC
+// RUN: cat %t/docs/B.yaml | FileCheck %s --check-prefix=CHECK-B
+// RUN: cat %t/docs/C.yaml | FileCheck %s --check-prefix=CHECK-C
+// RUN: cat %t/docs/D.yaml | FileCheck %s --check-prefix=CHECK-D
+// RUN: cat %t/docs/E.yaml | FileCheck %s --check-prefix=CHECK-E
+// RUN: cat %t/docs/E/ProtectedMethod.yaml | FileCheck %s --check-prefix=CHECK-EPM
+// RUN: cat %t/docs/E/E.yaml | FileCheck %s --check-prefix=CHECK-ECON
+// RUN: cat %t/docs/E/'~E.yaml' | FileCheck %s --check-prefix=CHECK-EDES
+// RUN: cat %t/docs/F.yaml | FileCheck %s --check-prefix=CHECK-F
+// RUN: cat %t/docs/X.yaml | FileCheck %s --check-prefix=CHECK-X
+// RUN: cat %t/docs/X/Y.yaml | FileCheck %s --check-prefix=CHECK-Y
+// RUN: cat %t/docs/H.yaml | FileCheck %s --check-prefix=CHECK-H
+// RUN: cat %t/docs/H/I.yaml | FileCheck %s --check-prefix=CHECK-I
+
+union A { int X; int Y; };
+
+// CHECK-A: ---
+// CHECK-A-NEXT: USR: 'ACE81AFA6627B4CEF2B456FB6E1252925674AF7E'
+// CHECK-A-NEXT: Name:'A'
+// CHECK-A-NEXT: DefLocation: 
+// CHECK-A-NEXT:   LineNumber:  21
+// CHECK-A-NEXT:   Filename:'{{.*}}'
+// CHECK-A-NEXT: TagType: Union
+// CHECK-A-NEXT: Members: 
+// CHECK-A-NEXT:   - Type:
+// CHECK-A-NEXT:   Name:'int'
+// CHECK-A-NEXT: Name:'X'
+// CHECK-A-NEXT:   - Type:
+// CHECK-A-NEXT:   Name:'int'
+// CHECK-A-NEXT: Name:'Y'
+// CHECK-A-NEXT: ...
+
+
+enum B { X, Y };
+
+// CHECK-B: ---
+// CHECK-B-NEXT: USR: 'FC07BD34D5E77782C263FA97929EA8753740'
+// CHECK-B-NEXT: Name:'B'
+// CHECK-B-NEXT: DefLocation: 
+// CHECK-B-NEXT:   LineNumber:  40
+// CHECK-B-NEXT:   Filename:'{{.*}}'
+// CHECK-B-NEXT: Members: 
+// CHECK-B-NEXT:   - 'X'
+// CHECK-B-NEXT:   - 'Y'
+// CHECK-B-NEXT: ...
+
+enum class Bc { A, B };
+
+// CHECK-BC: ---
+// CHECK-BC-NEXT: USR: '1E3438A08BA22025C0B46289FF0686F92C8924C5'
+// CHECK-BC-NEXT: Name:'Bc'
+// CHECK-BC-NEXT: DefLocation: 
+// CHECK-BC-NEXT:   LineNumber:  53
+// CHECK-BC-NEXT:   Filename:'{{.*}}'
+// CHECK-BC-NEXT: Scoped:  true
+// CHECK-BC-NEXT: Members: 
+// CHECK-BC-NEXT:   - 'A'
+// CHECK-BC-NEXT:   - 'B'
+// CHECK-BC-NEXT: ...
+
+struct C { int i; };
+
+// CHECK-C: ---
+// CHECK-C-NEXT: USR: '06B5F6A19BA9F6A832E127C9968282B94619B210'
+// CHECK-C-NEXT: Name:'C'
+// CHECK-C-NEXT: DefLocation: 
+// CHECK-C-NEXT:   LineNumber:  67
+// CHECK-C-NEXT:   Filename:'{{.*}}'
+// CHECK-C-NEXT: Members: 
+// CHECK-C-NEXT:   - Type:
+// CHECK-C-NEXT:   Name:'int'
+// CHECK-C-NEXT: Name:'i'
+// CHECK-C-NEXT: ...
+
+class D {};
+
+// CHECK-D: ---
+// CHECK-D-NEXT: USR: '0921737541208B8FA9BB42B60F78AC1D779AA054'
+// CHECK-D-NEXT: Name:'D'
+// CHECK-D-NEXT: DefLocation: 
+// CHECK-D-NEXT:   LineNumber:  81
+// CHECK-D-NEXT:   Filename:'{{.*}}'
+// CHECK-D-NEXT: TagType: Class
+// CHECK-D-NEXT: ...
+
+class E {
+public:
+  E() {}
+
+// CHECK-ECON: ---
+// CHECK-ECON-NEXT: USR: 'DEB4AC1CD9253CD9EF7FBE6BCAC506D77984ABD4'
+// CHECK-ECON-NEXT: Name:'E'
+// CHECK-ECON-NEXT: Namespace:   
+// CHECK-ECON-NEXT:   - Type:Record
+// CHECK-ECON-NEXT: Name:'E'
+// CHECK-ECON-NEXT: USR: '289584A8E0FF4178A794622A547AA622503967A1'
+// CHECK-ECON-NEXT: DefLocation:
+// CHECK-ECON-NEXT:   LineNumber:  94
+// CHECK-ECON-NEXT:   Filename:'{{.*}}'
+// CHECK-ECON-NEXT: IsMethod:true
+// CHECK-ECON-NEXT: Parent:  
+// CHECK-ECON-NEXT:   Type:Record
+// CHECK-ECON-NEXT:   Name:'E'
+// CHECK-ECON-NEXT:   USR: '289584A8E0FF4178A794622A547AA622503967A1'
+// CHECK-ECON-NEXT: ReturnType:  
+// CHECK-ECON-NEXT:   Type:
+// CHECK-ECON-NEXT: Name:'void'
+// CHECK-ECON-NEXT: ...
+  
+  ~E() {}
+  
+// CHECK-EDES: ---
+// CHECK-EDES-NEXT: USR: 

[PATCH] D45517: [analyzer] False positive refutation with Z3

2018-05-31 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added inline comments.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:928
+  bool isModelFeasible() override {
+return Solver.check() != Z3_L_FALSE;
+  }

george.karpenkov wrote:
> The semantics of this method is incorrect. It should return a tri-value 
> somehow (e.g. `Optional`, and then higher-level logic in visitor should 
> decide what to do with it.)
We could also use `ConditionTruthVal` for this purpose.


https://reviews.llvm.org/D45517



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


[PATCH] D45517: [analyzer] False positive refutation with Z3

2018-05-31 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov requested changes to this revision.
george.karpenkov added a comment.
This revision now requires changes to proceed.

Thanks, this is going in the right direction!




Comment at: 
include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h:182
 
+  virtual void reset() {}
+  virtual bool isModelFeasible() { return true; }

We don't need reset anymore.



Comment at: 
include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h:183
+  virtual void reset() {}
+  virtual bool isModelFeasible() { return true; }
+  virtual void addRangeConstraints(ConstraintRangeTy) {}

Making those virtual does not make much sense to me.
Returning `true` by default is not correct.
When we are using the visitor, we should already know we have a 
`Z3ConstraintsManager`, why can't we just use methods of that class?



Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:2377
+// Try to create the refutation manager, using Z3
+std::unique_ptr RefutationMgr =
+Opts.shouldCrosscheckWithZ3()

1. RefutationMgr should be created in the visitor constructor.
2. At this point we should not check options; if the visitor is created, we are 
assuming that the option is on.
3. Consequently, the subsequent assert should be dropped.



Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:2391
+if (!RefutationMgr->isModelFeasible())
+  BR.markInvalid("Infeasible constraints", N->getLocationContext());
+  }

That would be checking all constraints in all nodes one by one. I thought the 
idea was to encode all constraints from the entire path and then check all of 
it.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:889
+
+  LLVM_DUMP_METHOD void dump() const { print(llvm::errs()); }
 }; // end class Z3Solver





Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:925
 
+  void reset() override { Solver.reset(); }
+

We don't need `reset` anymore.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:928
+  bool isModelFeasible() override {
+return Solver.check() != Z3_L_FALSE;
+  }

The semantics of this method is incorrect. It should return a tri-value somehow 
(e.g. `Optional`, and then higher-level logic in visitor should decide 
what to do with it.)



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1272
+  // FIXME: fix available in D35450
+  if (RangeTy.isNull())
+continue;

Since https://reviews.llvm.org/D47603 has landed we should drop this branch.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1282
+
+  Z3Expr LHS = getZ3BinExpr(Exp, SymTy, BO_GE, FromExp, RangeTy, nullptr);
+  Z3Expr RHS = getZ3BinExpr(Exp, SymTy, BO_LE, ToExp, RangeTy, nullptr);

/*RetTy=*/nullptr


https://reviews.llvm.org/D45517



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


[PATCH] D46112: Allow _Atomic to be specified on incomplete types

2018-05-31 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

If you don't want to spend too much time on C++, fine; could you add a short 
Objective-C test instead to make sure the trivially-copyable checks are working?

What are the changes to Sema::RequireCompleteTypeImpl supposed to do?




Comment at: test/Sema/atomic-type.c:30
+  int i;
+  (void)__atomic_load(addr, , 5); // expected-error {{address argument to 
atomic operation must be a pointer to a trivially-copyable type ('_Atomic(void) 
*' invalid)}}
+  (void)__c11_atomic_load(addr, 5); // expected-error {{invalid use of 
incomplete type 'void'}}

This error message is terrible; yes, technically 'void' isn't trivially 
copyable, but that isn't really helpful.


https://reviews.llvm.org/D46112



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


[PATCH] D43341: [clang-doc] Implement reducer portion of the frontend framework

2018-05-31 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added inline comments.



Comment at: clang-doc/tool/ClangDocMain.cpp:181
+doc::writeInfo(I.get(), Buffer);
+  if (DumpResultToFile("bc", Group.getKey() + ".bc", Buffer))
+return 1;

ioeric wrote:
> juliehockett wrote:
> > ioeric wrote:
> > > (Sorry that I might be missing context here.)
> > > 
> > > Could you please explain the incentive for dumping each info group to one 
> > > bc file? If the key identifies a symbol (e.g. USR), wouldn't this result 
> > > in a bitcode file being created for each symbol? This doesn't seem very 
> > > scalable.  
> > Yes, it would. This is mostly for debugging, since there's not really any 
> > tools outside the clang system that would actually want/be able to use this 
> > information.
> Ok, is there any plan to convert intermediate result to final result and 
> output in a more accessible format? If so, please add a `FIXME` somewhere 
> just to be clearer.
That's what the next patch set is (to generate YAML).


https://reviews.llvm.org/D43341



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


[PATCH] D43341: [clang-doc] Implement reducer portion of the frontend framework

2018-05-31 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 149371.
juliehockett marked 13 inline comments as done.
juliehockett added a comment.

Fixing comments


https://reviews.llvm.org/D43341

Files:
  clang-doc/BitcodeReader.cpp
  clang-doc/BitcodeReader.h
  clang-doc/BitcodeWriter.cpp
  clang-doc/BitcodeWriter.h
  clang-doc/CMakeLists.txt
  clang-doc/Representation.cpp
  clang-doc/Representation.h
  clang-doc/tool/ClangDocMain.cpp
  docs/ReleaseNotes.rst
  test/clang-doc/bc-comment.cpp
  test/clang-doc/bc-namespace.cpp
  test/clang-doc/bc-record.cpp

Index: test/clang-doc/bc-record.cpp
===
--- /dev/null
+++ test/clang-doc/bc-record.cpp
@@ -0,0 +1,254 @@
+// This test requires Linux due to the system-dependent USR for the
+// inner class in function H.
+// REQUIRES: system-linux
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump-intermediate -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/bc/ACE81AFA6627B4CEF2B456FB6E1252925674AF7E.bc --dump | FileCheck %s --check-prefix CHECK-A
+// RUN: llvm-bcanalyzer %t/docs/bc/FC07BD34D5E77782C263FA97929EA8753740.bc --dump | FileCheck %s --check-prefix CHECK-B
+// RUN: llvm-bcanalyzer %t/docs/bc/1E3438A08BA22025C0B46289FF0686F92C8924C5.bc --dump | FileCheck %s --check-prefix CHECK-BC
+// RUN: llvm-bcanalyzer %t/docs/bc/06B5F6A19BA9F6A832E127C9968282B94619B210.bc --dump | FileCheck %s --check-prefix CHECK-C
+// RUN: llvm-bcanalyzer %t/docs/bc/0921737541208B8FA9BB42B60F78AC1D779AA054.bc --dump | FileCheck %s --check-prefix CHECK-D
+// RUN: llvm-bcanalyzer %t/docs/bc/289584A8E0FF4178A794622A547AA622503967A1.bc --dump | FileCheck %s --check-prefix CHECK-E
+// RUN: llvm-bcanalyzer %t/docs/bc/DEB4AC1CD9253CD9EF7FBE6BCAC506D77984ABD4.bc --dump | FileCheck %s --check-prefix CHECK-ECON
+// RUN: llvm-bcanalyzer %t/docs/bc/BD2BDEBD423F80BACCEA75DE6D6622D355FC2D17.bc --dump | FileCheck %s --check-prefix CHECK-EDES
+// RUN: llvm-bcanalyzer %t/docs/bc/E3B54702FABFF4037025BA194FC27C47006330B5.bc --dump | FileCheck %s --check-prefix CHECK-F
+// RUN: llvm-bcanalyzer %t/docs/bc/B6AC4C5C9F2EA3F2B3ECE1A33D349F4EE502B24E.bc --dump | FileCheck %s --check-prefix CHECK-H
+// RUN: llvm-bcanalyzer %t/docs/bc/6BA1EE2B3DAEACF6E4306F10AF44908F4807927C.bc --dump | FileCheck %s --check-prefix CHECK-I
+// RUN: llvm-bcanalyzer %t/docs/bc/5093D428CDC62096A67547BA52566E4FB9404EEE.bc --dump | FileCheck %s --check-prefix CHECK-PM
+// RUN: llvm-bcanalyzer %t/docs/bc/CA7C7935730B5EACD25F080E9C83FA087CCDC75E.bc --dump | FileCheck %s --check-prefix CHECK-X
+// RUN: llvm-bcanalyzer %t/docs/bc/641AB4A3D36399954ACDE29C7A8833032BF40472.bc --dump | FileCheck %s --check-prefix CHECK-Y
+
+void H() {
+  class I {};
+}
+// CHECK-H: 
+  // CHECK-H-NEXT: 
+  // CHECK-H-NEXT:  blob data = 'H'
+  // CHECK-H-NEXT:  blob data = '{{.*}}'
+  // CHECK-H-NEXT: 
+// CHECK-H-NEXT: 
+  // CHECK-H-NEXT:  blob data = 'void'
+  // CHECK-H-NEXT: 
+// CHECK-H-NEXT: 
+  // CHECK-H-NEXT: 
+// CHECK-H-NEXT: 
+
+
+// CHECK-I: 
+  // CHECK-I-NEXT: 
+  // CHECK-I-NEXT:  blob data = 'I'
+  // CHECK-I-NEXT: 
+// CHECK-I-NEXT: 
+// CHECK-I-NEXT:  blob data = 'H'
+// CHECK-I-NEXT: 
+// CHECK-I-NEXT: 
+  // CHECK-I-NEXT: 
+  // CHECK-I-NEXT:  blob data = '{{.*}}'
+  // CHECK-I-NEXT: 
+// CHECK-I-NEXT: 
+
+union A { int X; int Y; };
+// CHECK-A: 
+  // CHECK-A-NEXT: 
+  // CHECK-A-NEXT:  blob data = 'A'
+  // CHECK-A-NEXT:  blob data = '{{.*}}'
+  // CHECK-A-NEXT: 
+  // CHECK-A-NEXT: 
+// CHECK-A-NEXT: 
+  // CHECK-A-NEXT:  blob data = 'int'
+  // CHECK-A-NEXT: 
+// CHECK-A-NEXT: 
+// CHECK-A-NEXT:  blob data = 'X'
+// CHECK-A-NEXT: 
+  // CHECK-A-NEXT: 
+  // CHECK-A-NEXT: 
+// CHECK-A-NEXT: 
+  // CHECK-A-NEXT:  blob data = 'int'
+  // CHECK-A-NEXT: 
+// CHECK-A-NEXT: 
+// CHECK-A-NEXT:  blob data = 'Y'
+// CHECK-A-NEXT: 
+  // CHECK-A-NEXT: 
+// CHECK-A-NEXT: 
+
+enum B { X, Y };
+// CHECK-B: 
+  // CHECK-B-NEXT: 
+  // CHECK-B-NEXT:  blob data = 'B'
+  // CHECK-B-NEXT:  blob data = '{{.*}}'
+  // CHECK-B-NEXT:  blob data = 'X'
+  // CHECK-B-NEXT:  blob data = 'Y'
+// CHECK-B-NEXT: 
+
+enum class Bc { A, B };
+// CHECK-BC: 
+  // CHECK-BC-NEXT: 
+  // CHECK-BC-NEXT:  blob data = 'Bc'
+  // CHECK-BC-NEXT:  blob data = '{{.*}}'
+  // CHECK-BC-NEXT: 
+  // CHECK-BC-NEXT:  blob data = 'A'
+  // CHECK-BC-NEXT:  blob data = 'B'
+// CHECK-BC-NEXT: 
+
+struct C { int i; };
+// CHECK-C: 
+  // CHECK-C-NEXT: 
+  // CHECK-C-NEXT:  blob data = 'C'
+  // CHECK-C-NEXT:  blob data = '{{.*}}'
+  // CHECK-C-NEXT: 
+// CHECK-C-NEXT: 
+  // CHECK-C-NEXT:  blob data = 'int'
+  // CHECK-C-NEXT: 
+// CHECK-C-NEXT: 
+// CHECK-C-NEXT:  blob data = 'i'
+// CHECK-C-NEXT: 
+  // CHECK-C-NEXT: 
+// CHECK-C-NEXT: 
+
+class D {};
+// CHECK-D: 
+  // CHECK-D-NEXT: 
+  // CHECK-D-NEXT:  blob data = 'D'
+  

r333704 - [analyzer] fix bug with 1-bit APSInt types in Z3ConstraintManager

2018-05-31 Thread Dominic Chen via cfe-commits
Author: ddcc
Date: Thu May 31 15:23:07 2018
New Revision: 333704

URL: http://llvm.org/viewvc/llvm-project?rev=333704=rev
Log:
[analyzer] fix bug with 1-bit APSInt types in Z3ConstraintManager

Summary: Clang does not have a corresponding QualType for a 1-bit APSInt, so 
use the BoolTy and extend the APSInt. Split from D35450. Fixes PR37622.

Reviewers: george.karpenkov, NoQ

Subscribers: mikhail.ramalho, xazax.hun, szepet, rnkovacs, cfe-commits, 
a.sidorin

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

Added:
cfe/trunk/test/Analysis/apsint.c
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp?rev=333704=333703=333704=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp Thu May 31 
15:23:07 2018
@@ -987,6 +987,9 @@ private:
   // TODO: Refactor to put elsewhere
   QualType getAPSIntType(const llvm::APSInt ) const;
 
+  // Get the QualTy for the input APSInt, and fix it if it has a bitwidth of 1.
+  std::pair fixAPSInt(const llvm::APSInt ) const;
+
   // Perform implicit type conversion on binary symbolic expressions.
   // May modify all input parameters.
   // TODO: Refactor to use built-in conversion functions
@@ -1038,27 +1041,31 @@ ProgramStateRef Z3ConstraintManager::ass
   // The expression may be casted, so we cannot call getZ3DataExpr() directly
   Z3Expr Exp = getZ3Expr(Sym, );
 
-  assert((getAPSIntType(From) == getAPSIntType(To)) &&
- "Range values have different types!");
-  QualType RTy = getAPSIntType(From);
-  bool isSignedTy = RetTy->isSignedIntegerOrEnumerationType();
-  Z3Expr FromExp = Z3Expr::fromAPSInt(From);
-  Z3Expr ToExp = Z3Expr::fromAPSInt(To);
+  QualType FromTy;
+  llvm::APSInt NewFromInt;
+  std::tie(NewFromInt, FromTy) = fixAPSInt(From);
+  Z3Expr FromExp = Z3Expr::fromAPSInt(NewFromInt);
 
   // Construct single (in)equality
   if (From == To)
 return assumeZ3Expr(State, Sym,
 getZ3BinExpr(Exp, RetTy, InRange ? BO_EQ : BO_NE,
- FromExp, RTy, nullptr));
+ FromExp, FromTy, nullptr));
 
+  QualType ToTy;
+  llvm::APSInt NewToInt;
+  std::tie(NewToInt, ToTy) = fixAPSInt(To);
+  Z3Expr ToExp = Z3Expr::fromAPSInt(NewToInt);
+  assert(FromTy == ToTy && "Range values have different types!");
   // Construct two (in)equalities, and a logical and/or
-  Z3Expr LHS =
-  getZ3BinExpr(Exp, RetTy, InRange ? BO_GE : BO_LT, FromExp, RTy, nullptr);
+  Z3Expr LHS = getZ3BinExpr(Exp, RetTy, InRange ? BO_GE : BO_LT, FromExp,
+FromTy, nullptr);
   Z3Expr RHS =
-  getZ3BinExpr(Exp, RetTy, InRange ? BO_LE : BO_GT, ToExp, RTy, nullptr);
+  getZ3BinExpr(Exp, RetTy, InRange ? BO_LE : BO_GT, ToExp, ToTy, nullptr);
   return assumeZ3Expr(
   State, Sym,
-  Z3Expr::fromBinOp(LHS, InRange ? BO_LAnd : BO_LOr, RHS, isSignedTy));
+  Z3Expr::fromBinOp(LHS, InRange ? BO_LAnd : BO_LOr, RHS,
+RetTy->isSignedIntegerOrEnumerationType()));
 }
 
 ProgramStateRef Z3ConstraintManager::assumeSymUnsupported(ProgramStateRef 
State,
@@ -1145,8 +1152,8 @@ ConditionTruthVal Z3ConstraintManager::c
 
 const llvm::APSInt *Z3ConstraintManager::getSymVal(ProgramStateRef State,
SymbolRef Sym) const {
-  BasicValueFactory  = getBasicVals();
-  ASTContext  = BV.getContext();
+  BasicValueFactory  = getBasicVals();
+  ASTContext  = BVF.getContext();
 
   if (const SymbolData *SD = dyn_cast(Sym)) {
 QualType Ty = Sym->getType();
@@ -1180,7 +1187,7 @@ const llvm::APSInt *Z3ConstraintManager:
   return nullptr;
 
 // This is the only solution, store it
-return (Value);
+return (Value);
   } else if (const SymbolCast *SC = dyn_cast(Sym)) {
 SymbolRef CastSym = SC->getOperand();
 QualType CastTy = SC->getType();
@@ -1191,7 +1198,7 @@ const llvm::APSInt *Z3ConstraintManager:
 const llvm::APSInt *Value;
 if (!(Value = getSymVal(State, CastSym)))
   return nullptr;
-return (SC->getType(), *Value);
+return (SC->getType(), *Value);
   } else if (const BinarySymExpr *BSE = dyn_cast(Sym)) {
 const llvm::APSInt *LHS, *RHS;
 if (const SymIntExpr *SIE = dyn_cast(BSE)) {
@@ -1215,7 +1222,7 @@ const llvm::APSInt *Z3ConstraintManager:
 QualType LTy = getAPSIntType(*LHS), RTy = getAPSIntType(*RHS);
 doIntTypeConversion(
 ConvertedLHS, LTy, ConvertedRHS, RTy);
-return BV.evalAPSInt(BSE->getOpcode(), ConvertedLHS, ConvertedRHS);
+return BVF.evalAPSInt(BSE->getOpcode(), ConvertedLHS, ConvertedRHS);
   }
 
   llvm_unreachable("Unsupported expression to get symbol value!");
@@ 

[PATCH] D47603: [analyzer] fix bug with 1-bit APSInt types in Z3ConstraintManager

2018-05-31 Thread Dominic Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333704: [analyzer] fix bug with 1-bit APSInt types in 
Z3ConstraintManager (authored by ddcc, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D47603

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
  cfe/trunk/test/Analysis/apsint.c

Index: cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -987,6 +987,9 @@
   // TODO: Refactor to put elsewhere
   QualType getAPSIntType(const llvm::APSInt ) const;
 
+  // Get the QualTy for the input APSInt, and fix it if it has a bitwidth of 1.
+  std::pair fixAPSInt(const llvm::APSInt ) const;
+
   // Perform implicit type conversion on binary symbolic expressions.
   // May modify all input parameters.
   // TODO: Refactor to use built-in conversion functions
@@ -1038,27 +1041,31 @@
   // The expression may be casted, so we cannot call getZ3DataExpr() directly
   Z3Expr Exp = getZ3Expr(Sym, );
 
-  assert((getAPSIntType(From) == getAPSIntType(To)) &&
- "Range values have different types!");
-  QualType RTy = getAPSIntType(From);
-  bool isSignedTy = RetTy->isSignedIntegerOrEnumerationType();
-  Z3Expr FromExp = Z3Expr::fromAPSInt(From);
-  Z3Expr ToExp = Z3Expr::fromAPSInt(To);
+  QualType FromTy;
+  llvm::APSInt NewFromInt;
+  std::tie(NewFromInt, FromTy) = fixAPSInt(From);
+  Z3Expr FromExp = Z3Expr::fromAPSInt(NewFromInt);
 
   // Construct single (in)equality
   if (From == To)
 return assumeZ3Expr(State, Sym,
 getZ3BinExpr(Exp, RetTy, InRange ? BO_EQ : BO_NE,
- FromExp, RTy, nullptr));
+ FromExp, FromTy, nullptr));
 
+  QualType ToTy;
+  llvm::APSInt NewToInt;
+  std::tie(NewToInt, ToTy) = fixAPSInt(To);
+  Z3Expr ToExp = Z3Expr::fromAPSInt(NewToInt);
+  assert(FromTy == ToTy && "Range values have different types!");
   // Construct two (in)equalities, and a logical and/or
-  Z3Expr LHS =
-  getZ3BinExpr(Exp, RetTy, InRange ? BO_GE : BO_LT, FromExp, RTy, nullptr);
+  Z3Expr LHS = getZ3BinExpr(Exp, RetTy, InRange ? BO_GE : BO_LT, FromExp,
+FromTy, nullptr);
   Z3Expr RHS =
-  getZ3BinExpr(Exp, RetTy, InRange ? BO_LE : BO_GT, ToExp, RTy, nullptr);
+  getZ3BinExpr(Exp, RetTy, InRange ? BO_LE : BO_GT, ToExp, ToTy, nullptr);
   return assumeZ3Expr(
   State, Sym,
-  Z3Expr::fromBinOp(LHS, InRange ? BO_LAnd : BO_LOr, RHS, isSignedTy));
+  Z3Expr::fromBinOp(LHS, InRange ? BO_LAnd : BO_LOr, RHS,
+RetTy->isSignedIntegerOrEnumerationType()));
 }
 
 ProgramStateRef Z3ConstraintManager::assumeSymUnsupported(ProgramStateRef State,
@@ -1145,8 +1152,8 @@
 
 const llvm::APSInt *Z3ConstraintManager::getSymVal(ProgramStateRef State,
SymbolRef Sym) const {
-  BasicValueFactory  = getBasicVals();
-  ASTContext  = BV.getContext();
+  BasicValueFactory  = getBasicVals();
+  ASTContext  = BVF.getContext();
 
   if (const SymbolData *SD = dyn_cast(Sym)) {
 QualType Ty = Sym->getType();
@@ -1180,7 +1187,7 @@
   return nullptr;
 
 // This is the only solution, store it
-return (Value);
+return (Value);
   } else if (const SymbolCast *SC = dyn_cast(Sym)) {
 SymbolRef CastSym = SC->getOperand();
 QualType CastTy = SC->getType();
@@ -1191,7 +1198,7 @@
 const llvm::APSInt *Value;
 if (!(Value = getSymVal(State, CastSym)))
   return nullptr;
-return (SC->getType(), *Value);
+return (SC->getType(), *Value);
   } else if (const BinarySymExpr *BSE = dyn_cast(Sym)) {
 const llvm::APSInt *LHS, *RHS;
 if (const SymIntExpr *SIE = dyn_cast(BSE)) {
@@ -1215,7 +1222,7 @@
 QualType LTy = getAPSIntType(*LHS), RTy = getAPSIntType(*RHS);
 doIntTypeConversion(
 ConvertedLHS, LTy, ConvertedRHS, RTy);
-return BV.evalAPSInt(BSE->getOpcode(), ConvertedLHS, ConvertedRHS);
+return BVF.evalAPSInt(BSE->getOpcode(), ConvertedLHS, ConvertedRHS);
   }
 
   llvm_unreachable("Unsupported expression to get symbol value!");
@@ -1342,13 +1349,15 @@
   BinaryOperator::Opcode Op = BSE->getOpcode();
 
   if (const SymIntExpr *SIE = dyn_cast(BSE)) {
-RTy = getAPSIntType(SIE->getRHS());
 Z3Expr LHS = getZ3SymExpr(SIE->getLHS(), , hasComparison);
-Z3Expr RHS = Z3Expr::fromAPSInt(SIE->getRHS());
+llvm::APSInt NewRInt;
+std::tie(NewRInt, RTy) = fixAPSInt(SIE->getRHS());
+Z3Expr RHS = Z3Expr::fromAPSInt(NewRInt);
 return getZ3BinExpr(LHS, LTy, Op, RHS, RTy, RetTy);
   } else if (const IntSymExpr *ISE = dyn_cast(BSE)) {
-LTy = getAPSIntType(ISE->getLHS());
-Z3Expr LHS = Z3Expr::fromAPSInt(ISE->getLHS());
+llvm::APSInt 

[PATCH] D47394: [OpenMP][Clang][NVPTX] Replace bundling with partial linking for the OpenMP NVPTX device offloading toolchain

2018-05-31 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In https://reviews.llvm.org/D47394#1118223, @gtbercea wrote:

> I tried this example 
> (https://devblogs.nvidia.com/separate-compilation-linking-cuda-device-code/). 
> It worked with NVCC but not with clang++. I can produce the main.o particle.o 
> and v.o objects as relocatable (-fcuda-rdc) but the final step fails with a 
> missing reference error.


It's not clear what exactly you mean by the "final step" and what exactly was 
the error. Could you give me more details?

> This leads me to believe that embedding the CUDA fatbin code in the host 
> object comes with limitations. If I were to change the OpenMP NVPTX toolchain 
> to do the same then I would run into similar problems.

It's a two-part problem.

In the end, we need to place GPU-side binary (whether it's an object or an 
executable) in a way that CUDA tools can recognize. You should end up with 
pretty much the same set of bits. If clang currently does not do that well 
enough, we should fix it.

Second part is what do we do about GPU-side object files. NVCC has some 
under-the-hood magic that invokes nvlink. If we invoke clang for the final 
linking phase, it has no idea that some of .o files may have GPU code in it 
that may need extra steps before we can pass everything to the linker to 
produce the host executable. IMO the linking of GPU-side objects should be done 
outside of clang. I.e. one could do it with an extra build rule which would 
invoke `nvcc --device-link  ...` to link all GPU-side objects into a GPU 
executable, still wrapped in a host .o, which can then be linked into the host 
executable.

> On the other hand., the example, ported to use OpenMP declare target regions 
> (instead of __device__) it all compiles, links and runs correctly.
> 
> In general, I feel that if we go the way you propose then the solution is 
> truly confined to NVPTX. If we instead implement a scheme like the one in 
> this patch then we give other toolchains a chance to perhaps fill the nvlink 
> "gap" and eventually be able to handle offloading in a similar manner and 
> support static linking.

I'm not sure how is "fatbin + clang -fcuda-gpubinary" is any more confining to 
NVPTX than "fatbin + clang + ld -r" -- either way you rely on nvidia-specific 
tool. If at some point you find it too confining, changing either of those will 
require pretty much the same amount of work.


Repository:
  rC Clang

https://reviews.llvm.org/D47394



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


[PATCH] D47603: [analyzer] fix bug with 1-bit APSInt types in Z3ConstraintManager

2018-05-31 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov accepted this revision.
george.karpenkov added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D47603



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


r333703 - [WebAssembly] Use Windows EH instructions for Wasm EH

2018-05-31 Thread Heejin Ahn via cfe-commits
Author: aheejin
Date: Thu May 31 15:18:13 2018
New Revision: 333703

URL: http://llvm.org/viewvc/llvm-project?rev=333703=rev
Log:
[WebAssembly] Use Windows EH instructions for Wasm EH

Summary:
Because wasm control flow needs to be structured, using WinEH
instructions to support wasm EH brings several benefits. This patch
makes wasm EH uses Windows EH instructions, with some changes:
1. Because wasm uses a single catch block to catch all C++ exceptions,
   this merges all catch clauses into a single catchpad, within which we
   test the EH selector as in Itanium EH.
2. Generates a call to `__clang_call_terminate` in case a cleanup
   throws. Wasm does not have a runtime to handle this.
3. In case there is no catch-all clause, inserts a call to
   `__cxa_rethrow` at the end of a catchpad in order to unwind to an
   enclosing EH scope.

Reviewers: majnemer, dschuff

Subscribers: jfb, sbc100, jgravelle-google, sunfish, cfe-commits

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

Added:
cfe/trunk/test/CodeGenCXX/wasm-eh.cpp
Modified:
cfe/trunk/lib/CodeGen/CGCXXABI.h
cfe/trunk/lib/CodeGen/CGCleanup.cpp
cfe/trunk/lib/CodeGen/CGCleanup.h
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXXABI.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXXABI.h?rev=333703=333702=333703=diff
==
--- cfe/trunk/lib/CodeGen/CGCXXABI.h (original)
+++ cfe/trunk/lib/CodeGen/CGCXXABI.h Thu May 31 15:18:13 2018
@@ -607,6 +607,17 @@ CGCXXABI *CreateItaniumCXXABI(CodeGenMod
 /// Creates a Microsoft-family ABI.
 CGCXXABI *CreateMicrosoftCXXABI(CodeGenModule );
 
+struct CatchRetScope final : EHScopeStack::Cleanup {
+  llvm::CatchPadInst *CPI;
+
+  CatchRetScope(llvm::CatchPadInst *CPI) : CPI(CPI) {}
+
+  void Emit(CodeGenFunction , Flags flags) override {
+llvm::BasicBlock *BB = CGF.createBasicBlock("catchret.dest");
+CGF.Builder.CreateCatchRet(CPI, BB);
+CGF.EmitBlock(BB);
+  }
+};
 }
 }
 

Modified: cfe/trunk/lib/CodeGen/CGCleanup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.cpp?rev=333703=333702=333703=diff
==
--- cfe/trunk/lib/CodeGen/CGCleanup.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCleanup.cpp Thu May 31 15:18:13 2018
@@ -971,16 +971,21 @@ void CodeGenFunction::PopCleanupBlock(bo
 SaveAndRestore RestoreCurrentFuncletPad(
 CurrentFuncletPad);
 llvm::CleanupPadInst *CPI = nullptr;
-if (!EHPersonality::get(*this).usesFuncletPads()) {
-  EHStack.pushTerminate();
-  PushedTerminate = true;
-} else {
+
+const EHPersonality  = EHPersonality::get(*this);
+if (Personality.usesFuncletPads()) {
   llvm::Value *ParentPad = CurrentFuncletPad;
   if (!ParentPad)
 ParentPad = llvm::ConstantTokenNone::get(CGM.getLLVMContext());
   CurrentFuncletPad = CPI = Builder.CreateCleanupPad(ParentPad);
 }
 
+// Non-MSVC personalities need to terminate when an EH cleanup throws.
+if (!Personality.isMSVCPersonality()) {
+  EHStack.pushTerminate();
+  PushedTerminate = true;
+}
+
 // We only actually emit the cleanup code if the cleanup is either
 // active or was used before it was deactivated.
 if (EHActiveFlag.isValid() || IsActive) {

Modified: cfe/trunk/lib/CodeGen/CGCleanup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.h?rev=333703=333702=333703=diff
==
--- cfe/trunk/lib/CodeGen/CGCleanup.h (original)
+++ cfe/trunk/lib/CodeGen/CGCleanup.h Thu May 31 15:18:13 2018
@@ -627,16 +627,21 @@ struct EHPersonality {
   static const EHPersonality MSVC_except_handler;
   static const EHPersonality MSVC_C_specific_handler;
   static const EHPersonality MSVC_CxxFrameHandler3;
+  static const EHPersonality GNU_Wasm_CPlusPlus;
 
   /// Does this personality use landingpads or the family of pad instructions
   /// designed to form funclets?
-  bool usesFuncletPads() const { return isMSVCPersonality(); }
+  bool usesFuncletPads() const {
+return isMSVCPersonality() || isWasmPersonality();
+  }
 
   bool isMSVCPersonality() const {
 return this == _except_handler || this == _C_specific_handler ||
this == _CxxFrameHandler3;
   }
 
+  bool isWasmPersonality() const { return this == _Wasm_CPlusPlus; }
+
   bool isMSVCXXPersonality() const { return this == _CxxFrameHandler3; }
 };
 }

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=333703=333702=333703=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp 

[PATCH] D44931: [WebAssembly] Use Windows EH instructions for Wasm EH

2018-05-31 Thread Heejin Ahn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333703: [WebAssembly] Use Windows EH instructions for Wasm 
EH (authored by aheejin, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D44931

Files:
  cfe/trunk/lib/CodeGen/CGCXXABI.h
  cfe/trunk/lib/CodeGen/CGCleanup.cpp
  cfe/trunk/lib/CodeGen/CGCleanup.h
  cfe/trunk/lib/CodeGen/CGException.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
  cfe/trunk/test/CodeGenCXX/wasm-eh.cpp

Index: cfe/trunk/test/CodeGenCXX/wasm-eh.cpp
===
--- cfe/trunk/test/CodeGenCXX/wasm-eh.cpp
+++ cfe/trunk/test/CodeGenCXX/wasm-eh.cpp
@@ -0,0 +1,384 @@
+// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+
+void may_throw();
+void dont_throw() noexcept;
+
+struct Cleanup {
+  ~Cleanup() { dont_throw(); }
+};
+
+// Multiple catch clauses w/o catch-all
+void test0() {
+  try {
+may_throw();
+  } catch (int) {
+dont_throw();
+  } catch (double) {
+dont_throw();
+  }
+}
+
+// CHECK-LABEL: define void @_Z5test0v() {{.*}} personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*)
+
+// CHECK:   %[[INT_ALLOCA:.*]] = alloca i32
+// CHECK:   invoke void @_Z9may_throwv()
+// CHECK-NEXT:   to label %[[NORMAL_BB:.*]] unwind label %[[CATCHDISPATCH_BB:.*]]
+
+// CHECK: [[CATCHDISPATCH_BB]]:
+// CHECK-NEXT:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* bitcast (i8** @_ZTIi to i8*), i8* bitcast (i8** @_ZTId to i8*)]
+// CHECK-NEXT:   %[[EXN:.*]] = call i8* @llvm.wasm.get.exception(token %[[CATCHPAD]])
+// CHECK-NEXT:   store i8* %[[EXN]], i8** %exn.slot
+// CHECK-NEXT:   %[[SELECTOR:.*]] = call i32 @llvm.wasm.get.ehselector(token %[[CATCHPAD]])
+// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #2
+// CHECK-NEXT:   %[[MATCHES:.*]] = icmp eq i32 %[[SELECTOR]], %[[TYPEID]]
+// CHECK-NEXT:   br i1 %[[MATCHES]], label %[[CATCH_INT_BB:.*]], label %[[CATCH_FALLTHROUGH_BB:.*]]
+
+// CHECK: [[CATCH_INT_BB]]:
+// CHECK-NEXT:   %[[EXN:.*]] = load i8*, i8** %exn.slot
+// CHECK-NEXT:   %[[ADDR:.*]] = call i8* @__cxa_begin_catch(i8* %[[EXN]]) {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   %[[ADDR_CAST:.*]] = bitcast i8* %[[ADDR]] to i32*
+// CHECK-NEXT:   %[[INT_VAL:.*]] = load i32, i32* %[[ADDR_CAST]]
+// CHECK-NEXT:   store i32 %[[INT_VAL]], i32* %[[INT_ALLOCA]]
+// CHECK-NEXT:   call void @_Z10dont_throwv() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   call void @__cxa_end_catch() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   catchret from %[[CATCHPAD]] to label %[[CATCHRET_DEST_BB0:.*]]
+
+// CHECK: [[CATCHRET_DEST_BB0]]:
+// CHECK-NEXT:   br label %[[TRY_CONT_BB:.*]]
+
+// CHECK: [[CATCH_FALLTHROUGH_BB]]
+// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTId to i8*)) #2
+// CHECK-NEXT:   %[[MATCHES:.*]] = icmp eq i32 %[[SELECTOR]], %[[TYPEID]]
+// CHECK-NEXT:   br i1 %[[MATCHES]], label %[[CATCH_FLOAT_BB:.*]], label %[[RETHROW_BB:.*]]
+
+// CHECK: [[CATCH_FLOAT_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label %[[CATCHRET_DEST_BB1:.*]]
+
+// CHECK: [[CATCHRET_DEST_BB1]]:
+// CHECK-NEXT:   br label %[[TRY_CONT_BB]]
+
+// CHECK: [[RETHROW_BB]]:
+// CHECK-NEXT:   call void @__cxa_rethrow() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   unreachable
+
+// Single catch-all
+void test1() {
+  try {
+may_throw();
+  } catch (...) {
+dont_throw();
+  }
+}
+
+// CATCH-LABEL: @_Z5test1v()
+
+// CHECK:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* null]
+// CHECK:   br label %[[CATCH_ALL_BB:.*]]
+
+// CHECK: [[CATCH_ALL_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+// Multiple catch clauses w/ catch-all
+void test2() {
+  try {
+may_throw();
+  } catch (int) {
+dont_throw();
+  } catch (...) {
+dont_throw();
+  }
+}
+
+// CHECK-LABEL: @_Z5test2v()
+
+// CHECK:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* bitcast (i8** @_ZTIi to i8*), i8* null]
+// CHECK:   br i1 %{{.*}}, label %[[CATCH_INT_BB:.*]], label %[[CATCH_ALL_BB:.*]]
+
+// CHECK: [[CATCH_INT_BB]]:
+// CHECK:   catchret from 

[PATCH] D47607: [libcxx] Almost fix some UB in and

2018-05-31 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: rsmith, EricWF, mclow.lists.
Herald added subscribers: christof, kosarev.

 and  define `__value_type` as a union between pair 
and pair so that various operations can move into/from these pairs 
[1]. This is a pretty blatant strict aliasing violation, and has the potential 
break code that was optimized by TBAA. We can't remove this, not only would 
that be a significant pessimization, but we are also required to provide a 
non-const reference to the key_type to implement splicing maps & sets. This 
patch fixes `__value_type` by downgrading it from "accidentally launch the 
missiles"-level UB to theoretical UB, namely, instead of type-punning between 
pairs we just const_cast the key. It's still undefined to mutate a const 
object, but clang doesn't actually optimize on this rule. Just to be paranoid 
this patch also `launder()`s to "pick-up" the new value of key whenever we read 
from it, though this isn't launder's actual use-case. Thanks to @rsmith for the 
suggestions!

To do this, this patch:

- removes the __nc_value_type data member of the `__value_type` union
- provides access to the pair with `pair`, which is 
used to assign through to the pair
- changes `__value_type.__cc` to `__value_type.__get_value()`, the latter calls 
std::launder in C++1z mode.

https://reviews.llvm.org/D46845 depends on this patch.

[1]: https://stackoverflow.com/a/31667355

Thanks for taking a look!
Erik


Repository:
  rCXX libc++

https://reviews.llvm.org/D47607

Files:
  libcxx/include/__hash_table
  libcxx/include/__tree
  libcxx/include/map
  libcxx/include/unordered_map

Index: libcxx/include/unordered_map
===
--- libcxx/include/unordered_map
+++ libcxx/include/unordered_map
@@ -396,7 +396,7 @@
 const _Hash& hash_function() const _NOEXCEPT {return *this;}
 _LIBCPP_INLINE_VISIBILITY
 size_t operator()(const _Cp& __x) const
-{return static_cast(*this)(__x.__cc.first);}
+{return static_cast(*this)(__x.__get_value().first);}
 _LIBCPP_INLINE_VISIBILITY
 size_t operator()(const _Key& __x) const
 {return static_cast(*this)(__x);}
@@ -425,7 +425,7 @@
 const _Hash& hash_function() const _NOEXCEPT {return __hash_;}
 _LIBCPP_INLINE_VISIBILITY
 size_t operator()(const _Cp& __x) const
-{return __hash_(__x.__cc.first);}
+{return __hash_(__x.__get_value().first);}
 _LIBCPP_INLINE_VISIBILITY
 size_t operator()(const _Key& __x) const
 {return __hash_(__x);}
@@ -464,13 +464,13 @@
 const _Pred& key_eq() const _NOEXCEPT {return *this;}
 _LIBCPP_INLINE_VISIBILITY
 bool operator()(const _Cp& __x, const _Cp& __y) const
-{return static_cast(*this)(__x.__cc.first, __y.__cc.first);}
+{return static_cast(*this)(__x.__get_value().first, __y.__get_value().first);}
 _LIBCPP_INLINE_VISIBILITY
 bool operator()(const _Cp& __x, const _Key& __y) const
-{return static_cast(*this)(__x.__cc.first, __y);}
+{return static_cast(*this)(__x.__get_value().first, __y);}
 _LIBCPP_INLINE_VISIBILITY
 bool operator()(const _Key& __x, const _Cp& __y) const
-{return static_cast(*this)(__x, __y.__cc.first);}
+{return static_cast(*this)(__x, __y.__get_value().first);}
 void swap(__unordered_map_equal&__y)
 _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
 {
@@ -496,13 +496,13 @@
 const _Pred& key_eq() const _NOEXCEPT {return __pred_;}
 _LIBCPP_INLINE_VISIBILITY
 bool operator()(const _Cp& __x, const _Cp& __y) const
-{return __pred_(__x.__cc.first, __y.__cc.first);}
+{return __pred_(__x.__get_value().first, __y.__get_value().first);}
 _LIBCPP_INLINE_VISIBILITY
 bool operator()(const _Cp& __x, const _Key& __y) const
-{return __pred_(__x.__cc.first, __y);}
+{return __pred_(__x.__get_value().first, __y);}
 _LIBCPP_INLINE_VISIBILITY
 bool operator()(const _Key& __x, const _Cp& __y) const
-{return __pred_(__x, __y.__cc.first);}
+{return __pred_(__x, __y.__get_value().first);}
 void swap(__unordered_map_equal&__y)
 _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
 {
@@ -572,9 +572,9 @@
 void operator()(pointer __p) _NOEXCEPT
 {
 if (__second_constructed)
-__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.second));
+__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().second));
 if (__first_constructed)
-__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.first));
+__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().first));
 if (__p)
 __alloc_traits::deallocate(__na_, __p, 1);
 }
@@ -587,27 +587,69 @@
 typedef _Key key_type;
 typedef _Tp  

[PATCH] D47301: Warning for framework include violation from Headers to PrivateHeaders

2018-05-31 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno marked an inline comment as done.
bruno added inline comments.



Comment at: include/clang/Basic/DiagnosticGroups.td:34-35
 def AutoImport : DiagGroup<"auto-import">;
 def FrameworkHdrQuotedInclude : 
DiagGroup<"quoted-include-in-framework-header">;
+def FrameworkIncludePrivateFromPublic : 
DiagGroup<"framework-include-private-from-public">;
 def CXX14BinaryLiteral : DiagGroup<"c++14-binary-literal">;

vsapsai wrote:
> It might be convenient for users to have a warning group that will cover 
> different framework warnings, something like -Wframework-hygiene. But it's 
> out of scope for this review, more as an idea for future improvements.
Yep, that should come once we land all other bits.



Comment at: lib/Lex/HeaderSearch.cpp:625
+static bool isFrameworkStylePath(StringRef Path, bool ,
+ SmallVectorImpl ) {
   using namespace llvm::sys;

vsapsai wrote:
> In this function we accept some paths that aren't valid framework paths. Need 
> to think more if it is OK or if we want to be stricter.
It should be ok at this point, otherwise the framework style path would have 
failed before finding this header.



Comment at: test/Modules/framework-public-includes-private.m:33
+
+int bar() { return foo(); }
+

vsapsai wrote:
> I'm not entirely sure it's not covered by existing test. It might be worth 
> testing private header including public header and private header including 
> another private header.
The warning is on by default and clang already have the scenario you described 
in other module tests - those would fail if there's a bug in the logic here.


https://reviews.llvm.org/D47301



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


[PATCH] D47394: [OpenMP][Clang][NVPTX] Replace bundling with partial linking for the OpenMP NVPTX device offloading toolchain

2018-05-31 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

> Assuming we do proceed with back-to-CUDA approach, one thing I'd consider 
> would be using clang's -fcuda-include-gpubinary option which CUDA uses to 
> include GPU code into the host object. You may be able to use it to avoid 
> compiling and partially linking .fatbin and host .o.

I tried this example 
(https://devblogs.nvidia.com/separate-compilation-linking-cuda-device-code/). 
It worked with NVCC but not with clang++. I can produce the main.o particle.o 
and v.o objects as relocatable (-fcuda-rdc) but the final step fails with a 
missing reference error.
This leads me to believe that embedding the CUDA fatbin code in the host object 
comes with limitations. If I were to change the OpenMP NVPTX toolchain to do 
the same then I would run into similar problems.

On the other hand., the example, ported to use OpenMP declare target regions 
(instead of __device__) it all compiles, links and runs correctly.

In general, I feel that if we go the way you propose then the solution is truly 
confined to NVPTX. If we instead implement a scheme like the one in this patch 
then we give other toolchains a chance to perhaps fill the nvlink "gap" and 
eventually be able to handle offloading in a similar manner and support static 
linking.


Repository:
  rC Clang

https://reviews.llvm.org/D47394



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


[PATCH] D47301: Warning for framework include violation from Headers to PrivateHeaders

2018-05-31 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno updated this revision to Diff 149361.
bruno added a comment.

Update patch after changes to https://reviews.llvm.org/D47157. Also address 
some of Volodymyr feedback.


https://reviews.llvm.org/D47301

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticLexKinds.td
  lib/Lex/HeaderSearch.cpp
  test/Modules/Inputs/framework-public-includes-private/A.framework/Headers/A.h
  
test/Modules/Inputs/framework-public-includes-private/A.framework/Modules/module.modulemap
  
test/Modules/Inputs/framework-public-includes-private/A.framework/Modules/module.private.modulemap
  
test/Modules/Inputs/framework-public-includes-private/A.framework/PrivateHeaders/APriv.h
  
test/Modules/Inputs/framework-public-includes-private/A.framework/PrivateHeaders/APriv2.h
  test/Modules/Inputs/framework-public-includes-private/a.hmap.json
  test/Modules/Inputs/framework-public-includes-private/flat-header-path/Z.h
  
test/Modules/Inputs/framework-public-includes-private/flat-header-path/Z.modulemap
  
test/Modules/Inputs/framework-public-includes-private/flat-header-path/Z.private.modulemap
  test/Modules/Inputs/framework-public-includes-private/flat-header-path/ZPriv.h
  test/Modules/Inputs/framework-public-includes-private/z.hmap.json
  test/Modules/Inputs/framework-public-includes-private/z.yaml
  test/Modules/framework-public-includes-private.m

Index: test/Modules/framework-public-includes-private.m
===
--- /dev/null
+++ test/Modules/framework-public-includes-private.m
@@ -0,0 +1,37 @@
+// REQUIRES: shell
+
+// RUN: rm -rf %t
+// RUN: mkdir %t
+
+// RUN: hmaptool write %S/Inputs/framework-public-includes-private/a.hmap.json %t/a.hmap
+// RUN: hmaptool write %S/Inputs/framework-public-includes-private/z.hmap.json %t/z.hmap
+
+// RUN: sed -e "s:TEST_DIR:%S/Inputs/framework-public-includes-private:g" \
+// RUN:   %S/Inputs/framework-public-includes-private/z.yaml > %t/z.yaml
+
+// The output with and without modules should be the same, without modules first.
+// RUN: %clang_cc1 \
+// RUN:   -iquote %t/z.hmap -iquote %t/a.hmap -ivfsoverlay %t/z.yaml \
+// RUN:   -F%S/Inputs/framework-public-includes-private \
+// RUN:   -fsyntax-only %s -verify
+
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache \
+// RUN:   -iquote %t/z.hmap -iquote %t/a.hmap -ivfsoverlay %t/z.yaml \
+// RUN:   -F%S/Inputs/framework-public-includes-private \
+// RUN:   -fsyntax-only %s \
+// RUN:   2>%t/stderr
+
+// The same warnings show up when modules is on but -verify doesn't get it
+// because they only show up under the module A building context.
+// RUN: FileCheck --input-file=%t/stderr %s
+// CHECK: public framework header includes private framework header 'A/APriv.h'
+// CHECK: public framework header includes private framework header 'A/APriv2.h'
+// CHECK: public framework header includes private framework header 'Z/ZPriv.h'
+
+#import "A.h"
+
+int bar() { return foo(); }
+
+// expected-warning@Inputs/framework-public-includes-private/A.framework/Headers/A.h:2{{public framework header includes private framework header 'A/APriv.h'}}
+// expected-warning@Inputs/framework-public-includes-private/A.framework/Headers/A.h:3{{public framework header includes private framework header 'A/APriv2.h'}}
+// expected-warning@Inputs/framework-public-includes-private/flat-header-path/Z.h:1{{public framework header includes private framework header 'Z/ZPriv.h'}}
Index: test/Modules/Inputs/framework-public-includes-private/z.yaml
===
--- /dev/null
+++ test/Modules/Inputs/framework-public-includes-private/z.yaml
@@ -0,0 +1,45 @@
+{
+  'version': 0,
+  'case-sensitive': 'false',
+  'use-external-names' : 'false',
+  'roots': [
+{
+  'type': 'directory',
+  'name': "TEST_DIR/Z.framework/Headers",
+  'contents': [
+{
+  'type': 'file',
+  'name': "Z.h",
+  'external-contents': "TEST_DIR/flat-header-path/Z.h"
+}
+  ]
+},
+{
+  'type': 'directory',
+  'name': "TEST_DIR/Z.framework/PrivateHeaders",
+  'contents': [
+{
+  'type': 'file',
+  'name': "ZPriv.h",
+  'external-contents': "TEST_DIR/flat-header-path/ZPriv.h"
+}
+  ]
+},
+{
+  'type': 'directory',
+  'name': "TEST_DIR/Z.framework/Modules",
+  'contents': [
+{
+  'type': 'file',
+  'name': "module.modulemap",
+  'external-contents': "TEST_DIR/flat-header-path/Z.modulemap"
+},
+{
+  'type': 'file',
+  'name': "module.private.modulemap",
+  'external-contents': "TEST_DIR/flat-header-path/Z.private.modulemap"
+}
+  ]
+}
+  ]
+}
Index: test/Modules/Inputs/framework-public-includes-private/z.hmap.json
===
--- /dev/null
+++ 

[PATCH] D46911: [Fixed Point Arithmetic] Addition of the remaining fixed point types and their saturated equivalents

2018-05-31 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 149360.
leonardchan marked 7 inline comments as done.

Repository:
  rC Clang

https://reviews.llvm.org/D46911

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/AST/Type.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/Basic/TargetInfo.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  test/Frontend/fixed_point.c
  test/Frontend/fixed_point_bit_widths.c
  test/Frontend/fixed_point_errors.c
  test/Frontend/fixed_point_errors.cpp

Index: test/Frontend/fixed_point_errors.cpp
===
--- test/Frontend/fixed_point_errors.cpp
+++ test/Frontend/fixed_point_errors.cpp
@@ -1,5 +1,9 @@
+// RUN: %clang_cc1 -x c++ %s -verify
 // RUN: %clang_cc1 -x c++ -ffixed-point %s -verify
 
 // Name namgling is not provided for fixed point types in c++
 
 _Accum accum;   // expected-error{{unknown type name '_Accum'}}
+_Fract fract;   // expected-error{{unknown type name '_Fract'}}
+_Sat _Accum sat_accum;  // expected-error{{unknown type name '_Sat'}}
+// expected-error@-1{{expected ';' after top level declarator}}
Index: test/Frontend/fixed_point_errors.c
===
--- test/Frontend/fixed_point_errors.c
+++ test/Frontend/fixed_point_errors.c
@@ -5,6 +5,14 @@
 
 long long _Accum longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
 unsigned long long _Accum u_longlong_accum;   // expected-error{{'long long _Accum' is invalid}}
+long long _Fract longlong_fract;  // expected-error{{'long long _Fract' is invalid}}
+unsigned long long _Fract u_longlong_fract;   // expected-error{{'long long _Fract' is invalid}}
+
+_Sat long long _Accum sat_longlong_accum; // expected-error{{'long long _Accum' is invalid}}
+_Sat unsigned long long _Accum sat_u_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+_Sat long long _Fract sat_longlong_fract; // expected-error{{'long long _Fract' is invalid}}
+_Sat unsigned long long _Fract sat_u_longlong_fract;  // expected-error{{'long long _Fract' is invalid}}
+
 
 /* Although _Complex types work with floating point numbers, the extension
  * provides no info for complex fixed point types. */
@@ -19,9 +27,67 @@
 _Complex _Accum cmplx_s_accum;  // expected-error{{'_Complex _Accum' is invalid}}
 _Complex long _Accum cmplx_s_long_accum;// expected-error{{'_Complex _Accum' is invalid}}
 
+_Complex signed short _Fract cmplx_s_short_fract;   // expected-error{{'_Complex _Fract' is invalid}}
+_Complex signed _Fract cmplx_s_fract;   // expected-error{{'_Complex _Fract' is invalid}}
+_Complex signed long _Fract cmplx_s_long_fract; // expected-error{{'_Complex _Fract' is invalid}}
+_Complex unsigned short _Fract cmplx_u_short_fract; // expected-error{{'_Complex _Fract' is invalid}}
+_Complex unsigned _Fract cmplx_u_fract; // expected-error{{'_Complex _Fract' is invalid}}
+_Complex unsigned long _Fract cmplx_u_long_fract;   // expected-error{{'_Complex _Fract' is invalid}}
+_Complex short _Fract cmplx_s_short_fract;  // expected-error{{'_Complex _Fract' is invalid}}
+_Complex _Fract cmplx_s_fract;  // expected-error{{'_Complex _Fract' is invalid}}
+_Complex long _Fract cmplx_s_long_fract;// expected-error{{'_Complex _Fract' is invalid}}
+
+_Complex _Sat signed short _Accum cmplx_sat_s_short_accum;   // expected-error{{'_Complex _Accum' is invalid}}
+_Complex _Sat signed _Accum cmplx_sat_s_accum;   // expected-error{{'_Complex _Accum' is invalid}}
+_Complex _Sat signed long _Accum cmplx_sat_s_long_accum; // expected-error{{'_Complex _Accum' is invalid}}
+_Complex _Sat unsigned short _Accum cmplx_sat_u_short_accum; // expected-error{{'_Complex _Accum' is invalid}}
+_Complex _Sat unsigned _Accum cmplx_sat_u_accum; // expected-error{{'_Complex _Accum' is invalid}}
+_Complex _Sat unsigned long _Accum cmplx_sat_u_long_accum;   // expected-error{{'_Complex _Accum' is invalid}}
+_Complex _Sat short _Accum cmplx_sat_s_short_accum;  // expected-error{{'_Complex _Accum' is 

[PATCH] D46911: [Fixed Point Arithmetic] Addition of the remaining fixed point types and their saturated equivalents

2018-05-31 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: lib/Sema/DeclSpec.cpp:1123
+if (!(TypeSpecType == TST_accum || TypeSpecType == TST_fract)) {
+  S.Diag(TSSatLoc, diag::err_invalid_saturation_spec)
+  << getSpecifierName((TST)TypeSpecType, Policy);

ebevhan wrote:
> Handling this case here means that placing _Sat on something other than 
> exactly a fixed-point type is a parsing error rather than a semantic error. 
> How does this handle _Sat on sugared types? Should _Sat on things like 
> typedefs work?
> 
>   typedef _Fract myfract;
>   _Sat myfract F;
> 
> The primary issue (and this is one that we have encountered as well) is that 
> you cannot have a true _Sat typedef since _Sat only exists as part of builtin 
> types. You need to desugar/canonicalize the type and then do 
> getCorrespondingSaturatingType (or have getCorrespondingSaturatingType look 
> at the canonical type internally).
I think _Sat is analogous to _Complex where it only works with specific builtin 
types, albeit the only builtin type _Complex doesn't work with is _Bool.

Currently this example would throw the error `'_Sat' specifier is only valid on 
'_Fract' or '_Accum', not 'type-name'` which is similar to what _Complex does 
when paired with a typedef:

```
typedef double mydouble;
mydouble _Complex D;  // _Complex type-name' is invalid
```

I don't see this as a big problem right now, but am willing to come back to 
this in the future if it becomes more urgent. For now, I added a test that 
asserts this error is thrown.



Comment at: lib/Sema/SemaType.cpp:1410
+
+if (DS.getTypeSpecSign() != DeclSpec::TSS_unsigned)
+  Result = fixedpoint::getCorrespondingSignedType(Context, Result);

ebevhan wrote:
> The logic is a bit reversed. The default should be to select the signed 
> variant, and if the TSS is unsigned, then convert it to the unsigned variant.
Using getCorrespondingUnsignedType(). Also changed 
getCorrespondingUnsignedType() to accept fixed point types.


Repository:
  rC Clang

https://reviews.llvm.org/D46911



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


[PATCH] D47157: Warning for framework headers using double quote includes

2018-05-31 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added inline comments.



Comment at: test/Modules/double-quotes.m:24-25
+
+// The same warnings show up when modules is on but -verify doesn't get it
+// because they only show up under the module A building context.
+// RUN: FileCheck --input-file=%t/stderr %s

dexonsmith wrote:
> Would using an explicit module build make this any easier?
---
Not really =T


https://reviews.llvm.org/D47157



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


[PATCH] D47157: Warning for framework headers using double quote includes

2018-05-31 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno updated this revision to Diff 149359.
bruno edited the summary of this revision.
bruno added a comment.

Update after Duncan's review: remove header name from the warning message 
(since it's already in the fixit)


https://reviews.llvm.org/D47157

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticLexKinds.td
  lib/Lex/HeaderSearch.cpp
  test/Modules/Inputs/double-quotes/A.framework/Headers/A.h
  test/Modules/Inputs/double-quotes/A.framework/Headers/A0.h
  test/Modules/Inputs/double-quotes/A.framework/Modules/module.modulemap
  test/Modules/Inputs/double-quotes/B.h
  test/Modules/Inputs/double-quotes/X.framework/Headers/X.h
  test/Modules/Inputs/double-quotes/X.framework/Modules/module.modulemap
  test/Modules/Inputs/double-quotes/a.hmap.json
  test/Modules/Inputs/double-quotes/flat-header-path/Z.h
  test/Modules/Inputs/double-quotes/flat-header-path/Z.modulemap
  test/Modules/Inputs/double-quotes/x.hmap.json
  test/Modules/Inputs/double-quotes/z.yaml
  test/Modules/double-quotes.m

Index: test/Modules/double-quotes.m
===
--- /dev/null
+++ test/Modules/double-quotes.m
@@ -0,0 +1,39 @@
+// REQUIRES: shell
+
+// RUN: rm -rf %t
+// RUN: mkdir %t
+
+// RUN: hmaptool write %S/Inputs/double-quotes/a.hmap.json %t/a.hmap
+// RUN: hmaptool write %S/Inputs/double-quotes/x.hmap.json %t/x.hmap
+
+// RUN: sed -e "s:TEST_DIR:%S/Inputs/double-quotes:g" \
+// RUN:   %S/Inputs/double-quotes/z.yaml > %t/z.yaml
+
+// The output with and without modules should be the same
+
+// RUN: %clang_cc1 \
+// RUN:   -I %t/x.hmap -iquote %t/a.hmap -ivfsoverlay %t/z.yaml \
+// RUN:   -F%S/Inputs/double-quotes -I%S/Inputs/double-quotes \
+// RUN:   -Wquoted-include-in-framework-header -fsyntax-only %s -verify
+
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache \
+// RUN:   -I %t/x.hmap -iquote %t/a.hmap -ivfsoverlay %t/z.yaml \
+// RUN:   -F%S/Inputs/double-quotes -I%S/Inputs/double-quotes \
+// RUN:   -Wquoted-include-in-framework-header -fsyntax-only %s \
+// RUN:   2>%t/stderr
+
+// The same warnings show up when modules is on but -verify doesn't get it
+// because they only show up under the module A building context.
+// RUN: FileCheck --input-file=%t/stderr %s
+// CHECK: double-quoted include "A0.h" in framework header, expected angle-bracketed instead
+// CHECK: double-quoted include "B.h" in framework header, expected angle-bracketed instead
+// CHECK: double-quoted include "B.h" in framework header, expected angle-bracketed instead
+
+#import "A.h"
+#import 
+
+int bar() { return foo(); }
+
+// expected-warning@Inputs/double-quotes/A.framework/Headers/A.h:1{{double-quoted include "A0.h" in framework header, expected angle-bracketed instead}}
+// expected-warning@Inputs/double-quotes/A.framework/Headers/A.h:2{{double-quoted include "B.h" in framework header, expected angle-bracketed instead}}
+// expected-warning@Inputs/double-quotes/flat-header-path/Z.h:1{{double-quoted include "B.h" in framework header, expected angle-bracketed instead}}
Index: test/Modules/Inputs/double-quotes/z.yaml
===
--- /dev/null
+++ test/Modules/Inputs/double-quotes/z.yaml
@@ -0,0 +1,28 @@
+{
+  'version': 0,
+  'case-sensitive': 'false',
+  'roots': [
+{
+  'type': 'directory',
+  'name': "TEST_DIR/Z.framework/Headers",
+  'contents': [
+{
+  'type': 'file',
+  'name': "Z.h",
+  'external-contents': "TEST_DIR/flat-header-path/Z.h"
+}
+  ]
+},
+{
+  'type': 'directory',
+  'name': "TEST_DIR/Z.framework/Modules",
+  'contents': [
+{
+  'type': 'file',
+  'name': "module.modulemap",
+  'external-contents': "TEST_DIR/flat-header-path/Z.modulemap"
+}
+  ]
+}
+  ]
+}
Index: test/Modules/Inputs/double-quotes/x.hmap.json
===
--- /dev/null
+++ test/Modules/Inputs/double-quotes/x.hmap.json
@@ -0,0 +1,7 @@
+
+{
+  "mappings" :
+{
+ "X.h" : "X/X.h"
+}
+}
Index: test/Modules/Inputs/double-quotes/flat-header-path/Z.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/double-quotes/flat-header-path/Z.modulemap
@@ -0,0 +1,3 @@
+framework module Z {
+	header "Z.h"
+}
Index: test/Modules/Inputs/double-quotes/flat-header-path/Z.h
===
--- /dev/null
+++ test/Modules/Inputs/double-quotes/flat-header-path/Z.h
@@ -0,0 +1 @@
+#import "B.h" // Included from Z.h & A.h
Index: test/Modules/Inputs/double-quotes/a.hmap.json
===
--- /dev/null
+++ test/Modules/Inputs/double-quotes/a.hmap.json
@@ -0,0 +1,7 @@
+
+{
+  "mappings" :
+{
+ "A.h" : "A/A.h"
+}
+}
Index: 

[PATCH] D47603: [analyzer] fix bug with 1-bit APSInt types in Z3ConstraintManager

2018-05-31 Thread Dominic Chen via Phabricator via cfe-commits
ddcc updated this revision to Diff 149356.
ddcc added a comment.

Add test, address comments


Repository:
  rC Clang

https://reviews.llvm.org/D47603

Files:
  lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
  test/Analysis/apsint.c

Index: test/Analysis/apsint.c
===
--- /dev/null
+++ test/Analysis/apsint.c
@@ -0,0 +1,7 @@
+// REQUIRES: z3
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux-gnu -analyzer-checker=core -verify %s
+// expected-no-diagnostics
+
+_Bool a() {
+  return !({ a(); });
+}
Index: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -987,6 +987,9 @@
   // TODO: Refactor to put elsewhere
   QualType getAPSIntType(const llvm::APSInt ) const;
 
+  // Get the QualTy for the input APSInt, and fix it if it has a bitwidth of 1.
+  std::pair fixAPSInt(const llvm::APSInt ) const;
+
   // Perform implicit type conversion on binary symbolic expressions.
   // May modify all input parameters.
   // TODO: Refactor to use built-in conversion functions
@@ -1038,27 +1041,31 @@
   // The expression may be casted, so we cannot call getZ3DataExpr() directly
   Z3Expr Exp = getZ3Expr(Sym, );
 
-  assert((getAPSIntType(From) == getAPSIntType(To)) &&
- "Range values have different types!");
-  QualType RTy = getAPSIntType(From);
-  bool isSignedTy = RetTy->isSignedIntegerOrEnumerationType();
-  Z3Expr FromExp = Z3Expr::fromAPSInt(From);
-  Z3Expr ToExp = Z3Expr::fromAPSInt(To);
+  QualType FromTy;
+  llvm::APSInt NewFromInt;
+  std::tie(NewFromInt, FromTy) = fixAPSInt(From);
+  Z3Expr FromExp = Z3Expr::fromAPSInt(NewFromInt);
 
   // Construct single (in)equality
   if (From == To)
 return assumeZ3Expr(State, Sym,
 getZ3BinExpr(Exp, RetTy, InRange ? BO_EQ : BO_NE,
- FromExp, RTy, nullptr));
+ FromExp, FromTy, nullptr));
 
+  QualType ToTy;
+  llvm::APSInt NewToInt;
+  std::tie(NewToInt, ToTy) = fixAPSInt(To);
+  Z3Expr ToExp = Z3Expr::fromAPSInt(NewToInt);
+  assert(FromTy == ToTy && "Range values have different types!");
   // Construct two (in)equalities, and a logical and/or
-  Z3Expr LHS =
-  getZ3BinExpr(Exp, RetTy, InRange ? BO_GE : BO_LT, FromExp, RTy, nullptr);
+  Z3Expr LHS = getZ3BinExpr(Exp, RetTy, InRange ? BO_GE : BO_LT, FromExp,
+FromTy, nullptr);
   Z3Expr RHS =
-  getZ3BinExpr(Exp, RetTy, InRange ? BO_LE : BO_GT, ToExp, RTy, nullptr);
+  getZ3BinExpr(Exp, RetTy, InRange ? BO_LE : BO_GT, ToExp, ToTy, nullptr);
   return assumeZ3Expr(
   State, Sym,
-  Z3Expr::fromBinOp(LHS, InRange ? BO_LAnd : BO_LOr, RHS, isSignedTy));
+  Z3Expr::fromBinOp(LHS, InRange ? BO_LAnd : BO_LOr, RHS,
+RetTy->isSignedIntegerOrEnumerationType()));
 }
 
 ProgramStateRef Z3ConstraintManager::assumeSymUnsupported(ProgramStateRef State,
@@ -1145,8 +1152,8 @@
 
 const llvm::APSInt *Z3ConstraintManager::getSymVal(ProgramStateRef State,
SymbolRef Sym) const {
-  BasicValueFactory  = getBasicVals();
-  ASTContext  = BV.getContext();
+  BasicValueFactory  = getBasicVals();
+  ASTContext  = BVF.getContext();
 
   if (const SymbolData *SD = dyn_cast(Sym)) {
 QualType Ty = Sym->getType();
@@ -1180,7 +1187,7 @@
   return nullptr;
 
 // This is the only solution, store it
-return (Value);
+return (Value);
   } else if (const SymbolCast *SC = dyn_cast(Sym)) {
 SymbolRef CastSym = SC->getOperand();
 QualType CastTy = SC->getType();
@@ -1191,7 +1198,7 @@
 const llvm::APSInt *Value;
 if (!(Value = getSymVal(State, CastSym)))
   return nullptr;
-return (SC->getType(), *Value);
+return (SC->getType(), *Value);
   } else if (const BinarySymExpr *BSE = dyn_cast(Sym)) {
 const llvm::APSInt *LHS, *RHS;
 if (const SymIntExpr *SIE = dyn_cast(BSE)) {
@@ -1215,7 +1222,7 @@
 QualType LTy = getAPSIntType(*LHS), RTy = getAPSIntType(*RHS);
 doIntTypeConversion(
 ConvertedLHS, LTy, ConvertedRHS, RTy);
-return BV.evalAPSInt(BSE->getOpcode(), ConvertedLHS, ConvertedRHS);
+return BVF.evalAPSInt(BSE->getOpcode(), ConvertedLHS, ConvertedRHS);
   }
 
   llvm_unreachable("Unsupported expression to get symbol value!");
@@ -1342,13 +1349,15 @@
   BinaryOperator::Opcode Op = BSE->getOpcode();
 
   if (const SymIntExpr *SIE = dyn_cast(BSE)) {
-RTy = getAPSIntType(SIE->getRHS());
 Z3Expr LHS = getZ3SymExpr(SIE->getLHS(), , hasComparison);
-Z3Expr RHS = Z3Expr::fromAPSInt(SIE->getRHS());
+llvm::APSInt NewRInt;
+std::tie(NewRInt, RTy) = fixAPSInt(SIE->getRHS());
+Z3Expr RHS = Z3Expr::fromAPSInt(NewRInt);
 return getZ3BinExpr(LHS, LTy, Op, RHS, RTy, RetTy);
   } else if (const IntSymExpr 

[PATCH] D47603: [analyzer] fix bug with 1-bit APSInt types in Z3ConstraintManager

2018-05-31 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added a comment.

In https://reviews.llvm.org/D47603#1118138, @vlad.tsyrklevich wrote:

> In https://reviews.llvm.org/D47603#1118106, @george.karpenkov wrote:
>
> > Would it be possible to add tests? I know we have very few unit tests, but 
> > I assume you could actually use an integration test to exercise this path?
>
>
> I tested this change and it fixes PR37622. There's a simple crash reproducer 
> included there.


Cool, thanks for the repro! It's been long enough since I've touched this code 
that I don't recall the original failing testcase. I'll add the test to this 
revision.




Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1044
   Z3Expr Exp = getZ3Expr(Sym, );
-
-  assert((getAPSIntType(From) == getAPSIntType(To)) &&
- "Range values have different types!");
-  QualType RTy = getAPSIntType(From);
-  bool isSignedTy = RetTy->isSignedIntegerOrEnumerationType();
-  Z3Expr FromExp = Z3Expr::fromAPSInt(From);
-  Z3Expr ToExp = Z3Expr::fromAPSInt(To);
+  QualType LTy;
+  llvm::APSInt NewFromInt;

george.karpenkov wrote:
> What does `L` stand for here? It's confusing because `L/R` usually stand for 
> left/right-hand-side in this context.
They correspond to the inferred left/right hand-side inferred types, but inside 
the subsequent Z3Expr `LHS` and `RHS` variables. This is confusing, so I'll 
rename them to `FromTy` and `ToTy`.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1154
+  BasicValueFactory  = getBasicVals();
+  ASTContext  = BVF.getContext();
 

george.karpenkov wrote:
> that's a separate change, but OK
Yeah, this is one of several small miscellaneous changes that didn't make the 
original commit. It seemed a bit excessive to open separate revisions for each, 
so I've just been merging them into the next patch. I'm not sure which is 
preferable?



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1426
+*Ty = getAPSIntType(Int);
+  return Int;
+}

george.karpenkov wrote:
> It's redundant to mutate the argument passed by reference and also return it.
> Could we take a single `APSInt` parameter by value and return 
> `std::pair` ?
Sure.


Repository:
  rC Clang

https://reviews.llvm.org/D47603



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


[PATCH] D47564: [Parse] Use CapturedStmt for @finally on MSVC

2018-05-31 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 149351.
smeenai edited the summary of this revision.
smeenai added a comment.

@rnk comment


Repository:
  rC Clang

https://reviews.llvm.org/D47564

Files:
  include/clang/AST/Stmt.h
  include/clang/Basic/CapturedStmt.h
  include/clang/Sema/ScopeInfo.h
  lib/Parse/ParseObjc.cpp
  test/SemaObjC/finally-msvc.m


Index: test/SemaObjC/finally-msvc.m
===
--- /dev/null
+++ test/SemaObjC/finally-msvc.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple i686--windows-msvc -fexceptions -fobjc-exceptions 
-ast-dump %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64--windows-msvc -fexceptions -fobjc-exceptions 
-ast-dump %s 2>&1 | FileCheck %s
+
+void f() {
+  @try {
+  } @finally {
+  }
+}
+
+// CHECK:  ObjCAtFinallyStmt
+// CHECK-NEXT:   CapturedStmt
+// CHECK-NEXT: CapturedDecl
+// CHECK-NEXT:   CompoundStmt
+// CHECK-NEXT:   ImplicitParamDecl
Index: lib/Parse/ParseObjc.cpp
===
--- lib/Parse/ParseObjc.cpp
+++ lib/Parse/ParseObjc.cpp
@@ -2585,13 +2585,26 @@
   ParseScope FinallyScope(this,
   Scope::DeclScope | Scope::CompoundStmtScope);
 
+  bool ShouldCapture =
+  getTargetInfo().getTriple().isWindowsMSVCEnvironment();
+  if (ShouldCapture)
+Actions.ActOnCapturedRegionStart(Tok.getLocation(), getCurScope(),
+ CR_ObjCAtFinally, 1);
+
   StmtResult FinallyBody(true);
   if (Tok.is(tok::l_brace))
 FinallyBody = ParseCompoundStatementBody();
   else
 Diag(Tok, diag::err_expected) << tok::l_brace;
-  if (FinallyBody.isInvalid())
+
+  if (FinallyBody.isInvalid()) {
 FinallyBody = Actions.ActOnNullStmt(Tok.getLocation());
+if (ShouldCapture)
+  Actions.ActOnCapturedRegionError();
+  } else if (ShouldCapture) {
+FinallyBody = Actions.ActOnCapturedRegionEnd(FinallyBody.get());
+  }
+
   FinallyStmt = Actions.ActOnObjCAtFinallyStmt(AtCatchFinallyLoc,
FinallyBody.get());
   catch_or_finally_seen = true;
Index: include/clang/Sema/ScopeInfo.h
===
--- include/clang/Sema/ScopeInfo.h
+++ include/clang/Sema/ScopeInfo.h
@@ -748,6 +748,8 @@
 switch (CapRegionKind) {
 case CR_Default:
   return "default captured statement";
+case CR_ObjCAtFinally:
+  return "Objective-C @finally statement";
 case CR_OpenMP:
   return "OpenMP region";
 }
Index: include/clang/Basic/CapturedStmt.h
===
--- include/clang/Basic/CapturedStmt.h
+++ include/clang/Basic/CapturedStmt.h
@@ -16,6 +16,7 @@
 /// The different kinds of captured statement.
 enum CapturedRegionKind {
   CR_Default,
+  CR_ObjCAtFinally,
   CR_OpenMP
 };
 
Index: include/clang/AST/Stmt.h
===
--- include/clang/AST/Stmt.h
+++ include/clang/AST/Stmt.h
@@ -2133,7 +2133,7 @@
 
   /// The pointer part is the implicit the outlined function and the 
   /// int part is the captured region kind, 'CR_Default' etc.
-  llvm::PointerIntPair CapDeclAndKind;
+  llvm::PointerIntPair CapDeclAndKind;
 
   /// The record for captured variables, a RecordDecl or CXXRecordDecl.
   RecordDecl *TheRecordDecl = nullptr;


Index: test/SemaObjC/finally-msvc.m
===
--- /dev/null
+++ test/SemaObjC/finally-msvc.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple i686--windows-msvc -fexceptions -fobjc-exceptions -ast-dump %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64--windows-msvc -fexceptions -fobjc-exceptions -ast-dump %s 2>&1 | FileCheck %s
+
+void f() {
+  @try {
+  } @finally {
+  }
+}
+
+// CHECK:  ObjCAtFinallyStmt
+// CHECK-NEXT:   CapturedStmt
+// CHECK-NEXT: CapturedDecl
+// CHECK-NEXT:   CompoundStmt
+// CHECK-NEXT:   ImplicitParamDecl
Index: lib/Parse/ParseObjc.cpp
===
--- lib/Parse/ParseObjc.cpp
+++ lib/Parse/ParseObjc.cpp
@@ -2585,13 +2585,26 @@
   ParseScope FinallyScope(this,
   Scope::DeclScope | Scope::CompoundStmtScope);
 
+  bool ShouldCapture =
+  getTargetInfo().getTriple().isWindowsMSVCEnvironment();
+  if (ShouldCapture)
+Actions.ActOnCapturedRegionStart(Tok.getLocation(), getCurScope(),
+ CR_ObjCAtFinally, 1);
+
   StmtResult FinallyBody(true);
   if (Tok.is(tok::l_brace))
 FinallyBody = ParseCompoundStatementBody();
   else
 Diag(Tok, diag::err_expected) << tok::l_brace;
-  if (FinallyBody.isInvalid())
+
+  if (FinallyBody.isInvalid()) {
 FinallyBody = 

[PATCH] D47603: [analyzer] fix bug with 1-bit APSInt types in Z3ConstraintManager

2018-05-31 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich added a comment.

In https://reviews.llvm.org/D47603#1118106, @george.karpenkov wrote:

> Would it be possible to add tests? I know we have very few unit tests, but I 
> assume you could actually use an integration test to exercise this path?


I tested this change and it fixes PR37622. There's a simple crash reproducer 
included there.


Repository:
  rC Clang

https://reviews.llvm.org/D47603



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


[PATCH] D47564: [Parse] Use CapturedStmt for @finally on MSVC

2018-05-31 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Using CapturedStmt to do frontend outlining was the direction I suggested. I 
want to hear what @rsmith and @rjmccall think, though.




Comment at: lib/Parse/ParseObjc.cpp:2588
 
+  bool ShouldCapture = Actions.getASTContext()
+   .getTargetInfo()

Parser has a `getTargetInfo()` method, so this can be shorter.


Repository:
  rC Clang

https://reviews.llvm.org/D47564



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


[PATCH] D47350: [analyzer] Track class member initializer constructors path-sensitively within their construction context.

2018-05-31 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.




https://reviews.llvm.org/D47350



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


[PATCH] D47603: [analyzer] fix bug with 1-bit APSInt types in Z3ConstraintManager

2018-05-31 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov requested changes to this revision.
george.karpenkov added a comment.
This revision now requires changes to proceed.

Thanks! Looks good with minor changes.

Would it be possible to add tests? I know we have very few unit tests, but I 
assume you could actually use an integration test to exercise this path?




Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1044
   Z3Expr Exp = getZ3Expr(Sym, );
-
-  assert((getAPSIntType(From) == getAPSIntType(To)) &&
- "Range values have different types!");
-  QualType RTy = getAPSIntType(From);
-  bool isSignedTy = RetTy->isSignedIntegerOrEnumerationType();
-  Z3Expr FromExp = Z3Expr::fromAPSInt(From);
-  Z3Expr ToExp = Z3Expr::fromAPSInt(To);
+  QualType LTy;
+  llvm::APSInt NewFromInt;

What does `L` stand for here? It's confusing because `L/R` usually stand for 
left/right-hand-side in this context.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1154
+  BasicValueFactory  = getBasicVals();
+  ASTContext  = BVF.getContext();
 

that's a separate change, but OK



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1426
+*Ty = getAPSIntType(Int);
+  return Int;
+}

It's redundant to mutate the argument passed by reference and also return it.
Could we take a single `APSInt` parameter by value and return 
`std::pair` ?



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1640
 #else
-  llvm::report_fatal_error("Clang was not compiled with Z3 support!", false);
+  llvm::report_fatal_error("Clang was not compiled with Z3 support, rebuild "
+   "with -DCLANG_ANALYZER_BUILD_Z3=ON",

that's a separate change, but OK


Repository:
  rC Clang

https://reviews.llvm.org/D47603



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


Re: [PATCH] D47597: IRGen: Write .dwo files when -split-dwarf-file is used together with -fthinlto-index.

2018-05-31 Thread Teresa Johnson via cfe-commits
On Thu, May 31, 2018 at 12:00 PM Peter Collingbourne 
wrote:

>
>
> On Thu, May 31, 2018 at 11:54 AM, David Blaikie 
> wrote:
>
>>
>>
>> On Thu, May 31, 2018 at 11:20 AM Peter Collingbourne via Phabricator <
>> revi...@reviews.llvm.org> wrote:
>>
>>> pcc created this revision.
>>> pcc added reviewers: tejohnson, dblaikie.
>>> Herald added subscribers: JDevlieghere, hiraditya, eraman, inglorion,
>>> mehdi_amini.
>>>
>>> https://reviews.llvm.org/D47597
>>>
>>> Files:
>>>   clang/lib/CodeGen/BackendUtil.cpp
>>>   clang/test/CodeGen/thinlto-split-dwarf.c
>>>   llvm/include/llvm/LTO/Config.h
>>>   llvm/lib/LTO/LTOBackend.cpp
>>>
>>>
>>> Index: llvm/lib/LTO/LTOBackend.cpp
>>> ===
>>> --- llvm/lib/LTO/LTOBackend.cpp
>>> +++ llvm/lib/LTO/LTOBackend.cpp
>>> @@ -291,14 +291,19 @@
>>>  return;
>>>
>>>std::unique_ptr DwoOut;
>>> +  SmallString<1024> DwoFile(Conf.DwoPath);
>>>if (!Conf.DwoDir.empty()) {
>>>  std::error_code EC;
>>>  if (auto EC = llvm::sys::fs::create_directories(Conf.DwoDir))
>>>report_fatal_error("Failed to create directory " + Conf.DwoDir +
>>> ": " +
>>>   EC.message());
>>>
>>> -SmallString<1024> DwoFile(Conf.DwoDir);
>>> +DwoFile = Conf.DwoDir;
>>>  sys::path::append(DwoFile, std::to_string(Task) + ".dwo");
>>> +  }
>>> +
>>> +  if (!DwoFile.empty()) {
>>> +std::error_code EC;
>>>  TM->Options.MCOptions.SplitDwarfFile = DwoFile.str().str();
>>>  DwoOut = llvm::make_unique(DwoFile, EC,
>>> sys::fs::F_None);
>>>  if (EC)
>>> Index: llvm/include/llvm/LTO/Config.h
>>> ===
>>> --- llvm/include/llvm/LTO/Config.h
>>> +++ llvm/include/llvm/LTO/Config.h
>>> @@ -76,6 +76,11 @@
>>>/// The directory to store .dwo files.
>>>std::string DwoDir;
>>>
>>> +  /// The path to write a .dwo file to. This should generally only be
>>> used when
>>> +  /// running an individual backend directly via thinBackend(), as
>>> otherwise
>>> +  /// all .dwo files will be written to the same path.
>>> +  std::string DwoPath;
>>> +
>>>/// Optimization remarks file path.
>>>std::string RemarksFilename = "";
>>>
>>> Index: clang/test/CodeGen/thinlto-split-dwarf.c
>>> ===
>>> --- /dev/null
>>> +++ clang/test/CodeGen/thinlto-split-dwarf.c
>>> @@ -0,0 +1,21 @@
>>> +// REQUIRES: x86-registered-target
>>> +
>>> +// RUN: %clang_cc1 -debug-info-kind=limited -triple
>>> x86_64-unknown-linux-gnu \
>>> +// RUN:   -flto=thin -emit-llvm-bc \
>>> +// RUN:   -o %t.o %s
>>> +
>>> +// RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
>>> +// RUN:   -o %t2.index \
>>> +// RUN:   -r=%t.o,main,px
>>> +
>>> +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu \
>>> +// RUN:   -emit-obj -fthinlto-index=%t.o.thinlto.bc \
>>> +// RUN:   -o %t.native.o -split-dwarf-file %t.native.dwo -x ir %t.o
>>>
>>
>> Can this be written in a single IR file yet (rather than frontend
>> compiling, indexing, then backend compiling), now that Teresa's implemented
>> some of the summary IR syntax?
>>
>
> I think the parsing part isn't implemented yet, so that wouldn't work.
>

Regarding this - the parsing support is coming along, slowly but surely.
I'd say I am about 75% done.
Teresa


> Besides, we would need two separate files anyway: the bitcode file (%t.o)
> and the combined summary (%t.o.thinlto.bc).
>
> Peter
>
>
>>
>>
>>> +
>>> +// RUN: llvm-readobj -sections %t.native.o | FileCheck --check-prefix=O
>>> %s
>>> +// RUN: llvm-readobj -sections %t.native.dwo | FileCheck
>>> --check-prefix=DWO %s
>>> +
>>> +// O-NOT: .dwo
>>> +// DWO: .dwo
>>> +
>>> +int main() {}
>>> Index: clang/lib/CodeGen/BackendUtil.cpp
>>> ===
>>> --- clang/lib/CodeGen/BackendUtil.cpp
>>> +++ clang/lib/CodeGen/BackendUtil.cpp
>>> @@ -1161,6 +1161,7 @@
>>>Conf.DebugPassManager = CGOpts.DebugPassManager;
>>>Conf.RemarksWithHotness = CGOpts.DiagnosticsWithHotness;
>>>Conf.RemarksFilename = CGOpts.OptRecordFile;
>>> +  Conf.DwoPath = CGOpts.SplitDwarfFile;
>>>switch (Action) {
>>>case Backend_EmitNothing:
>>>  Conf.PreCodeGenModuleHook = [](size_t Task, const Module ) {
>>>
>>>
>>>
>
>
> --
> --
> Peter
>


-- 
Teresa Johnson |  Software Engineer |  tejohn...@google.com |  408-460-2413
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47603: [analyzer] fix bug with 1-bit APSInt types in Z3ConstraintManager

2018-05-31 Thread Dominic Chen via Phabricator via cfe-commits
ddcc created this revision.
ddcc added reviewers: george.karpenkov, NoQ.
Herald added subscribers: a.sidorin, szepet, xazax.hun.

Clang does not have a corresponding QualType for a 1-bit APSInt, so use the 
BoolTy and extend the APSInt. Split from https://reviews.llvm.org/D35450.


Repository:
  rC Clang

https://reviews.llvm.org/D47603

Files:
  lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp

Index: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -987,6 +987,10 @@
   // TODO: Refactor to put elsewhere
   QualType getAPSIntType(const llvm::APSInt ) const;
 
+  // Fix the input APSInt if it is has a bitwidth of 1, and set the type.
+  const llvm::APSInt (const llvm::APSInt , llvm::APSInt ,
+QualType *Ty = nullptr) const;
+
   // Perform implicit type conversion on binary symbolic expressions.
   // May modify all input parameters.
   // TODO: Refactor to use built-in conversion functions
@@ -1037,28 +1041,29 @@
   QualType RetTy;
   // The expression may be casted, so we cannot call getZ3DataExpr() directly
   Z3Expr Exp = getZ3Expr(Sym, );
-
-  assert((getAPSIntType(From) == getAPSIntType(To)) &&
- "Range values have different types!");
-  QualType RTy = getAPSIntType(From);
-  bool isSignedTy = RetTy->isSignedIntegerOrEnumerationType();
-  Z3Expr FromExp = Z3Expr::fromAPSInt(From);
-  Z3Expr ToExp = Z3Expr::fromAPSInt(To);
+  QualType LTy;
+  llvm::APSInt NewFromInt;
+  Z3Expr FromExp = Z3Expr::fromAPSInt(fixAPSInt(From, NewFromInt, ));
 
   // Construct single (in)equality
   if (From == To)
 return assumeZ3Expr(State, Sym,
 getZ3BinExpr(Exp, RetTy, InRange ? BO_EQ : BO_NE,
- FromExp, RTy, nullptr));
+ FromExp, LTy, nullptr));
 
+  QualType RTy;
+  llvm::APSInt NewToInt;
+  Z3Expr ToExp = Z3Expr::fromAPSInt(fixAPSInt(To, NewToInt, ));
+  assert(LTy == RTy && "Range values have different types!");
   // Construct two (in)equalities, and a logical and/or
   Z3Expr LHS =
-  getZ3BinExpr(Exp, RetTy, InRange ? BO_GE : BO_LT, FromExp, RTy, nullptr);
+  getZ3BinExpr(Exp, RetTy, InRange ? BO_GE : BO_LT, FromExp, LTy, nullptr);
   Z3Expr RHS =
   getZ3BinExpr(Exp, RetTy, InRange ? BO_LE : BO_GT, ToExp, RTy, nullptr);
   return assumeZ3Expr(
   State, Sym,
-  Z3Expr::fromBinOp(LHS, InRange ? BO_LAnd : BO_LOr, RHS, isSignedTy));
+  Z3Expr::fromBinOp(LHS, InRange ? BO_LAnd : BO_LOr, RHS,
+RetTy->isSignedIntegerOrEnumerationType()));
 }
 
 ProgramStateRef Z3ConstraintManager::assumeSymUnsupported(ProgramStateRef State,
@@ -1145,8 +1150,8 @@
 
 const llvm::APSInt *Z3ConstraintManager::getSymVal(ProgramStateRef State,
SymbolRef Sym) const {
-  BasicValueFactory  = getBasicVals();
-  ASTContext  = BV.getContext();
+  BasicValueFactory  = getBasicVals();
+  ASTContext  = BVF.getContext();
 
   if (const SymbolData *SD = dyn_cast(Sym)) {
 QualType Ty = Sym->getType();
@@ -1180,7 +1185,7 @@
   return nullptr;
 
 // This is the only solution, store it
-return (Value);
+return (Value);
   } else if (const SymbolCast *SC = dyn_cast(Sym)) {
 SymbolRef CastSym = SC->getOperand();
 QualType CastTy = SC->getType();
@@ -1191,7 +1196,7 @@
 const llvm::APSInt *Value;
 if (!(Value = getSymVal(State, CastSym)))
   return nullptr;
-return (SC->getType(), *Value);
+return (SC->getType(), *Value);
   } else if (const BinarySymExpr *BSE = dyn_cast(Sym)) {
 const llvm::APSInt *LHS, *RHS;
 if (const SymIntExpr *SIE = dyn_cast(BSE)) {
@@ -1215,7 +1220,7 @@
 QualType LTy = getAPSIntType(*LHS), RTy = getAPSIntType(*RHS);
 doIntTypeConversion(
 ConvertedLHS, LTy, ConvertedRHS, RTy);
-return BV.evalAPSInt(BSE->getOpcode(), ConvertedLHS, ConvertedRHS);
+return BVF.evalAPSInt(BSE->getOpcode(), ConvertedLHS, ConvertedRHS);
   }
 
   llvm_unreachable("Unsupported expression to get symbol value!");
@@ -1342,13 +1347,13 @@
   BinaryOperator::Opcode Op = BSE->getOpcode();
 
   if (const SymIntExpr *SIE = dyn_cast(BSE)) {
-RTy = getAPSIntType(SIE->getRHS());
+llvm::APSInt NewRInt;
 Z3Expr LHS = getZ3SymExpr(SIE->getLHS(), , hasComparison);
-Z3Expr RHS = Z3Expr::fromAPSInt(SIE->getRHS());
+Z3Expr RHS = Z3Expr::fromAPSInt(fixAPSInt(SIE->getRHS(), NewRInt, ));
 return getZ3BinExpr(LHS, LTy, Op, RHS, RTy, RetTy);
   } else if (const IntSymExpr *ISE = dyn_cast(BSE)) {
-LTy = getAPSIntType(ISE->getLHS());
-Z3Expr LHS = Z3Expr::fromAPSInt(ISE->getLHS());
+llvm::APSInt NewLInt;
+Z3Expr LHS = Z3Expr::fromAPSInt(fixAPSInt(ISE->getLHS(), NewLInt, ));
 Z3Expr RHS = getZ3SymExpr(ISE->getRHS(), , hasComparison);
 return 

[PATCH] D47157: Warning for framework headers using double quote includes

2018-05-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D47157



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


[PATCH] D47157: Warning for framework headers using double quote includes

2018-05-31 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: test/Modules/double-quotes.m:27-29
+// CHECK: double-quoted include "A0.h" in framework header, expected 
angle-bracketed include  instead
+// CHECK: double-quoted include "B.h" in framework header, expected 
angle-bracketed include  instead
+// CHECK: double-quoted include "B.h" in framework header, expected 
angle-bracketed include  instead

aaron.ballman wrote:
> dexonsmith wrote:
> > When there's a fixit, you don't need to list it in the warning text (the 
> > fix-it itself is sufficient).  I also feel like "quoted include" is as 
> > clear as "double-quoted include" (but more succinct).  So I think these 
> > would be better as:
> > 
> > > warning: quoted include "..." in framework header, expected 
> > > angle-bracketed include instead
> > 
> Some other lexer diagnostics use "double-quoted" when they want to 
> distinguish with "angle-bracketed" (see 
> `warn_pragma_include_alias_mismatch_angle` and 
> `warn_pragma_include_alias_mismatch_quote` as examples). I don't have a 
> strong opinion on what form we use, but I'd prefer for it to be consistent 
> exposition.
I agree we should be consistent.  No reason to change it here then.


https://reviews.llvm.org/D47157



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


[PATCH] D46013: [ARM] Conform to AAPCS when passing overaligned composites as arguments

2018-05-31 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added reviewers: aemerson, rjmccall.
efriedma added a comment.

I'm not sure Apple will want to mess with their ABI like this... adding some 
reviewers.

Otherwise LGTM.




Comment at: lib/CodeGen/TargetInfo.cpp:5790
   // than ABI alignment.
-  uint64_t ABIAlign = 4;
-  uint64_t TyAlign = getContext().getTypeAlign(Ty) / 8;
-  if (getABIKind() == ARMABIInfo::AAPCS_VFP ||
-   getABIKind() == ARMABIInfo::AAPCS)
-ABIAlign = std::min(std::max(TyAlign, (uint64_t)4), (uint64_t)8);
-
+  uint64_t ABIAlign = 32;
+  uint64_t TyAlign;

I'd rather do alignment computations in bytes, rather than bits (can we use 
getTypeAlignInChars here?)


https://reviews.llvm.org/D46013



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


[PATCH] D47393: [clang-format] Disable AlwaysBreakBeforeMultilineStrings in Google style for Objective-C 

2018-05-31 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore updated this revision to Diff 149338.
stephanemoore added a comment.

Removed the last format from the tests. That particular scenario was failing 
and it might need additional changes to pass. I also think that particular 
scenario is not critical to the change and can be considered in a followup.


Repository:
  rC Clang

https://reviews.llvm.org/D47393

Files:
  lib/Format/Format.cpp
  unittests/Format/FormatTestObjC.cpp


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -1193,6 +1193,17 @@
"}");
 }
 
+TEST_F(FormatTestObjC, AlwaysBreakBeforeMultilineStrings) {
+  Style = getGoogleStyle(FormatStyle::LK_ObjC);
+  Style.ColumnLimit = 40;
+  verifyFormat(" = @\"\"\n"
+   "   @\"\";");
+  verifyFormat("(@\"\"\n"
+   " @\"\");");
+  verifyFormat("(qqq, @\"\"\n"
+   "  @\"\");");
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -799,6 +799,7 @@
 // has been implemented.
 GoogleStyle.BreakStringLiterals = false;
   } else if (Language == FormatStyle::LK_ObjC) {
+GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.ColumnLimit = 100;
   }
 


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -1193,6 +1193,17 @@
"}");
 }
 
+TEST_F(FormatTestObjC, AlwaysBreakBeforeMultilineStrings) {
+  Style = getGoogleStyle(FormatStyle::LK_ObjC);
+  Style.ColumnLimit = 40;
+  verifyFormat(" = @\"\"\n"
+   "   @\"\";");
+  verifyFormat("(@\"\"\n"
+   " @\"\");");
+  verifyFormat("(qqq, @\"\"\n"
+   "  @\"\");");
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -799,6 +799,7 @@
 // has been implemented.
 GoogleStyle.BreakStringLiterals = false;
   } else if (Language == FormatStyle::LK_ObjC) {
+GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.ColumnLimit = 100;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47350: [analyzer] Track class member initializer constructors path-sensitively within their construction context.

2018-05-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 149337.
NoQ added a comment.

Hmm, actually composition looks very pretty if you use the magic word "impl".


https://reviews.llvm.org/D47350

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  test/Analysis/cxx17-mandatory-elision.cpp

Index: test/Analysis/cxx17-mandatory-elision.cpp
===
--- test/Analysis/cxx17-mandatory-elision.cpp
+++ test/Analysis/cxx17-mandatory-elision.cpp
@@ -21,6 +21,37 @@
 } // namespace variable_functional_cast_crash
 
 
+namespace ctor_initializer {
+
+struct S {
+  int x, y, z;
+};
+
+struct T {
+  S s;
+  int w;
+  T(int w): s(), w(w) {}
+};
+
+class C {
+  T t;
+public:
+  C() : t(T(4)) {
+S s = {1, 2, 3};
+t.s = s;
+// FIXME: Should be TRUE in C++11 as well.
+clang_analyzer_eval(t.w == 4);
+#if __cplusplus >= 201703L
+// expected-warning@-2{{TRUE}}
+#else
+// expected-warning@-4{{UNKNOWN}}
+#endif
+  }
+};
+
+} // namespace ctor_initializer
+
+
 namespace address_vector_tests {
 
 template  struct AddressVector {
Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -153,6 +153,7 @@
   QualType Ty = Field->getType();
   FieldVal = makeZeroElementRegion(State, FieldVal, Ty,
CallOpts.IsArrayCtorOrDtor);
+  State = addObjectUnderConstruction(State, Init, LCtx, FieldVal);
   return std::make_pair(State, FieldVal);
 }
 case ConstructionContext::NewAllocatedObjectKind: {
@@ -272,35 +273,6 @@
   State, loc::MemRegionVal(MRMgr.getCXXTempObjectRegion(E, LCtx)));
 }
 
-const CXXConstructExpr *
-ExprEngine::findDirectConstructorForCurrentCFGElement() {
-  // Go backward in the CFG to see if the previous element (ignoring
-  // destructors) was a CXXConstructExpr. If so, that constructor
-  // was constructed directly into an existing region.
-  // This process is essentially the inverse of that performed in
-  // findElementDirectlyInitializedByCurrentConstructor().
-  if (currStmtIdx == 0)
-return nullptr;
-
-  const CFGBlock *B = getBuilderContext().getBlock();
-
-  unsigned int PreviousStmtIdx = currStmtIdx - 1;
-  CFGElement Previous = (*B)[PreviousStmtIdx];
-
-  while (Previous.getAs() && PreviousStmtIdx > 0) {
---PreviousStmtIdx;
-Previous = (*B)[PreviousStmtIdx];
-  }
-
-  if (Optional PrevStmtElem = Previous.getAs()) {
-if (auto *CtorExpr = dyn_cast(PrevStmtElem->getStmt())) {
-  return CtorExpr;
-}
-  }
-
-  return nullptr;
-}
-
 void ExprEngine::VisitCXXConstructExpr(const CXXConstructExpr *CE,
ExplodedNode *Pred,
ExplodedNodeSet ) {
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -109,7 +109,75 @@
 // to the object's location, so that on every such statement the location
 // could have been retrieved.
 
-typedef std::pair ConstructedObjectKey;
+/// ConstructedObjectKey is used for being able to find the path-sensitive
+/// memory region of a freshly constructed object while modeling the AST node
+/// that syntactically represents the object that is being constructed.
+/// Semantics of such nodes may sometimes require access to the region that's
+/// not otherwise present in the program state, or to the very fact that
+/// the construction context was present and contained references to these
+/// AST nodes.
+class ConstructedObjectKey {
+  typedef std::pair<
+  llvm::PointerUnion,
+  const LocationContext *> ConstructedObjectKeyImpl;
+
+  ConstructedObjectKeyImpl Impl;
+
+  const void *getAnyASTNodePtr() const {
+if (const Stmt *S = getStmt())
+  return S;
+else
+  return getCXXCtorInitializer();
+  }
+
+public:
+  ConstructedObjectKey(
+  llvm::PointerUnion P,
+  const LocationContext *LC)
+  : Impl(P, LC) {
+// This is the full list of statements that require additional actions when
+// encountered. This list may be expanded when new actions are implemented.
+assert(getCXXCtorInitializer() || isa(getStmt()) ||
+   isa(getStmt()) || isa(getStmt()) ||
+   isa(getStmt()));
+  }
+
+  const Stmt *getStmt() const {
+return Impl.first.dyn_cast();
+  }
+
+  const CXXCtorInitializer *getCXXCtorInitializer() const {
+return Impl.first.dyn_cast();
+  }
+
+  const LocationContext *getLocationContext() const {
+return Impl.second;
+  }
+
+  void print(llvm::raw_ostream , PrinterHelper *Helper, PrintingPolicy ) {
+OS << '(' << getLocationContext() << ',' << getAnyASTNodePtr() << ") ";
+if (const Stmt *S 

[PATCH] D46664: Fix null MSInheritanceAttr deref in CXXRecordDecl::getMSInheritanceModel()

2018-05-31 Thread Andrew Rogers via Phabricator via cfe-commits
adr26 added a comment.

That's a nice change to avoid duplication in 
`ClassTemplateSpecializationDecl::getMostRecentDecl()`. Thanks for your help 
getting this out the door!


Repository:
  rC Clang

https://reviews.llvm.org/D46664



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


[PATCH] D47445: [ASTImporter] Corrected diagnostic client handling in tests.

2018-05-31 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added a comment.

Thanks for the explanation. Please do add documentation comments for the new 
method so people using ASTUnit in their own code have an idea when and why they 
would need to call this. Something like "if you intend to emit additional 
diagnostics after the ASTUnit is created [...]". 
Also consider making the naming more clear to match the intended purpose, like 
`enableEmittingAdditionalDiagnostics()` or something similar.
Otherwise LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D47445



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


Re: [PATCH] D47597: IRGen: Write .dwo files when -split-dwarf-file is used together with -fthinlto-index.

2018-05-31 Thread Peter Collingbourne via cfe-commits
On Thu, May 31, 2018 at 11:54 AM, David Blaikie  wrote:

>
>
> On Thu, May 31, 2018 at 11:20 AM Peter Collingbourne via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> pcc created this revision.
>> pcc added reviewers: tejohnson, dblaikie.
>> Herald added subscribers: JDevlieghere, hiraditya, eraman, inglorion,
>> mehdi_amini.
>>
>> https://reviews.llvm.org/D47597
>>
>> Files:
>>   clang/lib/CodeGen/BackendUtil.cpp
>>   clang/test/CodeGen/thinlto-split-dwarf.c
>>   llvm/include/llvm/LTO/Config.h
>>   llvm/lib/LTO/LTOBackend.cpp
>>
>>
>> Index: llvm/lib/LTO/LTOBackend.cpp
>> ===
>> --- llvm/lib/LTO/LTOBackend.cpp
>> +++ llvm/lib/LTO/LTOBackend.cpp
>> @@ -291,14 +291,19 @@
>>  return;
>>
>>std::unique_ptr DwoOut;
>> +  SmallString<1024> DwoFile(Conf.DwoPath);
>>if (!Conf.DwoDir.empty()) {
>>  std::error_code EC;
>>  if (auto EC = llvm::sys::fs::create_directories(Conf.DwoDir))
>>report_fatal_error("Failed to create directory " + Conf.DwoDir +
>> ": " +
>>   EC.message());
>>
>> -SmallString<1024> DwoFile(Conf.DwoDir);
>> +DwoFile = Conf.DwoDir;
>>  sys::path::append(DwoFile, std::to_string(Task) + ".dwo");
>> +  }
>> +
>> +  if (!DwoFile.empty()) {
>> +std::error_code EC;
>>  TM->Options.MCOptions.SplitDwarfFile = DwoFile.str().str();
>>  DwoOut = llvm::make_unique(DwoFile, EC,
>> sys::fs::F_None);
>>  if (EC)
>> Index: llvm/include/llvm/LTO/Config.h
>> ===
>> --- llvm/include/llvm/LTO/Config.h
>> +++ llvm/include/llvm/LTO/Config.h
>> @@ -76,6 +76,11 @@
>>/// The directory to store .dwo files.
>>std::string DwoDir;
>>
>> +  /// The path to write a .dwo file to. This should generally only be
>> used when
>> +  /// running an individual backend directly via thinBackend(), as
>> otherwise
>> +  /// all .dwo files will be written to the same path.
>> +  std::string DwoPath;
>> +
>>/// Optimization remarks file path.
>>std::string RemarksFilename = "";
>>
>> Index: clang/test/CodeGen/thinlto-split-dwarf.c
>> ===
>> --- /dev/null
>> +++ clang/test/CodeGen/thinlto-split-dwarf.c
>> @@ -0,0 +1,21 @@
>> +// REQUIRES: x86-registered-target
>> +
>> +// RUN: %clang_cc1 -debug-info-kind=limited -triple
>> x86_64-unknown-linux-gnu \
>> +// RUN:   -flto=thin -emit-llvm-bc \
>> +// RUN:   -o %t.o %s
>> +
>> +// RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
>> +// RUN:   -o %t2.index \
>> +// RUN:   -r=%t.o,main,px
>> +
>> +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu \
>> +// RUN:   -emit-obj -fthinlto-index=%t.o.thinlto.bc \
>> +// RUN:   -o %t.native.o -split-dwarf-file %t.native.dwo -x ir %t.o
>>
>
> Can this be written in a single IR file yet (rather than frontend
> compiling, indexing, then backend compiling), now that Teresa's implemented
> some of the summary IR syntax?
>

I think the parsing part isn't implemented yet, so that wouldn't work.
Besides, we would need two separate files anyway: the bitcode file (%t.o)
and the combined summary (%t.o.thinlto.bc).

Peter


>
>
>> +
>> +// RUN: llvm-readobj -sections %t.native.o | FileCheck --check-prefix=O
>> %s
>> +// RUN: llvm-readobj -sections %t.native.dwo | FileCheck
>> --check-prefix=DWO %s
>> +
>> +// O-NOT: .dwo
>> +// DWO: .dwo
>> +
>> +int main() {}
>> Index: clang/lib/CodeGen/BackendUtil.cpp
>> ===
>> --- clang/lib/CodeGen/BackendUtil.cpp
>> +++ clang/lib/CodeGen/BackendUtil.cpp
>> @@ -1161,6 +1161,7 @@
>>Conf.DebugPassManager = CGOpts.DebugPassManager;
>>Conf.RemarksWithHotness = CGOpts.DiagnosticsWithHotness;
>>Conf.RemarksFilename = CGOpts.OptRecordFile;
>> +  Conf.DwoPath = CGOpts.SplitDwarfFile;
>>switch (Action) {
>>case Backend_EmitNothing:
>>  Conf.PreCodeGenModuleHook = [](size_t Task, const Module ) {
>>
>>
>>


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


[PATCH] D47600: [UBSan] DO NOT COMMIT: precise UBSan checks experiment

2018-05-31 Thread Aleksey Shlyapnikov via Phabricator via cfe-commits
alekseyshl created this revision.

clang part of the two part patch (LLVM + clang)

LLVM part: https://reviews.llvm.org/D47599

Refer to https://reviews.llvm.org/D47599 for the detailed description.


Repository:
  rC Clang

https://reviews.llvm.org/D47600

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGExpr.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp

Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1118,6 +1118,10 @@
 
   Opts.EmitVersionIdentMetadata = Args.hasFlag(OPT_Qy, OPT_Qn, true);
 
+  Opts.ExperimentalUseCondTrap = Args.hasFlag(
+  OPT_fexperimental_use_cond_trap, OPT_fno_experimental_use_cond_trap,
+  /* Default */ false);
+
   return Success;
 }
 
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4799,6 +4799,9 @@
   CmdArgs.push_back("-fforce-enable-int128");
   }
 
+  Args.AddLastArg(CmdArgs, options::OPT_fexperimental_use_cond_trap,
+  options::OPT_fno_experimental_use_cond_trap);
+
   // Finally add the compile command to the compilation.
   if (Args.hasArg(options::OPT__SLASH_fallback) &&
   Output.getType() == types::TY_Object &&
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -3131,18 +3131,25 @@
 void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked) {
   llvm::BasicBlock *Cont = createBasicBlock("cont");
 
-  // If we're optimizing, collapse all calls to trap down to just one per
-  // function to save on code size.
-  if (!CGM.getCodeGenOpts().OptimizationLevel || !TrapBB) {
-TrapBB = createBasicBlock("trap");
+  if (CGM.getCodeGenOpts().ExperimentalUseCondTrap) {
+TrapBB = createBasicBlock("condtrap");
 Builder.CreateCondBr(Checked, Cont, TrapBB);
 EmitBlock(TrapBB);
-llvm::CallInst *TrapCall = EmitTrapCall(llvm::Intrinsic::trap);
-TrapCall->setDoesNotReturn();
-TrapCall->setDoesNotThrow();
-Builder.CreateUnreachable();
+Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::condtrap));
   } else {
-Builder.CreateCondBr(Checked, Cont, TrapBB);
+// If we're optimizing, collapse all calls to trap down to just one per
+// function to save on code size.
+if (!CGM.getCodeGenOpts().OptimizationLevel || !TrapBB) {
+  TrapBB = createBasicBlock("trap");
+  Builder.CreateCondBr(Checked, Cont, TrapBB);
+  EmitBlock(TrapBB);
+  llvm::CallInst *TrapCall = EmitTrapCall(llvm::Intrinsic::trap);
+  TrapCall->setDoesNotReturn();
+  TrapCall->setDoesNotThrow();
+  Builder.CreateUnreachable();
+} else {
+  Builder.CreateCondBr(Checked, Cont, TrapBB);
+}
   }
 
   EmitBlock(Cont);
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -332,6 +332,8 @@
 /// Whether to embed source in DWARF debug line section.
 CODEGENOPT(EmbedSource, 1, 0)
 
+CODEGENOPT(ExperimentalUseCondTrap, 1, 0)
+
 #undef CODEGENOPT
 #undef ENUM_CODEGENOPT
 #undef VALUE_CODEGENOPT
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1102,6 +1102,10 @@
   Alias, AliasArgs<["full"]>,
   HelpText<"Enable cf-protection in 'full' mode">;
 
+def fexperimental_use_cond_trap : Flag<["-"], "fexperimental-use-cond-trap">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Enables an experimental conditional trap in LLVM.">;
+
 def fxray_instrument : Flag<["-"], "fxray-instrument">, Group,
   Flags<[CC1Option]>,
   HelpText<"Generate XRay instrumentation sleds on function entry and exit">;
@@ -1437,6 +1441,10 @@
 def : Flag<["-"], "fno-aligned-new">, Alias;
 def faligned_new_EQ : Joined<["-"], "faligned-new=">;
 
+def fno_experimental_use_cond_trap : Flag<["-"], "fno-experimental-use-cond-trap">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Disables an experimental conditional trap in LLVM.">;
+
 def fobjc_legacy_dispatch : Flag<["-"], "fobjc-legacy-dispatch">, Group;
 def fobjc_new_property : Flag<["-"], "fobjc-new-property">, Group;
 def fobjc_infer_related_result_type : Flag<["-"], "fobjc-infer-related-result-type">,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D47597: IRGen: Write .dwo files when -split-dwarf-file is used together with -fthinlto-index.

2018-05-31 Thread David Blaikie via cfe-commits
On Thu, May 31, 2018 at 11:20 AM Peter Collingbourne via Phabricator <
revi...@reviews.llvm.org> wrote:

> pcc created this revision.
> pcc added reviewers: tejohnson, dblaikie.
> Herald added subscribers: JDevlieghere, hiraditya, eraman, inglorion,
> mehdi_amini.
>
> https://reviews.llvm.org/D47597
>
> Files:
>   clang/lib/CodeGen/BackendUtil.cpp
>   clang/test/CodeGen/thinlto-split-dwarf.c
>   llvm/include/llvm/LTO/Config.h
>   llvm/lib/LTO/LTOBackend.cpp
>
>
> Index: llvm/lib/LTO/LTOBackend.cpp
> ===
> --- llvm/lib/LTO/LTOBackend.cpp
> +++ llvm/lib/LTO/LTOBackend.cpp
> @@ -291,14 +291,19 @@
>  return;
>
>std::unique_ptr DwoOut;
> +  SmallString<1024> DwoFile(Conf.DwoPath);
>if (!Conf.DwoDir.empty()) {
>  std::error_code EC;
>  if (auto EC = llvm::sys::fs::create_directories(Conf.DwoDir))
>report_fatal_error("Failed to create directory " + Conf.DwoDir + ":
> " +
>   EC.message());
>
> -SmallString<1024> DwoFile(Conf.DwoDir);
> +DwoFile = Conf.DwoDir;
>  sys::path::append(DwoFile, std::to_string(Task) + ".dwo");
> +  }
> +
> +  if (!DwoFile.empty()) {
> +std::error_code EC;
>  TM->Options.MCOptions.SplitDwarfFile = DwoFile.str().str();
>  DwoOut = llvm::make_unique(DwoFile, EC,
> sys::fs::F_None);
>  if (EC)
> Index: llvm/include/llvm/LTO/Config.h
> ===
> --- llvm/include/llvm/LTO/Config.h
> +++ llvm/include/llvm/LTO/Config.h
> @@ -76,6 +76,11 @@
>/// The directory to store .dwo files.
>std::string DwoDir;
>
> +  /// The path to write a .dwo file to. This should generally only be
> used when
> +  /// running an individual backend directly via thinBackend(), as
> otherwise
> +  /// all .dwo files will be written to the same path.
> +  std::string DwoPath;
> +
>/// Optimization remarks file path.
>std::string RemarksFilename = "";
>
> Index: clang/test/CodeGen/thinlto-split-dwarf.c
> ===
> --- /dev/null
> +++ clang/test/CodeGen/thinlto-split-dwarf.c
> @@ -0,0 +1,21 @@
> +// REQUIRES: x86-registered-target
> +
> +// RUN: %clang_cc1 -debug-info-kind=limited -triple
> x86_64-unknown-linux-gnu \
> +// RUN:   -flto=thin -emit-llvm-bc \
> +// RUN:   -o %t.o %s
> +
> +// RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
> +// RUN:   -o %t2.index \
> +// RUN:   -r=%t.o,main,px
> +
> +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu \
> +// RUN:   -emit-obj -fthinlto-index=%t.o.thinlto.bc \
> +// RUN:   -o %t.native.o -split-dwarf-file %t.native.dwo -x ir %t.o
>

Can this be written in a single IR file yet (rather than frontend
compiling, indexing, then backend compiling), now that Teresa's implemented
some of the summary IR syntax?


> +
> +// RUN: llvm-readobj -sections %t.native.o | FileCheck --check-prefix=O %s
> +// RUN: llvm-readobj -sections %t.native.dwo | FileCheck
> --check-prefix=DWO %s
> +
> +// O-NOT: .dwo
> +// DWO: .dwo
> +
> +int main() {}
> Index: clang/lib/CodeGen/BackendUtil.cpp
> ===
> --- clang/lib/CodeGen/BackendUtil.cpp
> +++ clang/lib/CodeGen/BackendUtil.cpp
> @@ -1161,6 +1161,7 @@
>Conf.DebugPassManager = CGOpts.DebugPassManager;
>Conf.RemarksWithHotness = CGOpts.DiagnosticsWithHotness;
>Conf.RemarksFilename = CGOpts.OptRecordFile;
> +  Conf.DwoPath = CGOpts.SplitDwarfFile;
>switch (Action) {
>case Backend_EmitNothing:
>  Conf.PreCodeGenModuleHook = [](size_t Task, const Module ) {
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45517: [analyzer] False positive refutation with Z3

2018-05-31 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs added a comment.

In https://reviews.llvm.org/D45517#1117898, @mikhail.ramalho wrote:

> Just want to comment here and give thanks again for the first version of
>  the refutation code. It's being really helpful to develop the approach this
>  code as a base; things would definitely be slower if I had to start it from
>  scratch.


@mikhail.ramalho Thanks for this note, it's very nice of you :)
I'm glad if it saves a bit of time, but it's only a rough sketch, so please 
feel free to tailor it to your liking (and the reviewers' of course).


https://reviews.llvm.org/D45517



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


[PATCH] D46664: Fix null MSInheritanceAttr deref in CXXRecordDecl::getMSInheritanceModel()

2018-05-31 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Thanks for the patch, I committed it as r333680 with a minor modification.


https://reviews.llvm.org/D46664



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


[PATCH] D46664: Fix null MSInheritanceAttr deref in CXXRecordDecl::getMSInheritanceModel()

2018-05-31 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC333680: Fix null MSInheritanceAttr deref in 
CXXRecordDecl::getMSInheritanceModel() (authored by rnk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46664?vs=149300=149329#toc

Repository:
  rC Clang

https://reviews.llvm.org/D46664

Files:
  include/clang/AST/DeclCXX.h
  include/clang/AST/DeclTemplate.h
  lib/AST/MicrosoftMangle.cpp
  lib/AST/Type.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/microsoft-abi-member-pointers.cpp

Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -2733,7 +2733,7 @@
   assert(MD->isInstance() && "Member function must not be static!");
 
   CharUnits NonVirtualBaseAdjustment = CharUnits::Zero();
-  const CXXRecordDecl *RD = MD->getParent()->getMostRecentDecl();
+  const CXXRecordDecl *RD = MD->getParent()->getMostRecentNonInjectedDecl();
   CodeGenTypes  = CGM.getTypes();
 
   unsigned VBTableIndex = 0;
Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1370,12 +1370,12 @@
 const NamedDecl *ND = TA.getAsDecl();
 if (isa(ND) || isa(ND)) {
   mangleMemberDataPointer(
-  cast(ND->getDeclContext())->getMostRecentDecl(),
+  cast(ND->getDeclContext())->getMostRecentNonInjectedDecl(),
   cast(ND));
 } else if (const FunctionDecl *FD = dyn_cast(ND)) {
   const CXXMethodDecl *MD = dyn_cast(FD);
   if (MD && MD->isInstance()) {
-mangleMemberFunctionPointer(MD->getParent()->getMostRecentDecl(), MD);
+mangleMemberFunctionPointer(MD->getParent()->getMostRecentNonInjectedDecl(), MD);
   } else {
 Out << "$1?";
 mangleName(FD);
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -2040,7 +2040,7 @@
   return false;
 // The inheritance attribute might only be present on the most recent
 // CXXRecordDecl, use that one.
-RD = RD->getMostRecentDecl();
+RD = RD->getMostRecentNonInjectedDecl();
 // Nothing interesting to do if the inheritance attribute is already set.
 if (RD->hasAttr())
   return false;
@@ -3936,5 +3936,5 @@
 }
 
 CXXRecordDecl *MemberPointerType::getMostRecentCXXRecordDecl() const {
-  return getClass()->getAsCXXRecordDecl()->getMostRecentDecl();
+  return getClass()->getAsCXXRecordDecl()->getMostRecentNonInjectedDecl();
 }
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7544,7 +7544,7 @@
 
 /// Locks in the inheritance model for the given class and all of its bases.
 static void assignInheritanceModel(Sema , CXXRecordDecl *RD) {
-  RD = RD->getMostRecentDecl();
+  RD = RD->getMostRecentNonInjectedDecl();
   if (!RD->hasAttr()) {
 MSInheritanceAttr::Spelling IM;
 
Index: include/clang/AST/DeclCXX.h
===
--- include/clang/AST/DeclCXX.h
+++ include/clang/AST/DeclCXX.h
@@ -751,6 +751,21 @@
 return const_cast(this)->getMostRecentDecl();
   }
 
+  CXXRecordDecl *getMostRecentNonInjectedDecl() {
+CXXRecordDecl *Recent =
+static_cast(this)->getMostRecentDecl();
+while (Recent->isInjectedClassName()) {
+  // FIXME: Does injected class name need to be in the redeclarations chain?
+  assert(Recent->getPreviousDecl());
+  Recent = Recent->getPreviousDecl();
+}
+return Recent;
+  }
+
+  const CXXRecordDecl *getMostRecentNonInjectedDecl() const {
+return const_cast(this)->getMostRecentNonInjectedDecl();
+  }
+
   CXXRecordDecl *getDefinition() const {
 // We only need an update if we don't already know which
 // declaration is the definition.
Index: include/clang/AST/DeclTemplate.h
===
--- include/clang/AST/DeclTemplate.h
+++ include/clang/AST/DeclTemplate.h
@@ -1720,14 +1720,8 @@
   // it's not clear that we should override that, because the most recent
   // declaration as a CXXRecordDecl sometimes is the injected-class-name.
   ClassTemplateSpecializationDecl *getMostRecentDecl() {
-CXXRecordDecl *Recent = static_cast(
-  this)->getMostRecentDecl();
-while (!isa(Recent)) {
-  // FIXME: Does injected class name need to be in the redeclarations chain?
-  assert(Recent->isInjectedClassName() && Recent->getPreviousDecl());
-  Recent = Recent->getPreviousDecl();
-}
-return cast(Recent);
+return cast(
+getMostRecentNonInjectedDecl());
   }
 
   /// Retrieve the template that this specialization specializes.
Index: 

r333680 - Fix null MSInheritanceAttr deref in CXXRecordDecl::getMSInheritanceModel()

2018-05-31 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu May 31 11:42:29 2018
New Revision: 333680

URL: http://llvm.org/viewvc/llvm-project?rev=333680=rev
Log:
Fix null MSInheritanceAttr deref in CXXRecordDecl::getMSInheritanceModel()

Ensure latest MPT decl has a MSInheritanceAttr when instantiating
templates, to avoid null MSInheritanceAttr deref in
CXXRecordDecl::getMSInheritanceModel().

See PR#37399 for repo / details.

Patch by Andrew Rogers!

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

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=333680=333679=333680=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Thu May 31 11:42:29 2018
@@ -751,6 +751,21 @@ public:
 return const_cast(this)->getMostRecentDecl();
   }
 
+  CXXRecordDecl *getMostRecentNonInjectedDecl() {
+CXXRecordDecl *Recent =
+static_cast(this)->getMostRecentDecl();
+while (Recent->isInjectedClassName()) {
+  // FIXME: Does injected class name need to be in the redeclarations 
chain?
+  assert(Recent->getPreviousDecl());
+  Recent = Recent->getPreviousDecl();
+}
+return Recent;
+  }
+
+  const CXXRecordDecl *getMostRecentNonInjectedDecl() const {
+return const_cast(this)->getMostRecentNonInjectedDecl();
+  }
+
   CXXRecordDecl *getDefinition() const {
 // We only need an update if we don't already know which
 // declaration is the definition.

Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=333680=333679=333680=diff
==
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Thu May 31 11:42:29 2018
@@ -1720,14 +1720,8 @@ public:
   // it's not clear that we should override that, because the most recent
   // declaration as a CXXRecordDecl sometimes is the injected-class-name.
   ClassTemplateSpecializationDecl *getMostRecentDecl() {
-CXXRecordDecl *Recent = static_cast(
-  this)->getMostRecentDecl();
-while (!isa(Recent)) {
-  // FIXME: Does injected class name need to be in the redeclarations 
chain?
-  assert(Recent->isInjectedClassName() && Recent->getPreviousDecl());
-  Recent = Recent->getPreviousDecl();
-}
-return cast(Recent);
+return cast(
+getMostRecentNonInjectedDecl());
   }
 
   /// Retrieve the template that this specialization specializes.

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=333680=333679=333680=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Thu May 31 11:42:29 2018
@@ -1370,12 +1370,12 @@ void MicrosoftCXXNameMangler::mangleTemp
 const NamedDecl *ND = TA.getAsDecl();
 if (isa(ND) || isa(ND)) {
   mangleMemberDataPointer(
-  cast(ND->getDeclContext())->getMostRecentDecl(),
+  
cast(ND->getDeclContext())->getMostRecentNonInjectedDecl(),
   cast(ND));
 } else if (const FunctionDecl *FD = dyn_cast(ND)) {
   const CXXMethodDecl *MD = dyn_cast(FD);
   if (MD && MD->isInstance()) {
-mangleMemberFunctionPointer(MD->getParent()->getMostRecentDecl(), MD);
+
mangleMemberFunctionPointer(MD->getParent()->getMostRecentNonInjectedDecl(), 
MD);
   } else {
 Out << "$1?";
 mangleName(FD);

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=333680=333679=333680=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Thu May 31 11:42:29 2018
@@ -2040,7 +2040,7 @@ bool Type::isIncompleteType(NamedDecl **
   return false;
 // The inheritance attribute might only be present on the most recent
 // CXXRecordDecl, use that one.
-RD = RD->getMostRecentDecl();
+RD = RD->getMostRecentNonInjectedDecl();
 // Nothing interesting to do if the inheritance attribute is already set.
 if (RD->hasAttr())
   return false;
@@ -3936,5 +3936,5 @@ QualType::DestructionKind QualType::isDe
 }
 
 CXXRecordDecl *MemberPointerType::getMostRecentCXXRecordDecl() const {
-  return getClass()->getAsCXXRecordDecl()->getMostRecentDecl();
+  return 

[PATCH] D47157: Warning for framework headers using double quote includes

2018-05-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: test/Modules/double-quotes.m:27-29
+// CHECK: double-quoted include "A0.h" in framework header, expected 
angle-bracketed include  instead
+// CHECK: double-quoted include "B.h" in framework header, expected 
angle-bracketed include  instead
+// CHECK: double-quoted include "B.h" in framework header, expected 
angle-bracketed include  instead

dexonsmith wrote:
> When there's a fixit, you don't need to list it in the warning text (the 
> fix-it itself is sufficient).  I also feel like "quoted include" is as clear 
> as "double-quoted include" (but more succinct).  So I think these would be 
> better as:
> 
> > warning: quoted include "..." in framework header, expected angle-bracketed 
> > include instead
> 
Some other lexer diagnostics use "double-quoted" when they want to distinguish 
with "angle-bracketed" (see `warn_pragma_include_alias_mismatch_angle` and 
`warn_pragma_include_alias_mismatch_quote` as examples). I don't have a strong 
opinion on what form we use, but I'd prefer for it to be consistent exposition.


https://reviews.llvm.org/D47157



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


[PATCH] D47499: [analyzer] Annotate program state update methods with LLVM_NODISCARD.

2018-05-31 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333679: [analyzer] Annotate ProgramState update methods with 
LLVM_NODISCARD. (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47499?vs=148988=149328#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47499

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -177,38 +177,38 @@
   ///
   /// This returns a new state with the added constraint on \p cond.
   /// If no new state is feasible, NULL is returned.
-  ProgramStateRef assume(DefinedOrUnknownSVal cond, bool assumption) const;
+  LLVM_NODISCARD ProgramStateRef assume(DefinedOrUnknownSVal cond,
+bool assumption) const;
 
   /// Assumes both "true" and "false" for \p cond, and returns both
   /// corresponding states (respectively).
   ///
   /// This is more efficient than calling assume() twice. Note that one (but not
   /// both) of the returned states may be NULL.
-  std::pair
+  LLVM_NODISCARD std::pair
   assume(DefinedOrUnknownSVal cond) const;
 
-  ProgramStateRef assumeInBound(DefinedOrUnknownSVal idx,
-   DefinedOrUnknownSVal upperBound,
-   bool assumption,
-   QualType IndexType = QualType()) const;
+  LLVM_NODISCARD ProgramStateRef
+  assumeInBound(DefinedOrUnknownSVal idx, DefinedOrUnknownSVal upperBound,
+bool assumption, QualType IndexType = QualType()) const;
 
   /// Assumes that the value of \p Val is bounded with [\p From; \p To]
   /// (if \p assumption is "true") or it is fully out of this range
   /// (if \p assumption is "false").
   ///
   /// This returns a new state with the added constraint on \p cond.
   /// If no new state is feasible, NULL is returned.
-  ProgramStateRef assumeInclusiveRange(DefinedOrUnknownSVal Val,
-   const llvm::APSInt ,
-   const llvm::APSInt ,
-   bool assumption) const;
+  LLVM_NODISCARD ProgramStateRef assumeInclusiveRange(DefinedOrUnknownSVal Val,
+  const llvm::APSInt ,
+  const llvm::APSInt ,
+  bool assumption) const;
 
   /// Assumes given range both "true" and "false" for \p Val, and returns both
   /// corresponding states (respectively).
   ///
   /// This is more efficient than calling assume() twice. Note that one (but not
   /// both) of the returned states may be NULL.
-  std::pair
+  LLVM_NODISCARD std::pair
   assumeInclusiveRange(DefinedOrUnknownSVal Val, const llvm::APSInt ,
const llvm::APSInt ) const;
 
@@ -232,30 +232,32 @@
 
   /// Create a new state by binding the value 'V' to the statement 'S' in the
   /// state's environment.
-  ProgramStateRef BindExpr(const Stmt *S, const LocationContext *LCtx,
-   SVal V, bool Invalidate = true) const;
+  LLVM_NODISCARD ProgramStateRef BindExpr(const Stmt *S,
+  const LocationContext *LCtx, SVal V,
+  bool Invalidate = true) const;
+
+  LLVM_NODISCARD ProgramStateRef bindLoc(Loc location, SVal V,
+ const LocationContext *LCtx,
+ bool notifyChanges = true) const;
 
-  ProgramStateRef bindLoc(Loc location,
-  SVal V,
-  const LocationContext *LCtx,
-  bool notifyChanges = true) const;
-
-  ProgramStateRef bindLoc(SVal location, SVal V, const LocationContext *LCtx) const;
+  LLVM_NODISCARD ProgramStateRef bindLoc(SVal location, SVal V,
+ const LocationContext *LCtx) const;
 
   /// Initializes the region of memory represented by \p loc with an initial
   /// value. Once initialized, all values loaded from any sub-regions of that
   /// region will be equal to \p V, unless overwritten later by the program.
   /// This method should not be used on regions that are already initialized.
   /// If you need to indicate that memory contents have suddenly become unknown
   /// within a certain region of memory, consider invalidateRegions().
-  ProgramStateRef bindDefaultInitial(SVal loc, SVal V,
- const LocationContext *LCtx) const;
+  LLVM_NODISCARD ProgramStateRef
+  bindDefaultInitial(SVal 

r333679 - [analyzer] Annotate ProgramState update methods with LLVM_NODISCARD.

2018-05-31 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu May 31 11:30:41 2018
New Revision: 333679

URL: http://llvm.org/viewvc/llvm-project?rev=333679=rev
Log:
[analyzer] Annotate ProgramState update methods with LLVM_NODISCARD.

Because our program states are immutable, methods like "add<>", "set<>", "bind"
create a copy of the program state instead of mutating the existing state.
If the updated state is discarded, it clearly indicates a bug.
Such bugs are introduced frequently, hence the warn_unused_result annotation.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h?rev=333679=333678=333679=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h 
Thu May 31 11:30:41 2018
@@ -177,20 +177,20 @@ public:
   ///
   /// This returns a new state with the added constraint on \p cond.
   /// If no new state is feasible, NULL is returned.
-  ProgramStateRef assume(DefinedOrUnknownSVal cond, bool assumption) const;
+  LLVM_NODISCARD ProgramStateRef assume(DefinedOrUnknownSVal cond,
+bool assumption) const;
 
   /// Assumes both "true" and "false" for \p cond, and returns both
   /// corresponding states (respectively).
   ///
   /// This is more efficient than calling assume() twice. Note that one (but 
not
   /// both) of the returned states may be NULL.
-  std::pair
+  LLVM_NODISCARD std::pair
   assume(DefinedOrUnknownSVal cond) const;
 
-  ProgramStateRef assumeInBound(DefinedOrUnknownSVal idx,
-   DefinedOrUnknownSVal upperBound,
-   bool assumption,
-   QualType IndexType = QualType()) const;
+  LLVM_NODISCARD ProgramStateRef
+  assumeInBound(DefinedOrUnknownSVal idx, DefinedOrUnknownSVal upperBound,
+bool assumption, QualType IndexType = QualType()) const;
 
   /// Assumes that the value of \p Val is bounded with [\p From; \p To]
   /// (if \p assumption is "true") or it is fully out of this range
@@ -198,17 +198,17 @@ public:
   ///
   /// This returns a new state with the added constraint on \p cond.
   /// If no new state is feasible, NULL is returned.
-  ProgramStateRef assumeInclusiveRange(DefinedOrUnknownSVal Val,
-   const llvm::APSInt ,
-   const llvm::APSInt ,
-   bool assumption) const;
+  LLVM_NODISCARD ProgramStateRef assumeInclusiveRange(DefinedOrUnknownSVal Val,
+  const llvm::APSInt ,
+  const llvm::APSInt ,
+  bool assumption) const;
 
   /// Assumes given range both "true" and "false" for \p Val, and returns both
   /// corresponding states (respectively).
   ///
   /// This is more efficient than calling assume() twice. Note that one (but 
not
   /// both) of the returned states may be NULL.
-  std::pair
+  LLVM_NODISCARD std::pair
   assumeInclusiveRange(DefinedOrUnknownSVal Val, const llvm::APSInt ,
const llvm::APSInt ) const;
 
@@ -232,15 +232,16 @@ public:
 
   /// Create a new state by binding the value 'V' to the statement 'S' in the
   /// state's environment.
-  ProgramStateRef BindExpr(const Stmt *S, const LocationContext *LCtx,
-   SVal V, bool Invalidate = true) const;
+  LLVM_NODISCARD ProgramStateRef BindExpr(const Stmt *S,
+  const LocationContext *LCtx, SVal V,
+  bool Invalidate = true) const;
+
+  LLVM_NODISCARD ProgramStateRef bindLoc(Loc location, SVal V,
+ const LocationContext *LCtx,
+ bool notifyChanges = true) const;
 
-  ProgramStateRef bindLoc(Loc location,
-  SVal V,
-  const LocationContext *LCtx,
-  bool notifyChanges = true) const;
-
-  ProgramStateRef bindLoc(SVal location, SVal V, const LocationContext *LCtx) 
const;
+  LLVM_NODISCARD ProgramStateRef bindLoc(SVal location, SVal V,
+ const LocationContext *LCtx) const;
 
   /// Initializes the region of memory represented by \p loc with an initial
   /// value. Once initialized, all values loaded from any sub-regions of that
@@ -248,14 +249,15 @@ public:
   /// This method should not be used on regions that are already initialized.
   /// If 

[PATCH] D47157: Warning for framework headers using double quote includes

2018-05-31 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: test/Modules/double-quotes.m:24-25
+
+// The same warnings show up when modules is on but -verify doesn't get it
+// because they only show up under the module A building context.
+// RUN: FileCheck --input-file=%t/stderr %s

Would using an explicit module build make this any easier?



Comment at: test/Modules/double-quotes.m:27-29
+// CHECK: double-quoted include "A0.h" in framework header, expected 
angle-bracketed include  instead
+// CHECK: double-quoted include "B.h" in framework header, expected 
angle-bracketed include  instead
+// CHECK: double-quoted include "B.h" in framework header, expected 
angle-bracketed include  instead

When there's a fixit, you don't need to list it in the warning text (the fix-it 
itself is sufficient).  I also feel like "quoted include" is as clear as 
"double-quoted include" (but more succinct).  So I think these would be better 
as:

> warning: quoted include "..." in framework header, expected angle-bracketed 
> include instead



https://reviews.llvm.org/D47157



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


[PATCH] D47597: IRGen: Write .dwo files when -split-dwarf-file is used together with -fthinlto-index.

2018-05-31 Thread Peter Collingbourne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333677: IRGen: Write .dwo files when -split-dwarf-file is 
used together with -fthinlto… (authored by pcc, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47597?vs=149323=149326#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47597

Files:
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/test/CodeGen/thinlto-split-dwarf.c
  llvm/trunk/include/llvm/LTO/Config.h
  llvm/trunk/lib/LTO/LTOBackend.cpp


Index: llvm/trunk/lib/LTO/LTOBackend.cpp
===
--- llvm/trunk/lib/LTO/LTOBackend.cpp
+++ llvm/trunk/lib/LTO/LTOBackend.cpp
@@ -291,14 +291,19 @@
 return;
 
   std::unique_ptr DwoOut;
+  SmallString<1024> DwoFile(Conf.DwoPath);
   if (!Conf.DwoDir.empty()) {
 std::error_code EC;
 if (auto EC = llvm::sys::fs::create_directories(Conf.DwoDir))
   report_fatal_error("Failed to create directory " + Conf.DwoDir + ": " +
  EC.message());
 
-SmallString<1024> DwoFile(Conf.DwoDir);
+DwoFile = Conf.DwoDir;
 sys::path::append(DwoFile, std::to_string(Task) + ".dwo");
+  }
+
+  if (!DwoFile.empty()) {
+std::error_code EC;
 TM->Options.MCOptions.SplitDwarfFile = DwoFile.str().str();
 DwoOut = llvm::make_unique(DwoFile, EC, sys::fs::F_None);
 if (EC)
Index: llvm/trunk/include/llvm/LTO/Config.h
===
--- llvm/trunk/include/llvm/LTO/Config.h
+++ llvm/trunk/include/llvm/LTO/Config.h
@@ -76,6 +76,11 @@
   /// The directory to store .dwo files.
   std::string DwoDir;
 
+  /// The path to write a .dwo file to. This should generally only be used when
+  /// running an individual backend directly via thinBackend(), as otherwise
+  /// all .dwo files will be written to the same path.
+  std::string DwoPath;
+
   /// Optimization remarks file path.
   std::string RemarksFilename = "";
 
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -1161,6 +1161,7 @@
   Conf.DebugPassManager = CGOpts.DebugPassManager;
   Conf.RemarksWithHotness = CGOpts.DiagnosticsWithHotness;
   Conf.RemarksFilename = CGOpts.OptRecordFile;
+  Conf.DwoPath = CGOpts.SplitDwarfFile;
   switch (Action) {
   case Backend_EmitNothing:
 Conf.PreCodeGenModuleHook = [](size_t Task, const Module ) {
Index: cfe/trunk/test/CodeGen/thinlto-split-dwarf.c
===
--- cfe/trunk/test/CodeGen/thinlto-split-dwarf.c
+++ cfe/trunk/test/CodeGen/thinlto-split-dwarf.c
@@ -0,0 +1,21 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux-gnu \
+// RUN:   -flto=thin -emit-llvm-bc \
+// RUN:   -o %t.o %s
+
+// RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
+// RUN:   -o %t2.index \
+// RUN:   -r=%t.o,main,px
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu \
+// RUN:   -emit-obj -fthinlto-index=%t.o.thinlto.bc \
+// RUN:   -o %t.native.o -split-dwarf-file %t.native.dwo -x ir %t.o
+
+// RUN: llvm-readobj -sections %t.native.o | FileCheck --check-prefix=O %s
+// RUN: llvm-readobj -sections %t.native.dwo | FileCheck --check-prefix=DWO %s
+
+// O-NOT: .dwo
+// DWO: .dwo
+
+int main() {}


Index: llvm/trunk/lib/LTO/LTOBackend.cpp
===
--- llvm/trunk/lib/LTO/LTOBackend.cpp
+++ llvm/trunk/lib/LTO/LTOBackend.cpp
@@ -291,14 +291,19 @@
 return;
 
   std::unique_ptr DwoOut;
+  SmallString<1024> DwoFile(Conf.DwoPath);
   if (!Conf.DwoDir.empty()) {
 std::error_code EC;
 if (auto EC = llvm::sys::fs::create_directories(Conf.DwoDir))
   report_fatal_error("Failed to create directory " + Conf.DwoDir + ": " +
  EC.message());
 
-SmallString<1024> DwoFile(Conf.DwoDir);
+DwoFile = Conf.DwoDir;
 sys::path::append(DwoFile, std::to_string(Task) + ".dwo");
+  }
+
+  if (!DwoFile.empty()) {
+std::error_code EC;
 TM->Options.MCOptions.SplitDwarfFile = DwoFile.str().str();
 DwoOut = llvm::make_unique(DwoFile, EC, sys::fs::F_None);
 if (EC)
Index: llvm/trunk/include/llvm/LTO/Config.h
===
--- llvm/trunk/include/llvm/LTO/Config.h
+++ llvm/trunk/include/llvm/LTO/Config.h
@@ -76,6 +76,11 @@
   /// The directory to store .dwo files.
   std::string DwoDir;
 
+  /// The path to write a .dwo file to. This should generally only be used when
+  /// running an individual backend directly via thinBackend(), as otherwise
+  /// all .dwo files will be written to the same path.
+  std::string DwoPath;
+
   /// Optimization remarks file path.
   std::string RemarksFilename = "";
 
Index: 

r333677 - IRGen: Write .dwo files when -split-dwarf-file is used together with -fthinlto-index.

2018-05-31 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Thu May 31 11:25:59 2018
New Revision: 333677

URL: http://llvm.org/viewvc/llvm-project?rev=333677=rev
Log:
IRGen: Write .dwo files when -split-dwarf-file is used together with 
-fthinlto-index.

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

Added:
cfe/trunk/test/CodeGen/thinlto-split-dwarf.c
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=333677=333676=333677=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu May 31 11:25:59 2018
@@ -1161,6 +1161,7 @@ static void runThinLTOBackend(ModuleSumm
   Conf.DebugPassManager = CGOpts.DebugPassManager;
   Conf.RemarksWithHotness = CGOpts.DiagnosticsWithHotness;
   Conf.RemarksFilename = CGOpts.OptRecordFile;
+  Conf.DwoPath = CGOpts.SplitDwarfFile;
   switch (Action) {
   case Backend_EmitNothing:
 Conf.PreCodeGenModuleHook = [](size_t Task, const Module ) {

Added: cfe/trunk/test/CodeGen/thinlto-split-dwarf.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-split-dwarf.c?rev=333677=auto
==
--- cfe/trunk/test/CodeGen/thinlto-split-dwarf.c (added)
+++ cfe/trunk/test/CodeGen/thinlto-split-dwarf.c Thu May 31 11:25:59 2018
@@ -0,0 +1,21 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux-gnu \
+// RUN:   -flto=thin -emit-llvm-bc \
+// RUN:   -o %t.o %s
+
+// RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
+// RUN:   -o %t2.index \
+// RUN:   -r=%t.o,main,px
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu \
+// RUN:   -emit-obj -fthinlto-index=%t.o.thinlto.bc \
+// RUN:   -o %t.native.o -split-dwarf-file %t.native.dwo -x ir %t.o
+
+// RUN: llvm-readobj -sections %t.native.o | FileCheck --check-prefix=O %s
+// RUN: llvm-readobj -sections %t.native.dwo | FileCheck --check-prefix=DWO %s
+
+// O-NOT: .dwo
+// DWO: .dwo
+
+int main() {}


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


[PATCH] D47597: IRGen: Write .dwo files when -split-dwarf-file is used together with -fthinlto-index.

2018-05-31 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

LGTM thanks!


https://reviews.llvm.org/D47597



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


[PATCH] D47578: Do not enforce absolute path argv0 in windows

2018-05-31 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added inline comments.



Comment at: llvm/lib/Support/Windows/Process.inc:226
+
+static std::error_code GetLongArgv0Path(const wchar_t *Argv0,
+SmallVectorImpl ,

It looks like this function is a bit too complicated. I'd define a function 
that expands DOS-style 8.3 path and adds missing extension, and use that 
function.


https://reviews.llvm.org/D47578



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


[PATCH] D46084: [Fixed Point Arithmetic] Addition of the Fixed Point _Accum type

2018-05-31 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Basic/TargetInfo.cpp:45
+  AccumWidth = AccumAlign = 32;
+  LongAccumWidth = LongAccumAlign = 64;
   SuitableAlign = 64;

leonardchan wrote:
> leonardchan wrote:
> > ebevhan wrote:
> > > leonardchan wrote:
> > > > rsmith wrote:
> > > > > jfb wrote:
> > > > > > This seems weird because Targets which don't have these values for 
> > > > > > the non-Accum versions will have .e.g. `sizeof(short) != 
> > > > > > sizeof(short _Accum)`. Is there a point in ever having `_Accum` 
> > > > > > differ in size, width, and alignment from the underlying type? If 
> > > > > > not, can you set these values after the sub-target has specified 
> > > > > > its preferences?
> > > > > I'm uncomfortable about opting all targets into this behavior with 
> > > > > these default values; this will result in an ABI break if later a 
> > > > > target updates these to the correct values. A per-target 
> > > > > `AccumSupported` flag would help substantially. But this is OK for 
> > > > > the short term while you're still working on the feature.
> > > > > 
> > > > > We'll also need the target to inform us of the number of integer and 
> > > > > fractional bits for each such type.
> > > > The integral and fractional bits will be set in the target and is 
> > > > available in a later patch.
> > > > We'll also need the target to inform us of the number of integer and 
> > > > fractional bits for each such type.
> > > 
> > > I believe the only one that is needed is for the number of fractional 
> > > bits; the number of integer bits is implied by the difference between the 
> > > type width and fractional bits. I think I mention this in one of the 
> > > other patches.
> > > 
> > > 
> > You're right. I was stuck in the mindset that we would be providing an 
> > integral and fractional value.
> > The integral and fractional bits will be set in the target and is available 
> > in a later patch.
> 
> I mean just the fractional bits since the integral will just be the bit width 
> minus fractional.
You're assuming that all bits will be either integral or fractional bits (and 
in particular that there are no padding bits). I don't know if that's actually 
going to be true for all target ABIs, but I suppose it's OK to make this 
assumption until it's proven wrong by some actual target.


Repository:
  rC Clang

https://reviews.llvm.org/D46084



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


[PATCH] D47597: IRGen: Write .dwo files when -split-dwarf-file is used together with -fthinlto-index.

2018-05-31 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc created this revision.
pcc added reviewers: tejohnson, dblaikie.
Herald added subscribers: JDevlieghere, hiraditya, eraman, inglorion, 
mehdi_amini.

https://reviews.llvm.org/D47597

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/thinlto-split-dwarf.c
  llvm/include/llvm/LTO/Config.h
  llvm/lib/LTO/LTOBackend.cpp


Index: llvm/lib/LTO/LTOBackend.cpp
===
--- llvm/lib/LTO/LTOBackend.cpp
+++ llvm/lib/LTO/LTOBackend.cpp
@@ -291,14 +291,19 @@
 return;
 
   std::unique_ptr DwoOut;
+  SmallString<1024> DwoFile(Conf.DwoPath);
   if (!Conf.DwoDir.empty()) {
 std::error_code EC;
 if (auto EC = llvm::sys::fs::create_directories(Conf.DwoDir))
   report_fatal_error("Failed to create directory " + Conf.DwoDir + ": " +
  EC.message());
 
-SmallString<1024> DwoFile(Conf.DwoDir);
+DwoFile = Conf.DwoDir;
 sys::path::append(DwoFile, std::to_string(Task) + ".dwo");
+  }
+
+  if (!DwoFile.empty()) {
+std::error_code EC;
 TM->Options.MCOptions.SplitDwarfFile = DwoFile.str().str();
 DwoOut = llvm::make_unique(DwoFile, EC, sys::fs::F_None);
 if (EC)
Index: llvm/include/llvm/LTO/Config.h
===
--- llvm/include/llvm/LTO/Config.h
+++ llvm/include/llvm/LTO/Config.h
@@ -76,6 +76,11 @@
   /// The directory to store .dwo files.
   std::string DwoDir;
 
+  /// The path to write a .dwo file to. This should generally only be used when
+  /// running an individual backend directly via thinBackend(), as otherwise
+  /// all .dwo files will be written to the same path.
+  std::string DwoPath;
+
   /// Optimization remarks file path.
   std::string RemarksFilename = "";
 
Index: clang/test/CodeGen/thinlto-split-dwarf.c
===
--- /dev/null
+++ clang/test/CodeGen/thinlto-split-dwarf.c
@@ -0,0 +1,21 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux-gnu \
+// RUN:   -flto=thin -emit-llvm-bc \
+// RUN:   -o %t.o %s
+
+// RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
+// RUN:   -o %t2.index \
+// RUN:   -r=%t.o,main,px
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu \
+// RUN:   -emit-obj -fthinlto-index=%t.o.thinlto.bc \
+// RUN:   -o %t.native.o -split-dwarf-file %t.native.dwo -x ir %t.o
+
+// RUN: llvm-readobj -sections %t.native.o | FileCheck --check-prefix=O %s
+// RUN: llvm-readobj -sections %t.native.dwo | FileCheck --check-prefix=DWO %s
+
+// O-NOT: .dwo
+// DWO: .dwo
+
+int main() {}
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1161,6 +1161,7 @@
   Conf.DebugPassManager = CGOpts.DebugPassManager;
   Conf.RemarksWithHotness = CGOpts.DiagnosticsWithHotness;
   Conf.RemarksFilename = CGOpts.OptRecordFile;
+  Conf.DwoPath = CGOpts.SplitDwarfFile;
   switch (Action) {
   case Backend_EmitNothing:
 Conf.PreCodeGenModuleHook = [](size_t Task, const Module ) {


Index: llvm/lib/LTO/LTOBackend.cpp
===
--- llvm/lib/LTO/LTOBackend.cpp
+++ llvm/lib/LTO/LTOBackend.cpp
@@ -291,14 +291,19 @@
 return;
 
   std::unique_ptr DwoOut;
+  SmallString<1024> DwoFile(Conf.DwoPath);
   if (!Conf.DwoDir.empty()) {
 std::error_code EC;
 if (auto EC = llvm::sys::fs::create_directories(Conf.DwoDir))
   report_fatal_error("Failed to create directory " + Conf.DwoDir + ": " +
  EC.message());
 
-SmallString<1024> DwoFile(Conf.DwoDir);
+DwoFile = Conf.DwoDir;
 sys::path::append(DwoFile, std::to_string(Task) + ".dwo");
+  }
+
+  if (!DwoFile.empty()) {
+std::error_code EC;
 TM->Options.MCOptions.SplitDwarfFile = DwoFile.str().str();
 DwoOut = llvm::make_unique(DwoFile, EC, sys::fs::F_None);
 if (EC)
Index: llvm/include/llvm/LTO/Config.h
===
--- llvm/include/llvm/LTO/Config.h
+++ llvm/include/llvm/LTO/Config.h
@@ -76,6 +76,11 @@
   /// The directory to store .dwo files.
   std::string DwoDir;
 
+  /// The path to write a .dwo file to. This should generally only be used when
+  /// running an individual backend directly via thinBackend(), as otherwise
+  /// all .dwo files will be written to the same path.
+  std::string DwoPath;
+
   /// Optimization remarks file path.
   std::string RemarksFilename = "";
 
Index: clang/test/CodeGen/thinlto-split-dwarf.c
===
--- /dev/null
+++ clang/test/CodeGen/thinlto-split-dwarf.c
@@ -0,0 +1,21 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux-gnu \
+// RUN:   -flto=thin -emit-llvm-bc \
+// RUN:   -o %t.o %s
+
+// RUN: 

[PATCH] D45517: [analyzer] False positive refutation with Z3

2018-05-31 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho added subscribers: dcoughlin, george.karpenkov, NoQ.
mikhail.ramalho added a comment.

Hi,

> Just a bit of context and to have some expectation management regarding
>  this patch. The main purpose of this implementation was to back a thesis.
>  It was made under a very serious time pressure and the main goal was to be
>  able to measure on real world projects as soon as possible and in the
>  meantime to be flexible so we can measure multiple configurations (like
>  incremental solving).
> 
> So the goal was a flexible proof of concept that is sensible to measure in
>  the shortest possible time. After the thesis was done, Reka started to work
>  an another GSoC project, so she had no time to review the code with the
>  requirements of upstreaming in mind. Nevertheless we found that sharing the
>  proof of concept could be useful for the community.  So it is perfectly
>  reasonable if you disagree with some design decisions behind this patch,
>  because the requirements for the thesis (in the short time frame) was very
>  different from the requirements of upstreaming this work. In a different
>  context these decisions made perfect sense.

Just want to comment here and give thanks again for the first version of
the refutation code. It's being really helpful to develop the approach this
code as a base; things would definitely be slower if I had to start it from
scratch.

Thanks!


https://reviews.llvm.org/D45517



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


[PATCH] D45517: [analyzer] False positive refutation with Z3

2018-05-31 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho updated this revision to Diff 149317.
mikhail.ramalho marked 6 inline comments as not done.
mikhail.ramalho added a comment.

- Simplified refutation process: it now collects all the constraints in a given 
path and, only when it reaches the root node, the refutation manager is created 
and the constraints are checked for reachability. All the optimizations were 
removed.
- Moved RangedConstraintManager.h to include/
- Moved refutation check to be the first in the list of BugVisitors
- Added dump method to Z3Solver (to print the formula)
- Added more documentation/comments


https://reviews.llvm.org/D45517

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/BugReporter.cpp
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  lib/StaticAnalyzer/Core/RangedConstraintManager.h
  lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
  test/Analysis/z3-crosscheck.c

Index: test/Analysis/z3-crosscheck.c
===
--- /dev/null
+++ test/Analysis/z3-crosscheck.c
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -DNO_CROSSCHECK -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config crosscheck-with-z3=true -verify %s
+// REQUIRES: z3
+
+#ifndef NO_CROSSCHECK
+// expected-no-diagnostics
+#endif
+
+int foo(int x) 
+{
+  int *z = 0;
+  if ((x & 1) && ((x & 1) ^ 1))
+#ifdef NO_CROSSCHECK
+  return *z; // expected-warning {{Dereference of null pointer (loaded from variable 'z')}}
+#else
+  return *z; // no-warning
+#endif
+  return 0;
+}
+
+void g(int d);
+
+void f(int *a, int *b) {
+  int c = 5;
+  if ((a - b) == 0)
+c = 0;
+  if (a != b)
+#ifdef NO_CROSSCHECK
+g(3 / c); // expected-warning {{Division by zero}}
+#else
+g(3 / c); // no-warning
+#endif
+}
+
+_Bool nondet_bool();
+
+void h(int d) {
+  int x, y, k, z = 1;
+#ifdef NO_CROSSCHECK
+  while (z < k) { // expected-warning {{The right operand of '<' is a garbage value}}
+#else
+  // FIXME: Should warn about 'k' being a garbage value
+  while (z < k) { // no-warning
+#endif
+z = 2 * z;
+  }
+}
+
+void i() {
+  _Bool c = nondet_bool();
+  if (c) {
+h(1);
+  } else {
+h(2);
+  }
+}
+
Index: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -10,6 +10,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h"
 
 #include "clang/Config/config.h"
@@ -880,6 +881,12 @@
 
   /// Reset the solver and remove all constraints.
   void reset() { Z3_solver_reset(Z3Context::ZC, Solver); }
+
+  void print(raw_ostream ) const {
+OS << Z3_solver_to_string(Z3Context::ZC, Solver);
+  }
+
+  LLVM_DUMP_METHOD void dump() const { print(llvm::errs()); }
 }; // end class Z3Solver
 
 void Z3ErrorHandler(Z3_context Context, Z3_error_code Error) {
@@ -915,6 +922,17 @@
   void print(ProgramStateRef St, raw_ostream , const char *nl,
  const char *sep) override;
 
+  void reset() override { Solver.reset(); }
+
+  bool isModelFeasible() override {
+return Solver.check() != Z3_L_FALSE;
+  }
+
+  /// Converts the ranged constraints of a set of symbols to SMT
+  ///
+  /// \param CR The set of constraints.
+  void addRangeConstraints(ConstraintRangeTy CR) override;
+
   //===--===//
   // Implementation for interface from SimpleConstraintManager.
   //===--===//
@@ -1235,6 +1253,42 @@
   return State->set(CZ);
 }
 
+void Z3ConstraintManager::addRangeConstraints(ConstraintRangeTy CR) {
+  for (const auto  : CR) {
+SymbolRef Sym = I.first;
+
+Z3Expr Constraints = Z3Expr::fromBoolean(false);
+
+for (const auto  : I.second) {
+  const llvm::APSInt  = Range.From();
+  const llvm::APSInt  = Range.To();
+
+  assert((getAPSIntType(From) == getAPSIntType(To)) &&
+ "Range values have different types!");
+  QualType RangeTy = getAPSIntType(From);
+  // Skip ranges whose endpoints cannot be converted to APSInts with
+  // a valid APSIntType.
+  // FIXME: fix available in D35450

[PATCH] D47157: Warning for framework headers using double quote includes

2018-05-31 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno updated this revision to Diff 149313.
bruno added a comment.

Updated the patch after Duncan and Aaron reviews. I actually went a bit more 
aggressive with the fixits, since I realized the conditions for the warning are 
already strict enough and we should take the chance to be more clear. For the 
attached testcase, the output now is:

  ./A.framework/Headers/A.h:2:10: warning: double-quoted include "A0.h" in 
framework header, expected angle-bracketed include  instead
  #include "A0.h"
   ^~
   
  ./A.framework/Headers/A.h:3:10: warning: double-quoted include "B.h" in 
framework header, expected angle-bracketed include  instead
  #include "B.h"
   ^
   


https://reviews.llvm.org/D47157

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticLexKinds.td
  lib/Lex/HeaderSearch.cpp
  test/Modules/Inputs/double-quotes/A.framework/Headers/A.h
  test/Modules/Inputs/double-quotes/A.framework/Headers/A0.h
  test/Modules/Inputs/double-quotes/A.framework/Modules/module.modulemap
  test/Modules/Inputs/double-quotes/B.h
  test/Modules/Inputs/double-quotes/X.framework/Headers/X.h
  test/Modules/Inputs/double-quotes/X.framework/Modules/module.modulemap
  test/Modules/Inputs/double-quotes/a.hmap.json
  test/Modules/Inputs/double-quotes/flat-header-path/Z.h
  test/Modules/Inputs/double-quotes/flat-header-path/Z.modulemap
  test/Modules/Inputs/double-quotes/x.hmap.json
  test/Modules/Inputs/double-quotes/z.yaml
  test/Modules/double-quotes.m

Index: test/Modules/double-quotes.m
===
--- /dev/null
+++ test/Modules/double-quotes.m
@@ -0,0 +1,38 @@
+// REQUIRES: shell
+
+// RUN: rm -rf %t
+// RUN: mkdir %t
+
+// RUN: hmaptool write %S/Inputs/double-quotes/a.hmap.json %t/a.hmap
+// RUN: hmaptool write %S/Inputs/double-quotes/x.hmap.json %t/x.hmap
+
+// RUN: sed -e "s:TEST_DIR:%S/Inputs/double-quotes:g" \
+// RUN:   %S/Inputs/double-quotes/z.yaml > %t/z.yaml
+
+// The output with and without modules should be the same, without modules first.
+// RUN: %clang_cc1 \
+// RUN:   -I %t/x.hmap -iquote %t/a.hmap -ivfsoverlay %t/z.yaml \
+// RUN:   -F%S/Inputs/double-quotes -I%S/Inputs/double-quotes \
+// RUN:   -Wquoted-include-in-framework-header -fsyntax-only %s -verify
+
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache \
+// RUN:   -I %t/x.hmap -iquote %t/a.hmap -ivfsoverlay %t/z.yaml \
+// RUN:   -F%S/Inputs/double-quotes -I%S/Inputs/double-quotes \
+// RUN:   -Wquoted-include-in-framework-header -fsyntax-only %s \
+// RUN:   2>%t/stderr
+
+// The same warnings show up when modules is on but -verify doesn't get it
+// because they only show up under the module A building context.
+// RUN: FileCheck --input-file=%t/stderr %s
+// CHECK: double-quoted include "A0.h" in framework header, expected angle-bracketed include  instead
+// CHECK: double-quoted include "B.h" in framework header, expected angle-bracketed include  instead
+// CHECK: double-quoted include "B.h" in framework header, expected angle-bracketed include  instead
+
+#import "A.h"
+#import 
+
+int bar() { return foo(); }
+
+// expected-warning@Inputs/double-quotes/A.framework/Headers/A.h:2{{double-quoted include "A0.h" in framework header}}
+// expected-warning@Inputs/double-quotes/A.framework/Headers/A.h:3{{double-quoted include "B.h" in framework header}}
+// expected-warning@Inputs/double-quotes/flat-header-path/Z.h:1{{double-quoted include "B.h" in framework header}}
Index: test/Modules/Inputs/double-quotes/z.yaml
===
--- /dev/null
+++ test/Modules/Inputs/double-quotes/z.yaml
@@ -0,0 +1,28 @@
+{
+  'version': 0,
+  'case-sensitive': 'false',
+  'roots': [
+{
+  'type': 'directory',
+  'name': "TEST_DIR/Z.framework/Headers",
+  'contents': [
+{
+  'type': 'file',
+  'name': "Z.h",
+  'external-contents': "TEST_DIR/flat-header-path/Z.h"
+}
+  ]
+},
+{
+  'type': 'directory',
+  'name': "TEST_DIR/Z.framework/Modules",
+  'contents': [
+{
+  'type': 'file',
+  'name': "module.modulemap",
+  'external-contents': "TEST_DIR/flat-header-path/Z.modulemap"
+}
+  ]
+}
+  ]
+}
Index: test/Modules/Inputs/double-quotes/x.hmap.json
===
--- /dev/null
+++ test/Modules/Inputs/double-quotes/x.hmap.json
@@ -0,0 +1,7 @@
+
+{
+  "mappings" :
+{
+ "X.h" : "X/X.h"
+}
+}
Index: test/Modules/Inputs/double-quotes/flat-header-path/Z.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/double-quotes/flat-header-path/Z.modulemap
@@ -0,0 +1,3 @@
+framework module Z {
+	header "Z.h"
+}
Index: test/Modules/Inputs/double-quotes/flat-header-path/Z.h

[PATCH] D47557: Filesystem tests: un-confuse write time

2018-05-31 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

So the reason there are `atime` tests at all is due to the implementation 
details of `__last_write_time` here. Essentially we have to do extra work 
trying to maintain the access time.

I'm OK with this patches rename. `first` and `second` were certainly not clear.

That being said, I'm not sure we should be removing the access time tests, they 
were intentional.


Repository:
  rCXX libc++

https://reviews.llvm.org/D47557



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


[clang-tools-extra] r333673 - PrintEscapedString -> printEscapedString

2018-05-31 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Thu May 31 10:36:31 2018
New Revision: 333673

URL: http://llvm.org/viewvc/llvm-project?rev=333673=rev
Log:
PrintEscapedString -> printEscapedString

Update PrintEscapedString after renaming it in ADT.

Modified:
clang-tools-extra/trunk/clangd/Protocol.cpp

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=333673=333672=333673=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Thu May 31 10:36:31 2018
@@ -137,7 +137,7 @@ json::Expr toJSON(const TextEdit ) {
 
 llvm::raw_ostream <<(llvm::raw_ostream , const TextEdit ) {
   OS << TE.range << " => \"";
-  PrintEscapedString(TE.newText, OS);
+  printEscapedString(TE.newText, OS);
   return OS << '"';
 }
 


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


[PATCH] D47578: Do not enforce absolute path argv0 in windows

2018-05-31 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth added a comment.

In https://reviews.llvm.org/D47578#1117874, @rnk wrote:

> The LLDB test suite isn't in very good shape on Windows. It is complicated to 
> set up and build, I don't want to block this fix on @takuto.ikuta setting up 
> that build environment. This is a Windows-only change, and I believe it makes 
> it more consistent with Linux, so as long as check-llvm, check-clang, and 
> check-lld pass, this should be relatively safe.


OK, I'll take rnk's word for that.


https://reviews.llvm.org/D47578



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


[PATCH] D47402: [analyzer] Improve simplifySVal performance further.

2018-05-31 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333671: [analyzer] Improve performance of the SVal 
simplification mechanism further. (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47402?vs=148695=149315#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47402

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp


Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1222,6 +1222,12 @@
 ProgramStateRef State;
 SValBuilder 
 
+// Cache results for the lifetime of the Simplifier. Results change every
+// time new constraints are added to the program state, which is the whole
+// point of simplifying, and for that very reason it's pointless to 
maintain
+// the same cache for the duration of the whole analysis.
+llvm::DenseMap Cached;
+
 static bool isUnchanged(SymbolRef Sym, SVal Val) {
   return Sym == Val.getAsSymbol();
 }
@@ -1242,9 +1248,16 @@
 // start producing them.
 
 SVal VisitSymIntExpr(const SymIntExpr *S) {
+  auto I = Cached.find(S);
+  if (I != Cached.end())
+return I->second;
+
   SVal LHS = Visit(S->getLHS());
-  if (isUnchanged(S->getLHS(), LHS))
-return SVB.makeSymbolVal(S);
+  if (isUnchanged(S->getLHS(), LHS)) {
+SVal V = SVB.makeSymbolVal(S);
+Cached[S] = V;
+return V;
+  }
   SVal RHS;
   // By looking at the APSInt in the right-hand side of S, we cannot
   // figure out if it should be treated as a Loc or as a NonLoc.
@@ -1263,15 +1276,27 @@
   } else {
 RHS = SVB.makeIntVal(S->getRHS());
   }
-  return SVB.evalBinOp(State, S->getOpcode(), LHS, RHS, S->getType());
+
+  SVal V = SVB.evalBinOp(State, S->getOpcode(), LHS, RHS, S->getType());
+  Cached[S] = V;
+  return V;
 }
 
 SVal VisitSymSymExpr(const SymSymExpr *S) {
+  auto I = Cached.find(S);
+  if (I != Cached.end())
+return I->second;
+
   SVal LHS = Visit(S->getLHS());
   SVal RHS = Visit(S->getRHS());
-  if (isUnchanged(S->getLHS(), LHS) && isUnchanged(S->getRHS(), RHS))
-return SVB.makeSymbolVal(S);
-  return SVB.evalBinOp(State, S->getOpcode(), LHS, RHS, S->getType());
+  if (isUnchanged(S->getLHS(), LHS) && isUnchanged(S->getRHS(), RHS)) {
+SVal V = SVB.makeSymbolVal(S);
+Cached[S] = V;
+return V;
+  }
+  SVal V = SVB.evalBinOp(State, S->getOpcode(), LHS, RHS, S->getType());
+  Cached[S] = V;
+  return V;
 }
 
 SVal VisitSymExpr(SymbolRef S) { return nonloc::SymbolVal(S); }


Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1222,6 +1222,12 @@
 ProgramStateRef State;
 SValBuilder 
 
+// Cache results for the lifetime of the Simplifier. Results change every
+// time new constraints are added to the program state, which is the whole
+// point of simplifying, and for that very reason it's pointless to maintain
+// the same cache for the duration of the whole analysis.
+llvm::DenseMap Cached;
+
 static bool isUnchanged(SymbolRef Sym, SVal Val) {
   return Sym == Val.getAsSymbol();
 }
@@ -1242,9 +1248,16 @@
 // start producing them.
 
 SVal VisitSymIntExpr(const SymIntExpr *S) {
+  auto I = Cached.find(S);
+  if (I != Cached.end())
+return I->second;
+
   SVal LHS = Visit(S->getLHS());
-  if (isUnchanged(S->getLHS(), LHS))
-return SVB.makeSymbolVal(S);
+  if (isUnchanged(S->getLHS(), LHS)) {
+SVal V = SVB.makeSymbolVal(S);
+Cached[S] = V;
+return V;
+  }
   SVal RHS;
   // By looking at the APSInt in the right-hand side of S, we cannot
   // figure out if it should be treated as a Loc or as a NonLoc.
@@ -1263,15 +1276,27 @@
   } else {
 RHS = SVB.makeIntVal(S->getRHS());
   }
-  return SVB.evalBinOp(State, S->getOpcode(), LHS, RHS, S->getType());
+
+  SVal V = SVB.evalBinOp(State, S->getOpcode(), LHS, RHS, S->getType());
+  Cached[S] = V;
+  return V;
 }
 
 SVal VisitSymSymExpr(const SymSymExpr *S) {
+  auto I = Cached.find(S);
+  if (I != Cached.end())
+return I->second;
+
   SVal LHS = Visit(S->getLHS());
   SVal RHS = Visit(S->getRHS());
-  if (isUnchanged(S->getLHS(), LHS) && isUnchanged(S->getRHS(), RHS))
-return SVB.makeSymbolVal(S);
-  return SVB.evalBinOp(State, S->getOpcode(), LHS, RHS, S->getType());
+  if 

  1   2   >