[PATCH] D21515: Update clang for D21514. NFC

2016-06-19 Thread Amaury SECHET via cfe-commits
deadalnix created this revision.
deadalnix added reviewers: ahatanak, bkramer, whitequark, mehdi_amini, void.
deadalnix added a subscriber: cfe-commits.

As per title.

http://reviews.llvm.org/D21515

Files:
  lib/CodeGen/CGExpr.cpp

Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -2735,10 +2735,11 @@
 llvm::CallInst *CodeGenFunction::EmitTrapCall(llvm::Intrinsic::ID IntrID) {
   llvm::CallInst *TrapCall = Builder.CreateCall(CGM.getIntrinsic(IntrID));
 
-  if (!CGM.getCodeGenOpts().TrapFuncName.empty())
-TrapCall->addAttribute(llvm::AttributeSet::FunctionIndex,
-   "trap-func-name",
-   CGM.getCodeGenOpts().TrapFuncName);
+  if (!CGM.getCodeGenOpts().TrapFuncName.empty()) {
+auto A = llvm::Attribute::get(getLLVMContext(), "trap-func-name",
+  CGM.getCodeGenOpts().TrapFuncName);
+TrapCall->addAttribute(llvm::AttributeSet::FunctionIndex, A);
+  }
 
   return TrapCall;
 }


Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -2735,10 +2735,11 @@
 llvm::CallInst *CodeGenFunction::EmitTrapCall(llvm::Intrinsic::ID IntrID) {
   llvm::CallInst *TrapCall = Builder.CreateCall(CGM.getIntrinsic(IntrID));
 
-  if (!CGM.getCodeGenOpts().TrapFuncName.empty())
-TrapCall->addAttribute(llvm::AttributeSet::FunctionIndex,
-   "trap-func-name",
-   CGM.getCodeGenOpts().TrapFuncName);
+  if (!CGM.getCodeGenOpts().TrapFuncName.empty()) {
+auto A = llvm::Attribute::get(getLLVMContext(), "trap-func-name",
+  CGM.getCodeGenOpts().TrapFuncName);
+TrapCall->addAttribute(llvm::AttributeSet::FunctionIndex, A);
+  }
 
   return TrapCall;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21510: [libc++] Check hash before calling __hash_table key_eq function

2016-06-19 Thread Kwasi Mensah via cfe-commits
kmensah added a comment.

I've run make make check-libcxx and this seems to pass fine.


Repository:
  rL LLVM

http://reviews.llvm.org/D21510



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


[PATCH] D21510: [libc++] Check hash before calling __hash_table key_eq function

2016-06-19 Thread Kwasi Mensah via cfe-commits
kmensah created this revision.
kmensah added a subscriber: cfe-commits.
kmensah set the repository for this revision to rL LLVM.

The current implementations of __hash_table::find used by 
std::unordered_set/unordered_map call key_eq on each key that lands in the same 
bucket as the key you're looking for. However, since equal objects mush hash to 
the same value, you can short-circuit the possibly expensive call to key_eq by 
checking the hashes first.

Repository:
  rL LLVM

http://reviews.llvm.org/D21510

Files:
  include/__hash_table

Index: include/__hash_table
===
--- include/__hash_table
+++ include/__hash_table
@@ -2200,7 +2200,7 @@
__constrain_hash(__nd->__hash_, __bc) 
== __chash;
__nd = 
__nd->__next_)
 {
-if (key_eq()(__nd->__value_, __k))
+if ((__nd->__hash_ == __hash) && key_eq()(__nd->__value_, __k))
 #if _LIBCPP_DEBUG_LEVEL >= 2
 return iterator(__nd, this);
 #else
@@ -2229,7 +2229,7 @@
__constrain_hash(__nd->__hash_, 
__bc) == __chash;
__nd = 
__nd->__next_)
 {
-if (key_eq()(__nd->__value_, __k))
+if ((__nd->__hash_ == __hash) && key_eq()(__nd->__value_, __k))
 #if _LIBCPP_DEBUG_LEVEL >= 2
 return const_iterator(__nd, this);
 #else


Index: include/__hash_table
===
--- include/__hash_table
+++ include/__hash_table
@@ -2200,7 +2200,7 @@
__constrain_hash(__nd->__hash_, __bc) == __chash;
__nd = __nd->__next_)
 {
-if (key_eq()(__nd->__value_, __k))
+if ((__nd->__hash_ == __hash) && key_eq()(__nd->__value_, __k))
 #if _LIBCPP_DEBUG_LEVEL >= 2
 return iterator(__nd, this);
 #else
@@ -2229,7 +2229,7 @@
__constrain_hash(__nd->__hash_, __bc) == __chash;
__nd = __nd->__next_)
 {
-if (key_eq()(__nd->__value_, __k))
+if ((__nd->__hash_ == __hash) && key_eq()(__nd->__value_, __k))
 #if _LIBCPP_DEBUG_LEVEL >= 2
 return const_iterator(__nd, this);
 #else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21508: Make friend function template definition available if class is instantiated.

2016-06-19 Thread Serge Pavlov via cfe-commits
sepavloff created this revision.
sepavloff added a reviewer: rsmith.
sepavloff added a subscriber: cfe-commits.

Similar to friend functions, if a friend function template is defined in a
class template, its definition is available only if the class is instantiated.

http://reviews.llvm.org/D21508

Files:
  include/clang/AST/DeclTemplate.h
  lib/AST/DeclTemplate.cpp
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/friend2.cpp

Index: test/SemaCXX/friend2.cpp
===
--- test/SemaCXX/friend2.cpp
+++ test/SemaCXX/friend2.cpp
@@ -91,6 +91,73 @@
   friend int func10(int);  // expected-error{{functions that differ only in their return type cannot be overloaded}}
 };
 
