[PATCH] D16403: Add scope information to CFG for If/While/For/Do/Compound/CXXRangeFor statements

2017-08-09 Thread Maxim Ostapenko via Phabricator via cfe-commits
m.ostapenko updated this revision to Diff 110329.
m.ostapenko added a comment.

Rebased and ping.


Repository:
  rL LLVM

https://reviews.llvm.org/D16403

Files:
  include/clang/Analysis/AnalysisContext.h
  include/clang/Analysis/CFG.h
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/Analysis/AnalysisDeclContext.cpp
  lib/Analysis/CFG.cpp
  lib/StaticAnalyzer/Core/AnalysisManager.cpp
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  test/Analysis/analyzer-config.c
  test/Analysis/analyzer-config.cpp
  test/Analysis/scopes-cfg-output.cpp

Index: test/Analysis/scopes-cfg-output.cpp
===
--- /dev/null
+++ test/Analysis/scopes-cfg-output.cpp
@@ -0,0 +1,1098 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-scopes=true %s > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
+
+class A {
+public:
+// CHECK:  [B1 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+  A() {}
+
+// CHECK:  [B1 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+  ~A() {}
+
+// CHECK:  [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:  [B1]
+// CHECK-NEXT:   1: CFGScopeBegin(CompoundStmt)
+// CHECK-NEXT:   2: 1
+// CHECK-NEXT:   3: return [B1.2];
+// CHECK-NEXT:   4: CFGScopeEnd(ReturnStmt)
+// CHECK-NEXT:   Preds (1): B2
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+  operator int() const { return 1; }
+};
+
+int getX();
+extern const bool UV;
+
+// CHECK:  [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:  [B1]
+// CHECK-NEXT:   1: CFGScopeBegin(CompoundStmt)
+// CHECK-NEXT:   2:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   3: A a;
+// CHECK-NEXT:   4: a
+// CHECK-NEXT:   5: [B1.4] (ImplicitCastExpr, NoOp, const class A)
+// CHECK-NEXT:   6: const A &b = a;
+// CHECK-NEXT:   7: A() (CXXConstructExpr, class A)
+// CHECK-NEXT:   8: [B1.7] (BindTemporary)
+// CHECK-NEXT:   9: [B1.8] (ImplicitCastExpr, NoOp, const class A)
+// CHECK-NEXT:  10: [B1.9]
+// CHECK-NEXT:  11: const A &c = A();
+// CHECK-NEXT:  12: [B1.11].~A() (Implicit destructor)
+// CHECK-NEXT:  13: [B1.3].~A() (Implicit destructor)
+// CHECK-NEXT:  14: CFGScopeEnd(CompoundStmt)
+// CHECK-NEXT:   Preds (1): B2
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+void test_const_ref() {
+  A a;
+  const A& b = a;
+  const A& c = A();
+}
+
+// CHECK:  [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:  [B1]
+// CHECK-NEXT:   1: CFGScopeBegin(CompoundStmt)
+// CHECK-NEXT:   2:  (CXXConstructExpr, class A [2])
+// CHECK-NEXT:   3: A a[2];
+// CHECK-NEXT:   4:  (CXXConstructExpr, class A [0])
+// CHECK-NEXT:   5: A b[0];
+// CHECK-NEXT:   6: [B1.3].~A() (Implicit destructor)
+// CHECK-NEXT:   7: CFGScopeEnd(CompoundStmt)
+// CHECK-NEXT:   Preds (1): B2
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+void test_array() {
+  A a[2];
+  A b[0];
+}
+
+// CHECK:  [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:  [B1]
+// CHECK-NEXT:   1: CFGScopeBegin(CompoundStmt)
+// CHECK-NEXT:   2:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   3: A a;
+// CHECK-NEXT:   4: CFGScopeBegin(CompoundStmt)
+// CHECK-NEXT:   5:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   6: A c;
+// CHECK-NEXT:   7:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   8: A d;
+// CHECK-NEXT:   9: [B1.8].~A() (Implicit destructor)
+// CHECK-NEXT:  10: [B1.6].~A() (Implicit destructor)
+// CHECK-NEXT:  11: CFGScopeEnd(CompoundStmt)
+// CHECK-NEXT:  12:  (CXXConstructExpr, class A)
+// CHECK-NEXT:  13: A b;
+// CHECK-NEXT:  14: [B1.13].~A() (Implicit destructor)
+// CHECK-NEXT:  15: [B1.3].~A() (Implicit destructor)
+// CHECK-NEXT:  16: CFGScopeEnd(CompoundStmt)
+// CHECK-NEXT:   Preds (1): B2
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+void test_scope() {
+  A a;
+  { A c;
+A d;
+  }
+  A b;
+}
+
+// CHECK:  [B4 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B3
+// CHECK:  [B1]
+// CHECK-NEXT:   1:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   2: A c;
+// CHECK-NEXT:   3: [B1.2].~A() (Implicit destructor)
+// CHECK-NEXT:   4: [B3.5].~A() (Implicit destructor)
+// CHECK-NEXT:   5: [B3.3].~A() (Implicit destructor)
+// CHECK-NEXT:   6: CFGScopeEnd(CompoundStmt)
+// CHECK-NEXT:   Preds (1): B3
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B2]
+// CHECK-NEXT:   1: CFGScopeBegin(IfStmt)
+// CHECK-NEXT:   2: return;
+// CHECK-NEXT:   3: [B3.5].~A() (Implicit destructor)
+// CHECK-NEXT:   4: [B3.3].~A() (Implicit destructor)
+// CHECK-NEXT:   5: CFGScopeEnd(ReturnStmt)
+// CHECK-NEXT:   Preds (1): B3
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B3]
+// CHECK-NEXT:   1: CFGScopeBegin(CompoundStmt

Re: [PATCH] D36386: [clang] Remove unit test which uses reverse-iterate and fix a PointerLikeTypeTrait specialization

2017-08-09 Thread Grang, Mandeep Singh via cfe-commits
In D35043 I have removed the llvm tests which use -reverse-iterate. This 
patch removes the clang tests.


Should I post a later patch to change all "class PointerLikeTypeTraits" 
to "struct PointerLikeTypeTraits"?


On 8/7/2017 2:50 PM, David Blaikie wrote:



On Mon, Aug 7, 2017 at 12:08 PM Mandeep Singh Grang via Phabricator 
mailto:revi...@reviews.llvm.org>> wrote:


mgrang added a comment.

This patch does 3 things:

1. Get rid of the unit test objc-modern-metadata-visibility2.mm
 because this test
check uses flag -reverse-iterate. This flag will be removed in
https://reviews.llvm.org/D35043.


Sure - please commit that separately (probably once D35043 is approved 
- probably best to include that removal in D35043, or a separate patch 
that /only/ removes the -reverse-iterate flag (& any tests that use 
it) as a standalone change?).


Does this test need a replacement? If this test is removed and the 
underlying issue it was testing regresses, will one of the buildbots 
(reverse or normal) catch the problem?


2. https://reviews.llvm.org/D35043 gets rid of the empty base
definition for PointerLikeTypeTraits. This results in a compiler
warning because PointerLikeTypeTrait has been defined as struct
here while in the header it is a class. So I have changed struct
to class.


I'd probably go the other way - traits classes like this make more 
sense as structs, I think - it only has public members & no 
implementation really has any need for supporting private members.


3. Since I changed struct PointerLikeTypeTrait to class
PointerLikeTypeTrait here, the member functions are no longer
public now. This results in a compiler error. So I explicitly
marked them as public here.


https://reviews.llvm.org/D36386





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


[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-09 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

In https://reviews.llvm.org/D35955#835994, @euhlmann wrote:

> In https://reviews.llvm.org/D35955#835439, @klimek wrote:
>
> > I think if we need this info, we can just make it count down to -1 again 
> > (or, but that's isomorphic, let it run from 0 and make sure we never index 
> > into the data structures at 0 :)
>
>
> Should I do one of these things? Let me know how you'd like me to implement 
> this.


So my suggestion would be to let it count down to -1 again and put a check 
around indexing into the data structures.


https://reviews.llvm.org/D35955



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


r310449 - [Sema] Extend -Wenum-compare to handle mixed enum comparisons in switch statements

2017-08-09 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Wed Aug  9 01:57:09 2017
New Revision: 310449

URL: http://llvm.org/viewvc/llvm-project?rev=310449&view=rev
Log:
[Sema] Extend -Wenum-compare to handle mixed enum comparisons in switch 
statements

Patch by: Reka Nikolett Kovacs

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

Modified:
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/Sema/switch.c
cfe/trunk/test/SemaCXX/warn-enum-compare.cpp

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=310449&r1=310448&r2=310449&view=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Aug  9 01:57:09 2017
@@ -602,14 +602,14 @@ static bool EqEnumVals(const std::pair(expr))
-expr = cleanups->getSubExpr();
-  while (ImplicitCastExpr *impcast = dyn_cast(expr)) {
-if (impcast->getCastKind() != CK_IntegralCast) break;
-expr = impcast->getSubExpr();
+static QualType GetTypeBeforeIntegralPromotion(const Expr *&E) {
+  if (const auto *CleanUps = dyn_cast(E))
+E = CleanUps->getSubExpr();
+  while (const auto *ImpCast = dyn_cast(E)) {
+if (ImpCast->getCastKind() != CK_IntegralCast) break;
+E = ImpCast->getSubExpr();
   }
-  return expr->getType();
+  return E->getType();
 }
 
 ExprResult Sema::CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond) {
@@ -743,6 +743,24 @@ static bool ShouldDiagnoseSwitchCaseNotI
   return true;
 }
 
+static void checkEnumTypesInSwitchStmt(Sema &S, const Expr *Cond,
+   const Expr *Case) {
+  QualType CondType = GetTypeBeforeIntegralPromotion(Cond);
+  QualType CaseType = Case->getType();
+
+  const EnumType *CondEnumType = CondType->getAs();
+  const EnumType *CaseEnumType = CaseType->getAs();
+  if (!CondEnumType || !CaseEnumType)
+return;
+
+  if (S.Context.hasSameUnqualifiedType(CondType, CaseType))
+return;
+
+  S.Diag(Case->getExprLoc(), diag::warn_comparison_of_mixed_enum_types)
+  << CondType << CaseType << Cond->getSourceRange()
+  << Case->getSourceRange();
+}
+
 StmtResult
 Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
 Stmt *BodyStmt) {
@@ -760,7 +778,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocati
 
   QualType CondType = CondExpr->getType();
 
-  Expr *CondExprBeforePromotion = CondExpr;
+  const Expr *CondExprBeforePromotion = CondExpr;
   QualType CondTypeBeforePromotion =
   GetTypeBeforeIntegralPromotion(CondExprBeforePromotion);
 
@@ -843,6 +861,8 @@ Sema::ActOnFinishSwitchStmt(SourceLocati
 break;
   }
 
+  checkEnumTypesInSwitchStmt(*this, CondExpr, Lo);
+
   llvm::APSInt LoVal;
 
   if (getLangOpts().CPlusPlus11) {

Modified: cfe/trunk/test/Sema/switch.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/switch.c?rev=310449&r1=310448&r2=310449&view=diff
==
--- cfe/trunk/test/Sema/switch.c (original)
+++ cfe/trunk/test/Sema/switch.c Wed Aug  9 01:57:09 2017
@@ -372,6 +372,7 @@ void switch_on_ExtendedEnum1(enum Extend
   case EE1_b: break;
   case EE1_c: break; // no-warning
   case EE1_d: break; // expected-warning {{case value not in enumerated type 
'enum ExtendedEnum1'}}
+  // expected-warning@-1 {{comparison of two values with different enumeration 
types ('enum ExtendedEnum1' and 'const enum ExtendedEnum1_unrelated')}}
   }
 }
 

Modified: cfe/trunk/test/SemaCXX/warn-enum-compare.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-enum-compare.cpp?rev=310449&r1=310448&r2=310449&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-enum-compare.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-enum-compare.cpp Wed Aug  9 01:57:09 2017
@@ -209,4 +209,21 @@ void test () {
   while (getBar() > x); // expected-warning  {{comparison of two values with 
different enumeration types ('Bar' and 'Foo')}}
   while (getBar() < x); // expected-warning  {{comparison of two values with 
different enumeration types ('Bar' and 'Foo')}}
 
+  switch (a) {
+case name1::F1: break;
+case name1::F3: break;
+case name2::B2: break; // expected-warning {{comparison of two values with 
different enumeration types ('name1::Foo' and 'name2::Baz')}}
+  }
+
+  switch (x) {
+case FooB: break;
+case FooC: break;
+case BarD: break; // expected-warning {{comparison of two values with 
different enumeration types ('Foo' and 'Bar')}}
+  }
+
+  switch(getBar()) {
+case BarE: break;
+case BarF: break;
+case FooA: break; // expected-warning {{comparison of two values with 
different enumeration types ('Bar' and 'Foo')}}
+  }
 }


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

[PATCH] D36407: [Sema] Extend -Wenum-compare to handle mixed enum comparisons in switch statements

2017-08-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310449: [Sema] Extend -Wenum-compare to handle mixed enum 
comparisons in switch… (authored by xazax).

Changed prior to commit:
  https://reviews.llvm.org/D36407?vs=110219&id=110333#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36407

Files:
  cfe/trunk/lib/Sema/SemaStmt.cpp
  cfe/trunk/test/Sema/switch.c
  cfe/trunk/test/SemaCXX/warn-enum-compare.cpp

Index: cfe/trunk/test/SemaCXX/warn-enum-compare.cpp
===
--- cfe/trunk/test/SemaCXX/warn-enum-compare.cpp
+++ cfe/trunk/test/SemaCXX/warn-enum-compare.cpp
@@ -209,4 +209,21 @@
   while (getBar() > x); // expected-warning  {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
   while (getBar() < x); // expected-warning  {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
 
+  switch (a) {
+case name1::F1: break;
+case name1::F3: break;
+case name2::B2: break; // expected-warning {{comparison of two values with different enumeration types ('name1::Foo' and 'name2::Baz')}}
+  }
+
+  switch (x) {
+case FooB: break;
+case FooC: break;
+case BarD: break; // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+  }
+
+  switch(getBar()) {
+case BarE: break;
+case BarF: break;
+case FooA: break; // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+  }
 }
Index: cfe/trunk/test/Sema/switch.c
===
--- cfe/trunk/test/Sema/switch.c
+++ cfe/trunk/test/Sema/switch.c
@@ -372,6 +372,7 @@
   case EE1_b: break;
   case EE1_c: break; // no-warning
   case EE1_d: break; // expected-warning {{case value not in enumerated type 'enum ExtendedEnum1'}}
+  // expected-warning@-1 {{comparison of two values with different enumeration types ('enum ExtendedEnum1' and 'const enum ExtendedEnum1_unrelated')}}
   }
 }
 
Index: cfe/trunk/lib/Sema/SemaStmt.cpp
===
--- cfe/trunk/lib/Sema/SemaStmt.cpp
+++ cfe/trunk/lib/Sema/SemaStmt.cpp
@@ -602,14 +602,14 @@
 
 /// GetTypeBeforeIntegralPromotion - Returns the pre-promotion type of
 /// potentially integral-promoted expression @p expr.
-static QualType GetTypeBeforeIntegralPromotion(Expr *&expr) {
-  if (ExprWithCleanups *cleanups = dyn_cast(expr))
-expr = cleanups->getSubExpr();
-  while (ImplicitCastExpr *impcast = dyn_cast(expr)) {
-if (impcast->getCastKind() != CK_IntegralCast) break;
-expr = impcast->getSubExpr();
+static QualType GetTypeBeforeIntegralPromotion(const Expr *&E) {
+  if (const auto *CleanUps = dyn_cast(E))
+E = CleanUps->getSubExpr();
+  while (const auto *ImpCast = dyn_cast(E)) {
+if (ImpCast->getCastKind() != CK_IntegralCast) break;
+E = ImpCast->getSubExpr();
   }
-  return expr->getType();
+  return E->getType();
 }
 
 ExprResult Sema::CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond) {
@@ -743,6 +743,24 @@
   return true;
 }
 
+static void checkEnumTypesInSwitchStmt(Sema &S, const Expr *Cond,
+   const Expr *Case) {
+  QualType CondType = GetTypeBeforeIntegralPromotion(Cond);
+  QualType CaseType = Case->getType();
+
+  const EnumType *CondEnumType = CondType->getAs();
+  const EnumType *CaseEnumType = CaseType->getAs();
+  if (!CondEnumType || !CaseEnumType)
+return;
+
+  if (S.Context.hasSameUnqualifiedType(CondType, CaseType))
+return;
+
+  S.Diag(Case->getExprLoc(), diag::warn_comparison_of_mixed_enum_types)
+  << CondType << CaseType << Cond->getSourceRange()
+  << Case->getSourceRange();
+}
+
 StmtResult
 Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
 Stmt *BodyStmt) {
@@ -760,7 +778,7 @@
 
   QualType CondType = CondExpr->getType();
 
-  Expr *CondExprBeforePromotion = CondExpr;
+  const Expr *CondExprBeforePromotion = CondExpr;
   QualType CondTypeBeforePromotion =
   GetTypeBeforeIntegralPromotion(CondExprBeforePromotion);
 
@@ -843,6 +861,8 @@
 break;
   }
 
+  checkEnumTypesInSwitchStmt(*this, CondExpr, Lo);
+
   llvm::APSInt LoVal;
 
   if (getLangOpts().CPlusPlus11) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34324: [clang-format] let PointerAlignment dictate spacing of function ref qualifiers

2017-08-09 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good. Thank you!


https://reviews.llvm.org/D34324



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


r310458 - [clang-format] Put '/**' and '*/' on own lines in jsdocs ending in comment pragmas

2017-08-09 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Wed Aug  9 02:42:32 2017
New Revision: 310458

URL: http://llvm.org/viewvc/llvm-project?rev=310458&view=rev
Log:
[clang-format] Put '/**' and '*/' on own lines in jsdocs ending in comment 
pragmas

Summary:
This handles a case where the trailing '*/' of a multiline jsdoc eding in a
comment pragma wouldn't be put on a new line.

Reviewers: mprobst

Reviewed By: mprobst

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/lib/Format/BreakableToken.cpp
cfe/trunk/lib/Format/BreakableToken.h
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/BreakableToken.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.cpp?rev=310458&r1=310457&r2=310458&view=diff
==
--- cfe/trunk/lib/Format/BreakableToken.cpp (original)
+++ cfe/trunk/lib/Format/BreakableToken.cpp Wed Aug  9 02:42:32 2017
@@ -681,12 +681,18 @@ void BreakableBlockComment::replaceWhite
   InPPDirective, /*Newlines=*/1, ContentColumn[LineIndex] - Prefix.size());
 }
 
-BreakableToken::Split BreakableBlockComment::getSplitAfterLastLine(
-unsigned TailOffset, unsigned ColumnLimit,
-llvm::Regex &CommentPragmasRegex) const {
-  if (DelimitersOnNewline)
-return getSplit(Lines.size() - 1, TailOffset, ColumnLimit,
-CommentPragmasRegex);
+BreakableToken::Split
+BreakableBlockComment::getSplitAfterLastLine(unsigned TailOffset,
+ unsigned ColumnLimit) const {
+  if (DelimitersOnNewline) {
+// Replace the trailing whitespace of the last line with a newline.
+// In case the last line is empty, the ending '*/' is already on its own
+// line.
+StringRef Line = Content.back().substr(TailOffset);
+StringRef TrimmedLine = Line.rtrim(Blanks);
+if (!TrimmedLine.empty())
+  return Split(TrimmedLine.size(), Line.size() - TrimmedLine.size());
+  }
   return Split(StringRef::npos, 0);
 }
 

Modified: cfe/trunk/lib/Format/BreakableToken.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.h?rev=310458&r1=310457&r2=310458&view=diff
==
--- cfe/trunk/lib/Format/BreakableToken.h (original)
+++ cfe/trunk/lib/Format/BreakableToken.h Wed Aug  9 02:42:32 2017
@@ -161,8 +161,8 @@ public:
   ///
   /// A result having offset == StringRef::npos means that no reformat is
   /// necessary.
-  virtual Split getSplitAfterLastLine(unsigned TailOffset, unsigned 
ColumnLimit,
-  llvm::Regex &CommentPragmasRegex) const {
+  virtual Split getSplitAfterLastLine(unsigned TailOffset,
+  unsigned ColumnLimit) const {
 return Split(StringRef::npos, 0);
   }
 
@@ -347,8 +347,8 @@ public:
   void replaceWhitespaceBefore(unsigned LineIndex, unsigned PreviousEndColumn,
unsigned ColumnLimit, Split SplitBefore,
WhitespaceManager &Whitespaces) override;
-  Split getSplitAfterLastLine(unsigned TailOffset, unsigned ColumnLimit,
-  llvm::Regex &CommentPragmasRegex) const override;
+  Split getSplitAfterLastLine(unsigned TailOffset,
+  unsigned ColumnLimit) const override;
 
   bool mayReflow(unsigned LineIndex,
  llvm::Regex &CommentPragmasRegex) const override;

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=310458&r1=310457&r2=310458&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Wed Aug  9 02:42:32 2017
@@ -1383,8 +1383,8 @@ unsigned ContinuationIndenter::breakProt
 }
   }
 
