[PATCH] D25267: cmake: Set CMAKE_INSTALL_RPATH in Clang when building separately from LLVM

2016-10-05 Thread Michał Górny via cfe-commits
mgorny added a comment.

I presume you copied it out of LLVM. If that's the case, please add an comment 
above stating where it's been copied from.


https://reviews.llvm.org/D25267



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


[PATCH] D24656: [clang-tidy] Add check readability-redundant-declaration

2016-10-05 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki marked 2 inline comments as done.
danielmarjamaki added a comment.

Ping.

I am not very happy about how I detect multivariable declarations. But I really 
don't see any such info in the VarDecl. For instance, the AST dump does not 
show this info.


https://reviews.llvm.org/D24656



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


[PATCH] D25267: cmake: Set CMAKE_INSTALL_RPATH in Clang when building separately from LLVM

2016-10-05 Thread Peter Levine via cfe-commits
plevine added a comment.

In https://reviews.llvm.org/D25267#561955, @mgorny wrote:

> I presume you copied it out of LLVM. If that's the case, please add an 
> comment above stating where it's been copied from.


Yes.  I copied it from LLVM's top-level CMakeLists.txt and added  
${LLVM_LIBRARY_DIR} to the rpath.


https://reviews.llvm.org/D25267



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


[PATCH] D25092: [analyzer] Add "Assuming..." diagnostic pieces for short-circuit logical operators.

2016-10-05 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283302: [analyzer] Improve "Assuming..." diagnostic pieces 
for logical operators. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D25092?vs=73472&id=73601#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25092

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  cfe/trunk/test/Analysis/conditional-path-notes.c
  cfe/trunk/test/Analysis/edges-new.mm

Index: cfe/trunk/test/Analysis/conditional-path-notes.c
===
--- cfe/trunk/test/Analysis/conditional-path-notes.c
+++ cfe/trunk/test/Analysis/conditional-path-notes.c
@@ -64,11 +64,12 @@
   }
 }
 
-void testNonDiagnosableBranchLogical(int a, int b) {
+void testDiagnosableBranchLogical(int a, int b) {
   if (a && b) {
-// expected-note@-1 {{Assuming the condition is true}}
+// expected-note@-1 {{Assuming 'a' is not equal to 0}}
 // expected-note@-2 {{Left side of '&&' is true}}
-// expected-note@-3 {{Taking true branch}}
+// expected-note@-3 {{Assuming 'b' is not equal to 0}}
+// expected-note@-4 {{Taking true branch}}
 *(volatile int *)0 = 1; // expected-warning{{Dereference of null pointer}}
 // expected-note@-1 {{Dereference of null pointer}}
   }
@@ -1343,6 +1344,35 @@
 // CHECK-NEXT:   
 // CHECK-NEXT: 
 // CHECK-NEXT: 
+// CHECK-NEXT:  kindevent
+// CHECK-NEXT:  location
+// CHECK-NEXT:  
+// CHECK-NEXT:   line68
+// CHECK-NEXT:   col7
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  ranges
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  line68
+// CHECK-NEXT:  col7
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  line68
+// CHECK-NEXT:  col7
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT:
+// CHECK-NEXT:  
+// CHECK-NEXT:  depth0
+// CHECK-NEXT:  extended_message
+// CHECK-NEXT:  Assuming 'a' is not equal to 0
+// CHECK-NEXT:  message
+// CHECK-NEXT:  Assuming 'a' is not equal to 0
+// CHECK-NEXT: 
+// CHECK-NEXT: 
 // CHECK-NEXT:  kindcontrol
 // CHECK-NEXT:  edges
 // CHECK-NEXT:   
@@ -1377,53 +1407,19 @@
 // CHECK-NEXT:   
 // CHECK-NEXT: 
 // CHECK-NEXT: 
-// CHECK-NEXT:  kindcontrol
-// CHECK-NEXT:  edges
-// CHECK-NEXT:   
-// CHECK-NEXT:
-// CHECK-NEXT: start
-// CHECK-NEXT:  
-// CHECK-NEXT:   
-// CHECK-NEXT:line68
-// CHECK-NEXT:col12
-// CHECK-NEXT:file0
-// CHECK-NEXT:   
-// CHECK-NEXT:   
-// CHECK-NEXT:line68
-// CHECK-NEXT:col12
-// CHECK-NEXT:file0
-// CHECK-NEXT:   
-// CHECK-NEXT:  
-// CHECK-NEXT: end
-// CHECK-NEXT:  
-// CHECK-NEXT:   
-// CHECK-NEXT:line68
-// CHECK-NEXT:col7
-// CHECK-NEXT:file0
-// CHECK-NEXT:   
-// CHECK-NEXT:   
-// CHECK-NEXT:line68
-// CHECK-NEXT:col7
-// CHECK-NEXT:file0
-// CHECK-NEXT:   
-// CHECK-NEXT:  
-// CHECK-NEXT:
-// CHECK-NEXT:   
-// CHECK-NEXT: 
-// CHECK-NEXT: 
 // CHECK-NEXT:  kindevent
 // CHECK-NEXT:  location
 // CHECK-NEXT:  
 // CHECK-NEXT:   line68
-// CHECK-NEXT:   col7
+// CHECK-NEXT:   col12
 // CHECK-NEXT:   file0
 // CHECK-NEXT:  
 // CHECK-NEXT:  ranges
 // CHECK-NEXT:  
 // CHECK-NEXT:
 // CHECK-NEXT: 
 // CHECK-NEXT:  line68
-// CHECK-NEXT:  col7
+// CHECK-NEXT:  col12
 // CHECK-NEXT:  file0
 // CHECK-NEXT: 
 // CHECK-NEXT: 
@@ -1435,9 +1431,9 @@
 // CHECK-NEXT:  
 // CHECK-NEXT:  depth0
 // CHECK-NEXT:  extended_message
-// CHECK-NEXT:  Assuming the condition is true
+// CHECK-NEXT:  Assuming 'b' is not equal to 0
 // CHECK-NEXT:  message
-// CHECK-NEXT:  Assuming the condition is true
+// CHECK-NEXT:  Assuming 'b' is not equal to 0
 // CHECK-NEXT: 
 // CHECK-NEXT: 
 // CHECK-NEXT:  kindcontrol
@@ -1448,24 +1444,24 @@
 // CHECK-NEXT:  
 // CHECK-NEXT:   
 // CHECK-NEXT:line68
-// CHECK-NEXT:col7
+// CHECK-NEXT:col12
 // CHECK-NEXT:file0
 // CHECK-NEXT:   
 // CHECK-NEXT:   
 // CHECK-NEXT:line68
-// CHECK-NEXT:col7
+// CHECK-NEXT:col12
 // CHECK-NEXT:file0
 // CHECK-NEXT:   
 // CHECK-NEXT:  
 // CHECK-NEXT: end
 // CHECK-NEXT:  
 // CHECK-NEXT:   
-// CHECK-NEXT:line72
+// CHECK-NEXT:line73
 // CHECK-NEXT:col5
 // CHECK-NEXT:file0
 // 

r283302 - [analyzer] Improve "Assuming..." diagnostic pieces for logical operators.

2016-10-05 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Oct  5 03:28:25 2016
New Revision: 283302

URL: http://llvm.org/viewvc/llvm-project?rev=283302&view=rev
Log:
[analyzer] Improve "Assuming..." diagnostic pieces for logical operators.

Logical short-circuit operators now act like other branch conditions.

If the symbolic value of the left-hand side is not known to be true or false
(based on the previous execution path), the "Assuming" event piece is added
in order to explain that the analyzer is adding a new assumption.

Additionally, when the assumption is made against the right-hand side of
the logical operator (i.e. when the operator itself acts as a condition
in another CFG terminator), the "Assuming..." piece is written out for the
right-hand side of the operator rather than for the whole operator.
This allows expression-specific diagnostic message text to be constructed.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/test/Analysis/conditional-path-notes.c
cfe/trunk/test/Analysis/edges-new.mm

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=283302&r1=283301&r2=283302&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Wed Oct  5 
03:28:25 2016
@@ -1271,7 +1271,22 @@ ConditionBRVisitor::VisitTerminator(cons
 BugReporterContext &BRC) {
   const Expr *Cond = nullptr;
 
+  // In the code below, Term is a CFG terminator and Cond is a branch condition
+  // expression upon which the decision is made on this terminator.
+  //
+  // For example, in "if (x == 0)", the "if (x == 0)" statement is a 
terminator,
+  // and "x == 0" is the respective condition.
+  //
+  // Another example: in "if (x && y)", we've got two terminators and two
+  // conditions due to short-circuit nature of operator "&&":
+  // 1. The "if (x && y)" statement is a terminator,
+  //and "y" is the respective condition.
+  // 2. Also "x && ..." is another terminator,
+  //and "x" is its condition.
+
   switch (Term->getStmtClass()) {
+  // FIXME: Stmt::SwitchStmtClass is worth handling, however it is a bit
+  // more tricky because there are more than two branches to account for.
   default:
 return nullptr;
   case Stmt::IfStmtClass:
@@ -1280,6 +1295,24 @@ ConditionBRVisitor::VisitTerminator(cons
   case Stmt::ConditionalOperatorClass:
 Cond = cast(Term)->getCond();
 break;
+  case Stmt::BinaryOperatorClass:
+// When we encounter a logical operator (&& or ||) as a CFG terminator,
+// then the condition is actually its LHS; otheriwse, we'd encounter
+// the parent, such as if-statement, as a terminator.
+const auto *BO = cast(Term);
+assert(BO->isLogicalOp() &&
+   "CFG terminator is not a short-circuit operator!");
+Cond = BO->getLHS();
+break;
+  }
+
+  // However, when we encounter a logical operator as a branch condition,
+  // then the condition is actually its RHS, because LHS would be
+  // the condition for the logical operator terminator.
+  while (const auto *InnerBO = dyn_cast(Cond)) {
+if (!InnerBO->isLogicalOp())
+  break;
+Cond = InnerBO->getRHS()->IgnoreParens();
   }
 
   assert(Cond);

Modified: cfe/trunk/test/Analysis/conditional-path-notes.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/conditional-path-notes.c?rev=283302&r1=283301&r2=283302&view=diff
==
--- cfe/trunk/test/Analysis/conditional-path-notes.c (original)
+++ cfe/trunk/test/Analysis/conditional-path-notes.c Wed Oct  5 03:28:25 2016
@@ -64,11 +64,12 @@ void testDiagnosableBranch(int a) {
   }
 }
 
-void testNonDiagnosableBranchLogical(int a, int b) {
+void testDiagnosableBranchLogical(int a, int b) {
   if (a && b) {
-// expected-note@-1 {{Assuming the condition is true}}
+// expected-note@-1 {{Assuming 'a' is not equal to 0}}
 // expected-note@-2 {{Left side of '&&' is true}}
-// expected-note@-3 {{Taking true branch}}
+// expected-note@-3 {{Assuming 'b' is not equal to 0}}
+// expected-note@-4 {{Taking true branch}}
 *(volatile int *)0 = 1; // expected-warning{{Dereference of null pointer}}
 // expected-note@-1 {{Dereference of null pointer}}
   }
@@ -1343,6 +1344,35 @@ void testNonDiagnosableBranchArithmetic(
 // CHECK-NEXT:   
 // CHECK-NEXT: 
 // CHECK-NEXT: 
+// CHECK-NEXT:  kindevent
+// CHECK-NEXT:  location
+// CHECK-NEXT:  
+// CHECK-NEXT:   line68
+// CHECK-NEXT:   col7
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  ranges
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHEC

Re: [clang-tools-extra] r281453 - [clang-tidy] Add check 'misc-use-after-move'

2016-10-05 Thread Chandler Carruth via cfe-commits
(Somehow I missed this, sorry for silence...)

On Wed, Sep 14, 2016 at 6:13 AM Martin Böhme  wrote:

> While I'm excited to see this go in anywhere, I have to say I'm a bit sad
> it isn't going in as a warning and instead inside clang-tidy. This has been
> a much requested warning from Clang for many years.
>
> Is there a concise description of why this design was chosen? Are there
> specific problems that make it infeasible to be a warnings? Is there maybe
> a plan to move it to a warning after some set of issues are addressed?
>
>
> Yes, my hope is that this can be moved to a warning, and others have
> expressed the same thought to me.
>
> There are two main issues that need to be addressed before this can be
> made a warning:
>
>- I suspect (though I haven't measured) that the implementation isn't
>currently efficient enough to be made a Clang warning.
>- There are a number of scenarios in which the check warns when
>arguably it should not. These are:
>   - User-defined types that make guarantees about the state of a
>   moved-from object (in the way that std::unique_ptr and std::shared_ptr 
> do).
>   Some form of annotation could be used to indicate that this is the case.
>   - User-defined types that provide a member function to reinitialize
>   the entire object (the way that clear() does on the standard container
>   classes). These could either again be annotated in some way, or we could
>   simply assume that any non-const member function reinitializes the 
> object.
>
> I think it would be good to have a general design discussion about what
the semantic model should be here. I have a somewhat specific and precise
idea of what C++ is going for here based on several previous (extensive)
conversations about this with Richard Smith, David Blaikie, and DeLesley
Hutchins. Notably, DeLesley worked on this and closely related warnings in
Clang for quite some time.


>- Tests for move constructors / move assignment operators. Often,
>   these tests check that a moved-from object is left in a certain state, 
> even
>   if the class in question does not provide such a guarantee to clients 
> (the
>   intent being to check that the move constructor / move assignment 
> operator
>   do not simply perform a copy).
>
> All of these scenarios are probably somewhat controversial, but I don't
> think there's a broad consensus that any of them should be prohibited, so
> there needs to be a way to silence the warning in these cases.
>
>
The first two are actually pretty critical features of some types, so yea,
this will end up needing to be directly supported.


>
> I do hope to resolve these issues and make this check into a warning, but
> in the meantime, having it available as a clang-tidy check seems like a
> good way to gather feedback and gain experience with it.
>
> Since you say this is a much-requested warning: Any pointers to previous
> discussions that I should be aware of?
>

Searching the interwebs finds at least:
http://lists.llvm.org/pipermail/cfe-dev/2014-October/039468.html

I know internally our users have asked for this repeatedly, I'll send you
info there.

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


r283303 - [analyzer] Squash a compile error in r283301.

2016-10-05 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Oct  5 03:47:31 2016
New Revision: 283303

URL: http://llvm.org/viewvc/llvm-project?rev=283303&view=rev
Log:
[analyzer] Squash a compile error in r283301.

The constexpr string literal trick isn't supported in MSVC2013.

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h?rev=283303&r1=283302&r2=283303&view=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h 
Wed Oct  5 03:47:31 2016
@@ -186,10 +186,9 @@ public:
 class ConditionBRVisitor final
 : public BugReporterVisitorImpl {
 
-  static constexpr const char *const GenericTrueMessage =
-  "Assuming the condition is true";
-  static constexpr const char *const GenericFalseMessage =
-  "Assuming the condition is false";
+  // FIXME: constexpr initialization isn't supported by MSVC2013.
+  static const char *const GenericTrueMessage;
+  static const char *const GenericFalseMessage;
 
 public:
   void Profile(llvm::FoldingSetNodeID &ID) const override {

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=283303&r1=283302&r2=283303&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Wed Oct  5 
03:47:31 2016
@@ -1603,6 +1603,11 @@ ConditionBRVisitor::VisitTrueTest(const
   return event;
 }
 
+const char *const ConditionBRVisitor::GenericTrueMessage =
+"Assuming the condition is true";
+const char *const ConditionBRVisitor::GenericFalseMessage =
+"Assuming the condition is false";
+
 bool ConditionBRVisitor::isPieceMessageGeneric(
 const PathDiagnosticPiece *Piece) {
   return Piece->getString() == GenericTrueMessage ||


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


[PATCH] D24998: Add a new optimization option -Og

2016-10-05 Thread Keith Walker via cfe-commits
keith.walker.arm added a comment.

Looking into what optimisations would be relevant to -Og (or rather what 
optimisation should be omitted because they are too disruptive to the debug 
experience) is something that I have on my road-map as something to look into 
and gather feedback on.

I agree that this should be considered as just the starting point for enabling 
a fully functional -Og option.


https://reviews.llvm.org/D24998



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


r283304 - [Sema] Packed member warning: Use the typedef name for anonymous structures

2016-10-05 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Oct  5 04:27:48 2016
New Revision: 283304

URL: http://llvm.org/viewvc/llvm-project?rev=283304&view=rev
Log:
[Sema] Packed member warning: Use the typedef name for anonymous structures

This commit improves the packed member warning by showing the name of the
anonymous structure/union when it was defined within a typedef declaration.

rdar://28498901

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

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/address-packed.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=283304&r1=283303&r2=283304&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Oct  5 04:27:48 2016
@@ -11372,8 +11372,13 @@ void Sema::AddPotentialMisalignedMembers
 
 void Sema::DiagnoseMisalignedMembers() {
   for (MisalignedMember &m : MisalignedMembers) {
+const NamedDecl *ND = m.RD;
+if (ND->getName().empty()) {
+  if (const TypedefNameDecl *TD = m.RD->getTypedefNameForAnonDecl())
+ND = TD;
+}
 Diag(m.E->getLocStart(), diag::warn_taking_address_of_packed_member)
-<< m.MD << m.RD << m.E->getSourceRange();
+<< m.MD << ND << m.E->getSourceRange();
   }
   MisalignedMembers.clear();
 }

Modified: cfe/trunk/test/Sema/address-packed.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/address-packed.c?rev=283304&r1=283303&r2=283304&view=diff
==
--- cfe/trunk/test/Sema/address-packed.c (original)
+++ cfe/trunk/test/Sema/address-packed.c Wed Oct  5 04:27:48 2016
@@ -161,3 +161,38 @@ struct AlignedTo2Bis* g7(struct AlignedT
 {
 return (struct AlignedTo2Bis*)&s->x; // no-warning
 }
+
+typedef struct {
+  char c;
+  int x;
+} __attribute__((packed)) TypedefStructArguable;
+
+typedef union {
+  char c;
+  int x;
+} __attribute((packed)) TypedefUnionArguable;
+
+typedef TypedefStructArguable TypedefStructArguableTheSecond;
+
+int *typedef1(TypedefStructArguable *s) {
+return &s->x; // expected-warning {{packed member 'x' of class or 
structure 'TypedefStructArguable'}}
+}
+
+int *typedef2(TypedefStructArguableTheSecond *s) {
+return &s->x; // expected-warning {{packed member 'x' of class or 
structure 'TypedefStructArguable'}}
+}
+
+int *typedef3(TypedefUnionArguable *s) {
+return &s->x; // expected-warning {{packed member 'x' of class or 
structure 'TypedefUnionArguable'}}
+}
+
+struct S6 {
+  union {
+char c;
+int x;
+  } __attribute__((packed));
+};
+
+int *anonymousInnerUnion(struct S6 *s) {
+  return &s->x; // expected-warning {{packed member 'x' of class or structure 
'S6::(anonymous)'}}
+}


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


[PATCH] D25106: Packed member warning: Use the typedef name for anonymous structures when it is available

2016-10-05 Thread Alex Lorenz via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283304: [Sema] Packed member warning: Use the typedef name 
for anonymous structures (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D25106?vs=73338&id=73611#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25106

Files:
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/Sema/address-packed.c


Index: cfe/trunk/test/Sema/address-packed.c
===
--- cfe/trunk/test/Sema/address-packed.c
+++ cfe/trunk/test/Sema/address-packed.c
@@ -161,3 +161,38 @@
 {
 return (struct AlignedTo2Bis*)&s->x; // no-warning
 }
+
+typedef struct {
+  char c;
+  int x;
+} __attribute__((packed)) TypedefStructArguable;
+
+typedef union {
+  char c;
+  int x;
+} __attribute((packed)) TypedefUnionArguable;
+
+typedef TypedefStructArguable TypedefStructArguableTheSecond;
+
+int *typedef1(TypedefStructArguable *s) {
+return &s->x; // expected-warning {{packed member 'x' of class or 
structure 'TypedefStructArguable'}}
+}
+
+int *typedef2(TypedefStructArguableTheSecond *s) {
+return &s->x; // expected-warning {{packed member 'x' of class or 
structure 'TypedefStructArguable'}}
+}
+
+int *typedef3(TypedefUnionArguable *s) {
+return &s->x; // expected-warning {{packed member 'x' of class or 
structure 'TypedefUnionArguable'}}
+}
+
+struct S6 {
+  union {
+char c;
+int x;
+  } __attribute__((packed));
+};
+
+int *anonymousInnerUnion(struct S6 *s) {
+  return &s->x; // expected-warning {{packed member 'x' of class or structure 
'S6::(anonymous)'}}
+}
Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -11372,8 +11372,13 @@
 
 void Sema::DiagnoseMisalignedMembers() {
   for (MisalignedMember &m : MisalignedMembers) {
+const NamedDecl *ND = m.RD;
+if (ND->getName().empty()) {
+  if (const TypedefNameDecl *TD = m.RD->getTypedefNameForAnonDecl())
+ND = TD;
+}
 Diag(m.E->getLocStart(), diag::warn_taking_address_of_packed_member)
-<< m.MD << m.RD << m.E->getSourceRange();
+<< m.MD << ND << m.E->getSourceRange();
   }
   MisalignedMembers.clear();
 }


Index: cfe/trunk/test/Sema/address-packed.c
===
--- cfe/trunk/test/Sema/address-packed.c
+++ cfe/trunk/test/Sema/address-packed.c
@@ -161,3 +161,38 @@
 {
 return (struct AlignedTo2Bis*)&s->x; // no-warning
 }
+
+typedef struct {
+  char c;
+  int x;
+} __attribute__((packed)) TypedefStructArguable;
+
+typedef union {
+  char c;
+  int x;
+} __attribute((packed)) TypedefUnionArguable;
+
+typedef TypedefStructArguable TypedefStructArguableTheSecond;
+
+int *typedef1(TypedefStructArguable *s) {
+return &s->x; // expected-warning {{packed member 'x' of class or structure 'TypedefStructArguable'}}
+}
+
+int *typedef2(TypedefStructArguableTheSecond *s) {
+return &s->x; // expected-warning {{packed member 'x' of class or structure 'TypedefStructArguable'}}
+}
+
+int *typedef3(TypedefUnionArguable *s) {
+return &s->x; // expected-warning {{packed member 'x' of class or structure 'TypedefUnionArguable'}}
+}
+
+struct S6 {
+  union {
+char c;
+int x;
+  } __attribute__((packed));
+};
+
+int *anonymousInnerUnion(struct S6 *s) {
+  return &s->x; // expected-warning {{packed member 'x' of class or structure 'S6::(anonymous)'}}
+}
Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -11372,8 +11372,13 @@
 
 void Sema::DiagnoseMisalignedMembers() {
   for (MisalignedMember &m : MisalignedMembers) {
+const NamedDecl *ND = m.RD;
+if (ND->getName().empty()) {
+  if (const TypedefNameDecl *TD = m.RD->getTypedefNameForAnonDecl())
+ND = TD;
+}
 Diag(m.E->getLocStart(), diag::warn_taking_address_of_packed_member)
-<< m.MD << m.RD << m.E->getSourceRange();
+<< m.MD << ND << m.E->getSourceRange();
   }
   MisalignedMembers.clear();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25254: test-suite: Change extension used for reference outputs by Makefile-based harness so we can start improving how the CMake-based harness works without breaking the old system or the bui

2016-10-05 Thread Renato Golin via cfe-commits
rengolin added a comment.

Can you expand on how you plan to add the second set of reference outputs?

We already have multiple reference outputs, for example big endian vs. little 
endian. I was expecting you to have done a similar thing, which doesn't involve 
changing every single reference file. :)

One way this could be simpler is to change the Makefile on each affected 
directories to duplicate the tests & check differently against the reference 
file. It can be the same reference, but with different thresholds for different 
fp-contract options.


https://reviews.llvm.org/D25254



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


[PATCH] D24954: [ToolChains] Disable OpenSUSE rules for SLES10

2016-10-05 Thread İsmail Dönmez via cfe-commits
ismail added a comment.

That looks good to me but I am not a reviewer. Someone else must approve.


https://reviews.llvm.org/D24954



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


[clang-tools-extra] r283306 - Overhaul clang-include-fixer.el

2016-10-05 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Oct  5 05:04:13 2016
New Revision: 283306

URL: http://llvm.org/viewvc/llvm-project?rev=283306&view=rev
Log:
Overhaul clang-include-fixer.el

General overhaul to fix many coding bugs, simplify the code, and improve 
readability.

* Clarify documentation strings of user options.
* Say that clang-include-fixer-executable is a file to have auto completion.
* Allow user to select available options for clang-include-fixer-input-format. 
Turn it into a symbol as it's not a free-form string.
* Remove clang-include-fixer-query-mode. This option was apparently used to 
select between two different operation modes, which is not a typical use case 
for user options. Provide two separate commands instead.
* Add a face for the overlay highlighting so that users can customize it.
Move user commands to the front so that readers of the code aren't buried in 
internal functions.
* Make process calls asynchronous. This is possible here because 
clang-include-fixer doesn't change files in place. This means input is no 
longer blocked while clang-include-fixer is running.
* Factor out logic in helper functions to keep functions short.
* Add comments where appropriate.
* Provide an alternative buffer replacement strategy for the case that a single 
line was inserted (the normal case in the case of clang-include-fixer). This 
keeps point, markers, and other buffer information intact.
* Use let-alist and association lists instead of property lists to shorten the 
code.
* Instead of highlighting only the first occurrence of a symbol, highlight all 
occurrences and move point to the closest one.
* Detect qualified names at point.
* Use filepos-to-bufferpos if available.
* Formatting.

Patch by Philipp Stephani!

Added:
clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer-test.el
Modified:
clang-tools-extra/trunk/docs/include-fixer.rst
clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el

