[PATCH] D36955: [libclang] Visit attributes for function and class templates

2017-09-27 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe requested changes to this revision.
jbcoe added a comment.
This revision now requires changes to proceed.

Looks great. Please add tests to clang/tools/c-index-test/c-index-test.c too as 
the Python tests are not run on build-bots (to the best of my knowledge).


https://reviews.llvm.org/D36955



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


r314279 - [clang-format] Fix FixNamespaceComments when BraceWrapping AfterNamespace is true.

2017-09-27 Thread Marek Kurdej via cfe-commits
Author: mkurdej
Date: Wed Sep 27 00:51:51 2017
New Revision: 314279

URL: http://llvm.org/viewvc/llvm-project?rev=314279&view=rev
Log:
[clang-format] Fix FixNamespaceComments when BraceWrapping AfterNamespace is 
true.

Summary:
NamespaceEndCommentsFixer did not fix namespace comments when the brace opening 
the namespace was not on the same line as the "namespace" keyword.
It occurs in Allman, GNU and Linux styles and whenever 
BraceWrapping.AfterNamespace is true.

Before:
```lang=cpp
namespace a
{
void f();
void g();
}
```

After:
```lang=cpp
namespace a
{
void f();
void g();
} // namespace a
```

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp?rev=314279&r1=314278&r2=314279&view=diff
==
--- cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp (original)
+++ cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp Wed Sep 27 00:51:51 2017
@@ -118,6 +118,12 @@ getNamespaceToken(const AnnotatedLine *l
 return nullptr;
   assert(StartLineIndex < AnnotatedLines.size());
   const FormatToken *NamespaceTok = AnnotatedLines[StartLineIndex]->First;
+  if (NamespaceTok->is(tok::l_brace)) {
+// "namespace" keyword can be on the line preceding '{', e.g. in styles
+// where BraceWrapping.AfterNamespace is true.
+if (StartLineIndex > 0)
+  NamespaceTok = AnnotatedLines[StartLineIndex - 1]->First;
+  }
   // Detect "(inline)? namespace" in the beginning of a line.
   if (NamespaceTok->is(tok::kw_inline))
 NamespaceTok = NamespaceTok->getNextNonComment();

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=314279&r1=314278&r2=314279&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Sep 27 00:51:51 2017
@@ -1413,7 +1413,7 @@ TEST_F(FormatTest, FormatsTypedefEnum) {
   verifyFormat("typedef enum {} EmptyEnum;");
   verifyFormat("typedef enum { A, B, C } ShortEnum;");
   verifyFormat("typedef enum {\n"
-   "  ZERO = 0,\n" 
+   "  ZERO = 0,\n"
"  ONE = 1,\n"
"  TWO = 2,\n"
"  THREE = 3\n"
@@ -1425,7 +1425,7 @@ TEST_F(FormatTest, FormatsTypedefEnum) {
   verifyFormat("typedef enum { A, B, C } ShortEnum;");
   verifyFormat("typedef enum\n"
"{\n"
-   "  ZERO = 0,\n" 
+   "  ZERO = 0,\n"
"  ONE = 1,\n"
"  TWO = 2,\n"
"  THREE = 3\n"
@@ -9323,7 +9323,7 @@ TEST_F(FormatTest, LinuxBraceBreaking) {
"struct B {\n"
"  int x;\n"
"};\n"
-   "}\n",
+   "} // namespace a\n",
LinuxBraceStyle);
   verifyFormat("enum X {\n"
"  Y = 0,\n"
@@ -9453,6 +9453,19 @@ TEST_F(FormatTest, StroustrupBraceBreaki
 TEST_F(FormatTest, AllmanBraceBreaking) {
   FormatStyle AllmanBraceStyle = getLLVMStyle();
   AllmanBraceStyle.BreakBeforeBraces = FormatStyle::BS_Allman;
+
+  EXPECT_EQ("namespace a\n"
+"{\n"
+"void f();\n"
+"void g();\n"
+"} // namespace a\n",
+format("namespace a\n"
+   "{\n"
+   "void f();\n"
+   "void g();\n"
+   "}\n",
+   AllmanBraceStyle));
+
   verifyFormat("namespace a\n"
"{\n"
"class A\n"
@@ -9471,7 +9484,7 @@ TEST_F(FormatTest, AllmanBraceBreaking)
"{\n"
"  int x;\n"
"};\n"
-   "}",
+   "} // namespace a",
AllmanBraceStyle);
 
   verifyFormat("void f()\n"
@@ -9677,7 +9690,7 @@ TEST_F(FormatTest, GNUBraceBreaking) {
"  }\n"
"  void g() { return; }\n"
"}\n"
-   "}",
+   "} // namespace a",
GNUBraceStyle);
 
   verifyFormat("void f()\n"


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


[PATCH] D37554: [libclang] Allow crash recovery with LIBCLANG_NOTHREADS

2017-09-27 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

Ping 4


https://reviews.llvm.org/D37554



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


[PATCH] D38110: [libunwind][MIPS]: Add support for unwinding in O32 and N64 processes.

2017-09-27 Thread Simon Dardis via Phabricator via cfe-commits
sdardis edited subscribers, added: cfe-commits; removed: llvm-commits.
sdardis added a comment.

+CC cfe-commits, -CC llvm-commits.

Some comments inlined.

I've managed to run the test-suite on one of my machines here and I'm seeing 3 
failures:

  libunwind :: libunwind_01.pass.cpp
  libunwind :: libunwind_02.pass.cpp
  libunwind :: unw_getcontext.pass.cpp

This is with a GCC toolchain, 6.3. Did you test with clang?




Comment at: include/__libunwind_config.h:54
 #  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 32
+# elif defined(__mips_o32)
+#  define _LIBUNWIND_TARGET_MIPS_O32 1

Can you avoid using the __mips_o32 macro and instead use defined(__mips__) && 
_MIPS_SIM == _ABIO32 ?

It appears the __mips_o32 is a FreeBSD specific macro. Also, test for 
__mips_soft_float .



Comment at: include/__libunwind_config.h:59
+#  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 32
+# elif defined(__mips_n64)
+#  define _LIBUNWIND_TARGET_MIPS_N64 1

Likewise "defined(__mips__) && _MIPS_SIM == _ABI64 && __mips_soft_float"



Comment at: src/UnwindRegistersRestore.S:492
 
+#elif defined(__mips_o32)
+

defined(__mips_o32) -> defined(__mips__) && _MIPS_SIM == _ABIO32



Comment at: src/UnwindRegistersRestore.S:500
+//
+  .set noreorder
+  .set noat

Prefix this with:

   .set push
   .set nomacro

Also, the assembler directives should come after the function declaration / 
defines.



Comment at: src/UnwindRegistersRestore.S:539
+  lw$4, (4 * 4)($4)
+
+#elif defined(__mips_n64)

   .set pop



Comment at: src/UnwindRegistersRestore.S:540
+
+#elif defined(__mips_n64)
+

defined(__mips__) && _MIPS_SIM == _ABI64



Comment at: src/UnwindRegistersRestore.S:550
+  .set noat
+DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind18Registers_mips_n646jumptoEv)
+  // r0 is zero

See my comments on the o32 assembly.



Comment at: src/UnwindRegistersSave.S:90
 
+#elif defined(__mips_o32)
+

See my previous comments about this preprocessor macro.



Comment at: src/UnwindRegistersSave.S:101
+DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
+  .set noreorder
+  # s0 - s7

Wrap this with

   .set push
   .set noat
   .set nomacro



Comment at: src/UnwindRegistersSave.S:120
+  sw$30, (4 * 30)($4)
+
+#elif defined(__mips_n64)

and:
   .set pop



Comment at: src/UnwindRegistersSave.S:121
+
+#elif defined(__mips_n64)
+

Again, see my previous comments on this preprocessor define.



Comment at: src/UnwindRegistersSave.S:132
+DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
+  .set noreorder
+  # s0 - s7

Wrap this with

   .set push
   .set noat
   .set nomacro



Comment at: src/UnwindRegistersSave.S:151
+  sd$30, (8 * 30)($4)
+
 # elif defined(__mips__)

   .set pop



Comment at: src/libunwind.cpp:66
 #elif defined(__mips__)
 # warning The MIPS architecture is not supported.
 #else

The MIPS architecture is not supported with this ABI and environment!


https://reviews.llvm.org/D38110



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


r314287 - [analyzer] Fix and refactor bugreporter::getDerefExpr() API.

2017-09-27 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Sep 27 02:33:37 2017
New Revision: 314287

URL: http://llvm.org/viewvc/llvm-project?rev=314287&view=rev
Log:
[analyzer] Fix and refactor bugreporter::getDerefExpr() API.

This API is used by checkers (and other entities) in order to track where does
a value originate from, by jumping from an expression value of which is equal
to that value to the expression from which this value has "appeared". For
example, it may be an lvalue from which the rvalue was loaded, or a function
call from which the dereferenced pointer was returned.

The function now avoids incorrectly unwrapping implicit lvalue-to-rvalue casts,
which caused crashes and incorrect intermediate diagnostic pieces. It also no
longer relies on how the expression is written when guessing what it means.

Fixes pr34373 and pr34731.

rdar://problem/33594502

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

Added:
cfe/trunk/test/Analysis/null-deref-path-notes.c
cfe/trunk/test/Analysis/null-deref-path-notes.cpp
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/test/Analysis/null-deref-path-notes.m

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=314287&r1=314286&r2=314287&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Wed Sep 27 
02:33:37 2017
@@ -42,48 +42,68 @@ bool bugreporter::isDeclRefExprToReferen
   return false;
 }
 
+/// Given that expression S represents a pointer that would be dereferenced,
+/// try to find a sub-expression from which the pointer came from.
+/// This is used for tracking down origins of a null or undefined value:
+/// "this is null because that is null because that is null" etc.
+/// We wipe away field and element offsets because they merely add offsets.
+/// We also wipe away all casts except lvalue-to-rvalue casts, because the
+/// latter represent an actual pointer dereference; however, we remove
+/// the final lvalue-to-rvalue cast before returning from this function
+/// because it demonstrates more clearly from where the pointer rvalue was
+/// loaded. Examples:
+///   x->y.z  ==>  x (lvalue)
+///   foo()->y.z  ==>  foo() (rvalue)
 const Expr *bugreporter::getDerefExpr(const Stmt *S) {
-  // Pattern match for a few useful cases:
-  //   a[0], p->f, *p
   const Expr *E = dyn_cast(S);
   if (!E)
 return nullptr;
-  E = E->IgnoreParenCasts();
 
   while (true) {
-if (const BinaryOperator *B = dyn_cast(E)) {
-  assert(B->isAssignmentOp());
-  E = B->getLHS()->IgnoreParenCasts();
-  continue;
-}
-else if (const UnaryOperator *U = dyn_cast(E)) {
-  if (U->getOpcode() == UO_Deref)
-return U->getSubExpr()->IgnoreParenCasts();
-}
-else if (const MemberExpr *ME = dyn_cast(E)) {
-  if (ME->isImplicitAccess()) {
-return ME;
-  } else if (ME->isArrow() || isDeclRefExprToReference(ME->getBase())) {
-return ME->getBase()->IgnoreParenCasts();
+if (const CastExpr *CE = dyn_cast(E)) {
+  if (CE->getCastKind() == CK_LValueToRValue) {
+// This cast represents the load we're looking for.
+break;
+  }
+  E = CE->getSubExpr();
+} else if (isa(E)) {
+  // Probably more arithmetic can be pattern-matched here,
+  // but for now give up.
+  break;
+} else if (const UnaryOperator *U = dyn_cast(E)) {
+  if (U->getOpcode() == UO_Deref) {
+// Operators '*' and '&' don't actually mean anything.
+// We look at casts instead.
+E = U->getSubExpr();
   } else {
-// If we have a member expr with a dot, the base must have been
-// dereferenced.
-return getDerefExpr(ME->getBase());
+// Probably more arithmetic can be pattern-matched here,
+// but for now give up.
+break;
   }
 }
-else if (const ObjCIvarRefExpr *IvarRef = dyn_cast(E)) {
-  return IvarRef->getBase()->IgnoreParenCasts();
-}
-else if (const ArraySubscriptExpr *AE = dyn_cast(E)) {
-  return getDerefExpr(AE->getBase());
-}
-else if (isa(E)) {
-  return E;
+// Pattern match for a few useful cases: a[0], p->f, *p etc.
+else if (const MemberExpr *ME = dyn_cast(E)) {
+  E = ME->getBase();
+} else if (const ObjCIvarRefExpr *IvarRef = dyn_cast(E)) {
+  E = IvarRef->getBase();
+} else if (const ArraySubscriptExpr *AE = dyn_cast(E)) 
{
+  E = AE->getBase();
+} else if (const ParenExpr *PE = dyn_cast(E)) {
+  E = PE->getSubExpr();
+} else {
+  // Other arbitrary stuff.
+  break;
 }
-break;
   }
 
-  return nullptr;
+  // Special case: remove the final lvalue-to-rvalue cast, but do not recurse
+  // deeper into the sub-expression. This wa

[PATCH] D37023: [analyzer] Fix bugreporter::getDerefExpr() again.

2017-09-27 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314287: [analyzer] Fix and refactor 
bugreporter::getDerefExpr() API. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D37023?vs=116673&id=116781#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37023

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  cfe/trunk/test/Analysis/null-deref-path-notes.c
  cfe/trunk/test/Analysis/null-deref-path-notes.cpp
  cfe/trunk/test/Analysis/null-deref-path-notes.m

Index: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -42,48 +42,68 @@
   return false;
 }
 
+/// Given that expression S represents a pointer that would be dereferenced,
+/// try to find a sub-expression from which the pointer came from.
+/// This is used for tracking down origins of a null or undefined value:
+/// "this is null because that is null because that is null" etc.
+/// We wipe away field and element offsets because they merely add offsets.
+/// We also wipe away all casts except lvalue-to-rvalue casts, because the
+/// latter represent an actual pointer dereference; however, we remove
+/// the final lvalue-to-rvalue cast before returning from this function
+/// because it demonstrates more clearly from where the pointer rvalue was
+/// loaded. Examples:
+///   x->y.z  ==>  x (lvalue)
+///   foo()->y.z  ==>  foo() (rvalue)
 const Expr *bugreporter::getDerefExpr(const Stmt *S) {
-  // Pattern match for a few useful cases:
-  //   a[0], p->f, *p
   const Expr *E = dyn_cast(S);
   if (!E)
 return nullptr;
-  E = E->IgnoreParenCasts();
 
   while (true) {
-if (const BinaryOperator *B = dyn_cast(E)) {
-  assert(B->isAssignmentOp());
-  E = B->getLHS()->IgnoreParenCasts();
-  continue;
-}
-else if (const UnaryOperator *U = dyn_cast(E)) {
-  if (U->getOpcode() == UO_Deref)
-return U->getSubExpr()->IgnoreParenCasts();
-}
-else if (const MemberExpr *ME = dyn_cast(E)) {
-  if (ME->isImplicitAccess()) {
-return ME;
-  } else if (ME->isArrow() || isDeclRefExprToReference(ME->getBase())) {
-return ME->getBase()->IgnoreParenCasts();
+if (const CastExpr *CE = dyn_cast(E)) {
+  if (CE->getCastKind() == CK_LValueToRValue) {
+// This cast represents the load we're looking for.
+break;
+  }
+  E = CE->getSubExpr();
+} else if (isa(E)) {
+  // Probably more arithmetic can be pattern-matched here,
+  // but for now give up.
+  break;
+} else if (const UnaryOperator *U = dyn_cast(E)) {
+  if (U->getOpcode() == UO_Deref) {
+// Operators '*' and '&' don't actually mean anything.
+// We look at casts instead.
+E = U->getSubExpr();
   } else {
-// If we have a member expr with a dot, the base must have been
-// dereferenced.
-return getDerefExpr(ME->getBase());
+// Probably more arithmetic can be pattern-matched here,
+// but for now give up.
+break;
   }
 }
-else if (const ObjCIvarRefExpr *IvarRef = dyn_cast(E)) {
-  return IvarRef->getBase()->IgnoreParenCasts();
-}
-else if (const ArraySubscriptExpr *AE = dyn_cast(E)) {
-  return getDerefExpr(AE->getBase());
-}
-else if (isa(E)) {
-  return E;
+// Pattern match for a few useful cases: a[0], p->f, *p etc.
+else if (const MemberExpr *ME = dyn_cast(E)) {
+  E = ME->getBase();
+} else if (const ObjCIvarRefExpr *IvarRef = dyn_cast(E)) {
+  E = IvarRef->getBase();
+} else if (const ArraySubscriptExpr *AE = dyn_cast(E)) {
+  E = AE->getBase();
+} else if (const ParenExpr *PE = dyn_cast(E)) {
+  E = PE->getSubExpr();
+} else {
+  // Other arbitrary stuff.
+  break;
 }
-break;
   }
 
-  return nullptr;
+  // Special case: remove the final lvalue-to-rvalue cast, but do not recurse
+  // deeper into the sub-expression. This way we return the lvalue from which
+  // our pointer rvalue was loaded.
+  if (const ImplicitCastExpr *CE = dyn_cast(E))
+if (CE->getCastKind() == CK_LValueToRValue)
+  E = CE->getSubExpr();
+
+  return E;
 }
 
 const Stmt *bugreporter::GetDenomExpr(const ExplodedNode *N) {
Index: cfe/trunk/test/Analysis/null-deref-path-notes.m
===
--- cfe/trunk/test/Analysis/null-deref-path-notes.m
+++ cfe/trunk/test/Analysis/null-deref-path-notes.m
@@ -50,6 +50,23 @@
   *p = 1; // expected-warning{{Dereference of null pointer}} expected-note{{Dereference of null pointer}}
 }
 
+@interface WithArrayPtr
+- (void) useArray;
+@end
+
+@implementation WithArrayPtr {
+@public int *p;
+}
+- (void)useArray {
+  p[1] = 2; // expected-warning{{Array access (via ivar 'p') res

[PATCH] D37025: [analyzer] Support more pointer arithmetic in bugreporter::getDerefExpr().

2017-09-27 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314290: [analyzer] Match more patterns in 
bugreporter::getDerefExpr() API. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D37025?vs=112221&id=116783#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37025

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  cfe/trunk/test/Analysis/inlining/inline-defensive-checks.c
  cfe/trunk/test/Analysis/null-deref-path-notes.c
  cfe/trunk/test/Analysis/nullptr.cpp

Index: cfe/trunk/test/Analysis/null-deref-path-notes.c
===
--- cfe/trunk/test/Analysis/null-deref-path-notes.c
+++ cfe/trunk/test/Analysis/null-deref-path-notes.c
@@ -4,7 +4,7 @@
 // of the null pointer for path notes. Apparently, not much actual tracking
 // needs to be done in this example.
 void pr34373() {
-  int *a = 0;
+  int *a = 0; // expected-note{{'a' initialized to a null pointer value}}
   (a + 0)[0]; // expected-warning{{Array access results in a null pointer dereference}}
   // expected-note@-1{{Array access results in a null pointer dereference}}
 }
Index: cfe/trunk/test/Analysis/inlining/inline-defensive-checks.c
===
--- cfe/trunk/test/Analysis/inlining/inline-defensive-checks.c
+++ cfe/trunk/test/Analysis/inlining/inline-defensive-checks.c
@@ -169,6 +169,18 @@
   *x = 7; // no-warning
 }
 
+void idcTrackZeroValueThroughManyUnaryPointerOperatorsWithAssignment(struct S *s) {
+  idc(s);
+  int *x = &*&(s->f1);
+  *x = 7; // no-warning
+}
+
+void idcTrackZeroValueThroughManyUnaryPointerOperatorsWithAssignmentAndUnaryIncrement(struct S *s) {
+  idc(s);
+  int *x = &*&((++s)->f1);
+  *x = 7; // no-warning
+}
+
 
 struct S2 {
   int a[1];
Index: cfe/trunk/test/Analysis/nullptr.cpp
===
--- cfe/trunk/test/Analysis/nullptr.cpp
+++ cfe/trunk/test/Analysis/nullptr.cpp
@@ -1,11 +1,12 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -Wno-conversion-null -analyzer-checker=core,debug.ExprInspection -analyzer-store region -verify %s
+// RUN: %clang_analyze_cc1 -std=c++11 -Wno-conversion-null -analyzer-checker=core,debug.ExprInspection -analyzer-store region -analyzer-output=text -verify %s
 
 void clang_analyzer_eval(int);
 
 // test to see if nullptr is detected as a null pointer
 void foo1(void) {
-  char  *np = nullptr;
+  char  *np = nullptr; // expected-note{{'np' initialized to a null pointer value}}
   *np = 0;  // expected-warning{{Dereference of null pointer}}
+// expected-note@-1{{Dereference of null pointer}}
 }
 
 // check if comparing nullptr to nullptr is detected properly
@@ -23,10 +24,11 @@
   struct foo {
 int a, f;
   };
-  char *np = nullptr;
+  char *np = nullptr; // expected-note{{'np' initialized to a null pointer value}}
   // casting a nullptr to anything should be caught eventually
-  int *ip = &(((struct foo *)np)->f);
+  int *ip = &(((struct foo *)np)->f); // expected-note{{'ip' initialized to a null pointer value}}
   *ip = 0;  // expected-warning{{Dereference of null pointer}}
+// expected-note@-1{{Dereference of null pointer}}
   // should be error here too, but analysis gets stopped
 //  *np = 0;
 }
@@ -49,16 +51,31 @@
 }
 
 void zoo1() {
-  char **p = 0;
+  char **p = 0; // expected-note{{'p' initialized to a null pointer value}}
   delete *(p + 0); // expected-warning{{Dereference of null pointer}}
+   // expected-note@-1{{Dereference of null pointer}}
+}
+
+void zoo1backwards() {
+  char **p = 0; // expected-note{{'p' initialized to a null pointer value}}
+  delete *(0 + p); // expected-warning{{Dereference of null pointer}}
+   // expected-note@-1{{Dereference of null pointer}}
+}
+
+typedef __INTPTR_TYPE__ intptr_t;
+void zoo1multiply() {
+  char **p = 0; // FIXME-should-be-note:{{'p' initialized to a null pointer value}}
+  delete *((char **)((intptr_t)p * 2)); // expected-warning{{Dereference of null pointer}}
+   // expected-note@-1{{Dereference of null pointer}}
 }
 
 void zoo2() {
   int **a = 0;
-  int **b = 0;
+  int **b = 0; // expected-note{{'b' initialized to a null pointer value}}
   asm ("nop"
   :"=r"(*a)
   :"0"(*b) // expected-warning{{Dereference of null pointer}}
+   // expected-note@-1{{Dereference of null pointer}}
   );
 }
 
@@ -70,17 +87,19 @@
 int a;
   };
 
-  int *x = 0;
+  int *x = 0; // expected-note{{'x' initialized to a null pointer value}}
   return S(*x).a; // expected-warning{{Dereference of null pointer}}
+  // expected-note@-1{{Dereference of null pointer}}
 }
 
 int materializeTempExpr() {
-  int *n = 0;
+  int *n = 0; // expected-note{{'n' initialized to a null pointer value}}
   struct S {
 int a;
 S(int i): a(i) {}
   };
   const S &s = S(*n); // expected-warning{{Dereferenc

r314290 - [analyzer] Match more patterns in bugreporter::getDerefExpr() API.

2017-09-27 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Sep 27 02:50:45 2017
New Revision: 314290

URL: http://llvm.org/viewvc/llvm-project?rev=314290&view=rev
Log:
[analyzer] Match more patterns in bugreporter::getDerefExpr() API.

This function can now track null pointer through simple pointer arithmetic,
such as '*&*(p + 2)' => 'p' and so on, displaying intermediate diagnostic pieces
for the user to understand where the null pointer is coming from.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/test/Analysis/inlining/inline-defensive-checks.c
cfe/trunk/test/Analysis/null-deref-path-notes.c
cfe/trunk/test/Analysis/nullptr.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=314290&r1=314289&r2=314290&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Wed Sep 27 
02:50:45 2017
@@ -66,12 +66,24 @@ const Expr *bugreporter::getDerefExpr(co
 break;
   }
   E = CE->getSubExpr();
-} else if (isa(E)) {
-  // Probably more arithmetic can be pattern-matched here,
-  // but for now give up.
-  break;
+} else if (const BinaryOperator *B = dyn_cast(E)) {
+  // Pointer arithmetic: '*(x + 2)' -> 'x') etc.
+  if (B->getType()->isPointerType()) {
+if (B->getLHS()->getType()->isPointerType()) {
+  E = B->getLHS();
+} else if (B->getRHS()->getType()->isPointerType()) {
+  E = B->getRHS();
+} else {
+  break;
+}
+  } else {
+// Probably more arithmetic can be pattern-matched here,
+// but for now give up.
+break;
+  }
 } else if (const UnaryOperator *U = dyn_cast(E)) {
-  if (U->getOpcode() == UO_Deref) {
+  if (U->getOpcode() == UO_Deref || U->getOpcode() == UO_AddrOf ||
+  (U->isIncrementDecrementOp() && U->getType()->isPointerType())) {
 // Operators '*' and '&' don't actually mean anything.
 // We look at casts instead.
 E = U->getSubExpr();

Modified: cfe/trunk/test/Analysis/inlining/inline-defensive-checks.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/inlining/inline-defensive-checks.c?rev=314290&r1=314289&r2=314290&view=diff
==
--- cfe/trunk/test/Analysis/inlining/inline-defensive-checks.c (original)
+++ cfe/trunk/test/Analysis/inlining/inline-defensive-checks.c Wed Sep 27 
02:50:45 2017
@@ -169,6 +169,18 @@ void idcTrackZeroValueThroughUnaryPointe
   *x = 7; // no-warning
 }
 
+void idcTrackZeroValueThroughManyUnaryPointerOperatorsWithAssignment(struct S 
*s) {
+  idc(s);
+  int *x = &*&(s->f1);
+  *x = 7; // no-warning
+}
+
+void 
idcTrackZeroValueThroughManyUnaryPointerOperatorsWithAssignmentAndUnaryIncrement(struct
 S *s) {
+  idc(s);
+  int *x = &*&((++s)->f1);
+  *x = 7; // no-warning
+}
+
 
 struct S2 {
   int a[1];

Modified: cfe/trunk/test/Analysis/null-deref-path-notes.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/null-deref-path-notes.c?rev=314290&r1=314289&r2=314290&view=diff
==
--- cfe/trunk/test/Analysis/null-deref-path-notes.c (original)
+++ cfe/trunk/test/Analysis/null-deref-path-notes.c Wed Sep 27 02:50:45 2017
@@ -4,7 +4,7 @@
 // of the null pointer for path notes. Apparently, not much actual tracking
 // needs to be done in this example.
 void pr34373() {
-  int *a = 0;
+  int *a = 0; // expected-note{{'a' initialized to a null pointer value}}
   (a + 0)[0]; // expected-warning{{Array access results in a null pointer 
dereference}}
   // expected-note@-1{{Array access results in a null pointer 
dereference}}
 }

Modified: cfe/trunk/test/Analysis/nullptr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nullptr.cpp?rev=314290&r1=314289&r2=314290&view=diff
==
--- cfe/trunk/test/Analysis/nullptr.cpp (original)
+++ cfe/trunk/test/Analysis/nullptr.cpp Wed Sep 27 02:50:45 2017
@@ -1,11 +1,12 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -Wno-conversion-null 
-analyzer-checker=core,debug.ExprInspection -analyzer-store region -verify %s
+// RUN: %clang_analyze_cc1 -std=c++11 -Wno-conversion-null 
-analyzer-checker=core,debug.ExprInspection -analyzer-store region 
-analyzer-output=text -verify %s
 
 void clang_analyzer_eval(int);
 
 // test to see if nullptr is detected as a null pointer
 void foo1(void) {
-  char  *np = nullptr;
+  char  *np = nullptr; // expected-note{{'np' initialized to a null pointer 
value}}
   *np = 0;  // expected-warning{{Dereference of null pointer

[PATCH] D38291: clang-format/java: Unbreak genenrics formatting after r299952.

2017-09-27 Thread Richard Bradfield via Phabricator via cfe-commits
bradfier accepted this revision.
bradfier added a comment.
This revision is now accepted and ready to land.

If this doesn't break the test case for '>>>' then it looks good, although I'm 
not sure what has changed in the interim to allow that to work. When I made the 
patch in r299952 we definitely required the explicit JavaRightLogicalShift 
handling.


https://reviews.llvm.org/D38291



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


r314298 - [analyzer] Fix an outdated comment in a test. NFC.

2017-09-27 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Sep 27 03:59:06 2017
New Revision: 314298

URL: http://llvm.org/viewvc/llvm-project?rev=314298&view=rev
Log:
[analyzer] Fix an outdated comment in a test. NFC.

Modified:
cfe/trunk/test/Analysis/null-deref-path-notes.c

Modified: cfe/trunk/test/Analysis/null-deref-path-notes.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/null-deref-path-notes.c?rev=314298&r1=314297&r2=314298&view=diff
==
--- cfe/trunk/test/Analysis/null-deref-path-notes.c (original)
+++ cfe/trunk/test/Analysis/null-deref-path-notes.c Wed Sep 27 03:59:06 2017
@@ -1,8 +1,7 @@
 // RUN: %clang_analyze_cc1 -w -x c -analyzer-checker=core 
-analyzer-output=text -verify %s
 
 // Avoid the crash when finding the expression for tracking the origins
-// of the null pointer for path notes. Apparently, not much actual tracking
-// needs to be done in this example.
+// of the null pointer for path notes.
 void pr34373() {
   int *a = 0; // expected-note{{'a' initialized to a null pointer value}}
   (a + 0)[0]; // expected-warning{{Array access results in a null pointer 
dereference}}


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


Re: r309386 - Recommit r308327 3rd time: Add a warning for missing

2017-09-27 Thread Alex L via cfe-commits
Are the pshpack1.h/poppack.h headers included from other headers in the SDK
or are they intended for end-users? If they're only used in the SDK then
the SDK headers should probably be system headers, so the warning should be
silenced.

Apart from that there's no real good solution for this issue unfortunately
apart from turning off the warning with a command-line flag or a pragma. I
don't think this particular pattern warrants some sort of special treatment
in Clang.

On 26 September 2017 at 17:02, Nico Weber  wrote:

> Another bit of feedback: The Microsoft SDK has pragma adjustment headers
> that are used like so:
>
> #include 
> // Define structs with alignment 1 here
> #include 
>
> This warning fires on that. I haven't seen these headers in active use
> recently, but I remember seeing them quite a bit maybe 10 years ago. (It
> took me until today to remember their names.) Any ideas on how to deal with
> that?
>
> On Fri, Jul 28, 2017 at 2:41 PM, Alex Lorenz via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: arphaman
>> Date: Fri Jul 28 07:41:21 2017
>> New Revision: 309386
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=309386&view=rev
>> Log:
>> Recommit r308327 3rd time: Add a warning for missing
>> '#pragma pack (pop)' and suspicious uses of '#pragma pack' in included
>> files
>>
>> The second recommit (r309106) was reverted because the "non-default
>> #pragma
>> pack value chages the alignment of struct or union members in the
>> included file"
>> warning proved to be too aggressive for external projects like Chromium
>> (https://bugs.chromium.org/p/chromium/issues/detail?id=749197). This
>> recommit
>> makes the problematic warning a non-default one, and gives it the
>> -Wpragma-pack-suspicious-include warning option.
>>
>> The first recommit (r308441) caused a "non-default #pragma pack value
>> might
>> change the alignment of struct or union members in the included file"
>> warning
>> in LLVM itself. This recommit tweaks the added warning to avoid warnings
>> for
>> #includes that don't have any records that are affected by the non-default
>> alignment. This tweak avoids the previously emitted warning in LLVM.
>>
>> Original message:
>>
>> This commit adds a new -Wpragma-pack warning. It warns in the following
>> cases:
>>
>> - When a translation unit is missing terminating #pragma pack (pop)
>> directives.
>> - When entering an included file if the current alignment value as
>> determined
>>   by '#pragma pack' directives is different from the default alignment
>> value.
>> - When leaving an included file that changed the state of the current
>> alignment
>>   value.
>>
>> rdar://10184173
>>
>> Differential Revision: https://reviews.llvm.org/D35484
>>
>> Added:
>> cfe/trunk/test/PCH/suspicious-pragma-pack.c
>> cfe/trunk/test/Sema/Inputs/pragma-pack1.h
>> cfe/trunk/test/Sema/Inputs/pragma-pack2.h
>> cfe/trunk/test/Sema/suspicious-pragma-pack.c
>> cfe/trunk/test/SemaObjC/Inputs/empty.h
>> cfe/trunk/test/SemaObjC/suspicious-pragma-pack.m
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/include/clang/Lex/PPCallbacks.h
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/include/clang/Serialization/ASTReader.h
>> cfe/trunk/lib/Parse/ParsePragma.cpp
>> cfe/trunk/lib/Sema/Sema.cpp
>> cfe/trunk/lib/Sema/SemaAttr.cpp
>> cfe/trunk/lib/Serialization/ASTReader.cpp
>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>> cfe/trunk/test/OpenMP/declare_simd_messages.cpp
>> cfe/trunk/test/PCH/pragma-pack.c
>> cfe/trunk/test/Parser/pragma-options.c
>> cfe/trunk/test/Parser/pragma-options.cpp
>> cfe/trunk/test/Parser/pragma-pack.c
>> cfe/trunk/test/Sema/pragma-pack.c
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Basic/DiagnosticGroups.td?rev=309386&r1=309385&r2=309386&view=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jul 28
>> 07:41:21 2017
>> @@ -471,8 +471,10 @@ def IgnoredPragmaIntrinsic : DiagGroup<"
>>  def UnknownPragmas : DiagGroup<"unknown-pragmas">;
>>  def IgnoredPragmas : DiagGroup<"ignored-pragmas",
>> [IgnoredPragmaIntrinsic]>;
>>  def PragmaClangAttribute : DiagGroup<"pragma-clang-attribute">;
>> +def PragmaPackSuspiciousInclude : DiagGroup<"pragma-pack-suspici
>> ous-include">;
>> +def PragmaPack : DiagGroup<"pragma-pack", [PragmaPackSuspiciousInclude]>
>> ;
>>  def Pragmas : DiagGroup<"pragmas", [UnknownPragmas, IgnoredPragmas,
>> -PragmaClangAttribute]>;
>> +PragmaClangAttribute, PragmaPack]>;
>>  def UnknownWarningOption : DiagGroup<"unknown-warning-option">;
>>  def NSobjectAttri

r314300 - [X86][MS-InlineAsm] Extended support for variables / identifiers on memory / immediate expressions

2017-09-27 Thread Coby Tayree via cfe-commits
Author: coby
Date: Wed Sep 27 05:36:54 2017
New Revision: 314300

URL: http://llvm.org/viewvc/llvm-project?rev=314300&view=rev
Log:
[X86][MS-InlineAsm] Extended support for variables / identifiers on memory / 
immediate expressions

Allow the proper recognition of Enum values and global variables inside ms 
inline-asm memory / immediate expressions, as they require some additional 
overhead and treated incorrect if doesn't early recognized.
supersedes D33277, D35775
Corrsponds with D37412, D37413

Added:
cfe/trunk/test/CodeGen/ms-inline-asm-enums.cpp   (with props)
cfe/trunk/test/CodeGen/ms-inline-asm-variables.c   (with props)

Added: cfe/trunk/test/CodeGen/ms-inline-asm-enums.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm-enums.cpp?rev=314300&view=auto
==
--- cfe/trunk/test/CodeGen/ms-inline-asm-enums.cpp (added)
+++ cfe/trunk/test/CodeGen/ms-inline-asm-enums.cpp Wed Sep 27 05:36:54 2017
@@ -0,0 +1,54 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -fasm-blocks -triple i386-apple-darwin10 -emit-llvm -o - 
| FileCheck %s
+
+namespace x {
+  enum { A = 12 };
+  struct y_t {
+enum { A = 17 };
+int r;
+  } y;
+}
+
+// CHECK-LABEL: t1
+void t1() {
+  enum { A = 1 };
+  // CHECK: call void asm
+  // CHECK-SAME: mov eax, $$12
+  __asm mov eax, x::A
+  // CHECK-SAME: mov eax, $$17
+  __asm mov eax, x::y_t::A
+  // CHECK-NEXT: call void asm
+  // CHECK-SAME: mov eax, $$1
+  __asm {mov eax, A}
+}
+
+// CHECK-LABEL: t2
+void t2() {
+  enum { A = 1, B };
+  // CHECK: call void asm
+  // CHECK-SAME: mov eax, $$21
+  __asm mov eax, (A + 9) * 2 + A
+  // CHECK-SAME: mov eax, $$4
+  __asm mov eax, A << 2
+  // CHECK-SAME: mov eax, $$2
+  __asm mov eax, B & 3
+  // CHECK-SAME: mov eax, $$5
+  __asm mov eax, 3 + (B & 3)
+  // CHECK-SAME: mov eax, $$8
+  __asm mov eax, 2 << A * B
+}
+
+// CHECK-LABEL: t3
+void t3() {
+  int arr[4];
+  enum { A = 4, B };
+  // CHECK: call void asm
+  // CHECK-SAME: mov eax, [eax + $$47]
+  __asm { mov eax, [(x::A + 9) + A * B + 3 + 3 + eax] }
+  // CHECK-NEXT: call void asm
+  // CHECK-SAME: mov eax, dword ptr $0[$$4]
+  __asm { mov eax, dword ptr [arr + A] }
+  // CHECK-NEXT: call void asm
+  // CHECK-SAME: mov eax, dword ptr $0[$$8]
+  __asm { mov eax, dword ptr A[arr + A] }
+}

Propchange: cfe/trunk/test/CodeGen/ms-inline-asm-enums.cpp
--
svn:eol-style = native

Propchange: cfe/trunk/test/CodeGen/ms-inline-asm-enums.cpp
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/CodeGen/ms-inline-asm-enums.cpp
--
svn:mime-type = text/plain

Added: cfe/trunk/test/CodeGen/ms-inline-asm-variables.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm-variables.c?rev=314300&view=auto
==
--- cfe/trunk/test/CodeGen/ms-inline-asm-variables.c (added)
+++ cfe/trunk/test/CodeGen/ms-inline-asm-variables.c Wed Sep 27 05:36:54 2017
@@ -0,0 +1,35 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -fasm-blocks -triple i386-apple-darwin10 -emit-llvm -o - 
| FileCheck %s
+
+int gVar;
+void t1() {
+  // CHECK: add eax, dword ptr gVar[eax]
+  __asm add eax, dword ptr gVar[eax]
+  // CHECK: add dword ptr gVar[eax], eax
+  __asm add dword ptr [eax+gVar], eax
+  // CHECK: add ebx, dword ptr gVar[ebx + $$270]
+  __asm add ebx, dword ptr gVar[271 - 82 + 81 + ebx]
+  // CHECK: add dword ptr gVar[ebx + $$828], ebx
+  __asm add dword ptr [ebx + gVar + 828], ebx
+  // CHECK: add ecx, dword ptr gVar[ecx + ecx * $$4 + $$4590]
+  __asm add ecx, dword ptr gVar[4590 + ecx + ecx*4]
+  // CHECK: add dword ptr gVar[ecx + ecx * $$8 + $$73], ecx
+  __asm add dword ptr [gVar + ecx + 45 + 23 - 53 + 60 - 2 + ecx*8], ecx
+  // CHECK: add gVar[ecx + ebx + $$7], eax
+  __asm add 1 + 1 + 2 + 3[gVar + ecx + ebx], eax
+}
+
+void t2() {
+  int lVar;
+  // CHECK: mov eax, dword ptr ${{[0-9]}}[eax]
+  __asm mov eax, dword ptr lVar[eax]
+  // CHECK: mov dword ptr ${{[0-9]}}[eax], eax
+  __asm mov dword ptr [eax+lVar], eax
+  // CHECK: mov ebx, dword ptr ${{[0-9]}}[ebx + $$270]
+  __asm mov ebx, dword ptr lVar[271 - 82 + 81 + ebx]
+  // CHECK: mov dword ptr ${{[0-9]}}[ebx + $$828], ebx
+  __asm mov dword ptr [ebx + lVar + 828], ebx
+  // CHECK: mov ${{[0-9]}}[ebx + $$47], eax
+  __asm mov 5 + 8 + 13 + 21[lVar + ebx], eax
+}
+

Propchange: cfe/trunk/test/CodeGen/ms-inline-asm-variables.c
--
svn:eol-style = native

Propchange: cfe/trunk/test/CodeGen/ms-inline-asm-variables.c
--
svn:keyword

r314302 - revert rL314300

2017-09-27 Thread Coby Tayree via cfe-commits
Author: coby
Date: Wed Sep 27 06:02:44 2017
New Revision: 314302

URL: http://llvm.org/viewvc/llvm-project?rev=314302&view=rev
Log:
revert rL314300
accidently added only tests w/o the respective changes..


Removed:
cfe/trunk/test/CodeGen/ms-inline-asm-enums.cpp
cfe/trunk/test/CodeGen/ms-inline-asm-variables.c

Removed: cfe/trunk/test/CodeGen/ms-inline-asm-enums.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm-enums.cpp?rev=314301&view=auto
==
--- cfe/trunk/test/CodeGen/ms-inline-asm-enums.cpp (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm-enums.cpp (removed)
@@ -1,54 +0,0 @@
-// REQUIRES: x86-registered-target
-// RUN: %clang_cc1 %s -fasm-blocks -triple i386-apple-darwin10 -emit-llvm -o - 
| FileCheck %s
-
-namespace x {
-  enum { A = 12 };
-  struct y_t {
-enum { A = 17 };
-int r;
-  } y;
-}
-
-// CHECK-LABEL: t1
-void t1() {
-  enum { A = 1 };
-  // CHECK: call void asm
-  // CHECK-SAME: mov eax, $$12
-  __asm mov eax, x::A
-  // CHECK-SAME: mov eax, $$17
-  __asm mov eax, x::y_t::A
-  // CHECK-NEXT: call void asm
-  // CHECK-SAME: mov eax, $$1
-  __asm {mov eax, A}
-}
-
-// CHECK-LABEL: t2
-void t2() {
-  enum { A = 1, B };
-  // CHECK: call void asm
-  // CHECK-SAME: mov eax, $$21
-  __asm mov eax, (A + 9) * 2 + A
-  // CHECK-SAME: mov eax, $$4
-  __asm mov eax, A << 2
-  // CHECK-SAME: mov eax, $$2
-  __asm mov eax, B & 3
-  // CHECK-SAME: mov eax, $$5
-  __asm mov eax, 3 + (B & 3)
-  // CHECK-SAME: mov eax, $$8
-  __asm mov eax, 2 << A * B
-}
-
-// CHECK-LABEL: t3
-void t3() {
-  int arr[4];
-  enum { A = 4, B };
-  // CHECK: call void asm
-  // CHECK-SAME: mov eax, [eax + $$47]
-  __asm { mov eax, [(x::A + 9) + A * B + 3 + 3 + eax] }
-  // CHECK-NEXT: call void asm
-  // CHECK-SAME: mov eax, dword ptr $0[$$4]
-  __asm { mov eax, dword ptr [arr + A] }
-  // CHECK-NEXT: call void asm
-  // CHECK-SAME: mov eax, dword ptr $0[$$8]
-  __asm { mov eax, dword ptr A[arr + A] }
-}

Removed: cfe/trunk/test/CodeGen/ms-inline-asm-variables.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm-variables.c?rev=314301&view=auto
==
--- cfe/trunk/test/CodeGen/ms-inline-asm-variables.c (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm-variables.c (removed)
@@ -1,35 +0,0 @@
-// REQUIRES: x86-registered-target
-// RUN: %clang_cc1 %s -fasm-blocks -triple i386-apple-darwin10 -emit-llvm -o - 
| FileCheck %s
-
-int gVar;
-void t1() {
-  // CHECK: add eax, dword ptr gVar[eax]
-  __asm add eax, dword ptr gVar[eax]
-  // CHECK: add dword ptr gVar[eax], eax
-  __asm add dword ptr [eax+gVar], eax
-  // CHECK: add ebx, dword ptr gVar[ebx + $$270]
-  __asm add ebx, dword ptr gVar[271 - 82 + 81 + ebx]
-  // CHECK: add dword ptr gVar[ebx + $$828], ebx
-  __asm add dword ptr [ebx + gVar + 828], ebx
-  // CHECK: add ecx, dword ptr gVar[ecx + ecx * $$4 + $$4590]
-  __asm add ecx, dword ptr gVar[4590 + ecx + ecx*4]
-  // CHECK: add dword ptr gVar[ecx + ecx * $$8 + $$73], ecx
-  __asm add dword ptr [gVar + ecx + 45 + 23 - 53 + 60 - 2 + ecx*8], ecx
-  // CHECK: add gVar[ecx + ebx + $$7], eax
-  __asm add 1 + 1 + 2 + 3[gVar + ecx + ebx], eax
-}
-
-void t2() {
-  int lVar;
-  // CHECK: mov eax, dword ptr ${{[0-9]}}[eax]
-  __asm mov eax, dword ptr lVar[eax]
-  // CHECK: mov dword ptr ${{[0-9]}}[eax], eax
-  __asm mov dword ptr [eax+lVar], eax
-  // CHECK: mov ebx, dword ptr ${{[0-9]}}[ebx + $$270]
-  __asm mov ebx, dword ptr lVar[271 - 82 + 81 + ebx]
-  // CHECK: mov dword ptr ${{[0-9]}}[ebx + $$828], ebx
-  __asm mov dword ptr [ebx + lVar + 828], ebx
-  // CHECK: mov ${{[0-9]}}[ebx + $$47], eax
-  __asm mov 5 + 8 + 13 + 21[lVar + ebx], eax
-}
-


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


[PATCH] D38290: Add a ld64.lld alias for the MACHO LLD target

2017-09-27 Thread Martell Malone via Phabricator via cfe-commits
martell updated this revision to Diff 116801.
martell added a comment.

address comment


Repository:
  rL LLVM

https://reviews.llvm.org/D38290

Files:
  tools/clang/lib/Driver/ToolChain.cpp
  tools/lld/tools/lld/CMakeLists.txt
  tools/lld/tools/lld/lld.cpp


Index: tools/lld/tools/lld/lld.cpp
===
--- tools/lld/tools/lld/lld.cpp
+++ tools/lld/tools/lld/lld.cpp
@@ -45,7 +45,7 @@
   return StringSwitch(S)
   .CasesLower("ld", "ld.lld", "gnu", Gnu)
   .CaseLower("link", WinLink)
-  .CaseLower("darwin", Darwin)
+  .CasesLower("ld64", "ld64.lld", "darwin", Darwin)
   .Default(Invalid);
 }
 
Index: tools/lld/tools/lld/CMakeLists.txt
===
--- tools/lld/tools/lld/CMakeLists.txt
+++ tools/lld/tools/lld/CMakeLists.txt
@@ -17,7 +17,7 @@
   RUNTIME DESTINATION bin)
 
 if(NOT LLD_SYMLINKS_TO_CREATE)
-  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld)
+  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld ld64.lld)
 endif()
 
 foreach(link ${LLD_SYMLINKS_TO_CREATE})
Index: tools/clang/lib/Driver/ToolChain.cpp
===
--- tools/clang/lib/Driver/ToolChain.cpp
+++ tools/clang/lib/Driver/ToolChain.cpp
@@ -390,7 +390,11 @@
 // then use whatever the default system linker is.
 return GetProgramPath(getDefaultLinker());
   } else {
-llvm::SmallString<8> LinkerName("ld.");
+llvm::SmallString<8> LinkerName;
+if (Triple.isOSDarwin())
+  LinkerName.append("ld64.");
+else
+  LinkerName.append("ld.");
 LinkerName.append(UseLinker);
 
 std::string LinkerPath(GetProgramPath(LinkerName.c_str()));


Index: tools/lld/tools/lld/lld.cpp
===
--- tools/lld/tools/lld/lld.cpp
+++ tools/lld/tools/lld/lld.cpp
@@ -45,7 +45,7 @@
   return StringSwitch(S)
   .CasesLower("ld", "ld.lld", "gnu", Gnu)
   .CaseLower("link", WinLink)
-  .CaseLower("darwin", Darwin)
+  .CasesLower("ld64", "ld64.lld", "darwin", Darwin)
   .Default(Invalid);
 }
 
Index: tools/lld/tools/lld/CMakeLists.txt
===
--- tools/lld/tools/lld/CMakeLists.txt
+++ tools/lld/tools/lld/CMakeLists.txt
@@ -17,7 +17,7 @@
   RUNTIME DESTINATION bin)
 
 if(NOT LLD_SYMLINKS_TO_CREATE)
-  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld)
+  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld ld64.lld)
 endif()
 
 foreach(link ${LLD_SYMLINKS_TO_CREATE})
Index: tools/clang/lib/Driver/ToolChain.cpp
===
--- tools/clang/lib/Driver/ToolChain.cpp
+++ tools/clang/lib/Driver/ToolChain.cpp
@@ -390,7 +390,11 @@
 // then use whatever the default system linker is.
 return GetProgramPath(getDefaultLinker());
   } else {
-llvm::SmallString<8> LinkerName("ld.");
+llvm::SmallString<8> LinkerName;
+if (Triple.isOSDarwin())
+  LinkerName.append("ld64.");
+else
+  LinkerName.append("ld.");
 LinkerName.append(UseLinker);
 
 std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37861: preserving #pragma clang assume_nonnull in preprocessed output

2017-09-27 Thread Zbigniew Sarbinowski via Phabricator via cfe-commits
zibi added a comment.

Eli, if you have trouble committing this please let me know. Not sure what is 
happening.


https://reviews.llvm.org/D37861



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


[PATCH] D37023: [analyzer] Fix bugreporter::getDerefExpr() again.

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

Thank you, Artem!


Repository:
  rL LLVM

https://reviews.llvm.org/D37023



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


[PATCH] D38179: [clang-tidy] Handle unions in modernize-use-equals-default check

2017-09-27 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/modernize/UseEqualsDefaultCheck.cpp:119-120
+
+  // A defaulted default constructor of a union with a field with a non trivial
+  // default constructor would be deleted.
+  if (Record->isUnion()) {

malcolm.parsons wrote:
> aaron.ballman wrote:
> > This does not match what's in [class.ctor]p5.
> > 
> > "X is a union that has a variant member with a non-trivial default 
> > constructor and no variant member of X has a default member initializer" -- 
> > you aren't checking for the default member initializer.
> > 
> > also missing for unions: "X is a union and all of its variant members are 
> > of const-qualified type (or array thereof)"
> > 
> > (You should add test cases for these.)
> > 
> > It might make more sense to implement this as 
> > `CXXRecordDecl::defaultedDestructorIsDeleted()`?
> Is there any way to call `Sema::ShouldDeleteSpecialMember()` from a 
> clang-tidy check?
By the time clang-tidy checks are invoked, Sema is already dead, and I don't 
think there's a reasonable way to use it.



Comment at: clang-tidy/modernize/UseEqualsDefaultCheck.cpp:127
+
+  if (const RecordType *RecordTy = T->getAs()) {
+CXXRecordDecl *FieldRec = cast(RecordTy->getDecl());

malcolm.parsons wrote:
> aaron.ballman wrote:
> > You can use `auto` here and below.
> This was copied from `CXXRecordDecl::addedMember()`.
Not all LLVM/Clang code is ideal. It makes sense to clean up issues once the 
code is changed and even more so when it's copied elsewhere.


https://reviews.llvm.org/D38179



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


[PATCH] D38113: OpenCL: Assume functions are convergent

2017-09-27 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D38113#878852, @hfinkel wrote:

> In https://reviews.llvm.org/D38113#877874, @Anastasia wrote:
>
> > The problem of adding this attribute conservatively for all functions is 
> > that it prevents some optimizations to happen. I agree to commit this as a 
> > temporary fix to guarantee correctness of generated code.
>
>
> This is one of those unfortunate things we had to do for correctness in CUDA, 
> and the situation seems the same here. When we're not doing separate 
> compilation (which I imagine we're also generally not doing for OpenCL 
> complication), I'm under the impression that the attribute removal is fairly 
> effective.


I agree both communities would benefit so it feels like it might be worth the 
effort.

> 
> 
>> But if we ask to add the `convergent` attribute into the spec we can avoid 
>> doing this in the compiler?
> 
> But even if you do that, would that not be in a future version of OpenCL? If 
> so, for code complying to current standards, you'd need this behavior.

Yes, the fix is needed anyway to provide backwards compatibility.


https://reviews.llvm.org/D38113



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


[PATCH] D30946: [ScopePrinting] Added support to print full scopes of types and declarations.

2017-09-27 Thread Simon Schroeder via Phabricator via cfe-commits
schroedersi added a comment.

Ping :)


https://reviews.llvm.org/D30946



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


[PATCH] D37804: [OpenCL] Handle address space conversion while setting type alignment

2017-09-27 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314304: [OpenCL] Handle address space conversion while 
setting type alignment. (authored by stulova).

Changed prior to commit:
  https://reviews.llvm.org/D37804?vs=116548&id=116809#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37804

Files:
  cfe/trunk/lib/CodeGen/CGBuilder.h
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/test/CodeGenOpenCL/vectorLoadStore.cl


Index: cfe/trunk/lib/CodeGen/CGBuilder.h
===
--- cfe/trunk/lib/CodeGen/CGBuilder.h
+++ cfe/trunk/lib/CodeGen/CGBuilder.h
@@ -145,6 +145,13 @@
Addr.getAlignment());
   }
 
+  using CGBuilderBaseTy::CreateAddrSpaceCast;
+  Address CreateAddrSpaceCast(Address Addr, llvm::Type *Ty,
+  const llvm::Twine &Name = "") {
+return Address(CreateAddrSpaceCast(Addr.getPointer(), Ty, Name),
+   Addr.getAlignment());
+  }
+
   /// Cast the element type of the given address to a different type,
   /// preserving information like the alignment and address space.
   Address CreateElementBitCast(Address Addr, llvm::Type *Ty,
Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -925,6 +925,7 @@
 // Non-converting casts (but not C's implicit conversion from void*).
 case CK_BitCast:
 case CK_NoOp:
+case CK_AddressSpaceConversion:
   if (auto PtrTy = CE->getSubExpr()->getType()->getAs()) {
 if (PtrTy->getPointeeType()->isVoidType())
   break;
@@ -953,8 +954,10 @@
   CodeGenFunction::CFITCK_UnrelatedCast,
   CE->getLocStart());
 }
-
-return Builder.CreateBitCast(Addr, ConvertType(E->getType()));
+return CE->getCastKind() != CK_AddressSpaceConversion
+   ? Builder.CreateBitCast(Addr, ConvertType(E->getType()))
+   : Builder.CreateAddrSpaceCast(Addr,
+ ConvertType(E->getType()));
   }
   break;
 
