[libcxx] r268850 - Fix memory_resource build for _LIBCPP_HAS_NO_THREADS

2016-05-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat May  7 00:37:31 2016
New Revision: 268850

URL: http://llvm.org/viewvc/llvm-project?rev=268850&view=rev
Log:
Fix memory_resource build for _LIBCPP_HAS_NO_THREADS

Modified:
libcxx/trunk/src/experimental/memory_resource.cpp

Modified: libcxx/trunk/src/experimental/memory_resource.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/memory_resource.cpp?rev=268850&r1=268849&r2=268850&view=diff
==
--- libcxx/trunk/src/experimental/memory_resource.cpp (original)
+++ libcxx/trunk/src/experimental/memory_resource.cpp Sat May  7 00:37:31 2016
@@ -11,7 +11,7 @@
 
 #ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER
 #include "atomic"
-#else
+#elif !defined(_LIBCPP_HAS_NO_THREADS)
 #include "mutex"
 #endif
 
@@ -100,7 +100,7 @@ __default_memory_resource(bool set = fal
 return _VSTD::atomic_load_explicit(
 &__res, memory_order::memory_order_acquire);
 }
-#else
+#elif !defined(_LIBCPP_HAS_NO_THREADS)
 static memory_resource * res = &res_init.resources.new_delete_res;
 static mutex res_lock;
 if (set) {
@@ -113,6 +113,16 @@ __default_memory_resource(bool set = fal
 lock_guard guard(res_lock);
 return res;
 }
+#else
+static memory_resource* res = &res_init.resources.new_delete_res;
+if (set) {
+new_res = new_res ? new_res : new_delete_resource();
+memory_resource * old_res = res;
+res = new_res;
+return old_res;
+} else {
+return res;
+}
 #endif
 }
 


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


Re: [PATCH] D18347: [PATCH] Fix thread_annotation negtest for thread safety.

2016-05-06 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

This was committed in r264191.


http://reviews.llvm.org/D18347



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


[PATCH] D20045: [ObjC][CodeGen] Remove an assert that is no longer correct.

2016-05-06 Thread Akira Hatanaka via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rjmccall, rsmith, manmanren.
ahatanak added a subscriber: cfe-commits.

The assert was committed in r183967. After r231508 made changes to promote 
constant temporaries to globals, the assert fires when a std::initializer_list 
is constructed using Objective-C string literals:

void foo1() {
  std::vector strs = {@"a", @"b"};
}

rdar://problem/25504992
rdar://problem/25955179

http://reviews.llvm.org/D20045

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGenObjCXX/arc-cxx11-init-list.mm

Index: test/CodeGenObjCXX/arc-cxx11-init-list.mm
===
--- test/CodeGenObjCXX/arc-cxx11-init-list.mm
+++ test/CodeGenObjCXX/arc-cxx11-init-list.mm
@@ -1,5 +1,11 @@
 // RUN: %clang_cc1 -triple armv7-ios5.0 -std=c++11 -fobjc-arc -Os -emit-llvm 
-o - %s | FileCheck %s
 
+// CHECK: @[[STR0:.*]] = private unnamed_addr constant [5 x i8] c"str0\00", 
section "__TEXT,__cstring,cstring_literals"
+// CHECK: @[[UNNAMED_CFSTRING0:.*]] = private constant 
%struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x 
i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* 
getelementptr inbounds ([5 x i8], [5 x i8]* @[[STR0]], i32 0, i32 0), i32 4 }, 
section "__DATA,__cfstring"
+// CHECK: @[[STR1:.*]] = private unnamed_addr constant [5 x i8] c"str1\00", 
section "__TEXT,__cstring,cstring_literals"
+// CHECK: @[[UNNAMED_CFSTRING1:.*]] = private constant 
%struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x 
i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* 
getelementptr inbounds ([5 x i8], [5 x i8]* @[[STR1]], i32 0, i32 0), i32 4 }, 
section "__DATA,__cfstring"
+// CHECK: @[[REFTMP:.*]] = private constant [2 x i8*] [i8* bitcast 
(%struct.__NSConstantString_tag* @[[UNNAMED_CFSTRING0]] to i8*), i8* bitcast 
(%struct.__NSConstantString_tag* @[[UNNAMED_CFSTRING1]] to i8*)]
+
 typedef __SIZE_TYPE__ size_t;
 
 namespace std {
@@ -32,6 +38,17 @@
 // CHECK-NEXT: store i8* [[INSTANCE]], i8** [[CAST]],
 // CHECK: call void @objc_release(i8* {{.*}})
 
+std::initializer_list foo1() {
+  return {@"str0", @"str1"};
+}
+
+// CHECK: define void @_Z4foo1v(%"class.std::initializer_list.0"* {{.*}} 
%[[AGG_RESULT:.*]])
+// CHECK: %[[BEGIN:.*]] = getelementptr inbounds 
%"class.std::initializer_list.0", %"class.std::initializer_list.0"* 
%[[AGG_RESULT]], i32 0, i32 0
+// CHECK: store i8** getelementptr inbounds ([2 x i8*], [2 x i8*]* 
@[[REFTMP]], i32 0, i32 0), i8*** %[[BEGIN]]
+// CHECK: %[[SIZE:.*]] = getelementptr inbounds 
%"class.std::initializer_list.0", %"class.std::initializer_list.0"* 
%[[AGG_RESULT]], i32 0, i32 1
+// CHECK: store i32 2, i32* %[[SIZE]]
+// CHECK: ret void
+
 void external();
 
 extern "C" void extended() {
@@ -49,4 +66,3 @@
 // CHECK: [[INSTANCE:%.*]] = {{.*}} call i8* bitcast (i8* (i8*, i8*, ...)* 
@objc_msgSend to i8* (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}})
 // CHECK-NEXT: store i8* [[INSTANCE]], i8** bitcast ([1 x %0*]* @_ZGR2il_ to 
i8**)
 // CHECK: {{.*}} call void @objc_autoreleasePoolPop(i8* [[POOL]])
-
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -360,9 +360,10 @@
ConvertTypeForMem(E->getType())
  ->getPointerTo(Object.getAddressSpace())),
Object.getAlignment());
-  // We should not have emitted the initializer for this temporary as a
-  // constant.
-  assert(!Var->hasInitializer());
+
+  if (Var->hasInitializer())
+return MakeAddrLValue(Object, M->getType(), AlignmentSource::Decl);
+
   Var->setInitializer(CGM.EmitNullConstant(E->getType()));
 }
 LValue RefTempDst = MakeAddrLValue(Object, M->getType(),


Index: test/CodeGenObjCXX/arc-cxx11-init-list.mm
===
--- test/CodeGenObjCXX/arc-cxx11-init-list.mm
+++ test/CodeGenObjCXX/arc-cxx11-init-list.mm
@@ -1,5 +1,11 @@
 // RUN: %clang_cc1 -triple armv7-ios5.0 -std=c++11 -fobjc-arc -Os -emit-llvm -o - %s | FileCheck %s
 
+// CHECK: @[[STR0:.*]] = private unnamed_addr constant [5 x i8] c"str0\00", section "__TEXT,__cstring,cstring_literals"
+// CHECK: @[[UNNAMED_CFSTRING0:.*]] = private constant %struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @[[STR0]], i32 0, i32 0), i32 4 }, section "__DATA,__cfstring"
+// CHECK: @[[STR1:.*]] = private unnamed_addr constant [5 x i8] c"str1\00", section "__TEXT,__cstring,cstring_literals"
+// CHECK: @[[UNNAMED_CFSTRING1:.*]] = private constant %struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* getelementptr inbounds ([5 x i8], [5 x i8]

[libcxx] r268844 - Update TS implementation status page

2016-05-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri May  6 22:24:31 2016
New Revision: 268844

URL: http://llvm.org/viewvc/llvm-project?rev=268844&view=rev
Log:
Update TS implementation status page

Modified:
libcxx/trunk/www/ts1z_status.html

Modified: libcxx/trunk/www/ts1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/ts1z_status.html?rev=268844&r1=268843&r2=268844&view=diff
==
--- libcxx/trunk/www/ts1z_status.html (original)
+++ libcxx/trunk/www/ts1z_status.html Fri May  6 22:24:31 2016
@@ -72,6 +72,14 @@
Time UtilitiesComplete
System Error SupportComplete
   
+  Class memory_resourceComplete
+  Class template polymorphic_allocatorComplete
+  Template alias resource_adaptorComplete
+  Global memory resourcesComplete
+  Pool resource classesImplementation in 
progress
+  Class monotonic_buffer_resourceImplementation in 
progress
+  Alias templates using polymorphic memory 
resourceComplete
+  
SearchersComplete
Optional ObjectsInitial implementation 
complete
class anyComplete


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


r268843 - Update \param corresponding to r268819. [-Wdocumentation]

2016-05-06 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Fri May  6 22:12:30 2016
New Revision: 268843

URL: http://llvm.org/viewvc/llvm-project?rev=268843&view=rev
Log:
Update \param corresponding to r268819. [-Wdocumentation]

Modified:
cfe/trunk/include/clang/Lex/ModuleMap.h

Modified: cfe/trunk/include/clang/Lex/ModuleMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=268843&r1=268842&r2=268843&view=diff
==
--- cfe/trunk/include/clang/Lex/ModuleMap.h (original)
+++ cfe/trunk/include/clang/Lex/ModuleMap.h Fri May  6 22:12:30 2016
@@ -53,7 +53,7 @@ public:
 
   /// \brief Called when a header is added during module map parsing.
   ///
-  /// \param File The header file itself.
+  /// \param Filename The header file itself.
   virtual void moduleMapAddHeader(StringRef Filename) {}
 };
   


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


[libcxx] r268842 - Change allocator::allocate to throw length_error, not bad_alloc

2016-05-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri May  6 22:12:24 2016
New Revision: 268842

URL: http://llvm.org/viewvc/llvm-project?rev=268842&view=rev
Log:
Change allocator::allocate to throw length_error, not bad_alloc

Modified:
libcxx/trunk/include/memory

libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=268842&r1=268841&r2=268842&view=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Fri May  6 22:12:24 2016
@@ -607,6 +607,7 @@ void* align(size_t alignment, size_t siz
 #include <__functional_base>
 #include 
 #include 
+#include 
 #include 
 #if defined(_LIBCPP_NO_EXCEPTIONS)
 #include 
@@ -1728,11 +1729,8 @@ public:
 _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, 
allocator::const_pointer = 0)
 {
 if (__n > max_size())
-#ifndef _LIBCPP_NO_EXCEPTIONS
-throw bad_alloc();
-#else
-assert(!"allocator::allocate::bad_alloc");
-#endif
+__libcpp_throw(length_error("allocator::allocate(size_t n)"
+  " 'n' exceeds maximum supported size"));
 return static_cast(_VSTD::__allocate(__n * sizeof(_Tp)));
 }
 _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
@@ -1827,13 +1825,10 @@ public:
 _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, 
allocator::const_pointer = 0)
 {
 if (__n > max_size())
-#ifndef _LIBCPP_NO_EXCEPTIONS
-throw bad_alloc();
-#else
-assert(!"allocator::allocate::bad_alloc");
-#endif
+__libcpp_throw(length_error("allocator::allocate(size_t 
n)"
+  " 'n' exceeds maximum supported size"));
 return static_cast(_VSTD::__allocate(__n * sizeof(_Tp)));
-}
+}
 _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
 {_VSTD::__deallocate((void*)__p);}
 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT

Modified: 
libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp?rev=268842&r1=268841&r2=268842&view=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp
 Fri May  6 22:12:24 2016
@@ -20,9 +20,11 @@ template 
 void test_max(size_t count)
 {
 std::allocator a;
-try { a.allocate( count ); }
-catch ( const std::bad_alloc &) { return ; }
-assert (false);
+try {
+a.allocate(count);
+assert(false);
+} catch (const std::exception &) {
+}
 }
 
 int main()


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


[libcxx] r268841 - Add experimental container alias templates for PMRs

2016-05-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri May  6 22:09:55 2016
New Revision: 268841

URL: http://llvm.org/viewvc/llvm-project?rev=268841&view=rev
Log:
Add experimental container alias templates for PMRs

Added:
libcxx/trunk/include/experimental/deque
libcxx/trunk/include/experimental/forward_list
libcxx/trunk/include/experimental/list
libcxx/trunk/include/experimental/map
libcxx/trunk/include/experimental/regex
libcxx/trunk/include/experimental/set
libcxx/trunk/include/experimental/string
libcxx/trunk/include/experimental/unordered_map
libcxx/trunk/include/experimental/unordered_set
libcxx/trunk/include/experimental/vector
libcxx/trunk/test/libcxx/experimental/memory/memory.resource.aliases/

libcxx/trunk/test/libcxx/experimental/memory/memory.resource.aliases/header_deque_libcpp_version.pass.cpp

libcxx/trunk/test/libcxx/experimental/memory/memory.resource.aliases/header_forward_list_libcpp_version.pass.cpp

libcxx/trunk/test/libcxx/experimental/memory/memory.resource.aliases/header_list_libcpp_version.pass.cpp

libcxx/trunk/test/libcxx/experimental/memory/memory.resource.aliases/header_map_libcpp_version.pass.cpp

libcxx/trunk/test/libcxx/experimental/memory/memory.resource.aliases/header_regex_libcpp_version.pass.cpp

libcxx/trunk/test/libcxx/experimental/memory/memory.resource.aliases/header_set_libcpp_version.pass.cpp

libcxx/trunk/test/libcxx/experimental/memory/memory.resource.aliases/header_string_libcpp_version.pass.cpp

libcxx/trunk/test/libcxx/experimental/memory/memory.resource.aliases/header_unordered_map_libcpp_version.pass.cpp

libcxx/trunk/test/libcxx/experimental/memory/memory.resource.aliases/header_unordered_set_libcpp_version.pass.cpp

libcxx/trunk/test/libcxx/experimental/memory/memory.resource.aliases/header_vector_libcpp_version.pass.cpp
libcxx/trunk/test/std/experimental/memory/memory.resource.aliases/

libcxx/trunk/test/std/experimental/memory/memory.resource.aliases/header_deque_synop.pass.cpp

libcxx/trunk/test/std/experimental/memory/memory.resource.aliases/header_forward_list_synop.pass.cpp

libcxx/trunk/test/std/experimental/memory/memory.resource.aliases/header_list_synop.pass.cpp

libcxx/trunk/test/std/experimental/memory/memory.resource.aliases/header_map_synop.pass.cpp

libcxx/trunk/test/std/experimental/memory/memory.resource.aliases/header_regex_synop.pass.cpp

libcxx/trunk/test/std/experimental/memory/memory.resource.aliases/header_set_synop.pass.cpp

libcxx/trunk/test/std/experimental/memory/memory.resource.aliases/header_string_synop.pass.cpp

libcxx/trunk/test/std/experimental/memory/memory.resource.aliases/header_unordered_map_synop.pass.cpp

libcxx/trunk/test/std/experimental/memory/memory.resource.aliases/header_unordered_set_synop.pass.cpp

libcxx/trunk/test/std/experimental/memory/memory.resource.aliases/header_vector_synop.pass.cpp

Added: libcxx/trunk/include/experimental/deque
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/deque?rev=268841&view=auto
==
--- libcxx/trunk/include/experimental/deque (added)
+++ libcxx/trunk/include/experimental/deque Fri May  6 22:09:55 2016
@@ -0,0 +1,47 @@
+// -*- C++ -*-
+//===--- deque 
===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_EXPERIMENTAL_DEQUE
+#define _LIBCPP_EXPERIMENTAL_DEQUE
+/*
+experimental/deque synopsis
+
+// C++1z
+namespace std {
+namespace experimental {
+inline namespace fundamentals_v1 {
+namespace pmr {
+
+  template 
+  using deque = std::deque>;
+
+} // namespace pmr
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace std
+
+ */
+
+#include 
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
+
+template 
+using deque = _VSTD::deque<_ValueT, polymorphic_allocator<_ValueT>>;
+
+_LIBCPP_END_NAMESPACE_LFTS_PMR
+
+#endif /* _LIBCPP_EXPERIMENTAL_DEQUE */

Added: libcxx/trunk/include/experimental/forward_list
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/forward_list?rev=268841&view=auto
==
--- libcxx/trunk/include/experimental/forward_list (added)
+++ libcxx/trunk/include/experimental/forward_list Fri May  6 22:09:55 2016
@@ -0,0 +1,47 @@
+// -*- C++ -*-
+//===--- forward_list 
-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the Unive

[libcxx] r268839 - Fix one more usage of _LIBCPP_HAS_NO_EXCEPTIONS

2016-05-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri May  6 21:33:25 2016
New Revision: 268839

URL: http://llvm.org/viewvc/llvm-project?rev=268839&view=rev
Log:
Fix one more usage of _LIBCPP_HAS_NO_EXCEPTIONS

Modified:
libcxx/trunk/src/experimental/memory_resource.cpp

Modified: libcxx/trunk/src/experimental/memory_resource.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/memory_resource.cpp?rev=268839&r1=268838&r2=268839&view=diff
==
--- libcxx/trunk/src/experimental/memory_resource.cpp (original)
+++ libcxx/trunk/src/experimental/memory_resource.cpp Fri May  6 21:33:25 2016
@@ -50,7 +50,7 @@ public:
 
 protected:
 virtual void* do_allocate(size_t, size_t) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+#ifndef _LIBCPP_NO_EXCEPTIONS
 throw std::bad_alloc();
 #else
 abort();


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


[libcxx] r268838 - Fix typo it _LIBCPP_NO_EXCEPTIONS macro

2016-05-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri May  6 21:30:21 2016
New Revision: 268838

URL: http://llvm.org/viewvc/llvm-project?rev=268838&view=rev
Log:
Fix typo it _LIBCPP_NO_EXCEPTIONS macro

Modified:
libcxx/trunk/include/exception

Modified: libcxx/trunk/include/exception
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/exception?rev=268838&r1=268837&r2=268838&view=diff
==
--- libcxx/trunk/include/exception (original)
+++ libcxx/trunk/include/exception Fri May  6 21:30:21 2016
@@ -80,7 +80,7 @@ template  void rethrow_if_neste
 #include <__config>
 #include 
 #include 
-#if defined(_LIBCPP_HAS_NO_EXCEPTIONS)
+#if defined(_LIBCPP_NO_EXCEPTIONS)
 #include 
 #include 
 #endif
@@ -260,7 +260,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 template 
 _LIBCPP_INLINE_VISIBILITY
 inline void __libcpp_throw(_Exception const& __e) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+#ifndef _LIBCPP_NO_EXCEPTIONS
 throw __e;
 #else
 _VSTD::fprintf(stderr, "%s\n", __e.what());


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


Re: [Clang] Convergent Attribute

2016-05-06 Thread Richard Smith via cfe-commits
On Fri, May 6, 2016 at 4:20 PM, Matt Arsenault via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On 05/06/2016 02:42 PM, David Majnemer via cfe-commits wrote:
>
>> This example looks wrong to me. It doesn't seem meaningful for a function
>> to be both readonly and convergent, because convergent means the call has
>> some side-effect visible to other threads and readonly means the call has
>> no side-effects visible outside the function.
>>
> This s not correct. It is valid for convergent operations to be
> readonly/readnone. Barriers are a common case which do have side effects,
> but there are also classes of GPU instructions which do not access memory
> and still need the convergent semantics.
>

Can you give an example? It's not clear to me how a function could be both
convergent and satisfy the readnone requirement that it not "access[...]
any mutable state (e.g. memory, control registers, etc) visible to caller
functions". Synchronizing with other threads seems like it would cause such
a state change in an abstract sense. Is the critical distinction here that
the state mutation is visible to the code that spawned the gang of threads,
but not to other threads within the gang? (This seems like a bug in the
definition of readonly if so, because it means that a readonly call whose
result is unused cannot be deleted.)

I care about this because Clang maps __attribute__((pure)) to LLVM
readonly, and -- irrespective of the LLVM semantics -- a call to a function
marked pure is permitted to be deleted if the return value is unused, or to
have multiple calls CSE'd. As a result, inside Clang, we use that attribute
to determine whether an expression has side effects, and Clang's reasoning
about these things may also lead to miscompiles if a call to a function
marked __attribute__((pure, convergent)) actually can have a side effect.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20039: [CUDA] Restrict init of local __shared__ variables to empty constructors only.

2016-05-06 Thread Justin Lebar via cfe-commits
jlebar added a comment.

While I think this is 100% the right thing to do, I am worried about breaking 
existing targets.  Maybe we need an escape valve, at least until we get that 
sorted out?  Unless you're pretty confident this isn't happening / will be easy 
enough to fix.



Comment at: lib/CodeGen/CGDecl.cpp:376
@@ +375,3 @@
+  // CUDA's local and local static __shared__ variables should not
+  // have any non-empty initializers which is ensured by Sema.
+  // Whatever initializer such variable may have when it gets here is

Please set off "which is ensured by Sema" somehow.  I'd probably say

> initializers.  (This is ensured by Sema.)


Comment at: lib/Sema/SemaDecl.cpp:10416
@@ -10415,2 +10415,3 @@
   // 7.5). CUDA also allows constant initializers for __constant__ and
-  // __device__ variables.
+  // __device__ variables.  We also must have the same checks applied
+  // to all __shared__ variables whether they are local or

s/have the same checks applied/apply the same checks


http://reviews.llvm.org/D20039



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


Re: [PATCH] D20007: Add

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

Accepting before committing.


http://reviews.llvm.org/D20007



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


Re: [PATCH] D19866: [Analyzer] Correct stack address escape diagnostic

2016-05-06 Thread Devin Coughlin via cfe-commits
dcoughlin added inline comments.


