Re: r300650 - [modules] Properly look up the owning module for an instantiation of a merged template.

2017-04-18 Thread Chandler Carruth via cfe-commits
Reverted in r300658.

On Tue, Apr 18, 2017 at 8:30 PM Chandler Carruth 
wrote:

> Consider code like the following:
>
> ```
> #include 
>
> template 
> class MyAllocator : public std::allocator {
>  public:
>   typedef std::allocator Alloc;
>   typedef typename Alloc::pointer pointer;
>   typedef typename Alloc::size_type size_type;
>
>   MyAllocator() {}
>
>   template 
>   MyAllocator(const MyAllocator& x) : Alloc(x) {}
>
>   pointer allocate(size_type n,
>std::allocator::const_pointer /*hint*/ = nullptr)
> {
> void* p = malloc(n * sizeof(T));
> return static_cast(p);
>   }
>
>   void deallocate(pointer p, size_type) { free(p); }
>
>   template 
>   struct rebind {
> typedef MyAllocator other;
>   };
>
>  private:
>   template 
>   friend class MyAllocator;
> };
>
> std::shared_ptr x = std::allocate_shared(MyAllocator(), 0);
> ```
>
> This will fail to compile against libstdc++ 4.9's alloc_traits.h, when
> that header comes from a module, with an error message along the lines of:
> .../bits/alloc_traits.h:197:2: error: too few template arguments for class
> template '__alloctr_rebind'
> using rebind_alloc = typename __alloctr_rebind<_Alloc,
> _Tp>::__type;
>
> I think this is enough for you to debug, but let me know if not. I'm going
> to revert this temporarily to unbreak our modules builds using this version
> of libstdc++.
>
> On Tue, Apr 18, 2017 at 8:14 PM Chandler Carruth 
> wrote:
>
>> This appears to break a pretty straightforward use of things like
>> libstdc++'s __alloctr_rebind (undefined template with a default argument,
>> specializations, etc):
>>
>> https://github.com/gcc-mirror/gcc/blob/gcc-4_9-branch/libstdc++-v3/include/bits/alloc_traits.h#L58-L73
>>
>> At least, I'm getting errors from this. I'm working on a test case, but
>> as usual, the test case may be... large.
>>
>> On Tue, Apr 18, 2017 at 6:49 PM Richard Smith via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: rsmith
>>> Date: Tue Apr 18 20:36:43 2017
>>> New Revision: 300650
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=300650=rev
>>> Log:
>>> [modules] Properly look up the owning module for an instantiation of a
>>> merged template.
>>>
>>> When looking for the template instantiation pattern of a templated
>>> entity,
>>> consistently select the definition of the pattern if there is one. This
>>> means
>>> we'll pick the same owning module when we start instantiating a template
>>> that
>>> we'll later pick when determining which modules are visible during that
>>> instantiation.
>>>
>>> Modified:
>>> cfe/trunk/lib/AST/Decl.cpp
>>> cfe/trunk/lib/AST/DeclCXX.cpp
>>> cfe/trunk/lib/Sema/SemaLookup.cpp
>>> cfe/trunk/test/Modules/Inputs/template-default-args/a.h
>>> cfe/trunk/test/Modules/template-default-args.cpp
>>>
>>> Modified: cfe/trunk/lib/AST/Decl.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=300650=300649=300650=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/AST/Decl.cpp (original)
>>> +++ cfe/trunk/lib/AST/Decl.cpp Tue Apr 18 20:36:43 2017
>>> @@ -2251,6 +2251,13 @@ bool VarDecl::checkInitIsICE() const {
>>>return Eval->IsICE;
>>>  }
>>>
>>> +template
>>> +static DeclT *getDefinitionOrSelf(DeclT *D) {
>>> +  if (auto *Def = D->getDefinition())
>>> +return Def;
>>> +  return D;
>>> +}
>>> +
>>>  VarDecl *VarDecl::getTemplateInstantiationPattern() const {
>>>// If it's a variable template specialization, find the template or
>>> partial
>>>// specialization from which it was instantiated.
>>> @@ -2262,7 +2269,7 @@ VarDecl *VarDecl::getTemplateInstantiati
>>>break;
>>>  VTD = NewVTD;
>>>}
>>> -  return VTD->getTemplatedDecl()->getDefinition();
>>> +  return getDefinitionOrSelf(VTD->getTemplatedDecl());
>>>  }
>>>  if (auto *VTPSD =
>>>  From.dyn_cast()) {
>>> @@ -2271,7 +2278,7 @@ VarDecl *VarDecl::getTemplateInstantiati
>>>break;
>>>  VTPSD = NewVTPSD;
>>>}
>>> -  return VTPSD->getDefinition();
>>> +  return getDefinitionOrSelf(VTPSD);
>>>  }
>>>}
>>>
>>> @@ -2280,23 +2287,18 @@ VarDecl *VarDecl::getTemplateInstantiati
>>>VarDecl *VD = getInstantiatedFromStaticDataMember();
>>>while (auto *NewVD = VD->getInstantiatedFromStaticDataMember())
>>>  VD = NewVD;
>>> -  return VD->getDefinition();
>>> +  return getDefinitionOrSelf(VD);
>>>  }
>>>}
>>>
>>>if (VarTemplateDecl *VarTemplate = getDescribedVarTemplate()) {
>>> -
>>>  while (VarTemplate->getInstantiatedFromMemberTemplate()) {
>>>if (VarTemplate->isMemberSpecialization())
>>>  break;
>>>VarTemplate = VarTemplate->getInstantiatedFromMemberTemplate();
>>>  }
>>>
>>> -assert((!VarTemplate->getTemplatedDecl() ||
>>> -

r300659 - Revert r300653 and r300650. The underlying commit fixes one issue with

2017-04-18 Thread Chandler Carruth via cfe-commits
Author: chandlerc
Date: Wed Apr 19 00:25:13 2017
New Revision: 300659

URL: http://llvm.org/viewvc/llvm-project?rev=300659=rev
Log:
Revert r300653 and r300650. The underlying commit fixes one issue with
modules but exposes much more widespread issues. Example and more
information is on the review thread for r300650.

Original commit summary:
[modules] Properly look up the owning module for an instantiation of a merged 
template.

Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/test/Modules/Inputs/template-default-args/a.h
cfe/trunk/test/Modules/template-default-args.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=300659=300658=300659=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Apr 19 00:25:13 2017
@@ -2251,14 +2251,6 @@ bool VarDecl::checkInitIsICE() const {
   return Eval->IsICE;
 }
 
-template
-static DeclT *getDefinitionOrSelf(DeclT *D) {
-  assert(D);
-  if (auto *Def = D->getDefinition())
-return Def;
-  return D;
-}
-
 VarDecl *VarDecl::getTemplateInstantiationPattern() const {
   // If it's a variable template specialization, find the template or partial
   // specialization from which it was instantiated.
@@ -2270,7 +2262,7 @@ VarDecl *VarDecl::getTemplateInstantiati
   break;
 VTD = NewVTD;
   }
-  return getDefinitionOrSelf(VTD->getTemplatedDecl());
+  return VTD->getTemplatedDecl()->getDefinition();
 }
 if (auto *VTPSD =
 From.dyn_cast()) {
@@ -2279,7 +2271,7 @@ VarDecl *VarDecl::getTemplateInstantiati
   break;
 VTPSD = NewVTPSD;
   }
-  return getDefinitionOrSelf(VTPSD);
+  return VTPSD->getDefinition();
 }
   }
 
@@ -2288,18 +2280,23 @@ VarDecl *VarDecl::getTemplateInstantiati
   VarDecl *VD = getInstantiatedFromStaticDataMember();
   while (auto *NewVD = VD->getInstantiatedFromStaticDataMember())
 VD = NewVD;
-  return getDefinitionOrSelf(VD);
+  return VD->getDefinition();
 }
   }
 
   if (VarTemplateDecl *VarTemplate = getDescribedVarTemplate()) {
+
 while (VarTemplate->getInstantiatedFromMemberTemplate()) {
   if (VarTemplate->isMemberSpecialization())
 break;
   VarTemplate = VarTemplate->getInstantiatedFromMemberTemplate();
 }
 
-return getDefinitionOrSelf(VarTemplate->getTemplatedDecl());
+assert((!VarTemplate->getTemplatedDecl() ||
+!isTemplateInstantiation(getTemplateSpecializationKind())) &&
+   "couldn't find pattern for variable instantiation");
+
+return VarTemplate->getTemplatedDecl();
   }
   return nullptr;
 }
@@ -3203,12 +3200,9 @@ bool FunctionDecl::isTemplateInstantiati

 FunctionDecl *FunctionDecl::getTemplateInstantiationPattern() const {
   // Handle class scope explicit specialization special case.
-  if (getTemplateSpecializationKind() == TSK_ExplicitSpecialization) {
-if (auto *Spec = getClassScopeSpecializationPattern())
-  return getDefinitionOrSelf(Spec);
-return nullptr;
-  }
-
+  if (getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
+return getClassScopeSpecializationPattern();
+  
   // If this is a generic lambda call operator specialization, its 
   // instantiation pattern is always its primary template's pattern
   // even if its primary template was instantiated from another 
@@ -3220,10 +3214,16 @@ FunctionDecl *FunctionDecl::getTemplateI
 
   if (isGenericLambdaCallOperatorSpecialization(
   dyn_cast(this))) {
-assert(getPrimaryTemplate() && "not a generic lambda call operator?");
-return getDefinitionOrSelf(getPrimaryTemplate()->getTemplatedDecl());
+assert(getPrimaryTemplate() && "A generic lambda specialization must be "
+   "generated from a primary call operator "
+   "template");
+assert(getPrimaryTemplate()->getTemplatedDecl()->getBody() &&
+   "A generic lambda call operator template must always have a body - "
+   "even if instantiated from a prototype (i.e. as written) member "
+   "template");
+return getPrimaryTemplate()->getTemplatedDecl();
   }
-
+  
   if (FunctionTemplateDecl *Primary = getPrimaryTemplate()) {
 while (Primary->getInstantiatedFromMemberTemplate()) {
   // If we have hit a point where the user provided a specialization of
@@ -3232,14 +3232,11 @@ FunctionDecl *FunctionDecl::getTemplateI
 break;
   Primary = Primary->getInstantiatedFromMemberTemplate();
 }
-
-return getDefinitionOrSelf(Primary->getTemplatedDecl());
+
+return Primary->getTemplatedDecl();
   } 
-
-  if (auto *MFD = getInstantiatedFromMemberFunction())
-return getDefinitionOrSelf(MFD);
-
-  return nullptr;
+
+  return 

r300658 - [CodeGen] Use APInt::lshrInPlace instead of APInt::lshr. NFC

2017-04-18 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Apr 19 00:17:33 2017
New Revision: 300658

URL: http://llvm.org/viewvc/llvm-project?rev=300658=rev
Log:
[CodeGen] Use APInt::lshrInPlace instead of APInt::lshr. NFC

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

Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=300658=300657=300658=diff
==
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Wed Apr 19 00:17:33 2017
@@ -201,7 +201,7 @@ void ConstStructBuilder::AppendBitField(
   unsigned NewFieldWidth = FieldSize - BitsInPreviousByte;
 
   if (CGM.getDataLayout().isBigEndian()) {
-Tmp = Tmp.lshr(NewFieldWidth);
+Tmp.lshrInPlace(NewFieldWidth);
 Tmp = Tmp.trunc(BitsInPreviousByte);
 
 // We want the remaining high bits.
@@ -210,7 +210,7 @@ void ConstStructBuilder::AppendBitField(
 Tmp = Tmp.trunc(BitsInPreviousByte);
 
 // We want the remaining low bits.
-FieldValue = FieldValue.lshr(BitsInPreviousByte);
+FieldValue.lshrInPlace(BitsInPreviousByte);
 FieldValue = FieldValue.trunc(NewFieldWidth);
   }
 }
@@ -273,7 +273,7 @@ void ConstStructBuilder::AppendBitField(
   // We want the low bits.
   Tmp = FieldValue.trunc(CharWidth);
 
-  FieldValue = FieldValue.lshr(CharWidth);
+  FieldValue.lshrInPlace(CharWidth);
 }
 
 Elements.push_back(llvm::ConstantInt::get(CGM.getLLVMContext(), Tmp));


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


[PATCH] D30771: [analyzer] Teach the MallocChecker about Glib API for two arguments

2017-04-18 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai updated this revision to Diff 95684.
xiangzhai added a subscriber: cfe-commits.
xiangzhai added a comment.

Hi Artem,

I updated my patch as you suggested: never using `Arg1Val` after `TotalSize` is 
computed, on all branches. please review it, thanks a lot!

Regards,
Leslie Zhai


Repository:
  rL LLVM

https://reviews.llvm.org/D30771

Files:
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  test/Analysis/gmalloc.c

Index: test/Analysis/gmalloc.c
===
--- test/Analysis/gmalloc.c
+++ test/Analysis/gmalloc.c
@@ -13,6 +13,12 @@
 gpointer g_try_malloc(gsize n_bytes);
 gpointer g_try_malloc0(gsize n_bytes);
 gpointer g_try_realloc(gpointer mem, gsize n_bytes);
+gpointer g_malloc_n(gsize n_blocks, gsize n_block_bytes);
+gpointer g_malloc0_n(gsize n_blocks, gsize n_block_bytes);
+gpointer g_realloc_n(gpointer mem, gsize n_blocks, gsize n_block_bytes);
+gpointer g_try_malloc_n(gsize n_blocks, gsize n_block_bytes);
+gpointer g_try_malloc0_n(gsize n_blocks, gsize n_block_bytes);
+gpointer g_try_realloc_n(gpointer mem, gsize n_blocks, gsize n_block_bytes);
 void g_free(gpointer mem);
 gpointer g_memdup(gconstpointer mem, guint byte_size);
 
@@ -25,6 +31,12 @@
   gpointer g3 = g_try_malloc(n_bytes);
   gpointer g4 = g_try_malloc0(n_bytes);
   g3 = g_try_realloc(g3, n_bytes * 2);
+  gpointer g5 = g_malloc_n(n_bytes, sizeof(char));
+  gpointer g6 = g_malloc0_n(n_bytes, sizeof(char));
+  g5 = g_realloc_n(g5, n_bytes * 2, sizeof(char));
+  gpointer g7 = g_try_malloc_n(n_bytes, sizeof(char));
+  gpointer g8 = g_try_malloc0_n(n_bytes, sizeof(char));
+  g7 = g_try_realloc_n(g7, n_bytes * 2, sizeof(char));
 
   g_free(g1);
   g_free(g2);
@@ -38,6 +50,12 @@
   gpointer g3 = g_try_malloc(n_bytes);
   gpointer g4 = g_try_malloc0(n_bytes);
   g3 = g_try_realloc(g3, n_bytes * 2);
+  gpointer g5 = g_malloc_n(n_bytes, sizeof(char));
+  gpointer g6 = g_malloc0_n(n_bytes, sizeof(char));
+  g5 = g_realloc_n(g5, n_bytes * 2, sizeof(char));
+  gpointer g7 = g_try_malloc_n(n_bytes, sizeof(char));
+  gpointer g8 = g_try_malloc0_n(n_bytes, sizeof(char));
+  g7 = g_try_realloc_n(g7, n_bytes * 2, sizeof(char));
 
   g_free(g1);
   g_free(g2);
@@ -52,8 +70,100 @@
   gpointer g3 = g_try_malloc(n_bytes);
   gpointer g4 = g_try_malloc0(n_bytes);
   g3 = g_try_realloc(g3, n_bytes * 2); // expected-warning{{Potential leak of memory pointed to by 'g4'}}
+  gpointer g5 = g_malloc_n(n_bytes, sizeof(char));
+  gpointer g6 = g_malloc0_n(n_bytes, sizeof(char));
+  g5 = g_realloc_n(g5, n_bytes * 2, sizeof(char)); // expected-warning{{Potential leak of memory pointed to by 'g6'}}
+  gpointer g7 = g_try_malloc_n(n_bytes, sizeof(char)); // expected-warning{{Potential leak of memory pointed to by 'g5'}}
+  gpointer g8 = g_try_malloc0_n(n_bytes, sizeof(char));
+  g7 = g_try_realloc_n(g7, n_bytes * 2, sizeof(char)); // expected-warning{{Potential leak of memory pointed to by 'g8'}}
+
+  g_free(g1); // expected-warning{{Potential leak of memory pointed to by 'g7'}}
+  g_free(g2);
+  g_free(g3);
+}
+
+void f4() {
+  gpointer g1 = g_malloc(n_bytes);
+  gpointer g2 = g_malloc0(n_bytes);
+  g1 = g_realloc(g1, n_bytes * 2);
+  gpointer g3 = g_try_malloc(n_bytes);
+  gpointer g4 = g_try_malloc0(n_bytes);
+  g3 = g_try_realloc(g3, n_bytes * 2);
+  gpointer g5 = g_malloc_n(n_bytes, sizeof(char));
+  gpointer g6 = g_malloc0_n(n_bytes, sizeof(char));
+  g5 = g_realloc_n(g5, n_bytes * 2, sizeof(char)); // expected-warning{{Potential leak of memory pointed to by 'g6'}}
+  gpointer g7 = g_try_malloc_n(n_bytes, sizeof(char)); // expected-warning{{Potential leak of memory pointed to by 'g5'}}
+  gpointer g8 = g_try_malloc0_n(n_bytes, sizeof(char));
+  g7 = g_try_realloc_n(g7, n_bytes * 2, sizeof(char)); // expected-warning{{Potential leak of memory pointed to by 'g8'}}
+
+  g_free(g1); // expected-warning{{Potential leak of memory pointed to by 'g7'}}
+  g_free(g2);
+  g_free(g3);
+  g_free(g4);
+}
+
+void f5() {
+  gpointer g1 = g_malloc(n_bytes);
+  gpointer g2 = g_malloc0(n_bytes);
+  g1 = g_realloc(g1, n_bytes * 2);
+  gpointer g3 = g_try_malloc(n_bytes);
+  gpointer g4 = g_try_malloc0(n_bytes);
+  g3 = g_try_realloc(g3, n_bytes * 2);
+  gpointer g5 = g_malloc_n(n_bytes, sizeof(char));
+  gpointer g6 = g_malloc0_n(n_bytes, sizeof(char));
+  g5 = g_realloc_n(g5, n_bytes * 2, sizeof(char)); // expected-warning{{Potential leak of memory pointed to by 'g6'}}
+  gpointer g7 = g_try_malloc_n(n_bytes, sizeof(char));
+  gpointer g8 = g_try_malloc0_n(n_bytes, sizeof(char));
+  g7 = g_try_realloc_n(g7, n_bytes * 2, sizeof(char)); // expected-warning{{Potential leak of memory pointed to by 'g8'}}
+
+  g_free(g1); // expected-warning{{Potential leak of memory pointed to by 'g7'}}
+  g_free(g2);
+  g_free(g3);
+  g_free(g4);
+  g_free(g5);
+}
+
+void f6() {
+  gpointer g1 = g_malloc(n_bytes);
+  gpointer g2 = g_malloc0(n_bytes);
+  g1 = g_realloc(g1, n_bytes * 2);
+  gpointer g3 = g_try_malloc(n_bytes);
+  

[PATCH] D31885: Remove TBAA information from LValues representing union members

2017-04-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Thanks for CC'ing me.  There are two problems here.

The first is that vectors are aggregates which contain values of their element 
type.  (And honestly, we may need to be more permissive than this because 
people are pretty lax about the element type in a vector until it comes time to 
actually use it.)  We really can't be wishy-washy about casting a 
pointer-to-vector to a pointer-to-element and manipulating it as an array, or 
vice-versa — that's an incredibly common part of vector programming.  But even 
if we wanted to be wishy-washy, there are language features which allow you to 
drill into a vector and access an element individually, and while you can't 
take the address of the result, it still generates an access of the element 
type which obviously aliases the entire vector.  So we need to be modeling 
that, and hey, if we do that, we'll stop miscompiling this test case and can 
all go home. :)

The second is that our alias-analysis philosophy says that the fact that two 
accesses "sufficiently obviously" can alias should always override TBAA.  I 
have a hard time seeing what about the test cases I'm seeing makes it 
insufficiently obvious that the accesses alias.  The  accesses are ultimately 
derived from the same pointer; either the analysis is capable of counting to 
32, in which case it should see that they definitely alias, or it is not, in 
which can it needs to assume that they might.  Perhaps the existing AA 
interface is just inadequate?  It seems to me that it can't express that 
middle-ground of "I have a concrete reason to think that these pointers are 
related but cannot answer for certain whether they overlap".  Because if it 
could just answer that rather than having to downgrade all the way to MayAlias, 
it seems clear to me that (1) most memory transforms would treat it exactly the 
same as MayAlias but (2) it should be considered strong enough to suppress TBAA.

John.


Repository:
  rL LLVM

https://reviews.llvm.org/D31885



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


Re: r300650 - [modules] Properly look up the owning module for an instantiation of a merged template.

2017-04-18 Thread Chandler Carruth via cfe-commits
Consider code like the following:

```
#include 

template 
class MyAllocator : public std::allocator {
 public:
  typedef std::allocator Alloc;
  typedef typename Alloc::pointer pointer;
  typedef typename Alloc::size_type size_type;

  MyAllocator() {}

  template 
  MyAllocator(const MyAllocator& x) : Alloc(x) {}

  pointer allocate(size_type n,
   std::allocator::const_pointer /*hint*/ = nullptr) {
void* p = malloc(n * sizeof(T));
return static_cast(p);
  }

  void deallocate(pointer p, size_type) { free(p); }

  template 
  struct rebind {
typedef MyAllocator other;
  };

 private:
  template 
  friend class MyAllocator;
};

std::shared_ptr x = std::allocate_shared(MyAllocator(), 0);
```

This will fail to compile against libstdc++ 4.9's alloc_traits.h, when that
header comes from a module, with an error message along the lines of:
.../bits/alloc_traits.h:197:2: error: too few template arguments for class
template '__alloctr_rebind'
using rebind_alloc = typename __alloctr_rebind<_Alloc, _Tp>::__type;

I think this is enough for you to debug, but let me know if not. I'm going
to revert this temporarily to unbreak our modules builds using this version
of libstdc++.

On Tue, Apr 18, 2017 at 8:14 PM Chandler Carruth 
wrote:

> This appears to break a pretty straightforward use of things like
> libstdc++'s __alloctr_rebind (undefined template with a default argument,
> specializations, etc):
>
> https://github.com/gcc-mirror/gcc/blob/gcc-4_9-branch/libstdc++-v3/include/bits/alloc_traits.h#L58-L73
>
> At least, I'm getting errors from this. I'm working on a test case, but as
> usual, the test case may be... large.
>
> On Tue, Apr 18, 2017 at 6:49 PM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Tue Apr 18 20:36:43 2017
>> New Revision: 300650
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=300650=rev
>> Log:
>> [modules] Properly look up the owning module for an instantiation of a
>> merged template.
>>
>> When looking for the template instantiation pattern of a templated entity,
>> consistently select the definition of the pattern if there is one. This
>> means
>> we'll pick the same owning module when we start instantiating a template
>> that
>> we'll later pick when determining which modules are visible during that
>> instantiation.
>>
>> Modified:
>> cfe/trunk/lib/AST/Decl.cpp
>> cfe/trunk/lib/AST/DeclCXX.cpp
>> cfe/trunk/lib/Sema/SemaLookup.cpp
>> cfe/trunk/test/Modules/Inputs/template-default-args/a.h
>> cfe/trunk/test/Modules/template-default-args.cpp
>>
>> Modified: cfe/trunk/lib/AST/Decl.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=300650=300649=300650=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/Decl.cpp (original)
>> +++ cfe/trunk/lib/AST/Decl.cpp Tue Apr 18 20:36:43 2017
>> @@ -2251,6 +2251,13 @@ bool VarDecl::checkInitIsICE() const {
>>return Eval->IsICE;
>>  }
>>
>> +template
>> +static DeclT *getDefinitionOrSelf(DeclT *D) {
>> +  if (auto *Def = D->getDefinition())
>> +return Def;
>> +  return D;
>> +}
>> +
>>  VarDecl *VarDecl::getTemplateInstantiationPattern() const {
>>// If it's a variable template specialization, find the template or
>> partial
>>// specialization from which it was instantiated.
>> @@ -2262,7 +2269,7 @@ VarDecl *VarDecl::getTemplateInstantiati
>>break;
>>  VTD = NewVTD;
>>}
>> -  return VTD->getTemplatedDecl()->getDefinition();
>> +  return getDefinitionOrSelf(VTD->getTemplatedDecl());
>>  }
>>  if (auto *VTPSD =
>>  From.dyn_cast()) {
>> @@ -2271,7 +2278,7 @@ VarDecl *VarDecl::getTemplateInstantiati
>>break;
>>  VTPSD = NewVTPSD;
>>}
>> -  return VTPSD->getDefinition();
>> +  return getDefinitionOrSelf(VTPSD);
>>  }
>>}
>>
>> @@ -2280,23 +2287,18 @@ VarDecl *VarDecl::getTemplateInstantiati
>>VarDecl *VD = getInstantiatedFromStaticDataMember();
>>while (auto *NewVD = VD->getInstantiatedFromStaticDataMember())
>>  VD = NewVD;
>> -  return VD->getDefinition();
>> +  return getDefinitionOrSelf(VD);
>>  }
>>}
>>
>>if (VarTemplateDecl *VarTemplate = getDescribedVarTemplate()) {
>> -
>>  while (VarTemplate->getInstantiatedFromMemberTemplate()) {
>>if (VarTemplate->isMemberSpecialization())
>>  break;
>>VarTemplate = VarTemplate->getInstantiatedFromMemberTemplate();
>>  }
>>
>> -assert((!VarTemplate->getTemplatedDecl() ||
>> -!isTemplateInstantiation(getTemplateSpecializationKind())) &&
>> -   "couldn't find pattern for variable instantiation");
>> -
>> -return VarTemplate->getTemplatedDecl();
>> +return getDefinitionOrSelf(VarTemplate->getTemplatedDecl());
>>}
>>return nullptr;
>>  }
>> @@ -3201,7 +3203,7 @@ bool 

[PATCH] D28462: clang-format: Add new style option AlignConsecutiveMacros

2017-04-18 Thread Erik Nyquist via Phabricator via cfe-commits
enyquist updated this revision to Diff 95680.
enyquist added a comment.

Rebased on latest


Repository:
  rL LLVM

https://reviews.llvm.org/D28462

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/WhitespaceManager.cpp
  lib/Format/WhitespaceManager.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -7519,8 +7519,104 @@
   verifyFormat("a or_eq 8;", Spaces);
 }
 