-  BreakableToken::Split SplitAfterLastLine = Token->getSplitAfterLastLine(
-  TailOffset, ColumnLimit, CommentPragmasRegex);
+  BreakableToken::Split SplitAfterLastLine =
+  Token->getSplitAfterLastLine(TailOffset, ColumnLimit);
   if (SplitAfterLastLine.first != StringRef::npos) {
 if (!DryRun)
   Token->replaceWhitespaceAfterLastLine(TailOffset, SplitAfterLastLine,

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=310458&r1=310457&r2=310458&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Wed Aug  9 02:42:32 2017
@@ -158,6 +158,53 @@ TEST_F(FormatTestJS, JSDocComments) {
"var x = 1;\n"
"}",
get

[PATCH] D36359: [clang-format] Put '/**' and '*/' on own lines in jsdocs ending in comment pragmas

2017-08-09 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310458: [clang-format] Put '/**' and '*/' on own lines in 
jsdocs ending in comment… (authored by krasimir).

Repository:
  rL LLVM

https://reviews.llvm.org/D36359

Files:
  cfe/trunk/lib/Format/BreakableToken.cpp
  cfe/trunk/lib/Format/BreakableToken.h
  cfe/trunk/lib/Format/ContinuationIndenter.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp

Index: cfe/trunk/lib/Format/BreakableToken.h
===
--- cfe/trunk/lib/Format/BreakableToken.h
+++ cfe/trunk/lib/Format/BreakableToken.h
@@ -161,8 +161,8 @@
   ///
   /// A result having offset == StringRef::npos means that no reformat is
   /// necessary.
-  virtual Split getSplitAfterLastLine(unsigned TailOffset, unsigned ColumnLimit,
-  llvm::Regex &CommentPragmasRegex) const {
+  virtual Split getSplitAfterLastLine(unsigned TailOffset,
+  unsigned ColumnLimit) const {
 return Split(StringRef::npos, 0);
   }
 
@@ -347,8 +347,8 @@
   void replaceWhitespaceBefore(unsigned LineIndex, unsigned PreviousEndColumn,
unsigned ColumnLimit, Split SplitBefore,
WhitespaceManager &Whitespaces) override;
-  Split getSplitAfterLastLine(unsigned TailOffset, unsigned ColumnLimit,
-  llvm::Regex &CommentPragmasRegex) const override;
+  Split getSplitAfterLastLine(unsigned TailOffset,
+  unsigned ColumnLimit) const override;
 
   bool mayReflow(unsigned LineIndex,
  llvm::Regex &CommentPragmasRegex) const override;
Index: cfe/trunk/lib/Format/BreakableToken.cpp
===
--- cfe/trunk/lib/Format/BreakableToken.cpp
+++ cfe/trunk/lib/Format/BreakableToken.cpp
@@ -681,12 +681,18 @@
   InPPDirective, /*Newlines=*/1, ContentColumn[LineIndex] - Prefix.size());
 }
 
-BreakableToken::Split BreakableBlockComment::getSplitAfterLastLine(
-unsigned TailOffset, unsigned ColumnLimit,
-llvm::Regex &CommentPragmasRegex) const {
-  if (DelimitersOnNewline)
-return getSplit(Lines.size() - 1, TailOffset, ColumnLimit,
-CommentPragmasRegex);
+BreakableToken::Split
+BreakableBlockComment::getSplitAfterLastLine(unsigned TailOffset,
+ unsigned ColumnLimit) const {
+  if (DelimitersOnNewline) {
+// Replace the trailing whitespace of the last line with a newline.
+// In case the last line is empty, the ending '*/' is already on its own
+// line.
+StringRef Line = Content.back().substr(TailOffset);
+StringRef TrimmedLine = Line.rtrim(Blanks);
+if (!TrimmedLine.empty())
+  return Split(TrimmedLine.size(), Line.size() - TrimmedLine.size());
+  }
   return Split(StringRef::npos, 0);
 }
 
Index: cfe/trunk/lib/Format/ContinuationIndenter.cpp
===
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp
@@ -1383,8 +1383,8 @@
 }
   }
 
-  BreakableToken::Split SplitAfterLastLine = Token->getSplitAfterLastLine(
-  TailOffset, ColumnLimit, CommentPragmasRegex);
+  BreakableToken::Split SplitAfterLastLine =
+  Token->getSplitAfterLastLine(TailOffset, ColumnLimit);
   if (SplitAfterLastLine.first != StringRef::npos) {
 if (!DryRun)
   Token->replaceWhitespaceAfterLastLine(TailOffset, SplitAfterLastLine,
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -158,6 +158,53 @@
"var x = 1;\n"
"}",
getGoogleJSStyleWithColumns(20)));
+
+  // Don't break the first line of a single line short jsdoc comment pragma.
+  EXPECT_EQ("/** @returns j */",
+format("/** @returns j */",
+   getGoogleJSStyleWithColumns(20)));
+
+  // Break a single line long jsdoc comment pragma.
+  EXPECT_EQ("/**\n"
+" * @returns {string} jsdoc line 12\n"
+" */",
+format("/** @returns {string} jsdoc line 12 */",
+   getGoogleJSStyleWithColumns(20)));
+
+  EXPECT_EQ("/**\n"
+" * @returns {string} jsdoc line 12\n"
+" */",
+format("/** @returns {string} jsdoc line 12  */",
+   getGoogleJSStyleWithColumns(20)));
+
+  EXPECT_EQ("/**\n"
+" * @returns {string} jsdoc line 12\n"
+" */",
+format("/** @returns {string} jsdoc line 12*/",
+   getGoogleJSStyleWithColumns(20)));
+
+  // Fix a multiline jsdoc comment ending in a comment pragma.
+  EXPECT_EQ("/**\n"
+" * line 1\n"
+" * line 2\n"
+

[PATCH] D35355: Fix templated type alias completion when using global completion cache

2017-08-09 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D35355



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


[PATCH] D34331: func.wrap.func.con: Unset function before destroying anything

2017-08-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

The tests actually do compile in C++03, but they still fail because of infinite 
recursion:

  frame #196562: 0x0001155c 
nullptr_t_assign_reentrant.pass.cpp.exe`A::~A() + 92
  frame #196563: 0x00011405 
nullptr_t_assign_reentrant.pass.cpp.exe`std::__1::__compressed_pair_elem::~__compressed_pair_elem() + 21
  frame #196564: 0x00012685 
nullptr_t_assign_reentrant.pass.cpp.exe`std::__1::__compressed_pair >::~__compressed_pair() + 21
  frame #196565: 0x00012665 
nullptr_t_assign_reentrant.pass.cpp.exe`std::__1::__compressed_pair >::~__compressed_pair() + 21
  frame #196566: 0x00012389 
nullptr_t_assign_reentrant.pass.cpp.exe`std::__1::__function::__func, void ()>::destroy() + 25
  frame #196567: 0x000114b9 
nullptr_t_assign_reentrant.pass.cpp.exe`std::__1::function::operator=(std::__1::nullptr_t) + 57
  frame #196568: 0x0001155c 
nullptr_t_assign_reentrant.pass.cpp.exe`A::~A() + 92

Looks like prior to C++11 some different destruction behaviour is triggered 
which isn't fixed by this patch. So the tests should be either guarded by 
`UNSUPPORTED/XFAIL` or the patch should support C++03.


https://reviews.llvm.org/D34331



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


[PATCH] D34331: func.wrap.func.con: Unset function before destroying anything

2017-08-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

If you look at the AST diff between C++11 and C++03 this error still happens 
because of how `nullptr` is processed:

C++11:

  | |-CXXDestructorDecl 0x7fdab27a2498  line:24:3 used ~A 
'void (void) noexcept'
  | | `-CompoundStmt 0x7fdab27bcfb8 
  | |   |-GCCAsmStmt 0x7fdab27a2670 
  | |   `-IfStmt 0x7fdab27bcf88 
  | | |-<<>>
  | | |-ImplicitCastExpr 0x7fdab27a26e0  '_Bool' 
  | | | `-DeclRefExpr 0x7fdab27a26b8  '_Bool' lvalue Var 
0x7fdab27a23b8 'cancel' '_Bool'
  | | |-CXXOperatorCallExpr 0x7fdab27bcf40  'class 
std::__1::function' lvalue
  | | | |-ImplicitCastExpr 0x7fdab27bcf28  'class 
std::__1::function &(*)(nullptr_t) noexcept' 

  | | | | `-DeclRefExpr 0x7fdab27bcea0  'class 
std::__1::function &(nullptr_t) noexcept' lvalue CXXMethod 
0x7fdab27ab010 'operator=' 'class std::__1::function &(nullptr_t) 
noexcept'
  | | | |-DeclRefExpr 0x7fdab27a26f8  'std::function':'class std::__1::function' lvalue Var 0x7fdab27a2348 
'global' 'std::function':'class std::__1::function'
  | | | `-CXXNullPtrLiteralExpr 0x7fdab27a2720  'nullptr_t'
  | | `-<<>>

vs C++03:

  | |-CXXDestructorDecl 0x7fc72b6d80d8  line:24:3 used ~A 
'void (void)'
  | | `-CompoundStmt 0x7fc72b6dfd88 
  | |   |-GCCAsmStmt 0x7fc72b6d82a0 
  | |   `-IfStmt 0x7fc72b6dfd58 
  | | |-<<>>
  | | |-ImplicitCastExpr 0x7fc72b6d8310 

 '_Bool' 
  | | | `-DeclRefExpr 0x7fc72b6d82e8  '_Bool' lvalue Var 
0x7fc72b6d8028 'cancel' '_Bool'
  | | |-CXXOperatorCallExpr 0x7fc72b6dfd10  
'class std::__1::function' lvalue
  | | | |-ImplicitCastExpr 0x7fc72b6dfcf8 

 'class std::__1::function &(*)(struct std::__1::nullptr_t)' 

  | | | | `-DeclRefExpr 0x7fc72b6dfca0  'class 
std::__1::function &(struct std::__1::nullptr_t)' lvalue CXXMethod 
0x7fc72b6daea0 'operator=' 'class std::__1::function &(struct 
std::__1::nullptr_t)'
  | | | |-DeclRefExpr 0x7fc72b6d8328  'std::function':'class std::__1::function' lvalue Var 0x7fc72b6d7fb8 
'global' 'std::function':'class std::__1::function'
  | | | `-CXXConstructExpr 0x7fc72b6dfc68 
 
'struct std::__1::nullptr_t' 'void (const struct std::__1::nullptr_t &) 
throw()' elidable
  | | |   `-MaterializeTemporaryExpr 0x7fc72b6dfc50 
 
'const struct std::__1::nullptr_t' lvalue
  | | | `-ImplicitCastExpr 0x7fc72b6dfc38 
 
'const struct std::__1::nullptr_t' 
  | | |   `-CallExpr 0x7fc72b6d83d0 
 
'struct std::__1::nullptr_t'
  | | | `-ImplicitCastExpr 0x7fc72b6d83b8 
 
'struct std::__1::nullptr_t (*)(void)' 
  | | |   `-DeclRefExpr 0x7fc72b6d8380 
 
'struct std::__1::nullptr_t (void)' lvalue Function 0x7fc72b08d340 
'__get_nullptr_t' 'struct std::__1::nullptr_t (void)'
  | | `-<<>>


https://reviews.llvm.org/D34331



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


[PATCH] D34331: func.wrap.func.con: Unset function before destroying anything

2017-08-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Ah, I got it. There's a `__functional_03` header that seems to implement 
`function` for C++03 because of manual variadic template expansions.
You have to update the operators in the header as well.


https://reviews.llvm.org/D34331



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


[PATCH] D36179: [clang-diff] Move printing of matches and changes to clang-diff

2017-08-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Previous `Move` resulted in `llvm_unreachable("TODO");`, but now it seems to be 
fixed. The new output for `Move` and `UpdateMove` should be tested in a test.


https://reviews.llvm.org/D36179



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


[PATCH] D36180: [clang-diff] Add option to dump the AST, one node per line

2017-08-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D36180



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


[PATCH] D36364: [AArch64] Add support for a MinGW AArch64 target

2017-08-09 Thread Martell Malone via Phabricator via cfe-commits
martell accepted this revision.
martell added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D36364



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


[PATCH] D36182: [clang-diff] Add HTML side-by-side diff output

2017-08-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: test/Tooling/clang-diff-html.py:1
+# RUN: clang-diff %S/Inputs/clang-diff-basic-src.cpp %S/clang-diff-basic.cpp 
-html -- | %python %s > %t.filecheck
+# RUN: clang-diff %S/Inputs/clang-diff-basic-src.cpp %S/clang-diff-basic.cpp 
-dump-matches -- | FileCheck %t.filecheck

Why did you decide to use a python script for this? Can you just file check the 
HTML output directly, or do you think this is better?


https://reviews.llvm.org/D36182



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


[PATCH] D36183: [clang-diff] Simplify mapping

2017-08-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: include/clang/Tooling/ASTDiff/ASTDiff.h:114
 
-  /// If this is set to true, nodes that have parents that must not be matched
-  /// (see NodeComparison) will be allowed to be matched.
-  bool EnableMatchingWithUnmatchableParents = false;
+  bool StopAfterTopDown = false;
 

It doesn't look like this field is used in this patch, please remove it or move 
it to a different patch.


https://reviews.llvm.org/D36183



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


[PATCH] D36184: [clang-diff] Filter AST nodes

2017-08-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Tooling/ASTDiff/ASTDiff.cpp:177
+static bool isDeclExcluded(const Decl *D) { return D->isImplicit(); }
+static bool isStmtExcluded(const Stmt *S) { return false; }
+

You should just use one call  `isNodeExcluded` that will redirect to 
node-specific overload, and avoid the multiple clauses in conditions, i.e..:

```
static bool isSpecializedNodeExcluded(const Decl *D) { }
static bool isSpecializedNodeExcluded(const Stmt *S) {}

template 
static bool isNodeExcluded(const SourceManager &SrcMgr, T *N) {
    current code ...
   return isSpecializedNodeExcluded(N);
}
```

Then you can use `if (isNodeExcluded(Tree.AST.getSourceManager(), D))` 
everywhere.


https://reviews.llvm.org/D36184



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


[PATCH] D36450: [X86][Ms-InlineAsm] Extend MS Dot operator to accept "this" + struct/class pointers aliases

2017-08-09 Thread coby via Phabricator via cfe-commits
coby added inline comments.



Comment at: lib/Sema/SemaStmtAsm.cpp:702-705
+  // MS InlineAsm often uses struct pointer aliases as a base
+  const QualType QT = TD->getUnderlyingType();
+  RT = isa(QT) ? QT->getPointeeType()->getAs() :
+  QT->getAs();

rnk wrote:
> This would probably be simpler as:
>   QualType Ty = TD->getUnderlyingType();
>   if (const auto *PT = Ty->getAs())
> Ty = PT->getPointeeType();
>   RT = Ty->getAsRecordType();
> ... to avoid repeating getAs().
Indeed. thx for pointing it out!


Repository:
  rL LLVM

https://reviews.llvm.org/D36450



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


[PATCH] D36458: Fix crash when current lexer is nullptr

2017-08-09 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer added a comment.

Changes like this should come with a small, c-index-test based, test case so we 
don't reintroduce the same bug in the future.


https://reviews.llvm.org/D36458



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


r310464 - Revert "PR19668, PR23034: Fix handling of move constructors and deleted copy constructors when deciding whether classes should be passed indirectly."

2017-08-09 Thread Diana Picus via cfe-commits
Author: rovka
Date: Wed Aug  9 05:22:25 2017
New Revision: 310464

URL: http://llvm.org/viewvc/llvm-project?rev=310464&view=rev
Log:
Revert "PR19668, PR23034: Fix handling of move constructors and deleted copy 
constructors when deciding whether classes should be passed indirectly."

This reverts commit r310401 because it seems to have broken some ARM
bot(s).

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/CodeGen/CGCXXABI.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310464&r1=310463&r2=310464&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Wed Aug  9 05:22:25 2017
@@ -375,7 +375,6 @@ class CXXRecordDecl : public RecordDecl
 /// \brief These flags are \c true if a defaulted corresponding special
 /// member can't be fully analyzed without performing overload resolution.
 /// @{
-unsigned NeedOverloadResolutionForCopyConstructor : 1;
 unsigned NeedOverloadResolutionForMoveConstructor : 1;
 unsigned NeedOverloadResolutionForMoveAssignment : 1;
 unsigned NeedOverloadResolutionForDestructor : 1;
@@ -384,7 +383,6 @@ class CXXRecordDecl : public RecordDecl
 /// \brief These flags are \c true if an implicit defaulted corresponding
 /// special member would be defined as deleted.
 /// @{
-unsigned DefaultedCopyConstructorIsDeleted : 1;
 unsigned DefaultedMoveConstructorIsDeleted : 1;
 unsigned DefaultedMoveAssignmentIsDeleted : 1;
 unsigned DefaultedDestructorIsDeleted : 1;
@@ -417,12 +415,6 @@ class CXXRecordDecl : public RecordDecl
 /// constructor.
 unsigned HasDefaultedDefaultConstructor : 1;
 
-/// \brief True if this class can be passed in a non-address-preserving
-/// fashion (such as in registers) according to the C++ language rules.
-/// This does not imply anything about how the ABI in use will actually
-/// pass an object of this class.
-unsigned CanPassInRegisters : 1;
-
 /// \brief True if a defaulted default constructor for this class would
 /// be constexpr.
 unsigned DefaultedDefaultConstructorIsConstexpr : 1;
@@ -819,50 +811,18 @@ public:
 return data().FirstFriend.isValid();
   }
 
-  /// \brief \c true if a defaulted copy constructor for this class would be
-  /// deleted.
-  bool defaultedCopyConstructorIsDeleted() const {
-assert((!needsOverloadResolutionForCopyConstructor() ||
-(data().DeclaredSpecialMembers & SMF_CopyConstructor)) &&
-   "this property has not yet been computed by Sema");
-return data().DefaultedCopyConstructorIsDeleted;
-  }
-
-  /// \brief \c true if a defaulted move constructor for this class would be
-  /// deleted.
-  bool defaultedMoveConstructorIsDeleted() const {
-assert((!needsOverloadResolutionForMoveConstructor() ||
-(data().DeclaredSpecialMembers & SMF_MoveConstructor)) &&
-   "this property has not yet been computed by Sema");
-return data().DefaultedMoveConstructorIsDeleted;
-  }
-
-  /// \brief \c true if a defaulted destructor for this class would be deleted.
-  bool defaultedDestructorIsDeleted() const {
-return !data().DefaultedDestructorIsDeleted;
-  }
-
-  /// \brief \c true if we know for sure that this class has a single,
-  /// accessible, unambiguous copy constructor that is not deleted.
-  bool hasSimpleCopyConstructor() const {
-return !hasUserDeclaredCopyConstructor() &&
-   !data().DefaultedCopyConstructorIsDeleted;
-  }
-
   /// \brief \c true if we know for sure that this class has a single,
   /// accessible, unambiguous move constructor that is not deleted.
   bool hasSimpleMoveConstructor() const {
 return !hasUserDeclaredMoveConstructor() && hasMoveConstructor() &&
!data().DefaultedMoveConstructorIsDeleted;
   }
-
   /// \brief \c true if we know for sure that this class has a single,
   /// accessible, unambiguous move assignment operator that is not deleted.
   bool hasSimpleMoveAssignment() const {
 return !hasUserDeclaredMoveAssignment() && hasMoveAssignment() &&
!data().DefaultedMoveAssignmentIsDeleted;
   }
-
   /// \brief \c true if we know for sure that this class has an accessible
   /// destructor that is not deleted.
   bool hasSimpleDestructor() const {
@@ -918,16 +878,7 @@ public:
   /// \brief Determine whether we need to eagerly declare a defaulted copy
   /// constructor for 

Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-09 Thread Diana Picus via cfe-commits
Hi Richard,

I'm sorry but I've reverted this in r310464 because it was breaking
some ASAN tests on this bot:
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9452

Please let me know if I can help debug this.

Cheers,
Diana

On 8 August 2017 at 21:14, Richard Smith via cfe-commits
 wrote:
> I forgot to say:
>
> Based on a patch by Vassil Vassilev, which was based on a patch by Bernd
> Schmidt, which was based on a patch by Reid Kleckner.
>
> On 8 August 2017 at 12:12, Richard Smith via cfe-commits
>  wrote:
>>
>> Author: rsmith
>> Date: Tue Aug  8 12:12:28 2017
>> New Revision: 310401
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=310401&view=rev
>> Log:
>> PR19668, PR23034: Fix handling of move constructors and deleted copy
>> constructors when deciding whether classes should be passed indirectly.
>>
>> This fixes ABI differences between Clang and GCC:
>>
>>  * Previously, Clang ignored the move constructor when making this
>>determination. It now takes the move constructor into account, per
>>https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may
>>seem recent, but the ABI change was agreed on the Itanium C++ ABI
>>list a long time ago).
>>
>>  * Previously, Clang's behavior when the copy constructor was deleted
>>was unstable -- depending on whether the lazy declaration of the
>>copy constructor had been triggered, you might get different behavior.
>>We now eagerly declare the copy constructor whenever its deletedness
>>is unclear, and ignore deleted copy/move constructors when looking for
>>a trivial such constructor.
>>
>> This also fixes an ABI difference between Clang and MSVC:
>>
>>  * If the copy constructor would be implicitly deleted (but has not been
>>lazily declared yet), for instance because the class has an rvalue
>>reference member, we would pass it directly. We now pass such a class
>>indirectly, matching MSVC.
>>
>> Modified:
>> cfe/trunk/include/clang/AST/DeclCXX.h
>> cfe/trunk/lib/AST/ASTImporter.cpp
>> cfe/trunk/lib/AST/DeclCXX.cpp
>> cfe/trunk/lib/CodeGen/CGCXXABI.cpp
>> cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
>> cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>> cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
>> cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310401&r1=310400&r2=310401&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
>> +++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug  8 12:12:28 2017
>> @@ -375,6 +375,7 @@ class CXXRecordDecl : public RecordDecl
>>  /// \brief These flags are \c true if a defaulted corresponding
>> special
>>  /// member can't be fully analyzed without performing overload
>> resolution.
>>  /// @{
>> +unsigned NeedOverloadResolutionForCopyConstructor : 1;
>>  unsigned NeedOverloadResolutionForMoveConstructor : 1;
>>  unsigned NeedOverloadResolutionForMoveAssignment : 1;
>>  unsigned NeedOverloadResolutionForDestructor : 1;
>> @@ -383,6 +384,7 @@ class CXXRecordDecl : public RecordDecl
>>  /// \brief These flags are \c true if an implicit defaulted
>> corresponding
>>  /// special member would be defined as deleted.
>>  /// @{
>> +unsigned DefaultedCopyConstructorIsDeleted : 1;
>>  unsigned DefaultedMoveConstructorIsDeleted : 1;
>>  unsigned DefaultedMoveAssignmentIsDeleted : 1;
>>  unsigned DefaultedDestructorIsDeleted : 1;
>> @@ -415,6 +417,12 @@ class CXXRecordDecl : public RecordDecl
>>  /// constructor.
>>  unsigned HasDefaultedDefaultConstructor : 1;
>>
>> +/// \brief True if this class can be passed in a
>> non-address-preserving
>> +/// fashion (such as in registers) according to the C++ language
>> rules.
>> +/// This does not imply anything about how the ABI in use will
>> actually
>> +/// pass an object of this class.
>> +unsigned CanPassInRegisters : 1;
>> +
>>  /// \brief True if a defaulted default constructor for this class
>> would
>>  /// be constexpr.
>>  unsigned DefaultedDefaultConstructorIsConstexpr : 1;
>> @@ -811,18 +819,50 @@ public:
>>  return data().FirstFriend.isValid();
>>}
>>
>> +  /// \brief \c true if a defaulted copy constructor for this class would
>> be
>> +  /// deleted.
>> +  bool defaultedCopyConstructorIsDeleted() const {
>> +assert((!needsOverloadResolutionForCopyConstructor() ||
>> +(data().DeclaredSpecialMembers & SMF_CopyConstructor)) &&
>> +   "this property has not yet been computed by Sema");
>> +return data().DefaultedCopyConstructorIsDeleted;
>> +  }
>> +
>> +  /// \brief

r310468 - [Sema] -Wenum-compare no longer warn on anonymous enums in switch statements

2017-08-09 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Wed Aug  9 05:34:58 2017
New Revision: 310468

URL: http://llvm.org/viewvc/llvm-project?rev=310468&view=rev
Log:
[Sema] -Wenum-compare no longer warn on anonymous enums in switch statements

Patch by: Reka Nikolett Kovacs

Modified:
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/SemaCXX/warn-enum-compare.cpp

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=310468&r1=310467&r2=310468&view=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Aug  9 05:34:58 2017
@@ -753,6 +753,12 @@ static void checkEnumTypesInSwitchStmt(S
   if (!CondEnumType || !CaseEnumType)
 return;
 
+  // Ignore anonymous enums.
+  if (!CondEnumType->getDecl()->getIdentifier())
+return;
+  if (!CaseEnumType->getDecl()->getIdentifier())
+return;
+
   if (S.Context.hasSameUnqualifiedType(CondType, CaseType))
 return;
 

Modified: cfe/trunk/test/SemaCXX/warn-enum-compare.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-enum-compare.cpp?rev=310468&r1=310467&r2=310468&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-enum-compare.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-enum-compare.cpp Wed Aug  9 05:34:58 2017
@@ -226,4 +226,11 @@ void test () {
 case BarF: break;
 case FooA: break; // expected-warning {{comparison of two values with 
different enumeration types ('Bar' and 'Foo')}}
   }
+
+  switch(x) {
+case AnonAA: break; // expected-warning {{case value not in enumerated 
type 'Foo'}}
+case FooA: break;
+case FooB: break;
+case FooC: break;
+  }
 }


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


[PATCH] D35020: [Modules] Add ability to specify module name to module file mapping

2017-08-09 Thread Boris Kolpackov via Phabricator via cfe-commits
boris added a comment.

Ping.


https://reviews.llvm.org/D35020



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


[PATCH] D35678: Omit sumbodule semantics for TS modules

2017-08-09 Thread Boris Kolpackov via Phabricator via cfe-commits
boris added a comment.

Ping.


https://reviews.llvm.org/D35678



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


[PATCH] D36171: AMDGPU: Use direct struct returns

2017-08-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


https://reviews.llvm.org/D36171



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


[clang-tools-extra] r310470 - [clangd] Fixed a bug in make_tagged.

2017-08-09 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Aug  9 05:55:13 2017
New Revision: 310470

URL: http://llvm.org/viewvc/llvm-project?rev=310470&view=rev
Log:
[clangd] Fixed a bug in make_tagged.

It accidentally std::move'd from Value parameter if it deduced to an
l-value ref.

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.h

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=310470&r1=310469&r2=310470&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Wed Aug  9 05:55:13 2017
@@ -66,7 +66,7 @@ public:
 
 template 
 Tagged::type> make_tagged(T &&Value, VFSTag Tag) {
-  return Tagged(std::forward(Value), Tag);
+  return Tagged::type>(std::forward(Value), Tag);
 }
 
 class DiagnosticsConsumer {


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


[PATCH] D36458: Fix crash when current lexer is nullptr

2017-08-09 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

But I don't know the source of that issue, I only know how to fix it because I 
caught that one in debugger and added a check to prevent it.
How can I write testcase for such fix?


https://reviews.llvm.org/D36458



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


Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-09 Thread Vassil Vassilev via cfe-commits

Hi Diana,

  It seems the service is down. Could you send us the details of the 
failures (incl stack traces if any)


Many thanks,
Vassil
On 09/08/17 15:27, Diana Picus via cfe-commits wrote:

Hi Richard,

I'm sorry but I've reverted this in r310464 because it was breaking
some ASAN tests on this bot:
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9452

Please let me know if I can help debug this.

Cheers,
Diana

On 8 August 2017 at 21:14, Richard Smith via cfe-commits
 wrote:

I forgot to say:

Based on a patch by Vassil Vassilev, which was based on a patch by Bernd
Schmidt, which was based on a patch by Reid Kleckner.

On 8 August 2017 at 12:12, Richard Smith via cfe-commits
 wrote:

Author: rsmith
Date: Tue Aug  8 12:12:28 2017
New Revision: 310401

URL: http://llvm.org/viewvc/llvm-project?rev=310401&view=rev
Log:
PR19668, PR23034: Fix handling of move constructors and deleted copy
constructors when deciding whether classes should be passed indirectly.

This fixes ABI differences between Clang and GCC:

  * Previously, Clang ignored the move constructor when making this
determination. It now takes the move constructor into account, per
https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may
seem recent, but the ABI change was agreed on the Itanium C++ ABI
list a long time ago).

  * Previously, Clang's behavior when the copy constructor was deleted
was unstable -- depending on whether the lazy declaration of the
copy constructor had been triggered, you might get different behavior.
We now eagerly declare the copy constructor whenever its deletedness
is unclear, and ignore deleted copy/move constructors when looking for
a trivial such constructor.

This also fixes an ABI difference between Clang and MSVC:

  * If the copy constructor would be implicitly deleted (but has not been
lazily declared yet), for instance because the class has an rvalue
reference member, we would pass it directly. We now pass such a class
indirectly, matching MSVC.

Modified:
 cfe/trunk/include/clang/AST/DeclCXX.h
 cfe/trunk/lib/AST/ASTImporter.cpp
 cfe/trunk/lib/AST/DeclCXX.cpp
 cfe/trunk/lib/CodeGen/CGCXXABI.cpp
 cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
 cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
 cfe/trunk/lib/Sema/SemaDeclCXX.cpp
 cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
 cfe/trunk/lib/Serialization/ASTWriter.cpp
 cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
 cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310401&r1=310400&r2=310401&view=diff

==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug  8 12:12:28 2017
@@ -375,6 +375,7 @@ class CXXRecordDecl : public RecordDecl
  /// \brief These flags are \c true if a defaulted corresponding
special
  /// member can't be fully analyzed without performing overload
resolution.
  /// @{
+unsigned NeedOverloadResolutionForCopyConstructor : 1;
  unsigned NeedOverloadResolutionForMoveConstructor : 1;
  unsigned NeedOverloadResolutionForMoveAssignment : 1;
  unsigned NeedOverloadResolutionForDestructor : 1;
@@ -383,6 +384,7 @@ class CXXRecordDecl : public RecordDecl
  /// \brief These flags are \c true if an implicit defaulted
corresponding
  /// special member would be defined as deleted.
  /// @{
+unsigned DefaultedCopyConstructorIsDeleted : 1;
  unsigned DefaultedMoveConstructorIsDeleted : 1;
  unsigned DefaultedMoveAssignmentIsDeleted : 1;
  unsigned DefaultedDestructorIsDeleted : 1;
@@ -415,6 +417,12 @@ class CXXRecordDecl : public RecordDecl
  /// constructor.
  unsigned HasDefaultedDefaultConstructor : 1;

+/// \brief True if this class can be passed in a
non-address-preserving
+/// fashion (such as in registers) according to the C++ language
rules.
+/// This does not imply anything about how the ABI in use will
actually
+/// pass an object of this class.
+unsigned CanPassInRegisters : 1;
+
  /// \brief True if a defaulted default constructor for this class
would
  /// be constexpr.
  unsigned DefaultedDefaultConstructorIsConstexpr : 1;
@@ -811,18 +819,50 @@ public:
  return data().FirstFriend.isValid();
}

+  /// \brief \c true if a defaulted copy constructor for this class would
be
+  /// deleted.
+  bool defaultedCopyConstructorIsDeleted() const {
+assert((!needsOverloadResolutionForCopyConstructor() ||
+(data().DeclaredSpecialMembers & SMF_CopyConstructor)) &&
+   "this property has not yet been computed by Sema");
+return data().DefaultedCopyConstructorIsDeleted;
+  }
+
+  /// \brief \c true if a defaulted move constructor for this class would
be
+  

[PATCH] D36473: Fix broken getAttributeSpellingListIndex for pragma attributes

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

LGTM, good catch!


https://reviews.llvm.org/D36473



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


r310472 - [X86][Ms-InlineAsm] Extend MS Dot operator to accept "this" + struct/class pointers aliases

2017-08-09 Thread Coby Tayree via cfe-commits
Author: coby
Date: Wed Aug  9 06:31:41 2017
New Revision: 310472

URL: http://llvm.org/viewvc/llvm-project?rev=310472&view=rev
Log:
[X86][Ms-InlineAsm] Extend MS Dot operator to accept "this" + struct/class 
pointers aliases

MS InlineAsm Dot operator accepts "Bases" such as "this" (cpp) and class/struct 
pointer typedef.
This patch enhance its implementation with this behavior.

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

