Re: [PATCH] D12358: [Analyzer] Handling constant bound loops

2015-08-28 Thread Ted Kremenek via cfe-commits
Hi Sean,

I responded with some more feedback.  Conceptually the patch is quite simple, 
but I think Anna’s points are all spot on.  I think we’d all be quite amendable 
for this work to go in under a flag, with further improvements going in on top 
of that.  That way we can all collectively start hashing this out in trunk 
instead of feature creeping a patch.

Ted

> On Aug 27, 2015, at 10:15 AM, Ted Kremenek  wrote:
> 
> 
> 
> 
> 
>> On Aug 27, 2015, at 8:57 AM, Sean Eveson  wrote:
>> 
>> I accept that my current patch is not a comprehensive solution to the 
>> problem and that it may introduce false positives, however I do think it is 
>> an improvement, where it is preferable to have false positives over doing no 
>> analysis after the loop.
> 
> Hi Sean,
> 
> I'll take another closer look at your patch tonight and come back with more 
> feedback. I completely understand your eagerness to push this forward.  I 
> don't think that anybody disagrees with you that we want to do analysis of 
> more code, especially the code that's currently not being analyzed all 
> because of our current handling of loops. That said, if the solution is not 
> precise enough it may cause a flurry of false positives, which then renders 
> the efficacy of the tool impotent.  It doesn't matter if the tool has more 
> coverage if it produces a high-volume of false positives.  I'm not saying 
> that your patch will result in that happening all the time, but we should not 
> just land the patch without understanding its implications.  I also think 
> that with some relatively small enhancements most of our concerns can be 
> addressed.
> 
> Because of the way the analyzer works, false positives often happen because 
> of "correlated conditions" that are improperly truck by the analyzer.  
> Essentially, if an event that happened earlier in a path would have had an 
> anti-correlation with something happening later in the path then reporting an 
> issue along that path related to those two conditions would be a false 
> positive.  We go to great lengths in the analyzer to handle correlated 
> conditions; that is why it is a path sensitive analysis, which is very 
> expensive.  When we drop information on the floor, we lose precision and for 
> some kinds of code can greatly increase the chance of producing false 
> positives.
> 
> We do drop information on the floor all the time, but when we do we try to 
> make those decisions quite deliberate and understand their implications.  
> Some checkers also are written with the mindset that if there is insufficient 
> information to report an issue with high confidence than no issue is reported 
> at all.  But the problem here by not invalidating values possibly touched by 
> the loop is that there is a incorrect perception that the information is 
> precise when indeed it is not.
> 
> Thanks again for pushing on this; handling loops better is something I have 
> wanted us to tackle for a very long time but never found the time to do it.  
> I'll circle back with you tonight with more feedback.
> 
> Cheers,
> Ted

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


[libcxx] r246280 - Fix most GCC warnings during build. Only -Wattribute left.

2015-08-28 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Aug 28 02:02:42 2015
New Revision: 246280

URL: http://llvm.org/viewvc/llvm-project?rev=246280&view=rev
Log:
Fix most GCC warnings during build. Only -Wattribute left.

Modified:
libcxx/trunk/include/string
libcxx/trunk/include/system_error

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=246280&r1=246279&r2=246280&view=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Fri Aug 28 02:02:42 2015
@@ -1444,7 +1444,8 @@ public:
 _LIBCPP_INLINE_VISIBILITY size_type length() const _NOEXCEPT {return 
size();}
 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT;
 _LIBCPP_INLINE_VISIBILITY size_type capacity() const _NOEXCEPT
-{return (__is_long() ? __get_long_cap() : __min_cap) - 1;}
+{return (__is_long() ? __get_long_cap()
+ : static_cast(__min_cap)) - 1;}
 
 void resize(size_type __n, value_type __c);
 _LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, 
value_type());}
@@ -1784,11 +1785,11 @@ private:
 template  static
 _LIBCPP_INLINE_VISIBILITY
 size_type __align_it(size_type __s) _NOEXCEPT
-{return __s + (__a-1) & ~(__a-1);}
+{return (__s + (__a-1)) & ~(__a-1);}
 enum {__alignment = 16};
 static _LIBCPP_INLINE_VISIBILITY
 size_type __recommend(size_type __s) _NOEXCEPT