+TEST_F(FormatTest, AlignConsecutiveMacros) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AlignConsecutiveAssignments = true;
+  Style.AlignConsecutiveDeclarations = true;
+  Style.AlignConsecutiveMacros = false;
+
+  verifyFormat("#define a 3\n"
+   "#define  4\n"
+   "#define ccc (5)",
+   Style);
+
+  verifyFormat("#define f(x) (x * x)\n"
+   "#define fff(x, y, z) (x * y + z)\n"
+   "#define (x, y) (x - y)",
+   Style);
+
+  verifyFormat("#define foo(x, y) (x + y)\n"
+   "#define bar (5, 6)(2 + 2)",
+   Style);
+
+  verifyFormat("#define a 3\n"
+   "#define  4\n"
+   "#define ccc (5)\n"
+   "#define f(x) (x * x)\n"
+   "#define fff(x, y, z) (x * y + z)\n"
+   "#define (x, y) (x - y)",
+   Style);
+
+  Style.AlignConsecutiveMacros = true;
+  verifyFormat("#define a3\n"
+   "#define  4\n"
+   "#define ccc  (5)",
+   Style);
+
+  verifyFormat("#define f(x) (x * x)\n"
+   "#define fff(x, y, z) (x * y + z)\n"
+   "#define (x, y)   (x - y)",
+   Style);
+
+  verifyFormat("#define foo(x, y) (x + y)\n"
+   "#define bar   (5, 6)(2 + 2)",
+   Style);
+
+  verifyFormat("#define a3\n"
+   "#define  4\n"
+   "#define ccc  (5)\n"
+   "#define f(x) (x * x)\n"
+   "#define fff(x, y, z) (x * y + z)\n"
+   "#define (x, y)   (x - y)",
+   Style);
+
+  verifyFormat("#define a 5\n"
+   "#define foo(x, y) (x + y)\n"
+   "#define CCC   (6)\n"
+   "auto lambda = []() {\n"
+   "  auto  ii = 0;\n"
+   "  float j  = 0;\n"
+   "  return 0;\n"
+   "};\n"
+   "int   i  = 0;\n"
+   "float i2 = 0;\n"
+   "auto  v  = type{\n"
+   "i = 1,   //\n"
+   "(i = 2), //\n"
+   "i = 3//\n"
+   "};",
+   Style);
+
+  Style.AlignConsecutiveMacros = false;
+  Style.ColumnLimit = 20;
+
+  verifyFormat("#define a  \\\n"
+   "  \"aa\"\n"
+   "#define D  \\\n"
+   "  \"aa\" \\\n"
+   "  \"ccdde\"\n"
+   "#define B  \\\n"
+   "  \"Q\"  \\\n"
+   "  \"F\"  \\\n"
+   "  \"\"\n",
+   Style);
+
+  Style.AlignConsecutiveMacros = true;
+  verifyFormat("#define a  \\\n"
+   "  \"aa\"\n"
+   "#define D  \\\n"
+   "  \"aa\" \\\n"
+   "  \"ccdde\"\n"
+   "#define B  \\\n"
+   "  \"Q\"  \\\n"
+   "  \"F\"  \\\n"
+   "  \"\"\n",
+   Style);
+}
+
 TEST_F(FormatTest, AlignConsecutiveAssignments) {
   FormatStyle Alignment = getLLVMStyle();
+  Alignment.AlignConsecutiveMacros = true;
   Alignment.AlignConsecutiveAssignments = false;
   verifyFormat("int a = 5;\n"
"int oneTwoThree = 123;",
@@ -7703,6 +7799,7 @@
 
 TEST_F(FormatTest, AlignConsecutiveDeclarations) {
   FormatStyle Alignment = getLLVMStyle();
+  Alignment.AlignConsecutiveMacros = true;
   Alignment.AlignConsecutiveDeclarations = false;
   verifyFormat("float const a = 5;\n"
"int oneTwoThree = 123;",
@@ -8667,6 +8764,7 @@
   CHECK_PARSE_BOOL(AlignEscapedNewlinesLeft);
   CHECK_PARSE_BOOL(AlignOperands);
   CHECK_PARSE_BOOL(AlignTrailingComments);
+  CHECK_PARSE_BOOL(AlignConsecutiveMacros);
   CHECK_PARSE_BOOL(AlignConsecutiveAssignments);
   CHECK_PARSE_BOOL(AlignConsecutiveDeclarations);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
Index: lib/Format/WhitespaceManager.h
===
--- lib/Format/WhitespaceManager.h
+++ lib/Format/WhitespaceManager.h
@@ -165,6 +165,9 @@
   /// \c EscapedNewlineColumn for the first tokens or token parts in a line.
   void calculateLineBreakInformation();
 
+  /// \brief Align 

[PATCH] D32187: [CodeGen][ObjC]

2017-04-18 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks, this looks great.  A few tweaks about the diagnostic and LGTM.




Comment at: include/clang/Basic/DiagnosticSemaKinds.td:4985
+def note_protected_by_objc_fast_enumeration : Note<
+  "jump enters Objective-c fast enumeration loop body">;
 def note_protected_by_objc_try : Note<

Capitalization: "Objective-C"

It's probably better to just say "fast enumeration loop" and leave off "body".


https://reviews.llvm.org/D32187



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


Re: r300650 - [modules] Properly look up the owning module for an instantiation of a merged template.

2017-04-18 Thread Chandler Carruth via cfe-commits
This appears to break a pretty straightforward use of things like
libstdc++'s __alloctr_rebind (undefined template with a default argument,
specializations, etc):
https://github.com/gcc-mirror/gcc/blob/gcc-4_9-branch/libstdc++-v3/include/bits/alloc_traits.h#L58-L73

At least, I'm getting errors from this. I'm working on a test case, but as
usual, the test case may be... large.

On Tue, Apr 18, 2017 at 6:49 PM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Tue Apr 18 20:36:43 2017
> New Revision: 300650
>
> URL: http://llvm.org/viewvc/llvm-project?rev=300650=rev
> Log:
> [modules] Properly look up the owning module for an instantiation of a
> merged template.
>
> When looking for the template instantiation pattern of a templated entity,
> consistently select the definition of the pattern if there is one. This
> means
> we'll pick the same owning module when we start instantiating a template
> that
> we'll later pick when determining which modules are visible during that
> instantiation.
>
> Modified:
> cfe/trunk/lib/AST/Decl.cpp
> cfe/trunk/lib/AST/DeclCXX.cpp
> cfe/trunk/lib/Sema/SemaLookup.cpp
> cfe/trunk/test/Modules/Inputs/template-default-args/a.h
> cfe/trunk/test/Modules/template-default-args.cpp
>
> Modified: cfe/trunk/lib/AST/Decl.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=300650=300649=300650=diff
>
> ==
> --- cfe/trunk/lib/AST/Decl.cpp (original)
> +++ cfe/trunk/lib/AST/Decl.cpp Tue Apr 18 20:36:43 2017
> @@ -2251,6 +2251,13 @@ bool VarDecl::checkInitIsICE() const {
>return Eval->IsICE;
>  }
>
> +template
> +static DeclT *getDefinitionOrSelf(DeclT *D) {
> +  if (auto *Def = D->getDefinition())
> +return Def;
> +  return D;
> +}
> +
>  VarDecl *VarDecl::getTemplateInstantiationPattern() const {
>// If it's a variable template specialization, find the template or
> partial
>// specialization from which it was instantiated.
> @@ -2262,7 +2269,7 @@ VarDecl *VarDecl::getTemplateInstantiati
>break;
>  VTD = NewVTD;
>}
> -  return VTD->getTemplatedDecl()->getDefinition();
> +  return getDefinitionOrSelf(VTD->getTemplatedDecl());
>  }
>  if (auto *VTPSD =
>  From.dyn_cast()) {
> @@ -2271,7 +2278,7 @@ VarDecl *VarDecl::getTemplateInstantiati
>break;
>  VTPSD = NewVTPSD;
>}
> -  return VTPSD->getDefinition();
> +  return getDefinitionOrSelf(VTPSD);
>  }
>}
>
> @@ -2280,23 +2287,18 @@ VarDecl *VarDecl::getTemplateInstantiati
>VarDecl *VD = getInstantiatedFromStaticDataMember();
>while (auto *NewVD = VD->getInstantiatedFromStaticDataMember())
>  VD = NewVD;
> -  return VD->getDefinition();
> +  return getDefinitionOrSelf(VD);
>  }
>}
>
>if (VarTemplateDecl *VarTemplate = getDescribedVarTemplate()) {
> -
>  while (VarTemplate->getInstantiatedFromMemberTemplate()) {
>if (VarTemplate->isMemberSpecialization())
>  break;
>VarTemplate = VarTemplate->getInstantiatedFromMemberTemplate();
>  }
>
> -assert((!VarTemplate->getTemplatedDecl() ||
> -!isTemplateInstantiation(getTemplateSpecializationKind())) &&
> -   "couldn't find pattern for variable instantiation");
> -
> -return VarTemplate->getTemplatedDecl();
> +return getDefinitionOrSelf(VarTemplate->getTemplatedDecl());
>}
>return nullptr;
>  }
> @@ -3201,7 +3203,7 @@ bool FunctionDecl::isTemplateInstantiati
>  FunctionDecl *FunctionDecl::getTemplateInstantiationPattern() const {
>// Handle class scope explicit specialization special case.
>if (getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
> -return getClassScopeSpecializationPattern();
> +return getDefinitionOrSelf(getClassScopeSpecializationPattern());
>
>// If this is a generic lambda call operator specialization, its
>// instantiation pattern is always its primary template's pattern
> @@ -3214,16 +3216,10 @@ FunctionDecl *FunctionDecl::getTemplateI
>
>if (isGenericLambdaCallOperatorSpecialization(
>dyn_cast(this))) {
> -assert(getPrimaryTemplate() && "A generic lambda specialization must
> be "
> -   "generated from a primary call
> operator "
> -   "template");
> -assert(getPrimaryTemplate()->getTemplatedDecl()->getBody() &&
> -   "A generic lambda call operator template must always have a
> body - "
> -   "even if instantiated from a prototype (i.e. as written)
> member "
> -   "template");
> -return getPrimaryTemplate()->getTemplatedDecl();
> +assert(getPrimaryTemplate() && "not a generic lambda call operator?");
> +return getDefinitionOrSelf(getPrimaryTemplate()->getTemplatedDecl());
>}
> -
> +
>if (FunctionTemplateDecl *Primary = 

[PATCH] D31885: Remove TBAA information from LValues representing union members

2017-04-18 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

To be clear, I'm find with disabling union tbaa until we can fix things for 
real. I'm somewhat concerned that this patch is quadratic in the AST.

FWIW, I tried just setting TBAAPath = true in EmitLValueForField and then 
returning nullptr from CodeGenTBAA::getTBAAStructTagInfo when 
BaseQTy->isUnionType() is true. This mostly works, although it does not handle 
the array case as this patch does. Maybe putting some code in 
EmitArraySubscriptExpr will also take care of that?


Repository:
  rL LLVM

https://reviews.llvm.org/D31885



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


r300653 - Fix member function call with null 'this' pointer.

2017-04-18 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Apr 18 21:19:21 2017
New Revision: 300653

URL: http://llvm.org/viewvc/llvm-project?rev=300653=rev
Log:
Fix member function call with null 'this' pointer.

Modified:
cfe/trunk/lib/AST/Decl.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=300653=300652=300653=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Apr 18 21:19:21 2017
@@ -2253,6 +2253,7 @@ bool VarDecl::checkInitIsICE() const {
 
 template
 static DeclT *getDefinitionOrSelf(DeclT *D) {
+  assert(D);
   if (auto *Def = D->getDefinition())
 return Def;
   return D;
@@ -3202,9 +3203,12 @@ bool FunctionDecl::isTemplateInstantiati

 FunctionDecl *FunctionDecl::getTemplateInstantiationPattern() const {
   // Handle class scope explicit specialization special case.
-  if (getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
-return getDefinitionOrSelf(getClassScopeSpecializationPattern());
-  
+  if (getTemplateSpecializationKind() == TSK_ExplicitSpecialization) {
+if (auto *Spec = getClassScopeSpecializationPattern())
+  return getDefinitionOrSelf(Spec);
+return nullptr;
+  }
+
   // If this is a generic lambda call operator specialization, its 
   // instantiation pattern is always its primary template's pattern
   // even if its primary template was instantiated from another 


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


[libcxx] r300652 - Fix tests for extended noexcept in the container adaptors tests

2017-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 18 21:07:12 2017
New Revision: 300652

URL: http://llvm.org/viewvc/llvm-project?rev=300652=rev
Log:
Fix tests for extended noexcept in the container adaptors tests

Modified:

libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp?rev=300652=300651=300652=diff
==
--- 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp
 Tue Apr 18 21:07:12 2017
@@ -17,7 +17,6 @@
 
 // This tests a conforming extension
 
-// UNSUPPORTED: c++98, c++03
 
 #include 
 #include 
@@ -27,8 +26,10 @@
 
 int main()
 {
+#if defined(_LIBCPP_VERSION)
 {
 typedef std::priority_queue C;
 static_assert(std::is_nothrow_default_constructible::value, "");
 }
+#endif
 }

Modified: 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp?rev=300652=300651=300652=diff
==
--- 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp
 Tue Apr 18 21:07:12 2017
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03
+
 // 
 
 // priority_queue(priority_queue&&)
@@ -15,8 +17,6 @@
 
 // This tests a conforming extension
 
-// UNSUPPORTED: c++98, c++03
-
 #include 
 #include 
 

Modified: 
libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp?rev=300652=300651=300652=diff
==
--- 
libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp
 Tue Apr 18 21:07:12 2017
@@ -16,8 +16,6 @@
 
 // This tests a conforming extension
 
-// UNSUPPORTED: c++98, c++03
-
 #include 
 #include 
 
@@ -26,8 +24,10 @@
 
 int main()
 {
+#if defined(_LIBCPP_VERSION)
 {
 typedef std::queue C;
 static_assert(std::is_nothrow_default_constructible::value, "");
 }
+#endif
 }

Modified: 
libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp?rev=300652=300651=300652=diff
==
--- 
libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp
 Tue Apr 18 21:07:12 2017
@@ -16,7 +16,6 @@
 
 // This tests a conforming extension
 
-// UNSUPPORTED: c++98, c++03
 
 #include 
 #include 
@@ -26,8 +25,10 @@
 
 int main()
 {
+#if defined(_LIBCPP_VERSION)
 {
 typedef std::queue C;
 static_assert(std::is_nothrow_move_constructible::value, "");
 }
+#endif
 }

Modified: 
libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp?rev=300652=300651=300652=diff
==
--- 
libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp
 (original)
+++ 

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-04-18 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.

This patch adds support for attribute "noescape", which is used to tell the 
compiler that a block passed to a function will not be called after the 
function returns.

To ensure that the block does not escape, clang imposes the following 
restrictions on its usage:

- Cannot be passed to a function expecting an escaping block
- Cannot be returned from a function
- Cannot be captured by a block
- Cannot be assigned to a variable

There are other improvements we can make to Sema and CodeGen if the compiler 
can tell whether a block escapes or not, which should follow this patch.

rdar://problem/19886775


https://reviews.llvm.org/D32210

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaStmt.cpp
  test/SemaObjCXX/noescape.mm

Index: test/SemaObjCXX/noescape.mm
===
--- /dev/null
+++ test/SemaObjCXX/noescape.mm
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -std=c++11 %s
+
+typedef void (^BlockTy)();
+
+void noescapeFunc(id, __attribute__((noescape)) BlockTy);
+void escapeFunc(id, BlockTy); // expected-note {{parameter is not annotated with noescape}}
+void noescapeFuncId(id, __attribute__((noescape)) id);
+void escapeFuncId(id, id); // expected-note {{parameter is not annotated with noescape}}
+void variadicFunc(int, ...);
+void invalidFunc0(int __attribute__((noescape))); // expected-warning {{'noescape' attribute ignored on parameter of non-pointer type}}
+
+__attribute__((objc_root_class)) @interface C
+-(BlockTy)noescapeMethod:(id)a blockArg:(__attribute__((noescape)) BlockTy)b;
+-(void)escapeMethod:(id)a blockArg:(BlockTy)b; // expected-note {{parameter is not annotated with noescape}}
+@end
+
+@implementation C
+-(BlockTy)noescapeMethod:(id)a blockArg:(__attribute__((noescape)) BlockTy)b { // expected-note {{parameter is annotated with noescape}}
+  return b; // expected-error {{cannot return non-escaping parameter}}
+}
+-(void)escapeMethod:(id)a blockArg:(BlockTy)b {
+}
+@end
+
+struct S {
+  void noescapeMethod(__attribute__((noescape)) BlockTy);
+  void escapeMethod(BlockTy); // expected-note {{parameter is not annotated with noescape}}
+};
+
+BlockTy test1([[clang::noescape]] BlockTy neb, BlockTy eb, C *c1, S *s1) { // expected-note 11 {{parameter is annotated with noescape}}
+  id i;
+  BlockTy t;
+  t = neb; // expected-error {{cannot assign non-escaping parameter}}
+  t = eb;
+  (void)^{ neb(); }; // expected-error 3 {{block cannot capture non-escaping parameter}}
+  (void)^{ eb(); };
+  auto noescapeBlock = ^(__attribute__((noescape)) BlockTy neb) {};
+  auto escapeBlock = ^(BlockTy eb) {}; // expected-note {{parameter is not annotated with noescape}}
+  noescapeBlock(neb);
+  noescapeBlock(eb);
+  escapeBlock(neb); // expected-error {{cannot pass non-escaping parameter}}
+  escapeBlock(eb);
+  noescapeFunc(i, neb);
+  noescapeFunc(i, eb);
+  escapeFunc(i, neb); // expected-error {{cannot pass non-escaping parameter}}
+  escapeFunc(i, eb);
+  noescapeFuncId(i, neb);
+  noescapeFuncId(i, eb);
+  escapeFuncId(i, neb); // expected-error {{cannot pass non-escaping parameter}}
+  escapeFuncId(i, eb);
+  variadicFunc(1, neb); // expected-error {{cannot pass non-escaping parameter}}
+  variadicFunc(1, eb);
+  [c1 noescapeMethod:i blockArg:neb];
+  [c1 noescapeMethod:i blockArg:eb];
+  [c1 escapeMethod:i blockArg:neb]; // expected-error {{cannot pass non-escaping parameter}}
+  [c1 escapeMethod:i blockArg:eb];
+  s1->noescapeMethod(neb);
+  s1->noescapeMethod(eb);
+  s1->escapeMethod(neb); // expected-error {{cannot pass non-escaping parameter}}
+  s1->escapeMethod(eb);
+  return neb; // expected-error {{cannot return non-escaping parameter}}
+}
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -3199,6 +3199,14 @@
   const AttrVec *Attrs = nullptr;
   bool isObjCMethod = false;
 
+  if (const auto *DRE = dyn_cast_or_null(RetValExp)) {
+const auto *D = DRE->getDecl();
+if (D->hasAttr()) {
+  Diag(DRE->getLocation(), diag::err_noescape_returned) << D->getName();
+  Diag(D->getLocation(), diag::note_noescape_parameter) << 0;
+}
+  }
+
   if (const FunctionDecl *FD = getCurFunctionDecl()) {
 FnRetType = FD->getReturnType();
 if (FD->hasAttrs())
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -11174,6 +11174,18 @@
   DiagnoseSelfAssignment(*this, LHS.get(), RHS.get(), OpLoc);
   DiagnoseSelfMove(LHS.get(), RHS.get(), OpLoc);
 }
+
+if (RHS.get())
+  if (const auto *DRE =
+  dyn_cast_or_null(RHS.get()->IgnoreImpCasts())) {
+const auto *D = DRE->getDecl();
+

r300650 - [modules] Properly look up the owning module for an instantiation of a merged template.

2017-04-18 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Apr 18 20:36:43 2017
New Revision: 300650

URL: http://llvm.org/viewvc/llvm-project?rev=300650=rev
Log:
[modules] Properly look up the owning module for an instantiation of a merged 
template.

When looking for the template instantiation pattern of a templated entity,
consistently select the definition of the pattern if there is one. This means
we'll pick the same owning module when we start instantiating a template that
we'll later pick when determining which modules are visible during that
instantiation.

Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/test/Modules/Inputs/template-default-args/a.h
cfe/trunk/test/Modules/template-default-args.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=300650=300649=300650=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Apr 18 20:36:43 2017
@@ -2251,6 +2251,13 @@ bool VarDecl::checkInitIsICE() const {
   return Eval->IsICE;
 }
 
+template
+static DeclT *getDefinitionOrSelf(DeclT *D) {
+  if (auto *Def = D->getDefinition())
+return Def;
+  return D;
+}
+
 VarDecl *VarDecl::getTemplateInstantiationPattern() const {
   // If it's a variable template specialization, find the template or partial
   // specialization from which it was instantiated.
@@ -2262,7 +2269,7 @@ VarDecl *VarDecl::getTemplateInstantiati
   break;
 VTD = NewVTD;
   }
-  return VTD->getTemplatedDecl()->getDefinition();
+  return getDefinitionOrSelf(VTD->getTemplatedDecl());
 }
 if (auto *VTPSD =
 From.dyn_cast()) {
@@ -2271,7 +2278,7 @@ VarDecl *VarDecl::getTemplateInstantiati
   break;
 VTPSD = NewVTPSD;
   }
-  return VTPSD->getDefinition();
+  return getDefinitionOrSelf(VTPSD);
 }
   }
 
@@ -2280,23 +2287,18 @@ VarDecl *VarDecl::getTemplateInstantiati
   VarDecl *VD = getInstantiatedFromStaticDataMember();
   while (auto *NewVD = VD->getInstantiatedFromStaticDataMember())
 VD = NewVD;
-  return VD->getDefinition();
+  return getDefinitionOrSelf(VD);
 }
   }
 
   if (VarTemplateDecl *VarTemplate = getDescribedVarTemplate()) {
-
 while (VarTemplate->getInstantiatedFromMemberTemplate()) {
   if (VarTemplate->isMemberSpecialization())
 break;
   VarTemplate = VarTemplate->getInstantiatedFromMemberTemplate();
 }
 
-assert((!VarTemplate->getTemplatedDecl() ||
-!isTemplateInstantiation(getTemplateSpecializationKind())) &&
-   "couldn't find pattern for variable instantiation");
-
-return VarTemplate->getTemplatedDecl();
+return getDefinitionOrSelf(VarTemplate->getTemplatedDecl());
   }
   return nullptr;
 }
@@ -3201,7 +3203,7 @@ bool FunctionDecl::isTemplateInstantiati
 FunctionDecl *FunctionDecl::getTemplateInstantiationPattern() const {
   // Handle class scope explicit specialization special case.
   if (getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
-return getClassScopeSpecializationPattern();
+return getDefinitionOrSelf(getClassScopeSpecializationPattern());
   
   // If this is a generic lambda call operator specialization, its 
   // instantiation pattern is always its primary template's pattern
@@ -3214,16 +3216,10 @@ FunctionDecl *FunctionDecl::getTemplateI
 
   if (isGenericLambdaCallOperatorSpecialization(
   dyn_cast(this))) {
-assert(getPrimaryTemplate() && "A generic lambda specialization must be "
-   "generated from a primary call operator "
-   "template");
-assert(getPrimaryTemplate()->getTemplatedDecl()->getBody() &&
-   "A generic lambda call operator template must always have a body - "
-   "even if instantiated from a prototype (i.e. as written) member "
-   "template");
-return getPrimaryTemplate()->getTemplatedDecl();
+assert(getPrimaryTemplate() && "not a generic lambda call operator?");
+return getDefinitionOrSelf(getPrimaryTemplate()->getTemplatedDecl());
   }
-  
+
   if (FunctionTemplateDecl *Primary = getPrimaryTemplate()) {
 while (Primary->getInstantiatedFromMemberTemplate()) {
   // If we have hit a point where the user provided a specialization of
@@ -3232,11 +3228,14 @@ FunctionDecl *FunctionDecl::getTemplateI
 break;
   Primary = Primary->getInstantiatedFromMemberTemplate();
 }
-
-return Primary->getTemplatedDecl();
+
+return getDefinitionOrSelf(Primary->getTemplatedDecl());
   } 
-
-  return getInstantiatedFromMemberFunction();
+
+  if (auto *MFD = getInstantiatedFromMemberFunction())
+return getDefinitionOrSelf(MFD);
+
+  return nullptr;
 }
 
 FunctionTemplateDecl *FunctionDecl::getPrimaryTemplate() const {
@@ -3780,7 +3779,7 @@ EnumDecl 

[libcxx] r300649 - Cleanup usages of _LIBCPP_HAS_NO_<c++11-feature> in

2017-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 18 20:35:58 2017
New Revision: 300649

URL: http://llvm.org/viewvc/llvm-project?rev=300649=rev
Log:
Cleanup usages of _LIBCPP_HAS_NO_ in 

Modified:
libcxx/trunk/include/exception

Modified: libcxx/trunk/include/exception
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/exception?rev=300649=300648=300649=diff
==
--- libcxx/trunk/include/exception (original)
+++ libcxx/trunk/include/exception Tue Apr 18 20:35:58 2017
@@ -209,11 +209,11 @@ struct __throw_with_nested;
 template 
 struct __throw_with_nested<_Tp, _Up, true> {
 _LIBCPP_NORETURN static inline _LIBCPP_ALWAYS_INLINE void
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 __do_throw(_Tp&& __t)
-#else
+#else
 __do_throw (_Tp& __t)
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 {
 throw __nested<_Up>(_VSTD::forward<_Tp>(__t));
 }
@@ -222,11 +222,11 @@ struct __throw_with_nested<_Tp, _Up, tru
 template 
 struct __throw_with_nested<_Tp, _Up, false> {
 _LIBCPP_NORETURN static inline _LIBCPP_ALWAYS_INLINE void
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 __do_throw(_Tp&& __t)
-#else
+#else
 __do_throw (_Tp& __t)
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 {
 throw _VSTD::forward<_Tp>(__t);
 }
@@ -236,11 +236,11 @@ struct __throw_with_nested<_Tp, _Up, fal
 template 
 _LIBCPP_NORETURN
 void
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 throw_with_nested(_Tp&& __t)
 #else
 throw_with_nested (_Tp& __t)
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif // _LIBCPP_CXX03_LANG
 {
 #ifndef _LIBCPP_NO_EXCEPTIONS
 typedef typename decay<_Tp>::type _Up;


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


[libcxx] r300648 - Cleanup usages of _LIBCPP_HAS_NO_<c++11-feature> in , , , and

2017-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 18 20:34:08 2017
New Revision: 300648

URL: http://llvm.org/viewvc/llvm-project?rev=300648=rev
Log:
Cleanup usages of _LIBCPP_HAS_NO_ in , , , 
and 

Modified:
libcxx/trunk/include/bitset
libcxx/trunk/include/ios
libcxx/trunk/include/iterator
libcxx/trunk/include/locale

Modified: libcxx/trunk/include/bitset
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/bitset?rev=300648=300647=300648=diff
==
--- libcxx/trunk/include/bitset (original)
+++ libcxx/trunk/include/bitset Tue Apr 18 20:34:08 2017
@@ -197,11 +197,11 @@ protected:
 _LIBCPP_INLINE_VISIBILITY
 size_t __hash_code() const _NOEXCEPT;
 private:
-#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+#ifdef _LIBCPP_CXX03_LANG
 void __init(unsigned long long __v, false_type) _NOEXCEPT;
 _LIBCPP_INLINE_VISIBILITY
 void __init(unsigned long long __v, true_type) _NOEXCEPT;
-#endif  // _LIBCPP_HAS_NO_CONSTEXPR
+#endif  // _LIBCPP_CXX03_LANG
 unsigned long to_ulong(false_type) const;
 _LIBCPP_INLINE_VISIBILITY
 unsigned long to_ulong(true_type) const;
@@ -217,16 +217,16 @@ template 
 inline
 _LIBCPP_CONSTEXPR
 __bitset<_N_words, _Size>::__bitset() _NOEXCEPT
-#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+#ifndef _LIBCPP_CXX03_LANG
 : __first_{0}
 #endif
 {
-#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+#ifdef _LIBCPP_CXX03_LANG
 _VSTD::fill_n(__first_, _N_words, __storage_type(0));
 #endif
 }
 
-#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+#ifdef _LIBCPP_CXX03_LANG
 
 template 
 void
@@ -249,13 +249,13 @@ __bitset<_N_words, _Size>::__init(unsign
 _VSTD::fill(__first_ + 1, __first_ + sizeof(__first_)/sizeof(__first_[0]), 
__storage_type(0));
 }
 
-#endif  // _LIBCPP_HAS_NO_CONSTEXPR
+#endif  // _LIBCPP_CXX03_LANG
 
 template 
 inline
 _LIBCPP_CONSTEXPR
 __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
-#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+#ifndef _LIBCPP_CXX03_LANG
 #if __SIZEOF_SIZE_T__ == 8
 : __first_{__v}
 #elif __SIZEOF_SIZE_T__ == 4
@@ -265,7 +265,7 @@ __bitset<_N_words, _Size>::__bitset(unsi
 #endif
 #endif
 {
-#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+#ifdef _LIBCPP_CXX03_LANG
 __init(__v, integral_constant());
 #endif
 }

Modified: libcxx/trunk/include/ios
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ios?rev=300648=300647=300648=diff
==
--- libcxx/trunk/include/ios (original)
+++ libcxx/trunk/include/ios Tue Apr 18 20:34:08 2017
@@ -657,7 +657,7 @@ protected:
 
 _LIBCPP_INLINE_VISIBILITY 
 void move(basic_ios& __rhs);
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_ALWAYS_INLINE
 void move(basic_ios&& __rhs) {move(__rhs);}
 #endif

Modified: libcxx/trunk/include/iterator
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=300648=300647=300648=diff
==
--- libcxx/trunk/include/iterator (original)
+++ libcxx/trunk/include/iterator Tue Apr 18 20:34:08 2017
@@ -783,10 +783,10 @@ public:
 _LIBCPP_INLINE_VISIBILITY explicit back_insert_iterator(_Container& __x) : 
container(_VSTD::addressof(__x)) {}
 _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(const typename 
_Container::value_type& __value_)
 {container->push_back(__value_); return *this;}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(typename 
_Container::value_type&& __value_)
 {container->push_back(_VSTD::move(__value_)); return *this;}
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator*() {return 
*this;}
 _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator++(){return 
*this;}
 _LIBCPP_INLINE_VISIBILITY back_insert_iterator  operator++(int) {return 
*this;}
@@ -816,10 +816,10 @@ public:
 _LIBCPP_INLINE_VISIBILITY explicit front_insert_iterator(_Container& __x) 
: container(_VSTD::addressof(__x)) {}
 _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(const typename 
_Container::value_type& __value_)
 {container->push_front(__value_); return *this;}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(typename 
_Container::value_type&& __value_)
 {container->push_front(_VSTD::move(__value_)); return *this;}
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator*() {return 
*this;}
 _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator++(){return 
*this;}
 _LIBCPP_INLINE_VISIBILITY front_insert_iterator  

[libcxx] r300646 - Cleanup remaining usages of _LIBCPP_HAS_NO_<c++11-feature> in the functional library

2017-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 18 20:28:47 2017
New Revision: 300646

URL: http://llvm.org/viewvc/llvm-project?rev=300646=rev
Log:
Cleanup remaining usages of _LIBCPP_HAS_NO_ in the functional 
library

Modified:
libcxx/trunk/include/__functional_base
libcxx/trunk/include/functional

Modified: libcxx/trunk/include/__functional_base
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__functional_base?rev=300646=300645=300646=diff
==
--- libcxx/trunk/include/__functional_base (original)
+++ libcxx/trunk/include/__functional_base Tue Apr 18 20:28:47 2017
@@ -251,7 +251,7 @@ struct __weak_result_type<_Rp (_Cp::*)(_
 };
 
 
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#ifndef _LIBCPP_CXX03_LANG
 // 3 or more arguments
 
 template 
@@ -296,10 +296,6 @@ struct __weak_result_type<_Rp (_Cp::*)(_
 typedef _Rp result_type;
 };
 
-#endif // _LIBCPP_HAS_NO_VARIADICS
-
-#ifndef _LIBCPP_CXX03_LANG
-
 template 
 struct __invoke_return
 {
@@ -316,7 +312,7 @@ struct __invoke_return
 template 
 struct __invoke_void_return_wrapper
 {
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#ifndef _LIBCPP_CXX03_LANG
 template 
 static _Ret __call(_Args&&... __args) {
 return __invoke(_VSTD::forward<_Args>(__args)...);
@@ -347,7 +343,7 @@ struct __invoke_void_return_wrapper
 template <>
 struct __invoke_void_return_wrapper
 {
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#ifndef _LIBCPP_CXX03_LANG
 template 
 static void __call(_Args&&... __args) {
 __invoke(_VSTD::forward<_Args>(__args)...);
@@ -389,7 +385,7 @@ public:
 // construct/copy/destroy
 _LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) _NOEXCEPT
 : __f_(_VSTD::addressof(__f)) {}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 private: reference_wrapper(type&&); public: // = delete; // do not bind to 
temps
 #endif
 
@@ -397,7 +393,7 @@ public:
 _LIBCPP_INLINE_VISIBILITY operator type&() const _NOEXCEPT {return 
*__f_;}
 _LIBCPP_INLINE_VISIBILITY  type& get() const _NOEXCEPT {return 
*__f_;}
 
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#ifndef _LIBCPP_CXX03_LANG
 // invoke
 template 
 _LIBCPP_INLINE_VISIBILITY
@@ -510,7 +506,7 @@ public:
 operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
 return __invoke(get(), __a0, __a1, __a2);
 }
-#endif // _LIBCPP_HAS_NO_VARIADICS
+#endif // _LIBCPP_CXX03_LANG
 };
 
 
@@ -568,7 +564,7 @@ public:
 
 struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { };
 
-#if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_MEMORY)
+#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_MEMORY)
 extern const allocator_arg_t allocator_arg;
 #else
 constexpr allocator_arg_t allocator_arg = allocator_arg_t();
@@ -611,7 +607,7 @@ template 
 constexpr size_t uses_allocator_v = uses_allocator<_Tp, _Alloc>::value;
 #endif
 
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#ifndef _LIBCPP_CXX03_LANG
 
 // allocator construction
 
@@ -663,7 +659,7 @@ void __user_alloc_construct (_Tp *__stor
  __storage, __a, _VSTD::forward<_Args>(__args)...
 );
 }
-#endif  // _LIBCPP_HAS_NO_VARIADICS
+#endif  // _LIBCPP_CXX03_LANG
 
 _LIBCPP_END_NAMESPACE_STD
 

Modified: libcxx/trunk/include/functional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/functional?rev=300646=300645=300646=diff
==
--- libcxx/trunk/include/functional (original)
+++ libcxx/trunk/include/functional Tue Apr 18 20:28:47 2017
@@ -1264,7 +1264,7 @@ private:
 public:
 _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) _NOEXCEPT : __f_(__f) {}
 
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#ifndef _LIBCPP_CXX03_LANG
 // invoke
 template 
 _LIBCPP_INLINE_VISIBILITY
@@ -1454,7 +1454,7 @@ bool __not_null(function<_Fp> const& __f
 
 } // namespace __function
 
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#ifndef _LIBCPP_CXX03_LANG
 
 namespace __function {
 
@@ -1983,7 +1983,7 @@ void
 swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) 
_NOEXCEPT
 {return __x.swap(__y);}
 
-#else // _LIBCPP_HAS_NO_VARIADICS
+#else // _LIBCPP_CXX03_LANG
 
 #include <__functional_03>
 
@@ -2047,7 +2047,7 @@ struct __is_placeholder {};
 
 
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#ifndef _LIBCPP_CXX03_LANG
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -2347,7 +2347,7 @@ bind(_Fp&& __f, _BoundArgs&&... __bound_
 return type(_VSTD::forward<_Fp>(__f), 
_VSTD::forward<_BoundArgs>(__bound_args)...);
 }
 
-#endif  // _LIBCPP_HAS_NO_VARIADICS
+#endif  // _LIBCPP_CXX03_LANG
 
 #if _LIBCPP_STD_VER > 14
 


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


[libcxx] r300644 - Cleanup remaining usages of _LIBCPP_HAS_NO_<c++11-feature> in tuple and utility

2017-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 18 20:23:39 2017
New Revision: 300644

URL: http://llvm.org/viewvc/llvm-project?rev=300644=rev
Log:
Cleanup remaining usages of _LIBCPP_HAS_NO_ in tuple and utility

Modified:
libcxx/trunk/include/__tuple
libcxx/trunk/include/tuple
libcxx/trunk/include/utility

Modified: libcxx/trunk/include/__tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tuple?rev=300644=300643=300644=diff
==
--- libcxx/trunk/include/__tuple (original)
+++ libcxx/trunk/include/__tuple Tue Apr 18 20:23:39 2017
@@ -85,7 +85,7 @@ template  struct __tuple_like
 
 // tuple specializations
 
-#if !defined(_LIBCPP_HAS_NO_VARIADICS)
+#ifndef _LIBCPP_CXX03_LANG
 
 template  struct __tuple_indices {};
 
@@ -189,7 +189,8 @@ template 
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
 get(const tuple<_Tp...>&&) _NOEXCEPT;
-#endif
+
+#endif // !defined(_LIBCPP_CXX03_LANG)
 
 // pair specializations
 
@@ -205,7 +206,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTE
 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
 get(const pair<_T1, _T2>&) _NOEXCEPT;
 
-#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+#ifndef _LIBCPP_CXX03_LANG
 template 
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
@@ -233,7 +234,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTE
 const _Tp&
 get(const array<_Tp, _Size>&) _NOEXCEPT;
 
-#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+#ifndef _LIBCPP_CXX03_LANG
 template 
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 _Tp&&
@@ -245,8 +246,7 @@ const _Tp&&
 get(const array<_Tp, _Size>&&) _NOEXCEPT;
 #endif
 
-#if !defined(_LIBCPP_HAS_NO_VARIADICS)
-
+#ifndef _LIBCPP_CXX03_LANG
 
 // __tuple_types
 
@@ -468,9 +468,6 @@ template 
 using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type;
 #endif
 
-#endif  // _LIBCPP_HAS_NO_VARIADICS
-
-#ifndef _LIBCPP_CXX03_LANG
 template 
 struct __tuple_like_with_size_imp : false_type {};
 
@@ -495,7 +492,7 @@ struct _LIBCPP_TYPE_VIS __check_tuple_co
 template 
 static constexpr bool __enable_assign() { return false; }
 };
-#endif
+#endif // !defined(_LIBCPP_CXX03_LANG)
 
 #if _LIBCPP_STD_VER > 14
 

Modified: libcxx/trunk/include/tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=300644=300643=300644=diff
==
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Tue Apr 18 20:23:39 2017
@@ -148,7 +148,7 @@ template 
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#ifndef _LIBCPP_CXX03_LANG
 
 
 // __tuple_leaf
@@ -1345,9 +1345,6 @@ template 
 struct _LIBCPP_TEMPLATE_VIS uses_allocator, _Alloc>
 : true_type {};
 
-#endif // _LIBCPP_HAS_NO_VARIADICS
-
-#ifndef _LIBCPP_CXX03_LANG
 template 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -1358,7 +1355,6 @@ pair<_T1, _T2>::pair(piecewise_construct
   second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
 {
 }
-#endif // _LIBCPP_CXX03_LANG
 
 #if _LIBCPP_STD_VER > 14
 template 
@@ -1404,6 +1400,8 @@ _LIBCPP_NOEXCEPT_RETURN(
 
 #endif // _LIBCPP_STD_VER > 14
 
+#endif // !defined(_LIBCPP_CXX03_LANG)
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_TUPLE

Modified: libcxx/trunk/include/utility
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=300644=300643=300644=diff
==
--- libcxx/trunk/include/utility (original)
+++ libcxx/trunk/include/utility Tue Apr 18 20:23:39 2017
@@ -272,14 +272,14 @@ swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 typename conditional
 <
 !is_nothrow_move_constructible<_Tp>::value && 
is_copy_constructible<_Tp>::value,
 const _Tp&,
 _Tp&&
 >::type
-#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#else  // _LIBCPP_CXX03_LANG
 const _Tp&
 #endif
 move_if_noexcept(_Tp& __x) _NOEXCEPT
@@ -293,7 +293,7 @@ template 
 #endif
 
 struct _LIBCPP_TEMPLATE_VIS piecewise_construct_t { };
-#if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_UTILITY)
+#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_UTILITY)
 extern const piecewise_construct_t piecewise_construct;// = 
piecewise_construct_t();
 #else
 constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
@@ -608,8 +608,7 @@ swap(pair<_T1, _T2>& __x, pair<_T1, _T2>
 __x.swap(__y);
 }
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
+#ifndef _LIBCPP_CXX03_LANG
 
 template 
 struct __make_pair_return_impl
@@ -638,7 +637,7 @@ make_pair(_T1&& __t1, _T2&& __t2)
(_VSTD::forward<_T1>(__t1), 

[libcxx] r300643 - Cleanup remaining _LIBCPP_HAS_NO_<c++11-feature> usages in container headers

2017-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 18 20:23:04 2017
New Revision: 300643

URL: http://llvm.org/viewvc/llvm-project?rev=300643=rev
Log:
Cleanup remaining _LIBCPP_HAS_NO_ usages in container headers

Modified:
libcxx/trunk/include/__hash_table
libcxx/trunk/include/__split_buffer
libcxx/trunk/include/__tree
libcxx/trunk/include/ext/hash_map

Modified: libcxx/trunk/include/__hash_table
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=300643=300642=300643=diff
==
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Tue Apr 18 20:23:04 2017
@@ -798,8 +798,7 @@ public:
 _NOEXCEPT_(is_nothrow_copy_constructible::value)
 : __data_(__size, __a) {}
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 __bucket_list_deallocator(__bucket_list_deallocator&& __x)
 _NOEXCEPT_(is_nothrow_move_constructible::value)
@@ -807,8 +806,7 @@ public:
 {
 __x.size() = 0;
 }
-
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
 
 _LIBCPP_INLINE_VISIBILITY
 size_type& size() _NOEXCEPT {return __data_.first();}

Modified: libcxx/trunk/include/__split_buffer
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__split_buffer?rev=300643=300642=300643=diff
==
--- libcxx/trunk/include/__split_buffer (original)
+++ libcxx/trunk/include/__split_buffer Tue Apr 18 20:23:04 2017
@@ -66,7 +66,7 @@ public:
 __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
 ~__split_buffer();
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 __split_buffer(__split_buffer&& __c)
 _NOEXCEPT_(is_nothrow_move_constructible::value);
 __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
@@ -74,7 +74,7 @@ public:
 
_NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
 is_nothrow_move_assignable::value) ||
!__alloc_traits::propagate_on_container_move_assignment::value);
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 
 _LIBCPP_INLINE_VISIBILITY   iterator begin() _NOEXCEPT   {return 
__begin_;}
 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return 
__begin_;}
@@ -99,14 +99,12 @@ public:
 void shrink_to_fit() _NOEXCEPT;
 void push_front(const_reference __x);
 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
-#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+#ifndef _LIBCPP_CXX03_LANG
 void push_front(value_type&& __x);
 void push_back(value_type&& __x);
-#if !defined(_LIBCPP_HAS_NO_VARIADICS)
 template 
 void emplace_back(_Args&&... __args);
-#endif  // !defined(_LIBCPP_HAS_NO_VARIADICS)
-#endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+#endif  // !defined(_LIBCPP_CXX03_LANG)
 
 _LIBCPP_INLINE_VISIBILITY void pop_front() 
{__destruct_at_begin(__begin_+1);}
 _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);}
@@ -343,7 +341,7 @@ __split_buffer<_Tp, _Allocator>::~__spli
 __alloc_traits::deallocate(__alloc(), __first_, capacity());
 }
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 
 template 
 __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
@@ -405,7 +403,7 @@ __split_buffer<_Tp, _Allocator>::operato
 return *this;
 }
 
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 
 template 
 void
@@ -492,7 +490,7 @@ __split_buffer<_Tp, _Allocator>::push_fr
 --__begin_;
 }
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 
 template 
 void
@@ -524,7 +522,7 @@ __split_buffer<_Tp, _Allocator>::push_fr
 --__begin_;
 }
 
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -556,7 +554,7 @@ __split_buffer<_Tp, _Allocator>::push_ba
 ++__end_;
 }
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 
 template 
 void