Modified:
cfe/trunk/lib/Sema/SemaStmtAsm.cpp
cfe/trunk/test/CodeGen/ms-inline-asm.c
cfe/trunk/test/CodeGen/ms-inline-asm.cpp

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=310472&r1=310471&r2=310472&view=diff
==
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Wed Aug  9 06:31:41 2017
@@ -677,22 +677,33 @@ bool Sema::LookupInlineAsmField(StringRe
   SmallVector Members;
   Member.split(Members, ".");
 
-  LookupResult BaseResult(*this, &Context.Idents.get(Base), SourceLocation(),
-  LookupOrdinaryName);
+  NamedDecl *FoundDecl = nullptr;
 
-  if (!LookupName(BaseResult, getCurScope()))
-return true;
-  
-  if(!BaseResult.isSingleResult())
+  // MS InlineAsm uses 'this' as a base
+  if (getLangOpts().CPlusPlus && Base.equals("this")) {
+if (const Type *PT = getCurrentThisType().getTypePtrOrNull())
+  FoundDecl = PT->getPointeeType()->getAsTagDecl();
+  } else {
+LookupResult BaseResult(*this, &Context.Idents.get(Base), SourceLocation(),
+LookupOrdinaryName);
+if (LookupName(BaseResult, getCurScope()) && BaseResult.isSingleResult())
+  FoundDecl = BaseResult.getFoundDecl();
+  }
+
+  if (!FoundDecl)
 return true;
-  NamedDecl *FoundDecl = BaseResult.getFoundDecl();
+
   for (StringRef NextMember : Members) {
 const RecordType *RT = nullptr;
 if (VarDecl *VD = dyn_cast(FoundDecl))
   RT = VD->getType()->getAs();
 else if (TypedefNameDecl *TD = dyn_cast(FoundDecl)) {
   MarkAnyDeclReferenced(TD->getLocation(), TD, /*OdrUse=*/false);
-  RT = TD->getUnderlyingType()->getAs();
+  // MS InlineAsm often uses struct pointer aliases as a base
+  QualType QT = TD->getUnderlyingType();
+  if (const auto *PT = QT->getAs())
+QT = PT->getPointeeType();
+  RT = QT->getAs();
 } else if (TypeDecl *TD = dyn_cast(FoundDecl))
   RT = TD->getTypeForDecl()->getAs();
 else if (FieldDecl *TD = dyn_cast(FoundDecl))

Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=310472&r1=310471&r2=310472&view=diff
==
--- cfe/trunk/test/CodeGen/ms-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c Wed Aug  9 06:31:41 2017
@@ -527,7 +527,7 @@ void cpuid() {
 typedef struct {
   int a;
   int b;
-} A;
+} A, *pA;
 
 typedef struct {
   int b1;
@@ -539,7 +539,7 @@ typedef struct {
   A   c2;
   int c3;
   B   c4;
-} C;
+} C, *pC;
 
 void t39() {
 // CHECK-LABEL: define void @t39
@@ -547,6 +547,8 @@ void t39() {
 // CHECK: mov eax, [eax].4
   __asm mov eax, [eax] A.b
 // CHECK: mov eax, [eax] .4
+  __asm mov eax, [eax] pA.b
+// CHECK: mov eax, [eax] .4
   __asm mov eax, fs:[0] A.b
 // CHECK: mov eax, fs:[$$0] .4
   __asm mov eax, [eax].B.b2.a
@@ -557,6 +559,8 @@ void t39() {
 // CHECK: mov eax, fs:[$$0] .8
   __asm mov eax, [eax]C.c4.b2.b
 // CHECK: mov eax, [eax].24
+  __asm mov eax, [eax]pC.c4.b2.b
+// CHECK: mov eax, [eax].24
 // CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
 

Modified: cfe/trunk/test/CodeGen/ms-inline-asm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.cpp?rev=310472&r1=310471&r2=310472&view=diff
==
--- cfe/trunk/test/CodeGen/ms-inline-asm.cpp (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm.cpp Wed Aug  9 06:31:41 2017
@@ -180,3 +180,19 @@ void t8() {
   A::g();
 }
 
+void t9() {
+  // CHECK-LABEL: define void @_Z2t9v()
+  struct A {
+int a;
+int b;
+void g() {
+  __asm mov eax, dword ptr [eax]this.b
+  // CHECK: call void asm sideeffect inteldialect
+  // CHECK-SAME: mov eax, dword ptr [eax].4
+  // CHECK-SAME: "~{eax},~{dirflag},~{fpsr},~{flags}"()
+}
+  };
+  A AA;
+  AA.g();
+}
+


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


[PATCH] D36450: [X86][Ms-InlineAsm] Extend MS Dot operator to accept "this" + struct/class pointers aliases

2017-08-09 Thread coby via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310472: [X86][Ms-InlineAsm] Extend MS Dot operator to accept 
"this" + struct/class… (authored by coby).

Changed prior to commit:
  https://reviews.llvm.org/D36450?vs=110145&id=110377#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36450

Files:
  cfe/trunk/lib/Sema/SemaStmtAsm.cpp
  cfe/trunk/test/CodeGen/ms-inline-asm.c
  cfe/trunk/test/CodeGen/ms-inline-asm.cpp

Index: cfe/trunk/test/CodeGen/ms-inline-asm.cpp
===
--- cfe/trunk/test/CodeGen/ms-inline-asm.cpp
+++ cfe/trunk/test/CodeGen/ms-inline-asm.cpp
@@ -180,3 +180,19 @@
   A::g();
 }
 
+void t9() {
+  // CHECK-LABEL: define void @_Z2t9v()
+  struct A {
+int a;
+int b;
+void g() {
+  __asm mov eax, dword ptr [eax]this.b
+  // CHECK: call void asm sideeffect inteldialect
+  // CHECK-SAME: mov eax, dword ptr [eax].4
+  // CHECK-SAME: "~{eax},~{dirflag},~{fpsr},~{flags}"()
+}
+  };
+  A AA;
+  AA.g();
+}
+
Index: cfe/trunk/test/CodeGen/ms-inline-asm.c
===
--- cfe/trunk/test/CodeGen/ms-inline-asm.c
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c
@@ -527,7 +527,7 @@
 typedef struct {
   int a;
   int b;
-} A;
+} A, *pA;
 
 typedef struct {
   int b1;
@@ -539,14 +539,16 @@
   A   c2;
   int c3;
   B   c4;
-} C;
+} C, *pC;
 
 void t39() {
 // CHECK-LABEL: define void @t39
   __asm mov eax, [eax].A.b
 // CHECK: mov eax, [eax].4
   __asm mov eax, [eax] A.b
 // CHECK: mov eax, [eax] .4
+  __asm mov eax, [eax] pA.b
+// CHECK: mov eax, [eax] .4
   __asm mov eax, fs:[0] A.b
 // CHECK: mov eax, fs:[$$0] .4
   __asm mov eax, [eax].B.b2.a
@@ -557,6 +559,8 @@
 // CHECK: mov eax, fs:[$$0] .8
   __asm mov eax, [eax]C.c4.b2.b
 // CHECK: mov eax, [eax].24
+  __asm mov eax, [eax]pC.c4.b2.b
+// CHECK: mov eax, [eax].24
 // CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
 
Index: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
===
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp
@@ -677,22 +677,33 @@
   SmallVector Members;
   Member.split(Members, ".");
 
-  LookupResult BaseResult(*this, &Context.Idents.get(Base), SourceLocation(),
-  LookupOrdinaryName);
+  NamedDecl *FoundDecl = nullptr;
 
-  if (!LookupName(BaseResult, getCurScope()))
-return true;
-  
-  if(!BaseResult.isSingleResult())
+  // MS InlineAsm uses 'this' as a base
+  if (getLangOpts().CPlusPlus && Base.equals("this")) {
+if (const Type *PT = getCurrentThisType().getTypePtrOrNull())
+  FoundDecl = PT->getPointeeType()->getAsTagDecl();
+  } else {
+LookupResult BaseResult(*this, &Context.Idents.get(Base), SourceLocation(),
+LookupOrdinaryName);
+if (LookupName(BaseResult, getCurScope()) && BaseResult.isSingleResult())
+  FoundDecl = BaseResult.getFoundDecl();
+  }
+
+  if (!FoundDecl)
 return true;
-  NamedDecl *FoundDecl = BaseResult.getFoundDecl();
+
   for (StringRef NextMember : Members) {
 const RecordType *RT = nullptr;
 if (VarDecl *VD = dyn_cast(FoundDecl))
   RT = VD->getType()->getAs();
 else if (TypedefNameDecl *TD = dyn_cast(FoundDecl)) {
   MarkAnyDeclReferenced(TD->getLocation(), TD, /*OdrUse=*/false);
-  RT = TD->getUnderlyingType()->getAs();
+  // MS InlineAsm often uses struct pointer aliases as a base
+  QualType QT = TD->getUnderlyingType();
+  if (const auto *PT = QT->getAs())
+QT = PT->getPointeeType();
+  RT = QT->getAs();
 } else if (TypeDecl *TD = dyn_cast(FoundDecl))
   RT = TD->getTypeForDecl()->getAs();
 else if (FieldDecl *TD = dyn_cast(FoundDecl))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36471: [StaticAnalyzer] Try to calculate arithmetic result when operand has a range of possible values

2017-08-09 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki updated this revision to Diff 110378.
danielmarjamaki added a comment.

Refactoring, use BasicValueFactory::evalAPSInt


Repository:
  rL LLVM

https://reviews.llvm.org/D36471

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  test/Analysis/eval-range.c

Index: test/Analysis/eval-range.c
===
--- test/Analysis/eval-range.c
+++ test/Analysis/eval-range.c
@@ -0,0 +1,18 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(int);
+
+void test1(int a) {
+  if (a >= 10 && a <= 50) {
+int b;
+
+b = a + 2;
+clang_analyzer_eval(b >= 12 && b <= 52); // expected-warning{{TRUE}}
+
+b = a - 2;
+clang_analyzer_eval(b >= 8 && b <= 48); // expected-warning{{TRUE}}
+
+b = a / 2;
+clang_analyzer_eval(b >= 5 && b <= 25); // expected-warning{{TRUE}}
+  }
+}
Index: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -304,6 +304,8 @@
   void print(ProgramStateRef State, raw_ostream &Out, const char *nl,
  const char *sep) override;
 
+  ProgramStateRef evalRangeOp(ProgramStateRef state, SVal V) override;
+
   //===--===//
   // Implementation for interface from RangedConstraintManager.
   //===--===//
@@ -741,3 +743,56 @@
   }
   Out << nl;
 }
+
+ProgramStateRef RangeConstraintManager::evalRangeOp(ProgramStateRef St,
+SVal V) {
+  const SymExpr *SE = V.getAsSymExpr();
+  if (!SE)
+return nullptr;
+
+  const SymIntExpr *SIE = dyn_cast(SE);
+  if (!SIE)
+return nullptr;
+
+  const clang::BinaryOperatorKind Opc = SIE->getOpcode();
+
+  if (Opc != BO_Add && Opc != BO_Sub && Opc != BO_Div)
+return nullptr;
+
+  const SymExpr *LHS = SIE->getLHS();
+  const llvm::APSInt &RHS = SIE->getRHS();
+
+  ConstraintRangeTy Ranges = St->get();
+  for (ConstraintRangeTy::iterator I = Ranges.begin(), E = Ranges.end(); I != E;
+   ++I) {
+if (LHS == I.getKey()) {
+  const auto D = I.getData();
+  for (auto I = D.begin(); I != D.end(); ++I) {
+if (I->From().isUnsigned() != RHS.isUnsigned())
+  // TODO: Handle sign conversions.
+  return nullptr;
+if (I->From().getBitWidth() != RHS.getBitWidth())
+  // TODO: Promote values.
+  return nullptr;
+if (I->From().isNegative())
+  // TODO: Handle negative range values
+  return nullptr;
+
+BasicValueFactory &BVF = getBasicVals();
+const llvm::APSInt *Lower = BVF.evalAPSInt(Opc, I->From(), RHS);
+if (!Lower)
+  return nullptr;
+const llvm::APSInt *Upper = BVF.evalAPSInt(Opc, I->To(), RHS);
+if (!Upper)
+  return nullptr;
+
+SymbolRef Sym = V.getAsSymbol();
+RangeSet RS =
+getRange(St, Sym).Intersect(getBasicVals(), F, *Lower, *Upper);
+// TODO: This only evaluates the first range. Evaluate all ranges.
+return RS.isEmpty() ? nullptr : St->set(Sym, RS);
+  }
+}
+  }
+  return nullptr;
+}
Index: lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -98,7 +98,9 @@
   }
 
   state = state->BindExpr(B, LCtx, Result);
-  Bldr.generateNode(B, *it, state);
+  ProgramStateRef state2 =
+  getConstraintManager().evalRangeOp(state, Result);
+  Bldr.generateNode(B, *it, state2 ? state2 : state);
   continue;
 }
 
Index: include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
@@ -142,13 +142,15 @@
   /// Scan all symbols referenced by the constraints. If the symbol is not
   /// alive, remove it.
   virtual ProgramStateRef removeDeadBindings(ProgramStateRef state,
- SymbolReaper& SymReaper) = 0;
+ SymbolReaper &SymReaper) = 0;
 
-  virtual void print(ProgramStateRef state,
- raw_ostream &Out,
- const char* nl,
+  virtual void print(ProgramStateRef state, raw_ostream &Out, const char *nl,
  const char *sep) = 0;
 
+  virtual ProgramStateRef evalRangeOp(ProgramStateRef state, SVal V) {
+return nullptr;
+  }
+
   virtual

[PATCH] D36471: [StaticAnalyzer] Try to calculate arithmetic result when operand has a range of possible values

2017-08-09 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment.

Should evalAPSInt() have machinery to do standard sign/type promotions? I 
suggest that I add one more argument `bool promote = false`, do you think that 
sounds good?


Repository:
  rL LLVM

https://reviews.llvm.org/D36471



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


[PATCH] D36261: [clangd] Use multiple working threads in clangd.

2017-08-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 110381.
ilya-biryukov added a comment.

- Added a stress test for multithreading.


https://reviews.llvm.org/D36261

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -136,18 +137,23 @@
 static const std::chrono::seconds DefaultFutureTimeout =
 std::chrono::seconds(10);
 
+static bool diagsContainErrors(ArrayRef Diagnostics) {
+  for (const auto &DiagAndFixIts : Diagnostics) {
+// FIXME: severities returned by clangd should have a descriptive
+// diagnostic severity enum
+const int ErrorSeverity = 1;
+if (DiagAndFixIts.Diag.severity == ErrorSeverity)
+  return true;
+  }
+  return false;
+}
+
 class ErrorCheckingDiagConsumer : public DiagnosticsConsumer {
 public:
   void
   onDiagnosticsReady(PathRef File,
  Tagged> Diagnostics) override {
-bool HadError = false;
-for (const auto &DiagAndFixIts : Diagnostics.Value) {
-  // FIXME: severities returned by clangd should have a descriptive
-  // diagnostic severity enum
-  const int ErrorSeverity = 1;
-  HadError = DiagAndFixIts.Diag.severity == ErrorSeverity;
-}
+bool HadError = diagsContainErrors(Diagnostics.Value);
 
 std::lock_guard Lock(Mutex);
 HadErrorInLastDiags = HadError;
@@ -196,24 +202,46 @@
   std::vector ExtraClangFlags;
 };
 
+IntrusiveRefCntPtr
+buildTestFS(llvm::StringMap const &Files) {
+  IntrusiveRefCntPtr MemFS(
+  new vfs::InMemoryFileSystem);
+  for (auto &FileAndContents : Files)
+MemFS->addFile(FileAndContents.first(), time_t(),
+   llvm::MemoryBuffer::getMemBuffer(FileAndContents.second,
+FileAndContents.first()));
+
+  auto OverlayFS = IntrusiveRefCntPtr(
+  new vfs::OverlayFileSystem(vfs::getTempOnlyFS()));
+  OverlayFS->pushOverlay(std::move(MemFS));
+  return OverlayFS;
+}
+
+class ConstantFSProvider : public FileSystemProvider {
+public:
+  ConstantFSProvider(IntrusiveRefCntPtr FS,
+ VFSTag Tag = VFSTag())
+  : FS(std::move(FS)), Tag(std::move(Tag)) {}
+
+  Tagged>
+  getTaggedFileSystem(PathRef File) override {
+return make_tagged(FS, Tag);
+  }
+
+private:
+  IntrusiveRefCntPtr FS;
+  VFSTag Tag;
+};
+
 class MockFSProvider : public FileSystemProvider {
 public:
   Tagged>
   getTaggedFileSystem(PathRef File) override {
-IntrusiveRefCntPtr MemFS(
-new vfs::InMemoryFileSystem);
 if (ExpectedFile)
   EXPECT_EQ(*ExpectedFile, File);
 
-for (auto &FileAndContents : Files)
-  MemFS->addFile(FileAndContents.first(), time_t(),
- llvm::MemoryBuffer::getMemBuffer(FileAndContents.second,
-  FileAndContents.first()));
-
-auto OverlayFS = IntrusiveRefCntPtr(
-new vfs::OverlayFileSystem(vfs::getTempOnlyFS()));
-OverlayFS->pushOverlay(std::move(MemFS));
-return make_tagged(OverlayFS, Tag);
+auto FS = buildTestFS(Files);
+return make_tagged(FS, Tag);
   }
 
   llvm::Optional> ExpectedFile;
@@ -272,17 +300,17 @@
 MockFSProvider FS;
 ErrorCheckingDiagConsumer DiagConsumer;
 MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
-ClangdServer Server(CDB, DiagConsumer, FS,
-/*RunSynchronously=*/false);
+ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount());
 for (const auto &FileWithContents : ExtraFiles)
   FS.Files[getVirtualTestFilePath(FileWithContents.first)] =
   FileWithContents.second;
 
 auto SourceFilename = getVirtualTestFilePath(SourceFileRelPath);
 
 FS.ExpectedFile = SourceFilename;
 
-// Have to sync reparses because RunSynchronously is false.
+// Have to sync reparses because requests are processed on the calling
+// thread.
 auto AddDocFuture = Server.addDocument(SourceFilename, SourceContents);
 
 auto Result = dumpASTWithoutMemoryLocs(Server, SourceFilename);
@@ -334,8 +362,7 @@
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
-  ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/false);
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount());
 
   const auto SourceContents = R"cpp(
 #include "foo.h"
@@ -379,8 +406,7 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
-  ClangdServer Server(CDB, DiagConsumer, FS,
-  /*RunSynchronously=*/false);
+  ClangdServer 

[PATCH] D36261: [clangd] Use multiple working threads in clangd.

2017-08-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Added a test that exercises some multi-threading behaviour. 
It really finds bugs, at least it found a problem that was fixed by 
https://reviews.llvm.org/D36397. (Will make sure to submit that other change 
before this one).

As discussed with @klimek, will move to `llvm::ThreadPool` after submitting a 
fix for it to allow functions with moveable-only arguments to be used there 
(that's what clangd uses).


https://reviews.llvm.org/D36261



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


[PATCH] D36397: [clangd] Fixed a data race.

2017-08-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D36397#833912, @klimek wrote:

> Yea, we'll probably want to add a "smash it hard with parallel" requests kind 
> of test to catch these things. You're right, there is probably not a better 
> solution for this specific bug.


Added a relevant test to https://reviews.llvm.org/D36261. It actually found 
this problem (after repeatedly running it for some time).


https://reviews.llvm.org/D36397



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


Re: r310449 - [Sema] Extend -Wenum-compare to handle mixed enum comparisons in switch statements

2017-08-09 Thread Nico Weber via cfe-commits
Any way we could put this behind a different flag (say,
-Wenum-compare-switch, in the same group as -Wenum-compare, so that
-W(no-)enum-compare affects both)? Our codebase was -Wenum-compare clean
before this commit but is very not clean now, so we'd now have to disable
-Wenum-compare altogether, but then we won't catch regressions in
non-switch statements either.

On Wed, Aug 9, 2017 at 4:57 AM, Gabor Horvath via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: xazax
> Date: Wed Aug  9 01:57:09 2017
> New Revision: 310449
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310449&view=rev
> Log:
> [Sema] Extend -Wenum-compare to handle mixed enum comparisons in switch
> statements
>
> Patch by: Reka Nikolett Kovacs
>
> Differential Revision: https://reviews.llvm.org/D36407
>
> Modified:
> cfe/trunk/lib/Sema/SemaStmt.cpp
> cfe/trunk/test/Sema/switch.c
> cfe/trunk/test/SemaCXX/warn-enum-compare.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaStmt.cpp?rev=310449&r1=310448&r2=310449&view=diff
> 
> ==
> --- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Aug  9 01:57:09 2017
> @@ -602,14 +602,14 @@ static bool EqEnumVals(const std::pair
>  /// GetTypeBeforeIntegralPromotion - Returns the pre-promotion type of
>  /// potentially integral-promoted expression @p expr.
> -static QualType GetTypeBeforeIntegralPromotion(Expr *&expr) {
> -  if (ExprWithCleanups *cleanups = dyn_cast(expr))
> -expr = cleanups->getSubExpr();
> -  while (ImplicitCastExpr *impcast = dyn_cast(expr)) {
> -if (impcast->getCastKind() != CK_IntegralCast) break;
> -expr = impcast->getSubExpr();
> +static QualType GetTypeBeforeIntegralPromotion(const Expr *&E) {
> +  if (const auto *CleanUps = dyn_cast(E))
> +E = CleanUps->getSubExpr();
> +  while (const auto *ImpCast = dyn_cast(E)) {
> +if (ImpCast->getCastKind() != CK_IntegralCast) break;
> +E = ImpCast->getSubExpr();
>}
> -  return expr->getType();
> +  return E->getType();
>  }
>
>  ExprResult Sema::CheckSwitchCondition(SourceLocation SwitchLoc, Expr
> *Cond) {
> @@ -743,6 +743,24 @@ static bool ShouldDiagnoseSwitchCaseNotI
>return true;
>  }
>
> +static void checkEnumTypesInSwitchStmt(Sema &S, const Expr *Cond,
> +   const Expr *Case) {
> +  QualType CondType = GetTypeBeforeIntegralPromotion(Cond);
> +  QualType CaseType = Case->getType();
> +
> +  const EnumType *CondEnumType = CondType->getAs();
> +  const EnumType *CaseEnumType = CaseType->getAs();
> +  if (!CondEnumType || !CaseEnumType)
> +return;
> +
> +  if (S.Context.hasSameUnqualifiedType(CondType, CaseType))
> +return;
> +
> +  S.Diag(Case->getExprLoc(), diag::warn_comparison_of_mixed_enum_types)
> +  << CondType << CaseType << Cond->getSourceRange()
> +  << Case->getSourceRange();
> +}
> +
>  StmtResult
>  Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
>  Stmt *BodyStmt) {
> @@ -760,7 +778,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocati
>
>QualType CondType = CondExpr->getType();
>
> -  Expr *CondExprBeforePromotion = CondExpr;
> +  const Expr *CondExprBeforePromotion = CondExpr;
>QualType CondTypeBeforePromotion =
>GetTypeBeforeIntegralPromotion(CondExprBeforePromotion);
>
> @@ -843,6 +861,8 @@ Sema::ActOnFinishSwitchStmt(SourceLocati
>  break;
>}
>
> +  checkEnumTypesInSwitchStmt(*this, CondExpr, Lo);
> +
>llvm::APSInt LoVal;
>
>if (getLangOpts().CPlusPlus11) {
>
> Modified: cfe/trunk/test/Sema/switch.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/
> switch.c?rev=310449&r1=310448&r2=310449&view=diff
> 
> ==
> --- cfe/trunk/test/Sema/switch.c (original)
> +++ cfe/trunk/test/Sema/switch.c Wed Aug  9 01:57:09 2017
> @@ -372,6 +372,7 @@ void switch_on_ExtendedEnum1(enum Extend
>case EE1_b: break;
>case EE1_c: break; // no-warning
>case EE1_d: break; // expected-warning {{case value not in enumerated
> type 'enum ExtendedEnum1'}}
> +  // expected-warning@-1 {{comparison of two values with different
> enumeration types ('enum ExtendedEnum1' and 'const enum
> ExtendedEnum1_unrelated')}}
>}
>  }
>
>
> Modified: cfe/trunk/test/SemaCXX/warn-enum-compare.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> SemaCXX/warn-enum-compare.cpp?rev=310449&r1=310448&r2=310449&view=diff
> 
> ==
> --- cfe/trunk/test/SemaCXX/warn-enum-compare.cpp (original)
> +++ cfe/trunk/test/SemaCXX/warn-enum-compare.cpp Wed Aug  9 01:57:09 2017
> @@ -209,4 +209,21 @@ void test () {
>while (getBar() > x); // expected-warning  {{comparison of two values
> with different enumeration types 

Re: r310449 - [Sema] Extend -Wenum-compare to handle mixed enum comparisons in switch statements

2017-08-09 Thread Gábor Horváth via cfe-commits
Sure!

There was a follow-up patch that excluded anonymous enums. Is it still that
bad to introduce it under a new flag?

Regards,
Gábor

On 9 August 2017 at 16:07, Nico Weber  wrote:

> Any way we could put this behind a different flag (say,
> -Wenum-compare-switch, in the same group as -Wenum-compare, so that
> -W(no-)enum-compare affects both)? Our codebase was -Wenum-compare clean
> before this commit but is very not clean now, so we'd now have to disable
> -Wenum-compare altogether, but then we won't catch regressions in
> non-switch statements either.
>
> On Wed, Aug 9, 2017 at 4:57 AM, Gabor Horvath via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: xazax
>> Date: Wed Aug  9 01:57:09 2017
>> New Revision: 310449
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=310449&view=rev
>> Log:
>> [Sema] Extend -Wenum-compare to handle mixed enum comparisons in switch
>> statements
>>
>> Patch by: Reka Nikolett Kovacs
>>
>> Differential Revision: https://reviews.llvm.org/D36407
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaStmt.cpp
>> cfe/trunk/test/Sema/switch.c
>> cfe/trunk/test/SemaCXX/warn-enum-compare.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaS
>> tmt.cpp?rev=310449&r1=310448&r2=310449&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Aug  9 01:57:09 2017
>> @@ -602,14 +602,14 @@ static bool EqEnumVals(const std::pair>
>>  /// GetTypeBeforeIntegralPromotion - Returns the pre-promotion type of
>>  /// potentially integral-promoted expression @p expr.
>> -static QualType GetTypeBeforeIntegralPromotion(Expr *&expr) {
>> -  if (ExprWithCleanups *cleanups = dyn_cast(expr))
>> -expr = cleanups->getSubExpr();
>> -  while (ImplicitCastExpr *impcast = dyn_cast(expr)) {
>> -if (impcast->getCastKind() != CK_IntegralCast) break;
>> -expr = impcast->getSubExpr();
>> +static QualType GetTypeBeforeIntegralPromotion(const Expr *&E) {
>> +  if (const auto *CleanUps = dyn_cast(E))
>> +E = CleanUps->getSubExpr();
>> +  while (const auto *ImpCast = dyn_cast(E)) {
>> +if (ImpCast->getCastKind() != CK_IntegralCast) break;
>> +E = ImpCast->getSubExpr();
>>}
>> -  return expr->getType();
>> +  return E->getType();
>>  }
>>
>>  ExprResult Sema::CheckSwitchCondition(SourceLocation SwitchLoc, Expr
>> *Cond) {
>> @@ -743,6 +743,24 @@ static bool ShouldDiagnoseSwitchCaseNotI
>>return true;
>>  }
>>
>> +static void checkEnumTypesInSwitchStmt(Sema &S, const Expr *Cond,
>> +   const Expr *Case) {
>> +  QualType CondType = GetTypeBeforeIntegralPromotion(Cond);
>> +  QualType CaseType = Case->getType();
>> +
>> +  const EnumType *CondEnumType = CondType->getAs();
>> +  const EnumType *CaseEnumType = CaseType->getAs();
>> +  if (!CondEnumType || !CaseEnumType)
>> +return;
>> +
>> +  if (S.Context.hasSameUnqualifiedType(CondType, CaseType))
>> +return;
>> +
>> +  S.Diag(Case->getExprLoc(), diag::warn_comparison_of_mixed_enum_types)
>> +  << CondType << CaseType << Cond->getSourceRange()
>> +  << Case->getSourceRange();
>> +}
>> +
>>  StmtResult
>>  Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
>>  Stmt *BodyStmt) {
>> @@ -760,7 +778,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocati
>>
>>QualType CondType = CondExpr->getType();
>>
>> -  Expr *CondExprBeforePromotion = CondExpr;
>> +  const Expr *CondExprBeforePromotion = CondExpr;
>>QualType CondTypeBeforePromotion =
>>GetTypeBeforeIntegralPromotion(CondExprBeforePromotion);
>>
>> @@ -843,6 +861,8 @@ Sema::ActOnFinishSwitchStmt(SourceLocati
>>  break;
>>}
>>
>> +  checkEnumTypesInSwitchStmt(*this, CondExpr, Lo);
>> +
>>llvm::APSInt LoVal;
>>
>>if (getLangOpts().CPlusPlus11) {
>>
>> Modified: cfe/trunk/test/Sema/switch.c
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/swit
>> ch.c?rev=310449&r1=310448&r2=310449&view=diff
>> 
>> ==
>> --- cfe/trunk/test/Sema/switch.c (original)
>> +++ cfe/trunk/test/Sema/switch.c Wed Aug  9 01:57:09 2017
>> @@ -372,6 +372,7 @@ void switch_on_ExtendedEnum1(enum Extend
>>case EE1_b: break;
>>case EE1_c: break; // no-warning
>>case EE1_d: break; // expected-warning {{case value not in enumerated
>> type 'enum ExtendedEnum1'}}
>> +  // expected-warning@-1 {{comparison of two values with different
>> enumeration types ('enum ExtendedEnum1' and 'const enum
>> ExtendedEnum1_unrelated')}}
>>}
>>  }
>>
>>
>> Modified: cfe/trunk/test/SemaCXX/warn-enum-compare.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/
>> warn-enum-compare.cpp?rev=310449&r1=310448&r2=310449&view=diff
>> ==

Re: r310449 - [Sema] Extend -Wenum-compare to handle mixed enum comparisons in switch statements

2017-08-09 Thread Aaron Ballman via cfe-commits
On Wed, Aug 9, 2017 at 10:07 AM, Nico Weber via cfe-commits
 wrote:
> Any way we could put this behind a different flag (say,
> -Wenum-compare-switch, in the same group as -Wenum-compare, so that
> -W(no-)enum-compare affects both)? Our codebase was -Wenum-compare clean
> before this commit but is very not clean now, so we'd now have to disable
> -Wenum-compare altogether, but then we won't catch regressions in non-switch
> statements either.

I would not be opposed to that.

~Aaron

>
> On Wed, Aug 9, 2017 at 4:57 AM, Gabor Horvath via cfe-commits
>  wrote:
>>
>> Author: xazax
>> Date: Wed Aug  9 01:57:09 2017
>> New Revision: 310449
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=310449&view=rev
>> Log:
>> [Sema] Extend -Wenum-compare to handle mixed enum comparisons in switch
>> statements
>>
>> Patch by: Reka Nikolett Kovacs
>>
>> Differential Revision: https://reviews.llvm.org/D36407
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaStmt.cpp
>> cfe/trunk/test/Sema/switch.c
>> cfe/trunk/test/SemaCXX/warn-enum-compare.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=310449&r1=310448&r2=310449&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Aug  9 01:57:09 2017
>> @@ -602,14 +602,14 @@ static bool EqEnumVals(const std::pair>
>>  /// GetTypeBeforeIntegralPromotion - Returns the pre-promotion type of
>>  /// potentially integral-promoted expression @p expr.
>> -static QualType GetTypeBeforeIntegralPromotion(Expr *&expr) {
>> -  if (ExprWithCleanups *cleanups = dyn_cast(expr))
>> -expr = cleanups->getSubExpr();
>> -  while (ImplicitCastExpr *impcast = dyn_cast(expr)) {
>> -if (impcast->getCastKind() != CK_IntegralCast) break;
>> -expr = impcast->getSubExpr();
>> +static QualType GetTypeBeforeIntegralPromotion(const Expr *&E) {
>> +  if (const auto *CleanUps = dyn_cast(E))
>> +E = CleanUps->getSubExpr();
>> +  while (const auto *ImpCast = dyn_cast(E)) {
>> +if (ImpCast->getCastKind() != CK_IntegralCast) break;
>> +E = ImpCast->getSubExpr();
>>}
>> -  return expr->getType();
>> +  return E->getType();
>>  }
>>
>>  ExprResult Sema::CheckSwitchCondition(SourceLocation SwitchLoc, Expr
>> *Cond) {
>> @@ -743,6 +743,24 @@ static bool ShouldDiagnoseSwitchCaseNotI
>>return true;
>>  }
>>
>> +static void checkEnumTypesInSwitchStmt(Sema &S, const Expr *Cond,
>> +   const Expr *Case) {
>> +  QualType CondType = GetTypeBeforeIntegralPromotion(Cond);
>> +  QualType CaseType = Case->getType();
>> +
>> +  const EnumType *CondEnumType = CondType->getAs();
>> +  const EnumType *CaseEnumType = CaseType->getAs();
>> +  if (!CondEnumType || !CaseEnumType)
>> +return;
>> +
>> +  if (S.Context.hasSameUnqualifiedType(CondType, CaseType))
>> +return;
>> +
>> +  S.Diag(Case->getExprLoc(), diag::warn_comparison_of_mixed_enum_types)
>> +  << CondType << CaseType << Cond->getSourceRange()
>> +  << Case->getSourceRange();
>> +}
>> +
>>  StmtResult
>>  Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
>>  Stmt *BodyStmt) {
>> @@ -760,7 +778,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocati
>>
>>QualType CondType = CondExpr->getType();
>>
>> -  Expr *CondExprBeforePromotion = CondExpr;
>> +  const Expr *CondExprBeforePromotion = CondExpr;
>>QualType CondTypeBeforePromotion =
>>GetTypeBeforeIntegralPromotion(CondExprBeforePromotion);
>>
>> @@ -843,6 +861,8 @@ Sema::ActOnFinishSwitchStmt(SourceLocati
>>  break;
>>}
>>
>> +  checkEnumTypesInSwitchStmt(*this, CondExpr, Lo);
>> +
>>llvm::APSInt LoVal;
>>
>>if (getLangOpts().CPlusPlus11) {
>>
>> Modified: cfe/trunk/test/Sema/switch.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/switch.c?rev=310449&r1=310448&r2=310449&view=diff
>>
>> ==
>> --- cfe/trunk/test/Sema/switch.c (original)
>> +++ cfe/trunk/test/Sema/switch.c Wed Aug  9 01:57:09 2017
>> @@ -372,6 +372,7 @@ void switch_on_ExtendedEnum1(enum Extend
>>case EE1_b: break;
>>case EE1_c: break; // no-warning
>>case EE1_d: break; // expected-warning {{case value not in enumerated
>> type 'enum ExtendedEnum1'}}
>> +  // expected-warning@-1 {{comparison of two values with different
>> enumeration types ('enum ExtendedEnum1' and 'const enum
>> ExtendedEnum1_unrelated')}}
>>}
>>  }
>>
>>
>> Modified: cfe/trunk/test/SemaCXX/warn-enum-compare.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-enum-compare.cpp?rev=310449&r1=310448&r2=310449&view=diff
>>
>> ==
>> --- cfe/trunk/test/SemaCXX/warn-enum-compare.cpp (original)
>> +++ cfe/tr

r310477 - [OpenCL] Minor refactoring to reduce copy/pasted code

2017-08-09 Thread Joey Gouly via cfe-commits
Author: joey
Date: Wed Aug  9 07:52:47 2017
New Revision: 310477

URL: http://llvm.org/viewvc/llvm-project?rev=310477&view=rev
Log:
[OpenCL] Minor refactoring to reduce copy/pasted code

Set the type of TheCall inside SemaBuiltinReserveRWPipe to reduce
duplicated code.

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

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=310477&r1=310476&r2=310477&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Aug  9 07:52:47 2017
@@ -683,6 +683,11 @@ static bool SemaBuiltinReserveRWPipe(Sem
 return true;
   }
 
+  // Since return type of reserve_read/write_pipe built-in function is
+  // reserve_id_t, which is not defined in the builtin def file , we used int
+  // as return type and need to override the return type of these functions.
+  Call->setType(S.Context.OCLReserveIDTy);
+
   return false;
 }
 
@@ -1086,20 +1091,12 @@ Sema::CheckBuiltinFunctionCall(FunctionD
   case Builtin::BIwork_group_reserve_write_pipe:
 if (SemaBuiltinReserveRWPipe(*this, TheCall))
   return ExprError();
-// Since return type of reserve_read/write_pipe built-in function is
-// reserve_id_t, which is not defined in the builtin def file , we used int
-// as return type and need to override the return type of these functions.
-TheCall->setType(Context.OCLReserveIDTy);
 break;
   case Builtin::BIsub_group_reserve_read_pipe:
   case Builtin::BIsub_group_reserve_write_pipe:
 if (checkOpenCLSubgroupExt(*this, TheCall) ||
 SemaBuiltinReserveRWPipe(*this, TheCall))
   return ExprError();
-// Since return type of reserve_read/write_pipe built-in function is
-// reserve_id_t, which is not defined in the builtin def file , we used int
-// as return type and need to override the return type of these functions.
-TheCall->setType(Context.OCLReserveIDTy);
 break;
   case Builtin::BIcommit_read_pipe:
   case Builtin::BIcommit_write_pipe:


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


r310478 - Reapply Sema: allow imaginary constants via GNU extension if UDL overloads not present.

2017-08-09 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Wed Aug  9 07:56:48 2017
New Revision: 310478

URL: http://llvm.org/viewvc/llvm-project?rev=310478&view=rev
Log:
Reapply Sema: allow imaginary constants via GNU extension if UDL overloads not 
present.

C++14 added user-defined literal support for complex numbers so that you
can write something like "complex val = 2i". However, there is
an existing GNU extension supporting this syntax and interpreting the
result as a _Complex type.

This changes parsing so that such literals are interpreted in terms of
C++14's operators if an overload is present but otherwise falls back to
the original GNU extension.

(We now have more robust diagnostics for implicit conversions so the
libc++ test that caused the original revert still passes).

Added:
cfe/trunk/test/SemaCXX/imaginary-constants.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Lex/LiteralSupport.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=310478&r1=310477&r2=310478&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Wed Aug  9 07:56:48 2017
@@ -173,8 +173,6 @@ def warn_char_constant_too_large : Warni
 def err_multichar_utf_character_literal : Error<
   "Unicode character literals may not contain multiple characters">;
 def err_exponent_has_no_digits : Error<"exponent has no digits">;
-def ext_imaginary_constant : Extension<
-  "imaginary constants are a GNU extension">, InGroup;
 def err_hex_constant_requires : Error<
   "hexadecimal floating %select{constant|literal}0 requires "
   "%select{an exponent|a significand}1">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=310478&r1=310477&r2=310478&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Aug  9 07:56:48 
2017
@@ -194,6 +194,8 @@ def warn_duplicate_declspec : Warning<"d
   InGroup;
 def ext_plain_complex : ExtWarn<
   "plain '_Complex' requires a type specifier; assuming '_Complex double'">;
+def ext_imaginary_constant : Extension<
+  "imaginary constants are a GNU extension">, InGroup;
 def ext_integer_complex : Extension<
   "complex integer types are a GNU extension">, InGroup;
 

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=310478&r1=310477&r2=310478&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Aug  9 07:56:48 2017
@@ -3020,6 +3020,8 @@ public:
   enum LiteralOperatorLookupResult {
 /// \brief The lookup resulted in an error.
 LOLR_Error,
+/// \brief The lookup found no match but no diagnostic was issued.
+LOLR_ErrorNoDiagnostic,
 /// \brief The lookup found a single 'cooked' literal operator, which
 /// expects a normal literal to be built and passed to it.
 LOLR_Cooked,
@@ -3144,7 +3146,8 @@ public:
 ArrayRef ArgTys,
 bool AllowRaw,
 bool AllowTemplate,
-bool AllowStringTemplate);
+bool AllowStringTemplate,
+bool DiagnoseMissing);
   bool isKnownName(StringRef name);
 
   void ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc,

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=310478&r1=310477&r2=310478&view=diff
==
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Wed Aug  9 07:56:48 2017
@@ -658,9 +658,6 @@ NumericLiteralParser::NumericLiteralPars
   break;
 }
   }
-  // "i", "if", and "il" are user-defined suffixes in C++1y.
-  if (*s == 'i' && PP.getLangOpts().CPlusPlus14)
-break;
   // fall through.
 case 'j':
 case 'J':
@@ -672,35 +669,34 @@ NumericLiteralParser::NumericLiteralPars
 break;
   }
 
-  if (s != ThisTokEnd) {
+  // "i", "if", and "il" are user-defined suffixes in C++1y.
+  if (s

r310482 - clang-format: [JS] detect ASI after closing parens.

2017-08-09 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Wed Aug  9 08:19:16 2017
New Revision: 310482

URL: http://llvm.org/viewvc/llvm-project?rev=310482&view=rev
Log:
clang-format: [JS] detect ASI after closing parens.

Summary: A closing parenthesis followed by a declaration or statement should 
always terminate the current statement.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=310482&r1=310481&r2=310482&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Wed Aug  9 08:19:16 2017
@@ -853,7 +853,8 @@ void UnwrappedLineParser::readTokenWithJ
Previous->isOneOf(tok::r_square, tok::r_paren, tok::plusplus,
  tok::minusminus)))
 return addUnwrappedLine();
-  if (PreviousMustBeValue && isJSDeclOrStmt(Keywords, Next))
+  if ((PreviousMustBeValue || Previous->is(tok::r_paren)) &&
+  isJSDeclOrStmt(Keywords, Next))
 return addUnwrappedLine();
 }
 

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=310482&r1=310481&r2=310482&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Wed Aug  9 08:19:16 2017
@@ -1106,6 +1106,10 @@ TEST_F(FormatTestJS, WrapRespectsAutomat
"  readonly ratherLongField = 1;\n"
"}",
getGoogleJSStyleWithColumns(20));
+  verifyFormat("const x = (5 + 9)\n"
+   "const y = 3\n",
+   "const x = (   5 +9)\n"
+   "const y = 3\n");
 }
 
 TEST_F(FormatTestJS, AutomaticSemicolonInsertionHeuristic) {


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


[PATCH] D36491: clang-format: [JS] detect ASI after closing parens.

2017-08-09 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310482: clang-format: [JS] detect ASI after closing parens. 
(authored by mprobst).

Repository:
  rL LLVM

https://reviews.llvm.org/D36491

Files:
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -853,7 +853,8 @@
Previous->isOneOf(tok::r_square, tok::r_paren, tok::plusplus,
  tok::minusminus)))
 return addUnwrappedLine();
-  if (PreviousMustBeValue && isJSDeclOrStmt(Keywords, Next))
+  if ((PreviousMustBeValue || Previous->is(tok::r_paren)) &&
+  isJSDeclOrStmt(Keywords, Next))
 return addUnwrappedLine();
 }
 
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1106,6 +1106,10 @@
"  readonly ratherLongField = 1;\n"
"}",
getGoogleJSStyleWithColumns(20));
+  verifyFormat("const x = (5 + 9)\n"
+   "const y = 3\n",
+   "const x = (   5 +9)\n"
+   "const y = 3\n");
 }
 
 TEST_F(FormatTestJS, AutomaticSemicolonInsertionHeuristic) {


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -853,7 +853,8 @@
Previous->isOneOf(tok::r_square, tok::r_paren, tok::plusplus,
  tok::minusminus)))
 return addUnwrappedLine();
