Re: [PATCH] D14864: [X86] Support for C calling convention only for MCU target.

2015-11-25 Thread Alexey Bataev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL254063: [X86] Support for C calling convention only for MCU 
target. (authored by ABataev).

Changed prior to commit:
  http://reviews.llvm.org/D14864?vs=41004&id=41115#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14864

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Sema/callingconv-iamcu.c

Index: cfe/trunk/test/Sema/callingconv-iamcu.c
===
--- cfe/trunk/test/Sema/callingconv-iamcu.c
+++ cfe/trunk/test/Sema/callingconv-iamcu.c
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 %s -fsyntax-only -triple i686-intel-elfiamcu -verify
+
+void __attribute__((fastcall)) foo(float *a) { // expected-warning {{calling convention 'fastcall' ignored for this target}}
+}
+
+void __attribute__((stdcall)) bar(float *a) { // expected-warning {{calling convention 'stdcall' ignored for this target}}
+}
+
+void __attribute__((fastcall(1))) baz(float *a) { // expected-error {{'fastcall' attribute takes no arguments}}
+}
+
+void __attribute__((fastcall)) test2(int a, ...) { // expected-warning {{calling convention 'fastcall' ignored for this target}}
+}
+void __attribute__((stdcall)) test3(int a, ...) { // expected-warning {{calling convention 'stdcall' ignored for this target}}
+}
+void __attribute__((thiscall)) test4(int a, ...) { // expected-warning {{calling convention 'thiscall' ignored for this target}}
+}
+
+void __attribute__((cdecl)) ctest0() {}
+
+void __attribute__((cdecl(1))) ctest1(float x) {} // expected-error {{'cdecl' attribute takes no arguments}}
+
+void (__attribute__((fastcall)) *pfoo)(float*) = foo; // expected-warning {{calling convention 'fastcall' ignored for this target}}
+
+void (__attribute__((stdcall)) *pbar)(float*) = bar; // expected-warning {{calling convention 'stdcall' ignored for this target}}
+
+void (*pctest0)() = ctest0;
+
+void ctest2() {}
+void (__attribute__((cdecl)) *pctest2)() = ctest2;
+
+typedef void (__attribute__((fastcall)) *Handler) (float *); // expected-warning {{calling convention 'fastcall' ignored for this target}}
+Handler H = foo;
+
+int __attribute__((pcs("aapcs", "aapcs"))) pcs1(void); // expected-error {{'pcs' attribute takes one argument}}
+int __attribute__((pcs())) pcs2(void); // expected-error {{'pcs' attribute takes one argument}}
+int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{'pcs' attribute requires a string}} \
+   // expected-error {{invalid PCS type}}
+int __attribute__((pcs(0))) pcs4(void); // expected-error {{'pcs' attribute requires a string}}
+/* These are ignored because the target is i386 and not ARM */
+int __attribute__((pcs("aapcs"))) pcs5(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
+int __attribute__((pcs("aapcs-vfp"))) pcs6(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
+int __attribute__((pcs("foo"))) pcs7(void); // expected-error {{invalid PCS type}}
+
+void ctest3();
+void __attribute__((cdecl)) ctest3() {}
+
+typedef __attribute__((stdcall)) void (*PROC)(); // expected-warning {{calling convention 'stdcall' ignored for this target}}
+PROC __attribute__((cdecl)) ctest4(const char *x) {}
+
+void __attribute__((intel_ocl_bicc)) inteloclbifunc(float *a) {} // expected-warning {{calling convention 'intel_ocl_bicc' ignored for this target}}
+
+struct type_test {} __attribute__((stdcall)); // expected-warning {{calling convention 'stdcall' ignored for this target}} expected-warning {{'stdcall' attribute only applies to functions and methods}}
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -3391,11 +3391,6 @@
   }
   if (CPU >= CK_i586)
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
-
-  if (getTriple().isOSIAMCU()) {
-Builder.defineMacro("__iamcu");
-Builder.defineMacro("__iamcu__");
-  }
 }
 
 bool X86TargetInfo::hasFeature(StringRef Feature) const {
@@ -3644,11 +3639,6 @@
 IntPtrType = SignedInt;
 RegParmMax = 3;
 
-if (getTriple().isOSIAMCU()) {
-  LongDoubleWidth = 64;
-  LongDoubleFormat = &llvm::APFloat::IEEEdouble;
-}
-
 // Use fpret for all types.
 RealTypeUsesObjCFPRet = ((1 << TargetInfo::Float) |
  (1 << TargetInfo::Double) |
@@ -3881,6 +3871,27 @@
   }
 };
 
+// X86-32 MCU target
+class MCUX86_32TargetInfo : public X86_32TargetInfo {
+public:
+  MCUX86_32TargetInfo(const llvm::Triple &Triple) : X86_32TargetInfo(Triple) {
+LongDoubleWidth = 64;
+LongDoubleFormat = &llvm::APFloat::IEEEdouble;
+  }
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
+// On MCU we support only C calling convention.
+return CC == CC_C ? CCCR_OK : CCCR_Warning;
+  }
+
+  void getTargetDefines(const LangOptions &Opts,

r254063 - [X86] Support for C calling convention only for MCU target.

2015-11-25 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Nov 25 03:24:26 2015
New Revision: 254063

URL: http://llvm.org/viewvc/llvm-project?rev=254063&view=rev
Log:
[X86] Support for C calling convention only for MCU target.
For MCU only C calling convention is allowed, all other calling conventions are 
not supported.
Differential Revision: http://reviews.llvm.org/D14864

Added:
cfe/trunk/test/Sema/callingconv-iamcu.c   (with props)
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=254063&r1=254062&r2=254063&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Nov 25 03:24:26 2015
@@ -3391,11 +3391,6 @@ void X86TargetInfo::getTargetDefines(con
   }
   if (CPU >= CK_i586)
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
-
-  if (getTriple().isOSIAMCU()) {
-Builder.defineMacro("__iamcu");
-Builder.defineMacro("__iamcu__");
-  }
 }
 
 bool X86TargetInfo::hasFeature(StringRef Feature) const {
@@ -3644,11 +3639,6 @@ public:
 IntPtrType = SignedInt;
 RegParmMax = 3;
 
-if (getTriple().isOSIAMCU()) {
-  LongDoubleWidth = 64;
-  LongDoubleFormat = &llvm::APFloat::IEEEdouble;
-}
-
 // Use fpret for all types.
 RealTypeUsesObjCFPRet = ((1 << TargetInfo::Float) |
  (1 << TargetInfo::Double) |
@@ -3881,6 +3871,27 @@ public:
   }
 };
 
+// X86-32 MCU target
+class MCUX86_32TargetInfo : public X86_32TargetInfo {
+public:
+  MCUX86_32TargetInfo(const llvm::Triple &Triple) : X86_32TargetInfo(Triple) {
+LongDoubleWidth = 64;
+LongDoubleFormat = &llvm::APFloat::IEEEdouble;
+  }
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
+// On MCU we support only C calling convention.
+return CC == CC_C ? CCCR_OK : CCCR_Warning;
+  }
+
+  void getTargetDefines(const LangOptions &Opts,
+MacroBuilder &Builder) const override {
+X86_32TargetInfo::getTargetDefines(Opts, Builder);
+Builder.defineMacro("__iamcu");
+Builder.defineMacro("__iamcu__");
+  }
+};
+
 // RTEMS Target
 template
 class RTEMSTargetInfo : public OSTargetInfo {
@@ -7769,6 +7780,8 @@ static TargetInfo *AllocateTarget(const
   return new RTEMSX86_32TargetInfo(Triple);
 case llvm::Triple::NaCl:
   return new NaClTargetInfo(Triple);
+case llvm::Triple::ELFIAMCU:
+  return new MCUX86_32TargetInfo(Triple);
 default:
   return new X86_32TargetInfo(Triple);
 }

Added: cfe/trunk/test/Sema/callingconv-iamcu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/callingconv-iamcu.c?rev=254063&view=auto
==
--- cfe/trunk/test/Sema/callingconv-iamcu.c (added)
+++ cfe/trunk/test/Sema/callingconv-iamcu.c Wed Nov 25 03:24:26 2015
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 %s -fsyntax-only -triple i686-intel-elfiamcu -verify
+
+void __attribute__((fastcall)) foo(float *a) { // expected-warning {{calling 
convention 'fastcall' ignored for this target}}
+}
+
+void __attribute__((stdcall)) bar(float *a) { // expected-warning {{calling 
convention 'stdcall' ignored for this target}}
+}
+
+void __attribute__((fastcall(1))) baz(float *a) { // expected-error 
{{'fastcall' attribute takes no arguments}}
+}
+
+void __attribute__((fastcall)) test2(int a, ...) { // expected-warning 
{{calling convention 'fastcall' ignored for this target}}
+}
+void __attribute__((stdcall)) test3(int a, ...) { // expected-warning 
{{calling convention 'stdcall' ignored for this target}}
+}
+void __attribute__((thiscall)) test4(int a, ...) { // expected-warning 
{{calling convention 'thiscall' ignored for this target}}
+}
+
+void __attribute__((cdecl)) ctest0() {}
+
+void __attribute__((cdecl(1))) ctest1(float x) {} // expected-error {{'cdecl' 
attribute takes no arguments}}
+
+void (__attribute__((fastcall)) *pfoo)(float*) = foo; // expected-warning 
{{calling convention 'fastcall' ignored for this target}}
+
+void (__attribute__((stdcall)) *pbar)(float*) = bar; // expected-warning 
{{calling convention 'stdcall' ignored for this target}}
+
+void (*pctest0)() = ctest0;
+
+void ctest2() {}
+void (__attribute__((cdecl)) *pctest2)() = ctest2;
+
+typedef void (__attribute__((fastcall)) *Handler) (float *); // 
expected-warning {{calling convention 'fastcall' ignored for this target}}
+Handler H = foo;
+
+int __attribute__((pcs("aapcs", "aapcs"))) pcs1(void); // expected-error 
{{'pcs' attribute takes one argument}}
+int __attribute__((pcs())) pcs2(void); // expected-error {{'pcs' attribute 
takes one argument}}
+int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{'pcs' attribute 
requires a string}} \
+   // expected-error {{invalid PCS 
type}}
+int __attribute__((pcs(0))) pcs4(void

Re: [PATCH] D14653: [libcxx] Introduce the mechanism for fixing -fno-exceptions test failures.

2015-11-25 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

Gentle ping.


http://reviews.llvm.org/D14653



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


[PATCH] D14977: clang-tidy: code cleanup with isAssignmentOperator

2015-11-25 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki created this revision.
danielmarjamaki added subscribers: cfe-commits, alexfh.

This is a small code cleanup. No change in logical behaviour is intended.

http://reviews.llvm.org/D14977

Files:
  clang-tidy/misc/AssertSideEffectCheck.cpp

Index: clang-tidy/misc/AssertSideEffectCheck.cpp
===
--- clang-tidy/misc/AssertSideEffectCheck.cpp
+++ clang-tidy/misc/AssertSideEffectCheck.cpp
@@ -33,11 +33,7 @@
   }
 
   if (const auto *Op = dyn_cast(E)) {
-BinaryOperator::Opcode OC = Op->getOpcode();
-return OC == BO_Assign || OC == BO_MulAssign || OC == BO_DivAssign ||
-   OC == BO_RemAssign || OC == BO_AddAssign || OC == BO_SubAssign ||
-   OC == BO_ShlAssign || OC == BO_ShrAssign || OC == BO_AndAssign ||
-   OC == BO_XorAssign || OC == BO_OrAssign;
+return Op->isAssignmentOp();
   }
 
   if (const auto *OpCallExpr = dyn_cast(E)) {


Index: clang-tidy/misc/AssertSideEffectCheck.cpp
===
--- clang-tidy/misc/AssertSideEffectCheck.cpp
+++ clang-tidy/misc/AssertSideEffectCheck.cpp
@@ -33,11 +33,7 @@
   }
 
   if (const auto *Op = dyn_cast(E)) {
-BinaryOperator::Opcode OC = Op->getOpcode();
-return OC == BO_Assign || OC == BO_MulAssign || OC == BO_DivAssign ||
-   OC == BO_RemAssign || OC == BO_AddAssign || OC == BO_SubAssign ||
-   OC == BO_ShlAssign || OC == BO_ShrAssign || OC == BO_AndAssign ||
-   OC == BO_XorAssign || OC == BO_OrAssign;
+return Op->isAssignmentOp();
   }
 
   if (const auto *OpCallExpr = dyn_cast(E)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14977: clang-tidy: code cleanup with isAssignmentOperator

2015-11-25 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a reviewer: alexfh.
alexfh added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D14977



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


Re: [PATCH] D14964: [clang-tidy] Fix problem with parallel configure build

2015-11-25 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

LG

Do you need me to submit this?


Repository:
  rL LLVM

http://reviews.llvm.org/D14964



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


[PATCH] D14980: PR18513: make gcc compatible layout for bit-fields with explicit aligned attribute

2015-11-25 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin created this revision.
DmitryPolukhin added a reviewer: rjmccall.
DmitryPolukhin added a subscriber: cfe-commits.

Fix binary compatibility issue with GCC.

http://reviews.llvm.org/D14980

Files:
  lib/AST/RecordLayoutBuilder.cpp
  test/Sema/bitfield-layout.c

Index: test/Sema/bitfield-layout.c
===
--- test/Sema/bitfield-layout.c
+++ test/Sema/bitfield-layout.c
@@ -1,8 +1,13 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=i686-apple-darwin9
 // expected-no-diagnostics
+#include 
 
-#define CHECK_SIZE(kind, name, size) extern int name##1[sizeof(kind name) == 
size ? 1 : -1];
-#define CHECK_ALIGN(kind, name, size) extern int name##2[__alignof(kind name) 
== size ? 1 : -1];
+#define CHECK_SIZE(kind, name, size) \
+  extern int name##1[sizeof(kind name) == size ? 1 : -1];
+#define CHECK_ALIGN(kind, name, size) \
+  extern int name##2[__alignof(kind name) == size ? 1 : -1];
+#define CHECK_OFFSET(kind, name, member, offset) \
+  extern int name##2[offsetof(kind name, member) == offset ? 1 : -1];
 
 // Zero-width bit-fields
 struct a {char x; int : 0; char y;};
@@ -56,3 +61,35 @@
 CHECK_SIZE(struct, s0, 0x3218)
 CHECK_ALIGN(struct, s0, 4)
 
+// Bit-field with explicit align bigger than normal.
+struct g0 {
+  char a;
+  __attribute__((aligned(16))) int b : 1;
+  char c;
+};
+
+CHECK_SIZE(struct, g0, 32);
+CHECK_ALIGN(struct, g0, 16);
+CHECK_OFFSET(struct, g0, c, 17);
+
+// Bit-field with explicit align smaller than normal.
+struct g1 {
+  char a;
+  __attribute__((aligned(2))) int b : 1;
+  char c;
+};
+
+CHECK_SIZE(struct, g1, 4);
+CHECK_ALIGN(struct, g1, 4);
+CHECK_OFFSET(struct, g1, c, 3);
+
+// Same as above but without explicit align.
+struct g2 {
+  char a;
+  int b : 1;
+  char c;
+};
+
+CHECK_SIZE(struct, g2, 4);
+CHECK_ALIGN(struct, g2, 4);
+CHECK_OFFSET(struct, g2, c, 2);
Index: lib/AST/RecordLayoutBuilder.cpp
===
--- lib/AST/RecordLayoutBuilder.cpp
+++ lib/AST/RecordLayoutBuilder.cpp
@@ -1552,7 +1552,8 @@
 FieldAlign = 1;
 
   // But, if there's an 'aligned' attribute on the field, honor that.