@@ -588,8 +586,6 @@ __split_buffer<_Tp, _Allocator>::push_ba
 ++__end_;
 }
 
-#ifndef _LIBCPP_HAS_NO_VARIADICS
-
 template 
 template 
 void
@@ -621,9 +617,7 @@ __split_buffer<_Tp, _Allocator>::emplace
 ++__end_;
 }
 
-#endif  // _LIBCPP_HAS_NO_VARIADICS
-
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY

Modified: libcxx/trunk/include/__tree
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tree?rev=300643=300642=300643=diff
==
--- libcxx/trunk/include/__tree (original)
+++ libcxx/trunk/include/__tree Tue Apr 18 20:23:04 2017
@@ -1105,7 +1105,7 @@ public:
 void 

[libcxx] r300637 - Cleanup _LIBCPP_HAS_NO_<c++11-feature> in support headers and final tests

2017-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 18 20:02:49 2017
New Revision: 300637

URL: http://llvm.org/viewvc/llvm-project?rev=300637=rev
Log:
Cleanup _LIBCPP_HAS_NO_ in support headers and final tests

Modified:
libcxx/trunk/test/libcxx/containers/sequences/vector/asan_throw.pass.cpp
libcxx/trunk/test/libcxx/iterators/trivial_iterators.pass.cpp
libcxx/trunk/test/libcxx/strings/iterators.exceptions.pass.cpp
libcxx/trunk/test/libcxx/strings/iterators.noexcept.pass.cpp

libcxx/trunk/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp
libcxx/trunk/test/support/Counter.h
libcxx/trunk/test/support/MoveOnly.h
libcxx/trunk/test/support/allocators.h
libcxx/trunk/test/support/nasty_containers.hpp
libcxx/trunk/test/support/tracked_value.h

Modified: 
libcxx/trunk/test/libcxx/containers/sequences/vector/asan_throw.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/sequences/vector/asan_throw.pass.cpp?rev=300637=300636=300637=diff
==
--- libcxx/trunk/test/libcxx/containers/sequences/vector/asan_throw.pass.cpp 
(original)
+++ libcxx/trunk/test/libcxx/containers/sequences/vector/asan_throw.pass.cpp 
Tue Apr 18 20:02:49 2017
@@ -13,6 +13,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "asan_testing.h"
 
 class X {
@@ -70,7 +71,7 @@ void test_push_back() {
 }
 
 void test_emplace_back() {
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#if TEST_STD_VER >= 11
   std::vector v;
   v.reserve(2);
   v.push_back(X(2));
@@ -83,7 +84,7 @@ void test_emplace_back() {
   }
   assert(v.size() == 1);
   assert(is_contiguous_container_asan_correct(v));
-#endif // _LIBCPP_HAS_NO_VARIADICS
+#endif
 }
 
 void test_insert_range() {
@@ -121,7 +122,7 @@ void test_insert() {
 }
 
 void test_emplace() {
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#if TEST_STD_VER >= 11
   std::vector v;
   v.reserve(3);
   v.insert(v.end(), X(1));
@@ -135,7 +136,7 @@ void test_emplace() {
   }
   assert(v.size() == 2);
   assert(is_contiguous_container_asan_correct(v));
-#endif // _LIBCPP_HAS_NO_VARIADICS
+#endif
 }
 
 void test_insert_range2() {

Modified: libcxx/trunk/test/libcxx/iterators/trivial_iterators.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/iterators/trivial_iterators.pass.cpp?rev=300637=300636=300637=diff
==
--- libcxx/trunk/test/libcxx/iterators/trivial_iterators.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/iterators/trivial_iterators.pass.cpp Tue Apr 18 
20:02:49 2017
@@ -179,7 +179,7 @@ int main()
 static_assert(( 
std::__libcpp_is_trivial_iterator
  ::value), "");
 static_assert(( 
std::__libcpp_is_trivial_iterator::value),
 "");
 
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#if TEST_STD_VER >= 11
 //  Initializer list  (which has no reverse iterators)
 static_assert(( 
std::__libcpp_is_trivial_iterator
  ::value), "");
 static_assert(( 
std::__libcpp_is_trivial_iterator  
  ::value), "");

Modified: libcxx/trunk/test/libcxx/strings/iterators.exceptions.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/strings/iterators.exceptions.pass.cpp?rev=300637=300636=300637=diff
==
--- libcxx/trunk/test/libcxx/strings/iterators.exceptions.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/strings/iterators.exceptions.pass.cpp Tue Apr 18 
20:02:49 2017
@@ -80,7 +80,7 @@ int main()
 static_assert(( 
std::__libcpp_string_gets_noexcept_iterator
  ::value), "");
 static_assert(( 
std::__libcpp_string_gets_noexcept_iterator::value),
 "");
 
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#if TEST_STD_VER >= 11
 //  Initializer list  (which has no reverse iterators)
 static_assert(( 
std::__libcpp_string_gets_noexcept_iterator
  ::value), "");
 static_assert(( 
std::__libcpp_string_gets_noexcept_iterator
::value), "");

Modified: libcxx/trunk/test/libcxx/strings/iterators.noexcept.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/strings/iterators.noexcept.pass.cpp?rev=300637=300636=300637=diff
==
--- libcxx/trunk/test/libcxx/strings/iterators.noexcept.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/strings/iterators.noexcept.pass.cpp Tue Apr 18 
20:02:49 2017
@@ -28,6 +28,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "test_iterators.h"
 
 int main()
@@ -72,7 +73,7 @@ 

[PATCH] D32187: [CodeGen][ObjC]

2017-04-18 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 95667.
ahatanak added a comment.

Unconditionally ban jumping into body of ObjC fast enumeration loop.


https://reviews.llvm.org/D32187

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/JumpDiagnostics.cpp
  lib/Sema/SemaStmt.cpp
  test/SemaObjC/foreach.m


Index: test/SemaObjC/foreach.m
===
--- test/SemaObjC/foreach.m
+++ test/SemaObjC/foreach.m
@@ -55,3 +55,27 @@
   for (obj.prop in collection) { /* expected-error {{selector element is not a 
valid lvalue}} */
   }
 }
+
+int cond();
+
+void test3(NSObject *a0, NSObject *a1) {
+  for (id i in a0) { /* expected-note 2 {{jump enters Objective-c fast 
enumeration loop body}} */
+for (id j in a1) { /* expected-note 2 {{jump enters Objective-c fast 
enumeration loop body}} */
+  (void)i, (void)j;
+label0:
+  if (cond())
+goto label1;
+}
+label1:
+if (cond())
+  goto label0; /* expected-error {{cannot jump from this goto statement to 
its label}} */
+if (cond())
+  goto label2;
+  }
+
+label2:
+  if (cond())
+goto label0; /* expected-error {{cannot jump from this goto statement to 
its label}} */
+  if (cond())
+goto label1; /* expected-error{{cannot jump from this goto statement to 
its label}} */
+}
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -1783,6 +1783,7 @@
 Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc,
  Stmt *First, Expr *collection,
  SourceLocation RParenLoc) {
+  getCurFunction()->setHasBranchProtectedScope();
 
   ExprResult CollectionExprResult =
 CheckObjCForCollectionOperand(ForLoc, collection);
Index: lib/Sema/JumpDiagnostics.cpp
===
--- lib/Sema/JumpDiagnostics.cpp
+++ lib/Sema/JumpDiagnostics.cpp
@@ -287,6 +287,15 @@
 IndirectJumpTargets.push_back(cast(S)->getLabel());
 break;
 
+  case Stmt::ObjCForCollectionStmtClass: {
+auto *CS = cast(S);
+unsigned Diag = diag::note_protected_by_objc_fast_enumeration;
+unsigned NewParentScope = Scopes.size();
+Scopes.push_back(GotoScope(ParentScope, Diag, 0, S->getLocStart()));
+BuildScopeInformation(CS->getBody(), NewParentScope);
+return;
+  }
+
   case Stmt::IndirectGotoStmtClass:
 // "goto *&" is a special case which we treat as equivalent
 // to a normal goto.  In addition, we don't calculate scope in the
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -4981,6 +4981,8 @@
   "jump enters controlled statement of if available">;
 def note_protected_by_vla : Note<
   "jump bypasses initialization of variable length array">;
+def note_protected_by_objc_fast_enumeration : Note<
+  "jump enters Objective-c fast enumeration loop body">;
 def note_protected_by_objc_try : Note<
   "jump bypasses initialization of @try block">;
 def note_protected_by_objc_catch : Note<


Index: test/SemaObjC/foreach.m
===
--- test/SemaObjC/foreach.m
+++ test/SemaObjC/foreach.m
@@ -55,3 +55,27 @@
   for (obj.prop in collection) { /* expected-error {{selector element is not a valid lvalue}} */
   }
 }
+
+int cond();
+
+void test3(NSObject *a0, NSObject *a1) {
+  for (id i in a0) { /* expected-note 2 {{jump enters Objective-c fast enumeration loop body}} */
+for (id j in a1) { /* expected-note 2 {{jump enters Objective-c fast enumeration loop body}} */
+  (void)i, (void)j;
+label0:
+  if (cond())
+goto label1;
+}
+label1:
+if (cond())
+  goto label0; /* expected-error {{cannot jump from this goto statement to its label}} */
+if (cond())
+  goto label2;
+  }
+
+label2:
+  if (cond())
+goto label0; /* expected-error {{cannot jump from this goto statement to its label}} */
+  if (cond())
+goto label1; /* expected-error{{cannot jump from this goto statement to its label}} */
+}
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -1783,6 +1783,7 @@
 Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc,
  Stmt *First, Expr *collection,
  SourceLocation RParenLoc) {
+  getCurFunction()->setHasBranchProtectedScope();
 
   ExprResult CollectionExprResult =
 CheckObjCForCollectionOperand(ForLoc, collection);
Index: lib/Sema/JumpDiagnostics.cpp
===
--- lib/Sema/JumpDiagnostics.cpp
+++ lib/Sema/JumpDiagnostics.cpp
@@ -287,6 +287,15 @@
 IndirectJumpTargets.push_back(cast(S)->getLabel());
  

[libcxx] r300635 - Cleanup _LIBCPP_HAS_NO_<c++11-feature> in the utilities library

2017-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 18 19:56:32 2017
New Revision: 300635

URL: http://llvm.org/viewvc/llvm-project?rev=300635=rev
Log:
Cleanup _LIBCPP_HAS_NO_ in the utilities library

Modified:
libcxx/trunk/test/std/utilities/meta/meta.help/integral_constant.pass.cpp

libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cons/default.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cons/rep.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.nonmember/op_times_rep.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.special/max.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.special/min.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.special/zero.pass.cpp

libcxx/trunk/test/std/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp

libcxx/trunk/test/std/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp

libcxx/trunk/test/std/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp

libcxx/trunk/test/std/utilities/utility/pairs/pair.piecewise/piecewise_construct.pass.cpp
libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.help/integral_constant.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.help/integral_constant.pass.cpp?rev=300635=300634=300635=diff
==
--- libcxx/trunk/test/std/utilities/meta/meta.help/integral_constant.pass.cpp 
(original)
+++ libcxx/trunk/test/std/utilities/meta/meta.help/integral_constant.pass.cpp 
Tue Apr 18 19:56:32 2017
@@ -22,11 +22,11 @@ int main()
 static_assert(_5::value == 5, "");
 static_assert((std::is_same<_5::value_type, int>::value), "");
 static_assert((std::is_same<_5::type, _5>::value), "");
-#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+#if TEST_STD_VER >= 11
 static_assert((_5() == 5), "");
-#else
-assert(_5() == 5);
 #endif
+assert(_5() == 5);
+
 
 #if TEST_STD_VER > 11
 static_assert ( _5{}() == 5, "" );

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp?rev=300635=300634=300635=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp
 Tue Apr 18 19:56:32 2017
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03
+
 // type_traits
 
 // aligned_union
@@ -17,7 +19,6 @@
 
 int main()
 {
-#ifndef _LIBCPP_HAS_NO_VARIADICS
 {
 typedef std::aligned_union<10, char >::type T1;
 #if TEST_STD_VER > 11
@@ -90,5 +91,4 @@ int main()
 static_assert(std::alignment_of::value == 4, "");
 static_assert(sizeof(T1) == 4, "");
 }
-#endif
 }

Modified: 

[PATCH] D32207: Corrrect warn_unused_result attribute

2017-04-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.

The original idea was that if the attribute on an operator, that the 
return-value unused-ness wouldn't matter.  However, all of the operators except 
postfix inc/dec return references!  References don't result in this warning 
anyway, so those are already excluded.

However, the existing patch(in addition to missing a bunch of valid cases, such 
as a function returning a copy) would still hit non-member operators anyway!  
This patch removes the previous condition (if our current function is in the 
warn-unused-result'ed type) and replaces it with one that explicitly checks for 
post inc/dec (since these are likely going to be SO common that warning on them 
would be extreme).


https://reviews.llvm.org/D32207

Files:
  include/clang/AST/Decl.h
  lib/AST/Decl.cpp
  test/SemaCXX/warn-unused-result.cpp


Index: test/SemaCXX/warn-unused-result.cpp
===
--- test/SemaCXX/warn-unused-result.cpp
+++ test/SemaCXX/warn-unused-result.cpp
@@ -160,3 +160,41 @@
   (void)noexcept(f(), false); // Should not warn.
 }
 }
+namespace {
+// C++ Methods should warn even in their own class. Post increment/decrement
+// are special-cased to not warn for return-type due to ubiquitousness.
+struct[[clang::warn_unused_result]] S {
+  S DoThing() { return {}; };
+  S operator++(int) { return {}; };
+  S operator--(int) { return {}; };
+  S operator++() { return {}; };
+  S operator--() { return {}; };
+};
+
+struct[[clang::warn_unused_result]] P {
+  P DoThing() { return {}; };
+};
+
+P operator++(const P &, int) { return {}; };
+P operator++(const P &) { return {}; };
+P operator--(const P &, int) { return {}; };
+P operator--(const P &) { return {}; };
+
+void f() {
+  S s;
+  P p;
+  s.DoThing(); // expected-warning {{ignoring return value}}
+  p.DoThing(); // expected-warning {{ignoring return value}}
+  // Special case the following to not warn.
+  s++;
+  s--;
+  p++;
+  p--;
+  // Improperly written prefix operators should still warn.
+  ++s; // expected-warning {{ignoring return value}}
+  --s; // expected-warning {{ignoring return value}}
+  ++p; // expected-warning {{ignoring return value}}
+  --p; // expected-warning {{ignoring return value}}
+
+}
+}
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -3004,8 +3004,11 @@
   QualType RetType = getReturnType();
   if (RetType->isRecordType()) {
 const CXXRecordDecl *Ret = RetType->getAsCXXRecordDecl();
-const auto *MD = dyn_cast(this);
-if (Ret && !(MD && MD->getCorrespondingMethodInClass(Ret, true))) {
+auto OpCode = getOverloadedOperator();
+bool IsPostfix =
+(OpCode == OO_PlusPlus || OpCode == OO_MinusMinus) &&
+(this->getNumParams() + (isa(this) ? 1 : 0)) == 2;
+if (Ret && !IsPostfix) {
   if (const auto *R = Ret->getAttr())
 return R;
 }
Index: include/clang/AST/Decl.h
===
--- include/clang/AST/Decl.h
+++ include/clang/AST/Decl.h
@@ -2082,10 +2082,9 @@
   const Attr *getUnusedResultAttr() const;
 
   /// \brief Returns true if this function or its return type has the
-  /// warn_unused_result attribute. If the return type has the attribute and
-  /// this function is a method of the return type's class, then false will be
-  /// returned to avoid spurious warnings on member methods such as assignment
-  /// operators.
+  /// warn_unused_result attribute. If the return type has the attribute,
+  /// and this function is a post-increment operator, then false will be 
returned
+  /// to avoid valid, albeit ubiquitous warnings.
   bool hasUnusedResultAttr() const { return getUnusedResultAttr() != nullptr; }
 
   /// \brief Returns the storage class as written in the source. For the


Index: test/SemaCXX/warn-unused-result.cpp
===
--- test/SemaCXX/warn-unused-result.cpp
+++ test/SemaCXX/warn-unused-result.cpp
@@ -160,3 +160,41 @@
   (void)noexcept(f(), false); // Should not warn.
 }
 }
+namespace {
+// C++ Methods should warn even in their own class. Post increment/decrement
+// are special-cased to not warn for return-type due to ubiquitousness.
+struct[[clang::warn_unused_result]] S {
+  S DoThing() { return {}; };
+  S operator++(int) { return {}; };
+  S operator--(int) { return {}; };
+  S operator++() { return {}; };
+  S operator--() { return {}; };
+};
+
+struct[[clang::warn_unused_result]] P {
+  P DoThing() { return {}; };
+};
+
+P operator++(const P &, int) { return {}; };
+P operator++(const P &) { return {}; };
+P operator--(const P &, int) { return {}; };
+P operator--(const P &) { return {}; };
+
+void f() {
+  S s;
+  P p;
+  s.DoThing(); // expected-warning {{ignoring return value}}
+  p.DoThing(); // expected-warning {{ignoring return value}}
+  // Special case the following to not warn.
+  

[libcxx] r300633 - Cleanup _LIBCPP_HAS_NO_<c++11-feature> in the string library.

2017-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 18 19:28:44 2017
New Revision: 300633

URL: http://llvm.org/viewvc/llvm-project?rev=300633=rev
Log:
Cleanup _LIBCPP_HAS_NO_ in the string library.

Modified:
libcxx/trunk/include/string

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.nonmembers/string_op+/pointer_string.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.nonmembers/string_op+/string_pointer.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.nonmembers/string_op+/string_string.pass.cpp

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=300633=300632=300633=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Tue Apr 18 19:28:44 2017
@@ -763,7 +763,7 @@ public:
 basic_string(const basic_string& __str);
 basic_string(const basic_string& __str, const allocator_type& __a);
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 basic_string(basic_string&& __str)
 #if _LIBCPP_STD_VER <= 14
@@ -774,7 +774,7 @@ public:
 
 _LIBCPP_INLINE_VISIBILITY
 basic_string(basic_string&& __str, const allocator_type& __a);
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY basic_string(const _CharT* __s);
 _LIBCPP_INLINE_VISIBILITY
 basic_string(const _CharT* __s, const _Allocator& __a);
@@ -806,12 +806,12 @@ public:
 template
 _LIBCPP_INLINE_VISIBILITY
 basic_string(_InputIterator __first, _InputIterator __last, const 
allocator_type& __a);
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 basic_string(initializer_list<_CharT> __il);
 _LIBCPP_INLINE_VISIBILITY
 basic_string(initializer_list<_CharT> __il, const _Allocator& __a);
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#endif  // _LIBCPP_CXX03_LANG
 
 inline ~basic_string();
 
@@ -825,17 +825,15 @@ public:
 #endif
 _LIBCPP_INLINE_VISIBILITY
 basic_string& operator=(__self_view __sv)  {return assign(__sv);}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 basic_string& operator=(basic_string&& __str)
 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, 
__alloc_traits>::value));
+ _LIBCPP_INLINE_VISIBILITY
+basic_string& operator=(initializer_list __il) {return 
assign(__il.begin(), __il.size());}
 #endif
 _LIBCPP_INLINE_VISIBILITY basic_string& operator=(const value_type* __s) 
{return assign(__s);}
 basic_string& operator=(value_type __c);
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
-_LIBCPP_INLINE_VISIBILITY
-basic_string& operator=(initializer_list __il) {return 
assign(__il.begin(), __il.size());}
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
 #if _LIBCPP_DEBUG_LEVEL >= 2
 _LIBCPP_INLINE_VISIBILITY
@@ -918,9 +916,9 @@ public:
 _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(__self_view __sv)   
   {return append(__sv);}
 _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const value_type* __s)  
   {return append(__s);}
 _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(value_type __c) 
   {push_back(__c); return *this;}
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY basic_string& 
operator+=(initializer_list __il) {return append(__il);}
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#endif  // _LIBCPP_CXX03_LANG
 
 _LIBCPP_INLINE_VISIBILITY
 basic_string& append(const basic_string& __str);
@@ -968,10 +966,10 @@ public:
   return __append_forward_unsafe(__first, __last);
 }
 
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 basic_string& append(initializer_list __il) {return 
append(__il.begin(), __il.size());}
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#endif  // _LIBCPP_CXX03_LANG
 
 void push_back(value_type __c);
 _LIBCPP_INLINE_VISIBILITY
@@ -985,7 +983,7 @@ public:
 basic_string& assign(__self_view __sv) { return assign(__sv.data(), 
__sv.size()); }
 _LIBCPP_INLINE_VISIBILITY
 basic_string& 

[libcxx] r300632 - Cleanup _LIBCPP_HAS_NO_<c++11-feature> macros in the numeric tests and headers

2017-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 18 19:23:45 2017
New Revision: 300632

URL: http://llvm.org/viewvc/llvm-project?rev=300632=rev
Log:
Cleanup _LIBCPP_HAS_NO_ macros in the numeric tests and headers

Modified:
libcxx/trunk/include/random
libcxx/trunk/include/valarray

libcxx/trunk/test/std/numerics/complex.number/complex.literals/literals.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.literals/literals1.fail.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.members/construct.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.special/double_float_explicit.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.special/double_float_implicit.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.special/float_double_explicit.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp

libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/initializer_list_assign.pass.cpp

libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/initializer_list.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/values.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_init.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_default.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_init.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_default.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_init_func.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_init_func.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_default.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_init_func.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_init_func.pass.cpp
libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp
libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/values.pass.cpp
libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.util/rand.util.seedseq/initializer_list.pass.cpp

Modified: libcxx/trunk/include/random
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/random?rev=300632=300631=300632=diff
==
--- libcxx/trunk/include/random (original)
+++ libcxx/trunk/include/random Tue Apr 18 19:23:45 2017
@@ -2826,7 +2826,7 @@ public:
 static _LIBCPP_CONSTEXPR const size_t block_size = __p;
 static _LIBCPP_CONSTEXPR const size_t used_block = __r;
 
-#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+#ifdef _LIBCPP_CXX03_LANG
 static const result_type _Min = _Engine::_Min;
 static const result_type _Max = _Engine::_Max;
 #else
@@ -2845,11 +2845,11 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 explicit discard_block_engine(const _Engine& __e)
 : __e_(__e), __n_(0) {}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 explicit discard_block_engine(_Engine&& __e)
 : __e_(_VSTD::move(__e)), __n_(0) {}
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 explicit discard_block_engine(result_type __sd) : __e_(__sd), __n_(0) {}
 template
@@ -3014,7 +3014,7 @@ private:
 result_type,
 _Engine_result_type
 >::type _Working_result_type;
-#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+#ifdef _LIBCPP_CXX03_LANG
 static const _Working_result_type _Rp = _Engine::_Max - _Engine::_Min
   + _Working_result_type(1);
 #else
@@ -3055,11 +3055,11 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 explicit independent_bits_engine(const _Engine& __e)
 : __e_(__e) {}
-#ifndef 

r300628 - Use less temporary AttributeLists NFC

2017-04-18 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Apr 18 18:50:03 2017
New Revision: 300628

URL: http://llvm.org/viewvc/llvm-project?rev=300628=rev
Log:
Use less temporary AttributeLists NFC

Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGCall.h
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h   (contents, props changed)

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=300628=300627=300628=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Apr 18 18:50:03 2017
@@ -1762,7 +1762,7 @@ void CodeGenModule::AddDefaultFnAttrs(ll
 
 void CodeGenModule::ConstructAttributeList(
 StringRef Name, const CGFunctionInfo , CGCalleeInfo CalleeInfo,
-AttributeListType , unsigned , bool AttrOnCallSite) {
+llvm::AttributeList , unsigned , bool AttrOnCallSite) 
{
   llvm::AttrBuilder FuncAttrs;
   llvm::AttrBuilder RetAttrs;
 
@@ -1931,13 +1931,8 @@ void CodeGenModule::ConstructAttributeLi
   RetAttrs.addAttribute(llvm::Attribute::NonNull);
   }
 
-  // Attach return attributes.
-  if (RetAttrs.hasAttributes()) {
-PAL.push_back(llvm::AttributeList::get(
-getLLVMContext(), llvm::AttributeList::ReturnIndex, RetAttrs));
-  }
-
   bool hasUsedSRet = false;
+  SmallVector ArgAttrs(IRFunctionArgs.totalIRArgs());
 
   // Attach attributes to sret.
   if (IRFunctionArgs.hasSRetArg()) {
@@ -1946,16 +1941,16 @@ void CodeGenModule::ConstructAttributeLi
 hasUsedSRet = true;
 if (RetAI.getInReg())
   SRETAttrs.addAttribute(llvm::Attribute::InReg);
-PAL.push_back(llvm::AttributeList::get(
-getLLVMContext(), IRFunctionArgs.getSRetArgNo() + 1, SRETAttrs));
+ArgAttrs[IRFunctionArgs.getSRetArgNo()] =
+llvm::AttributeSet::get(getLLVMContext(), SRETAttrs);
   }
 
   // Attach attributes to inalloca argument.
   if (IRFunctionArgs.hasInallocaArg()) {
 llvm::AttrBuilder Attrs;
 Attrs.addAttribute(llvm::Attribute::InAlloca);
-PAL.push_back(llvm::AttributeList::get(
-getLLVMContext(), IRFunctionArgs.getInallocaArgNo() + 1, Attrs));
+ArgAttrs[IRFunctionArgs.getInallocaArgNo()] =
+llvm::AttributeSet::get(getLLVMContext(), Attrs);
   }
 
   unsigned ArgNo = 0;
@@ -1968,10 +1963,12 @@ void CodeGenModule::ConstructAttributeLi
 
 // Add attribute for padding argument, if necessary.
 if (IRFunctionArgs.hasPaddingArg(ArgNo)) {
-  if (AI.getPaddingInReg())
-PAL.push_back(llvm::AttributeList::get(
-getLLVMContext(), IRFunctionArgs.getPaddingArgNo(ArgNo) + 1,
-llvm::Attribute::InReg));
+  if (AI.getPaddingInReg()) {
+ArgAttrs[IRFunctionArgs.getPaddingArgNo(ArgNo)] =
+llvm::AttributeSet::get(
+getLLVMContext(),
+llvm::AttrBuilder().addAttribute(llvm::Attribute::InReg));
+  }
 }
 
 // 'restrict' -> 'noalias' is done in EmitFunctionProlog when we
@@ -2086,15 +2083,15 @@ void CodeGenModule::ConstructAttributeLi
   unsigned FirstIRArg, NumIRArgs;
   std::tie(FirstIRArg, NumIRArgs) = IRFunctionArgs.getIRArgs(ArgNo);
   for (unsigned i = 0; i < NumIRArgs; i++)
-PAL.push_back(llvm::AttributeList::get(getLLVMContext(),
-   FirstIRArg + i + 1, Attrs));
+ArgAttrs[FirstIRArg + i] =
+llvm::AttributeSet::get(getLLVMContext(), Attrs);
 }
   }
   assert(ArgNo == FI.arg_size());
 
-  if (FuncAttrs.hasAttributes())
-PAL.push_back(llvm::AttributeList::get(
-getLLVMContext(), llvm::AttributeList::FunctionIndex, FuncAttrs));
+  AttrList = llvm::AttributeList::get(
+  getLLVMContext(), llvm::AttributeSet::get(getLLVMContext(), FuncAttrs),
+  llvm::AttributeSet::get(getLLVMContext(), RetAttrs), ArgAttrs);
 }
 
 /// An argument came in as a promoted argument; demote it back to its
@@ -2205,8 +2202,7 @@ void CodeGenFunction::EmitFunctionProlog
   if (IRFunctionArgs.hasSRetArg()) {
 auto AI = cast(FnArgs[IRFunctionArgs.getSRetArgNo()]);
 AI->setName("agg.result");
-AI->addAttr(llvm::AttributeList::get(getLLVMContext(), AI->getArgNo() + 1,
- llvm::Attribute::NoAlias));
+AI->addAttr(llvm::Attribute::NoAlias);
   }
 
   // Track if we received the parameter as a pointer (indirect, byval, or
@@ -2297,9 +2293,7 @@ void CodeGenFunction::EmitFunctionProlog
 if (const ParmVarDecl *PVD = dyn_cast(Arg)) {
   if (getNonNullAttr(CurCodeDecl, PVD, PVD->getType(),
  PVD->getFunctionScopeIndex()))
-AI->addAttr(llvm::AttributeList::get(getLLVMContext(),
- AI->getArgNo() + 1,
- 

[libcxx] r300627 - Cleanup _LIBCPP_HAS_NO_<c++11-features> macro usage in regex

2017-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 18 18:42:15 2017
New Revision: 300627

URL: http://llvm.org/viewvc/llvm-project?rev=300627=rev
Log:
Cleanup _LIBCPP_HAS_NO_ macro usage in regex

Modified:
libcxx/trunk/include/regex
libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.il.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.assign/il.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp

Modified: libcxx/trunk/include/regex
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=300627=300626=300627=diff
==
--- libcxx/trunk/include/regex (original)
+++ libcxx/trunk/include/regex Tue Apr 18 18:42:15 2017
@@ -2539,14 +2539,14 @@ public:
 : __flags_(__f), __marked_count_(0), __loop_count_(0), 
__open_count_(0),
   __end_(0)
 {__parse(__first, __last);}
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 basic_regex(initializer_list __il,
 flag_type __f = regex_constants::ECMAScript)
 : __flags_(__f), __marked_count_(0), __loop_count_(0), 
__open_count_(0),
   __end_(0)
 {__parse(__il.begin(), __il.end());}
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#endif  // _LIBCPP_CXX03_LANG
 
 //~basic_regex() = default;
 
@@ -2555,11 +2555,11 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 basic_regex& operator=(const value_type* __p)
 {return assign(__p);}
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 basic_regex& operator=(initializer_list __il)
 {return assign(__il);}
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#endif  // _LIBCPP_CXX03_LANG
 template 
 _LIBCPP_INLINE_VISIBILITY
 basic_regex& operator=(const basic_string& __p)
@@ -2569,7 +2569,7 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 basic_regex& assign(const basic_regex& __that)
 {return *this = __that;}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 basic_regex& assign(basic_regex&& __that) _NOEXCEPT
 {return *this = _VSTD::move(__that);}
@@ -2626,14 +2626,14 @@ public:
 return assign(basic_regex(__first, __last, __f));
 }
 
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#ifndef _LIBCPP_CXX03_LANG
 
 _LIBCPP_INLINE_VISIBILITY
 basic_regex& assign(initializer_list __il,
 flag_type __f = regex_constants::ECMAScript)
 {return assign(__il.begin(), __il.end(), __f);}
 
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#endif  // _LIBCPP_CXX03_LANG
 
 // const operations:
 _LIBCPP_INLINE_VISIBILITY
@@ -6213,7 +6213,7 @@ public:
  regex_constants::match_default) = delete;
 #endif
 
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#ifndef _LIBCPP_CXX03_LANG
 regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator 
__b,
  const regex_type& __re,
  initializer_list __submatches,
@@ -6227,7 +6227,7 @@ public:
  regex_constants::match_flag_type __m =
regex_constants::match_default) = 
delete;
 #endif
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#endif  // _LIBCPP_CXX03_LANG
 template 
 regex_token_iterator(_BidirectionalIterator __a,
  _BidirectionalIterator __b,
@@ -6327,7 +6327,7 @@ regex_token_iterator<_BidirectionalItera
 __init(__a, __b);
 }
 
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#ifndef _LIBCPP_CXX03_LANG
 
 template 
 regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
@@ -6342,7 +6342,7 @@ regex_token_iterator<_BidirectionalItera
 __init(__a, __b);
 }
 
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#endif  // _LIBCPP_CXX03_LANG
 
 template 
 template 

Modified: 
libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp?rev=300627=300626=300627=diff
==
--- libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp 
(original)
+++ libcxx/trunk/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp 
Tue Apr 18 18:42:15 2017
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03
+
 // 
 
 // class regex_token_iterator