Index: cfe/trunk/test/CodeGenOpenCL/vectorLoadStore.cl
===
--- cfe/trunk/test/CodeGenOpenCL/vectorLoadStore.cl
+++ cfe/trunk/test/CodeGenOpenCL/vectorLoadStore.cl
@@ -1,9 +1,22 @@
-// RUN: %clang_cc1 %s -emit-llvm -O0 -o - | FileCheck %s
+// RUN: %clang_cc1 -triple "spir-unknown-unknown" %s -emit-llvm -O0 -o - | 
FileCheck %s
 
-typedef char char3 __attribute((ext_vector_type(3)));;
+typedef char char2 __attribute((ext_vector_type(2)));
+typedef char char3 __attribute((ext_vector_type(3)));
+typedef char char8 __attribute((ext_vector_type(8)));
+typedef float float4 __attribute((ext_vector_type(4)));
 
 // Check for optimized vec3 load/store which treats vec3 as vec4.
 void foo(char3 *P, char3 *Q) {
   *P = *Q;
   // CHECK: %{{.*}} = shufflevector <4 x i8> %{{.*}}, <4 x i8> undef, <3 x 
i32> 
 }
+
+// CHECK: define spir_func void @alignment()
+void alignment() {
+  __private char2 data_generic[100];
+  __private char8 data_private[100];
+
+  // CHECK: %{{.*}} = load <4 x float>, <4 x float> addrspace(4)* %{{.*}}, 
align 2
+  // CHECK: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 8
+  ((private float4 *)data_private)[1] = ((float4 *)data_generic)[2];
+}