+// Case of template friend functions.
+
+template void func_11(T *x);
+template
+struct C11a {
+  template friend void func_11(T *x) {}
+};
+template
+struct C11b {
+  template friend void func_11(T *x) {}
+};
+
+
+template inline void func_12(T *x) {}
+template
+struct C12a {
+  template friend void func_12(T *x) {}
+};
+template
+struct C12b {
+  template friend void func_12(T *x) {}
+};
+
+
+template
+struct C13a {
+  template friend void func_13(T *x) {}
+};
+template
+struct C13b {
+  template friend void func_13(T *x) {}
+};
+
+
+template inline void func_14(T *x) {}  // expected-note{{previous definition is here}}
+template
+struct C14 {
+  template friend void func_14(T *x) {} // expected-error{{redefinition of 'func_14'}}
+};
+
+C14 v14;  // expected-note{{in instantiation of template class 'C14' requested here}}
+
+
+template inline void func_15(T *x);
+template
+struct C15a {
+  template friend void func_15(T *x) {} // expected-note{{previous definition is here}}
+};
+template
+struct C15b {
+  template friend void func_15(T *x) {} // expected-error{{redefinition of 'func_15'}}
+};
+
+C15a v15a;
+C15b v15b;  // expected-note{{in instantiation of template class 'C15b' requested here}}
+
+
+template void func_16(T *x);
+template
+struct C16 {
+  template friend void func_16(T *x) {}  // expected-error{{redefinition of 'func_16'}}
+ // expected-note@-1{{previous definition is here}}
+};
+
+C16 v16a;
+C16 v16b;  //expected-note{{in instantiation of template class 'C16' requested here}}
+
 
 namespace pr22307 {
 
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8757,10 +8757,23 @@
 
 if (FunctionTemplateDecl *OldTemplateDecl
   = dyn_cast(OldDecl)) {
-  NewFD->setPreviousDeclaration(OldTemplateDecl->getTemplatedDecl());
   FunctionTemplateDecl *NewTemplateDecl
 = NewFD->getDescribedFunctionTemplate();
   assert(NewTemplateDecl && "Template/non-template mismatch");
+  Redeclaration = shouldLinkDependentDeclWithPrevious(NewTemplateDecl,
+  OldTemplateDecl);
+  if (Redeclaration &&
+  (NewTemplateDecl->getFriendObjectKind() != Decl::FOK_None ||
+   OldTemplateDecl->getFriendObjectKind() != Decl::FOK_None))
+if (FunctionTemplateDecl *NewDef = NewTemplateDecl->getDefinition())
+  if (FunctionTemplateDecl *OldDef = OldTemplateDecl->getDefinition()) {
+Diag(NewDef->getLocation(), diag::err_redefinition)
+<< NewDef->getDeclName();
+Diag(OldDef->getLocation(), diag::note_previous_definition);
+Redeclaration = false;
+  }
+  if (Redeclaration)
+NewFD->setPreviousDeclaration(OldTemplateDecl->getTemplatedDecl());
   if (CXXMethodDecl *Method
 = dyn_cast(NewTemplateDecl->getTemplatedDecl())) {
 Method->setAccess(OldTemplateDecl->getAccess());
Index: lib/AST/DeclTemplate.cpp
===
--- lib/AST/DeclTemplate.cpp
+++ lib/AST/DeclTemplate.cpp
@@ -289,6 +289,31 @@
   }
 }
 
+/// \brief Returns definition for this function template of null if no
+/// definition found.
+///
+/// This function scans not only redeclarations but also templates from which
+/// these declarations are instantiated, if the function template was
+/// instantiated from another template.
+///
+FunctionTemplateDecl *FunctionTemplateDecl::getDefinition() const {
+  for (auto *R : redecls()) {
+FunctionTemplateDecl *F = cast(R);
+if (F->isThisDeclarationADefinition())
+  return F;
+
+// If template does not have a body, probably it is instantiated from
+// another template, which is not used yet.
+while (FunctionTemplateDecl *P = F->getInstantiatedFromMemberTemplate()) {
+  if (P->isThisDeclarationADefinition())
+return P;
+  F = P;
+}
+  }
+
+  return nullptr;
+}
+
 llvm::FoldingSetVector &
 FunctionTemplateDecl::getSpecializations() const {
   LoadLazySpecializations();
Index: include/clang/AST/DeclTemplate.h

Re: [PATCH] D16989: Change interpretation of function definition in friend declaration of template class.

2016-06-19 Thread Serge Pavlov via cfe-commits
sepavloff updated this revision to Diff 61220.
sepavloff added a comment.

Updated patch

Added handling of FunctionTemplateDecl to shouldLinkDependentDeclWithPrevious. 
It is not
used now but is required for subsequent patch. Also position comment correctly.


http://reviews.llvm.org/D16989

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/PR25848.cpp
  test/SemaCXX/friend2.cpp

Index: test/SemaCXX/friend2.cpp
===
--- /dev/null
+++ test/SemaCXX/friend2.cpp
@@ -0,0 +1,145 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+// If a friend function is defined in several non-template classes,
+// it is an error.
+
+void func1(int);
+struct C1a {
+  friend void func1(int) {}  // expected-note{{previous definition is here}}
+};
+struct C1b {
+  friend void func1(int) {}  // expected-error{{redefinition of 'func1'}}
+};
+
+
+// If a friend function is defined in both non-template and template
+// classes it is an error only if the template is instantiated.
+
+void func2(int);
+struct C2a {
+  friend void func2(int) {}
+};
+template struct C2b {
+  friend void func2(int) {}
+};
+
+void func3(int);
+struct C3a {
+  friend void func3(int) {}  // expected-note{{previous definition is here}}
+};
+template struct C3b {
+  friend void func3(int) {}  // expected-error{{redefinition of 'func3'}}
+};
+C3b c3;  // expected-note{{in instantiation of template class 'C3b' requested here}}
+
+
+// If a friend function is defined in several template classes it is an error
+// only if several templates are instantiated.
+
+void func4(int);
+template struct C4a {
+  friend void func4(int) {}
+};
+template struct C4b {
+  friend void func4(int) {}
+};
+
+
+void func5(int);
+template struct C5a {
+  friend void func5(int) {}
+};
+template struct C5b {
+  friend void func5(int) {}
+};
+C5a c5a;
+
+void func6(int);
+template struct C6a {
+  friend void func6(int) {}  // expected-note{{previous definition is here}}
+};
+template struct C6b {
+  friend void func6(int) {}  // expected-error{{redefinition of 'func6'}}
+};
+C6a c6a;
+C6b c6b;  // expected-note{{in instantiation of template class 'C6b' requested here}}
+
+void func7(int);
+template struct C7 {
+  friend void func7(int) {}  // expected-error{{redefinition of 'func7'}}
+ // expected-note@-1{{previous definition is here}}
+};
+C7 c7a;
+C7 c7b;  // expected-note{{in instantiation of template class 'C7' requested here}}
+
+
+// Even if clases are not instantiated and hence friend functions defined in them are not
+// available, their declarations can be checked.
+
+void func8(int);  // expected-note{{previous declaration is here}}
+template struct C8a {
+  friend long func8(int);  // expected-error{{functions that differ only in their return type cannot be overloaded}}
+};
+
+void func9(int);  // expected-note{{previous declaration is here}}
+template struct C9a {
+  friend int func9(int);  // expected-error{{functions that differ only in their return type cannot be overloaded}}
+};
+
+void func10(int);  // expected-note{{previous declaration is here}}
+template struct C10a {
+  friend int func10(int);  // expected-error{{functions that differ only in their return type cannot be overloaded}}
+};
+
+
+namespace pr22307 {
+
+struct t {
+  friend int leak(t);
+};
+
+template
+struct m {
+  friend int leak(t) { return sizeof(v); }  // expected-error{{redefinition of 'leak'}} expected-note{{previous definition is here}}
+};
+
+template struct m;
+template struct m;  // expected-note{{in instantiation of template class 'pr22307::m' requested here}}
+
+int main() {
+  leak(t());
+}
+
+}
+
+namespace pr17923 {
+
+void f(unsigned long long);
+
+template struct X {
+  friend void f(unsigned long long) {
+ T t;
+  }
+};
+
+int main() { f(1234); }
+
+}
+
+namespace pr17923a {
+
+int get();
+
+template< int value >
+class set {
+  friend int get()
+{ return value; } // return 0; is OK
+};
+
+template class set< 5 >;
+
+int main() {
+  get();
+}
+
+}
Index: test/SemaCXX/PR25848.cpp
===
--- /dev/null
+++ test/SemaCXX/PR25848.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A;
+
+inline int g();  // expected-warning{{inline function 'g' is not defined}}
+
+template
+struct R {
+  friend int g() {
+return M;
+  }
+};
+
+void m() {
+  g();  // expected-note{{used here}}
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8568,6 +8568,39 @@
   return NewFD;
 }
 
+/// \brief Checks if the new declaration declared in dependent context must be
+/// put in the same redeclaration chain as the specified declaration.
+///
+/// \param D Declaration that is checked.
+/// \param PrevDecl Previous declaration found with proper lookup method for the
+///   

Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

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

Changes after running http://reviews.llvm.org/D21507


http://reviews.llvm.org/D20964



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


[libcxx] r273123 - Add entry to CREDITS.TXT for propagate_const

2016-06-19 Thread Jonathan Coe via cfe-commits
Author: jbcoe
Date: Sun Jun 19 14:36:28 2016
New Revision: 273123

URL: http://llvm.org/viewvc/llvm-project?rev=273123=rev
Log:
Add entry to CREDITS.TXT for propagate_const

Modified:
libcxx/trunk/CREDITS.TXT

Modified: libcxx/trunk/CREDITS.TXT
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CREDITS.TXT?rev=273123=273122=273123=diff
==
--- libcxx/trunk/CREDITS.TXT (original)
+++ libcxx/trunk/CREDITS.TXT Sun Jun 19 14:36:28 2016
@@ -37,6 +37,10 @@ E: mclow.li...@gmail.com
 E: marsh...@idio.com
 D: C++14 support, patches and bug fixes.
 
+N: Jonathan B Coe
+E: jb...@me.com
+D: Implementation of propagate_const.
+
 N: Eric Fiselier
 E: e...@efcs.ca
 D: LFTS support, patches and bug fixes.


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


[libcxx] r273122 - Implement std::experimental::propagate_const from LFTS v2

2016-06-19 Thread Jonathan Coe via cfe-commits
Author: jbcoe
Date: Sun Jun 19 14:34:13 2016
New Revision: 273122

URL: http://llvm.org/viewvc/llvm-project?rev=273122=rev
Log:
Implement std::experimental::propagate_const from LFTS v2

Summary:
An implementation of std::experimental::propagate_const from Library 
Fundamentals Technical Specification v2.

No tests are provided for disallowed types like fancy pointers or function 
pointers as no code was written to handle these.

Reviewers: EricWF, mclow.lists

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

Added:
libcxx/trunk/include/experimental/propagate_const
libcxx/trunk/test/std/experimental/utilities/propagate_const/

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.assignment/

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.assignment/assign.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.assignment/assign_convertible_element_type.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.assignment/assign_convertible_propagate_const.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.assignment/assign_element_type.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.assignment/move_assign.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.assignment/move_assign_convertible.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.assignment/move_assign_convertible_propagate_const.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.ctors/

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.ctors/convertible_element_type.explicit.ctor.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.ctors/convertible_element_type.non-explicit.ctor.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.ctors/convertible_propagate_const.copy_ctor.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.ctors/convertible_propagate_const.explicit.move_ctor.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.ctors/convertible_propagate_const.move_ctor.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.ctors/copy_ctor.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.ctors/element_type.explicit.ctor.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.ctors/element_type.non-explicit.ctor.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.ctors/move_ctor.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.non-const_observers/

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.non-const_observers/dereference.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.non-const_observers/explicit_operator_element_type_ptr.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.non-const_observers/get.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.non-const_observers/op_arrow.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.non-const_observers/operator_element_type_ptr.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.observers/

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.observers/dereference.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.observers/explicit_operator_element_type_ptr.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.observers/get.pass.cpp

libcxx/trunk/test/std/experimental/utilities/propagate_const/propagate_const.class/propagate_const.observers/op_arrow.pass.cpp


[libcxx] r273121 - Test commit; remove some spaces at EOL. No functional change.

2016-06-19 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Sun Jun 19 14:29:52 2016
New Revision: 273121

URL: http://llvm.org/viewvc/llvm-project?rev=273121=rev
Log:
Test commit; remove some spaces at EOL. No functional change.

Modified:
libcxx/trunk/include/utility

Modified: libcxx/trunk/include/utility
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=273121=273120=273121=diff
==
--- libcxx/trunk/include/utility (original)
+++ libcxx/trunk/include/utility Sun Jun 19 14:29:52 2016
@@ -169,7 +169,7 @@ template
 template
   using index_sequence_for = make_index_sequence;
 
-template 
+template
 T exchange(T& obj, U&& new_value);
 }  // std
 
@@ -817,7 +817,7 @@ template
 
 template
 using index_sequence_for = make_index_sequence;
-  
+
 #endif  // _LIBCPP_STD_VER > 11
 
 #if _LIBCPP_STD_VER > 11
@@ -828,7 +828,7 @@ _T1 exchange(_T1& __obj, _T2 && __new_va
 _T1 __old_value = _VSTD::move(__obj);
 __obj = _VSTD::forward<_T2>(__new_value);
 return __old_value;
-}
+}
 #endif  // _LIBCPP_STD_VER > 11
 
 _LIBCPP_END_NAMESPACE_STD


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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-19 Thread Piotr Padlewski via cfe-commits
Prazek updated this revision to Diff 61214.
Prazek added a comment.