@@ -23,7 +25,6 @@
 
 int main()
 {
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 {
 std::regex 

[libcxx] r300626 - Cleanup _LIBCPP_HAS_NO_<c++11-feature> in the input.output library

2017-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 18 18:38:41 2017
New Revision: 300626

URL: http://llvm.org/viewvc/llvm-project?rev=300626=rev
Log:
Cleanup _LIBCPP_HAS_NO_ in the input.output library

Modified:
libcxx/trunk/include/fstream
libcxx/trunk/include/istream
libcxx/trunk/include/ostream
libcxx/trunk/include/sstream
libcxx/trunk/include/strstream

libcxx/trunk/test/std/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp

libcxx/trunk/test/std/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp

libcxx/trunk/test/std/input.output/file.streams/fstreams/fstream.assign/move_assign.pass.cpp

libcxx/trunk/test/std/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp

libcxx/trunk/test/std/input.output/file.streams/fstreams/ifstream.assign/move_assign.pass.cpp

libcxx/trunk/test/std/input.output/file.streams/fstreams/ifstream.cons/move.pass.cpp

libcxx/trunk/test/std/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp

libcxx/trunk/test/std/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/move_assign.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/move.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream/istream.assign/move_assign.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.assign/move_assign.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.cons/move.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.rvalue/CharT_pointer.pass.cpp

libcxx/trunk/test/std/input.output/string.streams/istringstream/istringstream.assign/move.pass.cpp

libcxx/trunk/test/std/input.output/string.streams/istringstream/istringstream.cons/move.pass.cpp

libcxx/trunk/test/std/input.output/string.streams/ostringstream/ostringstream.assign/move.pass.cpp

libcxx/trunk/test/std/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp

libcxx/trunk/test/std/input.output/string.streams/stringstream.cons/move.pass.cpp

libcxx/trunk/test/std/input.output/string.streams/stringstream.cons/move2.pass.cpp

libcxx/trunk/test/std/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp

Modified: libcxx/trunk/include/fstream
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/fstream?rev=300626=300625=300626=diff
==
--- libcxx/trunk/include/fstream (original)
+++ libcxx/trunk/include/fstream Tue Apr 18 18:38:41 2017
@@ -193,13 +193,13 @@ public:
 
 // 27.9.1.2 Constructors/destructor:
 basic_filebuf();
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 basic_filebuf(basic_filebuf&& __rhs);
 #endif
 virtual ~basic_filebuf();
 
 // 27.9.1.3 Assign/swap:
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 basic_filebuf& operator=(basic_filebuf&& __rhs);
 #endif
@@ -276,7 +276,7 @@ basic_filebuf<_CharT, _Traits>::basic_fi
 setbuf(0, 4096);
 }
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 
 template 
 basic_filebuf<_CharT, _Traits>::basic_filebuf(basic_filebuf&& __rhs)
@@ -352,7 +352,7 @@ basic_filebuf<_CharT, _Traits>::operator
 return *this;
 }
 
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 
 template 
 basic_filebuf<_CharT, _Traits>::~basic_filebuf()
@@ -1017,12 +1017,10 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 explicit basic_ifstream(const string& __s, ios_base::openmode __mode = 
ios_base::in);
 #endif
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 basic_ifstream(basic_ifstream&& __rhs);
-#endif
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 _LIBCPP_INLINE_VISIBILITY
 basic_ifstream& operator=(basic_ifstream&& __rhs);
 #endif
@@ -1071,7 +1069,7 @@ basic_ifstream<_CharT, _Traits>::basic_i
 }
 #endif
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 
 template 
 inline
@@ -1092,7 +1090,7 @@ basic_ifstream<_CharT, _Traits>::operato
 return *this;
 }
 
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 
 template 
 inline
@@ -1177,12 +1175,10 @@ public:
 explicit basic_ofstream(const char* __s, ios_base::openmode __mode = 
ios_base::out);
 _LIBCPP_INLINE_VISIBILITY
 explicit basic_ofstream(const string& __s, ios_base::openmode __mode = 
ios_base::out);
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 basic_ofstream(basic_ofstream&& __rhs);
-#endif
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 _LIBCPP_INLINE_VISIBILITY
 

Re: [clang-tools-extra] r300588 - [clang-tidy] Address a few late comments.

2017-04-18 Thread Alexander Kornienko via cfe-commits
Thanks! One nit: StringRef doesn't need to be qualified.

On Apr 18, 2017 11:00 PM, "Haojian Wu via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

Author: hokein
Date: Tue Apr 18 15:47:34 2017
New Revision: 300588

URL: http://llvm.org/viewvc/llvm-project?rev=300588=rev
Log:
[clang-tidy] Address a few late comments.

Modified:
clang-tools-extra/trunk/clang-tidy/performance/
InefficientVectorOperationCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/performance/
InefficientVectorOperationCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
trunk/clang-tidy/performance/InefficientVectorOperationChec
k.cpp?rev=300588=300587=300588=diff

==
--- clang-tools-extra/trunk/clang-tidy/performance/
InefficientVectorOperationCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/performance/
InefficientVectorOperationCheck.cpp Tue Apr 18 15:47:34 2017
@@ -99,7 +99,8 @@ void InefficientVectorOperationCheck::re

 void InefficientVectorOperationCheck::check(
 const MatchFinder::MatchResult ) {
-  if (Result.Context->getDiagnostics().hasUncompilableErrorOccurred())
+  auto* Context = Result.Context;
+  if (Context->getDiagnostics().hasUncompilableErrorOccurred())
 return;

   const SourceManager  = *Result.SourceManager;
@@ -113,7 +114,7 @@ void InefficientVectorOperationCheck::ch

   llvm::SmallPtrSet AllVectorVarRefs =
   utils::decl_ref_expr::allDeclRefExprs(*VectorVarDecl, *LoopParent,
-*Result.Context);
+*Context);
   for (const auto *Ref : AllVectorVarRefs) {
 // Skip cases where there are usages (defined as DeclRefExpr that
refers to
 // "v") of vector variable `v` before the for loop. We consider these
usages
@@ -128,19 +129,19 @@ void InefficientVectorOperationCheck::ch
 }
   }

-  llvm::StringRef LoopEndSource = clang::Lexer::getSourceText(
+  llvm::StringRef LoopEndSource = Lexer::getSourceText(
   CharSourceRange::getTokenRange(LoopEndExpr->getSourceRange()), SM,
-  clang::LangOptions());
-  llvm::StringRef VectorVarName = clang::Lexer::getSourceText(
+  Context->getLangOpts());
+  llvm::StringRef VectorVarName = Lexer::getSourceText(
   CharSourceRange::getTokenRange(
   PushBackCall->getImplicitObjectArgument()->getSourceRange()),
-  SM, clang::LangOptions());
+  SM, Context->getLangOpts());
   std::string ReserveStmt =
   (VectorVarName + ".reserve(" + LoopEndSource + ");\n").str();

   diag(PushBackCall->getLocStart(),
"'push_back' is called inside a loop; "
-   "consider pre-allocating the vector capacity before the loop.")
+   "consider pre-allocating the vector capacity before the loop")
   << FixItHint::CreateInsertion(ForLoop->getLocStart(), ReserveStmt);
 }



___
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


[PATCH] D31561: cmath: Skip Libc for integral types in isinf, etc.

2017-04-18 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: libcxx/include/math.h:400
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if::value, int>::type
+fpclassify(_A1 __lcpp_x) _NOEXCEPT

hfinkel wrote:
> Maybe we should predicate this, and other infinity-related functions, on 
> std::numeric_limits<_A1>::has_infinity. That seems more general, and safer 
> for potential user-defined types.
I don't think we need to worry about user-defined types.  The standard limits 
the parameters to "arithmetic types" and in [basic.fundamental] it lists 
exactly what those types are.  


https://reviews.llvm.org/D31561



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


[libcxx] r300625 - Cleanup _LIBCPP_HAS_NO_<c++11-feature> in algorithm

2017-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 18 18:26:47 2017
New Revision: 300625

URL: http://llvm.org/viewvc/llvm-project?rev=300625=rev
Log:
Cleanup _LIBCPP_HAS_NO_ in algorithm

Modified:
libcxx/trunk/include/algorithm

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.remove/remove_if.pass.cpp

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.swap/swap_ranges.pass.cpp

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.unique/unique.pass.cpp

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.unique/unique_pred.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=300625=300624=300625=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Tue Apr 18 18:26:47 2017
@@ -2548,7 +2548,7 @@ min(const _Tp& __a, const _Tp& __b)
 return _VSTD::min(__a, __b, __less<_Tp>());
 }
 
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#ifndef _LIBCPP_CXX03_LANG
 
 template
 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
@@ -2566,7 +2566,7 @@ min(initializer_list<_Tp> __t)
 return *_VSTD::min_element(__t.begin(), __t.end(), __less<_Tp>());
 }
 
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#endif  // _LIBCPP_CXX03_LANG
 
 // max_element
 
@@ -2613,7 +2613,7 @@ max(const _Tp& __a, const _Tp& __b)
 return _VSTD::max(__a, __b, __less<_Tp>());
 }
 
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#ifndef _LIBCPP_CXX03_LANG
 
 template
 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
@@ -2631,7 +2631,7 @@ max(initializer_list<_Tp> __t)
 return *_VSTD::max_element(__t.begin(), __t.end(), __less<_Tp>());
 }
 
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#endif  // _LIBCPP_CXX03_LANG
 
 #if _LIBCPP_STD_VER > 14
 // clamp
@@ -2732,7 +2732,7 @@ minmax(const _Tp& __a, const _Tp& __b)
 return _VSTD::minmax(__a, __b, __less<_Tp>());
 }
 
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#ifndef _LIBCPP_CXX03_LANG
 
 template
 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
@@ -2779,7 +2779,7 @@ minmax(initializer_list<_Tp> __t)
 return _VSTD::minmax(__t, __less<_Tp>());
 }
 
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#endif  // _LIBCPP_CXX03_LANG
 
 // random_shuffle
 
@@ -2837,7 +2837,7 @@ private:
 _Engine_result_type __mask0_;
 _Engine_result_type __mask1_;
 
-#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+#ifdef _LIBCPP_CXX03_LANG
 static const _Working_result_type _Rp = _Engine::_Max - _Engine::_Min
   + _Working_result_type(1);
 #else
@@ -3080,7 +3080,7 @@ random_shuffle(_RandomAccessIterator __f
 template 
 void
 random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
_RandomNumberGenerator&& __rand)
 #else
_RandomNumberGenerator& __rand)
@@ -3173,7 +3173,7 @@ _SampleIterator sample(_PopulationIterat
 
 template
 void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
  _UniformRandomNumberGenerator&& __g)
 #else
  _UniformRandomNumberGenerator& __g)

Modified: 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp?rev=300625=300624=300625=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp
 Tue Apr 18 18:26:47 2017

[libcxx] r300623 - Cleanup _LIBCPP_HAS_NO_<c++11-feature> macros for std::initializer_list

2017-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 18 18:09:36 2017
New Revision: 300623

URL: http://llvm.org/viewvc/llvm-project?rev=300623=rev
Log:
Cleanup _LIBCPP_HAS_NO_ macros for std::initializer_list

Added:

libcxx/trunk/test/std/language.support/support.initlist/include_cxx03.pass.cpp
Modified:
libcxx/trunk/include/initializer_list

libcxx/trunk/test/std/language.support/support.initlist/support.initlist.access/access.pass.cpp

libcxx/trunk/test/std/language.support/support.initlist/support.initlist.cons/default.pass.cpp

libcxx/trunk/test/std/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp
libcxx/trunk/test/std/language.support/support.initlist/types.pass.cpp

Modified: libcxx/trunk/include/initializer_list
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/initializer_list?rev=300623=300622=300623=diff
==
--- libcxx/trunk/include/initializer_list (original)
+++ libcxx/trunk/include/initializer_list Tue Apr 18 18:09:36 2017
@@ -53,7 +53,7 @@ template const E* end(initializ
 namespace std  // purposefully not versioned
 {
 
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#ifndef _LIBCPP_CXX03_LANG
 
 template
 class _LIBCPP_TEMPLATE_VIS initializer_list
@@ -111,7 +111,7 @@ end(initializer_list<_Ep> __il) _NOEXCEP
 return __il.end();
 }
 
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#endif  // !defined(_LIBCPP_CXX03_LANG)
 
 }  // std
 

Added: 
libcxx/trunk/test/std/language.support/support.initlist/include_cxx03.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.initlist/include_cxx03.pass.cpp?rev=300623=auto
==
--- 
libcxx/trunk/test/std/language.support/support.initlist/include_cxx03.pass.cpp 
(added)
+++ 
libcxx/trunk/test/std/language.support/support.initlist/include_cxx03.pass.cpp 
Tue Apr 18 18:09:36 2017
@@ -0,0 +1,18 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// Test that the file can be included in C++03
+
+#include 
+
+int main()
+{
+}

Modified: 
libcxx/trunk/test/std/language.support/support.initlist/support.initlist.access/access.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.initlist/support.initlist.access/access.pass.cpp?rev=300623=300622=300623=diff
==
--- 
libcxx/trunk/test/std/language.support/support.initlist/support.initlist.access/access.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.initlist/support.initlist.access/access.pass.cpp
 Tue Apr 18 18:09:36 2017
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03
+
 // template class initializer_list;
 
 // const E* begin() const;
@@ -19,8 +21,6 @@
 
 #include "test_macros.h"
 
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
-
 struct A
 {
 A(std::initializer_list il)
@@ -52,13 +52,9 @@ struct B
 
 #endif  // TEST_STD_VER > 11
 
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
-
 int main()
 {
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 A test1 = {3, 2, 1};
-#endif
 #if TEST_STD_VER > 11
 constexpr B test2 = {3, 2, 1};
 #endif  // TEST_STD_VER > 11

Modified: 
libcxx/trunk/test/std/language.support/support.initlist/support.initlist.cons/default.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.initlist/support.initlist.cons/default.pass.cpp?rev=300623=300622=300623=diff
==
--- 
libcxx/trunk/test/std/language.support/support.initlist/support.initlist.cons/default.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.initlist/support.initlist.cons/default.pass.cpp
 Tue Apr 18 18:09:36 2017
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03
+
 // template class initializer_list;
 
 // initializer_list();
@@ -20,10 +22,9 @@ struct A {};
 
 int main()
 {
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 std::initializer_list il;
 assert(il.size() == 0);
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
 #if TEST_STD_VER > 11
 constexpr std::initializer_list il2;
 static_assert(il2.size() == 0, "");

Modified: 
libcxx/trunk/test/std/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp
URL: 

[libcxx] r300622 - Cleanup _LIBCPP_HAS_NO_<c++11-feature> macros in thread.

2017-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 18 18:05:08 2017
New Revision: 300622

URL: http://llvm.org/viewvc/llvm-project?rev=300622=rev
Log:
Cleanup _LIBCPP_HAS_NO_ macros in thread.

Modified:
libcxx/trunk/include/__mutex_base
libcxx/trunk/include/mutex
libcxx/trunk/include/thread

libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp

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

libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp

Modified: libcxx/trunk/include/__mutex_base
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__mutex_base?rev=300622=300621=300622=diff
==
--- libcxx/trunk/include/__mutex_base (original)
+++ libcxx/trunk/include/__mutex_base Tue Apr 18 18:05:08 2017
@@ -34,7 +34,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) 
mutex
 {
-#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+#ifndef _LIBCPP_CXX03_LANG
 __libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER;
 #else
 __libcpp_mutex_t __m_;
@@ -42,7 +42,7 @@ class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SA
 
 public:
 _LIBCPP_INLINE_VISIBILITY
-#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+#ifndef _LIBCPP_CXX03_LANG
 constexpr mutex() _NOEXCEPT = default;
 #else
 mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;}
@@ -66,7 +66,7 @@ struct _LIBCPP_TYPE_VIS defer_lock_t {};
 struct _LIBCPP_TYPE_VIS try_to_lock_t {};
 struct _LIBCPP_TYPE_VIS adopt_lock_t {};
 
-#if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_MUTEX)
+#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_MUTEX)
 
 extern const defer_lock_t  defer_lock;
 extern const try_to_lock_t try_to_lock;
@@ -150,7 +150,7 @@ private:
 unique_lock& operator=(unique_lock const&); // = delete;
 
 public:
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 unique_lock(unique_lock&& __u) _NOEXCEPT
 : __m_(__u.__m_), __owns_(__u.__owns_)
@@ -167,7 +167,7 @@ public:
 return *this;
 }
 
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 
 void lock();
 bool try_lock();
@@ -279,7 +279,7 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_st
 
 class _LIBCPP_TYPE_VIS condition_variable
 {
-#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+#ifndef _LIBCPP_CXX03_LANG
 __libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER;
 #else
 __libcpp_condvar_t __cv_;
@@ -287,7 +287,7 @@ class _LIBCPP_TYPE_VIS condition_variabl
 
 public:
 _LIBCPP_INLINE_VISIBILITY
-#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+#ifndef _LIBCPP_CXX03_LANG
 constexpr condition_variable() _NOEXCEPT = default;
 #else
 condition_variable() _NOEXCEPT {__cv_ = 
(__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;}

Modified: libcxx/trunk/include/mutex
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/mutex?rev=300622=300621=300622=diff
==
--- libcxx/trunk/include/mutex (original)
+++ libcxx/trunk/include/mutex Tue Apr 18 18:05:08 2017
@@ -191,7 +191,7 @@ template
 #include <__mutex_base>
 #include 
 #include 
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#ifndef _LIBCPP_CXX03_LANG
 #include 
 #endif
 #include <__threading_support>
@@ -343,7 +343,7 @@ try_lock(_L0& __l0, _L1& __l1)
 return 0;
 }
 
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#ifndef _LIBCPP_CXX03_LANG
 
 template 
 int
@@ -362,7 +362,7 @@ try_lock(_L0& __l0, _L1& __l1, _L2& __l2
 return __r;
 }
 
-#endif  // _LIBCPP_HAS_NO_VARIADICS
+#endif  // _LIBCPP_CXX03_LANG
 
 template 
 void
@@ -391,7 +391,7 @@ lock(_L0& __l0, _L1& __l1)
 }
 }
 
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#ifndef _LIBCPP_CXX03_LANG
 
 template 
 void
@@ -466,7 +466,7 @@ void __unlock(_L0& __l0, _L1& __l1, _L2&
 _VSTD::__unlock(__l2, __l3...);
 }
 
-#endif  // _LIBCPP_HAS_NO_VARIADICS
+#endif  // _LIBCPP_CXX03_LANG
 
 #if _LIBCPP_STD_VER > 14
 template 
@@ -550,13 +550,13 @@ private:
 
 struct _LIBCPP_TEMPLATE_VIS once_flag;
 
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#ifndef _LIBCPP_CXX03_LANG
 
 template
 _LIBCPP_INLINE_VISIBILITY
 void call_once(once_flag&, _Callable&&, _Args&&...);
 
-#else  // _LIBCPP_HAS_NO_VARIADICS
+#else  // _LIBCPP_CXX03_LANG
 
 template
 _LIBCPP_INLINE_VISIBILITY
@@ -566,7 +566,7 @@ template
 _LIBCPP_INLINE_VISIBILITY
 void call_once(once_flag&, const _Callable&);
 