Index: cfe/trunk/lib/CodeGen/CGBuilder.h
===
--- cfe/trunk/lib/CodeGen/CGBuilder.h
+++ cfe/trunk/lib/CodeGen/CGBuilder.h
@@ -145,6 +145,13 @@
Addr.getAlignment());
   }
 
+  using CGBuilderBaseTy::CreateAddrSpaceCast;
+  Address CreateAddrSpaceCast(Address Addr, llvm::Type *Ty,
+  const llvm::Twine &Name = "") {
+return Address(CreateAddrSpaceCast(Addr.getPointer(), Ty, Name),
+   Addr.getAlignment());
+  }
+
   /// Cast the element type of the given address to a different type,
   /// preserving information like the alignment and address space.
   Address CreateElementBitCast(Address Addr, llvm::Type *Ty,
Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -925,6 +925,7 @@
 // Non-converting casts (but not C's implicit conversion from void*).
 case CK_BitCast:
 case CK_NoOp:
+case CK_AddressSpaceConversion:
   if (auto PtrTy = CE->getSubExpr()->getType()->getAs()) {
 if (PtrTy->getPointeeType()->isVoidType())
   break;
@@ -953,8 +954,10 @@
   CodeGenFunction::CFITCK_UnrelatedCast,
   CE->getLocStart());
 }
-
-return Builder.CreateBitCast(Addr, ConvertType(E->getType()));
+return CE->getCastKin

r314304 - [OpenCL] Handle address space conversion while setting type alignment.

2017-09-27 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Wed Sep 27 07:37:00 2017
New Revision: 314304

URL: http://llvm.org/viewvc/llvm-project?rev=314304&view=rev
Log:
[OpenCL] Handle address space conversion while setting type alignment.

Added missing addrspacecast case in alignment computation
logic of pointer type emission in IR generation.

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


Modified:
cfe/trunk/lib/CodeGen/CGBuilder.h
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/test/CodeGenOpenCL/vectorLoadStore.cl

Modified: cfe/trunk/lib/CodeGen/CGBuilder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuilder.h?rev=314304&r1=314303&r2=314304&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuilder.h (original)
+++ cfe/trunk/lib/CodeGen/CGBuilder.h Wed Sep 27 07:37:00 2017
@@ -145,6 +145,13 @@ public:
Addr.getAlignment());
   }
 
+  using CGBuilderBaseTy::CreateAddrSpaceCast;
+  Address CreateAddrSpaceCast(Address Addr, llvm::Type *Ty,
+  const llvm::Twine &Name = "") {
+return Address(CreateAddrSpaceCast(Addr.getPointer(), Ty, Name),
+   Addr.getAlignment());
+  }
+
   /// Cast the element type of the given address to a different type,
   /// preserving information like the alignment and address space.
   Address CreateElementBitCast(Address Addr, llvm::Type *Ty,

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=314304&r1=314303&r2=314304&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Wed Sep 27 07:37:00 2017
@@ -925,6 +925,7 @@ Address CodeGenFunction::EmitPointerWith
 // Non-converting casts (but not C's implicit conversion from void*).
 case CK_BitCast:
 case CK_NoOp:
+case CK_AddressSpaceConversion:
   if (auto PtrTy = CE->getSubExpr()->getType()->getAs()) {
 if (PtrTy->getPointeeType()->isVoidType())
   break;
@@ -953,8 +954,10 @@ Address CodeGenFunction::EmitPointerWith
   CodeGenFunction::CFITCK_UnrelatedCast,
   CE->getLocStart());
 }
-
-return Builder.CreateBitCast(Addr, ConvertType(E->getType()));
+return CE->getCastKind() != CK_AddressSpaceConversion
+   ? Builder.CreateBitCast(Addr, ConvertType(E->getType()))
+   : Builder.CreateAddrSpaceCast(Addr,
+ ConvertType(E->getType()));
   }
   break;
 

Modified: cfe/trunk/test/CodeGenOpenCL/vectorLoadStore.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/vectorLoadStore.cl?rev=314304&r1=314303&r2=314304&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/vectorLoadStore.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/vectorLoadStore.cl Wed Sep 27 07:37:00 2017
@@ -1,9 +1,22 @@
-// RUN: %clang_cc1 %s -emit-llvm -O0 -o - | FileCheck %s
+// RUN: %clang_cc1 -triple "spir-unknown-unknown" %s -emit-llvm -O0 -o - | 
FileCheck %s
 
-typedef char char3 __attribute((ext_vector_type(3)));;
+typedef char char2 __attribute((ext_vector_type(2)));
+typedef char char3 __attribute((ext_vector_type(3)));
+typedef char char8 __attribute((ext_vector_type(8)));
+typedef float float4 __attribute((ext_vector_type(4)));
 
 // Check for optimized vec3 load/store which treats vec3 as vec4.
 void foo(char3 *P, char3 *Q) {
   *P = *Q;
   // CHECK: %{{.*}} = shufflevector <4 x i8> %{{.*}}, <4 x i8> undef, <3 x 
i32> 
 }
+
+// CHECK: define spir_func void @alignment()
+void alignment() {
+  __private char2 data_generic[100];
+  __private char8 data_private[100];
+
+  // CHECK: %{{.*}} = load <4 x float>, <4 x float> addrspace(4)* %{{.*}}, 
align 2
+  // CHECK: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 8
+  ((private float4 *)data_private)[1] = ((float4 *)data_generic)[2];
+}


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


[PATCH] D38257: [OpenMP] Fix memory leak when translating arguments

2017-09-27 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea accepted this revision.
gtbercea added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D38257



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


[PATCH] D38258: [OpenMP] Fix passing of -m arguments to device toolchain

2017-09-27 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added inline comments.



Comment at: test/Driver/openmp-offload.c:89
+/// ###
+
 /// Check the phases graph when using a single target, different from the host.

Shouldn't these tests be in the gpu test file?


https://reviews.llvm.org/D38258



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


[PATCH] D38259: [OpenMP] Fix translation of target args

2017-09-27 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea accepted this revision.
gtbercea added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D38259



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


[PATCH] D38258: [OpenMP] Fix passing of -m arguments to device toolchain

2017-09-27 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: test/Driver/openmp-offload.c:89
+/// ###
+
 /// Check the phases graph when using a single target, different from the host.

gtbercea wrote:
> Shouldn't these tests be in the gpu test file?
There is nothing specific to GPUs here IMO, that is why I moved the test back 
to this file


https://reviews.llvm.org/D38258



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


[PATCH] D38258: [OpenMP] Fix passing of -m arguments to device toolchain

2017-09-27 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea accepted this revision.
gtbercea added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: test/Driver/openmp-offload.c:89
+/// ###
+
 /// Check the phases graph when using a single target, different from the host.

Hahnfeld wrote:
> gtbercea wrote:
> > Shouldn't these tests be in the gpu test file?
> There is nothing specific to GPUs here IMO, that is why I moved the test back 
> to this file
Actually no, you're right! :)


https://reviews.llvm.org/D38258



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


[PATCH] D38113: OpenCL: Assume functions are convergent

2017-09-27 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D38113#878840, @jlebar wrote:

> > Yes, that's why if it would be responsibility of the kernel developer to 
> > specify this explicitly we could avoid this complications in the compiler. 
> > But if we add it into the language now we still need to support the 
> > correctness for the code written with the earlier standards. And also it 
> > adds the complexity to the programmer to make sure it's specified 
> > correctly. But I think it is still worth discussing with the spec committee.
>
> To me this seems like a small complication in the compiler to avoid an 
> extremely easy bug for users to write.  But, not my language.  :)


Yes, I think I would perhaps argue for inclusion of non-convergent instead 
since this option seems to make more sense.

> 
> 
>> The deduction of convergent is indeed tricky. So if there is any function in 
>> the CFG path which is marked as convergent ( or "non-convergent") this will 
>> have to be back propagated to the callers unless we force to explicitly 
>> specify it but it would be too error prone for the kernel writers I guess.
> 
> This probably isn't the right forum to discuss proposals to change the LLVM 
> IR spec.  But if you want to propose something like this, please cc me on the 
> thread, I probably have opinions.  :)

Will do! If we have bigger use case it would be easier to get accepted. I will 
check with the OpenCL community first and see if there is an agreement 
internally.

> 
> 
>> Btw, what is the advantage of having "non-convergent" instead and why is the 
>> deduction of convergent property more complicated with it?
> 
> The advantage of switching LLVM IR to non-convergent would be that front-ends 
> wouldn't have the bug that arsenm is fixing here.  "Unadorned" IR would be 
> correct.  And, in the absence of external or unanalyzable indirect calls, 
> you'd get the same performance as we get today even if you had no annotations.

Yes, I see this sounds more reasonable indeed. Btw, currently LLVM can remove 
`convergent` in some cases to recover the performance loss?

> The complexity I was referring to occurs if you add the non-convergent 
> attribute and keep the convergent attr.  I don't think we want that.

I think keeping both would add more confusions and hence result in even more 
errors/complications.

> But I'm not really proposing a change to the convergent attribute in LLVM IR 
> -- it's probably better to leave it as-is, since we all understand how it 
> works, it ain't broke.

But at the same time since we already know what we needed redesign should be 
easier. Alternative option would be to add convergent during IR generation as 
default option and no attribute where `non-convergent` is set. This way at 
least we give programmer a way to achieve higher performance. But of course it 
wouldn't be ideal to be inconsistent with the IR. Currently as I can see there 
is a little use of convergent in the frontend since we set it for all functions 
anyways. The problem is that it wouldn't be possible to remove it immediately. 
But we can at least deprecate it for a start.


https://reviews.llvm.org/D38113



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


[PATCH] D38113: OpenCL: Assume functions are convergent

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

In https://reviews.llvm.org/D38113#882187, @Anastasia wrote:

> In https://reviews.llvm.org/D38113#878840, @jlebar wrote:
>
> >
>


...

> Yes, I see this sounds more reasonable indeed. Btw, currently LLVM can remove 
> `convergent` in some cases to recover the performance loss?

Yes. See removeConvergentAttrs in lib/Transforms/IPO/FunctionAttrs.cpp.

...


https://reviews.llvm.org/D38113



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


[clang-tools-extra] r314309 - [clangd] Handle InitializeParams and store rootUri

2017-09-27 Thread Marc-Andre Laperle via cfe-commits
Author: malaperle
Date: Wed Sep 27 08:31:17 2017
New Revision: 314309

URL: http://llvm.org/viewvc/llvm-project?rev=314309&view=rev
Log:
[clangd] Handle InitializeParams and store rootUri

Summary:
The root Uri is the workspace location and will be useful in the context of
indexing. We could also add more things to InitializeParams in order to
configure Clangd for C/C++ sepecific extensions.

Reviewers: ilya-biryukov, bkramer, krasimir, Nebiroth

Reviewed By: ilya-biryukov

Subscribers: ilya-biryukov

Tags: #clang-tools-extra

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

Added:
clang-tools-extra/trunk/test/clangd/initialize-params-invalid.test
clang-tools-extra/trunk/test/clangd/initialize-params.test
Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
clang-tools-extra/trunk/clangd/ProtocolHandlers.h

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=314309&r1=314308&r2=314309&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Sep 27 08:31:17 2017
@@ -51,7 +51,8 @@ class ClangdLSPServer::LSPProtocolCallba
 public:
   LSPProtocolCallbacks(ClangdLSPServer &LangServer) : LangServer(LangServer) {}
 
-  void onInitialize(StringRef ID, JSONOutput &Out) override;
+  void onInitialize(StringRef ID, InitializeParams IP,
+JSONOutput &Out) override;
   void onShutdown(JSONOutput &Out) override;
   void onDocumentDidOpen(DidOpenTextDocumentParams Params,
  JSONOutput &Out) override;
@@ -77,6 +78,7 @@ private:
 };
 
 void ClangdLSPServer::LSPProtocolCallbacks::onInitialize(StringRef ID,
+ InitializeParams IP,
  JSONOutput &Out) {
   Out.writeMessage(
   R"({"jsonrpc":"2.0","id":)" + ID +
@@ -89,6 +91,10 @@ void ClangdLSPServer::LSPProtocolCallbac
   "completionProvider": {"resolveProvider": false, 
"triggerCharacters": [".",">",":"]},
   "definitionProvider": true
 }}})");
