Re: [PATCH] D23765: Fix for clang PR 29087

2016-09-14 Thread Serge Pavlov via cfe-commits
sepavloff added a subscriber: sepavloff.
sepavloff added a comment.

You need to provide a test for the fix.


https://reviews.llvm.org/D23765



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


r281587 - Update clang unittests for rL281586.

2016-09-14 Thread Wei Mi via cfe-commits
Author: wmi
Date: Thu Sep 15 01:31:30 2016
New Revision: 281587

URL: http://llvm.org/viewvc/llvm-project?rev=281587&view=rev
Log:
Update clang unittests for rL281586.

The change in rL281586 is in llvm component and tests updated here are
in clang component, so I have to commit them consecutively.

Modified:
cfe/trunk/test/CodeGen/cleanup-destslot-simple.c
cfe/trunk/test/CodeGen/temporary-lifetime-exceptions.cpp
cfe/trunk/test/CodeGen/temporary-lifetime.cpp
cfe/trunk/test/CodeGenCXX/nrvo.cpp
cfe/trunk/test/CodeGenObjC/exceptions.m
cfe/trunk/test/CodeGenObjCXX/exceptions-legacy.mm

Modified: cfe/trunk/test/CodeGen/cleanup-destslot-simple.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cleanup-destslot-simple.c?rev=281587&r1=281586&r2=281587&view=diff
==
--- cfe/trunk/test/CodeGen/cleanup-destslot-simple.c (original)
+++ cfe/trunk/test/CodeGen/cleanup-destslot-simple.c Thu Sep 15 01:31:30 2016
@@ -13,8 +13,8 @@ int test() {
   return *p;
 // CHECK: [[X:%.*]] = alloca i32
 // CHECK: [[P:%.*]] = alloca i32*
-// LIFETIME: call void @llvm.lifetime.start(i64 4, i8* %{{.*}}){{( 
#[0-9]+)?}}, !dbg
-// LIFETIME: call void @llvm.lifetime.start(i64 8, i8* %{{.*}}){{( 
#[0-9]+)?}}, !dbg
+// LIFETIME: call void @llvm.lifetime.start(i64 4, i8* nonnull %{{.*}}){{( 
#[0-9]+)?}}, !dbg
+// LIFETIME: call void @llvm.lifetime.start(i64 8, i8* nonnull %{{.*}}){{( 
#[0-9]+)?}}, !dbg
 // CHECK-NOT: store i32 %{{.*}}, i32* %cleanup.dest.slot
 // LIFETIME: call void @llvm.lifetime.end(i64 8, {{.*}}){{( #[0-9]+)?}}, !dbg
 // LIFETIME: call void @llvm.lifetime.end(i64 4, {{.*}}){{( #[0-9]+)?}}, !dbg

Modified: cfe/trunk/test/CodeGen/temporary-lifetime-exceptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/temporary-lifetime-exceptions.cpp?rev=281587&r1=281586&r2=281587&view=diff
==
--- cfe/trunk/test/CodeGen/temporary-lifetime-exceptions.cpp (original)
+++ cfe/trunk/test/CodeGen/temporary-lifetime-exceptions.cpp Thu Sep 15 
01:31:30 2016
@@ -9,16 +9,16 @@ A Baz(const A&);
 void Test1() {
   // CHECK-LABEL: @_Z5Test1v(
   // CHECK: getelementptr
-  // CHECK-NEXT: call void @llvm.lifetime.start(i64 1, i8* [[TMP:[^ ]+]])
+  // CHECK-NEXT: call void @llvm.lifetime.start(i64 1, i8* nonnull [[TMP:[^ 
]+]])
   // CHECK-NEXT: getelementptr
-  // CHECK-NEXT: call void @llvm.lifetime.start(i64 1, i8* [[TMP1:[^ ]+]])
+  // CHECK-NEXT: call void @llvm.lifetime.start(i64 1, i8* nonnull [[TMP1:[^ 
]+]])
 
   // Normal exit
-  // CHECK: call void @llvm.lifetime.end(i64 1, i8* [[TMP1]])
-  // CHECK-NEXT: call void @llvm.lifetime.end(i64 1, i8* [[TMP]])
+  // CHECK: call void @llvm.lifetime.end(i64 1, i8* nonnull [[TMP1]])
+  // CHECK-NEXT: call void @llvm.lifetime.end(i64 1, i8* nonnull [[TMP]])
 
   // Exception exit
-  // CHECK: call void @llvm.lifetime.end(i64 1, i8* [[TMP1]])
-  // CHECK-NEXT: call void @llvm.lifetime.end(i64 1, i8* [[TMP]])
+  // CHECK: call void @llvm.lifetime.end(i64 1, i8* nonnull [[TMP1]])
+  // CHECK-NEXT: call void @llvm.lifetime.end(i64 1, i8* nonnull [[TMP]])
   Baz(Baz(A()));
 }

Modified: cfe/trunk/test/CodeGen/temporary-lifetime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/temporary-lifetime.cpp?rev=281587&r1=281586&r2=281587&view=diff
==
--- cfe/trunk/test/CodeGen/temporary-lifetime.cpp (original)
+++ cfe/trunk/test/CodeGen/temporary-lifetime.cpp Thu Sep 15 01:31:30 2016
@@ -21,27 +21,27 @@ T Baz();
 
 void Test1() {
   // CHECK-DTOR-LABEL: Test1
-  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* nonnull 
%[[ADDR:[0-9]+]])
   // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
   // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
   // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR]])
-  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
-  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* nonnull %[[ADDR]])
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* nonnull 
%[[ADDR:[0-9]+]])
   // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
   // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
   // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR]])
-  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* nonnull %[[ADDR]])
   // CHECK-DTOR: }
 
   // CHECK-NO-DTOR-LABEL: Test1
-  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* 
%[[ADDR:[0-9]+]])
+  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* nonnull 
%[[ADDR:[0-9]+]])
   // CHECK-NO-DTOR: cal

r281582 - Builtins.def: Explicitly undef finitef, to appease mingw. It defines finitef as alias of _finitef.

2016-09-14 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Thu Sep 15 00:11:43 2016
New Revision: 281582

URL: http://llvm.org/viewvc/llvm-project?rev=281582&view=rev
Log:
Builtins.def: Explicitly undef finitef, to appease mingw. It defines finitef as 
alias of _finitef.

