r298978 - Reverted r298976 [OpenCL] Added parsing for OpenCL vector types.

2017-03-28 Thread Egor Churaev via cfe-commits
Author: echuraev
Date: Wed Mar 29 00:40:45 2017
New Revision: 298978

URL: http://llvm.org/viewvc/llvm-project?rev=298978=rev
Log:
Reverted r298976 [OpenCL] Added parsing for OpenCL vector types.

Removed:
cfe/trunk/test/Parser/vector-cast-define.cl
Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Parse/ParseExpr.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=298978=298977=298978=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Wed Mar 29 00:40:45 2017
@@ -1449,12 +1449,10 @@ private:
   ExprResult ParseCastExpression(bool isUnaryExpression,
  bool isAddressOfOperand,
  bool ,
- TypeCastState isTypeCast,
- bool isVectorLiteral = false);
+ TypeCastState isTypeCast);
   ExprResult ParseCastExpression(bool isUnaryExpression,
  bool isAddressOfOperand = false,
- TypeCastState isTypeCast = NotTypeCast,
- bool isVectorLiteral = false);
+ TypeCastState isTypeCast = NotTypeCast);
 
   /// Returns true if the next token cannot start an expression.
   bool isNotExpressionStart();

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=298978=298977=298978=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Mar 29 00:40:45 2017
@@ -473,14 +473,12 @@ Parser::ParseRHSOfBinaryExpression(ExprR
 ///
 ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
bool isAddressOfOperand,
-   TypeCastState isTypeCast,
-   bool isVectorLiteral) {
+   TypeCastState isTypeCast) {
   bool NotCastExpr;
   ExprResult Res = ParseCastExpression(isUnaryExpression,
isAddressOfOperand,
NotCastExpr,
-   isTypeCast,
-   isVectorLiteral);
+   isTypeCast);
   if (NotCastExpr)
 Diag(Tok, diag::err_expected_expression);
   return Res;
@@ -696,8 +694,7 @@ class CastExpressionIdValidator : public
 ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