Modified: clang-tools-extra/trunk/docs/include-fixer.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/include-fixer.rst?rev=283306&r1=283305&r2=283306&view=diff
==
--- clang-tools-extra/trunk/docs/include-fixer.rst (original)
+++ clang-tools-extra/trunk/docs/include-fixer.rst Wed Oct  5 05:04:13 2016
@@ -121,26 +121,19 @@ in your ``.emacs``:
  (add-to-list 'load-path 
"path/to/llvm/source/tools/clang/tools/extra/include-fixer/tool/"
  (require 'clang-include-fixer)
 
-Within Emacs the tool can be invoked with the command ``M-x 
clang-include-fixer``.
+Within Emacs the tool can be invoked with the command
+``M-x clang-include-fixer``.  This will insert the header that defines the
+first undefined symbol; if there is more than one header that would define the
+symbol, the user is prompted to select one.
 
-Make sure Emacs can find :program:`clang-include-fixer`:
-
-- Add the path to :program:`clang-include-fixer` to the PATH environment 
variable.
-
-Customized settings in `.emacs`:
-
-- ``(custom-set-variables '(clang-include-fixer-executable 
"/path/to/include-fixer"))``
+To include the header that defines the symbol at point, run
+``M-x clang-include-fixer-at-point``.
 
-  Set clang-include-fixer binary file path.
-
-- ``(custom-set-variables '(clang-include-fixer-query-mode t))``
-
-  Set to `t` if you want to insert ``#include`` for the symbol under the 
cursor.
-  Default is `nil`. Compared to normal mode, this mode won't parse the source
-  file and only search the sysmbol from database, which is faster than normal
-  mode.
+Make sure Emacs can find :program:`clang-include-fixer`:
 
-See ``clang-include-fixer.el`` for more details.
+- Either add the parent directory of :program:`clang-include-fixer` to the PATH
+  environment variable, or customize the Emacs user option
+  ``clang-include-fixer-executable`` to point to the file name of the program.
 
 How it Works
 

Added: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer-test.el
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer-test.el?rev=283306&view=auto
==
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer-test.el 
(added)
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer-test.el Wed 
Oct  5 05:04:13 2016
@@ -0,0 +1,40 @@
+;;; clang-include-fixer-test.el --- unit tests for clang-include-fixer.el  -*- 
lexical-binding: t; -*-
+
+;;; Commentary:
+
+;; Unit tests for clang-include-fixer.el.
+
+;;; Code:
+
+(require 'cc-mode)
+(require 'ert)
+
+(ert-deftest clang-include-fixer--insert-line ()
+  "Unit test for `clang-include-fixer--insert-line'."
+  (with-temp-buffer
+(insert "aa\nab\nac\nad\n")
+(let ((from (current-buffer)))
+  (with-temp-buffer
+(insert "aa\nac\nad\n")
+(let ((to (current-buffer)))
+  (should

[PATCH] D25210: [ARM] Add Cortex-R52 target to CLANG

2016-10-05 Thread James Molloy via cfe-commits
jmolloy accepted this revision.
jmolloy added a comment.
This revision is now accepted and ready to land.

LGTM, thanks Javed!


https://reviews.llvm.org/D25210



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


[PATCH] D24615: [OpenMP] clang doesnt diagnose if there is a lexical block around a for stmt for OpenMP loops. It is technically not allowed in the OpenMP standard

2016-10-05 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

In https://reviews.llvm.org/D24615#561532, @kkwli0 wrote:

> Should we issue a warning message in this case?


Agree


https://reviews.llvm.org/D24615



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


[PATCH] D25153: preprocessor supports `-dI` flag

2016-10-05 Thread Steve O'Brien via cfe-commits
elsteveogrande updated this revision to Diff 73625.
elsteveogrande added a comment.

Addressed most recent comments, hopefully squashed the last few things.


https://reviews.llvm.org/D25153

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/PreprocessorOutputOptions.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/PrintPreprocessedOutput.cpp
  test/Preprocessor/dump_import.h
  test/Preprocessor/dump_import.m
  test/Preprocessor/dump_include.c
  test/Preprocessor/dump_include.h

Index: test/Preprocessor/dump_include.h
===
--- /dev/null
+++ test/Preprocessor/dump_include.h
@@ -0,0 +1,2 @@
+#pragma once
+#define DUMP_INCLUDE_TESTVAL 1
Index: test/Preprocessor/dump_include.c
===
--- /dev/null
+++ test/Preprocessor/dump_include.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -w -E -dI -isystem %S %s -o - | grep '^#include *
+#include "dump_include.h"
+#include_next "dump_include.h"
Index: test/Preprocessor/dump_import.m
===
--- /dev/null
+++ test/Preprocessor/dump_import.m
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -E -dI %s -o - | grep '^#import'
+
+// See also `dump_include.c` which tests other inclusion cases with `-dI`.
+
+#import "dump_import.h"
Index: test/Preprocessor/dump_import.h
===
--- /dev/null
+++ test/Preprocessor/dump_import.h
@@ -0,0 +1 @@
+#define DUMP_IMPORT_TESTVAL 1
Index: lib/Frontend/PrintPreprocessedOutput.cpp
===
--- lib/Frontend/PrintPreprocessedOutput.cpp
+++ lib/Frontend/PrintPreprocessedOutput.cpp
@@ -93,13 +93,16 @@
   bool Initialized;
   bool DisableLineMarkers;
   bool DumpDefines;
+  bool DumpIncludeDirectives;
   bool UseLineDirectives;
   bool IsFirstFileEntered;
 public:
   PrintPPOutputPPCallbacks(Preprocessor &pp, raw_ostream &os, bool lineMarkers,
-   bool defines, bool UseLineDirectives)
+   bool defines, bool DumpIncludeDirectives,
+   bool UseLineDirectives)
   : PP(pp), SM(PP.getSourceManager()), ConcatInfo(PP), OS(os),
 DisableLineMarkers(lineMarkers), DumpDefines(defines),
+DumpIncludeDirectives(DumpIncludeDirectives),
 UseLineDirectives(UseLineDirectives) {
 CurLine = 0;
 CurFilename += "";
@@ -311,6 +314,42 @@
   }
 }
 
+/// Escape a pathname appropriate for use in preprocessed output, e.g. if using
+/// '-dI' to print info about inclusions of a header within the given \p Path.
+///
+/// This escapes certain characters unsafe for strings within double-quotes, in
+/// turn within a block comment, using a backslash.  Thus the double-quote and
+/// backslash chars are escaped with `\`.  A `*/` (end-of-block-comment)
+/// sequence will become `*\/`.
+///
+/// \param Path Path name.
+/// \returns Vector of characters representing the escaped string.
+static std::vector sanitizePath(StringRef Path) {
+  std::vector Buffer;
+  Buffer.reserve(Path.size() * 2);
+  size_t Size = 0;
+  const size_t N = Path.size();
+  size_t I = 0;
+  while (I < N) {
+if (Path[I] == '\\' || Path[I] == '\"') {
+  // Have to escape backslashes or double-quotes.
+  // Send out backslash to escape the next char.
+  Buffer.push_back('\\');
+} else if (Path[I] == '*' && (I + 1) < N && Path[I + 1] == '/') {
+  // In the exceedingly strange case of the path having a "*/" sequence,
+  // escape only the slash.  Note that we don't always escape slashes, only
+  // slashes as part of this sequence.
+  // Copy out the asterisk and consume it...
+  Buffer.push_back(Path[I++]);
+  // Send out backslash to escape the next char (i.e. the slash).
+  Buffer.push_back('\\');
+}
+// Consume and write out the next input char.
+Buffer.push_back(Path[I++]);
+  }
+  return Buffer;
+}
+
 void PrintPPOutputPPCallbacks::InclusionDirective(SourceLocation HashLoc,
   const Token &IncludeTok,
   StringRef FileName,
@@ -320,20 +359,20 @@
   StringRef SearchPath,
   StringRef RelativePath,
   const Module *Imported) {
-  // When preprocessing, turn implicit imports into @imports.
-  // FIXME: This is a stop-gap until a more comprehensive "preprocessing with
-  // modules" solution is introduced.
   if (Imported) {
+// When preprocessing, turn implicit imports into @imports.
+// FIXME: This is a stop-gap until a more comprehensive "preprocessing with
+// modules" solution is introduced.
 startNewLineIfNeeded();
 MoveToLine(HashLoc);
 if (PP.getLangOpts().ObjC2) {
   OS << "@im

[PATCH] D25273: Fix PR30520: Fix incomplete type crash when dealing with transparent_union attribute

2016-10-05 Thread Alex Lorenz via cfe-commits
arphaman created this revision.
arphaman added a reviewer: aaron.ballman.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

This patch fixes a crash that happens when clang is analyzing a 
transparent_union attribute on a union which has a field with incomplete type.

(Right now there's also a C++ crash like this when a field has a dependent 
type, but I plan on fixing it in a separate patch by analyzing the dependent 
attribute when the dependent union is instantiated).


Repository:
  rL LLVM

https://reviews.llvm.org/D25273

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/transparent-union.c


Index: test/Sema/transparent-union.c
===
--- test/Sema/transparent-union.c
+++ test/Sema/transparent-union.c
@@ -89,3 +89,12 @@
 unsigned int u3;
   } __attribute__((aligned(8)));
 } __attribute__((transparent_union));
+
+union pr30520v { void b; } __attribute__((transparent_union)); // 
expected-error {{field has incomplete type 'void'}}
+
+union pr30520a { int b[]; } __attribute__((transparent_union)); // 
expected-error {{field has incomplete type 'int []'}}
+
+// expected-note@+1 2 {{forward declaration of 'struct stb'}}
+union pr30520s { struct stb b; } __attribute__((transparent_union)); // 
expected-error {{field has incomplete type 'struct stb'}}
+
+union pr30520s2 { int *v; struct stb b; } __attribute__((transparent_union)); 
// expected-error {{field has incomplete type 'struct stb'}}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3044,10 +3044,14 @@
 return;
   }
 
+  if (FirstType->isIncompleteType())
+return;
   uint64_t FirstSize = S.Context.getTypeSize(FirstType);
   uint64_t FirstAlign = S.Context.getTypeAlign(FirstType);
   for (; Field != FieldEnd; ++Field) {
 QualType FieldType = Field->getType();
+if (FieldType->isIncompleteType())
+  return;
 // FIXME: this isn't fully correct; we also need to test whether the
 // members of the union would all have the same calling convention as the
 // first member of the union. Checking just the size and alignment isn't


Index: test/Sema/transparent-union.c
===
--- test/Sema/transparent-union.c
+++ test/Sema/transparent-union.c
@@ -89,3 +89,12 @@
 unsigned int u3;
   } __attribute__((aligned(8)));
 } __attribute__((transparent_union));
+
+union pr30520v { void b; } __attribute__((transparent_union)); // expected-error {{field has incomplete type 'void'}}
+
+union pr30520a { int b[]; } __attribute__((transparent_union)); // expected-error {{field has incomplete type 'int []'}}
+
+// expected-note@+1 2 {{forward declaration of 'struct stb'}}
+union pr30520s { struct stb b; } __attribute__((transparent_union)); // expected-error {{field has incomplete type 'struct stb'}}
+
+union pr30520s2 { int *v; struct stb b; } __attribute__((transparent_union)); // expected-error {{field has incomplete type 'struct stb'}}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3044,10 +3044,14 @@
 return;
   }
 
+  if (FirstType->isIncompleteType())
+return;
   uint64_t FirstSize = S.Context.getTypeSize(FirstType);
   uint64_t FirstAlign = S.Context.getTypeAlign(FirstType);
   for (; Field != FieldEnd; ++Field) {
 QualType FieldType = Field->getType();
+if (FieldType->isIncompleteType())
+  return;
 // FIXME: this isn't fully correct; we also need to test whether the
 // members of the union would all have the same calling convention as the
 // first member of the union. Checking just the size and alignment isn't
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24861: [Sema] extend Wshift-op-parentheses so it warns for multiplicative operators

2016-10-05 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki set the repository for this revision to rL LLVM.
danielmarjamaki updated this revision to Diff 73633.
danielmarjamaki added a comment.

Add new flag : -Wshift-op-parentheses-mul
This is not enabled by default.


Repository:
  rL LLVM

https://reviews.llvm.org/D24861

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  test/Sema/parentheses.cpp

Index: test/Sema/parentheses.cpp
===
--- test/Sema/parentheses.cpp
+++ test/Sema/parentheses.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -Wparentheses -fsyntax-only -verify %s
-// RUN: %clang_cc1 -Wparentheses -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -Wparentheses -Wshift-op-parentheses-mul -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wparentheses -Wshift-op-parentheses-mul -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 bool someConditionFunc();
 
@@ -95,6 +95,23 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:10-[[@LINE-2]]:10}:"("
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:15-[[@LINE-3]]:15}:")"
 
+  (void)(a >> b * c); // expected-warning {{operator '>>' has lower precedence than '*'; '*' will be evaluated first}} \
+ expected-note {{place parentheses around the '*' expression to silence this warning}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:15-[[@LINE-2]]:15}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:20}:")"
+
+  (void)(a / b << c); // expected-warning {{operator '<<' has lower precedence than '/'; '/' will be evaluated first}} \
+ expected-note {{place parentheses around the '/' expression to silence this warning}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:10-[[@LINE-2]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:15-[[@LINE-3]]:15}:")"
+
+  (void)(a % b << c); // expected-warning {{operator '<<' has lower precedence than '%'; '%' will be evaluated first}} \
+ expected-note {{place parentheses around the '%' expression to silence this warning}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:10-[[@LINE-2]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:15-[[@LINE-3]]:15}:")"
+
+  (void)(a * b << c); // no warning, often the execution order does not matter.
+
   Stream() << b + c;
   Stream() >> b + c; // expected-warning {{operator '>>' has lower precedence than '+'; '+' will be evaluated first}} \
 expected-note {{place parentheses around the '+' expression to silence this warning}}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -11263,18 +11263,26 @@
   }
 }
 
-static void DiagnoseAdditionInShift(Sema &S, SourceLocation OpLoc,
-Expr *SubExpr, StringRef Shift) {
-  if (BinaryOperator *Bop = dyn_cast(SubExpr)) {
-if (Bop->getOpcode() == BO_Add || Bop->getOpcode() == BO_Sub) {
-  StringRef Op = Bop->getOpcodeStr();
-  S.Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
-  << Bop->getSourceRange() << OpLoc << Shift << Op;
-  SuggestParentheses(S, Bop->getOperatorLoc(),
-  S.PDiag(diag::note_precedence_silence) << Op,
-  Bop->getSourceRange());
-}
-  }
+static void DiagnoseAddOrMulInShift(Sema &S, SourceLocation OpLoc,
+Expr *SubExpr, StringRef Shift,
+bool ShiftLeftLHS) {
+  BinaryOperator *Bop = dyn_cast(SubExpr);
+  if (!Bop)
+return;
+  if (!Bop->isAdditiveOp() && !Bop->isMultiplicativeOp())
+return;
+  // In many cases, execution order does not matter for 'A*BgetOpcodeStr();
+  S.Diag(Bop->getOperatorLoc(), Bop->isAdditiveOp()
+? diag::warn_addition_in_bitshift
+: diag::warn_multiplication_in_bitshift)
+  << Bop->getSourceRange() << OpLoc << Shift << Op;
+  SuggestParentheses(S, Bop->getOperatorLoc(),
+ S.PDiag(diag::note_precedence_silence) << Op,
+ Bop->getSourceRange());
 }
 
 static void DiagnoseShiftCompare(Sema &S, SourceLocation OpLoc,
@@ -11330,8 +11338,8 @@
   if ((Opc == BO_Shl && LHSExpr->getType()->isIntegralType(Self.getASTContext()))
   || Opc == BO_Shr) {
 StringRef Shift = BinaryOperator::getOpcodeStr(Opc);
-DiagnoseAdditionInShift(Self, OpLoc, LHSExpr, Shift);
-DiagnoseAdditionInShift(Self, OpLoc, RHSExpr, Shift);
+DiagnoseAddOrMulInShift(Self, OpLoc, LHSExpr, Shift, Opc == BO_Shl);
+DiagnoseAddOrMulInShift(Self, OpLoc, RHSExpr, Shift, false);
   }
 
   // Warn on overloaded shift operators and comparisons, such as:
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include

[PATCH] D25252: [OpenMP] Check if the template specialization is mappable instead of specialized template

2016-10-05 Thread David Sheinkman via cfe-commits
davidsh created this revision.
davidsh added reviewers: carlo.bertolli, arpith-jacob, kkwli0, sfantao, ABataev.
davidsh added a subscriber: cfe-commits.

Clang segfaults on this case instead of diagnosing because it looks at the 
specialized template:
template 
struct MyClass;

template<>
struct MyClass
{
virtual void foo() {}
};

int main() {

  MyClass m;
  #pragma omp target map(m)
  {}

}


https://reviews.llvm.org/D25252

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/target_map_messages.cpp


Index: test/OpenMP/target_map_messages.cpp
===
--- test/OpenMP/target_map_messages.cpp
+++ test/OpenMP/target_map_messages.cpp
@@ -347,6 +347,15 @@
   S5(int v):a(v) { }
 };
 
+template 
+struct S6;
+
+template<>
+struct S6  // expected-note {{mappable type cannot be polymorphic}}
+{
+   virtual void foo();
+};
+
 S3 h;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or 
thread local}}
 
@@ -451,6 +460,7 @@
   int i;
   int &j = i;
   int *k = &j;
+  S6 m;
   int x;
   int y;
   int to, tofrom, always;
@@ -513,6 +523,8 @@
   {}
 #pragma omp target firstprivate(j) map(j)  // expected-error {{firstprivate 
variable cannot be in a map clause in '#pragma omp target' directive}} 
expected-note {{defined as firstprivate}}
   {}
+#pragma omp target map(m) // expected-error {{type 'S6' is not mappable 
to target}}
+  {}
   return tmain(argc)+tmain(argc); // expected-note {{in 
instantiation of function template specialization 'tmain' requested 
here}} expected-note {{in instantiation of function template specialization 
'tmain' requested here}}
 }
 #endif
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -10523,9 +10523,6 @@
   if (!RD || RD->isInvalidDecl())
 return true;
 
-  if (auto *CTSD = dyn_cast(RD))
-if (auto *CTD = CTSD->getSpecializedTemplate())
-  RD = CTD->getTemplatedDecl();
   auto QTy = SemaRef.Context.getRecordType(RD);
   if (RD->isDynamicClass()) {
 SemaRef.Diag(Loc, diag::err_omp_not_mappable_type) << QTy;


Index: test/OpenMP/target_map_messages.cpp
===
--- test/OpenMP/target_map_messages.cpp
+++ test/OpenMP/target_map_messages.cpp
@@ -347,6 +347,15 @@
   S5(int v):a(v) { }
 };
 
+template 
+struct S6;
+
+template<>
+struct S6  // expected-note {{mappable type cannot be polymorphic}}
+{
+   virtual void foo();
+};
+
 S3 h;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
 
@@ -451,6 +460,7 @@
   int i;
   int &j = i;
   int *k = &j;
+  S6 m;
   int x;
   int y;
   int to, tofrom, always;
@@ -513,6 +523,8 @@
   {}
 #pragma omp target firstprivate(j) map(j)  // expected-error {{firstprivate variable cannot be in a map clause in '#pragma omp target' directive}} expected-note {{defined as firstprivate}}
   {}
+#pragma omp target map(m) // expected-error {{type 'S6' is not mappable to target}}
+  {}
   return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
 #endif
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -10523,9 +10523,6 @@
   if (!RD || RD->isInvalidDecl())
 return true;
 
-  if (auto *CTSD = dyn_cast(RD))
-if (auto *CTD = CTSD->getSpecializedTemplate())
-  RD = CTD->getTemplatedDecl();
   auto QTy = SemaRef.Context.getRecordType(RD);
   if (RD->isDynamicClass()) {
 SemaRef.Diag(Loc, diag::err_omp_not_mappable_type) << QTy;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25256: [Driver] Print path to correct rtlib for -print_libgcc_file_name

2016-10-05 Thread Petr Hosek via cfe-commits
phosek created this revision.
phosek added a subscriber: cfe-commits.
phosek set the repository for this revision to rL LLVM.

When compiler-rt is being used as a runtime library, Clang would print an 
invalid path when -print_libgcc_file_name option is used. We should print a 
path to compiler-rt builtin library instead.


Repository:
  rL LLVM

https://reviews.llvm.org/D25256

Files:
  lib/Driver/Driver.cpp


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -994,7 +994,17 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
+std::string Path;
+switch (RLT) {
+case ToolChain::RLT_CompilerRT:
+  Path = TC.getCompilerRT(C.getArgs(), "builtins");
+  break;
+case ToolChain::RLT_Libgcc:
+  Path = GetFilePath("libgcc.a", TC);
+  break;
+}
+llvm::outs() << Path << "\n";
 return false;
   }
 


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -994,7 +994,17 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
+std::string Path;
+switch (RLT) {
+case ToolChain::RLT_CompilerRT:
+  Path = TC.getCompilerRT(C.getArgs(), "builtins");
+  break;
+case ToolChain::RLT_Libgcc:
+  Path = GetFilePath("libgcc.a", TC);
+  break;
+}
+llvm::outs() << Path << "\n";
 return false;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25171: clang-format: Add two new formatting options

2016-10-05 Thread Robin Sommer via cfe-commits
rsmmr added a comment.

Cool, thanks Steve. What's the next step for me to get it committed?


https://reviews.llvm.org/D25171



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


[PATCH] D25117: [Driver] Add driver support for Fuchsia

2016-10-05 Thread Petr Hosek via cfe-commits
phosek updated this revision to Diff 73562.

Repository:
  rL LLVM

https://reviews.llvm.org/D25117

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  test/Driver/fuchsia.c
  test/Driver/fuchsia.cpp

Index: test/Driver/fuchsia.cpp
===
--- /dev/null
+++ test/Driver/fuchsia.cpp
@@ -0,0 +1,33 @@
+// RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia \
+// RUN: --sysroot=%S/platform 2>&1 | FileCheck %s
+// CHECK: {{.*}}clang{{.*}}" "-cc1"
+// CHECK: "-fuse-init-array"
+// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK: "-internal-isystem" "[[SYSROOT]]{{/|}}include{{/|}}c++{{/|}}v1"
+// CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
+// CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
+// CHECK: "--sysroot=[[SYSROOT]]"
+// CHECK: "-pie"
+// CHECK: "--build-id"
+// CHECK: "-dynamic-linker" "ld.so.1"
+// CHECK: Scrt1.o
+// CHECK-NOT: crti.o
+// CHECK-NOT: crtbegin.o
+// CHECK: "-L[[SYSROOT]]/lib"
+// CHECK: "-lc++" "-lc++abi" "-lunwind" "-lm"
+// CHECK: "{{.*[/\\]}}libclang_rt.builtins-x86_64.a"
+// CHECK: "-lc"
+// CHECK-NOT: crtend.o
+// CHECK-NOT: crtn.o
+
+// RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -stdlib=libstdc++ 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-STDLIB
+// CHECK-STDLIB: error: invalid library name in argument '-stdlib=libstdc++'
+
+// RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -static-libstdc++ 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-STATIC
+// CHECK-STATIC: "-Bstatic"
+// CHECK-STATIC: "-lc++" "-lc++abi" "-lunwind"
+// CHECK-STATIC: "-Bdynamic"
+// CHECK-STATIC: "-lm"
+// CHECK-STATIC: "-lc"
Index: test/Driver/fuchsia.c
===
--- /dev/null
+++ test/Driver/fuchsia.c
@@ -0,0 +1,40 @@
+// RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
+// RUN: --sysroot=%S/platform 2>&1 | FileCheck %s
+// CHECK: {{.*}}clang{{.*}}" "-cc1"
+// CHECK: "-fuse-init-array"
+// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
+// CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
+// CHECK: "--sysroot=[[SYSROOT]]"
+// CHECK: "-pie"
+// CHECK: "--build-id"
+// CHECK: "-dynamic-linker" "ld.so.1"
+// CHECK: Scrt1.o
+// CHECK-NOT: crti.o
+// CHECK-NOT: crtbegin.o
+// CHECK: "-L[[SYSROOT]]/lib"
+// CHECK: "{{.*[/\\]}}libclang_rt.builtins-x86_64.a"
+// CHECK: "-lc"
+// CHECK-NOT: crtend.o
+// CHECK-NOT: crtn.o
+
+// RUN: %clang %s -### --target=x86_64-unknown-fuchsia -rtlib=libgcc 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-RTLIB
+// CHECK-RTLIB: error: invalid runtime library name in argument '-rtlib=libgcc'
+
+// RUN: %clang %s -### --target=x86_64-unknown-fuchsia -static 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-STATIC
+// CHECK-STATIC: "-Bstatic"
+// CHECK-STATIC: "-Bdynamic"
+// CHECK-STATIC: "-lc"
+
+// RUN: %clang %s -### --target=x86_64-unknown-fuchsia -shared 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SHARED
+// CHECK-SHARED-NOT: "-pie"
+// CHECK-SHARED: "-shared"
+
+// RUN: %clang %s -### --target=x86_64-unknown-fuchsia -r 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-RELOCATABLE
+// CHECK-RELOCATABLE-NOT: "-pie"
+// CHECK-RELOCATABLE-NOT: "--build-id"
+// CHECK-RELOCATABLE: "-r"
Index: lib/Driver/Tools.h
===
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -596,6 +596,21 @@
 };
 } // end namespace nacltools
 
+namespace fuchsia {
+class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
+public:
+  Linker(const ToolChain &TC) : GnuTool("fuchsia::Linker", "ld.lld", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+  bool isLinkJob() const override { return true; }
+
+  void ConstructJob(Compilation &C, const JobAction &JA,
+const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::opt::ArgList &TCArgs,
+const char *LinkingOutput) const override;
+};
+} // end namespace fuchsia
+
 /// minix -- Directly call GNU Binutils assembler and linker
 namespace minix {
 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9493,6 +9493,7 @@
   llvm_unreachable("unsupported OS");
 case llvm::Triple::Win32:
 case llvm::Triple::Linux:
+case llvm::Triple::Fuchsia:
   addClangRT(TC, Args, CmdArgs);
   break;
 }
