[PATCH] D28316: [libc++] Cleanup and document <__threading_support>

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

@compnerd Just waiting on @rmaprath before committing. This is a breaking 
change for his use case since this patch changes the semantics of 
`_LIBCPP_HAS_THREAD_API_EXTERNAL` and `-DLIBCXX_HAS_EXTERNAL_THREAD_API`.


https://reviews.llvm.org/D28316



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


[PATCH] D28346: [AVR] Allow specifying the CPU on the command line

2017-01-05 Thread Dylan McKay via Phabricator via cfe-commits
dylanmckay created this revision.
dylanmckay added a reviewer: jroelofs.
dylanmckay added a subscriber: cfe-commits.

This tells clang about all of the different AVR microcontrollers.

It also adds code to define the correct preprocessor macros for each
device.


https://reviews.llvm.org/D28346

Files:
  lib/Basic/Targets.cpp

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -8385,6 +8385,254 @@
   }
 };
 
+/// Information about a specific microcontroller.
+struct MCUInfo {
+  const char *Name;
+  const char *DefineName;
+};
+
+// This list should be kept up-to-date with AVRDevices.td in LLVM.
+static ArrayRef AVRMcus = {
+  { "at90s1200", "__AVR_AT90S1200__" },
+  { "attiny11", "__AVR_ATtiny11" },
+  { "attiny12", "__AVR_ATtiny12" },
+  { "attiny15", "__AVR_ATtiny15" },
+  { "attiny28", "__AVR_ATtiny28" },
+  { "at90s2313", "__AVR_AT90S2313" },
+  { "at90s2323", "__AVR_AT90S2323" },
+  { "at90s2333", "__AVR_AT90S2333" },
+  { "at90s2343", "__AVR_AT90S2343" },
+  { "attiny22", "__AVR_ATtiny22" },
+  { "attiny26", "__AVR_ATtiny26" },
+  { "at86rf401", "__AVR_AT86RF401" },
+  { "at90s4414", "__AVR_AT90S4414" },
+  { "at90s4433", "__AVR_AT90S4433" },
+  { "at90s4434", "__AVR_AT90S4434" },
+  { "at90s8515", "__AVR_AT90S8515" },
+  { "at90c8534", "__AVR_AT90c8534" },
+  { "at90s8535", "__AVR_AT90S8535" },
+  { "ata5272", "__AVR_ATA5272" },
+  { "attiny13", "__AVR_ATtiny13" },
+  { "attiny13a", "__AVR_ATtiny13A" },
+  { "attiny2313", "__AVR_ATtiny2313" },
+  { "attiny2313a", "__AVR_ATtiny2313A" },
+  { "attiny24", "__AVR_ATtiny24" },
+  { "attiny24a", "__AVR_ATtiny24A" },
+  { "attiny4313", "__AVR_ATtiny4313" },
+  { "attiny44", "__AVR_ATtiny44" },
+  { "attiny44a", "__AVR_ATtiny44A" },
+  { "attiny84", "__AVR_ATtiny84" },
+  { "attiny84a", "__AVR_ATtiny84A" },
+  { "attiny25", "__AVR_ATtiny25" },
+  { "attiny45", "__AVR_ATtiny45" },
+  { "attiny85", "__AVR_ATtiny85" },
+  { "attiny261", "__AVR_ATtiny261" },
+  { "attiny261a", "__AVR_ATtiny261A" },
+  { "attiny461", "__AVR_ATtiny461" },
+  { "attiny461a", "__AVR_ATtiny461A" },
+  { "attiny861", "__AVR_ATtiny861" },
+  { "attiny861a", "__AVR_ATtiny861A" },
+  { "attiny87", "__AVR_ATtiny87" },
+  { "attiny43u", "__AVR_ATtiny43U" },
+  { "attiny48", "__AVR_ATtiny48" },
+  { "attiny88", "__AVR_ATtiny88" },
+  { "attiny828", "__AVR_ATtiny828" },
+  { "at43usb355", "__AVR_AT43USB355" },
+  { "at76c711", "__AVR_AT76C711" },
+  { "atmega103", "__AVR_ATmega103" },
+  { "at43usb320", "__AVR_AT43USB320" },
+  { "attiny167", "__AVR_ATtiny167" },
+  { "at90usb82", "__AVR_AT90USB82" },
+  { "at90usb162", "__AVR_AT90USB162" },
+  { "ata5505", "__AVR_ATA5505" },
+  { "atmega8u2", "__AVR_ATmega8U2" },
+  { "atmega16u2", "__AVR_ATmega16U2" },
+  { "atmega32u2", "__AVR_ATmega32U2" },
+  { "attiny1634", "__AVR_ATtiny1634" },
+  { "atmega8", "__AVR_ATmega8" },
+  { "ata6289", "__AVR_ATA6289" },
+  { "atmega8a", "__AVR_ATmega8A" },
+  { "ata6285", "__AVR_ATA6285" },
+  { "ata6286", "__AVR_ATA6286" },
+  { "atmega48", "__AVR_ATmega48" },
+  { "atmega48a", "__AVR_ATmega48A" },
+  { "atmega48pa", "__AVR_ATmega48PA" },
+  { "atmega48p", "__AVR_ATmega48P" },
+  { "atmega88", "__AVR_ATmega88" },
+  { "atmega88a", "__AVR_ATmega88A" },
+  { "atmega88p", "__AVR_ATmega88P" },
+  { "atmega88pa", "__AVR_ATmega88PA" },
+  { "atmega8515", "__AVR_ATmega8515" },
+  { "atmega8535", "__AVR_ATmega8535" },
+  { "atmega8hva", "__AVR_ATmega8HVA" },
+  { "at90pwm1", "__AVR_AT90PWM1" },
+  { "at90pwm2", "__AVR_AT90PWM2" },
+  { "at90pwm2b", "__AVR_AT90PWM2B" },
+  { "at90pwm3", "__AVR_AT90PWM3" },
+  { "at90pwm3b", "__AVR_AT90PWM3B" },
+  { "at90pwm81", "__AVR_AT90PWM81" },
+  { "ata5790", "__AVR_ATA5790" },
+  { "ata5795", "__AVR_ATA5795" },
+  { "atmega16", "__AVR_ATmega16" },
+  { "atmega16a", "__AVR_ATmega16A" },
+  { "atmega161", "__AVR_ATmega161" },
+  { "atmega162", "__AVR_ATmega162" },
+  { "atmega163", "__AVR_ATmega163" },
+  { "atmega164a", "__AVR_ATmega164A" },
+  { "atmega164p", "__AVR_ATmega164P" },
+  { "atmega164pa", "__AVR_ATmega164PA" },
+  { "atmega165", "__AVR_ATmega165" },
+  { "atmega165a", "__AVR_ATmega165A" },
+  { "atmega165p", "__AVR_ATmega165P" },
+  { "atmega165pa", "__AVR_ATmega165PA" },
+  { "atmega168", "__AVR_ATmega168" },
+  { "atmega168a", "__AVR_ATmega168A" },
+  { "atmega168p", "__AVR_ATmega168P" },
+  { "atmega168pa", "__AVR_ATmega168PA" },
+  { "atmega169", "__AVR_ATmega169" },
+  { "atmega169a", "__AVR_ATmega169A" },
+  { "atmega169p", "__AVR_ATmega169P" },
+  { "atmega169pa", "__AVR_ATmega169PA" },
+  { "atmega32", "__AVR_ATmega32" },
+  { "atmega32a", "__AVR_ATmega32A" },
+  { "atmega323", "__AVR_ATmega323" },
+  { "atmega324a", "__AVR_ATmega324A" },
+  { "atmega324p", "__AVR_ATmega324P" },
+  { "atmega324pa", "__AVR_ATmega324PA" },
+  { "atmega325", "__AVR_ATmega325" },
+  { "atmega325a", "__AVR_ATmega325A" },
+  { "atmega325p", "__AVR_ATmega325P" },
+  { "atmega325

[libcxx] r291091 - Get tests linking on Windows.

2017-01-05 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Jan  5 02:07:17 2017
New Revision: 291091

URL: http://llvm.org/viewvc/llvm-project?rev=291091&view=rev
Log:
Get tests linking on Windows.

This patch is a temporary hack to get the tests passing on
Windows.

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

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=291091&r1=291090&r2=291091&view=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Thu Jan  5 02:07:17 2017
@@ -386,6 +386,9 @@ class Configuration(object):
 # Configure extra flags
 compile_flags_str = self.get_lit_conf('compile_flags', '')
 self.cxx.compile_flags += shlex.split(compile_flags_str)
+# FIXME: Can we remove this?
+if self.is_windows:
+self.cxx.compile_flags += ['-D_CRT_SECURE_NO_WARNINGS']
 
 def configure_default_compile_flags(self):
 # Try and get the std version from the command line. Fall back to
@@ -572,6 +575,9 @@ class Configuration(object):
 # Configure libraries
 if self.cxx_stdlib_under_test == 'libc++':
 self.cxx.link_flags += ['-nodefaultlibs']
+# FIXME: Handle MSVCRT as part of the ABI library handling.
+if self.is_windows:
+self.cxx.link_flags += ['-nostdlib', '-lmsvcrtd']
 self.configure_link_flags_cxx_library()
 self.configure_link_flags_abi_library()
 self.configure_extra_library_flags()


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


[PATCH] D28316: [libc++] Cleanup and document <__threading_support>

2017-01-05 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: docs/DesignDocs/ThreadingSupportAPI.rst:17
+
+The ``<__threading_support>`` header is where libc++ defines it's internal
+threading interface. It contains forward declarations of the internal threading

s/it's/its


https://reviews.llvm.org/D28316



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


[PATCH] D28316: [libc++] Cleanup and document <__threading_support>

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

- Address inline comments


https://reviews.llvm.org/D28316

Files:
  CMakeLists.txt
  docs/DesignDocs/ThreadingSupportAPI.rst
  docs/index.rst
  include/__config
  include/__config_site.in
  include/__threading_support
  lib/CMakeLists.txt
  test/CMakeLists.txt
  test/lit.site.cfg.in
  test/support/external_threads.cpp

Index: test/support/external_threads.cpp
===
--- test/support/external_threads.cpp
+++ test/support/external_threads.cpp
@@ -6,5 +6,5 @@
 // Source Licenses. See LICENSE.TXT for details.
 //
 //===--===//
-#define _LIBCPP_BUILDING_THREAD_API_EXTERNAL_PTHREAD
+#define _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL
 #include <__threading_support>
Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -28,7 +28,7 @@
 config.use_libatomic= "@LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB@"
 
 config.libcxxabi_shared = "@LIBCXXABI_ENABLE_SHARED@"
-config.cxx_ext_threads  = "@LIBCXX_HAS_EXTERNAL_THREAD_API@"
+config.cxx_ext_threads  = "@LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY@"
 
 # Let the main config do the real work.
 config.loaded_site_config = True
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -34,7 +34,7 @@
 pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
 pythonize_bool(LIBCXX_HAS_ATOMIC_LIB)
 pythonize_bool(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB)
-pythonize_bool(LIBCXX_HAS_EXTERNAL_THREAD_API)
+pythonize_bool(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
 
 # By default, for non-standalone builds, libcxx and libcxxabi share a library
 # directory.
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -275,7 +275,7 @@
   )
 endif()
 
-if (LIBCXX_HAS_EXTERNAL_THREAD_API)
+if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
   file(GLOB LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES ../test/support/external_threads.cpp)
 
   if (LIBCXX_ENABLE_SHARED)
Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -17,48 +17,28 @@
 #pragma GCC system_header
 #endif
 
-#ifndef _LIBCPP_HAS_NO_THREADS
-
-#ifndef __libcpp_has_include
-  #ifndef __has_include
-#define __libcpp_has_include(x) 0
-  #else
-#define __libcpp_has_include(x) __has_include(x)
-  #endif
-#endif
-
-#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && \
-!__libcpp_has_include(<__external_threading>)
-// If the <__external_threading> header is absent, build libc++ against a
-// pthread-oriented thread api but leave out its implementation. This setup
-// allows building+testing of an externally-threaded library variant (on any
-// platform that supports pthreads). Here, an 'externally-threaded' library
-// variant is one where the implementation of the libc++ thread api is provided
-// as a separate library.
-#define _LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD
-#endif
-
-#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && \
-__libcpp_has_include(<__external_threading>)
-#include <__external_threading>
-#else
-
-#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
-defined(_LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD)
-#include 
-#include 
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+# ifdef _LIBCPP_HAS_NO_THREADS
+#   error _LIBCPP_HAS_NO_THREADS cannot be defined with _LIBCPP_HAS_THREAD_API_EXTERNAL
+# endif
+# include <__external_threading>
+#elif !defined(_LIBCPP_HAS_NO_THREADS)
+
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+# include 
+# include 
 #endif
 
-#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+#if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
+defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)
 #define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
 #else
 #define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
 #endif
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
-defined(_LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD)
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 // Mutex
 typedef pthread_mutex_t __libcpp_mutex_t;
 #define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
@@ -161,8 +141,10 @@
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
 
-#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
-defined(_LIBCPP_BUILDING_THREAD_API_EXTERNAL_PTHREAD)
+#if !defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
+defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)
+
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 
 int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m)
 {
@@ -310,9 +292,9 @@
 
 #endif // _LIBCPP_HAS_THREAD_API_PTHREAD
 
-_LIBCPP_END_NAMESPACE_S

[libcxx] r291093 - Use C++11 static_assert in variant tests. Patch from Michael Park

2017-01-05 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Jan  5 03:03:43 2017
New Revision: 291093

URL: http://llvm.org/viewvc/llvm-project?rev=291093&view=rev
Log:
Use C++11 static_assert in variant tests. Patch from Michael Park

Modified:

libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp

libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp

Modified: 
libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp?rev=291093&r1=291092&r2=291093&view=diff
==
--- 
libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
 Thu Jan  5 03:03:43 2017
@@ -63,7 +63,7 @@ struct TCopyAssignNTMoveAssign {
   int value;
 };
 
-static_assert(std::is_trivially_copy_assignable_v);
+static_assert(std::is_trivially_copy_assignable_v, 
"");
 
 void test_copy_assignment_sfinae() {
   {
@@ -99,8 +99,8 @@ void test_copy_assignment_same_index() {
   }
 } test;
 constexpr auto result = test();
-static_assert(result.index == 0);
-static_assert(result.value == 42);
+static_assert(result.index == 0, "");
+static_assert(result.value == 42, "");
   }
   {
 struct {
@@ -113,8 +113,8 @@ void test_copy_assignment_same_index() {
   }
 } test;
 constexpr auto result = test();
-static_assert(result.index == 1);
-static_assert(result.value == 42l);
+static_assert(result.index == 1, "");
+static_assert(result.value == 42l, "");
   }
   {
 struct {
@@ -127,8 +127,8 @@ void test_copy_assignment_same_index() {
   }
 } test;
 constexpr auto result = test();
-static_assert(result.index == 1);
-static_assert(result.value == 42);
+static_assert(result.index == 1, "");
+static_assert(result.value == 42, "");
   }
   {
 struct {
@@ -141,8 +141,8 @@ void test_copy_assignment_same_index() {
   }
 } test;
 constexpr auto result = test();
-static_assert(result.index == 1);
-static_assert(result.value == 42);
+static_assert(result.index == 1, "");
+static_assert(result.value == 42, "");
   }
 }
 
@@ -158,8 +158,8 @@ void test_copy_assignment_different_inde
   }
 } test;
 constexpr auto result = test();
-static_assert(result.index == 1);
-static_assert(result.value == 42l);
+static_assert(result.index == 1, "");
+static_assert(result.value == 42l, "");
   }
   {
 struct {
@@ -172,8 +172,8 @@ void test_copy_assignment_different_inde
   }
 } test;
 constexpr auto result = test();
-static_assert(result.index == 1);
-static_assert(result.value == 42);
+static_assert(result.index == 1, "");
+static_assert(result.value == 42, "");
   }
 }
 

Modified: 
libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp?rev=291093&r1=291092&r2=291093&view=diff
==
--- 
libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp
 Thu Jan  5 03:03:43 2017
@@ -64,7 +64,7 @@ struct TMoveAssignNTCopyAssign {
   int value;
 };
 
-static_assert(std::is_trivially_move_assignable_v);
+static_assert(std::is_trivially_move_assignable_v, 
"");
 
 void test_move_assignment_sfinae() {
   {
@@ -100,8 +100,8 @@ void test_move_assignment_same_index() {
   }
 } test;
 constexpr auto result = test();
-static_assert(result.index == 0);
-static_assert(result.value == 42);
+static_assert(result.index == 0, "");
+static_assert(result.value == 42, "");
   }
   {
 struct {
@@ -114,8 +114,8 @@ void test_move_assignment_same_index() {
   }
 } test;
 constexpr auto result = test();
-static_assert(result.index == 1);
-static_assert(result.value == 42l);
+static_assert(result.index == 1, "");
+static_assert(result.value == 42l, "");
   }
   {
 struct {
@@ -128,8 +128,8 @@ void test_move_assignment_same_index() {
   }
 } test;
 constexpr auto result = test();
-static_assert(result.index == 1);
-static_assert(result.value == 42);
+static_assert(result.index == 1, "");
+static_assert(result.value == 42, "");
   }
 }
 
@@ -145,8 +145,8 @@ void test_move_assignment_different_inde
   }
 } test;
 constexpr auto result = test();
-static_assert(result.index == 1);
-static_assert(result.value == 42l);
+static_assert(result.index == 1, "");
+

[libcxx] r291094 - Add gcc-[56] clang-3.[678] to list of XFAILS for variant tests. Patch from Michael Park

2017-01-05 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Jan  5 03:06:30 2017
New Revision: 291094

URL: http://llvm.org/viewvc/llvm-project?rev=291094&view=rev
Log:
Add gcc-[56] clang-3.[678] to list of XFAILS for variant tests. Patch from 
Michael Park

Modified:

libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp

libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp

libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp

libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp

Modified: 
libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp?rev=291094&r1=291093&r2=291094&view=diff
==
--- 
libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
 Thu Jan  5 03:06:30 2017
@@ -10,8 +10,9 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 
-// Clang 3.8 doesn't generate constexpr special members correctly.
-// XFAIL: clang-3.8, apple-clang-7, apple-clang-8
+// The following compilers don't generate constexpr special members correctly.
+// XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8
+// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8
 
 // 
 

Modified: 
libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp?rev=291094&r1=291093&r2=291094&view=diff
==
--- 
libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp
 Thu Jan  5 03:06:30 2017
@@ -10,9 +10,9 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 
-// Clang 3.8 doesn't generate constexpr special members correctly.
-// XFAIL: clang-3.8, apple-clang-7, apple-clang-8
-
+// The following compilers don't generate constexpr special members correctly.
+// XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8
+// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8
 
 // 
 

Modified: 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp?rev=291094&r1=291093&r2=291094&view=diff
==
--- 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp
 Thu Jan  5 03:06:30 2017
@@ -10,8 +10,10 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 
-// Clang 3.8 doesn't allow constexpr variables of non-literal type
-// XFAIL: clang-3.8, apple-clang-7, apple-clang-8
+// The following compilers don't allow constexpr variables of non-literal type.
+// XFAIL: gcc-5, gcc-6
+// XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8
+// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8
 
 // 
 

Modified: 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp?rev=291094&r1=291093&r2=291094&view=diff
==
--- 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp
 Thu Jan  5 03:06:30 2017
@@ -10,8 +10,10 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 
-// Clang 3.8 doesn't allow constexpr variables of non-literal type
-// XFAIL: clang-3.8, apple-clang-7, apple-clang-8
+// The following compilers don't allow constexpr variables of non-literal type.
+// XFAIL: gcc-5, gcc-6
+// XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8
+// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8
 
 // 
 


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


[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse* flags implicitly

2017-01-05 Thread Dmitry Vyukov via Phabricator via cfe-commits
dvyukov added a comment.

Yes, for tsan runtime detection does not make lots of sense -- we only have few 
SSE instructions on inlined fast path. The SSE code provides quite substantial 
speedup. User -march flag won't help as runtime is prebuilt. SCUDO is sse4.2, 
but tsan is sse3. Do you actually see any problems with sse3? It's like 10 
years old. I agree with you that strictly speaking we do wrong thing for old 
processors. But if we disable it, we disable it for everybody.  So if you don't 
hit cashes with it, I would prefer to keep sse3 in tsan.


https://reviews.llvm.org/D28304



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


[PATCH] D28315: Update tools to use new getStyle API

2017-01-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In https://reviews.llvm.org/D28315#635865, @amaiorano wrote:

> I made these changes, and they build, but I didn't really test them. Are 
> there unit tests for these tools that I can run?


If you use ninja build, you can run `ninja check-clang-tools` to run all tests.


https://reviews.llvm.org/D28315



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


[PATCH] D28238: [Driver] Add openSuse AArch64 Triple

2017-01-05 Thread Renato Golin via Phabricator via cfe-commits
rengolin added a comment.

Please, add tests to test/Driver.


https://reviews.llvm.org/D28238



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


[PATCH] D28316: [libc++] Cleanup and document <__threading_support>

2017-01-05 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath added a comment.

This is much better (few nits inline). And many thanks for the docs update 
(btw, do those docs updates land on some web URL automagically when committed?).

I think we should point out on the docs that 
`_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL` is only meant for `libc++` developers / 
testers. The purpose of this library variant is to:

- Demonstrate that `libc++` can be built with threading support externalised. 
We use `pthreads` as the underlying implementation in this case because that's 
the one we can easily test on any platform. I don't think anyone wants to 
distribute this library variant to users; they would rather compile `libc++` 
for `pthread` directly instead.
- Write tests that applies to the `LIBCXX_HAS_EXTERNAL_THREAD_API` variant. For 
example, I hope to write a test to check that the produced `libc++` dylib has 
no references to `pthread_` symbols within it. Such a test will ensure that the 
core sources of `libc++` remains pthread-free (all threading should be wired 
through the threading API).

If a library vendors really wants to distribute a variant of `libc++` with the 
threading support externalised, they should use a custom `__external_threading` 
header to replicate the behaviour of `_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL`.

Hope that makes sense?




Comment at: CMakeLists.txt:172
This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF)
+option(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY
+"Build libc++ with an externalized threading library.

Can you add another check so that this is not used together with 
`LIBCXX_HAS_EXTERNAL_THREAD_API` ?



Comment at: include/__config:894
 // Thread API
-#if !defined(_LIBCPP_HAS_NO_THREADS) && \
-!defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
-!defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+#if !defined(_LIBCPP_HAS_NO_THREADS)
 # if defined(__FreeBSD__) || \

// ignore this comment please (phab won't allow me to delete draft comments)



Comment at: include/__threading_support:21
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+# ifdef _LIBCPP_HAS_NO_THREADS
+#   error _LIBCPP_HAS_NO_THREADS cannot be defined with 
_LIBCPP_HAS_THREAD_API_EXTERNAL

This is already enforced in the `__config` header (just below where it derives 
the thread API). I think we can remove this check.



Comment at: include/__threading_support:33
+#if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
+defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)
 #define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS

Do we need the second check? I think `_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL` is 
already set through `__config` header (through `__config_site.in`) when this 
header gets included `external_threads.cpp` (?).



Comment at: include/__threading_support:38
 #endif
 
 _LIBCPP_BEGIN_NAMESPACE_STD

Can we add a second check here like:

```
#if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) && \
!defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
#error "Don't know how to declare the thread API without pthreads".
#endif
```
Or we can enforce this on the cmake file itself (or both). This ties up to my 
comment about `_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL` only meant to be for 
`libc++` developers / testers.


https://reviews.llvm.org/D28316



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


r291096 - No canonical-prefixes match in avr-toolchain.c.

2017-01-05 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Jan  5 04:06:58 2017
New Revision: 291096

URL: http://llvm.org/viewvc/llvm-project?rev=291096&view=rev
Log:
No canonical-prefixes match in avr-toolchain.c.

Modified:
cfe/trunk/test/Driver/avr-toolchain.c

Modified: cfe/trunk/test/Driver/avr-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/avr-toolchain.c?rev=291096&r1=291095&r2=291096&view=diff
==
--- cfe/trunk/test/Driver/avr-toolchain.c (original)
+++ cfe/trunk/test/Driver/avr-toolchain.c Thu Jan  5 04:06:58 2017
@@ -1,4 +1,4 @@
 // A basic clang -cc1 command-line.
 
-// RUN: %clang %s -### -target avr 2>&1 | FileCheck -check-prefix=CC1 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target avr 2>&1 | FileCheck 
-check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "avr"


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


[PATCH] D28316: [libc++] Cleanup and document <__threading_support>

2017-01-05 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF marked 3 inline comments as done.
EricWF added a comment.

In https://reviews.llvm.org/D28316#636686, @rmaprath wrote:

> (btw, do those docs updates land on some web URL automagically when 
> committed?).


Assuming the builder isn't broken then yes, the docs should automagically 
update within ~3 minutes.

> I think we should point out on the docs that 
> `_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL` is only meant for `libc++` developers / 
> testers. The purpose of this library variant is to:
> 
> - Demonstrate that `libc++` can be built with threading support externalised. 
> We use `pthreads` as the underlying implementation in this case because 
> that's the one we can easily test on any platform. I don't think anyone wants 
> to distribute this library variant to users; they would rather compile 
> `libc++` for `pthread` directly instead.
> - Write tests that applies to the `LIBCXX_HAS_EXTERNAL_THREAD_API` variant. 
> For example, I hope to write a test to check that the produced `libc++` dylib 
> has no references to `pthread_` symbols within it. Such a test will ensure 
> that the core sources of `libc++` remains pthread-free (all threading should 
> be wired through the threading API). If a library vendors really wants to 
> distribute a variant of `libc++` with the threading support externalised, 
> they should use a custom `__external_threading` header to replicate the 
> behaviour of `_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL`.
> 
>   Hope that makes sense?

All of that makes sense. I think you could write those docs better than I 
could. Would you be willing to update them?




Comment at: include/__threading_support:21
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+# ifdef _LIBCPP_HAS_NO_THREADS
+#   error _LIBCPP_HAS_NO_THREADS cannot be defined with 
_LIBCPP_HAS_THREAD_API_EXTERNAL

rmaprath wrote:
> This is already enforced in the `__config` header (just below where it 
> derives the thread API). I think we can remove this check.
Good catch. Thanks!



Comment at: include/__threading_support:33
+#if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
+defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)
 #define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS

rmaprath wrote:
> Do we need the second check? I think `_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL` is 
> already set through `__config` header (through `__config_site.in`) when this 
> header gets included `external_threads.cpp` (?).
I think it seems useful enough to make 
`_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL` work on its own to build a 
standalone threading library.



Comment at: include/__threading_support:38
 #endif
 
 _LIBCPP_BEGIN_NAMESPACE_STD

rmaprath wrote:
> Can we add a second check here like:
> 
> ```
> #if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) && \
> !defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
> #error "Don't know how to declare the thread API without pthreads".
> #endif
> ```
> Or we can enforce this on the cmake file itself (or both). This ties up to my 
> comment about `_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL` only meant to be for 
> `libc++` developers / testers.
I think that's already done in the `__config` header if we can't find a 
threading API.


https://reviews.llvm.org/D28316



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


[PATCH] D28316: [libc++] Cleanup and document <__threading_support>

2017-01-05 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 83211.
EricWF marked an inline comment as done.

https://reviews.llvm.org/D28316

Files:
  CMakeLists.txt
  docs/DesignDocs/ThreadingSupportAPI.rst
  docs/index.rst
  include/__config
  include/__config_site.in
  include/__threading_support
  lib/CMakeLists.txt
  test/CMakeLists.txt
  test/lit.site.cfg.in
  test/support/external_threads.cpp

Index: test/support/external_threads.cpp
===
--- test/support/external_threads.cpp
+++ test/support/external_threads.cpp
@@ -6,5 +6,5 @@
 // Source Licenses. See LICENSE.TXT for details.
 //
 //===--===//
-#define _LIBCPP_BUILDING_THREAD_API_EXTERNAL_PTHREAD
+#define _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL
 #include <__threading_support>
Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -28,7 +28,7 @@
 config.use_libatomic= "@LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB@"
 
 config.libcxxabi_shared = "@LIBCXXABI_ENABLE_SHARED@"
-config.cxx_ext_threads  = "@LIBCXX_HAS_EXTERNAL_THREAD_API@"
+config.cxx_ext_threads  = "@LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY@"
 
 # Let the main config do the real work.
 config.loaded_site_config = True
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -34,7 +34,7 @@
 pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
 pythonize_bool(LIBCXX_HAS_ATOMIC_LIB)
 pythonize_bool(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB)
-pythonize_bool(LIBCXX_HAS_EXTERNAL_THREAD_API)
+pythonize_bool(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
 
 # By default, for non-standalone builds, libcxx and libcxxabi share a library
 # directory.
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -275,7 +275,7 @@
   )
 endif()
 
-if (LIBCXX_HAS_EXTERNAL_THREAD_API)
+if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
   file(GLOB LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES ../test/support/external_threads.cpp)
 
   if (LIBCXX_ENABLE_SHARED)
Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -17,48 +17,25 @@
 #pragma GCC system_header
 #endif
 
-#ifndef _LIBCPP_HAS_NO_THREADS
-
-#ifndef __libcpp_has_include
-  #ifndef __has_include
-#define __libcpp_has_include(x) 0
-  #else
-#define __libcpp_has_include(x) __has_include(x)
-  #endif
-#endif
-
-#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && \
-!__libcpp_has_include(<__external_threading>)
-// If the <__external_threading> header is absent, build libc++ against a
-// pthread-oriented thread api but leave out its implementation. This setup
-// allows building+testing of an externally-threaded library variant (on any
-// platform that supports pthreads). Here, an 'externally-threaded' library
-// variant is one where the implementation of the libc++ thread api is provided
-// as a separate library.
-#define _LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD
-#endif
-
-#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && \
-__libcpp_has_include(<__external_threading>)
-#include <__external_threading>
-#else
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+# include <__external_threading>
+#elif !defined(_LIBCPP_HAS_NO_THREADS)
 
-#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
-defined(_LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD)
-#include 
-#include 
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+# include 
+# include 
 #endif
 
-#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+#if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
+defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)
 #define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
 #else
 #define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
 #endif
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
-defined(_LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD)
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 // Mutex
 typedef pthread_mutex_t __libcpp_mutex_t;
 #define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
@@ -161,8 +138,10 @@
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
 
-#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
-defined(_LIBCPP_BUILDING_THREAD_API_EXTERNAL_PTHREAD)
+#if !defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
+defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)
+
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 
 int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m)
 {
@@ -310,9 +289,9 @@
 
 #endif // _LIBCPP_HAS_THREAD_API_PTHREAD
 
-_LIBCPP_END_NAMESPACE_STD
+#endif // !_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL || _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL
 
-#endif // !_LIBCPP_HAS_THREAD_API_EXTERNAL ||

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

2017-01-05 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: doug.gregor, t.p.northover.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

This patch defines __OBJC_BOOL_IS_BOOL for C code as well, since Objective-C's 
BOOL can be also used by C code.


Repository:
  rL LLVM

https://reviews.llvm.org/D28349

Files:
  lib/Frontend/InitPreprocessor.cpp
  test/Frontend/objc-bool-is-bool.m


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


Index: test/Frontend/objc-bool-is-bool.m
===
--- test/Frontend/objc-bool-is-bool.m
+++ test/Frontend/objc-bool-is-bool.m
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -fsyntax-only -E -dM -triple=armv7k-apple-watchos %s | FileCheck --check-prefix=BOOL %s
 // RUN: %clang_cc1 -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 %s | FileCheck --check-prefix=CHAR %s
-// RUN: %clang_cc1 -x c -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 %s | FileCheck --check-prefix=NONE %s
+// RUN: %clang_cc1 -x c -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 %s | FileCheck --check-prefix=CHAR %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 %s | FileCheck --check-prefix=CHAR %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 %s | FileCheck --check-prefix=NONE %s
 
 // rdar://21170440
 
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -593,9 +593,6 @@
 Builder.defineMacro("OBJC_ZEROCOST_EXCEPTIONS");
 }
 