Comment at: 
llvm/tools/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp:229
@@ -228,3 +228,3 @@
 BT_stackleak.reset(
-new BuiltinBug(this, "Stack address stored into global variable",
-   "Stack address was saved into a global variable. "
+new BuiltinBug(this, "Stack address stored into global/static 
variable",
+   "Stack address was saved into a global/static variable. 
"

zaks.anna wrote:
> I don't like the '/' here. The only idea I have is to replace it with "into a 
> variable with static allocation", which is also not ideal because it uses 
> jargon.
We have to be careful about changing the 'Name' parameter here. This is 
supposed to be stable, because we use it for issue hashing. Any change will 
cause the issue hash to change and stymie use of the issue hash for 
baselining/issue suppression. 

I think we should probably not change it. It isn't user facing, so improving 
the text won't make a difference in user experience (although to does show up 
in plists as the "type" of the bug (via the "BugType" field in PathDiagnostic).








Comment at: 
llvm/tools/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp:232
@@ -231,3 +231,3 @@
"This is dangerous because the address will become "
"invalid after returning from the function"));
 

This string here is actually never used, so you should just remove it and use 
the constructor of BuiltinBug that doesn't take a description.


Comment at: 
llvm/tools/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp:242
@@ +241,3 @@
+  os << "static";
+else
+  os << "global";

This is great!


http://reviews.llvm.org/D19866



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


r268825 - [CrashReproducer] Always use realpath for destination

2016-05-06 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri May  6 18:58:58 2016
New Revision: 268825

URL: http://llvm.org/viewvc/llvm-project?rev=268825&view=rev
Log:
[CrashReproducer] Always use realpath for destination

When running reproducer scripts we need that original symlinks from the
source filesystem are reproduced in the VFS so that different virtual
paths can map to the same file, allowing the FileManager to share the
same UID between these virtual entries. This avoids all sorts of module
redefinition errors when using frameworks.

Modified:
cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m

Modified: cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp?rev=268825&r1=268824&r2=268825&view=diff
==
--- cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp (original)
+++ cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp Fri May  6 18:58:58 
2016
@@ -153,47 +153,40 @@ bool ModuleDependencyCollector::getRealP
 std::error_code ModuleDependencyCollector::copyToRoot(StringRef Src) {
   using namespace llvm::sys;
 
-  // We need an absolute path to append to the root.
+  // We need an absolute src path to append to the root.
   SmallString<256> AbsoluteSrc = Src;
   fs::make_absolute(AbsoluteSrc);
-  // Canonicalize to a native path to avoid mixed separator styles.
+  // Canonicalize src to a native path to avoid mixed separator styles.
   path::native(AbsoluteSrc);
   // Remove redundant leading "./" pieces and consecutive separators.
   AbsoluteSrc = path::remove_leading_dotslash(AbsoluteSrc);
 
-  // Canonicalize path by removing "..", "." components.
+  // Canonicalize the source path by removing "..", "." components.
   SmallString<256> CanonicalPath = AbsoluteSrc;
   path::remove_dots(CanonicalPath, /*remove_dot_dot=*/true);
 
   // If a ".." component is present after a symlink component, remove_dots may
   // lead to the wrong real destination path. Let the source be canonicalized
-  // like that but make sure the destination uses the real path.
-  bool HasDotDotInPath =
-  std::count(path::begin(AbsoluteSrc), path::end(AbsoluteSrc), "..") > 0;
+  // like that but make sure we always use the real path for the destination.
   SmallString<256> RealPath;
-  bool HasRemovedSymlinkComponent = HasDotDotInPath &&
- getRealPath(AbsoluteSrc, RealPath) &&
- !StringRef(CanonicalPath).equals(RealPath);
-
-  // Build the destination path.
+  if (!getRealPath(AbsoluteSrc, RealPath))
+RealPath = CanonicalPath;
   SmallString<256> Dest = getDest();
-  path::append(Dest, path::relative_path(HasRemovedSymlinkComponent ? RealPath
- : CanonicalPath));
+  path::append(Dest, path::relative_path(RealPath));
 
   // Copy the file into place.
   if (std::error_code EC = fs::create_directories(path::parent_path(Dest),
/*IgnoreExisting=*/true))
 return EC;
-  if (std::error_code EC = fs::copy_file(
-  HasRemovedSymlinkComponent ? RealPath : CanonicalPath, Dest))
+  if (std::error_code EC = fs::copy_file(RealPath, Dest))
 return EC;
 
-  // Use the canonical path under the root for the file mapping. Also create
-  // an additional entry for the real path.
+  // Always map a canonical src path to its real path into the YAML, by doing
+  // this we map different virtual src paths to the same entry in the VFS
+  // overlay, which is a way to emulate symlink inside the VFS; this is also
+  // needed for correctness, not doing that can lead to module redifinition
+  // errors.
   addFileMapping(CanonicalPath, Dest);
-  if (HasRemovedSymlinkComponent)
-addFileMapping(RealPath, Dest);
-
   return std::error_code();
 }
 

Modified: cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m?rev=268825&r1=268824&r2=268825&view=diff
==
--- cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m Fri May  6 
18:58:58 2016
@@ -43,17 +43,9 @@
 // CHECKYAML: 'case-sensitive':
 // CHECKYAML-NEXT: 'use-external-names': 'false',
 // CHECKYAML-NEXT: 'overlay-relative': 'true',
-// CHECKYAML: 'type': 'directory'
-// CHECKYAML: 'name': "/[[PATH:.*]]/i/usr/include",
-// CHECKYAML-NEXT: 'contents': [
-// CHECKYAML-NEXT:   {
-// CHECKYAML-NEXT: 'type': 'file',
-// CHECKYAML-NEXT: 'name': "module.map",
-// CHECKYAML-NEXT: 'external-contents': 
"/[[PATH]]/i/usr/include/module.map"
-// CHECKYAML-NEXT:   },
 
 // CHECKYAML: 'type': 'directory'
-// CHECKYAML: 'name': "/[[PATH]]/i/usr",
+// CHECKYAML

Re: [Clang] Convergent Attribute

2016-05-06 Thread Matt Arsenault via cfe-commits

On 05/06/2016 12:11 PM, Anastasia Stulova via cfe-commits wrote:

I was just wondering whether it would make sense to restrict the usage of the attribute 
to OpenCL language i.e. to add  "let LangOpts = [OpenCL];" in the attribute 
definition.

This seems to be a pointless arbitrary restriction to me

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


r268819 - [CrashReproducer] Change module map callback signature. NFC

2016-05-06 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri May  6 18:21:50 2016
New Revision: 268819

URL: http://llvm.org/viewvc/llvm-project?rev=268819&view=rev
Log:
[CrashReproducer] Change module map callback signature. NFC

Use a StringRef instead of a FileEntry in the moduleMapAddHeader
callback to allow more flexibility on what to collect on further
patches. This changes the interface I introduced in r264971.

Modified:
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp

Modified: cfe/trunk/include/clang/Lex/ModuleMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=268819&r1=268818&r2=268819&view=diff
==
--- cfe/trunk/include/clang/Lex/ModuleMap.h (original)
+++ cfe/trunk/include/clang/Lex/ModuleMap.h Fri May  6 18:21:50 2016
@@ -54,7 +54,7 @@ public:
   /// \brief Called when a header is added during module map parsing.
   ///
   /// \param File The header file itself.
-  virtual void moduleMapAddHeader(const FileEntry &File) {}
+  virtual void moduleMapAddHeader(StringRef Filename) {}
 };
   
 class ModuleMap {

Modified: cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp?rev=268819&r1=268818&r2=268819&view=diff
==
--- cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp (original)
+++ cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp Fri May  6 18:21:50 
2016
@@ -44,8 +44,7 @@ struct ModuleDependencyMMCallbacks : pub
   ModuleDependencyMMCallbacks(ModuleDependencyCollector &Collector)
   : Collector(Collector) {}
 
-  void moduleMapAddHeader(const FileEntry &File) override {
-StringRef HeaderPath = File.getName();
+  void moduleMapAddHeader(StringRef HeaderPath) override {
 if (llvm::sys::path::is_absolute(HeaderPath))
   Collector.addFile(HeaderPath);
   }

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=268819&r1=268818&r2=268819&view=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Fri May  6 18:21:50 2016
@@ -809,7 +809,7 @@ void ModuleMap::addHeader(Module *Mod, M
 
   // Notify callbacks that we just added a new header.
   for (const auto &Cb : Callbacks)
-Cb->moduleMapAddHeader(*Header.Entry);
+Cb->moduleMapAddHeader(Header.Entry->getName());
 }
 
 void ModuleMap::excludeHeader(Module *Mod, Module::Header Header) {


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


r268820 - [VFS] Add dump methods to the VFS overlay tree

2016-05-06 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri May  6 18:21:57 2016
New Revision: 268820

URL: http://llvm.org/viewvc/llvm-project?rev=268820&view=rev
Log:
[VFS] Add dump methods to the VFS overlay tree

Useful when debugging issues within the VFS overlay.

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

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=268820&r1=268819&r2=268820&view=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Fri May  6 18:21:57 2016
@@ -16,6 +16,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
@@ -920,6 +921,29 @@ public:
 return ExternalContentsPrefixDir;
   }
 
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+LLVM_DUMP_METHOD void dump() const {
+for (const std::unique_ptr &Root : Roots)
+  dumpEntry(Root.get());
+  }
+
+LLVM_DUMP_METHOD void dumpEntry(Entry *E, int NumSpaces = 0) const {
+StringRef Name = E->getName();
+for (int i = 0, e = NumSpaces; i < e; ++i)
+  dbgs() << " ";
+dbgs() << "'" << Name.str().c_str() << "'" << "\n";
+
+if (E->getKind() == EK_Directory) {
+  auto *DE = dyn_cast(E);
+  assert(DE && "Should be a directory");
+
+  for (std::unique_ptr &SubEntry :
+   llvm::make_range(DE->contents_begin(), DE->contents_end()))
+dumpEntry(SubEntry.get(), NumSpaces+2);
+}
+  }
+#endif
+
 };
 
 /// \brief A helper class to hold the common YAML parsing state.


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


Re: [Clang] Convergent Attribute

2016-05-06 Thread Matt Arsenault via cfe-commits

On 05/06/2016 02:42 PM, David Majnemer via cfe-commits wrote:
This example looks wrong to me. It doesn't seem meaningful for a 
function to be both readonly and convergent, because convergent means 
the call has some side-effect visible to other threads and readonly 
means the call has no side-effects visible outside the function.
This s not correct. It is valid for convergent operations to be 
readonly/readnone. Barriers are a common case which do have side 
effects, but there are also classes of GPU instructions which do not 
access memory and still need the convergent semantics.


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


Re: [Clang] Convergent Attribute

2016-05-06 Thread Matt Arsenault via cfe-commits

On 05/06/2016 02:53 PM, Richard Smith via cfe-commits wrote:
It looks like we added the noduplicate attribute to clang to support 
OpenCL's barrier function. Did we get the semantics for it wrong for 
its intended use case?
Yes. Noduplicate is essentially deprecated in favor of convergent. 
noduplicate is too strict, duplicating is OK in the case of unrolling a 
loop with a barrier for example.

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


[PATCH] D20040: Treat qualifiers on elaborated types for qualtypenames appropriately.

2016-05-06 Thread Sterling Augustine via cfe-commits
saugustine created this revision.
saugustine added a reviewer: rnk.
saugustine added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Treat qualifiers on elaborated types for qualtypenames appropriately.

http://reviews.llvm.org/D20040

Files:
  lib/Tooling/Core/QualTypeNames.cpp
  unittests/Tooling/QualTypeNamesTest.cpp

Index: unittests/Tooling/QualTypeNamesTest.cpp
===
--- unittests/Tooling/QualTypeNamesTest.cpp
+++ unittests/Tooling/QualTypeNamesTest.cpp
@@ -88,6 +88,7 @@
   "Foo::non_dependent_type";
   Visitor.ExpectedQualTypeNames["AnEnumVar"] = "EnumScopeClass::AnEnum";
   Visitor.ExpectedQualTypeNames["AliasTypeVal"] = "A::B::C::InnerAlias";
+  Visitor.ExpectedQualTypeNames["CheckM"] = "const A::B::Class0 *";
   Visitor.runOver(
   "int CheckInt;\n"
   "template \n"
@@ -108,6 +109,7 @@
   "  AnotherClass> CheckC);\n"
   "   void Function2(Template0,\n"
   "Template0 > CheckD);\n"
+  "   void Function3(const B::Class0* CheckM);\n"
   "  }\n"
   "template class Variadic {};\n"
   "Variadic, "
Index: lib/Tooling/Core/QualTypeNames.cpp
===
--- lib/Tooling/Core/QualTypeNames.cpp
+++ lib/Tooling/Core/QualTypeNames.cpp
@@ -383,7 +383,10 @@
   }
 
   NestedNameSpecifier *Prefix = nullptr;
-  Qualifiers PrefixQualifiers;
+  // Local qualifiers are attached to the Qualtype outside of the
+  // elaborated type.  Retrieve them before descending into the
+  // elaborated type.
+  Qualifiers PrefixQualifiers = QT.getLocalQualifiers();
   ElaboratedTypeKeyword Keyword = ETK_None;
   if (const auto *ETypeInput = dyn_cast(QT.getTypePtr())) {
 QT = ETypeInput->getNamedType();
@@ -395,8 +398,7 @@
true /*FullyQualified*/);
 
   // move the qualifiers on the outer type (avoid 'std::const string'!)
-  if (Prefix) {
-PrefixQualifiers = QT.getLocalQualifiers();
+  if (Prefix || Keyword != ETK_None) {
 QT = QualType(QT.getTypePtr(), 0);
   }
 


Index: unittests/Tooling/QualTypeNamesTest.cpp
===
--- unittests/Tooling/QualTypeNamesTest.cpp
+++ unittests/Tooling/QualTypeNamesTest.cpp
@@ -88,6 +88,7 @@
   "Foo::non_dependent_type";
   Visitor.ExpectedQualTypeNames["AnEnumVar"] = "EnumScopeClass::AnEnum";
   Visitor.ExpectedQualTypeNames["AliasTypeVal"] = "A::B::C::InnerAlias";
+  Visitor.ExpectedQualTypeNames["CheckM"] = "const A::B::Class0 *";
   Visitor.runOver(
   "int CheckInt;\n"
   "template \n"
@@ -108,6 +109,7 @@
   "  AnotherClass> CheckC);\n"
   "   void Function2(Template0,\n"
   "Template0 > CheckD);\n"
+  "   void Function3(const B::Class0* CheckM);\n"
   "  }\n"
   "template class Variadic {};\n"
   "Variadic, "
Index: lib/Tooling/Core/QualTypeNames.cpp
===
--- lib/Tooling/Core/QualTypeNames.cpp
+++ lib/Tooling/Core/QualTypeNames.cpp
@@ -383,7 +383,10 @@
   }
 
   NestedNameSpecifier *Prefix = nullptr;
-  Qualifiers PrefixQualifiers;
+  // Local qualifiers are attached to the Qualtype outside of the
+  // elaborated type.  Retrieve them before descending into the
+  // elaborated type.
+  Qualifiers PrefixQualifiers = QT.getLocalQualifiers();
   ElaboratedTypeKeyword Keyword = ETK_None;
   if (const auto *ETypeInput = dyn_cast(QT.getTypePtr())) {
 QT = ETypeInput->getNamedType();
@@ -395,8 +398,7 @@
true /*FullyQualified*/);
 
   // move the qualifiers on the outer type (avoid 'std::const string'!)
-  if (Prefix) {
-PrefixQualifiers = QT.getLocalQualifiers();
+  if (Prefix || Keyword != ETK_None) {
 QT = QualType(QT.getTypePtr(), 0);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r268817 - [modules] Attempt to improve performance for declaration merging without a Sema

2016-05-06 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May  6 18:14:07 2016
New Revision: 268817

URL: http://llvm.org/viewvc/llvm-project?rev=268817&view=rev
Log:
[modules] Attempt to improve performance for declaration merging without a Sema
object in C. Rather than using the DeclContext (which is very slow because it
triggers us to build a lookup table for the DeclContext), use a separate map
from identifiers to decls for this case, containing only the ones we've
actually deserialized. For convenience, this map is implemented as an
IdentifierResolver.

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

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=268817&r1=268816&r2=268817&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Fri May  6 18:14:07 2016
@@ -27,6 +27,7 @@
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/PreprocessingRecord.h"
 #include "clang/Sema/ExternalSemaSource.h"
+#include "clang/Sema/IdentifierResolver.h"
 #include "clang/Serialization/ASTBitCodes.h"
 #include "clang/Serialization/ContinuousRangeMap.h"
 #include "clang/Serialization/Module.h"
@@ -390,6 +391,11 @@ private:
   /// \brief The module manager which manages modules and their dependencies
   ModuleManager ModuleMgr;
 
+  /// \brief A dummy identifier resolver used to merge TU-scope declarations in
+  /// C, for the cases where we don't have a Sema object to provide a real
+  /// identifier resolver.
+  IdentifierResolver DummyIdResolver;
+
   /// A mapping from extension block names to module file extensions.
   llvm::StringMap> 
ModuleFileExtensions;
 
@@ -2100,6 +2106,11 @@ public:
   /// imported.
   Sema *getSema() { return SemaObj; }
 
+  /// \brief Get the identifier resolver used for name lookup / updates
+  /// in the translation unit scope. We have one of these even if we don't
+  /// have a Sema object.
+  IdentifierResolver &getIdResolver();
+
   /// \brief Retrieve the identifier table associated with the
   /// preprocessor.
   IdentifierTable &getIdentifierTable();

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=268817&r1=268816&r2=268817&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri May  6 18:14:07 2016
@@ -8695,6 +8695,7 @@ ASTReader::ASTReader(
   FileMgr(PP.getFileManager()), PCHContainerRdr(PCHContainerRdr),
   Diags(PP.getDiagnostics()), SemaObj(nullptr), PP(PP), Context(Context),
   Consumer(nullptr), ModuleMgr(PP.getFileManager(), PCHContainerRdr),
+  DummyIdResolver(PP),
   ReadTimer(std::move(ReadTimer)),
   PragmaMSStructState(-1),
   PragmaMSPointersToMembersState(-1),
@@ -8733,3 +8734,7 @@ ASTReader::~ASTReader() {
   if (OwnsDeserializationListener)
 delete DeserializationListener;
 }
+
+IdentifierResolver &ASTReader::getIdResolver() {
+  return SemaObj ? SemaObj->IdResolver : DummyIdResolver;
+}

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=268817&r1=268816&r2=268817&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri May  6 18:14:07 2016
@@ -23,7 +23,6 @@
 #include "clang/AST/DeclVisitor.h"
 #include "clang/AST/Expr.h"
 #include "clang/Sema/IdentifierResolver.h"
-#include "clang/Sema/Sema.h"
 #include "clang/Sema/SemaDiagnostic.h"
 #include "llvm/Support/SaveAndRestore.h"
 
@@ -2814,9 +2813,9 @@ ASTDeclReader::FindExistingResult::~Find
   if (needsAnonymousDeclarationNumber(New)) {
 setAnonymousDeclForMerging(Reader, New->getLexicalDeclContext(),
AnonymousDeclNumber, New);
-  } else if (DC->isTranslationUnit() && Reader.SemaObj &&
+  } else if (DC->isTranslationUnit() &&
  !Reader.getContext().getLangOpts().CPlusPlus) {
-if (Reader.SemaObj->IdResolver.tryAddTopLevelDecl(New, Name))
+if (Reader.getIdResolver().tryAddTopLevelDecl(New, Name))
   Reader.PendingFakeLookupResults[Name.getAsIdentifierInfo()]
 .push_back(New);
   } else if (DeclContext *MergeDC = getPrimaryContextForMerging(Reader, DC)) {
@@ -2919,9 +2918,9 @@ ASTDeclReader::FindExistingResult ASTDec
   if (isSameEntity(Existing, D))
 return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
   TypedefNameForLinkage);
-  } else if (DC->isTransla

[PATCH] D20039: [CUDA] Restrict init of local __shared__ variables to empty constructors only.

2016-05-06 Thread Artem Belevich via cfe-commits
tra created this revision.
tra added reviewers: jingyue, jlebar, rnk.
tra added a subscriber: cfe-commits.

While __shared__ variables look like any other variable with a static storage 
class to compiler, they behave differently on device side.

* one instance is created per block of GPUS, so standard "initialize once using 
guard variable" model does not quite work.
* lifetime of the variables ends when the __global__ function exits. Again, it 
does not fit current assumption about static 
  local vars as we will need to init them again if that function is called 
again.
* with that in mind, deinitialization on app exit does not work either as the 
variable no longer exists past its kernel's exit.

nvcc takes a rather dangerous shortcut and allows non-empty constructors for 
local __static__ variables. It calls initializer on every entry into the scope 
and produces a warning that there's going to be a data race as there will be 
many kernels doing init on many instances of that __shared__ variable. It also 
calls destructors on exit from the scope. Now, imagine recursive call of a 
function with a local __static__ variable...

Until we figure out better way to deal with this, clang will only allow empty 
constructors for local __shared__ variables in a way identical to restrictions 
imposed on dynamic initializers for global variables.


http://reviews.llvm.org/D20039

Files:
  lib/CodeGen/CGDecl.cpp
  lib/Sema/SemaDecl.cpp
  test/CodeGenCUDA/device-var-init.cu

Index: test/CodeGenCUDA/device-var-init.cu
===
--- test/CodeGenCUDA/device-var-init.cu
+++ test/CodeGenCUDA/device-var-init.cu
@@ -63,6 +63,8 @@
 
 // static in-class field initializer.  NVCC does not allow it, but
 // clang generates static initializer for this, so we'll accept it.
+// We still can't use it on __shared__ vars as they don't allow *any*
+// initializers.
 struct NCFS {
   int ncfs = 3;
 };
@@ -367,8 +369,13 @@
   T_B_NEC t_b_nec;
   T_F_NEC t_f_nec;
   T_FA_NEC t_fa_nec;
+  static __shared__ EC s_ec;
+  static __shared__ ETC s_etc;
+#if ERROR_CASE
+  static __shared__ NCFS s_ncfs;
+  // expected-error@-1 {{initialization is not supported for __shared__ 
variables.}}
   static __shared__ UC s_uc;
-#if ERROR_CASE
+  // expected-error@-1 {{initialization is not supported for __shared__ 
variables.}}
   static __device__ int ds; 
   // expected-error@-1 {{Within a __device__/__global__ function, only 
__shared__ variables may be marked "static"}}
   static __constant__ int dc;
@@ -394,7 +401,8 @@
 // CHECK:   call void @_ZN7T_B_NECC1Ev(%struct.T_B_NEC* %t_b_nec)
 // CHECK:   call void @_ZN7T_F_NECC1Ev(%struct.T_F_NEC* %t_f_nec)
 // CHECK:   call void @_ZN8T_FA_NECC1Ev(%struct.T_FA_NEC* %t_fa_nec)
-// CHECK:   call void @_ZN2UCC1Ev(%struct.UC* addrspacecast (%struct.UC 
addrspace(3)* @_ZZ2dfvE4s_uc to %struct.UC*))
+// CHECK-NOT: call void @_ZN2ECC1Ev(%struct.EC* addrspacecast (%struct.EC 
addrspace(3)* @_ZZ2dfvE4s_ec to %struct.EC*))
+// CHECK-NOT: call void @_ZN3ETCC1IJEEEDpT_(%struct.ETC* addrspacecast 
(%struct.ETC addrspace(3)* @_ZZ2dfvE5s_etc to %struct.ETC*))
 // CHECK: ret void
 
 // We should not emit global init function.
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -10413,13 +10413,15 @@
   // Perform check for initializers of device-side global variables.
   // CUDA allows empty constructors as initializers (see E.2.3.1, CUDA
   // 7.5). CUDA also allows constant initializers for __constant__ and
-  // __device__ variables.
+  // __device__ variables.  We also must have the same checks applied
+  // to all __shared__ variables whether they are local or
+  // not.
   if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
 const Expr *Init = VD->getInit();