-#endif  // _LIBCPP_HAS_NO_VARIADICS
+#endif  // _LIBCPP_CXX03_LANG
 
 struct _LIBCPP_TEMPLATE_VIS once_flag
 {
@@ -580,11 +580,11 @@ private:
 
 unsigned long __state_;
 
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#ifndef _LIBCPP_CXX03_LANG
 template
 friend
 void call_once(once_flag&, _Callable&&, _Args&&...);
-#else  // 

[PATCH] D32199: [TBAASan] A TBAA Sanitizer (Clang)

2017-04-18 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel created this revision.
Herald added subscribers: mcrosier, emaste.

This patch introduces the runtime components of a TBAA sanitizer: a sanitizer 
for type-based aliasing violations.

C/C++ have type-based aliasing rules, and LLVM's optimizer can exploit  these 
given TBAA metadata added by Clang. Roughly, a pointer of given  type cannot be 
used to access an object of a different type (with, of  course, certain 
exceptions). Unfortunately, there's a lot of code in the wild that violates 
these rules (e.g. for type punning), and such code often must be built with 
-fno-strict-aliasing. Performance is often sacrificed as a result. Part of the 
problem is the difficulty of finding TBAA violations. Hopefully, this sanitizer 
will help.

https://reviews.llvm.org/D32197 (Runtime)
https://reviews.llvm.org/D32198 (LLVM)

The Clang changes seems mostly formulaic, the one specific change being that 
when the TBAA sanitizer is enabled, TBAA is always generated, even at -O0.

Clang's TBAA representation currently has a problem representing unions, as 
demonstrated by the one XFAIL'd test in the runtime patch. We'll update the 
TBAA representation to fix this, and at the same time, update the sanitizer.


https://reviews.llvm.org/D32199

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/Sanitizers.def
  include/clang/Driver/SanitizerArgs.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenTBAA.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChains/CommonArgs.cpp
  lib/Driver/ToolChains/FreeBSD.cpp
  lib/Driver/ToolChains/Linux.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Lex/PPMacroExpansion.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/sanitize-tbaa-attr.cpp
  test/Driver/sanitizer-ld.c

Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -181,6 +181,18 @@
 
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-unknown-linux -fuse-ld=ld -stdlib=platform -lstdc++ \
+// RUN: -fsanitize=tbaa \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-TBAASAN-LINUX-CXX %s
+//
+// CHECK-TBAASAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-TBAASAN-LINUX-CXX-NOT: stdc++
+// CHECK-TBAASAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.tbaasan-x86_64.a" "-no-whole-archive"
+// CHECK-TBAASAN-LINUX-CXX: stdc++
+
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux -fuse-ld=ld -stdlib=platform -lstdc++ \
 // RUN: -fsanitize=memory \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
Index: test/CodeGen/sanitize-tbaa-attr.cpp
===
--- /dev/null
+++ test/CodeGen/sanitize-tbaa-attr.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=WITHOUT %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s -fsanitize=tbaa | FileCheck -check-prefix=TBAASAN %s
+// RUN: echo "src:%s" | sed -e 's/\\//g' > %t
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s -fsanitize=tbaa -fsanitize-blacklist=%t | FileCheck -check-prefix=BL %s
+
+// The sanitize_tbaa attribute should be attached to functions
+// when TBAASanitizer is enabled, unless no_sanitize_tbaa attribute
+// is present.
+
+// WITHOUT:  NoTBAASAN1{{.*}}) [[NOATTR:#[0-9]+]]
+// BL:  NoTBAASAN1{{.*}}) [[NOATTR:#[0-9]+]]
+// TBAASAN:  NoTBAASAN1{{.*}}) [[NOATTR:#[0-9]+]]
+__attribute__((no_sanitize_tbaa))
+int NoTBAASAN1(int *a) { return *a; }
+
+// WITHOUT:  NoTBAASAN2{{.*}}) [[NOATTR]]
+// BL:  NoTBAASAN2{{.*}}) [[NOATTR]]
+// TBAASAN:  NoTBAASAN2{{.*}}) [[NOATTR]]
+__attribute__((no_sanitize_tbaa))
+int NoTBAASAN2(int *a);
+int NoTBAASAN2(int *a) { return *a; }
+
+// WITHOUT:  NoTBAASAN3{{.*}}) [[NOATTR:#[0-9]+]]
+// BL:  NoTBAASAN3{{.*}}) [[NOATTR:#[0-9]+]]
+// TBAASAN:  NoTBAASAN3{{.*}}) [[NOATTR:#[0-9]+]]
+__attribute__((no_sanitize("tbaa")))
+int NoTBAASAN3(int *a) { return *a; }
+
+// WITHOUT:  TBAASANOk{{.*}}) [[NOATTR]]
+// BL:  TBAASANOk{{.*}}) [[NOATTR]]
+// TBAASAN: TBAASANOk{{.*}}) [[WITH:#[0-9]+]]
+int TBAASANOk(int *a) { return *a; }
+
+// WITHOUT:  TemplateTBAASANOk{{.*}}) [[NOATTR]]
+// BL:  TemplateTBAASANOk{{.*}}) [[NOATTR]]
+// TBAASAN: TemplateTBAASANOk{{.*}}) [[WITH]]
+template
+int TemplateTBAASANOk() { return i; }
+
+// WITHOUT:  TemplateNoTBAASAN{{.*}}) [[NOATTR]]
+// BL:  TemplateNoTBAASAN{{.*}}) [[NOATTR]]
+// TBAASAN: TemplateNoTBAASAN{{.*}}) [[NOATTR]]
+template
+__attribute__((no_sanitize_tbaa))
+int TemplateNoTBAASAN() { return i; }
+
+int force_instance = TemplateTBAASANOk<42>()
+ 

[PATCH] D31542: [clang-tidy] Extend readability-container-size-empty to add comparisons to newly-constructed objects

2017-04-18 Thread Josh Zimmerman via Phabricator via cfe-commits
joshz updated this revision to Diff 95655.
joshz added a comment.

Updated per some suggestions by sbenza@ on dealing with the parentheses; 
IsBinaryOrTernary is based on a function he wrote at Google.

PTAL.


Repository:
  rL LLVM

https://reviews.llvm.org/D31542

Files:
  clang-tidy/readability/ContainerSizeEmptyCheck.cpp
  clang-tidy/utils/ASTUtils.cpp
  clang-tidy/utils/ASTUtils.h
  test/clang-tidy/readability-container-size-empty.cpp

Index: test/clang-tidy/readability-container-size-empty.cpp
===
--- test/clang-tidy/readability-container-size-empty.cpp
+++ test/clang-tidy/readability-container-size-empty.cpp
@@ -3,6 +3,8 @@
 namespace std {
 template  struct vector {
   vector();
+  bool operator==(const vector& other) const;
+  bool operator!=(const vector& other) const;
   unsigned long size() const;
   bool empty() const;
 };
@@ -9,6 +11,11 @@
 
 template  struct basic_string {
   basic_string();
+  bool operator==(const basic_string& other) const;
+  bool operator!=(const basic_string& other) const;
+  bool operator==(const char *) const;
+  bool operator!=(const char *) const;
+  basic_string operator+(const basic_string& other) const;
   unsigned long size() const;
   bool empty() const;
 };
@@ -19,6 +26,8 @@
 inline namespace __v2 {
 template  struct set {
   set();
+  bool operator==(const set& other) const;
+  bool operator!=(const set& other) const;
   unsigned long size() const;
   bool empty() const;
 };
@@ -29,6 +38,8 @@
 template 
 class TemplatedContainer {
 public:
+  bool operator==(const TemplatedContainer& other) const;
+  bool operator!=(const TemplatedContainer& other) const;
   int size() const;
   bool empty() const;
 };
@@ -36,6 +47,8 @@
 template 
 class PrivateEmpty {
 public:
+  bool operator==(const PrivateEmpty& other) const;
+  bool operator!=(const PrivateEmpty& other) const;
   int size() const;
 private:
   bool empty() const;
@@ -54,6 +67,7 @@
 
 class Container {
 public:
+  bool operator==(const Container& other) const;
   int size() const;
   bool empty() const;
 };
@@ -75,9 +89,21 @@
 
 bool Container3::empty() const { return this->size() == 0; }
 
+class Container4 {
+public:
+  bool operator==(const Container4& rhs) const;
+  int size() const;
+  bool empty() const { return *this == Container4(); }
+};
+
+std::string s_func() {
+  return std::string();
+}
+
 int main() {
   std::set intSet;
   std::string str;
+  std::string str2;
   std::wstring wstr;
   str.size() + 0;
   str.size() - 0;
@@ -87,24 +113,57 @@
 ;
   // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty]
   // CHECK-FIXES: {{^  }}if (intSet.empty()){{$}}
-  // CHECK-MESSAGES: :23:8: note: method 'set'::empty() defined here
+  // CHECK-MESSAGES: :32:8: note: method 'set'::empty() defined here
+  if (intSet == std::set())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used to check for emptiness
+  // CHECK-FIXES: {{^  }}if (intSet.empty()){{$}}
+  // CHECK-MESSAGES: :32:8: note: method 'set'::empty() defined here
+  if (s_func() == "")
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (s_func().empty()){{$}}
   if (str.size() == 0)
 ;
   // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
   // CHECK-FIXES: {{^  }}if (str.empty()){{$}}
+  if ((str + str2).size() == 0)
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if ((str + str2).empty()){{$}}
+  if (str == "")
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (str.empty()){{$}}
+  if (str + str2 == "")
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if ((str + str2).empty()){{$}}
   if (wstr.size() == 0)
 ;
   // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
   // CHECK-FIXES: {{^  }}if (wstr.empty()){{$}}
+  if (wstr == "")
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (wstr.empty()){{$}}
   std::vector vect;
   if (vect.size() == 0)
 ;
   // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
   // CHECK-FIXES: {{^  }}if (vect.empty()){{$}}
+  if (vect == std::vector())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if (vect.empty()){{$}}
   if (vect.size() != 0)
 ;
   // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
   // CHECK-FIXES: {{^  }}if (!vect.empty()){{$}}
+  if (vect != std::vector())
+;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
+  // CHECK-FIXES: {{^  }}if 

[libcxx] r300620 - Cleanup _LIBCPP_HAS_NO_<c++11-feature> in std::unordered_map and std::unordered_multimap

2017-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 18 17:50:56 2017
New Revision: 300620

URL: http://llvm.org/viewvc/llvm-project?rev=300620=rev
Log:
Cleanup _LIBCPP_HAS_NO_ in std::unordered_map and 
std::unordered_multimap

This completes the cleanup of the containers, at least within the tests.

Modified:
libcxx/trunk/include/unordered_map
libcxx/trunk/test/std/containers/Emplaceable.h

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/emplace.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/emplace_hint.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_init.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp

Modified: libcxx/trunk/include/unordered_map
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/unordered_map?rev=300620=300619=300620=diff
==
--- libcxx/trunk/include/unordered_map (original)
+++ libcxx/trunk/include/unordered_map Tue Apr 18 17:50:56 2017
@@ -547,7 +547,7 @@ public:
   __second_constructed(false)
 {}
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 __hash_map_node_destructor(__hash_node_destructor&& __x)
 _NOEXCEPT
@@ -557,7 +557,7 @@ public:
 {
 __x.__value_constructed = false;
 }
-#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#else  // _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 __hash_map_node_destructor(const __hash_node_destructor& 
__x)
 : __na_(__x.__na_),
@@ -566,7 +566,7 @@ public:
 {
 const_cast(__x.__value_constructed) = false;
 }
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 
 _LIBCPP_INLINE_VISIBILITY
 void operator()(pointer __p) _NOEXCEPT
@@ -819,20 +819,18 @@ public:
 explicit unordered_map(const allocator_type& __a);
 unordered_map(const unordered_map& __u);
 unordered_map(const unordered_map& __u, const allocator_type& __a);
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 unordered_map(unordered_map&& __u)
 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
 unordered_map(unordered_map&& __u, const allocator_type& __a);
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 unordered_map(initializer_list __il);
 unordered_map(initializer_list __il, size_type __n,
   const hasher& __hf = hasher(), const key_equal& __eql = 
key_equal());
 unordered_map(initializer_list __il, size_type __n,
   const hasher& __hf, const key_equal& __eql,
   const allocator_type& __a);
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#endif  // _LIBCPP_CXX03_LANG
 #if _LIBCPP_STD_VER > 11
 _LIBCPP_INLINE_VISIBILITY
 unordered_map(size_type __n, const allocator_type& __a)
@@ -875,15 +873,13 @@ public:
 #endif
 return *this;
 }
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef 

[libcxx] r300619 - Cleanup _LIBCPP_HAS_NO_<c++11-feature> macros in std::unordered_set and std::unordered_multiset

2017-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 18 17:37:32 2017
New Revision: 300619

URL: http://llvm.org/viewvc/llvm-project?rev=300619=rev
Log:
Cleanup _LIBCPP_HAS_NO_ macros in std::unordered_set and 
std::unordered_multiset

Modified:
libcxx/trunk/include/unordered_set
libcxx/trunk/test/std/containers/unord/unord.multiset/emplace.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multiset/emplace_hint.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multiset/insert_init.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multiset/insert_rvalue.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.set/emplace.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.set/emplace_hint.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.set/insert_init.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.set/insert_rvalue.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp

Modified: libcxx/trunk/include/unordered_set
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/unordered_set?rev=300619=300618=300619=diff
==
--- libcxx/trunk/include/unordered_set (original)
+++ libcxx/trunk/include/unordered_set Tue Apr 18 17:37:32 2017
@@ -408,13 +408,11 @@ public:
 explicit unordered_set(const allocator_type& __a);
 unordered_set(const unordered_set& __u);
 unordered_set(const unordered_set& __u, const allocator_type& __a);
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 unordered_set(unordered_set&& __u)
 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
 unordered_set(unordered_set&& __u, const allocator_type& __a);
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 unordered_set(initializer_list __il);
 unordered_set(initializer_list __il, size_type __n,
   const hasher& __hf = hasher(),
@@ -432,7 +430,7 @@ public:
   const hasher& __hf, const allocator_type& 
__a)
 : unordered_set(__il, __n, __hf, key_equal(), __a) {}
 #endif
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#endif  // _LIBCPP_CXX03_LANG
 // ~unordered_set() = default;
 _LIBCPP_INLINE_VISIBILITY
 unordered_set& operator=(const unordered_set& __u)
@@ -440,15 +438,13 @@ public:
 __table_ = __u.__table_;
 return *this;
 }
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 unordered_set& operator=(unordered_set&& __u)
 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
-#endif
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 _LIBCPP_INLINE_VISIBILITY
 unordered_set& operator=(initializer_list __il);
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#endif  // _LIBCPP_CXX03_LANG
 
 _LIBCPP_INLINE_VISIBILITY
 allocator_type get_allocator() const _NOEXCEPT
@@ -474,7 +470,7 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 const_iterator cend()   const _NOEXCEPT {return __table_.end();}
 
-#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && 
!defined(_LIBCPP_HAS_NO_VARIADICS)
+#ifndef _LIBCPP_CXX03_LANG
 template 
 

r300611 - [modules-ts] Fold together -x c++ and -x c++-module at -cc1 level.

2017-04-18 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Apr 18 16:55:37 2017
New Revision: 300611

URL: http://llvm.org/viewvc/llvm-project?rev=300611=rev
Log:
[modules-ts] Fold together -x c++ and -x c++-module at -cc1 level.

The driver needs to know whether it's building a module interface or
implementation unit because it affects which outputs it produces and how it
builds the command pipeline. But the frontend doesn't need to know and should
not care: all it needs to know is what action it is being asked to perform on
the input.

(This is in preparation for permitting -emit-obj to be used on a module
interface unit to produce object code without going via a "full" PCM file.)

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Driver/modules-ts.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=300611=300610=300611=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Apr 18 16:55:37 2017
@@ -649,8 +649,24 @@ static void addDashXForInput(const ArgLi
   CmdArgs.push_back("-x");
   if (Args.hasArg(options::OPT_rewrite_objc))
 CmdArgs.push_back(types::getTypeName(types::TY_PP_ObjCXX));
-  else
-CmdArgs.push_back(types::getTypeName(Input.getType()));
+  else {
+// Map the driver type to the frontend type. This is mostly an identity
+// mapping, except that the distinction between module interface units
+// and other source files does not exist at the frontend layer.
+const char *ClangType;
+switch (Input.getType()) {
+case types::TY_CXXModule:
+  ClangType = "c++";
+  break;
+case types::TY_PP_CXXModule:
+  ClangType = "c++-cpp-output";
+  break;
+default:
+  ClangType = types::getTypeName(Input.getType());
+  break;
+}
+CmdArgs.push_back(ClangType);
+  }
 }
 
 static void appendUserToPath(SmallVectorImpl ) {

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=300611=300610=300611=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Apr 18 16:55:37 2017
@@ -1353,13 +1353,11 @@ static InputKind ParseFrontendArgs(Front
   .Case("cl", IK_OpenCL)
   .Case("cuda", IK_CUDA)
   .Case("c++", IK_CXX)
-  .Case("c++-module", IK_CXX)
   .Case("objective-c", IK_ObjC)
   .Case("objective-c++", IK_ObjCXX)
   .Case("cpp-output", IK_PreprocessedC)
   .Case("assembler-with-cpp", IK_Asm)
   .Case("c++-cpp-output", IK_PreprocessedCXX)
-  .Case("c++-module-cpp-output", IK_PreprocessedCXX)
   .Case("cuda-cpp-output", IK_PreprocessedCuda)
   .Case("objective-c-cpp-output", IK_PreprocessedObjC)
   .Case("objc-cpp-output", IK_PreprocessedObjC)

Modified: cfe/trunk/test/Driver/modules-ts.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/modules-ts.cpp?rev=300611=300610=300611=diff
==
--- cfe/trunk/test/Driver/modules-ts.cpp (original)
+++ cfe/trunk/test/Driver/modules-ts.cpp Tue Apr 18 16:55:37 2017
@@ -4,7 +4,7 @@
 //
 // CHECK-PRECOMPILE: -cc1 {{.*}} -emit-module-interface
 // CHECK-PRECOMPILE-SAME: -o {{.*}}.pcm
-// CHECK-PRECOMPILE-SAME: -x c++-module
+// CHECK-PRECOMPILE-SAME: -x c++
 // CHECK-PRECOMPILE-SAME: modules-ts.cpp
 
 // Check compiling a .pcm file to a .o file.


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


r300609 - Do not warn about whitespace between ??/ trigraph and newline in line comments if trigraphs are disabled in the current language.

2017-04-18 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Apr 18 16:45:04 2017
New Revision: 300609

URL: http://llvm.org/viewvc/llvm-project?rev=300609=rev
Log:
Do not warn about whitespace between ??/ trigraph and newline in line comments 
if trigraphs are disabled in the current language.

Modified:
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/test/Lexer/cxx1z-trigraphs.cpp

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=300609=300608=300609=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Tue Apr 18 16:45:04 2017
@@ -1171,6 +1171,8 @@ const char *Lexer::SkipEscapedNewLines(c
   // If not a trigraph for escape, bail out.
   if (P[1] != '?' || P[2] != '/')
 return P;
+  // FIXME: Take LangOpts into account; the language might not
+  // support trigraphs.
   AfterEscape = P+3;
 } else {
   return P;
@@ -2079,17 +2081,17 @@ bool Lexer::SkipLineComment(Token 
 HasSpace = true;
   }
 
-  if (*EscapePtr == '\\') // Escaped newline.
+  if (*EscapePtr == '\\')
+// Escaped newline.
 CurPtr = EscapePtr;
   else if (EscapePtr[0] == '/' && EscapePtr[-1] == '?' &&
-   EscapePtr[-2] == '?') // Trigraph-escaped newline.
+   EscapePtr[-2] == '?' && LangOpts.Trigraphs)
+// Trigraph-escaped newline.
 CurPtr = EscapePtr-2;
   else
 break; // This is a newline, we're done.
 
   // If there was space between the backslash and newline, warn about it.
-  // FIXME: This warning is bogus if trigraphs are disabled and the line
-  // ended with '?' '?' '\\' '\n'.
   if (HasSpace && !isLexingRawMode())
 Diag(EscapePtr, diag::backslash_newline_space);
 }

Modified: cfe/trunk/test/Lexer/cxx1z-trigraphs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/cxx1z-trigraphs.cpp?rev=300609=300608=300609=diff
==
--- cfe/trunk/test/Lexer/cxx1z-trigraphs.cpp (original)
+++ cfe/trunk/test/Lexer/cxx1z-trigraphs.cpp Tue Apr 18 16:45:04 2017
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -std=c++1z %s -verify
-// RUN: %clang_cc1 -std=c++1z %s -ftrigraphs -fsyntax-only
+// RUN: %clang_cc1 -std=c++1z %s -ftrigraphs -fsyntax-only 2>&1 | FileCheck 
--check-prefix=TRIGRAPHS %s
 
 ??= define foo ; // expected-error {{}} expected-warning {{trigraph ignored}}
 
@@ -7,3 +7,8 @@ static_assert("??="[0] == '#', ""); // e
 
 // ??/
 error here; // expected-error {{}}
+
+// Note, there is intentionally trailing whitespace two lines below.
+// TRIGRAPHS: :[[@LINE+1]]:{{.*}} backslash and newline separated by space
+// ??/  
+error here; // expected-error {{}}


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


[PATCH] D32170: Add a FixItHint for -Wmissing-prototypes to insert 'static '.

2017-04-18 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:11652
 static bool ShouldWarnAboutMissingPrototype(const FunctionDecl *FD,
- const FunctionDecl*& PossibleZeroParamPrototype) {
+ const FunctionDecl*& PossibleZeroParamPrototype,
+ bool *PossibleMissingStatic) {

Fix the format while here?



Comment at: lib/Sema/SemaDecl.cpp:11653
+ const FunctionDecl*& PossibleZeroParamPrototype,
+ bool *PossibleMissingStatic) {
   // Don't warn about invalid declarations.

Maybe s/Possible/Possibly/ ?



Comment at: lib/Sema/SemaDecl.cpp:11708
+   FD->getDeclContext()->isTranslationUnit() &&
+   FD->getStorageClass() == SC_None;
+

Does this exclude templated functions? If not, the "static" might be put into 
the wrong place.



Comment at: lib/Sema/SemaDecl.cpp:12114
+auto DiagBuilder =
+Diag(FD->getLocation(), diag::warn_missing_prototype_maybe_static)
+<< FD;

I wonder whether it is useful to display the changed message here. In the cases 
I have seen where the function definition is coming from a macro, you'd 
actually need to surround it with an unnamed namespace to fix. Maybe just add 
this logic to the outer if statement?


https://reviews.llvm.org/D32170



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


[libcxx] r300604 - Cleanup _LIBCPP_HAS_NO_<c++11-feature> for std::queue and std::priority_queue.

2017-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 18 16:23:18 2017
New Revision: 300604

URL: http://llvm.org/viewvc/llvm-project?rev=300604=rev
Log:
Cleanup _LIBCPP_HAS_NO_ for std::queue and std::priority_queue.

Modified:
libcxx/trunk/include/queue

libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_alloc.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_alloc.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_move_alloc.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_move.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_move.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.members/emplace.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.members/push_rvalue.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/ctor_move.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp

Modified: libcxx/trunk/include/queue
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/queue?rev=300604=300603=300604=diff
==
--- libcxx/trunk/include/queue (original)
+++ libcxx/trunk/include/queue Tue Apr 18 16:23:18 2017
@@ -213,29 +213,27 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 queue(const queue& __q) : c(__q.c) {}
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+_LIBCPP_INLINE_VISIBILITY
+queue& operator=(const queue& __q) {c = __q.c; return *this;}
+
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 queue(queue&& __q)
 _NOEXCEPT_(is_nothrow_move_constructible::value)
 : c(_VSTD::move(__q.c)) {}
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 _LIBCPP_INLINE_VISIBILITY
-queue& operator=(const queue& __q) {c = __q.c; return *this;}
-
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-_LIBCPP_INLINE_VISIBILITY
 queue& operator=(queue&& __q)
 _NOEXCEPT_(is_nothrow_move_assignable::value)
 {c = _VSTD::move(__q.c); return *this;}
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 
 _LIBCPP_INLINE_VISIBILITY
 explicit queue(const container_type& __c)  : c(__c) {}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {}
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 template 
 _LIBCPP_INLINE_VISIBILITY
 explicit queue(const _Alloc& __a,
@@ -254,7 +252,7 @@ public:
typename enable_if::value>::type* = 0)
 : c(__c, __a) {}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 template 
 _LIBCPP_INLINE_VISIBILITY
 queue(container_type&& __c, const _Alloc& __a,
@@ -268,7 +266,7 @@ public:
  
_Alloc>::value>::type* = 0)
 : c(_VSTD::move(__q.c), __a) {}
 
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 
 _LIBCPP_INLINE_VISIBILITY
 bool  empty() const {return c.empty();}
@@ -286,10 +284,9 @@ public:
 
 _LIBCPP_INLINE_VISIBILITY
 void push(const value_type& __v) {c.push_back(__v);}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 void push(value_type&& __v)  {c.push_back(_VSTD::move(__v));}
-#ifndef 

[PATCH] D32192: Enable leak sanitizer builds for darwin

2017-04-18 Thread Francis Ricci via Phabricator via cfe-commits
fjricci created this revision.

Support for leak sanitizer on darwin has been added to
compiler-rt, this patch adds compiler support.


https://reviews.llvm.org/D32192

Files:
  lib/Driver/ToolChains/Darwin.cpp


Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1035,6 +1035,8 @@
   const SanitizerArgs  = getSanitizerArgs();
   if (Sanitize.needsAsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
+  if (Sanitize.needsLsanRt())
+AddLinkSanitizerLibArgs(Args, CmdArgs, "lsan");
   if (Sanitize.needsUbsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
   if (Sanitize.needsTsanRt())
@@ -1896,9 +1898,11 @@
 if (!isMacosxVersionLT(10, 9))
   Res |= SanitizerKind::Vptr;
 Res |= SanitizerKind::SafeStack;
+Res |= SanitizerKind::Leak;
 if (IsX86_64)
   Res |= SanitizerKind::Thread;
   } else if (isTargetIOSSimulator() || isTargetTvOSSimulator()) {
+Res |= SanitizerKind::Leak;
 if (IsX86_64)
   Res |= SanitizerKind::Thread;
   }


Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1035,6 +1035,8 @@
   const SanitizerArgs  = getSanitizerArgs();
   if (Sanitize.needsAsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
+  if (Sanitize.needsLsanRt())
+AddLinkSanitizerLibArgs(Args, CmdArgs, "lsan");
   if (Sanitize.needsUbsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
   if (Sanitize.needsTsanRt())
@@ -1896,9 +1898,11 @@
 if (!isMacosxVersionLT(10, 9))
   Res |= SanitizerKind::Vptr;
 Res |= SanitizerKind::SafeStack;
+Res |= SanitizerKind::Leak;
 if (IsX86_64)
   Res |= SanitizerKind::Thread;
   } else if (isTargetIOSSimulator() || isTargetTvOSSimulator()) {
+Res |= SanitizerKind::Leak;
 if (IsX86_64)
   Res |= SanitizerKind::Thread;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r300602 - Cleanup _LIBCPP_HAS_NO_<c++11-feature> macro uses in std::stack.

2017-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 18 16:16:26 2017
New Revision: 300602

URL: http://llvm.org/viewvc/llvm-project?rev=300602=rev
Log:
Cleanup _LIBCPP_HAS_NO_ macro uses in std::stack.

Modified:
libcxx/trunk/include/stack

libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/stack/stack.defn/assign_move.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/stack/stack.defn/push_rv.pass.cpp

Modified: libcxx/trunk/include/stack
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/stack?rev=300602=300601=300602=diff
==
--- libcxx/trunk/include/stack (original)
+++ libcxx/trunk/include/stack Tue Apr 18 16:16:26 2017
@@ -126,29 +126,28 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 stack(const stack& __q) : c(__q.c) {}
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+_LIBCPP_INLINE_VISIBILITY
+stack& operator=(const stack& __q) {c = __q.c; return *this;}
+
+
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 stack(stack&& __q)
 _NOEXCEPT_(is_nothrow_move_constructible::value)
 : c(_VSTD::move(__q.c)) {}
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 _LIBCPP_INLINE_VISIBILITY
-stack& operator=(const stack& __q) {c = __q.c; return *this;}
-
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-_LIBCPP_INLINE_VISIBILITY
 stack& operator=(stack&& __q)
 _NOEXCEPT_(is_nothrow_move_assignable::value)
 {c = _VSTD::move(__q.c); return *this;}
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 _LIBCPP_INLINE_VISIBILITY
-explicit stack(const container_type& __c) : c(__c) {}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-_LIBCPP_INLINE_VISIBILITY
 explicit stack(container_type&& __c) : c(_VSTD::move(__c)) {}
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
+
+_LIBCPP_INLINE_VISIBILITY
+explicit stack(const container_type& __c) : c(__c) {}
+
 template 
 _LIBCPP_INLINE_VISIBILITY
 explicit stack(const _Alloc& __a,
@@ -167,7 +166,7 @@ public:
   typename enable_if::value>::type* = 0)
 : c(__s.c, __a) {}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 template 
 _LIBCPP_INLINE_VISIBILITY
 stack(container_type&& __c, const _Alloc& __a,
@@ -180,7 +179,7 @@ public:
   typename enable_if::value>::type* = 0)
 : c(_VSTD::move(__s.c), __a) {}
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 
 _LIBCPP_INLINE_VISIBILITY
 bool empty() const  {return c.empty();}
@@ -193,10 +192,10 @@ public:
 
 _LIBCPP_INLINE_VISIBILITY
 void push(const value_type& __v) {c.push_back(__v);}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 void push(value_type&& __v) {c.push_back(_VSTD::move(__v));}
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+
 template 
 _LIBCPP_INLINE_VISIBILITY
 #if _LIBCPP_STD_VER > 14
@@ -206,8 +205,8 @@ public:
 void  emplace(_Args&&... __args)
 {c.emplace_back(_VSTD::forward<_Args>(__args)...);}
 #endif
-#endif  // _LIBCPP_HAS_NO_VARIADICS
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
+
 _LIBCPP_INLINE_VISIBILITY
 void pop() {c.pop_back();}
 

Modified: 
libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp?rev=300602=300601=300602=diff
==
--- 
libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp
 Tue Apr 18 16:16:26 2017
@@ -15,6 +15,7 @@
 #include 
 #include 
 

[libcxx] r300600 - Cleanup _LIBCPP_HAS_NO_<c++11-feature> macros in std::map and std::multimap

2017-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 18 16:08:06 2017
New Revision: 300600

URL: http://llvm.org/viewvc/llvm-project?rev=300600=rev
Log:
Cleanup _LIBCPP_HAS_NO_ macros in std::map and std::multimap

Modified:
libcxx/trunk/include/map

libcxx/trunk/test/std/containers/associative/map/map.access/index_tuple.pass.cpp

libcxx/trunk/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp

libcxx/trunk/test/std/containers/associative/map/map.cons/initializer_list.pass.cpp

libcxx/trunk/test/std/containers/associative/map/map.cons/initializer_list_compare.pass.cpp

libcxx/trunk/test/std/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp
libcxx/trunk/test/std/containers/associative/map/map.cons/move.pass.cpp

libcxx/trunk/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp

libcxx/trunk/test/std/containers/associative/map/map.cons/move_assign.pass.cpp

libcxx/trunk/test/std/containers/associative/map/map.modifiers/emplace.pass.cpp

libcxx/trunk/test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp

libcxx/trunk/test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/move.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp

Modified: libcxx/trunk/include/map
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/map?rev=300600=300599=300600=diff
==
--- libcxx/trunk/include/map (original)
+++ libcxx/trunk/include/map Tue Apr 18 16:08:06 2017
@@ -582,7 +582,7 @@ public:
   __second_constructed(false)
 {}
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 __map_node_destructor(__tree_node_destructor&& __x) 
_NOEXCEPT
 : __na_(__x.__na_),
@@ -591,7 +591,7 @@ public:
 {
 __x.__value_constructed = false;
 }
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 
 _LIBCPP_INLINE_VISIBILITY
 void operator()(pointer __p) _NOEXCEPT
@@ -667,7 +667,7 @@ private:
~__value_type();
 };
 
-#endif
+#endif // _LIBCPP_CXX03_LANG
 
 template 
 struct __extract_key_value_types;
@@ -921,7 +921,7 @@ public:
 return *this;
 }
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 
 _LIBCPP_INLINE_VISIBILITY
 map(map&& __m)
@@ -940,10 +940,6 @@ public:
 return *this;
 }
 
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
-
 _LIBCPP_INLINE_VISIBILITY
 map(initializer_list __il, const key_compare& __comp = 
key_compare())
 : __tree_(__vc(__comp))
@@ -971,7 +967,7 @@ public:
 return *this;
 }
 
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#endif  // _LIBCPP_CXX03_LANG
 
 _LIBCPP_INLINE_VISIBILITY
 explicit map(const allocator_type& __a)
@@ -1082,6 +1078,10 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 iterator insert(const_iterator __p,  value_type&& __v)
 {return __tree_.__insert_unique(__p.__i_, _VSTD::move(__v));}
+
+_LIBCPP_INLINE_VISIBILITY
+void insert(initializer_list __il)
+{insert(__il.begin(), __il.end());}
 #endif
 
 template 
@@ -1092,14 +1092,6 @@ public:
 insert(__e.__i_, *__f);
 }
 
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
-
-_LIBCPP_INLINE_VISIBILITY
-void insert(initializer_list __il)
-{insert(__il.begin(), __il.end());}
-
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
-
 #if _LIBCPP_STD_VER > 14
 
 template 
@@ -1194,7 +1186,7 @@ public:
 return emplace_hint(__h, _VSTD::move(__k), _VSTD::forward<_Vp>(__v));
  }
 
-#endif
+#endif // _LIBCPP_STD_VER > 14
 
 _LIBCPP_INLINE_VISIBILITY
 iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);}
@@ -1307,7 +1299,6 @@ private:
 
 
 #ifndef _LIBCPP_CXX03_LANG
-
 template 
 map<_Key, _Tp, _Compare, 

[PATCH] D32119: Emit warning when umbrella directory does not exists

2017-04-18 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Landed in r300594.


https://reviews.llvm.org/D32119



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


[libcxx] r300595 - Cleanup _LIBCPP_HAS_NO_<c++11-feature> for std::set and std::multiset

2017-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 18 15:58:03 2017
New Revision: 300595

URL: http://llvm.org/viewvc/llvm-project?rev=300595=rev
Log:
Cleanup _LIBCPP_HAS_NO_ for std::set and std::multiset

Modified:
libcxx/trunk/include/set
libcxx/trunk/test/std/containers/associative/multiset/emplace.pass.cpp
libcxx/trunk/test/std/containers/associative/multiset/emplace_hint.pass.cpp

libcxx/trunk/test/std/containers/associative/multiset/insert_initializer_list.pass.cpp

libcxx/trunk/test/std/containers/associative/multiset/insert_iter_rv.pass.cpp
libcxx/trunk/test/std/containers/associative/multiset/insert_rv.pass.cpp

libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp

libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp

libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare.pass.cpp

libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare_alloc.pass.cpp

libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/move.pass.cpp

libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp

libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp
libcxx/trunk/test/std/containers/associative/set/emplace.pass.cpp
libcxx/trunk/test/std/containers/associative/set/emplace_hint.pass.cpp

libcxx/trunk/test/std/containers/associative/set/insert_initializer_list.pass.cpp
libcxx/trunk/test/std/containers/associative/set/insert_iter_rv.pass.cpp
libcxx/trunk/test/std/containers/associative/set/insert_rv.pass.cpp

libcxx/trunk/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp

libcxx/trunk/test/std/containers/associative/set/set.cons/initializer_list.pass.cpp

libcxx/trunk/test/std/containers/associative/set/set.cons/initializer_list_compare.pass.cpp

libcxx/trunk/test/std/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp
libcxx/trunk/test/std/containers/associative/set/set.cons/move.pass.cpp

libcxx/trunk/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp

libcxx/trunk/test/std/containers/associative/set/set.cons/move_assign.pass.cpp

Modified: libcxx/trunk/include/set
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/set?rev=300595=300594=300595=diff
==
--- libcxx/trunk/include/set (original)
+++ libcxx/trunk/include/set Tue Apr 18 15:58:03 2017
@@ -486,12 +486,12 @@ public:
 return *this;
 }
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 _LIBCPP_INLINE_VISIBILITY
 set(set&& __s)
 _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
 : __tree_(_VSTD::move(__s.__tree_)) {}
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 
 _LIBCPP_INLINE_VISIBILITY
 explicit set(const allocator_type& __a)
@@ -504,11 +504,9 @@ public:
 insert(__s.begin(), __s.end());
 }
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_CXX03_LANG
 set(set&& __s, const allocator_type& __a);
-#endif
 
-#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 _LIBCPP_INLINE_VISIBILITY
 set(initializer_list __il, const value_compare& __comp = 
value_compare())
 : __tree_(__comp)
@@ -536,9 +534,7 @@ public:
 __tree_.__assign_unique(__il.begin(), __il.end());
 return *this;
 }
-#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 _LIBCPP_INLINE_VISIBILITY
 set& operator=(set&& __s)
 _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
@@ -546,7 +542,7 @@ public:
 __tree_ = _VSTD::move(__s.__tree_);
 return *this;
 }
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif  // _LIBCPP_CXX03_LANG
 
 _LIBCPP_INLINE_VISIBILITY
   iterator begin() _NOEXCEPT   {return __tree_.begin();}
@@ -587,7 +583,7 @@ public:
 size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
 
 // modifiers:
-#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && 
!defined(_LIBCPP_HAS_NO_VARIADICS)
+#ifndef _LIBCPP_CXX03_LANG
 template 
 _LIBCPP_INLINE_VISIBILITY
 pair emplace(_Args&&... __args)
@@ -596,23 +592,15 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 iterator emplace_hint(const_iterator __p, _Args&&... __args)
 {return __tree_.__emplace_hint_unique(__p, 
_VSTD::forward<_Args>(__args)...);}
-#endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && 
!defined(_LIBCPP_HAS_NO_VARIADICS)
+#endif  // _LIBCPP_CXX03_LANG
+
 _LIBCPP_INLINE_VISIBILITY
 pair insert(const value_type& __v)
 {return __tree_.__insert_unique(__v);}

r300594 - PR30508: Downgrade error to warning if the umbrella folder doesn't exist.

2017-04-18 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Apr 18 15:57:29 2017
New Revision: 300594

URL: http://llvm.org/viewvc/llvm-project?rev=300594=rev
Log:
PR30508: Downgrade error to warning if the umbrella folder doesn't exist.

Patch by Yuka Takahashi (D32119)!

Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/test/Modules/umbrella-header-include-builtin.mm

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=300594=300593=300594=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Apr 18 15:57:29 2017
@@ -594,8 +594,6 @@ def err_mmap_expected_mmap_file : Error<
 def err_mmap_module_redefinition : Error<
   "redefinition of module '%0'">;
 def note_mmap_prev_definition : Note<"previously defined here">;
-def err_mmap_umbrella_dir_not_found : Error<
-  "umbrella directory '%0' not found">;
 def err_mmap_umbrella_clash : Error<
   "umbrella for module '%0' already covers this directory">;
 def err_mmap_module_id : Error<
@@ -656,6 +654,9 @@ def note_implicit_top_level_module_impor
 def warn_uncovered_module_header : Warning<
   "umbrella header for module '%0' does not include header '%1'">, 
   InGroup;
+def warn_mmap_umbrella_dir_not_found : Warning<
+  "umbrella directory '%0' not found">,
+  InGroup;
 def err_expected_id_building_module : Error<
   "expected a module name in '__building_module' expression">;
 def warn_use_of_private_header_outside_module : Warning<

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=300594=300593=300594=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Tue Apr 18 15:57:29 2017
@@ -2002,9 +2002,8 @@ void ModuleMapParser::parseUmbrellaDirDe
   }
   
   if (!Dir) {
-Diags.Report(DirNameLoc, diag::err_mmap_umbrella_dir_not_found)
+Diags.Report(DirNameLoc, diag::warn_mmap_umbrella_dir_not_found)
   << DirName;
-HadError = true;
 return;
   }
 

Modified: cfe/trunk/test/Modules/umbrella-header-include-builtin.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/umbrella-header-include-builtin.mm?rev=300594=300593=300594=diff
==
--- cfe/trunk/test/Modules/umbrella-header-include-builtin.mm (original)
+++ cfe/trunk/test/Modules/umbrella-header-include-builtin.mm Tue Apr 18 
15:57:29 2017
@@ -4,3 +4,11 @@
 // RUN: %clang -cc1 -fsyntax-only -nostdinc++ -isysroot 
%S/Inputs/libc-libcxx/sysroot -isystem 
%S/Inputs/libc-libcxx/sysroot/usr/include/c++/v1 
-F%S/Inputs/libc-libcxx/sysroot/Frameworks -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -x objective-c++ %s
 
 #include 
+
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "module NonExistent1 { umbrella \"NonExistent\" }" > 
%t/modules.modulemap
+// RUN: echo "" > %t/A.h
+// RUN: echo "#include \"A.h\"  int i;" > %t/T.cxx
+// RUN: %clang -I %t -fmodules -fsyntax-only %t/T.cxx
+// expected-warning {{ umbrella directory }}


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


[PATCH] D32187: [CodeGen][ObjC]

2017-04-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I wouldn't mind unconditionally banning this in JumpDiagnostics, actually.


https://reviews.llvm.org/D32187



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


r300591 - The SubjectMatchRule enum should not be used as a DenseMap key to avoid

2017-04-18 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Apr 18 15:54:23 2017
New Revision: 300591

URL: http://llvm.org/viewvc/llvm-project?rev=300591=rev
Log:
The SubjectMatchRule enum should not be used as a DenseMap key to avoid
UBSAN 'invalid value' failures

The commit r300556 introduced a UBSAN issue that was caught by
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap. The DenseMap
failed to create an empty/tombstone value as the empty/tombstone values for the
SubjectMatchRule enum were not valid enum constants.

Modified:
cfe/trunk/include/clang/Basic/AttrSubjectMatchRules.h
cfe/trunk/lib/Sema/SemaAttr.cpp

Modified: cfe/trunk/include/clang/Basic/AttrSubjectMatchRules.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrSubjectMatchRules.h?rev=300591=300590=300591=diff
==
--- cfe/trunk/include/clang/Basic/AttrSubjectMatchRules.h (original)
+++ cfe/trunk/include/clang/Basic/AttrSubjectMatchRules.h Tue Apr 18 15:54:23 
2017
@@ -24,23 +24,9 @@ enum SubjectMatchRule {
 
 const char *getSubjectMatchRuleSpelling(SubjectMatchRule Rule);
 
-using ParsedSubjectMatchRuleSet = llvm::DenseMap;
+using ParsedSubjectMatchRuleSet = llvm::DenseMap;
 
 } // end namespace attr
 } // end namespace clang
 
-namespace llvm {
-
-template <>
-struct DenseMapInfo : DenseMapInfo {
-  static inline clang::attr::SubjectMatchRule getEmptyKey() {
-return (clang::attr::SubjectMatchRule)DenseMapInfo::getEmptyKey();
-  }
-  static inline clang::attr::SubjectMatchRule getTombstoneKey() {
-return (clang::attr::SubjectMatchRule)DenseMapInfo::getTombstoneKey();
-  }
-};
-
-} // end namespace llvm
-
 #endif