-Builder.defineMacro("__OBJC_BOOL_IS_BOOL",
-Twine(TI.useSignedCharForObjCBool() ? "0" : "1"));
-
 if (LangOpts.getGC() != LangOptions::NonGC)
   Builder.defineMacro("__OBJC_GC__");
 
@@ -626,6 +623,12 @@
 Builder.defineMacro("IB_DESIGNABLE", "");
   }
 
+  // Define a macro that describes the Objective-C boolean type for both
+  // Objective-C/C++ and plain C code.
+  if (LangOpts.ObjC1 || !LangOpts.CPlusPlus)
+Builder.defineMacro("__OBJC_BOOL_IS_BOOL",
+Twine(TI.useSignedCharForObjCBool() ? "0" : "1"));
+
   if (LangOpts.CPlusPlus)
 InitializeCPlusPlusFeatureTestMacros(LangOpts, Builder);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28330: [analyzer] Fix false positives in Keychain API checker

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

> Do not check if the return status has been compared to error (or no error) at 
> the time when leaks are reported since the status symbol might no longer be 
> alive. Instead, pattern match on the assume and stop tracking allocated 
> symbols on error paths.

Aha, i see! So we have pairs (A, B) of symbols (symbol A - the data that needs 
to be freed, and symbol B - the corresponding return value that needs to be 
checked for error). And liveness of A during `free()` doesn't imply liveness of 
B during `free()`.

There are multiple options:

1. In `checkDeadSymbols`, detect that B is dying, extract the necessary 
`assume()` results, and update the allocation state similarly to how you did in 
`evalAssume`, but only upon death of B.
2. In `checkLiveSymbols`, mark B as live for as long as A is alive.

I'm in favor of option 2 ideologically (if we ever automate GDM 
symbol-to-symbol maps to avoid manual cleanup, they'd naturally work that way 
out of the box and will be easy to understand) and of option 1 performance-wise 
(we'd maintain less live symbols, our most frequently-accessed maps will become 
smaller).

In any case, //we shouldn't keep dead symbols in checker state maps//, because 
the kind of error you spotted may show up pretty often.


https://reviews.llvm.org/D28330



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


[PATCH] D28316: [libc++] Cleanup and document <__threading_support>

2017-01-05 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath added a comment.

In https://reviews.llvm.org/D28316#636700, @EricWF wrote:

> In https://reviews.llvm.org/D28316#636686, @rmaprath wrote:
>
> > (btw, do those docs updates land on some web URL automagically when 
> > committed?).
>
>
> Assuming the builder isn't broken then yes, the docs should automagically 
> update within ~3 minutes.
>
> > I think we should point out on the docs that 
> > `_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL` is only meant for `libc++` developers 
> > / testers. The purpose of this library variant is to:
> > 
> > - Demonstrate that `libc++` can be built with threading support 
> > externalised. We use `pthreads` as the underlying implementation in this 
> > case because that's the one we can easily test on any platform. I don't 
> > think anyone wants to distribute this library variant to users; they would 
> > rather compile `libc++` for `pthread` directly instead.
> > - Write tests that applies to the `LIBCXX_HAS_EXTERNAL_THREAD_API` variant. 
> > For example, I hope to write a test to check that the produced `libc++` 
> > dylib has no references to `pthread_` symbols within it. Such a test will 
> > ensure that the core sources of `libc++` remains pthread-free (all 
> > threading should be wired through the threading API). If a library vendors 
> > really wants to distribute a variant of `libc++` with the threading support 
> > externalised, they should use a custom `__external_threading` header to 
> > replicate the behaviour of `_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL`.
> > 
> >   Hope that makes sense?
>
> All of that makes sense. I think you could write those docs better than I 
> could. Would you be willing to update them?


Sure, please go ahead with the commit. I'll have to do some downstream 
adjustments first, then I will update the docs.

Thanks for sorting this out!




Comment at: include/__threading_support:33
+#if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
+defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)
 #define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS

EricWF wrote:
> rmaprath wrote:
> > Do we need the second check? I think `_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL` 
> > is already set through `__config` header (through `__config_site.in`) when 
> > this header gets included `external_threads.cpp` (?).
> I think it seems useful enough to make 
> `_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL` work on its own to build a 
> standalone threading library.
Makes sense.



Comment at: include/__threading_support:38
 #endif
 
 _LIBCPP_BEGIN_NAMESPACE_STD

EricWF wrote:
> rmaprath wrote:
> > Can we add a second check here like:
> > 
> > ```
> > #if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) && \
> > !defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
> > #error "Don't know how to declare the thread API without pthreads".
> > #endif
> > ```
> > Or we can enforce this on the cmake file itself (or both). This ties up to 
> > my comment about `_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL` only meant to be for 
> > `libc++` developers / testers.
> I think that's already done in the `__config` header if we can't find a 
> threading API.
Indeed, missed that.


https://reviews.llvm.org/D28316



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


[PATCH] D28350: [Sema] Avoid -Wshadow warning when a "redefinition of " error is presented

2017-01-05 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: rsmith, rnk, bruno.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

This patch ensures that clang avoids the redundant -Wshadow warning for 
variables that already get a "redefinition of " error.


Repository:
  rL LLVM

https://reviews.llvm.org/D28350

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/warn-shadow-in-lambdas.cpp
  test/SemaCXX/warn-shadow.cpp

Index: test/SemaCXX/warn-shadow.cpp
===
--- test/SemaCXX/warn-shadow.cpp
+++ test/SemaCXX/warn-shadow.cpp
@@ -97,3 +97,13 @@
 void test8() {
   int bob; // expected-warning {{declaration shadows a variable in the global namespace}}
 }
+
+namespace rdar29067894 {
+
+void avoidWarningWhenRedefining(int b) { // expected-note {{previous definition is here}}
+  int a = 0; // expected-note {{previous definition is here}}
+  int a = 1; // expected-error {{redefinition of 'a'}}
+  int b = 2; // expected-error {{redefinition of 'b'}}
+}
+
+}
Index: test/SemaCXX/warn-shadow-in-lambdas.cpp
===
--- test/SemaCXX/warn-shadow-in-lambdas.cpp
+++ test/SemaCXX/warn-shadow-in-lambdas.cpp
@@ -137,3 +137,11 @@
   auto g3 = [param] // expected-note {{variable 'param' is explicitly captured here}}
(auto param) { ; }; // expected-warning {{declaration shadows a local variable}}
 }
+
+void avoidWarningWhenRedefining() {
+  int a = 1;
+  auto l = [b = a] { // expected-note {{previous definition is here}}
+// Don't warn on redefinitions.
+int b = 0; // expected-error {{redefinition of 'b'}}
+  };
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6425,9 +6425,10 @@
 }
   }
 
-  // Diagnose shadowed variables before filtering for scope.
-  if (D.getCXXScopeSpec().isEmpty())
-CheckShadow(S, NewVD, Previous);
+  // Find the shadowed declaration before filtering for scope.
+  NamedDecl *ShadowedDecl = D.getCXXScopeSpec().isEmpty()
+? getShadowedDeclaration(NewVD, Previous)
+: nullptr;
 
   // Don't consider existing declarations that are in a different
   // scope and are out-of-semantic-context declarations (if the new
@@ -6522,6 +6523,10 @@
 }
   }
 
+  // Diagnose shadowed variables iff this isn't a redeclaration.
+  if (ShadowedDecl && !D.isRedeclaration())
+CheckShadow(NewVD, ShadowedDecl, Previous);
+
   ProcessPragmaWeak(S, NewVD);
 
   // If this is the first declaration of an extern C variable, update
@@ -6595,33 +6600,40 @@
   return SourceLocation();
 }
 