@@ -9979,6 +9980,112 @@
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 
+void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,
+   const InputInfo &Output,
+   const InputInfoList

[PATCH] D25263: [Driver] Allow setting the default linker during build

2016-10-05 Thread Petr Hosek via cfe-commits
phosek created this revision.
phosek added a subscriber: cfe-commits.
phosek set the repository for this revision to rL LLVM.
Herald added subscribers: mgorny, beanz.

This change allows setting the default linker used by the Clang driver when 
configuring the build.


Repository:
  rL LLVM

https://reviews.llvm.org/D25263

Files:
  CMakeLists.txt
  include/clang/Config/config.h.cmake
  lib/Driver/ToolChain.cpp


Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -341,31 +341,29 @@
 }
 
 std::string ToolChain::GetLinkerPath() const {
-  if (Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
-StringRef UseLinker = A->getValue();
-
-if (llvm::sys::path::is_absolute(UseLinker)) {
-  // If we're passed -fuse-ld= with what looks like an absolute path,
-  // don't attempt to second-guess that.
-  if (llvm::sys::fs::exists(UseLinker))
-return UseLinker;
-} else {
-  // If we're passed -fuse-ld= with no argument, or with the argument ld,
-  // then use whatever the default system linker is.
-  if (UseLinker.empty() || UseLinker == "ld")
-return GetProgramPath("ld");
-
-  llvm::SmallString<8> LinkerName("ld.");
-  LinkerName.append(UseLinker);
-
-  std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
-  if (llvm::sys::fs::exists(LinkerPath))
-return LinkerPath;
-}
+  const Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ);
+  StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
+
+  if (llvm::sys::path::is_absolute(UseLinker)) {
+// If we're passed -fuse-ld= with what looks like an absolute path,
+// don't attempt to second-guess that.
+if (llvm::sys::fs::exists(UseLinker))
+  return UseLinker;
+  } else if (A && (UseLinker.empty() || UseLinker == "ld")) {
+// If we're passed -fuse-ld= with no argument, or with the argument ld,
+// then use whatever the default system linker is.
+return GetProgramPath("ld");
+  } else if (!UseLinker.empty()) {
+llvm::SmallString<8> LinkerName("ld.");
+LinkerName.append(UseLinker);
+
+std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
+if (llvm::sys::fs::exists(LinkerPath))
+  return LinkerPath;
+  }
 
+  if (A)
 getDriver().Diag(diag::err_drv_invalid_linker_name) << 
A->getAsString(Args);
-return "";
-  }
 
   return GetProgramPath(DefaultLinker);
 }
Index: include/clang/Config/config.h.cmake
===
--- include/clang/Config/config.h.cmake
+++ include/clang/Config/config.h.cmake
@@ -8,6 +8,9 @@
 /* Bug report URL. */
 #define BUG_REPORT_URL "${BUG_REPORT_URL}"
 
+/* Default linker to use. */
+#define CLANG_DEFAULT_LINKER "${CLANG_DEFAULT_LINKER}"
+
 /* Default C++ stdlib to use. */
 #define CLANG_DEFAULT_CXX_STDLIB "${CLANG_DEFAULT_CXX_STDLIB}"
 
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -195,6 +195,17 @@
 set(ENABLE_X86_RELAX_RELOCATIONS OFF CACHE BOOL
 "enable x86 relax relocations by default")
 
+set(CLANG_DEFAULT_LINKER "" CACHE STRING
+  "Default linker to use (\"bfd\" or \"gold\" or \"lld\", empty for platform 
default")
+if (NOT(CLANG_DEFAULT_LINKER STREQUAL "" OR
+CLANG_DEFAULT_LINKER STREQUAL "bfd" OR
+CLANG_DEFAULT_LINKER STREQUAL "gold" OR
+CLANG_DEFAULT_LINKER STREQUAL "lld"))
+  message(WARNING "Resetting default linker to use platform default")
+  set(CLANG_DEFAULT_LINKER "" CACHE STRING
+"Default linker to use (\"bfd\" or \"gold\" or \"lld\", empty for platform 
default" FORCE)
+endif()
+
 set(CLANG_DEFAULT_CXX_STDLIB "" CACHE STRING
   "Default C++ stdlib to use (\"libstdc++\" or \"libc++\", empty for platform 
default")
 if (NOT(CLANG_DEFAULT_CXX_STDLIB STREQUAL "" OR


Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -341,31 +341,29 @@
 }
 
 std::string ToolChain::GetLinkerPath() const {
-  if (Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
-StringRef UseLinker = A->getValue();
-
-if (llvm::sys::path::is_absolute(UseLinker)) {
-  // If we're passed -fuse-ld= with what looks like an absolute path,
-  // don't attempt to second-guess that.
-  if (llvm::sys::fs::exists(UseLinker))
-return UseLinker;
-} else {
-  // If we're passed -fuse-ld= with no argument, or with the argument ld,
-  // then use whatever the default system linker is.
-  if (UseLinker.empty() || UseLinker == "ld")
-return GetProgramPath("ld");
-
-  llvm::SmallString<8> LinkerName("ld.");
-  LinkerName.append(UseLinker);
-
-  std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
-  if (llvm::sys::fs::exists(LinkerPath))
-return LinkerPath;
-}
+  const A

[PATCH] D25204: Register Calling Convention, Clang changes

2016-10-05 Thread Oren Ben Simhon via cfe-commits
oren_ben_simhon added inline comments.


> AttrDocs.td:1267
> +
> +.. _`__regcall`: https://software.intel.com/en-us/node/512847
> +  }];

You might want to use the following link instead because it is most updated: 
https://software.intel.com/en-us/node/693069

> TargetInfo.cpp:3352
>// Keep track of the number of assigned registers.
> -  unsigned freeIntRegs = 6, freeSSERegs = 8;
> +  unsigned freeIntRegs = IsRegCall ? 11 : 6;
> +  unsigned freeSSERegs = IsRegCall ? 16 : 8;

According to the ABI, there are 12 free int regs for windows and 11 free int 
regs for non-windows (linux, OSX, etc). Is that taken into account somewhere?

> TargetInfo.cpp:3732
> +  } else if (IsRegCall) {
> +// RegCall gives us 16 SSE registers total, return or otherwise.
> +FreeSSERegs = 16;

Maybe i misinterpret the comment, but AFAIK, RegCall gives us 16 SSE registers 
for each (return values and passed arguments)

> regcall.c:26
> +void __regcall v3(int a, struct Small b, int c) {}
> +// Win32: define x86_regcallcc void @"\01__regcall3__v3@12"(i32 inreg %a, 
> i32 %b.0, i32 inreg %c)
> +// Win64: define x86_regcallcc void @"\01__regcall3__v3@24"(i32 %a, i32 
> %b.coerce, i32 %c)

I see that expended structures don't get InReg attribute. IMHO, If you know 
that the value should be saved in register then you InReg attribute should be 
added.

https://reviews.llvm.org/D25204



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


[PATCH] D15075: No error for conflict between inputs\outputs and clobber list

2016-10-05 Thread Ziv Izhar via cfe-commits
zizhar updated this revision to Diff 73617.
zizhar added a comment.

Changed the '^' to point to the clobber which conflicts.
Changed the relevant comments.
However, regarding the point about the non-alphabetical characters - It's a 
different behavior for these specific characters,
since these should be ignored and the default case is for an unknown character.


https://reviews.llvm.org/D15075

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TargetInfo.h
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets.cpp
  lib/Headers/intrin.h
  lib/Sema/SemaStmtAsm.cpp
  test/Sema/asm.c

Index: test/Sema/asm.c
===
--- test/Sema/asm.c
+++ test/Sema/asm.c
@@ -28,6 +28,16 @@
   asm ("nop" : : : "204"); // expected-error {{unknown register name '204' in asm}}
   asm ("nop" : : : "-1"); // expected-error {{unknown register name '-1' in asm}}
   asm ("nop" : : : "+1"); // expected-error {{unknown register name '+1' in asm}}
+  register void *clobber_conflict asm ("%rcx");
+  register void *no_clobber_conflict asm ("%rax");
+  int a,b,c;
+  asm ("nop" : "=r" (no_clobber_conflict) : "r" (clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=r" (clobber_conflict) : "r" (no_clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=r" (clobber_conflict) : "r" (clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=c" (a) : "r" (no_clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=r" (no_clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=r" (clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=a" (a) : "b" (b) : "%rcx", "%rbx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}} 
 }
 
 // rdar://6094010
Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -22,6 +22,7 @@
 #include "clang/Sema/ScopeInfo.h"
 #include "clang/Sema/SemaInternal.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/MC/MCParser/MCAsmParser.h"
 using namespace clang;
 using namespace sema;
@@ -137,6 +138,58 @@
   return false;
 }
 
+// Extracting the register name from the Expression value,
+// if there is no register name to extract, returns ""
+StringRef ExtractRegisterName(const Expr *Expression, const TargetInfo &Target) {
+  while (const ImplicitCastExpr *P = dyn_cast(Expression)) {
+Expression = P->getSubExpr();
+  }
+  if (const DeclRefExpr *AsmDeclRef = dyn_cast(Expression)) {
+// Handle cases where the expression is a variable
+const VarDecl *Variable = dyn_cast(AsmDeclRef->getDecl());
+if (Variable && Variable->getStorageClass() == SC_Register) {
+  if (AsmLabelAttr *Attr = Variable->getAttr())
+return Target.isValidGCCRegisterName(Attr->getLabel())
+? Target.getNormalizedGCCRegisterName(Attr->getLabel(), true)
+: "";
+}
+  }
+  return "";
+}
+
+// Checks if there is a conflict between the input and output lists with the
+// clobbers list. If there's a conflict, returns the location of the
+// conflicted clobber, else returns nullptr
+SourceLocation* GetClobberConflictLocation(MultiExprArg Exprs, 
+  StringLiteral **Constraints, StringLiteral **Clobbers, int NumClobbers,
+  const TargetInfo &Target, ASTContext &Cont) {
+  llvm::StringSet<> InOutVars;
+  // Collect all the input and output registers from the extended asm statement
+  // in order to check for conflicts with the clobber list
+  for (int i = 0; i < Exprs.size(); ++i) {
+StringRef Constraint = Constraints[i]->getString();
+StringRef InOutReg = Target.getConstraintRegister(
+  Constraint, ExtractRegisterName(Exprs[i], Target));
+if (InOutReg != "")
+  InOutVars.insert(InOutReg);
+  }
+  // Check for each item in the clobber list if it conflicts with the input
+  // or output
+  for (int i = 0; i < NumClobbers; ++i) {
+StringRef Clobber = Clobbers[i]->getString();
+// We only check registers, therefore we don't check cc and memory clobbers
+if (Clobber == "cc" || Clobber == "memory")
+  continue;
+Clobber = Target.getNormalizedGCCRegisterName(Clobber, true);
+// Go over the output's registers we collected
+if (InOutVars.find(Clobber) != InOutVars.end()){
+  SourceLocation Loc = Clobbers[i]->getLocStart();
+  return &Loc;
+}
+  }
+  return nullptr;
+}
+
 StmtResu

[PATCH] D25012: [x86][inline-asm] Add support for curly brackets escape using "%" in extended inline asm.

2016-10-05 Thread Matan via cfe-commits
mharoush updated this revision to Diff 73602.

Repository:
  rL LLVM

https://reviews.llvm.org/D25012

Files:
  lib/AST/Stmt.cpp
  test/CodeGen/x86_inlineasm_curly_bracket_escape.c


Index: lib/AST/Stmt.cpp
===
--- lib/AST/Stmt.cpp
+++ lib/AST/Stmt.cpp
@@ -533,15 +533,17 @@
   DiagOffs = CurPtr-StrStart-1;
   return diag::err_asm_invalid_escape;
 }
-
+// Handle escaped char and continue looping over the asm string.
 char EscapedChar = *CurPtr++;
-if (EscapedChar == '%') {  // %% -> %
-  // Escaped percentage sign.
-  CurStringPiece += '%';
+switch (EscapedChar) {
+default:
+  break;
+case '%': // %% -> %
+case '{': // %{ -> {
+case '}': // %} -> }
+  CurStringPiece += EscapedChar;
   continue;
-}
-
-if (EscapedChar == '=') {  // %= -> Generate an unique ID.
+case '=': // %= -> Generate a unique ID.
   CurStringPiece += "${:uid}";
   continue;
 }
Index: test/CodeGen/x86_inlineasm_curly_bracket_escape.c
===
--- test/CodeGen/x86_inlineasm_curly_bracket_escape.c
+++ test/CodeGen/x86_inlineasm_curly_bracket_escape.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -target-cpu skylake-avx512 -O0  -S -emit-llvm -o - -Wall 
-Werror | FileCheck %s
+// This test checks validity of inline assembly using curly brackets syntax
+// for extended inline asm.
+
+void test_curly_brackets() {
+//CHECK:  %xmm1,%xmm0,%xmm1 {%k1}{z}
+asm("vpaddb\t %%xmm1,%%xmm0,%%xmm1 %{%%k1%}%{z%}\t":::);
+}
\ No newline at end of file


Index: lib/AST/Stmt.cpp
===
--- lib/AST/Stmt.cpp
+++ lib/AST/Stmt.cpp
@@ -533,15 +533,17 @@
   DiagOffs = CurPtr-StrStart-1;
   return diag::err_asm_invalid_escape;
 }
-
+// Handle escaped char and continue looping over the asm string.
 char EscapedChar = *CurPtr++;
-if (EscapedChar == '%') {  // %% -> %
-  // Escaped percentage sign.
-  CurStringPiece += '%';
+switch (EscapedChar) {
+default:
+  break;
+case '%': // %% -> %
+case '{': // %{ -> {
+case '}': // %} -> }
+  CurStringPiece += EscapedChar;
   continue;
-}
-
-if (EscapedChar == '=') {  // %= -> Generate an unique ID.
+case '=': // %= -> Generate a unique ID.
   CurStringPiece += "${:uid}";
   continue;
 }
Index: test/CodeGen/x86_inlineasm_curly_bracket_escape.c
===
--- test/CodeGen/x86_inlineasm_curly_bracket_escape.c
+++ test/CodeGen/x86_inlineasm_curly_bracket_escape.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -target-cpu skylake-avx512 -O0  -S -emit-llvm -o - -Wall -Werror | FileCheck %s
+// This test checks validity of inline assembly using curly brackets syntax
+// for extended inline asm.
+
+void test_curly_brackets() {
+//CHECK:  %xmm1,%xmm0,%xmm1 {%k1}{z}
+asm("vpaddb\t %%xmm1,%%xmm0,%%xmm1 %{%%k1%}%{z%}\t":::);
+}
\ No newline at end of file
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25011: [x86][inline-asm] Introducing (AVX512) k0-k7 registers for inline-asm usage

2016-10-05 Thread Matan via cfe-commits
mharoush added a comment.

This patch is a part of a larger support for k constraints, its main purpose is 
to add the option to choose the specific kN register while using basic inline 
assembly, the constraint support for extended inline assembly is being 
supported by another patch D25062    D25063 



Repository:
  rL LLVM

https://reviews.llvm.org/D25011



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


[PATCH] D25012: [x86][inline-asm] Add support for curly brackets escape using "%" in extended inline asm.

2016-10-05 Thread Matan via cfe-commits
mharoush marked an inline comment as done.
mharoush added a comment.

Done


Repository:
  rL LLVM

https://reviews.llvm.org/D25012



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


r283314 - [Clang][AVX512][BuiltIn]Adding missing intrinsics move_{sd|ss} to clang

2016-10-05 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Wed Oct  5 07:56:06 2016
New Revision: 283314

URL: http://llvm.org/viewvc/llvm-project?rev=283314&view=rev
Log:
[Clang][AVX512][BuiltIn]Adding missing intrinsics move_{sd|ss} to clang

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


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=283314&r1=283313&r2=283314&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Oct  5 07:56:06 2016
@@ -2021,6 +2021,8 @@ TARGET_BUILTIN(__builtin_ia32_expandload
 TARGET_BUILTIN(__builtin_ia32_expandsf512_mask, "V16fV16fV16fUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_expandsi512_mask, "V16iV16iV16iUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_cvtps2pd512_mask, "V8dV8fV8dUcIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_movss_mask, "V4fV4fV4fV4fUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_movsd_mask, "V2dV2dV2dV2dUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_compressstoredf512_mask, 
"vV8d*V8dUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_compressstoredi512_mask, 
"vV8LLi*V8LLiUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_compressstoresf512_mask, 
"vV16f*V16fUs","","avx512f")

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=283314&r1=283313&r2=283314&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Wed Oct  5 07:56:06 2016
@@ -9140,6 +9140,40 @@ _mm512_maskz_moveldup_ps (__mmask16 __U,
  (__v16sf)_mm512_setzero_ps());
 }
 
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_mask_move_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
+{
+  return (__m128) __builtin_ia32_movss_mask ((__v4sf) __A, (__v4sf) __B,
+   (__v4sf) __W,
+   (__mmask8) __U);
+}
+
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_maskz_move_ss (__mmask8 __U, __m128 __A, __m128 __B)
+{
+  return (__m128) __builtin_ia32_movss_mask ((__v4sf) __A, (__v4sf) __B,
+   (__v4sf)
+   _mm_setzero_si128(),
+   (__mmask8) __U);
+}
+
+static __inline__ __m128d __DEFAULT_FN_ATTRS
+_mm_mask_move_sd (__m128d __W, __mmask8 __U, __m128d __A, __m128d __B)
+{
+  return (__m128d) __builtin_ia32_movsd_mask ((__v2df) __A, (__v2df) __B,
+   (__v2df) __W,
+   (__mmask8) __U);
+}
+
+static __inline__ __m128d __DEFAULT_FN_ATTRS
+_mm_maskz_move_sd (__mmask8 __U, __m128d __A, __m128d __B)
+{
+  return (__m128d) __builtin_ia32_movsd_mask ((__v2df) __A, (__v2df) __B,
+   (__v2df)
+   _mm_setzero_pd (),
+   (__mmask8) __U);
+}
+
 #define _mm512_shuffle_epi32(A, I) __extension__ ({ \
   (__m512i)__builtin_shufflevector((__v16si)(__m512i)(A), \
(__v16si)_mm512_undefined_epi32(), \

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=283314&r1=283313&r2=283314&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Wed Oct  5 07:56:06 2016
@@ -7863,6 +7863,34 @@ __m512d test_mm512_setzero_pd()
   return _mm512_setzero_pd();
 }
 
+__m128 test_mm_mask_move_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
+{
+  // CHECK-LABEL: @test_mm_mask_move_ss
+  // CHECK: @llvm.x86.avx512.mask.move.ss
+  return _mm_mask_move_ss ( __W,  __U,  __A,  __B);
+}
+
+__m128 test_mm_maskz_move_ss (__mmask8 __U, __m128 __A, __m128 __B)
+{
+  // CHECK-LABEL: @test_mm_maskz_move_ss
+  // CHECK: @llvm.x86.avx512.mask.move.ss
+  return _mm_maskz_move_ss (__U, __A, __B);
+}
+
+__m128d test_mm_mask_move_sd (__m128 __W, __mmask8 __U, __m128d __A, __m128d 
__B)
+{
+  // CHECK-LABEL: @test_mm_mask_move_sd
+  // CHECK: @llvm.x86.avx512.mask.move.sd
+  return _mm_mask_move_sd ( __W,  __U,  __A,  __B);
+}
+
+__m128d test_mm_maskz_move_sd (__mmask8 __U, __m128d __A, __m128d __B)
+{
+  // CHECK-LABEL: @test_mm_maskz_move_sd
+  // CHECK: @llvm.x86.avx512.mask.move.sd
+  return _mm_maskz_move_sd (__U, __A, __B);
+}
+
 __m512d test_mm512_abs_pd(__m512d a){
   // CHECK-LABEL: @test_mm512_abs_pd
   // CHECK: and <8 x i64> 


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


[PATCH] D21021: [Clang][AVX512][BuiltIn]Adding intrinsics move_{sd|ss} to clang

2016-10-05 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283314: [Clang][AVX512][BuiltIn]Adding missing intrinsics 
move_{sd|ss} to clang (authored by mzuckerm).

Changed prior to commit:
  https://reviews.llvm.org/D21021?vs=59720&id=73638#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21021

Files:
  cfe/trunk/include/clang/Basic/BuiltinsX86.def
  cfe/trunk/lib/Headers/avx512fintrin.h
  cfe/trunk/test/CodeGen/avx512f-builtins.c


Index: cfe/trunk/include/clang/Basic/BuiltinsX86.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def
@@ -2021,6 +2021,8 @@
 TARGET_BUILTIN(__builtin_ia32_expandsf512_mask, "V16fV16fV16fUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_expandsi512_mask, "V16iV16iV16iUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_cvtps2pd512_mask, "V8dV8fV8dUcIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_movss_mask, "V4fV4fV4fV4fUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_movsd_mask, "V2dV2dV2dV2dUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_compressstoredf512_mask, 
"vV8d*V8dUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_compressstoredi512_mask, 
"vV8LLi*V8LLiUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_compressstoresf512_mask, 
"vV16f*V16fUs","","avx512f")
Index: cfe/trunk/test/CodeGen/avx512f-builtins.c
===
--- cfe/trunk/test/CodeGen/avx512f-builtins.c
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c
@@ -7863,6 +7863,34 @@
   return _mm512_setzero_pd();
 }
 
+__m128 test_mm_mask_move_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
+{
+  // CHECK-LABEL: @test_mm_mask_move_ss
+  // CHECK: @llvm.x86.avx512.mask.move.ss
+  return _mm_mask_move_ss ( __W,  __U,  __A,  __B);
+}
+
+__m128 test_mm_maskz_move_ss (__mmask8 __U, __m128 __A, __m128 __B)
+{
+  // CHECK-LABEL: @test_mm_maskz_move_ss
+  // CHECK: @llvm.x86.avx512.mask.move.ss
+  return _mm_maskz_move_ss (__U, __A, __B);
+}
+
+__m128d test_mm_mask_move_sd (__m128 __W, __mmask8 __U, __m128d __A, __m128d 
__B)
+{
+  // CHECK-LABEL: @test_mm_mask_move_sd
+  // CHECK: @llvm.x86.avx512.mask.move.sd
+  return _mm_mask_move_sd ( __W,  __U,  __A,  __B);
+}
+
+__m128d test_mm_maskz_move_sd (__mmask8 __U, __m128d __A, __m128d __B)
+{
+  // CHECK-LABEL: @test_mm_maskz_move_sd
+  // CHECK: @llvm.x86.avx512.mask.move.sd
+  return _mm_maskz_move_sd (__U, __A, __B);
+}
+
 __m512d test_mm512_abs_pd(__m512d a){
   // CHECK-LABEL: @test_mm512_abs_pd
   // CHECK: and <8 x i64> 
Index: cfe/trunk/lib/Headers/avx512fintrin.h
===
--- cfe/trunk/lib/Headers/avx512fintrin.h
+++ cfe/trunk/lib/Headers/avx512fintrin.h
@@ -9140,6 +9140,40 @@
  (__v16sf)_mm512_setzero_ps());
 }
 
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_mask_move_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
+{
+  return (__m128) __builtin_ia32_movss_mask ((__v4sf) __A, (__v4sf) __B,
+   (__v4sf) __W,
+   (__mmask8) __U);
+}
+
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_maskz_move_ss (__mmask8 __U, __m128 __A, __m128 __B)
+{
+  return (__m128) __builtin_ia32_movss_mask ((__v4sf) __A, (__v4sf) __B,
+   (__v4sf)
+   _mm_setzero_si128(),
+   (__mmask8) __U);
+}
+
+static __inline__ __m128d __DEFAULT_FN_ATTRS
+_mm_mask_move_sd (__m128d __W, __mmask8 __U, __m128d __A, __m128d __B)
+{
+  return (__m128d) __builtin_ia32_movsd_mask ((__v2df) __A, (__v2df) __B,
+   (__v2df) __W,
+   (__mmask8) __U);
+}
+
+static __inline__ __m128d __DEFAULT_FN_ATTRS
+_mm_maskz_move_sd (__mmask8 __U, __m128d __A, __m128d __B)
+{
+  return (__m128d) __builtin_ia32_movsd_mask ((__v2df) __A, (__v2df) __B,
+   (__v2df)
+   _mm_setzero_pd (),
+   (__mmask8) __U);
+}
+
 #define _mm512_shuffle_epi32(A, I) __extension__ ({ \
   (__m512i)__builtin_shufflevector((__v16si)(__m512i)(A), \
(__v16si)_mm512_undefined_epi32(), \


Index: cfe/trunk/include/clang/Basic/BuiltinsX86.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def
@@ -2021,6 +2021,8 @@
 TARGET_BUILTIN(__builtin_ia32_expandsf512_mask, "V16fV16fV16fUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_expandsi512_mask, "V16iV16iV16iUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_cvtps2pd512_mask, "V8dV8fV8dUcIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_movss_mask, "V4fV4fV4fV4fUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_movsd_mask, "V2dV2dV2dV2dUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_compressstoredf512_mask, "vV8d*V8dUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_compressstoredi512_mask, "vV8LLi*V8LLiUc","","avx512f")
 TARGET_BUI

[PATCH] D19586: Misleading Indentation check

2016-10-05 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added inline comments.


> MisleadingIndentationCheck.cpp:20
> +
> +void MisleadingIndentationCheck::danglingElseCheck(
> +const MatchFinder::MatchResult &Result) {

There is no handling of tabs and spaces by danglingElseCheck as far as I see.

The "if" might for example be indented with spaces. And then the corresponding 
"else" is indented with a tab. Then I guess there is false positive.

If the "if" is indented with 2 spaces and the "else" is indented with 2 tabs. 
then I assume there is false negative.

It's unfortunate. Is it ok?

> MisleadingIndentationCheck.cpp:34
> +  Result.SourceManager->getExpansionColumnNumber(ElseLoc))
> +diag(ElseLoc, "potential dangling else");
> +}

I see no test case that says "potential dangling else". If I'm not mistaken 
that should be added.

Is it really sufficient to write that? It's not obvious to me why clang-tidy 
would think it's dangling.

> MisleadingIndentationCheck.cpp:44
> +
> +if (isa(CurrentStmt)) {
> +  IfStmt *CurrentIf = dyn_cast(CurrentStmt);

You don't need to use both isa and dyn_cast:

  if (const auto *CurrentIf = dyn_cast(CurrentStmt)) {
  Inside = CurrentIf->getElse() ? CurrentIf->getElse() : 
CurrentIf->getThen();
  } 

> MisleadingIndentationCheck.h:20
> +/// Checks the code for dangling else,
> +///   and possible misleading indentations due to missing braces.
> +///

there are too many spaces in this comment

https://reviews.llvm.org/D19586



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


[PATCH] D25252: [OpenMP] Check if the template specialization is mappable instead of specialized template

2016-10-05 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D25252



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


[PATCH] D25204: Register Calling Convention, Clang changes

2016-10-05 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


> Type.h:1381
>  /// regparm and the calling convention.
> -unsigned ExtInfo : 9;
> +unsigned ExtInfo : 10;
>  

Erich, do you really need this? You don't increase number of required bits 
anymore, so this code must be restored

> Type.h:2909-2921
> +// Feel free to rearrange or add bits, but if you go over 10,
>  // you'll need to adjust both the Bits field below and
>  // Type::FunctionTypeBitfields.
>  
>  //   |  CC  |noreturn|produces|regparm|
> -//   |0 .. 3|   4|5   | 6 .. 8|
> +//   |0 .. 4|   5|6   | 7 .. 9|
>  //

Also, you don't need these changes anymore

> MicrosoftMangle.cpp:434
> +
> +  if (auto FD = dyn_cast(D))
> +if (FD->getType()->castAs()->getCallConv() ==

`auto*`

> CodeGenModule.cpp:686
>  assert(II && "Attempt to mangle unnamed decl.");
> -Str = II->getName();
> +const FunctionDecl *FD = dyn_cast(ND);
> +

`const auto *FD`

> ABataev wrote in TargetInfo.cpp:1546-1548
> Seems to me this code is clang-formatted

I mean, did you try to reformat the whole `return` statement? It looks ugly

> rnk wrote in TargetInfo.cpp:3321
> variable naming

I believe the whole patch must be `clang-tide`d

https://reviews.llvm.org/D25204



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


[PATCH] D25162: Make DeletedLines local variables in checkEmptyNamespace.

2016-10-05 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 73641.
ioeric added a comment.

- Added a test case.


https://reviews.llvm.org/D25162

Files:
  lib/Format/Format.cpp
  unittests/Format/CleanupTest.cpp


Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -119,6 +119,24 @@
   EXPECT_EQ(Expected, Result);
 }
 
+TEST_F(CleanupTest, EmptyNamespaceAroundConditionalCompilation) {
+  std::string Code = "#ifdef A\n"
+ "int a;\n"
+ "int b;\n"
+ "#else\n"
+ "#endif\n"
+ "namespace {}";
+  std::string Expected = "#ifdef A\n"
+ "int a;\n"
+ "int b;\n"
+ "#else\n"
+ "#endif\n";
+  std::vector Ranges(1, tooling::Range(0, Code.size()));
+  FormatStyle Style = getLLVMStyle();
+  std::string Result = cleanup(Code, Ranges, Style);
+  EXPECT_EQ(Expected, Result);
+}
+
 TEST_F(CleanupTest, CtorInitializationSimpleRedundantComma) {
   std::string Code = "class A {\nA() : , {} };";
   std::string Expected = "class A {\nA()  {} };";
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1041,11 +1041,12 @@
 
   // Iterate through all lines and remove any empty (nested) namespaces.
   void checkEmptyNamespace(SmallVectorImpl &AnnotatedLines) {
+std::set DeletedLines;
 for (unsigned i = 0, e = AnnotatedLines.size(); i != e; ++i) {
   auto &Line = *AnnotatedLines[i];
   if (Line.startsWith(tok::kw_namespace) ||
   Line.startsWith(tok::kw_inline, tok::kw_namespace)) {
-checkEmptyNamespace(AnnotatedLines, i, i);
+checkEmptyNamespace(AnnotatedLines, i, i, DeletedLines);
   }
 }
 
@@ -1063,7 +1064,8 @@
   // sets \p NewLine to the last line checked.
   // Returns true if the current namespace is empty.
   bool checkEmptyNamespace(SmallVectorImpl &AnnotatedLines,
-   unsigned CurrentLine, unsigned &NewLine) {
+   unsigned CurrentLine, unsigned &NewLine,
+   std::set &DeletedLines) {
 unsigned InitLine = CurrentLine, End = AnnotatedLines.size();
 if (Style.BraceWrapping.AfterNamespace) {
   // If the left brace is in a new line, we should consume it first so that
@@ -1083,7 +1085,8 @@
   if (AnnotatedLines[CurrentLine]->startsWith(tok::kw_namespace) ||
   AnnotatedLines[CurrentLine]->startsWith(tok::kw_inline,
   tok::kw_namespace)) {
-if (!checkEmptyNamespace(AnnotatedLines, CurrentLine, NewLine))
+if (!checkEmptyNamespace(AnnotatedLines, CurrentLine, NewLine,
+ DeletedLines))
   return false;
 CurrentLine = NewLine;
 continue;
@@ -1208,8 +1211,6 @@
 
   // Tokens to be deleted.
   std::set DeletedTokens;
-  // The line numbers of lines to be deleted.
-  std::set DeletedLines;
 };
 
 struct IncludeDirective {


Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -119,6 +119,24 @@
   EXPECT_EQ(Expected, Result);
 }
 
+TEST_F(CleanupTest, EmptyNamespaceAroundConditionalCompilation) {
+  std::string Code = "#ifdef A\n"
+ "int a;\n"
+ "int b;\n"
+ "#else\n"
+ "#endif\n"
+ "namespace {}";
+  std::string Expected = "#ifdef A\n"
+ "int a;\n"
+ "int b;\n"
+ "#else\n"
+ "#endif\n";
+  std::vector Ranges(1, tooling::Range(0, Code.size()));
+  FormatStyle Style = getLLVMStyle();
+  std::string Result = cleanup(Code, Ranges, Style);
+  EXPECT_EQ(Expected, Result);
+}
+
 TEST_F(CleanupTest, CtorInitializationSimpleRedundantComma) {
   std::string Code = "class A {\nA() : , {} };";
   std::string Expected = "class A {\nA()  {} };";
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1041,11 +1041,12 @@
 
   // Iterate through all lines and remove any empty (nested) namespaces.
   void checkEmptyNamespace(SmallVectorImpl &AnnotatedLines) {
+std::set DeletedLines;
 for (unsigned i = 0, e = AnnotatedLines.size(); i != e; ++i) {
   auto &Line = *AnnotatedLines[i];
   if (Line.startsWith(tok::kw_namespace) ||
   Line.startsWith(tok::kw_inline, tok::kw_namespace)) {
-checkEmptyNamespace(AnnotatedLines, i, i);
+checkEmptyNamespace(AnnotatedLines, i, i, DeletedLines);
   }
 }
 
@@ -1063,7 +1064,8 @@
   // sets \p NewLine 

[PATCH] D24085: arm: Fix ttype encoding assertion failure.

2016-10-05 Thread Marshall Clow via cfe-commits
mclow.lists added inline comments.


> cxa_personality.cpp:363
> +   "Unexpected TTypeEncoding");
>  (void)ttypeEncoding;
>  

It's not clear to me how this accomplishes what you want.
You're looking for `00/10/90`, right?  Why not just check for that?

Why are you anding with 0x0f ?
Before, this would pass only a single value - `DW_EH_PE_absptr` (aka 0)
With this change, it passes 32 values: 00, 03, 10, 13, 20, 23, and so on.

Was that your intent?

https://reviews.llvm.org/D24085



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


[PATCH] D24012: Fix strict-aliasing violation in typeinfo::hash_code()

2016-10-05 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

Adding a reference here: https://llvm.org/bugs/show_bug.cgi?id=30613


https://reviews.llvm.org/D24012



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


[PATCH] D24669: {Sema] Gcc compatibility of vector shift.

2016-10-05 Thread Vladimir Yakovlev via cfe-commits
vbyakovlcl updated this revision to Diff 73642.

https://reviews.llvm.org/D24669

Files:
  llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
  llvm/tools/clang/lib/Sema/SemaExpr.cpp
  llvm/tools/clang/test/CodeGen/vecshift.c
  llvm/tools/clang/test/Sema/vecshift.c


Index: llvm/tools/clang/lib/Sema/SemaExpr.cpp
===
--- llvm/tools/clang/lib/Sema/SemaExpr.cpp
+++ llvm/tools/clang/lib/Sema/SemaExpr.cpp
@@ -8784,6 +8784,20 @@
 << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
   return QualType();
 }
+if (!S.LangOpts.OpenCL && !S.LangOpts.ZVector) {
+  const BuiltinType *LHSBT = LHSEleType->getAs();
+  const BuiltinType *RHSBT = RHSEleType->getAs();
+  if (LHSBT != RHSBT &&
+  S.Context.getTypeSize(LHSBT) != S.Context.getTypeSize(RHSBT)) {
+S.Diag(Loc, diag::warn_typecheck_vector_element_sizes_not_equal)
+<< LHS.get()->getType() << RHS.get()->getType()
+<< LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+if (S.Diags.getDiagnosticLevel(
+diag::warn_typecheck_vector_element_sizes_not_equal, Loc) ==
+DiagnosticsEngine::Level::Error)
+  return QualType();
+  }
+}
   } else {
 // ...else expand RHS to match the number of elements in LHS.
 QualType VecTy =
Index: llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2301,6 +2301,9 @@
   "cannot convert between vector and non-scalar values (%0 and %1)">;
 def err_typecheck_vector_lengths_not_equal : Error<
   "vector operands do not have the same number of elements (%0 and %1)">;
+def warn_typecheck_vector_element_sizes_not_equal : Warning<
+  "vector operands do not have the same elements sizes (%0 and %1)">,
+  InGroup>, DefaultError;
 def err_ext_vector_component_exceeds_length : Error<
   "vector component access exceeds type %0">;
 def err_ext_vector_component_name_illegal : Error<
Index: llvm/tools/clang/test/CodeGen/vecshift.c
===
--- llvm/tools/clang/test/CodeGen/vecshift.c
+++ llvm/tools/clang/test/CodeGen/vecshift.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1  -Wno-error-gnu-vec-elem-size -emit-llvm %s -o - | 
FileCheck %s
 
 typedef __attribute__((__ext_vector_type__(8))) char vector_char8;
 typedef __attribute__((__ext_vector_type__(8))) short vector_short8;
Index: llvm/tools/clang/test/Sema/vecshift.c
===
--- llvm/tools/clang/test/Sema/vecshift.c
+++ llvm/tools/clang/test/Sema/vecshift.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -DERR -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-error-gnu-vec-elem-size -verify %s
 
 typedef __attribute__((__ext_vector_type__(8))) char vector_char8;
 typedef __attribute__((__ext_vector_type__(8))) short vector_short8;
@@ -48,16 +49,30 @@
   vus8 = 1 << vus8;
 
   vc8 = vc8 << vc8;
-  vi8 = vi8 << vuc8;
-  vuc8 = vuc8 << vi8;
-  vus8 = vus8 << vui8;
-  vui8 = vui8 << vs8;
+#ifdef ERR
+  vi8 = vi8 << vuc8; // expected-error {{vector operands do not have the same 
elements sizes}}
+  vuc8 = vuc8 << vi8; // expected-error {{vector operands do not have the same 
elements sizes}}
+  vus8 = vus8 << vui8; // expected-error {{vector operands do not have the 
same elements sizes}}
+  vui8 = vui8 << vs8; // expected-error {{vector operands do not have the same 
elements sizes}}
+#else
+  vi8 = vi8 << vuc8; // expected-warning {{vector operands do not have the 
same elements sizes}}
+  vuc8 = vuc8 << vi8; // expected-warning {{vector operands do not have the 
same elements sizes}}
+  vus8 = vus8 << vui8; // expected-warning {{vector operands do not have the 
same elements sizes}}
+  vui8 = vui8 << vs8; // expected-warning {{vector operands do not have the 
same elements sizes}}
+#endif
 
   vc8 <<= vc8;