-  if (PreviousMustBeValue && isJSDeclOrStmt(Keywords, Next))
+  if ((PreviousMustBeValue || Previous->is(tok::r_paren)) &&
+  isJSDeclOrStmt(Keywords, Next))
 return addUnwrappedLine();
 }
 
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1106,6 +1106,10 @@
"  readonly ratherLongField = 1;\n"
"}",
getGoogleJSStyleWithColumns(20));
+  verifyFormat("const x = (5 + 9)\n"
+   "const y = 3\n",
+   "const x = (   5 +9)\n"
+   "const y = 3\n");
 }
 
 TEST_F(FormatTestJS, AutomaticSemicolonInsertionHeuristic) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33945: [OpenCL] Add support for missing sub_group functions.

2017-08-09 Thread Joey Gouly via Phabricator via cfe-commits
joey closed this revision.
joey added a comment.

I committed all the parts separately:  r309567 (with r309571 to fix a test), 
r309678 and r310477.


https://reviews.llvm.org/D33945



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


r310483 - Fix broken getAttributeSpellingListIndex for pragma attributes

2017-08-09 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Aug  9 08:27:36 2017
New Revision: 310483

URL: http://llvm.org/viewvc/llvm-project?rev=310483&view=rev
Log:
Fix broken getAttributeSpellingListIndex for pragma attributes

We noticed when implementing a new pragma that the TableGen-generated function 
getAttributeSpellingListIndex() did not work for pragma attributes. It relies 
on the values in the enum AttributeList::Syntax and a new value 
AS_ContextSensitiveKeyword was added changing the value for AS_Pragma. 
Apparently no tests failed since no pragmas currently make use of the 
generated function.

To fix this we can move AS_Pragma back to the value that TableGen code expects. 
Also to prevent changes in the enum from breaking that routine again I added 
calls to getAttributeSpellingListIndex() in the unroll pragma code. That will 
cause some lit test failures if the order is changed. I added a comment to 
remind of this issue in the future.

This assumes we don’t need/want full TableGen support for 
AS_ContextSensitiveKeyword. It currently only appears in getAttrKind and no 
other TableGen-generated routines.

Patch by: mikerice

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

Modified:
cfe/trunk/include/clang/Sema/AttributeList.h
cfe/trunk/lib/Sema/SemaStmtAttr.cpp

Modified: cfe/trunk/include/clang/Sema/AttributeList.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=310483&r1=310482&r2=310483&view=diff
==
--- cfe/trunk/include/clang/Sema/AttributeList.h (original)
+++ cfe/trunk/include/clang/Sema/AttributeList.h Wed Aug  9 08:27:36 2017
@@ -106,10 +106,12 @@ public:
 AS_Microsoft,
 /// __ptr16, alignas(...), etc.
 AS_Keyword,
-/// Context-sensitive version of a keyword attribute.
-AS_ContextSensitiveKeyword,
 /// #pragma ...
 AS_Pragma,
+// Note TableGen depends on the order above.  Do not add or change the 
order
+// without adding related code to TableGen/ClangAttrEmitter.cpp.
+/// Context-sensitive version of a keyword attribute.
+AS_ContextSensitiveKeyword,
   };
 
 private:

Modified: cfe/trunk/lib/Sema/SemaStmtAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAttr.cpp?rev=310483&r1=310482&r2=310483&view=diff
==
--- cfe/trunk/lib/Sema/SemaStmtAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAttr.cpp Wed Aug  9 08:27:36 2017
@@ -100,16 +100,15 @@ static Attr *handleLoopHintAttr(Sema &S,
 return nullptr;
   }
 
-  LoopHintAttr::Spelling Spelling;
+  LoopHintAttr::Spelling Spelling =
+  LoopHintAttr::Spelling(A.getAttributeSpellingListIndex());
   LoopHintAttr::OptionType Option;
   LoopHintAttr::LoopHintState State;
   if (PragmaNoUnroll) {
 // #pragma nounroll
-Spelling = LoopHintAttr::Pragma_nounroll;
 Option = LoopHintAttr::Unroll;
 State = LoopHintAttr::Disable;
   } else if (PragmaUnroll) {
-Spelling = LoopHintAttr::Pragma_unroll;
 if (ValueExpr) {
   // #pragma unroll N
   Option = LoopHintAttr::UnrollCount;
@@ -121,7 +120,6 @@ static Attr *handleLoopHintAttr(Sema &S,
 }
   } else {
 // #pragma clang loop ...
-Spelling = LoopHintAttr::Pragma_clang_loop;
 assert(OptionLoc && OptionLoc->Ident &&
"Attribute must have valid option info.");
 Option = llvm::StringSwitch(


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


[PATCH] D36473: Fix broken getAttributeSpellingListIndex for pragma attributes

2017-08-09 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310483: Fix broken getAttributeSpellingListIndex for pragma 
attributes (authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D36473?vs=110217&id=110404#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36473

Files:
  cfe/trunk/include/clang/Sema/AttributeList.h
  cfe/trunk/lib/Sema/SemaStmtAttr.cpp


Index: cfe/trunk/include/clang/Sema/AttributeList.h
===
--- cfe/trunk/include/clang/Sema/AttributeList.h
+++ cfe/trunk/include/clang/Sema/AttributeList.h
@@ -106,10 +106,12 @@
 AS_Microsoft,
 /// __ptr16, alignas(...), etc.
 AS_Keyword,
-/// Context-sensitive version of a keyword attribute.
-AS_ContextSensitiveKeyword,
 /// #pragma ...
 AS_Pragma,
+// Note TableGen depends on the order above.  Do not add or change the 
order
+// without adding related code to TableGen/ClangAttrEmitter.cpp.
+/// Context-sensitive version of a keyword attribute.
+AS_ContextSensitiveKeyword,
   };
 
 private:
Index: cfe/trunk/lib/Sema/SemaStmtAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaStmtAttr.cpp
+++ cfe/trunk/lib/Sema/SemaStmtAttr.cpp
@@ -100,16 +100,15 @@
 return nullptr;
   }
 
-  LoopHintAttr::Spelling Spelling;
+  LoopHintAttr::Spelling Spelling =
+  LoopHintAttr::Spelling(A.getAttributeSpellingListIndex());
   LoopHintAttr::OptionType Option;
   LoopHintAttr::LoopHintState State;
   if (PragmaNoUnroll) {
 // #pragma nounroll
-Spelling = LoopHintAttr::Pragma_nounroll;
 Option = LoopHintAttr::Unroll;
 State = LoopHintAttr::Disable;
   } else if (PragmaUnroll) {
-Spelling = LoopHintAttr::Pragma_unroll;
 if (ValueExpr) {
   // #pragma unroll N
   Option = LoopHintAttr::UnrollCount;
@@ -121,7 +120,6 @@
 }
   } else {
 // #pragma clang loop ...
-Spelling = LoopHintAttr::Pragma_clang_loop;
 assert(OptionLoc && OptionLoc->Ident &&
"Attribute must have valid option info.");
 Option = llvm::StringSwitch(


Index: cfe/trunk/include/clang/Sema/AttributeList.h
===
--- cfe/trunk/include/clang/Sema/AttributeList.h
+++ cfe/trunk/include/clang/Sema/AttributeList.h
@@ -106,10 +106,12 @@
 AS_Microsoft,
 /// __ptr16, alignas(...), etc.
 AS_Keyword,
-/// Context-sensitive version of a keyword attribute.
-AS_ContextSensitiveKeyword,
 /// #pragma ...
 AS_Pragma,
+// Note TableGen depends on the order above.  Do not add or change the order
+// without adding related code to TableGen/ClangAttrEmitter.cpp.
+/// Context-sensitive version of a keyword attribute.
+AS_ContextSensitiveKeyword,
   };
 
 private:
Index: cfe/trunk/lib/Sema/SemaStmtAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaStmtAttr.cpp
+++ cfe/trunk/lib/Sema/SemaStmtAttr.cpp
@@ -100,16 +100,15 @@
 return nullptr;
   }
 
-  LoopHintAttr::Spelling Spelling;
+  LoopHintAttr::Spelling Spelling =
+  LoopHintAttr::Spelling(A.getAttributeSpellingListIndex());
   LoopHintAttr::OptionType Option;
   LoopHintAttr::LoopHintState State;
   if (PragmaNoUnroll) {
 // #pragma nounroll
-Spelling = LoopHintAttr::Pragma_nounroll;
 Option = LoopHintAttr::Unroll;
 State = LoopHintAttr::Disable;
   } else if (PragmaUnroll) {
-Spelling = LoopHintAttr::Pragma_unroll;
 if (ValueExpr) {
   // #pragma unroll N
   Option = LoopHintAttr::UnrollCount;
@@ -121,7 +120,6 @@
 }
   } else {
 // #pragma clang loop ...
-Spelling = LoopHintAttr::Pragma_clang_loop;
 assert(OptionLoc && OptionLoc->Ident &&
"Attribute must have valid option info.");
 Option = llvm::StringSwitch(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r310449 - [Sema] Extend -Wenum-compare to handle mixed enum comparisons in switch statements

2017-08-09 Thread Nico Weber via cfe-commits
On Wed, Aug 9, 2017 at 10:11 AM, Gábor Horváth  wrote:

> Sure!
>
> There was a follow-up patch that excluded anonymous enums. Is it still
> that bad to introduce it under a new flag?
>

The follow-up was at r310468. https://build.chromium.org/p/chromium.fyi/
builders/ClangToTLinux/builds/8808 is with clang 310476 (i.e. it has the
follow-up) and things still don't build (
https://luci-logdog.appspot.com/v/?s=chromium%2Fbb%2Fchromium.fyi%2FClangToTLinux%2F8808%2F%2B%2Frecipes%2Fsteps%2Fcompile%2F0%2Fstdout).
The warning are in an external dependency (protobuf) that we can't change
very quickly. (And I'd imagine that other codebases out there will have the
same problem.)

So yes, a different flag would still be good.


>
> Regards,
> Gábor
>
>
> On 9 August 2017 at 16:07, Nico Weber  wrote:
>
>> Any way we could put this behind a different flag (say,
>> -Wenum-compare-switch, in the same group as -Wenum-compare, so that
>> -W(no-)enum-compare affects both)? Our codebase was -Wenum-compare clean
>> before this commit but is very not clean now, so we'd now have to disable
>> -Wenum-compare altogether, but then we won't catch regressions in
>> non-switch statements either.
>>
>> On Wed, Aug 9, 2017 at 4:57 AM, Gabor Horvath via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: xazax
>>> Date: Wed Aug  9 01:57:09 2017
>>> New Revision: 310449
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=310449&view=rev
>>> Log:
>>> [Sema] Extend -Wenum-compare to handle mixed enum comparisons in switch
>>> statements
>>>
>>> Patch by: Reka Nikolett Kovacs
>>>
>>> Differential Revision: https://reviews.llvm.org/D36407
>>>
>>> Modified:
>>> cfe/trunk/lib/Sema/SemaStmt.cpp
>>> cfe/trunk/test/Sema/switch.c
>>> cfe/trunk/test/SemaCXX/warn-enum-compare.cpp
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaS
>>> tmt.cpp?rev=310449&r1=310448&r2=310449&view=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Aug  9 01:57:09 2017
>>> @@ -602,14 +602,14 @@ static bool EqEnumVals(const std::pair>>
>>>  /// GetTypeBeforeIntegralPromotion - Returns the pre-promotion type of
>>>  /// potentially integral-promoted expression @p expr.
>>> -static QualType GetTypeBeforeIntegralPromotion(Expr *&expr) {
>>> -  if (ExprWithCleanups *cleanups = dyn_cast(expr))
>>> -expr = cleanups->getSubExpr();
>>> -  while (ImplicitCastExpr *impcast = dyn_cast(expr))
>>> {
>>> -if (impcast->getCastKind() != CK_IntegralCast) break;
>>> -expr = impcast->getSubExpr();
>>> +static QualType GetTypeBeforeIntegralPromotion(const Expr *&E) {
>>> +  if (const auto *CleanUps = dyn_cast(E))
>>> +E = CleanUps->getSubExpr();
>>> +  while (const auto *ImpCast = dyn_cast(E)) {
>>> +if (ImpCast->getCastKind() != CK_IntegralCast) break;
>>> +E = ImpCast->getSubExpr();
>>>}
>>> -  return expr->getType();
>>> +  return E->getType();
>>>  }
>>>
>>>  ExprResult Sema::CheckSwitchCondition(SourceLocation SwitchLoc, Expr
>>> *Cond) {
>>> @@ -743,6 +743,24 @@ static bool ShouldDiagnoseSwitchCaseNotI
>>>return true;
>>>  }
>>>
>>> +static void checkEnumTypesInSwitchStmt(Sema &S, const Expr *Cond,
>>> +   const Expr *Case) {
>>> +  QualType CondType = GetTypeBeforeIntegralPromotion(Cond);
>>> +  QualType CaseType = Case->getType();
>>> +
>>> +  const EnumType *CondEnumType = CondType->getAs();
>>> +  const EnumType *CaseEnumType = CaseType->getAs();
>>> +  if (!CondEnumType || !CaseEnumType)
>>> +return;
>>> +
>>> +  if (S.Context.hasSameUnqualifiedType(CondType, CaseType))
>>> +return;
>>> +
>>> +  S.Diag(Case->getExprLoc(), diag::warn_comparison_of_mixed_enum_types)
>>> +  << CondType << CaseType << Cond->getSourceRange()
>>> +  << Case->getSourceRange();
>>> +}
>>> +
>>>  StmtResult
>>>  Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
>>>  Stmt *BodyStmt) {
>>> @@ -760,7 +778,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocati
>>>
>>>QualType CondType = CondExpr->getType();
>>>
>>> -  Expr *CondExprBeforePromotion = CondExpr;
>>> +  const Expr *CondExprBeforePromotion = CondExpr;
>>>QualType CondTypeBeforePromotion =
>>>GetTypeBeforeIntegralPromotion(CondExprBeforePromotion);
>>>
>>> @@ -843,6 +861,8 @@ Sema::ActOnFinishSwitchStmt(SourceLocati
>>>  break;
>>>}
>>>
>>> +  checkEnumTypesInSwitchStmt(*this, CondExpr, Lo);
>>> +
>>>llvm::APSInt LoVal;
>>>
>>>if (getLangOpts().CPlusPlus11) {
>>>
>>> Modified: cfe/trunk/test/Sema/switch.c
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/swit
>>> ch.c?rev=310449&r1=310448&r2=310449&view=diff
>>> 
>>> ==
>>> --- cfe/trunk/test/Sema/switch.c (ori

[libcxx] r310487 - Change the way the literal operators are defined - now w/o a seperating space. This should be a NFC, but it will change how the compiler parses it.

2017-08-09 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Aug  9 08:42:50 2017
New Revision: 310487

URL: http://llvm.org/viewvc/llvm-project?rev=310487&view=rev
Log:
Change the way the literal operators are defined - now w/o a seperating space. 
This should be a NFC, but it will change how the compiler parses it.

Modified:
libcxx/trunk/include/chrono

Modified: libcxx/trunk/include/chrono
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/chrono?rev=310487&r1=310486&r2=310487&view=diff
==
--- libcxx/trunk/include/chrono (original)
+++ libcxx/trunk/include/chrono Wed Aug  9 08:42:50 2017
@@ -283,18 +283,18 @@ typedef steady_clock high_resolution_clo
 
 }  // chrono
 
-constexpr chrono::hours operator "" h(unsigned 
long long); // C++14
-constexpr chrono::duration> operator "" h(long 
double); // C++14
-constexpr chrono::minutes   operator "" 
min(unsigned long long); // C++14
-constexpr chrono::duration>   operator "" min(long 
double); // C++14
-constexpr chrono::seconds   operator "" s(unsigned 
long long); // C++14
-constexpr chrono::durationoperator "" s(long 
double); // C++14
-constexpr chrono::milliseconds  operator "" 
ms(unsigned long long); // C++14
-constexpr chrono::duration operator "" ms(long 
double); // C++14
-constexpr chrono::microseconds  operator "" 
us(unsigned long long); // C++14
-constexpr chrono::duration operator "" us(long 
double); // C++14
-constexpr chrono::nanoseconds   operator "" 
ns(unsigned long long); // C++14
-constexpr chrono::duration  operator "" ns(long 
double); // C++14
+constexpr chrono::hours operator ""h(unsigned 
long long); // C++14
+constexpr chrono::duration> operator ""h(long 
double); // C++14
+constexpr chrono::minutes   operator 
""min(unsigned long long); // C++14
+constexpr chrono::duration>   operator ""min(long 
double); // C++14
+constexpr chrono::seconds   operator ""s(unsigned 
long long); // C++14
+constexpr chrono::durationoperator ""s(long 
double); // C++14
+constexpr chrono::milliseconds  operator ""ms(unsigned 
long long); // C++14
+constexpr chrono::duration operator ""ms(long 
double); // C++14
+constexpr chrono::microseconds  operator ""us(unsigned 
long long); // C++14
+constexpr chrono::duration operator ""us(long 
double); // C++14
+constexpr chrono::nanoseconds   operator ""ns(unsigned 
long long); // C++14
+constexpr chrono::duration  operator ""ns(long 
double); // C++14
 
 }  // std
 */
@@ -1087,67 +1087,67 @@ inline namespace literals
   inline namespace chrono_literals
   {
 
-constexpr chrono::hours operator"" h(unsigned long long __h)
+constexpr chrono::hours operator""h(unsigned long long __h)
 {
 return chrono::hours(static_cast(__h));
 }
 
-constexpr chrono::duration> operator"" h(long 
double __h)
+constexpr chrono::duration> operator""h(long 
double __h)
 {
 return chrono::duration>(__h);
 }
 
 
-constexpr chrono::minutes operator"" min(unsigned long long __m)
+constexpr chrono::minutes operator""min(unsigned long long __m)
 {
 return chrono::minutes(static_cast(__m));
 }
 
-constexpr chrono::duration> operator"" min(long 
double __m)
+constexpr chrono::duration> operator""min(long 
double __m)
 {
 return chrono::duration> (__m);
 }
 
 
-constexpr chrono::seconds operator"" s(unsigned long long __s)
+constexpr chrono::seconds operator""s(unsigned long long __s)
 {
 return chrono::seconds(static_cast(__s));
 }
 
-constexpr chrono::duration operator"" s(long double __s)
+constexpr chrono::duration operator""s(long double __s)
 {
 return chrono::duration (__s);
 }
 
 
-constexpr chrono::milliseconds operator"" ms(unsigned long long __ms)
+constexpr chrono::milliseconds operator""ms(unsigned long long __ms)
 {
 return 
chrono::milliseconds(static_cast(__ms));
 }
 
-constexpr chrono::duration operator"" ms(long double 
__ms)
+constexpr chrono::duration operator""ms(long double 
__ms)
 {
 return chrono::duration(__ms);
 }
 
 
-constexpr chrono::microseconds operator"" us(unsigned long long __us)
+constexpr chrono::microseconds operator""us(unsigned long long __us)
 {
 return 
chrono::microseconds(static_cast(__us));
 }
 
-constexpr chrono::duration operator"" us(long double 
__us)
+constexpr chrono::duration operator""us(long double 
__us)
 {
 return chrono::duration (__us);
 }
 
 
-constexpr chrono::nanoseconds operator"" ns(unsig

[PATCH] D36526: [Sema] Assign new flag -Wenum-compare-switch to switch-related parts of -Wenum-compare

2017-08-09 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs created this revision.

This patch assigns switch-related parts of the `-Wenum-compare` diagnostic to a 
new flag `-Wenum-compare-switch`.

`-Wenum-compare-switch` is put into the same group as `-Wenum-compare` so that 
`-W(no-)enum-compare` affects both.


https://reviews.llvm.org/D36526

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaStmt.cpp
  test/Sema/switch.c
  test/SemaCXX/warn-enum-compare.cpp


Index: test/SemaCXX/warn-enum-compare.cpp
===
--- test/SemaCXX/warn-enum-compare.cpp
+++ test/SemaCXX/warn-enum-compare.cpp
@@ -212,19 +212,19 @@
   switch (a) {
 case name1::F1: break;
 case name1::F3: break;
-case name2::B2: break; // expected-warning {{comparison of two values with 
different enumeration types ('name1::Foo' and 'name2::Baz')}}
+case name2::B2: break; // expected-warning {{comparison of two values with 
different enumeration types in switch statement ('name1::Foo' and 
'name2::Baz')}}
   }
 
   switch (x) {
 case FooB: break;
 case FooC: break;
-case BarD: break; // expected-warning {{comparison of two values with 
different enumeration types ('Foo' and 'Bar')}}
+case BarD: break; // expected-warning {{comparison of two values with 
different enumeration types in switch statement ('Foo' and 'Bar')}}
   }
 
   switch(getBar()) {
 case BarE: break;
 case BarF: break;
-case FooA: break; // expected-warning {{comparison of two values with 
different enumeration types ('Bar' and 'Foo')}}
+case FooA: break; // expected-warning {{comparison of two values with 
different enumeration types in switch statement ('Bar' and 'Foo')}}
   }
 
   switch(x) {
Index: test/Sema/switch.c
===
--- test/Sema/switch.c
+++ test/Sema/switch.c
@@ -372,7 +372,7 @@
   case EE1_b: break;
   case EE1_c: break; // no-warning
   case EE1_d: break; // expected-warning {{case value not in enumerated type 
'enum ExtendedEnum1'}}
-  // expected-warning@-1 {{comparison of two values with different enumeration 
types ('enum ExtendedEnum1' and 'const enum ExtendedEnum1_unrelated')}}
+  // expected-warning@-1 {{comparison of two values with different enumeration 
types in switch statement ('enum ExtendedEnum1' and 'const enum 
ExtendedEnum1_unrelated')}}
   }
 }
 
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -762,7 +762,7 @@
   if (S.Context.hasSameUnqualifiedType(CondType, CaseType))
 return;
 