-/// \brief Diagnose variable or built-in function shadowing.  Implements
-/// -Wshadow.
-///
-/// This method is called whenever a VarDecl is added to a "useful"
-/// scope.
-///
-/// \param S the scope in which the shadowing name is being declared
-/// \param R the lookup of the name
-///
-void Sema::CheckShadow(Scope *S, VarDecl *D, const LookupResult& R) {
+/// \brief Return the declaration shadowed by the given variable \p D, or null
+/// if it doesn't shadow any declaration or shadowing warnings are disabled.
+NamedDecl *Sema::getShadowedDeclaration(const VarDecl *D,
+const LookupResult &R) {
   // Return if warning is ignored.
   if (Diags.isIgnored(diag::warn_decl_shadow, R.getNameLoc()))
-return;
+return nullptr;
 
   // Don't diagnose declarations at file scope.
   if (D->hasGlobalStorage())
-return;
-
-  DeclContext *NewDC = D->getDeclContext();
+return nullptr;
 
   // Only diagnose if we're shadowing an unambiguous field or variable.
   if (R.getResultKind() != LookupResult::Found)
-return;
+return nullptr;
 
-  NamedDecl* ShadowedDecl = R.getFoundDecl();
-  if (!isa(ShadowedDecl) && !isa(ShadowedDecl))
-return;
+  NamedDecl *ShadowedDecl = R.getFoundDecl();
+  return isa(ShadowedDecl) || isa(ShadowedDecl)
+ ? ShadowedDecl
+ : nullptr;
+}
+
+/// \brief Diagnose variable or built-in function shadowing.  Implements
+/// -Wshadow.
+///
+/// This method is called whenever a VarDecl is added to a "useful"
+/// scope.
+///
+/// \param ShadowedDecl the declaration that is shadowed by the given variable
+/// \param R the lookup of the name
+///
+void Sema::CheckShadow(VarDecl *D, NamedDecl *ShadowedDecl,
+   const LookupResult &R) {
+  DeclContext *NewDC = D->getDeclContext();
 
   if (FieldDecl *FD = dyn_cast(ShadowedDecl)) {
 // Fields are not shadowed by variables in C++ static methods.
@@ -6732,7 +6744,8 @@
   LookupResult R(*this, D->getDeclName(), D->getLocation(),
  Sema::LookupOrdinaryName, Sema::ForRedeclaration);
   LookupName(R, S);
-  CheckShadow(S, D, R);
+  if (NamedDecl *ShadowedDecl = getShadowedDeclaration(D, R))
+  

[PATCH] D28298: [OpenMP] Add fields for flags in the offload entry descriptor.

2017-01-05 Thread Samuel Antao via Phabricator via cfe-commits
sfantao marked an inline comment as done.
sfantao added a comment.

Hi Jonas,

Thanks for the review.




Comment at: lib/CodeGen/CGOpenMPRuntime.h:250-252
+  // \brief Flags associated the device global.
+  int32_t Flags;
+

Hahnfeld wrote:
> Is that intentionally not in the `protected` section below?
Yes, we have a public getter/setter to interact with that, so no need to make 
it protected.  


https://reviews.llvm.org/D28298



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


[PATCH] D28298: [OpenMP] Add fields for flags in the offload entry descriptor.

2017-01-05 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.h:250-252
+  // \brief Flags associated the device global.
+  int32_t Flags;
+

sfantao wrote:
> Hahnfeld wrote:
> > Is that intentionally not in the `protected` section below?
> Yes, we have a public getter/setter to interact with that, so no need to make 
> it protected.  
Hm, `Order` and `Kind` also have public getters and are currently never set 
from outside - will that be required in the future?


https://reviews.llvm.org/D28298



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


[PATCH] D28315: Update tools to use new getStyle API

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

In https://reviews.llvm.org/D28315#636670, @hokein wrote:

> In https://reviews.llvm.org/D28315#635865, @amaiorano wrote:
>
> > I made these changes, and they build, but I didn't really test them. Are 
> > there unit tests for these tools that I can run?
>
>
> If you use ninja build, you can run `ninja check-clang-tools` to run all 
> tests.


Is there a way to run tests without ninja? I'm on Windows. If not, I'll use my 
Linux VM.


https://reviews.llvm.org/D28315



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


[PATCH] D28346: [AVR] Allow specifying the CPU on the command line

2017-01-05 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

Testcase?


https://reviews.llvm.org/D28346



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


r291121 - [OpenMP] Update target codegen for NVPTX device.

2017-01-05 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Thu Jan  5 09:24:05 2017
New Revision: 291121

URL: http://llvm.org/viewvc/llvm-project?rev=291121&view=rev
Log:
[OpenMP] Update target codegen for NVPTX device.

This patch includes updates for codegen of the target region for the NVPTX
device. It moves initializers from the compiler to the runtime and updates
the worker loop to assume parallel work is retrieved from the runtime. A
subsequent patch will update the codegen to retrieve the parallel work using
calls to the runtime. It includes the removal of the inline attribute
for the worker loop and disabling debug info in it.

This allows codegen for a target directive and serial execution on the
NVPTX device.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D28125

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=291121&r1=291120&r2=291121&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Thu Jan  5 09:24:05 2017
@@ -22,14 +22,10 @@ using namespace CodeGen;
 
 namespace {
 enum OpenMPRTLFunctionNVPTX {
-  /// \brief Call to void __kmpc_kernel_init(kmp_int32 omp_handle,
-  /// kmp_int32 thread_limit);
+  /// \brief Call to void __kmpc_kernel_init(kmp_int32 thread_limit);
   OMPRTL_NVPTX__kmpc_kernel_init,
-};
-
-// NVPTX Address space
-enum AddressSpace {
-  AddressSpaceShared = 3,
+  /// \brief Call to void __kmpc_kernel_deinit();
+  OMPRTL_NVPTX__kmpc_kernel_deinit,
 };
 } // namespace
 
@@ -70,6 +66,15 @@ static void getNVPTXCTABarrier(CodeGenFu
 /// Synchronize all GPU threads in a block.
 static void syncCTAThreads(CodeGenFunction &CGF) { getNVPTXCTABarrier(CGF); }
 
+/// Get the value of the thread_limit clause in the teams directive.
+/// The runtime encodes thread_limit in the launch parameter, always starting
+/// thread_limit+warpSize threads per team.
+static llvm::Value *getThreadLimit(CodeGenFunction &CGF) {
+  CGBuilderTy &Bld = CGF.Builder;
+  return Bld.CreateSub(getNVPTXNumThreads(CGF), getNVPTXWarpSize(CGF),
+   "thread_limit");
+}
+
 /// Get the thread id of the OMP master thread.
 /// The master thread id is the first thread (lane) of the last warp in the
 /// GPU block.  Warp size is assumed to be some power of 2.
@@ -103,35 +108,105 @@ void CGOpenMPRuntimeNVPTX::WorkerFunctio
   CGM.getTypes().GetFunctionType(*CGFI), 
llvm::GlobalValue::InternalLinkage,
   /* placeholder */ "_worker", &CGM.getModule());
   CGM.SetInternalFunctionAttributes(/*D=*/nullptr, WorkerFn, *CGFI);
-  WorkerFn->setLinkage(llvm::GlobalValue::InternalLinkage);
-  WorkerFn->addFnAttr(llvm::Attribute::NoInline);
 }
 
-void CGOpenMPRuntimeNVPTX::initializeEnvironment() {
-  //
-  // Initialize master-worker control state in shared memory.
-  //
+void CGOpenMPRuntimeNVPTX::emitGenericKernel(const OMPExecutableDirective &D,
+ StringRef ParentName,
+ llvm::Function *&OutlinedFn,
+ llvm::Constant *&OutlinedFnID,
+ bool IsOffloadEntry,
+ const RegionCodeGenTy &CodeGen) {
+  EntryFunctionState EST;
+  WorkerFunctionState WST(CGM);
+
+  // Emit target region as a standalone region.
+  class NVPTXPrePostActionTy : public PrePostActionTy {
+CGOpenMPRuntimeNVPTX &RT;
+CGOpenMPRuntimeNVPTX::EntryFunctionState &EST;
+CGOpenMPRuntimeNVPTX::WorkerFunctionState &WST;
+
+  public:
+NVPTXPrePostActionTy(CGOpenMPRuntimeNVPTX &RT,
+ CGOpenMPRuntimeNVPTX::EntryFunctionState &EST,
+ CGOpenMPRuntimeNVPTX::WorkerFunctionState &WST)
+: RT(RT), EST(EST), WST(WST) {}
+void Enter(CodeGenFunction &CGF) override {
+  RT.emitGenericEntryHeader(CGF, EST, WST);
+}
+void Exit(CodeGenFunction &CGF) override {
+  RT.emitGenericEntryFooter(CGF, EST);
+}
+  } Action(*this, EST, WST);
+  CodeGen.setAction(Action);
+  emitTargetOutlinedFunctionHelper(D, ParentName, OutlinedFn, OutlinedFnID,
+   IsOffloadEntry, CodeGen);
+
+  // Create the worker function
+  emitWorkerFunction(WST);
+
+  // Now change the name of the worker function to correspond to this target
+  // region's entry function.
+  WST.WorkerFn->setName(OutlinedFn->getName() + "_worker");
+}
+
+// Setup NVPTX threads for master-worker OpenMP scheme.
+void CGOpenMPRuntimeNVPTX::emitGenericEntryHeader(CodeGenFunction &CGF,
+  EntryFunctionState &EST,
+ 

[PATCH] D28298: [OpenMP] Add fields for flags in the offload entry descriptor.

2017-01-05 Thread Samuel Antao via Phabricator via cfe-commits
sfantao updated this revision to Diff 83236.
sfantao marked 2 inline comments as done.
sfantao added a comment.

- Privatize Order, Flags and Kind of the offload entry.


https://reviews.llvm.org/D28298

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  test/OpenMP/target_codegen.cpp
  test/OpenMP/target_codegen_registration.cpp

Index: test/OpenMP/target_codegen_registration.cpp
===
--- test/OpenMP/target_codegen_registration.cpp
+++ test/OpenMP/target_codegen_registration.cpp
@@ -30,11 +30,11 @@
 // CHECK-DAG: [[SE:%.+]] = type { [64 x i32] }
 // CHECK-DAG: [[ST1:%.+]] = type { [228 x i32] }
 // CHECK-DAG: [[ST2:%.+]] = type { [1128 x i32] }
-// CHECK-DAG: [[ENTTY:%.+]] = type { i8*, i8*, i[[SZ:32|64]] }
+// CHECK-DAG: [[ENTTY:%.+]] = type { i8*, i8*, i[[SZ:32|64]], i32, i32 }
 // CHECK-DAG: [[DEVTY:%.+]] = type { i8*, i8*, [[ENTTY]]*, [[ENTTY]]* }
 // CHECK-DAG: [[DSCTY:%.+]] = type { i32, [[DEVTY]]*, [[ENTTY]]*, [[ENTTY]]* }
 
-// TCHECK:[[ENTTY:%.+]] = type { i8*, i8*, i[[SZ:32|64]] }
+// TCHECK:[[ENTTY:%.+]] = type { i8*, i8*, i[[SZ:32|64]], i32, i32 }
 
 // CHECK-DAG: [[A1:@.+]] = internal global [[SA]]
 // CHECK-DAG: [[A2:@.+]] = global [[SA]]
@@ -100,54 +100,54 @@
 // CHECK-NTARGET-NOT: private unnamed_addr constant [1 x i
 
 // CHECK-DAG: [[NAMEPTR1:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME1:__omp_offloading_[0-9a-f]+_[0-9a-f]+__Z.+_l[0-9]+]]\00"
-// CHECK-DAG: [[ENTRY1:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR1]], i32 0, i32 0), i[[SZ]] 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: [[ENTRY1:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR1]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR2:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME2:.+]]\00"
-// CHECK-DAG: [[ENTRY2:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR2]], i32 0, i32 0), i[[SZ]] 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: [[ENTRY2:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR2]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR3:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME3:.+]]\00"
-// CHECK-DAG: [[ENTRY3:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR3]], i32 0, i32 0), i[[SZ]] 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: [[ENTRY3:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR3]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR4:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME4:.+]]\00"
-// CHECK-DAG: [[ENTRY4:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR4]], i32 0, i32 0), i[[SZ]] 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: [[ENTRY4:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR4]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR5:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME5:.+]]\00"
-// CHECK-DAG: [[ENTRY5:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR5]], i32 0, i32 0), i[[SZ]] 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: [[ENTRY5:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR5]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR6:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME6:.+]]\00"
-// CHECK-DAG: [[ENTRY6:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR6]], i32 0, i32 0), i[[SZ]] 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: [[ENTRY6:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR6]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
 // CHECK-DAG: [[NAMEPTR7:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME7:.+]]\00"
-// CHECK-DAG: [[ENTRY7:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR7]], i32 0, i32 0), i[[SZ]] 0 }, section ".omp_offloading.entries", align 1
+// CHECK-DAG: [[ENTRY7:@.+]] = consta

[PATCH] D28298: [OpenMP] Add fields for flags in the offload entry descriptor.

2017-01-05 Thread Samuel Antao via Phabricator via cfe-commits
sfantao added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.h:250-252
+  // \brief Flags associated the device global.
+  int32_t Flags;
+

Hahnfeld wrote:
> sfantao wrote:
> > Hahnfeld wrote:
> > > Is that intentionally not in the `protected` section below?
> > Yes, we have a public getter/setter to interact with that, so no need to 
> > make it protected.  
> Hm, `Order` and `Kind` also have public getters and are currently never set 
> from outside - will that be required in the future?
Good point, I guess those fields were being directly accessed by the child 
classes but now they are set through the constructor. I am privatizing the all 
three fields in the last diff as they don't need to be protected anymore.


https://reviews.llvm.org/D28298



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


[PATCH] D28315: Update tools to use new getStyle API

2017-01-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In https://reviews.llvm.org/D28315#636821, @amaiorano wrote:

> Is there a way to run tests without ninja? I'm on Windows. If not, I'll use 
> my Linux VM.


It is not related to the build system. There should be a `check-clang-tools` 
project, you can run tests by building it.  For example, if you are using make, 
just run `make check-clang-tools`; If you are using Visual Studio, build the 
`check-clang-tools` project.


https://reviews.llvm.org/D28315



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


[PATCH] D28257: [OpenCL] Re-enable supported core extensions based on opencl version when disabling all extensions using pragma

2017-01-05 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

Ok, LGTM! Thanks!


https://reviews.llvm.org/D28257



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


[PATCH] D28298: [OpenMP] Add fields for flags in the offload entry descriptor.

2017-01-05 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld accepted this revision.
Hahnfeld added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D28298



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


[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse* flags implicitly

2017-01-05 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D28304#636669, @dvyukov wrote:

> User -march flag won't help as runtime is prebuilt.


I meant the flag used by the compiler vendor when compiler-rt is built.

> SCUDO is sse4.2, but tsan is sse3. Do you actually see any problems with 
> sse3? It's like 10 years old. I agree with you that strictly speaking we do 
> wrong thing for old processors.

Well, it seems that SSE3 is supported since Pentium 4 / newer versions of 
Athlon64. I don't see a big issue enabling it for x86-64 but for 32-bit systems 
you're ruling out quite a lot of hardware. My only pure x86-32 box (which I use 
to test stuff) does not support SSE3.

> But if we disable it, we disable it for everybody.  So if you don't hit 
> cashes with it, I would prefer to keep sse3 in tsan.

Well, I guess that depends on how you build compiler-rt. On Gentoo, we just 
pass user CFLAGS (I need to think more on that, tbh). I would rather see the 
compiler vendor deciding on which CPUs are to be supported by the compiler, 
rather than the build system silently bumping the minimum for one component.

That said, I think we need to work on improved portability of compiler runtimes 
shipped with clang. I will probably start an open discussion on that soonish. 
FWICS we pretty much 'officially' support building just one or two variants of 
compiler-rt for different ABIs of a single architecture. This doesn't scale 
well. While I'm not sure how significant the performance impact is but right 
now we either force compiler-rt to not use newer instructions (= make it 
slower) or randomly cause -march= not to be respected.


https://reviews.llvm.org/D28304



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


r291124 - [OpenMP] Add fields for flags in the offload entry descriptor.

2017-01-05 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Thu Jan  5 10:02:49 2017
New Revision: 291124

URL: http://llvm.org/viewvc/llvm-project?rev=291124&view=rev
Log:
[OpenMP] Add fields for flags in the offload entry descriptor.

Summary:
This patch adds two fields to the offload entry descriptor. One field is meant 
to signal Ctors/Dtors and `link` global variables, and the other is reserved 
for runtime library use. 

 Currently, these fields are only filled with zeros in the current code 
generation, but that will change when `declare target` is added. 

The reason, we are adding these fields now is to make the code generation 
consistent with the runtime library proposal under review in 
https://reviews.llvm.org/D14031.

Reviewers: ABataev, hfinkel, carlo.bertolli, kkwli0, arpith-jacob, Hahnfeld

Subscribers: cfe-commits, caomhin, jholewinski

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

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/test/OpenMP/target_codegen.cpp
cfe/trunk/test/OpenMP/target_codegen_registration.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=291124&r1=291123&r2=291124&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Jan  5 10:02:49 2017
@@ -2701,14 +2701,16 @@ void CGOpenMPRuntime::OffloadEntriesInfo
  "only required for the device "
  "code generation.");
   OffloadEntriesTargetRegion[DeviceID][FileID][ParentName][LineNum] =
-  OffloadEntryInfoTargetRegion(Order, /*Addr=*/nullptr, /*ID=*/nullptr);
+  OffloadEntryInfoTargetRegion(Order, /*Addr=*/nullptr, /*ID=*/nullptr,
+   /*Flags=*/0);
   ++OffloadingEntriesNum;
 }
 
 void CGOpenMPRuntime::OffloadEntriesInfoManagerTy::
 registerTargetRegionEntryInfo(unsigned DeviceID, unsigned FileID,
   StringRef ParentName, unsigned LineNum,
-  llvm::Constant *Addr, llvm::Constant *ID) {
+  llvm::Constant *Addr, llvm::Constant *ID,
+  int32_t Flags) {
   // If we are emitting code for a target, the entry is already initialized,
   // only has to be registered.
   if (CGM.getLangOpts().OpenMPIsDevice) {
@@ -2719,9 +2721,10 @@ void CGOpenMPRuntime::OffloadEntriesInfo
 assert(Entry.isValid() && "Entry not initialized!");
 Entry.setAddress(Addr);
 Entry.setID(ID);
+Entry.setFlags(Flags);
 return;
   } else {
-OffloadEntryInfoTargetRegion Entry(OffloadingEntriesNum++, Addr, ID);
+OffloadEntryInfoTargetRegion Entry(OffloadingEntriesNum++, Addr, ID, 
Flags);
 OffloadEntriesTargetRegion[DeviceID][FileID][ParentName][LineNum] = Entry;
   }
 }
@@ -2888,7 +2891,8 @@ CGOpenMPRuntime::createOffloadingBinaryD
 }
 
 void CGOpenMPRuntime::createOffloadEntry(llvm::Constant *ID,
- llvm::Constant *Addr, uint64_t Size) {
+ llvm::Constant *Addr, uint64_t Size,
+ int32_t Flags) {
   StringRef Name = Addr->getName();
   auto *TgtOffloadEntryType = cast(
   CGM.getTypes().ConvertTypeForMem(getTgtOffloadEntryQTy()));
@@ -2918,6 +2922,8 @@ void CGOpenMPRuntime::createOffloadEntry
   EntryInit.add(AddrPtr);
   EntryInit.add(StrPtr);
   EntryInit.addInt(CGM.SizeTy, Size);
+  EntryInit.addInt(CGM.Int32Ty, Flags);
+  EntryInit.addInt(CGM.Int32Ty, 0);
   llvm::GlobalVariable *Entry =
 EntryInit.finishAndCreateGlobal(".omp_offloading.entry",
 Align,
@@ -3090,6 +3096,8 @@ QualType CGOpenMPRuntime::getTgtOffloadE
   //  // (function or global)
   //   char  *name;   // Name of the function or global.
   //   size_t size;   // Size of the entry info (0 if it a function).
+  //   int32_tflags;  // Flags associated with the entry, e.g. 'link'.
+  //   int32_treserved;   // Reserved, to use by the runtime library.
   // };
   if (TgtOffloadEntryQTy.isNull()) {
 ASTContext &C = CGM.getContext();
@@ -3098,6 +3106,10 @@ QualType CGOpenMPRuntime::getTgtOffloadE
 addFieldToRecordDecl(C, RD, C.VoidPtrTy);
 addFieldToRecordDecl(C, RD, C.getPointerType(C.CharTy));
 addFieldToRecordDecl(C, RD, C.getSizeType());
+addFieldToRecordDecl(
+C, RD, C.getIntTypeForBitwidth(/*DestWidth=*/32, /*Signed=*/true));
+addFieldToRecordDecl(
+C, RD, C.getIntTypeForBitwidth(/*DestWidth=*/32, /*Signed=*/true));
 RD->completeDefinition();
 TgtOffloadEntryQTy = C.getRecordType(RD);

r291123 - CodeGen: plumb header search down to the IAS

2017-01-05 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Jan  5 10:02:32 2017
New Revision: 291123

URL: http://llvm.org/viewvc/llvm-project?rev=291123&view=rev
Log:
CodeGen: plumb header search down to the IAS

inline assembly may use the `.include` directive to include other
content into the file.  Without the integrated assembler, the `-I` group
gets passed to the assembler.  Emulate this by collecting the header
search paths and passing them to the IAS.

Resolves PR24811!

Added:
cfe/trunk/test/CodeGen/include/
cfe/trunk/test/CodeGen/include/function.x
cfe/trunk/test/CodeGen/include/module.x
cfe/trunk/test/CodeGen/inline-asm-inclusion.c
Modified:
cfe/trunk/include/clang/CodeGen/BackendUtil.h
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp

Modified: cfe/trunk/include/clang/CodeGen/BackendUtil.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/BackendUtil.h?rev=291123&r1=291122&r2=291123&view=diff
==
--- cfe/trunk/include/clang/CodeGen/BackendUtil.h (original)
+++ cfe/trunk/include/clang/CodeGen/BackendUtil.h Thu Jan  5 10:02:32 2017
@@ -21,6 +21,7 @@ namespace llvm {
 
 namespace clang {
   class DiagnosticsEngine;
+  class HeaderSearchOptions;
   class CodeGenOptions;
   class TargetOptions;
   class LangOptions;
@@ -34,7 +35,8 @@ namespace clang {
 Backend_EmitObj///< Emit native object files
   };
 
-  void EmitBackendOutput(DiagnosticsEngine &Diags, const CodeGenOptions 
&CGOpts,
+  void EmitBackendOutput(DiagnosticsEngine &Diags, const HeaderSearchOptions &,
+ const CodeGenOptions &CGOpts,
  const TargetOptions &TOpts, const LangOptions &LOpts,
  const llvm::DataLayout &TDesc, llvm::Module *M,
  BackendAction Action,

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=291123&r1=291122&r2=291123&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jan  5 10:02:32 2017
@@ -14,6 +14,7 @@
 #include "clang/Frontend/CodeGenOptions.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Frontend/Utils.h"
+#include "clang/Lex/HeaderSearchOptions.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
@@ -32,6 +33,7 @@
 #include "llvm/IR/ModuleSummaryIndex.h"
 #include "llvm/IR/Verifier.h"
 #include "llvm/LTO/LTOBackend.h"
+#include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Object/ModuleSummaryIndexObjectFile.h"
 #include "llvm/Passes/PassBuilder.h"
@@ -61,6 +63,7 @@ namespace {
 
 class EmitAssemblyHelper {
   DiagnosticsEngine &Diags;
+  const HeaderSearchOptions &HSOpts;
   const CodeGenOptions &CodeGenOpts;
   const clang::TargetOptions &TargetOpts;
   const LangOptions &LangOpts;
@@ -100,11 +103,14 @@ private:
  raw_pwrite_stream &OS);
 
 public:
-  EmitAssemblyHelper(DiagnosticsEngine &_Diags, const CodeGenOptions &CGOpts,
+  EmitAssemblyHelper(DiagnosticsEngine &_Diags,
+ const HeaderSearchOptions &HeaderSearchOpts,
+ const CodeGenOptions &CGOpts,
  const clang::TargetOptions &TOpts,
  const LangOptions &LOpts, Module *M)
-  : Diags(_Diags), CodeGenOpts(CGOpts), TargetOpts(TOpts), LangOpts(LOpts),
-TheModule(M), CodeGenerationTime("codegen", "Code Generation Time") {}
+  : Diags(_Diags), HSOpts(HeaderSearchOpts), CodeGenOpts(CGOpts),
+TargetOpts(TOpts), LangOpts(LOpts), TheModule(M),
+CodeGenerationTime("codegen", "Code Generation Time") {}
 
   ~EmitAssemblyHelper() {
 if (CodeGenOpts.DisableFree)
@@ -584,12 +590,18 @@ void EmitAssemblyHelper::CreateTargetMac
   Options.MCOptions.MCNoExecStack = CodeGenOpts.NoExecStack;
   Options.MCOptions.MCIncrementalLinkerCompatible =
   CodeGenOpts.IncrementalLinkerCompatible;
-  Options.MCOptions.MCPIECopyRelocations =
-  CodeGenOpts.PIECopyRelocations;
+  Options.MCOptions.MCPIECopyRelocations = CodeGenOpts.PIECopyRelocations;
   Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings;
   Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose;
   Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments;
   Options.MCOptions.ABIName = TargetOpts.ABI;
+  for (const auto &Entry : HSOpts.UserEntries)
+if (!Entry.IsFramework &&
+(Entry.Group == frontend::IncludeDirGroup::Quoted ||
+ Entry.Group == frontend::IncludeDirGroup::Angled ||
+ Entry.Group == frontend::IncludeDirGroup::System))
+  Options.MCOptions.IASSearchPaths.push_back(
+  Entry.IgnoreSysRoot ? Entr

[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2017-01-05 Thread Firat Kasmis via Phabricator via cfe-commits
firolino added inline comments.



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:34
+  // a tag declaration (e.g. struct, class etc.):
+  // class A { } Object1, Object2;  <-- won't be matched
+  Finder->addMatcher(

aaron.ballman wrote:
> firolino wrote:
> > aaron.ballman wrote:
> > > firolino wrote:
> > > > aaron.ballman wrote:
> > > > > firolino wrote:
> > > > > > firolino wrote:
> > > > > > > firolino wrote:
> > > > > > > > firolino wrote:
> > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > firolino wrote:
> > > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > > Why do we not want to match this?
> > > > > > > > > > > If we decide, whether we transform 
> > > > > > > > > > > ```
> > > > > > > > > > > class A { 
> > > > > > > > > > > } Object1, Object2;
> > > > > > > > > > > ``` 
> > > > > > > > > > > to
> > > > > > > > > > > ```
> > > > > > > > > > > class A { 
> > > > > > > > > > > } Object1, 
> > > > > > > > > > > Object2;
> > > > > > > > > > > ``` 
> > > > > > > > > > > or
> > > > > > > > > > > ```
> > > > > > > > > > > class A { 
> > > > > > > > > > > } 
> > > > > > > > > > > Object1, 
> > > > > > > > > > > Object2;
> > > > > > > > > > > ``` 
> > > > > > > > > > > I might consider adding support for it. Moreover, this 
> > > > > > > > > > > kind of definition is usually seen globally and I don't 
> > > > > > > > > > > know how to handle globals yet. See 
> > > > > > > > > > > http://lists.llvm.org/pipermail/cfe-dev/2015-November/046262.html
> > > > > > > > > > I think this should be handled. It can be handled in either 
> > > > > > > > > > of the forms you show, or by saying:
> > > > > > > > > > ```
> > > > > > > > > > A Object1;
> > > > > > > > > > A Object2;
> > > > > > > > > > ```
> > > > > > > > > > If all of these turn out to be a problem, we can still 
> > > > > > > > > > diagnose without providing a fixit.
> > > > > > > > > > 
> > > > > > > > > > As for globals in general, they can be handled in a 
> > > > > > > > > > separate patch once we figure out the declaration grouping.
> > > > > > > > > OK. I will try to split the object definition from the class 
> > > > > > > > > definition, as you have suggested. Thus, I can kick out the 
> > > > > > > > > tagDecl-matcher as well. If there is no easy way to do this, 
> > > > > > > > > it will be reported anyway but without a fixit.
> > > > > > > > > 
> > > > > > > > > Note for me: Update documentation!
> > > > > > > > What about
> > > > > > > > ```
> > > > > > > > struct S {
> > > > > > > > } S1;
> > > > > > > > ```
> > > > > > > > I would like to report this too, since two names are being 
> > > > > > > > declared here. `S` and `S1`. What do you think?
> > > > > > > ```
> > > > > > > struct {
> > > > > > > } nn1, nn2;
> > > > > > > ```
> > > > > > > Shall we ignore anonymous definitions?
> > > > > > To be more precise: Warn and provide a fixit for `struct S {} S1`. 
> > > > > > Only warn for `struct {} nn1, nn2`.
> > > > > > What about
> > > > > > 
> > > > > > ```
> > > > > > struct S {
> > > > > > } S1;
> > > > > > ```
> > > > > > I would like to report this too, since two names are being declared 
> > > > > > here. S and S1. What do you think?
> > > > > 
> > > > > I don't think that this should be diagnosed. For one, this is a 
> > > > > relatively common pattern (arguably more common than `struct S { } 
> > > > > S1, S2;`), but also, it names two very distinct entities (a type and 
> > > > > a variable).
> > > > > 
> > > > > > ```
> > > > > > struct {
> > > > > > } nn1, nn2;
> > > > > >```
> > > > > > Shall we ignore anonymous definitions?
> > > > > 
> > > > > Yes, we basically have to.
> > > > > 
> > > > Transforming
> > > > ```
> > > > typedef struct X { int t; } X, Y;
> > > > ```
> > > > to
> > > > ```
> > > > typedef struct X { int t; };
> > > > typedef X X;
> > > > typedef X Y;
> > > > ```
> > > > will be valid, but looks odd.
> > > I am on the fence about this transformation -- it does not declare new 
> > > objects, but instead declares new types. A very common pattern in some 
> > > libraries (such as the Win32 SDK) is to declare:
> > > ```
> > > typedef struct Blah {
> > > 
> > > } Blah, *PBlah, **PPBlah;
> > > ```
> > > Because of that pattern, diagnosing the above typedef is likely to be 
> > > very chatty in some projects, and I don't know that the fixit provides 
> > > much real benefit for types.
> > > 
> > > At least for the CERT DCL04-C version of this rule, that code should not 
> > > be flagged. Do you think any of the variations of this check should flag 
> > > it?
> > Maybe we should reconsider where to split and where not. The original idea 
> > was to minimize confusion on code like
> > ```
> > int* a,b;
> > ```
> > whereas 
> > ```
> > struct S {} *s1, s2;
> > ```
> > seems not so confusing as above. However, 
> > ```
> > struct S {}* s1, s2;
> > ```
> > looks dangerous again.
> > 
> > Even following code looks unfamiliar to me.
> > ```
> > typedef struc

[PATCH] D25866: [Sema] Support implicit scalar to vector conversions

2017-01-05 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

Ping.


https://reviews.llvm.org/D25866



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


r291125 - test: add an explicit triple

2017-01-05 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Jan  5 10:36:15 2017
New Revision: 291125

URL: http://llvm.org/viewvc/llvm-project?rev=291125&view=rev
Log:
test: add an explicit triple

Not all targets use the integrated assembler.  Specify a triple to
ensure we use the integrated as for this.

Modified:
cfe/trunk/test/CodeGen/inline-asm-inclusion.c

Modified: cfe/trunk/test/CodeGen/inline-asm-inclusion.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/inline-asm-inclusion.c?rev=291125&r1=291124&r2=291125&view=diff
==
--- cfe/trunk/test/CodeGen/inline-asm-inclusion.c (original)
+++ cfe/trunk/test/CodeGen/inline-asm-inclusion.c Thu Jan  5 10:36:15 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -I %p/include -S -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i686--- -I %p/include -S -o - %s | FileCheck %s
 
 __asm__(".include \"module.x\"");
 void function(void) {


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


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

2017-01-05 Thread Doug Gregor via Phabricator via cfe-commits
doug.gregor added a comment.

The "!LangOpts.CPlusPlus" doesn't make sense to me. You're presumably defining 
this macro in C because the Objective-C runtime is usable from C, but that same 
logic applies to C++ code. It seems like we should be defining this macro 
unconditionally.


Repository:
  rL LLVM

https://reviews.llvm.org/D28349



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


r291128 - [Windows] Remove functions in intrin.h that are defined in Builtin.def.

2017-01-05 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  5 10:51:37 2017
New Revision: 291128

URL: http://llvm.org/viewvc/llvm-project?rev=291128&view=rev
Log:
[Windows] Remove functions in intrin.h that are defined in Builtin.def.

Summary:
These duplicate declarations cause a problem for CUDA compiles on
Windows.  All implicitly-defined functions are host+device, and this
applies to the declarations in Builtin.def.  But then when we see the
declarations in intrin.h, they have no attributes, so are host-only
functions.  This is an error.

(A better fix might be to make these builtins host-only, but that is a
much bigger change.)

Reviewers: rnk

Subscribers: cfe-commits, echristo

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

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

Modified: cfe/trunk/lib/Headers/intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=291128&r1=291127&r2=291128&view=diff
==
--- cfe/trunk/lib/Headers/intrin.h (original)
+++ cfe/trunk/lib/Headers/intrin.h Thu Jan  5 10:51:37 2017
@@ -65,7 +65,6 @@ static __inline__
 void __cpuid(int[4], int);
 static __inline__
 void __cpuidex(int[4], int, int);
-void __debugbreak(void);
 static __inline__
 __int64 __emul(int, int);
 static __inline__
@@ -109,10 +108,6 @@ void __outdword(unsigned short, unsigned
 void __outdwordstring(unsigned short, unsigned long *, unsigned long);
 void __outword(unsigned short, unsigned short);
 void __outwordstring(unsigned short, unsigned short *, unsigned long);
-static __inline__
-unsigned int __popcnt(unsigned int);
-static __inline__
-unsigned short __popcnt16(unsigned short);
 unsigned long __readcr0(void);
 unsigned long __readcr2(void);
 static __inline__
@@ -124,8 +119,6 @@ unsigned int __readdr(unsigned int);
 static __inline__
 unsigned char __readfsbyte(unsigned long);
 static __inline__
-unsigned long __readfsdword(unsigned long);
-static __inline__
 unsigned __int64 __readfsqword(unsigned long);
 static __inline__
 unsigned short __readfsword(unsigned long);
@@ -179,108 +172,34 @@ static __inline__
 unsigned char _bittestandreset(long *, long);
 static __inline__
 unsigned char _bittestandset(long *, long);
-unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64);
-unsigned long __cdecl _byteswap_ulong(unsigned long);
-unsigned short __cdecl _byteswap_ushort(unsigned short);
 void __cdecl _disable(void);
 void __cdecl _enable(void);
 long _InterlockedAddLargeStatistic(__int64 volatile *_Addend, long _Value);
-static __inline__
-long _InterlockedAnd(long volatile *_Value, long _Mask);
-static __inline__
-short _InterlockedAnd16(short volatile *_Value, short _Mask);
-static __inline__
-char _InterlockedAnd8(char volatile *_Value, char _Mask);
 unsigned char _interlockedbittestandreset(long volatile *, long);
 static __inline__
 unsigned char _interlockedbittestandset(long volatile *, long);
-static __inline__
-long __cdecl _InterlockedCompareExchange(long volatile *_Destination,
- long _Exchange, long _Comparand);
 long _InterlockedCompareExchange_HLEAcquire(long volatile *, long, long);
 long _InterlockedCompareExchange_HLERelease(long volatile *, long, long);
-static __inline__
-short _InterlockedCompareExchange16(short volatile *_Destination,
-short _Exchange, short _Comparand);
-static __inline__
-__int64 _InterlockedCompareExchange64(__int64 volatile *_Destination,
-  __int64 _Exchange, __int64 _Comparand);
 __int64 _InterlockedcompareExchange64_HLEAcquire(__int64 volatile *, __int64,
  __int64);
 __int64 _InterlockedCompareExchange64_HLERelease(__int64 volatile *, __int64,
  __int64);
-static __inline__
-char _InterlockedCompareExchange8(char volatile *_Destination, char _Exchange,
-  char _Comparand);
 void *_InterlockedCompareExchangePointer_HLEAcquire(void *volatile *, void *,
 void *);
 void *_InterlockedCompareExchangePointer_HLERelease(void *volatile *, void *,
 void *);
-static __inline__
-long __cdecl _InterlockedDecrement(long volatile *_Addend);
-static __inline__
-short _InterlockedDecrement16(short volatile *_Addend);
-long _InterlockedExchange(long volatile *_Target, long _Value);
-static __inline__
-short _InterlockedExchange16(short volatile *_Target, short _Value);
-static __inline__
-char _InterlockedExchange8(char volatile *_Target, char _Value);
-static __inline__
-long __cdecl _InterlockedExchangeAdd(long volatile *_Addend, long _Value);
 long _InterlockedExchangeAdd_HLEAcquire(long volatile *, long);
 long _InterlockedExchangeAdd_HLERelease(long volatile *, long);
-static __inline__
-short _InterlockedExchangeAdd16(short volatile *_Addend, short 

[PATCH] D28318: [TableGen] Only normalize the spelling of GNU-style attributes.

2017-01-05 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291129: [TableGen] Only normalize the spelling of GNU-style 
attributes. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D28318?vs=83125&id=83253#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28318

Files:
  cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp


Index: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
===
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
@@ -133,10 +133,9 @@
   return Name.trim("_");
 }
 
-// Normalize attribute spelling only if the spelling has both leading
-// and trailing underscores. For example, __ms_struct__ will be 
-// normalized to "ms_struct"; __cdecl will remain intact.
-static StringRef NormalizeAttrSpelling(StringRef AttrSpelling) {
+// Normalize the spelling of a GNU attribute (i.e. "x" in 
"__attribute__((x))"),
+// removing "__" if it appears at the beginning and end of the attribute's 
name.
+static StringRef NormalizeGNUAttrSpelling(StringRef AttrSpelling) {
   if (AttrSpelling.startswith("__") && AttrSpelling.endswith("__")) {
 AttrSpelling = AttrSpelling.substr(2, AttrSpelling.size() - 4);
   }
@@ -3045,7 +3044,11 @@
 
 assert(Matches && "Unsupported spelling variety found");
 
-Spelling += NormalizeAttrSpelling(RawSpelling);
+if (Variety == "GNU")
+  Spelling += NormalizeGNUAttrSpelling(RawSpelling);
+else
+  Spelling += RawSpelling;
+
 if (SemaHandler)
   Matches->push_back(StringMatcher::StringPair(Spelling,
   "return AttributeList::AT_" + AttrName + ";"));


Index: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
===
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
@@ -133,10 +133,9 @@
   return Name.trim("_");
 }
 
-// Normalize attribute spelling only if the spelling has both leading
-// and trailing underscores. For example, __ms_struct__ will be 
-// normalized to "ms_struct"; __cdecl will remain intact.
-static StringRef NormalizeAttrSpelling(StringRef AttrSpelling) {
+// Normalize the spelling of a GNU attribute (i.e. "x" in "__attribute__((x))"),
+// removing "__" if it appears at the beginning and end of the attribute's name.
+static StringRef NormalizeGNUAttrSpelling(StringRef AttrSpelling) {
   if (AttrSpelling.startswith("__") && AttrSpelling.endswith("__")) {
 AttrSpelling = AttrSpelling.substr(2, AttrSpelling.size() - 4);
   }
@@ -3045,7 +3044,11 @@
 
 assert(Matches && "Unsupported spelling variety found");
 
-Spelling += NormalizeAttrSpelling(RawSpelling);
+if (Variety == "GNU")
+  Spelling += NormalizeGNUAttrSpelling(RawSpelling);
+else
+  Spelling += RawSpelling;
+
 if (SemaHandler)
   Matches->push_back(StringMatcher::StringPair(Spelling,
   "return AttributeList::AT_" + AttrName + ";"));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r291129 - [TableGen] Only normalize the spelling of GNU-style attributes.

2017-01-05 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  5 10:51:54 2017
New Revision: 291129

URL: http://llvm.org/viewvc/llvm-project?rev=291129&view=rev
Log:
[TableGen] Only normalize the spelling of GNU-style attributes.

Summary:
When Sema looks up an attribute name, it strips off leading and trailing
"__" if the attribute is GNU-style.  That is, __attribute__((foo)) and
__attribute__((__foo__)) are equivalent.

This is only true for GNU-style attributes.  In particular,
__declspec(__foo__) is not equivalent to __declspec(foo), and Sema
respects this difference.

This patch fixes TableGen to match Sema's behavior.  The spelling
'GNU<"__foo__">' should be normalized to 'GNU<"foo">', but
'Declspec<"__foo__">' should not be changed.

This is necessary to make CUDA compilation work on Windows, because e.g.
the __device__ attribute is spelled __declspec(__device__).

Attr.td does not contain any Declspec spellings that start or end with
"__", so this change should not affect any other attributes.

Reviewers: rnk

Subscribers: cfe-commits, tra

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

Modified:
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=291129&r1=291128&r2=291129&view=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Thu Jan  5 10:51:54 2017
@@ -133,10 +133,9 @@ static StringRef NormalizeNameForSpellin
   return Name.trim("_");
 }
 
-// Normalize attribute spelling only if the spelling has both leading
-// and trailing underscores. For example, __ms_struct__ will be 
-// normalized to "ms_struct"; __cdecl will remain intact.
-static StringRef NormalizeAttrSpelling(StringRef AttrSpelling) {
+// Normalize the spelling of a GNU attribute (i.e. "x" in 
"__attribute__((x))"),
+// removing "__" if it appears at the beginning and end of the attribute's 
name.
+static StringRef NormalizeGNUAttrSpelling(StringRef AttrSpelling) {
   if (AttrSpelling.startswith("__") && AttrSpelling.endswith("__")) {
 AttrSpelling = AttrSpelling.substr(2, AttrSpelling.size() - 4);
   }
@@ -3045,7 +3044,11 @@ void EmitClangAttrParsedAttrKinds(Record
 
 assert(Matches && "Unsupported spelling variety found");
 
-Spelling += NormalizeAttrSpelling(RawSpelling);
+if (Variety == "GNU")
+  Spelling += NormalizeGNUAttrSpelling(RawSpelling);
+else
+  Spelling += RawSpelling;
+
 if (SemaHandler)
   Matches->push_back(StringMatcher::StringPair(Spelling,
   "return AttributeList::AT_" + AttrName + ";"));


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


r291130 - [CUDA] Make CUDAInstallationDetector take the host triple in its constructor.

2017-01-05 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  5 10:52:11 2017
New Revision: 291130

URL: http://llvm.org/viewvc/llvm-project?rev=291130&view=rev
Log:
[CUDA] Make CUDAInstallationDetector take the host triple in its constructor.

Summary:
Previously it was taking the true target triple, which is not really
what it needs: The location of the CUDA installation depends on the host
OS.

Reviewers: tra

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=291130&r1=291129&r2=291130&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Jan  5 10:52:11 2017
@@ -1805,7 +1805,7 @@ static CudaVersion ParseCudaVersionFile(
 }
 
 CudaInstallationDetector::CudaInstallationDetector(
-const Driver &D, const llvm::Triple &TargetTriple,
+const Driver &D, const llvm::Triple &HostTriple,
 const llvm::opt::ArgList &Args)
 : D(D) {
   SmallVector CudaPathCandidates;
@@ -1840,7 +1840,7 @@ CudaInstallationDetector::CudaInstallati
 // It's sufficient for our purposes to be flexible: If both lib and lib64
 // exist, we choose whichever one matches our triple.  Otherwise, if only
 // lib exists, we use it.
-if (TargetTriple.isArch64Bit() && FS.exists(InstallPath + "/lib64"))
+if (HostTriple.isArch64Bit() && FS.exists(InstallPath + "/lib64"))
   LibPath = InstallPath + "/lib64";
 else if (FS.exists(InstallPath + "/lib"))
   LibPath = InstallPath + "/lib";
@@ -4870,7 +4870,7 @@ Tool *DragonFly::buildLinker() const {
 CudaToolChain::CudaToolChain(const Driver &D, const llvm::Triple &Triple,
  const ToolChain &HostTC, const ArgList &Args)
 : ToolChain(D, Triple, Args), HostTC(HostTC),
-  CudaInstallation(D, Triple, Args) {
+  CudaInstallation(D, HostTC.getTriple(), Args) {
   if (CudaInstallation.isValid())
 getProgramPaths().push_back(CudaInstallation.getBinPath());
 }

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=291130&r1=291129&r2=291130&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Thu Jan  5 10:52:11 2017
@@ -43,7 +43,7 @@ private:
   mutable llvm::SmallSet ArchsWithVersionTooLowErrors;
 
 public:
-  CudaInstallationDetector(const Driver &D, const llvm::Triple &Triple,
+  CudaInstallationDetector(const Driver &D, const llvm::Triple &HostTriple,
const llvm::opt::ArgList &Args);
 
   void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,


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


[PATCH] D28319: [CUDA] Make CUDAInstallationDetector take the host triple in its constructor.

2017-01-05 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291130: [CUDA] Make CUDAInstallationDetector take the host 
triple in its constructor. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D28319?vs=83126&id=83254#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28319

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Driver/ToolChains.h


Index: cfe/trunk/lib/Driver/ToolChains.h
===
--- cfe/trunk/lib/Driver/ToolChains.h
+++ cfe/trunk/lib/Driver/ToolChains.h
@@ -43,7 +43,7 @@
   mutable llvm::SmallSet ArchsWithVersionTooLowErrors;
 
 public:
-  CudaInstallationDetector(const Driver &D, const llvm::Triple &Triple,
+  CudaInstallationDetector(const Driver &D, const llvm::Triple &HostTriple,
const llvm::opt::ArgList &Args);
 
   void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -1805,7 +1805,7 @@
 }
 
 CudaInstallationDetector::CudaInstallationDetector(
-const Driver &D, const llvm::Triple &TargetTriple,
+const Driver &D, const llvm::Triple &HostTriple,
 const llvm::opt::ArgList &Args)
 : D(D) {
   SmallVector CudaPathCandidates;
@@ -1840,7 +1840,7 @@
 // It's sufficient for our purposes to be flexible: If both lib and lib64
 // exist, we choose whichever one matches our triple.  Otherwise, if only
 // lib exists, we use it.
-if (TargetTriple.isArch64Bit() && FS.exists(InstallPath + "/lib64"))
+if (HostTriple.isArch64Bit() && FS.exists(InstallPath + "/lib64"))
   LibPath = InstallPath + "/lib64";
 else if (FS.exists(InstallPath + "/lib"))
   LibPath = InstallPath + "/lib";
@@ -4870,7 +4870,7 @@
 CudaToolChain::CudaToolChain(const Driver &D, const llvm::Triple &Triple,
  const ToolChain &HostTC, const ArgList &Args)
 : ToolChain(D, Triple, Args), HostTC(HostTC),
-  CudaInstallation(D, Triple, Args) {
+  CudaInstallation(D, HostTC.getTriple(), Args) {
   if (CudaInstallation.isValid())
 getProgramPaths().push_back(CudaInstallation.getBinPath());
 }


Index: cfe/trunk/lib/Driver/ToolChains.h
===
--- cfe/trunk/lib/Driver/ToolChains.h
+++ cfe/trunk/lib/Driver/ToolChains.h
@@ -43,7 +43,7 @@
   mutable llvm::SmallSet ArchsWithVersionTooLowErrors;
 
 public:
-  CudaInstallationDetector(const Driver &D, const llvm::Triple &Triple,
+  CudaInstallationDetector(const Driver &D, const llvm::Triple &HostTriple,
const llvm::opt::ArgList &Args);
 
   void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -1805,7 +1805,7 @@
 }
 
 CudaInstallationDetector::CudaInstallationDetector(
-const Driver &D, const llvm::Triple &TargetTriple,
+const Driver &D, const llvm::Triple &HostTriple,
 const llvm::opt::ArgList &Args)
 : D(D) {
   SmallVector CudaPathCandidates;
@@ -1840,7 +1840,7 @@
 // It's sufficient for our purposes to be flexible: If both lib and lib64
 // exist, we choose whichever one matches our triple.  Otherwise, if only
 // lib exists, we use it.
-if (TargetTriple.isArch64Bit() && FS.exists(InstallPath + "/lib64"))
+if (HostTriple.isArch64Bit() && FS.exists(InstallPath + "/lib64"))
   LibPath = InstallPath + "/lib64";
 else if (FS.exists(InstallPath + "/lib"))
   LibPath = InstallPath + "/lib";
@@ -4870,7 +4870,7 @@
 CudaToolChain::CudaToolChain(const Driver &D, const llvm::Triple &Triple,
  const ToolChain &HostTC, const ArgList &Args)
 : ToolChain(D, Triple, Args), HostTC(HostTC),
-  CudaInstallation(D, Triple, Args) {
+  CudaInstallation(D, HostTC.getTriple(), Args) {
   if (CudaInstallation.isValid())
 getProgramPaths().push_back(CudaInstallation.getBinPath());
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r291131 - [Driver] Driver changes to support CUDA compilation on Windows.

2017-01-05 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  5 10:52:29 2017
New Revision: 291131

URL: http://llvm.org/viewvc/llvm-project?rev=291131&view=rev
Log:
[Driver] Driver changes to support CUDA compilation on Windows.

Summary:
For the most part this is straightforward: Just add a CudaInstallation
object to the MSVC and MinGW toolchains.

CudaToolChain has to override computeMSVCVersion so that
Clang::constructJob passes the right version flag to cc1.  We have to
modify IsWindowsMSVC and friends in Clang::constructJob to be true when
compiling CUDA device code on Windows for the same reason.

Depends on: D28319

Reviewers: tra

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/Driver/Inputs/CUDA-windows/
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/bin/
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/bin/.keep
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/include/
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/include/.keep
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/lib/
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/lib/.keep
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/nvvm/
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/nvvm/libdevice/
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/nvvm/libdevice/libdevice.compute_30.10.bc
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/nvvm/libdevice/libdevice.compute_35.10.bc
cfe/trunk/test/Driver/cuda-windows.cu
Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/MSVCToolChain.cpp
cfe/trunk/lib/Driver/MinGWToolChain.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=291131&r1=291130&r2=291131&view=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Thu Jan  5 10:52:29 2017
@@ -139,6 +139,13 @@ public:
   vfs::FileSystem &getVFS() const;
   const llvm::Triple &getTriple() const { return Triple; }
 
+  /// Get the toolchain's aux triple, if it has one.
+  ///
+  /// Exactly what the aux triple represents depends on the toolchain, but for
+  /// example when compiling CUDA code for the GPU, the triple might be NVPTX,
+  /// while the aux triple is the host (CPU) toolchain, e.g. x86-linux-gnu.
+  virtual const llvm::Triple *getAuxTriple() const { return nullptr; }
+
   llvm::Triple::ArchType getArch() const { return Triple.getArch(); }
   StringRef getArchName() const { return Triple.getArchName(); }
   StringRef getPlatform() const { return Triple.getVendorName(); }

Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSVCToolChain.cpp?rev=291131&r1=291130&r2=291131&view=diff
==
--- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Thu Jan  5 10:52:29 2017
@@ -47,9 +47,9 @@ using namespace clang::driver::toolchain
 using namespace clang;
 using namespace llvm::opt;
 
-MSVCToolChain::MSVCToolChain(const Driver &D, const llvm::Triple& Triple,
+MSVCToolChain::MSVCToolChain(const Driver &D, const llvm::Triple &Triple,
  const ArgList &Args)
-  : ToolChain(D, Triple, Args) {
+: ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
 getProgramPaths().push_back(getDriver().Dir);
@@ -94,6 +94,15 @@ bool MSVCToolChain::isPICDefaultForced()
   return getArch() == llvm::Triple::x86_64;
 }
 
+void MSVCToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
+   ArgStringList &CC1Args) const {
+  CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
+}
+
+void MSVCToolChain::printVerboseInfo(raw_ostream &OS) const {
+  Cud

r291133 - [ToolChains] Use "static" instead of an anonymous namespace for a function. NFC

2017-01-05 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  5 10:52:47 2017
New Revision: 291133

URL: http://llvm.org/viewvc/llvm-project?rev=291133&view=rev
Log:
[ToolChains] Use "static" instead of an anonymous namespace for a function.  NFC

Modified:
cfe/trunk/lib/Driver/MinGWToolChain.cpp

Modified: cfe/trunk/lib/Driver/MinGWToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MinGWToolChain.cpp?rev=291133&r1=291132&r2=291133&view=diff
==
--- cfe/trunk/lib/Driver/MinGWToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/MinGWToolChain.cpp Thu Jan  5 10:52:47 2017
@@ -20,10 +20,9 @@ using namespace clang::driver::toolchain
 using namespace clang;
 using namespace llvm::opt;
 
-namespace {
 // Simplified from 
Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple.
-bool findGccVersion(StringRef LibDir, std::string &GccLibDir,
-std::string &Ver) {
+static bool findGccVersion(StringRef LibDir, std::string &GccLibDir,
+   std::string &Ver) {
   Generic_GCC::GCCVersion Version = Generic_GCC::GCCVersion::Parse("0.0.0");
   std::error_code EC;
   for (llvm::sys::fs::directory_iterator LI(LibDir, EC), LE; !EC && LI != LE;
@@ -40,7 +39,6 @@ bool findGccVersion(StringRef LibDir, st
   }
   return Ver.size();
 }
-}
 
 void MinGW::findGccLibDir() {
   llvm::SmallVector, 2> Archs;


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


[PATCH] D28320: [Driver] Driver changes to support CUDA compilation on Windows.

2017-01-05 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
jlebar marked an inline comment as done.
Closed by commit rL291131: [Driver] Driver changes to support CUDA compilation 
on Windows. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D28320?vs=83127&id=83255#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28320

Files:
  cfe/trunk/include/clang/Driver/ToolChain.h
  cfe/trunk/lib/Driver/MSVCToolChain.cpp
  cfe/trunk/lib/Driver/MinGWToolChain.cpp
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Driver/ToolChains.h
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU Computing 
Toolkit/CUDA/v8.0/bin/.keep
  cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU Computing 
Toolkit/CUDA/v8.0/include/.keep
  cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU Computing 
Toolkit/CUDA/v8.0/lib/.keep
  cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU Computing 
Toolkit/CUDA/v8.0/nvvm/libdevice/libdevice.compute_30.10.bc
  cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU Computing 
Toolkit/CUDA/v8.0/nvvm/libdevice/libdevice.compute_35.10.bc
  cfe/trunk/test/Driver/cuda-windows.cu

Index: cfe/trunk/include/clang/Driver/ToolChain.h
===
--- cfe/trunk/include/clang/Driver/ToolChain.h
+++ cfe/trunk/include/clang/Driver/ToolChain.h
@@ -139,6 +139,13 @@
   vfs::FileSystem &getVFS() const;
   const llvm::Triple &getTriple() const { return Triple; }
 
+  /// Get the toolchain's aux triple, if it has one.
+  ///
+  /// Exactly what the aux triple represents depends on the toolchain, but for
+  /// example when compiling CUDA code for the GPU, the triple might be NVPTX,
+  /// while the aux triple is the host (CPU) toolchain, e.g. x86-linux-gnu.
+  virtual const llvm::Triple *getAuxTriple() const { return nullptr; }
+
   llvm::Triple::ArchType getArch() const { return Triple.getArch(); }
   StringRef getArchName() const { return Triple.getArchName(); }
   StringRef getPlatform() const { return Triple.getVendorName(); }
Index: cfe/trunk/test/Driver/cuda-windows.cu
===
--- cfe/trunk/test/Driver/cuda-windows.cu
+++ cfe/trunk/test/Driver/cuda-windows.cu
@@ -0,0 +1,14 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+//
+// RUN: %clang -v --target=i386-pc-windows-msvc \
+// RUN:   --sysroot=%S/Inputs/CUDA-windows 2>&1 %s -### | FileCheck %s
+// RUN: %clang -v --target=i386-pc-windows-mingw32 \
+// RUN:   --sysroot=%S/Inputs/CUDA-windows 2>&1 %s -### | FileCheck %s
+
+// CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA-windows/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0
+// CHECK: "-cc1" "-triple" "nvptx-nvidia-cuda"
+// CHECK-SAME: "-fms-extensions"
+// CHECK-SAME: "-fms-compatibility"
+// CHECK-SAME: "-fms-compatibility-version=
Index: cfe/trunk/lib/Driver/MinGWToolChain.cpp
===
--- cfe/trunk/lib/Driver/MinGWToolChain.cpp
+++ cfe/trunk/lib/Driver/MinGWToolChain.cpp
@@ -63,7 +63,7 @@
 }
 
 MinGW::MinGW(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
-: ToolChain(D, Triple, Args) {
+: ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
 // In Windows there aren't any standard install locations, we search
@@ -135,6 +135,15 @@
   return getArch() == llvm::Triple::x86_64;
 }
 
+void MinGW::AddCudaIncludeArgs(const ArgList &DriverArgs,
+   ArgStringList &CC1Args) const {
+  CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
+}
+
+void MinGW::printVerboseInfo(raw_ostream &OS) const {
+  CudaInstallation.print(OS);
+}
+
 // Include directories for various hosts:
 
 // Windows, mingw.org
Index: cfe/trunk/lib/Driver/MSVCToolChain.cpp
===
--- cfe/trunk/lib/Driver/MSVCToolChain.cpp
+++ cfe/trunk/lib/Driver/MSVCToolChain.cpp
@@ -47,9 +47,9 @@
 using namespace clang;
 using namespace llvm::opt;
 
-MSVCToolChain::MSVCToolChain(const Driver &D, const llvm::Triple& Triple,
+MSVCToolChain::MSVCToolChain(const Driver &D, const llvm::Triple &Triple,
  const ArgList &Args)
-  : ToolChain(D, Triple, Args) {
+: ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
 getProgramPaths().push_back(getDriver().Dir);
@@ -94,6 +94,15 @@
   return getArch() == llvm::Triple::x86_64;
 }
 
+void MSVCToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
+   ArgStringList &CC1Args) const {
+  CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args

r291134 - [CUDA] Add __declspec spellings for CUDA attributes.

2017-01-05 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  5 10:53:04 2017
New Revision: 291134

URL: http://llvm.org/viewvc/llvm-project?rev=291134&view=rev
Log:
[CUDA] Add __declspec spellings for CUDA attributes.

Summary: CUDA attributes are spelled __declspec(__foo__) on Windows.

Reviewers: tra

Subscribers: cfe-commits, rnk

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

Added:
cfe/trunk/test/SemaCUDA/attr-declspec.cu
Modified:
cfe/trunk/include/clang/Basic/Attr.td

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=291134&r1=291133&r2=291134&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Thu Jan  5 10:53:04 2017
@@ -601,49 +601,53 @@ def Constructor : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
+// CUDA attributes are spelled __attribute__((attr)) or __declspec(__attr__).
+
 def CUDAConstant : InheritableAttr {
-  let Spellings = [GNU<"constant">];
+  let Spellings = [GNU<"constant">, Declspec<"__constant__">];
   let Subjects = SubjectList<[Var]>;
   let LangOpts = [CUDA];
   let Documentation = [Undocumented];
 }
 
 def CUDACudartBuiltin : IgnoredAttr {
-  let Spellings = [GNU<"cudart_builtin">];
+  let Spellings = [GNU<"cudart_builtin">, Declspec<"__cudart_builtin__">];
   let LangOpts = [CUDA];
 }
 
 def CUDADevice : InheritableAttr {
-  let Spellings = [GNU<"device">];
+  let Spellings = [GNU<"device">, Declspec<"__device__">];
   let Subjects = SubjectList<[Function, Var]>;
   let LangOpts = [CUDA];
   let Documentation = [Undocumented];
 }
 
 def CUDADeviceBuiltin : IgnoredAttr {
-  let Spellings = [GNU<"device_builtin">];
+  let Spellings = [GNU<"device_builtin">, Declspec<"__device_builtin__">];
   let LangOpts = [CUDA];
 }
 
 def CUDADeviceBuiltinSurfaceType : IgnoredAttr {
-  let Spellings = [GNU<"device_builtin_surface_type">];
+  let Spellings = [GNU<"device_builtin_surface_type">,
+   Declspec<"__device_builtin_surface_type__">];
   let LangOpts = [CUDA];
 }
 
 def CUDADeviceBuiltinTextureType : IgnoredAttr {
-  let Spellings = [GNU<"device_builtin_texture_type">];
+  let Spellings = [GNU<"device_builtin_texture_type">,
+   Declspec<"__device_builtin_texture_type__">];
   let LangOpts = [CUDA];
 }
 
 def CUDAGlobal : InheritableAttr {
-  let Spellings = [GNU<"global">];
+  let Spellings = [GNU<"global">, Declspec<"__global__">];
   let Subjects = SubjectList<[Function]>;
   let LangOpts = [CUDA];
   let Documentation = [Undocumented];
 }
 
 def CUDAHost : InheritableAttr {
-  let Spellings = [GNU<"host">];
+  let Spellings = [GNU<"host">, Declspec<"__host__">];
   let Subjects = SubjectList<[Function]>;
   let LangOpts = [CUDA];
   let Documentation = [Undocumented];
@@ -657,7 +661,7 @@ def CUDAInvalidTarget : InheritableAttr
 }
 
 def CUDALaunchBounds : InheritableAttr {
-  let Spellings = [GNU<"launch_bounds">];
+  let Spellings = [GNU<"launch_bounds">, Declspec<"__launch_bounds__">];
   let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>];
   let LangOpts = [CUDA];
   let Subjects = SubjectList<[ObjCMethod, FunctionLike], WarnDiag,
@@ -669,7 +673,7 @@ def CUDALaunchBounds : InheritableAttr {
 }
 
 def CUDAShared : InheritableAttr {
-  let Spellings = [GNU<"shared">];
+  let Spellings = [GNU<"shared">, Declspec<"__shared__">];
   let Subjects = SubjectList<[Var]>;
   let LangOpts = [CUDA];
   let Documentation = [Undocumented];
@@ -1195,6 +1199,8 @@ def NoThrow : InheritableAttr {
 }
 
 def NvWeak : IgnoredAttr {
+  // No Declspec spelling of this attribute; the CUDA headers use
+  // __attribute__((nv_weak)) unconditionally.
   let Spellings = [GNU<"nv_weak">];
   let LangOpts = [CUDA];
 }

Added: cfe/trunk/test/SemaCUDA/attr-declspec.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/attr-declspec.cu?rev=291134&view=auto
==
--- cfe/trunk/test/SemaCUDA/attr-declspec.cu (added)
+++ cfe/trunk/test/SemaCUDA/attr-declspec.cu Thu Jan  5 10:53:04 2017
@@ -0,0 +1,34 @@
+// Test the __declspec spellings of CUDA attributes.
+//
+// RUN: %clang_cc1 -fsyntax-only -fms-extensions -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fms-extensions -fcuda-is-device -verify %s
+// Now pretend that we're compiling a C file. There should be warnings.
+// RUN: %clang_cc1 -DEXPECT_WARNINGS -fms-extensions -fsyntax-only -verify -x 
c %s
+
+#if defined(EXPECT_WARNINGS)
+// expected-warning@+12 {{'__device__' attribute ignored}}
+// expected-warning@+12 {{'__global__' attribute ignored}}
+// expected-warning@+12 {{'__constant__' attribute ignored}}
+// expected-warning@+12 {{'__shared__' attribute ignored}}
+// expected-warning@+12 {{'__host__' attribute ignored}}
+//
+// (Currently we don't for the other attributes. They are implemented with
+// Ign

r291135 - [CUDA] More correctly inherit primitive types from the host during device compilation.

2017-01-05 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  5 10:53:21 2017
New Revision: 291135

URL: http://llvm.org/viewvc/llvm-project?rev=291135&view=rev
Log:
[CUDA] More correctly inherit primitive types from the host during device 
compilation.

Summary:
CUDA lets users share structs between the host and device, so for that
and other reasons, primitive types such as ptrdiff_t should be the same
on both sides of the compilation.

Our code to do this wasn't entirely successful.  In particular, we did a
bunch of work during the NVPTXTargetInfo constructor, only to override
it in the NVPTX{32,64}TargetInfo constructors.  It worked well enough on
Linux and Mac, but Windows is LLP64, which is different enough to break
it.

This patch removes the NVPTX{32,64}TargetInfo classes entirely and fixes
the bug described above.

Reviewers: tra

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/cuda-types.cu

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=291135&r1=291134&r2=291135&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Jan  5 10:53:21 2017
@@ -1751,30 +1751,57 @@ class NVPTXTargetInfo : public TargetInf
   static const char *const GCCRegNames[];
   static const Builtin::Info BuiltinInfo[];
   CudaArch GPU;
+  std::unique_ptr HostTarget;
 
 public:
-  NVPTXTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
+  NVPTXTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts,
+  unsigned TargetPointerWidth)
   : TargetInfo(Triple) {
+assert((TargetPointerWidth == 32 || TargetPointerWidth == 64) &&
+   "NVPTX only supports 32- and 64-bit modes.");
+
 TLSSupported = false;
-LongWidth = LongAlign = 64;
 AddrSpaceMap = &NVPTXAddrSpaceMap;
 UseAddrSpaceMapMangling = true;
+
 // Define available target features
 // These must be defined in sorted order!
 NoAsmVariants = true;
 GPU = CudaArch::SM_20;
 
+if (TargetPointerWidth == 32)
+  resetDataLayout("e-p:32:32-i64:64-v16:16-v32:32-n16:32:64");
+else
+  resetDataLayout("e-i64:64-v16:16-v32:32-n16:32:64");
+
 // If possible, get a TargetInfo for our host triple, so we can match its
 // types.
 llvm::Triple HostTriple(Opts.HostTriple);
-if (HostTriple.isNVPTX())
-  return;
-std::unique_ptr HostTarget(
-AllocateTarget(llvm::Triple(Opts.HostTriple), Opts));
+if (!HostTriple.isNVPTX())
+  HostTarget.reset(AllocateTarget(llvm::Triple(Opts.HostTriple), Opts));
+
+// If no host target, make some guesses about the data layout and return.
 if (!HostTarget) {
+  LongWidth = LongAlign = TargetPointerWidth;
+  PointerWidth = PointerAlign = TargetPointerWidth;
+  switch (TargetPointerWidth) {
+  case 32:
+SizeType = TargetInfo::UnsignedInt;
+PtrDiffType = TargetInfo::SignedInt;
+IntPtrType = TargetInfo::SignedInt;
+break;
+  case 64:
+SizeType = TargetInfo::UnsignedLong;
+PtrDiffType = TargetInfo::SignedLong;
+IntPtrType = TargetInfo::SignedLong;
+break;
+  default:
+llvm_unreachable("TargetPointerWidth must be 32 or 64");
+  }
   return;
 }
 
+// Copy properties from host target.
 PointerWidth = HostTarget->getPointerWidth(/* AddrSpace = */ 0);
 PointerAlign = HostTarget->getPointerAlign(/* AddrSpace = */ 0);
 BoolWidth = HostTarget->getBoolWidth();
@@ -1953,31 +1980,6 @@ ArrayRef NVPTXTargetInfo::
   return llvm::makeArrayRef(GCCRegNames);
 }
 
-class NVPTX32TargetInfo : public NVPTXTargetInfo {
-public:
-  NVPTX32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
-  : NVPTXTargetInfo(Triple, Opts) {
-LongWidth = LongAlign = 32;
-PointerWidth = PointerAlign = 32;
-SizeType = TargetInfo::UnsignedInt;
-PtrDiffType = TargetInfo::SignedInt;
-IntPtrType = TargetInfo::SignedInt;
-resetDataLayout("e-p:32:32-i64:64-v16:16-v32:32-n16:32:64");
-  }
-};
-
-class NVPTX64TargetInfo : public NVPTXTargetInfo {
-public:
-  NVPTX64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
-  : NVPTXTargetInfo(Triple, Opts) {
-PointerWidth = PointerAlign = 64;
-SizeType = TargetInfo::UnsignedLong;
-PtrDiffType = TargetInfo::SignedLong;
-IntPtrType = TargetInfo::SignedLong;
-resetDataLayout("e-i64:64-v16:16-v32:32-n16:32:64");
-  }
-};
-
 static const unsigned AMDGPUAddrSpaceMap[] = {
   1,// opencl_global
   3,// opencl_local
@@ -8735,9 +8737,9 @@ static TargetInfo *AllocateTarget(const
 }
 
   case llvm::Triple::nvptx:
-return new NVPTX32TargetInfo(Triple, Opts);
+return new NVPTXTargetInfo(Triple, Opts, /*TargetPointerWidth=*/32);
   case llvm::Triple::nvpt

[PATCH] D28322: [CUDA] More correctly inherit primitive types from the host during device compilation.

2017-01-05 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291135: [CUDA] More correctly inherit primitive types from 
the host during device… (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D28322?vs=83129&id=83258#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28322

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Preprocessor/cuda-types.cu

Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -1751,30 +1751,57 @@
   static const char *const GCCRegNames[];
   static const Builtin::Info BuiltinInfo[];
   CudaArch GPU;
+  std::unique_ptr HostTarget;
 
 public:
-  NVPTXTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
+  NVPTXTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts,
+  unsigned TargetPointerWidth)
   : TargetInfo(Triple) {
+assert((TargetPointerWidth == 32 || TargetPointerWidth == 64) &&
+   "NVPTX only supports 32- and 64-bit modes.");
+
 TLSSupported = false;
-LongWidth = LongAlign = 64;
 AddrSpaceMap = &NVPTXAddrSpaceMap;
 UseAddrSpaceMapMangling = true;
+
 // Define available target features
 // These must be defined in sorted order!
 NoAsmVariants = true;
 GPU = CudaArch::SM_20;
 
+if (TargetPointerWidth == 32)
+  resetDataLayout("e-p:32:32-i64:64-v16:16-v32:32-n16:32:64");
+else
+  resetDataLayout("e-i64:64-v16:16-v32:32-n16:32:64");
+
 // If possible, get a TargetInfo for our host triple, so we can match its
 // types.
 llvm::Triple HostTriple(Opts.HostTriple);
-if (HostTriple.isNVPTX())
-  return;
-std::unique_ptr HostTarget(
-AllocateTarget(llvm::Triple(Opts.HostTriple), Opts));
+if (!HostTriple.isNVPTX())
+  HostTarget.reset(AllocateTarget(llvm::Triple(Opts.HostTriple), Opts));
+
+// If no host target, make some guesses about the data layout and return.
 if (!HostTarget) {
+  LongWidth = LongAlign = TargetPointerWidth;
+  PointerWidth = PointerAlign = TargetPointerWidth;
+  switch (TargetPointerWidth) {
+  case 32:
+SizeType = TargetInfo::UnsignedInt;
+PtrDiffType = TargetInfo::SignedInt;
+IntPtrType = TargetInfo::SignedInt;
+break;
+  case 64:
+SizeType = TargetInfo::UnsignedLong;
+PtrDiffType = TargetInfo::SignedLong;
+IntPtrType = TargetInfo::SignedLong;
+break;
+  default:
+llvm_unreachable("TargetPointerWidth must be 32 or 64");
+  }
   return;
 }
 
+// Copy properties from host target.
 PointerWidth = HostTarget->getPointerWidth(/* AddrSpace = */ 0);
 PointerAlign = HostTarget->getPointerAlign(/* AddrSpace = */ 0);
 BoolWidth = HostTarget->getBoolWidth();
@@ -1953,31 +1980,6 @@
   return llvm::makeArrayRef(GCCRegNames);
 }
 
-class NVPTX32TargetInfo : public NVPTXTargetInfo {
-public:
-  NVPTX32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
-  : NVPTXTargetInfo(Triple, Opts) {
-LongWidth = LongAlign = 32;
-PointerWidth = PointerAlign = 32;
-SizeType = TargetInfo::UnsignedInt;
-PtrDiffType = TargetInfo::SignedInt;
-IntPtrType = TargetInfo::SignedInt;
-resetDataLayout("e-p:32:32-i64:64-v16:16-v32:32-n16:32:64");
-  }
-};
-
-class NVPTX64TargetInfo : public NVPTXTargetInfo {
-public:
-  NVPTX64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
-  : NVPTXTargetInfo(Triple, Opts) {
-PointerWidth = PointerAlign = 64;
-SizeType = TargetInfo::UnsignedLong;
-PtrDiffType = TargetInfo::SignedLong;
-IntPtrType = TargetInfo::SignedLong;
-resetDataLayout("e-i64:64-v16:16-v32:32-n16:32:64");
-  }
-};
-
 static const unsigned AMDGPUAddrSpaceMap[] = {
   1,// opencl_global
   3,// opencl_local
@@ -8735,9 +8737,9 @@
 }
 
   case llvm::Triple::nvptx:
-return new NVPTX32TargetInfo(Triple, Opts);
+return new NVPTXTargetInfo(Triple, Opts, /*TargetPointerWidth=*/32);
   case llvm::Triple::nvptx64:
-return new NVPTX64TargetInfo(Triple, Opts);
+return new NVPTXTargetInfo(Triple, Opts, /*TargetPointerWidth=*/64);
 
   case llvm::Triple::amdgcn:
   case llvm::Triple::r600:
Index: cfe/trunk/test/Preprocessor/cuda-types.cu
===
--- cfe/trunk/test/Preprocessor/cuda-types.cu
+++ cfe/trunk/test/Preprocessor/cuda-types.cu
@@ -28,3 +28,19 @@
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
 // RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %T/powerpc64-device-defines-filtered
 // RUN: diff %T/powerpc64-host-defines-filtered %T/powerpc64-device-defines-filtered
+
+// RUN: %clang --cuda-host-only -nocudainc -target i386-windows-msvc -x cuda -E -dM -o - /dev/null \
+// RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define 

[PATCH] D28321: [CUDA] Add __declspec spellings for CUDA attributes.

2017-01-05 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291134: [CUDA] Add __declspec spellings for CUDA attributes. 
(authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D28321?vs=83128&id=83257#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28321

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/test/SemaCUDA/attr-declspec.cu

Index: cfe/trunk/test/SemaCUDA/attr-declspec.cu
===
--- cfe/trunk/test/SemaCUDA/attr-declspec.cu
+++ cfe/trunk/test/SemaCUDA/attr-declspec.cu
@@ -0,0 +1,34 @@
+// Test the __declspec spellings of CUDA attributes.
+//
+// RUN: %clang_cc1 -fsyntax-only -fms-extensions -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fms-extensions -fcuda-is-device -verify %s
+// Now pretend that we're compiling a C file. There should be warnings.
+// RUN: %clang_cc1 -DEXPECT_WARNINGS -fms-extensions -fsyntax-only -verify -x c %s
+
+#if defined(EXPECT_WARNINGS)
+// expected-warning@+12 {{'__device__' attribute ignored}}
+// expected-warning@+12 {{'__global__' attribute ignored}}
+// expected-warning@+12 {{'__constant__' attribute ignored}}
+// expected-warning@+12 {{'__shared__' attribute ignored}}
+// expected-warning@+12 {{'__host__' attribute ignored}}
+//
+// (Currently we don't for the other attributes. They are implemented with
+// IgnoredAttr, which is ignored irrespective of any LangOpts.)
+#else
+// expected-no-diagnostics
+#endif
+
+__declspec(__device__) void f_device();
+__declspec(__global__) void f_global();
+__declspec(__constant__) int* g_constant;
+__declspec(__shared__) float *g_shared;
+__declspec(__host__) void f_host();
+__declspec(__device_builtin__) void f_device_builtin();
+typedef __declspec(__device_builtin__) const void *t_device_builtin;
+enum __declspec(__device_builtin__) e_device_builtin {E};
+__declspec(__device_builtin__) int v_device_builtin;
+__declspec(__cudart_builtin__) void f_cudart_builtin();
+__declspec(__device_builtin_surface_type__) unsigned long long surface_var;
+__declspec(__device_builtin_texture_type__) unsigned long long texture_var;
+
+// Note that there's no __declspec spelling of nv_weak.
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -601,49 +601,53 @@
   let Documentation = [Undocumented];
 }
 
+// CUDA attributes are spelled __attribute__((attr)) or __declspec(__attr__).
+
 def CUDAConstant : InheritableAttr {
-  let Spellings = [GNU<"constant">];
+  let Spellings = [GNU<"constant">, Declspec<"__constant__">];
   let Subjects = SubjectList<[Var]>;
   let LangOpts = [CUDA];
   let Documentation = [Undocumented];
 }
 
 def CUDACudartBuiltin : IgnoredAttr {
-  let Spellings = [GNU<"cudart_builtin">];
+  let Spellings = [GNU<"cudart_builtin">, Declspec<"__cudart_builtin__">];
   let LangOpts = [CUDA];
 }
 
 def CUDADevice : InheritableAttr {
-  let Spellings = [GNU<"device">];
+  let Spellings = [GNU<"device">, Declspec<"__device__">];
   let Subjects = SubjectList<[Function, Var]>;
   let LangOpts = [CUDA];
   let Documentation = [Undocumented];
 }
 
 def CUDADeviceBuiltin : IgnoredAttr {
-  let Spellings = [GNU<"device_builtin">];
+  let Spellings = [GNU<"device_builtin">, Declspec<"__device_builtin__">];
   let LangOpts = [CUDA];
 }
 
 def CUDADeviceBuiltinSurfaceType : IgnoredAttr {
-  let Spellings = [GNU<"device_builtin_surface_type">];
+  let Spellings = [GNU<"device_builtin_surface_type">,
+   Declspec<"__device_builtin_surface_type__">];
   let LangOpts = [CUDA];
 }
 
 def CUDADeviceBuiltinTextureType : IgnoredAttr {
-  let Spellings = [GNU<"device_builtin_texture_type">];
+  let Spellings = [GNU<"device_builtin_texture_type">,
+   Declspec<"__device_builtin_texture_type__">];
   let LangOpts = [CUDA];
 }
 
 def CUDAGlobal : InheritableAttr {
-  let Spellings = [GNU<"global">];
+  let Spellings = [GNU<"global">, Declspec<"__global__">];
   let Subjects = SubjectList<[Function]>;
   let LangOpts = [CUDA];
   let Documentation = [Undocumented];
 }
 
 def CUDAHost : InheritableAttr {
-  let Spellings = [GNU<"host">];
+  let Spellings = [GNU<"host">, Declspec<"__host__">];
   let Subjects = SubjectList<[Function]>;
   let LangOpts = [CUDA];
   let Documentation = [Undocumented];
@@ -657,7 +661,7 @@
 }
 
 def CUDALaunchBounds : InheritableAttr {
-  let Spellings = [GNU<"launch_bounds">];
+  let Spellings = [GNU<"launch_bounds">, Declspec<"__launch_bounds__">];
   let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>];
   let LangOpts = [CUDA];
   let Subjects = SubjectList<[ObjCMethod, FunctionLike], WarnDiag,
@@ -669,7 +673,7 @@
 }
 
 def CUDAShared : InheritableAttr {
-  let Spellings = [GNU<"shared">];
+  let Spellings = [GNU<"shared">, Declspec<"__shared__">];
   let Subjects = SubjectList<[Var]>;
   let LangOpt

r291136 - [CUDA] Let NVPTX inherit the host's calling conventions.

2017-01-05 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  5 10:53:38 2017
New Revision: 291136

URL: http://llvm.org/viewvc/llvm-project?rev=291136&view=rev
Log:
[CUDA] Let NVPTX inherit the host's calling conventions.

Summary:
When compiling device code, we may still see host code with explicit
calling conventions.  NVPTX needs to claim that it supports these CCs,
so that (a) we don't raise noisy warnings, and (b) we don't break
existing code which relies on the existence of these CCs when
specializing templates.  (If a CC doesn't exist, clang ignores it, so
two template specializations which are different only insofar as one
specifies a CC are considered identical and therefore are an error if
that CC is not supported.)

Reviewers: tra

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=291136&r1=291135&r2=291136&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Jan  5 10:53:38 2017
@@ -1962,6 +1962,16 @@ public:
 Opts.support("cl_khr_local_int32_base_atomics");
 Opts.support("cl_khr_local_int32_extended_atomics");
   }
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
+// CUDA compilations support all of the host's calling conventions.
+//
+// TODO: We should warn if you apply a non-default CC to anything other 
than
+// a host function.
+if (HostTarget)
+  return HostTarget->checkCallingConvention(CC);
+return CCCR_Warning;
+  }
 };
 
 const Builtin::Info NVPTXTargetInfo::BuiltinInfo[] = {

Added: cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu?rev=291136&view=auto
==
--- cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu (added)
+++ cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu Thu Jan  5 10:53:38 
2017
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++11 -triple i386-windows-msvc \
+// RUN:   -aux-triple nvptx-nvidia-cuda -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -std=c++11 -triple nvptx-nvidia-cuda \
+// RUN:   -aux-triple i386-windows-msvc -fsyntax-only \
+// RUN:   -fcuda-is-device -verify %s
+
+// RUN: %clang_cc1 -std=c++11 -triple nvptx-nvidia-cuda \
+// RUN:   -aux-triple x86_64-linux-gnu -fsyntax-only \
+// RUN:   -fcuda-is-device -verify -verify-ignore-unexpected=note \
+// RUN:   -DEXPECT_ERR %s
+
+// CUDA device code should inherit the host's calling conventions.
+
+template 
+struct Foo;
+
+template 
+struct Foo {};
+
+// On x86_64-linux-gnu, this is a redefinition of the template, because the
+// __fastcall calling convention doesn't exist (and is therefore ignored).
+#ifndef EXPECT_ERR
+// expected-no-diagnostics
+#else
+// expected-error@+4 {{redefinition of 'Foo}}
+// expected-warning@+3 {{calling convention '__fastcall' ignored}}
+#endif
+template 
+struct Foo {};


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


r291137 - [CUDA] Don't define functions that the CUDA headers themselves define on Windows.

2017-01-05 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  5 10:53:55 2017
New Revision: 291137

URL: http://llvm.org/viewvc/llvm-project?rev=291137&view=rev
Log:
[CUDA] Don't define functions that the CUDA headers themselves define on 
Windows.

Reviewers: tra

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/Headers/__clang_cuda_cmath.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_cmath.h?rev=291137&r1=291136&r2=291137&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_cmath.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_cmath.h Thu Jan  5 10:53:55 2017
@@ -72,6 +72,10 @@ __DEVICE__ int fpclassify(double __x) {
 __DEVICE__ float frexp(float __arg, int *__exp) {
   return ::frexpf(__arg, __exp);
 }
+
+// For inscrutable reasons, the CUDA headers define these functions for us on
+// Windows.
+#ifndef _MSC_VER
 __DEVICE__ bool isinf(float __x) { return ::__isinff(__x); }
 __DEVICE__ bool isinf(double __x) { return ::__isinf(__x); }
 __DEVICE__ bool isfinite(float __x) { return ::__finitef(__x); }
@@ -79,6 +83,10 @@ __DEVICE__ bool isfinite(float __x) { re
 // __finitef, does not exist when compiling for MacOS.  __isfinited is 
available
 // everywhere and is just as good.
 __DEVICE__ bool isfinite(double __x) { return ::__isfinited(__x); }
+__DEVICE__ bool isnan(float __x) { return ::__isnanf(__x); }
+__DEVICE__ bool isnan(double __x) { return ::__isnan(__x); }
+#endif
+
 __DEVICE__ bool isgreater(float __x, float __y) {
   return __builtin_isgreater(__x, __y);
 }
@@ -109,8 +117,6 @@ __DEVICE__ bool islessgreater(float __x,
 __DEVICE__ bool islessgreater(double __x, double __y) {
   return __builtin_islessgreater(__x, __y);
 }
-__DEVICE__ bool isnan(float __x) { return ::__isnanf(__x); }
-__DEVICE__ bool isnan(double __x) { return ::__isnan(__x); }
 __DEVICE__ bool isnormal(float __x) { return __builtin_isnormal(__x); }
 __DEVICE__ bool isnormal(double __x) { return __builtin_isnormal(__x); }
 __DEVICE__ bool isunordered(float __x, float __y) {


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


[PATCH] D28324: [CUDA] Don't define functions that the CUDA headers themselves define on Windows.

2017-01-05 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
jlebar marked an inline comment as done.
Closed by commit rL291137: [CUDA] Don't define functions that the CUDA headers 
themselves define on… (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D28324?vs=83132&id=83260#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28324

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


Index: cfe/trunk/lib/Headers/__clang_cuda_cmath.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_cmath.h
+++ cfe/trunk/lib/Headers/__clang_cuda_cmath.h
@@ -72,13 +72,21 @@
 __DEVICE__ float frexp(float __arg, int *__exp) {
   return ::frexpf(__arg, __exp);
 }
+
+// For inscrutable reasons, the CUDA headers define these functions for us on
+// Windows.
+#ifndef _MSC_VER
 __DEVICE__ bool isinf(float __x) { return ::__isinff(__x); }
 __DEVICE__ bool isinf(double __x) { return ::__isinf(__x); }
 __DEVICE__ bool isfinite(float __x) { return ::__finitef(__x); }
 // For inscrutable reasons, __finite(), the double-precision version of
 // __finitef, does not exist when compiling for MacOS.  __isfinited is 
available
 // everywhere and is just as good.
 __DEVICE__ bool isfinite(double __x) { return ::__isfinited(__x); }
+__DEVICE__ bool isnan(float __x) { return ::__isnanf(__x); }
+__DEVICE__ bool isnan(double __x) { return ::__isnan(__x); }
+#endif
+
 __DEVICE__ bool isgreater(float __x, float __y) {
   return __builtin_isgreater(__x, __y);
 }
@@ -109,8 +117,6 @@
 __DEVICE__ bool islessgreater(double __x, double __y) {
   return __builtin_islessgreater(__x, __y);
 }
-__DEVICE__ bool isnan(float __x) { return ::__isnanf(__x); }
-__DEVICE__ bool isnan(double __x) { return ::__isnan(__x); }
 __DEVICE__ bool isnormal(float __x) { return __builtin_isnormal(__x); }
 __DEVICE__ bool isnormal(double __x) { return __builtin_isnormal(__x); }
 __DEVICE__ bool isunordered(float __x, float __y) {


Index: cfe/trunk/lib/Headers/__clang_cuda_cmath.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_cmath.h
+++ cfe/trunk/lib/Headers/__clang_cuda_cmath.h
@@ -72,13 +72,21 @@
 __DEVICE__ float frexp(float __arg, int *__exp) {
   return ::frexpf(__arg, __exp);
 }
+
+// For inscrutable reasons, the CUDA headers define these functions for us on
+// Windows.
+#ifndef _MSC_VER
 __DEVICE__ bool isinf(float __x) { return ::__isinff(__x); }
 __DEVICE__ bool isinf(double __x) { return ::__isinf(__x); }
 __DEVICE__ bool isfinite(float __x) { return ::__finitef(__x); }
 // For inscrutable reasons, __finite(), the double-precision version of
 // __finitef, does not exist when compiling for MacOS.  __isfinited is available
 // everywhere and is just as good.
 __DEVICE__ bool isfinite(double __x) { return ::__isfinited(__x); }
+__DEVICE__ bool isnan(float __x) { return ::__isnanf(__x); }
+__DEVICE__ bool isnan(double __x) { return ::__isnan(__x); }
+#endif
+
 __DEVICE__ bool isgreater(float __x, float __y) {
   return __builtin_isgreater(__x, __y);
 }
@@ -109,8 +117,6 @@
 __DEVICE__ bool islessgreater(double __x, double __y) {
   return __builtin_islessgreater(__x, __y);
 }
-__DEVICE__ bool isnan(float __x) { return ::__isnanf(__x); }
-__DEVICE__ bool isnan(double __x) { return ::__isnan(__x); }
 __DEVICE__ bool isnormal(float __x) { return __builtin_isnormal(__x); }
 __DEVICE__ bool isnormal(double __x) { return __builtin_isnormal(__x); }
 __DEVICE__ bool isunordered(float __x, float __y) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r291138 - [CUDA] Rename keywords used in macro so they don't conflict with MSVC.

2017-01-05 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  5 10:54:11 2017
New Revision: 291138

URL: http://llvm.org/viewvc/llvm-project?rev=291138&view=rev
Log:
[CUDA] Rename keywords used in macro so they don't conflict with MSVC.

Summary:
MSVC seems to use "__in" and "__out" for its own purposes, so we have to
pick different names in this macro.

Reviewers: tra

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h?rev=291138&r1=291137&r2=291138&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h Thu Jan  5 10:54:11 2017
@@ -35,50 +35,50 @@
 
 #pragma push_macro("__MAKE_SHUFFLES")
 #define __MAKE_SHUFFLES(__FnName, __IntIntrinsic, __FloatIntrinsic, __Mask)
\
-  inline __device__ int __FnName(int __in, int __offset,   
\
+  inline __device__ int __FnName(int __val, int __offset,  
\
  int __width = warpSize) { 
\
-return __IntIntrinsic(__in, __offset,  
\
+return __IntIntrinsic(__val, __offset, 
\
   ((warpSize - __width) << 8) | (__Mask)); 
\
   }
\
-  inline __device__ float __FnName(float __in, int __offset,   
\
+  inline __device__ float __FnName(float __val, int __offset,  
\
int __width = warpSize) {   
\
-return __FloatIntrinsic(__in, __offset,
\
+return __FloatIntrinsic(__val, __offset,   
\
 ((warpSize - __width) << 8) | (__Mask));   
\
   }
\
-  inline __device__ unsigned int __FnName(unsigned int __in, int __offset, 
\
+  inline __device__ unsigned int __FnName(unsigned int __val, int __offset,
\
   int __width = warpSize) {
\
 return static_cast(  
\
-::__FnName(static_cast(__in), __offset, __width));
\
+::__FnName(static_cast(__val), __offset, __width));   
\
   }
\
-  inline __device__ long long __FnName(long long __in, int __offset,   
\
+  inline __device__ long long __FnName(long long __val, int __offset,  
\
int __width = warpSize) {   
\
 struct __Bits {
\
   int __a, __b;
\
 }; 
\
-_Static_assert(sizeof(__in) == sizeof(__Bits));
\
+_Static_assert(sizeof(__val) == sizeof(__Bits));   
\
 _Static_assert(sizeof(__Bits) == 2 * sizeof(int)); 
\
 __Bits __tmp;  
\
-memcpy(&__in, &__tmp, sizeof(__in));   
\
+memcpy(&__val, &__tmp, sizeof(__val)); 
\
 __tmp.__a = ::__FnName(__tmp.__a, __offset, __width);  
\
 __tmp.__b = ::__FnName(__tmp.__b, __offset, __width);  
\
-long long __out;   
\
-memcpy(&__out, &__tmp, sizeof(__tmp)); 
\
-return __out;  
\
+long long __ret;   
\
+memcpy(&__ret, &__tmp, sizeof(__tmp)); 
\
+return __ret;  
\
   }
\
   inline __device__ unsigned long long __FnName(   
\
-  unsigned long long __in, int __offset, int __width = warpSize) { 
\
-return static_cast(
\
-::__FnName(static_cast(__in), __offset, __width)); 
\
+  unsigned long long __val, int __offset, int __width = warpSize) {
\
+return static_cast(::__FnName( 
\
+static_cast(__val), __offset, __width));   

[PATCH] D28317: [Windows] Remove functions in intrin.h that are defined in Builtin.def.

2017-01-05 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291128: [Windows] Remove functions in intrin.h that are 
defined in Builtin.def. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D28317?vs=83124&id=83252#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28317

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

Index: cfe/trunk/lib/Headers/intrin.h
===
--- cfe/trunk/lib/Headers/intrin.h
+++ cfe/trunk/lib/Headers/intrin.h
@@ -65,7 +65,6 @@
 void __cpuid(int[4], int);
 static __inline__
 void __cpuidex(int[4], int, int);
-void __debugbreak(void);
 static __inline__
 __int64 __emul(int, int);
 static __inline__
@@ -109,10 +108,6 @@
 void __outdwordstring(unsigned short, unsigned long *, unsigned long);
 void __outword(unsigned short, unsigned short);
 void __outwordstring(unsigned short, unsigned short *, unsigned long);
-static __inline__
-unsigned int __popcnt(unsigned int);
-static __inline__
-unsigned short __popcnt16(unsigned short);
 unsigned long __readcr0(void);
 unsigned long __readcr2(void);
 static __inline__
@@ -124,8 +119,6 @@
 static __inline__
 unsigned char __readfsbyte(unsigned long);
 static __inline__
-unsigned long __readfsdword(unsigned long);
-static __inline__
 unsigned __int64 __readfsqword(unsigned long);
 static __inline__
 unsigned short __readfsword(unsigned long);
@@ -179,108 +172,34 @@
 unsigned char _bittestandreset(long *, long);
 static __inline__
 unsigned char _bittestandset(long *, long);
-unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64);
-unsigned long __cdecl _byteswap_ulong(unsigned long);
-unsigned short __cdecl _byteswap_ushort(unsigned short);
 void __cdecl _disable(void);
 void __cdecl _enable(void);
 long _InterlockedAddLargeStatistic(__int64 volatile *_Addend, long _Value);
-static __inline__
-long _InterlockedAnd(long volatile *_Value, long _Mask);
-static __inline__
-short _InterlockedAnd16(short volatile *_Value, short _Mask);
-static __inline__
-char _InterlockedAnd8(char volatile *_Value, char _Mask);
 unsigned char _interlockedbittestandreset(long volatile *, long);
 static __inline__
 unsigned char _interlockedbittestandset(long volatile *, long);
-static __inline__
-long __cdecl _InterlockedCompareExchange(long volatile *_Destination,
- long _Exchange, long _Comparand);
 long _InterlockedCompareExchange_HLEAcquire(long volatile *, long, long);
 long _InterlockedCompareExchange_HLERelease(long volatile *, long, long);
-static __inline__
-short _InterlockedCompareExchange16(short volatile *_Destination,
-short _Exchange, short _Comparand);
-static __inline__
-__int64 _InterlockedCompareExchange64(__int64 volatile *_Destination,
-  __int64 _Exchange, __int64 _Comparand);
 __int64 _InterlockedcompareExchange64_HLEAcquire(__int64 volatile *, __int64,
  __int64);
 __int64 _InterlockedCompareExchange64_HLERelease(__int64 volatile *, __int64,
  __int64);
-static __inline__
-char _InterlockedCompareExchange8(char volatile *_Destination, char _Exchange,
-  char _Comparand);
 void *_InterlockedCompareExchangePointer_HLEAcquire(void *volatile *, void *,
 void *);
 void *_InterlockedCompareExchangePointer_HLERelease(void *volatile *, void *,
 void *);
-static __inline__
-long __cdecl _InterlockedDecrement(long volatile *_Addend);
-static __inline__
-short _InterlockedDecrement16(short volatile *_Addend);
-long _InterlockedExchange(long volatile *_Target, long _Value);
-static __inline__
-short _InterlockedExchange16(short volatile *_Target, short _Value);
-static __inline__
-char _InterlockedExchange8(char volatile *_Target, char _Value);
-static __inline__
-long __cdecl _InterlockedExchangeAdd(long volatile *_Addend, long _Value);
 long _InterlockedExchangeAdd_HLEAcquire(long volatile *, long);
 long _InterlockedExchangeAdd_HLERelease(long volatile *, long);
-static __inline__
-short _InterlockedExchangeAdd16(short volatile *_Addend, short _Value);
 __int64 _InterlockedExchangeAdd64_HLEAcquire(__int64 volatile *, __int64);
 __int64 _InterlockedExchangeAdd64_HLERelease(__int64 volatile *, __int64);
-static __inline__
-char _InterlockedExchangeAdd8(char volatile *_Addend, char _Value);
-static __inline__
-long __cdecl _InterlockedIncrement(long volatile *_Addend);
-static __inline__
-short _InterlockedIncrement16(short volatile *_Addend);
-static __inline__
-long _InterlockedOr(long volatile *_Value, long _Mask);
-static __inline__
-short _InterlockedOr16(short volatile *_Value, short _Mask);
-static __inline__
-char _InterlockedOr8(char volatile *_Value, char _Mask);
-static __inline__
-long _Inte

[PATCH] D28325: [CUDA] Rename keywords used in macro so they don't conflict with MSVC.

2017-01-05 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291138: [CUDA] Rename keywords used in macro so they don't 
conflict with MSVC. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D28325?vs=83133&id=83261#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28325

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


Index: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
@@ -35,50 +35,50 @@
 
 #pragma push_macro("__MAKE_SHUFFLES")
 #define __MAKE_SHUFFLES(__FnName, __IntIntrinsic, __FloatIntrinsic, __Mask)
\
-  inline __device__ int __FnName(int __in, int __offset,   
\
+  inline __device__ int __FnName(int __val, int __offset,  
\
  int __width = warpSize) { 
\
-return __IntIntrinsic(__in, __offset,  
\
+return __IntIntrinsic(__val, __offset, 
\
   ((warpSize - __width) << 8) | (__Mask)); 
\
   }
\
-  inline __device__ float __FnName(float __in, int __offset,   
\
+  inline __device__ float __FnName(float __val, int __offset,  
\
int __width = warpSize) {   
\
-return __FloatIntrinsic(__in, __offset,
\
+return __FloatIntrinsic(__val, __offset,   
\
 ((warpSize - __width) << 8) | (__Mask));   
\
   }
\
-  inline __device__ unsigned int __FnName(unsigned int __in, int __offset, 
\
+  inline __device__ unsigned int __FnName(unsigned int __val, int __offset,
\
   int __width = warpSize) {
\
 return static_cast(  
\
-::__FnName(static_cast(__in), __offset, __width));
\
+::__FnName(static_cast(__val), __offset, __width));   
\
   }
\
-  inline __device__ long long __FnName(long long __in, int __offset,   
\
+  inline __device__ long long __FnName(long long __val, int __offset,  
\
int __width = warpSize) {   
\
 struct __Bits {
\
   int __a, __b;
\
 }; 
\
-_Static_assert(sizeof(__in) == sizeof(__Bits));
\
+_Static_assert(sizeof(__val) == sizeof(__Bits));   
\
 _Static_assert(sizeof(__Bits) == 2 * sizeof(int)); 
\
 __Bits __tmp;  
\
-memcpy(&__in, &__tmp, sizeof(__in));   
\
+memcpy(&__val, &__tmp, sizeof(__val)); 
\
 __tmp.__a = ::__FnName(__tmp.__a, __offset, __width);  
\
 __tmp.__b = ::__FnName(__tmp.__b, __offset, __width);  
\
-long long __out;   
\
-memcpy(&__out, &__tmp, sizeof(__tmp)); 
\
-return __out;  
\
+long long __ret;   
\
+memcpy(&__ret, &__tmp, sizeof(__tmp)); 
\
+return __ret;  
\
   }
\
   inline __device__ unsigned long long __FnName(   
\
-  unsigned long long __in, int __offset, int __width = warpSize) { 
\
-return static_cast(
\
-::__FnName(static_cast(__in), __offset, __width)); 
\
+  unsigned long long __val, int __offset, int __width = warpSize) {
\
+return static_cast(::__FnName( 
\
+static_cast(__val), __offset, __width));   
\
   }
\
-  inline __device__ double __FnName(double __in, int __offset, 
\
+  inline __device__ double __FnName(double __val, int __offset,
\
   

[PATCH] D28326: [Docs] Update docs to indicate that CUDA compilation is supported on Windows.

2017-01-05 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291139: [Docs] Update docs to indicate that CUDA compilation 
is supported on Windows. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D28326?vs=83134&id=83262#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28326

Files:
  llvm/trunk/docs/CompileCudaWithLLVM.rst


Index: llvm/trunk/docs/CompileCudaWithLLVM.rst
===
--- llvm/trunk/docs/CompileCudaWithLLVM.rst
+++ llvm/trunk/docs/CompileCudaWithLLVM.rst
@@ -35,8 +35,8 @@
 
 You will need CUDA 7.0, 7.5, or 8.0 to compile with clang.
 
-CUDA compilation is supported on Linux, and on MacOS as of -XX-XX.  Windows
-support is planned but not yet in place.
+CUDA compilation is supported on Linux, on MacOS as of 2016-11-18, and on
+Windows as of 2017-01-05.
 
 Invoking clang
 --


Index: llvm/trunk/docs/CompileCudaWithLLVM.rst
===
--- llvm/trunk/docs/CompileCudaWithLLVM.rst
+++ llvm/trunk/docs/CompileCudaWithLLVM.rst
@@ -35,8 +35,8 @@
 
 You will need CUDA 7.0, 7.5, or 8.0 to compile with clang.
 
-CUDA compilation is supported on Linux, and on MacOS as of -XX-XX.  Windows
-support is planned but not yet in place.
+CUDA compilation is supported on Linux, on MacOS as of 2016-11-18, and on
+Windows as of 2017-01-05.
 
 Invoking clang
 --
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28323: [CUDA] Let NVPTX inherit the host's calling conventions.

2017-01-05 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291136: [CUDA] Let NVPTX inherit the host's calling 
conventions. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D28323?vs=83130&id=83259#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28323

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu


Index: cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu
===
--- cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu
+++ cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++11 -triple i386-windows-msvc \
+// RUN:   -aux-triple nvptx-nvidia-cuda -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -std=c++11 -triple nvptx-nvidia-cuda \
+// RUN:   -aux-triple i386-windows-msvc -fsyntax-only \
+// RUN:   -fcuda-is-device -verify %s
+
+// RUN: %clang_cc1 -std=c++11 -triple nvptx-nvidia-cuda \
+// RUN:   -aux-triple x86_64-linux-gnu -fsyntax-only \
+// RUN:   -fcuda-is-device -verify -verify-ignore-unexpected=note \
+// RUN:   -DEXPECT_ERR %s
+
+// CUDA device code should inherit the host's calling conventions.
+
+template 
+struct Foo;
+
+template 
+struct Foo {};
+
+// On x86_64-linux-gnu, this is a redefinition of the template, because the
+// __fastcall calling convention doesn't exist (and is therefore ignored).
+#ifndef EXPECT_ERR
+// expected-no-diagnostics
+#else
+// expected-error@+4 {{redefinition of 'Foo}}
+// expected-warning@+3 {{calling convention '__fastcall' ignored}}
+#endif
+template 
+struct Foo {};
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -1962,6 +1962,16 @@
 Opts.support("cl_khr_local_int32_base_atomics");
 Opts.support("cl_khr_local_int32_extended_atomics");
   }
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
+// CUDA compilations support all of the host's calling conventions.
+//
+// TODO: We should warn if you apply a non-default CC to anything other 
than
+// a host function.
+if (HostTarget)
+  return HostTarget->checkCallingConvention(CC);
+return CCCR_Warning;
+  }
 };
 
 const Builtin::Info NVPTXTargetInfo::BuiltinInfo[] = {


Index: cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu
===
--- cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu
+++ cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++11 -triple i386-windows-msvc \
+// RUN:   -aux-triple nvptx-nvidia-cuda -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -std=c++11 -triple nvptx-nvidia-cuda \
+// RUN:   -aux-triple i386-windows-msvc -fsyntax-only \
+// RUN:   -fcuda-is-device -verify %s
+
+// RUN: %clang_cc1 -std=c++11 -triple nvptx-nvidia-cuda \
+// RUN:   -aux-triple x86_64-linux-gnu -fsyntax-only \
+// RUN:   -fcuda-is-device -verify -verify-ignore-unexpected=note \
+// RUN:   -DEXPECT_ERR %s
+
+// CUDA device code should inherit the host's calling conventions.
+
+template 
+struct Foo;
+
+template 
+struct Foo {};
+
+// On x86_64-linux-gnu, this is a redefinition of the template, because the
+// __fastcall calling convention doesn't exist (and is therefore ignored).
+#ifndef EXPECT_ERR
+// expected-no-diagnostics
+#else
+// expected-error@+4 {{redefinition of 'Foo}}
+// expected-warning@+3 {{calling convention '__fastcall' ignored}}
+#endif
+template 
+struct Foo {};
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -1962,6 +1962,16 @@
 Opts.support("cl_khr_local_int32_base_atomics");
 Opts.support("cl_khr_local_int32_extended_atomics");
   }
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
+// CUDA compilations support all of the host's calling conventions.
+//
+// TODO: We should warn if you apply a non-default CC to anything other than
+// a host function.
+if (HostTarget)
+  return HostTarget->checkCallingConvention(CC);
+return CCCR_Warning;
+  }
 };
 
 const Builtin::Info NVPTXTargetInfo::BuiltinInfo[] = {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r291142 - test: add a requires registered target

2017-01-05 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Jan  5 11:09:20 2017
New Revision: 291142

URL: http://llvm.org/viewvc/llvm-project?rev=291142&view=rev
Log:
test: add a requires registered target

It seems that the ARM buildbots do not include x86 support.  However,
other x86 targets do not support the ARM target.  Use a x86 triple and
require the registered target.

Modified:
cfe/trunk/test/CodeGen/inline-asm-inclusion.c

Modified: cfe/trunk/test/CodeGen/inline-asm-inclusion.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/inline-asm-inclusion.c?rev=291142&r1=291141&r2=291142&view=diff
==
--- cfe/trunk/test/CodeGen/inline-asm-inclusion.c (original)
+++ cfe/trunk/test/CodeGen/inline-asm-inclusion.c Thu Jan  5 11:09:20 2017
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple i686--- -I %p/include -S -o - %s | FileCheck %s
+// REQUIRES: x86-registered-target
 
 __asm__(".include \"module.x\"");
 void function(void) {


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


[PATCH] D28131: [libcxx] Fix PR31402: map::__find_equal_key has undefined behavior.

2017-01-05 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: include/__tree:1400
 __parent_pointer& __parent, const key_type& __v);
+// FIXME: Make this function const qualified. Unfortunetly doing so
+// breaks existing code which uses non-const callable comparators.

Didn't we address this in http://wg21.link/LWG2542 ?



https://reviews.llvm.org/D28131



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


[PATCH] D28362: [ThinLTO] Optionally ignore empty index file

2017-01-05 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
tejohnson added a reviewer: mehdi_amini.
tejohnson added a subscriber: cfe-commits.

In order to simplify distributed build system integration, where actions
may be scheduled before the Thin Link which determines the list of
objects selected by the linker. The gold plugin currently will emit
0-sized index files for objects not selected by the link, to enable
checking for expected output files by the build system. If the build
system then schedules a backend action for these bitcode files, we want
to be able to fall back to normal compilation instead of failing.
Fallback is enabled under an option with this patch (I am investigating
whether this can be addressed in our build system, but that is a longer
term fix and so this enables a workaround in the meantime).


https://reviews.llvm.org/D28362

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/thinlto_backend.ll


Index: test/CodeGen/thinlto_backend.ll
===
--- test/CodeGen/thinlto_backend.ll
+++ test/CodeGen/thinlto_backend.ll
@@ -12,6 +12,11 @@
 ; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=bad.thinlto.bc 2>&1 
| FileCheck %s -check-prefix=CHECK-ERROR1
 ; CHECK-ERROR1: Error loading index file 'bad.thinlto.bc'
 
+; Ensure we ignore empty index file under -ignore-empty-index-file
+; RUN: touch %t4.thinlto.bc
+; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=%t4.thinlto.bc 
-ignore-empty-index-file 2>&1 | FileCheck %s -check-prefix=CHECK-NOERROR
+; CHECK-NOERROR-NOT: Error loading index file 'bad.thinlto.bc'
+
 ; Ensure f2 was imported
 ; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t3.o -x ir %t1.o -c 
-fthinlto-index=%t.thinlto.bc
 ; RUN: llvm-nm %t3.o | FileCheck --check-prefix=CHECK-OBJ %s
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -36,6 +36,7 @@
 #include "llvm/Object/ModuleSummaryIndexObjectFile.h"
 #include "llvm/Passes/PassBuilder.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/TargetRegistry.h"
@@ -57,6 +58,12 @@
 using namespace clang;
 using namespace llvm;
 
+static llvm::cl::opt IgnoreEmptyThinLTOIndexFile(
+"ignore-empty-index-file", llvm::cl::ZeroOrMore,
+llvm::cl::desc(
+"Ignore an empty index file and perform non-ThinLTO compilation"),
+llvm::cl::init(false));
+
 namespace {
 
 class EmitAssemblyHelper {
@@ -935,8 +942,16 @@
   Module *M, BackendAction Action,
   std::unique_ptr OS) {
   if (!CGOpts.ThinLTOIndexFile.empty()) {
-runThinLTOBackend(CGOpts, M, std::move(OS));
-return;
+bool DoThinLTOBackend = true;
+if (IgnoreEmptyThinLTOIndexFile) {
+  uint64_t IndexFileSize;
+  llvm::sys::fs::file_size(CGOpts.ThinLTOIndexFile, IndexFileSize);
+  DoThinLTOBackend = IndexFileSize > 0;
+}
+if (DoThinLTOBackend) {
+  runThinLTOBackend(CGOpts, M, std::move(OS));
+  return;
+}
   }
 
   EmitAssemblyHelper AsmHelper(Diags, CGOpts, TOpts, LOpts, M);


Index: test/CodeGen/thinlto_backend.ll
===
--- test/CodeGen/thinlto_backend.ll
+++ test/CodeGen/thinlto_backend.ll
@@ -12,6 +12,11 @@
 ; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=bad.thinlto.bc 2>&1 | FileCheck %s -check-prefix=CHECK-ERROR1
 ; CHECK-ERROR1: Error loading index file 'bad.thinlto.bc'
 
+; Ensure we ignore empty index file under -ignore-empty-index-file
+; RUN: touch %t4.thinlto.bc
+; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=%t4.thinlto.bc -ignore-empty-index-file 2>&1 | FileCheck %s -check-prefix=CHECK-NOERROR
+; CHECK-NOERROR-NOT: Error loading index file 'bad.thinlto.bc'
+
 ; Ensure f2 was imported
 ; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t3.o -x ir %t1.o -c -fthinlto-index=%t.thinlto.bc
 ; RUN: llvm-nm %t3.o | FileCheck --check-prefix=CHECK-OBJ %s
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -36,6 +36,7 @@
 #include "llvm/Object/ModuleSummaryIndexObjectFile.h"
 #include "llvm/Passes/PassBuilder.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/TargetRegistry.h"
@@ -57,6 +58,12 @@
 using namespace clang;
 using namespace llvm;
 
+static llvm::cl::opt IgnoreEmptyThinLTOIndexFile(
+"ignore-empty-index-file", llvm::cl::ZeroOrMore,
+llvm::cl::desc(
+"Ignore an empty index file and perform non-ThinLTO compilation"),
+llvm::cl::init(false));
+
 namespace {
 
 class EmitAssemblyHelper {
@@ -935,8 +94

[PATCH] D28348: Taught the analyzer about Glib API to check Memory-leak

2017-01-05 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

Thanks for the patch!

Could you, please, resubmit the patch with context as described here 
http://llvm.org/docs/Phabricator.html
Also, please, add tests. See test/Analysis/ for examples.


Repository:
  rL LLVM

https://reviews.llvm.org/D28348



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


r291143 - Migrate PathDiagnosticPiece to std::shared_ptr

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 11:26:53 2017
New Revision: 291143

URL: http://llvm.org/viewvc/llvm-project?rev=291143&view=rev
Log:
Migrate PathDiagnosticPiece to std::shared_ptr

Simplifies and makes explicit the memory ownership model rather than
implicitly passing/acquiring ownership.

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h?rev=291143&r1=291142&r2=291143&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Thu 
Jan  5 11:26:53 2017
@@ -66,8 +66,7 @@ public:
   typedef SmallVector, 8> VisitorList;
   typedef VisitorList::iterator visitor_iterator;
   typedef SmallVector ExtraTextList;
-  typedef SmallVector, 4>
-  NoteList;
+  typedef SmallVector, 4> NoteList;
 
 protected:
   friend class BugReporter;
@@ -268,12 +267,12 @@ public:
   /// the extra note should appear.
   void addNote(StringRef Msg, const PathDiagnosticLocation &Pos,
ArrayRef Ranges) {
-PathDiagnosticNotePiece *P = new PathDiagnosticNotePiece(Pos, Msg);
+auto P = std::make_shared(Pos, Msg);
 
 for (const auto &R : Ranges)
   P->addRange(R);
 
-Notes.push_back(P);
+Notes.push_back(std::move(P));
   }
 
   // FIXME: Instead of making an override, we could have default-initialized

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h?rev=291143&r1=291142&r2=291143&view=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h 
Thu Jan  5 11:26:53 2017
@@ -59,10 +59,9 @@ public:
   ///
   /// The last parameter can be used to register a new visitor with the given
   /// BugReport while processing a node.
-  virtual PathDiagnosticPiece *VisitNode(const ExplodedNode *Succ,
- const ExplodedNode *Pred,
- BugReporterContext &BRC,
- BugReport &BR) = 0;
+  virtual std::shared_ptr
+  VisitNode(const ExplodedNode *Succ, const ExplodedNode *Pred,
+BugReporterContext &BRC, BugReport &BR) = 0;
 
   /// \brief Provide custom definition for the final diagnostic piece on the
   /// path - the piece, which is displayed before the path is expanded.
@@ -121,10 +120,10 @@ public:
 
   void Profile(llvm::FoldingSetNodeID &ID) const override;
 
-  PathDiagnosticPiece *VisitNode(const ExplodedNode *N,
- const ExplodedNode *PrevN,
- BugReporterContext &BRC,
- BugReport &BR) override;
+  std::shared_ptr VisitNode(const ExplodedNode *N,
+ const ExplodedNode *PrevN,
+ BugReporterContext &BRC,
+ BugReport &BR) override;
 };
 
 class TrackConstraintBRVisitor final
@@ -150,10 +149,10 @@ public:
   /// to make all PathDiagnosticPieces created by this visitor.
   static const char *getTag();
 
-  PathDiagnosticPiece *VisitNode(const ExplodedNode *N,
-

[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2017-01-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:34
+  // a tag declaration (e.g. struct, class etc.):
+  // class A { } Object1, Object2;  <-- won't be matched
+  Finder->addMatcher(

firolino wrote:
> aaron.ballman wrote:
> > firolino wrote:
> > > aaron.ballman wrote:
> > > > firolino wrote:
> > > > > aaron.ballman wrote:
> > > > > > firolino wrote:
> > > > > > > firolino wrote:
> > > > > > > > firolino wrote:
> > > > > > > > > firolino wrote:
> > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > firolino wrote:
> > > > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > > > Why do we not want to match this?
> > > > > > > > > > > > If we decide, whether we transform 
> > > > > > > > > > > > ```
> > > > > > > > > > > > class A { 
> > > > > > > > > > > > } Object1, Object2;
> > > > > > > > > > > > ``` 
> > > > > > > > > > > > to
> > > > > > > > > > > > ```
> > > > > > > > > > > > class A { 
> > > > > > > > > > > > } Object1, 
> > > > > > > > > > > > Object2;
> > > > > > > > > > > > ``` 
> > > > > > > > > > > > or
> > > > > > > > > > > > ```
> > > > > > > > > > > > class A { 
> > > > > > > > > > > > } 
> > > > > > > > > > > > Object1, 
> > > > > > > > > > > > Object2;
> > > > > > > > > > > > ``` 
> > > > > > > > > > > > I might consider adding support for it. Moreover, this 
> > > > > > > > > > > > kind of definition is usually seen globally and I don't 
> > > > > > > > > > > > know how to handle globals yet. See 
> > > > > > > > > > > > http://lists.llvm.org/pipermail/cfe-dev/2015-November/046262.html
> > > > > > > > > > > I think this should be handled. It can be handled in 
> > > > > > > > > > > either of the forms you show, or by saying:
> > > > > > > > > > > ```
> > > > > > > > > > > A Object1;
> > > > > > > > > > > A Object2;
> > > > > > > > > > > ```
> > > > > > > > > > > If all of these turn out to be a problem, we can still 
> > > > > > > > > > > diagnose without providing a fixit.
> > > > > > > > > > > 
> > > > > > > > > > > As for globals in general, they can be handled in a 
> > > > > > > > > > > separate patch once we figure out the declaration 
> > > > > > > > > > > grouping.
> > > > > > > > > > OK. I will try to split the object definition from the 
> > > > > > > > > > class definition, as you have suggested. Thus, I can kick 
> > > > > > > > > > out the tagDecl-matcher as well. If there is no easy way to 
> > > > > > > > > > do this, it will be reported anyway but without a fixit.
> > > > > > > > > > 
> > > > > > > > > > Note for me: Update documentation!
> > > > > > > > > What about
> > > > > > > > > ```
> > > > > > > > > struct S {
> > > > > > > > > } S1;
> > > > > > > > > ```
> > > > > > > > > I would like to report this too, since two names are being 
> > > > > > > > > declared here. `S` and `S1`. What do you think?
> > > > > > > > ```
> > > > > > > > struct {
> > > > > > > > } nn1, nn2;
> > > > > > > > ```
> > > > > > > > Shall we ignore anonymous definitions?
> > > > > > > To be more precise: Warn and provide a fixit for `struct S {} 
> > > > > > > S1`. Only warn for `struct {} nn1, nn2`.
> > > > > > > What about
> > > > > > > 
> > > > > > > ```
> > > > > > > struct S {
> > > > > > > } S1;
> > > > > > > ```
> > > > > > > I would like to report this too, since two names are being 
> > > > > > > declared here. S and S1. What do you think?
> > > > > > 
> > > > > > I don't think that this should be diagnosed. For one, this is a 
> > > > > > relatively common pattern (arguably more common than `struct S { } 
> > > > > > S1, S2;`), but also, it names two very distinct entities (a type 
> > > > > > and a variable).
> > > > > > 
> > > > > > > ```
> > > > > > > struct {
> > > > > > > } nn1, nn2;
> > > > > > >```
> > > > > > > Shall we ignore anonymous definitions?
> > > > > > 
> > > > > > Yes, we basically have to.
> > > > > > 
> > > > > Transforming
> > > > > ```
> > > > > typedef struct X { int t; } X, Y;
> > > > > ```
> > > > > to
> > > > > ```
> > > > > typedef struct X { int t; };
> > > > > typedef X X;
> > > > > typedef X Y;
> > > > > ```
> > > > > will be valid, but looks odd.
> > > > I am on the fence about this transformation -- it does not declare new 
> > > > objects, but instead declares new types. A very common pattern in some 
> > > > libraries (such as the Win32 SDK) is to declare:
> > > > ```
> > > > typedef struct Blah {
> > > > 
> > > > } Blah, *PBlah, **PPBlah;
> > > > ```
> > > > Because of that pattern, diagnosing the above typedef is likely to be 
> > > > very chatty in some projects, and I don't know that the fixit provides 
> > > > much real benefit for types.
> > > > 
> > > > At least for the CERT DCL04-C version of this rule, that code should 
> > > > not be flagged. Do you think any of the variations of this check should 
> > > > flag it?
> > > Maybe we should reconsider where to split and where not. The original 
> > > idea was to minimize confusion on code like
>

[PATCH] D28365: [Driver] Updated for Visual Studio 2017

2017-01-05 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood created this revision.
hamzasood added reviewers: rnk, ruiu, hans.
hamzasood added a subscriber: cfe-commits.

The patch updates the MSVC ToolChain for the changes made in Visual Studio 2017 
(https://blogs.msdn.microsoft.com/vcblog/2016/10/07/compiler-tools-layout-in-visual-studio-15/).
Other notable changes:

- Path handling code has been centralised to make potential future changes less 
painful.
- A compiler error is emitted if the driver is unable to locate a usable MSVC 
toolchain. (Previously it'd fail with a cryptic error such as "link.exe is not 
executable")
- Support for the new Setup Config Server 

 API has been added, albeit block commented out with a preprocessor 
conditional. This can probably be re-evaluated when the API is officially 
released (it's currently at the RC stage), but it's left in to make it easy for 
anyone familiar with the API to give it a go with Clang.

Patch by Hamza Sood.


https://reviews.llvm.org/D28365

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/MSVCToolChain.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -10799,16 +10799,10 @@
   const char *Exe,
   const char *ClangProgramPath) {
   const auto &MSVC = static_cast(TC);
-  std::string visualStudioBinDir;
-  if (MSVC.getVisualStudioBinariesFolder(ClangProgramPath,
- visualStudioBinDir)) {
-SmallString<128> FilePath(visualStudioBinDir);
-llvm::sys::path::append(FilePath, Exe);
-if (llvm::sys::fs::can_execute(FilePath.c_str()))
-  return FilePath.str();
-  }
-
-  return Exe;
+  SmallString<128> FilePath(MSVC.getSubDirectoryPath(toolchains::MSVCToolChain
+ ::SubDirectoryType::Bin));
+  llvm::sys::path::append(FilePath, Exe);
+  return (llvm::sys::fs::can_execute(FilePath) ? FilePath.str() : Exe);
 }
 
 void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA,
@@ -10833,33 +10827,17 @@
 // did not run vcvarsall), try to build a consistent link environment.  If
 // the environment variable is set however, assume the user knows what
 // they're doing.
-std::string VisualStudioDir;
 const auto &MSVC = static_cast(TC);
-if (MSVC.getVisualStudioInstallDir(VisualStudioDir)) {
-  SmallString<128> LibDir(VisualStudioDir);
-  llvm::sys::path::append(LibDir, "VC", "lib");
-  switch (MSVC.getArch()) {
-  case llvm::Triple::x86:
-// x86 just puts the libraries directly in lib
-break;
-  case llvm::Triple::x86_64:
-llvm::sys::path::append(LibDir, "amd64");
-break;
-  case llvm::Triple::arm:
-llvm::sys::path::append(LibDir, "arm");
-break;
-  default:
-break;
-  }
-  CmdArgs.push_back(
-  Args.MakeArgString(std::string("-libpath:") + LibDir.c_str()));
+CmdArgs.push_back(Args.MakeArgString(
+  std::string("-libpath:")
+  + MSVC.getSubDirectoryPath(toolchains::MSVCToolChain
+ ::SubDirectoryType::Lib)));
 
-  if (MSVC.useUniversalCRT(VisualStudioDir)) {
-std::string UniversalCRTLibPath;
-if (MSVC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
-  CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") +
-   UniversalCRTLibPath));
-  }
+if (MSVC.useUniversalCRT()) {
+  std::string UniversalCRTLibPath;
+  if (MSVC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
+CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:")
+ + UniversalCRTLibPath));
 }
 
 std::string WindowsSdkLibPath;
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -1140,6 +1140,13 @@
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
 
+  enum class SubDirectoryType {
+Bin,
+Include,
+Lib,
+  };
+  std::string getSubDirectoryPath(SubDirectoryType Type) const;
+
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
 llvm::opt::ArgStringList &CC1Args) const override;
@@ -1147,17 +1154,10 @@
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
 
-  bool getWindowsSDKDir(std::string &path, int &major,
-std::string &windowsSDKIncludeVersion,
-std::string &windowsSDKLibVersion) const;
   bool getWindowsSDKLibraryPath(std:

Re: Fix for Visual Studio 2017

2017-01-05 Thread Hamza Sood via cfe-commits
I’ve submitted an updated version via Phabricator 
(https://reviews.llvm.org/D28365 ), so this 
one can be ignored.___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28330: [analyzer] Fix false positives in Keychain API checker

2017-01-05 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

I did not think of solution #1! It's definitely better than the pattern 
matching I've added here. However, this checker fires so infrequently, that I 
do not think it's worth investing more time into perfecting it.

I suspect the solution #2 is what this checker was trying to use to begin with. 
It marks the return symbol as dependent on the allocated symbol by calling:

  C.getSymbolManager().addSymbolDependency(V, RetStatusSymbol);

However, addSymbolDependency only worked for isLive() and not for !isDead(). 
Would be good to investigate this further as other checkers such as malloc also 
use addSymbolDependency.


https://reviews.llvm.org/D28330



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


[libcxx] r291145 - thread_support: split out {,non-}recursive mutex

2017-01-05 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Jan  5 11:54:45 2017
New Revision: 291145

URL: http://llvm.org/viewvc/llvm-project?rev=291145&view=rev
Log:
thread_support: split out {,non-}recursive mutex

Split out the recursive and non-recursive mutex.  This split is needed
for platforms which may use differing types for the two mutex (e.g.
Win32 threads).

Modified:
libcxx/trunk/include/__threading_support
libcxx/trunk/include/mutex
libcxx/trunk/src/mutex.cpp

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=291145&r1=291144&r2=291145&view=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Thu Jan  5 11:54:45 2017
@@ -63,6 +63,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 typedef pthread_mutex_t __libcpp_mutex_t;
 #define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
 
+typedef pthread_mutex_t __libcpp_recursive_mutex_t;
+
 // Condition Variable
 typedef pthread_cond_t __libcpp_condvar_t;
 #define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
@@ -83,7 +85,19 @@ typedef pthread_key_t __libcpp_tls_key;
 
 // Mutex
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m);
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m);
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m);
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m);
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m);
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_mutex_lock(__libcpp_mutex_t *__m);
@@ -164,7 +178,7 @@ int __libcpp_tls_set(__libcpp_tls_key __
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
 defined(_LIBCPP_BUILDING_THREAD_API_EXTERNAL_PTHREAD)
 
-int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m)
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
 {
   pthread_mutexattr_t attr;
   int __ec = pthread_mutexattr_init(&attr);
@@ -188,6 +202,26 @@ int __libcpp_recursive_mutex_init(__libc
   return 0;
 }
 
+int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
+{
+  return pthread_mutex_lock(__m);
+}
+
+int __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
+{
+  return pthread_mutex_trylock(__m);
+}
+
+int __libcpp_recursive_mutex_unlock(__libcpp_mutex_t *__m)
+{
+  return pthread_mutex_unlock(__m);
+}
+
+int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m)
+{
+  return pthread_mutex_destroy(__m);
+}
+
 int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
 {
   return pthread_mutex_lock(__m);

Modified: libcxx/trunk/include/mutex
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/mutex?rev=291145&r1=291144&r2=291145&view=diff
==
--- libcxx/trunk/include/mutex (original)
+++ libcxx/trunk/include/mutex Thu Jan  5 11:54:45 2017
@@ -206,7 +206,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 class _LIBCPP_TYPE_VIS recursive_mutex
 {
-__libcpp_mutex_t __m_;
+__libcpp_recursive_mutex_t __m_;
 
 public:
  recursive_mutex();
@@ -221,7 +221,8 @@ public:
 bool try_lock() _NOEXCEPT;
 void unlock()  _NOEXCEPT;
 
-typedef __libcpp_mutex_t* native_handle_type;
+typedef __libcpp_recursive_mutex_t* native_handle_type;
+
 _LIBCPP_INLINE_VISIBILITY
 native_handle_type native_handle() {return &__m_;}
 };

Modified: libcxx/trunk/src/mutex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/mutex.cpp?rev=291145&r1=291144&r2=291145&view=diff
==
--- libcxx/trunk/src/mutex.cpp (original)
+++ libcxx/trunk/src/mutex.cpp Thu Jan  5 11:54:45 2017
@@ -59,7 +59,7 @@ recursive_mutex::recursive_mutex()
 
 recursive_mutex::~recursive_mutex()
 {
-int e = __libcpp_mutex_destroy(&__m_);
+int e = __libcpp_recursive_mutex_destroy(&__m_);
 (void)e;
 assert(e == 0);
 }
@@ -67,7 +67,7 @@ recursive_mutex::~recursive_mutex()
 void
 recursive_mutex::lock()
 {
-int ec = __libcpp_mutex_lock(&__m_);
+int ec = __libcpp_recursive_mutex_lock(&__m_);
 if (ec)
 __throw_system_error(ec, "recursive_mutex lock failed");
 }
@@ -75,7 +75,7 @@ recursive_mutex::lock()
 void
 recursive_mutex::unlock() _NOEXCEPT
 {
-int e = __libcpp_mutex_unlock(&__m_);
+int e = __libcpp_recursive_mutex_unlock(&__m_);
 (void)e;
 assert(e == 0);
 }
@@ -83,7 +83,7 @@ recursive_mutex::unlock() _NOEXCEPT
 bool
 recursive_mutex::try_lock() _NOEXCEPT
 {
-return __libcpp_mutex_trylock(&__m_) == 0;
+return __libcpp_recursive_mutex_trylock(&__m_) == 0;
 }
 
 // timed_mutex


_

[PATCH] D28338: thread_support: split out {,non-}recursive mutex

2017-01-05 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd closed this revision.
compnerd added a comment.

SVN r291145


Repository:
  rL LLVM

https://reviews.llvm.org/D28338



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


r291148 - Typo

2017-01-05 Thread Joerg Sonnenberger via cfe-commits
Author: joerg
Date: Thu Jan  5 11:59:44 2017
New Revision: 291148

URL: http://llvm.org/viewvc/llvm-project?rev=291148&view=rev
Log:
Typo

Modified:
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=291148&r1=291147&r2=291148&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Thu Jan  5 11:59:44 2017
@@ -541,8 +541,8 @@ TEST_F(FormatTestJS, FunctionLiterals) {
"  foo();\n"
"  bar();\n"
"},\n"
-   "this, arg1IsReallyLongAndNeeedsLineBreaks,\n"
-   "arg3IsReallyLongAndNeeedsLineBreaks);");
+   "this, arg1IsReallyLongAndNeedsLineBreaks,\n"
+   "arg3IsReallyLongAndNeedsLineBreaks);");
   verifyFormat("var closure = goog.bind(function() {  // comment\n"
"  foo();\n"
"  bar();\n"


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


[PATCH] D28220: provide Win32 native threading

2017-01-05 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd marked an inline comment as done.
compnerd added inline comments.



Comment at: include/__threading_support:474
+  
system_clock::time_point(duration_cast(duration));
+  auto timeout_ms = duration_cast(abstime - system_clock::now());
+

halyavin wrote:
> Since negative timeouts can't be avoided, we must make sure that 
> timeout_ms.count() is at least zero.
Good point.  I suppose that the assert takes care of that though.



Comment at: include/__threading_support:476
+
+  _LIBCPP_ASSERT(timeout_ms.count() > INFINITE && "timeout duration overflow");
+  if (!SleepConditionVariableSRW(__cv, __m, timeout_ms.count(), 0))

halyavin wrote:
> It is >= INFINITE. _LIBCPP_ASSERT has 2 arguments and supports error message 
> out of the box.
Shouldnt this be, `timeout_ms.count() > 0` which implicitly ensures that it is 
not `INFINITE` (-1)?


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



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


[PATCH] D27424: Add the diagnose_if attribute to clang.

2017-01-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D27424#636496, @george.burgess.iv wrote:

> Do we have a page that details when we should/shouldn't use `auto`? I was 
> under the impression that it was preferred only in cases where the type's 
> spelled out (e.g. `cast`, ...). (To be clear, I'm happy to use it in 
> loops, too; I'd just like to know if we have guidelines about it. :) )


We do: 
http://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable

Btw, there's a question in there about late parsing that Phab won't let me 
delete, feel free to ignore it. ;-)




Comment at: include/clang/Basic/Attr.td:1584
+def DiagnoseIf : InheritableAttr {
+  let Spellings = [GNU<"diagnose_if">];
+  let Subjects = SubjectList<[Function]>;

george.burgess.iv wrote:
> aaron.ballman wrote:
> > I think this should also have a C++ spelling under the clang namespace.
> Agreed. Though, it looks like that would requires us teaching the parser how 
> to late-parse c++11 attrs if we wanted to do it properly. Given the size of 
> this patch, I think that can be done as a follow-up.
That seems reasonable to me.



Comment at: include/clang/Sema/Sema.h:2616
+  DiagnoseIfAttr *
+  checkArgDependentDiagnoseIf(FunctionDecl *Function, ArrayRef Args,
+  SmallVectorImpl &Nonfatal,

george.burgess.iv wrote:
> aaron.ballman wrote:
> > Can this (and the other new functions) accept the `FunctionDecl` as a 
> > `const FunctionDecl *` instead?
> Not easily, unless you'd prefer to see `const` here and a `const_cast` or two 
> in `checkArgDependentDiagnoseIf` over what we have now. I have no preference, 
> so if you would prefer to see that, I'm happy to do it.
> 
> If `ExprResult` and initialization routines like 
> `Sema::PerformCopyInitialization` were happy to take a `const Expr *`, this 
> would be a different story :)
That sounds like more churn than it's worth, to me. It'd be nice if we were 
better about const-correctness, but that's not this patch's problem to solve. 
;-)



Comment at: lib/AST/ExprConstant.cpp:10371
+assert(MD && "Don't provide `this` for non-methods.");
+assert(!MD->isStatic() && "Don't provide `this` for non-static methods.");
+#endif

I think the message means to say "Don't provide 'this' for static methods."



Comment at: lib/Parse/ParseDecl.cpp:371-372
 return;
   }
 
   // These may refer to the function arguments, but need to be parsed early to

In the last patch, this code was checking for `enable_if` or `diagnose_if`, but 
now only checks for `enable_if`. Do you not need this for `diagnose_if` because 
it's now late parsed?



Comment at: lib/Sema/SemaDeclAttr.cpp:949
+#ifndef NDEBUG
+if (auto *MD = dyn_cast(FD))
+  ClassType = MD->getParent();

`const auto *`


https://reviews.llvm.org/D27424



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


r291150 - Use shared_ptr instead of IntrusiveRefCntPtr for ModuleFileExtension

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 12:23:18 2017
New Revision: 291150

URL: http://llvm.org/viewvc/llvm-project?rev=291150&view=rev
Log:
Use shared_ptr instead of IntrusiveRefCntPtr for ModuleFileExtension

The intrusiveness wasn't needed here, so this simplifies/clarifies the
ownership model.

Modified:
cfe/trunk/include/clang/Frontend/CompilerInstance.h
cfe/trunk/include/clang/Frontend/FrontendOptions.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/include/clang/Serialization/ModuleFileExtension.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/GeneratePCH.cpp

Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=291150&r1=291149&r2=291150&view=diff
==
--- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Thu Jan  5 12:23:18 2017
@@ -653,7 +653,7 @@ public:
   StringRef Path, StringRef Sysroot, bool DisablePCHValidation,
   bool AllowPCHWithCompilerErrors, Preprocessor &PP, ASTContext &Context,
   const PCHContainerReader &PCHContainerRdr,
-  ArrayRef> Extensions,
+  ArrayRef> Extensions,
   void *DeserializationListener, bool OwnDeserializationListener,
   bool Preamble, bool UseGlobalModuleIndex);
 

Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=291150&r1=291149&r2=291150&view=diff
==
--- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Thu Jan  5 12:23:18 2017
@@ -243,7 +243,7 @@ public:
   std::vector Plugins;
 
   /// The list of module file extensions.
-  std::vector> ModuleFileExtensions;
+  std::vector> ModuleFileExtensions;
 
   /// \brief The list of module map files to load before processing the input.
   std::vector ModuleMapFiles;

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=291150&r1=291149&r2=291150&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Jan  5 12:23:18 2017
@@ -414,7 +414,7 @@ private:
   IdentifierResolver DummyIdResolver;
 
   /// A mapping from extension block names to module file extensions.
-  llvm::StringMap> 
ModuleFileExtensions;
+  llvm::StringMap> ModuleFileExtensions;
 
   /// \brief A timer used to track the time spent deserializing.
   std::unique_ptr ReadTimer;
@@ -1366,7 +1366,7 @@ public:
   /// deserializing.
   ASTReader(Preprocessor &PP, ASTContext &Context,
 const PCHContainerReader &PCHContainerRdr,
-ArrayRef> Extensions,
+ArrayRef> Extensions,
 StringRef isysroot = "", bool DisableValidation = false,
 bool AllowASTWithCompilerErrors = false,
 bool AllowConfigurationMismatch = false,

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=291150&r1=291149&r2=291150&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Thu Jan  5 12:23:18 2017
@@ -498,7 +498,7 @@ public:
   /// \brief Create a new precompiled header writer that outputs to
   /// the given bitstream.
   ASTWriter(llvm::BitstreamWriter &Stream,
-ArrayRef> Extensions,
+ArrayRef> Extensions,
 bool IncludeTimestamps = true);
   ~ASTWriter() override;
 
@@ -934,13 +934,10 @@ protected:
   SmallVectorImpl &getPCH() const { return Buffer->Data; }
 
 public:
-  PCHGenerator(
-const Preprocessor &PP, StringRef OutputFile,
-StringRef isysroot,
-std::shared_ptr Buffer,
-ArrayRef> Extensions,
-bool AllowASTWithErrors = false,
-bool IncludeTimestamps = true);
+  PCHGenerator(const Preprocessor &PP, StringRef OutputFile, StringRef 
isysroot,
+   std::shared_ptr Buffer,
+   ArrayRef> Extensions,
+   bool AllowASTWithErrors = false, bool IncludeTimestamps = true);
   ~PCHGenerator() override;
   void InitializeSema(Sema &S) override { SemaPtr = &S; }
   voi

[PATCH] D28362: [ThinLTO] Optionally ignore empty index file

2017-01-05 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added inline comments.



Comment at: lib/CodeGen/BackendUtil.cpp:65
+"Ignore an empty index file and perform non-ThinLTO compilation"),
+llvm::cl::init(false));
+

Is it common to do this in clang?


https://reviews.llvm.org/D28362



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


[PATCH] D28362: [ThinLTO] Optionally ignore empty index file

2017-01-05 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: lib/CodeGen/BackendUtil.cpp:65
+"Ignore an empty index file and perform non-ThinLTO compilation"),
+llvm::cl::init(false));
+

mehdi_amini wrote:
> Is it common to do this in clang?
Doesn't look common, but I see one other LLVM internal option (in 
CodeGenPGO.cpp), and a few other uses in tests. Is there a better way to do 
internal options in clang?


https://reviews.llvm.org/D28362



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


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

2017-01-05 Thread Manman Ren via Phabricator via cfe-commits
manmanren added a comment.

I forgot to upload the testing case, I will add it now.

Manman




Comment at: include/clang/Basic/FileManager.h:176
+  /// Manage memory buffers associated with pcm files.
+  std::unique_ptr BufferMgr;
+

benlangmuir wrote:
> Why is this inside the FileManager? It isn't used by the FileManager.
I initially had another patch that puts PCMCache object at the top level (i.e 
whenever we create a FileManager, we create a PCMCache object). The initial 
patch is much bigger than this patch. PCMCache is cacheing the content of a PCM 
File, and is shared across threads that we spawned to build modules implicitly, 
just like FileManager. I had some discussions with Bruno and Adrian, we felt 
FileManager is a better place. But if you have other suggestions, please let me 
know!



Comment at: include/clang/Basic/FileManager.h:308
+  /// a thread, we pop a ThreadContext.
+  struct ThreadContext {
+/// Keep track of all module files that have been validated in this thread

benlangmuir wrote:
> Can we call this something like "ModuleLoadContext" or maybe 
> "ModuleCompilationContext"?  The word thread is misleading, since the threads 
> are not run concurrently, and are only an implementation detail of our crash 
> recovery.
> 
> Also, can you explain why it is only necessary to keep information about the 
> the current stack of contexts?  In a situation like
> 
> A imports B imports C
> A imports D imports C
> 
> We would no longer have information about C being validated, right?  What 
> happens if there's a mismatch there?  Can this never happen?
Sure, we can call it ModuleCompilationContext because we are spawning threads 
to build modules implicitly.

The issue we are trying to detect is use-after-free, i.e we don't want a thread 
to hold on to an invalid FileEntry. We error out before trying to delete the 
FileEntry that is live in another thread.

In a situation like
A imports B imports C
A imports D imports C

A will start a thread to build B, and B will start a thread to build C, C will 
be validated in B's compilation thread and A's compilation thread. Later on, if 
D tries to invalidate C, D knows that an ancestor thread A has validated C, so 
the compiler will error out. And it is okay for A to invalidate C in A's 
compilation thread, because we can clean up the references to C's FileEntry.



https://reviews.llvm.org/D28299



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


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

2017-01-05 Thread Manman Ren via Phabricator via cfe-commits
manmanren updated this revision to Diff 83273.
manmanren added a comment.

Add testing case.


https://reviews.llvm.org/D28299

Files:
  include/clang/Basic/DiagnosticSerializationKinds.td
  include/clang/Basic/FileManager.h
  include/clang/Serialization/ASTReader.h
  include/clang/Serialization/ASTWriter.h
  include/clang/Serialization/Module.h
  include/clang/Serialization/ModuleManager.h
  lib/Basic/FileManager.cpp
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/ChainedIncludesSource.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/GeneratePCH.cpp
  lib/Serialization/ModuleManager.cpp
  test/Modules/Inputs/system-out-of-date/X.h
  test/Modules/Inputs/system-out-of-date/Y.h
  test/Modules/Inputs/system-out-of-date/Z.h
  test/Modules/Inputs/system-out-of-date/module.map
  test/Modules/system-out-of-date-test.m

Index: test/Modules/system-out-of-date-test.m
===
--- /dev/null
+++ test/Modules/system-out-of-date-test.m
@@ -0,0 +1,13 @@
+// RUN: rm -rf %t
+// RUN: echo '@import X;' | \
+// RUN:   %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN: -fmodules-cache-path=%t -I %S/Inputs/system-out-of-date \
+// RUN: -fsyntax-only -x objective-c -
+
+// We have an version built with different diagnostic options.
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/system-out-of-date -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module %s -fsyntax-only 2>&1 | FileCheck %s
+ @import X;
+ 
+ #import 
+// CHECK: While building module 'Z' imported from
+// CHECK: {{.*}}Y-{{.*}}pcm' was validated as a system module, ignoring differences in diagnostic options
Index: test/Modules/Inputs/system-out-of-date/module.map
===
--- /dev/null
+++ test/Modules/Inputs/system-out-of-date/module.map
@@ -0,0 +1,12 @@
+module X [system] {
+  header "X.h" // imports Y
+  export *
+}
+module Y {
+  header "Y.h"
+  export *
+}
+module Z {
+  header "Z.h" // imports Y
+  export *
+}
Index: test/Modules/Inputs/system-out-of-date/Z.h
===
--- /dev/null
+++ test/Modules/Inputs/system-out-of-date/Z.h
@@ -0,0 +1 @@
+#import 
Index: test/Modules/Inputs/system-out-of-date/Y.h
===
--- /dev/null
+++ test/Modules/Inputs/system-out-of-date/Y.h
@@ -0,0 +1 @@
+//empty
Index: test/Modules/Inputs/system-out-of-date/X.h
===
--- /dev/null
+++ test/Modules/Inputs/system-out-of-date/X.h
@@ -0,0 +1 @@
+#import 
Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -108,7 +108,11 @@
 // Load the contents of the module
 if (std::unique_ptr Buffer = lookupBuffer(FileName)) {
   // The buffer was already provided for us.
-  ModuleEntry->Buffer = std::move(Buffer);
+  ModuleEntry->Buffer = Buffer.get();
+  FileMgr.getPCMCache()->addConsistentBuffer(FileName, std::move(Buffer));
+} else if(llvm::MemoryBuffer *ConsistentB =
+  FileMgr.getPCMCache()->lookupConsistentBuffer(FileName)) {
+  ModuleEntry->Buffer = ConsistentB;
 } else {
   // Open the AST file.
   llvm::ErrorOr> Buf(
@@ -131,7 +135,8 @@
 return Missing;
   }
 
-  ModuleEntry->Buffer = std::move(*Buf);
+  ModuleEntry->Buffer = (*Buf).get();
+  FileMgr.getPCMCache()->addConsistentBuffer(FileName, std::move(*Buf));
 }
 
 // Initialize the stream.
@@ -148,8 +153,11 @@
   ErrorStr = ModuleEntry->Signature != ASTFileSignature({{0}}) ?
  "signature mismatch" : "could not read module signature";
 
-  if (NewModule)
+  if (NewModule) {
+FileMgr.getPCMCache()->removeFromConsistentBuffer(
+ModuleEntry->FileName);
 delete ModuleEntry;
+  }
   return OutOfDate;
 }
   }
@@ -184,7 +192,8 @@
 void ModuleManager::removeModules(
 ModuleIterator first, ModuleIterator last,
 llvm::SmallPtrSetImpl &LoadedSuccessfully,
-ModuleMap *modMap) {
+ModuleMap *modMap,
+llvm::SmallVectorImpl &ValidationConflicts) {
   if (first == last)
 return;
 
@@ -227,16 +236,76 @@
 // Files that didn't make it through ReadASTCore successfully will be
 // rebuilt (or there was an error). Invalidate them so that we can load the
 // new files that will be renamed over the old ones.
-if (LoadedSuccessfully.count(*victim) == 0)
-  FileMgr.invalidateCache((*victim)->File);
-
+if (LoadedSuccessfully.count(*victim) == 0) {
+  // Before removing the module file, check if it was validated in an
+  // ancestor

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

2017-01-05 Thread Manman Ren via Phabricator via cfe-commits
manmanren added inline comments.



Comment at: include/clang/Basic/DiagnosticSerializationKinds.td:131
+  "diagnostic options now it is a non-system module">,
+  InGroup;
+

aprantl wrote:
> Is this better?
> 
> "module file '%0' was validated as a system module and is now being imported 
> as a non-system module; any differences in diagnostics options will be 
> ignored"
Thanks Adrian. Your wording sounds better.



Comment at: include/clang/Basic/DiagnosticSerializationKinds.td:135
+  "module file '%0' was validated in an ancestor thread, now it needs to "
+  "be invalidated">;
+

aprantl wrote:
> I wonder if there is a way to rephrase this message such that an end-user 
> could understan how to interpret this error?
I am not sure if we will emit this error diagnostic in some case, that is why I 
don't have a testing case. Maybe it is better to throw a hard error instead of 
a diagnostic that user can't understand?



https://reviews.llvm.org/D28299



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


r291155 - Simplify ASTReader ctor by using in-class initializers for many member variables

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 12:45:45 2017
New Revision: 291155

URL: http://llvm.org/viewvc/llvm-project?rev=291155&view=rev
Log:
Simplify ASTReader ctor by using in-class initializers for many member variables

Modified:
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=291155&r1=291154&r2=291155&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Thu Jan  5 12:45:45 2017
@@ -107,16 +107,16 @@ private:
   llvm::BitstreamWriter &Stream;
 
   /// \brief The ASTContext we're writing.
-  ASTContext *Context;
+  ASTContext *Context = nullptr;
 
   /// \brief The preprocessor we're writing.
-  Preprocessor *PP;
+  Preprocessor *PP = nullptr;
 
   /// \brief The reader of existing AST files, if we're chaining.
-  ASTReader *Chain;
+  ASTReader *Chain = nullptr;
 
   /// \brief The module we're currently writing, if any.
-  Module *WritingModule;
+  Module *WritingModule = nullptr;
 
   /// \brief The base directory for any relative paths we emit.
   std::string BaseDirectory;
@@ -129,14 +129,14 @@ private:
 
   /// \brief Indicates when the AST writing is actively performing
   /// serialization, rather than just queueing updates.
-  bool WritingAST;
+  bool WritingAST = false;
 
   /// \brief Indicates that we are done serializing the collection of decls
   /// and types to emit.
-  bool DoneWritingDeclsAndTypes;
+  bool DoneWritingDeclsAndTypes = false;
 
   /// \brief Indicates that the AST contained compiler errors.
-  bool ASTHasCompilerErrors;
+  bool ASTHasCompilerErrors = false;
 
   /// \brief Mapping from input file entries to the index into the
   /// offset table where information about that input file is stored.
@@ -170,10 +170,10 @@ private:
   std::queue DeclTypesToEmit;
 
   /// \brief The first ID number we can use for our own declarations.
-  serialization::DeclID FirstDeclID;
+  serialization::DeclID FirstDeclID = serialization::NUM_PREDEF_DECL_IDS;
 
   /// \brief The decl ID that will be assigned to the next new decl.
-  serialization::DeclID NextDeclID;
+  serialization::DeclID NextDeclID = FirstDeclID;
 
   /// \brief Map that provides the ID numbers of each declaration within
   /// the output stream, as well as those deserialized from a chained PCH.
@@ -205,10 +205,10 @@ private:
   void associateDeclWithFile(const Decl *D, serialization::DeclID);
 
   /// \brief The first ID number we can use for our own types.
-  serialization::TypeID FirstTypeID;
+  serialization::TypeID FirstTypeID = serialization::NUM_PREDEF_TYPE_IDS;
 
   /// \brief The type ID that will be assigned to the next new type.
-  serialization::TypeID NextTypeID;
+  serialization::TypeID NextTypeID = FirstTypeID;
 
   /// \brief Map that provides the ID numbers of each type within the
   /// output stream, plus those deserialized from a chained PCH.
@@ -226,10 +226,10 @@ private:
   std::vector TypeOffsets;
 
   /// \brief The first ID number we can use for our own identifiers.
-  serialization::IdentID FirstIdentID;
+  serialization::IdentID FirstIdentID = serialization::NUM_PREDEF_IDENT_IDS;
 
   /// \brief The identifier ID that will be assigned to the next new 
identifier.
-  serialization::IdentID NextIdentID;
+  serialization::IdentID NextIdentID = FirstIdentID;
 
   /// \brief Map that provides the ID numbers of each identifier in
   /// the output stream.
@@ -240,10 +240,10 @@ private:
   llvm::MapVector 
IdentifierIDs;
 
   /// \brief The first ID number we can use for our own macros.
-  serialization::MacroID FirstMacroID;
+  serialization::MacroID FirstMacroID = serialization::NUM_PREDEF_MACRO_IDS;
 
   /// \brief The identifier ID that will be assigned to the next new 
identifier.
-  serialization::MacroID NextMacroID;
+  serialization::MacroID NextMacroID = FirstMacroID;
 
   /// \brief Map that provides the ID numbers of each macro.
   llvm::DenseMap MacroIDs;
@@ -275,16 +275,18 @@ private:
   std::vector IdentifierOffsets;
 
   /// \brief The first ID number we can use for our own submodules.
-  serialization::SubmoduleID FirstSubmoduleID;
-  
+  serialization::SubmoduleID FirstSubmoduleID =
+  serialization::NUM_PREDEF_SUBMODULE_IDS;
+
   /// \brief The submodule ID that will be assigned to the next new submodule.
-  serialization::SubmoduleID NextSubmoduleID;
+  serialization::SubmoduleID NextSubmoduleID = FirstSubmoduleID;
 
   /// \brief The first ID number we can use for our own selectors.
-  serialization::SelectorID FirstSelectorID;
+  serialization::SelectorID FirstSelectorID =
+  serialization::NUM_PREDEF_SELECTOR_IDS;
 
   /// \brief The selector ID that will be assigned to the next new selector.
-  serialization::SelectorID N

r291154 - Simplify ASTReader ctor by using in-class initializers (NSDMIs to the rest of you) for many member variables

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 12:45:43 2017
New Revision: 291154

URL: http://llvm.org/viewvc/llvm-project?rev=291154&view=rev
Log:
Simplify ASTReader ctor by using in-class initializers (NSDMIs to the rest of 
you) for many member variables

Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=291154&r1=291153&r2=291154&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Jan  5 12:45:43 2017
@@ -384,8 +384,8 @@ private:
   std::unique_ptr Listener;
 
   /// \brief The receiver of deserialization events.
-  ASTDeserializationListener *DeserializationListener;
-  bool OwnsDeserializationListener;
+  ASTDeserializationListener *DeserializationListener = nullptr;
+  bool OwnsDeserializationListener = false;
 
   SourceManager &SourceMgr;
   FileManager &FileMgr;
@@ -394,7 +394,7 @@ private:
 
   /// \brief The semantic analysis object that will be processing the
   /// AST files and the translation unit that uses it.
-  Sema *SemaObj;
+  Sema *SemaObj = nullptr;
 
   /// \brief The preprocessor that will be loading the source file.
   Preprocessor &PP;
@@ -403,7 +403,7 @@ private:
   ASTContext &Context;
 
   /// \brief The AST consumer.
-  ASTConsumer *Consumer;
+  ASTConsumer *Consumer = nullptr;
 
   /// \brief The module manager which manages modules and their dependencies
   ModuleManager ModuleMgr;
@@ -802,10 +802,10 @@ private:
   SourceLocation OptimizeOffPragmaLocation;
 
   /// \brief The PragmaMSStructKind pragma ms_struct state if set, or -1.
-  int PragmaMSStructState;
+  int PragmaMSStructState = -1;
 
   /// \brief The PragmaMSPointersToMembersKind pragma pointers_to_members 
state.
-  int PragmaMSPointersToMembersState;
+  int PragmaMSPointersToMembersState = -1;
   SourceLocation PointersToMembersPragmaLocation;
 
   /// \brief The OpenCL extension settings.
@@ -870,10 +870,10 @@ private:
   bool UseGlobalIndex;
 
   /// \brief Whether we have tried loading the global module index yet.
-  bool TriedLoadingGlobalIndex;
+  bool TriedLoadingGlobalIndex = false;
 
   ///\brief Whether we are currently processing update records.
-  bool ProcessingUpdateRecords;
+  bool ProcessingUpdateRecords = false;
 
   typedef llvm::DenseMap SwitchCaseMapTy;
   /// \brief Mapping from switch-case IDs in the chain to switch-case 
statements
@@ -886,73 +886,73 @@ private:
 
   /// \brief The number of source location entries de-serialized from
   /// the PCH file.
-  unsigned NumSLocEntriesRead;
+  unsigned NumSLocEntriesRead = 0;
 
   /// \brief The number of source location entries in the chain.
-  unsigned TotalNumSLocEntries;
+  unsigned TotalNumSLocEntries = 0;
 
   /// \brief The number of statements (and expressions) de-serialized
   /// from the chain.
-  unsigned NumStatementsRead;
+  unsigned NumStatementsRead = 0;
 
   /// \brief The total number of statements (and expressions) stored
   /// in the chain.
-  unsigned TotalNumStatements;
+  unsigned TotalNumStatements = 0;
 
   /// \brief The number of macros de-serialized from the chain.
-  unsigned NumMacrosRead;
+  unsigned NumMacrosRead = 0;
 
   /// \brief The total number of macros stored in the chain.
-  unsigned TotalNumMacros;
+  unsigned TotalNumMacros = 0;
 
   /// \brief The number of lookups into identifier tables.
-  unsigned NumIdentifierLookups;
+  unsigned NumIdentifierLookups = 0;
 
   /// \brief The number of lookups into identifier tables that succeed.
-  unsigned NumIdentifierLookupHits;
+  unsigned NumIdentifierLookupHits = 0;
 
   /// \brief The number of selectors that have been read.
-  unsigned NumSelectorsRead;
+  unsigned NumSelectorsRead = 0;
 
   /// \brief The number of method pool entries that have been read.
-  unsigned NumMethodPoolEntriesRead;
+  unsigned NumMethodPoolEntriesRead = 0;
 
   /// \brief The number of times we have looked up a selector in the method
   /// pool.
-  unsigned NumMethodPoolLookups;
+  unsigned NumMethodPoolLookups = 0;
 
   /// \brief The number of times we have looked up a selector in the method
   /// pool and found something.
-  unsigned NumMethodPoolHits;
+  unsigned NumMethodPoolHits = 0;
 
   /// \brief The number of times we have looked up a selector in the method
   /// pool within a specific module.
-  unsigned NumMethodPoolTableLookups;
+  unsigned NumMethodPoolTableLookups = 0;
 
   /// \brief The number of times we have looked up a selector in the method
   /// pool within a specific module and found something.
-  unsigned NumMethodPoolTableHits;
+  unsigned NumMethodPoolTableHits = 0;
 
   /// \brief The total number of method pool entries in the selector table.
-  unsigned TotalNumMethodPoolEntries;
+  unsi

r291156 - Move VariantMatcher's Payload to std::shared_ptr rather than IntrusiveRefCntPtr

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 12:51:54 2017
New Revision: 291156

URL: http://llvm.org/viewvc/llvm-project?rev=291156&view=rev
Log:
Move VariantMatcher's Payload to std::shared_ptr rather than IntrusiveRefCntPtr

Modified:
cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h
cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp

Modified: cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h?rev=291156&r1=291155&r2=291156&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h Thu Jan  5 
12:51:54 2017
@@ -119,7 +119,7 @@ class VariantMatcher {
   /// \brief Payload interface to be specialized by each matcher type.
   ///
   /// It follows a similar interface as VariantMatcher itself.
-  class Payload : public RefCountedBase {
+  class Payload {
   public:
 virtual ~Payload();
 virtual llvm::Optional getSingleMatcher() const = 0;
@@ -208,7 +208,8 @@ public:
   std::string getTypeAsString() const;
 
 private:
-  explicit VariantMatcher(Payload *Value) : Value(Value) {}
+  explicit VariantMatcher(std::shared_ptr Value)
+  : Value(std::move(Value)) {}
 
   template  struct TypedMatcherOps;
 
@@ -216,7 +217,7 @@ private:
   class PolymorphicPayload;
   class VariadicOpPayload;
 
-  IntrusiveRefCntPtr Value;
+  std::shared_ptr Value;
 };
 
 template 

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp?rev=291156&r1=291155&r2=291156&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp Thu Jan  5 12:51:54 2017
@@ -216,18 +216,20 @@ private:
 VariantMatcher::VariantMatcher() {}
 
 VariantMatcher VariantMatcher::SingleMatcher(const DynTypedMatcher &Matcher) {
-  return VariantMatcher(new SinglePayload(Matcher));
+  return VariantMatcher(std::make_shared(Matcher));
 }
 
 VariantMatcher
 VariantMatcher::PolymorphicMatcher(std::vector Matchers) {
-  return VariantMatcher(new PolymorphicPayload(std::move(Matchers)));
+  return VariantMatcher(
+  std::make_shared(std::move(Matchers)));
 }
 
 VariantMatcher VariantMatcher::VariadicOperatorMatcher(
 DynTypedMatcher::VariadicOperator Op,
 std::vector Args) {
-  return VariantMatcher(new VariadicOpPayload(Op, std::move(Args)));
+  return VariantMatcher(
+  std::make_shared(Op, std::move(Args)));
 }
 
 llvm::Optional VariantMatcher::getSingleMatcher() const {


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


r291160 - Move PreprocessorOptions to std::shared_ptr from IntrusiveRefCntPtr

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 13:11:36 2017
New Revision: 291160

URL: http://llvm.org/viewvc/llvm-project?rev=291160&view=rev
Log:
Move PreprocessorOptions to std::shared_ptr from IntrusiveRefCntPtr

Modified:
cfe/trunk/include/clang/Frontend/CompilerInvocation.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/include/clang/Lex/PreprocessorOptions.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
cfe/trunk/unittests/Basic/SourceManagerTest.cpp
cfe/trunk/unittests/Lex/LexerTest.cpp
cfe/trunk/unittests/Lex/PPCallbacksTest.cpp
cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp

Modified: cfe/trunk/include/clang/Frontend/CompilerInvocation.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInvocation.h?rev=291160&r1=291159&r2=291160&view=diff
==
--- cfe/trunk/include/clang/Frontend/CompilerInvocation.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInvocation.h Thu Jan  5 13:11:36 
2017
@@ -68,7 +68,7 @@ public:
   IntrusiveRefCntPtr HeaderSearchOpts;
 
   /// Options controlling the preprocessor (aside from \#include handling).
-  IntrusiveRefCntPtr PreprocessorOpts;
+  std::shared_ptr PreprocessorOpts;
 
   CompilerInvocationBase();
   ~CompilerInvocationBase();
@@ -90,6 +90,9 @@ public:
 return *HeaderSearchOpts;
   }
 
+  std::shared_ptr getPreprocessorOptsPtr() {
+return PreprocessorOpts;
+  }
   PreprocessorOptions &getPreprocessorOpts() { return *PreprocessorOpts; }
   const PreprocessorOptions &getPreprocessorOpts() const {
 return *PreprocessorOpts;

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=291160&r1=291159&r2=291160&view=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Thu Jan  5 13:11:36 2017
@@ -95,7 +95,7 @@ enum MacroUse {
 /// know anything about preprocessor-level issues like the \#include stack,
 /// token expansion, etc.
 class Preprocessor : public RefCountedBase {
-  IntrusiveRefCntPtr PPOpts;
+  std::shared_ptr PPOpts;
   DiagnosticsEngine*Diags;
   LangOptions   &LangOpts;
   const TargetInfo  *Target;
@@ -650,10 +650,9 @@ class Preprocessor : public RefCountedBa
   void updateOutOfDateIdentifier(IdentifierInfo &II) const;
 
 public:
-  Preprocessor(IntrusiveRefCntPtr PPOpts,
-   DiagnosticsEngine &diags, LangOptions &opts,
-   SourceManager &SM, HeaderSearch &Headers,
-   ModuleLoader &TheModuleLoader,
+  Preprocessor(std::shared_ptr PPOpts,
+   DiagnosticsEngine &diags, LangOptions &opts, SourceManager &SM,
+   HeaderSearch &Headers, ModuleLoader &TheModuleLoader,
IdentifierInfoLookup *IILookup = nullptr,
bool OwnsHeaderSearch = false,
TranslationUnitKind TUKind = TU_Complete);

Modified: cfe/trunk/include/clang/Lex/PreprocessorOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessorOptions.h?rev=291160&r1=291159&r2=291160&view=diff
==
--- cfe/trunk/include/clang/Lex/PreprocessorOptions.h (original)
+++ cfe/trunk/include/clang/Lex/PreprocessorOptions.h Thu Jan  5 13:11:36 2017
@@ -40,7 +40,7 @@ enum ObjCXXARCStandardLibraryKind {
   
 /// PreprocessorOptions - This class is used for passing the various options
 /// used in preprocessor initialization to InitializePreprocessor().
-class PreprocessorOptions : public RefCountedBase {
+class PreprocessorOptions {
 public:
   std::vector > Macros;
   std::vector Includes;

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=291160&r1=291159&r2=291160&view=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Thu Jan  5 13:11:36 2017
@@ -683,7 +683,7 @@ std::unique_ptr ASTUnit::LoadFr
  AST->ASTFileLangOpts,
  /*Target=*/nullptr));
 
-  PreprocessorOptions *PPOpts = new PreprocessorOptions();
+  auto PPOpts = std::make_shared();
 
   for (const auto &RemappedFile : RemappedFiles)
 PPOpts->addRemappedFile(RemappedFile.first, RemappedFile.second);
@@ -693,11 +693,11 @@ std::unique_ptr ASTUnit::LoadFr
   HeaderSearch &HeaderInfo = *AST->HeaderInfo;
   unsigned Counter;
 
-  AST->PP =
-  new Preprocessor(PPOpts, AST->getDiagnostics(), AST->ASTFileLangOpts,
-   AST->getSourceManager(), HeaderInfo, *AST,
-   /*IILooku

r291159 - Move FailedModulesSet over to shared_ptr from IntrusiveRefCntPtr

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 13:11:31 2017
New Revision: 291159

URL: http://llvm.org/viewvc/llvm-project?rev=291159&view=rev
Log:
Move FailedModulesSet over to shared_ptr from IntrusiveRefCntPtr

Modified:
cfe/trunk/include/clang/Lex/PreprocessorOptions.h
cfe/trunk/lib/Frontend/CompilerInstance.cpp

Modified: cfe/trunk/include/clang/Lex/PreprocessorOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessorOptions.h?rev=291159&r1=291158&r2=291159&view=diff
==
--- cfe/trunk/include/clang/Lex/PreprocessorOptions.h (original)
+++ cfe/trunk/include/clang/Lex/PreprocessorOptions.h Thu Jan  5 13:11:31 2017
@@ -117,7 +117,7 @@ public:
   ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary;
 
   /// \brief Records the set of modules
-  class FailedModulesSet : public RefCountedBase {
+  class FailedModulesSet {
 llvm::StringSet<> Failed;
 
   public:
@@ -136,7 +136,7 @@ public:
   /// to (re)build modules, so that once a module fails to build anywhere,
   /// other instances will see that the module has failed and won't try to
   /// build it again.
-  IntrusiveRefCntPtr FailedModules;
+  std::shared_ptr FailedModules;
 
 public:
   PreprocessorOptions() : UsePredefines(true), DetailedRecord(false),

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=291159&r1=291158&r2=291159&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Thu Jan  5 13:11:31 2017
@@ -1049,7 +1049,8 @@ static bool compileModuleImpl(CompilerIn
   PreprocessorOptions &ImportingPPOpts
 = ImportingInstance.getInvocation().getPreprocessorOpts();
   if (!ImportingPPOpts.FailedModules)
-ImportingPPOpts.FailedModules = new PreprocessorOptions::FailedModulesSet;
+ImportingPPOpts.FailedModules =
+std::make_shared();
   PPOpts.FailedModules = ImportingPPOpts.FailedModules;
 
   // If there is a module map file, build the module using the module map.


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


r291166 - Move Preprocessor over to std::shared_ptr rather than IntrusiveRefCntPtr

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 13:48:07 2017
New Revision: 291166

URL: http://llvm.org/viewvc/llvm-project?rev=291166&view=rev
Log:
Move Preprocessor over to std::shared_ptr rather than IntrusiveRefCntPtr

Modified:
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/include/clang/Frontend/CompilerInstance.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp
cfe/trunk/tools/libclang/CXIndexDataConsumer.h
cfe/trunk/tools/libclang/Indexing.cpp

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=291166&r1=291165&r2=291166&view=diff
==
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Thu Jan  5 13:48:07 2017
@@ -86,7 +86,7 @@ private:
   IntrusiveRefCntPtr   SourceMgr;
   std::unique_ptr   HeaderInfo;
   IntrusiveRefCntPtr  Target;
-  IntrusiveRefCntPtrPP;
+  std::shared_ptr   PP;
   IntrusiveRefCntPtr  Ctx;
   std::shared_ptr  TargetOpts;
   IntrusiveRefCntPtr HSOpts;
@@ -496,12 +496,13 @@ public:
 
   const Preprocessor &getPreprocessor() const { return *PP; }
 Preprocessor &getPreprocessor()   { return *PP; }
+  std::shared_ptr getPreprocessorPtr() const { return PP; }
 
   const ASTContext &getASTContext() const { return *Ctx; }
 ASTContext &getASTContext()   { return *Ctx; }
 
   void setASTContext(ASTContext *ctx) { Ctx = ctx; }
-  void setPreprocessor(Preprocessor *pp);
+  void setPreprocessor(std::shared_ptr pp);
 
   bool hasSema() const { return (bool)TheSema; }
   Sema &getSema() const { 

Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=291166&r1=291165&r2=291166&view=diff
==
--- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Thu Jan  5 13:48:07 2017
@@ -91,7 +91,7 @@ class CompilerInstance : public ModuleLo
   IntrusiveRefCntPtr SourceMgr;
 
   /// The preprocessor.
-  IntrusiveRefCntPtr PP;
+  std::shared_ptr PP;
 
   /// The AST context.
   IntrusiveRefCntPtr Context;
@@ -433,13 +433,14 @@ public:
 return *PP;
   }
 
+  std::shared_ptr getPreprocessorPtr() { return PP; }
+
   void resetAndLeakPreprocessor() {
-BuryPointer(PP.get());
-PP.resetWithoutRelease();
+BuryPointer(new std::shared_ptr(PP));
   }
 
   /// Replace the current preprocessor.
-  void setPreprocessor(Preprocessor *Value);
+  void setPreprocessor(std::shared_ptr Value);
 
   /// }
   /// @name ASTContext

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=291166&r1=291165&r2=291166&view=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Thu Jan  5 13:48:07 2017
@@ -94,7 +94,7 @@ enum MacroUse {
 /// Lexers know only about tokens within a single source file, and don't
 /// know anything about preprocessor-level issues like the \#include stack,
 /// token expansion, etc.
-class Preprocessor : public RefCountedBase {
+class Preprocessor {
   std::shared_ptr PPOpts;
   DiagnosticsEngine*Diags;
   LangOptions   &LangOpts;

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=291166&r1=291165&r2=291166&view=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Thu Jan  5 13:48:07 2017
@@ -257,7 +257,9 @@ ASTUnit::~ASTUnit() {
 fprintf(stderr, "--- %u translation units\n", --ActiveASTUnitObjects);
 }
 
-void ASTUnit::setPreprocessor(Preprocessor *pp) { PP = pp; }
+void ASTUnit::setPreprocessor(std::shared_ptr PP) {
+  this->PP = std::move(PP);
+}
 
 /// \brief Determine the set of code-completion contexts in which this 
 /// declaration should be shown.
@@ -693,11 +695,11 @@ std::unique_ptr ASTUnit::LoadFr
   HeaderSearch &HeaderInfo = *AST->HeaderInfo;
   unsigned Counter;
 
-  AST->PP = new Preprocessor(std::move(PPOpts), AST->getDiagnostics(),
- AST->ASTFileLangOpts, AST->getSourceManager(),
- HeaderInfo, *AST,
- /*IILookup=*/nullptr,
- /*OwnsHeaderSearch=*/false);
+  AST->

r291167 - Move SerializedDiagnosticPrinter's SharedState to std::shared_ptr rather than IntrusiveRefCntPtr

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 13:48:10 2017
New Revision: 291167

URL: http://llvm.org/viewvc/llvm-project?rev=291167&view=rev
Log:
Move SerializedDiagnosticPrinter's SharedState to std::shared_ptr rather than 
IntrusiveRefCntPtr

Modified:
cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp

Modified: cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp?rev=291167&r1=291166&r2=291167&view=diff
==
--- cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp Thu Jan  5 13:48:10 
2017
@@ -143,7 +143,7 @@ class SDiagsWriter : public DiagnosticCo
 
   struct SharedState;
 
-  explicit SDiagsWriter(IntrusiveRefCntPtr State)
+  explicit SDiagsWriter(std::shared_ptr State)
   : LangOpts(nullptr), OriginalInstance(false), MergeChildRecords(false),
 State(std::move(State)) {}
 
@@ -151,7 +151,7 @@ public:
   SDiagsWriter(StringRef File, DiagnosticOptions *Diags, bool 
MergeChildRecords)
   : LangOpts(nullptr), OriginalInstance(true),
 MergeChildRecords(MergeChildRecords),
-State(new SharedState(File, Diags)) {
+State(std::make_shared(File, Diags)) {
 if (MergeChildRecords)
   RemoveOldDiagnostics();
 EmitPreamble();
@@ -251,7 +251,7 @@ private:
 
   /// \brief State that is shared among the various clones of this diagnostic
   /// consumer.
-  struct SharedState : RefCountedBase {
+  struct SharedState {
 SharedState(StringRef File, DiagnosticOptions *Diags)
 : DiagOpts(Diags), Stream(Buffer), OutputFile(File.str()),
   EmittedAnyDiagBlocks(false) {}
@@ -299,7 +299,7 @@ private:
   };
 
   /// \brief State shared among the various clones of this diagnostic consumer.
-  IntrusiveRefCntPtr State;
+  std::shared_ptr State;
 };
 } // end anonymous namespace
 


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


[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse* flags implicitly

2017-01-05 Thread Dmitry Vyukov via Phabricator via cfe-commits
dvyukov added a comment.

> I don't see a big issue enabling it for x86-64 but for 32-bit systems you're 
> ruling out quite a lot of hardware.

Tsan does not support 32-bits.


https://reviews.llvm.org/D28304



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


r291170 - If an explicitly-specified pack might have been extended by template argument

2017-01-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jan  5 14:27:28 2017
New Revision: 291170

URL: http://llvm.org/viewvc/llvm-project?rev=291170&view=rev
Log:
If an explicitly-specified pack might have been extended by template argument
deduction, don't forget to check the argument is valid.

Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/SemaTemplate/deduction.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=291170&r1=291169&r2=291170&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Thu Jan  5 14:27:28 2017
@@ -2215,25 +2215,26 @@ static Sema::TemplateDeductionResult Con
 
 if (!Deduced[I].isNull()) {
   if (I < NumAlreadyConverted) {
-// We have already fully type-checked and converted this
-// argument, because it was explicitly-specified. Just record the
-// presence of this argument.
-Builder.push_back(Deduced[I]);
 // We may have had explicitly-specified template arguments for a
 // template parameter pack (that may or may not have been extended
 // via additional deduced arguments).
-if (Param->isParameterPack() && CurrentInstantiationScope) {
-  if (CurrentInstantiationScope->getPartiallySubstitutedPack() ==
-  Param) {
-// Forget the partially-substituted pack; its substitution is now
-// complete.
-CurrentInstantiationScope->ResetPartiallySubstitutedPack();
-  }
+if (Param->isParameterPack() && CurrentInstantiationScope &&
+CurrentInstantiationScope->getPartiallySubstitutedPack() == Param) 
{
+  // Forget the partially-substituted pack; its substitution is now
+  // complete.
+  CurrentInstantiationScope->ResetPartiallySubstitutedPack();
+  // We still need to check the argument in case it was extended by
+  // deduction.
+} else {
+  // We have already fully type-checked and converted this
+  // argument, because it was explicitly-specified. Just record the
+  // presence of this argument.
+  Builder.push_back(Deduced[I]);
+  continue;
 }
-continue;
   }
 
-  // We have deduced this argument, so it still needs to be
+  // We may have deduced this argument, so it still needs to be
   // checked and converted.
   if (ConvertDeducedTemplateArgument(S, Param, Deduced[I], Template, Info,
  IsDeduced, Builder)) {

Modified: cfe/trunk/test/SemaTemplate/deduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/deduction.cpp?rev=291170&r1=291169&r2=291170&view=diff
==
--- cfe/trunk/test/SemaTemplate/deduction.cpp (original)
+++ cfe/trunk/test/SemaTemplate/deduction.cpp Thu Jan  5 14:27:28 2017
@@ -428,3 +428,17 @@ namespace deduction_from_empty_list {
 f<1>({0}, {0, 1}); // expected-error {{no matching}}
   }
 }
+
+namespace check_extended_pack {
+  template struct X { typedef int type; };
+  template void f(typename X::type...);
+  template void f(T, int, int);
+  void g() {
+f(0, 0, 0);
+  }
+
+  template struct Y {};
+  template void g(Y); // expected-note {{deduced non-type 
template argument does not have the same type as the corresponding template 
parameter ('int *' vs 'int')}}
+  int n;
+  void h() { g<0>(Y<0, &n>()); } // expected-error {{no matching function}}
+}


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


[PATCH] D28220: provide Win32 native threading

2017-01-05 Thread Andrey Khalyavin via Phabricator via cfe-commits
halyavin added inline comments.



Comment at: include/__threading_support:474
+  
system_clock::time_point(duration_cast(duration));
+  auto timeout_ms = duration_cast(abstime - system_clock::now());
+

compnerd wrote:
> halyavin wrote:
> > Since negative timeouts can't be avoided, we must make sure that 
> > timeout_ms.count() is at least zero.
> Good point.  I suppose that the assert takes care of that though.
Negative timeout_ms.count() is a normal case, we shouldn't fail on assertion. 
The reason is that program can always be slow enough for current timestamp 
(system_clock::now()) to pass any fixed point in time (__ts/abstime). 



Comment at: include/__threading_support:476
+
+  _LIBCPP_ASSERT(timeout_ms.count() > INFINITE && "timeout duration overflow");
+  if (!SleepConditionVariableSRW(__cv, __m, timeout_ms.count(), 0))

compnerd wrote:
> halyavin wrote:
> > It is >= INFINITE. _LIBCPP_ASSERT has 2 arguments and supports error 
> > message out of the box.
> Shouldnt this be, `timeout_ms.count() > 0` which implicitly ensures that it 
> is not `INFINITE` (-1)?
I just checked in the Windows SDK, INFINITE is defined as `0x` and 
negative timeouts are legal anyway.



Repository:
  rL LLVM

https://reviews.llvm.org/D28220



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


[libcxx] r291174 - typeinfo: style adjustments for adding MS ABI RTTI

2017-01-05 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Jan  5 15:22:22 2017
New Revision: 291174

URL: http://llvm.org/viewvc/llvm-project?rev=291174&view=rev
Log:
typeinfo: style adjustments for adding MS ABI RTTI

This is motivated by adding a third RTTI scheme to libc++.  Split out
the two forms of the itanium RTTI representation.  This is based on
suggestions from Eric Fiselier.  NFC

Modified:
libcxx/trunk/include/typeinfo

Modified: libcxx/trunk/include/typeinfo
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/typeinfo?rev=291174&r1=291173&r2=291174&view=diff
==
--- libcxx/trunk/include/typeinfo (original)
+++ libcxx/trunk/include/typeinfo Thu Jan  5 15:22:22 2017
@@ -69,6 +69,12 @@ public:
 #pragma GCC system_header
 #endif
 
+#if defined(_LIBCPP_NONUNIQUE_RTTI_BIT)
+#define _LIBCPP_HAS_NONUNIQUE_TYPEINFO
+#else
+#define _LIBCPP_HAS_UNIQUE_TYPEINFO
+#endif
+
 namespace std  // purposefully not using versioning namespace
 {
 
@@ -77,76 +83,89 @@ class _LIBCPP_EXCEPTION_ABI type_info
 type_info& operator=(const type_info&);
 type_info(const type_info&);
 
+#if defined(_LIBCPP_HAS_NONUNIQUE_TYPEINFO)
+_LIBCPP_INLINE_VISIBILITY
+int __compare_nonunique_names(const type_info &__arg) const _NOEXCEPT
+{ return __builtin_strcmp(name(), __arg.name()); }
+#endif
+
 protected:
-#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
-const char* __type_name;
-#else
+#if defined(_LIBCPP_HAS_NONUNIQUE_TYPEINFO)
 // A const char* with the non-unique RTTI bit possibly set.
 uintptr_t __type_name;
-#endif
 
 _LIBCPP_INLINE_VISIBILITY
-explicit type_info(const char* __n)
-#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
-: __type_name(__n) {}
+type_info(const char* __n) : __type_name(reinterpret_cast(__n)) 
{}
 #else
-: __type_name(reinterpret_cast(__n)) {}
+const char *__type_name;
+
+_LIBCPP_INLINE_VISIBILITY
+type_info(const char* __n) : __type_name(__n) {}
 #endif
 
 public:
 virtual ~type_info();
 
+#if defined(_LIBCPP_HAS_NONUNIQUE_TYPEINFO)
 _LIBCPP_INLINE_VISIBILITY
 const char* name() const _NOEXCEPT
-#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
-{return __type_name;}
-#else
-{return reinterpret_cast(__type_name & 
~_LIBCPP_NONUNIQUE_RTTI_BIT);}
-#endif
+{
+  return reinterpret_cast(__type_name &
+   ~_LIBCPP_NONUNIQUE_RTTI_BIT);
+}
 
 _LIBCPP_INLINE_VISIBILITY
 bool before(const type_info& __arg) const _NOEXCEPT
-#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
-{return __type_name < __arg.__type_name;}
-#else
-{if (!((__type_name & __arg.__type_name) & _LIBCPP_NONUNIQUE_RTTI_BIT))
-   return __type_name < __arg.__type_name;
- return __compare_nonunique_names(__arg) < 0;}
-#endif
+{
+  if (!((__type_name & __arg.__type_name) & _LIBCPP_NONUNIQUE_RTTI_BIT))
+return __type_name < __arg.__type_name;
+  return __compare_nonunique_names(__arg) < 0;
+}
 
 _LIBCPP_INLINE_VISIBILITY
 size_t hash_code() const _NOEXCEPT
-#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
-{return reinterpret_cast(__type_name);}
-#else
-{if (!(__type_name & _LIBCPP_NONUNIQUE_RTTI_BIT)) return __type_name;
- const char *__ptr = name();
- size_t __hash = 5381;
- while (unsigned char __c = static_cast(*__ptr++))
-   __hash = (__hash * 33) ^ __c;
- return __hash;}
-#endif
+{
+  if (!(__type_name & _LIBCPP_NONUNIQUE_RTTI_BIT))
+return __type_name;
+
+  const char* __ptr = name();
+  size_t __hash = 5381;
+  while (unsigned char __c = static_cast(*__ptr++))
+__hash = (__hash * 33) ^ __c;
+  return __hash;
+}
 
 _LIBCPP_INLINE_VISIBILITY
 bool operator==(const type_info& __arg) const _NOEXCEPT
-#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
-{return __type_name == __arg.__type_name;}
+{
+  if (__type_name == __arg.__type_name)
+return true;
+
+  if (!((__type_name & __arg.__type_name) & _LIBCPP_NONUNIQUE_RTTI_BIT))
+return false;
+  return __compare_nonunique_names(__arg) == 0;
+}
 #else
-{if (__type_name == __arg.__type_name) return true;
- if (!((__type_name & __arg.__type_name) & _LIBCPP_NONUNIQUE_RTTI_BIT))
-   return false;
- return __compare_nonunique_names(__arg) == 0;}
-#endif
 _LIBCPP_INLINE_VISIBILITY
-bool operator!=(const type_info& __arg) const _NOEXCEPT
-{return !operator==(__arg);}
+const char* name() const _NOEXCEPT
+{ return __type_name; }
 
-#ifdef _LIBCPP_NONUNIQUE_RTTI_BIT
-  private:
 _LIBCPP_INLINE_VISIBILITY
-int __compare_nonunique_names(const type_info &__arg) const _NOEXCEPT
-{return __builtin_strcmp(name(), __arg.name());}
+bool before(const type_info& __arg) const _NOEXCEPT
+{ return __type_name < __arg.__type_name; }
+
+_LIBCPP_INLINE_VISIBILITY
+size_t hash_code() const _NOEXCE

[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse* flags implicitly

2017-01-05 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Oh, sorry that I didn't check that. Then I guess it's good enough for me, we're 
losing just few old Athlon 64 CPUs, I guess. I'll update the patch to remove 
4.2 only.


https://reviews.llvm.org/D28304



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


[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse4.2 flag implicitly

2017-01-05 Thread Michał Górny via Phabricator via cfe-commits
mgorny retitled this revision from "[compiler-rt] [cmake] Disable appending 
-msse* flags implicitly" to "[compiler-rt] [cmake] Disable appending -msse4.2 
flag implicitly".
mgorny updated the summary for this revision.
mgorny updated this revision to Diff 83298.

https://reviews.llvm.org/D28304

Files:
  cmake/config-ix.cmake
  lib/scudo/CMakeLists.txt


Index: lib/scudo/CMakeLists.txt
===
--- lib/scudo/CMakeLists.txt
+++ lib/scudo/CMakeLists.txt
@@ -4,7 +4,6 @@
 
 set(SCUDO_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF SCUDO_CFLAGS)
-append_list_if(COMPILER_RT_HAS_MSSE4_2_FLAG -msse4.2 SCUDO_CFLAGS)
 
 set(SCUDO_SOURCES
   scudo_allocator.cpp
Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -29,7 +29,6 @@
 check_cxx_compiler_flag(-ftls-model=initial-exec 
COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC)
 check_cxx_compiler_flag(-fno-lto COMPILER_RT_HAS_FNO_LTO_FLAG)
 check_cxx_compiler_flag("-Werror -msse3" COMPILER_RT_HAS_MSSE3_FLAG)
-check_cxx_compiler_flag("-Werror -msse4.2"   COMPILER_RT_HAS_MSSE4_2_FLAG)
 check_cxx_compiler_flag(--sysroot=.  COMPILER_RT_HAS_SYSROOT_FLAG)
 
 if(NOT WIN32 AND NOT CYGWIN)


Index: lib/scudo/CMakeLists.txt
===
--- lib/scudo/CMakeLists.txt
+++ lib/scudo/CMakeLists.txt
@@ -4,7 +4,6 @@
 
 set(SCUDO_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF SCUDO_CFLAGS)
-append_list_if(COMPILER_RT_HAS_MSSE4_2_FLAG -msse4.2 SCUDO_CFLAGS)
 
 set(SCUDO_SOURCES
   scudo_allocator.cpp
Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -29,7 +29,6 @@
 check_cxx_compiler_flag(-ftls-model=initial-exec COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC)
 check_cxx_compiler_flag(-fno-lto COMPILER_RT_HAS_FNO_LTO_FLAG)
 check_cxx_compiler_flag("-Werror -msse3" COMPILER_RT_HAS_MSSE3_FLAG)
-check_cxx_compiler_flag("-Werror -msse4.2"   COMPILER_RT_HAS_MSSE4_2_FLAG)
 check_cxx_compiler_flag(--sysroot=.  COMPILER_RT_HAS_SYSROOT_FLAG)
 
 if(NOT WIN32 AND NOT CYGWIN)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse4.2 flag implicitly

2017-01-05 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

@cryptoad good to go then?


https://reviews.llvm.org/D28304



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


[PATCH] D28242: [ubsan] Minimize size of data for type_mismatch (Redo of D19667)

2017-01-05 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

LGTM, but I am not the owner.


https://reviews.llvm.org/D28242



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


r291179 - Add vec_insert4b and vec_extract4b functions to altivec.h

2017-01-05 Thread Sean Fertile via cfe-commits
Author: sfertile
Date: Thu Jan  5 15:43:30 2017
New Revision: 291179

URL: http://llvm.org/viewvc/llvm-project?rev=291179&view=rev
Log:
Add vec_insert4b and vec_extract4b functions to altivec.h

Add builtins for the functions and custom codegen mapping the builtins to their
corresponding intrinsics and handling the endian related swapping.

https://reviews.llvm.org/D26546

Added:
cfe/trunk/test/CodeGen/builtins-ppc-error.c
cfe/trunk/test/CodeGen/builtins-ppc-extractword-error.c
cfe/trunk/test/CodeGen/builtins-ppc-insertword-error.c
Modified:
cfe/trunk/include/clang/Basic/BuiltinsPPC.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/altivec.h
cfe/trunk/test/CodeGen/builtins-ppc-p9vector.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsPPC.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsPPC.def?rev=291179&r1=291178&r2=291179&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsPPC.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsPPC.def Thu Jan  5 15:43:30 2017
@@ -417,6 +417,9 @@ BUILTIN(__builtin_vsx_xvcvhpsp, "V4fV8Us
 BUILTIN(__builtin_vsx_xvtstdcdp, "V2ULLiV2dIi", "")
 BUILTIN(__builtin_vsx_xvtstdcsp, "V4UiV4fIi", "")
 
+BUILTIN(__builtin_vsx_insertword, "V16UcV4UiV16UcIi", "")
+BUILTIN(__builtin_vsx_extractuword, "V2ULLiV16UcIi", "")
+
 // HTM builtins
 BUILTIN(__builtin_tbegin, "UiUIi", "")
 BUILTIN(__builtin_tend, "UiUIi", "")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=291179&r1=291178&r2=291179&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Jan  5 15:43:30 2017
@@ -35,6 +35,11 @@ using namespace clang;
 using namespace CodeGen;
 using namespace llvm;
 
+static
+int64_t clamp(int64_t Value, int64_t Low, int64_t High) {
+  return std::min(High, std::max(Low, Value));
+}
+
 /// getBuiltinLibFunction - Given a builtin id for a function like
 /// "__builtin_fabsf", return a Function* for "fabsf".
 llvm::Constant *CodeGenModule::getBuiltinLibFunction(const FunctionDecl *FD,
@@ -8191,6 +8196,85 @@ Value *CodeGenFunction::EmitPPCBuiltinEx
 llvm_unreachable("Unknown FMA operation");
 return nullptr; // Suppress no-return warning
   }
+
+  case PPC::BI__builtin_vsx_insertword: {
+llvm::Function *F = CGM.getIntrinsic(Intrinsic::ppc_vsx_xxinsertw);
+
+// Third argument is a compile time constant int. It must be clamped to
+// to the range [0, 12].
+ConstantInt *ArgCI = dyn_cast(Ops[2]);
+assert(ArgCI &&
+   "Third arg to xxinsertw intrinsic must be constant integer");
+const int64_t MaxIndex = 12;
+int64_t Index = clamp(ArgCI->getSExtValue(), 0, MaxIndex);
+
+// The builtin semantics don't exactly match the xxinsertw instructions
+// semantics (which ppc_vsx_xxinsertw follows). The builtin extracts the
+// word from the first argument, and inserts it in the second argument. The
+// instruction extracts the word from its second input register and inserts
+// it into its first input register, so swap the first and second 
arguments.
+std::swap(Ops[0], Ops[1]);
+
+// Need to cast the second argument from a vector of unsigned int to a
+// vector of long long.
+Ops[1] = Builder.CreateBitCast(Ops[1], llvm::VectorType::get(Int64Ty, 2));
+
+if (getTarget().isLittleEndian()) {
+  // Create a shuffle mask of (1, 0)
+  Constant *ShuffleElts[2] = { ConstantInt::get(Int32Ty, 1),
+   ConstantInt::get(Int32Ty, 0)
+ };
+  Constant *ShuffleMask = llvm::ConstantVector::get(ShuffleElts);
+
+  // Reverse the double words in the vector we will extract from.
+  Ops[0] = Builder.CreateBitCast(Ops[0], llvm::VectorType::get(Int64Ty, 
2));
+  Ops[0] = Builder.CreateShuffleVector(Ops[0], Ops[0], ShuffleMask);
+
+  // Reverse the index.
+  Index = MaxIndex - Index;
+}
+
+// Intrinsic expects the first arg to be a vector of int.
+Ops[0] = Builder.CreateBitCast(Ops[0], llvm::VectorType::get(Int32Ty, 4));
+Ops[2] = ConstantInt::getSigned(Int32Ty, Index);
+return Builder.CreateCall(F, Ops);
+  }
+
+  case PPC::BI__builtin_vsx_extractuword: {
+llvm::Function *F = CGM.getIntrinsic(Intrinsic::ppc_vsx_xxextractuw);
+
+// Intrinsic expects the first argument to be a vector of doublewords.
+Ops[0] = Builder.CreateBitCast(Ops[0], llvm::VectorType::get(Int64Ty, 2));
+
+// The second argument is a compile time constant int that needs to
+// be clamped to the range [0, 12].
+ConstantInt *ArgCI = dyn_cast(Ops[1]);
+assert(ArgCI &&
+   "Second Arg to xxextractuw intrinsic must be a constant integer!");
+const int64_t MaxIndex = 12;
+in

[PATCH] D28365: [Driver] Updated for Visual Studio 2017

2017-01-05 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood updated this revision to Diff 83303.
hamzasood added a comment.

- Fixed an error in retrieving a toolchain path from the registry.
- Updated the base revision.


https://reviews.llvm.org/D28365

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/MSVCToolChain.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -10809,16 +10809,10 @@
   const char *Exe,
   const char *ClangProgramPath) {
   const auto &MSVC = static_cast(TC);
-  std::string visualStudioBinDir;
-  if (MSVC.getVisualStudioBinariesFolder(ClangProgramPath,
- visualStudioBinDir)) {
-SmallString<128> FilePath(visualStudioBinDir);
-llvm::sys::path::append(FilePath, Exe);
-if (llvm::sys::fs::can_execute(FilePath.c_str()))
-  return FilePath.str();
-  }
-
-  return Exe;
+  SmallString<128> FilePath(MSVC.getSubDirectoryPath(toolchains::MSVCToolChain
+ ::SubDirectoryType::Bin));
+  llvm::sys::path::append(FilePath, Exe);
+  return (llvm::sys::fs::can_execute(FilePath) ? FilePath.str() : Exe);
 }
 
 void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA,
@@ -10843,33 +10837,17 @@
 // did not run vcvarsall), try to build a consistent link environment.  If
 // the environment variable is set however, assume the user knows what
 // they're doing.
-std::string VisualStudioDir;
 const auto &MSVC = static_cast(TC);
-if (MSVC.getVisualStudioInstallDir(VisualStudioDir)) {
-  SmallString<128> LibDir(VisualStudioDir);
-  llvm::sys::path::append(LibDir, "VC", "lib");
-  switch (MSVC.getArch()) {
-  case llvm::Triple::x86:
-// x86 just puts the libraries directly in lib
-break;
-  case llvm::Triple::x86_64:
-llvm::sys::path::append(LibDir, "amd64");
-break;
-  case llvm::Triple::arm:
-llvm::sys::path::append(LibDir, "arm");
-break;
-  default:
-break;
-  }
-  CmdArgs.push_back(
-  Args.MakeArgString(std::string("-libpath:") + LibDir.c_str()));
+CmdArgs.push_back(Args.MakeArgString(
+  std::string("-libpath:")
+  + MSVC.getSubDirectoryPath(toolchains::MSVCToolChain
+ ::SubDirectoryType::Lib)));
 
-  if (MSVC.useUniversalCRT(VisualStudioDir)) {
-std::string UniversalCRTLibPath;
-if (MSVC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
-  CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") +
-   UniversalCRTLibPath));
-  }
+if (MSVC.useUniversalCRT()) {
+  std::string UniversalCRTLibPath;
+  if (MSVC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
+CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:")
+ + UniversalCRTLibPath));
 }
 
 std::string WindowsSdkLibPath;
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -1155,6 +1155,13 @@
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
 
+  enum class SubDirectoryType {
+Bin,
+Include,
+Lib,
+  };
+  std::string getSubDirectoryPath(SubDirectoryType Type) const;
+
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
 llvm::opt::ArgStringList &CC1Args) const override;
@@ -1163,19 +1170,12 @@
   llvm::opt::ArgStringList &CC1Args) const override;
 
   void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
-  llvm::opt::ArgStringList &CC1Args) const override;
+  llvm::opt::ArgStringList &CC1Args) const override;
 
-  bool getWindowsSDKDir(std::string &path, int &major,
-std::string &windowsSDKIncludeVersion,
-std::string &windowsSDKLibVersion) const;
   bool getWindowsSDKLibraryPath(std::string &path) const;
   /// \brief Check if Universal CRT should be used if available
-  bool useUniversalCRT(std::string &visualStudioDir) const;
-  bool getUniversalCRTSdkDir(std::string &path, std::string &ucrtVersion) const;
+  bool useUniversalCRT() const;
   bool getUniversalCRTLibraryPath(std::string &path) const;
-  bool getVisualStudioInstallDir(std::string &path) const;
-  bool getVisualStudioBinariesFolder(const char *clangProgramPath,
- std::string &path) const;
   VersionTuple
   computeMSVCVersion(const Driver *D,
  const llvm::opt::ArgList &Args) const override;
@@ -1196,7 +1196,11 @@
 
   Tool *buildLinker() co

[PATCH] D28365: [Driver] Updated for Visual Studio 2017

2017-01-05 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth added a comment.

(I could be missing something because the diff doesn't have much context.)

If I'm reading this right, it looks like it will no longer search the PATH in 
order to find cl.exe.  If that's the case, then I'm mildly worried about this 
change in behavior.  I know I have multiple versions of VS installed, and 
commonly select one just by moving its bin directory to the head of PATH.  The 
old behavior would find that one (which is used for things like defaulting 
-fms-compatibility-version) while the new behavior will find the newest one 
installed on the machine.

That's not necessarily a deal breaker, but it's an important change for Windows 
developers to be aware of.


https://reviews.llvm.org/D28365



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


Re: r291179 - Add vec_insert4b and vec_extract4b functions to altivec.h

2017-01-05 Thread Evgenii Stepanov via cfe-commits
Tests on linux/x86_64 are failing with:
fatal error: error in backend: Cannot select: intrinsic %llvm.ppc.vsx.xxinsertw

On Thu, Jan 5, 2017 at 1:43 PM, Sean Fertile via cfe-commits
 wrote:
> Author: sfertile
> Date: Thu Jan  5 15:43:30 2017
> New Revision: 291179
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291179&view=rev
> Log:
> Add vec_insert4b and vec_extract4b functions to altivec.h
>
> Add builtins for the functions and custom codegen mapping the builtins to 
> their
> corresponding intrinsics and handling the endian related swapping.
>
> https://reviews.llvm.org/D26546
>
> Added:
> cfe/trunk/test/CodeGen/builtins-ppc-error.c
> cfe/trunk/test/CodeGen/builtins-ppc-extractword-error.c
> cfe/trunk/test/CodeGen/builtins-ppc-insertword-error.c
> Modified:
> cfe/trunk/include/clang/Basic/BuiltinsPPC.def
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/lib/Headers/altivec.h
> cfe/trunk/test/CodeGen/builtins-ppc-p9vector.c
>
> Modified: cfe/trunk/include/clang/Basic/BuiltinsPPC.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsPPC.def?rev=291179&r1=291178&r2=291179&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/BuiltinsPPC.def (original)
> +++ cfe/trunk/include/clang/Basic/BuiltinsPPC.def Thu Jan  5 15:43:30 2017
> @@ -417,6 +417,9 @@ BUILTIN(__builtin_vsx_xvcvhpsp, "V4fV8Us
>  BUILTIN(__builtin_vsx_xvtstdcdp, "V2ULLiV2dIi", "")
>  BUILTIN(__builtin_vsx_xvtstdcsp, "V4UiV4fIi", "")
>
> +BUILTIN(__builtin_vsx_insertword, "V16UcV4UiV16UcIi", "")
> +BUILTIN(__builtin_vsx_extractuword, "V2ULLiV16UcIi", "")
> +
>  // HTM builtins
>  BUILTIN(__builtin_tbegin, "UiUIi", "")
>  BUILTIN(__builtin_tend, "UiUIi", "")
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=291179&r1=291178&r2=291179&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Jan  5 15:43:30 2017
> @@ -35,6 +35,11 @@ using namespace clang;
>  using namespace CodeGen;
>  using namespace llvm;
>
> +static
> +int64_t clamp(int64_t Value, int64_t Low, int64_t High) {
> +  return std::min(High, std::max(Low, Value));
> +}
> +
>  /// getBuiltinLibFunction - Given a builtin id for a function like
>  /// "__builtin_fabsf", return a Function* for "fabsf".
>  llvm::Constant *CodeGenModule::getBuiltinLibFunction(const FunctionDecl *FD,
> @@ -8191,6 +8196,85 @@ Value *CodeGenFunction::EmitPPCBuiltinEx
>  llvm_unreachable("Unknown FMA operation");
>  return nullptr; // Suppress no-return warning
>}
> +
> +  case PPC::BI__builtin_vsx_insertword: {
> +llvm::Function *F = CGM.getIntrinsic(Intrinsic::ppc_vsx_xxinsertw);
> +
> +// Third argument is a compile time constant int. It must be clamped to
> +// to the range [0, 12].
> +ConstantInt *ArgCI = dyn_cast(Ops[2]);
> +assert(ArgCI &&
> +   "Third arg to xxinsertw intrinsic must be constant integer");
> +const int64_t MaxIndex = 12;
> +int64_t Index = clamp(ArgCI->getSExtValue(), 0, MaxIndex);
> +
> +// The builtin semantics don't exactly match the xxinsertw instructions
> +// semantics (which ppc_vsx_xxinsertw follows). The builtin extracts the
> +// word from the first argument, and inserts it in the second argument. 
> The
> +// instruction extracts the word from its second input register and 
> inserts
> +// it into its first input register, so swap the first and second 
> arguments.
> +std::swap(Ops[0], Ops[1]);
> +
> +// Need to cast the second argument from a vector of unsigned int to a
> +// vector of long long.
> +Ops[1] = Builder.CreateBitCast(Ops[1], llvm::VectorType::get(Int64Ty, 
> 2));
> +
> +if (getTarget().isLittleEndian()) {
> +  // Create a shuffle mask of (1, 0)
> +  Constant *ShuffleElts[2] = { ConstantInt::get(Int32Ty, 1),
> +   ConstantInt::get(Int32Ty, 0)
> + };
> +  Constant *ShuffleMask = llvm::ConstantVector::get(ShuffleElts);
> +
> +  // Reverse the double words in the vector we will extract from.
> +  Ops[0] = Builder.CreateBitCast(Ops[0], llvm::VectorType::get(Int64Ty, 
> 2));
> +  Ops[0] = Builder.CreateShuffleVector(Ops[0], Ops[0], ShuffleMask);
> +
> +  // Reverse the index.
> +  Index = MaxIndex - Index;
> +}
> +
> +// Intrinsic expects the first arg to be a vector of int.
> +Ops[0] = Builder.CreateBitCast(Ops[0], llvm::VectorType::get(Int32Ty, 
> 4));
> +Ops[2] = ConstantInt::getSigned(Int32Ty, Index);
> +return Builder.CreateCall(F, Ops);
> +  }
> +
> +  case PPC::BI__builtin_vsx_extractuword: {
> +llvm::Function *F = CGM.getIntrinsic(Intrinsic::ppc_vsx_xxextractuw);
> +
> +// Intrinsic expects the first arg

r291184 - IntrusiveRefCntPtr -> std::shared_ptr for CompilerInvocationBase and CodeCompleteConsumer

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 16:19:11 2017
New Revision: 291184

URL: http://llvm.org/viewvc/llvm-project?rev=291184&view=rev
Log:
IntrusiveRefCntPtr -> std::shared_ptr for CompilerInvocationBase and 
CodeCompleteConsumer

Modified:
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/include/clang/Frontend/CompilerInstance.h
cfe/trunk/include/clang/Frontend/CompilerInvocation.h
cfe/trunk/include/clang/Frontend/Utils.h
cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
cfe/trunk/include/clang/Tooling/Tooling.h
cfe/trunk/lib/ARCMigrate/ARCMT.cpp
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
cfe/trunk/lib/Tooling/Tooling.cpp
cfe/trunk/tools/c-index-test/core_main.cpp
cfe/trunk/tools/clang-import-test/clang-import-test.cpp
cfe/trunk/tools/diagtool/ShowEnabledWarnings.cpp
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
cfe/trunk/tools/libclang/CXTranslationUnit.h
cfe/trunk/tools/libclang/Indexing.cpp
cfe/trunk/unittests/AST/ExternalASTSourceTest.cpp
cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp
cfe/trunk/unittests/Frontend/FrontendActionTest.cpp

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=291184&r1=291183&r2=291184&view=diff
==
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Thu Jan  5 16:19:11 2017
@@ -108,8 +108,8 @@ private:
 
   /// Optional owned invocation, just used to make the invocation used in
   /// LoadFromCommandLine available.
-  IntrusiveRefCntPtr Invocation;
-  
+  std::shared_ptr Invocation;
+
   // OnlyLocalDecls - when true, walking this AST should only visit 
declarations
   // that come from the AST itself, not from included precompiled headers.
   // FIXME: This is temporary; eventually, CIndex will always do this.
@@ -358,22 +358,21 @@ public:
   }
   
   /// \brief Retrieve the allocator used to cache global code completions.
-  IntrusiveRefCntPtr
+  std::shared_ptr
   getCachedCompletionAllocator() {
 return CachedCompletionAllocator;
   }
 
   CodeCompletionTUInfo &getCodeCompletionTUInfo() {
 if (!CCTUInfo)
-  CCTUInfo.reset(new CodeCompletionTUInfo(
-new 
GlobalCodeCompletionAllocator));
+  CCTUInfo = llvm::make_unique(
+  std::make_shared());
 return *CCTUInfo;
   }
 
 private:
   /// \brief Allocator used to store cached code completions.
-  IntrusiveRefCntPtr
-CachedCompletionAllocator;
+  std::shared_ptr CachedCompletionAllocator;
 
   std::unique_ptr CCTUInfo;
 
@@ -702,11 +701,11 @@ public:
   /// remapped contents of that file.
   typedef std::pair RemappedFile;
 
-  /// \brief Create a ASTUnit. Gets ownership of the passed 
CompilerInvocation. 
-  static ASTUnit *create(CompilerInvocation *CI,
- IntrusiveRefCntPtr Diags,
- bool CaptureDiagnostics,
- bool UserFilesAreVolatile);
+  /// \brief Create a ASTUnit. Gets ownership of the passed CompilerInvocation.
+  static std::unique_ptr
+  create(std::shared_ptr CI,
+ IntrusiveRefCntPtr Diags, bool CaptureDiagnostics,
+ bool UserFilesAreVolatile);
 
   /// \brief Create a ASTUnit from an AST file.
   ///
@@ -771,7 +770,7 @@ public:
   /// created ASTUnit was passed in \p Unit then the caller can check that.
   ///
   static ASTUnit *LoadFromCompilerInvocationAction(
-  CompilerInvocation *CI,
+  std::shared_ptr CI,
   std::shared_ptr PCHContainerOps,
   IntrusiveRefCntPtr Diags,
   FrontendAction *Action = nullptr, ASTUnit *Unit = nullptr,
@@ -798,7 +797,7 @@ public:
   // FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we
   // shouldn't need to specify them at construction time.
   static std::unique_ptr LoadFromCompilerInvocation(
-  CompilerInvocation *CI,
+  std::shared_ptr CI,
   std::shared_ptr PCHContainerOps,
   IntrusiveRefCntPtr Diags, FileManager *FileMgr,
   bool OnlyLocalDecls = false, bool CaptureDiagnostics = false,

Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=291184&r1=291183&r2=291184&view=diff
==
--- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Thu Jan  5 16:19:11 2017
@@ -70,7 +70,7 @@ class TargetInfo;
 /// and a lon

[PATCH] D28231: -Wunreachable-code: Avoid multiple diagnostics that are triggered by the same source range and fix the unary operator fixit source range

2017-01-05 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: lib/Analysis/ReachableCode.cpp:229
+  if (SilenceableCondValNotSet && SilenceableCondVal->getBegin().isValid())
+*SilenceableCondVal = UO->getSourceRange();
+  return UO->getOpcode() == UO_LNot && IsSubExprConfigValue;

Thanks, that fixed the incorrect fixit. The patch looks good to me, but there 
are still cases in which the suggestions clang makes are not accurate. Perhaps 
you can leave a FIXME somewhere so that we don't forget to fix it later?

For example, if we change the condition in the test case to this,

```
if (!(s->p && 0))
```

, clang suggests enclosing the entire expression with a parenthesis (caret 
points to "!"), but the warning will not go away unless the parenthesis is 
around "0".

The second example is in function unaryOpFixit in warn-unreachable.c. clang 
suggests enclosing "-1" with a parenthesis, but it still warns after putting 
the parenthesis around "-1" or "1".


Repository:
  rL LLVM

https://reviews.llvm.org/D28231



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


r291185 - Fix examples for recent shared_ptrification

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 16:36:44 2017
New Revision: 291185

URL: http://llvm.org/viewvc/llvm-project?rev=291185&view=rev
Log:
Fix examples for recent shared_ptrification

Modified:
cfe/trunk/examples/clang-interpreter/main.cpp

Modified: cfe/trunk/examples/clang-interpreter/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/clang-interpreter/main.cpp?rev=291185&r1=291184&r2=291185&view=diff
==
--- cfe/trunk/examples/clang-interpreter/main.cpp (original)
+++ cfe/trunk/examples/clang-interpreter/main.cpp Thu Jan  5 16:36:44 2017
@@ -145,7 +145,7 @@ int main(int argc, const char **argv, ch
 
   // Create a compiler instance to handle the actual work.
   CompilerInstance Clang;
-  Clang.setInvocation(CI.release());
+  Clang.setInvocation(std::move(CI));
 
   // Create the compilers actual diagnostics engine.
   Clang.createDiagnostics();


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


[PATCH] D28381: [WebAssembly] Always inline atomics

2017-01-05 Thread Jacob Gravelle via Phabricator via cfe-commits
jgravelle-google created this revision.
jgravelle-google added reviewers: dschuff, sunfish.
jgravelle-google added a subscriber: cfe-commits.
Herald added a subscriber: jfb.

Wasm MVP doesn't have any mechanism to respect atomicity. Skip emitting
libcalls for the time being.


https://reviews.llvm.org/D28381

Files:
  lib/Basic/Targets.cpp
  test/Preprocessor/init.c


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8610,7 +8610,7 @@
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_INT_LOCK_FREE 2
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 1
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LONG_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_POINTER_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_SHORT_LOCK_FREE 2
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -8137,7 +8137,8 @@
   explicit WebAssembly32TargetInfo(const llvm::Triple &T,
const TargetOptions &Opts)
   : WebAssemblyTargetInfo(T, Opts) {
-MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
+// WebAssembly MVP has no way to express atomics, so always inline them
+MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128");
   }
 


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8610,7 +8610,7 @@
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_INT_LOCK_FREE 2
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 1
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LONG_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_POINTER_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_SHORT_LOCK_FREE 2
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -8137,7 +8137,8 @@
   explicit WebAssembly32TargetInfo(const llvm::Triple &T,
const TargetOptions &Opts)
   : WebAssemblyTargetInfo(T, Opts) {
-MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
+// WebAssembly MVP has no way to express atomics, so always inline them
+MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128");
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r291186 - Fix for shared_ptrification in Clang

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 16:44:07 2017
New Revision: 291186

URL: http://llvm.org/viewvc/llvm-project?rev=291186&view=rev
Log:
Fix for shared_ptrification in Clang

Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
clang-tools-extra/trunk/include-fixer/IncludeFixer.h

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=291186&r1=291185&r2=291186&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Thu Jan  5 16:44:07 
2017
@@ -82,14 +82,15 @@ IncludeFixerActionFactory::IncludeFixerA
 IncludeFixerActionFactory::~IncludeFixerActionFactory() = default;
 
 bool IncludeFixerActionFactory::runInvocation(
-clang::CompilerInvocation *Invocation, clang::FileManager *Files,
+std::shared_ptr Invocation,
+clang::FileManager *Files,
 std::shared_ptr PCHContainerOps,
 clang::DiagnosticConsumer *Diagnostics) {
   assert(Invocation->getFrontendOpts().Inputs.size() == 1);
 
   // Set up Clang.
   clang::CompilerInstance Compiler(PCHContainerOps);
-  Compiler.setInvocation(Invocation);
+  Compiler.setInvocation(std::move(Invocation));
   Compiler.setFileManager(Files);
 
   // Create the compiler's actual diagnostics engine. We want to drop all

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.h?rev=291186&r1=291185&r2=291186&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.h (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.h Thu Jan  5 16:44:07 
2017
@@ -42,7 +42,7 @@ public:
   ~IncludeFixerActionFactory() override;
 
   bool
-  runInvocation(clang::CompilerInvocation *Invocation,
+  runInvocation(std::shared_ptr Invocation,
 clang::FileManager *Files,
 std::shared_ptr PCHContainerOps,
 clang::DiagnosticConsumer *Diagnostics) override;


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


[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2017-01-05 Thread Firat Kasmis via Phabricator via cfe-commits
firolino added inline comments.



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:34
+  // a tag declaration (e.g. struct, class etc.):
+  // class A { } Object1, Object2;  <-- won't be matched
+  Finder->addMatcher(

aaron.ballman wrote:
> firolino wrote:
> > aaron.ballman wrote:
> > > firolino wrote:
> > > > aaron.ballman wrote:
> > > > > firolino wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > firolino wrote:
> > > > > > > > firolino wrote:
> > > > > > > > > firolino wrote:
> > > > > > > > > > firolino wrote:
> > > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > > firolino wrote:
> > > > > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > > > > Why do we not want to match this?
> > > > > > > > > > > > > If we decide, whether we transform 
> > > > > > > > > > > > > ```
> > > > > > > > > > > > > class A { 
> > > > > > > > > > > > > } Object1, Object2;
> > > > > > > > > > > > > ``` 
> > > > > > > > > > > > > to
> > > > > > > > > > > > > ```
> > > > > > > > > > > > > class A { 
> > > > > > > > > > > > > } Object1, 
> > > > > > > > > > > > > Object2;
> > > > > > > > > > > > > ``` 
> > > > > > > > > > > > > or
> > > > > > > > > > > > > ```
> > > > > > > > > > > > > class A { 
> > > > > > > > > > > > > } 
> > > > > > > > > > > > > Object1, 
> > > > > > > > > > > > > Object2;
> > > > > > > > > > > > > ``` 
> > > > > > > > > > > > > I might consider adding support for it. Moreover, 
> > > > > > > > > > > > > this kind of definition is usually seen globally and 
> > > > > > > > > > > > > I don't know how to handle globals yet. See 
> > > > > > > > > > > > > http://lists.llvm.org/pipermail/cfe-dev/2015-November/046262.html
> > > > > > > > > > > > I think this should be handled. It can be handled in 
> > > > > > > > > > > > either of the forms you show, or by saying:
> > > > > > > > > > > > ```
> > > > > > > > > > > > A Object1;
> > > > > > > > > > > > A Object2;
> > > > > > > > > > > > ```
> > > > > > > > > > > > If all of these turn out to be a problem, we can still 
> > > > > > > > > > > > diagnose without providing a fixit.
> > > > > > > > > > > > 
> > > > > > > > > > > > As for globals in general, they can be handled in a 
> > > > > > > > > > > > separate patch once we figure out the declaration 
> > > > > > > > > > > > grouping.
> > > > > > > > > > > OK. I will try to split the object definition from the 
> > > > > > > > > > > class definition, as you have suggested. Thus, I can kick 
> > > > > > > > > > > out the tagDecl-matcher as well. If there is no easy way 
> > > > > > > > > > > to do this, it will be reported anyway but without a 
> > > > > > > > > > > fixit.
> > > > > > > > > > > 
> > > > > > > > > > > Note for me: Update documentation!
> > > > > > > > > > What about
> > > > > > > > > > ```
> > > > > > > > > > struct S {
> > > > > > > > > > } S1;
> > > > > > > > > > ```
> > > > > > > > > > I would like to report this too, since two names are being 
> > > > > > > > > > declared here. `S` and `S1`. What do you think?
> > > > > > > > > ```
> > > > > > > > > struct {
> > > > > > > > > } nn1, nn2;
> > > > > > > > > ```
> > > > > > > > > Shall we ignore anonymous definitions?
> > > > > > > > To be more precise: Warn and provide a fixit for `struct S {} 
> > > > > > > > S1`. Only warn for `struct {} nn1, nn2`.
> > > > > > > > What about
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > struct S {
> > > > > > > > } S1;
> > > > > > > > ```
> > > > > > > > I would like to report this too, since two names are being 
> > > > > > > > declared here. S and S1. What do you think?
> > > > > > > 
> > > > > > > I don't think that this should be diagnosed. For one, this is a 
> > > > > > > relatively common pattern (arguably more common than `struct S { 
> > > > > > > } S1, S2;`), but also, it names two very distinct entities (a 
> > > > > > > type and a variable).
> > > > > > > 
> > > > > > > > ```
> > > > > > > > struct {
> > > > > > > > } nn1, nn2;
> > > > > > > >```
> > > > > > > > Shall we ignore anonymous definitions?
> > > > > > > 
> > > > > > > Yes, we basically have to.
> > > > > > > 
> > > > > > Transforming
> > > > > > ```
> > > > > > typedef struct X { int t; } X, Y;
> > > > > > ```
> > > > > > to
> > > > > > ```
> > > > > > typedef struct X { int t; };
> > > > > > typedef X X;
> > > > > > typedef X Y;
> > > > > > ```
> > > > > > will be valid, but looks odd.
> > > > > I am on the fence about this transformation -- it does not declare 
> > > > > new objects, but instead declares new types. A very common pattern in 
> > > > > some libraries (such as the Win32 SDK) is to declare:
> > > > > ```
> > > > > typedef struct Blah {
> > > > > 
> > > > > } Blah, *PBlah, **PPBlah;
> > > > > ```
> > > > > Because of that pattern, diagnosing the above typedef is likely to be 
> > > > > very chatty in some projects, and I don't know that the fixit 
> > > > > provides much real benefit for types.
> > > > > 
> > > > > At least for the CERT DCL04-C

  1   2   >