-const bool IsGlobal = VD->hasGlobalStorage() && !VD->isStaticLocal();
-if (Init && IsGlobal &&
+if (Init && VD->hasGlobalStorage() &&
 (VD->hasAttr() || VD->hasAttr() ||
  VD->hasAttr())) {
+  assert((!VD->isStaticLocal() || VD->hasAttr()));
   bool AllowedInit = false;
   if (const CXXConstructExpr *CE = dyn_cast(Init))
 AllowedInit =
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -371,8 +371,15 @@
 
   llvm::GlobalVariable *var =
 cast(addr->stripPointerCasts());
+
+  // CUDA's local and local static __shared__ variables should not
+  // have any non-empty initializers which is ensured by Sema.
+  // Whatever initializer such variable may have when it gets here is
+  // a no-op and should not be emitted.
+  bool isCudaSharedVar = getLangOpts().CUDA && getLangOpts().CUDAIsDevice &&
+ D.hasAttr();
   // If this value has an initializer, emit it.
-  if (D.getInit())
+  if (D.getInit() && !isCudaSharedVar)
 var = Add

Re: [PATCH] D20034: [CUDA] Only __shared__ variables can be static local on device side.

2016-05-06 Thread Artem Belevich via cfe-commits
tra added a comment.

In http://reviews.llvm.org/D20034#423945, @jlebar wrote:

> What are we supposed to do if we encounter a static __shared__ variable in an 
> HD function?  Presumably that also should be an error if we invoke the HD 
> function from the device?


nvcc produces an error only of such HD function is used from a __host__ 
function:

  error: a function scope variable cannot be declared with "shared" inside a 
host function

Considering that each block gets its own instance of that shared variable, 
there's no way to access it from host in principle so the error makes sense. 
I'll add it in a separate patch.


http://reviews.llvm.org/D20034



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


Re: [PATCH] D20034: [CUDA] Only __shared__ variables can be static local on device side.

2016-05-06 Thread Justin Lebar via cfe-commits
jlebar added a comment.

What are we supposed to do if we encounter a static __shared__ variable in an 
HD function?  Presumably that also should be an error if we invoke the HD 
function from the device?


http://reviews.llvm.org/D20034



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


Re: [Clang] Convergent Attribute

2016-05-06 Thread Richard Smith via cfe-commits
On Fri, May 6, 2016 at 2:42 PM, David Majnemer 
wrote:

> On Fri, May 6, 2016 at 2:36 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> On Fri, May 6, 2016 at 1:56 PM, Ettore Speziale via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Hello,
>>>
>>> > In the case of foo, there could be a problem.
>>> > If you do not mark it convergent, the LLVM sink pass push the call to
>>> foo to the then branch of the ternary operator, hence the program has been
>>> incorrectly optimized.
>>> >
>>> > Really? It looks like the problem is that you lied to the compiler by
>>> marking the function as 'pure'. The barrier is a side-effect that cannot be
>>> removed or duplicated, so it's not correct to mark this function as pure.
>>>
>>> I was trying to write a very small example to trick LLVM and trigger the
>>> optimization. It is based on Transforms/Sink/convergent.ll:
>>>
>>> define i32 @foo(i1 %arg) {
>>> entry:
>>>   %c = call i32 @bar() readonly convergent
>>>   br i1 %arg, label %then, label %end
>>>
>>> then:
>>>   ret i32 %c
>>>
>>> end:
>>>   ret i32 0
>>> }
>>>
>>> declare i32 @bar() readonly convergent
>>>
>>
>> This example looks wrong to me. It doesn't seem meaningful for a function
>> to be both readonly and convergent, because convergent means the call has
>> some side-effect visible to other threads and readonly means the call has
>> no side-effects visible outside the function.
>>
>> Here is another example:
>>>
>>> void foo0(void);
>>> void foo1(void);
>>>
>>> __attribute__((convergent)) void baz() {
>>>   barrier(CLK_GLOBAL_MEM_FENCE);
>>> }
>>>
>>> void bar(int x, global int *y) {
>>>   if (x < 5)
>>> foo0();
>>>   else
>>> foo1();
>>>
>>>   baz();
>>>
>>>   if (x < 5)
>>> foo0();
>>>   else
>>> foo1();
>>> }
>>>
>>
>> This one looks a lot more interesting. It looks like 'convergent' is a
>> way of informing LLVM that the call cannot be duplicated, yes? That being
>> the case, how is this attribute different from the existing
>> [[clang::noduplicate]] / __attribute__((noduplicate)) attribute?
>>
>
> I think it has more to do with LLVM's definition of convergent: that you
> really do not want control dependencies changing for a callsite.
>

Hmm, so we can't transform:

  %a = complex_pure_operation1
  %b = complex_pure_operation2
  %c = select i1 %x, i32 %a, i32 %b
  call void @foo(i32 %c) convergent

... into ...

  br i1 %x, label %aa, label %bb

aa:
  %a = complex_pure_operation1
  br label %cont

bb:
  %b = complex_pure_operation2
  br label %cont

cont:
  %c = phi i32 [ %a, %aa ],  [ %b, %bb ]
  call void @foo(i32 %c) convergent

?

It looks like we added the noduplicate attribute to clang to support
OpenCL's barrier function. Did we get the semantics for it wrong for its
intended use case?


> http://llvm.org/docs/LangRef.html#function-attributes
>
>
>>
>> Based on Transforms/JumpThreading/basic.ll:
>>>
>>> define void @h_con(i32 %p) {
>>>   %x = icmp ult i32 %p, 5
>>>   br i1 %x, label %l1, label %l2
>>>
>>> l1:
>>>   call void @j()
>>>   br label %l3
>>>
>>> l2:
>>>   call void @k()
>>>   br label %l3
>>>
>>> l3:
>>> ; CHECK: call void @g() [[CON:#[0-9]+]]
>>> ; CHECK-NOT: call void @g() [[CON]]
>>>   call void @g() convergent
>>>   %y = icmp ult i32 %p, 5
>>>   br i1 %y, label %l4, label %l5
>>>
>>> l4:
>>>   call void @j()
>>>   ret void
>>>
>>> l5:
>>>   call void @k()
>>>   ret void
>>> ; CHECK: }
>>> }
>>>
>>> If you do not mark baz convergent, you get this:
>>>
>>> clang -x cl -emit-llvm -S -o - test.c -O0 | opt -mem2reg -jump-threading
>>> -S
>>>
>>> define void @bar(i32 %x) #0 {
>>> entry:
>>>   %cmp = icmp slt i32 %x, 5
>>>   br i1 %cmp, label %if.then2, label %if.else3
>>>
>>> if.then2: ; preds = %entry
>>>   call void @foo0()
>>>   call void @baz()
>>>   call void @foo0()
>>>   br label %if.end4
>>>
>>> if.else3: ; preds = %entry
>>>   call void @foo1()
>>>   call void @baz()
>>>   call void @foo1()
>>>   br label %if.end4
>>>
>>> if.end4:  ; preds = %if.else3,
>>> %if.then2
>>>   ret void
>>> }
>>>
>>> Which is illegal, as the value of x might not be the same for all
>>> work-items.
>>>
>>> I’ll update the patch such as:
>>>
>>> * it uses the example about jump-threading
>>> * it marks the attribute available in OpenCL/Cuda
>>> * it provides the [[clang::convergent]] attribute
>>>
>>> Thanks,
>>> Ettore Speziale
>>>
>>> --
>>> Ettore Speziale — Compiler Engineer
>>> speziale.ett...@gmail.com
>>> espezi...@apple.com
>>> --
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> h

Re: r268797 - Fix sysroot-prefix.c on Windows (/ vs \).

2016-05-06 Thread Nico Weber via cfe-commits
On Fri, May 6, 2016 at 5:43 PM, Yaron Keren via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi Nico,
>
> In other tests, {{/|}} or {{/|\\}} are used match the forward or
> backward slash(es). clang escapes \ so we get two of them in output and
> four in the LIT test.
>
> It would be nice to have more elegant construct for this general problem,
> to avoid tests like:
>
>
> "{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++"
>
> maybe having FileCheck allow  / match \ when running under Windows?
>

Seems overly magical to me. Maybe we should use {{.}} instead of {{/|}}
unless it's really important it's a slash or backslash for the test ;-)


>
> Yaron
>
>
> 2016-05-07 0:17 GMT+03:00 Nico Weber via cfe-commits <
> cfe-commits@lists.llvm.org>:
>
>> Author: nico
>> Date: Fri May  6 16:17:32 2016
>> New Revision: 268797
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=268797&view=rev
>> Log:
>> Fix sysroot-prefix.c on Windows (/ vs \).
>>
>> Modified:
>> cfe/trunk/test/Preprocessor/sysroot-prefix.c
>>
>> Modified: cfe/trunk/test/Preprocessor/sysroot-prefix.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/sysroot-prefix.c?rev=268797&r1=268796&r2=268797&view=diff
>>
>> ==
>> --- cfe/trunk/test/Preprocessor/sysroot-prefix.c (original)
>> +++ cfe/trunk/test/Preprocessor/sysroot-prefix.c Fri May  6 16:17:32 2016
>> @@ -14,12 +14,12 @@
>>  // CHECK-NO_ISYSROOT_SYSROOT_DEV_NULL: ignoring nonexistent directory
>> "=/var/empty/include"
>>  // CHECK-NO_ISYSROOT_SYSROOT_DEV_NULL-NOT: ignoring nonexistent
>> directory "/var/empty/include"
>>
>> -// CHECK-ISYSROOT_SYSROOT_NULL: ignoring nonexistent directory
>> "/var/empty/null"
>> +// CHECK-ISYSROOT_SYSROOT_NULL: ignoring nonexistent directory
>> "/var/empty{{.}}null"
>>  // CHECK-ISYSROOT_SYSROOT_NULL-NOT: ignoring nonexistent directory
>> "=null"
>>
>> -// CHECK-ISYSROOT_ISYSROOT_SYSROOT_NULL: ignoring nonexistent directory
>> "/var/empty/root/null"
>> +// CHECK-ISYSROOT_ISYSROOT_SYSROOT_NULL: ignoring nonexistent directory
>> "/var/empty/root{{.}}null"
>>  // CHECK-ISYSROOT_ISYSROOT_SYSROOT_NULL-NOT: ignoring nonexistent
>> directory "=null"
>>
>> -// CHECK-ISYSROOT_ISYSROOT_SWAPPED_SYSROOT_NULL: ignoring nonexistent
>> directory "/var/empty/null"
>> +// CHECK-ISYSROOT_ISYSROOT_SWAPPED_SYSROOT_NULL: ignoring nonexistent
>> directory "/var/empty{{.}}null"
>>  // CHECK-ISYSROOT_ISYSROOT_SWAPPED_SYSROOT_NULL-NOT: ignoring
>> nonexistent directory "=null"
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r268797 - Fix sysroot-prefix.c on Windows (/ vs \).

2016-05-06 Thread Yaron Keren via cfe-commits
Hi Nico,

In other tests, {{/|}} or {{/|\\}} are used match the forward or
backward slash(es). clang escapes \ so we get two of them in output and
four in the LIT test.

It would be nice to have more elegant construct for this general problem,
to avoid tests like:

"{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++"

maybe having FileCheck allow  / match \ when running under Windows?

Yaron


2016-05-07 0:17 GMT+03:00 Nico Weber via cfe-commits <
cfe-commits@lists.llvm.org>:

> Author: nico
> Date: Fri May  6 16:17:32 2016
> New Revision: 268797
>
> URL: http://llvm.org/viewvc/llvm-project?rev=268797&view=rev
> Log:
> Fix sysroot-prefix.c on Windows (/ vs \).
>
> Modified:
> cfe/trunk/test/Preprocessor/sysroot-prefix.c
>
> Modified: cfe/trunk/test/Preprocessor/sysroot-prefix.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/sysroot-prefix.c?rev=268797&r1=268796&r2=268797&view=diff
>
> ==
> --- cfe/trunk/test/Preprocessor/sysroot-prefix.c (original)
> +++ cfe/trunk/test/Preprocessor/sysroot-prefix.c Fri May  6 16:17:32 2016
> @@ -14,12 +14,12 @@
>  // CHECK-NO_ISYSROOT_SYSROOT_DEV_NULL: ignoring nonexistent directory
> "=/var/empty/include"
>  // CHECK-NO_ISYSROOT_SYSROOT_DEV_NULL-NOT: ignoring nonexistent directory
> "/var/empty/include"
>
> -// CHECK-ISYSROOT_SYSROOT_NULL: ignoring nonexistent directory
> "/var/empty/null"
> +// CHECK-ISYSROOT_SYSROOT_NULL: ignoring nonexistent directory
> "/var/empty{{.}}null"
>  // CHECK-ISYSROOT_SYSROOT_NULL-NOT: ignoring nonexistent directory "=null"
>
> -// CHECK-ISYSROOT_ISYSROOT_SYSROOT_NULL: ignoring nonexistent directory
> "/var/empty/root/null"
> +// CHECK-ISYSROOT_ISYSROOT_SYSROOT_NULL: ignoring nonexistent directory
> "/var/empty/root{{.}}null"
>  // CHECK-ISYSROOT_ISYSROOT_SYSROOT_NULL-NOT: ignoring nonexistent
> directory "=null"
>
> -// CHECK-ISYSROOT_ISYSROOT_SWAPPED_SYSROOT_NULL: ignoring nonexistent
> directory "/var/empty/null"
> +// CHECK-ISYSROOT_ISYSROOT_SWAPPED_SYSROOT_NULL: ignoring nonexistent
> directory "/var/empty{{.}}null"
>  // CHECK-ISYSROOT_ISYSROOT_SWAPPED_SYSROOT_NULL-NOT: ignoring nonexistent
> directory "=null"
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-05-06 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D19666



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


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.

2016-05-06 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.


Comment at: lib/Headers/opencl-c.h:14057
@@ +14056,3 @@
+event_t __attribute__((overloadable)) async_work_group_copy(__local float2 
*dst, const __global float2 *src, size_t num_elements, event_t event);
+event_t __attribute__((overloadable)) async_work_group_copy(__local char3 
*dst, const __global char3 *src, size_t num_elements, event_t event);
+event_t __attribute__((overloadable)) async_work_group_copy(__local uchar3 
*dst, const __global uchar3 *src, size_t num_elements, event_t event);

If this representation is not generic enough. Any suggestion for an 
alternative? Thanks.


http://reviews.llvm.org/D18369



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


Re: [Clang] Convergent Attribute

2016-05-06 Thread David Majnemer via cfe-commits
On Fri, May 6, 2016 at 2:36 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Fri, May 6, 2016 at 1:56 PM, Ettore Speziale via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Hello,
>>
>> > In the case of foo, there could be a problem.
>> > If you do not mark it convergent, the LLVM sink pass push the call to
>> foo to the then branch of the ternary operator, hence the program has been
>> incorrectly optimized.
>> >
>> > Really? It looks like the problem is that you lied to the compiler by
>> marking the function as 'pure'. The barrier is a side-effect that cannot be
>> removed or duplicated, so it's not correct to mark this function as pure.
>>
>> I was trying to write a very small example to trick LLVM and trigger the
>> optimization. It is based on Transforms/Sink/convergent.ll:
>>
>> define i32 @foo(i1 %arg) {
>> entry:
>>   %c = call i32 @bar() readonly convergent
>>   br i1 %arg, label %then, label %end
>>
>> then:
>>   ret i32 %c
>>
>> end:
>>   ret i32 0
>> }
>>
>> declare i32 @bar() readonly convergent
>>
>
> This example looks wrong to me. It doesn't seem meaningful for a function
> to be both readonly and convergent, because convergent means the call has
> some side-effect visible to other threads and readonly means the call has
> no side-effects visible outside the function.
>
> Here is another example:
>>
>> void foo0(void);
>> void foo1(void);
>>
>> __attribute__((convergent)) void baz() {
>>   barrier(CLK_GLOBAL_MEM_FENCE);
>> }
>>
>> void bar(int x, global int *y) {
>>   if (x < 5)
>> foo0();
>>   else
>> foo1();
>>
>>   baz();
>>
>>   if (x < 5)
>> foo0();
>>   else
>> foo1();
>> }
>>
>
> This one looks a lot more interesting. It looks like 'convergent' is a way
> of informing LLVM that the call cannot be duplicated, yes? That being the
> case, how is this attribute different from the existing
> [[clang::noduplicate]] / __attribute__((noduplicate)) attribute?
>

I think it has more to do with LLVM's definition of convergent: that you
really do not want control dependencies changing for a callsite.

http://llvm.org/docs/LangRef.html#function-attributes


>
> Based on Transforms/JumpThreading/basic.ll:
>>
>> define void @h_con(i32 %p) {
>>   %x = icmp ult i32 %p, 5
>>   br i1 %x, label %l1, label %l2
>>
>> l1:
>>   call void @j()
>>   br label %l3
>>
>> l2:
>>   call void @k()
>>   br label %l3
>>
>> l3:
>> ; CHECK: call void @g() [[CON:#[0-9]+]]
>> ; CHECK-NOT: call void @g() [[CON]]
>>   call void @g() convergent
>>   %y = icmp ult i32 %p, 5
>>   br i1 %y, label %l4, label %l5
>>
>> l4:
>>   call void @j()
>>   ret void
>>
>> l5:
>>   call void @k()
>>   ret void
>> ; CHECK: }
>> }
>>
>> If you do not mark baz convergent, you get this:
>>
>> clang -x cl -emit-llvm -S -o - test.c -O0 | opt -mem2reg -jump-threading
>> -S
>>
>> define void @bar(i32 %x) #0 {
>> entry:
>>   %cmp = icmp slt i32 %x, 5
>>   br i1 %cmp, label %if.then2, label %if.else3
>>
>> if.then2: ; preds = %entry
>>   call void @foo0()
>>   call void @baz()
>>   call void @foo0()
>>   br label %if.end4
>>
>> if.else3: ; preds = %entry
>>   call void @foo1()
>>   call void @baz()
>>   call void @foo1()
>>   br label %if.end4
>>
>> if.end4:  ; preds = %if.else3,
>> %if.then2
>>   ret void
>> }
>>
>> Which is illegal, as the value of x might not be the same for all
>> work-items.
>>
>> I’ll update the patch such as:
>>
>> * it uses the example about jump-threading
>> * it marks the attribute available in OpenCL/Cuda
>> * it provides the [[clang::convergent]] attribute
>>
>> Thanks,
>> Ettore Speziale
>>
>> --
>> Ettore Speziale — Compiler Engineer
>> speziale.ett...@gmail.com
>> espezi...@apple.com
>> --
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r268801 - Tweak --param=no_default_flags=true to still add -Ilibcxx/test/support

2016-05-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri May  6 16:35:06 2016
New Revision: 268801

URL: http://llvm.org/viewvc/llvm-project?rev=268801&view=rev
Log:
Tweak --param=no_default_flags=true to still add -Ilibcxx/test/support

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=268801&r1=268800&r2=268801&view=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Fri May  6 16:35:06 2016
@@ -293,6 +293,10 @@ class Configuration(object):
 no_default_flags = self.get_lit_bool('no_default_flags', False)
 if not no_default_flags:
 self.configure_default_compile_flags()
+# This include is always needed so add so add it regardless of
+# 'no_default_flags'.
+support_path = os.path.join(self.libcxx_src_root, 'test/support')
+self.cxx.compile_flags += ['-I' + support_path]
 # Configure extra flags
 compile_flags_str = self.get_lit_conf('compile_flags', '')
 self.cxx.compile_flags += shlex.split(compile_flags_str)
@@ -341,7 +345,6 @@ class Configuration(object):
 
 def configure_compile_flags_header_includes(self):
 support_path = os.path.join(self.libcxx_src_root, 'test/support')
-self.cxx.compile_flags += ['-I' + support_path]
 self.cxx.compile_flags += ['-include', os.path.join(support_path, 
'nasty_macros.hpp')]
 self.configure_config_site_header()
 libcxx_headers = self.get_lit_conf(


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


Re: [Clang] Convergent Attribute

2016-05-06 Thread Richard Smith via cfe-commits
On Fri, May 6, 2016 at 1:56 PM, Ettore Speziale via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hello,
>
> > In the case of foo, there could be a problem.
> > If you do not mark it convergent, the LLVM sink pass push the call to
> foo to the then branch of the ternary operator, hence the program has been
> incorrectly optimized.
> >
> > Really? It looks like the problem is that you lied to the compiler by
> marking the function as 'pure'. The barrier is a side-effect that cannot be
> removed or duplicated, so it's not correct to mark this function as pure.
>
> I was trying to write a very small example to trick LLVM and trigger the
> optimization. It is based on Transforms/Sink/convergent.ll:
>
> define i32 @foo(i1 %arg) {
> entry:
>   %c = call i32 @bar() readonly convergent
>   br i1 %arg, label %then, label %end
>
> then:
>   ret i32 %c
>
> end:
>   ret i32 0
> }
>
> declare i32 @bar() readonly convergent
>

This example looks wrong to me. It doesn't seem meaningful for a function
to be both readonly and convergent, because convergent means the call has
some side-effect visible to other threads and readonly means the call has
no side-effects visible outside the function.

Here is another example:
>
> void foo0(void);
> void foo1(void);
>
> __attribute__((convergent)) void baz() {
>   barrier(CLK_GLOBAL_MEM_FENCE);
> }
>
> void bar(int x, global int *y) {
>   if (x < 5)
> foo0();
>   else
> foo1();
>
>   baz();
>
>   if (x < 5)
> foo0();
>   else
> foo1();
> }
>

This one looks a lot more interesting. It looks like 'convergent' is a way
of informing LLVM that the call cannot be duplicated, yes? That being the
case, how is this attribute different from the existing
[[clang::noduplicate]] / __attribute__((noduplicate)) attribute?

Based on Transforms/JumpThreading/basic.ll:
>
> define void @h_con(i32 %p) {
>   %x = icmp ult i32 %p, 5
>   br i1 %x, label %l1, label %l2
>
> l1:
>   call void @j()
>   br label %l3
>
> l2:
>   call void @k()
>   br label %l3
>
> l3:
> ; CHECK: call void @g() [[CON:#[0-9]+]]
> ; CHECK-NOT: call void @g() [[CON]]
>   call void @g() convergent
>   %y = icmp ult i32 %p, 5
>   br i1 %y, label %l4, label %l5
>
> l4:
>   call void @j()
>   ret void
>
> l5:
>   call void @k()
>   ret void
> ; CHECK: }
> }
>
> If you do not mark baz convergent, you get this:
>
> clang -x cl -emit-llvm -S -o - test.c -O0 | opt -mem2reg -jump-threading -S
>
> define void @bar(i32 %x) #0 {
> entry:
>   %cmp = icmp slt i32 %x, 5
>   br i1 %cmp, label %if.then2, label %if.else3
>
> if.then2: ; preds = %entry
>   call void @foo0()
>   call void @baz()
>   call void @foo0()
>   br label %if.end4
>
> if.else3: ; preds = %entry
>   call void @foo1()
>   call void @baz()
>   call void @foo1()
>   br label %if.end4
>
> if.end4:  ; preds = %if.else3,
> %if.then2
>   ret void
> }
>
> Which is illegal, as the value of x might not be the same for all
> work-items.
>
> I’ll update the patch such as:
>
> * it uses the example about jump-threading
> * it marks the attribute available in OpenCL/Cuda
> * it provides the [[clang::convergent]] attribute
>
> Thanks,
> Ettore Speziale
>
> --
> Ettore Speziale — Compiler Engineer
> speziale.ett...@gmail.com
> espezi...@apple.com
> --
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19932: [OpenCL] Add to_{global|local|private} builtin functions.

2016-05-06 Thread Yaxun Liu via cfe-commits
yaxunl marked 5 inline comments as done.
yaxunl added a comment.

> I agree with Xiuli, if we don't have generic implementation with i8*,  the 
> libraries would have to contain every possible implementation of each AS 
> conversion builtin including user defined types (which we don't even know 
> beforehand).

> 

> I think that bitcast is not an issue in general as soon as passed type is 
> casted from and back to the original type. This way we will disallow loosing 
> the type information if let's say we compile:

> 

>   int *ptr = ...

>   to_global(ptr) -> the return type is global int* (and not global void*)

> 

> 

> Because we can create a bitcast to the original type.


These builtin functions can be lowered by a module pass which tracing the 
argument to determine the real addr space. In that case it does not matter that 
it can take infinite number of names.

However, there may be platforms on which these builtin functions are 
implemented in runtime library. I agree code generated as such will cause 
difficulty for them. Therefore I will emit call to i8 addrspace(1)* to_global 
(i8* addrspace(4)) and insert bitcasts. Also the name will not be mangled.



Comment at: lib/Sema/SemaChecking.cpp:480
@@ +479,3 @@
+  .getQualifiers().getAddressSpace() == LangAS::opencl_constant) {
+S.Diag(Call->getLocStart(), diag::err_opencl_builtin_to_addr_invalid_arg)
+<< Call->getArg(0) << Call->getDirectCallee() << 
Call->getSourceRange();

Anastasia wrote:
> Should we also check that argument and return pointer type match?
> 
> Also we should probably check that the return type is in the right AS. 
The return type is generated based on the function and argument type. It always 
matches the argument type and has right AS. If the context of this call expr 
expects a different type, diagnostics will be emitted by the enclosing context.


Comment at: lib/Sema/SemaExpr.cpp:5222
@@ -5166,5 +5221,3 @@
 if (FDecl && FDecl->getBuiltinID()) {
-  // Rewrite the function decl for this builtin by replacing parameters
-  // with no explicit address space with the address space of the arguments
-  // in ArgExprs.
-  if ((FDecl = rewriteBuiltinFunctionDecl(this, Context, FDecl, 
ArgExprs))) {
+  // Rewrite the function decl for OpenCL to_addr builtin.
+  if (FunctionDecl *NFDecl = rewriteBuiltinFunctionDeclForOpenCLToAddr(

Anastasia wrote:
> Is there any reason not to do normal IR CodeGen in CGBuiltin.cpp like we did 
> for pipes:
> http://reviews.llvm.org/D15914
> 
> Otherwise, it seems like we add an extra overhead for all the builtins and it 
> doesn't seem any simpler code either.
In that case the type of the call expr does not need to be dynamically 
generated.

In this case, the type of the call expr depends on the argument type. If we 
don't dynamically generate the prototype of the builtin function, we have to 
insert bitcast, which results in an AST which is no longer a call expr and the 
diagnostics will become ugly.


http://reviews.llvm.org/D19932



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


[PATCH] D20034: [CUDA] Only __shared__ variables can be static local on device side.

2016-05-06 Thread Artem Belevich via cfe-commits
tra created this revision.
tra added reviewers: jingyue, jlebar.
tra added a subscriber: cfe-commits.

According to CUDA programming guide (v7.5):

> E.2.9.4: Within the body of a __device__ or __global__ function, only 
> __shared__ variables may be declared with static storage class.



http://reviews.llvm.org/D20034

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/CodeGenCUDA/device-var-init.cu

Index: test/CodeGenCUDA/device-var-init.cu
===
--- test/CodeGenCUDA/device-var-init.cu
+++ test/CodeGenCUDA/device-var-init.cu
@@ -368,6 +368,14 @@
   T_F_NEC t_f_nec;
   T_FA_NEC t_fa_nec;
   static __shared__ UC s_uc;
+#if ERROR_CASE
+  static __device__ int ds; 
+  // expected-error@-1 {{Within a __device__/__global__ function, only 
__shared__ variables may be marked "static"}}
+  static __constant__ int dc;
+  // expected-error@-1 {{Within a __device__/__global__ function, only 
__shared__ variables may be marked "static"}}
+  static int v;
+  // expected-error@-1 {{Within a __device__/__global__ function, only 
__shared__ variables may be marked "static"}}
+#endif
 }
 
 // CHECK:   call void @_ZN2ECC1Ev(%struct.EC* %ec)
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -10389,15 +10389,24 @@
 }
   }
 
-  // Static locals inherit dll attributes from their function.
   if (VD->isStaticLocal()) {
 if (FunctionDecl *FD =
 dyn_cast_or_null(VD->getParentFunctionOrMethod())) {
+  // Static locals inherit dll attributes from their function.
   if (Attr *A = getDLLAttr(FD)) {
 auto *NewAttr = cast(A->clone(getASTContext()));
 NewAttr->setInherited(true);
 VD->addAttr(NewAttr);
   }
+  // CUDA E.2.9.4: Within the body of a __device__ or __global__
+  // function, only __shared__ variables may be declared with
+  // static storage class.
+  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice &&
+  (FD->hasAttr() || FD->hasAttr()) &&
+  !VD->hasAttr()) {
+Diag(VD->getLocation(), diag::err_device_static_local_var);
+VD->setInvalidDecl();
+  }
 }
   }
 
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6556,7 +6556,9 @@
 "__device__, __constant__, and __shared__ variables.">;
 def err_shared_var_init : Error<
 "initialization is not supported for __shared__ variables.">;
-
+def err_device_static_local_var : Error<
+"Within a __device__/__global__ function, "
+"only __shared__ variables may be marked \"static\"">;
 def warn_non_pod_vararg_with_format_string : Warning<
   "cannot pass %select{non-POD|non-trivial}0 object of type %1 to variadic "
   "%select{function|block|method|constructor}2; expected type from format "


Index: test/CodeGenCUDA/device-var-init.cu
===
--- test/CodeGenCUDA/device-var-init.cu
+++ test/CodeGenCUDA/device-var-init.cu
@@ -368,6 +368,14 @@
   T_F_NEC t_f_nec;
   T_FA_NEC t_fa_nec;
   static __shared__ UC s_uc;
+#if ERROR_CASE
+  static __device__ int ds; 
+  // expected-error@-1 {{Within a __device__/__global__ function, only __shared__ variables may be marked "static"}}
+  static __constant__ int dc;
+  // expected-error@-1 {{Within a __device__/__global__ function, only __shared__ variables may be marked "static"}}
+  static int v;
+  // expected-error@-1 {{Within a __device__/__global__ function, only __shared__ variables may be marked "static"}}
+#endif
 }
 
 // CHECK:   call void @_ZN2ECC1Ev(%struct.EC* %ec)
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -10389,15 +10389,24 @@
 }
   }
 
-  // Static locals inherit dll attributes from their function.
   if (VD->isStaticLocal()) {
 if (FunctionDecl *FD =
 dyn_cast_or_null(VD->getParentFunctionOrMethod())) {
+  // Static locals inherit dll attributes from their function.
   if (Attr *A = getDLLAttr(FD)) {
 auto *NewAttr = cast(A->clone(getASTContext()));
 NewAttr->setInherited(true);
 VD->addAttr(NewAttr);
   }
+  // CUDA E.2.9.4: Within the body of a __device__ or __global__
+  // function, only __shared__ variables may be declared with
+  // static storage class.
+  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice &&
+  (FD->hasAttr() || FD->hasAttr()) &&
+  !VD->hasAttr()) {
+Diag(VD->getLocation(), diag::err_device_static_local_var);
+VD->setInvalidDecl();
+  }
 }
   }
 
Index: include/clang/Basic/DiagnosticSemaKinds.td

r268797 - Fix sysroot-prefix.c on Windows (/ vs \).

2016-05-06 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri May  6 16:17:32 2016
New Revision: 268797

URL: http://llvm.org/viewvc/llvm-project?rev=268797&view=rev
Log:
Fix sysroot-prefix.c on Windows (/ vs \).

Modified:
cfe/trunk/test/Preprocessor/sysroot-prefix.c

Modified: cfe/trunk/test/Preprocessor/sysroot-prefix.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/sysroot-prefix.c?rev=268797&r1=268796&r2=268797&view=diff
==
--- cfe/trunk/test/Preprocessor/sysroot-prefix.c (original)
+++ cfe/trunk/test/Preprocessor/sysroot-prefix.c Fri May  6 16:17:32 2016
@@ -14,12 +14,12 @@
 // CHECK-NO_ISYSROOT_SYSROOT_DEV_NULL: ignoring nonexistent directory 
"=/var/empty/include"
 // CHECK-NO_ISYSROOT_SYSROOT_DEV_NULL-NOT: ignoring nonexistent directory 
"/var/empty/include"
 
-// CHECK-ISYSROOT_SYSROOT_NULL: ignoring nonexistent directory 
"/var/empty/null"
+// CHECK-ISYSROOT_SYSROOT_NULL: ignoring nonexistent directory 
"/var/empty{{.}}null"
 // CHECK-ISYSROOT_SYSROOT_NULL-NOT: ignoring nonexistent directory "=null"
 
-// CHECK-ISYSROOT_ISYSROOT_SYSROOT_NULL: ignoring nonexistent directory 
"/var/empty/root/null"
+// CHECK-ISYSROOT_ISYSROOT_SYSROOT_NULL: ignoring nonexistent directory 
"/var/empty/root{{.}}null"
 // CHECK-ISYSROOT_ISYSROOT_SYSROOT_NULL-NOT: ignoring nonexistent directory 
"=null"
 
-// CHECK-ISYSROOT_ISYSROOT_SWAPPED_SYSROOT_NULL: ignoring nonexistent 
directory "/var/empty/null"
+// CHECK-ISYSROOT_ISYSROOT_SWAPPED_SYSROOT_NULL: ignoring nonexistent 
directory "/var/empty{{.}}null"
 // CHECK-ISYSROOT_ISYSROOT_SWAPPED_SYSROOT_NULL-NOT: ignoring nonexistent 
directory "=null"
 


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


r268793 - Availability: set location when creating attribute for tvos, watchos.

2016-05-06 Thread Manman Ren via cfe-commits
Author: mren
Date: Fri May  6 16:04:01 2016
New Revision: 268793

URL: http://llvm.org/viewvc/llvm-project?rev=268793&view=rev
Log:
Availability: set location when creating attribute for tvos, watchos.

When inferring availability attributes for tvos, watchos from ios, we
use the same source location and set the implicit bit to true.

So when emitting diagnostics on inferred attributes, we have a source
location.

rdar://25893544

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/attr-availability-tvos.c

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=268793&r1=268792&r2=268793&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri May  6 16:04:01 2016
@@ -2158,6 +2158,7 @@ public:
   /// Attribute merging methods. Return true if a new attribute was added.
   AvailabilityAttr *mergeAvailabilityAttr(NamedDecl *D, SourceRange Range,
   IdentifierInfo *Platform,
+  bool Implicit,
   VersionTuple Introduced,
   VersionTuple Deprecated,
   VersionTuple Obsoleted,

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=268793&r1=268792&r2=268793&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri May  6 16:04:01 2016
@@ -2204,7 +2204,8 @@ static bool mergeDeclAttribute(Sema &S,
   unsigned AttrSpellingListIndex = Attr->getSpellingListIndex();
   if (const auto *AA = dyn_cast(Attr))
 NewAttr = S.mergeAvailabilityAttr(D, AA->getRange(), AA->getPlatform(),
-  AA->getIntroduced(), AA->getDeprecated(),
+  AA->isImplicit(), AA->getIntroduced(),
+  AA->getDeprecated(),
   AA->getObsoleted(), AA->getUnavailable(),
   AA->getMessage(), AA->getStrict(),
   AA->getReplacement(), AMK,

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=268793&r1=268792&r2=268793&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri May  6 16:04:01 2016
@@ -1957,6 +1957,7 @@ static bool versionsMatch(const VersionT
 
 AvailabilityAttr *Sema::mergeAvailabilityAttr(NamedDecl *D, SourceRange Range,
   IdentifierInfo *Platform,
+  bool Implicit,
   VersionTuple Introduced,
   VersionTuple Deprecated,
   VersionTuple Obsoleted,
@@ -2001,14 +2002,14 @@ AvailabilityAttr *Sema::mergeAvailabilit
   // If there is an existing availability attribute for this platform that
   // is explicit and the new one is implicit use the explicit one and
   // discard the new implicit attribute.
-  if (OldAA->getRange().isValid() && Range.isInvalid()) {
+  if (!OldAA->isImplicit() && Implicit) {
 return nullptr;
   }
 
   // If there is an existing attribute for this platform that is implicit
   // and the new attribute is explicit then erase the old one and
   // continue processing the attributes.
-  if (Range.isValid() && OldAA->getRange().isInvalid()) {
+  if (!Implicit && OldAA->isImplicit()) {
 Attrs.erase(Attrs.begin() + i);
 --e;
 continue;
@@ -2107,11 +2108,13 @@ AvailabilityAttr *Sema::mergeAvailabilit
   if (!checkAvailabilityAttr(*this, Range, Platform, MergedIntroduced,
  MergedDeprecated, MergedObsoleted) &&
   !OverrideOrImpl) {
-return ::new (Context) AvailabilityAttr(Range, Context, Platform,
+auto *Avail =  ::new (Context) AvailabilityAttr(Range, Context, Platform,
 Introduced, Deprecated,
 Obsoleted, IsUnavailable, Message,
 IsStrict, Replacement,
 AttrSpellingListIndex);
+Avail->setImplicit(Implicit);
+return Avail;
   }
   return nullptr;
 }
@@ -2149,6 +2152,7 @@ static void handleAvailabilityAttr(Sema
 Replacement = SE->getSt

Re: [Clang] Convergent Attribute

2016-05-06 Thread Ettore Speziale via cfe-commits
Hello,

> In the case of foo, there could be a problem.
> If you do not mark it convergent, the LLVM sink pass push the call to foo to 
> the then branch of the ternary operator, hence the program has been 
> incorrectly optimized.
> 
> Really? It looks like the problem is that you lied to the compiler by marking 
> the function as 'pure'. The barrier is a side-effect that cannot be removed 
> or duplicated, so it's not correct to mark this function as pure.

I was trying to write a very small example to trick LLVM and trigger the 
optimization. It is based on Transforms/Sink/convergent.ll:

define i32 @foo(i1 %arg) {
entry:
  %c = call i32 @bar() readonly convergent
  br i1 %arg, label %then, label %end

then:
  ret i32 %c

end:
  ret i32 0
}

declare i32 @bar() readonly convergent

Here is another example:

void foo0(void);
void foo1(void);

__attribute__((convergent)) void baz() {
  barrier(CLK_GLOBAL_MEM_FENCE);
}

void bar(int x, global int *y) {
  if (x < 5)
foo0();
  else
foo1();

  baz();

  if (x < 5)
foo0();
  else
foo1();
}

Based on Transforms/JumpThreading/basic.ll:

define void @h_con(i32 %p) {
  %x = icmp ult i32 %p, 5
  br i1 %x, label %l1, label %l2

l1:
  call void @j()
  br label %l3

l2:
  call void @k()
  br label %l3

l3:
; CHECK: call void @g() [[CON:#[0-9]+]]
; CHECK-NOT: call void @g() [[CON]]
  call void @g() convergent
  %y = icmp ult i32 %p, 5
  br i1 %y, label %l4, label %l5

l4:
  call void @j()
  ret void

l5:
  call void @k()
  ret void
; CHECK: }
}

If you do not mark baz convergent, you get this:

clang -x cl -emit-llvm -S -o - test.c -O0 | opt -mem2reg -jump-threading -S

define void @bar(i32 %x) #0 {
entry:
  %cmp = icmp slt i32 %x, 5
  br i1 %cmp, label %if.then2, label %if.else3

if.then2: ; preds = %entry
  call void @foo0()
  call void @baz()
  call void @foo0()
  br label %if.end4

if.else3: ; preds = %entry
  call void @foo1()
  call void @baz()
  call void @foo1()
  br label %if.end4

if.end4:  ; preds = %if.else3, %if.then2
  ret void
}

Which is illegal, as the value of x might not be the same for all work-items.

I’ll update the patch such as:

* it uses the example about jump-threading
* it marks the attribute available in OpenCL/Cuda
* it provides the [[clang::convergent]] attribute

Thanks,
Ettore Speziale

--
Ettore Speziale — Compiler Engineer
speziale.ett...@gmail.com
espezi...@apple.com
--

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


Re: [PATCH] D19932: [OpenCL] Add to_{global|local|private} builtin functions.

2016-05-06 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

In http://reviews.llvm.org/D19932#422374, @yaxunl wrote:

> In http://reviews.llvm.org/D19932#421961, @pxli168 wrote:
>
> > Could we output a generic function in CodeGen?
> >  This seems to have no big difference to have a lot of declaration in an 
> > opencl c header file.
>
>
> What return type and argument type to use would you suggest for this generic 
> function? If it is something like
>
>   i8 addrspace(1)* to_global(i8 addrspace(4)*)
>   
>
> then bitcasts will be needed, which is what we want to avoid.
>
> These functions accept pointers to arbitrary user types, so they cannot be 
> declared in a header file.


I agree with Xiuli, if we don't have generic implementation with i8*,  the 
libraries would have to contain every possible implementation of each AS 
conversion builtin including user defined types (which we don't even know 
beforehand).

I think that bitcast is not an issue in general as soon as passed type is 
casted from and back to the original type. This way we will disallow loosing 
the type information if let's say we compile:

  int *ptr = ...
  to_global(ptr) -> the return type is global int* (and not global void*)
   

Because we can create a bitcast to the original type.



Comment at: include/clang/Basic/Builtins.def:1292
@@ +1291,3 @@
+// OpenCL v2.0 s6.13.9 - Address space qualifier functions.
+LANGBUILTIN(to_global, "v*v*", "tn", OCLC_LANG)
+LANGBUILTIN(to_local, "v*v*", "tn", OCLC_LANG)

I think we should not enable those builtins for all OpenCL versions as it 
prevents using those identifiers. I don't think they are reserved in the 
earlier OpenCL versions?

But I have a patch fixing it for all CL2.0 builtins. I can upload later. No 
need to fix now!


Comment at: lib/CodeGen/CGBuiltin.cpp:2127
@@ -2126,1 +2126,3 @@
 
+  // OpenCL v2.0 s6.13.9 Address space qualifier functions.
+  case Builtin::BIto_global:

Could you add "-" before "Address ..." to match general style.


Comment at: lib/CodeGen/CGBuiltin.cpp:2138
@@ +2137,3 @@
+Builder.CreateCall(CGM.CreateRuntimeFunction(FTy,
+  CGM.getMangledName(E->getDirectCallee())), {Arg0}));
+  }

I don't think mangling would work here at all. See my general comment to the 
generated prototype discussion.


Comment at: lib/Sema/SemaChecking.cpp:480
@@ +479,3 @@
+  .getQualifiers().getAddressSpace() == LangAS::opencl_constant) {
+S.Diag(Call->getLocStart(), diag::err_opencl_builtin_to_addr_invalid_arg)
+<< Call->getArg(0) << Call->getDirectCallee() << 
Call->getSourceRange();

Should we also check that argument and return pointer type match?

Also we should probably check that the return type is in the right AS. 


Comment at: lib/Sema/SemaExpr.cpp:5222
@@ -5166,5 +5221,3 @@
 if (FDecl && FDecl->getBuiltinID()) {
-  // Rewrite the function decl for this builtin by replacing parameters
-  // with no explicit address space with the address space of the arguments
-  // in ArgExprs.
-  if ((FDecl = rewriteBuiltinFunctionDecl(this, Context, FDecl, 
ArgExprs))) {
+  // Rewrite the function decl for OpenCL to_addr builtin.
+  if (FunctionDecl *NFDecl = rewriteBuiltinFunctionDeclForOpenCLToAddr(

Is there any reason not to do normal IR CodeGen in CGBuiltin.cpp like we did 
for pipes:
http://reviews.llvm.org/D15914

Otherwise, it seems like we add an extra overhead for all the builtins and it 
doesn't seem any simpler code either.


http://reviews.llvm.org/D19932



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


Re: [Clang] Convergent Attribute

2016-05-06 Thread Richard Smith via cfe-commits
On Wed, May 4, 2016 at 5:47 PM, Ettore Speziale via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hello,
>
> > I would appreciate a bit more background on this attribute's
> > semantics. How would a user know when to add this attribute to their
> > function definition? Are there other attributes that cannot be used in
> > conjunction with this one? Should this apply to member functions? What
> > about Objective-C methods?
>
> The convergent attribute is meant to be used with languages supporting the
> SIMT execution model, like OpenCL.
>
> I put the following example in the documentation:
>
>   __attribute__((convergent)) __attribute__((pure)) int foo(void) {
> int x;
> ...
> barrier(CLK_GLOBAL_MEM_FENCE);
> ...
> return x;
>   }
>
>   kernel void bar(global int *y) {
> int z = foo();
> *y = get_global_id() == 0 ? z : 0;
>   }
>
> The call to barrier must be either executed by all work-items in a
> work-group, or by none of them.
> This is a requirement of OpenCL, and is left to the programmer to ensure
> that happens.
>
> In the case of foo, there could be a problem.
> If you do not mark it convergent, the LLVM sink pass push the call to foo
> to the then branch of the ternary operator, hence the program has been
> incorrectly optimized.
>

Really? It looks like the problem is that you lied to the compiler by
marking the function as 'pure'. The barrier is a side-effect that cannot be
removed or duplicated, so it's not correct to mark this function as pure.


> The LLVM convergent attribute has been introduced in order to solve this
> problem for intrinsic functions.
> The goal of this patch is to expose that attribute at the CLANG level, so
> it can be used on all functions.
>
> The user is supposed to add such attribute when the function requires
> convergent execution, like in the example above.
>
> I’m not aware of any attribute that would conflict with convergent.
>
> The convergent attribute can be applied as well to member functions.
>
> The convergent attribute cannot be applied to Objective-C methods right
> now — it will be ignored:
>
> test.c:14:27: warning: 'convergent' attribute only applies to functions
> [-Wignored-attributes]
> - (void) x __attribute__((convergent));
>
> Since convergent is meant for languages supporting the SIMT execution
> model, and to the best of my knowledge I’m not aware of any language based
> on Objective-C supporting that, I would guess there is no benefit in
> supporting convergent on ObjectiveC methods.
>
> >> diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td
> >> index df41aeb..eafafc6 100644
> >> --- a/include/clang/Basic/Attr.td
> >> +++ b/include/clang/Basic/Attr.td
> >> @@ -580,6 +580,12 @@ def Constructor : InheritableAttr {
> >>   let Documentation = [Undocumented];
> >> }
> >>
> >> +def Convergent : InheritableAttr {
> >> +  let Spellings = [GNU<"convergent">];
> >
> > Is there a reason to not support this under CXX11<"clang",
> > "convergent"> as well?
>
> I’ve just used the most basic spelling, which fit the OpenCL case.
> I can add support for the CXX11 spelling if you find it valuable.
>
> >> +  let Subjects = SubjectList<[Function]>;
> >> +  let Documentation = [Undocumented];
> >
> > Please, no new undocumented attributes.
>
> Fixed, here is updated patch:
>
>
>
>
> Thanks!
>
> --
> Ettore Speziale — Compiler Engineer
> speziale.ett...@gmail.com
> espezi...@apple.com
> --
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r268786 - Availability: attach the note to the declaration with the attributes.

2016-05-06 Thread Manman Ren via cfe-commits
Author: mren
Date: Fri May  6 14:57:16 2016
New Revision: 268786

URL: http://llvm.org/viewvc/llvm-project?rev=268786&view=rev
Log:
Availability: attach the note to the declaration with the attributes.

Sometimes, the declaration we found has inherited availability
attributes, attaching the note to it does not tell us where the
availability attributes are in the source.

Go through the redecl chain to find the declaration with actual
availability attributes.

rdar://25221771

Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/attr-availability-macosx.c

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=268786&r1=268785&r2=268786&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri May  6 14:57:16 2016
@@ -6171,6 +6171,34 @@ static bool isDeclUnavailable(Decl *D) {
   return false;
 }
 
+static const AvailabilityAttr *getAttrForPlatform(ASTContext &Context,
+  const Decl *D) {
+  // Check each AvailabilityAttr to find the one for this platform.
+  for (const auto *A : D->attrs()) {
+if (const auto *Avail = dyn_cast(A)) {
+  // FIXME: this is copied from CheckAvailability. We should try to
+  // de-duplicate.
+
+  // Check if this is an App Extension "platform", and if so chop off
+  // the suffix for matching with the actual platform.
+  StringRef ActualPlatform = Avail->getPlatform()->getName();
+  StringRef RealizedPlatform = ActualPlatform;
+  if (Context.getLangOpts().AppExt) {
+size_t suffix = RealizedPlatform.rfind("_app_extension");
+if (suffix != StringRef::npos)
+  RealizedPlatform = RealizedPlatform.slice(0, suffix);
+  }
+
+  StringRef TargetPlatform = Context.getTargetInfo().getPlatformName();
+
+  // Match the platform name.
+  if (RealizedPlatform == TargetPlatform)
+return Avail;
+}
+  }
+  return nullptr;
+}
+
 static void DoEmitAvailabilityWarning(Sema &S, Sema::AvailabilityDiagnostic K,
   Decl *Ctx, const NamedDecl *D,
   StringRef Message, SourceLocation Loc,
@@ -6268,7 +6296,7 @@ static void DoEmitAvailabilityWarning(Se
   if (K == Sema::AD_Deprecation) {
 if (auto attr = D->getAttr())
   Replacement = attr->getReplacement();
-if (auto attr = D->getAttr())
+if (auto attr = getAttrForPlatform(S.Context, D))
   Replacement = attr->getReplacement();
 
 if (!Replacement.empty())
@@ -6297,8 +6325,27 @@ static void DoEmitAvailabilityWarning(Se
 S.Diag(UnknownObjCClass->getLocation(), diag::note_forward_class);
   }
 
-  S.Diag(D->getLocation(), diag_available_here)
-  << D << available_here_select_kind;
+  // The declaration can have multiple availability attributes, we are looking
+  // at one of them.
+  const AvailabilityAttr *A = getAttrForPlatform(S.Context, D);
+  if (A && A->isInherited()) {
+for (const Decl *Redecl = D->getMostRecentDecl(); Redecl;
+ Redecl = Redecl->getPreviousDecl()) {
+  const AvailabilityAttr *AForRedecl = getAttrForPlatform(S.Context,
+  Redecl);
+  if (AForRedecl && !AForRedecl->isInherited()) {
+// If D is a declaration with inherited attributes, the note should
+// point to the declaration with actual attributes.
+S.Diag(Redecl->getLocation(), diag_available_here) << D
+<< available_here_select_kind;
+break;
+  }
+}
+  }
+  else
+S.Diag(D->getLocation(), diag_available_here)
+<< D << available_here_select_kind;
+
   if (K == Sema::AD_Partial)
 S.Diag(Loc, diag::note_partial_availability_silence) << D;
 }

Modified: cfe/trunk/test/Sema/attr-availability-macosx.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-availability-macosx.c?rev=268786&r1=268785&r2=268786&view=diff
==
--- cfe/trunk/test/Sema/attr-availability-macosx.c (original)
+++ cfe/trunk/test/Sema/attr-availability-macosx.c Fri May  6 14:57:16 2016
@@ -45,3 +45,14 @@ enum {
 enum __attribute__((availability(macosx,introduced=8.0,deprecated=9.0))) {
 bar1 = foo
 };
+
+// Make sure the note is on the declaration with the actual availability 
attributes.
+struct __attribute__((availability(macosx,strict,introduced=10.9))) type_info 
// \
+expected-note{{'type_info' has been explicitly marked unavailable here}}
+{
+};
+struct type_info;
+int test2() {
+  struct type_info *t; // expected-error{{'type_info' is unavailable: 
introduced in OS X 10.9}}
+  return 0;
+}


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

Re: [Clang] Convergent Attribute

2016-05-06 Thread David Majnemer via cfe-commits
I think it could be useful for CUDA too.

On Friday, May 6, 2016, Anastasia Stulova via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi Ettore,
>
> LGTM generally!
>
> I was just wondering whether it would make sense to restrict the usage of
> the attribute to OpenCL language i.e. to add  "let LangOpts = [OpenCL];" in
> the attribute definition.
>
> Thanks!
> Anastasia
>
> -Original Message-
> From: Ettore Speziale [mailto:speziale.ett...@gmail.com ]
> Sent: 05 May 2016 01:48
> To: Aaron Ballman
> Cc: Ettore Speziale; Anastasia Stulova; Clang Commits
> Subject: Re: [Clang] Convergent Attribute
>
> Hello,
>
> > I would appreciate a bit more background on this attribute's
> > semantics. How would a user know when to add this attribute to their
> > function definition? Are there other attributes that cannot be used in
> > conjunction with this one? Should this apply to member functions? What
> > about Objective-C methods?
>
> The convergent attribute is meant to be used with languages supporting the
> SIMT execution model, like OpenCL.
>
> I put the following example in the documentation:
>
>   __attribute__((convergent)) __attribute__((pure)) int foo(void) {
> int x;
> ...
> barrier(CLK_GLOBAL_MEM_FENCE);
> ...
> return x;
>   }
>
>   kernel void bar(global int *y) {
> int z = foo();
> *y = get_global_id() == 0 ? z : 0;
>   }
>
> The call to barrier must be either executed by all work-items in a
> work-group, or by none of them.
> This is a requirement of OpenCL, and is left to the programmer to ensure
> that happens.
>
> In the case of foo, there could be a problem.
> If you do not mark it convergent, the LLVM sink pass push the call to foo
> to the then branch of the ternary operator, hence the program has been
> incorrectly optimized.
>
> The LLVM convergent attribute has been introduced in order to solve this
> problem for intrinsic functions.
> The goal of this patch is to expose that attribute at the CLANG level, so
> it can be used on all functions.
>
> The user is supposed to add such attribute when the function requires
> convergent execution, like in the example above.
>
> I’m not aware of any attribute that would conflict with convergent.
>
> The convergent attribute can be applied as well to member functions.
>
> The convergent attribute cannot be applied to Objective-C methods right
> now — it will be ignored:
>
> test.c:14:27: warning: 'convergent' attribute only applies to functions
> [-Wignored-attributes]
> - (void) x __attribute__((convergent));
>
> Since convergent is meant for languages supporting the SIMT execution
> model, and to the best of my knowledge I’m not aware of any language based
> on Objective-C supporting that, I would guess there is no benefit in
> supporting convergent on ObjectiveC methods.
>
> >> diff --git a/include/clang/Basic/Attr.td
> >> b/include/clang/Basic/Attr.td index df41aeb..eafafc6 100644
> >> --- a/include/clang/Basic/Attr.td
> >> +++ b/include/clang/Basic/Attr.td
> >> @@ -580,6 +580,12 @@ def Constructor : InheritableAttr {
> >>   let Documentation = [Undocumented]; }
> >>
> >> +def Convergent : InheritableAttr {
> >> +  let Spellings = [GNU<"convergent">];
> >
> > Is there a reason to not support this under CXX11<"clang",
> > "convergent"> as well?
>
> I’ve just used the most basic spelling, which fit the OpenCL case.
> I can add support for the CXX11 spelling if you find it valuable.
>
> >> +  let Subjects = SubjectList<[Function]>;  let Documentation =
> >> + [Undocumented];
> >
> > Please, no new undocumented attributes.
>
> Fixed, here is updated patch:
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org 
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r268784 - test: attempt to repair windows build

2016-05-06 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri May  6 14:39:00 2016
New Revision: 268784

URL: http://llvm.org/viewvc/llvm-project?rev=268784&view=rev
Log:
test: attempt to repair windows build

Replace use of /dev/null with /var/empty.  lit will substitute the /dev/null
include path resulting in failures.  Use a path under /var/empty which is
supposed to be empty to ensure that we can successfully test.

Modified:
cfe/trunk/test/Preprocessor/sysroot-prefix.c

Modified: cfe/trunk/test/Preprocessor/sysroot-prefix.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/sysroot-prefix.c?rev=268784&r1=268783&r2=268784&view=diff
==
--- cfe/trunk/test/Preprocessor/sysroot-prefix.c (original)
+++ cfe/trunk/test/Preprocessor/sysroot-prefix.c Fri May  6 14:39:00 2016
@@ -1,21 +1,18 @@
-// RUN: %clang_cc1 -v -isysroot /var/empty -I /dev/null -E %s -o /dev/null 
2>&1 | FileCheck -check-prefix CHECK-ISYSROOT_NO_SYSROOT %s
-// RUN: %clang_cc1 -v -isysroot /var/empty -I =/dev/null -E %s -o /dev/null 
2>&1 | FileCheck -check-prefix CHECK-ISYSROOT_SYSROOT_DEV_NULL %s
-// RUN: %clang_cc1 -v -I =/dev/null -E %s -o /dev/null 2>&1 | FileCheck 
-check-prefix CHECK-NO_ISYSROOT_SYSROOT_DEV_NULL %s
+// RUN: %clang_cc1 -v -isysroot /var/empty -I /var/empty/include -E %s -o 
/dev/null 2>&1 | FileCheck -check-prefix CHECK-ISYSROOT_NO_SYSROOT %s
+// RUN: %clang_cc1 -v -isysroot /var/empty -I =/var/empty/include -E %s -o 
/dev/null 2>&1 | FileCheck -check-prefix CHECK-ISYSROOT_SYSROOT_DEV_NULL %s
+// RUN: %clang_cc1 -v -I =/var/empty/include -E %s -o /dev/null 2>&1 | 
FileCheck -check-prefix CHECK-NO_ISYSROOT_SYSROOT_DEV_NULL %s
 // RUN: %clang_cc1 -v -isysroot /var/empty -I =null -E %s -o /dev/null 2>&1 | 
FileCheck -check-prefix CHECK-ISYSROOT_SYSROOT_NULL %s
 // RUN: %clang_cc1 -v -isysroot /var/empty -isysroot /var/empty/root -I =null 
-E %s -o /dev/null 2>&1 | FileCheck -check-prefix 
CHECK-ISYSROOT_ISYSROOT_SYSROOT_NULL %s
 // RUN: %clang_cc1 -v -isysroot /var/empty/root -isysroot /var/empty -I =null 
-E %s -o /dev/null 2>&1 | FileCheck -check-prefix 
CHECK-ISYSROOT_ISYSROOT_SWAPPED_SYSROOT_NULL %s
 
-// CHECK-ISYSROOT_NO_SYSROOT: ignoring nonexistent directory "/dev/null"
-// CHECK-ISYSROOT_NO_SYSROOT-NOT: ignoring nonexistent directory 
"/var/empty/dev/null"
+// CHECK-ISYSROOT_NO_SYSROOT: ignoring nonexistent directory 
"/var/empty/include"
+// CHECK-ISYSROOT_NO_SYSROOT-NOT: ignoring nonexistent directory 
"/var/empty/var/empty/include"
 
-// CHECK-NO_ISYSROOT_SYSROOT_DEV_NULL: ignoring nonexistent directory 
"=/dev/null"
-// CHECK-NO_ISYSROOT_SYSROOT_DEV_NULL-NOT: ignoring nonexistent directory 
"/dev/null"
+// CHECK-ISYSROOT_SYSROOT_DEV_NULL: ignoring nonexistent directory 
"/var/empty/var/empty/include"
+// CHECK-ISYSROOT_SYSROOT_DEV_NULL-NOT: ignoring nonexistent directory 
"/var/empty"
 
-// CHECK-ISYSROOT_SYSROOT_DEV_NULL: ignoring nonexistent directory 
"/var/empty/dev/null"
-// CHECK-ISYSROOT_SYSROOT_DEV_NULL-NOT: ignoring nonexistent directory 
"/dev/null"
-
-// CHECK-NO_ISYSROOT_SYSROOT: ignoring nonexistent directory "=/dev/null"
-// CHECK-NO_ISYSROOT_SYSROOT-NOT: ignoring nonexistent directory 
"/var/empty/dev/null"
+// CHECK-NO_ISYSROOT_SYSROOT_DEV_NULL: ignoring nonexistent directory 
"=/var/empty/include"
+// CHECK-NO_ISYSROOT_SYSROOT_DEV_NULL-NOT: ignoring nonexistent directory 
"/var/empty/include"
 
 // CHECK-ISYSROOT_SYSROOT_NULL: ignoring nonexistent directory 
"/var/empty/null"
 // CHECK-ISYSROOT_SYSROOT_NULL-NOT: ignoring nonexistent directory "=null"


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


r268781 - ObjC kindof: set the type of a conditional expression when involving kindof.

2016-05-06 Thread Manman Ren via cfe-commits
Author: mren
Date: Fri May  6 14:35:02 2016
New Revision: 268781

URL: http://llvm.org/viewvc/llvm-project?rev=268781&view=rev
Log:
ObjC kindof: set the type of a conditional expression when involving kindof.

When either LHS or RHS is a kindof type, we return a kindof type.

rdar://problem/20513780

Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/SemaObjC/kindof.m

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=268781&r1=268780&r2=268781&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri May  6 14:35:02 2016
@@ -7163,6 +7163,11 @@ QualType ASTContext::areCommonBaseCompat
   if (!LDecl || !RDecl)
 return QualType();
 
+  // When either LHS or RHS is a kindof type, we should return a kindof type.
+  // For example, for common base of kindof(ASub1) and kindof(ASub2), we return
+  // kindof(A).
+  bool anyKindOf = LHS->isKindOfType() || RHS->isKindOfType();
+
   // Follow the left-hand side up the class hierarchy until we either hit a
   // root or find the RHS. Record the ancestors in case we don't find it.
   llvm::SmallDenseMap
@@ -7197,10 +7202,12 @@ QualType ASTContext::areCommonBaseCompat
 anyChanges = true;
 
   // If anything in the LHS will have changed, build a new result type.
-  if (anyChanges) {
+  // If we need to return a kindof type but LHS is not a kindof type, we
+  // build a new result type.
+  if (anyChanges || LHS->isKindOfType() != anyKindOf) {
 QualType Result = getObjCInterfaceType(LHS->getInterface());
 Result = getObjCObjectType(Result, LHSTypeArgs, Protocols,
-   LHS->isKindOfType());
+   anyKindOf || LHS->isKindOfType());
 return getObjCObjectPointerType(Result);
   }
 
@@ -7245,10 +7252,12 @@ QualType ASTContext::areCommonBaseCompat
   if (!Protocols.empty())
 anyChanges = true;
 
-  if (anyChanges) {
+  // If we need to return a kindof type but RHS is not a kindof type, we
+  // build a new result type.
+  if (anyChanges || RHS->isKindOfType() != anyKindOf) {
 QualType Result = getObjCInterfaceType(RHS->getInterface());
 Result = getObjCObjectType(Result, RHSTypeArgs, Protocols,
-   RHS->isKindOfType());
+   anyKindOf || RHS->isKindOfType());
 return getObjCObjectPointerType(Result);
   }
 

Modified: cfe/trunk/test/SemaObjC/kindof.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/kindof.m?rev=268781&r1=268780&r2=268781&view=diff
==
--- cfe/trunk/test/SemaObjC/kindof.m (original)
+++ cfe/trunk/test/SemaObjC/kindof.m Fri May  6 14:35:02 2016
@@ -187,6 +187,39 @@ void test_crosscast_conversions(void) {
   NSString_obj = kindof_NSNumber_obj; // expected-warning{{from '__kindof 
NSNumber *'}}
 }
 
+@interface NSCell : NSObject
+@end
+@interface NSCellSub : NSCell
+@end
+@interface NSCellSub2 : NSCell
+@end
+@interface NSCellSubSub : NSCellSub
+@end
+
+typedef signed char BOOL;
+void test_conditional(BOOL flag) {
+  NSCellSubSub *result;
+  __kindof NSCellSub *kindof_Sub;
+  NSCell *cell;
+  NSCellSub *sub;
+  NSCellSub2 *sub2;
+  NSCellSubSub *subsub;
+
+  // LHS is kindof NSCellSub, RHS is NSCell --> kindof NSCell
+  // LHS is kindof NSCellSub, RHS is NSCellSub --> kindof NSCellSub
+  // LHS is kindof NSCellSub, RHS is NSCellSub2 --> kindof NSCell
+  // LHS is kindof NSCellSub, RHS is NSCellSubSub --> kindof NSCellSub
+  result = flag ? kindof_Sub : cell;
+  result = flag ? kindof_Sub : sub;
+  result = flag ? kindof_Sub : sub2;
+  result = flag ? kindof_Sub : subsub;
+
+  result = flag ? cell : kindof_Sub;
+  result = flag ? sub : kindof_Sub;
+  result = flag ? sub2 : kindof_Sub;
+  result = flag ? subsub : kindof_Sub;
+}
+
 // ---
 // Blocks
 // ---
@@ -277,7 +310,6 @@ void test(__kindof Bar *kBar) {
 }
 
 // Make sure we don't emit warning about no method found.
-typedef signed char BOOL;
 @interface A : NSObject
 @property (readonly, getter=isActive) BOOL active;
 @end


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


r268777 - Frontend: support -I=path for sysroot expansion

2016-05-06 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri May  6 14:13:55 2016
New Revision: 268777

URL: http://llvm.org/viewvc/llvm-project?rev=268777&view=rev
Log:
Frontend: support -I=path for sysroot expansion

From the GCC manpage:

  -I dir
... If dir begins with =, then the = will be replaced by the sysroot prefix;
see --sysroot and -isysroot.

Add support to expand the `=` as a prefix of the include path with the sysroot
if specified.  `-isysroot` takes precedence over `--sysroot` as the normal
argument behaviour occurs.  The ordering of the `-isysroot` is relevant to the
path substituted.  If no `--sysroot=` or `-isysroot` option is present, the = is
not expanded.

Resolves PR26965!

Added:
cfe/trunk/test/Preprocessor/sysroot-prefix.c
Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=268777&r1=268776&r2=268777&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri May  6 14:13:55 2016
@@ -1278,6 +1278,8 @@ static void ParseHeaderSearchArgs(Header
 
   // Add -I..., -F..., and -index-header-map options in order.
   bool IsIndexHeaderMap = false;
+  bool IsSysrootSpecified =
+  Args.hasArg(OPT__sysroot_EQ) || Args.hasArg(OPT_isysroot);
   for (const Arg *A : Args.filtered(OPT_I, OPT_F, OPT_index_header_map)) {
 if (A->getOption().matches(OPT_index_header_map)) {
   // -index-header-map applies to the next -I or -F.
@@ -1288,8 +1290,18 @@ static void ParseHeaderSearchArgs(Header
 frontend::IncludeDirGroup Group =
 IsIndexHeaderMap ? frontend::IndexHeaderMap : frontend::Angled;
 
-Opts.AddPath(A->getValue(), Group,
- /*IsFramework=*/A->getOption().matches(OPT_F), true);
+bool IsFramework = A->getOption().matches(OPT_F);
+std::string Path = A->getValue();
+
+if (IsSysrootSpecified && !IsFramework && A->getValue()[0] == '=') {
+  SmallString<32> Buffer;
+  llvm::sys::path::append(Buffer, Opts.Sysroot,
+  llvm::StringRef(A->getValue()).substr(1));
+  Path = Buffer.str();
+}
+
+Opts.AddPath(Path.c_str(), Group, IsFramework,
+ /*IgnoreSysroot*/ true);
 IsIndexHeaderMap = false;
   }
 

Added: cfe/trunk/test/Preprocessor/sysroot-prefix.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/sysroot-prefix.c?rev=268777&view=auto
==
--- cfe/trunk/test/Preprocessor/sysroot-prefix.c (added)
+++ cfe/trunk/test/Preprocessor/sysroot-prefix.c Fri May  6 14:13:55 2016
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -v -isysroot /var/empty -I /dev/null -E %s -o /dev/null 
2>&1 | FileCheck -check-prefix CHECK-ISYSROOT_NO_SYSROOT %s
+// RUN: %clang_cc1 -v -isysroot /var/empty -I =/dev/null -E %s -o /dev/null 
2>&1 | FileCheck -check-prefix CHECK-ISYSROOT_SYSROOT_DEV_NULL %s
+// RUN: %clang_cc1 -v -I =/dev/null -E %s -o /dev/null 2>&1 | FileCheck 
-check-prefix CHECK-NO_ISYSROOT_SYSROOT_DEV_NULL %s
+// RUN: %clang_cc1 -v -isysroot /var/empty -I =null -E %s -o /dev/null 2>&1 | 
FileCheck -check-prefix CHECK-ISYSROOT_SYSROOT_NULL %s
+// RUN: %clang_cc1 -v -isysroot /var/empty -isysroot /var/empty/root -I =null 
-E %s -o /dev/null 2>&1 | FileCheck -check-prefix 
CHECK-ISYSROOT_ISYSROOT_SYSROOT_NULL %s
+// RUN: %clang_cc1 -v -isysroot /var/empty/root -isysroot /var/empty -I =null 
-E %s -o /dev/null 2>&1 | FileCheck -check-prefix 
CHECK-ISYSROOT_ISYSROOT_SWAPPED_SYSROOT_NULL %s
+
+// CHECK-ISYSROOT_NO_SYSROOT: ignoring nonexistent directory "/dev/null"
+// CHECK-ISYSROOT_NO_SYSROOT-NOT: ignoring nonexistent directory 
"/var/empty/dev/null"
+
+// CHECK-NO_ISYSROOT_SYSROOT_DEV_NULL: ignoring nonexistent directory 
"=/dev/null"
+// CHECK-NO_ISYSROOT_SYSROOT_DEV_NULL-NOT: ignoring nonexistent directory 
"/dev/null"
+
+// CHECK-ISYSROOT_SYSROOT_DEV_NULL: ignoring nonexistent directory 
"/var/empty/dev/null"
+// CHECK-ISYSROOT_SYSROOT_DEV_NULL-NOT: ignoring nonexistent directory 
"/dev/null"
+
+// CHECK-NO_ISYSROOT_SYSROOT: ignoring nonexistent directory "=/dev/null"
+// CHECK-NO_ISYSROOT_SYSROOT-NOT: ignoring nonexistent directory 
"/var/empty/dev/null"
+
+// CHECK-ISYSROOT_SYSROOT_NULL: ignoring nonexistent directory 
"/var/empty/null"
+// CHECK-ISYSROOT_SYSROOT_NULL-NOT: ignoring nonexistent directory "=null"
+
+// CHECK-ISYSROOT_ISYSROOT_SYSROOT_NULL: ignoring nonexistent directory 
"/var/empty/root/null"
+// CHECK-ISYSROOT_ISYSROOT_SYSROOT_NULL-NOT: ignoring nonexistent directory 
"=null"
+
+// CHECK-ISYSROOT_ISYSROOT_SWAPPED_SYSROOT_NULL: ignoring nonexistent 
directory "/var/empty/null"
+// CHECK-ISYSROOT_ISYSROOT_SWAPPED_SYSROOT_NULL-NOT: ignoring nonexistent 
directory "=null"
+


___
cfe-com

Re: [PATCH] D19780: Output OpenCL version in Clang diagnostics

2016-05-06 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: lib/Parse/ParseDecl.cpp:3519
@@ +3518,3 @@
+   / 100);
+const char *VerSpec = (VerMajor + std::string (".") + 
VerMinor).c_str();
+Diag(Tok, DiagID) << VerSpec << PrevSpec << isStorageClass;

rivanvx wrote:
> Anastasia wrote:
> > I think it will be nicer to use string (not char*) here too.
> Other Spec are const char*, so I did it for consistency. But I don't care 
> either way.
Yes, it will be shorter. StringRef should work too I think.

Thanks!


http://reviews.llvm.org/D19780



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


RE: [Clang] Convergent Attribute

2016-05-06 Thread Anastasia Stulova via cfe-commits
Hi Ettore,

LGTM generally!

I was just wondering whether it would make sense to restrict the usage of the 
attribute to OpenCL language i.e. to add  "let LangOpts = [OpenCL];" in the 
attribute definition.

Thanks!
Anastasia

-Original Message-
From: Ettore Speziale [mailto:speziale.ett...@gmail.com] 
Sent: 05 May 2016 01:48
To: Aaron Ballman
Cc: Ettore Speziale; Anastasia Stulova; Clang Commits
Subject: Re: [Clang] Convergent Attribute

Hello,

> I would appreciate a bit more background on this attribute's 
> semantics. How would a user know when to add this attribute to their 
> function definition? Are there other attributes that cannot be used in 
> conjunction with this one? Should this apply to member functions? What 
> about Objective-C methods?

The convergent attribute is meant to be used with languages supporting the SIMT 
execution model, like OpenCL.

I put the following example in the documentation:

  __attribute__((convergent)) __attribute__((pure)) int foo(void) {
int x;
...
barrier(CLK_GLOBAL_MEM_FENCE);
...
return x;
  }

  kernel void bar(global int *y) {
int z = foo();
*y = get_global_id() == 0 ? z : 0;
  }

The call to barrier must be either executed by all work-items in a work-group, 
or by none of them.
This is a requirement of OpenCL, and is left to the programmer to ensure that 
happens.

In the case of foo, there could be a problem.
If you do not mark it convergent, the LLVM sink pass push the call to foo to 
the then branch of the ternary operator, hence the program has been incorrectly 
optimized.

The LLVM convergent attribute has been introduced in order to solve this 
problem for intrinsic functions.
The goal of this patch is to expose that attribute at the CLANG level, so it 
can be used on all functions.

The user is supposed to add such attribute when the function requires 
convergent execution, like in the example above.

I’m not aware of any attribute that would conflict with convergent.

The convergent attribute can be applied as well to member functions.

The convergent attribute cannot be applied to Objective-C methods right now — 
it will be ignored:

test.c:14:27: warning: 'convergent' attribute only applies to functions 
[-Wignored-attributes]
- (void) x __attribute__((convergent));

Since convergent is meant for languages supporting the SIMT execution model, 
and to the best of my knowledge I’m not aware of any language based on 
Objective-C supporting that, I would guess there is no benefit in supporting 
convergent on ObjectiveC methods.

>> diff --git a/include/clang/Basic/Attr.td 
>> b/include/clang/Basic/Attr.td index df41aeb..eafafc6 100644
>> --- a/include/clang/Basic/Attr.td
>> +++ b/include/clang/Basic/Attr.td
>> @@ -580,6 +580,12 @@ def Constructor : InheritableAttr {
>>   let Documentation = [Undocumented]; }
>> 
>> +def Convergent : InheritableAttr {
>> +  let Spellings = [GNU<"convergent">];
> 
> Is there a reason to not support this under CXX11<"clang", 
> "convergent"> as well?

I’ve just used the most basic spelling, which fit the OpenCL case.
I can add support for the CXX11 spelling if you find it valuable.

>> +  let Subjects = SubjectList<[Function]>;  let Documentation = 
>> + [Undocumented];
> 
> Please, no new undocumented attributes.

Fixed, here is updated patch:

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


r268773 - [analyzer] Add tests for Objective-C class properties

2016-05-06 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Fri May  6 13:24:50 2016
New Revision: 268773

URL: http://llvm.org/viewvc/llvm-project?rev=268773&view=rev
Log:
[analyzer] Add tests for Objective-C class properties

Add basic tests to ensure the analyzer has support for class properties. This
is a test-only change.

rdar://problem/25256807

Modified:
cfe/trunk/test/Analysis/properties.m

Modified: cfe/trunk/test/Analysis/properties.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/properties.m?rev=268773&r1=268772&r2=268773&view=diff
==
--- cfe/trunk/test/Analysis/properties.m (original)
+++ cfe/trunk/test/Analysis/properties.m Fri May  6 13:24:50 2016
@@ -384,6 +384,114 @@ void testConsistencyAssign(Person *p) {
 #endif
 @end
 
+//--
+// class properties
+//--
+
+int gBackingForReadWriteClassProp = 0;
+
+@interface ClassWithClassProperties
+@property(class, readonly) int readOnlyClassProp;
+
+@property(class) int readWriteClassProp;
+
+// Make sure we handle when a class and instance property have the same
+// name. Test both when instance comes first and when class comes first.
+@property(readonly) int classAndInstancePropWithSameNameOrderInstanceFirst;
+@property(class, readonly) int 
classAndInstancePropWithSameNameOrderInstanceFirst;
+
+@property(class, readonly) int classAndInstancePropWithSameNameOrderClassFirst;
+@property(readonly) int classAndInstancePropWithSameNameOrderClassFirst;
+
+
+@property(class, readonly) int dynamicClassProp;
+
+@end
+
+@interface ClassWithClassProperties (OtherTranslationUnit)
+@property(class, assign) id propInOtherTranslationUnit;
+@end
+
+@implementation ClassWithClassProperties
+
+@dynamic dynamicClassProp;
+
++ (int)readOnlyClassProp {
+  return 1;
+}
+
++ (int)readWriteClassProp {
+  return gBackingForReadWriteClassProp;
+}
+
++ (void)setReadWriteClassProp:(int)val {
+  gBackingForReadWriteClassProp = val;
+}
+
+- (int)classAndInstancePropWithSameNameOrderInstanceFirst {
+  return 12;
+}
+
++ (int)classAndInstancePropWithSameNameOrderInstanceFirst {
+  return 13;
+}
+
++ (int)classAndInstancePropWithSameNameOrderClassFirst {
+  return 14;
+}
+
+- (int)classAndInstancePropWithSameNameOrderClassFirst {
+  return 15;
+}
+
+- (void)testInlineClassProp {
+  clang_analyzer_eval(ClassWithClassProperties.readOnlyClassProp == 1); // 
expected-warning{{TRUE}}
+
+  ClassWithClassProperties.readWriteClassProp = 7;
+  clang_analyzer_eval(ClassWithClassProperties.readWriteClassProp == 7); // 
expected-warning{{TRUE}}
+  ClassWithClassProperties.readWriteClassProp = 8;
+  clang_analyzer_eval(ClassWithClassProperties.readWriteClassProp == 8); // 
expected-warning{{TRUE}}
+}
+
+- (void)testUnknownClassProp {
+  clang_analyzer_eval(ClassWithClassProperties.propInOtherTranslationUnit == 
ClassWithClassProperties.propInOtherTranslationUnit); // 
expected-warning{{UNKNOWN}}
+}
+
+- (void)testEscapeGlobalOnUnknownProp {
+  gBackingForReadWriteClassProp = 33;
+  ClassWithClassProperties.propInOtherTranslationUnit = 0;
+  clang_analyzer_eval(gBackingForReadWriteClassProp == 33); // 
expected-warning{{UNKNOWN}}
+}
+
+- (void)testClassAndInstancePropertyWithSameName {
+  clang_analyzer_eval(self.classAndInstancePropWithSameNameOrderInstanceFirst 
== 12); // expected-warning{{TRUE}}
+  
clang_analyzer_eval(ClassWithClassProperties.classAndInstancePropWithSameNameOrderInstanceFirst
 == 13); // expected-warning{{TRUE}}
+
+  
clang_analyzer_eval(ClassWithClassProperties.classAndInstancePropWithSameNameOrderClassFirst
 == 14); // expected-warning{{TRUE}}
+  clang_analyzer_eval(self.classAndInstancePropWithSameNameOrderClassFirst == 
15); // expected-warning{{TRUE}}
+}
+
+- (void)testDynamicClassProp {
+  clang_analyzer_eval(ClassWithClassProperties.dynamicClassProp == 16); // 
expected-warning{{UNKNOWN}}
+}
+
+@end
+
+@interface SubclassOfClassWithClassProperties : ClassWithClassProperties
+@end
+
+@implementation SubclassOfClassWithClassProperties
++ (int)dynamicClassProp; {
+ return 16;
+}
+
+- (void)testDynamicClassProp {
+  clang_analyzer_eval(SubclassOfClassWithClassProperties.dynamicClassProp == 
16); // expected-warning{{TRUE}}
+}
+
+@end
+
+
 #if !__has_feature(objc_arc)
 void testOverrelease(Person *p, int coin) {
   switch (coin) {


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


r268768 - [www][analyzer] Update recommended suppression mechanism for localization.

2016-05-06 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Fri May  6 13:13:30 2016
New Revision: 268768

URL: http://llvm.org/viewvc/llvm-project?rev=268768&view=rev
Log:
[www][analyzer] Update recommended suppression mechanism for localization.

Based on feedback from Jordan Rose, make the recommended suppression function 
be 'static
inline'.

Modified:
cfe/trunk/www/analyzer/faq.html

Modified: cfe/trunk/www/analyzer/faq.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/analyzer/faq.html?rev=268768&r1=268767&r2=268768&view=diff
==
--- cfe/trunk/www/analyzer/faq.html (original)
+++ cfe/trunk/www/analyzer/faq.html Fri May  6 13:13:30 2016
@@ -84,10 +84,10 @@ You can add __attribute__((unused))<
 When the analyzer sees that an unlocalized string is passed to a method 
that will present that string to the user, it is going to produce a message 
similar to this one:
 User-facing text should use localized string 
macro
 
-If your project deliberately uses unlocalized user-facing strings (for 
example, in a debugging UI that is never shown to customers), you can suppress 
the analyzer warnings (and document your intent) with a function that just 
returns its input but is annotated to return a localized string:
+If your project deliberately uses unlocalized user-facing strings (for 
example, in a debugging UI that is never shown to users), you can suppress the 
analyzer warnings (and document your intent) with a function that just returns 
its input but is annotated to return a localized string:
 
 __attribute__((annotate("returns_localized_nsstring")))
-NSString *LocalizationNotNeeded(NSString *s) {
+static inline NSString *LocalizationNotNeeded(NSString *s) {
   return s;
 }
 


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


[libclc] r268766 - math: Add erf ported from amd-builtins

2016-05-06 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Fri May  6 13:02:30 2016
New Revision: 268766

URL: http://llvm.org/viewvc/llvm-project?rev=268766&view=rev
Log:
math: Add erf ported from amd-builtins

The scalar float/double function bodies are a direct copy/paste,
aside from the removed (optional) code in float function body that
requires subnormals.

reviewers: jvesely

Patch by: Vedran Miletić 

Added:
libclc/trunk/generic/include/clc/math/erf.h
libclc/trunk/generic/lib/math/erf.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/clc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=268766&r1=268765&r2=268766&view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Fri May  6 13:02:30 2016
@@ -47,6 +47,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Added: libclc/trunk/generic/include/clc/math/erf.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/erf.h?rev=268766&view=auto
==
--- libclc/trunk/generic/include/clc/math/erf.h (added)
+++ libclc/trunk/generic/include/clc/math/erf.h Fri May  6 13:02:30 2016
@@ -0,0 +1,9 @@
+#undef erfc
+
+#define __CLC_BODY 
+#define __CLC_FUNCTION erf
+
+#include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=268766&r1=268765&r2=268766&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Fri May  6 13:02:30 2016
@@ -77,6 +77,7 @@ math/copysign.cl
 math/cos.cl
 math/cospi.cl
 math/ep_log.cl
+math/erf.cl
 math/erfc.cl
 math/exp.cl
 math/exp_helper.cl

Added: libclc/trunk/generic/lib/math/erf.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/erf.cl?rev=268766&view=auto
==
--- libclc/trunk/generic/lib/math/erf.cl (added)
+++ libclc/trunk/generic/lib/math/erf.cl Fri May  6 13:02:30 2016
@@ -0,0 +1,402 @@
+/*
+ * Copyright (c) 2014 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include 
+
+#include "math.h"
+#include "../clcmacro.h"
+
+/*
+ * 
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * 
+*/
+
+#define erx   8.4506291151e-01f/* 0x3f58560b */
+
+// Coefficients for approximation to  erf on [00.84375]
+
+#define efx   1.2837916613e-01f/* 0x3e0375d4 */
+#define efx8  1.0270333290e+00f/* 0x3f8375d4 */
+
+#define pp0   1.2837916613e-01f/* 0x3e0375d4 */
+#define pp1  -3.2504209876e-01f/* 0xbea66beb */
+#define pp2  -2.8481749818e-02f/* 0xbce9528f */
+#define pp3  -5.7702702470e-03f/* 0xbbbd1489 */
+#define pp4  -2.3763017452e-05f/* 0xb7c756b1 */
+#define qq1   3.9791721106e-01f/* 0x3ecbbbce */
+#define qq2   6.5022252500e-02f/* 0x3d852a63 */
+#define qq3   5.0813062117e-03f/* 0x3ba68116 */
+#define qq4   1.3249473704e-04f/* 0x390aee49 */
+#define qq5  -3.9602282413e-06f/* 0xb684e21a */
+
+// Coefficients for approximation to  erf  in [0.843751.25]
+
+#define pa0  -2.3621185683e-03f/* 0xbb1acdc6 */
+#define pa1   4.1485610604e-01f/* 0x3ed46805 */
+#define pa2  -3.7220788002e

Re: [PATCH] D19993: Fixed cppcoreguidelines-pro-type-member-init when checking records with indirect fields

2016-05-06 Thread Michael Miller via cfe-commits
michael_miller updated this revision to Diff 56439.
michael_miller added a comment.

Switched to using getAsCXXRecordDecl.


http://reviews.llvm.org/D19993

Files:
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
  test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -357,3 +357,13 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these bases: NegativeAggregateType
   // CHECK-FIXES: PositiveSelfInitialization() : NegativeAggregateType(), PositiveSelfInitialization() {}
 };
+
+class PositiveIndirectMember {
+  struct {
+int *A;
+// CHECK-FIXES: int *A{};
+  };
+
+  PositiveIndirectMember() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these fields: A
+};
Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
@@ -103,3 +103,14 @@
 
   int X;
 };
+
+class PositiveIndirectMember {
+  struct {
+int *A;
+  };
+
+  PositiveIndirectMember() : A() {}
+  PositiveIndirectMember(int) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these fields: A
+  // CHECK-FIXES: PositiveIndirectMember(int) : A() {}
+};
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -27,16 +27,23 @@
 
 namespace {
 
-void fieldsRequiringInit(const RecordDecl::field_range &Fields,
- ASTContext &Context,
- SmallPtrSetImpl &FieldsToInit) {
+// Iterate over all the fields in a record type, both direct and indirect (e.g.
+// if the record contains an anonmyous struct). If OneFieldPerUnion is true and
+// the record type (or indirect field) is a union, forEachField will stop after
+// the first field.
+template 
+void forEachField(const RecordDecl *Record, const T &Fields,
+  bool OneFieldPerUnion, Func &&Fn) {
   for (const FieldDecl *F : Fields) {
-if (F->hasInClassInitializer())
-  continue;
-QualType Type = F->getType();
-if (!F->hasInClassInitializer() &&
-utils::type_traits::isTriviallyDefaultConstructible(Type, Context))
-  FieldsToInit.insert(F);
+if (F->isAnonymousStructOrUnion()) {
+  if (const CXXRecordDecl *R = F->getType()->getAsCXXRecordDecl())
+forEachField(R, R->fields(), OneFieldPerUnion, Fn);
+} else {
+  Fn(F);
+}
+
+if (OneFieldPerUnion && Record->isUnion())
+  break;
   }
 }
 
@@ -179,8 +186,8 @@
   // Gets either the field or base class being initialized by the provided
   // initializer.
   const auto *InitDecl =
-  Init->isMemberInitializer()
-  ? static_cast(Init->getMember())
+  Init->isAnyMemberInitializer()
+  ? static_cast(Init->getAnyMember())
   : Init->getBaseClass()->getAsCXXRecordDecl();
 
   // Add all fields between current field up until the next intializer.
@@ -216,7 +223,8 @@
   Decls.emplace_back(Decl);
 }
   }
-  Decls.append(ClassDecl->fields().begin(), ClassDecl->fields().end());
+  forEachField(ClassDecl, ClassDecl->fields(), false,
+   [&](const FieldDecl *F) { Decls.push_back(F); });
 }
 
 template 
@@ -238,22 +246,6 @@
   }
 }
 
-template 
-void forEachField(const RecordDecl *Record, const T &Fields,
-  bool OneFieldPerUnion, Func &&Fn) {
-  for (const FieldDecl *F : Fields) {
-if (F->isAnonymousStructOrUnion()) {
-  if (const RecordDecl *R = getCanonicalRecordDecl(F->getType()))
-forEachField(R, R->fields(), OneFieldPerUnion, Fn);
-} else {
-  Fn(F);
-}
-
-if (OneFieldPerUnion && Record->isUnion())
-  break;
-  }
-}
-
 } // anonymous namespace
 
 ProTypeMemberInitCheck::ProTypeMemberInitCheck(StringRef Name,
@@ -314,8 +306,14 @@
   if (IsUnion && ClassDecl->hasInClassInitializer())
 return;
 
+  // Gather all fields (direct and indirect) that need to be initialized.
   SmallPtrSet FieldsToInit;
-  fieldsRequiringInit(ClassDecl->fields(), Context, FieldsToInit);
+  forEachField(ClassDecl, ClassDecl->fields(), false, [&](const FieldDecl *F) {
+if (!F->hasInClassInitializer() &&
+utils::type_traits::isTriviallyDefaultConstructible(F->getType(),
+Context))
+  FieldsToInit.insert(F);
+  });
   if (

r268764 - [www][analyzer] Add FAQ about suppression of missing localization diagnostic.

2016-05-06 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Fri May  6 12:51:34 2016
New Revision: 268764

URL: http://llvm.org/viewvc/llvm-project?rev=268764&view=rev
Log:
[www][analyzer] Add FAQ about suppression of missing localization diagnostic.

Modified:
cfe/trunk/www/analyzer/faq.html

Modified: cfe/trunk/www/analyzer/faq.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/analyzer/faq.html?rev=268764&r1=268763&r2=268764&view=diff
==
--- cfe/trunk/www/analyzer/faq.html (original)
+++ cfe/trunk/www/analyzer/faq.html Fri May  6 12:51:34 2016
@@ -28,6 +28,7 @@ pointer is never null. How can I tell th
 null?
   How do I tell the static analyzer that I don't 
care about a specific dead store?
   How do I tell the static analyzer that I don't 
care about a specific unused instance variable in Objective C?
+  How do I tell the static analyzer that I 
don't care about a specific unlocalized string?
   The analyzer assumes that a loop body is never 
entered.  How can I tell it that the loop body will be entered at least 
once?
   How can I suppress a specific analyzer 
warning?
   How can I selectively exclude code the analyzer 
examines?
@@ -78,6 +79,32 @@ You can use the (void)x; idiom
 Instance variable 'commonName' in class 'HappyBird' 
is never used by the methods in its @implementation
 You can add __attribute__((unused)) to the instance variable 
declaration to suppress the warning.
 
+Q: How do I tell the static analyzer 
that I don't care about a specific unlocalized string?
+
+When the analyzer sees that an unlocalized string is passed to a method 
that will present that string to the user, it is going to produce a message 
similar to this one:
+User-facing text should use localized string 
macro
+
+If your project deliberately uses unlocalized user-facing strings (for 
example, in a debugging UI that is never shown to customers), you can suppress 
the analyzer warnings (and document your intent) with a function that just 
returns its input but is annotated to return a localized string:
+
+__attribute__((annotate("returns_localized_nsstring")))
+NSString *LocalizationNotNeeded(NSString *s) {
+  return s;
+}
+
+
+You can then call this function when creating your debugging UI:
+
+[field setStringValue:LocalizationNotNeeded(@"Debug")];
+
+
+Some projects may also find it useful to use NSLocalizedString but add "DNL" 
or "Do Not Localize" to the string contents as a convention:
+
+UILabel *testLabel = [[UILabel alloc] init];
+NSString *s = NSLocalizedString(@"Hello ", @"For debug 
purposes");
+[testLabel setText:s];
+
+
+
 Q: The analyzer assumes that a loop body is 
never entered.  How can I tell it that the loop body will be entered at least 
once?
 
 


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


Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

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

Get back to this solution.
comments?


http://reviews.llvm.org/D19871



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


Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

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

fix unittests


http://reviews.llvm.org/D19871

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -3475,6 +3475,13 @@
   EXPECT_TRUE(notMatches("int i = 0;", castExpr()));
 }
 
+TEST(CastExpression, HasCastKind) {
+  EXPECT_TRUE(matches("char *p = 0;",
+  castExpr(hasCastKind(CK_NullToPointer;
+  EXPECT_TRUE(notMatches("char *p = 0;",
+  castExpr(hasCastKind(CK_DerivedToBase;
+}
+
 TEST(ReinterpretCast, MatchesSimpleCase) {
   EXPECT_TRUE(matches("char* p = reinterpret_cast(&p);",
   cxxReinterpretCastExpr()));
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -75,6 +75,7 @@
   // TODO: Here is the list of the missing matchers, grouped by reason.
   //
   // Need Variant/Parser fixes:
+  // hasCastKind  
   // ofKind
   //
   // Polymorphic + argument overload:
@@ -210,6 +211,7 @@
   REGISTER_MATCHER(hasBody);
   REGISTER_MATCHER(hasCanonicalType);
   REGISTER_MATCHER(hasCaseConstant);
+  REGISTER_MATCHER(hasCastKind);
   REGISTER_MATCHER(hasCondition);
   REGISTER_MATCHER(hasConditionVariableStatement);
   REGISTER_MATCHER(hasDecayedType);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3548,6 +3548,17 @@
   InnerMatcher.matches(*SubExpression, Finder, Builder));
 }
 
+/// \brief Matches casts that has a given cast kind.
+///
+/// Example: matches the implicit cast around \c 0
+/// (matcher = castExpr(hasCastKind(CK_NullToPointer)))
+/// \code
+///   int *p = 0;
+/// \endcode
+AST_MATCHER_P(CastExpr, hasCastKind, CastKind, Kind) {
+  return Node.getCastKind() == Kind;
+}
+
 /// \brief Matches casts whose destination type matches a given matcher.
 ///
 /// (Note: Clang's AST refers to other conversions as "casts" too, and calls
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2156,6 +2156,15 @@
 
 
 
+MatcherCastExpr>hasCastKindCastKind Kind
+Matches casts that has 
a given cast kind.
+
+Example: matches the implicit cast around 0
+(matcher = castExpr(hasCastKind(CK_NullToPointer)))
+  int *p = 0;
+
+
+
 MatcherCharacterLiteral>equalsValueT  Value
 Matches literals that are 
equal to the given value.
 


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -3475,6 +3475,13 @@
   EXPECT_TRUE(notMatches("int i = 0;", castExpr()));
 }
 
+TEST(CastExpression, HasCastKind) {
+  EXPECT_TRUE(matches("char *p = 0;",
+  castExpr(hasCastKind(CK_NullToPointer;
+  EXPECT_TRUE(notMatches("char *p = 0;",
+  castExpr(hasCastKind(CK_DerivedToBase;
+}
+
 TEST(ReinterpretCast, MatchesSimpleCase) {
   EXPECT_TRUE(matches("char* p = reinterpret_cast(&p);",
   cxxReinterpretCastExpr()));
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -75,6 +75,7 @@
   // TODO: Here is the list of the missing matchers, grouped by reason.
   //
   // Need Variant/Parser fixes:
+  // hasCastKind  
   // ofKind
   //
   // Polymorphic + argument overload:
@@ -210,6 +211,7 @@
   REGISTER_MATCHER(hasBody);
   REGISTER_MATCHER(hasCanonicalType);
   REGISTER_MATCHER(hasCaseConstant);
+  REGISTER_MATCHER(hasCastKind);
   REGISTER_MATCHER(hasCondition);
   REGISTER_MATCHER(hasConditionVariableStatement);
   REGISTER_MATCHER(hasDecayedType);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3548,6 +3548,17 @@
   InnerMatcher.matches(*SubExpression, Finder, Builder));
 }
 
+/// \brief Matches casts that has a given cast kind.
+///
+/// Example: matches the implicit cast around \c 0
+/// (matcher = castExpr(hasCastKind(CK_NullToPointer)))
+/// \code
+///   int *p = 0;
+/// \endcode
+AST_MATCHER_P(CastExpr, hasCastKind, C

Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

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

revert to previous solution


http://reviews.llvm.org/D19871

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -3475,6 +3475,13 @@
   EXPECT_TRUE(notMatches("int i = 0;", castExpr()));
 }
 
+TEST(CastExpression, HasCastKind) {
+  EXPECT_TRUE(matches("char *p = 0;",
+  castExpr(hasCastKind(CK_NullToPointer;
+  EXPECT_TRUE(notMatches("char *p = 0;",
+  castExpr(hasCastKind(CK_DerivedToBase;
+}
+
 TEST(ReinterpretCast, MatchesSimpleCase) {
   EXPECT_TRUE(matches("char* p = reinterpret_cast(&p);",
   cxxReinterpretCastExpr()));
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -75,6 +75,7 @@
   // TODO: Here is the list of the missing matchers, grouped by reason.
   //
   // Need Variant/Parser fixes:
+  // hasCastKind  
   // ofKind
   //
   // Polymorphic + argument overload:
@@ -210,6 +211,7 @@
   REGISTER_MATCHER(hasBody);
   REGISTER_MATCHER(hasCanonicalType);
   REGISTER_MATCHER(hasCaseConstant);
+  REGISTER_MATCHER(hasCastKind);
   REGISTER_MATCHER(hasCondition);
   REGISTER_MATCHER(hasConditionVariableStatement);
   REGISTER_MATCHER(hasDecayedType);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3548,6 +3548,17 @@
   InnerMatcher.matches(*SubExpression, Finder, Builder));
 }
 
+/// \brief Matches casts that has a given cast kind.
+///
+/// Example: matches the implicit cast around \c 0
+/// (matcher = castExpr(hasCastKind(CK_NullToPointer)))
+/// \code
+///   int *p = 0;
+/// \endcode
+AST_MATCHER_P(CastExpr, hasCastKind, CastKind, Kind) {
+  return Node.getCastKind() == Kind;
+}
+
 /// \brief Matches casts whose destination type matches a given matcher.
 ///
 /// (Note: Clang's AST refers to other conversions as "casts" too, and calls


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -3475,6 +3475,13 @@
   EXPECT_TRUE(notMatches("int i = 0;", castExpr()));
 }
 
+TEST(CastExpression, HasCastKind) {
+  EXPECT_TRUE(matches("char *p = 0;",
+  castExpr(hasCastKind(CK_NullToPointer;
+  EXPECT_TRUE(notMatches("char *p = 0;",
+  castExpr(hasCastKind(CK_DerivedToBase;
+}
+
 TEST(ReinterpretCast, MatchesSimpleCase) {
   EXPECT_TRUE(matches("char* p = reinterpret_cast(&p);",
   cxxReinterpretCastExpr()));
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -75,6 +75,7 @@
   // TODO: Here is the list of the missing matchers, grouped by reason.
   //
   // Need Variant/Parser fixes:
+  // hasCastKind  
   // ofKind
   //
   // Polymorphic + argument overload:
@@ -210,6 +211,7 @@
   REGISTER_MATCHER(hasBody);
   REGISTER_MATCHER(hasCanonicalType);
   REGISTER_MATCHER(hasCaseConstant);
+  REGISTER_MATCHER(hasCastKind);
   REGISTER_MATCHER(hasCondition);
   REGISTER_MATCHER(hasConditionVariableStatement);
   REGISTER_MATCHER(hasDecayedType);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3548,6 +3548,17 @@
   InnerMatcher.matches(*SubExpression, Finder, Builder));
 }
 
+/// \brief Matches casts that has a given cast kind.
+///
+/// Example: matches the implicit cast around \c 0
+/// (matcher = castExpr(hasCastKind(CK_NullToPointer)))
+/// \code
+///   int *p = 0;
+/// \endcode
+AST_MATCHER_P(CastExpr, hasCastKind, CastKind, Kind) {
+  return Node.getCastKind() == Kind;
+}
+
 /// \brief Matches casts whose destination type matches a given matcher.
 ///
 /// (Note: Clang's AST refers to other conversions as "casts" too, and calls
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r268749 - More fixes to codeblock formatting in documentation.

2016-05-06 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May  6 11:48:29 2016
New Revision: 268749

URL: http://llvm.org/viewvc/llvm-project?rev=268749&view=rev
Log:
More fixes to codeblock formatting in documentation.

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=268749&r1=268748&r2=268749&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Fri May  6 11:48:29 2016
@@ -129,9 +129,9 @@ Changes to C++1z features since Clang 3.
 
   .. code-block:: c++
 
-  struct A { int n; };
-  struct B : A { int x, y; };
-  B b = { 1, 2, 3 }; // b.n == 1, b.x == 2, b.y == 3
+struct A { int n; };
+struct B : A { int x, y; };
+B b = { 1, 2, 3 }; // b.n == 1, b.x == 2, b.y == 3
 
 - The range in a range-based ``for`` statement can have different types for 
its ``begin``
   and ``end`` iterators. This is permitted as an extension in C++11 onwards.


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


Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-05-06 Thread David Majnemer via cfe-commits
majnemer added a comment.

In http://reviews.llvm.org/D19654#423382, @andreybokhanko wrote:

> David, thank you for the thorough review! -- it definitely made the patch 
> stronger and me even more paranoid than the rest of Intel. :-)


Thanks for implementing this :)

> 

> 

> In http://reviews.llvm.org/D19654#422445, @majnemer wrote:

> 

> > FYI, we will also want to update `getAddrOfCXXCatchHandler` and 
> > `getThrowInfo` to correctly handle `__unaligned`.

> 

> 

> Do you want me to implement this (I have no idea how EH works on Windows, but 
> can try...) or plan to implement yourself?


I have no plans to implement this but I don't think it is very difficult.  The 
way I'd go about this is to see what happens when the following occur:

  throw (int *__unaligned)nullptr;

MSVC should emit a ThrowInfo object, _TI... which points to a 
CatchableTypeArray, _CTA... which will point to two CatchableTypes, _CT...: one 
for pointer-to-void and the other for pointer-to-int.
Both of the CatchableTypes have a bitfield containing qualifiers, among other 
things.  One of these are where __unaligned should go, see `getThrowInfo` for 
more details.

> Yours,

> Andrey



Repository:
  rL LLVM

http://reviews.llvm.org/D19654



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


Re: [PATCH] D19876: Add an AST matcher for string-literal length

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

Aaron? minus re-generation of the doc.
Is that what you want to see?

note: returned types for both getLength are not the same (APInt vs unsigned 
int).
I took the 'hasSize'-Matcher approach to let overloaded operators do the job 
for dispatching types.

note: there is a unittest for top-level node that is no longer valid because 
stringLiteral can be a top-level node now.


http://reviews.llvm.org/D19876



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


Re: [PATCH] D19876: Add an AST matcher for string-literal length

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

fix unittests


http://reviews.llvm.org/D19876

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  include/clang/ASTMatchers/ASTMatchersInternal.h
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -51,7 +51,6 @@
 
   // Do not accept non-toplevel matchers.
   EXPECT_FALSE(Finder.addDynamicMatcher(isArrow(), nullptr));
-  EXPECT_FALSE(Finder.addDynamicMatcher(hasSize(2), nullptr));
   EXPECT_FALSE(Finder.addDynamicMatcher(hasName("x"), nullptr));
 }
 
@@ -2536,6 +2535,17 @@
   EXPECT_TRUE(notMatches("const char s[1] = {'a'};", Literal));
 }
 
+TEST(StringLiteral, HasSize) {
+  StatementMatcher Literal = stringLiteral(hasSize(4));
+  EXPECT_TRUE(matches("const char *s = \"abcd\";", Literal));
+  // wide string
+  EXPECT_TRUE(matches("const wchar_t *s = L\"abcd\";", Literal));
+  // with escaped characters
+  EXPECT_TRUE(matches("const char *s = \"\x05\x06\x07\x08\";", Literal));
+  // no matching, too small
+  EXPECT_TRUE(notMatches("const char *s = \"ab\";", Literal));
+}
+
 TEST(Matcher, CharacterLiterals) {
   StatementMatcher CharLiteral = characterLiteral();
   EXPECT_TRUE(matches("const char c = 'c';", CharLiteral));
Index: include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- include/clang/ASTMatchers/ASTMatchersInternal.h
+++ include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1651,6 +1651,19 @@
 }
 
 template 
+struct HasSizeMatcher {
+  static bool hasSize(const Ty &Node, unsigned int N) {
+return Node.getSize() == N;
+  }
+};
+
+template <>
+inline bool HasSizeMatcher::hasSize(
+const StringLiteral &Node, unsigned int N) {
+  return Node.getLength() == N;
+}
+
+template 
 struct GetSourceExpressionMatcher {
   static const Expr *get(const Ty &Node) {
 return Node.getSubExpr();
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -1560,7 +1560,8 @@
 ///
 /// Example matches "abcd", L"abcd"
 /// \code
-///   char *s = "abcd"; wchar_t *ws = L"abcd"
+///   char *s = "abcd";
+///   wchar_t *ws = L"abcd";
 /// \endcode
 const internal::VariadicDynCastAllOfMatcher<
   Stmt,
@@ -1573,7 +1574,8 @@
 ///
 /// Example matches 'a', L'a'
 /// \code
-///   char ch = 'a'; wchar_t chw = L'a';
+///   char ch = 'a';
+///   wchar_t chw = L'a';
 /// \endcode
 const internal::VariadicDynCastAllOfMatcher<
   Stmt,
@@ -1609,7 +1611,8 @@
 ///
 /// Example match: {1}, (1, 2)
 /// \code
-///   int array[4] = {1}; vector int myvec = (vector int)(1, 2);
+///   int array[4] = {1};
+///   vector int myvec = (vector int)(1, 2);
 /// \endcode
 const internal::VariadicDynCastAllOfMatcher<
   Stmt,
@@ -4228,18 +4231,26 @@
 ///   matches "int a[2]"
 AST_TYPE_MATCHER(ConstantArrayType, constantArrayType);
 
-/// \brief Matches \c ConstantArrayType nodes that have the specified size.
+/// \brief Matches nodes that have the specified size.
 ///
 /// Given
 /// \code
 ///   int a[42];
 ///   int b[2 * 21];
 ///   int c[41], d[43];
+///   char *s = "abcd";
+///   wchar_t *ws = L"abcd";
+///   char *w = "a";
 /// \endcode
 /// constantArrayType(hasSize(42))
 ///   matches "int a[42]" and "int b[2 * 21]"
-AST_MATCHER_P(ConstantArrayType, hasSize, unsigned, N) {
-  return Node.getSize() == N;
+/// stringLiteral(hasSize(4))
+///   matches "abcd", L"abcd"
+AST_POLYMORPHIC_MATCHER_P(hasSize,
+  AST_POLYMORPHIC_SUPPORTED_TYPES(ConstantArrayType,
+  StringLiteral),
+  unsigned, N) {
+  return internal::HasSizeMatcher::hasSize(Node, N);
 }
 
 /// \brief Matches C++ arrays whose size is a value-dependent expression.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19876: Add an AST matcher for string-literal length

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

merging hasSize


http://reviews.llvm.org/D19876

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  include/clang/ASTMatchers/ASTMatchersInternal.h
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -2536,6 +2536,17 @@
   EXPECT_TRUE(notMatches("const char s[1] = {'a'};", Literal));
 }
 
+TEST(StringLiteral, LengthIs) {
+  StatementMatcher Literal = stringLiteral(lengthIs(4));
+  EXPECT_TRUE(matches("const char *s = \"abcd\";", Literal));
+  // wide string
+  EXPECT_TRUE(matches("const wchar_t *s = L\"abcd\";", Literal));
+  // with escaped characters
+  EXPECT_TRUE(matches("const char *s = \"\x05\x06\x07\x08\";", Literal));
+  // no matching, too small
+  EXPECT_TRUE(notMatches("const char *s = \"ab\";", Literal));
+}
+
 TEST(Matcher, CharacterLiterals) {
   StatementMatcher CharLiteral = characterLiteral();
   EXPECT_TRUE(matches("const char c = 'c';", CharLiteral));
Index: include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- include/clang/ASTMatchers/ASTMatchersInternal.h
+++ include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1651,6 +1651,19 @@
 }
 
 template 
+struct HasSizeMatcher {
+  static bool hasSize(const Ty &Node, unsigned int N) {
+return Node.getSize() == N;
+  }
+};
+
+template <>
+inline bool HasSizeMatcher::hasSize(
+const StringLiteral &Node, unsigned int N) {
+  return Node.getLength() == N;
+}
+
+template 
 struct GetSourceExpressionMatcher {
   static const Expr *get(const Ty &Node) {
 return Node.getSubExpr();
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -1560,7 +1560,8 @@
 ///
 /// Example matches "abcd", L"abcd"
 /// \code
-///   char *s = "abcd"; wchar_t *ws = L"abcd"
+///   char *s = "abcd";
+///   wchar_t *ws = L"abcd";
 /// \endcode
 const internal::VariadicDynCastAllOfMatcher<
   Stmt,
@@ -1573,7 +1574,8 @@
 ///
 /// Example matches 'a', L'a'
 /// \code
-///   char ch = 'a'; wchar_t chw = L'a';
+///   char ch = 'a';
+///   wchar_t chw = L'a';
 /// \endcode
 const internal::VariadicDynCastAllOfMatcher<
   Stmt,
@@ -1609,7 +1611,8 @@
 ///
 /// Example match: {1}, (1, 2)
 /// \code
-///   int array[4] = {1}; vector int myvec = (vector int)(1, 2);
+///   int array[4] = {1};
+///   vector int myvec = (vector int)(1, 2);
 /// \endcode
 const internal::VariadicDynCastAllOfMatcher<
   Stmt,
@@ -4228,18 +4231,26 @@
 ///   matches "int a[2]"
 AST_TYPE_MATCHER(ConstantArrayType, constantArrayType);
 
-/// \brief Matches \c ConstantArrayType nodes that have the specified size.
+/// \brief Matches nodes that have the specified size.
 ///
 /// Given
 /// \code
 ///   int a[42];
 ///   int b[2 * 21];
 ///   int c[41], d[43];
+///   char *s = "abcd";
+///   wchar_t *ws = L"abcd";
+///   char *w = "a";
 /// \endcode
 /// constantArrayType(hasSize(42))
 ///   matches "int a[42]" and "int b[2 * 21]"
-AST_MATCHER_P(ConstantArrayType, hasSize, unsigned, N) {
-  return Node.getSize() == N;
+/// stringLiteral(lengthIs(4))
+///   matches "abcd", L"abcd"
+AST_POLYMORPHIC_MATCHER_P(hasSize,
+  AST_POLYMORPHIC_SUPPORTED_TYPES(ConstantArrayType,
+  StringLiteral),
+  unsigned, N) {
+  return internal::HasSizeMatcher::hasSize(Node, N);
 }
 
 /// \brief Matches C++ arrays whose size is a value-dependent expression.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18745: [clang-tidy] Adds modernize-use-bool-literals check.

2016-05-06 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good!


http://reviews.llvm.org/D18745



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


Re: [PATCH] D11781: Refactored pthread usage in libcxx

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

@espositofulvio: Thanks for the patch! :)

Committed as r268734.


Repository:
  rL LLVM

http://reviews.llvm.org/D11781



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


Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

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

@EricWF: Thanks for taking the time to review! :)

Committed as r268734. The bots seem to be happy.


http://reviews.llvm.org/D19412



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


Re: [PATCH] D19876: Add an AST matcher for string-literal length

2016-05-06 Thread Etienne Bergeron via cfe-commits
etienneb added inline comments.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1578
@@ +1577,3 @@
+/// \endcode
+AST_MATCHER_P(StringLiteral, lengthIs, unsigned, N) {
+  return Node.getLength() == N;

etienneb wrote:
> aaron.ballman wrote:
> > etienneb wrote:
> > > etienneb wrote:
> > > > aaron.ballman wrote:
> > > > > Perhaps we can adjust the `hasSize()` matcher instead? It currently 
> > > > > works with ConstantArrayType, but it seems reasonable for it to also 
> > > > > work with StringLiteral.
> > > > I didn't like the term "size" as it typically refer to the size in 
> > > > bytes.
> > > > Which is not the same for a wide-string.
> > > > 
> > > > Now, there is two different convention for naming matchers:
> > > >   hasLength   and  lengthIs  ?
> > > > 
> > > > Any toughs on that?
> > > > 
> > > > 
> > > Here is the matcher for hasSize
> > > ```
> > > AST_MATCHER_P(ConstantArrayType, hasSize, unsigned, N) {
> > >   return Node.getSize() == N;
> > > }
> > > ```
> > > 
> > > It's getting the getSize attribute. I believe we should stick with the 
> > > name of the attribute.
> > > But, I'm not sure if we should use hasLength, or lengthIs.
> > I'm not too worried about size vs length (for instance, std::string has 
> > both). I would imagine this being implemented the same way we do other 
> > things with variance in API but not concept. See GetBodyMatcher in 
> > ASTMatchersInternal.h (and others near there) as an example.
> > 
> > I prefer hasSize because the two concepts are quite similar. For instance, 
> > a string literal's type is of a constant array type already.
> I do not have strong opinion too on the naming. I'm curious if others also 
> has opinion on it?
> Then, I'll proceed.
>  For instance, a string literal's type

stringLiteral is matching an expression and not a type.
And, hasSize is currently applied on types.
Do we want this?


http://reviews.llvm.org/D19876



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


Re: [PATCH] D19780: Output OpenCL version in Clang diagnostics

2016-05-06 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: lib/Parse/ParseDecl.cpp:3519
@@ +3518,3 @@
+   / 100);
+const char *VerSpec = (VerMajor + std::string (".") + 
VerMinor).c_str();
+Diag(Tok, DiagID) << VerSpec << PrevSpec << isStorageClass;

I think it will be nicer to use string (not char*) here too.


http://reviews.llvm.org/D19780



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


Re: r268727 - [MSVC] Implementation of __unaligned as a proper type qualifier

2016-05-06 Thread Andrey Bokhanko via cfe-commits
Thanks for reverting (I started it, but your fingers are faster than
mine...)

I will look at the reproducer.

Yours,
Andrey


On Fri, May 6, 2016 at 5:41 PM, Nico Weber  wrote:

> I verified that this is due to this change. I filed
> https://llvm.org/bugs/show_bug.cgi?id=27666 with a reduced repro and
> reverted this change in r268736.
>
> On Fri, May 6, 2016 at 9:52 AM, Nico Weber  wrote:
>
>> We're getting this crash now with a regression range of 268724:268729 --
>> i.e. almost certainly this change:
>>
>> FAILED: obj/net/dns/net.mdns_client.obj
>> ninja -t msvc -e environment.x64 --
>> "..\..\third_party/llvm-build/Release+Asserts/bin/clang-cl" -m64 /nologo
>> /showIncludes /FC @obj\net\dns\net.mdns_client.obj.rsp /c
>> ..\..\net\dns\mdns_client.cc /Foobj\net\dns\net.mdns_client.obj
>> /Fdobj\net\net.cc.pdb
>> In file included from ..\..\net\dns\mdns_client.cc:11:
>> In file included from ..\..\net/dns/mdns_client_impl.h:26:
>> In file included from ..\..\net/udp/udp_server_socket.h:13:
>> In file included from ..\..\net/udp/udp_socket.h:11:
>> In file included from ..\..\net/udp/udp_socket_win.h:8:
>> In file included from
>> C:\b\depot_tools\win_toolchain\vs_files\95ddda401ec5678f15eeed01d2bee08fcbc5ee97\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\um\qos2.h:23:
>> C:\b\depot_tools\win_toolchain\vs_files\95ddda401ec5678f15eeed01d2bee08fcbc5ee97\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\shared\mstcpip.h(588,13):
>>  error: no matching constructor for initialization of 'IN_ADDR' (aka
>> 'in_addr')
>> IN_ADDR Ipv4Address = *a;
>> ^ ~~
>> Assertion failed: CVR && "unexpected qualifiers mismatch", file
>> C:\b\build\slave\ClangToTWin64\build\src\third_party\llvm\tools\clang\lib\Sema\SemaOverload.cpp,
>> line 9118
>>
>> Can you revert again? Should be easy to repro, just include  in a
>> cc file and compile that. Let me know if you need help reproducing.
>>
>> On Fri, May 6, 2016 at 7:47 AM, Andrey Bokhanko via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: asbokhan
>>> Date: Fri May  6 06:47:55 2016
>>> New Revision: 268727
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=268727&view=rev
>>> Log:
>>> [MSVC] Implementation of __unaligned as a proper type qualifier
>>>
>>> This patch implements __unaligned (MS extension) as a proper type
>>> qualifier
>>> (before that, it was implemented as an ignored attribute).
>>>
>>> It also fixes PR27367.
>>>
>>> Differential Revision: http://reviews.llvm.org/D19654
>>>
>>> Modified:
>>> cfe/trunk/include/clang/AST/Type.h
>>> cfe/trunk/include/clang/Basic/AddressSpaces.h
>>> cfe/trunk/include/clang/Basic/Attr.td
>>> cfe/trunk/include/clang/Sema/DeclSpec.h
>>> cfe/trunk/include/clang/Sema/Sema.h
>>> cfe/trunk/lib/AST/MicrosoftMangle.cpp
>>> cfe/trunk/lib/AST/TypePrinter.cpp
>>> cfe/trunk/lib/Parse/ParseDecl.cpp
>>> cfe/trunk/lib/Parse/ParseTentative.cpp
>>> cfe/trunk/lib/Sema/DeclSpec.cpp
>>> cfe/trunk/lib/Sema/SemaCodeComplete.cpp
>>> cfe/trunk/lib/Sema/SemaDecl.cpp
>>> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>>> cfe/trunk/lib/Sema/SemaExpr.cpp
>>> cfe/trunk/lib/Sema/SemaOverload.cpp
>>> cfe/trunk/lib/Sema/SemaType.cpp
>>> cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
>>> cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp
>>> cfe/trunk/test/Sema/MicrosoftExtensions.c
>>> cfe/trunk/test/Sema/address_spaces.c
>>> cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c
>>> cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
>>>
>>> Modified: cfe/trunk/include/clang/AST/Type.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=268727&r1=268726&r2=268727&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/AST/Type.h (original)
>>> +++ cfe/trunk/include/clang/AST/Type.h Fri May  6 06:47:55 2016
>>> @@ -152,8 +152,8 @@ public:
>>>
>>>enum {
>>>  /// The maximum supported address space number.
>>> -/// 24 bits should be enough for anyone.
>>> -MaxAddressSpace = 0xffu,
>>> +/// 23 bits should be enough for anyone.
>>> +MaxAddressSpace = 0x7fu,
>>>
>>>  /// The width of the "fast" qualifier mask.
>>>  FastWidth = 3,
>>> @@ -265,6 +265,13 @@ public:
>>>  Mask |= mask;
>>>}
>>>
>>> +  bool hasUnaligned() const { return Mask & UMask; }
>>> +  void setUnaligned(bool flag) {
>>> +Mask = (Mask & ~UMask) | (flag ? UMask : 0);
>>> +  }
>>> +  void removeUnaligned() { Mask &= ~UMask; }
>>> +  void addUnaligned() { Mask |= UMask; }
>>> +
>>>bool hasObjCGCAttr() const { return Mask & GCAttrMask; }
>>>GC getObjCGCAttr() const { return GC((Mask & GCAttrMask) >>
>>> GCAttrShift); }
>>>void setObjCGCAttr(GC type) {
>>> @@ -433,7 +440,9 @@ public:
>>> // ObjC lifetime qualifiers must match exactly.
>>> getObjCLifetime() == other.getObjCLifetime() &&
>>>

Re: r268727 - [MSVC] Implementation of __unaligned as a proper type qualifier

2016-05-06 Thread Nico Weber via cfe-commits
I verified that this is due to this change. I filed
https://llvm.org/bugs/show_bug.cgi?id=27666 with a reduced repro and
reverted this change in r268736.

On Fri, May 6, 2016 at 9:52 AM, Nico Weber  wrote:

> We're getting this crash now with a regression range of 268724:268729 --
> i.e. almost certainly this change:
>
> FAILED: obj/net/dns/net.mdns_client.obj
> ninja -t msvc -e environment.x64 --
> "..\..\third_party/llvm-build/Release+Asserts/bin/clang-cl" -m64 /nologo
> /showIncludes /FC @obj\net\dns\net.mdns_client.obj.rsp /c
> ..\..\net\dns\mdns_client.cc /Foobj\net\dns\net.mdns_client.obj
> /Fdobj\net\net.cc.pdb
> In file included from ..\..\net\dns\mdns_client.cc:11:
> In file included from ..\..\net/dns/mdns_client_impl.h:26:
> In file included from ..\..\net/udp/udp_server_socket.h:13:
> In file included from ..\..\net/udp/udp_socket.h:11:
> In file included from ..\..\net/udp/udp_socket_win.h:8:
> In file included from
> C:\b\depot_tools\win_toolchain\vs_files\95ddda401ec5678f15eeed01d2bee08fcbc5ee97\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\um\qos2.h:23:
> C:\b\depot_tools\win_toolchain\vs_files\95ddda401ec5678f15eeed01d2bee08fcbc5ee97\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\shared\mstcpip.h(588,13):
>  error: no matching constructor for initialization of 'IN_ADDR' (aka
> 'in_addr')
> IN_ADDR Ipv4Address = *a;
> ^ ~~
> Assertion failed: CVR && "unexpected qualifiers mismatch", file
> C:\b\build\slave\ClangToTWin64\build\src\third_party\llvm\tools\clang\lib\Sema\SemaOverload.cpp,
> line 9118
>
> Can you revert again? Should be easy to repro, just include  in a
> cc file and compile that. Let me know if you need help reproducing.
>
> On Fri, May 6, 2016 at 7:47 AM, Andrey Bokhanko via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: asbokhan
>> Date: Fri May  6 06:47:55 2016
>> New Revision: 268727
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=268727&view=rev
>> Log:
>> [MSVC] Implementation of __unaligned as a proper type qualifier
>>
>> This patch implements __unaligned (MS extension) as a proper type
>> qualifier
>> (before that, it was implemented as an ignored attribute).
>>
>> It also fixes PR27367.
>>
>> Differential Revision: http://reviews.llvm.org/D19654
>>
>> Modified:
>> cfe/trunk/include/clang/AST/Type.h
>> cfe/trunk/include/clang/Basic/AddressSpaces.h
>> cfe/trunk/include/clang/Basic/Attr.td
>> cfe/trunk/include/clang/Sema/DeclSpec.h
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/lib/AST/MicrosoftMangle.cpp
>> cfe/trunk/lib/AST/TypePrinter.cpp
>> cfe/trunk/lib/Parse/ParseDecl.cpp
>> cfe/trunk/lib/Parse/ParseTentative.cpp
>> cfe/trunk/lib/Sema/DeclSpec.cpp
>> cfe/trunk/lib/Sema/SemaCodeComplete.cpp
>> cfe/trunk/lib/Sema/SemaDecl.cpp
>> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>> cfe/trunk/lib/Sema/SemaExpr.cpp
>> cfe/trunk/lib/Sema/SemaOverload.cpp
>> cfe/trunk/lib/Sema/SemaType.cpp
>> cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
>> cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp
>> cfe/trunk/test/Sema/MicrosoftExtensions.c
>> cfe/trunk/test/Sema/address_spaces.c
>> cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c
>> cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/Type.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=268727&r1=268726&r2=268727&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/Type.h (original)
>> +++ cfe/trunk/include/clang/AST/Type.h Fri May  6 06:47:55 2016
>> @@ -152,8 +152,8 @@ public:
>>
>>enum {
>>  /// The maximum supported address space number.
>> -/// 24 bits should be enough for anyone.
>> -MaxAddressSpace = 0xffu,
>> +/// 23 bits should be enough for anyone.
>> +MaxAddressSpace = 0x7fu,
>>
>>  /// The width of the "fast" qualifier mask.
>>  FastWidth = 3,
>> @@ -265,6 +265,13 @@ public:
>>  Mask |= mask;
>>}
>>
>> +  bool hasUnaligned() const { return Mask & UMask; }
>> +  void setUnaligned(bool flag) {
>> +Mask = (Mask & ~UMask) | (flag ? UMask : 0);
>> +  }
>> +  void removeUnaligned() { Mask &= ~UMask; }
>> +  void addUnaligned() { Mask |= UMask; }
>> +
>>bool hasObjCGCAttr() const { return Mask & GCAttrMask; }
>>GC getObjCGCAttr() const { return GC((Mask & GCAttrMask) >>
>> GCAttrShift); }
>>void setObjCGCAttr(GC type) {
>> @@ -433,7 +440,9 @@ public:
>> // ObjC lifetime qualifiers must match exactly.
>> getObjCLifetime() == other.getObjCLifetime() &&
>> // CVR qualifiers may subset.
>> -   (((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask &
>> CVRMask));
>> +   (((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask &
>> CVRMask)) &&
>> +   // U qualifier may superset.
>> +   (!(other.Mask & UMask) || (

r268736 - Revert r268727, it caused PR27666.

2016-05-06 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri May  6 09:34:29 2016
New Revision: 268736

URL: http://llvm.org/viewvc/llvm-project?rev=268736&view=rev
Log:
Revert r268727, it caused PR27666.

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/AddressSpaces.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseTentative.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp
cfe/trunk/test/Sema/MicrosoftExtensions.c
cfe/trunk/test/Sema/address_spaces.c
cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=268736&r1=268735&r2=268736&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Fri May  6 09:34:29 2016
@@ -152,8 +152,8 @@ public:
 
   enum {
 /// The maximum supported address space number.
-/// 23 bits should be enough for anyone.
-MaxAddressSpace = 0x7fu,
+/// 24 bits should be enough for anyone.
+MaxAddressSpace = 0xffu,
 
 /// The width of the "fast" qualifier mask.
 FastWidth = 3,
@@ -265,13 +265,6 @@ public:
 Mask |= mask;
   }
 
-  bool hasUnaligned() const { return Mask & UMask; }
-  void setUnaligned(bool flag) {
-Mask = (Mask & ~UMask) | (flag ? UMask : 0);
-  }
-  void removeUnaligned() { Mask &= ~UMask; }
-  void addUnaligned() { Mask |= UMask; }
-
   bool hasObjCGCAttr() const { return Mask & GCAttrMask; }
   GC getObjCGCAttr() const { return GC((Mask & GCAttrMask) >> GCAttrShift); }
   void setObjCGCAttr(GC type) {
@@ -440,9 +433,7 @@ public:
// ObjC lifetime qualifiers must match exactly.
getObjCLifetime() == other.getObjCLifetime() &&
// CVR qualifiers may subset.
-   (((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask & CVRMask)) &&
-   // U qualifier may superset.
-   (!(other.Mask & UMask) || (Mask & UMask));
+   (((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask & CVRMask));
   }
 
   /// \brief Determines if these qualifiers compatibly include another set of
@@ -510,19 +501,16 @@ public:
 
 private:
 
-  // bits: |0 1 2|3|4 .. 5|6  ..  8|9   ...   31|
-  //   |C R V|U|GCAttr|Lifetime|AddressSpace|
+  // bits: |0 1 2|3 .. 4|5  ..  7|8   ...   31|
+  //   |C R V|GCAttr|Lifetime|AddressSpace|
   uint32_t Mask;
 
-  static const uint32_t UMask = 0x8;
-  static const uint32_t UShift = 3;
-  static const uint32_t GCAttrMask = 0x30;
-  static const uint32_t GCAttrShift = 4;
-  static const uint32_t LifetimeMask = 0x1C0;
-  static const uint32_t LifetimeShift = 6;
-  static const uint32_t AddressSpaceMask =
-  ~(CVRMask | UMask | GCAttrMask | LifetimeMask);
-  static const uint32_t AddressSpaceShift = 9;
+  static const uint32_t GCAttrMask = 0x18;
+  static const uint32_t GCAttrShift = 3;
+  static const uint32_t LifetimeMask = 0xE0;
+  static const uint32_t LifetimeShift = 5;
+  static const uint32_t AddressSpaceMask = ~(CVRMask|GCAttrMask|LifetimeMask);
+  static const uint32_t AddressSpaceShift = 8;
 };
 
 /// A std::pair-like structure for storing a qualified type split
@@ -5389,13 +5377,7 @@ inline bool QualType::isMoreQualifiedTha
 /// int" is at least as qualified as "const int", "volatile int",
 /// "int", and "const volatile int".
 inline bool QualType::isAtLeastAsQualifiedAs(QualType other) const {
-  Qualifiers otherQuals = other.getQualifiers();
-
-  // Ignore __unaligned qualifier if this type is a void.
-  if (getUnqualifiedType()->isVoidType())
-otherQuals.removeUnaligned();
-
-  return getQualifiers().compatiblyIncludes(otherQuals);
+  return getQualifiers().compatiblyIncludes(other.getQualifiers());
 }
 
 /// If Type is a reference type (e.g., const

Modified: cfe/trunk/include/clang/Basic/AddressSpaces.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AddressSpaces.h?rev=268736&r1=268735&r2=268736&view=diff
==
--- cfe/trunk/include/clang/Basic/AddressSpaces.h (original)
+++ cfe/trunk/include/clang/Basic/AddressSpaces.h Fri May  6 09:34:29 2016
@@ -25,7 +25,7 @@ namespace LangAS {
 /// This uses a high starting offset so as not to conflict with any address
 /// space used by 

[libcxx] r268734 - Refactor pthread usage of libcxx.

2016-05-06 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Fri May  6 09:06:29 2016
New Revision: 268734

URL: http://llvm.org/viewvc/llvm-project?rev=268734&view=rev
Log:
Refactor pthread usage of libcxx.

This patch extracts out all the pthread dependencies of libcxx into the
new header __threading_support. The motivation is to make it easy to
re-target libcxx into platforms that do not support pthread.

Original patch from Fulvio Esposito (fulvio.espos...@outlook.com) - D11781

Applied with tweaks - D19412

Change-Id: I30f0075de93dd8129416e06babc195aa936b

Added:
libcxx/trunk/include/__threading_support
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/__mutex_base
libcxx/trunk/include/mutex
libcxx/trunk/include/thread
libcxx/trunk/src/algorithm.cpp
libcxx/trunk/src/condition_variable.cpp
libcxx/trunk/src/memory.cpp
libcxx/trunk/src/mutex.cpp
libcxx/trunk/src/thread.cpp

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=268734&r1=268733&r2=268734&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri May  6 09:06:29 2016
@@ -812,6 +812,20 @@ extern "C" void __sanitizer_annotate_con
 #  define _LIBCPP_WEAK __attribute__((__weak__))
 #endif
 
+// Thread API
+#ifndef _LIBCPP_HAS_NO_THREADS
+# if defined(__FreeBSD__) || \
+defined(__NetBSD__) || \
+defined(__linux__) || \
+defined(__APPLE__) || \
+defined(__CloudABI__)
+#  define _LIBCPP_THREAD_API_PTHREAD
+# else
+#  error "No thread API"
+# endif // _LIBCPP_THREAD_API
+#endif // _LIBCPP_HAS_NO_THREADS
+
+
 #if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
 #  error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
  _LIBCPP_HAS_NO_THREADS is defined.

Modified: libcxx/trunk/include/__mutex_base
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__mutex_base?rev=268734&r1=268733&r2=268734&view=diff
==
--- libcxx/trunk/include/__mutex_base (original)
+++ libcxx/trunk/include/__mutex_base Fri May  6 09:06:29 2016
@@ -14,9 +14,7 @@
 #include <__config>
 #include 
 #include 
-#ifndef _LIBCPP_HAS_NO_THREADS
-#include 
-#endif
+#include <__threading_support>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -36,14 +34,14 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) 
mutex
 {
-pthread_mutex_t __m_;
+__libcpp_mutex_t __m_;
 
 public:
 _LIBCPP_INLINE_VISIBILITY
 #ifndef _LIBCPP_HAS_NO_CONSTEXPR
- constexpr mutex() _NOEXCEPT : __m_(PTHREAD_MUTEX_INITIALIZER) {}
+constexpr mutex() _NOEXCEPT : __m_(_LIBCPP_MUTEX_INITIALIZER) {}
 #else
- mutex() _NOEXCEPT {__m_ = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;}
+mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;}
 #endif
  ~mutex();
 
@@ -56,7 +54,7 @@ public:
 bool try_lock() _NOEXCEPT 
_LIBCPP_THREAD_SAFETY_ANNOTATION(try_acquire_capability(true));
 void unlock() _NOEXCEPT 
_LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability());
 
-typedef pthread_mutex_t* native_handle_type;
+typedef __libcpp_mutex_t* native_handle_type;
 _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return 
&__m_;}
 };
 
@@ -276,13 +274,13 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_st
 
 class _LIBCPP_TYPE_VIS condition_variable
 {
-pthread_cond_t __cv_;
+__libcpp_condvar_t  __cv_;
 public:
 _LIBCPP_INLINE_VISIBILITY
 #ifndef _LIBCPP_HAS_NO_CONSTEXPR
-constexpr condition_variable() : __cv_(PTHREAD_COND_INITIALIZER) {}
+constexpr condition_variable() : __cv_(_LIBCPP_CONDVAR_INITIALIZER) {}
 #else
-condition_variable() {__cv_ = (pthread_cond_t)PTHREAD_COND_INITIALIZER;}
+condition_variable() {__cv_ = 
(__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;}
 #endif
 ~condition_variable();
 
@@ -321,7 +319,7 @@ public:
  const chrono::duration<_Rep, _Period>& __d,
  _Predicate __pred);
 
-typedef pthread_cond_t* native_handle_type;
+typedef __libcpp_condvar_t* native_handle_type;
 _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return 
&__cv_;}
 
 private:

Added: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=268734&view=auto
==
--- libcxx/trunk/include/__threading_support (added)
+++ libcxx/trunk/include/__threading_support Fri May  6 09:06:29 2016
@@ -0,0 +1,205 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Il

Re: r268727 - [MSVC] Implementation of __unaligned as a proper type qualifier

2016-05-06 Thread Nico Weber via cfe-commits
We're getting this crash now with a regression range of 268724:268729 --
i.e. almost certainly this change:

FAILED: obj/net/dns/net.mdns_client.obj
ninja -t msvc -e environment.x64 --
"..\..\third_party/llvm-build/Release+Asserts/bin/clang-cl" -m64 /nologo
/showIncludes /FC @obj\net\dns\net.mdns_client.obj.rsp /c
..\..\net\dns\mdns_client.cc /Foobj\net\dns\net.mdns_client.obj
/Fdobj\net\net.cc.pdb
In file included from ..\..\net\dns\mdns_client.cc:11:
In file included from ..\..\net/dns/mdns_client_impl.h:26:
In file included from ..\..\net/udp/udp_server_socket.h:13:
In file included from ..\..\net/udp/udp_socket.h:11:
In file included from ..\..\net/udp/udp_socket_win.h:8:
In file included from
C:\b\depot_tools\win_toolchain\vs_files\95ddda401ec5678f15eeed01d2bee08fcbc5ee97\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\um\qos2.h:23:
C:\b\depot_tools\win_toolchain\vs_files\95ddda401ec5678f15eeed01d2bee08fcbc5ee97\win_sdk\bin\..\..\win_sdk\Include\10.0.10586.0\shared\mstcpip.h(588,13):
 error: no matching constructor for initialization of 'IN_ADDR' (aka
'in_addr')
IN_ADDR Ipv4Address = *a;
^ ~~
Assertion failed: CVR && "unexpected qualifiers mismatch", file
C:\b\build\slave\ClangToTWin64\build\src\third_party\llvm\tools\clang\lib\Sema\SemaOverload.cpp,
line 9118

Can you revert again? Should be easy to repro, just include  in a
cc file and compile that. Let me know if you need help reproducing.

On Fri, May 6, 2016 at 7:47 AM, Andrey Bokhanko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: asbokhan
> Date: Fri May  6 06:47:55 2016
> New Revision: 268727
>
> URL: http://llvm.org/viewvc/llvm-project?rev=268727&view=rev
> Log:
> [MSVC] Implementation of __unaligned as a proper type qualifier
>
> This patch implements __unaligned (MS extension) as a proper type qualifier
> (before that, it was implemented as an ignored attribute).
>
> It also fixes PR27367.
>
> Differential Revision: http://reviews.llvm.org/D19654
>
> Modified:
> cfe/trunk/include/clang/AST/Type.h
> cfe/trunk/include/clang/Basic/AddressSpaces.h
> cfe/trunk/include/clang/Basic/Attr.td
> cfe/trunk/include/clang/Sema/DeclSpec.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/AST/MicrosoftMangle.cpp
> cfe/trunk/lib/AST/TypePrinter.cpp
> cfe/trunk/lib/Parse/ParseDecl.cpp
> cfe/trunk/lib/Parse/ParseTentative.cpp
> cfe/trunk/lib/Sema/DeclSpec.cpp
> cfe/trunk/lib/Sema/SemaCodeComplete.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaOverload.cpp
> cfe/trunk/lib/Sema/SemaType.cpp
> cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
> cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp
> cfe/trunk/test/Sema/MicrosoftExtensions.c
> cfe/trunk/test/Sema/address_spaces.c
> cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c
> cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
>
> Modified: cfe/trunk/include/clang/AST/Type.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=268727&r1=268726&r2=268727&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/Type.h (original)
> +++ cfe/trunk/include/clang/AST/Type.h Fri May  6 06:47:55 2016
> @@ -152,8 +152,8 @@ public:
>
>enum {
>  /// The maximum supported address space number.
> -/// 24 bits should be enough for anyone.
> -MaxAddressSpace = 0xffu,
> +/// 23 bits should be enough for anyone.
> +MaxAddressSpace = 0x7fu,
>
>  /// The width of the "fast" qualifier mask.
>  FastWidth = 3,
> @@ -265,6 +265,13 @@ public:
>  Mask |= mask;
>}
>
> +  bool hasUnaligned() const { return Mask & UMask; }
> +  void setUnaligned(bool flag) {
> +Mask = (Mask & ~UMask) | (flag ? UMask : 0);
> +  }
> +  void removeUnaligned() { Mask &= ~UMask; }
> +  void addUnaligned() { Mask |= UMask; }
> +
>bool hasObjCGCAttr() const { return Mask & GCAttrMask; }
>GC getObjCGCAttr() const { return GC((Mask & GCAttrMask) >>
> GCAttrShift); }
>void setObjCGCAttr(GC type) {
> @@ -433,7 +440,9 @@ public:
> // ObjC lifetime qualifiers must match exactly.
> getObjCLifetime() == other.getObjCLifetime() &&
> // CVR qualifiers may subset.
> -   (((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask &
> CVRMask));
> +   (((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask &
> CVRMask)) &&
> +   // U qualifier may superset.
> +   (!(other.Mask & UMask) || (Mask & UMask));
>}
>
>/// \brief Determines if these qualifiers compatibly include another
> set of
> @@ -501,16 +510,19 @@ public:
>
>  private:
>
> -  // bits: |0 1 2|3 .. 4|5  ..  7|8   ...   31|
> -  //   |C R V|GCAttr|Lifetime|AddressSpace|
> +  // bits: |0 1 2|3|4 .. 5|6  ..  8|9   ...   31|
> +  //   |C R V|U|

Re: [PATCH] D19105: Changes in clang after running http://reviews.llvm.org/D18821

2016-05-06 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

In http://reviews.llvm.org/D19105#422702, @Quuxplusone wrote:

> It seems like this proposed diagnostic and fixit, statistically speaking, is 
> *never* correct.
>  In the cases where there is a code issue to be corrected, the diagnosable 
> issue really seems to involve dataflow analysis:
>
> "Here is a variable of integral type (not bool), which over its lifetime 
> assumes only the values `0` and `1`. This variable should be declared as type 
> `bool`."
>  "Here is a function returning integral type (not bool), which returns only 
> the values `0` and `1`. This function should be declared as returning type 
> `bool`."
>  "Here is a parameter of integral type (not bool), which (via whole-program 
> analysis) assumes only the values `0` and `1`. This parameter should be 
> declared as type `bool`."


You are right, if someone is using true/false, then he probably mean it, and he 
is just assigning it to wrong type. But I don't see a point spending too much 
time to write something that would be smart enough to fix most of the issues as 
we would like. I think having this fixit is good for now and I would leave it 
like this. 
From my usage, I like when clang-tidy touch some files and changes it somewhow, 
so it is much simpler to check it in git than to look at the warnings.



Comment at: lib/Driver/Tools.cpp:2022
@@ -2021,3 +2021,3 @@
 
-if (OptionIter->second == true) {
+if (OptionIter->second == 1) {
   // Duplicate option specified.

Quuxplusone wrote:
> Shouldn't the original code already have triggered some warning about 
> explicit comparison with a boolean value?
> 
> if (OptionIter->second) {
> 
> doesn't have literally the same semantics, but it's clearly IMHO what was 
> intended.
> Also, if `decltype(llvm::StringMap::iterator{}->second)` is not `bool`, 
> something weird is going on.
te misc-simplify-boolean-expression is to solve this problem. I will check if 
this code make sense.


http://reviews.llvm.org/D19105



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


Re: [PATCH] D19936: Adding omitted column to invalid loc diagnostic.

2016-05-06 Thread Ben Craig via cfe-commits
bcraig added a comment.

r268732


http://reviews.llvm.org/D19936



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


r268732 - Adding omitted column to invalid loc diagnostic.

2016-05-06 Thread Ben Craig via cfe-commits
Author: bcraig
Date: Fri May  6 08:29:46 2016
New Revision: 268732

URL: http://llvm.org/viewvc/llvm-project?rev=268732&view=rev
Log:
Adding omitted column to invalid loc diagnostic.

note_fe_backend_invalid_loc expects three arguments (file, line, column), 
and will assert when only given two. The other two places in this file that
use note_fe_backend_invalid_loc already supply the Column for the third
parameter.

http://reviews.llvm.org/D19936

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

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=268732&r1=268731&r2=268732&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Fri May  6 08:29:46 2016
@@ -454,7 +454,7 @@ const FullSourceLoc BackendConsumer::get
 // we could not translate this location. This can happen in the
 // case of #line directives.
 Diags.Report(Loc, diag::note_fe_backend_invalid_loc)
-<< Filename << Line;
+<< Filename << Line << Column;
 
   return Loc;
 }


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


Re: [PATCH] D18745: [clang-tidy] Adds modernize-use-bool-literals check.

2016-05-06 Thread Jakub Staroń via cfe-commits
staronj added inline comments.


Comment at: clang-tidy/modernize/UseBoolLiteralsCheck.cpp:56
@@ +55,3 @@
+   "converting integer literal to "
+   "bool%select{| inside a macro}0, use bool literal instead");
+

alexfh wrote:
> Can you explain, why is it important to note that this happens "inside a 
> macro"?
"Inside a macro" removed.


http://reviews.llvm.org/D18745



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


Re: [PATCH] D20014: [libc++] Explicit return in non-void function

2016-05-06 Thread Bernard Ogden via cfe-commits
bogden added a comment.

I think this fix is OK, but I'm not clear on why we need both C and D, so 
perhaps it is important that the function does not have a return statement.


http://reviews.llvm.org/D20014



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


Re: [PATCH] D18745: [clang-tidy] Adds modernize-use-bool-literals check.

2016-05-06 Thread Jakub Staroń via cfe-commits
staronj updated this revision to Diff 56395.
staronj marked 3 inline comments as done.

http://reviews.llvm.org/D18745

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseBoolLiteralsCheck.cpp
  clang-tidy/modernize/UseBoolLiteralsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-bool-literals.rst
  test/clang-tidy/modernize-use-bool-literals.cpp

Index: test/clang-tidy/modernize-use-bool-literals.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-bool-literals.cpp
@@ -0,0 +1,122 @@
+// RUN: %check_clang_tidy %s modernize-use-bool-literals %t
+
+bool IntToTrue = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: converting integer literal to bool, use bool literal instead [modernize-use-bool-literals]
+// CHECK-FIXES: {{^}}bool IntToTrue = true;{{$}}
+
+bool IntToFalse(0);
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: {{.*}}
+// CHECK-FIXES: {{^}}bool IntToFalse(false);{{$}}
+
+bool LongLongToTrue{0x1LL};
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}}
+// CHECK-FIXES: {{^}}bool LongLongToTrue{true};{{$}}
+
+bool ExplicitCStyleIntToFalse = (bool)0;
+// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: {{.*}}
+// CHECK-FIXES: {{^}}bool ExplicitCStyleIntToFalse = false;{{$}}
+
+bool ExplicitFunctionalIntToFalse = bool(0);
+// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: {{.*}}
+// CHECK-FIXES: {{^}}bool ExplicitFunctionalIntToFalse = false;{{$}}
+
+bool ExplicitStaticIntToFalse = static_cast(0);
+// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: {{.*}}
+// CHECK-FIXES: {{^}}bool ExplicitStaticIntToFalse = false;{{$}}
+
+#define TRUE_MACRO 1
+// CHECK-FIXES: {{^}}#define TRUE_MACRO 1{{$}}
+
+bool MacroIntToTrue = TRUE_MACRO;
+// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: converting integer literal to bool, use bool literal instead [modernize-use-bool-literals]
+// CHECK-FIXES: {{^}}bool MacroIntToTrue = TRUE_MACRO;{{$}}
+
+#define FALSE_MACRO bool(0)
+// CHECK-FIXES: {{^}}#define FALSE_MACRO bool(0){{$}}
+
+
+bool TrueBool = true; // OK
+
+bool FalseBool = bool(FALSE_MACRO);
+// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: {{.*}}
+// CHECK-FIXES: {{^}}bool FalseBool = bool(FALSE_MACRO);{{$}}
+
+void boolFunction(bool bar) {
+
+}
+
+char Character = 0; // OK
+
+unsigned long long LongInteger = 1; // OK
+
+#define MACRO_DEPENDENT_CAST(x) static_cast(x)
+// CHECK-FIXES: {{^}}#define MACRO_DEPENDENT_CAST(x) static_cast(x){{$}}
+
+bool MacroDependentBool = MACRO_DEPENDENT_CAST(0);
+// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: {{.*}}
+// CHECK-FIXES: {{^}}bool MacroDependentBool = MACRO_DEPENDENT_CAST(0);{{$}}
+
+bool ManyMacrosDependent = MACRO_DEPENDENT_CAST(FALSE_MACRO);
+// CHECK-MESSAGES: :[[@LINE-1]]:49: warning: {{.*}}
+// CHECK-FIXES: {{^}}bool ManyMacrosDependent = MACRO_DEPENDENT_CAST(FALSE_MACRO);{{$}}
+
+class FooClass {
+  public:
+  FooClass() : JustBool(0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: {{.*}}
+  // CHECK-FIXES: {{^ *}}FooClass() : JustBool(false) {}{{$}}
+  FooClass(int) : JustBool{0} {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: {{.*}}
+  // CHECK-FIXES: {{^ *}}FooClass(int) : JustBool{false} {}{{$}}
+  private:
+  bool JustBool;
+  bool BoolWithBraces{0};
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: {{.*}}
+  // CHECK-FIXES: {{^ *}}bool BoolWithBraces{false};{{$}}
+  bool BoolFromInt = 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: {{.*}}
+  // CHECK-FIXES: {{^ *}}bool BoolFromInt = false;{{$}}
+  bool SimpleBool = true; // OK
+};
+
+template
+void templateFunction(type) {
+  type TemplateType = 0;
+  // CHECK-FIXES: {{^ *}}type TemplateType = 0;{{$}}
+  return;
+}
+
+template
+void valueDependentTemplateFunction() {
+  bool Boolean = c;
+  // CHECK-FIXES: {{^ *}}bool Boolean = c;{{$}}
+  return;
+}
+
+template
+void anotherTemplateFunction(type) {
+  bool JustBool = 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: {{.*}}
+  // CHECK-FIXES: {{^ *}}bool JustBool = false;{{$}}
+  return;
+}
+
+int main() {
+  boolFunction(1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: {{.*}}
+  // CHECK-FIXES: {{^ *}}boolFunction(true);{{$}}
+
+  boolFunction(false);
+
+  templateFunction(0);
+
+  templateFunction(false);
+
+  valueDependentTemplateFunction<1>();
+
+  anotherTemplateFunction(1);
+
+  IntToTrue = 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}}
+  // CHECK-FIXES: {{^ *}}IntToTrue = true;{{$}}
+}
Index: docs/clang-tidy/checks/modernize-use-bool-literals.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-use-bool-literals.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - modernize-use-bool-literals
+
+modernize-use-bool-literals
+===
+
+Finds integer literals which are cast to bool.
+
+.. code-block:: c++
+
+  bool p = 1;
+  bool f = static_cast(1);
+  std::ios_base::sync_with_stdio(0);
+
+  //

[PATCH] D20014: [libc++] Explicit return in non-void function

2016-05-06 Thread Bernard Ogden via cfe-commits
bogden created this revision.
bogden added a reviewer: EricWF.
bogden added a subscriber: cfe-commits.

This test contains a non-void function with no explicit return,
causing it to fail when built with -Werror=return-type. This patch adds
a return to the function.

http://reviews.llvm.org/D20014

Files:
  
test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp

Index: 
test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp
===
--- 
test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp
+++ 
test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp
@@ -30,7 +30,7 @@
 };
 
 struct D {
-  static int allocator_type() {}
+  static int allocator_type() { return 0; }
 };
 
 struct E {


Index: test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp
===
--- test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp
+++ test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp
@@ -30,7 +30,7 @@
 };
 
 struct D {
-  static int allocator_type() {}
+  static int allocator_type() { return 0; }
 };
 
 struct E {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r268718 - AMDGPU/SI: Use amdgpu_kernel calling convention for OpenCL kernels.

2016-05-06 Thread Nikolay Haustov via cfe-commits
Author: nhaustov
Date: Fri May  6 04:15:24 2016
New Revision: 268718

URL: http://llvm.org/viewvc/llvm-project?rev=268718&view=rev
Log:
AMDGPU/SI: Use amdgpu_kernel calling convention for OpenCL kernels.

Reviewers: tstellarAMD, arsenm

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/CodeGenOpenCL/amdgpu-calling-conv.cl
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=268718&r1=268717&r2=268718&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri May  6 04:15:24 2016
@@ -6826,6 +6826,14 @@ void AMDGPUTargetCodeGenInfo::setTargetA
   if (!FD)
 return;
 
+  if (M.getLangOpts().OpenCL) {
+if (FD->hasAttr()) {
+  // Set amdgpu_kernel calling convention for OpenCL kernels.
+  llvm::Function *Fn = cast(GV);
+  Fn->setCallingConv(llvm::CallingConv::AMDGPU_KERNEL);
+}
+  }
+
   if (const auto Attr = FD->getAttr()) {
 llvm::Function *F = cast(GV);
 uint32_t NumVGPR = Attr->getNumVGPR();

Added: cfe/trunk/test/CodeGenOpenCL/amdgpu-calling-conv.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-calling-conv.cl?rev=268718&view=auto
==
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-calling-conv.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-calling-conv.cl Fri May  6 04:15:24 2016
@@ -0,0 +1,12 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | 
FileCheck %s
+
+// CHECK: define amdgpu_kernel void @calling_conv_amdgpu_kernel()
+kernel void calling_conv_amdgpu_kernel()
+{
+}
+
+// CHECK: define void @calling_conv_none()
+void calling_conv_none()
+{
+}

Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl?rev=268718&r1=268717&r2=268718&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl Fri May  6 04:15:24 2016
@@ -5,23 +5,23 @@
 
 __attribute__((amdgpu_num_vgpr(64))) // expected-no-diagnostics
 kernel void test_num_vgpr64() {
-// CHECK: define void @test_num_vgpr64() [[ATTR_VGPR64:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_vgpr64() [[ATTR_VGPR64:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_sgpr(32))) // expected-no-diagnostics
 kernel void test_num_sgpr32() {
-// CHECK: define void @test_num_sgpr32() [[ATTR_SGPR32:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_sgpr32() [[ATTR_SGPR32:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_vgpr(64), amdgpu_num_sgpr(32))) // 
expected-no-diagnostics
 kernel void test_num_vgpr64_sgpr32() {
-// CHECK: define void @test_num_vgpr64_sgpr32() [[ATTR_VGPR64_SGPR32:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_vgpr64_sgpr32() 
[[ATTR_VGPR64_SGPR32:#[0-9]+]]
 
 }
 
 __attribute__((amdgpu_num_sgpr(20), amdgpu_num_vgpr(40))) // 
expected-no-diagnostics
 kernel void test_num_sgpr20_vgpr40() {
-// CHECK: define void @test_num_sgpr20_vgpr40() [[ATTR_SGPR20_VGPR40:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_sgpr20_vgpr40() 
[[ATTR_SGPR20_VGPR40:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_vgpr(0))) // expected-no-diagnostics


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


Re: [PATCH] D19918: AMDGPU/SI: Use amdgpu_kernel calling convention for OpenCL kernels.

2016-05-06 Thread Nikolay Haustov via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268718: AMDGPU/SI: Use amdgpu_kernel calling convention for 
OpenCL kernels. (authored by nhaustov).

Changed prior to commit:
  http://reviews.llvm.org/D19918?vs=56141&id=56389#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19918

Files:
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/CodeGenOpenCL/amdgpu-calling-conv.cl
  cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl

Index: cfe/trunk/test/CodeGenOpenCL/amdgpu-calling-conv.cl
===
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-calling-conv.cl
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-calling-conv.cl
@@ -0,0 +1,12 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | 
FileCheck %s
+
+// CHECK: define amdgpu_kernel void @calling_conv_amdgpu_kernel()
+kernel void calling_conv_amdgpu_kernel()
+{
+}
+
+// CHECK: define void @calling_conv_none()
+void calling_conv_none()
+{
+}
Index: cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
===
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
@@ -5,23 +5,23 @@
 
 __attribute__((amdgpu_num_vgpr(64))) // expected-no-diagnostics
 kernel void test_num_vgpr64() {
-// CHECK: define void @test_num_vgpr64() [[ATTR_VGPR64:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_vgpr64() [[ATTR_VGPR64:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_sgpr(32))) // expected-no-diagnostics
 kernel void test_num_sgpr32() {
-// CHECK: define void @test_num_sgpr32() [[ATTR_SGPR32:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_sgpr32() [[ATTR_SGPR32:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_vgpr(64), amdgpu_num_sgpr(32))) // 
expected-no-diagnostics
 kernel void test_num_vgpr64_sgpr32() {
-// CHECK: define void @test_num_vgpr64_sgpr32() [[ATTR_VGPR64_SGPR32:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_vgpr64_sgpr32() 
[[ATTR_VGPR64_SGPR32:#[0-9]+]]
 
 }
 
 __attribute__((amdgpu_num_sgpr(20), amdgpu_num_vgpr(40))) // 
expected-no-diagnostics
 kernel void test_num_sgpr20_vgpr40() {
-// CHECK: define void @test_num_sgpr20_vgpr40() [[ATTR_SGPR20_VGPR40:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_sgpr20_vgpr40() 
[[ATTR_SGPR20_VGPR40:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_vgpr(0))) // expected-no-diagnostics
Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -6826,6 +6826,14 @@
   if (!FD)
 return;
 
+  if (M.getLangOpts().OpenCL) {
+if (FD->hasAttr()) {
+  // Set amdgpu_kernel calling convention for OpenCL kernels.
+  llvm::Function *Fn = cast(GV);
+  Fn->setCallingConv(llvm::CallingConv::AMDGPU_KERNEL);
+}
+  }
+
   if (const auto Attr = FD->getAttr()) {
 llvm::Function *F = cast(GV);
 uint32_t NumVGPR = Attr->getNumVGPR();


Index: cfe/trunk/test/CodeGenOpenCL/amdgpu-calling-conv.cl
===
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-calling-conv.cl
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-calling-conv.cl
@@ -0,0 +1,12 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define amdgpu_kernel void @calling_conv_amdgpu_kernel()
+kernel void calling_conv_amdgpu_kernel()
+{
+}
+
+// CHECK: define void @calling_conv_none()
+void calling_conv_none()
+{
+}
Index: cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
===
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
@@ -5,23 +5,23 @@
 
 __attribute__((amdgpu_num_vgpr(64))) // expected-no-diagnostics
 kernel void test_num_vgpr64() {
-// CHECK: define void @test_num_vgpr64() [[ATTR_VGPR64:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_vgpr64() [[ATTR_VGPR64:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_sgpr(32))) // expected-no-diagnostics
 kernel void test_num_sgpr32() {
-// CHECK: define void @test_num_sgpr32() [[ATTR_SGPR32:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_sgpr32() [[ATTR_SGPR32:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_vgpr(64), amdgpu_num_sgpr(32))) // expected-no-diagnostics
 kernel void test_num_vgpr64_sgpr32() {
-// CHECK: define void @test_num_vgpr64_sgpr32() [[ATTR_VGPR64_SGPR32:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_vgpr64_sgpr32() [[ATTR_VGPR64_SGPR32:#[0-9]+]]
 
 }
 
 __attribute__((amdgpu_num_sgpr(20), amdgpu_num_vgpr(40))) // expected-no-diagnostics
 kernel void test_num_sgpr20_vgpr40() {
-// CHECK: define void @test_num_sgpr20_vgpr40() [[ATTR_SGPR20_VGPR40:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_

r268729 - [OPENMP 4.5] Tests for 'private|firstprivates' clauses in 'taskloop' directive.

2016-05-06 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri May  6 07:04:14 2016
New Revision: 268729

URL: http://llvm.org/viewvc/llvm-project?rev=268729&view=rev
Log:
[OPENMP 4.5] Tests for 'private|firstprivates' clauses in 'taskloop' directive.

Added tests for codegen for private|firstprivate clauses in taskloop-based 
directives.

Added:
cfe/trunk/test/OpenMP/taskloop_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_private_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_private_codegen.cpp

Added: cfe/trunk/test/OpenMP/taskloop_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_firstprivate_codegen.cpp?rev=268729&view=auto
==
--- cfe/trunk/test/OpenMP/taskloop_firstprivate_codegen.cpp (added)
+++ cfe/trunk/test/OpenMP/taskloop_firstprivate_codegen.cpp Fri May  6 07:04:14 
2016
@@ -0,0 +1,513 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-apple-darwin10 
-emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-apple-darwin10 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -std=c++11 
-include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -DLAMBDA -triple 
x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=LAMBDA %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -fblocks -DBLOCKS -triple 
x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=BLOCKS %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -DARRAY -triple 
x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=ARRAY %s
+// expected-no-diagnostics
+// REQUIRES: x86-registered-target
+// It doesn't pass on win32.
+// REQUIRES: shell
+#ifndef ARRAY
+#ifndef HEADER
+#define HEADER
+
+template 
+struct S {
+  T f;
+  S(T a) : f(a) {}
+  S() : f() {}
+  S(const S &s, T t = T()) : f(s.f + t) {}
+  operator T() { return T(); }
+  ~S() {}
+};
+
+volatile double g;
+
+// CHECK-DAG: [[KMP_TASK_T_TY:%.+]] = type { i8*, i32 (i32, i8*)*, i32, i32 
(i32, i8*)*, i64, i64, i64, i32 }
+// CHECK-DAG: [[S_DOUBLE_TY:%.+]] = type { double }
+// CHECK-DAG: [[PRIVATES_MAIN_TY:%.+]] = type {{.?}}{ [2 x [[S_DOUBLE_TY]]], 
[[S_DOUBLE_TY]], i32, [2 x i32]
+// CHECK-DAG: [[CAP_MAIN_TY:%.+]] = type { [2 x i32]*, i32*, [2 x 
[[S_DOUBLE_TY]]]*, [[S_DOUBLE_TY]]*, i{{[0-9]+}}* }
+// CHECK-DAG: [[KMP_TASK_MAIN_TY:%.+]] = type { [[KMP_TASK_T_TY]], 
[[PRIVATES_MAIN_TY]] }
+// CHECK-DAG: [[S_INT_TY:%.+]] = type { i32 }
+// CHECK-DAG: [[CAP_TMAIN_TY:%.+]] = type { [2 x i32]*, i32*, [2 x 
[[S_INT_TY]]]*, [[S_INT_TY]]* }
+// CHECK-DAG: [[PRIVATES_TMAIN_TY:%.+]] = type { i32, [2 x i32], [2 x 
[[S_INT_TY]]], [[S_INT_TY]], [104 x i8] }
+// CHECK-DAG: [[KMP_TASK_TMAIN_TY:%.+]] = type { [[KMP_TASK_T_TY]], 
[{{[0-9]+}} x i8], [[PRIVATES_TMAIN_TY]] }
+template 
+T tmain() {
+  S ttt;
+  S test(ttt);
+  T t_var __attribute__((aligned(128))) = T();
+  T vec[] = {1, 2};
+  S s_arr[] = {1, 2};
+  S var(3);
+#pragma omp taskloop firstprivate(t_var, vec, s_arr, s_arr, var, var)
+  for (int i = 0; i < 10; ++i) {
+vec[0] = t_var;
+s_arr[0] = var;
+  }
+  return T();
+}
+
+int main() {
+  static int sivar;
+#ifdef LAMBDA
+  // LAMBDA: [[G:@.+]] = global double
+  // LAMBDA: [[SIVAR:@.+]] = internal global i{{[0-9]+}} 0,
+  // LAMBDA-LABEL: @main
+  // LAMBDA: call{{( x86_thiscallcc)?}} void [[OUTER_LAMBDA:@.+]](
+  [&]() {
+  // LAMBDA: define{{.*}} internal{{.*}} void [[OUTER_LAMBDA]](
+  // LAMBDA: [[RES:%.+]] = call i8* @__kmpc_omp_task_alloc(%{{[^ ]+}} 
@{{[^,]+}}, i32 %{{[^,]+}}, i32 1, i64 80, i64 16, i32 (i32, i8*)* bitcast (i32 
(i32, %{{[^*]+}}*)* [[TASK_ENTRY:@[^ ]+]] to i32 (i32, i8*)*))
+// LAMBDA: [[PRIVATES:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* 
%{{.+}}, i{{.+}} 0, i{{.+}} 1
+// LAMBDA: [[G_PRIVATE_ADDR:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* 
[[PRIVATES]], i{{.+}} 0, i{{.+}} 0
+// LAMBDA: [[G_ADDR_REF:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* 
%{{.+}}, i{{.+}} 0, i{{.+}} 0
+// LAMBDA: [[G_REF:%.+]] = load double*, double** [[G_ADDR_REF]]
+// LAMBDA: [[G_VAL:%.+]] = load volatile double, double* [[G_REF]]
+// LAMBDA: store volatile double [[G_VAL]], double* [[G_PRIVATE_ADDR]]
+
+// LAMBDA: [[SIVAR_PRIVATE_ADDR:%.+]] = getelementptr inbounds %{{.+}}, 
%{{.+}}* [[PRIVATES]], i{{.+}} 0, i{{.+}} 1
+// LAMBDA: [[SIVAR_ADDR_REF:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* 
%{{.+}}, i{{.+}} 0, i{{.+}} 1
+// LAMBDA: [[SIVAR_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** 
[[SIVAR_ADDR_REF]]
+// LAMBDA: [[SIVAR_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[SIVAR_REF]]
+// LAMBDA: store i{{[0-9]+}} [[SIVAR_VAL]], i{{[0-9]+}}* [[SIVAR_PRIVATE_ADDR]]
+
+// LAMBDA: call void @__kmpc_taskloop(%{{.+}}* @{{.+}}, i32 %{{.+}}, i8* 
[[RES]], i32 1, i64* %{{.+}}, i64* %{{.+}}, i64 %{{.+}}, i32 0, i32 0, i64 0

r268728 - s/codeblock/code-block to fix the Sphinx build.

2016-05-06 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri May  6 06:56:57 2016
New Revision: 268728

URL: http://llvm.org/viewvc/llvm-project?rev=268728&view=rev
Log:
s/codeblock/code-block to fix the Sphinx build.

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=268728&r1=268727&r2=268728&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Fri May  6 06:56:57 2016
@@ -94,7 +94,7 @@ C++ Language Changes in Clang
 - Clang now enforces the rule that a *using-declaration* cannot name an 
enumerator of a
   scoped enumeration.
 
-  .. codeblock:: c++
+  .. code-block:: c++
 
 namespace Foo { enum class E { e }; }
 namespace Bar {
@@ -105,7 +105,7 @@ C++ Language Changes in Clang
 - Clang now enforces the rule that an enumerator of an unscoped enumeration 
declared at
   class scope can only be named by a *using-declaration* in a derived class.
 
-  .. codeblock:: c++
+  .. code-block:: c++
 
 class Foo { enum E { e }; }
 using Foo::e; // error
@@ -127,7 +127,7 @@ Changes to C++1z features since Clang 3.
 
 - In C++1z mode, aggregate initialization can be performed for classes with 
base classes:
 
-  .. codeblock:: c++
+  .. code-block:: c++
 
   struct A { int n; };
   struct B : A { int x, y; };


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


Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-05-06 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

David, thank you for the thorough review! -- it definitely made the patch 
stronger and me even more paranoid than the rest of Intel. :-)

In http://reviews.llvm.org/D19654#422445, @majnemer wrote:

> FYI, we will also want to update `getAddrOfCXXCatchHandler` and 
> `getThrowInfo` to correctly handle `__unaligned`.


Do you want me to implement this (I have no idea how EH works on Windows, but 
can try...) or plan to implement yourself?

Yours,
Andrey


Repository:
  rL LLVM

http://reviews.llvm.org/D19654



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


Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-05-06 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268727: [MSVC] Implementation of __unaligned as a proper 
type qualifier (authored by asbokhan).

Changed prior to commit:
  http://reviews.llvm.org/D19654?vs=55588&id=56401#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19654

Files:
  cfe/trunk/include/clang/AST/Type.h
  cfe/trunk/include/clang/Basic/AddressSpaces.h
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Sema/DeclSpec.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/AST/MicrosoftMangle.cpp
  cfe/trunk/lib/AST/TypePrinter.cpp
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseTentative.cpp
  cfe/trunk/lib/Sema/DeclSpec.cpp
  cfe/trunk/lib/Sema/SemaCodeComplete.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaDeclObjC.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
  cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp
  cfe/trunk/test/Sema/MicrosoftExtensions.c
  cfe/trunk/test/Sema/address_spaces.c
  cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c
  cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp

Index: cfe/trunk/include/clang/AST/Type.h
===
--- cfe/trunk/include/clang/AST/Type.h
+++ cfe/trunk/include/clang/AST/Type.h
@@ -152,8 +152,8 @@
 
   enum {
 /// The maximum supported address space number.
-/// 24 bits should be enough for anyone.
-MaxAddressSpace = 0xffu,
+/// 23 bits should be enough for anyone.
+MaxAddressSpace = 0x7fu,
 
 /// The width of the "fast" qualifier mask.
 FastWidth = 3,
@@ -265,6 +265,13 @@
 Mask |= mask;
   }
 
+  bool hasUnaligned() const { return Mask & UMask; }
+  void setUnaligned(bool flag) {
+Mask = (Mask & ~UMask) | (flag ? UMask : 0);
+  }
+  void removeUnaligned() { Mask &= ~UMask; }
+  void addUnaligned() { Mask |= UMask; }
+
   bool hasObjCGCAttr() const { return Mask & GCAttrMask; }
   GC getObjCGCAttr() const { return GC((Mask & GCAttrMask) >> GCAttrShift); }
   void setObjCGCAttr(GC type) {
@@ -433,7 +440,9 @@
// ObjC lifetime qualifiers must match exactly.
getObjCLifetime() == other.getObjCLifetime() &&
// CVR qualifiers may subset.
-   (((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask & CVRMask));
+   (((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask & CVRMask)) &&
+   // U qualifier may superset.
+   (!(other.Mask & UMask) || (Mask & UMask));
   }
 
   /// \brief Determines if these qualifiers compatibly include another set of
@@ -501,16 +510,19 @@
 
 private:
 
-  // bits: |0 1 2|3 .. 4|5  ..  7|8   ...   31|
-  //   |C R V|GCAttr|Lifetime|AddressSpace|
+  // bits: |0 1 2|3|4 .. 5|6  ..  8|9   ...   31|
+  //   |C R V|U|GCAttr|Lifetime|AddressSpace|
   uint32_t Mask;
 
-  static const uint32_t GCAttrMask = 0x18;
-  static const uint32_t GCAttrShift = 3;
-  static const uint32_t LifetimeMask = 0xE0;
-  static const uint32_t LifetimeShift = 5;
-  static const uint32_t AddressSpaceMask = ~(CVRMask|GCAttrMask|LifetimeMask);
-  static const uint32_t AddressSpaceShift = 8;
+  static const uint32_t UMask = 0x8;
+  static const uint32_t UShift = 3;
+  static const uint32_t GCAttrMask = 0x30;
+  static const uint32_t GCAttrShift = 4;
+  static const uint32_t LifetimeMask = 0x1C0;
+  static const uint32_t LifetimeShift = 6;
+  static const uint32_t AddressSpaceMask =
+  ~(CVRMask | UMask | GCAttrMask | LifetimeMask);
+  static const uint32_t AddressSpaceShift = 9;
 };
 
 /// A std::pair-like structure for storing a qualified type split
@@ -5377,7 +5389,13 @@
 /// int" is at least as qualified as "const int", "volatile int",
 /// "int", and "const volatile int".
 inline bool QualType::isAtLeastAsQualifiedAs(QualType other) const {
-  return getQualifiers().compatiblyIncludes(other.getQualifiers());
+  Qualifiers otherQuals = other.getQualifiers();
+
+  // Ignore __unaligned qualifier if this type is a void.
+  if (getUnqualifiedType()->isVoidType())
+otherQuals.removeUnaligned();
+
+  return getQualifiers().compatiblyIncludes(otherQuals);
 }
 
 /// If Type is a reference type (e.g., const
Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -1675,7 +1675,8 @@
 SourceLocation ConstQualLoc = SourceLocation(),
 SourceLocation VolatileQualLoc = SourceLocation(),
 SourceLocation RestrictQualLoc = SourceLocation(),
-SourceLocation AtomicQualLoc = SourceLocation());
+SourceLocation AtomicQualLoc = SourceLocation(),
+SourceLocation UnalignedQua

r268727 - [MSVC] Implementation of __unaligned as a proper type qualifier

2016-05-06 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Fri May  6 06:47:55 2016
New Revision: 268727

URL: http://llvm.org/viewvc/llvm-project?rev=268727&view=rev
Log:
[MSVC] Implementation of __unaligned as a proper type qualifier

This patch implements __unaligned (MS extension) as a proper type qualifier
(before that, it was implemented as an ignored attribute).

It also fixes PR27367.

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

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/AddressSpaces.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseTentative.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp
cfe/trunk/test/Sema/MicrosoftExtensions.c
cfe/trunk/test/Sema/address_spaces.c
cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=268727&r1=268726&r2=268727&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Fri May  6 06:47:55 2016
@@ -152,8 +152,8 @@ public:
 
   enum {
 /// The maximum supported address space number.
-/// 24 bits should be enough for anyone.
-MaxAddressSpace = 0xffu,
+/// 23 bits should be enough for anyone.
+MaxAddressSpace = 0x7fu,
 
 /// The width of the "fast" qualifier mask.
 FastWidth = 3,
@@ -265,6 +265,13 @@ public:
 Mask |= mask;
   }
 
+  bool hasUnaligned() const { return Mask & UMask; }
+  void setUnaligned(bool flag) {
+Mask = (Mask & ~UMask) | (flag ? UMask : 0);
+  }
+  void removeUnaligned() { Mask &= ~UMask; }
+  void addUnaligned() { Mask |= UMask; }
+
   bool hasObjCGCAttr() const { return Mask & GCAttrMask; }
   GC getObjCGCAttr() const { return GC((Mask & GCAttrMask) >> GCAttrShift); }
   void setObjCGCAttr(GC type) {
@@ -433,7 +440,9 @@ public:
// ObjC lifetime qualifiers must match exactly.
getObjCLifetime() == other.getObjCLifetime() &&
// CVR qualifiers may subset.
-   (((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask & CVRMask));
+   (((Mask & CVRMask) | (other.Mask & CVRMask)) == (Mask & CVRMask)) &&
+   // U qualifier may superset.
+   (!(other.Mask & UMask) || (Mask & UMask));
   }
 
   /// \brief Determines if these qualifiers compatibly include another set of
@@ -501,16 +510,19 @@ public:
 
 private:
 
-  // bits: |0 1 2|3 .. 4|5  ..  7|8   ...   31|
-  //   |C R V|GCAttr|Lifetime|AddressSpace|
+  // bits: |0 1 2|3|4 .. 5|6  ..  8|9   ...   31|
+  //   |C R V|U|GCAttr|Lifetime|AddressSpace|
   uint32_t Mask;
 
-  static const uint32_t GCAttrMask = 0x18;
-  static const uint32_t GCAttrShift = 3;
-  static const uint32_t LifetimeMask = 0xE0;
-  static const uint32_t LifetimeShift = 5;
-  static const uint32_t AddressSpaceMask = ~(CVRMask|GCAttrMask|LifetimeMask);
-  static const uint32_t AddressSpaceShift = 8;
+  static const uint32_t UMask = 0x8;
+  static const uint32_t UShift = 3;
+  static const uint32_t GCAttrMask = 0x30;
+  static const uint32_t GCAttrShift = 4;
+  static const uint32_t LifetimeMask = 0x1C0;
+  static const uint32_t LifetimeShift = 6;
+  static const uint32_t AddressSpaceMask =
+  ~(CVRMask | UMask | GCAttrMask | LifetimeMask);
+  static const uint32_t AddressSpaceShift = 9;
 };
 
 /// A std::pair-like structure for storing a qualified type split
@@ -5377,7 +5389,13 @@ inline bool QualType::isMoreQualifiedTha
 /// int" is at least as qualified as "const int", "volatile int",
 /// "int", and "const volatile int".
 inline bool QualType::isAtLeastAsQualifiedAs(QualType other) const {
-  return getQualifiers().compatiblyIncludes(other.getQualifiers());
+  Qualifiers otherQuals = other.getQualifiers();
+
+  // Ignore __unaligned qualifier if this type is a void.
+  if (getUnqualifiedType()->isVoidType())
+otherQuals.removeUnaligned();
+
+  return getQualifiers().compatiblyIncludes(otherQuals);
 }
 
 /// If Type is a reference type (e.g., const

Modified: cfe/trunk/include/clang/Basic/AddressSpaces.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AddressSpaces.h?rev=268727&r1=268726&r2=268727&view=diff
==
--- cfe/trunk/include

Re: [PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-05-06 Thread Filipe Cabecinhas via cfe-commits
filcab updated this revision to Diff 56396.
filcab added a comment.

Address Richard's comments.
Final Windows fixes (force a Linux target so our mangled label matches).


http://reviews.llvm.org/D19666

Files:
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGExpr.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ubsan-strip-path-components.cpp
  test/Driver/fubsan-strip-path-components.cpp

Index: test/Driver/fubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/Driver/fubsan-strip-path-components.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang %s -### -o %t.o -fsanitize-undefined-strip-path-components=42 2>&1 | FileCheck %s
+// CHECK: "-fsanitize-undefined-strip-path-components=42"
Index: test/CodeGen/ubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/CodeGen/ubsan-strip-path-components.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -fsanitize=unreachable -o - | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=0 | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=2 | FileCheck %s -check-prefix=REMOVE-FIRST-TWO -check-prefix=CHECK
+
+// Try to strip too much:
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-9 | FileCheck %s -check-prefix=REGULAR
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=9 | FileCheck %s -check-prefix=LAST-ONLY
+
+// Check stripping from the file name
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-2 | FileCheck %s -check-prefix=LAST-TWO
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-1 | FileCheck %s -check-prefix=LAST-ONLY
+
+// REGULAR: @[[SRC:[0-9.a-zA-Z_]+]] =  private unnamed_addr constant [{{.*}} x i8] c"{{.*test(.|\\5C)CodeGen(.|\\5C)ubsan-strip-path-components\.cpp}}\00", align 1
+
+// First path component: "/" or "$drive_letter:", then a name, or '\5C' on Windows
+// REMOVE-FIRST-TWO: @[[STR:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"{{(.:|/)([^\\/]*(/|\\5C))}}[[REST:.*ubsan-strip-path-components\.cpp]]\00", align 1
+// REMOVE-FIRST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"[[REST]]\00", align 1
+
+// LAST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"CodeGen{{/|\\5C}}ubsan-strip-path-components.cpp\00", align 1
+// LAST-ONLY: @[[SRC:[0-9.a-zA-Z_]+]] =private unnamed_addr constant [{{.*}} x i8] c"ubsan-strip-path-components.cpp\00", align 1
+
+// CHECK: @[[STATIC_DATA:[0-9.a-zA-Z_]+]] = private unnamed_addr global { { [{{.*}} x i8]*, i32, i32 } } { { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+6]], i32 3 } }
+void g(const char *);
+void f() {
+  // CHECK-LABEL: @_Z1fv(
+  g(__FILE__);
+  // CHECK: call void @__ubsan_handle_builtin_unreachable(i8* bitcast ({ { [{{.*}} x i8]*, i32, i32 } }* @[[STATIC_DATA]] to i8*)) {{.*}}, !nosanitize
+  __builtin_unreachable();
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -782,6 +782,9 @@
   Opts.CudaGpuBinaryFileNames =
   Args.getAllArgValues(OPT_fcuda_include_gpubinary);
 
+  Opts.EmitCheckPathComponentsToStrip = getLastArgIntValue(
+  Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags);
+
   return Success;
 }
 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5595,6 +5595,10 @@
   if (Arg *A = Args.getLastArg(options::OPT_fshow_overloads_EQ))
 A->render(Args, CmdArgs);
 
+  if (Arg *A = Args.getLastArg(
+  options::OPT_fsanitize_undefined_strip_path_components_EQ))
+A->render(Args, CmdArgs);
+
   // -fdollars-in-identifiers default varies depending on platform and
   // language; only pass if specified.
   if (Arg *A = Args.getLastArg(options::OPT_fdollars_in_identifiers,
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -32,6 +32,7 @@
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Su

Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

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


Comment at: include-fixer/find-all-symbols/FindAllSymbols.h:16
@@ +15,3 @@
+#include "llvm/ADT/StringRef.h"
+
+#include 

No space between #includes in LLVM.


Comment at: include-fixer/find-all-symbols/PragmaCommentHandler.cpp:27
@@ +26,3 @@
+  SmallVector Matches;
+  if (!llvm::Regex(IWYUPragma).match(Text, &Matches))
+return false;

Isn't this regex just a complex way to write Text.find(IWYUPragma)?


http://reviews.llvm.org/D19816



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


r268721 - [OPENMP 4.0] Codegen for 'declare simd' directive.

2016-05-06 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri May  6 04:40:08 2016
New Revision: 268721

URL: http://llvm.org/viewvc/llvm-project?rev=268721&view=rev
Log:
[OPENMP 4.0] Codegen for 'declare simd' directive.

OpenMP 4.0 adds support for elemental functions using declarative
directive '#pragma omp declare simd'. Patch adds mangling for simd
functions in accordance with
https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt

Added:
cfe/trunk/test/OpenMP/declare_simd_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=268721&r1=268720&r2=268721&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri May  6 04:40:08 2016
@@ -6042,3 +6042,228 @@ void CGOpenMPRuntime::emitTargetEnterOrE
 ThenGenRCG(CGF);
   }
 }
+
+namespace {
+  /// Kind of parameter in a function with 'declare simd' directive.
+  enum ParamKindTy { LinearWithVarStride, Linear, Uniform, Vector };
+  /// Attribute set of the parameter.
+  struct ParamAttrTy {
+ParamKindTy Kind = Vector;
+llvm::APSInt StrideOrArg;
+llvm::APSInt Alignment;
+  };
+} // namespace
+
+static unsigned evaluateCDTSize(const FunctionDecl *FD,
+ArrayRef ParamAttrs) {
+  // Every vector variant of a SIMD-enabled function has a vector length 
(VLEN).
+  // If OpenMP clause "simdlen" is used, the VLEN is the value of the argument
+  // of that clause. The VLEN value must be power of 2.
+  // In other case the notion of the function`s "characteristic data type" 
(CDT)
+  // is used to compute the vector length.
+  // CDT is defined in the following order:
+  //   a) For non-void function, the CDT is the return type.
+  //   b) If the function has any non-uniform, non-linear parameters, then the
+  //   CDT is the type of the first such parameter.
+  //   c) If the CDT determined by a) or b) above is struct, union, or class
+  //   type which is pass-by-value (except for the type that maps to the
+  //   built-in complex data type), the characteristic data type is int.
+  //   d) If none of the above three cases is applicable, the CDT is int.
+  // The VLEN is then determined based on the CDT and the size of vector
+  // register of that ISA for which current vector version is generated. The
+  // VLEN is computed using the formula below:
+  //   VLEN  = sizeof(vector_register) / sizeof(CDT),
+  // where vector register size specified in section 3.2.1 Registers and the
+  // Stack Frame of original AMD64 ABI document.
+  QualType RetType = FD->getReturnType();
+  if (RetType.isNull())
+return 0;
+  ASTContext &C = FD->getASTContext();
+  QualType CDT;
+  if (!RetType.isNull() && !RetType->isVoidType())
+CDT = RetType;
+  else {
+unsigned Offset = 0;
+if (auto *MD = dyn_cast(FD)) {
+  if (ParamAttrs[Offset].Kind == Vector)
+CDT = C.getPointerType(C.getRecordType(MD->getParent()));
+  ++Offset;
+}
+if (CDT.isNull()) {
+  for (unsigned I = 0, E = FD->getNumParams(); I < E; ++I) {
+if (ParamAttrs[I + Offset].Kind == Vector) {
+  CDT = FD->getParamDecl(I)->getType();
+  break;
+}
+  }
+}
+  }
+  if (CDT.isNull())
+CDT = C.IntTy;
+  CDT = CDT->getCanonicalTypeUnqualified();
+  if (CDT->isRecordType() || CDT->isUnionType())
+CDT = C.IntTy;
+  return C.getTypeSize(CDT);
+}
+
+static void
+emitX86DeclareSimdFunction(const FunctionDecl *FD, llvm::Function *Fn,
+   llvm::APSInt VLENVal,
+   ArrayRef ParamAttrs,
+   OMPDeclareSimdDeclAttr::BranchStateTy State) {
+  struct ISADataTy {
+char ISA;
+unsigned VecRegSize;
+  };
+  ISADataTy ISAData[] = {
+  {
+  'b', 128
+  }, // SSE
+  {
+  'c', 256
+  }, // AVX
+  {
+  'd', 256
+  }, // AVX2
+  {
+  'e', 512
+  }, // AVX512
+  };
+  llvm::SmallVector Masked;
+  switch (State) {
+  case OMPDeclareSimdDeclAttr::BS_Undefined:
+Masked.push_back('N');
+Masked.push_back('M');
+break;
+  case OMPDeclareSimdDeclAttr::BS_Notinbranch:
+Masked.push_back('N');
+break;
+  case OMPDeclareSimdDeclAttr::BS_Inbranch:
+Masked.push_back('M');
+break;
+  }
+  for (auto Mask : Masked) {
+for (auto &Data : ISAData) {
+  SmallString<256> Buffer;
+  llvm::raw_svector_ostream Out(Buffer);
+  Out << "_ZGV" << Data.ISA << Mask;
+  if (!VLENVal) {
+Out << llvm::APSInt::getUnsigned(Data.VecRegSize /
+ evaluateCDTSize(FD, ParamAttrs));
+  } else
+Out << VLENVal;
+  for (auto &ParamAttr : 

Re: [PATCH] D19865: [clang-tidy] - PerformanceUnnecesaryCopyInitialization - only trigger for decl stmts with single VarDecl.

2016-05-06 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D19865#423140, @flx wrote:

> In http://reviews.llvm.org/D19865#419905, @flx wrote:
>
> > In http://reviews.llvm.org/D19865#419830, @alexfh wrote:
> >
> > > Is it a workaround to avoid breaking the code by incorrect fixes?
> >
> >
> > Yes. We can't simply change the type of DeclStmt when we only look one of 
> > the VarDecls and how it is initialized.
>
>
> Also, all tests still pass. Alex, do you have any particular concern with 
> this approach?


Even if we can't easily provide an automated fix (we could teach the check to 
split declarations, but it might not worth the effort), we could still emit a 
warning. WDYT?


Repository:
  rL LLVM

http://reviews.llvm.org/D19865



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


Re: [PATCH] D19534: [clang-tidy] new google-default-arguments check

2016-05-06 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM with one nit.



Comment at: test/clang-tidy/google-default-arguments.cpp:10
@@ +9,3 @@
+  void f(int I, int J = 5);
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: default arguments on virtual or 
override methods are prohibited [google-default-arguments]
+};

You can remove the `[google-default-arguments]` in this line and `line 15`. 
Usually we only keep it on the first warning message.


http://reviews.llvm.org/D19534



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


Re: [PATCH] D20011: [OpenMP 4.5] Parse+Sema for '#pragma omp declare target' clauses

2016-05-06 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


http://reviews.llvm.org/D20011



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


Re: [PATCH] D19993: Fixed cppcoreguidelines-pro-type-member-init when checking records with indirect fields

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


Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:31
@@ +30,3 @@
+// Convenience utility to get a RecordDecl from a QualType.
+const RecordDecl *getCanonicalRecordDecl(const QualType &Type) {
+  if (const auto *RT = Type.getCanonicalType()->getAs())

michael_miller wrote:
> alexfh wrote:
> > Is `getCanonicalType()` important here? Did you try using 
> > `QualType::getAsCXXRecordDecl()`?
> Probably not but I didn't try it. I just moved the previous function up to 
> the top so I didn't have to forward declare it.
> 
> One thing I'm simply unsure of is whether it's possible to get a RecordDecl 
> that's not a CXXRecordDecl in C++ code. It seems like the answer is no but 
> that might be another reason to keep it as is if I'm wrong about that...
> One thing I'm simply unsure of is whether it's possible to get a RecordDecl 
> that's not a CXXRecordDecl in C++ code.

From the documents, `RecordDecl` and `CXXRecordDecl` present  
struct/union/class, except `CXXRecordDecl` provides more methods for classes. 
So I think you can try `QualType::getAsCXXRecordDecl()` here.



http://reviews.llvm.org/D19993



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


[PATCH] D20011: [OpenMP 4.5] Parse+Sema for '#pragma omp declare target' clauses

2016-05-06 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin created this revision.
DmitryPolukhin added a reviewer: ABataev.
DmitryPolukhin added a subscriber: cfe-commits.

Support OpenMP version 4.5 syntax for #pragma omp declare target.

Syntax:
  #pragma omp declare target (extended-list) new-line
or
  #pragma omp declare target clause[ [,] clause ... ] new-line

Where clause is one of the following:
  to(extended-list)
  link(list)

http://reviews.llvm.org/D20011

Files:
  include/clang/AST/ASTMutationListener.h
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTWriter.h
  lib/Frontend/MultiplexConsumer.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  test/OpenMP/declare_target_ast_print.cpp
  test/OpenMP/declare_target_messages.cpp

Index: test/OpenMP/declare_target_messages.cpp
===
--- test/OpenMP/declare_target_messages.cpp
+++ test/OpenMP/declare_target_messages.cpp
@@ -4,9 +4,15 @@
 
 int a, b; // expected-warning {{declaration is not declared in any declare target region}}
 __thread int t; // expected-note {{defined as threadprivate or thread local}}
-#pragma omp declare target private(a) // expected-warning {{extra tokens at the end of '#pragma omp declare target' are ignored}}
+
+#pragma omp declare target . // expected-error {{expected '(' after 'declare target'}}
+
+#pragma omp declare target
 void f();
 #pragma omp end declare target shared(a) // expected-warning {{extra tokens at the end of '#pragma omp end declare target' are ignored}}
+
+#pragma omp declare target map(a) // expected-error {{unexpected 'map' clause, only 'to' or 'link' clauses expected}}
+
 void c(); // expected-warning {{declaration is not declared in any declare target region}}
 
 extern int b;
@@ -86,4 +92,10 @@
 } //  expected-error {{expected '#pragma omp end declare target'}}
 #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}}
 
+#pragma omp declare target link(S) // expected-error {{'S' used in declare target directive is not a variable or a function name}}
+
+#pragma omp declare target (x, x) // expected-error {{'x' appears multiple times in clauses on the same declare target directive}}
+#pragma omp declare target to(x) to(x) // expected-error {{'x' appears multiple times in clauses on the same declare target directive}}
+#pragma omp declare target link(x) // expected-error {{'x' must not appear in both clauses 'to' and 'link'}}
+
 #pragma omp declare target // expected-error {{expected '#pragma omp end declare target'}} expected-note {{to match this '#pragma omp declare target'}}
Index: test/OpenMP/declare_target_ast_print.cpp
===
--- test/OpenMP/declare_target_ast_print.cpp
+++ test/OpenMP/declare_target_ast_print.cpp
@@ -79,6 +79,51 @@
 #pragma omp end declare target
 // CHECK: #pragma omp end declare target
 
+int a1;
+void f1() {
+}
+#pragma omp declare target (a1, f1)
+// CHECK: #pragma omp declare target
+// CHECK: int a1;
+// CHECK: #pragma omp end declare target
+// CHECK: #pragma omp declare target
+// CHECK: void f1()
+// CHECK: #pragma omp end declare target
+
+int b1, b2, b3;
+void f2() {
+}
+#pragma omp declare target to(b1) to(b2), to(b3, f2)
+// CHECK: #pragma omp declare target
+// CHECK: int b1;
+// CHECK: #pragma omp end declare target
+// CHECK: #pragma omp declare target
+// CHECK: int b2;
+// CHECK: #pragma omp end declare target
+// CHECK: #pragma omp declare target
+// CHECK: int b3;
+// CHECK: #pragma omp end declare target
+// CHECK: #pragma omp declare target
+// CHECK: void f2()
+// CHECK: #pragma omp end declare target
+
+int c1, c2, c3;
+void f3() {
+}
+#pragma omp declare target link(c1) link(c2), link(c3, f3)
+// CHECK: #pragma omp declare target link
+// CHECK: int c1;
+// CHECK: #pragma omp end declare target
+// CHECK: #pragma omp declare target link
+// CHECK: int c2;
+// CHECK: #pragma omp end declare target
+// CHECK: #pragma omp declare target link
+// CHECK: int c3;
+// CHECK: #pragma omp end declare target
+// CHECK: #pragma omp declare target link
+// CHECK: void f3()
+// CHECK: #pragma omp end declare target
+
 int main (int argc, char **argv) {
   foo();
   foo_c();
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -5816,12 +5816,14 @@
   DeclUpdates[D].push_back(DeclUpdate(UPD_DECL_MARKED_OPENMP_THREADPRIVATE));
 }
 
-void ASTWriter::DeclarationMarkedOpenMPDeclareTarget(const Decl *D) {
+void ASTWriter::DeclarationMarkedOpenMPDeclareTarget(const Decl *D,
+ const Attr *Attr) {
   assert(!WritingAST && "Alr

Re: [PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-05-06 Thread Filipe Cabecinhas via cfe-commits
filcab added inline comments.


Comment at: lib/CodeGen/CGExpr.cpp:2385-2386
@@ +2384,4 @@
+FilenameString = FilenameString.substr(I - E);
+  else
+FilenameString = llvm::sys::path::filename(FilenameString);
+} else if (PathComponentsToStrip > 0) {

rsmith wrote:
> This doesn't look right: if `I == E`, we were asked to keep at least as many 
> components as there were, so we should keep the entire string. I think the 
> `substr(I - E)` codepath is appropriate in either case here.
Ah, right.
My rationale was "if the number of stuff to strip (positive or negative) is 
greater than the number of path components, keep only the filename", which 
doesn't really fit with the negative case.
Will change today.


Comment at: test/CodeGen/ubsan-strip-path-components.cpp:6
@@ +5,3 @@
+// Try to strip too much:
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - 
-fsanitize-undefined-strip-path-components=-9 | FileCheck %s 
-check-prefix=LAST-ONLY
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - 
-fsanitize-undefined-strip-path-components=9 | FileCheck %s 
-check-prefix=LAST-ONLY

rsmith wrote:
> I think this test is incorrect too.
Yep, test update coming.


http://reviews.llvm.org/D19666



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