+  if (IP.rootUri && !IP.rootUri->file.empty())
+LangServer.Server.setRootPath(IP.rootUri->file);
+  else if (IP.rootPath && !IP.rootPath->empty())
+LangServer.Server.setRootPath(*IP.rootPath);
 }
 
 void ClangdLSPServer::LSPProtocolCallbacks::onShutdown(JSONOutput &Out) {

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=314309&r1=314308&r2=314309&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Sep 27 08:31:17 2017
@@ -15,6 +15,7 @@
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
@@ -154,12 +155,19 @@ ClangdServer::ClangdServer(GlobalCompila
   SnippetCompletions(SnippetCompletions), WorkScheduler(AsyncThreadsCount) 
{
 }
 
+void ClangdServer::setRootPath(PathRef RootPath) {
+  std::string NewRootPath = llvm::sys::path::convert_to_slash(
+  RootPath, llvm::sys::path::Style::posix);
+  if (llvm::sys::fs::is_directory(NewRootPath))
+this->RootPath = NewRootPath;
+}
+
 std::future ClangdServer::addDocument(PathRef File, StringRef Contents) {
   DocVersion Version = DraftMgr.updateDraft(File, Contents);
 
   auto TaggedFS = FSProvider.getTaggedFileSystem(File);
-  std::shared_ptr Resources =
-  Units.getOrCreateFile(File, ResourceDir, CDB, PCHs, TaggedFS.Value, 
Logger);
+  std::shared_ptr Resources = Units.getOrCreateFile(
+  File, ResourceDir, CDB, PCHs, TaggedFS.Value, Logger);
   return scheduleReparseAndDiags(File, VersionedDraft{Version, Contents.str()},
  std::move(Resources), std::move(TaggedFS));
 }

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=314309&r1=314308&r2=314309&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Wed Sep 27 08:31:17 2017
@@ -211,6 +211,9 @@ public:
bool SnippetCompletions, clangd::Logger &Logger,
llvm::Optional ResourceDir = llvm::None);
 
+  /

[PATCH] D37826: Refine generation of TBAA information in clang

2017-09-27 Thread Ivan A. Kosarev via Phabricator via cfe-commits
kosarev added a comment.

Colleagues, please let me know if I can do anything else to help with reviewing 
the patch. Thanks.


https://reviews.llvm.org/D37826



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


[PATCH] D37804: [OpenCL] Handle address space conversion while setting type alignment

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

vectorLoadStore.cl is failing on our bots: 
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/8187, 
please check it out


Repository:
  rL LLVM

https://reviews.llvm.org/D37804



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


[PATCH] D37554: [libclang] Allow crash recovery with LIBCLANG_NOTHREADS

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

I think your change makes sense, but maybe asking for a better description.

It appears you:

- Enabled crash recovery for some libclang operations on a calling thread even 
when `LIBCLANG_NOTHREAD` is specified.  Previously it would only run under 
crash recovery if `LIBCLANG_NOTHREAD` is not set.
- Moved handling of `LIBCLANG_NOTHREAD` env variable into `RunSafely` from its 
call sites.

That said, I am not familiar with the code you're changing, so can't really 
LGTM this. Hopefully, someone else can do that.


https://reviews.llvm.org/D37554



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


Re: [PATCH] D37826: Refine generation of TBAA information in clang

2017-09-27 Thread Daniel Berlin via cfe-commits
(As i mentioned to hal offline, i'm too slammed to help here)

On Wed, Sep 27, 2017 at 8:47 AM, Ivan A. Kosarev via Phabricator <
revi...@reviews.llvm.org> wrote:

> kosarev added a comment.
>
> Colleagues, please let me know if I can do anything else to help with
> reviewing the patch. Thanks.
>
>
> https://reviews.llvm.org/D37826
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-09-27 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/Sema/SemaType.cpp:6808
 
+static void deduceOpenCLImplicitAddrSpace(TypeProcessingState &State,
+  QualType &T, TypeAttrLocation TAL) {

Great! This looks so clear now!



Comment at: lib/Sema/SemaType.cpp:6810
+  QualType &T, TypeAttrLocation TAL) {
+  if (!State.getSema().getLangOpts().OpenCL ||
+  T.getAddressSpace() != LangAS::Default)

I think this could be checked before calling the function.



Comment at: lib/Sema/SemaType.cpp:6863
+  unsigned ImpAddr;
+  bool IsStatic = D.getDeclSpec().getStorageClassSpec() == 
DeclSpec::SCS_static;
+  // Put OpenCL automatic variable in private address space.

Do we cover `extern` too?



Comment at: lib/Sema/SemaType.cpp:6872
+  ImpAddr = LangAS::opencl_private;
+else if (IsStatic)
+  ImpAddr = LangAS::opencl_global;

I think we can't have this case for CL1.2 see s6.8. But I think it could happen 
for `extern` though.


https://reviews.llvm.org/D35082



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


[PATCH] D37804: [OpenCL] Handle address space conversion while setting type alignment

2017-09-27 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

Committed in r314304

In https://reviews.llvm.org/D37804#882252, @alekseyshl wrote:

> vectorLoadStore.cl is failing on our bots: 
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/8187, 
> please check it out


I will commit a fix in a bit.


Repository:
  rL LLVM

https://reviews.llvm.org/D37804



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


r314317 - [OpenCL] Fixed CL version in failing test.

2017-09-27 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Wed Sep 27 10:03:35 2017
New Revision: 314317

URL: http://llvm.org/viewvc/llvm-project?rev=314317&view=rev
Log:
[OpenCL] Fixed CL version in failing test.


Modified:
cfe/trunk/test/CodeGenOpenCL/vectorLoadStore.cl

Modified: cfe/trunk/test/CodeGenOpenCL/vectorLoadStore.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/vectorLoadStore.cl?rev=314317&r1=314316&r2=314317&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/vectorLoadStore.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/vectorLoadStore.cl Wed Sep 27 10:03:35 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple "spir-unknown-unknown" %s -emit-llvm -O0 -o - | 
FileCheck %s
+// RUN: %clang_cc1 -cl-std=CL2.0 -triple "spir-unknown-unknown" %s -emit-llvm 
-O0 -o - | FileCheck %s
 
 typedef char char2 __attribute((ext_vector_type(2)));
 typedef char char3 __attribute((ext_vector_type(3)));


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


[PATCH] D37804: [OpenCL] Handle address space conversion while setting type alignment

2017-09-27 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

Committed in r314317.


Repository:
  rL LLVM

https://reviews.llvm.org/D37804



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


[PATCH] D38208: Add support for remembering origins to ExternalASTMerger

2017-09-27 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D38208



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


[PATCH] D38209: [Sema] Correct nothrow inherited by noexcept

2017-09-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 116840.
erichkeane marked 2 inline comments as done.
erichkeane added a comment.

2 small changes @aaron.ballman requested.


https://reviews.llvm.org/D38209

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/SemaCXX/nothrow-as-noexcept-ctor.cpp


Index: test/SemaCXX/nothrow-as-noexcept-ctor.cpp
===
--- /dev/null
+++ test/SemaCXX/nothrow-as-noexcept-ctor.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify 
-std=c++14
+
+// expected-no-diagnostics
+struct Base {
+  __attribute__((nothrow)) Base() {}
+};
+
+struct Derived : Base {
+  Derived() noexcept = default;
+};
+
+struct Base2 {
+   Base2() noexcept {}
+};
+
+struct Derived2 : Base2 {
+  __attribute__((nothrow)) Derived2() = default;
+};
+
+struct Base3 {
+  __attribute__((nothrow)) Base3() {}
+};
+
+struct Derived3 : Base3 {
+  __attribute__((nothrow)) Derived3() = default;
+};
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -167,6 +167,9 @@
   if (ComputedEST == EST_None)
 return;
 
+  if (EST == EST_None && Method->hasAttr())
+EST = EST_BasicNoexcept;
+
   switch(EST) {
   // If this function can throw any exceptions, make a note of that.
   case EST_MSAny:


Index: test/SemaCXX/nothrow-as-noexcept-ctor.cpp
===
--- /dev/null
+++ test/SemaCXX/nothrow-as-noexcept-ctor.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify -std=c++14
+
+// expected-no-diagnostics
+struct Base {
+  __attribute__((nothrow)) Base() {}
+};
+
+struct Derived : Base {
+  Derived() noexcept = default;
+};
+
+struct Base2 {
+   Base2() noexcept {}
+};
+
+struct Derived2 : Base2 {
+  __attribute__((nothrow)) Derived2() = default;
+};
+
+struct Base3 {
+  __attribute__((nothrow)) Base3() {}
+};
+
+struct Derived3 : Base3 {
+  __attribute__((nothrow)) Derived3() = default;
+};
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -167,6 +167,9 @@
   if (ComputedEST == EST_None)
 return;
 
+  if (EST == EST_None && Method->hasAttr())
+EST = EST_BasicNoexcept;
+
   switch(EST) {
   // If this function can throw any exceptions, make a note of that.
   case EST_MSAny:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r314325 - clang-format/java: Unbreak genenrics formatting after r299952.

2017-09-27 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Sep 27 10:57:50 2017
New Revision: 314325

URL: http://llvm.org/viewvc/llvm-project?rev=314325&view=rev
Log:
clang-format/java: Unbreak genenrics formatting after r299952.

https://reviews.llvm.org/rL299952 merged '>>>' tokens into a single
JavaRightLogicalShift token. This broke formatting of generics nested more than
two deep, e.g. Foo>> because the '>>>' now weren't three '>' for
parseAngle().

Luckily, just deleting JavaRightLogicalShift fixes things without breaking the
test added in r299952, so do that.

https://reviews.llvm.org/D38291

Modified:
cfe/trunk/lib/Format/FormatTokenLexer.cpp
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJava.cpp

Modified: cfe/trunk/lib/Format/FormatTokenLexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatTokenLexer.cpp?rev=314325&r1=314324&r2=314325&view=diff
==
--- cfe/trunk/lib/Format/FormatTokenLexer.cpp (original)
+++ cfe/trunk/lib/Format/FormatTokenLexer.cpp Wed Sep 27 10:57:50 2017
@@ -96,12 +96,8 @@ void FormatTokenLexer::tryMergePreviousT
   }
 
   if (Style.Language == FormatStyle::LK_Java) {
-static const tok::TokenKind JavaRightLogicalShift[] = {
-tok::greater, tok::greater, tok::greater};
 static const tok::TokenKind JavaRightLogicalShiftAssign[] = {
 tok::greater, tok::greater, tok::greaterequal};
-if (tryMergeTokens(JavaRightLogicalShift, TT_BinaryOperator))
-  return;
 if (tryMergeTokens(JavaRightLogicalShiftAssign, TT_BinaryOperator))
   return;
   }

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=314325&r1=314324&r2=314325&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Sep 27 10:57:50 2017
@@ -47,7 +47,7 @@ private:
 if (NonTemplateLess.count(CurrentToken->Previous))
   return false;
 
-const FormatToken &Previous = *CurrentToken->Previous;
+const FormatToken &Previous = *CurrentToken->Previous;  // The '<'.
 if (Previous.Previous) {
   if (Previous.Previous->Tok.isLiteral())
 return false;
@@ -2323,7 +2323,7 @@ bool TokenAnnotator::spaceRequiredBetwee
   if (Left.is(TT_TemplateCloser) && Left.MatchingParen &&
   Left.MatchingParen->Previous &&
   Left.MatchingParen->Previous->is(tok::period))
-// A.DoSomething();
+// A.>>DoSomething();
 return false;
   if (Left.is(TT_TemplateCloser) && Right.is(tok::l_square))
 return false;

Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=314325&r1=314324&r2=314325&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp Wed Sep 27 10:57:50 2017
@@ -333,6 +333,11 @@ TEST_F(FormatTestJava, Generics) {
   verifyFormat("Iterable a;");
 
   verifyFormat("A.doSomething();");
+  verifyFormat("A.>doSomething();");
+  verifyFormat("A.>>doSomething();");
+  verifyFormat("A.>>>doSomething();");
+
+  verifyFormat("OrderedPair>> p = null;");
 
   verifyFormat("@Override\n"
"public Map getAll() {}");


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


[PATCH] D38291: clang-format/java: Unbreak genenrics formatting after r299952.

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

r314325, thanks!


https://reviews.llvm.org/D38291



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


[PATCH] D14358: DWARF's forward decl of a template should have template parameters.

2017-09-27 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

In https://reviews.llvm.org/D14358#881666, @aprantl wrote:

> Does this have to be exposed through the driver or could this be a cc1 option 
> only?


My thinking was to make it easier for LLDB to play with it and decide whether 
DWARF conformance on this point is a good thing for them also.  But I admit 
it's not something an end user would really care about or want to change.  I 
can make it a cc1 option.




Comment at: include/clang/Basic/LangOptions.def:144
 BENIGN_LANGOPT(EmitAllDecls  , 1, 0, "emitting all declarations")
+BENIGN_LANGOPT(EmitFwdTemplateChildren, 1, 0, "emit template parameter 
children in forward declarations")
 LANGOPT(MathErrno , 1, 1, "errno in math functions")

aprantl wrote:
> Why is this a LangOpt instead of a CodeGenOpt?
> Should it reference `debug` somewhere in the name?
Because I thought EmitAllDecls was for debug info, and this felt related.  But 
I see EmitAllDecls is not used in CGDebugInfo and generally we do put 
debug-related options in CodeGenOpt so I will move that.  (Someday we should 
collect all that stuff into a DebugOpt class.)
And I will rename it to DebugFwdTemplateChildren.


https://reviews.llvm.org/D14358



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


r314329 - [OpenMP] Fix passing of -m arguments to device toolchain

2017-09-27 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Wed Sep 27 11:12:34 2017
New Revision: 314329

URL: http://llvm.org/viewvc/llvm-project?rev=314329&view=rev
Log:
[OpenMP] Fix passing of -m arguments to device toolchain

AuxTriple is not set if host and device share a toolchain. Also,
removing an argument modifies the DAL which needs to be returned
for future use.
(Move tests back to offload-openmp.c as they are not related to GPUs.)

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

Modified:
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/test/Driver/openmp-offload-gpu.c
cfe/trunk/test/Driver/openmp-offload.c

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=314329&r1=314328&r2=314329&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Wed Sep 27 11:12:34 2017
@@ -807,16 +807,19 @@ llvm::opt::DerivedArgList *ToolChain::Tr
   if (DeviceOffloadKind == Action::OFK_OpenMP) {
 DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
 const OptTable &Opts = getDriver().getOpts();
-bool NewArgAdded = false;
+bool Modified = false;
 
 // Handle -Xopenmp-target flags
 for (Arg *A : Args) {
   // Exclude flags which may only apply to the host toolchain.
-  // Do not exclude flags when the host triple (AuxTriple),
-  // matches the current toolchain triple.
+  // Do not exclude flags when the host triple (AuxTriple)
+  // matches the current toolchain triple. If it is not present
+  // at all, target and host share a toolchain.
   if (A->getOption().matches(options::OPT_m_Group)) {
-if (getAuxTriple() && getAuxTriple()->str() == getTriple().str())
+if (!getAuxTriple() || getAuxTriple()->str() == getTriple().str())
   DAL->append(A);
+else
+  Modified = true;
 continue;
   }
 
@@ -857,10 +860,10 @@ llvm::opt::DerivedArgList *ToolChain::Tr
   A = XOpenMPTargetArg.release();
   AllocatedArgs.push_back(A);
   DAL->append(A);
-  NewArgAdded = true;
+  Modified = true;
 }
 
-if (NewArgAdded) {
+if (Modified) {
   return DAL;
 } else {
   delete DAL;

Modified: cfe/trunk/test/Driver/openmp-offload-gpu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openmp-offload-gpu.c?rev=314329&r1=314328&r2=314329&view=diff
==
--- cfe/trunk/test/Driver/openmp-offload-gpu.c (original)
+++ cfe/trunk/test/Driver/openmp-offload-gpu.c Wed Sep 27 11:12:34 2017
@@ -9,38 +9,6 @@
 
 /// ###
 
-/// Check -Xopenmp-target=powerpc64le-ibm-linux-gnu -march=pwr7 is passed when 
compiling for the device.
-// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu 
-Xopenmp-target=powerpc64le-ibm-linux-gnu -mcpu=pwr7 %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-EQ-TARGET %s
-
-// CHK-FOPENMP-EQ-TARGET: clang{{.*}} "-target-cpu" "pwr7"
-
-/// ###
-
-/// Check -Xopenmp-target -march=pwr7 is passed when compiling for the device.
-// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target -mcpu=pwr7 %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET %s
-
-// CHK-FOPENMP-TARGET: clang{{.*}} "-target-cpu" "pwr7"
-
-/// ###
-
-/// Check -Xopenmp-target triggers error when multiple triples are used.
-// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-unknown-linux-gnu 
-Xopenmp-target -mcpu=pwr8 %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET-AMBIGUOUS-ERROR %s
-
-// CHK-FOPENMP-TARGET-AMBIGUOUS-ERROR: clang{{.*}} error: cannot deduce 
implicit triple value for -Xopenmp-target, specify triple using 
-Xopenmp-target=
-
-/// ###
-
-/// Check -Xopenmp-target triggers error when an option requiring arguments is 
passed to it.
-// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target -Xopenmp-target 
-mcpu=pwr8 %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET-NESTED-ERROR %s
-
-// CHK-FOPENMP-TARGET-NESTED-ERROR: clang{{.*}} error: invalid -Xopenmp-target 
argument: '-Xopenmp-target -Xopenmp-target', options requiring arguments are 
unsupported
-
-/// ###
-
 /// Check -Xopenmp-target uses one of the archs provided when several archs 
are used.
 // RUN:   %clang -### -no-canonical-prefixe

r314328 - [OpenMP] Fix memory leak when translating arguments

2017-09-27 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Wed Sep 27 11:12:31 2017
New Revision: 314328

URL: http://llvm.org/viewvc/llvm-project?rev=314328&view=rev
Log:
[OpenMP] Fix memory leak when translating arguments

Parsing the argument after -Xopenmp-target allocates memory that needs
to be freed. Associate it with the final DerivedArgList after we know
which one will be used.

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

Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/Compilation.cpp
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/test/Driver/openmp-offload-gpu.c

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=314328&r1=314327&r2=314328&view=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Wed Sep 27 11:12:31 2017
@@ -249,9 +249,10 @@ public:
   ///
   /// \param DeviceOffloadKind - The device offload kind used for the
   /// translation.
-  virtual llvm::opt::DerivedArgList *
-  TranslateOpenMPTargetArgs(const llvm::opt::DerivedArgList &Args,
-  Action::OffloadKind DeviceOffloadKind) const;
+  virtual llvm::opt::DerivedArgList *TranslateOpenMPTargetArgs(
+  const llvm::opt::DerivedArgList &Args,
+  Action::OffloadKind DeviceOffloadKind,
+  SmallVector &AllocatedArgs) const;
 
   /// Choose a tool to use to handle the action \p JA.
   ///

Modified: cfe/trunk/lib/Driver/Compilation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=314328&r1=314327&r2=314328&view=diff
==
--- cfe/trunk/lib/Driver/Compilation.cpp (original)
+++ cfe/trunk/lib/Driver/Compilation.cpp Wed Sep 27 11:12:31 2017
@@ -51,9 +51,10 @@ Compilation::getArgsForToolChain(const T
 
   DerivedArgList *&Entry = TCArgs[{TC, BoundArch, DeviceOffloadKind}];
   if (!Entry) {
+SmallVector AllocatedArgs;
 // Translate OpenMP toolchain arguments provided via the -Xopenmp-target 
flags.
-DerivedArgList *OpenMPArgs = TC->TranslateOpenMPTargetArgs(*TranslatedArgs,
-DeviceOffloadKind);
+DerivedArgList *OpenMPArgs = TC->TranslateOpenMPTargetArgs(
+*TranslatedArgs, DeviceOffloadKind, AllocatedArgs);
 if (!OpenMPArgs) {
   Entry = TC->TranslateArgs(*TranslatedArgs, BoundArch, DeviceOffloadKind);
 } else {
@@ -63,6 +64,11 @@ Compilation::getArgsForToolChain(const T
 
 if (!Entry)
   Entry = TranslatedArgs;
+
+// Add allocated arguments to the final DAL.
+for (auto ArgPtr : AllocatedArgs) {
+  Entry->AddSynthesizedArg(ArgPtr);
+}
   }
 
   return *Entry;

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=314328&r1=314327&r2=314328&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Wed Sep 27 11:12:31 2017
@@ -800,9 +800,10 @@ ToolChain::computeMSVCVersion(const Driv
   return VersionTuple();
 }
 
-llvm::opt::DerivedArgList *
-ToolChain::TranslateOpenMPTargetArgs(const llvm::opt::DerivedArgList &Args,
-Action::OffloadKind DeviceOffloadKind) const {
+llvm::opt::DerivedArgList *ToolChain::TranslateOpenMPTargetArgs(
+const llvm::opt::DerivedArgList &Args,
+Action::OffloadKind DeviceOffloadKind,
+SmallVector &AllocatedArgs) const {
   if (DeviceOffloadKind == Action::OFK_OpenMP) {
 DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
 const OptTable &Opts = getDriver().getOpts();
@@ -854,6 +855,7 @@ ToolChain::TranslateOpenMPTargetArgs(con
   }
   XOpenMPTargetArg->setBaseArg(A);
   A = XOpenMPTargetArg.release();
+  AllocatedArgs.push_back(A);
   DAL->append(A);
   NewArgAdded = true;
 }

Modified: cfe/trunk/test/Driver/openmp-offload-gpu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openmp-offload-gpu.c?rev=314328&r1=314327&r2=314328&view=diff
==
--- cfe/trunk/test/Driver/openmp-offload-gpu.c (original)
+++ cfe/trunk/test/Driver/openmp-offload-gpu.c Wed Sep 27 11:12:31 2017
@@ -2,9 +2,6 @@
 /// Perform several driver tests for OpenMP offloading
 ///
 
-// Until this test is stabilized on all local configurations.
-// UNSUPPORTED: linux
-
 // REQUIRES: clang-driver
 // REQUIRES: x86-registered-target
 // REQUIRES: powerpc-registered-target


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


r314330 - [OpenMP] Fix translation of target args

2017-09-27 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Wed Sep 27 11:12:36 2017
New Revision: 314330

URL: http://llvm.org/viewvc/llvm-project?rev=314330&view=rev
Log:
[OpenMP] Fix translation of target args

ToolChain::TranslateArgs() returns nullptr if no changes are performed.
This would currently mean that OpenMPArgs are lost. Patch fixes this
by falling back to simply using OpenMPArgs in that case.

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

Modified:
cfe/trunk/lib/Driver/Compilation.cpp

Modified: cfe/trunk/lib/Driver/Compilation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=314330&r1=314329&r2=314330&view=diff
==
--- cfe/trunk/lib/Driver/Compilation.cpp (original)
+++ cfe/trunk/lib/Driver/Compilation.cpp Wed Sep 27 11:12:36 2017
@@ -57,14 +57,16 @@ Compilation::getArgsForToolChain(const T
 *TranslatedArgs, DeviceOffloadKind, AllocatedArgs);
 if (!OpenMPArgs) {
   Entry = TC->TranslateArgs(*TranslatedArgs, BoundArch, DeviceOffloadKind);
+  if (!Entry)
+Entry = TranslatedArgs;
 } else {
   Entry = TC->TranslateArgs(*OpenMPArgs, BoundArch, DeviceOffloadKind);
-  delete OpenMPArgs;
+  if (!Entry)
+Entry = OpenMPArgs;
+  else
+delete OpenMPArgs;
 }
 
-if (!Entry)
-  Entry = TranslatedArgs;
-
 // Add allocated arguments to the final DAL.
 for (auto ArgPtr : AllocatedArgs) {
   Entry->AddSynthesizedArg(ArgPtr);


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


[PATCH] D38258: [OpenMP] Fix passing of -m arguments to device toolchain

2017-09-27 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314329: [OpenMP] Fix passing of -m arguments to device 
toolchain (authored by Hahnfeld).

Changed prior to commit:
  https://reviews.llvm.org/D38258?vs=116608&id=116845#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38258

Files:
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/test/Driver/openmp-offload-gpu.c
  cfe/trunk/test/Driver/openmp-offload.c

Index: cfe/trunk/test/Driver/openmp-offload.c
===
--- cfe/trunk/test/Driver/openmp-offload.c
+++ cfe/trunk/test/Driver/openmp-offload.c
@@ -39,6 +39,54 @@
 
 /// ###
 
+/// Check -Xopenmp-target=powerpc64le-ibm-linux-gnu -mcpu=pwr7 is passed when compiling for the device.
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target=powerpc64le-ibm-linux-gnu -mcpu=pwr7 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-EQ-TARGET %s
+
+// CHK-FOPENMP-EQ-TARGET: clang{{.*}} "-target-cpu" "pwr7" {{.*}}"-fopenmp-is-device"
+
+/// ###
+
+/// Check -Xopenmp-target -mcpu=pwr7 is passed when compiling for the device.
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target -mcpu=pwr7 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET %s
+
+// CHK-FOPENMP-TARGET: clang{{.*}} "-target-cpu" "pwr7" {{.*}}"-fopenmp-is-device"
+
+/// ##
+
+/// Check -mcpu=pwr7 is passed to the same triple.
+// RUN:%clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -target powerpc64le-ibm-linux-gnu -mcpu=pwr7 %s 2>&1 \
+// RUN:| FileCheck -check-prefix=CHK-FOPENMP-MCPU-TO-SAME-TRIPLE %s
+
+// CHK-FOPENMP-MCPU-TO-SAME-TRIPLE: clang{{.*}} "-target-cpu" "pwr7" {{.*}}"-fopenmp-is-device"
+
+/// ##
+
+/// Check -march=pwr7 is NOT passed to nvptx64-nvidia-cuda.
+// RUN:%clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -march=pwr7 %s 2>&1 \
+// RUN:| FileCheck -check-prefix=CHK-FOPENMP-MARCH-TO-GPU %s
+
+// CHK-FOPENMP-MARCH-TO-GPU-NOT: clang{{.*}} "-target-cpu" "pwr7" {{.*}}"-fopenmp-is-device"
+
+/// ###
+
+/// Check -Xopenmp-target triggers error when multiple triples are used.
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-unknown-linux-gnu -Xopenmp-target -mcpu=pwr8 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET-AMBIGUOUS-ERROR %s
+
+// CHK-FOPENMP-TARGET-AMBIGUOUS-ERROR: clang{{.*}} error: cannot deduce implicit triple value for -Xopenmp-target, specify triple using -Xopenmp-target=
+
+/// ###
+
+/// Check -Xopenmp-target triggers error when an option requiring arguments is passed to it.
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target -Xopenmp-target -mcpu=pwr8 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET-NESTED-ERROR %s
+
+// CHK-FOPENMP-TARGET-NESTED-ERROR: clang{{.*}} error: invalid -Xopenmp-target argument: '-Xopenmp-target -Xopenmp-target', options requiring arguments are unsupported
+
+/// ###
+
 /// Check the phases graph when using a single target, different from the host.
 /// We should have an offload action joining the host compile and device
 /// preprocessor and another one joining the device linking outputs to the host
Index: cfe/trunk/test/Driver/openmp-offload-gpu.c
===
--- cfe/trunk/test/Driver/openmp-offload-gpu.c
+++ cfe/trunk/test/Driver/openmp-offload-gpu.c
@@ -9,38 +9,6 @@
 
 /// ###
 
-/// Check -Xopenmp-target=powerpc64le-ibm-linux-gnu -march=pwr7 is passed when compiling for the device.
-// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target=powerpc64le-ibm-linux-gnu -mcpu=pwr7 %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-EQ-TARGET %s
-
-// CHK-FOPENMP-EQ-TARGET: clang{{.*}} "-target-cpu" "pwr7"
-
-/// ###
-
-/// Check -Xopenmp-target -march=pwr7 is passed when compiling for the device.
-// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target -mcpu=

[PATCH] D38259: [OpenMP] Fix translation of target args

2017-09-27 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314330: [OpenMP] Fix translation of target args (authored by 
Hahnfeld).

Changed prior to commit:
  https://reviews.llvm.org/D38259?vs=116610&id=116846#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38259

Files:
  cfe/trunk/lib/Driver/Compilation.cpp


Index: cfe/trunk/lib/Driver/Compilation.cpp
===
--- cfe/trunk/lib/Driver/Compilation.cpp
+++ cfe/trunk/lib/Driver/Compilation.cpp
@@ -57,14 +57,16 @@
 *TranslatedArgs, DeviceOffloadKind, AllocatedArgs);
 if (!OpenMPArgs) {
   Entry = TC->TranslateArgs(*TranslatedArgs, BoundArch, DeviceOffloadKind);
+  if (!Entry)
+Entry = TranslatedArgs;
 } else {
   Entry = TC->TranslateArgs(*OpenMPArgs, BoundArch, DeviceOffloadKind);
-  delete OpenMPArgs;
+  if (!Entry)
+Entry = OpenMPArgs;
+  else
+delete OpenMPArgs;
 }
 
-if (!Entry)
-  Entry = TranslatedArgs;
-
 // Add allocated arguments to the final DAL.
 for (auto ArgPtr : AllocatedArgs) {
   Entry->AddSynthesizedArg(ArgPtr);


Index: cfe/trunk/lib/Driver/Compilation.cpp
===
--- cfe/trunk/lib/Driver/Compilation.cpp
+++ cfe/trunk/lib/Driver/Compilation.cpp
@@ -57,14 +57,16 @@
 *TranslatedArgs, DeviceOffloadKind, AllocatedArgs);
 if (!OpenMPArgs) {
   Entry = TC->TranslateArgs(*TranslatedArgs, BoundArch, DeviceOffloadKind);
+  if (!Entry)
+Entry = TranslatedArgs;
 } else {
   Entry = TC->TranslateArgs(*OpenMPArgs, BoundArch, DeviceOffloadKind);
-  delete OpenMPArgs;
+  if (!Entry)
+Entry = OpenMPArgs;
+  else
+delete OpenMPArgs;
 }
 
-if (!Entry)
-  Entry = TranslatedArgs;
-
 // Add allocated arguments to the final DAL.
 for (auto ArgPtr : AllocatedArgs) {
   Entry->AddSynthesizedArg(ArgPtr);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38257: [OpenMP] Fix memory leak when translating arguments

2017-09-27 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314328: [OpenMP] Fix memory leak when translating arguments 
(authored by Hahnfeld).

Changed prior to commit:
  https://reviews.llvm.org/D38257?vs=116607&id=116844#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38257

Files:
  cfe/trunk/include/clang/Driver/ToolChain.h
  cfe/trunk/lib/Driver/Compilation.cpp
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/test/Driver/openmp-offload-gpu.c


Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -800,9 +800,10 @@
   return VersionTuple();
 }
 
-llvm::opt::DerivedArgList *
-ToolChain::TranslateOpenMPTargetArgs(const llvm::opt::DerivedArgList &Args,
-Action::OffloadKind DeviceOffloadKind) const {
+llvm::opt::DerivedArgList *ToolChain::TranslateOpenMPTargetArgs(
+const llvm::opt::DerivedArgList &Args,
+Action::OffloadKind DeviceOffloadKind,
+SmallVector &AllocatedArgs) const {
   if (DeviceOffloadKind == Action::OFK_OpenMP) {
 DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
 const OptTable &Opts = getDriver().getOpts();
@@ -854,6 +855,7 @@
   }
   XOpenMPTargetArg->setBaseArg(A);
   A = XOpenMPTargetArg.release();
+  AllocatedArgs.push_back(A);
   DAL->append(A);
   NewArgAdded = true;
 }
Index: cfe/trunk/lib/Driver/Compilation.cpp
===
--- cfe/trunk/lib/Driver/Compilation.cpp
+++ cfe/trunk/lib/Driver/Compilation.cpp
@@ -51,9 +51,10 @@
 
   DerivedArgList *&Entry = TCArgs[{TC, BoundArch, DeviceOffloadKind}];
   if (!Entry) {
+SmallVector AllocatedArgs;
 // Translate OpenMP toolchain arguments provided via the -Xopenmp-target 
flags.
-DerivedArgList *OpenMPArgs = TC->TranslateOpenMPTargetArgs(*TranslatedArgs,
-DeviceOffloadKind);
+DerivedArgList *OpenMPArgs = TC->TranslateOpenMPTargetArgs(
+*TranslatedArgs, DeviceOffloadKind, AllocatedArgs);
 if (!OpenMPArgs) {
   Entry = TC->TranslateArgs(*TranslatedArgs, BoundArch, DeviceOffloadKind);
 } else {
@@ -63,6 +64,11 @@
 
 if (!Entry)
   Entry = TranslatedArgs;
+
+// Add allocated arguments to the final DAL.
+for (auto ArgPtr : AllocatedArgs) {
+  Entry->AddSynthesizedArg(ArgPtr);
+}
   }
 
   return *Entry;
Index: cfe/trunk/include/clang/Driver/ToolChain.h
===
--- cfe/trunk/include/clang/Driver/ToolChain.h
+++ cfe/trunk/include/clang/Driver/ToolChain.h
@@ -249,9 +249,10 @@
   ///
   /// \param DeviceOffloadKind - The device offload kind used for the
   /// translation.
-  virtual llvm::opt::DerivedArgList *
-  TranslateOpenMPTargetArgs(const llvm::opt::DerivedArgList &Args,
-  Action::OffloadKind DeviceOffloadKind) const;
+  virtual llvm::opt::DerivedArgList *TranslateOpenMPTargetArgs(
+  const llvm::opt::DerivedArgList &Args,
+  Action::OffloadKind DeviceOffloadKind,
+  SmallVector &AllocatedArgs) const;
 
   /// Choose a tool to use to handle the action \p JA.
   ///
Index: cfe/trunk/test/Driver/openmp-offload-gpu.c
===
--- cfe/trunk/test/Driver/openmp-offload-gpu.c
+++ cfe/trunk/test/Driver/openmp-offload-gpu.c
@@ -2,9 +2,6 @@
 /// Perform several driver tests for OpenMP offloading
 ///
 
-// Until this test is stabilized on all local configurations.
-// UNSUPPORTED: linux
-
 // REQUIRES: clang-driver
 // REQUIRES: x86-registered-target
 // REQUIRES: powerpc-registered-target


Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -800,9 +800,10 @@
   return VersionTuple();
 }
 
-llvm::opt::DerivedArgList *
-ToolChain::TranslateOpenMPTargetArgs(const llvm::opt::DerivedArgList &Args,
-Action::OffloadKind DeviceOffloadKind) const {
+llvm::opt::DerivedArgList *ToolChain::TranslateOpenMPTargetArgs(
+const llvm::opt::DerivedArgList &Args,
+Action::OffloadKind DeviceOffloadKind,
+SmallVector &AllocatedArgs) const {
   if (DeviceOffloadKind == Action::OFK_OpenMP) {
 DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
 const OptTable &Opts = getDriver().getOpts();
@@ -854,6 +855,7 @@
   }
   XOpenMPTargetArg->setBaseArg(A);
   A = XOpenMPTargetArg.release();
+  AllocatedArgs.push_back(A);
   DAL->append(A);
   NewArgAdded = true;
 }
Index: cfe/trunk/lib/Driver/Compilation.cpp
===
--- cfe/trunk/lib/Driver/Compilation.cpp
+++ cfe/trunk/lib/Driver/Compilation.cpp
@@ -51,9 +51,10 @@
 
   DerivedArgList *&Entry = TCArgs[{TC, BoundArch, DeviceOffloadKind}];
   if (!Entry) {
+SmallVector AllocatedAr

[PATCH] D14358: DWARF's forward decl of a template should have template parameters.

2017-09-27 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

> I would prefer to eliminate the `` from the instance name as well, 
> because our debugger reconstructs a name more to its liking from the 
> parameter children.  However, IIUC the name with params is used for 
> deduplication in LTO, so that is probably not such a good idea. :-)

Though you have this out of tree? How do you cope with LTO there?

I've not fully refreshed myself on the previous conversations - but it looks 
like my thought was that this state proposed here is weird/inconsistent: The 
parameters are already in the name, so adding them in the DIEs seems redundant. 
If the parameters weren't in the name then this change might make more sense.




Comment at: test/CodeGenCXX/debug-info-fwd-template-param.cpp:6-17
+template class A {
+public:
+  A(T val);
+private:
+  T x;
+};
+

Probably simpler:

  template class A;
  A *p;

?


https://reviews.llvm.org/D14358



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


[PATCH] D38303: [Sema] Correct IUnknown to support Unknwnbase.h Header.

2017-09-27 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/AST/DeclCXX.cpp:1497-1505
+  bool IsInNamespace = false;
+  const auto *DeclContext = getDeclContext();
+  while (!DeclContext->isTranslationUnit()) {
+if (DeclContext->isNamespace()) {
+  IsInNamespace = true;
+  break;
+}

This would be nicer factored out as a static helper because it would let you 
early return and avoid the variable and break. You could just fold the call 
into the condition in the `if` below.


https://reviews.llvm.org/D38303



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


[PATCH] D38284: [clang-tidy] Fix google-readability-namespace-comments handling of C++17 nested namespaces

2017-09-27 Thread Alexandru Octavian Buțiu via Phabricator via cfe-commits
predator5047 updated this revision to Diff 116850.
predator5047 added a comment.

Fixed spelling mistake and added a test case.


https://reviews.llvm.org/D38284

Files:
  clang-tidy/readability/NamespaceCommentCheck.cpp
  clang-tidy/readability/NamespaceCommentCheck.h
  test/clang-tidy/google-readability-nested-namespace-comments.cpp

Index: test/clang-tidy/google-readability-nested-namespace-comments.cpp
===
--- /dev/null
+++ test/clang-tidy/google-readability-nested-namespace-comments.cpp
@@ -0,0 +1,22 @@
+// RUN: %check_clang_tidy %s google-readability-namespace-comments %t -- -std=c++17
+
+namespace n1::n2 {
+namespace n3 {
+	
+	//so that namespace is not empty
+	void f();
+	
+	
+	
+	
+	
+	
+	
+	
+// CHECK-MESSAGES: :[[@LINE+4]]:2: warning: namespace 'n3' not terminated with
+// CHECK-MESSAGES: :[[@LINE-13]]:11: note: namespace 'n3' starts here	
+// CHECK-MESSAGES: :[[@LINE+2]]:3: warning: namespace 'n1::n2' not terminated with a closing comment [google-readability-namespace-comments]
+// CHECK-MESSAGES: :[[@LINE-16]]:11: note: namespace 'n1::n2' starts here
+}}
+// CHECK-FIXES: }  // namespace n3
+// CHECK-FIXES: }  // namespace n1::n2
\ No newline at end of file
Index: clang-tidy/readability/NamespaceCommentCheck.h
===
--- clang-tidy/readability/NamespaceCommentCheck.h
+++ clang-tidy/readability/NamespaceCommentCheck.h
@@ -34,6 +34,7 @@
   llvm::Regex NamespaceCommentPattern;
   const unsigned ShortNamespaceLines;
   const unsigned SpacesBeforeComments;
+  llvm::SmallVector Ends;
 };
 
 } // namespace readability
Index: clang-tidy/readability/NamespaceCommentCheck.cpp
===
--- clang-tidy/readability/NamespaceCommentCheck.cpp
+++ clang-tidy/readability/NamespaceCommentCheck.cpp
@@ -23,7 +23,7 @@
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   NamespaceCommentPattern("^/[/*] *(end (of )?)? *(anonymous|unnamed)? *"
-  "namespace( +([a-zA-Z0-9_]+))?\\.? *(\\*/)?$",
+  "namespace( +([a-zA-Z0-9_:]+))?\\.? *(\\*/)?$",
   llvm::Regex::IgnoreCase),
   ShortNamespaceLines(Options.get("ShortNamespaceLines", 1u)),
   SpacesBeforeComments(Options.get("SpacesBeforeComments", 1u)) {}
@@ -56,6 +56,14 @@
   return Fix;
 }
 
+static std::string getNamespaceComment(const std::string &s, bool InsertLineBreak) {
+	std::string Fix = "// namespace ";
+	Fix.append(s);
+	if (InsertLineBreak)
+		Fix.append("\n");
+	return Fix;
+}
+
 void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *ND = Result.Nodes.getNodeAs("namespace");
   const SourceManager &Sources = *Result.SourceManager;
@@ -74,6 +82,34 @@
   SourceLocation AfterRBrace = ND->getRBraceLoc().getLocWithOffset(1);
   SourceLocation Loc = AfterRBrace;
   Token Tok;
+  SourceLocation LBracketLocation = ND->getLocation();
+  auto NestedNamespaceBegin = LBracketLocation;
+
+  // Currently for nested namepsace (n1::n2::...) the AST matcher will match foo
+  // then bar instead of a single match. So if we got a nested namespace we have
+  // to skip the next ones
+  for (const auto &i : Ends) {
+if (Sources.isBeforeInTranslationUnit(NestedNamespaceBegin, i)) {
+  return;
+}
+  }
+
+  while (Lexer::getRawToken(LBracketLocation, Tok, Sources, getLangOpts()) ||
+ !Tok.is(tok::l_brace)) {
+LBracketLocation = LBracketLocation.getLocWithOffset(1);
+  }
+
+  auto TextRange =
+  Lexer::getAsCharRange(SourceRange(NestedNamespaceBegin, LBracketLocation),
+Sources, getLangOpts());
+  auto NestedNamespaceName =
+  Lexer::getSourceText(TextRange, Sources, getLangOpts()).rtrim();
+  bool IsNested = NestedNamespaceName.contains(':');
+
+  if (IsNested) {
+Ends.push_back(LBracketLocation);
+  }
+
   // Skip whitespace until we find the next token.
   while (Lexer::getRawToken(Loc, Tok, Sources, getLangOpts()) ||
  Tok.is(tok::semi)) {
@@ -98,10 +134,13 @@
   StringRef NamespaceNameInComment = Groups.size() > 5 ? Groups[5] : "";
   StringRef Anonymous = Groups.size() > 3 ? Groups[3] : "";
 
-  // Check if the namespace in the comment is the same.
-  if ((ND->isAnonymousNamespace() && NamespaceNameInComment.empty()) ||
-  (ND->getNameAsString() == NamespaceNameInComment &&
-   Anonymous.empty())) {
+  // C++17 nested namespace
+  if (IsNested && NestedNamespaceName == NamespaceNameInComment) {
+return;
+  } // Check if the namespace in the comment is the same.
+  else if ((ND->isAnonymousNamespace() && NamespaceNameInComment.empty()) ||
+   (ND->getNameAsString() == NamespaceNameInComment &&
+Anonymous.empty())) {
 // FIXME: Maybe we need a strict

[PATCH] D14358: DWARF's forward decl of a template should have template parameters.

2017-09-27 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

In https://reviews.llvm.org/D14358#882445, @dblaikie wrote:

> > I would prefer to eliminate the `` from the instance name as well, 
> > because our debugger reconstructs a name more to its liking from the 
> > parameter children.  However, IIUC the name with params is used for 
> > deduplication in LTO, so that is probably not such a good idea. :-)
>
> Though you have this out of tree? How do you cope with LTO there?


We discovered that we had to keep them in the name for LTO.

> I've not fully refreshed myself on the previous conversations - but it looks 
> like my thought was that this state proposed here is weird/inconsistent: The 
> parameters are already in the name, so adding them in the DIEs seems 
> redundant. If the parameters weren't in the name then this change might make 
> more sense.

Our debugger throws away the params in the name, and relies on the children.  
The names as rendered in DWARF by Clang are not textually consistent with names 
as rendered by the demangler.  Our debugger uses the children to construct 
names that are consistent with how the demangler works.  Then it can match up 
type names returned by the demangler to type names it has constructed.  
Assuming I am not misunderstanding our debugger guys again, but that's my 
recollection.

I believe we have talked previously about using a different scheme for 
deduplication that doesn't depend (or not so much) on the names.  If we had 
that, we could eliminate params from the name, and save probably a noticeable 
chunk of space in the string section.  I haven't tried to measure that, though. 
 But we have to have the children in place before we can experiment with other 
deduplication schemes.

There is also the pedantic point that DWARF doesn't say these child entries are 
optional, or omitted for forward declarations.  I know gcc doesn't (or didn't, 
anyway; what I have locally is gcc 5.4) but gcc is not the arbiter of what 
constitutes conforming DWARF.


https://reviews.llvm.org/D14358



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


[PATCH] D38326: [CUDA] Work around conflicting function definitions in CUDA-9 headers.

2017-09-27 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
Herald added a subscriber: sanjoy.

https://reviews.llvm.org/D38326

Files:
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -173,7 +173,18 @@
 // __device__.
 #pragma push_macro("__forceinline__")
 #define __forceinline__ __device__ __inline__ __attribute__((always_inline))
+
+#pragma push_macro("__float2half_rn")
+#if CUDA_VERSION >= 9000
+// CUDA-9 has conflicting prototypes for __float2half_rn(float f) in
+// cuda_fp16.h[pp] and device_functions.hpp. We need to get the one in
+// device_functions.hpp out of the way.
+#define __float2half_rn  __float2half_rn_disabled
+#endif
+
 #include "device_functions.hpp"
+#pragma pop_macro("__float2half_rn")
+
 
 // math_function.hpp uses the __USE_FAST_MATH__ macro to determine whether we
 // get the slow-but-accurate or fast-but-inaccurate versions of functions like


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -173,7 +173,18 @@
 // __device__.
 #pragma push_macro("__forceinline__")
 #define __forceinline__ __device__ __inline__ __attribute__((always_inline))
+
+#pragma push_macro("__float2half_rn")
+#if CUDA_VERSION >= 9000
+// CUDA-9 has conflicting prototypes for __float2half_rn(float f) in
+// cuda_fp16.h[pp] and device_functions.hpp. We need to get the one in
+// device_functions.hpp out of the way.
+#define __float2half_rn  __float2half_rn_disabled
+#endif
+
 #include "device_functions.hpp"
+#pragma pop_macro("__float2half_rn")
+
 
 // math_function.hpp uses the __USE_FAST_MATH__ macro to determine whether we
 // get the slow-but-accurate or fast-but-inaccurate versions of functions like
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14358: DWARF's forward decl of a template should have template parameters.

2017-09-27 Thread David Blaikie via cfe-commits
On Wed, Sep 27, 2017 at 11:50 AM Paul Robinson via Phabricator <
revi...@reviews.llvm.org> wrote:

> probinson added a comment.
>
> In https://reviews.llvm.org/D14358#882445, @dblaikie wrote:
>
> > > I would prefer to eliminate the `` from the instance name as
> well, because our debugger reconstructs a name more to its liking from the
> parameter children.  However, IIUC the name with params is used for
> deduplication in LTO, so that is probably not such a good idea. :-)
> >
> > Though you have this out of tree? How do you cope with LTO there?
>
>
> We discovered that we had to keep them in the name for LTO.
>
> > I've not fully refreshed myself on the previous conversations - but it
> looks like my thought was that this state proposed here is
> weird/inconsistent: The parameters are already in the name, so adding them
> in the DIEs seems redundant. If the parameters weren't in the name then
> this change might make more sense.
>
> Our debugger throws away the params in the name, and relies on the
> children.  The names as rendered in DWARF by Clang are not textually
> consistent with names as rendered by the demangler.  Our debugger uses the
> children to construct names that are consistent with how the demangler
> works.  Then it can match up type names returned by the demangler to type
> names it has constructed.  Assuming I am not misunderstanding our debugger
> guys again, but that's my recollection.
>
> I believe we have talked previously about using a different scheme for
> deduplication that doesn't depend (or not so much) on the names.  If we had
> that, we could eliminate params from the name, and save probably a
> noticeable chunk of space in the string section.  I haven't tried to
> measure that, though.  But we have to have the children in place before we
> can experiment with other deduplication schemes.
>

Fair enough - yeah, I would agree with Adrian that this probably isn't a
driver flag (at least not yet), though. Either only driven by the debugger
tuning (though perhaps we had some position that debugger tuning wouldn't
ever be the only way to access functionality, only change defaults) or
additionally a cc1 flag. Haven't thought about the name.


>
> There is also the pedantic point that DWARF doesn't say these child
> entries are optional, or omitted for forward declarations.  I know gcc
> doesn't (or didn't, anyway; what I have locally is gcc 5.4) but gcc is not
> the arbiter of what constitutes conforming DWARF.
>
>
> https://reviews.llvm.org/D14358
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38101: [Sema] Diagnose tautological comparison with type's min/max values

2017-09-27 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 116857.
lebedev.ri added a comment.

Rebased, ping.

Vanilla stage-2 build is now warning-clean, the only previous warning was fixed.


Repository:
  rL LLVM

https://reviews.llvm.org/D38101

Files:
  docs/ReleaseNotes.rst
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/Sema/outof-range-constant-compare.c

Index: test/Sema/outof-range-constant-compare.c
===
--- test/Sema/outof-range-constant-compare.c
+++ test/Sema/outof-range-constant-compare.c
@@ -102,6 +102,7 @@
   return 1;
 
 short s = value();
+
 if (s == 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always false}}
 return 0;
 if (s != 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
@@ -128,6 +129,112 @@
 if (0x1234567812345678L >= s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
 return 0;
 
+if (s == 32767)
+return 0;
+if (s != 32767)
+return 0;
+if (s < 32767)
+return 0;
+if (s <= 32767) // expected-warning {{comparison 'short' <= 32767 is always true}}
+return 0;
+if (s > 32767) // expected-warning {{comparison 'short' > 32767 is always false}}
+return 0;
+if (s >= 32767)
+return 0;
+
+if (32767 == s)
+return 0;
+if (32767 != s)
+return 0;
+if (32767 < s) // expected-warning {{comparison 32767 < 'short' is always false}}
+return 0;
+if (32767 <= s)
+return 0;
+if (32767 > s)
+return 0;
+if (32767 >= s) // expected-warning {{comparison 32767 >= 'short' is always true}}
+return 0;
+
+// FIXME: assumes two's complement
+if (s == -32768)
+return 0;
+if (s != -32768)
+return 0;
+if (s < -32768) // expected-warning {{comparison 'short' < -32768 is always false}}
+return 0;
+if (s <= -32768)
+return 0;
+if (s > -32768)
+return 0;
+if (s >= -32768) // expected-warning {{comparison 'short' >= -32768 is always true}}
+return 0;
+
+if (-32768 == s)
+return 0;
+if (-32768 != s)
+return 0;
+if (-32768 < s)
+return 0;
+if (-32768 <= s) // expected-warning {{comparison -32768 <= 'short' is always true}}
+return 0;
+if (-32768 > s) // expected-warning {{comparison -32768 > 'short' is always false}}
+return 0;
+if (-32768 >= s)
+return 0;
+
+if (s == 32767UL)
+return 0;
+if (s != 32767UL)
+return 0;
+if (s < 32767UL)
+return 0;
+if (s <= 32767UL) // expected-warning {{comparison 'short' <= 32767 is always true}}
+return 0;
+if (s > 32767UL) // expected-warning {{comparison 'short' > 32767 is always false}}
+return 0;
+if (s >= 32767UL)
+return 0;
+
+if (32767UL == s)
+return 0;
+if (32767UL != s)
+return 0;
+if (32767UL < s) // expected-warning {{comparison 32767 < 'short' is always false}}
+return 0;
+if (32767UL <= s)
+return 0;
+if (32767UL > s)
+return 0;
+if (32767UL >= s) // expected-warning {{comparison 32767 >= 'short' is always true}}
+return 0;
+
+// FIXME: assumes two's complement
+if (s == -32768L)
+return 0;
+if (s != -32768L)
+return 0;
+if (s < -32768L) // expected-warning {{comparison 'short' < -32768 is always false}}
+return 0;
+if (s <= -32768L)
+return 0;
+if (s > -32768L)
+return 0;
+if (s >= -32768L) // expected-warning {{comparison 'short' >= -32768 is always true}}
+return 0;
+
+if (-32768L == s)
+return 0;
+if (-32768L != s)
+return 0;
+if (-32768L < s)
+return 0;
+if (-32768L <= s) // expected-warning {{comparison -32768 <= 'short' is always true}}
+return 0;
+if (-32768L > s) // expected-warning {{comparison -32768 > 'short' is always false}}
+return 0;
+if (-32768L >= s)
+return 0;
+
 long l = value();
 if (l == 0x1234567812345678L)
 return 0;
@@ -208,6 +315,66 @@
 if (0xUL >= un)
 return 0;
 
+unsigned short us = value();
+
+if (us == 65535)
+return 0;
+if (us != 65535)
+return 0;
+if (us < 65535)
+return 0;
+if (us <= 65535) // expected-warning {{comparison 'unsigned short' <= 65535 is always true}}
+return 0;
+if (us > 65535) // expected-warning {{comparison 'unsigned short' > 65535 is always false}}
+return 0;
+if (us >= 65535)
+return 0;
+
+if (65535 == us)
+return 0;
+if (65535 != us)
+ 

r314334 - [CUDA] Work around conflicting function definitions in CUDA-9 headers.

2017-09-27 Thread Artem Belevich via cfe-commits
Author: tra
Date: Wed Sep 27 12:07:15 2017
New Revision: 314334

URL: http://llvm.org/viewvc/llvm-project?rev=314334&view=rev
Log:
[CUDA] Work around conflicting function definitions in CUDA-9 headers.

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

Modified:
cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h

Modified: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h?rev=314334&r1=314333&r2=314334&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h Wed Sep 27 12:07:15 
2017
@@ -173,7 +173,18 @@ inline __host__ double __signbitd(double
 // __device__.
 #pragma push_macro("__forceinline__")
 #define __forceinline__ __device__ __inline__ __attribute__((always_inline))
+
+#pragma push_macro("__float2half_rn")
+#if CUDA_VERSION >= 9000
+// CUDA-9 has conflicting prototypes for __float2half_rn(float f) in
+// cuda_fp16.h[pp] and device_functions.hpp. We need to get the one in
+// device_functions.hpp out of the way.
+#define __float2half_rn  __float2half_rn_disabled
+#endif
+
 #include "device_functions.hpp"
+#pragma pop_macro("__float2half_rn")
+
 
 // math_function.hpp uses the __USE_FAST_MATH__ macro to determine whether we
 // get the slow-but-accurate or fast-but-inaccurate versions of functions like


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


[PATCH] D38326: [CUDA] Work around conflicting function definitions in CUDA-9 headers.

2017-09-27 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314334: [CUDA] Work around conflicting function definitions 
in CUDA-9 headers. (authored by tra).

Changed prior to commit:
  https://reviews.llvm.org/D38326?vs=116856&id=116858#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38326

Files:
  cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h


Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -173,7 +173,18 @@
 // __device__.
 #pragma push_macro("__forceinline__")
 #define __forceinline__ __device__ __inline__ __attribute__((always_inline))
+
+#pragma push_macro("__float2half_rn")
+#if CUDA_VERSION >= 9000
+// CUDA-9 has conflicting prototypes for __float2half_rn(float f) in
+// cuda_fp16.h[pp] and device_functions.hpp. We need to get the one in
+// device_functions.hpp out of the way.
+#define __float2half_rn  __float2half_rn_disabled
+#endif
+
 #include "device_functions.hpp"
+#pragma pop_macro("__float2half_rn")
+
 
 // math_function.hpp uses the __USE_FAST_MATH__ macro to determine whether we
 // get the slow-but-accurate or fast-but-inaccurate versions of functions like


Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -173,7 +173,18 @@
 // __device__.
 #pragma push_macro("__forceinline__")
 #define __forceinline__ __device__ __inline__ __attribute__((always_inline))
+
+#pragma push_macro("__float2half_rn")
+#if CUDA_VERSION >= 9000
+// CUDA-9 has conflicting prototypes for __float2half_rn(float f) in
+// cuda_fp16.h[pp] and device_functions.hpp. We need to get the one in
+// device_functions.hpp out of the way.
+#define __float2half_rn  __float2half_rn_disabled
+#endif
+
 #include "device_functions.hpp"
+#pragma pop_macro("__float2half_rn")
+
 
 // math_function.hpp uses the __USE_FAST_MATH__ macro to determine whether we
 // get the slow-but-accurate or fast-but-inaccurate versions of functions like
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38327: [Sema] Put nullability fix-it after the end of the pointer.

2017-09-27 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.

Fixes nullability fix-it for `id`. With this change
nullability specifier is inserted after ">" instead of between
"id" and "<".

rdar://problem/34260995


https://reviews.llvm.org/D38327

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaType.cpp
  clang/test/FixIt/Inputs/nullability-objc.h
  clang/test/FixIt/nullability.mm
  clang/test/SemaObjCXX/Inputs/nullability-consistency-2.h

Index: clang/test/SemaObjCXX/Inputs/nullability-consistency-2.h
===
--- clang/test/SemaObjCXX/Inputs/nullability-consistency-2.h
+++ clang/test/SemaObjCXX/Inputs/nullability-consistency-2.h
@@ -6,9 +6,9 @@
 
 void g3(const
 id // expected-warning{{missing a nullability type specifier}}
+volatile
 // expected-note@-1 {{insert '_Nullable' if the pointer may be null}}
 // expected-note@-2 {{insert '_Nonnull' if the pointer should never be null}}
-volatile
 * // expected-warning{{missing a nullability type specifier}}
 // expected-note@-1 {{insert '_Nullable' if the pointer may be null}}
 // expected-note@-2 {{insert '_Nonnull' if the pointer should never be null}}
Index: clang/test/FixIt/nullability.mm
===
--- clang/test/FixIt/nullability.mm
+++ clang/test/FixIt/nullability.mm
@@ -2,8 +2,10 @@
 // RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -fblocks -std=gnu++11 -I %S/Inputs %s >%t.txt 2>&1
 // RUN: FileCheck %s < %t.txt
 // RUN: FileCheck %S/Inputs/nullability.h < %t.txt
+// RUN: FileCheck %S/Inputs/nullability-objc.h < %t.txt
 
 #include "nullability.h"
+#include "nullability-objc.h"
 
 #pragma clang assume_nonnull begin
 
Index: clang/test/FixIt/Inputs/nullability-objc.h
===
--- /dev/null
+++ clang/test/FixIt/Inputs/nullability-objc.h
@@ -0,0 +1,48 @@
+@class Item;
+@class Container;
+@protocol Protocol;
+
+// rdar://problem/34260995
+// The first pointer in the file is handled in a different way so need
+// a separate test for this case even if the parameter type is the same as in
+// objcIdParameterWithProtocol.
+void objcIdParameterWithProtocolFirstInFile(id i); // expected-warning {{pointer is missing a nullability type specifier}}
+// expected-note@-1 {{insert '_Nullable'}}
+// expected-note@-2 {{insert '_Nonnull'}}
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-3]]:57-[[@LINE-3]]:57}:" _Nullable"
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-4]]:57-[[@LINE-4]]:57}:" _Nonnull"
+
+int * _Nonnull forceNullabilityWarningsObjC(void);
+
+void objcClassParameter(Item *i); // expected-warning {{pointer is missing a nullability type specifier}}
+// expected-note@-1 {{insert '_Nullable'}}
+// expected-note@-2 {{insert '_Nonnull'}}
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-3]]:31-[[@LINE-3]]:31}:" _Nullable "
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-4]]:31-[[@LINE-4]]:31}:" _Nonnull "
+
+void objcClassParameterWithProtocol(Item *i); // expected-warning {{pointer is missing a nullability type specifier}}
+// expected-note@-1 {{insert '_Nullable'}}
+// expected-note@-2 {{insert '_Nonnull'}}
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-3]]:53-[[@LINE-3]]:53}:" _Nullable "
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-4]]:53-[[@LINE-4]]:53}:" _Nonnull "
+
+// rdar://problem/34260995
+void objcIdParameterWithProtocol(id i); // expected-warning {{pointer is missing a nullability type specifier}}
+// expected-note@-1 {{insert '_Nullable'}}
+// expected-note@-2 {{insert '_Nonnull'}}
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-3]]:46-[[@LINE-3]]:46}:" _Nullable"
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-4]]:46-[[@LINE-4]]:46}:" _Nonnull"
+
+// Class parameters don't have nullability type specifier.
+void objcParameterizedClassParameter(Container *c); // expected-warning {{pointer is missing a nullability type specifier}}
+// expected-note@-1 {{insert '_Nullable'}}
+// expected-note@-2 {{insert '_Nonnull'}}
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-3]]:57-[[@LINE-3]]:57}:" _Nullable "
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-4]]:57-[[@LINE-4]]:57}:" _Nonnull "
+
+// Class parameters don't have nullability type specifier.
+void objcParameterizedClassParameterWithProtocol(Container> *c); // expected-warning {{pointer is missing a nullability type specifier}}
+// expected-note@-1 {{insert '_Nullable'}}
+// expected-note@-2 {{insert '_Nonnull'}}
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-3]]:75-[[@LINE-3]]:75}:" _Nullable "
+// CHECK: fix-it:"{{.*}}nullability-objc.h":{[[@LINE-4]]:75-[[@LINE-4]]:75}:" _Nonnull "
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -3500,7 +3500,8 @@
 
 static void emitNullabilityConsistencyWarning(Sema &S,

[PATCH] D14358: DWARF's forward decl of a template should have template parameters.

2017-09-27 Thread Paul Robinson via Phabricator via cfe-commits
probinson updated this revision to Diff 116862.
probinson added a comment.

command-line option is cc1 not driver
internal flag moved from LangOpts to CodeGenOpts and renamed
simplified test


https://reviews.llvm.org/D14358

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGDebugInfo.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/debug-info-fwd-template-param.cpp


Index: test/CodeGenCXX/debug-info-fwd-template-param.cpp
===
--- test/CodeGenCXX/debug-info-fwd-template-param.cpp
+++ test/CodeGenCXX/debug-info-fwd-template-param.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 %s -triple=%itanium_abi_triple -debug-info-kind=limited 
-debug-forward-template-params -emit-llvm -o - | FileCheck --check-prefix=CHILD 
%s
+// RUN: %clang_cc1 %s -triple=%itanium_abi_triple -debug-info-kind=limited 
-emit-llvm -o - | FileCheck --check-prefix=NONE %s
+// A DWARF forward declaration of a template instantiation should have template
+// parameter children (if we ask for them).
+
+template class A;
+A *p;
+
+// CHILD:  !DICompositeType(tag: DW_TAG_class_type, name: "A"
+// CHILD-SAME: flags: DIFlagFwdDecl
+// CHILD-SAME: templateParams: [[PARAM_LIST:![0-9]*]]
+// CHILD:  [[PARAM_LIST]] = !{[[PARAM:![0-9]*]]}
+// CHILD:  [[PARAM]] = !DITemplateTypeParameter(name: "T",
+// CHILD-SAME: type: [[CTYPE:![0-9]*]]
+// CHILD:  [[CTYPE]] = !DIDerivedType(tag: DW_TAG_const_type
+// CHILD-SAME: baseType: [[BTYPE:![0-9]*]]
+// CHILD:  [[BTYPE]] = !DIBasicType(name: "int"
+
+// NONE:   !DICompositeType(tag: DW_TAG_class_type, name: "A"
+// NONE-SAME:  flags: DIFlagFwdDecl
+// NONE-NOT:   templateParams:
+// NONE-SAME:  )
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -528,6 +528,7 @@
   Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining);
   Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
   Opts.DebugExplicitImport = Triple.isPS4CPU();
