r252398 - Use makeArrayRef instead of explicitly mentioning the type. NFC

2015-11-06 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sat Nov  7 00:16:16 2015
New Revision: 252398

URL: http://llvm.org/viewvc/llvm-project?rev=252398&view=rev
Log:
Use makeArrayRef instead of explicitly mentioning the type. NFC

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=252398&r1=252397&r2=252398&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat Nov  7 00:16:16 2015
@@ -5048,7 +5048,7 @@ Sema::BuildResolvedCallExpr(Expr *Fn, Na
 if (!Result.isUsable()) return ExprError();
 TheCall = dyn_cast(Result.get());
 if (!TheCall) return Result;
-Args = ArrayRef(TheCall->getArgs(), TheCall->getNumArgs());
+Args = llvm::makeArrayRef(TheCall->getArgs(), TheCall->getNumArgs());
   }
 
   // Bail out early if calling a builtin with custom typechecking.


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


r252397 - Fix indentation. NFC

2015-11-06 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sat Nov  7 00:16:14 2015
New Revision: 252397

URL: http://llvm.org/viewvc/llvm-project?rev=252397&view=rev
Log:
Fix indentation. NFC

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=252397&r1=252396&r2=252397&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Sat Nov  7 00:16:14 2015
@@ -493,9 +493,9 @@ Sema::CheckBuiltinFunctionCall(FunctionD
   case Builtin::BI__builtin_add_overflow:
   case Builtin::BI__builtin_sub_overflow:
   case Builtin::BI__builtin_mul_overflow:
-  if (SemaBuiltinOverflow(*this, TheCall))
-  return ExprError();
-  break;
+if (SemaBuiltinOverflow(*this, TheCall))
+  return ExprError();
+break;
   case Builtin::BI__builtin_operator_new:
   case Builtin::BI__builtin_operator_delete:
 if (!getLangOpts().CPlusPlus) {


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


Re: [PATCH] D13330: Implement __attribute__((unique_instantiation))

2015-11-06 Thread Keno Fischer via cfe-commits
loladiro updated this revision to Diff 39627.
loladiro updated the summary for this revision.
loladiro added a comment.

Address review feedback regarding diagnostic wording/expand tests to full text 
of diagnostic.


http://reviews.llvm.org/D13330

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  lib/AST/ASTContext.cpp
  lib/CodeGen/CGVTables.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaTemplate.cpp
  test/CodeGenCXX/unique-instantiation.cpp
  test/SemaCXX/unique-instantiations.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -2371,6 +2371,8 @@
 case Func | ObjCMethod | Param: return "ExpectedFunctionMethodOrParameter";
 case Func | ObjCMethod: return "ExpectedFunctionOrMethod";
 case Func | Var: return "ExpectedVariableOrFunction";
+case Func | Class:
+  return "ExpectedFunctionOrClass";
 
 // If not compiling for C++, the class portion does not apply.
 case Func | Var | Class:
Index: test/SemaCXX/unique-instantiations.cpp
===
--- /dev/null
+++ test/SemaCXX/unique-instantiations.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang -cc1 -std=c++11 -fsyntax-only -verify %s
+
+template 
+struct foo1 {};
+template struct __attribute__((unique_instantiation)) foo1; // expected-error{{'unique_instantiation' attribute on an explicit instantiation requires a previous explicit instantiation declaration}}
+
+template 
+struct foo2 {};
+extern template struct foo2;// expected-note{{previous explicit instantiation is here}}
+template struct __attribute__((unique_instantiation)) foo2; // expected-error{{'unique_instantiation' attribute must be specified for all declarations and definitions of this explicit template instantiation}}
+
+template 
+struct foo3 {};
+extern template struct __attribute__((unique_instantiation)) foo3; // expected-note{{previous explicit instantiation is here}}
+extern template struct foo3;   // expected-error{{'unique_instantiation' attribute must be specified for all declarations and definitions of this explicit template instantiation}}
+
+template 
+struct __attribute__((unique_instantiation)) foo4 {}; // expected-error{{'unique_instantiation' attribute only applies to explicit template declarations or definitions}}
+
+template 
+struct foo5 {};
+extern template struct __attribute__((unique_instantiation)) foo5; // expected-note{{previous explicit instantiation is here}}
+template struct foo5;  // expected-error{{'unique_instantiation' attribute must be specified for all declarations and definitions of this explicit template instantiation}}
+
+template 
+struct foo6 {};
+extern template struct  __attribute__((unique_instantiation(16))) foo6;// expected-error{{'unique_instantiation' attribute takes no arguments}}
+template struct __attribute__((unique_instantiation("Hello World"))) foo6; // expected-error{{'unique_instantiation' attribute takes no arguments}}
Index: test/CodeGenCXX/unique-instantiation.cpp
===
--- /dev/null
+++ test/CodeGenCXX/unique-instantiation.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang -std=c++11 -emit-llvm -c -S -o - %s | FileCheck %s
+
+template 
+struct foo {
+  T x;
+  T getX() { return x; }
+  struct bar {
+T y;
+bar(T y) : y(y) {}
+  };
+};
+template 
+T bar();
+
+// CHECK: define i32 @_ZN3fooIiE4getXEv
+// CHECK: define void @_ZN3fooIiE3barC2Ei
+// CHECK-NOT: define weak_odr i32 @_ZN3fooIiE4getXEv
+// CHECK-NOT: define weak_odr void @_ZN3fooIiE3barC2Ei
+extern template struct __attribute__((unique_instantiation)) foo;
+template struct __attribute__((unique_instantiation)) foo;
+
+extern template __attribute__((unique_instantiation)) int bar();
+
+template 
+T bar() {
+  return (T)0;
+}
+
+// CHECK: define i32 @_Z3barIiET_v()
+// CHECK-NOT: define weak_odr i32 @_Z3barIiET_v()
+template __attribute__((unique_instantiation)) int bar();
+
+int footest() {
+  auto var = foo{5};
+  auto var2 = foo::bar{5};
+  auto x = bar();
+  return var.getX();
+}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7330,20 +7330,22 @@
   Specialization->setExternLoc(ExternLoc);
   Specialization->setTemplateKeywordLoc(TemplateLoc);
   Specialization->setRBraceLoc(SourceLocation());
+  Specialization->setTemplateSpecializationKind(TSK);
 
   if (Attr)
 ProcessDeclAttributeList(S, Specialization, Attr);
 
+  if (PrevDecl)
+mergeDeclAttributes(Specialization, PrevDecl)

Re: [PATCH] D13330: Implement __attribute__((unique_instantiation))

2015-11-06 Thread Keno Fischer via cfe-commits
loladiro added inline comments.


Comment at: include/clang/Basic/Attr.td:1463
@@ +1462,3 @@
+  let Spellings = [GNU<"unique_instantiation">];
+  let Subjects = SubjectList<[Function, CXXRecord], ErrorDiag>;
+  let Documentation = [UniqueInstantiationDocs];

loladiro wrote:
> majnemer wrote:
> > They work ok, clang just thinks that it's a declaration of a variable 
> > template.  Try this:
> >   template  T n = T();
> >   extern template int n;
> >   template int n;
> I see. I'll look into adding support for it. Can you explain why my example 
> doesn't work? GCC seems to allow this.
Bump on the question of differences to GCC here.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2456
@@ -2450,1 +2455,3 @@
+def err_unique_instantiation_not_previous : Error<
+  "'unique_instantiation' attribute must be specified for all declarations and 
definitions of this explicit template instantiation">;
 

aaron.ballman wrote:
> > They are checking for two different conditions in the spec. One requires 
> > that all explicit template instantiations with this attribute have a 
> > declaration, the other that every declaration/definition has the attribute.
> 
> Okay, I see now what this diagnostic is attempting to convey. I think it 
> should read:
> ```
> def err_unique_instantiation_no_declaration : Error<
>   "'unique_instantiation' attribute on an explicit instantiation requires a 
> previous explicit instantiation declaration">;
> ```
Sounds good.


Comment at: test/SemaCXX/unique-instantiations.cpp:23
@@ +22,2 @@
+extern template struct __attribute__((unique_instantiation)) foo5; // 
expected-note{{previous explicit instantiation is here}}
+template struct foo5;  // 
expected-error{{must be specified for all declarations}}

aaron.ballman wrote:
> Missing tests for correct usage of the attribute. Missing tests of the 
> attribute diagnosing when given arguments.
Isn't the correct usage checked for in the CodeGen tests above?


Repository:
  rL LLVM

http://reviews.llvm.org/D13330



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


Re: [PATCH] D14096: [clang-tidy] add new check cppcoreguidelines-pro-type-cstyle-cast

2015-11-06 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a reviewer: alexfh.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good with a comment. Thank you for contribution!



Comment at: test/clang-tidy/cppcoreguidelines-pro-type-cstyle-cast.cpp:14
@@ +13,3 @@
+  i = (int*)j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not use C-style cast to cast 
away constness [cppcoreguidelines-pro-type-cstyle-cast]
+  j = (const int*)i; // OK, const added

I think, it makes sense to leave the `[cppcoreguidelines-pro-type-cstyle-cast]` 
only once and remove it everywhere else to make the test easier to read.


http://reviews.llvm.org/D14096



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


Re: [PATCH] D7606: Fix adress cast for C++ in SEMA

2015-11-06 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 39619.
sfantao added a comment.

Rebase and add check to make sure the pointee of the pointers being casted 
match.

In a previous review, it was suggested by Richard Smith to move the check to 
the end of `TryReinterpretCast`. However, that does not solve the issue given 
that it is possible to have a successful cast try before the end of 
`TryReinterpretCast` is reached. The testcase in this patch is one of those 
cases.


http://reviews.llvm.org/D7606

Files:
  lib/Sema/Sema.cpp
  lib/Sema/SemaCast.cpp
  test/CodeGen/address-space-explicit-cast.c

Index: test/CodeGen/address-space-explicit-cast.c
===
--- /dev/null
+++ test/CodeGen/address-space-explicit-cast.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm -o - -x c %s | FileCheck -check-prefix=CHECK %s
+// RUN: %clang_cc1 -emit-llvm -o - -x c++ %s | FileCheck 
-check-prefix=CHECK-CXX %s
+
+typedef __attribute__((address_space(1))) char *AddrSpaceCharType;
+
+// CHECK-LABEL: @foo()
+// CHECK-CXX-LABEL: @_Z3foov()
+void foo() {
+  // CHECK: %p = alloca i8 addrspace(1)*
+  // CHECK-CXX: %p = alloca i8 addrspace(1)*
+  AddrSpaceCharType p;
+
+  // CHECK: store i8 addrspace(1)* addrspacecast ({{.*}} to i8 addrspace(1)*), 
i8 addrspace(1)** %p
+  // CHECK-CXX: store i8 addrspace(1)* addrspacecast ({{.*}} to i8 
addrspace(1)*), i8 addrspace(1)** %p
+  p = (AddrSpaceCharType) "a";
+}
Index: lib/Sema/SemaCast.cpp
===
--- lib/Sema/SemaCast.cpp
+++ lib/Sema/SemaCast.cpp
@@ -2036,7 +2036,7 @@
   << OpRange;
 return TC_Success;
   }
-  
+
   // C++ 5.2.10p7: A pointer to an object can be explicitly converted to
   //   a pointer to an object of different type.
   // Void pointers are not specified, but supported by every compiler out 
there.
@@ -2104,6 +2104,22 @@
   return;
 }
 
+  // If we are casting pointers, we need to check whether this refers to an
+  // address space cast.
+  if (DestType->isPointerType() && SrcExpr.get()->getType()->isPointerType()) {
+QualType DTy =
+Self.getASTContext().getCanonicalType(DestType->getPointeeType());
+QualType STy = Self.getASTContext().getCanonicalType(
+SrcExpr.get()->getType()->getPointeeType());
+// If the pointer point to the same type in different address spaces, this
+// is an address-space cast.
+if (STy.getTypePtr() == DTy.getTypePtr() &&
+STy.getAddressSpace() != DTy.getAddressSpace()) {
+  Kind = CK_AddressSpaceConversion;
+  return;
+}
+  }
+
   // C++ [expr.cast]p5: The conversions performed by
   //   - a const_cast,
   //   - a static_cast,
Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -392,6 +392,14 @@
   if (ExprTy == TypeTy)
 return E;
 
+  // In the event an address space cast is requested, the kind passed from the
+  // caller should not be CK_NoOp.
+  assert((Kind != CK_NoOp ||
+  !(ExprTy->isPointerType() && TypeTy->isPointerType() &&
+ExprTy->getPointeeType().getAddressSpace() !=
+TypeTy->getPointeeType().getAddressSpace())) &&
+ "NoOp is not a valid kind for and address cast");
+
   if (ImplicitCastExpr *ImpCast = dyn_cast(E)) {
 if (ImpCast->getCastKind() == Kind && (!BasePath || BasePath->empty())) {
   ImpCast->setType(Ty);


Index: test/CodeGen/address-space-explicit-cast.c
===
--- /dev/null
+++ test/CodeGen/address-space-explicit-cast.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm -o - -x c %s | FileCheck -check-prefix=CHECK %s
+// RUN: %clang_cc1 -emit-llvm -o - -x c++ %s | FileCheck -check-prefix=CHECK-CXX %s
+
+typedef __attribute__((address_space(1))) char *AddrSpaceCharType;
+
+// CHECK-LABEL: @foo()
+// CHECK-CXX-LABEL: @_Z3foov()
+void foo() {
+  // CHECK: %p = alloca i8 addrspace(1)*
+  // CHECK-CXX: %p = alloca i8 addrspace(1)*
+  AddrSpaceCharType p;
+
+  // CHECK: store i8 addrspace(1)* addrspacecast ({{.*}} to i8 addrspace(1)*), i8 addrspace(1)** %p
+  // CHECK-CXX: store i8 addrspace(1)* addrspacecast ({{.*}} to i8 addrspace(1)*), i8 addrspace(1)** %p
+  p = (AddrSpaceCharType) "a";
+}
Index: lib/Sema/SemaCast.cpp
===
--- lib/Sema/SemaCast.cpp
+++ lib/Sema/SemaCast.cpp
@@ -2036,7 +2036,7 @@
   << OpRange;
 return TC_Success;
   }
-  
+
   // C++ 5.2.10p7: A pointer to an object can be explicitly converted to
   //   a pointer to an object of different type.
   // Void pointers are not specified, but supported by every compiler out there.
@@ -2104,6 +2104,22 @@
   return;
 }
 
+  // If we are casting pointers, we need to check whether this refers to an
+  // address space cast.
+  if (DestType->isPointerType() && SrcExpr.get()->getType()->isPointerType()) {

Re: [PATCH] D14471: [AArch64] Fix a crash in driver

2015-11-06 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

Send the patch to cfe-commits.


http://reviews.llvm.org/D14471



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


Re: [PATCH] D14410: Cleanup: move all visibility attributes to the first declaration.

2015-11-06 Thread Evgeniy Stepanov via cfe-commits
eugenis closed this revision.
eugenis added a comment.

Confirmed and landed as r252385.
Thanks for the quick response!


Repository:
  rL LLVM

http://reviews.llvm.org/D14410



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


[libcxx] r252385 - Cleanup: move visibility/linkage attributes to the first declaration.

2015-11-06 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Fri Nov  6 19:22:13 2015
New Revision: 252385

URL: http://llvm.org/viewvc/llvm-project?rev=252385&view=rev
Log:
Cleanup: move visibility/linkage attributes to the first declaration.

This change moves visibility attributes from out-of-class method
definitions to in-class declaration. This is needed for a switch to
attribute((internal_linkage)) (see http://reviews.llvm.org/D13925)
which can only appear on the first declaration.

This change does not touch istream/ostream/streambuf. They are
handled separately in http://reviews.llvm.org/D14409.

Modified:
libcxx/trunk/include/__hash_table
libcxx/trunk/include/__mutex_base
libcxx/trunk/include/__split_buffer
libcxx/trunk/include/bitset
libcxx/trunk/include/condition_variable
libcxx/trunk/include/deque
libcxx/trunk/include/future
libcxx/trunk/include/locale
libcxx/trunk/include/memory
libcxx/trunk/include/random
libcxx/trunk/include/regex
libcxx/trunk/include/string
libcxx/trunk/include/thread
libcxx/trunk/include/valarray
libcxx/trunk/include/vector

Modified: libcxx/trunk/include/__hash_table
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=252385&r1=252384&r2=252385&view=diff
==
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Fri Nov  6 19:22:13 2015
@@ -836,6 +836,7 @@ public:
 typedef __hash_local_iterator<__node_pointer> local_iterator;
 typedef __hash_const_local_iterator<__node_pointer>   
const_local_iterator;
 
+_LIBCPP_INLINE_VISIBILITY
 __hash_table()
 _NOEXCEPT_(
 is_nothrow_default_constructible<__bucket_list>::value &&
@@ -843,6 +844,7 @@ public:
 is_nothrow_default_constructible<__node_allocator>::value &&
 is_nothrow_default_constructible::value &&
 is_nothrow_default_constructible::value);
+_LIBCPP_INLINE_VISIBILITY
 __hash_table(const hasher& __hf, const key_equal& __eql);
 __hash_table(const hasher& __hf, const key_equal& __eql,
  const allocator_type& __a);
@@ -863,6 +865,7 @@ public:
 
 __hash_table& operator=(const __hash_table& __u);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+_LIBCPP_INLINE_VISIBILITY
 __hash_table& operator=(__hash_table&& __u)
 _NOEXCEPT_(
 __node_traits::propagate_on_container_move_assignment::value &&
@@ -934,9 +937,13 @@ public:
 return __bucket_list_.get_deleter().size();
 }
 
+_LIBCPP_INLINE_VISIBILITY
 iterator   begin() _NOEXCEPT;
+_LIBCPP_INLINE_VISIBILITY
 iterator   end() _NOEXCEPT;
+_LIBCPP_INLINE_VISIBILITY
 const_iterator begin() const _NOEXCEPT;
+_LIBCPP_INLINE_VISIBILITY
 const_iterator end() const _NOEXCEPT;
 
 template 
@@ -965,6 +972,7 @@ public:
 __node_holder remove(const_iterator __p) _NOEXCEPT;
 
 template 
+_LIBCPP_INLINE_VISIBILITY
 size_type __count_unique(const _Key& __k) const;
 template 
 size_type __count_multi(const _Key& __k) const;
@@ -1130,7 +1138,7 @@ private:
 };
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table()
 _NOEXCEPT_(
 is_nothrow_default_constructible<__bucket_list>::value &&
@@ -1143,7 +1151,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf,
const key_equal& __eql)
 : __bucket_list_(nullptr, __bucket_list_deleter()),
@@ -1410,7 +1418,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 __hash_table<_Tp, _Hash, _Equal, _Alloc>&
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u)
 _NOEXCEPT_(
@@ -1495,7 +1503,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT
 {
@@ -1507,7 +1515,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT
 {
@@ -1519,7 +1527,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT
 {
@@ -1531,7 +1539,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline
 typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT
 {
@@ -22

r252376 - Use regex in test case.

2015-11-06 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Fri Nov  6 18:48:18 2015
New Revision: 252376

URL: http://llvm.org/viewvc/llvm-project?rev=252376&view=rev
Log:
Use regex in test case.

This is a follow-up to r252369.

Modified:
cfe/trunk/test/CodeGen/attr-no-tail.c

Modified: cfe/trunk/test/CodeGen/attr-no-tail.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-no-tail.c?rev=252376&r1=252375&r2=252376&view=diff
==
--- cfe/trunk/test/CodeGen/attr-no-tail.c (original)
+++ cfe/trunk/test/CodeGen/attr-no-tail.c Fri Nov  6 18:48:18 2015
@@ -6,7 +6,7 @@
 // Check that indirect calls do not have the notail marker.
 // CHECK: store i32 (i32)* @callee1, i32 (i32)** [[ALLOCA1:%[A-Za-z0-9]+]], 
align 8
 // CHECK: [[INDIRFUNC:%[0-9]+]] = load i32 (i32)*, i32 (i32)** [[ALLOCA1]], 
align 8
-// CHECK: %{{[a-z0-9]+}} = call i32 [[INDIRFUNC]](i32 %6)
+// CHECK: %{{[a-z0-9]+}} = call i32 [[INDIRFUNC]](i32 %{{[0-9]+}}
 
 // CHECK: %{{[a-z0-9]+}} = call i32 @callee2(i32 %
 


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


Re: [PATCH] D12614: [OpenMP] Offloading descriptor registration and device codegen.

2015-11-06 Thread John McCall via cfe-commits
rjmccall added a comment.

In http://reviews.llvm.org/D12614#284158, @sfantao wrote:

> As for the structor variants, I am now using the complete variant to generate 
> the names of the kernels as you suggested. I didn't add any method to CXXABI 
> as that will require extra logic in ASTContext to make that visible during 
> the code generation. Instead, I hardcoded `Ctor[Dtor]_Complete` in the code 
> generation, similarly to what is done in the name mangler. Let me know if 
> you'd rather have the method in CXXABI.


I think just using the complete variant is a totally reasonable choice.

I'll try to take a look at the rest of the patch soon.

John.


http://reviews.llvm.org/D12614



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


Re: [PATCH] D12922: Add support for function attribute "notail"

2015-11-06 Thread Akira Hatanaka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL252369: Add support for function attribute 
'not_tail_called'. (authored by ahatanak).

Changed prior to commit:
  http://reviews.llvm.org/D12922?vs=39003&id=39607#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12922

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Basic/AttrDocs.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/CodeGen/attr-no-tail.c
  cfe/trunk/test/CodeGenCXX/attr-notail.cpp
  cfe/trunk/test/Sema/attr-notail.c
  cfe/trunk/test/SemaCXX/attr-notail.cpp

Index: cfe/trunk/lib/CodeGen/CGCall.cpp
===
--- cfe/trunk/lib/CodeGen/CGCall.cpp
+++ cfe/trunk/lib/CodeGen/CGCall.cpp
@@ -3493,6 +3493,10 @@
   // lexical order, so deactivate it and run it manually here.
   CallArgs.freeArgumentMemory(*this);
 
+  if (llvm::CallInst *Call = dyn_cast(CI))
+if (TargetDecl && TargetDecl->hasAttr())
+  Call->setTailCallKind(llvm::CallInst::TCK_NoTail);
+
   RValue Ret = [&] {
 switch (RetAI.getKind()) {
 case ABIArgInfo::InAlloca:
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -5373,6 +5373,16 @@
   ND.setInvalidDecl();
 }
   }
+
+  // Virtual functions cannot be marked as 'notail'.
+  if (auto *Attr = ND.getAttr())
+if (auto *MD = dyn_cast(&ND))
+  if (MD->isVirtual()) {
+S.Diag(ND.getLocation(),
+   diag::err_invalid_attribute_on_virtual_function)
+<< Attr;
+ND.dropAttr();
+  }
 }
 
 static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl,
Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -1701,6 +1701,15 @@
Attr.getAttributeSpellingListIndex()));
 }
 
+static void handleNotTailCalledAttr(Sema &S, Decl *D,
+const AttributeList &Attr) {
+  if (checkAttrMutualExclusion(S, D, Attr))
+return;
+
+  D->addAttr(::new (S.Context) NotTailCalledAttr(
+  Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+}
+
 static void handleUsedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
   if (const VarDecl *VD = dyn_cast(D)) {
 if (VD->hasLocalStorage()) {
@@ -3419,6 +3428,9 @@
 
 static void handleAlwaysInlineAttr(Sema &S, Decl *D,
const AttributeList &Attr) {
+  if (checkAttrMutualExclusion(S, D, Attr))
+return;
+
   if (AlwaysInlineAttr *Inline = S.mergeAlwaysInlineAttr(
   D, Attr.getRange(), Attr.getName(),
   Attr.getAttributeSpellingListIndex()))
@@ -4991,6 +5003,9 @@
   case AttributeList::AT_ReturnsTwice:
 handleSimpleAttribute(S, D, Attr);
 break;
+  case AttributeList::AT_NotTailCalled:
+handleNotTailCalledAttr(S, D, Attr);
+break;
   case AttributeList::AT_Used:
 handleUsedAttr(S, D, Attr);
 break;
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2409,6 +2409,8 @@
   "%0 attribute ignored when parsing type">, InGroup;
 def err_base_specifier_attribute : Error<
   "%0 attribute cannot be applied to a base specifier">;
+def err_invalid_attribute_on_virtual_function : Error<
+  "%0 attribute cannot be applied to virtual functions">;
 
 // Availability attribute
 def warn_availability_unknown_platform : Warning<
Index: cfe/trunk/include/clang/Basic/AttrDocs.td
===
--- cfe/trunk/include/clang/Basic/AttrDocs.td
+++ cfe/trunk/include/clang/Basic/AttrDocs.td
@@ -1620,3 +1620,52 @@
 arguments, with arbitrary offsets.
   }];
 }
+
+def NotTailCalledDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``not_tail_called`` attribute prevents tail-call optimization on statically bound calls. It has no effect on indirect calls. Virtual functions, objective-c methods, and functions marked as ``always_inline`` cannot be marked as ``not_tail_called``.
+
+For example, it prevents tail-call optimization in the following case:
+  .. code-block: c
+  int __attribute__((not_tail_called)) foo1(int);
+
+  int foo2(int a) {
+return foo1(a); // No tail-call optimization on direct calls.
+  }
+
+However, it doesn't prevent tail-call optimization in this case:
+  .. code-block: c
+  int __attribute__((not_tail_called)) foo1(int);
+
+  int foo2(int a) {
+int (*fn)(int) = &foo1;
+
+// not_t

Re: [PATCH] D14459: Adjust printQualifiedName to handle unscoped enums in a way similar to anonymous namespaces.

2015-11-06 Thread Sterling Augustine via cfe-commits
saugustine updated this revision to Diff 39605.
saugustine added a comment.

Handle unscoped enum with name. Also add test cases.


http://reviews.llvm.org/D14459

Files:
  lib/AST/Decl.cpp
  unittests/AST/NamedDeclPrinterTest.cpp

Index: unittests/AST/NamedDeclPrinterTest.cpp
===
--- unittests/AST/NamedDeclPrinterTest.cpp
+++ unittests/AST/NamedDeclPrinterTest.cpp
@@ -131,3 +131,45 @@
 "A",
 "A"));
 }
+
+TEST(NamedDeclPrinter, TestUnscopedUnnamedEnum) {
+  ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches(
+"enum { A };",
+"A",
+"A"));
+}
+
+TEST(NamedDeclPrinter, TestNamedEnum) {
+  ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches(
+"enum X { A };",
+"A",
+"X::A"));
+}
+
+TEST(NamedDeclPrinter, TestScopedNamedEnum) {
+  ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches(
+"enum class X { A };",
+"A",
+"X::A"));
+}
+
+TEST(NamedDeclPrinter, TestClassWithUnscopedUnnamedEnum) {
+  ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches(
+"class X { enum { A }; };",
+"A",
+"X::A"));
+}
+
+TEST(NamedDeclPrinter, TestClassWithUnscopedNamedEnum) {
+  ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches(
+"class X { enum Y { A }; };",
+"A",
+"X::Y::A"));
+}
+
+TEST(NamedDeclPrinter, TestClassWithScopedNamedEnum) {
+  ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches(
+"class X { enum class Y { A }; };",
+"A",
+"X::Y::A"));
+}
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -1430,6 +1430,15 @@
 }
   }
   OS << ')';