-{return (__s < __min_cap ? __min_cap :
+{return (__s < __min_cap ? static_cast(__min_cap) :
  __align_it (__s+1)) - 1;}
 

Modified: libcxx/trunk/include/system_error
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/system_error?rev=246280&r1=246279&r2=246280&view=diff
==
--- libcxx/trunk/include/system_error (original)
+++ libcxx/trunk/include/system_error Fri Aug 28 02:02:42 2015
@@ -371,7 +371,7 @@ public:
 error_category() _NOEXCEPT;
 #else
 _LIBCPP_ALWAYS_INLINE
-_LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT _LIBCPP_DEFAULT;
+_LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT _LIBCPP_DEFAULT
 #endif
 private:
 error_category(const error_category&);// = delete;


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


Re: r246278 - [OPENMP 4.0] Codegen for array sections.

2015-08-28 Thread Daniel Jasper via cfe-commits
This fails on the bot, reverting:
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/12747/

On Fri, Aug 28, 2015 at 8:09 AM, Alexey Bataev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: abataev
> Date: Fri Aug 28 01:09:05 2015
> New Revision: 246278
>
> URL: http://llvm.org/viewvc/llvm-project?rev=246278&view=rev
> Log:
> [OPENMP 4.0] Codegen for array sections.
> Added codegen for array section in 'depend' clause of 'task' directive. It
> emits to pointers, one for the begin of array section and another for the
> end of array section. Size of the section is calculated as (end + 1 -
> start) * sizeof(basic_element_type).
>
> Modified:
> cfe/trunk/lib/CodeGen/CGExpr.cpp
> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
> cfe/trunk/test/OpenMP/task_codegen.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=246278&r1=246277&r2=246278&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Aug 28 01:09:05 2015
> @@ -911,6 +911,8 @@ LValue CodeGenFunction::EmitLValue(const
>  return EmitUnaryOpLValue(cast(E));
>case Expr::ArraySubscriptExprClass:
>  return EmitArraySubscriptExpr(cast(E));
> +  case Expr::OMPArraySectionExprClass:
> +return EmitOMPArraySectionExpr(cast(E));
>case Expr::ExtVectorElementExprClass:
>  return EmitExtVectorElementExpr(cast(E));
>case Expr::MemberExprClass:
> @@ -2559,6 +2561,131 @@ LValue CodeGenFunction::EmitArraySubscri
>return LV;
>  }
>
> +LValue CodeGenFunction::EmitOMPArraySectionExpr(const OMPArraySectionExpr
> *E,
> +bool LowerBound) {
> +  LValue Base;
> +  if (auto *ASE =
> +
> dyn_cast(E->getBase()->IgnoreParenImpCasts()))
> +Base = EmitOMPArraySectionExpr(ASE, LowerBound);
> +  else
> +Base = EmitLValue(E->getBase());
> +  QualType BaseTy = Base.getType();
> +  llvm::Value *Idx;
> +  QualType ResultExprTy;
> +  if (auto *AT = getContext().getAsArrayType(BaseTy))
> +ResultExprTy = AT->getElementType();
> +  else
> +ResultExprTy = BaseTy->getPointeeType();
> +  if (LowerBound) {
> +Idx = E->getLowerBound()
> +  ? Builder.CreateIntCast(EmitScalarExpr(E->getLowerBound()),
> +  IntPtrTy,
> +  E->getLowerBound()
> +  ->getType()
> +
> ->hasSignedIntegerRepresentation())
> +  : llvm::ConstantInt::getNullValue(IntPtrTy);
> +  } else {
> +auto &C = CGM.getContext();
> +auto *Length = E->getLength();
> +if (Length || E->getColonLoc().isInvalid()) {
> +  // Idx = LowerBound + Length - 1;
> +  auto *One = llvm::ConstantInt::get(IntPtrTy, /*V=*/1);
> +  if (Length) {
> +Idx = Builder.CreateIntCast(
> +EmitScalarExpr(Length), IntPtrTy,
> +Length->getType()->hasSignedIntegerRepresentation());
> +  }
> +  auto *LowerBound = E->getLowerBound();
> +  llvm::APSInt ConstLowerBound;
> +  if (LowerBound &&
> LowerBound->isIntegerConstantExpr(ConstLowerBound, C))
> +LowerBound = nullptr;
> +  if (LowerBound && ConstLowerBound.getZExtValue() != 0) {
> +auto *LowerBoundVal = Builder.CreateIntCast(
> +EmitScalarExpr(LowerBound), IntPtrTy,
> +LowerBound->getType()->hasSignedIntegerRepresentation());
> +if (E->getColonLoc().isValid()) {
> +  if (getLangOpts().isSignedOverflowDefined())
> +Idx = Builder.CreateAdd(Idx, LowerBoundVal);
> +  else
> +Idx = Builder.CreateNSWAdd(Idx, LowerBoundVal);
> +} else
> +  Idx = LowerBoundVal;
> +  }
> +  if (E->getColonLoc().isValid()) {
> +if (getLangOpts().isSignedOverflowDefined())
> +  Idx = Builder.CreateSub(Idx, One);
> +else
> +  Idx = Builder.CreateNSWSub(Idx, One);
> +  }
> +} else if (auto *VAT = C.getAsVariableArrayType(BaseTy)) {
> +  // Idx = ArrSize - 1;
> +  Length = VAT->getSizeExpr();
> +  Idx = Builder.CreateIntCast(
> +  EmitScalarExpr(Length), IntPtrTy,
> +  Length->getType()->hasSignedIntegerRepresentation());
> +  auto *One = llvm::ConstantInt::get(IntPtrTy, /*V=*/1);
> +  if (getLangOpts().isSignedOverflowDefined())
> +Idx = Builder.CreateSub(Idx, One);
> +  else
> +Idx = Builder.CreateNSWSub(Idx, One);
> +} else {
> +  // Idx = ArrSize - 1;
> +  auto *CAT = C.getAsConstantArrayType(BaseTy);
> +  Idx = llvm::ConstantInt::get(IntPtrTy,
> CAT->getSize().getZExtValue() - 1);
> +}
> +  }
> +
> +  llvm::Value *Address;
> +  CharUnits ArrayAlignment;
> +  if (auto *VLA = getContext().getAsVariableArrayType(ResultExprT

Re: [PATCH] D12358: [Analyzer] Handling constant bound loops

2015-08-28 Thread Ted Kremenek via cfe-commits
krememek added a comment.

In http://reviews.llvm.org/D12358#234975, @krememek wrote:

>




> 

> 

> 1. We need to consult the number of times a loop has been executed to 
> determine when to apply this widening.  We can look at the basic block 
> counts, which are already used to cull off too many loop iterations.


On closer inspection, this is actually already in the patch:

  BldCtx.blockCount() == AMgr.options.maxBlockVisitOnPath - 1

I do wonder if nested loops will cause a problem here, however.  If a loop is 
nested, `blockCount()` could already be the same as `maxBlockVisitOnPath() ` 
because of the outer loop.  For example:

  for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++) { ... }
  }

On the second iteration of the outer loop, but the first iteration of the inner 
loop within that second outer loop iteration, the block count for the body of 
the nested loop will already be 2.  The analyzer will prune paths, regardless 
of this loop widening heuristic.  I don't think the suggested patch actually 
helps with this case because the block count gets exhausted.  We may need a way 
to enhance the accounting of block counts when taking into account heuristics 
for loops.


http://reviews.llvm.org/D12358



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


Re: r246278 - [OPENMP 4.0] Codegen for array sections.

2015-08-28 Thread Daniel Jasper via cfe-commits
Sorry, totally forgot that your are in the right timezone. Will not revert
for now and hope that you can figure this out :-)

On Fri, Aug 28, 2015 at 9:10 AM, Daniel Jasper  wrote:

> This fails on the bot, reverting:
>
> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/12747/
>
> On Fri, Aug 28, 2015 at 8:09 AM, Alexey Bataev via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: abataev
>> Date: Fri Aug 28 01:09:05 2015
>> New Revision: 246278
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=246278&view=rev
>> Log:
>> [OPENMP 4.0] Codegen for array sections.
>> Added codegen for array section in 'depend' clause of 'task' directive.
>> It emits to pointers, one for the begin of array section and another for
>> the end of array section. Size of the section is calculated as (end + 1 -
>> start) * sizeof(basic_element_type).
>>
>> Modified:
>> cfe/trunk/lib/CodeGen/CGExpr.cpp
>> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
>> cfe/trunk/lib/CodeGen/CodeGenFunction.h
>> cfe/trunk/test/OpenMP/task_codegen.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=246278&r1=246277&r2=246278&view=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Aug 28 01:09:05 2015
>> @@ -911,6 +911,8 @@ LValue CodeGenFunction::EmitLValue(const
>>  return EmitUnaryOpLValue(cast(E));
>>case Expr::ArraySubscriptExprClass:
>>  return EmitArraySubscriptExpr(cast(E));
>> +  case Expr::OMPArraySectionExprClass:
>> +return EmitOMPArraySectionExpr(cast(E));
>>case Expr::ExtVectorElementExprClass:
>>  return EmitExtVectorElementExpr(cast(E));
>>case Expr::MemberExprClass:
>> @@ -2559,6 +2561,131 @@ LValue CodeGenFunction::EmitArraySubscri
>>return LV;
>>  }
>>
>> +LValue CodeGenFunction::EmitOMPArraySectionExpr(const
>> OMPArraySectionExpr *E,
>> +bool LowerBound) {
>> +  LValue Base;
>> +  if (auto *ASE =
>> +
>> dyn_cast(E->getBase()->IgnoreParenImpCasts()))
>> +Base = EmitOMPArraySectionExpr(ASE, LowerBound);
>> +  else
>> +Base = EmitLValue(E->getBase());
>> +  QualType BaseTy = Base.getType();
>> +  llvm::Value *Idx;
>> +  QualType ResultExprTy;
>> +  if (auto *AT = getContext().getAsArrayType(BaseTy))
>> +ResultExprTy = AT->getElementType();
>> +  else
>> +ResultExprTy = BaseTy->getPointeeType();
>> +  if (LowerBound) {
>> +Idx = E->getLowerBound()
>> +  ? Builder.CreateIntCast(EmitScalarExpr(E->getLowerBound()),
>> +  IntPtrTy,
>> +  E->getLowerBound()
>> +  ->getType()
>> +
>> ->hasSignedIntegerRepresentation())
>> +  : llvm::ConstantInt::getNullValue(IntPtrTy);
>> +  } else {
>> +auto &C = CGM.getContext();
>> +auto *Length = E->getLength();
>> +if (Length || E->getColonLoc().isInvalid()) {
>> +  // Idx = LowerBound + Length - 1;
>> +  auto *One = llvm::ConstantInt::get(IntPtrTy, /*V=*/1);
>> +  if (Length) {
>> +Idx = Builder.CreateIntCast(
>> +EmitScalarExpr(Length), IntPtrTy,
>> +Length->getType()->hasSignedIntegerRepresentation());
>> +  }
>> +  auto *LowerBound = E->getLowerBound();
>> +  llvm::APSInt ConstLowerBound;
>> +  if (LowerBound &&
>> LowerBound->isIntegerConstantExpr(ConstLowerBound, C))
>> +LowerBound = nullptr;
>> +  if (LowerBound && ConstLowerBound.getZExtValue() != 0) {
>> +auto *LowerBoundVal = Builder.CreateIntCast(
>> +EmitScalarExpr(LowerBound), IntPtrTy,
>> +LowerBound->getType()->hasSignedIntegerRepresentation());
>> +if (E->getColonLoc().isValid()) {
>> +  if (getLangOpts().isSignedOverflowDefined())
>> +Idx = Builder.CreateAdd(Idx, LowerBoundVal);
>> +  else
>> +Idx = Builder.CreateNSWAdd(Idx, LowerBoundVal);
>> +} else
>> +  Idx = LowerBoundVal;
>> +  }
>> +  if (E->getColonLoc().isValid()) {
>> +if (getLangOpts().isSignedOverflowDefined())
>> +  Idx = Builder.CreateSub(Idx, One);
>> +else
>> +  Idx = Builder.CreateNSWSub(Idx, One);
>> +  }
>> +} else if (auto *VAT = C.getAsVariableArrayType(BaseTy)) {
>> +  // Idx = ArrSize - 1;
>> +  Length = VAT->getSizeExpr();
>> +  Idx = Builder.CreateIntCast(
>> +  EmitScalarExpr(Length), IntPtrTy,
>> +  Length->getType()->hasSignedIntegerRepresentation());
>> +  auto *One = llvm::ConstantInt::get(IntPtrTy, /*V=*/1);
>> +  if (getLangOpts().isSignedOverflowDefined())
>> +Idx = Builder.CreateSub(Idx, One);
>> +  else
>> +Idx = Builder.CreateNSWSub(Idx, One);
>> +} else {
>> +  // I

r246282 - Revert r246214 and r246213

2015-08-28 Thread Steven Wu via cfe-commits
Author: steven_wu
Date: Fri Aug 28 02:14:10 2015
New Revision: 246282

URL: http://llvm.org/viewvc/llvm-project?rev=246282&view=rev
Log:
Revert r246214 and r246213

These two commits causes llvm LTO bootstrap to hang in ScalarEvolution.

Removed:
cfe/trunk/test/CodeGenCXX/vtable-assume-load.cpp
Modified:
cfe/trunk/lib/CodeGen/CGCXXABI.h
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/test/CodeGen/available-externally-hidden.cpp
cfe/trunk/test/CodeGenCXX/ctor-globalopt.cpp
cfe/trunk/test/CodeGenCXX/thunks.cpp
cfe/trunk/test/CodeGenCXX/virtual-base-ctor.cpp
cfe/trunk/test/CodeGenCXX/vtable-available-externally.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXXABI.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXXABI.h?rev=246282&r1=246281&r2=246282&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCXXABI.h (original)
+++ cfe/trunk/lib/CodeGen/CGCXXABI.h Fri Aug 28 02:14:10 2015
@@ -218,10 +218,8 @@ public:
   virtual void emitThrow(CodeGenFunction &CGF, const CXXThrowExpr *E) = 0;
   virtual llvm::GlobalVariable *getThrowInfo(QualType T) { return nullptr; }
 
-  /// \brief Determine whether it's possible to emit a vtable for \p RD, even
-  /// though we do not know that the vtable has been marked as used by semantic
-  /// analysis.
-  virtual bool canSpeculativelyEmitVTable(const CXXRecordDecl *RD) const = 0;
+  virtual bool canEmitAvailableExternallyVTable(
+  const CXXRecordDecl *RD) const = 0;
 
   virtual void emitBeginCatch(CodeGenFunction &CGF, const CXXCatchStmt *C) = 0;
 
@@ -348,25 +346,13 @@ public:
   virtual void emitVTableDefinitions(CodeGenVTables &CGVT,
  const CXXRecordDecl *RD) = 0;
 
-  /// Checks if ABI requires extra virtual offset for vtable field.
-  virtual bool
-  isVirtualOffsetNeededForVTableField(CodeGenFunction &CGF,
-  CodeGenFunction::VPtr Vptr) = 0;
-
-  /// Checks if ABI requires to initilize vptrs for given dynamic class.
-  virtual bool doStructorsInitializeVPtrs(const CXXRecordDecl *VTableClass) = 
0;
-
-  /// Get the address point of the vtable for the given base subobject.
-  virtual llvm::Constant *
-  getVTableAddressPoint(BaseSubobject Base,
-const CXXRecordDecl *VTableClass) = 0;
-
   /// Get the address point of the vtable for the given base subobject while
-  /// building a constructor or a destructor.
-  virtual llvm::Value *
-  getVTableAddressPointInStructor(CodeGenFunction &CGF, const CXXRecordDecl 
*RD,
-  BaseSubobject Base,
-  const CXXRecordDecl *NearestVBase) = 0;
+  /// building a constructor or a destructor. On return, NeedsVirtualOffset
+  /// tells if a virtual base adjustment is needed in order to get the offset
+  /// of the base subobject.
+  virtual llvm::Value *getVTableAddressPointInStructor(
+  CodeGenFunction &CGF, const CXXRecordDecl *RD, BaseSubobject Base,
+  const CXXRecordDecl *NearestVBase, bool &NeedsVirtualOffset) = 0;
 
   /// Get the address point of the vtable for the given base subobject while
   /// building a constexpr.

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=246282&r1=246281&r2=246282&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Fri Aug 28 02:14:10 2015
@@ -1412,8 +1412,7 @@ void CodeGenModule::ConstructAttributeLi
 
 if (const FunctionDecl *Fn = dyn_cast(TargetDecl)) {
   const FunctionProtoType *FPT = Fn->getType()->getAs();
-  if (FPT && !isUnresolvedExceptionSpec(FPT->getExceptionSpecType()) &&
-  FPT->isNothrow(getContext()))
+  if (FPT && FPT->isNothrow(getContext()))
 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
   // Don't use [[noreturn]] or _Noreturn for a call to a virtual function.
   // These attributes are not inherited by overloads.

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=246282&r1=246281&r2=246282&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Fri Aug 28 02:14:10 2015
@@ -1806,14 +1806,12 @@ void CodeGenFunction::EmitCXXConstructor
  bool ForVirtualBase,
  bool Delegating, llvm::Value 
*This,
  const CXXConstructExpr *E) {
-  const CXXRecor

Re: r246214 - Assume loads fix #2

2015-08-28 Thread Steven Wu via cfe-commits
I am pretty sure this commit and r246213 causes llvm LTO bootstrap to hang in 
ScalarEvolution. Doesn’t look like a bug introduced in the commit but 
definitely triggered something bad. I reverted both commit in r246282.

You should able to reproduce the hang by building llvm-cov using LTO. Let me 
know if you need help for a reduced test case.

Thanks

Steven

> On Aug 27, 2015, at 2:35 PM, Piotr Padlewski via cfe-commits 
>  wrote:
> 
> Author: prazek
> Date: Thu Aug 27 16:35:41 2015
> New Revision: 246214
> 
> URL: 
> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D246214-26view-3Drev&d=BQIGaQ&c=eEvniauFctOgLOKGJOplqw&r=AyppgLQmqA6F6mGKjHYJQMsYFVSyBzNb052X2-XqxQo&m=74Ho53VBiSjPg1sSirQymG9cfu0g_kH2TPgrIwIkMsA&s=bzaEvH1N-pXVZNnhTXbVnUXyKmR20AciXN_zJ-SETjw&e=
>  
> Log:
> Assume loads fix #2
> 
> There was linker problem, and it turns out that it is not always safe
> to refer to vtable. If the vtable is used, then we can refer to it
> without any problem, but because we don't know when it will be used or
> not, we can only check if vtable is external or it is safe to to emit it
> speculativly (when class it doesn't have any inline virtual functions).
> It should be fixed in the future.
> 
> https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D12385&d=BQIGaQ&c=eEvniauFctOgLOKGJOplqw&r=AyppgLQmqA6F6mGKjHYJQMsYFVSyBzNb052X2-XqxQo&m=74Ho53VBiSjPg1sSirQymG9cfu0g_kH2TPgrIwIkMsA&s=bMLQH3JdjE2Utt9cC3cfAJOSJ05ZaOoTW7ev_hDFEgQ&e=
>  
> 
> Modified:
>cfe/trunk/lib/CodeGen/CGCXXABI.h
>cfe/trunk/lib/CodeGen/CGClass.cpp
>cfe/trunk/lib/CodeGen/CGVTables.cpp
>cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
>cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
>cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
>cfe/trunk/test/CodeGenCXX/thunks.cpp
>cfe/trunk/test/CodeGenCXX/vtable-assume-load.cpp
>cfe/trunk/test/CodeGenCXX/vtable-available-externally.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGCXXABI.h
> URL: 
> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_CodeGen_CGCXXABI.h-3Frev-3D246214-26r1-3D246213-26r2-3D246214-26view-3Ddiff&d=BQIGaQ&c=eEvniauFctOgLOKGJOplqw&r=AyppgLQmqA6F6mGKjHYJQMsYFVSyBzNb052X2-XqxQo&m=74Ho53VBiSjPg1sSirQymG9cfu0g_kH2TPgrIwIkMsA&s=leudiFW4SvRTkcpIUEbGg8vvviVI12BygT3LQphKTBc&e=
>  
> ==
> --- cfe/trunk/lib/CodeGen/CGCXXABI.h (original)
> +++ cfe/trunk/lib/CodeGen/CGCXXABI.h Thu Aug 27 16:35:41 2015
> @@ -218,8 +218,10 @@ public:
>   virtual void emitThrow(CodeGenFunction &CGF, const CXXThrowExpr *E) = 0;
>   virtual llvm::GlobalVariable *getThrowInfo(QualType T) { return nullptr; }
> 
> -  virtual bool canEmitAvailableExternallyVTable(
> -  const CXXRecordDecl *RD) const = 0;
> +  /// \brief Determine whether it's possible to emit a vtable for \p RD, even
> +  /// though we do not know that the vtable has been marked as used by 
> semantic
> +  /// analysis.
> +  virtual bool canSpeculativelyEmitVTable(const CXXRecordDecl *RD) const = 0;
> 
>   virtual void emitBeginCatch(CodeGenFunction &CGF, const CXXCatchStmt *C) = 
> 0;
> 
> 
> Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
> URL: 
> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_CodeGen_CGClass.cpp-3Frev-3D246214-26r1-3D246213-26r2-3D246214-26view-3Ddiff&d=BQIGaQ&c=eEvniauFctOgLOKGJOplqw&r=AyppgLQmqA6F6mGKjHYJQMsYFVSyBzNb052X2-XqxQo&m=74Ho53VBiSjPg1sSirQymG9cfu0g_kH2TPgrIwIkMsA&s=pjy3fMgGIh-biMJxLcTXYSklw13ul6gAje-Ft1LgxQg&e=
>  
> ==
> --- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGClass.cpp Thu Aug 27 16:35:41 2015
> @@ -1857,8 +1857,15 @@ void CodeGenFunction::EmitCXXConstructor
>   // with a vtable.  We don't do this for base subobjects for two reasons:
>   // first, it's incorrect for classes with virtual bases, and second, we're
>   // about to overwrite the vptrs anyway.
> +  // We also have to make sure if we can refer to vtable:
> +  // - If vtable is external then it's safe to use it (for 
> available_externally
> +  //   CGVTables will make sure if it can emit it).
> +  // - Otherwise we can refer to vtable if it's safe to speculatively emit.
> +  // FIXME: If vtable is used by ctor/dtor, we are always safe to refer to 
> it.
>   if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
> -  ClassDecl->isDynamicClass() && Type != Ctor_Base)
> +  ClassDecl->isDynamicClass() && Type != Ctor_Base &&
> +  (CGM.getVTables().isVTableExternal(ClassDecl) ||
> +   CGM.getCXXABI().canSpeculativelyEmitVTable(ClassDecl)))
> EmitVTableAssumptionLoads(ClassDecl, This);
> }
> 
> 
> Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
> URL: 
> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_CodeGen_CGVTables.cpp-3Frev-3D246214-26r1-3D2

r246288 - Revert "[OPENMP 4.0] Codegen for array sections."

2015-08-28 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Fri Aug 28 03:42:22 2015
New Revision: 246288

URL: http://llvm.org/viewvc/llvm-project?rev=246288&view=rev
Log:
Revert "[OPENMP 4.0] Codegen for array sections."

The test is currently failing on bots:
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/12747/

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/OpenMP/task_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=246288&r1=246287&r2=246288&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Aug 28 03:42:22 2015
@@ -911,8 +911,6 @@ LValue CodeGenFunction::EmitLValue(const
 return EmitUnaryOpLValue(cast(E));
   case Expr::ArraySubscriptExprClass:
 return EmitArraySubscriptExpr(cast(E));
-  case Expr::OMPArraySectionExprClass:
-return EmitOMPArraySectionExpr(cast(E));
   case Expr::ExtVectorElementExprClass:
 return EmitExtVectorElementExpr(cast(E));
   case Expr::MemberExprClass:
@@ -2561,131 +2559,6 @@ LValue CodeGenFunction::EmitArraySubscri
   return LV;
 }
 
-LValue CodeGenFunction::EmitOMPArraySectionExpr(const OMPArraySectionExpr *E,
-bool LowerBound) {
-  LValue Base;
-  if (auto *ASE =
-  dyn_cast(E->getBase()->IgnoreParenImpCasts()))
-Base = EmitOMPArraySectionExpr(ASE, LowerBound);
-  else
-Base = EmitLValue(E->getBase());
-  QualType BaseTy = Base.getType();
-  llvm::Value *Idx;
-  QualType ResultExprTy;
-  if (auto *AT = getContext().getAsArrayType(BaseTy))
-ResultExprTy = AT->getElementType();
-  else
-ResultExprTy = BaseTy->getPointeeType();
-  if (LowerBound) {
-Idx = E->getLowerBound()
-  ? Builder.CreateIntCast(EmitScalarExpr(E->getLowerBound()),
-  IntPtrTy,
-  E->getLowerBound()
-  ->getType()
-  ->hasSignedIntegerRepresentation())
-  : llvm::ConstantInt::getNullValue(IntPtrTy);
-  } else {
-auto &C = CGM.getContext();
-auto *Length = E->getLength();
-if (Length || E->getColonLoc().isInvalid()) {
-  // Idx = LowerBound + Length - 1;
-  auto *One = llvm::ConstantInt::get(IntPtrTy, /*V=*/1);
-  if (Length) {
-Idx = Builder.CreateIntCast(
-EmitScalarExpr(Length), IntPtrTy,
-Length->getType()->hasSignedIntegerRepresentation());
-  }
-  auto *LowerBound = E->getLowerBound();
-  llvm::APSInt ConstLowerBound;
-  if (LowerBound && LowerBound->isIntegerConstantExpr(ConstLowerBound, C))
-LowerBound = nullptr;
-  if (LowerBound && ConstLowerBound.getZExtValue() != 0) {
-auto *LowerBoundVal = Builder.CreateIntCast(
-EmitScalarExpr(LowerBound), IntPtrTy,
-LowerBound->getType()->hasSignedIntegerRepresentation());
-if (E->getColonLoc().isValid()) {
-  if (getLangOpts().isSignedOverflowDefined())
-Idx = Builder.CreateAdd(Idx, LowerBoundVal);
-  else
-Idx = Builder.CreateNSWAdd(Idx, LowerBoundVal);
-} else
-  Idx = LowerBoundVal;
-  }
-  if (E->getColonLoc().isValid()) {
-if (getLangOpts().isSignedOverflowDefined())
-  Idx = Builder.CreateSub(Idx, One);
-else
-  Idx = Builder.CreateNSWSub(Idx, One);
-  }
-} else if (auto *VAT = C.getAsVariableArrayType(BaseTy)) {
-  // Idx = ArrSize - 1;
-  Length = VAT->getSizeExpr();
-  Idx = Builder.CreateIntCast(
-  EmitScalarExpr(Length), IntPtrTy,
-  Length->getType()->hasSignedIntegerRepresentation());
-  auto *One = llvm::ConstantInt::get(IntPtrTy, /*V=*/1);
-  if (getLangOpts().isSignedOverflowDefined())
-Idx = Builder.CreateSub(Idx, One);
-  else
-Idx = Builder.CreateNSWSub(Idx, One);
-} else {
-  // Idx = ArrSize - 1;
-  auto *CAT = C.getAsConstantArrayType(BaseTy);
-  Idx = llvm::ConstantInt::get(IntPtrTy, CAT->getSize().getZExtValue() - 
1);
-}
-  }
-
-  llvm::Value *Address;
-  CharUnits ArrayAlignment;
-  if (auto *VLA = getContext().getAsVariableArrayType(ResultExprTy)) {
-// The element count here is the total number of non-VLA elements.
-llvm::Value *numElements = getVLASize(VLA).first;
-
-// Effectively, the multiply by the VLA size is part of the GEP.
-// GEP indexes are signed, and scaling an index isn't permitted to
-// signed-overflow, so we use the same semantics for our explicit
-// multiply.  We suppress this if overflow is not undefined behavior.
-if (getLangOpts().isSignedOverflowDefined()) {
-  Idx = Builder.CreateMul(Idx, numElements);
-

Re: [PATCH] D11297: PR17829: Functions declared extern "C" with a name matching a mangled C++ function are allowed

2015-08-28 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 33401.
andreybokhanko added a comment.

Fixed last note from John McCall.

John, please re-review.

Yours,
Andrey


http://reviews.llvm.org/D11297

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CGCXX.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/duplicate-mangled-name.cpp

Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -237,6 +237,20 @@
   }
 }
 
+void CodeGenModule::addGlobalValReplacement(llvm::GlobalValue *GV, llvm::Constant *C) {
+  GlobalValReplacements.push_back(std::make_pair(GV, C));
+}
+
+void CodeGenModule::applyGlobalValReplacements() {
+  for (auto &I : GlobalValReplacements) {
+llvm::GlobalValue *GV = I.first;
+llvm::Constant *C = I.second;
+
+GV->replaceAllUsesWith(C);
+GV->eraseFromParent();
+  }
+}
+
 // This is only used in aliases that we created and we know they have a
 // linear structure.
 static const llvm::GlobalObject *getAliasedGlobal(const llvm::GlobalAlias &GA) {
@@ -339,6 +353,7 @@
 
 void CodeGenModule::Release() {
   EmitDeferred();
+  applyGlobalValReplacements();
   applyReplacements();
   checkAliases();
   EmitCXXGlobalInitFunc();
@@ -1108,9 +1123,16 @@
 llvm::GlobalValue *GV = G.GV;
 G.GV = nullptr;
 
-assert(!GV || GV == GetGlobalValue(getMangledName(D)));
-if (!GV)
-  GV = GetGlobalValue(getMangledName(D));
+// We should call GetAddrOfGlobal with IsForDefinition set to true in order
+// to get GlobalValue with exactly the type we need, not something that
+// might had been created for another decl with the same mangled name but
+// different type.
+// FIXME: Support for variables is not implemented yet.
+if (isa(D.getDecl()))
+  GV = cast(GetAddrOfGlobal(D, /*IsForDefinition=*/true));
+else
+  if (!GV)
+GV = GetGlobalValue(getMangledName(D));
 
 // Check to see if we've already emitted this.  This is necessary
 // for a couple of reasons: first, decls can end up in the
@@ -1541,6 +1563,9 @@
   llvm_unreachable("Invalid argument to EmitGlobalDefinition()");
 }
 
+static void ReplaceUsesOfNonProtoTypeWithRealFunction(llvm::GlobalValue *Old,
+  llvm::Function *NewFn);
+
 /// GetOrCreateLLVMFunction - If the specified mangled name is not in the
 /// module, create and return an llvm Function with the specified type. If there
 /// is something in the module with the specified name, return it potentially
@@ -1553,7 +1578,8 @@
llvm::Type *Ty,
GlobalDecl GD, bool ForVTable,
bool DontDefer, bool IsThunk,
-   llvm::AttributeSet ExtraAttrs) {
+   llvm::AttributeSet ExtraAttrs,
+   bool IsForDefinition) {
   const Decl *D = GD.getDecl();
 
   // Lookup the entry, lazily creating it if necessary.
@@ -1569,11 +1595,32 @@
 if (D && !D->hasAttr() && !D->hasAttr())
   Entry->setDLLStorageClass(llvm::GlobalValue::DefaultStorageClass);
 
-if (Entry->getType()->getElementType() == Ty)
+// If there are two attempts to define the same mangled name, issue a
+// warning.
+if (IsForDefinition && !Entry->isDeclaration()) {
+  GlobalDecl OtherGD;
+  // Check that GD is not yet in ExplicitDefinitions is required to make
+  // sure that we issue a warning only once.
+  if (lookupRepresentativeDecl(MangledName, OtherGD) &&
+  (GD.getDecl() != OtherGD.getDecl()) &&
+  DiagnosedConflictingDefinitions.insert(GD).second) {
+getDiags().Report(D->getLocation(),
+  diag::warn_duplicate_mangled_name);
+getDiags().Report(OtherGD.getDecl()->getLocation(),
+  diag::note_previous_definition);
+  }
+}
+
+if ((isa(Entry) || isa(Entry)) &&
+(Entry->getType()->getElementType() == Ty)) {
   return Entry;
+}
 
 // Make sure the result is of the correct type.
-return llvm::ConstantExpr::getBitCast(Entry, Ty->getPointerTo());
+// (If function is requested for a definition, we always need to create a new
+// function, not just return a bitcast.)
+if (!IsForDefinition)
+  return llvm::ConstantExpr::getBitCast(Entry, Ty->getPointerTo());
   }
 
   // This function doesn't have a complete type (for example, the return
@@ -1588,10 +1635,36 @@
 FTy = llvm::FunctionType::get(VoidTy, false);
 IsIncompleteFunction = true;
   }
-  
-  llvm::Function *F = llvm::Function::Create(FTy,
- llvm::Function::ExternalLinkage,
-   

Re: [PATCH] D11832: [Patch] [Analyzer] false positive: Potential leak connected with memcpy (PR 22954)

2015-08-28 Thread pierre gousseau via cfe-commits
pgousseau added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:863
@@ +862,3 @@
+
+  const ElementRegion *ER = dyn_cast(R);
+  // Cast is safe as BufVal's region is a FieldRegion.

dcoughlin wrote:
> You can use cast(R) here, which will assert that R is an 
> ElementRegion, and remove the assert below.
Will do ! Thanks.


http://reviews.llvm.org/D11832



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


Re: [PATCH] D11832: [Patch] [Analyzer] false positive: Potential leak connected with memcpy (PR 22954)

2015-08-28 Thread pierre gousseau via cfe-commits
pgousseau updated this revision to Diff 33402.
pgousseau added a comment.

Replace 'dyn_cast' by 'cast' following Devin's review.

If all looks good could someone commit this patch for me ?

Regards,

Pierre


http://reviews.llvm.org/D11832

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  lib/StaticAnalyzer/Core/RegionStore.cpp
  test/Analysis/pr22954.c

Index: test/Analysis/pr22954.c
===
--- /dev/null
+++ test/Analysis/pr22954.c
@@ -0,0 +1,697 @@
+// Given code 'struct aa { char s1[4]; char * s2;} a; memcpy(a.s1, ...);',
+// this test checks that the CStringChecker only invalidates the destination buffer array a.s1 (instead of a.s1 and a.s2).
+// At the moment the whole of the destination array content is invalidated.
+// If a.s1 region has a symbolic offset, the whole region of 'a' is invalidated.
+// Specific triple set to test structures of size 0.
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-store=region -verify %s
+
+typedef __typeof(sizeof(int)) size_t;
+
+char *strdup(const char *s);
+void free(void *);
+void *memcpy(void *dst, const void *src, size_t n); // expected-note{{passing argument to parameter 'dst' here}}
+void *malloc(size_t n);
+
+void clang_analyzer_eval(int);
+
+struct aa {
+char s1[4];
+char *s2;
+};
+
+// Test different types of structure initialisation.
+int f0() {
+  struct aa a0 = {{1, 2, 3, 4}, 0};
+  a0.s2 = strdup("hello");
+  char input[] = {'a', 'b', 'c', 'd'};
+  memcpy(a0.s1, input, 4);
+  clang_analyzer_eval(a0.s1[0] == 'a'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a0.s1[1] == 'b'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a0.s1[2] == 'c'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a0.s1[3] == 'd'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a0.s2 == 0); // expected-warning{{UNKNOWN}}
+  free(a0.s2); // no warning
+  return 0;
+}
+
+int f1() {
+  struct aa a1;
+  a1.s2 = strdup("hello");
+  char input[] = {'a', 'b', 'c', 'd'};
+  memcpy(a1.s1, input, 4);
+  clang_analyzer_eval(a1.s1[0] == 'a'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a1.s1[1] == 'b'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a1.s1[2] == 'c'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a1.s1[3] == 'd'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a1.s2 == 0); // expected-warning{{UNKNOWN}}
+  free(a1.s2); // no warning
+  return 0;
+}
+
+int f2() {
+  struct aa a2 = {{1, 2}};
+  a2.s2 = strdup("hello");
+  char input[] = {'a', 'b', 'c', 'd'};
+  memcpy(a2.s1, input, 4);
+  clang_analyzer_eval(a2.s1[0] == 'a'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a2.s1[1] == 'b'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a2.s1[2] == 'c'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a2.s1[3] == 'd'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a2.s2 == 0); // expected-warning{{UNKNOWN}}
+  free(a2.s2); // no warning
+  return 0;
+}
+
+int f3() {
+  struct aa a3 = {{1, 2, 3, 4}, 0};
+  a3.s2 = strdup("hello");
+  char input[] = {'a', 'b', 'c', 'd'};
+  int * dest = (int*)a3.s1;
+  memcpy(dest, input, 4);
+  clang_analyzer_eval(a3.s1[0] == 'a'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(dest[0] == 'a'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a3.s1[1] == 'b'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(dest[1] == 'b'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a3.s1[2] == 'c'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(dest[2] == 'c'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a3.s1[3] == 'd'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(dest[3] == 'd'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(a3.s2 == 0); // expected-warning{{UNKNOWN}}
+  free(a3.s2); // no warning
+  return 0;
+}
+
+struct bb {
+  struct aa a;
+  char * s2;
+};
+
+int f4() {
+  struct bb b0 = {{1, 2, 3, 4}, 0};
+  b0.s2 = strdup("hello");
+  b0.a.s2 = strdup("hola");
+  char input[] = {'a', 'b', 'c', 'd'};
+  char * dest = (char*)(b0.a.s1);
+  memcpy(dest, input, 4);
+  clang_analyzer_eval(b0.a.s1[0] == 'a'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(dest[0] == 'a'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(b0.a.s1[1] == 'b'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(dest[1] == 'b'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(b0.a.s1[2] == 'c'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(dest[2] == 'c'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(b0.a.s1[3] == 'd'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(dest[3] == 'd'); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(b0.s2 == 0); // expected-warning{{UNKNOWN}}
+  free(b0.a.s2); // no warning
+  free(b0.s2); // no warning
+  return 0;
+}
+
+// Test that memor

Re: [PATCH] D11297: PR17829: Functions declared extern "C" with a name matching a mangled C++ function are allowed

2015-08-28 Thread John McCall via cfe-commits
rjmccall added a comment.

This looks great, thanks!  One last comment; if you agree with me, go ahead and 
fix it and then commit.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2323
@@ -2323,1 +2322,3 @@
+  "definition with same mangled name as another definition">,
+  InGroup;
 def err_cyclic_alias : Error<

I'm sorry to bring this up so late in the process, but is there a good reason 
for this to be a warning and not an error?


http://reviews.llvm.org/D11297



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


Re: [PATCH] D11361: [OpenMP] Target directive host codegen

2015-08-28 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:2991-3005
@@ +2990,17 @@
+
+/// \brief Values for bit flags used to specify the mapping type for
+/// offloading.
+enum OpenMPOffloadMappingFlags {
+  /// \brief Allocate memory on the device and move data from host to device.
+  OMP_MAP_TO = 0x01,
+  /// \brief Allocate memory on the device and move data from device to host.
+  OMP_MAP_FROM = 0x02,
+};
+
+enum OpenMPOffloadingReservedDeviceIDs {
+  /// \brief Device ID if the device was not defined, runtime should get it
+  /// from environment variables in the spec.
+  OMP_DEVICEID_UNDEF = -1,
+};
+
+void CGOpenMPRuntime::emitTargetCall(CodeGenFunction &CGF,

Move them to CGOpenMPRuntime::emitTargetCall(), they can be made local


Comment at: test/OpenMP/target_codegen.cpp:8
@@ +7,3 @@
+// expected-no-diagnostics
+// REQUIRES: powerpc-registered-target
+#ifndef HEADER

Some of your tests has triple i386, they don't need PowerPC target


http://reviews.llvm.org/D11361



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


Re: [PATCH] D6551: Improvements to scan-build.

2015-08-28 Thread Sylvestre Ledru via cfe-commits
sylvestre.ledru added a comment.

Anton, I think you should just commit it. We can always iterate on this later 
if it breaks anything.
The patch is big and rebasing is time consuming.


http://reviews.llvm.org/D6551



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


Re: [PATCH] D12081: Add use-nullptr check to clang-tidy.

2015-08-28 Thread Aaron Ballman via cfe-commits
On Thu, Aug 27, 2015 at 7:36 PM, Alexander Kornienko  wrote:
> On Fri, Aug 28, 2015 at 1:23 AM, Aaron Ballman 
> wrote:
>>
>> On Thu, Aug 27, 2015 at 7:20 PM, Alexander Kornienko 
>> wrote:
>> > alexfh added a comment.
>> >
>> > In http://reviews.llvm.org/D12081#234614, @aaron.ballman wrote:
>> >
>> >> While working on r246209, one of the build bots ran into an issue
>> >> (commented below) that has me slightly perplexed. The build break can be
>> >> found at:
>> >> http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/30516
>> >
>> >
>> > Seems to be related to the  -std=c++98 in the test?
>>
>> That's what I figured as well.
>>
>> >
>> >> What's also strange is that I could not reproduce that failure locally
>> >> (MSVC 2015 debug build, Windows 10)...
>> >
>> >
>> > That's strange. Maybe there's some command-line argument parsing magic
>> > when targeting windows?
>>
>> That's what I'm slightly more concerned by. I will investigate in the
>> morning on my machine and see what I come up with.
>>
>> >
>> >
>> > 
>> > Comment at: test/clang-tidy/modernize-use-nullptr-basic.cpp:2
>> > @@ +1,3 @@
>> > +// RUN: $(dirname %s)/check_clang_tidy.sh %s modernize-use-nullptr %t
>> > -- \
>> > +// RUN:   -std=c++98 -Wno-non-literal-null-conversion
>> > +// REQUIRES: shell
>> > 
>> > aaron.ballman wrote:
>> >> Sorry for bringing this up later, but how is this test supposed to
>> >> work? nullptr is not a valid C++98 construct, and so I don't think we 
>> >> should
>> >> be recommending fixes to use nullptr in this case. Is there a reason this
>> >> test case is using -std=c++98 instead of -std=c++11?
>> > Looks like a mistake. It should be -std=c++11. But while the check
>> > wasn't looking at LangOpts, it didn't make any difference, because we don't
>> > try to compile the fixed code.
>>
>> Okay, glad it's just a mistake. When I recommit my patch, I'll correct
>> this RUN line.
>
>
> Apparently, I was wrong. Some of the constructs in the test file fail to
> compile in c++11. So maybe we should allow the check to run in c++98 mode:
> to migrate the constructs that otherwise wouldn't compile. It still makes
> sense to require C++, I guess.

I suppose that for things in the modernize category, it makes sense to
allow it for any C++ language option as the user may be attempting to
modernize the code base. I'll go that route, thank you!

~Aaron

>
>>
>>
>> Thanks!
>>
>> ~Aaron
>>
>> >
>> >
>> > http://reviews.llvm.org/D12081
>> >
>> >
>> >
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r246295 - Support Debian s390x multiarch paths

2015-08-28 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Fri Aug 28 07:26:09 2015
New Revision: 246295

URL: http://llvm.org/viewvc/llvm-project?rev=246295&view=rev
Log:
Support Debian s390x multiarch paths

Summary: Patch by Steven Chamberlain 

Reviewers: uweigand

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

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

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=246295&r1=246294&r2=246295&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Aug 28 07:26:09 2015
@@ -3099,6 +3099,10 @@ static std::string getMultiarchTriple(co
 if (llvm::sys::fs::exists(SysRoot + "/lib/sparc64-linux-gnu"))
   return "sparc64-linux-gnu";
 break;
+  case llvm::Triple::systemz:
+if (llvm::sys::fs::exists(SysRoot + "/lib/s390x-linux-gnu"))
+  return "s390x-linux-gnu";
+break;
   }
   return TargetTriple.str();
 }
@@ -3442,6 +3446,8 @@ void Linux::AddClangSystemIncludeArgs(co
   "/usr/include/sparc-linux-gnu"};
   const StringRef Sparc64MultiarchIncludeDirs[] = {
   "/usr/include/sparc64-linux-gnu"};
+  const StringRef SYSTEMZMultiarchIncludeDirs[] = {
+  "/usr/include/s390x-linux-gnu"};
   ArrayRef MultiarchIncludeDirs;
   switch (getTriple().getArch()) {
   case llvm::Triple::x86_64:
@@ -3487,6 +3493,9 @@ void Linux::AddClangSystemIncludeArgs(co
   case llvm::Triple::sparcv9:
 MultiarchIncludeDirs = Sparc64MultiarchIncludeDirs;
 break;
+  case llvm::Triple::systemz:
+MultiarchIncludeDirs = SYSTEMZMultiarchIncludeDirs;
+break;
   default:
 break;
   }

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=246295&r1=246294&r2=246295&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Aug 28 07:26:09 2015
@@ -8122,7 +8122,7 @@ static std::string getLinuxDynamicLinker
   return "/lib64/ld64.so.1";
 return "/lib64/ld64.so.2";
   } else if (Arch == llvm::Triple::systemz)
-return "/lib64/ld64.so.1";
+return "/lib/ld64.so.1";
   else if (Arch == llvm::Triple::sparcv9)
 return "/lib64/ld-linux.so.2";
   else if (Arch == llvm::Triple::x86_64 &&


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


Re: [PATCH] D11297: PR17829: Functions declared extern "C" with a name matching a mangled C++ function are allowed

2015-08-28 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2323
@@ -2323,1 +2322,3 @@
+  "definition with same mangled name as another definition">,
+  InGroup;
 def err_cyclic_alias : Error<

rjmccall wrote:
> I'm sorry to bring this up so late in the process, but is there a good reason 
> for this to be a warning and not an error?
No good reasons at all -- I thought you want this to be a warning, but looks 
like I misinterpreted you.

Do you want me to make this an error?

(If yes, apart of changing warn_duplicate_mangled_name to 
err_duplicate_mangled_name everywhere, I will have to change the test -- let me 
know whatever you want to review these changes or not really interested and 
your "go ahead and fix it and then commit" still holds true)

Andrey



http://reviews.llvm.org/D11297



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


Re: [PATCH] D12358: [Analyzer] Handling constant bound loops

2015-08-28 Thread Sean Eveson via cfe-commits
seaneveson added a comment.

In http://reviews.llvm.org/D12358#234949, @zaks.anna wrote:

> We try to avoid false positives as much as possible. They are very painful 
> for users to deal with.




> You should develop this feature behind a flag. This would allow for 
> incremental development and simplify evaluation.


I absolutely want to minimize false positives, but I also want to make a start 
on just doing something after the loop, where the solution could then be 
improved upon. Developing behind a flag seems to be an ideal solution to me.

In http://reviews.llvm.org/D12358#234975, @krememek wrote:

> I think the functionality started here by doing something clever with loops 
> is complex enough to warrant putting this into a separate .cpp file.


Good idea.

In http://reviews.llvm.org/D12358#234986, @krememek wrote:

> I do wonder if nested loops will cause a problem here


Yes the patch only works with the inner most loop. A fix to this should ideally 
prevent inner loops being analyzed again from an identical state. I haven’t 
looked into if this will ‘just happen’ as a result of the framework, or how to 
do it otherwise.

In http://reviews.llvm.org/D12358#234977, @krememek wrote:

> I think we’d all be quite amendable for this work to go in under a flag, with 
> further improvements going in on top of that.  That way we can all 
> collectively start hashing this out in trunk instead of feature creeping a 
> patch.


If I refactor this patch in its current state into a separate file and put it 
behind a flag, would it then be acceptable?  I would then like to take some 
time to look at the invalidation improvements as discussed in this thread.


http://reviews.llvm.org/D12358



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


[clang-tools-extra] r246298 - Reapplying r246209, which exposed language options to the checkers. This time disable UseNullptrCheck when not compiling in C++ mode, but still allow in C++11 mode since

2015-08-28 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Aug 28 08:20:46 2015
New Revision: 246298

URL: http://llvm.org/viewvc/llvm-project?rev=246298&view=rev
Log:
Reapplying r246209, which exposed language options to the checkers. This time 
disable UseNullptrCheck when not compiling in C++ mode, but still allow in 
C++11 mode since it's likely the user wishes to modernize their code.

Added:
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.c
Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.h
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.h?rev=246298&r1=246297&r2=246298&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.h Fri Aug 28 08:20:46 2015
@@ -158,6 +158,8 @@ protected:
   OptionsView Options;
   /// \brief Returns the main file name of the current translation unit.
   StringRef getCurrentMainFile() const { return Context->getCurrentFile(); }
+  /// \brief Returns the language options from the context.
+  LangOptions getLangOpts() const { return Context->getLangOpts(); }
 };
 
 class ClangTidyCheckFactories;

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=246298&r1=246297&r2=246298&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Fri Aug 
28 08:20:46 2015
@@ -212,6 +212,7 @@ void ClangTidyContext::setCurrentFile(St
 
 void ClangTidyContext::setASTContext(ASTContext *Context) {
   DiagEngine->SetArgToStringFn(&FormatASTNodeDiagnosticArgument, Context);
+  LangOpts = Context->getLangOpts();
 }
 
 const ClangTidyGlobalOptions &ClangTidyContext::getGlobalOptions() const {

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h?rev=246298&r1=246297&r2=246298&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h Fri Aug 28 
08:20:46 2015
@@ -149,6 +149,9 @@ public:
   /// \brief Sets ASTContext for the current translation unit.
   void setASTContext(ASTContext *Context);
 
+  /// \brief Gets the language options from the AST context
+  LangOptions getLangOpts() const { return LangOpts; }
+
   /// \brief Returns the name of the clang-tidy check which produced this
   /// diagnostic ID.
   StringRef getCheckName(unsigned DiagnosticID) const;
@@ -198,6 +201,8 @@ private:
   ClangTidyOptions CurrentOptions;
   std::unique_ptr CheckFilter;
 
+  LangOptions LangOpts;
+
   ClangTidyStats Stats;
 
   llvm::DenseMap CheckNamesByDiagnosticID;

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp?rev=246298&r1=246297&r2=246298&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp Fri Aug 28 
08:20:46 2015
@@ -453,7 +453,11 @@ void UseNullptrCheck::storeOptions(Clang
 }
 
 void UseNullptrCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(makeCastSequenceMatcher(), this);
+  // Only register the matcher for C++. Because this checker is used for
+  // modernization, it is reasonable to run it on any C++ standard with the
+  // assumption the user is trying to modernize their codebase.
+  if (getLangOpts().CPlusPlus)
+Finder->addMatcher(makeCastSequenceMatcher(), this);
 }
 
 void UseNullptrCheck::check(const MatchFinder::MatchResult &Result) {

Added: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.c
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.c?rev=246298&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.c (added)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.c Fri Aug 28 
08:20:46 2015
@@ -0,0 +1,10 @@
+// RUN: clang-tidy %s -checks=-*,modernize-use-nullptr -- | count 0
+
+// Note: this test expects no dia

Re: [PATCH] D11963: Create a __config_site file to capture configuration decisions.

2015-08-28 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

In http://reviews.llvm.org/D11963#234789, @EricWF wrote:

> Copy the headers to the build directory during every build instead of just 
> during CMake configuration.


Sounds like this would cause every build to effectively be a full build. I 
don't think we want that...

If that's the case, then I think we should use the same trick that TableGen 
uses: write the new file to a temporary, and overwrite it iff they differ.


http://reviews.llvm.org/D11963



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


r246303 - fix typo; NFC

2015-08-28 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Fri Aug 28 09:42:54 2015
New Revision: 246303

URL: http://llvm.org/viewvc/llvm-project?rev=246303&view=rev
Log:
fix typo; NFC

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

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=246303&r1=246302&r2=246303&view=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Fri Aug 28 09:42:54 2015
@@ -1349,7 +1349,7 @@ namespace {
 
   }; // end class DeclExtractor
 
-  // DeclMatcher checks to see if the decls are used in a non-evauluated
+  // DeclMatcher checks to see if the decls are used in a non-evaluated
   // context.
   class DeclMatcher : public EvaluatedExprVisitor {
 llvm::SmallPtrSetImpl &Decls;


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


Re: Implict casts disappeared from syntactic init list expressions in C++

2015-08-28 Thread Abramo Bagnara via cfe-commits
Ping.

Il 25/08/2015 19:27, Abramo Bagnara ha scritto:
> Comparing the result of InitListExpr::getSyntacticForm between r224986
> and r245836 I've discovered that integer to char implicit cast for
> integer literal 3 is no longer added to AST for C++ (while it is present
> in C).
> 
> This is the source used to test:
> 
> char v[10] = { 3 };
> 
> Taken in account that:
> 
> - implicit cast (and other conversions, constructor calls, etc.) are
> very important also for who need to visit the syntactic form (obvious in
> *both* C and C++)
> 
> - to generate that for the syntactic form permit to increase the
> efficiency and the sharing when using designated range extensions (as
> the conversion chain don't need to be replicated for each entry)
> 
> I think it is a regression. Am I missing something?
> 


-- 
Abramo Bagnara

BUGSENG srl - http://bugseng.com
mailto:abramo.bagn...@bugseng.com
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D12435: [Concepts] Add diagnostic; invalid specifier on function or variable concept declaration

2015-08-28 Thread Nathan Wilson via cfe-commits
nwilson created this revision.
nwilson added reviewers: rsmith, hubert.reinterpretcast, aaron.ballman, 
faisalv, fraggamuffin.
nwilson added a subscriber: cfe-commits.

Diagnose variable and function concept declarations when an invalid specifier 
appears

http://reviews.llvm.org/D12435

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp
@@ -0,0 +1,9 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template concept thread_local bool VCTL = true; // expected-error 
{{variable concept cannot be declared with thread_local specified}}
+
+template concept constexpr bool VCC = true; // expected-error 
{{variable concept cannot be declared with constexpr specified}}
+
+template concept constexpr bool FCC() { return true; } // 
expected-error {{function concept cannot be declared with constexpr specified}}
+
+template concept inline bool FCI() { return true; } // 
expected-error {{function concept cannot be declared with inline specified}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5871,8 +5871,26 @@
 if (D.getDeclSpec().isConstexprSpecified())
   NewVD->setConstexpr(true);
 
-if (D.getDeclSpec().isConceptSpecified())
+if (D.getDeclSpec().isConceptSpecified()) {
   NewVD->setConcept(true);
+
+  // C++ Concepts TS [dcl.spec.concept]p2: A concept definition shall not
+  // be declared with the thread_local, inline, friend, or constexpr
+  // specifiers, [...]
+  if (D.getDeclSpec().getThreadStorageClassSpec() == TSCS_thread_local) {
+Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(),
+ diag::err_concept_decl_invalid_sepcifiers)
+<< 0 << 0;
+NewVD->setInvalidDecl(true);
+  }
+
+  if (D.getDeclSpec().isConstexprSpecified()) {
+Diag(D.getDeclSpec().getConstexprSpecLoc(),
+ diag::err_concept_decl_invalid_sepcifiers)
+<< 0 << 1;
+NewVD->setInvalidDecl(true);
+  }
+}
   }
 
   // Set the lexical context. If the declarator has a C++ scope specifier, the
@@ -7497,6 +7515,23 @@
   // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is
   // implicity defined to be a constexpr declaration (implicitly inline)
   NewFD->setImplicitlyInline();
+
+  // C++ Concepts TS [dcl.spec.concept]p2: A concept definition shall not
+  // be declared with the thread_local, inline, friend, or constexpr
+  // specifiers, [...]
+  if (isConstexpr) {
+Diag(D.getDeclSpec().getConstexprSpecLoc(),
+ diag::err_concept_decl_invalid_sepcifiers)
+<< 1 << 1;
+NewFD->setInvalidDecl(true);
+  }
+
+  if (isInline) {
+Diag(D.getDeclSpec().getInlineSpecLoc(),
+ diag::err_concept_decl_invalid_sepcifiers)
+<< 1 << 2;
+NewFD->setInvalidDecl(true);
+  }
 }
 
 // If __module_private__ was specified, mark the function accordingly.
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -1979,6 +1979,9 @@
   "variable concept declaration must be initialized">;
 def err_function_concept_exception_spec : Error<
   "function concept cannot have exception specification">;
+def err_concept_decl_invalid_sepcifiers : Error<
+  "%select{variable|function}0 concept cannot be declared with "
+  "%select{thread_local|constexpr|inline}1 specified">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<


Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp
@@ -0,0 +1,9 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template concept thread_local bool VCTL = true; // expected-error {{variable concept cannot be declared with thread_local specified}}
+
+template concept constexpr bool VCC = true; // expected-error {{variable concept cannot be declared with constexpr specified}}
+
+template concept constexpr bool FCC() { return true; } // expected-error {{function concept cannot be declared with constexpr specified}}
+
+template concept inline bool FCI() { return true; } // expected-error {{function concept cannot be declared with inline specified}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5871,8 +5871,26 @@
 if (D.getDeclSpec().is

Re: [PATCH] D12022: Refactored dtor sanitizing into EHScopeStack

2015-08-28 Thread Naomi Musgrave via cfe-commits
nmusgrave updated this revision to Diff 33436.
nmusgrave added a comment.

- Checking for existence of fields to poison in alias emission.


http://reviews.llvm.org/D12022

Files:
  lib/CodeGen/CGCXX.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
  test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp

Index: test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp
===
--- /dev/null
+++ test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp
@@ -0,0 +1,30 @@
+// Test -fsanitize-memory-use-after-dtor
+// RUN: %clang_cc1 -fsanitize=memory -O1 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=memory -O2 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+template 
+class Vector {
+public:
+  int size;
+  ~Vector() {}
+};
+
+// Virtual function table for the derived class only contains
+// its own destructors, with no aliasing to base class dtors.
+struct Base {
+  Vector v;
+  int x;
+  Base() { x = 5; }
+  virtual ~Base() {}
+};
+
+struct Derived : public Base {
+  int z;
+  Derived() { z = 10; }
+  ~Derived() {}
+};
+
+Derived d;
+
+// Definition of virtual function table
+// CHECK: @_ZTV7Derived = {{.*}}(void (%struct.Derived*)* @_ZN7DerivedD1Ev to i8*){{.*}}(void (%struct.Derived*)* @_ZN7DerivedD0Ev to i8*)
Index: test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
===
--- /dev/null
+++ test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -fsanitize=memory -O0 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=memory -O1 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+template 
+class Vector {
+public:
+  int size;
+  ~Vector() {
+size += 1;
+  }
+};
+
+struct Base {
+  int b1;
+  double b2;
+  Base() {
+b1 = 5;
+b2 = 10.989;
+  }
+  virtual ~Base() {}
+};
+
+struct VirtualBase {
+  int vb1;
+  int vb2;
+  VirtualBase() {
+vb1 = 10;
+vb2 = 11;
+  }
+  virtual ~VirtualBase() {}
+};
+
+struct Derived : public Base, public virtual VirtualBase {
+  int d1;
+  Vector v;
+  int d2;
+  Derived() {
+d1 = 10;
+  }
+  ~Derived() {}
+};
+
+Derived d;
+
+// Destruction order:
+// Derived: int, Vector, Base, VirtualBase
+
+// CHECK-LABEL: define {{.*}}ZN7DerivedD1Ev
+// CHECK: call void {{.*}}ZN11VirtualBaseD2Ev
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}ZN7DerivedD0Ev
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}ZN11VirtualBaseD1Ev
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}ZN11VirtualBaseD0Ev
+// CHECK: ret void
+
+// poison 2 ints
+// CHECK-LABEL: define {{.*}}ZN11VirtualBaseD2Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 8)
+// CHECK: ret void
+
+// poison int and double
+// CHECK-LABEL: define {{.*}}ZN4BaseD2Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 16)
+// CHECK: ret void
+
+// poison int, ignore vector, poison int
+// CHECK-LABEL: define {{.*}}ZN7DerivedD2Ev
+// CHECK: call void {{.*}}ZN6VectorIiED1Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4)
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4)
+// CHECK: call void {{.*}}ZN4BaseD2Ev
+// CHECK: ret void
+
+// poison int
+// CHECK-LABEL: define {{.*}}ZN6VectorIiED2Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4)
+// CHECK: ret void
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -1098,6 +1098,13 @@
   /// are emitted lazily.
   void EmitGlobal(GlobalDecl D);
 
+  bool
+  HasTrivialDestructorBody(ASTContext &Context,
+   const CXXRecordDecl *BaseClassDecl,
+   const CXXRecordDecl *MostDerivedClassDecl);
+  bool
+  FieldHasTrivialDestructorBody(ASTContext &Context, const FieldDecl *Field);
+
   bool TryEmitDefinitionAsAlias(GlobalDecl Alias, GlobalDecl Target,
 bool InEveryTU);
   bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D);
Index: lib/CodeGen/CGClass.cpp
===
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1286,11 +1286,7 @@
   CM.finish();
 }
 
-static bool
-FieldHasTrivialDestructorBody(ASTContext &Context, const FieldDecl *Field);
-
-static bool
-HasTrivialDestructorBody(ASTContext &Context,
+bool CodeGenModule::HasTrivialDestructorBody(ASTContext &Context,
  const CXXRecordDecl *BaseClassDecl,
  const CXXRecordDecl *MostDerivedClassDecl)
 {
@@ -1332,10 +1328,12 @@
   return tr

Re: [PATCH] D12022: Refactored dtor sanitizing into EHScopeStack

2015-08-28 Thread Naomi Musgrave via cfe-commits
nmusgrave marked 3 inline comments as done.
nmusgrave added a comment.

http://reviews.llvm.org/D12022



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


Re: [PATCH] D12022: Refactored dtor sanitizing into EHScopeStack

2015-08-28 Thread Naomi Musgrave via cfe-commits
nmusgrave added inline comments.


Comment at: test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp:30
@@ +29,2 @@
+// Definition of virtual function table
+// CHECK: @_ZTV7Derived = {{.*}}(void (%struct.Derived*)* @_ZN7DerivedD1Ev to 
i8*){{.*}}(void (%struct.Derived*)* @_ZN7DerivedD0Ev to i8*)

Its checking that my aliasing is repressed when appropriate.Should I keep or 
get rid of this test case?


http://reviews.llvm.org/D12022



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


Re: [PATCH] D12435: [Concepts] Add diagnostic; invalid specifier on function or variable concept declaration

2015-08-28 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1982
@@ -1981,1 +1981,3 @@
   "function concept cannot have exception specification">;
+def err_concept_decl_invalid_sepcifiers : Error<
+  "%select{variable|function}0 concept cannot be declared with "

The wording seems unwieldy. There are a number of messages of the form:

> [ ... ] cannot be declared ''

Perhaps something along those lines would work here?

btw, there's a typo in the message identifier.


http://reviews.llvm.org/D12435



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


[PATCH][Solaris] Default to -fno-cxa-finalize

2015-08-28 Thread Xan López via cfe-commits
There is no __cxa_finalize symbol available on recent Solaris OS
versions, so we need this flag to make non trivial C++ programs run.

Also stop looking for cxa_finalize.o, since it won't be there.

(This patch sits on top of a couple of unreviewed patches that make clang 
actually work on Solaris, see:

http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20150810/292800.html
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20150817/293971.html

It should be trivial to rebase against master if it is reviewed first though)

Xan
>From 014ddb164689a3452b76f85079f213d607d07840 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Xan=20L=C3=B3pez?= 
Date: Fri, 14 Aug 2015 11:36:56 +0200
Subject: [PATCH 2/4] [Solaris] Default to -fno-cxa-finalize

There is no __cxa_finalize symbol available on recent Solaris OS
versions, so we need this flag to make non trivial C++ programs run.

Also stop looking for cxa_finalize.o, since it won't be there.
---
 lib/Driver/Tools.cpp | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index b204961..cf01d7b 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -4506,8 +4506,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   if (!Args.hasFlag(options::OPT_fuse_cxa_atexit,
 options::OPT_fno_use_cxa_atexit,
 !IsWindowsCygnus && !IsWindowsGNU &&
-getToolChain().getArch() != llvm::Triple::hexagon &&
-getToolChain().getArch() != llvm::Triple::xcore) ||
+getToolChain().getTriple().getOS() != 
llvm::Triple::Solaris &&
+getToolChain().getArch() != llvm::Triple::hexagon &&
+getToolChain().getArch() != llvm::Triple::xcore) ||
   KernelOrKext)
 CmdArgs.push_back("-fno-use-cxa-atexit");
 
@@ -6882,10 +6883,6 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 Args.MakeArgString(getToolChain().GetFilePath("values-Xa.o")));
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crtbegin.o")));
-
-if (getToolChain().getDriver().CCCIsCXX())
-  CmdArgs.push_back(
-  Args.MakeArgString(getToolChain().GetFilePath("cxa_finalize.o")));
   }
 
   const ToolChain::path_list &Paths = getToolChain().getFilePaths();
-- 
2.4.3

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


[PATCH][Solaris] Add -lc also when linking shared libraries

2015-08-28 Thread Xan López via cfe-commits
This is actually needed, otherwise libc won't be added at all. For
instance when building libclang.so all the libc symbols won't be
found, with ld warning about libc being an "implicit dependency".

((This patch sits on top of a couple of unreviewed patches that make clang 
actually work on Solaris, see:

http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20150810/292800.html
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20150817/293971.html

It should be trivial to rebase against master if it is reviewed first though)

Xan
>From 8e81d6b095542c0ff1e28cf1f09d675f8afe1a25 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Xan=20L=C3=B3pez?= 
Date: Mon, 17 Aug 2015 16:04:26 +0200
Subject: [PATCH 4/4] [Solaris] Add -lc also when linking shared libraries

This is actually needed, otherwise libc won't be added at all. For
instance when building libclang.so all the libc symbols won't be
found, with ld warning about libc being an "implicit dependency".
---
 lib/Driver/Tools.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index cf01d7b..2034c0f 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -6899,9 +6899,9 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 if (getToolChain().getDriver().CCCIsCXX())
   getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
 CmdArgs.push_back("-lgcc_s");
+CmdArgs.push_back("-lc");
 if (!Args.hasArg(options::OPT_shared)) {
   CmdArgs.push_back("-lgcc");
-  CmdArgs.push_back("-lc");
   CmdArgs.push_back("-lm");
 }
   }
-- 
2.4.3

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


[clang-tools-extra] r246310 - Disable several more clang-tidy modernize checkers when not compiling in C++ mode. Loop conversion would make recommendations for C code, so added a test to ensure that d

2015-08-28 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Aug 28 12:58:10 2015
New Revision: 246310

URL: http://llvm.org/viewvc/llvm-project?rev=246310&view=rev
Log:
Disable several more clang-tidy modernize checkers when not compiling in C++ 
mode. Loop conversion would make recommendations for C code, so added a test to 
ensure that does not happen. The pass by value, use auto and replace auto_ptr 
checkers would not make recommendations for C code, and are disabled for 
performance reasons, but do not require an extra test.

Added:
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert.c
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=246310&r1=246309&r2=246310&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Fri Aug 
28 12:58:10 2015
@@ -539,9 +539,14 @@ void LoopConvertCheck::findAndVerifyUsag
 }
 
 void LoopConvertCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(makeArrayLoopMatcher(), this);
-  Finder->addMatcher(makeIteratorLoopMatcher(), this);
-  Finder->addMatcher(makePseudoArrayLoopMatcher(), this);
+  // Only register the matchers for C++. Because this checker is used for
+  // modernization, it is reasonable to run it on any C++ standard with the
+  // assumption the user is trying to modernize their codebase.
+  if (getLangOpts().CPlusPlus) {
+Finder->addMatcher(makeArrayLoopMatcher(), this);
+Finder->addMatcher(makeIteratorLoopMatcher(), this);
+Finder->addMatcher(makePseudoArrayLoopMatcher(), this);
+  }
 }
 
 void LoopConvertCheck::check(const MatchFinder::MatchResult &Result) {

Modified: clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp?rev=246310&r1=246309&r2=246310&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp Fri Aug 
28 12:58:10 2015
@@ -127,35 +127,46 @@ void PassByValueCheck::storeOptions(Clan
 }
 
 void PassByValueCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(
-  constructorDecl(
-  forEachConstructorInitializer(
-  ctorInitializer(
-  // Clang builds a CXXConstructExpr only whin it knows which
-  // constructor will be called. In dependent contexts a
-  // ParenListExpr is generated instead of a CXXConstructExpr,
-  // filtering out templates automatically for us.
-  withInitializer(constructExpr(
-  has(declRefExpr(to(
-  parmVarDecl(
-  hasType(qualType(
-  // Match only const-ref or a non-const value
-  // parameters. Rvalues and const-values
-  // shouldn't be modified.
-  anyOf(constRefType(), nonConstValueType()
-  .bind("Param",
-  hasDeclaration(constructorDecl(
-  isCopyConstructor(), unless(isDeleted()),
-  
hasDeclContext(recordDecl(isMoveConstructible(
-  .bind("Initializer")))
-  .bind("Ctor"),
-  this);
+  // Only register the matchers for C++; the functionality currently does not
+  // provide any benefit to other languages, despite being benign.
+  if (getLangOpts().CPlusPlus) {
+Finder->addMatcher(
+constructorDecl(
+forEachConstructorInitializer(
+ctorInitializer(
+// Clang builds a CXXConstructExpr only whin it knows which
+// constructor will be called. In dependent contexts a
+// ParenListExpr is generated instead of a 
CXXConstructExpr,
+// filtering out templates automatically for us.
+withInitializer(constructExpr(
+has(declRefExpr(to(
+parmVarDecl(
+hasType(qualType(
+// Match only const-ref or a non-const 
value
+// parameters. Rvalues and const-values
+ 

Re: [PATCH] D11832: [Patch] [Analyzer] false positive: Potential leak connected with memcpy (PR 22954)

2015-08-28 Thread Devin Coughlin via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

I will commit. Thanks for your work on this, Pierre!


http://reviews.llvm.org/D11832



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


Re: [PATCH] D11815: Pass subtarget feature "force-align-stack"

2015-08-28 Thread Akira Hatanaka via cfe-commits
ahatanak added inline comments.


Comment at: lib/Driver/Tools.cpp:4232
@@ +4231,3 @@
+   false))
+CmdArgs.push_back(Args.MakeArgString("-force-align-stack"));
+

hfinkel wrote:
> ahatanak wrote:
> > echristo wrote:
> > > hfinkel wrote:
> > > > echristo wrote:
> > > > > hfinkel wrote:
> > > > > > The code below for OPT_mstackrealign uses -mstackrealign as the 
> > > > > > name of the backend option too. Why not do the same for 
> > > > > > OPT_mstackrealign (use -mstackrealign as the name of the backend 
> > > > > > option) instead of inventing a new flag name -force-align-stack?
> > > > > In general we don't do that. But I also don't want this to use a 
> > > > > backend option anyhow, why are we doing that here once we have the 
> > > > > attribute?
> > > > It's not a backend option, this is the flag being passed from the 
> > > > driver to clang -cc1.
> > > > 
> > > Aha. I must have misread. Then I totally agree :)
> > I believe the confusing part here is that the CC1 option "-mstackrealign" 
> > in the code below indicates stack realignment is allowed, but not 
> > necessarily forced (see the definition of StackRealignment in 
> > CodeGenOptions.def). This is different from the driver option 
> > options::OPT_mstackrealign, which indicates stack alignment should be 
> > forced.
> > 
> > Does that answer your question?
> Yes, but this somehow makes things seem even more broken. As I understand it, 
> we have two underlying CodeGen options here:
> 
>  1. May the backend realign the stack if it thinks that it should? [Mainly 
> because it has some overaligned local variable to put on the stack]. This is 
> on by default.
>  2. Must the backend realign all functions. This is off by default.
> 
> GCC has an option -mstackrealign documented to mean only (2). But we 
> currently use its inverse (-mno-stackrealign) to mean the inverse of (1). 
> Frankly, (1) seems like a debugging option, and I don't see why we are 
> exposing it to users. If we have overaligned locals, than the backend should 
> realign the stack. Always. Otherwise the code is broken. Then we can use 
> -mstackrealign for its intended purpose of only meaning (2), and 
> -mno-stackrealign the inverse of (2).
> 
I think you are right. gcc's -mno-stackrealign doesn't disallow stack 
realignment. It cancels a -mstackrealign preceding it, but has no effect if it 
appears alone on the command line.

I'll upload a new patch shortly.


http://reviews.llvm.org/D11815



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


[PATCH] D12444: [Sema] Avoid crash on tag-type mismatch (Fixes PR24610)

2015-08-28 Thread Vedant Kumar via cfe-commits
vsk created this revision.
vsk added a subscriber: cfe-commits.

We currently assert-fail on the following input:

enum Color { R, G, B };
typedef struct Color C;

This patch just changes the assert to a conditional.

https://llvm.org/bugs/show_bug.cgi?id=24610

http://reviews.llvm.org/D12444

Files:
  lib/Sema/SemaDecl.cpp
  test/Sema/enum.c

Index: test/Sema/enum.c
===
--- test/Sema/enum.c
+++ test/Sema/enum.c
@@ -119,3 +119,7 @@
 
 typedef enum { NegativeShort = (short)-1 } NegativeShortEnum;
 int NegativeShortTest[NegativeShort == -1 ? 1 : -1];
+
+// PR24610
+enum Color { Red, Green, Blue }; // expected-note{{previous use is here}}
+typedef struct Color NewColor; // expected-error {{use of 'Color' with tag 
type that does not match previous declaration}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -3568,7 +3568,8 @@
 return;
 
   // A well-formed anonymous tag must always be a TUK_Definition.
-  assert(TagFromDeclSpec->isThisDeclarationADefinition());
+  if (!TagFromDeclSpec->isThisDeclarationADefinition())
+return;
 
   // The type must match the tag exactly;  no qualifiers allowed.
   if (!Context.hasSameType(NewTD->getUnderlyingType(),


Index: test/Sema/enum.c
===
--- test/Sema/enum.c
+++ test/Sema/enum.c
@@ -119,3 +119,7 @@
 
 typedef enum { NegativeShort = (short)-1 } NegativeShortEnum;
 int NegativeShortTest[NegativeShort == -1 ? 1 : -1];
+
+// PR24610
+enum Color { Red, Green, Blue }; // expected-note{{previous use is here}}
+typedef struct Color NewColor; // expected-error {{use of 'Color' with tag type that does not match previous declaration}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -3568,7 +3568,8 @@
 return;
 
   // A well-formed anonymous tag must always be a TUK_Definition.
-  assert(TagFromDeclSpec->isThisDeclarationADefinition());
+  if (!TagFromDeclSpec->isThisDeclarationADefinition())
+return;
 
   // The type must match the tag exactly;  no qualifiers allowed.
   if (!Context.hasSameType(NewTD->getUnderlyingType(),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D6551: Improvements to scan-build.

2015-08-28 Thread Devin Coughlin via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.

I ran our build-bot scripts with this and it looks good to me, although I've 
noted two places with trailing whitespace. Thanks for your patience!



Comment at: tools/scan-build/scan-build:1403
@@ +1402,3 @@
+  my $Args = shift;
+  
+  while (@$Args) {

Trailing whitespace here.


Comment at: tools/scan-build/scan-build:1774
@@ -1742,2 +1773,3 @@
 # Postprocess the HTML directory.
-my $NumBugs = Postprocess($HtmlDir, $BaseDir, $AnalyzerStats, $KeepEmpty);
+my $NumBugs = Postprocess($Options{OutputDir}, $BaseDir, 
+  $Options{AnalyzerStats}, $Options{KeepEmpty});

Trailing whitespace here.


http://reviews.llvm.org/D6551



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


Re: [PATCH] D6551: Improvements to scan-build.

2015-08-28 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Please, make sure to include a very specific commit title/message.


http://reviews.llvm.org/D6551



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


[clang-tools-extra] r246318 - Disable clang-tidy misc checkers when not compiling in C++ mode. Many of the checkers do not require additional testing as the tests will not compile for other languages

2015-08-28 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Aug 28 14:27:19 2015
New Revision: 246318

URL: http://llvm.org/viewvc/llvm-project?rev=246318&view=rev
Log:
Disable clang-tidy misc checkers when not compiling in C++ mode. Many of the 
checkers do not require additional testing as the tests will not compile for 
other languages or modes, or the checkers would never match a valid construct.

Added:

clang-tools-extra/trunk/test/clang-tidy/misc-undelegated-constructor-cxx98.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/UndelegatedConstructor.cpp
clang-tools-extra/trunk/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/UnusedRAIICheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp?rev=246318&r1=246317&r2=246318&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp 
Fri Aug 28 14:27:19 2015
@@ -19,31 +19,37 @@ namespace misc {
 
 void AssignOperatorSignatureCheck::registerMatchers(
 ast_matchers::MatchFinder *Finder) {
-  const auto HasGoodReturnType = 
methodDecl(returns(lValueReferenceType(pointee(
-  unless(isConstQualified()), hasDeclaration(equalsBoundNode("class"));
+  // Only register the matchers for C++; the functionality currently does not
+  // provide any benefit to other languages, despite being benign.
+  if (getLangOpts().CPlusPlus) {
+const auto HasGoodReturnType = methodDecl(returns(lValueReferenceType(
+pointee(unless(isConstQualified()),
+hasDeclaration(equalsBoundNode("class"));
+
+const auto IsSelf = qualType(anyOf(
+hasDeclaration(equalsBoundNode("class")),
+referenceType(pointee(hasDeclaration(equalsBoundNode("class"));
+const auto IsSelfAssign =
+methodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())),
+   hasName("operator="), ofClass(recordDecl().bind("class")),
+   hasParameter(0, parmVarDecl(hasType(IsSelf
+.bind("method");
+
+Finder->addMatcher(
+methodDecl(IsSelfAssign, unless(HasGoodReturnType)).bind("ReturnType"),
+this);
+
+const auto BadSelf = referenceType(
+anyOf(lValueReferenceType(pointee(unless(isConstQualified(,
+  rValueReferenceType(pointee(isConstQualified();
+
+Finder->addMatcher(
+methodDecl(IsSelfAssign, hasParameter(0, 
parmVarDecl(hasType(BadSelf
+.bind("ArgumentType"),
+this);
 
-  const auto IsSelf = qualType(
-  anyOf(hasDeclaration(equalsBoundNode("class")),
-referenceType(pointee(hasDeclaration(equalsBoundNode("class"));
-  const auto IsSelfAssign =
-  methodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())),
- hasName("operator="), ofClass(recordDecl().bind("class")),
- hasParameter(0, parmVarDecl(hasType(IsSelf.bind("method");
-
-  Finder->addMatcher(
-  methodDecl(IsSelfAssign, unless(HasGoodReturnType)).bind("ReturnType"),
-  this);
-
-  const auto BadSelf = referenceType(
-  anyOf(lValueReferenceType(pointee(unless(isConstQualified(,
-rValueReferenceType(pointee(isConstQualified();
-
-  Finder->addMatcher(
-  methodDecl(IsSelfAssign, hasParameter(0, parmVarDecl(hasType(BadSelf
-  .bind("ArgumentType"),
-  this);
-
-  Finder->addMatcher(methodDecl(IsSelfAssign, isConst()).bind("Const"), this);
+Finder->addMatcher(methodDecl(IsSelfAssign, isConst()).bind("Const"), 
this);
+  }
 }
 
 

Modified: clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp?rev=246318&r1=246317&r2=246318&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp Fri Aug 28 
14:27:19 2015
@@ -19,21 +19,27 @@ namespace tidy {
 namespace misc {
 
 void InaccurateEraseCheck::registerMatchers(MatchFi

r246319 - Revert "[X86][F16C] Added debug codegen test for F16C intrinsics"

2015-08-28 Thread Renato Golin via cfe-commits
Author: rengolin
Date: Fri Aug 28 14:34:53 2015
New Revision: 246319

URL: http://llvm.org/viewvc/llvm-project?rev=246319&view=rev
Log:
Revert "[X86][F16C] Added debug codegen test for F16C intrinsics"

This reverts commit r246204, as it was breaking all ARM/AArch64 bots.

Modified:
cfe/trunk/test/CodeGen/f16c-builtins.c

Modified: cfe/trunk/test/CodeGen/f16c-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/f16c-builtins.c?rev=246319&r1=246318&r2=246319&view=diff
==
--- cfe/trunk/test/CodeGen/f16c-builtins.c (original)
+++ cfe/trunk/test/CodeGen/f16c-builtins.c Fri Aug 28 14:34:53 2015
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +f16c 
-emit-llvm -o - -Werror | FileCheck %s
-// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +f16c -S 
-o - -Werror | FileCheck %s --check-prefix=CHECK-ASM
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +f16c 
-emit-llvm -o - | FileCheck %s
 
 // Don't include mm_malloc.h, it's system specific.
 #define __MM_MALLOC_H
@@ -8,24 +7,20 @@
 
 __m128 test_mm_cvtph_ps(__m128i a) {
   // CHECK: @llvm.x86.vcvtph2ps.128
-  // CHECK-ASM: vcvtph2ps %xmm{{.*}}, %xmm{{.*}}
   return _mm_cvtph_ps(a);
 }
 
 __m256 test_mm256_cvtph_ps(__m128i a) {
   // CHECK: @llvm.x86.vcvtph2ps.256
-  // CHECK-ASM: vcvtph2ps %xmm{{.*}}, %ymm{{.*}}
   return _mm256_cvtph_ps(a);
 }
 
 __m128i test_mm_cvtps_ph(__m128 a) {
   // CHECK: @llvm.x86.vcvtps2ph.128
-  // CHECK-ASM: vcvtps2ph $0, %xmm{{.*}}, %xmm{{.*}}
   return _mm_cvtps_ph(a, 0);
 }
 
 __m128i test_mm256_cvtps_ph(__m256 a) {
   // CHECK: @llvm.x86.vcvtps2ph.256
-  // CHECK-ASM: vcvtps2ph $0, %ymm{{.*}}, %xmm{{.*}}
   return _mm256_cvtps_ph(a, 0);
 }


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


Re: r246204 - [X86][F16C] Added debug codegen test for F16C intrinsics

2015-08-28 Thread Renato Golin via cfe-commits
Hi Simon,

I've reverted this commit in r246319, as it broke all ARM/AArch64 bots
and lots of other errors accumulated.

cheers,
--renato


On 27 August 2015 at 21:34, Simon Pilgrim via cfe-commits
 wrote:
> Author: rksimon
> Date: Thu Aug 27 15:34:02 2015
> New Revision: 246204
>
> URL: http://llvm.org/viewvc/llvm-project?rev=246204&view=rev
> Log:
> [X86][F16C] Added debug codegen test for F16C intrinsics
>
> Part of PR24590
>
> Modified:
> cfe/trunk/test/CodeGen/f16c-builtins.c
>
> Modified: cfe/trunk/test/CodeGen/f16c-builtins.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/f16c-builtins.c?rev=246204&r1=246203&r2=246204&view=diff
> ==
> --- cfe/trunk/test/CodeGen/f16c-builtins.c (original)
> +++ cfe/trunk/test/CodeGen/f16c-builtins.c Thu Aug 27 15:34:02 2015
> @@ -1,4 +1,5 @@
> -// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +f16c 
> -emit-llvm -o - | FileCheck %s
> +// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +f16c 
> -emit-llvm -o - -Werror | FileCheck %s
> +// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +f16c 
> -S -o - -Werror | FileCheck %s --check-prefix=CHECK-ASM
>
>  // Don't include mm_malloc.h, it's system specific.
>  #define __MM_MALLOC_H
> @@ -7,20 +8,24 @@
>
>  __m128 test_mm_cvtph_ps(__m128i a) {
>// CHECK: @llvm.x86.vcvtph2ps.128
> +  // CHECK-ASM: vcvtph2ps %xmm{{.*}}, %xmm{{.*}}
>return _mm_cvtph_ps(a);
>  }
>
>  __m256 test_mm256_cvtph_ps(__m128i a) {
>// CHECK: @llvm.x86.vcvtph2ps.256
> +  // CHECK-ASM: vcvtph2ps %xmm{{.*}}, %ymm{{.*}}
>return _mm256_cvtph_ps(a);
>  }
>
>  __m128i test_mm_cvtps_ph(__m128 a) {
>// CHECK: @llvm.x86.vcvtps2ph.128
> +  // CHECK-ASM: vcvtps2ph $0, %xmm{{.*}}, %xmm{{.*}}
>return _mm_cvtps_ph(a, 0);
>  }
>
>  __m128i test_mm256_cvtps_ph(__m256 a) {
>// CHECK: @llvm.x86.vcvtps2ph.256
> +  // CHECK-ASM: vcvtps2ph $0, %ymm{{.*}}, %xmm{{.*}}
>return _mm256_cvtps_ph(a, 0);
>  }
>
>
> ___
> 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


r246320 - Revert "[X86][FMA4] Added debug codegen test for FMA4 intrinsics"

2015-08-28 Thread Renato Golin via cfe-commits
Author: rengolin
Date: Fri Aug 28 14:36:27 2015
New Revision: 246320

URL: http://llvm.org/viewvc/llvm-project?rev=246320&view=rev
Log:
Revert "[X86][FMA4] Added debug codegen test for FMA4 intrinsics"

This reverts commit r246206, as it broke all ARM/AArch64 bots.

Modified:
cfe/trunk/test/CodeGen/fma4-builtins.c

Modified: cfe/trunk/test/CodeGen/fma4-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/fma4-builtins.c?rev=246320&r1=246319&r2=246320&view=diff
==
--- cfe/trunk/test/CodeGen/fma4-builtins.c (original)
+++ cfe/trunk/test/CodeGen/fma4-builtins.c Fri Aug 28 14:36:27 2015
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +fma4 
-emit-llvm -o - -Werror | FileCheck %s
-// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +fma4 -S 
-o - -Werror | FileCheck %s --check-prefix=CHECK-ASM
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +fma4 
-emit-llvm -o - | FileCheck %s
 
 // Don't include mm_malloc.h, it's system specific.
 #define __MM_MALLOC_H
@@ -8,192 +7,160 @@
 
 __m128 test_mm_macc_ps(__m128 a, __m128 b, __m128 c) {
   // CHECK: @llvm.x86.fma.vfmadd.ps
-  // CHECK-ASM: vfmaddps %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_macc_ps(a, b, c);
 }
 
 __m128d test_mm_macc_pd(__m128d a, __m128d b, __m128d c) {
   // CHECK: @llvm.x86.fma.vfmadd.pd
-  // CHECK-ASM: vfmaddpd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_macc_pd(a, b, c);
 }
 
 __m128 test_mm_macc_ss(__m128 a, __m128 b, __m128 c) {
   // CHECK: @llvm.x86.fma.vfmadd.ss
-  // CHECK-ASM: vfmaddss %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_macc_ss(a, b, c);
 }
 
 __m128d test_mm_macc_sd(__m128d a, __m128d b, __m128d c) {
   // CHECK: @llvm.x86.fma.vfmadd.sd
-  // CHECK-ASM: vfmaddsd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_macc_sd(a, b, c);
 }
 
 __m128 test_mm_msub_ps(__m128 a, __m128 b, __m128 c) {
   // CHECK: @llvm.x86.fma.vfmsub.ps
-  // CHECK-ASM: vfmsubps %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_msub_ps(a, b, c);
 }
 
 __m128d test_mm_msub_pd(__m128d a, __m128d b, __m128d c) {
   // CHECK: @llvm.x86.fma.vfmsub.pd
-  // CHECK-ASM: vfmsubpd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_msub_pd(a, b, c);
 }
 
 __m128 test_mm_msub_ss(__m128 a, __m128 b, __m128 c) {
   // CHECK: @llvm.x86.fma.vfmsub.ss
-  // CHECK-ASM: vfmsubss %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_msub_ss(a, b, c);
 }
 
 __m128d test_mm_msub_sd(__m128d a, __m128d b, __m128d c) {
   // CHECK: @llvm.x86.fma.vfmsub.sd
-  // CHECK-ASM: vfmsubsd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_msub_sd(a, b, c);
 }
 
 __m128 test_mm_nmacc_ps(__m128 a, __m128 b, __m128 c) {
   // CHECK: @llvm.x86.fma.vfnmadd.ps
-  // CHECK-ASM: vfnmaddps %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_nmacc_ps(a, b, c);
 }
 
 __m128d test_mm_nmacc_pd(__m128d a, __m128d b, __m128d c) {
   // CHECK: @llvm.x86.fma.vfnmadd.pd
-  // CHECK-ASM: vfnmaddpd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_nmacc_pd(a, b, c);
 }
 
 __m128 test_mm_nmacc_ss(__m128 a, __m128 b, __m128 c) {
   // CHECK: @llvm.x86.fma.vfnmadd.ss
-  // CHECK-ASM: vfnmaddss %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_nmacc_ss(a, b, c);
 }
 
 __m128d test_mm_nmacc_sd(__m128d a, __m128d b, __m128d c) {
   // CHECK: @llvm.x86.fma.vfnmadd.sd
-  // CHECK-ASM: vfnmaddsd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_nmacc_sd(a, b, c);
 }
 
 __m128 test_mm_nmsub_ps(__m128 a, __m128 b, __m128 c) {
   // CHECK: @llvm.x86.fma.vfnmsub.ps
-  // CHECK-ASM: vfnmsubps %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_nmsub_ps(a, b, c);
 }
 
 __m128d test_mm_nmsub_pd(__m128d a, __m128d b, __m128d c) {
   // CHECK: @llvm.x86.fma.vfnmsub.pd
-  // CHECK-ASM: vfnmsubpd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_nmsub_pd(a, b, c);
 }
 
 __m128 test_mm_nmsub_ss(__m128 a, __m128 b, __m128 c) {
   // CHECK: @llvm.x86.fma.vfnmsub.ss
-  // CHECK-ASM: vfnmsubss %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_nmsub_ss(a, b, c);
 }
 
 __m128d test_mm_nmsub_sd(__m128d a, __m128d b, __m128d c) {
   // CHECK: @llvm.x86.fma.vfnmsub.sd
-  // CHECK-ASM: vfnmsubsd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_nmsub_sd(a, b, c);
 }
 
 __m128 test_mm_maddsub_ps(__m128 a, __m128 b, __m128 c) {
   // CHECK: @llvm.x86.fma.vfmaddsub.ps
-  // CHECK-ASM: vfmaddsubps %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_maddsub_ps(a, b, c);
 }
 
 __m128d test_mm_maddsub_pd(__m128d a, __m128d b, __m128d c) {
   // CHECK: @llvm.x86.fma.vfmaddsub.pd
-  // CHECK-ASM: vfmaddsubpd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_maddsub_pd(a, b, c);
 }
 
 __m128 test_mm_msubadd_ps(__m128 a, __m128 b, __m128 c) {
   // CHECK: @llvm.x86.fm

Re: r246206 - [X86][FMA4] Added debug codegen test for FMA4 intrinsics

2015-08-28 Thread Renato Golin via cfe-commits
Hi Simon,

This one too, reverted in r246320.

cheers,
--renato

On 27 August 2015 at 21:41, Simon Pilgrim via cfe-commits
 wrote:
> Author: rksimon
> Date: Thu Aug 27 15:41:45 2015
> New Revision: 246206
>
> URL: http://llvm.org/viewvc/llvm-project?rev=246206&view=rev
> Log:
> [X86][FMA4] Added debug codegen test for FMA4 intrinsics
>
> Part of PR24590
>
> Modified:
> cfe/trunk/test/CodeGen/fma4-builtins.c
>
> Modified: cfe/trunk/test/CodeGen/fma4-builtins.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/fma4-builtins.c?rev=246206&r1=246205&r2=246206&view=diff
> ==
> --- cfe/trunk/test/CodeGen/fma4-builtins.c (original)
> +++ cfe/trunk/test/CodeGen/fma4-builtins.c Thu Aug 27 15:41:45 2015
> @@ -1,4 +1,5 @@
> -// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +fma4 
> -emit-llvm -o - | FileCheck %s
> +// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +fma4 
> -emit-llvm -o - -Werror | FileCheck %s
> +// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +fma4 
> -S -o - -Werror | FileCheck %s --check-prefix=CHECK-ASM
>
>  // Don't include mm_malloc.h, it's system specific.
>  #define __MM_MALLOC_H
> @@ -7,160 +8,192 @@
>
>  __m128 test_mm_macc_ps(__m128 a, __m128 b, __m128 c) {
>// CHECK: @llvm.x86.fma.vfmadd.ps
> +  // CHECK-ASM: vfmaddps %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_macc_ps(a, b, c);
>  }
>
>  __m128d test_mm_macc_pd(__m128d a, __m128d b, __m128d c) {
>// CHECK: @llvm.x86.fma.vfmadd.pd
> +  // CHECK-ASM: vfmaddpd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_macc_pd(a, b, c);
>  }
>
>  __m128 test_mm_macc_ss(__m128 a, __m128 b, __m128 c) {
>// CHECK: @llvm.x86.fma.vfmadd.ss
> +  // CHECK-ASM: vfmaddss %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_macc_ss(a, b, c);
>  }
>
>  __m128d test_mm_macc_sd(__m128d a, __m128d b, __m128d c) {
>// CHECK: @llvm.x86.fma.vfmadd.sd
> +  // CHECK-ASM: vfmaddsd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_macc_sd(a, b, c);
>  }
>
>  __m128 test_mm_msub_ps(__m128 a, __m128 b, __m128 c) {
>// CHECK: @llvm.x86.fma.vfmsub.ps
> +  // CHECK-ASM: vfmsubps %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_msub_ps(a, b, c);
>  }
>
>  __m128d test_mm_msub_pd(__m128d a, __m128d b, __m128d c) {
>// CHECK: @llvm.x86.fma.vfmsub.pd
> +  // CHECK-ASM: vfmsubpd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_msub_pd(a, b, c);
>  }
>
>  __m128 test_mm_msub_ss(__m128 a, __m128 b, __m128 c) {
>// CHECK: @llvm.x86.fma.vfmsub.ss
> +  // CHECK-ASM: vfmsubss %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_msub_ss(a, b, c);
>  }
>
>  __m128d test_mm_msub_sd(__m128d a, __m128d b, __m128d c) {
>// CHECK: @llvm.x86.fma.vfmsub.sd
> +  // CHECK-ASM: vfmsubsd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_msub_sd(a, b, c);
>  }
>
>  __m128 test_mm_nmacc_ps(__m128 a, __m128 b, __m128 c) {
>// CHECK: @llvm.x86.fma.vfnmadd.ps
> +  // CHECK-ASM: vfnmaddps %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_nmacc_ps(a, b, c);
>  }
>
>  __m128d test_mm_nmacc_pd(__m128d a, __m128d b, __m128d c) {
>// CHECK: @llvm.x86.fma.vfnmadd.pd
> +  // CHECK-ASM: vfnmaddpd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_nmacc_pd(a, b, c);
>  }
>
>  __m128 test_mm_nmacc_ss(__m128 a, __m128 b, __m128 c) {
>// CHECK: @llvm.x86.fma.vfnmadd.ss
> +  // CHECK-ASM: vfnmaddss %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_nmacc_ss(a, b, c);
>  }
>
>  __m128d test_mm_nmacc_sd(__m128d a, __m128d b, __m128d c) {
>// CHECK: @llvm.x86.fma.vfnmadd.sd
> +  // CHECK-ASM: vfnmaddsd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_nmacc_sd(a, b, c);
>  }
>
>  __m128 test_mm_nmsub_ps(__m128 a, __m128 b, __m128 c) {
>// CHECK: @llvm.x86.fma.vfnmsub.ps
> +  // CHECK-ASM: vfnmsubps %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_nmsub_ps(a, b, c);
>  }
>
>  __m128d test_mm_nmsub_pd(__m128d a, __m128d b, __m128d c) {
>// CHECK: @llvm.x86.fma.vfnmsub.pd
> +  // CHECK-ASM: vfnmsubpd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_nmsub_pd(a, b, c);
>  }
>
>  __m128 test_mm_nmsub_ss(__m128 a, __m128 b, __m128 c) {
>// CHECK: @llvm.x86.fma.vfnmsub.ss
> +  // CHECK-ASM: vfnmsubss %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_nmsub_ss(a, b, c);
>  }
>
>  __m128d test_mm_nmsub_sd(__m128d a, __m128d b, __m128d c) {
>// CHECK: @llvm.x86.fma.vfnmsub.sd
> +  // CHECK-ASM: vfnmsubsd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_nmsub_sd(a, b, c);
>  }
>
>  __m128 test_mm_maddsub_ps(__m128 a, __m128 b, __m128 c) {
>// CHECK: @llvm.x86.fma.vfmaddsub.ps
> +  // CHECK-ASM: vfmaddsubps %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_maddsub_ps(a, b, c);
>  }
>
>  __

Re: r246211 - [X86][XOP] Added debug codegen test for XOP intrinsics

2015-08-28 Thread Renato Golin via cfe-commits
And this one, too, in r246321.

--renato

On 27 August 2015 at 22:32, Simon Pilgrim via cfe-commits
 wrote:
> Author: rksimon
> Date: Thu Aug 27 16:32:03 2015
> New Revision: 246211
>
> URL: http://llvm.org/viewvc/llvm-project?rev=246211&view=rev
> Log:
> [X86][XOP] Added debug codegen test for XOP intrinsics
>
> Part of PR24590
>
> Modified:
> cfe/trunk/test/CodeGen/xop-builtins.c
>
> Modified: cfe/trunk/test/CodeGen/xop-builtins.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xop-builtins.c?rev=246211&r1=246210&r2=246211&view=diff
> ==
> --- cfe/trunk/test/CodeGen/xop-builtins.c (original)
> +++ cfe/trunk/test/CodeGen/xop-builtins.c Thu Aug 27 16:32:03 2015
> @@ -1,4 +1,5 @@
> -// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +xop 
> -emit-llvm -o - | FileCheck %s
> +// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +xop 
> -emit-llvm -o - -Werror | FileCheck %s
> +// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +xop 
> -S -o - -Werror | FileCheck %s --check-prefix=CHECK-ASM
>
>  // Don't include mm_malloc.h, it's system specific.
>  #define __MM_MALLOC_H
> @@ -7,320 +8,384 @@
>
>  __m128i test_mm_maccs_epi16(__m128i a, __m128i b, __m128i c) {
>// CHECK: @llvm.x86.xop.vpmacssww
> +  // CHECK-ASM: vpmacssww %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_maccs_epi16(a, b, c);
>  }
>
>  __m128i test_mm_macc_epi16(__m128i a, __m128i b, __m128i c) {
>// CHECK: @llvm.x86.xop.vpmacsww
> +  // CHECK-ASM: vpmacsww %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_macc_epi16(a, b, c);
>  }
>
>  __m128i test_mm_maccsd_epi16(__m128i a, __m128i b, __m128i c) {
>// CHECK: @llvm.x86.xop.vpmacsswd
> +  // CHECK-ASM: vpmacsswd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_maccsd_epi16(a, b, c);
>  }
>
>  __m128i test_mm_maccd_epi16(__m128i a, __m128i b, __m128i c) {
>// CHECK: @llvm.x86.xop.vpmacswd
> +  // CHECK-ASM: vpmacswd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_maccd_epi16(a, b, c);
>  }
>
>  __m128i test_mm_maccs_epi32(__m128i a, __m128i b, __m128i c) {
>// CHECK: @llvm.x86.xop.vpmacssdd
> +  // CHECK-ASM: vpmacssdd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_maccs_epi32(a, b, c);
>  }
>
>  __m128i test_mm_macc_epi32(__m128i a, __m128i b, __m128i c) {
>// CHECK: @llvm.x86.xop.vpmacsdd
> +  // CHECK-ASM: vpmacsdd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_macc_epi32(a, b, c);
>  }
>
>  __m128i test_mm_maccslo_epi32(__m128i a, __m128i b, __m128i c) {
>// CHECK: @llvm.x86.xop.vpmacssdql
> +  // CHECK-ASM: vpmacssdql %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_maccslo_epi32(a, b, c);
>  }
>
>  __m128i test_mm_macclo_epi32(__m128i a, __m128i b, __m128i c) {
>// CHECK: @llvm.x86.xop.vpmacsdql
> +  // CHECK-ASM: vpmacsdql %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_macclo_epi32(a, b, c);
>  }
>
>  __m128i test_mm_maccshi_epi32(__m128i a, __m128i b, __m128i c) {
>// CHECK: @llvm.x86.xop.vpmacssdqh
> +  // CHECK-ASM: vpmacssdqh %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_maccshi_epi32(a, b, c);
>  }
>
>  __m128i test_mm_macchi_epi32(__m128i a, __m128i b, __m128i c) {
>// CHECK: @llvm.x86.xop.vpmacsdqh
> +  // CHECK-ASM: vpmacsdqh %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_macchi_epi32(a, b, c);
>  }
>
>  __m128i test_mm_maddsd_epi16(__m128i a, __m128i b, __m128i c) {
>// CHECK: @llvm.x86.xop.vpmadcsswd
> +  // CHECK-ASM: vpmadcsswd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_maddsd_epi16(a, b, c);
>  }
>
>  __m128i test_mm_maddd_epi16(__m128i a, __m128i b, __m128i c) {
>// CHECK: @llvm.x86.xop.vpmadcswd
> +  // CHECK-ASM: vpmadcswd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
>return _mm_maddd_epi16(a, b, c);
>  }
>
>  __m128i test_mm_haddw_epi8(__m128i a) {
>// CHECK: @llvm.x86.xop.vphaddbw
> +  // CHECK-ASM: vphaddbw %xmm{{.*}}, %xmm{{.*}}
>return _mm_haddw_epi8(a);
>  }
>
>  __m128i test_mm_haddd_epi8(__m128i a) {
>// CHECK: @llvm.x86.xop.vphaddbd
> +  // CHECK-ASM: vphaddbd %xmm{{.*}}, %xmm{{.*}}
>return _mm_haddd_epi8(a);
>  }
>
>  __m128i test_mm_haddq_epi8(__m128i a) {
>// CHECK: @llvm.x86.xop.vphaddbq
> +  // CHECK-ASM: vphaddbq %xmm{{.*}}, %xmm{{.*}}
>return _mm_haddq_epi8(a);
>  }
>
>  __m128i test_mm_haddd_epi16(__m128i a) {
>// CHECK: @llvm.x86.xop.vphaddwd
> +  // CHECK-ASM: vphaddwd %xmm{{.*}}, %xmm{{.*}}
>return _mm_haddd_epi16(a);
>  }
>
>  __m128i test_mm_haddq_epi16(__m128i a) {
>// CHECK: @llvm.x86.xop.vphaddwq
> +  // CHECK-ASM: vphaddwq %xmm{{.*}}, %xmm{{.*}}
>return _mm_haddq_epi16(a);
>  }
>
>  __m128i test_mm_haddq_epi32(__m128i a) {
>// CHECK: @llvm.x86.xop.vphadddq
> +  // CHECK-ASM: vphadddq %xmm{{.*}}, %xmm{{.*}}
>return _mm_haddq_ep

r246321 - Revert "[X86][XOP] Added debug codegen test for XOP intrinsics"

2015-08-28 Thread Renato Golin via cfe-commits
Author: rengolin
Date: Fri Aug 28 14:38:05 2015
New Revision: 246321

URL: http://llvm.org/viewvc/llvm-project?rev=246321&view=rev
Log:
Revert "[X86][XOP] Added debug codegen test for XOP intrinsics"

This reverts commit r246211, as it broke all ARM/AArch64 bots.

Modified:
cfe/trunk/test/CodeGen/xop-builtins.c

Modified: cfe/trunk/test/CodeGen/xop-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xop-builtins.c?rev=246321&r1=246320&r2=246321&view=diff
==
--- cfe/trunk/test/CodeGen/xop-builtins.c (original)
+++ cfe/trunk/test/CodeGen/xop-builtins.c Fri Aug 28 14:38:05 2015
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +xop 
-emit-llvm -o - -Werror | FileCheck %s
-// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +xop -S 
-o - -Werror | FileCheck %s --check-prefix=CHECK-ASM
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +xop 
-emit-llvm -o - | FileCheck %s
 
 // Don't include mm_malloc.h, it's system specific.
 #define __MM_MALLOC_H
@@ -8,384 +7,320 @@
 
 __m128i test_mm_maccs_epi16(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmacssww
-  // CHECK-ASM: vpmacssww %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_maccs_epi16(a, b, c);
 }
 
 __m128i test_mm_macc_epi16(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmacsww
-  // CHECK-ASM: vpmacsww %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_macc_epi16(a, b, c);
 }
 
 __m128i test_mm_maccsd_epi16(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmacsswd
-  // CHECK-ASM: vpmacsswd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_maccsd_epi16(a, b, c);
 }
 
 __m128i test_mm_maccd_epi16(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmacswd
-  // CHECK-ASM: vpmacswd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_maccd_epi16(a, b, c);
 }
 
 __m128i test_mm_maccs_epi32(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmacssdd
-  // CHECK-ASM: vpmacssdd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_maccs_epi32(a, b, c);
 }
 
 __m128i test_mm_macc_epi32(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmacsdd
-  // CHECK-ASM: vpmacsdd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_macc_epi32(a, b, c);
 }
 
 __m128i test_mm_maccslo_epi32(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmacssdql
-  // CHECK-ASM: vpmacssdql %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_maccslo_epi32(a, b, c);
 }
 
 __m128i test_mm_macclo_epi32(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmacsdql
-  // CHECK-ASM: vpmacsdql %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_macclo_epi32(a, b, c);
 }
 
 __m128i test_mm_maccshi_epi32(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmacssdqh
-  // CHECK-ASM: vpmacssdqh %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_maccshi_epi32(a, b, c);
 }
 
 __m128i test_mm_macchi_epi32(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmacsdqh
-  // CHECK-ASM: vpmacsdqh %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_macchi_epi32(a, b, c);
 }
 
 __m128i test_mm_maddsd_epi16(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmadcsswd
-  // CHECK-ASM: vpmadcsswd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_maddsd_epi16(a, b, c);
 }
 
 __m128i test_mm_maddd_epi16(__m128i a, __m128i b, __m128i c) {
   // CHECK: @llvm.x86.xop.vpmadcswd
-  // CHECK-ASM: vpmadcswd %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}, %xmm{{.*}}
   return _mm_maddd_epi16(a, b, c);
 }
 
 __m128i test_mm_haddw_epi8(__m128i a) {
   // CHECK: @llvm.x86.xop.vphaddbw
-  // CHECK-ASM: vphaddbw %xmm{{.*}}, %xmm{{.*}}
   return _mm_haddw_epi8(a);
 }
 
 __m128i test_mm_haddd_epi8(__m128i a) {
   // CHECK: @llvm.x86.xop.vphaddbd
-  // CHECK-ASM: vphaddbd %xmm{{.*}}, %xmm{{.*}}
   return _mm_haddd_epi8(a);
 }
 
 __m128i test_mm_haddq_epi8(__m128i a) {
   // CHECK: @llvm.x86.xop.vphaddbq
-  // CHECK-ASM: vphaddbq %xmm{{.*}}, %xmm{{.*}}
   return _mm_haddq_epi8(a);
 }
 
 __m128i test_mm_haddd_epi16(__m128i a) {
   // CHECK: @llvm.x86.xop.vphaddwd
-  // CHECK-ASM: vphaddwd %xmm{{.*}}, %xmm{{.*}}
   return _mm_haddd_epi16(a);
 }
 
 __m128i test_mm_haddq_epi16(__m128i a) {
   // CHECK: @llvm.x86.xop.vphaddwq
-  // CHECK-ASM: vphaddwq %xmm{{.*}}, %xmm{{.*}}
   return _mm_haddq_epi16(a);
 }
 
 __m128i test_mm_haddq_epi32(__m128i a) {
   // CHECK: @llvm.x86.xop.vphadddq
-  // CHECK-ASM: vphadddq %xmm{{.*}}, %xmm{{.*}}
   return _mm_haddq_epi32(a);
 }
 
 __m128i test_mm_haddw_epu8(__m128i a) {
   // CHECK: @llvm.x86.xop.vphaddubw
-  // CHECK-ASM: vphaddubw %xmm{{.*}}, %xmm{{.*}}
   return _mm_haddw_epu8(a);
 }
 
 __m128i test_mm_haddd_epu8(__m128i a) {
   // CHECK: @llvm.x86.xop.vphaddubd
-  // CHECK-ASM: vphaddubd %xm

r246323 - Revert "[X86][3DNow] Added debug codegen test for 3DNow! intrinsics"

2015-08-28 Thread Renato Golin via cfe-commits
Author: rengolin
Date: Fri Aug 28 14:39:29 2015
New Revision: 246323

URL: http://llvm.org/viewvc/llvm-project?rev=246323&view=rev
Log:
Revert "[X86][3DNow] Added debug codegen test for 3DNow! intrinsics"

This reverts commit r246223, as it broke all ARM/AArch64 bots.

Modified:
cfe/trunk/test/CodeGen/3dnow-builtins.c

Modified: cfe/trunk/test/CodeGen/3dnow-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/3dnow-builtins.c?rev=246323&r1=246322&r2=246323&view=diff
==
--- cfe/trunk/test/CodeGen/3dnow-builtins.c (original)
+++ cfe/trunk/test/CodeGen/3dnow-builtins.c Fri Aug 28 14:39:29 2015
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 %s -O0 -triple=x86_64-unknown-unknown -target-feature 
+3dnow -emit-llvm -o - -Werror | FileCheck %s
-// RUN: %clang_cc1 %s -O0 -triple=x86_64-unknown-unknown -target-feature 
+3dnow -S -o - -Werror | FileCheck %s --check-prefix=CHECK-ASM
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-unknown-unknown -target-feature 
+3dnow -emit-llvm -o - | FileCheck %s
 
 // Don't include mm_malloc.h, it's system specific.
 #define __MM_MALLOC_H
@@ -9,126 +8,108 @@
 __m64 test_m_pavgusb(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pavgusb
   // CHECK: @llvm.x86.3dnow.pavgusb
-  // CHECK-ASM: pavgusb %mm{{.*}}, %mm{{.*}}
   return _m_pavgusb(m1, m2);
 }
 
 __m64 test_m_pf2id(__m64 m) {
   // CHECK-LABEL: define i64 @test_m_pf2id
   // CHECK: @llvm.x86.3dnow.pf2id
-  // CHECK-ASM: pf2id %mm{{.*}}, %mm{{.*}}
   return _m_pf2id(m);
 }
 
 __m64 test_m_pfacc(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfacc
   // CHECK: @llvm.x86.3dnow.pfacc
-  // CHECK-ASM: pfacc %mm{{.*}}, %mm{{.*}}
   return _m_pfacc(m1, m2);
 }
 
 __m64 test_m_pfadd(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfadd
   // CHECK: @llvm.x86.3dnow.pfadd
-  // CHECK-ASM: pfadd %mm{{.*}}, %mm{{.*}}
   return _m_pfadd(m1, m2);
 }
 
 __m64 test_m_pfcmpeq(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfcmpeq
   // CHECK: @llvm.x86.3dnow.pfcmpeq
-  // CHECK-ASM: pfcmpeq %mm{{.*}}, %mm{{.*}}
   return _m_pfcmpeq(m1, m2);
 }
 
 __m64 test_m_pfcmpge(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfcmpge
   // CHECK: @llvm.x86.3dnow.pfcmpge
-  // CHECK-ASM: pfcmpge %mm{{.*}}, %mm{{.*}}
   return _m_pfcmpge(m1, m2);
 }
 
 __m64 test_m_pfcmpgt(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfcmpgt
   // CHECK: @llvm.x86.3dnow.pfcmpgt
-  // CHECK-ASM: pfcmpgt %mm{{.*}}, %mm{{.*}}
   return _m_pfcmpgt(m1, m2);
 }
 
 __m64 test_m_pfmax(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfmax
   // CHECK: @llvm.x86.3dnow.pfmax
-  // CHECK-ASM: pfmax %mm{{.*}}, %mm{{.*}}
   return _m_pfmax(m1, m2);
 }
 
 __m64 test_m_pfmin(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfmin
   // CHECK: @llvm.x86.3dnow.pfmin
-  // CHECK-ASM: pfmin %mm{{.*}}, %mm{{.*}}
   return _m_pfmin(m1, m2);
 }
 
 __m64 test_m_pfmul(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfmul
   // CHECK: @llvm.x86.3dnow.pfmul
-  // CHECK-ASM: pfmul %mm{{.*}}, %mm{{.*}}
   return _m_pfmul(m1, m2);
 }
 
 __m64 test_m_pfrcp(__m64 m) {
   // CHECK-LABEL: define i64 @test_m_pfrcp
   // CHECK: @llvm.x86.3dnow.pfrcp
-  // CHECK-ASM: pfrcp %mm{{.*}}, %mm{{.*}}
   return _m_pfrcp(m);
 }
 
 __m64 test_m_pfrcpit1(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfrcpit1
   // CHECK: @llvm.x86.3dnow.pfrcpit1
-  // CHECK-ASM: pfrcpit1 %mm{{.*}}, %mm{{.*}}
   return _m_pfrcpit1(m1, m2);
 }
 
 __m64 test_m_pfrcpit2(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfrcpit2
   // CHECK: @llvm.x86.3dnow.pfrcpit2
-  // CHECK-ASM: pfrcpit2 %mm{{.*}}, %mm{{.*}}
   return _m_pfrcpit2(m1, m2);
 }
 
 __m64 test_m_pfrsqrt(__m64 m) {
   // CHECK-LABEL: define i64 @test_m_pfrsqrt
   // CHECK: @llvm.x86.3dnow.pfrsqrt
-  // CHECK-ASM: pfrsqrt %mm{{.*}}, %mm{{.*}}
   return _m_pfrsqrt(m);
 }
 
 __m64 test_m_pfrsqrtit1(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfrsqrtit1
   // CHECK: @llvm.x86.3dnow.pfrsqit1
-  // CHECK-ASM: pfrsqit1 %mm{{.*}}, %mm{{.*}}
   return _m_pfrsqrtit1(m1, m2);
 }
 
 __m64 test_m_pfsub(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfsub
   // CHECK: @llvm.x86.3dnow.pfsub
-  // CHECK-ASM: pfsub %mm{{.*}}, %mm{{.*}}
   return _m_pfsub(m1, m2);
 }
 
 __m64 test_m_pfsubr(__m64 m1, __m64 m2) {
   // CHECK-LABEL: define i64 @test_m_pfsubr
   // CHECK: @llvm.x86.3dnow.pfsubr
-  // CHECK-ASM: pfsubr %mm{{.*}}, %mm{{.*}}
   return _m_pfsubr(m1, m2);
 }
 
 __m64 test_m_pi2fd(__m64 m) {
   // CHECK-LABEL: define i64 @test_m_pi2fd
   // CHECK: @llvm.x86.3dnow.pi2fd
-  // CHECK-ASM: pi2fd %mm{{.*}}, %mm{{.*}}
   return _m_pi2fd(m);
 }
 
@@ -141,41 +122,35 @@ __m64 test_m_pmulhrw(__m64 m1, __m64 m2)
 __m64 test_m_pf2iw(__m64 m) {
   // CHECK-LABEL: define i64 @test_m_pf2iw
   // CHECK: @llvm.x86.3dnowa.pf2iw
-  // CHECK-ASM: pf2iw %mm{{.*}}

r246322 - Adding an AST matcher for namespaceAliasDecl.

2015-08-28 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Aug 28 14:39:21 2015
New Revision: 246322

URL: http://llvm.org/viewvc/llvm-project?rev=246322&view=rev
Log:
Adding an AST matcher for namespaceAliasDecl.

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

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=246322&r1=246321&r2=246322&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Fri Aug 28 14:39:21 2015
@@ -285,6 +285,17 @@ Example matches X, S, the anonymous unio
 
 
 
+MatcherDecl>namespaceAliasDeclMatcherNamespaceAliasDecl>...
+Matches a 
declaration of a namespace alias.
+
+Given
+  namespace test {}
+  namespace alias = ::test;
+namespaceAliasDecl()
+  matches "namespace alias" but not "namespace test"
+
+
+
 MatcherDecl>namespaceDeclMatcherNamespaceDecl>...
 Matches a declaration 
of a namespace.
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=246322&r1=246321&r2=246322&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Fri Aug 28 14:39:21 2015
@@ -292,6 +292,18 @@ const internal::VariadicDynCastAllOfMatc
 ///   matches "namespace {}" and "namespace test {}"
 const internal::VariadicDynCastAllOfMatcher namespaceDecl;
 
+/// \brief Matches a declaration of a namespace alias.
+///
+/// Given
+/// \code
+///   namespace test {}
+///   namespace alias = ::test;
+/// \endcode
+/// namespaceAliasDecl()
+///   matches "namespace alias" but not "namespace test"
+const internal::VariadicDynCastAllOfMatcher
+namespaceAliasDecl;
+
 /// \brief Matches C++ class declarations.
 ///
 /// Example matches \c X, \c Z

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=246322&r1=246321&r2=246322&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Fri Aug 28 14:39:21 2015
@@ -288,6 +288,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(memberPointerType);
   REGISTER_MATCHER(methodDecl);
   REGISTER_MATCHER(namedDecl);
+  REGISTER_MATCHER(namespaceAliasDecl);
   REGISTER_MATCHER(namespaceDecl);
   REGISTER_MATCHER(namesType);
   REGISTER_MATCHER(nestedNameSpecifier);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=246322&r1=246321&r2=246322&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Fri Aug 28 14:39:21 2015
@@ -4369,6 +4369,11 @@ TEST(NS, Anonymous) {
   EXPECT_TRUE(matches("namespace {}", namespaceDecl(isAnonymous(;
 }
 
+TEST(NS, Alias) {
+  EXPECT_TRUE(matches("namespace test {} namespace alias = ::test;",
+  namespaceAliasDecl(hasName("alias";
+}
+
 TEST(NNS, MatchesTypes) {
   NestedNameSpecifierMatcher Matcher = nestedNameSpecifier(
 specifiesType(hasDeclaration(recordDecl(hasName("A");


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


r246324 - Updating the AST matcher documentation with a new entry; NFC.

2015-08-28 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Aug 28 14:39:56 2015
New Revision: 246324

URL: http://llvm.org/viewvc/llvm-project?rev=246324&view=rev
Log:
Updating the AST matcher documentation with a new entry; NFC.

Modified:
cfe/trunk/docs/LibASTMatchersReference.html

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=246324&r1=246323&r2=246324&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Fri Aug 28 14:39:56 2015
@@ -1353,6 +1353,20 @@ referenceType() matches the types of b,
 
 
 
+MatcherType>substTemplateTypeParmTypeMatcherSubstTemplateTypeParmType>...
+Matches 
types that represent the result of substituting a type for a
+template type parameter.
+
+Given
+  template 
+  void F(T t) {
+int i = 1 + t;
+  }
+
+substTemplateTypeParmType() matches the type of 't' but not '1'
+
+
+
 MatcherType>templateSpecializationTypeMatcherTemplateSpecializationType>...
 Matches 
template specialization types.
 


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


[clang-tools-extra] r246325 - Updated to make use of the AST matcher instead of a custom matcher; NFC.

2015-08-28 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Aug 28 14:40:30 2015
New Revision: 246325

URL: http://llvm.org/viewvc/llvm-project?rev=246325&view=rev
Log:
Updated to make use of the AST matcher instead of a custom matcher; NFC.

Modified:
clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp?rev=246325&r1=246324&r2=246325&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp Fri Aug 
28 14:40:30 2015
@@ -17,10 +17,6 @@ using namespace clang::ast_matchers;
 namespace clang {
 namespace tidy {
 
-// FIXME: Move this to ASTMatchers.h.
-const ast_matchers::internal::VariadicDynCastAllOfMatcher<
-Decl, NamespaceAliasDecl> namespaceAliasDecl;
-
 void UnusedAliasDeclsCheck::registerMatchers(MatchFinder *Finder) {
   // Only register the matchers for C++11; the functionality currently does not
   // provide any benefit to other languages, despite being benign.


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


Re: r246223 - [X86][3DNow] Added debug codegen test for 3DNow! intrinsics

2015-08-28 Thread Renato Golin via cfe-commits
And finally this one in r246323.

Please, move all those tests to an X86 specific area and check the
AArch64 bots after commit to make sure it passes.

You probably didn't get the email because the bot was broken when you
committed, then all your other commits were breaking a broken bot. :)

cheers,
--renato

On 27 August 2015 at 23:18, Simon Pilgrim via cfe-commits
 wrote:
> Author: rksimon
> Date: Thu Aug 27 17:18:09 2015
> New Revision: 246223
>
> URL: http://llvm.org/viewvc/llvm-project?rev=246223&view=rev
> Log:
> [X86][3DNow] Added debug codegen test for 3DNow! intrinsics
>
> Part of PR24590
>
> Modified:
> cfe/trunk/test/CodeGen/3dnow-builtins.c
>
> Modified: cfe/trunk/test/CodeGen/3dnow-builtins.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/3dnow-builtins.c?rev=246223&r1=246222&r2=246223&view=diff
> ==
> --- cfe/trunk/test/CodeGen/3dnow-builtins.c (original)
> +++ cfe/trunk/test/CodeGen/3dnow-builtins.c Thu Aug 27 17:18:09 2015
> @@ -1,4 +1,5 @@
> -// RUN: %clang_cc1 %s -O3 -triple=x86_64-unknown-unknown -target-feature 
> +3dnow -emit-llvm -o - | FileCheck %s
> +// RUN: %clang_cc1 %s -O0 -triple=x86_64-unknown-unknown -target-feature 
> +3dnow -emit-llvm -o - -Werror | FileCheck %s
> +// RUN: %clang_cc1 %s -O0 -triple=x86_64-unknown-unknown -target-feature 
> +3dnow -S -o - -Werror | FileCheck %s --check-prefix=CHECK-ASM
>
>  // Don't include mm_malloc.h, it's system specific.
>  #define __MM_MALLOC_H
> @@ -8,108 +9,126 @@
>  __m64 test_m_pavgusb(__m64 m1, __m64 m2) {
>// CHECK-LABEL: define i64 @test_m_pavgusb
>// CHECK: @llvm.x86.3dnow.pavgusb
> +  // CHECK-ASM: pavgusb %mm{{.*}}, %mm{{.*}}
>return _m_pavgusb(m1, m2);
>  }
>
>  __m64 test_m_pf2id(__m64 m) {
>// CHECK-LABEL: define i64 @test_m_pf2id
>// CHECK: @llvm.x86.3dnow.pf2id
> +  // CHECK-ASM: pf2id %mm{{.*}}, %mm{{.*}}
>return _m_pf2id(m);
>  }
>
>  __m64 test_m_pfacc(__m64 m1, __m64 m2) {
>// CHECK-LABEL: define i64 @test_m_pfacc
>// CHECK: @llvm.x86.3dnow.pfacc
> +  // CHECK-ASM: pfacc %mm{{.*}}, %mm{{.*}}
>return _m_pfacc(m1, m2);
>  }
>
>  __m64 test_m_pfadd(__m64 m1, __m64 m2) {
>// CHECK-LABEL: define i64 @test_m_pfadd
>// CHECK: @llvm.x86.3dnow.pfadd
> +  // CHECK-ASM: pfadd %mm{{.*}}, %mm{{.*}}
>return _m_pfadd(m1, m2);
>  }
>
>  __m64 test_m_pfcmpeq(__m64 m1, __m64 m2) {
>// CHECK-LABEL: define i64 @test_m_pfcmpeq
>// CHECK: @llvm.x86.3dnow.pfcmpeq
> +  // CHECK-ASM: pfcmpeq %mm{{.*}}, %mm{{.*}}
>return _m_pfcmpeq(m1, m2);
>  }
>
>  __m64 test_m_pfcmpge(__m64 m1, __m64 m2) {
>// CHECK-LABEL: define i64 @test_m_pfcmpge
>// CHECK: @llvm.x86.3dnow.pfcmpge
> +  // CHECK-ASM: pfcmpge %mm{{.*}}, %mm{{.*}}
>return _m_pfcmpge(m1, m2);
>  }
>
>  __m64 test_m_pfcmpgt(__m64 m1, __m64 m2) {
>// CHECK-LABEL: define i64 @test_m_pfcmpgt
>// CHECK: @llvm.x86.3dnow.pfcmpgt
> +  // CHECK-ASM: pfcmpgt %mm{{.*}}, %mm{{.*}}
>return _m_pfcmpgt(m1, m2);
>  }
>
>  __m64 test_m_pfmax(__m64 m1, __m64 m2) {
>// CHECK-LABEL: define i64 @test_m_pfmax
>// CHECK: @llvm.x86.3dnow.pfmax
> +  // CHECK-ASM: pfmax %mm{{.*}}, %mm{{.*}}
>return _m_pfmax(m1, m2);
>  }
>
>  __m64 test_m_pfmin(__m64 m1, __m64 m2) {
>// CHECK-LABEL: define i64 @test_m_pfmin
>// CHECK: @llvm.x86.3dnow.pfmin
> +  // CHECK-ASM: pfmin %mm{{.*}}, %mm{{.*}}
>return _m_pfmin(m1, m2);
>  }
>
>  __m64 test_m_pfmul(__m64 m1, __m64 m2) {
>// CHECK-LABEL: define i64 @test_m_pfmul
>// CHECK: @llvm.x86.3dnow.pfmul
> +  // CHECK-ASM: pfmul %mm{{.*}}, %mm{{.*}}
>return _m_pfmul(m1, m2);
>  }
>
>  __m64 test_m_pfrcp(__m64 m) {
>// CHECK-LABEL: define i64 @test_m_pfrcp
>// CHECK: @llvm.x86.3dnow.pfrcp
> +  // CHECK-ASM: pfrcp %mm{{.*}}, %mm{{.*}}
>return _m_pfrcp(m);
>  }
>
>  __m64 test_m_pfrcpit1(__m64 m1, __m64 m2) {
>// CHECK-LABEL: define i64 @test_m_pfrcpit1
>// CHECK: @llvm.x86.3dnow.pfrcpit1
> +  // CHECK-ASM: pfrcpit1 %mm{{.*}}, %mm{{.*}}
>return _m_pfrcpit1(m1, m2);
>  }
>
>  __m64 test_m_pfrcpit2(__m64 m1, __m64 m2) {
>// CHECK-LABEL: define i64 @test_m_pfrcpit2
>// CHECK: @llvm.x86.3dnow.pfrcpit2
> +  // CHECK-ASM: pfrcpit2 %mm{{.*}}, %mm{{.*}}
>return _m_pfrcpit2(m1, m2);
>  }
>
>  __m64 test_m_pfrsqrt(__m64 m) {
>// CHECK-LABEL: define i64 @test_m_pfrsqrt
>// CHECK: @llvm.x86.3dnow.pfrsqrt
> +  // CHECK-ASM: pfrsqrt %mm{{.*}}, %mm{{.*}}
>return _m_pfrsqrt(m);
>  }
>
>  __m64 test_m_pfrsqrtit1(__m64 m1, __m64 m2) {
>// CHECK-LABEL: define i64 @test_m_pfrsqrtit1
>// CHECK: @llvm.x86.3dnow.pfrsqit1
> +  // CHECK-ASM: pfrsqit1 %mm{{.*}}, %mm{{.*}}
>return _m_pfrsqrtit1(m1, m2);
>  }
>
>  __m64 test_m_pfsub(__m64 m1, __m64 m2) {
>// CHECK-LABEL: define i64 @test_m_pfsub
>// CHECK: @llvm.x86.3dnow.pfsub
> +  // CHECK-ASM: pfsub %mm{{.*}}, %mm{{.*}}
>return _m_pfsub(m1, m2);
>  }
>
>  __m64 test_m_pfsubr(__

Re: [PATCH] D11815: Pass subtarget feature "force-align-stack"

2015-08-28 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 33456.
ahatanak added a comment.

This updated patch changes the handling of driver option 
-mstackrealign/-mno-stackrealign. -mno-stackrealign no longer indicates stack 
realignment should be disallowed and clang no longer attaches function 
attribute "no-realign-stack". The option is only used to cancel -mstackrealign 
on the command line. The cc1 option "-mstackrealign" now means "force stack 
realignment" rather than "allow stack realignment" and causes function 
attribute "stackrealign" to be attached to the functions in the IR.


http://reviews.llvm.org/D11815

Files:
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGCall.cpp
  lib/Driver/Tools.cpp
  test/CodeGen/stackrealign.c
  test/Driver/rewrite-legacy-objc.m
  test/Driver/rewrite-objc.m
  test/Driver/stackrealign.c

Index: test/Driver/stackrealign.c
===
--- test/Driver/stackrealign.c
+++ test/Driver/stackrealign.c
@@ -1,12 +1,6 @@
-// RUN: %clang -### %s 2>&1 | FileCheck %s -check-prefix=NORMAL
-// NORMAL-NOT: -force-align-stack
-// NORMAL: -mstackrealign
+// RUN: %clang -### %s 2>&1 | FileCheck %s -check-prefix=NO-REALIGN
+// RUN: %clang -### -mno-stackrealign -mstackrealign %s 2>&1 | FileCheck %s -check-prefix=REALIGN
+// RUN: %clang -### -mstackrealign -mno-stackrealign %s 2>&1 | FileCheck %s -check-prefix=NO-REALIGN
 
-// RUN: %clang -### -mstackrealign %s 2>&1 | FileCheck %s -check-prefix=MREALIGN
-// MREALIGN: -force-align-stack
-// MREALIGN: -mstackrealign
-
-// RUN: %clang -### -mno-stackrealign %s 2>&1 | \
-// RUN: FileCheck %s -check-prefix=MNOREALIGN
-// MNOREALIGN-NOT: -force-align-stack
-// MNOREALIGN-NOT: -mstackrealign
+// REALIGN: -mstackrealign
+// NO-REALIGN-NOT: -mstackrealign
Index: test/Driver/rewrite-objc.m
===
--- test/Driver/rewrite-objc.m
+++ test/Driver/rewrite-objc.m
@@ -3,4 +3,4 @@
 // TEST0: clang{{.*}}" "-cc1"
 // TEST0: "-rewrite-objc"
 // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
+// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fobjc-runtime=macosx" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
Index: test/Driver/rewrite-legacy-objc.m
===
--- test/Driver/rewrite-legacy-objc.m
+++ test/Driver/rewrite-legacy-objc.m
@@ -3,11 +3,11 @@
 // TEST0: clang{{.*}}" "-cc1"
 // TEST0: "-rewrite-objc"
 // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
+// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
 // TEST0: rewrite-legacy-objc.m"
 // RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.9.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=TEST1 %s
 // RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.6.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=TEST2 %s
-// TEST1: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
-// TEST2: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
+// TEST1: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
+// TEST2: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
Index: test/CodeGen/stackrealign.c
=

Re: r246223 - [X86][3DNow] Added debug codegen test for 3DNow! intrinsics

2015-08-28 Thread Simon Pilgrim via cfe-commits
Thanks for the heads up Renato. I've a candidate fix (it was missing 
REQUIRES: x86-registered-target) and will commit it later and keep an 
extra eye on the non-x86 buildbots.


On 28/08/2015 20:41, Renato Golin wrote:

And finally this one in r246323.

Please, move all those tests to an X86 specific area and check the
AArch64 bots after commit to make sure it passes.

You probably didn't get the email because the bot was broken when you
committed, then all your other commits were breaking a broken bot. :)

cheers,
--renato

On 27 August 2015 at 23:18, Simon Pilgrim via cfe-commits
 wrote:

Author: rksimon
Date: Thu Aug 27 17:18:09 2015
New Revision: 246223

URL: http://llvm.org/viewvc/llvm-project?rev=246223&view=rev
Log:
[X86][3DNow] Added debug codegen test for 3DNow! intrinsics

Part of PR24590

Modified:
 cfe/trunk/test/CodeGen/3dnow-builtins.c

Modified: cfe/trunk/test/CodeGen/3dnow-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/3dnow-builtins.c?rev=246223&r1=246222&r2=246223&view=diff
==
--- cfe/trunk/test/CodeGen/3dnow-builtins.c (original)
+++ cfe/trunk/test/CodeGen/3dnow-builtins.c Thu Aug 27 17:18:09 2015
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -O3 -triple=x86_64-unknown-unknown -target-feature 
+3dnow -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-unknown-unknown -target-feature 
+3dnow -emit-llvm -o - -Werror | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-unknown-unknown -target-feature 
+3dnow -S -o - -Werror | FileCheck %s --check-prefix=CHECK-ASM

  // Don't include mm_malloc.h, it's system specific.
  #define __MM_MALLOC_H
@@ -8,108 +9,126 @@
  __m64 test_m_pavgusb(__m64 m1, __m64 m2) {
// CHECK-LABEL: define i64 @test_m_pavgusb
// CHECK: @llvm.x86.3dnow.pavgusb
+  // CHECK-ASM: pavgusb %mm{{.*}}, %mm{{.*}}
return _m_pavgusb(m1, m2);
  }

  __m64 test_m_pf2id(__m64 m) {
// CHECK-LABEL: define i64 @test_m_pf2id
// CHECK: @llvm.x86.3dnow.pf2id
+  // CHECK-ASM: pf2id %mm{{.*}}, %mm{{.*}}
return _m_pf2id(m);
  }

  __m64 test_m_pfacc(__m64 m1, __m64 m2) {
// CHECK-LABEL: define i64 @test_m_pfacc
// CHECK: @llvm.x86.3dnow.pfacc
+  // CHECK-ASM: pfacc %mm{{.*}}, %mm{{.*}}
return _m_pfacc(m1, m2);
  }

  __m64 test_m_pfadd(__m64 m1, __m64 m2) {
// CHECK-LABEL: define i64 @test_m_pfadd
// CHECK: @llvm.x86.3dnow.pfadd
+  // CHECK-ASM: pfadd %mm{{.*}}, %mm{{.*}}
return _m_pfadd(m1, m2);
  }

  __m64 test_m_pfcmpeq(__m64 m1, __m64 m2) {
// CHECK-LABEL: define i64 @test_m_pfcmpeq
// CHECK: @llvm.x86.3dnow.pfcmpeq
+  // CHECK-ASM: pfcmpeq %mm{{.*}}, %mm{{.*}}
return _m_pfcmpeq(m1, m2);
  }

  __m64 test_m_pfcmpge(__m64 m1, __m64 m2) {
// CHECK-LABEL: define i64 @test_m_pfcmpge
// CHECK: @llvm.x86.3dnow.pfcmpge
+  // CHECK-ASM: pfcmpge %mm{{.*}}, %mm{{.*}}
return _m_pfcmpge(m1, m2);
  }

  __m64 test_m_pfcmpgt(__m64 m1, __m64 m2) {
// CHECK-LABEL: define i64 @test_m_pfcmpgt
// CHECK: @llvm.x86.3dnow.pfcmpgt
+  // CHECK-ASM: pfcmpgt %mm{{.*}}, %mm{{.*}}
return _m_pfcmpgt(m1, m2);
  }

  __m64 test_m_pfmax(__m64 m1, __m64 m2) {
// CHECK-LABEL: define i64 @test_m_pfmax
// CHECK: @llvm.x86.3dnow.pfmax
+  // CHECK-ASM: pfmax %mm{{.*}}, %mm{{.*}}
return _m_pfmax(m1, m2);
  }

  __m64 test_m_pfmin(__m64 m1, __m64 m2) {
// CHECK-LABEL: define i64 @test_m_pfmin
// CHECK: @llvm.x86.3dnow.pfmin
+  // CHECK-ASM: pfmin %mm{{.*}}, %mm{{.*}}
return _m_pfmin(m1, m2);
  }

  __m64 test_m_pfmul(__m64 m1, __m64 m2) {
// CHECK-LABEL: define i64 @test_m_pfmul
// CHECK: @llvm.x86.3dnow.pfmul
+  // CHECK-ASM: pfmul %mm{{.*}}, %mm{{.*}}
return _m_pfmul(m1, m2);
  }

  __m64 test_m_pfrcp(__m64 m) {
// CHECK-LABEL: define i64 @test_m_pfrcp
// CHECK: @llvm.x86.3dnow.pfrcp
+  // CHECK-ASM: pfrcp %mm{{.*}}, %mm{{.*}}
return _m_pfrcp(m);
  }

  __m64 test_m_pfrcpit1(__m64 m1, __m64 m2) {
// CHECK-LABEL: define i64 @test_m_pfrcpit1
// CHECK: @llvm.x86.3dnow.pfrcpit1
+  // CHECK-ASM: pfrcpit1 %mm{{.*}}, %mm{{.*}}
return _m_pfrcpit1(m1, m2);
  }

  __m64 test_m_pfrcpit2(__m64 m1, __m64 m2) {
// CHECK-LABEL: define i64 @test_m_pfrcpit2
// CHECK: @llvm.x86.3dnow.pfrcpit2
+  // CHECK-ASM: pfrcpit2 %mm{{.*}}, %mm{{.*}}
return _m_pfrcpit2(m1, m2);
  }

  __m64 test_m_pfrsqrt(__m64 m) {
// CHECK-LABEL: define i64 @test_m_pfrsqrt
// CHECK: @llvm.x86.3dnow.pfrsqrt
+  // CHECK-ASM: pfrsqrt %mm{{.*}}, %mm{{.*}}
return _m_pfrsqrt(m);
  }

  __m64 test_m_pfrsqrtit1(__m64 m1, __m64 m2) {
// CHECK-LABEL: define i64 @test_m_pfrsqrtit1
// CHECK: @llvm.x86.3dnow.pfrsqit1
+  // CHECK-ASM: pfrsqit1 %mm{{.*}}, %mm{{.*}}
return _m_pfrsqrtit1(m1, m2);
  }

  __m64 test_m_pfsub(__m64 m1, __m64 m2) {
// CHECK-LABEL: define i64 @test_m_pfsub
// CHECK: @llvm.x86.3dnow.pfsub
+  // CHECK-ASM: pfsub %mm{{.*}}, %mm{{.*}}
return _m_pfs

[PATCH] D12445: [Static Analyzer] Remove sinks from nullability checks.

2015-08-28 Thread Gábor Horváth via cfe-commits
xazax.hun created this revision.
xazax.hun added reviewers: zaks.anna, dcoughlin, krememek, jordan_rose.
xazax.hun added a subscriber: cfe-commits.

With this patch a nullability violation no longer generates a sink node, so it 
does not cause any coverage loss for other checkers.
>From now on, it also do not warns, when a nullability precondition is 
>violated. These changes are related, because in order to be able to remove the 
>sinks (without generating duplicate reports for the same symbol), there should 
>be a mechanism to turn off this checker for a path.

http://reviews.llvm.org/D12445

Files:
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  test/Analysis/nullability.mm

Index: test/Analysis/nullability.mm
===
--- test/Analysis/nullability.mm
+++ test/Analysis/nullability.mm
@@ -179,3 +179,44 @@
   takesNullable(p);
   takesNonnull(p);
 }
+
+void onlyReportFirstPreconditionViolationOnPath() {
+  Dummy *p = returnsNullable();
+  takesNonnull(p); // expected-warning {{}}
+  takesNonnull(p); // No warning.
+  // The first warning was not a sink. The analysis expected to continue.
+  int i = 0;
+  i = 5 / i; // expected-warning {{Division by zero}}
+  (void)i;
+}
+
+Dummy *_Nonnull doNotWarnWhenPreconditionIsViolatedInTopFunc(
+Dummy *_Nonnull p) {
+  if (!p) {
+Dummy *ret =
+0; // avoid compiler warning (which is not generated by the analyzer)
+if (getRandom())
+  return ret; // no warning
+else
+  return p; // no warning
+  } else {
+return p;
+  }
+}
+
+Dummy *_Nonnull doNotWarnWhenPreconditionIsViolated(Dummy *_Nonnull p) {
+  if (!p) {
+Dummy *ret =
+0; // avoid compiler warning (which is not generated by the analyzer)
+if (getRandom())
+  return ret; // no warning
+else
+  return p; // no warning
+  } else {
+return p;
+  }
+}
+
+void testPreconditionViolationInInlinedFunction(Dummy *p) {
+  doNotWarnWhenPreconditionIsViolated(p);
+}
Index: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -161,6 +161,11 @@
 const MemRegion *Region;
   };
 
+  // This overload of report bug reports the bugs conditionally. When a
+  // nullability precondition is violated it will not report any bugs at all.
+  void reportBug(ErrorKind Error, ExplodedNode *N, const MemRegion *Region,
+ CheckerContext &C, const Stmt *ValueExpr = nullptr) const;
+
   void reportBug(ErrorKind Error, ExplodedNode *N, const MemRegion *Region,
  BugReporter &BR, const Stmt *ValueExpr = nullptr) const {
 if (!BT)
@@ -220,6 +225,13 @@
 REGISTER_MAP_WITH_PROGRAMSTATE(NullabilityMap, const MemRegion *,
NullabilityState)
 
+// If the nullability preconditions of a function is violated, we should not
+// report that, a postcondition is violated. For this reason once a precondition
+// is not met on a path, this checker will be esentially turned of for the rest
+// of the analysis. We do not want to generate a sink node however, so this
+// check does not reduce the coverage.
+REGISTER_TRAIT_WITH_PROGRAMSTATE(PreconditionViolated, bool)
+
 enum class NullConstraint { IsNull, IsNotNull, Unknown };
 
 static NullConstraint getNullConstraint(DefinedOrUnknownSVal Val,
@@ -302,6 +314,68 @@
   return Nullability::Unspecified;
 }
 
+template 
+static ProgramStateRef
+checkParamsForPreconditionViolation(const ParamVarDeclRange &Params,
+ProgramStateRef State,
+const LocationContext *LocCtxt) {
+  for (const auto *ParamDecl : Params) {
+if (ParamDecl->isParameterPack())
+  break;
+
+if (getNullabilityAnnotation(ParamDecl->getType()) != Nullability::Nonnull)
+  continue;
+
+auto RegVal = State->getLValue(ParamDecl, LocCtxt)
+  .template getAs();
+if (!RegVal)
+  continue;
+
+auto ParamValue = State->getSVal(RegVal->getRegion())
+  .template getAs();
+if (!ParamValue)
+  continue;
+
+if (getNullConstraint(*ParamValue, State) == NullConstraint::IsNull) {
+  return State->set(true);
+}
+  }
+  return State;
+}
+
+static ProgramStateRef
+checkPreconditionViolation(ProgramStateRef State,
+   const LocationContext *LocCtxt) {
+  const Decl *D = LocCtxt->getDecl();
+  if (!D)
+return State;
+
+  if (const auto *BlockD = dyn_cast(D)) {
+return checkParamsForPreconditionViolation(BlockD->parameters(), State,
+   LocCtxt);
+  }
+
+  if (const auto *FuncDecl = dyn_cast(D)) {
+return checkParamsForPreconditionViolation(FuncDecl->parameters(), State,
+   LocCtxt);
+  }
+  return State;
+}
+
+void

Re: r246223 - [X86][3DNow] Added debug codegen test for 3DNow! intrinsics

2015-08-28 Thread Renato Golin via cfe-commits
Thanks!
On 28 Aug 2015 9:33 pm, "Simon Pilgrim"  wrote:

> Thanks for the heads up Renato. I've a candidate fix (it was missing
> REQUIRES: x86-registered-target) and will commit it later and keep an extra
> eye on the non-x86 buildbots.
>
> On 28/08/2015 20:41, Renato Golin wrote:
>
>> And finally this one in r246323.
>>
>> Please, move all those tests to an X86 specific area and check the
>> AArch64 bots after commit to make sure it passes.
>>
>> You probably didn't get the email because the bot was broken when you
>> committed, then all your other commits were breaking a broken bot. :)
>>
>> cheers,
>> --renato
>>
>> On 27 August 2015 at 23:18, Simon Pilgrim via cfe-commits
>>  wrote:
>>
>>> Author: rksimon
>>> Date: Thu Aug 27 17:18:09 2015
>>> New Revision: 246223
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=246223&view=rev
>>> Log:
>>> [X86][3DNow] Added debug codegen test for 3DNow! intrinsics
>>>
>>> Part of PR24590
>>>
>>> Modified:
>>>  cfe/trunk/test/CodeGen/3dnow-builtins.c
>>>
>>> Modified: cfe/trunk/test/CodeGen/3dnow-builtins.c
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/3dnow-builtins.c?rev=246223&r1=246222&r2=246223&view=diff
>>>
>>> ==
>>> --- cfe/trunk/test/CodeGen/3dnow-builtins.c (original)
>>> +++ cfe/trunk/test/CodeGen/3dnow-builtins.c Thu Aug 27 17:18:09 2015
>>> @@ -1,4 +1,5 @@
>>> -// RUN: %clang_cc1 %s -O3 -triple=x86_64-unknown-unknown
>>> -target-feature +3dnow -emit-llvm -o - | FileCheck %s
>>> +// RUN: %clang_cc1 %s -O0 -triple=x86_64-unknown-unknown
>>> -target-feature +3dnow -emit-llvm -o - -Werror | FileCheck %s
>>> +// RUN: %clang_cc1 %s -O0 -triple=x86_64-unknown-unknown
>>> -target-feature +3dnow -S -o - -Werror | FileCheck %s
>>> --check-prefix=CHECK-ASM
>>>
>>>   // Don't include mm_malloc.h, it's system specific.
>>>   #define __MM_MALLOC_H
>>> @@ -8,108 +9,126 @@
>>>   __m64 test_m_pavgusb(__m64 m1, __m64 m2) {
>>> // CHECK-LABEL: define i64 @test_m_pavgusb
>>> // CHECK: @llvm.x86.3dnow.pavgusb
>>> +  // CHECK-ASM: pavgusb %mm{{.*}}, %mm{{.*}}
>>> return _m_pavgusb(m1, m2);
>>>   }
>>>
>>>   __m64 test_m_pf2id(__m64 m) {
>>> // CHECK-LABEL: define i64 @test_m_pf2id
>>> // CHECK: @llvm.x86.3dnow.pf2id
>>> +  // CHECK-ASM: pf2id %mm{{.*}}, %mm{{.*}}
>>> return _m_pf2id(m);
>>>   }
>>>
>>>   __m64 test_m_pfacc(__m64 m1, __m64 m2) {
>>> // CHECK-LABEL: define i64 @test_m_pfacc
>>> // CHECK: @llvm.x86.3dnow.pfacc
>>> +  // CHECK-ASM: pfacc %mm{{.*}}, %mm{{.*}}
>>> return _m_pfacc(m1, m2);
>>>   }
>>>
>>>   __m64 test_m_pfadd(__m64 m1, __m64 m2) {
>>> // CHECK-LABEL: define i64 @test_m_pfadd
>>> // CHECK: @llvm.x86.3dnow.pfadd
>>> +  // CHECK-ASM: pfadd %mm{{.*}}, %mm{{.*}}
>>> return _m_pfadd(m1, m2);
>>>   }
>>>
>>>   __m64 test_m_pfcmpeq(__m64 m1, __m64 m2) {
>>> // CHECK-LABEL: define i64 @test_m_pfcmpeq
>>> // CHECK: @llvm.x86.3dnow.pfcmpeq
>>> +  // CHECK-ASM: pfcmpeq %mm{{.*}}, %mm{{.*}}
>>> return _m_pfcmpeq(m1, m2);
>>>   }
>>>
>>>   __m64 test_m_pfcmpge(__m64 m1, __m64 m2) {
>>> // CHECK-LABEL: define i64 @test_m_pfcmpge
>>> // CHECK: @llvm.x86.3dnow.pfcmpge
>>> +  // CHECK-ASM: pfcmpge %mm{{.*}}, %mm{{.*}}
>>> return _m_pfcmpge(m1, m2);
>>>   }
>>>
>>>   __m64 test_m_pfcmpgt(__m64 m1, __m64 m2) {
>>> // CHECK-LABEL: define i64 @test_m_pfcmpgt
>>> // CHECK: @llvm.x86.3dnow.pfcmpgt
>>> +  // CHECK-ASM: pfcmpgt %mm{{.*}}, %mm{{.*}}
>>> return _m_pfcmpgt(m1, m2);
>>>   }
>>>
>>>   __m64 test_m_pfmax(__m64 m1, __m64 m2) {
>>> // CHECK-LABEL: define i64 @test_m_pfmax
>>> // CHECK: @llvm.x86.3dnow.pfmax
>>> +  // CHECK-ASM: pfmax %mm{{.*}}, %mm{{.*}}
>>> return _m_pfmax(m1, m2);
>>>   }
>>>
>>>   __m64 test_m_pfmin(__m64 m1, __m64 m2) {
>>> // CHECK-LABEL: define i64 @test_m_pfmin
>>> // CHECK: @llvm.x86.3dnow.pfmin
>>> +  // CHECK-ASM: pfmin %mm{{.*}}, %mm{{.*}}
>>> return _m_pfmin(m1, m2);
>>>   }
>>>
>>>   __m64 test_m_pfmul(__m64 m1, __m64 m2) {
>>> // CHECK-LABEL: define i64 @test_m_pfmul
>>> // CHECK: @llvm.x86.3dnow.pfmul
>>> +  // CHECK-ASM: pfmul %mm{{.*}}, %mm{{.*}}
>>> return _m_pfmul(m1, m2);
>>>   }
>>>
>>>   __m64 test_m_pfrcp(__m64 m) {
>>> // CHECK-LABEL: define i64 @test_m_pfrcp
>>> // CHECK: @llvm.x86.3dnow.pfrcp
>>> +  // CHECK-ASM: pfrcp %mm{{.*}}, %mm{{.*}}
>>> return _m_pfrcp(m);
>>>   }
>>>
>>>   __m64 test_m_pfrcpit1(__m64 m1, __m64 m2) {
>>> // CHECK-LABEL: define i64 @test_m_pfrcpit1
>>> // CHECK: @llvm.x86.3dnow.pfrcpit1
>>> +  // CHECK-ASM: pfrcpit1 %mm{{.*}}, %mm{{.*}}
>>> return _m_pfrcpit1(m1, m2);
>>>   }
>>>
>>>   __m64 test_m_pfrcpit2(__m64 m1, __m64 m2) {
>>> // CHECK-LABEL: define i64 @test_m_pfrcpit2
>>> // CHECK: @llvm.x86.3dnow.pfrcpit2
>>> +  // CHECK-ASM: pfrcpit2 %mm{{.*}}, %mm{{.*}}
>>> return _m_pfrcpit2(m1, m2);
>>>   }
>>>
>>>   __m64 test_m_pfrsqrt(__m64 

[PATCH] D12446: [PATCH] Enable clang-tidy misc-static-assert for C11

2015-08-28 Thread Aaron Ballman via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: alexfh, djasper.
aaron.ballman added a subscriber: cfe-commits.

This patch adds support for the C11 _Static_assert macro to clang-tidy's 
misc-static-assert checker. There are a few things I'm not overly satisfied 
with, and welcome suggestions on how to improve, if desired.

1) If  is included, then static_assert() is also fine to use. 
Presumably, in order for the assert() check to trigger,  has to be 
included, but I don't feel particularly comfortable with that assumption. If 
there's a way to access a Preprocessor instance from check(), we can use 
getMacroDefinitionAtLoc() to determine whether static_assert() is defined and a 
valid replacement for assert(). For right now, I'm always using 
_Static_assert() in C11 mode to be on the safe side.
2) My Python skills are rudimentary at best. If there's a better way to update 
check_clang_tidy.py to handle file extensions, that would be great. This change 
is required or else the script fails on .c test cases that check fixes because 
of writing out to a .tmp.cpp file instead of a .tmp.c file conflicts with the 
language options specified on the RUN line.

~Aaron

http://reviews.llvm.org/D12446

Files:
  clang-tidy/misc/StaticAssertCheck.cpp
  test/clang-tidy/check_clang_tidy.py
  test/clang-tidy/misc-static-assert-c11.c
  test/clang-tidy/misc-static-assert-c99.c

Index: test/clang-tidy/misc-static-assert-c99.c
===
--- test/clang-tidy/misc-static-assert-c99.c
+++ test/clang-tidy/misc-static-assert-c99.c
@@ -0,0 +1,24 @@
+// RUN: %python %S/check_clang_tidy.py %s misc-static-assert %t -- -std=c99
+
+void abort() {}
+#ifdef NDEBUG
+#define assert(x) 1
+#else
+#define assert(x)  \
+  if (!(x))\
+  abort()
+#endif
+
+void f(void) {
+  int x = 1;
+  assert(x == 0);
+  // CHECK-FIXES: {{^  }}assert(x == 0);
+
+  #define static_assert(x, msg) _Static_assert(x, msg)
+  assert(11 == 5 + 6);
+  // CHECK-FIXES: {{^  }}assert(11 == 5 + 6);
+  #undef static_assert
+
+  assert(10 == 5 + 5);
+  // CHECK-FIXES: {{^  }}assert(10 == 5 + 5);
+}
Index: test/clang-tidy/misc-static-assert-c11.c
===
--- test/clang-tidy/misc-static-assert-c11.c
+++ test/clang-tidy/misc-static-assert-c11.c
@@ -0,0 +1,26 @@
+// RUN: %python %S/check_clang_tidy.py %s misc-static-assert %t -- -std=c11
+
+void abort() {}
+#ifdef NDEBUG
+#define assert(x) 1
+#else
+#define assert(x)  \
+  if (!(x))\
+  abort()
+#endif
+
+void f(void) {
+  int x = 1;
+  assert(x == 0);
+  // CHECK-FIXES: {{^  }}assert(x == 0);
+
+  #define static_assert(x, msg) _Static_assert(x, msg)
+  assert(11 == 5 + 6);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
+  // CHECK-FIXES: {{^  }}_Static_assert(11 == 5 + 6, "");
+  #undef static_assert
+
+  assert(10 == 5 + 5);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
+  // CHECK-FIXES: {{^  }}_Static_assert(10 == 5 + 5, "");
+}
Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -38,12 +38,16 @@
 sys.exit('Not enough arguments.')
 
   input_file_name = sys.argv[1]
+  extension = '.cpp'
+  if (input_file_name.endswith('.c')):
+extension = '.c'
+
   check_name = sys.argv[2]
-  temp_file_name = sys.argv[3] + '.cpp'
+  temp_file_name = sys.argv[3] + extension
 
   clang_tidy_extra_args = sys.argv[4:]
   if len(clang_tidy_extra_args) == 0:
-clang_tidy_extra_args = ['--', '--std=c++11']
+clang_tidy_extra_args = ['--', '--std=c++11' if extension == '.cpp' else '-std=c99']
 
   with open(input_file_name, 'r') as input_file:
 input_text = input_file.read()
Index: clang-tidy/misc/StaticAssertCheck.cpp
===
--- clang-tidy/misc/StaticAssertCheck.cpp
+++ clang-tidy/misc/StaticAssertCheck.cpp
@@ -27,10 +27,9 @@
 : ClangTidyCheck(Name, Context) {}
 
 void StaticAssertCheck::registerMatchers(MatchFinder *Finder) {
-  // FIXME: I don't see why this checker couldn't also be interesting for
-  // _Static_assert in C11, or static_assert if  has been included, 
-  // but it is currently only enabled for C++11. Investigate.
-  if (getLangOpts().CPlusPlus11) {
+  // This checker only makes sense for languages that have static assertion
+  // capabilities: C++11 and C11.
+  if (getLangOpts().CPlusPlus11 || getLangOpts().C11) {
 auto IsAlwaysFalse = expr(ignoringParenImpCasts(
 expr(anyOf(boolLiteral(equals(false)), integerLiteral(equals(0)),
n

Re: [PATCH] D12022: Refactored dtor sanitizing into EHScopeStack

2015-08-28 Thread Naomi Musgrave via cfe-commits
nmusgrave updated this revision to Diff 33463.
nmusgrave marked an inline comment as done.
nmusgrave added a comment.

- Alias-repressing test case ignores casting of pointers.


http://reviews.llvm.org/D12022

Files:
  lib/CodeGen/CGCXX.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
  test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp

Index: test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp
===
--- /dev/null
+++ test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp
@@ -0,0 +1,30 @@
+// Test -fsanitize-memory-use-after-dtor
+// RUN: %clang_cc1 -fsanitize=memory -O1 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=memory -O2 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+template 
+class Vector {
+public:
+  int size;
+  ~Vector() {}
+};
+
+// Virtual function table for the derived class only contains
+// its own destructors, with no aliasing to base class dtors.
+struct Base {
+  Vector v;
+  int x;
+  Base() { x = 5; }
+  virtual ~Base() {}
+};
+
+struct Derived : public Base {
+  int z;
+  Derived() { z = 10; }
+  ~Derived() {}
+};
+
+Derived d;
+
+// Definition of virtual function table
+// CHECK: @_ZTV7Derived = {{.*}}@_ZN7DerivedD1Ev{{.*}}@_ZN7DerivedD0Ev
Index: test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
===
--- /dev/null
+++ test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -fsanitize=memory -O0 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=memory -O1 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+template 
+class Vector {
+public:
+  int size;
+  ~Vector() {
+size += 1;
+  }
+};
+
+struct Base {
+  int b1;
+  double b2;
+  Base() {
+b1 = 5;
+b2 = 10.989;
+  }
+  virtual ~Base() {}
+};
+
+struct VirtualBase {
+  int vb1;
+  int vb2;
+  VirtualBase() {
+vb1 = 10;
+vb2 = 11;
+  }
+  virtual ~VirtualBase() {}
+};
+
+struct Derived : public Base, public virtual VirtualBase {
+  int d1;
+  Vector v;
+  int d2;
+  Derived() {
+d1 = 10;
+  }
+  ~Derived() {}
+};
+
+Derived d;
+
+// Destruction order:
+// Derived: int, Vector, Base, VirtualBase
+
+// CHECK-LABEL: define {{.*}}ZN7DerivedD1Ev
+// CHECK: call void {{.*}}ZN11VirtualBaseD2Ev
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}ZN7DerivedD0Ev
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}ZN11VirtualBaseD1Ev
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}ZN11VirtualBaseD0Ev
+// CHECK: ret void
+
+// poison 2 ints
+// CHECK-LABEL: define {{.*}}ZN11VirtualBaseD2Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 8)
+// CHECK: ret void
+
+// poison int and double
+// CHECK-LABEL: define {{.*}}ZN4BaseD2Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 16)
+// CHECK: ret void
+
+// poison int, ignore vector, poison int
+// CHECK-LABEL: define {{.*}}ZN7DerivedD2Ev
+// CHECK: call void {{.*}}ZN6VectorIiED1Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4)
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4)
+// CHECK: call void {{.*}}ZN4BaseD2Ev
+// CHECK: ret void
+
+// poison int
+// CHECK-LABEL: define {{.*}}ZN6VectorIiED2Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4)
+// CHECK: ret void
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -1098,6 +1098,13 @@
   /// are emitted lazily.
   void EmitGlobal(GlobalDecl D);
 
+  bool
+  HasTrivialDestructorBody(ASTContext &Context,
+   const CXXRecordDecl *BaseClassDecl,
+   const CXXRecordDecl *MostDerivedClassDecl);
+  bool
+  FieldHasTrivialDestructorBody(ASTContext &Context, const FieldDecl *Field);
+
   bool TryEmitDefinitionAsAlias(GlobalDecl Alias, GlobalDecl Target,
 bool InEveryTU);
   bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D);
Index: lib/CodeGen/CGClass.cpp
===
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1286,11 +1286,7 @@
   CM.finish();
 }
 
-static bool
-FieldHasTrivialDestructorBody(ASTContext &Context, const FieldDecl *Field);
-
-static bool
-HasTrivialDestructorBody(ASTContext &Context,
+bool CodeGenModule::HasTrivialDestructorBody(ASTContext &Context,
  const CXXRecordDecl *BaseClassDecl,
  const CXXRecordDecl *MostDerivedClassDecl)
 {
@@ -1332,10 +1328,12 @@
   return true;
 }
 
-static bool
-FieldHa

Re: Implict casts disappeared from syntactic init list expressions in C++

2015-08-28 Thread Richard Smith via cfe-commits
On Tue, Aug 25, 2015 at 10:27 AM, Abramo Bagnara  wrote:

> Comparing the result of InitListExpr::getSyntacticForm between r224986
> and r245836 I've discovered that integer to char implicit cast for
> integer literal 3 is no longer added to AST for C++ (while it is present
> in C).
>
> This is the source used to test:
>
> char v[10] = { 3 };
>
> Taken in account that:
>
> - implicit cast (and other conversions, constructor calls, etc.) are
> very important also for who need to visit the syntactic form (obvious in
> *both* C and C++)
>
> - to generate that for the syntactic form permit to increase the
> efficiency and the sharing when using designated range extensions (as
> the conversion chain don't need to be replicated for each entry)
>
> I think it is a regression. Am I missing something?


Why do you expect this semantic information to appear in the syntactic form
of the initializer?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12422: Allow TLS vars in dllimport/export functions; only inline dllimport functions when safe (PR24593)

2015-08-28 Thread David Majnemer via cfe-commits
majnemer accepted this revision.
majnemer added a comment.
This revision is now accepted and ready to land.

LGTM

We should probably do something about lambdas, they can't be imported or 
exported but this can be done in a follow up patch.


http://reviews.llvm.org/D12422



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


Re: [PATCH] D12435: [Concepts] Add diagnostic; invalid specifier on function or variable concept declaration

2015-08-28 Thread Nathan Wilson via cfe-commits
nwilson added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1982
@@ -1981,1 +1981,3 @@
   "function concept cannot have exception specification">;
+def err_concept_decl_invalid_sepcifiers : Error<
+  "%select{variable|function}0 concept cannot be declared with "

hubert.reinterpretcast wrote:
> The wording seems unwieldy. There are a number of messages of the form:
> 
> > [ ... ] cannot be declared ''
> 
> Perhaps something along those lines would work here?
> 
> btw, there's a typo in the message identifier.
I'll fix the typo. Thanks. I can change the wording as well; I don't feel too 
strongly about it unless someone has a different opinion. Are you okay with the 
second select?

So, it would be:
"%select{variable|function}0 concept cannot be declared 
%select{thread_local|constexpr|inline}1"


http://reviews.llvm.org/D12435



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


r246338 - Allow TLS vars in dllimport/export functions; only inline dllimport functions when safe (PR24593)

2015-08-28 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Fri Aug 28 16:47:01 2015
New Revision: 246338

URL: http://llvm.org/viewvc/llvm-project?rev=246338&view=rev
Log:
Allow TLS vars in dllimport/export functions; only inline dllimport functions 
when safe (PR24593)

This patch does two things:

1) Don't error about dllimport/export on thread-local static local variables.
   We put those attributes on static locals in dllimport/export functions
   implicitly in case the function gets inlined. Now, for TLS variables this
   is a problem because we can't import such variables, but it's a benign
   problem becase:

2) Make sure we never inline a dllimport function TLS static locals. In fact,
   never inline a dllimport function that references a non-imported function
   or variable (because these are not defined in the importing library). This
   seems to match MSVC's behaviour.

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

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CodeGenCXX/dllimport.cpp
cfe/trunk/test/SemaCXX/dllexport.cpp
cfe/trunk/test/SemaCXX/dllimport.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=246338&r1=246337&r2=246338&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Aug 28 16:47:01 2015
@@ -1448,6 +1448,35 @@ namespace {
   return true;
 }
   };
+
+  struct DLLImportFunctionVisitor
+  : public RecursiveASTVisitor {
+bool SafeToInline = true;
+
+bool VisitVarDecl(VarDecl *VD) {
+  // A thread-local variable cannot be imported.
+  SafeToInline = !VD->getTLSKind();
+  return SafeToInline;
+}
+
+// Make sure we're not referencing non-imported vars or functions.
+bool VisitDeclRefExpr(DeclRefExpr *E) {
+  ValueDecl *VD = E->getDecl();
+  if (isa(VD))
+SafeToInline = VD->hasAttr();
+  else if (VarDecl *V = dyn_cast(VD))
+SafeToInline = !V->hasGlobalStorage() || V->hasAttr();
+  return SafeToInline;
+}
+bool VisitCXXDeleteExpr(CXXDeleteExpr *E) {
+  SafeToInline = E->getOperatorDelete()->hasAttr();
+  return SafeToInline;
+}
+bool VisitCXXNewExpr(CXXNewExpr *E) {
+  SafeToInline = E->getOperatorNew()->hasAttr();
+  return SafeToInline;
+}
+  };
 }
 
 // isTriviallyRecursive - Check if this function calls another
@@ -1478,6 +1507,15 @@ CodeGenModule::shouldEmitFunction(Global
   const auto *F = cast(GD.getDecl());
   if (CodeGenOpts.OptimizationLevel == 0 && !F->hasAttr())
 return false;
+
+  if (F->hasAttr()) {
+// Check whether it would be safe to inline this dllimport function.
+DLLImportFunctionVisitor Visitor;
+Visitor.TraverseFunctionDecl(const_cast(F));
+if (!Visitor.SafeToInline)
+  return false;
+  }
+
   // PR9614. Avoid cases where the source code is lying to us. An available
   // externally function should have an equivalent function somewhere else,
   // but a function that calls itself is clearly not equivalent to the real

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=246338&r1=246337&r2=246338&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Aug 28 16:47:01 2015
@@ -9967,9 +9967,17 @@ Sema::FinalizeDeclaration(Decl *ThisDecl
   // dllimport/dllexport variables cannot be thread local, their TLS index
   // isn't exported with the variable.
   if (DLLAttr && VD->getTLSKind()) {
-Diag(VD->getLocation(), diag::err_attribute_dll_thread_local) << VD
-  << DLLAttr;
-VD->setInvalidDecl();
+FunctionDecl *F = dyn_cast(VD->getDeclContext());
+if (F && getDLLAttr(F)) {
+  assert(VD->isStaticLocal());
+  // But if this is a static local in a dlimport/dllexport function, the
+  // function will never be inlined, which means the var would never be
+  // imported, so having it marked import/export is safe.
+} else {
+  Diag(VD->getLocation(), diag::err_attribute_dll_thread_local) << VD
+<< DLLAttr;
+  VD->setInvalidDecl();
+}
   }
 
   if (UsedAttr *Attr = VD->getAttr()) {

Modified: cfe/trunk/test/CodeGenCXX/dllimport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllimport.cpp?rev=246338&r1=246337&r2=246338&view=diff
==
--- cfe/trunk/test/CodeGenCXX/dllimport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllimport.cpp Fri Aug 28 16:47:01 2015
@@ -86,7 +86,7 @@ USEVAR(GlobalRedecl3)
 namespace ns { __declspec(dllimpo

Re: [PATCH] D12422: Allow TLS vars in dllimport/export functions; only inline dllimport functions when safe (PR24593)

2015-08-28 Thread Hans Wennborg via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL246338: Allow TLS vars in dllimport/export functions; only 
inline dllimport functions… (authored by hans).

Changed prior to commit:
  http://reviews.llvm.org/D12422?vs=33388&id=33471#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12422

Files:
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/CodeGenCXX/dllimport.cpp
  cfe/trunk/test/SemaCXX/dllexport.cpp
  cfe/trunk/test/SemaCXX/dllimport.cpp

Index: cfe/trunk/test/SemaCXX/dllimport.cpp
===
--- cfe/trunk/test/SemaCXX/dllimport.cpp
+++ cfe/trunk/test/SemaCXX/dllimport.cpp
@@ -93,6 +93,18 @@
 
 // Thread local variables are invalid.
 __declspec(dllimport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllimport'}}
+inline void InlineWithThreadLocal() {
+  static __declspec(dllimport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllimport'}}
+}
+
+// But if they're in a dllimported function, it's OK because we will not inline the function.
+// This doesn't work on MinGW, because there, dllimport on the inline function is ignored.
+#ifndef GNU
+inline void __declspec(dllimport) ImportedInlineWithThreadLocal() {
+  static __declspec(dllimport) __thread int OK1; // no-error
+  static __thread int OK2; // no-error
+}
+#endif
 
 // Import in local scope.
 __declspec(dllimport) float LocalRedecl1; // expected-note{{previous declaration is here}}
Index: cfe/trunk/test/SemaCXX/dllexport.cpp
===
--- cfe/trunk/test/SemaCXX/dllexport.cpp
+++ cfe/trunk/test/SemaCXX/dllexport.cpp
@@ -71,6 +71,15 @@
 
 // Thread local variables are invalid.
 __declspec(dllexport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllexport'}}
+inline void InlineWithThreadLocal() {
+  static __declspec(dllexport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllexport'}}
+}
+
+// But if they're in a dllexport function, it's ok, because they will never get imported.
+inline void __declspec(dllexport) ExportedInlineWithThreadLocal() {
+  static __declspec(dllexport) __thread int OK1; // no-error
+  static __thread int OK2; // no-error
+}
 
 // Export in local scope.
 void functionScope() {
Index: cfe/trunk/test/CodeGenCXX/dllimport.cpp
===
--- cfe/trunk/test/CodeGenCXX/dllimport.cpp
+++ cfe/trunk/test/CodeGenCXX/dllimport.cpp
@@ -86,7 +86,7 @@
 namespace ns { __declspec(dllimport) int ExternalGlobal; }
 USEVAR(ns::ExternalGlobal)
 
-int f();
+int __declspec(dllimport) f();
 // MO1-DAG: @"\01?x@?1??inlineStaticLocalsFunc@@YAHXZ@4HA" = available_externally dllimport global i32 0
 // MO1-DAG: @"\01??_B?1??inlineStaticLocalsFunc@@YAHXZ@51" = available_externally dllimport global i32 0
 inline int __declspec(dllimport) inlineStaticLocalsFunc() {
@@ -314,6 +314,46 @@
 namespace ns { __declspec(dllimport) void externalFunc(); }
 USE(ns::externalFunc)
 
+// A dllimport function referencing non-imported vars or functions must not be available_externally.
+__declspec(dllimport) int ImportedVar;
+int NonImportedVar;
+__declspec(dllimport) int ImportedFunc();
+int NonImportedFunc();
+__declspec(dllimport) inline int ReferencingImportedVar() { return ImportedVar; }
+// MO1-DAG: define available_externally dllimport i32 @"\01?ReferencingImportedVar@@YAHXZ"
+__declspec(dllimport) inline int ReferencingNonImportedVar() { return NonImportedVar; }
+// MO1-DAG: declare dllimport i32 @"\01?ReferencingNonImportedVar@@YAHXZ"()
+__declspec(dllimport) inline int ReferencingImportedFunc() { return ImportedFunc(); }
+// MO1-DAG: define available_externally dllimport i32 @"\01?ReferencingImportedFunc@@YAHXZ"
+__declspec(dllimport) inline int ReferencingNonImportedFunc() { return NonImportedFunc(); }
+// MO1-DAG: declare dllimport i32 @"\01?ReferencingNonImportedFunc@@YAHXZ"()
+USE(ReferencingImportedVar)
+USE(ReferencingNonImportedVar)
+USE(ReferencingImportedFunc)
+USE(ReferencingNonImportedFunc)
+// References to operator new and delete count too, despite not being DeclRefExprs.
+__declspec(dllimport) inline int *ReferencingNonImportedNew() { return new int[2]; }
+// MO1-DAG: declare dllimport i32* @"\01?ReferencingNonImportedNew@@YAPAHXZ"
+__declspec(dllimport) inline int *ReferencingNonImportedDelete() { delete (int*)nullptr; }
+// MO1-DAG: declare dllimport i32* @"\01?ReferencingNonImportedDelete@@YAPAHXZ"
+USE(ReferencingNonImportedNew)
+USE(ReferencingNonImportedDelete)
+__declspec(dllimport) void* operator new[](__SIZE_TYPE__);
+__declspec(dllimport) void operator delete(void*);
+__declspec(dllimport) inline int *ReferencingImportedNew() 

Re: [PATCH] D11297: PR17829: Functions declared extern "C" with a name matching a mangled C++ function are allowed

2015-08-28 Thread John McCall via cfe-commits
rjmccall added a comment.

Yes, please make it an error.  And the obvious test changes are fine. :)


http://reviews.llvm.org/D11297



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


Re: [PATCH] D12435: [Concepts] Add diagnostic; invalid specifier on function or variable concept declaration

2015-08-28 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1982
@@ -1981,1 +1981,3 @@
   "function concept cannot have exception specification">;
+def err_concept_decl_invalid_sepcifiers : Error<
+  "%select{variable|function}0 concept cannot be declared with "

nwilson wrote:
> hubert.reinterpretcast wrote:
> > The wording seems unwieldy. There are a number of messages of the form:
> > 
> > > [ ... ] cannot be declared ''
> > 
> > Perhaps something along those lines would work here?
> > 
> > btw, there's a typo in the message identifier.
> I'll fix the typo. Thanks. I can change the wording as well; I don't feel too 
> strongly about it unless someone has a different opinion. Are you okay with 
> the second select?
> 
> So, it would be:
> "%select{variable|function}0 concept cannot be declared 
> %select{thread_local|constexpr|inline}1"
Not sure if other people have an opinion, but the single quotes around, e.g., 
'inline' would fit. For 'friend', the quoted version is terser (without quotes, 
it would be awkward). On that note, if we plan to use this message for the 
"friend" case, let's add it in the same order as the quoted portion of the TS 
now.


http://reviews.llvm.org/D12435



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


Re: [PATCH] D11832: [Patch] [Analyzer] false positive: Potential leak connected with memcpy (PR 22954)

2015-08-28 Thread Devin Coughlin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL246345: [analyzer] When memcpy'ing into a fixed-size array, 
do not invalidate entire… (authored by dcoughlin).

Changed prior to commit:
  http://reviews.llvm.org/D11832?vs=33402&id=33478#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11832

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
  cfe/trunk/test/Analysis/pr22954.c

Index: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -710,8 +710,7 @@
   }
 
   bool AddToWorkList(const MemRegion *R) {
-const MemRegion *BaseR = R->getBaseRegion();
-return AddToWorkList(WorkListElement(BaseR), getCluster(BaseR));
+return static_cast(this)->AddToWorkList(R);
   }
 
   void RunWorkList() {
@@ -956,9 +955,20 @@
 
   void VisitCluster(const MemRegion *baseR, const ClusterBindings *C);
   void VisitBinding(SVal V);
+
+  using ClusterAnalysis::AddToWorkList;
+
+  bool AddToWorkList(const MemRegion *R);
 };
 }
 
+bool invalidateRegionsWorker::AddToWorkList(const MemRegion *R) {
+  bool doNotInvalidateSuperRegion = ITraits.hasTrait(
+  R, RegionAndSymbolInvalidationTraits::TK_DoNotInvalidateSuperRegion);
+  const MemRegion *BaseR = doNotInvalidateSuperRegion ? R : R->getBaseRegion();
+  return AddToWorkList(WorkListElement(BaseR), getCluster(BaseR));
+}
+
 void invalidateRegionsWorker::VisitBinding(SVal V) {
   // A symbol?  Mark it touched by the invalidation.
   if (SymbolRef Sym = V.getAsSymbol())
@@ -1071,6 +1081,66 @@
   }
 
   if (const ArrayType *AT = Ctx.getAsArrayType(T)) {
+bool doNotInvalidateSuperRegion = ITraits.hasTrait(
+baseR,
+RegionAndSymbolInvalidationTraits::TK_DoNotInvalidateSuperRegion);
+
+if (doNotInvalidateSuperRegion) {
+  // We are not doing blank invalidation of the whole array region so we
+  // have to manually invalidate each elements.
+  Optional NumElements;
+
+  // Compute lower and upper offsets for region within array.
+  if (const ConstantArrayType *CAT = dyn_cast(AT))
+NumElements = CAT->getSize().getZExtValue();
+  if (!NumElements) // We are not dealing with a constant size array
+goto conjure_default;
+  QualType ElementTy = AT->getElementType();
+  uint64_t ElemSize = Ctx.getTypeSize(ElementTy);
+  const RegionOffset &RO = baseR->getAsOffset();
+  const MemRegion *SuperR = baseR->getBaseRegion();
+  if (RO.hasSymbolicOffset()) {
+// If base region has a symbolic offset,
+// we revert to invalidating the super region.
+if (SuperR)
+  AddToWorkList(SuperR);
+goto conjure_default;
+  }
+  assert(RO.getOffset() >= 0 && "Offset should not be negative");
+  uint64_t LowerOffset = RO.getOffset();
+  uint64_t UpperOffset = LowerOffset + *NumElements * ElemSize;
+
+  // Invalidate regions which are within array boundaries,
+  // or have a symbolic offset.
+  if (!SuperR)
+goto conjure_default;
+
+  const ClusterBindings *C = B.lookup(SuperR);
+  if (!C)
+goto conjure_default;
+
+  for (ClusterBindings::iterator I = C->begin(), E = C->end(); I != E;
+   ++I) {
+const BindingKey &BK = I.getKey();
+Optional ROffset =
+BK.hasSymbolicOffset() ? Optional() : BK.getOffset();
+// Check offset is not symbolic and within array's boundaries.
+// Handles arrays of 0 elements and of 0-sized elements as well.
+if (!ROffset ||
+(ROffset &&
+ ((*ROffset >= LowerOffset && *ROffset < UpperOffset) ||
+  (LowerOffset == UpperOffset && *ROffset == LowerOffset {
+  B = B.removeBinding(I.getKey());
+  // Bound symbolic regions need to be invalidated for dead symbol
+  // detection.
+  SVal V = I.getData();
+  const MemRegion *R = V.getAsRegion();
+  if (R && isa(R))
+VisitBinding(V);
+}
+  }
+}
+  conjure_default:
   // Set the default value of the array to conjured symbol.
 DefinedOrUnknownSVal V =
 svalBuilder.conjureSymbolVal(baseR, Ex, LCtx,
@@ -2187,11 +2257,20 @@
   void VisitCluster(const MemRegion *baseR, const ClusterBindings *C);
   using ClusterAnalysis::VisitCluster;
 
+  using ClusterAnalysis::AddToWorkList;
+
+  bool AddToWorkList(const MemRegion *R);
+
   bool UpdatePostponed();
   void VisitBinding(SVal V);
 };
 }
 
+bool removeDeadBindingsWorker::AddToWorkList(const MemRegion *R) {
+  const MemRegion *BaseR = R->getBaseRegion();
+  return AddToWorkList(WorkListElement(BaseR), getCluster(BaseR));
+}
+
 void removeDeadBindingsWorker::VisitAddedToCluster(co

r246345 - [analyzer] When memcpy'ing into a fixed-size array, do not invalidate entire region.

2015-08-28 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Fri Aug 28 17:26:05 2015
New Revision: 246345

URL: http://llvm.org/viewvc/llvm-project?rev=246345&view=rev
Log:
[analyzer] When memcpy'ing into a fixed-size array, do not invalidate entire 
region.

Change the analyzer's modeling of memcpy to be more precise when copying into 
fixed-size
array fields. With this change, instead of invalidating the entire containing 
region the
analyzer now invalidates only offsets for the array itself when it can show 
that the
memcpy stays within the bounds of the array.

This addresses false positive memory leak warnings of the kind reported by
krzysztof in https://llvm.org/bugs/show_bug.cgi?id=22954

A patch by Pierre Gousseau!

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

Added:
cfe/trunk/test/Analysis/pr22954.c
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=246345&r1=246344&r2=246345&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Fri 
Aug 28 17:26:05 2015
@@ -1333,7 +1333,9 @@ public:
 /// Tells that a region's contents is not changed.
 TK_PreserveContents = 0x1,
 /// Suppress pointer-escaping of a region.
-TK_SuppressEscape = 0x2
+TK_SuppressEscape = 0x2,
+// Do not invalidate super region.
+TK_DoNotInvalidateSuperRegion = 0x4
 
 // Do not forget to extend StorageTypeForKinds if number of traits exceed 
 // the number of bits StorageTypeForKinds can store.

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp?rev=246345&r1=246344&r2=246345&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp Fri Aug 28 
17:26:05 2015
@@ -145,7 +145,8 @@ public:
   static ProgramStateRef InvalidateBuffer(CheckerContext &C,
   ProgramStateRef state,
   const Expr *Ex, SVal V,
-  bool IsSourceBuffer);
+  bool IsSourceBuffer,
+  const Expr *Size);
 
   static bool SummarizeRegion(raw_ostream &os, ASTContext &Ctx,
   const MemRegion *MR);
@@ -193,6 +194,14 @@ public:
 ProgramStateRef state,
 NonLoc left,
 NonLoc right) const;
+
+  // Return true if destination buffer of copy function is in bound.
+  // Expects SVal of Size to be positive and unsigned.
+  // Expects SVal of FirstBuf to be a FieldRegion.
+  static bool IsFirstBufInBound(CheckerContext &C,
+ProgramStateRef state,
+const Expr *FirstBuf,
+const Expr *Size);
 };
 
 } //end anonymous namespace
@@ -814,10 +823,68 @@ const StringLiteral *CStringChecker::get
   return strRegion->getStringLiteral();
 }
 
+bool CStringChecker::IsFirstBufInBound(CheckerContext &C,
+   ProgramStateRef state,
+   const Expr *FirstBuf,
+   const Expr *Size) {
+
+  // Originally copied from CheckBufferAccess and CheckLocation.
+  SValBuilder &svalBuilder = C.getSValBuilder();
+  ASTContext &Ctx = svalBuilder.getContext();
+  const LocationContext *LCtx = C.getLocationContext();
+
+  QualType sizeTy = Size->getType();
+  QualType PtrTy = Ctx.getPointerType(Ctx.CharTy);
+  SVal BufVal = state->getSVal(FirstBuf, LCtx);
+
+  SVal LengthVal = state->getSVal(Size, LCtx);
+  // Cast is safe as the size argument to copy functions are of integral type.
+  NonLoc Length = LengthVal.castAs();
+
+  // Compute the offset of the last element to be accessed: size-1.
+  NonLoc One = svalBuilder.makeIntVal(1, sizeTy).castAs();
+  NonLoc LastOffset =
+  svalBuilder.evalBinOpNN(state, BO_Sub, Length, One, sizeTy)
+  .castAs();
+
+  // Check that the first buffer is sufficiently long.
+  SVal BufStart = svalBuilder.evalCast(BufVal, PtrTy, FirstBuf->getType());
+  // Cast is safe as caller checks BufVal is a MemRegionVal.
+  Loc BufLoc = BufStart.castAs();
+
+  SVal BufEnd =
+  svalBuilder.evalBinOpLN(state, BO_Add, B

r246346 - Fold TargetInfo::handleUserFeatures into TargetInfo::initFeatureMap.

2015-08-28 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Fri Aug 28 17:32:01 2015
New Revision: 246346

URL: http://llvm.org/viewvc/llvm-project?rev=246346&view=rev
Log:
Fold TargetInfo::handleUserFeatures into TargetInfo::initFeatureMap.

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=246346&r1=246345&r2=246346&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Fri Aug 28 17:32:01 2015
@@ -746,8 +746,14 @@ public:
   /// \return False on error (invalid features).
   virtual bool initFeatureMap(llvm::StringMap &Features,
   DiagnosticsEngine &Diags, StringRef CPU,
-  std::vector &FAW) const {
-return handleUserFeatures(Features, FAW, Diags);
+  std::vector &FeatureVec) const {
+for (const auto &F : FeatureVec) {
+  const char *Name = F.c_str();
+  // Apply the feature via the target.
+  bool Enabled = Name[0] == '+';
+  setFeatureEnabled(Features, Name + 1, Enabled);
+}
+return true;
   }
 
   /// \brief Get the ABI currently in use.
@@ -787,22 +793,6 @@ public:
 Features[Name] = Enabled;
   }
 
-  /// \brief Add user defined features to the feature set while
-  /// possibly diagnosing incompatibilities.
-  ///
-  /// \return False on error.
-  virtual bool handleUserFeatures(llvm::StringMap &Features,
- std::vector &UserFeatures,
- DiagnosticsEngine &Diags) const {
-for (const auto &F : UserFeatures) {
-  const char *Name = F.c_str();
-  // Apply the feature via the target.
-  bool Enabled = Name[0] == '+';
-  setFeatureEnabled(Features, Name + 1, Enabled);
-}
-return true;
-  }
-
   /// \brief Perform initialization based on the user configured
   /// set of features (e.g., +sse4).
   ///

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=246346&r1=246345&r2=246346&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Aug 28 17:32:01 2015
@@ -865,13 +865,10 @@ public:
 
   bool initFeatureMap(llvm::StringMap &Features, DiagnosticsEngine 
&Diags,
   StringRef CPU,
-  std::vector &FAW) const override;
+  std::vector &FeaturesVec) const override;
 
   bool handleTargetFeatures(std::vector &Features,
 DiagnosticsEngine &Diags) override;
-  bool handleUserFeatures(llvm::StringMap &Features,
-  std::vector &UserFeatures,
-  DiagnosticsEngine &Diags) const override;
   bool hasFeature(StringRef Feature) const override;
   void setFeatureEnabled(llvm::StringMap &Features, StringRef Name,
  bool Enabled) const override;
@@ -1050,30 +1047,6 @@ bool PPCTargetInfo::handleTargetFeatures
   return true;
 }
 
-bool PPCTargetInfo::handleUserFeatures(llvm::StringMap &Features,
-   std::vector &FAW,
-   DiagnosticsEngine &Diags) const {
-  // Handle explicit options being passed to the compiler here: if we've
-  // explicitly turned off vsx and turned on power8-vector or direct-move then
-  // go ahead and error since the customer has expressed a somewhat 
incompatible
-  // set of options.
-  if (std::find(FAW.begin(), FAW.end(), "-vsx") != FAW.end()) {
-if (std::find(FAW.begin(), FAW.end(), "+power8-vector") != FAW.end()) {
-  Diags.Report(diag::err_opt_not_valid_with_opt) << "-mpower8-vector"
- << "-mno-vsx";
-  return false;
-}
-
-if (std::find(FAW.begin(), FAW.end(), "+direct-move") != FAW.end()) {
-  Diags.Report(diag::err_opt_not_valid_with_opt) << "-mdirect-move"
- << "-mno-vsx";
-  return false;
-}
-  }
-
-  return TargetInfo::handleUserFeatures(Features, FAW, Diags);
-}
-
 /// PPCTargetInfo::getTargetDefines - Return a set of the PowerPC-specific
 /// #defines that are not tied to a specific subtarget.
 void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
@@ -1253,9 +1226,9 @@ void PPCTargetInfo::getTargetDefines(con
   //   __NO_FPRS__
 }
 
-bool PPCTargetInfo::initFeatureMap(llvm::StringMap &Features,
-   DiagnosticsEngine &Diags, StringRef CPU,
-   std::vector &FAW) const {
+bool PPCTargetInfo::initFeatureMap(
+llvm::StringMap &Features, DiagnosticsEngine &Diags, StringRef CPU,
+s

r246347 - PR24612: Don't bail out of checking a constexpr function before checking

2015-08-28 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Aug 28 17:33:53 2015
New Revision: 246347

URL: http://llvm.org/viewvc/llvm-project?rev=246347&view=rev
Log:
PR24612: Don't bail out of checking a constexpr function before checking
whether it can ever produce a constant expression in the case where it has a
void return type and no return statements.

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=246347&r1=246346&r2=246347&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Aug 28 17:33:53 2015
@@ -1230,9 +1230,9 @@ bool Sema::CheckConstexprFunctionBody(co
   Diag(Dcl->getLocation(),
OK ? diag::warn_cxx11_compat_constexpr_body_no_return
   : diag::err_constexpr_body_no_return);
-  return OK;
-}
-if (ReturnStmts.size() > 1) {
+  if (!OK)
+return false;
+} else if (ReturnStmts.size() > 1) {
   Diag(ReturnStmts.back(),
getLangOpts().CPlusPlus14
  ? diag::warn_cxx11_compat_constexpr_body_multiple_return

Modified: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp?rev=246347&r1=246346&r2=246347&view=diff
==
--- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp Fri Aug 28 
17:33:53 2015
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -triple x86_64-unknown-unknown -verify 
-std=c++11 -fcxx-exceptions %s
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-unknown-unknown -verify 
-std=c++14 -fcxx-exceptions %s
 // RUN: %clang_cc1 -fsyntax-only -triple x86_64-unknown-unknown -std=c++11 
-fcxx-exceptions -Wno-invalid-constexpr %s -DNO_INVALID_CONSTEXPR
 
 namespace StdExample {
@@ -102,7 +103,10 @@ X x = cmin(X(), X()); // ok, not constex
 template
 struct Y {
   constexpr Y() {}
-  constexpr int get() { return T(); } // expected-warning {{C++14}}
+  constexpr int get() { return T(); }
+#if __cplusplus < 201402L
+  // expected-warning@-2 {{C++14}}
+#endif
 };
 struct Z { operator int(); };
 
@@ -118,7 +122,7 @@ namespace PR14550 {
   // marks some functions as constexpr which use builtins which we don't
   // support constant folding). Ensure that we don't mark those functions
   // as invalid after suppressing the diagnostic.
-# 122 "p5.cpp" 1 3
+# 126 "p5.cpp" 1 3
   int n;
   struct A {
 static constexpr int f() { return n; }
@@ -126,7 +130,11 @@ namespace PR14550 {
   template struct B {
 B() { g(T::f()); } // expected-error {{undeclared identifier 'g'}}
   };
-# 130 "p5.cpp" 2
+# 134 "p5.cpp" 2
   template class B; // expected-note {{here}}
 }
 #endif
+
+#if __cplusplus >= 201402L
+constexpr void f() { throw; } // expected-error {{never produces}} 
expected-note {{subexpression}}
+#endif


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


LLVM buildmaster will be restarted tonight

2015-08-28 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be restarted after 6 PM Pacific time today.

Thanks

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


[PATCH] D12453: [CUDA] Allow function overloads based on host/device attributes.

2015-08-28 Thread Artem Belevich via cfe-commits
tra created this revision.
tra added reviewers: eliben, rsmith, jholewinski, echristo, jingyue.
tra added a subscriber: cfe-commits.

The patch makes it possible to parse CUDA files that contain host/device 
functions with identical signatures, but different attributes  without having 
to physically split source into host-only and device-only parts.

This change is needed in order to parse CUDA header files that have a lot of 
name clashes with standard include files.

Gory details are in design doc here: [[ https://goo.gl/EXnymm | 
https://goo.gl/EXnymm ]]
Feel free to leave comments there or in this review thread.

This feature is controlled with CC1 option -fcuda-target-overloads and is 
disabled by default.

Includes the changes to add appropriate host/device attribute to 
target-specific builtins that were reviewed in http://reviews.llvm.org/D12122

http://reviews.llvm.org/D12453

Files:
  include/clang/Basic/Builtins.h
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  include/clang/Sema/Sema.h
  lib/AST/ItaniumMangle.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaOverload.cpp
  test/CodeGenCUDA/function-overload.cu
  test/SemaCUDA/builtins.cu
  test/SemaCUDA/function-overload.cu
  test/SemaCUDA/implicit-intrinsic.cu

Index: test/SemaCUDA/implicit-intrinsic.cu
===
--- test/SemaCUDA/implicit-intrinsic.cu
+++ test/SemaCUDA/implicit-intrinsic.cu
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -std=gnu++11 -triple nvptx64-unknown-unknown -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -fcuda-is-device -fsyntax-only -verify %s
 
 #include "Inputs/cuda.h"
 
 // expected-no-diagnostics
 __device__ void __threadfence_system() {
-  // This shouldn't produce an error, since __nvvm_membar_sys is inferred to
-  // be __host__ __device__ and thus callable from device code.
+  // This shouldn't produce an error, since __nvvm_membar_sys should be
+  // __device__ and thus callable from device code.
   __nvvm_membar_sys();
 }
Index: test/SemaCUDA/function-overload.cu
===
--- /dev/null
+++ test/SemaCUDA/function-overload.cu
@@ -0,0 +1,173 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// Make sure we handle target overloads correctly.
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu \
+// RUN:-fsyntax-only -fcuda-target-overloads -verify %s
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda \
+// RUN:-fsyntax-only -fcuda-target-overloads -fcuda-is-device -verify %s
+
+// Check target overloads handling with disabled call target checks.
+// RUN: %clang_cc1 -DNOCHECKS -triple x86_64-unknown-linux-gnu -fsyntax-only \
+// RUN:-fcuda-disable-target-call-checks -fcuda-target-overloads -verify %s
+// RUN: %clang_cc1 -DNOCHECKS -triple nvptx64-nvidia-cuda -fsyntax-only \
+// RUN:-fcuda-disable-target-call-checks -fcuda-target-overloads \
+// RUN:-fcuda-is-device -verify %s
+
+#include "Inputs/cuda.h"
+
+typedef int (*fp_t)(void);
+
+__device__ int dhhd(void) { return 2; }
+__host__ int dhhd(void) { return 1; } // expected-note {{previous definition is here}}
+int dhhd(void) { return 1; } // expected-error {{redefinition of 'dhhd'}}
+__host__ __device__ int dhhd(void) { return 3; }
+
+__host__ int hhd(void) { return 4; }
+__host__ __device__ int dhd(void) { return 5; }
+
+__device__ int dhd(void) { return 6; }
+__host__ __device__ int hhd(void) { return 7; }
+
+__device__ int d(void) { return 8; }
+__host__ int h(void) { return 9; }
+__global__ void g(void) {}
+
+extern "C" __device__ int chd(void) {return 10;}
+extern "C" __host__ int chd(void) {return 11;} // expected-note {{previous definition is here}}
+extern "C" int chd(void) {return 11;} // expected-error {{redefinition of 'chd'}}
+extern "C" __host__ __device__ int chd(void) {return 12;} // expected-note {{previous definition is here}}
+extern "C" __host__ __device__ int chd(void) {return 13;} // expected-error {{redefinition of 'chd'}}
+
+__host__ void hostf(void) {
+  fp_t dhddp = dhhd;
+  fp_t hhdp = hhd;
+  fp_t dhdp = dhd;
+  fp_t dp = d;
+#if !defined(NOCHECKS)
+  // expected-error@-2 {{reference to __device__ function 'd' in __host__ function}}
+  // expected-note@32 {{'d' declared here}}
+#endif
+  fp_t hp = h;
+
+  dhhd();
+  hhd();
+  dhd();
+  chd();
+  d();
+#if !defined(NOCHECKS)
+  // expected-error@-2 {{no matching function for call to 'd'}}
+  // expected-note@32 {{candidate function not viable: call to __device__ function from __host__ function}}
+#endif
+  h();
+
+  g(); // expected-error {{call to global function g not configured}}
+  g<<<0,0>>>();
+}
+
+__device__ void devicef(void) {
+  fp_t dhddp = dhhd;
+  fp_t hhdp = hhd;
+  fp_t dhdp = dhd;
+  fp_t dp = d;
+  fp_t hp = h;
+#if !defined(NOCHECKS)
+  // expected

r246348 - Follow-up to r246338: use getParentFunctionOrMethod

2015-08-28 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Fri Aug 28 17:56:21 2015
New Revision: 246348

URL: http://llvm.org/viewvc/llvm-project?rev=246348&view=rev
Log:
Follow-up to r246338: use getParentFunctionOrMethod

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

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=246348&r1=246347&r2=246348&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Aug 28 17:56:21 2015
@@ -9967,7 +9967,7 @@ Sema::FinalizeDeclaration(Decl *ThisDecl
   // dllimport/dllexport variables cannot be thread local, their TLS index
   // isn't exported with the variable.
   if (DLLAttr && VD->getTLSKind()) {
-FunctionDecl *F = dyn_cast(VD->getDeclContext());
+auto *F = dyn_cast_or_null(VD->getParentFunctionOrMethod());
 if (F && getDLLAttr(F)) {
   assert(VD->isStaticLocal());
   // But if this is a static local in a dlimport/dllexport function, the


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


Re: [PATCH] D1623: Support __builtin_ms_va_list.

2015-08-28 Thread Charles Davis via cfe-commits
cdavis5x updated this revision to Diff 33490.
cdavis5x added a comment.

- Rebase onto http://reviews.llvm.org/rL246348.
- Register the `__builtin_ms_va_list` predef decl. Fixes a nasty interaction 
with modules.
- Mark `__builtin_ms_va_start` builtin as manually type-checked.


http://reviews.llvm.org/D1623

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Expr.h
  include/clang/Basic/BuiltinsX86.def
  include/clang/Basic/TargetInfo.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTDiagnostic.cpp
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaExpr.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/CodeGen/ms_abi.c
  test/PCH/Inputs/va_arg.h
  test/PCH/va_arg.c
  test/PCH/va_arg.cpp
  test/PCH/va_arg.h
  test/Sema/varargs-x86-64.c
  test/SemaTemplate/instantiate-expr-3.cpp

Index: test/SemaTemplate/instantiate-expr-3.cpp
===
--- test/SemaTemplate/instantiate-expr-3.cpp
+++ test/SemaTemplate/instantiate-expr-3.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
 
 // -
 // Imaginary literals
@@ -108,12 +108,41 @@
 struct VaArg1 {
   void f(int n, ...) {
 VaList va;
-__builtin_va_start(va, n); // expected-error{{int}}
+__builtin_va_start(va, n); // expected-error{{int}} expected-error{{char *}}
 for (int i = 0; i != n; ++i)
   (void)__builtin_va_arg(va, ArgType); // expected-error{{int}}
-__builtin_va_end(va); // expected-error{{int}}
+__builtin_va_end(va); // expected-error{{int}} expected-error{{char *}}
   }
 };
 
 template struct VaArg1<__builtin_va_list, int>;
+template struct VaArg1<__builtin_ms_va_list, int>; // expected-note{{instantiation}}
 template struct VaArg1; // expected-note{{instantiation}}
+
+template
+struct VaArg2 {
+  void f(int n, ...) {
+__builtin_ms_va_list va;
+__builtin_ms_va_start(va, n);
+for (int i = 0; i != n; ++i)
+  (void)__builtin_va_arg(va, ArgType);
+__builtin_ms_va_end(va);
+  }
+};
+
+template struct VaArg2;
+
+template
+struct VaArg3 {
+  void f(int n, ...) {
+VaList va;
+__builtin_ms_va_start(va, n); // expected-error{{int}} expected-error{{__va_list_tag}}
+for (int i = 0; i != n; ++i)
+  (void)__builtin_va_arg(va, ArgType); // expected-error{{int}}
+__builtin_ms_va_end(va); // expected-error{{int}} expected-error{{__va_list_tag}}
+  }
+};
+
+template struct VaArg3<__builtin_ms_va_list, int>;
+template struct VaArg3<__builtin_va_list, int>; // expected-note{{instantiation}}
+template struct VaArg3; // expected-note{{instantiation}}
Index: test/Sema/varargs-x86-64.c
===
--- test/Sema/varargs-x86-64.c
+++ test/Sema/varargs-x86-64.c
@@ -6,3 +6,70 @@
   (void)__builtin_va_arg(args2, int); // expected-error {{first argument to 'va_arg' is of type 'const __builtin_va_list' and not 'va_list'}}
 }
 
+void __attribute__((ms_abi)) g1(int a)
+{
+__builtin_ms_va_list ap;
+
+__builtin_ms_va_start(ap, a, a); // expected-error {{too many arguments to function}}
+__builtin_ms_va_start(ap, a); // expected-error {{'va_start' used in function with fixed args}}
+}
+
+void __attribute__((ms_abi)) g2(int a, int b, ...)
+{
+__builtin_ms_va_list ap;
+
+__builtin_ms_va_start(ap, 10); // expected-warning {{second parameter of 'va_start' not last named argument}}
+__builtin_ms_va_start(ap, a); // expected-warning {{second parameter of 'va_start' not last named argument}}
+__builtin_ms_va_start(ap, b);
+}
+
+void __attribute__((ms_abi)) g3(float a, ...)
+{
+__builtin_ms_va_list ap;
+
+__builtin_ms_va_start(ap, a);
+__builtin_ms_va_start(ap, (a));
+}
+
+void __attribute__((ms_abi)) g5() {
+  __builtin_ms_va_list ap;
+  __builtin_ms_va_start(ap,ap); // expected-error {{'va_start' used in function with fixed args}}
+}
+
+void __attribute__((ms_abi)) g6(int a, ...) {
+  __builtin_ms_va_list ap;
+  __builtin_ms_va_start(ap); // expected-error {{too few arguments to function}}
+}
+
+void __attribute__((ms_abi))
+bar(__builtin_ms_va_list authors, ...) {
+  __builtin_ms_va_start (authors, authors);
+  (void)__builtin_va_arg(authors, int);
+  __builtin_ms_va_end (authors);
+}
+
+void __attribute__((ms_abi)) g7(int a, ...) {
+  __builtin_ms_va_list ap;
+  __builtin_ms_va_start(ap, a);
+  // FIXME: This error message is sub-par.
+  __builtin_va_arg(ap, int) = 1; // expected-er

Re: [PATCH] D12313: Introduce __builtin_nontemporal_store and __builtin_nontemporal_load.

2015-08-28 Thread Michael Zolotukhin via cfe-commits
mzolotukhin updated this revision to Diff 33492.
mzolotukhin added a comment.

- Use EmitStoreOfScalar and EmitLoadOfScalar for generating nontemporal loads 
and stores.
- Rebase on TOT.


http://reviews.llvm.org/D12313

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGValue.h
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaChecking.cpp
  test/CodeGen/Nontemporal.cpp

Index: test/CodeGen/Nontemporal.cpp
===
--- /dev/null
+++ test/CodeGen/Nontemporal.cpp
@@ -0,0 +1,48 @@
+// Test frontend handling of nontemporal builtins.
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s
+
+signed char sc;
+unsigned char uc;
+signed short ss;
+unsigned short us;
+signed int si;
+unsigned int ui;
+signed long long sll;
+unsigned long long ull;
+float f1, f2;
+double d1, d2;
+float __attribute__((vector_size(16))) vf1, vf2;
+char __attribute__((vector_size(8))) vc1, vc2;
+bool b1, b2;
+
+void test_all_sizes(void) // CHECK-LABEL: test_all_sizes
+{
+  __builtin_nontemporal_store(true, &b1); // CHECK: store i8 1, i8* @b1, align 1, !nontemporal
+  __builtin_nontemporal_store(b1, &b2);   // CHECK: store i8{{.*}}, align 1, !nontemporal
+  __builtin_nontemporal_store(1, &uc);// CHECK: store i8{{.*}}align 1, !nontemporal
+  __builtin_nontemporal_store(1, &sc);// CHECK: store i8{{.*}}align 1, !nontemporal
+  __builtin_nontemporal_store(1, &us);// CHECK: store i16{{.*}}align 2, !nontemporal
+  __builtin_nontemporal_store(1, &ss);// CHECK: store i16{{.*}}align 2, !nontemporal
+  __builtin_nontemporal_store(1, &ui);// CHECK: store i32{{.*}}align 4, !nontemporal
+  __builtin_nontemporal_store(1, &si);// CHECK: store i32{{.*}}align 4, !nontemporal
+  __builtin_nontemporal_store(1, &ull);   // CHECK: store i64{{.*}}align 8, !nontemporal
+  __builtin_nontemporal_store(1, &sll);   // CHECK: store i64{{.*}}align 8, !nontemporal
+  __builtin_nontemporal_store(1.0, &f1);  // CHECK: store float{{.*}}align 4, !nontemporal
+  __builtin_nontemporal_store(1.0, &d1);  // CHECK: store double{{.*}}align 8, !nontemporal
+  __builtin_nontemporal_store(vf1, &vf2); // CHECK: store <4 x float>{{.*}}align 16, !nontemporal
+  __builtin_nontemporal_store(vc1, &vc2); // CHECK: store <8 x i8>{{.*}}align 8, !nontemporal
+
+  b1 = __builtin_nontemporal_load(&b2);   // CHECK: load i8{{.*}}align 1, !nontemporal
+  uc = __builtin_nontemporal_load(&sc);   // CHECK: load i8{{.*}}align 1, !nontemporal
+  sc = __builtin_nontemporal_load(&uc);   // CHECK: load i8{{.*}}align 1, !nontemporal
+  us = __builtin_nontemporal_load(&ss);   // CHECK: load i16{{.*}}align 2, !nontemporal
+  ss = __builtin_nontemporal_load(&us);   // CHECK: load i16{{.*}}align 2, !nontemporal
+  ui = __builtin_nontemporal_load(&si);   // CHECK: load i32{{.*}}align 4, !nontemporal
+  si = __builtin_nontemporal_load(&ui);   // CHECK: load i32{{.*}}align 4, !nontemporal
+  ull = __builtin_nontemporal_load(&sll); // CHECK: load i64{{.*}}align 8, !nontemporal
+  sll = __builtin_nontemporal_load(&ull); // CHECK: load i64{{.*}}align 8, !nontemporal
+  f1 = __builtin_nontemporal_load(&f2);   // CHECK: load float{{.*}}align 4, !nontemporal
+  d1 = __builtin_nontemporal_load(&d2);   // CHECK: load double{{.*}}align 8, !nontemporal
+  vf2 = __builtin_nontemporal_load(&vf1); // CHECK: load <4 x float>{{.*}}align 16, !nontemporal
+  vc2 = __builtin_nontemporal_load(&vc1); // CHECK: load <8 x i8>{{.*}}align 8, !nontemporal
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -441,6 +441,9 @@
   case Builtin::BI__sync_swap_8:
   case Builtin::BI__sync_swap_16:
 return SemaBuiltinAtomicOverloaded(TheCallResult);
+  case Builtin::BI__builtin_nontemporal_load:
+  case Builtin::BI__builtin_nontemporal_store:
+return SemaBuiltinNontemporalOverloaded(TheCallResult);
 #define BUILTIN(ID, TYPE, ATTRS)
 #define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
   case Builtin::BI##ID: \
@@ -2210,6 +2213,80 @@
   return TheCallResult;
 }
 
+/// SemaBuiltinNontemporalOverloaded - We have a call to
+/// __builtin_nontemporal_store or __builtin_nontemporal_load, which is an
+/// overloaded function based on the pointer type of its last argument.
+/// The main ActOnCallExpr routines have already promoted the types of
+/// arguments because all of these calls are prototyped as void(...).
+///
+/// This function goes through and does final semantic checking for these
+/// builtins.
+ExprResult Sema::SemaBuiltinNontemporalOverloaded(ExprResult TheCallResult) {
+  CallExpr *TheCall = (CallExpr *)TheCallResult.get();
+  DeclRefExpr *DRE =
+  cast(TheCall->getCallee()->IgnoreParenCasts());
+  FunctionDecl *FDecl = cast(DRE->getDecl());
+  unsigned BuiltinID = FDe

Re: [PATCH] D12313: Introduce __builtin_nontemporal_store and __builtin_nontemporal_load.

2015-08-28 Thread Michael Zolotukhin via cfe-commits
mzolotukhin added a comment.

Hi Hal,

I added `Nontemporal` field to LValue and started to use it in 
`EmitStoreOfScalar`/`EmitLoadOfScalar`. Does it look like something you had in 
mind?

Thanks,
Michael


http://reviews.llvm.org/D12313



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


[PATCH] D12458: [clang] add __builtin_unpredictable and convert to metadata

2015-08-28 Thread Sanjay Patel via cfe-commits
spatel created this revision.
spatel added reviewers: hfinkel, kbsmith1, kparzysz, reames, silvas.
spatel added a subscriber: cfe-commits.
spatel added a dependency: D12341: add unpredictable metadata type for control 
flow.

This patch depends on D12341 ('unpredictable' metadata type for LLVM). 

For now, I am ignoring the horrible thought that this builtin might take an 
extra parameter to distinguish different hardware. :)

The goal is to make LLVM generate different code for these functions for a 
target that has cheap branches (see PR23827 for more details):

   int foo();
   int normal(int x, int y, int z) {
  if (x != 0 && y != 0) return foo();
  return 1;
   }
   
   int crazy(int x, int y) {
  if (__builtin_unpredictable(x != 0 && y != 0)) return foo();
  return 1;
   }



http://reviews.llvm.org/D12458

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/Builtins.def
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  test/CodeGen/builtin-unpredictable.c

Index: test/CodeGen/builtin-unpredictable.c
===
--- test/CodeGen/builtin-unpredictable.c
+++ test/CodeGen/builtin-unpredictable.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -O1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -O0 | FileCheck %s --check-prefix=CHECK_O0
+
+// When optimizing, the builtin should be converted to metadata.
+// When not optimizing, there should be no metadata created for the builtin.
+// In both cases, the builtin should be removed from the code.
+
+void foo();
+void branch(int x) {
+// CHECK-LABEL: define void @branch(
+
+// CHECK-NOT: builtin_unpredictable
+// CHECK: !unpredictable [[METADATA:.+]]
+// CHECK: [[METADATA]] = !{i8 100}
+
+// CHECK_O0-NOT: builtin_unpredictable
+// CHECK_O0-NOT: !unpredictable 
+
+  if (__builtin_unpredictable(x > 0))
+foo ();
+}
+
+// TODO: Add metadata for unpredictable switches.
+int unpredictable_switch(int x) {
+  switch(__builtin_unpredictable(x)) {
+  default:
+return 0;
+  case 0:
+  case 1:
+  case 2:
+return 1;
+  case 5:
+return 5;
+  };
+
+  return 0;
+}
Index: lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
+++ lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
@@ -41,11 +41,12 @@
   default:
 return false;
 
+  case Builtin::BI__builtin_unpredictable:
   case Builtin::BI__builtin_expect:
   case Builtin::BI__builtin_assume_aligned:
   case Builtin::BI__builtin_addressof: {
-// For __builtin_expect and __builtin_assume_aligned, just return the value
-// of the subexpression.
+// For __builtin_unpredictable, __builtin_expect, and
+// __builtin_assume_aligned, just return the value of the subexpression.
 // __builtin_addressof is going from a reference to a pointer, but those
 // are represented the same way in the analyzer.
 assert (CE->arg_begin() != CE->arg_end());
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -24,6 +24,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/StmtCXX.h"
+#include "clang/Basic/Builtins.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
 #include "clang/Frontend/CodeGenOptions.h"
@@ -1203,6 +1204,25 @@
 return;
   }
 
+  // If the branch has a condition wrapped by __builtin_unpredictable,
+  // create metadata that specifies that the branch is unpredictable.
+  // Don't bother if not optimizing because that metadata would not be used.
+  llvm::MDNode *Unpredictable = nullptr;
+  if (CGM.getCodeGenOpts().OptimizationLevel != 0) {
+if (const CallExpr *Call = dyn_cast(Cond)) {
+  const Decl *TargetDecl = Call->getCalleeDecl();
+  if (const FunctionDecl *FD = dyn_cast_or_null(TargetDecl)) {
+if (FD->getBuiltinID() == Builtin::BI__builtin_unpredictable) {
+  // Unpredictable metadata is a percentage from 0 (completely
+  // predictable) to 100 (completely unpredictable). If the program has
+  // this hint, we assume the branch is completely unpredictable.
+  llvm::MDBuilder MDHelper(getLLVMContext());
+  Unpredictable = MDHelper.createUnpredictable(100);
+}
+  }
+}
+  }
+
   // Create branch weights based on the number of times we get here and the
   // number of times the condition should be true.
   uint64_t CurrentCount = std::max(getCurrentProfileCount(), TrueCount);
@@ -1215,7 +1235,7 @@
 ApplyDebugLocation DL(*this, Cond);
 CondV = EvaluateExprAsBool(Cond);
   }
-  Builder.CreateCondBr(CondV, TrueBlock, FalseBlock, Weights);
+  Builder.CreateCond

Re: [PATCH] D12445: [Static Analyzer] Remove sinks from nullability checks.

2015-08-28 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:166
@@ +165,3 @@
+  // nullability precondition is violated it will not report any bugs at all.
+  void reportBug(ErrorKind Error, ExplodedNode *N, const MemRegion *Region,
+ CheckerContext &C, const Stmt *ValueExpr = nullptr) const;

The difference is not clear by looking at the signature; maybe you should 
rename the method to make it more clear what the difference is.

Please, use doxygen style comments everywhere!


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:228
@@ -222,1 +227,3 @@
 
+// If the nullability preconditions of a function is violated, we should not
+// report that, a postcondition is violated. For this reason once a 
precondition

preconditions -> precondition
I am not sure what you mean by postcondition and where that term is defined.
turned of ->  turned off
so this check does not -> so that this checker would not lead to reduced 
coverage


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:371
@@ +370,3 @@
+  checkPreconditionViolation(OriginalState, C.getLocationContext());
+  if (NewState != OriginalState) {
+C.addTransition(NewState, N);

Looks like you are assuming that you cannot get to this point with 
OriginalState having the PreconditionViolation bit set. This seems fragile. At 
minimum, you should assert this, but maybe changing the 
checkPreconditionViolation API would be better?


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:395
@@ +394,3 @@
+  // reaped.
+  if (!State->get()) {
+ProgramStateRef NewState =

Maybe you should only do this if there was at least one symbol with nullability 
info removed in the loop above? Would that work?


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:430
@@ -338,1 +429,3 @@
+// Do not suppress errors on defensive code paths, because dereferencing
+// null is alwazs an error.
 if (Event.IsDirectDereference)

Please, spell check your comments.

We are not dereferencing null.. we are dereferencing a nullable pointer..
Am I wrong?


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:565
@@ -468,5 +564,3 @@
   ParamNullability == Nullability::Nonnull) {
-static CheckerProgramPointTag Tag(this, "NullablePassedToNonnull");
-ExplodedNode *N = C.generateSink(State, C.getPredecessor(), &Tag);
-reportBug(ErrorKind::NullablePassedToNonnull, N, Region,
-  C.getBugReporter(), ArgExpr);
+State = State->set(true);
+ExplodedNode *N = C.addTransition(State);

I do not understand how this works..

Does this ever report an issue? I thought this version of the bugReport will 
only report an issue if PreconditionViolation is not set. (Same for the code 
below and above..)

Is this tested?




http://reviews.llvm.org/D12445



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


Re: [PATCH] D12446: [PATCH] Enable clang-tidy misc-static-assert for C11

2015-08-28 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

> 1. If  is included, then static_assert() is also fine to use. 
> Presumably, in order for the assert() check to trigger,  has to be 
> included, but I don't feel particularly comfortable with that assumption.


Do you have any C11 code that uses `assert()`, but doesn't include `assert.h`? 
If no, I'd suggest relying on this assumption until someone stumbles upon this 
and files a bug (or fixes this). One more option is to ensure assert.h is 
always included in the file being fixed (there's `IncludeInserter` class that 
can do this).

> If there's a way to access a Preprocessor instance from check(),


You can subscribe to `PPCallbacks` and find out if static_assert is defined 
after the last include. Or if it's defined and not undefined. But I'd probably 
just skip this until you see real code that would benefit from this.

> we can use getMacroDefinitionAtLoc() to determine whether static_assert() is 
> defined and a valid replacement for assert(). For right now, I'm 

>  always using _Static_assert() in C11 mode to be on the safe side.




> 2. My Python skills are rudimentary at best. If there's a better way to 
> update check_clang_tidy.py to handle file extensions, that would be great. 
> This change is required or else the script fails on .c test cases that check 
> fixes because of writing out to a .tmp.cpp file instead of a .tmp.c file 
> conflicts with the language options specified on the RUN line.


Alternatively, you could add "-x c" to the test's RUN: line, but your solution 
is an improvement over this hack. Thanks!



Comment at: test/clang-tidy/check_clang_tidy.py:50
@@ -45,3 +49,3 @@
   if len(clang_tidy_extra_args) == 0:
-clang_tidy_extra_args = ['--', '--std=c++11']
+clang_tidy_extra_args = ['--', '--std=c++11' if extension == '.cpp' else 
'-std=c99']
 

I'm not sure that c99 is a good default for C code here. The existing .c tests 
don't rely on this, and the tests you're adding override `-std` anyway. I'd 
change this to `['--', '--std=c++11'] if extension == '.cpp' else ['--']`.


Comment at: test/clang-tidy/misc-static-assert-c99.c:1
@@ +1,2 @@
+// RUN: %python %S/check_clang_tidy.py %s misc-static-assert %t -- -std=c99
+

Instead of duplicating the test, you could add a second run line in the other 
test and just verify that clang-tidy doesn't generate any warnings when run 
with `-std=c99`. The invariant "no warnings == no fixes" is pretty basic for 
clang-tidy, so you can rely on it in the tests.


http://reviews.llvm.org/D12446



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


Re: [PATCH] D12445: [Static Analyzer] Remove sinks from nullability checks.

2015-08-28 Thread Gábor Horváth via cfe-commits
xazax.hun updated this revision to Diff 33501.
xazax.hun marked 6 inline comments as done.
xazax.hun added a comment.

Addressed the comments.


http://reviews.llvm.org/D12445

Files:
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  test/Analysis/nullability.mm

Index: test/Analysis/nullability.mm
===
--- test/Analysis/nullability.mm
+++ test/Analysis/nullability.mm
@@ -179,3 +179,44 @@
   takesNullable(p);
   takesNonnull(p);
 }
+
+void onlyReportFirstPreconditionViolationOnPath() {
+  Dummy *p = returnsNullable();
+  takesNonnull(p); // expected-warning {{}}
+  takesNonnull(p); // No warning.
+  // The first warning was not a sink. The analysis expected to continue.
+  int i = 0;
+  i = 5 / i; // expected-warning {{Division by zero}}
+  (void)i;
+}
+
+Dummy *_Nonnull doNotWarnWhenPreconditionIsViolatedInTopFunc(
+Dummy *_Nonnull p) {
+  if (!p) {
+Dummy *ret =
+0; // avoid compiler warning (which is not generated by the analyzer)
+if (getRandom())
+  return ret; // no warning
+else
+  return p; // no warning
+  } else {
+return p;
+  }
+}
+
+Dummy *_Nonnull doNotWarnWhenPreconditionIsViolated(Dummy *_Nonnull p) {
+  if (!p) {
+Dummy *ret =
+0; // avoid compiler warning (which is not generated by the analyzer)
+if (getRandom())
+  return ret; // no warning
+else
+  return p; // no warning
+  } else {
+return p;
+  }
+}
+
+void testPreconditionViolationInInlinedFunction(Dummy *p) {
+  doNotWarnWhenPreconditionIsViolated(p);
+}
Index: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -161,6 +161,16 @@
 const MemRegion *Region;
   };
 
+  /// When any of the nonnull arguments of the analyzed function is null, do not
+  /// report anything and turn off the check.
+  ///
+  /// When \p SuppressPath is set to true, no more bugs will be reported on this
+  /// path by this checker.
+  void reportBugConditionally(ErrorKind Error, ExplodedNode *N,
+  const MemRegion *Region, CheckerContext &C,
+  const Stmt *ValueExpr = nullptr,
+  bool SuppressPath = false) const;
+
   void reportBug(ErrorKind Error, ExplodedNode *N, const MemRegion *Region,
  BugReporter &BR, const Stmt *ValueExpr = nullptr) const {
 if (!BT)
@@ -220,6 +230,13 @@
 REGISTER_MAP_WITH_PROGRAMSTATE(NullabilityMap, const MemRegion *,
NullabilityState)
 
+// If the nullability precondition of a function is violated, we should not
+// report nullability related issues on that path. For this reason once a
+// precondition is not met on a path, this checker will be esentially turned off
+// for the rest of the analysis. We do not want to generate a sink node however,
+// so this checker would not lead to reduced coverage.
+REGISTER_TRAIT_WITH_PROGRAMSTATE(PreconditionViolated, bool)
+
 enum class NullConstraint { IsNull, IsNotNull, Unknown };
 
 static NullConstraint getNullConstraint(DefinedOrUnknownSVal Val,
@@ -302,6 +319,75 @@
   return Nullability::Unspecified;
 }
 
+template 
+static ProgramStateRef
+checkParamsForPreconditionViolation(const ParamVarDeclRange &Params,
+ProgramStateRef State,
+const LocationContext *LocCtxt) {
+  for (const auto *ParamDecl : Params) {
+if (ParamDecl->isParameterPack())
+  break;
+
+if (getNullabilityAnnotation(ParamDecl->getType()) != Nullability::Nonnull)
+  continue;
+
+auto RegVal = State->getLValue(ParamDecl, LocCtxt)
+  .template getAs();
+if (!RegVal)
+  continue;
+
+auto ParamValue = State->getSVal(RegVal->getRegion())
+  .template getAs();
+if (!ParamValue)
+  continue;
+
+if (getNullConstraint(*ParamValue, State) == NullConstraint::IsNull) {
+  return State->set(true);
+}
+  }
+  return State;
+}
+
+static ProgramStateRef
+checkPreconditionViolation(ProgramStateRef State,
+   const LocationContext *LocCtxt) {
+  const Decl *D = LocCtxt->getDecl();
+  if (!D)
+return State;
+
+  if (const auto *BlockD = dyn_cast(D)) {
+return checkParamsForPreconditionViolation(BlockD->parameters(), State,
+   LocCtxt);
+  }
+
+  if (const auto *FuncDecl = dyn_cast(D)) {
+return checkParamsForPreconditionViolation(FuncDecl->parameters(), State,
+   LocCtxt);
+  }
+  return State;
+}
+
+void NullabilityChecker::reportBugConditionally(
+ErrorKind Error, ExplodedNode *N, const MemRegion *Region,
+CheckerContext &C, const Stmt *ValueExpr, bool SuppressPath) const {
+  ProgramStateRef

Re: [PATCH] D12445: [Static Analyzer] Remove sinks from nullability checks.

2015-08-28 Thread Gábor Horváth via cfe-commits
xazax.hun added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:395
@@ +394,3 @@
+  // reaped.
+  if (!State->get()) {
+ProgramStateRef NewState =

zaks.anna wrote:
> Maybe you should only do this if there was at least one symbol with 
> nullability info removed in the loop above? Would that work?
That would not work.
Only "nullable" nullability and contradictions are tracked for the symbols 
right now. If nothing is marked nullable, this branch would never be taken.


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:430
@@ -338,1 +429,3 @@
+// Do not suppress errors on defensive code paths, because dereferencing
+// null is alwazs an error.
 if (Event.IsDirectDereference)

zaks.anna wrote:
> Please, spell check your comments.
> 
> We are not dereferencing null.. we are dereferencing a nullable pointer..
> Am I wrong?
You are right.


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:565
@@ -468,5 +564,3 @@
   ParamNullability == Nullability::Nonnull) {
-static CheckerProgramPointTag Tag(this, "NullablePassedToNonnull");
-ExplodedNode *N = C.generateSink(State, C.getPredecessor(), &Tag);
-reportBug(ErrorKind::NullablePassedToNonnull, N, Region,
-  C.getBugReporter(), ArgExpr);
+State = State->set(true);
+ExplodedNode *N = C.addTransition(State);

zaks.anna wrote:
> I do not understand how this works..
> 
> Does this ever report an issue? I thought this version of the bugReport will 
> only report an issue if PreconditionViolation is not set. (Same for the code 
> below and above..)
> 
> Is this tested?
> 
> 
Yes, it works.

The reason is that, reportBug does report bugs, when PreconditionViolated is 
set to true. It does not report bugs, when one of the nonnull argument is 
constrained to be null. PreconditionViolated is used at the beginning of some 
callbacks to return early.

However I think this behavior might be confusing, so I refactored the code. 
From now on reportBugConditionally does not report any bug, when 
PreconditionViolated is set to true, and it does set it to true when a reported 
bug should suppress other bugs along the path.


http://reviews.llvm.org/D12445



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


[PATCH] D12462: [PATCH] [clang-tidy] Add inconsistent declaration parameter name check

2015-08-28 Thread Piotr Dziwinski via cfe-commits
piotrdz created this revision.
piotrdz added a subscriber: cfe-commits.
piotrdz set the repository for this revision to rL LLVM.

This is first of series of patches, porting code from my project colobot-lint, 
as I mentioned recently in cfe-dev mailing list.

This patch adds a new check in readability module: 
readability-inconsistent-declaration-parameter-name. I also added appropriate 
testcases and documentation.

I chose readability module, as it seems it is the best place for it.

I think I followed the rules of LLVM coding guideline, but I may have missed 
something, as I usually use other code formatting style.

Repository:
  rL LLVM

http://reviews.llvm.org/D12462

Files:
   tools/clang/extra/clang-tidy/readability/CMakeLists.txt
   
tools/clang/extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
   
tools/clang/extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
   tools/clang/extra/clang-tidy/readability/ReadabilityTidyModule.cpp
   tools/clang/extra/docs/clang-tidy/checks/list.rst
   
tools/clang/extra/docs/clang-tidy/checks/readability-inconsistent-declaration-parameter-name.rst
   
tools/clang/extra/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp

Index:  tools/clang/extra/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
===
---  tools/clang/extra/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
+++  tools/clang/extra/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
@@ -0,0 +1,20 @@
+// RUN: %python %S/check_clang_tidy.py %s readability-inconsistent-declaration-parameter-name %t
+
+void consistentFunction(int a, int b, int c);
+void consistentFunction(int a, int b, int c);
+void consistentFunction(int a, int b, int /*c*/);
+void consistentFunction(int /*c*/, int /*c*/, int /*c*/);
+
+// CHECK-MESSAGES: :[[@LINE+1]]:6: warning: function 'inconsistentFunction' has other declaration with different parameter name(s) [readability-inconsistent-declaration-parameter-name]
+void inconsistentFunction(int a, int b, int c);
+void inconsistentFunction(int d, int e, int f);
+void inconsistentFunction(int x, int y, int z);
+
+struct SomeStruct
+{
+// CHECK-MESSAGES: :[[@LINE+1]]:10: warning:  function 'SomeStruct::inconsistentFunction' has other declaration with different parameter name(s) [readability-inconsistent-declaration-parameter-name]
+void inconsistentFunction(int a);
+};
+
+void SomeStruct::inconsistentFunction(int b)
+{}
Index:  tools/clang/extra/docs/clang-tidy/checks/readability-inconsistent-declaration-parameter-name.rst
===
---  tools/clang/extra/docs/clang-tidy/checks/readability-inconsistent-declaration-parameter-name.rst
+++  tools/clang/extra/docs/clang-tidy/checks/readability-inconsistent-declaration-parameter-name.rst
@@ -0,0 +1,16 @@
+readability-inconsistent-declaration-parameter-name
+===
+
+
+Find function declarations which differ in parameter names.
+
+Example:
+
+.. code:: c++
+
+  // in foo.hpp:
+  void foo(int a, int b, int c);
+
+  // in foo.cpp:
+  void foo(int d, int e, int f); // warning
+
Index:  tools/clang/extra/docs/clang-tidy/checks/list.rst
===
---  tools/clang/extra/docs/clang-tidy/checks/list.rst
+++  tools/clang/extra/docs/clang-tidy/checks/list.rst
@@ -47,6 +47,7 @@
readability-else-after-return
readability-function-size
readability-identifier-naming
+   readability-inconsistent-declaration-parameter-name
readability-named-parameter
readability-redundant-smartptr-get
readability-redundant-string-cstr
Index:  tools/clang/extra/clang-tidy/readability/ReadabilityTidyModule.cpp
===
---  tools/clang/extra/clang-tidy/readability/ReadabilityTidyModule.cpp
+++  tools/clang/extra/clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -15,6 +15,7 @@
 #include "ElseAfterReturnCheck.h"
 #include "FunctionSizeCheck.h"
 #include "IdentifierNamingCheck.h"
+#include "InconsistentDeclarationParameterNameCheck.h"
 #include "NamedParameterCheck.h"
 #include "RedundantSmartptrGetCheck.h"
 #include "RedundantStringCStrCheck.h"
@@ -38,6 +39,8 @@
 "readability-function-size");
 CheckFactories.registerCheck(
 "readability-identifier-naming");
+CheckFactories.registerCheck(
+"readability-inconsistent-declaration-parameter-name");
 CheckFactories.registerCheck(
 "readability-named-parameter");
 CheckFactories.registerCheck(
Index:  tools/clang/extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
===
---  tools/clang/extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
+++  tools/clan

Re: [PATCH] D1623: Support __builtin_ms_va_list.

2015-08-28 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/AST/Expr.h:3709
@@ -3708,3 +3708,3 @@
   VAArgExpr(SourceLocation BLoc, Expr* e, TypeSourceInfo *TInfo,
-SourceLocation RPLoc, QualType t)
+SourceLocation RPLoc, QualType t, bool IsMS = false)
 : Expr(VAArgExprClass, t, VK_RValue, OK_Ordinary,

Is there a reason to add a default argument for this? It looks like all calls 
provide an argument.


Comment at: include/clang/AST/Expr.h:3720-3722
@@ -3719,4 +3719,5 @@
 
-  /// \brief Create an empty __builtin_va_arg expression.
-  explicit VAArgExpr(EmptyShell Empty) : Expr(VAArgExprClass, Empty) { }
+  /// Create an empty __builtin_va_arg expression.
+  explicit VAArgExpr(EmptyShell Empty, bool IsMS = false)
+: Expr(VAArgExprClass, Empty), Val(0), TInfo(0, IsMS) { }
 

The `IsMS` flag you added here is never used.


Comment at: include/clang/AST/Expr.h:3728-3734
@@ -3726,5 +3727,9 @@
 
-  TypeSourceInfo *getWrittenTypeInfo() const { return TInfo; }
-  void setWrittenTypeInfo(TypeSourceInfo *TI) { TInfo = TI; }
+  /// Returns whether this is really a Win64 ABI va_arg expression.
+  bool isMicrosoftABI() const { return TInfo.getInt(); }
+  void setIsMicrosoftABI(bool IsMS) { TInfo.setInt(IsMS); }
+
+  TypeSourceInfo *getWrittenTypeInfo() const { return TInfo.getPointer(); }
+  void setWrittenTypeInfo(TypeSourceInfo *TI) { TInfo.setPointer(TI); }
 
   SourceLocation getBuiltinLoc() const { return BuiltinLoc; }

Probably because its second argument is a type, and we couldn't preserve that 
and maintain AST fidelity if we represented it as a `CallExpr`.


Comment at: lib/CodeGen/CGExprScalar.cpp:3387-3392
@@ -3386,4 +3386,8 @@
 
-  llvm::Value *ArgValue = CGF.EmitVAListRef(VE->getSubExpr());
-  llvm::Value *ArgPtr = CGF.EmitVAArg(ArgValue, VE->getType());
+  llvm::Value *ArgValue = VE->isMicrosoftABI() ?
+CGF.EmitMSVAListRef(VE->getSubExpr()) :
+CGF.EmitVAListRef(VE->getSubExpr());
+  llvm::Value *ArgPtr = VE->isMicrosoftABI() ?
+CGF.EmitMSVAArg(ArgValue, VE->getType()) :
+CGF.EmitVAArg(ArgValue, VE->getType());
   llvm::Type *ArgTy = ConvertType(VE->getType());

Do you really need this dispatch? `CodeGenFunction` dispatches this to the 
function's ABI info class, which should do the right thing already.


Comment at: lib/Sema/SemaChecking.cpp:1038-1040
@@ -1037,1 +1037,5 @@
+  case X86::BI__builtin_ms_va_start:
+if (Context.getTargetInfo().getTriple().getArch() != llvm::Triple::x86_64)
+  return false;
+return SemaBuiltinVAStart(TheCall);
   case X86::BI_mm_prefetch: i = 1; l = 0; u = 3; break;

Can we do better than this? I think it'd be better to check that 
`__builtin_ms_va_start` only occurs in a function using the MS ABI's variadic 
calling convention, and `__builtin_va_start` only occurs in a function using 
the normal variadic C calling convention.


http://reviews.llvm.org/D1623



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


Re: [PATCH] D1623: Support __builtin_ms_va_list.

2015-08-28 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/CodeGen/CGExprScalar.cpp:3387-3392
@@ -3386,4 +3386,8 @@
 
-  llvm::Value *ArgValue = CGF.EmitVAListRef(VE->getSubExpr());
-  llvm::Value *ArgPtr = CGF.EmitVAArg(ArgValue, VE->getType());
+  llvm::Value *ArgValue = VE->isMicrosoftABI() ?
+CGF.EmitMSVAListRef(VE->getSubExpr()) :
+CGF.EmitVAListRef(VE->getSubExpr());
+  llvm::Value *ArgPtr = VE->isMicrosoftABI() ?
+CGF.EmitMSVAArg(ArgValue, VE->getType()) :
+CGF.EmitVAArg(ArgValue, VE->getType());
   llvm::Type *ArgTy = ConvertType(VE->getType());

rsmith wrote:
> Do you really need this dispatch? `CodeGenFunction` dispatches this to the 
> function's ABI info class, which should do the right thing already.
Hmm, scratch that, it's entirely possible for an MS VA list to get passed into 
a non-MS-ABI function and then to have __builtin_va_arg called on it.


http://reviews.llvm.org/D1623



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


[PATCH] D12466: Fix empty -L Path on OSX hosts

2015-08-28 Thread Martell Malone via cfe-commits
martell created this revision.
martell added reviewers: rnk, yaron.keren.
martell added a subscriber: cfe-commits.
martell set the repository for this revision to rL LLVM.

Not quite sure if this is the proper way to fix this.
This is currently my work around when working from an OSX host though.

I think I need some feedback from either rnk or yaron on how to fix this.
I assume the path is supposed to be "." and not an empty string as it is on mac.
I can't reproduce this issue on linux or windows also.

Repository:
  rL LLVM

http://reviews.llvm.org/D12466

Files:
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9267,6 +9267,7 @@
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   const ToolChain::path_list Paths = TC.getFilePaths();
   for (const auto &Path : Paths)
+  if(Path.length() > 0)
 CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + Path));

   AddLinkerInputs(TC, Inputs, Args, CmdArgs);


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9267,6 +9267,7 @@
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   const ToolChain::path_list Paths = TC.getFilePaths();
   for (const auto &Path : Paths)
+  if(Path.length() > 0)
 CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + Path));

   AddLinkerInputs(TC, Inputs, Args, CmdArgs);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r246355 - Add a check for a function we're not testing.

2015-08-28 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Fri Aug 28 21:59:37 2015
New Revision: 246355

URL: http://llvm.org/viewvc/llvm-project?rev=246355&view=rev
Log:
Add a check for a function we're not testing.

Modified:
cfe/trunk/test/CodeGen/attr-target-x86.c

Modified: cfe/trunk/test/CodeGen/attr-target-x86.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-target-x86.c?rev=246355&r1=246354&r2=246355&view=diff
==
--- cfe/trunk/test/CodeGen/attr-target-x86.c (original)
+++ cfe/trunk/test/CodeGen/attr-target-x86.c Fri Aug 28 21:59:37 2015
@@ -24,6 +24,7 @@ int __attribute__((target("no-aes, arch=
 // We're currently ignoring the fpmath attribute so koala should be identical 
to baz and bar.
 // CHECK: koala{{.*}} #0
 // CHECK: echidna{{.*}} #2
+// CHECK: panda{{.*}} #3
 // CHECK: bar{{.*}} #0
 // CHECK: qux{{.*}} #1
 // CHECK: qax{{.*}} #4


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