Changes after running og llvm code base. Adding llvm::SmallVector was a good 
idea, because it has fired for much more cases and I have found 3 other bugs.
Now check doesn't fire when argument of constructor is bitfield or new 
expression, or when constructor is converted to base class.
I will post diff of changes after running in a minute


http://reviews.llvm.org/D20964

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tidy/modernize/UseEmplaceCheck.h
  clang-tidy/utils/Matchers.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-emplace.rst
  test/clang-tidy/modernize-use-emplace.cpp

Index: test/clang-tidy/modernize-use-emplace.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-emplace.cpp
@@ -0,0 +1,342 @@
+// RUN: %check_clang_tidy %s modernize-use-emplace %t
+
+namespace std {
+template 
+class vector {
+public:
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args){};
+};
+template 
+class list {
+public:
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args){};
+};
+
+template 
+class deque {
+public:
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args){};
+};
+
+template 
+class pair {
+public:
+  pair() = default;
+  pair(const pair &) = default;
+  pair(pair &&) = default;
+
+  pair(const T1 &, const T2 &) {}
+  pair(T1 &&, T2 &&) {}
+
+  template 
+  pair(const pair ){};
+  template 
+  pair(pair &){};
+};
+
+template 
+pair make_pair(T1, T2) {
+  return pair();
+};
+
+template 
+class unique_ptr {
+public:
+  unique_ptr(T *) {}
+};
+} // namespace std
+
+void testInts() {
+  std::vector v;
+  v.push_back(42);
+  v.push_back(int(42));
+  v.push_back(int{42});
+  v.push_back(42.0);
+  int z;
+  v.push_back(z);
+}
+
+struct Something {
+  Something(int a, int b = 41) {}
+  Something() {}
+  void push_back(Something);
+};
+
+struct Convertable {
+  operator Something() { return Something{}; }
+};
+
+struct Zoz {
+  Zoz(Something, int = 42) {}
+};
+
+Zoz getZoz(Something s) { return Zoz(s); }
+
+void test_Something() {
+  std::vector v;
+
+  v.push_back(Something(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(Something{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(Something());
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
+  // CHECK-FIXES: v.emplace_back();
+
+  v.push_back(Something{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
+  // CHECK-FIXES: v.emplace_back();
+
+  v.push_back(42);
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
+  // CHECK-FIXES: v.emplace_back(42);
+
+  Something temporary(42, 42);
+  temporary.push_back(temporary);
+  v.push_back(temporary);
+
+  v.push_back(Convertable());
+  v.push_back(Convertable{});
+  Convertable s;
+  v.push_back(s);
+}
+
+void test2() {
+  std::vector v;
+  v.push_back(Zoz(Something(21, 37)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
+  // CHECK-FIXES: v.emplace_back(Something(21, 37));
+
+  v.push_back(Zoz(Something(21, 37), 42));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
+  // CHECK-FIXES: v.emplace_back(Something(21, 37), 42);
+
+  v.push_back(getZoz(Something(1, 2)));
+}
+
+void testPair() {
+  std::vector> v;
+  v.push_back(std::pair(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  std::vector> v2;
+  v2.push_back(std::pair(Something(42, 42), Zoz(Something(21, 37;
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use emplace_back
+  // CHECK-FIXES: v2.emplace_back(Something(42, 42), Zoz(Something(21, 37)));
+}
+
+struct Base {
+  Base(int, int *, int = 42);
+};
+
+struct Derived : Base {
+  Derived(int *, Something) : Base(42, nullptr) {}
+};
+
+void testDerived() {
+  std::vector v;
+  v.push_back(Derived(nullptr, Something{}));
+}
+
+void testNewExpr() {
+  std::vector v;
+  v.push_back(Derived(new int, Something{}));
+}
+
+void testSpaces() {
+  std::vector v;
+
+  // clang-format off
+
+  v.push_back(Something(1, //arg1
+2 // arg2
+   ) // Something
+  );
+  // CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use emplace_back
+  // CHECK-FIXES: v.emplace_back(1, //arg1
+  // CHECK-FIXES:2 // arg2
+  // CHECK-FIXES:  // Something
+  // CHECK-FIXES:   

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

2016-06-19 Thread Zoltán Dániel Török via cfe-commits
zdtorok created this revision.
zdtorok added reviewers: zaks.anna, dcoughlin, xazax.hun.
zdtorok added a subscriber: cfe-commits.
zdtorok set the repository for this revision to rL LLVM.

This checker should find the calls to blocking functions (for example: sleep, 
getc, fgets,read,recv etc.) inside a critical section. When sleep(x) is called 
while a mutex is held, other threads cannot lock the same mutex. This might 
take some time, leading to bad performance or even deadlock.

Example:

```
mutex_t m;

void f() {
  sleep(1000); // Error: sleep() while m is locked! [f() is called from 
foobar() while m is locked]
  // do some work
}

void foobar() {
  lock(m);
  f();
  unlock(m);
}
```

Repository:
  rL LLVM

http://reviews.llvm.org/D21506

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

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

[PATCH] D21505: [Clang][AVX512][Intrinsics]Adding intrinsics for mov{ss|sd} instruction set

2016-06-19 Thread michael zuckerman via cfe-commits
m_zuckerman created this revision.
m_zuckerman added reviewers: AsafBadouh, igorb, delena.
m_zuckerman added a subscriber: cfe-commits.

http://reviews.llvm.org/D21505

Files:
  lib/Headers/avx512fintrin.h
  test/CodeGen/avx512f-builtins.c

Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -241,6 +241,23 @@
   _mm512_mask_store_pd(p, m, a);
 }
 
+__m128 test_mm_mask_store_ss (float * __W, __mmask8 __U, __m128 __A)
+{
+  // CHECK-LABEL: @test_mm_mask_store_ss
+  // CHECK: store float {{.*}}, float* {{.*}}
+  // CHECK: load <4 x float>, <4 x float>* {{.*}}
+  return _mm_mask_store_ss (__W, __U, __A);
+}
+
+__m128d test_mm_mask_store_sd (double * __W, __mmask8 __U, __m128d __A)
+{
+  // CHECK-LABEL: @test_mm_mask_store_sd
+  // CHECK: store double {{.*}}, double* {{.*}}
+  // CHECK: load <2 x double>, <2 x double>* {{.*}}
+  return _mm_mask_store_sd ( __W,  __U,  __A);
+}
+
+
 void test_mm512_mask_storeu_epi32(void *__P, __mmask16 __U, __m512i __A) {
   // CHECK-LABEL: @test_mm512_mask_storeu_epi32
   // CHECK: @llvm.masked.store.v16i32(<16 x i32> %{{.*}}, <16 x i32>* %{{.*}}, i32 1, <16 x i1> %{{.*}})
@@ -371,6 +388,38 @@
   return _mm512_maskz_load_pd(__U, __P);
 }
 
+__m128 test_mm_mask_load_ss (__m128 __W, __mmask8 __U, float const* __A)
+{
+  // CHECK-LABEL: @test_mm_mask_load_ss
+  // CHECK: select <4 x i1> {{.*}}, <4 x float> {{.*}}, <4 x float> {{.*}}
+  // CHECK: load <4 x float>, <4 x float>* {{.*}}
+  return _mm_mask_load_ss ( __W,  __U,  __A);
+}
+
+__m128 test_mm_maskz_load_ss (__mmask8 __U, float const* __A)
+{
+  // CHECK-LABEL: @test_mm_maskz_load_ss
+  // CHECK: select <4 x i1> {{.*}}, <4 x float> {{.*}}, <4 x float> {{.*}}
+  // CHECK: load <4 x float>, <4 x float>* {{.*}}
+  return _mm_maskz_load_ss (__U, __A);
+}
+
+__m128d test_mm_mask_load_sd (__m128 __W, __mmask8 __U, double const* __A)
+{
+  // CHECK-LABEL: @test_mm_mask_load_sd
+  // CHECK: select <2 x i1>{{.*}}, <2 x double>{{.*}}, <2 x double>{{.*}} 
+  // CHECK: load <2 x double>, <2 x double>* {{.*}}
+  return _mm_mask_load_sd ( __W,  __U,  __A);
+}
+
+__m128d test_mm_maskz_load_sd (__mmask8 __U, double const* __A)
+{
+  // CHECK-LABEL: @test_mm_maskz_load_sd
+  // CHECK: select <2 x i1> {{.*}}, <2 x double> {{.*}}, <2 x double> {{.*}}
+  // CHECK: load <2 x double>, <2 x double>* {{.*}}
+  return _mm_maskz_load_sd (__U, __A);
+}
+
 __m512d test_mm512_set1_pd(double d)
 {
   // CHECK-LABEL: @test_mm512_set1_pd
@@ -6125,6 +6174,38 @@
   return _mm512_maskz_mov_ps(__U, __A); 
 }
 
+__m128 test_mm_mask_move_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
+{
+  // CHECK-LABEL: @test_mm_mask_move_ss
+  // CHECK: select <4 x i1>{{.*}}, <4 x float> {{.*}}, <4 x float>{{.*}}
+  // CHECK: load <4 x float>, <4 x float>* {{.*}}
+ return _mm_mask_move_ss ( __W,  __U,  __A,  __B);
+}
+
+__m128 test_mm_maskz_move_ss (__mmask8 __U, __m128 __A, __m128 __B)
+{
+  // CHECK-LABEL: @test_mm_maskz_move_ss
+  // CHECK: select <4 x i1>{{.*}}, <4 x float> {{.*}}, <4 x float>{{.*}}
+  // CHECK: load <4 x float>, <4 x float>* {{.*}}
+  return _mm_maskz_move_ss (__U, __A, __B);
+}
+
+__m128d test_mm_mask_move_sd (__m128 __W, __mmask8 __U, __m128d __A, __m128d __B)
+{
+  // CHECK-LABEL: @test_mm_mask_move_sd
+  // CHECK: select <2 x i1>{{.*}}, <2 x double>{{.*}}, <2 x double>{{.*}}
+  // CHECK: load <2 x double>, <2 x double>* {{.*}}
+  return _mm_mask_move_sd ( __W,  __U,  __A,  __B);
+}
+
+__m128d test_mm_maskz_move_sd (__mmask8 __U, __m128d __A, __m128d __B)
+{
+  // CHECK-LABEL: @test_mm_maskz_move_sd
+  // CHECK: select <2 x i1> {{.*}}, <2 x double> {{.*}}, <2 x double> {{.*}}
+  // CHECK: load <2 x double>, <2 x double>* {{.*}}
+  return _mm_maskz_move_sd (__U, __A, __B);
+}
+
 void test_mm512_mask_compressstoreu_pd(void *__P, __mmask8 __U, __m512d __A) {
   // CHECK-LABEL: @test_mm512_mask_compressstoreu_pd
   // CHECK: @llvm.x86.avx512.mask.compress.store.pd.512
Index: lib/Headers/avx512fintrin.h
===
--- lib/Headers/avx512fintrin.h
+++ lib/Headers/avx512fintrin.h
@@ -4400,6 +4400,42 @@
   return *(__m512i *) __P;
 }
 
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_mask_load_ss (__m128 __W, __mmask8 __U, const float* __A)
+{
+  __m128 temp = __builtin_ia32_selectps_128 ((__mmask8) __U,
+ (__v4sf) _mm_load_ss(__A),
+ (__v4sf) __W);
+  return (__m128) { temp[0], 0, 0, 0}; 
+}
+
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_maskz_load_ss (__mmask8 __U, const float* __A)
+{
+  __m128 temp = __builtin_ia32_selectps_128 ((__mmask8) __U,
+ (__v4sf) _mm_load_ss(__A),
+ (__v4sf) _mm_setzero_si128());
+   return (__m128) {temp[0], 0, 0, 0};
+}
+
+static __inline__ __m128d 

Re: [PATCH] D21504: [X86] add _mm_loadu_si64

2016-06-19 Thread Asaf Badouh via cfe-commits
AsafBadouh updated this revision to Diff 61200.
AsafBadouh added a comment.

small changes according to Simon review.


Repository:
  rL LLVM

http://reviews.llvm.org/D21504

Files:
  tools/clang/lib/Headers/emmintrin.h
  tools/clang/test/CodeGen/sse2-builtins.c

Index: tools/clang/lib/Headers/emmintrin.h
===
--- tools/clang/lib/Headers/emmintrin.h
+++ tools/clang/lib/Headers/emmintrin.h
@@ -505,6 +505,16 @@
   return ((struct __loadu_pd*)__dp)->__v;
 }
 
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_loadu_si64(void const *__a)
+{
+  struct __loadu_si64 {
+long long __v;
+  } __attribute__((__packed__, __may_alias__));
+  long long __u = ((struct __loadu_si64*)__a)->__v;
+  return (__m128i){__u, 0L};
+}
+
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_load_sd(double const *__dp)
 {
Index: tools/clang/test/CodeGen/sse2-builtins.c
===
--- tools/clang/test/CodeGen/sse2-builtins.c
+++ tools/clang/test/CodeGen/sse2-builtins.c
@@ -1520,3 +1520,12 @@
   // CHECK: xor <2 x i64> %{{.*}}, %{{.*}}
   return _mm_xor_si128(A, B);
 }
+
+__m128i test_mm_loadu_si64(void const* A) {
+  // CHECK-LABEL: test_mm_loadu_si64
+  // CHECK: load i64, i64* %__u
+  // CHECK: insertelement <2 x i64> undef, i64 %{{.*}}, i32 0
+  // CHECK: insertelement <2 x i64> %{{.*}}, i64 0, i32 1
+  return _mm_loadu_si64(A);
+}
+


Index: tools/clang/lib/Headers/emmintrin.h
===
--- tools/clang/lib/Headers/emmintrin.h
+++ tools/clang/lib/Headers/emmintrin.h
@@ -505,6 +505,16 @@
   return ((struct __loadu_pd*)__dp)->__v;
 }
 
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_loadu_si64(void const *__a)
+{
+  struct __loadu_si64 {
+long long __v;
+  } __attribute__((__packed__, __may_alias__));
+  long long __u = ((struct __loadu_si64*)__a)->__v;
+  return (__m128i){__u, 0L};
+}
+
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_load_sd(double const *__dp)
 {
Index: tools/clang/test/CodeGen/sse2-builtins.c
===
--- tools/clang/test/CodeGen/sse2-builtins.c
+++ tools/clang/test/CodeGen/sse2-builtins.c
@@ -1520,3 +1520,12 @@
   // CHECK: xor <2 x i64> %{{.*}}, %{{.*}}
   return _mm_xor_si128(A, B);
 }
+
+__m128i test_mm_loadu_si64(void const* A) {
+  // CHECK-LABEL: test_mm_loadu_si64
+  // CHECK: load i64, i64* %__u
+  // CHECK: insertelement <2 x i64> undef, i64 %{{.*}}, i32 0
+  // CHECK: insertelement <2 x i64> %{{.*}}, i64 0, i32 1
+  return _mm_loadu_si64(A);
+}
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21504: [X86] add _mm_loadu_si64

2016-06-19 Thread Simon Pilgrim via cfe-commits
RKSimon added a subscriber: RKSimon.


Comment at: tools/clang/test/CodeGen/sse2-builtins.c:1527
@@ +1526,3 @@
+  // CHECK: load i64, i64* %__u
+  // CHECK: insertelement <2 x i64> undef, i64 %4, i32 0
+  // CHECK: insertelement <2 x i64> %{{.*}}, i64 0, i32 1

Replace the hardcoded %4 argument with a general pattern match


Comment at: tools/clang/test/CodeGen/sse2-builtins.c:1530
@@ +1529,3 @@
+  // CHECK: store <2 x i64> %{{.*}}, <2 x i64>* %{{.*}}, align 16
+  // CHECK: load <2 x i64>, <2 x i64>* %{{.*}}, align 16
+  return _mm_loadu_si64(A);

Is the store/load necessary? This appears to be just the -O0 stack behaviour


Repository:
  rL LLVM

http://reviews.llvm.org/D21504



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


[PATCH] D21504: [X86] add _mm_loadu_si64

2016-06-19 Thread Asaf Badouh via cfe-commits
AsafBadouh created this revision.
AsafBadouh added reviewers: delena, igorb, m_zuckerman.
AsafBadouh added a subscriber: cfe-commits.
AsafBadouh set the repository for this revision to rL LLVM.

Repository:
  rL LLVM

http://reviews.llvm.org/D21504

Files:
  tools/clang/lib/Headers/emmintrin.h
  tools/clang/test/CodeGen/sse2-builtins.c

Index: tools/clang/lib/Headers/emmintrin.h
===
--- tools/clang/lib/Headers/emmintrin.h
+++ tools/clang/lib/Headers/emmintrin.h
@@ -505,6 +505,16 @@
   return ((struct __loadu_pd*)__dp)->__v;
 }
 
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_loadu_si64(void const *__a)
+{
+  struct __loadu_si64 {
+long long __v;
+  } __attribute__((__packed__, __may_alias__));
+  long long __u = ((struct __loadu_si64*)__a)->__v;
+  return (__m128i){__u, 0L};
+}
+
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_load_sd(double const *__dp)
 {
Index: tools/clang/test/CodeGen/sse2-builtins.c
===
--- tools/clang/test/CodeGen/sse2-builtins.c
+++ tools/clang/test/CodeGen/sse2-builtins.c
@@ -1520,3 +1520,14 @@
   // CHECK: xor <2 x i64> %{{.*}}, %{{.*}}
   return _mm_xor_si128(A, B);
 }
+
+__m128i test_mm_loadu_si64(void const* A) {
+  // CHECK-LABEL: test_mm_loadu_si64
+  // CHECK: load i64, i64* %__u
+  // CHECK: insertelement <2 x i64> undef, i64 %4, i32 0
+  // CHECK: insertelement <2 x i64> %{{.*}}, i64 0, i32 1
+  // CHECK: store <2 x i64> %{{.*}}, <2 x i64>* %{{.*}}, align 16
+  // CHECK: load <2 x i64>, <2 x i64>* %{{.*}}, align 16
+  return _mm_loadu_si64(A);
+}
+


Index: tools/clang/lib/Headers/emmintrin.h
===
--- tools/clang/lib/Headers/emmintrin.h
+++ tools/clang/lib/Headers/emmintrin.h
@@ -505,6 +505,16 @@
   return ((struct __loadu_pd*)__dp)->__v;
 }
 
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_loadu_si64(void const *__a)
+{
+  struct __loadu_si64 {
+long long __v;
+  } __attribute__((__packed__, __may_alias__));
+  long long __u = ((struct __loadu_si64*)__a)->__v;
+  return (__m128i){__u, 0L};
+}
+
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_load_sd(double const *__dp)
 {
Index: tools/clang/test/CodeGen/sse2-builtins.c
===
--- tools/clang/test/CodeGen/sse2-builtins.c
+++ tools/clang/test/CodeGen/sse2-builtins.c
@@ -1520,3 +1520,14 @@
   // CHECK: xor <2 x i64> %{{.*}}, %{{.*}}
   return _mm_xor_si128(A, B);
 }
+
+__m128i test_mm_loadu_si64(void const* A) {
+  // CHECK-LABEL: test_mm_loadu_si64
+  // CHECK: load i64, i64* %__u
+  // CHECK: insertelement <2 x i64> undef, i64 %4, i32 0
+  // CHECK: insertelement <2 x i64> %{{.*}}, i64 0, i32 1
+  // CHECK: store <2 x i64> %{{.*}}, <2 x i64>* %{{.*}}, align 16
+  // CHECK: load <2 x i64>, <2 x i64>* %{{.*}}, align 16
+  return _mm_loadu_si64(A);
+}
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21497: Fix test to specify C++03 (fails with C++11).

2016-06-19 Thread Olivier Goffart via cfe-commits
ogoffart added a comment.

I made http://reviews.llvm.org/D21502 that should also fix this test.


http://reviews.llvm.org/D21497



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


[PATCH] D21501: [Driver] Add support for Broadcom Vulcan core

2016-06-19 Thread pankaj gode via cfe-commits
pgode created this revision.
pgode added reviewers: t.p.northover, rengolin.
pgode added a subscriber: cfe-commits.
Herald added a subscriber: aemerson.

Adds support for new Broadcom Vulcan core (ARMv8.1A) .

http://reviews.llvm.org/D21501

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Tools.cpp
  test/Driver/aarch64-cpus.c
  test/Preprocessor/aarch64-target-features.c

Index: test/Preprocessor/aarch64-target-features.c
===
--- test/Preprocessor/aarch64-target-features.c
+++ test/Preprocessor/aarch64-target-features.c
@@ -95,14 +95,16 @@
 // RUN: %clang -target aarch64 -mcpu=cortex-a73 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-CORTEX-A73 %s
 // RUN: %clang -target aarch64 -mcpu=exynos-m1 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-M1 %s
 // RUN: %clang -target aarch64 -mcpu=kryo -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-KRYO %s
+// RUN: %clang -target aarch64 -mcpu=vulcan -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-VULCAN %s
 // CHECK-MCPU-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+neon" "-target-feature" "+crypto" "-target-feature" "+zcm" 
"-target-feature" "+zcz"
 // CHECK-MCPU-A35: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A53: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A57: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A72: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-CORTEX-A73: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-M1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-KRYO: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
+// CHECK-MCPU-VULCAN: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64 -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-ARCH-ARM64 %s
 // CHECK-ARCH-ARM64: "-target-cpu" "cyclone" "-target-feature" "+neon" 
"-target-feature" "+crypto" "-target-feature" "+zcm" "-target-feature" "+zcz"
Index: test/Driver/aarch64-cpus.c
===
--- test/Driver/aarch64-cpus.c
+++ test/Driver/aarch64-cpus.c
@@ -114,6 +114,20 @@
 // RUN: %clang -target arm64 -mlittle-endian -mtune=kryo -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-KRYO %s
 // ARM64-KRYO: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "kryo"
 
+// RUN: %clang -target aarch64 -mcpu=vulcan -### -c %s 2>&1 | FileCheck 
-check-prefix=VULCAN %s
+// RUN: %clang -target aarch64 -mlittle-endian -mcpu=vulcan -### -c %s 2>&1 | 
FileCheck -check-prefix=VULCAN %s
+// RUN: %clang -target aarch64_be -mlittle-endian -mcpu=vulcan -### -c %s 2>&1 
| FileCheck -check-prefix=VULCAN %s
+// RUN: %clang -target aarch64 -mtune=vulcan -### -c %s 2>&1 | FileCheck 
-check-prefix=VULCAN %s
+// RUN: %clang -target aarch64 -mlittle-endian -mtune=vulcan -### -c %s 2>&1 | 
FileCheck -check-prefix=VULCAN %s
+// RUN: %clang -target aarch64_be -mlittle-endian -mtune=vulcan -### -c %s 
2>&1 | FileCheck -check-prefix=VULCAN %s
+// VULCAN: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "vulcan"
+
+// RUN: %clang -target arm64 -mcpu=vulcan -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-VULCAN %s
+// RUN: %clang -target arm64 -mlittle-endian -mcpu=vulcan -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-VULCAN %s
+// RUN: %clang -target arm64 -mtune=vulcan -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-VULCAN %s
+// RUN: %clang -target arm64 -mlittle-endian -mtune=vulcan -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-VULCAN %s
+// ARM64-VULCAN: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "vulcan"
+
 // RUN: %clang -target aarch64_be -### -c %s 2>&1 | FileCheck 
-check-prefix=GENERIC-BE %s
 // RUN: %clang -target aarch64 -mbig-endian -### -c %s 2>&1 | FileCheck 
-check-prefix=GENERIC-BE %s
 // RUN: %clang -target aarch64_be -mbig-endian -### -c %s 2>&1 | FileCheck 
-check-prefix=GENERIC-BE %s
@@ -167,11 +181,21 @@
 // RUN: %clang -target aarch64_be -mbig-endian -mtune=exynos-m1 -### -c %s 
2>&1 | FileCheck -check-prefix=M1-BE %s
 // M1-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" "exynos-m1"
 
+// RUN: %clang -target aarch64_be -mcpu=vulcan -### -c %s 2>&1 | FileCheck 
-check-prefix=VULCAN-BE %s
+// RUN: %clang -target aarch64 -mbig-endian -mcpu=vulcan -### -c %s 2>&1 | 
FileCheck -check-prefix=VULCAN-BE %s
+// RUN: %clang 

Re: [PATCH] D21497: Fix test to specify C++03 (fails with C++11).

2016-06-19 Thread Olivier Goffart via cfe-commits
ogoffart added a comment.

I'm sorry for commiting broken test.

However this is supposed to work also in C++11 mode.  I'm investigating what's 
wrong.


http://reviews.llvm.org/D21497



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


[libcxx] r273107 - Fix various undefined behavior found by UBSan.

2016-06-19 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jun 19 02:08:27 2016
New Revision: 273107

URL: http://llvm.org/viewvc/llvm-project?rev=273107=rev
Log:
Fix various undefined behavior found by UBSan.

* Fix non-null violation in strstream.cpp
  Overflow was calling memcpy with a null parameter and a size of 0.

* Fix std/atomics/atomics.flag/ tests:
  a.test_and_set() was reading from an uninitialized atomic, but wasn't
  using the value. The tests now clear the flag before performing the
  first test_and_set. This allows UBSAN to test that clear doesn't read
  an invalid value.

* Fix std/experimental/algorithms/alg.random.sample/sample.pass.cpp
  The tests were dereferencing a past-the-end pointer to an array so that
  they could do pointer arithmetic with it. Instead of dereference the iterator
  I changed the tests to use the special 'base()' test iterator method.

* Add -fno-sanitize=float-divide-by-zero to suppress division by zero UBSAN 
diagnostics.
  The tests that cause float division by zero are explicitly aware that they
  are doing that. Since this is well defined for IEEE floats suppress the 
warnings
  for now.

Modified:
libcxx/trunk/src/strstream.cpp
libcxx/trunk/test/libcxx/test/config.py
libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp

libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
libcxx/trunk/test/std/atomics/atomics.flag/clear.pass.cpp

libcxx/trunk/test/std/experimental/algorithms/alg.random.sample/sample.pass.cpp

Modified: libcxx/trunk/src/strstream.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/strstream.cpp?rev=273107=273106=273107=diff
==
--- libcxx/trunk/src/strstream.cpp (original)
+++ libcxx/trunk/src/strstream.cpp Sun Jun 19 02:08:27 2016
@@ -11,6 +11,7 @@
 #include "algorithm"
 #include "climits"
 #include "cstring"
+#include "__debug"
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
@@ -167,7 +168,10 @@ strstreambuf::overflow(int_type __c)
 buf = new char[new_size];
 if (buf == nullptr)
 return int_type(EOF);
-memcpy(buf, eback(), static_cast(old_size));
+if (old_size != 0) {
+_LIBCPP_ASSERT(eback(), "overflow copying from NULL");
+memcpy(buf, eback(), static_cast(old_size));
+}
 ptrdiff_t ninp = gptr()  - eback();
 ptrdiff_t einp = egptr() - eback();
 ptrdiff_t nout = pptr()  - pbase();

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=273107=273106=273107=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Sun Jun 19 02:08:27 2016
@@ -620,12 +620,13 @@ class Configuration(object):
 blacklist = os.path.join(self.libcxx_src_root,
  'test/ubsan_blacklist.txt')
 self.cxx.flags += ['-fsanitize=undefined',
-   '-fno-sanitize=vptr,function',
+   
'-fno-sanitize=vptr,function,float-divide-by-zero',
'-fno-sanitize-recover=all',
'-fsanitize-blacklist=' + blacklist]
 self.cxx.compile_flags += ['-O3']
 self.env['UBSAN_OPTIONS'] = 'print_stacktrace=1'
 self.config.available_features.add('ubsan')
+self.config.available_features.add('sanitizer-new-delete')
 elif san == 'Thread':
 self.cxx.flags += ['-fsanitize=thread']
 self.config.available_features.add('tsan')

Modified: libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp?rev=273107=273106=273107=diff
==
--- libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp 
(original)
+++ libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp Sun 
Jun 19 02:08:27 2016
@@ -23,12 +23,14 @@ int main()
 {
 {
 std::atomic_flag f;
+f.clear();
 f.test_and_set();
 atomic_flag_clear();
 assert(f.test_and_set() == 0);
 }
 {
 volatile std::atomic_flag f;
+f.clear();
 f.test_and_set();
 atomic_flag_clear();
 assert(f.test_and_set() == 0);

Modified: 
libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp?rev=273107=273106=273107=diff
==
--- 

[libcxx] r273106 - Implement LWG issue 1169. num_get not fully compatible with strto*

2016-06-19 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Jun 19 01:58:22 2016
New Revision: 273106

URL: http://llvm.org/viewvc/llvm-project?rev=273106=rev
Log:
Implement LWG issue 1169. num_get not fully compatible with strto*

Use strtof and strtod for floats and doubles respectively instead of
always using strtold. The other parts of the change are already implemented
in libc++.

This patch also has a drive by fix to wbuffer_convert::underflow() which
prevents it from calling memmove(buff, null, 0).

Modified:
libcxx/trunk/include/locale
libcxx/trunk/include/support/solaris/xlocale.h
libcxx/trunk/include/support/xlocale/__strtonum_fallback.h

libcxx/trunk/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_double.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/locale
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/locale?rev=273106=273105=273106=diff
==
--- libcxx/trunk/include/locale (original)
+++ libcxx/trunk/include/locale Sun Jun 19 01:58:22 2016
@@ -180,6 +180,7 @@ template  class messages_by
 
 #include <__config>
 #include <__locale>
+#include <__debug>
 #include 
 #include 
 #include 
@@ -756,6 +757,28 @@ __num_get_unsigned_integral(const char*
 }
 
 template 
+_LIBCPP_INLINE_VISIBILITY
+_Tp __do_strtod(const char* __a, char** __p2);
+
+template <>
+inline _LIBCPP_INLINE_VISIBILITY
+float __do_strtod(const char* __a, char** __p2) {
+return strtof_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
+}
+
+template <>
+inline _LIBCPP_INLINE_VISIBILITY
+double __do_strtod(const char* __a, char** __p2) {
+return strtod_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
+}
+
+template <>
+inline _LIBCPP_INLINE_VISIBILITY
+long double __do_strtod(const char* __a, char** __p2) {
+return strtold_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
+}
+
+template 
 _Tp
 __num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err)
 {
@@ -764,7 +787,7 @@ __num_get_float(const char* __a, const c
 typename remove_reference::type __save_errno = errno;
 errno = 0;
 char *__p2;
-long double __ld = strtold_l(__a, &__p2, _LIBCPP_GET_C_LOCALE);
+_Tp __ld = __do_strtod<_Tp>(__a, &__p2);
 typename remove_reference::type __current_errno = 
errno;
 if (__current_errno == 0)
 errno = __save_errno;
@@ -775,7 +798,7 @@ __num_get_float(const char* __a, const c
 }
 else if (__current_errno == ERANGE)
 __err = ios_base::failbit;
-return static_cast<_Tp>(__ld);
+return __ld;
 }
 __err = ios_base::failbit;
 return 0;
@@ -3901,7 +3924,9 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::u
 }
 else
 {
-memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
+ _LIBCPP_ASSERT(!(__extbufnext_ == NULL && (__extbufend_ != 
__extbufnext_)), "underflow moving from NULL" );
+ if (__extbufend_ != __extbufnext_)
+memmove(__extbuf_, __extbufnext_, __extbufend_ - 
__extbufnext_);
 __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
 __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? 
sizeof(__extbuf_min_) : __ebs_);
 streamsize __nmemb = 
_VSTD::min(static_cast(this->egptr() - this->eback() - __unget_sz),

Modified: libcxx/trunk/include/support/solaris/xlocale.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/solaris/xlocale.h?rev=273106=273105=273106=diff
==
--- libcxx/trunk/include/support/solaris/xlocale.h (original)
+++ libcxx/trunk/include/support/solaris/xlocale.h Sun Jun 19 01:58:22 2016
@@ -44,11 +44,6 @@ long strtol_l(const char *__nptr, char *
   return strtol(__nptr, __endptr, __base);
 }
 static inline
-long double strtold_l(const char *__nptr, char **__endptr,
-locale_t __loc) {
-  return strtold(__nptr, __endptr);
-}
-static inline
 unsigned long long strtoull_l(const char *__nptr, char **__endptr,
 int __base, locale_t __loc) {
   return strtoull(__nptr, __endptr, __base);
@@ -58,6 +53,21 @@ unsigned long strtoul_l(const char *__np
 int __base, locale_t __loc) {
   return strtoul(__nptr, __endptr, __base);
 }
+static inline
+float strtof_l(const char *__nptr, char **__endptr,
+locale_t __loc) {
+  return strtof(__nptr, __endptr);
+}
+static inline
+double strtod_l(const char *__nptr, char **__endptr,
+locale_t __loc) {
+  return strtod(__nptr, __endptr);
+}
+static inline
+long double strtold_l(const char *__nptr, char **__endptr,
+