Re: [PATCH] D16779: Fix attribute((mode([word|unwind_word]))) for x32

2016-02-01 Thread Reid Kleckner via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL259383: Fix attribute((mode([word|unwind_word]))) for x32 
(authored by rnk).

Changed prior to commit:
  http://reviews.llvm.org/D16779?vs=46558=46559#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16779

Files:
  cfe/trunk/include/clang/Basic/TargetInfo.h
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/Sema/attr-mode.c

Index: cfe/trunk/include/clang/Basic/TargetInfo.h
===
--- cfe/trunk/include/clang/Basic/TargetInfo.h
+++ cfe/trunk/include/clang/Basic/TargetInfo.h
@@ -413,10 +413,10 @@
   }
 
   // Return the size of unwind_word for this target.
-  unsigned getUnwindWordWidth() const { return getPointerWidth(0); }
+  virtual unsigned getUnwindWordWidth() const { return getPointerWidth(0); }
 
   /// \brief Return the "preferred" register width on this target.
-  unsigned getRegisterWidth() const {
+  virtual unsigned getRegisterWidth() const {
 // Currently we assume the register width on the target matches the pointer
 // width, we can introduce a new variable for this if/when some target 
wants
 // it.
Index: cfe/trunk/test/Sema/attr-mode.c
===
--- cfe/trunk/test/Sema/attr-mode.c
+++ cfe/trunk/test/Sema/attr-mode.c
@@ -4,6 +4,8 @@
 // RUN:   -verify %s
 // RUN: %clang_cc1 -triple powerpc64-pc-linux-gnu -DTEST_64BIT_PPC64 
-fsyntax-only \
 // RUN:   -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnux32 -DTEST_64BIT_X86 
-fsyntax-only \
+// RUN:   -verify %s
 
 typedef int i16_1 __attribute((mode(HI)));
 int i16_1_test[sizeof(i16_1) == 2 ? 1 : -1];
@@ -63,8 +65,17 @@
 void test_long_to_i64(long long* y) { f_i64_arg(y); }
 void test_long_to_ui64(unsigned long long* y) { f_ui64_arg(y); }
 #elif TEST_64BIT_X86
+#ifdef __ILP32__
+typedef unsigned int gcc_word __attribute__((mode(word)));
+int foo[sizeof(gcc_word) == 8 ? 1 : -1];
+typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
+int foo[sizeof(gcc_unwind_word) == 8 ? 1 : -1];
+void test_long_to_i64(long long* y) { f_i64_arg(y); }
+void test_long_to_ui64(unsigned long long* y) { f_ui64_arg(y); }
+#else
 void test_long_to_i64(long* y) { f_i64_arg(y); }
 void test_long_to_ui64(unsigned long* y) { f_ui64_arg(y); }
+#endif
 typedef  float f128ibm __attribute__ ((mode (TF))); // 
expected-error{{unsupported machine mode 'TF'}}
 #elif TEST_64BIT_PPC64
 typedef  float f128ibm __attribute__ ((mode (TF)));
Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -3332,7 +3332,7 @@
 // FIXME: glibc uses 'word' to define register_t; this is narrower than a
 // pointer on PIC16 and other embedded platforms.
 if (Str == "word")
-  DestWidth = S.Context.getTargetInfo().getPointerWidth(0);
+  DestWidth = S.Context.getTargetInfo().getRegisterWidth();
 else if (Str == "byte")
   DestWidth = S.Context.getTargetInfo().getCharWidth();
 break;
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -4029,6 +4029,8 @@
 
   // for x32 we need it here explicitly
   bool hasInt128Type() const override { return true; }
+  unsigned getUnwindWordWidth() const override { return 64; }
+  unsigned getRegisterWidth() const override { return 64; }
 
   bool validateGlobalRegisterVariable(StringRef RegName,
   unsigned RegSize,


Index: cfe/trunk/include/clang/Basic/TargetInfo.h
===
--- cfe/trunk/include/clang/Basic/TargetInfo.h
+++ cfe/trunk/include/clang/Basic/TargetInfo.h
@@ -413,10 +413,10 @@
   }
 
   // Return the size of unwind_word for this target.
-  unsigned getUnwindWordWidth() const { return getPointerWidth(0); }
+  virtual unsigned getUnwindWordWidth() const { return getPointerWidth(0); }
 
   /// \brief Return the "preferred" register width on this target.
-  unsigned getRegisterWidth() const {
+  virtual unsigned getRegisterWidth() const {
 // Currently we assume the register width on the target matches the pointer
 // width, we can introduce a new variable for this if/when some target wants
 // it.
Index: cfe/trunk/test/Sema/attr-mode.c
===
--- cfe/trunk/test/Sema/attr-mode.c
+++ cfe/trunk/test/Sema/attr-mode.c
@@ -4,6 +4,8 @@
 // RUN:   -verify %s
 // RUN: %clang_cc1 -triple powerpc64-pc-linux-gnu -DTEST_64BIT_PPC64 -fsyntax-only \
 // RUN:   -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnux32 -DTEST_64BIT_X86 -fsyntax-only \
+// RUN:   -verify %s
 
 typedef int i16_1 

Re: [PATCH] D16686: [OpenCL] Generate metadata for opencl_unroll_hint attribute

2016-02-01 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 46570.
yaxunl marked 7 inline comments as done.
yaxunl added a comment.

Revised as Anastasia suggested.


http://reviews.llvm.org/D16686

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  lib/CodeGen/CGLoopInfo.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseStmt.cpp
  lib/Sema/SemaStmtAttr.cpp
  test/CodeGenOpenCL/unroll-hint.cl
  test/Parser/opencl-unroll-hint.cl
  test/SemaOpenCL/unroll-hint.cl

Index: test/SemaOpenCL/unroll-hint.cl
===
--- /dev/null
+++ test/SemaOpenCL/unroll-hint.cl
@@ -0,0 +1,19 @@
+//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s
+
+kernel void C (global int *x) {
+  int I = 3;
+  __attribute__((opencl_unroll_hint(I))) // expected-error {{opencl_unroll_hint attribute requires an integer constant}}
+  while (I--);
+}
+
+kernel void D (global int *x) {
+  int i = 10;
+  __attribute__((opencl_unroll_hint))
+  do {
+  } while(i--);
+}
+
+kernel void E() {
+  __attribute__((opencl_unroll_hint(2,4))) // expected-error {{1 attribute takes no more than 1 argument}}
+  for(int i=0; i<100; i++);
+}
Index: test/Parser/opencl-unroll-hint.cl
===
--- /dev/null
+++ test/Parser/opencl-unroll-hint.cl
@@ -0,0 +1,8 @@
+//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s
+
+kernel void B (global int *x) {
+  __attribute__((opencl_unroll_hint(42)))
+  if (x[0]) // expected-error {{OpenCL only supports opencl_unroll_hint attribute on for, while, and do statements}}
+x[0] = 15;
+}
+
Index: test/CodeGenOpenCL/unroll-hint.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/unroll-hint.cl
@@ -0,0 +1,96 @@
+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+
+/*** for ***/
+void for_count()
+{
+// CHECK-LABEL: for_count
+__attribute__((opencl_unroll_hint(8)))
+for( int i = 0; i < 1000; ++i);
+// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_COUNT:.*]]
+}
+
+void for_disable()
+{
+// CHECK-LABEL: for_disable
+__attribute__((opencl_unroll_hint(1)))
+for( int i = 0; i < 1000; ++i);
+// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_DISABLE:.*]]
+}
+
+void for_full()
+{
+// CHECK-LABEL: for_full
+__attribute__((opencl_unroll_hint))
+for( int i = 0; i < 1000; ++i);
+// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_FULL:.*]]
+}
+
+/*** while ***/
+void while_count()
+{
+// CHECK-LABEL: while_count
+int i = 1000;
+__attribute__((opencl_unroll_hint(8)))
+while(i-->0);
+// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_COUNT:.*]]
+}
+
+void while_disable()
+{
+// CHECK-LABEL: while_disable
+int i = 1000;
+__attribute__((opencl_unroll_hint(1)))
+while(i-->0);
+// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_DISABLE:.*]]
+}
+
+void while_full()
+{
+// CHECK-LABEL: while_full
+int i = 1000;
+__attribute__((opencl_unroll_hint))
+while(i-->0);
+// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_FULL:.*]]
+}
+
+/*** do ***/
+void do_count()
+{
+// CHECK-LABEL: do_count
+int i = 1000;
+__attribute__((opencl_unroll_hint(8)))
+do {} while(i--> 0);
+// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_COUNT:.*]]
+}
+
+void do_disable()
+{
+// CHECK-LABEL: do_disable
+int i = 1000;
+__attribute__((opencl_unroll_hint(1)))
+do {} while(i--> 0);
+// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_DISABLE:.*]]
+}
+
+void do_full()
+{
+// CHECK-LABEL: do_full
+int i = 1000;
+__attribute__((opencl_unroll_hint))
+do {} while(i--> 0);
+// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_FULL:.*]]
+}
+
+
+// CHECK: ![[FOR_COUNT]] =  distinct !{![[FOR_COUNT]],  ![[COUNT:.*]]}
+// CHECK: ![[COUNT]] =  !{!"llvm.loop.unroll.count", i32 8}
+// CHECK: ![[FOR_DISABLE]]   =  distinct !{![[FOR_DISABLE]],  ![[DISABLE:.*]]}
+// CHECK: ![[DISABLE]]   =  !{!"llvm.loop.unroll.disable"}
+// CHECK: ![[FOR_FULL]]  =  distinct !{![[FOR_FULL]],  ![[FULL:.*]]}
+// CHECK: ![[FULL]]  =  !{!"llvm.loop.unroll.full"}
+// CHECK: ![[WHILE_COUNT]]   =  distinct !{![[WHILE_COUNT]],![[COUNT]]}
+// CHECK: ![[WHILE_DISABLE]] =  distinct !{![[WHILE_DISABLE]],  ![[DISABLE]]}
+// CHECK: ![[WHILE_FULL]]=  distinct !{![[WHILE_FULL]], ![[FULL]]}
+// CHECK: ![[DO_COUNT]]  =  distinct !{![[DO_COUNT]],   ![[COUNT]]}
+// CHECK: ![[DO_DISABLE]]=  distinct !{![[DO_DISABLE]], ![[DISABLE]]}
+// CHECK: ![[DO_FULL]]   =  distinct !{![[DO_FULL]],![[FULL]]}
Index: lib/Sema/SemaStmtAttr.cpp
===
--- lib/Sema/SemaStmtAttr.cpp
+++ lib/Sema/SemaStmtAttr.cpp
@@ -203,6 +203,47 @@
   }
 }
 

Re: [PATCH] D16738: Fix invalid casts in .

2016-02-01 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

In http://reviews.llvm.org/D16738#340175, @EricWF wrote:

> > This also could be fixed in a different way by replacing C-style
>
> >  casts with reinterpret_cast<>, which, from my reading of the
>
> >  standard, is allowed in this context.
>
>
> I agree that using `void*` to represent raw memory is the better approach 
> than `reinterpret_cast<>()`.
>  However I'm concerned that changing the signature (and mangling) of `virtual 
> void __clone(...)` could cause ABI problems.
>  I *think* this should be "safe" because the VTable's mangled name doesn't 
> change. but if I'm wrong we must use `reinterpret_cast<>` for calls to 
> `__clone(...)`.
>
> The parts of the patch that don't affect `__clone(...)` LGTM. You can commit 
> them separably if you want.
>
> > That would not help with CFI
>
> >  though, which still flags such casts as invalid (yes, it is stricter that 
> > the standard).
>
>
> I'm sure there are alternative ways to make CFI shut up. Perhaps we could do 
> the `Buffer* -> Base*` conversion inside a blacklisted function (akin to 
> std::launder)?
>  It would also be nice to have "`__attribute__((__no_sanitize__("cfi")))`.


We do have this attribute.


Repository:
  rL LLVM

http://reviews.llvm.org/D16738



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


r259383 - Fix attribute((mode([word|unwind_word]))) for x32

2016-02-01 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Mon Feb  1 12:58:24 2016
New Revision: 259383

URL: http://llvm.org/viewvc/llvm-project?rev=259383=rev
Log:
Fix attribute((mode([word|unwind_word]))) for x32

Patch by H.J. Lu

```
typedef unsigned int gcc_word __attribute__((mode(word)));
```
and

```
typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
```
define the largest unsigned integer types which can be stored in a
general purpose register, which may not be the pointer type.  For x32,
they aren't pointer nor unsigned long.  We should

1. Make getUnwindWordWidth and getRegisterWidth virtual,
2. Override them for x32, similar to hasInt128Type.
3. Use getRegisterWidth for __attribute__((mode(word)));

This fixes PR 24706.

Reviewers: rnk

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

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/attr-mode.c

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=259383=259382=259383=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Mon Feb  1 12:58:24 2016
@@ -413,10 +413,10 @@ public:
   }
 
   // Return the size of unwind_word for this target.
-  unsigned getUnwindWordWidth() const { return getPointerWidth(0); }
+  virtual unsigned getUnwindWordWidth() const { return getPointerWidth(0); }
 
   /// \brief Return the "preferred" register width on this target.
-  unsigned getRegisterWidth() const {
+  virtual unsigned getRegisterWidth() const {
 // Currently we assume the register width on the target matches the pointer
 // width, we can introduce a new variable for this if/when some target 
wants
 // it.

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=259383=259382=259383=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Feb  1 12:58:24 2016
@@ -4029,6 +4029,8 @@ public:
 
   // for x32 we need it here explicitly
   bool hasInt128Type() const override { return true; }
+  unsigned getUnwindWordWidth() const override { return 64; }
+  unsigned getRegisterWidth() const override { return 64; }
 
   bool validateGlobalRegisterVariable(StringRef RegName,
   unsigned RegSize,

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=259383=259382=259383=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Feb  1 12:58:24 2016
@@ -3332,7 +3332,7 @@ static void parseModeAttrArg(Sema , St
 // FIXME: glibc uses 'word' to define register_t; this is narrower than a
 // pointer on PIC16 and other embedded platforms.
 if (Str == "word")
-  DestWidth = S.Context.getTargetInfo().getPointerWidth(0);
+  DestWidth = S.Context.getTargetInfo().getRegisterWidth();
 else if (Str == "byte")
   DestWidth = S.Context.getTargetInfo().getCharWidth();
 break;

Modified: cfe/trunk/test/Sema/attr-mode.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-mode.c?rev=259383=259382=259383=diff
==
--- cfe/trunk/test/Sema/attr-mode.c (original)
+++ cfe/trunk/test/Sema/attr-mode.c Mon Feb  1 12:58:24 2016
@@ -4,6 +4,8 @@
 // RUN:   -verify %s
 // RUN: %clang_cc1 -triple powerpc64-pc-linux-gnu -DTEST_64BIT_PPC64 
-fsyntax-only \
 // RUN:   -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnux32 -DTEST_64BIT_X86 
-fsyntax-only \
+// RUN:   -verify %s
 
 typedef int i16_1 __attribute((mode(HI)));
 int i16_1_test[sizeof(i16_1) == 2 ? 1 : -1];
@@ -63,8 +65,17 @@ void test_int_to_ui32(unsigned int* y) {
 void test_long_to_i64(long long* y) { f_i64_arg(y); }
 void test_long_to_ui64(unsigned long long* y) { f_ui64_arg(y); }
 #elif TEST_64BIT_X86
+#ifdef __ILP32__
+typedef unsigned int gcc_word __attribute__((mode(word)));
+int foo[sizeof(gcc_word) == 8 ? 1 : -1];
+typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
+int foo[sizeof(gcc_unwind_word) == 8 ? 1 : -1];
+void test_long_to_i64(long long* y) { f_i64_arg(y); }
+void test_long_to_ui64(unsigned long long* y) { f_ui64_arg(y); }
+#else
 void test_long_to_i64(long* y) { f_i64_arg(y); }
 void test_long_to_ui64(unsigned long* y) { f_ui64_arg(y); }
+#endif
 typedef  float f128ibm __attribute__ ((mode (TF))); // 
expected-error{{unsupported machine mode 'TF'}}
 #elif TEST_64BIT_PPC64
 typedef  float f128ibm __attribute__ ((mode (TF)));



Re: [PATCH] D16748: Cleanup MemRegion.cpp/MemRegion.h

2016-02-01 Thread Alexander Riccio via cfe-commits
ariccio marked an inline comment as done.
ariccio added a comment.

As said in comment, I disagree with the no need for `const` here.



Comment at: C:/LLVM/llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1396
@@ -1395,3 +1395,3 @@
   const auto  = AC->getReferencedBlockVars(BC->getDecl());
-  auto NumBlockVars =
+  const auto NumBlockVars =
   std::distance(ReferencedBlockVars.begin(), ReferencedBlockVars.end());

aaron.ballman wrote:
> No need for a const here; the correct change is to not use auto (here and the 
> line above), but instead spell out the type explicitly.
The const is partly to make sure that the `if (NumBlockVars == 0) {` line never 
accidentally becomes `if (NumBlockVars = 0) {` like it did in CPython:

http://bugs.python.org/issue25844


Comment at: C:/LLVM/llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1396
@@ -1395,3 +1395,3 @@
   const auto  = AC->getReferencedBlockVars(BC->getDecl());
-  auto NumBlockVars =
+  const auto NumBlockVars =
   std::distance(ReferencedBlockVars.begin(), ReferencedBlockVars.end());

ariccio wrote:
> aaron.ballman wrote:
> > No need for a const here; the correct change is to not use auto (here and 
> > the line above), but instead spell out the type explicitly.
> The const is partly to make sure that the `if (NumBlockVars == 0) {` line 
> never accidentally becomes `if (NumBlockVars = 0) {` like it did in CPython:
> 
> http://bugs.python.org/issue25844
For archival reasons, I'll copy & paste the relevant diff here (I hate dead 
links):


```
--- a/PC/launcher.c
+++ b/PC/launcher.c
@@ -114,7 +114,7 @@ static wchar_t * get_env(wchar_t * key)
 if (result >= BUFSIZE) {
 /* Large environment variable. Accept some leakage */
 wchar_t *buf2 = (wchar_t*)malloc(sizeof(wchar_t) * (result+1));
-if (buf2 = NULL) {
+if (buf2 == NULL) {
 error(RC_NO_MEMORY, L"Could not allocate environment buffer");
 }
 GetEnvironmentVariableW(key, buf2, result);
```


http://reviews.llvm.org/D16748



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


[PATCH] D16786: [Clang-tidy] Make modernize-redundant-void-arg working with included files

2016-02-01 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko created this revision.
Eugene.Zelenko added reviewers: alexfh, LegalizeAdulthood, aaron.ballman.
Eugene.Zelenko added a subscriber: cfe-commits.
Eugene.Zelenko set the repository for this revision to rL LLVM.

This fix for PR25894. I checked it on my work code base.

Build and regressions were OK on RHEL 6.

Repository:
  rL LLVM

http://reviews.llvm.org/D16786

Files:
  clang-tidy/modernize/RedundantVoidArgCheck.cpp

Index: clang-tidy/modernize/RedundantVoidArgCheck.cpp
===
--- clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -46,42 +46,30 @@
 namespace modernize {
 
 void RedundantVoidArgCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(functionDecl(isExpansionInMainFile(), parameterCountIs(0),
-  unless(isImplicit()), unless(isExternC()))
- .bind(FunctionId),
+  Finder->addMatcher(functionDecl(parameterCountIs(0), unless(isImplicit()),
+  unless(isExternC())).bind(FunctionId),
  this);
-  Finder->addMatcher(typedefDecl(isExpansionInMainFile()).bind(TypedefId),
- this);
+  Finder->addMatcher(typedefDecl().bind(TypedefId), this);
   auto ParenFunctionType = parenType(innerType(functionType()));
   auto PointerToFunctionType = pointee(ParenFunctionType);
   auto FunctionOrMemberPointer =
   anyOf(hasType(pointerType(PointerToFunctionType)),
 hasType(memberPointerType(PointerToFunctionType)));
-  Finder->addMatcher(
-  fieldDecl(isExpansionInMainFile(), 
FunctionOrMemberPointer).bind(FieldId),
-  this);
-  Finder->addMatcher(
-  varDecl(isExpansionInMainFile(), FunctionOrMemberPointer).bind(VarId),
-  this);
+  Finder->addMatcher(fieldDecl(FunctionOrMemberPointer).bind(FieldId), this);
+  Finder->addMatcher(varDecl(FunctionOrMemberPointer).bind(VarId), this);
   auto CastDestinationIsFunction =
   hasDestinationType(pointsTo(ParenFunctionType));
   Finder->addMatcher(
-  cStyleCastExpr(isExpansionInMainFile(), CastDestinationIsFunction)
-  .bind(CStyleCastId),
-  this);
+  cStyleCastExpr(CastDestinationIsFunction).bind(CStyleCastId), this);
   Finder->addMatcher(
-  cxxStaticCastExpr(isExpansionInMainFile(), CastDestinationIsFunction)
-  .bind(NamedCastId),
-  this);
+  cxxStaticCastExpr(CastDestinationIsFunction).bind(NamedCastId), this);
   Finder->addMatcher(
-  cxxReinterpretCastExpr(isExpansionInMainFile(), 
CastDestinationIsFunction)
-  .bind(NamedCastId),
+  cxxReinterpretCastExpr(CastDestinationIsFunction).bind(NamedCastId),
   this);
   Finder->addMatcher(
-  cxxConstCastExpr(isExpansionInMainFile(), CastDestinationIsFunction)
-  .bind(NamedCastId),
+  cxxConstCastExpr(CastDestinationIsFunction).bind(NamedCastId),
   this);
-  Finder->addMatcher(lambdaExpr(isExpansionInMainFile()).bind(LambdaId), this);
+  Finder->addMatcher(lambdaExpr().bind(LambdaId), this);
 }
 
 void RedundantVoidArgCheck::check(const MatchFinder::MatchResult ) {


Index: clang-tidy/modernize/RedundantVoidArgCheck.cpp
===
--- clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -46,42 +46,30 @@
 namespace modernize {
 
 void RedundantVoidArgCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(functionDecl(isExpansionInMainFile(), parameterCountIs(0),
-  unless(isImplicit()), unless(isExternC()))
- .bind(FunctionId),
+  Finder->addMatcher(functionDecl(parameterCountIs(0), unless(isImplicit()),
+  unless(isExternC())).bind(FunctionId),
  this);
-  Finder->addMatcher(typedefDecl(isExpansionInMainFile()).bind(TypedefId),
- this);
+  Finder->addMatcher(typedefDecl().bind(TypedefId), this);
   auto ParenFunctionType = parenType(innerType(functionType()));
   auto PointerToFunctionType = pointee(ParenFunctionType);
   auto FunctionOrMemberPointer =
   anyOf(hasType(pointerType(PointerToFunctionType)),
 hasType(memberPointerType(PointerToFunctionType)));
-  Finder->addMatcher(
-  fieldDecl(isExpansionInMainFile(), FunctionOrMemberPointer).bind(FieldId),
-  this);
-  Finder->addMatcher(
-  varDecl(isExpansionInMainFile(), FunctionOrMemberPointer).bind(VarId),
-  this);
+  Finder->addMatcher(fieldDecl(FunctionOrMemberPointer).bind(FieldId), this);
+  Finder->addMatcher(varDecl(FunctionOrMemberPointer).bind(VarId), this);
   auto CastDestinationIsFunction =
   hasDestinationType(pointsTo(ParenFunctionType));
   Finder->addMatcher(
-  cStyleCastExpr(isExpansionInMainFile(), CastDestinationIsFunction)
-  .bind(CStyleCastId),
-  this);
+  

RE: [PATCH] D16754: Bug 15785 - OpenCL errors using vector/scalar conditionals and short integer types

2016-02-01 Thread Igor Chesnokov via cfe-commits
Thanks Paul!

-Original Message-
From: Robinson, Paul [mailto:paul_robin...@playstation.sony.com] 
Sent: Monday, February 1, 2016 11:46 PM
To: Igor Chesnokov; Anton Korobeynikov
Cc: cfe-commits (cfe-commits@lists.llvm.org)
Subject: RE: [PATCH] D16754: Bug 15785 - OpenCL errors using vector/scalar 
conditionals and short integer types

> Hi Anton,
> 
>   Okey, nevermore.
>   But what to do with a bug which needs simply be closed (NABs)?
>   I believe they also need a review/approval.
> 
> Igor

Bugs do not have such a strict process, compared to patches.
If you don't feel confident in closing the bug directly, you can ask the person 
who submitted the bug if they are happy with your answer.
--paulr

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


Re: [PATCH] D15305: [CUDA] Do not allow dynamic initialization of global device side variables.

2016-02-01 Thread Artem Belevich via cfe-commits
Richard,

On Fri, Jan 15, 2016 at 5:32 PM, Richard Smith 
wrote:

> On Fri, Jan 15, 2016 at 5:29 PM, Richard Smith 
> wrote:
> > On Fri, Jan 15, 2016 at 4:22 PM, Artem Belevich  wrote:
> >> tra added inline comments.
> >>
> >> 
> >> Comment at: lib/CodeGen/CodeGenModule.cpp:2334
> >> @@ -2339,1 +2333,3 @@
> >> +  D->hasAttr())
> >>  Init = llvm::UndefValue::get(getTypes().ConvertType(ASTTy));
> >> +  else if (!InitExpr) {
> >> 
> >> rsmith wrote:
> >>> As this is a global variable, it should presumably still be statically
> zero-initialized.
> >> There is no way to initialize __shared__ variables. They are rough
> equivalent of local variables, only in this case CUDA allocates them per
> kernel invocation from a shared buffer with no guarantees regarding its
> contents.
> >>
> >> They used to be zero-initialized by compiler, but that was
> intentionally changed to undef in r245786 / http://reviews.llvm.org/D12241
> >
> > That doesn't seem right. C++ guarantees zero-initialization for all
> > globals, prior to performing any other initialization.
>
> It looks like the problem being fixed by D12241 was probably caused by
> the __shared__ variables having the wrong linkage.
>

I'll take a look at this separately as it's unrelated to this patch.

I believe current patch addresses your other comments.

--Artem




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


Re: [PATCH] D15305: [CUDA] Do not allow dynamic initialization of global device side variables.

2016-02-01 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Some minor things, but feel free to commit after addressing them.

I agree that we should figure out what to do about the zero/undef 
initialization separately.



Comment at: lib/Sema/SemaCUDA.cpp:429-430
@@ +428,4 @@
+  CXXConstructorDecl *CD) {
+  if (!CD->isDefined() && CD->isTemplateInstantiation())
+InstantiateFunctionDefinition(VarLoc, CD->getFirstDecl());
+

The function might still not be defined after this (if the template is not 
defined); you should presumably return `false` here in that case.


Comment at: lib/Sema/SemaCUDA.cpp:442
@@ +441,3 @@
+  // and the function body is an empty compound statement.
+  if (!(CD->isDefined() && CD->getNumParams() == 0 && CD->hasTrivialBody()))
+return false;

Please do remove the `isDefined` check here. Including it makes a reader wonder 
what case it's trying to handle.


Comment at: lib/Sema/SemaCUDA.cpp:455-457
@@ +454,5 @@
+
+  // Its class has no virtual functions and no virtual base classes.
+  if (CD->getParent()->isDynamicClass())
+return false;
+

Maybe reorder this before the `CXXCtorInitializer` check? It's a much cheaper 
test.


Comment at: lib/Sema/SemaDecl.cpp:10191-10198
@@ +10190,10 @@
+  bool AllowedInit = false;
+  if (const CXXConstructExpr *CE = dyn_cast(Init))
+AllowedInit =
+isEmptyCudaConstructor(VD->getLocation(), CE->getConstructor());
+  else if ((VD->hasAttr() ||
+VD->hasAttr()) &&
+   VD->getInit()->isConstantInitializer(
+   Context, VD->getType()->isReferenceType()))
+AllowedInit = true;
+

What should happen if the init is a constant initializer that is a 
`CXXConstructExpr`, but it uses a constructor that is not empty from CUDA's 
perspective? Such as:

  struct X { constexpr X() { int n = 0; } };
  __device__ X x;

I would assume this should be valid, but I think you'll reject it. Maybe change 
`else if (` to `if (!AllowedInit &&`?


Comment at: lib/Sema/SemaDecl.cpp:10196-10198
@@ +10195,5 @@
+VD->hasAttr()) &&
+   VD->getInit()->isConstantInitializer(
+   Context, VD->getType()->isReferenceType()))
+AllowedInit = true;
+

Might be clearer as

  if (__device__ || __constant__)
AllowedInit = isConstantInitializer(...)


http://reviews.llvm.org/D15305



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


Re: [PATCH] D16748: Cleanup MemRegion.cpp/MemRegion.h

2016-02-01 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: C:/LLVM/llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1396
@@ -1395,3 +1395,3 @@
   const auto  = AC->getReferencedBlockVars(BC->getDecl());
-  auto NumBlockVars =
+  const auto NumBlockVars =
   std::distance(ReferencedBlockVars.begin(), ReferencedBlockVars.end());

ariccio wrote:
> ariccio wrote:
> > aaron.ballman wrote:
> > > No need for a const here; the correct change is to not use auto (here and 
> > > the line above), but instead spell out the type explicitly.
> > The const is partly to make sure that the `if (NumBlockVars == 0) {` line 
> > never accidentally becomes `if (NumBlockVars = 0) {` like it did in CPython:
> > 
> > http://bugs.python.org/issue25844
> For archival reasons, I'll copy & paste the relevant diff here (I hate dead 
> links):
> 
> 
> ```
> --- a/PC/launcher.c
> +++ b/PC/launcher.c
> @@ -114,7 +114,7 @@ static wchar_t * get_env(wchar_t * key)
>  if (result >= BUFSIZE) {
>  /* Large environment variable. Accept some leakage */
>  wchar_t *buf2 = (wchar_t*)malloc(sizeof(wchar_t) * (result+1));
> -if (buf2 = NULL) {
> +if (buf2 == NULL) {
>  error(RC_NO_MEMORY, L"Could not allocate environment buffer");
>  }
>  GetEnvironmentVariableW(key, buf2, result);
> ```
While this form of bug can certainly crop up, it's still a bridge-too-far for 
this project, as I understand it our de facto guidelines on this. I am not 
certain that we want to start sprinkling const onto value types (as opposed to 
reference and pointer types) at this point. If we do, it should certainly be 
something handled a bit more consistently and actively than a general clean-up 
related to unnecessary type casting.


http://reviews.llvm.org/D16748



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


Re: r257710 - [Sema] Suppress diags in overload resolution.

2016-02-01 Thread Richard Smith via cfe-commits
LGTM for 3.8.

On Wed, Jan 13, 2016 at 4:03 PM, Hans Wennborg  wrote:
> Thanks! Richard, what say the code owner?
>
> On Wed, Jan 13, 2016 at 3:59 PM, George Burgess IV
>  wrote:
>> FYI: This patch should to be merged into the clang 3.8.0 branch.
>>
>> Thank you!
>> George
>>
>> On Wed, Jan 13, 2016 at 3:36 PM, George Burgess IV via cfe-commits
>>  wrote:
>>>
>>> Author: gbiv
>>> Date: Wed Jan 13 17:36:34 2016
>>> New Revision: 257710
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=257710=rev
>>> Log:
>>> [Sema] Suppress diags in overload resolution.
>>>
>>> We were emitting diagnostics from our shiny new C-only overload
>>> resolution mode. This patch attempts to silence all such diagnostics.
>>>
>>> This fixes PR26085.
>>> Differential Revision: http://reviews.llvm.org/D16159
>>>
>>> Added:
>>> cfe/trunk/test/SemaObjC/ovl-check.m
>>> Modified:
>>> cfe/trunk/include/clang/Sema/Sema.h
>>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>>> cfe/trunk/lib/Sema/SemaExpr.cpp
>>> cfe/trunk/lib/Sema/SemaExprObjC.cpp
>>> cfe/trunk/lib/Sema/SemaOverload.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=257710=257709=257710=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>>> +++ cfe/trunk/include/clang/Sema/Sema.h Wed Jan 13 17:36:34 2016
>>> @@ -2229,7 +2229,8 @@ public:
>>>bool CheckPointerConversion(Expr *From, QualType ToType,
>>>CastKind ,
>>>CXXCastPath& BasePath,
>>> -  bool IgnoreBaseAccess);
>>> +  bool IgnoreBaseAccess,
>>> +  bool Diagnose = true);
>>>bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType
>>> ToType,
>>>   bool InOverloadResolution,
>>>   QualType );
>>> @@ -5388,7 +5389,8 @@ public:
>>>  unsigned AmbigiousBaseConvID,
>>>  SourceLocation Loc, SourceRange
>>> Range,
>>>  DeclarationName Name,
>>> -CXXCastPath *BasePath);
>>> +CXXCastPath *BasePath,
>>> +bool IgnoreAccess = false);
>>>
>>>std::string getAmbiguousPathsDisplayString(CXXBasePaths );
>>>
>>> @@ -7514,14 +7516,15 @@ public:
>>>  ObjCMethodDecl *,
>>>  ObjCMethodDecl *,
>>>  TypedefNameDecl *,
>>> -bool CfToNs);
>>> -
>>> +bool CfToNs, bool Diagnose =
>>> true);
>>> +
>>>bool CheckObjCBridgeRelatedConversions(SourceLocation Loc,
>>>   QualType DestType, QualType
>>> SrcType,
>>> - Expr *);
>>> -
>>> -  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr
>>> *);
>>> -
>>> + Expr *, bool Diagnose =
>>> true);
>>> +
>>> +  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr
>>> *,
>>> +  bool Diagnose = true);
>>> +
>>>bool checkInitMethod(ObjCMethodDecl *method, QualType
>>> receiverTypeIfCall);
>>>
>>>/// \brief Check whether the given new method is a valid override of
>>> the
>>> @@ -8613,6 +8616,7 @@ public:
>>>ARCConversionResult CheckObjCARCConversion(SourceRange castRange,
>>>   QualType castType, Expr
>>> *,
>>>   CheckedConversionKind CCK,
>>> + bool Diagnose = true,
>>>   bool DiagnoseCFAudited =
>>> false,
>>>   BinaryOperatorKind Opc =
>>> BO_PtrMemD
>>>   );
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=257710=257709=257710=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Jan 13 17:36:34 2016
>>> @@ -1742,13 +1742,18 @@ void Sema::BuildBasePathArray(const CXXB
>>>  /// otherwise. Loc is the location where this routine should point to
>>>  /// if there is an error, and Range is the source range to highlight
>>>  /// if there is an error.
>>> +///
>>> +/// If either InaccessibleBaseID or AmbigiousBaseConvID 

r259409 - Code clean up; NFC.

2016-02-01 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Feb  1 15:28:33 2016
New Revision: 259409

URL: http://llvm.org/viewvc/llvm-project?rev=259409=rev
Log:
Code clean up; NFC.

Patch by Alexander Riccio.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp?rev=259409=259408=259409=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp Mon Feb  1 15:28:33 
2016
@@ -49,12 +49,12 @@ static void collectCheckers(const Checke
 CheckerOptInfo , CheckerInfoSet ) {
   // Use a binary search to find the possible start of the package.
   CheckerRegistry::CheckerInfo packageInfo(nullptr, opt.getName(), "");
-  CheckerRegistry::CheckerInfoList::const_iterator e = checkers.end();
+  auto end = checkers.cend();
   CheckerRegistry::CheckerInfoList::const_iterator i =
-std::lower_bound(checkers.begin(), e, packageInfo, checkerNameLT);
+std::lower_bound(checkers.cbegin(), end, packageInfo, checkerNameLT);
 
   // If we didn't even find a possible package, give up.
-  if (i == e)
+  if (i == end)
 return;
 
   // If what we found doesn't actually start the package, give up.
@@ -73,7 +73,7 @@ static void collectCheckers(const Checke
 size = packageSize->getValue();
 
   // Step through all the checkers in the package.
-  for (e = i+size; i != e; ++i) {
+  for (auto checkEnd = i+size; i != checkEnd; ++i) {
 if (opt.isEnabled())
   collected.insert(&*i);
 else


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


Re: [PATCH] D15450: Avoid double deletion in Clang driver.

2016-02-01 Thread Serge Pavlov via cfe-commits
sepavloff updated this revision to Diff 46575.
sepavloff added a comment.

Added regression test.


http://reviews.llvm.org/D15450

Files:
  lib/CodeGen/CodeGenAction.cpp
  unittests/Frontend/CMakeLists.txt
  unittests/Frontend/CodeGenActionTest.cpp

Index: unittests/Frontend/CodeGenActionTest.cpp
===
--- /dev/null
+++ unittests/Frontend/CodeGenActionTest.cpp
@@ -0,0 +1,61 @@
+//===- unittests/Frontend/CodeGenActionTest.cpp --- FrontendAction tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Unit tests for CodeGenAction.
+//
+//===--===//
+
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/CodeGen/CodeGenAction.h"
+#include "clang/CodeGen/BackendUtil.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace clang;
+using namespace clang::frontend;
+
+namespace {
+
+
+class NullCodeGenAction : public CodeGenAction {
+public:
+  NullCodeGenAction(llvm::LLVMContext *_VMContext = nullptr)
+: CodeGenAction(Backend_EmitLL, _VMContext) {}
+
+  // The action does not call methods of ATContext.
+  void ExecuteAction() override {
+CompilerInstance  = getCompilerInstance();
+if (!CI.hasPreprocessor())
+  return;
+if (!CI.hasSema())
+  CI.createSema(getTranslationUnitKind(), nullptr);
+  }
+};
+
+
+TEST(CodeGenTest, TestNullCodeGen) {
+  CompilerInvocation *Invocation = new CompilerInvocation;
+  Invocation->getPreprocessorOpts().addRemappedFile(
+  "test.cc",
+  MemoryBuffer::getMemBuffer("").release());
+  Invocation->getFrontendOpts().Inputs.push_back(
+  FrontendInputFile("test.cc", IK_CXX));
+  Invocation->getFrontendOpts().ProgramAction = EmitLLVM;
+  Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
+  CompilerInstance Compiler;
+  Compiler.setInvocation(Invocation);
+  Compiler.createDiagnostics();
+  EXPECT_TRUE(Compiler.hasDiagnostics());
+
+  std::unique_ptr Act(new NullCodeGenAction);
+  bool Success = Compiler.ExecuteAction(*Act);
+  EXPECT_TRUE(Success);
+}
+
+}
Index: unittests/Frontend/CMakeLists.txt
===
--- unittests/Frontend/CMakeLists.txt
+++ unittests/Frontend/CMakeLists.txt
@@ -4,11 +4,13 @@
 
 add_clang_unittest(FrontendTests
   FrontendActionTest.cpp
+  CodeGenActionTest.cpp
   )
 target_link_libraries(FrontendTests
   clangAST
   clangBasic
   clangFrontend
   clangLex
   clangSema
+  clangCodeGen
   )
Index: lib/CodeGen/CodeGenAction.cpp
===
--- lib/CodeGen/CodeGenAction.cpp
+++ lib/CodeGen/CodeGenAction.cpp
@@ -53,7 +53,6 @@
 
 std::unique_ptr Gen;
 
-std::unique_ptr TheModule;
 SmallVector, 4>
 LinkModules;
 
@@ -81,7 +80,10 @@
 this->LinkModules.push_back(
 std::make_pair(I.first, std::unique_ptr(I.second)));
 }
-std::unique_ptr takeModule() { return std::move(TheModule); }
+llvm::Module *getModule() const { return Gen->GetModule(); }
+std::unique_ptr takeModule() {
+  return std::unique_ptr(Gen->ReleaseModule());
+}
 void releaseLinkModules() {
   for (auto  : LinkModules)
 I.second.release();
@@ -101,8 +103,6 @@
 
   Gen->Initialize(Ctx);
 
-  TheModule.reset(Gen->GetModule());
-
   if (llvm::TimePassesIsEnabled)
 LLVMIRGeneration.stopTimer();
 }
@@ -149,25 +149,12 @@
   }
 
   // Silently ignore if we weren't initialized for some reason.
-  if (!TheModule)
-return;
-
-  // Make sure IR generation is happy with the module. This is released by
-  // the module provider.
-  llvm::Module *M = Gen->ReleaseModule();
-  if (!M) {
-// The module has been released by IR gen on failures, do not double
-// free.
-TheModule.release();
+  if (!getModule())
 return;
-  }
-
-  assert(TheModule.get() == M &&
- "Unexpected module change during IR generation");
 
   // Install an inline asm handler so that diagnostics get printed through
   // our diagnostics hooks.
-  LLVMContext  = TheModule->getContext();
+  LLVMContext  = getModule()->getContext();
   LLVMContext::InlineAsmDiagHandlerTy OldHandler =
 Ctx.getInlineAsmDiagnosticHandler();
   void *OldContext = Ctx.getInlineAsmDiagnosticContext();
@@ -182,13 +169,13 @@
   for (auto  : LinkModules) {
 unsigned LinkFlags = I.first;
 CurLinkModule = I.second.get();
-if (Linker::linkModules(*M, std::move(I.second), LinkFlags))
+if (Linker::linkModules(*getModule(), std::move(I.second), LinkFlags))
  

RE: [PATCH] D16754: Bug 15785 - OpenCL errors using vector/scalar conditionals and short integer types

2016-02-01 Thread Robinson, Paul via cfe-commits
> Hi Anton,
> 
>   Okey, nevermore.
>   But what to do with a bug which needs simply be closed (NABs)?
>   I believe they also need a review/approval.
> 
> Igor

Bugs do not have such a strict process, compared to patches.
If you don't feel confident in closing the bug directly, you can ask
the person who submitted the bug if they are happy with your answer.
--paulr

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


Re: [PATCH] D16478: Always build a new TypeSourceInfo for function templates with parameters

2016-02-01 Thread Richard Smith via cfe-commits
rsmith added a comment.

This is a bug -- we intend to reuse `Stmt` nodes across the template and its 
instantiations, but we should have separate `Decl` nodes in each instantiation 
(otherwise the `Decl`'s parent will be wrong etc).



Comment at: lib/Sema/SemaTemplateInstantiate.cpp:1519-1521
@@ -1518,5 +1518,5 @@
 
   TypeLoc TL = T->getTypeLoc().IgnoreParens();
   if (!TL.getAs())
 return false;
 

This doesn't look quite right: IIRC, there can be attributes here as well as 
parens (in particular, calling convention attributes can appear in this 
position).


Comment at: lib/Sema/SemaTemplateInstantiate.cpp:1530
@@ -1528,2 +1529,3 @@
 if (!P) continue;
+AllParmsNull = false;
 

Just return true here?


http://reviews.llvm.org/D16478



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


Re: r257710 - [Sema] Suppress diags in overload resolution.

2016-02-01 Thread Hans Wennborg via cfe-commits
Thanks! r259412.

On Mon, Feb 1, 2016 at 1:32 PM, Richard Smith  wrote:
> LGTM for 3.8.
>
> On Wed, Jan 13, 2016 at 4:03 PM, Hans Wennborg  wrote:
>> Thanks! Richard, what say the code owner?
>>
>> On Wed, Jan 13, 2016 at 3:59 PM, George Burgess IV
>>  wrote:
>>> FYI: This patch should to be merged into the clang 3.8.0 branch.
>>>
>>> Thank you!
>>> George
>>>
>>> On Wed, Jan 13, 2016 at 3:36 PM, George Burgess IV via cfe-commits
>>>  wrote:

 Author: gbiv
 Date: Wed Jan 13 17:36:34 2016
 New Revision: 257710

 URL: http://llvm.org/viewvc/llvm-project?rev=257710=rev
 Log:
 [Sema] Suppress diags in overload resolution.

 We were emitting diagnostics from our shiny new C-only overload
 resolution mode. This patch attempts to silence all such diagnostics.

 This fixes PR26085.
 Differential Revision: http://reviews.llvm.org/D16159

 Added:
 cfe/trunk/test/SemaObjC/ovl-check.m
 Modified:
 cfe/trunk/include/clang/Sema/Sema.h
 cfe/trunk/lib/Sema/SemaDeclCXX.cpp
 cfe/trunk/lib/Sema/SemaExpr.cpp
 cfe/trunk/lib/Sema/SemaExprObjC.cpp
 cfe/trunk/lib/Sema/SemaOverload.cpp

 Modified: cfe/trunk/include/clang/Sema/Sema.h
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=257710=257709=257710=diff

 ==
 --- cfe/trunk/include/clang/Sema/Sema.h (original)
 +++ cfe/trunk/include/clang/Sema/Sema.h Wed Jan 13 17:36:34 2016
 @@ -2229,7 +2229,8 @@ public:
bool CheckPointerConversion(Expr *From, QualType ToType,
CastKind ,
CXXCastPath& BasePath,
 -  bool IgnoreBaseAccess);
 +  bool IgnoreBaseAccess,
 +  bool Diagnose = true);
bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType
 ToType,
   bool InOverloadResolution,
   QualType );
 @@ -5388,7 +5389,8 @@ public:
  unsigned AmbigiousBaseConvID,
  SourceLocation Loc, SourceRange
 Range,
  DeclarationName Name,
 -CXXCastPath *BasePath);
 +CXXCastPath *BasePath,
 +bool IgnoreAccess = false);

std::string getAmbiguousPathsDisplayString(CXXBasePaths );

 @@ -7514,14 +7516,15 @@ public:
  ObjCMethodDecl *,
  ObjCMethodDecl *,
  TypedefNameDecl *,
 -bool CfToNs);
 -
 +bool CfToNs, bool Diagnose =
 true);
 +
bool CheckObjCBridgeRelatedConversions(SourceLocation Loc,
   QualType DestType, QualType
 SrcType,
 - Expr *);
 -
 -  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr
 *);
 -
 + Expr *, bool Diagnose =
 true);
 +
 +  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr
 *,
 +  bool Diagnose = true);
 +
bool checkInitMethod(ObjCMethodDecl *method, QualType
 receiverTypeIfCall);

/// \brief Check whether the given new method is a valid override of
 the
 @@ -8613,6 +8616,7 @@ public:
ARCConversionResult CheckObjCARCConversion(SourceRange castRange,
   QualType castType, Expr
 *,
   CheckedConversionKind CCK,
 + bool Diagnose = true,
   bool DiagnoseCFAudited =
 false,
   BinaryOperatorKind Opc =
 BO_PtrMemD
   );

 Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=257710=257709=257710=diff

 ==
 --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
 +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Jan 13 17:36:34 2016
 @@ -1742,13 +1742,18 @@ void Sema::BuildBasePathArray(const CXXB
  /// otherwise. Loc is the 

Re: r257831 - Refactor template type diffing

2016-02-01 Thread Richard Smith via cfe-commits
On Thu, Jan 14, 2016 at 2:57 PM, Richard Trieu via cfe-commits
 wrote:
> Author: rtrieu
> Date: Thu Jan 14 16:56:39 2016
> New Revision: 257831
>
> URL: http://llvm.org/viewvc/llvm-project?rev=257831=rev
> Log:
> Refactor template type diffing
>
> 1) Instead of using pairs of From/To* fields, combine fields into a struct
> TemplateArgInfo and have two in each DiffNode.
> 2) Use default initialization in DiffNode so that the constructor shows the
> only field that is initialized differently on construction.
> 3) Use Set and Get functions per each DiffKind to make sure all fields for the
> diff is set.  In one case, the Expr fields were not set.
> 4) Don't print boolean literals for boolean template arguments.  This prevents
> printing 'false aka 0'
>
> Only #3 has a functional change, which is reflected in the test change.
>
> Modified:
> cfe/trunk/lib/AST/ASTDiagnostic.cpp
> cfe/trunk/test/Misc/diag-template-diffing.cpp
>
> Modified: cfe/trunk/lib/AST/ASTDiagnostic.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDiagnostic.cpp?rev=257831=257830=257831=diff
> ==
> --- cfe/trunk/lib/AST/ASTDiagnostic.cpp (original)
> +++ cfe/trunk/lib/AST/ASTDiagnostic.cpp Thu Jan 14 16:56:39 2016
> @@ -491,82 +491,67 @@ class TemplateDiff {
>/// DiffTree - A tree representation the differences between two types.
>class DiffTree {
>public:
> -/// DiffKind - The difference in a DiffNode and which fields are used.
> +/// DiffKind - The difference in a DiffNode.  Fields of
> +/// TemplateArgumentInfo needed by each difference can be found in the
> +/// Set* and Get* functions.
>  enum DiffKind {
>/// Incomplete or invalid node.
>Invalid,
> -  /// Another level of templates, uses TemplateDecl and Qualifiers
> +  /// Another level of templates, requires that

... requires that what?

>Template,
> -  /// Type difference, uses QualType
> +  /// Type difference, all type differences except those falling under
> +  /// the Template difference.
>Type,
> -  /// Expression difference, uses Expr
> +  /// Expression difference, this is only when both arguments are
> +  /// expressions.  If one argument is an expression and the other is
> +  /// Integer or Declaration, then use that diff type instead.
>Expression,
> -  /// Template argument difference, uses TemplateDecl
> +  /// Template argument difference
>TemplateTemplate,
> -  /// Integer difference, uses APSInt and Expr
> +  /// Integer difference
>Integer,
> -  /// Declaration difference, uses ValueDecl
> +  /// Declaration difference, nullptr arguments are included here
>Declaration
>  };
> +
>private:
> +/// TemplateArgumentInfo - All the information needed to pretty print
> +/// a template argument.  See the Set* and Get* functions to see which
> +/// fields are used for each DiffKind.
> +struct TemplateArgumentInfo {
> +  QualType ArgType;
> +  Qualifiers Qual;
> +  llvm::APSInt Val;
> +  bool IsValidInt = false;
> +  Expr *ArgExpr = nullptr;
> +  TemplateDecl *TD = nullptr;
> +  ValueDecl *VD = nullptr;
> +  bool NeedAddressOf = false;
> +  bool IsNullPtr = false;
> +  bool IsDefault = false;
> +};
> +
>  /// DiffNode - The root node stores the original type.  Each child node
>  /// stores template arguments of their parents.  For templated types, the
>  /// template decl is also stored.
>  struct DiffNode {
> -  DiffKind Kind;
> +  DiffKind Kind = Invalid;
>
>/// NextNode - The index of the next sibling node or 0.
> -  unsigned NextNode;
> +  unsigned NextNode = 0;
>
>/// ChildNode - The index of the first child node or 0.
> -  unsigned ChildNode;
> +  unsigned ChildNode = 0;
>
>/// ParentNode - The index of the parent node.
> -  unsigned ParentNode;
> -
> -  /// FromType, ToType - The type arguments.
> -  QualType FromType, ToType;
> -
> -  /// FromExpr, ToExpr - The expression arguments.
> -  Expr *FromExpr, *ToExpr;
> -
> -  /// FromNullPtr, ToNullPtr - If the template argument is a nullptr
> -  bool FromNullPtr, ToNullPtr;
> -
> -  /// FromTD, ToTD - The template decl for template template
> -  /// arguments or the type arguments that are templates.
> -  TemplateDecl *FromTD, *ToTD;
> -
> -  /// FromQual, ToQual - Qualifiers for template types.
> -  Qualifiers FromQual, ToQual;
> -
> -  /// FromInt, ToInt - APSInt's for integral arguments.
> -  llvm::APSInt FromInt, ToInt;
> -
> -  /// IsValidFromInt, IsValidToInt - Whether the APSInt's are valid.
> -  bool IsValidFromInt, IsValidToInt;
> +  unsigned ParentNode = 0;
>
> -  /// FromValueDecl, ToValueDecl - Whether the argument is a decl.

Re: r258396 - Fix crash for typedefs for arrays of runtime bounds in Lambdas/Captured Statements, used in sizeof() expression only.

2016-02-01 Thread Richard Smith via cfe-commits
LGTM for 3.8.

On Thu, Jan 21, 2016 at 1:10 PM, Hans Wennborg  wrote:
> Richard, it was suggested (in
> https://llvm.org/bugs/show_bug.cgi?id=26059#c7) that this gets merged
> to 3.8. I believe this falls under your ownership.
>
> On Thu, Jan 21, 2016 at 4:54 AM, Alexey Bataev via cfe-commits
>  wrote:
>> Author: abataev
>> Date: Thu Jan 21 06:54:48 2016
>> New Revision: 258396
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=258396=rev
>> Log:
>> Fix crash for typedefs for arrays of runtime bounds in Lambdas/Captured 
>> Statements, used in sizeof() expression only.
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaExpr.cpp
>> cfe/trunk/test/CodeGenCXX/lambda-expressions.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers

2016-02-01 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.h:21-22
@@ -20,71 +20,4 @@
 /// them to use the appropriate boolean expression directly.
 ///
-/// Examples:
-///
-/// ===  
-/// Initial expression   Result
-/// ---  
-/// `if (b == true)` `if (b)`
-/// `if (b == false)``if (!b)`
-/// `if (b && true)` `if (b)`
-/// `if (b && false)``if (false)`
-/// `if (b || true)` `if (true)`
-/// `if (b || false)``if (b)`
-/// `e ? true : false`   `e`
-/// `e ? false : true`   `!e`
-/// `if (true) t(); else f();`   `t();`
-/// `if (false) t(); else f();`  `f();`
-/// `if (e) return true; else return false;` `return e;`
-/// `if (e) return false; else return true;` `return !e;`
-/// `if (e) b = true; else b = false;`   `b = e;`
-/// `if (e) b = false; else b = true;`   `b = !e;`
-/// `if (e) return true; return false;`  `return e;`
-/// `if (e) return false; return true;`  `return !e;`
-/// ===  
-///
-/// The resulting expression `e` is modified as follows:
-///   1. Unnecessary parentheses around the expression are removed.
-///   2. Negated applications of `!` are eliminated.
-///   3. Negated applications of comparison operators are changed to use the
-///  opposite condition.
-///   4. Implicit conversions of pointer to `bool` are replaced with explicit
-///  comparisons to `nullptr`.
-///   5. Implicit casts to `bool` are replaced with explicit casts to `bool`.
-///   6. Object expressions with `explicit operator bool` conversion operators
-///  are replaced with explicit casts to `bool`.
-///
-/// Examples:
-///   1. The ternary assignment `bool b = (i < 0) ? true : false;` has 
redundant
-///  parentheses and becomes `bool b = i < 0;`.
-///
-///   2. The conditional return `if (!b) return false; return true;` has an
-///  implied double negation and becomes `return b;`.
-///
-///   3. The conditional return `if (i < 0) return false; return true;` becomes
-///  `return i >= 0;`.
-///
-///  The conditional return `if (i != 0) return false; return true;` 
becomes
-///  `return i == 0;`.
-///
-///   4. The conditional return `if (p) return true; return false;` has an
-///  implicit conversion of a pointer to `bool` and becomes
-///  `return p != nullptr;`.
-///
-///  The ternary assignment `bool b = (i & 1) ? true : false;` has an
-///  implicit conversion of `i & 1` to `bool` and becomes
-///  `bool b = static_cast(i & 1);`.
-///
-///   5. The conditional return `if (i & 1) return true; else return false;` 
has
-///  an implicit conversion of an integer quantity `i & 1` to `bool` and
-///  becomes `return static_cast(i & 1);`
-///
-///   6. Given `struct X { explicit operator bool(); };`, and an instance `x` 
of
-///  `struct X`, the conditional return `if (x) return true; return false;`
-///  becomes `return static_cast(x);`
-///
-/// When a conditional boolean return or assignment appears at the end of a
-/// chain of `if`, `else if` statements, the conditional statement is left
-/// unchanged unless the option `ChainedConditionalReturn` or
-/// `ChainedConditionalAssignment`, respectively, is specified as non-zero.
-/// The default value for both options is zero.
-///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/readability-simplify-boolean-expr.html

LegalizeAdulthood wrote:
> aaron.ballman wrote:
> > LegalizeAdulthood wrote:
> > > aaron.ballman wrote:
> > > > I think I can agree with that, but I also think it depends a lot on 
> > > > what the purpose to the check is. If it's "improve readability 
> > > > regarding parens" + options that control when to remove or add, that 
> > > > makes sense to me. Otherwise, I think segregating the checks into one 
> > > > that removes (plus options) and one that adds (plus options) makes 
> > > > sense -- even if they perhaps use the same underlying heuristic engine 
> > > > and are simply surfaced as separate checks.
> > > This check isn't at all about the readability of parens, so it doesn't 
> > > make sense for this check to be concerned with it IMO.
> > Agreed; trying to suss out what the appropriate design for this particular 
> > check is. I think I've talked myself into "don't touch parens here."
> Currently in this patch, parens are added when the expression compared to 
> `nullptr` or `0` is a binary operator.
> 
> I think that is the right thing to do here so we get:
> 
> ```
> bool b = (i & 1) 

[clang-tools-extra] r259424 - Fix build problem by lower SmallSet to a reasonable value

2016-02-01 Thread Matthias Braun via cfe-commits
Author: matze
Date: Mon Feb  1 16:18:58 2016
New Revision: 259424

URL: http://llvm.org/viewvc/llvm-project?rev=259424=rev
Log:
Fix build problem by lower SmallSet to a reasonable value

Modified:
clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp

Modified: clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp?rev=259424=259423=259424=diff
==
--- clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp (original)
+++ clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp Mon Feb  1 
16:18:58 2016
@@ -1276,7 +1276,7 @@ private:
   std::vector HeaderStack;
   std::vector InclusionPaths;
   InclusionPathHandle CurrentInclusionPathHandle;
-  llvm::SmallSet HeadersInThisCompile;
+  llvm::SmallSet HeadersInThisCompile;
   std::vector IncludeDirectives;
   MacroExpansionMap MacroExpansions;
   ConditionalExpansionMap ConditionalExpansions;


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


r259428 - Always build a new TypeSourceInfo for function templates with parameters

2016-02-01 Thread Nico Weber via cfe-commits
Author: nico
Date: Mon Feb  1 16:31:51 2016
New Revision: 259428

URL: http://llvm.org/viewvc/llvm-project?rev=259428=rev
Log:
Always build a new TypeSourceInfo for function templates with parameters

RecursiveASTVisitor::TraverseFunctionHelper() traverses a function's
ParmVarDecls by going to the function's getTypeSourceInfo if it exists, and
`DEF_TRAVERSE_TYPELOC(FunctionProtoType` then goes to the function's
ParmVarDecls.

For a function template that doesn't have parameters that explicitly depend on
the template parameter, we used to be clever and not build a new
TypeSourceInfo. That meant that when an instantiation of such a template is
visited, its TypeSourceInfo would point to the ParmVarDecls of the template,
not of the instantiation, which then confused clients of RecursiveASTVisitor.

So don't be clever for function templates that have parameters, even if none of
the parameters depend on the type.

Fixes PR26257.
http://reviews.llvm.org/D16478

Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=259428=259427=259428=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Mon Feb  1 16:31:51 2016
@@ -1512,7 +1512,7 @@ QualType Sema::SubstType(QualType T,
 }
 
 static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T) {
-  if (T->getType()->isInstantiationDependentType() || 
+  if (T->getType()->isInstantiationDependentType() ||
   T->getType()->isVariablyModifiedType())
 return true;
 
@@ -1521,23 +1521,13 @@ static bool NeedsInstantiationAsFunction
 return false;
 
   FunctionProtoTypeLoc FP = TL.castAs();
-  for (unsigned I = 0, E = FP.getNumParams(); I != E; ++I) {
-ParmVarDecl *P = FP.getParam(I);
-
+  for (ParmVarDecl *P : FP.getParams()) {
 // This must be synthesized from a typedef.
 if (!P) continue;
 
-// The parameter's type as written might be dependent even if the
-// decayed type was not dependent.
-if (TypeSourceInfo *TSInfo = P->getTypeSourceInfo())
-  if (TSInfo->getType()->isInstantiationDependentType())
-return true;
-
-// TODO: currently we always rebuild expressions.  When we
-// properly get lazier about this, we should use the same
-// logic to avoid rebuilding prototypes here.
-if (P->hasDefaultArg())
-  return true;
+// If there are any parameters, a new TypeSourceInfo that refers to the
+// instantiated parameters must be built.
+return true;
   }
 
   return false;
@@ -1556,7 +1546,7 @@ TypeSourceInfo *Sema::SubstFunctionDeclT
   assert(!ActiveTemplateInstantiations.empty() &&
  "Cannot perform an instantiation without some context on the "
  "instantiation stack");
-  
+
   if (!NeedsInstantiationAsFunctionType(T))
 return T;
 

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=259428=259427=259428=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Mon Feb  1 16:31:51 2016
@@ -4276,6 +4276,17 @@ TEST(HasAncestor, AnonymousUnionMemberEx
   declRefExpr(to(decl(hasAncestor(decl()));
 }
 
+TEST(HasAncestor, NonParmDependentTemplateParmVarDeclRefExpr) {
+  EXPECT_TRUE(matches("struct PartitionAllocator {\n"
+  "  template\n"
+  "  static int quantizedSize(int count) {\n"
+  "return count;\n"
+  "  }\n"
+  "  void f() { quantizedSize(10); }\n"
+  "};",
+  declRefExpr(to(decl(hasAncestor(decl()));
+}
+
 TEST(HasParent, MatchesAllParents) {
   EXPECT_TRUE(matches(
   "template  struct C { static void f() { 42; } };"


___
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

2016-02-01 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


Re: [PATCH] D16478: Always build a new TypeSourceInfo for function templates with parameters

2016-02-01 Thread Nico Weber via cfe-commits
thakis updated this revision to Diff 46577.
thakis added a comment.

just return true


http://reviews.llvm.org/D16478

Files:
  lib/Sema/SemaTemplateInstantiate.cpp

Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -1512,7 +1512,7 @@
 }
 
 static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T) {
-  if (T->getType()->isInstantiationDependentType() || 
+  if (T->getType()->isInstantiationDependentType() ||
   T->getType()->isVariablyModifiedType())
 return true;
 
@@ -1522,22 +1522,12 @@
 
   FunctionProtoTypeLoc FP = TL.castAs();
   for (unsigned I = 0, E = FP.getNumParams(); I != E; ++I) {
-ParmVarDecl *P = FP.getParam(I);
-
 // This must be synthesized from a typedef.
-if (!P) continue;
-
-// The parameter's type as written might be dependent even if the
-// decayed type was not dependent.
-if (TypeSourceInfo *TSInfo = P->getTypeSourceInfo())
-  if (TSInfo->getType()->isInstantiationDependentType())
-return true;
+if (!FP.getParam(I)) continue;
 
-// TODO: currently we always rebuild expressions.  When we
-// properly get lazier about this, we should use the same
-// logic to avoid rebuilding prototypes here.
-if (P->hasDefaultArg())
-  return true;
+// If there are any parameters, a new TypeSourceInfo that refers to the
+// instantiated parameters must be built.
+return true;
   }
 
   return false;
@@ -1556,7 +1546,7 @@
   assert(!ActiveTemplateInstantiations.empty() &&
  "Cannot perform an instantiation without some context on the "
  "instantiation stack");
-  
+
   if (!NeedsInstantiationAsFunctionType(T))
 return T;
 


Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -1512,7 +1512,7 @@
 }
 
 static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T) {
-  if (T->getType()->isInstantiationDependentType() || 
+  if (T->getType()->isInstantiationDependentType() ||
   T->getType()->isVariablyModifiedType())
 return true;
 
@@ -1522,22 +1522,12 @@
 
   FunctionProtoTypeLoc FP = TL.castAs();
   for (unsigned I = 0, E = FP.getNumParams(); I != E; ++I) {
-ParmVarDecl *P = FP.getParam(I);
-
 // This must be synthesized from a typedef.
-if (!P) continue;
-
-// The parameter's type as written might be dependent even if the
-// decayed type was not dependent.
-if (TypeSourceInfo *TSInfo = P->getTypeSourceInfo())
-  if (TSInfo->getType()->isInstantiationDependentType())
-return true;
+if (!FP.getParam(I)) continue;
 
-// TODO: currently we always rebuild expressions.  When we
-// properly get lazier about this, we should use the same
-// logic to avoid rebuilding prototypes here.
-if (P->hasDefaultArg())
-  return true;
+// If there are any parameters, a new TypeSourceInfo that refers to the
+// instantiated parameters must be built.
+return true;
   }
 
   return false;
@@ -1556,7 +1546,7 @@
   assert(!ActiveTemplateInstantiations.empty() &&
  "Cannot perform an instantiation without some context on the "
  "instantiation stack");
-  
+
   if (!NeedsInstantiationAsFunctionType(T))
 return T;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16478: Always build a new TypeSourceInfo for function templates with parameters

2016-02-01 Thread Nico Weber via cfe-commits
thakis updated this revision to Diff 46578.
thakis added a comment.

restore accidentally dropped test


http://reviews.llvm.org/D16478

Files:
  lib/Sema/SemaTemplateInstantiate.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -4276,6 +4276,17 @@
   declRefExpr(to(decl(hasAncestor(decl()));
 }
 
+TEST(HasAncestor, NonParmDependentTemplateParmVarDeclRefExpr) {
+  EXPECT_TRUE(matches("struct PartitionAllocator {\n"
+  "  template\n"
+  "  static int quantizedSize(int count) {\n"
+  "return count;\n"
+  "  }\n"
+  "  void f() { quantizedSize(10); }\n"
+  "};",
+  declRefExpr(to(decl(hasAncestor(decl()));
+}
+
 TEST(HasParent, MatchesAllParents) {
   EXPECT_TRUE(matches(
   "template  struct C { static void f() { 42; } };"
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -1512,7 +1512,7 @@
 }
 
 static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T) {
-  if (T->getType()->isInstantiationDependentType() || 
+  if (T->getType()->isInstantiationDependentType() ||
   T->getType()->isVariablyModifiedType())
 return true;
 
@@ -1522,22 +1522,12 @@
 
   FunctionProtoTypeLoc FP = TL.castAs();
   for (unsigned I = 0, E = FP.getNumParams(); I != E; ++I) {
-ParmVarDecl *P = FP.getParam(I);
-
 // This must be synthesized from a typedef.
-if (!P) continue;
-
-// The parameter's type as written might be dependent even if the
-// decayed type was not dependent.
-if (TypeSourceInfo *TSInfo = P->getTypeSourceInfo())
-  if (TSInfo->getType()->isInstantiationDependentType())
-return true;
+if (!FP.getParam(I)) continue;
 
-// TODO: currently we always rebuild expressions.  When we
-// properly get lazier about this, we should use the same
-// logic to avoid rebuilding prototypes here.
-if (P->hasDefaultArg())
-  return true;
+// If there are any parameters, a new TypeSourceInfo that refers to the
+// instantiated parameters must be built.
+return true;
   }
 
   return false;
@@ -1556,7 +1546,7 @@
   assert(!ActiveTemplateInstantiations.empty() &&
  "Cannot perform an instantiation without some context on the "
  "instantiation stack");
-  
+
   if (!NeedsInstantiationAsFunctionType(T))
 return T;
 


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -4276,6 +4276,17 @@
   declRefExpr(to(decl(hasAncestor(decl()));
 }
 
+TEST(HasAncestor, NonParmDependentTemplateParmVarDeclRefExpr) {
+  EXPECT_TRUE(matches("struct PartitionAllocator {\n"
+  "  template\n"
+  "  static int quantizedSize(int count) {\n"
+  "return count;\n"
+  "  }\n"
+  "  void f() { quantizedSize(10); }\n"
+  "};",
+  declRefExpr(to(decl(hasAncestor(decl()));
+}
+
 TEST(HasParent, MatchesAllParents) {
   EXPECT_TRUE(matches(
   "template  struct C { static void f() { 42; } };"
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -1512,7 +1512,7 @@
 }
 
 static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T) {
-  if (T->getType()->isInstantiationDependentType() || 
+  if (T->getType()->isInstantiationDependentType() ||
   T->getType()->isVariablyModifiedType())
 return true;
 
@@ -1522,22 +1522,12 @@
 
   FunctionProtoTypeLoc FP = TL.castAs();
   for (unsigned I = 0, E = FP.getNumParams(); I != E; ++I) {
-ParmVarDecl *P = FP.getParam(I);
-
 // This must be synthesized from a typedef.
-if (!P) continue;
-
-// The parameter's type as written might be dependent even if the
-// decayed type was not dependent.
-if (TypeSourceInfo *TSInfo = P->getTypeSourceInfo())
-  if (TSInfo->getType()->isInstantiationDependentType())
-return true;
+if (!FP.getParam(I)) continue;
 
-// TODO: currently we always rebuild expressions.  When we
-// properly get lazier about this, we should use the same
-// logic to avoid rebuilding prototypes here.
-if (P->hasDefaultArg())
-  return true;
+// If there are any parameters, a new TypeSourceInfo that refers to the
+// instantiated parameters must be 

Re: [PATCH] D16478: Always build a new TypeSourceInfo for function templates with parameters

2016-02-01 Thread Nico Weber via cfe-commits
thakis marked an inline comment as done.


Comment at: lib/Sema/SemaTemplateInstantiate.cpp:1519-1521
@@ -1518,5 +1518,5 @@
 
   TypeLoc TL = T->getTypeLoc().IgnoreParens();
   if (!TL.getAs())
 return false;
 

Ack.


http://reviews.llvm.org/D16478



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


Re: [PATCH] D16478: Always build a new TypeSourceInfo for function templates with parameters

2016-02-01 Thread Nico Weber via cfe-commits
thakis closed this revision.
thakis added a comment.

r259428, thanks! Went with the for-each loop but left the structure as-is -- I 
find the comments helpful and it's not clear where they should go else.


http://reviews.llvm.org/D16478



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


Re: [PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers

2016-02-01 Thread Richard via cfe-commits
LegalizeAdulthood added inline comments.


Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.h:21-22
@@ -20,71 +20,4 @@
 /// them to use the appropriate boolean expression directly.
 ///
-/// Examples:
-///
-/// ===  
-/// Initial expression   Result
-/// ---  
-/// `if (b == true)` `if (b)`
-/// `if (b == false)``if (!b)`
-/// `if (b && true)` `if (b)`
-/// `if (b && false)``if (false)`
-/// `if (b || true)` `if (true)`
-/// `if (b || false)``if (b)`
-/// `e ? true : false`   `e`
-/// `e ? false : true`   `!e`
-/// `if (true) t(); else f();`   `t();`
-/// `if (false) t(); else f();`  `f();`
-/// `if (e) return true; else return false;` `return e;`
-/// `if (e) return false; else return true;` `return !e;`
-/// `if (e) b = true; else b = false;`   `b = e;`
-/// `if (e) b = false; else b = true;`   `b = !e;`
-/// `if (e) return true; return false;`  `return e;`
-/// `if (e) return false; return true;`  `return !e;`
-/// ===  
-///
-/// The resulting expression `e` is modified as follows:
-///   1. Unnecessary parentheses around the expression are removed.
-///   2. Negated applications of `!` are eliminated.
-///   3. Negated applications of comparison operators are changed to use the
-///  opposite condition.
-///   4. Implicit conversions of pointer to `bool` are replaced with explicit
-///  comparisons to `nullptr`.
-///   5. Implicit casts to `bool` are replaced with explicit casts to `bool`.
-///   6. Object expressions with `explicit operator bool` conversion operators
-///  are replaced with explicit casts to `bool`.
-///
-/// Examples:
-///   1. The ternary assignment `bool b = (i < 0) ? true : false;` has 
redundant
-///  parentheses and becomes `bool b = i < 0;`.
-///
-///   2. The conditional return `if (!b) return false; return true;` has an
-///  implied double negation and becomes `return b;`.
-///
-///   3. The conditional return `if (i < 0) return false; return true;` becomes
-///  `return i >= 0;`.
-///
-///  The conditional return `if (i != 0) return false; return true;` 
becomes
-///  `return i == 0;`.
-///
-///   4. The conditional return `if (p) return true; return false;` has an
-///  implicit conversion of a pointer to `bool` and becomes
-///  `return p != nullptr;`.
-///
-///  The ternary assignment `bool b = (i & 1) ? true : false;` has an
-///  implicit conversion of `i & 1` to `bool` and becomes
-///  `bool b = static_cast(i & 1);`.
-///
-///   5. The conditional return `if (i & 1) return true; else return false;` 
has
-///  an implicit conversion of an integer quantity `i & 1` to `bool` and
-///  becomes `return static_cast(i & 1);`
-///
-///   6. Given `struct X { explicit operator bool(); };`, and an instance `x` 
of
-///  `struct X`, the conditional return `if (x) return true; return false;`
-///  becomes `return static_cast(x);`
-///
-/// When a conditional boolean return or assignment appears at the end of a
-/// chain of `if`, `else if` statements, the conditional statement is left
-/// unchanged unless the option `ChainedConditionalReturn` or
-/// `ChainedConditionalAssignment`, respectively, is specified as non-zero.
-/// The default value for both options is zero.
-///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/readability-simplify-boolean-expr.html

aaron.ballman wrote:
> LegalizeAdulthood wrote:
> > aaron.ballman wrote:
> > > LegalizeAdulthood wrote:
> > > > aaron.ballman wrote:
> > > > > I think I can agree with that, but I also think it depends a lot on 
> > > > > what the purpose to the check is. If it's "improve readability 
> > > > > regarding parens" + options that control when to remove or add, that 
> > > > > makes sense to me. Otherwise, I think segregating the checks into one 
> > > > > that removes (plus options) and one that adds (plus options) makes 
> > > > > sense -- even if they perhaps use the same underlying heuristic 
> > > > > engine and are simply surfaced as separate checks.
> > > > This check isn't at all about the readability of parens, so it doesn't 
> > > > make sense for this check to be concerned with it IMO.
> > > Agreed; trying to suss out what the appropriate design for this 
> > > particular check is. I think I've talked myself into "don't touch parens 
> > > here."
> > Currently in this patch, parens are added when the expression compared to 
> > `nullptr` or `0` is a binary operator.
> > 
> > I think 

Re: [PATCH] D16478: Always build a new TypeSourceInfo for function templates with parameters

2016-02-01 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM



Comment at: lib/Sema/SemaTemplateInstantiate.cpp:1525-1530
@@ -1524,18 +1524,8 @@
   for (unsigned I = 0, E = FP.getNumParams(); I != E; ++I) {
-ParmVarDecl *P = FP.getParam(I);
-
 // This must be synthesized from a typedef.
-if (!P) continue;
-
-// The parameter's type as written might be dependent even if the
-// decayed type was not dependent.
-if (TypeSourceInfo *TSInfo = P->getTypeSourceInfo())
-  if (TSInfo->getType()->isInstantiationDependentType())
-return true;
+if (!FP.getParam(I)) continue;
 
-// TODO: currently we always rebuild expressions.  When we
-// properly get lazier about this, we should use the same
-// logic to avoid rebuilding prototypes here.
-if (P->hasDefaultArg())
-  return true;
+// If there are any parameters, a new TypeSourceInfo that refers to the
+// instantiated parameters must be built.
+return true;
   }

Maybe replace the whole loop with

  for (ParmVarDecl *D : FP.getParmArray())
if (D)
  return true;

(or an STL algorithm for same)?


http://reviews.llvm.org/D16478



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


Re: r259271 - Improve -Wconstant-conversion

2016-02-01 Thread Richard Trieu via cfe-commits
C++11 narrowing only happens during certain conversions while this warning
checks all conversions.

We might be able to avoid char array initialization, but it would be a
little tricky.  These warning usually have little information about where
the conversion is coming from, so distinguishing array initialization
versus variable initialization could be hard.

On Sat, Jan 30, 2016 at 6:41 AM, Nico Weber  wrote:

> Shouldn't the new case be in -Wc++11-narrowing instead? This is warning in
> similar places where that warning used to warn.
>
> In practice, char arrays seem to be often used for storing binary blobs in
> header files, and those are usually initialized with numbers 0...255
> instead of -128...127 (why not make the array uint8_t then? Because maybe
> the function you want to pass the data from wants a char* array, and having
> to reinterpret_cast from uint8_t to char is annoying). Maybe this shouldn't
> fire for char arrays?
>
> On Fri, Jan 29, 2016 at 6:51 PM, Richard Trieu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rtrieu
>> Date: Fri Jan 29 17:51:16 2016
>> New Revision: 259271
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=259271=rev
>> Log:
>> Improve -Wconstant-conversion
>>
>> Switch the evaluation from isIntegerConstantExpr to EvaluateAsInt.
>> EvaluateAsInt will evaluate more types of expressions than
>> isIntegerConstantExpr.
>>
>> Move one case from -Wsign-conversion to -Wconstant-conversion.  The case
>> is:
>> 1) Source and target types are signed
>> 2) Source type is wider than the target type
>> 3) The source constant value is positive
>> 4) The conversion will store the value as negative in the target.
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaChecking.cpp
>> cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp
>> cfe/trunk/test/Sema/constant-conversion.c
>>
>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=259271=259270=259271=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Jan 29 17:51:16 2016
>> @@ -7578,7 +7578,7 @@ void CheckImplicitConversion(Sema , Ex
>>  // If the source is a constant, use a default-on diagnostic.
>>  // TODO: this should happen for bitfield stores, too.
>>  llvm::APSInt Value(32);
>> -if (E->isIntegerConstantExpr(Value, S.Context)) {
>> +if (E->EvaluateAsInt(Value, S.Context, Expr::SE_AllowSideEffects)) {
>>if (S.SourceMgr.isInSystemMacro(CC))
>>  return;
>>
>> @@ -7603,6 +7603,42 @@ void CheckImplicitConversion(Sema , Ex
>>  return DiagnoseImpCast(S, E, T, CC,
>> diag::warn_impcast_integer_precision);
>>}
>>
>> +  if (TargetRange.Width == SourceRange.Width && !TargetRange.NonNegative
>> &&
>> +  SourceRange.NonNegative && Source->isSignedIntegerType()) {
>> +// Warn when doing a signed to signed conversion, warn if the
>> positive
>> +// source value is exactly the width of the target type, which will
>> +// cause a negative value to be stored.
>> +
>> +llvm::APSInt Value;
>> +if (E->EvaluateAsInt(Value, S.Context, Expr::SE_AllowSideEffects)) {
>> +  if (!S.SourceMgr.isInSystemMacro(CC)) {
>> +
>> +IntegerLiteral *IntLit =
>> +dyn_cast(E->IgnoreParenImpCasts());
>> +
>> +// If initializing from a constant, and the constant starts with
>> '0',
>> +// then it is a binary, octal, or hexadecimal.  Allow these
>> constants
>> +// to fill all the bits, even if there is a sign change.
>> +if (!IntLit ||
>> +
>> *(S.getSourceManager().getCharacterData(IntLit->getLocStart())) !=
>> +'0') {
>> +
>> +  std::string PrettySourceValue = Value.toString(10);
>> +  std::string PrettyTargetValue =
>> +  PrettyPrintInRange(Value, TargetRange);
>> +
>> +  S.DiagRuntimeBehavior(
>> +  E->getExprLoc(), E,
>> +  S.PDiag(diag::warn_impcast_integer_precision_constant)
>> +  << PrettySourceValue << PrettyTargetValue <<
>> E->getType() << T
>> +  << E->getSourceRange() << clang::SourceRange(CC));
>> +  return;
>> +}
>> +  }
>> +}
>> +// Fall through for non-constants to give a sign conversion warning.
>> +  }
>> +
>>if ((TargetRange.NonNegative && !SourceRange.NonNegative) ||
>>(!TargetRange.NonNegative && SourceRange.NonNegative &&
>> SourceRange.Width == TargetRange.Width)) {
>>
>> Modified: cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp?rev=259271=259270=259271=diff
>>
>> ==
>> --- cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp (original)
>> +++ 

Re: [PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers

2016-02-01 Thread Richard via cfe-commits
LegalizeAdulthood added inline comments.


Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.h:21-22
@@ -20,71 +20,4 @@
 /// them to use the appropriate boolean expression directly.
 ///
-/// Examples:
-///
-/// ===  
-/// Initial expression   Result
-/// ---  
-/// `if (b == true)` `if (b)`
-/// `if (b == false)``if (!b)`
-/// `if (b && true)` `if (b)`
-/// `if (b && false)``if (false)`
-/// `if (b || true)` `if (true)`
-/// `if (b || false)``if (b)`
-/// `e ? true : false`   `e`
-/// `e ? false : true`   `!e`
-/// `if (true) t(); else f();`   `t();`
-/// `if (false) t(); else f();`  `f();`
-/// `if (e) return true; else return false;` `return e;`
-/// `if (e) return false; else return true;` `return !e;`
-/// `if (e) b = true; else b = false;`   `b = e;`
-/// `if (e) b = false; else b = true;`   `b = !e;`
-/// `if (e) return true; return false;`  `return e;`
-/// `if (e) return false; return true;`  `return !e;`
-/// ===  
-///
-/// The resulting expression `e` is modified as follows:
-///   1. Unnecessary parentheses around the expression are removed.
-///   2. Negated applications of `!` are eliminated.
-///   3. Negated applications of comparison operators are changed to use the
-///  opposite condition.
-///   4. Implicit conversions of pointer to `bool` are replaced with explicit
-///  comparisons to `nullptr`.
-///   5. Implicit casts to `bool` are replaced with explicit casts to `bool`.
-///   6. Object expressions with `explicit operator bool` conversion operators
-///  are replaced with explicit casts to `bool`.
-///
-/// Examples:
-///   1. The ternary assignment `bool b = (i < 0) ? true : false;` has 
redundant
-///  parentheses and becomes `bool b = i < 0;`.
-///
-///   2. The conditional return `if (!b) return false; return true;` has an
-///  implied double negation and becomes `return b;`.
-///
-///   3. The conditional return `if (i < 0) return false; return true;` becomes
-///  `return i >= 0;`.
-///
-///  The conditional return `if (i != 0) return false; return true;` 
becomes
-///  `return i == 0;`.
-///
-///   4. The conditional return `if (p) return true; return false;` has an
-///  implicit conversion of a pointer to `bool` and becomes
-///  `return p != nullptr;`.
-///
-///  The ternary assignment `bool b = (i & 1) ? true : false;` has an
-///  implicit conversion of `i & 1` to `bool` and becomes
-///  `bool b = static_cast(i & 1);`.
-///
-///   5. The conditional return `if (i & 1) return true; else return false;` 
has
-///  an implicit conversion of an integer quantity `i & 1` to `bool` and
-///  becomes `return static_cast(i & 1);`
-///
-///   6. Given `struct X { explicit operator bool(); };`, and an instance `x` 
of
-///  `struct X`, the conditional return `if (x) return true; return false;`
-///  becomes `return static_cast(x);`
-///
-/// When a conditional boolean return or assignment appears at the end of a
-/// chain of `if`, `else if` statements, the conditional statement is left
-/// unchanged unless the option `ChainedConditionalReturn` or
-/// `ChainedConditionalAssignment`, respectively, is specified as non-zero.
-/// The default value for both options is zero.
-///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/readability-simplify-boolean-expr.html

aaron.ballman wrote:
> LegalizeAdulthood wrote:
> > aaron.ballman wrote:
> > > I think I can agree with that, but I also think it depends a lot on what 
> > > the purpose to the check is. If it's "improve readability regarding 
> > > parens" + options that control when to remove or add, that makes sense to 
> > > me. Otherwise, I think segregating the checks into one that removes (plus 
> > > options) and one that adds (plus options) makes sense -- even if they 
> > > perhaps use the same underlying heuristic engine and are simply surfaced 
> > > as separate checks.
> > This check isn't at all about the readability of parens, so it doesn't make 
> > sense for this check to be concerned with it IMO.
> Agreed; trying to suss out what the appropriate design for this particular 
> check is. I think I've talked myself into "don't touch parens here."
Currently in this patch, parens are added when the expression compared to 
`nullptr` or `0` is a binary operator.

I think that is the right thing to do here so we get:

```
bool b = (i & 1) == 0;
```

instead of

```
bool b = i & 1 == 0;
```




Re: r258396 - Fix crash for typedefs for arrays of runtime bounds in Lambdas/Captured Statements, used in sizeof() expression only.

2016-02-01 Thread Hans Wennborg via cfe-commits
Thanks! r259414.

On Mon, Feb 1, 2016 at 1:36 PM, Richard Smith  wrote:
> LGTM for 3.8.
>
> On Thu, Jan 21, 2016 at 1:10 PM, Hans Wennborg  wrote:
>> Richard, it was suggested (in
>> https://llvm.org/bugs/show_bug.cgi?id=26059#c7) that this gets merged
>> to 3.8. I believe this falls under your ownership.
>>
>> On Thu, Jan 21, 2016 at 4:54 AM, Alexey Bataev via cfe-commits
>>  wrote:
>>> Author: abataev
>>> Date: Thu Jan 21 06:54:48 2016
>>> New Revision: 258396
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=258396=rev
>>> Log:
>>> Fix crash for typedefs for arrays of runtime bounds in Lambdas/Captured 
>>> Statements, used in sizeof() expression only.
>>>
>>> Modified:
>>> cfe/trunk/lib/Sema/SemaExpr.cpp
>>> cfe/trunk/test/CodeGenCXX/lambda-expressions.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r258782 - Recommit: R258773 [OpenCL] Pipe builtin functions

2016-02-01 Thread Richard Smith via cfe-commits
On Mon, Jan 25, 2016 at 8:03 PM, Xiuli Pan via cfe-commits
 wrote:
> Author: pxl
> Date: Mon Jan 25 22:03:48 2016
> New Revision: 258782
>
> URL: http://llvm.org/viewvc/llvm-project?rev=258782=rev
> Log:
> Recommit: R258773 [OpenCL] Pipe builtin functions
> Fix arc patch fuzz error.
> Summary:
> Support for the pipe built-in functions for OpenCL 2.0.
> The pipe builtin functions may have infinite kinds of element types, one 
> approach
> would be to just generate calls that would always use generic types such as 
> void*.
> This patch is based on bader's opencl support patch on SPIR-V branch.
>
> Reviewers: Anastasia, pekka.jaaskelainen
>
> Subscribers: keryell, bader, cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D15914
>
> Added:
> cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl
> cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
> Modified:
> cfe/trunk/include/clang/Basic/Builtins.def
> cfe/trunk/include/clang/Basic/Builtins.h
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Basic/Builtins.cpp
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/lib/Sema/SemaChecking.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Builtins.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=258782=258781=258782=diff
> ==
> --- cfe/trunk/include/clang/Basic/Builtins.def (original)
> +++ cfe/trunk/include/clang/Basic/Builtins.def Mon Jan 25 22:03:48 2016
> @@ -1252,6 +1252,32 @@ BUILTIN(__builtin___get_unsafe_stack_ptr
>  BUILTIN(__builtin_nontemporal_store, "v.", "t")
>  BUILTIN(__builtin_nontemporal_load, "v.", "t")
>
> +// OpenCL v2.0 s6.13.16, s9.17.3.5 - Pipe functions.
> +// We need the generic prototype, since the packet type could be anything.
> +LANGBUILTIN(read_pipe, "i.", "tn", OCLC_LANG)
> +LANGBUILTIN(write_pipe, "i.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(reserve_read_pipe, "i.", "tn", OCLC_LANG)
> +LANGBUILTIN(reserve_write_pipe, "i.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(commit_write_pipe, "v.", "tn", OCLC_LANG)
> +LANGBUILTIN(commit_read_pipe, "v.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(sub_group_reserve_read_pipe, "i.", "tn", OCLC_LANG)
> +LANGBUILTIN(sub_group_reserve_write_pipe, "i.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(sub_group_commit_read_pipe, "v.", "tn", OCLC_LANG)
> +LANGBUILTIN(sub_group_commit_write_pipe, "v.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(work_group_reserve_read_pipe, "i.", "tn", OCLC_LANG)
> +LANGBUILTIN(work_group_reserve_write_pipe, "i.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(work_group_commit_read_pipe, "v.", "tn", OCLC_LANG)
> +LANGBUILTIN(work_group_commit_write_pipe, "v.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(get_pipe_num_packets, "Ui.", "tn", OCLC_LANG)
> +LANGBUILTIN(get_pipe_max_packets, "Ui.", "tn", OCLC_LANG)
> +
>  #undef BUILTIN
>  #undef LIBBUILTIN
>  #undef LANGBUILTIN
>
> Modified: cfe/trunk/include/clang/Basic/Builtins.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=258782=258781=258782=diff
> ==
> --- cfe/trunk/include/clang/Basic/Builtins.h (original)
> +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Jan 25 22:03:48 2016
> @@ -36,6 +36,7 @@ enum LanguageID {
>CXX_LANG = 0x4,  // builtin for cplusplus only.
>OBJC_LANG = 0x8, // builtin for objective-c and objective-c++
>MS_LANG = 0x10,  // builtin requires MS mode.
> +  OCLC_LANG = 0x20,// builtin for OpenCL C only.

Missing space after comma.

>ALL_LANGUAGES = C_LANG | CXX_LANG | OBJC_LANG, // builtin for all 
> languages.
>ALL_GNU_LANGUAGES = ALL_LANGUAGES | GNU_LANG,  // builtin requires GNU 
> mode.
>ALL_MS_LANGUAGES = ALL_LANGUAGES | MS_LANG // builtin requires MS mode.
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=258782=258781=258782=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Jan 25 22:03:48 
> 2016
> @@ -7680,6 +7680,16 @@ def err_atomic_init_constant : Error<
>  def err_opencl_implicit_vector_conversion : Error<
>"implicit conversions between vector types (%0 and %1) are not permitted">;
>
> +// OpenCL v2.0 s6.13.6 -- Builtin Pipe Functions
> +def err_opencl_builtin_pipe_first_arg : Error<
> +  "first argument to %0 must be a pipe type">;
> +def err_opencl_builtin_pipe_arg_num : Error<
> +"invalid number of arguments to function: %0">;

Too much indentation here.

> +def err_opencl_builtin_pipe_invalid_arg : Error<
> +  "invalid argument type to function %0 (expecting %1)">;
> +def err_opencl_builtin_pipe_invalid_access_modifier : Error<
> +  "invalid 

Re: r258782 - Recommit: R258773 [OpenCL] Pipe builtin functions

2016-02-01 Thread Richard Smith via cfe-commits
On Thu, Jan 28, 2016 at 11:25 AM, Hans Wennborg  wrote:
> I don't think we have a specific code owner for OpenCL in Clang, which
> means Richard is the owner.
>
> Richard, what do you think?

Is there a reason we want to push this new feature into 3.8 rather
than waiting for the next release?

> On Wed, Jan 27, 2016 at 10:08 PM, xiuli pan  wrote:
>> Hi hans,
>>
>> Request to merge it to release 38
>>
>> It adds Pipe BIFs to be used along with Pipe type committed earlier (in 
>> r257254).
>>
>> Thanks
>> Xiuli
>>
>> -Original Message-
>> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of 
>> Xiuli Pan via cfe-commits
>> Sent: Tuesday, January 26, 2016 12:04 PM
>> To: cfe-commits@lists.llvm.org
>> Subject: r258782 - Recommit: R258773 [OpenCL] Pipe builtin functions
>>
>> Author: pxl
>> Date: Mon Jan 25 22:03:48 2016
>> New Revision: 258782
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=258782=rev
>> Log:
>> Recommit: R258773 [OpenCL] Pipe builtin functions
>> Fix arc patch fuzz error.
>> Summary:
>> Support for the pipe built-in functions for OpenCL 2.0.
>> The pipe builtin functions may have infinite kinds of element types, one 
>> approach
>> would be to just generate calls that would always use generic types such as 
>> void*.
>> This patch is based on bader's opencl support patch on SPIR-V branch.
>>
>> Reviewers: Anastasia, pekka.jaaskelainen
>>
>> Subscribers: keryell, bader, cfe-commits
>>
>> Differential Revision: http://reviews.llvm.org/D15914
>>
>> Added:
>> cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl
>> cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
>> Modified:
>> cfe/trunk/include/clang/Basic/Builtins.def
>> cfe/trunk/include/clang/Basic/Builtins.h
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/lib/Basic/Builtins.cpp
>> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>> cfe/trunk/lib/Sema/SemaChecking.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/Builtins.def
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=258782=258781=258782=diff
>> ==
>> --- cfe/trunk/include/clang/Basic/Builtins.def (original)
>> +++ cfe/trunk/include/clang/Basic/Builtins.def Mon Jan 25 22:03:48 2016
>> @@ -1252,6 +1252,32 @@ BUILTIN(__builtin___get_unsafe_stack_ptr
>>  BUILTIN(__builtin_nontemporal_store, "v.", "t")
>>  BUILTIN(__builtin_nontemporal_load, "v.", "t")
>>
>> +// OpenCL v2.0 s6.13.16, s9.17.3.5 - Pipe functions.
>> +// We need the generic prototype, since the packet type could be anything.
>> +LANGBUILTIN(read_pipe, "i.", "tn", OCLC_LANG)
>> +LANGBUILTIN(write_pipe, "i.", "tn", OCLC_LANG)
>> +
>> +LANGBUILTIN(reserve_read_pipe, "i.", "tn", OCLC_LANG)
>> +LANGBUILTIN(reserve_write_pipe, "i.", "tn", OCLC_LANG)
>> +
>> +LANGBUILTIN(commit_write_pipe, "v.", "tn", OCLC_LANG)
>> +LANGBUILTIN(commit_read_pipe, "v.", "tn", OCLC_LANG)
>> +
>> +LANGBUILTIN(sub_group_reserve_read_pipe, "i.", "tn", OCLC_LANG)
>> +LANGBUILTIN(sub_group_reserve_write_pipe, "i.", "tn", OCLC_LANG)
>> +
>> +LANGBUILTIN(sub_group_commit_read_pipe, "v.", "tn", OCLC_LANG)
>> +LANGBUILTIN(sub_group_commit_write_pipe, "v.", "tn", OCLC_LANG)
>> +
>> +LANGBUILTIN(work_group_reserve_read_pipe, "i.", "tn", OCLC_LANG)
>> +LANGBUILTIN(work_group_reserve_write_pipe, "i.", "tn", OCLC_LANG)
>> +
>> +LANGBUILTIN(work_group_commit_read_pipe, "v.", "tn", OCLC_LANG)
>> +LANGBUILTIN(work_group_commit_write_pipe, "v.", "tn", OCLC_LANG)
>> +
>> +LANGBUILTIN(get_pipe_num_packets, "Ui.", "tn", OCLC_LANG)
>> +LANGBUILTIN(get_pipe_max_packets, "Ui.", "tn", OCLC_LANG)
>> +
>>  #undef BUILTIN
>>  #undef LIBBUILTIN
>>  #undef LANGBUILTIN
>>
>> Modified: cfe/trunk/include/clang/Basic/Builtins.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=258782=258781=258782=diff
>> ==
>> --- cfe/trunk/include/clang/Basic/Builtins.h (original)
>> +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Jan 25 22:03:48 2016
>> @@ -36,6 +36,7 @@ enum LanguageID {
>>CXX_LANG = 0x4,  // builtin for cplusplus only.
>>OBJC_LANG = 0x8, // builtin for objective-c and objective-c++
>>MS_LANG = 0x10,  // builtin requires MS mode.
>> +  OCLC_LANG = 0x20,// builtin for OpenCL C only.
>>ALL_LANGUAGES = C_LANG | CXX_LANG | OBJC_LANG, // builtin for all 
>> languages.
>>ALL_GNU_LANGUAGES = ALL_LANGUAGES | GNU_LANG,  // builtin requires GNU 
>> mode.
>>ALL_MS_LANGUAGES = ALL_LANGUAGES | MS_LANG // builtin requires MS 
>> mode.
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=258782=258781=258782=diff
>> ==
>> 

Re: r258782 - Recommit: R258773 [OpenCL] Pipe builtin functions

2016-02-01 Thread Hans Wennborg via cfe-commits
On Mon, Feb 1, 2016 at 1:53 PM, Richard Smith  wrote:
> On Thu, Jan 28, 2016 at 11:25 AM, Hans Wennborg  wrote:
>> I don't think we have a specific code owner for OpenCL in Clang, which
>> means Richard is the owner.
>>
>> Richard, what do you think?
>
> Is there a reason we want to push this new feature into 3.8 rather
> than waiting for the next release?

Not from my end. Unless it's a low-cost merge (and it doesn't seem to
be, based on your comments), it seems this should just wait for 3.9.


>> On Wed, Jan 27, 2016 at 10:08 PM, xiuli pan  wrote:
>>> Hi hans,
>>>
>>> Request to merge it to release 38
>>>
>>> It adds Pipe BIFs to be used along with Pipe type committed earlier (in 
>>> r257254).
>>>
>>> Thanks
>>> Xiuli
>>>
>>> -Original Message-
>>> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of 
>>> Xiuli Pan via cfe-commits
>>> Sent: Tuesday, January 26, 2016 12:04 PM
>>> To: cfe-commits@lists.llvm.org
>>> Subject: r258782 - Recommit: R258773 [OpenCL] Pipe builtin functions
>>>
>>> Author: pxl
>>> Date: Mon Jan 25 22:03:48 2016
>>> New Revision: 258782
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=258782=rev
>>> Log:
>>> Recommit: R258773 [OpenCL] Pipe builtin functions
>>> Fix arc patch fuzz error.
>>> Summary:
>>> Support for the pipe built-in functions for OpenCL 2.0.
>>> The pipe builtin functions may have infinite kinds of element types, one 
>>> approach
>>> would be to just generate calls that would always use generic types such as 
>>> void*.
>>> This patch is based on bader's opencl support patch on SPIR-V branch.
>>>
>>> Reviewers: Anastasia, pekka.jaaskelainen
>>>
>>> Subscribers: keryell, bader, cfe-commits
>>>
>>> Differential Revision: http://reviews.llvm.org/D15914
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r259418 - Undoing commit r259366 to debug buildbot failure.

2016-02-01 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Mon Feb  1 16:02:05 2016
New Revision: 259418

URL: http://llvm.org/viewvc/llvm-project?rev=259418=rev
Log:
Undoing commit r259366 to debug buildbot failure.
> http://reviews.llvm.org/D16758


Modified:
cfe/trunk/include/clang/Basic/OpenMPKinds.h
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/distribute_private_messages.cpp
cfe/trunk/test/OpenMP/nesting_of_regions.cpp
cfe/trunk/test/OpenMP/target_data_device_messages.cpp
cfe/trunk/test/OpenMP/target_device_messages.cpp
cfe/trunk/test/OpenMP/target_if_messages.cpp
cfe/trunk/test/OpenMP/target_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_default_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_device_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_if_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_map_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_num_threads_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_private_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_proc_bind_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_reduction_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_shared_messages.cpp
cfe/trunk/test/OpenMP/target_private_messages.cpp
cfe/trunk/test/OpenMP/teams_reduction_messages.cpp

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.h?rev=259418=259417=259418=diff
==
--- cfe/trunk/include/clang/Basic/OpenMPKinds.h (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.h Mon Feb  1 16:02:05 2016
@@ -156,20 +156,11 @@ bool isOpenMPTaskLoopDirective(OpenMPDir
 /// parallel', otherwise - false.
 bool isOpenMPParallelDirective(OpenMPDirectiveKind DKind);
 
-/// \brief Checks if the specified directive is a target code offload 
directive.
+/// \brief Checks if the specified directive is a target-kind directive.
 /// \param DKind Specified directive.
-/// \return true - the directive is a target code offload directive like
-/// 'omp target', 'omp target parallel', 'omp target xxx'
+/// \return true - the directive is a target-like directive like 'omp target',
 /// otherwise - false.
-bool isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind);
-
-/// \brief Checks if the specified directive is a target data offload 
directive.
-/// \param DKind Specified directive.
-/// \return true - the directive is a target data offload directive like
-/// 'omp target data', 'omp target update', 'omp target enter data',
-/// 'omp target exit data'
-/// otherwise - false.
-bool isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind);
+bool isOpenMPTargetDirective(OpenMPDirectiveKind DKind);
 
 /// \brief Checks if the specified directive is a teams-kind directive.
 /// \param DKind Specified directive.

Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=259418=259417=259418=diff
==
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original)
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Mon Feb  1 16:02:05 2016
@@ -576,15 +576,8 @@ bool clang::isOpenMPParallelDirective(Op
  // TODO add next directives.
 }
 
-bool clang::isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind) {
-  // TODO add next directives.
-  return DKind == OMPD_target || DKind == OMPD_target_parallel;
-}
-
-bool clang::isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind) {
-  // TODO add target update directive check.
-  return DKind == OMPD_target_data || DKind == OMPD_target_enter_data ||
- DKind == OMPD_target_exit_data;
+bool clang::isOpenMPTargetDirective(OpenMPDirectiveKind DKind) {
+  return DKind == OMPD_target; // TODO add next directives.
 }
 
 bool clang::isOpenMPTeamsDirective(OpenMPDirectiveKind DKind) {

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=259418=259417=259418=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon Feb  1 16:02:05 2016
@@ -809,7 +809,7 @@ bool Sema::IsOpenMPCapturedByRef(ValueDe
   auto DKind = DSAStack->getDirectiveForScope(RSI->TheScope);
   auto Ty = D->getType();
 
-  if (isOpenMPTargetExecutionDirective(DKind)) {
+  if (isOpenMPTargetDirective(DKind)) {
 // This table summarizes how a given variable should be passed to the 
device
 // given its type and the clauses where it appears. This table is based on
 // the description in OpenMP 4.5 [2.10.4, target Construct] and
@@ -907,7 +907,7 @@ bool 

Re: [libcxx] r258107 - Fix PR#26175. Thanks to Josh Petrie for the report and the patch. Reviewed as http://reviews.llvm.org/D16262

2016-02-01 Thread Hans Wennborg via cfe-commits
Marshall: ping?

On Tue, Jan 26, 2016 at 11:08 AM, Hans Wennborg  wrote:
> On Tue, Jan 19, 2016 at 9:21 AM, Hans Wennborg  wrote:
>> On Tue, Jan 19, 2016 at 12:01 AM, Dimitry Andric  wrote:
>>> On 19 Jan 2016, at 01:50, Marshall Clow via cfe-commits 
>>>  wrote:

 Author: marshall
 Date: Mon Jan 18 18:50:37 2016
 New Revision: 258107

 URL: http://llvm.org/viewvc/llvm-project?rev=258107=rev
 Log:
 Fix PR#26175. Thanks to Josh Petrie for the report and the patch. Reviewed 
 as http://reviews.llvm.org/D16262
>>>
>>> This looks like a good candidate for the 3.8 branch, do you agree?
>>
>> Sounds good to me if Marshall agrees.
>
> Ping?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2016-02-01 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 46588.
nwilson added a comment.

- Fix a couple of comments to reflect the Patch.
- Clang-format the changes in this Patch.


http://reviews.llvm.org/D13357

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
@@ -41,3 +41,20 @@
 void fpc(concept int i) {} // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+
+template  concept bool VCEI{ true };
+template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template  concept bool VCPS{ true };
+template  concept bool VCPS{ true }; // expected-error {{'concept' cannot be applied on an partial specialization}}
+
+template  concept bool VCES{ true };
+template <> concept bool VCES{ true }; // expected-error {{'concept' cannot be applied on an explicit specialization}}
+
+template  concept bool FCEI() { return true; }
+template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template  concept bool FCES() { return true; }
+template <> concept bool FCES() { return true; } // expected-error {{'concept' cannot be applied on an explicit specialization}}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7673,6 +7673,15 @@
 Diag(D.getDeclSpec().getConstexprSpecLoc(),
  diag::err_explicit_instantiation_constexpr);
 
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template or variable template,
+  // declared in namespace scope.
+  if (D.getDeclSpec().isConceptSpecified()) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 0;
+return true;
+  }
+
   // C++0x [temp.explicit]p2:
   //   There are two forms of explicit instantiation: an explicit instantiation
   //   definition and an explicit instantiation declaration. An explicit
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6002,6 +6002,16 @@
 NewVD->setInvalidDecl(true);
   }
 
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a [...] variable template, declared
+  // in namespace scope. [...] A concept definition refers to [...] a
+  // variable concept and its initializer.
+  if (IsVariableTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization)
+<< (IsPartialSpecialization ? 2 : 1);
+  }
+
   // C++ Concepts TS [dcl.spec.concept]p6: A variable concept has the
   // following restrictions:
   // - The declared type shall have the type bool.
@@ -7667,6 +7677,10 @@
 }
 
 if (isConcept) {
+  // This is a function concept.
+  if (FunctionTemplateDecl *FTD = NewFD->getDescribedFunctionTemplate())
+FTD->setConcept(true);
+
   // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
   // applied only to the definition of a function template [...]
   if (!D.isFunctionDefinition()) {
@@ -7733,6 +7747,15 @@
 << 1 << 3;
 NewFD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template [...], declared
+  // in namespace scope. [...] A concept definition refers to either a
+  // function concept and its definition [...].
+  if (isFunctionTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 1;
+  }
 }
 
 // If __module_private__ was specified, mark the function accordingly.
@@ -7994,9 +8017,9 @@
  TemplateId->NumArgs);
   translateTemplateArguments(TemplateArgsPtr,
  TemplateArgs);
-
+
   HasExplicitTemplateArgs = true;
-
+
  

r259445 - Template Type Diffing change

2016-02-01 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Mon Feb  1 18:36:59 2016
New Revision: 259445

URL: http://llvm.org/viewvc/llvm-project?rev=259445=rev
Log:
Template Type Diffing change

When all the arguments of a template are elided, print "A<...>" instead of
"A<[2 * ...]>".  Also remove comment fragment that means nothing.

Modified:
cfe/trunk/lib/AST/ASTDiagnostic.cpp
cfe/trunk/test/Misc/diag-template-diffing-color.cpp
cfe/trunk/test/Misc/diag-template-diffing-cxx98.cpp
cfe/trunk/test/Misc/diag-template-diffing.cpp

Modified: cfe/trunk/lib/AST/ASTDiagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDiagnostic.cpp?rev=259445=259444=259445=diff
==
--- cfe/trunk/lib/AST/ASTDiagnostic.cpp (original)
+++ cfe/trunk/lib/AST/ASTDiagnostic.cpp Mon Feb  1 18:36:59 2016
@@ -497,7 +497,7 @@ class TemplateDiff {
 enum DiffKind {
   /// Incomplete or invalid node.
   Invalid,
-  /// Another level of templates, requires that
+  /// Another level of templates
   Template,
   /// Type difference, all type differences except those falling under
   /// the Template difference.
@@ -1523,12 +1523,14 @@ class TemplateDiff {
 OS << FromTD->getNameAsString() << '<';
 Tree.MoveToChild();
 unsigned NumElideArgs = 0;
+bool AllArgsElided = true;
 do {
   if (ElideType) {
 if (Tree.NodeIsSame()) {
   ++NumElideArgs;
   continue;
 }
+AllArgsElided = false;
 if (NumElideArgs > 0) {
   PrintElideArgs(NumElideArgs, Indent);
   NumElideArgs = 0;
@@ -1539,8 +1541,12 @@ class TemplateDiff {
   if (Tree.HasNextSibling())
 OS << ", ";
 } while (Tree.AdvanceSibling());
-if (NumElideArgs > 0)
-  PrintElideArgs(NumElideArgs, Indent);
+if (NumElideArgs > 0) {
+  if (AllArgsElided)
+OS << "...";
+  else
+PrintElideArgs(NumElideArgs, Indent);
+}
 
 Tree.Parent();
 OS << ">";

Modified: cfe/trunk/test/Misc/diag-template-diffing-color.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-template-diffing-color.cpp?rev=259445=259444=259445=diff
==
--- cfe/trunk/test/Misc/diag-template-diffing-color.cpp (original)
+++ cfe/trunk/test/Misc/diag-template-diffing-color.cpp Mon Feb  1 18:36:59 2016
@@ -34,42 +34,38 @@ void set16(vector) {}
 void test16() {
   set16(vector >());
 }
-// CHECK: {{.*}}candidate function not viable: no known conversion from 
'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}vector<[...]>>' to 
'vector>' for 1st argument
+// CHECK: {{.*}}candidate function not viable: no known conversion from 
'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}vector<...>>' to 
'vector>' for 1st argument
 // TREE: {{.*}}candidate function not viable: no known conversion from 
argument type to parameter type for 1st argument
 // TREE:   vector<
-// TREE: {{\[}}[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}!= [[CYAN]](no 
qualifiers){{ ?}}[[RESET]]]{{ ?}}vector<
-// TREE:   [...]>>
+// TREE: {{\[}}[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}!= [[CYAN]](no 
qualifiers){{ ?}}[[RESET]]]{{ ?}}vector<...>>
 
 void set17(vector >) {}
 void test17() {
   set17(vector());
 }
-// CHECK: candidate function not viable: no known conversion from 
'vector>' to 'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ 
?}}vector<[...]>>' for 1st argument
+// CHECK: candidate function not viable: no known conversion from 
'vector>' to 'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ 
?}}vector<...>>' for 1st argument
 // TREE: candidate function not viable: no known conversion from argument type 
to parameter type for 1st argument
 // TREE:   vector<
-// TREE: {{\[}}[[CYAN]](no qualifiers){{ ?}}[[RESET]]{{ ?}}!= 
[[CYAN]]const[[RESET]]] vector<
-// TREE:   [...]>>
+// TREE: {{\[}}[[CYAN]](no qualifiers){{ ?}}[[RESET]]{{ ?}}!= 
[[CYAN]]const[[RESET]]] vector<...>>
 
 void set18(vector >) {}
 void test18() {
   set18(vector >());
 }
-// CHECK: candidate function not viable: no known conversion from 
'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}vector<[...]>>' to 
'vector<[[CYAN]]volatile{{ ?}}[[RESET]]{{ ?}}vector<[...]>>' for 1st argument
+// CHECK: candidate function not viable: no known conversion from 
'vector<[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}vector<...>>' to 
'vector<[[CYAN]]volatile{{ ?}}[[RESET]]{{ ?}}vector<...>>' for 1st argument
 // TREE: no matching function for call to 'set18'
 // TREE: candidate function not viable: no known conversion from argument type 
to parameter type for 1st argument
 // TREE:   vector<
-// TREE: {{\[}}[[CYAN]]const{{ ?}}[[RESET]]{{ ?}}!= 
[[CYAN]]volatile[[RESET]]] vector<
-// TREE:   [...]>>
+// TREE: {{\[}}[[CYAN]]const{{ 

Re: [PATCH] D16788: PS4 ABI Round 2. Actual PS4 code.

2016-02-01 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/AST/RecordLayoutBuilder.cpp:1598-1599
@@ -1597,1 +1597,4 @@
 
+// PS4 remains compatible to pre r257462 behavior.
+bool isPS4ABI = (Context.getTargetInfo().getCXXABI().getKind() == 
TargetCXXABI::PS4);
+

Please say what that behavior was here. "The PS4 ABI ignores explicit alignment 
attributes on bitfields." or similar.


http://reviews.llvm.org/D16788



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


Re: [PATCH] D16264: For FreeBSD, use _p variants of libraries for linking C++ programs

2016-02-01 Thread Saleem Abdulrasool via cfe-commits
compnerd added a comment.

I think it would be better if we could actually create a helper to get the 
profiling library name for a specific library, and use that in both locations.

Do we have a test for the math case at the very least?


http://reviews.llvm.org/D16264



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


Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2016-02-01 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/AST/DeclTemplate.h:374
@@ +373,3 @@
+  bool isConcept() const { return TemplatedDecl.getInt(); }
+  void setConcept(bool IC) { TemplatedDecl.setInt(true); }
+

I would prefer to not have a setter at all, but if it's awkward to pass this 
flag into the constructor, then a setter is fine (and I don't mind whether or 
not it takes a parameter). We should definitely not take a parameter and ignore 
it though.


http://reviews.llvm.org/D13357



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


Re: [PATCH] D16692: [OpenCL] Eliminate warning when declaring OpenCL builtin functions

2016-02-01 Thread Xiuli PAN via cfe-commits
pxli168 accepted this revision.
pxli168 added a comment.

Thanks, LGTM!


http://reviews.llvm.org/D16692



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


RE: r258782 - Recommit: R258773 [OpenCL] Pipe builtin functions

2016-02-01 Thread xiuli pan via cfe-commits
Thank you for you advise, I will make these fixed in some later commit.

-Original Message-
From: meta...@gmail.com [mailto:meta...@gmail.com] On Behalf Of Richard Smith
Sent: Tuesday, February 2, 2016 5:53 AM
To: Xiuli Pan 
Cc: cfe-commits 
Subject: Re: r258782 - Recommit: R258773 [OpenCL] Pipe builtin functions

On Mon, Jan 25, 2016 at 8:03 PM, Xiuli Pan via cfe-commits 
 wrote:
> Author: pxl
> Date: Mon Jan 25 22:03:48 2016
> New Revision: 258782
>
> URL: http://llvm.org/viewvc/llvm-project?rev=258782=rev
> Log:
> Recommit: R258773 [OpenCL] Pipe builtin functions Fix arc patch fuzz 
> error.
> Summary:
> Support for the pipe built-in functions for OpenCL 2.0.
> The pipe builtin functions may have infinite kinds of element types, 
> one approach would be to just generate calls that would always use generic 
> types such as void*.
> This patch is based on bader's opencl support patch on SPIR-V branch.
>
> Reviewers: Anastasia, pekka.jaaskelainen
>
> Subscribers: keryell, bader, cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D15914
>
> Added:
> cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl
> cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
> Modified:
> cfe/trunk/include/clang/Basic/Builtins.def
> cfe/trunk/include/clang/Basic/Builtins.h
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Basic/Builtins.cpp
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/lib/Sema/SemaChecking.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Builtins.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Buil
> tins.def?rev=258782=258781=258782=diff
> ==
> 
> --- cfe/trunk/include/clang/Basic/Builtins.def (original)
> +++ cfe/trunk/include/clang/Basic/Builtins.def Mon Jan 25 22:03:48 
> +++ 2016
> @@ -1252,6 +1252,32 @@ BUILTIN(__builtin___get_unsafe_stack_ptr
>  BUILTIN(__builtin_nontemporal_store, "v.", "t")  
> BUILTIN(__builtin_nontemporal_load, "v.", "t")
>
> +// OpenCL v2.0 s6.13.16, s9.17.3.5 - Pipe functions.
> +// We need the generic prototype, since the packet type could be anything.
> +LANGBUILTIN(read_pipe, "i.", "tn", OCLC_LANG) LANGBUILTIN(write_pipe, 
> +"i.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(reserve_read_pipe, "i.", "tn", OCLC_LANG) 
> +LANGBUILTIN(reserve_write_pipe, "i.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(commit_write_pipe, "v.", "tn", OCLC_LANG) 
> +LANGBUILTIN(commit_read_pipe, "v.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(sub_group_reserve_read_pipe, "i.", "tn", OCLC_LANG) 
> +LANGBUILTIN(sub_group_reserve_write_pipe, "i.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(sub_group_commit_read_pipe, "v.", "tn", OCLC_LANG) 
> +LANGBUILTIN(sub_group_commit_write_pipe, "v.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(work_group_reserve_read_pipe, "i.", "tn", OCLC_LANG) 
> +LANGBUILTIN(work_group_reserve_write_pipe, "i.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(work_group_commit_read_pipe, "v.", "tn", OCLC_LANG) 
> +LANGBUILTIN(work_group_commit_write_pipe, "v.", "tn", OCLC_LANG)
> +
> +LANGBUILTIN(get_pipe_num_packets, "Ui.", "tn", OCLC_LANG) 
> +LANGBUILTIN(get_pipe_max_packets, "Ui.", "tn", OCLC_LANG)
> +
>  #undef BUILTIN
>  #undef LIBBUILTIN
>  #undef LANGBUILTIN
>
> Modified: cfe/trunk/include/clang/Basic/Builtins.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Buil
> tins.h?rev=258782=258781=258782=diff
> ==
> 
> --- cfe/trunk/include/clang/Basic/Builtins.h (original)
> +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Jan 25 22:03:48 2016
> @@ -36,6 +36,7 @@ enum LanguageID {
>CXX_LANG = 0x4,  // builtin for cplusplus only.
>OBJC_LANG = 0x8, // builtin for objective-c and objective-c++
>MS_LANG = 0x10,  // builtin requires MS mode.
> +  OCLC_LANG = 0x20,// builtin for OpenCL C only.

Missing space after comma.

>ALL_LANGUAGES = C_LANG | CXX_LANG | OBJC_LANG, // builtin for all 
> languages.
>ALL_GNU_LANGUAGES = ALL_LANGUAGES | GNU_LANG,  // builtin requires GNU 
> mode.
>ALL_MS_LANGUAGES = ALL_LANGUAGES | MS_LANG // builtin requires MS mode.
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diag
> nosticSemaKinds.td?rev=258782=258781=258782=diff
> ==
> 
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Jan 25 
> +++ 22:03:48 2016
> @@ -7680,6 +7680,16 @@ def err_atomic_init_constant : Error<  def 
> err_opencl_implicit_vector_conversion : Error<
>"implicit conversions between vector types (%0 and %1) are not 
> permitted">;
>
> +// OpenCL v2.0 s6.13.6 -- Builtin Pipe Functions def 
> 

Re: [PATCH] D16686: [OpenCL] Generate metadata for opencl_unroll_hint attribute

2016-02-01 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 46608.
yaxunl added a comment.

Add test for negative unroll hint value as suggested by Xiuli.


http://reviews.llvm.org/D16686

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  lib/CodeGen/CGLoopInfo.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseStmt.cpp
  lib/Sema/SemaStmtAttr.cpp
  test/CodeGenOpenCL/unroll-hint.cl
  test/Parser/opencl-unroll-hint.cl
  test/SemaOpenCL/unroll-hint.cl

Index: test/SemaOpenCL/unroll-hint.cl
===
--- /dev/null
+++ test/SemaOpenCL/unroll-hint.cl
@@ -0,0 +1,24 @@
+//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s
+
+kernel void C (global int *x) {
+  int I = 3;
+  __attribute__((opencl_unroll_hint(I))) // expected-error {{opencl_unroll_hint attribute requires an integer constant}}
+  while (I--);
+}
+
+kernel void D (global int *x) {
+  int i = 10;
+  __attribute__((opencl_unroll_hint))
+  do {
+  } while(i--);
+}
+
+kernel void E() {
+  __attribute__((opencl_unroll_hint(2,4))) // expected-error {{1 attribute takes no more than 1 argument}}
+  for(int i=0; i<100; i++);
+}
+
+kernel void F() {
+  __attribute__((opencl_unroll_hint(-1))) // expected-error {{opencl_unroll_hint attribute requires a positive integral compile time constant expression}}
+  for(int i=0; i<100; i++);
+}
Index: test/Parser/opencl-unroll-hint.cl
===
--- /dev/null
+++ test/Parser/opencl-unroll-hint.cl
@@ -0,0 +1,8 @@
+//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s
+
+kernel void B (global int *x) {
+  __attribute__((opencl_unroll_hint(42)))
+  if (x[0]) // expected-error {{OpenCL only supports opencl_unroll_hint attribute on for, while, and do statements}}
+x[0] = 15;
+}
+
Index: test/CodeGenOpenCL/unroll-hint.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/unroll-hint.cl
@@ -0,0 +1,96 @@
+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+
+/*** for ***/
+void for_count()
+{
+// CHECK-LABEL: for_count
+__attribute__((opencl_unroll_hint(8)))
+for( int i = 0; i < 1000; ++i);
+// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_COUNT:.*]]
+}
+
+void for_disable()
+{
+// CHECK-LABEL: for_disable
+__attribute__((opencl_unroll_hint(1)))
+for( int i = 0; i < 1000; ++i);
+// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_DISABLE:.*]]
+}
+
+void for_full()
+{
+// CHECK-LABEL: for_full
+__attribute__((opencl_unroll_hint))
+for( int i = 0; i < 1000; ++i);
+// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_FULL:.*]]
+}
+
+/*** while ***/
+void while_count()
+{
+// CHECK-LABEL: while_count
+int i = 1000;
+__attribute__((opencl_unroll_hint(8)))
+while(i-->0);
+// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_COUNT:.*]]
+}
+
+void while_disable()
+{
+// CHECK-LABEL: while_disable
+int i = 1000;
+__attribute__((opencl_unroll_hint(1)))
+while(i-->0);
+// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_DISABLE:.*]]
+}
+
+void while_full()
+{
+// CHECK-LABEL: while_full
+int i = 1000;
+__attribute__((opencl_unroll_hint))
+while(i-->0);
+// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_FULL:.*]]
+}
+
+/*** do ***/
+void do_count()
+{
+// CHECK-LABEL: do_count
+int i = 1000;
+__attribute__((opencl_unroll_hint(8)))
+do {} while(i--> 0);
+// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_COUNT:.*]]
+}
+
+void do_disable()
+{
+// CHECK-LABEL: do_disable
+int i = 1000;
+__attribute__((opencl_unroll_hint(1)))
+do {} while(i--> 0);
+// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_DISABLE:.*]]
+}
+
+void do_full()
+{
+// CHECK-LABEL: do_full
+int i = 1000;
+__attribute__((opencl_unroll_hint))
+do {} while(i--> 0);
+// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_FULL:.*]]
+}
+
+
+// CHECK: ![[FOR_COUNT]] =  distinct !{![[FOR_COUNT]],  ![[COUNT:.*]]}
+// CHECK: ![[COUNT]] =  !{!"llvm.loop.unroll.count", i32 8}
+// CHECK: ![[FOR_DISABLE]]   =  distinct !{![[FOR_DISABLE]],  ![[DISABLE:.*]]}
+// CHECK: ![[DISABLE]]   =  !{!"llvm.loop.unroll.disable"}
+// CHECK: ![[FOR_FULL]]  =  distinct !{![[FOR_FULL]],  ![[FULL:.*]]}
+// CHECK: ![[FULL]]  =  !{!"llvm.loop.unroll.full"}
+// CHECK: ![[WHILE_COUNT]]   =  distinct !{![[WHILE_COUNT]],![[COUNT]]}
+// CHECK: ![[WHILE_DISABLE]] =  distinct !{![[WHILE_DISABLE]],  ![[DISABLE]]}
+// CHECK: ![[WHILE_FULL]]=  distinct !{![[WHILE_FULL]], ![[FULL]]}
+// CHECK: ![[DO_COUNT]]  =  distinct !{![[DO_COUNT]],   ![[COUNT]]}
+// CHECK: ![[DO_DISABLE]]=  distinct !{![[DO_DISABLE]], ![[DISABLE]]}
+// CHECK: ![[DO_FULL]]   =  distinct !{![[DO_FULL]],

Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2016-02-01 Thread Nathan Wilson via cfe-commits
nwilson marked 5 inline comments as done.
nwilson added a comment.

Marking some comments Done which were fixed in previous updates.


http://reviews.llvm.org/D13357



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


Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2016-02-01 Thread Nathan Wilson via cfe-commits
nwilson added inline comments.


Comment at: include/clang/AST/DeclTemplate.h:374
@@ +373,3 @@
+  bool isConcept() const { return TemplatedDecl.getInt(); }
+  void setConcept(bool IC) { TemplatedDecl.setInt(true); }
+

rsmith wrote:
> I would prefer to not have a setter at all, but if it's awkward to pass this 
> flag into the constructor, then a setter is fine (and I don't mind whether or 
> not it takes a parameter). We should definitely not take a parameter and 
> ignore it though.
Ah, gotcha. Yeah, it seemed somewhat awkward to me to pass the flag all the way 
through. As a note it would be VarTemplateDecl -> RedeclarableTemplateDecl -> 
TemplateDecl. Also, RedeclarableTemplateDecl also currently currently takes 7 
parameters. 

If you feel strongly, I can move it to the constructor. Otherwise, I'll take 
the parameter out of the setter as both you and Hubert have pointed out the 
property will not need to set to false.


http://reviews.llvm.org/D13357



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


Re: [modules] PR24954

2016-02-01 Thread Richard Smith via cfe-commits
On Thu, Jan 28, 2016 at 8:23 AM, Vassil Vassilev  wrote:
> Would this patch be more reasonable? It follows what
> RegisterTemplateSpecialization (introduced in r245779) does. AFAICT this
> adds an update record far less often.

It's still adding redundant update records. We'll write the
appropriate update record as part of serializing the declaration
itself, so we only need to ensure that the declaration is emitted, not
actually emit an update record for it. Perhaps you could store a list
of such declarations on the ASTWriter, and call GetDeclRef on each of
them once we start emitting the AST file (or maybe just push them into
UpdatingVisibleDecls). Please also restrict this to the template
friend corner case.

> --Vassil
>
> On 12/12/15 16:13, Vassil Vassilev wrote:
>
> I couldn't find GetDecl routine in the ASTWriter. Could you elaborate?
>
> Assuming you meant ASTWriter::GetDeclRef(D): It seems that the conditions
> when calling GetDeclRef differ from the conditions of
> AddedCXXTemplateSpecialization. Eg:
>
> ASTWriter::AddedCXXTemplateSpecialization {
>   assert(!WritingAST && "Already writing the AST!");
>   ...
> }
> ASTWriter::GetDeclRef {
>   assert(WritingAST && "Cannot request a declaration ID before AST
> writing");
>   ..
> }
>
> IIUC this particular instantiation happens *after* module B was built, thus
> it needs to be retrospectively added to the serialized namespace. It looks
> like even avoiding somehow the asserts of GetDeclRef it wouldn't help much.
>
> Alternatively I could try to reduce the redundant update records by
> narrowing down to instantiations coming in the context of friends.
>
> --Vassil
>
> On 12/12/15 01:07, Richard Smith wrote:
>
> Instead of adding an update record directly in this case (which will emit
> far more update records than necessary), how about just calling GetDecl(D)
> from AddedCXXTemplateSpecialization to ensure that it gets emitted?
>
> On Fri, Dec 4, 2015 at 7:46 AM, Vassil Vassilev  wrote:
>>
>> Hi,
>>   Could you review my fix please.
>> Many thanks,
>> Vassil
>>
>> On 08/10/15 15:53, Vassil Vassilev wrote:
>>>
>>> Hi Richard,
>>>   I started working on https://llvm.org/bugs/show_bug.cgi?id=24954
>>>
>>>   IIUC r228485 introduces an abstraction to deal with
>>> not-really-anonymous friend decls
>>> (serialization::needsAnonymousDeclarationNumber in ASTCommon.cpp).
>>>
>>>   A comment explicitly says:
>>>   "// This doesn't apply to friend tag decls; Sema makes those available
>>> to name
>>>// lookup in the surrounding context."
>>>
>>>   In the bug reproducer, the friend function (wrt __iom_t10) is forward
>>> declared in the same namespace, where Sema makes the friend available for a
>>> name lookup.
>>>
>>>   It seems that the friend operator<< in __iom_t10 (sorry about the names
>>> they come from libcxx) doesn't get registered in the ASTWriter's DeclIDs but
>>> it gets registered in outer namespace's lookup table. Thus, assert is
>>> triggered when finalizing module A, since it rebuilds the lookups of the
>>> updated contexts.
>>>
>>>   The issue only appears when building module A deserializes/uses module
>>> B.
>>>
>>>   Currently I was assume that something wrong happens in either
>>> needsAnonymousDeclarationNumber or I hit a predicted issue
>>> ASTWriterDecl.cpp:1602
>>> // FIXME: This is not correct; when we reach an imported declaration
>>> we
>>> // won't emit its previous declaration.
>>> (void)Writer.GetDeclRef(D->getPreviousDecl());
>>> (void)Writer.GetDeclRef(MostRecent);
>>>
>>>   The issue seems a fairly complex one and I am a bit stuck.
>>>
>>>   Any hints are very very welcome ;)
>>> Many thanks,
>>> Vassil
>>>
>>>
>>>
>>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16360: unordered_map: Avoid unnecessary mallocs when no insert occurs

2016-02-01 Thread Duncan P. N. Exon Smith via cfe-commits
dexonsmith updated this revision to Diff 46603.
dexonsmith added a comment.

Eric, I think this addresses all of your review comments.

There are a couple of prep NFC commits that I sent for review:
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160201/148661.html
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160201/148662.html

What's changed here:

- insert() now calls emplace() -- this could be split out (it is locally).
- Renamed __hash_table::__insert_unique_value to __insert_unique_key_value and 
updated callers -- this could also be split out (it is locally).
- Moved the dispatch logic to emplace().
- Changed the dispatch logic to use a type trait (although it's still 
multi-stage to find the number of arguments).
- Removed the unnecessary #ifdefs in the hasher (etc.).


http://reviews.llvm.org/D16360

Files:
  include/__hash_table
  include/unordered_map
  test/libcxx/containers/unord/unord.map/insert_dup_alloc.pass.cpp

Index: test/libcxx/containers/unord/unord.map/insert_dup_alloc.pass.cpp
===
--- /dev/null
+++ test/libcxx/containers/unord/unord.map/insert_dup_alloc.pass.cpp
@@ -0,0 +1,87 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// Check that we don't allocate when trying to insert a duplicate value into a
+// unordered_map.
+
+#include 
+#include 
+#include "count_new.hpp"
+#include "MoveOnly.h"
+
+int main()
+{
+{
+std::unordered_map<int, int> s;
+assert(globalMemCounter.checkNewCalledEq(0));
+
+for(int i=0; i < 100; ++i) {
+s.insert(std::make_pair(3, i));
+s.insert(std::make_pair(3, unsigned(i)));
+s.insert(s.end(), std::make_pair(3, i));
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+s.emplace(std::make_pair(3, i));
+s.emplace_hint(s.end(), std::make_pair(3, i));
+#endif
+{
+const std::pair<int, int> P(3, i);
+s.insert(P);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+s.emplace(P);
+s.emplace_hint(s.end(), P);
+#endif
+}
+}
+
+assert(s.size() == 1);
+assert(s.count(3) == 1);
+assert(s.at(3) == 0);
+assert(globalMemCounter.checkNewCalledEq(2));
+}
+assert(globalMemCounter.checkOutstandingNewEq(0));
+globalMemCounter.reset();
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+{
+std::unordered_map<MoveOnly, MoveOnly> s;
+assert(globalMemCounter.checkNewCalledEq(0));
+
+for(int i=0; i<100; i++) {
+s.insert(std::make_pair(MoveOnly(3), MoveOnly(i)));
+s.insert(s.end(), std::make_pair(MoveOnly(3), MoveOnly(i)));
+s.emplace(std::make_pair(MoveOnly(3), MoveOnly(i)));
+s.emplace_hint(s.end(), std::make_pair(MoveOnly(3), MoveOnly(i)));
+}
+
+assert(s.size() == 1);
+assert(s.count(MoveOnly(3)) == 1);
+assert(s.at(MoveOnly(3)) == 0);
+assert(globalMemCounter.checkNewCalledEq(2));
+}
+assert(globalMemCounter.checkOutstandingNewEq(0));
+globalMemCounter.reset();
+{
+std::unordered_map<int, MoveOnly> s;
+assert(globalMemCounter.checkNewCalledEq(0));
+
+for(int i=0; i<100; i++) {
+s.insert(std::make_pair(3, MoveOnly(i)));
+s.insert(s.end(), std::make_pair(3, MoveOnly(i)));
+s.emplace(std::make_pair(3, MoveOnly(i)));
+s.emplace_hint(s.end(), std::make_pair(3, MoveOnly(i)));
+}
+
+assert(s.size() == 1);
+assert(s.count(3) == 1);
+assert(s.at(3) == 0);
+assert(globalMemCounter.checkNewCalledEq(2));
+}
+assert(globalMemCounter.checkOutstandingNewEq(0));
+globalMemCounter.reset();
+#endif
+}
Index: include/unordered_map
===
--- include/unordered_map
+++ include/unordered_map
@@ -399,6 +399,9 @@
 size_t operator()(const _Cp& __x) const
 {return static_cast(*this)(__x.__cc.first);}
 _LIBCPP_INLINE_VISIBILITY
+size_t operator()(const typename _Cp::value_type& __x) const
+{return static_cast(*this)(__x.first);}
+_LIBCPP_INLINE_VISIBILITY
 size_t operator()(const _Key& __x) const
 {return static_cast(*this)(__x);}
 void swap(__unordered_map_hasher&__y)
@@ -429,6 +432,9 @@
 size_t operator()(const _Cp& __x) const
 {return __hash_(__x.__cc.first);}
 _LIBCPP_INLINE_VISIBILITY
+size_t operator()(const typename _Cp::value_type& __x) const
+{return __hash_(__x.first);}
+_LIBCPP_INLINE_VISIBILITY
 size_t operator()(const _Key& __x) const
 {return __hash_(__x);}
 void swap(__unordered_map_

Re: [PATCH] D16686: [OpenCL] Generate metadata for opencl_unroll_hint attribute

2016-02-01 Thread Xiuli PAN via cfe-commits
pxli168 added inline comments.


Comment at: test/SemaOpenCL/unroll-hint.cl:22
@@ +21,2 @@
+}
+#endif

It seems the negative integer invalid test  is missing?
I think it was in your last diff.


http://reviews.llvm.org/D16686



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


Re: [PATCH] D16539: [FIX] 26194 - LLVM crash in CXXNameMangler::mangleType

2016-02-01 Thread Xiuli PAN via cfe-commits
pxli168 added inline comments.


Comment at: test/CodeGenOpenCL/generic_mangling.cl:1
@@ +1,2 @@
+// RUN: %clang_cc1 -ffake-address-space-map -emit-llvm -ffp-contract=off -x cl 
-cl-std=CL2.0 -o - %s | FileCheck %s
+

Is this enough for the new added MicrosoftMangle?


Comment at: tools/driver/driver.cpp:367
@@ -367,1 +366,3 @@
+int Result = ExecuteCC1Tool(argv, argv[1] + 4);
+return Result; // Useful for debugging to set breakpoint here
   }

I think this dubug use shuold not be in the patch.


http://reviews.llvm.org/D16539



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


Re: [PATCH] D16586: Make clang AAPCS compliant w.r.t volatile bitfield accesses

2016-02-01 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.


Comment at: test/CodeGen/aapcs-bitfield.c:312-317
@@ +311,8 @@
+
+  // BE: %[[PTR3:.*]] = bitcast %struct.st5a* %[[PTR2]] to i32*
+  // BE-NEXT: %[[LD:.*]] = load volatile i32, i32* %[[PTR3]], align 4
+  // BE-NEXT: %[[CLR:.*]] = and i32 %[[LD]], -16252929
+  // BE-NEXT: %[[SET:.*]] = or i32 %[[CLR]], 1572864
+  // BE-NEXT: store volatile i32 %[[SET]], i32* %[[PTR3]], align 4
+  m->y.b = 3;
+}

This violates the C and C++ object models by creating a data race on `m->y.a` 
that was not present in the source code. A store to a bit-field cannot write to 
bytes that are not part of the same sequence of bit-field members. If this ABI 
really requires that (and supports multi-threaded systems), it is not a correct 
ABI for C11 nor C++11. (This leaves open the question of which standard we 
should follow...)


http://reviews.llvm.org/D16586



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


r259453 - [asan] Add iOS support for Address Sanitizer

2016-02-01 Thread Anna Zaks via cfe-commits
Author: zaks
Date: Mon Feb  1 20:04:48 2016
New Revision: 259453

URL: http://llvm.org/viewvc/llvm-project?rev=259453=rev
Log:
[asan] Add iOS support for Address Sanitizer

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

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/test/Driver/darwin-sanitizer-ld.c
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=259453=259452=259453=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Feb  1 20:04:48 2016
@@ -319,6 +319,26 @@ void MachO::AddLinkRuntimeLib(const ArgL
   }
 }
 
+StringRef Darwin::getOSLibraryNameSuffix() const {
+  switch(TargetPlatform) {
+  case DarwinPlatformKind::MacOS:
+return "osx";
+  case DarwinPlatformKind::IPhoneOS:
+return "ios";
+  case DarwinPlatformKind::IPhoneOSSimulator:
+return "iossim";
+  case DarwinPlatformKind::TvOS:
+return "tvos";
+  case DarwinPlatformKind::TvOSSimulator:
+return "tvossim";
+  case DarwinPlatformKind::WatchOS:
+return "watchos";
+  case DarwinPlatformKind::WatchOSSimulator:
+return "watchossim";
+  }
+  llvm_unreachable("Unsupported platform");
+}
+
 void Darwin::addProfileRTLibs(const ArgList ,
   ArgStringList ) const {
   if (!needsProfileRT(Args)) return;
@@ -363,12 +383,11 @@ void DarwinClang::AddLinkSanitizerLibArg
 // Sanitizer runtime libraries requires C++.
 AddCXXStdlibLibArgs(Args, CmdArgs);
   }
-  // ASan is not supported on watchOS.
-  assert(isTargetMacOS() || isTargetIOSSimulator());
-  StringRef OS = isTargetMacOS() ? "osx" : "iossim";
+
   AddLinkRuntimeLib(
   Args, CmdArgs,
-  (Twine("libclang_rt.") + Sanitizer + "_" + OS + "_dynamic.dylib").str(),
+  (Twine("libclang_rt.") + Sanitizer + "_" +
+   getOSLibraryNameSuffix() + "_dynamic.dylib").str(),
   /*AlwaysLink*/ true, /*IsEmbedded*/ false,
   /*AddRPath*/ true);
 
@@ -1221,8 +1240,7 @@ void Darwin::CheckObjCARC() const {
 
 SanitizerMask Darwin::getSupportedSanitizers() const {
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
-  if (isTargetMacOS() || isTargetIOSSimulator())
-Res |= SanitizerKind::Address;
+  Res |= SanitizerKind::Address;
   if (isTargetMacOS()) {
 if (!isMacosxVersionLT(10, 9))
   Res |= SanitizerKind::Vptr;

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=259453=259452=259453=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Mon Feb  1 20:04:48 2016
@@ -496,6 +496,8 @@ protected:
 return TargetVersion < VersionTuple(V0, V1, V2);
   }
 
+  StringRef getOSLibraryNameSuffix() const;
+
 public:
   /// }
   /// @name ToolChain Implementation

Modified: cfe/trunk/test/Driver/darwin-sanitizer-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-sanitizer-ld.c?rev=259453=259452=259453=diff
==
--- cfe/trunk/test/Driver/darwin-sanitizer-ld.c (original)
+++ cfe/trunk/test/Driver/darwin-sanitizer-ld.c Mon Feb  1 20:04:48 2016
@@ -11,16 +11,6 @@
 // CHECK-ASAN: "-rpath" "{{.*}}lib{{.*}}darwin"
 
 // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
-// RUN:   -fsanitize=address -mios-simulator-version-min=7.0 %s -o %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ASAN-IOSSIM %s
-
-// CHECK-ASAN-IOSSIM: "{{.*}}ld{{(.exe)?}}"
-// CHECK-ASAN-IOSSIM: lc++
-// CHECK-ASAN-IOSSIM: libclang_rt.asan_iossim_dynamic.dylib"
-// CHECK-ASAN-IOSSIM: "-rpath" "@executable_path"
-// CHECK-ASAN-IOSSIM: "-rpath" "{{.*}}lib{{.*}}darwin"
-
-// RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
 // RUN:   -fPIC -shared -fsanitize=address %s -o %t.so 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-DYN-ASAN %s
 
@@ -65,3 +55,63 @@
 
 // CHECK-DYN-BOUNDS: "{{.*}}ld{{(.exe)?}}"
 // CHECK-DYN-BOUNDS-NOT: ubsan_osx
+
+// RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
+// RUN:   -fsanitize=address -mios-simulator-version-min=7.0 %s -o %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-IOSSIM %s
+
+// CHECK-ASAN-IOSSIM: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ASAN-IOSSIM: lc++
+// CHECK-ASAN-IOSSIM: libclang_rt.asan_iossim_dynamic.dylib"
+// CHECK-ASAN-IOSSIM: "-rpath" "@executable_path"
+// CHECK-ASAN-IOSSIM: "-rpath" "{{.*}}lib{{.*}}darwin"
+
+// RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
+// RUN:   -fsanitize=address -mtvos-simulator-version-min=8.3.0 %s -o %t.o 
2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-TVOSSIM %s
+
+// CHECK-ASAN-TVOSSIM: "{{.*}}ld{{(.exe)?}}"
+// 

[PATCH] D16794: [Clang-tidy] Make readability-simplify-boolean-expr working with included files

2016-02-01 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko created this revision.
Eugene.Zelenko added reviewers: alexfh, LegalizeAdulthood, aaron.ballman.
Eugene.Zelenko added a subscriber: cfe-commits.
Eugene.Zelenko set the repository for this revision to rL LLVM.

This fix for PR26332. I checked it on my work code base.

Build and regressions were OK on RHEL 6.

Repository:
  rL LLVM

http://reviews.llvm.org/D16794

Files:
  clang-tidy/readability/SimplifyBooleanExprCheck.cpp

Index: clang-tidy/readability/SimplifyBooleanExprCheck.cpp
===
--- clang-tidy/readability/SimplifyBooleanExprCheck.cpp
+++ clang-tidy/readability/SimplifyBooleanExprCheck.cpp
@@ -273,7 +273,7 @@
   StringRef BooleanId) {
   Finder->addMatcher(
   binaryOperator(
-  isExpansionInMainFile(), hasOperatorName(OperatorName),
+  hasOperatorName(OperatorName),
   hasLHS(allOf(expr().bind(LHSId),
cxxBoolLiteral(equals(Value)).bind(BooleanId))),
   hasRHS(expr().bind(RHSId)),
@@ -287,8 +287,7 @@
   StringRef BooleanId) {
   Finder->addMatcher(
   binaryOperator(
-  isExpansionInMainFile(), hasOperatorName(OperatorName),
-  hasLHS(expr().bind(LHSId)),
+  hasOperatorName(OperatorName), hasLHS(expr().bind(LHSId)),
   unless(
   hasLHS(anyOf(cxxBoolLiteral(), 
hasDescendant(cxxBoolLiteral(),
   hasRHS(allOf(expr().bind(RHSId),
@@ -301,7 +300,7 @@
StringRef OperatorName,
StringRef BooleanId) {
   Finder->addMatcher(
-  binaryOperator(isExpansionInMainFile(), hasOperatorName(OperatorName),
+  binaryOperator(hasOperatorName(OperatorName),
  hasLHS(allOf(expr().bind(LHSId),
   
ignoringImpCasts(cxxBoolLiteral(equals(Value))
.bind(BooleanId,
@@ -315,7 +314,7 @@
StringRef OperatorName,
StringRef BooleanId) {
   Finder->addMatcher(
-  binaryOperator(isExpansionInMainFile(), hasOperatorName(OperatorName),
+  binaryOperator(hasOperatorName(OperatorName),
  unless(hasLHS(hasDescendant(cxxBoolLiteral(,
  hasLHS(expr().bind(LHSId)),
  hasRHS(allOf(expr().bind(RHSId),
@@ -327,8 +326,7 @@
 void SimplifyBooleanExprCheck::matchBoolCondition(MatchFinder *Finder,
   bool Value,
   StringRef BooleanId) {
-  Finder->addMatcher(ifStmt(isExpansionInMainFile(),
-hasCondition(cxxBoolLiteral(equals(Value))
+  Finder->addMatcher(ifStmt(hasCondition(cxxBoolLiteral(equals(Value))
  .bind(BooleanId))).bind(IfStmtId),
  this);
 }
@@ -337,8 +335,7 @@
   bool Value,
   StringRef TernaryId) {
   Finder->addMatcher(
-  conditionalOperator(isExpansionInMainFile(),
-  hasTrueExpression(cxxBoolLiteral(equals(Value))),
+  conditionalOperator(hasTrueExpression(cxxBoolLiteral(equals(Value))),
   hasFalseExpression(cxxBoolLiteral(equals(!Value
   .bind(TernaryId),
   this);
@@ -347,13 +344,11 @@
 void SimplifyBooleanExprCheck::matchIfReturnsBool(MatchFinder *Finder,
   bool Value, StringRef Id) {
   if (ChainedConditionalReturn) {
-Finder->addMatcher(ifStmt(isExpansionInMainFile(),
-  hasThen(returnsBool(Value, ThenLiteralId)),
+Finder->addMatcher(ifStmt(hasThen(returnsBool(Value, ThenLiteralId)),
   hasElse(returnsBool(!Value))).bind(Id),
this);
   } else {
-Finder->addMatcher(ifStmt(isExpansionInMainFile(),
-  unless(hasParent(ifStmt())),
+Finder->addMatcher(ifStmt(unless(hasParent(ifStmt())),
   hasThen(returnsBool(Value, ThenLiteralId)),
   hasElse(returnsBool(!Value))).bind(Id),
this);
@@ -376,12 +371,9 @@
   auto Else = anyOf(SimpleElse, compoundStmt(statementCountIs(1),
  hasAnySubstatement(SimpleElse)));
   if (ChainedConditionalAssignment) {
-Finder->addMatcher(
-ifStmt(isExpansionInMainFile(), hasThen(Then), hasElse(Else)).bind(Id),
-this);
+Finder->addMatcher(ifStmt(hasThen(Then), hasElse(Else)).bind(Id), this);
   } else {
-Finder->addMatcher(ifStmt(isExpansionInMainFile(),
- 

[PATCH] D16791: unordered_map: Match emplace_hint logic when _LIBCPP_DEBUG, NFC

2016-02-01 Thread Duncan P. N. Exon Smith via cfe-commits
dexonsmith created this revision.
dexonsmith added a reviewer: EricWF.
dexonsmith added a subscriber: cfe-commits.

When `!defined(_LIBCPP_DEBUG)`, unordered_map::emplace_hint() forwards
to emplace().  Do the same when `defined(_LIBCPP_DEBUG)`.

This has no real functionality change, just unifies the logic as a
prep commit.


http://reviews.llvm.org/D16791

Files:
  include/unordered_map

Index: include/unordered_map
===
--- include/unordered_map
+++ include/unordered_map
@@ -932,7 +932,7 @@
 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
 "unordered_map::emplace_hint(const_iterator, args...) called 
with an iterator not"
 " referring to this unordered_map");
-return 
__table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
+return emplace(_VSTD::forward<_Args>(__args)...).first;
 }
 #else
 iterator emplace_hint(const_iterator, _Args&&... __args)


Index: include/unordered_map
===
--- include/unordered_map
+++ include/unordered_map
@@ -932,7 +932,7 @@
 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
 "unordered_map::emplace_hint(const_iterator, args...) called with an iterator not"
 " referring to this unordered_map");
-return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
+return emplace(_VSTD::forward<_Args>(__args)...).first;
 }
 #else
 iterator emplace_hint(const_iterator, _Args&&... __args)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15624: Add iOS/watchOS/tvOS support for ASan (clang part)

2016-02-01 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL259453: [asan] Add iOS support for Address Sanitizer 
(authored by zaks).

Changed prior to commit:
  http://reviews.llvm.org/D15624?vs=45720=46605#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15624

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Driver/ToolChains.h
  cfe/trunk/test/Driver/darwin-sanitizer-ld.c
  cfe/trunk/test/Driver/fsanitize.c

Index: cfe/trunk/test/Driver/darwin-sanitizer-ld.c
===
--- cfe/trunk/test/Driver/darwin-sanitizer-ld.c
+++ cfe/trunk/test/Driver/darwin-sanitizer-ld.c
@@ -11,16 +11,6 @@
 // CHECK-ASAN: "-rpath" "{{.*}}lib{{.*}}darwin"
 
 // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
-// RUN:   -fsanitize=address -mios-simulator-version-min=7.0 %s -o %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ASAN-IOSSIM %s
-
-// CHECK-ASAN-IOSSIM: "{{.*}}ld{{(.exe)?}}"
-// CHECK-ASAN-IOSSIM: lc++
-// CHECK-ASAN-IOSSIM: libclang_rt.asan_iossim_dynamic.dylib"
-// CHECK-ASAN-IOSSIM: "-rpath" "@executable_path"
-// CHECK-ASAN-IOSSIM: "-rpath" "{{.*}}lib{{.*}}darwin"
-
-// RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
 // RUN:   -fPIC -shared -fsanitize=address %s -o %t.so 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-DYN-ASAN %s
 
@@ -65,3 +55,63 @@
 
 // CHECK-DYN-BOUNDS: "{{.*}}ld{{(.exe)?}}"
 // CHECK-DYN-BOUNDS-NOT: ubsan_osx
+
+// RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
+// RUN:   -fsanitize=address -mios-simulator-version-min=7.0 %s -o %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-IOSSIM %s
+
+// CHECK-ASAN-IOSSIM: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ASAN-IOSSIM: lc++
+// CHECK-ASAN-IOSSIM: libclang_rt.asan_iossim_dynamic.dylib"
+// CHECK-ASAN-IOSSIM: "-rpath" "@executable_path"
+// CHECK-ASAN-IOSSIM: "-rpath" "{{.*}}lib{{.*}}darwin"
+
+// RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
+// RUN:   -fsanitize=address -mtvos-simulator-version-min=8.3.0 %s -o %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-TVOSSIM %s
+
+// CHECK-ASAN-TVOSSIM: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ASAN-TVOSSIM: lc++
+// CHECK-ASAN-TVOSSIM: libclang_rt.asan_tvossim_dynamic.dylib"
+// CHECK-ASAN-TVOSSIM: "-rpath" "@executable_path"
+// CHECK-ASAN-TVOSSIM: "-rpath" "{{.*}}lib{{.*}}darwin"
+
+// RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
+// RUN:   -fsanitize=address -mwatchos-simulator-version-min=2.0.0 %s -o %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-WATCHOSSIM %s
+
+// CHECK-ASAN-WATCHOSSIM: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ASAN-WATCHOSSIM: lc++
+// CHECK-ASAN-WATCHOSSIM: libclang_rt.asan_watchossim_dynamic.dylib"
+// CHECK-ASAN-WATCHOSSIM: "-rpath" "@executable_path"
+// CHECK-ASAN-WATCHOSSIM: "-rpath" "{{.*}}lib{{.*}}darwin"
+
+// RUN: %clang -no-canonical-prefixes -### -target armv7-apple-ios  \
+// RUN:   -fsanitize=address -miphoneos-version-min=7 %s -o %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-IOS %s
+
+// CHECK-ASAN-IOS: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ASAN-IOS: lc++
+// CHECK-ASAN-IOS: libclang_rt.asan_ios_dynamic.dylib"
+// CHECK-ASAN-IOS: "-rpath" "@executable_path"
+// CHECK-ASAN-IOS: "-rpath" "{{.*}}lib{{.*}}darwin"
+
+// RUN: %clang -no-canonical-prefixes -### -target arm64-apple-tvos \
+// RUN:   -fsanitize=address -mtvos-version-min=8.3 %s -o %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-TVOS %s
+
+// CHECK-ASAN-TVOS: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ASAN-TVOS: lc++
+// CHECK-ASAN-TVOS: libclang_rt.asan_tvos_dynamic.dylib"
+// CHECK-ASAN-TVOS: "-rpath" "@executable_path"
+// CHECK-ASAN-TVOS: "-rpath" "{{.*}}lib{{.*}}darwin"
+
+// RUN: %clang -no-canonical-prefixes -### -target armv7k-apple-watchos \
+// RUN:   -fsanitize=address -mwatchos-version-min=2.0 %s -o %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-WATCHOS %s
+
+// CHECK-ASAN-WATCHOS: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ASAN-WATCHOS: lc++
+// CHECK-ASAN-WATCHOS: libclang_rt.asan_watchos_dynamic.dylib"
+// CHECK-ASAN-WATCHOS: "-rpath" "@executable_path"
+// CHECK-ASAN-WATCHOS: "-rpath" "{{.*}}lib{{.*}}darwin"
Index: cfe/trunk/test/Driver/fsanitize.c
===
--- cfe/trunk/test/Driver/fsanitize.c
+++ cfe/trunk/test/Driver/fsanitize.c
@@ -230,7 +230,7 @@
 // CHECK-VPTR-DARWIN-NEW: -fsanitize=alignment,vptr
 
 // RUN: %clang -target armv7-apple-ios7 -miphoneos-version-min=7.0 -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-IOS
-// CHECK-ASAN-IOS: unsupported option '-fsanitize=address' for target 'arm-apple-ios7'
+// CHECK-ASAN-IOS: -fsanitize=address
 
 // RUN: %clang -target i386-pc-openbsd -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-OPENBSD
 // CHECK-ASAN-OPENBSD: unsupported option '-fsanitize=address' for target 'i386-pc-openbsd'
Index: 

[PATCH] D16788: Ps4 ABI Round 2. Actual PS4 code.

2016-02-01 Thread Sunil Srivastava via cfe-commits
Sunil_Srivastava created this revision.
Sunil_Srivastava added reviewers: rjmccall, DmitryPolukhin, rsmith, probinson.
Sunil_Srivastava added a subscriber: cfe-commits.

This is the round 2 of the PS4 ABI. In this round:

1) A new value PS4 has been added to TargetCXXABI::Kind. It is being used for 
x86_64-scei-ps4 triple only.
2) RecordLayoutBuilder.cpp has been logically reverted back to pre r257462 
behavior for PS4 abi.
3) The test Sema/bitfield-layout.c has been enhanced by adding the PS4 triple, 
and few test entries that differ between PS4 and other triples, have been put 
under '#ifdef PS4'. Logically, the test has not changed for triples other than 
x86_64-scei-ps4. For x86_64-scei-ps4 triple, the test matches pre r257462 
behavior.

The test passes on all listed triples on x86 Linux and windows hosts.

http://reviews.llvm.org/D16788

Files:
  include/clang/Basic/TargetCXXABI.h
  lib/AST/ASTContext.cpp
  lib/AST/RecordLayoutBuilder.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  test/Sema/bitfield-layout.c

Index: test/Sema/bitfield-layout.c
===
--- test/Sema/bitfield-layout.c
+++ test/Sema/bitfield-layout.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=arm-linux-gnueabihf
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=aarch64-linux-gnu
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=x86_64-pc-linux-gnu
+// RUN: %clang_cc1 %s -fsyntax-only -verify -triple=x86_64-scei-ps4
 // expected-no-diagnostics
 #include 
 
@@ -96,9 +97,15 @@
   char c;
 };
 
+#if defined(__PS4__)
+CHECK_SIZE(struct, g0, 16);
+CHECK_ALIGN(struct, g0, 16);
+CHECK_OFFSET(struct, g0, c, 2);
+#else
 CHECK_SIZE(struct, g0, 32);
 CHECK_ALIGN(struct, g0, 16);
 CHECK_OFFSET(struct, g0, c, 17);
+#endif
 
 // Bit-field with explicit align smaller than normal.
 struct g1 {
@@ -109,7 +116,11 @@
 
 CHECK_SIZE(struct, g1, 4);
 CHECK_ALIGN(struct, g1, 4);
+#if defined(__PS4__)
+CHECK_OFFSET(struct, g1, c, 2);
+#else
 CHECK_OFFSET(struct, g1, c, 3);
+#endif
 
 // Same as above but without explicit align.
 struct g2 {
@@ -130,9 +141,14 @@
   char c;
 };
 
-CHECK_SIZE(struct, g3, 32);
 CHECK_ALIGN(struct, g3, 16);
+#if defined(__PS4__)
+CHECK_SIZE(struct, g3, 16);
+CHECK_OFFSET(struct, g3, c, 2);
+#else
+CHECK_SIZE(struct, g3, 32);
 CHECK_OFFSET(struct, g3, c, 17);
+#endif
 
 struct __attribute__((packed)) g4 {
   char a;
@@ -142,7 +158,11 @@
 
 CHECK_SIZE(struct, g4, 4);
 CHECK_ALIGN(struct, g4, 2);
+#if defined(__PS4__)
+CHECK_OFFSET(struct, g4, c, 2);
+#else
 CHECK_OFFSET(struct, g4, c, 3);
+#endif
 
 struct g5 {
   char : 1;
@@ -162,28 +182,44 @@
   char : 1;
   __attribute__((aligned(1))) int n : 25;
 };
+#if defined(__PS4__)
+CHECK_SIZE(struct, g7, 4);
+#else
 CHECK_SIZE(struct, g7, 8);
+#endif
 CHECK_ALIGN(struct, g7, 4);
 
 struct __attribute__((packed)) g8 {
   char : 1;
   __attribute__((aligned(1))) int n : 25;
 };
+#if defined(__PS4__)
+CHECK_SIZE(struct, g8, 4);
+#else
 CHECK_SIZE(struct, g8, 5);
+#endif
 CHECK_ALIGN(struct, g8, 1);
 
 struct g9 {
   __attribute__((aligned(1))) char a : 2, b : 2, c : 2, d : 2, e : 2;
   int i;
 };
+#if defined(__PS4__)
+CHECK_SIZE(struct, g9, 8);
+#else
 CHECK_SIZE(struct, g9, 12);
+#endif
 CHECK_ALIGN(struct, g9, 4);
 
 struct __attribute__((packed)) g10 {
   __attribute__((aligned(1))) char a : 2, b : 2, c : 2, d : 2, e : 2;
   int i;
 };
+#if defined(__PS4__)
+CHECK_SIZE(struct, g10, 6);
+#else
 CHECK_SIZE(struct, g10, 9);
+#endif
 CHECK_ALIGN(struct, g10, 1);
 
 struct g11 {
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -480,6 +480,7 @@
 return new WebAssemblyCXXABI(CGM);
 
   case TargetCXXABI::GenericItanium:
+  case TargetCXXABI::PS4:
 if (CGM.getContext().getTargetInfo().getTriple().getArch()
 == llvm::Triple::le32) {
   // For PNaCl, use ARM-style method pointers so that PNaCl code
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -69,6 +69,7 @@
   case TargetCXXABI::WatchOS:
   case TargetCXXABI::GenericMIPS:
   case TargetCXXABI::GenericItanium:
+  case TargetCXXABI::PS4:
   case TargetCXXABI::WebAssembly:
 return CreateItaniumCXXABI(CGM);
   case TargetCXXABI::Microsoft:
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -602,6 +602,9 @@
   PS4OSTargetInfo(const llvm::Triple ) : OSTargetInfo(Triple) {
 this->WCharType = this->UnsignedShort;
 
+// PS4 uses a variant of the C++11 ABI.
+this->TheCXXABI.set(TargetCXXABI::PS4);
+
 // On PS4, TLS variable cannot be aligned to more than 32 bytes (256 bits).
 this->MaxTLSAlign = 256;
 

Re: [PATCH] D16467: [libcxx] re.results.form: Format out-of-range subexpression references as null

2016-02-01 Thread Duncan P. N. Exon Smith via cfe-commits
dexonsmith added a subscriber: dexonsmith.
dexonsmith added a comment.

Ping.

Marshall, does this look okay?


http://reviews.llvm.org/D16467



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


Re: [PATCH] D16467: [libcxx] re.results.form: Format out-of-range subexpression references as null

2016-02-01 Thread Duncan P. N. Exon Smith via cfe-commits
Ping.

Marshall, does this look okay?

> On 2016-Jan-25, at 10:32, Duncan P. N. Exon Smith via cfe-commits 
>  wrote:
> 
> dexonsmith updated this revision to Diff 45879.
> dexonsmith added a comment.
> 
> Addressed Marshall's review comments: deferring to 
> match_results::operator[]() rather than duplicating the logic.
> 
> 
> http://reviews.llvm.org/D16467
> 
> Files:
>  include/regex
>  test/std/re/re.results/re.results.form/form1.pass.cpp
> 
> Index: test/std/re/re.results/re.results.form/form1.pass.cpp
> ===
> --- test/std/re/re.results/re.results.form/form1.pass.cpp
> +++ test/std/re/re.results/re.results.form/form1.pass.cpp
> @@ -38,6 +38,31 @@
> {
> std::match_results m;
> const char s[] = "abcdefghijk";
> +assert(std::regex_search(s, m, std::regex("cd((e)fg)hi",
> +  
> std::regex_constants::nosubs)));
> +
> +char out[100] = {0};
> +const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, 
> m[2]: $2";
> +char* r = m.format(output_iterator(out),
> +fmt, fmt + std::char_traits::length(fmt)).base();
> +assert(r == out + 54);
> +assert(std::string(out) == "prefix: ab, match: cdefghi, suffix: jk, 
> m[1]: , m[2]: ");
> +}
> +{
> +std::match_results m;
> +const char s[] = "abcdefghijk";
> +assert(std::regex_search(s, m, std::regex("cdefghi")));
> +
> +char out[100] = {0};
> +const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, 
> m[2]: $2";
> +char* r = m.format(output_iterator(out),
> +fmt, fmt + std::char_traits::length(fmt)).base();
> +assert(r == out + 54);
> +assert(std::string(out) == "prefix: ab, match: cdefghi, suffix: jk, 
> m[1]: , m[2]: ");
> +}
> +{
> +std::match_results m;
> +const char s[] = "abcdefghijk";
> assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
> 
> char out[100] = {0};
> @@ -61,6 +86,33 @@
> assert(r == out + 34);
> assert(std::string(out) == "match: cdefghi, m[1]: efg, m[2]: e");
> }
> +{
> +std::match_results m;
> +const char s[] = "abcdefghijk";
> +assert(std::regex_search(s, m, std::regex("cd((e)fg)hi",
> +  
> std::regex_constants::nosubs)));
> +
> +char out[100] = {0};
> +const char fmt[] = "match: &, m[1]: \\1, m[2]: \\2";
> +char* r = m.format(output_iterator(out),
> +fmt, fmt + std::char_traits::length(fmt),
> +std::regex_constants::format_sed).base();
> +assert(r == out + 30);
> +assert(std::string(out) == "match: cdefghi, m[1]: , m[2]: ");
> +}
> +{
> +std::match_results m;
> +const char s[] = "abcdefghijk";
> +assert(std::regex_search(s, m, std::regex("cdefghi")));
> +
> +char out[100] = {0};
> +const char fmt[] = "match: &, m[1]: \\1, m[2]: \\2";
> +char* r = m.format(output_iterator(out),
> +fmt, fmt + std::char_traits::length(fmt),
> +std::regex_constants::format_sed).base();
> +assert(r == out + 30);
> +assert(std::string(out) == "match: cdefghi, m[1]: , m[2]: ");
> +}
> 
> {
> std::match_results m;
> Index: include/regex
> ===
> --- include/regex
> +++ include/regex
> @@ -5387,8 +5387,8 @@
> if ('0' <= *__fmt_first && *__fmt_first <= '9')
> {
> size_t __i = *__fmt_first - '0';
> -__out = _VSTD::copy(__matches_[__i].first,
> -   __matches_[__i].second, __out);
> +__out = _VSTD::copy((*this)[__i].first,
> +(*this)[__i].second, __out);
> }
> else
> {
> @@ -5439,8 +5439,8 @@
> ++__fmt_first;
> __i = 10 * __i + *__fmt_first - '0';
> }
> -__out = _VSTD::copy(__matches_[__i].first,
> -   __matches_[__i].second, __out);
> +__out = _VSTD::copy((*this)[__i].first,
> +(*this)[__i].second, __out);
> }
> else
> {
> 
> 
> ___
> 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

[PATCH] D16792: unordered_map: Use __hash_table::__emplace_unique(), NFC

2016-02-01 Thread Duncan P. N. Exon Smith via cfe-commits
dexonsmith created this revision.
dexonsmith added a reviewer: EricWF.
dexonsmith added a subscriber: cfe-commits.

Instead of duplicating code in unordered_map::emplace(), use
__hash_table::__emplace_unique().

http://reviews.llvm.org/D16792

Files:
  include/unordered_map

Index: include/unordered_map
===
--- include/unordered_map
+++ include/unordered_map
@@ -922,7 +922,8 @@
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 
 template 
-pair emplace(_Args&&... __args);
+pair emplace(_Args&&... __args)
+{return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
 
 template 
 _LIBCPP_INLINE_VISIBILITY
@@ -1474,18 +1475,6 @@
 return __h;
 }
 
-template 
-template 
-pair::iterator, bool>
-unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args)
-{
-__node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
-pair __r = __table_.__node_insert_unique(__h.get());
-if (__r.second)
-__h.release();
-return __r;
-}
-
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 


Index: include/unordered_map
===
--- include/unordered_map
+++ include/unordered_map
@@ -922,7 +922,8 @@
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 
 template 
-pair emplace(_Args&&... __args);
+pair emplace(_Args&&... __args)
+{return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
 
 template 
 _LIBCPP_INLINE_VISIBILITY
@@ -1474,18 +1475,6 @@
 return __h;
 }
 
-template 
-template 
-pair::iterator, bool>
-unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args)
-{
-__node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
-pair __r = __table_.__node_insert_unique(__h.get());
-if (__r.second)
-__h.release();
-return __r;
-}
-
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16360: unordered_map: Avoid unnecessary mallocs when no insert occurs

2016-02-01 Thread Duncan P. N. Exon Smith via cfe-commits
Marshall, thanks for the link to #2464.  That does look scary.

Nevertheless, I think this -- and the other over-eager allocations
in {unordered_,}{multi,}{map,set} -- are worth optimizing as long
as we can do it in a standards-compliant way.  It's a pretty serious
regression in performance compared to expectations from C++03's
insert().

Let me know if you can think of some testing I can add to be sure
I'm not breaking anything (maybe test/std/.../ doesn't have enough
coverage?).

> On 2016-Jan-25, at 07:54, Marshall Clow  wrote:
> 
> mclow.lists added a comment.
> 
> I don't have any comments on this code at this time, but I want to caution 
> people that this part of the standard library is **extremely** carefully 
> specified, and meeting all the requirements is a fiddly bit of work.
> 
> For an example of this, look at LWG issue #2464, which has been added to the 
> draft C++17 standard.
> 
> 
> http://reviews.llvm.org/D16360
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16717: [clang-tidy] Add non-constant references in function parameters check.

2016-02-01 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 46510.
hokein added a comment.

Fix code style.


http://reviews.llvm.org/D16717

Files:
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/GoogleTidyModule.cpp
  clang-tidy/google/NonConstReferences.cpp
  clang-tidy/google/NonConstReferences.h
  docs/clang-tidy/checks/google-runtime-references.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/google-runtime-references.cpp

Index: test/clang-tidy/google-runtime-references.cpp
===
--- /dev/null
+++ test/clang-tidy/google-runtime-references.cpp
@@ -0,0 +1,139 @@
+// RUN: clang-tidy -checks=-*,google-runtime-references %s -- -std=c++11 | FileCheck -implicit-check-not='{{warning:|error:}}' %s
+
+int a;
+int  = a;
+int *c;
+void f1(int a);
+void f2(int *b);
+void f3(const int );
+void f4(int const );
+
+// Don't warn on implicit operator= in c++11 mode.
+class A {
+  virtual void f() {}
+};
+// Don't warn on rvalue-references.
+struct A2 {
+  A2(A2&&) = default;
+  void f(A2&&) {}
+};
+
+// Don't warn on iostream parameters.
+namespace xxx {
+class istream { };
+class ostringstream { };
+}
+void g1(xxx::istream );
+void g1(xxx::ostringstream );
+
+void g1(int );
+// CHECK: [[@LINE-1]]:14: warning: non-const reference parameter 'a', make it const or use a pointer [google-runtime-references]
+
+struct s {};
+void g2(int a, int b, s c, s );
+// CHECK: [[@LINE-1]]:31: warning: non-const reference parameter 'd', {{.*}}
+
+typedef int 
+void g3(ref a);
+// CHECK: [[@LINE-1]]:13: warning: non-const reference {{.*}}
+
+void g4(int , int , int &);
+// CHECK: [[@LINE-1]]:14: warning: non-const reference parameter 'a', {{.*}}
+// CHECK: [[@LINE-2]]:22: warning: non-const reference parameter 'b', {{.*}}
+// CHECK: [[@LINE-3]]:30: warning: non-const reference parameter '', {{.*}}
+
+class B {
+  B(B& a) {}
+// CHECK: [[@LINE-1]]:8: warning: non-const reference {{.*}}
+  virtual void f(int ) {}
+// CHECK: [[@LINE-1]]:23: warning: non-const reference {{.*}}
+  void g(int );
+// CHECK: [[@LINE-1]]:15: warning: non-const reference {{.*}}
+
+  // Don't warn on the parameter of stream extractors defined as members.
+  B& operator>>(int& val) { return *this; }
+};
+
+// Only warn on the first declaration of each function to reduce duplicate
+// warnings.
+void B::g(int ) {}
+
+// Don't warn on the first parameter of stream inserters.
+A& operator<<(A& s, int&) { return s; }
+// CHECK: [[@LINE-1]]:25: warning: non-const reference parameter '', {{.*}}
+
+// Don't warn on either parameter of stream extractors. Both need to be
+// non-const references by convention.
+A& operator>>(A& input, int& val) { return input; }
+
+// Don't warn on lambdas.
+auto lambda = [] (int&) {};
+
+// Don't warn on typedefs, as we'll warn on the function itself.
+typedef int (*fp)(int &);
+
+// Don't warn on function references.
+typedef void F();
+void g5(const F& func) {}
+void g6(F& func) {}
+
+template
+void g7(const T& t) {}
+
+template
+void g8(T t) {}
+
+void f5() {
+  g5(f5);
+  g6(f5);
+  g7(f5);
+  g7(f5);
+  g8(f5);
+  g8(f5);
+}
+
+// Don't warn on dependent types.
+template
+void g9(T& t) {}
+template
+void g10(T t) {}
+
+void f6() {
+  int i;
+  float f;
+  g9(i);
+  g9(i);
+  g9(i);
+  g10(i);
+  g10(f);
+}
+
+// Warn only on the overridden methods from the base class, as the child class
+// only implements the interface.
+class C : public B {
+  C();
+  virtual void f(int ) {}
+};
+
+// Don't warn on operator<< with streams-like interface.
+A& operator<<(A& s, int) { return s; }
+
+// Don't warn on swap().
+void swap(C& c1, C& c2) {}
+
+// Don't warn on standalone operator++, operator--, operator+=, operator-=,
+// operator*=, etc. that all need non-const references to be functional.
+A& operator++(A& a) { return a; }
+A operator++(A& a, int) { return a; }
+A& operator--(A& a) { return a; }
+A operator--(A& a, int) { return a; }
+A& operator+=(A& a, const A& b) { return a; }
+A& operator-=(A& a, const A& b) { return a; }
+A& operator*=(A& a, const A& b) { return a; }
+A& operator/=(A& a, const A& b) { return a; }
+A& operator%=(A& a, const A& b) { return a; }
+A& operator<<=(A& a, const A& b) { return a; }
+A& operator>>=(A& a, const A& b) { return a; }
+A& operator|=(A& a, const A& b) { return a; }
+A& operator^=(A& a, const A& b) { return a; }
+A& operator&=(A& a, const A& b) { return a; }
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -38,6 +38,7 @@
google-runtime-member-string-references
google-runtime-memset
google-runtime-operator
+   google-runtime-references
llvm-header-guard
llvm-include-order
llvm-namespace-comment
Index: docs/clang-tidy/checks/google-runtime-references.rst
===
--- /dev/null
+++ 

Re: [PATCH] D16351: [FIX] Bug 25404 - Crash on typedef in OpenCL 2.0

2016-02-01 Thread Igor Chesnokov via cfe-commits
ichesnokov added a comment.

> majnemer: Why isn't this logic buried in GetArgumentVector so that other 
> tools may take advantage of it?


Sorry, I do not understand what you say.
I looked into GetArgumentVector and this function is dummy now in both Unix and 
Windows, and it does not look like correct place to implement this fix.
Could you please clarify what the change do you propose?

This fix is global, not only for OpenCL. The patch is .cl because initial bugs 
is for OpenCL.
What can I do is generalizing the bug by adding patch in .c.


Repository:
  rL LLVM

http://reviews.llvm.org/D16351



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


Re: [PATCH] D16063: [Analyzer] Use a wider integer type for an array index

2016-02-01 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL259345: [analyzer] Use a wider integer type for an array 
index. (authored by dergachev).

Changed prior to commit:
  http://reviews.llvm.org/D16063?vs=44606=46513#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16063

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  cfe/trunk/test/Analysis/index-type.c

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
@@ -65,7 +65,7 @@
   SymMgr(context, BasicVals, alloc),
   MemMgr(context, alloc),
   StateMgr(stateMgr),
-  ArrayIndexTy(context.IntTy),
+  ArrayIndexTy(context.LongLongTy),
   ArrayIndexWidth(context.getTypeSize(ArrayIndexTy)) {}
 
   virtual ~SValBuilder() {}
Index: cfe/trunk/test/Analysis/index-type.c
===
--- cfe/trunk/test/Analysis/index-type.c
+++ cfe/trunk/test/Analysis/index-type.c
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze 
-analyzer-checker=core,alpha.security.ArrayBoundV2 -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze 
-analyzer-checker=core,alpha.security.ArrayBoundV2 -DM32 -verify %s
+// expected-no-diagnostics
+
+#define UINT_MAX (~0u)
+
+#ifdef M32
+
+#define X86_ARRAY_SIZE (UINT_MAX/2 + 4)
+
+void testIndexTooBig() {
+  char arr[X86_ARRAY_SIZE];
+  char *ptr = arr + UINT_MAX/2;
+  ptr += 2;  // index shouldn't overflow
+  *ptr = 42; // no-warning
+}
+
+#else // 64-bit tests
+
+#define ARRAY_SIZE 0x1
+
+void testIndexOverflow64() {
+  char arr[ARRAY_SIZE];
+  char *ptr = arr + UINT_MAX/2;
+  ptr += 2;  // don't overflow 64-bit index
+  *ptr = 42; // no-warning
+}
+
+#define ULONG_MAX (~0ul)
+#define BIG_INDEX (ULONG_MAX/16)
+
+void testIndexTooBig64() {
+  char arr[ULONG_MAX/8-1];
+  char *ptr = arr + BIG_INDEX;
+  ptr += 2;  // don't overflow 64-bit index
+  *ptr = 42; // no-warning
+}
+
+#endif


Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
@@ -65,7 +65,7 @@
   SymMgr(context, BasicVals, alloc),
   MemMgr(context, alloc),
   StateMgr(stateMgr),
-  ArrayIndexTy(context.IntTy),
+  ArrayIndexTy(context.LongLongTy),
   ArrayIndexWidth(context.getTypeSize(ArrayIndexTy)) {}
 
   virtual ~SValBuilder() {}
Index: cfe/trunk/test/Analysis/index-type.c
===
--- cfe/trunk/test/Analysis/index-type.c
+++ cfe/trunk/test/Analysis/index-type.c
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,alpha.security.ArrayBoundV2 -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,alpha.security.ArrayBoundV2 -DM32 -verify %s
+// expected-no-diagnostics
+
+#define UINT_MAX (~0u)
+
+#ifdef M32
+
+#define X86_ARRAY_SIZE (UINT_MAX/2 + 4)
+
+void testIndexTooBig() {
+  char arr[X86_ARRAY_SIZE];
+  char *ptr = arr + UINT_MAX/2;
+  ptr += 2;  // index shouldn't overflow
+  *ptr = 42; // no-warning
+}
+
+#else // 64-bit tests
+
+#define ARRAY_SIZE 0x1
+
+void testIndexOverflow64() {
+  char arr[ARRAY_SIZE];
+  char *ptr = arr + UINT_MAX/2;
+  ptr += 2;  // don't overflow 64-bit index
+  *ptr = 42; // no-warning
+}
+
+#define ULONG_MAX (~0ul)
+#define BIG_INDEX (ULONG_MAX/16)
+
+void testIndexTooBig64() {
+  char arr[ULONG_MAX/8-1];
+  char *ptr = arr + BIG_INDEX;
+  ptr += 2;  // don't overflow 64-bit index
+  *ptr = 42; // no-warning
+}
+
+#endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16764: Move incorrect-roundings to upstream.

2016-02-01 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: alexfh.
hokein added subscribers: jpienaar, cfe-commits.

This is originally implemented by Jacques Pienaar.

http://reviews.llvm.org/D16764

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/IncorrectRoundings.cpp
  clang-tidy/misc/IncorrectRoundings.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-incorrect-roundings.rst
  test/clang-tidy/misc-incorrect-roundings.cpp

Index: test/clang-tidy/misc-incorrect-roundings.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-incorrect-roundings.cpp
@@ -0,0 +1,86 @@
+// RUN: %check_clang_tidy %s misc-incorrect-roundings %t
+
+void b(int x) {}
+
+void f1() {
+  float f;
+  double d;
+  long double ld;
+  int x;
+
+  x = (d + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5) to integer leads to incorrect rounding; consider using lrint (#include ) instead [misc-incorrect-roundings]
+  x = (d + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (f + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (f + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (0.5 + d);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (0.5f + d);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (0.5 + ld);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (0.5f + ld);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (0.5 + f);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (0.5f + f);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (int)(d + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(d + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(ld + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(ld + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(f + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(f + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(0.5 + d);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(0.5f + d);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(0.5 + ld);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(0.5f + ld);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(0.5 + f);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(0.5f + f);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = static_cast(d + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(d + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(ld + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(ld + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(f + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(f + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(0.5 + d);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(0.5f + d);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(0.5 + ld);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(0.5f + ld);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(0.5 + f);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(0.5f + f);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+
+  // Don't warn if constant is not 0.5.
+  x = (int)(d + 0.6);
+  x = (int)(0.6 + d);
+
+  // Don't warn if binary operator is not directly beneath cast.
+  x = (int)(1 + (0.5 + f));
+}
Index: docs/clang-tidy/checks/misc-incorrect-roundings.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-incorrect-roundings.rst
@@ -0,0 +1,12 @@
+misc-incorrect-roundings
+
+
+Checks the usage of patterns known to produce incorrect rounding.
+Programmers often use
+  (int)(double_expression + 0.5)
+to round the double expression to an integer. The problem with this:
+
+1. It is unnecessarily slow.
+2. It is incorrect. The number 0.49975 (smallest representable float
+   number below 0.5) rounds to 1.0. Even worse behavior for negative
+   numbers where both 

Re: [PATCH] D16765: [Clang-Format] Add option for spacing between function parameters

2016-02-01 Thread Daniel Jasper via cfe-commits
djasper added a comment.

Please read 
http://clang.llvm.org/docs/ClangFormatStyleOptions.html#adding-additional-style-options


http://reviews.llvm.org/D16765



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


Re: [PATCH] D16764: Move incorrect-roundings to upstream.

2016-02-01 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 46515.
hokein added a comment.

Update


http://reviews.llvm.org/D16764

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/IncorrectRoundings.cpp
  clang-tidy/misc/IncorrectRoundings.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-incorrect-roundings.rst
  test/clang-tidy/misc-incorrect-roundings.cpp

Index: test/clang-tidy/misc-incorrect-roundings.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-incorrect-roundings.cpp
@@ -0,0 +1,86 @@
+// RUN: %check_clang_tidy %s misc-incorrect-roundings %t
+
+void b(int x) {}
+
+void f1() {
+  float f;
+  double d;
+  long double ld;
+  int x;
+
+  x = (d + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5) to integer leads to incorrect rounding; consider using lrint (#include ) instead [misc-incorrect-roundings]
+  x = (d + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (f + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (f + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (0.5 + d);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (0.5f + d);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (0.5 + ld);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (0.5f + ld);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (0.5 + f);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (0.5f + f);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: casting (double + 0.5)
+  x = (int)(d + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(d + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(ld + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(ld + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(f + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(f + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(0.5 + d);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(0.5f + d);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(0.5 + ld);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(0.5f + ld);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(0.5 + f);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = (int)(0.5f + f);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: casting (double + 0.5)
+  x = static_cast(d + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(d + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(ld + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(ld + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(f + 0.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(f + 0.5f);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(0.5 + d);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(0.5f + d);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(0.5 + ld);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(0.5f + ld);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(0.5 + f);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+  x = static_cast(0.5f + f);
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: casting (double + 0.5)
+
+  // Don't warn if constant is not 0.5.
+  x = (int)(d + 0.6);
+  x = (int)(0.6 + d);
+
+  // Don't warn if binary operator is not directly beneath cast.
+  x = (int)(1 + (0.5 + f));
+}
Index: docs/clang-tidy/checks/misc-incorrect-roundings.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-incorrect-roundings.rst
@@ -0,0 +1,12 @@
+misc-incorrect-roundings
+
+
+Checks the usage of patterns known to produce incorrect rounding.
+Programmers often use
+  (int)(double_expression + 0.5)
+to round the double expression to an integer. The problem with this:
+
+1. It is unnecessarily slow.
+2. It is incorrect. The number 0.49975 (smallest representable float
+   number below 0.5) rounds to 1.0. Even worse behavior for negative
+   numbers where both -0.5f and -1.4f both round to 0.0.
Index: docs/clang-tidy/checks/list.rst

Re: [PATCH] D15040: [ARM] Add command-line options for ARMv8.2-A

2016-02-01 Thread Oliver Stannard via cfe-commits
olista01 added a comment.

Ping?


http://reviews.llvm.org/D15040



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


r259376 - Move LocInfoType from Sema to AST.

2016-02-01 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Feb  1 11:42:01 2016
New Revision: 259376

URL: http://llvm.org/viewvc/llvm-project?rev=259376=rev
Log:
Move LocInfoType from Sema to AST.

While transient and only used during parsing, LocInfoTypes are still used
from ASTDumper and are part of the AST.

Added:
cfe/trunk/include/clang/AST/LocInfoType.h
  - copied, changed from r259366, cfe/trunk/include/clang/Sema/LocInfoType.h
Removed:
cfe/trunk/include/clang/Sema/LocInfoType.h
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ASTConsumer.cpp
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp

Copied: cfe/trunk/include/clang/AST/LocInfoType.h (from r259366, 
cfe/trunk/include/clang/Sema/LocInfoType.h)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/LocInfoType.h?p2=cfe/trunk/include/clang/AST/LocInfoType.h=cfe/trunk/include/clang/Sema/LocInfoType.h=259366=259376=259376=diff
==
--- cfe/trunk/include/clang/Sema/LocInfoType.h (original)
+++ cfe/trunk/include/clang/AST/LocInfoType.h Mon Feb  1 11:42:01 2016
@@ -36,11 +36,10 @@ class LocInfoType : public Type {
   TypeSourceInfo *DeclInfo;
 
   LocInfoType(QualType ty, TypeSourceInfo *TInfo)
-: Type((TypeClass)LocInfo, ty, ty->isDependentType(),
-   ty->isInstantiationDependentType(),
-   ty->isVariablyModifiedType(),
-   ty->containsUnexpandedParameterPack()),
-  DeclInfo(TInfo) {
+  : Type((TypeClass)LocInfo, ty, ty->isDependentType(),
+ ty->isInstantiationDependentType(), ty->isVariablyModifiedType(),
+ ty->containsUnexpandedParameterPack()),
+DeclInfo(TInfo) {
 assert(getTypeClass() == (TypeClass)LocInfo && "LocInfo didn't fit in 
TC?");
   }
   friend class Sema;

Removed: cfe/trunk/include/clang/Sema/LocInfoType.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/LocInfoType.h?rev=259375=auto
==
--- cfe/trunk/include/clang/Sema/LocInfoType.h (original)
+++ cfe/trunk/include/clang/Sema/LocInfoType.h (removed)
@@ -1,62 +0,0 @@
-//===--- LocInfoType.h - Parsed Type with Location Information---*- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-//
-// This file defines the LocInfoType class, which holds a type and its
-// source-location information.
-//
-//===--===//
-#ifndef LLVM_CLANG_SEMA_LOCINFOTYPE_H
-#define LLVM_CLANG_SEMA_LOCINFOTYPE_H
-
-#include "clang/AST/Type.h"
-
-namespace clang {
-
-class TypeSourceInfo;
-
-/// \brief Holds a QualType and a TypeSourceInfo* that came out of a declarator
-/// parsing.
-///
-/// LocInfoType is a "transient" type, only needed for passing to/from Parser
-/// and Sema, when we want to preserve type source info for a parsed type.
-/// It will not participate in the type system semantics in any way.
-class LocInfoType : public Type {
-  enum {
-// The last number that can fit in Type's TC.
-// Avoids conflict with an existing Type class.
-LocInfo = Type::TypeLast + 1
-  };
-
-  TypeSourceInfo *DeclInfo;
-
-  LocInfoType(QualType ty, TypeSourceInfo *TInfo)
-: Type((TypeClass)LocInfo, ty, ty->isDependentType(),
-   ty->isInstantiationDependentType(),
-   ty->isVariablyModifiedType(),
-   ty->containsUnexpandedParameterPack()),
-  DeclInfo(TInfo) {
-assert(getTypeClass() == (TypeClass)LocInfo && "LocInfo didn't fit in 
TC?");
-  }
-  friend class Sema;
-
-public:
-  QualType getType() const { return getCanonicalTypeInternal(); }
-  TypeSourceInfo *getTypeSourceInfo() const { return DeclInfo; }
-
-  void getAsStringInternal(std::string ,
-   const PrintingPolicy ) const;
-
-  static bool classof(const Type *T) {
-return T->getTypeClass() == (TypeClass)LocInfo;
-  }
-};
-
-} // end namespace clang
-
-#endif // LLVM_CLANG_SEMA_LOCINFOTYPE_H

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=259376=259375=259376=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Feb  1 11:42:01 2016
@@ -20,6 +20,7 @@
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/ExternalASTSource.h"
+#include "clang/AST/LocInfoType.h"
 #include "clang/AST/MangleNumberingContext.h"
 #include "clang/AST/NSAPI.h"
 #include "clang/AST/PrettyPrinter.h"
@@ -35,7 +36,6 @@
 #include "clang/Sema/DeclSpec.h"
 #include 

Re: [PATCH] D15305: [CUDA] Do not allow dynamic initialization of global device side variables.

2016-02-01 Thread Jacques Pienaar via cfe-commits
jpienaar added a comment.

@jlebar: We defer it to your and Richard's approval. Thanks


http://reviews.llvm.org/D15305



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


r259355 - Remove the egregious PCHContainer layering hack that doesn't seem to be necessary anymore.

2016-02-01 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Feb  1 07:22:39 2016
New Revision: 259355

URL: http://llvm.org/viewvc/llvm-project?rev=259355=rev
Log:
Remove the egregious PCHContainer layering hack that doesn't seem to be 
necessary anymore.

Modified:
cfe/trunk/lib/Basic/FileManager.cpp
cfe/trunk/lib/Frontend/PCHContainerOperations.cpp

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=259355=259354=259355=diff
==
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Mon Feb  1 07:22:39 2016
@@ -19,7 +19,6 @@
 
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemStatCache.h"
-#include "clang/Frontend/PCHContainerOperations.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/ADT/STLExtras.h"
@@ -564,7 +563,3 @@ void FileManager::PrintStats() const {
 
   //llvm::errs() << PagesMapped << BytesOfPagesMapped << FSLookups;
 }
-
-// Virtual destructors for abstract base classes that need live in Basic.
-PCHContainerWriter::~PCHContainerWriter() {}
-PCHContainerReader::~PCHContainerReader() {}

Modified: cfe/trunk/lib/Frontend/PCHContainerOperations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHContainerOperations.cpp?rev=259355=259354=259355=diff
==
--- cfe/trunk/lib/Frontend/PCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHContainerOperations.cpp Mon Feb  1 07:22:39 2016
@@ -19,6 +19,9 @@
 
 using namespace clang;
 
+PCHContainerWriter::~PCHContainerWriter() {}
+PCHContainerReader::~PCHContainerReader() {}
+
 namespace {
 
 /// \brief A PCHContainerGenerator that writes out the PCH to a flat file.


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


Re: [PATCH] D16686: [OpenCL] Generate metadata for opencl_unroll_hint attribute

2016-02-01 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 46526.
yaxunl added a comment.

update the tests.


http://reviews.llvm.org/D16686

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  lib/CodeGen/CGLoopInfo.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseStmt.cpp
  lib/Sema/SemaStmtAttr.cpp
  test/CodeGenOpenCL/unroll-hint.cl
  test/Parser/opencl-unroll-hint.cl
  test/SemaOpenCL/unroll-hint.cl

Index: test/SemaOpenCL/unroll-hint.cl
===
--- /dev/null
+++ test/SemaOpenCL/unroll-hint.cl
@@ -0,0 +1,19 @@
+//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s
+
+kernel void C (global int *x) {
+  int I = 3;
+  __attribute__((opencl_unroll_hint(I))) // expected-error {{opencl_unroll_hint attribute requires an integer constant}}
+  while (I--);
+}
+
+kernel void D (global int *x) {
+  int i = 10;
+  __attribute__((opencl_unroll_hint))
+  do {
+  } while(i--);
+}
+
+kernel void E() {
+  __attribute__((opencl_unroll_hint(2,4))) // expected-error {{1 attribute takes no more than 1 argument}}
+  for(int i=0; i<100; i++);
+}
Index: test/Parser/opencl-unroll-hint.cl
===
--- /dev/null
+++ test/Parser/opencl-unroll-hint.cl
@@ -0,0 +1,8 @@
+//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s
+
+kernel void B (global int *x) {
+  __attribute__((opencl_unroll_hint(42)))
+  if (x[0]) // expected-error {{OpenCL only supports opencl_unroll_hint attribute on for, while, and do statements}}
+x[0] = 15;
+}
+
Index: test/CodeGenOpenCL/unroll-hint.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/unroll-hint.cl
@@ -0,0 +1,114 @@
+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+
+/*** for ***/
+void for_count(int* sum)
+{
+// CHECK-LABEL: for_count
+__attribute__((opencl_unroll_hint(8)))
+for( int i = 0; i < 1000; ++i) {
+*sum += i;
+}
+// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_COUNT:.*]]
+}
+
+void for_disable(int* sum)
+{
+// CHECK-LABEL: for_disable
+__attribute__((opencl_unroll_hint(1)))
+for( int i = 0; i < 1000; ++i) {
+*sum += i;
+}
+// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_DISABLE:.*]]
+}
+
+void for_full(int* sum)
+{
+// CHECK-LABEL: for_full
+__attribute__((opencl_unroll_hint))
+for( int i = 0; i < 1000; ++i) {
+*sum += i;
+}
+// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_FULL:.*]]
+}
+
+/*** while ***/
+void while_count(int* sum)
+{
+// CHECK-LABEL: while_count
+int i = 1000;
+__attribute__((opencl_unroll_hint(8)))
+while(i-->0) {
+*sum += i;
+}
+// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_COUNT:.*]]
+}
+
+void while_disable(int* sum)
+{
+// CHECK-LABEL: while_disable
+int i = 1000;
+__attribute__((opencl_unroll_hint(1)))
+while(i-->0) {
+*sum += i;
+}
+// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_DISABLE:.*]]
+}
+
+void while_full(int* sum)
+{
+// CHECK-LABEL: while_full
+int i = 1000;
+__attribute__((opencl_unroll_hint))
+while(i-->0) {
+*sum += i;
+}
+// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_FULL:.*]]
+}
+
+/*** do ***/
+void do_count(int* sum)
+{
+// CHECK-LABEL: do_count
+int i = 1000;
+__attribute__((opencl_unroll_hint(8)))
+do {
+*sum += i;
+} while(i--> 0);
+// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_COUNT:.*]]
+}
+
+void do_disable(int* sum)
+{
+// CHECK-LABEL: do_disable
+int i = 1000;
+__attribute__((opencl_unroll_hint(1)))
+do {
+*sum += i;
+} while(i--> 0);
+// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_DISABLE:.*]]
+}
+
+void do_full(int* sum)
+{
+// CHECK-LABEL: do_full
+int i = 1000;
+__attribute__((opencl_unroll_hint))
+do {
+*sum += i;
+} while(i--> 0);
+// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_FULL:.*]]
+}
+
+
+// CHECK: ![[FOR_COUNT]] =  distinct !{![[FOR_COUNT]],  ![[COUNT:.*]]}
+// CHECK: ![[COUNT]] =  !{!"llvm.loop.unroll.count", i32 8}
+// CHECK: ![[FOR_DISABLE]]   =  distinct !{![[FOR_DISABLE]],  ![[DISABLE:.*]]}
+// CHECK: ![[DISABLE]]   =  !{!"llvm.loop.unroll.disable"}
+// CHECK: ![[FOR_FULL]]  =  distinct !{![[FOR_FULL]],  ![[FULL:.*]]}
+// CHECK: ![[FULL]]  =  !{!"llvm.loop.unroll.full"}
+// CHECK: ![[WHILE_COUNT]]   =  distinct !{![[WHILE_COUNT]],![[COUNT]]}
+// CHECK: ![[WHILE_DISABLE]] =  distinct !{![[WHILE_DISABLE]],  ![[DISABLE]]}
+// CHECK: ![[WHILE_FULL]]=  distinct !{![[WHILE_FULL]], ![[FULL]]}
+// CHECK: ![[DO_COUNT]]  =  distinct !{![[DO_COUNT]],   ![[COUNT]]}
+// CHECK: ![[DO_DISABLE]]=  distinct !{![[DO_DISABLE]], ![[DISABLE]]}
+// 

r259345 - [analyzer] Use a wider integer type for an array index.

2016-02-01 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Feb  1 03:29:17 2016
New Revision: 259345

URL: http://llvm.org/viewvc/llvm-project?rev=259345=rev
Log:
[analyzer] Use a wider integer type for an array index.

Avoids unexpected overflows while performing pointer arithmetics in 64-bit code.
Moreover, neither PointerDiffType nor 'int' can be used as a common array index
type because arrays may have size (and indexes) more than PTRDIFF_MAX but less
than SIZE_MAX.

Patch by Aleksei Sidorin!

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

Added:
cfe/trunk/test/Analysis/index-type.c
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h?rev=259345=259344=259345=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h Mon 
Feb  1 03:29:17 2016
@@ -65,7 +65,7 @@ public:
   SymMgr(context, BasicVals, alloc),
   MemMgr(context, alloc),
   StateMgr(stateMgr),
-  ArrayIndexTy(context.IntTy),
+  ArrayIndexTy(context.LongLongTy),
   ArrayIndexWidth(context.getTypeSize(ArrayIndexTy)) {}
 
   virtual ~SValBuilder() {}

Added: cfe/trunk/test/Analysis/index-type.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/index-type.c?rev=259345=auto
==
--- cfe/trunk/test/Analysis/index-type.c (added)
+++ cfe/trunk/test/Analysis/index-type.c Mon Feb  1 03:29:17 2016
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze 
-analyzer-checker=core,alpha.security.ArrayBoundV2 -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze 
-analyzer-checker=core,alpha.security.ArrayBoundV2 -DM32 -verify %s
+// expected-no-diagnostics
+
+#define UINT_MAX (~0u)
+
+#ifdef M32
+
+#define X86_ARRAY_SIZE (UINT_MAX/2 + 4)
+
+void testIndexTooBig() {
+  char arr[X86_ARRAY_SIZE];
+  char *ptr = arr + UINT_MAX/2;
+  ptr += 2;  // index shouldn't overflow
+  *ptr = 42; // no-warning
+}
+
+#else // 64-bit tests
+
+#define ARRAY_SIZE 0x1
+
+void testIndexOverflow64() {
+  char arr[ARRAY_SIZE];
+  char *ptr = arr + UINT_MAX/2;
+  ptr += 2;  // don't overflow 64-bit index
+  *ptr = 42; // no-warning
+}
+
+#define ULONG_MAX (~0ul)
+#define BIG_INDEX (ULONG_MAX/16)
+
+void testIndexTooBig64() {
+  char arr[ULONG_MAX/8-1];
+  char *ptr = arr + BIG_INDEX;
+  ptr += 2;  // don't overflow 64-bit index
+  *ptr = 42; // no-warning
+}
+
+#endif


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


[PATCH] D16765: [Clang-Format] Add option for spacing between function parameters

2016-02-01 Thread Kai Wolf via cfe-commits
NewProggie created this revision.
NewProggie added reviewers: poiru, djasper, klimek.
NewProggie added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

This patch adds an option to remove the blank after comma between several 
function parameters. The default value is still to keep the blank.

http://reviews.llvm.org/D16765

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

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -10954,6 +10954,19 @@
   verifyFormat("A();", Spaces);
 }
 
+TEST_F(FormatTest, SpacesBetweenFunctionParameters) {
+  FormatStyle Spaces = getLLVMStyle();
+  Spaces.SpacesBetweenFunctionParameters = false;
+
+  verifyFormat("void foo(int a);", Spaces);
+  verifyFormat("void foo(int a,double b);", Spaces);
+  verifyFormat("void foo(int a,double b,char c);", Spaces);
+
+  Spaces.SpacesBetweenFunctionParameters = true;
+  verifyFormat("void foo(int a, double b);", Spaces);
+  verifyFormat("void foo(int a, double b, char c);", Spaces);
+}
+
 TEST_F(FormatTest, TripleAngleBrackets) {
   verifyFormat("f<<<1, 1>>>();");
   verifyFormat("f<<<1, 1, 1, s>>>();");
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2074,7 +2074,7 @@
   if (Right.is(TT_OverloadedOperatorLParen))
 return Style.SpaceBeforeParens == FormatStyle::SBPO_Always;
   if (Left.is(tok::comma))
-return true;
+return Style.SpacesBetweenFunctionParameters;
   if (Right.is(tok::comma))
 return false;
   if (Right.isOneOf(TT_CtorInitializerColon, TT_ObjCBlockLParen))
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -322,6 +322,8 @@
 IO.mapOptional("SpaceInEmptyParentheses", Style.SpaceInEmptyParentheses);
 IO.mapOptional("SpacesBeforeTrailingComments",
Style.SpacesBeforeTrailingComments);
+IO.mapOptional("SpacesBetweenFunctionParameters",
+   Style.SpacesBetweenFunctionParameters);
 IO.mapOptional("SpacesInAngles", Style.SpacesInAngles);
 IO.mapOptional("SpacesInContainerLiterals",
Style.SpacesInContainerLiterals);
@@ -516,6 +518,7 @@
   LLVMStyle.ObjCSpaceBeforeProtocolList = true;
   LLVMStyle.PointerAlignment = FormatStyle::PAS_Right;
   LLVMStyle.SpacesBeforeTrailingComments = 1;
+  LLVMStyle.SpacesBetweenFunctionParameters = true;
   LLVMStyle.Standard = FormatStyle::LS_Cpp11;
   LLVMStyle.UseTab = FormatStyle::UT_Never;
   LLVMStyle.ReflowComments = true;
@@ -561,6 +564,7 @@
   GoogleStyle.ObjCSpaceBeforeProtocolList = false;
   GoogleStyle.PointerAlignment = FormatStyle::PAS_Left;
   GoogleStyle.SpacesBeforeTrailingComments = 2;
+  GoogleStyle.SpacesBetweenFunctionParameters = true;
   GoogleStyle.Standard = FormatStyle::LS_Auto;
 
   GoogleStyle.PenaltyReturnTypeOnItsOwnLine = 200;
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -539,6 +539,9 @@
   /// commonly have different usage patterns and a number of special cases.
   unsigned SpacesBeforeTrailingComments;
 
+  /// \b If \c true, spaces will be inserted between function parameters.
+  bool SpacesBetweenFunctionParameters;
+
   /// \brief If \c true, spaces will be inserted after '<' and before '>' in
   /// template argument lists
   bool SpacesInAngles;
@@ -657,6 +660,8 @@
SpaceBeforeParens == R.SpaceBeforeParens &&
SpaceInEmptyParentheses == R.SpaceInEmptyParentheses &&
SpacesBeforeTrailingComments == R.SpacesBeforeTrailingComments &&
+   SpacesBetweenFunctionParameters ==
+   R.SpacesBetweenFunctionParameters &&
SpacesInAngles == R.SpacesInAngles &&
SpacesInContainerLiterals == R.SpacesInContainerLiterals &&
SpacesInCStyleCastParentheses == R.SpacesInCStyleCastParentheses &&
Index: docs/ClangFormatStyleOptions.rst
===
--- docs/ClangFormatStyleOptions.rst
+++ docs/ClangFormatStyleOptions.rst
@@ -611,6 +611,9 @@
   This does not affect trailing block comments (``/**/`` - comments) as those
   commonly have different usage patterns and a number of special cases.
 
+**SpacesBetweenFunctionParameters** (``bool``)
+  If ``true``, a space will be inserted between several function parameters.
+
 **SpacesInAngles** (``bool``)
   If ``true``, spaces will be inserted after '<' and before '>' in
   template argument lists
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

r259359 - Reapply r259210 with a fix for RegistryTest.cpp.

2016-02-01 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Feb  1 08:11:47 2016
New Revision: 259359

URL: http://llvm.org/viewvc/llvm-project?rev=259359=rev
Log:
Reapply r259210 with a fix for RegistryTest.cpp.

Patch by Richard Thomson.

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

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=259359=259358=259359=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Mon Feb  1 08:11:47 2016
@@ -1308,6 +1308,18 @@ c and d.
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Type.html;>TypefunctionProtoTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html;>FunctionProtoType...
+Matches 
FunctionProtoType nodes.
+
+Given
+  int (*f)(int);
+  void g();
+functionProtoType()
+  matches "int (*f)(int)" and the type of "g" in C++ mode.
+  In C mode, "g" is not matched because it does not contain a prototype.
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Type.html;>TypefunctionTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1FunctionType.html;>FunctionType...
 Matches FunctionType 
nodes.
 
@@ -2335,13 +2347,40 @@ compiled in C mode.
 
 
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html;>FunctionDeclparameterCountIsunsigned N
-Matches 
FunctionDecls that have a specific parameter count.
+Matches 
FunctionDecls and FunctionProtoTypes that have a
+specific parameter count.
+
+Given
+  void f(int i) {}
+  void g(int i, int j) {}
+  void h(int i, int j);
+  void j(int i);
+  void k(int x, int y, int z, ...);
+functionDecl(parameterCountIs(2))
+  matches void g(int i, int j) {}
+functionProtoType(parameterCountIs(2))
+  matches void h(int i, int j)
+functionProtoType(parameterCountIs(3))
+  matches void k(int x, int y, int z, ...);
+
+
+
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html;>FunctionProtoTypeparameterCountIsunsigned N
+Matches 
FunctionDecls and FunctionProtoTypes that have a
+specific parameter count.
 
 Given
   void f(int i) {}
   void g(int i, int j) {}
+  void h(int i, int j);
+  void j(int i);
+  void k(int x, int y, int z, ...);
 functionDecl(parameterCountIs(2))
-  matches g(int i, int j) {}
+  matches void g(int i, int j) {}
+functionProtoType(parameterCountIs(2))
+  matches void h(int i, int j)
+functionProtoType(parameterCountIs(3))
+  matches void k(int x, int y, int z, ...);
 
 
 
@@ -3995,8 +4034,8 @@ actual casts "explicit" casts.)
 
 
 
-Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Expr.html;>ExprhasTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>Decl 
InnerMatcher
-Overloaded to match the 
declaration of the expression's or value
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Expr.html;>ExprhasTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>Decl 
InnerMatcher
+Overloaded to match the 
declaration of the expression's or value
 declaration's type.
 
 In case of a value declaration (for example a variable declaration),
@@ -4020,8 +4059,10 @@ matcher.
 
 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")
 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")
+and U (matcher = typedefDecl(hasType(asString("int")))
  class X {};
  void y(X x) { x; X z; }
+ typedef int U;
 
 
 
@@ -4796,6 +4837,19 @@ Usable as: Any Matcher
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1TypedefDecl.html;>TypedefDeclhasTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1QualType.html;>QualType
 InnerMatcher
+Matches if the expression's 
or declaration's type matches a type
+matcher.
+
+Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")
+and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")
+and U (matcher = typedefDecl(hasType(asString("int")))
+ class X {};
+ void y(X x) { x; X z; }
+ typedef int U;
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1TypedefType.html;>TypedefTypehasDeclarationMatcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>Decl  
InnerMatcher
 Matches a node if 
the declaration associated with that node
 matches the given matcher.
@@ -4881,8 +4935,8 @@ usingDecl(hasAnyUsingShadowDecl(hasTarge
   matches using X::b but not using X::a 
 
 
-Matcherhttp://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html;>ValueDeclhasTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>Decl 
InnerMatcher
-Overloaded to match the 
declaration of the expression's or value

Re: [PATCH] D8149: Extend hasType narrowing matcher for TypedefDecls, add functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes

2016-02-01 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

I haven't quite figured out the proper phab workflow for reverts yet either, 
but I took the updated patch, applied it, and commit in r259359. Thank you for 
the fix!


http://reviews.llvm.org/D8149



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


Re: r259260 - [UBSan] Add documentation for runtime issue suppression.

2016-02-01 Thread Hans Wennborg via cfe-commits
On Fri, Jan 29, 2016 at 4:50 PM, Alexey Samsonov  wrote:
>
> On Fri, Jan 29, 2016 at 3:16 PM, Hans Wennborg  wrote:
>>
>> Yes, that seems like a good idea. Go ahead and merge (or let me know
>> if you'd prefer me to do it).
>
>
> I'd appreciate if you could do it. Thanks!

r259371. Thanks.

>> On Fri, Jan 29, 2016 at 3:14 PM, Alexey Samsonov 
>> wrote:
>> > Hans, do you think it makes sense to merge this patch into 3.8?
>> >
>> > On Fri, Jan 29, 2016 at 3:07 PM, Alexey Samsonov via cfe-commits
>> >  wrote:
>> >>
>> >> Author: samsonov
>> >> Date: Fri Jan 29 17:07:14 2016
>> >> New Revision: 259260
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=259260=rev
>> >> Log:
>> >> [UBSan] Add documentation for runtime issue suppression.
>> >>
>> >> Modified:
>> >> cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
>> >>
>> >> Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
>> >> URL:
>> >>
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=259260=259259=259260=diff
>> >>
>> >>
>> >> ==
>> >> --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
>> >> +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Fri Jan 29 17:07:14
>> >> 2016
>> >> @@ -168,6 +168,38 @@ UndefinedBehaviorSanitizer supports ``sr
>> >>  :doc:`SanitizerSpecialCaseList`, that can be used to suppress error
>> >> reports
>> >>  in the specified source files or functions.
>> >>
>> >> +Runtime suppressions
>> >> +
>> >> +
>> >> +Sometimes you can suppress UBSan error reports for specific files,
>> >> functions,
>> >> +or libraries without recompiling the code. You need to pass a path to
>> >> +suppression file in a ``UBSAN_OPTIONS`` environment variable.
>> >> +
>> >> +.. code-block:: bash
>> >> +
>> >> +UBSAN_OPTIONS=suppressions=MyUBSan.supp
>> >> +
>> >> +You need to specify a :ref:`check ` you are suppressing
>> >> and
>> >> the
>> >> +bug location. For example:
>> >> +
>> >> +.. code-block:: bash
>> >> +
>> >> +  signed-integer-overflow:file-with-known-overflow.cpp
>> >> +  alignment:function_doing_unaligned_access
>> >> +  vptr:shared_object_with_vptr_failures.so
>> >> +
>> >> +There are several limitations:
>> >> +
>> >> +* Sometimes your binary must have enough debug info and/or symbol
>> >> table,
>> >> so
>> >> +  that the runtime could figure out source file or function name to
>> >> match
>> >> +  against the suppression.
>> >> +* It is only possible to suppress recoverable checks. For the example
>> >> above,
>> >> +  you can additionally pass
>> >> +  ``-fsanitize-recover=signed-integer-overflow,alignment,vptr``,
>> >> although
>> >> +  most of UBSan checks are recoverable by default.
>> >> +* Check groups (like ``undefined``) can't be used in suppressions
>> >> file,
>> >> only
>> >> +  fine-grained checks are supported.
>> >> +
>> >>  Supported Platforms
>> >>  ===
>> >>
>> >>
>> >>
>> >> ___
>> >> cfe-commits mailing list
>> >> cfe-commits@lists.llvm.org
>> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>> >
>> >
>> >
>> >
>> > --
>> > Alexey Samsonov
>> > vonos...@gmail.com
>
>
>
>
> --
> Alexey Samsonov
> vonos...@gmail.com
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r196411 - Give all members of exception types default visibility. Lack of this is causing some illegal code relocations rare and hard to reproduce cases.

2016-02-01 Thread Rafael Espíndola via cfe-commits
>> Yes, that is what I mean. It is odd that -frtti changes us from "this
>> is not available anywhere, use linkonce_odr" to "it is available
>> elsewhere, use an external declaration".
>
> Yes, I agree, it's weird (although the transition is in the other
> direction, really, since there's no such flag as -frtti, just -fno-rtti).
> -fexceptions -fno-rtti is a weird combination to begin with though.

I got curious and decided to reduce it. What I got was:

class foo {
  virtual void bar();
};
struct zed : public foo {};
int f() { throw zed(); }

Without -fno-rtti _ZTI3foo is external. With -fno-rtti it is
linkonce_odr. It looks like -fno-rtti disables some key function logic
in both gcc and clang.

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


Re: [PATCH] D16758: [OpenMP] Prevent nesting of target constructs within target code execution regions.

2016-02-01 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL259366: [OpenMP] Prevent nesting of target constructs within 
target code execution… (authored by arpith).

Changed prior to commit:
  http://reviews.llvm.org/D16758?vs=46496=46544#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16758

Files:
  cfe/trunk/include/clang/Basic/OpenMPKinds.h
  cfe/trunk/lib/Basic/OpenMPKinds.cpp
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/test/OpenMP/distribute_private_messages.cpp
  cfe/trunk/test/OpenMP/nesting_of_regions.cpp
  cfe/trunk/test/OpenMP/target_data_device_messages.cpp
  cfe/trunk/test/OpenMP/target_device_messages.cpp
  cfe/trunk/test/OpenMP/target_if_messages.cpp
  cfe/trunk/test/OpenMP/target_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_default_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_device_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_firstprivate_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_if_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_map_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_num_threads_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_private_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_proc_bind_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_reduction_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_shared_messages.cpp
  cfe/trunk/test/OpenMP/target_private_messages.cpp
  cfe/trunk/test/OpenMP/teams_reduction_messages.cpp

Index: cfe/trunk/lib/Sema/SemaOpenMP.cpp
===
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp
@@ -809,7 +809,7 @@
   auto DKind = DSAStack->getDirectiveForScope(RSI->TheScope);
   auto Ty = D->getType();
 
-  if (isOpenMPTargetDirective(DKind)) {
+  if (isOpenMPTargetExecutionDirective(DKind)) {
 // This table summarizes how a given variable should be passed to the device
 // given its type and the clauses where it appears. This table is based on
 // the description in OpenMP 4.5 [2.10.4, target Construct] and
@@ -907,7 +907,7 @@
 DSAStack->hasDirective(
 [](OpenMPDirectiveKind K, const DeclarationNameInfo ,
SourceLocation Loc) -> bool {
-  return isOpenMPTargetDirective(K);
+  return isOpenMPTargetExecutionDirective(K);
 },
 false)) {
   return true;
@@ -944,7 +944,8 @@
 
   auto *VD = dyn_cast(D);
   return VD && !VD->hasLocalStorage() &&
- DSAStack->hasExplicitDirective(isOpenMPTargetDirective, Level);
+ DSAStack->hasExplicitDirective(isOpenMPTargetExecutionDirective,
+Level);
 }
 
 void Sema::DestroyDataSharingAttributesStack() { delete DSAStack; }
@@ -2313,11 +2314,11 @@
   // | target   | flush   | *  |
   // | target   | ordered | *  |
   // | target   | atomic  | *  |
-  // | target   | target  | *  |
-  // | target   | target parallel | *  |
-  // | target   | target enter| *  |
+  // | target   | target  ||
+  // | target   | target parallel ||
+  // | target   | target enter||
   // |  | data||
-  // | target   | target exit | *  |
+  // | target   | target exit ||
   // |  | data||
   // | target   | teams   | *  |
   // | target   | cancellation||
@@ -2347,11 +2348,11 @@
   // | target parallel  | flush   | *  |
   // | target parallel  | ordered | *  |
   // | target parallel  | atomic  | *  |
-  // | target parallel  | target  | *  |
-  // | target parallel  | target parallel | *  |
-  // | target parallel  | target enter| *  |
+  // | target parallel  | target  ||
+  // | target parallel  | target parallel ||
+  // | target parallel  | target enter||
   // |  | data||
-  // | target parallel  | target exit | *  

Re: [PATCH] D16259: Add clang-tidy readability-redundant-control-flow check

2016-02-01 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Thank you for adding more test cases! Could you address one more comment in a 
follow-up, please?



Comment at: test/clang-tidy/readability-redundant-control-flow.cpp:193
@@ +192,3 @@
+// CHECK-FIXES-NEXT: {{^return;$}}
+// CHECK-FIXES-NEXT: {{^ *}$}}
+

This test doesn't verify whether the second `return` is removed or not. 
Whatever the behavior is, it would be good to make it obvious in the test.


http://reviews.llvm.org/D16259



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


Re: [PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers

2016-02-01 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.h:21-22
@@ -20,71 +20,4 @@
 /// them to use the appropriate boolean expression directly.
 ///
-/// Examples:
-///
-/// ===  
-/// Initial expression   Result
-/// ---  
-/// `if (b == true)` `if (b)`
-/// `if (b == false)``if (!b)`
-/// `if (b && true)` `if (b)`
-/// `if (b && false)``if (false)`
-/// `if (b || true)` `if (true)`
-/// `if (b || false)``if (b)`
-/// `e ? true : false`   `e`
-/// `e ? false : true`   `!e`
-/// `if (true) t(); else f();`   `t();`
-/// `if (false) t(); else f();`  `f();`
-/// `if (e) return true; else return false;` `return e;`
-/// `if (e) return false; else return true;` `return !e;`
-/// `if (e) b = true; else b = false;`   `b = e;`
-/// `if (e) b = false; else b = true;`   `b = !e;`
-/// `if (e) return true; return false;`  `return e;`
-/// `if (e) return false; return true;`  `return !e;`
-/// ===  
-///
-/// The resulting expression `e` is modified as follows:
-///   1. Unnecessary parentheses around the expression are removed.
-///   2. Negated applications of `!` are eliminated.
-///   3. Negated applications of comparison operators are changed to use the
-///  opposite condition.
-///   4. Implicit conversions of pointer to `bool` are replaced with explicit
-///  comparisons to `nullptr`.
-///   5. Implicit casts to `bool` are replaced with explicit casts to `bool`.
-///   6. Object expressions with `explicit operator bool` conversion operators
-///  are replaced with explicit casts to `bool`.
-///
-/// Examples:
-///   1. The ternary assignment `bool b = (i < 0) ? true : false;` has 
redundant
-///  parentheses and becomes `bool b = i < 0;`.
-///
-///   2. The conditional return `if (!b) return false; return true;` has an
-///  implied double negation and becomes `return b;`.
-///
-///   3. The conditional return `if (i < 0) return false; return true;` becomes
-///  `return i >= 0;`.
-///
-///  The conditional return `if (i != 0) return false; return true;` 
becomes
-///  `return i == 0;`.
-///
-///   4. The conditional return `if (p) return true; return false;` has an
-///  implicit conversion of a pointer to `bool` and becomes
-///  `return p != nullptr;`.
-///
-///  The ternary assignment `bool b = (i & 1) ? true : false;` has an
-///  implicit conversion of `i & 1` to `bool` and becomes
-///  `bool b = static_cast(i & 1);`.
-///
-///   5. The conditional return `if (i & 1) return true; else return false;` 
has
-///  an implicit conversion of an integer quantity `i & 1` to `bool` and
-///  becomes `return static_cast(i & 1);`
-///
-///   6. Given `struct X { explicit operator bool(); };`, and an instance `x` 
of
-///  `struct X`, the conditional return `if (x) return true; return false;`
-///  becomes `return static_cast(x);`
-///
-/// When a conditional boolean return or assignment appears at the end of a
-/// chain of `if`, `else if` statements, the conditional statement is left
-/// unchanged unless the option `ChainedConditionalReturn` or
-/// `ChainedConditionalAssignment`, respectively, is specified as non-zero.
-/// The default value for both options is zero.
-///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/readability-simplify-boolean-expr.html

LegalizeAdulthood wrote:
> aaron.ballman wrote:
> > I think I can agree with that, but I also think it depends a lot on what 
> > the purpose to the check is. If it's "improve readability regarding parens" 
> > + options that control when to remove or add, that makes sense to me. 
> > Otherwise, I think segregating the checks into one that removes (plus 
> > options) and one that adds (plus options) makes sense -- even if they 
> > perhaps use the same underlying heuristic engine and are simply surfaced as 
> > separate checks.
> This check isn't at all about the readability of parens, so it doesn't make 
> sense for this check to be concerned with it IMO.
Agreed; trying to suss out what the appropriate design for this particular 
check is. I think I've talked myself into "don't touch parens here."


http://reviews.llvm.org/D16308



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


Re: [PATCH] D16692: [OpenCL] Eliminate warning when declaring OpenCL builtin functions

2016-02-01 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM!


http://reviews.llvm.org/D16692



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


Re: [PATCH] D16526: Add hasRetValue narrowing matcher for returnStmt

2016-02-01 Thread Richard via cfe-commits
LegalizeAdulthood added a comment.

In http://reviews.llvm.org/D16526#334938, @aaron.ballman wrote:

> I'm of two minds on this [...]


I just need a thumbs up/down on this.

Thumbs down, I discard the review.

Thumbs up, you take the patch.

Patch by Richard Thomson.


http://reviews.llvm.org/D16526



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


Re: [PATCH] D16135: Macro Debug Info support in Clang

2016-02-01 Thread Adrian Prantl via cfe-commits
aprantl added inline comments.


Comment at: lib/CodeGen/CGDebugInfo.cpp:2099
@@ -2098,1 +2098,3 @@
 
+llvm::DIMacro *CGDebugInfo::CreateMacro(llvm::DIMacroFile *Parent, bool 
IsUndef,
+SourceLocation LineLoc, StringRef Name,

By using a bool for IsUndef, we'll end up with somewhat ugly call sites like  
  DI->CreateMacro(Parent, /*IsUndef*/ true, ...);
so we might as well just pass in the dwarf constant
  DI->CreateMacro(Parent, llvm::dwarf::DW_MACINFO_undef, ...);
directly.


http://reviews.llvm.org/D16135



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


Re: [PATCH] D16219: PR8901: attribute "mode" rejected for enums and dependent types

2016-02-01 Thread Denis Zobnin via cfe-commits
d.zobnin.bugzilla updated this revision to Diff 46521.
d.zobnin.bugzilla added a comment.

Thanks for the review!

Only updated the text of diagnostics, NFC.


http://reviews.llvm.org/D16219

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  include/clang/Sema/Sema.h
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CodeGen/attr-mode-enums.c
  test/CodeGenCXX/attr-mode-vector-types-tmpl.cpp
  test/Sema/attr-mode-enums.c
  test/Sema/attr-mode.c
  test/SemaCXX/attr-mode-tmpl.cpp

Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -227,6 +227,14 @@
 Attr.getSpellingListIndex());
 }
 
+static void
+instantiateDependentModeAttr(Sema ,
+ const MultiLevelTemplateArgumentList ,
+ const ModeAttr , Decl *New) {
+  S.AddModeAttr(Attr.getRange(), New, Attr.getMode(),
+Attr.getSpellingListIndex(), /*InInstantiation=*/true);
+}
+
 void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList ,
 const Decl *Tmpl, Decl *New,
 LateInstantiatedAttrVec *LateAttrs,
@@ -265,6 +273,11 @@
   continue;
 }
 
+if (const ModeAttr *Mode = dyn_cast(TmplAttr)) {
+  instantiateDependentModeAttr(*this, TemplateArgs, *Mode, New);
+  continue;
+}
+
 // Existing DLL attribute on the instantiation takes precedence.
 if (TmplAttr->getKind() == attr::DLLExport ||
 TmplAttr->getKind() == attr::DLLImport) {
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3297,6 +3297,8 @@
 /// attribute.
 static void parseModeAttrArg(Sema , StringRef Str, unsigned ,
  bool , bool ) {
+  IntegerMode = true;
+  ComplexMode = false;
   switch (Str.size()) {
   case 2:
 switch (Str[0]) {
@@ -3363,9 +3365,15 @@
   }
 
   IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
-  StringRef Str = Name->getName();
 
+  S.AddModeAttr(Attr.getRange(), D, Name, Attr.getAttributeSpellingListIndex());
+}
+
+void Sema::AddModeAttr(SourceRange AttrRange, Decl *D, IdentifierInfo *Name,
+   unsigned SpellingListIndex, bool InInstantiation) {
+  StringRef Str = Name->getName();
   normalizeName(Str);
+  SourceLocation AttrLoc = AttrRange.getBegin();
 
   unsigned DestWidth = 0;
   bool IntegerMode = true;
@@ -3381,99 +3389,126 @@
 if (VectorStringLength &&
 !Str.substr(1, VectorStringLength).getAsInteger(10, VectorSize) &&
 VectorSize.isPowerOf2()) {
-  parseModeAttrArg(S, Str.substr(VectorStringLength + 1), DestWidth,
+  parseModeAttrArg(*this, Str.substr(VectorStringLength + 1), DestWidth,
IntegerMode, ComplexMode);
-  S.Diag(Attr.getLoc(), diag::warn_vector_mode_deprecated);
+  // Avoid duplicate warning from template instantiation.
+  if (!InInstantiation)
+Diag(AttrLoc, diag::warn_vector_mode_deprecated);
 } else {
   VectorSize = 0;
 }
   }
 
   if (!VectorSize)
-parseModeAttrArg(S, Str, DestWidth, IntegerMode, ComplexMode);
+parseModeAttrArg(*this, Str, DestWidth, IntegerMode, ComplexMode);
+
+  // FIXME: Sync this with InitializePredefinedMacros; we need to match int8_t
+  // and friends, at least with glibc.
+  // FIXME: Make sure floating-point mappings are accurate
+  // FIXME: Support XF and TF types
+  if (!DestWidth) {
+Diag(AttrLoc, diag::err_machine_mode) << 0 /*Unknown*/ << Name;
+return;
+  }
 
   QualType OldTy;
   if (TypedefNameDecl *TD = dyn_cast(D))
 OldTy = TD->getUnderlyingType();
-  else
+  else if (EnumDecl *ED = dyn_cast(D)) {
+// Something like 'typedef enum { X } __attribute__((mode(XX))) T;'.
+// Try to get type from enum declaration, default to int.
+OldTy = ED->getIntegerType();
+if (OldTy.isNull())
+  OldTy = Context.IntTy;
+  } else
 OldTy = cast(D)->getType();
 
+  if (OldTy->isDependentType()) {
+D->addAttr(::new (Context)
+   ModeAttr(AttrRange, Context, Name, SpellingListIndex));
+return;
+  }
+
   // Base type can also be a vector type (see PR17453).
   // Distinguish between base type and base element type.
   QualType OldElemTy = OldTy;
   if (const VectorType *VT = OldTy->getAs())
 OldElemTy = VT->getElementType();
 
-  if (!OldElemTy->getAs() && !OldElemTy->isComplexType())
-S.Diag(Attr.getLoc(), diag::err_mode_not_primitive);
+  // GCC allows 'mode' attribute on enumeration types (even incomplete), except
+  // for vector modes. So, 'enum X __attribute__((mode(QI)));' forms a complete
+  // type, 'enum { A } __attribute__((mode(V4SI)))' is rejected.
+  if ((isa(D) || 

Re: [PATCH] D15120: Add support for __float128 type to be used by targets that support it

2016-02-01 Thread Nemanja Ivanovic via cfe-commits
nemanjai added a comment.

If the reviewers don't mind, I would like to keep this patch with diagnostics 
for interoperability between the two types for now. This is simply because 
enabling such interoperability requires changes to some of the conversion 
infrastructure (i.e. allowing FPTrunc/FPExt for types of the same width, etc.). 
This is to prevent crashes on code such as:

  __float128 foo(long double d) {
return d;
  }

A test case like that will trip asserts when attempting to generate code. Of 
course, this is easy to fix (3 minor changes in 2 files) but even if we emit 
that IR, the back end will fail when trying to compile it.
What I meant to do with this patch is to just get the Clang support in and emit 
diagnostics for things that the target isn't able to do yet. I will follow this 
up with a patch that will:

1. Remove the diagnostics
2. Allow the conversions
3. Provide libcalls for the necessary operations (similarly to what GCC does)


Repository:
  rL LLVM

http://reviews.llvm.org/D15120



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


r259351 - clang-format: Fix alignment of trailing multiline columns.

2016-02-01 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Feb  1 05:20:55 2016
New Revision: 259351

URL: http://llvm.org/viewvc/llvm-project?rev=259351=rev
Log:
clang-format: Fix alignment of trailing multiline columns.

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

Modified: cfe/trunk/lib/Format/WhitespaceManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/WhitespaceManager.cpp?rev=259351=259350=259351=diff
==
--- cfe/trunk/lib/Format/WhitespaceManager.cpp (original)
+++ cfe/trunk/lib/Format/WhitespaceManager.cpp Mon Feb  1 05:20:55 2016
@@ -372,16 +372,20 @@ void WhitespaceManager::alignTrailingCom
   unsigned CommentColumn = SourceMgr.getSpellingColumnNumber(
   Changes[i].OriginalWhitespaceRange.getEnd());
   for (unsigned j = i + 1; j != e; ++j) {
-if (Changes[j].Kind != tok::comment) { // Skip over comments.
-  unsigned NextColumn = SourceMgr.getSpellingColumnNumber(
-  Changes[j].OriginalWhitespaceRange.getEnd());
-  // The start of the next token was previously aligned with the
-  // start of this comment.
-  WasAlignedWithStartOfNextLine =
-  CommentColumn == NextColumn ||
-  CommentColumn == NextColumn + Style.IndentWidth;
-  break;
-}
+if (Changes[j].Kind == tok::comment ||
+Changes[j].Kind == tok::unknown)
+  // Skip over comments and unknown tokens. "unknown tokens are used 
for
+  // the continuation of multiline comments.
+  continue;
+
+unsigned NextColumn = SourceMgr.getSpellingColumnNumber(
+Changes[j].OriginalWhitespaceRange.getEnd());
+// The start of the next token was previously aligned with the
+// start of this comment.
+WasAlignedWithStartOfNextLine =
+CommentColumn == NextColumn ||
+CommentColumn == NextColumn + Style.IndentWidth;
+break;
   }
 }
 if (!Style.AlignTrailingComments || FollowsRBraceInColumn0) {

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=259351=259350=259351=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Feb  1 05:20:55 2016
@@ -962,6 +962,14 @@ TEST_F(FormatTest, UnderstandsSingleLine
"// at start\n"
"otherLine();"));
   EXPECT_EQ("lineWith(); // comment\n"
+"/*\n"
+" * at start */\n"
+"otherLine();",
+format("lineWith();   // comment\n"
+   "/*\n"
+   " * at start */\n"
+   "otherLine();"));
+  EXPECT_EQ("lineWith(); // comment\n"
 "// at start\n"
 "otherLine();",
 format("lineWith();   // comment\n"


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


r259353 - clang-format: Fix incorrect pointer detection in lambdas in constructor

2016-02-01 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Feb  1 05:21:07 2016
New Revision: 259353

URL: http://llvm.org/viewvc/llvm-project?rev=259353=rev
Log:
clang-format: Fix incorrect pointer detection in lambdas in constructor
initializers.

Before:
  Constructor() : member([](A *a, B * b) {}) {}

After:
  Constructor() : member([](A *a, B *b) {}) {}

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=259353=259352=259353=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Feb  1 05:21:07 2016
@@ -887,8 +887,8 @@ private:
Previous && Previous->isOneOf(tok::star, tok::amp);
Previous = Previous->Previous)
 Previous->Type = TT_PointerOrReference;
-  if (Line.MustBeDeclaration)
-Contexts.back().IsExpression = Contexts.front().InCtorInitializer;
+  if (Line.MustBeDeclaration && !Contexts.front().InCtorInitializer)
+Contexts.back().IsExpression = false;
 } else if (Current.Previous &&
Current.Previous->is(TT_CtorInitializerColon)) {
   Contexts.back().IsExpression = true;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=259353=259352=259353=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Feb  1 05:21:07 2016
@@ -5634,6 +5634,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
   verifyFormat("[](const decltype(*a) ) {}");
   verifyFormat("decltype(a * b) F();");
   verifyFormat("#define MACRO() [](A *a) { return 1; }");
+  verifyFormat("Constructor() : member([](A *a, B *b) {}) {}");
   verifyIndependentOfContext("typedef void (*f)(int *a);");
   verifyIndependentOfContext("int i{a * b};");
   verifyIndependentOfContext("aaa && aaa->f();");


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


r259350 - clang-format: [JS] Treat "in" as a proper operator.

2016-02-01 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Feb  1 05:20:47 2016
New Revision: 259350

URL: http://llvm.org/viewvc/llvm-project?rev=259350=rev
Log:
clang-format: [JS] Treat "in" as a proper operator.

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=259350=259349=259350=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Feb  1 05:20:47 2016
@@ -1035,6 +1035,9 @@ private:
 
 if (Tok.Previous->isOneOf(TT_LeadingJavaAnnotation, 
Keywords.kw_instanceof))
   return false;
+if (Style.Language == FormatStyle::LK_JavaScript &&
+Tok.Previous->is(Keywords.kw_in))
+  return false;
 
 // Skip "const" as it does not have an influence on whether this is a name.
 FormatToken *PreviousNotConst = Tok.Previous;
@@ -1390,6 +1393,9 @@ private:
Style.Language == FormatStyle::LK_JavaScript) &&
   Current->is(Keywords.kw_instanceof))
 return prec::Relational;
+  if (Style.Language == FormatStyle::LK_JavaScript &&
+  Current->is(Keywords.kw_in))
+return prec::Relational;
   if (Current->is(TT_BinaryOperator) || Current->is(tok::comma))
 return Current->getPrecedence();
   if (Current->isOneOf(tok::period, tok::arrow))
@@ -2277,6 +2283,10 @@ bool TokenAnnotator::canBreakBefore(cons
   return true;
 if (Right.NestingLevel == 0 && Right.is(Keywords.kw_is))
   return false;
+if (Left.is(Keywords.kw_in))
+  return Style.BreakBeforeBinaryOperators == FormatStyle::BOS_None;
+if (Right.is(Keywords.kw_in))
+  return Style.BreakBeforeBinaryOperators != FormatStyle::BOS_None;
   }
 
   if (Left.is(tok::at))

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=259350=259349=259350=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Feb  1 05:20:47 2016
@@ -86,6 +86,17 @@ TEST_F(FormatTestJS, UnderstandsJavaScri
 
   verifyFormat("var b = a.map((x) => x + 1);");
   verifyFormat("return ('aaa') in ;");
+  verifyFormat("var x = a() in\n"
+   ".aa.aa;");
+  FormatStyle Style = getGoogleJSStyleWithColumns(80);
+  Style.AlignOperands = true;
+  verifyFormat("var x = a() in\n"
+   ".aa.aa;",
+   Style);
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
+  verifyFormat("var x = a()\n"
+   "in 
.aa.aa;",
+   Style);
 
   // ES6 spread operator.
   verifyFormat("someFunction(...a);");


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


r259352 - clang-format: Add option to disable string literal formatting.

2016-02-01 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Feb  1 05:21:02 2016
New Revision: 259352

URL: http://llvm.org/viewvc/llvm-project?rev=259352=rev
Log:
clang-format: Add option to disable string literal formatting.

Modified:
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=259352=259351=259352=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Mon Feb  1 05:21:02 2016
@@ -285,6 +285,9 @@ struct FormatStyle {
   /// \brief Break after each annotation on a field in Java files.
   bool BreakAfterJavaFieldAnnotations;
 
+  /// \brief Allow breaking string literals when formatting.
+  bool BreakStringLiterals;
+
   /// \brief The column limit.
   ///
   /// A column limit of \c 0 means that there is no column limit. In this case,
@@ -619,6 +622,7 @@ struct FormatStyle {
BreakConstructorInitializersBeforeComma ==
R.BreakConstructorInitializersBeforeComma &&
BreakAfterJavaFieldAnnotations == R.BreakAfterJavaFieldAnnotations 
&&
+   BreakStringLiterals == R.BreakStringLiterals &&
ColumnLimit == R.ColumnLimit && CommentPragmas == R.CommentPragmas 
&&
ConstructorInitializerAllOnOneLineOrOnePerLine ==
R.ConstructorInitializerAllOnOneLineOrOnePerLine &&

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=259352=259351=259352=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Mon Feb  1 05:21:02 2016
@@ -1061,7 +1061,8 @@ unsigned ContinuationIndenter::breakProt
 // FIXME: String literal breaking is currently disabled for Java and JS, as
 // it requires strings to be merged using "+" which we don't support.
 if (Style.Language == FormatStyle::LK_Java ||
-Style.Language == FormatStyle::LK_JavaScript)
+Style.Language == FormatStyle::LK_JavaScript ||
+!Style.BreakStringLiterals)
   return 0;
 
 // Don't break string literals inside preprocessor directives (except for

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=259352=259351=259352=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Feb  1 05:21:02 2016
@@ -275,6 +275,9 @@ template <> struct MappingTraitshttp://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=259352=259351=259352=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Feb  1 05:21:02 2016
@@ -7958,6 +7958,10 @@ TEST_F(FormatTest, BreaksStringLiterals)
"aaa\"});",
getGoogleStyle()));
 
+  FormatStyle Style = getLLVMStyleWithColumns(12);
+  Style.BreakStringLiterals = false;
+  EXPECT_EQ("\"some text other\";", format("\"some text other\";", Style));
+
   FormatStyle AlignLeft = getLLVMStyleWithColumns(12);
   AlignLeft.AlignEscapedNewlinesLeft = true;
   EXPECT_EQ("#define A \\\n"
@@ -9823,8 +9827,10 @@ TEST_F(FormatTest, ParsesConfigurationBo
   CHECK_PARSE_BOOL(AlwaysBreakTemplateDeclarations);
   CHECK_PARSE_BOOL(BinPackArguments);
   CHECK_PARSE_BOOL(BinPackParameters);
+  CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);
   CHECK_PARSE_BOOL(BreakBeforeTernaryOperators);
   CHECK_PARSE_BOOL(BreakConstructorInitializersBeforeComma);
+  CHECK_PARSE_BOOL(BreakStringLiterals);
   CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine);
   CHECK_PARSE_BOOL(DerivePointerAlignment);
   CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding");


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


Re: [PATCH] D16317: [Analyzer] Fix for PR23790: bind real value returned from strcmp when modelling strcmp.

2016-02-01 Thread Антон Ярцев via cfe-commits
ayartsev updated this revision to Diff 46538.
ayartsev added a comment.

Updated the patch, please review.


http://reviews.llvm.org/D16317

Files:
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  test/Analysis/string.c

Index: test/Analysis/string.c
===
--- test/Analysis/string.c
+++ test/Analysis/string.c
@@ -680,6 +680,18 @@
 #define strcmp BUILTIN(strcmp)
 int strcmp(const char * s1, const char * s2);
 
+void strcmp_check_modelling() {
+  char *x = "aa";
+  char *y = "a";
+  clang_analyzer_eval(strcmp(x, y) > 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strcmp(x, y) <= 0); // expected-warning{{FALSE}}
+  clang_analyzer_eval(strcmp(x, y) > 1); // expected-warning{{UNKNOWN}}
+
+  clang_analyzer_eval(strcmp(y, x) < 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strcmp(y, x) >= 0); // expected-warning{{FALSE}}
+  clang_analyzer_eval(strcmp(y, x) < -1); // expected-warning{{UNKNOWN}}
+}
+
 void strcmp_constant0() {
   clang_analyzer_eval(strcmp("123", "123") == 0); // expected-warning{{TRUE}}
 }
@@ -703,13 +715,13 @@
 void strcmp_1() {
   char *x = "234";
   char *y = "123";
-  clang_analyzer_eval(strcmp(x, y) == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strcmp(x, y) > 0); // expected-warning{{TRUE}}
 }
 
 void strcmp_2() {
   char *x = "123";
   char *y = "234";
-  clang_analyzer_eval(strcmp(x, y) == -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strcmp(x, y) < 0); // expected-warning{{TRUE}}
 }
 
 void strcmp_null_0() {
@@ -727,25 +739,25 @@
 void strcmp_diff_length_0() {
   char *x = "12345";
   char *y = "234";
-  clang_analyzer_eval(strcmp(x, y) == -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strcmp(x, y) < 0); // expected-warning{{TRUE}}
 }
 
 void strcmp_diff_length_1() {
   char *x = "123";
   char *y = "23456";
-  clang_analyzer_eval(strcmp(x, y) == -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strcmp(x, y) < 0); // expected-warning{{TRUE}}
 }
 
 void strcmp_diff_length_2() {
   char *x = "12345";
   char *y = "123";
-  clang_analyzer_eval(strcmp(x, y) == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strcmp(x, y) > 0); // expected-warning{{TRUE}}
 }
 
 void strcmp_diff_length_3() {
   char *x = "123";
   char *y = "12345";
-  clang_analyzer_eval(strcmp(x, y) == -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strcmp(x, y) < 0); // expected-warning{{TRUE}}
 }
 
 void strcmp_embedded_null () {
@@ -763,6 +775,18 @@
 #define strncmp BUILTIN(strncmp)
 int strncmp(const char *s1, const char *s2, size_t n);
 
+void strncmp_check_modelling() {
+  char *x = "aa";
+  char *y = "a";
+  clang_analyzer_eval(strncmp(x, y, 2) > 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strncmp(x, y, 2) <= 0); // expected-warning{{FALSE}}
+  clang_analyzer_eval(strncmp(x, y, 2) > 1); // expected-warning{{UNKNOWN}}
+
+  clang_analyzer_eval(strncmp(y, x, 2) < 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strncmp(y, x, 2) >= 0); // expected-warning{{FALSE}}
+  clang_analyzer_eval(strncmp(y, x, 2) < -1); // expected-warning{{UNKNOWN}}
+}
+
 void strncmp_constant0() {
   clang_analyzer_eval(strncmp("123", "123", 3) == 0); // expected-warning{{TRUE}}
 }
@@ -786,13 +810,13 @@
 void strncmp_1() {
   char *x = "234";
   char *y = "123";
-  clang_analyzer_eval(strncmp(x, y, 3) == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strncmp(x, y, 3) > 0); // expected-warning{{TRUE}}
 }
 
 void strncmp_2() {
   char *x = "123";
   char *y = "234";
-  clang_analyzer_eval(strncmp(x, y, 3) == -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strncmp(x, y, 3) < 0); // expected-warning{{TRUE}}
 }
 
 void strncmp_null_0() {
@@ -810,25 +834,25 @@
 void strncmp_diff_length_0() {
   char *x = "12345";
   char *y = "234";
-  clang_analyzer_eval(strncmp(x, y, 5) == -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strncmp(x, y, 5) < 0); // expected-warning{{TRUE}}
 }
 
 void strncmp_diff_length_1() {
   char *x = "123";
   char *y = "23456";
-  clang_analyzer_eval(strncmp(x, y, 5) == -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strncmp(x, y, 5) < 0); // expected-warning{{TRUE}}
 }
 
 void strncmp_diff_length_2() {
   char *x = "12345";
   char *y = "123";
-  clang_analyzer_eval(strncmp(x, y, 5) == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strncmp(x, y, 5) > 0); // expected-warning{{TRUE}}
 }
 
 void strncmp_diff_length_3() {
   char *x = "123";
   char *y = "12345";
-  clang_analyzer_eval(strncmp(x, y, 5) == -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strncmp(x, y, 5) < 0); // expected-warning{{TRUE}}
 }
 
 void strncmp_diff_length_4() {
@@ -840,13 +864,13 @@
 void strncmp_diff_length_5() {
   char *x = "012";
   char *y = "12345";
-  clang_analyzer_eval(strncmp(x, y, 3) == -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(strncmp(x, y, 3) < 0); // expected-warning{{TRUE}}
 }
 
 void strncmp_diff_length_6() {
   char *x = "234";
   

Re: [PATCH] D16764: Move incorrect-roundings to upstream.

2016-02-01 Thread Haojian Wu via cfe-commits
hokein marked 3 inline comments as done.


Comment at: clang-tidy/misc/IncorrectRoundings.cpp:39
@@ +38,3 @@
+namespace tidy {
+void IncorrectRoundings::registerMatchers(MatchFinder *MatchFinder) {
+  // Match a floating literal with value 0.5.

Done. The `ASTMatchers.h` file is not in clang-tidy repository, so I 
temporarily implement `isFloatingPoint` narrowing matcher here.

Will create a separated patch to clang repository.


Comment at: clang-tidy/misc/IncorrectRoundings.cpp:51
@@ +50,3 @@
+
+  // Match if either the LHS or RHS is a floating literal of 0.5 or a floating
+  // literal of 0.5 and the other is of type double or vice versa.

Just found out there is no need to bind here since `check` function doesn't use 
it. Have removed it.


http://reviews.llvm.org/D16764



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


Re: [PATCH] D16529: [clang-tidy] Add modernize-raw-string-literal check

2016-02-01 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:80
@@ +79,3 @@
+return false;
+
+  const size_t NewLinePos = Text.find(R"(\n)");

aaron.ballman wrote:
> This is why I would still prefer to block on fixing StringLiteral. This is 
> functional, but really kind of nasty -- in the common case (not already a raw 
> string literal), this does two linear searches through the entire string 
> literal.
Richard, you're right, it's `u8R"(...)"`, not `Ru8"(...)"` or something. 
Nevertheless, doing a full scan for `R` (the search for `"` wouldn't result in 
a full scan) in this condition shouldn't be necessary, it could first find a 
`"` and then check if the previous character is `R`. It would be a bit more 
code, but less needless work at runtime.

Alternatively, D16012 might be a better answer, if it ever makes it into Clang.


Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:88
@@ +87,3 @@
+}
+
+bool containsDelimiter(StringRef Bytes, const std::string ) {

aaron.ballman wrote:
> I think Alex's point is: why not R"('\"?x01)" (removing the need for lit)?
Exactly, I was only talking about `lit`, not about using the raw string literal.


Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:96
@@ +95,3 @@
+  std::string Delimiter;
+  for (int Counter = 0; containsDelimiter(Bytes, Delimiter); ++Counter) {
+Delimiter = (Counter == 0) ? "lit" : "lit" + std::to_string(Counter);

Please address my comment above that relates to this code. Specifically, I find 
this generic algorithm unnecessarily inefficient and too rigid, i.e. one can't 
configure a custom set of delimiters that don't follow the  
pattern. I suggest using a list of pre-concatenated pairs of strings (like 
`R"lit(` and `)lit"`).


http://reviews.llvm.org/D16529



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


Re: [PATCH] D16526: Add hasRetValue narrowing matcher for returnStmt

2016-02-01 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D16526#340785, @LegalizeAdulthood wrote:

> In http://reviews.llvm.org/D16526#334938, @aaron.ballman wrote:
>
> > I'm of two minds on this [...]
>
>
> I just need a thumbs up/down on this.
>
> Thumbs down, I discard the review.
>
> Thumbs up, you take the patch.
>
> Patch by Richard Thomson.


I think the patch should be discarded. I appreciate the time you put into 
making the patch, however!


http://reviews.llvm.org/D16526



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


Re: [PATCH] D16770: [MS] PR26234: Allow typedef redefinition of equally qualified, sized and aligned types in C

2016-02-01 Thread David Majnemer via cfe-commits
majnemer added a comment.

MSVC permits:

  typedef int foo;
  typedef float foo;

This is crazy and most certainly not 'benign'. I think that we should insist 
that the underlying types not just be the same size and alignment but the same 
kind of scalar type. If two types are integral or enumerator types, they should 
have the same signedness.

I believe this would be enough to get things like vortex working without 
harming developer productivity.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:4265-4267
@@ -4264,2 +4264,5 @@
   InGroup>;
+def warn_benign_redefinition_different_typedef : ExtWarn<
+  "benign typedef redefinition with different types%diff{ ($ vs $)|}0,1 "
+  "is a Microsoft extension">, InGroup;
 def err_redefinition_different_typedef : Error<

I think giving a warning that 'benign' sends the message that the code is OK 
and that the warning should be disabled.  I think we should say something like 
"typedef redefinition is ignored due to conflicting underlying type".


Comment at: lib/AST/ASTContext.cpp:6727-6728
@@ +6726,4 @@
+bool ASTContext::areMSCompatibleTypesInC(QualType OldType, QualType NewType) {
+  assert(getLangOpts().MicrosoftExt &&
+ "This routine must be called in Microsoft mode only!");
+  assert(!getLangOpts().CPlusPlus && !getLangOpts().ObjC1 &&

Shouldn't this be `MSVCCompat`, not `MicrosoftExt`?


Comment at: lib/Sema/SemaDecl.cpp:1868
@@ -1846,2 +1867,3 @@
   QualType OldType;
-  if (TypedefNameDecl *OldTypedef = dyn_cast(Old))
+  TypedefNameDecl *OldTypedef = dyn_cast(Old);
+  if (OldTypedef)

Please use `auto` here.


http://reviews.llvm.org/D16770



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


Re: [PATCH] D16586: Make clang AAPCS compliant w.r.t volatile bitfield accesses

2016-02-01 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

Ping?


http://reviews.llvm.org/D16586



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


Re: [PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers

2016-02-01 Thread Richard via cfe-commits
LegalizeAdulthood added inline comments.


Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.h:21-22
@@ -20,71 +20,4 @@
 /// them to use the appropriate boolean expression directly.
 ///
-/// Examples:
-///
-/// ===  
-/// Initial expression   Result
-/// ---  
-/// `if (b == true)` `if (b)`
-/// `if (b == false)``if (!b)`
-/// `if (b && true)` `if (b)`
-/// `if (b && false)``if (false)`
-/// `if (b || true)` `if (true)`
-/// `if (b || false)``if (b)`
-/// `e ? true : false`   `e`
-/// `e ? false : true`   `!e`
-/// `if (true) t(); else f();`   `t();`
-/// `if (false) t(); else f();`  `f();`
-/// `if (e) return true; else return false;` `return e;`
-/// `if (e) return false; else return true;` `return !e;`
-/// `if (e) b = true; else b = false;`   `b = e;`
-/// `if (e) b = false; else b = true;`   `b = !e;`
-/// `if (e) return true; return false;`  `return e;`
-/// `if (e) return false; return true;`  `return !e;`
-/// ===  
-///
-/// The resulting expression `e` is modified as follows:
-///   1. Unnecessary parentheses around the expression are removed.
-///   2. Negated applications of `!` are eliminated.
-///   3. Negated applications of comparison operators are changed to use the
-///  opposite condition.
-///   4. Implicit conversions of pointer to `bool` are replaced with explicit
-///  comparisons to `nullptr`.
-///   5. Implicit casts to `bool` are replaced with explicit casts to `bool`.
-///   6. Object expressions with `explicit operator bool` conversion operators
-///  are replaced with explicit casts to `bool`.
-///
-/// Examples:
-///   1. The ternary assignment `bool b = (i < 0) ? true : false;` has 
redundant
-///  parentheses and becomes `bool b = i < 0;`.
-///
-///   2. The conditional return `if (!b) return false; return true;` has an
-///  implied double negation and becomes `return b;`.
-///
-///   3. The conditional return `if (i < 0) return false; return true;` becomes
-///  `return i >= 0;`.
-///
-///  The conditional return `if (i != 0) return false; return true;` 
becomes
-///  `return i == 0;`.
-///
-///   4. The conditional return `if (p) return true; return false;` has an
-///  implicit conversion of a pointer to `bool` and becomes
-///  `return p != nullptr;`.
-///
-///  The ternary assignment `bool b = (i & 1) ? true : false;` has an
-///  implicit conversion of `i & 1` to `bool` and becomes
-///  `bool b = static_cast(i & 1);`.
-///
-///   5. The conditional return `if (i & 1) return true; else return false;` 
has
-///  an implicit conversion of an integer quantity `i & 1` to `bool` and
-///  becomes `return static_cast(i & 1);`
-///
-///   6. Given `struct X { explicit operator bool(); };`, and an instance `x` 
of
-///  `struct X`, the conditional return `if (x) return true; return false;`
-///  becomes `return static_cast(x);`
-///
-/// When a conditional boolean return or assignment appears at the end of a
-/// chain of `if`, `else if` statements, the conditional statement is left
-/// unchanged unless the option `ChainedConditionalReturn` or
-/// `ChainedConditionalAssignment`, respectively, is specified as non-zero.
-/// The default value for both options is zero.
-///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/readability-simplify-boolean-expr.html

aaron.ballman wrote:
> I think I can agree with that, but I also think it depends a lot on what the 
> purpose to the check is. If it's "improve readability regarding parens" + 
> options that control when to remove or add, that makes sense to me. 
> Otherwise, I think segregating the checks into one that removes (plus 
> options) and one that adds (plus options) makes sense -- even if they perhaps 
> use the same underlying heuristic engine and are simply surfaced as separate 
> checks.
This check isn't at all about the readability of parens, so it doesn't make 
sense for this check to be concerned with it IMO.


http://reviews.llvm.org/D16308



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


[PATCH] D16797: Update clang support on recent Haiku

2016-02-01 Thread Jérôme Duval via cfe-commits
korli created this revision.
korli added a reviewer: rsmith.
korli added a subscriber: cfe-commits.
korli set the repository for this revision to rL LLVM.
Herald added a subscriber: aemerson.

[ Copied from [[ https://llvm.org/bugs/show_bug.cgi?id=26404 | 
https://llvm.org/bugs/show_bug.cgi?id=26404 ]] ]

clang support on Haiku is lagging a bit, and missing on x86_64.

This patch updates support for x86 and add support for x86_64. It should apply 
directly to trunk and it's harmless in the sense that it only affects Haiku.

Please consider reviewing.

Repository:
  rL LLVM

http://reviews.llvm.org/D16797

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Frontend/InitHeaderSearch.cpp

Index: lib/Frontend/InitHeaderSearch.cpp
===
--- lib/Frontend/InitHeaderSearch.cpp
+++ lib/Frontend/InitHeaderSearch.cpp
@@ -267,38 +267,39 @@
   }
 
   case llvm::Triple::Haiku:
-AddPath("/boot/common/include", System, false);
-AddPath("/boot/develop/headers/os", System, false);
-AddPath("/boot/develop/headers/os/app", System, false);
-AddPath("/boot/develop/headers/os/arch", System, false);
-AddPath("/boot/develop/headers/os/device", System, false);
-AddPath("/boot/develop/headers/os/drivers", System, false);
-AddPath("/boot/develop/headers/os/game", System, false);
-AddPath("/boot/develop/headers/os/interface", System, false);
-AddPath("/boot/develop/headers/os/kernel", System, false);
-AddPath("/boot/develop/headers/os/locale", System, false);
-AddPath("/boot/develop/headers/os/mail", System, false);
-AddPath("/boot/develop/headers/os/media", System, false);
-AddPath("/boot/develop/headers/os/midi", System, false);
-AddPath("/boot/develop/headers/os/midi2", System, false);
-AddPath("/boot/develop/headers/os/net", System, false);
-AddPath("/boot/develop/headers/os/storage", System, false);
-AddPath("/boot/develop/headers/os/support", System, false);
-AddPath("/boot/develop/headers/os/translation", System, false);
-AddPath("/boot/develop/headers/os/add-ons/graphics", System, false);
-AddPath("/boot/develop/headers/os/add-ons/input_server", System, false);
-AddPath("/boot/develop/headers/os/add-ons/screen_saver", System, false);
-AddPath("/boot/develop/headers/os/add-ons/tracker", System, false);
-AddPath("/boot/develop/headers/os/be_apps/Deskbar", System, false);
-AddPath("/boot/develop/headers/os/be_apps/NetPositive", System, false);
-AddPath("/boot/develop/headers/os/be_apps/Tracker", System, false);
-AddPath("/boot/develop/headers/cpp", System, false);
-AddPath("/boot/develop/headers/cpp/i586-pc-haiku", System, false);
-AddPath("/boot/develop/headers/3rdparty", System, false);
-AddPath("/boot/develop/headers/bsd", System, false);
-AddPath("/boot/develop/headers/glibc", System, false);
-AddPath("/boot/develop/headers/posix", System, false);
-AddPath("/boot/develop/headers",  System, false);
+AddPath("/boot/system/non-packaged/develop/headers", System, false);
+AddPath("/boot/system/develop/headers/os", System, false);
+AddPath("/boot/system/develop/headers/os/app", System, false);
+AddPath("/boot/system/develop/headers/os/arch", System, false);
+AddPath("/boot/system/develop/headers/os/device", System, false);
+AddPath("/boot/system/develop/headers/os/drivers", System, false);
+AddPath("/boot/system/develop/headers/os/game", System, false);
+AddPath("/boot/system/develop/headers/os/interface", System, false);
+AddPath("/boot/system/develop/headers/os/kernel", System, false);
+AddPath("/boot/system/develop/headers/os/locale", System, false);
+AddPath("/boot/system/develop/headers/os/mail", System, false);
+AddPath("/boot/system/develop/headers/os/media", System, false);
+AddPath("/boot/system/develop/headers/os/midi", System, false);
+AddPath("/boot/system/develop/headers/os/midi2", System, false);
+AddPath("/boot/system/develop/headers/os/net", System, false);
+AddPath("/boot/system/develop/headers/os/opengl", System, false);
+AddPath("/boot/system/develop/headers/os/storage", System, false);
+AddPath("/boot/system/develop/headers/os/support", System, false);
+AddPath("/boot/system/develop/headers/os/translation", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/graphics", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/input_server", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/mail_daemon", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/registrar", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/screen_saver", System, false);
+AddPath("/boot/system/develop/headers/os/add-ons/tracker", System, false);
+AddPath("/boot/system/develop/headers/os/be_apps/Deskbar", System, 

[clang-tools-extra] r259393 - Sort checks alphabetically in ReadabilityTidyModule.cpp.

2016-02-01 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Mon Feb  1 13:47:24 2016
New Revision: 259393

URL: http://llvm.org/viewvc/llvm-project?rev=259393=rev
Log:
Sort checks alphabetically in ReadabilityTidyModule.cpp.

Modified:
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp?rev=259393=259392=259393=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp 
Mon Feb  1 13:47:24 2016
@@ -45,18 +45,18 @@ public:
 "readability-implicit-bool-cast");
 CheckFactories.registerCheck(
 "readability-inconsistent-declaration-parameter-name");
-CheckFactories.registerCheck(
-"readability-redundant-control-flow");
-CheckFactories.registerCheck(
-"readability-uniqueptr-delete-release");
 CheckFactories.registerCheck(
 "readability-named-parameter");
+CheckFactories.registerCheck(
+"readability-redundant-control-flow");
 CheckFactories.registerCheck(
 "readability-redundant-smartptr-get");
 CheckFactories.registerCheck(
 "readability-redundant-string-cstr");
 CheckFactories.registerCheck(
 "readability-simplify-boolean-expr");
+CheckFactories.registerCheck(
+"readability-uniqueptr-delete-release");
   }
 };
 


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


Re: [PATCH] D16788: PS4 ABI Round 2. Actual PS4 code.

2016-02-01 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: include/clang/Basic/TargetCXXABI.h:118
@@ -115,1 +117,3 @@
+/// in LLVM 3.2.
+PS4
   };

I'm not sure why you added a new C++ ABI kind here.  The bug fix you're opting 
out of is not at all specific to C++, and there are more straightforward ways 
to check the target than checking the C++ ABI kind.

I mean, I have no doubt that eventually there will be some significant C++ ABI 
bug fix that you don't want to pick up, so I'm not opposed to adding a new C++ 
ABI kind.  It just seems inappropriate to do that in this patch.


Comment at: lib/AST/RecordLayoutBuilder.cpp:1598-1599
@@ -1597,1 +1597,4 @@
 
+// PS4 remains compatible to pre r257462 behavior.
+bool isPS4ABI = (Context.getTargetInfo().getCXXABI().getKind() == 
TargetCXXABI::PS4);
+

rsmith wrote:
> Please say what that behavior was here. "The PS4 ABI ignores explicit 
> alignment attributes on bitfields." or similar.
Also, this should be added as a bit on TargetInfo instead of making it a 
target-specific check in random code.  This also makes it easier to make the 
code self-documenting, because instead of:

   } else if (ExplicitFieldAlign && !isPS4ABI) {

you'd have

   } else if (ExplicitFieldAlign && 
Context.getTargetInfo().useExplicitBitFieldAlignment()) {

You can then document the fact that your ABI is explicitly opting out of this 
bug fix in a comment on the line in Targets.cpp where you set this field to 
false.


http://reviews.llvm.org/D16788



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


Re: [PATCH] D16630: PR23057: Fix assertion `Val && "isa<> used on a null pointer"' on invalid for-range expression

2016-02-01 Thread David Majnemer via cfe-commits
majnemer added a subscriber: majnemer.


Comment at: lib/Parse/ParseStmt.cpp:1719-1724
@@ -1718,6 +1718,8 @@
   if (ForRange) {
+ExprResult CorrectedRange =
+Actions.CorrectDelayedTyposInExpr(ForRangeInit.RangeExpr.get());
 ForRangeStmt = Actions.ActOnCXXForRangeStmt(
 getCurScope(), ForLoc, CoawaitLoc, FirstPart.get(),
-ForRangeInit.ColonLoc, ForRangeInit.RangeExpr.get(),
+ForRangeInit.ColonLoc, CorrectedRange.get(),
 T.getCloseLocation(), Sema::BFRK_Build);
 

Does this change effect all of the test cases you've added? If not, I think it 
would make sense to split this change out.


http://reviews.llvm.org/D16630



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


  1   2   >