Modified: cfe/trunk/lib/Sema/SemaAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAttr.cpp?rev=300591=300590=300591=diff
==
--- cfe/trunk/lib/Sema/SemaAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaAttr.cpp Tue Apr 18 15:54:23 2017
@@ -440,12 +440,12 @@ void Sema::ActOnPragmaAttributePush(Attr
 //variable(is_parameter).
 //  - a sub-rule and a sibling that's negated. E.g.
 //variable(is_thread_local) and variable(unless(is_parameter))
-llvm::SmallDenseMap, 2>
+llvm::SmallDenseMap, 2>
 RulesToFirstSpecifiedNegatedSubRule;
 for (const auto  : Rules) {
+  attr::SubjectMatchRule MatchRule = attr::SubjectMatchRule(Rule.first);
   Optional ParentRule =
-  getParentAttrMatcherRule(Rule.first);
+  getParentAttrMatcherRule(MatchRule);
   if (!ParentRule)
 continue;
   auto It = Rules.find(*ParentRule);
@@ -453,7 +453,7 @@ void Sema::ActOnPragmaAttributePush(Attr
 // A sub-rule contradicts a parent rule.
 Diag(Rule.second.getBegin(),
  diag::err_pragma_attribute_matcher_subrule_contradicts_rule)
-<< attr::getSubjectMatchRuleSpelling(Rule.first)
+<< attr::getSubjectMatchRuleSpelling(MatchRule)
 << attr::getSubjectMatchRuleSpelling(*ParentRule) << It->second
 << FixItHint::CreateRemoval(
replacementRangeForListElement(*this, Rule.second));
@@ -461,14 +461,15 @@ void Sema::ActOnPragmaAttributePush(Attr
 // declarations that receive the attribute.
 continue;
   }
-  if (isNegatedAttrMatcherSubRule(Rule.first))
+  if (isNegatedAttrMatcherSubRule(MatchRule))
 RulesToFirstSpecifiedNegatedSubRule.insert(
 std::make_pair(*ParentRule, Rule));
 }
 bool IgnoreNegatedSubRules = false;
 for (const auto  : Rules) {
+  attr::SubjectMatchRule MatchRule = attr::SubjectMatchRule(Rule.first);
   Optional ParentRule =
-  getParentAttrMatcherRule(Rule.first);
+  getParentAttrMatcherRule(MatchRule);
   if (!ParentRule)
 continue;
   auto It = RulesToFirstSpecifiedNegatedSubRule.find(*ParentRule);
@@ -479,8 +480,9 @@ void Sema::ActOnPragmaAttributePush(Attr
 It->second.second.getBegin(),
 diag::
 
err_pragma_attribute_matcher_negated_subrule_contradicts_subrule)
-<< attr::getSubjectMatchRuleSpelling(It->second.first)
-<< attr::getSubjectMatchRuleSpelling(Rule.first) << Rule.second
+<< attr::getSubjectMatchRuleSpelling(
+   attr::SubjectMatchRule(It->second.first))
+<< attr::getSubjectMatchRuleSpelling(MatchRule) << Rule.second
 << FixItHint::CreateRemoval(
replacementRangeForListElement(*this, It->second.second));
 // Keep going but ignore all of the negated sub-rules.
@@ -491,11 +493,11 @@ void Sema::ActOnPragmaAttributePush(Attr
 
 if (!IgnoreNegatedSubRules) {
   

[clang-tools-extra] r300588 - [clang-tidy] Address a few late comments.

2017-04-18 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Apr 18 15:47:34 2017
New Revision: 300588

URL: http://llvm.org/viewvc/llvm-project?rev=300588=rev
Log:
[clang-tidy] Address a few late comments.

Modified:

clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp?rev=300588=300587=300588=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp
 Tue Apr 18 15:47:34 2017
@@ -99,7 +99,8 @@ void InefficientVectorOperationCheck::re
 
 void InefficientVectorOperationCheck::check(
 const MatchFinder::MatchResult ) {
-  if (Result.Context->getDiagnostics().hasUncompilableErrorOccurred())
+  auto* Context = Result.Context;
+  if (Context->getDiagnostics().hasUncompilableErrorOccurred())
 return;
 
   const SourceManager  = *Result.SourceManager;
@@ -113,7 +114,7 @@ void InefficientVectorOperationCheck::ch
 
   llvm::SmallPtrSet AllVectorVarRefs =
   utils::decl_ref_expr::allDeclRefExprs(*VectorVarDecl, *LoopParent,
-*Result.Context);
+*Context);
   for (const auto *Ref : AllVectorVarRefs) {
 // Skip cases where there are usages (defined as DeclRefExpr that refers to
 // "v") of vector variable `v` before the for loop. We consider these 
usages
@@ -128,19 +129,19 @@ void InefficientVectorOperationCheck::ch
 }
   }
 
-  llvm::StringRef LoopEndSource = clang::Lexer::getSourceText(
+  llvm::StringRef LoopEndSource = Lexer::getSourceText(
   CharSourceRange::getTokenRange(LoopEndExpr->getSourceRange()), SM,
-  clang::LangOptions());
-  llvm::StringRef VectorVarName = clang::Lexer::getSourceText(
+  Context->getLangOpts());
+  llvm::StringRef VectorVarName = Lexer::getSourceText(
   CharSourceRange::getTokenRange(
   PushBackCall->getImplicitObjectArgument()->getSourceRange()),
-  SM, clang::LangOptions());
+  SM, Context->getLangOpts());
   std::string ReserveStmt =
   (VectorVarName + ".reserve(" + LoopEndSource + ");\n").str();
 
   diag(PushBackCall->getLocStart(),
"'push_back' is called inside a loop; "
-   "consider pre-allocating the vector capacity before the loop.")
+   "consider pre-allocating the vector capacity before the loop")
   << FixItHint::CreateInsertion(ForLoop->getLocStart(), ReserveStmt);
 }
 


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


[PATCH] D31976: Avoid assert when a non-static member function is qualified with __unaligned

2017-04-18 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

I see, thank you for the explanation.


https://reviews.llvm.org/D31976



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


[PATCH] D32187: [CodeGen][ObjC]

2017-04-18 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.

This fixes a bug in EmitObjCForCollectionStmt which is causing clang to 
generate malformed IR.

When the following code (which I think is legal, at least when it is not 
compiled with ARC) is compiled:

$ cat test1.m

  @interface Obj
  @end
  void bar(void);
  void foo(Obj *o) {
Obj *i;
for (i in o) {
thing:
  bar();
}
goto thing;
  }

the compilation terminates with the messages "Instruction does not dominate all 
uses!".

This patch fixes the bug by using temporary local variables instead of PHI 
instructions and moving instructions to locations that dominate their uses.

The example I showed still fails to compile (with an assertion) when compiled 
with -fobjc-arc, but I think that is a separate bug.

rdar://problem/31670637


https://reviews.llvm.org/D32187

Files:
  lib/CodeGen/CGObjC.cpp
  test/CodeGenObjC/arc-foreach.m

Index: test/CodeGenObjC/arc-foreach.m
===
--- test/CodeGenObjC/arc-foreach.m
+++ test/CodeGenObjC/arc-foreach.m
@@ -26,6 +26,9 @@
 // CHECK-LP64:  [[ARRAY:%.*]] = alloca [[ARRAY_T:%.*]]*,
 // CHECK-LP64-NEXT: [[X:%.*]] = alloca i8*,
 // CHECK-LP64-NEXT: [[STATE:%.*]] = alloca [[STATE_T:%.*]],
+// CHECK-LP64-NEXT: [[INDEX:%.*]] = alloca [[INDEX_T:.*]],
+// CHECK-LP64-NEXT: [[COUNT:%.*]] = alloca [[COUNT_T:.*]],
+// CHECK-LP64-NEXT: [[MUTATION:%.*]] = alloca [[MUTATION_T:.*]],
 // CHECK-LP64-NEXT: [[BUFFER:%.*]] = alloca [16 x i8*], align 8
 // CHECK-LP64-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
 
@@ -50,13 +53,29 @@
 // CHECK-LP64-NEXT: [[T1:%.*]] = bitcast [[ARRAY_T]]* [[SAVED_ARRAY]] to i8*
 // CHECK-LP64-NEXT: [[SIZE:%.*]] = call i64 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i64 (i8*, i8*, [[STATE_T]]*, [16 x i8*]*, i64)*)(i8* [[T1]], i8* [[T0]], [[STATE_T]]* [[STATE]], [16 x i8*]* [[BUFFER]], i64 16)
 
+// CHECK-LP64-NEXT: [[MUTATIONPTRPTR:%.*]] = getelementptr inbounds [[STATE_T]], [[STATE_T]]* [[STATE]]
+
 // Check for a nonzero result.
 // CHECK-LP64-NEXT: [[T0:%.*]] = icmp eq i64 [[SIZE]], 0
 // CHECK-LP64-NEXT: br i1 [[T0]]
 
+// Initialize count, index, and mutation.
+// CHECK-LP64: [[MUTATIONPTR:%.*]] = load [[MUTATION_T]]*, [[MUTATION_T]]** [[MUTATIONPTRPTR]]
+// CHECK-LP64: [[INITIALMUTATIONVAL:%.*]] = load [[MUTATION_T]], [[MUTATION_T]]* [[MUTATIONPTR]]
+// CHECK-LP64: store [[MUTATION_T]] [[INITIALMUTATIONVAL]], [[MUTATION_T]]* [[MUTATION]]
+// CHECK-LP64: store [[INDEX_T]] 0, [[INDEX_T]]* [[INDEX]]
+// CHECK-LP64: store [[COUNT_T]] [[SIZE]], [[COUNT_T]]* [[COUNT]]
+
+// Check for mutation.
+// CHECK-LP64: [[MUTATIONPTR:%.*]] = load [[MUTATION_T]]*, [[MUTATION_T]]** [[MUTATIONPTRPTR]]
+// CHECK-LP64: [[MUTATIONSTATE:%.*]] = load [[MUTATION_T]], [[MUTATION_T]]* [[MUTATIONPTR]]
+// CHECK-LP64: [[INITIALMUTATIONVAL:%.*]] = load [[MUTATION_T]], [[MUTATION_T]]* [[MUTATION]]
+// CHECK-LP64: icmp eq [[MUTATION_T]] [[MUTATIONSTATE]], [[INITIALMUTATIONVAL]]
+
 // CHECK-LP64:  [[T0:%.*]] = getelementptr inbounds [[STATE_T]], [[STATE_T]]* [[STATE]], i32 0, i32 1
 // CHECK-LP64-NEXT: [[T1:%.*]] = load i8**, i8*** [[T0]]
-// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr i8*, i8** [[T1]], i64
+// CHECK-LP64-NEXT: [[INDEXVAL:%.*]] = load [[INDEX_T]], [[INDEX_T]]* [[INDEX]]
+// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr i8*, i8** [[T1]], i64 [[INDEXVAL]]
 // CHECK-LP64-NEXT: [[T3:%.*]] = load i8*, i8** [[T2]]
 // CHECK-LP64-NEXT: store i8* [[T3]], i8** [[X]]
 
@@ -69,9 +88,18 @@
 // CHECK-LP64: call void @use_block(
 // CHECK-LP64-NEXT: call void @objc_storeStrong(i8** [[D0]], i8* null)
 
+// Increment index.
+// CHECK-LP64: [[INDEXVAL:%.*]] = load [[INDEX_T]], [[INDEX_T]]* [[INDEX]]
+// CHECK-LP64: [[T0:%.*]] = add [[INDEX_T]] [[INDEXVAL]], 1
+// CHECK-LP64: store [[INDEX_T]] [[T0]], [[INDEX_T]]* [[INDEX]]
+// CHECK-LP64: [[COUNTVAL:%.*]] = load [[COUNT_T]], [[COUNT_T]]* [[COUNT]]
+// CHECK-LP64: icmp ult [[COUNT_T]] [[T0]], [[COUNTVAL]]
+
 // CHECK-LP64:  [[T0:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_
 // CHECK-LP64-NEXT: [[T1:%.*]] = bitcast [[ARRAY_T]]* [[SAVED_ARRAY]] to i8*
 // CHECK-LP64-NEXT: [[SIZE:%.*]] = call i64 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i64 (i8*, i8*, [[STATE_T]]*, [16 x i8*]*, i64)*)(i8* [[T1]], i8* [[T0]], [[STATE_T]]* [[STATE]], [16 x i8*]* [[BUFFER]], i64 16)
+// CHECK-LP64: store [[INDEX_T]] 0, [[INDEX_T]]* [[INDEX]]
+// CHECK-LP64: store [[COUNT_T]] [[SIZE]], [[COUNT_T]]* [[COUNT]]
 
 // Release the array.
 // CHECK-LP64:  [[T0:%.*]] = bitcast [[ARRAY_T]]* [[SAVED_ARRAY]] to i8*
@@ -99,12 +127,16 @@
 // CHECK-LP64:  alloca [[ARRAY_T:%.*]]*,
 // CHECK-LP64-NEXT: [[X:%.*]] = alloca i8*,
 // CHECK-LP64-NEXT: [[STATE:%.*]] = alloca [[STATE_T:%.*]],
+// CHECK-LP64-NEXT: [[INDEX:%.*]] = alloca [[INDEX_T:.*]],
+// CHECK-LP64-NEXT: [[COUNT:%.*]] = alloca [[COUNT_T:.*]],
+// CHECK-LP64-NEXT: [[MUTATION:%.*]] = alloca [[MUTATION_T:.*]],
 // CHECK-LP64-NEXT: alloca [16 x i8*], align 8
 // 

[PATCH] D32046: [Preprocessor]Correct Macro-Arg allocation of StringifiedArguments, correct getNumArguments

2017-04-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Bump!  I'll note that this patch has nothing to do with MSVC and should simply 
be a memory-usage savings.


https://reviews.llvm.org/D32046



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


[libcxx] r300581 - [test] Silence another unused-typedef warning

2017-04-18 Thread Casey Carter via cfe-commits
Author: caseycarter
Date: Tue Apr 18 15:04:39 2017
New Revision: 300581

URL: http://llvm.org/viewvc/llvm-project?rev=300581=rev
Log:
[test] Silence another unused-typedef warning

Modified:

libcxx/trunk/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp?rev=300581=300580=300581=diff
==
--- 
libcxx/trunk/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp
 Tue Apr 18 15:04:39 2017
@@ -78,7 +78,6 @@ void test_sfinae() {
   using DA = NCConvertingDeleter;// non-copyable deleters
   using DAC = NCConvertingDeleter; // non-copyable deleters
 
-  using DB = NCConvertingDeleter;
   using UA = std::unique_ptr;
   using UAC = std::unique_ptr;
   using UAD = std::unique_ptr;


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


r300578 - [DOXYGEN] Minor improvements in doxygen comments.

2017-04-18 Thread Ekaterina Romanova via cfe-commits
Author: kromanova
Date: Tue Apr 18 14:44:07 2017
New Revision: 300578

URL: http://llvm.org/viewvc/llvm-project?rev=300578=rev
Log:
[DOXYGEN] Minor improvements in doxygen comments.

- To be consistent with the rest of the intrinsics headers, I removed the tags 
 ..  for marking instruction names in italics in in smmintrin.h. 

- Formatting changes to fit into 80 characters. 

I got an OK from Eric Christopher to commit doxygen comments without prior code
review upstream.


Modified:
cfe/trunk/lib/Headers/smmintrin.h
cfe/trunk/lib/Headers/xmmintrin.h

Modified: cfe/trunk/lib/Headers/smmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/smmintrin.h?rev=300578=300577=300578=diff
==
--- cfe/trunk/lib/Headers/smmintrin.h (original)
+++ cfe/trunk/lib/Headers/smmintrin.h Tue Apr 18 14:44:07 2017
@@ -56,8 +56,7 @@
 /// __m128 _mm_ceil_ps(__m128 X);
 /// \endcode
 ///
-/// This intrinsic corresponds to the   VROUNDPS / ROUNDPS  
-/// instruction.
+/// This intrinsic corresponds to the  VROUNDPS / ROUNDPS  instruction.
 ///
 /// \param X
 ///A 128-bit vector of [4 x float] values to be rounded up.
@@ -74,8 +73,7 @@
 /// __m128d _mm_ceil_pd(__m128d X);
 /// \endcode
 ///
-/// This intrinsic corresponds to the   VROUNDPD / ROUNDPD  
-/// instruction.
+/// This intrinsic corresponds to the  VROUNDPD / ROUNDPD  instruction.
 ///
 /// \param X
 ///A 128-bit vector of [2 x double] values to be rounded up.
@@ -94,8 +92,7 @@
 /// __m128 _mm_ceil_ss(__m128 X, __m128 Y);
 /// \endcode
 ///
-/// This intrinsic corresponds to the   VROUNDSS / ROUNDSS  
-/// instruction.
+/// This intrinsic corresponds to the  VROUNDSS / ROUNDSS  instruction.
 ///
 /// \param X
 ///A 128-bit vector of [4 x float]. The values stored in bits [127:32] are
@@ -120,8 +117,7 @@
 /// __m128d _mm_ceil_sd(__m128d X, __m128d Y);
 /// \endcode
 ///
-/// This intrinsic corresponds to the   VROUNDSD / ROUNDSD  
-/// instruction.
+/// This intrinsic corresponds to the  VROUNDSD / ROUNDSD  instruction.
 ///
 /// \param X
 ///A 128-bit vector of [2 x double]. The value stored in bits [127:64] is
@@ -144,8 +140,7 @@
 /// __m128 _mm_floor_ps(__m128 X);
 /// \endcode
 ///
-/// This intrinsic corresponds to the   VROUNDPS / ROUNDPS  
-/// instruction.
+/// This intrinsic corresponds to the  VROUNDPS / ROUNDPS  instruction.
 ///
 /// \param X
 ///A 128-bit vector of [4 x float] values to be rounded down.
@@ -162,8 +157,7 @@
 /// __m128d _mm_floor_pd(__m128d X);
 /// \endcode
 ///
-/// This intrinsic corresponds to the   VROUNDPD / ROUNDPD  
-/// instruction.
+/// This intrinsic corresponds to the  VROUNDPD / ROUNDPD  instruction.
 ///
 /// \param X
 ///A 128-bit vector of [2 x double].
@@ -182,8 +176,7 @@
 /// __m128 _mm_floor_ss(__m128 X, __m128 Y);
 /// \endcode
 ///
-/// This intrinsic corresponds to the   VROUNDSS / ROUNDSS  
-/// instruction.
+/// This intrinsic corresponds to the  VROUNDSS / ROUNDSS  instruction.
 ///
 /// \param X
 ///A 128-bit vector of [4 x float]. The values stored in bits [127:32] are
@@ -208,8 +201,7 @@
 /// __m128d _mm_floor_sd(__m128d X, __m128d Y);
 /// \endcode
 ///
-/// This intrinsic corresponds to the   VROUNDSD / ROUNDSD  
-/// instruction.
+/// This intrinsic corresponds to the  VROUNDSD / ROUNDSD  instruction.
 ///
 /// \param X
 ///A 128-bit vector of [2 x double]. The value stored in bits [127:64] is
@@ -233,8 +225,7 @@
 /// __m128 _mm_round_ps(__m128 X, const int M);
 /// \endcode
 ///
-/// This intrinsic corresponds to the   VROUNDPS / ROUNDPS  
-/// instruction.
+/// This intrinsic corresponds to the  VROUNDPS / ROUNDPS  instruction.
 ///
 /// \param X
 ///A 128-bit vector of [4 x float].
@@ -269,8 +260,7 @@
 /// __m128 _mm_round_ss(__m128 X, __m128 Y, const int M);
 /// \endcode
 ///
-/// This intrinsic corresponds to the   VROUNDSS / ROUNDSS  
-/// instruction.
+/// This intrinsic corresponds to the  VROUNDSS / ROUNDSS  instruction.
 ///
 /// \param X
 ///A 128-bit vector of [4 x float]. The values stored in bits [127:32] are
@@ -310,8 +300,7 @@
 /// __m128d _mm_round_pd(__m128d X, const int M);
 /// \endcode
 ///
-/// This intrinsic corresponds to the   VROUNDPD / ROUNDPD  
-/// instruction.
+/// This intrinsic corresponds to the  VROUNDPD / ROUNDPD  instruction.
 ///
 /// \param X
 ///A 128-bit vector of [2 x double].
@@ -333,7 +322,6 @@
 #define _mm_round_pd(X, M) __extension__ ({ \
   (__m128d)__builtin_ia32_roundpd((__v2df)(__m128d)(X), (M)); })
 
-
 /// \brief Copies the upper element of the first 128-bit vector operand to the
 ///corresponding upper element of the 128-bit result vector of [2 x 
double].
 ///Rounds the lower element of the second 128-bit vector operand to an
@@ -347,8 +335,7 @@
 /// __m128d _mm_round_sd(__m128d X, __m128d Y, const int M);
 /// \endcode
 ///
-/// This intrinsic corresponds to the   VROUNDSD / ROUNDSD  
-/// instruction.
+/// 

[PATCH] D32064: [asan] Disable ASan global-GC depending on the target and compiler flags

2017-04-18 Thread Evgeniy Stepanov via Phabricator via cfe-commits
eugenis added a comment.

Ping.
I don't really have a preference.


Repository:
  rL LLVM

https://reviews.llvm.org/D32064



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


Re: [libcxx] r300575 - [test] Silence unused parameter/typedef warnings

2017-04-18 Thread Eric Fiselier via cfe-commits
Sorry I've been meaning to enable `-Wunused-typedef" for a while but I
haven't had a chance to clean up the remaining occurrences

Thanks for the cleanup.