-  vi8 <<= vuc8;
-  vuc8 <<= vi8;
-  vus8 <<= vui8;
-  vui8 <<= vs8;
+#ifdef ERR
+  vi8 <<= vuc8; // expected-error {{vector operands do not have the same 
elements sizes}}
+  vuc8 <<= vi8; // expected-error {{vector operands do not have the same 
elements sizes}}
+  vus8 <<= vui8; // expected-error {{vector operands do not have the same 
elements sizes}}
+  vui8 <<= vs8; // expected-error {{vector operands do not have the same 
elements sizes}}
+#else
+  vi8 <<= vuc8; // expected-warning {{vector operands do not have the same 
elements sizes}}
+  vuc8 <<= vi8; // expected-warning {{vector operands do not have the same 
elements sizes}}
+  vus8 <<= vui8; // expected-warning {{vector operands do not have the same 
elements sizes}}
+  vui8 <<= vs8; // expected-warning {{vector ope

[PATCH] D24669: {Sema] Gcc compatibility of vector shift.

2016-10-05 Thread Vladimir Yakovlev via cfe-commits
vbyakovlcl added inline comments.


> ahatanak wrote in SemaExpr.cpp:8787
> Is it possible to use ASTContext::getTypeSize here?

You are right.

https://reviews.llvm.org/D24669



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


[PATCH] D21026: [clang-format] append newline after code when inserting new headers at the end of the code which does not end with newline.

2016-10-05 Thread Eric Liu via cfe-commits
ioeric added a comment.

Sorry for the delay

I've updated the patch to work with the new tooling::Replacements.


https://reviews.llvm.org/D21026



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


[PATCH] D21026: [clang-format] append newline after code when inserting new headers at the end of the code which does not end with newline.

2016-10-05 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 73648.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- Merged with origin/master.
- Update newline insertion according to the new Replacements implementation.


https://reviews.llvm.org/D21026

Files:
  lib/Format/Format.cpp
  unittests/Format/CleanupTest.cpp


Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -709,16 +709,24 @@
   EXPECT_EQ(Expected, apply(Code, Replaces));
 }
 
-// FIXME: although this case does not crash, the insertion is wrong. A '\n'
-// should be inserted between the two #includes.
 TEST_F(CleanUpReplacementsTest, NoNewLineAtTheEndOfCode) {
   std::string Code = "#include ";
-  std::string Expected = "#include #include \n";
+  std::string Expected = "#include \n#include \n";
   tooling::Replacements Replaces =
   toReplacements({createInsertion("#include ")});
   EXPECT_EQ(Expected, apply(Code, Replaces));
 }
 