-  if (unsigned ExplicitFieldAlign = D->getMaxAlignment()) {
+  unsigned ExplicitFieldAlign = D->getMaxAlignment();
+  if (ExplicitFieldAlign) {
 FieldAlign = std::max(FieldAlign, ExplicitFieldAlign);
 UnpackedFieldAlign = std::max(UnpackedFieldAlign, ExplicitFieldAlign);
   }
@@ -1601,10 +1602,12 @@
 (AllowPadding &&
  (FieldOffset & (FieldAlign-1)) + FieldSize > TypeSize)) {
   FieldOffset = llvm::RoundUpToAlignment(FieldOffset, FieldAlign);
-}
+} else if (ExplicitFieldAlign)
+  FieldOffset = llvm::RoundUpToAlignment(FieldOffset, ExplicitFieldAlign);
 
 // Repeat the computation for diagnostic purposes.
 if (FieldSize == 0 ||
+ExplicitFieldAlign ||
 (AllowPadding &&
  (UnpackedFieldOffset & (UnpackedFieldAlign-1)) + FieldSize > 
TypeSize))
   UnpackedFieldOffset = llvm::RoundUpToAlignment(UnpackedFieldOffset,


Index: test/Sema/bitfield-layout.c
===
--- test/Sema/bitfield-layout.c
+++ test/Sema/bitfield-layout.c
@@ -1,8 +1,13 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=i686-apple-darwin9
 // expected-no-diagnostics
+#include 
 
-#define CHECK_SIZE(kind, name, size) extern int name##1[sizeof(kind name) == size ? 1 : -1];
-#define CHECK_ALIGN(kind, name, size) extern int name##2[__alignof(kind name) == size ? 1 : -1];
+#define CHECK_SIZE(kind, name, size) \
+  extern int name##1[sizeof(kind name) == size ? 1 : -1];
+#define CHECK_ALIGN(kind, name, size) \
+  extern int name##2[__alignof(kind name) == size ? 1 : -1];
+#define CHECK_OFFSET(kind, name, member, offset) \
+  extern int name##2[offsetof(kind name, member) == offset ? 1 : -1];
 
 // Zero-width bit-fields
 struct a {char x; int : 0; char y;};
@@ -56,3 +61,35 @@
 CHECK_SIZE(struct, s0, 0x3218)
 CHECK_ALIGN(struct, s0, 4)
 
+// Bit-field with explicit align bigger than normal.
+struct g0 {
+  char a;
+  __attribute__((aligned(16))) int b : 1;
+  char c;
+};
+
+CHECK_SIZE(struct, g0, 32);
+CHECK_ALIGN(struct, g0, 16);
+CHECK_OFFSET(struct, g0, c, 17);
+
+// Bit-field with explicit align smaller than normal.
+struct g1 {
+  char a;
+  __attribute__((aligned(2))) int b : 1;
+  char c;
+};
+
+CHECK_SIZE(struct, g1, 4);
+CHECK_ALIGN(struct, g1, 4);
+CHECK_OFFSET(struct, g1, c, 3);
+
+// Same as above but without explicit align.
+struct g2 {
+  char a;
+  int b : 1;
+  char c;
+};
+
+CHECK_SIZE(struct, g2, 4);
+CHECK_ALIGN(struct, g2, 4);
+CHECK_OFFSET(struct, g2, c, 2);
Index: lib/AST/RecordLayoutBuilder.cpp
===
--- lib/AST/RecordLayoutBuilder.cpp
+++ lib/AST/RecordLayoutBuilder.cpp
@@ -1552,7 +1552,8 @@
 FieldAlign = 1;
 
   // But, if there's an 'aligned' attribute on the field, hono

Re: [PATCH] D11182: [OPENMP 4.0] Initial support for 'omp declare reduction' construct.

2015-11-25 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

Richard, could you take a look one more time, please?


http://reviews.llvm.org/D11182



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


Re: [PATCH] D10599: [OPENMP 4.0] Initial support for '#pragma omp declare simd' directive.

2015-11-25 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

Richard, any comments?


http://reviews.llvm.org/D10599



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


[clang-tools-extra] r254066 - [clang-tidy] code cleanup using isAssignmentOp()

2015-11-25 Thread Daniel Marjamaki via cfe-commits
Author: danielmarjamaki
Date: Wed Nov 25 05:30:00 2015
New Revision: 254066

URL: http://llvm.org/viewvc/llvm-project?rev=254066&view=rev
Log:
[clang-tidy] code cleanup using isAssignmentOp()

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

Modified: clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp?rev=254066&r1=254065&r2=254066&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp Wed Nov 
25 05:30:00 2015
@@ -33,11 +33,7 @@ AST_MATCHER_P(Expr, hasSideEffect, bool,
   }
 
   if (const auto *Op = dyn_cast(E)) {
-BinaryOperator::Opcode OC = Op->getOpcode();
-return OC == BO_Assign || OC == BO_MulAssign || OC == BO_DivAssign ||
-   OC == BO_RemAssign || OC == BO_AddAssign || OC == BO_SubAssign ||
-   OC == BO_ShlAssign || OC == BO_ShrAssign || OC == BO_AndAssign ||
-   OC == BO_XorAssign || OC == BO_OrAssign;
+return Op->isAssignmentOp();
   }
 
   if (const auto *OpCallExpr = dyn_cast(E)) {


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


Re: [PATCH] D14977: clang-tidy: code cleanup with isAssignmentOperator

2015-11-25 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki closed this revision.
danielmarjamaki added a comment.

Committed with 254066.


http://reviews.llvm.org/D14977



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


Re: [PATCH] D14954: [x86] Exclusion of incorrect include headers paths for MCU target

2015-11-25 Thread Michael Kuperstein via cfe-commits
mkuper accepted this revision.
mkuper added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D14954



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


r254067 - [MSVC] 'property' with an empty array in array subscript expression.

2015-11-25 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Nov 25 06:01:00 2015
New Revision: 254067

URL: http://llvm.org/viewvc/llvm-project?rev=254067&view=rev
Log:
[MSVC] 'property' with an empty array in array subscript expression.
MSVC supports 'property' attribute and allows to apply it to the declaration of 
an empty array in a class or structure definition.
For example:
```
__declspec(property(get=GetX, put=PutX)) int x[];
```
The above statement indicates that x[] can be used with one or more array 
indices. In this case, i=p->x[a][b] will be turned into i=p->GetX(a, b), and 
p->x[a][b] = i will be turned into p->PutX(a, b, i);
Differential Revision: http://reviews.llvm.org/D13336

Added:
cfe/trunk/test/SemaCXX/ms-property-error.cpp   (with props)
cfe/trunk/test/SemaCXX/ms-property.cpp   (with props)
Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/StmtNodes.td
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprClassification.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaPseudoObject.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/CodeGenCXX/ms-property.cpp
cfe/trunk/tools/libclang/CXCursor.cpp

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=254067&r1=254066&r2=254067&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Wed Nov 25 06:01:00 2015
@@ -677,6 +677,69 @@ public:
   friend class ASTStmtReader;
 };
 
+/// MS property subscript expression.
+/// MSVC supports 'property' attribute and allows to apply it to the
+/// declaration of an empty array in a class or structure definition.
+/// For example:
+/// \code
+/// __declspec(property(get=GetX, put=PutX)) int x[];
+/// \endcode
+/// The above statement indicates that x[] can be used with one or more array
+/// indices. In this case, i=p->x[a][b] will be turned into i=p->GetX(a, b), 
and
+/// p->x[a][b] = i will be turned into p->PutX(a, b, i).
+/// This is a syntactic pseudo-object expression.
+class MSPropertySubscriptExpr : public Expr {
+  friend class ASTStmtReader;
+  enum { BASE_EXPR, IDX_EXPR, NUM_SUBEXPRS = 2 };
+  Stmt *SubExprs[NUM_SUBEXPRS];
+  SourceLocation RBracketLoc;
+
+  void setBase(Expr *Base) { SubExprs[BASE_EXPR] = Base; }
+  void setIdx(Expr *Idx) { SubExprs[IDX_EXPR] = Idx; }
+
+public:
+  MSPropertySubscriptExpr(Expr *Base, Expr *Idx, QualType Ty, ExprValueKind VK,
+  ExprObjectKind OK, SourceLocation RBracketLoc)
+  : Expr(MSPropertySubscriptExprClass, Ty, VK, OK, Idx->isTypeDependent(),
+ Idx->isValueDependent(), Idx->isInstantiationDependent(),
+ Idx->containsUnexpandedParameterPack()),
+RBracketLoc(RBracketLoc) {
+SubExprs[BASE_EXPR] = Base;
+SubExprs[IDX_EXPR] = Idx;
+  }
+
+  /// \brief Create an empty array subscript expression.
+  explicit MSPropertySubscriptExpr(EmptyShell Shell)
+  : Expr(MSPropertySubscriptExprClass, Shell) {}
+
+  Expr *getBase() { return cast(SubExprs[BASE_EXPR]); }
+  const Expr *getBase() const { return cast(SubExprs[BASE_EXPR]); }
+
+  Expr *getIdx() { return cast(SubExprs[IDX_EXPR]); }
+  const Expr *getIdx() const { return cast(SubExprs[IDX_EXPR]); }
+
+  SourceLocation getLocStart() const LLVM_READONLY {
+return getBase()->getLocStart();
+  }
+  SourceLocation getLocEnd() const LLVM_READONLY { return RBracketLoc; }
+
+  SourceLocation getRBracketLoc() const { return RBracketLoc; }
+  void setRBracketLoc(SourceLocation L) { RBracketLoc = L; }
+
+  SourceLocation getExprLoc() const LLVM_READONLY {
+return getBase()->getExprLoc();
+  }
+
+  static bool classof(const Stmt *T) {
+return T->getStmtClass() == MSPropertySubscriptExprClass;
+  }
+
+  // Iterators
+  child_range children() {
+return child_range(&SubExprs[0], &SubExprs[0] + NUM_SUBEXPRS);
+  }
+};
+
 /// A Microsoft C++ @c __uuidof expression, which gets
 /// the _GUID that corresponds to the supplied type or expression.
 ///

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=254067&r1=254066&r2=254067&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Wed Nov 2

Re: [PATCH] D13336: [MSVC] 'property' with an empty array in array subscript expression.

2015-11-25 Thread Alexey Bataev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL254067: [MSVC] 'property' with an empty array in array 
subscript expression. (authored by ABataev).

Changed prior to commit:
  http://reviews.llvm.org/D13336?vs=41018&id=41125#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13336

Files:
  cfe/trunk/include/clang/AST/ExprCXX.h
  cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
  cfe/trunk/include/clang/Basic/StmtNodes.td
  cfe/trunk/include/clang/Serialization/ASTBitCodes.h
  cfe/trunk/lib/AST/Expr.cpp
  cfe/trunk/lib/AST/ExprClassification.cpp
  cfe/trunk/lib/AST/ExprConstant.cpp
  cfe/trunk/lib/AST/ItaniumMangle.cpp
  cfe/trunk/lib/AST/StmtPrinter.cpp
  cfe/trunk/lib/AST/StmtProfile.cpp
  cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaPseudoObject.cpp
  cfe/trunk/lib/Sema/TreeTransform.h
  cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
  cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
  cfe/trunk/test/CodeGenCXX/ms-property.cpp
  cfe/trunk/test/SemaCXX/ms-property-error.cpp
  cfe/trunk/test/SemaCXX/ms-property.cpp
  cfe/trunk/tools/libclang/CXCursor.cpp

Index: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
===
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
@@ -2112,6 +2112,8 @@
   TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
 })
 
+DEF_TRAVERSE_STMT(MSPropertySubscriptExpr, {})
+
 DEF_TRAVERSE_STMT(CXXUuidofExpr, {
   // The child-iterator will pick up the arg if it's an expression,
   // but not if it's a type.
Index: cfe/trunk/include/clang/AST/ExprCXX.h
===
--- cfe/trunk/include/clang/AST/ExprCXX.h
+++ cfe/trunk/include/clang/AST/ExprCXX.h
@@ -677,6 +677,69 @@
   friend class ASTStmtReader;
 };
 
+/// MS property subscript expression.
+/// MSVC supports 'property' attribute and allows to apply it to the
+/// declaration of an empty array in a class or structure definition.
+/// For example:
+/// \code
+/// __declspec(property(get=GetX, put=PutX)) int x[];
+/// \endcode
+/// The above statement indicates that x[] can be used with one or more array
+/// indices. In this case, i=p->x[a][b] will be turned into i=p->GetX(a, b), and
+/// p->x[a][b] = i will be turned into p->PutX(a, b, i).
+/// This is a syntactic pseudo-object expression.
+class MSPropertySubscriptExpr : public Expr {
+  friend class ASTStmtReader;
+  enum { BASE_EXPR, IDX_EXPR, NUM_SUBEXPRS = 2 };
+  Stmt *SubExprs[NUM_SUBEXPRS];
+  SourceLocation RBracketLoc;
+
+  void setBase(Expr *Base) { SubExprs[BASE_EXPR] = Base; }
+  void setIdx(Expr *Idx) { SubExprs[IDX_EXPR] = Idx; }
+
+public:
+  MSPropertySubscriptExpr(Expr *Base, Expr *Idx, QualType Ty, ExprValueKind VK,
+  ExprObjectKind OK, SourceLocation RBracketLoc)
+  : Expr(MSPropertySubscriptExprClass, Ty, VK, OK, Idx->isTypeDependent(),
+ Idx->isValueDependent(), Idx->isInstantiationDependent(),
+ Idx->containsUnexpandedParameterPack()),
+RBracketLoc(RBracketLoc) {
+SubExprs[BASE_EXPR] = Base;
+SubExprs[IDX_EXPR] = Idx;
+  }
+
+  /// \brief Create an empty array subscript expression.
+  explicit MSPropertySubscriptExpr(EmptyShell Shell)
+  : Expr(MSPropertySubscriptExprClass, Shell) {}
+
+  Expr *getBase() { return cast(SubExprs[BASE_EXPR]); }
+  const Expr *getBase() const { return cast(SubExprs[BASE_EXPR]); }
+
+  Expr *getIdx() { return cast(SubExprs[IDX_EXPR]); }
+  const Expr *getIdx() const { return cast(SubExprs[IDX_EXPR]); }
+
+  SourceLocation getLocStart() const LLVM_READONLY {
+return getBase()->getLocStart();
+  }
+  SourceLocation getLocEnd() const LLVM_READONLY { return RBracketLoc; }
+
+  SourceLocation getRBracketLoc() const { return RBracketLoc; }
+  void setRBracketLoc(SourceLocation L) { RBracketLoc = L; }
+
+  SourceLocation getExprLoc() const LLVM_READONLY {
+return getBase()->getExprLoc();
+  }
+
+  static bool classof(const Stmt *T) {
+return T->getStmtClass() == MSPropertySubscriptExprClass;
+  }
+
+  // Iterators
+  child_range children() {
+return child_range(&SubExprs[0], &SubExprs[0] + NUM_SUBEXPRS);
+  }
+};
+
 /// A Microsoft C++ @c __uuidof expression, which gets
 /// the _GUID that corresponds to the supplied type or expression.
 ///
Index: cfe/trunk/include/clang/Basic/StmtNodes.td
===
--- cfe/trunk/include/clang/Basic/StmtNodes.td
+++ cfe/trunk/include/clang/Basic/StmtNodes.td
@@ -180,6 +180,7 @@
 
 // Microsoft Extensions.
 def MSPropertyRefExpr : DStmt;
+def MSPropertySubscriptExpr : DStmt;
 def CXXUuidofExpr : DStmt; 
 def SEHTryStmt : Stmt;
 def SEHExceptStmt : Stmt;
Index: cfe/trunk/include/clang/Serialization/ASTBitCodes.h

Re: [PATCH] D13126: New static analyzer checker for loss of sign/precision

2015-11-25 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added a comment.

ping..

the latest patch has an alternative approach, where the checker track values of 
symbols.

  REGISTER_MAP_WITH_PROGRAMSTATE(DeclVal, const ValueDecl *, SVal)

The reason I don't use normal ProgramState values is that these symbol values 
are truncated.

I wonder what you think about this alternative approach. if I finish this, will 
it have a chance to be accepted?


http://reviews.llvm.org/D13126



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


Re: [PATCH] D13336: [MSVC] 'property' with an empty array in array subscript expression.

2015-11-25 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

John, thanks a lot for the review!
Committed version has a fix according to your last comment.


Repository:
  rL LLVM

http://reviews.llvm.org/D13336



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


[PATCH] D14982: ARM v8.1a adds Advanced SIMD instructions for Rounding Double Multiply Add/Subtract.

2015-11-25 Thread Alexandros Lamprineas via cfe-commits
labrinea created this revision.
labrinea added reviewers: jmolloy, rengolin, cfe-commits.
Herald added subscribers: rengolin, aemerson.

The following instructions are added to AArch32 instruction set:
  - VQRDMLAH: Vector Saturating Rounding Doubling Multiply Accumulate Retu   
ing High Half
  - VQRDMLSH: Vector Saturating Rounding Doubling Multiply Subtract Returning 
High Half

The following instructions are added to AArch64 instruction set:
  - SQRDMLAH: Signed Saturating Rounding Doubling Multiply Accumulate Returning 
High Half
  - SQRDMLSH: Signed Saturating Rounding Doubling Multiply Subtract Returning 
High Half

This patch adds intrinsic and ACLE macro support for these instructions, as 
well as corresponding tests.

http://reviews.llvm.org/D14982

Files:
  include/clang/Basic/arm_neon.td
  lib/Basic/Targets.cpp
  test/CodeGen/aarch64-neon-2velem.c
  test/CodeGen/aarch64-neon-intrinsics.c
  test/CodeGen/aarch64-neon-scalar-x-indexed-elem.c
  test/CodeGen/arm_neon_intrinsics.c
  test/Preprocessor/aarch64-target-features.c
  test/Preprocessor/arm-target-features.c

Index: test/Preprocessor/arm-target-features.c
===
--- test/Preprocessor/arm-target-features.c
+++ test/Preprocessor/arm-target-features.c
@@ -407,4 +407,5 @@
 // CHECK-V81A: __ARM_ARCH 8
 // CHECK-V81A: __ARM_ARCH_8_1A__ 1
 // CHECK-V81A: #define __ARM_ARCH_PROFILE 'A'
+// CHECK-V81A: __ARM_FEATURE_QRDMX 1
 // CHECK-V81A: #define __ARM_FP 0xE
Index: test/Preprocessor/aarch64-target-features.c
===
--- test/Preprocessor/aarch64-target-features.c
+++ test/Preprocessor/aarch64-target-features.c
@@ -71,6 +71,9 @@
 // CHECK-NEON: __ARM_NEON 1
 // CHECK-NEON: __ARM_NEON_FP 0xE
 
+// RUN: %clang -target aarch64-none-eabi -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-V81A %s
+// CHECK-V81A: __ARM_FEATURE_QRDMX 1
+
 // RUN: %clang -target aarch64 -march=arm64 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-ARCH-NOT-ACCEPT %s
 // RUN: %clang -target aarch64 -march=aarch64 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-ARCH-NOT-ACCEPT %s
 // CHECK-ARCH-NOT-ACCEPT: error: the clang compiler does not support
Index: test/CodeGen/arm_neon_intrinsics.c
===
--- test/CodeGen/arm_neon_intrinsics.c
+++ test/CodeGen/arm_neon_intrinsics.c
@@ -6425,6 +6425,64 @@
 }
 
 
+// CHECK-LABEL: test_vqrdmlah_s16
+// CHECK:  vqrdmulh.s16 [[REG:d[0-9]+]], d{{[0-9]+}}, d{{[0-9]+}}
+// CHECK-NEXT: vqadd.s16 d{{[0-9]+}}, d{{[0-9]+}}, [[REG]]
+int16x4_t test_vqrdmlah_s16(int16x4_t a, int16x4_t b, int16x4_t c) {
+  return vqrdmlah_s16(a, b, c);
+}
+
+// CHECK-LABEL: test_vqrdmlah_s32
+// CHECK:  vqrdmulh.s32 [[REG:d[0-9]+]], d{{[0-9]+}}, d{{[0-9]+}}
+// CHECK-NEXT: vqadd.s32 d{{[0-9]+}}, d{{[0-9]+}}, [[REG]]
+int32x2_t test_vqrdmlah_s32(int32x2_t a, int32x2_t b, int32x2_t c) {
+  return vqrdmlah_s32(a, b, c);
+}
+
+// CHECK-LABEL: test_vqrdmlahq_s16
+// CHECK:  vqrdmulh.s16 [[REG:q[0-9]+]], q{{[0-9]+}}, q{{[0-9]+}}
+// CHECK-NEXT: vqadd.s16 q{{[0-9]+}}, q{{[0-9]+}}, [[REG]]
+int16x8_t test_vqrdmlahq_s16(int16x8_t a, int16x8_t b, int16x8_t c) {
+  return vqrdmlahq_s16(a, b, c);
+}
+
+// CHECK-LABEL: test_vqrdmlahq_s32
+// CHECK:  vqrdmulh.s32 [[REG:q[0-9]+]], q{{[0-9]+}}, q{{[0-9]+}}
+// CHECK-NEXT: vqadd.s32 q{{[0-9]+}}, q{{[0-9]+}}, [[REG]]
+int32x4_t test_vqrdmlahq_s32(int32x4_t a, int32x4_t b, int32x4_t c) {
+  return vqrdmlahq_s32(a, b, c);
+}
+
+
+// CHECK-LABEL: test_vqrdmlsh_s16
+// CHECK:  vqrdmulh.s16 [[REG:d[0-9]+]], d{{[0-9]+}}, d{{[0-9]+}}
+// CHECK-NEXT: vqsub.s16 d{{[0-9]+}}, d{{[0-9]+}}, [[REG]]
+int16x4_t test_vqrdmlsh_s16(int16x4_t a, int16x4_t b, int16x4_t c) {
+  return vqrdmlsh_s16(a, b, c);
+}
+
+// CHECK-LABEL: test_vqrdmlsh_s32
+// CHECK:  vqrdmulh.s32 [[REG:d[0-9]+]], d{{[0-9]+}}, d{{[0-9]+}}
+// CHECK-NEXT: vqsub.s32 d{{[0-9]+}}, d{{[0-9]+}}, [[REG]]
+int32x2_t test_vqrdmlsh_s32(int32x2_t a, int32x2_t b, int32x2_t c) {
+  return vqrdmlsh_s32(a, b, c);
+}
+
+// CHECK-LABEL: test_vqrdmlshq_s16
+// CHECK:  vqrdmulh.s16 [[REG:q[0-9]+]], q{{[0-9]+}}, q{{[0-9]+}}
+// CHECK-NEXT: vqsub.s16 q{{[0-9]+}}, q{{[0-9]+}}, [[REG]]
+int16x8_t test_vqrdmlshq_s16(int16x8_t a, int16x8_t b, int16x8_t c) {
+  return vqrdmlshq_s16(a, b, c);
+}
+
+// CHECK-LABEL: test_vqrdmlshq_s32
+// CHECK:  vqrdmulh.s32 [[REG:q[0-9]+]], q{{[0-9]+}}, q{{[0-9]+}}
+// CHECK-NEXT: vqsub.s32 q{{[0-9]+}}, q{{[0-9]+}}, [[REG]]
+int32x4_t test_vqrdmlshq_s32(int32x4_t a, int32x4_t b, int32x4_t c) {
+  return vqrdmlshq_s32(a, b, c);
+}
+
+
 // CHECK-LABEL: test_vqrdmulh_lane_s16
 // CHECK: vqrdmulh.s16 d{{[0-9]+}}, d{{[0-9]+}}, d{{[0-9]+}}[{{[0-9]}}]
 int16x4_t test_vqrdmulh_lane_s16(int16x4_t a, int16x4_t b) {
@@ -6450,6 +6508,64 @@
 }
 
 