-  S.Diag(Case->getExprLoc(), diag::warn_comparison_of_mixed_enum_types)
+  S.Diag(Case->getExprLoc(), diag::warn_comparison_of_mixed_enum_types_switch)
   << CondType << CaseType << Cond->getSourceRange()
   << Case->getSourceRange();
 }
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -5916,7 +5916,11 @@
 def warn_comparison_of_mixed_enum_types : Warning<
   "comparison of two values with different enumeration types"
   "%diff{ ($ and $)|}0,1">,
-  InGroup>;
+  InGroup;
+def warn_comparison_of_mixed_enum_types_switch : Warning<
+  "comparison of two values with different enumeration types in switch 
statement"
+  "%diff{ ($ and $)|}0,1">,
+  InGroup;
 def warn_null_in_arithmetic_operation : Warning<
   "use of NULL in arithmetic operation">,
   InGroup;
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -454,6 +454,8 @@
 def SwitchBool : DiagGroup<"switch-bool">;
 def SwitchEnum : DiagGroup<"switch-enum">;
 def Switch : DiagGroup<"switch">;
+def EnumCompareSwitch : DiagGroup<"enum-compare-switch">;
+def EnumCompare   : DiagGroup<"enum-compare", [EnumCompareSwitch]>;
 def ImplicitFallthroughPerFunction :
   DiagGroup<"implicit-fallthrough-per-function">;
 def ImplicitFallthrough  : DiagGroup<"implicit-fallthrough",