+  Opts.DebugFwdTemplateParams = Args.hasArg(OPT_debug_forward_template_params);
 
   for (const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ))
 Opts.DebugPrefixMap.insert(StringRef(Arg).split('='));
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2969,6 +2969,11 @@
 CmdArgs.push_back("-generate-type-units");
   }
 
+  // Decide how to render forward declarations of template instantiations.
+  // SCE wants full descriptions, others just get them in the name.
+  if (DebuggerTuning == llvm::DebuggerKind::SCE)
+CmdArgs.push_back("-debug-forward-template-params");
+
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D);
 }
 
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -833,6 +833,10 @@
   llvm::DICompositeType *RetTy = DBuilder.createReplaceableCompositeType(
   getTagForRecord(RD), RDName, Ctx, DefUnit, Line, 0, Size, Align,
   llvm::DINode::FlagFwdDecl, FullName);
+  if (CGM.getCodeGenOpts().DebugFwdTemplateParams)
+if (auto *TSpecial = dyn_cast(RD))
+  DBuilder.replaceArrays(RetTy, llvm::DINodeArray(),
+ CollectCXXTemplateParams(TSpecial, DefUnit));
   ReplaceMap.emplace_back(
   std::piecewise_construct, std::make_tuple(Ty),
   std::make_tuple(static_cast(RetTy)));
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -219,6 +219,10 @@
 CODEGENOPT(SplitDwarfInlining, 1, 1) ///< Whether to include inlining info in 
the
  ///< skeleton CU to allow for 
symbolication
 ///< of inline stack frames without .dwo 
files.
+CODEGENOPT(DebugFwdTemplateParams, 1, 0) ///< Whether to emit complete
+ ///< template parameter descriptions 
in
+ ///< forward declarations (versus just
+ ///< including them in the name).
 
 CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists.
 
Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -200,6 +200,9 @@
 def dwarf_ext_refs : Flag<["-"], "dwarf-ext-refs">,
   HelpText<"Generate debug info with external references to clang modules"
" or precompiled headers">;

[PATCH] D37861: preserving #pragma clang assume_nonnull in preprocessed output

2017-09-27 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Oops, sorry, lost track of it; I'll commit it today.


https://reviews.llvm.org/D37861



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


[PATCH] D38327: [Sema] Put nullability fix-it after the end of the pointer.

2017-09-27 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose accepted this revision.
jordan_rose added a comment.
This revision is now accepted and ready to land.

Nice catch, Volodymyr! Looks good to me.


https://reviews.llvm.org/D38327



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


[PATCH] D38327: [Sema] Put nullability fix-it after the end of the pointer.

2017-09-27 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

To preempt some of review feedback here are attempted and rejected approaches:

- Pass `pointerLoc` and `pointerEndLoc` as `pointerRange`. Such source range 
can be misleading as `pointerLoc` doesn't necesserily point at the beginning. 
For example, for `int *x` pointer range would be "*" and I would expect it to 
be "int *". So it's not really a range but 2 related locations.

- Use `D.getDeclSpec().getLocEnd()` instead of 
`D.getDeclSpec().getTypeSpecTypeLoc()`. In this case warning location points at 
the closing angle bracket and that can be confusing to developers. It looks like

  ./test.h:14:3: warning: pointer is missing a nullability type specifier 
(_Nonnull, _Nullable, or _Null_unspecified)
id thingies;
   ^



- Use `pointerLoc` for insert note instead of `pointerEndLoc`. It looks like

  ./test.h:14:3: note: insert '_Nullable' if the pointer may be null
id thingies;
^
 _Nullable

compared to suggested

  ./test.h:14:18: note: insert '_Nullable' if the pointer may be null
id thingies;
   ^
 _Nullable

I don't expect developers to know that they should match whitespace preceding 
_Nullable to calculate where in the line it should be inserted. And I think 
developers shouldn't care about it. So put the cursor where you expect the text 
to be inserted.


https://reviews.llvm.org/D38327



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


[PATCH] D38270: [clang] Add getUnsignedPointerDiffType method

2017-09-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

> The code for printf diagnostics + new tests are supposed to be added by a 
> separate diff.

I think you should combine that diff and this one into a single patch, 
otherwise this patch is untestable.




Comment at: include/clang/AST/ASTContext.h:1492-1493
 
+  /// \brief Return the unique unsigned counterpart of 
+  /// "ptrdiff_t" integer type.
+  QualType getUnsignedPointerDiffType() const;

Wrap the comment, and you might want to refer to C11 7.21.6.1p7 as a 
justification for why this is needed.


Repository:
  rL LLVM

https://reviews.llvm.org/D38270



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


RE: [PATCH] D14358: DWARF's forward decl of a template should have template parameters.

2017-09-27 Thread Robinson, Paul via cfe-commits
(though perhaps we had some position that debugger tuning wouldn't ever be the 
only way to access functionality, only change defaults)

That's correct.  Tuning must unpack to other settings that can be set 
separately.  That was very strong feedback from when we introduced the tuning 
concept.
--paulr

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


[PATCH] D38186: Add the new -Wnull-pointer-arithmetic warnings to the release notes

2017-09-27 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added inline comments.



Comment at: ReleaseNotes.rst:82
+- ``-Wnull-pointer-arithmetic`` now warns about performing pointer arithmetic
+  on a null pointer. It has an undefined behavior if the offset is nonzero.
+

We can probably just make this one entry:

  ``-Wnull-pointer-arithmetic`` now warns about performing pointer arithmetic 
on a null pointer. Such pointer arithmetic has an undefined behavior if the 
offset is nonzero. It also now warns about arithmetic on a null pointer treated 
as a cast from integer to pointer (GNU extension).



https://reviews.llvm.org/D38186



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


[PATCH] D30295: [analyzer] clarify undef shift result when shift count is negative or exceeds the bit width

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

fixed review comments


Repository:
  rL LLVM

https://reviews.llvm.org/D30295

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
  lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
  lib/StaticAnalyzer/Core/CheckerContext.cpp
  test/Analysis/bitwise-ops.c

Index: test/Analysis/bitwise-ops.c
===
--- test/Analysis/bitwise-ops.c
+++ test/Analysis/bitwise-ops.c
@@ -22,11 +22,25 @@
   case 1:
 return 0ULL << 63; // no-warning
   case 2:
-return 0ULL << 64; // expected-warning{{The result of the '<<' expression is undefined}}
+return 0ULL << 64; // expected-warning{{The result of the left shift is undefined due to shifting by '64', which is larger or equal to the width of type 'unsigned long long'}}
   case 3:
-return 0ULL << 65; // expected-warning{{The result of the '<<' expression is undefined}}
+return 0ULL << 65; // expected-warning{{The result of the left shift is undefined due to shifting by '65', which is larger or equal to the width of type 'unsigned long long'}}
 
   default:
 return 0;
   }