+// CHECK-LABEL: test_vqrdmlah_lane_s16
+// CHECK:  vqrdmulh.s16 [[REG:d[0-9]+]], d{{[0-9]+}}, d{{[0-9

Re: [PATCH] D14872: PR25575: Make GCC 4.4+ comatible layout for packed bit-fileds of char type

2015-11-25 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin updated this revision to Diff 41131.
DmitryPolukhin added a comment.

Added warning about semantic change + uploaded context. PTAL


http://reviews.llvm.org/D14872

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/struct-packed-align.c

Index: test/Sema/struct-packed-align.c
===
--- test/Sema/struct-packed-align.c
+++ test/Sema/struct-packed-align.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify
-// expected-no-diagnostics
+// RUN: %clang_cc1 %s -fsyntax-only -triple=x86_64-windows-coff -verify
 
 // Packed structs.
 struct s {
@@ -138,3 +138,24 @@
 extern int n1[sizeof(struct nS) == 9 ? 1 : -1];
 extern int n2[__alignof(struct nS) == 1 ? 1 : -1];
 #endif
+
+// Packed attribute shouldn't be ignored for bit-field of char types.
+// Note from GCC reference manual: The 4.1, 4.2 and 4.3 series of GCC ignore
+// the packed attribute on bit-fields of type char. This has been fixed in
+// GCC 4.4 but the change can lead to differences in the structure layout.
+// See the documentation of -Wpacked-bitfield-compat for more information.
+struct packed_chars {
+  char a:4;
+  char b:8 __attribute__ ((packed));
+  // expected-warning@-1 {{offset of packed bit-field 'b' has changed with GCC 
version 4.4 - the newer semantic is provided here}}
+  char c:4;
+};
+
+#if defined(_WIN32)
+// On Windows clang ignores uses MSVC compatible layout in this case.
+extern int o1[sizeof(struct packed_chars) == 3 ? 1 : -1];
+extern int o2[__alignof(struct packed_chars) == 1 ? 1 : -1];
+#else
+extern int o1[sizeof(struct packed_chars) == 2 ? 1 : -1];
+extern int o2[__alignof(struct packed_chars) == 1 ? 1 : -1];
+#endif
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -1040,13 +1040,15 @@
 // has no effect.
 if (!FD->getType()->isDependentType() &&
 !FD->getType()->isIncompleteType() &&
+FD->isBitField() &&
 S.Context.getTypeAlign(FD->getType()) <= 8)
-  S.Diag(Attr.getLoc(), diag::warn_attribute_ignored_for_field_of_type)
-<< Attr.getName() << FD->getType();
-else
-  FD->addAttr(::new (S.Context)
-  PackedAttr(Attr.getRange(), S.Context,
- Attr.getAttributeSpellingListIndex()));
+  S.Diag(Attr.getLoc(),
+ diag::note_attribute_packed_for_bitfield_semantics_changed)
+<< FD->getDeclName();
+
+FD->addAttr(::new (S.Context)
+PackedAttr(Attr.getRange(), S.Context,
+   Attr.getAttributeSpellingListIndex()));
   } else
 S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
 }
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2777,9 +2777,10 @@
   "cast to %1 from smaller integer type %0">,
   InGroup;
 
-def warn_attribute_ignored_for_field_of_type : Warning<
-  "%0 attribute ignored for field of type %1">,
-  InGroup;
+def note_attribute_packed_for_bitfield_semantics_changed : Warning<
+  "offset of packed bit-field %0 has changed with GCC version 4.4 - "
+  "the newer semantic is provided here">,
+  InGroup>;
 def warn_transparent_union_attribute_field_size_align : Warning<
   "%select{alignment|size}0 of field %1 (%2 bits) does not match the "
   "%select{alignment|size}0 of the first field in transparent union; "


Index: test/Sema/struct-packed-align.c
===
--- test/Sema/struct-packed-align.c
+++ test/Sema/struct-packed-align.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify
-// expected-no-diagnostics
+// RUN: %clang_cc1 %s -fsyntax-only -triple=x86_64-windows-coff -verify
 
 // Packed structs.
 struct s {
@@ -138,3 +138,24 @@
 extern int n1[sizeof(struct nS) == 9 ? 1 : -1];
 extern int n2[__alignof(struct nS) == 1 ? 1 : -1];
 #endif
+
+// Packed attribute shouldn't be ignored for bit-field of char types.
+// Note from GCC reference manual: The 4.1, 4.2 and 4.3 series of GCC ignore
+// the packed attribute on bit-fields of type char. This has been fixed in
+// GCC 4.4 but the change can lead to differences in the structure layout.
+// See the documentation of -Wpacked-bitfield-compat for more information.
+struct packed_chars {
+  char a:4;
+  char b:8 __attribute__ ((packed));
+  // expected-warning@-1 {{offset of packed bit-field 'b' has changed with GCC version 4.4 - the newer semantic is provided here}}
+  char c:4;
+};
+
+#if defined(_WIN32)
+// On Windows clang ignores uses MSVC compatible layout in this case.
+extern int o1[sizeof(struct packed_chars) == 3 ? 1 : -1];
+extern int o2[__alignof(struct packed_chars) == 1 ? 1 : -1];
+#else
+extern int o1[sizeof(struct p

Re: [libcxx] r254050 - Silence a -Wmissing-braces warning in the tests; mbstate_t is defined differently on different C libraries.

2015-11-25 Thread Joerg Sonnenberger via cfe-commits
On Tue, Nov 24, 2015 at 05:38:23PM -0800, David Blaikie via cfe-commits wrote:
> Could this initialization just be written as "mbstate_t mb = {}" & avoid
> the warning entirely (I'm not entirely sure what the warning was, but I
> imagine that'd avoid it)

Or even better, just use the portable memset(&mb, 0, sizeof(mb)).

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


Re: [PATCH] D14582: [clang-tidy] cppcoreguidelines-pro-bounds-pointer-arithmetic: ignore generated pointer arithmetic

2015-11-25 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Sorry for the delay, I was sick and didn't read mail.

Looks good with a nit. Thanks for the fix!



Comment at: clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp:28
@@ -28,1 +27,3 @@
+ hasType(pointerType()),
+ 
unless(hasLHS(ignoringImpCasts(declRefExpr(to(isImplicit()))
   .bind("expr"),

nit: Does this still fit to 80 characters? I mean, clang-format, please ;)


http://reviews.llvm.org/D14582



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


Re: [PATCH] D13980: Add "x87" in x86 target feature map

2015-11-25 Thread Andrey Turetskiy via cfe-commits
aturetsk updated this revision to Diff 41137.
aturetsk added a comment.

Use getCPUKind once


http://reviews.llvm.org/D13980

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/attr-target-x86-mmx.c
  test/CodeGen/attr-target-x86.c

Index: test/CodeGen/attr-target-x86.c
===
--- test/CodeGen/attr-target-x86.c
+++ test/CodeGen/attr-target-x86.c
@@ -18,6 +18,8 @@
 
 int __attribute__((target("no-mmx"))) qq(int a) { return 40; }
 
+int __attribute__((target("arch=i386"))) qix(int a) { return 4; }
+
 // Check that we emit the additional subtarget and cpu features for foo and 
not for baz or bar.
 // CHECK: baz{{.*}} #0
 // CHECK: foo{{.*}} #1
@@ -31,9 +33,11 @@
 // CHECK: qux{{.*}} #1
 // CHECK: qax{{.*}} #4
 // CHECK: qq{{.*}} #5
-// CHECK: #0 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+sse,+sse2"
-// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+xsave,+xsaveopt"
-// CHECK: #2 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+sse,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512pf,-avx512vl,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop,-xsave,-xsaveopt"
-// CHECK: #3 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
-// CHECK: #4 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+xsave,+xsaveopt,-aes"
-// CHECK: #5 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+sse,+sse2,-3dnow,-3dnowa,-mmx"
+// CHECK: qix{{.*}} #6
+// CHECK: #0 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+sse,+sse2,+x87"
+// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
+// CHECK: #2 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+sse,+x87,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512pf,-avx512vl,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop,-xsave,-xsaveopt"
+// CHECK: #3 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87"
+// CHECK: #4 = {{.*}}"target-cpu"="ivybridge" 
"target-features"="+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt,-aes"
+// CHECK: #5 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+fxsr,+sse,+sse2,+x87,-3dnow,-3dnowa,-mmx"
+// CHECK: #6 = {{.*}}"target-cpu"="i386" "target-features"="+mmx,+sse,+sse2"
Index: test/CodeGen/attr-target-x86-mmx.c
===
--- test/CodeGen/attr-target-x86-mmx.c
+++ test/CodeGen/attr-target-x86-mmx.c
@@ -19,4 +19,4 @@
   _mm_srai_pi32(a, c);
 }
 
-// CHECK: "target-features"="+mmx,+sse"
+// CHECK: "target-features"="+mmx,+sse,+x87"
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2542,7 +2542,13 @@
   if (getTriple().getArch() == llvm::Triple::x86_64)
 setFeatureEnabledImpl(Features, "sse2", true);
 
-  switch (getCPUKind(CPU)) {
+  CPUKind Kind = getCPUKind(CPU);
+
+  // All X86 processors but i386 have X87.
+  if (Kind != CK_i386)
+setFeatureEnabledImpl(Features, "x87", true);
+
+  switch (Kind) {
   case CK_Generic:
   case CK_i386:
   case CK_i486:


Index: test/CodeGen/attr-target-x86.c
===
--- test/CodeGen/attr-target-x86.c
+++ test/CodeGen/attr-target-x86.c
@@ -18,6 +18,8 @@
 
 int __attribute__((target("no-mmx"))) qq(int a) { return 40; }
 
+int __attribute__((target("arch=i386"))) qix(int a) { return 4; }
+
 // Check that we emit the additional subtarget and cpu features for foo and not for baz or bar.
 // CHECK: baz{{.*}} #0
 // CHECK: foo{{.*}} #1
@@ -31,9 +33,11 @@
 // CHECK: qux{{.*}} #1
 // CHECK: qax{{.*}} #4
 // CHECK: qq{{.*}} #5
-// CHECK: #0 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2"
-// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" "target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+xsave,+xsaveopt"
-// CHECK: #2 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512pf,-avx512vl,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop,-xsave,-xsaveopt"
-// CHECK: #3 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3"
-// CHECK: #4 = {{.*}}"target-cpu"="ivybridge" "target-features"="+avx,+

Re: [PATCH] D13980: Add "x87" in x86 target feature map

2015-11-25 Thread Andrey Turetskiy via cfe-commits
aturetsk added a comment.

> Are there any of the intrinsics in the headers that also depend on x87?


Not that I could find.



Comment at: lib/Basic/Targets.cpp:2545-2546
@@ -2544,2 +2544,4 @@
 
-  switch (getCPUKind(CPU)) {
+  CPUKind Kind = getCPUKind(CPU);
+
+  // All X86 processors but i386 have X87.

Done.


http://reviews.llvm.org/D13980



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


Re: [PATCH] D14824: [PATCH] Add clang-tidy check for static or thread_local objects where construction may throw

2015-11-25 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Sorry for the delay, I was sick last week.

Looks mostly fine.



Comment at: clang-tidy/cert/CERTTidyModule.cpp:19
@@ -18,2 +18,3 @@
 #include "../misc/ThrowByValueCatchByReferenceCheck.h"
+#include "StaticObjectExceptionCheck.h"
 #include "SetLongJmpCheck.h"

Please sort includes.


Comment at: clang-tidy/cert/StaticObjectExceptionCheck.cpp:18
@@ +17,3 @@
+namespace {
+AST_MATCHER(CXXConstructorDecl, isNoThrowConstructor) {
+  const auto *FnTy = Node.getType()->getAs();

ThrownExceptionTypeCheck.cpp defines a similar matcher. Looks like we need to 
move the `isNothrow` part to the ASTMatchers.h already.


Comment at: clang-tidy/cert/StaticObjectExceptionCheck.h:18
@@ +17,3 @@
+
+/// FIXME: Write a short description.
+///

Maybe address the FIXME right away? ;)


http://reviews.llvm.org/D14824



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


Re: [PATCH] D14286: ASTImporter: expressions, pt.1

2015-11-25 Thread Aleksei Sidorin via cfe-commits
a.sidorin added a comment.

I understand your position. However, we cannot check that we don't import 
`BreakStmt` as `ContinueStmt` using just ASTMerge without any verification. As 
I understand, unit tests is what we need  because we need to check that the 
overall imported type/expression is correct. And  I think that we really need 
to create tests for all nodes with import implemented since that is a target of 
tests (yes, it can take some time, but I think it is strictly required). With 
static_assert we can perform only a limited amount of checks so I decided to 
use ASTMatchers.
But I think I can just use both approaches: I may use your tests and keep this 
unit test framework as well to perform more strict checks.


http://reviews.llvm.org/D14286



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


Re: [PATCH] D12031: Const std::move() argument ClangTidy check

2015-11-25 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Awesome! Thank you for the new check!

There are a couple of nits, but I'll fix these before submitting the patch.



Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:42
@@ +41,3 @@
+auto MoveRange = CharSourceRange::getCharRange(CallMove->getSourceRange());
+auto FileMoveRange = Lexer::makeFileCharRange(MoveRange, SM, 
getLangOpts());
+if (!FileMoveRange.isValid()) {

s/auto/CharSourceRange/


Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:47
@@ +46,3 @@
+bool IsVariable = isa(Arg);
+DiagnosticBuilder DB =
+diag(FileMoveRange.getBegin(), "std::move of the %select{|const }0"

I'd replace `DiagnosticBuilder DB` with `auto Diag` - this is more a local 
convention, not a general rule.


Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:57
@@ +56,3 @@
+  Arg->getLocStart()),
+SM, getLangOpts());
+CharSourceRange AfterArgumentsRange = Lexer::makeFileCharRange(

This can probably happen when `Arg` comes from another macro (or a macro 
argument). A test can be added later.


http://reviews.llvm.org/D12031



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


Re: [PATCH] D14919: Fix IssueHash generation

2015-11-25 Thread Orbán György via cfe-commits
I did not create a test checker for the NormalizeLine error in the patch.
Should I add a test checker for this? Do you have any suggestions
where to put it if required?

GetEnclosingDeclContextSignature already checks for nullptr, this
should have been done in the NormalizeLine function also, but in that
case it is not enough because the Lexer needs the LangOpts.


On Tue, Nov 24, 2015 at 5:18 PM, Sean Eveson  wrote:
> seaneveson added a subscriber: seaneveson.
> seaneveson added a comment.
>
>> If the Decl *D pointer is nullptr the NormalizeLine would crash while 
>> getting the LangOptions.
>
>
> Do you have a reproducible test case for this?
>
>
> http://reviews.llvm.org/D14919
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14919: Fix IssueHash generation

2015-11-25 Thread Gyorgy Orban via cfe-commits
o.gyorgy added a subscriber: o.gyorgy.
o.gyorgy marked an inline comment as done.
o.gyorgy added a comment.

I did not create a test checker for the NormalizeLine error in the patch.
Should I add a test checker for this? Do you have any suggestions
where to put it if required?

GetEnclosingDeclContextSignature already checks for nullptr, this
should have been done in the NormalizeLine function also, but in that
case it is not enough because the Lexer needs the LangOpts.


http://reviews.llvm.org/D14919



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


Re: [PATCH] D14871: [Power PC] fix calculating address of arguments on stack for variadic functions

2015-11-25 Thread Strahinja Petrovic via cfe-commits
spetrovic updated the summary for this revision.
spetrovic updated this revision to Diff 41142.
spetrovic marked 4 inline comments as done.

http://reviews.llvm.org/D14871

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/ppc-varargs-struct.c

Index: test/CodeGen/ppc-varargs-struct.c
===
--- test/CodeGen/ppc-varargs-struct.c
+++ test/CodeGen/ppc-varargs-struct.c
@@ -39,9 +39,13 @@
 // CHECK-PPC:[[USING_OVERFLOW]]
 // CHECK-PPC-NEXT:  [[OVERFLOW_AREA_P:%[0-9]+]] = getelementptr inbounds 
%struct.__va_list_tag, %struct.__va_list_tag* [[ARRAYDECAY]], i32 0, i32 3
 // CHECK-PPC-NEXT:  [[OVERFLOW_AREA:%.+]] = load i8*, i8** 
[[OVERFLOW_AREA_P]], align 4
-// CHECK-PPC-NEXT:  [[MEMADDR:%.+]] = bitcast i8* [[OVERFLOW_AREA]] to 
%struct.x**
-// CHECK-PPC-NEXT:  [[NEW_OVERFLOW_AREA:%[0-9]+]] = getelementptr inbounds i8, 
i8* [[OVERFLOW_AREA]], i32 4
-// CHECK-PPC-NEXT:  store i8* [[NEW_OVERFLOW_AREA]], i8** [[OVERFLOW_AREA_P]]
+// CHECK-PPC-NEXT:  %{{[0-9]+}} =  ptrtoint i8* %{{[0-9]+}} to i32
+// CHECK-PPC-NEXT:  %{{[0-9]+}} = add i32 %{{[0-9]+}}, 7
+// CHECK-PPC-NEXT:  %{{[0-9]+}} = and i32 %{{[0-9]+}}, -8
+// CHECK-PPC-NEXT:  %overflow_arg_area.align = inttoptr i32 %{{[0-9]+}} to i8*
+// CHECK-PPC-NEXT:  [[MEMADDR:%.+]] = bitcast i8* %overflow_arg_area.align to 
%struct.x**
+// CHECK-PPC-NEXT:  [[NEW_OVERFLOW_AREA:%[0-9]+]] = getelementptr inbounds i8, 
i8* %overflow_arg_area.align, i32 4
+// CHECK-PPC-NEXT:  store i8* [[NEW_OVERFLOW_AREA:%[0-9]+]], i8** 
[[OVERFLOW_AREA_P]], align 4
 // CHECK-PPC-NEXT:  br label %[[CONT]]
 //
 // CHECK-PPC:[[CONT]]
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -223,6 +223,23 @@
   return Addr;
 }
 
+static Address emitRoundPointerUpToAlignment(CodeGenFunction &CGF,
+ llvm::Value *OverflowArgArea,
+ CharUnits Align) {
+  llvm::Value *PtrAsInt = OverflowArgArea;
+  // OverflowArgArea = (OverflowArgArea + Align - 1) & -Align;
+  PtrAsInt = CGF.Builder.CreatePtrToInt(PtrAsInt, CGF.IntPtrTy);
+  PtrAsInt = CGF.Builder.CreateAdd(PtrAsInt,
+llvm::ConstantInt::get(CGF.IntPtrTy, Align.getQuantity() - 1));
+  llvm::Value *Mask = llvm::ConstantInt::get(CGF.Int32Ty,
+ -Align.getQuantity());
+  PtrAsInt = CGF.Builder.CreateAnd(PtrAsInt, Mask);
+  PtrAsInt = CGF.Builder.CreateIntToPtr(PtrAsInt,
+OverflowArgArea->getType(),
+"overflow_arg_area.align");
+  return Address(PtrAsInt, Align);
+}
+
 /// Emit va_arg for a platform using the common void* representation,
 /// where arguments are simply emitted in an array of slots on the stack.
 ///
@@ -3543,9 +3560,14 @@
   Builder.CreateStructGEP(VAList, 3, CharUnits::fromQuantity(4));
 Address OverflowArea(Builder.CreateLoad(OverflowAreaAddr),
  OverflowAreaAlign);
-
-// The current address is the address of the varargs element.
-// FIXME: do we not need to round up to alignment?
+// Round up address of argument to alignment
+llvm::Value *OverflowArgArea = OverflowArea.getPointer();
+CharUnits Align = CGF.getContext().getTypeAlignInChars(Ty);
+if (Align > OverflowAreaAlign) {
+  OverflowArea = emitRoundPointerUpToAlignment(CGF, OverflowArgArea,
+   Align);
+}
+ 
 MemAddr = Builder.CreateElementBitCast(OverflowArea, DirectTy);
 
 // Increase the overflow area.


Index: test/CodeGen/ppc-varargs-struct.c
===
--- test/CodeGen/ppc-varargs-struct.c
+++ test/CodeGen/ppc-varargs-struct.c
@@ -39,9 +39,13 @@
 // CHECK-PPC:[[USING_OVERFLOW]]
 // CHECK-PPC-NEXT:  [[OVERFLOW_AREA_P:%[0-9]+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* [[ARRAYDECAY]], i32 0, i32 3
 // CHECK-PPC-NEXT:  [[OVERFLOW_AREA:%.+]] = load i8*, i8** [[OVERFLOW_AREA_P]], align 4
-// CHECK-PPC-NEXT:  [[MEMADDR:%.+]] = bitcast i8* [[OVERFLOW_AREA]] to %struct.x**
-// CHECK-PPC-NEXT:  [[NEW_OVERFLOW_AREA:%[0-9]+]] = getelementptr inbounds i8, i8* [[OVERFLOW_AREA]], i32 4
-// CHECK-PPC-NEXT:  store i8* [[NEW_OVERFLOW_AREA]], i8** [[OVERFLOW_AREA_P]]
+// CHECK-PPC-NEXT:  %{{[0-9]+}} =  ptrtoint i8* %{{[0-9]+}} to i32
+// CHECK-PPC-NEXT:  %{{[0-9]+}} = add i32 %{{[0-9]+}}, 7
+// CHECK-PPC-NEXT:  %{{[0-9]+}} = and i32 %{{[0-9]+}}, -8
+// CHECK-PPC-NEXT:  %overflow_arg_area.align = inttoptr i32 %{{[0-9]+}} to i8*
+// CHECK-PPC-NEXT:  [[MEMADDR:%.+]] = bitcast i8* %overflow_arg_area.align to %struct.x**
+// CHECK-PPC-NEXT:  [[NEW_OVERFLOW_AREA:%[0-9]+]] = getelementptr inbounds i8, i8* %overflow_arg_area.align, i32 4
+// CHECK-PPC-NEXT:  store i8* [[NEW_OVERFLOW_AREA:%[0-9]+]], i8** [[OVERFLOW

[clang-tools-extra] r254070 - [clang-tidy] Const std::move() argument ClangTidy check

2015-11-25 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Nov 25 09:56:11 2015
New Revision: 254070

URL: http://llvm.org/viewvc/llvm-project?rev=254070&view=rev
Log:
[clang-tidy] Const std::move() argument ClangTidy check

ClangTidy check for finding cases when std::move() is called with const or
trivially copyable arguments, that doesn't lead to any move or argument but it
makes copy. FixIt generates patch for removing call of std::move().

Patch by Vadym Doroshenko! (+ a couple of minor fixes)

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

Added:
clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h
clang-tools-extra/trunk/test/clang-tidy/move-const-arg.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=254070&r1=254069&r2=254070&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Wed Nov 25 09:56:11 
2015
@@ -10,6 +10,7 @@ add_clang_library(clangTidyMiscModule
   MacroParenthesesCheck.cpp
   MacroRepeatedSideEffectsCheck.cpp
   MiscTidyModule.cpp
+  MoveConstantArgumentCheck.cpp 
   MoveConstructorInitCheck.cpp
   NewDeleteOverloadsCheck.cpp
   NoexceptMoveConstructorCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp?rev=254070&r1=254069&r2=254070&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp Wed Nov 25 
09:56:11 2015
@@ -18,6 +18,7 @@
 #include "InefficientAlgorithmCheck.h"
 #include "MacroParenthesesCheck.h"
 #include "MacroRepeatedSideEffectsCheck.h"
+#include "MoveConstantArgumentCheck.h"
 #include "MoveConstructorInitCheck.h"
 #include "NewDeleteOverloadsCheck.h"
 #include "NoexceptMoveConstructorCheck.h"
@@ -54,6 +55,8 @@ public:
 "misc-macro-parentheses");
 CheckFactories.registerCheck(
 "misc-macro-repeated-side-effects");
+CheckFactories.registerCheck(
+"misc-move-const-arg");
 CheckFactories.registerCheck(
 "misc-move-constructor-init");
 CheckFactories.registerCheck(

Added: clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp?rev=254070&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp Wed 
Nov 25 09:56:11 2015
@@ -0,0 +1,71 @@
+//===--- MoveConstandArgumentCheck.cpp - clang-tidy 
---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "MoveConstantArgumentCheck.h"
+
+#include 
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+using namespace ast_matchers;
+
+void MoveConstantArgumentCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+  Finder->addMatcher(callExpr(unless(isInTemplateInstantiation()),
+  callee(functionDecl(hasName("::std::move"
+ .bind("call-move"),
+ this);
+}
+
+void MoveConstantArgumentCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *CallMove = Result.Nodes.getNodeAs("call-move");
+  if (CallMove->getNumArgs() != 1)
+return;
+  const Expr *Arg = CallMove->getArg(0);
+  SourceManager &SM = Result.Context->getSourceManager();
+
+  bool IsConstArg = Arg->getType().isConstQualified();
+  bool IsTriviallyCopyable =
+  Arg->getType().isTriviallyCopyableType(*Result.Context);
+
+  if (IsConstArg || IsTriviallyCopyable) {
+auto MoveRange = CharSourceRange::getCharRange(CallMove->getSourceRange());
+auto FileMoveRange = Lexer::makeFileCharRange(MoveRange, SM, 
getLangOpts());
+if (!FileMoveRange.isValid())
+  return;
+bool IsVariable = isa(Arg);
+auto Diag =
+diag(FileMoveRange.getBegin(), "std::move of the %select{|const }0"
+   "%select{expression|variable}1 "
+   "%select{|of trivially-copyable type }2"
+   

Re: [PATCH] D12031: Const std::move() argument ClangTidy check

2015-11-25 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL254070: [clang-tidy] Const std::move() argument ClangTidy 
check (authored by alexfh).

Changed prior to commit:
  http://reviews.llvm.org/D12031?vs=41061&id=41146#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12031

Files:
  clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h
  clang-tools-extra/trunk/test/clang-tidy/move-const-arg.cpp

Index: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
@@ -10,6 +10,7 @@
   MacroParenthesesCheck.cpp
   MacroRepeatedSideEffectsCheck.cpp
   MiscTidyModule.cpp
+  MoveConstantArgumentCheck.cpp 
   MoveConstructorInitCheck.cpp
   NewDeleteOverloadsCheck.cpp
   NoexceptMoveConstructorCheck.cpp
Index: clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
@@ -18,6 +18,7 @@
 #include "InefficientAlgorithmCheck.h"
 #include "MacroParenthesesCheck.h"
 #include "MacroRepeatedSideEffectsCheck.h"
+#include "MoveConstantArgumentCheck.h"
 #include "MoveConstructorInitCheck.h"
 #include "NewDeleteOverloadsCheck.h"
 #include "NoexceptMoveConstructorCheck.h"
@@ -54,6 +55,8 @@
 "misc-macro-parentheses");
 CheckFactories.registerCheck(
 "misc-macro-repeated-side-effects");
+CheckFactories.registerCheck(
+"misc-move-const-arg");
 CheckFactories.registerCheck(
 "misc-move-constructor-init");
 CheckFactories.registerCheck(
Index: clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h
@@ -0,0 +1,31 @@
+//===--- MoveConstandArgumentCheck.h - clang-tidy -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONTANTARGUMENTCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONTANTARGUMENTCHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+class MoveConstantArgumentCheck : public ClangTidyCheck {
+public:
+  MoveConstantArgumentCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace misc
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONTANTARGUMENTCHECK_H
Index: clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
@@ -0,0 +1,71 @@
+//===--- MoveConstandArgumentCheck.cpp - clang-tidy ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "MoveConstantArgumentCheck.h"
+
+#include 
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+using namespace ast_matchers;
+
+void MoveConstantArgumentCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+  Finder->addMatcher(callExpr(unless(isInTemplateInstantiation()),
+  callee(functionDecl(hasName("::std::move"
+ .bind("call-move"),
+ this);
+}
+
+void MoveConstantArgumentCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *CallMove = Result.Nodes.getNodeAs("call-move");
+  if (CallMove->getNumArgs() != 1)
+return;
+  const Expr *Arg = CallMove->getArg(0);
+  SourceManager &SM = Result.Context->getSourceManager();
+
+  bool IsConstArg = Arg->getType().isConstQualified();
+  bool IsTriviallyCopyable =
+  Arg->getType().isTriviallyCopyableType(*Result.Context);
+
+  if (IsConstArg || IsTr

Re: [PATCH] D12031: Const std::move() argument ClangTidy check

2015-11-25 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Missed a couple of comments. Anyway, I'm fixing these myself as a part of 
commit.



Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:42
@@ +41,3 @@
+auto MoveRange = CharSourceRange::getCharRange(CallMove->getSourceRange());
+auto FileMoveRange = Lexer::makeFileCharRange(MoveRange, SM, 
getLangOpts());
+if (!FileMoveRange.isValid()) {

alexfh wrote:
> s/auto/CharSourceRange/
... or do the reverse below on lines 54, 58.


Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:43
@@ +42,3 @@
+auto FileMoveRange = Lexer::makeFileCharRange(MoveRange, SM, 
getLangOpts());
+if (!FileMoveRange.isValid()) {
+  return;

It's not common for LLVM style to put braces around single-line bodies of loops 
and  conditional statements.


Repository:
  rL LLVM

http://reviews.llvm.org/D12031



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


Re: [libcxx] r254050 - Silence a -Wmissing-braces warning in the tests; mbstate_t is defined differently on different C libraries.

2015-11-25 Thread David Blaikie via cfe-commits
Is {} not portable in some way?
On Nov 25, 2015 5:58 AM, "Joerg Sonnenberger via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> On Tue, Nov 24, 2015 at 05:38:23PM -0800, David Blaikie via cfe-commits
> wrote:
> > Could this initialization just be written as "mbstate_t mb = {}" & avoid
> > the warning entirely (I'm not entirely sure what the warning was, but I
> > imagine that'd avoid it)
>
> Or even better, just use the portable memset(&mb, 0, sizeof(mb)).
>
> Joerg
> ___
> 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


[clang-tools-extra] r254074 - [clang-tidy] Fix a typo in my latest commit.

2015-11-25 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Nov 25 10:38:22 2015
New Revision: 254074

URL: http://llvm.org/viewvc/llvm-project?rev=254074&view=rev
Log:
[clang-tidy] Fix a typo in my latest commit.

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

Modified: clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp?rev=254074&r1=254073&r2=254074&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp Wed 
Nov 25 10:38:22 2015
@@ -60,8 +60,8 @@ void MoveConstantArgumentCheck::check(co
 SM, getLangOpts());
 
 if (BeforeArgumentsRange.isValid() && AfterArgumentsRange.isValid()) {
-  DB << FixItHint::CreateRemoval(BeforeArgumentsRange)
- << FixItHint::CreateRemoval(AfterArgumentsRange);
+  Diag << FixItHint::CreateRemoval(BeforeArgumentsRange)
+   << FixItHint::CreateRemoval(AfterArgumentsRange);
 }
   }
 }


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


Re: [PATCH] D14824: [PATCH] Add clang-tidy check for static or thread_local objects where construction may throw

2015-11-25 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D14824#296574, @alexfh wrote:

> Sorry for the delay, I was sick last week.


No worries on the delay, I was sick the last two weeks as well. I hope you are 
feeling better!



Comment at: clang-tidy/cert/StaticObjectExceptionCheck.cpp:18
@@ +17,3 @@
+namespace {
+AST_MATCHER(CXXConstructorDecl, isNoThrowConstructor) {
+  const auto *FnTy = Node.getType()->getAs();

alexfh wrote:
> ThrownExceptionTypeCheck.cpp defines a similar matcher. Looks like we need to 
> move the `isNothrow` part to the ASTMatchers.h already.
Agreed; implemented.


Comment at: clang-tidy/cert/StaticObjectExceptionCheck.h:18
@@ +17,3 @@
+
+/// FIXME: Write a short description.
+///

alexfh wrote:
> Maybe address the FIXME right away? ;)
LOL! Good catch. :-)


http://reviews.llvm.org/D14824



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


Re: [PATCH] D14824: [PATCH] Add clang-tidy check for static or thread_local objects where construction may throw

2015-11-25 Thread Aaron Ballman via cfe-commits
aaron.ballman updated this revision to Diff 41150.
aaron.ballman marked 3 inline comments as done.
aaron.ballman added a comment.

Updating patch based on review comments.


http://reviews.llvm.org/D14824

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  clang-tidy/cert/StaticObjectExceptionCheck.cpp
  clang-tidy/cert/StaticObjectExceptionCheck.h
  clang-tidy/cert/ThrownExceptionTypeCheck.cpp
  clang-tidy/utils/Matchers.h
  docs/clang-tidy/checks/cert-static-object-exception.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cert-static-object-exception.cpp

Index: test/clang-tidy/cert-static-object-exception.cpp
===
--- test/clang-tidy/cert-static-object-exception.cpp
+++ test/clang-tidy/cert-static-object-exception.cpp
@@ -0,0 +1,52 @@
+// RUN: %check_clang_tidy %s cert-err58-cpp %t
+
+struct S {
+  S() noexcept(false);
+};
+
+struct T {
+  T() noexcept;
+};
+
+struct U {
+  U() {}
+};
+
+struct V {
+  explicit V(const char *) {} // Can throw
+};
+
+
+S s;
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 's' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]
+// CHECK-MESSAGES: 4:3: note: possibly throwing constructor declared here
+T t; // ok
+U u;
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 'u' with static storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: 12:3: note: possibly throwing constructor declared here
+V v("v");
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 'v' with static storage duration may throw an exception that cannot be caught
+// CHECK-MESSAGES: 16:12: note: possibly throwing constructor declared here
+
+void f(S s1, T t1, U u1, V v1) { // ok, ok, ok, ok
+  S s2; // ok
+  T t2; // ok
+  U u2; // ok
+  V v2("v"); // ok
+
+  thread_local S s3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: construction of 's3' with thread_local storage duration may throw an exception that cannot be caught
+  thread_local T t3; // ok
+  thread_local U u3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: construction of 'u3' with thread_local storage duration may throw an exception that cannot be caught
+  thread_local V v3("v");
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: construction of 'v3' with thread_local storage duration may throw an exception that cannot be caught
+
+  static S s4;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: construction of 's4' with static storage duration may throw an exception that cannot be caught
+  static T t4; // ok
+  static U u4;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: construction of 'u4' with static storage duration may throw an exception that cannot be caught
+  static V v4("v");
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: construction of 'v4' with static storage duration may throw an exception that cannot be caught
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -1,8 +1,9 @@
 List of clang-tidy Checks
 =
 
-.. toctree::
+.. toctree::   
cert-setlongjmp
+   cert-static-object-exception
cert-thrown-exception-type
cert-variadic-function-def
cppcoreguidelines-pro-bounds-array-to-pointer-decay
Index: docs/clang-tidy/checks/cert-static-object-exception.rst
===
--- docs/clang-tidy/checks/cert-static-object-exception.rst
+++ docs/clang-tidy/checks/cert-static-object-exception.rst
@@ -0,0 +1,9 @@
+cert-err58-cpp
+==
+
+This check flags all static or thread_local variable declarations where the
+constructor for the object may throw an exception.
+
+This check corresponds to the CERT C++ Coding Standard rule
+`ERR58-CPP. Constructors of objects with static or thread storage duration must not throw exceptions
+`_.
Index: clang-tidy/utils/Matchers.h
===
--- clang-tidy/utils/Matchers.h
+++ clang-tidy/utils/Matchers.h
@@ -23,6 +23,22 @@
   return IsExpensive && *IsExpensive;
 }
 
+AST_MATCHER(FunctionDecl, isNoThrow) {
+  const auto *FnTy = Node.getType()->getAs();
+  
+  // If the function does not have a prototype, then it is assumed to be a
+  // throwing function (as it would if the function did not have any exception
+  // specification).
+  if (!FnTy)
+return false;
+
+  // Assume the best for any unresolved exception specification.
+  if (isUnresolvedExceptionSpec(FnTy->getExceptionSpecType()))
+return true;
+
+  return FnTy->isNothrow(Node.getASTContext());
+}
+
 } // namespace matchers
 } // namespace tidy
 } // namespace clang
Index: clang-tidy/cert/ThrownExceptio

Re: r253958 - Reduce the stack usage per recursive step when RecursiveASTVisitor cannot perform data recursion.

2015-11-25 Thread David Blaikie via cfe-commits
Guessing this or one of the related patches introduced this build breakage?
I haven't looked at it too carefully yet...

http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/26570/steps/compile/logs/stdio

On Mon, Nov 23, 2015 at 11:13 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Tue Nov 24 01:13:06 2015
> New Revision: 253958
>
> URL: http://llvm.org/viewvc/llvm-project?rev=253958&view=rev
> Log:
> Reduce the stack usage per recursive step when RecursiveASTVisitor cannot
> perform data recursion.
>
> Modified:
> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
>
> Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=253958&r1=253957&r2=253958&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
> +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Tue Nov 24 01:13:06
> 2015
> @@ -471,28 +471,10 @@ private:
>/// \brief Process clauses with list of variables.
>template  bool VisitOMPClauseList(T *Node);
>
> -  bool dataTraverse(Stmt *S);
>bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue);
>  };
>
>  template 
> -bool RecursiveASTVisitor::dataTraverse(Stmt *S) {
> -  SmallVector Queue;
> -  Queue.push_back(S);
> -
> -  while (!Queue.empty()) {
> -Stmt *CurrS = Queue.pop_back_val();
> -
> -size_t N = Queue.size();
> -TRY_TO(dataTraverseNode(CurrS, &Queue));
> -// Process new children in the order they were added.
> -std::reverse(Queue.begin() + N, Queue.end());
> -  }
> -
> -  return true;
> -}
> -
> -template 
>  bool RecursiveASTVisitor::dataTraverseNode(Stmt *S,
>  DataRecursionQueue
> *Queue) {
>  #define DISPATCH_STMT(NAME, CLASS, VAR)
>   \
> @@ -561,10 +543,23 @@ bool RecursiveASTVisitor::Trave
>&RecursiveASTVisitor::TraverseStmt>::value)
>  return dataTraverseNode(S, nullptr);
>
> -  if (!Queue)
> -return dataTraverse(S);
> +  if (Queue) {
> +Queue->push_back(S);
> +return true;
> +  }
> +
> +  SmallVector LocalQueue;
> +  LocalQueue.push_back(S);
> +
> +  while (!LocalQueue.empty()) {
> +Stmt *CurrS = LocalQueue.pop_back_val();
> +
> +size_t N = LocalQueue.size();
> +TRY_TO(dataTraverseNode(CurrS, &LocalQueue));
> +// Process new children in the order they were added.
> +std::reverse(LocalQueue.begin() + N, LocalQueue.end());
> +  }
>
> -  Queue->push_back(S);
>return true;
>  }
>
>
>
> ___
> 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


Re: [PATCH] D6370: Disable frame pointer elimination when -pg is used

2015-11-25 Thread Sanjay Patel via cfe-commits
spatel added a subscriber: spatel.
spatel added a comment.

Abandon patch?
http://reviews.llvm.org/D14215
http://reviews.llvm.org/rL253886


http://reviews.llvm.org/D6370



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


Re: [PATCH] D14286: ASTImporter: expressions, pt.1

2015-11-25 Thread Serge Pavlov via cfe-commits
sepavloff added a comment.

If you are going to make unit tests, consider alternative approach also. In 
repository `test-suite` the directory `SingleSource/UnitTests` contains runtime 
tests obtained from single file. You could modify Makefile that runs these 
tests in such a way that each test runs twice, one as now it runs and the other 
would run through the sequence `compile to ast` - `compile empty source with 
with ast-import`. Tests for missing nodes could be added into 
`SingleSource/UnitTests`, they would be substantially simpler that those using 
ASTMatchers. More importantly, such tests would make indeed exhaustive testing 
of importer.


http://reviews.llvm.org/D14286



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


Re: [PATCH] D14982: ARM v8.1a adds Advanced SIMD instructions for Rounding Double Multiply Add/Subtract.

2015-11-25 Thread Tim Northover via cfe-commits
t.p.northover added a subscriber: t.p.northover.
t.p.northover added a comment.

Do these get the right diagnostics when used on CPUs without the new feature? I 
can't see how __ARM_FEATURE_QRDMX gets wired through to arm_neon.h.


http://reviews.llvm.org/D14982



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


Re: [PATCH] D13126: New static analyzer checker for loss of sign/precision

2015-11-25 Thread Artem Dergachev via cfe-commits
NoQ added a subscriber: NoQ.
NoQ added a comment.

In http://reviews.llvm.org/D13126#291763, @danielmarjamaki wrote:

> I have problems with the "default" handling of expressions.
>
> I want to warn about loss of precision for such code:
>
>   unsigned int x = 256;
>   unsigned char c;
>   c = x;
>   
>
> The analyser tells me that the RHS value is 0 instead of 256 in the 
> assignment "c = x". Here is the dump of the ProgramState:
>
> Store (direct and default bindings), 0x0 :
>
> Expressions:
>  (0x7b9bd30,0x7b458d8) c : &c
>  (0x7b9bd30,0x7b45940) x : 0 U8b
>  Ranges are empty.


Hmm. I guess you need to sign up for the cast expression rather than for the 
binary operator expression. By the time you reach the assignment operator, the 
value before the cast is already removed from the environment.


http://reviews.llvm.org/D13126



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


Re: [PATCH] D6370: Disable frame pointer elimination when -pg is used

2015-11-25 Thread Sanjay Patel via cfe-commits
spatel added a comment.

[I posted this in Phab, but it has not made it to the mailing list.]

Abandon patch?
http://reviews.llvm.org/D14215
http://reviews.llvm.org/rL253886

Also, I linked:
https://llvm.org/bugs/show_bug.cgi?id=14713
https://llvm.org/bugs/show_bug.cgi?id=25535


http://reviews.llvm.org/D6370



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


Re: [PATCH] D14964: [clang-tidy] Fix problem with parallel configure build

2015-11-25 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL254081: Fix problem with Clang-tidy parallel configure 
build. (authored by eugenezelenko).

Changed prior to commit:
  http://reviews.llvm.org/D14964?vs=41076&id=41160#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14964

Files:
  clang-tools-extra/trunk/clang-tidy/tool/Makefile

Index: clang-tools-extra/trunk/clang-tidy/tool/Makefile
===
--- clang-tools-extra/trunk/clang-tidy/tool/Makefile
+++ clang-tools-extra/trunk/clang-tidy/tool/Makefile
@@ -39,10 +39,10 @@
$(Echo) Making install directory: $@
$(Verb) $(MKDIR) $@
 
-$(DESTFILES): $(SRCFILES)
+$(DESTFILES): $(SRCFILES) $(PROJ_sharedir)
 
 $(PROJ_sharedir)/%.py: $(PROJ_SRC_DIR)/%.py
$(Echo) Installing script file: $(notdir $<)
$(Verb) $(ScriptInstall) $< $(PROJ_sharedir)
 
-install-local:: $(PROJ_sharedir) $(DESTFILES)
+install-local:: $(DESTFILES)


Index: clang-tools-extra/trunk/clang-tidy/tool/Makefile
===
--- clang-tools-extra/trunk/clang-tidy/tool/Makefile
+++ clang-tools-extra/trunk/clang-tidy/tool/Makefile
@@ -39,10 +39,10 @@
 	$(Echo) Making install directory: $@
 	$(Verb) $(MKDIR) $@
 
-$(DESTFILES): $(SRCFILES)
+$(DESTFILES): $(SRCFILES) $(PROJ_sharedir)
 
 $(PROJ_sharedir)/%.py: $(PROJ_SRC_DIR)/%.py
 	$(Echo) Installing script file: $(notdir $<)
 	$(Verb) $(ScriptInstall) $< $(PROJ_sharedir)
 
-install-local:: $(PROJ_sharedir) $(DESTFILES)
+install-local:: $(DESTFILES)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r254081 - Fix problem with Clang-tidy parallel configure build.

2015-11-25 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Wed Nov 25 13:16:34 2015
New Revision: 254081

URL: http://llvm.org/viewvc/llvm-project?rev=254081&view=rev
Log:
Fix problem with Clang-tidy parallel configure build.

Differential revision: http://reviews.llvm.org/D14964

Modified:
clang-tools-extra/trunk/clang-tidy/tool/Makefile

Modified: clang-tools-extra/trunk/clang-tidy/tool/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/Makefile?rev=254081&r1=254080&r2=254081&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/Makefile (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/Makefile Wed Nov 25 13:16:34 2015
@@ -39,10 +39,10 @@ $(PROJ_sharedir):
$(Echo) Making install directory: $@
$(Verb) $(MKDIR) $@
 
-$(DESTFILES): $(SRCFILES)
+$(DESTFILES): $(SRCFILES) $(PROJ_sharedir)
 
 $(PROJ_sharedir)/%.py: $(PROJ_SRC_DIR)/%.py
$(Echo) Installing script file: $(notdir $<)
$(Verb) $(ScriptInstall) $< $(PROJ_sharedir)
 
-install-local:: $(PROJ_sharedir) $(DESTFILES)
+install-local:: $(DESTFILES)


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


r254083 - Stop using SFINAE to detect whether a derived-class override of Traverse* can

2015-11-25 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Nov 25 13:33:20 2015
New Revision: 254083

URL: http://llvm.org/viewvc/llvm-project?rev=254083&view=rev
Log:
Stop using SFINAE to detect whether a derived-class override of Traverse* can
take a queue; some supported versions of GCC believe that this substitution
failure is an error. Instead, use a partial specialization to detect the type
of a pointer to the corresponding member. This is less general, but good enough
for our uses.

Modified:
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=254083&r1=254082&r2=254083&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Wed Nov 25 13:33:20 2015
@@ -276,14 +276,11 @@ public:
 //  Methods on Stmts 
 
 private:
-  // Determine if the specified derived-class member M can be passed a
-  // DataRecursionQueue* argument.
-  template
-  std::false_type callableWithQueue(...);
-  template
-  std::true_type callableWithQueue(M m, Derived *d = nullptr, P *p = nullptr,
-   DataRecursionQueue *q = nullptr,
-   decltype((d->*m)(p, q)) = false);
+  template
+  struct has_same_member_pointer_type : std::false_type {};
+  template
+  struct has_same_member_pointer_type
+  : std::true_type {};
 
   // Traverse the given statement. If the most-derived traverse function takes 
a
   // data recursion queue, pass it on; otherwise, discard it. Note that the
@@ -291,10 +288,13 @@ private:
   // class can take a queue, so if we're taking the second arm, make the first
   // arm call our function rather than the derived class version.
 #define TRAVERSE_STMT_BASE(NAME, CLASS, VAR, QUEUE)
\
-  (decltype(callableWithQueue(&Derived::Traverse##NAME))::value 
\
+  (has_same_member_pointer_type::value 
\
? static_cast(&Derived::Traverse##NAME))::value,   
\
+ has_same_member_pointer_type< 
\
+ decltype(&RecursiveASTVisitor::Traverse##NAME),   
\
+ decltype(&Derived::Traverse##NAME)>::value,   
\
  Derived &, RecursiveASTVisitor &>::type>(*this)   
\
  .Traverse##NAME(static_cast(VAR), QUEUE) 
\
: getDerived().Traverse##NAME(static_cast(VAR)))


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


Re: [PATCH] D14215: Disable frame pointer elimination when using -pg

2015-11-25 Thread Simon Pilgrim via cfe-commits
RKSimon added a subscriber: RKSimon.
RKSimon closed this revision.
RKSimon added a comment.

Committed at http://reviews.llvm.org/rL253886


http://reviews.llvm.org/D14215



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


r254097 - P0001R1: 'register' storage class specifier is no longer permitted in C++1z.

2015-11-25 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Nov 25 15:34:21 2015
New Revision: 254097

URL: http://llvm.org/viewvc/llvm-project?rev=254097&view=rev
Log:
P0001R1: 'register' storage class specifier is no longer permitted in C++1z.

We will still allow it in system headers, in macros from system headers, when
combined with an 'asm' label, and under the flag -Wno-register.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/deprecated.cpp
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=254097&r1=254096&r2=254097&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Nov 25 15:34:21 2015
@@ -187,6 +187,8 @@ def CXX14Compat : DiagGroup<"c++14-compa
 def CXX14CompatPedantic : DiagGroup<"c++14-compat-pedantic",
 [CXXPre1zCompatPedantic]>;
 
+def CXX1zCompat : DiagGroup<"c++1z-compat", [DeprecatedRegister]>;
+
 def : DiagGroup<"effc++">;
 def DivZero : DiagGroup<"division-by-zero">;
 def ExitTimeDestructors : DiagGroup<"exit-time-destructors">;
@@ -314,6 +316,7 @@ def : DiagGroup<"redundant-decls">;
 def RedeclaredClassMember : DiagGroup<"redeclared-class-member">;
 def GNURedeclaredEnum : DiagGroup<"gnu-redeclared-enum">;
 def RedundantMove : DiagGroup<"redundant-move">;
+def Register : DiagGroup<"register", [DeprecatedRegister]>;
 def ReturnStackAddress : DiagGroup<"return-stack-address">;
 def ReturnTypeCLinkage : DiagGroup<"return-type-c-linkage">;
 def ReturnType : DiagGroup<"return-type", [ReturnTypeCLinkage]>;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=254097&r1=254096&r2=254097&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Nov 25 15:34:21 
2015
@@ -213,8 +213,11 @@ def warn_auto_storage_class : Warning<
   InGroup, DefaultIgnore;
 
 def warn_deprecated_register : Warning<
-  "'register' storage class specifier is deprecated">,
-  InGroup;
+  "'register' storage class specifier is deprecated "
+  "and incompatible with C++1z">, InGroup;
+def ext_register_storage_class : ExtWarn<
+  "ISO C++1z does not allow 'register' storage class specifier">,
+  DefaultError, InGroup;
 
 def err_invalid_decl_spec_combination : Error<
   "cannot combine with previous '%0' declaration specifier">;

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=254097&r1=254096&r2=254097&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Nov 25 15:34:21 2015
@@ -5709,7 +5709,8 @@ Sema::ActOnVariableDeclarator(Scope *S,
 // Suppress the warning in system macros, it's used in macros in some
 // popular C system headers, such as in glibc's htonl() macro.
 Diag(D.getDeclSpec().getStorageClassSpecLoc(),
- diag::warn_deprecated_register)
+ getLangOpts().CPlusPlus1z ? diag::ext_register_storage_class
+   : diag::warn_deprecated_register)
   << FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc());
   }
 

Modified: cfe/trunk/test/SemaCXX/deprecated.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/deprecated.cpp?rev=254097&r1=254096&r2=254097&view=diff
==
--- cfe/trunk/test/SemaCXX/deprecated.cpp (original)
+++ cfe/trunk/test/SemaCXX/deprecated.cpp Wed Nov 25 15:34:21 2015
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -std=c++98 %s -Wdeprecated -verify -triple x86_64-linux-gnu
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -triple x86_64-linux-gnu
 // RUN: %clang_cc1 -std=c++1y %s -Wdeprecated -verify -triple x86_64-linux-gnu
+// RUN: %clang_cc1 -std=c++1z %s -Wdeprecated -verify -triple x86_64-linux-gnu
 
 // RUN: %clang_cc1 -std=c++1y %s -Wdeprecated -verify -triple x86_64-linux-gnu 
-Wno-deprecated-register -DNO_DEPRECATED_FLAGS
 
@@ -17,8 +18,10 @@ void h() throw(...);
 
 void stuff() {
   register int n;
-#if __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS)
-  // expected-warning@-2 {{'register' storage class specifier is deprecated}}
+#if __cplusplus > 201402L
+  // expected-error@-2 {{ISO C++1z does not allow 'register' storage class 
specifier}}
+#elif __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS)
+  // expected-warning@-4 {{'register

Re: [PATCH] D14872: PR25575: Make GCC 4.4+ comatible layout for packed bit-fileds of char type

2015-11-25 Thread hfin...@anl.gov via cfe-commits
hfinkel added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2783
@@ -2783,1 +2782,3 @@
+  "the newer semantic is provided here">,
+  InGroup>;
 def warn_transparent_union_attribute_field_size_align : Warning<

Calling this "a semantic" reads oddly to me. This sounds better to me:

  def note_attribute_packed_for_bitfield_offset_changed : Warning<
"the offset assigned to packed bit-field member %0 has changed with GCC 
version 4.4 - "
"the newer offset is used here">,
InGroup>;


Comment at: lib/Sema/SemaDeclAttr.cpp:1040
@@ -1039,3 +1039,3 @@
 // If the alignment is less than or equal to 8 bits, the packed attribute
 // has no effect.
 if (!FD->getType()->isDependentType() &&

This comment is now out of date?


http://reviews.llvm.org/D14872



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


Re: [PATCH] D14872: PR25575: Make GCC 4.4+ comatible layout for packed bit-fileds of char type

2015-11-25 Thread Richard Smith via cfe-commits
On Nov 25, 2015 1:53 PM, "hfin...@anl.gov via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:
>
> hfinkel added inline comments.
>
> 
> Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2783
> @@ -2783,1 +2782,3 @@
> +  "the newer semantic is provided here">,
> +  InGroup>;
>  def warn_transparent_union_attribute_field_size_align : Warning<
> 
> Calling this "a semantic" reads oddly to me. This sounds better to me:
>
>   def note_attribute_packed_for_bitfield_offset_changed : Warning<
> "the offset assigned to packed bit-field member %0 has changed with
GCC version 4.4 - "

Please also remove the "has" here.

> "the newer offset is used here">,
> InGroup>;
>
> 
> Comment at: lib/Sema/SemaDeclAttr.cpp:1040
> @@ -1039,3 +1039,3 @@
>  // If the alignment is less than or equal to 8 bits, the packed
attribute
>  // has no effect.
>  if (!FD->getType()->isDependentType() &&
> 
> This comment is now out of date?
>
>
> http://reviews.llvm.org/D14872
>
>
>
> ___
> 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


r254107 - [analyzer] Include block capture copy expressions in the CFG.

2015-11-25 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Wed Nov 25 16:35:37 2015
New Revision: 254107

URL: http://llvm.org/viewvc/llvm-project?rev=254107&view=rev
Log:
[analyzer] Include block capture copy expressions in the CFG.

This prevents spurious dead store warnings when a C++ lambda is casted to a 
block.

I've also added several tests documenting our still-incomplete support for 
lambda-to-block
casts.

rdar://problem/22236293

Added:
cfe/trunk/test/Analysis/blocks.mm
Modified:
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/test/Analysis/lambdas.mm

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=254107&r1=254106&r2=254107&view=diff
==
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Wed Nov 25 16:35:37 2015
@@ -460,6 +460,7 @@ private:
   CFGBlock *VisitImplicitCastExpr(ImplicitCastExpr *E, AddStmtChoice asc);
   CFGBlock *VisitIndirectGotoStmt(IndirectGotoStmt *I);
   CFGBlock *VisitLabelStmt(LabelStmt *L);
+  CFGBlock *VisitBlockExpr(BlockExpr *E, AddStmtChoice asc);
   CFGBlock *VisitLambdaExpr(LambdaExpr *E, AddStmtChoice asc);
   CFGBlock *VisitLogicalOperator(BinaryOperator *B);
   std::pair VisitLogicalOperator(BinaryOperator *B,
@@ -1453,7 +1454,7 @@ CFGBlock *CFGBuilder::Visit(Stmt * S, Ad
   return VisitBinaryOperator(cast(S), asc);
 
 case Stmt::BlockExprClass:
-  return VisitNoRecurse(cast(S), asc);
+  return VisitBlockExpr(cast(S), asc);
 
 case Stmt::BreakStmtClass:
   return VisitBreakStmt(cast(S));
@@ -2333,6 +2334,18 @@ CFGBlock *CFGBuilder::VisitLabelStmt(Lab
   return LabelBlock;
 }
 
+CFGBlock *CFGBuilder::VisitBlockExpr(BlockExpr *E, AddStmtChoice asc) {
+  CFGBlock *LastBlock = VisitNoRecurse(E, asc);
+  for (const BlockDecl::Capture &CI : E->getBlockDecl()->captures()) {
+if (Expr *CopyExpr = CI.getCopyExpr()) {
+  CFGBlock *Tmp = Visit(CopyExpr);
+  if (Tmp)
+LastBlock = Tmp;
+}
+  }
+  return LastBlock;
+}
+
 CFGBlock *CFGBuilder::VisitLambdaExpr(LambdaExpr *E, AddStmtChoice asc) {
   CFGBlock *LastBlock = VisitNoRecurse(E, asc);
   for (LambdaExpr::capture_init_iterator it = E->capture_init_begin(),

Added: cfe/trunk/test/Analysis/blocks.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/blocks.mm?rev=254107&view=auto
==
--- cfe/trunk/test/Analysis/blocks.mm (added)
+++ cfe/trunk/test/Analysis/blocks.mm Wed Nov 25 16:35:37 2015
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze 
-analyzer-checker=core -fblocks -analyzer-opt-analyze-nested-blocks -verify -x 
objective-c++ %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -analyze 
-analyzer-checker=core,debug.DumpCFG -fblocks 
-analyzer-opt-analyze-nested-blocks  %s > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
+
+// expected-no-diagnostics
+
+void testBlockWithoutCopyExpression(int i) {
+  // Captures i, with no copy expression.
+  (void)(^void() {
+(void)i;
+  });
+}
+
+// CHECK-LABEL:void testBlockWithoutCopyExpression(int i)
+// CHECK-NEXT: [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+
+// CHECK: [B1]
+// CHECK-NEXT:   1: ^{ }
+// CHECK-NEXT:   2: (void)([B1.1]) (CStyleCastExpr, ToVoid, void)
+// CHECK-NEXT:   Preds (1): B2
+// CHECK-NEXT:   Succs (1): B0
+
+// CHECK: [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+
+struct StructWithCopyConstructor {
+  StructWithCopyConstructor(int i);
+  StructWithCopyConstructor(const StructWithCopyConstructor &s);
+};
+void testBlockWithCopyExpression(StructWithCopyConstructor s) {
+  // Captures s, with a copy expression calling the copy constructor for 
StructWithCopyConstructor.
+  (void)(^void() {
+(void)s;
+  });
+}
+
+// CHECK-LABEL:void testBlockWithCopyExpression(StructWithCopyConstructor s)
+// CHECK-NEXT: [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+
+// CHECK: [B1]
+// CHECK-NEXT:   1: s
+// CHECK-NEXT:   2: [B1.1] (CXXConstructExpr, const struct 
StructWithCopyConstructor)
+// CHECK-NEXT:   3: ^{ }
+// CHECK-NEXT:   4: (void)([B1.3]) (CStyleCastExpr, ToVoid, void)
+// CHECK-NEXT:   Preds (1): B2
+// CHECK-NEXT:   Succs (1): B0
+
+// CHECK: [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+
+void testBlockWithCaptureByReference() {
+  __block StructWithCopyConstructor s(5);
+  // Captures s by reference, so no copy expression.
+  (void)(^void() {
+(void)s;
+  });
+}
+
+// CHECK-LABEL:void testBlockWithCaptureByReference()
+// CHECK-NEXT: [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+
+// CHECK: [B1]
+// CHECK-NEXT:   1: 5
+// CHECK-NEXT:   2: [B1.1] (CXXConstructExpr, struct StructWithCopyConstructor)
+// CHECK-NEXT:   3: StructWithCopyConstructor s(5) 
__attribute__((blocks("byref")));
+// CHECK-NEXT:   4: ^{ }
+// CHECK-NEXT:   5: (void)([B1.4]) (CStyleCastExpr, ToVoid, void)
+// CHECK-NEXT:   Preds (1): B2
+// CHECK-NEXT:   Succs (1): B0
+
+// CH

Re: [PATCH] D14871: [Power PC] fix calculating address of arguments on stack for variadic functions

2015-11-25 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: lib/CodeGen/TargetInfo.cpp:241
@@ +240,3 @@
+  return Address(PtrAsInt, Align);
+}
+

Thank you for extracting this.

First, this function deserves a doc comment now; I would suggest:

  /// Dynamically round a pointer up to a multiple of the given alignment.

Also, this is now generically useful, so (1) please rename OverflowArgArea to 
something more generic, like Ptr, and (2) please use LLVM value names based on 
the name already in Ptr.  That is, instead of "overflow_arg_area.align", please 
use
  Ptr->getName () + ".aligned"

Finally, please look for the other places in this file that you could change to 
use this new function.  There's one in emitVoidPtrDirectVAArg, and there are 
several other in other targets.


Comment at: lib/CodeGen/TargetInfo.cpp:3568
@@ +3567,3 @@
+  OverflowArea = emitRoundPointerUpToAlignment(CGF, OverflowArgArea,
+   Align);
+}

Please sink OverflowArgArea into the if block, since you don't need it outside.


http://reviews.llvm.org/D14871



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


[PATCH] Don't crash when dumping objc_bridge_related attributes

2015-11-25 Thread Joe Ranieri via cfe-commits
Clang's AST dumping currently crashes when dumping objc_bridge_related
attributes where the class method and instance method fields are left
empty. The attached patch marks the two arguments as optional and
updates TableGen to understand the optional flag for identifier
attribute arguments when generating the dump function.

-- Joe Ranieri
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td (revision 254076)
+++ include/clang/Basic/Attr.td (working copy)
@@ -1071,8 +1071,8 @@
   let Spellings = [GNU<"objc_bridge_related">];
   let Subjects = SubjectList<[Record], ErrorDiag>;
   let Args = [IdentifierArgument<"RelatedClass">,
-  IdentifierArgument<"ClassMethod">,
-  IdentifierArgument<"InstanceMethod">];
+  IdentifierArgument<"ClassMethod", 1>,
+  IdentifierArgument<"InstanceMethod", 1>];
   let HasCustomParsing = 1;
   let Documentation = [Undocumented];
 }
Index: test/Misc/ast-dump-attr.cpp
===
--- test/Misc/ast-dump-attr.cpp (revision 254076)
+++ test/Misc/ast-dump-attr.cpp (working copy)
@@ -150,3 +150,7 @@
   // CHECK: DeprecatedAttr
 }
 }
+
+struct __attribute__((objc_bridge_related(NSParagraphStyle,,))) TestBridgedRef;
+// CHECK: CXXRecordDecl{{.*}} struct TestBridgedRef
+// CHECK-NEXT: ObjCBridgeRelatedAttr{{.*}} NSParagraphStyle
Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp (revision 254076)
+++ utils/TableGen/ClangAttrEmitter.cpp (working copy)
@@ -279,6 +279,8 @@
 OS << "OS << \" \";\n";
 OS << "dumpBareDeclRef(SA->get" << getUpperName() << "());\n"; 
   } else if (type == "IdentifierInfo *") {
+if (isOptional())
+  OS << "if (SA->get" << getUpperName() << "())\n  ";
 OS << "OS << \" \" << SA->get" << getUpperName()
<< "()->getName();\n";
   } else if (type == "TypeSourceInfo *") {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r254041 - Teach RAV to pass its DataRecursionQueue to derived classes if they ask for it,

2015-11-25 Thread Richard Smith via cfe-commits
Looks like the bots are all happy now.

On Tue, Nov 24, 2015 at 11:45 PM, Alexey Samsonov 
wrote:

> Unfortunately, the bot still seems to be unhappy:
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/12246/steps/build%20fresh%20clang/logs/stdio
>
> On Tue, Nov 24, 2015 at 6:45 PM, Richard Smith 
> wrote:
>
>> Hah, looks like a rejects-valid, but it found a real bug, so *shrug*. =)
>> Hopefully fixed in r254053.
>>
>>
>> On Tue, Nov 24, 2015 at 5:14 PM, Alexey Samsonov 
>> wrote:
>>
>>> Hm, looks like we can't compile Clang itself after this change (with
>>> GCC):
>>>
>>>
>>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/12237
>>>
>>> On Tue, Nov 24, 2015 at 3:50 PM, Richard Smith via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: rsmith
 Date: Tue Nov 24 17:50:47 2015
 New Revision: 254041

 URL: http://llvm.org/viewvc/llvm-project?rev=254041&view=rev
 Log:
 Teach RAV to pass its DataRecursionQueue to derived classes if they ask
 for it,
 to allow them to explicitly opt into data recursion despite having
 overridden
 Traverse*Stmt or Traverse*Expr. Use this to reintroduce data recursion
 to the
 one place that lost it when DataRecursiveASTVisitor was removed.

 Modified:
 cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
 cfe/trunk/tools/libclang/IndexBody.cpp

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

 ==
 --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
 +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Tue Nov 24
 17:50:47 2015
 @@ -14,6 +14,8 @@
  #ifndef LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
  #define LLVM_CLANG_AST_RECURSIVEASTVISITOR_H

 +#include 
 +
  #include "clang/AST/Attr.h"
  #include "clang/AST/Decl.h"
  #include "clang/AST/DeclCXX.h"
 @@ -132,13 +134,13 @@ namespace clang {
  /// instantiations will be visited at the same time as the pattern
  /// from which they were produced.
  template  class RecursiveASTVisitor {
 +public:
/// A queue used for performing data recursion over statements.
/// Parameters involving this type are used to implement data
/// recursion over Stmts and Exprs within this class, and should
 -  /// not be explicitly specified by derived classes.
 +  /// typically not be explicitly specified by derived classes.
typedef SmallVectorImpl DataRecursionQueue;

 -public:
/// \brief Return a reference to the derived class.
Derived &getDerived() { return *static_cast(this); }

 @@ -274,24 +276,32 @@ public:
  //  Methods on Stmts 

  private:
 -  template
 -  struct is_same_member_pointer : std::false_type {};
 -  template
 -  struct is_same_member_pointer : std::true_type {};
 -
 -  // Traverse the given statement. If the traverse function was not
 overridden,
 -  // pass on the data recursion queue information.
 +  // Determine if the specified derived-class member M can be passed a
 +  // DataRecursionQueue* argument.
 +  template
 +  std::false_type callableWithQueue(...);
 +  template
 +  std::true_type callableWithQueue(M m, Derived *d = nullptr, P *p =
 nullptr,
 +   DataRecursionQueue *q = nullptr,
 +   decltype((d->*m)(p, q)) = false);
 +
 +  // Traverse the given statement. If the most-derived traverse
 function takes a
 +  // data recursion queue, pass it on; otherwise, discard it. Note
 that the
 +  // first branch of this conditional must compile whether or not the
 derived
 +  // class can take a queue, so if we're taking the second arm, make
 the first
 +  // arm call our function rather than the derived class version.
  #define TRAVERSE_STMT_BASE(NAME, CLASS, VAR, QUEUE)
 \
 -  (is_same_member_pointer>>> \
 -  &Derived::Traverse##NAME,
 \
 -
 decltype(&RecursiveASTVisitor::Traverse##NAME),  \
 -
 &RecursiveASTVisitor::Traverse##NAME>::value \
 -   ? this->Traverse##NAME(static_cast(VAR), QUEUE)
 \
 +  (decltype(callableWithQueue>>> *>(&Derived::Traverse##NAME))::value   \
 +   ? static_cast>>> \
 + decltype(
  \
 + callableWithQueue>>> *>(&Derived::Traverse##NAME))::value, \
 + Derived &, RecursiveASTVisitor &>::type>(*this)
  \
 + .Traverse##NAME(static_cast(VAR), QUEUE)
  \
  

Re: [PATCH] D13980: Add "x87" in x86 target feature map

2015-11-25 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Basic/Targets.cpp:2548
@@ +2547,3 @@
+  // All X86 processors but i386 have X87.
+  if (Kind != CK_i386)
+setFeatureEnabledImpl(Features, "x87", true);

What about `CK_Generic`? Also, if `CK_i486` can be used for the 486SX, we need 
to exclude it here too. It looks (from wikipedia) like all the "WinChip" 
flavours of 486 have an x87 unit, but it'd be nice if someone could confirm 
that. Maybe we should have separate `CPUKind`s for 486 SX versus 486 DX.


http://reviews.llvm.org/D13980



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


r254114 - [analyzer] Add tests for generalized lambda capture (C++14). NFC.

2015-11-25 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Wed Nov 25 18:11:23 2015
New Revision: 254114

URL: http://llvm.org/viewvc/llvm-project?rev=254114&view=rev
Log:
[analyzer] Add tests for generalized lambda capture (C++14). NFC.

Add tests demonstrating that the analyzer supports generalized lambda capture. 
This
support falls out naturally from the work Gábor Horváth did adding C++11 
lambdas to
the analyzer.

Added:
cfe/trunk/test/Analysis/lambdas-generalized-capture.cpp

Added: cfe/trunk/test/Analysis/lambdas-generalized-capture.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/lambdas-generalized-capture.cpp?rev=254114&view=auto
==
--- cfe/trunk/test/Analysis/lambdas-generalized-capture.cpp (added)
+++ cfe/trunk/test/Analysis/lambdas-generalized-capture.cpp Wed Nov 25 18:11:23 
2015
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -analyze 
-analyzer-checker=core,deadcode,debug.ExprInspection -verify %s
+
+int clang_analyzer_eval(int);
+
+void generalizedCapture() {
+  int v = 7;
+  auto lambda = [x=v]() {
+return x;
+  };
+
+  int result = lambda();
+  clang_analyzer_eval(result == 7); // expected-warning {{TRUE}}
+}
+
+void sideEffectsInGeneralizedCapture() {
+  int v = 7;
+  auto lambda = [x=v++]() {
+return x;
+  };
+  clang_analyzer_eval(v == 8); // expected-warning {{TRUE}}
+
+  int r1 = lambda();
+  int r2 = lambda();
+  clang_analyzer_eval(r1 == 7); // expected-warning {{TRUE}}
+  clang_analyzer_eval(r2 == 7); // expected-warning {{TRUE}}
+  clang_analyzer_eval(v == 8); // expected-warning {{TRUE}}
+}
+
+int addOne(int p) {
+ return p + 1;
+}
+
+void inliningInGeneralizedCapture() {
+  int v = 7;
+  auto lambda = [x=addOne(v)]() {
+return x;
+  };
+
+  int result = lambda();
+  clang_analyzer_eval(result == 8); // expected-warning {{TRUE}}
+}
+
+void caseSplitInGeneralizedCapture(bool p) {
+  auto lambda = [x=(p ? 1 : 2)]() {
+return x;
+  };
+
+  int result = lambda();
+  clang_analyzer_eval(result == 1); // expected-warning {{FALSE}} 
expected-warning {{TRUE}}
+}


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


LLVM buildmaster will be restarted tonight

2015-11-25 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 7 PM Pacific time
today.

Thanks

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


r254117 - Driver: protect from empty -L args

2015-11-25 Thread Martell Malone via cfe-commits
Author: martell
Date: Wed Nov 25 19:02:07 2015
New Revision: 254117

URL: http://llvm.org/viewvc/llvm-project?rev=254117&view=rev
Log:
Driver: protect from empty -L args

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

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

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=254117&r1=254116&r2=254117&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Wed Nov 25 19:02:07 2015
@@ -619,7 +619,8 @@ void ToolChain::AddCXXStdlibLibArgs(cons
 void ToolChain::AddFilePathLibArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
   for (const auto &LibPath : getFilePaths())
-CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
+if(LibPath.length() > 0)
+  CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
 }
 
 void ToolChain::AddCCKextLibArgs(const ArgList &Args,


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


[libcxx] r254119 - Add static_assert to set/multiset/map/multimap/forward_list/deque that the allocator's value_type match the container's value_type. vector/unordered/list/string already do this. Add

2015-11-25 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Nov 25 19:24:04 2015
New Revision: 254119

URL: http://llvm.org/viewvc/llvm-project?rev=254119&view=rev
Log:
Add static_assert to set/multiset/map/multimap/forward_list/deque that the 
allocator's value_type match the container's value_type. 
vector/unordered/list/string already do this. Add tests for all the containers 
to verify this.

Added:
libcxx/trunk/test/std/containers/associative/map/allocator_mismatch.fail.cpp

libcxx/trunk/test/std/containers/associative/multimap/allocator_mismatch.fail.cpp

libcxx/trunk/test/std/containers/associative/multiset/allocator_mismatch.fail.cpp
libcxx/trunk/test/std/containers/associative/set/allocator_mismatch.fail.cpp
libcxx/trunk/test/std/containers/sequences/deque/allocator_mismatch.fail.cpp

libcxx/trunk/test/std/containers/sequences/forwardlist/allocator_mismatch.fail.cpp
libcxx/trunk/test/std/containers/sequences/list/allocator_mismatch.fail.cpp

libcxx/trunk/test/std/containers/sequences/vector/allocator_mismatch.fail.cpp
libcxx/trunk/test/std/containers/unord/unord.map/allocator_mismatch.fail.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/allocator_mismatch.fail.cpp

libcxx/trunk/test/std/containers/unord/unord.multiset/allocator_mismatch.fail.cpp
libcxx/trunk/test/std/containers/unord/unord.set/allocator_mismatch.fail.cpp
libcxx/trunk/test/std/strings/basic.string/allocator_mismatch.fail.cpp
Modified:
libcxx/trunk/include/deque
libcxx/trunk/include/forward_list
libcxx/trunk/include/map
libcxx/trunk/include/set

Modified: libcxx/trunk/include/deque
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/deque?rev=254119&r1=254118&r2=254119&view=diff
==
--- libcxx/trunk/include/deque (original)
+++ libcxx/trunk/include/deque Wed Nov 25 19:24:04 2015
@@ -1196,6 +1196,9 @@ public:
 typedef _Tp value_type;
 typedef _Allocator allocator_type;
 
+static_assert((is_same::value),
+  "Allocator::value_type must be same type as value_type");
+
 typedef __deque_base __base;
 
 typedef typename __base::__alloc_traits__alloc_traits;

Modified: libcxx/trunk/include/forward_list
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/forward_list?rev=254119&r1=254118&r2=254119&view=diff
==
--- libcxx/trunk/include/forward_list (original)
+++ libcxx/trunk/include/forward_list Wed Nov 25 19:24:04 2015
@@ -537,6 +537,9 @@ public:
 typedef _Tpvalue_type;
 typedef _Alloc allocator_type;
 
+static_assert((is_same::value),
+  "Allocator::value_type must be same type as value_type");
+
 typedef value_type&
reference;
 typedef const value_type&  
const_reference;
 typedef typename allocator_traits::pointer pointer;

Modified: libcxx/trunk/include/map
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/map?rev=254119&r1=254118&r2=254119&view=diff
==
--- libcxx/trunk/include/map (original)
+++ libcxx/trunk/include/map Wed Nov 25 19:24:04 2015
@@ -840,6 +840,9 @@ public:
 typedef value_type&  reference;
 typedef const value_type&const_reference;
 
+static_assert((is_same::value),
+  "Allocator::value_type must be same type as value_type");
+
 class _LIBCPP_TYPE_VIS_ONLY value_compare
 : public binary_function
 {
@@ -1696,6 +1699,9 @@ public:
 typedef value_type&  reference;
 typedef const value_type&const_reference;
 
+static_assert((is_same::value),
+  "Allocator::value_type must be same type as value_type");
+
 class _LIBCPP_TYPE_VIS_ONLY value_compare
 : public binary_function
 {

Modified: libcxx/trunk/include/set
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/set?rev=254119&r1=254118&r2=254119&view=diff
==
--- libcxx/trunk/include/set (original)
+++ libcxx/trunk/include/set Wed Nov 25 19:24:04 2015
@@ -409,6 +409,9 @@ public:
 typedef value_type&  reference;
 typedef const value_type&const_reference;
 
+static_assert((is_same::value),
+  "Allocator::value_type must be same type as value_type");
+
 private:
 typedef __tree __base;
 typedef allocator_traits  __alloc_traits;
@@ -819,6 +822,9 @@ public:
 typedef value_type&  reference;
 typedef const value_type&const_reference;
 
+static_assert((is_same::val

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

2015-11-25 Thread Martell Malone via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL254117: Driver: protect from empty -L args (authored by 
martell).

Changed prior to commit:
  http://reviews.llvm.org/D12466?vs=33510&id=41202#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12466

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

Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -619,7 +619,8 @@
 void ToolChain::AddFilePathLibArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
   for (const auto &LibPath : getFilePaths())
-CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
+if(LibPath.length() > 0)
+  CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
 }
 
 void ToolChain::AddCCKextLibArgs(const ArgList &Args,


Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -619,7 +619,8 @@
 void ToolChain::AddFilePathLibArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
   for (const auto &LibPath : getFilePaths())
-CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
+if(LibPath.length() > 0)
+  CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
 }
 
 void ToolChain::AddCCKextLibArgs(const ArgList &Args,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2015-11-25 Thread David Blaikie via cfe-commits
Is this testable?
On Nov 25, 2015 5:56 PM, "Martell Malone via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> This revision was automatically updated to reflect the committed changes.
> Closed by commit rL254117: Driver: protect from empty -L args (authored by
> martell).
>
> Changed prior to commit:
>   http://reviews.llvm.org/D12466?vs=33510&id=41202#toc
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D12466
>
> Files:
>   cfe/trunk/lib/Driver/ToolChain.cpp
>
> Index: cfe/trunk/lib/Driver/ToolChain.cpp
> ===
> --- cfe/trunk/lib/Driver/ToolChain.cpp
> +++ cfe/trunk/lib/Driver/ToolChain.cpp
> @@ -619,7 +619,8 @@
>  void ToolChain::AddFilePathLibArgs(const ArgList &Args,
> ArgStringList &CmdArgs) const {
>for (const auto &LibPath : getFilePaths())
> -CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
> +if(LibPath.length() > 0)
> +  CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
>  }
>
>  void ToolChain::AddCCKextLibArgs(const ArgList &Args,
>
>
>
> ___
> 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


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

2015-11-25 Thread David Blaikie via cfe-commits
dblaikie added a subscriber: dblaikie.
dblaikie added a comment.

Is this testable?


Repository:
  rL LLVM

http://reviews.llvm.org/D12466



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


r254121 - [modules] Refactor handling of -fmodules-embed-*. Track this properly rather

2015-11-25 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Nov 25 20:04:16 2015
New Revision: 254121

URL: http://llvm.org/viewvc/llvm-project?rev=254121&view=rev
Log:
[modules] Refactor handling of -fmodules-embed-*. Track this properly rather
than reusing the "overridden buffer" mechanism. This will allow us to make
embedded files and overridden files behave differently in future.

Modified:
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Basic/FileManager.cpp
cfe/trunk/lib/Basic/SourceManager.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=254121&r1=254120&r2=254121&view=diff
==
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Wed Nov 25 20:04:16 2015
@@ -122,7 +122,7 @@ namespace SrcMgr {
 /// \brief The number of lines in this ContentCache.
 ///
 /// This is only valid if SourceLineCache is non-null.
-unsigned NumLines : 31;
+unsigned NumLines;
 
 /// \brief Indicates whether the buffer itself was provided to override
 /// the actual file contents.
@@ -135,12 +135,17 @@ namespace SrcMgr {
 /// file considered as a system one.
 unsigned IsSystemFile : 1;
 
+/// \brief True if this file may be transient, that is, if it might not
+/// exist at some later point in time when this content entry is used,
+/// after serialization and deserialization.
+unsigned IsTransient : 1;
+
 ContentCache(const FileEntry *Ent = nullptr) : ContentCache(Ent, Ent) {}
 
 ContentCache(const FileEntry *Ent, const FileEntry *contentEnt)
   : Buffer(nullptr, false), OrigEntry(Ent), ContentsEntry(contentEnt),
 SourceLineCache(nullptr), NumLines(0), BufferOverridden(false),
-IsSystemFile(false) {}
+IsSystemFile(false), IsTransient(false) {}
 
 ~ContentCache();
 
@@ -149,7 +154,7 @@ namespace SrcMgr {
 /// is not transferred, so this is a logical error.
 ContentCache(const ContentCache &RHS)
   : Buffer(nullptr, false), SourceLineCache(nullptr),
-BufferOverridden(false), IsSystemFile(false) {
+BufferOverridden(false), IsSystemFile(false), IsTransient(false) {
   OrigEntry = RHS.OrigEntry;
   ContentsEntry = RHS.ContentsEntry;
 
@@ -862,17 +867,13 @@ public:
   /// This should be called before parsing has begun.
   void disableFileContentsOverride(const FileEntry *File);
 
-  /// \brief Request that the contents of the given source file are written
-  /// to a created module file if they are used in this compilation. This
-  /// removes the requirement that the file still exist when the module is used
-  /// (but does not make the file visible to header search and the like when
-  /// the module is used).
-  void embedFileContentsInModule(const FileEntry *SourceFile);
-
-  /// \brief Request that all files that are read during this compilation be
-  /// written to any created module file.
-  void setEmbedAllFileContentsInModule(bool Embed) {
-FilesAreTransient = Embed;
+  /// \brief Specify that a file is transient.
+  void setFileIsTransient(const FileEntry *SourceFile);
+
+  /// \brief Specify that all files that are read during this compilation are
+  /// transient.
+  void setAllFilesAreTransient(bool Transient) {
+FilesAreTransient = Transient;
   }
 
   
//======//

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=254121&r1=254120&r2=254121&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Wed Nov 25 20:04:16 2015
@@ -1058,6 +1058,7 @@ private:
 off_t StoredSize;
 time_t StoredTime;
 bool Overridden;
+bool Transient;
   };
 
   /// \brief Reads the stored information about an input file.

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=254121&r1=254120&r2=254121&view=diff
==
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Wed Nov 25 20:04:16 2015
@@ -137,7 +137,7 @@ void FileManager::addAncestorsAsVirtualD
   // at the same time.  Therefore, if DirName is already in the cache,
   // we don't need to recurse as its ancestors must also already be in
   // the cache.
-  if (NamedDirEnt.second)
+  if (NamedDirEnt.second && NamedDirEnt.

r254122 - P0002R1: increment on expressions of type bool is no longer allowed in C++1z.

2015-11-25 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Nov 25 20:16:37 2015
New Revision: 254122

URL: http://llvm.org/viewvc/llvm-project?rev=254122&view=rev
Log:
P0002R1: increment on expressions of type bool is no longer allowed in C++1z.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CXX/drs/dr1xx.cpp
cfe/trunk/test/SemaCXX/deprecated.cpp
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=254122&r1=254121&r2=254122&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Nov 25 20:16:37 2015
@@ -187,7 +187,8 @@ def CXX14Compat : DiagGroup<"c++14-compa
 def CXX14CompatPedantic : DiagGroup<"c++14-compat-pedantic",
 [CXXPre1zCompatPedantic]>;
 
-def CXX1zCompat : DiagGroup<"c++1z-compat", [DeprecatedRegister]>;
+def CXX1zCompat : DiagGroup<"c++1z-compat", [DeprecatedRegister,
+ DeprecatedIncrementBool]>;
 
 def : DiagGroup<"effc++">;
 def DivZero : DiagGroup<"division-by-zero">;
@@ -204,6 +205,7 @@ def DanglingElse: DiagGroup<"dangling-el
 def DanglingField : DiagGroup<"dangling-field">;
 def DistributedObjectModifiers : DiagGroup<"distributed-object-modifiers">;
 def FlagEnum : DiagGroup<"flag-enum">;
+def IncrementBool : DiagGroup<"increment-bool", [DeprecatedIncrementBool]>;
 def InfiniteRecursion : DiagGroup<"infinite-recursion">;
 def GNUImaginaryConstant : DiagGroup<"gnu-imaginary-constant">;
 def IgnoredQualifiers : DiagGroup<"ignored-qualifiers">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=254122&r1=254121&r2=254122&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Nov 25 20:16:37 
2015
@@ -5727,8 +5727,11 @@ def note_member_declared_here : Note<
   "member %0 declared here">;
 def err_decrement_bool : Error<"cannot decrement expression of type bool">;
 def warn_increment_bool : Warning<
-  "incrementing expression of type bool is deprecated">,
-  InGroup;
+  "incrementing expression of type bool is deprecated and "
+  "incompatible with C++1z">, InGroup;
+def ext_increment_bool : ExtWarn<
+  "ISO C++1z does not allow incrementing expression of type bool">,
+  DefaultError, InGroup;
 def err_increment_decrement_enum : Error<
   "cannot %select{decrement|increment}0 expression of enum type %1">;
 def err_catch_incomplete_ptr : Error<

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=254122&r1=254121&r2=254122&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Nov 25 20:16:37 2015
@@ -9680,7 +9680,9 @@ static QualType CheckIncrementDecrementO
   return QualType();
 }
 // Increment of bool sets it to true, but is deprecated.
-S.Diag(OpLoc, diag::warn_increment_bool) << Op->getSourceRange();
+S.Diag(OpLoc, S.getLangOpts().CPlusPlus1z ? diag::ext_increment_bool
+  : diag::warn_increment_bool)
+  << Op->getSourceRange();
   } else if (S.getLangOpts().CPlusPlus && ResType->isEnumeralType()) {
 // Error on enum increments and decrements in C++ mode
 S.Diag(OpLoc, diag::err_increment_decrement_enum) << IsInc << ResType;

Modified: cfe/trunk/test/CXX/drs/dr1xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr1xx.cpp?rev=254122&r1=254121&r2=254122&view=diff
==
--- cfe/trunk/test/CXX/drs/dr1xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr1xx.cpp Wed Nov 25 20:16:37 2015
@@ -524,8 +524,13 @@ namespace dr143 { // dr143: yes
 
 namespace dr145 { // dr145: yes
   void f(bool b) {
+#if __cplusplus <= 201402L
 ++b; // expected-warning {{deprecated}}
 b++; // expected-warning {{deprecated}}
+#else
+++b; // expected-error {{increment}}
+b++; // expected-error {{increment}}
+#endif
   }
 }
 

Modified: cfe/trunk/test/SemaCXX/deprecated.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/deprecated.cpp?rev=254122&r1=254121&r2=254122&view=diff
==
--- cfe/trunk/test/SemaCXX/deprecated.cpp (original)
+++ cfe/trunk/test/SemaCXX/deprecated.cpp Wed Nov 25 20:16:37 2015
@@ -28,7 +28,19 @@ void stuff() {
 

r254123 - Update reference to final TM TS spec.

2015-11-25 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Nov 25 20:23:21 2015
New Revision: 254123

URL: http://llvm.org/viewvc/llvm-project?rev=254123&view=rev
Log:
Update reference to final TM TS spec.

Modified:
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/www/cxx_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=254123&r1=254122&r2=254123&view=diff
==
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Wed Nov 25 20:23:21 2015
@@ -679,7 +679,7 @@ Clang version they became available:
 
 
   [TS] Transactional Memory
-  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4302.pdf";>N4302
+  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4514.pdf";>N4514
   No
 
 


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


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

2015-11-25 Thread Martell Malone via cfe-commits
martell added a comment.

> Is this testable?


Seems to me the only way to add this as a test would be to add bad code to 
clang to purposely pass an empty LibPath argument.
This is probably something we do not want to do.

This is probably why Reid never asked me for one in the review.


Repository:
  rL LLVM

http://reviews.llvm.org/D12466



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


[PATCH] D15005: Fix PR8170: Clang does not check constructor declaration that uses a template-id

2015-11-25 Thread Faisal Vali via cfe-commits
faisalv created this revision.
faisalv added a reviewer: rsmith.
faisalv added a subscriber: cfe-commits.

Clang currently does no real checking of the template argument list when a 
template-id is used to declare a constructor:

template struct X {
  X(); // Clang erroneously accepts this.
};

Both gcc and edg emit an error on the above code (though one could claim the 
spec temp.local p1 is perhaps not as explicit as it could be in this regard)

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



http://reviews.llvm.org/D15005

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaTemplate.cpp
  test/CXX/temp/temp.res/temp.local/p1.cpp

Index: test/CXX/temp/temp.res/temp.local/p1.cpp
===
--- test/CXX/temp/temp.res/temp.local/p1.cpp
+++ test/CXX/temp/temp.res/temp.local/p1.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// expected-no-diagnostics
+
 
 // C++0x [temp.local]p1:
 //   Like normal (non-template) classes, class templates have an
@@ -11,12 +11,15 @@
 template  struct X0 {
   X0();
   ~X0();
+  X0(int); 
+  X0(int*); //expected-error{{expected 'X0' or 'X0'}}
   X0 f(const X0&);
 };
 
 // Test non-type template parameters.
 template  struct X1 {
   X1();
+  template X1(char); //expected-error{{expected 'X1' or 'X1'}}
   ~X1();
   X1 f(const X1& x1a) { X1 x1b(x1a); return x1b; }
 };
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -518,6 +518,65 @@
   llvm_unreachable("Unhandled parsed template argument");
 }
 
+std::string
+Sema::stringifyTemplateArguments(const TemplateSpecializationType *TST) {
+  ArrayRef TemplateArgs(TST->getArgs(), TST->getNumArgs());
+
+  llvm::SmallString<256> StringifiedTemplateArgs;
+  std::for_each(TemplateArgs.begin(), TemplateArgs.end(),
+[&StringifiedTemplateArgs, this](const TemplateArgument &TA) {
+if (const bool IsFirst = !StringifiedTemplateArgs.size())
+  StringifiedTemplateArgs = "<";
+else
+  StringifiedTemplateArgs += ",";
+llvm::raw_svector_ostream OS(StringifiedTemplateArgs);
+TA.print(this->getPrintingPolicy(), OS);
+  });
+
+  StringifiedTemplateArgs += ">";
+  return StringifiedTemplateArgs.c_str();
+}
+
+void Sema::checkUnqualifiedTemplateIdIsConstructor(
+TemplateIdAnnotation *TemplateId, const CXXRecordDecl *TemplatedClass) {
+  assert(TemplatedClass->getDescribedClassTemplate());
+  assert(TemplateId->Name == TemplatedClass->getIdentifier() &&
+ "TemplateId must have the same identifier as that of the class!");
+
+  // Get the type that corresponds to this template id, while suppressing all
+  // diagnostics.
+  const bool PrevSuppress = Diags.getSuppressAllDiagnostics();
+  Diags.setSuppressAllDiagnostics(true);
+  TypeResult TemplateIdTy = ActOnTemplateIdType(
+  TemplateId->SS, TemplateId->TemplateKWLoc,
+  TemplateTy::make(
+  TemplateName(TemplatedClass->getDescribedClassTemplate())),
+  TemplateId->TemplateNameLoc, TemplateId->LAngleLoc,
+  ASTTemplateArgsPtr(TemplateId->getTemplateArgs(), TemplateId->NumArgs),
+  TemplateId->RAngleLoc, /*IsCtorOrDtorName*/ true);
+  Diags.setSuppressAllDiagnostics(PrevSuppress);
+
+  // If the template-id type is the same type as the type of the
+  // templated-class, all is ok - else emit a diagnostic.
+  if (TemplateIdTy.get() &&
+  Context.hasSameType(GetTypeFromParser(TemplateIdTy.get()).getTypePtr(),
+  Context.getTypeDeclType(TemplatedClass).getTypePtr()))
+return;
+
+  // Emit a diagnostic, indicating that the template arguments do not match up
+  // to the injected class name.
+  std::string ExpectedTemplateId = TemplateId->Name->getName();
+  ExpectedTemplateId += stringifyTemplateArguments(
+  cast(Context.getTypeDeclType(TemplatedClass))
+  ->getInjectedTST());
+
+  Diag(TemplateId->TemplateNameLoc,
+   diag::err_expected_constructor_template_id)
+  << TemplateId->Name << ExpectedTemplateId.c_str()
+  << FixItHint::CreateRemoval(
+ SourceRange(TemplateId->LAngleLoc, TemplateId->RAngleLoc));
+}
+
 /// \brief Translates template arguments as provided by the parser
 /// into template arguments used by semantic analysis.
 void Sema::translateTemplateArguments(const ASTTemplateArgsPtr &TemplateArgsIn,
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -1270,18 +1270,23 @@
 /// nested classes, this will only return true if II is the name of
 /// the innermost class.
 bool Sema::isCurrentClassName(const IdentifierInfo &II, Scope *,
-  const CXXScopeSpec *SS) {
+ 

r254133 - Use range-based for loops. NFC

2015-11-25 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Nov 25 23:10:07 2015
New Revision: 254133

URL: http://llvm.org/viewvc/llvm-project?rev=254133&view=rev
Log:
Use range-based for loops. NFC

Modified:
cfe/trunk/lib/Basic/Diagnostic.cpp

Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=254133&r1=254132&r2=254133&view=diff
==
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Wed Nov 25 23:10:07 2015
@@ -278,8 +278,8 @@ bool DiagnosticsEngine::setDiagnosticGro
 return true;
 
   // Perform the mapping change.
-  for (unsigned i = 0, e = GroupDiags.size(); i != e; ++i) {
-DiagnosticMapping &Info = 
GetCurDiagState()->getOrAddMapping(GroupDiags[i]);
+  for (diag::kind Diag : GroupDiags) {
+DiagnosticMapping &Info = GetCurDiagState()->getOrAddMapping(Diag);
 
 if (Info.getSeverity() == diag::Severity::Error ||
 Info.getSeverity() == diag::Severity::Fatal)
@@ -309,8 +309,8 @@ bool DiagnosticsEngine::setDiagnosticGro
 return true;
 
   // Perform the mapping change.
-  for (unsigned i = 0, e = GroupDiags.size(); i != e; ++i) {
-DiagnosticMapping &Info = 
GetCurDiagState()->getOrAddMapping(GroupDiags[i]);
+  for (diag::kind Diag : GroupDiags) {
+DiagnosticMapping &Info = GetCurDiagState()->getOrAddMapping(Diag);
 
 if (Info.getSeverity() == diag::Severity::Fatal)
   Info.setSeverity(diag::Severity::Error);
@@ -329,9 +329,9 @@ void DiagnosticsEngine::setSeverityForAl
   Diags->getAllDiagnostics(Flavor, AllDiags);
 
   // Set the mapping.
-  for (unsigned i = 0, e = AllDiags.size(); i != e; ++i)
-if (Diags->isBuiltinWarningOrExtension(AllDiags[i]))
-  setSeverity(AllDiags[i], Map, Loc);
+  for (diag::kind Diag : AllDiags)
+if (Diags->isBuiltinWarningOrExtension(Diag))
+  setSeverity(Diag, Map, Loc);
 }
 
 void DiagnosticsEngine::Report(const StoredDiagnostic &storedDiag) {


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


[PATCH] D15006: Driver: Better detection of mingw-gcc

2015-11-25 Thread Martell Malone via cfe-commits
martell created this revision.
martell added a reviewer: yaron.keren.
martell added a subscriber: cfe-commits.

As discussed after r253898 here is the better gcc detection.

Note: I could add a break in the new for loop but I don't feel it is needed

Thoughts?


http://reviews.llvm.org/D15006

Files:
  lib/Driver/MinGWToolChain.cpp

Index: lib/Driver/MinGWToolChain.cpp
===
--- lib/Driver/MinGWToolChain.cpp
+++ lib/Driver/MinGWToolChain.cpp
@@ -66,15 +66,22 @@
 : ToolChain(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());

-  // On Windows if there is no sysroot we search for gcc on the PATH.
+  llvm::SmallVector, 2> Gccs;
+  Gccs.emplace_back(getTriple().getArchName());
+  Gccs[0] += "-w64-mingw32-gcc";
+  Gccs.emplace_back("mingw32-gcc");
+
+  for (StringRef CandidateGcc : Gccs)
+if (llvm::ErrorOr GPPName =
+  llvm::sys::findProgramByName(CandidateGcc)) {
+  Base = llvm::sys::path::parent_path(
+  llvm::sys::path::parent_path(GPPName.get()));
+  break;
+}
+
   if (getDriver().SysRoot.size())
-  Base = getDriver().SysRoot;
-#ifdef LLVM_ON_WIN32
-  else if (llvm::ErrorOr GPPName =
-   llvm::sys::findProgramByName("gcc"))
-Base = llvm::sys::path::parent_path(
-llvm::sys::path::parent_path(GPPName.get()));
-#endif
+Base = getDriver().SysRoot;
+
   if (!Base.size())
 Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
 


Index: lib/Driver/MinGWToolChain.cpp
===
--- lib/Driver/MinGWToolChain.cpp
+++ lib/Driver/MinGWToolChain.cpp
@@ -66,15 +66,22 @@
 : ToolChain(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());

-  // On Windows if there is no sysroot we search for gcc on the PATH.
+  llvm::SmallVector, 2> Gccs;
+  Gccs.emplace_back(getTriple().getArchName());
+  Gccs[0] += "-w64-mingw32-gcc";
+  Gccs.emplace_back("mingw32-gcc");
+
+  for (StringRef CandidateGcc : Gccs)
+if (llvm::ErrorOr GPPName =
+  llvm::sys::findProgramByName(CandidateGcc)) {
+  Base = llvm::sys::path::parent_path(
+  llvm::sys::path::parent_path(GPPName.get()));
+  break;
+}
+
   if (getDriver().SysRoot.size())
-  Base = getDriver().SysRoot;
-#ifdef LLVM_ON_WIN32
-  else if (llvm::ErrorOr GPPName =
-   llvm::sys::findProgramByName("gcc"))
-Base = llvm::sys::path::parent_path(
-llvm::sys::path::parent_path(GPPName.get()));
-#endif
+Base = getDriver().SysRoot;
+
   if (!Base.size())
 Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15006: Driver: Better detection of mingw-gcc

2015-11-25 Thread Martell Malone via cfe-commits
martell updated the summary for this revision.
martell updated this revision to Diff 41208.
martell added a comment.

Removed the break that I didn't think was needed
Can be re-added ??

Will added testcases


http://reviews.llvm.org/D15006

Files:
  lib/Driver/MinGWToolChain.cpp

Index: lib/Driver/MinGWToolChain.cpp
===
--- lib/Driver/MinGWToolChain.cpp
+++ lib/Driver/MinGWToolChain.cpp
@@ -66,15 +66,20 @@
 : ToolChain(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());

-  // On Windows if there is no sysroot we search for gcc on the PATH.
+  llvm::SmallVector, 2> Gccs;
+  Gccs.emplace_back(getTriple().getArchName());
+  Gccs[0] += "-w64-mingw32-gcc";
+  Gccs.emplace_back("mingw32-gcc");
+
+  for (StringRef CandidateGcc : Gccs)
+if (llvm::ErrorOr GPPName =
+  llvm::sys::findProgramByName(CandidateGcc))
+  Base = llvm::sys::path::parent_path(
+  llvm::sys::path::parent_path(GPPName.get()));
+
   if (getDriver().SysRoot.size())
-  Base = getDriver().SysRoot;
-#ifdef LLVM_ON_WIN32
-  else if (llvm::ErrorOr GPPName =
-   llvm::sys::findProgramByName("gcc"))
-Base = llvm::sys::path::parent_path(
-llvm::sys::path::parent_path(GPPName.get()));
-#endif
+Base = getDriver().SysRoot;
+
   if (!Base.size())
 Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
 


Index: lib/Driver/MinGWToolChain.cpp
===
--- lib/Driver/MinGWToolChain.cpp
+++ lib/Driver/MinGWToolChain.cpp
@@ -66,15 +66,20 @@
 : ToolChain(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());

-  // On Windows if there is no sysroot we search for gcc on the PATH.
+  llvm::SmallVector, 2> Gccs;
+  Gccs.emplace_back(getTriple().getArchName());
+  Gccs[0] += "-w64-mingw32-gcc";
+  Gccs.emplace_back("mingw32-gcc");
+
+  for (StringRef CandidateGcc : Gccs)
+if (llvm::ErrorOr GPPName =
+  llvm::sys::findProgramByName(CandidateGcc))
+  Base = llvm::sys::path::parent_path(
+  llvm::sys::path::parent_path(GPPName.get()));
+
   if (getDriver().SysRoot.size())
-  Base = getDriver().SysRoot;
-#ifdef LLVM_ON_WIN32
-  else if (llvm::ErrorOr GPPName =
-   llvm::sys::findProgramByName("gcc"))
-Base = llvm::sys::path::parent_path(
-llvm::sys::path::parent_path(GPPName.get()));
-#endif
+Base = getDriver().SysRoot;
+
   if (!Base.size())
 Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r254134 - [Diagnostics] Call setMapping on the correct diagnostic states in a few places. GetCurDiagState() was being used when it shouldn't be.

2015-11-25 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Nov 25 23:51:54 2015
New Revision: 254134

URL: http://llvm.org/viewvc/llvm-project?rev=254134&view=rev
Log:
[Diagnostics] Call setMapping on the correct diagnostic states in a few places. 
GetCurDiagState() was being used when it shouldn't be.

I spotted this by inspection in the for loop that wasn't using its iterator and 
was just acting on the current state repeatedly.

This appears to have been introduced as a copy and paste bug in r140763 over 4 
years ago.

I have no idea how to test this. I just went back to the original commit and 
tried to use the variables it was using before that.

Modified:
cfe/trunk/lib/Basic/Diagnostic.cpp

Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=254134&r1=254133&r2=254134&view=diff
==
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Wed Nov 25 23:51:54 2015
@@ -226,12 +226,12 @@ void DiagnosticsEngine::setSeverity(diag
   // Update all diagnostic states that are active after the given location.
   for (DiagStatePointsTy::iterator
  I = Pos+1, E = DiagStatePoints.end(); I != E; ++I) {
-GetCurDiagState()->setMapping(Diag, Mapping);
+I->State->setMapping(Diag, Mapping);
   }
 
   // If the location corresponds to an existing point, just update its state.
   if (Pos->Loc == Loc) {
-GetCurDiagState()->setMapping(Diag, Mapping);
+Pos->State->setMapping(Diag, Mapping);
 return;
   }
 
@@ -240,7 +240,7 @@ void DiagnosticsEngine::setSeverity(diag
   assert(Pos->Loc.isBeforeInTranslationUnitThan(Loc));
   DiagStates.push_back(*Pos->State);
   DiagState *NewState = &DiagStates.back();
-  GetCurDiagState()->setMapping(Diag, Mapping);
+  NewState->setMapping(Diag, Mapping);
   DiagStatePoints.insert(Pos+1, DiagStatePoint(NewState,
FullSourceLoc(Loc, 
*SourceMgr)));
 }


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


Re: [PATCH] D15006: Driver: Better detection of mingw-gcc

2015-11-25 Thread Martell Malone via cfe-commits
martell added a comment.

@ismail can you test this for your setup please? :)


http://reviews.llvm.org/D15006



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


Re: [PATCH] D15006: Driver: Better detection of mingw-gcc

2015-11-25 Thread Yaron Keren via cfe-commits
yaron.keren added a comment.

This always searches for something-gcc and then discards the result if sysroot 
was provided, which is a waste.
Move the searching to a helper function and then it can be done only if sysroot 
was not provided, as it is now.

The break is needed to avoid looking for mingw32-gcc after 
x86_64-w64-mingw32-gcc was already found. It's a wasted search.


http://reviews.llvm.org/D15006



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


Re: [PATCH] D15006: Driver: Better detection of mingw-gcc

2015-11-25 Thread Martell Malone via cfe-commits
martell updated this revision to Diff 41209.
martell added a comment.

Updated to reflect feedback

I'm not too sure what todo for testcases on this one because they already exist 
for the most part.
I ran the test suite and they all pass.

I would have to create a mingw32-gcc and {armv7|i686|x86_64}-w64-mingw32-gcc 
and chmod+x for the testcase.
Is that safe ?


http://reviews.llvm.org/D15006

Files:
  lib/Driver/MinGWToolChain.cpp
  lib/Driver/ToolChains.h

Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -661,6 +661,7 @@
   std::string Arch;
   mutable std::unique_ptr Preprocessor;
   mutable std::unique_ptr Compiler;
+  void findGccDir();
   void findGccLibDir();
 };
 
Index: lib/Driver/MinGWToolChain.cpp
===
--- lib/Driver/MinGWToolChain.cpp
+++ lib/Driver/MinGWToolChain.cpp
@@ -62,19 +62,29 @@
   }
 }

+void MinGW::findGccDir() {
+  llvm::SmallVector, 2> Gccs;
+  Gccs.emplace_back(getTriple().getArchName());
+  Gccs[0] += "-w64-mingw32-gcc";
+  Gccs.emplace_back("mingw32-gcc");
+  for (StringRef CandidateGcc : Gccs)
+if (llvm::ErrorOr GPPName =
+  llvm::sys::findProgramByName(CandidateGcc)) {
+  Base = llvm::sys::path::parent_path(
+  llvm::sys::path::parent_path(GPPName.get()));
+  return;
+}
+}
+
 MinGW::MinGW(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
 : ToolChain(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());

-  // On Windows if there is no sysroot we search for gcc on the PATH.
   if (getDriver().SysRoot.size())
-  Base = getDriver().SysRoot;
-#ifdef LLVM_ON_WIN32
-  else if (llvm::ErrorOr GPPName =
-   llvm::sys::findProgramByName("gcc"))
-Base = llvm::sys::path::parent_path(
-llvm::sys::path::parent_path(GPPName.get()));
-#endif
+Base = getDriver().SysRoot;
+  else
+findGccDir();
+
   if (!Base.size())
 Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());



Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -661,6 +661,7 @@
   std::string Arch;
   mutable std::unique_ptr Preprocessor;
   mutable std::unique_ptr Compiler;
+  void findGccDir();
   void findGccLibDir();
 };
 
Index: lib/Driver/MinGWToolChain.cpp
===
--- lib/Driver/MinGWToolChain.cpp
+++ lib/Driver/MinGWToolChain.cpp
@@ -62,19 +62,29 @@
   }
 }

+void MinGW::findGccDir() {
+  llvm::SmallVector, 2> Gccs;
+  Gccs.emplace_back(getTriple().getArchName());
+  Gccs[0] += "-w64-mingw32-gcc";
+  Gccs.emplace_back("mingw32-gcc");
+  for (StringRef CandidateGcc : Gccs)
+if (llvm::ErrorOr GPPName =
+  llvm::sys::findProgramByName(CandidateGcc)) {
+  Base = llvm::sys::path::parent_path(
+  llvm::sys::path::parent_path(GPPName.get()));
+  return;
+}
+}
+
 MinGW::MinGW(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
 : ToolChain(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());

-  // On Windows if there is no sysroot we search for gcc on the PATH.
   if (getDriver().SysRoot.size())
-  Base = getDriver().SysRoot;
-#ifdef LLVM_ON_WIN32
-  else if (llvm::ErrorOr GPPName =
-   llvm::sys::findProgramByName("gcc"))
-Base = llvm::sys::path::parent_path(
-llvm::sys::path::parent_path(GPPName.get()));
-#endif
+Base = getDriver().SysRoot;
+  else
+findGccDir();
+
   if (!Base.size())
 Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());

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


r254141 - [OPENMP 4.5] Fixed rules for 'ordered' clause.

2015-11-25 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Nov 26 01:50:39 2015
New Revision: 254141

URL: http://llvm.org/viewvc/llvm-project?rev=254141&view=rev
Log:
[OPENMP 4.5] Fixed rules for 'ordered' clause.
According to OpenMP 4.5 the parameter of 'ordered' clause must be greater than 
or equal to the parameter of 'collapse' clause. Patch adds this rule.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/for_ordered_clause.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=254141&r1=254140&r2=254141&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Nov 26 01:50:39 
2015
@@ -7901,6 +7901,10 @@ def note_omp_static_member_in_target : N
   "mappable type cannot contain static members">;
 def err_omp_threadprivate_in_map : Error<
   "threadprivate variables are not allowed in map clause">;
+def err_omp_wrong_ordered_loop_count : Error<
+  "the parameter of the 'ordered' clause must be greater than or equal to the 
parameter of the 'collapse' clause">;
+def note_collapse_loop_count : Note<
+  "parameter of the 'collapse' clause">;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=254141&r1=254140&r2=254141&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Nov 26 01:50:39 2015
@@ -3359,13 +3359,22 @@ CheckOpenMPLoop(OpenMPDirectiveKind DKin
 // Found 'collapse' clause - calculate collapse number.
 llvm::APSInt Result;
 if (CollapseLoopCountExpr->EvaluateAsInt(Result, SemaRef.getASTContext()))
-  NestedLoopCount += Result.getLimitedValue() - 1;
+  NestedLoopCount = Result.getLimitedValue();
   }
   if (OrderedLoopCountExpr) {
 // Found 'ordered' clause - calculate collapse number.
 llvm::APSInt Result;
-if (OrderedLoopCountExpr->EvaluateAsInt(Result, SemaRef.getASTContext()))
-  NestedLoopCount += Result.getLimitedValue() - 1;
+if (OrderedLoopCountExpr->EvaluateAsInt(Result, SemaRef.getASTContext())) {
+  if (Result.getLimitedValue() < NestedLoopCount) {
+SemaRef.Diag(OrderedLoopCountExpr->getExprLoc(),
+ diag::err_omp_wrong_ordered_loop_count)
+<< OrderedLoopCountExpr->getSourceRange();
+SemaRef.Diag(CollapseLoopCountExpr->getExprLoc(),
+ diag::note_collapse_loop_count)
+<< CollapseLoopCountExpr->getSourceRange();
+  }
+  NestedLoopCount = Result.getLimitedValue();
+}
   }
   // This is helper routine for loop directives (e.g., 'for', 'simd',
   // 'for simd', etc.).
@@ -5256,13 +5265,10 @@ ExprResult Sema::VerifyPositiveIntegerCo
 << E->getSourceRange();
 return ExprError();
   }
-  if (CKind == OMPC_collapse) {
-DSAStack->setCollapseNumber(DSAStack->getCollapseNumber() - 1 +
-Result.getExtValue());
-  } else if (CKind == OMPC_ordered) {
-DSAStack->setCollapseNumber(DSAStack->getCollapseNumber() - 1 +
-Result.getExtValue());
-  }
+  if (CKind == OMPC_collapse)
+DSAStack->setCollapseNumber(Result.getExtValue());
+  else if (CKind == OMPC_ordered)
+DSAStack->setCollapseNumber(Result.getExtValue());
   return ICE;
 }
 

Modified: cfe/trunk/test/OpenMP/for_ordered_clause.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_ordered_clause.cpp?rev=254141&r1=254140&r2=254141&view=diff
==
--- cfe/trunk/test/OpenMP/for_ordered_clause.cpp (original)
+++ cfe/trunk/test/OpenMP/for_ordered_clause.cpp Thu Nov 26 01:50:39 2015
@@ -52,11 +52,19 @@ T tmain(T argc, S **argv) {
 #pragma omp for ordered(1)
   for (int i = ST; i < N; i++)
 argv[0][i] = argv[0][i] - argv[0][i - ST];
+#pragma omp for ordered(N-1) // expected-error 2 {{argument to 'ordered' 
clause must be a positive integer value}}
+  for (int i = ST; i < N; i++)
+argv[0][i] = argv[0][i] - argv[0][i - ST];
 #pragma omp for ordered(N) // expected-error {{argument to 'ordered' clause 
must be a positive integer value}}
   for (T i = ST; i < N; i++)
 argv[0][i] = argv[0][i] - argv[0][i - ST];
 #pragma omp for ordered(2) // expected-note {{as specified in 'ordered' 
clause}}
   foo();// expected-error {{expected 2 for loops after 
'#pragma omp for'}}
+#pragma omp for ordered(N) collapse(N + 2) // expected-error {{the parameter 
of the 'ordered' clause must be greater than or equal to the parameter of the 
'

Re: [PATCH] D14940: [OpenMP] Update target directive codegen to use 4.5 implicit data mappings.

2015-11-25 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: include/clang/AST/Stmt.h:2018-2020
@@ -2016,2 +2017,5 @@
 break;
+  case VCK_ByCopy:
+assert(Var && "capturing by copy must have a variable!");
+break;
   case VCK_VLAType:

Also add assertion that only pointers anmd scalars are allowed to be captured 
by value


Comment at: lib/CodeGen/CGStmtOpenMP.cpp:139-140
@@ -112,2 +138,4 @@
   I = S.captures().begin();
-  for (auto *FD : RD->fields()) {
+  for (auto FI = RD->field_begin(), FE = RD->field_end(); FI != FE;
+   ++FI, ++Cnt, ++I) {
+auto *FD = *FI;

Turn back to range-based loop


Comment at: lib/Sema/SemaOpenMP.cpp:818-819
@@ +817,4 @@
+// captures in that those cases.
+IsByRef = isa(Ty) || isa(Ty) ||
+  isa(Ty);
+  }

Wow. I think it is just enough to check !Ty->isScalarType().


http://reviews.llvm.org/D14940



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