On Tue, Apr 18, 2017 at 12:44 PM, Casey Carter via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: caseycarter
> Date: Tue Apr 18 13:44:33 2017
> New Revision: 300575
>
> URL: http://llvm.org/viewvc/llvm-project?rev=300575=rev
> Log:
> [test] Silence unused parameter/typedef warnings
>
> Modified:
> libcxx/trunk/test/std/language.support/support.
> exception/except.nested/throw_with_nested.pass.cpp
> libcxx/trunk/test/std/utilities/smartptr/unique.ptr/
> unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp
> libcxx/trunk/test/std/utilities/smartptr/unique.ptr/
> unique.ptr.class/unique.ptr.ctor/default.pass.cpp
>
> Modified: libcxx/trunk/test/std/language.support/support.
> exception/except.nested/throw_with_nested.pass.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/
> language.support/support.exception/except.nested/throw_
> with_nested.pass.cpp?rev=300575=300574=300575=diff
> 
> ==
> --- libcxx/trunk/test/std/language.support/support.
> exception/except.nested/throw_with_nested.pass.cpp (original)
> +++ libcxx/trunk/test/std/language.support/support.
> exception/except.nested/throw_with_nested.pass.cpp Tue Apr 18 13:44:33
> 2017
> @@ -113,7 +113,7 @@ int main()
>  std::throw_with_nested("String literal");
>  assert(false);
>  }
> -catch (const char * s)
> +catch (const char *)
>  {
>  }
>  }
>
> Modified: libcxx/trunk/test/std/utilities/smartptr/unique.ptr/
> unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/
> utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.
> asgn/move_convert.runtime.pass.cpp?rev=300575=300574&
> r2=300575=diff
> 
> ==
> --- libcxx/trunk/test/std/utilities/smartptr/unique.ptr/
> unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp (original)
> +++ libcxx/trunk/test/std/utilities/smartptr/unique.ptr/
> unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp Tue Apr 18
> 13:44:33 2017
> @@ -81,11 +81,9 @@ void test_sfinae() {
>using DB = NCConvertingDeleter;
>using UA = std::unique_ptr;
>using UAC = std::unique_ptr;
> -  using UB = std::unique_ptr;
>using UAD = std::unique_ptr;
>using UACD = std::unique_ptr;
>
> -  using UBD = std::unique_ptr;
>{ // cannot move from an lvalue
>  static_assert(std::is_assignable::value, "");
>  static_assert(!std::is_assignable::value, "");
>
> Modified: libcxx/trunk/test/std/utilities/smartptr/unique.ptr/
> unique.ptr.class/unique.ptr.ctor/default.pass.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/
> utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.
> ctor/default.pass.cpp?rev=300575=300574=300575=diff
> 
> ==
> --- libcxx/trunk/test/std/utilities/smartptr/unique.ptr/
> unique.ptr.class/unique.ptr.ctor/default.pass.cpp (original)
> +++ libcxx/trunk/test/std/utilities/smartptr/unique.ptr/
> unique.ptr.class/unique.ptr.ctor/default.pass.cpp Tue Apr 18 13:44:33 2017
> @@ -46,7 +46,7 @@ struct NonDefaultDeleter {
>  template 
>  void test_sfinae() {
>  #if TEST_STD_VER >= 11
> -  { // the constructor does not participate in overload resultion when
> +  { // the constructor does not participate in overload resolution when
>  // the deleter is a pointer type
>  using U = std::unique_ptr;
>  static_assert(!std::is_default_constructible::value, "");
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r300575 - [test] Silence unused parameter/typedef warnings

2017-04-18 Thread Casey Carter via cfe-commits
Author: caseycarter
Date: Tue Apr 18 13:44:33 2017
New Revision: 300575

URL: http://llvm.org/viewvc/llvm-project?rev=300575=rev
Log:
[test] Silence unused parameter/typedef warnings

Modified:

libcxx/trunk/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp

libcxx/trunk/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp

libcxx/trunk/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/default.pass.cpp

Modified: 
libcxx/trunk/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp?rev=300575=300574=300575=diff
==
--- 
libcxx/trunk/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
 Tue Apr 18 13:44:33 2017
@@ -113,7 +113,7 @@ int main()
 std::throw_with_nested("String literal");
 assert(false);
 }
-catch (const char * s)
+catch (const char *)
 {
 }
 }

Modified: 
libcxx/trunk/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp?rev=300575=300574=300575=diff
==
--- 
libcxx/trunk/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.asgn/move_convert.runtime.pass.cpp
 Tue Apr 18 13:44:33 2017
@@ -81,11 +81,9 @@ void test_sfinae() {
   using DB = NCConvertingDeleter;
   using UA = std::unique_ptr;
   using UAC = std::unique_ptr;
-  using UB = std::unique_ptr;
   using UAD = std::unique_ptr;
   using UACD = std::unique_ptr;
 
-  using UBD = std::unique_ptr;
   { // cannot move from an lvalue
 static_assert(std::is_assignable::value, "");
 static_assert(!std::is_assignable::value, "");

Modified: 
libcxx/trunk/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/default.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/default.pass.cpp?rev=300575=300574=300575=diff
==
--- 
libcxx/trunk/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/default.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/default.pass.cpp
 Tue Apr 18 13:44:33 2017
@@ -46,7 +46,7 @@ struct NonDefaultDeleter {
 template 
 void test_sfinae() {
 #if TEST_STD_VER >= 11
-  { // the constructor does not participate in overload resultion when
+  { // the constructor does not participate in overload resolution when
 // the deleter is a pointer type
 using U = std::unique_ptr;
 static_assert(!std::is_default_constructible::value, "");


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


[PATCH] D32119: Emit warning when umbrella directory does not exists

2017-04-18 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev accepted this revision.
v.g.vassilev added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D32119



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


[PATCH] D24886: Add [[clang::suppress(rule, ...)]] attribute

2017-04-18 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: cfe/trunk/include/clang/Basic/AttrDocs.td:2792
+  namespace N {
+[[clang::suppress("type", "bounds")]];
+...

Should this be `gsl::suppress` as well?


Repository:
  rL LLVM

https://reviews.llvm.org/D24886



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


[PATCH] D32181: Remove use of coverage-file flag

2017-04-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.

The -coverage-file flag was removed in r280306, but I believe this part may 
have been missed. However, since I'm unfamiliar with this feature, I wanted to 
be sure.


https://reviews.llvm.org/D32181

Files:
  lib/Driver/Job.cpp


Index: lib/Driver/Job.cpp
===
--- lib/Driver/Job.cpp
+++ lib/Driver/Job.cpp
@@ -49,7 +49,7 @@
   // arguments.  Therefore, we need to skip the flag and the next argument.
   bool ShouldSkip = llvm::StringSwitch(Flag)
 .Cases("-MF", "-MT", "-MQ", "-serialize-diagnostic-file", true)
-.Cases("-o", "-coverage-file", "-dependency-file", true)
+.Cases("-o", "-dependency-file", true)
 .Cases("-fdebug-compilation-dir", "-diagnostic-log-file", true)
 .Cases("-dwarf-debug-flags", "-ivfsoverlay", true)
 .Default(false);


Index: lib/Driver/Job.cpp
===
--- lib/Driver/Job.cpp
+++ lib/Driver/Job.cpp
@@ -49,7 +49,7 @@
   // arguments.  Therefore, we need to skip the flag and the next argument.
   bool ShouldSkip = llvm::StringSwitch(Flag)
 .Cases("-MF", "-MT", "-MQ", "-serialize-diagnostic-file", true)
-.Cases("-o", "-coverage-file", "-dependency-file", true)
+.Cases("-o", "-dependency-file", true)
 .Cases("-fdebug-compilation-dir", "-diagnostic-log-file", true)
 .Cases("-dwarf-debug-flags", "-ivfsoverlay", true)
 .Default(false);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31542: [clang-tidy] Extend readability-container-size-empty to add comparisons to newly-constructed objects

2017-04-18 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

LG with one nit.




Comment at: clang-tidy/readability/ContainerSizeEmptyCheck.cpp:209
+ "the 'empty' method should be used to check "
+ "for emptiness instead of comparing to an empty object.")
+<< Hint;

nit: Please remove the trailing period to follow the style other diagnostic 
messages use.


Repository:
  rL LLVM

https://reviews.llvm.org/D31542



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


[PATCH] D32014: Remove unused varible

2017-04-18 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL300572: Remove unused varible (authored by rnk).

Changed prior to commit:
  https://reviews.llvm.org/D32014?vs=95123=95602#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32014

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


Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -1391,8 +1391,6 @@
 }
 
 bool Sema::CheckARMBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
-  llvm::APSInt Result;
-
   if (BuiltinID == ARM::BI__builtin_arm_ldrex ||
   BuiltinID == ARM::BI__builtin_arm_ldaex ||
   BuiltinID == ARM::BI__builtin_arm_strex ||
@@ -1439,8 +1437,6 @@
 
 bool Sema::CheckAArch64BuiltinFunctionCall(unsigned BuiltinID,
  CallExpr *TheCall) {
-  llvm::APSInt Result;
-
   if (BuiltinID == AArch64::BI__builtin_arm_ldrex ||
   BuiltinID == AArch64::BI__builtin_arm_ldaex ||
   BuiltinID == AArch64::BI__builtin_arm_strex ||


Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -1391,8 +1391,6 @@
 }
 
 bool Sema::CheckARMBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
-  llvm::APSInt Result;
-
   if (BuiltinID == ARM::BI__builtin_arm_ldrex ||
   BuiltinID == ARM::BI__builtin_arm_ldaex ||
   BuiltinID == ARM::BI__builtin_arm_strex ||
@@ -1439,8 +1437,6 @@
 
 bool Sema::CheckAArch64BuiltinFunctionCall(unsigned BuiltinID,
  CallExpr *TheCall) {
-  llvm::APSInt Result;
-
   if (BuiltinID == AArch64::BI__builtin_arm_ldrex ||
   BuiltinID == AArch64::BI__builtin_arm_ldaex ||
   BuiltinID == AArch64::BI__builtin_arm_strex ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r300572 - Remove unused varible

2017-04-18 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Apr 18 12:44:41 2017
New Revision: 300572

URL: http://llvm.org/viewvc/llvm-project?rev=300572=rev
Log:
Remove unused varible

The Result variable is unused both in Sema::CheckARMBuiltinFunctionCall
and Sema::CheckAArch64BuiltinFunctionCall, remove it.

Patch by Wei-Ren Chen!

Reviewers: craig.topper, rnk

Reviewed By: rnk

Subscribers: aemerson, cfe-commits, rengolin

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

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=300572=300571=300572=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Apr 18 12:44:41 2017
@@ -1391,8 +1391,6 @@ bool Sema::CheckARMBuiltinExclusiveCall(
 }
 
 bool Sema::CheckARMBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
-  llvm::APSInt Result;
-
   if (BuiltinID == ARM::BI__builtin_arm_ldrex ||
   BuiltinID == ARM::BI__builtin_arm_ldaex ||
   BuiltinID == ARM::BI__builtin_arm_strex ||
@@ -1439,8 +1437,6 @@ bool Sema::CheckARMBuiltinFunctionCall(u
 
 bool Sema::CheckAArch64BuiltinFunctionCall(unsigned BuiltinID,
  CallExpr *TheCall) {
-  llvm::APSInt Result;
-
   if (BuiltinID == AArch64::BI__builtin_arm_ldrex ||
   BuiltinID == AArch64::BI__builtin_arm_ldaex ||
   BuiltinID == AArch64::BI__builtin_arm_strex ||


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


r300571 - [AArch64][clang] Pass cpu/arch information to assembler for AArch64.

2017-04-18 Thread Manoj Gupta via cfe-commits
Author: manojgupta
Date: Tue Apr 18 12:36:10 2017
New Revision: 300571

URL: http://llvm.org/viewvc/llvm-project?rev=300571=rev
Log:
[AArch64][clang] Pass cpu/arch information to assembler for AArch64.

Summary:
Pass Cpu/Arch options to assembler for AArch64 with no-integrated-as.
This fixes PR20019.

Reviewers: richard.barton.arm, kristof.beyls, rengolin

Reviewed By: rengolin

Subscribers: srhines, pirama, aemerson, rengolin, cfe-commits

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/linux-as.c

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=300571=300570=300571=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Tue Apr 18 12:36:10 2017
@@ -770,6 +770,12 @@ void tools::gnutools::Assembler::Constru
 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);
 break;
   }
+  case llvm::Triple::aarch64:
+  case llvm::Triple::aarch64_be: {
+Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
+Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+break;
+  }
   case llvm::Triple::mips:
   case llvm::Triple::mipsel:
   case llvm::Triple::mips64:

Modified: cfe/trunk/test/Driver/linux-as.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-as.c?rev=300571=300570=300571=diff
==
--- cfe/trunk/test/Driver/linux-as.c (original)
+++ cfe/trunk/test/Driver/linux-as.c Tue Apr 18 12:36:10 2017
@@ -100,6 +100,33 @@
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-HARDFP %s
 // CHECK-ARM-HARDFP: as{{(.exe)?}}" "-mfloat-abi=hard"
 //
+// RUN: %clang -target aarch64-linux-gnu -mcpu=cortex-a53 -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM64-MCPU %s
+// CHECK-ARM64-MCPU: as{{(.exe)?}}" "-mcpu=cortex-a53"
+//
+// RUN: %clang -target aarch64-linux-gnu -march=armv8-a -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM64-MARCH %s
+// CHECK-ARM64-MARCH: as{{(.exe)?}}" "-march=armv8-a"
+//
+// RUN: %clang -target aarch64-linux-gnu -mcpu=cortex-a53 -march=armv8-a -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM64-ALL %s
+// CHECK-ARM64-ALL: as{{(.exe)?}}" "-march=armv8-a" "-mcpu=cortex-a53"
+//
+// RUN: %clang -target aarch64_be-linux-gnu -mcpu=cortex-a53 -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM64-MCPU %s
+//
+// RUN: %clang -target aarch64_be-linux-gnu -march=armv8-a -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM64-MARCH %s
+//
+// RUN: %clang -target aarch64_be-linux-gnu -mcpu=cortex-a53 -march=armv8-a 
-### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM64-ALL %s
+//
 // RUN: %clang -target ppc-linux -mcpu=invalid-cpu -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-PPC-NO-MCPU %s


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


r300570 - Testing commit access.

2017-04-18 Thread Manoj Gupta via cfe-commits
Author: manojgupta
Date: Tue Apr 18 12:34:46 2017
New Revision: 300570

URL: http://llvm.org/viewvc/llvm-project?rev=300570=rev
Log:
Testing commit access.

Summary: Test commit access.

Reviewers: gbiv, george.burgess.iv

Reviewed By: george.burgess.iv

Subscribers: cfe-commits

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

Modified:
cfe/trunk/unittests/Driver/ToolChainTest.cpp

Modified: cfe/trunk/unittests/Driver/ToolChainTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Driver/ToolChainTest.cpp?rev=300570=300569=300570=diff
==
--- cfe/trunk/unittests/Driver/ToolChainTest.cpp (original)
+++ cfe/trunk/unittests/Driver/ToolChainTest.cpp Tue Apr 18 12:34:46 2017
@@ -142,4 +142,4 @@ TEST(ToolChainTest, DefaultDriverMode) {
   EXPECT_TRUE(CLDriver.IsCLMode());
 }
 
-} // end anonymous namespace
+} // end anonymous namespace.


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


[clang-tools-extra] r300569 - [clang-tidy] Fix google-explicit-constructor issue with out-of-line conversions

2017-04-18 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue Apr 18 12:26:00 2017
New Revision: 300569

URL: http://llvm.org/viewvc/llvm-project?rev=300569=rev
Log:
[clang-tidy] Fix google-explicit-constructor issue with out-of-line conversions

Modified:
clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp

Modified: clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp?rev=300569=300568=300569=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp Tue 
Apr 18 12:26:00 2017
@@ -91,6 +91,8 @@ void ExplicitConstructorCheck::check(con
 
   if (const auto *Conversion =
   Result.Nodes.getNodeAs("conversion")) {
+if (Conversion->isOutOfLine())
+  return;
 SourceLocation Loc = Conversion->getLocation();
 // Ignore all macros until we learn to ignore specific ones (e.g. used in
 // gmock to define matchers).

Modified: 
clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp?rev=300569=300568=300569=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp Tue 
Apr 18 12:26:00 2017
@@ -46,9 +46,9 @@ struct A {
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: copy constructor should not be 
declared explicit [google-explicit-constructor]
   // CHECK-FIXES: {{^  }}A(const A& a) {}
 
-  A(int x1) {}
+  A(int x1);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: single-argument constructors 
must be marked explicit to avoid unintentional implicit conversions 
[google-explicit-constructor]
-  // CHECK-FIXES: {{^  }}explicit A(int x1) {}
+  // CHECK-FIXES: {{^  }}explicit A(int x1);
 
   A(double x2, double y = 3.14) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructors that are callable 
with a single argument must be marked explicit to avoid unintentional implicit 
conversions [google-explicit-constructor]
@@ -60,6 +60,8 @@ struct A {
   // CHECK-FIXES: {{^  }}explicit A(T&&... args);
 };
 
+inline A::A(int x1) {}
+
 struct B {
   B(std::initializer_list list1) {}
   B(const std::initializer_list ) {}
@@ -69,6 +71,10 @@ struct B {
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'operator bool' must be marked 
explicit to avoid unintentional implicit conversions 
[google-explicit-constructor]
   // CHECK-FIXES: {{^  }}explicit operator bool() const { return true; }
 
+  operator double() const;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'operator double' must be marked 
explicit to avoid unintentional implicit conversions 
[google-explicit-constructor]
+  // CHECK-FIXES: {{^  }}explicit operator double() const;
+
   explicit B(::std::initializer_list list4) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: initializer-list constructor 
should not be declared explicit [google-explicit-constructor]
   // CHECK-FIXES: {{^  }}B(::std::initializer_list list4) {}
@@ -82,6 +88,8 @@ struct B {
   // CHECK-FIXES: {{^  }}B(::std::initializer_list &) {}
 };
 
+inline B::operator double() const { return 0.0; }
+
 struct StructWithFnPointer {
   void (*f)();
 } struct_with_fn_pointer = {[] {}};


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


[libcxx] r300568 - Mark LWG#2788 as complete - we already do this

2017-04-18 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Apr 18 12:22:49 2017
New Revision: 300568

URL: http://llvm.org/viewvc/llvm-project?rev=300568=rev
Log:
Mark LWG#2788 as complete - we already do this

Modified:
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=300568=300567=300568=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Tue Apr 18 12:22:49 2017
@@ -442,7 +442,7 @@
http://wg21.link/LWG2785;>2785quoted 
should work with basic_string_viewKonaComplete
http://wg21.link/LWG2786;>2786Annex C 
should mention shared_ptr changes for array 
supportKonaComplete
http://wg21.link/LWG2787;>2787[file_status.cons] 
doesn't match class definitionKonaComplete
-   http://wg21.link/LWG2788;>2788basic_string range mutators 
unintentionally require a default constructible 
allocatorKona
+   http://wg21.link/LWG2788;>2788basic_string range mutators 
unintentionally require a default constructible 
allocatorKonaComplete
http://wg21.link/LWG2789;>2789Equivalence 
of contained objectsKonaComplete
http://wg21.link/LWG2790;>2790Missing 
specification of 
istreambuf_iterator::operator-Kona
http://wg21.link/LWG2794;>2794Missing 
requirements for allocator pointersKona


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


[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-18 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Awesome, thanks! A few late comments inline.




Comment at: 
clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp:56
+void InefficientVectorOperationCheck::registerMatchers(MatchFinder *Finder) {
+  const auto VectorDecl = cxxRecordDecl(hasName("::std::vector"));
+  const auto VectorDefaultConstructorCall = cxxConstructExpr(

It might make sense to make the list of types configurable to support custom 
vector-like types.



Comment at: 
clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp:65
+  cxxMemberCallExpr(
+  callee(cxxMethodDecl(hasName("push_back"))), on(hasType(VectorDecl)),
+  onImplicitObjectArgument(declRefExpr(to(VectorVarDecl

Loops with `emplace_back` would suffer from the same issue.



Comment at: 
clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp:131
+
+  llvm::StringRef LoopEndSource = clang::Lexer::getSourceText(
+  CharSourceRange::getTokenRange(LoopEndExpr->getSourceRange()), SM,

No need to namespace-qualify StringRef and Lexer.



Comment at: 
clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp:133
+  CharSourceRange::getTokenRange(LoopEndExpr->getSourceRange()), SM,
+  clang::LangOptions());
+  llvm::StringRef VectorVarName = clang::Lexer::getSourceText(

Actual LangOptions should be used instead of a default-constructed instance. 
Same below.



Comment at: 
clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp:143
+   "'push_back' is called inside a loop; "
+   "consider pre-allocating the vector capacity before the loop.")
+  << FixItHint::CreateInsertion(ForLoop->getLocStart(), ReserveStmt);

Please remove the trailing period.


Repository:
  rL LLVM

https://reviews.llvm.org/D31757



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


[PATCH] D32178: Delete unstable integration tests

2017-04-18 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs created this revision.

These tests are breaking when tested under the upstream 3.8.1 release + the 
10.12 / 16C58 sdk. They use headers from the host SDKs, so they are not stable 
with respect to adding new language features, such as class `@properties`.

Regression tests should not depend at all on the state of the host system. If 
these tests are still useful, they ought to live somewhere else (test-suite?).


https://reviews.llvm.org/D32178

Files:
  test/Integration/carbon.c
  test/Integration/cocoa-pch.m
  test/Integration/cocoa.m


Index: test/Integration/cocoa.m
===
--- test/Integration/cocoa.m
+++ test/Integration/cocoa.m
@@ -1,5 +0,0 @@
-// RUN: %clang -arch x86_64 %s -fsyntax-only -Xclang -print-stats
-#ifdef __APPLE__
-#include 
-#endif
-
Index: test/Integration/cocoa-pch.m
===
--- test/Integration/cocoa-pch.m
+++ test/Integration/cocoa-pch.m
@@ -1,7 +0,0 @@
-// RUN: %clang -arch x86_64 -x objective-c-header %s -o %t.h.pch
-// RUN: touch %t.empty.m
-// RUN: %clang -arch x86_64 -fsyntax-only %t.empty.m -include %t.h -Xclang 
-ast-dump 2>&1 > /dev/null
-#ifdef __APPLE__
-#include 
-#endif
-
Index: test/Integration/carbon.c
===
--- test/Integration/carbon.c
+++ test/Integration/carbon.c
@@ -1,4 +0,0 @@
-// RUN: %clang -fsyntax-only %s
-#ifdef __APPLE__
-#include 
-#endif


Index: test/Integration/cocoa.m
===
--- test/Integration/cocoa.m
+++ test/Integration/cocoa.m
@@ -1,5 +0,0 @@
-// RUN: %clang -arch x86_64 %s -fsyntax-only -Xclang -print-stats
-#ifdef __APPLE__
-#include 
-#endif
-
Index: test/Integration/cocoa-pch.m
===
--- test/Integration/cocoa-pch.m
+++ test/Integration/cocoa-pch.m
@@ -1,7 +0,0 @@
-// RUN: %clang -arch x86_64 -x objective-c-header %s -o %t.h.pch
-// RUN: touch %t.empty.m
-// RUN: %clang -arch x86_64 -fsyntax-only %t.empty.m -include %t.h -Xclang -ast-dump 2>&1 > /dev/null
-#ifdef __APPLE__
-#include 
-#endif
-
Index: test/Integration/carbon.c
===
--- test/Integration/carbon.c
+++ test/Integration/carbon.c
@@ -1,4 +0,0 @@
-// RUN: %clang -fsyntax-only %s
-#ifdef __APPLE__
-#include 
-#endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32081: Add support for editor placeholders to Clang's lexer

2017-04-18 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 95596.
arphaman marked 2 inline comments as done.
arphaman added a comment.

Add comments and remove `-fno-allow-editor-placeholders` from CC1 options.


Repository:
  rL LLVM

https://reviews.llvm.org/D32081

Files:
  include/clang/Basic/DiagnosticLexKinds.td
  include/clang/Basic/IdentifierTable.h
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  include/clang/Lex/Lexer.h
  include/clang/Lex/Token.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Lex/Lexer.cpp
  lib/Parse/Parser.cpp
  lib/Sema/SemaCXXScopeSpec.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  test/Driver/clang_f_opts.c
  test/Parser/editor-placeholder-recovery.cpp
  test/Parser/placeholder-recovery.m

Index: test/Parser/placeholder-recovery.m
===
--- test/Parser/placeholder-recovery.m
+++ test/Parser/placeholder-recovery.m
@@ -1,11 +1,14 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
+@protocol NSObject
+@end
+
+@protocol <#protocol name#>  // expected-error {{editor placeholder in source file}}
+// expected-note@-1 {{protocol started here}}
+
 // FIXME: We could do much better with this, if we recognized
 // placeholders somehow. However, we're content with not generating
 // bogus 'archaic' warnings with bad location info.
-@protocol <#protocol name#>  // expected-error {{expected identifier or '('}} \
-// expected-error 2{{expected identifier}} \
-// expected-warning{{protocol has no object type specified; defaults to qualified 'id'}}
-<#methods#>
+<#methods#> // expected-error {{editor placeholder in source file}}
 
-@end
+@end // expected-error {{prefix attribute must be followed by an interface or protocol}} expected-error {{missing '@end'}}
Index: test/Parser/editor-placeholder-recovery.cpp
===
--- /dev/null
+++ test/Parser/editor-placeholder-recovery.cpp
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -fallow-editor-placeholders -DSUPPRESS -verify %s
+
+struct Struct {
+public:
+void method(Struct );
+};
+
+struct <#struct name#> {
+  int <#field-name#>;
+#ifndef SUPPRESS
+  // expected-error@-3 {{editor placeholder in source file}}
+  // expected-error@-3 {{editor placeholder in source file}}
+#endif
+};
+
+typename <#typename#>::<#name#>;
+decltype(<#expression#>) foobar;
+typedef <#type#> <#name#>;
+#ifndef SUPPRESS
+  // expected-error@-4 2 {{editor placeholder in source file}}
+  // expected-error@-4 {{editor placeholder in source file}}
+  // expected-error@-4 2 {{editor placeholder in source file}}
+#endif
+
+namespace <#identifier#> {
+  <#declarations#>
+#ifndef SUPPRESS
+  // expected-error@-3 {{editor placeholder in source file}}
+  // expected-error@-3 {{editor placeholder in source file}}
+#endif
+
+}
+
+using <#qualifier#>::<#name#>;
+#ifndef SUPPRESS
+  // expected-error@-2 2 {{editor placeholder in source file}}
+#endif
+
+void avoidPlaceholderErrors(Struct ) {
+static_cast< <#type#> >(<#expression#>);
+while (<#condition#>) {
+<#statements#>
+}
+obj.method(<#Struct #>);
+#ifndef SUPPRESS
+  // expected-error@-6 2 {{editor placeholder in source file}}
+  // expected-error@-6 {{editor placeholder in source file}}
+  // expected-error@-6 {{editor placeholder in source file}}
+  // expected-error@-5 {{editor placeholder in source file}}
+#endif
+switch (<#expression#>) {
+case <#constant#>:
+<#statements#>
+#ifndef SUPPRESS
+  // expected-error@-4 {{editor placeholder in source file}}
+  // expected-error@-4 {{editor placeholder in source file}}
+  // expected-error@-4 {{editor placeholder in source file}}
+#endif
+break;
+
+default:
+break;
+}
+}
+
+void Struct::method(<#Struct #>, noSupressionHere) { // expected-error {{unknown type name 'noSupressionHere'}} expected-error {{C++ requires a type specifier for all declarations}}
+#ifndef SUPPRESS
+  // expected-error@-2 {{editor placeholder in source file}}
+#endif
+}
Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -494,3 +494,8 @@
 // RUN: %clang -### -S -fdebug-info-for-profiling -fno-debug-info-for-profiling %s 2>&1 | FileCheck -check-prefix=CHECK-NO-PROFILE-DEBUG %s
 // CHECK-PROFILE-DEBUG: -fdebug-info-for-profiling
 // CHECK-NO-PROFILE-DEBUG-NOT: -fdebug-info-for-profiling
+
+// RUN: %clang -### -S -fallow-editor-placeholders %s 2>&1 | FileCheck -check-prefix=CHECK-ALLOW-PLACEHOLDERS %s
+// RUN: %clang -### -S -fno-allow-editor-placeholders %s 2>&1 | FileCheck -check-prefix=CHECK-NO-ALLOW-PLACEHOLDERS %s
+// CHECK-ALLOW-PLACEHOLDERS: -fallow-editor-placeholders
+// CHECK-NO-ALLOW-PLACEHOLDERS-NOT: -fallow-editor-placeholders
Index: lib/Sema/SemaExpr.cpp

[PATCH] D32164: [clang-tidy] misc-misplaced-widening-cast: Disable checking of implicit widening casts by default

2017-04-18 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D32164



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


[PATCH] D32176: Add #pragma clang attribute support for the external_source_symbol attribute

2017-04-18 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 95593.
arphaman added a comment.

Avoid a vector copy by using a reference variable.


Repository:
  rL LLVM

https://reviews.llvm.org/D32176

Files:
  include/clang/Basic/Attr.td
  lib/Sema/SemaDeclAttr.cpp
  test/Misc/pragma-attribute-supported-attributes-list.test
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -1611,7 +1611,36 @@
 
 struct PragmaClangAttributeSupport {
   std::vector Rules;
-  llvm::DenseMap SubjectsToRules;
+
+  class RuleOrAggregateRuleSet {
+std::vector Rules;
+bool IsRule;
+RuleOrAggregateRuleSet(ArrayRef Rules,
+   bool IsRule)
+: Rules(Rules.begin(), Rules.end()), IsRule(IsRule) {}
+
+  public:
+bool isRule() const { return IsRule; }
+
+AttributeSubjectMatchRule () {
+  assert(IsRule && "not a rule!");
+  return Rules[0];
+}
+
+ArrayRef getAggregateRuleSet() const {
+  return Rules;
+}
+
+static RuleOrAggregateRuleSet
+getRule(const AttributeSubjectMatchRule ) {
+  return RuleOrAggregateRuleSet(Rule, /*IsRule=*/true);
+}
+static RuleOrAggregateRuleSet
+getAggregateRuleSet(ArrayRef Rules) {
+  return RuleOrAggregateRuleSet(Rules, /*IsRule=*/false);
+}
+  };
+  llvm::DenseMap SubjectsToRules;
 
   PragmaClangAttributeSupport(RecordKeeper );
 
@@ -1626,6 +1655,15 @@
 
 } // end anonymous namespace
 
+static bool doesDeclDeriveFrom(const Record *D, const Record *Base) {
+  const Record *CurrentBase = D->getValueAsDef("Base");
+  if (!CurrentBase)
+return false;
+  if (CurrentBase == Base)
+return true;
+  return doesDeclDeriveFrom(CurrentBase, Base);
+}
+
 PragmaClangAttributeSupport::PragmaClangAttributeSupport(
 RecordKeeper ) {
   std::vector MetaSubjects =
@@ -1638,7 +1676,11 @@
 SubjectContainer->getValueAsListOfDefs("Subjects");
 for (const auto *Subject : ApplicableSubjects) {
   bool Inserted =
-  SubjectsToRules.try_emplace(Subject, MetaSubject, Constraint).second;
+  SubjectsToRules
+  .try_emplace(Subject, RuleOrAggregateRuleSet::getRule(
+AttributeSubjectMatchRule(MetaSubject,
+  Constraint)))
+  .second;
   if (!Inserted) {
 PrintFatalError("Attribute subject match rules should not represent"
 "same attribute subjects.");
@@ -1652,6 +1694,37 @@
 for (const auto *Constraint : Constraints)
   MapFromSubjectsToRules(Constraint, MetaSubject, Constraint);
   }
+
+  std::vector Aggregates =
+  Records.getAllDerivedDefinitions("AttrSubjectMatcherAggregateRule");
+  std::vector DeclNodes = Records.getAllDerivedDefinitions("DDecl");
+  for (const Record *Aggregate : Aggregates) {
+Record *SubjectDecl = Aggregate->getValueAsDef("Subject");
+
+// Gather sub-classes of the aggregate subject that act as attribute
+// subject rules.
+std::vector Rules;
+for (const auto *D : DeclNodes) {
+  if (doesDeclDeriveFrom(D, SubjectDecl)) {
+auto It = SubjectsToRules.find(D);
+if (It == SubjectsToRules.end())
+  continue;
+if (!It->second.isRule() || It->second.getRule().isSubRule())
+  continue; // Assume that the rule will be included as well.
+Rules.push_back(It->second.getRule());
+  }
+}
+
+bool Inserted =
+SubjectsToRules
+.try_emplace(SubjectDecl,
+ RuleOrAggregateRuleSet::getAggregateRuleSet(Rules))
+.second;
+if (!Inserted) {
+  PrintFatalError("Attribute subject match rules should not represent"
+  "same attribute subjects.");
+}
+  }
 }
 
 static PragmaClangAttributeSupport &
@@ -1738,24 +1811,25 @@
 auto It = SubjectsToRules.find(Subject);
 assert(It != SubjectsToRules.end() &&
"This attribute is unsupported by #pragma clang attribute");
-AttributeSubjectMatchRule Rule = It->getSecond();
-// The rule might be language specific, so only subtract it from the given
-// rules if the specific language options are specified.
-std::vector LangOpts = Rule.getLangOpts();
-SS << "  MatchRules.push_back(std::make_pair(" << Rule.getEnumValue()
-   << ", /*IsSupported=*/";
-if (!LangOpts.empty()) {
-  for (auto I = LangOpts.begin(), E = LangOpts.end(); I != E; ++I) {
-std::string Part = (*I)->getValueAsString("Name");
-if ((*I)->getValueAsBit("Negated"))
-  SS << "!";
-SS << "LangOpts." + Part;
-if (I + 1 != E)
-  SS << " || ";
-  }
-} else
-  SS << "true";
-SS << "));\n";
+for (const auto  : It->getSecond().getAggregateRuleSet()) {
+  // The rule might be 

[PATCH] D32176: Add #pragma clang attribute support for the external_source_symbol attribute

2017-04-18 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

Right now the `external_source_symbol` attribute isn't supported by `#pragma 
clang attribute` for the following two reasons:

- The `Named` attribute subject isn't supported by TableGen.
- There was no way to specify a subject match rule for `#pragma clang 
attribute` that could operate on a set of attribute subjects (e.g. the ones 
that derive from `NamedDecl`).

This patch fixes the two issues and thus adds `external_source_symbol` support 
to `#pragma clang attribute`,


Repository:
  rL LLVM

https://reviews.llvm.org/D32176

Files:
  include/clang/Basic/Attr.td
  lib/Sema/SemaDeclAttr.cpp
  test/Misc/pragma-attribute-supported-attributes-list.test
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -1611,7 +1611,36 @@
 
 struct PragmaClangAttributeSupport {
   std::vector Rules;
-  llvm::DenseMap SubjectsToRules;
+
+  class RuleOrAggregateRuleSet {
+std::vector Rules;
+bool IsRule;
+RuleOrAggregateRuleSet(ArrayRef Rules,
+   bool IsRule)
+: Rules(Rules.begin(), Rules.end()), IsRule(IsRule) {}
+
+  public:
+bool isRule() const { return IsRule; }
+
+AttributeSubjectMatchRule () {
+  assert(IsRule && "not a rule!");
+  return Rules[0];
+}
+
+ArrayRef getAggregateRuleSet() const {
+  return Rules;
+}
+
+static RuleOrAggregateRuleSet
+getRule(const AttributeSubjectMatchRule ) {
+  return RuleOrAggregateRuleSet(Rule, /*IsRule=*/true);
+}
+static RuleOrAggregateRuleSet
+getAggregateRuleSet(ArrayRef Rules) {
+  return RuleOrAggregateRuleSet(Rules, /*IsRule=*/false);
+}
+  };
+  llvm::DenseMap SubjectsToRules;
 
   PragmaClangAttributeSupport(RecordKeeper );
 
@@ -1626,6 +1655,15 @@
 
 } // end anonymous namespace
 
+static bool doesDeclDeriveFrom(const Record *D, const Record *Base) {
+  const Record *CurrentBase = D->getValueAsDef("Base");
+  if (!CurrentBase)
+return false;
+  if (CurrentBase == Base)
+return true;
+  return doesDeclDeriveFrom(CurrentBase, Base);
+}
+
 PragmaClangAttributeSupport::PragmaClangAttributeSupport(
 RecordKeeper ) {
   std::vector MetaSubjects =
@@ -1638,7 +1676,11 @@
 SubjectContainer->getValueAsListOfDefs("Subjects");
 for (const auto *Subject : ApplicableSubjects) {
   bool Inserted =
-  SubjectsToRules.try_emplace(Subject, MetaSubject, Constraint).second;
+  SubjectsToRules
+  .try_emplace(Subject, RuleOrAggregateRuleSet::getRule(
+AttributeSubjectMatchRule(MetaSubject,
+  Constraint)))
+  .second;
   if (!Inserted) {
 PrintFatalError("Attribute subject match rules should not represent"
 "same attribute subjects.");
@@ -1652,6 +1694,37 @@
 for (const auto *Constraint : Constraints)
   MapFromSubjectsToRules(Constraint, MetaSubject, Constraint);
   }
+
+  std::vector Aggregates =
+  Records.getAllDerivedDefinitions("AttrSubjectMatcherAggregateRule");
+  std::vector DeclNodes = Records.getAllDerivedDefinitions("DDecl");
+  for (const Record *Aggregate : Aggregates) {
+Record *SubjectDecl = Aggregate->getValueAsDef("Subject");
+
+// Gather sub-classes of the aggregate subject that act as attribute
+// subject rules.
+std::vector Rules;
+for (const auto *D : DeclNodes) {
+  if (doesDeclDeriveFrom(D, SubjectDecl)) {
+auto It = SubjectsToRules.find(D);
+if (It == SubjectsToRules.end())
+  continue;
+if (!It->second.isRule() || It->second.getRule().isSubRule())
+  continue; // Assume that the rule will be included as well.
+Rules.push_back(It->second.getRule());
+  }
+}
+
+bool Inserted =
+SubjectsToRules
+.try_emplace(SubjectDecl,
+ RuleOrAggregateRuleSet::getAggregateRuleSet(Rules))
+.second;
+if (!Inserted) {
+  PrintFatalError("Attribute subject match rules should not represent"
+  "same attribute subjects.");
+}
+  }
 }
 
 static PragmaClangAttributeSupport &
@@ -1738,24 +1811,25 @@
 auto It = SubjectsToRules.find(Subject);
 assert(It != SubjectsToRules.end() &&
"This attribute is unsupported by #pragma clang attribute");
-AttributeSubjectMatchRule Rule = It->getSecond();
-// The rule might be language specific, so only subtract it from the given
-// rules if the specific language options are specified.
-std::vector LangOpts = Rule.getLangOpts();
-SS << "  MatchRules.push_back(std::make_pair(" << Rule.getEnumValue()
-   << ", /*IsSupported=*/";
-if (!LangOpts.empty()) {
-  for (auto I = LangOpts.begin(), E = LangOpts.end(); I 

[clang-tools-extra] r300563 - Make the test pass on x86_64-win32 target.

2017-04-18 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Apr 18 11:25:03 2017
New Revision: 300563

URL: http://llvm.org/viewvc/llvm-project?rev=300563=rev
Log:
Make the test pass on x86_64-win32 target.

Modified:

clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-vector-operation.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-vector-operation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-vector-operation.cpp?rev=300563=300562=300563=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-vector-operation.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-vector-operation.cpp
 Tue Apr 18 11:25:03 2017
@@ -1,9 +1,9 @@
-// RUN: %check_clang_tidy %s performance-inefficient-vector-operation %t -- 
-format-style=llvm -- -fno-ms-extensions
-// FIXME: This may work with -target x86_64-win32.
+// RUN: %check_clang_tidy %s performance-inefficient-vector-operation %t -- 
-format-style=llvm --
+
+namespace std {
 
 typedef int size_t;
 
-namespace std {
 template 
 class vector {
  public:
@@ -73,7 +73,7 @@ void f(std::vector& t) {
   {
 std::vector v;
 // CHECK-FIXES: v.reserve(t.size());
-for (size_t i = 0; i < t.size(); ++i) {
+for (std::size_t i = 0; i < t.size(); ++i) {
   v.push_back(t[i]);
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
 }
@@ -81,7 +81,7 @@ void f(std::vector& t) {
   {
 std::vector v;
 // CHECK-FIXES: v.reserve(t.size() - 1);
-for (size_t i = 0; i < t.size() - 1; ++i) {
+for (std::size_t i = 0; i < t.size() - 1; ++i) {
   v.push_back(t[i]);
 } // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
   }
@@ -152,7 +152,7 @@ void f(std::vector& t) {
 std::vector v;
 // CHECK-FIXES-NOT: v.reserve(t.size());
 // v isn't referenced in for-loop body.
-for (size_t i = 0; i < t.size(); ++i) {
+for (std::size_t i = 0; i < t.size(); ++i) {
   t.push_back(i);
 }
   }
@@ -161,7 +161,7 @@ void f(std::vector& t) {
 int k;
 // CHECK-FIXES-NOT: v.reserve(10);
 // For-loop isn't a fixable loop.
-for (size_t i = 0; k < 10; ++i) {
+for (std::size_t i = 0; k < 10; ++i) {
   v.push_back(t[i]);
 }
   }
@@ -177,7 +177,7 @@ void f(std::vector& t) {
 int k;
 // CHECK-FIXES-NOT: v.reserve(10);
 // For-loop isn't a fixable loop.
-for (size_t i = 0; i < 10; ++k) {
+for (std::size_t i = 0; i < 10; ++k) {
   v.push_back(t[i]);
 }
   }


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


[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

@chapuni, thanks for the workaround. It makes sense to make it work for 
targeting msvc. Will fix it in a follow-up.


Repository:
  rL LLVM

https://reviews.llvm.org/D31757



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


[PATCH] D32170: Add a FixItHint for -Wmissing-prototypes to insert 'static '.

2017-04-18 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh created this revision.

Missing 'static' on functions that are intended to be local to a translation
unit seems to be the most common cause of -Wmissing-prototypes warnings, so
suggesting a fix seems to be convenient and useful.


https://reviews.llvm.org/D32170

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/warn-missing-prototypes.cpp

Index: test/SemaCXX/warn-missing-prototypes.cpp
===
--- test/SemaCXX/warn-missing-prototypes.cpp
+++ test/SemaCXX/warn-missing-prototypes.cpp
@@ -1,6 +1,22 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-prototypes -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -implicit-check-not=fix-it:
 
-void f() { } // expected-warning {{no previous prototype for function 'f'}}
+void f() { } // expected-warning {{no previous prototype for function 'f'; did you mean to mark the function 'static'?}}
+// CHECK: fix-it:"{{.*}}":{4:1-4:1}:"static "
+
+#define F2 void f2() { }
+
+F2 // expected-warning {{no previous prototype for function 'f2'}}
+
+extern void f3() {} // expected-warning {{no previous prototype for function 'f3'}}
+extern "C" void f4() {} // expected-warning {{no previous prototype for function 'f4'}}
+extern "C++" void f5() {} // expected-warning {{no previous prototype for function 'f5'}}
+extern "C" {
+  void f6() {} // expected-warning {{no previous prototype for function 'f6'}}
+}
+extern "C++" {
+  void f7() {} // expected-warning {{no previous prototype for function 'f7'}}
+}
 
 namespace NS {
   void f() { } // expected-warning {{no previous prototype for function 'f'}}
@@ -16,6 +32,7 @@
   void f() { }
 };
 
+
 // Don't warn about inline functions.
 inline void g() { }
 
@@ -32,3 +49,6 @@
 
 // Don't warn on explicitly deleted functions.
 void j() = delete;
+
+// Don't warn on static functions.
+static void s() {}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -11649,7 +11649,8 @@
 }
 
 static bool ShouldWarnAboutMissingPrototype(const FunctionDecl *FD,
- const FunctionDecl*& PossibleZeroParamPrototype) {
+ const FunctionDecl*& PossibleZeroParamPrototype,
+ bool *PossibleMissingStatic) {
   // Don't warn about invalid declarations.
   if (FD->isInvalidDecl())
 return false;
@@ -11686,21 +11687,27 @@
   if (FD->isDeleted())
 return false;
 
-  bool MissingPrototype = true;
   for (const FunctionDecl *Prev = FD->getPreviousDecl();
Prev; Prev = Prev->getPreviousDecl()) {
 // Ignore any declarations that occur in function or method
 // scope, because they aren't visible from the header.
 if (Prev->getLexicalDeclContext()->isFunctionOrMethod())
   continue;
 
-MissingPrototype = !Prev->getType()->isFunctionProtoType();
+if (Prev->getType()->isFunctionProtoType())
+  return false;
+
 if (FD->getNumParams() == 0)
   PossibleZeroParamPrototype = Prev;
 break;
   }
 
-  return MissingPrototype;
+  // Check whether applying a 'static' could make sense for this function.
+  *PossibleMissingStatic = FD->getDeclContext() &&
+   FD->getDeclContext()->isTranslationUnit() &&
+   FD->getStorageClass() == SC_None;
+
+  return true;
 }
 
 void
@@ -12099,8 +12106,19 @@
 //   definition itself provides a prototype. The aim is to detect
 //   global functions that fail to be declared in header files.
 const FunctionDecl *PossibleZeroParamPrototype = nullptr;
-if (ShouldWarnAboutMissingPrototype(FD, PossibleZeroParamPrototype)) {
-  Diag(FD->getLocation(), diag::warn_missing_prototype) << FD;
+bool PossibleMissingStatic = false;
+if (ShouldWarnAboutMissingPrototype(FD, PossibleZeroParamPrototype,
+)) {
+  if (PossibleMissingStatic) {
+auto DiagBuilder =
+Diag(FD->getLocation(), diag::warn_missing_prototype_maybe_static)
+<< FD;
+SourceLocation Loc = FD->getLocStart();
+if (Loc.isFileID())
+  DiagBuilder << FixItHint::CreateInsertion(Loc, "static ");
+  } else {
+Diag(FD->getLocation(), diag::warn_missing_prototype) << FD;
+  }
 
   if (PossibleZeroParamPrototype) {
 // We found a declaration that is not a prototype,
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -4545,9 +4545,12 @@
   "%select{function|method|block}0 has been explicitly marked sentinel here">;
 def warn_missing_prototype : Warning<
   "no previous prototype for function %0">,
-  

[PATCH] D31542: [clang-tidy] Extend readability-container-size-empty to add comparisons to newly-constructed objects

2017-04-18 Thread Josh Zimmerman via Phabricator via cfe-commits
joshz added a comment.

I don't believe I have access to commit this revision myself; can someone 
please do it for me?

Thanks! :-)


Repository:
  rL LLVM

https://reviews.llvm.org/D31542



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


[PATCH] D31542: [clang-tidy] Extend readability-container-size-empty to add comparisons to newly-constructed objects

2017-04-18 Thread Josh Zimmerman via Phabricator via cfe-commits
joshz added a comment.

Thanks, Aaron!


Repository:
  rL LLVM

https://reviews.llvm.org/D31542



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


r300562 - mingw-w64: enable support for __declspec(selectany)

2017-04-18 Thread Martell Malone via cfe-commits
Author: martell
Date: Tue Apr 18 10:56:24 2017
New Revision: 300562

URL: http://llvm.org/viewvc/llvm-project?rev=300562=rev
Log:
mingw-w64: enable support for __declspec(selectany)

Add selectany as a GCC spelling for mingw-w64

Reviewers: rnk

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

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/test/Sema/attr-selectany.c
cfe/trunk/test/SemaCXX/attr-selectany.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=300562=300561=300562=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Apr 18 10:56:24 2017
@@ -2351,9 +2351,8 @@ def DLLImport : InheritableAttr, TargetS
   let Documentation = [DLLImportDocs];
 }
 
-def SelectAny : InheritableAttr {
-  let Spellings = [Declspec<"selectany">];
-  let LangOpts = [MicrosoftExt];
+def SelectAny : InheritableAttr, TargetSpecificAttr {
+  let Spellings = [Declspec<"selectany">, GCC<"selectany">];
   let Documentation = [Undocumented];
 }
 

Modified: cfe/trunk/test/Sema/attr-selectany.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-selectany.c?rev=300562=300561=300562=diff
==
--- cfe/trunk/test/Sema/attr-selectany.c (original)
+++ cfe/trunk/test/Sema/attr-selectany.c Tue Apr 18 10:56:24 2017
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fms-compatibility -fms-extensions -verify %s
+// RUN: %clang_cc1 -triple x86_64-win32 -fdeclspec -verify %s
+// RUN: %clang_cc1 -triple x86_64-mingw32 -verify %s
 
 extern __declspec(selectany) const int x1 = 1; // no warning, const means we 
need extern in C++
 

Modified: cfe/trunk/test/SemaCXX/attr-selectany.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-selectany.cpp?rev=300562=300561=300562=diff
==
--- cfe/trunk/test/SemaCXX/attr-selectany.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-selectany.cpp Tue Apr 18 10:56:24 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fms-compatibility -fms-extensions -fsyntax-only -verify 
-std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-win32 -fms-compatibility -fms-extensions 
-fsyntax-only -verify -std=c++11 %s
 // MSVC produces similar diagnostics.
 
 __declspec(selectany) void foo() { } // expected-error{{'selectany' can only 
be applied to data items with external linkage}}


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


[PATCH] D32081: Add support for editor placeholders to Clang's lexer

2017-04-18 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added inline comments.



Comment at: include/clang/Basic/IdentifierTable.h:358
 
+  /// Return true if this identifier is an editor placeholder.
+  bool isEditorPlaceholder() const {

Nitpick: There should probably be an example in the doc comment.  The editor 
placeholder syntax isn't commonly known.



Comment at: include/clang/Driver/Options.td:1478
+  "fno-allow-editor-placeholders">, Group,
+  Flags<[CC1Option]>;
+

Does the negative -fno- option need to be CC1Option?  Later in this patch you 
seem to canonicalize on the positive form when passing to the frontend.


Repository:
  rL LLVM

https://reviews.llvm.org/D32081



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


r300560 - [ASTPrinter] Print template parameter lists for out-of-line functions

2017-04-18 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Apr 18 10:12:34 2017
New Revision: 300560

URL: http://llvm.org/viewvc/llvm-project?rev=300560=rev
Log:
[ASTPrinter] Print template parameter lists for out-of-line functions

Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/Misc/ast-print-out-of-line-func.cpp

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=300560=300559=300560=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Tue Apr 18 10:12:34 2017
@@ -478,6 +478,11 @@ void DeclPrinter::VisitFunctionDecl(Func
 
   if (D->isFunctionTemplateSpecialization())
 Out << "template<> ";
+  else if (!D->getDescribedFunctionTemplate()) {
+for (unsigned I = 0, NumTemplateParams = D->getNumTemplateParameterLists();
+ I < NumTemplateParams; ++I)
+  printTemplateParameters(D->getTemplateParameterList(I));
+  }
 
   CXXConstructorDecl *CDecl = dyn_cast(D);
   CXXConversionDecl *ConversionDecl = dyn_cast(D);
@@ -1055,6 +1060,12 @@ void DeclPrinter::VisitTemplateDecl(cons
 
 void DeclPrinter::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
   prettyPrintPragmas(D->getTemplatedDecl());
+  // Print any leading template parameter lists.
+  if (const FunctionDecl *FD = D->getTemplatedDecl()) {
+for (unsigned I = 0, NumTemplateParams = 
FD->getNumTemplateParameterLists();
+ I < NumTemplateParams; ++I)
+  printTemplateParameters(FD->getTemplateParameterList(I));
+  }
   VisitRedeclarableTemplateDecl(D);
 
   // Never print "instantiations" for deduction guides (they don't really

Modified: cfe/trunk/test/Misc/ast-print-out-of-line-func.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-out-of-line-func.cpp?rev=300560=300559=300560=diff
==
--- cfe/trunk/test/Misc/ast-print-out-of-line-func.cpp (original)
+++ cfe/trunk/test/Misc/ast-print-out-of-line-func.cpp Tue Apr 18 10:12:34 2017
@@ -52,3 +52,44 @@ void Wrapper::Inner::staticMember() { }
 // CHECK: void Wrapper::Inner::staticMember()
 
 }
+
+template
+class TemplateRecord {
+  void function();
+  template void functionTemplate(T, U);
+};
+
+template
+void TemplateRecord::function() { }
+// CHECK: template  void TemplateRecord::function()
+
+template
+template
+void TemplateRecord::functionTemplate(T, U) { }
+// CHECK: template  template  void 
TemplateRecord::functionTemplate(T, U)
+
+template<>
+class TemplateRecord<0, int> {
+  void function();
+  template void functionTemplate(int, U);
+};
+
+void TemplateRecord<0, int>::function() { }
+// CHECK: void TemplateRecord<0, int>::function()
+
+template
+void TemplateRecord<0, int>::functionTemplate(int, U) { }
+// CHECK: template  void TemplateRecord<0, 
int>::functionTemplate(int, U)
+
+template
+struct OuterTemplateRecord {
+  template
+  struct Inner {
+void function();
+  };
+};
+
+template
+template
+void OuterTemplateRecord::Inner::function() { }
+// CHECK: template  template  void 
OuterTemplateRecord::Inner::function()


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


Re: r300555 - Driver: Better detection of mingw-gcc

2017-04-18 Thread Alex L via cfe-commits
No problem, thanks for the quick update!

On 18 April 2017 at 15:56, Martell Malone  wrote:

> Yes I do :)
> I updated https://reviews.llvm.org/D15005 with a comment incase anyone
> goes there.
> I also updated https://reviews.llvm.org/D15006 (the correct link) to
> point to the commit revision.
>
> Thanks for pointing that out Alex
>
> On Tue, Apr 18, 2017 at 3:49 PM, Alex L  wrote:
>
>> I think you've got the wrong Phabricator link in the commit log.
>>
>> On 18 April 2017 at 15:27, Martell Malone via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: martell
>>> Date: Tue Apr 18 09:27:36 2017
>>> New Revision: 300555
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=300555=rev
>>> Log:
>>> Driver: Better detection of mingw-gcc
>>>
>>> Stop blindly searching for "gcc.exe" on windows.
>>> Stop assuming "/usr" on unix, fixes cross compiling.
>>>
>>> Reviewers: mati865, yaron.keren
>>>
>>> Subscribers: ismail, rnk
>>>
>>> Differential revision: https://reviews.llvm.org/D15005
>>>
>>> Modified:
>>> cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
>>> cfe/trunk/lib/Driver/ToolChains/MinGW.h
>>>
>>> Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Too
>>> lChains/MinGW.cpp?rev=300555=300554=300555=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp (original)
>>> +++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp Tue Apr 18 09:27:36 2017
>>> @@ -285,28 +285,30 @@ void toolchains::MinGW::findGccLibDir()
>>>}
>>>  }
>>>
>>> +llvm::ErrorOr toolchains::MinGW::findGcc() {
>>> +  llvm::SmallVector, 2> Gccs;
>>> +  Gccs.emplace_back(getTriple().getArchName());
>>> +  Gccs[0] += "-w64-mingw32-gcc";
>>> +  Gccs.emplace_back("mingw32-gcc");
>>> +  // Please do not add "gcc" here
>>> +  for (StringRef CandidateGcc : Gccs)
>>> +if (llvm::ErrorOr GPPName =
>>> llvm::sys::findProgramByName(CandidateGcc))
>>> +  return GPPName;
>>> +  return make_error_code(std::errc::no_such_file_or_directory);
>>> +}
>>> +
>>>  toolchains::MinGW::MinGW(const Driver , const llvm::Triple ,
>>>   const ArgList )
>>>  : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
>>>getProgramPaths().push_back(getDriver().getInstalledDir());
>>>
>>> -// In Windows there aren't any standard install locations, we search
>>> -// for gcc on the PATH. In Linux the base is always /usr.
>>> -#ifdef LLVM_ON_WIN32
>>>if (getDriver().SysRoot.size())
>>>  Base = getDriver().SysRoot;
>>> -  else if (llvm::ErrorOr GPPName =
>>> -   llvm::sys::findProgramByName("gcc"))
>>> +  else if (llvm::ErrorOr GPPName = findGcc())
>>>  Base = llvm::sys::path::parent_path(
>>>  llvm::sys::path::parent_path(GPPName.get()));
>>>else
>>>  Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
>>> -#else
>>> -  if (getDriver().SysRoot.size())
>>> -Base = getDriver().SysRoot;
>>> -  else
>>> -Base = "/usr";
>>> -#endif
>>>
>>>Base += llvm::sys::path::get_separator();
>>>findGccLibDir();
>>>
>>> Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.h
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Too
>>> lChains/MinGW.h?rev=300555=300554=300555=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/Driver/ToolChains/MinGW.h (original)
>>> +++ cfe/trunk/lib/Driver/ToolChains/MinGW.h Tue Apr 18 09:27:36 2017
>>> @@ -93,6 +93,7 @@ private:
>>>mutable std::unique_ptr Preprocessor;
>>>mutable std::unique_ptr Compiler;
>>>void findGccLibDir();
>>> +  llvm::ErrorOr findGcc();
>>>  };
>>>
>>>  } // end namespace toolchains
>>>
>>>
>>> ___
>>> 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


[PATCH] D31868: [analyzer] Check NULL pointer dereference issue for memset function

2017-04-18 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai added a comment.

Hi All,

Thanks for your review! I will update my patch tomorrow! Almost 4+ days no see, 
I miss you :)

Regards,
Leslie Zhaii


Repository:
  rL LLVM

https://reviews.llvm.org/D31868



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


Re: r300555 - Driver: Better detection of mingw-gcc

2017-04-18 Thread Martell Malone via cfe-commits
Yes I do :)
I updated https://reviews.llvm.org/D15005 with a comment incase anyone goes
there.
I also updated https://reviews.llvm.org/D15006 (the correct link) to point
to the commit revision.

Thanks for pointing that out Alex

On Tue, Apr 18, 2017 at 3:49 PM, Alex L  wrote:

> I think you've got the wrong Phabricator link in the commit log.
>
> On 18 April 2017 at 15:27, Martell Malone via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: martell
>> Date: Tue Apr 18 09:27:36 2017
>> New Revision: 300555
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=300555=rev
>> Log:
>> Driver: Better detection of mingw-gcc
>>
>> Stop blindly searching for "gcc.exe" on windows.
>> Stop assuming "/usr" on unix, fixes cross compiling.
>>
>> Reviewers: mati865, yaron.keren
>>
>> Subscribers: ismail, rnk
>>
>> Differential revision: https://reviews.llvm.org/D15005
>>
>> Modified:
>> cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
>> cfe/trunk/lib/Driver/ToolChains/MinGW.h
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Too
>> lChains/MinGW.cpp?rev=300555=300554=300555=diff
>> 
>> ==
>> --- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp Tue Apr 18 09:27:36 2017
>> @@ -285,28 +285,30 @@ void toolchains::MinGW::findGccLibDir()
>>}
>>  }
>>
>> +llvm::ErrorOr toolchains::MinGW::findGcc() {
>> +  llvm::SmallVector, 2> Gccs;
>> +  Gccs.emplace_back(getTriple().getArchName());
>> +  Gccs[0] += "-w64-mingw32-gcc";
>> +  Gccs.emplace_back("mingw32-gcc");
>> +  // Please do not add "gcc" here
>> +  for (StringRef CandidateGcc : Gccs)
>> +if (llvm::ErrorOr GPPName =
>> llvm::sys::findProgramByName(CandidateGcc))
>> +  return GPPName;
>> +  return make_error_code(std::errc::no_such_file_or_directory);
>> +}
>> +
>>  toolchains::MinGW::MinGW(const Driver , const llvm::Triple ,
>>   const ArgList )
>>  : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
>>getProgramPaths().push_back(getDriver().getInstalledDir());
>>
>> -// In Windows there aren't any standard install locations, we search
>> -// for gcc on the PATH. In Linux the base is always /usr.
>> -#ifdef LLVM_ON_WIN32
>>if (getDriver().SysRoot.size())
>>  Base = getDriver().SysRoot;
>> -  else if (llvm::ErrorOr GPPName =
>> -   llvm::sys::findProgramByName("gcc"))
>> +  else if (llvm::ErrorOr GPPName = findGcc())
>>  Base = llvm::sys::path::parent_path(
>>  llvm::sys::path::parent_path(GPPName.get()));
>>else
>>  Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
>> -#else
>> -  if (getDriver().SysRoot.size())
>> -Base = getDriver().SysRoot;
>> -  else
>> -Base = "/usr";
>> -#endif
>>
>>Base += llvm::sys::path::get_separator();
>>findGccLibDir();
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Too
>> lChains/MinGW.h?rev=300555=300554=300555=diff
>> 
>> ==
>> --- cfe/trunk/lib/Driver/ToolChains/MinGW.h (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/MinGW.h Tue Apr 18 09:27:36 2017
>> @@ -93,6 +93,7 @@ private:
>>mutable std::unique_ptr Preprocessor;
>>mutable std::unique_ptr Compiler;
>>void findGccLibDir();
>> +  llvm::ErrorOr findGcc();
>>  };
>>
>>  } // end namespace toolchains
>>
>>
>> ___
>> 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


[PATCH] D15005: Fix PR8170: Clang does not check constructor declaration that uses a template-id

2017-04-18 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

It won't let me revert the automatically updated diff to the previous one 
because I am not the author.
@faisalv are you able todo this and Sorry for the confusion.


Repository:
  rL LLVM

https://reviews.llvm.org/D15005



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


[PATCH] D15005: Fix PR8170: Clang does not check constructor declaration that uses a template-id

2017-04-18 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

In case anyone comes here looking for https://reviews.llvm.org/rL300555 that 
should be https://reviews.llvm.org/D15006 no https://reviews.llvm.org/D15005.

Thanks


Repository:
  rL LLVM

https://reviews.llvm.org/D15005



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


Re: r300555 - Driver: Better detection of mingw-gcc

2017-04-18 Thread Alex L via cfe-commits
I think you've got the wrong Phabricator link in the commit log.

On 18 April 2017 at 15:27, Martell Malone via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: martell
> Date: Tue Apr 18 09:27:36 2017
> New Revision: 300555
>
> URL: http://llvm.org/viewvc/llvm-project?rev=300555=rev
> Log:
> Driver: Better detection of mingw-gcc
>
> Stop blindly searching for "gcc.exe" on windows.
> Stop assuming "/usr" on unix, fixes cross compiling.
>
> Reviewers: mati865, yaron.keren
>
> Subscribers: ismail, rnk
>
> Differential revision: https://reviews.llvm.org/D15005
>
> Modified:
> cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
> cfe/trunk/lib/Driver/ToolChains/MinGW.h
>
> Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/
> ToolChains/MinGW.cpp?rev=300555=300554=300555=diff
> 
> ==
> --- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp Tue Apr 18 09:27:36 2017
> @@ -285,28 +285,30 @@ void toolchains::MinGW::findGccLibDir()
>}
>  }
>
> +llvm::ErrorOr toolchains::MinGW::findGcc() {
> +  llvm::SmallVector, 2> Gccs;
> +  Gccs.emplace_back(getTriple().getArchName());
> +  Gccs[0] += "-w64-mingw32-gcc";
> +  Gccs.emplace_back("mingw32-gcc");
> +  // Please do not add "gcc" here
> +  for (StringRef CandidateGcc : Gccs)
> +if (llvm::ErrorOr GPPName = llvm::sys::findProgramByName(
> CandidateGcc))
> +  return GPPName;
> +  return make_error_code(std::errc::no_such_file_or_directory);
> +}
> +
>  toolchains::MinGW::MinGW(const Driver , const llvm::Triple ,
>   const ArgList )
>  : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
>getProgramPaths().push_back(getDriver().getInstalledDir());
>
> -// In Windows there aren't any standard install locations, we search
> -// for gcc on the PATH. In Linux the base is always /usr.
> -#ifdef LLVM_ON_WIN32
>if (getDriver().SysRoot.size())
>  Base = getDriver().SysRoot;
> -  else if (llvm::ErrorOr GPPName =
> -   llvm::sys::findProgramByName("gcc"))
> +  else if (llvm::ErrorOr GPPName = findGcc())
>  Base = llvm::sys::path::parent_path(
>  llvm::sys::path::parent_path(GPPName.get()));
>else
>  Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
> -#else
> -  if (getDriver().SysRoot.size())
> -Base = getDriver().SysRoot;
> -  else
> -Base = "/usr";
> -#endif
>
>Base += llvm::sys::path::get_separator();
>findGccLibDir();
>
> Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/
> ToolChains/MinGW.h?rev=300555=300554=300555=diff
> 
> ==
> --- cfe/trunk/lib/Driver/ToolChains/MinGW.h (original)
> +++ cfe/trunk/lib/Driver/ToolChains/MinGW.h Tue Apr 18 09:27:36 2017
> @@ -93,6 +93,7 @@ private:
>mutable std::unique_ptr Preprocessor;
>mutable std::unique_ptr Compiler;
>void findGccLibDir();
> +  llvm::ErrorOr findGcc();
>  };
>
>  } // end namespace toolchains
>
>
> ___
> 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


[PATCH] D15006: Driver: Better detection of mingw-gcc

2017-04-18 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

Committed as https://reviews.llvm.org/rL300555


Repository:
  rL LLVM

https://reviews.llvm.org/D15006



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


[PATCH] D15005: Fix PR8170: Clang does not check constructor declaration that uses a template-id

2017-04-18 Thread Martell Malone via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL300555: Driver: Better detection of mingw-gcc (authored by 
martell).

Changed prior to commit:
  https://reviews.llvm.org/D15005?vs=41206=95568#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D15005

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


Index: cfe/trunk/lib/Driver/ToolChains/MinGW.h
===
--- cfe/trunk/lib/Driver/ToolChains/MinGW.h
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.h
@@ -93,6 +93,7 @@
   mutable std::unique_ptr Preprocessor;
   mutable std::unique_ptr Compiler;
   void findGccLibDir();
+  llvm::ErrorOr findGcc();
 };
 
 } // end namespace toolchains
Index: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
@@ -285,28 +285,30 @@
   }
 }
 
+llvm::ErrorOr toolchains::MinGW::findGcc() {
+  llvm::SmallVector, 2> Gccs;
+  Gccs.emplace_back(getTriple().getArchName());
+  Gccs[0] += "-w64-mingw32-gcc";
+  Gccs.emplace_back("mingw32-gcc");
+  // Please do not add "gcc" here
+  for (StringRef CandidateGcc : Gccs)
+if (llvm::ErrorOr GPPName = 
llvm::sys::findProgramByName(CandidateGcc))
+  return GPPName;
+  return make_error_code(std::errc::no_such_file_or_directory);
+}
+
 toolchains::MinGW::MinGW(const Driver , const llvm::Triple ,
  const ArgList )
 : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
-// In Windows there aren't any standard install locations, we search
-// for gcc on the PATH. In Linux the base is always /usr.
-#ifdef LLVM_ON_WIN32
   if (getDriver().SysRoot.size())
 Base = getDriver().SysRoot;
-  else if (llvm::ErrorOr GPPName =
-   llvm::sys::findProgramByName("gcc"))
+  else if (llvm::ErrorOr GPPName = findGcc())
 Base = llvm::sys::path::parent_path(
 llvm::sys::path::parent_path(GPPName.get()));
   else
 Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
-#else
-  if (getDriver().SysRoot.size())
-Base = getDriver().SysRoot;
-  else
-Base = "/usr";
-#endif
 
   Base += llvm::sys::path::get_separator();
   findGccLibDir();


Index: cfe/trunk/lib/Driver/ToolChains/MinGW.h
===
--- cfe/trunk/lib/Driver/ToolChains/MinGW.h
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.h
@@ -93,6 +93,7 @@
   mutable std::unique_ptr Preprocessor;
   mutable std::unique_ptr Compiler;
   void findGccLibDir();
+  llvm::ErrorOr findGcc();
 };
 
 } // end namespace toolchains
Index: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
@@ -285,28 +285,30 @@
   }
 }
 
+llvm::ErrorOr toolchains::MinGW::findGcc() {
+  llvm::SmallVector, 2> Gccs;
+  Gccs.emplace_back(getTriple().getArchName());
+  Gccs[0] += "-w64-mingw32-gcc";
+  Gccs.emplace_back("mingw32-gcc");
+  // Please do not add "gcc" here
+  for (StringRef CandidateGcc : Gccs)
+if (llvm::ErrorOr GPPName = llvm::sys::findProgramByName(CandidateGcc))
+  return GPPName;
+  return make_error_code(std::errc::no_such_file_or_directory);
+}
+
 toolchains::MinGW::MinGW(const Driver , const llvm::Triple ,
  const ArgList )
 : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
-// In Windows there aren't any standard install locations, we search
-// for gcc on the PATH. In Linux the base is always /usr.
-#ifdef LLVM_ON_WIN32
   if (getDriver().SysRoot.size())
 Base = getDriver().SysRoot;
-  else if (llvm::ErrorOr GPPName =
-   llvm::sys::findProgramByName("gcc"))
+  else if (llvm::ErrorOr GPPName = findGcc())
 Base = llvm::sys::path::parent_path(
 llvm::sys::path::parent_path(GPPName.get()));
   else
 Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
-#else
-  if (getDriver().SysRoot.size())
-Base = getDriver().SysRoot;
-  else
-Base = "/usr";
-#endif
 
   Base += llvm::sys::path::get_separator();
   findGccLibDir();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r300555 - Driver: Better detection of mingw-gcc

2017-04-18 Thread Martell Malone via cfe-commits
Author: martell
Date: Tue Apr 18 09:27:36 2017
New Revision: 300555

URL: http://llvm.org/viewvc/llvm-project?rev=300555=rev
Log:
Driver: Better detection of mingw-gcc

Stop blindly searching for "gcc.exe" on windows.
Stop assuming "/usr" on unix, fixes cross compiling.

Reviewers: mati865, yaron.keren

Subscribers: ismail, rnk

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

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

Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MinGW.cpp?rev=300555=300554=300555=diff
==
--- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp Tue Apr 18 09:27:36 2017
@@ -285,28 +285,30 @@ void toolchains::MinGW::findGccLibDir()
   }
 }
 
+llvm::ErrorOr toolchains::MinGW::findGcc() {
+  llvm::SmallVector, 2> Gccs;
+  Gccs.emplace_back(getTriple().getArchName());
+  Gccs[0] += "-w64-mingw32-gcc";
+  Gccs.emplace_back("mingw32-gcc");
+  // Please do not add "gcc" here
+  for (StringRef CandidateGcc : Gccs)
+if (llvm::ErrorOr GPPName = 
llvm::sys::findProgramByName(CandidateGcc))
+  return GPPName;
+  return make_error_code(std::errc::no_such_file_or_directory);
+}
+
 toolchains::MinGW::MinGW(const Driver , const llvm::Triple ,
  const ArgList )
 : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
-// In Windows there aren't any standard install locations, we search
-// for gcc on the PATH. In Linux the base is always /usr.
-#ifdef LLVM_ON_WIN32
   if (getDriver().SysRoot.size())
 Base = getDriver().SysRoot;
-  else if (llvm::ErrorOr GPPName =
-   llvm::sys::findProgramByName("gcc"))
+  else if (llvm::ErrorOr GPPName = findGcc())
 Base = llvm::sys::path::parent_path(
 llvm::sys::path::parent_path(GPPName.get()));
   else
 Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
-#else
-  if (getDriver().SysRoot.size())
-Base = getDriver().SysRoot;
-  else
-Base = "/usr";
-#endif
 
   Base += llvm::sys::path::get_separator();
   findGccLibDir();

Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MinGW.h?rev=300555=300554=300555=diff
==
--- cfe/trunk/lib/Driver/ToolChains/MinGW.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.h Tue Apr 18 09:27:36 2017
@@ -93,6 +93,7 @@ private:
   mutable std::unique_ptr Preprocessor;
   mutable std::unique_ptr Compiler;
   void findGccLibDir();
+  llvm::ErrorOr findGcc();
 };
 
 } // end namespace toolchains


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


[PATCH] D32164: [clang-tidy] misc-misplaced-widening-cast: Disable checking of implicit widening casts by default

2017-04-18 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.
Herald added a subscriber: whisperity.

Users reported some false positives using this check. This patch sets the 
default value of the option for checking implicit widening casts to false. We 
also suggest renaming the check to something like missing-or-misplaced-widening 
cast so the name also covers the implicit case. This patch supersedes 
https://reviews.llvm.org/D31097.


https://reviews.llvm.org/D32164

Files:
  clang-tidy/misc/MisplacedWideningCastCheck.cpp
  test/clang-tidy/misc-misplaced-widening-cast-implicit-enabled.cpp
  test/clang-tidy/misc-misplaced-widening-cast.cpp

Index: test/clang-tidy/misc-misplaced-widening-cast.cpp
===
--- test/clang-tidy/misc-misplaced-widening-cast.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-// RUN: %check_clang_tidy %s misc-misplaced-widening-cast %t -- -config="{CheckOptions: [{key: misc-misplaced-widening-cast.CheckImplicitCasts, value: 1}]}" --
-
-void func(long arg) {}
-
-void assign(int a, int b) {
-  long l;
-
-  l = a * b;
-  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' is ineffective, or there is loss of precision before the conversion [misc-misplaced-widening-cast]
-  l = (long)(a * b);
-  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long'
-  l = (long)a * b;
-
-  l = a << 8;
-  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long'
-  l = (long)(a << 8);
-  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long'
-  l = (long)b << 8;
-
-  l = static_cast(a * b);
-  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long'
-}
-
-void compare(int a, int b, long c) {
-  bool l;
-
-  l = a * b == c;
-  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long'
-  l = c == a * b;
-  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: either cast from 'int' to 'long'
-  l = (long)(a * b) == c;
-  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long'
-  l = c == (long)(a * b);
-  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: either cast from 'int' to 'long'
-  l = (long)a * b == c;
-  l = c == (long)a * b;
-}
-
-void init(unsigned int n) {
-  long l1 = n << 8;
-  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: either cast from 'unsigned int' to 'long'
-  long l2 = (long)(n << 8);
-  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: either cast from 'unsigned int' to 'long'
-  long l3 = (long)n << 8;
-}
-
-void call(unsigned int n) {
-  func(n << 8);
-  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: either cast from 'unsigned int' to 'long'
-  func((long)(n << 8));
-  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: either cast from 'unsigned int' to 'long'
-  func((long)n << 8);
-}
-
-long ret(int a) {
-  if (a < 0) {
-return a * 1000;
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: either cast from 'int' to 'long'
-  } else if (a > 0) {
-return (long)(a * 1000);
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: either cast from 'int' to 'long'
-  } else {
-return (long)a * 1000;
-  }
-}
-
-void dontwarn1(unsigned char a, int i, unsigned char *p) {
-  long l;
-  // The result is a 9 bit value, there is no truncation in the implicit cast.
-  l = (long)(a + 15);
-  // The result is a 12 bit value, there is no truncation in the implicit cast.
-  l = (long)(a << 4);
-  // The result is a 3 bit value, there is no truncation in the implicit cast.
-  l = (long)((i % 5) + 1);
-  // The result is a 16 bit value, there is no truncation in the implicit cast.
-  l = (long)(((*p) << 8) + *(p + 1));
-}
-
-template  struct DontWarn2 {
-  void assign(T a, T b) {
-long l;
-l = (long)(a * b);
-  }
-};
-DontWarn2 DW2;
-
-// Cast is not suspicious when casting macro.
-#define A  (X<<2)
-long macro1(int X) {
-  return (long)A;
-}
-
-// Don't warn about cast in macro.
-#define B(X,Y)   (long)(X*Y)
-long macro2(int x, int y) {
-  return B(x,y);
-}
-
-void floatingpoint(float a, float b) {
-  double d = (double)(a * b); // Currently we don't warn for this.
-}
Index: test/clang-tidy/misc-misplaced-widening-cast-implicit-enabled.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-misplaced-widening-cast-implicit-enabled.cpp
@@ -0,0 +1,101 @@
+// RUN: %check_clang_tidy %s misc-misplaced-widening-cast %t -- -config="{CheckOptions: [{key: misc-misplaced-widening-cast.CheckImplicitCasts, value: 1}]}" --
+
+void func(long arg) {}
+
+void assign(int a, int b) {
+  long l;
+
+  l = a * b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long' is ineffective, or there is loss of precision before the conversion [misc-misplaced-widening-cast]
+  l = (long)(a * b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long'
+  l = (long)a * b;
+
+  l = a << 8;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: either cast from 'int' to 'long'
+  

[PATCH] D31868: [analyzer] Check NULL pointer dereference issue for memset function

2017-04-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Wow, so you're doing the binding thing now? Thanks! It was not critical for 
landing this patch, so you could have fixed comments here, allowing us to 
commit what's already done, and then proceed with further improvements. It's 
also easier to review and aligns with the LLVM's policy of incremental 
development.

Could you add test cases for the new feature? For instance,

  void foo() {
int *x = malloc(sizeof(int));
memset(x, 0, sizeof(int));
1 / *x; // expected-warning{{Division by zero}}
  }

  void bar() {
int *x = malloc(sizeof(int));
memset(x, 0, 1);
1 / *x; // no-warning
  }

Tests that involve setting memory to anything but 0 are also welcome!




Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2066
+
+  if (StateSameSize) {
+SVal ConstVal = State->getSVal(Const, LCtx);

I believe that if the size is not the same, you'd still need to do invalidation.


Repository:
  rL LLVM

https://reviews.llvm.org/D31868



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


[PATCH] D30909: [Analyzer] Finish taint propagation to derived symbols of tainted regions

2017-04-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:494
+  SymbolManager  = C.getSymbolManager();
+  return SM.getDerivedSymbol(Sym, LCV.getRegion());
 }

vlad.tsyrklevich wrote:
> NoQ wrote:
> > vlad.tsyrklevich wrote:
> > > NoQ wrote:
> > > > I'd think about this a bit more and come back.
> > > > 
> > > > I need to understand how come that constructing a symbol manually is 
> > > > the right thing to do; that doesn't happen very often, but it seems 
> > > > correct here.
> > > Indeed it is odd. The best justification I could come up with: LCVs are 
> > > meant to be optimizations, their 'purpose' is to expose an SVal that 
> > > hides SymbolRef values so that we can have a split store. We don't have 
> > > to copy all of a compound values SymbolRef mappings because LCVs are kept 
> > > distinct. Hence to set/query/constrain region values you use SVals so 
> > > that RegionStore can differentiate between LCVs and SymbolRef backed 
> > > SVals for the two different stores it contains.
> > > 
> > > The taint interface however requires you taint a SymbolRef, not an SVal. 
> > > If we wanted, instead of doing this logic here, we could change 
> > > getPointedToSymbol() to return an SVal and update usages of it 
> > > accordingly since that value is only passed on to 
> > > ProgramState.isTainted()/ProgramState.addTaint() anyway. Then we could 
> > > update addTaint/isTainted to perform this logic, hiding it from the 
> > > checker.
> > > 
> > > This still requires manually constructing a symbol, now it's just 
> > > performed in the analyzer instead of in a checker. Not sure if that 
> > > addresses the issue you were considering, but the idea that we need to 
> > > 'undo' the LCV optimization hiding the SymbolRef to have a value to taint 
> > > seems somewhat convincing to me. What do you think?
> > Hmm (!) I suggest adding a new function to the program state, that we'd 
> > call `addPartialTaint()` or something like that, and this function would 
> > accept a symbol and a region and would act identically to passing a derived 
> > symbol (from this symbol and that region) to `addTaint()` (but we wouldn't 
> > need to actually construct a derived symbol here).
> > 
> > Such API would be easier to understand and use than the current approach 
> > that forces the user to construct a derived symbol manually in the checker 
> > code. Unfortunately, this checker's `getLCVSymbol()` would become a bit 
> > more complicated (having various return types depending on circumstances), 
> > but this misfortune seems more random than systematic to me.
> > 
> > Since we're having this new kind of partial taint, why don't we expose it 
> > in the API.
> I'm happy to implement it this way, but figured I'd ask why you prefer this 
> approach first in the interest of keeping the TaintChecker simple! The 
> optimal approach to me seems to be changing `getPointedToSymbol()` to 
> `getPointedToSVal()` and having `addTaint(SVal)` call `addPartialTaint()` 
> when it's passed an LCV sub-region. That way users of the taint interface 
> like the TaintChecker have a clean way to add & check regardless of whether 
> it's a SymbolRef or an LCV but the partial taint functionality is still 
> exposed and documented for those who might want to use it in new ways.
> 
> Just curious to understand your rationale. Thanks for the feedback!
Your idea actually looks good to me! I'd approve going this way.

With this change to `addTaint(SVal)`, i suspect it'd need some extra 
documentation to explain what it does now.



Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:676
+  if (const SymbolDerived *SD = dyn_cast(Sym)) {
+TaintedSymRegionsRef SymRegions(0, TSRFactory.getTreeFactory());
+

The `SymRegions` name is a bit confusing because we often shorten 
`SymbolicRegion` to `SymRegion` (eg. in dumps), which is not what we mean.



Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:682
+
+SymRegions = SymRegions.add(SD->getRegion());
+NewState = NewState->set(SD->getParentSymbol(), 
SymRegions);

I wonder if it's worth it to check if a super-region of this region is already 
tainted, and avoid adding the region in this scenario.

I guess in practice it won't happen very often, because this code would most 
likely be executed just once per taint source. This probably deserves a comment 
though.


https://reviews.llvm.org/D30909



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


[PATCH] D31542: [clang-tidy] Extend readability-container-size-empty to add comparisons to newly-constructed objects

2017-04-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D31542



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


r300550 - [ARM] Add hardware build attributes in assembler

2017-04-18 Thread Oliver Stannard via cfe-commits
Author: olista01
Date: Tue Apr 18 08:21:05 2017
New Revision: 300550

URL: http://llvm.org/viewvc/llvm-project?rev=300550=rev
Log:
[ARM] Add hardware build attributes in assembler

This passes an option to the ARM assembly parser to emit build
attributes for the hardware selected by command line options, when
assembling an assembly file.

This is not enabled for C/C++, as this would result in duplicate build
attribute directives being emitted in each inline assembly block, when
emitting assembly.

This also adds an option to allow disabling this behaviour for assembly
files, for users who were relying on the old behaviour.

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


Added:
cfe/trunk/test/Driver/arm-default-build-attributes.s
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=300550=300549=300550=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Apr 18 08:21:05 2017
@@ -1646,6 +1646,8 @@ def march_EQ : Joined<["-"], "march=">,
 def masm_EQ : Joined<["-"], "masm=">, Group, Flags<[DriverOption]>;
 def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group;
 def mimplicit_it_EQ : Joined<["-"], "mimplicit-it=">, Group;
+def mdefault_build_attributes : Joined<["-"], "mdefault-build-attributes">, 
Group;
+def mno_default_build_attributes : Joined<["-"], 
"mno-default-build-attributes">, Group;
 def mconstant_cfstrings : Flag<["-"], "mconstant-cfstrings">, 
Group;
 def mconsole : Joined<["-"], "mconsole">, Group, 
Flags<[DriverOption]>;
 def mwindows : Joined<["-"], "mwindows">, Group, 
Flags<[DriverOption]>;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=300550=300549=300550=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Apr 18 08:21:05 2017
@@ -4996,6 +4996,19 @@ void ClangAs::ConstructJob(Compilation &
   case llvm::Triple::x86_64:
 AddX86TargetArgs(Args, CmdArgs);
 break;
+
+  case llvm::Triple::arm:
+  case llvm::Triple::armeb:
+  case llvm::Triple::thumb:
+  case llvm::Triple::thumbeb:
+// This isn't in AddARMTargetArgs because we want to do this for assembly
+// only, not C/C++.
+if (Args.hasFlag(options::OPT_mdefault_build_attributes,
+ options::OPT_mno_default_build_attributes, true)) {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-arm-add-build-attributes");
+}
+break;
   }
 
   // Consume all the warning flags. Usually this would be handled more

Added: cfe/trunk/test/Driver/arm-default-build-attributes.s
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-default-build-attributes.s?rev=300550=auto
==
--- cfe/trunk/test/Driver/arm-default-build-attributes.s (added)
+++ cfe/trunk/test/Driver/arm-default-build-attributes.s Tue Apr 18 08:21:05 
2017
@@ -0,0 +1,20 @@
+// Enabled by default for assembly
+// RUN: %clang -target armv7--none-eabi -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-ENABLED
+
+// Can be forced on or off for assembly.
+// RUN: %clang -target armv7--none-eabi -### %s 2>&1 
-mno-default-build-attributes \
+// RUN:| FileCheck %s -check-prefix CHECK-DISABLED
+// RUN: %clang -target armv7--none-eabi -### %s 2>&1 
-mdefault-build-attributes \
+// RUN:| FileCheck %s -check-prefix CHECK-ENABLED
+
+// Option ignored C/C++ (since we always emit hardware and ABI build attributes
+// during codegen).
+// RUN: %clang -target armv7--none-eabi -### -x c %s 
-mdefault-build-attributes -verify 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-DISABLED
+// RUN: %clang -target armv7--none-eabi -### -x c++ %s 
-mdefault-build-attributes -verify 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-DISABLED
+
+// CHECK-DISABLED-NOT: "-arm-add-build-attributes"
+// CHECK-ENABLED: "-arm-add-build-attributes"
+// expected-warning {{argument unused during compilation: 
'-mno-default-build-attributes'}}


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


r300549 - [ARM, AArch64] Define __ELF__ for arm-none-eabihf and AArch64

2017-04-18 Thread Oliver Stannard via cfe-commits
Author: olista01
Date: Tue Apr 18 08:12:36 2017
New Revision: 300549

URL: http://llvm.org/viewvc/llvm-project?rev=300549=rev
Log:
[ARM,AArch64] Define __ELF__ for arm-none-eabihf and AArch64

This macro is defined for arm-none-eabi as of r266625, but it should also be
defined for eabihf and aarch64.


Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=300549=300548=300549=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Apr 18 08:12:36 2017
@@ -5467,9 +5467,11 @@ public:
 Builder.defineMacro("__arm__");
 // For bare-metal none-eabi.
 if (getTriple().getOS() == llvm::Triple::UnknownOS &&
-getTriple().getEnvironment() == llvm::Triple::EABI)
+(getTriple().getEnvironment() == llvm::Triple::EABI ||
+ getTriple().getEnvironment() == llvm::Triple::EABIHF))
   Builder.defineMacro("__ELF__");
 
+
 // Target properties.
 Builder.defineMacro("__REGISTER_PREFIX__", "");
 
@@ -6118,6 +6120,11 @@ public:
 MacroBuilder ) const override {
 // Target identification.
 Builder.defineMacro("__aarch64__");
+// For bare-metal none-eabi.
+if (getTriple().getOS() == llvm::Triple::UnknownOS &&
+(getTriple().getEnvironment() == llvm::Triple::EABI ||
+ getTriple().getEnvironment() == llvm::Triple::EABIHF))
+  Builder.defineMacro("__ELF__");
 
 // Target properties.
 Builder.defineMacro("_LP64");

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=300549=300548=300549=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Tue Apr 18 08:12:36 2017
@@ -2378,6 +2378,9 @@
 // ARM-NETBSD:#define __arm__ 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-eabi < /dev/null | 
FileCheck -match-full-lines -check-prefix ARM-NONE-EABI %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-eabihf < /dev/null | 
FileCheck -match-full-lines -check-prefix ARM-NONE-EABI %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-none-eabi < /dev/null 
| FileCheck -match-full-lines -check-prefix ARM-NONE-EABI %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-none-eabihf < 
/dev/null | FileCheck -match-full-lines -check-prefix ARM-NONE-EABI %s
 // ARM-NONE-EABI: #define __ELF__ 1
 
 // No MachO targets use the full EABI, even if AAPCS is used.


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


[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-18 Thread NAKAMURA Takumi via Phabricator via cfe-commits
chapuni added a comment.

Does it work for targeting msvc?
See also; 
http://bb.pgr.jp/builders/test-clang-tools-msc-x64-on-i686-linux-RA/builds/1043

Appeased in r300545. Would it be happier if it worked with "-target 
x86_64-win32"?


Repository:
  rL LLVM

https://reviews.llvm.org/D31757



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


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

2017-04-18 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

Realised I've some comments to submit.




Comment at: lib/Sema/SemaExpr.cpp:8032
+
+  return InvalidOperands(Loc, LHS, RHS);
+}

bruno wrote:
> Double checking here: are there tests for the `InvalidOperands` case above?
Yes, this case is covered in the new diff in test/Sema/vector-ops.c and in 
test/Sema/vector-gcc-compat.c . 



Comment at: lib/Sema/SemaExpr.cpp:10024
+  // FIXME: The check for C++ here is for GCC compatibility. GCC rejects the
+  //usage of logical operators with vectors in C. This check could be
+  //notionally dropped.

bruno wrote:
> Please mention in the comment the list of logical ops that this applies to: 
> "!, &&, ||"
I've updated the relevant Check* functions with FIXME:s noting that they should 
handle vector types for compatibility with GCC.



Comment at: test/Sema/vector-gcc-compat.c:101
+
+  v2i64_r = v2i64_a && 1; // expected-error {{invalid vector operand to binary 
expression ('v2i64' (vector of 2 'long long' values))}}
+  v2i64_r = v2i64_a || 1; // expected-error {{invalid vector operand to binary 
expression ('v2i64' (vector of 2 'long long' values))}}

bruno wrote:
> Is this because of && and others only working in C++? If so, we need a better 
> error message here, along the lines of "logical expression with vector only 
> support in C++". If later on we decide to support it in non-C++, we then get 
> rid of the warning.
> 
> 
> 
Yes, these operators are oddly only available in C++.

I've changed the error message to "logical expression with vector type[s] 
'' (vector of  '' values) [and ''] 
is only supported in C++".


https://reviews.llvm.org/D25866



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


[PATCH] D31097: [clang-tidy] don't warn about implicit widening casts in function calls

2017-04-18 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment.

> Or I can do it for you if you wish.

yes please


Repository:
  rL LLVM

https://reviews.llvm.org/D31097



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


  1   2   >