-}
\ No newline at end of file
+}
+
+int testOverflowShift(int a) {
+  if (a == 323) {
+return 1 << a; // expected-warning{{The result of the left shift is undefined due to shifting by '323', which is larger or equal to the width of type 'int'}}
+  }
+  return 0;
+}
+
+int testNegativeShift(int a) {
+  if (a == -5) {
+return 1 << a; // expected-warning{{The result of the left shift is undefined because the right operand is negative}}
+  }
+  return 0;
+}
Index: lib/StaticAnalyzer/Core/CheckerContext.cpp
===
--- lib/StaticAnalyzer/Core/CheckerContext.cpp
+++ lib/StaticAnalyzer/Core/CheckerContext.cpp
@@ -99,3 +99,35 @@
   return Lexer::getSpelling(Loc, buf, getSourceManager(), getLangOpts());
 }
 
+/// Evaluate comparison and return true if it's known that condition is true
+static bool evalComparison(SVal LHSVal, BinaryOperatorKind ComparisonOp,
+   SVal RHSVal, ProgramStateRef State) {
+  if (LHSVal.isUnknownOrUndef())
+return false;
+  ProgramStateManager &Mgr = State->getStateManager();
+  if (!LHSVal.getAs()) {
+LHSVal = Mgr.getStoreManager().getBinding(State->getStore(),
+  LHSVal.castAs());
+if (LHSVal.isUnknownOrUndef() || !LHSVal.getAs())
+  return false;
+  }
+
+  SValBuilder &Bldr = Mgr.getSValBuilder();
+  SVal Eval = Bldr.evalBinOp(State, ComparisonOp, LHSVal, RHSVal,
+ Bldr.getConditionType());
+  if (Eval.isUnknownOrUndef())
+return false;
+  ProgramStateRef StTrue, StFalse;
+  std::tie(StTrue, StFalse) = State->assume(Eval.castAs());
+  return StTrue && !StFalse;
+}
+
+bool CheckerContext::isGreaterOrEqual(const Expr *E, unsigned long long Val) {
+  DefinedSVal V = getSValBuilder().makeIntVal(Val, getASTContext().LongLongTy);
+  return evalComparison(getSVal(E), BO_GE, V, getState());
+}
+
+bool CheckerContext::isNegative(const Expr *E) {
+  DefinedSVal V = getSValBuilder().makeIntVal(0, false);
+  return evalComparison(getSVal(E), BO_LT, V, getState());
+}
Index: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
@@ -59,6 +59,11 @@
   return StOutBound && !StInBound;
 }
 
+static bool isShiftOverflow(const BinaryOperator *B, CheckerContext &C) {
+  return C.isGreaterOrEqual(
+  B->getRHS(), C.getASTContext().getIntWidth(B->getLHS()->getType()));
+}
+
 void UndefResultChecker::checkPostStmt(const BinaryOperator *B,
CheckerContext &C) const {
   ProgramStateRef state = C.getState();
@@ -97,18 +102,46 @@
 }
 
 if (Ex) {
-  OS << "The " << (isLeft ? "left" : "right")
- << " operand of '"
+  OS << "The " << (isLeft ? "left" : "right") << " operand of '"
  << BinaryOperator::getOpcodeStr(B->getOpcode())
  << "' is a garbage value";
   if (isArrayIndexOutOfBounds(C, Ex))
 OS << " due to array index out of bounds";
-}
-else {
+} else {
   // Neither operand was undefined, but the result is undefined.
-  OS << "The result of the '"
- << BinaryOperator::getOpcodeStr(B->getOpcode())
- << "' expression is undefined";
+  if ((B->getOpcode() == BinaryOperatorKind::BO_Shl ||
+   B->getOpcode() == BinaryOperatorKind::BO_Shr) &&
+  C.isNegative(B->getRHS())) {
+OS << "The result of the "
+   << ((B->getOpcode() == BinaryOperatorKind::BO_Shl) ? "left"
+  : "right")
+   << " shi

r314336 - Add support for remembering origins to ExternalASTMerger

2017-09-27 Thread Sean Callanan via cfe-commits
Author: spyffe
Date: Wed Sep 27 12:57:58 2017
New Revision: 314336

URL: http://llvm.org/viewvc/llvm-project?rev=314336&view=rev
Log:
Add support for remembering origins to ExternalASTMerger

ExternalASTMerger has hitherto relied on being able to look up 
any Decl through its named DeclContext chain. This works for 
many cases, but causes problems for function-local structs, 
which cannot be looked up in their containing FunctionDecl. An
example case is

void f() {
  { struct S { int a; }; }
  { struct S { bool b; }; }
}

It is not possible to lookup either of the two Ses individually 
(or even to provide enough information to disambiguate) after 
parsing is over; and there is typically no need to, since they 
are invisible to the outside world.

However, ExternalASTMerger needs to be able to complete either 
S on demand. This led to an XFAIL on test/Import/local-struct, 
which this patch removes. The way the patch works is:

It defines a new data structure, ExternalASTMerger::OriginMap,
which clients are expected to maintain (default-constructing 
if the origin does not have an ExternalASTMerger servicing it)
As DeclContexts are imported, if they cannot be looked up by 
name they are placed in the OriginMap. This allows 
ExternalASTMerger to complete them later if necessary.
As DeclContexts are imported from an origin that already has 
its own OriginMap, the origins are forwarded – but only for 
those DeclContexts that are actually used. This keeps the 
amount of stored data minimal.

The patch also applies several improvements from review:

- Thoroughly documents the interface to ExternalASTMerger;
- Adds optional logging to help track what's going on; and
- Cleans up a bunch of braces and dangling elses.

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

Added:
cfe/trunk/test/Import/extern-c-function/
  - copied from r311017, cfe/trunk/test/Import/overloaded-function/
cfe/trunk/test/Import/extern-c-function/Inputs/F.cpp
  - copied, changed from r311017, 
cfe/trunk/test/Import/overloaded-function/Inputs/F1.c
cfe/trunk/test/Import/extern-c-function/test.cpp
  - copied, changed from r311017, 
cfe/trunk/test/Import/overloaded-function/test.c
cfe/trunk/test/Import/forward-declared-objc-class/
  - copied from r311468, cfe/trunk/test/Import/forward-declared-struct/
cfe/trunk/test/Import/forward-declared-objc-class/Inputs/S1.m
  - copied, changed from r311468, 
cfe/trunk/test/Import/forward-declared-struct/Inputs/S1.c
cfe/trunk/test/Import/forward-declared-objc-class/Inputs/S2.m
  - copied, changed from r311468, 
cfe/trunk/test/Import/forward-declared-struct/Inputs/S2.c
cfe/trunk/test/Import/forward-declared-objc-class/Inputs/S3.m
  - copied, changed from r311468, 
cfe/trunk/test/Import/forward-declared-struct/Inputs/S1.c
cfe/trunk/test/Import/forward-declared-objc-class/test.m
  - copied, changed from r311468, 
cfe/trunk/test/Import/forward-declared-struct/test.c
cfe/trunk/test/Import/forward-declared-struct/Inputs/S3.c
  - copied unchanged from r311468, 
cfe/trunk/test/Import/forward-declared-struct/Inputs/S1.c
cfe/trunk/test/Import/local-struct-use-origins/
  - copied from r310656, cfe/trunk/test/Import/local-struct/
cfe/trunk/test/Import/objc-definitions-in-expression/
  - copied from r311468, cfe/trunk/test/Import/objc-method/
cfe/trunk/test/Import/struct-and-var/
  - copied from r310656, cfe/trunk/test/Import/conflicting-struct/
cfe/trunk/test/Import/template/
  - copied from r310656, cfe/trunk/test/Import/template-specialization/
Removed:
cfe/trunk/test/Import/extern-c-function/Inputs/F1.c
cfe/trunk/test/Import/extern-c-function/Inputs/F2.c
cfe/trunk/test/Import/extern-c-function/test.c
cfe/trunk/test/Import/forward-declared-objc-class/Inputs/S1.c
cfe/trunk/test/Import/forward-declared-objc-class/Inputs/S2.c
cfe/trunk/test/Import/forward-declared-objc-class/test.c
Modified:
cfe/trunk/include/clang/AST/ExternalASTMerger.h
cfe/trunk/lib/AST/ExternalASTMerger.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/Import/forward-declared-struct/test.c
cfe/trunk/test/Import/local-struct-use-origins/test.cpp
cfe/trunk/test/Import/local-struct/test.cpp
cfe/trunk/test/Import/objc-definitions-in-expression/test.m
cfe/trunk/test/Import/struct-and-var/Inputs/S1.cpp
cfe/trunk/test/Import/struct-and-var/Inputs/S2.cpp
cfe/trunk/test/Import/struct-and-var/test.cpp
cfe/trunk/test/Import/template/Inputs/T.cpp
cfe/trunk/test/Import/template/test.cpp
cfe/trunk/tools/clang-import-test/clang-import-test.cpp

Modified: cfe/trunk/include/clang/AST/ExternalASTMerger.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTMerger.h?rev=314336&r1=314335&r2=314336&view=diff
==
--- cfe/trunk/include/clang/AST/ExternalASTMerger.h (original)
+++ cfe/trunk

[PATCH] D38208: Add support for remembering origins to ExternalASTMerger

2017-09-27 Thread Sean Callanan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314336: Add support for remembering origins to 
ExternalASTMerger (authored by spyffe).

Changed prior to commit:
  https://reviews.llvm.org/D38208?vs=116680&id=116868#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38208

Files:
  cfe/trunk/include/clang/AST/ExternalASTMerger.h
  cfe/trunk/lib/AST/ExternalASTMerger.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/Import/extern-c-function/Inputs/F.cpp
  cfe/trunk/test/Import/extern-c-function/test.cpp
  cfe/trunk/test/Import/forward-declared-objc-class/Inputs/S1.m
  cfe/trunk/test/Import/forward-declared-objc-class/Inputs/S2.m
  cfe/trunk/test/Import/forward-declared-objc-class/Inputs/S3.m
  cfe/trunk/test/Import/forward-declared-objc-class/test.m
  cfe/trunk/test/Import/forward-declared-struct/Inputs/S3.c
  cfe/trunk/test/Import/forward-declared-struct/test.c
  cfe/trunk/test/Import/local-struct-use-origins/Inputs/Callee.cpp
  cfe/trunk/test/Import/local-struct-use-origins/test.cpp
  cfe/trunk/test/Import/local-struct/test.cpp
  cfe/trunk/test/Import/objc-definitions-in-expression/Inputs/S.m
  cfe/trunk/test/Import/objc-definitions-in-expression/test.m
  cfe/trunk/test/Import/struct-and-var/Inputs/S1.cpp
  cfe/trunk/test/Import/struct-and-var/Inputs/S2.cpp
  cfe/trunk/test/Import/struct-and-var/test.cpp
  cfe/trunk/test/Import/template/Inputs/T.cpp
  cfe/trunk/test/Import/template/test.cpp
  cfe/trunk/tools/clang-import-test/clang-import-test.cpp

Index: cfe/trunk/lib/AST/ExternalASTMerger.cpp
===
--- cfe/trunk/lib/AST/ExternalASTMerger.cpp
+++ cfe/trunk/lib/AST/ExternalASTMerger.cpp
@@ -14,6 +14,7 @@
 
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/ExternalASTMerger.h"
 
@@ -32,29 +33,18 @@
 
 typedef std::pair, ASTImporter *> Candidate;
 
-class LazyASTImporter : public ASTImporter {
-public:
-  LazyASTImporter(ASTContext &ToContext, FileManager &ToFileManager,
-  ASTContext &FromContext, FileManager &FromFileManager)
-  : ASTImporter(ToContext, ToFileManager, FromContext, FromFileManager,
-/*MinimalImport=*/true) {}
-  Decl *Imported(Decl *From, Decl *To) override {
-if (auto ToTag = dyn_cast(To)) {
-  ToTag->setHasExternalLexicalStorage();
-  ToTag->setMustBuildLookupTable();
-} else if (auto ToNamespace = dyn_cast(To)) {
-  ToNamespace->setHasExternalVisibleStorage();
-} else if (auto ToContainer = dyn_cast(To)) {
-  ToContainer->setHasExternalLexicalStorage();
-  ToContainer->setMustBuildLookupTable();
-}
-return ASTImporter::Imported(From, To);
-  }
-};
+/// For the given DC, return the DC that is safe to perform lookups on.  This is
+/// the DC we actually want to work with most of the time.
+const DeclContext *CanonicalizeDC(const DeclContext *DC) {
+  if (isa(DC))
+return DC->getRedeclContext();
+  return DC;
+}
 
 Source
 LookupSameContext(Source SourceTU, const DeclContext *DC,
   ASTImporter &ReverseImporter) {
+  DC = CanonicalizeDC(DC);
   if (DC->isTranslationUnit()) {
 return SourceTU;
   }
@@ -64,101 +54,328 @@
 // If we couldn't find the parent DC in this TranslationUnit, give up.
 return nullptr;
   }
-  auto ND = cast(DC);
+  auto *ND = cast(DC);
   DeclarationName Name = ND->getDeclName();
   Source SourceName = ReverseImporter.Import(Name);
   DeclContext::lookup_result SearchResult =
   SourceParentDC.get()->lookup(SourceName.get());
   size_t SearchResultSize = SearchResult.size();
-  // Handle multiple candidates once we have a test for it.
-  // This may turn up when we import template specializations correctly.
-  assert(SearchResultSize < 2);
-  if (SearchResultSize == 0) {
-// couldn't find the name, so we have to give up
+  if (SearchResultSize == 0 || SearchResultSize > 1) {
+// There are two cases here.  First, we might not find the name.
+// We might also find multiple copies, in which case we have no
+// guarantee that the one we wanted is the one we pick.  (E.g.,
+// if we have two specializations of the same template it is
+// very hard to determine which is the one you want.)
+//
+// The Origins map fixes this problem by allowing the origin to be
+// explicitly recorded, so we trigger that recording by returning
+// nothing (rather than a possibly-inaccurate guess) here.
 return nullptr;
   } else {
 NamedDecl *SearchResultDecl = SearchResult[0];
-return dyn_cast(SearchResultDecl);
+if (isa(SearchResultDecl) &&
+SearchResultDecl->getKind() == DC->getDeclKind())
+  return cast(SearchResultDecl)->getPrimaryContext();
+return nullptr; // This type of lookup is unsupported
   }
 }
 
-bool IsForwardDeclaration(Decl *D) {
-  if (auto TD = dyn_cast(D)) {
-return !TD->is

[PATCH] D37822: [OpenCL] Clean up and add missing fields for block struct

2017-09-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 4 inline comments as done.
yaxunl added inline comments.



Comment at: lib/CodeGen/CGBlocks.cpp:311
+// The header is basically 'struct { int; int; generic void *;
+// custom_fields; }'. Assert that that struct is packed.
+auto GenPtrAlign = CharUnits::fromQuantity(

Anastasia wrote:
> remove one "that".
will do.



Comment at: lib/CodeGen/CGBlocks.cpp:312
+// custom_fields; }'. Assert that that struct is packed.
+auto GenPtrAlign = CharUnits::fromQuantity(
+CGM.getTarget().getPointerAlign(LangAS::opencl_generic) / 8);

Anastasia wrote:
> I think the alignment might not be computed correctly now if there will be 
> custom fields that might have a bigger size than a pointer? Also what happens 
> if we have captures as well?
Will fix.

The captures will be accounted for by computeBlockInfo and BlockSize and 
BlockAlign will be updated.



Comment at: lib/CodeGen/CGBlocks.cpp:850
+   CGM.getDataLayout().getTypeAllocSize(I->getType())),
+   "block.custom");
+  }

Anastasia wrote:
> do we need to add numeration to each item name?
yes. will add it.



Comment at: lib/CodeGen/CGBlocks.cpp:1250
   // Function
   fields.add(blockFn);
 

Anastasia wrote:
> If we reorder fields and put this on top we can merge the if statements above 
> and below this point.
By convention the size of the whole struct is the first field so that the 
library function reads the first integer and knows how many bytes to copy.


https://reviews.llvm.org/D37822



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


[PATCH] D14358: DWARF's forward decl of a template should have template parameters.

2017-09-27 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Looks OK to me - couple of minor questions.




Comment at: include/clang/Frontend/CodeGenOptions.def:222
 ///< of inline stack frames without .dwo 
files.
+CODEGENOPT(DebugFwdTemplateParams, 1, 0) ///< Whether to emit complete
+ ///< template parameter descriptions 
in

Maybe 'Decl' rather than 'Fwd'.



Comment at: test/CodeGenCXX/debug-info-fwd-template-param.cpp:7
+template class A;
+A *p;
+

Any particular reason for const int, rather than int?


https://reviews.llvm.org/D14358



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


[PATCH] D38303: [Sema] Correct IUnknown to support Unknwnbase.h Header.

2017-09-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 116876.
erichkeane added a comment.

As @rnk suggested, pull my condition out into a static function.


https://reviews.llvm.org/D38303

Files:
  lib/AST/DeclCXX.cpp
  test/SemaCXX/ms-iunknown-template-function.cpp
  test/SemaCXX/ms-iunknown.cpp

Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1470,6 +1470,15 @@
   return false;
 }
 
+static bool IsDeclContextInNamespace(const DeclContext *DC) {
+  while (!DC->isTranslationUnit()) {
+if (DC->isNamespace())
+  return true;
+DC = DC->getParent();
+  }
+  return false;
+}
+
 bool CXXRecordDecl::isInterfaceLike() const {
   assert(hasDefinition() && "checking for interface-like without a definition");
   // All __interfaces are inheritently interface-like.
@@ -1486,13 +1495,16 @@
 
   // No interface-like type can have a method with a definition.
   for (const auto *const Method : methods())
-if (Method->isDefined())
+if (Method->isDefined() && !Method->isImplicit())
   return false;
 
   // Check "Special" types.
   const auto *Uuid = getAttr();
-  if (Uuid && isStruct() && (getDeclContext()->isTranslationUnit() ||
- getDeclContext()->isExternCXXContext()) &&
+  // MS SDK declares IUnknown/IDispatch both in the root of a TU, or in an
+  // extern C++ block directly in the TU.  These are only valid if in one
+  // of these two situations.
+  if (Uuid && isStruct() && !getDeclContext()->isExternCContext() &&
+  !IsDeclContextInNamespace(getDeclContext()) &&
   ((getName() == "IUnknown" &&
 Uuid->getGuid() == "---C000-0046") ||
(getName() == "IDispatch" &&
Index: test/SemaCXX/ms-iunknown-template-function.cpp
===
--- test/SemaCXX/ms-iunknown-template-function.cpp
+++ test/SemaCXX/ms-iunknown-template-function.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s 
+typedef long HRESULT;
+typedef unsigned long ULONG;
+typedef struct _GUID {
+  unsigned long Data1;
+  unsigned short Data2;
+  unsigned short Data3;
+  unsigned char Data4[8];
+} GUID;
+typedef GUID IID;
+
+// remove stdcall, since the warnings have nothing to do with
+// what is being tested.
+#define __stdcall
+
+extern "C" {
+extern "C++" {
+// expected-warning@+1 {{__declspec attribute 'novtable'}}
+struct __declspec(uuid("---C000-0046")) __declspec(novtable)
+IUnknown {
+public:
+  virtual HRESULT __stdcall QueryInterface(
+  const IID &riid,
+  void **ppvObject) = 0;
+
+  virtual ULONG __stdcall AddRef(void) = 0;
+
+  virtual ULONG __stdcall Release(void) = 0;
+
+  template 
+  HRESULT __stdcall QueryInterface(Q **pp) {
+return QueryInterface(__uuidof(Q), (void **)pp);
+  }
+};
+}
+}
+
+__interface ISfFileIOPropertyPage : public IUnknown{};
+
Index: test/SemaCXX/ms-iunknown.cpp
===
--- test/SemaCXX/ms-iunknown.cpp
+++ test/SemaCXX/ms-iunknown.cpp
@@ -2,19 +2,30 @@
 
 extern "C++" struct __declspec(uuid("---C000-0046")) IUnknown {
   void foo();
+  // Definitions aren't allowed, unless they are a template.
+  template
+  void bar(T t){}
 };
+
 struct IPropertyPageBase : public IUnknown {};
 struct IPropertyPage : public IPropertyPageBase {};
 __interface ISfFileIOPropertyPage : public IPropertyPage {};
 
 
 namespace NS {
   struct __declspec(uuid("---C000-0046")) IUnknown {};
   // expected-error@+1 {{interface type cannot inherit from}}
-  __interface IPropertyPageBase : public IUnknown {}; 
+  __interface IPropertyPageBase : public IUnknown {};
 }
+
+namespace NS2 {
+extern "C++" struct __declspec(uuid("---C000-0046")) IUnknown {};
+// expected-error@+1 {{interface type cannot inherit from}}
+__interface IPropertyPageBase : public IUnknown{};
+}
+
 // expected-error@+1 {{interface type cannot inherit from}}
-__interface IPropertyPageBase2 : public NS::IUnknown {}; 
+__interface IPropertyPageBase2 : public NS::IUnknown {};
 
 __interface temp_iface {};
 struct bad_base : temp_iface {};
@@ -32,8 +43,8 @@
 
 struct Page5 : public Page3, Page4{};
 // expected-error@+1 {{interface type cannot inherit from}}
-__interface PropertyPage2 : public Page5 {}; 
+__interface PropertyPage2 : public Page5 {};
 
 __interface IF1 {};
-__interface PP : IUnknown, IF1{}; 
+__interface PP : IUnknown, IF1{};
 __interface PP2 : PP, Page3, Page4{};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37822: [OpenCL] Clean up and add missing fields for block struct

2017-09-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 116877.
yaxunl marked 4 inline comments as done.
yaxunl added a comment.

Rebased to ToT and revised by Anastasia's comments.


https://reviews.llvm.org/D37822

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  lib/CodeGen/TargetInfo.h
  test/CodeGen/blocks-opencl.cl
  test/CodeGenOpenCL/blocks.cl
  test/CodeGenOpenCL/cl20-device-side-enqueue.cl

Index: test/CodeGenOpenCL/cl20-device-side-enqueue.cl
===
--- test/CodeGenOpenCL/cl20-device-side-enqueue.cl
+++ test/CodeGenOpenCL/cl20-device-side-enqueue.cl
@@ -7,7 +7,7 @@
 typedef struct {int a;} ndrange_t;
 
 // N.B. The check here only exists to set BL_GLOBAL
-// COMMON: @block_G =  addrspace(1) constant void (i8 addrspace(3)*) addrspace(4)* addrspacecast (void (i8 addrspace(3)*) addrspace(1)* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor addrspace(2)* } addrspace(1)* [[BL_GLOBAL:@__block_literal_global(\.[0-9]+)?]] to void (i8 addrspace(3)*) addrspace(1)*) to void (i8 addrspace(3)*) addrspace(4)*)
+// COMMON: @block_G =  addrspace(1) constant void (i8 addrspace(3)*) addrspace(4)* addrspacecast (void (i8 addrspace(3)*) addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL:@__block_literal_global(\.[0-9]+)?]] to void (i8 addrspace(3)*) addrspace(1)*) to void (i8 addrspace(3)*) addrspace(4)*)
 const bl_t block_G = (bl_t) ^ (local void *a) {};
 
 kernel void device_side_enqueue(global int *a, global int *b, int i) {
@@ -27,9 +27,10 @@
   // COMMON: [[NDR:%[a-z0-9]+]] = alloca %struct.ndrange_t, align 4
   // COMMON: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t{{.*}}*, %opencl.queue_t{{.*}}** %default_queue
   // COMMON: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
-  // COMMON: [[BL:%[0-9]+]] = bitcast <{ i8*, i32, i32, i8*, %struct.__block_descriptor addrspace(2)*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block to void ()*
+  // B32: [[BL:%[0-9]+]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32, i32 addrspace(1)* }>* %block to void ()*
+  // B64: [[BL:%[0-9]+]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32 addrspace(1)*, i32 addrspace(1)*, i32 }>* %block to void ()*
   // COMMON: [[BL_I8:%[0-9]+]] = addrspacecast void ()* [[BL]] to i8 addrspace(4)*
-  // COMMON: call i32 @__enqueue_kernel_basic(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* byval [[NDR]]{{(.[0-9]+)?}}, i8 addrspace(4)* [[BL_I8]])
+  // COMMON: call i32 @__enqueue_kernel_basic(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* byval [[NDR]]{{([0-9]+)?}}, i8 addrspace(4)* [[BL_I8]])
   enqueue_kernel(default_queue, flags, ndrange,
  ^(void) {
a[i] = b[i];
@@ -39,7 +40,7 @@
   // COMMON: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
   // COMMON: [[WAIT_EVNT:%[0-9]+]] = addrspacecast %opencl.clk_event_t{{.*}}** %event_wait_list to %opencl.clk_event_t{{.*}}* addrspace(4)*
   // COMMON: [[EVNT:%[0-9]+]] = addrspacecast %opencl.clk_event_t{{.*}}** %clk_event to %opencl.clk_event_t{{.*}}* addrspace(4)*
-  // COMMON: [[BL:%[0-9]+]] = bitcast <{ i8*, i32, i32, i8*, %struct.__block_descriptor addrspace(2)*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block3 to void ()*
+  // COMMON: [[BL:%[0-9]+]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block3 to void ()*
   // COMMON: [[BL_I8:%[0-9]+]] = addrspacecast void ()* [[BL]] to i8 addrspace(4)*
   // COMMON: call i32 @__enqueue_kernel_basic_events(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]],  %struct.ndrange_t* {{.*}}, i32 2, %opencl.clk_event_t{{.*}}* addrspace(4)* [[WAIT_EVNT]], %opencl.clk_event_t{{.*}}* addrspace(4)* [[EVNT]], i8 addrspace(4)* [[BL_I8]])
   enqueue_kernel(default_queue, flags, ndrange, 2, &event_wait_list, &clk_event,
@@ -52,11 +53,11 @@
   // B32: %[[TMP:.*]] = alloca [1 x i32]
   // B32: %[[TMP1:.*]] = getelementptr [1 x i32], [1 x i32]* %[[TMP]], i32 0, i32 0
   // B32: store i32 256, i32* %[[TMP1]], align 4
-  // B32: call i32 @__enqueue_kernel_vaargs(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{(.[0-9]+)?}}, i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor addrspace(2)* } addrspace(1)* @__block_literal_global{{(.[0-9]+)?}} to i8 addrspace(1)*) to i8 addrspace(4)*), i32 1, i32* %[[TMP1]])
+  // B32: call i32 @__enqueue_kernel_vaargs(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{([0-9]+)?}}, i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* @__block_literal_global{{(.[0-9]+)?}} to i8 addrspace(1)*) to i8 addrspace(4)*), i32 1, i32* %[[TMP1]])
   // B64: %[[TMP:.*]] = alloca [1 x i64]
   // B64: %[[TMP1:.*]] = getelementptr [1 x i64], [1 x i64]* %[[TMP]], i32 0, i32 0
   // B64: store i64 256, i64* %[[TMP1]], align 8
-  // B64: call i32 @__enqueue_kernel_vaargs(%opencl

[PATCH] D14358: DWARF's forward decl of a template should have template parameters.

2017-09-27 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a reviewer: rnk.
probinson added a comment.

+rnk for the CodeView question.




Comment at: include/clang/Frontend/CodeGenOptions.def:222
 ///< of inline stack frames without .dwo 
files.
+CODEGENOPT(DebugFwdTemplateParams, 1, 0) ///< Whether to emit complete
+ ///< template parameter descriptions 
in

dblaikie wrote:
> Maybe 'Decl' rather than 'Fwd'.
Well, in a sense they are all declarations, and 'Fwd' is a clearer statement of 
the distinction this flag is trying to make.  Unless you feel strongly I'd 
prefer to leave it as is.



Comment at: lib/CodeGen/CGDebugInfo.cpp:836
   llvm::DINode::FlagFwdDecl, FullName);
+  if (CGM.getCodeGenOpts().DebugFwdTemplateParams)
+if (auto *TSpecial = dyn_cast(RD))

It just occurred to me... should CodeView care about this?



Comment at: test/CodeGenCXX/debug-info-fwd-template-param.cpp:7
+template class A;
+A *p;
+

dblaikie wrote:
> Any particular reason for const int, rather than int?
It was the illustrative example of the difference between the demangler ("int 
const") and clang ("const int") that the debugger guys tripped over, and so was 
in the source I started with when creating this test.  I think you are correct, 
it is not important to have it.



https://reviews.llvm.org/D14358



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


Re: [PATCH] D14358: DWARF's forward decl of a template should have template parameters.

2017-09-27 Thread David Blaikie via cfe-commits
On Wed, Sep 27, 2017 at 1:58 PM Paul Robinson via Phabricator <
revi...@reviews.llvm.org> wrote:

> probinson added a reviewer: rnk.
> probinson added a comment.
>
> +rnk for the CodeView question.
>
>
>
> 
> Comment at: include/clang/Frontend/CodeGenOptions.def:222
>  ///< of inline stack frames without
> .dwo files.
> +CODEGENOPT(DebugFwdTemplateParams, 1, 0) ///< Whether to emit complete
> + ///< template parameter
> descriptions in
> 
> dblaikie wrote:
> > Maybe 'Decl' rather than 'Fwd'.
> Well, in a sense they are all declarations, and 'Fwd' is a clearer
> statement of the distinction this flag is trying to make.  Unless you feel
> strongly I'd prefer to leave it as is.
>

Fair enough.


> 
> Comment at: lib/CodeGen/CGDebugInfo.cpp:836
>llvm::DINode::FlagFwdDecl, FullName);
> +  if (CGM.getCodeGenOpts().DebugFwdTemplateParams)
> +if (auto *TSpecial = dyn_cast(RD))
> 
> It just occurred to me... should CodeView care about this?
>

Not sure

Reid?


>
>
> 
> Comment at: test/CodeGenCXX/debug-info-fwd-template-param.cpp:7
> +template class A;
> +A *p;
> +
> 
> dblaikie wrote:
> > Any particular reason for const int, rather than int?
> It was the illustrative example of the difference between the demangler
> ("int const") and clang ("const int") that the debugger guys tripped over,
> and so was in the source I started with when creating this test.  I think
> you are correct, it is not important to have it.
>

*nod* I understand that it's part of the original issue, but doesn't seem
needed/relevant here.  Thanks! :)


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


[PATCH] D37855: [bindings] allow null strings in Python 3

2017-09-27 Thread Masud Rahman via Phabricator via cfe-commits
frutiger added a comment.

//Friendly poke!//


https://reviews.llvm.org/D37855



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


[PATCH] D37905: [libclang, bindings]: add spelling location

2017-09-27 Thread Masud Rahman via Phabricator via cfe-commits
frutiger added a comment.

//Friendly poke!//


https://reviews.llvm.org/D37905



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


r314354 - [AVR] Update data layout to match current LLVM trunk

2017-09-27 Thread Dylan McKay via cfe-commits
Author: dylanmckay
Date: Wed Sep 27 15:09:01 2017
New Revision: 314354

URL: http://llvm.org/viewvc/llvm-project?rev=314354&view=rev
Log:
[AVR] Update data layout to match current LLVM trunk

The data layout was changed in r314179 to fix atomic loads and stores.

Modified:
cfe/trunk/lib/Basic/Targets/AVR.h

Modified: cfe/trunk/lib/Basic/Targets/AVR.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AVR.h?rev=314354&r1=314353&r2=314354&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AVR.h (original)
+++ cfe/trunk/lib/Basic/Targets/AVR.h Wed Sep 27 15:09:01 2017
@@ -56,8 +56,7 @@ public:
 WIntType = SignedInt;
 Char32Type = UnsignedLong;
 SigAtomicType = SignedChar;
-resetDataLayout("e-p:16:16:16-i8:8:8-i16:16:16-i32:32:32-i64:64:64"
-"-f32:32:32-f64:64:64-n8");
+resetDataLayout("e-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8");
   }
 
   void getTargetDefines(const LangOptions &Opts,


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


[PATCH] D38205: [Sema] Warn on attribute nothrow conflicting with language specifiers

2017-09-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 116892.
erichkeane marked 2 inline comments as done.
erichkeane added a comment.

changes that were suggested by @aaron.ballman

It DOES warn on the template correctly, however I'm not thrilled that it misses 
the 'warning' info.  Any idea how I can get that information to give that 
'note'?  I'd like an "in instantiation of template ..." type note.


https://reviews.llvm.org/D38205

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclAttr.cpp
  test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp


Index: test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify 
-std=c++14
+
+struct S {
+  //expected-warning@+2 {{Attribute nothrow ignored due to conflicting 
exception specification}}
+  //expected-note@+1 {{exception specification declared here}}
+  __attribute__((nothrow)) S() noexcept(true);
+  //expected-warning@+2 {{Attribute nothrow ignored due to conflicting 
exception specification}}
+  //expected-note@+1 {{exception specification declared here}}
+  __attribute__((nothrow)) void Func1() noexcept(false);
+  __attribute__((nothrow)) void Func3() noexcept;
+};
+
+void throwing() noexcept(false);
+void non_throwing(bool b = true) noexcept;
+
+template 
+struct T {
+__attribute__((nothrow)) void f(Fn) noexcept(Fn());
+};
+
+//expected-warning@-3 {{Attribute nothrow ignored due to conflicting exception 
specification}}
+//expected-note@-4 {{exception specification declared here}}
+template struct T;
+template struct T;
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -1985,6 +1985,25 @@
   attr.getRange(), S.Context, attr.getAttributeSpellingListIndex()));
 }
 
+static void handleNoThrowAttr(Sema &S, Decl *D, const AttributeList &Attrs) {
+  assert(isa(D) && "attribute nothrow only valid on functions");
+
+  auto *FD = cast(D);
+  const auto *FPT = FD->getType()->getAs();
+
+  if (FPT && FPT->hasExceptionSpec() &&
+  FPT->getExceptionSpecType() != EST_BasicNoexcept) {
+S.Diag(Attrs.getLoc(),
+   diag::warn_nothrow_attr_disagrees_with_exception_specification);
+S.Diag(FD->getExceptionSpecSourceRange().getBegin(),
+   diag::note_previous_decl)
+<< "exception specification";
+  }
+
+  D->addAttr(::new (S.Context) NoThrowAttr(
+  Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex()));
+}
+
 static void handleNoCallerSavedRegsAttr(Sema &S, Decl *D,
 const AttributeList &Attr) {
   if (S.CheckNoCallerSavedRegsAttr(Attr))
@@ -6211,7 +6230,7 @@
 handleNoReturnAttr(S, D, Attr);
 break;
   case AttributeList::AT_NoThrow:
-handleSimpleAttribute(S, D, Attr);
+handleNoThrowAttr(S, D, Attr);
 break;
   case AttributeList::AT_CUDAShared:
 handleSharedAttr(S, D, Attr);
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -1407,6 +1407,10 @@
   "argument to noexcept specifier must be a constant expression">;
 def err_exception_spec_not_parsed : Error<
   "exception specification is not available until end of class definition">;
+def warn_nothrow_attr_disagrees_with_exception_specification
+: ExtWarn<"Attribute nothrow ignored due to conflicting exception "
+  "specification">,
+  InGroup;
 
 // C++ access checking
 def err_class_redeclared_with_different_access : Error<


Index: test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify -std=c++14
+
+struct S {
+  //expected-warning@+2 {{Attribute nothrow ignored due to conflicting exception specification}}
+  //expected-note@+1 {{exception specification declared here}}
+  __attribute__((nothrow)) S() noexcept(true);
+  //expected-warning@+2 {{Attribute nothrow ignored due to conflicting exception specification}}
+  //expected-note@+1 {{exception specification declared here}}
+  __attribute__((nothrow)) void Func1() noexcept(false);
+  __attribute__((nothrow)) void Func3() noexcept;
+};
+
+void throwing() noexcept(false);
+void non_throwing(bool b = true) noexcept;
+
+template 
+struct T {
+__attribute__((nothrow)) void f(Fn) noexcept(Fn());
+};
+
+//expected-warning@-3 {{Attribute nothrow ignored due to conflicting exception specification}}
+//expected-note@-4 {{exception specification declared here}}
+te

[PATCH] D38270: [clang] Add getUnsignedPointerDiffType method

2017-09-27 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap updated this revision to Diff 116894.
alexshap added a comment.

Address the comments


Repository:
  rL LLVM

https://reviews.llvm.org/D38270

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/Analysis/ScanfFormatString.cpp
  test/FixIt/format.m
  test/Sema/format-strings-scanf.c

Index: test/Sema/format-strings-scanf.c
===
--- test/Sema/format-strings-scanf.c
+++ test/Sema/format-strings-scanf.c
@@ -13,6 +13,16 @@
   unsigned short : (short)0,   \
   unsigned char : (signed char)0))
 typedef __SSIZE_TYPE__ ssize_t; 
+
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+#define __UNSIGNED_PTRDIFF_TYPE__  \
+  __typeof__(_Generic((__PTRDIFF_TYPE__)0, \
+  long long int : (unsigned long long int)0,   \
+  long int : (unsigned long int)0, \
+  int : (unsigned int)0,   \
+  short : (unsigned short)0,   \
+  signed char : (unsigned char)0))
+
 typedef struct _FILE FILE;
 typedef __WCHAR_TYPE__ wchar_t;
 
@@ -200,6 +210,26 @@
   scanf("%zn", &d3); // expected-warning-re{{format specifies type 'ssize_t *' (aka '{{.+}}') but the argument has type 'double *'}}
 }
 
+void test_ptrdiff_t_types() {
+  __UNSIGNED_PTRDIFF_TYPE__ p1 = 0;
+  scanf("%tu", &p1); // No warning.
+
+  double d1 = 0.;
+  scanf("%tu", &d1); // expected-warning-re{{format specifies type 'unsigned ptrdiff_t *' (aka '{{.+}}') but the argument has type 'double *'}}
+
+  ptrdiff_t p2 = 0;
+  scanf("%td", &p2); // No warning.
+  
+  double d2 = 0.;
+  scanf("%td", &d2); // expected-warning-re{{format specifies type 'ptrdiff_t *' (aka '{{.+}}') but the argument has type 'double *'}}
+
+  ptrdiff_t p3 = 0;
+  scanf("%tn", &p3); // No warning.
+  
+  double d3 = 0.;
+  scanf("%tn", &d3); // expected-warning-re{{format specifies type 'ptrdiff_t *' (aka '{{.+}}') but the argument has type 'double *'}}
+}
+
 void check_conditional_literal(char *s, int *i) {
   scanf(0 ? "%s" : "%d", i); // no warning
   scanf(1 ? "%s" : "%d", i); // expected-warning{{format specifies type 'char *'}}
Index: test/FixIt/format.m
===
--- test/FixIt/format.m
+++ test/FixIt/format.m
@@ -242,6 +242,19 @@
   // see the comment in PrintfSpecifier::fixType in PrintfFormatString.cpp.
 }
 
+void testPtrDiffTypes() {
+  printf("%tu", 0.f); // expected-warning-re{{format specifies type 'unsigned ptrdiff_t' (aka '{{.+}}') but the argument has type 'float'}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:14}:"%f"
+  
+  printf("%td", 0.f); // expected-warning-re{{format specifies type 'ptrdiff_t' (aka '{{.+}}') but the argument has type 'float'}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:14}:"%f"
+
+  short x;
+  printf("%tn", &x); // expected-warning-re{{format specifies type 'ptrdiff_t *' (aka '{{.+}}') but the argument has type 'short *'}}
+  // PrintfSpecifier::fixType doesn't handle %n, so a fix-it is not emitted,
+  // see the comment in PrintfSpecifier::fixType in PrintfFormatString.cpp.
+}
+
 void testEnum() {
   typedef enum {
 ImplicitA = 1,
Index: lib/Analysis/ScanfFormatString.cpp
===
--- lib/Analysis/ScanfFormatString.cpp
+++ lib/Analysis/ScanfFormatString.cpp
@@ -291,8 +291,8 @@
 case LengthModifier::AsSizeT:
   return ArgType::PtrTo(ArgType(Ctx.getSizeType(), "size_t"));
 case LengthModifier::AsPtrDiff:
-  // FIXME: Unsigned version of ptrdiff_t?
-  return ArgType();
+  return ArgType::PtrTo(
+  ArgType(Ctx.getUnsignedPointerDiffType(), "unsigned ptrdiff_t"));
 case LengthModifier::AsLongDouble:
   // GNU extension.
   return ArgType::PtrTo(Ctx.UnsignedLongLongTy);
Index: lib/Analysis/PrintfFormatString.cpp
===
--- lib/Analysis/PrintfFormatString.cpp
+++ lib/Analysis/PrintfFormatString.cpp
@@ -505,9 +505,7 @@
? ArgType(Ctx.UnsignedLongLongTy, "unsigned __int64")
: ArgType(Ctx.UnsignedIntTy, "unsigned __int32");
   case LengthModifier::AsPtrDiff:
-// FIXME: How to get the corresponding unsigned
-// version of ptrdiff_t?
-return ArgType();
+return ArgType(Ctx.getUnsignedPointerDiffType(), "unsigned ptrdiff_t");
   case LengthModifier::AsAllocate:
   case LengthModifier::AsMAllocate:
   case LengthModifier::AsWide:
Index: lib/AST/ASTContext.cpp

[PATCH] D36562: [Bitfield] Make the bitfield a separate location if it has width of legal integer type and its bit offset is naturally aligned for the type

2017-09-27 Thread Wei Mi via Phabricator via cfe-commits
wmi updated this revision to Diff 116896.
wmi added a comment.

Address Hal's comment. Separate bitfields to shards separated by the 
naturally-sized-and-aligned fields.


Repository:
  rL LLVM

https://reviews.llvm.org/D36562

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGRecordLayoutBuilder.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/bitfield-split.cpp

Index: test/CodeGenCXX/bitfield-split.cpp
===
--- test/CodeGenCXX/bitfield-split.cpp
+++ test/CodeGenCXX/bitfield-split.cpp
@@ -0,0 +1,162 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -ffine-grained-bitfield-accesses \
+// RUN:   -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -ffine-grained-bitfield-accesses \
+// RUN:   -emit-llvm -fsanitize=address -o - %s | FileCheck %s --check-prefix=SANITIZE
+// Check -fsplit-bitfields will be ignored since sanitizer is enabled.
+
+struct S1 {
+  unsigned f1:2;
+  unsigned f2:6;
+  unsigned f3:8;
+  unsigned f4:4;
+  unsigned f5:8;
+};
+
+S1 a1;
+unsigned read8_1() {
+  // CHECK-LABEL: @_Z7read8_1v
+  // CHECK: %bf.load = load i8, i8* getelementptr inbounds (%struct.S1, %struct.S1* @a1, i32 0, i32 1), align 1
+  // CHECK-NEXT: %bf.cast = zext i8 %bf.load to i32
+  // CHECK-NEXT: ret i32 %bf.cast
+  // SANITIZE-LABEL: @_Z7read8_1v
+  // SANITIZE: %bf.load = load i32, i32* getelementptr inbounds {{.*}}, align 4
+  // SANITIZE: %bf.lshr = lshr i32 %bf.load, 8
+  // SANITIZE: %bf.clear = and i32 %bf.lshr, 255
+  // SANITIZE: ret i32 %bf.clear
+  return a1.f3;
+}
+void write8_1() {
+  // CHECK-LABEL: @_Z8write8_1v
+  // CHECK: store i8 3, i8* getelementptr inbounds (%struct.S1, %struct.S1* @a1, i32 0, i32 1), align 1
+  // CHECK-NEXT: ret void
+  // SANITIZE-LABEL: @_Z8write8_1v
+  // SANITIZE: %bf.load = load i32, i32* getelementptr inbounds {{.*}}, align 4
+  // SANITIZE-NEXT: %bf.clear = and i32 %bf.load, -65281
+  // SANITIZE-NEXT: %bf.set = or i32 %bf.clear, 768
+  // SANITIZE-NEXT: store i32 %bf.set, i32* getelementptr inbounds {{.*}}, align 4
+  // SANITIZE-NEXT: ret void
+  a1.f3 = 3;
+}
+
+unsigned read8_2() {
+  // CHECK-LABEL: @_Z7read8_2v
+  // CHECK: %bf.load = load i16, i16* getelementptr inbounds (%struct.S1, %struct.S1* @a1, i32 0, i32 2), align 2
+  // CHECK-NEXT: %bf.lshr = lshr i16 %bf.load, 4
+  // CHECK-NEXT: %bf.clear = and i16 %bf.lshr, 255
+  // CHECK-NEXT: %bf.cast = zext i16 %bf.clear to i32
+  // CHECK-NEXT: ret i32 %bf.cast
+  // SANITIZE-LABEL: @_Z7read8_2v
+  // SANITIZE: %bf.load = load i32, i32* getelementptr inbounds {{.*}}, align 4
+  // SANITIZE-NEXT: %bf.lshr = lshr i32 %bf.load, 20
+  // SANITIZE-NEXT: %bf.clear = and i32 %bf.lshr, 255
+  // SANITIZE-NEXT: ret i32 %bf.clear
+  return a1.f5;
+}
+void write8_2() {
+  // CHECK-LABEL: @_Z8write8_2v
+  // CHECK: %bf.load = load i16, i16* getelementptr inbounds (%struct.S1, %struct.S1* @a1, i32 0, i32 2), align 2
+  // CHECK-NEXT: %bf.clear = and i16 %bf.load, -4081
+  // CHECK-NEXT: %bf.set = or i16 %bf.clear, 48
+  // CHECK-NEXT: store i16 %bf.set, i16* getelementptr inbounds (%struct.S1, %struct.S1* @a1, i32 0, i32 2), align 2
+  // CHECK-NEXT: ret void
+  // SANITIZE-LABEL: @_Z8write8_2v
+  // SANITIZE: %bf.load = load i32, i32* getelementptr inbounds {{.*}}, align 4
+  // SANITIZE-NEXT: %bf.clear = and i32 %bf.load, -267386881
+  // SANITIZE-NEXT: %bf.set = or i32 %bf.clear, 3145728
+  // SANITIZE-NEXT: store i32 %bf.set, i32* getelementptr inbounds {{.*}}, align 4
+  // SANITIZE-NEXT: ret void
+  a1.f5 = 3;
+}
+
+struct S2 {
+  unsigned long f1:16;
+  unsigned long f2:16;
+  unsigned long f3:6;
+};
+
+S2 a2;
+unsigned read16_1() {
+  // CHECK-LABEL: @_Z8read16_1v
+  // CHECK: %bf.load = load i16, i16* getelementptr inbounds (%struct.S2, %struct.S2* @a2, i32 0, i32 0), align 8
+  // CHECK-NEXT: %bf.cast = zext i16 %bf.load to i64
+  // CHECK-NEXT: %conv = trunc i64 %bf.cast to i32
+  // CHECK-NEXT: ret i32 %conv
+  // SANITIZE-LABEL: @_Z8read16_1v
+  // SANITIZE: %bf.load = load i64, i64* bitcast {{.*}}, align 8
+  // SANITIZE-NEXT: %bf.clear = and i64 %bf.load, 65535
+  // SANITIZE-NEXT: %conv = trunc i64 %bf.clear to i32
+  // SANITIZE-NEXT: ret i32 %conv
+  return a2.f1;
+}
+unsigned read16_2() {
+  // CHECK-LABEL: @_Z8read16_2v
+  // CHECK: %bf.load = load i16, i16* getelementptr inbounds (%struct.S2, %struct.S2* @a2, i32 0, i32 1), align 2
+  // CHECK-NEXT: %bf.cast = zext i16 %bf.load to i64
+  // CHECK-NEXT: %conv = trunc i64 %bf.cast to i32
+  // CHECK-NEXT: ret i32 %conv
+  // SANITIZE-LABEL: @_Z8read16_2v
+  // SANITIZE: %bf.load = load i64, i64* bitcast {{.*}}, align 8
+  // SANITIZE-NEXT: %bf.lshr = lshr i64 %bf.load, 16
+  // SANITIZE-NEXT: %bf.clear = and i64 %bf.lshr, 65535
+  // SANITIZE-NEXT: %conv = trunc i64 %bf.clear to i32
+  // SANITIZE-NEXT: ret i32 %conv
+  return a2

r314364 - [Preprocessor] Preserve #pragma clang assume_nonnull in preprocessed output

2017-09-27 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Wed Sep 27 16:29:37 2017
New Revision: 314364

URL: http://llvm.org/viewvc/llvm-project?rev=314364&view=rev
Log:
[Preprocessor] Preserve #pragma clang assume_nonnull in preprocessed output

Patch by Zbigniew Sarbinowski!

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


Added:
cfe/trunk/test/Preprocessor/pragma_assume_nonnull.c
Modified:
cfe/trunk/include/clang/Lex/PPCallbacks.h
cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
cfe/trunk/lib/Lex/Pragma.cpp

Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=314364&r1=314363&r2=314364&view=diff
==
--- cfe/trunk/include/clang/Lex/PPCallbacks.h (original)
+++ cfe/trunk/include/clang/Lex/PPCallbacks.h Wed Sep 27 16:29:37 2017
@@ -235,6 +235,14 @@ public:
   virtual void PragmaWarningPop(SourceLocation Loc) {
   }
 
+  /// \brief Callback invoked when a \#pragma clang assume_nonnull begin 
directive
+  /// is read.
+  virtual void PragmaAssumeNonNullBegin(SourceLocation Loc) {}
+
+  /// \brief Callback invoked when a \#pragma clang assume_nonnull end 
directive
+  /// is read.
+  virtual void PragmaAssumeNonNullEnd(SourceLocation Loc) {}
+
   /// \brief Called by Preprocessor::HandleMacroExpandedIdentifier when a
   /// macro invocation is found.
   virtual void MacroExpands(const Token &MacroNameTok,
@@ -446,6 +454,16 @@ public:
 Second->PragmaWarningPop(Loc);
   }
 
+  void PragmaAssumeNonNullBegin(SourceLocation Loc) override {
+First->PragmaAssumeNonNullBegin(Loc);
+Second->PragmaAssumeNonNullBegin(Loc);
+  }
+
+  void PragmaAssumeNonNullEnd(SourceLocation Loc) override {
+First->PragmaAssumeNonNullEnd(Loc);
+Second->PragmaAssumeNonNullEnd(Loc);
+  }
+
   void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD,
 SourceRange Range, const MacroArgs *Args) override {
 First->MacroExpands(MacroNameTok, MD, Range, Args);

Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=314364&r1=314363&r2=314364&view=diff
==
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Wed Sep 27 16:29:37 2017
@@ -143,6 +143,8 @@ public:
  ArrayRef Ids) override;
   void PragmaWarningPush(SourceLocation Loc, int Level) override;
   void PragmaWarningPop(SourceLocation Loc) override;
+  void PragmaAssumeNonNullBegin(SourceLocation Loc) override;
+  void PragmaAssumeNonNullEnd(SourceLocation Loc) override;
 
   bool HandleFirstTokOnLine(Token &Tok);
 
@@ -549,6 +551,22 @@ void PrintPPOutputPPCallbacks::PragmaWar
   setEmittedDirectiveOnThisLine();
 }
 
+void PrintPPOutputPPCallbacks::
+PragmaAssumeNonNullBegin(SourceLocation Loc) {
+  startNewLineIfNeeded();
+  MoveToLine(Loc);
+  OS << "#pragma clang assume_nonnull begin";
+  setEmittedDirectiveOnThisLine();
+}
+
+void PrintPPOutputPPCallbacks::
+PragmaAssumeNonNullEnd(SourceLocation Loc) {
+  startNewLineIfNeeded();
+  MoveToLine(Loc);
+  OS << "#pragma clang assume_nonnull end";
+  setEmittedDirectiveOnThisLine();
+}
+
 /// HandleFirstTokOnLine - When emitting a preprocessed file in -E mode, this
 /// is called for the first token on each new line.  If this really is the 
start
 /// of a new logical line, handle it and return true, otherwise return false.

Modified: cfe/trunk/lib/Lex/Pragma.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=314364&r1=314363&r2=314364&view=diff
==
--- cfe/trunk/lib/Lex/Pragma.cpp (original)
+++ cfe/trunk/lib/Lex/Pragma.cpp Wed Sep 27 16:29:37 2017
@@ -1725,6 +1725,7 @@ struct PragmaAssumeNonNullHandler : publ
 
 // The start location we want after processing this.
 SourceLocation NewLoc;
+PPCallbacks *Callbacks = PP.getPPCallbacks();
 
 if (IsBegin) {
   // Complain about attempts to re-enter an audit.
@@ -1733,6 +1734,8 @@ struct PragmaAssumeNonNullHandler : publ
 PP.Diag(BeginLoc, diag::note_pragma_entered_here);
   }
   NewLoc = Loc;
+  if (Callbacks)
+Callbacks->PragmaAssumeNonNullBegin(NewLoc);
 } else {
   // Complain about attempts to leave an audit that doesn't exist.
   if (!BeginLoc.isValid()) {
@@ -1740,6 +1743,8 @@ struct PragmaAssumeNonNullHandler : publ
 return;
   }
   NewLoc = SourceLocation();
+  if (Callbacks)
+Callbacks->PragmaAssumeNonNullEnd(NewLoc);
 }
 
 PP.setPragmaAssumeNonNullLoc(NewLoc);

Added: cfe/trunk/test/Preprocessor/pragma_assume_nonnull.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/pragma_assume_nonnull.c?rev=314

[PATCH] D37861: preserving #pragma clang assume_nonnull in preprocessed output

2017-09-27 Thread Eli Friedman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314364: [Preprocessor] Preserve #pragma clang assume_nonnull 
in preprocessed output (authored by efriedma).

Changed prior to commit:
  https://reviews.llvm.org/D37861?vs=115838&id=116903#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37861

Files:
  cfe/trunk/include/clang/Lex/PPCallbacks.h
  cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
  cfe/trunk/lib/Lex/Pragma.cpp
  cfe/trunk/test/Preprocessor/pragma_assume_nonnull.c

Index: cfe/trunk/lib/Lex/Pragma.cpp
===
--- cfe/trunk/lib/Lex/Pragma.cpp
+++ cfe/trunk/lib/Lex/Pragma.cpp
@@ -1725,21 +1725,26 @@
 
 // The start location we want after processing this.
 SourceLocation NewLoc;
+PPCallbacks *Callbacks = PP.getPPCallbacks();
 
 if (IsBegin) {
   // Complain about attempts to re-enter an audit.
   if (BeginLoc.isValid()) {
 PP.Diag(Loc, diag::err_pp_double_begin_of_assume_nonnull);
 PP.Diag(BeginLoc, diag::note_pragma_entered_here);
   }
   NewLoc = Loc;
+  if (Callbacks)
+Callbacks->PragmaAssumeNonNullBegin(NewLoc);
 } else {
   // Complain about attempts to leave an audit that doesn't exist.
   if (!BeginLoc.isValid()) {
 PP.Diag(Loc, diag::err_pp_unmatched_end_of_assume_nonnull);
 return;
   }
   NewLoc = SourceLocation();
+  if (Callbacks)
+Callbacks->PragmaAssumeNonNullEnd(NewLoc);
 }
 
 PP.setPragmaAssumeNonNullLoc(NewLoc);
Index: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
===
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -143,6 +143,8 @@
  ArrayRef Ids) override;
   void PragmaWarningPush(SourceLocation Loc, int Level) override;
   void PragmaWarningPop(SourceLocation Loc) override;
+  void PragmaAssumeNonNullBegin(SourceLocation Loc) override;
+  void PragmaAssumeNonNullEnd(SourceLocation Loc) override;
 
   bool HandleFirstTokOnLine(Token &Tok);
 
@@ -549,6 +551,22 @@
   setEmittedDirectiveOnThisLine();
 }
 