bool isAddressOfOperand,
bool ,
-   TypeCastState isTypeCast,
-   bool isVectorLiteral) {
+   TypeCastState isTypeCast) {
   ExprResult Res;
   tok::TokenKind SavedKind = Tok.getKind();
   NotCastExpr = false;
@@ -725,9 +722,6 @@ ExprResult Parser::ParseCastExpression(b
 Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/,
isTypeCast == IsTypeCast, CastTy, RParenLoc);
 
-if (isVectorLiteral)
-return Res;
-
 switch (ParenExprType) {
 case SimpleExpr:   break;// Nothing else to do.
 case CompoundStmt: break;  // Nothing else to do.
@@ -2356,48 +2350,6 @@ Parser::ParseParenExpression(ParenParseO
 return ParseCompoundLiteralExpression(Ty.get(), OpenLoc, RParenLoc);
   }
 
-  if (Tok.is(tok::l_paren)) {
-// This could be OpenCL vector Literals
-if (getLangOpts().OpenCL)
-{
-  TypeResult Ty;
-  {
-InMessageExpressionRAIIObject InMessage(*this, false);
-Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo);
-  }
-  if(Ty.isInvalid())
-  {
- return ExprError();
-  }
-  QualType QT = Ty.get().get().getCanonicalType();
-  if (QT->isVectorType())
-  {
-// We parsed '(' vector-type-name ')' followed by '('
-
-// Parse the cast-expression that follows it next.
-// isVectorLiteral = true will make sure we don't parse any
-// Postfix expression yet
-Result = ParseCastExpression(/*isUnaryExpression=*/false,
- /*isAddressOfOperand=*/false,
- /*isTypeCast=*/IsTypeCast,
- /*isVectorLiteral=*/true);
-
-if (!Result.isInvalid()) {
-  Result = Actions.ActOnCastExpr(getCurScope(), OpenLoc,
- DeclaratorInfo, 

Re: r298976 - [OpenCL] Added parsing for OpenCL vector types.

2017-03-28 Thread Dean Michael Berris via cfe-commits
Thanks Egor!

On Wed, Mar 29, 2017 at 4:51 PM Egor Churaev  wrote:

> I see it. I'm reverting this patch and I'll investigate why it has happend.
>
> 2017-03-29 8:43 GMT+03:00 Dean Michael Berris :
>
> This seems to have broken multiple builds.
>
> On Wed, Mar 29, 2017 at 4:20 PM Egor Churaev via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: echuraev
> Date: Wed Mar 29 00:08:18 2017
> New Revision: 298976
>
> URL: http://llvm.org/viewvc/llvm-project?rev=298976=rev
> Log:
> [OpenCL] Added parsing for OpenCL vector types.
>
> Reviewers: cfe-commits, Anastasia
>
> Reviewed By: Anastasia
>
> Subscribers: yaxunl, bader
>
> Differential Revision: https://reviews.llvm.org/D31183
>
> Added:
> cfe/trunk/test/Parser/vector-cast-define.cl
> Modified:
> cfe/trunk/include/clang/Parse/Parser.h
> cfe/trunk/lib/Parse/ParseExpr.cpp
>
> Modified: cfe/trunk/include/clang/Parse/Parser.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=298976=298975=298976=diff
>
> ==
> --- cfe/trunk/include/clang/Parse/Parser.h (original)
> +++ cfe/trunk/include/clang/Parse/Parser.h Wed Mar 29 00:08:18 2017
> @@ -1449,10 +1449,12 @@ private:
>ExprResult ParseCastExpression(bool isUnaryExpression,
>   bool isAddressOfOperand,
>   bool ,
> - TypeCastState isTypeCast);
> + TypeCastState isTypeCast,
> + bool isVectorLiteral = false);
>ExprResult ParseCastExpression(bool isUnaryExpression,
>   bool isAddressOfOperand = false,
> - TypeCastState isTypeCast = NotTypeCast);
> + TypeCastState isTypeCast = NotTypeCast,
> + bool isVectorLiteral = false);
>
>/// Returns true if the next token cannot start an expression.
>bool isNotExpressionStart();
>
> Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=298976=298975=298976=diff
>
> ==
> --- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Mar 29 00:08:18 2017
> @@ -473,12 +473,14 @@ Parser::ParseRHSOfBinaryExpression(ExprR
>  ///
>  ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
> bool isAddressOfOperand,
> -   TypeCastState isTypeCast) {
> +   TypeCastState isTypeCast,
> +   bool isVectorLiteral) {
>bool NotCastExpr;
>ExprResult Res = ParseCastExpression(isUnaryExpression,
> isAddressOfOperand,
> NotCastExpr,
> -   isTypeCast);
> +   isTypeCast,
> +   isVectorLiteral);
>if (NotCastExpr)
>  Diag(Tok, diag::err_expected_expression);
>return Res;
> @@ -694,7 +696,8 @@ class CastExpressionIdValidator : public
>  ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
> bool isAddressOfOperand,
> bool ,
> -   TypeCastState isTypeCast) {
> +   TypeCastState isTypeCast,
> +   bool isVectorLiteral) {
>ExprResult Res;
>tok::TokenKind SavedKind = Tok.getKind();
>NotCastExpr = false;
> @@ -722,6 +725,9 @@ ExprResult Parser::ParseCastExpression(b
>  Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/,
> isTypeCast == IsTypeCast, CastTy,
> RParenLoc);
>
> +if (isVectorLiteral)
> +return Res;
> +
>  switch (ParenExprType) {
>  case SimpleExpr:   break;// Nothing else to do.
>  case CompoundStmt: break;  // Nothing else to do.
> @@ -2350,6 +2356,48 @@ Parser::ParseParenExpression(ParenParseO
>  return ParseCompoundLiteralExpression(Ty.get(), OpenLoc,
> RParenLoc);
>}
>
> +  if (Tok.is(tok::l_paren)) {
> +// This could be OpenCL vector Literals
> +if (getLangOpts().OpenCL)
> +{
> +  TypeResult Ty;
> +  {
> +InMessageExpressionRAIIObject InMessage(*this, false);
> +Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo);
> +  }
> +  if(Ty.isInvalid())
> +  {
> + return ExprError();
> +  }
> +  QualType QT = Ty.get().get().getCanonicalType();
> +  if 

Re: r298976 - [OpenCL] Added parsing for OpenCL vector types.

2017-03-28 Thread Egor Churaev via cfe-commits
I see it. I'm reverting this patch and I'll investigate why it has happend.

2017-03-29 8:43 GMT+03:00 Dean Michael Berris :

> This seems to have broken multiple builds.
>
> On Wed, Mar 29, 2017 at 4:20 PM Egor Churaev via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: echuraev
>> Date: Wed Mar 29 00:08:18 2017
>> New Revision: 298976
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=298976=rev
>> Log:
>> [OpenCL] Added parsing for OpenCL vector types.
>>
>> Reviewers: cfe-commits, Anastasia
>>
>> Reviewed By: Anastasia
>>
>> Subscribers: yaxunl, bader
>>
>> Differential Revision: https://reviews.llvm.org/D31183
>>
>> Added:
>> cfe/trunk/test/Parser/vector-cast-define.cl
>> Modified:
>> cfe/trunk/include/clang/Parse/Parser.h
>> cfe/trunk/lib/Parse/ParseExpr.cpp
>>
>> Modified: cfe/trunk/include/clang/Parse/Parser.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
>> clang/Parse/Parser.h?rev=298976=298975=298976=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Parse/Parser.h (original)
>> +++ cfe/trunk/include/clang/Parse/Parser.h Wed Mar 29 00:08:18 2017
>> @@ -1449,10 +1449,12 @@ private:
>>ExprResult ParseCastExpression(bool isUnaryExpression,
>>   bool isAddressOfOperand,
>>   bool ,
>> - TypeCastState isTypeCast);
>> + TypeCastState isTypeCast,
>> + bool isVectorLiteral = false);
>>ExprResult ParseCastExpression(bool isUnaryExpression,
>>   bool isAddressOfOperand = false,
>> - TypeCastState isTypeCast = NotTypeCast);
>> + TypeCastState isTypeCast = NotTypeCast,
>> + bool isVectorLiteral = false);
>>
>>/// Returns true if the next token cannot start an expression.
>>bool isNotExpressionStart();
>>
>> Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/
>> ParseExpr.cpp?rev=298976=298975=298976=diff
>> 
>> ==
>> --- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
>> +++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Mar 29 00:08:18 2017
>> @@ -473,12 +473,14 @@ Parser::ParseRHSOfBinaryExpression(ExprR
>>  ///
>>  ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
>> bool isAddressOfOperand,
>> -   TypeCastState isTypeCast) {
>> +   TypeCastState isTypeCast,
>> +   bool isVectorLiteral) {
>>bool NotCastExpr;
>>ExprResult Res = ParseCastExpression(isUnaryExpression,
>> isAddressOfOperand,
>> NotCastExpr,
>> -   isTypeCast);
>> +   isTypeCast,
>> +   isVectorLiteral);
>>if (NotCastExpr)
>>  Diag(Tok, diag::err_expected_expression);
>>return Res;
>> @@ -694,7 +696,8 @@ class CastExpressionIdValidator : public
>>  ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
>> bool isAddressOfOperand,
>> bool ,
>> -   TypeCastState isTypeCast) {
>> +   TypeCastState isTypeCast,
>> +   bool isVectorLiteral) {
>>ExprResult Res;
>>tok::TokenKind SavedKind = Tok.getKind();
>>NotCastExpr = false;
>> @@ -722,6 +725,9 @@ ExprResult Parser::ParseCastExpression(b
>>  Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/,
>> isTypeCast == IsTypeCast, CastTy,
>> RParenLoc);
>>
>> +if (isVectorLiteral)
>> +return Res;
>> +
>>  switch (ParenExprType) {
>>  case SimpleExpr:   break;// Nothing else to do.
>>  case CompoundStmt: break;  // Nothing else to do.
>> @@ -2350,6 +2356,48 @@ Parser::ParseParenExpression(ParenParseO
>>  return ParseCompoundLiteralExpression(Ty.get(), OpenLoc,
>> RParenLoc);
>>}
>>
>> +  if (Tok.is(tok::l_paren)) {
>> +// This could be OpenCL vector Literals
>> +if (getLangOpts().OpenCL)
>> +{
>> +  TypeResult Ty;
>> +  {
>> +InMessageExpressionRAIIObject InMessage(*this, false);
>> +Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo);
>> +  }
>> +  if(Ty.isInvalid())
>> +  {
>> + return ExprError();
>> +  }
>> +  QualType QT = Ty.get().get().getCanonicalType();
>> +  

Re: r298976 - [OpenCL] Added parsing for OpenCL vector types.

2017-03-28 Thread Dean Michael Berris via cfe-commits
This seems to have broken multiple builds.

On Wed, Mar 29, 2017 at 4:20 PM Egor Churaev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: echuraev
> Date: Wed Mar 29 00:08:18 2017
> New Revision: 298976
>
> URL: http://llvm.org/viewvc/llvm-project?rev=298976=rev
> Log:
> [OpenCL] Added parsing for OpenCL vector types.
>
> Reviewers: cfe-commits, Anastasia
>
> Reviewed By: Anastasia
>
> Subscribers: yaxunl, bader
>
> Differential Revision: https://reviews.llvm.org/D31183
>
> Added:
> cfe/trunk/test/Parser/vector-cast-define.cl
> Modified:
> cfe/trunk/include/clang/Parse/Parser.h
> cfe/trunk/lib/Parse/ParseExpr.cpp
>
> Modified: cfe/trunk/include/clang/Parse/Parser.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=298976=298975=298976=diff
>
> ==
> --- cfe/trunk/include/clang/Parse/Parser.h (original)
> +++ cfe/trunk/include/clang/Parse/Parser.h Wed Mar 29 00:08:18 2017
> @@ -1449,10 +1449,12 @@ private:
>ExprResult ParseCastExpression(bool isUnaryExpression,
>   bool isAddressOfOperand,
>   bool ,
> - TypeCastState isTypeCast);
> + TypeCastState isTypeCast,
> + bool isVectorLiteral = false);
>ExprResult ParseCastExpression(bool isUnaryExpression,
>   bool isAddressOfOperand = false,
> - TypeCastState isTypeCast = NotTypeCast);
> + TypeCastState isTypeCast = NotTypeCast,
> + bool isVectorLiteral = false);
>
>/// Returns true if the next token cannot start an expression.
>bool isNotExpressionStart();
>
> Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=298976=298975=298976=diff
>
> ==
> --- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Mar 29 00:08:18 2017
> @@ -473,12 +473,14 @@ Parser::ParseRHSOfBinaryExpression(ExprR
>  ///
>  ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
> bool isAddressOfOperand,
> -   TypeCastState isTypeCast) {
> +   TypeCastState isTypeCast,
> +   bool isVectorLiteral) {
>bool NotCastExpr;
>ExprResult Res = ParseCastExpression(isUnaryExpression,
> isAddressOfOperand,
> NotCastExpr,
> -   isTypeCast);
> +   isTypeCast,
> +   isVectorLiteral);
>if (NotCastExpr)
>  Diag(Tok, diag::err_expected_expression);
>return Res;
> @@ -694,7 +696,8 @@ class CastExpressionIdValidator : public
>  ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
> bool isAddressOfOperand,
> bool ,
> -   TypeCastState isTypeCast) {
> +   TypeCastState isTypeCast,
> +   bool isVectorLiteral) {
>ExprResult Res;
>tok::TokenKind SavedKind = Tok.getKind();
>NotCastExpr = false;
> @@ -722,6 +725,9 @@ ExprResult Parser::ParseCastExpression(b
>  Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/,
> isTypeCast == IsTypeCast, CastTy,
> RParenLoc);
>
> +if (isVectorLiteral)
> +return Res;
> +
>  switch (ParenExprType) {
>  case SimpleExpr:   break;// Nothing else to do.
>  case CompoundStmt: break;  // Nothing else to do.
> @@ -2350,6 +2356,48 @@ Parser::ParseParenExpression(ParenParseO
>  return ParseCompoundLiteralExpression(Ty.get(), OpenLoc,
> RParenLoc);
>}
>
> +  if (Tok.is(tok::l_paren)) {
> +// This could be OpenCL vector Literals
> +if (getLangOpts().OpenCL)
> +{
> +  TypeResult Ty;
> +  {
> +InMessageExpressionRAIIObject InMessage(*this, false);
> +Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo);
> +  }
> +  if(Ty.isInvalid())
> +  {
> + return ExprError();
> +  }
> +  QualType QT = Ty.get().get().getCanonicalType();
> +  if (QT->isVectorType())
> +  {
> +// We parsed '(' vector-type-name ')' followed by '('
> +
> +// Parse the cast-expression that follows it next.
> +// isVectorLiteral = true will make sure we don't parse any
> +

r298976 - [OpenCL] Added parsing for OpenCL vector types.

2017-03-28 Thread Egor Churaev via cfe-commits
Author: echuraev
Date: Wed Mar 29 00:08:18 2017
New Revision: 298976

URL: http://llvm.org/viewvc/llvm-project?rev=298976=rev
Log:
[OpenCL] Added parsing for OpenCL vector types.

Reviewers: cfe-commits, Anastasia

Reviewed By: Anastasia

Subscribers: yaxunl, bader

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

Added:
cfe/trunk/test/Parser/vector-cast-define.cl
Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Parse/ParseExpr.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=298976=298975=298976=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Wed Mar 29 00:08:18 2017
@@ -1449,10 +1449,12 @@ private:
   ExprResult ParseCastExpression(bool isUnaryExpression,
  bool isAddressOfOperand,
  bool ,
- TypeCastState isTypeCast);
+ TypeCastState isTypeCast,
+ bool isVectorLiteral = false);
   ExprResult ParseCastExpression(bool isUnaryExpression,
  bool isAddressOfOperand = false,
- TypeCastState isTypeCast = NotTypeCast);
+ TypeCastState isTypeCast = NotTypeCast,
+ bool isVectorLiteral = false);
 
   /// Returns true if the next token cannot start an expression.
   bool isNotExpressionStart();

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=298976=298975=298976=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Mar 29 00:08:18 2017
@@ -473,12 +473,14 @@ Parser::ParseRHSOfBinaryExpression(ExprR
 ///
 ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
bool isAddressOfOperand,
-   TypeCastState isTypeCast) {
+   TypeCastState isTypeCast,
+   bool isVectorLiteral) {
   bool NotCastExpr;
   ExprResult Res = ParseCastExpression(isUnaryExpression,
isAddressOfOperand,
NotCastExpr,
-   isTypeCast);
+   isTypeCast,
+   isVectorLiteral);
   if (NotCastExpr)
 Diag(Tok, diag::err_expected_expression);
   return Res;
@@ -694,7 +696,8 @@ class CastExpressionIdValidator : public
 ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
bool isAddressOfOperand,
bool ,
-   TypeCastState isTypeCast) {
+   TypeCastState isTypeCast,
+   bool isVectorLiteral) {
   ExprResult Res;
   tok::TokenKind SavedKind = Tok.getKind();
   NotCastExpr = false;
@@ -722,6 +725,9 @@ ExprResult Parser::ParseCastExpression(b
 Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/,
isTypeCast == IsTypeCast, CastTy, RParenLoc);
 
+if (isVectorLiteral)
+return Res;
+
 switch (ParenExprType) {
 case SimpleExpr:   break;// Nothing else to do.
 case CompoundStmt: break;  // Nothing else to do.
@@ -2350,6 +2356,48 @@ Parser::ParseParenExpression(ParenParseO
 return ParseCompoundLiteralExpression(Ty.get(), OpenLoc, RParenLoc);
   }
 
+  if (Tok.is(tok::l_paren)) {
+// This could be OpenCL vector Literals
+if (getLangOpts().OpenCL)
+{
+  TypeResult Ty;
+  {
+InMessageExpressionRAIIObject InMessage(*this, false);
+Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo);
+  }
+  if(Ty.isInvalid())
+  {
+ return ExprError();
+  }
+  QualType QT = Ty.get().get().getCanonicalType();
+  if (QT->isVectorType())
+  {
+// We parsed '(' vector-type-name ')' followed by '('
+
+// Parse the cast-expression that follows it next.
+// isVectorLiteral = true will make sure we don't parse any
+// Postfix expression yet
+Result = ParseCastExpression(/*isUnaryExpression=*/false,
+ /*isAddressOfOperand=*/false,
+ /*isTypeCast=*/IsTypeCast,
+ /*isVectorLiteral=*/true);
+
+if (!Result.isInvalid()) {
+ 

[PATCH] D31235: Enhance -Wshadow to warn when shadowing typedefs or type aliases

2017-03-28 Thread Ahmed Asadi via Phabricator via cfe-commits
ahmedasadi updated this revision to Diff 93342.
ahmedasadi marked 4 inline comments as done.

https://reviews.llvm.org/D31235

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/warn-shadow.cpp

Index: test/SemaCXX/warn-shadow.cpp
===
--- test/SemaCXX/warn-shadow.cpp
+++ test/SemaCXX/warn-shadow.cpp
@@ -1,20 +1,27 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -Wshadow-all %s
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c++11 -Wshadow-all %s
 
 namespace {
   int i; // expected-note {{previous declaration is here}}
 }
 
 namespace one {
 namespace two {
   int j; // expected-note {{previous declaration is here}}
+  typedef int jj; // expected-note 2 {{previous declaration is here}}
+  using jjj=int; // expected-note 2 {{previous declaration is here}}
 }
 }
 
 namespace xx {
   int m;
+  typedef int mm;
+  using mmm=int;
+
 }
 namespace yy {
   int m;
+  typedef char mm;
+  using mmm=char;
 }
 
 using namespace one::two;
@@ -25,14 +32,19 @@
   int i; // expected-warning {{declaration shadows a variable in namespace '(anonymous)'}}
   int j; // expected-warning {{declaration shadows a variable in namespace 'one::two'}}
   int m;
+  int mm;
+  int mmm;
 }
 
 class A {
-  static int data; // expected-note {{previous declaration}}
-  // expected-note@+1 {{previous declaration}}
+  static int data; // expected-note 1 {{previous declaration}}
+  // expected-note@+1 1 {{previous declaration}}
   int field;
   int f1, f2, f3, f4; // expected-note 8 {{previous declaration is here}}
 
+  typedef int a1; // expected-note 2 {{previous declaration}}
+  using a2=int; // expected-note 2 {{previous declaration}}
+
   // The initialization is safe, but the modifications are not.
   A(int f1, int f2, int f3, int f4) // expected-note-re 4 {{variable 'f{{[0-4]}}' is declared here}}
 	  : f1(f1) {
@@ -50,6 +62,28 @@
   void test() {
 char *field; // expected-warning {{declaration shadows a field of 'A'}}
 char *data; // expected-warning {{declaration shadows a static data member of 'A'}}
+char *a1; // no warning 
+char *a2; // no warning
+char *jj; // no warning
+char *jjj; // no warning
+  }
+
+  void test2() {
+typedef char field; // no warning
+typedef char data; // no warning
+typedef char a1; // expected-warning {{declaration shadows a typedef in 'A'}}
+typedef char a2; // expected-warning {{declaration shadows a type alias in 'A'}}
+typedef char jj; // expected-warning {{declaration shadows a typedef in namespace 'one::two'}}
+typedef char jjj; // expected-warning {{declaration shadows a type alias in namespace 'one::two'}}
+  }
+
+  void test3() {
+using field=char; // no warning
+using data=char; // no warning
+using a1=char; // expected-warning {{declaration shadows a typedef in 'A'}}
+using a2=char; // expected-warning {{declaration shadows a type alias in 'A'}}
+using jj=char; // expected-warning {{declaration shadows a typedef in namespace 'one::two'}}
+using jjj=char; // expected-warning {{declaration shadows a type alias in namespace 'one::two'}}
   }
 };
 
@@ -63,13 +97,23 @@
 namespace rdar8900456 {
 struct Foo {
   static void Baz();
+  static void Baz1();
+  static void Baz2();
 private:
   int Bar;
 };
 
 void Foo::Baz() {
   double Bar = 12; // Don't warn.
 }
+
+void Foo::Baz1() {
+  typedef int Bar; // Don't warn.
+}
+
+void Foo::Baz2() {
+  using Bar=int; // Don't warn.
+}
 }
 
 // http://llvm.org/PR9160
@@ -87,23 +131,68 @@
 };
 }
 
-extern int bob; // expected-note {{previous declaration is here}}
+extern int bob; // expected-note 1 {{previous declaration is here}}
+typedef int bob1; // expected-note 2 {{previous declaration is here}}
+using bob2=int; // expected-note 2 {{previous declaration is here}}
 
 // rdar://8883302
 void rdar8883302() {
   extern int bob; // don't warn for shadowing.
 }
 
 void test8() {
   int bob; // expected-warning {{declaration shadows a variable in the global namespace}}
+  int bob1; //no warning
+  int bob2; // no warning
+}
+
+void test9() {
+  typedef int bob; // no warning
+  typedef int bob1; // expected-warning {{declaration shadows a typedef in the global namespace}}
+  typedef int bob2; // expected-warning {{declaration shadows a type alias in the global namespace}}
+}
+
+void test10() {
+  using bob=int; // no warning
+  using bob1=int; // expected-warning {{declaration shadows a typedef in the global namespace}}
+  using bob2=int; // expected-warning {{declaration shadows a type alias in the global namespace}}
 }
 
 namespace rdar29067894 {
 
 void avoidWarningWhenRedefining(int b) { // expected-note {{previous definition is here}}
   int a = 0; // expected-note {{previous definition is here}}
   int a = 1; // expected-error {{redefinition of 'a'}}
   int b = 2; // expected-error {{redefinition of 'b'}}
+
+  using c=char; // expected-note {{previous definition is 

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

2017-03-28 Thread Erik Nyquist via Phabricator via cfe-commits
enyquist updated this revision to Diff 93341.
enyquist added a comment.

Apologies-- forgot to update a comment


Repository:
  rL LLVM

https://reviews.llvm.org/D28462

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

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

[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

2017-03-28 Thread Tony Tye via Phabricator via cfe-commits
t-tye added inline comments.



Comment at: include/clang/AST/ASTContext.h:2319
 return AddrSpaceMapMangling || 
-   AS < LangAS::Offset || 
-   AS >= LangAS::Offset + LangAS::Count;
+   AS > LangAS::target_first;
   }

Should this be >= since it wants to return for all target address spaces, and 
target_first is the first one?



Comment at: include/clang/AST/Type.h:336-342
+  /// Get the address space value used in diagnostics.
+  unsigned getAddressSpacePrintValue() const {
+unsigned AS = getAddressSpace();
+if (AS >= LangAS::target_first)
+  return AS - LangAS::target_first;
+return AS;
+  }

Is this the right thing to do? This is making the CLANG named address spaces 
have the same numbers as the target-specific address space numbers which would 
seem rather confusing.

What do the diagnostics want to display? For example, they could display the 
address space as a human readable form such as "Default", "OpenCL-global", 
CUDA-device", "target-specific(5)", etc. To do that this function could take an 
iostream and a LangAS value and use << to write to the iostream.


https://reviews.llvm.org/D31404



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


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

2017-03-28 Thread Erik Nyquist via Phabricator via cfe-commits
enyquist updated this revision to Diff 9.
enyquist marked 2 inline comments as done.

Repository:
  rL LLVM

https://reviews.llvm.org/D28462

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

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

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

2017-03-28 Thread Erik Nyquist via Phabricator via cfe-commits
enyquist added inline comments.



Comment at: lib/Format/WhitespaceManager.cpp:413
+
+  while (Param && !Param->is(tok::l_paren)) {
+if (!Param->is(tok::identifier) && !Param->is(tok::comma))

djasper wrote:
> enyquist wrote:
> > djasper wrote:
> > > I think you should be able to use Current.MatchingParen here.
> > Hmm, I couldn't make this work... I just replaced this line with
> > 
> > while (Param && Param != Current->MatchingParen)
> > 
> > But it must not be doing what I think it's doing, since it made some tests 
> > fail.
> > Mind you, my C-brain might be taking over here, please let me know if I'm 
> > using MatchingParen incorrectly
> You shouldn't need a while loop. Just:
> 
>   if (!Current->MatchingParen || !Current->MatchingParen->Previous)
> return false;
>   Param = Param->MatchingParen->Previous;
> 
> And with that, I think you can simplify all these methods a bit:
> 
>   static bool endsPPIdentifier(const FormatToken *Current) {
> if (!Current->Next || Current->Next->SpacesRequiredBefore == 0)
>   return false;
> 
> // If Current is a "(", skip past the parameter list.
> if (Current->is(tok::r_paren)) {
>   if (!Current->MatchingParen || !Current->MatchingParen->Previous)
> return false;
>   Current = Current->MatchingParen->Previous;
> }
> 
> const FormatToken *Keyword = Current->Previous;
> if (!Keyword || !Keyword->is(tok::pp_define))
>   return false;
> 
> return Current->is(tok::identifier);
>   }
> 
> Does that work? If so, I'd even suggest inlining this code directly into the 
> lambda instead of pulling out a function.
It seems that MatchingParen does not get set for parens surrounding a 
macro-function parameter list. So for now, a loop is needed. I was able to 
clean it up, though, and I've inlined the whole thing in the lambda.


Repository:
  rL LLVM

https://reviews.llvm.org/D28462



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


[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

2017-03-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 93329.
yaxunl added a comment.

Revised by Tony's comments.


https://reviews.llvm.org/D31404

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Type.h
  include/clang/Basic/AddressSpaces.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/AST/TypePrinter.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGObjCGNU.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCL/address-space-constant-initializers.cl
  test/CodeGenOpenCL/address-spaces.cl
  test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
  test/CodeGenOpenCL/vla.cl
  test/Sema/address_spaces.c
  test/Sema/invalid-assignment-constant-address-space.c

Index: test/Sema/invalid-assignment-constant-address-space.c
===
--- test/Sema/invalid-assignment-constant-address-space.c
+++ test/Sema/invalid-assignment-constant-address-space.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
 
-#define OPENCL_CONSTANT 8388354
-int __attribute__((address_space(OPENCL_CONSTANT))) c[3] = {0};
+#define OPENCL_CONSTANT -5
+int __attribute__((address_space(OPENCL_CONSTANT))) c[3] = {0}; //expected-warning{{address space is negative}}
 
 void foo() {
   c[0] = 1; //expected-error{{read-only variable is not assignable}}
Index: test/Sema/address_spaces.c
===
--- test/Sema/address_spaces.c
+++ test/Sema/address_spaces.c
@@ -19,8 +19,8 @@
   _AS1 int array[5];  // expected-error {{automatic variable qualified with an address space}}
   _AS1 int arrarr[5][5]; // expected-error {{automatic variable qualified with an address space}}
 
-  __attribute__((address_space(-1))) int *_boundsA; // expected-error {{address space is negative}}
-  __attribute__((address_space(0x7F))) int *_boundsB;
+  __attribute__((address_space(-1))) int *_boundsA; // expected-warning {{address space is negative}}
+  __attribute__((address_space(0x7F))) int *_boundsB; // expected-error {{address space is larger than the maximum supported}}
   __attribute__((address_space(0x100))) int *_boundsC; // expected-error {{address space is larger than the maximum supported}}
   // chosen specifically to overflow 32 bits and come out reasonable
   __attribute__((address_space(4294967500))) int *_boundsD; // expected-error {{address space is larger than the maximum supported}}
Index: test/CodeGenOpenCL/vla.cl
===
--- test/CodeGenOpenCL/vla.cl
+++ test/CodeGenOpenCL/vla.cl
@@ -1,18 +1,26 @@
-// RUN: %clang_cc1 -emit-llvm -triple "spir-unknown-unknown" -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple "spir-unknown-unknown" -O0 -cl-std=CL2.0 -o - %s | FileCheck -check-prefixes=CHECK,SPIR %s
+// RUN: %clang_cc1 -emit-llvm -triple amdgcn-amd-amdhsa-opencl -O0 -cl-std=CL2.0 -o - %s | FileCheck -check-prefixes=CHECK,SPIR %s
+// RUN: %clang_cc1 -emit-llvm -triple amdgcn-amd-amdhsa-amdgizcl -O0 -cl-std=CL2.0 -o - %s | FileCheck -check-prefixes=CHECK,GIZ %s
 
 constant int sz0 = 5;
-// CHECK: @sz0 = addrspace(2) constant i32 5
+// SPIR: @sz0 = addrspace(2) constant i32 5
+// GIZ: @sz0 = addrspace(4) constant i32 5
 const global int sz1 = 16;
 // CHECK: @sz1 = addrspace(1) constant i32 16
 const constant int sz2 = 8;
-// CHECK: @sz2 = addrspace(2) constant i32 8
+// SPIR: @sz2 = addrspace(2) constant i32 8
+// GIZ: @sz2 = addrspace(4) constant i32 8
 // CHECK: @testvla.vla2 = internal addrspace(3) global [8 x i16] undef
 
 kernel void testvla()
 {
   int vla0[sz0];
-// CHECK: %vla0 = alloca [5 x i32]
+// SPIR: %vla0 = alloca [5 x i32]
+// SPIR-NOT: %vla0 = alloca [5 x i32]{{.*}}addrspace
+// GIZ: %vla0 = alloca [5 x i32]{{.*}}addrspace(5)
   char vla1[sz1];
-// CHECK: %vla1 = alloca [16 x i8]
+// SPIR: %vla1 = alloca [16 x i8]
+// SPIR-NOT: %vla1 = alloca [16 x i8]{{.*}}addrspace
+// GIZ: %vla1 = alloca [16 x i8]{{.*}}addrspace(5)
   local short vla2[sz2];
 }
Index: test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
===
--- test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
+++ test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
@@ -4,6 +4,6 @@
 // RUN: %clang_cc1 %s -O0 -triple amdgcn---amdgizcl -emit-llvm -o - | FileCheck -check-prefix=GIZ %s
 
 // CHECK: target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
-// GIZ: target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
+// GIZ: target datalayout = 

[PATCH] D23418: [analyzer] Added a reusable constraint system to the CloneDetector

2017-03-28 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai added a comment.

Hi Raphael,

Congratulate the patch was accepted!

> Well this patch won't change a lot with the false-positives or performance 
> (it's more refactoring) :)

So may I Teach CloneDetection about Qt Meta-Object Compiler 
 and filter other auto-generated source files 
base your patch? thanks a lot!

Regards,
Leslie Zhai


https://reviews.llvm.org/D23418



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


Re: r298956 - Default enable the rtm feature only on skylake and later for now because Intel disabled the feature on some haswell and broadwell processors:

2017-03-28 Thread Jim Grosbach via cfe-commits
SGTM 

Sent from my iPhone

> On Mar 28, 2017, at 5:25 PM, Eric Christopher  wrote:
> 
> 
> 
>> On Tue, Mar 28, 2017 at 4:31 PM Craig Topper  wrote:
>> So if you use -march=hsw the backend will think rtm is enabled, but clang 
>> will block the intrinsics in the frontend?
> 
> Yeah. I've come to the conclusion that I think we should remove the feature 
> from the backend too. Using the option/feature in the frontend (or during 
> codegen of any sort) will turn on the instruction in the backend and we 
> should just rely on the option/feature.
>  
>> 
>> Not sure what you mean by split the haswell and broadwell cpu.
> 
> Into something similar to how the skylake cpu is configured in the front end 
> with different feature sets. I don't really think it's a good idea here, but 
> I thought I'd raise it.
> 
> Thoughts?
> 
> -eric
>  
>> 
>> ~Craig
>> 
>> On Tue, Mar 28, 2017 at 4:18 PM, Eric Christopher  wrote:
>> Hi Craig, Quentin, Jim,
>> 
>> Just bringing this patch to your attention here. I haven't turned it off in 
>> the backend since some processors do support it and we want to allow the 
>> code generation, with this change we simply make the user use -mrtm to get 
>> the functionality for now.
>> 
>> Question: Do we want to split the haswell and broadwell cpu to handle this 
>> different feature set or just leave it as an optional "enable it yourself" 
>> since it's an errata fix?
>> 
>> I went ahead and committed with this question outstanding so that users 
>> won't get illegal instructions if they happen to have the affected units.
>> 
>> -eric
>> 
>> 
>> On Tue, Mar 28, 2017 at 4:15 PM Eric Christopher via cfe-commits 
>>  wrote:
>> Author: echristo
>> Date: Tue Mar 28 18:03:19 2017
>> New Revision: 298956
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=298956=rev
>> Log:
>> Default enable the rtm feature only on skylake and later for now because 
>> Intel disabled the feature on some haswell and broadwell processors:
>> 
>> http://www.intel.com/content/dam/www/public/us/en/documents/specification-updates/core-m-processor-family-spec-update.pdf
>> 
>> the -mrtm option will still work normally.
>> 
>> Modified:
>> cfe/trunk/lib/Basic/Targets.cpp
>> cfe/trunk/test/Preprocessor/predefined-arch-macros.c
>> 
>> Modified: cfe/trunk/lib/Basic/Targets.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=298956=298955=298956=diff
>> ==
>> --- cfe/trunk/lib/Basic/Targets.cpp (original)
>> +++ cfe/trunk/lib/Basic/Targets.cpp Tue Mar 28 18:03:19 2017
>> @@ -3194,6 +3194,7 @@ bool X86TargetInfo::initFeatureMap(
>>  setFeatureEnabledImpl(Features, "mpx", true);
>>  setFeatureEnabledImpl(Features, "sgx", true);
>>  setFeatureEnabledImpl(Features, "clflushopt", true);
>> +setFeatureEnabledImpl(Features, "rtm", true);
>>  LLVM_FALLTHROUGH;
>>case CK_Broadwell:
>>  setFeatureEnabledImpl(Features, "rdseed", true);
>> @@ -3204,7 +3205,6 @@ bool X86TargetInfo::initFeatureMap(
>>  setFeatureEnabledImpl(Features, "lzcnt", true);
>>  setFeatureEnabledImpl(Features, "bmi", true);
>>  setFeatureEnabledImpl(Features, "bmi2", true);
>> -setFeatureEnabledImpl(Features, "rtm", true);
>>  setFeatureEnabledImpl(Features, "fma", true);
>>  setFeatureEnabledImpl(Features, "movbe", true);
>>  LLVM_FALLTHROUGH;
>> 
>> Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=298956=298955=298956=diff
>> ==
>> --- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
>> +++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Tue Mar 28 18:03:19 
>> 2017
>> @@ -525,7 +525,6 @@
>>  // CHECK_CORE_AVX2_M32: #define __PCLMUL__ 1
>>  // CHECK_CORE_AVX2_M32: #define __POPCNT__ 1
>>  // CHECK_CORE_AVX2_M32: #define __RDRND__ 1
>> -// CHECK_CORE_AVX2_M32: #define __RTM__ 1
>>  // CHECK_CORE_AVX2_M32: #define __SSE2__ 1
>>  // CHECK_CORE_AVX2_M32: #define __SSE3__ 1
>>  // CHECK_CORE_AVX2_M32: #define __SSE4_1__ 1
>> @@ -555,7 +554,6 @@
>>  // CHECK_CORE_AVX2_M64: #define __PCLMUL__ 1
>>  // CHECK_CORE_AVX2_M64: #define __POPCNT__ 1
>>  // CHECK_CORE_AVX2_M64: #define __RDRND__ 1
>> -// CHECK_CORE_AVX2_M64: #define __RTM__ 1
>>  // CHECK_CORE_AVX2_M64: #define __SSE2_MATH__ 1
>>  // CHECK_CORE_AVX2_M64: #define __SSE2__ 1
>>  // CHECK_CORE_AVX2_M64: #define __SSE3__ 1
>> @@ -591,7 +589,6 @@
>>  // CHECK_BROADWELL_M32: #define __POPCNT__ 1
>>  // CHECK_BROADWELL_M32: #define __RDRND__ 1
>>  // CHECK_BROADWELL_M32: #define __RDSEED__ 1
>> -// CHECK_BROADWELL_M32: #define __RTM__ 1
>>  // CHECK_BROADWELL_M32: #define __SSE2__ 1
>>  // CHECK_BROADWELL_M32: #define __SSE3__ 1
>>  // 

Re: r298913 - Added `applyAtomicChanges` function.

2017-03-28 Thread Juergen Ributzka via cfe-commits
I reverted the commit in r298967. Please fix the cyclic dependency issue
found here:
http://lab.llvm.org:8080/green/job/clang-stage2-cmake-modulesRDA_build/4776/

Cheers,
Juergen

On Tue, Mar 28, 2017 at 6:05 AM, Eric Liu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ioeric
> Date: Tue Mar 28 08:05:32 2017
> New Revision: 298913
>
> URL: http://llvm.org/viewvc/llvm-project?rev=298913=rev
> Log:
> Added `applyAtomicChanges` function.
>
> Summary: ... which applies a set of `AtomicChange`s on code.
>
> Reviewers: klimek, djasper
>
> Reviewed By: djasper
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D30777
>
> Modified:
> cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
> cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
> cfe/trunk/unittests/Tooling/RefactoringTest.cpp
>
> Modified: cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Tooling/Refactoring/AtomicChange.h?rev=298913=
> 298912=298913=diff
> 
> ==
> --- cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h (original)
> +++ cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h Tue Mar 28
> 08:05:32 2017
> @@ -16,6 +16,7 @@
>  #define LLVM_CLANG_TOOLING_REFACTOR_ATOMICCHANGE_H
>
>  #include "clang/Basic/SourceManager.h"
> +#include "clang/Format/Format.h"
>  #include "clang/Tooling/Core/Replacement.h"
>  #include "llvm/ADT/StringRef.h"
>  #include "llvm/Support/Error.h"
> @@ -123,6 +124,39 @@ private:
>tooling::Replacements Replaces;
>  };
>
> +// Defines specs for applying changes.
> +struct ApplyChangesSpec {
> +  // If true, cleans up redundant/erroneous code around changed code with
> +  // clang-format's cleanup functionality, e.g. redundant commas around
> deleted
> +  // parameter or empty namespaces introduced by deletions.
> +  bool Cleanup = true;
> +
> +  format::FormatStyle Style = format::getNoStyle();
> +
> +  // Options for selectively formatting changes with clang-format:
> +  // kAll: Format all changed lines.
> +  // kNone: Don't format anything.
> +  // kViolations: Format lines exceeding the `ColumnLimit` in `Style`.
> +  enum FormatOption { kAll, kNone, kViolations };
> +
> +  FormatOption Format = kNone;
> +};
> +
> +/// \brief Applies all AtomicChanges in \p Changes to the \p Code.
> +///
> +/// This completely ignores the file path in each change and replaces
> them with
> +/// \p FilePath, i.e. callers are responsible for ensuring all changes
> are for
> +/// the same file.
> +///
> +/// \returns The changed code if all changes are applied successfully;
> +/// otherwise, an llvm::Error carrying llvm::StringError is returned (the
> Error
> +/// message can be converted to string with `llvm::toString()` and the
> +/// error_code should be ignored).
> +llvm::Expected
> +applyAtomicChanges(llvm::StringRef FilePath, llvm::StringRef Code,
> +   llvm::ArrayRef Changes,
> +   const ApplyChangesSpec );
> +
>  } // end namespace tooling
>  } // end namespace clang
>
>
> Modified: cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/
> Refactoring/AtomicChange.cpp?rev=298913=298912=298913=diff
> 
> ==
> --- cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp (original)
> +++ cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp Tue Mar 28
> 08:05:32 2017
> @@ -84,6 +84,116 @@ template <> struct MappingTraits
>  namespace clang {
>  namespace tooling {
> +namespace {
> +
> +// Returns true if there is any line that violates \p ColumnLimit in range
> +// [Start, End].
> +bool violatesColumnLimit(llvm::StringRef Code, unsigned ColumnLimit,
> + unsigned Start, unsigned End) {
> +  auto StartPos = Code.rfind('\n', Start);
> +  StartPos = (StartPos == llvm::StringRef::npos) ? 0 : StartPos + 1;
> +
> +  auto EndPos = Code.find("\n", End);
> +  if (EndPos == llvm::StringRef::npos)
> +EndPos = Code.size();
> +
> +  llvm::SmallVector Lines;
> +  Code.substr(StartPos, EndPos - StartPos).split(Lines, '\n');
> +  for (llvm::StringRef Line : Lines)
> +if (Line.size() > ColumnLimit)
> +  return true;
> +  return false;
> +}
> +
> +std::vector
> +getRangesForFormating(llvm::StringRef Code, unsigned ColumnLimit,
> +  ApplyChangesSpec::FormatOption Format,
> +  const clang::tooling::Replacements ) {
> +  // kNone suppresses formatting entirely.
> +  if (Format == ApplyChangesSpec::kNone)
> +return {};
> +  std::vector Ranges;
> +  // This works assuming that replacements are ordered by offset.
> +  // FIXME: use `getAffectedRanges()` to calculate when it does not
> include '\n'
> +  // at the end of an insertion in affected ranges.
> +  int Offset = 0;

r298967 - Revert "Added `applyAtomicChanges` function."

2017-03-28 Thread Juergen Ributzka via cfe-commits
Author: ributzka
Date: Tue Mar 28 19:24:36 2017
New Revision: 298967

URL: http://llvm.org/viewvc/llvm-project?rev=298967=rev
Log:
Revert "Added `applyAtomicChanges` function."

This broke GreenDragon:
http://lab.llvm.org:8080/green/job/clang-stage2-cmake-modulesRDA_build/4776/

Reverting this commit and all follow-up commits.

Modified:
cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Modified: cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h?rev=298967=298966=298967=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h (original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h Tue Mar 28 
19:24:36 2017
@@ -16,7 +16,6 @@
 #define LLVM_CLANG_TOOLING_REFACTOR_ATOMICCHANGE_H
 
 #include "clang/Basic/SourceManager.h"
-#include "clang/Format/Format.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
@@ -124,39 +123,6 @@ private:
   tooling::Replacements Replaces;
 };
 
-// Defines specs for applying changes.
-struct ApplyChangesSpec {
-  // If true, cleans up redundant/erroneous code around changed code with
-  // clang-format's cleanup functionality, e.g. redundant commas around deleted
-  // parameter or empty namespaces introduced by deletions.
-  bool Cleanup = true;
-
-  format::FormatStyle Style = format::getNoStyle();
-
-  // Options for selectively formatting changes with clang-format:
-  // kAll: Format all changed lines.
-  // kNone: Don't format anything.
-  // kViolations: Format lines exceeding the `ColumnLimit` in `Style`.
-  enum FormatOption { kAll, kNone, kViolations };
-
-  FormatOption Format = kNone;
-};
-
-/// \brief Applies all AtomicChanges in \p Changes to the \p Code.
-///
-/// This completely ignores the file path in each change and replaces them with
-/// \p FilePath, i.e. callers are responsible for ensuring all changes are for
-/// the same file.
-///
-/// \returns The changed code if all changes are applied successfully;
-/// otherwise, an llvm::Error carrying llvm::StringError is returned (the Error
-/// message can be converted to string with `llvm::toString()` and the
-/// error_code should be ignored).
-llvm::Expected
-applyAtomicChanges(llvm::StringRef FilePath, llvm::StringRef Code,
-   llvm::ArrayRef Changes,
-   const ApplyChangesSpec );
-
 } // end namespace tooling
 } // end namespace clang
 

Modified: cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp?rev=298967=298966=298967=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp Tue Mar 28 19:24:36 2017
@@ -84,116 +84,6 @@ template <> struct MappingTraits Lines;
-  Code.substr(StartPos, EndPos - StartPos).split(Lines, '\n');
-  for (llvm::StringRef Line : Lines)
-if (Line.size() > ColumnLimit)
-  return true;
-  return false;
-}
-
-std::vector
-getRangesForFormating(llvm::StringRef Code, unsigned ColumnLimit,
-  ApplyChangesSpec::FormatOption Format,
-  const clang::tooling::Replacements ) {
-  // kNone suppresses formatting entirely.
-  if (Format == ApplyChangesSpec::kNone)
-return {};
-  std::vector Ranges;
-  // This works assuming that replacements are ordered by offset.
-  // FIXME: use `getAffectedRanges()` to calculate when it does not include 
'\n'
-  // at the end of an insertion in affected ranges.
-  int Offset = 0;
-  for (const clang::tooling::Replacement  : Replaces) {
-int Start = R.getOffset() + Offset;
-int End = Start + R.getReplacementText().size();
-if (!R.getReplacementText().empty() &&
-R.getReplacementText().back() == '\n' && R.getLength() == 0 &&
-R.getOffset() > 0 && R.getOffset() <= Code.size() &&
-Code[R.getOffset() - 1] == '\n')
-  // If we are inserting at the start of a line and the replacement ends in
-  // a newline, we don't need to format the subsequent line.
-  --End;
-Offset += R.getReplacementText().size() - R.getLength();
-
-if (Format == ApplyChangesSpec::kAll ||
-violatesColumnLimit(Code, ColumnLimit, Start, End))
-  Ranges.emplace_back(Start, End - Start);
-  }
-  return Ranges;
-}
-
-inline llvm::Error make_string_error(const llvm::Twine ) {
-  return llvm::make_error(Message,
- llvm::inconvertibleErrorCode());
-}
-
-// Creates replacements for inserting/deleting #include headers.
-llvm::Expected
-createReplacementsForHeaders(llvm::StringRef 

r298966 - Revert "Try to unbreak buildbots after r298913."

2017-03-28 Thread Juergen Ributzka via cfe-commits
Author: ributzka
Date: Tue Mar 28 19:24:34 2017
New Revision: 298966

URL: http://llvm.org/viewvc/llvm-project?rev=298966=rev
Log:
Revert "Try to unbreak buildbots after r298913."

Modified:
cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Modified: cfe/trunk/unittests/Tooling/RefactoringTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RefactoringTest.cpp?rev=298966=298965=298966=diff
==
--- cfe/trunk/unittests/Tooling/RefactoringTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/RefactoringTest.cpp Tue Mar 28 19:24:34 2017
@@ -1513,17 +1513,21 @@ TEST_F(ApplyAtomicChangesTest, InsertsNe
 }
 
 TEST_F(ApplyAtomicChangesTest, RemoveAndSortIncludes) {
-  setInput("#include \"a\"\n"
-   "#include \"b\"\n"
-   "#include \"c\"\n"
-   "\n"
-   "int a;");
+  setInput(R"(
+#include "a"
+#include "b"
+#include "c"
+
+int a;
+  )");
   Changes.emplace_back(FilePath, "key1");
   Changes.back().removeHeader("b");
-  EXPECT_EQ("#include \"a\"\n"
-"#include \"c\"\n"
-"\n"
-"int a;",
+  EXPECT_EQ(R"(
+#include "a"
+#include "c"
+
+int a;
+  )",
 rewrite());
 }
 TEST_F(ApplyAtomicChangesTest, InsertsSystemIncludes) {
@@ -1549,19 +1553,23 @@ TEST_F(ApplyAtomicChangesTest, InsertsSy
 }
 
 TEST_F(ApplyAtomicChangesTest, RemoveSystemIncludes) {
-  setInput("#include \n"
-   "#include \n"
-   "\n"
-   "#include \"c\""
-   "\n"
-   "int a;");
+  setInput(R"(
+#include 
+#include 
+
+#include "c"
+
+int a;
+  )");
   Changes.emplace_back(FilePath, "key1");
   Changes.back().removeHeader("");
-  EXPECT_EQ("#include \n"
-"\n"
-"#include \"c\""
-"\n"
-"int a;",
+  EXPECT_EQ(R"(
+#include 
+
+#include "c"
+
+int a;
+  )",
 rewrite());
 }
 


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


r298965 - Revert "clangToolingRefactor: Add libdeps upon clangFormat in r298913."

2017-03-28 Thread Juergen Ributzka via cfe-commits
Author: ributzka
Date: Tue Mar 28 19:24:32 2017
New Revision: 298965

URL: http://llvm.org/viewvc/llvm-project?rev=298965=rev
Log:
Revert "clangToolingRefactor: Add libdeps upon clangFormat in r298913."

Modified:
cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt

Modified: cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt?rev=298965=298964=298965=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt (original)
+++ cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt Tue Mar 28 19:24:32 2017
@@ -8,6 +8,5 @@ add_clang_library(clangToolingRefactor
 
   LINK_LIBS
   clangBasic
-  clangFormat
   clangToolingCore
   )


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


[PATCH] D31276: Add #pragma clang fp

2017-03-28 Thread Adam Nemet via Phabricator via cfe-commits
anemet added a comment.

(Sorry about updating the title/description back and forth but arcanist is 
buggy)


https://reviews.llvm.org/D31276



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


[PATCH] D31276: Add #pragma clang fast_math

2017-03-28 Thread Adam Nemet via Phabricator via cfe-commits
anemet updated this revision to Diff 93325.
anemet retitled this revision from "Add #pragma clang fp" to "Add #pragma clang 
fast_math".
anemet edited the summary of this revision.
anemet added a comment.

Rename pragma from #pragma clang fast_math contract_fast(on/off) -> #pragma 
clang fp contract(on/fast/off)

No other functional change.


https://reviews.llvm.org/D31276

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/TokenKinds.def
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/Parse/ParsePragma.cpp
  lib/Parse/ParseStmt.cpp
  lib/Parse/Parser.cpp
  lib/Sema/SemaAttr.cpp
  test/CodeGen/fp-contract-fast-pragma.cpp
  test/CodeGen/fp-contract-on-pragma.cpp
  test/Parser/cxx11-stmt-attributes.cpp
  test/Parser/pragma-fp.cpp

Index: test/Parser/pragma-fp.cpp
===
--- /dev/null
+++ test/Parser/pragma-fp.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+void test_0(int *List, int Length) {
+/* expected-error@+1 {{missing option; expected contract}} */
+#pragma clang fp
+  for (int i = 0; i < Length; i++) {
+List[i] = i;
+  }
+}
+void test_1(int *List, int Length) {
+/* expected-error@+1 {{invalid option 'blah'; expected contract}} */
+#pragma clang fp blah
+  for (int i = 0; i < Length; i++) {
+List[i] = i;
+  }
+}
+
+void test_3(int *List, int Length) {
+/* expected-error@+1 {{expected '('}} */
+#pragma clang fp contract on
+  for (int i = 0; i < Length; i++) {
+List[i] = i;
+  }
+}
+
+void test_4(int *List, int Length) {
+/* expected-error@+1 {{unexpected argument 'while' to '#pragma clang fp contract'; expected 'on', 'fast' or 'off'}} */
+#pragma clang fp contract(while)
+  for (int i = 0; i < Length; i++) {
+List[i] = i;
+  }
+}
+
+void test_5(int *List, int Length) {
+/* expected-error@+1 {{unexpected argument 'maybe' to '#pragma clang fp contract'; expected 'on', 'fast' or 'off'}} */
+#pragma clang fp contract(maybe)
+  for (int i = 0; i < Length; i++) {
+List[i] = i;
+  }
+}
+
+void test_6(int *List, int Length) {
+/* expected-error@+1 {{expected ')'}} */
+#pragma clang fp contract(fast
+  for (int i = 0; i < Length; i++) {
+List[i] = i;
+  }
+}
+
+void test_7(int *List, int Length) {
+/* expected-warning@+1 {{extra tokens at end of '#pragma clang fp' - ignored}} */
+#pragma clang fp contract(fast) *
+  for (int i = 0; i < Length; i++) {
+List[i] = i;
+  }
+}
+
+void test_8(int *List, int Length) {
+  for (int i = 0; i < Length; i++) {
+List[i] = i;
+/* expected-error@+1 {{'#pragma clang fp' can only appear at file scope or at the start of a compound statement}} */
+#pragma clang fp contract(fast)
+  }
+}
Index: test/Parser/cxx11-stmt-attributes.cpp
===
--- test/Parser/cxx11-stmt-attributes.cpp
+++ test/Parser/cxx11-stmt-attributes.cpp
@@ -80,5 +80,6 @@
   {
 [[ ]] // expected-error {{an attribute list cannot appear here}}
 #pragma STDC FP_CONTRACT ON // expected-error {{can only appear at file scope or at the start of a compound statement}}
+#pragma clang fp contract(fast) // expected-error {{can only appear at file scope or at the start of a compound statement}}
   }
 }
Index: test/CodeGen/fp-contract-on-pragma.cpp
===
--- /dev/null
+++ test/CodeGen/fp-contract-on-pragma.cpp
@@ -0,0 +1,76 @@
+// RUN: %clang_cc1 -O3 -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s
+
+// Is FP_CONTRACT honored in a simple case?
+float fp_contract_1(float a, float b, float c) {
+// CHECK: _Z13fp_contract_1fff
+// CHECK: tail call float @llvm.fmuladd
+#pragma clang fp contract(on)
+  return a * b + c;
+}
+
+// Is FP_CONTRACT state cleared on exiting compound statements?
+float fp_contract_2(float a, float b, float c) {
+  // CHECK: _Z13fp_contract_2fff
+  // CHECK: %[[M:.+]] = fmul float %a, %b
+  // CHECK-NEXT: fadd float %[[M]], %c
+  {
+#pragma clang fp contract(on)
+  }
+  return a * b + c;
+}
+
+// Does FP_CONTRACT survive template instantiation?
+class Foo {};
+Foo operator+(Foo, Foo);
+
+template 
+T template_muladd(T a, T b, T c) {
+#pragma clang fp contract(on)
+  return a * b + c;
+}
+
+float fp_contract_3(float a, float b, float c) {
+  // CHECK: _Z13fp_contract_3fff
+  // CHECK: tail call float @llvm.fmuladd
+  return template_muladd(a, b, c);
+}
+
+template 
+class fp_contract_4 {
+  float method(float a, float b, float c) {
+#pragma clang fp contract(on)
+return a * b + c;
+  }
+};
+
+template class fp_contract_4;
+// CHECK: _ZN13fp_contract_4IiE6methodEfff
+// CHECK: tail call float @llvm.fmuladd
+
+// Check file-scoped FP_CONTRACT
+#pragma clang fp contract(on)
+float fp_contract_5(float a, float b, float c) {
+  // CHECK: _Z13fp_contract_5fff
+  // CHECK: tail call float @llvm.fmuladd
+  return a * b + c;
+}
+
+#pragma clang fp contract(off)
+float fp_contract_6(float a, 

[PATCH] D31022: Implement P0298R3: `std::byte`

2017-03-28 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added inline comments.



Comment at: 
test/std/language.support/support.types/byteops/xor.assign.pass.cpp:13
+
+// XFAIL: c++98, c++03, c++11, c++14
+

EricWF wrote:
> Nit. These should be `// UNSUPPORTED`. `XFAIL` is for bugs we need to fix.
I have mixed feeling about this, in some case I have a test that I want to make 
sure works in some conditions and does not in other. Using UNSUPPORTED will 
"hide" such cases if they're unexpectingly passing.

Having to duplicate the test identically in a ".failed.cpp" with a `REQUIRE:` 
identical to the `UNSUPPORTED` in the `.pass.cpp` is adding some unnecessary 
overhead and maintenance burden as well. 


https://reviews.llvm.org/D31022



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


Re: r298956 - Default enable the rtm feature only on skylake and later for now because Intel disabled the feature on some haswell and broadwell processors:

2017-03-28 Thread Eric Christopher via cfe-commits
On Tue, Mar 28, 2017 at 4:31 PM Craig Topper  wrote:

> So if you use -march=hsw the backend will think rtm is enabled, but clang
> will block the intrinsics in the frontend?
>

Yeah. I've come to the conclusion that I think we should remove the feature
from the backend too. Using the option/feature in the frontend (or during
codegen of any sort) will turn on the instruction in the backend and we
should just rely on the option/feature.


>
> Not sure what you mean by split the haswell and broadwell cpu.
>

Into something similar to how the skylake cpu is configured in the front
end with different feature sets. I don't really think it's a good idea
here, but I thought I'd raise it.

Thoughts?

-eric


>
> ~Craig
>
> On Tue, Mar 28, 2017 at 4:18 PM, Eric Christopher 
> wrote:
>
> Hi Craig, Quentin, Jim,
>
> Just bringing this patch to your attention here. I haven't turned it off
> in the backend since some processors do support it and we want to allow the
> code generation, with this change we simply make the user use -mrtm to get
> the functionality for now.
>
> Question: Do we want to split the haswell and broadwell cpu to handle this
> different feature set or just leave it as an optional "enable it yourself"
> since it's an errata fix?
>
> I went ahead and committed with this question outstanding so that users
> won't get illegal instructions if they happen to have the affected units.
>
> -eric
>
>
> On Tue, Mar 28, 2017 at 4:15 PM Eric Christopher via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: echristo
> Date: Tue Mar 28 18:03:19 2017
> New Revision: 298956
>
> URL: http://llvm.org/viewvc/llvm-project?rev=298956=rev
> Log:
> Default enable the rtm feature only on skylake and later for now because
> Intel disabled the feature on some haswell and broadwell processors:
>
>
> http://www.intel.com/content/dam/www/public/us/en/documents/specification-updates/core-m-processor-family-spec-update.pdf
>
> the -mrtm option will still work normally.
>
> Modified:
> cfe/trunk/lib/Basic/Targets.cpp
> cfe/trunk/test/Preprocessor/predefined-arch-macros.c
>
> Modified: cfe/trunk/lib/Basic/Targets.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=298956=298955=298956=diff
>
> ==
> --- cfe/trunk/lib/Basic/Targets.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets.cpp Tue Mar 28 18:03:19 2017
> @@ -3194,6 +3194,7 @@ bool X86TargetInfo::initFeatureMap(
>  setFeatureEnabledImpl(Features, "mpx", true);
>  setFeatureEnabledImpl(Features, "sgx", true);
>  setFeatureEnabledImpl(Features, "clflushopt", true);
> +setFeatureEnabledImpl(Features, "rtm", true);
>  LLVM_FALLTHROUGH;
>case CK_Broadwell:
>  setFeatureEnabledImpl(Features, "rdseed", true);
> @@ -3204,7 +3205,6 @@ bool X86TargetInfo::initFeatureMap(
>  setFeatureEnabledImpl(Features, "lzcnt", true);
>  setFeatureEnabledImpl(Features, "bmi", true);
>  setFeatureEnabledImpl(Features, "bmi2", true);
> -setFeatureEnabledImpl(Features, "rtm", true);
>  setFeatureEnabledImpl(Features, "fma", true);
>  setFeatureEnabledImpl(Features, "movbe", true);
>  LLVM_FALLTHROUGH;
>
> Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=298956=298955=298956=diff
>
> ==
> --- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
> +++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Tue Mar 28
> 18:03:19 2017
> @@ -525,7 +525,6 @@
>  // CHECK_CORE_AVX2_M32: #define __PCLMUL__ 1
>  // CHECK_CORE_AVX2_M32: #define __POPCNT__ 1
>  // CHECK_CORE_AVX2_M32: #define __RDRND__ 1
> -// CHECK_CORE_AVX2_M32: #define __RTM__ 1
>  // CHECK_CORE_AVX2_M32: #define __SSE2__ 1
>  // CHECK_CORE_AVX2_M32: #define __SSE3__ 1
>  // CHECK_CORE_AVX2_M32: #define __SSE4_1__ 1
> @@ -555,7 +554,6 @@
>  // CHECK_CORE_AVX2_M64: #define __PCLMUL__ 1
>  // CHECK_CORE_AVX2_M64: #define __POPCNT__ 1
>  // CHECK_CORE_AVX2_M64: #define __RDRND__ 1
> -// CHECK_CORE_AVX2_M64: #define __RTM__ 1
>  // CHECK_CORE_AVX2_M64: #define __SSE2_MATH__ 1
>  // CHECK_CORE_AVX2_M64: #define __SSE2__ 1
>  // CHECK_CORE_AVX2_M64: #define __SSE3__ 1
> @@ -591,7 +589,6 @@
>  // CHECK_BROADWELL_M32: #define __POPCNT__ 1
>  // CHECK_BROADWELL_M32: #define __RDRND__ 1
>  // CHECK_BROADWELL_M32: #define __RDSEED__ 1
> -// CHECK_BROADWELL_M32: #define __RTM__ 1
>  // CHECK_BROADWELL_M32: #define __SSE2__ 1
>  // CHECK_BROADWELL_M32: #define __SSE3__ 1
>  // CHECK_BROADWELL_M32: #define __SSE4_1__ 1
> @@ -623,7 +620,6 @@
>  // CHECK_BROADWELL_M64: #define __POPCNT__ 1
>  // CHECK_BROADWELL_M64: #define __RDRND__ 1
>  // CHECK_BROADWELL_M64: #define __RDSEED__ 1
> -// CHECK_BROADWELL_M64: #define __RTM__ 1
>  // 

[PATCH] D25157: [compiler-rt] [cmake] Respect COMPILER_RT_BUILD_* for libs, headers and tests

2017-03-28 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added inline comments.



Comment at: test/sanitizer_common/CMakeLists.txt:7
 set(SUPPORTED_TOOLS)
-if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD" AND NOT ANDROID)
+if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD" AND NOT ANDROID AND
+   COMPILER_RT_HAS_ASAN)

Are the `CMAKE_SYSTEM_NAME_MATCHES` guards here necessary any more, now that 
the checks are happening in config-ix.cmake?


https://reviews.llvm.org/D25157



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


Re: r298956 - Default enable the rtm feature only on skylake and later for now because Intel disabled the feature on some haswell and broadwell processors:

2017-03-28 Thread Craig Topper via cfe-commits
So if you use -march=hsw the backend will think rtm is enabled, but clang
will block the intrinsics in the frontend?

Not sure what you mean by split the haswell and broadwell cpu.

~Craig

On Tue, Mar 28, 2017 at 4:18 PM, Eric Christopher 
wrote:

> Hi Craig, Quentin, Jim,
>
> Just bringing this patch to your attention here. I haven't turned it off
> in the backend since some processors do support it and we want to allow the
> code generation, with this change we simply make the user use -mrtm to get
> the functionality for now.
>
> Question: Do we want to split the haswell and broadwell cpu to handle this
> different feature set or just leave it as an optional "enable it yourself"
> since it's an errata fix?
>
> I went ahead and committed with this question outstanding so that users
> won't get illegal instructions if they happen to have the affected units.
>
> -eric
>
>
> On Tue, Mar 28, 2017 at 4:15 PM Eric Christopher via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: echristo
>> Date: Tue Mar 28 18:03:19 2017
>> New Revision: 298956
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=298956=rev
>> Log:
>> Default enable the rtm feature only on skylake and later for now because
>> Intel disabled the feature on some haswell and broadwell processors:
>>
>> http://www.intel.com/content/dam/www/public/us/en/
>> documents/specification-updates/core-m-processor-family-spec-update.pdf
>>
>> the -mrtm option will still work normally.
>>
>> Modified:
>> cfe/trunk/lib/Basic/Targets.cpp
>> cfe/trunk/test/Preprocessor/predefined-arch-macros.c
>>
>> Modified: cfe/trunk/lib/Basic/Targets.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/
>> Targets.cpp?rev=298956=298955=298956=diff
>> 
>> ==
>> --- cfe/trunk/lib/Basic/Targets.cpp (original)
>> +++ cfe/trunk/lib/Basic/Targets.cpp Tue Mar 28 18:03:19 2017
>> @@ -3194,6 +3194,7 @@ bool X86TargetInfo::initFeatureMap(
>>  setFeatureEnabledImpl(Features, "mpx", true);
>>  setFeatureEnabledImpl(Features, "sgx", true);
>>  setFeatureEnabledImpl(Features, "clflushopt", true);
>> +setFeatureEnabledImpl(Features, "rtm", true);
>>  LLVM_FALLTHROUGH;
>>case CK_Broadwell:
>>  setFeatureEnabledImpl(Features, "rdseed", true);
>> @@ -3204,7 +3205,6 @@ bool X86TargetInfo::initFeatureMap(
>>  setFeatureEnabledImpl(Features, "lzcnt", true);
>>  setFeatureEnabledImpl(Features, "bmi", true);
>>  setFeatureEnabledImpl(Features, "bmi2", true);
>> -setFeatureEnabledImpl(Features, "rtm", true);
>>  setFeatureEnabledImpl(Features, "fma", true);
>>  setFeatureEnabledImpl(Features, "movbe", true);
>>  LLVM_FALLTHROUGH;
>>
>> Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
>> Preprocessor/predefined-arch-macros.c?rev=298956=298955&
>> r2=298956=diff
>> 
>> ==
>> --- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
>> +++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Tue Mar 28
>> 18:03:19 2017
>> @@ -525,7 +525,6 @@
>>  // CHECK_CORE_AVX2_M32: #define __PCLMUL__ 1
>>  // CHECK_CORE_AVX2_M32: #define __POPCNT__ 1
>>  // CHECK_CORE_AVX2_M32: #define __RDRND__ 1
>> -// CHECK_CORE_AVX2_M32: #define __RTM__ 1
>>  // CHECK_CORE_AVX2_M32: #define __SSE2__ 1
>>  // CHECK_CORE_AVX2_M32: #define __SSE3__ 1
>>  // CHECK_CORE_AVX2_M32: #define __SSE4_1__ 1
>> @@ -555,7 +554,6 @@
>>  // CHECK_CORE_AVX2_M64: #define __PCLMUL__ 1
>>  // CHECK_CORE_AVX2_M64: #define __POPCNT__ 1
>>  // CHECK_CORE_AVX2_M64: #define __RDRND__ 1
>> -// CHECK_CORE_AVX2_M64: #define __RTM__ 1
>>  // CHECK_CORE_AVX2_M64: #define __SSE2_MATH__ 1
>>  // CHECK_CORE_AVX2_M64: #define __SSE2__ 1
>>  // CHECK_CORE_AVX2_M64: #define __SSE3__ 1
>> @@ -591,7 +589,6 @@
>>  // CHECK_BROADWELL_M32: #define __POPCNT__ 1
>>  // CHECK_BROADWELL_M32: #define __RDRND__ 1
>>  // CHECK_BROADWELL_M32: #define __RDSEED__ 1
>> -// CHECK_BROADWELL_M32: #define __RTM__ 1
>>  // CHECK_BROADWELL_M32: #define __SSE2__ 1
>>  // CHECK_BROADWELL_M32: #define __SSE3__ 1
>>  // CHECK_BROADWELL_M32: #define __SSE4_1__ 1
>> @@ -623,7 +620,6 @@
>>  // CHECK_BROADWELL_M64: #define __POPCNT__ 1
>>  // CHECK_BROADWELL_M64: #define __RDRND__ 1
>>  // CHECK_BROADWELL_M64: #define __RDSEED__ 1
>> -// CHECK_BROADWELL_M64: #define __RTM__ 1
>>  // CHECK_BROADWELL_M64: #define __SSE2_MATH__ 1
>>  // CHECK_BROADWELL_M64: #define __SSE2__ 1
>>  // CHECK_BROADWELL_M64: #define __SSE3__ 1
>>
>>
>> ___
>> 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

Re: r298956 - Default enable the rtm feature only on skylake and later for now because Intel disabled the feature on some haswell and broadwell processors:

2017-03-28 Thread Eric Christopher via cfe-commits
Hi Craig, Quentin, Jim,

Just bringing this patch to your attention here. I haven't turned it off in
the backend since some processors do support it and we want to allow the
code generation, with this change we simply make the user use -mrtm to get
the functionality for now.

Question: Do we want to split the haswell and broadwell cpu to handle this
different feature set or just leave it as an optional "enable it yourself"
since it's an errata fix?

I went ahead and committed with this question outstanding so that users
won't get illegal instructions if they happen to have the affected units.

-eric

On Tue, Mar 28, 2017 at 4:15 PM Eric Christopher via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: echristo
> Date: Tue Mar 28 18:03:19 2017
> New Revision: 298956
>
> URL: http://llvm.org/viewvc/llvm-project?rev=298956=rev
> Log:
> Default enable the rtm feature only on skylake and later for now because
> Intel disabled the feature on some haswell and broadwell processors:
>
>
> http://www.intel.com/content/dam/www/public/us/en/documents/specification-updates/core-m-processor-family-spec-update.pdf
>
> the -mrtm option will still work normally.
>
> Modified:
> cfe/trunk/lib/Basic/Targets.cpp
> cfe/trunk/test/Preprocessor/predefined-arch-macros.c
>
> Modified: cfe/trunk/lib/Basic/Targets.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=298956=298955=298956=diff
>
> ==
> --- cfe/trunk/lib/Basic/Targets.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets.cpp Tue Mar 28 18:03:19 2017
> @@ -3194,6 +3194,7 @@ bool X86TargetInfo::initFeatureMap(
>  setFeatureEnabledImpl(Features, "mpx", true);
>  setFeatureEnabledImpl(Features, "sgx", true);
>  setFeatureEnabledImpl(Features, "clflushopt", true);
> +setFeatureEnabledImpl(Features, "rtm", true);
>  LLVM_FALLTHROUGH;
>case CK_Broadwell:
>  setFeatureEnabledImpl(Features, "rdseed", true);
> @@ -3204,7 +3205,6 @@ bool X86TargetInfo::initFeatureMap(
>  setFeatureEnabledImpl(Features, "lzcnt", true);
>  setFeatureEnabledImpl(Features, "bmi", true);
>  setFeatureEnabledImpl(Features, "bmi2", true);
> -setFeatureEnabledImpl(Features, "rtm", true);
>  setFeatureEnabledImpl(Features, "fma", true);
>  setFeatureEnabledImpl(Features, "movbe", true);
>  LLVM_FALLTHROUGH;
>
> Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=298956=298955=298956=diff
>
> ==
> --- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
> +++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Tue Mar 28
> 18:03:19 2017
> @@ -525,7 +525,6 @@
>  // CHECK_CORE_AVX2_M32: #define __PCLMUL__ 1
>  // CHECK_CORE_AVX2_M32: #define __POPCNT__ 1
>  // CHECK_CORE_AVX2_M32: #define __RDRND__ 1
> -// CHECK_CORE_AVX2_M32: #define __RTM__ 1
>  // CHECK_CORE_AVX2_M32: #define __SSE2__ 1
>  // CHECK_CORE_AVX2_M32: #define __SSE3__ 1
>  // CHECK_CORE_AVX2_M32: #define __SSE4_1__ 1
> @@ -555,7 +554,6 @@
>  // CHECK_CORE_AVX2_M64: #define __PCLMUL__ 1
>  // CHECK_CORE_AVX2_M64: #define __POPCNT__ 1
>  // CHECK_CORE_AVX2_M64: #define __RDRND__ 1
> -// CHECK_CORE_AVX2_M64: #define __RTM__ 1
>  // CHECK_CORE_AVX2_M64: #define __SSE2_MATH__ 1
>  // CHECK_CORE_AVX2_M64: #define __SSE2__ 1
>  // CHECK_CORE_AVX2_M64: #define __SSE3__ 1
> @@ -591,7 +589,6 @@
>  // CHECK_BROADWELL_M32: #define __POPCNT__ 1
>  // CHECK_BROADWELL_M32: #define __RDRND__ 1
>  // CHECK_BROADWELL_M32: #define __RDSEED__ 1
> -// CHECK_BROADWELL_M32: #define __RTM__ 1
>  // CHECK_BROADWELL_M32: #define __SSE2__ 1
>  // CHECK_BROADWELL_M32: #define __SSE3__ 1
>  // CHECK_BROADWELL_M32: #define __SSE4_1__ 1
> @@ -623,7 +620,6 @@
>  // CHECK_BROADWELL_M64: #define __POPCNT__ 1
>  // CHECK_BROADWELL_M64: #define __RDRND__ 1
>  // CHECK_BROADWELL_M64: #define __RDSEED__ 1
> -// CHECK_BROADWELL_M64: #define __RTM__ 1
>  // CHECK_BROADWELL_M64: #define __SSE2_MATH__ 1
>  // CHECK_BROADWELL_M64: #define __SSE2__ 1
>  // CHECK_BROADWELL_M64: #define __SSE3__ 1
>
>
> ___
> 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


r298956 - Default enable the rtm feature only on skylake and later for now because Intel disabled the feature on some haswell and broadwell processors:

2017-03-28 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Tue Mar 28 18:03:19 2017
New Revision: 298956

URL: http://llvm.org/viewvc/llvm-project?rev=298956=rev
Log:
Default enable the rtm feature only on skylake and later for now because Intel 
disabled the feature on some haswell and broadwell processors:

http://www.intel.com/content/dam/www/public/us/en/documents/specification-updates/core-m-processor-family-spec-update.pdf

the -mrtm option will still work normally.

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=298956=298955=298956=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Mar 28 18:03:19 2017
@@ -3194,6 +3194,7 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "mpx", true);
 setFeatureEnabledImpl(Features, "sgx", true);
 setFeatureEnabledImpl(Features, "clflushopt", true);
+setFeatureEnabledImpl(Features, "rtm", true);
 LLVM_FALLTHROUGH;
   case CK_Broadwell:
 setFeatureEnabledImpl(Features, "rdseed", true);
@@ -3204,7 +3205,6 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "lzcnt", true);
 setFeatureEnabledImpl(Features, "bmi", true);
 setFeatureEnabledImpl(Features, "bmi2", true);
-setFeatureEnabledImpl(Features, "rtm", true);
 setFeatureEnabledImpl(Features, "fma", true);
 setFeatureEnabledImpl(Features, "movbe", true);
 LLVM_FALLTHROUGH;

Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=298956=298955=298956=diff
==
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Tue Mar 28 18:03:19 
2017
@@ -525,7 +525,6 @@
 // CHECK_CORE_AVX2_M32: #define __PCLMUL__ 1
 // CHECK_CORE_AVX2_M32: #define __POPCNT__ 1
 // CHECK_CORE_AVX2_M32: #define __RDRND__ 1
-// CHECK_CORE_AVX2_M32: #define __RTM__ 1
 // CHECK_CORE_AVX2_M32: #define __SSE2__ 1
 // CHECK_CORE_AVX2_M32: #define __SSE3__ 1
 // CHECK_CORE_AVX2_M32: #define __SSE4_1__ 1
@@ -555,7 +554,6 @@
 // CHECK_CORE_AVX2_M64: #define __PCLMUL__ 1
 // CHECK_CORE_AVX2_M64: #define __POPCNT__ 1
 // CHECK_CORE_AVX2_M64: #define __RDRND__ 1
-// CHECK_CORE_AVX2_M64: #define __RTM__ 1
 // CHECK_CORE_AVX2_M64: #define __SSE2_MATH__ 1
 // CHECK_CORE_AVX2_M64: #define __SSE2__ 1
 // CHECK_CORE_AVX2_M64: #define __SSE3__ 1
@@ -591,7 +589,6 @@
 // CHECK_BROADWELL_M32: #define __POPCNT__ 1
 // CHECK_BROADWELL_M32: #define __RDRND__ 1
 // CHECK_BROADWELL_M32: #define __RDSEED__ 1
-// CHECK_BROADWELL_M32: #define __RTM__ 1
 // CHECK_BROADWELL_M32: #define __SSE2__ 1
 // CHECK_BROADWELL_M32: #define __SSE3__ 1
 // CHECK_BROADWELL_M32: #define __SSE4_1__ 1
@@ -623,7 +620,6 @@
 // CHECK_BROADWELL_M64: #define __POPCNT__ 1
 // CHECK_BROADWELL_M64: #define __RDRND__ 1
 // CHECK_BROADWELL_M64: #define __RDSEED__ 1
-// CHECK_BROADWELL_M64: #define __RTM__ 1
 // CHECK_BROADWELL_M64: #define __SSE2_MATH__ 1
 // CHECK_BROADWELL_M64: #define __SSE2__ 1
 // CHECK_BROADWELL_M64: #define __SSE3__ 1


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


[PATCH] D31308: [clang-tidy] new check readability-no-alternative-tokens

2017-03-28 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre updated this revision to Diff 93309.
mgehre added a comment.

Improved diagnostic; updated documentation; added test for overloaded operator


https://reviews.llvm.org/D31308

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/OperatorsRepresentationCheck.cpp
  clang-tidy/readability/OperatorsRepresentationCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-operators-representation.rst
  test/clang-tidy/readability-operators-representation.cpp

Index: test/clang-tidy/readability-operators-representation.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-operators-representation.cpp
@@ -0,0 +1,63 @@
+// RUN: %check_clang_tidy %s readability-operators-representation %t
+
+void f() {
+  bool a, b, c;
+
+  c = a and b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: 'and' is an alternative token spelling; consider using '&&' [readability-operators-representation]
+  // CHECK-FIXES: c = a && b;
+  c and_eq a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'and_eq' is an alternative
+  // CHECK-FIXES: c &= a;
+  c = a bitand b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: 'bitand' is an alternative
+  // CHECK-FIXES: c = a & b;
+  c = a bitor b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: 'bitor' is an alternative
+  // CHECK-FIXES: c = a | b;
+  c = compl a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'compl' is an alternative
+  // CHECK-FIXES: c = ~ a;
+  c = not a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'not' is an alternative
+  // CHECK-FIXES: c = ! a;
+  c = a not_eq b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: 'not_eq' is an alternative
+  // CHECK-FIXES: c = a != b;
+  c = a or b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: 'or' is an alternative
+  // CHECK-FIXES: c = a || b;
+  c or_eq a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'or_eq' is an alternative
+  // CHECK-FIXES: c |= a;
+  c = a xor b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: 'xor' is an alternative
+  // CHECK-FIXES: c = a ^ b;
+  c xor_eq a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'xor_eq' is an alternative
+  // CHECK-FIXES: c ^= a;
+
+#define M a xor
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: 'xor' is an alternative
+  // CHECK-FIXES: #define M a ^
+  c = M b;
+
+  int arr[2];
+  for (int i : arr) // OK (Here is an implicit != operator.)
+;
+
+  auto ptr =  // OK
+  auto i = -1;   // OK
+  c = a && b;// OK
+  c &= a;// OK
+  c = !a;// OK
+}
+
+struct S {
+  friend S& operator and(const S &, const S &);
+};
+
+int g() {
+  S s1, s2;
+  S s3 = s1 and s2; // OK
+}
Index: docs/clang-tidy/checks/readability-operators-representation.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-operators-representation.rst
@@ -0,0 +1,23 @@
+.. title:: clang-tidy - readability-operators-representation
+
+readability-operators-representation
+
+
+Flags (and replaces) the alternative tokens for binary and unary operators by
+their primary ones for consistency.
+
+=== ===
+Primary Alternative
+=== ===
+``&&``  ``and``
+``&=``  ``and_eq``
+``&``   ``bitand``
+``|``   ``bitor``
+``~``   ``compl``
+``!``   ``not``
+``!=``  ``not_eq``
+``||``  ``or``
+``|=``  ``or_eq``
+``^``   ``xor``
+``^=``  ``xor_eq``
+=== ===
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -145,6 +145,7 @@
readability-misleading-indentation
readability-misplaced-array-index
readability-named-parameter
+   readability-operators-representation
readability-non-const-parameter
readability-redundant-control-flow
readability-redundant-declaration
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -72,6 +72,12 @@
 
   Finds misleading indentation where braces should be introduced or the code should be reformatted.
 
+- New `readability-operators-representation
+  `_ check
+
+  Flags (and replaces) the alternative tokens for binary and unary operators,
+  such as ``not`` (for ``!``) and ``or`` (for ``||``).
+
 - Added `ParameterThreshold` to `readability-function-size`.
 
   Finds functions that have more then `ParameterThreshold` parameters and emits a warning.
Index: clang-tidy/readability/ReadabilityTidyModule.cpp
===
--- clang-tidy/readability/ReadabilityTidyModule.cpp
+++ clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -23,6 +23,7 @@
 #include "MisleadingIndentationCheck.h"
 

[PATCH] D31308: [clang-tidy] new check readability-no-alternative-tokens

2017-03-28 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre added inline comments.



Comment at: clang-tidy/readability/OperatorsRepresentationCheck.cpp:34
+
+  if (const auto *B = Result.Nodes.getNodeAs("binary")) {
+switch (B->getOpcode()) {

aaron.ballman wrote:
> alexfh wrote:
> > aaron.ballman wrote:
> > > I think this would make more sense lifted into an AST matcher -- there 
> > > are bound to be a *lot* of binary operators, so letting the matcher 
> > > memoize things is likely to give better performance.
> > Any reasons not to do this on the lexer level?
> Technical reasons? None.
> User-experience reasons? We wouldn't want this to be on by default (I don't 
> think) and we usually don't implement off-by-default diagnostics in Clang. I 
> think a case could be made for doing it in the Lexer if the performance is 
> really that bad with a clang-tidy check and we couldn't improve it here, 
> though.
Do I correctly understand that "doing this on lexer level" would mean to 
implement this as a warning directly into clang? If yes, would it be possible 
to generate fixits and have them possibly applied automatically (as it is the 
case for clang-tidy)?



Comment at: clang-tidy/readability/OperatorsRepresentationCheck.cpp:68
+  if (PrimarySpelling != Spelling) {
+diag(OpLoc, "operator uses alternative spelling")
+<< FixItHint::CreateReplacement(TokenRange, PrimarySpelling);

aaron.ballman wrote:
> This diagnostic doesn't help the user to understand what's wrong with their 
> code (especially in the presence of multiple operators). Perhaps "'%0' is an 
> alternative token spelling; consider using '%1'"
> 
> It would be nice if we could say "consider using %1 for ", but I'm 
> really not certain why we would diagnose this code in the first place (it's 
> purely a matter of stylistic choice, as I understand it).
The main rational for this check is to enforce consistency and thus make it 
easier to read and comprehend the code.
I agree with your proposed diagnostics.


https://reviews.llvm.org/D31308



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


[PATCH] D31441: [clang-format] fix crash in NamespaceEndCommentsFixer (PR32438)

2017-03-28 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

Looks good! I just have two nits.




Comment at: lib/Format/NamespaceEndCommentsFixer.cpp:139
+}
 if (NamespaceTok->isNot(tok::kw_namespace))
   continue;

I'd instead just add a guard check at old line 136: 
```
if (!NamespaceTok || NamespaceTok->isNot(tok::kw_namespace))
  continue;
```



Comment at: unittests/Format/NamespaceEndCommentsFixerTest.cpp:586
+
+TEST_F(NamespaceEndCommentsFixerTest, PR32438) {
+  EXPECT_EQ("template  struct a {};\n"

I'd make the test name a bit descriptive; something like:
`HandlesInlineAtEndOfLine_PR32438`


https://reviews.llvm.org/D31441



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


[PATCH] D23418: [analyzer] Added a reusable constraint system to the CloneDetector

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

I am very happy to see this converging! Thanks for the work and perseverance! 
LGTM.


https://reviews.llvm.org/D23418



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


[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

2017-03-28 Thread Tony Tye via Phabricator via cfe-commits
t-tye added inline comments.



Comment at: lib/AST/ASTContext.cpp:9547-9555
+unsigned ASTContext::getTargetAddressSpace(unsigned AS) const {
+  // For OpenCL, the address space qualifier is 0 in AST.
+  if (AS == 0 && LangOpts.OpenCL)
+return getTargetInfo().getDataLayout().getAllocaAddrSpace();
+  if (AS < LangAS::Offset || AS >= LangAS::Offset + LangAS::Count)
+return AS;
+  else

yaxunl wrote:
> t-tye wrote:
> > yaxunl wrote:
> > > t-tye wrote:
> > > > Presumably this will not work if the user put an address space 
> > > > attribute on a variable with an address space of 0, since it is not 
> > > > possible to distinguish between a variable that never had an attribute 
> > > > and was function local, and one that has an explicit address space 
> > > > attribute specifying 0.
> > > > 
> > > > It would seem better if LangAS did not map the 0..LangAS::Offset to be 
> > > > target address spaces. Instead LangAS could use 0..LangAS::Count to be 
> > > > the CLANG explicitly specified values (reserving 0 to mean the default 
> > > > when none was specified), and values above LangAS::Count would map to 
> > > > the explicitly specified target address spaces. For example:
> > > > 
> > > > ```
> > > > namespace clang {
> > > >  
> > > >  namespace LangAS {
> > > >  
> > > >  /// \brief Defines the set of possible language-specific address 
> > > > spaces.
> > > >  ///
> > > >  /// This uses values above the language-specific address spaces to 
> > > > denote
> > > >  /// the target-specific address spaces biased by target_first.
> > > >  enum ID {
> > > >default = 0,
> > > >  
> > > >opencl_global,
> > > >opencl_local,
> > > >opencl_constant,
> > > >opencl_generic,
> > > >  
> > > >cuda_device,
> > > >cuda_constant,
> > > >cuda_shared,
> > > >  
> > > >Count,
> > > > 
> > > >target_first = Count
> > > >  };
> > > >  
> > > >  /// The type of a lookup table which maps from language-specific 
> > > > address spaces
> > > >  /// to target-specific ones.
> > > >  typedef unsigned Map[Count];
> > > >  
> > > >  }
> > > > ```
> > > > 
> > > > Then this function would be:
> > > > 
> > > > ```
> > > > unsigned ASTContext::getTargetAddressSpace(unsigned AS) const {
> > > >   if (AS == LangAS::default && LangOpts.OpenCL)
> > > > // For OpenCL, only function local variables are not explicitly 
> > > > marked with an
> > > > // address space in the AST, and these need to be the address space 
> > > > of alloca.
> > > > return getTargetInfo().getDataLayout().getAllocaAddrSpace();
> > > >   if (AS >= LangAS::target_first)
> > > > return AS - LangAS::target_first;
> > > >   else
> > > > return (*AddrSpaceMap)[AS];
> > > > }
> > > > ```
> > > > 
> > > > Each target AddrSpaceMap would map LangAS::default to that target's 
> > > > default generic address space since that matches most other languages.
> > > > 
> > > > The address space attribute would need a corresponding "+ 
> > > > LangAS::target_first" to the value it stored in the AST.
> > > > 
> > > > Then it is possible to definitively tell when an AST node has not had 
> > > > any address space specified as it will be the LangAS::default value.
> > > There is a lit test like this:
> > > 
> > > ```
> > > // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
> > > 
> > > #define OPENCL_CONSTANT 8388354
> > > int __attribute__((address_space(OPENCL_CONSTANT))) c[3] = {0};
> > > 
> > > void foo() {
> > >   c[0] = 1; //expected-error{{read-only variable is not assignable}}
> > > }
> > > 
> > > ```
> > > It tries to set address space of opencl_constant through 
> > > `__attribute__((address_space(n)))`. If we "+ LangAS::target_first" to 
> > > the value before it is tored in the AST, we are not able to use 
> > > `__attribute__((address_space(n)))` to represent opencl_constant.
> > This seems a bit of a hack. It could be made to work by simply defining 
> > OPENCL_CONSTANT to be the negative value that would result in the correct 
> > LangAS value, which is pretty much what the test is doing anyway. Just 
> > seems conflating the default value with the first target address space 
> > value is undesirable as it prevents specifying target address space 0 as 
> > that gets treated differently than any other address space value.
> Clang will emit error if address space value is negative, but I can change it 
> to a warning.
I guess the observation is that without a change the proposed changes will make 
__attribute__((address_space(0))) behave in unexpected ways for some targets 
(for AMDGPU it would actually cause address space for private to be used). The 
suggested approach also seems cleaner as it explicitly defines a "default" 
value which does not overlay the target address space range of values.


https://reviews.llvm.org/D31404



___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

2017-03-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/AST/ASTContext.cpp:9547-9555
+unsigned ASTContext::getTargetAddressSpace(unsigned AS) const {
+  // For OpenCL, the address space qualifier is 0 in AST.
+  if (AS == 0 && LangOpts.OpenCL)
+return getTargetInfo().getDataLayout().getAllocaAddrSpace();
+  if (AS < LangAS::Offset || AS >= LangAS::Offset + LangAS::Count)
+return AS;
+  else

t-tye wrote:
> yaxunl wrote:
> > t-tye wrote:
> > > Presumably this will not work if the user put an address space attribute 
> > > on a variable with an address space of 0, since it is not possible to 
> > > distinguish between a variable that never had an attribute and was 
> > > function local, and one that has an explicit address space attribute 
> > > specifying 0.
> > > 
> > > It would seem better if LangAS did not map the 0..LangAS::Offset to be 
> > > target address spaces. Instead LangAS could use 0..LangAS::Count to be 
> > > the CLANG explicitly specified values (reserving 0 to mean the default 
> > > when none was specified), and values above LangAS::Count would map to the 
> > > explicitly specified target address spaces. For example:
> > > 
> > > ```
> > > namespace clang {
> > >  
> > >  namespace LangAS {
> > >  
> > >  /// \brief Defines the set of possible language-specific address spaces.
> > >  ///
> > >  /// This uses values above the language-specific address spaces to denote
> > >  /// the target-specific address spaces biased by target_first.
> > >  enum ID {
> > >default = 0,
> > >  
> > >opencl_global,
> > >opencl_local,
> > >opencl_constant,
> > >opencl_generic,
> > >  
> > >cuda_device,
> > >cuda_constant,
> > >cuda_shared,
> > >  
> > >Count,
> > > 
> > >target_first = Count
> > >  };
> > >  
> > >  /// The type of a lookup table which maps from language-specific address 
> > > spaces
> > >  /// to target-specific ones.
> > >  typedef unsigned Map[Count];
> > >  
> > >  }
> > > ```
> > > 
> > > Then this function would be:
> > > 
> > > ```
> > > unsigned ASTContext::getTargetAddressSpace(unsigned AS) const {
> > >   if (AS == LangAS::default && LangOpts.OpenCL)
> > > // For OpenCL, only function local variables are not explicitly 
> > > marked with an
> > > // address space in the AST, and these need to be the address space 
> > > of alloca.
> > > return getTargetInfo().getDataLayout().getAllocaAddrSpace();
> > >   if (AS >= LangAS::target_first)
> > > return AS - LangAS::target_first;
> > >   else
> > > return (*AddrSpaceMap)[AS];
> > > }
> > > ```
> > > 
> > > Each target AddrSpaceMap would map LangAS::default to that target's 
> > > default generic address space since that matches most other languages.
> > > 
> > > The address space attribute would need a corresponding "+ 
> > > LangAS::target_first" to the value it stored in the AST.
> > > 
> > > Then it is possible to definitively tell when an AST node has not had any 
> > > address space specified as it will be the LangAS::default value.
> > There is a lit test like this:
> > 
> > ```
> > // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
> > 
> > #define OPENCL_CONSTANT 8388354
> > int __attribute__((address_space(OPENCL_CONSTANT))) c[3] = {0};
> > 
> > void foo() {
> >   c[0] = 1; //expected-error{{read-only variable is not assignable}}
> > }
> > 
> > ```
> > It tries to set address space of opencl_constant through 
> > `__attribute__((address_space(n)))`. If we "+ LangAS::target_first" to the 
> > value before it is tored in the AST, we are not able to use 
> > `__attribute__((address_space(n)))` to represent opencl_constant.
> This seems a bit of a hack. It could be made to work by simply defining 
> OPENCL_CONSTANT to be the negative value that would result in the correct 
> LangAS value, which is pretty much what the test is doing anyway. Just seems 
> conflating the default value with the first target address space value is 
> undesirable as it prevents specifying target address space 0 as that gets 
> treated differently than any other address space value.
Clang will emit error if address space value is negative, but I can change it 
to a warning.


https://reviews.llvm.org/D31404



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


[PATCH] D31363: [libc++] Remove cmake glob for source files

2017-03-28 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai planned changes to this revision.
smeenai added a comment.

I like the idea of verifying that all source files have been included. Will 
amend this accordingly. Thanks for the cmake pointer @beanz!




Comment at: lib/CMakeLists.txt:304
 if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
   file(GLOB LIBCXX_EXPERIMENTAL_SOURCES ../src/experimental/*.cpp)
   if (LIBCXX_ENABLE_FILESYSTEM)

EricWF wrote:
> These globs should be fixed as well.
Right, I missed this one.


https://reviews.llvm.org/D31363



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


[PATCH] D23418: [analyzer] Added a reusable constraint system to the CloneDetector

2017-03-28 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor updated this revision to Diff 93302.
teemperor added a comment.

- `auto` to `const auto` to be more consistent with LLVM style.


https://reviews.llvm.org/D23418

Files:
  include/clang/Analysis/CloneDetection.h
  lib/Analysis/CloneDetection.cpp
  lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  unittests/Analysis/CMakeLists.txt
  unittests/Analysis/CloneDetectionTest.cpp

Index: unittests/Analysis/CloneDetectionTest.cpp
===
--- /dev/null
+++ unittests/Analysis/CloneDetectionTest.cpp
@@ -0,0 +1,111 @@
+//===- unittests/Analysis/CloneDetectionTest.cpp - Clone detection tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Analysis/CloneDetection.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace analysis {
+namespace {
+
+class CloneDetectionVisitor
+: public RecursiveASTVisitor {
+
+  CloneDetector 
+
+public:
+  explicit CloneDetectionVisitor(CloneDetector ) : Detector(D) {}
+
+  bool VisitFunctionDecl(FunctionDecl *D) {
+Detector.analyzeCodeBody(D);
+return true;
+  }
+};
+
+/// Example constraint for testing purposes.
+/// Filters out all statements that are in a function which name starts with
+/// "bar".
+class NoBarFunctionConstraint {
+public:
+  void constrain(std::vector ) {
+CloneConstraint::splitCloneGroups(
+CloneGroups, [](const StmtSequence , const StmtSequence ) {
+  // Check if one of the sequences is in a function which name starts
+  // with
+  // "bar".
+  for (const StmtSequence  : {A, B}) {
+if (const auto *D =
+dyn_cast(Arg.getContainingDecl())) {
+  if (D->getNameAsString().find("bar") == 0)
+return false;
+}
+  }
+  return true;
+});
+  }
+};
+
+TEST(CloneDetector, NoPostOrderTraversal) {
+  auto ASTUnit =
+  clang::tooling::buildASTFromCode("void foo1(int ) { a1++; }\n"
+   "void foo2(int ) { a2++; }\n"
+   "void bar1(int ) { a3++; }\n"
+   "void bar2(int ) { a4++; }\n");
+  auto TU = ASTUnit->getASTContext().getTranslationUnitDecl();
+
+  CloneDetector Detector;
+  // Push all the function bodies into the detector.
+  CloneDetectionVisitor Visitor(Detector);
+  Visitor.TraverseTranslationUnitDecl(TU);
+
+  // Find clones with the usual settings, but but we want to filter out
+  // all statements from functions which names start with "bar".
+  std::vector CloneGroups;
+  Detector.findClones(CloneGroups, NoBarFunctionConstraint(),
+  RecursiveCloneTypeIIConstraint(),
+  MinComplexityConstraint(2), MinGroupSizeConstraint(2),
+  OnlyLargestCloneConstraint());
+
+  ASSERT_EQ(CloneGroups.size(), 1u);
+  ASSERT_EQ(CloneGroups.front().size(), 2u);
+
+  for (auto  : CloneGroups.front()) {
+const auto ND = dyn_cast(Clone.getContainingDecl());
+ASSERT_TRUE(ND != nullptr);
+// Check that no function name starting with "bar" is in the results...
+ASSERT_TRUE(ND->getNameAsString().find("bar") != 0);
+  }
+
+  // Retry above's example without the filter...
+  CloneGroups.clear();
+
+  Detector.findClones(CloneGroups, RecursiveCloneTypeIIConstraint(),
+  MinComplexityConstraint(2), MinGroupSizeConstraint(2),
+  OnlyLargestCloneConstraint());
+  ASSERT_EQ(CloneGroups.size(), 1u);
+  ASSERT_EQ(CloneGroups.front().size(), 4u);
+
+  // Count how many functions with the bar prefix we have in the results.
+  int FoundFunctionsWithBarPrefix = 0;
+  for (auto  : CloneGroups.front()) {
+const auto ND = dyn_cast(Clone.getContainingDecl());
+ASSERT_TRUE(ND != nullptr);
+// This time check that we picked up the bar functions from above
+if (ND->getNameAsString().find("bar") == 0) {
+  FoundFunctionsWithBarPrefix++;
+}
+  }
+  // We should have found the two functions bar1 and bar2.
+  ASSERT_EQ(FoundFunctionsWithBarPrefix, 2);
+}
+} // namespace
+} // namespace analysis
+} // namespace clang
Index: unittests/Analysis/CMakeLists.txt
===
--- unittests/Analysis/CMakeLists.txt
+++ unittests/Analysis/CMakeLists.txt
@@ -2,11 +2,12 @@
   Support
   )
 
-add_clang_unittest(CFGTests
+add_clang_unittest(ClangAnalysisTests
   CFGTest.cpp
+  CloneDetectionTest.cpp
   )
 
-target_link_libraries(CFGTests
+target_link_libraries(ClangAnalysisTests
   clangAnalysis
   clangAST
   clangASTMatchers
Index: lib/StaticAnalyzer/Checkers/CloneChecker.cpp

[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

2017-03-28 Thread Tony Tye via Phabricator via cfe-commits
t-tye added inline comments.



Comment at: lib/AST/ASTContext.cpp:9547-9555
+unsigned ASTContext::getTargetAddressSpace(unsigned AS) const {
+  // For OpenCL, the address space qualifier is 0 in AST.
+  if (AS == 0 && LangOpts.OpenCL)
+return getTargetInfo().getDataLayout().getAllocaAddrSpace();
+  if (AS < LangAS::Offset || AS >= LangAS::Offset + LangAS::Count)
+return AS;
+  else

yaxunl wrote:
> t-tye wrote:
> > Presumably this will not work if the user put an address space attribute on 
> > a variable with an address space of 0, since it is not possible to 
> > distinguish between a variable that never had an attribute and was function 
> > local, and one that has an explicit address space attribute specifying 0.
> > 
> > It would seem better if LangAS did not map the 0..LangAS::Offset to be 
> > target address spaces. Instead LangAS could use 0..LangAS::Count to be the 
> > CLANG explicitly specified values (reserving 0 to mean the default when 
> > none was specified), and values above LangAS::Count would map to the 
> > explicitly specified target address spaces. For example:
> > 
> > ```
> > namespace clang {
> >  
> >  namespace LangAS {
> >  
> >  /// \brief Defines the set of possible language-specific address spaces.
> >  ///
> >  /// This uses values above the language-specific address spaces to denote
> >  /// the target-specific address spaces biased by target_first.
> >  enum ID {
> >default = 0,
> >  
> >opencl_global,
> >opencl_local,
> >opencl_constant,
> >opencl_generic,
> >  
> >cuda_device,
> >cuda_constant,
> >cuda_shared,
> >  
> >Count,
> > 
> >target_first = Count
> >  };
> >  
> >  /// The type of a lookup table which maps from language-specific address 
> > spaces
> >  /// to target-specific ones.
> >  typedef unsigned Map[Count];
> >  
> >  }
> > ```
> > 
> > Then this function would be:
> > 
> > ```
> > unsigned ASTContext::getTargetAddressSpace(unsigned AS) const {
> >   if (AS == LangAS::default && LangOpts.OpenCL)
> > // For OpenCL, only function local variables are not explicitly marked 
> > with an
> > // address space in the AST, and these need to be the address space of 
> > alloca.
> > return getTargetInfo().getDataLayout().getAllocaAddrSpace();
> >   if (AS >= LangAS::target_first)
> > return AS - LangAS::target_first;
> >   else
> > return (*AddrSpaceMap)[AS];
> > }
> > ```
> > 
> > Each target AddrSpaceMap would map LangAS::default to that target's default 
> > generic address space since that matches most other languages.
> > 
> > The address space attribute would need a corresponding "+ 
> > LangAS::target_first" to the value it stored in the AST.
> > 
> > Then it is possible to definitively tell when an AST node has not had any 
> > address space specified as it will be the LangAS::default value.
> There is a lit test like this:
> 
> ```
> // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
> 
> #define OPENCL_CONSTANT 8388354
> int __attribute__((address_space(OPENCL_CONSTANT))) c[3] = {0};
> 
> void foo() {
>   c[0] = 1; //expected-error{{read-only variable is not assignable}}
> }
> 
> ```
> It tries to set address space of opencl_constant through 
> `__attribute__((address_space(n)))`. If we "+ LangAS::target_first" to the 
> value before it is tored in the AST, we are not able to use 
> `__attribute__((address_space(n)))` to represent opencl_constant.
This seems a bit of a hack. It could be made to work by simply defining 
OPENCL_CONSTANT to be the negative value that would result in the correct 
LangAS value, which is pretty much what the test is doing anyway. Just seems 
conflating the default value with the first target address space value is 
undesirable as it prevents specifying target address space 0 as that gets 
treated differently than any other address space value.


https://reviews.llvm.org/D31404



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


[PATCH] D31441: [clang-format] fix crash in NamespaceEndCommentsFixer (PR32438)

2017-03-28 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre created this revision.
Herald added a subscriber: klimek.

The new test case was crashing before. Now it passes
as expected.


https://reviews.llvm.org/D31441

Files:
  lib/Format/NamespaceEndCommentsFixer.cpp
  unittests/Format/NamespaceEndCommentsFixerTest.cpp


Index: unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -582,6 +582,21 @@
 "} // namespace\n"
 "}"));
 }
+
+TEST_F(NamespaceEndCommentsFixerTest, PR32438) {
+  EXPECT_EQ("template  struct a {};\n"
+"struct a b() {\n"
+"}\n"
+"#define c inline\n"
+"void d() {\n"
+"}\n",
+fixNamespaceEndComments("template  struct a {};\n"
+"struct a b() {\n"
+"}\n"
+"#define c inline\n"
+"void d() {\n"
+"}\n"));
+}
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/NamespaceEndCommentsFixer.cpp
===
--- lib/Format/NamespaceEndCommentsFixer.cpp
+++ lib/Format/NamespaceEndCommentsFixer.cpp
@@ -131,8 +131,11 @@
 assert(StartLineIndex < E);
 const FormatToken *NamespaceTok = AnnotatedLines[StartLineIndex]->First;
 // Detect "(inline)? namespace" in the beginning of a line.
-if (NamespaceTok->is(tok::kw_inline))
+if (NamespaceTok->is(tok::kw_inline)) {
   NamespaceTok = NamespaceTok->getNextNonComment();
+  if (!NamespaceTok)
+continue;
+}
 if (NamespaceTok->isNot(tok::kw_namespace))
   continue;
 FormatToken *RBraceTok = EndLine->First;


Index: unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -582,6 +582,21 @@
 "} // namespace\n"
 "}"));
 }
+
+TEST_F(NamespaceEndCommentsFixerTest, PR32438) {
+  EXPECT_EQ("template  struct a {};\n"
+"struct a b() {\n"
+"}\n"
+"#define c inline\n"
+"void d() {\n"
+"}\n",
+fixNamespaceEndComments("template  struct a {};\n"
+"struct a b() {\n"
+"}\n"
+"#define c inline\n"
+"void d() {\n"
+"}\n"));
+}
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/NamespaceEndCommentsFixer.cpp
===
--- lib/Format/NamespaceEndCommentsFixer.cpp
+++ lib/Format/NamespaceEndCommentsFixer.cpp
@@ -131,8 +131,11 @@
 assert(StartLineIndex < E);
 const FormatToken *NamespaceTok = AnnotatedLines[StartLineIndex]->First;
 // Detect "(inline)? namespace" in the beginning of a line.
-if (NamespaceTok->is(tok::kw_inline))
+if (NamespaceTok->is(tok::kw_inline)) {
   NamespaceTok = NamespaceTok->getNextNonComment();
+  if (!NamespaceTok)
+continue;
+}
 if (NamespaceTok->isNot(tok::kw_namespace))
   continue;
 FormatToken *RBraceTok = EndLine->First;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31440: PR32382: Adapt to LLVM changes in DIExpression.

2017-03-28 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl created this revision.

LLVM now interprets DIExpressions correctly and no longer determines the 
location description kind by looking at whether the first operator is a 
DW_OP_deref.

  

The code that emitted debug info for block captures used to rely on this and 
used the presence of an alloca (which was only emitted when optimizations were 
enabled) as a proxy for tweaking the expression in a way the resulted in the 
backend doing the right thing. This is now unnecessary and this patch 
unconditionally emits an alloca for block descriptors, which is then elided by 
mem2reg.

  

https://bugs.llvm.org/show_bug.cgi?id=32382
rdar://problem/31205000


https://reviews.llvm.org/D31440

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGenObjC/debug-info-block-captured-self.m
  test/CodeGenObjC/debug-info-blocks.m

Index: test/CodeGenObjC/debug-info-blocks.m
===
--- test/CodeGenObjC/debug-info-blocks.m
+++ test/CodeGenObjC/debug-info-blocks.m
@@ -4,11 +4,18 @@
 // Test that we generate the proper debug location for a captured self.
 // The second half of this test is in llvm/tests/DebugInfo/debug-info-blocks.ll
 
-// CHECK: define {{.*}}_block_invoke
-// CHECK: %[[BLOCK:.*]] = bitcast i8* %.block_descriptor to <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>*, !dbg
-// CHECK-NEXT: store <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %[[BLOCK]], <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>** %[[ALLOCA:.*]], align
-// CHECK-NEXT: call void @llvm.dbg.declare(metadata <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>** %[[ALLOCA]], metadata ![[SELF:[0-9]+]], metadata !{{.*}})
-// CHECK-NEXT: call void @llvm.dbg.declare(metadata %1** %d, metadata ![[D:[0-9]+]], metadata !{{.*}})
+// CHECK: define {{.*}}[A init]_block_invoke
+// CHECK-NEXT: entry
+// CHECK-NEXT: %[[DESC_ALLOCA:.*]] = alloca i8*, align 8
+// CHECK-NEXT: %[[BLOCK_ALLOCA:.*]] = alloca <{{.*}}>*, align 8
+// CHECK: store i8* %.block_descriptor, i8** %[[ALLOCA:.*]], align 8
+// CHECK: call void @llvm.dbg.declare(metadata i8** %[[DESC_ALLOCA]],
+// CHECK-SAME:metadata ![[BLOCK_VAR:[0-9]+]],
+// CHECK: call void @llvm.dbg.declare(
+// CHECK-SAME: metadata <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>**
+// CHECK-SAME:  %[[BLOCK_ALLOCA]], metadata ![[SELF_VAR:[0-9]+]],
+// CHECK-SAME:  metadata ![[SELF_EXPR:[0-9]+]])
+// CHECK: call void @llvm.dbg.declare(metadata %1** %d, metadata ![[D_VAR:[0-9]+]],
 
 // rdar://problem/14386148
 // Test that we don't emit bogus line numbers for the helper functions.
@@ -22,11 +29,13 @@
 // CHECK-NOT: ret
 // CHECK: load {{.*}}, !dbg ![[DESTROY_LINE:[0-9]+]]
 
-// CHECK-DAG: [[DBG_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
-// CHECK-DAG: [[COPY_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
-// CHECK-DAG: [[COPY_SP]] = distinct !DISubprogram(name: "__copy_helper_block_"
-// CHECK-DAG: [[DESTROY_LINE]] = !DILocation(line: 0, scope: ![[DESTROY_SP:[0-9]+]])
-// CHECK-DAG: [[DESTROY_SP]] = distinct !DISubprogram(name: "__destroy_helper_block_"
+// CHECK-DAG: ![[DBG_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
+// CHECK-DAG: ![[COPY_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]])
+// CHECK-DAG: ![[COPY_SP]] = distinct !DISubprogram(name: "__copy_helper_block_"
+// CHECK-DAG: ![[DESTROY_LINE]] = !DILocation(line: 0, scope: ![[DESTROY_SP:[0-9]+]])
+// CHECK-DAG: ![[DESTROY_SP]] = distinct !DISubprogram(name: "__destroy_helper_block_"
+// CHECK-DAG: ![[BLOCK_VAR]] = !DILocalVariable(name: ".block_descriptor"
+// CHECK-DAG: ![[SELF_EXPR]] = !DIExpression(DW_OP_plus, 32, DW_OP_deref)
 typedef unsigned int NSUInteger;
 
 @protocol NSObject
@@ -61,8 +70,8 @@
 {
 if ((self = [super init])) {
   run(^{
-  // CHECK-DAG: ![[SELF]] = !DILocalVariable(name: "self", scope:{{.*}}, line: [[@LINE+4]],
-  // CHECK-DAG: ![[D]] = !DILocalVariable(name: "d", scope:{{.*}}, line: [[@LINE+1]],
+  // CHECK-DAG: ![[SELF_VAR]] = !DILocalVariable(name: "self", scope:{{.*}}, line: [[@LINE+4]],
+  // CHECK-DAG: ![[D_VAR]] = !DILocalVariable(name: "d", scope:{{.*}}, line: [[@LINE+1]],
   NSMutableDictionary *d = [[NSMutableDictionary alloc] init]; 
   ivar = 42 + (int)[d count];
 });
Index: test/CodeGenObjC/debug-info-block-captured-self.m
===
--- test/CodeGenObjC/debug-info-block-captured-self.m
+++ test/CodeGenObjC/debug-info-block-captured-self.m
@@ -56,16 +56,22 @@
 // CHECK-NEXT:   [[DBGADDR:%.*]] = alloca [[BLOCK_T:<{.*}>]]*, align 8
 // CHECK:store i8* [[BLOCK_DESC:%.*]], i8** %[[MEM1]], align 8
 // CHECK:%[[TMP0:.*]] = load i8*, i8** %[[MEM1]]
-// CHECK:call void @llvm.dbg.value(metadata i8* %[[TMP0]], i64 0, metadata 

[PATCH] D25157: [compiler-rt] [cmake] Respect COMPILER_RT_BUILD_* for libs, headers and tests

2017-03-28 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 93296.
mgorny added a comment.

Rebased. Ping. Now that we have lit tests for builtins, it would be really 
useful for us to be able to build them without having to enable sanitizers.


https://reviews.llvm.org/D25157

Files:
  cmake/config-ix.cmake
  include/CMakeLists.txt
  lib/CMakeLists.txt
  test/sanitizer_common/CMakeLists.txt

Index: test/sanitizer_common/CMakeLists.txt
===
--- test/sanitizer_common/CMakeLists.txt
+++ test/sanitizer_common/CMakeLists.txt
@@ -4,13 +4,20 @@
 set(SANITIZER_COMMON_TESTSUITES)
 
 set(SUPPORTED_TOOLS)
-if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD" AND NOT ANDROID)
+if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD" AND NOT ANDROID AND
+   COMPILER_RT_HAS_ASAN)
   list(APPEND SUPPORTED_TOOLS asan)
 endif()
 if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT ANDROID)
-  list(APPEND SUPPORTED_TOOLS tsan)
-  list(APPEND SUPPORTED_TOOLS msan)
-  list(APPEND SUPPORTED_TOOLS lsan)
+  if(COMPILER_RT_HAS_TSAN)
+list(APPEND SUPPORTED_TOOLS tsan)
+  endif()
+  if(COMPILER_RT_HAS_MSAN)
+list(APPEND SUPPORTED_TOOLS msan)
+  endif()
+  if(COMPILER_RT_HAS_LSAN)
+list(APPEND SUPPORTED_TOOLS lsan)
+  endif()
 endif()
 
 # Create a separate config for each tool we support.
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -8,8 +8,7 @@
 # sanitizers or xray (or both).
 #
 #TODO: Refactor sanitizer_common into smaller pieces (e.g. flag parsing, utils).
-if (COMPILER_RT_HAS_SANITIZER_COMMON AND
-(COMPILER_RT_BUILD_SANITIZERS OR COMPILER_RT_BUILD_XRAY))
+if (COMPILER_RT_HAS_SANITIZER_COMMON)
   add_subdirectory(sanitizer_common)
 endif()
 
@@ -36,27 +35,27 @@
   endif()
 endfunction()
 
-if(COMPILER_RT_BUILD_SANITIZERS)
-  compiler_rt_build_runtime(interception)
+# the following set is conditional to COMPILER_RT_BUILD_SANITIZERS
+# (via COMPILER_RT_HAS_* in config-ix.cmake)
+compiler_rt_build_runtime(interception)
 
-  if(COMPILER_RT_HAS_SANITIZER_COMMON)
-add_subdirectory(stats)
-add_subdirectory(lsan)
-add_subdirectory(ubsan)
-  endif()
+if(COMPILER_RT_BUILD_SANITIZERS AND COMPILER_RT_HAS_SANITIZER_COMMON)
+  add_subdirectory(stats)
+  add_subdirectory(lsan)
+  add_subdirectory(ubsan)
+endif()
 
-  compiler_rt_build_sanitizer(asan)
-  compiler_rt_build_sanitizer(dfsan)
-  compiler_rt_build_sanitizer(msan)
-  compiler_rt_build_sanitizer(tsan tsan/dd)
-  compiler_rt_build_sanitizer(safestack)
-  compiler_rt_build_sanitizer(cfi)
-  compiler_rt_build_sanitizer(esan)
-  compiler_rt_build_sanitizer(scudo)
+compiler_rt_build_sanitizer(asan)
+compiler_rt_build_sanitizer(dfsan)
+compiler_rt_build_sanitizer(msan)
+compiler_rt_build_sanitizer(tsan tsan/dd)
+compiler_rt_build_sanitizer(safestack)
+compiler_rt_build_sanitizer(cfi)
+compiler_rt_build_sanitizer(esan)
+compiler_rt_build_sanitizer(scudo)
 
-  compiler_rt_build_runtime(profile)
-endif()
+compiler_rt_build_runtime(profile)
 
-if(COMPILER_RT_BUILD_XRAY)
-  compiler_rt_build_runtime(xray)
-endif()
+# the following set is conditional to COMPILER_RT_BUILD_XRAY
+# (via COMPILER_RT_HAS_* in config-ix.cmake)
+compiler_rt_build_runtime(xray)
Index: include/CMakeLists.txt
===
--- include/CMakeLists.txt
+++ include/CMakeLists.txt
@@ -1,18 +1,42 @@
-set(SANITIZER_HEADERS
-  sanitizer/allocator_interface.h
-  sanitizer/asan_interface.h
-  sanitizer/common_interface_defs.h
-  sanitizer/coverage_interface.h
-  sanitizer/dfsan_interface.h
-  sanitizer/esan_interface.h
-  sanitizer/linux_syscall_hooks.h
-  sanitizer/lsan_interface.h
-  sanitizer/msan_interface.h
-  sanitizer/tsan_interface.h
-  sanitizer/tsan_interface_atomic.h)
+set(SANITIZER_HEADERS)
+if(COMPILER_RT_HAS_SANITIZER_COMMON)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/allocator_interface.h
+   sanitizer/common_interface_defs.h
+   sanitizer/coverage_interface.h
+   sanitizer/linux_syscall_hooks.h)
+endif()
+if(COMPILER_RT_HAS_ASAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/asan_interface.h)
+endif()
+if(COMPILER_RT_HAS_DFSAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/dfsan_interface.h)
+endif()
+if(COMPILER_RT_HAS_ESAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/esan_interface.h)
+endif()
+if(COMPILER_RT_HAS_LSAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/lsan_interface.h)
+endif()
+if(COMPILER_RT_HAS_MSAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/msan_interface.h)
+endif()
+if(COMPILER_RT_HAS_TSAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/tsan_interface.h
+   sanitizer/tsan_interface_atomic.h)
+endif()
 
-set(XRAY_HEADERS
-  xray/xray_interface.h)
+set(XRAY_HEADERS)
+if(COMPILER_RT_BUILD_XRAY)
+  list(APPEND XRAY_HEADERS
+   xray/xray_interface.h)
+endif()
 
 set(COMPILER_RT_HEADERS
   ${SANITIZER_HEADERS}
Index: 

[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

2017-03-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/AST/ASTContext.cpp:9547-9555
+unsigned ASTContext::getTargetAddressSpace(unsigned AS) const {
+  // For OpenCL, the address space qualifier is 0 in AST.
+  if (AS == 0 && LangOpts.OpenCL)
+return getTargetInfo().getDataLayout().getAllocaAddrSpace();
+  if (AS < LangAS::Offset || AS >= LangAS::Offset + LangAS::Count)
+return AS;
+  else

t-tye wrote:
> Presumably this will not work if the user put an address space attribute on a 
> variable with an address space of 0, since it is not possible to distinguish 
> between a variable that never had an attribute and was function local, and 
> one that has an explicit address space attribute specifying 0.
> 
> It would seem better if LangAS did not map the 0..LangAS::Offset to be target 
> address spaces. Instead LangAS could use 0..LangAS::Count to be the CLANG 
> explicitly specified values (reserving 0 to mean the default when none was 
> specified), and values above LangAS::Count would map to the explicitly 
> specified target address spaces. For example:
> 
> ```
> namespace clang {
>  
>  namespace LangAS {
>  
>  /// \brief Defines the set of possible language-specific address spaces.
>  ///
>  /// This uses values above the language-specific address spaces to denote
>  /// the target-specific address spaces biased by target_first.
>  enum ID {
>default = 0,
>  
>opencl_global,
>opencl_local,
>opencl_constant,
>opencl_generic,
>  
>cuda_device,
>cuda_constant,
>cuda_shared,
>  
>Count,
> 
>target_first = Count
>  };
>  
>  /// The type of a lookup table which maps from language-specific address 
> spaces
>  /// to target-specific ones.
>  typedef unsigned Map[Count];
>  
>  }
> ```
> 
> Then this function would be:
> 
> ```
> unsigned ASTContext::getTargetAddressSpace(unsigned AS) const {
>   if (AS == LangAS::default && LangOpts.OpenCL)
> // For OpenCL, only function local variables are not explicitly marked 
> with an
> // address space in the AST, and these need to be the address space of 
> alloca.
> return getTargetInfo().getDataLayout().getAllocaAddrSpace();
>   if (AS >= LangAS::target_first)
> return AS - LangAS::target_first;
>   else
> return (*AddrSpaceMap)[AS];
> }
> ```
> 
> Each target AddrSpaceMap would map LangAS::default to that target's default 
> generic address space since that matches most other languages.
> 
> The address space attribute would need a corresponding "+ 
> LangAS::target_first" to the value it stored in the AST.
> 
> Then it is possible to definitively tell when an AST node has not had any 
> address space specified as it will be the LangAS::default value.
There is a lit test like this:

```
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only

#define OPENCL_CONSTANT 8388354
int __attribute__((address_space(OPENCL_CONSTANT))) c[3] = {0};

void foo() {
  c[0] = 1; //expected-error{{read-only variable is not assignable}}
}

```
It tries to set address space of opencl_constant through 
`__attribute__((address_space(n)))`. If we "+ LangAS::target_first" to the 
value before it is tored in the AST, we are not able to use 
`__attribute__((address_space(n)))` to represent opencl_constant.


https://reviews.llvm.org/D31404



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


[PATCH] D31044: Update for alloca construction changes

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

LGTM.


https://reviews.llvm.org/D31044



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


[PATCH] D31044: Update for alloca construction changes

2017-03-28 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 93282.

https://reviews.llvm.org/D31044

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExpr.cpp


Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -71,7 +71,8 @@
 /// block.
 llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(llvm::Type *Ty,
 const Twine ) {
-  return new llvm::AllocaInst(Ty, nullptr, Name, AllocaInsertPt);
+  return new llvm::AllocaInst(Ty, CGM.getDataLayout().getAllocaAddrSpace(),
+  nullptr, Name, AllocaInsertPt);
 }
 
 /// CreateDefaultAlignTempAlloca - This creates an alloca with the
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -3710,12 +3710,14 @@
   Address ArgMemory = Address::invalid();
   const llvm::StructLayout *ArgMemoryLayout = nullptr;
   if (llvm::StructType *ArgStruct = CallInfo.getArgStruct()) {
-ArgMemoryLayout = CGM.getDataLayout().getStructLayout(ArgStruct);
+const llvm::DataLayout  = CGM.getDataLayout();
+ArgMemoryLayout = DL.getStructLayout(ArgStruct);
 llvm::Instruction *IP = CallArgs.getStackBase();
 llvm::AllocaInst *AI;
 if (IP) {
   IP = IP->getNextNode();
-  AI = new llvm::AllocaInst(ArgStruct, "argmem", IP);
+  AI = new llvm::AllocaInst(ArgStruct, DL.getAllocaAddrSpace(),
+"argmem", IP);
 } else {
   AI = CreateTempAlloca(ArgStruct, "argmem");
 }


Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -71,7 +71,8 @@
 /// block.
 llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(llvm::Type *Ty,
 const Twine ) {
-  return new llvm::AllocaInst(Ty, nullptr, Name, AllocaInsertPt);
+  return new llvm::AllocaInst(Ty, CGM.getDataLayout().getAllocaAddrSpace(),
+  nullptr, Name, AllocaInsertPt);
 }
 
 /// CreateDefaultAlignTempAlloca - This creates an alloca with the
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -3710,12 +3710,14 @@
   Address ArgMemory = Address::invalid();
   const llvm::StructLayout *ArgMemoryLayout = nullptr;
   if (llvm::StructType *ArgStruct = CallInfo.getArgStruct()) {
-ArgMemoryLayout = CGM.getDataLayout().getStructLayout(ArgStruct);
+const llvm::DataLayout  = CGM.getDataLayout();
+ArgMemoryLayout = DL.getStructLayout(ArgStruct);
 llvm::Instruction *IP = CallArgs.getStackBase();
 llvm::AllocaInst *AI;
 if (IP) {
   IP = IP->getNextNode();
-  AI = new llvm::AllocaInst(ArgStruct, "argmem", IP);
+  AI = new llvm::AllocaInst(ArgStruct, DL.getAllocaAddrSpace(),
+"argmem", IP);
 } else {
   AI = CreateTempAlloca(ArgStruct, "argmem");
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31235: Enhance -Wshadow to warn when shadowing typedefs or type aliases

2017-03-28 Thread Ahmed Asadi via Phabricator via cfe-commits
ahmedasadi marked 3 inline comments as done.
ahmedasadi added inline comments.



Comment at: test/SemaCXX/warn-shadow.cpp:65
 char *data; // expected-warning {{declaration shadows a static data member 
of 'A'}}
+char *a1; // expected-warning {{declaration shadows a typedef in 'A'}}
+char *a2; // expected-warning {{declaration shadows a type alias in 'A'}}

arphaman wrote:
> It looks like previously this wouldn't have been a warning. Should we really 
> warn about local variables that shadow typedef names?
GCC does, though I agree the warning isn't that helpful as a variable typically 
can't be used in place of a type (only exception I can think of is sizeof).

I'll modify the patch to only warn when typedefs / type aliases shadow each 
other.


https://reviews.llvm.org/D31235



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


[PATCH] D27387: [libc++] Add a key function for bad_function_call

2017-03-28 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL298937: [libc++] Add a key function for bad_function_call 
(authored by smeenai).

Changed prior to commit:
  https://reviews.llvm.org/D27387?vs=90524=93276#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27387

Files:
  libcxx/trunk/include/__config
  libcxx/trunk/include/functional
  libcxx/trunk/lib/CMakeLists.txt
  libcxx/trunk/src/functional.cpp


Index: libcxx/trunk/lib/CMakeLists.txt
===
--- libcxx/trunk/lib/CMakeLists.txt
+++ libcxx/trunk/lib/CMakeLists.txt
@@ -177,7 +177,7 @@
 split_list(LIBCXX_COMPILE_FLAGS)
 split_list(LIBCXX_LINK_FLAGS)
 
-# Add a object library that contains the compiled source files.
+# Add an object library that contains the compiled source files.
 add_library(cxx_objects OBJECT ${exclude_from_all} ${LIBCXX_SOURCES} 
${LIBCXX_HEADERS})
 if(WIN32 AND NOT MINGW)
   target_compile_definitions(cxx_objects
Index: libcxx/trunk/src/functional.cpp
===
--- libcxx/trunk/src/functional.cpp
+++ libcxx/trunk/src/functional.cpp
@@ -0,0 +1,26 @@
+//===--- functional.cpp 
---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "functional"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+bad_function_call::~bad_function_call() _NOEXCEPT
+{
+}
+
+const char*
+bad_function_call::what() const _NOEXCEPT
+{
+return "std::bad_function_call";
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
Index: libcxx/trunk/include/__config
===
--- libcxx/trunk/include/__config
+++ libcxx/trunk/include/__config
@@ -58,6 +58,10 @@
 // `pointer_safety` and `get_pointer_safety()` will no longer be available
 // in C++03.
 #define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
+// Define a key function for `bad_function_call` in the library, to centralize
+// its vtable and typeinfo to libc++ rather than having all other libraries
+// using that class define their own copies.
+#define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
 #elif _LIBCPP_ABI_VERSION == 1
 #if !defined(_WIN32)
 // Enable compiling copies of now inline methods into the dylib to support
Index: libcxx/trunk/include/functional
===
--- libcxx/trunk/include/functional
+++ libcxx/trunk/include/functional
@@ -1389,6 +1389,12 @@
 class _LIBCPP_EXCEPTION_ABI bad_function_call
 : public exception
 {
+#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+public:
+virtual ~bad_function_call() _NOEXCEPT;
+
+virtual const char* what() const _NOEXCEPT;
+#endif
 };
 
 _LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE


Index: libcxx/trunk/lib/CMakeLists.txt
===
--- libcxx/trunk/lib/CMakeLists.txt
+++ libcxx/trunk/lib/CMakeLists.txt
@@ -177,7 +177,7 @@
 split_list(LIBCXX_COMPILE_FLAGS)
 split_list(LIBCXX_LINK_FLAGS)
 
-# Add a object library that contains the compiled source files.
+# Add an object library that contains the compiled source files.
 add_library(cxx_objects OBJECT ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
 if(WIN32 AND NOT MINGW)
   target_compile_definitions(cxx_objects
Index: libcxx/trunk/src/functional.cpp
===
--- libcxx/trunk/src/functional.cpp
+++ libcxx/trunk/src/functional.cpp
@@ -0,0 +1,26 @@
+//===--- functional.cpp ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "functional"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+bad_function_call::~bad_function_call() _NOEXCEPT
+{
+}
+
+const char*
+bad_function_call::what() const _NOEXCEPT
+{
+return "std::bad_function_call";
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
Index: libcxx/trunk/include/__config
===
--- libcxx/trunk/include/__config
+++ libcxx/trunk/include/__config
@@ -58,6 +58,10 @@
 // `pointer_safety` and `get_pointer_safety()` will no longer be available
 // in C++03.
 #define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
+// Define a key function for `bad_function_call` in the library, to centralize
+// its vtable and typeinfo to libc++ rather than having all other libraries
+// using 

[libcxx] r298937 - [libc++] Add a key function for bad_function_call

2017-03-28 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Tue Mar 28 14:33:31 2017
New Revision: 298937

URL: http://llvm.org/viewvc/llvm-project?rev=298937=rev
Log:
[libc++] Add a key function for bad_function_call

Summary:
bad_function_call is currently an empty class, so any object files using
that class will end up with their own copy of its typeinfo, typeinfo
name and vtable, leading to unnecessary duplication that has to be
resolved by the dynamic linker. Instead, give bad_function_call a key
function and put a definition for that key function in libc++ itself, to
centralize the typeinfo and vtable.

This is consistent with the behavior for other exception classes. The
key functions are defined in libc++ rather than libc++abi since the
class is defined in the libc++ versioning namespace, so ABI
compatibility with libstdc++ is not a concern.

Guard this change behind an ABI macro, since it isn't backwards
compatible (i.e., clients built against the new libc++ headers wouldn't
be able to run against an older libc++ library).

Reviewers: mclow.lists, EricWF

Subscribers: mgorny, cfe-commits

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

Added:
libcxx/trunk/src/functional.cpp
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/functional
libcxx/trunk/lib/CMakeLists.txt

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=298937=298936=298937=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Tue Mar 28 14:33:31 2017
@@ -58,6 +58,10 @@
 // `pointer_safety` and `get_pointer_safety()` will no longer be available
 // in C++03.
 #define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
+// Define a key function for `bad_function_call` in the library, to centralize
+// its vtable and typeinfo to libc++ rather than having all other libraries
+// using that class define their own copies.
+#define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
 #elif _LIBCPP_ABI_VERSION == 1
 #if !defined(_WIN32)
 // Enable compiling copies of now inline methods into the dylib to support

Modified: libcxx/trunk/include/functional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/functional?rev=298937=298936=298937=diff
==
--- libcxx/trunk/include/functional (original)
+++ libcxx/trunk/include/functional Tue Mar 28 14:33:31 2017
@@ -1389,6 +1389,12 @@ mem_fn(_Rp _Tp::* __pm) _NOEXCEPT
 class _LIBCPP_EXCEPTION_ABI bad_function_call
 : public exception
 {
+#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+public:
+virtual ~bad_function_call() _NOEXCEPT;
+
+virtual const char* what() const _NOEXCEPT;
+#endif
 };
 
 _LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=298937=298936=298937=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Tue Mar 28 14:33:31 2017
@@ -177,7 +177,7 @@ endif()
 split_list(LIBCXX_COMPILE_FLAGS)
 split_list(LIBCXX_LINK_FLAGS)
 
-# Add a object library that contains the compiled source files.
+# Add an object library that contains the compiled source files.
 add_library(cxx_objects OBJECT ${exclude_from_all} ${LIBCXX_SOURCES} 
${LIBCXX_HEADERS})
 if(WIN32 AND NOT MINGW)
   target_compile_definitions(cxx_objects

Added: libcxx/trunk/src/functional.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/functional.cpp?rev=298937=auto
==
--- libcxx/trunk/src/functional.cpp (added)
+++ libcxx/trunk/src/functional.cpp Tue Mar 28 14:33:31 2017
@@ -0,0 +1,26 @@
+//===--- functional.cpp 
---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "functional"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+bad_function_call::~bad_function_call() _NOEXCEPT
+{
+}
+
+const char*
+bad_function_call::what() const _NOEXCEPT
+{
+return "std::bad_function_call";
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD


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


[PATCH] D31272: Do not pass an explicit reexported symbol list when building libc++ dylib if also defining new/delete

2017-03-28 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

OK, I figured, it is because I have this revision locally on top of this one: 
https://reviews.llvm.org/D30765 ; and I can't submit the latter without the 
change here.


https://reviews.llvm.org/D31272



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


[PATCH] D27387: [libc++] Add a key function for bad_function_call

2017-03-28 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In https://reviews.llvm.org/D27387#711866, @EricWF wrote:

> This LGTM, but I have a question: Should we add these dylib definitions right 
> away so that it's easier to adopt the ABI change in future? This will allow 
> legacy dylibs to support this ABI change in future. If you agree we can make 
> that change as a follow up commit.


As in, leave the header as-is, but make the definitions in `functional.cpp` 
unconditional? I'm fine with that.


https://reviews.llvm.org/D27387



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


[PATCH] D23418: [analyzer] Added a reusable constraint system to the CloneDetector

2017-03-28 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor updated this revision to Diff 93270.
teemperor added a comment.

- Remove the `assert(ChildHash)` which is obviously wrong code that just rarely 
fails.


https://reviews.llvm.org/D23418

Files:
  include/clang/Analysis/CloneDetection.h
  lib/Analysis/CloneDetection.cpp
  lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  unittests/Analysis/CMakeLists.txt
  unittests/Analysis/CloneDetectionTest.cpp

Index: unittests/Analysis/CloneDetectionTest.cpp
===
--- /dev/null
+++ unittests/Analysis/CloneDetectionTest.cpp
@@ -0,0 +1,109 @@
+//===- unittests/Analysis/CloneDetectionTest.cpp - Clone detection tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Analysis/CloneDetection.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace analysis {
+namespace {
+
+class CloneDetectionVisitor
+: public RecursiveASTVisitor {
+
+  CloneDetector 
+
+public:
+  explicit CloneDetectionVisitor(CloneDetector ) : Detector(D) {}
+
+  bool VisitFunctionDecl(FunctionDecl *D) {
+Detector.analyzeCodeBody(D);
+return true;
+  }
+};
+
+/// Example constraint for testing purposes.
+/// Filters out all statements that are in a function which name starts with
+/// "bar".
+class NoBarFunctionConstraint {
+public:
+  void constrain(std::vector ) {
+CloneConstraint::splitCloneGroups(CloneGroups, [](const StmtSequence ,
+  const StmtSequence ) {
+  // Check if one of the sequences is in a function which name starts with
+  // "bar".
+  for (const StmtSequence  : {A, B}) {
+if (auto *D = dyn_cast(Arg.getContainingDecl())) {
+  if (D->getNameAsString().find("bar") == 0)
+return false;
+}
+  }
+  return true;
+});
+  }
+};
+
+TEST(CloneDetector, NoPostOrderTraversal) {
+  auto ASTUnit =
+  clang::tooling::buildASTFromCode("void foo1(int ) { a1++; }\n"
+   "void foo2(int ) { a2++; }\n"
+   "void bar1(int ) { a3++; }\n"
+   "void bar2(int ) { a4++; }\n");
+  auto TU = ASTUnit->getASTContext().getTranslationUnitDecl();
+
+  CloneDetector Detector;
+  // Push all the function bodies into the detector.
+  CloneDetectionVisitor Visitor(Detector);
+  Visitor.TraverseTranslationUnitDecl(TU);
+
+  // Find clones with the usual settings, but but we want to filter out
+  // all statements from functions which names start with "bar".
+  std::vector CloneGroups;
+  Detector.findClones(CloneGroups, NoBarFunctionConstraint(),
+  RecursiveCloneTypeIIConstraint(),
+  MinComplexityConstraint(2), MinGroupSizeConstraint(2),
+  OnlyLargestCloneConstraint());
+
+  ASSERT_EQ(CloneGroups.size(), 1u);
+  ASSERT_EQ(CloneGroups.front().size(), 2u);
+
+  for (auto  : CloneGroups.front()) {
+auto ND = dyn_cast(Clone.getContainingDecl());
+ASSERT_TRUE(ND != nullptr);
+// Check that no function name starting with "bar" is in the results...
+ASSERT_TRUE(ND->getNameAsString().find("bar") != 0);
+  }
+
+  // Retry above's example without the filter...
+  CloneGroups.clear();
+
+  Detector.findClones(CloneGroups, RecursiveCloneTypeIIConstraint(),
+  MinComplexityConstraint(2), MinGroupSizeConstraint(2),
+  OnlyLargestCloneConstraint());
+  ASSERT_EQ(CloneGroups.size(), 1u);
+  ASSERT_EQ(CloneGroups.front().size(), 4u);
+
+  // Count how many functions with the bar prefix we have in the results.
+  int FoundFunctionsWithBarPrefix = 0;
+  for (auto  : CloneGroups.front()) {
+auto ND = dyn_cast(Clone.getContainingDecl());
+ASSERT_TRUE(ND != nullptr);
+// This time check that we picked up the bar functions from above
+if (ND->getNameAsString().find("bar") == 0) {
+  FoundFunctionsWithBarPrefix++;
+}
+  }
+  // We should have found the two functions bar1 and bar2.
+  ASSERT_EQ(FoundFunctionsWithBarPrefix, 2);
+}
+} // namespace
+} // namespace analysis
+} // namespace clang
Index: unittests/Analysis/CMakeLists.txt
===
--- unittests/Analysis/CMakeLists.txt
+++ unittests/Analysis/CMakeLists.txt
@@ -2,11 +2,12 @@
   Support
   )
 
-add_clang_unittest(CFGTests
+add_clang_unittest(ClangAnalysisTests
   CFGTest.cpp
+  CloneDetectionTest.cpp
   )
 
-target_link_libraries(CFGTests
+target_link_libraries(ClangAnalysisTests
   clangAnalysis
   clangAST
   clangASTMatchers
Index: lib/StaticAnalyzer/Checkers/CloneChecker.cpp

[PATCH] D31363: [libc++] Remove cmake glob for source files

2017-03-28 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

LLVM has a CMake module "LLVMProcessSources.cmake" which verifies that all 
source files are referenced in the CMakeLists file. Since it is part of the 
LLVM distributed modules, you can re-use it in libcxx.


https://reviews.llvm.org/D31363



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


[PATCH] D26108: Add -Wnullability-completeness-on-arrays.

2017-03-28 Thread Ricardo Sanchez-Saez via Phabricator via cfe-commits
rsanchezsaez added a comment.

Haha! That makes sense. (I miss GitHub's comment reactions on Phabricator, 
consider your comments 'ed.)


Repository:
  rL LLVM

https://reviews.llvm.org/D26108



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


[PATCH] D31428: [x86] fix AVX FP cmp intrinsic documentation (PR28110)

2017-03-28 Thread Sanjay Patel via Phabricator via cfe-commits
spatel created this revision.
Herald added a subscriber: mcrosier.

This copies the text used in the #define statements to the code comments. The 
conflicting text comes from AMD manuals, but those are wrong. Sadly, this part 
has not been updated even after some docs were updated for Zen:
http://support.amd.com/en-us/search/tech-docs ( AMD64 Architecture Programmer's 
Manual Volume 4 )

See PR28110 for more discussion:
https://bugs.llvm.org/show_bug.cgi?id=28110


https://reviews.llvm.org/D31428

Files:
  lib/Headers/avxintrin.h

Index: lib/Headers/avxintrin.h
===
--- lib/Headers/avxintrin.h
+++ lib/Headers/avxintrin.h
@@ -1660,17 +1660,38 @@
 /// \param c
 ///An immediate integer operand, with bits [4:0] specifying which comparison
 ///operation to use: \n
-///00h, 08h, 10h, 18h: Equal \n
-///01h, 09h, 11h, 19h: Less than \n
-///02h, 0Ah, 12h, 1Ah: Less than or equal / Greater than or equal
-///(swapped operands) \n
-///03h, 0Bh, 13h, 1Bh: Unordered \n
-///04h, 0Ch, 14h, 1Ch: Not equal \n
-///05h, 0Dh, 15h, 1Dh: Not less than / Not greater than
-///(swapped operands) \n
-///06h, 0Eh, 16h, 1Eh: Not less than or equal / Not greater than or equal
-///(swapped operands) \n
-///07h, 0Fh, 17h, 1Fh: Ordered
+///0x00 : Equal (ordered, non-signaling)
+///0x01 : Less-than (ordered, signaling)
+///0x02 : Less-than-or-equal (ordered, signaling)
+///0x03 : Unordered (non-signaling)
+///0x04 : Not-equal (unordered, non-signaling)
+///0x05 : Not-less-than (unordered, signaling)
+///0x06 : Not-less-than-or-equal (unordered, signaling)
+///0x07 : Ordered (nonsignaling)
+///0x08 : Equal (unordered, non-signaling)
+///0x09 : Not-greater-than-or-equal (unord, signaling)
+///0x0a : Not-greater-than (unordered, signaling)
+///0x0b : False (ordered, non-signaling)
+///0x0c : Not-equal (ordered, non-signaling)
+///0x0d : Greater-than-or-equal (ordered, signaling)
+///0x0e : Greater-than (ordered, signaling)
+///0x0f : True (unordered, non-signaling)
+///0x10 : Equal (ordered, signaling)
+///0x11 : Less-than (ordered, non-signaling)
+///0x12 : Less-than-or-equal (ordered, non-signaling)
+///0x13 : Unordered (signaling)
+///0x14 : Not-equal (unordered, signaling)
+///0x15 : Not-less-than (unordered, non-signaling)
+///0x16 : Not-less-than-or-equal (unord, non-signaling)
+///0x17 : Ordered (signaling)
+///0x18 : Equal (unordered, signaling)
+///0x19 : Not-greater-than-or-equal (unord, non-sign)
+///0x1a : Not-greater-than (unordered, non-signaling)
+///0x1b : False (ordered, signaling)
+///0x1c : Not-equal (ordered, signaling)
+///0x1d : Greater-than-or-equal (ordered, non-signaling)
+///0x1e : Greater-than (ordered, non-signaling)
+///0x1f : True (unordered, signaling)
 /// \returns A 128-bit vector of [2 x double] containing the comparison results.
 #define _mm_cmp_pd(a, b, c) __extension__ ({ \
   (__m128d)__builtin_ia32_cmppd((__v2df)(__m128d)(a), \
@@ -1697,17 +1718,38 @@
 /// \param c
 ///An immediate integer operand, with bits [4:0] specifying which comparison
 ///operation to use: \n
-///00h, 08h, 10h, 18h: Equal \n
-///01h, 09h, 11h, 19h: Less than \n
-///02h, 0Ah, 12h, 1Ah: Less than or equal / Greater than or equal
-///(swapped operands) \n
-///03h, 0Bh, 13h, 1Bh: Unordered \n
-///04h, 0Ch, 14h, 1Ch: Not equal \n
-///05h, 0Dh, 15h, 1Dh: Not less than / Not greater than
-///(swapped operands) \n
-///06h, 0Eh, 16h, 1Eh: Not less than or equal / Not greater than or equal
-///(swapped operands) \n
-///07h, 0Fh, 17h, 1Fh: Ordered
+///0x00 : Equal (ordered, non-signaling)
+///0x01 : Less-than (ordered, signaling)
+///0x02 : Less-than-or-equal (ordered, signaling)
+///0x03 : Unordered (non-signaling)
+///0x04 : Not-equal (unordered, non-signaling)
+///0x05 : Not-less-than (unordered, signaling)
+///0x06 : Not-less-than-or-equal (unordered, signaling)
+///0x07 : Ordered (nonsignaling)
+///0x08 : Equal (unordered, non-signaling)
+///0x09 : Not-greater-than-or-equal (unord, signaling)
+///0x0a : Not-greater-than (unordered, signaling)
+///0x0b : False (ordered, non-signaling)
+///0x0c : Not-equal (ordered, non-signaling)
+///0x0d : Greater-than-or-equal (ordered, signaling)
+///0x0e : Greater-than (ordered, signaling)
+///0x0f : True (unordered, non-signaling)
+///0x10 : Equal (ordered, signaling)
+///0x11 : Less-than (ordered, non-signaling)
+///0x12 : Less-than-or-equal (ordered, non-signaling)
+///0x13 : Unordered (signaling)
+///0x14 : Not-equal (unordered, signaling)
+///0x15 : Not-less-than (unordered, non-signaling)
+///

[PATCH] D26108: Add -Wnullability-completeness-on-arrays.

2017-03-28 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose added a comment.

Yep, that's the correct syntax. It's not wonderful, but it's already where the 
C standard lets you put `const`, so we're just following established practice. 
(Learn something new and awful about C every day!)


Repository:
  rL LLVM

https://reviews.llvm.org/D26108



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


[PATCH] D26108: Add -Wnullability-completeness-on-arrays.

2017-03-28 Thread Ricardo Sanchez-Saez via Phabricator via cfe-commits
rsanchezsaez added a comment.

Oh, I see. Thanks for the explanation.

The fix-it syntax got me confused:

  - (instancetype)initWithValues:(const int32_t [__null_unspecified])values


Repository:
  rL LLVM

https://reviews.llvm.org/D26108



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


[PATCH] D26108: Add -Wnullability-completeness-on-arrays.

2017-03-28 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose added a comment.

No, the *arrays themselves* need to be marked as nullable or non-nullable. 
Remember that in C array parameters are passed as pointers.

The compiler should give you a fix-it that shows the correct syntax.


Repository:
  rL LLVM

https://reviews.llvm.org/D26108



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


[PATCH] D26108: Add -Wnullability-completeness-on-arrays.

2017-03-28 Thread Ricardo Sanchez-Saez via Phabricator via cfe-commits
rsanchezsaez added a comment.

I think this makes the warning to trigger on methods such as:

  - (instancetype)initWithValues:(const int32_t [])values
  - (void)updateWithRange:(NSRange)range floatArray:(CGFloat[])array;

(experienced on the just released //Xcode 8.3//).

Perhaps I'm misunderstanding something, but shouldn't the warning only apply to 
arrays of pointer types?


Repository:
  rL LLVM

https://reviews.llvm.org/D26108



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


[PATCH] D31289: [analyzer] Fix symbolication for unknown unary increment/decrement results.

2017-03-28 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL298927: [analyzer] Fix symbolication for unknown unary 
increment/decrement results. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D31289?vs=92812=93251#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31289

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  cfe/trunk/test/Analysis/casts.c


Index: cfe/trunk/test/Analysis/casts.c
===
--- cfe/trunk/test/Analysis/casts.c
+++ cfe/trunk/test/Analysis/casts.c
@@ -118,3 +118,8 @@
   extern float globalFloat;
   clang_analyzer_eval(globalFloat); // expected-warning{{UNKNOWN}}
 }
+
+void locAsIntegerCasts(void *p) {
+  int x = (int) p;
+  clang_analyzer_eval(++x < 10); // no-crash // expected-warning{{UNKNOWN}}
+}
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -1054,7 +1054,7 @@
 // Conjure a new symbol if necessary to recover precision.
 if (Result.isUnknown()){
   DefinedOrUnknownSVal SymVal =
-svalBuilder.conjureSymbolVal(nullptr, Ex, LCtx,
+svalBuilder.conjureSymbolVal(nullptr, U, LCtx,
  currBldrCtx->blockCount());
   Result = SymVal;
 
Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -362,6 +362,9 @@
  resultTy);
 case nonloc::ConcreteIntKind: {
   // Transform the integer into a location and compare.
+  // FIXME: This only makes sense for comparisons. If we want to, say,
+  // add 1 to a LocAsInteger, we'd better unpack the Loc and add to it,
+  // then pack it back into a LocAsInteger.
   llvm::APSInt i = rhs.castAs().getValue();
   BasicVals.getAPSIntType(Context.VoidPtrTy).apply(i);
   return evalBinOpLL(state, op, lhsL, makeLoc(i), resultTy);
@@ -942,6 +945,8 @@
 rhs = convertToArrayIndex(rhs).castAs();
 SVal index = UnknownVal();
 const MemRegion *superR = nullptr;
+// We need to know the type of the pointer in order to add an integer to 
it.
+// Depending on the type, different amount of bytes is added.
 QualType elementType;
 
 if (const ElementRegion *elemReg = dyn_cast(region)) {
@@ -955,6 +960,10 @@
   assert(op == BO_Add || op == BO_Sub);
   index = (op == BO_Add) ? rhs : evalMinus(rhs);
   superR = region;
+  // TODO: Is this actually reliable? Maybe improving our MemRegion
+  // hierarchy to provide typed regions for all non-void pointers would be
+  // better. For instance, we cannot extend this towards LocAsInteger
+  // operations, where result type of the expression is integer.
   if (resultTy->isAnyPointerType())
 elementType = resultTy->getPointeeType();
 }


Index: cfe/trunk/test/Analysis/casts.c
===
--- cfe/trunk/test/Analysis/casts.c
+++ cfe/trunk/test/Analysis/casts.c
@@ -118,3 +118,8 @@
   extern float globalFloat;
   clang_analyzer_eval(globalFloat); // expected-warning{{UNKNOWN}}
 }
+
+void locAsIntegerCasts(void *p) {
+  int x = (int) p;
+  clang_analyzer_eval(++x < 10); // no-crash // expected-warning{{UNKNOWN}}
+}
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -1054,7 +1054,7 @@
 // Conjure a new symbol if necessary to recover precision.
 if (Result.isUnknown()){
   DefinedOrUnknownSVal SymVal =
-svalBuilder.conjureSymbolVal(nullptr, Ex, LCtx,
+svalBuilder.conjureSymbolVal(nullptr, U, LCtx,
  currBldrCtx->blockCount());
   Result = SymVal;
 
Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -362,6 +362,9 @@
  resultTy);
 case nonloc::ConcreteIntKind: {
   // Transform the integer into a location and compare.
+  // FIXME: This only makes sense for comparisons. If we want to, say,
+  // add 1 to a LocAsInteger, we'd better unpack the Loc and add to it,
+  // then pack it back into a LocAsInteger.
   llvm::APSInt i = rhs.castAs().getValue();
   

r298927 - [analyzer] Fix symbolication for unknown unary increment/decrement results.

2017-03-28 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Mar 28 10:57:12 2017
New Revision: 298927

URL: http://llvm.org/viewvc/llvm-project?rev=298927=rev
Log:
[analyzer] Fix symbolication for unknown unary increment/decrement results.

If the value is known, but we cannot increment it, conjure a symbol to
represent the result of the operation based on the operator expression,
not on the sub-expression.

In particular, no longer crash on comparing a result of a LocAsInteger increment
to a constant integer.

rdar://problem/31067356

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
cfe/trunk/test/Analysis/casts.c

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp?rev=298927=298926=298927=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp Tue Mar 28 10:57:12 2017
@@ -1054,7 +1054,7 @@ void ExprEngine::VisitIncrementDecrement
 // Conjure a new symbol if necessary to recover precision.
 if (Result.isUnknown()){
   DefinedOrUnknownSVal SymVal =
-svalBuilder.conjureSymbolVal(nullptr, Ex, LCtx,
+svalBuilder.conjureSymbolVal(nullptr, U, LCtx,
  currBldrCtx->blockCount());
   Result = SymVal;
 

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp?rev=298927=298926=298927=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp Tue Mar 28 10:57:12 
2017
@@ -362,6 +362,9 @@ SVal SimpleSValBuilder::evalBinOpNN(Prog
  resultTy);
 case nonloc::ConcreteIntKind: {
   // Transform the integer into a location and compare.
+  // FIXME: This only makes sense for comparisons. If we want to, say,
+  // add 1 to a LocAsInteger, we'd better unpack the Loc and add to it,
+  // then pack it back into a LocAsInteger.
   llvm::APSInt i = rhs.castAs().getValue();
   BasicVals.getAPSIntType(Context.VoidPtrTy).apply(i);
   return evalBinOpLL(state, op, lhsL, makeLoc(i), resultTy);
@@ -942,6 +945,8 @@ SVal SimpleSValBuilder::evalBinOpLN(Prog
 rhs = convertToArrayIndex(rhs).castAs();
 SVal index = UnknownVal();
 const MemRegion *superR = nullptr;
+// We need to know the type of the pointer in order to add an integer to 
it.
+// Depending on the type, different amount of bytes is added.
 QualType elementType;
 
 if (const ElementRegion *elemReg = dyn_cast(region)) {
@@ -955,6 +960,10 @@ SVal SimpleSValBuilder::evalBinOpLN(Prog
   assert(op == BO_Add || op == BO_Sub);
   index = (op == BO_Add) ? rhs : evalMinus(rhs);
   superR = region;
+  // TODO: Is this actually reliable? Maybe improving our MemRegion
+  // hierarchy to provide typed regions for all non-void pointers would be
+  // better. For instance, we cannot extend this towards LocAsInteger
+  // operations, where result type of the expression is integer.
   if (resultTy->isAnyPointerType())
 elementType = resultTy->getPointeeType();
 }

Modified: cfe/trunk/test/Analysis/casts.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/casts.c?rev=298927=298926=298927=diff
==
--- cfe/trunk/test/Analysis/casts.c (original)
+++ cfe/trunk/test/Analysis/casts.c Tue Mar 28 10:57:12 2017
@@ -118,3 +118,8 @@ void castsToBool() {
   extern float globalFloat;
   clang_analyzer_eval(globalFloat); // expected-warning{{UNKNOWN}}
 }
+
+void locAsIntegerCasts(void *p) {
+  int x = (int) p;
+  clang_analyzer_eval(++x < 10); // no-crash // expected-warning{{UNKNOWN}}
+}


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


[PATCH] D30534: [analyzer] When creating a temporary object copy, properly copy the value into it.

2017-03-28 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL298924: [analyzer] When creating a temporary object, 
properly copy the value into it. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D30534?vs=92618=93250#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30534

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
  cfe/trunk/test/Analysis/temporaries-callback-order.cpp
  cfe/trunk/test/Analysis/temporaries.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -182,19 +182,25 @@
 ProgramStateRef
 ExprEngine::createTemporaryRegionIfNeeded(ProgramStateRef State,
   const LocationContext *LC,
-  const Expr *Ex,
+  const Expr *InitWithAdjustments,
   const Expr *Result) {
-  SVal V = State->getSVal(Ex, LC);
+  // FIXME: This function is a hack that works around the quirky AST
+  // we're often having with respect to C++ temporaries. If only we modelled
+  // the actual execution order of statements properly in the CFG,
+  // all the hassle with adjustments would not be necessary,
+  // and perhaps the whole function would be removed.
+  SVal InitValWithAdjustments = State->getSVal(InitWithAdjustments, LC);
   if (!Result) {
 // If we don't have an explicit result expression, we're in "if needed"
 // mode. Only create a region if the current value is a NonLoc.
-if (!V.getAs())
+if (!InitValWithAdjustments.getAs())
   return State;
-Result = Ex;
+Result = InitWithAdjustments;
   } else {
 // We need to create a region no matter what. For sanity, make sure we don't
 // try to stuff a Loc into a non-pointer temporary region.
-assert(!V.getAs() || Loc::isLocType(Result->getType()) ||
+assert(!InitValWithAdjustments.getAs() ||
+   Loc::isLocType(Result->getType()) ||
Result->getType()->isMemberPointerType());
   }
 
@@ -226,7 +232,8 @@
   SmallVector CommaLHSs;
   SmallVector Adjustments;
 
-  const Expr *Init = Ex->skipRValueSubobjectAdjustments(CommaLHSs, Adjustments);
+  const Expr *Init = InitWithAdjustments->skipRValueSubobjectAdjustments(
+  CommaLHSs, Adjustments);
 
   const TypedValueRegion *TR = nullptr;
   if (const MaterializeTemporaryExpr *MT =
@@ -241,6 +248,7 @@
 TR = MRMgr.getCXXTempObjectRegion(Init, LC);
 
   SVal Reg = loc::MemRegionVal(TR);
+  SVal BaseReg = Reg;
 
   // Make the necessary adjustments to obtain the sub-object.
   for (auto I = Adjustments.rbegin(), E = Adjustments.rend(); I != E; ++I) {
@@ -254,19 +262,47 @@
   break;
 case SubobjectAdjustment::MemberPointerAdjustment:
   // FIXME: Unimplemented.
-  State->bindDefault(Reg, UnknownVal(), LC);
+  State = State->bindDefault(Reg, UnknownVal(), LC);
   return State;
 }
   }
 
-  // Try to recover some path sensitivity in case we couldn't compute the value.
-  if (V.isUnknown())
-V = getSValBuilder().conjureSymbolVal(Result, LC, TR->getValueType(),
-  currBldrCtx->blockCount());
-  // Bind the value of the expression to the sub-object region, and then bind
-  // the sub-object region to our expression.
-  State = State->bindLoc(Reg, V, LC);
+  // What remains is to copy the value of the object to the new region.
+  // FIXME: In other words, what we should always do is copy value of the
+  // Init expression (which corresponds to the bigger object) to the whole
+  // temporary region TR. However, this value is often no longer present
+  // in the Environment. If it has disappeared, we instead invalidate TR.
+  // Still, what we can do is assign the value of expression Ex (which
+  // corresponds to the sub-object) to the TR's sub-region Reg. At least,
+  // values inside Reg would be correct.
+  SVal InitVal = State->getSVal(Init, LC);
+  if (InitVal.isUnknown()) {
+InitVal = getSValBuilder().conjureSymbolVal(Result, LC, Init->getType(),
+currBldrCtx->blockCount());
+State = State->bindLoc(BaseReg.castAs(), InitVal, LC, false);
+
+// Then we'd need to take the value that certainly exists and bind it over.
+if (InitValWithAdjustments.isUnknown()) {
+  // Try to recover some path sensitivity in case we couldn't
+  // compute the value.
+  InitValWithAdjustments = getSValBuilder().conjureSymbolVal(
+  Result, LC, InitWithAdjustments->getType(),
+  currBldrCtx->blockCount());
+}
+State =
+

r298924 - [analyzer] When creating a temporary object, properly copy the value into it.

2017-03-28 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Mar 28 10:43:26 2017
New Revision: 298924

URL: http://llvm.org/viewvc/llvm-project?rev=298924=rev
Log:
[analyzer] When creating a temporary object, properly copy the value into it.

Adjustments should be considered properly; we should copy the unadjusted object
over the whole temporary base region. If the unadjusted object is no longer
available in the Environment, invalidate the temporary base region, and then
copy the adjusted object into the adjusted sub-region of the temporary region.

This fixes a regression introduced by r288263, that caused various
false positives, due to copying only adjusted object into the adjusted region;
the rest of the base region therefore remained undefined.
Before r288263, the adjusted value was copied over the unadjusted region,
which is incorrect, but accidentally worked better due to how region store
disregards compound value bindings to non-base regions.

An additional test machinery is introduced to make sure that despite making
two binds, we only notify checkers once for both of them, without exposing
the partially copied objects.

This fix is a hack over a hack. The proper fix would be to model C++ temporaries
in the CFG, and after that dealing with adjustments would no longer be
necessary, and the values we need would no longer disappear from the
Environment.

rdar://problem/30658168

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

Added:
cfe/trunk/test/Analysis/temporaries-callback-order.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/Analysis/temporaries.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=298924=298923=298924=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Tue 
Mar 28 10:43:26 2017
@@ -621,16 +621,16 @@ private:
   void performTrivialCopy(NodeBuilder , ExplodedNode *Pred,
   const CallEvent );
 
-  /// If the value of the given expression is a NonLoc, copy it into a new
-  /// temporary object region, and replace the value of the expression with
-  /// that.
+  /// If the value of the given expression \p InitWithAdjustments is a NonLoc,
+  /// copy it into a new temporary object region, and replace the value of the
+  /// expression with that.
   ///
-  /// If \p ResultE is provided, the new region will be bound to this 
expression
-  /// instead of \p E.
+  /// If \p Result is provided, the new region will be bound to this expression
+  /// instead of \p InitWithAdjustments.
   ProgramStateRef createTemporaryRegionIfNeeded(ProgramStateRef State,
 const LocationContext *LC,
-const Expr *E,
-const Expr *ResultE = nullptr);
+const Expr 
*InitWithAdjustments,
+const Expr *Result = nullptr);
 
   /// For a DeclStmt or CXXInitCtorInitializer, walk backward in the current 
CFG
   /// block to find the constructor expression that directly constructed into

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp?rev=298924=298923=298924=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp Tue Mar 28 
10:43:26 2017
@@ -24,16 +24,29 @@ using namespace ento;
 
 namespace {
 
-class AnalysisOrderChecker : public Checker< check::PreStmt,
- check::PostStmt,
- 
check::PreStmt,
- 
check::PostStmt> {
-  bool isCallbackEnabled(CheckerContext , StringRef CallbackName) const {
-AnalyzerOptions  = C.getAnalysisManager().getAnalyzerOptions();
+class AnalysisOrderChecker
+: public Checker {
+  bool isCallbackEnabled(AnalyzerOptions , StringRef CallbackName) const {
 return Opts.getBooleanOption("*", false, this) ||
 Opts.getBooleanOption(CallbackName, false, this);
   }
 
+  bool 

[PATCH] D31375: Add docs for libunwind

2017-03-28 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

Review for adding a builder in: https://reviews.llvm.org/D31422


https://reviews.llvm.org/D31375



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


[PATCH] D31422: Add builder for libunwind docs

2017-03-28 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs created this revision.

Dimitri, do you mind hosting another docs builder on your machine?


https://reviews.llvm.org/D31422

Files:
  buildbot/osuosl/master/config/builders.py
  zorg/buildbot/builders/SphinxDocsBuilder.py


Index: zorg/buildbot/builders/SphinxDocsBuilder.py
===
--- zorg/buildbot/builders/SphinxDocsBuilder.py
+++ zorg/buildbot/builders/SphinxDocsBuilder.py
@@ -11,7 +11,8 @@
 clang_html= False, # Build Clang HTML documentation
 clang_tools_html  = False, # Build Clang Extra Tools HTML documentation
 lld_html  = False, # Build LLD HTML documentation
-libcxx_html   = False  # Build Libc++ HTML documentation
+libcxx_html   = False, # Build Libc++ HTML documentation
+libunwind_html= False  # Build libunwind HTML documentation
 ):
 
 f = buildbot.process.factory.BuildFactory()
@@ -23,6 +24,7 @@
 lld_srcdir = llvm_srcdir + '/tools/lld'
 libcxx_srcdir = llvm_srcdir + '/projects/libcxx'
 libcxxabi_srcdir = llvm_srcdir + '/projects/libcxxabi'
+libunwind_srcdir = llvm_srcdir + '/projects/libunwind'
 
 # Get LLVM. This is essential for all builds
 # because we build all subprojects in tree
@@ -65,6 +67,13 @@
   defaultBranch='trunk',
   workdir=libcxxabi_srcdir))
 
+if libunwind_html:
+f.addStep(SVN(name='svn-libunwind',
+  mode='update',
+  baseURL='http://llvm.org/svn/llvm-project/libunwind/',
+  defaultBranch='trunk',
+  workdir=libunwind_srcdir))
+
 f.addStep(ShellCommand(name="create-build-dir",
command=["mkdir", "-p", llvm_objdir],
haltOnFailure=False, # We might of already 
created the directory in a previous build
@@ -132,4 +141,12 @@
targets=['docs-libcxx-html']
   ))
 
+if libunwind_html:
+f.addStep(NinjaCommand(name="docs-libunwind-html",
+   haltOnFailure=True,
+   description=["Build libunwind Sphinx HTML 
documentation"],
+   workdir=llvm_objdir,
+   targets=['docs-libunwind-html']
+  ))
+
 return f
Index: buildbot/osuosl/master/config/builders.py
===
--- buildbot/osuosl/master/config/builders.py
+++ buildbot/osuosl/master/config/builders.py
@@ -1353,6 +1353,13 @@
'builddir':"libcxx-sphinx-docs",
'factory': 
SphinxDocsBuilder.getSphinxDocsBuildFactory(libcxx_html=True),
'category' : 'libcxx'
+ },
+ {
+   'name':"libunwind-sphinx-docs",
+   'slavenames':["gribozavr3"],
+   'builddir':"libunwind-sphinx-docs",
+   'factory': 
SphinxDocsBuilder.getSphinxDocsBuildFactory(libunwind_html=True),
+   'category' : 'libunwind'
  }
]
 


Index: zorg/buildbot/builders/SphinxDocsBuilder.py
===
--- zorg/buildbot/builders/SphinxDocsBuilder.py
+++ zorg/buildbot/builders/SphinxDocsBuilder.py
@@ -11,7 +11,8 @@
 clang_html= False, # Build Clang HTML documentation
 clang_tools_html  = False, # Build Clang Extra Tools HTML documentation
 lld_html  = False, # Build LLD HTML documentation
-libcxx_html   = False  # Build Libc++ HTML documentation
+libcxx_html   = False, # Build Libc++ HTML documentation
+libunwind_html= False  # Build libunwind HTML documentation
 ):
 
 f = buildbot.process.factory.BuildFactory()
@@ -23,6 +24,7 @@
 lld_srcdir = llvm_srcdir + '/tools/lld'
 libcxx_srcdir = llvm_srcdir + '/projects/libcxx'
 libcxxabi_srcdir = llvm_srcdir + '/projects/libcxxabi'
+libunwind_srcdir = llvm_srcdir + '/projects/libunwind'
 
 # Get LLVM. This is essential for all builds
 # because we build all subprojects in tree
@@ -65,6 +67,13 @@
   defaultBranch='trunk',
   workdir=libcxxabi_srcdir))
 
+if libunwind_html:
+f.addStep(SVN(name='svn-libunwind',
+  mode='update',
+  baseURL='http://llvm.org/svn/llvm-project/libunwind/',
+  defaultBranch='trunk',
+  workdir=libunwind_srcdir))
+
 f.addStep(ShellCommand(name="create-build-dir",
command=["mkdir", "-p", llvm_objdir],
haltOnFailure=False, # We might of already created the directory in a previous build
@@ -132,4 +141,12 @@
targets=['docs-libcxx-html']
  

[PATCH] D31397: [Bug 25404] Fix crash on typedef in OpenCL 2.0

2017-03-28 Thread Alexey Bader via Phabricator via cfe-commits
bader accepted this revision.
bader added a comment.
This revision is now accepted and ready to land.

I think my topics are not related to the bug 25404 and can be handled 
separately.
Thanks!


https://reviews.llvm.org/D31397



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


[PATCH] D31375: Add docs for libunwind

2017-03-28 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs closed this revision.
jroelofs added a comment.

r298922


https://reviews.llvm.org/D31375



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


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-03-28 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 93244.
gtbercea added a comment.
Herald added a subscriber: rengolin.

Update patch to reflect latest source code changes.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload.c


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -636,6 +636,16 @@
 
 /// ###
 
+/// Check PTXAS is passed the compute capability passed to the driver.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
--fopenmp-ptx=+ptx52 -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTX %s
+
+// CHK-PTX: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTX-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTX-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+
+/// ###
+
 /// Check that CLANG forwards the -v flag to PTXAS.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-save-temps -no-canonical-prefixes -v %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-VERBOSE %s
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -492,8 +492,18 @@
   // than LLVM defaults to. Use PTX4.2 which is the PTX version that
   // came with CUDA-7.0.
   CC1Args.push_back("-target-feature");
+
+  StringRef PtxVersion = DriverArgs.getLastArgValue(
+options::OPT_fopenmp_ptx_EQ);
+
   CC1Args.push_back("+ptx42");
 
+  if (DeviceOffloadingKind == Action::OFK_OpenMP &&
+  !PtxVersion.empty()) {
+// Use PTX version passed to the driver.
+CC1Args.back() = PtxVersion.data();
+  }
+
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
 SmallVector LibraryPaths;
 if (char *Env = ::getenv("LIBRARY_PATH")) {
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -529,6 +529,8 @@
   HelpText<"CUDA installation path">;
 def fopenmp_cuda_gpu_arch_EQ : Joined<["--"], "fopenmp-cuda-gpu-arch=">, 
Flags<[DriverOption]>,
   HelpText<"Pass a single CUDA GPU architecture (default sm_20) to be used by 
OpenMP device offloading.">;
+def fopenmp_ptx_EQ : Joined<["--"], "fopenmp-ptx=">, Flags<[DriverOption]>,
+  HelpText<"Pass a PTX version +ptxXX, default +ptx42 (for PTX version 4.2) 
used by OpenMP device offloading.">;
 def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Group,
   HelpText<"Path to ptxas (used for compiling CUDA code)">;
 def fcuda_flush_denormals_to_zero : Flag<["-"], 
"fcuda-flush-denormals-to-zero">,


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -636,6 +636,16 @@
 
 /// ###
 
+/// Check PTXAS is passed the compute capability passed to the driver.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda --fopenmp-ptx=+ptx52 -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTX %s
+
+// CHK-PTX: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTX-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTX-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+
+/// ###
+
 /// Check that CLANG forwards the -v flag to PTXAS.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes -v %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-VERBOSE %s
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -492,8 +492,18 @@
   // than LLVM defaults to. Use PTX4.2 which is the PTX version that
   // came with CUDA-7.0.
   CC1Args.push_back("-target-feature");
+
+  StringRef PtxVersion = DriverArgs.getLastArgValue(
+options::OPT_fopenmp_ptx_EQ);
+
   CC1Args.push_back("+ptx42");
 
+  if (DeviceOffloadingKind == Action::OFK_OpenMP &&
+  !PtxVersion.empty()) {
+// Use PTX version passed to the driver.
+CC1Args.back() = PtxVersion.data();
+  }
+
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
 SmallVector LibraryPaths;
 if (char *Env = ::getenv("LIBRARY_PATH")) {
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td

[libunwind] r298922 - [libunwind] Add sphinx docs

2017-03-28 Thread Jonathan Roelofs via cfe-commits
Author: jroelofs
Date: Tue Mar 28 10:21:43 2017
New Revision: 298922

URL: http://llvm.org/viewvc/llvm-project?rev=298922=rev
Log:
[libunwind] Add sphinx docs

https://reviews.llvm.org/D31375

Added:
libunwind/trunk/docs/
libunwind/trunk/docs/BuildingLibunwind.rst
libunwind/trunk/docs/CMakeLists.txt
libunwind/trunk/docs/README.txt
libunwind/trunk/docs/conf.py
libunwind/trunk/docs/index.rst
Modified:
libunwind/trunk/CMakeLists.txt

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=298922=298921=298922=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Tue Mar 28 10:21:43 2017
@@ -122,6 +122,7 @@ option(LIBUNWIND_ENABLE_STATIC "Build li
 option(LIBUNWIND_ENABLE_CROSS_UNWINDING "Enable cross-platform unwinding 
support." OFF)
 option(LIBUNWIND_ENABLE_ARM_WMMX "Enable unwinding support for ARM WMMX 
registers." OFF)
 option(LIBUNWIND_ENABLE_THREADS "Build libunwind with threading support." ON)
+option(LIBUNWIND_INCLUDE_DOCS "Build the libunwind documentation." 
${LLVM_INCLUDE_DOCS})
 
 set(LIBUNWIND_TARGET_TRIPLE "" CACHE STRING "Target triple for cross 
compiling.")
 set(LIBUNWIND_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
@@ -303,3 +304,7 @@ if (NOT LIBUNWIND_CXX_INCLUDE_PATHS STRE
 endif()
 
 add_subdirectory(src)
+
+if (LIBUNWIND_INCLUDE_DOCS)
+  add_subdirectory(docs)
+endif()

Added: libunwind/trunk/docs/BuildingLibunwind.rst
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/docs/BuildingLibunwind.rst?rev=298922=auto
==
--- libunwind/trunk/docs/BuildingLibunwind.rst (added)
+++ libunwind/trunk/docs/BuildingLibunwind.rst Tue Mar 28 10:21:43 2017
@@ -0,0 +1,167 @@
+.. _BuildingLibunwind:
+
+==
+Building libunwind
+==
+
+.. contents::
+  :local:
+
+.. _build instructions:
+
+Getting Started
+===
+
+On Mac OS, the easiest way to get this library is to link with -lSystem.
+However if you want to build tip-of-trunk from here (getting the bleeding
+edge), read on.
+
+The basic steps needed to build libc++ are:
+
+#. Checkout LLVM:
+
+   * ``cd where-you-want-llvm-to-live``
+   * ``svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm``
+
+#. Checkout libunwind:
+
+   * ``cd where-you-want-llvm-to-live``
+   * ``cd llvm/runtimes``
+   * ``svn co http://llvm.org/svn/llvm-project/libunwind/trunk libunwind``
+
+#. Configure and build libunwind:
+
+   CMake is the only supported configuration system.
+
+   Clang is the preferred compiler when building and using libunwind.
+
+   * ``cd where you want to build llvm``
+   * ``mkdir build``
+   * ``cd build``
+   * ``cmake -G  [options] ``
+
+   For more information about configuring libunwind see :ref:`CMake Options`.
+
+   * ``make unwind`` --- will build libunwind.
+   * ``make check-unwind`` --- will run the test suite.
+
+   Shared and static libraries for libunwind should now be present in 
llvm/build/lib.
+
+#. **Optional**: Install libunwind
+
+   If your system already provides an unwinder, it is important to be careful
+   not to replace it. Remember Use the CMake option ``CMAKE_INSTALL_PREFIX`` to
+   select a safe place to install libunwind.
+
+   * ``make install-unwind`` --- Will install the libraries and the headers
+
+
+It is sometimes beneficial to build outside of the LLVM tree. An out-of-tree
+build would look like this:
+
+.. code-block:: bash
+
+  $ cd where-you-want-libunwind-to-live
+  $ # Check out llvm, and libunwind
+  $ ``svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm``
+  $ ``svn co http://llvm.org/svn/llvm-project/libunwind/trunk libunwind``
+  $ cd where-you-want-to-build
+  $ mkdir build && cd build
+  $ export CC=clang CXX=clang++
+  $ cmake -DLLVM_PATH=path/to/llvm \
+  path/to/libunwind
+  $ make
+
+
+.. _CMake Options:
+
+CMake Options
+=
+
+Here are some of the CMake variables that are used often, along with a
+brief explanation and LLVM-specific notes. For full documentation, check the
+CMake docs or execute ``cmake --help-variable VARIABLE_NAME``.
+
+**CMAKE_BUILD_TYPE**:STRING
+  Sets the build type for ``make`` based generators. Possible values are
+  Release, Debug, RelWithDebInfo and MinSizeRel. On systems like Visual Studio
+  the user sets the build type with the IDE settings.
+
+**CMAKE_INSTALL_PREFIX**:PATH
+  Path where LLVM will be installed if "make install" is invoked or the
+  "INSTALL" target is built.
+
+**CMAKE_CXX_COMPILER**:STRING
+  The C++ compiler to use when building and testing libunwind.
+
+
+.. _libunwind-specific options:
+
+libunwind specific options
+--
+
+.. option:: LIBUNWIND_BUILD_32_BITS:BOOL
+
+  **Default**: Same as LLVM_BUILD_32_BITS
+
+  Toggle whether libunwind should be built with -m32.

[PATCH] D31375: Add docs for libunwind

2017-03-28 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

In https://reviews.llvm.org/D31375#712152, @jroelofs wrote:

> In https://reviews.llvm.org/D31375#711839, @EricWF wrote:
>
> > In https://reviews.llvm.org/D31375#710897, @jroelofs wrote:
> >
> > > In https://reviews.llvm.org/D31375#710891, @compnerd wrote:
> > >
> > > > What happens when you try building it in tree?
> > >
> > >
> > > The docs-libunwind-html target is missing, and the docs don't get built.
> >
> >
> > Shouldn't that be what happens when libunwind is built 
> > "out-of-tree"/standalone, not the other way around?
>
>
> "is" != "ought". That's what /is/ happening, not necessarily what we want to 
> happen.


And FWIW, it looks like libcxx's docs behave the same way... So this might be a 
problem with the way the `runtimes` dir works.


https://reviews.llvm.org/D31375



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


[PATCH] D31375: Add docs for libunwind

2017-03-28 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

In https://reviews.llvm.org/D31375#711839, @EricWF wrote:

> In https://reviews.llvm.org/D31375#710897, @jroelofs wrote:
>
> > In https://reviews.llvm.org/D31375#710891, @compnerd wrote:
> >
> > > What happens when you try building it in tree?
> >
> >
> > The docs-libunwind-html target is missing, and the docs don't get built.
>
>
> Shouldn't that be what happens when libunwind is built 
> "out-of-tree"/standalone, not the other way around?


"is" != "ought". That's what /is/ happening, not necessarily what we want to 
happen.


https://reviews.llvm.org/D31375



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


[PATCH] D30643: [OpenCL] Extended diagnostics for atomic initialization

2017-03-28 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: test/SemaOpenCL/atomic-init.cl:6
+kernel void test_atomic_initialization() {
+  a1 = 1; // expected-error {{atomic variable can only be assigned to a 
compile time constant and to variables in global adress space}}
+  atomic_int a2 = 0; // expected-error {{atomic variable can only be assigned 
to a compile time constant and to variables in global adress space}}

Btw, you could keep "initialized" here by using 'select' in the diagnostic 
message. 



Comment at: test/SemaOpenCL/atomic-init.cl:10
+  local atomic_int a4 = 0; // expected-error {{'__local' variable cannot have 
an initializer}}
+  global atomic_int a5 = 0; // expected-error {{function scope variable cannot 
be declared in global address space}}
+}

Could we also add a check for 'static global' variable?


https://reviews.llvm.org/D30643



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


[PATCH] D31321: [OpenCL] Do not generate "kernel_arg_type_qual" metadata for non-pointer args

2017-03-28 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: test/CodeGenOpenCL/kernel-arg-info.cl:66
 // CHECK: ![[MD13]] = !{!"int*", !"int", !"int", !"float*"}
-// CHECK: ![[MD14]] = !{!"restrict", !"const", !"volatile", !"restrict const"}
 // ARGINFO: ![[MD15]] = !{!"X", !"Y", !"anotherArg", !"Z"}

Could we modify the test to check that const and volatile are added for the 
pointers though?


https://reviews.llvm.org/D31321



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


[PATCH] D31183: [OpenCL] Added parsing for OpenCL vector types.

2017-03-28 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D31183



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


[PATCH] D31397: [Bug 25404] Fix crash on typedef in OpenCL 2.0

2017-03-28 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:2157
   if (getDiagnostics().getSuppressSystemWarnings() &&
-  (Context.getSourceManager().isInSystemHeader(Old->getLocation()) ||
+  // Some standard types are defined implicitly in Clang (e.g. OpenCL).
+  (Old->isImplicit() || New->isImplicit() ||

bader wrote:
> Anastasia wrote:
> > Anastasia wrote:
> > > ahatanak wrote:
> > > > Is it necessary to check whether New is implicit? I was just wondering 
> > > > when or how an implicit definition would redefine a typedef.
> > > I had a thought on it too, and I am not sure actually. This can happen if 
> > > we implicitly define something from the standard headers. But I believe 
> > > the Sema initialization should always happen before parsing the standard 
> > > header or even loading them from the PCH. So I guess this shouldn't ever 
> > > happen really? Perhaps, I should just remove this?
> > Actually in case of implicit typedefs we don't seem to follow this program 
> > path at all. So I am removing this.
> So something like this will also work?
> ```
> typedef float float4 __attribute((ext_vector_type(4)));
> typedef float4 atomic_int;
> ```
> 
An error will be given for this because the definitions are conflicting 
(incompatible).



Comment at: test/SemaOpenCL/types.cl:6
+// Check redefinition of standard types
+typedef atomic_int atomic_flag;

bader wrote:
> Can we check that -Wtypedef-redefinition will emit a warning for this 
> expression?
> This typedef seems to be unnecessary since clang implicitly defines 
> atomic_flag for OpenCL. User is not supposed to re-define it, so warning 
> would be helpful here.
A warning is given only with -Wsystem-headers in this case. I don't modify this 
change here. But I can add a test if necessary. Verify wouldn't work here 
though because a note about the old location of the typedef will be given 
without source information. But I can add a FileCheck test.


https://reviews.llvm.org/D31397



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


[PATCH] D31334: [clang-format] Add options for indenting preprocessor directives

2017-03-28 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

Thanks Daniel.

I'll give it a try using the proposed approach and update you soon(ish).


https://reviews.llvm.org/D31334



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


Re: [PATCH] D30777: Added `applyAtomicChanges` function.

2017-03-28 Thread Eric Liu via cfe-commits
Thank you Nakamura!

On Tue, Mar 28, 2017, 16:35 NAKAMURA Takumi via Phabricator <
revi...@reviews.llvm.org> wrote:

> chapuni added inline comments.
>
>
> 
> Comment at: cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h:19
>  #include "clang/Basic/SourceManager.h"
> +#include "clang/Format/Format.h"
>  #include "clang/Tooling/Core/Replacement.h"
> 
> It requires clangFormat in LINK_LIBS. Fixed in r298921.
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D30777
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29659: [OpenMP] Add flag for disabling the default generation of relocatable OpenMP target code for NVIDIA GPUs.

2017-03-28 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 93240.
gtbercea added a comment.
Herald added a subscriber: rengolin.

Update patch to reflect latest source code changes.


Repository:
  rL LLVM

https://reviews.llvm.org/D29659

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload.c


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -610,6 +610,23 @@
 
 /// ###
 
+/// PTXAS is passed -c flag by default when offloading to an NVIDIA device 
using OpenMP - disable it.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-fnoopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-C %s
+
+// CHK-PTXAS-C-NOT: ptxas{{.*}}" "-c"
+
+/// ###
+
+/// PTXAS is passed -c flag by default when offloading to an NVIDIA device 
using OpenMP
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-C-RELO %s
+
+// CHK-PTXAS-C-RELO: ptxas{{.*}}" "-c"
+
+/// ###
+
 /// Check that CLANG forwards the -v flag to PTXAS.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-save-temps -no-canonical-prefixes -v %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-VERBOSE %s
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -292,7 +292,9 @@
 CmdArgs.push_back(Args.MakeArgString(A));
 
   // In OpenMP we need to generate relocatable code.
-  if (JA.isOffloading(Action::OFK_OpenMP))
+  if (JA.isOffloading(Action::OFK_OpenMP) &&
+  !Args.hasFlag(options::OPT_fnoopenmp_relocatable_target,
+options::OPT_fopenmp_relocatable_target, false))
 CmdArgs.push_back("-c");
 
   const char *Exec;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1260,6 +1260,10 @@
   HelpText<"Specify comma-separated list of triples OpenMP offloading targets 
to be supported">;
 def fopenmp_dump_offload_linker_script : Flag<["-"], 
"fopenmp-dump-offload-linker-script">, Group, 
   Flags<[NoArgumentUnused]>;
+def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">, 
Group, Flags<[CC1Option, NoArgumentUnused]>,
+  HelpText<"OpenMP target code is compiled as relocatable using the -c flag. 
For OpenMP targets the code is relocatable by default.">;
+def fnoopenmp_relocatable_target : Flag<["-"], 
"fnoopenmp-relocatable-target">, Group, Flags<[CC1Option, 
NoArgumentUnused]>,
+  HelpText<"Do not compile OpenMP target code as relocatable.">;
 def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, 
Group;
 def foptimize_sibling_calls : Flag<["-"], "foptimize-sibling-calls">, 
Group;
 def force__cpusubtype__ALL : Flag<["-"], "force_cpusubtype_ALL">;


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -610,6 +610,23 @@
 
 /// ###
 
+/// PTXAS is passed -c flag by default when offloading to an NVIDIA device using OpenMP - disable it.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -fnoopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-C %s
+
+// CHK-PTXAS-C-NOT: ptxas{{.*}}" "-c"
+
+/// ###
+
+/// PTXAS is passed -c flag by default when offloading to an NVIDIA device using OpenMP
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-C-RELO %s
+
+// CHK-PTXAS-C-RELO: ptxas{{.*}}" "-c"
+
+/// ###
+
 /// Check that CLANG forwards the -v flag to PTXAS.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes -v %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-VERBOSE %s
Index: lib/Driver/ToolChains/Cuda.cpp

r298921 - clangToolingRefactor: Add libdeps upon clangFormat in r298913.

2017-03-28 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Tue Mar 28 09:18:10 2017
New Revision: 298921

URL: http://llvm.org/viewvc/llvm-project?rev=298921=rev
Log:
clangToolingRefactor: Add libdeps upon clangFormat in r298913.

Modified:
cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt

Modified: cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt?rev=298921=298920=298921=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt (original)
+++ cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt Tue Mar 28 09:18:10 2017
@@ -8,5 +8,6 @@ add_clang_library(clangToolingRefactor
 
   LINK_LIBS
   clangBasic
+  clangFormat
   clangToolingCore
   )


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


[PATCH] D30777: Added `applyAtomicChanges` function.

2017-03-28 Thread NAKAMURA Takumi via Phabricator via cfe-commits
chapuni added inline comments.



Comment at: cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h:19
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Tooling/Core/Replacement.h"

It requires clangFormat in LINK_LIBS. Fixed in r298921.


Repository:
  rL LLVM

https://reviews.llvm.org/D30777



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


r298919 - Try to unbreak buildbots after r298913.

2017-03-28 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Mar 28 08:56:19 2017
New Revision: 298919

URL: http://llvm.org/viewvc/llvm-project?rev=298919=rev
Log:
Try to unbreak buildbots after r298913.

Modified:
cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Modified: cfe/trunk/unittests/Tooling/RefactoringTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RefactoringTest.cpp?rev=298919=298918=298919=diff
==
--- cfe/trunk/unittests/Tooling/RefactoringTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/RefactoringTest.cpp Tue Mar 28 08:56:19 2017
@@ -1513,21 +1513,17 @@ TEST_F(ApplyAtomicChangesTest, InsertsNe
 }
 
 TEST_F(ApplyAtomicChangesTest, RemoveAndSortIncludes) {
-  setInput(R"(
-#include "a"
-#include "b"
-#include "c"
-
-int a;
-  )");
+  setInput("#include \"a\"\n"
+   "#include \"b\"\n"
+   "#include \"c\"\n"
+   "\n"
+   "int a;");
   Changes.emplace_back(FilePath, "key1");
   Changes.back().removeHeader("b");
-  EXPECT_EQ(R"(
-#include "a"
-#include "c"
-
-int a;
-  )",
+  EXPECT_EQ("#include \"a\"\n"
+"#include \"c\"\n"
+"\n"
+"int a;",
 rewrite());
 }
 TEST_F(ApplyAtomicChangesTest, InsertsSystemIncludes) {
@@ -1553,23 +1549,19 @@ TEST_F(ApplyAtomicChangesTest, InsertsSy
 }
 
 TEST_F(ApplyAtomicChangesTest, RemoveSystemIncludes) {
-  setInput(R"(
-#include 
-#include 
-
-#include "c"
-
-int a;
-  )");
+  setInput("#include \n"
+   "#include \n"
+   "\n"
+   "#include \"c\""
+   "\n"
+   "int a;");
   Changes.emplace_back(FilePath, "key1");
   Changes.back().removeHeader("");
-  EXPECT_EQ(R"(
-#include 
-
-#include "c"
-
-int a;
-  )",
+  EXPECT_EQ("#include \n"
+"\n"
+"#include \"c\""
+"\n"
+"int a;",
 rewrite());
 }
 


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


[PATCH] D31370: [clang-tidy] Prototype to check for exception specification

2017-03-28 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/clang-tidy/checks/modernize-noexcept-correctness.rst:41
+
+- AnnotateThrow -> boolean if a function that can throw for sure will be 
annotated with `noexcept(false)`

JonasToth wrote:
> Eugene.Zelenko wrote:
> > Please highlight language constructs with ``.
> should i highlight `function` here and above?
> as well `exception`. I think they are not directly language constructs but 
> more concepts.
No, only noexcept(false).


Repository:
  rL LLVM

https://reviews.llvm.org/D31370



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


[PATCH] D30777: Added `applyAtomicChanges` function.

2017-03-28 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL298913: Added `applyAtomicChanges` function. (authored by 
ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D30777?vs=93231=93232#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30777

Files:
  cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
  cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
  cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Index: cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
===
--- cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
+++ cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
@@ -16,6 +16,7 @@
 #define LLVM_CLANG_TOOLING_REFACTOR_ATOMICCHANGE_H
 
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
@@ -123,6 +124,39 @@
   tooling::Replacements Replaces;
 };
 
+// Defines specs for applying changes.
+struct ApplyChangesSpec {
+  // If true, cleans up redundant/erroneous code around changed code with
+  // clang-format's cleanup functionality, e.g. redundant commas around deleted
+  // parameter or empty namespaces introduced by deletions.
+  bool Cleanup = true;
+
+  format::FormatStyle Style = format::getNoStyle();
+
+  // Options for selectively formatting changes with clang-format:
+  // kAll: Format all changed lines.
+  // kNone: Don't format anything.
+  // kViolations: Format lines exceeding the `ColumnLimit` in `Style`.
+  enum FormatOption { kAll, kNone, kViolations };
+
+  FormatOption Format = kNone;
+};
+
+/// \brief Applies all AtomicChanges in \p Changes to the \p Code.
+///
+/// This completely ignores the file path in each change and replaces them with
+/// \p FilePath, i.e. callers are responsible for ensuring all changes are for
+/// the same file.
+///
+/// \returns The changed code if all changes are applied successfully;
+/// otherwise, an llvm::Error carrying llvm::StringError is returned (the Error
+/// message can be converted to string with `llvm::toString()` and the
+/// error_code should be ignored).
+llvm::Expected
+applyAtomicChanges(llvm::StringRef FilePath, llvm::StringRef Code,
+   llvm::ArrayRef Changes,
+   const ApplyChangesSpec );
+
 } // end namespace tooling
 } // end namespace clang
 
Index: cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
===
--- cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
+++ cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
@@ -84,6 +84,116 @@
 
 namespace clang {
 namespace tooling {
+namespace {
+
+// Returns true if there is any line that violates \p ColumnLimit in range
+// [Start, End].
+bool violatesColumnLimit(llvm::StringRef Code, unsigned ColumnLimit,
+ unsigned Start, unsigned End) {
+  auto StartPos = Code.rfind('\n', Start);
+  StartPos = (StartPos == llvm::StringRef::npos) ? 0 : StartPos + 1;
+
+  auto EndPos = Code.find("\n", End);
+  if (EndPos == llvm::StringRef::npos)
+EndPos = Code.size();
+
+  llvm::SmallVector Lines;
+  Code.substr(StartPos, EndPos - StartPos).split(Lines, '\n');
+  for (llvm::StringRef Line : Lines)
+if (Line.size() > ColumnLimit)
+  return true;
+  return false;
+}
+
+std::vector
+getRangesForFormating(llvm::StringRef Code, unsigned ColumnLimit,
+  ApplyChangesSpec::FormatOption Format,
+  const clang::tooling::Replacements ) {
+  // kNone suppresses formatting entirely.
+  if (Format == ApplyChangesSpec::kNone)
+return {};
+  std::vector Ranges;
+  // This works assuming that replacements are ordered by offset.
+  // FIXME: use `getAffectedRanges()` to calculate when it does not include '\n'
+  // at the end of an insertion in affected ranges.
+  int Offset = 0;
+  for (const clang::tooling::Replacement  : Replaces) {
+int Start = R.getOffset() + Offset;
+int End = Start + R.getReplacementText().size();
+if (!R.getReplacementText().empty() &&
+R.getReplacementText().back() == '\n' && R.getLength() == 0 &&
+R.getOffset() > 0 && R.getOffset() <= Code.size() &&
+Code[R.getOffset() - 1] == '\n')
+  // If we are inserting at the start of a line and the replacement ends in
+  // a newline, we don't need to format the subsequent line.
+  --End;
+Offset += R.getReplacementText().size() - R.getLength();
+
+if (Format == ApplyChangesSpec::kAll ||
+violatesColumnLimit(Code, ColumnLimit, Start, End))
+  Ranges.emplace_back(Start, End - Start);
+  }
+  return Ranges;
+}
+
+inline llvm::Error make_string_error(const llvm::Twine ) {
+  return llvm::make_error(Message,
+ llvm::inconvertibleErrorCode());
+}
+
+// Creates replacements for 

r298913 - Added `applyAtomicChanges` function.

2017-03-28 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Mar 28 08:05:32 2017
New Revision: 298913

URL: http://llvm.org/viewvc/llvm-project?rev=298913=rev
Log:
Added `applyAtomicChanges` function.

Summary: ... which applies a set of `AtomicChange`s on code.

Reviewers: klimek, djasper

Reviewed By: djasper

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Modified: cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h?rev=298913=298912=298913=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h (original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h Tue Mar 28 
08:05:32 2017
@@ -16,6 +16,7 @@
 #define LLVM_CLANG_TOOLING_REFACTOR_ATOMICCHANGE_H
 
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
@@ -123,6 +124,39 @@ private:
   tooling::Replacements Replaces;
 };
 
+// Defines specs for applying changes.
+struct ApplyChangesSpec {
+  // If true, cleans up redundant/erroneous code around changed code with
+  // clang-format's cleanup functionality, e.g. redundant commas around deleted
+  // parameter or empty namespaces introduced by deletions.
+  bool Cleanup = true;
+
+  format::FormatStyle Style = format::getNoStyle();
+
+  // Options for selectively formatting changes with clang-format:
+  // kAll: Format all changed lines.
+  // kNone: Don't format anything.
+  // kViolations: Format lines exceeding the `ColumnLimit` in `Style`.
+  enum FormatOption { kAll, kNone, kViolations };
+
+  FormatOption Format = kNone;
+};
+
+/// \brief Applies all AtomicChanges in \p Changes to the \p Code.
+///
+/// This completely ignores the file path in each change and replaces them with
+/// \p FilePath, i.e. callers are responsible for ensuring all changes are for
+/// the same file.
+///
+/// \returns The changed code if all changes are applied successfully;
+/// otherwise, an llvm::Error carrying llvm::StringError is returned (the Error
+/// message can be converted to string with `llvm::toString()` and the
+/// error_code should be ignored).
+llvm::Expected
+applyAtomicChanges(llvm::StringRef FilePath, llvm::StringRef Code,
+   llvm::ArrayRef Changes,
+   const ApplyChangesSpec );
+
 } // end namespace tooling
 } // end namespace clang
 

Modified: cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp?rev=298913=298912=298913=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp Tue Mar 28 08:05:32 2017
@@ -84,6 +84,116 @@ template <> struct MappingTraits Lines;
+  Code.substr(StartPos, EndPos - StartPos).split(Lines, '\n');
+  for (llvm::StringRef Line : Lines)
+if (Line.size() > ColumnLimit)
+  return true;
+  return false;
+}
+
+std::vector
+getRangesForFormating(llvm::StringRef Code, unsigned ColumnLimit,
+  ApplyChangesSpec::FormatOption Format,
+  const clang::tooling::Replacements ) {
+  // kNone suppresses formatting entirely.
+  if (Format == ApplyChangesSpec::kNone)
+return {};
+  std::vector Ranges;
+  // This works assuming that replacements are ordered by offset.
+  // FIXME: use `getAffectedRanges()` to calculate when it does not include 
'\n'
+  // at the end of an insertion in affected ranges.
+  int Offset = 0;
+  for (const clang::tooling::Replacement  : Replaces) {
+int Start = R.getOffset() + Offset;
+int End = Start + R.getReplacementText().size();
+if (!R.getReplacementText().empty() &&
+R.getReplacementText().back() == '\n' && R.getLength() == 0 &&
+R.getOffset() > 0 && R.getOffset() <= Code.size() &&
+Code[R.getOffset() - 1] == '\n')
+  // If we are inserting at the start of a line and the replacement ends in
+  // a newline, we don't need to format the subsequent line.
+  --End;
+Offset += R.getReplacementText().size() - R.getLength();
+
+if (Format == ApplyChangesSpec::kAll ||
+violatesColumnLimit(Code, ColumnLimit, Start, End))
+  Ranges.emplace_back(Start, End - Start);
+  }
+  return Ranges;
+}
+
+inline llvm::Error make_string_error(const llvm::Twine ) {
+  return llvm::make_error(Message,
+ llvm::inconvertibleErrorCode());
+}
+
+// Creates replacements for inserting/deleting #include headers.
+llvm::Expected

[PATCH] D30777: Added `applyAtomicChanges` function.

2017-03-28 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 93231.
ioeric added a comment.

- addressed comment.


https://reviews.llvm.org/D30777

Files:
  include/clang/Tooling/Refactoring/AtomicChange.h
  lib/Tooling/Refactoring/AtomicChange.cpp
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -1290,5 +1290,435 @@
   Replacement(Context.Sources, SourceLocation(), 0, "b")));
 }
 
+class ApplyAtomicChangesTest : public ::testing::Test {
+protected:
+  ApplyAtomicChangesTest() : FilePath("file.cc") {
+Spec.Cleanup = true;
+Spec.Format = ApplyChangesSpec::kAll;
+Spec.Style = format::getLLVMStyle();
+  }
+
+  ~ApplyAtomicChangesTest() override {}
+
+  void setInput(llvm::StringRef Input) {
+Code = Input;
+FID = Context.createInMemoryFile(FilePath, Code);
+  }
+
+  SourceLocation getLoc(unsigned Offset) const {
+return Context.Sources.getLocForStartOfFile(FID).getLocWithOffset(Offset);
+  }
+
+  AtomicChange replacementToAtomicChange(llvm::StringRef Key, unsigned Offset,
+ unsigned Length,
+ llvm::StringRef Text) {
+AtomicChange Change(FilePath, Key);
+llvm::Error Err =
+Change.replace(Context.Sources, getLoc(Offset), Length, Text);
+EXPECT_FALSE(Err);
+return Change;
+  }
+
+  std::string rewrite(bool FailureExpected = false) {
+llvm::Expected ChangedCode =
+applyAtomicChanges(FilePath, Code, Changes, Spec);
+EXPECT_EQ(FailureExpected, !ChangedCode);
+if (!ChangedCode) {
+  llvm::errs() << "Failed to apply changes: "
+   << llvm::toString(ChangedCode.takeError()) << "\n";
+  return "";
+}
+return *ChangedCode;
+  }
+
+  RewriterTestContext Context;
+  FileID FID;
+  ApplyChangesSpec Spec;
+  std::string Code;
+  std::string FilePath;
+  llvm::SmallVector Changes;
+};
+
+TEST_F(ApplyAtomicChangesTest, BasicRefactoring) {
+  setInput("int a;");
+  AtomicChange Change(FilePath, "key1");
+  Changes.push_back(replacementToAtomicChange("key1", 4, 1, "b"));
+  EXPECT_EQ("int b;", rewrite());
+}
+
+TEST_F(ApplyAtomicChangesTest, SeveralRefactorings) {
+  setInput("int a;\n"
+   "int b;");
+  Changes.push_back(replacementToAtomicChange("key1", 0, 3, "float"));
+  Changes.push_back(replacementToAtomicChange("key2", 4, 1, "f"));
+  Changes.push_back(replacementToAtomicChange("key3", 11, 1, "g"));
+  Changes.push_back(replacementToAtomicChange("key4", 7, 3, "float"));
+  EXPECT_EQ("float f;\n"
+"float g;",
+rewrite());
+}
+
+TEST_F(ApplyAtomicChangesTest, IgnorePathsInRefactorings) {
+  setInput("int a;\n"
+   "int b;");
+  Changes.push_back(replacementToAtomicChange("key1", 4, 1, "aa"));
+
+  FileID ID = Context.createInMemoryFile("AnotherFile", "12345678912345");
+  Changes.emplace_back("AnotherFile", "key2");
+  auto Err = Changes.back().replace(
+  Context.Sources,
+  Context.Sources.getLocForStartOfFile(ID).getLocWithOffset(11), 1, "bb");
+  ASSERT_TRUE(!Err);
+  EXPECT_EQ("int aa;\n"
+"int bb;",
+rewrite());
+}
+
+TEST_F(ApplyAtomicChangesTest, AppliesDuplicateInsertions) {
+  setInput("int a;");
+  Changes.push_back(replacementToAtomicChange("key1", 5, 0, "b"));
+  Changes.push_back(replacementToAtomicChange("key2", 5, 0, "b"));
+  EXPECT_EQ("int abb;", rewrite());
+}
+
+TEST_F(ApplyAtomicChangesTest, BailsOnOverlappingRefactorings) {
+  setInput("int a;");
+  Changes.push_back(replacementToAtomicChange("key1", 0, 5, "float f"));
+  Changes.push_back(replacementToAtomicChange("key2", 4, 1, "b"));
+  EXPECT_EQ("", rewrite(/*FailureExpected=*/true));
+}
+
+TEST_F(ApplyAtomicChangesTest, BasicReformatting) {
+  setInput("int  a;");
+  Changes.push_back(replacementToAtomicChange("key1", 5, 1, "b"));
+  EXPECT_EQ("int b;", rewrite());
+}
+
+TEST_F(ApplyAtomicChangesTest, OnlyFormatWhenViolateColumnLimits) {
+  Spec.Format = ApplyChangesSpec::kViolations;
+  Spec.Style.ColumnLimit = 8;
+  setInput("int  a;\n"
+   "inta;\n"
+   "int  ;\n");
+  Changes.push_back(replacementToAtomicChange("key1", 5, 1, "x"));
+  Changes.push_back(replacementToAtomicChange("key2", 15, 1, "x"));
+  Changes.push_back(replacementToAtomicChange("key3", 23, 8, "xx"));
+  EXPECT_EQ("int  x;\n"
+"int x;\n"
+"int  xx;\n",
+rewrite());
+}
+
+TEST_F(ApplyAtomicChangesTest, LastLineViolateColumnLimits) {
+  Spec.Format = ApplyChangesSpec::kViolations;
+  Spec.Style.ColumnLimit = 8;
+  setInput("int  a;\n"
+   "inta;");
+  Changes.push_back(replacementToAtomicChange("key1", 0, 1, "i"));
+  Changes.push_back(replacementToAtomicChange("key2", 15, 2, "y;"));
+  EXPECT_EQ("int  a;\n"
+"int y;",
+rewrite());
+}
+

r298912 - [ASTMatchers] add typeAliasTemplateDecl matcher.

2017-03-28 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Mar 28 07:56:47 2017
New Revision: 298912

URL: http://llvm.org/viewvc/llvm-project?rev=298912=rev
Log:
[ASTMatchers] add typeAliasTemplateDecl matcher.

Reviewers: hokein, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: aaron.ballman, cfe-commits, klimek

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

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

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=298912=298911=298912=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Tue Mar 28 07:56:47 2017
@@ -469,6 +469,15 @@ typeAliasDecl()
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DecltypeAliasTemplateDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1TypeAliasTemplateDecl.html;>TypeAliasTemplateDecl...
+Matches type 
alias template declarations.
+
+typeAliasTemplateDecl() matches
+  template typename T
+  using Y = XT;
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DecltypedefDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1TypedefDecl.html;>TypedefDecl...
 Matches typedef 
declarations.
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=298912=298911=298912=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Tue Mar 28 07:56:47 2017
@@ -180,6 +180,16 @@ const internal::VariadicDynCastAllOfMatc
 ///   matches "using Y = int", but not "typedef int X"
 const internal::VariadicDynCastAllOfMatcher typeAliasDecl;
 
+/// \brief Matches type alias template declarations.
+///
+/// typeAliasTemplateDecl() matches
+/// \code
+///   template 
+///   using Y = X;
+/// \endcode
+const internal::VariadicDynCastAllOfMatcher
+typeAliasTemplateDecl;
+
 /// \brief Matches AST nodes that were expanded within the main-file.
 ///
 /// Example matches X but not Y

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=298912=298911=298912=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Tue Mar 28 07:56:47 2017
@@ -417,6 +417,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(typedefNameDecl);
   REGISTER_MATCHER(typedefType);
   REGISTER_MATCHER(typeAliasDecl);
+  REGISTER_MATCHER(typeAliasTemplateDecl);
   REGISTER_MATCHER(typeLoc);
   REGISTER_MATCHER(unaryExprOrTypeTraitExpr);
   REGISTER_MATCHER(unaryOperator);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp?rev=298912=298911=298912=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp Tue Mar 28 07:56:47 
2017
@@ -1494,6 +1494,22 @@ TEST(TypedefNameDeclMatcher, Match) {
   typedefNameDecl(hasName("typedefNameDeclTest2";
 }
 
+TEST(TypeAliasTemplateDeclMatcher, Match) {
+  std::string Code = R"(
+template 
+class X { T t; };
+
+template 
+using typeAliasTemplateDecl = X;
+
+using typeAliasDecl = X;
+  )";
+  EXPECT_TRUE(
+  matches(Code, typeAliasTemplateDecl(hasName("typeAliasTemplateDecl";
+  EXPECT_TRUE(
+  notMatches(Code, typeAliasTemplateDecl(hasName("typeAliasDecl";
+}
+
 TEST(ObjCMessageExprMatcher, SimpleExprs) {
   // don't find ObjCMessageExpr where none are present
   EXPECT_TRUE(notMatchesObjC("", objcMessageExpr(anything(;


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


[PATCH] D28671: [ASTMatchers] add typeAliasTemplateDecl matcher.

2017-03-28 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL298912: [ASTMatchers] add typeAliasTemplateDecl matcher. 
(authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D28671?vs=93228=93230#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28671

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


Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -469,6 +469,15 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DecltypeAliasTemplateDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1TypeAliasTemplateDecl.html;>TypeAliasTemplateDecl...
+Matches type 
alias template declarations.
+
+typeAliasTemplateDecl() matches
+  template typename T
+  using Y = XT;
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DecltypedefDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1TypedefDecl.html;>TypedefDecl...
 Matches typedef 
declarations.
 
Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -180,6 +180,16 @@
 ///   matches "using Y = int", but not "typedef int X"
 const internal::VariadicDynCastAllOfMatcher typeAliasDecl;
 
+/// \brief Matches type alias template declarations.
+///
+/// typeAliasTemplateDecl() matches
+/// \code
+///   template 
+///   using Y = X;
+/// \endcode
+const internal::VariadicDynCastAllOfMatcher
+typeAliasTemplateDecl;
+
 /// \brief Matches AST nodes that were expanded within the main-file.
 ///
 /// Example matches X but not Y
Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -417,6 +417,7 @@
   REGISTER_MATCHER(typedefNameDecl);
   REGISTER_MATCHER(typedefType);
   REGISTER_MATCHER(typeAliasDecl);
+  REGISTER_MATCHER(typeAliasTemplateDecl);
   REGISTER_MATCHER(typeLoc);
   REGISTER_MATCHER(unaryExprOrTypeTraitExpr);
   REGISTER_MATCHER(unaryOperator);
Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1494,6 +1494,22 @@
   typedefNameDecl(hasName("typedefNameDeclTest2";
 }
 
+TEST(TypeAliasTemplateDeclMatcher, Match) {
+  std::string Code = R"(
+template 
+class X { T t; };
+
+template 
+using typeAliasTemplateDecl = X;
+
+using typeAliasDecl = X;
+  )";
+  EXPECT_TRUE(
+  matches(Code, typeAliasTemplateDecl(hasName("typeAliasTemplateDecl";
+  EXPECT_TRUE(
+  notMatches(Code, typeAliasTemplateDecl(hasName("typeAliasDecl";
+}
+
 TEST(ObjCMessageExprMatcher, SimpleExprs) {
   // don't find ObjCMessageExpr where none are present
   EXPECT_TRUE(notMatchesObjC("", objcMessageExpr(anything(;


Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -469,6 +469,15 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DecltypeAliasTemplateDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1TypeAliasTemplateDecl.html;>TypeAliasTemplateDecl...
+Matches type alias template declarations.
+
+typeAliasTemplateDecl() matches
+  template typename T
+  using Y = XT;
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DecltypedefDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1TypedefDecl.html;>TypedefDecl...
 Matches typedef declarations.
 
Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -180,6 +180,16 @@
 ///   matches "using Y = int", but not "typedef int X"
 const internal::VariadicDynCastAllOfMatcher typeAliasDecl;
 
+/// \brief Matches type alias template declarations.
+///
+/// typeAliasTemplateDecl() matches
+/// \code
+///   template 
+///   using Y = X;
+/// \endcode
+const internal::VariadicDynCastAllOfMatcher
+typeAliasTemplateDecl;
+
 /// \brief Matches AST nodes that were expanded within the main-file.
 ///
 /// Example matches X but not Y
Index: 

[PATCH] D28671: [ASTMatchers] add typeAliasTemplateDecl matcher.

2017-03-28 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: include/clang/ASTMatchers/ASTMatchers.h:191
+const internal::VariadicDynCastAllOfMatcher
+typeAliasTemplateDecl;
+

aaron.ballman wrote:
> Be sure to add this to Registry.cpp so that it can be used as a dynamic 
> matcher in clang-query.
Done. Thanks for the reminder!


https://reviews.llvm.org/D28671



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


[PATCH] D28671: [ASTMatchers] add typeAliasTemplateDecl matcher.

2017-03-28 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 93228.
ioeric marked an inline comment as done.
ioeric added a comment.

- Register the matcher to Dynamic.


https://reviews.llvm.org/D28671

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersNodeTest.cpp


Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1494,6 +1494,22 @@
   typedefNameDecl(hasName("typedefNameDeclTest2";
 }
 
+TEST(TypeAliasTemplateDeclMatcher, Match) {
+  std::string Code = R"(
+template 
+class X { T t; };
+
+template 
+using typeAliasTemplateDecl = X;
+
+using typeAliasDecl = X;
+  )";
+  EXPECT_TRUE(
+  matches(Code, typeAliasTemplateDecl(hasName("typeAliasTemplateDecl";
+  EXPECT_TRUE(
+  notMatches(Code, typeAliasTemplateDecl(hasName("typeAliasDecl";
+}
+
 TEST(ObjCMessageExprMatcher, SimpleExprs) {
   // don't find ObjCMessageExpr where none are present
   EXPECT_TRUE(notMatchesObjC("", objcMessageExpr(anything(;
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -417,6 +417,7 @@
   REGISTER_MATCHER(typedefNameDecl);
   REGISTER_MATCHER(typedefType);
   REGISTER_MATCHER(typeAliasDecl);
+  REGISTER_MATCHER(typeAliasTemplateDecl);
   REGISTER_MATCHER(typeLoc);
   REGISTER_MATCHER(unaryExprOrTypeTraitExpr);
   REGISTER_MATCHER(unaryOperator);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -180,6 +180,16 @@
 ///   matches "using Y = int", but not "typedef int X"
 const internal::VariadicDynCastAllOfMatcher typeAliasDecl;
 
+/// \brief Matches type alias template declarations.
+///
+/// typeAliasTemplateDecl() matches
+/// \code
+///   template 
+///   using Y = X;
+/// \endcode
+const internal::VariadicDynCastAllOfMatcher
+typeAliasTemplateDecl;
+
 /// \brief Matches AST nodes that were expanded within the main-file.
 ///
 /// Example matches X but not Y
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -469,6 +469,15 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DecltypeAliasTemplateDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1TypeAliasTemplateDecl.html;>TypeAliasTemplateDecl...
+Matches type 
alias template declarations.
+
+typeAliasTemplateDecl() matches
+  template typename T
+  using Y = XT;
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DecltypedefDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1TypedefDecl.html;>TypedefDecl...
 Matches typedef 
declarations.
 


Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1494,6 +1494,22 @@
   typedefNameDecl(hasName("typedefNameDeclTest2";
 }
 
+TEST(TypeAliasTemplateDeclMatcher, Match) {
+  std::string Code = R"(
+template 
+class X { T t; };
+
+template 
+using typeAliasTemplateDecl = X;
+
+using typeAliasDecl = X;
+  )";
+  EXPECT_TRUE(
+  matches(Code, typeAliasTemplateDecl(hasName("typeAliasTemplateDecl";
+  EXPECT_TRUE(
+  notMatches(Code, typeAliasTemplateDecl(hasName("typeAliasDecl";
+}
+
 TEST(ObjCMessageExprMatcher, SimpleExprs) {
   // don't find ObjCMessageExpr where none are present
   EXPECT_TRUE(notMatchesObjC("", objcMessageExpr(anything(;
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -417,6 +417,7 @@
   REGISTER_MATCHER(typedefNameDecl);
   REGISTER_MATCHER(typedefType);
   REGISTER_MATCHER(typeAliasDecl);
+  REGISTER_MATCHER(typeAliasTemplateDecl);
   REGISTER_MATCHER(typeLoc);
   REGISTER_MATCHER(unaryExprOrTypeTraitExpr);
   REGISTER_MATCHER(unaryOperator);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -180,6 +180,16 @@
 ///   matches "using Y = int", but not "typedef int X"
 const internal::VariadicDynCastAllOfMatcher typeAliasDecl;
 
+/// \brief Matches type alias template declarations.
+///
+/// typeAliasTemplateDecl() 

[PATCH] D28671: [ASTMatchers] add typeAliasTemplateDecl matcher.

2017-03-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added inline comments.



Comment at: include/clang/ASTMatchers/ASTMatchers.h:191
+const internal::VariadicDynCastAllOfMatcher
+typeAliasTemplateDecl;
+

Be sure to add this to Registry.cpp so that it can be used as a dynamic matcher 
in clang-query.


https://reviews.llvm.org/D28671



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


[PATCH] D31397: [Bug 25404] Fix crash on typedef in OpenCL 2.0

2017-03-28 Thread Alexey Bader via Phabricator via cfe-commits
bader added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:2157
   if (getDiagnostics().getSuppressSystemWarnings() &&
-  (Context.getSourceManager().isInSystemHeader(Old->getLocation()) ||
+  // Some standard types are defined implicitly in Clang (e.g. OpenCL).
+  (Old->isImplicit() || New->isImplicit() ||

Anastasia wrote:
> Anastasia wrote:
> > ahatanak wrote:
> > > Is it necessary to check whether New is implicit? I was just wondering 
> > > when or how an implicit definition would redefine a typedef.
> > I had a thought on it too, and I am not sure actually. This can happen if 
> > we implicitly define something from the standard headers. But I believe the 
> > Sema initialization should always happen before parsing the standard header 
> > or even loading them from the PCH. So I guess this shouldn't ever happen 
> > really? Perhaps, I should just remove this?
> Actually in case of implicit typedefs we don't seem to follow this program 
> path at all. So I am removing this.
So something like this will also work?
```
typedef float float4 __attribute((ext_vector_type(4)));
typedef float4 atomic_int;
```




Comment at: test/SemaOpenCL/types.cl:6
+// Check redefinition of standard types
+typedef atomic_int atomic_flag;

Can we check that -Wtypedef-redefinition will emit a warning for this 
expression?
This typedef seems to be unnecessary since clang implicitly defines atomic_flag 
for OpenCL. User is not supposed to re-define it, so warning would be helpful 
here.


https://reviews.llvm.org/D31397



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


[PATCH] D28671: [ASTMatchers] add typeAliasTemplateDecl matcher.

2017-03-28 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

PTAL


https://reviews.llvm.org/D28671



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


[PATCH] D28671: [ASTMatchers] add typeAliasTemplateDecl matcher.

2017-03-28 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 93227.
ioeric added a comment.

- generate html for the new matcher.


https://reviews.llvm.org/D28671

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  unittests/ASTMatchers/ASTMatchersNodeTest.cpp


Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1494,6 +1494,22 @@
   typedefNameDecl(hasName("typedefNameDeclTest2";
 }
 
+TEST(TypeAliasTemplateDeclMatcher, Match) {
+  std::string Code = R"(
+template 
+class X { T t; };
+
+template 
+using typeAliasTemplateDecl = X;
+
+using typeAliasDecl = X;
+  )";
+  EXPECT_TRUE(
+  matches(Code, typeAliasTemplateDecl(hasName("typeAliasTemplateDecl";
+  EXPECT_TRUE(
+  notMatches(Code, typeAliasTemplateDecl(hasName("typeAliasDecl";
+}
+
 TEST(ObjCMessageExprMatcher, SimpleExprs) {
   // don't find ObjCMessageExpr where none are present
   EXPECT_TRUE(notMatchesObjC("", objcMessageExpr(anything(;
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -180,6 +180,16 @@
 ///   matches "using Y = int", but not "typedef int X"
 const internal::VariadicDynCastAllOfMatcher typeAliasDecl;
 
+/// \brief Matches type alias template declarations.
+///
+/// typeAliasTemplateDecl() matches
+/// \code
+///   template 
+///   using Y = X;
+/// \endcode
+const internal::VariadicDynCastAllOfMatcher
+typeAliasTemplateDecl;
+
 /// \brief Matches AST nodes that were expanded within the main-file.
 ///
 /// Example matches X but not Y
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -469,6 +469,15 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DecltypeAliasTemplateDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1TypeAliasTemplateDecl.html;>TypeAliasTemplateDecl...
+Matches type 
alias template declarations.
+
+typeAliasTemplateDecl() matches
+  template typename T
+  using Y = XT;
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DecltypedefDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1TypedefDecl.html;>TypedefDecl...
 Matches typedef 
declarations.
 


Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1494,6 +1494,22 @@
   typedefNameDecl(hasName("typedefNameDeclTest2";
 }
 
+TEST(TypeAliasTemplateDeclMatcher, Match) {
+  std::string Code = R"(
+template 
+class X { T t; };
+
+template 
+using typeAliasTemplateDecl = X;
+
+using typeAliasDecl = X;
+  )";
+  EXPECT_TRUE(
+  matches(Code, typeAliasTemplateDecl(hasName("typeAliasTemplateDecl";
+  EXPECT_TRUE(
+  notMatches(Code, typeAliasTemplateDecl(hasName("typeAliasDecl";
+}
+
 TEST(ObjCMessageExprMatcher, SimpleExprs) {
   // don't find ObjCMessageExpr where none are present
   EXPECT_TRUE(notMatchesObjC("", objcMessageExpr(anything(;
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -180,6 +180,16 @@
 ///   matches "using Y = int", but not "typedef int X"
 const internal::VariadicDynCastAllOfMatcher typeAliasDecl;
 
+/// \brief Matches type alias template declarations.
+///
+/// typeAliasTemplateDecl() matches
+/// \code
+///   template 
+///   using Y = X;
+/// \endcode
+const internal::VariadicDynCastAllOfMatcher
+typeAliasTemplateDecl;
+
 /// \brief Matches AST nodes that were expanded within the main-file.
 ///
 /// Example matches X but not Y
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -469,6 +469,15 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DecltypeAliasTemplateDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1TypeAliasTemplateDecl.html;>TypeAliasTemplateDecl...
+Matches type alias template declarations.
+
+typeAliasTemplateDecl() matches
+  template typename T
+  using Y = XT;
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DecltypedefDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1TypedefDecl.html;>TypedefDecl...
 Matches typedef declarations.
 

[PATCH] D31397: [Bug 25404] Fix crash on typedef in OpenCL 2.0

2017-03-28 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 93226.
Anastasia added a comment.

Removed check of implicit for new type.


https://reviews.llvm.org/D31397

Files:
  lib/Sema/SemaDecl.cpp
  test/SemaOpenCL/types.cl


Index: test/SemaOpenCL/types.cl
===
--- /dev/null
+++ test/SemaOpenCL/types.cl
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only
+
+// expected-no-diagnostics
+
+// Check redefinition of standard types
+typedef atomic_int atomic_flag;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -2154,7 +2154,9 @@
   // -Wtypedef-redefinition.  If either the original or the redefinition is
   // in a system header, don't emit this for compatibility with GCC.
   if (getDiagnostics().getSuppressSystemWarnings() &&
-  (Context.getSourceManager().isInSystemHeader(Old->getLocation()) ||
+  // Some standard types are defined implicitly in Clang (e.g. OpenCL).
+  (Old->isImplicit() ||
+   Context.getSourceManager().isInSystemHeader(Old->getLocation()) ||
Context.getSourceManager().isInSystemHeader(New->getLocation(
 return;
 


Index: test/SemaOpenCL/types.cl
===
--- /dev/null
+++ test/SemaOpenCL/types.cl
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only
+
+// expected-no-diagnostics
+
+// Check redefinition of standard types
+typedef atomic_int atomic_flag;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -2154,7 +2154,9 @@
   // -Wtypedef-redefinition.  If either the original or the redefinition is
   // in a system header, don't emit this for compatibility with GCC.
   if (getDiagnostics().getSuppressSystemWarnings() &&
-  (Context.getSourceManager().isInSystemHeader(Old->getLocation()) ||
+  // Some standard types are defined implicitly in Clang (e.g. OpenCL).
+  (Old->isImplicit() ||
+   Context.getSourceManager().isInSystemHeader(Old->getLocation()) ||
Context.getSourceManager().isInSystemHeader(New->getLocation(
 return;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31397: [Bug 25404] Fix crash on typedef in OpenCL 2.0

2017-03-28 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:2157
   if (getDiagnostics().getSuppressSystemWarnings() &&
-  (Context.getSourceManager().isInSystemHeader(Old->getLocation()) ||
+  // Some standard types are defined implicitly in Clang (e.g. OpenCL).
+  (Old->isImplicit() || New->isImplicit() ||

Anastasia wrote:
> ahatanak wrote:
> > Is it necessary to check whether New is implicit? I was just wondering when 
> > or how an implicit definition would redefine a typedef.
> I had a thought on it too, and I am not sure actually. This can happen if we 
> implicitly define something from the standard headers. But I believe the Sema 
> initialization should always happen before parsing the standard header or 
> even loading them from the PCH. So I guess this shouldn't ever happen really? 
> Perhaps, I should just remove this?
Actually in case of implicit typedefs we don't seem to follow this program path 
at all. So I am removing this.


https://reviews.llvm.org/D31397



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


[PATCH] D31370: [clang-tidy] Prototype to check for exception specification

2017-03-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/NoexceptCorrectnessCheck.cpp:60
+  N.getNodeAs("direct_throwing_decl")) {
+// FIXME how is that done? i did not find a noThrow predicate
+//if (ThrowingDecl->isNoThrow()) {

JonasToth wrote:
> JonasToth wrote:
> > mgehre wrote:
> > > JonasToth wrote:
> > > > How can i find out the exception spepcification in a `FunctionDecl`? I 
> > > > would like to check if `noexcept` might be added when it is not 
> > > > justified.
> > > Try `ThrowingDecl 
> > > ->getType()->getAs()->getNoexceptSpec()`
> > Does not build :/
> > 
> >note: candidate: clang::FunctionProtoType::NoexceptResult 
> > clang::FunctionProtoType::getNoexceptSpec(const clang::ASTContext&) const
> >NoexceptResult getNoexceptSpec(const ASTContext ) const;
> > 
> > Where do i get the ASTContext from?
> `FunctionPrototype` has the `isNothrow` method, but it needs the `ASTContext` 
> as well.
> An alternative solution would be `hasNoexceptExceptionSpec()`. It would 
> ignore `throw()` most likely.
`Result.Context` is the ASTContext you need.


Repository:
  rL LLVM

https://reviews.llvm.org/D31370



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


[PATCH] D31417: [OpenMP] Add support for omp simd pragmas without runtime

2017-03-28 Thread Graham Hunter via Phabricator via cfe-commits
huntergr added a comment.

In https://reviews.llvm.org/D31417#712008, @fpetrogalli wrote:

> Hi Graham,
>
> thank you for working on this. I understand that you are gonna take care of 
> the CodeGen side of things for the new `-fopenmp-simd` option in a separate 
> patch?


CodeGen for 'simd' pragmas works fine with this patch. 'declare simd' doesn't 
quite work yet, but yes, I was planning to do that in a separate patch.

> I am asking because I expect that the tests in `test/OpenMP/declare_simd_*` 
> will give the same results when invoking clang with the new flag instead of 
> `-fopenmp`.

So 'isAllowedClauseForDirective' needs to be updated; at present, it just bails 
out immediately if the directive kind passed in is OMPD_declare_simd. The 
clauses for a 'declare simd' are handled a little differently in 
ParseOpenMP.cpp, and I need to look into why.

I mainly wanted feedback on the approach at this point, since the patch is 
pretty small and changes won't be too cumbersome.


https://reviews.llvm.org/D31417



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


[PATCH] D31413: [libc++] Use __attribute__((init_priority(101))) to ensure streams get initialized early

2017-03-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I'm not certain of a good way to test it, but I have a question about the value 
you picked for `init_priority`. My understanding of the values starting from 
101 is that 1-100 are reserved for implementation use. Is that understanding 
correct? If so, you may want to pick a value below 100 to ensure there's not an 
arms race with the user. I believe this may require some alteration to 
SemaDeclAttr.cpp to not diagnose when this is coming from a system header. 
Otherwise, what's to stop the user from having something marked 
`constructor(101)` that attempts to use a stream, but can't because they're not 
initialized yet?


https://reviews.llvm.org/D31413



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


[PATCH] D31397: [Bug 25404] Fix crash on typedef in OpenCL 2.0

2017-03-28 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:2157
   if (getDiagnostics().getSuppressSystemWarnings() &&
-  (Context.getSourceManager().isInSystemHeader(Old->getLocation()) ||
+  // Some standard types are defined implicitly in Clang (e.g. OpenCL).
+  (Old->isImplicit() || New->isImplicit() ||

ahatanak wrote:
> Is it necessary to check whether New is implicit? I was just wondering when 
> or how an implicit definition would redefine a typedef.
I had a thought on it too, and I am not sure actually. This can happen if we 
implicitly define something from the standard headers. But I believe the Sema 
initialization should always happen before parsing the standard header or even 
loading them from the PCH. So I guess this shouldn't ever happen really? 
Perhaps, I should just remove this?


https://reviews.llvm.org/D31397



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


[PATCH] D31397: [Bug 25404] Fix crash on typedef in OpenCL 2.0

2017-03-28 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 93225.
Anastasia added a comment.

Updated with the full diff.


https://reviews.llvm.org/D31397

Files:
  lib/Sema/SemaDecl.cpp
  test/SemaOpenCL/types.cl


Index: test/SemaOpenCL/types.cl
===
--- /dev/null
+++ test/SemaOpenCL/types.cl
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only
+
+// expected-no-diagnostics
+
+// Check redefinition of standard types
+typedef atomic_int atomic_flag;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -2154,7 +2154,9 @@
   // -Wtypedef-redefinition.  If either the original or the redefinition is
   // in a system header, don't emit this for compatibility with GCC.
   if (getDiagnostics().getSuppressSystemWarnings() &&
-  (Context.getSourceManager().isInSystemHeader(Old->getLocation()) ||
+  // Some standard types are defined implicitly in Clang (e.g. OpenCL).
+  (Old->isImplicit() || New->isImplicit() ||
+   Context.getSourceManager().isInSystemHeader(Old->getLocation()) ||
Context.getSourceManager().isInSystemHeader(New->getLocation(
 return;
 


Index: test/SemaOpenCL/types.cl
===
--- /dev/null
+++ test/SemaOpenCL/types.cl
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only
+
+// expected-no-diagnostics
+
+// Check redefinition of standard types
+typedef atomic_int atomic_flag;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -2154,7 +2154,9 @@
   // -Wtypedef-redefinition.  If either the original or the redefinition is
   // in a system header, don't emit this for compatibility with GCC.
   if (getDiagnostics().getSuppressSystemWarnings() &&
-  (Context.getSourceManager().isInSystemHeader(Old->getLocation()) ||
+  // Some standard types are defined implicitly in Clang (e.g. OpenCL).
+  (Old->isImplicit() || New->isImplicit() ||
+   Context.getSourceManager().isInSystemHeader(Old->getLocation()) ||
Context.getSourceManager().isInSystemHeader(New->getLocation(
 return;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31417: [OpenMP] Add support for omp simd pragmas without runtime

2017-03-28 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

Hi Graham,

thank you for working on this. I understand that you are gonna take care of the 
CodeGen side of things for the new `-fopenmp-simd` option in a separate patch?

I am asking because I expect that the tests in `test/OpenMP/declare_simd_*` 
will give the same results when invoking clang with the new flag instead of 
`-fopenmp`.

Thank you,

Francesco


https://reviews.llvm.org/D31417



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


[PATCH] D27810: FileManager: mark virtual file entries as valid entries

2017-03-28 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv closed this revision.
erikjv added a comment.

Committed as r298905.


https://reviews.llvm.org/D27810



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


[PATCH] D31417: [OpenMP] Add support for omp simd pragmas without runtime

2017-03-28 Thread Graham Hunter via Phabricator via cfe-commits
huntergr created this revision.
Herald added a subscriber: rengolin.

Adds a new flag ('-fopenmp-simd') to clang which enables processing
of 'simd' and 'declare simd' pragmas without supporting the rest
of OpenMP.

The pragma handler will filter out directives and clauses which
aren't related to simd, and the driver will not add lib(g)omp to
the list of libraries to link.

Documentation updated to describe the new flag.


https://reviews.llvm.org/D31417

Files:
  docs/ClangCommandLineReference.rst
  docs/UsersManual.rst
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  lib/CodeGen/CodeGenModule.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Parse/ParsePragma.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/linking.c
  test/OpenMP/simd_only.c

Index: test/OpenMP/simd_only.c
===
--- /dev/null
+++ test/OpenMP/simd_only.c
@@ -0,0 +1,157 @@
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c -triple aarch64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+// CHECK-LABEL: @simd_plain
+// CHECK-LABEL: omp.inner.for.body:
+// CHECK: load float, float* %arrayidx{{.*}} !llvm.mem.parallel_loop_access
+// CHECK: load float, float* %arrayidx{{.*}} !llvm.mem.parallel_loop_access
+// CHECK: store float %{{.*}}, float* %arrayidx{{.*}} !llvm.mem.parallel_loop_access
+// CHECK: ret void
+void simd_plain(float *a, float *b, float *c, int N) {
+  #pragma omp simd
+  for (int i = 0; i < N; i += 2)
+a[i] = b[i] * c[i];
+}
+
+// CHECK-LABEL: @simd_safelen_clause
+// CHECK-NOT: !llvm.mem.parallel_loop_access
+// CHECK-LABEL: omp.inner.for.inc:
+// CHECK: br label %omp.inner.for.cond, !llvm.loop
+// CHECK: ret void
+void simd_safelen_clause(float *a, float *b, float *c, int N) {
+  #pragma omp simd safelen(4)
+  for (int i = 0; i < N; i += 2)
+a[i] = b[i] * c[i];
+}
+
+extern long long initial_val();
+
+// CHECK-LABEL: @simd_simdlen_and_linear_clause
+// CHECK: omp.inner.for.body:
+// CHECK: !llvm.mem.parallel_loop_access
+// CHECK: ret void
+void simd_simdlen_and_linear_clause(float *a, float *b, float *c, int N) {
+  long long lv = initial_val();
+  #pragma omp simd simdlen(2) linear(lv: 4)
+  for (int i = 0; i < N; ++i) {
+a[lv] = b[lv] * c[lv];
+lv += 4;
+  }
+}
+
+extern float gfloat;
+
+// CHECK-LABEL: @simd_aligned_and_private_clause
+// CHECK-LABEL: entry:
+// CHECK: %gfloat = alloca float, align 4
+// CHECK: store float 1.00e+00, float* @gfloat, align 4
+// CHECK-LABEL: omp.inner.for.body:
+// CHECK-NOT: @gfloat
+// CHECK: load{{.*}}!llvm.mem.parallel_loop_access
+// CHECK: store float {{.*}}, float* %gfloat, align 4, !llvm.mem.parallel_loop_access
+// CHECK: %[[FADD:add[0-9]+]] = fadd float %{{[0-9]+}}, 2.00e+00
+// CHECK: store float %[[FADD]], float* {{.*}}, align 4, !llvm.mem.parallel_loop_access
+// CHECK: ret void
+void simd_aligned_and_private_clause(float *a, float *b, float *c, int N) {
+  gfloat = 1.0f;
+  #pragma omp simd aligned(a:4) private(gfloat)
+  for (int i = 0; i < N; i += 2) {
+gfloat = b[i] * c[i];
+a[i] = gfloat + 2.0f;
+  }
+}
+
+// CHECK-LABEL: @simd_lastprivate_and_reduction_clause
+// CHECK-LABEL: entry:
+// CHECK: %[[SUMVAR:sum[0-9]+]] = alloca float, align 4
+// CHECK: store float 0.00e+00, float* %[[SUMVAR]], align 4
+// CHECK-LABEL: omp.inner.for.body
+// CHECK: %[[LOAD:[0-9]+]] = load float, float* %[[SUMVAR]], align 4, !llvm.mem.parallel_loop_access
+// CHECK: %[[FADD:add[0-9]+]] = fadd float %[[LOAD]], %mul{{.*}}
+// CHECK: store float %[[FADD]], float* %[[SUMVAR]], align 4, !llvm.mem.parallel_loop_access
+// CHECK: store i32{{.*}}, i32* %[[IDXVAR:idx[0-9]+]]
+// CHECK-LABEL: omp.inner.for.end:
+// CHECK-DAG: %[[TMP1:[0-9]+]] = load i32, i32* %[[IDXVAR]], align 4
+// CHECK-DAG: store i32 %[[TMP1]], i32* %idx, align 4
+// CHECK-DAG: %[[INITVAL:[0-9]+]] = load float, float* %sum, align 4
+// CHECK-DAG: %[[TMP2:[0-9]+]] = load float, float* %[[SUMVAR]], align 4
+// CHECK-DAG: %[[SUMMED:add[0-9]+]] = fadd float %[[INITVAL]], %[[TMP2]]
+// CHECK-DAG: store float %[[SUMMED]], float* %sum, align 4
+// CHECK-LABEL: simd.if.end:
+// CHECK: %[[OUTVAL:[0-9]+]] = load float, float* %sum, align 4
+// CHECK: %[[OUTADDR:[0-9]+]] = load float*, float** %a.addr, align 8
+// CHECK: store float %[[OUTVAL]], float* %[[OUTADDR]], align 4
+// CHECK: %[[RETIDX:[0-9]+]] = load i32, i32* %idx, align 4
+// CHECK: ret i32 %[[RETIDX]]
+int simd_lastprivate_and_reduction_clause(float *a, float *b, float *c, int N) {
+  float sum = 0.0f;
+  int idx;
+  #pragma omp simd lastprivate(idx) reduction(+:sum)
+  for (int i = 0; i < N; ++i) {
+sum += b[i] * c[i];
+idx = i * 2;
+  }
+
+  *a = sum;
+  return idx;
+}
+
+// CHECK-LABEL: @simd_collapse_clause
+// CHECK: omp.inner.for.body:
+// CHECK-NOT: 

[PATCH] D31397: [Bug 25404] Fix crash on typedef in OpenCL 2.0

2017-03-28 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

Anastasia, could you generate patch with full context, please?


https://reviews.llvm.org/D31397



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


[PATCH] D23418: [analyzer] Added a reusable constraint system to the CloneDetector

2017-03-28 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor marked an inline comment as done.
teemperor added a comment.

Well this patch won't change a lot with the false-positives or performance 
(it's more refactoring) :)


https://reviews.llvm.org/D23418



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


r298905 - FileManager: mark virtual file entries as valid entries

2017-03-28 Thread Erik Verbruggen via cfe-commits
Author: erikjv
Date: Tue Mar 28 04:18:05 2017
New Revision: 298905

URL: http://llvm.org/viewvc/llvm-project?rev=298905=rev
Log:
FileManager: mark virtual file entries as valid entries

The getVirtualFile method would create entries for e.g. libclang's
CXUnsavedFile but not mark them as valid. The effect is that a lookup
through getFile where the file name is not exactly matching the virtual
file (e.g. through mixing slashes and backslashes on Windows) would
result in a normal file "lookup", and re-using the file entry found
by using the UniqueID, and overwrite the file entry fields. Because the
lookup involves opening the file, and moving it into the file entry, the
file is now open. The SourceManager keys its buffers on the UniqueID
(which is still the same), so it will find an already loaded buffer.
Because only the loading a buffer from disk will close the file, the
FileEntry will hold on to an open file for as long as the FileManager
is around. As the FileManager will only get destroyed at a reparse,
you can't safe to the "leaked" and locked file on Windows.


Modified:
cfe/trunk/lib/Basic/FileManager.cpp
cfe/trunk/unittests/Basic/FileManagerTest.cpp

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=298905=298904=298905=diff
==
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Tue Mar 28 04:18:05 2017
@@ -386,6 +386,7 @@ FileManager::getVirtualFile(StringRef Fi
   UFE->ModTime = ModificationTime;
   UFE->Dir = DirInfo;
   UFE->UID = NextFileUID++;
+  UFE->IsValid = true;
   UFE->File.reset();
   return UFE;
 }

Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=298905=298904=298905=diff
==
--- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original)
+++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Tue Mar 28 04:18:05 2017
@@ -12,6 +12,7 @@
 #include "clang/Basic/FileSystemStatCache.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Config/llvm-config.h"
+#include "llvm/Support/Path.h"
 #include "gtest/gtest.h"
 
 using namespace llvm;
@@ -29,6 +30,12 @@ private:
   llvm::StringMap StatCalls;
 
   void InjectFileOrDirectory(const char *Path, ino_t INode, bool IsFile) {
+#ifndef LLVM_ON_WIN32
+SmallString<128> NormalizedPath(Path);
+llvm::sys::path::native(NormalizedPath);
+Path = NormalizedPath.c_str();
+#endif
+
 FileData Data;
 Data.Name = Path;
 Data.Size = 0;
@@ -55,6 +62,12 @@ public:
   LookupResult getStat(StringRef Path, FileData , bool isFile,
std::unique_ptr *F,
vfs::FileSystem ) override {
+#ifndef LLVM_ON_WIN32
+SmallString<128> NormalizedPath(Path);
+llvm::sys::path::native(NormalizedPath);
+Path = NormalizedPath.c_str();
+#endif
+
 if (StatCalls.count(Path) != 0) {
   Data = StatCalls[Path];
   return CacheExists;
@@ -140,6 +153,7 @@ TEST_F(FileManagerTest, getFileReturnsVa
 
   const FileEntry *file = manager.getFile("/tmp/test");
   ASSERT_TRUE(file != nullptr);
+  ASSERT_TRUE(file->isValid());
   EXPECT_EQ("/tmp/test", file->getName());
 
   const DirectoryEntry *dir = file->getDir();
@@ -164,6 +178,7 @@ TEST_F(FileManagerTest, getFileReturnsVa
   manager.getVirtualFile("virtual/dir/bar.h", 100, 0);
   const FileEntry *file = manager.getFile("virtual/dir/bar.h");
   ASSERT_TRUE(file != nullptr);
+  ASSERT_TRUE(file->isValid());
   EXPECT_EQ("virtual/dir/bar.h", file->getName());
 
   const DirectoryEntry *dir = file->getDir();
@@ -185,7 +200,9 @@ TEST_F(FileManagerTest, getFileReturnsDi
   const FileEntry *fileFoo = manager.getFile("foo.cpp");
   const FileEntry *fileBar = manager.getFile("bar.cpp");
   ASSERT_TRUE(fileFoo != nullptr);
+  ASSERT_TRUE(fileFoo->isValid());
   ASSERT_TRUE(fileBar != nullptr);
+  ASSERT_TRUE(fileBar->isValid());
   EXPECT_NE(fileFoo, fileBar);
 }
 
@@ -231,8 +248,8 @@ TEST_F(FileManagerTest, getFileReturnsSa
   statCache->InjectFile("abc/bar.cpp", 42);
   manager.addStatCache(std::move(statCache));
 
-  manager.getVirtualFile("abc/foo.cpp", 100, 0);
-  manager.getVirtualFile("abc/bar.cpp", 200, 0);
+  ASSERT_TRUE(manager.getVirtualFile("abc/foo.cpp", 100, 0)->isValid());
+  ASSERT_TRUE(manager.getVirtualFile("abc/bar.cpp", 200, 0)->isValid());
 
   EXPECT_EQ(manager.getFile("abc/foo.cpp"), manager.getFile("abc/bar.cpp"));
 }
@@ -246,6 +263,37 @@ TEST_F(FileManagerTest, addRemoveStatCac
   manager.removeStatCache(statCache);
 }
 
+// getFile() Should return the same entry as getVirtualFile if the file 
actually
+// is a virtual file, even if the name is not exactly the same (but is after
+// normalisation done by the file system, like on Windows). 

  1   2   >