Index: test/SemaCXX/warn-enum-compare.cpp
===
--- test/SemaCXX/warn-enum-compare.cpp
+++ test/SemaCXX/warn-enum-compare.cpp
@@ -212,19 +212,19 @@
   switch (a) {
 case name1::F1: break;
 case name1::F3: break;
-case name2::B2: break; // expected-warning {{comparison of two values with different enumeration types ('name1::Foo' and 'name2::Baz')}}
+case name2::B2: break; // expected-warning {{comparison of two values with different enumeration types in switch statement ('name1::Foo' and 'name2::Baz')}}
   }
 
   switch (x) {
 case FooB: break;
 case FooC: break;
-case BarD: break; // expected-warning {{comparison of two values with different e

[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas

2017-08-09 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood created this revision.

This patch provides an implementation for P0428R2 .


https://reviews.llvm.org/D36527

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Sema/ScopeInfo.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseExprCXX.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaType.cpp
  test/Parser/cxx2a-template-lambdas.cpp
  test/SemaCXX/cxx2a-template-lambdas.cpp
  www/cxx_status.html

Index: www/cxx_status.html
===
--- www/cxx_status.html
+++ www/cxx_status.html
@@ -777,13 +777,12 @@
 
 C++2a implementation status
 
-Clang does not yet support any of the proposed features of
-
+Clang has experimental support for some proposed features of
 the C++ standard following C++17, provisionally named C++2a.
 Note that support for these features may change or be removed without notice,
 as the draft C++2a standard evolves.
 
-
+You can use Clang in C++2a mode with the -std=c++2a option.
 
 
 List of features and minimum Clang version with support
@@ -823,7 +822,7 @@
 
   template-parameter-list for generic lambdas
   http://wg21.link/p0428r2";>P0428R2
-  No
+  SVN
 
 
   Initializer list constructors in class template argument deduction
Index: test/SemaCXX/cxx2a-template-lambdas.cpp
===
--- test/SemaCXX/cxx2a-template-lambdas.cpp
+++ test/SemaCXX/cxx2a-template-lambdas.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++2a -verify %s
+
+template
+constexpr bool is_same = false;
+
+template
+constexpr bool is_same = true;
+
+template
+struct DummyTemplate { };
+
+void func() {
+  auto L0 = [](T arg) {
+static_assert(is_same);
+  };
+  L0(0);
+
+  auto L1 = [] {
+static_assert(I == 5);
+  };
+  L1.operator()<5>();
+
+  auto L2 = [] class T, class U>(T &&arg) {
+static_assert(is_same, DummyTemplate>);
+  };
+  L2(DummyTemplate());
+}
+
+template // expected-note {{declared here}}
+struct ShadowMe {
+  void member_func() {
+auto L = [] { }; // expected-error {{'T' shadows template parameter}}
+  }
+};
Index: test/Parser/cxx2a-template-lambdas.cpp
===
--- test/Parser/cxx2a-template-lambdas.cpp
+++ test/Parser/cxx2a-template-lambdas.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++2a %s -verify
+
+auto L0 = []<> { }; //expected-error {{expected template parameter list}}
+
+auto L1 = [] { };
+auto L2 = [](T1 arg1, T2 arg2) -> T1 { };
+auto L3 = [](auto arg) { T t; };
+auto L4 = []() { };
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -2789,8 +2789,8 @@
 // template parameter type.
 sema::LambdaScopeInfo *LSI = SemaRef.getCurLambda();
 assert(LSI && "No LambdaScopeInfo on the stack!");
-const unsigned TemplateParameterDepth = LSI->AutoTemplateParameterDepth;
-const unsigned AutoParameterPosition = LSI->AutoTemplateParams.size();
+const unsigned TemplateParameterDepth = LSI->TemplateParameterDepth;
+const unsigned AutoParameterPosition = LSI->TemplateParams.size();
 const bool IsParameterPack = D.hasEllipsis();
 
 // Create the TemplateTypeParmDecl here to retrieve the corresponding
@@ -2802,7 +2802,7 @@
 /*KeyLoc*/SourceLocation(), /*NameLoc*/D.getLocStart(),
 TemplateParameterDepth, AutoParameterPosition,
 /*Identifier*/nullptr, false, IsParameterPack);
-LSI->AutoTemplateParams.push_back(CorrespondingTemplateParam);
+LSI->TemplateParams.push_back(CorrespondingTemplateParam);
 // Replace the 'auto' in the function parameter with this invented 
 // template type parameter.
 // FIXME: Retain some type sugar to indicate that this was written
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -229,15 +229,17 @@
   if (LSI->GLTemplateParameterList)
 return LSI->GLTemplateParameterList;
 
-  if (!LSI->AutoTemplateParams.empty()) {
-SourceRange IntroRange = LSI->IntroducerRange;
-SourceLocation LAngleLoc = IntroRange.getBegin();
-SourceLocation RAngleLoc = IntroRange.getEnd();
+  if (!LSI->TemplateParams.empty()) {
+SourceRange ListRange = LSI->ExplicitTemplateParamsRange.isValid()
+  ? LSI->ExplicitTemplateParamsRange
+  : LSI->IntroducerRange;
+SourceLocation LAngleLoc = ListRange.getBegin();
+SourceLocation RAngleLoc = ListRange.getEnd();
 LSI->GLTemplateParameterList = TemplateParameterList::Create(
 SemaRef.Context,
 /*Template kw loc*/ SourceLocation(), LAngleLoc,
-llvm::makeArrayRef((NamedDecl *const *)LSI->AutoTemplateParams.data(),
-  

[clang-tools-extra] r310491 - [clang-tidy] Ignore newlines in checks list

2017-08-09 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Aug  9 09:00:31 2017
New Revision: 310491

URL: http://llvm.org/viewvc/llvm-project?rev=310491&view=rev
Log:
[clang-tidy] Ignore newlines in checks list

This is a follow up to https://reviews.llvm.org/D30567 where I overlooked that
LLVM YAML parser doesn't support multiline literal folding.

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp

clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=310491&r1=310490&r2=310491&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Wed Aug  
9 09:00:31 2017
@@ -115,7 +115,7 @@ ClangTidyError::ClangTidyError(StringRef
 // Returns true if GlobList starts with the negative indicator ('-'), removes 
it
 // from the GlobList.
 static bool ConsumeNegativeIndicator(StringRef &GlobList) {
-  GlobList = GlobList.trim(' ');
+  GlobList = GlobList.trim(" \r\n");
   if (GlobList.startswith("-")) {
 GlobList = GlobList.substr(1);
 return true;

Modified: 
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp?rev=310491&r1=310490&r2=310491&view=diff
==
--- 
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
 (original)
+++ 
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
 Wed Aug  9 09:00:31 2017
@@ -74,7 +74,7 @@ TEST(GlobList, WhitespacesAtBegin) {
 }
 
 TEST(GlobList, Complex) {
-  GlobList Filter("*,-a.*, -b.*,   a.1.* ,-a.1.A.*,-..,-...,-..+,-*$, -*qwe* 
");
+  GlobList Filter("*,-a.*, -b.*, \r  \n  a.1.* ,-a.1.A.*,-..,-...,-..+,-*$, 
-*qwe* ");
 
   EXPECT_TRUE(Filter.contains("aaa"));
   EXPECT_TRUE(Filter.contains("qqq"));


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


[PATCH] D36482: Enable SanitizerKind::Vptr on NetBSD/X86 and X86_64

2017-08-09 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

check-ubsan

  -- Testing: 172 tests, 8 threads --
  Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
  Testing Time: 20.19s
Expected Passes: 156
Unsupported Tests  : 16

I will enable more options and extend this commit.


Repository:
  rL LLVM

https://reviews.llvm.org/D36482



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


[PATCH] D29905: [OpenMP] Pass argument to device kernel by reference when map is used.

2017-08-09 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea closed this revision.
gtbercea added a comment.

Already covered by https://reviews.llvm.org/D34888


Repository:
  rL LLVM

https://reviews.llvm.org/D29905



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


[PATCH] D34512: Add preliminary Cross Translation Unit support library

2017-08-09 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

Apart from those in the in-line comments, I have a question: how safe is this 
library to `Release` builds? I know this is only a submodule dependency for the 
"real deal" in https://reviews.llvm.org/D30691, but I have seen some asserts 
that "imported function should already have a body" and such.

Will the static analyzer handle these errors gracefully and fall back to 
"function is unknown, let's throw my presumptions out of the window" or will it 
bail away? I'm explicitly thinking of the assert-lacking `Release` build.




Comment at: include/clang/Basic/AllDiagnostics.h:20
 #include "clang/AST/CommentDiagnostic.h"
+#include "clang/CrossTU/CrossTUDiagnostic.h"
 #include "clang/Analysis/AnalysisDiagnostic.h"

Import file order?



Comment at: include/clang/CrossTU/CrossTranslationUnit.h:42
+/// Note that this class also implements caching.
+class CrossTranslationUnit {
+public:

Does the name of this class make sense? If I say


```
CrossTranslationUnit *ctuptr = new CrossTranslationUnit(...);
```

did I construct a new //CrossTranslationUnit//? What even **is** a 
//CrossTranslationUnit//? Other class names, such as `ASTImporter`, `DiagOpts`, 
and `FrontendAction`, etc. somehow feel better at ~~transmitting~~ reflecting 
upon their meaning in their name.





Comment at: lib/CrossTU/CrossTranslationUnit.cpp:45
+
+/// Recursively visit the funtion decls of a DeclContext, and looks up a
+/// function based on mangled name.

"visit**s** (...) and looks up" or "visit (...) and look up"



Comment at: lib/CrossTU/CrossTranslationUnit.cpp:46
+/// Recursively visit the funtion decls of a DeclContext, and looks up a
+/// function based on mangled name.
+const FunctionDecl *

If we are using //USR// for lookup, then why does this look up "based on 
mangled name"?



Comment at: tools/CMakeLists.txt:25
   add_clang_subdirectory(scan-view)
+  add_clang_subdirectory(clang-func-mapping)
 endif()

The other "blocks" in this file look //somewhat// in alphabetic order, perhaps 
this should be added a few lines above?


https://reviews.llvm.org/D34512



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


[PATCH] D35372: [clang-tidy] Refactor the code and add a close-on-exec check on memfd_create() in Android module.

2017-08-09 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

I'm not sure this approach is the best to deal with the boilerplate, but it 
seems like an improvement compared to repeating code. See a few comments inline.




Comment at: clang-tidy/android/CloexecCheck.cpp:66
+
+StringRef CloexecCheck::getSpellingArg(const MatchFinder::MatchResult &Result,
+   int N) const {

1. Should this be a class method?
2. Is this ever used? (if it is going to be used in a different check, let's 
postpone its addition to that moment)



Comment at: clang-tidy/android/CloexecCheck.h:43
+ast_matchers::callExpr(
+ast_matchers::callee(FuncDecl().bind(FuncDeclBindingStr)))
+.bind(FuncBindingStr),

Can we make this method non-template and put its implementation to the .cpp 
file? It could accept a Matcher or something like that and just 
apply it:

void registerForCall(MatchFinder *Finder, Matcher Function) {
  Finder->addMatcher(calExpr(callee(functionDecl(isExternC(), 
Function).bind(...))).bind(...), this);
}

Then you could make `FuncDeclBindingStr` and `FuncBindingStr` local to the file.



Comment at: clang-tidy/android/CloexecCheck.h:47
+  }
+  /// Currently, we has three types of fixes.
+  ///

s/we has/we have/



Comment at: clang-tidy/android/CloexecCheck.h:102-137
+  ast_matchers::internal::Matcher hasIntegerParameter(int N) {
+return ast_matchers::hasParameter(
+N, ast_matchers::hasType(ast_matchers::isInteger()));
+  }
+
+  ast_matchers::internal::Matcher
+  hasCharPointerTypeParameter(int N) {

These methods don't add much value: `hasParameter(N, hasType(isInteger()))` is 
not much longer or harder to read than `hasIntegerParameter(N)`, etc. Also 
having these utilities as non-static methods doesn't make much sense. If you 
want a shorter way to describe function signatures, I would suggest a single 
utility function `hasParameters()` that would take a list of type matchers and 
apply them to the corresponding parameters. That one could be useful more 
broadly than in this specific check, so it could be placed in utils/ (and later 
in ASTMatchers.h, if we find enough potential users).



Comment at: clang-tidy/android/CloexecCheck.h:140
+private:
+  const static char *FuncDeclBindingStr;
+  const static char *FuncBindingStr;

You're missing one more const: `static const char * const FuncDeclBindingStr;`


https://reviews.llvm.org/D35372



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


[PATCH] D36529: Fixed a race condition in PrecompiledPreamble.

2017-08-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Catched by a test from https://reviews.llvm.org/D36261.


https://reviews.llvm.org/D36529



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


[PATCH] D36529: Fixed a race condition in PrecompiledPreamble.

2017-08-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.

Two PrecompiledPreambles, used in parallel on separate threads,
could be writing preamble to the same temporary file.


https://reviews.llvm.org/D36529

Files:
  lib/Frontend/PrecompiledPreamble.cpp


Index: lib/Frontend/PrecompiledPreamble.cpp
===
--- lib/Frontend/PrecompiledPreamble.cpp
+++ lib/Frontend/PrecompiledPreamble.cpp
@@ -28,6 +28,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/MutexGuard.h"
+#include "llvm/Support/Process.h"
 
 using namespace clang;
 
@@ -462,9 +463,16 @@
 PrecompiledPreamble::TempPCHFile::createInSystemTempDir(const Twine &Prefix,
 StringRef Suffix) {
   llvm::SmallString<64> File;
-  auto EC = llvm::sys::fs::createTemporaryFile(Prefix, Suffix, /*ref*/ File);
+  // Using a version of createTemporaryFile with a file descriptor guarantees
+  // that we would never get a race condition in a multi-threaded setting 
(i.e.,
+  // multiple threads getting the same temporary path).
+  int FD;
+  auto EC = llvm::sys::fs::createTemporaryFile(Prefix, Suffix, /*ref*/ FD,
+   /*ref*/ File);
   if (EC)
 return EC;
+  // We only needed to make sure the file exists, close the file right away.
+  llvm::sys::Process::SafelyCloseFileDescriptor(FD);
   return TempPCHFile(std::move(File).str());
 }
 


Index: lib/Frontend/PrecompiledPreamble.cpp
===
--- lib/Frontend/PrecompiledPreamble.cpp
+++ lib/Frontend/PrecompiledPreamble.cpp
@@ -28,6 +28,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/MutexGuard.h"
+#include "llvm/Support/Process.h"
 
 using namespace clang;
 
@@ -462,9 +463,16 @@
 PrecompiledPreamble::TempPCHFile::createInSystemTempDir(const Twine &Prefix,
 StringRef Suffix) {
   llvm::SmallString<64> File;
-  auto EC = llvm::sys::fs::createTemporaryFile(Prefix, Suffix, /*ref*/ File);
+  // Using a version of createTemporaryFile with a file descriptor guarantees
+  // that we would never get a race condition in a multi-threaded setting (i.e.,
+  // multiple threads getting the same temporary path).
+  int FD;
+  auto EC = llvm::sys::fs::createTemporaryFile(Prefix, Suffix, /*ref*/ FD,
+   /*ref*/ File);
   if (EC)
 return EC;
+  // We only needed to make sure the file exists, close the file right away.
+  llvm::sys::Process::SafelyCloseFileDescriptor(FD);
   return TempPCHFile(std::move(File).str());
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36452: [clang-tidy] Fix another crash in make-unique check.

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

Thank you for the fix!
Looks good!




Comment at: test/clang-tidy/modernize-make-unique.cpp:419
+
+class UniqueFoo : public std::unique_ptr {
+ public:

I suspected folks were doing weird stuff to cause this crash ;]


https://reviews.llvm.org/D36452



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


[PATCH] D36482: Enable SanitizerKind::Vptr on NetBSD/X86 and X86_64

2017-08-09 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski updated this revision to Diff 110420.
krytarowski edited the summary of this revision.
krytarowski added a comment.

Enable more sanitizers.


Repository:
  rL LLVM

https://reviews.llvm.org/D36482

Files:
  lib/Driver/ToolChains/NetBSD.cpp


Index: lib/Driver/ToolChains/NetBSD.cpp
===
--- lib/Driver/ToolChains/NetBSD.cpp
+++ lib/Driver/ToolChains/NetBSD.cpp
@@ -422,6 +422,14 @@
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   if (IsX86 || IsX86_64) {
 Res |= SanitizerKind::Address;
+Res |= SanitizerKind::Vptr;
+Res |= SanitizerKind::Leak;
+Res |= SanitizerKind::SafeStack;
+Res |= SanitizerKind::Function;
+  }
+  if (IsX86_64) {
+Res |= SanitizerKind::Leak;
+Res |= SanitizerKind::Thread;
   }
   return Res;
 }


Index: lib/Driver/ToolChains/NetBSD.cpp
===
--- lib/Driver/ToolChains/NetBSD.cpp
+++ lib/Driver/ToolChains/NetBSD.cpp
@@ -422,6 +422,14 @@
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   if (IsX86 || IsX86_64) {
 Res |= SanitizerKind::Address;
+Res |= SanitizerKind::Vptr;
+Res |= SanitizerKind::Leak;
+Res |= SanitizerKind::SafeStack;
+Res |= SanitizerKind::Function;
+  }
+  if (IsX86_64) {
+Res |= SanitizerKind::Leak;
+Res |= SanitizerKind::Thread;
   }
   return Res;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r310496 - [clang-tidy] Fix another crash in make-unique check.

2017-08-09 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Aug  9 10:03:42 2017
New Revision: 310496

URL: http://llvm.org/viewvc/llvm-project?rev=310496&view=rev
Log:
[clang-tidy] Fix another crash in make-unique check.

Summary:
The crash happens when calling `reset` method without any preceding
operation like "->" or ".", this could happen in a subclass of the
"std::unique_ptr".

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, xazax.hun, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp?rev=310496&r1=310495&r2=310496&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp Wed Aug  
9 10:03:42 2017
@@ -199,6 +199,13 @@ void MakeSmartPtrCheck::checkReset(Sourc
 return;
   }
 
+  // There are some cases where we don't have operator ("." or "->") of the
+  // "reset" expression, e.g. call "reset()" method directly in the subclass of
+  // "std::unique_ptr<>". We skip these cases.
+  if (OperatorLoc.isInvalid()) {
+return;
+  }
+
   auto Diag = diag(ResetCallStart, "use %0 instead")
   << MakeSmartPtrFunctionName;
 

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp?rev=310496&r1=310495&r2=310496&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp Wed Aug  
9 10:03:42 2017
@@ -415,3 +415,16 @@ void macro() {
   g2(t);
 }
 #undef DEFINE
+
+class UniqueFoo : public std::unique_ptr {
+ public:
+  void foo() {
+reset(new Foo);
+this->reset(new Foo);
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use std::make_unique instead
+// CHECK-FIXES: *this = std::make_unique();
+(*this).reset(new Foo);
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
+// CHECK-FIXES: (*this) = std::make_unique();
+  }
+};


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


[PATCH] D36452: [clang-tidy] Fix another crash in make-unique check.

2017-08-09 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310496: [clang-tidy] Fix another crash in make-unique check. 
(authored by hokein).

Repository:
  rL LLVM

https://reviews.llvm.org/D36452

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp


Index: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -199,6 +199,13 @@
 return;
   }
 
+  // There are some cases where we don't have operator ("." or "->") of the
+  // "reset" expression, e.g. call "reset()" method directly in the subclass of
+  // "std::unique_ptr<>". We skip these cases.
+  if (OperatorLoc.isInvalid()) {
+return;
+  }
+
   auto Diag = diag(ResetCallStart, "use %0 instead")
   << MakeSmartPtrFunctionName;
 
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
@@ -415,3 +415,16 @@
   g2(t);
 }
 #undef DEFINE
+
+class UniqueFoo : public std::unique_ptr {
+ public:
+  void foo() {
+reset(new Foo);
+this->reset(new Foo);
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use std::make_unique instead
+// CHECK-FIXES: *this = std::make_unique();
+(*this).reset(new Foo);
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
+// CHECK-FIXES: (*this) = std::make_unique();
+  }
+};


Index: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -199,6 +199,13 @@
 return;
   }
 
+  // There are some cases where we don't have operator ("." or "->") of the
+  // "reset" expression, e.g. call "reset()" method directly in the subclass of
+  // "std::unique_ptr<>". We skip these cases.
+  if (OperatorLoc.isInvalid()) {
+return;
+  }
+
   auto Diag = diag(ResetCallStart, "use %0 instead")
   << MakeSmartPtrFunctionName;
 
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
@@ -415,3 +415,16 @@
   g2(t);
 }
 #undef DEFINE
+
+class UniqueFoo : public std::unique_ptr {
+ public:
+  void foo() {
+reset(new Foo);
+this->reset(new Foo);
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use std::make_unique instead
+// CHECK-FIXES: *this = std::make_unique();
+(*this).reset(new Foo);
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
+// CHECK-FIXES: (*this) = std::make_unique();
+  }
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36530: [Parse] Document PrintStats, SkipFunctionBodies

2017-08-09 Thread Brian Gesiak via Phabricator via cfe-commits
modocache created this revision.

Add documentation for `clang::ParseAST` parameters `PrintStats` and
`SkipFunctionBodies`. Also, remove a tiny bit of trailing whitespace.


https://reviews.llvm.org/D36530

Files:
  include/clang/Parse/ParseAST.h


Index: include/clang/Parse/ParseAST.h
===
--- include/clang/Parse/ParseAST.h
+++ include/clang/Parse/ParseAST.h
@@ -29,10 +29,13 @@
   /// This operation inserts the parsed decls into the translation
   /// unit held by Ctx.
   ///
+  /// \param PrintStats Whether to print LLVM statistics related to parsing.
   /// \param TUKind The kind of translation unit being parsed.
-  ///
   /// \param CompletionConsumer If given, an object to consume code completion
   /// results.
+  /// \param SkipFunctionBodies Whether to skip parsing of function bodies.
+  /// This option can be used, for example, to speed up searches for
+  /// delcarations/definitions when indexing.
   void ParseAST(Preprocessor &pp, ASTConsumer *C,
 ASTContext &Ctx, bool PrintStats = false,
 TranslationUnitKind TUKind = TU_Complete,
@@ -43,7 +46,7 @@
   /// abstract syntax tree.
   void ParseAST(Sema &S, bool PrintStats = false,
 bool SkipFunctionBodies = false);
-  
+
 }  // end namespace clang
 
 #endif


Index: include/clang/Parse/ParseAST.h
===
--- include/clang/Parse/ParseAST.h
+++ include/clang/Parse/ParseAST.h
@@ -29,10 +29,13 @@
   /// This operation inserts the parsed decls into the translation
   /// unit held by Ctx.
   ///
+  /// \param PrintStats Whether to print LLVM statistics related to parsing.
   /// \param TUKind The kind of translation unit being parsed.
-  ///
   /// \param CompletionConsumer If given, an object to consume code completion
   /// results.
+  /// \param SkipFunctionBodies Whether to skip parsing of function bodies.
+  /// This option can be used, for example, to speed up searches for
+  /// delcarations/definitions when indexing.
   void ParseAST(Preprocessor &pp, ASTConsumer *C,
 ASTContext &Ctx, bool PrintStats = false,
 TranslationUnitKind TUKind = TU_Complete,
@@ -43,7 +46,7 @@
   /// abstract syntax tree.
   void ParseAST(Sema &S, bool PrintStats = false,
 bool SkipFunctionBodies = false);
-  
+
 }  // end namespace clang
 
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36482: Enable SanitizerKind::Vptr on NetBSD/X86 and X86_64

2017-08-09 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

check-safestack

  -- Testing: 8 tests, 8 threads --
  Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
  Testing Time: 0.56s
Expected Passes: 7
Unsupported Tests  : 1

I will research how to add the requested tests.


Repository:
  rL LLVM

https://reviews.llvm.org/D36482



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


[PATCH] D36531: [Parse] Document Parser::SkipFunctionBodies

2017-08-09 Thread Brian Gesiak via Phabricator via cfe-commits
modocache created this revision.

https://reviews.llvm.org/D36531

Files:
  include/clang/Parse/Parser.h


Index: include/clang/Parse/Parser.h
===
--- include/clang/Parse/Parser.h
+++ include/clang/Parse/Parser.h
@@ -253,6 +253,10 @@
   /// be NULL.
   bool ParsingInObjCContainer;
 
+  /// Whether to skip parsing of function bodies.
+  ///
+  /// This option can be used, for example, to speed up searches for
+  /// delcarations/definitions when indexing.
   bool SkipFunctionBodies;
 
   /// The location of the expression statement that is being parsed right now.


Index: include/clang/Parse/Parser.h
===
--- include/clang/Parse/Parser.h
+++ include/clang/Parse/Parser.h
@@ -253,6 +253,10 @@
   /// be NULL.
   bool ParsingInObjCContainer;
 
+  /// Whether to skip parsing of function bodies.
+  ///
+  /// This option can be used, for example, to speed up searches for
+  /// delcarations/definitions when indexing.
   bool SkipFunctionBodies;
 
   /// The location of the expression statement that is being parsed right now.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35932: [clang-tidy] Add integer division check

2017-08-09 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

A few more nits.




Comment at: clang-tidy/bugprone/IntegerDivisionCheck.cpp:40-44
+  hasAncestor(
+  castExpr(hasCastKind(CK_IntegralToFloating)).bind("FloatCast")),
+  unless(hasAncestor(
+  expr(Exceptions,
+   hasAncestor(castExpr(equalsBoundNode("FloatCast")))

The way `hasAncestor` is used in this code makes me uneasy. Each nested 
ancestor traversal can potentially slow down matching by a factor of the depth 
of the AST tree, which may lead to poor performance on certain types of code 
(nested descendant traversal is much worse though). Some of the overhead may be 
compensated by memoization, but it's hard to predict where it will actually 
work.

It's usually better to avoid nested ancestor traversals, if there are good 
alternatives. Here I don't see a better possibility with matchers, but it's to 
go one level lower and use RecursiveASTVisitor directly. Without constructing / 
discovering a problematic case it's hard to tell whether the performance win of 
switching to RAV is worth the added complexity, so I'm not suggesting to do 
that yet. Just mentioning a possible issue to be aware of.



Comment at: clang-tidy/bugprone/IntegerDivisionCheck.cpp:51
+  const auto *IntDiv = Result.Nodes.getNodeAs("IntDiv");
+  diag(IntDiv->getLocStart(), "integer division; possible precision loss");
+}

Maybe expand the message to describe the pattern the check matches more 
precisely? E.g. "result of an integer division is used in a floating point 
context; possible loss of precision"?



Comment at: docs/ReleaseNotes.rst:63-64
+
+  Finds cases of integer divisions that seem to alter the meaning of the
+  surrounding code.
 

The description is somewhat vague. How about "Finds cases where integer 
division in floating point context is likely to cause unintended loss of 
precision."? Same in the docs below.



Comment at: test/clang-tidy/bugprone-integer-division.cpp:14
+  return x / y - 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: integer division; possible 
precision loss [bugprone-integer-division]
+}

It's better to truncate repeated fragments of the messages, especially when 
they exceed 80 characters (better on a word boundary ;).


https://reviews.llvm.org/D35932



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


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

2017-08-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Looks like this test is failing on macOS again after this change:

http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/39231/testReport/Clang/Driver/openmp_offload_c/

Can you please take a look?


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D36532: Add -std=c++17

2017-08-09 Thread Hans Wennborg via Phabricator via cfe-commits
hans created this revision.

As suggested on PR33912.

Trying to keep this small to make it easy to merge to the 5.0 branch. We can do 
a follow-up with more thorough renaming (diagnostic text, options, ids, etc.) 
later.

(For c++14 this was done in r215982, and I think a smaller patch for the 3.5 
branch: 
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20140818/113013.html)


https://reviews.llvm.org/D36532

Files:
  include/clang/Frontend/LangStandards.def
  test/Driver/unknown-std.cpp
  test/SemaCXX/cxx1z-init-statement.cpp


Index: test/SemaCXX/cxx1z-init-statement.cpp
===
--- test/SemaCXX/cxx1z-init-statement.cpp
+++ test/SemaCXX/cxx1z-init-statement.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++1z -verify %s
+// RUN: %clang_cc1 -std=c++17 -verify %s
 
 void testIf() {
   int x = 0;
Index: test/Driver/unknown-std.cpp
===
--- test/Driver/unknown-std.cpp
+++ test/Driver/unknown-std.cpp
@@ -13,8 +13,8 @@
 // CHECK-NEXT: note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU 
extensions' standard
 // CHECK-NEXT: note: use 'c++14' for 'ISO C++ 2014 with amendments' standard
 // CHECK-NEXT: note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU 
extensions' standard
-// CHECK-NEXT: note: use 'c++1z' for 'Working draft for ISO C++ 2017' standard
-// CHECK-NEXT: note: use 'gnu++1z' for 'Working draft for ISO C++ 2017 with 
GNU extensions' standard
+// CHECK-NEXT: note: use 'c++17' for 'ISO C++ 2017' standard
+// CHECK-NEXT: note: use 'gnu++17' for 'ISO C++ 2017 with GNU extensions' 
standard
 // CHECK-NEXT: note: use 'c++2a' for 'Working draft for ISO C++ 2020' standard
 // CHECK-NEXT: note: use 'gnu++2a' for 'Working draft for ISO C++ 2020 with 
GNU extensions' standard
 // CUDA-NEXT: note: use 'cuda' for 'NVIDIA CUDA(tm)' standard
Index: include/clang/Frontend/LangStandards.def
===
--- include/clang/Frontend/LangStandards.def
+++ include/clang/Frontend/LangStandards.def
@@ -109,15 +109,17 @@
  GNUMode)
 LANGSTANDARD_ALIAS_DEPR(gnucxx14, "gnu++1y")
 
-LANGSTANDARD(cxx1z, "c++1z",
- CXX, "Working draft for ISO C++ 2017",
+LANGSTANDARD(cxx17, "c++17",
+ CXX, "ISO C++ 2017",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z 
|
  Digraphs | HexFloat)
+LANGSTANDARD_ALIAS_DEPR(cxx17, "c++1z")
 
-LANGSTANDARD(gnucxx1z, "gnu++1z",
- CXX, "Working draft for ISO C++ 2017 with GNU extensions",
+LANGSTANDARD(gnucxx17, "gnu++17",
+ CXX, "ISO C++ 2017 with GNU extensions",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z 
|
  Digraphs | HexFloat | GNUMode)
+LANGSTANDARD_ALIAS_DEPR(gnucxx17, "gnu++1z")
 
 LANGSTANDARD(cxx2a, "c++2a",
  CXX, "Working draft for ISO C++ 2020",


Index: test/SemaCXX/cxx1z-init-statement.cpp
===
--- test/SemaCXX/cxx1z-init-statement.cpp
+++ test/SemaCXX/cxx1z-init-statement.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++1z -verify %s
+// RUN: %clang_cc1 -std=c++17 -verify %s
 
 void testIf() {
   int x = 0;
Index: test/Driver/unknown-std.cpp
===
--- test/Driver/unknown-std.cpp
+++ test/Driver/unknown-std.cpp
@@ -13,8 +13,8 @@
 // CHECK-NEXT: note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU extensions' standard
 // CHECK-NEXT: note: use 'c++14' for 'ISO C++ 2014 with amendments' standard
 // CHECK-NEXT: note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU extensions' standard
-// CHECK-NEXT: note: use 'c++1z' for 'Working draft for ISO C++ 2017' standard
-// CHECK-NEXT: note: use 'gnu++1z' for 'Working draft for ISO C++ 2017 with GNU extensions' standard
+// CHECK-NEXT: note: use 'c++17' for 'ISO C++ 2017' standard
+// CHECK-NEXT: note: use 'gnu++17' for 'ISO C++ 2017 with GNU extensions' standard
 // CHECK-NEXT: note: use 'c++2a' for 'Working draft for ISO C++ 2020' standard
 // CHECK-NEXT: note: use 'gnu++2a' for 'Working draft for ISO C++ 2020 with GNU extensions' standard
 // CUDA-NEXT: note: use 'cuda' for 'NVIDIA CUDA(tm)' standard
Index: include/clang/Frontend/LangStandards.def
===
--- include/clang/Frontend/LangStandards.def
+++ include/clang/Frontend/LangStandards.def
@@ -109,15 +109,17 @@
  GNUMode)
 LANGSTANDARD_ALIAS_DEPR(gnucxx14, "gnu++1y")
 
-LANGSTANDARD(cxx1z, "c++1z",
- CXX, "Working draft for ISO C++ 2017",
+LANGSTANDARD(cxx17, "c++17",
+ CXX, "ISO C++ 2017",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z |
  Digraphs | HexFloat)
+LANGSTANDARD_ALIAS_DEPR(cxx17, "c++1z")
 
-LANGSTANDARD(gnucxx1z, "gnu++1z",
-   

[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-09 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann updated this revision to Diff 110429.
euhlmann edited the summary of this revision.
euhlmann added a comment.

This addresses Daniel's previous concerns. The option is now an enum, the 
heuristic for detecting include guards is expanded and has corresponding unit 
tests, and style issues are resolved.
This does not yet use `PPBranchLevel` to track indent; I'm updating this review 
with my current work before addressing that point.


https://reviews.llvm.org/D35955

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/UnwrappedLineFormatter.cpp
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/UnwrappedLineParser.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -2286,8 +2286,158 @@
getLLVMStyleWithColumns(11));
 }
 
-TEST_F(FormatTest, IndentPreprocessorDirectivesAtZero) {
-  EXPECT_EQ("{\n  {\n#define A\n  }\n}", format("{{\n#define A\n}}"));
+TEST_F(FormatTest, IndentPreprocessorDirectives) {
+  FormatStyle Style = getLLVMStyle();
+  Style.IndentPPDirectives = FormatStyle::PPDIS_None;
+  verifyFormat("#ifdef _WIN32\n"
+   "#define A 0\n"
+   "#ifdef VAR2\n"
+   "#define B 1\n"
+   "#include \n"
+   "#define MACRO  "
+   "\\\n"
+   "  some_very_long_func_a"
+   "a();\n"
+   "#endif\n"
+   "#else\n"
+   "#define A 1\n"
+   "#endif",
+   Style);
+
+  Style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
+  verifyFormat("#ifdef _WIN32\n"
+   "#  define A 0\n"
+   "#  ifdef VAR2\n"
+   "#define B 1\n"
+   "#include \n"
+   "#define MACRO  "
+   "\\\n"
+   "  some_very_long_func_a"
+   "a();\n"
+   "#  endif\n"
+   "#else\n"
+   "#  define A 1\n"
+   "#endif",
+   Style);
+  // Test with include guards.
+  EXPECT_EQ("#ifndef _SOMEFILE_H\n"
+"#define _SOMEFILE_H\n"
+"code();\n"
+"#endif",
+format("#ifndef _SOMEFILE_H\n"
+   "#define _SOMEFILE_H\n"
+   "code();\n"
+   "#endif",
+   Style));
+  // Include guards must have a #define with the same variable immediately
+  // after #ifndef.
+  EXPECT_EQ("#ifndef NOT_GUARD\n"
+"#  define FOO\n"
+"code();\n"
+"#endif",
+format("#ifndef NOT_GUARD\n"
+   "#  define FOO\n"
+   "code();\n"
+   "#endif",
+   Style));
+
+  // Include guards must cover the entire file.
+  EXPECT_EQ("code();\n"
+"#ifndef NOT_GUARD\n"
+"#  define NOT_GUARD\n"
+"code();\n"
+"#endif",
+format("code();\n"
+   "#ifndef NOT_GUARD\n"
+   "#  define NOT_GUARD\n"
+   "code();\n"
+   "#endif",
+   Style));
+  EXPECT_EQ("#ifndef NOT_GUARD\n"
+"#  define NOT_GUARD\n"
+"code();\n"
+"#endif\n"
+"code();",
+format("#ifndef NOT_GUARD\n"
+   "#  define NOT_GUARD\n"
+   "code();\n"
+   "#endif\n"
+   "code();",
+   Style));
+  // Include guards don't have #else.
+  EXPECT_EQ("#ifndef NOT_GUARD\n"
+"#  define NOT_GUARD\n"
+"code();\n"
+"#else\n"
+"#endif",
+format("#ifndef NOT_GUARD\n"
+   "#  define NOT_GUARD\n"
+   "code();\n"
+   "#else\n"
+   "#endif",
+   Style));
+  EXPECT_EQ("#ifndef NOT_GUARD\n"
+"#  define NOT_GUARD\n"
+"code();\n"
+"#elif FOO\n"
+"#endif",
+format("#ifndef NOT_GUARD\n"
+   "#  define NOT_GUARD\n"
+   "code();\n"
+   "#elif FOO\n"
+   "#endif",
+   Style));
+  // Defect: We currently do not deal with the case where there's code between
+  // the #ifndef and #define but all other conditions hold. This is because when
+  // the #define line is parsed, UnwrappedLineParser::Lines doesn't hold the
+  // previous code line yet, so we can't detect it.
+  EXPECT_NE("#ifndef NOT_GUARD\n"
+ 

[PATCH] D36427: [libcxxabi][demangler] Improve representation of substitutions/templates

2017-08-09 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

I have a few more nitpicks; LGTM after you fix those.




Comment at: src/cxa_demangle.cpp:1621-1631
+// Name stack, this is used by the parser to hold temporary names that were
+// parsed. The parser colapses multiple names into new nodes to construct
+// the AST. Once the parser is finished, names.size() == 1.
+PODSmallVector names;
+
+// Substitution table. Itanium supports name substitutions as a means of
+// compression. The string "S42_" refers to the 42nd entry in this table.

erik.pilkington wrote:
> dexonsmith wrote:
> > How much have you thought about these sizes (32, 32, and 4)?  Any evidence 
> > to back up these specific choices?
> Yep, 32 is enough for the Subs table/names to never overflow when demangling 
> the symbols in LLVM, and 4 seldom overflows TemplateParams. TemplateParams is 
> temporary held on the stack in parse_template_args(), so I wanted it to be 
> smaller.
Sounds great.  Please add comments to that effect.



Comment at: src/cxa_demangle.cpp:1626-1630
+Node **Begin = Substitutions.begin() + PackIndices[N];
+Node **End = (N + 1 == PackIndices.size())
+ ? Substitutions.end()
+ : Substitutions.begin() + PackIndices[N + 1];
+assert(End <= Substitutions.end() && Begin <= End);

This assertion won't be meaningful in the case that matters: when 
`PackIndices[N + 1]` is larger than `Substitutions.size()`.  In that case, 
`End` is in the middle of nowhere, and the result of `End <= 
Substitutions.end()` is undefined.  A smart optimizer would fold that to `true`.

You should assert `PackIndices[N + 1] <= Substitutions.size()`.



Comment at: src/cxa_demangle.cpp:5195-5199
+auto TmpParams = std::move(db.TemplateParams);
+size_t k0 = db.Names.size();
+const char* t1 = parse_template_arg(t, last, db);
+size_t k1 = db.Names.size();
+db.TemplateParams = std::move(TmpParams);

This looks really hairy.  This is the only (non-recursive) caller of 
`parse_template_arg`... it doesn't seem reasonable for `parse_template_arg` to 
modify template params, if we're just going to reset them after without looking.

Please add a FIXME to sort this out (at least to document the logic, if not to 
refactor it somehow).



Comment at: src/cxa_demangle.cpp:5207-5209
+}
+else
+{

Early `continue` instead of `else`, if you leave the logic like this.

I'm a little skeptical that this structure is better than before, though, since 
there's some non-trivial duplicated code.  I'll let you decide.


https://reviews.llvm.org/D36427



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


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

2017-08-09 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

In https://reviews.llvm.org/D29660#836927, @arphaman wrote:

> Looks like this test is failing on macOS again after this change:
>
> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/39231/testReport/Clang/Driver/openmp_offload_c/
>
> Can you please take a look?


Looking into it now.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D36492: [RFC][time-report] Add preprocessor timer

2017-08-09 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added subscribers: mzolotukhin, vsk.
vsk added a comment.

Thanks for working on this. Collecting better timing information in the 
frontend sgtm. It's cheap to do, and we can use the information to guide our 
efforts re: attacking the compile-time problem. Feel free to add me to future 
timing-related reviews. Regarding this specific patch:

Could you add a short test (perhaps in test/Misc?) that checks that 
-ftime-report prints out an entry for 'Preprocessing'?

It'd be nice to dump this timer from Preprocessor::PrintStats(), too.




Comment at: lib/Lex/Preprocessor.cpp:660
 
+  llvm::TimeRegion(PPOpts->ShowTimers ? &PreprocessingTimer : nullptr);
+

I wonder whether this is too fine-grained. I think setting up a timer in 
Preprocessor::Lex() might capture more information. Would you mind 
experimenting with that?



Comment at: lib/Lex/Preprocessor.cpp:660
 
+  llvm::TimeRegion(PPOpts->ShowTimers ? &PreprocessingTimer : nullptr);
+

vsk wrote:
> I wonder whether this is too fine-grained. I think setting up a timer in 
> Preprocessor::Lex() might capture more information. Would you mind 
> experimenting with that?
Nitpick: it may be useful to add PPOpts::getTimer(), in case we find more sites 
where we need to either get back the PP timer or nullptr.


https://reviews.llvm.org/D36492



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


[PATCH] D36482: Enable bunch of sanitizers on NetBSD/X86 and X86_64

2017-08-09 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski updated this revision to Diff 110442.
krytarowski edited the summary of this revision.
krytarowski added a comment.

Fix lsan entry.
Add tests.


Repository:
  rL LLVM

https://reviews.llvm.org/D36482

Files:
  lib/Driver/ToolChains/NetBSD.cpp
  test/Driver/fsanitize.c


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -516,6 +516,29 @@
 // RUN: %clang -target x86_64-unknown-cloudabi -fsanitize=safe-stack %s -### 
2>&1 | FileCheck %s -check-prefix=SAFESTACK-CLOUDABI
 // SAFESTACK-CLOUDABI: "-fsanitize=safe-stack"
 
+// RUN: %clang -target i386--netbsd -fsanitize=address %s -### 2>&1 | 
FileCheck %s -check-prefix=ADDRESS-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=address %s -### 2>&1 | 
FileCheck %s -check-prefix=ADDRESS-NETBSD
+// ADDRESS-NETBSD: "-fsanitize=address"
+
+// RUN: %clang -target i386--netbsd -fsanitize=vptr %s -### 2>&1 | FileCheck 
%s -check-prefix=VPTR-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=vptr %s -### 2>&1 | FileCheck 
%s -check-prefix=VPTR-NETBSD
+// VPTR-NETBSD: "-fsanitize=vptr"
+
+// RUN: %clang -target i386--netbsd -fsanitize=safe-stack %s -### 2>&1 | 
FileCheck %s -check-prefix=SAFESTACK-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=safe-stack %s -### 2>&1 | 
FileCheck %s -check-prefix=SAFESTACK-NETBSD
+// SAFESTACK-NETBSD: "-fsanitize=safe-stack"
+
+// RUN: %clang -target i386--netbsd -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-NETBSD
+// FUNCTION-NETBSD: "-fsanitize=function"
+
+// RUN: %clang -target i386--netbsd -fsanitize=leak %s -### 2>&1 | FileCheck 
%s -check-prefix=LEAK-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=leak %s -### 2>&1 | FileCheck 
%s -check-prefix=LEAK-NETBSD
+// LEAK-NETBSD: "-fsanitize=leak"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=thread %s -### 2>&1 | 
FileCheck %s -check-prefix=THREAD-NETBSD
+// THREAD-NETBSD: "-fsanitize=thread"
+
 // RUN: %clang -target x86_64-scei-ps4 -fsanitize=function 
-fsanitize=undefined %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-FSAN-UBSAN-PS4
 // CHECK-FSAN-UBSAN-PS4: unsupported option '-fsanitize=function' for target 
'x86_64-scei-ps4'
 // RUN: %clang -target x86_64-scei-ps4 -fsanitize=function %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-FSAN-PS4
Index: lib/Driver/ToolChains/NetBSD.cpp
===
--- lib/Driver/ToolChains/NetBSD.cpp
+++ lib/Driver/ToolChains/NetBSD.cpp
@@ -422,6 +422,13 @@
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   if (IsX86 || IsX86_64) {
 Res |= SanitizerKind::Address;
+Res |= SanitizerKind::Function;
+Res |= SanitizerKind::Leak;
+Res |= SanitizerKind::SafeStack;
+Res |= SanitizerKind::Vptr;
+  }
+  if (IsX86_64) {
+Res |= SanitizerKind::Thread;
   }
   return Res;
 }


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -516,6 +516,29 @@
 // RUN: %clang -target x86_64-unknown-cloudabi -fsanitize=safe-stack %s -### 2>&1 | FileCheck %s -check-prefix=SAFESTACK-CLOUDABI
 // SAFESTACK-CLOUDABI: "-fsanitize=safe-stack"
 
+// RUN: %clang -target i386--netbsd -fsanitize=address %s -### 2>&1 | FileCheck %s -check-prefix=ADDRESS-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=address %s -### 2>&1 | FileCheck %s -check-prefix=ADDRESS-NETBSD
+// ADDRESS-NETBSD: "-fsanitize=address"
+
+// RUN: %clang -target i386--netbsd -fsanitize=vptr %s -### 2>&1 | FileCheck %s -check-prefix=VPTR-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=vptr %s -### 2>&1 | FileCheck %s -check-prefix=VPTR-NETBSD
+// VPTR-NETBSD: "-fsanitize=vptr"
+
+// RUN: %clang -target i386--netbsd -fsanitize=safe-stack %s -### 2>&1 | FileCheck %s -check-prefix=SAFESTACK-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=safe-stack %s -### 2>&1 | FileCheck %s -check-prefix=SAFESTACK-NETBSD
+// SAFESTACK-NETBSD: "-fsanitize=safe-stack"
+
+// RUN: %clang -target i386--netbsd -fsanitize=function %s -### 2>&1 | FileCheck %s -check-prefix=FUNCTION-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=function %s -### 2>&1 | FileCheck %s -check-prefix=FUNCTION-NETBSD
+// FUNCTION-NETBSD: "-fsanitize=function"
+
+// RUN: %clang -target i386--netbsd -fsanitize=leak %s -### 2>&1 | FileCheck %s -check-prefix=LEAK-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=leak %s -### 2>&1 | FileCheck %s -check-prefix=LEAK-NETBSD
+// LEAK-NETBSD: "-fsanitize=leak"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=thread %s -### 2>&1 | FileCheck %s -check-prefix=THREAD-NETBSD
+// THREAD-NETBSD: "-fsanitize=thread"
+
 // RUN: %clang -target x86_64-scei-ps4 -fsanitize=function -fsanitize=undefined %s -#

[PATCH] D35937: [clang-tidy] Add new readability non-idiomatic static access

2017-08-09 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

A few late comments.




Comment at: 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-static-accessed-through-instance.rst:28-29
+
+  C::foo();
+  C::x;
+

This may be confusing as to whether the check removes the struct definition 
(and the definition of c1) or not.



Comment at: 
docs/clang-tidy/checks/readability-static-accessed-through-instance.rst:11
+
+Thefollowing code:
+

typo: "Thefollowing"



Comment at: test/clang-tidy/readability-static-accessed-through-instance.cpp:55
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member accessed through
+  // instance  [readability-static-accessed-through-instance]
+  // CHECK-FIXES: {{^}}  C::x;{{$}}

Line wrapping gone bad. I guess you can just remove the second line. Same below.


Repository:
  rL LLVM

https://reviews.llvm.org/D35937



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


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

2017-08-09 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

Revision 310505 fixes the tests for this patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D35372: [clang-tidy] Refactor the code and add a close-on-exec check on memfd_create() in Android module.

2017-08-09 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 110443.
yawanng marked 5 inline comments as done.

https://reviews.llvm.org/D35372

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecCheck.cpp
  clang-tidy/android/CloexecCheck.h
  clang-tidy/android/CloexecMemfdCreateCheck.cpp
  clang-tidy/android/CloexecMemfdCreateCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-memfd-create.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-cloexec-memfd-create.cpp

Index: test/clang-tidy/android-cloexec-memfd-create.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-memfd-create.cpp
@@ -0,0 +1,63 @@
+// RUN: %check_clang_tidy %s android-cloexec-memfd-create %t
+
+#define MFD_ALLOW_SEALING 1
+#define __O_CLOEXEC 3
+#define MFD_CLOEXEC __O_CLOEXEC
+#define TEMP_FAILURE_RETRY(exp) \
+  ({\
+int _rc;\
+do {\
+  _rc = (exp);  \
+} while (_rc == -1);\
+  })
+#define NULL 0
+
+extern "C" int memfd_create(const char *name, unsigned int flags);
+
+void a() {
+  memfd_create(NULL, MFD_ALLOW_SEALING);
+  // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: 'memfd_create' should use MFD_CLOEXEC where possible [android-cloexec-memfd-create]
+  // CHECK-FIXES: memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC)
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING));
+  // CHECK-MESSAGES: :[[@LINE-1]]:58: warning: 'memfd_create'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC))
+}
+
+void f() {
+  memfd_create(NULL, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'memfd_create'
+  // CHECK-FIXES: memfd_create(NULL, 3 | MFD_CLOEXEC)
+  TEMP_FAILURE_RETRY(memfd_create(NULL, 3));
+  // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: 'memfd_create'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(memfd_create(NULL, 3 | MFD_CLOEXEC))
+
+  int flag = 3;
+  memfd_create(NULL, flag);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, flag));
+}
+
+namespace i {
+int memfd_create(const char *name, unsigned int flags);
+
+void d() {
+  memfd_create(NULL, MFD_ALLOW_SEALING);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING));
+}
+
+} // namespace i
+
+void e() {
+  memfd_create(NULL, MFD_CLOEXEC);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_CLOEXEC));
+  memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC));
+}
+
+class G {
+public:
+  int memfd_create(const char *name, unsigned int flags);
+  void d() {
+memfd_create(NULL, MFD_ALLOW_SEALING);
+TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING));
+  }
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -6,6 +6,7 @@
 .. toctree::
android-cloexec-creat
android-cloexec-fopen
+   android-cloexec-memfd-create
android-cloexec-open
android-cloexec-socket
boost-use-to-string
Index: docs/clang-tidy/checks/android-cloexec-memfd-create.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/android-cloexec-memfd-create.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - android-cloexec-memfd-create
+
+android-cloexec-memfd-create
+
+
+``memfd_create()`` should include ``MFD_CLOEXEC`` in its type argument to avoid
+the file descriptor leakage. Without this flag, an opened sensitive file would
+remain open across a fork+exec to a lower-privileged SELinux domain.
+
+Examples:
+
+.. code-block:: c++
+
+  memfd_create(name, MFD_ALLOW_SEALING);
+
+  // becomes
+
+  memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC);
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -73,6 +73,12 @@
 
   Checks if the required mode ``e`` exists in the mode argument of ``fopen()``.
 
+- New `android-cloexec-memfd_create
+  `_ check
+
+  Checks if the required file flag ``MFD_CLOEXEC`` is present in the argument of
+  ``memfd_create()``.
+
 - New `android-cloexec-socket
   `_ check
 
Index: clang-tidy/android/CloexecMemfdCreateCheck.h
===
--- /dev/null
+++ clang-tidy/android/CloexecMemfdCreateCheck.h
@@ -0,0 +1,35 @@
+//===--- CloexecMemfdCreateCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===---

r310508 - PointerLikeTypeTraits: class->struct to match LLVM change

2017-08-09 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Wed Aug  9 11:34:22 2017
New Revision: 310508

URL: http://llvm.org/viewvc/llvm-project?rev=310508&view=rev
Log:
PointerLikeTypeTraits: class->struct to match LLVM change

Modified:
cfe/trunk/include/clang/AST/CanonicalType.h
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/DeclGroup.h
cfe/trunk/include/clang/AST/TemplateName.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/IdentifierTable.h
cfe/trunk/include/clang/Basic/SourceLocation.h
cfe/trunk/include/clang/CodeGen/ConstantInitFuture.h
cfe/trunk/include/clang/Sema/Ownership.h

Modified: cfe/trunk/include/clang/AST/CanonicalType.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CanonicalType.h?rev=310508&r1=310507&r2=310508&view=diff
==
--- cfe/trunk/include/clang/AST/CanonicalType.h (original)
+++ cfe/trunk/include/clang/AST/CanonicalType.h Wed Aug  9 11:34:22 2017
@@ -359,8 +359,7 @@ struct simplify_type< ::clang::CanQual is "basically a pointer".
 template
-class PointerLikeTypeTraits > {
-public:
+struct PointerLikeTypeTraits > {
   static inline void *getAsVoidPointer(clang::CanQual P) {
 return P.getAsOpaquePtr();
   }

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310508&r1=310507&r2=310508&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Wed Aug  9 11:34:22 2017
@@ -73,8 +73,7 @@ public:
 namespace llvm {
   // Provide PointerLikeTypeTraits for non-cvr pointers.
   template<>
-  class PointerLikeTypeTraits< ::clang::AnyFunctionDecl> {
-  public:
+  struct PointerLikeTypeTraits< ::clang::AnyFunctionDecl> {
 static inline void *getAsVoidPointer(::clang::AnyFunctionDecl F) {
   return F.get();
 }

Modified: cfe/trunk/include/clang/AST/DeclGroup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclGroup.h?rev=310508&r1=310507&r2=310508&view=diff
==
--- cfe/trunk/include/clang/AST/DeclGroup.h (original)
+++ cfe/trunk/include/clang/AST/DeclGroup.h Wed Aug  9 11:34:22 2017
@@ -138,10 +138,9 @@ public:
 namespace llvm {
   // DeclGroupRef is "like a pointer", implement PointerLikeTypeTraits.
   template 
-  class PointerLikeTypeTraits;
+  struct PointerLikeTypeTraits;
   template <>
-  class PointerLikeTypeTraits {
-  public:
+  struct PointerLikeTypeTraits {
 static inline void *getAsVoidPointer(clang::DeclGroupRef P) {
   return P.getAsOpaquePtr();
 }

Modified: cfe/trunk/include/clang/AST/TemplateName.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TemplateName.h?rev=310508&r1=310507&r2=310508&view=diff
==
--- cfe/trunk/include/clang/AST/TemplateName.h (original)
+++ cfe/trunk/include/clang/AST/TemplateName.h Wed Aug  9 11:34:22 2017
@@ -515,8 +515,7 @@ namespace llvm {
 
 /// \brief The clang::TemplateName class is effectively a pointer.
 template<>
-class PointerLikeTypeTraits {
-public:
+struct PointerLikeTypeTraits {
   static inline void *getAsVoidPointer(clang::TemplateName TN) {
 return TN.getAsVoidPointer();
   }

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=310508&r1=310507&r2=310508&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed Aug  9 11:34:22 2017
@@ -48,10 +48,9 @@ namespace clang {
 
 namespace llvm {
   template 
-  class PointerLikeTypeTraits;
+  struct PointerLikeTypeTraits;
   template<>
-  class PointerLikeTypeTraits< ::clang::Type*> {
-  public:
+  struct PointerLikeTypeTraits< ::clang::Type*> {
 static inline void *getAsVoidPointer(::clang::Type *P) { return P; }
 static inline ::clang::Type *getFromVoidPointer(void *P) {
   return static_cast< ::clang::Type*>(P);
@@ -59,8 +58,7 @@ namespace llvm {
 enum { NumLowBitsAvailable = clang::TypeAlignmentInBits };
   };
   template<>
-  class PointerLikeTypeTraits< ::clang::ExtQuals*> {
-  public:
+  struct PointerLikeTypeTraits< ::clang::ExtQuals*> {
 static inline void *getAsVoidPointer(::clang::ExtQuals *P) { return P; }
 static inline ::clang::ExtQuals *getFromVoidPointer(void *P) {
   return static_cast< ::clang::ExtQuals*>(P);
@@ -1143,8 +1141,7 @@ template<> struct simplify_type< ::clang
 
 // Teach SmallPtrSet that QualType is "basically a pointer".
 template<>
-class PointerLikeTypeTraits {
-public:
+struct PointerLikeTypeTraits {
   static inline void *getAsVoidPointer(clang::QualType P) {
 return P.ge

Re: [PATCH] D36386: [clang] Remove unit test which uses reverse-iterate and fix a PointerLikeTypeTrait specialization

2017-08-09 Thread David Blaikie via cfe-commits
On Wed, Aug 9, 2017 at 1:44 AM Grang, Mandeep Singh 
wrote:

> In D35043 I have removed the llvm tests which use -reverse-iterate. This
> patch removes the clang tests.
>

Ah, OK. I'm still curious about whether this results in a loss of test
coverage. Without this test, would the bug it was testing still be caught
by some test failure in at least one of the forward or reverse iteration
modes?


> Should I post a later patch to change all "class PointerLikeTypeTraits" to
> "struct PointerLikeTypeTraits"?
>

I'll just do that (r310506 & r310508) - done! :)


>
>
> On 8/7/2017 2:50 PM, David Blaikie wrote:
>
>
>
> On Mon, Aug 7, 2017 at 12:08 PM Mandeep Singh Grang via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> mgrang added a comment.
>>
>> This patch does 3 things:
>>
>> 1. Get rid of the unit test objc-modern-metadata-visibility2.mm because
>> this test check uses flag -reverse-iterate. This flag will be removed in
>> https://reviews.llvm.org/D35043.
>>
>
> Sure - please commit that separately (probably once D35043 is approved -
> probably best to include that removal in D35043, or a separate patch that
> /only/ removes the -reverse-iterate flag (& any tests that use it) as a
> standalone change?).
>
> Does this test need a replacement? If this test is removed and the
> underlying issue it was testing regresses, will one of the buildbots
> (reverse or normal) catch the problem?
>
>
>> 2. https://reviews.llvm.org/D35043 gets rid of the empty base definition
>> for PointerLikeTypeTraits. This results in a compiler warning because
>> PointerLikeTypeTrait has been defined as struct here while in the header it
>> is a class. So I have changed struct to class.
>>
>
> I'd probably go the other way - traits classes like this make more sense
> as structs, I think - it only has public members & no implementation really
> has any need for supporting private members.
>
>
>> 3. Since I changed struct PointerLikeTypeTrait to class
>> PointerLikeTypeTrait here, the member functions are no longer public now.
>> This results in a compiler error. So I explicitly marked them as public
>> here.
>>
>>
>> https://reviews.llvm.org/D36386
>>
>>
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36537: [OpenMP] Enable executable lookup into driver directory.

2017-08-09 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.

Invoking the compiler inside a script causes the clang-offload-bundler 
executable to not be found. This patch fixes this error.


Repository:
  rL LLVM

https://reviews.llvm.org/D36537

Files:
  lib/Driver/ToolChains/Cuda.cpp


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -438,6 +438,7 @@
   CudaInstallation(D, HostTC.getTriple(), Args), OK(OK) {
   if (CudaInstallation.isValid())
 getProgramPaths().push_back(CudaInstallation.getBinPath());
+  getProgramPaths().push_back(getDriver().Dir);
 }
 
 void CudaToolChain::addClangTargetOptions(


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -438,6 +438,7 @@
   CudaInstallation(D, HostTC.getTriple(), Args), OK(OK) {
   if (CudaInstallation.isValid())
 getProgramPaths().push_back(CudaInstallation.getBinPath());
+  getProgramPaths().push_back(getDriver().Dir);
 }
 
 void CudaToolChain::addClangTargetOptions(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35449: [X86] Implement __builtin_cpu_is

2017-08-09 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Ping


https://reviews.llvm.org/D35449



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


[PATCH] D36537: [OpenMP] Enable executable lookup into driver directory.

2017-08-09 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel accepted this revision.
hfinkel added a comment.
This revision is now accepted and ready to land.

I think this is fine, but please add a comment explaining that you're doing 
this to find (e.g., to find the offload bundler, etc.).


Repository:
  rL LLVM

https://reviews.llvm.org/D36537



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


[PATCH] D36537: [OpenMP] Enable executable lookup into driver directory.

2017-08-09 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 110447.
gtbercea added a comment.

Add comment.


https://reviews.llvm.org/D36537

Files:
  lib/Driver/ToolChains/Cuda.cpp


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -438,6 +438,9 @@
   CudaInstallation(D, HostTC.getTriple(), Args), OK(OK) {
   if (CudaInstallation.isValid())
 getProgramPaths().push_back(CudaInstallation.getBinPath());
+  // Lookup binaries into the driver directory, this is used to
+  // discover the clang-offload-bundler executable.
+  getProgramPaths().push_back(getDriver().Dir);
 }
 
 void CudaToolChain::addClangTargetOptions(


Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -438,6 +438,9 @@
   CudaInstallation(D, HostTC.getTriple(), Args), OK(OK) {
   if (CudaInstallation.isValid())
 getProgramPaths().push_back(CudaInstallation.getBinPath());
+  // Lookup binaries into the driver directory, this is used to
+  // discover the clang-offload-bundler executable.
+  getProgramPaths().push_back(getDriver().Dir);
 }
 
 void CudaToolChain::addClangTargetOptions(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D36386: [clang] Remove unit test which uses reverse-iterate and fix a PointerLikeTypeTrait specialization

2017-08-09 Thread Grang, Mandeep Singh via cfe-commits
> Ah, OK. I'm still curious about whether this results in a loss of 
test coverage. Without this test, would the bug it was testing still be 
caught by some test failure in at least one of the forward or reverse 
iteration modes?


Sorry ... I missed that. Yes, the reverse iteration buildbot 
http://lab.llvm.org:8011/builders/reverse-iteration would test these. 
These tests were a stopgap solution anyway while the reverse builtbot 
was being setup.



> I'll just do that (r310506 & r310508) - done! :)
Thanks!


--Mandeep


On 8/9/2017 11:35 AM, David Blaikie wrote:



On Wed, Aug 9, 2017 at 1:44 AM Grang, Mandeep Singh 
mailto:mgr...@codeaurora.org>> wrote:


In D35043 I have removed the llvm tests which use
-reverse-iterate. This patch removes the clang tests.


Ah, OK. I'm still curious about whether this results in a loss of test 
coverage. Without this test, would the bug it was testing still be 
caught by some test failure in at least one of the forward or reverse 
iteration modes?


Should I post a later patch to change all "class
PointerLikeTypeTraits" to "struct PointerLikeTypeTraits"?


I'll just do that (r310506 & r310508) - done! :)



On 8/7/2017 2:50 PM, David Blaikie wrote:



On Mon, Aug 7, 2017 at 12:08 PM Mandeep Singh Grang via
Phabricator mailto:revi...@reviews.llvm.org>> wrote:

mgrang added a comment.

This patch does 3 things:

1. Get rid of the unit test
objc-modern-metadata-visibility2.mm
 because this
test check uses flag -reverse-iterate. This flag will be
removed in https://reviews.llvm.org/D35043.


Sure - please commit that separately (probably once D35043 is
approved - probably best to include that removal in D35043, or a
separate patch that /only/ removes the -reverse-iterate flag (&
any tests that use it) as a standalone change?).

Does this test need a replacement? If this test is removed and
the underlying issue it was testing regresses, will one of the
buildbots (reverse or normal) catch the problem?

2. https://reviews.llvm.org/D35043 gets rid of the empty base
definition for PointerLikeTypeTraits. This results in a
compiler warning because PointerLikeTypeTrait has been
defined as struct here while in the header it is a class. So
I have changed struct to class.


I'd probably go the other way - traits classes like this make
more sense as structs, I think - it only has public members & no
implementation really has any need for supporting private members.

3. Since I changed struct PointerLikeTypeTrait to class
PointerLikeTypeTrait here, the member functions are no longer
public now. This results in a compiler error. So I explicitly
marked them as public here.


https://reviews.llvm.org/D36386







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


[PATCH] D34158: For Linux/gnu compatibility, preinclude if the file is available

2017-08-09 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

In https://reviews.llvm.org/D34158#836026, @jyknight wrote:

> In https://reviews.llvm.org/D34158#827178, @joerg wrote:
>
> > (2) It adds magic behavior that can make debugging more difficult. 
> > Partially preprocessed sources for example could be compiled with plain -c 
> > before, now they need a different command line.
>
>
> If this is a problem, making it be Linux-only does _nothing_ to solve it. But 
> I don't actually see how this is a substantively new problem? Compiling with 
> plain -c before
>  would get #defines for those predefined macros that the compiler sets, even 
> though you may not have wanted those. Is this fundamentally different?


It makes it a linux-only problem. As such, it is something *I* only care about 
secondary. A typical use case I care about a lot is pulling the crash report 
sources from my (NetBSD) build machine,
extracting the original command line to rerun the normal compilation with 
-save-temps. I don't necessarily have the (same) system headers on the machine 
I use for debugging and that's exactly
the kind of use case this change breaks. All other predefined macros are driven 
by the target triple and remain stable.

>> (3) It seems to me that the GNU userland (and maybe Windows) is the 
>> exception to a well integrated tool chain. Most other platforms have a 
>> single canonical
>>  libc, libm and libpthread implementation and can as such directly define 
>> all the relevant macros directly in the driver.
> 
> I don't think this is accurate. There's many platforms out there, and for 
> almost none of them do we have exact knowledge of the features of the libc 
> encoded
>  into the compiler. I'd note that not only do you need this for every (OS, 
> libc) combination, you'd need it for every (OS, libc-VERSION) combination.

Not really. The feature set is rarely changing and generally will have only a 
cut-off version.

>> Given that many of the macros involved are already reflected by the compiler 
>> behavior anyway, they can't be decoupled. I.e. the questionable
>>  concept of locale-independent wchar_t is already hard-coded in the front 
>> end as soon as any long character literals are used.
> 
> AFAICT, this example is not actually the case. The frontend only needs to 
> know *a* valid encoding for wide-character literals in some
>  implementation-defined locale (for example, it might always emit them as 
> unicode codepoints, as clang does).  Standard says:
>  "the array elements [...] are initialized with the sequence of wide 
> characters corresponding to the multibyte character sequence, as
>  defined by the mbstowcs function with an implementation defined current 
> locale."

I know what the standard says. It doesn't make much sense if you do not have a 
fixed wchar_t encoding.

> On the other hand, I believe the intent of this macro is to guarantee that 
> _no matter what_ the locale is,
>  that a U+0100 character (say, translated with mbrtowc from the locale 
> encoding) gets represented as 0x100.

Yes, so it is essentially "we have screwed up by creating a language mechanism 
that adds a major constraint, so let's go all the way".

> Thus, it's "fine" for the frontend to always emit wchar_t literals as 
> unicode, yet, the libc may sometimes use an arbitrary different
>  internal encoding, depending on the locale used at runtime. (Obviously using 
> wide character literals with such a libc would be a poor 
>  user experience, and such a libc probably ought to reconsider its choices, 
> but that's a different discussion.)

One of the biggest opponents of that was Itojun. It's not a decision that 
should be made here as it is only indirectly related to this discussion.

>> As such, please move the command line additions back into the 
>> target-specific files for targets that actually want to get this behavior.
> 
> Without even a suggestion of a better solution to use for other targets, I 
> find it is to be a real shame to push for this to be linux-only,
>  and leave everyone else hanging. I find that that _most_ of these defines 
> are effectively library decisions. I further would claim that these
>  are likely to vary over the lifetime of even a single libc, and that as such 
> we would be better served by allowing the libc to set them directly, rather 
> than encoding it into the compiler.
> 
> TTBOMK, no targets except linux/glibc/gcc actually comply with this part of 
> the C99/C11 standard today, and so this feature would be useful to have 
> available across all targets.
> 
> (I very much dislike that the C standard has started adding all these new 
> predefined macros, instead of exposing them from a header, but there's not 
> much to be done about that...)

Exactly. It's not like this is a lot of target logic. It should be a single 
call for targets that want to get this functionality. But that's my point -- it 
should be opt-in, not opt-out.


https://reviews.llvm.org/D34158



__

Re: [PATCH] D36386: [clang] Remove unit test which uses reverse-iterate and fix a PointerLikeTypeTrait specialization

2017-08-09 Thread David Blaikie via cfe-commits
OK - go ahead and remove the tests then, if the functionality is now
covered by the buildbot+existing tests.

On Wed, Aug 9, 2017 at 12:04 PM Grang, Mandeep Singh 
wrote:

> > Ah, OK. I'm still curious about whether this results in a loss of test
> coverage. Without this test, would the bug it was testing still be caught
> by some test failure in at least one of the forward or reverse iteration
> modes?
>
> Sorry ... I missed that. Yes, the reverse iteration buildbot
> http://lab.llvm.org:8011/builders/reverse-iteration would test these.
> These tests were a stopgap solution anyway while the reverse builtbot was
> being setup.
>
> > I'll just do that (r310506 & r310508) - done! :)
> Thanks!
>
>
> --Mandeep
>
> On 8/9/2017 11:35 AM, David Blaikie wrote:
>
>
>
> On Wed, Aug 9, 2017 at 1:44 AM Grang, Mandeep Singh 
> wrote:
>
>> In D35043 I have removed the llvm tests which use -reverse-iterate. This
>> patch removes the clang tests.
>>
>
> Ah, OK. I'm still curious about whether this results in a loss of test
> coverage. Without this test, would the bug it was testing still be caught
> by some test failure in at least one of the forward or reverse iteration
> modes?
>
>
>> Should I post a later patch to change all "class PointerLikeTypeTraits"
>> to "struct PointerLikeTypeTraits"?
>>
>
> I'll just do that (r310506 & r310508) - done! :)
>
>
>>
>>
>> On 8/7/2017 2:50 PM, David Blaikie wrote:
>>
>>
>>
>> On Mon, Aug 7, 2017 at 12:08 PM Mandeep Singh Grang via Phabricator <
>> revi...@reviews.llvm.org> wrote:
>>
>>> mgrang added a comment.
>>>
>>> This patch does 3 things:
>>>
>>> 1. Get rid of the unit test objc-modern-metadata-visibility2.mm because
>>> this test check uses flag -reverse-iterate. This flag will be removed in
>>> https://reviews.llvm.org/D35043.
>>>
>>
>> Sure - please commit that separately (probably once D35043 is approved -
>> probably best to include that removal in D35043, or a separate patch that
>> /only/ removes the -reverse-iterate flag (& any tests that use it) as a
>> standalone change?).
>>
>> Does this test need a replacement? If this test is removed and the
>> underlying issue it was testing regresses, will one of the buildbots
>> (reverse or normal) catch the problem?
>>
>>
>>> 2. https://reviews.llvm.org/D35043 gets rid of the empty base
>>> definition for PointerLikeTypeTraits. This results in a compiler warning
>>> because PointerLikeTypeTrait has been defined as struct here while in the
>>> header it is a class. So I have changed struct to class.
>>>
>>
>> I'd probably go the other way - traits classes like this make more sense
>> as structs, I think - it only has public members & no implementation really
>> has any need for supporting private members.
>>
>>
>>> 3. Since I changed struct PointerLikeTypeTrait to class
>>> PointerLikeTypeTrait here, the member functions are no longer public now.
>>> This results in a compiler error. So I explicitly marked them as public
>>> here.
>>>
>>>
>>> https://reviews.llvm.org/D36386
>>>
>>>
>>>
>>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r310511 - [OPENMP] Emit non-debug version of outlined functions with original

2017-08-09 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Aug  9 12:38:53 2017
New Revision: 310511

URL: http://llvm.org/viewvc/llvm-project?rev=310511&view=rev
Log:
[OPENMP] Emit non-debug version of outlined functions with original
name.

If the host code is compiled with the debug info, while the target
without, there is a problem that the compiler is unable to find the
debug wrapper. Patch fixes this problem by emitting special name for the
debug version of the code.

Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/distribute_codegen.cpp
cfe/trunk/test/OpenMP/parallel_codegen.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=310511&r1=310510&r2=310511&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Wed Aug  9 12:38:53 2017
@@ -247,7 +247,7 @@ namespace {
 /// true if cast to/from  UIntPtr is required for variables captured by
 /// value.
 const bool UIntPtrCastRequired = true;
-/// true if only casted argumefnts must be registered as local args or VLA
+/// true if only casted arguments must be registered as local args or VLA
 /// sizes.
 const bool RegisterCastedArgsOnly = false;
 /// Name of the generated function.
@@ -261,7 +261,7 @@ namespace {
   };
 }
 
-static std::pair emitOutlinedFunctionPrologue(
+static llvm::Function *emitOutlinedFunctionPrologue(
 CodeGenFunction &CGF, FunctionArgList &Args,
 llvm::MapVector>
 &LocalAddrs,
@@ -277,7 +277,6 @@ static std::pair
   CodeGenModule &CGM = CGF.CGM;
   ASTContext &Ctx = CGM.getContext();
   FunctionArgList TargetArgs;
-  bool HasUIntPtrArgs = false;
   Args.append(CD->param_begin(),
   std::next(CD->param_begin(), CD->getContextParamPosition()));
   TargetArgs.append(
@@ -296,7 +295,6 @@ static std::pair
 // outlined function.
 if ((I->capturesVariableByCopy() && !ArgType->isAnyPointerType()) ||
 I->capturesVariableArrayType()) {
-  HasUIntPtrArgs = true;
   if (FO.UIntPtrCastRequired)
 ArgType = Ctx.getUIntPtrType();
 }
@@ -432,7 +430,7 @@ static std::pair
 ++I;
   }
 
-  return {F, HasUIntPtrArgs};
+  return F;
 }
 
 llvm::Function *
@@ -448,12 +446,15 @@ CodeGenFunction::GenerateOpenMPCapturedS
   FunctionArgList Args;
   llvm::MapVector> 
LocalAddrs;
   llvm::DenseMap> 
VLASizes;
+  SmallString<256> Buffer;
+  llvm::raw_svector_ostream Out(Buffer);
+  Out << CapturedStmtInfo->getHelperName();
+  if (NeedWrapperFunction)
+Out << "_debug__";
   FunctionOptions FO(&S, !NeedWrapperFunction, 
/*RegisterCastedArgsOnly=*/false,
- CapturedStmtInfo->getHelperName());
-  llvm::Function *F;
-  bool HasUIntPtrArgs;
-  std::tie(F, HasUIntPtrArgs) = emitOutlinedFunctionPrologue(
-  *this, Args, LocalAddrs, VLASizes, CXXThisValue, FO);
+ Out.str());
+  llvm::Function *F = emitOutlinedFunctionPrologue(*this, Args, LocalAddrs,
+   VLASizes, CXXThisValue, FO);
   for (const auto &LocalAddrPair : LocalAddrs) {
 if (LocalAddrPair.second.first) {
   setAddrOfLocalVar(LocalAddrPair.second.first,
@@ -465,14 +466,12 @@ CodeGenFunction::GenerateOpenMPCapturedS
   PGO.assignRegionCounters(GlobalDecl(CD), F);
   CapturedStmtInfo->EmitBody(*this, CD->getBody());
   FinishFunction(CD->getBodyRBrace());
-  if (!NeedWrapperFunction || !HasUIntPtrArgs)
+  if (!NeedWrapperFunction)
 return F;
 
-  SmallString<256> Buffer;
-  llvm::raw_svector_ostream Out(Buffer);
-  Out << "__nondebug_wrapper_" << CapturedStmtInfo->getHelperName();
   FunctionOptions WrapperFO(&S, /*UIntPtrCastRequired=*/true,
-/*RegisterCastedArgsOnly=*/true, Out.str());
+/*RegisterCastedArgsOnly=*/true,
+CapturedStmtInfo->getHelperName());
   CodeGenFunction WrapperCGF(CGM, /*suppressNewContext=*/true);
   WrapperCGF.disableDebugInfo();
   Args.clear();
@@ -480,7 +479,7 @@ CodeGenFunction::GenerateOpenMPCapturedS
   VLASizes.clear();
   llvm::Function *WrapperF =
   emitOutlinedFunctionPrologue(WrapperCGF, Args, LocalAddrs, VLASizes,
-   WrapperCGF.CXXThisValue, WrapperFO).first;
+   WrapperCGF.CXXThisValue, WrapperFO);
   LValueBaseInfo BaseInfo(AlignmentSource::Decl, false);
   llvm::SmallVector CallArgs;
   for (const auto *Arg : Args) {

Modified: cfe/trunk/test/OpenMP/distribute_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_codegen.cpp?rev=310511&r1=310510&r2=310511&view=diff
==
--- cfe/trunk/te

[PATCH] D36532: Add -std=c++17

2017-08-09 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: include/clang/Frontend/LangStandards.def:113
+LANGSTANDARD(cxx17, "c++17",
+ CXX, "ISO C++ 2017",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z 
|

Missing "with amendments" compared to the other languages. We already implement 
some DRs against c++17.


https://reviews.llvm.org/D36532



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


Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-09 Thread Diana Picus via cfe-commits
Reverting this also fixed the selfhost bots:
http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2142
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/2309
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/1819

I'm afraid the logs for those look even less helpful.

On 9 August 2017 at 16:17, Diana Picus  wrote:
> Hi,
>
> See attached. FWIW, when I ran this on a very similar machine, I got
> 194 failures, all of which went away after reverting. So there might
> be something fishy going on.
>
> Regards,
> Diana
>
> On 9 August 2017 at 15:02, Vassil Vassilev  wrote:
>> Hi Diana,
>>
>>   It seems the service is down. Could you send us the details of the
>> failures (incl stack traces if any)
>>
>> Many thanks,
>> Vassil
>>
>> On 09/08/17 15:27, Diana Picus via cfe-commits wrote:
>>>
>>> Hi Richard,
>>>
>>> I'm sorry but I've reverted this in r310464 because it was breaking
>>> some ASAN tests on this bot:
>>> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9452
>>>
>>> Please let me know if I can help debug this.
>>>
>>> Cheers,
>>> Diana
>>>
>>> On 8 August 2017 at 21:14, Richard Smith via cfe-commits
>>>  wrote:

 I forgot to say:

 Based on a patch by Vassil Vassilev, which was based on a patch by Bernd
 Schmidt, which was based on a patch by Reid Kleckner.

 On 8 August 2017 at 12:12, Richard Smith via cfe-commits
  wrote:
>
> Author: rsmith
> Date: Tue Aug  8 12:12:28 2017
> New Revision: 310401
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310401&view=rev
> Log:
> PR19668, PR23034: Fix handling of move constructors and deleted copy
> constructors when deciding whether classes should be passed indirectly.
>
> This fixes ABI differences between Clang and GCC:
>
>   * Previously, Clang ignored the move constructor when making this
> determination. It now takes the move constructor into account, per
> https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may
> seem recent, but the ABI change was agreed on the Itanium C++ ABI
> list a long time ago).
>
>   * Previously, Clang's behavior when the copy constructor was deleted
> was unstable -- depending on whether the lazy declaration of the
> copy constructor had been triggered, you might get different
> behavior.
> We now eagerly declare the copy constructor whenever its deletedness
> is unclear, and ignore deleted copy/move constructors when looking
> for
> a trivial such constructor.
>
> This also fixes an ABI difference between Clang and MSVC:
>
>   * If the copy constructor would be implicitly deleted (but has not
> been
> lazily declared yet), for instance because the class has an rvalue
> reference member, we would pass it directly. We now pass such a
> class
> indirectly, matching MSVC.
>
> Modified:
>  cfe/trunk/include/clang/AST/DeclCXX.h
>  cfe/trunk/lib/AST/ASTImporter.cpp
>  cfe/trunk/lib/AST/DeclCXX.cpp
>  cfe/trunk/lib/CodeGen/CGCXXABI.cpp
>  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
>  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
>  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>  cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>  cfe/trunk/lib/Serialization/ASTWriter.cpp
>  cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
>  cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
>
> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
> URL:
>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310401&r1=310400&r2=310401&view=diff
>
>
> ==
> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
> +++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug  8 12:12:28 2017
> @@ -375,6 +375,7 @@ class CXXRecordDecl : public RecordDecl
>   /// \brief These flags are \c true if a defaulted corresponding
> special
>   /// member can't be fully analyzed without performing overload
> resolution.
>   /// @{
> +unsigned NeedOverloadResolutionForCopyConstructor : 1;
>   unsigned NeedOverloadResolutionForMoveConstructor : 1;
>   unsigned NeedOverloadResolutionForMoveAssignment : 1;
>   unsigned NeedOverloadResolutionForDestructor : 1;
> @@ -383,6 +384,7 @@ class CXXRecordDecl : public RecordDecl
>   /// \brief These flags are \c true if an implicit defaulted
> corresponding
>   /// special member would be defined as deleted.
>   /// @{
> +unsigned DefaultedCopyConstructorIsDeleted : 1;
>   unsigned DefaultedMoveConstructorIsDeleted : 1;
>   unsigned DefaultedMoveAssignmentIsDeleted : 1;
>   unsigned D

Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-09 Thread Vassil Vassilev via cfe-commits

On 09/08/17 22:54, Diana Picus wrote:

Reverting this also fixed the selfhost bots:
http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2142
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/2309
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/1819

I'm afraid the logs for those look even less helpful.
Not helpful indeed :) Do you have access to the machine and would you be 
willing to build in debug mode and send us some stack traces. I do not 
have any arm machines :(


On 9 August 2017 at 16:17, Diana Picus  wrote:

Hi,

See attached. FWIW, when I ran this on a very similar machine, I got
194 failures, all of which went away after reverting. So there might
be something fishy going on.

Regards,
Diana

On 9 August 2017 at 15:02, Vassil Vassilev  wrote:

Hi Diana,

   It seems the service is down. Could you send us the details of the
failures (incl stack traces if any)

Many thanks,
Vassil

On 09/08/17 15:27, Diana Picus via cfe-commits wrote:

Hi Richard,

I'm sorry but I've reverted this in r310464 because it was breaking
some ASAN tests on this bot:
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9452

Please let me know if I can help debug this.

Cheers,
Diana

On 8 August 2017 at 21:14, Richard Smith via cfe-commits
 wrote:

I forgot to say:

Based on a patch by Vassil Vassilev, which was based on a patch by Bernd
Schmidt, which was based on a patch by Reid Kleckner.

On 8 August 2017 at 12:12, Richard Smith via cfe-commits
 wrote:

Author: rsmith
Date: Tue Aug  8 12:12:28 2017
New Revision: 310401

URL: http://llvm.org/viewvc/llvm-project?rev=310401&view=rev
Log:
PR19668, PR23034: Fix handling of move constructors and deleted copy
constructors when deciding whether classes should be passed indirectly.

This fixes ABI differences between Clang and GCC:

   * Previously, Clang ignored the move constructor when making this
 determination. It now takes the move constructor into account, per
 https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may
 seem recent, but the ABI change was agreed on the Itanium C++ ABI
 list a long time ago).

   * Previously, Clang's behavior when the copy constructor was deleted
 was unstable -- depending on whether the lazy declaration of the
 copy constructor had been triggered, you might get different
behavior.
 We now eagerly declare the copy constructor whenever its deletedness
 is unclear, and ignore deleted copy/move constructors when looking
for
 a trivial such constructor.

This also fixes an ABI difference between Clang and MSVC:

   * If the copy constructor would be implicitly deleted (but has not
been
 lazily declared yet), for instance because the class has an rvalue
 reference member, we would pass it directly. We now pass such a
class
 indirectly, matching MSVC.

Modified:
  cfe/trunk/include/clang/AST/DeclCXX.h
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/lib/AST/DeclCXX.cpp
  cfe/trunk/lib/CodeGen/CGCXXABI.cpp
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
  cfe/trunk/lib/Serialization/ASTWriter.cpp
  cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310401&r1=310400&r2=310401&view=diff


==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug  8 12:12:28 2017
@@ -375,6 +375,7 @@ class CXXRecordDecl : public RecordDecl
   /// \brief These flags are \c true if a defaulted corresponding
special
   /// member can't be fully analyzed without performing overload
resolution.
   /// @{
+unsigned NeedOverloadResolutionForCopyConstructor : 1;
   unsigned NeedOverloadResolutionForMoveConstructor : 1;
   unsigned NeedOverloadResolutionForMoveAssignment : 1;
   unsigned NeedOverloadResolutionForDestructor : 1;
@@ -383,6 +384,7 @@ class CXXRecordDecl : public RecordDecl
   /// \brief These flags are \c true if an implicit defaulted
corresponding
   /// special member would be defined as deleted.
   /// @{
+unsigned DefaultedCopyConstructorIsDeleted : 1;
   unsigned DefaultedMoveConstructorIsDeleted : 1;
   unsigned DefaultedMoveAssignmentIsDeleted : 1;
   unsigned DefaultedDestructorIsDeleted : 1;
@@ -415,6 +417,12 @@ class CXXRecordDecl : public RecordDecl
   /// constructor.
   unsigned HasDefaultedDefaultConstructor : 1;

+/// \brief True if this class can be passed in a
non-address-preserving
+/// fashion (such as in registers) according to the C++ language
rules.
+

[PATCH] D36526: [Sema] Assign new flag -Wenum-compare-switch to switch-related parts of -Wenum-compare

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

LGTM


https://reviews.llvm.org/D36526



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


[PATCH] D36532: Add -std=c++17

2017-08-09 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: include/clang/Frontend/LangStandards.def:113
+LANGSTANDARD(cxx17, "c++17",
+ CXX, "ISO C++ 2017",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z 
|

rsmith wrote:
> Missing "with amendments" compared to the other languages. We already 
> implement some DRs against c++17.
Thanks! I wasn't sure about that part.


https://reviews.llvm.org/D36532



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


r310516 - Make -std=c++17 an alias of -std=c++1z

2017-08-09 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Aug  9 13:12:53 2017
New Revision: 310516

URL: http://llvm.org/viewvc/llvm-project?rev=310516&view=rev
Log:
Make -std=c++17 an alias of -std=c++1z

As suggested on PR33912.

Trying to keep this small to make it easy to merge to the 5.0 branch. We
can do a follow-up with more thorough renaming (diagnostic text,
options, ids, etc.) later.

(For C++14 this was done in r215982, and I think a smaller patch for the
3.5 branch:
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20140818/113013.html)

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

Modified:
cfe/trunk/include/clang/Frontend/LangStandards.def
cfe/trunk/test/Driver/unknown-std.cpp
cfe/trunk/test/SemaCXX/cxx1z-init-statement.cpp

Modified: cfe/trunk/include/clang/Frontend/LangStandards.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/LangStandards.def?rev=310516&r1=310515&r2=310516&view=diff
==
--- cfe/trunk/include/clang/Frontend/LangStandards.def (original)
+++ cfe/trunk/include/clang/Frontend/LangStandards.def Wed Aug  9 13:12:53 2017
@@ -109,15 +109,17 @@ LANGSTANDARD(gnucxx14, "gnu++14",
  GNUMode)
 LANGSTANDARD_ALIAS_DEPR(gnucxx14, "gnu++1y")
 
-LANGSTANDARD(cxx1z, "c++1z",
- CXX, "Working draft for ISO C++ 2017",
+LANGSTANDARD(cxx17, "c++17",
+ CXX, "ISO C++ 2017 with amendments",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z 
|
  Digraphs | HexFloat)
+LANGSTANDARD_ALIAS_DEPR(cxx17, "c++1z")
 
-LANGSTANDARD(gnucxx1z, "gnu++1z",
- CXX, "Working draft for ISO C++ 2017 with GNU extensions",
+LANGSTANDARD(gnucxx17, "gnu++17",
+ CXX, "ISO C++ 2017 with amendments and GNU extensions",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z 
|
  Digraphs | HexFloat | GNUMode)
+LANGSTANDARD_ALIAS_DEPR(gnucxx17, "gnu++1z")
 
 LANGSTANDARD(cxx2a, "c++2a",
  CXX, "Working draft for ISO C++ 2020",

Modified: cfe/trunk/test/Driver/unknown-std.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/unknown-std.cpp?rev=310516&r1=310515&r2=310516&view=diff
==
--- cfe/trunk/test/Driver/unknown-std.cpp (original)
+++ cfe/trunk/test/Driver/unknown-std.cpp Wed Aug  9 13:12:53 2017
@@ -13,8 +13,8 @@
 // CHECK-NEXT: note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU 
extensions' standard
 // CHECK-NEXT: note: use 'c++14' for 'ISO C++ 2014 with amendments' standard
 // CHECK-NEXT: note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU 
extensions' standard
-// CHECK-NEXT: note: use 'c++1z' for 'Working draft for ISO C++ 2017' standard
-// CHECK-NEXT: note: use 'gnu++1z' for 'Working draft for ISO C++ 2017 with 
GNU extensions' standard
+// CHECK-NEXT: note: use 'c++17' for 'ISO C++ 2017 with amendments' standard
+// CHECK-NEXT: note: use 'gnu++17' for 'ISO C++ 2017 with amendments and GNU 
extensions' standard
 // CHECK-NEXT: note: use 'c++2a' for 'Working draft for ISO C++ 2020' standard
 // CHECK-NEXT: note: use 'gnu++2a' for 'Working draft for ISO C++ 2020 with 
GNU extensions' standard
 // CUDA-NEXT: note: use 'cuda' for 'NVIDIA CUDA(tm)' standard

Modified: cfe/trunk/test/SemaCXX/cxx1z-init-statement.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-init-statement.cpp?rev=310516&r1=310515&r2=310516&view=diff
==
--- cfe/trunk/test/SemaCXX/cxx1z-init-statement.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1z-init-statement.cpp Wed Aug  9 13:12:53 2017
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++1z -verify %s
+// RUN: %clang_cc1 -std=c++17 -verify %s
 
 void testIf() {
   int x = 0;


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


[PATCH] D36532: Add -std=c++17

2017-08-09 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310516: Make -std=c++17 an alias of -std=c++1z (authored by 
hans).

Changed prior to commit:
  https://reviews.llvm.org/D36532?vs=110430&id=110462#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36532

Files:
  cfe/trunk/include/clang/Frontend/LangStandards.def
  cfe/trunk/test/Driver/unknown-std.cpp
  cfe/trunk/test/SemaCXX/cxx1z-init-statement.cpp


Index: cfe/trunk/include/clang/Frontend/LangStandards.def
===
--- cfe/trunk/include/clang/Frontend/LangStandards.def
+++ cfe/trunk/include/clang/Frontend/LangStandards.def
@@ -109,15 +109,17 @@
  GNUMode)
 LANGSTANDARD_ALIAS_DEPR(gnucxx14, "gnu++1y")
 
-LANGSTANDARD(cxx1z, "c++1z",
- CXX, "Working draft for ISO C++ 2017",
+LANGSTANDARD(cxx17, "c++17",
+ CXX, "ISO C++ 2017 with amendments",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z 
|
  Digraphs | HexFloat)
+LANGSTANDARD_ALIAS_DEPR(cxx17, "c++1z")
 
-LANGSTANDARD(gnucxx1z, "gnu++1z",
- CXX, "Working draft for ISO C++ 2017 with GNU extensions",
+LANGSTANDARD(gnucxx17, "gnu++17",
+ CXX, "ISO C++ 2017 with amendments and GNU extensions",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z 
|
  Digraphs | HexFloat | GNUMode)
+LANGSTANDARD_ALIAS_DEPR(gnucxx17, "gnu++1z")
 
 LANGSTANDARD(cxx2a, "c++2a",
  CXX, "Working draft for ISO C++ 2020",
Index: cfe/trunk/test/Driver/unknown-std.cpp
===
--- cfe/trunk/test/Driver/unknown-std.cpp
+++ cfe/trunk/test/Driver/unknown-std.cpp
@@ -13,8 +13,8 @@
 // CHECK-NEXT: note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU 
extensions' standard
 // CHECK-NEXT: note: use 'c++14' for 'ISO C++ 2014 with amendments' standard
 // CHECK-NEXT: note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU 
extensions' standard
-// CHECK-NEXT: note: use 'c++1z' for 'Working draft for ISO C++ 2017' standard
-// CHECK-NEXT: note: use 'gnu++1z' for 'Working draft for ISO C++ 2017 with 
GNU extensions' standard
+// CHECK-NEXT: note: use 'c++17' for 'ISO C++ 2017 with amendments' standard
+// CHECK-NEXT: note: use 'gnu++17' for 'ISO C++ 2017 with amendments and GNU 
extensions' standard
 // CHECK-NEXT: note: use 'c++2a' for 'Working draft for ISO C++ 2020' standard
 // CHECK-NEXT: note: use 'gnu++2a' for 'Working draft for ISO C++ 2020 with 
GNU extensions' standard
 // CUDA-NEXT: note: use 'cuda' for 'NVIDIA CUDA(tm)' standard
Index: cfe/trunk/test/SemaCXX/cxx1z-init-statement.cpp
===
--- cfe/trunk/test/SemaCXX/cxx1z-init-statement.cpp
+++ cfe/trunk/test/SemaCXX/cxx1z-init-statement.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++1z -verify %s
+// RUN: %clang_cc1 -std=c++17 -verify %s
 
 void testIf() {
   int x = 0;


Index: cfe/trunk/include/clang/Frontend/LangStandards.def
===
--- cfe/trunk/include/clang/Frontend/LangStandards.def
+++ cfe/trunk/include/clang/Frontend/LangStandards.def
@@ -109,15 +109,17 @@
  GNUMode)
 LANGSTANDARD_ALIAS_DEPR(gnucxx14, "gnu++1y")
 
-LANGSTANDARD(cxx1z, "c++1z",
- CXX, "Working draft for ISO C++ 2017",
+LANGSTANDARD(cxx17, "c++17",
+ CXX, "ISO C++ 2017 with amendments",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z |
  Digraphs | HexFloat)
+LANGSTANDARD_ALIAS_DEPR(cxx17, "c++1z")
 
-LANGSTANDARD(gnucxx1z, "gnu++1z",
- CXX, "Working draft for ISO C++ 2017 with GNU extensions",
+LANGSTANDARD(gnucxx17, "gnu++17",
+ CXX, "ISO C++ 2017 with amendments and GNU extensions",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z |
  Digraphs | HexFloat | GNUMode)
+LANGSTANDARD_ALIAS_DEPR(gnucxx17, "gnu++1z")
 
 LANGSTANDARD(cxx2a, "c++2a",
  CXX, "Working draft for ISO C++ 2020",
Index: cfe/trunk/test/Driver/unknown-std.cpp
===
--- cfe/trunk/test/Driver/unknown-std.cpp
+++ cfe/trunk/test/Driver/unknown-std.cpp
@@ -13,8 +13,8 @@
 // CHECK-NEXT: note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU extensions' standard
 // CHECK-NEXT: note: use 'c++14' for 'ISO C++ 2014 with amendments' standard
 // CHECK-NEXT: note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU extensions' standard
-// CHECK-NEXT: note: use 'c++1z' for 'Working draft for ISO C++ 2017' standard
-// CHECK-NEXT: note: use 'gnu++1z' for 'Working draft for ISO C++ 2017 with GNU extensions' standard
+// CHECK-NEXT: note: use 'c++17' for 'ISO C++ 2017 with amendments' standard
+// CHECK-NEXT: note: use 'gnu++17' for 'ISO C++ 2017 with amendments and GNU exte

[PATCH] D36423: [libc++] Introsort based sorting function

2017-08-09 Thread DIVYA SHANMUGHAN via Phabricator via cfe-commits
DIVYA added a comment.

Link to algorithm.bench.cpp benchmark 
https://github.com/hiraditya/std-benchmark/blob/master/cxx/algorithm.bench.cpp




Comment at: include/algorithm:4208
+
+  // Threshold(or depth limit) for introsort is taken to be 2*log2(size)
+  typedef typename iterator_traits<_RandomAccessIterator>::difference_type 
difference_type;

bcraig wrote:
> This comment says basically the same thing as the code.  The comment would be 
> more useful if it said why 2*log2(size) is used.
We tested the code with depth limit from log2(size) to 4*log2(size).It was 
giving good performance around 2*log2(size).So the depth limit was fixed a this 
value.


https://reviews.llvm.org/D36423



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


[PATCH] D34158: For Linux/gnu compatibility, preinclude if the file is available

2017-08-09 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D34158#837130, @joerg wrote:

> In https://reviews.llvm.org/D34158#836026, @jyknight wrote:
>
> > In https://reviews.llvm.org/D34158#827178, @joerg wrote:
> >
> > > (2) It adds magic behavior that can make debugging more difficult. 
> > > Partially preprocessed sources for example could be compiled with plain 
> > > -c before, now they need a different command line.
> >
> >
> > If this is a problem, making it be Linux-only does _nothing_ to solve it. 
> > But I don't actually see how this is a substantively new problem? Compiling 
> > with plain -c before
> >  would get #defines for those predefined macros that the compiler sets, 
> > even though you may not have wanted those. Is this fundamentally different?
>
>
> It makes it a linux-only problem. As such, it is something *I* only care 
> about secondary. A typical use case I care about a lot is pulling the crash 
> report sources from my (NetBSD) build machine,
>  extracting the original command line to rerun the normal compilation with 
> -save-temps. I don't necessarily have the (same) system headers on the 
> machine I use for debugging and that's exactly
>  the kind of use case this change breaks. All other predefined macros are 
> driven by the target triple and remain stable.


Don't you use preprocessed source files from a crash?


https://reviews.llvm.org/D34158



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


Re: r310436 - [AST] Move visibility computations into a class; NFC

2017-08-09 Thread Juergen Ributzka via cfe-commits
This seems to cause UBSAN issues:

runtime error: load of value 4294967295, which is not a valid value for
type 'clang::LVComputationKind'

See ASAN+UBSAN bot on Green Dragon:
http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/4065/console

On Tue, Aug 8, 2017 at 9:02 PM, George Burgess IV via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: gbiv
> Date: Tue Aug  8 21:02:49 2017
> New Revision: 310436
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310436&view=rev
> Log:
> [AST] Move visibility computations into a class; NFC
>
> This is patch 1 in a 2 patch series that aims to fix PR29160. Its goal
> is to cache decl visibility/linkage for the duration of each
> visibility+linkage query.
>
> The simplest way I can see to do this is to put the visibility
> calculation code that needs to (transitively) access this cache into a
> class, which is what this patch does. Actual caching will come in patch
> 2. (Another way would be to keep the cache in ASTContext + manually
> invalidate it or something, but that felt way too subtle to me.)
>
> Caching visibility results across multiple queries seems a bit tricky,
> since the user can add visibility attributes ~whenever they want, and
> these attributes can apparently have far-reaching effects (e.g. class
> visibility extends to its members, ...). Because a cache that's dropped
> at the end of each top-level query seems to work nearly as well and
> doesn't require any eviction logic, I opted for that design.
>
> Added:
> cfe/trunk/lib/AST/Linkage.h
> Modified:
> cfe/trunk/lib/AST/Decl.cpp
> cfe/trunk/lib/AST/Type.cpp
>
> Modified: cfe/trunk/lib/AST/Decl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> Decl.cpp?rev=310436&r1=310435&r2=310436&view=diff
> 
> ==
> --- cfe/trunk/lib/AST/Decl.cpp (original)
> +++ cfe/trunk/lib/AST/Decl.cpp Tue Aug  8 21:02:49 2017
> @@ -12,6 +12,7 @@
>  //===---
> ---===//
>
>  #include "clang/AST/Decl.h"
> +#include "Linkage.h"
>  #include "clang/AST/ASTContext.h"
>  #include "clang/AST/ASTLambda.h"
>  #include "clang/AST/ASTMutationListener.h"
> @@ -99,38 +100,6 @@ TranslationUnitDecl::TranslationUnitDecl
>  // and 'matcher' is a type only matters when looking for attributes
>  // and settings from the immediate context.
>
> -const static unsigned IgnoreExplicitVisibilityBit = 2;
> -const static unsigned IgnoreAllVisibilityBit = 4;
> -
> -/// Kinds of LV computation.  The linkage side of the computation is
> -/// always the same, but different things can change how visibility is
> -/// computed.
> -enum LVComputationKind {
> -  /// Do an LV computation for, ultimately, a type.
> -  /// Visibility may be restricted by type visibility settings and
> -  /// the visibility of template arguments.
> -  LVForType = NamedDecl::VisibilityForType,
> -
> -  /// Do an LV computation for, ultimately, a non-type declaration.
> -  /// Visibility may be restricted by value visibility settings and
> -  /// the visibility of template arguments.
> -  LVForValue = NamedDecl::VisibilityForValue,
> -
> -  /// Do an LV computation for, ultimately, a type that already has
> -  /// some sort of explicit visibility.  Visibility may only be
> -  /// restricted by the visibility of template arguments.
> -  LVForExplicitType = (LVForType | IgnoreExplicitVisibilityBit),
> -
> -  /// Do an LV computation for, ultimately, a non-type declaration
> -  /// that already has some sort of explicit visibility.  Visibility
> -  /// may only be restricted by the visibility of template arguments.
> -  LVForExplicitValue = (LVForValue | IgnoreExplicitVisibilityBit),
> -
> -  /// Do an LV computation when we only care about the linkage.
> -  LVForLinkageOnly =
> -  LVForValue | IgnoreExplicitVisibilityBit | IgnoreAllVisibilityBit
> -};
> -
>  /// Does this computation kind permit us to consider additional
>  /// visibility settings from attributes and the like?
>  static bool hasExplicitVisibilityAlready(LVComputationKind computation) {
> @@ -219,8 +188,8 @@ static Optional getVisibilit
>return None;
>  }
>
> -static LinkageInfo
> -getLVForType(const Type &T, LVComputationKind computation) {
> +LinkageInfo LinkageComputer::getLVForType(const Type &T,
> +  LVComputationKind computation) {
>if (computation == LVForLinkageOnly)
>  return LinkageInfo(T.getLinkage(), DefaultVisibility, true);
>return T.getLinkageAndVisibility();
> @@ -229,9 +198,8 @@ getLVForType(const Type &T, LVComputatio
>  /// \brief Get the most restrictive linkage for the types in the given
>  /// template parameter list.  For visibility purposes, template
>  /// parameters are part of the signature of a template.
> -static LinkageInfo
> -getLVForTemplateParameterList(const TemplateParameterList *Params,
> -  LVComputationKind com

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

2017-08-09 Thread Aleksey Shlyapnikov via Phabricator via cfe-commits
alekseyshl added a comment.

Even after r310505, openmp-offload.c continues to haunt our bots, for example 
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/2012. 
Can you please fix this test?


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


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

2017-08-09 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

In https://reviews.llvm.org/D29660#837298, @alekseyshl wrote:

> Even after r310505, openmp-offload.c continues to haunt our bots, for example 
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/2012.
>  Can you please fix this test?


Preparing a fix now.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


r310521 - [Sema] Assign new flag -Wenum-compare-switch to switch-related parts of -Wenum-compare

2017-08-09 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Wed Aug  9 13:56:43 2017
New Revision: 310521

URL: http://llvm.org/viewvc/llvm-project?rev=310521&view=rev
Log:
[Sema] Assign new flag -Wenum-compare-switch to switch-related parts of 
-Wenum-compare

Patch by: Reka Nikolett Kovacs

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/Sema/switch.c
cfe/trunk/test/SemaCXX/warn-enum-compare.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=310521&r1=310520&r2=310521&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Aug  9 13:56:43 2017
@@ -454,6 +454,8 @@ def CoveredSwitchDefault : DiagGroup<"co
 def SwitchBool : DiagGroup<"switch-bool">;
 def SwitchEnum : DiagGroup<"switch-enum">;
 def Switch : DiagGroup<"switch">;
+def EnumCompareSwitch : DiagGroup<"enum-compare-switch">;
+def EnumCompare   : DiagGroup<"enum-compare", [EnumCompareSwitch]>;
 def ImplicitFallthroughPerFunction :
   DiagGroup<"implicit-fallthrough-per-function">;
 def ImplicitFallthrough  : DiagGroup<"implicit-fallthrough",

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=310521&r1=310520&r2=310521&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Aug  9 13:56:43 
2017
@@ -5918,7 +5918,11 @@ def warn_runsigned_always_true_compariso
 def warn_comparison_of_mixed_enum_types : Warning<
   "comparison of two values with different enumeration types"
   "%diff{ ($ and $)|}0,1">,
-  InGroup>;
+  InGroup;
+def warn_comparison_of_mixed_enum_types_switch : Warning<
+  "comparison of two values with different enumeration types in switch 
statement"
+  "%diff{ ($ and $)|}0,1">,
+  InGroup;
 def warn_null_in_arithmetic_operation : Warning<
   "use of NULL in arithmetic operation">,
   InGroup;

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=310521&r1=310520&r2=310521&view=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Aug  9 13:56:43 2017
@@ -762,7 +762,7 @@ static void checkEnumTypesInSwitchStmt(S
   if (S.Context.hasSameUnqualifiedType(CondType, CaseType))
 return;
 
-  S.Diag(Case->getExprLoc(), diag::warn_comparison_of_mixed_enum_types)
+  S.Diag(Case->getExprLoc(), diag::warn_comparison_of_mixed_enum_types_switch)
   << CondType << CaseType << Cond->getSourceRange()
   << Case->getSourceRange();
 }

Modified: cfe/trunk/test/Sema/switch.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/switch.c?rev=310521&r1=310520&r2=310521&view=diff
==
--- cfe/trunk/test/Sema/switch.c (original)
+++ cfe/trunk/test/Sema/switch.c Wed Aug  9 13:56:43 2017
@@ -372,7 +372,7 @@ void switch_on_ExtendedEnum1(enum Extend
   case EE1_b: break;
   case EE1_c: break; // no-warning
   case EE1_d: break; // expected-warning {{case value not in enumerated type 
'enum ExtendedEnum1'}}
-  // expected-warning@-1 {{comparison of two values with different enumeration 
types ('enum ExtendedEnum1' and 'const enum ExtendedEnum1_unrelated')}}
+  // expected-warning@-1 {{comparison of two values with different enumeration 
types in switch statement ('enum ExtendedEnum1' and 'const enum 
ExtendedEnum1_unrelated')}}
   }
 }
 

Modified: cfe/trunk/test/SemaCXX/warn-enum-compare.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-enum-compare.cpp?rev=310521&r1=310520&r2=310521&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-enum-compare.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-enum-compare.cpp Wed Aug  9 13:56:43 2017
@@ -212,19 +212,19 @@ void test () {
   switch (a) {
 case name1::F1: break;
 case name1::F3: break;
-case name2::B2: break; // expected-warning {{comparison of two values with 
different enumeration types ('name1::Foo' and 'name2::Baz')}}
+case name2::B2: break; // expected-warning {{comparison of two values with 
different enumeration types in switch statement ('name1::Foo' and 
'name2::Baz')}}
   }
 
   switch (x) {
 case FooB: break;
 case FooC: break;
-case BarD: break; // expected-warning {{comparison of two values with 
different enumeratio

[PATCH] D36526: [Sema] Assign new flag -Wenum-compare-switch to switch-related parts of -Wenum-compare

2017-08-09 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.

Thanks!


https://reviews.llvm.org/D36526



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


  1   2   >