+TEST_F(CleanUpReplacementsTest, NoNewLineAtTheEndOfCodeMultipleInsertions) {
+  std::string Code = "#include ";
+  std::string Expected =
+  "#include \n#include \n#include \n";
+  tooling::Replacements Replaces =
+  toReplacements({createInsertion("#include "),
+  createInsertion("#include ")});
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
 TEST_F(CleanUpReplacementsTest, SkipExistingHeaders) {
   std::string Code = "#include \"a.h\"\n"
  "#include \n";
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1662,6 +1662,7 @@
 if (CategoryEndOffsets.find(*I) == CategoryEndOffsets.end())
   CategoryEndOffsets[*I] = CategoryEndOffsets[*std::prev(I)];
 
+  bool NeedNewLineAtEnd = !Code.empty() && Code.back() != '\n';
   for (const auto &R : HeaderInsertions) {
 auto IncludeDirective = R.getReplacementText();
 bool Matched = IncludeRegex.match(IncludeDirective, &Matches);
@@ -1680,10 +1681,18 @@
 std::string NewInclude = !IncludeDirective.endswith("\n")
  ? (IncludeDirective + "\n").str()
  : IncludeDirective.str();
+// When inserting headers at end of the code, also append '\n' to the code
+// if it does not end with '\n'.
+if (NeedNewLineAtEnd && Offset == Code.size()) {
+  NewInclude = "\n" + NewInclude;
+  NeedNewLineAtEnd = false;
+}
 auto NewReplace = tooling::Replacement(FileName, Offset, 0, NewInclude);
 auto Err = Result.add(NewReplace);
 if (Err) {
   llvm::consumeError(std::move(Err));
+  unsigned NewOffset = Result.getShiftedCodePosition(Offset);
+  NewReplace = tooling::Replacement(FileName, NewOffset, 0, NewInclude);
   Result = Result.merge(tooling::Replacements(NewReplace));
 }
   }


Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -709,16 +709,24 @@
   EXPECT_EQ(Expected, apply(Code, Replaces));
 }
 
-// FIXME: although this case does not crash, the insertion is wrong. A '\n'
-// should be inserted between the two #includes.
 TEST_F(CleanUpReplacementsTest, NoNewLineAtTheEndOfCode) {
   std::string Code = "#include ";
-  std::string Expected = "#include #include \n";
+  std::string Expected = "#include \n#include \n";
   tooling::Replacements Replaces =
   toReplacements({createInsertion("#include ")});
   EXPECT_EQ(Expected, apply(Code, Replaces));
 }
 
+TEST_F(CleanUpReplacementsTest, NoNewLineAtTheEndOfCodeMultipleInsertions) {
+  std::string Code = "#include ";
+  std::string Expected =
+  "#include \n#include \n#include \n";
+  tooling::Replacements Replaces =
+  toReplacements({createInsertion("#include "),
+  createInsertion("#include ")});
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
 TEST_F(CleanUpReplacementsTest, SkipExistingHeaders) {
   std::string Code = "#include \"a.h\"\n"
  "#include \n";
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1662,6 +1662,7 @@
 if (CategoryEndOffsets.find(*I) == CategoryEndOffsets.end())
   CategoryEndOffsets[*I] = CategoryEndOffsets[*std::prev(I)];
 
+  bool NeedNewLineAtEnd = !Code.empty() && Code.back() != '\n';
   for (const auto &R : HeaderInsertions) {
 auto IncludeDirective = R.getReplacementText();
 bool Matched = IncludeRegex.match(IncludeDirective, &Matches);
@@ -1680,10 +1681,18 @@
 std::string NewInclude = !IncludeDirective.endswith("\n")
  ? (IncludeDirective + "\n").str()
  : IncludeDirective.str();
+// When inserting headers at end of the code,

[PATCH] D21026: [clang-format] append newline after code when inserting new headers at the end of the code which does not end with newline.

2016-10-05 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.


https://reviews.llvm.org/D21026



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


[PATCH] D24644: Pass -ffunction-sections/-fdata-sections along to gold-plugin

2016-10-05 Thread Eric Christopher via cfe-commits
echristo added a comment.

There are two things pushing and pulling here:

a) You want to be able to pass compiler code generation options at the time 
we're actually doing the code generation,
b) "Traditionally" we don't pass CFLAGS to the linker.

I think I'd like to see us passing more options down at code generation time 
and handling it explicitly. In particular for this we don't have the knowledge 
at link time of what was intended. Even if we only turn it on when we see 
-gc-sections we won't know if the programmer wants function and data sections 
or just the former. Or maybe they want function sections for some reason other 
than gc-sections.

In short, I'm more on the a) side here in what I want :)

To go to PR22999: I think it might be reasonable for the linker during code 
generation to turn on function/data-sections where it isn't reasonable for us 
to do so in the compiler. I can come up with weird cases to break it, but those 
are largely module level inline assembly.


https://reviews.llvm.org/D24644



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


[PATCH] D25162: Make DeletedLines local variables in checkEmptyNamespace.

2016-10-05 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.


https://reviews.llvm.org/D25162



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


[PATCH] D24644: Pass -ffunction-sections/-fdata-sections along to gold-plugin

2016-10-05 Thread Mehdi AMINI via cfe-commits
mehdi_amini added a comment.

What about function attributes? Hey that's the trend :)
You could have a subset of the functions in their own sections but not all. 
With LTO it means that you can disable this for a single input file.


https://reviews.llvm.org/D24644



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


[libcxx] r283325 - Mark LWG issues 2221, 2556 and 2589 as complete

2016-10-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Oct  5 10:21:11 2016
New Revision: 283325

URL: http://llvm.org/viewvc/llvm-project?rev=283325&view=rev
Log:
Mark LWG issues 2221, 2556 and 2589 as complete

Modified:
libcxx/trunk/www/upcoming_meeting.html

Modified: libcxx/trunk/www/upcoming_meeting.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=283325&r1=283324&r2=283325&view=diff
==
--- libcxx/trunk/www/upcoming_meeting.html (original)
+++ libcxx/trunk/www/upcoming_meeting.html Wed Oct  5 10:21:11 2016
@@ -61,7 +61,7 @@
 
 http://wg21.link/LWG2062";>2062Effect 
contradictions w/o no-throw guarantee of std::function 
swapsIssaquah
 http://wg21.link/LWG2166";>2166Heap 
property underspecified?Issaquah
-http://wg21.link/LWG2221";>2221No 
formatted output operator for nullptrIssaquah
+http://wg21.link/LWG2221";>2221No 
formatted output operator for nullptrIssaquahPatch 
ready
 http://wg21.link/LWG2223";>2223shrink_to_fit effect on 
iterator validityIssaquah
 http://wg21.link/LWG2261";>2261Are 
containers required to use their 'pointer' type 
internally?Issaquah
 http://wg21.link/LWG2358";>2358Apparently-bogus definition of 
is_empty type traitIssaquah
@@ -79,14 +79,14 @@
 http://wg21.link/LWG2540";>2540unordered_multimap::insert 
hint iteratorIssaquah
 http://wg21.link/LWG2543";>2543LWG 2148 
(hash support for enum types) seems 
under-specifiedIssaquah
 http://wg21.link/LWG2544";>2544istreambuf_iterator(basic_streambuf* s) effects unclear when s is 0Issaquah
-http://wg21.link/LWG2556";>2556Wide 
contract for future::share()Issaquah
+http://wg21.link/LWG2556";>2556Wide 
contract for future::share()IssaquahPatch ready
 http://wg21.link/LWG2562";>2562Consistent 
total ordering of pointers by comparison 
functorsIssaquah
 http://wg21.link/LWG2567";>2567Specification of logical 
operator traits uses BaseCharacteristic, which is defined only for 
UnaryTypeTraits and BinaryTypeTraitsIssaquah
 http://wg21.link/LWG2569";>2569conjunction and disjunction 
requirements are too strictIssaquah
 http://wg21.link/LWG2570";>2570[fund.ts.v2] conjunction and 
disjunction requirements are too strictIssaquah
 http://wg21.link/LWG2578";>2578Iterator 
requirements should reference iterator traitsIssaquahNothing 
to do
 http://wg21.link/LWG2584";>2584 
ECMAScript IdentityEscape is ambiguousIssaquah
-http://wg21.link/LWG2589";>2589match_results can't satisfy 
the requirements of a containerIssaquah
+http://wg21.link/LWG2589";>2589match_results can't satisfy 
the requirements of a containerIssaquahNothing to do
 http://wg21.link/LWG2591";>2591std::function's member 
template target() should not lead to undefined 
behaviourIssaquah
 http://wg21.link/LWG2598";>2598addressof 
works on temporariesIssaquahPatch ready
 http://wg21.link/LWG2664";>2664operator/ 
(and other append) semantics not useful if argument has 
rootIssaquah
@@ -135,7 +135,7 @@
 
 2062 - 
 2166 - 
-2221 - 
+2221 - Patch and tests ready
 2223 - 
 2261 - 
 2358 - 
@@ -153,14 +153,14 @@
 2540 - 
 2543 - 
 2544 - 
-2556 - 
+2556 - Patch and tests ready
 2562 - 
 2567 - 
 2569 - 
 2570 - 
 2578 - This is just wording cleanup. 
 2584 - 
-2589 - 
+2589 - This is just wording cleanup. 
 2591 - 
 2598 - Patch and tests ready
 2664 - 
@@ -205,7 +205,7 @@
 2769 - 
 
 
-Last Updated: 4-Oct-2016
+Last Updated: 5-Oct-2016
 
 
 


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


[PATCH] D24644: Pass -ffunction-sections/-fdata-sections along to gold-plugin

2016-10-05 Thread Eric Christopher via cfe-commits
echristo added a comment.

In https://reviews.llvm.org/D24644#562286, @mehdi_amini wrote:

> What about function attributes? Hey that's the trend :)
>  You could have a subset of the functions in their own sections but not all. 
> With LTO it means that you can disable this for a single input file.


True, but we'd need data attributes too for -fdata-sections. That's the main 
reason I haven't migrated the options out of TargetOptions and into the IR 
here. Rough sketch on module merge time: We'd probably want to error on 
functions/data that had separate section set in one module but not in another - 
there are a few ways to make that not error at link time, but at that point 
you're really relying on weird linker side effects and it's probably not what 
you intended anyhow.

-eric


https://reviews.llvm.org/D24644



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


[PATCH] D25204: Register Calling Convention, Clang changes

2016-10-05 Thread Erich Keane via cfe-commits
erichkeane marked 9 inline comments as done.
erichkeane added inline comments.


> oren_ben_simhon wrote in AttrDocs.td:1267
> You might want to use the following link instead because it is most updated: 
> https://software.intel.com/en-us/node/693069

This has changed 2x since I started this project.  Is there a way to get a 
STABLE link?  I imagine that much of this documentation is filled with broken 
links (since MSDN breaks them constantly), but don't really want to add to it.

> oren_ben_simhon wrote in TargetInfo.cpp:3352
> According to the ABI, there are 12 free int regs for windows and 11 free int 
> regs for non-windows (linux, OSX, etc). Is that taken into account somewhere?

Yes.  There are separate ABIInfo types for windows.

> oren_ben_simhon wrote in TargetInfo.cpp:3732
> Maybe i misinterpret the comment, but AFAIK, RegCall gives us 16 SSE 
> registers for each (return values and passed arguments)

I'd misread that in the spec and Ried corrected my implementation below.  
Updating the comment.

> oren_ben_simhon wrote in regcall.c:26
> I see that expended structures don't get InReg attribute. IMHO, If you know 
> that the value should be saved in register then you InReg attribute should be 
> added.

I am not sure that is the case.  That behavior doesn't happen in vectorcall 
seemingly.

https://reviews.llvm.org/D25204



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


r283330 - [clang-format] append newline after code when inserting new headers at the end of the code which does not end with newline.

2016-10-05 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed Oct  5 10:42:19 2016
New Revision: 283330

URL: http://llvm.org/viewvc/llvm-project?rev=283330&view=rev
Log:
[clang-format] append newline after code when inserting new headers at the end 
of the code which does not end with newline.

Summary:
append newline after code when inserting new headers at the end of the
code which does not end with newline.

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/CleanupTest.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=283330&r1=283329&r2=283330&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed Oct  5 10:42:19 2016
@@ -1662,6 +1662,7 @@ fixCppIncludeInsertions(StringRef Code,
 if (CategoryEndOffsets.find(*I) == CategoryEndOffsets.end())
   CategoryEndOffsets[*I] = CategoryEndOffsets[*std::prev(I)];
 
+  bool NeedNewLineAtEnd = !Code.empty() && Code.back() != '\n';
   for (const auto &R : HeaderInsertions) {
 auto IncludeDirective = R.getReplacementText();
 bool Matched = IncludeRegex.match(IncludeDirective, &Matches);
@@ -1680,10 +1681,18 @@ fixCppIncludeInsertions(StringRef Code,
 std::string NewInclude = !IncludeDirective.endswith("\n")
  ? (IncludeDirective + "\n").str()
  : IncludeDirective.str();
+// When inserting headers at end of the code, also append '\n' to the code
+// if it does not end with '\n'.
+if (NeedNewLineAtEnd && Offset == Code.size()) {
+  NewInclude = "\n" + NewInclude;
+  NeedNewLineAtEnd = false;
+}
 auto NewReplace = tooling::Replacement(FileName, Offset, 0, NewInclude);
 auto Err = Result.add(NewReplace);
 if (Err) {
   llvm::consumeError(std::move(Err));
+  unsigned NewOffset = Result.getShiftedCodePosition(Offset);
+  NewReplace = tooling::Replacement(FileName, NewOffset, 0, NewInclude);
   Result = Result.merge(tooling::Replacements(NewReplace));
 }
   }

Modified: cfe/trunk/unittests/Format/CleanupTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/CleanupTest.cpp?rev=283330&r1=283329&r2=283330&view=diff
==
--- cfe/trunk/unittests/Format/CleanupTest.cpp (original)
+++ cfe/trunk/unittests/Format/CleanupTest.cpp Wed Oct  5 10:42:19 2016
@@ -709,16 +709,24 @@ TEST_F(CleanUpReplacementsTest, EmptyCod
   EXPECT_EQ(Expected, apply(Code, Replaces));
 }
 
-// FIXME: although this case does not crash, the insertion is wrong. A '\n'
-// should be inserted between the two #includes.
 TEST_F(CleanUpReplacementsTest, NoNewLineAtTheEndOfCode) {
   std::string Code = "#include ";
-  std::string Expected = "#include #include \n";
+  std::string Expected = "#include \n#include \n";
   tooling::Replacements Replaces =
   toReplacements({createInsertion("#include ")});
   EXPECT_EQ(Expected, apply(Code, Replaces));
 }
 
+TEST_F(CleanUpReplacementsTest, NoNewLineAtTheEndOfCodeMultipleInsertions) {
+  std::string Code = "#include ";
+  std::string Expected =
+  "#include \n#include \n#include \n";
+  tooling::Replacements Replaces =
+  toReplacements({createInsertion("#include "),
+  createInsertion("#include ")});
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
 TEST_F(CleanUpReplacementsTest, SkipExistingHeaders) {
   std::string Code = "#include \"a.h\"\n"
  "#include \n";


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


[PATCH] D21026: [clang-format] append newline after code when inserting new headers at the end of the code which does not end with newline.

2016-10-05 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283330: [clang-format] append newline after code when 
inserting new headers at the end… (authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D21026?vs=73648&id=73651#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21026

Files:
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/unittests/Format/CleanupTest.cpp


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -1662,6 +1662,7 @@
 if (CategoryEndOffsets.find(*I) == CategoryEndOffsets.end())
   CategoryEndOffsets[*I] = CategoryEndOffsets[*std::prev(I)];
 
+  bool NeedNewLineAtEnd = !Code.empty() && Code.back() != '\n';
   for (const auto &R : HeaderInsertions) {
 auto IncludeDirective = R.getReplacementText();
 bool Matched = IncludeRegex.match(IncludeDirective, &Matches);
@@ -1680,10 +1681,18 @@
 std::string NewInclude = !IncludeDirective.endswith("\n")
  ? (IncludeDirective + "\n").str()
  : IncludeDirective.str();
+// When inserting headers at end of the code, also append '\n' to the code
+// if it does not end with '\n'.
+if (NeedNewLineAtEnd && Offset == Code.size()) {
+  NewInclude = "\n" + NewInclude;
+  NeedNewLineAtEnd = false;
+}
 auto NewReplace = tooling::Replacement(FileName, Offset, 0, NewInclude);
 auto Err = Result.add(NewReplace);
 if (Err) {
   llvm::consumeError(std::move(Err));
+  unsigned NewOffset = Result.getShiftedCodePosition(Offset);
+  NewReplace = tooling::Replacement(FileName, NewOffset, 0, NewInclude);
   Result = Result.merge(tooling::Replacements(NewReplace));
 }
   }
Index: cfe/trunk/unittests/Format/CleanupTest.cpp
===
--- cfe/trunk/unittests/Format/CleanupTest.cpp
+++ cfe/trunk/unittests/Format/CleanupTest.cpp
@@ -709,16 +709,24 @@
   EXPECT_EQ(Expected, apply(Code, Replaces));
 }
 
-// FIXME: although this case does not crash, the insertion is wrong. A '\n'
-// should be inserted between the two #includes.
 TEST_F(CleanUpReplacementsTest, NoNewLineAtTheEndOfCode) {
   std::string Code = "#include ";
-  std::string Expected = "#include #include \n";
+  std::string Expected = "#include \n#include \n";
   tooling::Replacements Replaces =
   toReplacements({createInsertion("#include ")});
   EXPECT_EQ(Expected, apply(Code, Replaces));
 }
 
+TEST_F(CleanUpReplacementsTest, NoNewLineAtTheEndOfCodeMultipleInsertions) {
+  std::string Code = "#include ";
+  std::string Expected =
+  "#include \n#include \n#include \n";
+  tooling::Replacements Replaces =
+  toReplacements({createInsertion("#include "),
+  createInsertion("#include ")});
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
 TEST_F(CleanUpReplacementsTest, SkipExistingHeaders) {
   std::string Code = "#include \"a.h\"\n"
  "#include \n";


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -1662,6 +1662,7 @@
 if (CategoryEndOffsets.find(*I) == CategoryEndOffsets.end())
   CategoryEndOffsets[*I] = CategoryEndOffsets[*std::prev(I)];
 
+  bool NeedNewLineAtEnd = !Code.empty() && Code.back() != '\n';
   for (const auto &R : HeaderInsertions) {
 auto IncludeDirective = R.getReplacementText();
 bool Matched = IncludeRegex.match(IncludeDirective, &Matches);
@@ -1680,10 +1681,18 @@
 std::string NewInclude = !IncludeDirective.endswith("\n")
  ? (IncludeDirective + "\n").str()
  : IncludeDirective.str();
+// When inserting headers at end of the code, also append '\n' to the code
+// if it does not end with '\n'.
+if (NeedNewLineAtEnd && Offset == Code.size()) {
+  NewInclude = "\n" + NewInclude;
+  NeedNewLineAtEnd = false;
+}
 auto NewReplace = tooling::Replacement(FileName, Offset, 0, NewInclude);
 auto Err = Result.add(NewReplace);
 if (Err) {
   llvm::consumeError(std::move(Err));
+  unsigned NewOffset = Result.getShiftedCodePosition(Offset);
+  NewReplace = tooling::Replacement(FileName, NewOffset, 0, NewInclude);
   Result = Result.merge(tooling::Replacements(NewReplace));
 }
   }
Index: cfe/trunk/unittests/Format/CleanupTest.cpp
===
--- cfe/trunk/unittests/Format/CleanupTest.cpp
+++ cfe/trunk/unittests/Format/CleanupTest.cpp
@@ -709,16 +709,24 @@
   EXPECT_EQ(Expected, apply(Code, Replaces));
 }
 
-// FIXME: although this case does not crash, the insertion is wrong. A '\n'
-// should be inserted between the two #includes.
 TEST_F(CleanUpReplacem

[libcxx] r283331 - Add another append test for basic_string

2016-10-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Oct  5 10:47:13 2016
New Revision: 283331

URL: http://llvm.org/viewvc/llvm-project?rev=283331&view=rev
Log:
Add another append test for basic_string

Modified:

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp?rev=283331&r1=283330&r2=283331&view=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp
 Wed Oct  5 10:47:13 2016
@@ -164,6 +164,10 @@ int main()
 sv = s;
 s.append(sv, 0, std::string::npos);
 assert(s == "ABCDABCDABCDABCD");
+
+sv = s;
+s.append(sv, sv.size());
+assert(s == "ABCDABCDABCDABCD");
 }
 
 {


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


r283332 - Make DeletedLines local variables in checkEmptyNamespace.

2016-10-05 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed Oct  5 10:49:01 2016
New Revision: 283332

URL: http://llvm.org/viewvc/llvm-project?rev=283332&view=rev
Log:
Make DeletedLines local variables in checkEmptyNamespace.

Summary: Patch by Sam McCall!

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/CleanupTest.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=283332&r1=283331&r2=283332&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed Oct  5 10:49:01 2016
@@ -1041,11 +1041,12 @@ private:
 
   // Iterate through all lines and remove any empty (nested) namespaces.
   void checkEmptyNamespace(SmallVectorImpl &AnnotatedLines) {
+std::set DeletedLines;
 for (unsigned i = 0, e = AnnotatedLines.size(); i != e; ++i) {
   auto &Line = *AnnotatedLines[i];
   if (Line.startsWith(tok::kw_namespace) ||
   Line.startsWith(tok::kw_inline, tok::kw_namespace)) {
-checkEmptyNamespace(AnnotatedLines, i, i);
+checkEmptyNamespace(AnnotatedLines, i, i, DeletedLines);
   }
 }
 
@@ -1063,7 +1064,8 @@ private:
   // sets \p NewLine to the last line checked.
   // Returns true if the current namespace is empty.
   bool checkEmptyNamespace(SmallVectorImpl &AnnotatedLines,
-   unsigned CurrentLine, unsigned &NewLine) {
+   unsigned CurrentLine, unsigned &NewLine,
+   std::set &DeletedLines) {
 unsigned InitLine = CurrentLine, End = AnnotatedLines.size();
 if (Style.BraceWrapping.AfterNamespace) {
   // If the left brace is in a new line, we should consume it first so that
@@ -1083,7 +1085,8 @@ private:
   if (AnnotatedLines[CurrentLine]->startsWith(tok::kw_namespace) ||
   AnnotatedLines[CurrentLine]->startsWith(tok::kw_inline,
   tok::kw_namespace)) {
-if (!checkEmptyNamespace(AnnotatedLines, CurrentLine, NewLine))
+if (!checkEmptyNamespace(AnnotatedLines, CurrentLine, NewLine,
+ DeletedLines))
   return false;
 CurrentLine = NewLine;
 continue;
@@ -1208,8 +1211,6 @@ private:
 
   // Tokens to be deleted.
   std::set DeletedTokens;
-  // The line numbers of lines to be deleted.
-  std::set DeletedLines;
 };
 
 struct IncludeDirective {

Modified: cfe/trunk/unittests/Format/CleanupTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/CleanupTest.cpp?rev=283332&r1=283331&r2=283332&view=diff
==
--- cfe/trunk/unittests/Format/CleanupTest.cpp (original)
+++ cfe/trunk/unittests/Format/CleanupTest.cpp Wed Oct  5 10:49:01 2016
@@ -119,6 +119,24 @@ TEST_F(CleanupTest, EmptyNamespaceWithCo
   EXPECT_EQ(Expected, Result);
 }
 
+TEST_F(CleanupTest, EmptyNamespaceAroundConditionalCompilation) {
+  std::string Code = "#ifdef A\n"
+ "int a;\n"
+ "int b;\n"
+ "#else\n"
+ "#endif\n"
+ "namespace {}";
+  std::string Expected = "#ifdef A\n"
+ "int a;\n"
+ "int b;\n"
+ "#else\n"
+ "#endif\n";
+  std::vector Ranges(1, tooling::Range(0, Code.size()));
+  FormatStyle Style = getLLVMStyle();
+  std::string Result = cleanup(Code, Ranges, Style);
+  EXPECT_EQ(Expected, Result);
+}
+
 TEST_F(CleanupTest, CtorInitializationSimpleRedundantComma) {
   std::string Code = "class A {\nA() : , {} };";
   std::string Expected = "class A {\nA()  {} };";


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


[PATCH] D25162: Make DeletedLines local variables in checkEmptyNamespace.

2016-10-05 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283332: Make DeletedLines local variables in 
checkEmptyNamespace. (authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D25162?vs=73641&id=73652#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25162

Files:
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/unittests/Format/CleanupTest.cpp


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -1041,11 +1041,12 @@
 
   // Iterate through all lines and remove any empty (nested) namespaces.
   void checkEmptyNamespace(SmallVectorImpl &AnnotatedLines) {
+std::set DeletedLines;
 for (unsigned i = 0, e = AnnotatedLines.size(); i != e; ++i) {
   auto &Line = *AnnotatedLines[i];
   if (Line.startsWith(tok::kw_namespace) ||
   Line.startsWith(tok::kw_inline, tok::kw_namespace)) {
-checkEmptyNamespace(AnnotatedLines, i, i);
+checkEmptyNamespace(AnnotatedLines, i, i, DeletedLines);
   }
 }
 
@@ -1063,7 +1064,8 @@
   // sets \p NewLine to the last line checked.
   // Returns true if the current namespace is empty.
   bool checkEmptyNamespace(SmallVectorImpl &AnnotatedLines,
-   unsigned CurrentLine, unsigned &NewLine) {
+   unsigned CurrentLine, unsigned &NewLine,
+   std::set &DeletedLines) {
 unsigned InitLine = CurrentLine, End = AnnotatedLines.size();
 if (Style.BraceWrapping.AfterNamespace) {
   // If the left brace is in a new line, we should consume it first so that
@@ -1083,7 +1085,8 @@
   if (AnnotatedLines[CurrentLine]->startsWith(tok::kw_namespace) ||
   AnnotatedLines[CurrentLine]->startsWith(tok::kw_inline,
   tok::kw_namespace)) {
-if (!checkEmptyNamespace(AnnotatedLines, CurrentLine, NewLine))
+if (!checkEmptyNamespace(AnnotatedLines, CurrentLine, NewLine,
+ DeletedLines))
   return false;
 CurrentLine = NewLine;
 continue;
@@ -1208,8 +1211,6 @@
 
   // Tokens to be deleted.
   std::set DeletedTokens;
-  // The line numbers of lines to be deleted.
-  std::set DeletedLines;
 };
 
 struct IncludeDirective {
Index: cfe/trunk/unittests/Format/CleanupTest.cpp
===
--- cfe/trunk/unittests/Format/CleanupTest.cpp
+++ cfe/trunk/unittests/Format/CleanupTest.cpp
@@ -119,6 +119,24 @@
   EXPECT_EQ(Expected, Result);
 }
 
+TEST_F(CleanupTest, EmptyNamespaceAroundConditionalCompilation) {
+  std::string Code = "#ifdef A\n"
+ "int a;\n"
+ "int b;\n"
+ "#else\n"
+ "#endif\n"
+ "namespace {}";
+  std::string Expected = "#ifdef A\n"
+ "int a;\n"
+ "int b;\n"
+ "#else\n"
+ "#endif\n";
+  std::vector Ranges(1, tooling::Range(0, Code.size()));
+  FormatStyle Style = getLLVMStyle();
+  std::string Result = cleanup(Code, Ranges, Style);
+  EXPECT_EQ(Expected, Result);
+}
+
 TEST_F(CleanupTest, CtorInitializationSimpleRedundantComma) {
   std::string Code = "class A {\nA() : , {} };";
   std::string Expected = "class A {\nA()  {} };";


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -1041,11 +1041,12 @@
 
   // Iterate through all lines and remove any empty (nested) namespaces.
   void checkEmptyNamespace(SmallVectorImpl &AnnotatedLines) {
+std::set DeletedLines;
 for (unsigned i = 0, e = AnnotatedLines.size(); i != e; ++i) {
   auto &Line = *AnnotatedLines[i];
   if (Line.startsWith(tok::kw_namespace) ||
   Line.startsWith(tok::kw_inline, tok::kw_namespace)) {
-checkEmptyNamespace(AnnotatedLines, i, i);
+checkEmptyNamespace(AnnotatedLines, i, i, DeletedLines);
   }
 }
 
@@ -1063,7 +1064,8 @@
   // sets \p NewLine to the last line checked.
   // Returns true if the current namespace is empty.
   bool checkEmptyNamespace(SmallVectorImpl &AnnotatedLines,
-   unsigned CurrentLine, unsigned &NewLine) {
+   unsigned CurrentLine, unsigned &NewLine,
+   std::set &DeletedLines) {
 unsigned InitLine = CurrentLine, End = AnnotatedLines.size();
 if (Style.BraceWrapping.AfterNamespace) {
   // If the left brace is in a new line, we should consume it first so that
@@ -1083,7 +1085,8 @@
   if (AnnotatedLines[CurrentLine]->startsWith(tok::kw_namespace) ||
   AnnotatedLines[CurrentLine]->startsWith(tok::kw_inline,
   t

[clang-tools-extra] r283333 - [change-namespace] Fixed a bug in getShortestQualifiedNameInNamespace.

2016-10-05 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed Oct  5 10:52:39 2016
New Revision: 28

URL: http://llvm.org/viewvc/llvm-project?rev=28&view=rev
Log:
[change-namespace] Fixed a bug in getShortestQualifiedNameInNamespace.

Reviewers: hokein

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=28&r1=283332&r2=28&view=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Wed Oct  5 
10:52:39 2016
@@ -173,21 +173,24 @@ tooling::Replacement createInsertion(Sou
 // Returns the shortest qualified name for declaration `DeclName` in the
 // namespace `NsName`. For example, if `DeclName` is "a::b::X" and `NsName`
 // is "a::c::d", then "b::X" will be returned.
+// \param DeclName A fully qualified name, "::a::b::X" or "a::b::X".
+// \param NsName A fully qualified name, "::a::b" or "a::b". Global namespace
+//will have empty name.
 std::string getShortestQualifiedNameInNamespace(llvm::StringRef DeclName,
 llvm::StringRef NsName) {
-  llvm::SmallVector DeclNameSplitted;
-  DeclName.split(DeclNameSplitted, "::");
-  if (DeclNameSplitted.size() == 1)
-return DeclName;
-  const auto UnqualifiedName = DeclNameSplitted.back();
-  while (true) {
+  DeclName = DeclName.ltrim(':');
+  NsName = NsName.ltrim(':');
+  // If `DeclName` is a global variable, we prepend "::" to it if it is not in
+  // the global namespace.
+  if (DeclName.find(':') == llvm::StringRef::npos)
+return NsName.empty() ? DeclName.str() : ("::" + DeclName).str();
+
+  while (!DeclName.consume_front((NsName + "::").str())) {
 const auto Pos = NsName.find_last_of(':');
 if (Pos == llvm::StringRef::npos)
   return DeclName;
-const auto Prefix = NsName.substr(0, Pos - 1);
-if (DeclName.startswith(Prefix))
-  return (Prefix + "::" + UnqualifiedName).str();
-NsName = Prefix;
+assert(Pos > 0);
+NsName = NsName.substr(0, Pos - 1);
   }
   return DeclName;
 }

Modified: 
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp?rev=28&r1=283332&r2=28&view=diff
==
--- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp 
Wed Oct  5 10:52:39 2016
@@ -113,6 +113,24 @@ TEST_F(ChangeNamespaceTest, SimpleMoveIn
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, MoveIntoAnotherNestedNamespaceWithRef) {
+  NewNamespace = "na::nc";
+  std::string Code = "namespace na {\n"
+ "class A {};\n"
+ "namespace nb {\n"
+ "class X { A a; };\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "class A {};\n"
+ "\n"
+ "namespace nc {\n"
+ "class X { A a; };\n"
+ "} // namespace nc\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 TEST_F(ChangeNamespaceTest, SimpleMoveNestedNamespace) {
   NewNamespace = "na::x::y";
   std::string Code = "namespace na {\n"


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


[PATCH] D25264: Implement MS _BitScan intrinsics

2016-10-05 Thread Albert Gutowski via cfe-commits
agutowski added inline comments.


> majnemer wrote in CGBuiltin.cpp:2656-2684
> Does this do the right thing if the arg is zero?  I think it would if you 
> gave the call to the intrinsic an operand of false instead of true.

MSDN doesn't specify what should be put under the "Index" address when the 
argument is zero; as I checked, VS2015 with optimizations puts undefined value 
there, and I hope that's what I'm doing here.

https://reviews.llvm.org/D25264



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


[PATCH] D25065: [change-namespace] Fixed a bug in getShortestQualifiedNameInNamespace.

2016-10-05 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL28: [change-namespace] Fixed a bug in 
getShortestQualifiedNameInNamespace. (authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D25065?vs=73459&id=73653#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25065

Files:
  clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
  clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp


Index: 
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
+++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -113,6 +113,24 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, MoveIntoAnotherNestedNamespaceWithRef) {
+  NewNamespace = "na::nc";
+  std::string Code = "namespace na {\n"
+ "class A {};\n"
+ "namespace nb {\n"
+ "class X { A a; };\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "class A {};\n"
+ "\n"
+ "namespace nc {\n"
+ "class X { A a; };\n"
+ "} // namespace nc\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 TEST_F(ChangeNamespaceTest, SimpleMoveNestedNamespace) {
   NewNamespace = "na::x::y";
   std::string Code = "namespace na {\n"
Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
@@ -173,21 +173,24 @@
 // Returns the shortest qualified name for declaration `DeclName` in the
 // namespace `NsName`. For example, if `DeclName` is "a::b::X" and `NsName`
 // is "a::c::d", then "b::X" will be returned.
+// \param DeclName A fully qualified name, "::a::b::X" or "a::b::X".
+// \param NsName A fully qualified name, "::a::b" or "a::b". Global namespace
+//will have empty name.
 std::string getShortestQualifiedNameInNamespace(llvm::StringRef DeclName,
 llvm::StringRef NsName) {
-  llvm::SmallVector DeclNameSplitted;
-  DeclName.split(DeclNameSplitted, "::");
-  if (DeclNameSplitted.size() == 1)
-return DeclName;
-  const auto UnqualifiedName = DeclNameSplitted.back();
-  while (true) {
+  DeclName = DeclName.ltrim(':');
+  NsName = NsName.ltrim(':');
+  // If `DeclName` is a global variable, we prepend "::" to it if it is not in
+  // the global namespace.
+  if (DeclName.find(':') == llvm::StringRef::npos)
+return NsName.empty() ? DeclName.str() : ("::" + DeclName).str();
+
+  while (!DeclName.consume_front((NsName + "::").str())) {
 const auto Pos = NsName.find_last_of(':');
 if (Pos == llvm::StringRef::npos)
   return DeclName;
-const auto Prefix = NsName.substr(0, Pos - 1);
-if (DeclName.startswith(Prefix))
-  return (Prefix + "::" + UnqualifiedName).str();
-NsName = Prefix;
+assert(Pos > 0);
+NsName = NsName.substr(0, Pos - 1);
   }
   return DeclName;
 }


Index: clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
+++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -113,6 +113,24 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, MoveIntoAnotherNestedNamespaceWithRef) {
+  NewNamespace = "na::nc";
+  std::string Code = "namespace na {\n"
+ "class A {};\n"
+ "namespace nb {\n"
+ "class X { A a; };\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "class A {};\n"
+ "\n"
+ "namespace nc {\n"
+ "class X { A a; };\n"
+ "} // namespace nc\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 TEST_F(ChangeNamespaceTest, SimpleMoveNestedNamespace) {
   NewNamespace = "na::x::y";
   std::string Code = "namespace na {\n"
Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
+++ clang-tools-extra/trunk/chan

Re: [PATCH] D25254: test-suite: Change extension used for reference outputs by Makefile-based harness so we can start improving how the CMake-based harness works without breaking the old system or the

2016-10-05 Thread Abe Skolnik via cfe-commits

Can you expand on how you plan to add the second set of reference outputs?


I plan to {either re-target or replace with normal files} the new symlinks in upcoming patches. 
 The patch proposal to which you referred in the above is just "stage 1" of a large clean-up. 
We [Sebastian and I] have CMake code in progress that will significantly improve the harness 
WRT reference outputs.




We already have multiple reference outputs, for example big endian vs. little 
endian.


Yes.  I have noticed that, and made appropriate use of it in the WIP CMake code.  That CMake 
code is not yet ready for general inspection, but if anybody reading this wants to read what`s 
new in the WIP then please send me an e-mail about that.




I was expecting you to have done a similar thing, which doesn't involve 
changing every single reference file. :)


1: I _am_ doing a "similar thing", but it is not yet ready for general inspection.  In my WIP 
check-out of "test-suite" much is currently broken, waiting for me to fix it as part of my work 
[e.g. half-done fixes and improvements].  I`m reasonably sure the already-proposed patch is 
free of new breakage.


2: I didn`t change _any_ reference files in the patch proposal to which you referred in the 
above; I simply changed what the Makefile harness demands in terms of its reference-output 
pathnames, and added symlinks to the then-current reference output pathnames so that the 
Makefile harness won`t break.


The objective of the preceding, as I mentioned earlier, is to enable us all to fix/improve the 
CMake harness without breaking the Makefile harness.




One way this could be simpler is to change the Makefile on each affected 
directories to duplicate the tests & check differently
 against the reference file. It can be the same reference, but with different thresholds for 

different fp-contract options.

A key motivation in the relevant proposed patch is to change the Makefile harness as _little_ 
as _possible_.  We [SP & I] are not planning to improve the Makefile harness except in such a 
way as to make it "get out of the way" of the modern harness [as in the proposed patch 
currently under discussion].


If the Makefile harness is going to be completely-unneeded extremely soon, then a valid 
alternative is to just delete all files in the repo that are only there for the benefit of the 
Makefile harness and to cease assuming that we need to preserve backwards compatibility.  That 
would make the relevant proposed patch obsolete.


Regards,

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


[PATCH] D25264: Implement MS _BitScan intrinsics

2016-10-05 Thread Reid Kleckner via cfe-commits
rnk added a comment.

Nice, probably ready to land with one revision.



> majnemer wrote in CGBuiltin.cpp:2640-2647
> This should be in an anonymous namespace. Also, consider using an `enum 
> class` instead of an `enum` nested inside a namespace.

Let's also use a more specific name than MSVC, maybe MSVCIntrin or something.

https://reviews.llvm.org/D25264



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


[PATCH] D25264: Implement MS _BitScan intrinsics

2016-10-05 Thread Albert Gutowski via cfe-commits
agutowski added inline comments.


> majnemer wrote in CGBuiltin.cpp:2640-2647
> This should be in an anonymous namespace. Also, consider using an `enum 
> class` instead of an `enum` nested inside a namespace.

I can see three options:
 (1) put the existing code inside an anonymous namespace;
 (2) create a private enum class in CodeGenFunction;
 (3) pull EmitMSVCBuiltinExpr outside of CodeGenFunction and take CGF object as 
an argument (and then make enum class inside an anonymous namespace);
I don't really like any of them. Enum class sounds nice as I can imagine 
someone trying to pass the global builtin ID (like X86::BI_BitScanForward) 
instead of the one from MSVCIntrin namespace (although it should fail on any 
test; still, it would compile without enum class). But builtins use CGF methods 
all of the time, so pulling it out will make the code of every bulitin uglier. 
So I guess I'll try to go with the private enum class inside the 
CodeGenFunction, but if you have any better ideas, I'm eager to listen.

https://reviews.llvm.org/D25264



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


[PATCH] D25282: [clang-move] Cleanup around replacements.

2016-10-05 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: ioeric.
hokein added a subscriber: cfe-commits.

cleanup the remaining empty namespace after moving out the
class defintitions.


https://reviews.llvm.org/D25282

Files:
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h
  clang-move/tool/ClangMoveMain.cpp
  test/clang-move/move-class.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -161,7 +161,7 @@
   assert(!EC);
   (void)EC;
   auto Factory = llvm::make_unique(
-  Spec, FileToReplacements, InitialDirectory.str());
+  Spec, FileToReplacements, InitialDirectory.str(), "LLVM");
 
   tooling::runToolOnCodeWithArgs(
   Factory->create(), TestCC, {"-std=c++11"}, TestCCName, "clang-move",
Index: test/clang-move/move-class.cpp
===
--- test/clang-move/move-class.cpp
+++ test/clang-move/move-class.cpp
@@ -7,15 +7,15 @@
 // RUN: FileCheck -input-file=%T/clang-move/new_test.cpp -check-prefix=CHECK-NEW-TEST-CPP %s
 // RUN: FileCheck -input-file=%T/clang-move/new_test.h -check-prefix=CHECK-NEW-TEST-H %s
 // RUN: FileCheck -input-file=%T/clang-move/test.cpp -check-prefix=CHECK-OLD-TEST-CPP %s
-// RUN: FileCheck -input-file=%T/clang-move/test.h -check-prefix=CHECK-OLD-TEST-H %s
+// RUN: FileCheck -input-file=%T/clang-move/test.h %s -implicit-check-not='{{namespace.*}}'
 //
 // RUN: cp %S/Inputs/test*  %T/clang-move/
 // RUN: cd %T/clang-move
 // RUN: clang-move -name="a::Foo" -new_cc=%T/clang-move/new_test.cpp -new_header=%T/clang-move/new_test.h -old_cc=%T/clang-move/test.cpp -old_header=%T/clang-move/test.h %T/clang-move/test.cpp
 // RUN: FileCheck -input-file=%T/clang-move/new_test.cpp -check-prefix=CHECK-NEW-TEST-CPP %s
 // RUN: FileCheck -input-file=%T/clang-move/new_test.h -check-prefix=CHECK-NEW-TEST-H %s
 // RUN: FileCheck -input-file=%T/clang-move/test.cpp -check-prefix=CHECK-OLD-TEST-CPP %s
-// RUN: FileCheck -input-file=%T/clang-move/test.h -check-prefix=CHECK-OLD-TEST-H %s
+// RUN: FileCheck -input-file=%T/clang-move/test.h %s -implicit-check-not='{{namespace.*}}'
 //
 // CHECK-NEW-TEST-H: namespace a {
 // CHECK-NEW-TEST-H: class Foo {
@@ -30,10 +30,5 @@
 // CHECK-NEW-TEST-CPP: int Foo::f() { return 0; }
 // CHECK-NEW-TEST-CPP: } // namespace a
 //
-// CHECK-OLD-TEST-H: namespace a {
-// CHECK-OLD-TEST-H: } // namespace a
-//
 // CHECK-OLD-TEST-CPP: #include "test.h"
 // CHECK-OLD-TEST-CPP: #include "test2.h"
-// CHECK-OLD-TEST-CPP: namespace a {
-// CHECK-OLD-TEST-CPP: } // namespace a
Index: clang-move/tool/ClangMoveMain.cpp
===
--- clang-move/tool/ClangMoveMain.cpp
+++ clang-move/tool/ClangMoveMain.cpp
@@ -86,7 +86,7 @@
  Twine(EC.message()));
 
   auto Factory = llvm::make_unique(
-  Spec, Tool.getReplacements(), InitialDirectory.str());
+  Spec, Tool.getReplacements(), InitialDirectory.str(), Style);
 
   int CodeStatus = Tool.run(Factory.get());
   if (CodeStatus)
Index: clang-move/ClangMove.h
===
--- clang-move/ClangMove.h
+++ clang-move/ClangMove.h
@@ -50,7 +50,7 @@
   ClangMoveTool(
   const MoveDefinitionSpec &MoveSpec,
   std::map &FileToReplacements,
-  llvm::StringRef OriginalRunningDirectory);
+  llvm::StringRef OriginalRunningDirectory, llvm::StringRef Style);
 
   void registerMatchers(ast_matchers::MatchFinder *Finder);
 
@@ -95,15 +95,18 @@
   // directory when analyzing the source file. We save the original working
   // directory in order to get the absolute file path for the fields in Spec.
   std::string OriginalRunningDirectory;
+  // The name of a predefined code style.
+  std::string FallbackStyle;
 };
 
 class ClangMoveAction : public clang::ASTFrontendAction {
 public:
   ClangMoveAction(
   const ClangMoveTool::MoveDefinitionSpec &spec,
   std::map &FileToReplacements,
-  llvm::StringRef OriginalRunningDirectory)
-  : MoveTool(spec, FileToReplacements, OriginalRunningDirectory) {
+  llvm::StringRef OriginalRunningDirectory, llvm::StringRef FallbackStyle)
+  : MoveTool(spec, FileToReplacements, OriginalRunningDirectory,
+ FallbackStyle) {
 MoveTool.registerMatchers(&MatchFinder);
   }
 
@@ -123,18 +126,21 @@
   ClangMoveActionFactory(
   const ClangMoveTool::MoveDefinitionSpec &Spec,
   std::map &FileToReplacements,
-  llvm::StringRef OriginalRunningDirectory)
+  llvm::StringRef OriginalRunningDirectory, llvm::StringRef FallbackStyle)
   : Spec(Spec), FileToReplacements(FileToReplacements),
-OriginalRunningDirectory(OriginalRunningDirectory) {}
+OriginalRunningDirectory(OriginalRunningDirectory),
+FallbackStyle(FallbackStyle) {}
 
   cla

[PATCH] D24562: [libcxx] Recover no-exceptions XFAILs

2016-10-05 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 73661.
rmaprath added a comment.

First batch of XFAIL fixes.

I've changed some XFAILs to UNSUPPORTED where the test is all about exception 
handling. In other cases, I've used the test macro TEST_HAS_NO_EXCEPTIONS to 
conditionally exclude those parts that test
exception handling behaviour.

@EricWF: I can create a separate review if necessary, thought I'll re-use this 
review for the first batch, will be opening new reviews for the follow-ups.

/ Asiri


https://reviews.llvm.org/D24562

Files:
  test/std/re/re.alg/re.alg.search/grep.pass.cpp
  test/std/re/re.regex/re.regex.assign/assign.pass.cpp
  test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
  test/std/re/re.regex/re.regex.construct/bad_repeat.pass.cpp
  test/std/thread/futures/futures.async/async.pass.cpp
  test/std/thread/futures/futures.promise/dtor.pass.cpp
  test/std/thread/futures/futures.promise/get_future.pass.cpp
  test/std/thread/futures/futures.promise/move_ctor.pass.cpp
  test/std/thread/futures/futures.promise/set_exception.pass.cpp
  test/std/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
  test/std/thread/futures/futures.promise/set_lvalue.pass.cpp
  test/std/thread/futures/futures.promise/set_value_const.pass.cpp
  test/std/thread/futures/futures.promise/set_value_void.pass.cpp
  test/std/thread/futures/futures.shared_future/get.pass.cpp
  test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp
  test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp
  
test/std/thread/futures/futures.task/futures.task.members/make_ready_at_thread_exit.pass.cpp
  test/std/thread/futures/futures.task/futures.task.members/operator.pass.cpp
  test/std/thread/futures/futures.task/futures.task.members/reset.pass.cpp
  test/std/thread/futures/futures.unique_future/get.pass.cpp
  
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp

Index: test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
===
--- test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
+++ test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 
 // 
@@ -32,9 +31,11 @@
 
 void* operator new(std::size_t s) throw(std::bad_alloc)
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 if (throw_one == 0)
 throw std::bad_alloc();
 --throw_one;
+#endif
 ++outstanding_new;
 void* ret = std::malloc(s);
 if (!ret) std::abort(); // placate MSVC's unchecked malloc warning
@@ -118,6 +119,7 @@
 //  3 Finally check that a thread runs successfully if we throw after 'N+1'
 //allocations.
 void test_throwing_new_during_thread_creation() {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 throw_one = 0xFFF;
 {
 std::thread t(f);
@@ -142,6 +144,7 @@
 }
 f_run = false;
 throw_one = 0xFFF;
+#endif
 }
 
 int main()
@@ -162,6 +165,7 @@
 assert(G::op_run);
 }
 G::op_run = false;
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 try
 {
@@ -178,6 +182,7 @@
 assert(!G::op_run);
 }
 }
+#endif
 #if TEST_STD_VER >= 11
 {
 assert(G::n_alive == 0);
Index: test/std/thread/futures/futures.unique_future/get.pass.cpp
===
--- test/std/thread/futures/futures.unique_future/get.pass.cpp
+++ test/std/thread/futures/futures.unique_future/get.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 // UNSUPPORTED: c++98, c++03
 
@@ -22,6 +21,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 void func1(std::promise p)
 {
 std::this_thread::sleep_for(std::chrono::milliseconds(500));
@@ -73,6 +74,7 @@
 assert(f.get() == 3);
 assert(!f.valid());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::promise p;
 std::future f = p.get_future();
@@ -89,6 +91,7 @@
 }
 assert(!f.valid());
 }
+#endif
 }
 {
 typedef int& T;
@@ -100,6 +103,7 @@
 assert(f.get() == 5);
 assert(!f.valid());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::promise p;
 std::future f = p.get_future();
@@ -116,6 +120,7 @@
 }
 assert(!f.valid());
 }
+#endif
 }
 {
 typedef void T;
@@ -127,6 +132,7 @@
 f.get();
 assert(!f.valid());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::promise p;
 std::future f = p.get_future();
@@ -143,5 +149,6 @@
 }

[PATCH] D25283: AvailabilityAttrs: Refactor context checking when diagnosing an availability violation

2016-10-05 Thread Erik Pilkington via cfe-commits
erik.pilkington created this revision.
erik.pilkington added a reviewer: manmanren.
erik.pilkington added a subscriber: cfe-commits.

This patch removes some redundant functions that implement checking 
availability against context, and implements a new, more correct one: 
`ShouldDiagnoseAvailabilityInContext`. This is done to more easily allow 
delaying `AD_NotYetIntroduced` diagnostics, which is a patch I'll submit right 
after this!

As it happens, this fixes a bug:

  int unavailable_global __attribute__((unavailable));
  
  __attribute__((unavailable))
  @interface Foo
  - meth;
  @end
  
  @implementation Foo
  - meth {
(void) unavailable_global; // no error
(void) ^{
  (void) unavailable_global; // incorrect-error: 'unavailable_global' is 
not available
};
  }
  @end

Here, there is a reference to an unavailable declaration, `unavailable`, in the 
context of a block. We shouldn't emit an error here because 'meth' is 
implicitly unavailable, meaning that we should be able to reference other 
unavailable declarations inside it

The problem is that, though both `isDeclUnavailable()` and 
`getCurContextAvailability()` check the reference to `unavailable_global`, 
`isDeclUnavailable` doesn't infer availability attributes from @interface to 
@implementation (But does consider nested contexts), and 
`getCurContextAvailability()` doesn't consider non-immediate contexts (But does 
infer from @interface -> @implementation). Since they both don't catch this 
case, this error is emitted when it really shouldn't be!

Thanks for taking a look!


https://reviews.llvm.org/D25283

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExpr.cpp
  test/SemaObjC/class-unavail-warning.m

Index: test/SemaObjC/class-unavail-warning.m
===
--- test/SemaObjC/class-unavail-warning.m
+++ test/SemaObjC/class-unavail-warning.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fsyntax-only  -triple x86_64-apple-darwin10 -verify %s
+// RUN: %clang_cc1  -fsyntax-only -fblocks -triple x86_64-apple-darwin10 -verify %s
 // rdar://9092208
 
 __attribute__((unavailable("not available")))
@@ -98,3 +98,19 @@
 @end
 @interface UnavailSub(cat) // no error
 @end
+
+int unavail_global UNAVAILABLE;
+
+UNAVAILABLE __attribute__((objc_root_class))
+@interface TestAttrContext
+-meth;
+@end
+
+@implementation TestAttrContext
+-meth {
+  unavail_global = 2; // no warn
+  (void) ^{
+unavail_global = 4; // no warn
+  };
+}
+@end
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -103,17 +103,17 @@
   return false;
 }
 
-AvailabilityResult Sema::ShouldDiagnoseAvailabilityOfDecl(
-NamedDecl *&D, VersionTuple ContextVersion, std::string *Message) {
-  AvailabilityResult Result = D->getAvailability(Message, ContextVersion);
+AvailabilityResult
+Sema::ShouldDiagnoseAvailabilityOfDecl(NamedDecl *&D, std::string *Message) {
+  AvailabilityResult Result = D->getAvailability(Message);
 
   // For typedefs, if the typedef declaration appears available look
   // to the underlying type to see if it is more restrictive.
   while (const TypedefNameDecl *TD = dyn_cast(D)) {
 if (Result == AR_Available) {
   if (const TagType *TT = TD->getUnderlyingType()->getAs()) {
 D = TT->getDecl();
-Result = D->getAvailability(Message, ContextVersion);
+Result = D->getAvailability(Message);
 continue;
   }
 }
@@ -124,26 +124,18 @@
   if (ObjCInterfaceDecl *IDecl = dyn_cast(D)) {
 if (IDecl->getDefinition()) {
   D = IDecl->getDefinition();
-  Result = D->getAvailability(Message, ContextVersion);
+  Result = D->getAvailability(Message);
 }
   }
 
   if (const EnumConstantDecl *ECD = dyn_cast(D))
 if (Result == AR_Available) {
   const DeclContext *DC = ECD->getDeclContext();
   if (const EnumDecl *TheEnumDecl = dyn_cast(DC))
-Result = TheEnumDecl->getAvailability(Message, ContextVersion);
+Result = TheEnumDecl->getAvailability(Message);
 }
 
-  switch (Result) {
-  case AR_Available:
-return Result;
-
-  case AR_Unavailable:
-  case AR_Deprecated:
-return getCurContextAvailability() != Result ? Result : AR_Available;
-
-  case AR_NotYetIntroduced: {
+  if (Result == AR_NotYetIntroduced) {
 // Don't do this for enums, they can't be redeclared.
 if (isa(D) || isa(D))
   return AR_Available;
@@ -166,23 +158,18 @@
 
 return Warn ? AR_NotYetIntroduced : AR_Available;
   }
-  }
-  llvm_unreachable("Unknown availability result!");
+
+  return Result;
 }
 
 static void
 DiagnoseAvailabilityOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc,
const ObjCInterfaceDecl *UnknownObjCClass,
bool ObjCPropertyAccess) {
-  VersionTuple ContextVersion;
-  if (const DeclContext *DC = S.getCurObjCLexicalC

[PATCH] D25284: AvailabilityAttrs: Delay partial availability diagnostics

2016-10-05 Thread Erik Pilkington via cfe-commits
erik.pilkington created this revision.
erik.pilkington added a reviewer: manmanren.
erik.pilkington added a subscriber: cfe-commits.

Note: this patch depends on: https://reviews.llvm.org/D25283

This patch delays handling of `AR_NotYetIntroduced` diagnostics, so that the 
following compiles with no warnings:

  typedef int new_int __attribute__((availability(macos, introduced=100)));
  
  new_int f() __attribute__((availability(macos, introduced=100)));

This is done by treating `AR_NotYetIntroduced` diagnostics as delayed, just 
like `AR_Unavailable` and `AR_Deprecated`. This means that we emit the 
diagnostic once we finished parsing `f()`, at which point we have the context 
to determine if we should diagnose `new_int`.

Thanks!


https://reviews.llvm.org/D25284

Files:
  include/clang/Sema/DelayedDiagnostic.h
  lib/Sema/DelayedDiagnostic.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/SemaObjC/unguarded-availability.m

Index: test/SemaObjC/unguarded-availability.m
===
--- test/SemaObjC/unguarded-availability.m
+++ test/SemaObjC/unguarded-availability.m
@@ -63,7 +63,7 @@
 #ifdef OBJCPP
 // expected-note@+2 {{marked partial here}}
 #endif
-typedef int int_10_12 AVAILABLE_10_12; // expected-note 3 {{'int_10_12' has been explicitly marked partial here}}
+typedef int int_10_12 AVAILABLE_10_12; // expected-note 2 {{'int_10_12' has been explicitly marked partial here}}
 
 void use_typedef() {
   int_10_11 x; // expected-warning{{'int_10_11' is only available on macOS 10.11 or newer}} expected-note{{enclose 'int_10_11' in an @available check to silence this warning}}
@@ -127,8 +127,7 @@
 
 void test_params(int_10_12 x); // expected-warning {{'int_10_12' is partial: introduced in macOS 10.12}} expected-note{{redeclare}}
 
-// FIXME: This should be fine!
-void test_params2(int_10_12 x) AVAILABLE_10_12; // expected-warning {{'int_10_12' is partial: introduced in macOS 10.12}} expected-note{{redeclare}}
+void test_params2(int_10_12 x) AVAILABLE_10_12; // no warn
 
 #ifdef OBJCPP
 
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -6464,9 +6464,6 @@
 break;
 
   case AR_NotYetIntroduced:
-assert(!S.getCurFunctionOrMethodDecl() &&
-   "Function-level partial availablity should not be diagnosed here!");
-
 diag = diag::warn_partial_availability;
 diag_message = diag::warn_partial_message;
 diag_fwdclass_message = diag::warn_partial_fwdclass_message;
@@ -6539,15 +6536,14 @@
 
 static void handleDelayedAvailabilityCheck(Sema &S, DelayedDiagnostic &DD,
Decl *Ctx) {
-  assert(DD.Kind == DelayedDiagnostic::Deprecation ||
- DD.Kind == DelayedDiagnostic::Unavailable);
-  AvailabilityResult AR = DD.Kind == DelayedDiagnostic::Deprecation
-  ? AR_Deprecated
-  : AR_Unavailable;
+  assert(DD.Kind == DelayedDiagnostic::Availability &&
+ "Expected an availability diagnostic here");
+
   DD.Triggered = true;
-  DoEmitAvailabilityWarning(
-  S, AR, Ctx, DD.getDeprecationDecl(), DD.getDeprecationMessage(), DD.Loc,
-  DD.getUnknownObjCClass(), DD.getObjCProperty(), false);
+  DoEmitAvailabilityWarning(S, DD.getAvailabilityResult(), Ctx,
+DD.getDeprecationDecl(), DD.getDeprecationMessage(),
+DD.Loc, DD.getUnknownObjCClass(),
+DD.getObjCProperty(), false);
 }
 
 void Sema::PopParsingDeclaration(ParsingDeclState state, Decl *decl) {
@@ -6577,8 +6573,7 @@
 continue;
 
   switch (diag.Kind) {
-  case DelayedDiagnostic::Deprecation:
-  case DelayedDiagnostic::Unavailable:
+  case DelayedDiagnostic::Availability:
 // Don't bother giving deprecation/unavailable diagnostics if
 // the decl is invalid.
 if (!decl->isInvalidDecl())
@@ -6613,8 +6608,7 @@
const ObjCPropertyDecl  *ObjCProperty,
bool ObjCPropertyAccess) {
   // Delay if we're currently parsing a declaration.
-  if (DelayedDiagnostics.shouldDelayDiagnostics() &&
-  AR != AR_NotYetIntroduced) {
+  if (DelayedDiagnostics.shouldDelayDiagnostics()) {
 DelayedDiagnostics.add(DelayedDiagnostic::makeAvailability(
 AR, Loc, D, UnknownObjCClass, ObjCProperty, Message,
 ObjCPropertyAccess));
Index: lib/Sema/DelayedDiagnostic.cpp
===
--- lib/Sema/DelayedDiagnostic.cpp
+++ lib/Sema/DelayedDiagnostic.cpp
@@ -20,24 +20,15 @@
 using namespace sema;
 
 DelayedDiagnostic
-DelayedDiagnostic::makeAvailability(AvailabilityResult AD,
+DelayedDiagnostic::makeAvailability(AvailabilityResult AR,
 SourceLocation Loc,
 const NamedDecl 

[libcxx] r283339 - Make tests for is_empty better. No functional change.

2016-10-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Oct  5 12:01:16 2016
New Revision: 283339

URL: http://llvm.org/viewvc/llvm-project?rev=283339&view=rev
Log:
Make tests for is_empty better. No functional change.

Modified:

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp?rev=283339&r1=283338&r2=283339&view=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp
 Wed Oct  5 12:01:16 2016
@@ -11,6 +11,14 @@
 
 // is_empty
 
+// T is a non-union class type with:
+//  no non-static data members,
+//  no unnamed bit-fields of non-zero length,
+//  no virtual member functions,
+//  no virtual base classes,
+//  and no base class B for which is_empty_v is false.
+
+
 #include 
 #include "test_macros.h"
 
@@ -44,22 +52,33 @@ void test_is_not_empty()
 #endif
 }
 
-class Empty
-{
-};
+class Empty {};
+struct NotEmpty { int foo; };
 
-class NotEmpty
+class VirtualFn
 {
-virtual ~NotEmpty();
+virtual ~VirtualFn();
 };
 
 union Union {};
 
+struct EmptyBase: public Empty {};
+struct VirtualBase  : virtual Empty {};
+struct NotEmptyBase : public NotEmpty {};
+
+struct StaticMember{ static int foo; };
+struct NonStaticMember {int foo; };
+
 struct bit_zero
 {
 int :  0;
 };
 
+struct bit_one
+{
+int :  1;
+};
+
 int main()
 {
 test_is_not_empty();
@@ -72,7 +91,14 @@ int main()
 test_is_not_empty();
 test_is_not_empty();
 test_is_not_empty();
+test_is_not_empty();
+test_is_not_empty();
+test_is_not_empty();
+test_is_not_empty();
+test_is_empty();
 
 test_is_empty();
+test_is_empty();
+test_is_empty();
 test_is_empty();
 }


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


[libcxx] r283341 - Mark LWG#2358 as done

2016-10-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Oct  5 12:02:43 2016
New Revision: 283341

URL: http://llvm.org/viewvc/llvm-project?rev=283341&view=rev
Log:
Mark LWG#2358 as done

Modified:
libcxx/trunk/www/upcoming_meeting.html

Modified: libcxx/trunk/www/upcoming_meeting.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=283341&r1=283340&r2=283341&view=diff
==
--- libcxx/trunk/www/upcoming_meeting.html (original)
+++ libcxx/trunk/www/upcoming_meeting.html Wed Oct  5 12:02:43 2016
@@ -64,7 +64,7 @@
 http://wg21.link/LWG2221";>2221No 
formatted output operator for nullptrIssaquahPatch 
ready
 http://wg21.link/LWG2223";>2223shrink_to_fit effect on 
iterator validityIssaquah
 http://wg21.link/LWG2261";>2261Are 
containers required to use their 'pointer' type 
internally?Issaquah
-http://wg21.link/LWG2358";>2358Apparently-bogus definition of 
is_empty type traitIssaquah
+http://wg21.link/LWG2358";>2358Apparently-bogus definition of 
is_empty type traitIssaquahWe already do this
 http://wg21.link/LWG2394";>2394locale::name specification 
unclear - what is implementation-defined?Issaquah
 http://wg21.link/LWG2460";>2460LWG issue 
2408 and value categoriesIssaquah
 http://wg21.link/LWG2468";>2468Self-move-assignment of 
library typesIssaquah
@@ -138,7 +138,7 @@
 2221 - Patch and tests ready
 2223 - 
 2261 - 
-2358 - 
+2358 - We already do this; I improved the tests
 2394 - 
 2460 - 
 2468 - 


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


[PATCH] D25273: Fix PR30520: Fix incomplete type crash when dealing with transparent_union attribute

2016-10-05 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a reviewer: rnk.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm, thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D25273



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


[clang-tools-extra] r283338 - [change-namespace] Pass Style to ChangeNamespaceTool.

2016-10-05 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Oct  5 12:00:40 2016
New Revision: 283338

URL: http://llvm.org/viewvc/llvm-project?rev=283338&view=rev
Log:
[change-namespace] Pass Style to ChangeNamespaceTool.

Modified:
clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp

Modified: clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp?rev=283338&r1=283337&r2=283338&view=diff
==
--- clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp 
(original)
+++ clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp Wed 
Oct  5 12:00:40 2016
@@ -74,7 +74,7 @@ int main(int argc, const char **argv) {
   const auto &Files = OptionsParser.getSourcePathList();
   tooling::RefactoringTool Tool(OptionsParser.getCompilations(), Files);
   change_namespace::ChangeNamespaceTool NamespaceTool(
-  OldNamespace, NewNamespace, FilePattern, &Tool.getReplacements());
+  OldNamespace, NewNamespace, FilePattern, &Tool.getReplacements(), Style);
   ast_matchers::MatchFinder Finder;
   NamespaceTool.registerMatchers(&Finder);
   std::unique_ptr Factory =


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


[PATCH] D25264: Implement MS _BitScan intrinsics

2016-10-05 Thread Albert Gutowski via cfe-commits
agutowski updated this revision to Diff 73668.
agutowski added a comment.

change enum in MSVC namespace to enum class MSVCIntrin in CodeGenFunction; 
cover all control paths


https://reviews.llvm.org/D25264

Files:
  include/clang/Basic/BuiltinsARM.def
  include/clang/Basic/BuiltinsX86.def
  include/clang/Basic/BuiltinsX86_64.def
  lib/Basic/Targets.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Headers/intrin.h
  test/CodeGen/ms-intrinsics.c

Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -447,20 +447,6 @@
 |* Bit Counting and Testing
 \**/
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
-_BitScanForward(unsigned long *_Index, unsigned long _Mask) {
-  if (!_Mask)
-return 0;
-  *_Index = __builtin_ctzl(_Mask);
-  return 1;
-}
-static __inline__ unsigned char __DEFAULT_FN_ATTRS
-_BitScanReverse(unsigned long *_Index, unsigned long _Mask) {
-  if (!_Mask)
-return 0;
-  *_Index = 31 - __builtin_clzl(_Mask);
-  return 1;
-}
-static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _bittest(long const *_BitBase, long _BitPos) {
   return (*_BitBase >> _BitPos) & 1;
 }
@@ -506,20 +492,6 @@
 #endif
 #ifdef __x86_64__
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
-_BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask) {
-  if (!_Mask)
-return 0;
-  *_Index = __builtin_ctzll(_Mask);
-  return 1;
-}
-static __inline__ unsigned char __DEFAULT_FN_ATTRS
-_BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask) {
-  if (!_Mask)
-return 0;
-  *_Index = 63 - __builtin_clzll(_Mask);
-  return 1;
-}
-static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _bittest64(__int64 const *_BitBase, __int64 _BitPos) {
   return (*_BitBase >> _BitPos) & 1;
 }
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -2637,6 +2637,56 @@
   }
 }
 
+// Many of MSVC builtins are on both x64 and ARM; to avoid repeating code, we
+// handle them here.
+enum class CodeGenFunction::MSVCIntrin {
+  _BitScanForward,
+  _BitScanReverse
+};
+
+Value *CodeGenFunction::EmitMSVCBuiltinExpr(MSVCIntrin BuiltinID,
+const CallExpr *E) {
+  switch (BuiltinID) {
+  case MSVCIntrin::_BitScanForward:
+  case MSVCIntrin::_BitScanReverse: {
+Value *ArgValue = EmitScalarExpr(E->getArg(1));
+
+llvm::Type *ArgType = ArgValue->getType();
+llvm::Type *IndexType =
+EmitScalarExpr(E->getArg(0))->getType()->getPointerElementType();
+llvm::Type *ResultType = ConvertType(E->getType());
+
+Value *ArgZero = llvm::Constant::getNullValue(ArgType);
+Value *ResZero = llvm::Constant::getNullValue(ResultType);
+Value *ResOne = llvm::ConstantInt::get(ResultType, 1);
+
+Value *IsZero = Builder.CreateICmpEQ(ArgValue, ArgZero);
+Value *Result = Builder.CreateSelect(IsZero, ResZero, ResOne);
+
+Address IndexAddress = EmitPointerWithAlignment(E->getArg(0));
+
+if (BuiltinID == MSVCIntrin::_BitScanForward) {
+  Value *F = CGM.getIntrinsic(Intrinsic::cttz, ArgType);
+  Value *ZeroCount = Builder.CreateCall(F, {ArgValue, Builder.getTrue()});
+  ZeroCount = Builder.CreateIntCast(ZeroCount, IndexType, false);
+  Builder.CreateStore(ZeroCount, IndexAddress, false);
+} else {
+  unsigned ArgWidth = cast(ArgType)->getBitWidth();
+  Value *ArgTypeLastIndex = llvm::ConstantInt::get(IndexType, ArgWidth - 1);
+
+  Value *F = CGM.getIntrinsic(Intrinsic::ctlz, ArgType);
+  Value *ZeroCount = Builder.CreateCall(F, {ArgValue, Builder.getTrue()});
+  ZeroCount = Builder.CreateIntCast(ZeroCount, IndexType, false);
+  Value *Index = Builder.CreateNSWSub(ArgTypeLastIndex, ZeroCount);
+  Builder.CreateStore(Index, IndexAddress, false);
+}
+
+return Result;
+  }
+  }
+  llvm_unreachable("Incorrect MSVC intrinsic!");
+}
+
 Value *CodeGenFunction::EmitTargetBuiltinExpr(unsigned BuiltinID,
   const CallExpr *E) {
   if (getContext().BuiltinInfo.isAuxBuiltinID(BuiltinID)) {
@@ -4561,6 +4611,12 @@
 return Builder.CreateCall(F, {Ops[1], Ops[2], Ops[0],
   Ops[3], Ops[4], Ops[5]});
   }
+  case ARM::BI_BitScanForward:
+  case ARM::BI_BitScanForward64:
+return EmitMSVCBuiltinExpr(MSVCIntrin::_BitScanForward, E);
+  case ARM::BI_BitScanReverse:
+  case ARM::BI_BitScanReverse64:
+return EmitMSVCBuiltinExpr(MSVCIntrin::_BitScanReverse, E);
   }
 
   // Get the last argument, which specifies the vector type.
@@ -7599,6 +7655,13 @@
 HigherBits = Builder.CreateIntCast(HigherBits, ResType, IsSigned);
 return HigherBits;
   }
+
+  case X86::BI_BitScanForward:
+  case X86::BI_BitScanForward64:
+return EmitMSVCBuiltinExpr(MSVCIntrin::_B

[PATCH] D25273: Fix PR30520: Fix incomplete type crash when dealing with transparent_union attribute

2016-10-05 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM, thank you!


Repository:
  rL LLVM

https://reviews.llvm.org/D25273



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


[PATCH] D25264: Implement MS _BitScan intrinsics

2016-10-05 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


> CodeGenFunction.h:2964
> +private:
> +  enum class MSVCIntrin;
> +

Does this work on Linux? I thought you had to give it an explicit underlying 
type (enum class MSVCIntrin : unsigned;) to make that work.

https://reviews.llvm.org/D25264



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


[PATCH] D25264: Implement MS _BitScan intrinsics

2016-10-05 Thread Albert Gutowski via cfe-commits
agutowski added inline comments.


> rnk wrote in CodeGenFunction.h:2964
> Does this work on Linux? I thought you had to give it an explicit underlying 
> type (enum class MSVCIntrin : unsigned;) to make that work.

Yes, it seems to work on Linux too. According to the cppreference.com, it 
"declares a scoped enumeration type whose underlying type is int".

https://reviews.llvm.org/D25264



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


[PATCH] D24932: Fix PR 30440

2016-10-05 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin accepted this revision.
DmitryPolukhin added a comment.
This revision is now accepted and ready to land.

I think we need to fix this regression.


Repository:
  rL LLVM

https://reviews.llvm.org/D24932



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


[PATCH] D24397: Target Power9 bit counting and vector comparison instructions through builtins (front end portion)

2016-10-05 Thread Bjorn Pettersson via cfe-commits
bjope added a comment.

What is the progress about getting rid of these code generation checks?

(I'm still hesitating about commiting https://reviews.llvm.org/D24955 in llvm 
since that would make these clang tests fail...)


Repository:
  rL LLVM

https://reviews.llvm.org/D24397



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


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-05 Thread Serge Rogatch via cfe-commits
rSerge added a comment.

In https://reviews.llvm.org/D24799#561879, @dberris wrote:

> In https://reviews.llvm.org/D24799#561106, @rSerge wrote:
>
> > My mistake was that initially I only enumerated the unsupported targets 
> > from llvm\include\llvm\ADT\Triple.h . Now I've added also the cases from 
> > llvm\lib\Support\Triple.cpp .
> >  `XFAIL` requires a list of all unsupported cases, which is currently much 
> > larger than the list of supported cases. However, AFAIK there is nothing 
> > like `XPASS` in LIT.
>
>
> I just thought about reversing this. How about if you do something like:
>
>   // RUN: not %clang -v -fxray-instrument -c %s
>   // XFAIL: x86_64-, arm7-
>
>
> I suspect that would be sufficient to work as an `XPASS` of sorts?


Good idea, thanks. I've used it.


https://reviews.llvm.org/D24799



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


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-05 Thread Serge Rogatch via cfe-commits
rSerge updated this revision to Diff 73673.

https://reviews.llvm.org/D24799

Files:
  lib/Driver/Tools.cpp
  test/Driver/xray-instrument.c


Index: test/Driver/xray-instrument.c
===
--- test/Driver/xray-instrument.c
+++ test/Driver/xray-instrument.c
@@ -0,0 +1,3 @@
+// RUN: not %clang -v -fxray-instrument -c %s
+// XFAIL: amd64-, x86_64-, x86_64h-, arm
+typedef int a;
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4784,7 +4784,20 @@
 
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
-CmdArgs.push_back("-fxray-instrument");
+const char* const XRayInstrumentOption = "-fxray-instrument";
+switch(getToolChain().getArch()) {
+case llvm::Triple::arm:
+case llvm::Triple::x86_64:
+  break;
+default:
+{
+  std::string Feature(XRayInstrumentOption);
+  Feature += " on ";
+  Feature += Triple.getArchName().data();
+  D.Diag(diag::err_drv_clang_unsupported) << Feature;
+  break;
+} }
+CmdArgs.push_back(XRayInstrumentOption);
 if (const Arg *A =
 Args.getLastArg(options::OPT_fxray_instruction_threshold_,
 options::OPT_fxray_instruction_threshold_EQ)) {


Index: test/Driver/xray-instrument.c
===
--- test/Driver/xray-instrument.c
+++ test/Driver/xray-instrument.c
@@ -0,0 +1,3 @@
+// RUN: not %clang -v -fxray-instrument -c %s
+// XFAIL: amd64-, x86_64-, x86_64h-, arm
+typedef int a;
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4784,7 +4784,20 @@
 
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
-CmdArgs.push_back("-fxray-instrument");
+const char* const XRayInstrumentOption = "-fxray-instrument";
+switch(getToolChain().getArch()) {
+case llvm::Triple::arm:
+case llvm::Triple::x86_64:
+  break;
+default:
+{
+  std::string Feature(XRayInstrumentOption);
+  Feature += " on ";
+  Feature += Triple.getArchName().data();
+  D.Diag(diag::err_drv_clang_unsupported) << Feature;
+  break;
+} }
+CmdArgs.push_back(XRayInstrumentOption);
 if (const Arg *A =
 Args.getLastArg(options::OPT_fxray_instruction_threshold_,
 options::OPT_fxray_instruction_threshold_EQ)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25264: Implement MS _BitScan intrinsics

2016-10-05 Thread David Majnemer via cfe-commits
majnemer added inline comments.


> agutowski wrote in CGBuiltin.cpp:2656-2684
> MSDN doesn't specify what should be put under the "Index" address when the 
> argument is zero; as I checked, VS2015 with optimizations puts undefined 
> value there, and I hope that's what I'm doing here.

Intel (https://software.intel.com/en-us/node/523362) says the following:
Sets *p to the bit index of the least significant set bit of b or leaves it 
unchanged if b is zero. The function returns a non-zero result when b is 
non-zero and returns zero when b is zero.

This seems to mesh with this Mozilla bug report: 
https://bugzilla.mozilla.org/show_bug.cgi?id=1182370

https://reviews.llvm.org/D25264



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


[PATCH] D24397: Target Power9 bit counting and vector comparison instructions through builtins (front end portion)

2016-10-05 Thread Sanjay Patel via cfe-commits
spatel added a comment.

In https://reviews.llvm.org/D24397#562469, @bjope wrote:

> (I'm still hesitating about commiting https://reviews.llvm.org/D24955 in llvm 
> since that would make these clang tests fail...)


You can't do that. Bots will send you fail mail all day as they choke on the 
clang tests - speaking from experience. :)
We either need to fix or revert this commit in order to let 
https://reviews.llvm.org/D24955 proceed.


Repository:
  rL LLVM

https://reviews.llvm.org/D24397



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


[PATCH] D23096: [Sema] Pass CombineWithOuterScope = true to constructor of LocalInstantiationScope

2016-10-05 Thread Serge Pavlov via cfe-commits
sepavloff added a comment.

IIUC, the problem is observed because `Sema::getTemplateInstantiationArgs` does 
not handle the case of variable templates properly. Classes and functions are 
declaration contexts and implementation of the aforementioned function (and 
probably others) relies on this fact. Variable does not represents a context, 
and this causes errors like this. We cannot make 
`VarTemplateSpecializationDecl` a subclass of `DeclContext` because the latter 
not only serves as a host for other declarations but also supports name lookup. 
None is pertinent to the case of variable specialization.

I think, logic of `getTemplateInstantiationArgs` should be changed. The new 
implementation could inspect current instantiation 
(`Sema::ActiveTemplateInstantiations`) to check if it is an instantiation of a 
variable template. This could eliminate need of `VarTemplateSpec` and 
`VarTemplateSpecializationRAII`. Such solution looks more flexible as variable 
initializer may contain references to other variable instantiations, so single 
value of `VarTemplateSpec` is not sufficient to track instantiations.


https://reviews.llvm.org/D23096



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


[libcxx] r283356 - Mark LWG#2679 as complete

2016-10-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Oct  5 13:36:24 2016
New Revision: 283356

URL: http://llvm.org/viewvc/llvm-project?rev=283356&view=rev
Log:
Mark LWG#2679 as complete

Modified:
libcxx/trunk/www/upcoming_meeting.html

Modified: libcxx/trunk/www/upcoming_meeting.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=283356&r1=283355&r2=283356&view=diff
==
--- libcxx/trunk/www/upcoming_meeting.html (original)
+++ libcxx/trunk/www/upcoming_meeting.html Wed Oct  5 13:36:24 2016
@@ -93,7 +93,7 @@
 http://wg21.link/LWG2665";>2665remove_filename() post 
condition is incorrectIssaquah
 http://wg21.link/LWG2672";>2672Should 
is_empty use error_code in its 
specification?Issaquah
 http://wg21.link/LWG2678";>2678std::filesystem enum classes 
overspecifiedIssaquah
-http://wg21.link/LWG2679";>2679Inconsistent Use of Effects 
and Equivalent ToIssaquah
+http://wg21.link/LWG2679";>2679Inconsistent Use of Effects 
and Equivalent ToIssaquahNothing to do
 http://wg21.link/LWG2680";>2680Add 
"Equivalent to" to filesystemIssaquah
 http://wg21.link/LWG2681";>2681filesystem::copy() cannot copy 
symlinksIssaquah
 http://wg21.link/LWG2682";>2682filesystem::copy() won't 
create a symlink to a directoryIssaquah
@@ -167,7 +167,7 @@
 2665 - 
 2672 - 
 2678 - 
-2679 - 
+2679 - This is just wording cleanup. 
 2680 - 
 2681 - 
 2682 - 


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


[libcxx] r283360 - Comment out failing test while I figure out who is at fault

2016-10-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Oct  5 13:47:18 2016
New Revision: 283360

URL: http://llvm.org/viewvc/llvm-project?rev=283360&view=rev
Log:
Comment out failing test while I figure out who is at fault

Modified:

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp?rev=283360&r1=283359&r2=283360&view=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp
 Wed Oct  5 13:47:18 2016
@@ -95,7 +95,7 @@ int main()
 test_is_not_empty();
 test_is_not_empty();
 test_is_not_empty();
-test_is_empty();
+//test_is_not_empty();
 
 test_is_empty();
 test_is_empty();


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


Re: [PATCH] D24397: Target Power9 bit counting and vector comparison instructions through builtins (front end portion)

2016-10-05 Thread Nemanja Ivanovic via cfe-commits
OK, I get testing that I'm fine with if I remove the -O2 and the checks for
'select i1'.

Does that change suffice for the purposes of https://reviews.llvm.org/D24955
?

Namely, do I need to account for the possible addition of nsw/nuw flags to
the add instructions even without -O2?

On Wed, Oct 5, 2016 at 8:24 PM, Sanjay Patel  wrote:

> spatel added a comment.
>
> In https://reviews.llvm.org/D24397#562469, @bjope wrote:
>
> > (I'm still hesitating about commiting https://reviews.llvm.org/D24955
> in llvm since that would make these clang tests fail...)
>
>
> You can't do that. Bots will send you fail mail all day as they choke on
> the clang tests - speaking from experience. :)
> We either need to fix or revert this commit in order to let
> https://reviews.llvm.org/D24955 proceed.
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D24397
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24397: Target Power9 bit counting and vector comparison instructions through builtins (front end portion)

2016-10-05 Thread Sanjay Patel via cfe-commits
You should not need to account for any nsw/nuw flags if the clang test does
not enable the optimizer.
Ie, D24955 should not be running at -O0.

On Wed, Oct 5, 2016 at 1:09 PM, Nemanja Ivanovic 
wrote:

> OK, I get testing that I'm fine with if I remove the -O2 and the checks
> for 'select i1'.
>
> Does that change suffice for the purposes of
> https://reviews.llvm.org/D24955?
>
> Namely, do I need to account for the possible addition of nsw/nuw flags to
> the add instructions even without -O2?
>
> On Wed, Oct 5, 2016 at 8:24 PM, Sanjay Patel 
> wrote:
>
>> spatel added a comment.
>>
>> In https://reviews.llvm.org/D24397#562469, @bjope wrote:
>>
>> > (I'm still hesitating about commiting https://reviews.llvm.org/D24955
>> in llvm since that would make these clang tests fail...)
>>
>>
>> You can't do that. Bots will send you fail mail all day as they choke on
>> the clang tests - speaking from experience. :)
>> We either need to fix or revert this commit in order to let
>> https://reviews.llvm.org/D24955 proceed.
>>
>>
>> Repository:
>>   rL LLVM
>>
>> https://reviews.llvm.org/D24397
>>
>>
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24397: Target Power9 bit counting and vector comparison instructions through builtins (front end portion)

2016-10-05 Thread Nemanja Ivanovic via cfe-commits
OK, will remove optimization and the selects and commit this now.
Sorry about the delay.

On Wed, Oct 5, 2016 at 9:16 PM, Sanjay Patel  wrote:

> You should not need to account for any nsw/nuw flags if the clang test
> does not enable the optimizer.
> Ie, D24955 should not be running at -O0.
>
> On Wed, Oct 5, 2016 at 1:09 PM, Nemanja Ivanovic 
> wrote:
>
>> OK, I get testing that I'm fine with if I remove the -O2 and the checks
>> for 'select i1'.
>>
>> Does that change suffice for the purposes of
>> https://reviews.llvm.org/D24955?
>>
>> Namely, do I need to account for the possible addition of nsw/nuw flags
>> to the add instructions even without -O2?
>>
>> On Wed, Oct 5, 2016 at 8:24 PM, Sanjay Patel 
>> wrote:
>>
>>> spatel added a comment.
>>>
>>> In https://reviews.llvm.org/D24397#562469, @bjope wrote:
>>>
>>> > (I'm still hesitating about commiting https://reviews.llvm.org/D24955
>>> in llvm since that would make these clang tests fail...)
>>>
>>>
>>> You can't do that. Bots will send you fail mail all day as they choke on
>>> the clang tests - speaking from experience. :)
>>> We either need to fix or revert this commit in order to let
>>> https://reviews.llvm.org/D24955 proceed.
>>>
>>>
>>> Repository:
>>>   rL LLVM
>>>
>>> https://reviews.llvm.org/D24397
>>>
>>>
>>>
>>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r283363 - Removing optimization from the RUN lines and adjusting the checks

2016-10-05 Thread Nemanja Ivanovic via cfe-commits
Author: nemanjai
Date: Wed Oct  5 14:11:36 2016
New Revision: 283363

URL: http://llvm.org/viewvc/llvm-project?rev=283363&view=rev
Log:
Removing optimization from the RUN lines and adjusting the checks
to not rely on optimization.

Modified:
cfe/trunk/test/CodeGen/builtins-ppc-p9vector.c

Modified: cfe/trunk/test/CodeGen/builtins-ppc-p9vector.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-p9vector.c?rev=283363&r1=283362&r2=283363&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-ppc-p9vector.c (original)
+++ cfe/trunk/test/CodeGen/builtins-ppc-p9vector.c Wed Oct  5 14:11:36 2016
@@ -1,11 +1,11 @@
 // REQUIRES: powerpc-registered-target
 // RUN: %clang_cc1 -faltivec -target-feature +power9-vector \
 // RUN:   -triple powerpc64-unknown-unknown -emit-llvm %s \
-// RUN:   -O2 -o - | FileCheck %s -check-prefix=CHECK-BE
+// RUN:   -o - | FileCheck %s -check-prefix=CHECK-BE
 
 // RUN: %clang_cc1 -faltivec -target-feature +power9-vector \
 // RUN:   -triple powerpc64le-unknown-unknown -emit-llvm %s \
-// RUN:   -O2 -o - | FileCheck %s
+// RUN:   -o - | FileCheck %s
 
 #include 
 
@@ -31,7 +31,6 @@ unsigned test1(void) {
 // CHECK-BE: icmp eq i64 {{.*}}, 64
 // CHECK-BE: extractelement <2 x i64>
 // CHECK-BE: add i64 {{.*}}, 64
-// CHECK-BE: select i1
 // CHECK-BE: lshr i64 {{.*}}, 3
 // CHECK: @llvm.ppc.altivec.vcmpequb(<16 x i8>
 // CHECK: @llvm.cttz.v2i64(<2 x i64>
@@ -39,7 +38,6 @@ unsigned test1(void) {
 // CHECK: icmp eq i64 {{.*}}, 64
 // CHECK: extractelement <2 x i64>
 // CHECK: add i64 {{.*}}, 64
-// CHECK: select i1
 // CHECK: lshr i64 {{.*}}, 3
   return vec_first_match_index (vsca, vscb);
 }
@@ -50,7 +48,6 @@ unsigned test2(void) {
 // CHECK-BE: icmp eq i64 {{.*}}, 64
 // CHECK-BE: extractelement <2 x i64>
 // CHECK-BE: add i64 {{.*}}, 64
-// CHECK-BE: select i1
 // CHECK-BE: lshr i64 {{.*}}, 3
 // CHECK: @llvm.ppc.altivec.vcmpequb(<16 x i8>
 // CHECK: @llvm.cttz.v2i64(<2 x i64>
@@ -58,7 +55,6 @@ unsigned test2(void) {
 // CHECK: icmp eq i64 {{.*}}, 64
 // CHECK: extractelement <2 x i64>
 // CHECK: add i64 {{.*}}, 64
-// CHECK: select i1
 // CHECK: lshr i64 {{.*}}, 3
   return vec_first_match_index (vuca, vucb);
 }
@@ -69,7 +65,6 @@ unsigned test3(void) {
 // CHECK-BE: icmp eq i64 {{.*}}, 64
 // CHECK-BE: extractelement <2 x i64>
 // CHECK-BE: add i64 {{.*}}, 64
-// CHECK-BE: select i1
 // CHECK-BE: lshr i64 {{.*}}, 5
 // CHECK: @llvm.ppc.altivec.vcmpequw(<4 x i32>
 // CHECK: @llvm.cttz.v2i64(<2 x i64>
@@ -77,7 +72,6 @@ unsigned test3(void) {
 // CHECK: icmp eq i64 {{.*}}, 64
 // CHECK: extractelement <2 x i64>
 // CHECK: add i64 {{.*}}, 64
-// CHECK: select i1
 // CHECK: lshr i64 {{.*}}, 5
   return vec_first_match_index (vsia, vsib);
 }
@@ -88,7 +82,6 @@ unsigned test4(void) {
 // CHECK-BE: icmp eq i64 {{.*}}, 64
 // CHECK-BE: extractelement <2 x i64>
 // CHECK-BE: add i64 {{.*}}, 64
-// CHECK-BE: select i1
 // CHECK-BE: lshr i64 {{.*}}, 5
 // CHECK: @llvm.ppc.altivec.vcmpequw(<4 x i32>
 // CHECK: @llvm.cttz.v2i64(<2 x i64>
@@ -96,7 +89,6 @@ unsigned test4(void) {
 // CHECK: icmp eq i64 {{.*}}, 64
 // CHECK: extractelement <2 x i64>
 // CHECK: add i64 {{.*}}, 64
-// CHECK: select i1
 // CHECK: lshr i64 {{.*}}, 5
   return vec_first_match_index (vuia, vuib);
 }
@@ -107,7 +99,6 @@ unsigned test5(void) {
 // CHECK-BE: icmp eq i64 {{.*}}, 64
 // CHECK-BE: extractelement <2 x i64>
 // CHECK-BE: add i64 {{.*}}, 64
-// CHECK-BE: select i1
 // CHECK-BE: lshr i64 {{.*}}, 4
 // CHECK: @llvm.ppc.altivec.vcmpequh(<8 x i16>
 // CHECK: @llvm.cttz.v2i64(<2 x i64>
@@ -115,7 +106,6 @@ unsigned test5(void) {
 // CHECK: icmp eq i64 {{.*}}, 64
 // CHECK: extractelement <2 x i64>
 // CHECK: add i64 {{.*}}, 64
-// CHECK: select i1
 // CHECK: lshr i64 {{.*}}, 4
   return vec_first_match_index (vssa, vssb);
 }
@@ -126,7 +116,6 @@ unsigned test6(void) {
 // CHECK-BE: icmp eq i64 {{.*}}, 64
 // CHECK-BE: extractelement <2 x i64>
 // CHECK-BE: add i64 {{.*}}, 64
-// CHECK-BE: select i1
 // CHECK-BE: lshr i64 {{.*}}, 4
 // CHECK: @llvm.ppc.altivec.vcmpequh(<8 x i16>
 // CHECK: @llvm.cttz.v2i64(<2 x i64>
@@ -134,7 +123,6 @@ unsigned test6(void) {
 // CHECK: icmp eq i64 {{.*}}, 64
 // CHECK: extractelement <2 x i64>
 // CHECK: add i64 {{.*}}, 64
-// CHECK: select i1
 // CHECK: lshr i64 {{.*}}, 4
   return vec_first_match_index (vusa, vusb);
 }
@@ -149,7 +137,6 @@ unsigned test7(void) {
 // CHECK-BE: icmp eq i64 {{.*}}, 64
 // CHECK-BE: extractelement <2 x i64>
 // CHECK-BE: add i64 {{.*}}, 64
-// CHECK-BE: select i1
 // CHECK-BE: lshr i64 {{.*}}, 3
 // CHECK: @llvm.ppc.altivec.vcmpequb(<16 x i8>
 // CHECK: @llvm.ppc.altivec.vcmpequb(<16 x i8>
@@ -161,7 +148,6 @@ unsigned test7(void) {
 // CHECK: icmp eq i64 {{.*}}, 64
 // CHECK: extractelement <2 x i64>
 // CHECK: add i64 {{.*}}, 64
-// CHECK: select i1
 // CHECK: lshr i64 {{.*}}, 3
   return vec_first_match_or_eos_index (vsca, vscb);
 }
@@ -176,7 +162,6 @@ unsigned tes

Re: [PATCH] D24397: Target Power9 bit counting and vector comparison instructions through builtins (front end portion)

2016-10-05 Thread Nemanja Ivanovic via cfe-commits
 Committed revision 283363.

On Wed, Oct 5, 2016 at 9:18 PM, Nemanja Ivanovic 
wrote:

> OK, will remove optimization and the selects and commit this now.
> Sorry about the delay.
>
> On Wed, Oct 5, 2016 at 9:16 PM, Sanjay Patel 
> wrote:
>
>> You should not need to account for any nsw/nuw flags if the clang test
>> does not enable the optimizer.
>> Ie, D24955 should not be running at -O0.
>>
>> On Wed, Oct 5, 2016 at 1:09 PM, Nemanja Ivanovic > > wrote:
>>
>>> OK, I get testing that I'm fine with if I remove the -O2 and the checks
>>> for 'select i1'.
>>>
>>> Does that change suffice for the purposes of
>>> https://reviews.llvm.org/D24955?
>>>
>>> Namely, do I need to account for the possible addition of nsw/nuw flags
>>> to the add instructions even without -O2?
>>>
>>> On Wed, Oct 5, 2016 at 8:24 PM, Sanjay Patel 
>>> wrote:
>>>
 spatel added a comment.

 In https://reviews.llvm.org/D24397#562469, @bjope wrote:

 > (I'm still hesitating about commiting https://reviews.llvm.org/D24955
 in llvm since that would make these clang tests fail...)


 You can't do that. Bots will send you fail mail all day as they choke
 on the clang tests - speaking from experience. :)
 We either need to fix or revert this commit in order to let
 https://reviews.llvm.org/D24955 proceed.


 Repository:
   rL LLVM

 https://reviews.llvm.org/D24397




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


[PATCH] D25282: [clang-move] Cleanup around replacements.

2016-10-05 Thread Eric Liu via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

Lg


https://reviews.llvm.org/D25282



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


[PATCH] D25264: Implement MS _BitScan intrinsics

2016-10-05 Thread Albert Gutowski via cfe-commits
agutowski updated this revision to Diff 73685.
agutowski added a comment.

make _BitScan intrinsics compatible with Intel specification when the mask is 
zero


https://reviews.llvm.org/D25264

Files:
  include/clang/Basic/BuiltinsARM.def
  include/clang/Basic/BuiltinsX86.def
  include/clang/Basic/BuiltinsX86_64.def
  lib/Basic/Targets.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Headers/intrin.h
  test/CodeGen/ms-intrinsics.c

Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -447,20 +447,6 @@
 |* Bit Counting and Testing
 \**/
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
-_BitScanForward(unsigned long *_Index, unsigned long _Mask) {
-  if (!_Mask)
-return 0;
-  *_Index = __builtin_ctzl(_Mask);
-  return 1;
-}
-static __inline__ unsigned char __DEFAULT_FN_ATTRS
-_BitScanReverse(unsigned long *_Index, unsigned long _Mask) {
-  if (!_Mask)
-return 0;
-  *_Index = 31 - __builtin_clzl(_Mask);
-  return 1;
-}
-static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _bittest(long const *_BitBase, long _BitPos) {
   return (*_BitBase >> _BitPos) & 1;
 }
@@ -506,20 +492,6 @@
 #endif
 #ifdef __x86_64__
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
-_BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask) {
-  if (!_Mask)
-return 0;
-  *_Index = __builtin_ctzll(_Mask);
-  return 1;
-}
-static __inline__ unsigned char __DEFAULT_FN_ATTRS
-_BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask) {
-  if (!_Mask)
-return 0;
-  *_Index = 63 - __builtin_clzll(_Mask);
-  return 1;
-}
-static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _bittest64(__int64 const *_BitBase, __int64 _BitPos) {
   return (*_BitBase >> _BitPos) & 1;
 }
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -2637,6 +2637,68 @@
   }
 }
 
+// Many of MSVC builtins are on both x64 and ARM; to avoid repeating code, we
+// handle them here.
+enum class CodeGenFunction::MSVCIntrin {
+  _BitScanForward,
+  _BitScanReverse
+};
+
+Value *CodeGenFunction::EmitMSVCBuiltinExpr(MSVCIntrin BuiltinID,
+const CallExpr *E) {
+  switch (BuiltinID) {
+  case MSVCIntrin::_BitScanForward:
+  case MSVCIntrin::_BitScanReverse: {
+Value *ArgValue = EmitScalarExpr(E->getArg(1));
+
+llvm::Type *ArgType = ArgValue->getType();
+llvm::Type *IndexType =
+EmitScalarExpr(E->getArg(0))->getType()->getPointerElementType();
+llvm::Type *ResultType = ConvertType(E->getType());
+
+Value *ArgZero = llvm::Constant::getNullValue(ArgType);
+Value *ResZero = llvm::Constant::getNullValue(ResultType);
+Value *ResOne = llvm::ConstantInt::get(ResultType, 1);
+
+BasicBlock *Begin = Builder.GetInsertBlock();
+BasicBlock *End = createBasicBlock("bitscan_end", this->CurFn);
+Builder.SetInsertPoint(End);
+PHINode *Result = Builder.CreatePHI(ResultType, 2, "bitscan_result");
+
+Builder.SetInsertPoint(Begin);
+Value *IsZero = Builder.CreateICmpEQ(ArgValue, ArgZero);
+BasicBlock *NotZero = createBasicBlock("bitscan_not_zero", this->CurFn);
+Builder.CreateCondBr(IsZero, End, NotZero);
+Result->addIncoming(ResZero, Begin);
+
+Builder.SetInsertPoint(NotZero);
+Address IndexAddress = EmitPointerWithAlignment(E->getArg(0));
+
+if (BuiltinID == MSVCIntrin::_BitScanForward) {
+  Value *F = CGM.getIntrinsic(Intrinsic::cttz, ArgType);
+  Value *ZeroCount = Builder.CreateCall(F, {ArgValue, Builder.getTrue()});
+  ZeroCount = Builder.CreateIntCast(ZeroCount, IndexType, false);
+  Builder.CreateStore(ZeroCount, IndexAddress, false);
+} else {
+  unsigned ArgWidth = cast(ArgType)->getBitWidth();
+  Value *ArgTypeLastIndex = llvm::ConstantInt::get(IndexType, ArgWidth - 1);
+
+  Value *F = CGM.getIntrinsic(Intrinsic::ctlz, ArgType);
+  Value *ZeroCount = Builder.CreateCall(F, {ArgValue, Builder.getTrue()});
+  ZeroCount = Builder.CreateIntCast(ZeroCount, IndexType, false);
+  Value *Index = Builder.CreateNSWSub(ArgTypeLastIndex, ZeroCount);
+  Builder.CreateStore(Index, IndexAddress, false);
+}
+Builder.CreateBr(End);
+Result->addIncoming(ResOne, NotZero);
+
+Builder.SetInsertPoint(End);
+return Result;
+  }
+  }
+  llvm_unreachable("Incorrect MSVC intrinsic!");
+}
+
 Value *CodeGenFunction::EmitTargetBuiltinExpr(unsigned BuiltinID,
   const CallExpr *E) {
   if (getContext().BuiltinInfo.isAuxBuiltinID(BuiltinID)) {
@@ -4561,6 +4623,12 @@
 return Builder.CreateCall(F, {Ops[1], Ops[2], Ops[0],
   Ops[3], Ops[4], Ops[5]});
   }
+  case ARM::BI_BitScanForward:
+  case ARM::BI_BitScanForward64:
+ret

[PATCH] D1391: Bug fix: note diagnosis on expression narrowing...

2016-10-05 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko closed this revision.
Eugene.Zelenko added a comment.

Committed in https://reviews.llvm.org/rL188409.


https://reviews.llvm.org/D1391



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


[PATCH] D25264: Implement MS _BitScan intrinsics

2016-10-05 Thread Albert Gutowski via cfe-commits
agutowski added inline comments.


> CGBuiltin.cpp:2665
> +BasicBlock *End = createBasicBlock("bitscan_end", this->CurFn);
> +Builder.SetInsertPoint(End);
> +PHINode *Result = Builder.CreatePHI(ResultType, 2, "bitscan_result");

Is this line needed? I took it from __builtin_fpclassify, but I don't know what 
could be its purpose (it's repeated below, where the "bitscan_end" block really 
starts).

https://reviews.llvm.org/D25264



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


[PATCH] D1147: FIXME fix: improving diagnostics for template arguments deduction of class templates and explicit specializations

2016-10-05 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko closed this revision.
Eugene.Zelenko added a comment.

Committed in https://reviews.llvm.org/rL186727.


https://reviews.llvm.org/D1147



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


[PATCH] D1067: Variable templates w/ partial support for static data members

2016-10-05 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko closed this revision.
Eugene.Zelenko added a comment.

Committed in https://reviews.llvm.org/rL187762.


https://reviews.llvm.org/D1067



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


[PATCH] D25171: clang-format: Add two new formatting options

2016-10-05 Thread Robin Sommer via cfe-commits
rsmmr added a comment.

Sure, I'm aiming to use clang-format on a couple of open-source code bases 
using this style, with the main one being the Bro network security monitor, see 
www.bro.org and github.com/bro/bro (note the stars and forks :-) Bro is also 
featured on GitHub's list of security show cases, 
https://github.com/showcases/security.


https://reviews.llvm.org/D25171



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


[PATCH] D24508: PR28752: Do not instantiate var decls which are not visible.

2016-10-05 Thread Vassil Vassilev via cfe-commits
v.g.vassilev updated this revision to Diff 73688.
v.g.vassilev added a comment.

Address some comments and publish current progress.


https://reviews.llvm.org/D24508

Files:
  include/clang/AST/Decl.h
  lib/AST/Decl.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/Modules/Inputs/PR28752/Subdir1/b.h
  test/Modules/Inputs/PR28752/Subdir1/c.h
  test/Modules/Inputs/PR28752/Subdir1/module.modulemap
  test/Modules/Inputs/PR28752/a.h
  test/Modules/Inputs/PR28752/module.modulemap
  test/Modules/Inputs/PR28752/vector
  test/Modules/Inputs/merge-class-definition-visibility/a.h
  test/Modules/Inputs/merge-class-definition-visibility/c.h
  test/Modules/merge-class-definition-visibility.cpp
  test/Modules/pr28752.cpp

Index: test/Modules/pr28752.cpp
===
--- /dev/null
+++ test/Modules/pr28752.cpp
@@ -0,0 +1,19 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -I%S/Inputs/PR28752 -verify %s
+// RUN: %clang_cc1 -std=c++11 -nostdsysteminc -fmodules -fmodule-map-file=%S/Inputs/PR28752/Subdir1/module.modulemap -fmodule-map-file=%S/Inputs/PR28752/module.modulemap -fmodules-cache-path=%t -I%S/Inputs/PR28752 -I%S/Inputs/PR28752/Subdir1 -verify %s
+
+#include "a.h"
+#include "Subdir1/c.h"
+#include 
+
+class TClingClassInfo {
+  std::vector fIterStack;
+};
+
+TClingClassInfo *a;
+class TClingBaseClassInfo {
+  TClingBaseClassInfo() { new TClingClassInfo(*a); }
+};
+
+// expected-no-diagnostics
+
Index: test/Modules/merge-class-definition-visibility.cpp
===
--- test/Modules/merge-class-definition-visibility.cpp
+++ test/Modules/merge-class-definition-visibility.cpp
@@ -1,6 +1,6 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fmodules -fmodule-map-file=%S/Inputs/merge-class-definition-visibility/modmap \
-// RUN:-I%S/Inputs/merge-class-definition-visibility \
+// RUN:-std=c++1z -I%S/Inputs/merge-class-definition-visibility \
 // RUN:-fmodules-cache-path=%t %s -verify \
 // RUN:-fmodules-local-submodule-visibility
 // expected-no-diagnostics
Index: test/Modules/Inputs/merge-class-definition-visibility/c.h
===
--- test/Modules/Inputs/merge-class-definition-visibility/c.h
+++ test/Modules/Inputs/merge-class-definition-visibility/c.h
@@ -1 +1,3 @@
 struct A;
+
+inline int var_A;
Index: test/Modules/Inputs/merge-class-definition-visibility/a.h
===
--- test/Modules/Inputs/merge-class-definition-visibility/a.h
+++ test/Modules/Inputs/merge-class-definition-visibility/a.h
@@ -1 +1,3 @@
 struct A {};
+
+inline int var_A = 2;
Index: test/Modules/Inputs/PR28752/vector
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/vector
@@ -0,0 +1,28 @@
+#ifndef VECTOR
+#define VECTOR
+template  struct B;
+template  struct B { typedef _Tp type; };
+namespace std {
+template  struct D {
+
+  template  struct F {
+static const bool value = 0;
+  };
+
+  template 
+  typename B::value, _Alloc2>::type _S_select(_Alloc2);
+  template 
+  static
+  typename B::value, _Alloc2>::type _S_select(_Alloc2);
+};
+template 
+template 
+const bool D<_Alloc>::F<_Alloc2>::value;
+
+template  class vector {
+public:
+  vector(int);
+  vector(vector &) : vector(D::_S_select((bool)0)) {}
+};
+}
+#endif // VECTOR
\ No newline at end of file
Index: test/Modules/Inputs/PR28752/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/module.modulemap
@@ -0,0 +1 @@
+module a { header "a.h" export * }
Index: test/Modules/Inputs/PR28752/a.h
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/a.h
@@ -0,0 +1 @@
+#include 
Index: test/Modules/Inputs/PR28752/Subdir1/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/Subdir1/module.modulemap
@@ -0,0 +1,5 @@
+module b {
+  module "b.h" { header "b.h" export * }
+  module "c.h" { header "c.h" export * }
+  export *
+}
Index: test/Modules/Inputs/PR28752/Subdir1/b.h
===
--- /dev/null
+++ test/Modules/Inputs/PR28752/Subdir1/b.h
@@ -0,0 +1 @@
+#include 
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -893,6 +893,7 @@
   Record.push_back(D->getStorageClass());
   Record.push_back(D->getTSCSpec());
   Record.push_back(D->getInitStyle());
+  Record.push_back(D->isThisDeclarationADemotedDefinition());
   if (!isa(D))

[PATCH] D25171: clang-format: Add two new formatting options

2016-10-05 Thread Daniel Jasper via cfe-commits
djasper added a comment.

Sorry, but that's actually not enough, at least at first sight. With 37 
contributors total, bro is still quite small and only 12 of them have more than 
a handful of commits. And it doesn't have a real style guide. It has: 
https://www.bro.org/development/contribute.html#coding-guidelines, which 
basically says "adapt to the existing code structure" and "We don’t have many 
strict rules".


https://reviews.llvm.org/D25171



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


[PATCH] D834: Private Headers for Modules

2016-10-05 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.
This revision now requires review to proceed.

Committed in https://reviews.llvm.org/rL184471 and 
https://reviews.llvm.org/rL184472.


https://reviews.llvm.org/D834



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


[PATCH] D25047: [AST] Add a const version of CallExpr::children() (NFC)

2016-10-05 Thread Vedant Kumar via cfe-commits
vsk abandoned this revision.
vsk added a comment.

I no longer need this functionality.


https://reviews.llvm.org/D25047



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


[PATCH] D15075: No error for conflict between inputs\outputs and clobber list

2016-10-05 Thread Reid Kleckner via cfe-commits
rnk added a comment.

You should use git-clang-format or some equivalent to format your change.



> TargetInfo.h:597
> +  StringRef getNormalizedGCCRegisterName(StringRef Name,
> +bool ReturnCanonical = false) const;
>  

format

> TargetInfo.h:600
> +  virtual StringRef getConstraintRegister(const StringRef &Constraint,
> +const StringRef &Expression) const {
> +return "";

format

> TargetInfo.cpp:405
> +TargetInfo::getNormalizedGCCRegisterName(StringRef Name,
> +bool ReturnCanonical) const {
>assert(isValidGCCRegisterName(Name) && "Invalid register passed in");

format

> SemaStmtAsm.cpp:144
> +StringRef ExtractRegisterName(const Expr *Expression, const TargetInfo 
> &Target) {
> +  while (const ImplicitCastExpr *P = dyn_cast(Expression)) 
> {
> +Expression = P->getSubExpr();

This is a reimplementation of Expression->IgnoreImpCasts(), use that instead.

> SemaStmtAsm.cpp:153
> +return Target.isValidGCCRegisterName(Attr->getLabel())
> +? Target.getNormalizedGCCRegisterName(Attr->getLabel(), true)
> +: "";

format

> SemaStmtAsm.cpp:185
> +// Go over the output's registers we collected
> +if (InOutVars.find(Clobber) != InOutVars.end()){
> +  SourceLocation Loc = Clobbers[i]->getLocStart();

This can be InOutVars.count(Clobber), which is more idiomatic for testing set 
membership.

https://reviews.llvm.org/D15075



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


[PATCH] D25171: clang-format: Add two new formatting options

2016-10-05 Thread Daniel Jasper via cfe-commits
djasper added a comment.

It's not about whether or not we like the patch. It's whether adding these 
options is a good trade-off for clang-format overall. If we find that actually 
more people would find these styles desirable, we can reconsider.

I have left some comments anyway in case you want to keep the patch around.



> Format.h:603
>  
> +  /// \brief If ``true``, spaces will be inserted around if/for/while 
> conditions.
> +  bool SpacesAroundConditions;

It's actually more than if/for/while.

> Format.cpp:355
>  IO.mapOptional("SpacesInSquareBrackets", Style.SpacesInSquareBrackets);
> +IO.mapOptional("SpacesAfterNot",
> +   Style.SpacesAfterNot);

Unnecessary linebreaks.

> TokenAnnotator.cpp:1989
> +if (Left.is(tok::l_paren) && Left.Previous &&
> +  Left.Previous->isOneOf(tok::kw_if, tok::pp_elif, tok::kw_for, 
> tok::kw_while,
> + tok::kw_switch, TT_ForEachMacro))

Indent is off.

> TokenAnnotator.cpp:1989-1990
> +if (Left.is(tok::l_paren) && Left.Previous &&
> +  Left.Previous->isOneOf(tok::kw_if, tok::pp_elif, tok::kw_for, 
> tok::kw_while,
> + tok::kw_switch, TT_ForEachMacro))
> +return true;

This should go into a helper function or lambda so that it can be reused. What 
about catch? Also some of these aren't tested, e.g. the preprocessor ones.

> TokenAnnotator.cpp:1993
> +if (Right.is(tok::r_paren) && Right.MatchingParen && 
> Right.MatchingParen->Previous &&
> +  Right.MatchingParen->Previous->isOneOf(tok::kw_if, tok::pp_elif, 
> tok::kw_for, tok::kw_while,
> + tok::kw_switch, 
> TT_ForEachMacro))

Indent is off.

> TokenAnnotator.cpp:2232
>}
> + if (Style.SpacesAfterNot && Left.is(tok::exclaim))
> +return true;

Note that at least JavaScript/TypeScript has a ! postfix operator, i.e. unary 
operator that applies to the token before it. You definitely don't want to 
always add a space after that.

> TokenAnnotator.cpp:2233
> + if (Style.SpacesAfterNot && Left.is(tok::exclaim))
> +return true;
>if (Left.is(TT_UnaryOperator))

Indent is off.

> TokenAnnotator.cpp:2252
>  return false;
> -  if (Right.is(tok::coloncolon) && !Left.isOneOf(tok::l_brace, tok::comment))
> +  if (Right.is(tok::coloncolon) && !Left.isOneOf(tok::l_brace, tok::comment, 
> tok::l_paren))
>  return (Left.is(TT_TemplateOpener) &&

Is this related in any way? I don't see a test with ::

> FormatTest.cpp:11508
> +  Spaces.SpacesAfterNot = true;
> +  verifyFormat("if (! a)\n  return;", Spaces);
> +  verifyFormat("while (! (x || y))\n  return;", Spaces);

While you have added some test here, I think the more debatable ones are 
actually where there is also a space before the !, e.g.:

  if (a && ! b) ..
return ! c;
  bool x = ! y && z;

The last one is especially tricky, because it makes it less clear that ! binds 
stronger than &&. Might seem obvious in this case, but IIRC, we fought quite a 
few bugs of the form:

  if (! a < b) ..

Until a warning was added in Clang.

https://reviews.llvm.org/D25171



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


[PATCH] D24508: PR28752: Do not instantiate var decls which are not visible.

2016-10-05 Thread Richard Smith via cfe-commits
rsmith added a comment.

This looks like it's going in the right direction.



> Decl.cpp:2269-2272
> +  // If we have hit a point where the user provided a specialization of
> +  // this template, we're done looking.
> +  if (VarTemplate->isMemberSpecialization())
> +break;

I think we need a similar check in the static data member case above.

> Decl.cpp:2278
> +!isTemplateInstantiation(getTemplateSpecializationKind())) &&
> +   "couldn't find pattern for enum instantiation");
> +

enum?

> rsmith wrote in SemaTemplate.cpp:509
> `else if` doesn't make sense here -- we either need to produce a diagnostic 
> on all paths through here, or suppress the notes if we didn't produce a 
> diagnostic.

This function still appears to be able to return true (indicating to the caller 
that a diagnostic was produced) without actually producing a diagnostic.

> ASTWriterDecl.cpp:896-897
>Record.push_back(D->getInitStyle());
> +  Record.push_back(D->isThisDeclarationADemotedDefinition());
>if (!isa(D)) {
>  Record.push_back(D->isExceptionVariable());

Sink this flag into the "not for `ParmVarDecl`" block below.

> ASTWriterDecl.cpp:1965
> +  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // TSCSpec
> +  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // InitStyle
> +  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // 
> IsThisDeclarationADemotedDefinition

Hmm. The width of the `InitStyle` field is definitely wrong right now, but 
should be fixed separately from this change. It looks like we don't hit this 
today because we don't use this abbreviation for a variable with an 
initializer. In addition to fixing the width of this field, we should also 
remove the `getInit() == nullptr` check when selecting the abbreviation in 
`ASTDeclWriter::VisitVarDecl`.

https://reviews.llvm.org/D24508



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


[PATCH] D25171: clang-format: Add two new formatting options

2016-10-05 Thread Robin Sommer via cfe-commits
rsmmr added a comment.

Well, last time I counted it was more like 100 contributors---Bro existed 
before GitHub (and before git). The style-guide is lacking, yes ... what can I 
say.

I don't really want to argue about importance of the project. We would like to 
use clang-format here and elsewhere, and I'd think these options could be 
useful to others as well, so I created a patch and submitted. If you guys don't 
like it, your call.


https://reviews.llvm.org/D25171



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


[PATCH] D25264: Implement MS _BitScan intrinsics

2016-10-05 Thread David Majnemer via cfe-commits
majnemer added inline comments.


> agutowski wrote in CGBuiltin.cpp:2665
> Is this line needed? I took it from __builtin_fpclassify, but I don't know 
> what could be its purpose (it's repeated below, where the "bitscan_end" block 
> really starts).

It's needed for the call to CreatePHI to be in the correct basic block.

https://reviews.llvm.org/D25264



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


  1   2   >