+void PrintPPOutputPPCallbacks::
+PragmaAssumeNonNullBegin(SourceLocation Loc) {
+  startNewLineIfNeeded();
+  MoveToLine(Loc);
+  OS << "#pragma clang assume_nonnull begin";
+  setEmittedDirectiveOnThisLine();
+}
+
+void PrintPPOutputPPCallbacks::
+PragmaAssumeNonNullEnd(SourceLocation Loc) {
+  startNewLineIfNeeded();
+  MoveToLine(Loc);
+  OS << "#pragma clang assume_nonnull end";
+  setEmittedDirectiveOnThisLine();
+}
+
 /// HandleFirstTokOnLine - When emitting a preprocessed file in -E mode, this
 /// is called for the first token on each new line.  If this really is the start
 /// of a new logical line, handle it and return true, otherwise return false.
Index: cfe/trunk/include/clang/Lex/PPCallbacks.h
===
--- cfe/trunk/include/clang/Lex/PPCallbacks.h
+++ cfe/trunk/include/clang/Lex/PPCallbacks.h
@@ -235,6 +235,14 @@
   virtual void PragmaWarningPop(SourceLocation Loc) {
   }
 
+  /// \brief Callback invoked when a \#pragma clang assume_nonnull begin directive
+  /// is read.
+  virtual void PragmaAssumeNonNullBegin(SourceLocation Loc) {}
+
+  /// \brief Callback invoked when a \#pragma clang assume_nonnull end directive
+  /// is read.
+  virtual void PragmaAssumeNonNullEnd(SourceLocation Loc) {}
+
   /// \brief Called by Preprocessor::HandleMacroExpandedIdentifier when a
   /// macro invocation is found.
   virtual void MacroExpands(const Token &MacroNameTok,
@@ -446,6 +454,16 @@
 Second->PragmaWarningPop(Loc);
   }
 
+  void PragmaAssumeNonNullBegin(SourceLocation Loc) override {
+First->PragmaAssumeNonNullBegin(Loc);
+Second->PragmaAssumeNonNullBegin(Loc);
+  }
+
+  void PragmaAssumeNonNullEnd(SourceLocation Loc) override {
+First->PragmaAssumeNonNullEnd(Loc);
+Second->PragmaAssumeNonNullEnd(Loc);
+  }
+
   void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD,
 SourceRange Range, const MacroArgs *Args) override {
 First->MacroExpands(MacroNameTok, MD, Range, Args);
Index: cfe/trunk/test/Preprocessor/pragma_assume_nonnull.c
===
--- cfe/trunk/test/Preprocessor/pragma_assume_nonnull.c
+++ cfe/trunk/test/Preprocessor/pragma_assume_nonnull.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -E %s | FileCheck %s
+
+// CHECK: #pragma clang assume_nonnull begin
+#pragma clang assume_nonnull begin
+
+int bar(int * ip) { return *ip; }
+
+// CHECK: #pragma clang assume_nonnull end
+#pragma clang assume_nonnull end
+
+int foo(int * _Nonnull ip) { return *ip; }
+
+int main() {
+   return bar(0) + foo(0); // expected-warning 2 {{null passed to a callee that requires a non-null argument}}
+}

r314367 - [Targets/X86] Remove unneded `return` in setMaxAtomicWidth(). NFCI.

2017-09-27 Thread Davide Italiano via cfe-commits
Author: davide
Date: Wed Sep 27 17:24:20 2017
New Revision: 314367

URL: http://llvm.org/viewvc/llvm-project?rev=314367&view=rev
Log:
[Targets/X86] Remove unneded `return` in setMaxAtomicWidth(). NFCI.

Modified:
cfe/trunk/lib/Basic/Targets/X86.h

Modified: cfe/trunk/lib/Basic/Targets/X86.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.h?rev=314367&r1=314366&r2=314367&view=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.h (original)
+++ cfe/trunk/lib/Basic/Targets/X86.h Wed Sep 27 17:24:20 2017
@@ -875,7 +875,6 @@ public:
   void setMaxAtomicWidth() override {
 if (hasFeature("cx16"))
   MaxAtomicInlineWidth = 128;
-return;
   }
 
   ArrayRef getTargetBuiltins() const override;


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


r314370 - Look through parentheses.

2017-09-27 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Wed Sep 27 18:31:17 2017
New Revision: 314370

URL: http://llvm.org/viewvc/llvm-project?rev=314370&view=rev
Log:
Look through parentheses.

This fixes a bug where clang would emit instructions to reclaim a value
that's going to be __bridge-casted to CF.

rdar://problem/34687542

Modified:
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=314370&r1=314369&r2=314370&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Wed Sep 27 18:31:17 2017
@@ -4322,7 +4322,7 @@ static Expr *maybeUndoReclaimObject(Expr
   // problems here.  To catch them all, we'd need to rebuild arbitrary
   // value-propagating subexpressions --- we can't reliably rebuild
   // in-place because of expression sharing.
-  if (ImplicitCastExpr *ice = dyn_cast(e))
+  if (auto *ice = dyn_cast(e->IgnoreParens()))
 if (ice->getCastKind() == CK_ARCReclaimReturnedObject)
   return ice->getSubExpr();
 

Modified: cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m?rev=314370&r1=314369&r2=314370&view=diff
==
--- cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m Wed Sep 27 18:31:17 2017
@@ -97,3 +97,10 @@ void bridge_of_cf(int *i) {
   // CHECK-NEXT: ret void
 }
 
+// CHECK-LABEL: define %struct.__CFString* @bridge_of_paren_expr()
+CFStringRef bridge_of_paren_expr() {
+  // CHECK-NOT: call i8* @objc_retainAutoreleasedReturnValue(
+  // CHECK-NOT: call void @objc_release(
+  CFStringRef r = (__bridge CFStringRef)(CreateNSString());
+  return r;
+}


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


r314372 - [NFC] Modernize MacroArgs using TrailingObjects

2017-09-27 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Wed Sep 27 18:50:23 2017
New Revision: 314372

URL: http://llvm.org/viewvc/llvm-project?rev=314372&view=rev
Log:
[NFC] Modernize MacroArgs using TrailingObjects

Refactor MacroArgs to use TrailingObjects when creating a variably sized object 
on the heap to store the unexpanded tokens immediately after the MacroArgs 
object.

Modified:
cfe/trunk/include/clang/Lex/MacroArgs.h
cfe/trunk/lib/Lex/MacroArgs.cpp

Modified: cfe/trunk/include/clang/Lex/MacroArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/MacroArgs.h?rev=314372&r1=314371&r2=314372&view=diff
==
--- cfe/trunk/include/clang/Lex/MacroArgs.h (original)
+++ cfe/trunk/include/clang/Lex/MacroArgs.h Wed Sep 27 18:50:23 2017
@@ -17,6 +17,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Lex/Token.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/TrailingObjects.h"
 #include 
 
 namespace clang {
@@ -26,7 +27,10 @@ namespace clang {
 
 /// MacroArgs - An instance of this class captures information about
 /// the formal arguments specified to a function-like macro invocation.
-class MacroArgs {
+class MacroArgs final 
+: private llvm::TrailingObjects {
+
+  friend TrailingObjects;
   /// NumUnexpArgTokens - The number of raw, unexpanded tokens for the
   /// arguments.  All of the actual argument tokens are allocated immediately
   /// after the MacroArgs object in memory.  This is all of the arguments

Modified: cfe/trunk/lib/Lex/MacroArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/MacroArgs.cpp?rev=314372&r1=314371&r2=314372&view=diff
==
--- cfe/trunk/lib/Lex/MacroArgs.cpp (original)
+++ cfe/trunk/lib/Lex/MacroArgs.cpp Wed Sep 27 18:50:23 2017
@@ -33,7 +33,7 @@ MacroArgs *MacroArgs::create(const Macro
   // See if we have an entry with a big enough argument list to reuse on the
   // free list.  If so, reuse it.
   for (MacroArgs **Entry = &PP.MacroArgCache; *Entry;
-   Entry = &(*Entry)->ArgCache)
+   Entry = &(*Entry)->ArgCache) {
 if ((*Entry)->NumUnexpArgTokens >= UnexpArgTokens.size() &&
 (*Entry)->NumUnexpArgTokens < ClosestMatch) {
   ResultEnt = Entry;
@@ -44,14 +44,12 @@ MacroArgs *MacroArgs::create(const Macro
   // Otherwise, use the best fit.
   ClosestMatch = (*Entry)->NumUnexpArgTokens;
 }
-
+  }
   MacroArgs *Result;
   if (!ResultEnt) {
-// Allocate memory for a MacroArgs object with the lexer tokens at the end.
-Result = (MacroArgs *)malloc(sizeof(MacroArgs) +
- UnexpArgTokens.size() * sizeof(Token));
-// Construct the MacroArgs object.
-new (Result)
+// Allocate memory for a MacroArgs object with the lexer tokens at the end,
+// and construct the MacroArgs object.
+Result = new (std::malloc(totalSizeToAlloc(UnexpArgTokens.size(
 MacroArgs(UnexpArgTokens.size(), VarargsElided, MI->getNumParams());
   } else {
 Result = *ResultEnt;
@@ -63,9 +61,14 @@ MacroArgs *MacroArgs::create(const Macro
   }
 
   // Copy the actual unexpanded tokens to immediately after the result ptr.
-  if (!UnexpArgTokens.empty())
+  if (!UnexpArgTokens.empty()) {
+static_assert(std::is_trivially_copyable_v,
+  "assume trivial copyability if copying into the "
+  "uninitialized array (as opposed to reusing a cached "
+  "MacroArgs)");
 std::copy(UnexpArgTokens.begin(), UnexpArgTokens.end(), 
-  const_cast(Result->getUnexpArgument(0)));
+  Result->getTrailingObjects());
+  }
 
   return Result;
 }
@@ -93,6 +96,8 @@ MacroArgs *MacroArgs::deallocate() {
   // Run the dtor to deallocate the vectors.
   this->~MacroArgs();
   // Release the memory for the object.
+  static_assert(std::is_trivially_destructible_v,
+"assume trivially destructible and forego destructors");
   free(this);
   
   return Next;
@@ -115,7 +120,7 @@ unsigned MacroArgs::getArgLength(const T
 const Token *MacroArgs::getUnexpArgument(unsigned Arg) const {
   // The unexpanded argument tokens start immediately after the MacroArgs 
object
   // in memory.
-  const Token *Start = (const Token *)(this+1);
+  const Token *Start = getTrailingObjects();
   const Token *Result = Start;
   // Scan to find Arg.
   for (; Arg; ++Result) {


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


r314373 - [NFC] Don't use C++17 standard lib variable template helper traits, instead use ::value.

2017-09-27 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Wed Sep 27 19:00:40 2017
New Revision: 314373

URL: http://llvm.org/viewvc/llvm-project?rev=314373&view=rev
Log:
[NFC] Don't use C++17 standard lib variable template helper traits, instead use 
::value.

Modified:
cfe/trunk/lib/Lex/MacroArgs.cpp

Modified: cfe/trunk/lib/Lex/MacroArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/MacroArgs.cpp?rev=314373&r1=314372&r2=314373&view=diff
==
--- cfe/trunk/lib/Lex/MacroArgs.cpp (original)
+++ cfe/trunk/lib/Lex/MacroArgs.cpp Wed Sep 27 19:00:40 2017
@@ -62,7 +62,7 @@ MacroArgs *MacroArgs::create(const Macro
 
   // Copy the actual unexpanded tokens to immediately after the result ptr.
   if (!UnexpArgTokens.empty()) {
-static_assert(std::is_trivially_copyable_v,
+static_assert(std::is_trivially_copyable::value,
   "assume trivial copyability if copying into the "
   "uninitialized array (as opposed to reusing a cached "
   "MacroArgs)");
@@ -96,7 +96,7 @@ MacroArgs *MacroArgs::deallocate() {
   // Run the dtor to deallocate the vectors.
   this->~MacroArgs();
   // Release the memory for the object.
-  static_assert(std::is_trivially_destructible_v,
+  static_assert(std::is_trivially_destructible::value,
 "assume trivially destructible and forego destructors");
   free(this);
   


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


[PATCH] D38277: [compiler-rt}[CMake] Fix configuration on PowerPC with sanitizers

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

I wonder what's the error message?




Comment at: cmake/base-config-ix.cmake:153
+  # will fail with this option when building with a sanitizer.
+  set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+  string(REPLACE "-nodefaultlibs" "" CMAKE_REQUIRED_FLAGS 
${OLD_CMAKE_REQUIRED_FLAGS})

cmake_push_check_state()



Comment at: cmake/base-config-ix.cmake:157
+  # Undo the change.
+  set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}")
+

cmake_pop_check_state()


https://reviews.llvm.org/D38277



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


Re: r314373 - [NFC] Don't use C++17 standard lib variable template helper traits, instead use ::value.

2017-09-27 Thread James Y Knight via cfe-commits
This still doesn't work on some compilers, because
std::is_trivially_copyable isn't available:
http://lab.llvm.org:8011/builders/aosp-O3-polly-before-vectorizer-unprofitable/builds/265/steps/build/logs/stdio

On Wed, Sep 27, 2017 at 10:00 PM, Faisal Vali via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: faisalv
> Date: Wed Sep 27 19:00:40 2017
> New Revision: 314373
>
> URL: http://llvm.org/viewvc/llvm-project?rev=314373&view=rev
> Log:
> [NFC] Don't use C++17 standard lib variable template helper traits,
> instead use ::value.
>
> Modified:
> cfe/trunk/lib/Lex/MacroArgs.cpp
>
> Modified: cfe/trunk/lib/Lex/MacroArgs.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/
> MacroArgs.cpp?rev=314373&r1=314372&r2=314373&view=diff
> 
> ==
> --- cfe/trunk/lib/Lex/MacroArgs.cpp (original)
> +++ cfe/trunk/lib/Lex/MacroArgs.cpp Wed Sep 27 19:00:40 2017
> @@ -62,7 +62,7 @@ MacroArgs *MacroArgs::create(const Macro
>
>// Copy the actual unexpanded tokens to immediately after the result
> ptr.
>if (!UnexpArgTokens.empty()) {
> -static_assert(std::is_trivially_copyable_v,
> +static_assert(std::is_trivially_copyable::value,
>"assume trivial copyability if copying into the "
>"uninitialized array (as opposed to reusing a cached "
>"MacroArgs)");
> @@ -96,7 +96,7 @@ MacroArgs *MacroArgs::deallocate() {
>// Run the dtor to deallocate the vectors.
>this->~MacroArgs();
>// Release the memory for the object.
> -  static_assert(std::is_trivially_destructible_v,
> +  static_assert(std::is_trivially_destructible::value,
>  "assume trivially destructible and forego destructors");
>free(this);
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38342: [C++] Parse (sub) postfix expression after boolean literal

2017-09-27 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete created this revision.
Rakete added a project: clang.

Parsers a postfix expression after a boolean literal:

This fixes PR34273 .


https://reviews.llvm.org/D38342

Files:
  lib/Parse/ParseExpr.cpp
  test/CXX/expr/expr.post/expr.sub/p1.cpp


Index: test/CXX/expr/expr.post/expr.sub/p1.cpp
===
--- test/CXX/expr/expr.post/expr.sub/p1.cpp
+++ test/CXX/expr/expr.post/expr.sub/p1.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void pr34273() {
+  char Normal = "clang"[true]; // expected-no-diagnostics
+  char Special = true["clang"]; // expected-no-diagnostics
+}
+
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -798,7 +798,8 @@
 
   case tok::kw_true:
   case tok::kw_false:
-return ParseCXXBoolLiteral();
+Res = ParseCXXBoolLiteral();
+break;
   
   case tok::kw___objc_yes:
   case tok::kw___objc_no:


Index: test/CXX/expr/expr.post/expr.sub/p1.cpp
===
--- test/CXX/expr/expr.post/expr.sub/p1.cpp
+++ test/CXX/expr/expr.post/expr.sub/p1.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void pr34273() {
+  char Normal = "clang"[true]; // expected-no-diagnostics
+  char Special = true["clang"]; // expected-no-diagnostics
+}
+
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -798,7 +798,8 @@
 
   case tok::kw_true:
   case tok::kw_false:
-return ParseCXXBoolLiteral();
+Res = ParseCXXBoolLiteral();
+break;
   
   case tok::kw___objc_yes:
   case tok::kw___objc_no:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36150: [clangd] LSP extension to switch between source/header file

2017-09-27 Thread Marc-Andre Laperle via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314377: [clangd] LSP extension to switch between 
source/header file (authored by malaperle).

Changed prior to commit:
  https://reviews.llvm.org/D36150?vs=116387&id=116919#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36150

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.h
  clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
  clang-tools-extra/trunk/clangd/ProtocolHandlers.h
  clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
@@ -7,6 +7,7 @@
 //
 //===--===//
 
+#include "ClangdLSPServer.h"
 #include "ClangdServer.h"
 #include "Logger.h"
 #include "clang/Basic/VirtualFileSystem.h"
@@ -899,6 +900,84 @@
   }
 }
 
+TEST_F(ClangdVFSTest, CheckSourceHeaderSwitch) {
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  /*SnippetCompletions=*/false, EmptyLogger::getInstance());
+
+  auto SourceContents = R"cpp(
+  #include "foo.h"
+  int b = a;
+  )cpp";
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  auto FooH = getVirtualTestFilePath("foo.h");
+  auto Invalid = getVirtualTestFilePath("main.cpp");
+
+  FS.Files[FooCpp] = SourceContents;
+  FS.Files[FooH] = "int a;";
+  FS.Files[Invalid] = "int main() { \n return 0; \n }";
+
+  llvm::Optional PathResult = Server.switchSourceHeader(FooCpp);
+  EXPECT_TRUE(PathResult.hasValue());
+  ASSERT_EQ(PathResult.getValue(), FooH);
+
+  PathResult = Server.switchSourceHeader(FooH);
+  EXPECT_TRUE(PathResult.hasValue());
+  ASSERT_EQ(PathResult.getValue(), FooCpp);
+
+  SourceContents = R"c(
+  #include "foo.HH"
+  int b = a;
+  )c";
+
+  // Test with header file in capital letters and different extension, source
+  // file with different extension
+  auto FooC = getVirtualTestFilePath("bar.c");
+  auto FooHH = getVirtualTestFilePath("bar.HH");
+
+  FS.Files[FooC] = SourceContents;
+  FS.Files[FooHH] = "int a;";
+
+  PathResult = Server.switchSourceHeader(FooC);
+  EXPECT_TRUE(PathResult.hasValue());
+  ASSERT_EQ(PathResult.getValue(), FooHH);
+
+  // Test with both capital letters
+  auto Foo2C = getVirtualTestFilePath("foo2.C");
+  auto Foo2HH = getVirtualTestFilePath("foo2.HH");
+  FS.Files[Foo2C] = SourceContents;
+  FS.Files[Foo2HH] = "int a;";
+
+  PathResult = Server.switchSourceHeader(Foo2C);
+  EXPECT_TRUE(PathResult.hasValue());
+  ASSERT_EQ(PathResult.getValue(), Foo2HH);
+
+  // Test with source file as capital letter and .hxx header file
+  auto Foo3C = getVirtualTestFilePath("foo3.C");
+  auto Foo3HXX = getVirtualTestFilePath("foo3.hxx");
+
+  SourceContents = R"c(
+  #include "foo3.hxx"
+  int b = a;
+  )c";
+
+  FS.Files[Foo3C] = SourceContents;
+  FS.Files[Foo3HXX] = "int a;";
+
+  PathResult = Server.switchSourceHeader(Foo3C);
+  EXPECT_TRUE(PathResult.hasValue());
+  ASSERT_EQ(PathResult.getValue(), Foo3HXX);
+
+  // Test if asking for a corresponding file that doesn't exist returns an empty
+  // string.
+  PathResult = Server.switchSourceHeader(Invalid);
+  EXPECT_FALSE(PathResult.hasValue());
+}
+
 TEST_F(ClangdThreadingTest, NoConcurrentDiagnostics) {
   class NoConcurrentAccessDiagConsumer : public DiagnosticsConsumer {
   public:
Index: clang-tools-extra/trunk/clangd/ProtocolHandlers.h
===
--- clang-tools-extra/trunk/clangd/ProtocolHandlers.h
+++ clang-tools-extra/trunk/clangd/ProtocolHandlers.h
@@ -49,6 +49,8 @@
 JSONOutput &Out) = 0;
   virtual void onGoToDefinition(TextDocumentPositionParams Params, StringRef ID,
 JSONOutput &Out) = 0;
+  virtual void onSwitchSourceHeader(TextDocumentIdentifier Params, StringRef ID,
+JSONOutput &Out) = 0;  
 };
 
 void regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher, JSONOutput &Out,
Index: clang-tools-extra/trunk/clangd/ClangdServer.h
===
--- clang-tools-extra/trunk/clangd/ClangdServer.h
+++ clang-tools-extra/trunk/clangd/ClangdServer.h
@@ -248,6 +248,10 @@
   /// Get definition of symbol at a specified \p Line and \p Column in \p File.
   Tagged> findDefinitions(PathRef File, Position Pos);
 
+  /// Helper function that returns a path to the corresponding source file when
+  /// given a header file and vice versa.
+  llvm::Optional switchSourceHe

[clang-tools-extra] r314377 - [clangd] LSP extension to switch between source/header file

2017-09-27 Thread Marc-Andre Laperle via cfe-commits
Author: malaperle
Date: Wed Sep 27 20:14:40 2017
New Revision: 314377

URL: http://llvm.org/viewvc/llvm-project?rev=314377&view=rev
Log:
[clangd] LSP extension to switch between source/header file

Summary:
Small extension to LSP to allow clients to use clangd to switch between C 
header files and source files.
Final version will use the completed clangd indexer to use the index of symbols 
to be able to switch from header to source file when the file names don't match.

Reviewers: malaperle, krasimir, bkramer, ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: ilya-biryukov, cfe-commits, arphaman

Patch by: William Enright

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
clang-tools-extra/trunk/clangd/ProtocolHandlers.h
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=314377&r1=314376&r2=314377&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Sep 27 20:14:40 2017
@@ -72,6 +72,8 @@ public:
 JSONOutput &Out) override;
   void onGoToDefinition(TextDocumentPositionParams Params, StringRef ID,
 JSONOutput &Out) override;
+  void onSwitchSourceHeader(TextDocumentIdentifier Params, StringRef ID,
+JSONOutput &Out) override;  
 
 private:
   ClangdLSPServer &LangServer;
@@ -226,6 +228,21 @@ void ClangdLSPServer::LSPProtocolCallbac
   R"(,"result":[)" + Locations + R"(]})");
 }
 
+void ClangdLSPServer::LSPProtocolCallbacks::onSwitchSourceHeader(
+TextDocumentIdentifier Params, StringRef ID, JSONOutput &Out) {
+  llvm::Optional Result =
+  LangServer.Server.switchSourceHeader(Params.uri.file);
+  std::string ResultUri;
+  if (Result)
+ResultUri = URI::unparse(URI::fromFile(*Result));
+  else
+ResultUri = "\"\"";
+
+  Out.writeMessage(
+  R"({"jsonrpc":"2.0","id":)" + ID.str() +
+  R"(,"result":)" + ResultUri + R"(})");
+}
+
 ClangdLSPServer::ClangdLSPServer(JSONOutput &Out, unsigned AsyncThreadsCount,
  bool SnippetCompletions,
  llvm::Optional ResourceDir)

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=314377&r1=314376&r2=314377&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Sep 27 20:14:40 2017
@@ -296,6 +296,66 @@ Tagged> ClangdServ
   return make_tagged(std::move(Result), TaggedFS.Tag);
 }
 
+llvm::Optional ClangdServer::switchSourceHeader(PathRef Path) {
+
+  StringRef SourceExtensions[] = {".cpp", ".c", ".cc", ".cxx",
+  ".c++", ".m", ".mm"};
+  StringRef HeaderExtensions[] = {".h", ".hh", ".hpp", ".hxx", ".inc"};
+
+  StringRef PathExt = llvm::sys::path::extension(Path);
+
+  // Lookup in a list of known extensions.
+  auto SourceIter =
+  std::find_if(std::begin(SourceExtensions), std::end(SourceExtensions),
+   [&PathExt](PathRef SourceExt) {
+ return SourceExt.equals_lower(PathExt);
+   });
+  bool IsSource = SourceIter != std::end(SourceExtensions);
+
+  auto HeaderIter =
+  std::find_if(std::begin(HeaderExtensions), std::end(HeaderExtensions),
+   [&PathExt](PathRef HeaderExt) {
+ return HeaderExt.equals_lower(PathExt);
+   });
+
+  bool IsHeader = HeaderIter != std::end(HeaderExtensions);
+
+  // We can only switch between extensions known extensions.
+  if (!IsSource && !IsHeader)
+return llvm::None;
+
+  // Array to lookup extensions for the switch. An opposite of where original
+  // extension was found.
+  ArrayRef NewExts;
+  if (IsSource)
+NewExts = HeaderExtensions;
+  else
+NewExts = SourceExtensions;
+
+  // Storage for the new path.
+  SmallString<128> NewPath = StringRef(Path);
+
+  // Instance of vfs::FileSystem, used for file existence checks.
+  auto FS = FSProvider.getTaggedFileSystem(Path).Value;
+
+  // Loop through switched extension candidates.
+  for (StringRef NewExt : NewExts) {
+llvm::sys::path::replace_extension(NewPath, NewExt);
+if (FS->exists(NewPath))
+  return NewPath.str().str(); // First str() to convert from SmallString to
+  // StringRef, second to convert from 
StringRef

[PATCH] D36150: [clangd] LSP extension to switch between source/header file

2017-09-27 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

I submitted the patch. Thanks a lot William and Ilya!


Repository:
  rL LLVM

https://reviews.llvm.org/D36150



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


[PATCH] D38290: Add a ld64.lld alias for the MACHO LLD target

2017-09-27 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added a comment.

Is this for cross-compilation? If you invoke lld on macOS, it should act as 
ld64.

macOS lld is not actively maintained, so I wouldn't make it available more 
widely.


Repository:
  rL LLVM

https://reviews.llvm.org/D38290



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


[PATCH] D37150: [clangd] Command line arg to specify compile_commands.json path

2017-09-27 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle requested changes to this revision.
malaperle added inline comments.
This revision now requires changes to proceed.



Comment at: clangd/tool/ClangdMain.cpp:20
 #include 
+#include 
 

William, did you perhaps miss this comment? I don't think unistd.h makes sense 
here.


https://reviews.llvm.org/D37150



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


[PATCH] D37905: [libclang, bindings]: add spelling location

2017-09-27 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd requested changes to this revision.
compnerd added a comment.
This revision now requires changes to proceed.

If I'm not mistaken, the change just means that the python bindings need a 
"newer" libclang, libclang's interfaces don't really change.  I think that is 
acceptable.




Comment at: bindings/python/clang/cindex.py:320
+return self._get_spelling()['offset']
 
 def __eq__(self, other):

Does it make sense to introduce two new properties `expansion` and `spelling` 
and have the four fields be properties on those properties?  It seems like it 
would be more pythonic.



Comment at: tools/libclang/CXSourceLocation.cpp:321
   *static_cast(location.ptr_data[0]);
   // FIXME: This should call SourceManager::getSpellingLoc().
+  SourceLocation SpellLoc = SM.getSpellingLoc(Loc);

Remove the FIXME please.


https://reviews.llvm.org/D37905



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


[PATCH] D38290: Add a ld64.lld alias for the MACHO LLD target

2017-09-27 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

In https://reviews.llvm.org/D38290#882911, @ruiu wrote:

> Is this for cross-compilation?


It is mostly for native compilation on mac but this will work for cross 
compiling also.

> If you invoke lld on macOS, it should act as ld64.

That is if the file name is `ld` or if you pass the `darwin` flavour but that 
is not how clang invokes lld.

`-fuse-ld=lld` invokes `ld.lld` which is bound to the gnu frontend only even on 
MacOS hosts.
The reason for introducing ld64 is so we can still cross compile from MacOS to 
linux targets cleanly.


Repository:
  rL LLVM

https://reviews.llvm.org/D38290



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