+} else if (const EnumDecl *ED = dyn_cast(*I)) {
+  // C++ [dcl.enum]p10: Each enum-name and each unscoped
+  // enumerator is declared in the scope that immediately contains
+  // the enum-specifier. Each scoped enumerator is declared in the
+  // scope of the enumeration.
+  if (ED->isScoped() || ED->getIdentifier())
+OS << *ED;
+  else
+continue;
 } else {
   OS << *cast(*I);
 }


Index: unittests/AST/NamedDeclPrinterTest.cpp
===
--- unittests/AST/NamedDeclPrinterTest.cpp
+++ unittests/AST/NamedDeclPrinterTest.cpp
@@ -131,3 +131,45 @@
 "A",
 "A"));
 }
+
+TEST(NamedDeclPrinter, TestUnscopedUnnamedEnum) {
+  ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches(
+"enum { A };",
+"A",
+"A"));
+}
+
+TEST(NamedDeclPrinter, TestNamedEnum) {
+  ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches(
+"enum X { A };",
+"A",
+"X::A"));
+}
+
+TEST(NamedDeclPrinter, TestScopedNamedEnum) {
+  ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches(
+"enum class X { A };",
+"A",
+"X::A"));
+}
+
+TEST(NamedDeclPrinter, TestClassWithUnscopedUnnamedEnum) {
+  ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches(
+"class X { enum { A }; };",
+"A",
+"X::A"));
+}
+
+TEST(NamedDeclPrinter, TestClassWithUnscopedNamedEnum) {
+  ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches(
+"class X { enum Y { A }; };",
+"A",
+"X::Y::A"));
+}
+
+TEST(NamedDeclPrinter, TestClassWithScopedNamedEnum) {
+  ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches(
+"class X { enum class Y { A }; };",
+"A",
+"X::Y::A"));
+}
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -1430,6 +1430,15 @@
 }
   }
   OS << ')';
+} else if (const EnumDecl *ED = dyn_cast(*I)) {
+  // C++ [dcl.enum]p10: Each enum-name and each unscoped
+  // enumerator is declared in the scope that immediately contains
+  // the enum-specifier. Each scoped enumerator is declared in the
+  // scope of the enumeration.
+  if (ED->isScoped() || ED->getIdentifier())
+OS << *ED;
+  else
+continue;
 } else {
   OS << *cast(*I);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r252369 - Add support for function attribute 'not_tail_called'.

2015-11-06 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Fri Nov  6 17:56:15 2015
New Revision: 252369

URL: http://llvm.org/viewvc/llvm-project?rev=252369&view=rev
Log:
Add support for function attribute 'not_tail_called'.

This attribute is used to prevent tail-call optimizations to the marked
function. For example, in the following piece of code, foo1 will not be
tail-call optimized: 

int __attribute__((not_tail_called)) foo1(int);

int foo2(int a) {
  return foo1(a); // Tail-call optimization is not performed.
}

The attribute has effect only on statically bound calls. It has no
effect on indirect calls. Also, virtual functions and objective-c
methods cannot be marked as 'not_tail_called'.

rdar://problem/22667622

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

Added:
cfe/trunk/test/CodeGen/attr-no-tail.c
cfe/trunk/test/CodeGenCXX/attr-notail.cpp
cfe/trunk/test/Sema/attr-notail.c
cfe/trunk/test/SemaCXX/attr-notail.cpp
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=252369&r1=252368&r2=252369&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Fri Nov  6 17:56:15 2015
@@ -1029,6 +1029,12 @@ def NoInstrumentFunction : InheritableAt
   let Documentation = [Undocumented];
 }
 
+def NotTailCalled : InheritableAttr {
+  let Spellings = [GNU<"not_tail_called">, CXX11<"clang", "not_tail_called">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [NotTailCalledDocs];
+}
+
 def NoThrow : InheritableAttr {
   let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
   let Documentation = [Undocumented];

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=252369&r1=252368&r2=252369&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Fri Nov  6 17:56:15 2015
@@ -1620,3 +1620,52 @@ function are loads and stores from objec
 arguments, with arbitrary offsets.
   }];
 }
+
+def NotTailCalledDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``not_tail_called`` attribute prevents tail-call optimization on 
statically bound calls. It has no effect on indirect calls. Virtual functions, 
objective-c methods, and functions marked as ``always_inline`` cannot be marked 
as ``not_tail_called``.
+
+For example, it prevents tail-call optimization in the following case:
+  .. code-block: c
+  int __attribute__((not_tail_called)) foo1(int);
+
+  int foo2(int a) {
+return foo1(a); // No tail-call optimization on direct calls.
+  }
+
+However, it doesn't prevent tail-call optimization in this case:
+  .. code-block: c
+  int __attribute__((not_tail_called)) foo1(int);
+
+  int foo2(int a) {
+int (*fn)(int) = &foo1;
+
+// not_tail_called has no effect on an indirect call even if the call can 
be
+// resolved at compile time.
+return (*fn)(a);
+  }
+
+Marking virtual functions as ``not_tail_called`` is an error:
+  .. code-block: c++
+  class Base {
+  public:
+// not_tail_called on a virtual function is an error.
+[[clang::not_tail_called]] virtual int foo1();
+
+virtual int foo2();
+
+// Non-virtual functions can be marked ``not_tail_called``.
+[[clang::not_tail_called]] int foo3();
+  };
+
+  class Derived1 : public Base {
+  public:
+int foo1() override;
+
+// not_tail_called on a virtual function is an error.
+[[clang::not_tail_called]] int foo2() override;
+  };
+
+  }];
+}

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=252369&r1=252368&r2=252369&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Nov  6 17:56:15 
2015
@@ -2409,6 +2409,8 @@ def warn_attribute_not_on_decl : Warning
   "%0 attribute ignored when parsing type">, InGroup;
 def err_base_specifier_attribute : Error<
   "%0 attribute cannot be applied to a base specifier">;
+def err_invalid_attribute_on_virtual_function : Error<
+  "%0 attribute cannot be applied to virtual functions">;
 
 // Availability attribute
 def warn_availability_unknown_platform : Warning<

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=252369&r1=252368&r2=

[PATCH] D14467: [MS] Fix for bug 25013 - #pragma vtordisp is unknown inside functions.

2015-11-06 Thread Denis Zobnin via cfe-commits
d.zobnin.bugzilla created this revision.
d.zobnin.bugzilla added a reviewer: rnk.
d.zobnin.bugzilla added a subscriber: cfe-commits.

This patch adds support of #pragma vtordisp inside functions in attempt to 
improve compatibility. Microsoft compiler appears to save the stack of vtordisp 
modes on entry of struct methods' bodies and restore it on exit (method-local 
vtordisp).

http://reviews.llvm.org/D14467

Files:
  include/clang/Sema/Sema.h
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseStmt.cpp
  test/Layout/ms-vtordisp-local.cpp
  test/SemaCXX/pragma-vtordisp.cpp

Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -2854,6 +2854,11 @@
 return DeclGroupPtrTy();
   }
 
+  if (Tok.is(tok::annot_pragma_ms_vtordisp)) {
+HandlePragmaMSVtorDisp();
+return DeclGroupPtrTy();
+  }
+
   // If we see a namespace here, a close brace was missing somewhere.
   if (Tok.is(tok::kw_namespace)) {
 DiagnoseUnexpectedNamespace(cast(TagDecl));
Index: lib/Parse/ParseStmt.cpp
===
--- lib/Parse/ParseStmt.cpp
+++ lib/Parse/ParseStmt.cpp
@@ -358,6 +358,11 @@
 HandlePragmaMSPragma();
 return StmtEmpty();
 
+  case tok::annot_pragma_ms_vtordisp:
+ProhibitAttributes(Attrs);
+HandlePragmaMSVtorDisp();
+return StmtEmpty();
+
   case tok::annot_pragma_loop_hint:
 ProhibitAttributes(Attrs);
 return ParsePragmaLoopHint(Stmts, OnlyStatement, TrailingElseLoc, Attrs);
@@ -885,6 +890,9 @@
 case tok::annot_pragma_ms_pragma:
   HandlePragmaMSPragma();
   break;
+case tok::annot_pragma_ms_vtordisp:
+  HandlePragmaMSVtorDisp();
+  break;
 default:
   checkForPragmas = false;
   break;
@@ -1895,6 +1903,11 @@
   PrettyDeclStackTraceEntry CrashInfo(Actions, Decl, LBraceLoc,
   "parsing function body");
 
+  // Save and reset current vtordisp stack if we have entered a C++ method body.
+  bool IsCXXMethod =
+  getLangOpts().CPlusPlus && Decl && isa(Decl);
+  Sema::VtorDispStackRAII SavedVtorDispStack(Actions, IsCXXMethod);
+
   // Do not enter a scope for the brace, as the arguments are in the same scope
   // (the function body) as the body itself.  Instead, just read the statement
   // list and put it into a CompoundStmt for safe keeping.
@@ -1934,6 +1947,11 @@
 return Actions.ActOnSkippedFunctionBody(Decl);
   }
 
+  // Save and reset current vtordisp stack if we have entered a C++ method body.
+  bool IsCXXMethod =
+  getLangOpts().CPlusPlus && Decl && isa(Decl);
+  Sema::VtorDispStackRAII SavedVtorDispStack(Actions, IsCXXMethod);
+
   SourceLocation LBraceLoc = Tok.getLocation();
   StmtResult FnBody(ParseCXXTryBlockCommon(TryLoc, /*FnTry*/true));
   // If we failed to parse the try-catch, we just give the function an empty
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -1008,6 +1008,24 @@
 bool OldFPContractState : 1;
   };
 
+  /// Records and restores the vtordisp state on entry/exit of C++ method body.
+  class VtorDispStackRAII {
+  public:
+VtorDispStackRAII(Sema &S, bool ShouldSaveAndRestore)
+  : S(S), ShouldSaveAndRestore(ShouldSaveAndRestore), OldVtorDispStack() {
+  if (ShouldSaveAndRestore)
+OldVtorDispStack = S.VtorDispModeStack;
+}
+~VtorDispStackRAII() {
+  if (ShouldSaveAndRestore)
+S.VtorDispModeStack = OldVtorDispStack;
+}
+  private:
+Sema &S;
+bool ShouldSaveAndRestore;
+SmallVector OldVtorDispStack;
+  };
+
   void addImplicitTypedef(StringRef Name, QualType T);
 
 public:
Index: test/Layout/ms-vtordisp-local.cpp
===
--- test/Layout/ms-vtordisp-local.cpp
+++ test/Layout/ms-vtordisp-local.cpp
@@ -0,0 +1,194 @@
+// RUN: %clang_cc1 -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm-only -triple x86_64-pc-win32 -fdump-record-layouts -fsyntax-only %s 2>&1 | FileCheck %s
+
+struct Base {
+  virtual ~Base() {}
+  virtual void BaseFunc() {}
+};
+
+#pragma vtordisp(0)
+
+struct Container {
+  static void f() try {
+#pragma vtordisp(2)
+struct HasVtorDisp : virtual Base {
+  virtual ~HasVtorDisp() {}
+  virtual void Func() {}
+};
+
+int x[sizeof(HasVtorDisp)];
+
+// HasVtorDisp: vtordisp because of pragma right before it.
+//
+// CHECK: *** Dumping AST Record Layout
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct HasVtorDisp
+// CHECK-NEXT:  0 |   (HasVtorDisp vftable pointer)
+// CHECK-NEXT:  8 |   (HasVtorDisp vbtable pointer)
+// CHECK-NEXT: 20 |   (vtordisp for vbase Base)
+// CHECK-NEXT: 24 |   struct Base (virtual base)
+// CHECK-NEXT: 24 | (Base 

Re: [PATCH] D12547: Add support for function attribute "disable_tail_calls"

2015-11-06 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

I intend to change the documentation, but other than that there should be no 
changes.

I'll upload a rebased patch after I commit the other tail call patches.


http://reviews.llvm.org/D12547



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


Re: [PATCH] D13746: [clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-index

2015-11-06 Thread Matthias Gehre via cfe-commits
mgehre updated this revision to Diff 39601.
mgehre added a comment.

Add option GslHeader, generate fixes


http://reviews.llvm.org/D13746

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h
  docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp
@@ -0,0 +1,72 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-bounds-constant-array-index %t -- -config='{CheckOptions: [{key: cppcoreguidelines-pro-bounds-constant-array-index.GslHeader, value: "dir1/gslheader.h"}]}' -- -std=c++11
+#include 
+// CHECK-FIXES: #include "dir1/gslheader.h"
+
+namespace gsl {
+  template
+  T& at( T(&a)[N], size_t index );
+
+  template
+  T& at( std::array &a, size_t index );
+}
+
+constexpr int const_index(int base) {
+  return base + 3;
+}
+
+void f(std::array a, int pos) {
+  a [ pos / 2 /*comment*/] = 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use array subscript when the index is not a compile-time constant; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
+  // CHECK-FIXES: gsl::at(a,  pos / 2 /*comment*/) = 1;
+  int j = a[pos - 1];
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not use array subscript when the index is not a compile-time constant; use gsl::at() instead
+  // CHECK-FIXES: int j = gsl::at(a, pos - 1);
+
+  a.at(pos-1) = 2; // OK, at() instead of []
+  gsl::at(a, pos-1) = 2; // OK, gsl::at() instead of []
+
+  a[-1] = 3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: array index -1 is before the beginning of the array [cppcoreguidelines-pro-bounds-constant-array-index]
+  a[10] = 4;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: array index 10 is past the end of the array (which contains 10 elements) [cppcoreguidelines-pro-bounds-constant-array-index]
+
+  a[const_index(7)] = 3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: array index 10 is past the end of the array (which contains 10 elements)
+
+  a[0] = 3; // OK, constant index and inside bounds
+  a[1] = 3; // OK, constant index and inside bounds
+  a[9] = 3; // OK, constant index and inside bounds
+  a[const_index(6)] = 3; // OK, constant index and inside bounds
+}
+
+void g() {
+  int a[10];
+  for (int i = 0; i < 10; ++i) {
+a[i] = i;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use array subscript when the index is not a compile-time constant; use gsl::at() instead
+// CHECK-FIXES: gsl::at(a, i) = i;
+gsl::at(a, i) = i; // OK, gsl::at() instead of []
+  }
+
+  a[-1] = 3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: array index -1 is before the beginning of the array
+  a[10] = 4;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: array index 10 is past the end of the array (which contains 10 elements)
+  a[const_index(7)] = 3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: array index 10 is past the end of the array (which contains 10 elements)
+
+  a[0] = 3; // OK, constant index and inside bounds
+  a[1] = 3; // OK, constant index and inside bounds
+  a[9] = 3; // OK, constant index and inside bounds
+  a[const_index(6)] = 3; // OK, constant index and inside bounds
+}
+
+struct S {
+  int& operator[](int i);
+};
+
+void customOperator() {
+  S s;
+  int i = 0;
+  s[i] = 3; // OK, custom operator
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -5,6 +5,7 @@
cert-setlongjmp
cert-variadic-function-def
cppcoreguidelines-pro-bounds-array-to-pointer-decay
+   cppcoreguidelines-pro-bounds-constant-array-index
cppcoreguidelines-pro-bounds-pointer-arithmetic
cppcoreguidelines-pro-type-const-cast
cppcoreguidelines-pro-type-reinterpret-cast
Index: docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst
@@ -0,0 +1,12 @@
+cppcoreguidelines-pro-bounds-constant-array-index
+=
+
+This check flags all array subscriptions on static arrays and std::arrays that either have a non-compile-time constant index or are out of bounds.
+
+Dynamic accesses into arrays are difficult for both tools and humans to validate as safe. array_view is a bounds-checked, safe type for accessing arrays of data. at() is another alternative that ensures single accesses are bounds-checked.

Re: [PATCH] D14403: Create install targets for scan-build and scan-view

2015-11-06 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

In http://reviews.llvm.org/D14403#284054, @beanz wrote:

> I would prefer if installing these were optional and could be toggled on/off.


I'll add flags for that.


http://reviews.llvm.org/D14403



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


r252360 - StaticAnalyzer: Remove implicit ilist iterator conversions, NFC

2015-11-06 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Fri Nov  6 17:04:58 2015
New Revision: 252360

URL: http://llvm.org/viewvc/llvm-project?rev=252360&view=rev
Log:
StaticAnalyzer: Remove implicit ilist iterator conversions, NFC

Remove implicit ilist iterator conversions from clangStaticAnalyzer.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=252360&r1=252359&r2=252360&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Fri Nov  6 17:04:58 2015
@@ -3290,11 +3290,11 @@ FindReportInEquivalenceClass(BugReportEq
   // post-dominated by a sink, simply add all the nodes in the equivalence 
class
   // to 'Nodes'.  Any of the reports will serve as a "representative" report.
   if (!BT.isSuppressOnSink()) {
-BugReport *R = I;
+BugReport *R = &*I;
 for (BugReportEquivClass::iterator I=EQ.begin(), E=EQ.end(); I!=E; ++I) {
   const ExplodedNode *N = I->getErrorNode();
   if (N) {
-R = I;
+R = &*I;
 bugReports.push_back(R);
   }
 }
@@ -3320,9 +3320,9 @@ FindReportInEquivalenceClass(BugReportEq
 }
 // No successors?  By definition this nodes isn't post-dominated by a sink.
 if (errorNode->succ_empty()) {
-  bugReports.push_back(I);
+  bugReports.push_back(&*I);
   if (!exampleReport)
-exampleReport = I;
+exampleReport = &*I;
   continue;
 }
 
@@ -3346,9 +3346,9 @@ FindReportInEquivalenceClass(BugReportEq
 if (Succ->succ_empty()) {
   // If we found an end-of-path node that is not a sink.
   if (!Succ->isSink()) {
-bugReports.push_back(I);
+bugReports.push_back(&*I);
 if (!exampleReport)
-  exampleReport = I;
+  exampleReport = &*I;
 WL.clear();
 break;
   }


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


Re: [PATCH] D12473: [clang-tidy] Add old style function check

2015-11-06 Thread Piotr Dziwinski via cfe-commits
piotrdz abandoned this revision.
piotrdz added a comment.

@alexfh: Ah, I forgot about this review. I will mark it as abandoned, because I 
have already started work on new check for localizing variables. It will have 
the wider scope that Eugene proposed originally, that is to move variable 
declarations closer to their first use. If you're curious how the code looks, 
you can see it on my Github fork: https://github.com/piotrdz/clang-tools-extra, 
as I said in discussion on cfe-dev some time ago. I will submit this new check 
in a new review once I finish it.


http://reviews.llvm.org/D12473



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


r252358 - CodeGen: Remove implicit ilist iterator conversions, NFC

2015-11-06 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Fri Nov  6 17:00:41 2015
New Revision: 252358

URL: http://llvm.org/viewvc/llvm-project?rev=252358&view=rev
Log:
CodeGen: Remove implicit ilist iterator conversions, NFC

Make ilist iterator conversions explicit in clangCodeGen.  Eventually
I'll remove them everywhere.

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGCleanup.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenPGO.cpp

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=252358&r1=252357&r2=252358&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Fri Nov  6 17:00:41 2015
@@ -1264,10 +1264,9 @@ CodeGenFunction::GenerateBlockFunction(G
   continue;
 }
 
-DI->EmitDeclareOfBlockDeclRefVariable(variable, BlockPointerDbgLoc,
-  Builder, blockInfo,
-  entry_ptr == entry->end()
-  ? nullptr : entry_ptr);
+DI->EmitDeclareOfBlockDeclRefVariable(
+variable, BlockPointerDbgLoc, Builder, blockInfo,
+entry_ptr == entry->end() ? nullptr : &*entry_ptr);
   }
 }
 // Recover location if it was changed in the above loop.

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=252358&r1=252357&r2=252358&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Fri Nov  6 17:00:41 2015
@@ -2350,7 +2350,7 @@ void CodeGenFunction::EmitFunctionEpilog
 if (RetAI.getInAllocaSRet()) {
   llvm::Function::arg_iterator EI = CurFn->arg_end();
   --EI;
-  llvm::Value *ArgStruct = EI;
+  llvm::Value *ArgStruct = &*EI;
   llvm::Value *SRet = Builder.CreateStructGEP(
   nullptr, ArgStruct, RetAI.getInAllocaFieldIndex());
   RV = Builder.CreateAlignedLoad(SRet, getPointerAlign(), "sret");
@@ -2365,7 +2365,7 @@ void CodeGenFunction::EmitFunctionEpilog
 case TEK_Complex: {
   ComplexPairTy RT =
 EmitLoadOfComplex(MakeAddrLValue(ReturnValue, RetTy), EndLoc);
-  EmitStoreOfComplex(RT, MakeNaturalAlignAddrLValue(AI, RetTy),
+  EmitStoreOfComplex(RT, MakeNaturalAlignAddrLValue(&*AI, RetTy),
  /*isInit*/ true);
   break;
 }
@@ -2374,7 +2374,7 @@ void CodeGenFunction::EmitFunctionEpilog
   break;
 case TEK_Scalar:
   EmitStoreOfScalar(Builder.CreateLoad(ReturnValue),
-MakeNaturalAlignAddrLValue(AI, RetTy),
+MakeNaturalAlignAddrLValue(&*AI, RetTy),
 /*isInit*/ true);
   break;
 }

Modified: cfe/trunk/lib/CodeGen/CGCleanup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.cpp?rev=252358&r1=252357&r2=252358&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCleanup.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCleanup.cpp Fri Nov  6 17:00:41 2015
@@ -945,8 +945,8 @@ void CodeGenFunction::PopCleanupBlock(bo
 if (CleanupEndBB) {
   EHStack.popPadEnd();
   if (CleanupEndBB->hasNUsesOrMore(1)) {
-CurFn->getBasicBlockList().insertAfter(Builder.GetInsertBlock(),
-   CleanupEndBB);
+CurFn->getBasicBlockList().insertAfter(
+Builder.GetInsertBlock()->getIterator(), CleanupEndBB);
   } else {
 delete CleanupEndBB;
   }

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=252358&r1=252357&r2=252358&view=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Fri Nov  6 17:00:41 2015
@@ -1577,7 +1577,7 @@ void CodeGenFunction::EmitCapturedLocals
 // second parameter.
 auto AI = CurFn->arg_begin();
 ++AI;
-ParentFP = AI;
+ParentFP = &*AI;
   }
 
   // Create llvm.localrecover calls for all captures.
@@ -1732,8 +1732,7 @@ void CodeGenFunction::EmitSEHExceptionCo
   // __exception_info intrinsic.
   if (CGM.getTarget().getTriple().getArch() != llvm::Triple::x86) {
 // On Win64, the info is passed as the first parameter to the filter.
-auto AI = CurFn->arg_begin();
-SEHInfo

Re: [PATCH] D14184: [clang] Add initial support for -meabi flag

2015-11-06 Thread Vinicius Tinti via cfe-commits
tinti marked 6 inline comments as done.


Comment at: lib/Driver/Tools.cpp:3415
@@ -3414,1 +3414,3 @@
 
+  if (Arg *A = Args.getLastArg(options::OPT_meabi)) {
+CmdArgs.push_back("-meabi");

Good point! Fixed.


Comment at: lib/Frontend/CompilerInvocation.cpp:460
@@ +459,3 @@
+StringRef Value = A->getValue();
+llvm::EABI EABIVersion = llvm::StringSwitch(Value)
+ .Case("default", llvm::EABI::Default)

I have added. It requires to add an invalid or more apropriate name Unknown 
version.

If the backend ever sees an Unknown it will consider it as a Default.
The frontend considers Unknown as an invalid state and raises an error.


Repository:
  rL LLVM

http://reviews.llvm.org/D14184



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


Re: [PATCH] D14184: [clang] Add initial support for -meabi flag

2015-11-06 Thread Vinicius Tinti via cfe-commits
tinti set the repository for this revision to rL LLVM.
tinti updated this revision to Diff 39596.
tinti marked an inline comment as done.
tinti added a comment.

- Add test for error check
- Change StringSwitch to use lllvm::EABI type


Repository:
  rL LLVM

http://reviews.llvm.org/D14184

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/arm-eabi.c
  test/Driver/eabi.c

Index: test/Driver/eabi.c
===
--- /dev/null
+++ test/Driver/eabi.c
@@ -0,0 +1,13 @@
+// RUN: %clang %s -meabi 4 -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-EABI4 %s
+// RUN: %clang %s -meabi 5 -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-EABI5 %s
+// RUN: %clang %s -meabi gnu -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-GNUEABI %s
+// RUN: not %clang %s -meabi unknown 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-UNKNOWN %s
+
+// CHECK-EABI4: "-meabi" "4"
+// CHECK-EABI5: "-meabi" "5"
+// CHECK-GNUEABI: "-meabi" "gnu"
+// CHECK-UNKNOWN: error: invalid value 'unknown' in '-meabi unknown'
Index: test/CodeGen/arm-eabi.c
===
--- /dev/null
+++ test/CodeGen/arm-eabi.c
@@ -0,0 +1,20 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang -target arm-none-eabi -S -o - %s | FileCheck -check-prefix=CHECK-EABI %s
+// RUN: %clang -target arm-none-eabi -S -meabi gnu -o - %s | FileCheck -check-prefix=CHECK-GNUEABI %s
+// RUN: %clang -target arm-none-eabihf -S -o - %s | FileCheck -check-prefix=CHECK-EABI %s
+// RUN: %clang -target arm-none-eabihf -S -meabi gnu -o - %s | FileCheck -check-prefix=CHECK-GNUEABI %s
+// RUN: %clang -target arm-none-gnueabi -S -o - %s | FileCheck -check-prefix=CHECK-GNUEABI %s
+// RUN: %clang -target arm-none-gnueabi -S -meabi 5 -o - %s | FileCheck -check-prefix=CHECK-EABI %s
+// RUN: %clang -target arm-none-gnueabihf -S -o - %s | FileCheck -check-prefix=CHECK-GNUEABI %s
+// RUN: %clang -target arm-none-gnueabihf -S -meabi 5 -o - %s | FileCheck -check-prefix=CHECK-EABI %s
+
+struct my_s {
+  unsigned long a[18];
+};
+
+// CHECK-LABEL: foo
+// CHECK-EABI: bl __aeabi_memcpy4
+// CHECK-GNUEABI: bl memcpy
+void foo(unsigned long *t) {
+  *(struct my_s *)t = *((struct my_s *)(1UL));
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -36,6 +36,7 @@
 #include "llvm/Support/Host.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
+#include "llvm/Target/TargetOptions.h"
 #include 
 #include 
 #include 
@@ -454,6 +455,20 @@
   Opts.DisableFree = Args.hasArg(OPT_disable_free);
   Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
   Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
+  if (Arg *A = Args.getLastArg(OPT_meabi)) {
+StringRef Value = A->getValue();
+llvm::EABI EABIVersion = llvm::StringSwitch(Value)
+ .Case("default", llvm::EABI::Default)
+ .Case("4", llvm::EABI::EABI4)
+ .Case("5", llvm::EABI::EABI5)
+ .Case("gnu", llvm::EABI::GNU)
+ .Default(llvm::EABI::Unknown);
+if (EABIVersion == llvm::EABI::Unknown)
+  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
+<< Value;
+else
+  Opts.EABIVersion = Value;
+  }
   Opts.LessPreciseFPMAD = Args.hasArg(OPT_cl_mad_enable);
   Opts.LimitFloatPrecision = Args.getLastArgValue(OPT_mlimit_float_precision);
   Opts.NoInfsFPMath = (Args.hasArg(OPT_menable_no_infinities) ||
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3412,6 +3412,11 @@
 }
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_meabi)) {
+CmdArgs.push_back("-meabi");
+CmdArgs.push_back(A->getValue());
+  }
+
   CmdArgs.push_back("-mthread-model");
   if (Arg *A = Args.getLastArg(options::OPT_mthread_model))
 CmdArgs.push_back(A->getValue());
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -515,6 +515,14 @@
   Options.UseInitArray = CodeGenOpts.UseInitArray;
   Options.DisableIntegratedAS = CodeGenOpts.DisableIntegratedAS;
   Options.CompressDebugSections = CodeGenOpts.CompressDebugSections;
+
+  // Set EABI version.
+  Options.EABIVersion = llvm::StringSwitch(CodeGenOpts.EABIVersion)
+.Case("4", llvm::EABI::EABI4)
+.Case("5", llvm::EABI::EABI5)
+.Case("gnu", llvm::EABI::GNU)
+  

Re: [PATCH] D9888: [OPENMP] Driver support for OpenMP offloading

2015-11-06 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 39594.
sfantao added a comment.

Rebase.


http://reviews.llvm.org/D9888

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/Action.h
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Driver.h
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  include/clang/Driver/Types.h
  lib/Driver/Action.cpp
  lib/Driver/Compilation.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  lib/Driver/Types.cpp
  test/OpenMP/target_driver.c

Index: test/OpenMP/target_driver.c
===
--- /dev/null
+++ test/OpenMP/target_driver.c
@@ -0,0 +1,195 @@
+///
+/// Perform several driver tests for OpenMP offloading
+///
+
+/// ###
+
+/// Check whether an invalid OpenMP target is specified:
+// RUN:   %clang -### -fopenmp=libomp -omptargets=aaa-bbb-ccc-ddd %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-INVALID-TARGET %s
+// CHK-INVALID-TARGET: error: OpenMP target is invalid: 'aaa-bbb-ccc-ddd'
+
+/// ###
+
+/// Check warning for empty -omptargets
+// RUN:   %clang -### -fopenmp=libomp -omptargets=  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-EMPTY-OMPTARGETS %s
+// CHK-EMPTY-OMPTARGETS: warning: joined argument expects additional value: '-omptargets='
+
+/// ###
+
+/// Check the phases graph when using a single target, different from the host.
+/// The actions should be exactly the same as if not offloading was being used.
+// RUN:   %clang -ccc-print-phases -fopenmp=libomp -target powerpc64-ibm-linux-gnu -omptargets=x86_64-pc-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PHASES %s
+
+// CHK-PHASES-DAG: {{.*}}: linker, {[[A0:[0-9]+]]}, image
+// CHK-PHASES-DAG: [[A0]]: assembler, {[[A1:[0-9]+]]}, object
+// CHK-PHASES-DAG: [[A1]]: backend, {[[A2:[0-9]+]]}, assembler
+// CHK-PHASES-DAG: [[A2]]: compiler, {[[A3:[0-9]+]]}, ir
+// CHK-PHASES-DAG: [[A3]]: preprocessor, {[[I:[0-9]+]]}, cpp-output
+// CHK-PHASES-DAG: [[I]]: input, {{.*}}, c
+
+/// ###
+
+/// Check the phases when using multiple targets. Again, the actions are the
+/// same as if no offloading was being used. Here we also add a library to make
+/// sure it is not treated as input.
+// RUN:   %clang -ccc-print-phases -lm -fopenmp=libomp -target powerpc64-ibm-linux-gnu -omptargets=x86_64-pc-linux-gnu,powerpc64-ibm-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PHASES-LIB %s
+
+// CHK-PHASES-LIB-DAG: {{.*}}: linker, {[[L0:[0-9]+]], [[A0:[0-9]+]]}, image
+// CHK-PHASES-LIB-DAG: [[A0]]: assembler, {[[A1:[0-9]+]]}, object
+// CHK-PHASES-LIB-DAG: [[A1]]: backend, {[[A2:[0-9]+]]}, assembler
+// CHK-PHASES-LIB-DAG: [[A2]]: compiler, {[[A3:[0-9]+]]}, ir
+// CHK-PHASES-LIB-DAG: [[A3]]: preprocessor, {[[I:[0-9]+]]}, cpp-output
+// CHK-PHASES-LIB-DAG: [[I]]: input, {{.*}}, c
+// CHK-PHASES-LIB-DAG: [[L0]]: input, "m", object
+
+/// ###
+
+/// Check the phases when using multiple targets and passing an object file as
+/// input. An unbundling action has to be created.
+// RUN:   echo 'bla' > %t.o
+// RUN:   %clang -ccc-print-phases -lm -fopenmp=libomp -target powerpc64-ibm-linux-gnu -omptargets=x86_64-pc-linux-gnu,powerpc64-ibm-linux-gnu %s %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PHASES-OBJ %s
+
+// CHK-PHASES-OBJ-DAG: {{.*}}: linker, {[[L0:[0-9]+]], [[A0:[0-9]+]], [[B0:[0-9]+]]}, image
+// CHK-PHASES-OBJ-DAG: [[A0]]: assembler, {[[A1:[0-9]+]]}, object
+// CHK-PHASES-OBJ-DAG: [[A1]]: backend, {[[A2:[0-9]+]]}, assembler
+// CHK-PHASES-OBJ-DAG: [[A2]]: compiler, {[[A3:[0-9]+]]}, ir
+// CHK-PHASES-OBJ-DAG: [[A3]]: preprocessor, {[[I:[0-9]+]]}, cpp-output
+// CHK-PHASES-OBJ-DAG: [[I]]: input, {{.*}}, c
+// CHK-PHASES-OBJ-DAG: [[L0]]: input, "m", object
+// CHK-PHASES-OBJ-DAG: [[B0]]: clang-offload-unbundler, {[[B1:[0-9]+]]}, object
+// CHK-PHASES-OBJ-DAG: [[B1]]: input, "{{.*}}.o", object
+
+/// ###
+
+/// Check the phases when using multiple targets and separate compilation.
+// RUN:   echo 'bla' > %t.s
+// RUN:   %clang -ccc-print-phases -c -lm -fopenmp=libomp -target powerpc64-ibm-linux-gnu -omptargets=x86_64-pc-linux-gnu,powerpc64-ibm-linux-gnu %t.s -x cpp-output %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PHASES-SEP %s
+
+// CHK-PHASES-SEP-DAG: [[A:[0-9]+]]: input, "{{.*}}.c", cpp-output
+// CHK-PHASES-SEP-DAG: [[A1:[0-9]+]]: clang-offload-unbundler, {[[A]]}, cpp-output
+// CHK-PHASES-SEP-DAG: [[A2:[0-9]+]]: compiler, {[[A1]]}, ir
+// CHK-PHASES-SEP-DAG: 

Re: [PATCH] D13909: clang-offload-bundler - offload files bundling/unbundling tool

2015-11-06 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 39590.
sfantao added a comment.

Rebase.


http://reviews.llvm.org/D13909

Files:
  tools/CMakeLists.txt
  tools/Makefile
  tools/clang-offload-bundler/CMakeLists.txt
  tools/clang-offload-bundler/ClangOffloadBundler.cpp
  tools/clang-offload-bundler/Makefile

Index: tools/clang-offload-bundler/Makefile
===
--- /dev/null
+++ tools/clang-offload-bundler/Makefile
@@ -0,0 +1,21 @@
+##===- clang-offload-bundler/Makefile --*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===--===##
+
+CLANG_LEVEL := ../..
+
+TOOLNAME = clang-offload-bundler
+
+# No plugins, optimize startup time.
+TOOL_NO_EXPORTS = 1
+
+include $(CLANG_LEVEL)/../../Makefile.config
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) support option
+USEDLIBS = clangBasic.a
+
+include $(CLANG_LEVEL)/Makefile
Index: tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- /dev/null
+++ tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -0,0 +1,548 @@
+//===-- clang-offload-bundler/ClangOffloadBundler.cpp - Clang format tool -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief This file implements a clang-offload-bundler that bundles different
+/// files that relate with the same source code but different targets into a
+/// single one. Also the implements the opposite functionality, i.e. unbundle
+/// files previous created by this tool.
+///
+//===--===//
+
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/Version.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Signals.h"
+
+using namespace llvm;
+
+static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
+
+// Mark all our options with this category, everything else (except for -version
+// and -help) will be hidden.
+static cl::OptionCategory
+ClangOffloadBundlerCategory("clang-offload-bundler options");
+
+static cl::list
+InputFileNames("inputs", cl::CommaSeparated, cl::OneOrMore,
+   cl::desc("[,...]"),
+   cl::cat(ClangOffloadBundlerCategory));
+static cl::list
+OutputFileNames("outputs", cl::CommaSeparated, cl::OneOrMore,
+cl::desc("[,...]"),
+cl::cat(ClangOffloadBundlerCategory));
+static cl::list TargetNames("targets", cl::CommaSeparated,
+ cl::OneOrMore,
+ cl::desc("[,...]"),
+ cl::cat(ClangOffloadBundlerCategory));
+static cl::opt
+FilesType("type", cl::Required,
+  cl::desc("Type of the files to be bundled/unbundled.\n"
+   "Current supported types are:\n"
+   "  i   - cpp-output\n"
+   "  ii  - c++-cpp-output\n"
+   "  ll  - llvm\n"
+   "  bc  - llvm-bc\n"
+   "  s   - assembler\n"
+   "  o   - object\n"
+   "  gch - precompiled-header"),
+  cl::cat(ClangOffloadBundlerCategory));
+static cl::opt
+Unbundle("unbundle",
+ cl::desc("Unbundle bundled file into several output files.\n"),
+ cl::init(false), cl::cat(ClangOffloadBundlerCategory));
+
+/// \brief Magic string that marks the existence of offloading data.
+#define OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__"
+
+/// \brief Generic file handler interface.
+class FileHandler {
+protected:
+  /// \brief Update the file handler with information from the header of the
+  /// bundled file
+  virtual void ReadHeader(MemoryBuffer &Input) = 0;
+  /// \brief Read the marker of the next bundled to be read in the file. The
+  /// triple of the target associated with that bundled is returned. An empty
+  /// string is returned if there are no more bundles to be read.
+  virtual StringRef ReadBundleStart(MemoryBuffer &Input) = 0;
+  /// \brief Read the marker that closes the current bundle.
+  virtual void ReadBundleEnd(MemoryBuffer &Input) = 0;
+  /// \brief Read the current bundle and write the result into the stream \a OS.
+  virtual void ReadBundle(raw_fd_ostream &OS, MemoryBuffer &Input) = 0;
+
+  /// \brief Write the header of the bundled file to \a OS based on the
+  //

Re: [PATCH] D14410: Cleanup: move all visibility attributes to the first declaration.

2015-11-06 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

Yes. I'm just using libc++.so as a (incomplete) test that this is actually NFC. 
It did catch the extern template issue.


Repository:
  rL LLVM

http://reviews.llvm.org/D14410



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


Re: [PATCH] D14410: Cleanup: move all visibility attributes to the first declaration.

2015-11-06 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

It's not just libc++.so that could have it's ABI affected by adding/removing 
these. It's any shared library build against libc++. However if we are just 
moving the attribute to the proper place that should truly NFC modolo 
https://llvm.org/bugs/show_bug.cgi?id=25427.

LGTM and feel free to commit any similar cleanup without review. I'll have to 
think a little harder about the extern template issues before working through 
those.


Repository:
  rL LLVM

http://reviews.llvm.org/D14410



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


[libcxx] r252350 - Allow deque to handle incomplete types.

2015-11-06 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Fri Nov  6 16:02:29 2015
New Revision: 252350

URL: http://llvm.org/viewvc/llvm-project?rev=252350&view=rev
Log:
Allow deque to handle incomplete types.

Allow deque and deque::iterator instantiation with incomplete element
type. This is an ABI breaking change, and it is only enabled if
LIBCXX_ABI_VERSION >= 2 or LIBCXX_ABI_UNSTABLE=ON.

Added:
libcxx/trunk/test/libcxx/containers/sequences/deque/
libcxx/trunk/test/libcxx/containers/sequences/deque/incomplete.pass.cpp
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/deque

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=252350&r1=252349&r2=252350&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri Nov  6 16:02:29 2015
@@ -34,7 +34,11 @@
 #endif
 
 #if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
+// Change short string represention so that string data starts at offset 0,
+// improving its alignment in some cases.
 #define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+// Fix deque iterator type in order to support incomplete types.
+#define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
 #endif
 
 #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y

Modified: libcxx/trunk/include/deque
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/deque?rev=252350&r1=252349&r2=252350&view=diff
==
--- libcxx/trunk/include/deque (original)
+++ libcxx/trunk/include/deque Fri Nov  6 16:02:29 2015
@@ -261,8 +261,21 @@ move_backward(__deque_iterator<_V1, _P1,
   __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
   __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r);
 
+template 
+struct __deque_block_size {
+  static const _DiffType value = sizeof(_ValueType) < 256 ? 4096 / 
sizeof(_ValueType) : 16;
+};
+
 template 
+  class _DiffType, _DiffType _BS =
+#ifdef _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
+// Keep template parameter to avoid changing all template declarations 
thoughout
+// this file.
+   0
+#else
+   __deque_block_size<_ValueType, _DiffType>::value
+#endif
+  >
 class _LIBCPP_TYPE_VIS_ONLY __deque_iterator
 {
 typedef _MapPointer __map_iterator;
@@ -273,7 +286,7 @@ private:
 __map_iterator __m_iter_;
 pointer__ptr_;
 
-static const difference_type __block_size = _BlockSize;
+static const difference_type __block_size;
 public:
 typedef _ValueType  value_type;
 typedef random_access_iterator_tag  iterator_category;
@@ -287,7 +300,7 @@ public:
 
 template 
 _LIBCPP_INLINE_VISIBILITY
-__deque_iterator(const __deque_iterator& __it,
+__deque_iterator(const __deque_iterator& __it,
 typename enable_if::value>::type* 
= 0) _NOEXCEPT
 : __m_iter_(__it.__m_iter_), __ptr_(__it.__ptr_) {}
 
@@ -520,6 +533,12 @@ private:
   __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r);
 };
 
+template 
+const _DiffType __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer,
+ _DiffType, _BlockSize>::__block_size =
+__deque_block_size<_ValueType, _DiffType>::value;
+
 // copy
 
 template ::difference_type difference_type;
 typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer 
pointer;
+const difference_type __block_size = __deque_iterator<_V2, _P2, _R2, _M2, 
_D2, _B2>::__block_size;
 while (__f != __l)
 {
 pointer __rb = __r.__ptr_;
-pointer __re = *__r.__m_iter_ + _B2;
+pointer __re = *__r.__m_iter_ + __block_size;
 difference_type __bs = __re - __rb;
 difference_type __n = __l - __f;
 _RAIter __m = __l;
@@ -560,11 +580,12 @@ copy(__deque_iterator<_V1, _P1, _R1, _M1
 {
 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, 
_B1>::difference_type difference_type;
 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer 
pointer;
+const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, 
_D1, _B1>::__block_size;
 difference_type __n = __l - __f;
 while (__n > 0)
 {
 pointer __fb = __f.__ptr_;
-pointer __fe = *__f.__m_iter_ + _B1;
+pointer __fe = *__f.__m_iter_ + __block_size;
 difference_type __bs = __fe - __fb;
 if (__bs > __n)
 {
@@ -587,11 +608,12 @@ copy(__deque_iterator<_V1, _P1, _R1, _M1
 {
 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, 
_B1>::difference_type difference_type;
 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer 
pointer;
+const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, 
_D1, _B1>::__block_size;
 difference_type __n = __l - __f;
 

Re: [PATCH] D10677: Allow deque to handle incomplete types

2015-11-06 Thread Evgeniy Stepanov via cfe-commits
eugenis closed this revision.
eugenis added a comment.

Thanks!
Landed as r252350.


Repository:
  rL LLVM

http://reviews.llvm.org/D10677



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


Re: [PATCH] D12614: [OpenMP] Offloading descriptor registration and device codegen.

2015-11-06 Thread Samuel Antao via cfe-commits
sfantao added a comment.

In http://reviews.llvm.org/D12614#278101, @rjmccall wrote:

> In http://reviews.llvm.org/D12614#274349, @sfantao wrote:
>
> > Hi John,
> >
> > Thanks for the remark!
> >
> > In http://reviews.llvm.org/D12614#272354, @rjmccall wrote:
> >
> > > CurFuncDecl is supposed to be the enclosing user function.  Things like 
> > > outlined functions should be getting stored in CurCodeDecl; that's how 
> > > it's done for blocks and lambdas.
> >
> >
> > Apologies I was not accurate in my previous post. `CurFuncDecl` is in fact 
> > the declaration of the enclosing user function. What is not defined in some 
> > times undefined is `CurGD` and this is what I was trying to use to get the 
> > right mangled name of the user function, given that it also encodes the 
> > structor type. So my question is: is there a good/safe way to get the 
> > mangled  name of the user function given the function declaration? I didn't 
> > find any good way to do that without replicating part of the stuff that 
> > happens in the mangler.
>
>
> You don't actually want the structor type of the parent, because the nested 
> declaration is logically the same declaration across all of them.  For 
> example, a lambda used in a constructor is still just a single type; there 
> aren't implicitly 1-3 different types just because there are 1-3 different 
> variant entrypoints for the constructor.
>
> The way this generally works is that you just pick a single canonical 
> variant.  For example, the Itanium ABI says that you mangle local entities 
> within constructors as if they were defined within the complete-object 
> variant.  If you want to add a method to one of the CXXABI objects to pick a 
> canonical GD for a declaration, feel free.


Thanks for explaining that!

I am now relying exclusively on `CurFuncDecl` in the last diff.

As for the structor variants, I am now using the complete variant to generate 
the names of the kernels as you suggested. I didn't add any method to CXXABI as 
that will require extra logic in ASTContext to make that visible during the 
code generation. Instead, I hardcoded `Ctor[Dtor]_Complete` in the code 
generation, similarly to what is done in the name mangler. Let me know if you'd 
rather have the method in CXXABI.

Let me know other comments suggestions you may have.

Thanks again!
Samuel


http://reviews.llvm.org/D12614



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


Re: [PATCH] D14410: Cleanup: move all visibility attributes to the first declaration.

2015-11-06 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

This is a mechanical change, and AFAIR I checked that no bits of libc++.so are 
affected.

The same mechanical change in streambuf/istream/ostream (the stuff that's parts 
of extern templates) breaks libc++ because of 
https://llvm.org/bugs/show_bug.cgi?id=25427, that's why it's not included here.

I'll verify that this is not a functional change one more time.


Repository:
  rL LLVM

http://reviews.llvm.org/D14410



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


Re: [PATCH] D14410: Cleanup: move all visibility attributes to the first declaration.

2015-11-06 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Is this a mechanical change, or do you remove/add some attributes in this patch?


Repository:
  rL LLVM

http://reviews.llvm.org/D14410



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


Re: [PATCH] D12614: [OpenMP] Offloading descriptor registration and device codegen.

2015-11-06 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 39588.
sfantao added a comment.

Use `CurFuncDecl` to generate offload kernel names as suggested by John McCall.


http://reviews.llvm.org/D12614

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/Basic/LangOptions.h
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/OpenMP/target_codegen.cpp
  test/OpenMP/target_codegen_global_capture.cpp
  test/OpenMP/target_codegen_registration.cpp
  test/OpenMP/target_codegen_registration_naming.cpp
  test/OpenMP/target_messages.cpp

Index: test/OpenMP/target_messages.cpp
===
--- test/OpenMP/target_messages.cpp
+++ test/OpenMP/target_messages.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 -o - %s
+// RUN: not %clang_cc1 -fopenmp -std=c++11 -omptargets=aaa-bbb-ccc-ddd -o - %s 2>&1 | FileCheck %s
+// CHECK: error: OpenMP target is invalid: 'aaa-bbb-ccc-ddd'
 
 void foo() {
 }
Index: test/OpenMP/target_codegen_registration_naming.cpp
===
--- /dev/null
+++ test/OpenMP/target_codegen_registration_naming.cpp
@@ -0,0 +1,66 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s -check-prefix=TCHECK
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s -check-prefix=TCHECK
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s -check-prefix=TCHECK
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s -check-prefix=TCHECK
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK: [[CA:%.+]] = type { i32* }
+
+// CHECK: define {{.*}}i32 @[[NNAME:.+]](i32 {{.*}}%{{.+}})
+int nested(int a){
+  // CHECK: call void @.omp_offloading.[[FILEID:[0-9a-f]+\.[0-9a-f]+]].[[NNAME]].l[[T1L:[0-9]+]].c[[T1C:[0-9]+]](
+  #pragma omp target
+++a;
+
+  // CHECK: call void @"[[LNAME:.+]]"([[CA]]*
+  auto F = [&](){
+#pragma omp parallel
+{
+  #pragma omp target
+  ++a;
+}
+  };
+
+  F();
+
+  return a;
+}
+
+// CHECK: define {{.*}}void @.omp_offloading.[[FILEID]].[[NNAME]].l[[T1L]].c[[T1C]](
+// TCHECK: define {{.*}}void @.omp_offloading.[[FILEID:[0-9a-f]+\.[0-9a-f]+]].[[NNAME:.+]].l[[T1L:[0-9]+]].c[[T1C:[0-9]+]](
+
+// CHECK: define {{.*}}void @"[[LNAME]]"(
+// CHECK: call void {{.*}}@__kmpc_fork_call{{.+}}[[PNAME:@.+]] to
+
+// C

Re: [PATCH] D12382: Extend linux header search to find libc++ headers in c++/vN for any N.

2015-11-06 Thread Evgeniy Stepanov via cfe-commits
eugenis set the repository for this revision to rL LLVM.
eugenis updated this revision to Diff 39587.

Repository:
  rL LLVM

http://reviews.llvm.org/D12382

Files:
  lib/Driver/ToolChains.cpp
  test/Driver/Inputs/basic_linux_libcxxv2_tree/usr/bin/.keep
  test/Driver/Inputs/basic_linux_libcxxv2_tree/usr/include/c++/v1/.keep
  test/Driver/Inputs/basic_linux_libcxxv2_tree/usr/include/c++/v2/.keep
  test/Driver/Inputs/basic_linux_libcxxv2_tree/usr/lib/.keep
  test/Driver/Inputs/basic_linux_libstdcxx_libcxxv2_tree/usr/bin/.keep
  
test/Driver/Inputs/basic_linux_libstdcxx_libcxxv2_tree/usr/include/c++/4.8/backward/.keep
  
test/Driver/Inputs/basic_linux_libstdcxx_libcxxv2_tree/usr/include/c++/v1/.keep
  
test/Driver/Inputs/basic_linux_libstdcxx_libcxxv2_tree/usr/include/c++/v2/.keep
  test/Driver/Inputs/basic_linux_libstdcxx_libcxxv2_tree/usr/lib/.keep
  test/Driver/linux-header-search.cpp

Index: test/Driver/linux-header-search.cpp
===
--- test/Driver/linux-header-search.cpp
+++ test/Driver/linux-header-search.cpp
@@ -26,6 +26,42 @@
 // CHECK-BASIC-LIBCXX-INSTALL: "-internal-isystem" 
"[[SYSROOT]]/usr/bin/../include/c++/v1"
 // CHECK-BASIC-LIBCXX-INSTALL: "-internal-isystem" 
"[[SYSROOT]]/usr/local/include"
 //
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu \
+// RUN: -stdlib=libc++ \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin \
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxxv2_tree \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-BASIC-LIBCXXV2-SYSROOT %s
+// CHECK-BASIC-LIBCXXV2-SYSROOT: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-BASIC-LIBCXXV2-SYSROOT: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-BASIC-LIBCXXV2-SYSROOT: "-internal-isystem" 
"[[SYSROOT]]/usr/include/c++/v2"
+// CHECK-BASIC-LIBCXXV2-SYSROOT: "-internal-isystem" 
"[[SYSROOT]]/usr/local/include"
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu \
+// RUN: -stdlib=libc++ \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_libcxxv2_tree/usr/bin \
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxxv2_tree \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-BASIC-LIBCXXV2-INSTALL %s
+// CHECK-BASIC-LIBCXXV2-INSTALL: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-BASIC-LIBCXXV2-INSTALL: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-BASIC-LIBCXXV2-INSTALL: "-internal-isystem" 
"[[SYSROOT]]/usr/bin/../include/c++/v2"
+// CHECK-BASIC-LIBCXXV2-INSTALL: "-internal-isystem" 
"[[SYSROOT]]/usr/local/include"
+//
+// Test Linux with both libc++ and libstdc++ installed.
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu \
+// RUN: -stdlib=libc++ \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin \
+// RUN: --sysroot=%S/Inputs/basic_linux_libstdcxx_libcxxv2_tree \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-BASIC-LIBSTDCXX-LIBCXXV2-SYSROOT %s
+// CHECK-BASIC-LIBSTDCXX-LIBCXXV2-SYSROOT: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-BASIC-LIBSTDCXX-LIBCXXV2-SYSROOT: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-BASIC-LIBSTDCXX-LIBCXXV2-SYSROOT: "-internal-isystem" 
"[[SYSROOT]]/usr/include/c++/v2"
+// CHECK-BASIC-LIBSTDCXX-LIBCXXV2-SYSROOT: "-internal-isystem" 
"[[SYSROOT]]/usr/local/include"
+//
 // Test a very broken version of multiarch that shipped in Ubuntu 11.04.
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN: -target i386-unknown-linux \
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3846,6 +3846,25 @@
 }
 
 
+static std::string DetectLibcxxIncludePath(StringRef base) {
+  std::error_code EC;
+  int MaxVersion = 0;
+  std::string MaxVersionString = "";
+  for (llvm::sys::fs::directory_iterator LI(base, EC), LE; !EC && LI != LE;
+   LI = LI.increment(EC)) {
+StringRef VersionText = llvm::sys::path::filename(LI->path());
+int Version;
+if (VersionText[0] == 'v' &&
+!VersionText.slice(1, StringRef::npos).getAsInteger(10, Version)) {
+  if (Version > MaxVersion) {
+MaxVersion = Version;
+MaxVersionString = VersionText;
+  }
+}
+  }
+  return MaxVersion ? (base + "/" + MaxVersionString).str() : "";
+}
+
 void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
  ArgStringList &CC1Args) const {
   if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
@@ -3855,17 +3874,14 @@
   // Check if libc++ has been enabled and provide its include paths if so.
   if (GetCXXStdlibType(DriverArgs) == ToolChain::CST_Libcxx) {
 const std::string LibCXXIncludePathCandidates[] = {
-// The primary location is within the Clang installati

Re: [PATCH] D12382: Extend linux header search to find libc++ headers in c++/vN for any N.

2015-11-06 Thread Evgeniy Stepanov via cfe-commits
eugenis marked an inline comment as done.
eugenis added a comment.

Repository:
  rL LLVM

http://reviews.llvm.org/D12382



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


Re: [PATCH] D10677: Allow deque to handle incomplete types

2015-11-06 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

I think I've cleared up my own confusion. LGTM.


Repository:
  rL LLVM

http://reviews.llvm.org/D10677



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


Re: [PATCH] D13673: Add initial support for the MUSL C library.

2015-11-06 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM.


http://reviews.llvm.org/D13673



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


Re: [PATCH] D14130: Delete dead code in the LibcxxAndAbiBuilder

2015-11-06 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


http://reviews.llvm.org/D14130



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


Re: [PATCH] D9600: Add scan-build python implementation

2015-11-06 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a comment.

I'm wondering about the status of this, since I've not heard much in the past 
few months. Is this patch still progressing? (I hope so, I would really love to 
see us drop our reliance on Perl!)


http://reviews.llvm.org/D9600



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


Re: [PATCH] D14403: Create install targets for scan-build and scan-view

2015-11-06 Thread Ben Craig via cfe-commits
bcraig added a subscriber: bcraig.
bcraig added a comment.

For what it's worth, our internal branch installs these by default, and I was 
unpleasantly surprised when I found that upstream didn't.


http://reviews.llvm.org/D14403



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


Re: [PATCH] D14184: [clang] Add initial support for -meabi flag

2015-11-06 Thread Vinicius Tinti via cfe-commits
tinti removed rL LLVM as the repository for this revision.
tinti updated this revision to Diff 39579.

http://reviews.llvm.org/D14184

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/arm-eabi.c
  test/Driver/eabi.c

Index: test/Driver/eabi.c
===
--- /dev/null
+++ test/Driver/eabi.c
@@ -0,0 +1,10 @@
+// RUN: %clang %s -meabi 4 -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-EABI4 %s
+// RUN: %clang %s -meabi 5 -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-EABI5 %s
+// RUN: %clang %s -meabi gnu -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-GNUEABI %s
+
+// CHECK-EABI4: "-meabi" "4"
+// CHECK-EABI5: "-meabi" "5"
+// CHECK-GNUEABI: "-meabi" "gnu"
Index: test/CodeGen/arm-eabi.c
===
--- /dev/null
+++ test/CodeGen/arm-eabi.c
@@ -0,0 +1,20 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang -target arm-none-eabi -S -o - %s | FileCheck -check-prefix=CHECK-EABI %s
+// RUN: %clang -target arm-none-eabi -S -meabi gnu -o - %s | FileCheck -check-prefix=CHECK-GNUEABI %s
+// RUN: %clang -target arm-none-eabihf -S -o - %s | FileCheck -check-prefix=CHECK-EABI %s
+// RUN: %clang -target arm-none-eabihf -S -meabi gnu -o - %s | FileCheck -check-prefix=CHECK-GNUEABI %s
+// RUN: %clang -target arm-none-gnueabi -S -o - %s | FileCheck -check-prefix=CHECK-GNUEABI %s
+// RUN: %clang -target arm-none-gnueabi -S -meabi 5 -o - %s | FileCheck -check-prefix=CHECK-EABI %s
+// RUN: %clang -target arm-none-gnueabihf -S -o - %s | FileCheck -check-prefix=CHECK-GNUEABI %s
+// RUN: %clang -target arm-none-gnueabihf -S -meabi 5 -o - %s | FileCheck -check-prefix=CHECK-EABI %s
+
+struct my_s {
+  unsigned long a[18];
+};
+
+// CHECK-LABEL: foo
+// CHECK-EABI: bl __aeabi_memcpy4
+// CHECK-GNUEABI: bl memcpy
+void foo(unsigned long *t) {
+  *(struct my_s *)t = *((struct my_s *)(1UL));
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -36,6 +36,7 @@
 #include "llvm/Support/Host.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
+#include "llvm/Target/TargetOptions.h"
 #include 
 #include 
 #include 
@@ -454,6 +455,20 @@
   Opts.DisableFree = Args.hasArg(OPT_disable_free);
   Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
   Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
+  if (Arg *A = Args.getLastArg(OPT_meabi)) {
+StringRef Value = A->getValue();
+llvm::EABI EABIVersion = llvm::StringSwitch(Value)
+ .Case("default", llvm::EABI::Default)
+ .Case("4", llvm::EABI::EABI4)
+ .Case("5", llvm::EABI::EABI5)
+ .Case("gnu", llvm::EABI::GNU)
+ .Default(llvm::EABI::Unknown);
+if (EABIVersion == llvm::EABI::Unknown)
+  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
+<< Value;
+else
+  Opts.EABIVersion = Value;
+  }
   Opts.LessPreciseFPMAD = Args.hasArg(OPT_cl_mad_enable);
   Opts.LimitFloatPrecision = Args.getLastArgValue(OPT_mlimit_float_precision);
   Opts.NoInfsFPMath = (Args.hasArg(OPT_menable_no_infinities) ||
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3412,6 +3412,11 @@
 }
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_meabi)) {
+CmdArgs.push_back("-meabi");
+CmdArgs.push_back(A->getValue());
+  }
+
   CmdArgs.push_back("-mthread-model");
   if (Arg *A = Args.getLastArg(options::OPT_mthread_model))
 CmdArgs.push_back(A->getValue());
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -515,6 +515,14 @@
   Options.UseInitArray = CodeGenOpts.UseInitArray;
   Options.DisableIntegratedAS = CodeGenOpts.DisableIntegratedAS;
   Options.CompressDebugSections = CodeGenOpts.CompressDebugSections;
+
+  // Set EABI version.
+  Options.EABIVersion = llvm::StringSwitch(CodeGenOpts.EABIVersion)
+.Case("4", llvm::EABI::EABI4)
+.Case("5", llvm::EABI::EABI5)
+.Case("gnu", llvm::EABI::GNU)
+.Default(llvm::EABI::Default);
+
   Options.LessPreciseFPMADOption = CodeGenOpts.LessPreciseFPMAD;
   Options.NoInfsFPMath = CodeGenOpts.NoInfsFPMath;
   Options.NoNaNsFPMath = CodeGenOpts.NoNaNsFPMath;
Index: include/clang/Frontend/CodeGenOptions.h
==

Re: [PATCH] D14403: Create install targets for scan-build and scan-view

2015-11-06 Thread Chris Bieneman via cfe-commits
beanz added a comment.

I would prefer if installing these were optional and could be toggled on/off.

Other than that this all looks fine to me.


http://reviews.llvm.org/D14403



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


Re: [Diffusion] rL250657: Support linking against OpenMP runtime on FreeBSD.

2015-11-06 Thread Tom Stellard via cfe-commits
tstellarAMD added a project: 3.7-release.

Users:
  dim (Author)
  3.7-release (Auditor)
  cfe-commits (Auditor)
  tstellarAMD (Auditor)
  joerg (Auditor)
  rsmith (Auditor)

http://reviews.llvm.org/rL250657



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


Re: [PATCH] D14096: [clang-tidy] add new check cppcoreguidelines-pro-type-cstyle-cast

2015-11-06 Thread Matthias Gehre via cfe-commits
mgehre updated this revision to Diff 39576.
mgehre added a comment.

Update for review comments: add braces around else


http://reviews.llvm.org/D14096

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp
  clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.h
  docs/clang-tidy/checks/cppcoreguidelines-pro-type-cstyle-cast.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-pro-type-cstyle-cast.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-type-cstyle-cast.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-pro-type-cstyle-cast.cpp
@@ -0,0 +1,141 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-cstyle-cast %t
+
+void reinterpretcast() {
+  int i = 0;
+  void *j;
+  j = (int*)j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast]
+}
+
+void constcast() {
+  int* i;
+  const int* j;
+  i = (int*)j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not use C-style cast to cast away constness [cppcoreguidelines-pro-type-cstyle-cast]
+  j = (const int*)i; // OK, const added
+  (void)j; // OK, not a const_cast
+}
+
+void const_and_reinterpret() {
+  int* i;
+  const void* j;
+  i = (int*)j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast]
+}
+
+class Base {
+};
+
+class Derived : public Base {
+};
+
+class Base2 {
+};
+
+class MultiDerived : public Base, public Base2 {
+};
+
+class PolymorphicBase {
+public:
+  virtual ~PolymorphicBase();
+};
+
+class PolymorphicDerived : public PolymorphicBase {
+};
+
+class PolymorphicMultiDerived : public Base, public PolymorphicBase {
+};
+
+void pointers() {
+
+  auto P0 = (Derived*)new Base();
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use C-style cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-cstyle-cast]
+
+  const Base* B0;
+  auto PC0 = (const Derived*)(B0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not use C-style cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-cstyle-cast]
+
+  auto P1 = (Base*)new Derived(); // OK, upcast to a public base
+  auto P2 = (Base*)new MultiDerived(); // OK, upcast to a public base
+  auto P3 = (Base2*)new MultiDerived(); // OK, upcast to a public base
+}
+
+void pointers_polymorphic() {
+
+  auto PP0 = (PolymorphicDerived*)new PolymorphicBase();
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not use C-style cast to downcast from a base to a derived class; use dynamic_cast instead [cppcoreguidelines-pro-type-cstyle-cast]
+  // CHECK-FIXES: auto PP0 = dynamic_cast(new PolymorphicBase());
+
+  const PolymorphicBase* B0;
+  auto PPC0 = (const PolymorphicDerived*)B0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: do not use C-style cast to downcast from a base to a derived class; use dynamic_cast instead [cppcoreguidelines-pro-type-cstyle-cast]
+  // CHECK-FIXES: auto PPC0 = dynamic_cast(B0);
+
+
+  auto B1 = (PolymorphicBase*)new PolymorphicDerived(); // OK, upcast to a public base
+  auto B2 = (PolymorphicBase*)new PolymorphicMultiDerived(); // OK, upcast to a public base
+  auto B3 = (Base*)new PolymorphicMultiDerived(); // OK, upcast to a public base
+}
+
+void arrays() {
+  Base ArrayOfBase[10];
+  auto A0 = (Derived*)ArrayOfBase;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use C-style cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-cstyle-cast]
+}
+
+void arrays_polymorphic() {
+  PolymorphicBase ArrayOfPolymorphicBase[10];
+  auto AP0 = (PolymorphicDerived*)ArrayOfPolymorphicBase;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not use C-style cast to downcast from a base to a derived class; use dynamic_cast instead
+  // CHECK-FIXES: auto AP0 = dynamic_cast(ArrayOfPolymorphicBase);
+}
+
+void references() {
+  Base B0;
+  auto R0 = (Derived&)B0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use C-style cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-cstyle-cast]
+  Base& RefToBase = B0;
+  auto R1 = (Derived&)RefToBase;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use C-style cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-cstyle-cast]
+
+  const Base& ConstRefToBase = B0;
+  auto RC1 = (const Derived&)ConstRefToBase;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not use C-style cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-cstyle-cast]
+
+
+  Derived RD1;
+  auto R2 = (Base&)RD1; // OK, upcast to a public base
+}
+
+void references_polymorphic() {
+  PolymorphicBase B0;
+  auto RP0 = (PolymorphicDerived&)B0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not use C-style cast to downc

Re: [PATCH] D14354: Add new compiler flag to enable the generation of dwarf accelerator tables

2015-11-06 Thread Paul Robinson via cfe-commits
probinson added a comment.

I have an internal release freeze coming up in a couple of weeks, but I should 
be able to spend time on exposing the "tuning" in clang after that.  I don't 
mind this patch going in if you're not able to wait.


http://reviews.llvm.org/D14354



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


Re: [PATCH] D14354: Add new compiler flag to enable the generation of dwarf accelerator tables

2015-11-06 Thread Tamas Berghammer via cfe-commits
tberghammer added a comment.

If you plan to do the "tuning" in clang in the near future then we can abandon 
this change in favor of that one



Comment at: lib/Driver/Tools.cpp:3880
@@ +3879,3 @@
+  // -gdwarf-accel-tables should turn on -g and enable the genereation of the
+  // dwarf acceleration tables in the backend.
+  if (Args.hasArg(options::OPT_gdwarf_accel_tables)) {

probinson wrote:
> This is not how other similar options work (-ggnu-pubnames, -gdwarf-aranges). 
>  Do you have a particular reason why this one should imply -g?
No, I am perfectly happy if it don't imply '-g'


http://reviews.llvm.org/D14354



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


Re: [PATCH] D14354: Add new compiler flag to enable the generation of dwarf accelerator tables

2015-11-06 Thread Paul Robinson via cfe-commits
probinson added a comment.

In http://reviews.llvm.org/D14354#282988, @tberghammer wrote:

> In http://reviews.llvm.org/D14354#282870, @probinson wrote:
>
> > So, currently you get accel tables by default for platforms that "tune" for 
> > LLDB, currently Darwin and FreeBSD.
> >  Are you wanting to use LLDB on another platform, or did you want accel 
> > tables for a different debugger?
> >
> > (Eventually I will have a chance to expose the "tuning" up through Clang, 
> > and if you're running LLDB on another platform, that will be the easier way 
> > to get what you want.)
>
>
> We are using LLDB for Android (as part of Android Studio) and some of us also 
> use if for Linux (I hope we can get higher adaptation soon).


Okay.  I'll try to get the tuning-in-Clang task moved higher up my list, 
because if you had that you wouldn't need this patch.



Comment at: lib/Driver/Tools.cpp:3880
@@ +3879,3 @@
+  // -gdwarf-accel-tables should turn on -g and enable the genereation of the
+  // dwarf acceleration tables in the backend.
+  if (Args.hasArg(options::OPT_gdwarf_accel_tables)) {

This is not how other similar options work (-ggnu-pubnames, -gdwarf-aranges).  
Do you have a particular reason why this one should imply -g?


http://reviews.llvm.org/D14354



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


Re: [PATCH] D14192: Add ExtraArgs and ExtraArgsBefore options to enable clang warnings via configuration files.

2015-11-06 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

PTAL



Comment at: clang-tidy/ClangTidy.cpp:382
@@ +381,3 @@
+  const CommandLineArguments &Args, StringRef Filename) {
+ClangTidyOptions Opts = Context.getOptionsForFile(Filename);
+CommandLineArguments AdjustedArgs;

The interface should be clearer, if you think about the possibility of having 
different options for different files. Also, the documentation on the 
corresponding methods should help. But adding `getOptionsForFile` doesn't hurt.


http://reviews.llvm.org/D14192



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


Re: [PATCH] D14192: Add ExtraArgs and ExtraArgsBefore options to enable clang warnings via configuration files.

2015-11-06 Thread Alexander Kornienko via cfe-commits
alexfh updated this revision to Diff 39553.
alexfh added a comment.

Updated documentation comments.


http://reviews.llvm.org/D14192

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  test/clang-tidy/custom-diagnostics.cpp

Index: test/clang-tidy/custom-diagnostics.cpp
===
--- /dev/null
+++ test/clang-tidy/custom-diagnostics.cpp
@@ -0,0 +1,12 @@
+// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-shadow,clang-diagnostic-float-conversion' %s -- | count 0
+// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-shadow,clang-diagnostic-float-conversion' \
+// RUN:   -config='{ExtraArgs: ["-Wshadow","-Wno-unused-variable"], ExtraArgsBefore: ["-Wno-shadow","-Wfloat-conversion","-Wunused-variable"]}' %s -- \
+// RUN:   | FileCheck -implicit-check-not='{{warning:|error:}}' %s
+
+void f(float x) {
+  int a;
+  { int a; }
+  // CHECK: :[[@LINE-1]]:9: warning: declaration shadows a local variable [clang-diagnostic-shadow]
+  int b = x;
+  // CHECK: :[[@LINE-1]]:11: warning: implicit conversion turns floating-point number into integer: 'float' to 'int' [clang-diagnostic-float-conversion]
+}
Index: clang-tidy/ClangTidyOptions.h
===
--- clang-tidy/ClangTidyOptions.h
+++ clang-tidy/ClangTidyOptions.h
@@ -83,6 +83,14 @@
 
   /// \brief Key-value mapping used to store check-specific options.
   OptionMap CheckOptions;
+
+  typedef std::vector ArgList;
+
+  /// \brief Add extra compilation arguments to the end of the list.
+  llvm::Optional ExtraArgs;
+
+  /// \brief Add extra compilation arguments to the start of the list.
+  llvm::Optional ExtraArgsBefore;
 };
 
 /// \brief Abstract interface for retrieving various ClangTidy options.
Index: clang-tidy/ClangTidyOptions.cpp
===
--- clang-tidy/ClangTidyOptions.cpp
+++ clang-tidy/ClangTidyOptions.cpp
@@ -27,6 +27,7 @@
 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(FileFilter)
 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(FileFilter::LineRange)
 LLVM_YAML_IS_SEQUENCE_VECTOR(ClangTidyOptions::StringPair)
+LLVM_YAML_IS_SEQUENCE_VECTOR(std::string)
 
 namespace llvm {
 namespace yaml {
@@ -88,6 +89,8 @@
 IO.mapOptional("AnalyzeTemporaryDtors", Options.AnalyzeTemporaryDtors);
 IO.mapOptional("User", Options.User);
 IO.mapOptional("CheckOptions", NOpts->Options);
+IO.mapOptional("ExtraArgs", Options.ExtraArgs);
+IO.mapOptional("ExtraArgsBefore", Options.ExtraArgsBefore);
   }
 };
 
@@ -129,6 +132,10 @@
 Result.AnalyzeTemporaryDtors = Other.AnalyzeTemporaryDtors;
   if (Other.User)
 Result.User = Other.User;
+  if (Other.ExtraArgs)
+Result.ExtraArgs = Other.ExtraArgs;
+  if (Other.ExtraArgsBefore)
+Result.ExtraArgsBefore = Other.ExtraArgsBefore;
 
   for (const auto &KeyValue : Other.CheckOptions)
 Result.CheckOptions[KeyValue.first] = KeyValue.second;
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -149,22 +149,30 @@
   /// \brief Sets ASTContext for the current translation unit.
   void setASTContext(ASTContext *Context);
 
-  /// \brief Gets the language options from the AST context
+  /// \brief Gets the language options from the AST context.
   LangOptions getLangOpts() const { return LangOpts; }
 
   /// \brief Returns the name of the clang-tidy check which produced this
   /// diagnostic ID.
   StringRef getCheckName(unsigned DiagnosticID) const;
 
   /// \brief Returns check filter for the \c CurrentFile.
+  ///
+  /// The \c CurrentFile can be changed using \c setCurrentFile.
   GlobList &getChecksFilter();
 
   /// \brief Returns global options.
   const ClangTidyGlobalOptions &getGlobalOptions() const;
 
   /// \brief Returns options for \c CurrentFile.
+  ///
+  /// The \c CurrentFile can be changed using \c setCurrentFile.
   const ClangTidyOptions &getOptions() const;
 
+  /// \brief Returns options for \c File. Does not change or depend on
+  /// \c CurrentFile.
+  ClangTidyOptions getOptionsForFile(StringRef File) const;
+
   /// \brief Returns \c ClangTidyStats containing issued and ignored diagnostic
   /// counters.
   const ClangTidyStats &getStats() const { return Stats; }
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -202,9 +202,7 @@
 
 void ClangTidyContext::setCurrentFile(StringRef File) {
   CurrentFile = File;
-  // Safeguard against options with unset values.
-  CurrentOptions = ClangTidyOptions::getDefaults().mergeWith(
-  OptionsProvider->getOption

Re: [PATCH] D14192: Add ExtraArgs and ExtraArgsBefore options to enable clang warnings via configuration files.

2015-11-06 Thread Alexander Kornienko via cfe-commits
alexfh updated this revision to Diff 39551.
alexfh added a comment.

Added ClangTidyContext::getOptionsForFile.


http://reviews.llvm.org/D14192

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  test/clang-tidy/custom-diagnostics.cpp

Index: test/clang-tidy/custom-diagnostics.cpp
===
--- /dev/null
+++ test/clang-tidy/custom-diagnostics.cpp
@@ -0,0 +1,12 @@
+// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-shadow,clang-diagnostic-float-conversion' %s -- | count 0
+// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-shadow,clang-diagnostic-float-conversion' \
+// RUN:   -config='{ExtraArgs: ["-Wshadow","-Wno-unused-variable"], ExtraArgsBefore: ["-Wno-shadow","-Wfloat-conversion","-Wunused-variable"]}' %s -- \
+// RUN:   | FileCheck -implicit-check-not='{{warning:|error:}}' %s
+
+void f(float x) {
+  int a;
+  { int a; }
+  // CHECK: :[[@LINE-1]]:9: warning: declaration shadows a local variable [clang-diagnostic-shadow]
+  int b = x;
+  // CHECK: :[[@LINE-1]]:11: warning: implicit conversion turns floating-point number into integer: 'float' to 'int' [clang-diagnostic-float-conversion]
+}
Index: clang-tidy/ClangTidyOptions.h
===
--- clang-tidy/ClangTidyOptions.h
+++ clang-tidy/ClangTidyOptions.h
@@ -83,6 +83,14 @@
 
   /// \brief Key-value mapping used to store check-specific options.
   OptionMap CheckOptions;
+
+  typedef std::vector ArgList;
+
+  /// \brief Add extra compilation arguments to the end of the list.
+  llvm::Optional ExtraArgs;
+
+  /// \brief Add extra compilation arguments to the start of the list.
+  llvm::Optional ExtraArgsBefore;
 };
 
 /// \brief Abstract interface for retrieving various ClangTidy options.
Index: clang-tidy/ClangTidyOptions.cpp
===
--- clang-tidy/ClangTidyOptions.cpp
+++ clang-tidy/ClangTidyOptions.cpp
@@ -27,6 +27,7 @@
 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(FileFilter)
 LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(FileFilter::LineRange)
 LLVM_YAML_IS_SEQUENCE_VECTOR(ClangTidyOptions::StringPair)
+LLVM_YAML_IS_SEQUENCE_VECTOR(std::string)
 
 namespace llvm {
 namespace yaml {
@@ -88,6 +89,8 @@
 IO.mapOptional("AnalyzeTemporaryDtors", Options.AnalyzeTemporaryDtors);
 IO.mapOptional("User", Options.User);
 IO.mapOptional("CheckOptions", NOpts->Options);
+IO.mapOptional("ExtraArgs", Options.ExtraArgs);
+IO.mapOptional("ExtraArgsBefore", Options.ExtraArgsBefore);
   }
 };
 
@@ -129,6 +132,10 @@
 Result.AnalyzeTemporaryDtors = Other.AnalyzeTemporaryDtors;
   if (Other.User)
 Result.User = Other.User;
+  if (Other.ExtraArgs)
+Result.ExtraArgs = Other.ExtraArgs;
+  if (Other.ExtraArgsBefore)
+Result.ExtraArgsBefore = Other.ExtraArgsBefore;
 
   for (const auto &KeyValue : Other.CheckOptions)
 Result.CheckOptions[KeyValue.first] = KeyValue.second;
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -165,6 +165,8 @@
   /// \brief Returns options for \c CurrentFile.
   const ClangTidyOptions &getOptions() const;
 
+  ClangTidyOptions getOptionsForFile(StringRef File) const;
+
   /// \brief Returns \c ClangTidyStats containing issued and ignored diagnostic
   /// counters.
   const ClangTidyStats &getStats() const { return Stats; }
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -202,9 +202,7 @@
 
 void ClangTidyContext::setCurrentFile(StringRef File) {
   CurrentFile = File;
-  // Safeguard against options with unset values.
-  CurrentOptions = ClangTidyOptions::getDefaults().mergeWith(
-  OptionsProvider->getOptions(CurrentFile));
+  CurrentOptions = getOptionsForFile(CurrentFile);
   CheckFilter.reset(new GlobList(*getOptions().Checks));
 }
 
@@ -221,6 +219,13 @@
   return CurrentOptions;
 }
 
+ClangTidyOptions ClangTidyContext::getOptionsForFile(StringRef File) const {
+  // Merge options on top of getDefaults() as a safeguard against options with
+  // unset values.
+  return ClangTidyOptions::getDefaults().mergeWith(
+  OptionsProvider->getOptions(CurrentFile));
+}
+
 void ClangTidyContext::setCheckProfileData(ProfileData *P) { Profile = P; }
 
 GlobList &ClangTidyContext::getChecksFilter() {
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -36,6 +36,7 @@
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/ReplacementsYaml.h"
 #include "

Re: [PATCH] D12407: [clang-format-vs] Add an option to reformat source code when file is saved to disk

2015-11-06 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs:86
@@ -69,1 +85,3 @@
 
+IComponentModel componentModel = 
GetService(typeof(SComponentModel)) as IComponentModel;
+editorAdaptersFactoryService = 
componentModel.GetService();

hans wrote:
> aaron.ballman wrote:
> > berenm wrote:
> > > I did more tests on my side, and apparently this line does not work on 
> > > VS2012, componentModel is null. I don't know at all why and how to fix 
> > > it, and it works fine starting with VS2013.
> > Our minimum supported MSVC version for development is 2013. Do we document 
> > supported versions for clang-format? Do we want to support versions older 
> > than the development version we're on?
> The manifest claims support for 2010 and later. I usually test with 2012 when 
> I build the weekly snapshot.
> 
> Our clang-cl VS integration also tries to support 2010 and later, so I think 
> it would be nice if the clang-format plugin does too.
Thank you for the information! That sounds good to me. Then I think berenm's 
issue should be resolved if possible.


http://reviews.llvm.org/D12407



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


Re: [PATCH] D12407: [clang-format-vs] Add an option to reformat source code when file is saved to disk

2015-11-06 Thread Hans Wennborg via cfe-commits
hans added inline comments.


Comment at: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs:86
@@ -69,1 +85,3 @@
 
+IComponentModel componentModel = 
GetService(typeof(SComponentModel)) as IComponentModel;
+editorAdaptersFactoryService = 
componentModel.GetService();

aaron.ballman wrote:
> berenm wrote:
> > I did more tests on my side, and apparently this line does not work on 
> > VS2012, componentModel is null. I don't know at all why and how to fix it, 
> > and it works fine starting with VS2013.
> Our minimum supported MSVC version for development is 2013. Do we document 
> supported versions for clang-format? Do we want to support versions older 
> than the development version we're on?
The manifest claims support for 2010 and later. I usually test with 2012 when I 
build the weekly snapshot.

Our clang-cl VS integration also tries to support 2010 and later, so I think it 
would be nice if the clang-format plugin does too.


http://reviews.llvm.org/D12407



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


Re: [PATCH] D14292: [libcxx] Make it possible to build a no-exceptions variant of libcxx.

2015-11-06 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 39541.
rmaprath added a comment.

Patch updated to add XFAILS for all those tests that are failing on the new 
(-fno-exceptions) library variant. Follow-up patches will progressively 
un-XFAIL these tests (i.e. adapt them to cope with the new library variant).


http://reviews.llvm.org/D14292

Files:
  src/future.cpp
  test/libcxx/containers/sequences/vector/asan_throw.pass.cpp
  
test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp
  
test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp
  
test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/at.pass.cpp
  test/std/containers/associative/map/map.access/at.pass.cpp
  test/std/containers/sequences/array/at.pass.cpp
  
test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp
  
test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp
  
test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp
  
test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp
  
test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
  test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp
  
test/std/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp
  
test/std/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp
  
test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
  test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp
  test/std/depr/depr.c.headers/uchar_h.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp
  test/std/experimental/optional/optional.specalg/swap.pass.cpp
  test/std/experimental/string.view/string.view.access/at.pass.cpp
  
test/std/experimental/string.view/string.view.ops/compare.pointer_size.pass.cpp
  
test/std/experimental/string.view/string.view.ops/compare.size_size_sv.pass.cpp
  
test/std/experimental/string.view/string.view.ops/compare.size_size_sv_pointer_size.pass.cpp
  
test/std/experimental/string.view/string.view.ops/compare.size_size_sv_size_size.pass.cpp
  test/std/experimental/string.view/string.view.ops/copy.pass.cpp
  test/std/experimental/string.view/string.view.ops/substr.pass.cpp
  
test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
  test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp
  test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp
  
test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp
  test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp
  
test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
  
test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
  
test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
  
test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp
  test/std/language.support/support.exception/except.nested/assign.pass.cpp
  test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
  
test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
  
test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp
  
test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp
  
test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
  
test/std/language.support/support.exception/propagation/current_exception.pass.cpp
  
test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp
  
test/std/language.s

Re: [PATCH] D13304: Avoid inlining in throw statement

2015-11-06 Thread Jun Bum Lim via cfe-commits
junbuml added a comment.

Just ping to see if there is any objection about adding the extra check for 
CallSites in EHRs in inliner. I will be happy to hear any opinion, suggestion,  
or objection.


http://reviews.llvm.org/D13304



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


Re: [PATCH] D10599: [OPENMP 4.0] Initial support for '#pragma omp declare simd' directive.

2015-11-06 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/Basic/AttrDocs.td:1620
@@ +1619,3 @@
+  let Content = [{
+The declare simd construct can be applied to a function to enable the creation 
of one or more versions that can process multiple arguments using SIMD 
instructions from a single invocation from a SIMD loop. The declare simd 
directive is a declarative directive. There may be multiple declare simd 
directives for a function. The use of a declare simd construct on a function 
enables the creation of SIMD
+versions of the associated function that can be used to process multiple 
arguments from a single invocation from a SIMD loop concurrently.

Line length is an issue here. ;-)

Also, "from a single invocation from a SIMD loop"; should that be "from a 
single invocation of a SIMD loop" instead?

Any time you use "declare simd" as a syntactic phrase, it should be properly 
formatted for RST as ``declare simd``.


Comment at: lib/Parse/ParseOpenMP.cpp:97
@@ -89,1 +96,3 @@
+AccessSpecifier &AS, ParsedAttributesWithRange &Attrs,
+DeclSpec::TST TagType, Decl *TagDecl) {
   assert(Tok.is(tok::annot_pragma_openmp) && "Not an OpenMP directive!");

Can we not name the last parameter with an identifier that is also a type name? 
That always weirds me out. ;-)


Comment at: lib/Parse/ParseOpenMP.cpp:152
@@ +151,3 @@
+  } else {
+Ptr = ParseCXXClassMemberDeclarationWithPragmas(AS, Attrs, TagType,
+TagDecl);

Can you add a test case for a member declaration that has attributes to ensure 
the attributes are properly handled here? In fact, it would be good to add one 
for the top-level function as well.


Comment at: lib/Sema/SemaOpenMP.cpp:2370
@@ +2369,3 @@
+
+  auto *NewAttr = new (Context) OMPDeclareSimdDeclAttr(
+  SourceRange(StartLoc, StartLoc), Context, /*SI=*/0);

Please use OMPDeclareSimdDeclAttr::CreateImplicit instead.


http://reviews.llvm.org/D10599



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


[clang-tools-extra] r252315 - Allow the alias to be of a different type.

2015-11-06 Thread Angel Garcia Gomez via cfe-commits
Author: angelgarcia
Date: Fri Nov  6 09:47:04 2015
New Revision: 252315

URL: http://llvm.org/viewvc/llvm-project?rev=252315&view=rev
Log:
Allow the alias to be of a different type.

Summary: Consider a declaration an alias even if it doesn't have the same 
unqualified type than the container element, as long as one can be converted to 
the other using only implicit casts.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp?rev=252315&r1=252314&r2=252315&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp Fri Nov  
6 09:47:04 2015
@@ -342,21 +342,27 @@ static bool isAliasDecl(ASTContext *Cont
   if (!VDecl->hasInit())
 return false;
 
-  const Expr *Init =
-  digThroughConstructors(VDecl->getInit()->IgnoreParenImpCasts());
+  bool OnlyCasts = true;
+  const Expr *Init = VDecl->getInit()->IgnoreParenImpCasts();
+  if (Init && isa(Init)) {
+Init = digThroughConstructors(Init);
+OnlyCasts = false;
+  }
   if (!Init)
 return false;
 
   // Check that the declared type is the same as (or a reference to) the
   // container type.
-  QualType InitType = Init->getType();
-  QualType DeclarationType = VDecl->getType();
-  if (!DeclarationType.isNull() && DeclarationType->isReferenceType())
-DeclarationType = DeclarationType.getNonReferenceType();
-
-  if (InitType.isNull() || DeclarationType.isNull() ||
-  !Context->hasSameUnqualifiedType(DeclarationType, InitType))
-return false;
+  if (!OnlyCasts) {
+QualType InitType = Init->getType();
+QualType DeclarationType = VDecl->getType();
+if (!DeclarationType.isNull() && DeclarationType->isReferenceType())
+  DeclarationType = DeclarationType.getNonReferenceType();
+
+if (InitType.isNull() || DeclarationType.isNull() ||
+!Context->hasSameUnqualifiedType(DeclarationType, InitType))
+  return false;
+  }
 
   switch (Init->getStmtClass()) {
   case Stmt::ArraySubscriptExprClass: {
@@ -384,8 +390,8 @@ static bool isAliasDecl(ASTContext *Cont
 const auto *MemCall = cast(Init);
 // This check is needed because getMethodDecl can return nullptr if the
 // callee is a member function pointer.
-if (MemCall->getMethodDecl() &&
-MemCall->getMethodDecl()->getName() == "at") {
+const auto *MDecl = MemCall->getMethodDecl();
+if (MDecl && !isa(MDecl) && MDecl->getName() == "at") {
   assert(MemCall->getNumArgs() == 1);
   return isIndexInSubscriptExpr(MemCall->getArg(0), IndexVar);
 }

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp?rev=252315&r1=252314&r2=252315&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp 
Fri Nov  6 09:47:04 2015
@@ -159,7 +159,7 @@ void aliasing() {
   // CHECK-FIXES: for (int Alias : IntArr)
   // CHECK-FIXES-NEXT: for (unsigned J = 0; Alias; ++J)
 
-  struct IntRef { IntRef(const int& i); };
+  struct IntRef { IntRef(); IntRef(const int& i); operator int*(); };
   for (int I = 0; I < N; ++I) {
 IntRef Int(IntArr[I]);
   }
@@ -167,6 +167,25 @@ void aliasing() {
   // CHECK-FIXES: for (int I : IntArr)
   // CHECK-FIXES-NEXT: IntRef Int(I);
 
+  int *PtrArr[N];
+  for (unsigned I = 0; I < N; ++I) {
+const int* const P = PtrArr[I];
+printf("%d\n", *P);
+  }
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (auto P : PtrArr)
+  // CHECK-FIXES-NEXT: printf("%d\n", *P);
+
+  IntRef Refs[N];
+  for (unsigned I = 0; I < N; ++I) {
+int *P = Refs[I];
+printf("%d\n", *P);
+  }
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (auto & Ref : Refs)
+  // CHECK-FIXES-NEXT: int *P = Ref;
+  // CHECK-FIXES-NEXT: printf("%d\n", *P);
+
   // Ensure that removing the alias doesn't leave empty lines behind.
   for (int I = 0; I < N; ++I) {
 auto &X = IntArr[I];


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


Re: [PATCH] D14442: Allow the alias to be of a different type.

2015-11-06 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D14442



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


Re: [libcxx] r252274 - Cleanup foo.h headers and __config to work in C

2015-11-06 Thread Dan Albert via cfe-commits
Yeah, what's the motivation for this? I'd actually prefer that these didn't
work in C because I'd like to know if my build system is broken.
On Nov 6, 2015 03:05, "Joerg Sonnenberger via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> On Fri, Nov 06, 2015 at 06:30:12AM -, Eric Fiselier via cfe-commits
> wrote:
> > Author: ericwf
> > Date: Fri Nov  6 00:30:12 2015
> > New Revision: 252274
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=252274&view=rev
> > Log:
> > Cleanup foo.h headers and __config to work in C
>
> Why?
>
> Joerg
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12407: [clang-format-vs] Add an option to reformat source code when file is saved to disk

2015-11-06 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs:86
@@ -69,1 +85,3 @@
 
+IComponentModel componentModel = 
GetService(typeof(SComponentModel)) as IComponentModel;
+editorAdaptersFactoryService = 
componentModel.GetService();

berenm wrote:
> I did more tests on my side, and apparently this line does not work on 
> VS2012, componentModel is null. I don't know at all why and how to fix it, 
> and it works fine starting with VS2013.
Our minimum supported MSVC version for development is 2013. Do we document 
supported versions for clang-format? Do we want to support versions older than 
the development version we're on?


http://reviews.llvm.org/D12407



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


Re: [PATCH] D14442: Allow the alias to be of a different type.

2015-11-06 Thread Angel Garcia via cfe-commits
angelgarcia updated this revision to Diff 39530.
angelgarcia added a comment.

The test revealed a (already existing) bug. If we called getName() on a 
CXXConversionDecl, we would get the following assertion:

include/clang/AST/Decl.h:170: llvm::StringRef clang::NamedDecl::getName() 
const: Assertion `Name.isIdentifier() && "Name is not a simple identifier"' 
failed.

Solved now.


http://reviews.llvm.org/D14442

Files:
  clang-tidy/modernize/LoopConvertUtils.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp

Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -159,14 +159,33 @@
   // CHECK-FIXES: for (int Alias : IntArr)
   // CHECK-FIXES-NEXT: for (unsigned J = 0; Alias; ++J)
 
-  struct IntRef { IntRef(const int& i); };
+  struct IntRef { IntRef(); IntRef(const int& i); operator int*(); };
   for (int I = 0; I < N; ++I) {
 IntRef Int(IntArr[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (int I : IntArr)
   // CHECK-FIXES-NEXT: IntRef Int(I);
 
+  int *PtrArr[N];
+  for (unsigned I = 0; I < N; ++I) {
+const int* const P = PtrArr[I];
+printf("%d\n", *P);
+  }
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (auto P : PtrArr)
+  // CHECK-FIXES-NEXT: printf("%d\n", *P);
+
+  IntRef Refs[N];
+  for (unsigned I = 0; I < N; ++I) {
+int *P = Refs[I];
+printf("%d\n", *P);
+  }
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (auto & Ref : Refs)
+  // CHECK-FIXES-NEXT: int *P = Ref;
+  // CHECK-FIXES-NEXT: printf("%d\n", *P);
+
   // Ensure that removing the alias doesn't leave empty lines behind.
   for (int I = 0; I < N; ++I) {
 auto &X = IntArr[I];
Index: clang-tidy/modernize/LoopConvertUtils.cpp
===
--- clang-tidy/modernize/LoopConvertUtils.cpp
+++ clang-tidy/modernize/LoopConvertUtils.cpp
@@ -342,21 +342,27 @@
   if (!VDecl->hasInit())
 return false;
 
-  const Expr *Init =
-  digThroughConstructors(VDecl->getInit()->IgnoreParenImpCasts());
+  bool OnlyCasts = true;
+  const Expr *Init = VDecl->getInit()->IgnoreParenImpCasts();
+  if (Init && isa(Init)) {
+Init = digThroughConstructors(Init);
+OnlyCasts = false;
+  }
   if (!Init)
 return false;
 
   // Check that the declared type is the same as (or a reference to) the
   // container type.
-  QualType InitType = Init->getType();
-  QualType DeclarationType = VDecl->getType();
-  if (!DeclarationType.isNull() && DeclarationType->isReferenceType())
-DeclarationType = DeclarationType.getNonReferenceType();
+  if (!OnlyCasts) {
+QualType InitType = Init->getType();
+QualType DeclarationType = VDecl->getType();
+if (!DeclarationType.isNull() && DeclarationType->isReferenceType())
+  DeclarationType = DeclarationType.getNonReferenceType();
 
-  if (InitType.isNull() || DeclarationType.isNull() ||
-  !Context->hasSameUnqualifiedType(DeclarationType, InitType))
-return false;
+if (InitType.isNull() || DeclarationType.isNull() ||
+!Context->hasSameUnqualifiedType(DeclarationType, InitType))
+  return false;
+  }
 
   switch (Init->getStmtClass()) {
   case Stmt::ArraySubscriptExprClass: {
@@ -384,8 +390,8 @@
 const auto *MemCall = cast(Init);
 // This check is needed because getMethodDecl can return nullptr if the
 // callee is a member function pointer.
-if (MemCall->getMethodDecl() &&
-MemCall->getMethodDecl()->getName() == "at") {
+const auto *MDecl = MemCall->getMethodDecl();
+if (MDecl && !isa(MDecl) && MDecl->getName() == "at") {
   assert(MemCall->getNumArgs() == 1);
   return isIndexInSubscriptExpr(MemCall->getArg(0), IndexVar);
 }


Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -159,14 +159,33 @@
   // CHECK-FIXES: for (int Alias : IntArr)
   // CHECK-FIXES-NEXT: for (unsigned J = 0; Alias; ++J)
 
-  struct IntRef { IntRef(const int& i); };
+  struct IntRef { IntRef(); IntRef(const int& i); operator int*(); };
   for (int I = 0; I < N; ++I) {
 IntRef Int(IntArr[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
   // CHECK-FIXES: for (int I : IntArr)
   // CHECK-FIXES-NEXT: IntRef Int(I);
 
+  int *PtrArr[N];
+  for (unsigned I = 0; I < N; ++I) {
+const int* const P = PtrArr[I];
+printf("%d\n", *P);
+  }
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (auto P : PtrArr)
+  // CHECK-FIXES-NEXT: printf("%d\n", *P);
+
+  IntRef

Re: [PATCH] D12407: [clang-format-vs] Add an option to reformat source code when file is saved to disk

2015-11-06 Thread Beren Minor via cfe-commits
berenm added inline comments.


Comment at: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs:86
@@ -69,1 +85,3 @@
 
+IComponentModel componentModel = 
GetService(typeof(SComponentModel)) as IComponentModel;
+editorAdaptersFactoryService = 
componentModel.GetService();

I did more tests on my side, and apparently this line does not work on VS2012, 
componentModel is null. I don't know at all why and how to fix it, and it works 
fine starting with VS2013.


http://reviews.llvm.org/D12407



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


r252314 - Fixing line endings; NFC.

2015-11-06 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Nov  6 09:34:03 2015
New Revision: 252314

URL: http://llvm.org/viewvc/llvm-project?rev=252314&view=rev
Log:
Fixing line endings; NFC.

Modified:
cfe/trunk/include/clang/Basic/AttrDocs.td

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=252314&r1=252313&r2=252314&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Fri Nov  6 09:34:03 2015
@@ -181,9 +181,9 @@ to enforce the provided alignment assump
 def EnableIfDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
-.. Note:: Some features of this attribute are experimental. The meaning of
-  multiple enable_if attributes on a single declaration is subject to change in
-  a future version of clang. Also, the ABI is not standardized and the name
+.. Note:: Some features of this attribute are experimental. The meaning of
+  multiple enable_if attributes on a single declaration is subject to change in
+  a future version of clang. Also, the ABI is not standardized and the name
   mangling may change in future versions. To avoid that, use asm labels.
 
 The ``enable_if`` attribute can be placed on function declarations to control


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


Re: [PATCH] D14192: Add ExtraArgs and ExtraArgsBefore options to enable clang warnings via configuration files.

2015-11-06 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: clang-tidy/ClangTidy.cpp:382
@@ +381,3 @@
+  const CommandLineArguments &Args, StringRef Filename) {
+Context.setCurrentFile(Filename);
+const ClangTidyOptions &Opts = Context.getOptions();

alexfh wrote:
> klimek wrote:
> > alexfh wrote:
> > > klimek wrote:
> > > > My concern is still with the Filename in the arg callback. I'd like to 
> > > > understand the full use-case better.
> > > > From this code it looks like we want to change the ClangTidyContext's 
> > > > file and use the callback for that? That seems rather out of place, but 
> > > > maybe I'm missing something.
> > > We need the filename to retrieve the proper ClangTidyOptions for each 
> > > file. Context.setCurrentFile is used to specify which file should 
> > > getOptions return the options for.
> > But the extra-args don't depend on the file; it seems like the filename in 
> > the callback is only used to be notified when the file changes?
> The thing is that they do depend on the file, because we're implementing 
> their configuration from the config file, and different translation units can 
> have different corresponding configuration files.
Ok, now I get it. I completely didn't expect an interface that needs a 
setCurrentFile so it can getOptions afterwards for that file.
In that case, the Filename is OK, but I suggest changing the ClangTidyOptions 
to provide getOptions(file) instead.


http://reviews.llvm.org/D14192



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


Re: [PATCH] D14192: Add ExtraArgs and ExtraArgsBefore options to enable clang warnings via configuration files.

2015-11-06 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/ClangTidy.cpp:382
@@ +381,3 @@
+  const CommandLineArguments &Args, StringRef Filename) {
+Context.setCurrentFile(Filename);
+const ClangTidyOptions &Opts = Context.getOptions();

klimek wrote:
> alexfh wrote:
> > klimek wrote:
> > > My concern is still with the Filename in the arg callback. I'd like to 
> > > understand the full use-case better.
> > > From this code it looks like we want to change the ClangTidyContext's 
> > > file and use the callback for that? That seems rather out of place, but 
> > > maybe I'm missing something.
> > We need the filename to retrieve the proper ClangTidyOptions for each file. 
> > Context.setCurrentFile is used to specify which file should getOptions 
> > return the options for.
> But the extra-args don't depend on the file; it seems like the filename in 
> the callback is only used to be notified when the file changes?
The thing is that they do depend on the file, because we're implementing their 
configuration from the config file, and different translation units can have 
different corresponding configuration files.


http://reviews.llvm.org/D14192



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


Re: [PATCH] D12547: Add support for function attribute "disable_tail_calls"

2015-11-06 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Are you still looking for review on this patch, or are you intending to make 
modifications based on further discussion from the other tail call attribute?


http://reviews.llvm.org/D12547



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


Re: [PATCH] D14442: Allow the alias to be of a different type.

2015-11-06 Thread Manuel Klimek via cfe-commits
klimek added a comment.

Can you add a test with an overloaded conversion operator?


http://reviews.llvm.org/D14442



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


Re: [PATCH] D14403: Create install targets for scan-build and scan-view

2015-11-06 Thread Jonathan Roelofs via cfe-commits
jroelofs updated this revision to Diff 39529.
jroelofs added a comment.

Forgot to `svn add` after rebasing the patch on top of upstream.


http://reviews.llvm.org/D14403

Files:
  tools/CMakeLists.txt
  tools/Makefile
  tools/scan-build/CMakeLists.txt
  tools/scan-build/Makefile
  tools/scan-build/scan-build
  tools/scan-view/CMakeLists.txt
  tools/scan-view/Makefile
  tools/scan-view/Reporter.py
  tools/scan-view/ScanView.py
  www/analyzer/installation.html

Index: www/analyzer/installation.html
===
--- www/analyzer/installation.html
+++ www/analyzer/installation.html
@@ -100,11 +100,8 @@
 The locations of the scan-build and scan-view
 programs.
 
-Currently these are not installed using make install, and
-are located in $(SRCDIR)/tools/clang/tools/scan-build and
-$(SRCDIR)/tools/clang/tools/scan-view respectively (where
-$(SRCDIR) is the root LLVM source directory).  These locations
-are subject to change.
+These are installed via make install into the bin directory
+when clang is built.
 
 
 
Index: tools/scan-view/ScanView.py
===
--- tools/scan-view/ScanView.py
+++ tools/scan-view/ScanView.py
@@ -73,7 +73,7 @@
 ###
 # Other simple parameters
 
-kResources = posixpath.join(posixpath.dirname(__file__), 'Resources')
+kResources = posixpath.join(posixpath.dirname(__file__), '../share/scan-view')
 kConfigPath = os.path.expanduser('~/.scanview.cfg')
 
 ###
Index: tools/scan-view/Reporter.py
===
--- tools/scan-view/Reporter.py
+++ tools/scan-view/Reporter.py
@@ -175,7 +175,7 @@
 @staticmethod
 def isAvailable():
 # FIXME: Find this .scpt better
-path = os.path.join(os.path.dirname(__file__),'Resources/GetRadarVersion.scpt')
+path = os.path.join(os.path.dirname(__file__),'../share/scan-view/GetRadarVersion.scpt')
 try:
   p = subprocess.Popen(['osascript',path], 
   stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@@ -206,7 +206,7 @@
 if not componentVersion.strip():
 componentVersion = 'X'
 
-script = os.path.join(os.path.dirname(__file__),'Resources/FileRadar.scpt')
+script = os.path.join(os.path.dirname(__file__),'../share/scan-view/FileRadar.scpt')
 args = ['osascript', script, component, componentVersion, classification, personID, report.title,
 report.description, diagnosis, config] + map(os.path.abspath, report.files)
 #print >>sys.stderr, args
Index: tools/scan-view/Makefile
===
--- tools/scan-view/Makefile
+++ tools/scan-view/Makefile
@@ -0,0 +1,33 @@
+##===- tools/scan-view/Makefile *- Makefile -*-===##
+# 
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+# 
+##===--===##
+
+CLANG_LEVEL := ../..
+
+include $(CLANG_LEVEL)/../../Makefile.config
+include $(CLANG_LEVEL)/Makefile
+
+InstallTargets := $(ToolDir)/Reporter.py \
+  $(ToolDir)/ScanView.py \
+  $(ToolDir)/scan-view \
+  $(ToolDir)/startfile.py \
+  $(ShareDir)/scan-view/FileRadar.scpt \
+  $(ShareDir)/scan-view/GetRadarVersion.scpt \
+  $(ShareDir)/scan-view/bugcatcher.ico
+
+all:: $(InstallTargets)
+
+$(ToolDir)/%: % Makefile $(ToolDir)/.dir
+	$(Echo) "Copying $(notdir $<) to the 'bin' directory..."
+	$(Verb)cp $< $@
+	$(Verb)chmod +x $@
+
+$(ShareDir)/scan-view/%: Resources/% Makefile $(ShareDir)/scan-view/.dir
+	$(Echo) "Copying $(notdir $<) to the 'share' directory..."
+	$(Verb)cp $< $@
+
Index: tools/scan-view/CMakeLists.txt
===
--- tools/scan-view/CMakeLists.txt
+++ tools/scan-view/CMakeLists.txt
@@ -0,0 +1,30 @@
+add_custom_target(scan-view ALL)
+
+set(BinFiles
+  Reporter.py
+  ScanView.py
+  scan-view
+  startfile.py)
+
+file(GLOB ResourceFiles Resources/*)
+
+foreach(BinFile ${BinFiles})
+  add_custom_command(TARGET scan-view PRE_BUILD
+ COMMAND ${CMAKE_COMMAND} -E make_directory
+   ${CMAKE_BINARY_DIR}/bin
+ COMMAND ${CMAKE_COMMAND} -E copy
+   ${CMAKE_CURRENT_SOURCE_DIR}/${BinFile}
+   ${CMAKE_BINARY_DIR}/bin/)
+  install(PROGRAMS ${BinFile} DESTINATION bin)
+endforeach()
+
+foreach(ResourceFile ${ResourceFiles})
+  add_custom_command(TARGET scan-view PRE_BUILD
+ COMMAND ${CMAKE_COMMAND} -E make_directory
+   ${CMAKE_BINARY_DIR}/share/scan-view
+ COMMAND ${CMAKE_COMMAND} -E copy
+   ${ResourceF

Re: [PATCH] D12407: [clang-format-vs] Add an option to reformat source code when file is saved to disk

2015-11-06 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Ping. rnk, do you have a moment to look this over? My C#-fu is a bit rusty, but 
this seems reasonable to me.


http://reviews.llvm.org/D12407



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


Re: [PATCH] D14192: Add ExtraArgs and ExtraArgsBefore options to enable clang warnings via configuration files.

2015-11-06 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: clang-tidy/ClangTidy.cpp:382
@@ +381,3 @@
+  const CommandLineArguments &Args, StringRef Filename) {
+Context.setCurrentFile(Filename);
+const ClangTidyOptions &Opts = Context.getOptions();

alexfh wrote:
> klimek wrote:
> > My concern is still with the Filename in the arg callback. I'd like to 
> > understand the full use-case better.
> > From this code it looks like we want to change the ClangTidyContext's file 
> > and use the callback for that? That seems rather out of place, but maybe 
> > I'm missing something.
> We need the filename to retrieve the proper ClangTidyOptions for each file. 
> Context.setCurrentFile is used to specify which file should getOptions return 
> the options for.
But the extra-args don't depend on the file; it seems like the filename in the 
callback is only used to be notified when the file changes?


http://reviews.llvm.org/D14192



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


Re: [PATCH] D14442: Allow the alias to be of a different type.

2015-11-06 Thread Angel Garcia via cfe-commits
angelgarcia added a comment.

No. There is a test for that just before the one I added.


http://reviews.llvm.org/D14442



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


Re: [PATCH] D14442: Allow the alias to be of a different type.

2015-11-06 Thread Manuel Klimek via cfe-commits
klimek added a comment.

Does this still do it for types with a user-provided implicit constructor?


http://reviews.llvm.org/D14442



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


r252311 - Followup test failure fix for r252310 ("[tsan] Add Clang frontend support for TSan on OS X").

2015-11-06 Thread Kuba Brecka via cfe-commits
Author: kuba.brecka
Date: Fri Nov  6 09:20:30 2015
New Revision: 252311

URL: http://llvm.org/viewvc/llvm-project?rev=252311&view=rev
Log:
Followup test failure fix for r252310 ("[tsan] Add Clang frontend support for 
TSan on OS X").


Modified:
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=252311&r1=252310&r2=252311&view=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Fri Nov  6 09:20:30 2015
@@ -207,12 +207,11 @@
 // CHECK-MSAN-NOMSAN-DARWIN-NOT: unsupported option
 
 // RUN: %clang -target x86_64-apple-darwin10 -fsanitize=memory 
-fsanitize=thread,memory %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-MSAN-TSAN-MSAN-DARWIN
-// CHECK-MSAN-TSAN-MSAN-DARWIN: unsupported option '-fsanitize=thread,memory' 
for target 'x86_64-apple-darwin10'
+// CHECK-MSAN-TSAN-MSAN-DARWIN: unsupported option '-fsanitize=memory' for 
target 'x86_64-apple-darwin10'
 // CHECK-MSAN-TSAN-MSAN-DARWIN-NOT: unsupported option
 
 // RUN: %clang -target x86_64-apple-darwin10 -fsanitize=thread,memory 
-fsanitize=memory %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-TSAN-MSAN-MSAN-DARWIN
 // CHECK-TSAN-MSAN-MSAN-DARWIN: unsupported option '-fsanitize=memory' for 
target 'x86_64-apple-darwin10'
-// CHECK-TSAN-MSAN-MSAN-DARWIN: unsupported option '-fsanitize=thread' for 
target 'x86_64-apple-darwin10'
 // CHECK-TSAN-MSAN-MSAN-DARWIN-NOT: unsupported option
 
 // RUN: %clang -target x86_64-apple-darwin10 -fsanitize=function %s -### 2>&1 
| FileCheck %s --check-prefix=CHECK-FSAN-DARWIN


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


[PATCH] D14442: Allow the alias to be of a different type.

2015-11-06 Thread Angel Garcia via cfe-commits
angelgarcia created this revision.
angelgarcia added a reviewer: klimek.
angelgarcia added subscribers: cfe-commits, alexfh.

Consider a declaration an alias even if it doesn't have the same unqualified 
type than the container element, as long as one can be converted to the other 
using only implicit casts.

http://reviews.llvm.org/D14442

Files:
  clang-tidy/modernize/LoopConvertUtils.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp

Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -167,6 +167,15 @@
   // CHECK-FIXES: for (int I : IntArr)
   // CHECK-FIXES-NEXT: IntRef Int(I);
 
+  int *PtrArr[N];
+  for (unsigned I = 0; I < N; ++I) {
+const int* const P = PtrArr[I];
+printf("%d\n", *P);
+  }
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (auto P : PtrArr)
+  // CHECK-FIXES-NEXT: printf("%d\n", *P);
+
   // Ensure that removing the alias doesn't leave empty lines behind.
   for (int I = 0; I < N; ++I) {
 auto &X = IntArr[I];
Index: clang-tidy/modernize/LoopConvertUtils.cpp
===
--- clang-tidy/modernize/LoopConvertUtils.cpp
+++ clang-tidy/modernize/LoopConvertUtils.cpp
@@ -342,21 +342,27 @@
   if (!VDecl->hasInit())
 return false;
 
-  const Expr *Init =
-  digThroughConstructors(VDecl->getInit()->IgnoreParenImpCasts());
+  bool OnlyCasts = true;
+  const Expr *Init = VDecl->getInit()->IgnoreParenImpCasts();
+  if (Init && isa(Init)) {
+Init = digThroughConstructors(Init);
+OnlyCasts = false;
+  }
   if (!Init)
 return false;
 
   // Check that the declared type is the same as (or a reference to) the
   // container type.
-  QualType InitType = Init->getType();
-  QualType DeclarationType = VDecl->getType();
-  if (!DeclarationType.isNull() && DeclarationType->isReferenceType())
-DeclarationType = DeclarationType.getNonReferenceType();
+  if (!OnlyCasts) {
+QualType InitType = Init->getType();
+QualType DeclarationType = VDecl->getType();
+if (!DeclarationType.isNull() && DeclarationType->isReferenceType())
+  DeclarationType = DeclarationType.getNonReferenceType();
 
-  if (InitType.isNull() || DeclarationType.isNull() ||
-  !Context->hasSameUnqualifiedType(DeclarationType, InitType))
-return false;
+if (InitType.isNull() || DeclarationType.isNull() ||
+!Context->hasSameUnqualifiedType(DeclarationType, InitType))
+  return false;
+  }
 
   switch (Init->getStmtClass()) {
   case Stmt::ArraySubscriptExprClass: {


Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -167,6 +167,15 @@
   // CHECK-FIXES: for (int I : IntArr)
   // CHECK-FIXES-NEXT: IntRef Int(I);
 
+  int *PtrArr[N];
+  for (unsigned I = 0; I < N; ++I) {
+const int* const P = PtrArr[I];
+printf("%d\n", *P);
+  }
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (auto P : PtrArr)
+  // CHECK-FIXES-NEXT: printf("%d\n", *P);
+
   // Ensure that removing the alias doesn't leave empty lines behind.
   for (int I = 0; I < N; ++I) {
 auto &X = IntArr[I];
Index: clang-tidy/modernize/LoopConvertUtils.cpp
===
--- clang-tidy/modernize/LoopConvertUtils.cpp
+++ clang-tidy/modernize/LoopConvertUtils.cpp
@@ -342,21 +342,27 @@
   if (!VDecl->hasInit())
 return false;
 
-  const Expr *Init =
-  digThroughConstructors(VDecl->getInit()->IgnoreParenImpCasts());
+  bool OnlyCasts = true;
+  const Expr *Init = VDecl->getInit()->IgnoreParenImpCasts();
+  if (Init && isa(Init)) {
+Init = digThroughConstructors(Init);
+OnlyCasts = false;
+  }
   if (!Init)
 return false;
 
   // Check that the declared type is the same as (or a reference to) the
   // container type.
-  QualType InitType = Init->getType();
-  QualType DeclarationType = VDecl->getType();
-  if (!DeclarationType.isNull() && DeclarationType->isReferenceType())
-DeclarationType = DeclarationType.getNonReferenceType();
+  if (!OnlyCasts) {
+QualType InitType = Init->getType();
+QualType DeclarationType = VDecl->getType();
+if (!DeclarationType.isNull() && DeclarationType->isReferenceType())
+  DeclarationType = DeclarationType.getNonReferenceType();
 
-  if (InitType.isNull() || DeclarationType.isNull() ||
-  !Context->hasSameUnqualifiedType(DeclarationType, InitType))
-return false;
+if (InitType.isNull() || DeclarationType.isNull() ||
+!Context->hasSameUnqualifiedType(DeclarationType, InitType))
+  return false;
+  }
 
   switch (Init->getStmtClass()) {
   c

Re: [PATCH] D14192: Add ExtraArgs and ExtraArgsBefore options to enable clang warnings via configuration files.

2015-11-06 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/ClangTidy.cpp:382
@@ +381,3 @@
+  const CommandLineArguments &Args, StringRef Filename) {
+Context.setCurrentFile(Filename);
+const ClangTidyOptions &Opts = Context.getOptions();

klimek wrote:
> My concern is still with the Filename in the arg callback. I'd like to 
> understand the full use-case better.
> From this code it looks like we want to change the ClangTidyContext's file 
> and use the callback for that? That seems rather out of place, but maybe I'm 
> missing something.
We need the filename to retrieve the proper ClangTidyOptions for each file. 
Context.setCurrentFile is used to specify which file should getOptions return 
the options for.


http://reviews.llvm.org/D14192



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


Re: [PATCH] D14440: [tsan] Add Clang frontend support for TSan on OS X

2015-11-06 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL252310: [tsan] Add Clang frontend support for TSan on OS X 
(authored by kuba.brecka).

Changed prior to commit:
  http://reviews.llvm.org/D14440?vs=39524&id=39526#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14440

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

Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -389,6 +389,8 @@
 AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
   if (Sanitize.needsUbsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
+  if (Sanitize.needsTsanRt())
+AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
 
   // Otherwise link libSystem, then the dynamic runtime library, and finally 
any
   // target specific static runtime library.
@@ -1199,6 +1201,7 @@
 if (!isMacosxVersionLT(10, 9))
   Res |= SanitizerKind::Vptr;
 Res |= SanitizerKind::SafeStack;
+Res |= SanitizerKind::Thread;
   }
   return Res;
 }


Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -389,6 +389,8 @@
 AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
   if (Sanitize.needsUbsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
+  if (Sanitize.needsTsanRt())
+AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
 
   // Otherwise link libSystem, then the dynamic runtime library, and finally any
   // target specific static runtime library.
@@ -1199,6 +1201,7 @@
 if (!isMacosxVersionLT(10, 9))
   Res |= SanitizerKind::Vptr;
 Res |= SanitizerKind::SafeStack;
+Res |= SanitizerKind::Thread;
   }
   return Res;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r252310 - [tsan] Add Clang frontend support for TSan on OS X

2015-11-06 Thread Kuba Brecka via cfe-commits
Author: kuba.brecka
Date: Fri Nov  6 09:09:20 2015
New Revision: 252310

URL: http://llvm.org/viewvc/llvm-project?rev=252310&view=rev
Log:
[tsan] Add Clang frontend support for TSan on OS X

We're currently in process of porting TSan to OS X, and quite a few of the 
initial support in the runtime library has already landed in trunk. This patch 
actually enables "-fsanitize=thread" in the frontend.

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


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

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=252310&r1=252309&r2=252310&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Nov  6 09:09:20 2015
@@ -389,6 +389,8 @@ void DarwinClang::AddLinkRuntimeLibArgs(
 AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
   if (Sanitize.needsUbsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
+  if (Sanitize.needsTsanRt())
+AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
 
   // Otherwise link libSystem, then the dynamic runtime library, and finally 
any
   // target specific static runtime library.
@@ -1199,6 +1201,7 @@ SanitizerMask Darwin::getSupportedSaniti
 if (!isMacosxVersionLT(10, 9))
   Res |= SanitizerKind::Vptr;
 Res |= SanitizerKind::SafeStack;
+Res |= SanitizerKind::Thread;
   }
   return Res;
 }


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


[PATCH] D14441: [OpenCL] Pipe types support.

2015-11-06 Thread Alexey Bader via cfe-commits
bader created this revision.
bader added reviewers: pekka.jaaskelainen, gbenyei.
bader added a subscriber: cfe-commits.

Initial support for OpenCL 2.0 feature: pipe types.

http://reviews.llvm.org/D14441

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/DataRecursiveASTVisitor.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/Type.h
  include/clang/AST/TypeLoc.h
  include/clang/AST/TypeNodes.def
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/CodeGenOpenCL/pipe_types.cl
  test/PCH/ocl_types.cl
  test/PCH/ocl_types.h
  tools/libclang/CIndex.cpp

Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -447,6 +447,12 @@
   Code = TYPE_ATOMIC;
 }
 
+void
+ASTTypeWriter::VisitPipeType(const PipeType *T) {
+  Writer.AddTypeRef(T->getElementType(), Record);
+  Code = TYPE_PIPE;
+}
+
 namespace {
 
 class TypeLocWriter : public TypeLocVisitor {
@@ -672,6 +678,9 @@
   Writer.AddSourceLocation(TL.getKWLoc(), Record);
   Writer.AddSourceLocation(TL.getLParenLoc(), Record);
   Writer.AddSourceLocation(TL.getRParenLoc(), Record);
+}
+void TypeLocWriter::VisitPipeTypeLoc(PipeTypeLoc TL) {
+  Writer.AddSourceLocation(TL.getKWLoc(), Record);
 }
 
 void ASTWriter::WriteTypeAbbrevs() {
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -5631,6 +5631,17 @@
 QualType ValueType = readType(*Loc.F, Record, Idx);
 return Context.getAtomicType(ValueType);
   }
+
+  case TYPE_PIPE: {
+if (Record.size() != 1) {
+  Error("Incorrect encoding of pipe type");
+  return QualType();
+}
+
+// Reading the pipe element type.
+QualType ElementType = readType(*Loc.F, Record, Idx);
+return Context.getPipeType(ElementType);
+  }
   }
   llvm_unreachable("Invalid TypeCode!");
 }
@@ -5901,6 +5912,9 @@
   TL.setKWLoc(ReadSourceLocation(Record, Idx));
   TL.setLParenLoc(ReadSourceLocation(Record, Idx));
   TL.setRParenLoc(ReadSourceLocation(Record, Idx));
+}
+void TypeLocReader::VisitPipeTypeLoc(PipeTypeLoc TL) {
+  TL.setKWLoc(ReadSourceLocation(Record, Idx));
 }
 
 TypeSourceInfo *ASTReader::GetTypeSourceInfo(ModuleFile &F,
Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -3321,6 +3321,15 @@
 case tok::kw___bool:
   isInvalid = DS.SetTypeAltiVecBool(true, Loc, PrevSpec, DiagID, Policy);
   break;
+case tok::kw_pipe:
+  if (!getLangOpts().OpenCL || (getLangOpts().OpenCLVersion < 200)) {
+// OpenCL 2.0 defined this keyword. OpenCL 1.2 and earlier should
+// support the "pipe" word as identifier.
+Tok.getIdentifierInfo()->revertTokenIDToIdentifier();
+goto DoneWithDeclSpec;
+  }
+  isInvalid = DS.SetTypePipe(true, Loc, PrevSpec, DiagID, Policy);
+  break;
 case tok::kw___unknown_anytype:
   isInvalid = DS.SetTypeSpecType(TST_unknown_anytype, Loc,
  PrevSpec, DiagID, Policy);
@@ -4396,6 +4405,9 @@
   switch (Tok.getKind()) {
   default: return false;
 
+  case tok::kw_pipe:
+return getLangOpts().OpenCL && (getLangOpts().OpenCLVersion >= 200);
+
   case tok::identifier:   // foo::bar
 // Unfortunate hack to support "Class.factoryMethod" notation.
 if (getLangOpts().ObjC1 && NextToken().is(tok::period))
@@ -4841,6 +4853,9 @@
   if (Kind == tok::star || Kind == tok::caret)
 return true;
 
+  if ((Kind == tok::kw_pipe) && Lang.OpenCL && (Lang.OpenCLVersion >= 200))
+return true;
+
   if (!Lang.CPlusPlus)
 return false;
 
@@ -4935,6 +4950,16 @@
   }
 
   tok::TokenKind Kind = Tok.getKind();
+
+  if ( D.getDeclSpec().isTypeSpecPipe() ) {
+DeclSpec &DS = D.getMutableDeclSpec();
+
+  D.AddTypeInfo(DeclaratorChunk::getPipe(DS.getTypeQualifiers(),
+   DS.getPipeLoc()),
+  DS.getAttributes(),
+  SourceLocation());

[clang-tools-extra] r252308 - Use the old index identifier by default, instead of 'elem'.

2015-11-06 Thread Angel Garcia Gomez via cfe-commits
Author: angelgarcia
Date: Fri Nov  6 09:03:14 2015
New Revision: 252308

URL: http://llvm.org/viewvc/llvm-project?rev=252308&view=rev
Log:
Use the old index identifier by default, instead of 'elem'.

Summary: Use the old index name in the cases where the check would come up with 
an invented name.

Reviewers: klimek

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-camelback.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-const.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-lowercase.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-uppercase.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp?rev=252308&r1=252307&r2=252308&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp Fri Nov  
6 09:03:14 2015
@@ -831,54 +831,7 @@ std::string VariableNamer::createIndexNa
   return IteratorName;
   }
 
-  std::string Elem;
-  switch (Style) {
-  case NS_CamelBack:
-  case NS_LowerCase:
-Elem = "elem";
-break;
-  case NS_CamelCase:
-Elem = "Elem";
-break;
-  case NS_UpperCase:
-Elem = "ELEM";
-  }
-  // E.g.: (auto elem : container)
-  if (!declarationExists(Elem))
-return Elem;
-
-  IteratorName = AppendWithStyle(ContainerName, OldIndex->getName());
-  // E.g.: (auto container_i : container)
-  if (!declarationExists(IteratorName) || IteratorName == OldIndex->getName())
-return IteratorName;
-
-  IteratorName = AppendWithStyle(ContainerName, Elem);
-  // E.g.: (auto container_elem : container)
-  if (!declarationExists(IteratorName) || IteratorName == OldIndex->getName())
-return IteratorName;
-
-  // Someone defeated my naming scheme...
-  std::string GiveMeName;
-  switch (Style) {
-  case NS_CamelBack:
-GiveMeName = "giveMeName";
-break;
-  case NS_CamelCase:
-GiveMeName = "GiveMeName";
-break;
-  case NS_LowerCase:
-GiveMeName = "give_me_name_";
-break;
-  case NS_UpperCase:
-GiveMeName = "GIVE_ME_NAME_";
-  }
-  int Attempt = 0;
-  do {
-IteratorName = GiveMeName + std::to_string(Attempt++);
-  } while (declarationExists(IteratorName) ||
-   IteratorName == OldIndex->getName());
-
-  return IteratorName;
+  return OldIndex->getName();
 }
 
 /// \brief Determines whether or not the the name \a Symbol conflicts with

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp?rev=252308&r1=252307&r2=252308&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp 
Fri Nov  6 09:03:14 2015
@@ -18,8 +18,8 @@ void f() {
 int K;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead 
[modernize-loop-convert]
-  // CHECK-FIXES: for (int Elem : Arr)
-  // CHECK-FIXES-NEXT: Sum += Elem;
+  // CHECK-FIXES: for (int I : Arr)
+  // CHECK-FIXES-NEXT: Sum += I;
   // CHECK-FIXES-NEXT: int K;
 
   for (int I = 0; I < N; ++I) {
@@ -27,66 +27,66 @@ void f() {
 Sum += Arr[I] + 2;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : Arr)
-  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", Elem);
-  // CHECK-FIXES-NEXT: Sum += Elem + 2;
+  // CHECK-FIXES: for (int I : Arr)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I);
+  // CHECK-FIXES-NEXT: Sum += I + 2;
 
   for (int I = 0; I < N; ++I) {
 int X = Arr[I];
 int Y = Arr[I] + 2;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : Arr)
-  // CHECK-FIXES-NEXT: int X = Elem;
-  // CHECK-FIXES-NEXT: int Y = Elem + 2;
+  // CHECK-FIXES: for (int I : Arr)
+  // CHECK-FIXES-NEXT: int X = I;
+  // CHECK-FIXES-NEXT: int Y = I + 2;
 
   for (int I = 0; I < N; ++I) {
 int X = N;
 X = Arr[I];
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int Elem : Arr)
+  // CHECK-FIXES: for (int I : Arr)
   // CHECK-FIXES-NEXT: int X = N;
-  // CHECK-FIXES-NEXT: X = Elem;
+  // CHECK-FIXES-NEXT: X = I;
 
   for (int I = 0; 

[PATCH] D14440: [tsan] Add Clang frontend support for TSan on OS X

2015-11-06 Thread Kuba Brecka via cfe-commits
kubabrecka created this revision.
kubabrecka added reviewers: dvyukov, samsonov, kcc, glider.
kubabrecka added subscribers: cfe-commits, zaks.anna, ismailp, jasonk, 
jevinskie.

We're currently in process of porting TSan to OS X, and quite a few of the 
initial support in the runtime library has already landed in trunk.  This patch 
actually enables "-fsanitize=thread" in the frontend.

http://reviews.llvm.org/D14440

Files:
  lib/Driver/ToolChains.cpp

Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -389,6 +389,8 @@
 AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
   if (Sanitize.needsUbsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
+  if (Sanitize.needsTsanRt())
+AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
 
   // Otherwise link libSystem, then the dynamic runtime library, and finally 
any
   // target specific static runtime library.
@@ -1199,6 +1201,7 @@
 if (!isMacosxVersionLT(10, 9))
   Res |= SanitizerKind::Vptr;
 Res |= SanitizerKind::SafeStack;
+Res |= SanitizerKind::Thread;
   }
   return Res;
 }


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -389,6 +389,8 @@
 AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
   if (Sanitize.needsUbsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
+  if (Sanitize.needsTsanRt())
+AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
 
   // Otherwise link libSystem, then the dynamic runtime library, and finally any
   // target specific static runtime library.
@@ -1199,6 +1201,7 @@
 if (!isMacosxVersionLT(10, 9))
   Res |= SanitizerKind::Vptr;
 Res |= SanitizerKind::SafeStack;
+Res |= SanitizerKind::Thread;
   }
   return Res;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13048: Fix for merging decls in pragma weak

2015-11-06 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


http://reviews.llvm.org/D13048



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


Re: [PATCH] D14438: Use the old index identifier by default, instead of 'elem'.

2015-11-06 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D14438



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


r252307 - Fix __builtin_signbit for ppcf128 type

2015-11-06 Thread Petar Jovanovic via cfe-commits
Author: petarj
Date: Fri Nov  6 08:52:46 2015
New Revision: 252307

URL: http://llvm.org/viewvc/llvm-project?rev=252307&view=rev
Log:
Fix __builtin_signbit for ppcf128 type

Function__builtin_signbit returns wrong value for type ppcf128 on big endian
machines. This patch fixes how value is generated in that case.

Patch by Aleksandar Beserminji.

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


Added:
cfe/trunk/test/Analysis/builtin_signbit.cpp
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=252307&r1=252306&r2=252307&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Nov  6 08:52:46 2015
@@ -238,10 +238,20 @@ static Value *EmitSignBit(CodeGenFunctio
   llvm::Type *IntTy = llvm::IntegerType::get(C, Width);
   V = CGF.Builder.CreateBitCast(V, IntTy);
   if (Ty->isPPC_FP128Ty()) {
-// The higher-order double comes first, and so we need to truncate the
-// pair to extract the overall sign. The order of the pair is the same
-// in both little- and big-Endian modes.
+// We want the sign bit of the higher-order double. The bitcast we just
+// did works as if the double-double was stored to memory and then
+// read as an i128. The "store" will put the higher-order double in the
+// lower address in both little- and big-Endian modes, but the "load"
+// will treat those bits as a different part of the i128: the low bits in
+// little-Endian, the high bits in big-Endian. Therefore, on big-Endian
+// we need to shift the high bits down to the low before truncating.
 Width >>= 1;
+if (CGF.getTarget().isBigEndian()) {
+  Value *ShiftCst = llvm::ConstantInt::get(IntTy, Width);
+  V = CGF.Builder.CreateLShr(V, ShiftCst);
+} 
+// We are truncating value in order to extract the higher-order 
+// double, which we will be using to extract the sign from.
 IntTy = llvm::IntegerType::get(C, Width);
 V = CGF.Builder.CreateTrunc(V, IntTy);
   }

Added: cfe/trunk/test/Analysis/builtin_signbit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/builtin_signbit.cpp?rev=252307&view=auto
==
--- cfe/trunk/test/Analysis/builtin_signbit.cpp (added)
+++ cfe/trunk/test/Analysis/builtin_signbit.cpp Fri Nov  6 08:52:46 2015
@@ -0,0 +1,43 @@
+// RUN: %clang -target powerpc-linux-gnu -emit-llvm -S -O0 %s -o - | 
FileCheck %s --check-prefix=CHECK-BE --check-prefix=CHECK
+// RUN: %clang -target powerpc64-linux-gnu   -emit-llvm -S -O0 %s -o - | 
FileCheck %s --check-prefix=CHECK-BE --check-prefix=CHECK
+// RUN: %clang -target powerpc64le-linux-gnu -emit-llvm -S -O0 %s -o - | 
FileCheck %s --check-prefix=CHECK-LE --check-prefix=CHECK
+
+bool b;
+double d = -1.0;
+long double ld = -1.0L;
+void test_signbit()
+{
+  b = __builtin_signbit(1.0L);
+  // CHECK: i128
+  // CHECK-LE-NOT: lshr
+  // CHECK-BE: lshr
+  // CHECK: bitcast
+  // CHECK: ppc_fp128
+
+  b = __builtin_signbit(ld);
+  // CHECK: bitcast
+  // CHECK: ppc_fp128
+  // CHECK-LE-NOT: lshr
+  // CHECK-BE: lshr
+
+  b = __builtin_signbitf(1.0);
+  // CHECK: store i8 0
+
+  b = __builtin_signbitf(d);
+  // CHECK: bitcast
+  // CHECK-LE-NOT: lshr
+  // CHECK-BE-NOT: lshr
+
+  b = __builtin_signbitl(1.0L);
+  // CHECK: i128
+  // CHECK-LE-NOT: lshr
+  // CHECK-BE: lshr
+  // CHECK: bitcast
+  // CHECK: ppc_fp128
+
+  b = __builtin_signbitl(ld);
+  // CHECK: bitcast
+  // CHECK: ppc_fp128
+  // CHECK-LE-NOT: lshr
+  // CHECK-BE: lshr
+}


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


Re: [PATCH] D14149: __builtin_signbit fix for ppcf128 type

2015-11-06 Thread Petar Jovanovic via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL252307: Fix __builtin_signbit for ppcf128 type (authored by 
petarj).

Changed prior to commit:
  http://reviews.llvm.org/D14149?vs=39513&id=39523#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14149

Files:
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/test/Analysis/builtin_signbit.cpp

Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -238,10 +238,20 @@
   llvm::Type *IntTy = llvm::IntegerType::get(C, Width);
   V = CGF.Builder.CreateBitCast(V, IntTy);
   if (Ty->isPPC_FP128Ty()) {
-// The higher-order double comes first, and so we need to truncate the
-// pair to extract the overall sign. The order of the pair is the same
-// in both little- and big-Endian modes.
+// We want the sign bit of the higher-order double. The bitcast we just
+// did works as if the double-double was stored to memory and then
+// read as an i128. The "store" will put the higher-order double in the
+// lower address in both little- and big-Endian modes, but the "load"
+// will treat those bits as a different part of the i128: the low bits in
+// little-Endian, the high bits in big-Endian. Therefore, on big-Endian
+// we need to shift the high bits down to the low before truncating.
 Width >>= 1;
+if (CGF.getTarget().isBigEndian()) {
+  Value *ShiftCst = llvm::ConstantInt::get(IntTy, Width);
+  V = CGF.Builder.CreateLShr(V, ShiftCst);
+} 
+// We are truncating value in order to extract the higher-order 
+// double, which we will be using to extract the sign from.
 IntTy = llvm::IntegerType::get(C, Width);
 V = CGF.Builder.CreateTrunc(V, IntTy);
   }
Index: cfe/trunk/test/Analysis/builtin_signbit.cpp
===
--- cfe/trunk/test/Analysis/builtin_signbit.cpp
+++ cfe/trunk/test/Analysis/builtin_signbit.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang -target powerpc-linux-gnu -emit-llvm -S -O0 %s -o - | 
FileCheck %s --check-prefix=CHECK-BE --check-prefix=CHECK
+// RUN: %clang -target powerpc64-linux-gnu   -emit-llvm -S -O0 %s -o - | 
FileCheck %s --check-prefix=CHECK-BE --check-prefix=CHECK
+// RUN: %clang -target powerpc64le-linux-gnu -emit-llvm -S -O0 %s -o - | 
FileCheck %s --check-prefix=CHECK-LE --check-prefix=CHECK
+
+bool b;
+double d = -1.0;
+long double ld = -1.0L;
+void test_signbit()
+{
+  b = __builtin_signbit(1.0L);
+  // CHECK: i128
+  // CHECK-LE-NOT: lshr
+  // CHECK-BE: lshr
+  // CHECK: bitcast
+  // CHECK: ppc_fp128
+
+  b = __builtin_signbit(ld);
+  // CHECK: bitcast
+  // CHECK: ppc_fp128
+  // CHECK-LE-NOT: lshr
+  // CHECK-BE: lshr
+
+  b = __builtin_signbitf(1.0);
+  // CHECK: store i8 0
+
+  b = __builtin_signbitf(d);
+  // CHECK: bitcast
+  // CHECK-LE-NOT: lshr
+  // CHECK-BE-NOT: lshr
+
+  b = __builtin_signbitl(1.0L);
+  // CHECK: i128
+  // CHECK-LE-NOT: lshr
+  // CHECK-BE: lshr
+  // CHECK: bitcast
+  // CHECK: ppc_fp128
+
+  b = __builtin_signbitl(ld);
+  // CHECK: bitcast
+  // CHECK: ppc_fp128
+  // CHECK-LE-NOT: lshr
+  // CHECK-BE: lshr
+}


Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -238,10 +238,20 @@
   llvm::Type *IntTy = llvm::IntegerType::get(C, Width);
   V = CGF.Builder.CreateBitCast(V, IntTy);
   if (Ty->isPPC_FP128Ty()) {
-// The higher-order double comes first, and so we need to truncate the
-// pair to extract the overall sign. The order of the pair is the same
-// in both little- and big-Endian modes.
+// We want the sign bit of the higher-order double. The bitcast we just
+// did works as if the double-double was stored to memory and then
+// read as an i128. The "store" will put the higher-order double in the
+// lower address in both little- and big-Endian modes, but the "load"
+// will treat those bits as a different part of the i128: the low bits in
+// little-Endian, the high bits in big-Endian. Therefore, on big-Endian
+// we need to shift the high bits down to the low before truncating.
 Width >>= 1;
+if (CGF.getTarget().isBigEndian()) {
+  Value *ShiftCst = llvm::ConstantInt::get(IntTy, Width);
+  V = CGF.Builder.CreateLShr(V, ShiftCst);
+} 
+// We are truncating value in order to extract the higher-order 
+// double, which we will be using to extract the sign from.
 IntTy = llvm::IntegerType::get(C, Width);
 V = CGF.Builder.CreateTrunc(V, IntTy);
   }
Index: cfe/trunk/test/Analysis/builtin_signbit.cpp
===
--- cfe/trunk/test/Analysis/builtin_signbit.cpp
+++ cfe/trunk/test/Analysis/builtin_signbit.cpp
@@ -0,0 +1,43 @@
+// RU

[PATCH] D14438: Use the old index identifier by default, instead of 'elem'.

2015-11-06 Thread Angel Garcia via cfe-commits
angelgarcia created this revision.
angelgarcia added a reviewer: klimek.
angelgarcia added a subscriber: cfe-commits.

Use the old index name in the cases where the check would come up with an 
invented name.

http://reviews.llvm.org/D14438

Files:
  clang-tidy/modernize/LoopConvertUtils.cpp
  test/clang-tidy/modernize-loop-convert-basic.cpp
  test/clang-tidy/modernize-loop-convert-camelback.cpp
  test/clang-tidy/modernize-loop-convert-const.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp
  test/clang-tidy/modernize-loop-convert-lowercase.cpp
  test/clang-tidy/modernize-loop-convert-uppercase.cpp

Index: test/clang-tidy/modernize-loop-convert-uppercase.cpp
===
--- test/clang-tidy/modernize-loop-convert-uppercase.cpp
+++ test/clang-tidy/modernize-loop-convert-uppercase.cpp
@@ -14,8 +14,8 @@
 printf("%d\n", ARR[I]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead [modernize-loop-convert]
-  // CHECK-FIXES: for (int ELEM : ARR)
-  // CHECK-FIXES-NEXT: printf("%d\n", ELEM);
+  // CHECK-FIXES: for (int I : ARR)
+  // CHECK-FIXES-NEXT: printf("%d\n", I);
 
   for (int I = 0; I < N; ++I) {
 printf("%d\n", NUMS[I]);
@@ -36,50 +36,6 @@
 printf("%d\n", NUMS[I] + NUM);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int ELEM : NUMS)
-  // CHECK-FIXES-NEXT: printf("%d\n", ELEM + NUM);
-
-  int ELEM = 0;
-  for (int I = 0; I < N; ++I) {
-printf("%d\n", NUMS[I] + NUM + ELEM);
-  }
-  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int NUMS_I : NUMS)
-  // CHECK-FIXES-NEXT: printf("%d\n", NUMS_I + NUM + ELEM);
-
-  int NUMS_I = 0;
-  for (int I = 0; I < N; ++I) {
-printf("%d\n", NUMS[I] + NUM + ELEM + NUMS_I);
-  }
-  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int NUMS_ELEM : NUMS)
-  // CHECK-FIXES-NEXT: printf("%d\n", NUMS_ELEM + NUM + ELEM + NUMS_I);
-
-  int NUMS_ELEM = 0;
-  for (int I = 0; I < N; ++I) {
-printf("%d\n", NUMS[I] + NUM + ELEM + NUMS_I + NUMS_ELEM);
-  }
-  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int GIVE_ME_NAME_0 : NUMS)
-  // CHECK-FIXES-NEXT: printf("%d\n", GIVE_ME_NAME_0 + NUM + ELEM + NUMS_I + NUMS_ELEM);
-
-  int GIVE_ME_NAME_0 = 0;
-  for (int I = 0; I < N; ++I) {
-printf("%d\n", NUMS[I] + NUM + ELEM + NUMS_I + NUMS_ELEM + GIVE_ME_NAME_0);
-  }
-  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int GIVE_ME_NAME_1 : NUMS)
-  // CHECK-FIXES-NEXT: printf("%d\n", GIVE_ME_NAME_1 + NUM + ELEM + NUMS_I + NUMS_ELEM + GIVE_ME_NAME_0);
-
-  int NUMS_J = 0;
-  for (int I = 0; I < N; ++I) {
-for (int J = 0; J < N; ++J) {
-  printf("%d\n", NUMS[I] + NUMS[J] + NUM + ELEM + NUMS_I + NUMS_J + NUMS_ELEM);
-}
-  }
-  // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
-  // CHECK-MESSAGES: :[[@LINE-5]]:5: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int GIVE_ME_NAME_0 : NUMS)
-  // CHECK-FIXES: for (int GIVE_ME_NAME_1 : NUMS)
-  // CHECK-FIXES-NEXT: printf("%d\n", GIVE_ME_NAME_0 + GIVE_ME_NAME_1 + NUM + ELEM + NUMS_I + NUMS_J + NUMS_ELEM);
+  // CHECK-FIXES: for (int I : NUMS)
+  // CHECK-FIXES-NEXT: printf("%d\n", I + NUM);
 }
Index: test/clang-tidy/modernize-loop-convert-lowercase.cpp
===
--- test/clang-tidy/modernize-loop-convert-lowercase.cpp
+++ test/clang-tidy/modernize-loop-convert-lowercase.cpp
@@ -14,8 +14,8 @@
 printf("%d\n", arr[i]);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead [modernize-loop-convert]
-  // CHECK-FIXES: for (int elem : arr)
-  // CHECK-FIXES-NEXT: printf("%d\n", elem);
+  // CHECK-FIXES: for (int i : arr)
+  // CHECK-FIXES-NEXT: printf("%d\n", i);
 
   for (int i = 0; i < n; ++i) {
 printf("%d\n", nums[i]);
@@ -36,50 +36,6 @@
 printf("%d\n", nums[i] + num);
   }
   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int elem : nums)
-  // CHECK-FIXES-NEXT: printf("%d\n", elem + num);
-
-  int elem = 0;
-  for (int i = 0; i < n; ++i) {
-printf("%d\n", nums[i] + num + elem);
-  }
-  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int nums_i : nums)
-  // CHECK-FIXES-NEXT: printf("%d\n", nums_i + num + elem);
-
-  int nums_i = 0;
-  for (int i = 0; i < n; ++i) {
-printf("%d\n", nums[i] + num + elem + nums_i);
-  }
-  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int nums_elem : nums)
-  // CHECK-FIXES-NEXT: printf("%d\n", nums_elem + num + elem + nums_i);
-
-  int nums_elem = 0;
-  for (int i = 0; i < n; ++i) {
-printf("%d\n", nums[i] +

Re: [PATCH] D13330: Implement __attribute__((unique_instantiation))

2015-11-06 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2456
@@ -2450,1 +2455,3 @@
+def err_unique_instantiation_not_previous : Error<
+  "'unique_instantiation' attribute must be specified for all declarations and 
definitions of this explicit template instantiation">;
 

> They are checking for two different conditions in the spec. One requires that 
> all explicit template instantiations with this attribute have a declaration, 
> the other that every declaration/definition has the attribute.

Okay, I see now what this diagnostic is attempting to convey. I think it should 
read:
```
def err_unique_instantiation_no_declaration : Error<
  "'unique_instantiation' attribute on an explicit instantiation requires a 
previous explicit instantiation declaration">;
```


Comment at: test/SemaCXX/unique-instantiations.cpp:5
@@ +4,3 @@
+struct foo1 {};
+template struct __attribute__((unique_instantiation)) foo1; // 
expected-error{{requires a previous declaration}}
+

Please spell the entire diagnostic out in expected-error (applies to entire 
file).


Comment at: test/SemaCXX/unique-instantiations.cpp:23
@@ +22,2 @@
+extern template struct __attribute__((unique_instantiation)) foo5; // 
expected-note{{previous explicit instantiation is here}}
+template struct foo5;  // 
expected-error{{must be specified for all declarations}}

Missing tests for correct usage of the attribute. Missing tests of the 
attribute diagnosing when given arguments.


Repository:
  rL LLVM

http://reviews.llvm.org/D13330



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


Re: [PATCH] D14286: ASTImporter: expressions, pt.1

2015-11-06 Thread Aleksei Sidorin via cfe-commits
a.sidorin updated this revision to Diff 39517.
a.sidorin marked an inline comment as done.
a.sidorin added a comment.

Some issues pointed on review were fixed.


Repository:
  rL LLVM

http://reviews.llvm.org/D14286

Files:
  lib/AST/ASTImporter.cpp

Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -29,7 +29,16 @@
   public DeclVisitor,
   public StmtVisitor {
 ASTImporter &Importer;
-
+
+template
+void ImportMultipleItems(IIter Ibegin, IIter Iend, OIter Obegin) {
+  ASTImporter &ImporterRef = Importer;
+  std::transform(Ibegin, Iend, Obegin,
+[&ImporterRef](ItemT I) -> ItemT {
+  return ImporterRef.Import(I);
+});
+}
+
   public:
 explicit ASTNodeImporter(ASTImporter &Importer) : Importer(Importer) { }
 
@@ -86,6 +95,10 @@
 void ImportDeclarationNameLoc(const DeclarationNameInfo &From,
   DeclarationNameInfo& To);
 void ImportDeclContext(DeclContext *FromDC, bool ForceImport = false);
+
+typedef DesignatedInitExpr::Designator Designator;
+Designator ImportDesignator(const Designator &D);
+
 
 /// \brief What we should import from the definition.
 enum ImportDefinitionKind { 
@@ -174,6 +187,7 @@
 DeclGroupRef ImportDeclGroup(DeclGroupRef DG);
 
 Stmt *VisitStmt(Stmt *S);
+Stmt *VisitGCCAsmStmt(GCCAsmStmt *S);
 Stmt *VisitDeclStmt(DeclStmt *S);
 Stmt *VisitNullStmt(NullStmt *S);
 Stmt *VisitCompoundStmt(CompoundStmt *S);
@@ -191,7 +205,6 @@
 Stmt *VisitContinueStmt(ContinueStmt *S);
 Stmt *VisitBreakStmt(BreakStmt *S);
 Stmt *VisitReturnStmt(ReturnStmt *S);
-// FIXME: GCCAsmStmt
 // FIXME: MSAsmStmt
 // FIXME: SEHExceptStmt
 // FIXME: SEHFinallyStmt
@@ -212,13 +225,29 @@
 
 // Importing expressions
 Expr *VisitExpr(Expr *E);
+Expr *VisitVAArgExpr(VAArgExpr *E);
+Expr *VisitGNUNullExpr(GNUNullExpr *E);
+Expr *VisitPredefinedExpr(PredefinedExpr *E);
 Expr *VisitDeclRefExpr(DeclRefExpr *E);
+Expr *VisitInitListExpr(InitListExpr *ILE);
+Expr *VisitDesignatedInitExpr(DesignatedInitExpr *E);
+Expr *VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E);
+Expr *VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E);
 Expr *VisitIntegerLiteral(IntegerLiteral *E);
+Expr *VisitFloatingLiteral(FloatingLiteral *E);
 Expr *VisitCharacterLiteral(CharacterLiteral *E);
+Expr *VisitStringLiteral(StringLiteral *E);
+Expr *VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
+Expr *VisitAtomicExpr(AtomicExpr *E);
+Expr *VisitAddrLabelExpr(AddrLabelExpr *E);
 Expr *VisitParenExpr(ParenExpr *E);
+Expr *VisitParenListExpr(ParenListExpr *E);
+Expr *VisitStmtExpr(StmtExpr *E);
 Expr *VisitUnaryOperator(UnaryOperator *E);
 Expr *VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E);
 Expr *VisitBinaryOperator(BinaryOperator *E);
+Expr *VisitConditionalOperator(ConditionalOperator *E);
+Expr *VisitBinaryConditionalOperator(BinaryConditionalOperator *E);
 Expr *VisitCompoundAssignOperator(CompoundAssignOperator *E);
 Expr *VisitImplicitCastExpr(ImplicitCastExpr *E);
 Expr *VisitCStyleCastExpr(CStyleCastExpr *E);
@@ -229,6 +258,28 @@
 }
 using namespace clang;
 
+//--
+// Utilities
+//--
+
+namespace {
+
+template
+static bool containsNullPtr(IIter Ibegin, IIter Iend) {
+  return std::find(Ibegin, Iend, nullptr) == Iend;
+}
+
+template
+static bool checkPossibleNull(IIter Ibegin, IIter Iend, OIter Obegin) {
+  for (; Ibegin != Iend; Ibegin++, Obegin++)
+if (*Obegin == nullptr && Ibegin != nullptr)
+  return false;
+  return true;
+}
+
+} // end anonymous namespace
+
+
 //
 // Structural Equivalence
 //
@@ -4591,7 +4642,84 @@
  << S->getStmtClassName();
return nullptr;
  }
- 
+
+
+Stmt *ASTNodeImporter::VisitGCCAsmStmt(GCCAsmStmt *S) {
+  SmallVector Names;
+  for (unsigned i = 0, e = S->getNumOutputs(); i != e; i++) {
+IdentifierInfo *ToII = Importer.Import(S->getOutputIdentifier(i));
+if (!ToII)
+  return nullptr;
+Names.push_back(ToII);
+  }
+  for (unsigned i = 0, e = S->getNumInputs(); i != e; i++) {
+IdentifierInfo *ToII = Importer.Import(S->getInputIdentifier(i));
+if (!ToII)
+  return nullptr;
+Names.push_back(ToII);
+  }
+
+  SmallVector Clobbers;
+  for (unsigned i = 0, e = S->getNumClobbers(); i != e; i++) {
+StringLiteral *Clobber = cast_or_null(
+  Importer.Import(S->getClobberStringLiteral(i)));
+if (!Clobber)
+

Re: [PATCH] D14286: ASTImporter: expressions, pt.1

2015-11-06 Thread Aleksei Sidorin via cfe-commits
a.sidorin marked 7 inline comments as done.
a.sidorin added a comment.

Thank you for your comments. I leaved some replies and will update revision.
Something about lacking tests.

1. We cannot check if expression import is correct until we implement 
FunctionDecl body import. I was going to upstream Decl-related parts later but 
maybe it is better to include this small case in the first patch. What do you 
think?
2. What is the best way to test import of statements? Currently I have no idea 
how to do this (except of ast-dump). Any suggestions are welcome.



Comment at: lib/AST/ASTImporter.cpp:35
@@ +34,3 @@
+void ImportMultipleItems(IIter Ibegin, IIter Iend, OIter Obegin) {
+  ASTImporter &_Importer = Importer;
+  std::transform(Ibegin, Iend, Obegin,

sepavloff wrote:
> A name started with underscore is a reserved identifier (see C++ standard, 
> [global.names]), so it is better to use something more neutral, like 
> //TheImporter// or //Imp// or something else.
Ouch. I was just trying to unify this with the code already existing in 
ASTImporter. I'll rename this.
// TODO: refactor std::transform usage in ASTImporter.


Comment at: lib/AST/ASTImporter.cpp:48
@@ +47,3 @@
+template
+bool checkPossibleNull(IIter Ibegin, IIter Iend, OIter Obegin) {
+  for (; Ibegin != Iend; Ibegin++, Obegin++)

sepavloff wrote:
> This function is used in one place only, maybe inline its body in that place?
I'll use it in later patches so I'd prefer to keep it.


Comment at: lib/AST/ASTImporter.cpp:4655
@@ +4654,3 @@
+  for (unsigned i = 0, e = S->getNumClobbers(); i != e; i++) {
+StringLiteral *Clobber = cast_or_null(
+  Importer.Import(S->getClobberStringLiteral(i)));

sepavloff wrote:
> Again, clobber cannot be null, maybe `cast` instead of `cast_or_null`?
This guard is here because the return result of import may be null. This 
cast_or_null (and some others) handles such cases.


Repository:
  rL LLVM

http://reviews.llvm.org/D14286



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


Re: [PATCH] D13383: [clang] Add flag to DeclContext to distinguish between qualified and unqualified name lookups

2015-11-06 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

With moving the definition of the Deinitializer class closer to its use (it 
should be defined within the function itself given the limited use), LGTM.



Comment at: clang/lib/Sema/SemaLookup.cpp:211
@@ +210,3 @@
+  public:
+Deinitializer(const std::function& d): Deinit(d) {}
+~Deinitializer() { Deinit(); }

Formatting (the & goes with d).


http://reviews.llvm.org/D13383



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


[clang-tools-extra] r252303 - Avoid naming conflicts with the old index in modernize-loop-convert.

2015-11-06 Thread Angel Garcia Gomez via cfe-commits
Author: angelgarcia
Date: Fri Nov  6 08:04:12 2015
New Revision: 252303

URL: http://llvm.org/viewvc/llvm-project?rev=252303&view=rev
Log:
Avoid naming conflicts with the old index in modernize-loop-convert.

Summary: The old index declaration is going to be removed anyway, so we can 
reuse its name if it is the best candidate for the new index.

Reviewers: klimek

Subscribers: cfe-commits, alexfh

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp?rev=252303&r1=252302&r2=252303&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp Fri Nov  
6 08:04:12 2015
@@ -820,14 +820,14 @@ std::string VariableNamer::createIndexNa
   if (Len > 1 && ContainerName.endswith(Style == NS_UpperCase ? "S" : "s")) {
 IteratorName = ContainerName.substr(0, Len - 1);
 // E.g.: (auto thing : things)
-if (!declarationExists(IteratorName))
+if (!declarationExists(IteratorName) || IteratorName == 
OldIndex->getName())
   return IteratorName;
   }
 
   if (Len > 2 && ContainerName.endswith(Style == NS_UpperCase ? "S_" : "s_")) {
 IteratorName = ContainerName.substr(0, Len - 2);
 // E.g.: (auto thing : things_)
-if (!declarationExists(IteratorName))
+if (!declarationExists(IteratorName) || IteratorName == 
OldIndex->getName())
   return IteratorName;
   }
 
@@ -849,12 +849,12 @@ std::string VariableNamer::createIndexNa
 
   IteratorName = AppendWithStyle(ContainerName, OldIndex->getName());
   // E.g.: (auto container_i : container)
-  if (!declarationExists(IteratorName))
+  if (!declarationExists(IteratorName) || IteratorName == OldIndex->getName())
 return IteratorName;
 
   IteratorName = AppendWithStyle(ContainerName, Elem);
   // E.g.: (auto container_elem : container)
-  if (!declarationExists(IteratorName))
+  if (!declarationExists(IteratorName) || IteratorName == OldIndex->getName())
 return IteratorName;
 
   // Someone defeated my naming scheme...
@@ -875,7 +875,8 @@ std::string VariableNamer::createIndexNa
   int Attempt = 0;
   do {
 IteratorName = GiveMeName + std::to_string(Attempt++);
-  } while (declarationExists(IteratorName));
+  } while (declarationExists(IteratorName) ||
+   IteratorName == OldIndex->getName());
 
   return IteratorName;
 }

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp?rev=252303&r1=252302&r2=252303&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp 
Fri Nov  6 08:04:12 2015
@@ -325,6 +325,23 @@ void sameNames() {
   // CHECK-FIXES-NEXT: (void)NumsI;
 }
 
+void oldIndexConflict() {
+  for (int Num = 0; Num < N; ++Num) {
+printf("Num: %d\n", Nums[Num]);
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int Num : Nums)
+  // CHECK-FIXES-NEXT: printf("Num: %d\n", Num);
+
+  S Things;
+  for (S::iterator Thing = Things.begin(), End = Things.end(); Thing != End; 
++Thing) {
+printf("Thing: %d %d\n", Thing->X, (*Thing).X);
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (auto & Thing : Things)
+  // CHECK-FIXES-NEXT: printf("Thing: %d %d\n", Thing.X, Thing.X);
+}
+
 void macroConflict() {
   S MAXs;
   for (S::iterator It = MAXs.begin(), E = MAXs.end(); It != E; ++It) {


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


Re: [PATCH] D14437: Avoid naming conflicts with the old index in modernize-loop-convert.

2015-11-06 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D14437



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


Re: [PATCH] D13925: Implement __attribute__((internal_linkage))

2015-11-06 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

LGTM, thank you!



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:4090
@@ +4089,3 @@
+  "'internal_linkage' attribute on a non-static local variable is ignored">,
+  InGroup;
+

Good catch!


Repository:
  rL LLVM

http://reviews.llvm.org/D13925



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


[PATCH] D14437: Avoid naming conflicts with the old index in modernize-loop-convert.

2015-11-06 Thread Angel Garcia via cfe-commits
angelgarcia created this revision.
angelgarcia added a reviewer: klimek.
angelgarcia added subscribers: alexfh, cfe-commits.

The old index declaration is going to be removed anyway, so we can reuse its 
name if it is the best candidate for the new index.

http://reviews.llvm.org/D14437

Files:
  clang-tidy/modernize/LoopConvertUtils.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp

Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -325,6 +325,23 @@
   // CHECK-FIXES-NEXT: (void)NumsI;
 }
 
+void oldIndexConflict() {
+  for (int Num = 0; Num < N; ++Num) {
+printf("Num: %d\n", Nums[Num]);
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int Num : Nums)
+  // CHECK-FIXES-NEXT: printf("Num: %d\n", Num);
+
+  S Things;
+  for (S::iterator Thing = Things.begin(), End = Things.end(); Thing != End; 
++Thing) {
+printf("Thing: %d %d\n", Thing->X, (*Thing).X);
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (auto & Thing : Things)
+  // CHECK-FIXES-NEXT: printf("Thing: %d %d\n", Thing.X, Thing.X);
+}
+
 void macroConflict() {
   S MAXs;
   for (S::iterator It = MAXs.begin(), E = MAXs.end(); It != E; ++It) {
Index: clang-tidy/modernize/LoopConvertUtils.cpp
===
--- clang-tidy/modernize/LoopConvertUtils.cpp
+++ clang-tidy/modernize/LoopConvertUtils.cpp
@@ -820,14 +820,14 @@
   if (Len > 1 && ContainerName.endswith(Style == NS_UpperCase ? "S" : "s")) {
 IteratorName = ContainerName.substr(0, Len - 1);
 // E.g.: (auto thing : things)
-if (!declarationExists(IteratorName))
+if (!declarationExists(IteratorName) || IteratorName == 
OldIndex->getName())
   return IteratorName;
   }
 
   if (Len > 2 && ContainerName.endswith(Style == NS_UpperCase ? "S_" : "s_")) {
 IteratorName = ContainerName.substr(0, Len - 2);
 // E.g.: (auto thing : things_)
-if (!declarationExists(IteratorName))
+if (!declarationExists(IteratorName) || IteratorName == 
OldIndex->getName())
   return IteratorName;
   }
 
@@ -849,12 +849,12 @@
 
   IteratorName = AppendWithStyle(ContainerName, OldIndex->getName());
   // E.g.: (auto container_i : container)
-  if (!declarationExists(IteratorName))
+  if (!declarationExists(IteratorName) || IteratorName == OldIndex->getName())
 return IteratorName;
 
   IteratorName = AppendWithStyle(ContainerName, Elem);
   // E.g.: (auto container_elem : container)
-  if (!declarationExists(IteratorName))
+  if (!declarationExists(IteratorName) || IteratorName == OldIndex->getName())
 return IteratorName;
 
   // Someone defeated my naming scheme...
@@ -875,7 +875,8 @@
   int Attempt = 0;
   do {
 IteratorName = GiveMeName + std::to_string(Attempt++);
-  } while (declarationExists(IteratorName));
+  } while (declarationExists(IteratorName) ||
+   IteratorName == OldIndex->getName());
 
   return IteratorName;
 }


Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -325,6 +325,23 @@
   // CHECK-FIXES-NEXT: (void)NumsI;
 }
 
+void oldIndexConflict() {
+  for (int Num = 0; Num < N; ++Num) {
+printf("Num: %d\n", Nums[Num]);
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int Num : Nums)
+  // CHECK-FIXES-NEXT: printf("Num: %d\n", Num);
+
+  S Things;
+  for (S::iterator Thing = Things.begin(), End = Things.end(); Thing != End; ++Thing) {
+printf("Thing: %d %d\n", Thing->X, (*Thing).X);
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (auto & Thing : Things)
+  // CHECK-FIXES-NEXT: printf("Thing: %d %d\n", Thing.X, Thing.X);
+}
+
 void macroConflict() {
   S MAXs;
   for (S::iterator It = MAXs.begin(), E = MAXs.end(); It != E; ++It) {
Index: clang-tidy/modernize/LoopConvertUtils.cpp
===
--- clang-tidy/modernize/LoopConvertUtils.cpp
+++ clang-tidy/modernize/LoopConvertUtils.cpp
@@ -820,14 +820,14 @@
   if (Len > 1 && ContainerName.endswith(Style == NS_UpperCase ? "S" : "s")) {
 IteratorName = ContainerName.substr(0, Len - 1);
 // E.g.: (auto thing : things)
-if (!declarationExists(IteratorName))
+if (!declarationExists(IteratorName) || IteratorName == OldIndex->getName())
   return IteratorName;
   }
 
   if (Len > 2 && ContainerName.endswith(Style == NS_UpperCase ? "S_" : "s_")) {
 IteratorName = ContainerName.substr(0, Len - 2);
 // E.g.: (auto thing : things_)
-if (!declarationExists(IteratorN

Re: [PATCH] D14149: __builtin_signbit fix for ppcf128 type

2015-11-06 Thread Aleksandar Beserminji via cfe-commits
abeserminji updated this revision to Diff 39513.
abeserminji marked 2 inline comments as done.
abeserminji added a comment.

Comment modified


Repository:
  rL LLVM

http://reviews.llvm.org/D14149

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/Analysis/builtin_signbit.cpp

Index: test/Analysis/builtin_signbit.cpp
===
--- test/Analysis/builtin_signbit.cpp
+++ test/Analysis/builtin_signbit.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang -target powerpc-linux-gnu -emit-llvm -S -O0 %s -o - | 
FileCheck %s --check-prefix=CHECK-BE --check-prefix=CHECK
+// RUN: %clang -target powerpc64-linux-gnu   -emit-llvm -S -O0 %s -o - | 
FileCheck %s --check-prefix=CHECK-BE --check-prefix=CHECK
+// RUN: %clang -target powerpc64le-linux-gnu -emit-llvm -S -O0 %s -o - | 
FileCheck %s --check-prefix=CHECK-LE --check-prefix=CHECK
+
+bool b;
+double d = -1.0;
+long double ld = -1.0L;
+void test_signbit()
+{
+  b = __builtin_signbit(1.0L);
+  // CHECK: i128
+  // CHECK-LE-NOT: lshr
+  // CHECK-BE: lshr
+  // CHECK: bitcast
+  // CHECK: ppc_fp128
+
+  b = __builtin_signbit(ld);
+  // CHECK: bitcast
+  // CHECK: ppc_fp128
+  // CHECK-LE-NOT: lshr
+  // CHECK-BE: lshr
+
+  b = __builtin_signbitf(1.0);
+  // CHECK: store i8 0
+
+  b = __builtin_signbitf(d);
+  // CHECK: bitcast
+  // CHECK-LE-NOT: lshr
+  // CHECK-BE-NOT: lshr
+
+  b = __builtin_signbitl(1.0L);
+  // CHECK: i128
+  // CHECK-LE-NOT: lshr
+  // CHECK-BE: lshr
+  // CHECK: bitcast
+  // CHECK: ppc_fp128
+
+  b = __builtin_signbitl(ld);
+  // CHECK: bitcast
+  // CHECK: ppc_fp128
+  // CHECK-LE-NOT: lshr
+  // CHECK-BE: lshr
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -238,10 +238,20 @@
   llvm::Type *IntTy = llvm::IntegerType::get(C, Width);
   V = CGF.Builder.CreateBitCast(V, IntTy);
   if (Ty->isPPC_FP128Ty()) {
-// The higher-order double comes first, and so we need to truncate the
-// pair to extract the overall sign. The order of the pair is the same
-// in both little- and big-Endian modes.
+// We want the sign bit of the higher-order double. The bitcast we just
+// did works as if the double-double was stored to memory and then
+// read as an i128. The "store" will put the higher-order double in the
+// lower address in both little- and big-Endian modes, but the "load"
+// will treat those bits as a different part of the i128: the low bits in
+// little-Endian, the high bits in big-Endian. Therefore, on big-Endian
+// we need to shift the high bits down to the low before truncating.
 Width >>= 1;
+if (CGF.getTarget().isBigEndian()) {
+  Value *ShiftCst = llvm::ConstantInt::get(IntTy, Width);
+  V = CGF.Builder.CreateLShr(V, ShiftCst);
+} 
+// We are truncating value in order to extract the higher-order 
+// double, which we will be using to extract the sign from.
 IntTy = llvm::IntegerType::get(C, Width);
 V = CGF.Builder.CreateTrunc(V, IntTy);
   }


Index: test/Analysis/builtin_signbit.cpp
===
--- test/Analysis/builtin_signbit.cpp
+++ test/Analysis/builtin_signbit.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang -target powerpc-linux-gnu -emit-llvm -S -O0 %s -o - | FileCheck %s --check-prefix=CHECK-BE --check-prefix=CHECK
+// RUN: %clang -target powerpc64-linux-gnu   -emit-llvm -S -O0 %s -o - | FileCheck %s --check-prefix=CHECK-BE --check-prefix=CHECK
+// RUN: %clang -target powerpc64le-linux-gnu -emit-llvm -S -O0 %s -o - | FileCheck %s --check-prefix=CHECK-LE --check-prefix=CHECK
+
+bool b;
+double d = -1.0;
+long double ld = -1.0L;
+void test_signbit()
+{
+  b = __builtin_signbit(1.0L);
+  // CHECK: i128
+  // CHECK-LE-NOT: lshr
+  // CHECK-BE: lshr
+  // CHECK: bitcast
+  // CHECK: ppc_fp128
+
+  b = __builtin_signbit(ld);
+  // CHECK: bitcast
+  // CHECK: ppc_fp128
+  // CHECK-LE-NOT: lshr
+  // CHECK-BE: lshr
+
+  b = __builtin_signbitf(1.0);
+  // CHECK: store i8 0
+
+  b = __builtin_signbitf(d);
+  // CHECK: bitcast
+  // CHECK-LE-NOT: lshr
+  // CHECK-BE-NOT: lshr
+
+  b = __builtin_signbitl(1.0L);
+  // CHECK: i128
+  // CHECK-LE-NOT: lshr
+  // CHECK-BE: lshr
+  // CHECK: bitcast
+  // CHECK: ppc_fp128
+
+  b = __builtin_signbitl(ld);
+  // CHECK: bitcast
+  // CHECK: ppc_fp128
+  // CHECK-LE-NOT: lshr
+  // CHECK-BE: lshr
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -238,10 +238,20 @@
   llvm::Type *IntTy = llvm::IntegerType::get(C, Width);
   V = CGF.Builder.CreateBitCast(V, IntTy);
   if (Ty->isPPC_FP128Ty()) {
-// The higher-order double comes first, and so we need to truncate the
-// pair to extract the overall sign. The order of the pair is the same
-// in both little- and big-Endian modes.
+// We want the si

Re: [PATCH] D13673: Add initial support for the MUSL C library.

2015-11-06 Thread Vasileios Kalintiris via cfe-commits
vkalintiris added a comment.

Ping.


http://reviews.llvm.org/D13673



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


Re: [Diffusion] rL251335: MismatchingNewDeleteDetector uses incorrect field, and finds no initializer

2015-11-06 Thread Ismail Pazarbasi via cfe-commits
ismailp added a subscriber: ismailp.
ismailp added a comment.

Thanks!


Users:
  ismailp (Author)
  rsmith (Auditor)
  3.7-release (Auditor)
  cfe-commits (Auditor)
  tstellarAMD (Auditor)

http://reviews.llvm.org/rL251335



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


Re: [Diffusion] rL251335: MismatchingNewDeleteDetector uses incorrect field, and finds no initializer

2015-11-06 Thread Ismail Pazarbasi via cfe-commits
Thanks!

On Fri, Nov 6, 2015 at 12:44 PM, Tom Stellard  wrote:
> tstellarAMD accepted this commit.
> tstellarAMD added a comment.
>
> r252290
>
>
> Users:
>   ismailp (Author)
>   rsmith (Auditor)
>   3.7-release (Auditor)
>   cfe-commits (Auditor)
>   tstellarAMD (Auditor)
>
> http://reviews.llvm.org/rL251335
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [Diffusion] rL250657: Support linking against OpenMP runtime on FreeBSD.

2015-11-06 Thread Tom Stellard via cfe-commits
tstellarAMD accepted this commit.
tstellarAMD added a comment.

r252289


Users:
  dim (Author)
  3.7-release (Auditor)
  cfe-commits (Auditor)
  tstellarAMD (Auditor)
  joerg (Auditor)
  rsmith (Auditor)

http://reviews.llvm.org/rL250657



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


Re: [Diffusion] rL251335: MismatchingNewDeleteDetector uses incorrect field, and finds no initializer

2015-11-06 Thread Tom Stellard via cfe-commits
tstellarAMD accepted this commit.
tstellarAMD added a comment.

r252290


Users:
  ismailp (Author)
  rsmith (Auditor)
  3.7-release (Auditor)
  cfe-commits (Auditor)
  tstellarAMD (Auditor)

http://reviews.llvm.org/rL251335



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


Re: [Diffusion] rL248426: Support linking against OpenMP runtime on NetBSD.

2015-11-06 Thread Tom Stellard via cfe-commits
tstellarAMD accepted this commit.
tstellarAMD added a comment.

r252288


Users:
  joerg (Author, Auditor)
  3.7-release (Auditor)
  cfe-commits (Auditor)
  tstellarAMD (Auditor)
  rsmith (Auditor)

http://reviews.llvm.org/rL248426



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


Re: [Diffusion] rL248424: Push OpenMP linker flags after linker input on Darwin. Don't add any

2015-11-06 Thread Tom Stellard via cfe-commits
tstellarAMD accepted this commit.
tstellarAMD added a comment.

r252287


Users:
  joerg (Author, Auditor)
  3.7-release (Auditor)
  cfe-commits (Auditor)
  tstellarAMD (Auditor)
  rsmith (Auditor)

http://reviews.llvm.org/rL248424



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


  1   2   >