Modified:
cfe/trunk/include/clang/Basic/Builtins.def

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=281582&r1=281581&r2=281582&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Thu Sep 15 00:11:43 2016
@@ -944,6 +944,10 @@ LIBBUILTIN(fabs, "dd", "fnc", "math.h",
 LIBBUILTIN(fabsf, "ff", "fnc", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(fabsl, "LdLd", "fnc", "math.h", ALL_LANGUAGES)
 
+// Some systems define finitef as alias of _finitef.
+#if defined (finitef)
+#undef finitef
+#endif
 LIBBUILTIN(finite, "id", "fnc", "math.h", GNU_LANG)
 LIBBUILTIN(finitef, "if", "fnc", "math.h", GNU_LANG)
 LIBBUILTIN(finitel, "iLd", "fnc", "math.h", GNU_LANG)


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


[PATCH] D24600: [libc++] Add _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY to support GCC ABI compatibility

2016-09-14 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added reviewers: mclow.lists, eugenis, danalbert, jroelofs.
EricWF added a subscriber: cfe-commits.
Herald added subscribers: mgorny, beanz.

GCC and Clang handle visibility attributes on the out-of-line definition of 
externally instantiated templates differently. For example in the reproducer 
below Clang will emit both 'foo' and 'bar' with default visibility while GCC 
only emits a non-hidden 'foo'.  

```
// RUN: g++ -std=c++11 -shared -O3 test.cpp && sym_extract.py a.out
// RUN: clang++ -std=c++11 -shared -O3 test.cpp && sym_extract.py a.out
#define INLINE_VISIBILITY __attribute__((visibility("hidden"), always_inline))

template 
struct Foo {
  void foo();
  void bar();
};

template 
void Foo::foo() {}

template 
inline INLINE_VISIBILITY
void Foo::bar() {}

template struct Foo;
```

This difference creates ABI incompatibilities between Clang and GCC built 
dylibs. Specifically GCC built dylibs lack definitions for various member 
functions of `basic_string`, `basic_istream`, `basic_ostream`, 
`basic_iostream`, and `basic_streambuf` (All of these types are externally 
instantiated). 

Surprisingly these missing symbols don't cause many problems because the 
functions are marked `always_inline`  therefore the dylib definition is rarely 
needed. However when an out-of-line definition is required then GCC built 
dylibs will fail to link. For example [GCC built dylibs cannot build 
Clang](http://stackoverflow.com/questions/39454262/clang-build-errors).

This patch works around this issue by adding 
`_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY` which is used to mark externally 
instantiated member functions as always inline. When building the library 
`_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY` sets the symbol's visibility to 
"default" instead of "hidden", otherwise it acts exactly the same as 
`_LIBCPP_INLINE_VISIBILITY`.

After applying this patch GCC dylibs now contain:
  * `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7sungetcEv`
  * `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5gbumpEi`
  * `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7sungetcEv`
  * `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9sputbackcEc`
  * 
`_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getERNS_15basic_streambufIwS2_EE`
  * 
`_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRNS_9basic_iosIwS2_EES6_E`
  * `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4setpEPcS4_`
  * 
`_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEEC1EPNS_15basic_streambufIwS2_EE`
  * `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6snextcEv`
  * `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE4swapERS3_`
  * `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE4swapERS3_`
  * 
`_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm`
  * `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRNS_8ios_baseES5_E`
  * `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9pubsetbufEPcl`
  * 
`_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekoffExNS_8ios_base7seekdirEj`
  * 
`_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRNS_9basic_iosIwS2_EES6_E`
  * `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5pbumpEi`
  * 
`_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5seekpENS_4fposI11__mbstate_tEE`
  * `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE7getlineEPcl`
  * `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sgetcEv`
  * 
`_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getERNS_15basic_streambufIcS2_EE`
  * `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRNS_8ios_baseES5_E`
  * `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE8in_availEv`
  * `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRNS_8ios_baseES5_E`
  * `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6sbumpcEv`
  * 
`_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRNS_9basic_iosIcS2_EES6_E`
  * `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getERc`
  * `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE6snextcEv`
  * `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEmw`
  * `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE7getlineEPwl`
  * `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5tellpEv`
  * `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getERw`
  * `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEmc`
  * `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7pubsyncEv`
  * `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getEPcl`
  * 
`_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
  * 
`_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRNS_9basic_iosIcS2_EES6_E`
  * `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7pubsyncEv`
  * `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputcEc`
  * 
`_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5seekpExNS_8ios_base7seekdirE`
  * `_ZNKSt3__115basic_streambufIcNS_11char_traitsIcEEE6getlocEv`
  * `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5gbumpEi`
  * `_ZNSt

[PATCH] D24599: Add 'inline' but not _LIBCPP_INLINE_VISIBILITY to basic_string's destructor

2016-09-14 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added reviewers: mclow.lists, laxmansole, hiraditya, dblaikie.
EricWF added a subscriber: cfe-commits.

r280944 attempted to add both `inline` and `_LIBCPP_INLINE_VISIBILITY` to 
basic_string's destructor in order to achieve better inlining behavior. 
Unfortunately applying `_LIBCPP_INLINE_VISIBILITY` to the destructor [triggers 
a Clang bug](http://llvm.org/PR30341). This patch attempts to still get better 
inlining behavior while working around the Clang bug by simply applying 
`inline` without the attribute.

Unfortunately applying only `inline` causes the destructor to be inlined at -O2 
or greater whereas the attribute results in inlining at all optimization 
levels. However this is still better than no inlining at all. See 
https://godbolt.org/g/8UbKwb for example assembly.

My only concern with this patch is marking the function as `inline` without 
making the visibility hidden. I don't think that should have any weird 
consequences but I'm not 100%.

https://reviews.llvm.org/D24599

Files:
  include/string

Index: include/string
===
--- include/string
+++ include/string
@@ -1798,6 +1798,7 @@
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
 template 
+inline // _LIBCPP_INLINE_VISIBILITY FIXME: http://llvm.org/PR30341
 basic_string<_CharT, _Traits, _Allocator>::~basic_string()
 {
 #if _LIBCPP_DEBUG_LEVEL >= 2


Index: include/string
===
--- include/string
+++ include/string
@@ -1798,6 +1798,7 @@
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
 template 
+inline // _LIBCPP_INLINE_VISIBILITY FIXME: http://llvm.org/PR30341
 basic_string<_CharT, _Traits, _Allocator>::~basic_string()
 {
 #if _LIBCPP_DEBUG_LEVEL >= 2
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24598: Separate builtins for x84-64 and i386; implement __mulh and __umulh

2016-09-14 Thread Albert Gutowski via cfe-commits
agutowski created this revision.
agutowski added reviewers: rnk, thakis, majnemer.
agutowski added a subscriber: cfe-commits.

We need x86-64-specific builtins if we want to implement some of the MS 
intrinsics - winnt.h contains definitions of some functions for i386, but not 
for x86-64 (for example _InterlockedOr64), which means that we cannot treat 
them as builtins for both i386 and x86-64, because then we have definitions of 
builtin functions in winnt.h on i386.

https://reviews.llvm.org/D24598

Files:
  include/clang/Basic/BuiltinsX86_32.def
  include/clang/Basic/BuiltinsX86_64.def
  include/clang/Basic/TargetBuiltins.h
  lib/Basic/Targets.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/intrin.h
  test/CodeGen/ms-intrinsics.c
  test/Sema/implicit-ms-builtin-decl.c

Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -312,6 +312,7 @@
 unsigned __int64 __lzcnt64(unsigned __int64);
 static __inline__
 void __movsq(unsigned long long *, unsigned long long const *, size_t);
+static __inline__
 __int64 __mulh(__int64, __int64);
 static __inline__
 unsigned __int64 __popcnt64(unsigned __int64);
@@ -426,12 +427,8 @@
   *_HighProduct = _FullProduct >> 64;
   return _FullProduct;
 }
-static __inline__ unsigned __int64 __DEFAULT_FN_ATTRS
-__umulh(unsigned __int64 _Multiplier, unsigned __int64 _Multiplicand) {
-  unsigned __int128 _FullProduct =
-  (unsigned __int128)_Multiplier * (unsigned __int128)_Multiplicand;
-  return _FullProduct >> 64;
-}
+static __inline__
+unsigned __int64 __umulh(unsigned __int64, unsigned __int64);
 
 #endif /* __x86_64__ */
 
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -7488,7 +7488,31 @@
 return getCmpIntrinsicCall(Intrinsic::x86_sse2_cmp_sd, 6);
   case X86::BI__builtin_ia32_cmpordsd:
 return getCmpIntrinsicCall(Intrinsic::x86_sse2_cmp_sd, 7);
+
+  case X86_64::BI__mulh:
+  case X86_64::BI__umulh: {
+Value *LHS = EmitScalarExpr(E->getArg(0));
+Value *RHS = EmitScalarExpr(E->getArg(1));
+llvm::Type *ResType = ConvertType(E->getType());
+llvm::Type *Int128Ty = llvm::IntegerType::get(getLLVMContext(), 128);
+
+bool IsSigned = (BuiltinID == X86_64::BI__mulh);
+LHS = Builder.CreateIntCast(LHS, Int128Ty, IsSigned);
+RHS = Builder.CreateIntCast(RHS, Int128Ty, IsSigned);
+
+Value *MulResult, *HigherBits;
+if (IsSigned) {
+  MulResult = Builder.CreateNSWMul(LHS, RHS);
+  HigherBits = Builder.CreateAShr(MulResult, 64);
+} else {
+  MulResult = Builder.CreateNUWMul(LHS, RHS);
+  HigherBits = Builder.CreateLShr(MulResult, 64);
+}
+
+HigherBits = Builder.CreateIntCast(HigherBits, ResType, IsSigned);
+return HigherBits;
   }
+  }
 }
 
 
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2295,19 +2295,37 @@
   return TargetInfo::initFeatureMap(Features, Diags, CPU, FeatureVec);
 }
 
-// Namespace for x86 abstract base class
-const Builtin::Info BuiltinInfo[] = {
+const Builtin::Info BuiltinInfoX86_32[] = {
 #define BUILTIN(ID, TYPE, ATTRS)   \
   { #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
-#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER)\
-  { #ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr },
 #define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE)   \
   { #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE },
 #define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \
   { #ID, TYPE, ATTRS, HEADER, LANGS, FEATURE },
 #include "clang/Basic/BuiltinsX86.def"
+
+#define BUILTIN(ID, TYPE, ATTRS)   \
+  { #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
+#include "clang/Basic/BuiltinsX86_32.def"
 };
 
+const Builtin::Info BuiltinInfoX86_64[] = {
+#define BUILTIN(ID, TYPE, ATTRS)   \
+  { #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE)   \
+  { #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE },
+#define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \
+  { #ID, TYPE, ATTRS, HEADER, LANGS, FEATURE },
+#include "clang/Basic/BuiltinsX86.def"
+
+#define BUILTIN(ID, TYPE, ATTRS)   \
+  { #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
+#define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \
+  { #ID, TYPE, ATTRS, HEADER, LANGS, FEATURE },
+#include "clang/Basic/BuiltinsX86_64.def"
+};
+
+
 static const char* const GCCRegNames[] = {
   "ax", "dx", "cx", "bx", "si", "di", "bp", "sp",
   "st", "st(1)", "st(2)", "st(3)",

Re: [PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

2016-09-14 Thread Sasha Bermeister via cfe-commits
sashab added a comment.

Pinging for another LGTM since I have added it to -Wall and added a portability 
comment to the error message :)


https://reviews.llvm.org/D24289



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


[libclc] r281566 - math: Implement tgamma

2016-09-14 Thread Aaron Watry via cfe-commits
Author: awatry
Date: Wed Sep 14 19:17:34 2016
New Revision: 281566

URL: http://llvm.org/viewvc/llvm-project?rev=281566&view=rev
Log:
math: Implement tgamma

Signed-off-by: Aaron Watry 
Reviewed-by: Tom Stellard 

Added:
libclc/trunk/generic/include/clc/math/tgamma.h
libclc/trunk/generic/include/clc/math/tgamma.inc
libclc/trunk/generic/lib/math/tgamma.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=281566&r1=281565&r2=281566&view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Wed Sep 14 19:17:34 2016
@@ -88,6 +88,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Added: libclc/trunk/generic/include/clc/math/tgamma.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/tgamma.h?rev=281566&view=auto
==
--- libclc/trunk/generic/include/clc/math/tgamma.h (added)
+++ libclc/trunk/generic/include/clc/math/tgamma.h Wed Sep 14 19:17:34 2016
@@ -0,0 +1,3 @@
+#define __CLC_BODY 
+#include 
+#undef __CLC_BODY

Added: libclc/trunk/generic/include/clc/math/tgamma.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/tgamma.inc?rev=281566&view=auto
==
--- libclc/trunk/generic/include/clc/math/tgamma.inc (added)
+++ libclc/trunk/generic/include/clc/math/tgamma.inc Wed Sep 14 19:17:34 2016
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE tgamma(__CLC_GENTYPE a);

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=281566&r1=281565&r2=281566&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Wed Sep 14 19:17:34 2016
@@ -119,6 +119,7 @@ math/clc_sqrt.cl
 math/sqrt.cl
 math/tan.cl
 math/tanh.cl
+math/tgamma.cl
 relational/all.cl
 relational/any.cl
 relational/bitselect.cl

Added: libclc/trunk/generic/lib/math/tgamma.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/tgamma.cl?rev=281566&view=auto
==
--- libclc/trunk/generic/lib/math/tgamma.cl (added)
+++ libclc/trunk/generic/lib/math/tgamma.cl Wed Sep 14 19:17:34 2016
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2016 Aaron Watry
+ * 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"
+
+_CLC_OVERLOAD _CLC_DEF float tgamma(float x) {
+const float pi = 3.1415926535897932384626433832795f;
+float ax = fabs(x);
+float lg = lgamma(ax);
+float g = exp(lg);
+
+if (x < 0.0f) {
+float z = sinpi(x);
+g = g * ax * z;
+g = pi / g;
+g = g == 0 ? as_float(PINFBITPATT_SP32) : g;
+g = z == 0 ? as_float(QNANBITPATT_SP32) : g;
+}
+
+return g;
+}
+
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, tgamma, float);
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+_CLC_OVERLOAD _CLC_DEF double tgamma(double x) {
+const double pi = 3.1415926535897932384626433832795;
+double ax = fabs(x);
+double lg = lgamma(ax);
+double g = exp(lg);
+
+if (x < 0.0) {
+double z = sinpi(x);
+g = g * ax * z;
+g = pi / g;
+g = g == 0 ? as_double(PINFBITPATT_DP64) : g;
+g = z == 0 ? as_double(QNANBITPATT_DP64) : g;
+}
+
+return g;
+}
+
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, dou

[libclc] r281563 - Add ADDR_SPACE parameter to _CLC_V_V_VP_VECTORIZE

2016-09-14 Thread Aaron Watry via cfe-commits
Author: awatry
Date: Wed Sep 14 19:17:22 2016
New Revision: 281563

URL: http://llvm.org/viewvc/llvm-project?rev=281563&view=rev
Log:
Add ADDR_SPACE parameter to _CLC_V_V_VP_VECTORIZE

This macro is currently unused, but I plan to use it shortly.

The previous form did casts of pointers without an address space, which
doesn't work so well for CL 1.x.

Signed-off-by: Aaron Watry 
Reviewed-by: Tom Stellard 

Modified:
libclc/trunk/generic/lib/clcmacro.h

Modified: libclc/trunk/generic/lib/clcmacro.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/clcmacro.h?rev=281563&r1=281562&r2=281563&view=diff
==
--- libclc/trunk/generic/lib/clcmacro.h (original)
+++ libclc/trunk/generic/lib/clcmacro.h Wed Sep 14 19:17:22 2016
@@ -109,26 +109,41 @@
   } \
 \
 
-#define _CLC_V_V_VP_VECTORIZE(DECLSPEC, RET_TYPE, FUNCTION, ARG1_TYPE, 
ARG2_TYPE) \
-  DECLSPEC RET_TYPE##2 FUNCTION(ARG1_TYPE##2 x, ARG2_TYPE##2 *y) { \
-return (RET_TYPE##2)(FUNCTION(x.x, (ARG2_TYPE*)y), FUNCTION(x.y, 
(ARG2_TYPE*)y+1)); \
+#define _CLC_V_V_VP_VECTORIZE(DECLSPEC, RET_TYPE, FUNCTION, ARG1_TYPE, 
ADDR_SPACE, ARG2_TYPE) \
+  DECLSPEC RET_TYPE##2 FUNCTION(ARG1_TYPE##2 x, ADDR_SPACE ARG2_TYPE##2 *y) { \
+return (RET_TYPE##2)( \
+FUNCTION(x.x, (ARG2_TYPE*)y), \
+FUNCTION(x.y, (ADDR_SPACE ARG2_TYPE*)((ADDR_SPACE ARG2_TYPE*)y+1)) \
+); \
   } \
 \
-  DECLSPEC RET_TYPE##3 FUNCTION(ARG1_TYPE##3 x, ARG2_TYPE##3 *y) { \
-return (RET_TYPE##3)(FUNCTION(x.x, (ARG2_TYPE*)y), FUNCTION(x.y, 
(ARG2_TYPE*)y+1), \
- FUNCTION(x.z, (ARG2_TYPE*)y+2)); \
+  DECLSPEC RET_TYPE##3 FUNCTION(ARG1_TYPE##3 x, ADDR_SPACE ARG2_TYPE##3 *y) { \
+return (RET_TYPE##3)( \
+FUNCTION(x.x, (ARG2_TYPE*)y), \
+FUNCTION(x.y, (ADDR_SPACE ARG2_TYPE*)((ADDR_SPACE ARG2_TYPE*)y+1)), \
+FUNCTION(x.z, (ADDR_SPACE ARG2_TYPE*)((ADDR_SPACE ARG2_TYPE*)y+2)) \
+); \
   } \
 \
-  DECLSPEC RET_TYPE##4 FUNCTION(ARG1_TYPE##4 x, ARG2_TYPE##4 *y) { \
-return (RET_TYPE##4)(FUNCTION(x.lo, (ARG2_TYPE##2*)y), FUNCTION(x.hi, 
(ARG2_TYPE##2*)((ARG2_TYPE*)y+2))); \
+  DECLSPEC RET_TYPE##4 FUNCTION(ARG1_TYPE##4 x, ADDR_SPACE ARG2_TYPE##4 *y) { \
+return (RET_TYPE##4)( \
+FUNCTION(x.lo, (ARG2_TYPE##2*)y), \
+FUNCTION(x.hi, (ADDR_SPACE ARG2_TYPE##2*)((ADDR_SPACE ARG2_TYPE*)y+2)) 
\
+); \
   } \
 \
-  DECLSPEC RET_TYPE##8 FUNCTION(ARG1_TYPE##8 x, ARG2_TYPE##8 *y) { \
-return (RET_TYPE##8)(FUNCTION(x.lo, (ARG2_TYPE##4*)y), FUNCTION(x.hi, 
(ARG2_TYPE##4*)((ARG2_TYPE*)y+4))); \
+  DECLSPEC RET_TYPE##8 FUNCTION(ARG1_TYPE##8 x, ADDR_SPACE ARG2_TYPE##8 *y) { \
+return (RET_TYPE##8)( \
+FUNCTION(x.lo, (ARG2_TYPE##4*)y), \
+FUNCTION(x.hi, (ADDR_SPACE ARG2_TYPE##4*)((ADDR_SPACE ARG2_TYPE*)y+4)) 
\
+); \
   } \
 \
-  DECLSPEC RET_TYPE##16 FUNCTION(ARG1_TYPE##16 x, ARG2_TYPE##16 *y) { \
-return (RET_TYPE##16)(FUNCTION(x.lo, (ARG2_TYPE##8*)y), FUNCTION(x.hi, 
(ARG2_TYPE##8*)((ARG2_TYPE*)y+8))); \
+  DECLSPEC RET_TYPE##16 FUNCTION(ARG1_TYPE##16 x, ADDR_SPACE ARG2_TYPE##16 *y) 
{ \
+return (RET_TYPE##16)( \
+FUNCTION(x.lo, (ARG2_TYPE##8*)y), \
+FUNCTION(x.hi, (ADDR_SPACE ARG2_TYPE##8*)((ADDR_SPACE ARG2_TYPE*)y+8)) 
\
+); \
   }
 
 #define _CLC_DEFINE_BINARY_BUILTIN(RET_TYPE, FUNCTION, BUILTIN, ARG1_TYPE, 
ARG2_TYPE) \


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


[libclc] r281565 - math: Implement lgamma

2016-09-14 Thread Aaron Watry via cfe-commits
Author: awatry
Date: Wed Sep 14 19:17:31 2016
New Revision: 281565

URL: http://llvm.org/viewvc/llvm-project?rev=281565&view=rev
Log:
math: Implement lgamma

Just use lgamma_r and ignore the value returned in the second argument

Signed-off-by: Aaron Watry 
Reviewed-by: Tom Stellard 

Added:
libclc/trunk/generic/include/clc/math/lgamma.h
libclc/trunk/generic/include/clc/math/lgamma.inc
libclc/trunk/generic/lib/math/lgamma.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=281565&r1=281564&r2=281565&view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Wed Sep 14 19:17:31 2016
@@ -69,6 +69,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Added: libclc/trunk/generic/include/clc/math/lgamma.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/lgamma.h?rev=281565&view=auto
==
--- libclc/trunk/generic/include/clc/math/lgamma.h (added)
+++ libclc/trunk/generic/include/clc/math/lgamma.h Wed Sep 14 19:17:31 2016
@@ -0,0 +1,2 @@
+#define __CLC_BODY 
+#include 

Added: libclc/trunk/generic/include/clc/math/lgamma.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/lgamma.inc?rev=281565&view=auto
==
--- libclc/trunk/generic/include/clc/math/lgamma.inc (added)
+++ libclc/trunk/generic/include/clc/math/lgamma.inc Wed Sep 14 19:17:31 2016
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE lgamma(__CLC_GENTYPE a);

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=281565&r1=281564&r2=281565&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Wed Sep 14 19:17:31 2016
@@ -97,6 +97,7 @@ math/hypot.cl
 math/ilogb.cl
 math/clc_ldexp.cl
 math/ldexp.cl
+math/lgamma.cl
 math/lgamma_r.cl
 math/log.cl
 math/log10.cl

Added: libclc/trunk/generic/lib/math/lgamma.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/lgamma.cl?rev=281565&view=auto
==
--- libclc/trunk/generic/lib/math/lgamma.cl (added)
+++ libclc/trunk/generic/lib/math/lgamma.cl Wed Sep 14 19:17:31 2016
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2016 Aaron Watry 
+ * 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 "../clcmacro.h"
+
+_CLC_OVERLOAD _CLC_DEF float lgamma(float x) {
+int s;
+return lgamma_r(x, &s);
+}
+
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, lgamma, float)
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+_CLC_OVERLOAD _CLC_DEF double lgamma(double x) {
+int s;
+return lgamma_r(x, &s);
+}
+
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, lgamma, double)
+
+#endif
\ No newline at end of file


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


[libclc] r281564 - math: Implement lgamma_r

2016-09-14 Thread Aaron Watry via cfe-commits
Author: awatry
Date: Wed Sep 14 19:17:28 2016
New Revision: 281564

URL: http://llvm.org/viewvc/llvm-project?rev=281564&view=rev
Log:
math: Implement lgamma_r

Ported from the amd-builtins branch, which is itself based on the
Sun Microsystems implementation.

Signed-off-by: Aaron Watry 
Reviewed-by: Tom Stellard 

Added:
libclc/trunk/generic/include/clc/math/lgamma_r.h
libclc/trunk/generic/include/clc/math/lgamma_r.inc
libclc/trunk/generic/lib/math/lgamma_r.cl
libclc/trunk/generic/lib/math/lgamma_r.inc
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=281564&r1=281563&r2=281564&view=diff
==
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Wed Sep 14 19:17:28 2016
@@ -69,6 +69,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Added: libclc/trunk/generic/include/clc/math/lgamma_r.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/lgamma_r.h?rev=281564&view=auto
==
--- libclc/trunk/generic/include/clc/math/lgamma_r.h (added)
+++ libclc/trunk/generic/include/clc/math/lgamma_r.h Wed Sep 14 19:17:28 2016
@@ -0,0 +1,2 @@
+#define __CLC_BODY 
+#include 

Added: libclc/trunk/generic/include/clc/math/lgamma_r.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/lgamma_r.inc?rev=281564&view=auto
==
--- libclc/trunk/generic/include/clc/math/lgamma_r.inc (added)
+++ libclc/trunk/generic/include/clc/math/lgamma_r.inc Wed Sep 14 19:17:28 2016
@@ -0,0 +1,3 @@
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE lgamma_r(__CLC_GENTYPE x, global 
__CLC_INTN *iptr);
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE lgamma_r(__CLC_GENTYPE x, local 
__CLC_INTN *iptr);
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE lgamma_r(__CLC_GENTYPE x, private 
__CLC_INTN *iptr);

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=281564&r1=281563&r2=281564&view=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Wed Sep 14 19:17:28 2016
@@ -97,6 +97,7 @@ math/hypot.cl
 math/ilogb.cl
 math/clc_ldexp.cl
 math/ldexp.cl
+math/lgamma_r.cl
 math/log.cl
 math/log10.cl
 math/log1p.cl

Added: libclc/trunk/generic/lib/math/lgamma_r.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/lgamma_r.cl?rev=281564&view=auto
==
--- libclc/trunk/generic/lib/math/lgamma_r.cl (added)
+++ libclc/trunk/generic/lib/math/lgamma_r.cl Wed Sep 14 19:17:28 2016
@@ -0,0 +1,11 @@
+#include 
+
+#include "../clcmacro.h"
+#include "math.h"
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#endif
+
+#define __CLC_BODY 
+#include 

Added: libclc/trunk/generic/lib/math/lgamma_r.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/lgamma_r.inc?rev=281564&view=auto
==
--- libclc/trunk/generic/lib/math/lgamma_r.inc (added)
+++ libclc/trunk/generic/lib/math/lgamma_r.inc Wed Sep 14 19:17:28 2016
@@ -0,0 +1,500 @@
+/*
+ * Copyright (c) 2014 Advanced Micro Devices, Inc.
+ * Copyright (c) 2016 Aaron Watry 
+ *
+ * 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.
+ */
+
+#if __CLC_FPSIZE == 32
+#ifdef __CLC_SCALAR
+/*
+ * 
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * 

Re: [libcxx] r280944 - Added 'inline' attribute to basic_string's destructor

2016-09-14 Thread Eric Fiselier via cfe-commits
FYI I had to revert this in r281562 because of:

* http://llvm.org/PR30341 which breaks the LLVM build.
* http://llvm.org/PR30391 which breaks ABI compatibility when libc++.so is
compiled with GCC.

I'm working on fixing these issues so that this patch may be recommitted.
The GCC issue
also made worse by r278356 but I don't think we need to revert it (at least
right now).

/Eric



On Thu, Sep 8, 2016 at 8:31 AM, Aditya Kumar via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: hiraditya
> Date: Thu Sep  8 09:31:44 2016
> New Revision: 280944
>
> URL: http://llvm.org/viewvc/llvm-project?rev=280944&view=rev
> Log:
> Added 'inline' attribute to basic_string's destructor
>
> Author: laxmansole
>
> Reviewers: howard.hinnant
>mclow.lists
> Subscribers: EricWF, flyingforyou, evandro
>
> Differential Revision: https://reviews.llvm.org/D22834
>
> Currently basic_string's destructor is not getting inlined. So adding
> 'inline' attribute to ~basic_string().
> Worked in collaboration with Aditya Kumar.
>
> Modified:
> libcxx/trunk/include/string
>
> Modified: libcxx/trunk/include/string
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/
> string?rev=280944&r1=280943&r2=280944&view=diff
> 
> ==
> --- libcxx/trunk/include/string (original)
> +++ libcxx/trunk/include/string Thu Sep  8 09:31:44 2016
> @@ -1798,6 +1798,7 @@ basic_string<_CharT, _Traits, _Allocator
>  #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
>
>  template 
> +inline _LIBCPP_INLINE_VISIBILITY
>  basic_string<_CharT, _Traits, _Allocator>::~basic_string()
>  {
>  #if _LIBCPP_DEBUG_LEVEL >= 2
>
>
> ___
> 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] r281562 - Revert r280944 - Added 'inline' attribute to basic_string's destructor

2016-09-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Sep 14 18:52:01 2016
New Revision: 281562

URL: http://llvm.org/viewvc/llvm-project?rev=281562&view=rev
Log:
Revert r280944 - Added 'inline' attribute to basic_string's destructor

This patch causes a couple of issues:

1) It triggers http://llvm.org/PR30341. Although the bug is not truly a libc++
bug it breaks the LLVM build using libc++. Reverting this patch is only
a temporary workaround until Clang is fixed.

2) It adds yet another ABI incompatibility when libc++.so is compiled with GCC.
Specifically GCC doesn't ignore the _LIBCPP_INLINE_VISIBILITY on the out-of-line
definition when compiling the dylib. This causes the externally instantiated
~basic_string symbol to have hidden visibility.

This patch should be recommitted after addressing (1) and (2). (2) can be fixed
by adding _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY which is defined as
__attribute__((visibility("default"), always_inline)) as opposed to
_LIBCPP_INLINE_VISIBILITY which makes the symbol hidden.



Modified:
libcxx/trunk/include/string

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=281562&r1=281561&r2=281562&view=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Wed Sep 14 18:52:01 2016
@@ -1798,7 +1798,6 @@ basic_string<_CharT, _Traits, _Allocator
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
 basic_string<_CharT, _Traits, _Allocator>::~basic_string()
 {
 #if _LIBCPP_DEBUG_LEVEL >= 2


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


Re: [PATCH] D23765: Fix for clang PR 29087

2016-09-14 Thread Taewook Oh via cfe-commits
twoh added a comment.

Ping.


https://reviews.llvm.org/D23765



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


r281557 - Revert r281457 "Supports adding insertion around non-insertion replacements."

2016-09-14 Thread Artem Belevich via cfe-commits
Author: tra
Date: Wed Sep 14 18:03:06 2016
New Revision: 281557

URL: http://llvm.org/viewvc/llvm-project?rev=281557&view=rev
Log:
Revert r281457 "Supports adding insertion around non-insertion replacements."

Commit was breaking our internal tests.

Modified:
cfe/trunk/include/clang/Tooling/Core/Replacement.h
cfe/trunk/lib/Tooling/Core/Replacement.cpp
cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Modified: cfe/trunk/include/clang/Tooling/Core/Replacement.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/Replacement.h?rev=281557&r1=281556&r2=281557&view=diff
==
--- cfe/trunk/include/clang/Tooling/Core/Replacement.h (original)
+++ cfe/trunk/include/clang/Tooling/Core/Replacement.h Wed Sep 14 18:03:06 2016
@@ -158,18 +158,14 @@ class Replacements {
 
   /// \brief Adds a new replacement \p R to the current set of replacements.
   /// \p R must have the same file path as all existing replacements.
-  /// Returns `success` if the replacement is successfully inserted; otherwise,
+  /// Returns true if the replacement is successfully inserted; otherwise,
   /// it returns an llvm::Error, i.e. there is a conflict between R and the
-  /// existing replacements (i.e. they are order-dependent) or R's file path is
-  /// different from the filepath of existing replacements. Callers must
-  /// explicitly check the Error returned. This prevents users from adding
-  /// order-dependent replacements. To control the order in which
-  /// order-dependent replacements are applied, use merge({R}) with R referring
-  /// to the changed code after applying all existing replacements.
-  /// Two replacements are considered order-independent if they:
-  ///   - don't overlap (being directly adjacent is fine) and
-  ///   - aren't both inserts at the same code location (would be
-  /// order-dependent).
+  /// existing replacements or R's file path is different from the filepath of
+  /// existing replacements. Callers must explicitly check the Error returned.
+  /// This prevents users from adding order-dependent replacements. To control
+  /// the order in which order-dependent replacements are applied, use
+  /// merge({R}) with R referring to the changed code after applying all
+  /// existing replacements.
   /// Replacements with offset UINT_MAX are special - we do not detect 
conflicts
   /// for such replacements since users may add them intentionally as a special
   /// category of replacements.

Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Replacement.cpp?rev=281557&r1=281556&r2=281557&view=diff
==
--- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
+++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Wed Sep 14 18:03:06 2016
@@ -137,14 +137,6 @@ void Replacement::setFromSourceRange(con
 ReplacementText);
 }
 
-llvm::Error makeConflictReplacementsError(const Replacement &New,
-  const Replacement &Existing) {
-  return llvm::make_error(
-  "New replacement:\n" + New.toString() +
-  "\nconflicts with existing replacement:\n" + Existing.toString(),
-  llvm::inconvertibleErrorCode());
-}
-
 llvm::Error Replacements::add(const Replacement &R) {
   // Check the file path.
   if (!Replaces.empty() && R.getFilePath() != Replaces.begin()->getFilePath())
@@ -171,22 +163,11 @@ llvm::Error Replacements::add(const Repl
   // entries that start at the end can still be conflicting if R is an
   // insertion.
   auto I = Replaces.lower_bound(AtEnd);
-  // If `I` starts at the same offset as `R`, `R` must be an insertion.
-  if (I != Replaces.end() && R.getOffset() == I->getOffset()) {
-assert(R.getLength() == 0);
-// `I` is also an insertion, `R` and `I` conflict.
-if (I->getLength() == 0)
-  return makeConflictReplacementsError(R, *I);
-// Insertion `R` is adjacent to a non-insertion replacement `I`, so they
-// are order-independent. It is safe to assume that `R` will not conflict
-// with any replacement before `I` since all replacements before `I` must
-// either end before `R` or end at `R` but has length > 0 (if the
-// replacement before `I` is an insertion at `R`, it would have been `I`
-// since it is a lower bound of `AtEnd` and ordered before the current `I`
-// in the set).
-Replaces.insert(R);
-return llvm::Error::success();
-  }
+  // If it starts at the same offset as R (can only happen if R is an
+  // insertion), we have a conflict.  In that case, increase I to fall through
+  // to the conflict check.
+  if (I != Replaces.end() && R.getOffset() == I->getOffset())
+++I;
 
   // I is the smallest iterator whose entry cannot overlap.
   // If that is begin(), there are no overlaps.
@@ -197,19 +178,16 @@ llvm::Err

Re: [PATCH] D24590: [test-suite] [CUDA] Update README.

2016-09-14 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281552: [test-suite] [CUDA] Update README. (authored by 
jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D24590?vs=71445&id=71457#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24590

Files:
  test-suite/trunk/External/CUDA/README

Index: test-suite/trunk/External/CUDA/README
===
--- test-suite/trunk/External/CUDA/README
+++ test-suite/trunk/External/CUDA/README
@@ -48,14 +48,17 @@
   $ PATH=$CLANG_DIR/bin:$PATH CXX=clang++ CC=clang \
 cmake -G Ninja -DTEST_SUITE_EXTERNALS_DIR=$EXTERNALS $TEST_SUITE_DIR
   $ ninja cuda-tests-all
-  $ lit -j1 Externals/CUDA
+  $ lit -j1 External/CUDA
 
   When you run cmake, it should say "Found CUDA prerequisites $CUDA_EXTERNALS",
   followed by "Found cuda X.Y" and "Found GCC X.Y.Z" for each version you've
   installed.
 
-  For convenience there are top-level targets that build only one particular
-  variant of the tests:
+  There's a cuda-tests-simple target that excludes tests that take a long time
+  to build (Thrust), and cuda-tests-thrust builds only Thrust.
+
+  There are also top-level targets that build only one particular variant of 
the
+  tests:
 
 cuda-tests-
 
@@ -66,3 +69,6 @@
 -
 
   E.g: thrust-cuda-7.5-c++98-libstdc++-4.9.3 OR axpy-cuda-7.0-c++11-libc++
+
+  `ninja help | grep cuda` will show all the targets, for your copy/pasting
+  pleasure.


Index: test-suite/trunk/External/CUDA/README
===
--- test-suite/trunk/External/CUDA/README
+++ test-suite/trunk/External/CUDA/README
@@ -48,14 +48,17 @@
   $ PATH=$CLANG_DIR/bin:$PATH CXX=clang++ CC=clang \
 cmake -G Ninja -DTEST_SUITE_EXTERNALS_DIR=$EXTERNALS $TEST_SUITE_DIR
   $ ninja cuda-tests-all
-  $ lit -j1 Externals/CUDA
+  $ lit -j1 External/CUDA
 
   When you run cmake, it should say "Found CUDA prerequisites $CUDA_EXTERNALS",
   followed by "Found cuda X.Y" and "Found GCC X.Y.Z" for each version you've
   installed.
 
-  For convenience there are top-level targets that build only one particular
-  variant of the tests:
+  There's a cuda-tests-simple target that excludes tests that take a long time
+  to build (Thrust), and cuda-tests-thrust builds only Thrust.
+
+  There are also top-level targets that build only one particular variant of the
+  tests:
 
 cuda-tests-
 
@@ -66,3 +69,6 @@
 -
 
   E.g: thrust-cuda-7.5-c++98-libstdc++-4.9.3 OR axpy-cuda-7.0-c++11-libc++
+
+  `ninja help | grep cuda` will show all the targets, for your copy/pasting
+  pleasure.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24590: [test-suite] [CUDA] Update README.

2016-09-14 Thread Justin Lebar via cfe-commits
jlebar marked an inline comment as done.
jlebar added a comment.

Will add.  Thank you for the reviews!


https://reviews.llvm.org/D24590



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


r281550 - [clang-cl] Accept the joined equals version of -resource-dir=

2016-09-14 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Wed Sep 14 17:31:24 2016
New Revision: 281550

URL: http://llvm.org/viewvc/llvm-project?rev=281550&view=rev
Log:
[clang-cl] Accept the joined equals version of -resource-dir=

lib/Tooling injects this argument without regard for what driver syntax
is in use.

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=281550&r1=281549&r2=281550&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Sep 14 17:31:24 2016
@@ -1860,7 +1860,7 @@ def rdynamic : Flag<["-"], "rdynamic">;
 def resource_dir : Separate<["-"], "resource-dir">,
   Flags<[DriverOption, CC1Option, CoreOption, HelpHidden]>,
   HelpText<"The directory which holds the compiler resource files">;
-def resource_dir_EQ : Joined<["-"], "resource-dir=">, Flags<[DriverOption]>,
+def resource_dir_EQ : Joined<["-"], "resource-dir=">, Flags<[DriverOption, 
CoreOption]>,
   Alias;
 def rpath : Separate<["-"], "rpath">, Flags<[LinkerInput]>;
 def rtlib_EQ : Joined<["-", "--"], "rtlib=">,

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=281550&r1=281549&r2=281550&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Wed Sep 14 17:31:24 2016
@@ -515,7 +515,8 @@
 // RUN: -fms-extensions \
 // RUN: -fno-ms-extensions \
 // RUN: -mllvm -disable-llvm-optzns \
-// RUN: -resource-dir \
+// RUN: -resource-dir asdf \
+// RUN: -resource-dir=asdf \
 // RUN: -Wunused-variable \
 // RUN: -fmacro-backtrace-limit=0 \
 // RUN: -fstandalone-debug \


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


Re: [PATCH] D24590: [test-suite] [CUDA] Update README.

2016-09-14 Thread Artem Belevich via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM



Comment at: External/CUDA/README:58
@@ +57,3 @@
+  There's a cuda-tests-simple target that excludes tests that take a long time
+  to build (thrust).
+

It may be worth adding that we now also have `cuda-tests-thrust` which compiles 
all thrust variants.



https://reviews.llvm.org/D24590



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


Re: [PATCH] D24589: [test-suite] [CUDA] Add and tests.

2016-09-14 Thread Artem Belevich via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D24589



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


Re: [PATCH] D23921: Remove va_start diagnostic false positive with enumerations

2016-09-14 Thread Richard Smith via cfe-commits
LGTM

On 14 Sep 2016 2:36 pm, "Dimitry Andric"  wrote:

dim added a comment.

FWIW, I have already imported this fix into FreeBSD two weeks ago:
https://svnweb.freebsd.org/changeset/base/304960
It has been working fine for us.


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


Re: [PATCH] D22057: Prevent devirtualization of calls to un-instantiated functions.

2016-09-14 Thread Sunil Srivastava via cfe-commits
Sunil_Srivastava updated this revision to Diff 71432.
Sunil_Srivastava added a comment.

This is an update to address points raised by Richard Smith:

1. The bit and the access functions have been renamed from 
MarkedForPendingInstantiation to InstantiationIsPending.
2. It closely, though not entirely, tracks whether the function is on the 
PendingInstantiations list. More on this point below.
3. The test explicitly allows devirtualization if Function->isDefined(). This 
is also needed by the change in point 2 above.
4. The test has been enhanced to have PCH tests.

Now: Why the InstantiationIsPending bit is not precisely tracking the presence 
in the PendingInstantiations list?

Basically this is because I think that the call to Func2 in the test SHOULD get 
devirtualized. Func2 is not defined in this TU, an uncommon but possible 
situation. Given that, the compiler had no way to instantiate it, and it is a 
user error if Func2 does not get instantiated somewhere else. If Func2 does get 
instantiated somewhere else, then it is safe to devirtualize calls to it.

In contrast, operator[] is defined by the user, but for some reason (which will 
be removed by my next checkin, in situations we know of) the compiler has 
decided to not instantiate it (or rather, not decided to instantiate it, to be 
precise). In this case we do not want to devirtualize call to it, because the 
definition is not required to exist somewhere else. The whole motivation of 
this commit is to prevent such calls from devirtualization.

The instantiation loop removes items from the PendingInstantiations list and 
instantiates them, if the body is present. In the case of Func2, the body is 
not present, the function has already been removed from the list, yet it is not 
isDefined(). We need some way to distinguish this from the contrasting case of 
operator[], where the function was never put on the PendingInstantiations list. 
Hence in cases like Func2, I am not unsetting the InstantiationIsPending bit at 
the time of its removal from the list. Loosely speaking, we can say that the 
instantiation is indeed pending, though in some other TU.

Comments in Decls.h explain this behavior, though not in such details.

The expected behavior of the test will change by my next “first fix” commit, of 
course; in that the operator[] will get instantiated, and the call will be 
devirtualized.


https://reviews.llvm.org/D22057

Files:
  include/clang/AST/Decl.h
  lib/CodeGen/CGClass.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CodeGen/no-devirt.cpp

Index: test/CodeGen/no-devirt.cpp
===
--- test/CodeGen/no-devirt.cpp
+++ test/CodeGen/no-devirt.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 %s -DUSEIT -triple %itanium_abi_triple -emit-llvm -o - |  FileCheck %s
+
+// Test with decls and template defs in pch, and just use in .cpp
+// RUN:  %clang_cc1 %s -DTMPL_DEF_IN_HEADER -triple %itanium_abi_triple -emit-pch -o %t
+// RUN:  %clang_cc1 %s -DTMPL_DEF_IN_HEADER -DUSEIT -triple %itanium_abi_triple -include-pch %t -emit-llvm -o - | FileCheck %s
+
+// Test with A in pch, and B and C in main
+// Test with just decls in pch, and template defs and use in .cpp
+// RUN:  %clang_cc1 %s -triple %itanium_abi_triple -emit-pch -o %t
+// RUN:  %clang_cc1 %s -DUSEIT -triple %itanium_abi_triple -include-pch %t -emit-llvm -o - | FileCheck %s
+
+#ifndef HEADER
+#define HEADER
+template < typename T, int N = 0 > class TmplWithArray {
+public:
+  virtual T& operator [] (int idx);
+  virtual T& func1 (int idx);
+  virtual T& func2 (int idx);
+  T ar[N+1];
+};
+struct Wrapper {
+  TmplWithArray data;
+  bool indexIt(int a) {
+if (a > 6) return data[a] ;  // Should not devirtualize
+if (a > 4) return data.func1(a); // Should devirtualize
+return data.func2(a);// Should devirtualize
+  }
+};
+
+#ifdef TMPL_DEF_IN_HEADER
+template  T& TmplWithArray::operator[](int idx) {
+  return ar[idx];
+}
+template  T& TmplWithArray::func1(int idx) {
+  return ar[idx];
+}
+#endif // TMPL_DEF_IN_HEADER
+#endif // HEADER
+
+#ifdef USEIT
+#ifndef TMPL_DEF_IN_HEADER
+template  T& TmplWithArray::operator[](int idx) {
+  return ar[idx];
+}
+template  T& TmplWithArray::func1(int idx) {
+  return ar[idx];
+}
+#endif // !TMPL_DEF_IN_HEADER
+extern Wrapper ew;
+bool stuff(int p)
+{
+  return ew.indexIt(p);
+}
+#endif
+
+// CHECK-NOT: call {{.*}} @_ZN13TmplWithArrayIbLi10EEixEi
+// CHECK-DAG: call {{.*}} @_ZN13TmplWithArrayIbLi10EE5func1Ei
+// CHECK-DAG: call {{.*}} @_ZN13TmplWithArrayIbLi10EE5func2Ei
+
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3580,6 +3580,7 @@
   // Try again at the end of the translation unit (at which point a
   // definition will be required).
   assert(!Recursive);

Re: [PATCH] D24513: [AMDGPU] Expose flat work group size, register and wave control attributes

2016-09-14 Thread Konstantin Zhuravlyov via cfe-commits
kzhuravl added inline comments.


Comment at: include/clang/Basic/Attr.td:1067
@@ +1066,3 @@
+  let Spellings = [GNU<"amdgpu_waves_per_eu">];
+  let Args = [UnsignedArgument<"Min">, VariadicUnsignedArgument<"Max">];
+  let Documentation = [AMDGPUWavesPerEUDocs];

aaron.ballman wrote:
> Looking at the documentation, are you sure this should be a 
> `VariadicUnsignedArgument`? It seems like this should be an 
> `UnsignedArgument` with the optional bit set. Or can you pass multiple Max 
> values?
You are right. Switched to UnsignedArgument since only one Max is allowed. 
Thanks.


Comment at: lib/Sema/SemaDeclAttr.cpp:6048
@@ -5976,2 +6047,3 @@
   D->setInvalidDecl();
-} else if (Attr *A = D->getAttr()) {
+} else if (Attr *A = D->getAttr()) {
+  Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)

aaron.ballman wrote:
> This list is getting to the point where we really need to start handling this 
> in Attr.td soon. Are you planning to work on more AMDGPU attributes in the 
> near future?
I agree, and yes, few more attributes will need to be added in the near future. 
Would it be ok if I change it to start handling in Attr.td after this change, 
but before other attributes are added?


https://reviews.llvm.org/D24513



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


Re: [PATCH] D24513: [AMDGPU] Expose flat work group size, register and wave control attributes

2016-09-14 Thread Konstantin Zhuravlyov via cfe-commits
kzhuravl updated this revision to Diff 71449.
kzhuravl marked 15 inline comments as done.
kzhuravl added a comment.

Address review feedback


https://reviews.llvm.org/D24513

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenOpenCL/amdgpu-attrs.cl
  test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
  test/SemaCUDA/amdgpu-attrs.cu
  test/SemaCUDA/amdgpu-num-gpr-attr.cu
  test/SemaOpenCL/amdgpu-attrs.cl
  test/SemaOpenCL/amdgpu-num-register-attrs.cl

Index: test/SemaOpenCL/amdgpu-num-register-attrs.cl
===
--- test/SemaOpenCL/amdgpu-num-register-attrs.cl
+++ test/SemaOpenCL/amdgpu-num-register-attrs.cl
@@ -1,40 +0,0 @@
-// RUN: %clang_cc1 -triple r600-- -verify -fsyntax-only %s
-
-typedef __attribute__((amdgpu_num_vgpr(128))) struct FooStruct { // expected-error {{'amdgpu_num_vgpr' attribute only applies to kernel functions}}
-  int x;
-  float y;
-} FooStruct;
-
-
-__attribute__((amdgpu_num_vgpr("ABC"))) kernel void foo2() {} // expected-error {{'amdgpu_num_vgpr' attribute requires an integer constant}}
-__attribute__((amdgpu_num_sgpr("ABC"))) kernel void foo3() {} // expected-error {{'amdgpu_num_sgpr' attribute requires an integer constant}}
-
-
-__attribute__((amdgpu_num_vgpr(40))) void foo4() {} // expected-error {{'amdgpu_num_vgpr' attribute only applies to kernel functions}}
-__attribute__((amdgpu_num_sgpr(64))) void foo5() {} // expected-error {{'amdgpu_num_sgpr' attribute only applies to kernel functions}}
-
-__attribute__((amdgpu_num_vgpr(40))) kernel void foo7() {}
-__attribute__((amdgpu_num_sgpr(64))) kernel void foo8() {}
-__attribute__((amdgpu_num_vgpr(40), amdgpu_num_sgpr(64))) kernel void foo9() {}
-
-// Check 0 VGPR is accepted.
-__attribute__((amdgpu_num_vgpr(0))) kernel void foo10() {}
-
-// Check 0 SGPR is accepted.
-__attribute__((amdgpu_num_sgpr(0))) kernel void foo11() {}
-
-// Check both 0 SGPR and VGPR is accepted.
-__attribute__((amdgpu_num_vgpr(0), amdgpu_num_sgpr(0))) kernel void foo12() {}
-
-// Too large VGPR value.
-__attribute__((amdgpu_num_vgpr(4294967296))) kernel void foo13() {} // expected-error {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
-
-__attribute__((amdgpu_num_sgpr(4294967296))) kernel void foo14() {} // expected-error {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
-
-__attribute__((amdgpu_num_sgpr(4294967296), amdgpu_num_vgpr(4294967296))) kernel void foo15() {} // expected-error 2 {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
-
-
-// Make sure it is accepted with kernel keyword before the attribute.
-kernel __attribute__((amdgpu_num_vgpr(40))) void foo16() {}
-
-kernel __attribute__((amdgpu_num_sgpr(40))) void foo17() {}
Index: test/SemaOpenCL/amdgpu-attrs.cl
===
--- test/SemaOpenCL/amdgpu-attrs.cl
+++ test/SemaOpenCL/amdgpu-attrs.cl
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -triple amdgcn-- -verify -fsyntax-only %s
+
+typedef __attribute__((amdgpu_flat_work_group_size(32, 64))) struct struct_flat_work_group_size_32_64 { // expected-error {{'amdgpu_flat_work_group_size' attribute only applies to kernel functions}}
+  int x;
+  float y;
+} struct_flat_work_group_size_32_64;
+typedef __attribute__((amdgpu_waves_per_eu(2))) struct struct_waves_per_eu_2 { // expected-error {{'amdgpu_waves_per_eu' attribute only applies to kernel functions}}
+  int x;
+  float y;
+} struct_waves_per_eu_2;
+typedef __attribute__((amdgpu_waves_per_eu(2, 4))) struct struct_waves_per_eu_2_4 { // expected-error {{'amdgpu_waves_per_eu' attribute only applies to kernel functions}}
+  int x;
+  float y;
+} struct_waves_per_eu_2_4;
+typedef __attribute__((amdgpu_num_sgpr(32))) struct struct_num_sgpr_32 { // expected-error {{'amdgpu_num_sgpr' attribute only applies to kernel functions}}
+  int x;
+  float y;
+} struct_num_sgpr_32;
+typedef __attribute__((amdgpu_num_vgpr(64))) struct struct_num_vgpr_64 { // expected-error {{'amdgpu_num_vgpr' attribute only applies to kernel functions}}
+  int x;
+  float y;
+} struct_num_vgpr_64;
+
+__attribute__((amdgpu_flat_work_group_size(32, 64))) void func_flat_work_group_size_32_64() {} // expected-error {{'amdgpu_flat_work_group_size' attribute only applies to kernel functions}}
+__attribute__((amdgpu_waves_per_eu(2))) void func_waves_per_eu_2() {} // expected-error {{'amdgpu_waves_per_eu' attribute only applies to kernel functions}}
+__attribute__((amdgpu_waves_per_eu(2, 4))) void func_waves_per_eu_2_4() {} // expected-error {{'amdgpu_waves_per_eu' attribute only applies to kernel functions}}
+__attribute__((amdgpu_num_sgpr(32))) void func_num_sgpr_32() {} // expected-error {{'amdg

Re: [PATCH] D24588: [CUDA] Make __clang_cuda_cmath.h compatible with libc++.

2016-09-14 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281544: [CUDA] Make __clang_cuda_cmath.h compatible with 
libc++. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D24588?vs=71443&id=71447#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24588

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

Index: cfe/trunk/lib/Headers/__clang_cuda_cmath.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_cmath.h
+++ cfe/trunk/lib/Headers/__clang_cuda_cmath.h
@@ -327,17 +327,33 @@
 using ::atanh;
 using ::cbrt;
 using ::ceil;
+using ::copysign;
 using ::cos;
 using ::cosh;
 using ::erf;
 using ::erfc;
 using ::exp;
 using ::exp2;
 using ::expm1;
 using ::fabs;
+using ::fdim;
 using ::floor;
+using ::fma;
+using ::fmax;
+using ::fmin;
+using ::fmod;
+using ::fpclassify;
 using ::frexp;
+using ::hypot;
 using ::ilogb;
+using ::isfinite;
+using ::isgreater;
+using ::isgreaterequal;
+using ::isless;
+using ::islessequal;
+using ::islessgreater;
+using ::isnormal;
+using ::isunordered;
 using ::ldexp;
 using ::lgamma;
 using ::llrint;
@@ -349,17 +365,32 @@
 using ::logb;
 using ::lrint;
 using ::lround;
+using ::nearbyint;
+using ::nextafter;
 using ::nexttoward;
 using ::pow;
+using ::remainder;
 using ::remquo;
+using ::rint;
+using ::round;
 using ::scalbln;
 using ::scalbn;
+using ::signbit;
 using ::sin;
 using ::sinh;
 using ::sqrt;
 using ::tan;
 using ::tanh;
 using ::tgamma;
+using ::trunc;
+
+// Well this is fun: We need to pull these symbols in for libc++, but we can't
+// pull them in with libstdc++, because its ::isinf and ::isnan are different
+// than its std::isinf and std::isnan.
+#ifndef __GLIBCXX__
+using ::isinf;
+using ::isnan;
+#endif
 
 // Finally, pull the "foobarf" functions that CUDA defines in its headers into
 // namespace std.


Index: cfe/trunk/lib/Headers/__clang_cuda_cmath.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_cmath.h
+++ cfe/trunk/lib/Headers/__clang_cuda_cmath.h
@@ -327,17 +327,33 @@
 using ::atanh;
 using ::cbrt;
 using ::ceil;
+using ::copysign;
 using ::cos;
 using ::cosh;
 using ::erf;
 using ::erfc;
 using ::exp;
 using ::exp2;
 using ::expm1;
 using ::fabs;
+using ::fdim;
 using ::floor;
+using ::fma;
+using ::fmax;
+using ::fmin;
+using ::fmod;
+using ::fpclassify;
 using ::frexp;
+using ::hypot;
 using ::ilogb;
+using ::isfinite;
+using ::isgreater;
+using ::isgreaterequal;
+using ::isless;
+using ::islessequal;
+using ::islessgreater;
+using ::isnormal;
+using ::isunordered;
 using ::ldexp;
 using ::lgamma;
 using ::llrint;
@@ -349,17 +365,32 @@
 using ::logb;
 using ::lrint;
 using ::lround;
+using ::nearbyint;
+using ::nextafter;
 using ::nexttoward;
 using ::pow;
+using ::remainder;
 using ::remquo;
+using ::rint;
+using ::round;
 using ::scalbln;
 using ::scalbn;
+using ::signbit;
 using ::sin;
 using ::sinh;
 using ::sqrt;
 using ::tan;
 using ::tanh;
 using ::tgamma;
+using ::trunc;
+
+// Well this is fun: We need to pull these symbols in for libc++, but we can't
+// pull them in with libstdc++, because its ::isinf and ::isnan are different
+// than its std::isinf and std::isnan.
+#ifndef __GLIBCXX__
+using ::isinf;
+using ::isnan;
+#endif
 
 // Finally, pull the "foobarf" functions that CUDA defines in its headers into
 // namespace std.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24581: [CUDA] Add test checking our ability to take a function pointer to a __global__ function on the host side.

2016-09-14 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281543: [CUDA] Add test checking our ability to take a 
function pointer to a… (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D24581?vs=71423&id=71446#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24581

Files:
  cfe/trunk/test/SemaCUDA/reference-to-kernel-fn.cu

Index: cfe/trunk/test/SemaCUDA/reference-to-kernel-fn.cu
===
--- cfe/trunk/test/SemaCUDA/reference-to-kernel-fn.cu
+++ cfe/trunk/test/SemaCUDA/reference-to-kernel-fn.cu
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only -verify -DDEVICE 
%s
+
+// Check that we can reference (get a function pointer to) a __global__
+// function from the host side, but not the device side.  (We don't yet support
+// device-side kernel launches.)
+
+#include "Inputs/cuda.h"
+
+struct Dummy {};
+
+__global__ void kernel() {}
+// expected-note@-1 {{declared here}}
+#ifdef DEVICE
+// expected-note@-3 {{declared here}}
+#endif
+
+typedef void (*fn_ptr_t)();
+
+__host__ __device__ fn_ptr_t get_ptr_hd() {
+  return kernel;
+#ifdef DEVICE
+  // expected-error@-2 {{reference to __global__ function}}
+#endif
+}
+__host__ fn_ptr_t get_ptr_h() {
+  return kernel;
+}
+__device__ fn_ptr_t get_ptr_d() {
+  return kernel;  // expected-error {{reference to __global__ function}}
+}


Index: cfe/trunk/test/SemaCUDA/reference-to-kernel-fn.cu
===
--- cfe/trunk/test/SemaCUDA/reference-to-kernel-fn.cu
+++ cfe/trunk/test/SemaCUDA/reference-to-kernel-fn.cu
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only -verify -DDEVICE %s
+
+// Check that we can reference (get a function pointer to) a __global__
+// function from the host side, but not the device side.  (We don't yet support
+// device-side kernel launches.)
+
+#include "Inputs/cuda.h"
+
+struct Dummy {};
+
+__global__ void kernel() {}
+// expected-note@-1 {{declared here}}
+#ifdef DEVICE
+// expected-note@-3 {{declared here}}
+#endif
+
+typedef void (*fn_ptr_t)();
+
+__host__ __device__ fn_ptr_t get_ptr_hd() {
+  return kernel;
+#ifdef DEVICE
+  // expected-error@-2 {{reference to __global__ function}}
+#endif
+}
+__host__ fn_ptr_t get_ptr_h() {
+  return kernel;
+}
+__device__ fn_ptr_t get_ptr_d() {
+  return kernel;  // expected-error {{reference to __global__ function}}
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r281543 - [CUDA] Add test checking our ability to take a function pointer to a __global__ function on the host side.

2016-09-14 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Sep 14 16:50:11 2016
New Revision: 281543

URL: http://llvm.org/viewvc/llvm-project?rev=281543&view=rev
Log:
[CUDA] Add test checking our ability to take a function pointer to a __global__ 
function on the host side.

Summary: This functionality is used by Thrust.

Reviewers: tra

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/SemaCUDA/reference-to-kernel-fn.cu

Added: cfe/trunk/test/SemaCUDA/reference-to-kernel-fn.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/reference-to-kernel-fn.cu?rev=281543&view=auto
==
--- cfe/trunk/test/SemaCUDA/reference-to-kernel-fn.cu (added)
+++ cfe/trunk/test/SemaCUDA/reference-to-kernel-fn.cu Wed Sep 14 16:50:11 2016
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only -verify -DDEVICE 
%s
+
+// Check that we can reference (get a function pointer to) a __global__
+// function from the host side, but not the device side.  (We don't yet support
+// device-side kernel launches.)
+
+#include "Inputs/cuda.h"
+
+struct Dummy {};
+
+__global__ void kernel() {}
+// expected-note@-1 {{declared here}}
+#ifdef DEVICE
+// expected-note@-3 {{declared here}}
+#endif
+
+typedef void (*fn_ptr_t)();
+
+__host__ __device__ fn_ptr_t get_ptr_hd() {
+  return kernel;
+#ifdef DEVICE
+  // expected-error@-2 {{reference to __global__ function}}
+#endif
+}
+__host__ fn_ptr_t get_ptr_h() {
+  return kernel;
+}
+__device__ fn_ptr_t get_ptr_d() {
+  return kernel;  // expected-error {{reference to __global__ function}}
+}


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


r281544 - [CUDA] Make __clang_cuda_cmath.h compatible with libc++.

2016-09-14 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Sep 14 16:50:14 2016
New Revision: 281544

URL: http://llvm.org/viewvc/llvm-project?rev=281544&view=rev
Log:
[CUDA] Make __clang_cuda_cmath.h compatible with libc++.

Summary:
We need to add a bunch more "using"s, which weren't necessary with
libstdc++.

Once this is in I can check in a test to the test-suite.

Reviewers: tra

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/Headers/__clang_cuda_cmath.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_cmath.h?rev=281544&r1=281543&r2=281544&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_cmath.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_cmath.h Wed Sep 14 16:50:14 2016
@@ -327,6 +327,7 @@ using ::atan2;
 using ::atanh;
 using ::cbrt;
 using ::ceil;
+using ::copysign;
 using ::cos;
 using ::cosh;
 using ::erf;
@@ -335,9 +336,24 @@ using ::exp;
 using ::exp2;
 using ::expm1;
 using ::fabs;
+using ::fdim;
 using ::floor;
+using ::fma;
+using ::fmax;
+using ::fmin;
+using ::fmod;
+using ::fpclassify;
 using ::frexp;
+using ::hypot;
 using ::ilogb;
+using ::isfinite;
+using ::isgreater;
+using ::isgreaterequal;
+using ::isless;
+using ::islessequal;
+using ::islessgreater;
+using ::isnormal;
+using ::isunordered;
 using ::ldexp;
 using ::lgamma;
 using ::llrint;
@@ -349,17 +365,32 @@ using ::log2;
 using ::logb;
 using ::lrint;
 using ::lround;
+using ::nearbyint;
+using ::nextafter;
 using ::nexttoward;
 using ::pow;
+using ::remainder;
 using ::remquo;
+using ::rint;
+using ::round;
 using ::scalbln;
 using ::scalbn;
+using ::signbit;
 using ::sin;
 using ::sinh;
 using ::sqrt;
 using ::tan;
 using ::tanh;
 using ::tgamma;
+using ::trunc;
+
+// Well this is fun: We need to pull these symbols in for libc++, but we can't
+// pull them in with libstdc++, because its ::isinf and ::isnan are different
+// than its std::isinf and std::isnan.
+#ifndef __GLIBCXX__
+using ::isinf;
+using ::isnan;
+#endif
 
 // Finally, pull the "foobarf" functions that CUDA defines in its headers into
 // namespace std.


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


[PATCH] D24590: [test-suite] [CUDA] Update README.

2016-09-14 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added a subscriber: cfe-commits.

Fix typo (s/Externals/External/), and mention cuda-tests-simple.

https://reviews.llvm.org/D24590

Files:
  External/CUDA/README

Index: External/CUDA/README
===
--- External/CUDA/README
+++ External/CUDA/README
@@ -48,14 +48,17 @@
   $ PATH=$CLANG_DIR/bin:$PATH CXX=clang++ CC=clang \
 cmake -G Ninja -DTEST_SUITE_EXTERNALS_DIR=$EXTERNALS $TEST_SUITE_DIR
   $ ninja cuda-tests-all
-  $ lit -j1 Externals/CUDA
+  $ lit -j1 External/CUDA
 
   When you run cmake, it should say "Found CUDA prerequisites $CUDA_EXTERNALS",
   followed by "Found cuda X.Y" and "Found GCC X.Y.Z" for each version you've
   installed.
 
-  For convenience there are top-level targets that build only one particular
-  variant of the tests:
+  There's a cuda-tests-simple target that excludes tests that take a long time
+  to build (thrust).
+
+  There are also top-level targets that build only one particular variant of 
the
+  tests:
 
 cuda-tests-
 
@@ -66,3 +69,6 @@
 -
 
   E.g: thrust-cuda-7.5-c++98-libstdc++-4.9.3 OR axpy-cuda-7.0-c++11-libc++
+
+  `ninja help | grep cuda` will show all the targets, for your copy/pasting
+  pleasure.


Index: External/CUDA/README
===
--- External/CUDA/README
+++ External/CUDA/README
@@ -48,14 +48,17 @@
   $ PATH=$CLANG_DIR/bin:$PATH CXX=clang++ CC=clang \
 cmake -G Ninja -DTEST_SUITE_EXTERNALS_DIR=$EXTERNALS $TEST_SUITE_DIR
   $ ninja cuda-tests-all
-  $ lit -j1 Externals/CUDA
+  $ lit -j1 External/CUDA
 
   When you run cmake, it should say "Found CUDA prerequisites $CUDA_EXTERNALS",
   followed by "Found cuda X.Y" and "Found GCC X.Y.Z" for each version you've
   installed.
 
-  For convenience there are top-level targets that build only one particular
-  variant of the tests:
+  There's a cuda-tests-simple target that excludes tests that take a long time
+  to build (thrust).
+
+  There are also top-level targets that build only one particular variant of the
+  tests:
 
 cuda-tests-
 
@@ -66,3 +69,6 @@
 -
 
   E.g: thrust-cuda-7.5-c++98-libstdc++-4.9.3 OR axpy-cuda-7.0-c++11-libc++
+
+  `ninja help | grep cuda` will show all the targets, for your copy/pasting
+  pleasure.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24588: [CUDA] Make __clang_cuda_cmath.h compatible with libc++.

2016-09-14 Thread Artem Belevich via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D24588



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


[PATCH] D24588: [CUDA] Make __clang_cuda_cmath.h compatible with libc++.

2016-09-14 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added a subscriber: cfe-commits.

We need to add a bunch more "using"s, which weren't necessary with
libstdc++.

Once this is in I can check in a test to the test-suite.

https://reviews.llvm.org/D24588

Files:
  clang/lib/Headers/__clang_cuda_cmath.h

Index: clang/lib/Headers/__clang_cuda_cmath.h
===
--- clang/lib/Headers/__clang_cuda_cmath.h
+++ clang/lib/Headers/__clang_cuda_cmath.h
@@ -327,17 +327,33 @@
 using ::atanh;
 using ::cbrt;
 using ::ceil;
+using ::copysign;
 using ::cos;
 using ::cosh;
 using ::erf;
 using ::erfc;
 using ::exp;
 using ::exp2;
 using ::expm1;
 using ::fabs;
+using ::fdim;
 using ::floor;
+using ::fma;
+using ::fmax;
+using ::fmin;
+using ::fmod;
+using ::fpclassify;
 using ::frexp;
+using ::hypot;
 using ::ilogb;
+using ::isfinite;
+using ::isgreater;
+using ::isgreaterequal;
+using ::isless;
+using ::islessequal;
+using ::islessgreater;
+using ::isnormal;
+using ::isunordered;
 using ::ldexp;
 using ::lgamma;
 using ::llrint;
@@ -349,17 +365,32 @@
 using ::logb;
 using ::lrint;
 using ::lround;
+using ::nearbyint;
+using ::nextafter;
 using ::nexttoward;
 using ::pow;
+using ::remainder;
 using ::remquo;
+using ::rint;
+using ::round;
 using ::scalbln;
 using ::scalbn;
+using ::signbit;
 using ::sin;
 using ::sinh;
 using ::sqrt;
 using ::tan;
 using ::tanh;
 using ::tgamma;
+using ::trunc;
+
+// Well this is fun: We need to pull these symbols in for libc++, but we can't
+// pull them in with libstdc++, because its ::isinf and ::isnan are different
+// than its std::isinf and std::isnan.
+#ifndef __GLIBCXX__
+using ::isinf;
+using ::isnan;
+#endif
 
 // Finally, pull the "foobarf" functions that CUDA defines in its headers into
 // namespace std.


Index: clang/lib/Headers/__clang_cuda_cmath.h
===
--- clang/lib/Headers/__clang_cuda_cmath.h
+++ clang/lib/Headers/__clang_cuda_cmath.h
@@ -327,17 +327,33 @@
 using ::atanh;
 using ::cbrt;
 using ::ceil;
+using ::copysign;
 using ::cos;
 using ::cosh;
 using ::erf;
 using ::erfc;
 using ::exp;
 using ::exp2;
 using ::expm1;
 using ::fabs;
+using ::fdim;
 using ::floor;
+using ::fma;
+using ::fmax;
+using ::fmin;
+using ::fmod;
+using ::fpclassify;
 using ::frexp;
+using ::hypot;
 using ::ilogb;
+using ::isfinite;
+using ::isgreater;
+using ::isgreaterequal;
+using ::isless;
+using ::islessequal;
+using ::islessgreater;
+using ::isnormal;
+using ::isunordered;
 using ::ldexp;
 using ::lgamma;
 using ::llrint;
@@ -349,17 +365,32 @@
 using ::logb;
 using ::lrint;
 using ::lround;
+using ::nearbyint;
+using ::nextafter;
 using ::nexttoward;
 using ::pow;
+using ::remainder;
 using ::remquo;
+using ::rint;
+using ::round;
 using ::scalbln;
 using ::scalbn;
+using ::signbit;
 using ::sin;
 using ::sinh;
 using ::sqrt;
 using ::tan;
 using ::tanh;
 using ::tgamma;
+using ::trunc;
+
+// Well this is fun: We need to pull these symbols in for libc++, but we can't
+// pull them in with libstdc++, because its ::isinf and ::isnan are different
+// than its std::isinf and std::isnan.
+#ifndef __GLIBCXX__
+using ::isinf;
+using ::isnan;
+#endif
 
 // Finally, pull the "foobarf" functions that CUDA defines in its headers into
 // namespace std.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23921: Remove va_start diagnostic false positive with enumerations

2016-09-14 Thread Dimitry Andric via cfe-commits
dim added a comment.

FWIW, I have already imported this fix into FreeBSD two weeks ago: 
https://svnweb.freebsd.org/changeset/base/304960
It has been working fine for us.


https://reviews.llvm.org/D23921



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


Re: [PATCH] D24584: Do not warn about format strings that are indexed string literals.

2016-09-14 Thread Meike Baumgärtner via cfe-commits
meikeb updated this revision to Diff 71438.
meikeb added a comment.

Fix typos in commit message.


https://reviews.llvm.org/D24584

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/format-strings.c

Index: test/Sema/format-strings.c
===
--- test/Sema/format-strings.c
+++ test/Sema/format-strings.c
@@ -652,3 +652,38 @@
   // expected-note@-1{{treat the string as an argument to avoid this}}
 }
 #pragma GCC diagnostic warning "-Wformat-nonliteral"
+
+void test_char_pointer_arithmetic(int b) {
+  const char s1[] = "string";
+  const char s2[] = "%s string";
+
+  printf(s1 - 1);  // expected-warning {{format string is not a string literal (potentially insecure)}}
+  // expected-note@-1{{treat the string as an argument to avoid this}}
+
+  printf(s1 + 2);  // no-warning
+  printf(s2 + 2);  // no-warning
+
+  const char s3[] = "%s string";
+  printf((s3 + 2) - 2);  // expected-warning{{more '%' conversions than data arguments}}
+  // expected-note@-2{{format string is defined here}}
+  printf(2 + s2); // no-warning
+  printf(6 + s2 - 2); // no-warning
+  printf(2 + (b ? s1 : s2));  // no-warning
+
+  const char s5[] = "string %s";
+  printf(2 + (b ? s2 : s5));  // expected-warning{{more '%' conversions than data arguments}}
+  // expected-note@-2{{format string is defined here}}
+  printf(2 + (b ? s2 : s5), "");  // no-warning
+  printf(2 + (b ? s1 : s2 - 2), "");  // no-warning
+
+  const char s6[] = "%s string";
+  printf(2 + (b ? s1 : s6 - 2));  // expected-warning{{more '%' conversions than data arguments}}
+  // expected-note@-2{{format string is defined here}}
+  printf(1 ? s2 + 2 : s2);  // no-warning
+  printf(0 ? s2 : s2 + 2);  // no-warning
+  printf(2 + s2 + 5 * 3 - 16, "");  // expected-warning{{data argument not used}}
+
+  const char s7[] = "%s string %s %s";
+  printf(s7 + 3, "");  // expected-warning{{more '%' conversions than data arguments}}
+  // expected-note@-2{{format string is defined here}}
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -3839,7 +3839,95 @@
 };
 } // end anonymous namespace
 
-static void CheckFormatString(Sema &S, const StringLiteral *FExpr,
+static void sumOffsets(llvm::APSInt &Offset, llvm::APSInt Addend,
+ BinaryOperatorKind BinOpKind,
+ bool AddendIsRight) {
+  unsigned BitWidth = Offset.getBitWidth();
+  unsigned AddendBitWidth = Addend.getBitWidth();
+  // There might be negative interim results.
+  if (Addend.isUnsigned()) {
+Addend = Addend.zext(++AddendBitWidth);
+Addend.setIsSigned(true);
+  }
+  // Adjust the bit width of the APSInts.
+  if (AddendBitWidth > BitWidth) {
+Offset = Offset.sext(AddendBitWidth);
+BitWidth = AddendBitWidth;
+  } else if (BitWidth > AddendBitWidth) {
+Addend = Addend.sext(BitWidth);
+  }
+
+  bool Ov = false;
+  llvm::APSInt ResOffset = Offset;
+  if (BinOpKind == BO_Add)
+ResOffset = Offset.sadd_ov(Addend, Ov);
+  else {
+assert(AddendIsRight && BinOpKind == BO_Sub &&
+   "operator must be add or sub with addend on the right");
+ResOffset = Offset.ssub_ov(Addend, Ov);
+  }
+
+  // We add an offset to a pointer here so we should support an offset as big as
+  // possible.
+  if (Ov) {
+assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");
+Offset.sext(2 * BitWidth);
+sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
+return;
+  }
+
+  Offset = ResOffset;
+}
+
+namespace {
+// This is a wrapper class around StringLiteral to support offsetted string
+// literals as format strings. It takes the offset into account when returning
+// the string and its length or the source locations to display notes correctly.
+class FormatStringLiteral {
+  const StringLiteral *FExpr;
+  int64_t Offset;
+
+ public:
+  FormatStringLiteral(const StringLiteral *fexpr, int64_t Offset = 0)
+  : FExpr(fexpr), Offset(Offset) {}
+
+  StringRef getString() const {
+return FExpr->getString().drop_front(Offset);
+  }
+
+  unsigned getByteLength() const {
+return FExpr->getByteLength() - getCharByteWidth() * Offset;
+  }
+  unsigned getLength() const { return FExpr->getLength() - Offset; }
+  unsigned getCharByteWidth() const { return FExpr->getCharByteWidth(); }
+
+  StringLiteral::StringKind getKind() const { return FExpr->getKind(); }
+
+  QualType getType() const { return FExpr->getType(); }
+
+  bool isAscii() const { return FExpr->isAscii(); }
+  bool isWide() const { return FExpr->isWide(); }
+  bool isUTF8() const { return FExpr->isUTF8(); }
+  bool isUTF16() const { return FExpr->isUTF16(); }
+  bool isUTF32() const { return FExpr->isUTF32(); }
+  bool isPascal() const { return FExpr->isPascal(); }
+
+  SourceLocation getLocationOfByte(
+  unsigned ByteNo, const SourceManager &SM, const L

Re: [PATCH] D24584: Do not warn about format strings that are indexed string literals.

2016-09-14 Thread Meike Baumgärtner via cfe-commits
meikeb added a comment.

This is the same as https://reviews.llvm.org/D23820 besides that I added myself 
in the commit message as "Patch by". https://reviews.llvm.org/D23820 was 
reverted in https://reviews.llvm.org/D24579 because srhines' commit took 
authorship of this patch.


https://reviews.llvm.org/D24584



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


r281540 - Add some MS aliases for existing intrinsics

2016-09-14 Thread Albert Gutowski via cfe-commits
Author: agutowski
Date: Wed Sep 14 16:19:43 2016
New Revision: 281540

URL: http://llvm.org/viewvc/llvm-project?rev=281540&view=rev
Log:
Add some MS aliases for existing intrinsics

Reviewers: thakis, compnerd, majnemer, rsmith, rnk

Subscribers: alexshap, cfe-commits

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

Added:
cfe/trunk/test/Headers/x86intrin.cpp
cfe/trunk/test/Sema/implicit-intel-builtin-decl.c
cfe/trunk/test/Sema/implicit-ms-builtin-decl.c
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/include/clang/Basic/Builtins.h
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/emmintrin.h
cfe/trunk/lib/Headers/ia32intrin.h
cfe/trunk/lib/Headers/intrin.h
cfe/trunk/lib/Headers/xmmintrin.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CodeGen/builtins-x86.c

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=281540&r1=281539&r2=281540&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Wed Sep 14 16:19:43 2016
@@ -74,6 +74,7 @@
 //  f -> this is a libc/libm function without the '__builtin_' prefix. It can
 //   be followed by ':headername:' to state which header this function
 //   comes from.
+//  h -> this function requires a specific header or an explicit declaration.
 //  i -> this is a runtime library implemented function without the
 //   '__builtin_' prefix. It will be implemented in compiler-rt or libgcc.
 //  p:N: -> this is a printf-like function whose Nth argument is the format
@@ -708,6 +709,9 @@ BUILTIN(__builtin_rindex, "c*cC*i", "Fn"
 // Microsoft builtins.  These are only active with -fms-extensions.
 LANGBUILTIN(_alloca,  "v*z", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__assume, "vb",  "n", ALL_MS_LANGUAGES)
+LIBBUILTIN(_byteswap_ushort, "UsUs", "fnc", "stdlib.h", ALL_MS_LANGUAGES)
+LIBBUILTIN(_byteswap_ulong,  "ULiULi",   "fnc", "stdlib.h", ALL_MS_LANGUAGES)
+LIBBUILTIN(_byteswap_uint64, "ULLiULLi", "fnc", "stdlib.h", ALL_MS_LANGUAGES)
 LANGBUILTIN(__debugbreak, "v",   "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__exception_code, "ULi", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_exception_code,  "ULi", "n", ALL_MS_LANGUAGES)
@@ -745,6 +749,9 @@ LANGBUILTIN(_InterlockedXor8,  "ccD*c",
 LANGBUILTIN(_InterlockedXor16, "ssD*s",   "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedXor,   "LiLiD*Li","n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__noop,   "i.",  "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__popcnt16, "UsUs", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__popcnt,   "UiUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__popcnt64, "ULLiULLi", "nc", ALL_MS_LANGUAGES)
 LANGBUILTIN(__readfsdword,"ULiULi", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_rotl8,  "UcUcUc","n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_rotl16, "UsUsUc","n", ALL_MS_LANGUAGES)

Modified: cfe/trunk/include/clang/Basic/Builtins.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=281540&r1=281539&r2=281540&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.h (original)
+++ cfe/trunk/include/clang/Basic/Builtins.h Wed Sep 14 16:19:43 2016
@@ -139,6 +139,13 @@ public:
 return strchr(getRecord(ID).Attributes, 'f') != nullptr;
   }
 
+  /// \brief Returns true if this builtin requires appropriate header in other
+  /// compilers. In Clang it will work even without including it, but we can 
emit
+  /// a warning about missing header.
+  bool isHeaderDependentFunction(unsigned ID) const {
+return strchr(getRecord(ID).Attributes, 'h') != nullptr;
+  }
+
   /// \brief Determines whether this builtin is a predefined compiler-rt/libgcc
   /// function, such as "__clear_cache", where we know the signature a
   /// priori.

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=281540&r1=281539&r2=281540&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Sep 14 16:19:43 2016
@@ -23,6 +23,10 @@
 #   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
 #endif
 
+#if defined(BUILTIN) && !defined(TARGET_HEADER_BUILTIN)
+#  define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANG, FEATURE) 
BUILTIN(ID, TYPE, ATTRS)
+#endif
+
 // FIXME: Are these nothrow/const?
 
 // Miscellaneous builtin for checking x86 cpu features.
@@ -301,7 +305,9 @@ TARGET_BUILTIN(__builtin_ia32_pabsw128,
 TARGET_BUILTIN(__builtin_ia32_pabsd128, "V4iV4i", "", "ssse3")
 
 TARGET_BU

Re: [PATCH] D24330: Add some MS aliases for existing intrinsics

2016-09-14 Thread Albert Gutowski via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281540: Add some MS aliases for existing intrinsics 
(authored by agutowski).

Changed prior to commit:
  https://reviews.llvm.org/D24330?vs=71404&id=71437#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24330

Files:
  cfe/trunk/include/clang/Basic/Builtins.def
  cfe/trunk/include/clang/Basic/Builtins.h
  cfe/trunk/include/clang/Basic/BuiltinsX86.def
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/Headers/emmintrin.h
  cfe/trunk/lib/Headers/ia32intrin.h
  cfe/trunk/lib/Headers/intrin.h
  cfe/trunk/lib/Headers/xmmintrin.h
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/CodeGen/builtins-x86.c
  cfe/trunk/test/Headers/x86intrin.cpp
  cfe/trunk/test/Sema/implicit-intel-builtin-decl.c
  cfe/trunk/test/Sema/implicit-ms-builtin-decl.c

Index: cfe/trunk/include/clang/Basic/BuiltinsX86.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def
@@ -23,6 +23,10 @@
 #   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
 #endif
 
+#if defined(BUILTIN) && !defined(TARGET_HEADER_BUILTIN)
+#  define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANG, FEATURE) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
 // FIXME: Are these nothrow/const?
 
 // Miscellaneous builtin for checking x86 cpu features.
@@ -301,15 +305,18 @@
 TARGET_BUILTIN(__builtin_ia32_pabsd128, "V4iV4i", "", "ssse3")
 
 TARGET_BUILTIN(__builtin_ia32_ldmxcsr, "vUi", "", "sse")
+TARGET_HEADER_BUILTIN(_mm_setcsr, "vUi", "h","xmmintrin.h", ALL_LANGUAGES, "sse")
 TARGET_BUILTIN(__builtin_ia32_stmxcsr, "Ui", "", "sse")
+TARGET_HEADER_BUILTIN(_mm_getcsr, "Ui", "h", "xmmintrin.h", ALL_LANGUAGES, "sse")
 TARGET_BUILTIN(__builtin_ia32_cvtss2si, "iV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cvttss2si, "iV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cvtss2si64, "LLiV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_cvttss2si64, "LLiV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_storehps, "vV2i*V4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_storelps, "vV2i*V4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_movmskps, "iV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_sfence, "v", "", "sse")
+TARGET_HEADER_BUILTIN(_mm_sfence, "v", "h", "xmmintrin.h", ALL_LANGUAGES, "sse")
 TARGET_BUILTIN(__builtin_ia32_rcpps, "V4fV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_rcpss, "V4fV4f", "", "sse")
 TARGET_BUILTIN(__builtin_ia32_rsqrtps, "V4fV4f", "", "sse")
@@ -337,9 +344,13 @@
 TARGET_BUILTIN(__builtin_ia32_cvtps2dq, "V4iV4f", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cvttps2dq, "V4iV4f", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_clflush, "vvC*", "", "sse2")
+TARGET_HEADER_BUILTIN(_mm_clflush, "vvC*", "h", "emmintrin.h", ALL_LANGUAGES, "sse2")
 TARGET_BUILTIN(__builtin_ia32_lfence, "v", "", "sse2")
+TARGET_HEADER_BUILTIN(_mm_lfence, "v", "h", "emmintrin.h", ALL_LANGUAGES, "sse2")
 TARGET_BUILTIN(__builtin_ia32_mfence, "v", "", "sse2")
+TARGET_HEADER_BUILTIN(_mm_mfence, "v", "h", "emmintrin.h", ALL_LANGUAGES, "sse2")
 TARGET_BUILTIN(__builtin_ia32_pause, "v", "", "sse2")
+TARGET_HEADER_BUILTIN(_mm_pause, "v", "h", "emmintrin.h", ALL_LANGUAGES, "sse2")
 TARGET_BUILTIN(__builtin_ia32_pmuludq128, "V2LLiV4iV4i", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_psraw128, "V8sV8sV8s", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_psrad128, "V4iV4iV4i", "", "sse2")
@@ -894,6 +905,7 @@
 
 BUILTIN(__builtin_ia32_rdpmc, "ULLii", "")
 BUILTIN(__builtin_ia32_rdtsc, "ULLi", "")
+BUILTIN(__rdtsc, "ULLi", "")
 BUILTIN(__builtin_ia32_rdtscp, "ULLiUi*", "")
 // PKU
 TARGET_BUILTIN(__builtin_ia32_rdpkru, "Ui", "", "pku")
@@ -2059,3 +2071,4 @@
 
 #undef BUILTIN
 #undef TARGET_BUILTIN
+#undef TARGET_HEADER_BUILTIN
Index: cfe/trunk/include/clang/Basic/Builtins.def
===
--- cfe/trunk/include/clang/Basic/Builtins.def
+++ cfe/trunk/include/clang/Basic/Builtins.def
@@ -74,6 +74,7 @@
 //  f -> this is a libc/libm function without the '__builtin_' prefix. It can
 //   be followed by ':headername:' to state which header this function
 //   comes from.
+//  h -> this function requires a specific header or an explicit declaration.
 //  i -> this is a runtime library implemented function without the
 //   '__builtin_' prefix. It will be implemented in compiler-rt or libgcc.
 //  p:N: -> this is a printf-like function whose Nth argument is the format
@@ -708,6 +709,9 @@
 // Microsoft builtins.  These are only active with -fms-extensions.
 LANGBUILTIN(_alloca,  "v*z", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__assume, "vb",  "n", ALL_MS_LANGUAGES)
+LIBBUILTIN(_byteswap_ushort, "UsUs", "fnc", "stdlib.h", ALL_MS_LANGUAGES)
+LIBBUILTIN(_byteswap_ulong,  "ULiULi",   "fnc", "stdlib.h", ALL_MS_LANGUAGES)
+LIBBUILTIN(_byteswap_uint64, "ULLiULLi", "fnc", "stdlib.h", ALL_MS_LA

[PATCH] D24584: Do not warn about format strings that are indexed string literals.

2016-09-14 Thread Meike Baumgärtner via cfe-commits
meikeb created this revision.
meikeb added a reviewer: rsmith.
meikeb added subscribers: cfe-commits, srhines.

The warning for a format string not being a sting literal and therefore
being potentially insecure is overly strict for indecies into sting
literals. This fix checks if the index into the string literal is
precomputable. If thats the case it will check if the suffix of that
sting literal is a valid format string string literal. It will still
issue the aforementioned warning for out of range indecies into the
string literal.

Patch by Meike Baumgärtner (meikeb)

https://reviews.llvm.org/D24584

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/format-strings.c

Index: test/Sema/format-strings.c
===
--- test/Sema/format-strings.c
+++ test/Sema/format-strings.c
@@ -652,3 +652,38 @@
   // expected-note@-1{{treat the string as an argument to avoid this}}
 }
 #pragma GCC diagnostic warning "-Wformat-nonliteral"
+
+void test_char_pointer_arithmetic(int b) {
+  const char s1[] = "string";
+  const char s2[] = "%s string";
+
+  printf(s1 - 1);  // expected-warning {{format string is not a string literal (potentially insecure)}}
+  // expected-note@-1{{treat the string as an argument to avoid this}}
+
+  printf(s1 + 2);  // no-warning
+  printf(s2 + 2);  // no-warning
+
+  const char s3[] = "%s string";
+  printf((s3 + 2) - 2);  // expected-warning{{more '%' conversions than data arguments}}
+  // expected-note@-2{{format string is defined here}}
+  printf(2 + s2); // no-warning
+  printf(6 + s2 - 2); // no-warning
+  printf(2 + (b ? s1 : s2));  // no-warning
+
+  const char s5[] = "string %s";
+  printf(2 + (b ? s2 : s5));  // expected-warning{{more '%' conversions than data arguments}}
+  // expected-note@-2{{format string is defined here}}
+  printf(2 + (b ? s2 : s5), "");  // no-warning
+  printf(2 + (b ? s1 : s2 - 2), "");  // no-warning
+
+  const char s6[] = "%s string";
+  printf(2 + (b ? s1 : s6 - 2));  // expected-warning{{more '%' conversions than data arguments}}
+  // expected-note@-2{{format string is defined here}}
+  printf(1 ? s2 + 2 : s2);  // no-warning
+  printf(0 ? s2 : s2 + 2);  // no-warning
+  printf(2 + s2 + 5 * 3 - 16, "");  // expected-warning{{data argument not used}}
+
+  const char s7[] = "%s string %s %s";
+  printf(s7 + 3, "");  // expected-warning{{more '%' conversions than data arguments}}
+  // expected-note@-2{{format string is defined here}}
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -3839,7 +3839,95 @@
 };
 } // end anonymous namespace
 
-static void CheckFormatString(Sema &S, const StringLiteral *FExpr,
+static void sumOffsets(llvm::APSInt &Offset, llvm::APSInt Addend,
+ BinaryOperatorKind BinOpKind,
+ bool AddendIsRight) {
+  unsigned BitWidth = Offset.getBitWidth();
+  unsigned AddendBitWidth = Addend.getBitWidth();
+  // There might be negative interim results.
+  if (Addend.isUnsigned()) {
+Addend = Addend.zext(++AddendBitWidth);
+Addend.setIsSigned(true);
+  }
+  // Adjust the bit width of the APSInts.
+  if (AddendBitWidth > BitWidth) {
+Offset = Offset.sext(AddendBitWidth);
+BitWidth = AddendBitWidth;
+  } else if (BitWidth > AddendBitWidth) {
+Addend = Addend.sext(BitWidth);
+  }
+
+  bool Ov = false;
+  llvm::APSInt ResOffset = Offset;
+  if (BinOpKind == BO_Add)
+ResOffset = Offset.sadd_ov(Addend, Ov);
+  else {
+assert(AddendIsRight && BinOpKind == BO_Sub &&
+   "operator must be add or sub with addend on the right");
+ResOffset = Offset.ssub_ov(Addend, Ov);
+  }
+
+  // We add an offset to a pointer here so we should support an offset as big as
+  // possible.
+  if (Ov) {
+assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");
+Offset.sext(2 * BitWidth);
+sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
+return;
+  }
+
+  Offset = ResOffset;
+}
+
+namespace {
+// This is a wrapper class around StringLiteral to support offsetted string
+// literals as format strings. It takes the offset into account when returning
+// the string and its length or the source locations to display notes correctly.
+class FormatStringLiteral {
+  const StringLiteral *FExpr;
+  int64_t Offset;
+
+ public:
+  FormatStringLiteral(const StringLiteral *fexpr, int64_t Offset = 0)
+  : FExpr(fexpr), Offset(Offset) {}
+
+  StringRef getString() const {
+return FExpr->getString().drop_front(Offset);
+  }
+
+  unsigned getByteLength() const {
+return FExpr->getByteLength() - getCharByteWidth() * Offset;
+  }
+  unsigned getLength() const { return FExpr->getLength() - Offset; }
+  unsigned getCharByteWidth() const { return FExpr->getCharByteWidth(); }
+
+  StringLiteral::StringKind getKind() const { return FExpr->getKind

Re: [PATCH] D24581: [CUDA] Add test checking our ability to take a function pointer to a __global__ function on the host side.

2016-09-14 Thread Artem Belevich via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D24581



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


Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-09-14 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

LGTM after addressing the inline comments.



Comment at: src/cxa_thread_atexit.cpp:70
@@ +69,3 @@
+while (auto head = dtors) {
+  dtors = head->next;
+  head->dtor(head->obj);

tavianator wrote:
> EricWF wrote:
> > tavianator wrote:
> > > EricWF wrote:
> > > > There is a bug here. If `head->next == nullptr` and if 
> > > > `head->dtor(head->obj))` creates a TL variable in the destructor then 
> > > > that destructor will not be invoked.
> > > > 
> > > > Here's an updated test case which catches the bug: 
> > > > https://gist.github.com/EricWF/3bb50d4f28b91aa28d2adefea0e94a0e
> > > I can't reproduce that failure here, your exact test case passes (even 
> > > with `#undef HAVE___CXA_THREAD_ATEXIT_IMPL` and the weak symbol test 
> > > commented out).
> > > 
> > > Tracing the implementation logic, it seems correct.  If `head->next == 
> > > nullptr` then this line does `dtors = nullptr`.  Then if 
> > > `head->dtor(head->obj)` registers a new `thread_local`, 
> > > `__cxa_thread_atexit()` does `head = malloc(...); ... dtors = head;`.  
> > > Then the next iteration of the loop `while (auto head = dtors) {` picks 
> > > up that new node.
> > > 
> > > Have I missed something?
> > I can't reproduce this morning either, I must have been doing something 
> > funny. I'll look at this with a fresh head tomorrow. If I can't find 
> > anything this will be good to go. Thanks for working on this. 
> No problem!  I can integrate your updated test case anyway if you want.
Yeah I would like to see the upgraded test case applied. At least that way 
we're testing the case in question.

So I agree with your above analysis of what happens, and that all destructors 
are correctly called during the first iteration of pthread key destruction. My 
one issues is that we still register a new non-null key which forces pthread to 
run the destructor for the key again. I would like to see this fixed.


https://reviews.llvm.org/D21803



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


Re: [PATCH] D24467: Fix an error after D21678

2016-09-14 Thread Akira Hatanaka via cfe-commits
ahatanak added inline comments.


Comment at: llvm/tools/clang/test/Sema/vecshift.c:56
@@ +55,3 @@
+
+  vc4 = vc4 << vc8; // expected-error {{vector operands do not have the same 
number of elements}}
+  vi4 = vi4 << vuc8; // expected-error {{vector operands do not have the same 
number of elements}}

vbyakovlcl wrote:
> ahatanak wrote:
> > I don't think this patch was necessary to have clang print diagnostic 
> > "vector operands do not have the same number of elements"? If that's the 
> > case, I think it's better to add these lines in a separate commit.
> Do you propose to delete lines with this diagnostic?
Yes, I think you can move them to a separate patch. Doing so will help people 
who read the patch understand what problems you are trying to fix with this 
patch.


https://reviews.llvm.org/D24467



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


[PATCH] D24581: [CUDA] Add test checking our ability to take a function pointer to a __global__ function on the host side.

2016-09-14 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added a subscriber: cfe-commits.

This functionality is used by Thrust.

https://reviews.llvm.org/D24581

Files:
  clang/test/SemaCUDA/reference-to-kernel-fn.cu

Index: clang/test/SemaCUDA/reference-to-kernel-fn.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/reference-to-kernel-fn.cu
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only -verify -DDEVICE 
%s
+
+// Check that we can reference (get a function pointer to) a __global__
+// function from the host side, but not the device side.  (We don't yet support
+// device-side kernel launches.)
+
+#include "Inputs/cuda.h"
+
+struct Dummy {};
+
+__global__ void kernel() {}
+// expected-note@-1 {{declared here}}
+#ifdef DEVICE
+// expected-note@-3 {{declared here}}
+#endif
+
+typedef void (*fn_ptr_t)();
+
+__host__ __device__ fn_ptr_t get_ptr_hd() {
+  return kernel;
+#ifdef DEVICE
+  // expected-error@-2 {{reference to __global__ function}}
+#endif
+}
+__host__ fn_ptr_t get_ptr_h() {
+  return kernel;
+}
+__device__ fn_ptr_t get_ptr_d() {
+  return kernel;  // expected-error {{reference to __global__ function}}
+}


Index: clang/test/SemaCUDA/reference-to-kernel-fn.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/reference-to-kernel-fn.cu
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only -verify -DDEVICE %s
+
+// Check that we can reference (get a function pointer to) a __global__
+// function from the host side, but not the device side.  (We don't yet support
+// device-side kernel launches.)
+
+#include "Inputs/cuda.h"
+
+struct Dummy {};
+
+__global__ void kernel() {}
+// expected-note@-1 {{declared here}}
+#ifdef DEVICE
+// expected-note@-3 {{declared here}}
+#endif
+
+typedef void (*fn_ptr_t)();
+
+__host__ __device__ fn_ptr_t get_ptr_hd() {
+  return kernel;
+#ifdef DEVICE
+  // expected-error@-2 {{reference to __global__ function}}
+#endif
+}
+__host__ fn_ptr_t get_ptr_h() {
+  return kernel;
+}
+__device__ fn_ptr_t get_ptr_d() {
+  return kernel;  // expected-error {{reference to __global__ function}}
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24579: Revert "Do not warn about format strings that are indexed string literals."

2016-09-14 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281530: Revert "Do not warn about format strings that are 
indexed string literals." (authored by srhines).

Changed prior to commit:
  https://reviews.llvm.org/D24579?vs=71417&id=71419#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24579

Files:
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/Sema/format-strings.c

Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -3841,95 +3841,7 @@
 };
 } // end anonymous namespace
 
-static void sumOffsets(llvm::APSInt &Offset, llvm::APSInt Addend,
- BinaryOperatorKind BinOpKind,
- bool AddendIsRight) {
-  unsigned BitWidth = Offset.getBitWidth();
-  unsigned AddendBitWidth = Addend.getBitWidth();
-  // There might be negative interim results.
-  if (Addend.isUnsigned()) {
-Addend = Addend.zext(++AddendBitWidth);
-Addend.setIsSigned(true);
-  }
-  // Adjust the bit width of the APSInts.
-  if (AddendBitWidth > BitWidth) {
-Offset = Offset.sext(AddendBitWidth);
-BitWidth = AddendBitWidth;
-  } else if (BitWidth > AddendBitWidth) {
-Addend = Addend.sext(BitWidth);
-  }
-
-  bool Ov = false;
-  llvm::APSInt ResOffset = Offset;
-  if (BinOpKind == BO_Add)
-ResOffset = Offset.sadd_ov(Addend, Ov);
-  else {
-assert(AddendIsRight && BinOpKind == BO_Sub &&
-   "operator must be add or sub with addend on the right");
-ResOffset = Offset.ssub_ov(Addend, Ov);
-  }
-
-  // We add an offset to a pointer here so we should support an offset as big as
-  // possible.
-  if (Ov) {
-assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");
-Offset.sext(2 * BitWidth);
-sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
-return;
-  }
-
-  Offset = ResOffset;
-}
-
-namespace {
-// This is a wrapper class around StringLiteral to support offsetted string
-// literals as format strings. It takes the offset into account when returning
-// the string and its length or the source locations to display notes correctly.
-class FormatStringLiteral {
-  const StringLiteral *FExpr;
-  int64_t Offset;
-
- public:
-  FormatStringLiteral(const StringLiteral *fexpr, int64_t Offset = 0)
-  : FExpr(fexpr), Offset(Offset) {}
-
-  StringRef getString() const {
-return FExpr->getString().drop_front(Offset);
-  }
-
-  unsigned getByteLength() const {
-return FExpr->getByteLength() - getCharByteWidth() * Offset;
-  }
-  unsigned getLength() const { return FExpr->getLength() - Offset; }
-  unsigned getCharByteWidth() const { return FExpr->getCharByteWidth(); }
-
-  StringLiteral::StringKind getKind() const { return FExpr->getKind(); }
-
-  QualType getType() const { return FExpr->getType(); }
-
-  bool isAscii() const { return FExpr->isAscii(); }
-  bool isWide() const { return FExpr->isWide(); }
-  bool isUTF8() const { return FExpr->isUTF8(); }
-  bool isUTF16() const { return FExpr->isUTF16(); }
-  bool isUTF32() const { return FExpr->isUTF32(); }
-  bool isPascal() const { return FExpr->isPascal(); }
-
-  SourceLocation getLocationOfByte(
-  unsigned ByteNo, const SourceManager &SM, const LangOptions &Features,
-  const TargetInfo &Target, unsigned *StartToken = nullptr,
-  unsigned *StartTokenByteOffset = nullptr) const {
-return FExpr->getLocationOfByte(ByteNo + Offset, SM, Features, Target,
-StartToken, StartTokenByteOffset);
-  }
-
-  SourceLocation getLocStart() const LLVM_READONLY {
-return FExpr->getLocStart().getLocWithOffset(Offset);
-  }
-  SourceLocation getLocEnd() const LLVM_READONLY { return FExpr->getLocEnd(); }
-};
-}  // end anonymous namespace
-
-static void CheckFormatString(Sema &S, const FormatStringLiteral *FExpr,
+static void CheckFormatString(Sema &S, const StringLiteral *FExpr,
   const Expr *OrigFormatExpr,
   ArrayRef Args,
   bool HasVAListArg, unsigned format_idx,
@@ -3950,11 +3862,8 @@
   unsigned firstDataArg, Sema::FormatStringType Type,
   Sema::VariadicCallType CallType, bool InFunctionCall,
   llvm::SmallBitVector &CheckedVarArgs,
-  UncoveredArgHandler &UncoveredArg,
-  llvm::APSInt Offset) {
+  UncoveredArgHandler &UncoveredArg) {
  tryAgain:
-  assert(Offset.isSigned() && "invalid offset");
-
   if (E->isTypeDependent() || E->isValueDependent())
 return SLCT_NotALiteral;
 
@@ -3988,28 +3897,23 @@
 CheckLeft = false;
 }
 
-// We need to maintain the offsets for the right and the left hand side
-// separately to check if every possible indexed expression is a valid
-// string literal. The

r281530 - Revert "Do not warn about format strings that are indexed string literals."

2016-09-14 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Wed Sep 14 15:20:14 2016
New Revision: 281530

URL: http://llvm.org/viewvc/llvm-project?rev=281530&view=rev
Log:
Revert "Do not warn about format strings that are indexed string literals."

Summary: This reverts r281527 because I messed up the attribution.

Reviewers: srhines

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/format-strings.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=281530&r1=281529&r2=281530&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Sep 14 15:20:14 2016
@@ -3841,95 +3841,7 @@ enum StringLiteralCheckType {
 };
 } // end anonymous namespace
 
-static void sumOffsets(llvm::APSInt &Offset, llvm::APSInt Addend,
- BinaryOperatorKind BinOpKind,
- bool AddendIsRight) {
-  unsigned BitWidth = Offset.getBitWidth();
-  unsigned AddendBitWidth = Addend.getBitWidth();
-  // There might be negative interim results.
-  if (Addend.isUnsigned()) {
-Addend = Addend.zext(++AddendBitWidth);
-Addend.setIsSigned(true);
-  }
-  // Adjust the bit width of the APSInts.
-  if (AddendBitWidth > BitWidth) {
-Offset = Offset.sext(AddendBitWidth);
-BitWidth = AddendBitWidth;
-  } else if (BitWidth > AddendBitWidth) {
-Addend = Addend.sext(BitWidth);
-  }
-
-  bool Ov = false;
-  llvm::APSInt ResOffset = Offset;
-  if (BinOpKind == BO_Add)
-ResOffset = Offset.sadd_ov(Addend, Ov);
-  else {
-assert(AddendIsRight && BinOpKind == BO_Sub &&
-   "operator must be add or sub with addend on the right");
-ResOffset = Offset.ssub_ov(Addend, Ov);
-  }
-
-  // We add an offset to a pointer here so we should support an offset as big 
as
-  // possible.
-  if (Ov) {
-assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");
-Offset.sext(2 * BitWidth);
-sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
-return;
-  }
-
-  Offset = ResOffset;
-}
-
-namespace {
-// This is a wrapper class around StringLiteral to support offsetted string
-// literals as format strings. It takes the offset into account when returning
-// the string and its length or the source locations to display notes 
correctly.
-class FormatStringLiteral {
-  const StringLiteral *FExpr;
-  int64_t Offset;
-
- public:
-  FormatStringLiteral(const StringLiteral *fexpr, int64_t Offset = 0)
-  : FExpr(fexpr), Offset(Offset) {}
-
-  StringRef getString() const {
-return FExpr->getString().drop_front(Offset);
-  }
-
-  unsigned getByteLength() const {
-return FExpr->getByteLength() - getCharByteWidth() * Offset;
-  }
-  unsigned getLength() const { return FExpr->getLength() - Offset; }
-  unsigned getCharByteWidth() const { return FExpr->getCharByteWidth(); }
-
-  StringLiteral::StringKind getKind() const { return FExpr->getKind(); }
-
-  QualType getType() const { return FExpr->getType(); }
-
-  bool isAscii() const { return FExpr->isAscii(); }
-  bool isWide() const { return FExpr->isWide(); }
-  bool isUTF8() const { return FExpr->isUTF8(); }
-  bool isUTF16() const { return FExpr->isUTF16(); }
-  bool isUTF32() const { return FExpr->isUTF32(); }
-  bool isPascal() const { return FExpr->isPascal(); }
-
-  SourceLocation getLocationOfByte(
-  unsigned ByteNo, const SourceManager &SM, const LangOptions &Features,
-  const TargetInfo &Target, unsigned *StartToken = nullptr,
-  unsigned *StartTokenByteOffset = nullptr) const {
-return FExpr->getLocationOfByte(ByteNo + Offset, SM, Features, Target,
-StartToken, StartTokenByteOffset);
-  }
-
-  SourceLocation getLocStart() const LLVM_READONLY {
-return FExpr->getLocStart().getLocWithOffset(Offset);
-  }
-  SourceLocation getLocEnd() const LLVM_READONLY { return FExpr->getLocEnd(); }
-};
-}  // end anonymous namespace
-
-static void CheckFormatString(Sema &S, const FormatStringLiteral *FExpr,
+static void CheckFormatString(Sema &S, const StringLiteral *FExpr,
   const Expr *OrigFormatExpr,
   ArrayRef Args,
   bool HasVAListArg, unsigned format_idx,
@@ -3950,11 +3862,8 @@ checkFormatStringExpr(Sema &S, const Exp
   unsigned firstDataArg, Sema::FormatStringType Type,
   Sema::VariadicCallType CallType, bool InFunctionCall,
   llvm::SmallBitVector &CheckedVarArgs,
-  UncoveredArgHandler &UncoveredArg,
-  llvm::APSInt Offset) {
+  UncoveredArgHandler &UncoveredArg) {
  tryAgain:
-  assert(Offset.isSigned() && "invalid offset");
-
   if (E->isTypeDependent() || E->is

Re: [PATCH] D24508: PR28752: Do not instantiate var decls which are not visible.

2016-09-14 Thread Richard Smith via cfe-commits
rsmith added a comment.

I think you'll also need to update the `ASTDeclReader` to merge `VarDecl` 
definitions together if it reads a definition and there already is one in the 
AST. I note that right now `Sema::AddInitializerToDecl` permits multiple 
definitions of a `VarDecl`, which doesn't seem like what we want here; we'll 
probably want to merge those as we parse them, too.

Now, we have a problem here: unlike with classes and functions, we can't always 
convert a variable definition to a declaration by just dropping the 
initializer. Perhaps we can add a flag to `VarDecl` to indicate "this is just a 
declaration, even though it looks like a definition", to handle that case? 
(This would also be useful for `VarTemplateSpecializationDecl`s, where we 
currently reject valid code such as "template int n; int k = n;" 
because we have no way to represent the difference between a mere declaration 
and a definition of `n`.)



Comment at: lib/Sema/SemaTemplate.cpp:505
@@ -499,3 +504,3 @@
 Instantiation->setInvalidDecl();
   } else if (InstantiatedFromMember) {
 if (isa(Instantiation)) {

Why do we not issue a diagnostic in this case for a `VarDecl` when `Complain` 
is true and no definition is available? It seems like we should either be 
diagnosing this or asserting that it can't happen.


Comment at: lib/Sema/SemaTemplate.cpp:528
@@ +527,3 @@
+  Note = diag::note_template_decl_here;
+} else if (isa(Instantiation)) {
+  if (isa(Instantiation)) {

`else` + `assert` would make more sense here. No other kind of declaration 
should get here.


Comment at: lib/Sema/SemaType.cpp:6898-6899
@@ +6897,4 @@
+  } else if (auto *VD = dyn_cast(D)) {
+// FIXME: Handle the case where D is a VarTemplateSpecializationDecl, i.e. 
D
+// is not a static data member.
+if (auto *Pattern = VD->getInstantiatedFromStaticDataMember())

We should add a `getTemplateInstantiationPattern()` to `VarDecl` and use it 
from here.


https://reviews.llvm.org/D24508



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


[PATCH] D24579: Revert "Do not warn about format strings that are indexed string literals."

2016-09-14 Thread Stephen Hines via cfe-commits
srhines created this revision.
srhines added a subscriber: cfe-commits.

This reverts r281527 because I messed up the attribution.

https://reviews.llvm.org/D24579

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/format-strings.c

Index: test/Sema/format-strings.c
===
--- test/Sema/format-strings.c
+++ test/Sema/format-strings.c
@@ -652,38 +652,3 @@
   // expected-note@-1{{treat the string as an argument to avoid this}}
 }
 #pragma GCC diagnostic warning "-Wformat-nonliteral"
-
-void test_char_pointer_arithmetic(int b) {
-  const char s1[] = "string";
-  const char s2[] = "%s string";
-
-  printf(s1 - 1);  // expected-warning {{format string is not a string literal (potentially insecure)}}
-  // expected-note@-1{{treat the string as an argument to avoid this}}
-
-  printf(s1 + 2);  // no-warning
-  printf(s2 + 2);  // no-warning
-
-  const char s3[] = "%s string";
-  printf((s3 + 2) - 2);  // expected-warning{{more '%' conversions than data arguments}}
-  // expected-note@-2{{format string is defined here}}
-  printf(2 + s2); // no-warning
-  printf(6 + s2 - 2); // no-warning
-  printf(2 + (b ? s1 : s2));  // no-warning
-
-  const char s5[] = "string %s";
-  printf(2 + (b ? s2 : s5));  // expected-warning{{more '%' conversions than data arguments}}
-  // expected-note@-2{{format string is defined here}}
-  printf(2 + (b ? s2 : s5), "");  // no-warning
-  printf(2 + (b ? s1 : s2 - 2), "");  // no-warning
-
-  const char s6[] = "%s string";
-  printf(2 + (b ? s1 : s6 - 2));  // expected-warning{{more '%' conversions than data arguments}}
-  // expected-note@-2{{format string is defined here}}
-  printf(1 ? s2 + 2 : s2);  // no-warning
-  printf(0 ? s2 : s2 + 2);  // no-warning
-  printf(2 + s2 + 5 * 3 - 16, "");  // expected-warning{{data argument not used}}
-
-  const char s7[] = "%s string %s %s";
-  printf(s7 + 3, "");  // expected-warning{{more '%' conversions than data arguments}}
-  // expected-note@-2{{format string is defined here}}
-}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -3841,95 +3841,7 @@
 };
 } // end anonymous namespace
 
-static void sumOffsets(llvm::APSInt &Offset, llvm::APSInt Addend,
- BinaryOperatorKind BinOpKind,
- bool AddendIsRight) {
-  unsigned BitWidth = Offset.getBitWidth();
-  unsigned AddendBitWidth = Addend.getBitWidth();
-  // There might be negative interim results.
-  if (Addend.isUnsigned()) {
-Addend = Addend.zext(++AddendBitWidth);
-Addend.setIsSigned(true);
-  }
-  // Adjust the bit width of the APSInts.
-  if (AddendBitWidth > BitWidth) {
-Offset = Offset.sext(AddendBitWidth);
-BitWidth = AddendBitWidth;
-  } else if (BitWidth > AddendBitWidth) {
-Addend = Addend.sext(BitWidth);
-  }
-
-  bool Ov = false;
-  llvm::APSInt ResOffset = Offset;
-  if (BinOpKind == BO_Add)
-ResOffset = Offset.sadd_ov(Addend, Ov);
-  else {
-assert(AddendIsRight && BinOpKind == BO_Sub &&
-   "operator must be add or sub with addend on the right");
-ResOffset = Offset.ssub_ov(Addend, Ov);
-  }
-
-  // We add an offset to a pointer here so we should support an offset as big as
-  // possible.
-  if (Ov) {
-assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");
-Offset.sext(2 * BitWidth);
-sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
-return;
-  }
-
-  Offset = ResOffset;
-}
-
-namespace {
-// This is a wrapper class around StringLiteral to support offsetted string
-// literals as format strings. It takes the offset into account when returning
-// the string and its length or the source locations to display notes correctly.
-class FormatStringLiteral {
-  const StringLiteral *FExpr;
-  int64_t Offset;
-
- public:
-  FormatStringLiteral(const StringLiteral *fexpr, int64_t Offset = 0)
-  : FExpr(fexpr), Offset(Offset) {}
-
-  StringRef getString() const {
-return FExpr->getString().drop_front(Offset);
-  }
-
-  unsigned getByteLength() const {
-return FExpr->getByteLength() - getCharByteWidth() * Offset;
-  }
-  unsigned getLength() const { return FExpr->getLength() - Offset; }
-  unsigned getCharByteWidth() const { return FExpr->getCharByteWidth(); }
-
-  StringLiteral::StringKind getKind() const { return FExpr->getKind(); }
-
-  QualType getType() const { return FExpr->getType(); }
-
-  bool isAscii() const { return FExpr->isAscii(); }
-  bool isWide() const { return FExpr->isWide(); }
-  bool isUTF8() const { return FExpr->isUTF8(); }
-  bool isUTF16() const { return FExpr->isUTF16(); }
-  bool isUTF32() const { return FExpr->isUTF32(); }
-  bool isPascal() const { return FExpr->isPascal(); }
-
-  SourceLocation getLocationOfByte(
-  unsigned ByteNo, const SourceManager &SM, const LangOptions &Features,
-  const T

Re: [PATCH] D23820: Do not warn about format strings that are indexed string literals.

2016-09-14 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281527: Do not warn about format strings that are indexed 
string literals. (authored by srhines).

Changed prior to commit:
  https://reviews.llvm.org/D23820?vs=71286&id=71416#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23820

Files:
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/Sema/format-strings.c

Index: cfe/trunk/test/Sema/format-strings.c
===
--- cfe/trunk/test/Sema/format-strings.c
+++ cfe/trunk/test/Sema/format-strings.c
@@ -652,3 +652,38 @@
   // expected-note@-1{{treat the string as an argument to avoid this}}
 }
 #pragma GCC diagnostic warning "-Wformat-nonliteral"
+
+void test_char_pointer_arithmetic(int b) {
+  const char s1[] = "string";
+  const char s2[] = "%s string";
+
+  printf(s1 - 1);  // expected-warning {{format string is not a string literal (potentially insecure)}}
+  // expected-note@-1{{treat the string as an argument to avoid this}}
+
+  printf(s1 + 2);  // no-warning
+  printf(s2 + 2);  // no-warning
+
+  const char s3[] = "%s string";
+  printf((s3 + 2) - 2);  // expected-warning{{more '%' conversions than data arguments}}
+  // expected-note@-2{{format string is defined here}}
+  printf(2 + s2); // no-warning
+  printf(6 + s2 - 2); // no-warning
+  printf(2 + (b ? s1 : s2));  // no-warning
+
+  const char s5[] = "string %s";
+  printf(2 + (b ? s2 : s5));  // expected-warning{{more '%' conversions than data arguments}}
+  // expected-note@-2{{format string is defined here}}
+  printf(2 + (b ? s2 : s5), "");  // no-warning
+  printf(2 + (b ? s1 : s2 - 2), "");  // no-warning
+
+  const char s6[] = "%s string";
+  printf(2 + (b ? s1 : s6 - 2));  // expected-warning{{more '%' conversions than data arguments}}
+  // expected-note@-2{{format string is defined here}}
+  printf(1 ? s2 + 2 : s2);  // no-warning
+  printf(0 ? s2 : s2 + 2);  // no-warning
+  printf(2 + s2 + 5 * 3 - 16, "");  // expected-warning{{data argument not used}}
+
+  const char s7[] = "%s string %s %s";
+  printf(s7 + 3, "");  // expected-warning{{more '%' conversions than data arguments}}
+  // expected-note@-2{{format string is defined here}}
+}
Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -3841,7 +3841,95 @@
 };
 } // end anonymous namespace
 
-static void CheckFormatString(Sema &S, const StringLiteral *FExpr,
+static void sumOffsets(llvm::APSInt &Offset, llvm::APSInt Addend,
+ BinaryOperatorKind BinOpKind,
+ bool AddendIsRight) {
+  unsigned BitWidth = Offset.getBitWidth();
+  unsigned AddendBitWidth = Addend.getBitWidth();
+  // There might be negative interim results.
+  if (Addend.isUnsigned()) {
+Addend = Addend.zext(++AddendBitWidth);
+Addend.setIsSigned(true);
+  }
+  // Adjust the bit width of the APSInts.
+  if (AddendBitWidth > BitWidth) {
+Offset = Offset.sext(AddendBitWidth);
+BitWidth = AddendBitWidth;
+  } else if (BitWidth > AddendBitWidth) {
+Addend = Addend.sext(BitWidth);
+  }
+
+  bool Ov = false;
+  llvm::APSInt ResOffset = Offset;
+  if (BinOpKind == BO_Add)
+ResOffset = Offset.sadd_ov(Addend, Ov);
+  else {
+assert(AddendIsRight && BinOpKind == BO_Sub &&
+   "operator must be add or sub with addend on the right");
+ResOffset = Offset.ssub_ov(Addend, Ov);
+  }
+
+  // We add an offset to a pointer here so we should support an offset as big as
+  // possible.
+  if (Ov) {
+assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");
+Offset.sext(2 * BitWidth);
+sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
+return;
+  }
+
+  Offset = ResOffset;
+}
+
+namespace {
+// This is a wrapper class around StringLiteral to support offsetted string
+// literals as format strings. It takes the offset into account when returning
+// the string and its length or the source locations to display notes correctly.
+class FormatStringLiteral {
+  const StringLiteral *FExpr;
+  int64_t Offset;
+
+ public:
+  FormatStringLiteral(const StringLiteral *fexpr, int64_t Offset = 0)
+  : FExpr(fexpr), Offset(Offset) {}
+
+  StringRef getString() const {
+return FExpr->getString().drop_front(Offset);
+  }
+
+  unsigned getByteLength() const {
+return FExpr->getByteLength() - getCharByteWidth() * Offset;
+  }
+  unsigned getLength() const { return FExpr->getLength() - Offset; }
+  unsigned getCharByteWidth() const { return FExpr->getCharByteWidth(); }
+
+  StringLiteral::StringKind getKind() const { return FExpr->getKind(); }
+
+  QualType getType() const { return FExpr->getType(); }
+
+  bool isAscii() const { return FExpr->isAscii(); }
+  bool isWide() const { return FExpr->isWide(); }
+  bool isUTF8() const { retu

r281527 - Do not warn about format strings that are indexed string literals.

2016-09-14 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Wed Sep 14 15:05:20 2016
New Revision: 281527

URL: http://llvm.org/viewvc/llvm-project?rev=281527&view=rev
Log:
Do not warn about format strings that are indexed string literals.

Summary:
The warning for a format string not being a sting literal and therefore
being potentially insecure is overly strict for indecies into sting
literals. This fix checks if the index into the string literal is
precomputable. If thats the case it will check if the suffix of that
sting literal is a valid format string string literal. It will still
issue the aforementioned warning for out of range indecies into the
string literal.

Reviewers: rsmith

Subscribers: srhines, cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/format-strings.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=281527&r1=281526&r2=281527&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Sep 14 15:05:20 2016
@@ -3841,7 +3841,95 @@ enum StringLiteralCheckType {
 };
 } // end anonymous namespace
 
-static void CheckFormatString(Sema &S, const StringLiteral *FExpr,
+static void sumOffsets(llvm::APSInt &Offset, llvm::APSInt Addend,
+ BinaryOperatorKind BinOpKind,
+ bool AddendIsRight) {
+  unsigned BitWidth = Offset.getBitWidth();
+  unsigned AddendBitWidth = Addend.getBitWidth();
+  // There might be negative interim results.
+  if (Addend.isUnsigned()) {
+Addend = Addend.zext(++AddendBitWidth);
+Addend.setIsSigned(true);
+  }
+  // Adjust the bit width of the APSInts.
+  if (AddendBitWidth > BitWidth) {
+Offset = Offset.sext(AddendBitWidth);
+BitWidth = AddendBitWidth;
+  } else if (BitWidth > AddendBitWidth) {
+Addend = Addend.sext(BitWidth);
+  }
+
+  bool Ov = false;
+  llvm::APSInt ResOffset = Offset;
+  if (BinOpKind == BO_Add)
+ResOffset = Offset.sadd_ov(Addend, Ov);
+  else {
+assert(AddendIsRight && BinOpKind == BO_Sub &&
+   "operator must be add or sub with addend on the right");
+ResOffset = Offset.ssub_ov(Addend, Ov);
+  }
+
+  // We add an offset to a pointer here so we should support an offset as big 
as
+  // possible.
+  if (Ov) {
+assert(BitWidth <= UINT_MAX / 2 && "index (intermediate) result too big");
+Offset.sext(2 * BitWidth);
+sumOffsets(Offset, Addend, BinOpKind, AddendIsRight);
+return;
+  }
+
+  Offset = ResOffset;
+}
+
+namespace {
+// This is a wrapper class around StringLiteral to support offsetted string
+// literals as format strings. It takes the offset into account when returning
+// the string and its length or the source locations to display notes 
correctly.
+class FormatStringLiteral {
+  const StringLiteral *FExpr;
+  int64_t Offset;
+
+ public:
+  FormatStringLiteral(const StringLiteral *fexpr, int64_t Offset = 0)
+  : FExpr(fexpr), Offset(Offset) {}
+
+  StringRef getString() const {
+return FExpr->getString().drop_front(Offset);
+  }
+
+  unsigned getByteLength() const {
+return FExpr->getByteLength() - getCharByteWidth() * Offset;
+  }
+  unsigned getLength() const { return FExpr->getLength() - Offset; }
+  unsigned getCharByteWidth() const { return FExpr->getCharByteWidth(); }
+
+  StringLiteral::StringKind getKind() const { return FExpr->getKind(); }
+
+  QualType getType() const { return FExpr->getType(); }
+
+  bool isAscii() const { return FExpr->isAscii(); }
+  bool isWide() const { return FExpr->isWide(); }
+  bool isUTF8() const { return FExpr->isUTF8(); }
+  bool isUTF16() const { return FExpr->isUTF16(); }
+  bool isUTF32() const { return FExpr->isUTF32(); }
+  bool isPascal() const { return FExpr->isPascal(); }
+
+  SourceLocation getLocationOfByte(
+  unsigned ByteNo, const SourceManager &SM, const LangOptions &Features,
+  const TargetInfo &Target, unsigned *StartToken = nullptr,
+  unsigned *StartTokenByteOffset = nullptr) const {
+return FExpr->getLocationOfByte(ByteNo + Offset, SM, Features, Target,
+StartToken, StartTokenByteOffset);
+  }
+
+  SourceLocation getLocStart() const LLVM_READONLY {
+return FExpr->getLocStart().getLocWithOffset(Offset);
+  }
+  SourceLocation getLocEnd() const LLVM_READONLY { return FExpr->getLocEnd(); }
+};
+}  // end anonymous namespace
+
+static void CheckFormatString(Sema &S, const FormatStringLiteral *FExpr,
   const Expr *OrigFormatExpr,
   ArrayRef Args,
   bool HasVAListArg, unsigned format_idx,
@@ -3862,8 +3950,11 @@ checkFormatStringExpr(Sema &S, const Exp
   unsigned firstDataArg, Sema::FormatStringType Type,
   Sema::Vari

Re: [PATCH] D24372: [libcxx] Sprinkle constexpr over compressed_pair

2016-09-14 Thread Eric Fiselier via cfe-commits
static_cast(t) also works as a constexpr C++11 forward.

On Sep 13, 2016 4:07 PM, "Keno Fischer" 
wrote:

> loladiro added inline comments.
>
> 
> Comment at: include/memory:2137
> @@ -2132,3 +2136,3 @@
>
> -_LIBCPP_INLINE_VISIBILITY
> +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
>  __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&&
> __p)
> 
> mclow.lists wrote:
> > loladiro wrote:
> > > mclow.lists wrote:
> > > > Have you tested this on C++11?
> > > > I suspect that some of these need to be
> `_LIBCPP_CONSTEXPR_AFTER_CXX11`
> > > Well, as I mentioned there are other problems on C++11, namely forward
> not being constexpr (so even the simple constructors below can't be
> constant initialized in C++11). I would REALLY like for unique_ptr to be
> constant initialized even in C++11 mode. I feel like arguably the standard
> requires it by marking the constructor `constexpr`.
> > One way to deal with that is to define a call `__forward()` that is the
> same as `forward()` except that it's constexpr in C++11, and have
> compressed_pair call that.
> >
> I was worried that something in the definition of forward required C++14
> constexpr semantics? Is that not the case. If so this sounds like a good
> solution, and I can update the patch accordingly.
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D24372
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23820: Do not warn about format strings that are indexed string literals.

2016-09-14 Thread Stephen Hines via cfe-commits
srhines added a comment.

I will take care of submitting this. Thanks for the reviews everybody!


https://reviews.llvm.org/D23820



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


Re: [PATCH] D24518: Correct assert text in DeclGroup::getSingleDecl()

2016-09-14 Thread Kirill Bobyrev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281525: Correct assert text in DeclGroup::getSingleDecl() 
(authored by omtcyfz).

Changed prior to commit:
  https://reviews.llvm.org/D24518?vs=71188&id=71414#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24518

Files:
  cfe/trunk/include/clang/AST/DeclGroup.h

Index: cfe/trunk/include/clang/AST/DeclGroup.h
===
--- cfe/trunk/include/clang/AST/DeclGroup.h
+++ cfe/trunk/include/clang/AST/DeclGroup.h
@@ -84,7 +84,7 @@
   bool isDeclGroup() const { return getKind() == DeclGroupKind; }
 
   Decl *getSingleDecl() {
-assert(isSingleDecl() && "Isn't a declgroup");
+assert(isSingleDecl() && "Isn't a single decl");
 return D;
   }
   const Decl *getSingleDecl() const {


Index: cfe/trunk/include/clang/AST/DeclGroup.h
===
--- cfe/trunk/include/clang/AST/DeclGroup.h
+++ cfe/trunk/include/clang/AST/DeclGroup.h
@@ -84,7 +84,7 @@
   bool isDeclGroup() const { return getKind() == DeclGroupKind; }
 
   Decl *getSingleDecl() {
-assert(isSingleDecl() && "Isn't a declgroup");
+assert(isSingleDecl() && "Isn't a single decl");
 return D;
   }
   const Decl *getSingleDecl() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r281525 - Correct assert text in DeclGroup::getSingleDecl()

2016-09-14 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Wed Sep 14 14:59:26 2016
New Revision: 281525

URL: http://llvm.org/viewvc/llvm-project?rev=281525&view=rev
Log:
Correct assert text in DeclGroup::getSingleDecl()

Assert text for getSingleDecl() is inaccurate. Appears to have been copy pasted
from getDeclGroup().

Patch by Ben Taylor!

Reviewers: alexfh

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/DeclGroup.h

Modified: cfe/trunk/include/clang/AST/DeclGroup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclGroup.h?rev=281525&r1=281524&r2=281525&view=diff
==
--- cfe/trunk/include/clang/AST/DeclGroup.h (original)
+++ cfe/trunk/include/clang/AST/DeclGroup.h Wed Sep 14 14:59:26 2016
@@ -84,7 +84,7 @@ public:
   bool isDeclGroup() const { return getKind() == DeclGroupKind; }
 
   Decl *getSingleDecl() {
-assert(isSingleDecl() && "Isn't a declgroup");
+assert(isSingleDecl() && "Isn't a single decl");
 return D;
   }
   const Decl *getSingleDecl() const {


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


Re: [PATCH] D22452: [libcxx] Fix last_write_time tests for filesystems that don't support negative and very large times.

2016-09-14 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Thanks. I'll update this patch today.


https://reviews.llvm.org/D22452



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


Re: [PATCH] D23820: Do not warn about format strings that are indexed string literals.

2016-09-14 Thread Meike Baumgärtner via cfe-commits
meikeb marked an inline comment as done.
meikeb added a comment.

Thanks for reviewing my patch! It would be great if someone could submit this 
patch for me.


https://reviews.llvm.org/D23820



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


Re: [PATCH] D24518: Correct assert text in DeclGroup::getSingleDecl()

2016-09-14 Thread Ben Taylor via cfe-commits
brtaylor92 added a comment.

I don't have commit access. @alexfh could you please land the patch?


https://reviews.llvm.org/D24518



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


Re: [PATCH] D24467: Fix an error after D21678

2016-09-14 Thread Vladimir Yakovlev via cfe-commits
vbyakovlcl added inline comments.


Comment at: llvm/tools/clang/lib/Sema/SemaExpr.cpp:8790
@@ -8774,3 +8789,3 @@
   S.Context.getExtVectorType(RHSEleType, LHSVecTy->getNumElements());
 RHS = S.ImpCastExprToType(RHS.get(), VecTy, CK_VectorSplat);
   }

ahatanak wrote:
> OK. So the rule is that the type of the scalar operand is normally converted 
> to the vector element type of the other operand before being transformed to a 
> vector, but we don't have to do this when it's used as the RHS (shift amount) 
> because IRGen generates the correct IR without the conversion?
Yes. I think a CodeGen test should be added for checking of IR correctness. 


Comment at: llvm/tools/clang/test/Sema/vecshift.c:56
@@ +55,3 @@
+
+  vc4 = vc4 << vc8; // expected-error {{vector operands do not have the same 
number of elements}}
+  vi4 = vi4 << vuc8; // expected-error {{vector operands do not have the same 
number of elements}}

ahatanak wrote:
> I don't think this patch was necessary to have clang print diagnostic "vector 
> operands do not have the same number of elements"? If that's the case, I 
> think it's better to add these lines in a separate commit.
Do you propose to delete lines with this diagnostic?


https://reviews.llvm.org/D24467



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


Re: [PATCH] D24574: clang-format: [JS] ASI insertion after boolean literals.

2016-09-14 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Interesting.. Would have expected true/false to be literals as well, but ok :).


https://reviews.llvm.org/D24574



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


Re: [PATCH] D21506: [analyzer] Block in critical section

2016-09-14 Thread Anna Zaks via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!

Future steps:
How do we plan to bring this checker out of alpha? Have you evaluated it on 
large codebases?


Repository:
  rL LLVM

https://reviews.llvm.org/D21506



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


Re: [PATCH] D21506: [analyzer] Block in critical section

2016-09-14 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Do you have commit access or should we commit?


Repository:
  rL LLVM

https://reviews.llvm.org/D21506



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


Re: [PATCH] D24467: Fix an error after D21678

2016-09-14 Thread Akira Hatanaka via cfe-commits
ahatanak added inline comments.


Comment at: llvm/tools/clang/lib/Sema/SemaExpr.cpp:8751
@@ -8747,3 +8750,3 @@
 
   // OpenCL v1.1 s6.3.j says that the operands need to be integers.
   if (!LHSEleType->isIntegerType()) {

Should we mention that any vectors used as shift operands have to have integer 
element types? This comment gives the impression that only OpenCL vectors need 
to be integers.


Comment at: llvm/tools/clang/lib/Sema/SemaExpr.cpp:8790
@@ -8774,3 +8789,3 @@
   S.Context.getExtVectorType(RHSEleType, LHSVecTy->getNumElements());
 RHS = S.ImpCastExprToType(RHS.get(), VecTy, CK_VectorSplat);
   }

OK. So the rule is that the type of the scalar operand is normally converted to 
the vector element type of the other operand before being transformed to a 
vector, but we don't have to do this when it's used as the RHS (shift amount) 
because IRGen generates the correct IR without the conversion?


Comment at: llvm/tools/clang/test/Sema/vecshift.c:56
@@ +55,3 @@
+
+  vc4 = vc4 << vc8; // expected-error {{vector operands do not have the same 
number of elements}}
+  vi4 = vi4 << vuc8; // expected-error {{vector operands do not have the same 
number of elements}}

I don't think this patch was necessary to have clang print diagnostic "vector 
operands do not have the same number of elements"? If that's the case, I think 
it's better to add these lines in a separate commit.


https://reviews.llvm.org/D24467



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


Re: [PATCH] D24330: Add some MS aliases for existing intrinsics

2016-09-14 Thread Albert Gutowski via cfe-commits
agutowski updated this revision to Diff 71404.
agutowski added a comment.

Fix doxygen comment


https://reviews.llvm.org/D24330

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/Builtins.h
  include/clang/Basic/BuiltinsX86.def
  lib/Basic/Targets.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/emmintrin.h
  lib/Headers/ia32intrin.h
  lib/Headers/intrin.h
  lib/Headers/xmmintrin.h
  lib/Sema/SemaDecl.cpp
  test/CodeGen/builtins-x86.c
  test/Headers/x86intrin.cpp
  test/Sema/implicit-intel-builtin-decl.c
  test/Sema/implicit-ms-builtin-decl.c

Index: lib/Headers/ia32intrin.h
===
--- lib/Headers/ia32intrin.h
+++ lib/Headers/ia32intrin.h
@@ -60,12 +60,6 @@
   return __builtin_ia32_rdpmc(__A);
 }
 
-/* __rdtsc */
-static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
-__rdtsc(void) {
-  return __builtin_ia32_rdtsc();
-}
-
 /* __rdtscp */
 static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
 __rdtscp(unsigned int *__A) {
Index: lib/Headers/emmintrin.h
===
--- lib/Headers/emmintrin.h
+++ lib/Headers/emmintrin.h
@@ -2447,6 +2447,10 @@
 }
 #endif
 
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
 /// \brief The cache line containing __p is flushed and invalidated from all
 ///caches in the coherency domain.
 ///
@@ -2457,11 +2461,7 @@
 /// \param __p
 ///A pointer to the memory location used to identify the cache line to be
 ///flushed.
-static __inline__ void __DEFAULT_FN_ATTRS
-_mm_clflush(void const *__p)
-{
-  __builtin_ia32_clflush(__p);
-}
+void _mm_clflush(void const *);
 
 /// \brief Forces strong memory ordering (serialization) between load
 ///instructions preceding this instruction and load instructions following
@@ -2472,11 +2472,7 @@
 ///
 /// This intrinsic corresponds to the \c LFENCE instruction.
 ///
-static __inline__ void __DEFAULT_FN_ATTRS
-_mm_lfence(void)
-{
-  __builtin_ia32_lfence();
-}
+void _mm_lfence(void);
 
 /// \brief Forces strong memory ordering (serialization) between load and store
 ///instructions preceding this instruction and load and store instructions
@@ -2487,12 +2483,12 @@
 ///
 /// This intrinsic corresponds to the \c MFENCE instruction.
 ///
-static __inline__ void __DEFAULT_FN_ATTRS
-_mm_mfence(void)
-{
-  __builtin_ia32_mfence();
-}
+void _mm_mfence(void);
 
+#if defined(__cplusplus)
+} // extern "C"
+#endif
+
 /// \brief Converts 16-bit signed integers from both 128-bit integer vector
 ///operands into 8-bit signed integers, and packs the results into the
 ///destination. Positive values greater than 0x7F are saturated to 0x7F.
@@ -3213,11 +3209,10 @@
 ///
 /// This intrinsic corresponds to the \c PAUSE instruction.
 ///
-static __inline__ void __DEFAULT_FN_ATTRS
-_mm_pause(void)
-{
-  __builtin_ia32_pause();
-}
+#if defined(__cplusplus)
+extern "C"
+#endif
+void _mm_pause(void);
 
 #undef __DEFAULT_FN_ATTRS
 
Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -463,14 +463,6 @@
   *_Index = 31 - __builtin_clzl(_Mask);
   return 1;
 }
-static __inline__ unsigned short __DEFAULT_FN_ATTRS
-__popcnt16(unsigned short _Value) {
-  return __builtin_popcount((int)_Value);
-}
-static __inline__ unsigned int __DEFAULT_FN_ATTRS
-__popcnt(unsigned int _Value) {
-  return __builtin_popcount(_Value);
-}
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _bittest(long const *_BitBase, long _BitPos) {
   return (*_BitBase >> _BitPos) & 1;
@@ -513,11 +505,6 @@
   *_Index = 63 - __builtin_clzll(_Mask);
   return 1;
 }
-static __inline__
-unsigned __int64 __DEFAULT_FN_ATTRS
-__popcnt64(unsigned __int64 _Value) {
-  return __builtin_popcountll(_Value);
-}
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _bittest64(__int64 const *_BitBase, __int64 _BitPos) {
   return (*_BitBase >> _BitPos) & 1;
@@ -546,63 +533,63 @@
   __atomic_fetch_or(_BitBase, 1ll << _BitPos, __ATOMIC_SEQ_CST);
   return (_PrevVal >> _BitPos) & 1;
 }
-/**\
-|* Interlocked Exchange Add
-\**/
-static __inline__ __int64 __DEFAULT_FN_ATTRS
-_InterlockedExchangeAdd64(__int64 volatile *_Addend, __int64 _Value) {
-	return __atomic_fetch_add(_Addend, _Value, __ATOMIC_SEQ_CST);
-}
-/**\
-|* Interlocked Exchange Sub
-\**/
-static __inline__ __int64 __DEFAULT_FN_ATTRS
-_InterlockedExchangeSub64(__int64 volatile *_Subend, __int64 _Value) {
-	return __atomic_fetch_sub(_Subend, _Value, __ATOMIC_SEQ_CST);
-}
-/**\
-|* Interl

Re: [PATCH] D24330: Add some MS aliases for existing intrinsics

2016-09-14 Thread Albert Gutowski via cfe-commits
agutowski marked an inline comment as done.
agutowski added a comment.

https://reviews.llvm.org/D24330



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


Re: [PATCH] D24470: [analyzer] scan-build-py: Remove relative path hack for SATestsBuild.py

2016-09-14 Thread Devin Coughlin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281516: [analyzer] scan-build-py: Remove relative path hack 
for SATestsBuild.py (authored by dcoughlin).

Changed prior to commit:
  https://reviews.llvm.org/D24470?vs=71046&id=71401#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24470

Files:
  cfe/trunk/tools/scan-build-py/libscanbuild/runner.py
  cfe/trunk/tools/scan-build-py/tests/unit/test_runner.py

Index: cfe/trunk/tools/scan-build-py/tests/unit/test_runner.py
===
--- cfe/trunk/tools/scan-build-py/tests/unit/test_runner.py
+++ cfe/trunk/tools/scan-build-py/tests/unit/test_runner.py
@@ -219,20 +219,6 @@
 self.assertEqual(['-DNDEBUG', '-UNDEBUG'], test(['-DNDEBUG']))
 self.assertEqual(['-DSomething', '-UNDEBUG'], test(['-DSomething']))
 
-def test_set_file_relative_path(self):
-def test(expected, input):
-spy = Spy()
-self.assertEqual(spy.success,
- sut.set_file_path_relative(input, spy.call))
-self.assertEqual(expected, spy.arg['file'])
-
-test('source.c',
- {'file': '/home/me/source.c', 'directory': '/home/me'})
-test('me/source.c',
- {'file': '/home/me/source.c', 'directory': '/home'})
-test('../home/me/source.c',
- {'file': '/home/me/source.c', 'directory': '/tmp'})
-
 def test_set_language_fall_through(self):
 def language(expected, input):
 spy = Spy()
Index: cfe/trunk/tools/scan-build-py/libscanbuild/runner.py
===
--- cfe/trunk/tools/scan-build-py/libscanbuild/runner.py
+++ cfe/trunk/tools/scan-build-py/libscanbuild/runner.py
@@ -205,19 +205,8 @@
 return continuation(opts)
 
 
-@require(['file', 'directory'])
-def set_file_path_relative(opts, continuation=filter_debug_flags):
-""" Set source file path to relative to the working directory.
-
-The only purpose of this function is to pass the SATestBuild.py tests. """
-
-opts.update({'file': os.path.relpath(opts['file'], opts['directory'])})
-
-return continuation(opts)
-
-
 @require(['language', 'compiler', 'file', 'flags'])
-def language_check(opts, continuation=set_file_path_relative):
+def language_check(opts, continuation=filter_debug_flags):
 """ Find out the language from command line parameters or file name
 extension. The decision also influenced by the compiler invocation. """
 


Index: cfe/trunk/tools/scan-build-py/tests/unit/test_runner.py
===
--- cfe/trunk/tools/scan-build-py/tests/unit/test_runner.py
+++ cfe/trunk/tools/scan-build-py/tests/unit/test_runner.py
@@ -219,20 +219,6 @@
 self.assertEqual(['-DNDEBUG', '-UNDEBUG'], test(['-DNDEBUG']))
 self.assertEqual(['-DSomething', '-UNDEBUG'], test(['-DSomething']))
 
-def test_set_file_relative_path(self):
-def test(expected, input):
-spy = Spy()
-self.assertEqual(spy.success,
- sut.set_file_path_relative(input, spy.call))
-self.assertEqual(expected, spy.arg['file'])
-
-test('source.c',
- {'file': '/home/me/source.c', 'directory': '/home/me'})
-test('me/source.c',
- {'file': '/home/me/source.c', 'directory': '/home'})
-test('../home/me/source.c',
- {'file': '/home/me/source.c', 'directory': '/tmp'})
-
 def test_set_language_fall_through(self):
 def language(expected, input):
 spy = Spy()
Index: cfe/trunk/tools/scan-build-py/libscanbuild/runner.py
===
--- cfe/trunk/tools/scan-build-py/libscanbuild/runner.py
+++ cfe/trunk/tools/scan-build-py/libscanbuild/runner.py
@@ -205,19 +205,8 @@
 return continuation(opts)
 
 
-@require(['file', 'directory'])
-def set_file_path_relative(opts, continuation=filter_debug_flags):
-""" Set source file path to relative to the working directory.
-
-The only purpose of this function is to pass the SATestBuild.py tests. """
-
-opts.update({'file': os.path.relpath(opts['file'], opts['directory'])})
-
-return continuation(opts)
-
-
 @require(['language', 'compiler', 'file', 'flags'])
-def language_check(opts, continuation=set_file_path_relative):
+def language_check(opts, continuation=filter_debug_flags):
 """ Find out the language from command line parameters or file name
 extension. The decision also influenced by the compiler invocation. """
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r281516 - [analyzer] scan-build-py: Remove relative path hack for SATestsBuild.py

2016-09-14 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Wed Sep 14 13:14:11 2016
New Revision: 281516

URL: http://llvm.org/viewvc/llvm-project?rev=281516&view=rev
Log:
[analyzer] scan-build-py: Remove relative path hack for SATestsBuild.py

Remove the relative path hack in scan-build-py that converts a fully qualified
directory name and a fully qualified file path to a relative path before running
the analyzer on a file.

This hack is not needed: the bad interaction with SATestsBuild.py it was
intended to address is actually the same underlying problem that r280768 fixed.
Further, because the hack would always relativize paths, it caused
SATestBuild.py to be unable to properly line up issues when the build system
changed directory and then built a source file in a child directory but used a
fully-qualified path for the source file.

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

Modified:
cfe/trunk/tools/scan-build-py/libscanbuild/runner.py
cfe/trunk/tools/scan-build-py/tests/unit/test_runner.py

Modified: cfe/trunk/tools/scan-build-py/libscanbuild/runner.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/libscanbuild/runner.py?rev=281516&r1=281515&r2=281516&view=diff
==
--- cfe/trunk/tools/scan-build-py/libscanbuild/runner.py (original)
+++ cfe/trunk/tools/scan-build-py/libscanbuild/runner.py Wed Sep 14 13:14:11 
2016
@@ -205,19 +205,8 @@ def filter_debug_flags(opts, continuatio
 return continuation(opts)
 
 
-@require(['file', 'directory'])
-def set_file_path_relative(opts, continuation=filter_debug_flags):
-""" Set source file path to relative to the working directory.
-
-The only purpose of this function is to pass the SATestBuild.py tests. """
-
-opts.update({'file': os.path.relpath(opts['file'], opts['directory'])})
-
-return continuation(opts)
-
-
 @require(['language', 'compiler', 'file', 'flags'])
-def language_check(opts, continuation=set_file_path_relative):
+def language_check(opts, continuation=filter_debug_flags):
 """ Find out the language from command line parameters or file name
 extension. The decision also influenced by the compiler invocation. """
 

Modified: cfe/trunk/tools/scan-build-py/tests/unit/test_runner.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/tests/unit/test_runner.py?rev=281516&r1=281515&r2=281516&view=diff
==
--- cfe/trunk/tools/scan-build-py/tests/unit/test_runner.py (original)
+++ cfe/trunk/tools/scan-build-py/tests/unit/test_runner.py Wed Sep 14 13:14:11 
2016
@@ -219,20 +219,6 @@ class AnalyzerTest(unittest.TestCase):
 self.assertEqual(['-DNDEBUG', '-UNDEBUG'], test(['-DNDEBUG']))
 self.assertEqual(['-DSomething', '-UNDEBUG'], test(['-DSomething']))
 
-def test_set_file_relative_path(self):
-def test(expected, input):
-spy = Spy()
-self.assertEqual(spy.success,
- sut.set_file_path_relative(input, spy.call))
-self.assertEqual(expected, spy.arg['file'])
-
-test('source.c',
- {'file': '/home/me/source.c', 'directory': '/home/me'})
-test('me/source.c',
- {'file': '/home/me/source.c', 'directory': '/home'})
-test('../home/me/source.c',
- {'file': '/home/me/source.c', 'directory': '/tmp'})
-
 def test_set_language_fall_through(self):
 def language(expected, input):
 spy = Spy()


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


Re: [PATCH] D22346: [Clang-tidy] CERT-MSC50-CPP (std:rand() )

2016-09-14 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/cert/LimitedRandomnessCheck.cpp:22-23
@@ +21,4 @@
+  Finder->addMatcher(
+  declRefExpr(hasDeclaration(functionDecl(namedDecl(hasName("::rand")),
+  parameterCountIs(0
+  .bind("randomGenerator"),

falho wrote:
> xazax.hun wrote:
> > aaron.ballman wrote:
> > > xazax.hun wrote:
> > > > aaron.ballman wrote:
> > > > > xazax.hun wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > Prazek wrote:
> > > > > > > > aaron.ballman wrote:
> > > > > > > > > Prazek wrote:
> > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > This should be looking at a callExpr() rather than a 
> > > > > > > > > > > declRefExpr(), should it not?
> > > > > > > > > > I was also thinking about this, but this is actually 
> > > > > > > > > > better, because it will also match with binding rand with 
> > > > > > > > > > function pointer.
> > > > > > > > > True, but a DeclRefExpr doesn't mean it's a function call. 
> > > > > > > > > Binding the function is not contrary to the CERT rule, just 
> > > > > > > > > calling it. For instance, the following pathological case 
> > > > > > > > > will be caught by this check:
> > > > > > > > > ```
> > > > > > > > > if (std::rand) {}
> > > > > > > > > ```
> > > > > > > > > The behavior of this check should be consistent with 
> > > > > > > > > cert-env33-c, which only looks at calls. (If we really care 
> > > > > > > > > about bound functions, we'd need flow control analysis, and I 
> > > > > > > > > think that's overkill for both of those checks, but wouldn't 
> > > > > > > > > be opposed to someone writing the flow analysis if they 
> > > > > > > > > really wanted to.)
> > > > > > > > It would indeed fire on this pathological case, but I don't 
> > > > > > > > think we should care about cases like this, because no one is 
> > > > > > > > writing code like this (and if he would then it would probably 
> > > > > > > > be a bug).
> > > > > > > > I don't think that there is much code that binds pointer to 
> > > > > > > > std::rand either, but I think it would be good to display 
> > > > > > > > warning for this, because even if the function would be never 
> > > > > > > > called, then it means that this is a bug, and if it would be 
> > > > > > > > called then it would be nice to tell user that rand might be 
> > > > > > > > used here.
> > > > > > > > 
> > > > > > > > Anyway I don't oppose for changing it to callExpr, but I think 
> > > > > > > > it is better this way.
> > > > > > > > It would indeed fire on this pathological case, but I don't 
> > > > > > > > think we should care about cases like this, because no one is 
> > > > > > > > writing code like this (and if he would then it would probably 
> > > > > > > > be a bug).
> > > > > > > 
> > > > > > > It would be a known false-positive for a check designed to 
> > > > > > > conform to a particular coding standard. When deviations have 
> > > > > > > come up in the past for various coding standards, we've added an 
> > > > > > > option to enable the additional functionality, which I don't 
> > > > > > > think would be reasonable in this case. Alternatively, the CERT 
> > > > > > > guideline could be modified, but that is unlikely to occur 
> > > > > > > because binding the function pointer is not a security concern 
> > > > > > > (only calling the function).
> > > > > > In case you let binding to function pointer you introduce potential 
> > > > > > false negatives which is worse in this case in my opinion. 
> > > > > Basically: this half-measure is sufficient for the CERT coding rule, 
> > > > > but isn't ideal. The ideal check isn't likely to uncover many more 
> > > > > cases than the half-measure, which is why it was not implemented in 
> > > > > the past. If someone wants to implement the whole-measure, that's 
> > > > > great! But implementing a half, half-measure that isn't consistent 
> > > > > with other, similar checks is the wrong thing to do.
> > > > You can not implement an ideal checker. In general, it is undecidable 
> > > > whether std::rand is called or not. (You can easily create an example 
> > > > where you would need to solve the halting problem in order to decide 
> > > > whether std::rand is called.)
> > > > 
> > > > Since the ideal checker is infeasible the question is whether you are 
> > > > OK with false positives or false negatives. The approach you are 
> > > > suggesting result in false negatives. The current approach results in 
> > > > false positives. I think, for this security checker, a false positive 
> > > > is much less serious to have than a false negative. Moreover, I doubt 
> > > > that people write code where such false positives are intended and the 
> > > > code should not be changed. But in case you can think of an example, 
> > > > please let us know.
> > > > You can not implement an ideal checker. In general, it is undecidable 
> > > > whether s

Re: [PATCH] D24526: [Release notes] Mention readability-container-size-empty improvements

2016-09-14 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281510: [Release notes] Mention 
readability-container-size-empty improvements. (authored by eugenezelenko).

Changed prior to commit:
  https://reviews.llvm.org/D24526?vs=71250&id=71394#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24526

Files:
  clang-tools-extra/trunk/docs/ReleaseNotes.rst

Index: clang-tools-extra/trunk/docs/ReleaseNotes.rst
===
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst
@@ -95,6 +95,11 @@
   Warns about the performance overhead arising from concatenating strings using
   the ``operator+``, instead of ``operator+=``.
 
+- `readability-container-size-empty
+  
`_
 check
+  supports arbitrary containers with with suitable ``empty()`` and ``size()``
+  methods.
+
 - New `readability-misplaced-array-index
   
`_
 check
 


Index: clang-tools-extra/trunk/docs/ReleaseNotes.rst
===
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst
@@ -95,6 +95,11 @@
   Warns about the performance overhead arising from concatenating strings using
   the ``operator+``, instead of ``operator+=``.
 
+- `readability-container-size-empty
+  `_ check
+  supports arbitrary containers with with suitable ``empty()`` and ``size()``
+  methods.
+
 - New `readability-misplaced-array-index
   `_ check
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r281510 - [Release notes] Mention readability-container-size-empty improvements.

2016-09-14 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Wed Sep 14 12:41:51 2016
New Revision: 281510

URL: http://llvm.org/viewvc/llvm-project?rev=281510&view=rev
Log:
[Release notes] Mention readability-container-size-empty improvements.

Differential revision: https://reviews.llvm.org/D24526

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=281510&r1=281509&r2=281510&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Wed Sep 14 12:41:51 2016
@@ -95,6 +95,11 @@ Improvements to clang-tidy
   Warns about the performance overhead arising from concatenating strings using
   the ``operator+``, instead of ``operator+=``.
 
+- `readability-container-size-empty
+  
`_
 check
+  supports arbitrary containers with with suitable ``empty()`` and ``size()``
+  methods.
+
 - New `readability-misplaced-array-index
   
`_
 check
 


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


Re: [PATCH] D24526: [Release notes] Mention readability-container-size-empty improvements

2016-09-14 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added inline comments.


Comment at: docs/ReleaseNotes.rst:94
@@ +93,3 @@
+  
`_
 check
+  supports arbitrary containers with ``empty()`` and ``size()`` methods.
+

alexfh wrote:
> The wording is a bit too broad. We should somehow hint that the methods are 
> not just arbitrary. Maybe "with suitable ``size()`` and ``empty()`` methods"?
Will fix on commit. **Suitable** sounds good enough since link to documentation 
is provided, where more details could be found.


Repository:
  rL LLVM

https://reviews.llvm.org/D24526



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


Re: [PATCH] D24513: [AMDGPU] Expose flat work group size, register and wave control attributes

2016-09-14 Thread Aaron Ballman via cfe-commits
aaron.ballman requested changes to this revision.
This revision now requires changes to proceed.


Comment at: include/clang/Basic/Attr.td:1054-1056
@@ -1058,3 +1053,5 @@
+//
 // FIXME: This should be for OpenCLKernelFunction, but is not to
 // workaround needing to see kernel attribute before others to know if
 // this should be rejected on non-kernels.
+

This FIXME is now detached from what "this" is referring to. Can you clarify by 
mentioning that the Subjects list is what should be modified?


Comment at: include/clang/Basic/Attr.td:1067
@@ +1066,3 @@
+  let Spellings = [GNU<"amdgpu_waves_per_eu">];
+  let Args = [UnsignedArgument<"Min">, VariadicUnsignedArgument<"Max">];
+  let Documentation = [AMDGPUWavesPerEUDocs];

Looking at the documentation, are you sure this should be a 
`VariadicUnsignedArgument`? It seems like this should be an `UnsignedArgument` 
with the optional bit set. Or can you pass multiple Max values?


Comment at: include/clang/Basic/AttrDocs.td:1138
@@ +1137,3 @@
+ wavefronts are able to fit within the resources of an EU. Requesting
+more wavefronts can  hide memory latency but limits available registers which
+can result in spilling. Requesting fewer wavefronts can help reduce cache

There's an extra space between "can" and "hide".


Comment at: include/clang/Basic/AttrDocs.td:1144
@@ +1143,3 @@
+to ensure it is capable of meeting the requested values. However, when the
+kernel is executed there may be other reasons that prevent meeting the request,
+for example, there may be wavefronts from other kernels executing on the EU.

Comma after "executed".


Comment at: include/clang/Basic/AttrDocs.td:1147
@@ +1146,3 @@
+
+The error will be given if:
+  - Specified values violate subtarget specifications;

An error instead of The error.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2385
@@ -2384,1 +2384,3 @@
+def err_attribute_argument_invalid : Error<
+  "%0 attribute parameter is invalid: %1">;
 def err_attribute_argument_is_zero : Error<

I think this should say the attribute argument is invalid, rather than the 
attribute parameter.


Comment at: lib/CodeGen/TargetInfo.cpp:6958
@@ +6957,3 @@
+
+  if (const auto Attr = FD->getAttr()) {
+unsigned Min = Attr->getMin();

Should be `const auto *Attr`.


Comment at: lib/CodeGen/TargetInfo.cpp:6967-6969
@@ +6966,5 @@
+  F->addFnAttr("amdgpu-flat-work-group-size", AttrVal);
+} else {
+  assert(Max == 0 && "Max must be zero");
+}
+  }

Elide braces?


Comment at: lib/CodeGen/TargetInfo.cpp:6972
@@ +6971,3 @@
+
+  if (const auto Attr = FD->getAttr()) {
+unsigned Min = Attr->getMin();

`const auto *` here as well.


Comment at: lib/CodeGen/TargetInfo.cpp:6983-6985
@@ -6961,1 +6982,5 @@
+  F->addFnAttr("amdgpu-waves-per-eu", AttrVal);
+} else {
+  assert(Max == 0 && "Max must be zero");
+}
   }

Elide braces?


Comment at: lib/CodeGen/TargetInfo.cpp:6995
@@ +6994,3 @@
+
+  if (const auto Attr = FD->getAttr()) {
+uint32_t NumVGPR = Attr->getNumVGPR();

`const auto *` here as well.


Comment at: lib/Sema/SemaDeclAttr.cpp:4947
@@ +4946,3 @@
+  uint32_t Min = 0;
+  Expr *MinExpr = static_cast(Attr.getArgAsExpr(0));
+  if (!checkUInt32Argument(S, Attr, MinExpr, Min))

I don't think this case is required (here, or elsewhere). `getArgAsExpr()` 
already returns an `Expr *`.


Comment at: lib/Sema/SemaDeclAttr.cpp:4959-4960
@@ +4958,4 @@
+  << Attr.getName()
+  << "maximum flat work-group size must be zero since minimum flat "
+ "work-group size is zero";
+return;

Please include this text in the diagnostic rather than hard-coding it here. You 
can use `%select` to differentiate between different text snippets in the 
diagnostic, and the diagnostic doesn't need to continue to try to be generic. 
Same comment applies elsewhere.


Comment at: lib/Sema/SemaDeclAttr.cpp:4988
@@ +4987,3 @@
+  return;
+  }
+

This will change if you use the optional bit rather than a variadic argument, 
but this silently eats attributes that have more than two arguments, which is 
not a good user experience.


Comment at: lib/Sema/SemaDeclAttr.cpp:6048
@@ -5976,2 +6047,3 @@
   D->setInvalidDecl();
-} else if (Attr *A = D->getAttr()) {
+} else if (Attr *A = D->getAttr()) {
+  Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)

This list is getting to the point where we really need to start handling this 
in Attr.td soon. Are you planning to work on more AMDGPU attributes in the near 
future?

=

r281509 - Convert finite to builtin

2016-09-14 Thread Dehao Chen via cfe-commits
Author: dehao
Date: Wed Sep 14 12:34:14 2016
New Revision: 281509

URL: http://llvm.org/viewvc/llvm-project?rev=281509&view=rev
Log:
Convert finite to builtin

Summary: This patch converts finite/__finite to builtin functions so that it 
will be inlined by compiler.

Reviewers: hfinkel, davidxl, efriedma

Subscribers: efriedma, llvm-commits

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

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

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=281509&r1=281508&r2=281509&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Wed Sep 14 12:34:14 2016
@@ -937,6 +937,14 @@ LIBBUILTIN(fabs, "dd", "fnc", "math.h",
 LIBBUILTIN(fabsf, "ff", "fnc", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(fabsl, "LdLd", "fnc", "math.h", ALL_LANGUAGES)
 
+LIBBUILTIN(finite, "id", "fnc", "math.h", GNU_LANG)
+LIBBUILTIN(finitef, "if", "fnc", "math.h", GNU_LANG)
+LIBBUILTIN(finitel, "iLd", "fnc", "math.h", GNU_LANG)
+// glibc's math.h generates calls to __finite
+LIBBUILTIN(__finite, "id", "fnc", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(__finitef, "if", "fnc", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(__finitel, "iLd", "fnc", "math.h", ALL_LANGUAGES)
+
 LIBBUILTIN(fmod, "ddd", "fne", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(fmodf, "fff", "fne", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(fmodl, "LdLdLd", "fne", "math.h", ALL_LANGUAGES)

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=281509&r1=281508&r2=281509&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Sep 14 12:34:14 2016
@@ -903,6 +903,12 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType(;
   }
 
+  case Builtin::BIfinite:
+  case Builtin::BI__finite:
+  case Builtin::BIfinitef:
+  case Builtin::BI__finitef:
+  case Builtin::BIfinitel:
+  case Builtin::BI__finitel:
   case Builtin::BI__builtin_isinf:
   case Builtin::BI__builtin_isfinite: {
 // isinf(x)--> fabs(x) == infinity

Modified: cfe/trunk/test/CodeGen/builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins.c?rev=281509&r1=281508&r2=281509&view=diff
==
--- cfe/trunk/test/CodeGen/builtins.c (original)
+++ cfe/trunk/test/CodeGen/builtins.c Wed Sep 14 12:34:14 2016
@@ -220,6 +220,10 @@ void test_float_builtins(float F, double
   // CHECK: call float @llvm.fabs.f32(float
   // CHECK: fcmp one float {{.*}}, 0x7FF0
 
+  res = finite(D);
+  // CHECK: call double @llvm.fabs.f64(double
+  // CHECK: fcmp one double {{.*}}, 0x7FF0
+
   res = __builtin_isnormal(F);
   // CHECK: fcmp oeq float
   // CHECK: call float @llvm.fabs.f32(float


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


[PATCH] D24574: clang-format: [JS] ASI insertion after boolean literals.

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

Before when a semicolon was missing after a boolean literal:
a = true
return 1;

clang-format would parse this as one line and format as:
a = true return 1;

It turns out that C++ does not consider `true` and `false` to be literals, we
have to check for that explicitly.

https://reviews.llvm.org/D24574

Files:
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -747,6 +747,14 @@
   "String");
   verifyFormat("function f(@Foo bar) {}", "function f(@Foo\n"
   "  bar) {}");
+  verifyFormat("a = true\n"
+   "return 1",
+   "a = true\n"
+   "  return   1");
+  verifyFormat("a = 'true'\n"
+   "return 1",
+   "a = 'true'\n"
+   "  return   1");
 }
 
 TEST_F(FormatTestJS, ClosureStyleCasts) {
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -681,7 +681,9 @@
 
 static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords,
  const FormatToken *FormatTok) {
-  return FormatTok->Tok.isLiteral() || mustBeJSIdent(Keywords, FormatTok);
+  return FormatTok->Tok.isLiteral() ||
+ FormatTok->isOneOf(tok::kw_true, tok::kw_false) ||
+ mustBeJSIdent(Keywords, FormatTok);
 }
 
 // isJSDeclOrStmt returns true if |FormatTok| starts a declaration or statement


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -747,6 +747,14 @@
   "String");
   verifyFormat("function f(@Foo bar) {}", "function f(@Foo\n"
   "  bar) {}");
+  verifyFormat("a = true\n"
+   "return 1",
+   "a = true\n"
+   "  return   1");
+  verifyFormat("a = 'true'\n"
+   "return 1",
+   "a = 'true'\n"
+   "  return   1");
 }
 
 TEST_F(FormatTestJS, ClosureStyleCasts) {
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -681,7 +681,9 @@
 
 static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords,
  const FormatToken *FormatTok) {
-  return FormatTok->Tok.isLiteral() || mustBeJSIdent(Keywords, FormatTok);
+  return FormatTok->Tok.isLiteral() ||
+ FormatTok->isOneOf(tok::kw_true, tok::kw_false) ||
+ mustBeJSIdent(Keywords, FormatTok);
 }
 
 // isJSDeclOrStmt returns true if |FormatTok| starts a declaration or statement
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24513: [AMDGPU] Expose flat work group size, register and wave control attributes

2016-09-14 Thread Konstantin Zhuravlyov via cfe-commits
kzhuravl updated this revision to Diff 71382.
kzhuravl added a comment.

Fix minor typos


https://reviews.llvm.org/D24513

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenOpenCL/amdgpu-attrs.cl
  test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
  test/SemaCUDA/amdgpu-attrs.cu
  test/SemaCUDA/amdgpu-num-gpr-attr.cu
  test/SemaOpenCL/amdgpu-attrs.cl
  test/SemaOpenCL/amdgpu-num-register-attrs.cl

Index: test/SemaOpenCL/amdgpu-num-register-attrs.cl
===
--- test/SemaOpenCL/amdgpu-num-register-attrs.cl
+++ test/SemaOpenCL/amdgpu-num-register-attrs.cl
@@ -1,40 +0,0 @@
-// RUN: %clang_cc1 -triple r600-- -verify -fsyntax-only %s
-
-typedef __attribute__((amdgpu_num_vgpr(128))) struct FooStruct { // expected-error {{'amdgpu_num_vgpr' attribute only applies to kernel functions}}
-  int x;
-  float y;
-} FooStruct;
-
-
-__attribute__((amdgpu_num_vgpr("ABC"))) kernel void foo2() {} // expected-error {{'amdgpu_num_vgpr' attribute requires an integer constant}}
-__attribute__((amdgpu_num_sgpr("ABC"))) kernel void foo3() {} // expected-error {{'amdgpu_num_sgpr' attribute requires an integer constant}}
-
-
-__attribute__((amdgpu_num_vgpr(40))) void foo4() {} // expected-error {{'amdgpu_num_vgpr' attribute only applies to kernel functions}}
-__attribute__((amdgpu_num_sgpr(64))) void foo5() {} // expected-error {{'amdgpu_num_sgpr' attribute only applies to kernel functions}}
-
-__attribute__((amdgpu_num_vgpr(40))) kernel void foo7() {}
-__attribute__((amdgpu_num_sgpr(64))) kernel void foo8() {}
-__attribute__((amdgpu_num_vgpr(40), amdgpu_num_sgpr(64))) kernel void foo9() {}
-
-// Check 0 VGPR is accepted.
-__attribute__((amdgpu_num_vgpr(0))) kernel void foo10() {}
-
-// Check 0 SGPR is accepted.
-__attribute__((amdgpu_num_sgpr(0))) kernel void foo11() {}
-
-// Check both 0 SGPR and VGPR is accepted.
-__attribute__((amdgpu_num_vgpr(0), amdgpu_num_sgpr(0))) kernel void foo12() {}
-
-// Too large VGPR value.
-__attribute__((amdgpu_num_vgpr(4294967296))) kernel void foo13() {} // expected-error {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
-
-__attribute__((amdgpu_num_sgpr(4294967296))) kernel void foo14() {} // expected-error {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
-
-__attribute__((amdgpu_num_sgpr(4294967296), amdgpu_num_vgpr(4294967296))) kernel void foo15() {} // expected-error 2 {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
-
-
-// Make sure it is accepted with kernel keyword before the attribute.
-kernel __attribute__((amdgpu_num_vgpr(40))) void foo16() {}
-
-kernel __attribute__((amdgpu_num_sgpr(40))) void foo17() {}
Index: test/SemaOpenCL/amdgpu-attrs.cl
===
--- test/SemaOpenCL/amdgpu-attrs.cl
+++ test/SemaOpenCL/amdgpu-attrs.cl
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -triple amdgcn-- -verify -fsyntax-only %s
+
+typedef __attribute__((amdgpu_flat_work_group_size(32, 64))) struct struct_flat_work_group_size_32_64 { // expected-error {{'amdgpu_flat_work_group_size' attribute only applies to kernel functions}}
+  int x;
+  float y;
+} struct_flat_work_group_size_32_64;
+typedef __attribute__((amdgpu_waves_per_eu(2))) struct struct_waves_per_eu_2 { // expected-error {{'amdgpu_waves_per_eu' attribute only applies to kernel functions}}
+  int x;
+  float y;
+} struct_waves_per_eu_2;
+typedef __attribute__((amdgpu_waves_per_eu(2, 4))) struct struct_waves_per_eu_2_4 { // expected-error {{'amdgpu_waves_per_eu' attribute only applies to kernel functions}}
+  int x;
+  float y;
+} struct_waves_per_eu_2_4;
+typedef __attribute__((amdgpu_num_sgpr(32))) struct struct_num_sgpr_32 { // expected-error {{'amdgpu_num_sgpr' attribute only applies to kernel functions}}
+  int x;
+  float y;
+} struct_num_sgpr_32;
+typedef __attribute__((amdgpu_num_vgpr(64))) struct struct_num_vgpr_64 { // expected-error {{'amdgpu_num_vgpr' attribute only applies to kernel functions}}
+  int x;
+  float y;
+} struct_num_vgpr_64;
+
+__attribute__((amdgpu_flat_work_group_size(32, 64))) void func_flat_work_group_size_32_64() {} // expected-error {{'amdgpu_flat_work_group_size' attribute only applies to kernel functions}}
+__attribute__((amdgpu_waves_per_eu(2))) void func_waves_per_eu_2() {} // expected-error {{'amdgpu_waves_per_eu' attribute only applies to kernel functions}}
+__attribute__((amdgpu_waves_per_eu(2, 4))) void func_waves_per_eu_2_4() {} // expected-error {{'amdgpu_waves_per_eu' attribute only applies to kernel functions}}
+__attribute__((amdgpu_num_sgpr(32))) void func_num_sgpr_32() {} // expected-error {{'amdgpu_num_sgpr' attribute only applies to kernel functi

[PATCH] D24573: [CUDA] Do a better job at detecting wrong-side calls.

2016-09-14 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: rsmith.
jlebar added subscribers: tra, cfe-commits.

Move CheckCUDACall from ActOnCallExpr and BuildDeclRefExpr to
DiagnoseUseOfDecl.  This lets us catch some edge cases we were missing,
specifically around class operators.

This necessitates a few other changes:

 - Avoid emitting duplicate deferred diags in CheckCUDACall.

   Previously we'd carefully placed our call to CheckCUDACall such that
   it would only ever run once for a particular callsite.  But now this
   isn't the case.

 - Emit deferred diagnostics from a template
   specialization/instantiation's primary template, in addition to from
   the specialization/instantiation itself.  DiagnoseUseOfDecl ends up
   putting the deferred diagnostics on the template, rather than the
   specialization, so we need to check both.

https://reviews.llvm.org/D24573

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCUDA/Inputs/cuda.h
  clang/test/SemaCUDA/call-host-fn-from-device.cu

Index: clang/test/SemaCUDA/call-host-fn-from-device.cu
===
--- clang/test/SemaCUDA/call-host-fn-from-device.cu
+++ clang/test/SemaCUDA/call-host-fn-from-device.cu
@@ -12,6 +12,9 @@
 // expected-note@-4 {{'host_fn' declared here}}
 // expected-note@-5 {{'host_fn' declared here}}
 // expected-note@-6 {{'host_fn' declared here}}
+// expected-note@-7 {{'host_fn' declared here}}
+
+struct Dummy {};
 
 struct S {
   S() {}
@@ -34,6 +37,15 @@
 
   void h() {}
   // expected-note@-1 {{'h' declared here}}
+
+  void operator+();
+  // expected-note@-1 {{'operator+' declared here}}
+
+  void operator-(const T&) {}
+  // expected-note@-1 {{'operator-' declared here}}
+
+  operator Dummy() { return Dummy(); }
+  // expected-note@-1 {{'operator Dummy' declared here}}
 };
 
 __host__ __device__ void T::hd3() {
@@ -92,3 +104,30 @@
 __host__ __device__ void fn_ptr_template() {
   auto* ptr = &host_fn;  // Not an error because the template isn't instantiated.
 }
+
+__host__ __device__ void unaryOp() {
+  T t;
+  (void) +t; // expected-error {{reference to __host__ function 'operator+' in __host__ __device__ function}}
+}
+
+__host__ __device__ void binaryOp() {
+  T t;
+  (void) (t - t); // expected-error {{reference to __host__ function 'operator-' in __host__ __device__ function}}
+}
+
+__host__ __device__ void implicitConversion() {
+  T t;
+  Dummy d = t; // expected-error {{reference to __host__ function 'operator Dummy' in __host__ __device__ function}}
+}
+
+template 
+struct TmplStruct {
+  template  __host__ __device__ void fn() {}
+};
+
+template <>
+template <>
+__host__ __device__ void TmplStruct::fn() { host_fn(); }
+// expected-error@-1 {{reference to __host__ function 'host_fn' in __host__ __device__ function}}
+
+__device__ void double_specialization() { TmplStruct().fn(); }
Index: clang/test/SemaCUDA/Inputs/cuda.h
===
--- clang/test/SemaCUDA/Inputs/cuda.h
+++ clang/test/SemaCUDA/Inputs/cuda.h
@@ -22,7 +22,9 @@
 int cudaConfigureCall(dim3 gridSize, dim3 blockSize, size_t sharedSize = 0,
   cudaStream_t stream = 0);
 
-// Device-side placement new overloads.
+// Host- and device-side placement new overloads.
+void *operator new(__SIZE_TYPE__, void *p) { return p; }
+void *operator new[](__SIZE_TYPE__, void *p) { return p; }
 __device__ void *operator new(__SIZE_TYPE__, void *p) { return p; }
 __device__ void *operator new[](__SIZE_TYPE__, void *p) { return p; }
 
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -374,6 +374,9 @@
 if (getLangOpts().CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
 DeduceReturnType(FD, Loc))
   return true;
+
+if (getLangOpts().CUDA && !CheckCUDACall(Loc, FD))
+  return true;
   }
 
   // [OpenMP 4.0], 2.15 declare reduction Directive, Restrictions
@@ -1743,11 +1746,6 @@
const DeclarationNameInfo &NameInfo,
const CXXScopeSpec *SS, NamedDecl *FoundD,
const TemplateArgumentListInfo *TemplateArgs) {
-  if (getLangOpts().CUDA)
-if (FunctionDecl *Callee = dyn_cast(D))
-  if (!CheckCUDACall(NameInfo.getLoc(), Callee))
-return ExprError();
-
   bool RefersToCapturedVariable =
   isa(D) &&
   NeedToCaptureVariable(cast(D), NameInfo.getLoc());
@@ -5140,35 +5138,36 @@
   return Callee->getMinRequiredArguments() <= NumArgs;
 }
 
-static ExprResult ActOnCallExprImpl(Sema &S, Scope *Scope, Expr *Fn,
-SourceLocation LParenLoc,
-MultiExprArg ArgExprs,
-SourceLocation RParenLoc, Expr *ExecConfig,
-   

[PATCH] D24572: [clang-tidy] Clean up code after applying replacements.

2016-09-14 Thread Alexander Kornienko via cfe-commits
alexfh created this revision.
alexfh added reviewers: ioeric, hokein.
alexfh added a subscriber: cfe-commits.

Remove empty namespaces and initializer list commas / colons in
affected ranges. A strawman patch: proper options for enabling the cleanup and
specifying the format style are needed.

https://reviews.llvm.org/D24572

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  test/clang-tidy/clean-up-code.cpp
  test/clang-tidy/fix.cpp
  test/clang-tidy/google-readability-namespace-comments.cpp

Index: test/clang-tidy/google-readability-namespace-comments.cpp
===
--- test/clang-tidy/google-readability-namespace-comments.cpp
+++ test/clang-tidy/google-readability-namespace-comments.cpp
@@ -4,7 +4,7 @@
 namespace n2 {
 
 
-
+void f(); // So that the namespace isn't empty.
 
 
 // CHECK-MESSAGES: :[[@LINE+4]]:2: warning: namespace 'n2' not terminated with a closing comment [google-readability-namespace-comments]
Index: test/clang-tidy/fix.cpp
===
--- test/clang-tidy/fix.cpp
+++ test/clang-tidy/fix.cpp
@@ -5,6 +5,7 @@
 // RUN: FileCheck -input-file=%t.yaml -check-prefix=CHECK-YAML %s
 
 namespace i {
+void f(); // So that the namespace isn't empty.
 }
 // CHECK: } // namespace i
 // CHECK-MESSAGES: note: FIX-IT applied suggested code changes
Index: test/clang-tidy/clean-up-code.cpp
===
--- /dev/null
+++ test/clang-tidy/clean-up-code.cpp
@@ -0,0 +1,12 @@
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t
+namespace a { class A {}; }
+namespace b {
+using a::A;
+}
+namespace c {}
+// CHECK-MESSAGES: :[[@LINE-3]]:10: warning: using decl 'A' is unused [misc-unused-using-decls]
+// CHECK-FIXES: {{^namespace a { class A {}; }$}}
+// CHECK-FIXES-NOT: namespace
+// CHECK-FIXES: {{^namespace c {}$}}
+// FIXME: cleanupAroundReplacements leaves whitespace. Otherwise we could just
+// check the next line.
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -79,12 +79,13 @@
 
   tooling::Replacement Replacement(SM, Range, FixIt.CodeToInsert);
   llvm::Error Err = Error.Fix[Replacement.getFilePath()].add(Replacement);
-  // FIXME: better error handling.
+  // FIXME: better error handling (at least, don't let other replacements be
+  // applied).
   if (Err) {
 llvm::errs() << "Fix conflicts with existing fix! "
 << llvm::toString(std::move(Err)) << "\n";
+assert(false && "Fix conflicts with existing fix!");
   }
-  assert(!Err && "Fix conflicts with existing fix!");
 }
   }
 
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -22,6 +22,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Format/Format.h"
 #include "clang/Frontend/ASTConsumers.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendActions.h"
@@ -101,9 +102,8 @@
 DiagPrinter(new TextDiagnosticPrinter(llvm::outs(), &*DiagOpts)),
 Diags(IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts,
   DiagPrinter),
-SourceMgr(Diags, Files), Rewrite(SourceMgr, LangOpts),
-ApplyFixes(ApplyFixes), TotalFixes(0), AppliedFixes(0),
-WarningsAsErrors(0) {
+SourceMgr(Diags, Files), ApplyFixes(ApplyFixes), TotalFixes(0),
+AppliedFixes(0), WarningsAsErrors(0) {
 DiagOpts->ShowColors = llvm::sys::Process::StandardOutHasColors();
 DiagPrinter->BeginSourceFile(LangOpts);
   }
@@ -127,31 +127,56 @@
   auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0 [%1]"))
   << Message.Message << Name;
   for (const auto &FileAndReplacements : Error.Fix) {
-for (const auto &Replacement : FileAndReplacements.second) {
+for (const auto &Repl : FileAndReplacements.second) {
   // Retrieve the source range for applicable fixes. Macro definitions
   // on the command line have locations in a virtual buffer and don't
   // have valid file paths and are therefore not applicable.
   SourceRange Range;
   SourceLocation FixLoc;
-  if (Replacement.isApplicable()) {
-SmallString<128> FixAbsoluteFilePath = Replacement.getFilePath();
+  ++TotalFixes;
+  bool CanBeApplied = false;
+  if (Repl.isApplicable()) {
+SmallString<128> FixAbsoluteFilePath = Repl.getFilePath();
 Files.makeAbsolutePath(FixAbsoluteFilePath);
-FixLoc = getLocation(FixAbsoluteFilePath, Replacement.getOffset());
+if (Appl

[PATCH] D24571: [CUDA] Disallow overloading destructors.

2016-09-14 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: rsmith.
jlebar added subscribers: tra, cfe-commits.

We'd attempted to allow this, but turns out we were doing a very bad
job.  :)

Making this work properly would be a giant change in clang.  For
example, we'd need to make CXXRecordDecl::getDestructor()
context-sensitive, because the destructor you end up with depends on
where you're calling it from.

For now (and hopefully for ever), just disallow overloading of
destructors in CUDA.

https://reviews.llvm.org/D24571

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CodeGenCUDA/function-overload.cu
  clang/test/SemaCUDA/call-overloaded-destructor.cu
  clang/test/SemaCUDA/function-overload.cu
  clang/test/SemaCUDA/no-destructor-overload.cu

Index: clang/test/SemaCUDA/no-destructor-overload.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/no-destructor-overload.cu
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fcuda-is-device -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+// We don't allow destructors to be overloaded.  Making this work would be a
+// giant change to clang, and the use cases seem quite limited.
+
+struct A {
+  ~A() {} // expected-note {{previous declaration is here}}
+  __device__ ~A() {} // expected-error {{destructor cannot be redeclared}}
+};
+
+struct B {
+  __host__ ~B() {} // expected-note {{previous declaration is here}}
+  __host__ __device__ ~B() {} // expected-error {{destructor cannot be redeclared}}
+};
+
+struct C {
+  __host__ __device__ ~C() {} // expected-note {{previous declaration is here}}
+  __host__ ~C() {} // expected-error {{destructor cannot be redeclared}}
+};
+
+struct D {
+  __device__ ~D() {} // expected-note {{previous declaration is here}}
+  __host__ __device__ ~D() {} // expected-error {{destructor cannot be redeclared}}
+};
+
+struct E {
+  __host__ __device__ ~E() {} // expected-note {{previous declaration is here}}
+  __device__ ~E() {} // expected-error {{destructor cannot be redeclared}}
+};
+
Index: clang/test/SemaCUDA/function-overload.cu
===
--- clang/test/SemaCUDA/function-overload.cu
+++ clang/test/SemaCUDA/function-overload.cu
@@ -210,44 +210,11 @@
   __host__ ~d_h() {} // expected-error {{destructor cannot be redeclared}}
 };
 
-// H/D overloading is OK
-struct d_dh {
-  __device__ ~d_dh() {}
-  __host__ ~d_dh() {}
-};
-
 // HD is OK
 struct d_hd {
   __host__ __device__ ~d_hd() {}
 };
 
-// Mixing H/D and HD is not allowed.
-struct d_dhhd {
-  __device__ ~d_dhhd() {}
-  __host__ ~d_dhhd() {} // expected-note {{previous declaration is here}}
-  __host__ __device__ ~d_dhhd() {} // expected-error {{destructor cannot be redeclared}}
-};
-
-struct d_hhd {
-  __host__ ~d_hhd() {} // expected-note {{previous declaration is here}}
-  __host__ __device__ ~d_hhd() {} // expected-error {{destructor cannot be redeclared}}
-};
-
-struct d_hdh {
-  __host__ __device__ ~d_hdh() {} // expected-note {{previous declaration is here}}
-  __host__ ~d_hdh() {} // expected-error {{destructor cannot be redeclared}}
-};
-
-struct d_dhd {
-  __device__ ~d_dhd() {} // expected-note {{previous declaration is here}}
-  __host__ __device__ ~d_dhd() {} // expected-error {{destructor cannot be redeclared}}
-};
-
-struct d_hdd {
-  __host__ __device__ ~d_hdd() {} // expected-note {{previous declaration is here}}
-  __device__ ~d_hdd() {} // expected-error {{destructor cannot be redeclared}}
-};
-
 // Test overloading of member functions
 struct m_h {
   void operator delete(void *ptr); // expected-note {{previous declaration is here}}
Index: clang/test/SemaCUDA/call-overloaded-destructor.cu
===
--- clang/test/SemaCUDA/call-overloaded-destructor.cu
+++ /dev/null
@@ -1,17 +0,0 @@
-// expected-no-diagnostics
-
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fsyntax-only -fcuda-is-device -verify %s
-
-#include "Inputs/cuda.h"
-
-struct S {
-  __host__ ~S() {}
-  __device__ ~S() {}
-};
-
-__host__ __device__ void test() {
-  S s;
-  // This should not crash clang.
-  s.~S();
-}
Index: clang/test/CodeGenCUDA/function-overload.cu
===
--- clang/test/CodeGenCUDA/function-overload.cu
+++ clang/test/CodeGenCUDA/function-overload.cu
@@ -16,8 +16,6 @@
 struct s_cd_dh {
   __host__ s_cd_dh() { x = 11; }
   __device__ s_cd_dh() { x = 12; }
-  __host__ ~s_cd_dh() { x = 21; }
-  __device__ ~s_cd_dh() { x = 22; }
 };
 
 struct s_cd_hd {
@@ -38,7 +36,6 @@
   // CHECK-BOTH: call void @_ZN7s_cd_hdC1Ev
 
   // CHECK-BOTH: call void @_ZN7s_cd_hdD1Ev(
-  // CHECK-BOTH: call void @_ZN7s_cd_dhD1Ev(
 }
 // CHECK-BOTH: ret void
 
@@ -56,8 +53,3 @@
 // CHECK-BOTH: define linkonce_odr void @_ZN7s_cd_hdD2Ev(
 // CHECK-BOTH: store i

Re: [PATCH] D21506: [analyzer] Block in critical section

2016-09-14 Thread Zoltán Dániel Török via cfe-commits
zdtorok added a comment.

You are right NoQ, thank you for the remark, I've upload a new diff containing 
a fix for the integer underflow case.


Repository:
  rL LLVM

https://reviews.llvm.org/D21506



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


Re: [PATCH] D21506: [analyzer] Block in critical section

2016-09-14 Thread Zoltán Dániel Török via cfe-commits
zdtorok updated this revision to Diff 71375.
zdtorok added a comment.
Herald added subscribers: mgorny, beanz.

Fixed possible integer-underflow in case of unexpected unlocking function. Also 
added test for this.


Repository:
  rL LLVM

https://reviews.llvm.org/D21506

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  test/Analysis/block-in-critical-section.cpp

Index: test/Analysis/block-in-critical-section.cpp
===
--- /dev/null
+++ test/Analysis/block-in-critical-section.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.unix.BlockInCriticalSection -std=c++11 -verify %s
+
+void sleep(int x) {}
+
+namespace std {
+struct mutex {
+  void lock() {}
+  void unlock() {}
+};
+}
+
+void testBlockInCriticalSection() {
+  std::mutex m;
+  m.lock();
+  sleep(3); // expected-warning {{A blocking function %s is called inside a critical section}}
+  m.unlock();
+}
+
+void testBlockInCriticalSectionWithNestedMutexes() {
+  std::mutex m, n, k;
+  m.lock();
+  n.lock();
+  k.lock();
+  sleep(3); // expected-warning {{A blocking function %s is called inside a critical section}}
+  k.unlock();
+  sleep(5); // expected-warning {{A blocking function %s is called inside a critical section}}
+  n.unlock();
+  sleep(3); // expected-warning {{A blocking function %s is called inside a critical section}}
+  m.unlock();
+  sleep(3); // no-warning
+}
+
+void f() {
+  sleep(1000); // expected-warning {{A blocking function %s is called inside a critical section}}
+}
+
+void testBlockInCriticalSectionInterProcedural() {
+  std::mutex m;
+  m.lock();
+  f();
+  m.unlock();
+}
+
+void testBlockInCriticalSectionUnexpectedUnlock() {
+  std::mutex m;
+  m.unlock();
+  sleep(1); // no-warning
+  m.lock();
+  sleep(1); // expected-warning {{A blocking function %s is called inside a critical section}}
+}
Index: lib/StaticAnalyzer/Checkers/CMakeLists.txt
===
--- lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -9,6 +9,7 @@
   ArrayBoundChecker.cpp
   ArrayBoundCheckerV2.cpp
   BasicObjCFoundationChecks.cpp
+  BlockInCriticalSectionChecker.cpp
   BoolAssignmentChecker.cpp
   BuiltinFunctionChecker.cpp
   CStringChecker.cpp
Index: lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
@@ -0,0 +1,109 @@
+//===-- BlockInCriticalSectionChecker.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines a checker for blocks in critical sections. This checker should find
+// the calls to blocking functions (for example: sleep, getc, fgets, read,
+// recv etc.) inside a critical section. When sleep(x) is called while a mutex
+// is held, other threades cannot lock the same mutex. This might take some
+// time, leading to bad performance or even deadlock.
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+
+class BlockInCriticalSectionChecker : public Checker {
+
+  CallDescription LockFn, UnlockFn, SleepFn, GetcFn, FgetsFn, ReadFn, RecvFn;
+
+  std::unique_ptr BlockInCritSectionBugType;
+
+  void reportBlockInCritSection(SymbolRef FileDescSym,
+const CallEvent &call,
+CheckerContext &C) const;
+
+public:
+  BlockInCriticalSectionChecker();
+
+  void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
+
+  /// Process unlock.
+  /// Process lock.
+  /// Process blocking functions (sleep, getc, fgets, read, recv)
+  void checkPostCall(const CallEvent &Call, CheckerContext &C) const;
+
+};
+
+} // end anonymous namespace
+
+REGISTER_TRAIT_WITH_PROGRAMSTATE(MutexCounter, unsigned)
+
+BlockInCriticalSectionChecker::BlockInCriticalSectionChecker()
+: LockFn("lock"), UnlockFn("unlock"), SleepFn("sleep"), GetcFn("getc"),
+  FgetsFn("fgets"), ReadFn("read"), RecvFn("recv") {
+  // Initialize the bug type.
+  BlockInCritSectionBugType.reset(
+  new BugType(this, "Call to blocking function in critical section",
+"Blocking Error"));
+}
+
+void BlockInCriticalSection

Re: [PATCH] D24467: Fix an error after D21678

2016-09-14 Thread Vladimir Yakovlev via cfe-commits
vbyakovlcl added inline comments.


Comment at: llvm/tools/clang/lib/Sema/SemaExpr.cpp:8733
@@ -8731,2 +8732,3 @@
   if (!IsCompAssign) {
-LHS = S.UsualUnaryConversions(LHS.get());
+if (S.LangOpts.OpenCL || S.LangOpts.ZVector)
+  LHS = S.UsualUnaryConversions(LHS.get());

ahatanak wrote:
> It wasn't clear to me why we have to call 
> DefaultFunctionArrayLvalueConversion instead of UsualUnaryConversions. Is it 
> possible to come up with a test case that would fail without this change, and 
> if it is, can you add it to vecshift.c?
I cannot remember why I did this change. Removing it doesn't cause any new 
fails. 


Comment at: llvm/tools/clang/lib/Sema/SemaExpr.cpp:8747
@@ -8742,3 +8746,3 @@
 
   // Note that RHS might not be a vector.
   QualType RHSType = RHS.get()->getType();

ahatanak wrote:
> We no longer error out when LHS is not a vector, so it should mention that 
> either the LHS or the RHS might not be a vector.
I added a comment.


Comment at: llvm/tools/clang/lib/Sema/SemaExpr.cpp:8787
@@ -8770,1 +8786,3 @@
 }
+if (!S.LangOpts.OpenCL && !S.LangOpts.ZVector) {
+  const BuiltinType *LHSBT = LHSEleType->getAs();

ahatanak wrote:
> Is it possible to split this out to another patch? The first patch would fix 
> handling of (scalar << vector) and the second patch would make clang reject 
> vector shifts if element sizes of the LHS and RHS are different. It's not 
> clear whether it's correct to reject the latter case, so perhaps you can 
> discuss it in a separate patch? 
Ok. I removed this and will fail a new review after committing of this review.


Comment at: llvm/tools/clang/lib/Sema/SemaExpr.cpp:8847
@@ -8774,3 +8846,3 @@
   S.Context.getExtVectorType(RHSEleType, LHSVecTy->getNumElements());
 RHS = S.ImpCastExprToType(RHS.get(), VecTy, CK_VectorSplat);
   }

ahatanak wrote:
> When the LHS is a scalar, we check the type of the LHS and the element type 
> of the RHS, and if necessary, cast the LHS to the element type of the RHS. 
> What's the reason we don't do the same here?
No need, because CodeGen inserts a conversion.

define <8 x i16> @foo1(<8 x i16> %n, i32 %m) #0 {
entry:
  %n.addr = alloca <8 x i16>, align 16
  %m.addr = alloca i32, align 4
  store <8 x i16> %n, <8 x i16>* %n.addr, align 16
  store i32 %m, i32* %m.addr, align 4
  %0 = load <8 x i16>, <8 x i16>* %n.addr, align 16
  %1 = load i32, i32* %m.addr, align 4
  %splat.splatinsert = insertelement <8 x i32> undef, i32 %1, i32 0
  %splat.splat = shufflevector <8 x i32> %splat.splatinsert, <8 x i32> undef, 
<8 x i32> zeroinitializer
  %sh_prom = trunc <8 x i32> %splat.splat to <8 x i16>
  %shl = shl <8 x i16> %0, %sh_prom
  ret <8 x i16> %shl

We need insert a conversion of scalar LHS to the RHS element type because we 
must return a vector of the RHS type.


https://reviews.llvm.org/D24467



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


Re: [PATCH] D24562: [libcxx] Recover no-exceptions XFAILs

2016-09-14 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In https://reviews.llvm.org/D24562#542630, @mclow.lists wrote:

> What an awful test.  I wonder who wrote such a steaming pile.  Probably me.


I think I've thrown quite a lot of XFAILs like this in the past, just to get 
the no-exceptions build passing. Now I've got to clean them up one by one :)

Are you OK with this way of fixing them?

Cheers,

/ Asiri


https://reviews.llvm.org/D24562



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


Re: [PATCH] D24562: [libcxx] Recover no-exceptions XFAILs

2016-09-14 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

What an awful test.  I wonder who wrote such a steaming pile.  Probably me.


https://reviews.llvm.org/D24562



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


[PATCH] D24567: [clang-rename] Merge rename-{at|all} & optimise.

2016-09-14 Thread Kirill Bobyrev via cfe-commits
omtcyfz created this revision.
omtcyfz added reviewers: alexfh, vmiklos.
omtcyfz added a subscriber: cfe-commits.

Having both rename-at and rename-all both seems confusing and introduces 
unneeded difficulties. After merging rename-at and rename-all maintaining main 
function wrappers and custom help becomes redundant while CLI becomes less 
confusing.

D24224 (which was the original patch causing buildbot failures) wasn't aware of 
bugs caused by passing both `-offset` and `-qualified-name`.

D24224 was reverted and this patch previous diff to disallow both options 
present within single invocation.

Old and unmaintaned clang-rename unittest is deleted.

https://reviews.llvm.org/D24567

Files:
  clang-rename/USRFindingAction.cpp
  clang-rename/USRFindingAction.h
  clang-rename/tool/ClangRename.cpp
  docs/clang-rename.rst
  test/clang-rename/ClassFindByName.cpp
  test/clang-rename/ClassTestMulti.cpp
  test/clang-rename/ClassTestMultiByName.cpp
  test/clang-rename/ClassTestMultiByNameYAML.cpp
  test/clang-rename/FunctionWithClassFindByName.cpp
  test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml
  test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml
  test/clang-rename/Inputs/OffsetToNewName.yaml
  test/clang-rename/Inputs/QualifiedNameToNewName.yaml
  test/clang-rename/InvalidOldName.cpp
  test/clang-rename/NoNewName.cpp
  test/clang-rename/YAMLInput.cpp

Index: test/clang-rename/YAMLInput.cpp
===
--- /dev/null
+++ test/clang-rename/YAMLInput.cpp
@@ -0,0 +1,10 @@
+class Foo1 { // CHECK: class Bar1
+};
+
+class Foo2 { // CHECK: class Bar2
+};
+
+// Test 1.
+// RUN: clang-rename -input %S/Inputs/OffsetToNewName.yaml %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 2.
+// RUN: clang-rename -input %S/Inputs/QualifiedNameToNewName.yaml %s -- | sed 's,//.*,,' | FileCheck %s
Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
 // RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: clang-rename: for the -new-name option: must be specified
+// CHECK: clang-rename: -new-name must be specified.
Index: test/clang-rename/InvalidOldName.cpp
===
--- test/clang-rename/InvalidOldName.cpp
+++ /dev/null
@@ -1,2 +0,0 @@
-// RUN: not clang-rename rename-all -new-name=Foo -old-name=Bar %s -- 2>&1 | FileCheck %s
-// CHECK: clang-rename: could not find symbol Bar.
Index: test/clang-rename/Inputs/QualifiedNameToNewName.yaml
===
--- test/clang-rename/Inputs/QualifiedNameToNewName.yaml
+++ test/clang-rename/Inputs/QualifiedNameToNewName.yaml
@@ -1,6 +1,6 @@
 ---
-- OldName:Foo1
+- QualifiedName:  Foo1
   NewName:Bar1
-- OldName:Foo2
+- QualifiedName:  Foo2
   NewName:Bar2
 ...
Index: test/clang-rename/FunctionWithClassFindByName.cpp
===
--- test/clang-rename/FunctionWithClassFindByName.cpp
+++ test/clang-rename/FunctionWithClassFindByName.cpp
@@ -9,4 +9,4 @@
   return 0;
 }
 
-// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// RUN: clang-rename -qualified-name=Foo -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
Index: test/clang-rename/ClassTestMultiByNameYAML.cpp
===
--- test/clang-rename/ClassTestMultiByNameYAML.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-class Foo1 { // CHECK: class Bar1
-};
-
-class Foo2 { // CHECK: class Bar2
-};
-
-// Test 1.
-// RUN: clang-rename rename-all -input %S/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml %s -- | sed 's,//.*,,' | FileCheck %s
-// Test 2.
-// RUN: clang-rename rename-all -input %S/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml %s -- | sed 's,//.*,,' | FileCheck %s
Index: test/clang-rename/ClassTestMultiByName.cpp
===
--- test/clang-rename/ClassTestMultiByName.cpp
+++ test/clang-rename/ClassTestMultiByName.cpp
@@ -5,4 +5,4 @@
 };
 
 // Test 1.
-// RUN: clang-rename rename-all -old-name=Foo1 -new-name=Bar1 -old-name=Foo2 -new-name=Bar2 %s -- | sed 's,//.*,,' | FileCheck %s
+// RUN: clang-rename -qualified-name=Foo1 -new-name=Bar1 -qualified-name=Foo2 -new-name=Bar2 %s -- | sed 's,//.*,,' | FileCheck %s
Index: test/clang-rename/ClassTestMulti.cpp
===
--- test/clang-rename/ClassTestMulti.cpp
+++ test/clang-rename/ClassTestMulti.cpp
@@ -5,7 +5,7 @@
 };
 
 // Test 1.
-// RUN: clang-rename rename-all -offset=6 -new-name=Bar1 -offset=76 -new-name=Bar2 %s -- | sed 's,//.*,,' | FileCheck %s
+// RUN: clang-rename -off

Re: [PATCH] D24245: [ARM] ARM-specific attributes should be accepted for big-endian

2016-09-14 Thread Diana Picus via cfe-commits
rovka added a subscriber: rovka.
rovka accepted this revision.
rovka added a reviewer: rovka.
rovka added a comment.
This revision is now accepted and ready to land.

Looks like a sensible thing to do.


Repository:
  rL LLVM

https://reviews.llvm.org/D24245



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


r281487 - CodeGen: simplify the logic a slight bit

2016-09-14 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Wed Sep 14 10:17:46 2016
New Revision: 281487

URL: http://llvm.org/viewvc/llvm-project?rev=281487&view=rev
Log:
CodeGen: simplify the logic a slight bit

Move the definition of `getTriple()` into the header.  It would just call
`getTarget().getTriple()`.  Inline the definition to allow the compiler to see
the same amount of the layout as previously.  Remove the more verbose
`getTarget().getTriple()` in favour of `getTriple()`.

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

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=281487&r1=281486&r2=281487&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Sep 14 10:17:46 2016
@@ -189,8 +189,7 @@ void CodeGenModule::createOpenCLRuntime(
 void CodeGenModule::createOpenMPRuntime() {
   // Select a specialized code generation class based on the target, if any.
   // If it does not exist use the default implementation.
-  switch (getTarget().getTriple().getArch()) {
-
+  switch (getTriple().getArch()) {
   case llvm::Triple::nvptx:
   case llvm::Triple::nvptx64:
 assert(getLangOpts().OpenMPIsDevice &&
@@ -471,7 +470,7 @@ void CodeGenModule::Release() {
 getModule().addModuleFlag(llvm::Module::Override, "Cross-DSO CFI", 1);
   }
 
-  if (LangOpts.CUDAIsDevice && getTarget().getTriple().isNVPTX()) {
+  if (LangOpts.CUDAIsDevice && getTriple().isNVPTX()) {
 // Indicate whether __nvvm_reflect should be configured to flush denormal
 // floating point values to 0.  (This corresponds to its "__CUDA_FTZ"
 // property.)
@@ -1059,8 +1058,7 @@ void CodeGenModule::SetFunctionAttribute
   // where substantial code, including the libstdc++ dylib, was compiled with
   // GCC and does not actually return "this".
   if (!IsThunk && getCXXABI().HasThisReturn(GD) &&
-  !(getTarget().getTriple().isiOS() &&
-getTarget().getTriple().isOSVersionLT(6))) {
+  !(getTriple().isiOS() && getTriple().isOSVersionLT(6))) {
 assert(!F->arg_empty() &&
F->arg_begin()->getType()
  ->canLosslesslyBitCastTo(F->getReturnType()) &&
@@ -2201,7 +2199,7 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
 }
 
 // Handle XCore specific ABI requirements.
-if (getTarget().getTriple().getArch() == llvm::Triple::xcore &&
+if (getTriple().getArch() == llvm::Triple::xcore &&
 D->getLanguageLinkage() == CLanguageLinkage &&
 D->getType().isConstant(Context) &&
 isExternallyVisible(D->getLinkageAndVisibility().getLinkage()))
@@ -3187,7 +3185,7 @@ CodeGenModule::GetAddrOfConstantCFString
 llvm::Constant *GV =
 CreateRuntimeVariable(Ty, "__CFConstantStringClassReference");
 
-if (getTarget().getTriple().isOSBinFormatCOFF()) {
+if (getTriple().isOSBinFormatCOFF()) {
   IdentifierInfo &II = getContext().Idents.get(GV->getName());
   TranslationUnitDecl *TUDecl = getContext().getTranslationUnitDecl();
   DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
@@ -3253,7 +3251,7 @@ CodeGenModule::GetAddrOfConstantCFString
   // FIXME: We set the section explicitly to avoid a bug in ld64 224.1.
   // Without it LLVM can merge the string with a non unnamed_addr one during
   // LTO.  Doing that changes the section it ends in, which surprises ld64.
-  if (getTarget().getTriple().isOSBinFormatMachO())
+  if (getTriple().isOSBinFormatMachO())
 GV->setSection(isUTF16 ? "__TEXT,__ustring"
: "__TEXT,__cstring,cstring_literals");
 
@@ -3277,7 +3275,7 @@ CodeGenModule::GetAddrOfConstantCFString
 llvm::GlobalVariable::PrivateLinkage, C,
 "_unnamed_cfstring_");
   GV->setAlignment(Alignment.getQuantity());
-  switch (getTarget().getTriple().getObjectFormat()) {
+  switch (getTriple().getObjectFormat()) {
   case llvm::Triple::UnknownObjectFormat:
 llvm_unreachable("unknown file format");
   case llvm::Triple::COFF:

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=281487&r1=281486&r2=281487&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Wed Sep 14 10:17:46 2016
@@ -614,7 +614,7 @@ public:
 return TheModule.getDataLayout();
   }
   const TargetInfo &getTarget() const { return Target; }
-  const llvm::Triple &getTriple() const;
+  const llvm::Triple &getTriple() const { return Target.getTriple(); }
   bool supportsCOMDAT() const;
   void maybeSetTrivialComdat(const Decl &D, llvm::GlobalObject &GO);
 

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
UR

[libcxx] r281477 - [libcxx] Add a TSan regression test for a data race in call_once

2016-09-14 Thread Kuba Brecka via cfe-commits
Author: kuba.brecka
Date: Wed Sep 14 09:15:42 2016
New Revision: 281477

URL: http://llvm.org/viewvc/llvm-project?rev=281477&view=rev
Log:
[libcxx] Add a TSan regression test for a data race in call_once

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


Added:

libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.callonce/race.pass.cpp

Added: 
libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.callonce/race.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.callonce/race.pass.cpp?rev=281477&view=auto
==
--- 
libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.callonce/race.pass.cpp
 (added)
+++ 
libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.callonce/race.pass.cpp
 Wed Sep 14 09:15:42 2016
@@ -0,0 +1,48 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// 
+
+// struct once_flag;
+
+// template
+//   void call_once(once_flag& flag, Callable&& func, Args&&... args);
+
+// This test is supposed to be run with ThreadSanitizer and verifies that
+// call_once properly synchronizes user state, a data race that was fixed
+// in r280621.
+
+#include 
+#include 
+#include 
+
+std::once_flag flg0;
+long global = 0;
+
+void init0()
+{
+++global;
+}
+
+void f0()
+{
+std::call_once(flg0, init0);
+assert(global == 1);
+}
+
+int main()
+{
+std::thread t0(f0);
+std::thread t1(f0);
+t0.join();
+t1.join();
+assert(global == 1);
+}


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


[libcxx] r281476 - [libcxx] Fix a typo in test/libcxx/test/target_info.py that prevents running tests on Darwin with sanitizers

2016-09-14 Thread Kuba Brecka via cfe-commits
Author: kuba.brecka
Date: Wed Sep 14 09:13:50 2016
New Revision: 281476

URL: http://llvm.org/viewvc/llvm-project?rev=281476&view=rev
Log:
[libcxx] Fix a typo in test/libcxx/test/target_info.py that prevents running 
tests on Darwin with sanitizers

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


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

Modified: libcxx/trunk/test/libcxx/test/target_info.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/target_info.py?rev=281476&r1=281475&r2=281476&view=diff
==
--- libcxx/trunk/test/libcxx/test/target_info.py (original)
+++ libcxx/trunk/test/libcxx/test/target_info.py Wed Sep 14 09:13:50 2016
@@ -115,7 +115,7 @@ class DarwinLocalTI(DefaultTargetInfo):
 return False
 
 def add_sanitizer_features(self, sanitizer_type, features):
-if san == 'Undefined':
+if sanitizer_type == 'Undefined':
 features.add('sanitizer-new-delete')
 
 


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


[libcxx] r281475 - [libcxx] Enable building and testing of libcxx with ThreadSanitizer on OS X

2016-09-14 Thread Kuba Brecka via cfe-commits
Author: kuba.brecka
Date: Wed Sep 14 09:12:50 2016
New Revision: 281475

URL: http://llvm.org/viewvc/llvm-project?rev=281475&view=rev
Log:
[libcxx] Enable building and testing of libcxx with ThreadSanitizer on OS X

This patch enables building and testing libcxx under ThreadSanitizer on OS X. 
CMake builds that have -DLLVM_USE_SANITIZER=Thread will automatically build 
libcxx with -fsanitize=thread and testing via lit then runs under TSan.

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


Modified:
libcxx/trunk/lib/CMakeLists.txt

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=281475&r1=281474&r2=281475&view=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Wed Sep 14 09:12:50 2016
@@ -42,6 +42,8 @@ if (APPLE AND LLVM_USE_SANITIZER)
 set(LIBFILE "libclang_rt.asan_osx_dynamic.dylib")
   elseif("${LLVM_USE_SANITIZER}" STREQUAL "Undefined")
 set(LIBFILE "libclang_rt.ubsan_osx_dynamic.dylib")
+  elseif("${LLVM_USE_SANITIZER}" STREQUAL "Thread")
+set(LIBFILE "libclang_rt.tsan_osx_dynamic.dylib")
   else()
 message(WARNING "LLVM_USE_SANITIZER=${LLVM_USE_SANITIZER} is not supported 
on OS X")
   endif()


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


Re: [PATCH] D23907: Fix documentation of MemberExpr::getMemberDecl

2016-09-14 Thread Stephan Bergmann via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281469: Fix documentation of MemberExpr::getMemberDecl 
(authored by sberg).

Changed prior to commit:
  https://reviews.llvm.org/D23907?vs=69317&id=71357#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23907

Files:
  cfe/trunk/include/clang/AST/Expr.h

Index: cfe/trunk/include/clang/AST/Expr.h
===
--- cfe/trunk/include/clang/AST/Expr.h
+++ cfe/trunk/include/clang/AST/Expr.h
@@ -2406,8 +2406,8 @@
 
   /// \brief Retrieve the member declaration to which this expression refers.
   ///
-  /// The returned declaration will either be a FieldDecl or (in C++)
-  /// a CXXMethodDecl.
+  /// The returned declaration will be a FieldDecl or (in C++) a VarDecl (for
+  /// static data members), a CXXMethodDecl, or an EnumConstantDecl.
   ValueDecl *getMemberDecl() const { return MemberDecl; }
   void setMemberDecl(ValueDecl *D) { MemberDecl = D; }
 


Index: cfe/trunk/include/clang/AST/Expr.h
===
--- cfe/trunk/include/clang/AST/Expr.h
+++ cfe/trunk/include/clang/AST/Expr.h
@@ -2406,8 +2406,8 @@
 
   /// \brief Retrieve the member declaration to which this expression refers.
   ///
-  /// The returned declaration will either be a FieldDecl or (in C++)
-  /// a CXXMethodDecl.
+  /// The returned declaration will be a FieldDecl or (in C++) a VarDecl (for
+  /// static data members), a CXXMethodDecl, or an EnumConstantDecl.
   ValueDecl *getMemberDecl() const { return MemberDecl; }
   void setMemberDecl(ValueDecl *D) { MemberDecl = D; }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r281469 - Fix documentation of MemberExpr::getMemberDecl

2016-09-14 Thread Stephan Bergmann via cfe-commits
Author: sberg
Date: Wed Sep 14 09:03:50 2016
New Revision: 281469

URL: http://llvm.org/viewvc/llvm-project?rev=281469&view=rev
Log:
Fix documentation of MemberExpr::getMemberDecl

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

Modified:
cfe/trunk/include/clang/AST/Expr.h

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=281469&r1=281468&r2=281469&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Wed Sep 14 09:03:50 2016
@@ -2406,8 +2406,8 @@ public:
 
   /// \brief Retrieve the member declaration to which this expression refers.
   ///
-  /// The returned declaration will either be a FieldDecl or (in C++)
-  /// a CXXMethodDecl.
+  /// The returned declaration will be a FieldDecl or (in C++) a VarDecl (for
+  /// static data members), a CXXMethodDecl, or an EnumConstantDecl.
   ValueDecl *getMemberDecl() const { return MemberDecl; }
   void setMemberDecl(ValueDecl *D) { MemberDecl = D; }
 


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


Re: [PATCH] D24562: [libcxx] Recover no-exceptions XFAILs

2016-09-14 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 71349.
rmaprath added a comment.

(Added more context)


https://reviews.llvm.org/D24562

Files:
  test/std/re/re.alg/re.alg.search/grep.pass.cpp

Index: test/std/re/re.alg/re.alg.search/grep.pass.cpp
===
--- test/std/re/re.alg/re.alg.search/grep.pass.cpp
+++ test/std/re/re.alg/re.alg.search/grep.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template 
@@ -23,6 +22,7 @@
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 extern "C" void LLVMFuzzerTestOneInput(const char *data)
 {
 size_t size = strlen(data);
@@ -47,6 +47,7 @@
 
LLVMFuzzerTestOneInput(R"XX(Õ)_%()()((\8'_%()_%()_%()_%(()_%()_%()_%(.t;)()¥f()_%()(.)_%;)()!¥f)()XX");
 #endif
 }
+#endif
 
 int main()
 {
@@ -82,5 +83,7 @@
 assert(m.position(0) == 0);
 assert(m.str(0) == "");
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 fuzz_tests();
+#endif
 }


Index: test/std/re/re.alg/re.alg.search/grep.pass.cpp
===
--- test/std/re/re.alg/re.alg.search/grep.pass.cpp
+++ test/std/re/re.alg/re.alg.search/grep.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template 
@@ -23,6 +22,7 @@
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 extern "C" void LLVMFuzzerTestOneInput(const char *data)
 {
 size_t size = strlen(data);
@@ -47,6 +47,7 @@
 LLVMFuzzerTestOneInput(R"XX(Õ)_%()()((\8'_%()_%()_%()_%(()_%()_%()_%(.t;)()¥f()_%()(.)_%;)()!¥f)()XX");
 #endif
 }
+#endif
 
 int main()
 {
@@ -82,5 +83,7 @@
 assert(m.position(0) == 0);
 assert(m.str(0) == "");
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 fuzz_tests();
+#endif
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24562: [libcxx] Recover no-exceptions XFAILs

2016-09-14 Thread Asiri Rathnayake via cfe-commits
rmaprath created this revision.
rmaprath added reviewers: EricWF, mclow.lists.
rmaprath added a subscriber: cfe-commits.

When we added support for the no-exceptions build of `libc++`, all the tests 
that used exceptions got a blanket XFAIL for the no-exceptions variety.

Previously, we tried to fix-up these tests with an elaborate setjmp/longjmp 
hackery (see D14653), which was rejected on the grounds of being too 
complicated / obtrusive.

The current patch is a representative fix that does the most obvious thing 
instead: use pre-processor macros to exclude just the bits of the test that use 
exceptions. Unlike in the previous patch, this means we are not trying to 
associate / verify a particular behaviour of the no-exceptions library with 
respect to exceptional situations (like calling abort). Here we simply save the 
parts of the test that has nothing to do with exceptions, I think this is a 
fair compromise.

We could also split the test file into two; one that uses exceptions and one 
that does not, though I can't think of any added benefits of that approach.

If this patch is approved I'll go ahead and update the rest of the tests (~150) 
to follow the same.

https://reviews.llvm.org/D24562

Files:
  test/std/re/re.alg/re.alg.search/grep.pass.cpp

Index: test/std/re/re.alg/re.alg.search/grep.pass.cpp
===
--- test/std/re/re.alg/re.alg.search/grep.pass.cpp
+++ test/std/re/re.alg/re.alg.search/grep.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template 
@@ -23,6 +22,7 @@
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 extern "C" void LLVMFuzzerTestOneInput(const char *data)
 {
 size_t size = strlen(data);
@@ -47,6 +47,7 @@
 
LLVMFuzzerTestOneInput(R"XX(Õ)_%()()((\8'_%()_%()_%()_%(()_%()_%()_%(.t;)()¥f()_%()(.)_%;)()!¥f)()XX");
 #endif
 }
+#endif
 
 int main()
 {
@@ -82,5 +83,7 @@
 assert(m.position(0) == 0);
 assert(m.str(0) == "");
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 fuzz_tests();
+#endif
 }


Index: test/std/re/re.alg/re.alg.search/grep.pass.cpp
===
--- test/std/re/re.alg/re.alg.search/grep.pass.cpp
+++ test/std/re/re.alg/re.alg.search/grep.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template 
@@ -23,6 +22,7 @@
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 extern "C" void LLVMFuzzerTestOneInput(const char *data)
 {
 size_t size = strlen(data);
@@ -47,6 +47,7 @@
 LLVMFuzzerTestOneInput(R"XX(Õ)_%()()((\8'_%()_%()_%()_%(()_%()_%()_%(.t;)()¥f()_%()(.)_%;)()!¥f)()XX");
 #endif
 }
+#endif
 
 int main()
 {
@@ -82,5 +83,7 @@
 assert(m.position(0) == 0);
 assert(m.str(0) == "");
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 fuzz_tests();
+#endif
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24005: [compiler-rt cmake] Support overriding llvm-config query results

2016-09-14 Thread Michał Górny via cfe-commits
mgorny added a comment.

Thanks again. I've left them as-is and committed.


Repository:
  rL LLVM

https://reviews.llvm.org/D24005



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


Re: [PATCH] D24561: [clang-tidy] Add dependency on clangAnalysis to clangTidyMiscModule

2016-09-14 Thread Martin Böhme via cfe-commits
mboehme added a comment.

Thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D24561



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


Re: [PATCH] D24005: [compiler-rt cmake] Support overriding llvm-config query results

2016-09-14 Thread Michał Górny via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281461: [cmake] Support overriding llvm-config query results 
(authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D24005?vs=71040&id=71348#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24005

Files:
  compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake

Index: compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
===
--- compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
+++ compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
@@ -197,10 +197,15 @@
 message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
   endif()
   string(REGEX REPLACE "[ \t]*[\r\n]+[ \t]*" ";" CONFIG_OUTPUT 
${CONFIG_OUTPUT})
-  list(GET CONFIG_OUTPUT 0 LLVM_BINARY_DIR)
-  list(GET CONFIG_OUTPUT 1 LLVM_TOOLS_BINARY_DIR)
-  list(GET CONFIG_OUTPUT 2 LLVM_LIBRARY_DIR)
-  list(GET CONFIG_OUTPUT 3 LLVM_MAIN_SRC_DIR)
+  list(GET CONFIG_OUTPUT 0 BINARY_DIR)
+  list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR)
+  list(GET CONFIG_OUTPUT 2 LIBRARY_DIR)
+  list(GET CONFIG_OUTPUT 3 MAIN_SRC_DIR)
+
+  set(LLVM_BINARY_DIR ${BINARY_DIR} CACHE PATH "Path to LLVM build tree")
+  set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin")
+  set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
+  set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
 
   # Make use of LLVM CMake modules.
   file(TO_CMAKE_PATH ${LLVM_BINARY_DIR} LLVM_BINARY_DIR_CMAKE_STYLE)


Index: compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
===
--- compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
+++ compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
@@ -197,10 +197,15 @@
 message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
   endif()
   string(REGEX REPLACE "[ \t]*[\r\n]+[ \t]*" ";" CONFIG_OUTPUT ${CONFIG_OUTPUT})
-  list(GET CONFIG_OUTPUT 0 LLVM_BINARY_DIR)
-  list(GET CONFIG_OUTPUT 1 LLVM_TOOLS_BINARY_DIR)
-  list(GET CONFIG_OUTPUT 2 LLVM_LIBRARY_DIR)
-  list(GET CONFIG_OUTPUT 3 LLVM_MAIN_SRC_DIR)
+  list(GET CONFIG_OUTPUT 0 BINARY_DIR)
+  list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR)
+  list(GET CONFIG_OUTPUT 2 LIBRARY_DIR)
+  list(GET CONFIG_OUTPUT 3 MAIN_SRC_DIR)
+
+  set(LLVM_BINARY_DIR ${BINARY_DIR} CACHE PATH "Path to LLVM build tree")
+  set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin")
+  set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
+  set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
 
   # Make use of LLVM CMake modules.
   file(TO_CMAKE_PATH ${LLVM_BINARY_DIR} LLVM_BINARY_DIR_CMAKE_STYLE)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r281460 - [clang-tidy] Add dependency on clangAnalysis to clangTidyMiscModule

2016-09-14 Thread Martin Bohme via cfe-commits
Author: mboehme
Date: Wed Sep 14 08:33:11 2016
New Revision: 281460

URL: http://llvm.org/viewvc/llvm-project?rev=281460&view=rev
Log:
[clang-tidy] Add dependency on clangAnalysis to clangTidyMiscModule

Summary:
This is needed for the recently submitted misc-use-after-move check (rL281453).
For some reason, this still built under Linux, but it caused the PPC build bot
to fail.

Subscribers: beanz, cfe-commits, mgorny

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt

Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=281460&r1=281459&r2=281460&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Wed Sep 14 08:33:11 
2016
@@ -47,6 +47,7 @@ add_clang_library(clangTidyMiscModule
   VirtualNearMissCheck.cpp
 
   LINK_LIBS
+  clangAnalysis
   clangAST
   clangASTMatchers
   clangBasic


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


Re: [PATCH] D24561: [clang-tidy] Add dependency on clangAnalysis to clangTidyMiscModule

2016-09-14 Thread Martin Böhme via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281460: [clang-tidy] Add dependency on clangAnalysis to 
clangTidyMiscModule (authored by mboehme).

Changed prior to commit:
  https://reviews.llvm.org/D24561?vs=71345&id=71346#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24561

Files:
  clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt

Index: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
@@ -47,6 +47,7 @@
   VirtualNearMissCheck.cpp
 
   LINK_LIBS
+  clangAnalysis
   clangAST
   clangASTMatchers
   clangBasic


Index: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
@@ -47,6 +47,7 @@
   VirtualNearMissCheck.cpp
 
   LINK_LIBS
+  clangAnalysis
   clangAST
   clangASTMatchers
   clangBasic
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24561: [clang-tidy] Add dependency on clangAnalysis to clangTidyMiscModule

2016-09-14 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman accepted this revision.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM -- for these sort of post-commit fixes that are trivial and make failing 
bots happy, you can go ahead and commit them and handle further review once the 
bots go back to green.


https://reviews.llvm.org/D24561



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


Re: [PATCH] D24561: [clang-tidy] Add dependency on clangAnalysis to clangTidyMiscModule

2016-09-14 Thread Martin Böhme via cfe-commits
mboehme added a comment.

Trivial build fix, will submit without review.


https://reviews.llvm.org/D24561



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


[PATCH] D24561: [clang-tidy] Add dependency on clangAnalysis to clangTidyMiscModule

2016-09-14 Thread Martin Böhme via cfe-commits
mboehme created this revision.
mboehme added a subscriber: cfe-commits.
Herald added subscribers: mgorny, beanz.

This is needed for the recently submitted misc-use-after-move check (rL281453).
For some reason, this still built under Linux, but it caused the PPC build bot
to fail.

https://reviews.llvm.org/D24561

Files:
  clang-tidy/misc/CMakeLists.txt

Index: clang-tidy/misc/CMakeLists.txt
===
--- clang-tidy/misc/CMakeLists.txt
+++ clang-tidy/misc/CMakeLists.txt
@@ -47,6 +47,7 @@
   VirtualNearMissCheck.cpp
 
   LINK_LIBS
+  clangAnalysis
   clangAST
   clangASTMatchers
   clangBasic


Index: clang-tidy/misc/CMakeLists.txt
===
--- clang-tidy/misc/CMakeLists.txt
+++ clang-tidy/misc/CMakeLists.txt
@@ -47,6 +47,7 @@
   VirtualNearMissCheck.cpp
 
   LINK_LIBS
+  clangAnalysis
   clangAST
   clangASTMatchers
   clangBasic
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r281452 - Revert "[modules] When merging one definition into another, propagate the list of re-exporting modules from the discarded definition to the retained definition."

2016-09-14 Thread Eric Liu via cfe-commits
This revision caused internal build breakage, but unfortunately I'm not
sure what exactly in this revision caused the breakage. I have reported the
issue to @rsmith - the revision author.

On Wed, Sep 14, 2016 at 3:10 PM Nico Weber  wrote:

> When reverting something, please say why in the commit message.
>
> On Sep 14, 2016 6:13 AM, "Eric Liu via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: ioeric
> Date: Wed Sep 14 05:05:10 2016
> New Revision: 281452
>
> URL: http://llvm.org/viewvc/llvm-project?rev=281452&view=rev
> Log:
> Revert "[modules] When merging one definition into another, propagate the
> list of re-exporting modules from the discarded definition to the retained
> definition."
>
> This reverts commit r281429.
>
> Modified:
> cfe/trunk/include/clang/AST/ASTContext.h
> cfe/trunk/lib/AST/ASTContext.cpp
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/a.h
> cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/b.h
> cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/c.h
> cfe/trunk/test/Modules/merge-template-pattern-visibility.cpp
>
> Modified: cfe/trunk/include/clang/AST/ASTContext.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=281452&r1=281451&r2=281452&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
> +++ cfe/trunk/include/clang/AST/ASTContext.h Wed Sep 14 05:05:10 2016
> @@ -308,18 +308,10 @@ class ASTContext : public RefCountedBase
>/// merged into.
>llvm::DenseMap MergedDecls;
>
> -  /// The modules into which a definition has been merged, or a map from a
> -  /// merged definition to its canonical definition. This is really a
> union of
> -  /// a NamedDecl* and a vector of Module*.
> -  struct MergedModulesOrCanonicalDef {
> -llvm::TinyPtrVector MergedModules;
> -NamedDecl *CanonicalDef = nullptr;
> -  };
> -
>/// \brief A mapping from a defining declaration to a list of modules
> (other
>/// than the owning module of the declaration) that contain merged
>/// definitions of that entity.
> -  llvm::DenseMap
> MergedDefModules;
> +  llvm::DenseMap>
> MergedDefModules;
>
>/// \brief Initializers for a module, in order. Each Decl will be either
>/// something that has a semantic effect on startup (such as a variable
> with
> @@ -902,7 +894,6 @@ public:
>/// and should be visible whenever \p M is visible.
>void mergeDefinitionIntoModule(NamedDecl *ND, Module *M,
>   bool NotifyListeners = true);
> -  void mergeDefinitionIntoModulesOf(NamedDecl *ND, NamedDecl *Other);
>/// \brief Clean up the merged definition list. Call this if you might
> have
>/// added duplicates into the list.
>void deduplicateMergedDefinitonsFor(NamedDecl *ND);
> @@ -913,9 +904,7 @@ public:
>  auto MergedIt = MergedDefModules.find(Def);
>  if (MergedIt == MergedDefModules.end())
>return None;
> -if (auto *CanonDef = MergedIt->second.CanonicalDef)
> -  return getModulesWithMergedDefinition(CanonDef);
> -return MergedIt->second.MergedModules;
> +return MergedIt->second;
>}
>
>/// Add a declaration to the list of declarations that are initialized
>
> Modified: cfe/trunk/lib/AST/ASTContext.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=281452&r1=281451&r2=281452&view=diff
>
> ==
> --- cfe/trunk/lib/AST/ASTContext.cpp (original)
> +++ cfe/trunk/lib/AST/ASTContext.cpp Wed Sep 14 05:05:10 2016
> @@ -890,59 +890,10 @@ void ASTContext::mergeDefinitionIntoModu
>  if (auto *Listener = getASTMutationListener())
>Listener->RedefinedHiddenDefinition(ND, M);
>
> -  if (getLangOpts().ModulesLocalVisibility) {
> -auto *Merged = &MergedDefModules[ND];
> -if (auto *CanonDef = Merged->CanonicalDef)
> -  Merged = &MergedDefModules[CanonDef];
> -Merged->MergedModules.push_back(M);
> -  } else {
> -auto MergedIt = MergedDefModules.find(ND);
> -if (MergedIt != MergedDefModules.end() &&
> MergedIt->second.CanonicalDef)
> -  ND = MergedIt->second.CanonicalDef;
> +  if (getLangOpts().ModulesLocalVisibility)
> +MergedDefModules[ND].push_back(M);
> +  else
>  ND->setHidden(false);
> -  }
> -}
> -
> -void ASTContext::mergeDefinitionIntoModulesOf(NamedDecl *Def,
> -  NamedDecl *Other) {
> -  // We need to know the owning module of the merge source.
> -  assert(Other->isFromASTFile() && "merge of non-imported decl not
> supported");
> -  assert(Def != Other && "merging definition into itself");
> -
> -  if (!getLangOpts().ModulesLocalVisibility && !Other->isHidden()) {
> -Def->setHidden(false);
> -return;
> -  }
> -  assert(Other->getImportedOw

[clang-tools-extra] r281459 - reverting r281456

2016-09-14 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Wed Sep 14 08:23:14 2016
New Revision: 281459

URL: http://llvm.org/viewvc/llvm-project?rev=281459&view=rev
Log:
reverting r281456

Modified:
clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
clang-tools-extra/trunk/clang-rename/USRFindingAction.h
clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
clang-tools-extra/trunk/docs/clang-rename.rst
clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp
clang-tools-extra/trunk/test/clang-rename/ClassTestMulti.cpp
clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByName.cpp
clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp
clang-tools-extra/trunk/test/clang-rename/NoNewName.cpp

Modified: clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp?rev=281459&r1=281458&r2=281459&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp Wed Sep 14 
08:23:14 2016
@@ -28,7 +28,6 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/Tooling.h"
-
 #include 
 #include 
 #include 
@@ -46,10 +45,11 @@ namespace {
 // to virtual method.
 class AdditionalUSRFinder : public RecursiveASTVisitor {
 public:
-  AdditionalUSRFinder(const Decl *FoundDecl, ASTContext &Context)
-  : FoundDecl(FoundDecl), Context(Context) {}
+  explicit AdditionalUSRFinder(const Decl *FoundDecl, ASTContext &Context,
+   std::vector *USRs)
+  : FoundDecl(FoundDecl), Context(Context), USRs(USRs) {}
 
-  std::vector Find() {
+  void Find() {
 // Fill OverriddenMethods and PartialSpecs storages.
 TraverseDecl(Context.getTranslationUnitDecl());
 if (const auto *MethodDecl = dyn_cast(FoundDecl)) {
@@ -66,7 +66,7 @@ public:
 } else {
   USRSet.insert(getUSRForDecl(FoundDecl));
 }
-return std::vector(USRSet.begin(), USRSet.end());
+USRs->insert(USRs->end(), USRSet.begin(), USRSet.end());
   }
 
   bool VisitCXXMethodDecl(const CXXMethodDecl *MethodDecl) {
@@ -129,98 +129,69 @@ private:
 
   const Decl *FoundDecl;
   ASTContext &Context;
+  std::vector *USRs;
   std::set USRSet;
   std::vector OverriddenMethods;
   std::vector PartialSpecs;
 };
 } // namespace
 
-class NamedDeclFindingConsumer : public ASTConsumer {
-public:
-  NamedDeclFindingConsumer(ArrayRef SymbolOffsets,
-   ArrayRef QualifiedNames,
-   std::vector &SpellingNames,
-   std::vector> &USRList,
-   bool &ErrorOccurred)
-  : SymbolOffsets(SymbolOffsets), QualifiedNames(QualifiedNames),
-SpellingNames(SpellingNames), USRList(USRList),
-ErrorOccurred(ErrorOccurred) {}
-
-private:
-  bool FindSymbol(ASTContext &Context, const SourceManager &SourceMgr,
-  unsigned SymbolOffset, const std::string &QualifiedName) {
-DiagnosticsEngine &Engine = Context.getDiagnostics();
-
+struct NamedDeclFindingConsumer : public ASTConsumer {
+  void HandleTranslationUnit(ASTContext &Context) override {
+const SourceManager &SourceMgr = Context.getSourceManager();
+// The file we look for the USR in will always be the main source file.
 const SourceLocation Point =
 SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID())
 .getLocWithOffset(SymbolOffset);
-
-if (!Point.isValid()) {
-  ErrorOccurred = true;
-  unsigned InvalidOffset = Engine.getCustomDiagID(
-  DiagnosticsEngine::Error,
-  "SourceLocation in file %0 at offset %1 is invalid");
-  Engine.Report(Point, InvalidOffset) << SourceMgr.getFilename(Point)
-  << SymbolOffset;
-  return false;
-}
-
-const NamedDecl *FoundDecl = QualifiedName.empty()
- ? getNamedDeclAt(Context, Point)
- : getNamedDeclFor(Context, QualifiedName);
-
+if (!Point.isValid())
+  return;
+const NamedDecl *FoundDecl = nullptr;
+if (OldName.empty())
+  FoundDecl = getNamedDeclAt(Context, Point);
+else
+  FoundDecl = getNamedDeclFor(Context, OldName);
 if (FoundDecl == nullptr) {
-  if (QualifiedName.empty()) {
+  if (OldName.empty()) {
 FullSourceLoc FullLoc(Point, SourceMgr);
-unsigned CouldNotFindSymbolAt = Engine.getCustomDiagID(
-DiagnosticsEngine::Error,
-"clang-rename could not find symbol (offset %0)");
-Engine.Report(Point, CouldNotFindSymbolAt) << SymbolOffset;
-ErrorOccurred = true;
-return false;
+errs() << "clang-rename: could not find symbol at "
+   << SourceMgr.getFilename(Point) << ":"
+ 

Re: [clang-tools-extra] r281453 - [clang-tidy] Add check 'misc-use-after-move'

2016-09-14 Thread Martin Böhme via cfe-commits
>
> While I'm excited to see this go in anywhere, I have to say I'm a bit sad
> it isn't going in as a warning and instead inside clang-tidy. This has been
> a much requested warning from Clang for many years.
>
> Is there a concise description of why this design was chosen? Are there
> specific problems that make it infeasible to be a warnings? Is there maybe
> a plan to move it to a warning after some set of issues are addressed?
>

Yes, my hope is that this can be moved to a warning, and others have
expressed the same thought to me.

There are two main issues that need to be addressed before this can be made
a warning:

   - I suspect (though I haven't measured) that the implementation isn't
   currently efficient enough to be made a Clang warning.
   - There are a number of scenarios in which the check warns when arguably
   it should not. These are:
  - User-defined types that make guarantees about the state of a
  moved-from object (in the way that std::unique_ptr and
std::shared_ptr do).
  Some form of annotation could be used to indicate that this is the case.
  - User-defined types that provide a member function to reinitialize
  the entire object (the way that clear() does on the standard container
  classes). These could either again be annotated in some way, or we could
  simply assume that any non-const member function reinitializes the object.
  - Tests for move constructors / move assignment operators. Often,
  these tests check that a moved-from object is left in a certain
state, even
  if the class in question does not provide such a guarantee to
clients (the
  intent being to check that the move constructor / move
assignment operator
  do not simply perform a copy).

All of these scenarios are probably somewhat controversial, but I don't
think there's a broad consensus that any of them should be prohibited, so
there needs to be a way to silence the warning in these cases.


I do hope to resolve these issues and make this check into a warning, but
in the meantime, having it available as a clang-tidy check seems like a
good way to gather feedback and gain experience with it.

Since you say this is a much-requested warning: Any pointers to previous
discussions that I should be aware of?


See user-facing documentation for details.
>>
>
> In general, I suspect at least some more context should be provided in
> change descriptions. =]
>

Thanks -- still new to this.

The intent was not to repeat myself, but I evidently went a bit far with
that. ;) Is it of value if I provide a short summary on this thread, or is
this just something I should keep in mind for future patches?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >