[PATCH] D32825: [clang-format] Improve understanding of combined typedef+record declarations

2017-05-05 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes added a comment.

It strikes me that this doesn't handle `using`-style type aliases, but it seems 
hard to do this correctly in general, so still valuable to catch this simple, 
common case. Let me know if you have any better suggestions!


https://reviews.llvm.org/D32825



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


[PATCH] D32524: [clang-format] Fix MatchingOpeningBlockLineIndex computation

2017-05-05 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

Thank you! A test would be nice.




Comment at: lib/Format/UnwrappedLineParser.cpp:432
   size_t OpeningLineIndex =
-  Lines.empty() ? (UnwrappedLine::kInvalidIndex) : (Lines.size() - 1);
+  CurrentLines->empty() ? (UnwrappedLine::kInvalidIndex) : 
(CurrentLines->size() - 1);  //Lines does not account for 'nested' lines
 

Could you please reformat and use '//'-style comments?


https://reviews.llvm.org/D32524



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


[PATCH] D32700: [clang-tidy] Add misc-suspicious-memset-usage check.

2017-05-05 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs updated this revision to Diff 97917.
rnkovacs edited the summary of this revision.
rnkovacs added a comment.

- Removed case related to virtual pointers as there is a diagnostic flag for 
that.
- Added case warning for calls on classes with a constructor or destructor. 
Changed tests and docs accordingly.


https://reviews.llvm.org/D32700

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/SuspiciousMemsetUsageCheck.cpp
  clang-tidy/misc/SuspiciousMemsetUsageCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-suspicious-memset-usage.rst
  test/clang-tidy/misc-suspicious-memset-usage.cpp

Index: test/clang-tidy/misc-suspicious-memset-usage.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-suspicious-memset-usage.cpp
@@ -0,0 +1,126 @@
+// RUN: %check_clang_tidy %s misc-suspicious-memset-usage %t
+
+void *memset(void *, int, __SIZE_TYPE__);
+
+template 
+void mtempl(int *ptr) {
+  memset(ptr, '0', sizeof(T));
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: memset fill value is char '0', potentially mistaken for int 0 [misc-suspicious-memset-usage]
+  // CHECK-FIXES: memset(ptr, 0, sizeof(T));
+  memset(ptr, 256, sizeof(T));
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: memset fill value is out of unsigned character range, gets truncated [misc-suspicious-memset-usage]
+}
+
+void FillValue() {
+  int i[5] = {1, 2, 3, 4, 5};
+  int *p = i;
+  int l = 5;
+  char z = '1';
+  char *c = &z;
+
+  memset(p, '0', l);
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: memset fill value is char '0', potentially mistaken for int 0 [misc-suspicious-memset-usage]
+  // CHECK-FIXES: memset(p, 0, l);
+  memset(p, 0xabcd, l);
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: memset fill value is out of unsigned character range, gets truncated [misc-suspicious-memset-usage]
+
+#define M_CHAR_ZERO memset(p, '0', l);
+  M_CHAR_ZERO
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: memset fill value is char '0', potentially mistaken for int 0 [misc-suspicious-memset-usage]
+#define M_OUTSIDE_RANGE memset(p, 0xabcd, l);
+  M_OUTSIDE_RANGE
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: memset fill value is out of unsigned character range, gets truncated [misc-suspicious-memset-usage]
+
+  memset(p, '2', l);
+  memset(p, 0, l);
+  memset(c, '0', 1);
+  memset(p, 0x00, l);
+  mtempl(p);
+}
+
+struct Ctor {
+  Ctor();
+  void fCtor() {
+memset(this, 0, sizeof(*this));
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: memset used on class with user-defined constructor or destructor [misc-suspicious-memset-usage]
+  }
+};
+
+struct Dtor {
+  ~Dtor();
+  void fDtor() {
+memset(this, 0, sizeof(*this));
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: memset used on class with user-defined constructor or destructor [misc-suspicious-memset-usage]
+  }
+};
+
+struct Both {
+  Both();
+  ~Both();
+  void fBoth() {
+memset(this, 0, sizeof(*this));
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: memset used on class with user-defined constructor or destructor [misc-suspicious-memset-usage]
+  }
+};
+
+struct Neither {
+  void fNeither() {
+memset(this, 0, sizeof(*this));
+  }
+};
+
+void Destination() {
+  Ctor a;
+  memset(&a, 0, 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: memset used on class with user-defined constructor or destructor [misc-suspicious-memset-usage]
+  Dtor b;
+  memset(&b, 0, 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: memset used on class with user-defined constructor or destructor [misc-suspicious-memset-usage]
+  Both c;
+  memset(&c, 0, 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: memset used on class with user-defined constructor or destructor [misc-suspicious-memset-usage]
+  Neither d;
+  memset(&d, 0, 1);
+}
+
+struct Inside {
+  Inside() {
+memset(this, 0, sizeof(*this));
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: memset used on class with user-defined constructor or destructor [misc-suspicious-memset-usage]
+  }
+  ~Inside() {
+memset(this, 0, sizeof(*this));
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: memset used on class with user-defined constructor or destructor [misc-suspicious-memset-usage]
+  }
+};
+
+struct Base {
+  Base();
+  ~Base();
+};
+
+struct Derived : public Base {
+  void fDerived() {
+memset(this, 0, sizeof(*this));
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: memset used on class with user-defined constructor or destructor [misc-suspicious-memset-usage]
+  }
+};
+
+struct Lambda {
+  Lambda();
+  ~Lambda();
+  void fLambda() {
+[this] { memset(this, 0, sizeof(*this)); };
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: memset used on class with user-defined constructor or destructor [misc-suspicious-memset-usage]
+  }
+};
+
+struct Outer {
+  Outer();
+  ~Outer();
+  struct Inner {
+void fInner() {
+  memset(this, 0, sizeof(*this));
+}
+  };
+};
Index: docs/clang-

[PATCH] D32424: Add a fix-it for -Wunguarded-availability

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



Comment at: lib/Sema/SemaDeclAttr.cpp:7151
+Visitor.Scope = Scope;
+Visitor.TraverseStmt(const_cast(Scope));
+return Visitor.LastMatchingDREFirstNonScopeStmt;

erik.pilkington wrote:
> I think this could be simplified: If we iterate backwards through the 
> CompoundStmt::body(), calling `RecursiveASTVisitor::TraverseStmt()`, and bail 
> out if we encounter a `DeclRefExpr` to D, returning the current Stmt. This 
> also has the advantage that we don't have to iterate forward through the 
> CompoundStmt when we're looking for the last Child Stmt. Have you considered 
> this option?
Good idea, I will change this code.


Repository:
  rL LLVM

https://reviews.llvm.org/D32424



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


[PATCH] D32424: Add a fix-it for -Wunguarded-availability

2017-05-05 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 97922.
arphaman marked 2 inline comments as done.
arphaman added a comment.

- Simplify the RecursiveASTVisitor as suggested by Erik
- Improve the note to include `__builtin_available`


Repository:
  rL LLVM

https://reviews.llvm.org/D32424

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Lex/Lexer.h
  lib/Lex/Lexer.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/FixIt/fixit-availability.c
  test/FixIt/fixit-availability.mm

Index: test/FixIt/fixit-availability.mm
===
--- /dev/null
+++ test/FixIt/fixit-availability.mm
@@ -0,0 +1,111 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunguarded-availability -fdiagnostics-parseable-fixits -triple x86_64-apple-darwin9 %s 2>&1 | FileCheck %s
+
+__attribute__((availability(macos, introduced=10.12)))
+int function(void);
+
+void anotherFunction(int function);
+
+int use() {
+  function();
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:14-[[@LINE-2]]:14}:"\n  } else {\n  // Fallback on earlier versions\n  }"
+  int y = function(), x = 0;
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:29-[[@LINE-2]]:29}:"\n  } else {\n  // Fallback on earlier versions\n  }"
+  x += function();
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:19-[[@LINE-2]]:19}:"\n  } else {\n  // Fallback on earlier versions\n  }"
+  if (1) {
+x = function();
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:5-[[@LINE-1]]:5}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:20-[[@LINE-2]]:20}:"\n  } else {\n  // Fallback on earlier versions\n  }"
+  }
+  anotherFunction(function());
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:31-[[@LINE-2]]:31}:"\n  } else {\n  // Fallback on earlier versions\n  }"
+  if (function()) {
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE+1]]:4-[[@LINE+1]]:4}:"\n  } else {\n  // Fallback on earlier versions\n  }"
+  }
+  while (function())
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE+1]]:6-[[@LINE+1]]:6}:"\n  } else {\n  // Fallback on earlier versions\n  }"
+;
+  do
+function();
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:5-[[@LINE-1]]:5}:"if (@available(macos 10.12, *)) {\n"
+// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:16-[[@LINE-2]]:16}:"\n} else {\n// Fallback on earlier versions\n}"
+  while (1);
+  for (int i = 0; i < 10; ++i)
+function();
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:5-[[@LINE-1]]:5}:"if (@available(macos 10.12, *)) {\n"
+// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:16-[[@LINE-2]]:16}:"\n} else {\n// Fallback on earlier versions\n}"
+  switch (x) {
+  case 0:
+function();
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:5-[[@LINE-1]]:5}:"if (@available(macos 10.12, *)) {\n"
+// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:16-[[@LINE-2]]:16}:"\n} else {\n// Fallback on earlier versions\n}"
+  case 2:
+anotherFunction(1);
+function();
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:5-[[@LINE-1]]:5}:"if (@available(macos 10.12, *)) {\n"
+// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:16-[[@LINE-2]]:16}:"\n} else {\n// Fallback on earlier versions\n}"
+break;
+  default:
+function();
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:5-[[@LINE-1]]:5}:"if (@available(macos 10.12, *)) {\n"
+// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:16-[[@LINE-2]]:16}:"\n} else {\n// Fallback on earlier versions\n}"
+break;
+  }
+  return function();
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:21-[[@LINE-2]]:21}:"\n  } else {\n  // Fallback on earlier versions\n  }"
+}
+
+#define MYFUNCTION function
+
+#define MACRO_ARGUMENT(X) X
+#define MACRO_ARGUMENT_SEMI(X) X;
+#define MACRO_ARGUMENT_2(X) if (1) X;
+
+#define INNER_MACRO if (1) MACRO_ARGUMENT(function()); else ;
+
+void useInMacros() {
+  MYFUNCTION();
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:16-[[@LINE-2]]:16}:"\n  } else {\n  // Fallback on earlier versions\n  }"
+
+  MACRO_ARGUMENT_SEMI(function())
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:34-[[@LINE-2]]:34}:"\n  } else {\n  // Fallback on earlier ver

[PATCH] D32896: [OpenCL] Make CLK_NULL_RESERVE_ID invalid reserve id.

2017-05-05 Thread Egor Churaev via Phabricator via cfe-commits
echuraev created this revision.
Herald added a subscriber: yaxunl.

Make CLK_NULL_RESERVE_ID invalid reserve id.

Rename PIPE_RESERVE_ID_VALID_BIT to avoid user name space pollution.

Current implementation reserve_id_t type assumes that it's a pointer
type whose most significant bit is set to one and the rest of the bits
keep the id value.

This patch increase reserve id size by one bit on 32-bit platforms and
by 33 bits on 64-bit platforms.


https://reviews.llvm.org/D32896

Files:
  lib/Headers/opencl-c.h


Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -16014,8 +16014,10 @@
 
 // OpenCL v2.0 s6.13.16 - Pipe Functions
 #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
-#define PIPE_RESERVE_ID_VALID_BIT (1U << 30)
-#define CLK_NULL_RESERVE_ID (__builtin_astype(((void*)(__SIZE_MAX__)), 
reserve_id_t))
+// The most significant bit of valid reserve_id must be set to one.
+#define __PIPE_RESERVE_ID_VALID_BIT ((size_t)1 << (sizeof(size_t) * 8 - 1))
+// The macro CLK_NULL_RESERVE_ID refers to an invalid reservation ID.
+#define CLK_NULL_RESERVE_ID (__builtin_astype((void *)0, reserve_id_t))
 bool __ovld is_valid_reserve_id(reserve_id_t reserve_id);
 #endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 


Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -16014,8 +16014,10 @@
 
 // OpenCL v2.0 s6.13.16 - Pipe Functions
 #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
-#define PIPE_RESERVE_ID_VALID_BIT (1U << 30)
-#define CLK_NULL_RESERVE_ID (__builtin_astype(((void*)(__SIZE_MAX__)), reserve_id_t))
+// The most significant bit of valid reserve_id must be set to one.
+#define __PIPE_RESERVE_ID_VALID_BIT ((size_t)1 << (sizeof(size_t) * 8 - 1))
+// The macro CLK_NULL_RESERVE_ID refers to an invalid reservation ID.
+#define CLK_NULL_RESERVE_ID (__builtin_astype((void *)0, reserve_id_t))
 bool __ovld is_valid_reserve_id(reserve_id_t reserve_id);
 #endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32897: [OpenCL] Added checking OpenCL version for cl_khr_mipmap_image built-ins

2017-05-05 Thread Egor Churaev via Phabricator via cfe-commits
echuraev created this revision.
Herald added a subscriber: yaxunl.

https://reviews.llvm.org/D32897

Files:
  lib/Headers/opencl-c.h

Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -14962,6 +14962,7 @@
 #endif //cl_khr_gl_msaa_sharing
 
 // OpenCL Extension v2.0 s9.18 - Mipmaps
+#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 #ifdef cl_khr_mipmap_image
 
 float4 __purefn __ovld read_imagef(read_only image1d_t image, sampler_t sampler, float coord, float lod);
@@ -15037,6 +15038,7 @@
 uint4 __purefn __ovld read_imageui(read_only image3d_t image, sampler_t sampler, float4 coord, float lod);
 
 #endif //cl_khr_mipmap_image
+#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
 /**
 * Sampler-less Image Access
@@ -15135,6 +15137,7 @@
 float __purefn __ovld read_imagef(read_write image2d_array_msaa_depth_t image, int4 coord, int sample);
 #endif //cl_khr_gl_msaa_sharing
 
+#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 #ifdef cl_khr_mipmap_image
 float4 __purefn __ovld read_imagef(read_write image1d_t image, sampler_t sampler, float coord, float lod);
 int4 __purefn __ovld read_imagei(read_write image1d_t image, sampler_t sampler, float coord, float lod);
@@ -15208,6 +15211,7 @@
 int4 __purefn __ovld read_imagei(read_write image3d_t image, sampler_t sampler, float4 coord, float lod);
 uint4 __purefn __ovld read_imageui(read_write image3d_t image, sampler_t sampler, float4 coord, float lod);
 #endif //cl_khr_mipmap_image
+#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
 // Image read functions returning half4 type
 #ifdef cl_khr_fp16
@@ -15319,6 +15323,7 @@
 #endif //cl_khr_depth_images
 
 // OpenCL Extension v2.0 s9.18 - Mipmaps
+#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 #ifdef cl_khr_mipmap_image
 void __ovld write_imagef(write_only image1d_t image, int coord, int lod, float4 color);
 void __ovld write_imagei(write_only image1d_t image, int coord, int lod, int4 color);
@@ -15345,6 +15350,7 @@
 void __ovld write_imageui(write_only image3d_t image, int4 coord, int lod, uint4 color);
 #endif
 #endif //cl_khr_mipmap_image
+#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
 // Image write functions for half4 type
 #ifdef cl_khr_fp16
@@ -15391,6 +15397,7 @@
 void __ovld write_imagef(read_write image2d_array_depth_t image, int4 coord, float color);
 #endif //cl_khr_depth_images
 
+#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 #ifdef cl_khr_mipmap_image
 void __ovld write_imagef(read_write image1d_t image, int coord, int lod, float4 color);
 void __ovld write_imagei(read_write image1d_t image, int coord, int lod, int4 color);
@@ -15417,6 +15424,7 @@
 void __ovld write_imageui(read_write image3d_t image, int4 coord, int lod, uint4 color);
 #endif
 #endif //cl_khr_mipmap_image
+#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
 // Image write functions for half4 type
 #ifdef cl_khr_fp16
@@ -15559,6 +15567,7 @@
 #endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
 // OpenCL Extension v2.0 s9.18 - Mipmaps
+#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 #ifdef cl_khr_mipmap_image
 /**
  * Return the image miplevels.
@@ -15574,11 +15583,9 @@
 int __ovld get_image_num_mip_levels(write_only image3d_t image);
 #endif
 
-#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 int __ovld get_image_num_mip_levels(read_write image1d_t image);
 int __ovld get_image_num_mip_levels(read_write image2d_t image);
 int __ovld get_image_num_mip_levels(read_write image3d_t image);
-#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
 int __ovld get_image_num_mip_levels(read_only image1d_array_t image);
 int __ovld get_image_num_mip_levels(read_only image2d_array_t image);
@@ -15590,14 +15597,13 @@
 int __ovld get_image_num_mip_levels(write_only image2d_array_depth_t image);
 int __ovld get_image_num_mip_levels(write_only image2d_depth_t image);
 
-#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 int __ovld get_image_num_mip_levels(read_write image1d_array_t image);
 int __ovld get_image_num_mip_levels(read_write image2d_array_t image);
 int __ovld get_image_num_mip_levels(read_write image2d_array_depth_t image);
 int __ovld get_image_num_mip_levels(read_write image2d_depth_t image);
-#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
 #endif //cl_khr_mipmap_image
+#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
 /**
  * Return the channel data type. Valid values are:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32898: [OpenCL] Handle OpenCL specific subelement types

2017-05-05 Thread Egor Churaev via Phabricator via cfe-commits
echuraev created this revision.
Herald added a subscriber: yaxunl.

https://reviews.llvm.org/D32898

Files:
  lib/Sema/SemaInit.cpp
  test/SemaOpenCL/array-init.cl


Index: test/SemaOpenCL/array-init.cl
===
--- /dev/null
+++ test/SemaOpenCL/array-init.cl
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// expected-no-diagnostics
+
+__kernel void k2(queue_t q1, queue_t q2) {
+  queue_t q[] = {q1, q2};
+}
+
+__kernel void k3(read_only pipe int p) {
+  reserve_id_t i1 = reserve_read_pipe(p, 1);
+  reserve_id_t i2 = reserve_read_pipe(p, 1);
+  reserve_id_t i[] = {i1, i2};
+}
+
+event_t create_event();
+__kernel void k5() {
+  event_t e1 = create_event();
+  event_t e2 = create_event();
+  event_t e[] = {e1, e2};
+}
+
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -1209,7 +1209,7 @@
 
   } else {
 assert((ElemType->isRecordType() || ElemType->isVectorType() ||
-ElemType->isClkEventT()) && "Unexpected type");
+ElemType->isOpenCLSpecificType()) && "Unexpected type");
 
 // C99 6.7.8p13:
 //


Index: test/SemaOpenCL/array-init.cl
===
--- /dev/null
+++ test/SemaOpenCL/array-init.cl
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// expected-no-diagnostics
+
+__kernel void k2(queue_t q1, queue_t q2) {
+  queue_t q[] = {q1, q2};
+}
+
+__kernel void k3(read_only pipe int p) {
+  reserve_id_t i1 = reserve_read_pipe(p, 1);
+  reserve_id_t i2 = reserve_read_pipe(p, 1);
+  reserve_id_t i[] = {i1, i2};
+}
+
+event_t create_event();
+__kernel void k5() {
+  event_t e1 = create_event();
+  event_t e2 = create_event();
+  event_t e[] = {e1, e2};
+}
+
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -1209,7 +1209,7 @@
 
   } else {
 assert((ElemType->isRecordType() || ElemType->isVectorType() ||
-ElemType->isClkEventT()) && "Unexpected type");
+ElemType->isOpenCLSpecificType()) && "Unexpected type");
 
 // C99 6.7.8p13:
 //
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32900: [mips] Impose a threshold for coercion of aggregates

2017-05-05 Thread Stefan Maksimovic via Phabricator via cfe-commits
smaksimovic created this revision.
Herald added a subscriber: arichardson.

Modified MipsABIInfo::classifyArgumentType so that it now coerces aggregate 
structures
only if the size of said aggregate is less than 16/64 bytes, depending on the 
ABI.


https://reviews.llvm.org/D32900

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/mips-aggregate-arg.c


Index: test/CodeGen/mips-aggregate-arg.c
===
--- test/CodeGen/mips-aggregate-arg.c
+++ test/CodeGen/mips-aggregate-arg.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | 
FileCheck -check-prefix=O32 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n32 | FileCheck -check-prefix=N32-N64 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n64| FileCheck -check-prefix=N32-N64 %s
+
+struct t1 {
+  char t1[10];
+};
+
+struct t2 {
+  char t2[20];
+};
+
+struct t3 {
+  char t3[65];
+};
+
+extern struct t1 g1;
+extern struct t2 g2;
+extern struct t3 g3;
+extern void f1(struct t1);
+extern void f2(struct t2);
+extern void f3(struct t3);
+
+void f() {
+
+// O32:  call void @f1(i32 inreg %3, i32 inreg %5, i16 inreg %7)
+// O32:  call void @f2(%struct.t2* byval align 4 %tmp)
+// O32:  call void @f3(%struct.t3* byval align 4 %tmp1)
+
+// N32-N64:  call void @f1(i64 inreg %3, i16 inreg %5)
+// N32-N64:  call void @f2(i64 inreg %9, i64 inreg %11, i32 inreg %13)
+// N32-N64:  call void @f3(%struct.t3* byval align 8 %tmp)
+
+  f1(g1);
+  f2(g2);
+  f3(g3);  
+}
+
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -6696,6 +6696,14 @@
   return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
 }
 
+// Use indirect if the aggregate cannot fit into registers for
+// passing arguments according to the ABI
+unsigned Threshold = IsO32 ? 16 : 64;
+
+if(getContext().getTypeSizeInChars(Ty) > 
CharUnits::fromQuantity(Threshold))
+  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true,
+ getContext().getTypeAlign(Ty) / 8 > 
Align);
+
 // If we have reached here, aggregates are passed directly by coercing to
 // another structure type. Padding is inserted if the offset of the
 // aggregate is unaligned.


Index: test/CodeGen/mips-aggregate-arg.c
===
--- test/CodeGen/mips-aggregate-arg.c
+++ test/CodeGen/mips-aggregate-arg.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=O32 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  -target-abi n32 | FileCheck -check-prefix=N32-N64 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  -target-abi n64| FileCheck -check-prefix=N32-N64 %s
+
+struct t1 {
+  char t1[10];
+};
+
+struct t2 {
+  char t2[20];
+};
+
+struct t3 {
+  char t3[65];
+};
+
+extern struct t1 g1;
+extern struct t2 g2;
+extern struct t3 g3;
+extern void f1(struct t1);
+extern void f2(struct t2);
+extern void f3(struct t3);
+
+void f() {
+
+// O32:  call void @f1(i32 inreg %3, i32 inreg %5, i16 inreg %7)
+// O32:  call void @f2(%struct.t2* byval align 4 %tmp)
+// O32:  call void @f3(%struct.t3* byval align 4 %tmp1)
+
+// N32-N64:  call void @f1(i64 inreg %3, i16 inreg %5)
+// N32-N64:  call void @f2(i64 inreg %9, i64 inreg %11, i32 inreg %13)
+// N32-N64:  call void @f3(%struct.t3* byval align 8 %tmp)
+
+  f1(g1);
+  f2(g2);
+  f3(g3);  
+}
+
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -6696,6 +6696,14 @@
   return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
 }
 
+// Use indirect if the aggregate cannot fit into registers for
+// passing arguments according to the ABI
+unsigned Threshold = IsO32 ? 16 : 64;
+
+if(getContext().getTypeSizeInChars(Ty) > CharUnits::fromQuantity(Threshold))
+  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true,
+ getContext().getTypeAlign(Ty) / 8 > Align);
+
 // If we have reached here, aggregates are passed directly by coercing to
 // another structure type. Padding is inserted if the offset of the
 // aggregate is unaligned.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32810: Add cxxStdInitializerListExpr AST matcher

2017-05-05 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

LG


Repository:
  rL LLVM

https://reviews.llvm.org/D32810



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


[PATCH] D32767: [clang-tidy] Fix PR32896: detect initializer lists in modernize-use-empalce

2017-05-05 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

LG


Repository:
  rL LLVM

https://reviews.llvm.org/D32767



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


[PATCH] D32856: [OpenCL] Check that global samplers are const

2017-05-05 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh updated this revision to Diff 97932.
svenvh added a comment.

Improve diagnostic text as suggested.


https://reviews.llvm.org/D32856

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/SemaOpenCL/sampler_t.cl


Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -9,7 +9,7 @@
 
 constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
 constant sampler_t glb_smp2; // expected-error{{variable in constant address 
space must be initialized}}
-global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sampler 
type cannot be used with the __local and __global address space qualifiers}}
+global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sampler 
type cannot be used with the __local and __global address space qualifiers}} 
expected-error {{global sampler requires a const or constant address space 
qualifier}}
 
 constant sampler_t glb_smp4 = 0;
 #ifdef CHECK_SAMPLER_VALUE
@@ -38,6 +38,8 @@
 
 sampler_t bad(void); //expected-error{{declaring function return value of type 
'sampler_t' is not allowed}}
 
+sampler_t global_nonconst_smp = 0; // expected-error {{global sampler requires 
a const or constant address space qualifier}}
+
 void kernel ker(sampler_t argsmp) {
   local sampler_t smp; // expected-error{{sampler type cannot be used with the 
__local and __global address space qualifiers}}
   const sampler_t const_smp = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6070,12 +6070,24 @@
   }
 }
 
-// OpenCL v1.2 s6.9.b p4:
-// The sampler type cannot be used with the __local and __global address
-// space qualifiers.
-if (R->isSamplerT() && (R.getAddressSpace() == LangAS::opencl_local ||
-  R.getAddressSpace() == LangAS::opencl_global)) {
-  Diag(D.getIdentifierLoc(), diag::err_wrong_sampler_addressspace);
+if (R->isSamplerT()) {
+  // OpenCL v1.2 s6.9.b p4:
+  // The sampler type cannot be used with the __local and __global address
+  // space qualifiers.
+  if (R.getAddressSpace() == LangAS::opencl_local ||
+  R.getAddressSpace() == LangAS::opencl_global) {
+Diag(D.getIdentifierLoc(), diag::err_wrong_sampler_addressspace);
+  }
+
+  // OpenCL v1.2 s6.12.14.1:
+  // A global sampler must be declared with either the constant address
+  // space qualifier or with the const qualifier.
+  if (DC->isTranslationUnit() &&
+  !(R.getAddressSpace() == LangAS::opencl_constant ||
+  R.isConstQualified())) {
+Diag(D.getIdentifierLoc(), diag::err_opencl_nonconst_global_sampler);
+D.setInvalidType();
+  }
 }
 
 // OpenCL v1.2 s6.9.r:
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8297,6 +8297,8 @@
   "sampler_t variable required - got %0">;
 def err_wrong_sampler_addressspace: Error<
   "sampler type cannot be used with the __local and __global address space 
qualifiers">;
+def err_opencl_nonconst_global_sampler : Error<
+  "global sampler requires a const or constant address space qualifier">;
 def err_opencl_cast_non_zero_to_event_t : Error<
   "cannot cast non-zero value '%0' to 'event_t'">;
 def err_opencl_global_invalid_addr_space : Error<


Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -9,7 +9,7 @@
 
 constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
 constant sampler_t glb_smp2; // expected-error{{variable in constant address space must be initialized}}
-global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}}
+global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}} expected-error {{global sampler requires a const or constant address space qualifier}}
 
 constant sampler_t glb_smp4 = 0;
 #ifdef CHECK_SAMPLER_VALUE
@@ -38,6 +38,8 @@
 
 sampler_t bad(void); //expected-error{{declaring function return value of type 'sampler_t' is not allowed}}
 
+sampler_t global_nonconst_smp = 0; // expected-error {{global sampler requires 

[PATCH] D32815: [clang-tidy][CMake] Make clang-tidy usable as distribution component

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

I'm not sure I understand all implications, but from a cursory glance this 
seems reasonable.


Repository:
  rL LLVM

https://reviews.llvm.org/D32815



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


[PATCH] D32856: [OpenCL] Check that global samplers are const

2017-05-05 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh marked an inline comment as done.
svenvh added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:6085
+  // space qualifier or with the const qualifier.
+  if (DC->isTranslationUnit() &&
+  !(R.getAddressSpace() == LangAS::opencl_constant ||

yaxunl wrote:
> should be else if ?
> 
> if the previous error already happens, it is unnecessary to do the next check

Sure, I can do that, I am just not sure what the desirable behaviour is here?  
They are different errors, so with the current patch it emits both diagnostics 
(see the first test change).  If we just want one diagnostic (the first one in 
that test case), I can change it to else if; please let me know if you prefer 
that.


https://reviews.llvm.org/D32856



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


[PATCH] D32743: [clang-tidy] Add new cert-dcl21-cpp check.

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



Comment at: clang-tidy/cert/PostfixOperatorCheck.cpp:27
+hasOverloadedOperatorName("--")))
+ .bind("decl"),
+ this);

JonasToth wrote:
> could the `,this);` be on this line? seems odd.
Just let clang-format do its job, no need for manual tuning.

```
  Finder->addMatcher(functionDecl(anyOf(hasOverloadedOperatorName("++"),
hasOverloadedOperatorName("--")))
 .bind("decl"),
 this);
```

In this specific case `this` being on a separate line is reasonable, since the 
first argument of `addMatcher` spans multiple lines and it's more difficult to 
spot the second argument when it's placed on the same line  as `.bind(...)`.



Comment at: test/clang-tidy/cert-dcl21-cpp.cpp:1
+// RUN: %check_clang_tidy %s cert-dcl21-cpp %t
+

As usual, please add tests with macros and templates with multiple 
instantiations. When diagnostics in macros are ignored, the tests should 
demonstrate this as well.


https://reviews.llvm.org/D32743



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


[PATCH] D32903: Remove unused variable and argument from Lex/HeaderSearch.cpp

2017-05-05 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta created this revision.

https://reviews.llvm.org/D32903

Files:
  clang/lib/Lex/HeaderSearch.cpp

Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -234,9 +234,9 @@
   break;
   }
 }
-
+
 // FIXME: Figure out how header maps and module maps will work together.
-
+
 // Only deal with normal search directories.
 if (!SearchDirs[Idx].isNormalDir())
   continue;
@@ -251,7 +251,7 @@
   if (Module)
 break;
 }
-  
+
 // Search for a module map in a subdirectory with the same name as the
 // module.
 SmallString<128> NestedModuleMapDirName;
@@ -399,11 +399,8 @@
 ///
 /// \param FileMgr The file manager to use for directory lookups.
 /// \param DirName The name of the framework directory.
-/// \param SubmodulePath Will be populated with the submodule path from the
-/// returned top-level module to the originally named framework.
 static const DirectoryEntry *
-getTopFrameworkDir(FileManager &FileMgr, StringRef DirName,
-   SmallVectorImpl &SubmodulePath) {
+getTopFrameworkDir(FileManager &FileMgr, StringRef DirName) {
   assert(llvm::sys::path::extension(DirName) == ".framework" &&
  "Not a framework directory");
 
@@ -437,7 +434,6 @@
 // If this is a framework directory, then we're a subframework of this
 // framework.
 if (llvm::sys::path::extension(DirName) == ".framework") {
-  SubmodulePath.push_back(llvm::sys::path::stem(DirName));
   TopFrameworkDir = Dir;
 }
   } while (true);
@@ -518,7 +514,7 @@
 RelativePath->clear();
 RelativePath->append(Filename.begin()+SlashPos+1, Filename.end());
   }
-  
+
   // Check "/System/Library/Frameworks/Cocoa.framework/Headers/file.h"
   unsigned OrigSize = FrameworkName.size();
 
@@ -630,7 +626,7 @@
 
   if (SuggestedModule)
 *SuggestedModule = ModuleMap::KnownHeader();
-
+
   // If 'Filename' is absolute, check to see if it exists and no searching.
   if (llvm::sys::path::is_absolute(Filename)) {
 CurDir = nullptr;
@@ -815,7 +811,7 @@
   size_t SlashPos = Filename.find('/');
   if (SlashPos != StringRef::npos) {
 HFI.IndexHeaderMapHeader = 1;
-HFI.Framework = getUniqueFrameworkName(StringRef(Filename.begin(), 
+HFI.Framework = getUniqueFrameworkName(StringRef(Filename.begin(),
  SlashPos));
   }
 }
@@ -991,7 +987,7 @@
 
 /// \brief Merge the header file info provided by \p OtherHFI into the current
 /// header file info (\p HFI)
-static void mergeHeaderFileInfo(HeaderFileInfo &HFI, 
+static void mergeHeaderFileInfo(HeaderFileInfo &HFI,
 const HeaderFileInfo &OtherHFI) {
   assert(OtherHFI.External && "expected to merge external HFI");
 
@@ -1013,7 +1009,7 @@
   if (HFI.Framework.empty())
 HFI.Framework = OtherHFI.Framework;
 }
-
+
 /// getFileInfo - Return the HeaderFileInfo structure for the specified
 /// FileEntry.
 HeaderFileInfo &HeaderSearch::getFileInfo(const FileEntry *FE) {
@@ -1195,14 +1191,14 @@
   return FrameworkNames.insert(Framework).first->first();
 }
 
-bool HeaderSearch::hasModuleMap(StringRef FileName, 
+bool HeaderSearch::hasModuleMap(StringRef FileName,
 const DirectoryEntry *Root,
 bool IsSystem) {
   if (!HSOpts->ImplicitModuleMaps)
 return false;
 
   SmallVector FixUpDirectories;
-  
+
   StringRef DirName = FileName;
   do {
 // Get the parent directory name.
@@ -1235,7 +1231,7 @@
 // If we hit the top of our search, we're done.
 if (Dir == Root)
   return false;
-
+
 // Keep track of all of the directories we checked, so we can mark them as
 // having module maps if we eventually do find a module map.
 FixUpDirectories.push_back(Dir);
@@ -1292,10 +1288,9 @@
   // If we're supposed to suggest a module, look for one now.
   if (needModuleLookup(RequestingModule, SuggestedModule)) {
 // Find the top-level framework based on this framework.
-SmallVector SubmodulePath;
-const DirectoryEntry *TopFrameworkDir
-  = ::getTopFrameworkDir(FileMgr, FrameworkName, SubmodulePath);
-
+const DirectoryEntry *TopFrameworkDir =
+::getTopFrameworkDir(FileMgr, FrameworkName);
+
 // Determine the name of the top-level framework.
 StringRef ModuleName = llvm::sys::path::stem(TopFrameworkDir->getName());
 
@@ -1428,16 +1423,16 @@
 }
 
 
-HeaderSearch::LoadModuleMapResult 
+HeaderSearch::LoadModuleMapResult
 HeaderSearch::loadModuleMapFile(StringRef DirName, bool IsSystem,
 bool IsFramework) {
   if (const DirectoryEntry *Dir = FileMgr.getDirectory(DirName))
 return loadModuleMapFile(Dir, IsSystem, IsFramework);
-  
+
   return LMM_NoDirectory;
 }

[PATCH] D32902: [Analyzer] Iterator Checker - Part 7: Support for push and pop operations

2017-05-05 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 97942.
baloghadamsoftware added a comment.

Wrong diff.


https://reviews.llvm.org/D32902

Files:
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  test/Analysis/Inputs/system-header-simulator-cxx.h
  test/Analysis/diagnostics/explicit-suppression.cpp
  test/Analysis/invalidated-iterator.cpp
  test/Analysis/iterator-range.cpp

Index: test/Analysis/iterator-range.cpp
===
--- test/Analysis/iterator-range.cpp
+++ test/Analysis/iterator-range.cpp
@@ -97,8 +97,66 @@
   }
 }
 
+void good_push_back(std::list &L, int n) {
+  auto i0 = --L.cend();
+  L.push_back(n);
+  *++i0; // no-warning
+}
+
+void bad_push_back(std::list &L, int n) {
+  auto i0 = --L.cend();
+  L.push_back(n);
+  ++i0;
+  *++i0; // expected-warning{{Iterator accessed outside of its range}}
+}
+
+void good_pop_back(std::list &L, int n) {
+  auto i0 = --L.cend(); --i0;
+  L.pop_back();
+  *i0; // no-warning
+}
+
+void bad_pop_back(std::list &L, int n) {
+  auto i0 = --L.cend(); --i0;
+  L.pop_back();
+  *++i0; // expected-warning{{Iterator accessed outside of its range}}
+}
+
+void good_push_front(std::list &L, int n) {
+  auto i0 = L.cbegin();
+  L.push_front(n);
+  *--i0; // no-warning
+}
+
+void bad_push_front(std::list &L, int n) {
+  auto i0 = L.cbegin();
+  L.push_front(n);
+  --i0;
+  *--i0; // expected-warning{{Iterator accessed outside of its range}}
+}
+
+void good_pop_front(std::list &L, int n) {
+  auto i0 = ++L.cbegin();
+  L.pop_front();
+  *i0; // no-warning
+}
+
+void bad_pop_front(std::list &L, int n) {
+  auto i0 = ++L.cbegin();
+  L.pop_front();
+  *--i0; // expected-warning{{Iterator accessed outside of its range}}
+}
+
 void bad_move(std::list &L1, std::list &L2) {
   auto i0 = --L2.cend();
   L1 = std::move(L2);
   *++i0; // expected-warning{{Iterator accessed outside of its range}}
 }
+
+void bad_move_push_back(std::list &L1, std::list &L2, int n) {
+  auto i0 = --L2.cend();
+  L2.push_back(n);
+  L1 = std::move(L2);
+  ++i0;
+  *++i0; // expected-warning{{Iterator accessed outside of its range}}
+}
Index: test/Analysis/invalidated-iterator.cpp
===
--- test/Analysis/invalidated-iterator.cpp
+++ test/Analysis/invalidated-iterator.cpp
@@ -30,3 +30,170 @@
   FL1 = FL2;
   *i0; // expected-warning{{Invalidated iterator accessed}}
 }
+
+void good_push_back_list1(std::list &L, int n) {
+  auto i0 = L.cbegin(), i1 = L.cend();
+  L.push_back(n);
+  *i0; // no-warning
+  --i1; // no-warning
+}
+
+void good_push_back_vector1(std::vector &V, int n) {
+  auto i0 = V.cbegin(), i1 = V.cend();
+  V.push_back(n);
+  *i0; // no-warning
+}
+
+void bad_push_back_vector1(std::vector &V, int n) {
+  auto i0 = V.cbegin(), i1 = V.cend();
+  V.push_back(n);
+  --i1; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void bad_push_back_deque1(std::deque &D, int n) {
+  auto i0 = D.cbegin(), i1 = D.cend();
+  D.push_back(n);
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+  --i1; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void good_emplace_back_list1(std::list &L, int n) {
+  auto i0 = L.cbegin(), i1 = L.cend();
+  L.emplace_back(n);
+  *i0; // no-warning
+  --i1; // no-warning
+}
+
+void good_emplace_back_vector1(std::vector &V, int n) {
+  auto i0 = V.cbegin(), i1 = V.cend();
+  V.emplace_back(n);
+  *i0; // no-warning
+}
+
+void bad_emplace_back_vector1(std::vector &V, int n) {
+  auto i0 = V.cbegin(), i1 = V.cend();
+  V.emplace_back(n);
+  --i1; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void bad_emplace_back_deque1(std::deque &D, int n) {
+  auto i0 = D.cbegin(), i1 = D.cend();
+  D.emplace_back(n);
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+  --i1; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void good_pop_back_list1(std::list &L, int n) {
+  auto i0 = L.cbegin(), i1 = L.cend(), i2 = i1--;
+  L.pop_back();
+  *i0; // no-warning
+  *i2; // no-warning
+}
+
+void bad_pop_back_list1(std::list &L, int n) {
+  auto i0 = L.cbegin(), i1 = L.cend(), i2 = i1--;
+  L.pop_back();
+  *i1; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void good_pop_back_vector1(std::vector &V, int n) {
+  auto i0 = V.cbegin(), i1 = V.cend(), i2 = i1--;
+  V.pop_back();
+  *i0; // no-warning
+}
+
+void bad_pop_back_vector1(std::vector &V, int n) {
+  auto i0 = V.cbegin(), i1 = V.cend(), i2 = i1--;
+  V.pop_back();
+  *i1; // expected-warning{{Invalidated iterator accessed}}
+  --i2; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void good_pop_back_deque1(std::deque &D, int n) {
+  auto i0 = D.cbegin(), i1 = D.cend(), i2 = i1--;
+  D.pop_back();
+  *i0; // no-warning
+}
+
+void bad_pop_back_deque1(std::deque &D, int n) {
+  auto i0 = D.cbegin(), i1 = D.cend(), i2 = i1--;
+  D.pop_back();
+  *i1; // expected-warning{{Invalidated iterator accessed}}
+  --i2; // expected-warning{{Invalidated i

[PATCH] D32904: [Analyzer] Iterator Checker - Part 8: Support for assign, clear, insert, emplace and erase operations

2017-05-05 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.

This patch adds support for the following operations in the iterator checkers: 
assign, clear, insert, insert_after, emplace, emplace_after, erase and 
erase_after. This affects mismatched iterator checks ("this" and parameter must 
match) and invalidation checks (according to the standard).


https://reviews.llvm.org/D32904

Files:
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  test/Analysis/Inputs/system-header-simulator-cxx.h
  test/Analysis/diagnostics/explicit-suppression.cpp
  test/Analysis/invalidated-iterator.cpp
  test/Analysis/mismatched-iterator.cpp

Index: test/Analysis/mismatched-iterator.cpp
===
--- test/Analysis/mismatched-iterator.cpp
+++ test/Analysis/mismatched-iterator.cpp
@@ -3,6 +3,40 @@
 
 #include "Inputs/system-header-simulator-cxx.h"
 
+void good_insert1(std::vector &v, int n) {
+  v.insert(v.cbegin(), n); // no-warning
+}
+
+
+void good_insert2(std::vector &v, int len, int n) {
+  v.insert(v.cbegin(), len, n); // no-warning
+}
+
+void good_insert3(std::vector &v1, std::vector &v2) {
+  v1.insert(v1.cbegin(), v2.cbegin(), v2.cend()); // no-warning
+}
+
+void good_insert4(std::vector &v, int len, int n) {
+  v.insert(v.cbegin(), {n-1, n, n+1}); // no-warning
+}
+
+void good_insert_find(std::vector &v, int n, int m) {
+  auto i = std::find(v.cbegin(), v.cend(), n);
+  v.insert(i, m); // no-warning
+}
+
+void good_erase1(std::vector &v) {
+  v.erase(v.cbegin()); // no-warning
+}
+
+void good_erase2(std::vector &v) {
+  v.erase(v.cbegin(), v.cend()); // no-warning
+}
+
+void good_emplace(std::vector &v, int n) {
+  v.emplace(v.cbegin(), n); // no-warning
+}
+
 void good_ctor(std::vector &v) {
   std::vector new_v(v.cbegin(), v.cend()); // no-warning
 }
@@ -29,6 +63,38 @@
   if (v.cbegin() == v.cend()) {} // no-warning
 }
 
+void bad_insert1(std::vector &v1, std::vector &v2, int n) {
+  v2.insert(v1.cbegin(), n); // expected-warning{{Iterator access mismatched}}
+}
+
+void bad_insert2(std::vector &v1, std::vector &v2, int len, int n) {
+  v2.insert(v1.cbegin(), len, n); // expected-warning{{Iterator access mismatched}}
+}
+
+void bad_insert3(std::vector &v1, std::vector &v2) {
+  v2.insert(v1.cbegin(), v2.cbegin(), v2.cend()); // expected-warning{{Iterator access mismatched}}
+  v1.insert(v1.cbegin(), v1.cbegin(), v2.cend()); // expected-warning{{Iterator access mismatched}}
+  v1.insert(v1.cbegin(), v2.cbegin(), v1.cend()); // expected-warning{{Iterator access mismatched}}
+}
+
+void bad_insert4(std::vector &v1, std::vector &v2, int len, int n) {
+  v2.insert(v1.cbegin(), {n-1, n, n+1}); // expected-warning{{Iterator access mismatched}}
+}
+
+void bad_erase1(std::vector &v1, std::vector &v2) {
+  v2.erase(v1.cbegin()); // expected-warning{{Iterator access mismatched}}
+}
+
+void bad_erase2(std::vector &v1, std::vector &v2) {
+  v2.erase(v2.cbegin(), v1.cend()); // expected-warning{{Iterator access mismatched}}
+  v2.erase(v1.cbegin(), v2.cend()); // expected-warning{{Iterator access mismatched}}
+  v2.erase(v1.cbegin(), v1.cend()); // expected-warning{{Iterator access mismatched}}
+}
+
+void bad_emplace(std::vector &v1, std::vector &v2, int n) {
+  v2.emplace(v1.cbegin(), n); // expected-warning{{Iterator access mismatched}}
+}
+
 void bad_ctor(std::vector &v1, std::vector &v2) {
   std::vector new_v(v1.cbegin(), v2.cend()); // expected-warning{{Iterator access mismatched}}
 }
@@ -53,3 +119,32 @@
 *v1.cbegin();
   }
 }
+
+void bad_insert_find(std::vector &v1, std::vector &v2, int n, int m) {
+  auto i = std::find(v1.cbegin(), v1.cend(), n);
+  v2.insert(i, m); // expected-warning{{Iterator access mismatched}}
+}
+
+void good_overwrite(std::vector &v1, std::vector &v2, int n) {
+  auto i = v1.cbegin();
+  i = v2.cbegin();
+  v2.insert(i, n); // no-warning
+}
+
+void bad_overwrite(std::vector &v1, std::vector &v2, int n) {
+  auto i = v1.cbegin();
+  i = v2.cbegin();
+  v1.insert(i, n); // expected-warning{{Iterator access mismatched}}
+}
+
+void good_move(std::vector &v1, std::vector &v2) {
+  const auto i0 = ++v2.cbegin();
+  v1 = std::move(v2);
+  v1.erase(i0); // no-warning
+}
+
+void bad_move(std::vector &v1, std::vector &v2) {
+  const auto i0 = ++v2.cbegin();
+  v1 = std::move(v2);
+  v2.erase(i0); // expected-warning{{Iterator access mismatched}}
+}
Index: test/Analysis/invalidated-iterator.cpp
===
--- test/Analysis/invalidated-iterator.cpp
+++ test/Analysis/invalidated-iterator.cpp
@@ -31,6 +31,56 @@
   *i0; // expected-warning{{Invalidated iterator accessed}}
 }
 
+void bad_assign_list1(std::list &L, int n) {
+  auto i0 = L.cbegin();
+  L.assign(10, n);
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void bad_assign_vector1(std::vector &V, int n) {
+  auto i0 = V.cbegin();
+  V.assign(10, n);
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void bad_assign_deque1(s

[PATCH] D32351: [Tooling][libclang] Remove unused CompilationDatabase::MappedSources

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

Is there a specific reason to take this out? It seems generally useful to allow 
compilation-db implementors to provide sources.


https://reviews.llvm.org/D32351



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


[PATCH] D32905: [Analyzer] Iterator Checker - Part 9: Evaluation of std::find-like calls

2017-05-05 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.

This patch adds explicit evaluation of the following functions: std::find, 
std::find_end, std::find_first_of, std::find_if, std::find_if_not, 
std::lower_bound, std::upper_bound, std::search and std::search_n. On the one 
hand this is an optimization since the result of each of these functions is an 
iterators either inside the range or the iterator past the end of the range. 
This evaluation does exactly this. (We cannot simulate "inside the range" just 
an iterator bound to the same container with a new offset). On the other hand 
this evaluation is needed for random access operators since some STL 
implementations do some optimization where the length of the range is used 
instead of iterating until the end. This is hard to track in a checker so we 
must do this evaluation to prevent false positives and catch more real bugs.


https://reviews.llvm.org/D32905

Files:
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  test/Analysis/Inputs/system-header-simulator-cxx.h
  test/Analysis/iterator-range.cpp

Index: test/Analysis/iterator-range.cpp
===
--- test/Analysis/iterator-range.cpp
+++ test/Analysis/iterator-range.cpp
@@ -79,6 +79,125 @@
 *i2; // expected-warning{{Iterator accessed outside of its range}}
 }
 
+void good_find(std::vector &V, int e) {
+  auto first = std::find(V.begin(), V.end(), e);
+  if (V.end() != first)
+*first; // no-warning
+}
+
+void bad_find(std::vector &V, int e) {
+  auto first = std::find(V.begin(), V.end(), e);
+  *first; // expected-warning{{Iterator accessed outside of its range}}
+}
+
+void good_find_end(std::vector &V, std::vector &seq) {
+  auto last = std::find_end(V.begin(), V.end(), seq.begin(), seq.end());
+  if (V.end() != last)
+*last; // no-warning
+}
+
+void bad_find_end(std::vector &V, std::vector &seq) {
+  auto last = std::find_end(V.begin(), V.end(), seq.begin(), seq.end());
+  *last; // expected-warning{{Iterator accessed outside of its range}}
+}
+
+void good_find_first_of(std::vector &V, std::vector &seq) {
+  auto first =
+  std::find_first_of(V.begin(), V.end(), seq.begin(), seq.end());
+  if (V.end() != first)
+*first; // no-warning
+}
+
+void bad_find_first_of(std::vector &V, std::vector &seq) {
+  auto first = std::find_end(V.begin(), V.end(), seq.begin(), seq.end());
+  *first; // expected-warning{{Iterator accessed outside of its range}}
+}
+
+bool odd(int i) { return i % 2; }
+
+void good_find_if(std::vector &V) {
+  auto first = std::find_if(V.begin(), V.end(), odd);
+  if (V.end() != first)
+*first; // no-warning
+}
+
+void bad_find_if(std::vector &V, int e) {
+  auto first = std::find_if(V.begin(), V.end(), odd);
+  *first; // expected-warning{{Iterator accessed outside of its range}}
+}
+
+void good_find_if_not(std::vector &V) {
+  auto first = std::find_if_not(V.begin(), V.end(), odd);
+  if (V.end() != first)
+*first; // no-warning
+}
+
+void bad_find_if_not(std::vector &V, int e) {
+  auto first = std::find_if_not(V.begin(), V.end(), odd);
+  *first; // expected-warning{{Iterator accessed outside of its range}}
+}
+
+void good_lower_bound(std::vector &V, int e) {
+  auto first = std::lower_bound(V.begin(), V.end(), e);
+  if (V.end() != first)
+*first; // no-warning
+}
+
+void bad_lower_bound(std::vector &V, int e) {
+  auto first = std::lower_bound(V.begin(), V.end(), e);
+  *first; // expected-warning{{Iterator accessed outside of its range}}
+}
+
+void good_upper_bound(std::vector &V, int e) {
+  auto last = std::lower_bound(V.begin(), V.end(), e);
+  if (V.end() != last)
+*last; // no-warning
+}
+
+void bad_upper_bound(std::vector &V, int e) {
+  auto last = std::lower_bound(V.begin(), V.end(), e);
+  *last; // expected-warning{{Iterator accessed outside of its range}}
+}
+
+void good_search(std::vector &V, std::vector &seq) {
+  auto first = std::search(V.begin(), V.end(), seq.begin(), seq.end());
+  if (V.end() != first)
+*first; // no-warning
+}
+
+void bad_search(std::vector &V, std::vector &seq) {
+  auto first = std::search(V.begin(), V.end(), seq.begin(), seq.end());
+  *first; // expected-warning{{Iterator accessed outside of its range}}
+}
+
+void good_search_n(std::vector &V, std::vector &seq) {
+  auto nth = std::search_n(V.begin(), V.end(), seq.begin(), seq.end());
+  if (V.end() != nth)
+*nth; // no-warning
+}
+
+void bad_search_n(std::vector &V, std::vector &seq) {
+  auto nth = std::search_n(V.begin(), V.end(), seq.begin(), seq.end());
+  *nth; // expected-warning{{Iterator accessed outside of its range}}
+}
+
+template 
+InputIterator nonStdFind(InputIterator first, InputIterator last,
+ const T &val) {
+  for (auto i = first; i != last; ++i) {
+if (*i == val) {
+  return i;
+}
+  }
+  return last;
+}
+
+void good_non_std_find(std::vector &V, int e) {
+  auto first = nonStdFind(V.begin(), V.end(), e);
+  if (V.end() != first)
+*first

[PATCH] D32906: [Analyzer] Iterator Checker - Part 10: Support for iterators passed as parameter

2017-05-05 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.

check::Bind() is not invoked for parameter passing. We use a trick instead: in 
checkBeginFunction we copy the positions of iterator parameters from the 
arguments to the parameters.


https://reviews.llvm.org/D32906

Files:
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  test/Analysis/iterator-range.cpp
  test/Analysis/mismatched-iterator.cpp

Index: test/Analysis/mismatched-iterator.cpp
===
--- test/Analysis/mismatched-iterator.cpp
+++ test/Analysis/mismatched-iterator.cpp
@@ -137,6 +137,19 @@
   v1.insert(i, n); // expected-warning{{Iterator access mismatched}}
 }
 
+template
+bool is_cend(Container cont, Iterator it) {
+  return it == cont.cend();
+}
+
+void good_empty(std::vector &v) {
+  is_cend(v, v.cbegin()); // no-warning
+}
+
+void bad_empty(std::vector &v1, std::vector &v2) {
+  is_cend(v1, v2.cbegin()); // expected-warning@130{{Iterator access mismatched}}
+}
+
 void good_move(std::vector &v1, std::vector &v2) {
   const auto i0 = ++v2.cbegin();
   v1 = std::move(v2);
Index: test/Analysis/iterator-range.cpp
===
--- test/Analysis/iterator-range.cpp
+++ test/Analysis/iterator-range.cpp
@@ -198,6 +198,11 @@
 *first; // no-warning
 }
 
+void bad_non_std_find(std::vector &V, int e) {
+  auto first = nonStdFind(V.begin(), V.end(), e);
+  *first; // expected-warning{{Iterator accessed outside of its range}}
+}
+
 void tricky(std::vector &V, int e) {
   const auto first = V.begin();
   const auto comp1 = (first != V.end()), comp2 = (first == V.end());
Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -134,8 +134,8 @@
  check::PreStmt,
  check::PreStmt,
  check::PostStmt, check::Bind,
- check::LiveSymbols, check::DeadSymbols,
- eval::Assume, eval::Call> {
+ check::BeginFunction, check::LiveSymbols,
+ check::DeadSymbols, eval::Assume, eval::Call> {
   mutable IdentifierInfo *II_find = nullptr, *II_find_end = nullptr,
  *II_find_first_of = nullptr, *II_find_if = nullptr,
  *II_find_if_not = nullptr, *II_lower_bound = nullptr,
@@ -223,6 +223,7 @@
   void checkPreStmt(const CXXConstructExpr *CCE, CheckerContext &C) const;
   void checkPreStmt(const CXXOperatorCallExpr *COCE, CheckerContext &C) const;
   void checkBind(SVal Loc, SVal Val, const Stmt *S, CheckerContext &C) const;
+  void checkBeginFunction(CheckerContext &C) const;
   void checkPostStmt(const CXXConstructExpr *CCE, CheckerContext &C) const;
   void checkPostStmt(const DeclStmt *DS, CheckerContext &C) const;
   void checkPostStmt(const MaterializeTemporaryExpr *MTE,
@@ -707,6 +708,39 @@
   }
 }
 
+void IteratorChecker::checkBeginFunction(CheckerContext &C) const {
+  // Copy state of iterator arguments to iterator parameters
+  auto State = C.getState();
+  const auto *LCtx = C.getLocationContext();
+
+  const auto *Site = cast(LCtx)->getCallSite();
+  if (!Site)
+return;
+
+  const auto *FD = dyn_cast(LCtx->getDecl());
+  if (!FD)
+return;
+
+  const auto *CE = dyn_cast(Site);
+  if (!CE)
+return;
+
+  bool Change = false;
+  int idx = 0;
+  for (const auto P : FD->parameters()) {
+auto Param = State->getLValue(P, LCtx);
+auto Arg = State->getSVal(CE->getArg(idx++), LCtx->getParent());
+const auto *Pos = getIteratorPosition(State, Arg);
+if (!Pos)
+  continue;
+State = setIteratorPosition(State, Param, *Pos);
+Change = true;
+  }
+  if (Change) {
+C.addTransition(State);
+  }
+}
+
 void IteratorChecker::checkPostStmt(const MaterializeTemporaryExpr *MTE,
 CheckerContext &C) const {
   /* Transfer iterator state for to temporary objects */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31975: [Analyzer] Iterator Checkers

2017-05-05 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Split to 10 parts.


https://reviews.llvm.org/D31975



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


[PATCH] D32903: Remove unused variable and argument from Lex/HeaderSearch.cpp

2017-05-05 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta updated this revision to Diff 97949.
takuto.ikuta added a comment.

Remove IncludeLoc


https://reviews.llvm.org/D32903

Files:
  clang/include/clang/Lex/DirectoryLookup.h
  clang/include/clang/Lex/HeaderSearch.h
  clang/lib/Lex/HeaderSearch.cpp

Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -234,9 +234,9 @@
   break;
   }
 }
-
+
 // FIXME: Figure out how header maps and module maps will work together.
-
+
 // Only deal with normal search directories.
 if (!SearchDirs[Idx].isNormalDir())
   continue;
@@ -251,7 +251,7 @@
   if (Module)
 break;
 }
-  
+
 // Search for a module map in a subdirectory with the same name as the
 // module.
 SmallString<128> NestedModuleMapDirName;
@@ -299,7 +299,7 @@
 }
 
 const FileEntry *HeaderSearch::getFileAndSuggestModule(
-StringRef FileName, SourceLocation IncludeLoc, const DirectoryEntry *Dir,
+StringRef FileName, const DirectoryEntry *Dir,
 bool IsSystemHeaderDir, Module *RequestingModule,
 ModuleMap::KnownHeader *SuggestedModule) {
   // If we have a module map that might map this header, load it and
@@ -322,7 +322,6 @@
 const FileEntry *DirectoryLookup::LookupFile(
 StringRef &Filename,
 HeaderSearch &HS,
-SourceLocation IncludeLoc,
 SmallVectorImpl *SearchPath,
 SmallVectorImpl *RelativePath,
 Module *RequestingModule,
@@ -348,7 +347,7 @@
   RelativePath->append(Filename.begin(), Filename.end());
 }
 
-return HS.getFileAndSuggestModule(TmpDir, IncludeLoc, getDir(),
+return HS.getFileAndSuggestModule(TmpDir, getDir(),
   isSystemHeaderDirectory(),
   RequestingModule, SuggestedModule);
   }
@@ -399,11 +398,8 @@
 ///
 /// \param FileMgr The file manager to use for directory lookups.
 /// \param DirName The name of the framework directory.
-/// \param SubmodulePath Will be populated with the submodule path from the
-/// returned top-level module to the originally named framework.
 static const DirectoryEntry *
-getTopFrameworkDir(FileManager &FileMgr, StringRef DirName,
-   SmallVectorImpl &SubmodulePath) {
+getTopFrameworkDir(FileManager &FileMgr, StringRef DirName) {
   assert(llvm::sys::path::extension(DirName) == ".framework" &&
  "Not a framework directory");
 
@@ -437,7 +433,6 @@
 // If this is a framework directory, then we're a subframework of this
 // framework.
 if (llvm::sys::path::extension(DirName) == ".framework") {
-  SubmodulePath.push_back(llvm::sys::path::stem(DirName));
   TopFrameworkDir = Dir;
 }
   } while (true);
@@ -518,7 +513,7 @@
 RelativePath->clear();
 RelativePath->append(Filename.begin()+SlashPos+1, Filename.end());
   }
-  
+
   // Check "/System/Library/Frameworks/Cocoa.framework/Headers/file.h"
   unsigned OrigSize = FrameworkName.size();
 
@@ -630,7 +625,7 @@
 
   if (SuggestedModule)
 *SuggestedModule = ModuleMap::KnownHeader();
-
+
   // If 'Filename' is absolute, check to see if it exists and no searching.
   if (llvm::sys::path::is_absolute(Filename)) {
 CurDir = nullptr;
@@ -645,7 +640,7 @@
   RelativePath->append(Filename.begin(), Filename.end());
 }
 // Otherwise, just return the file.
-return getFileAndSuggestModule(Filename, IncludeLoc, nullptr,
+return getFileAndSuggestModule(Filename, nullptr,
/*IsSystemHeaderDir*/false,
RequestingModule, SuggestedModule);
   }
@@ -682,7 +677,7 @@
   Includer ? getFileInfo(Includer).DirInfo != SrcMgr::C_User :
   BuildSystemModule;
   if (const FileEntry *FE = getFileAndSuggestModule(
-  TmpDir, IncludeLoc, IncluderAndDir.second, IncluderIsSystemHeader,
+  TmpDir, IncluderAndDir.second, IncluderIsSystemHeader,
   RequestingModule, SuggestedModule)) {
 if (!Includer) {
   assert(First && "only first includer can have no file");
@@ -776,7 +771,7 @@
 bool InUserSpecifiedSystemFramework = false;
 bool HasBeenMapped = false;
 const FileEntry *FE = SearchDirs[i].LookupFile(
-Filename, *this, IncludeLoc, SearchPath, RelativePath, RequestingModule,
+Filename, *this, SearchPath, RelativePath, RequestingModule,
 SuggestedModule, InUserSpecifiedSystemFramework, HasBeenMapped,
 MappedName);
 if (HasBeenMapped) {
@@ -815,7 +810,7 @@
   size_t SlashPos = Filename.find('/');
   if (SlashPos != StringRef::npos) {
 HFI.IndexHeaderMapHeader = 1;
-HFI.Framework = getUniqueFrameworkName(StringRef(Filename.begin(), 
+HFI.Framework = getUniqueFrameworkName(StringRef(Filename.begin(),
  SlashPos));
   }

[PATCH] D32856: [OpenCL] Check that global samplers are const

2017-05-05 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:6085
+  // space qualifier or with the const qualifier.
+  if (DC->isTranslationUnit() &&
+  !(R.getAddressSpace() == LangAS::opencl_constant ||

svenvh wrote:
> yaxunl wrote:
> > should be else if ?
> > 
> > if the previous error already happens, it is unnecessary to do the next 
> > check
> 
> Sure, I can do that, I am just not sure what the desirable behaviour is here? 
>  They are different errors, so with the current patch it emits both 
> diagnostics (see the first test change).  If we just want one diagnostic (the 
> first one in that test case), I can change it to else if; please let me know 
> if you prefer that.
On second thoughts, let's keep it as it is.

Can you add tests for

const sampler_t

const constant sampler_t

const global sampler_t

Thanks.



https://reviews.llvm.org/D32856



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


[PATCH] D32909: [Tooling] Remove redundant check, NFCi

2017-05-05 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added a subscriber: klimek.

The Database check looks redundant.


https://reviews.llvm.org/D32909

Files:
  lib/Tooling/JSONCompilationDatabase.cpp


Index: lib/Tooling/JSONCompilationDatabase.cpp
===
--- lib/Tooling/JSONCompilationDatabase.cpp
+++ lib/Tooling/JSONCompilationDatabase.cpp
@@ -146,12 +146,8 @@
   loadFromDirectory(StringRef Directory, std::string &ErrorMessage) override {
 SmallString<1024> JSONDatabasePath(Directory);
 llvm::sys::path::append(JSONDatabasePath, "compile_commands.json");
-std::unique_ptr Database(
-JSONCompilationDatabase::loadFromFile(
-JSONDatabasePath, ErrorMessage, 
JSONCommandLineSyntax::AutoDetect));
-if (!Database)
-  return nullptr;
-return Database;
+return JSONCompilationDatabase::loadFromFile(
+JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect);
   }
 };
 


Index: lib/Tooling/JSONCompilationDatabase.cpp
===
--- lib/Tooling/JSONCompilationDatabase.cpp
+++ lib/Tooling/JSONCompilationDatabase.cpp
@@ -146,12 +146,8 @@
   loadFromDirectory(StringRef Directory, std::string &ErrorMessage) override {
 SmallString<1024> JSONDatabasePath(Directory);
 llvm::sys::path::append(JSONDatabasePath, "compile_commands.json");
-std::unique_ptr Database(
-JSONCompilationDatabase::loadFromFile(
-JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect));
-if (!Database)
-  return nullptr;
-return Database;
+return JSONCompilationDatabase::loadFromFile(
+JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect);
   }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32909: [Tooling] Remove redundant check, NFCi

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

lg


https://reviews.llvm.org/D32909



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


r302236 - [Tooling] Remove redundant check, NFCi

2017-05-05 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Fri May  5 09:07:23 2017
New Revision: 302236

URL: http://llvm.org/viewvc/llvm-project?rev=302236&view=rev
Log:
[Tooling] Remove redundant check, NFCi

Summary: The Database check looks redundant.

Reviewers: bkramer

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp

Modified: cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp?rev=302236&r1=302235&r2=302236&view=diff
==
--- cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp Fri May  5 09:07:23 2017
@@ -146,12 +146,8 @@ class JSONCompilationDatabasePlugin : pu
   loadFromDirectory(StringRef Directory, std::string &ErrorMessage) override {
 SmallString<1024> JSONDatabasePath(Directory);
 llvm::sys::path::append(JSONDatabasePath, "compile_commands.json");
-std::unique_ptr Database(
-JSONCompilationDatabase::loadFromFile(
-JSONDatabasePath, ErrorMessage, 
JSONCommandLineSyntax::AutoDetect));
-if (!Database)
-  return nullptr;
-return Database;
+return JSONCompilationDatabase::loadFromFile(
+JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect);
   }
 };
 


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


[PATCH] D32909: [Tooling] Remove redundant check, NFCi

2017-05-05 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302236: [Tooling] Remove redundant check, NFCi (authored by 
krasimir).

Changed prior to commit:
  https://reviews.llvm.org/D32909?vs=97952&id=97953#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32909

Files:
  cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp


Index: cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
===
--- cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
+++ cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
@@ -146,12 +146,8 @@
   loadFromDirectory(StringRef Directory, std::string &ErrorMessage) override {
 SmallString<1024> JSONDatabasePath(Directory);
 llvm::sys::path::append(JSONDatabasePath, "compile_commands.json");
-std::unique_ptr Database(
-JSONCompilationDatabase::loadFromFile(
-JSONDatabasePath, ErrorMessage, 
JSONCommandLineSyntax::AutoDetect));
-if (!Database)
-  return nullptr;
-return Database;
+return JSONCompilationDatabase::loadFromFile(
+JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect);
   }
 };
 


Index: cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
===
--- cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
+++ cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
@@ -146,12 +146,8 @@
   loadFromDirectory(StringRef Directory, std::string &ErrorMessage) override {
 SmallString<1024> JSONDatabasePath(Directory);
 llvm::sys::path::append(JSONDatabasePath, "compile_commands.json");
-std::unique_ptr Database(
-JSONCompilationDatabase::loadFromFile(
-JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect));
-if (!Database)
-  return nullptr;
-return Database;
+return JSONCompilationDatabase::loadFromFile(
+JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect);
   }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32906: [Analyzer] Iterator Checker - Part 10: Support for iterators passed as parameter

2017-05-05 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:711
 
+void IteratorChecker::checkBeginFunction(CheckerContext &C) const {
+  // Copy state of iterator arguments to iterator parameters

Can we use `const CheckerContext &C` here?



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:730
+  int idx = 0;
+  for (const auto P : FD->parameters()) {
+auto Param = State->getLValue(P, LCtx);

`const auto *P`?



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:731
+  for (const auto P : FD->parameters()) {
+auto Param = State->getLValue(P, LCtx);
+auto Arg = State->getSVal(CE->getArg(idx++), LCtx->getParent());

Can we declare this after L735?



https://reviews.llvm.org/D32906



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


[PATCH] D32906: [Analyzer] Iterator Checker - Part 10: Support for iterators passed as parameter

2017-05-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:711
 
+void IteratorChecker::checkBeginFunction(CheckerContext &C) const {
+  // Copy state of iterator arguments to iterator parameters

takuto.ikuta wrote:
> Can we use `const CheckerContext &C` here?
That's a checker callback called by the engine, not much we can change in its 
signature. Additionally, the `addTransition` method we use is sufficiently 
non-`const`, and that's the whole point of passing the checker context in every 
callback.

Anyway, `CheckerContext` is mostly a utility and is short-lived, and it doesn't 
make much sense to think of it as const.


https://reviews.llvm.org/D32906



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


[PATCH] D32906: [Analyzer] Iterator Checker - Part 10: Support for iterators passed as parameter

2017-05-05 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:711
 
+void IteratorChecker::checkBeginFunction(CheckerContext &C) const {
+  // Copy state of iterator arguments to iterator parameters

takuto.ikuta wrote:
> Can we use `const CheckerContext &C` here?
I didn't see C.addTransition, sorry.


https://reviews.llvm.org/D32906



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


r302240 - [Driver] Add a "-mmacos_version_min" option that's an alias for

2017-05-05 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri May  5 09:52:48 2017
New Revision: 302240

URL: http://llvm.org/viewvc/llvm-project?rev=302240&view=rev
Log:
[Driver] Add a "-mmacos_version_min" option that's an alias for
"-mmacosx_version_min"

The option -mmacosx_version_min will still be the canonical option for now, but
in the future we will switch over to -mmacos_version_min and make
-mmacosx_version_min an alias instead.

rdar://27043820

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/test/Driver/darwin-version.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=302240&r1=302239&r2=302240&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri May  5 09:52:48 2017
@@ -1688,6 +1688,8 @@ def mllvm : Separate<["-"], "mllvm">, Fl
   HelpText<"Additional arguments to forward to LLVM's option processing">;
 def mmacosx_version_min_EQ : Joined<["-"], "mmacosx-version-min=">,
   Group, HelpText<"Set Mac OS X deployment target">;
+def mmacos_version_min_EQ : Joined<["-"], "mmacos-version-min=">,
+  Group, Alias;
 def mms_bitfields : Flag<["-"], "mms-bitfields">, Group, 
Flags<[CC1Option]>,
   HelpText<"Set the default structure layout to be compatible with the 
Microsoft compiler standard">;
 def mno_ms_bitfields : Flag<["-"], "mno-ms-bitfields">, Group,

Modified: cfe/trunk/test/Driver/darwin-version.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-version.c?rev=302240&r1=302239&r2=302240&view=diff
==
--- cfe/trunk/test/Driver/darwin-version.c (original)
+++ cfe/trunk/test/Driver/darwin-version.c Fri May  5 09:52:48 2017
@@ -29,9 +29,13 @@
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX10 %s
 // RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min=10.10 -c %s 
-### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX10 %s
+// RUN: %clang -target x86_64-apple-macosx -mmacos-version-min=10.10 -c %s 
-### 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX10 %s
 // CHECK-VERSION-OSX10: "x86_64-apple-macosx10.10.0"
 // RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min= -c %s -### 
2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-MISSING %s
+// RUN: %clang -target x86_64-apple-macosx -mmacos-version-min= -c %s -### 
2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-MISSING %s
 // CHECK-VERSION-MISSING: invalid version number
 // RUN: %clang -target armv7k-apple-darwin -mwatchos-version-min=2.0 -c %s 
-### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-WATCHOS20 %s


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


[PATCH] D32796: [Driver] Add a "-mmacos_version_min" option that's an alias for "-mmacosx_version_min"

2017-05-05 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302240: [Driver] Add a "-mmacos_version_min" option that's 
an alias for (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D32796?vs=97599&id=97956#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32796

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/test/Driver/darwin-version.c


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1688,6 +1688,8 @@
   HelpText<"Additional arguments to forward to LLVM's option processing">;
 def mmacosx_version_min_EQ : Joined<["-"], "mmacosx-version-min=">,
   Group, HelpText<"Set Mac OS X deployment target">;
+def mmacos_version_min_EQ : Joined<["-"], "mmacos-version-min=">,
+  Group, Alias;
 def mms_bitfields : Flag<["-"], "mms-bitfields">, Group, 
Flags<[CC1Option]>,
   HelpText<"Set the default structure layout to be compatible with the 
Microsoft compiler standard">;
 def mno_ms_bitfields : Flag<["-"], "mno-ms-bitfields">, Group,
Index: cfe/trunk/test/Driver/darwin-version.c
===
--- cfe/trunk/test/Driver/darwin-version.c
+++ cfe/trunk/test/Driver/darwin-version.c
@@ -29,9 +29,13 @@
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX10 %s
 // RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min=10.10 -c %s 
-### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX10 %s
+// RUN: %clang -target x86_64-apple-macosx -mmacos-version-min=10.10 -c %s 
-### 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX10 %s
 // CHECK-VERSION-OSX10: "x86_64-apple-macosx10.10.0"
 // RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min= -c %s -### 
2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-MISSING %s
+// RUN: %clang -target x86_64-apple-macosx -mmacos-version-min= -c %s -### 
2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-MISSING %s
 // CHECK-VERSION-MISSING: invalid version number
 // RUN: %clang -target armv7k-apple-darwin -mwatchos-version-min=2.0 -c %s 
-### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-WATCHOS20 %s


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1688,6 +1688,8 @@
   HelpText<"Additional arguments to forward to LLVM's option processing">;
 def mmacosx_version_min_EQ : Joined<["-"], "mmacosx-version-min=">,
   Group, HelpText<"Set Mac OS X deployment target">;
+def mmacos_version_min_EQ : Joined<["-"], "mmacos-version-min=">,
+  Group, Alias;
 def mms_bitfields : Flag<["-"], "mms-bitfields">, Group, Flags<[CC1Option]>,
   HelpText<"Set the default structure layout to be compatible with the Microsoft compiler standard">;
 def mno_ms_bitfields : Flag<["-"], "mno-ms-bitfields">, Group,
Index: cfe/trunk/test/Driver/darwin-version.c
===
--- cfe/trunk/test/Driver/darwin-version.c
+++ cfe/trunk/test/Driver/darwin-version.c
@@ -29,9 +29,13 @@
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX10 %s
 // RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min=10.10 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX10 %s
+// RUN: %clang -target x86_64-apple-macosx -mmacos-version-min=10.10 -c %s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX10 %s
 // CHECK-VERSION-OSX10: "x86_64-apple-macosx10.10.0"
 // RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min= -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-MISSING %s
+// RUN: %clang -target x86_64-apple-macosx -mmacos-version-min= -c %s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-MISSING %s
 // CHECK-VERSION-MISSING: invalid version number
 // RUN: %clang -target armv7k-apple-darwin -mwatchos-version-min=2.0 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-WATCHOS20 %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32642: [Analyzer] Iterator Checker - Part 2: Increment, decrement operators and ahead-of-begin checks

2017-05-05 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:357
+return;
+  } else if (isEndCall(Func)) {
 handleEnd(C, OrigExpr, Call.getReturnValue(),

We cannot use else after return?
http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:576
+auto &SymMgr = C.getSymbolManager();
+const auto oldOffset = Pos->getOffset();
+auto newOffset =

oldOffset -> OldOffset?
same with L577, L580, L595, L596, L599 and so on.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:941
+  return State;
+} else {
+  const auto CData = CDataPtr->newBegin(Sym);

else after return?



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:945
+}
+  } else {
+const auto CData = ContainerData::fromBegin(Sym);

else after return too.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:1195
+Expr->getType());
+  } else {
+return LExpr->getLHS();

else after return?



https://reviews.llvm.org/D32642



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


[PATCH] D32592: [Analyzer] Iterator Checker - Part 1: Minimal Checker for a Simple Test Case

2017-05-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Noticed a few more things.

It sounds as if once this first patch lands, the rest should be easy :)

Regarding the comments in the code. I materialized my wishes to something like:

- At the top of the file:

  // In the code, iterator can be represented as a:
  // * type-I: typedef-ed pointer. Operations over such iterator, such as 
comparisons or increments, are modeled straightforwardly by the analyzer.
  // * type-II: structure with its method bodies available.  Operations over 
such iterator are inlined by the analyzer, and results of modeling these 
operations are exposing implementation details of the iterators, which is not 
necessarily helping.
  // * type-III: completely opaque structure. Operations over such iterator are 
modeled conservatively, producing conjured symbols everywhere.
  //
  // Additionally, depending on the circumstances, operators of types II and 
III can be represented as:
  // * type-IIa, type-IIIa: conjured structure symbols - when returned by value 
from conservatively evaluated methods such as `.begin()`.
  // * type-IIb, type-IIIb: memory regions of iterator-typed objects, such as 
variables or temporaries, when the iterator object is currently treated as an 
lvalue.
  // * type-IIc, type-IIIc: compound values of iterator-typed objects, when the 
iterator object is treated as an rvalue taken of a particular lvalue, eg. a 
copy of "type-a" iterator object, or an iterator that existed before the 
analysis has started.

Not sure if type-IIa iterators actually make sense. It's ok if you come up with 
your own classification :)

Then, in methods that deal with iterator `SVal`s directly, i wish we had hints 
explaining what's going on in these ~7 cases. In my opinion, that'd greatly 
help people understand the code later, and it'd help us understand how to avoid 
this variety and provide checker authors with a better API as soon as we get to 
this, so it's the biggest concern for me about this checker.




Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:16
+#include "ClangSACheckers.h"
+#include "clang/AST/DeclTemplate.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"

This header seems unused for now.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:22
+
+#include 
+

This header seems unused for now.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:153-155
+REGISTER_MAP_WITH_PROGRAMSTATE(IteratorSymbolMap, SymbolRef, IteratorPosition)
+REGISTER_MAP_WITH_PROGRAMSTATE(IteratorRegionMap, const MemRegion *,
+   IteratorPosition)

Carryover from the other review: did you try using `RegionOrSymbol` as a key 
and keep only one map?



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:166-167
+
+static llvm::APSInt Zero = llvm::APSInt::get(0);
+static llvm::APSInt One = llvm::APSInt::get(1);
+

I've a bit of doubt about those. Would they call their constructors every time 
clang starts, regardless of whether the analyzer or the checker is enabled? 
Maybe having them as private variables inside the checker class would be better?

As in http://llvm.org/docs/CodingStandards.html#do-not-use-static-constructors



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:294-297
+// Assumption: if return value is an iterator which is not yet bound to a
+// container, then look for the first iterator argument, and
+// bind the return value to the same container. This approach
+// works for STL algorithms.

baloghadamsoftware wrote:
> NoQ wrote:
> > I guess this deserves a test case (we could split this out as a separate 
> > feature as well).
> > 
> > I'm also afraid that we can encounter false positives on functions that are 
> > not STL algorithms. I suggest doing this by default only for STL functions 
> > (or maybe for other specific classes of functions for which we know it 
> > works this way) and do this for other functions under a checker option 
> > (i.e. something like `-analyzer-config 
> > IteratorChecker:AggressiveAssumptions=true`, similar to `MallocChecker`'s 
> > "Optimistic" option).
> I will check whether this piece of code could be moved in a later part of the 
> checker. However, I suggest to first wait for the first false positives 
> before we introduce such an option. This far the false positives in my 
> initial tests had different reasons, not this one.
Unfortunately, we've had a poor experience with this approach in other 
checkers. You never know, and it seems that it's always better to have a safe 
fallback mode available under a flag, because if a few classes of false 
positives are found, and we are forced to reduce the checker to a safer 
behavior, it'd be hard to remember all the places where unsafe heuristics were 
used.


=

[PATCH] D32747: [Analyzer] Iterator Checker - Part 3: Invalidation check, first for (copy) assignments

2017-05-05 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:271
+  InvalidatedBugType.reset(
+  new BugType(this, "Iterator invalidated", "Misuse of STL APIs"));
+  InvalidatedBugType->setSuppressOnSink(true);

OK to use make_unique here?


https://reviews.llvm.org/D32747



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


[PATCH] D32856: [OpenCL] Check that global samplers are const

2017-05-05 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh updated this revision to Diff 97959.
svenvh added a comment.

Added more tests as suggested.


https://reviews.llvm.org/D32856

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/SemaOpenCL/sampler_t.cl


Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -9,7 +9,8 @@
 
 constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
 constant sampler_t glb_smp2; // expected-error{{variable in constant address 
space must be initialized}}
-global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sampler 
type cannot be used with the __local and __global address space qualifiers}}
+global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sampler 
type cannot be used with the __local and __global address space qualifiers}} 
expected-error {{global sampler requires a const or constant address space 
qualifier}}
+const global sampler_t glb_smp3_const = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;  // expected-error{{sampler 
type cannot be used with the __local and __global address space qualifiers}}
 
 constant sampler_t glb_smp4 = 0;
 #ifdef CHECK_SAMPLER_VALUE
@@ -38,6 +39,11 @@
 
 sampler_t bad(void); //expected-error{{declaring function return value of type 
'sampler_t' is not allowed}}
 
+sampler_t global_nonconst_smp = 0; // expected-error {{global sampler requires 
a const or constant address space qualifier}}
+
+const sampler_t glb_smp10 = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+const constant sampler_t glb_smp11 = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+
 void kernel ker(sampler_t argsmp) {
   local sampler_t smp; // expected-error{{sampler type cannot be used with the 
__local and __global address space qualifiers}}
   const sampler_t const_smp = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6070,12 +6070,24 @@
   }
 }
 
-// OpenCL v1.2 s6.9.b p4:
-// The sampler type cannot be used with the __local and __global address
-// space qualifiers.
-if (R->isSamplerT() && (R.getAddressSpace() == LangAS::opencl_local ||
-  R.getAddressSpace() == LangAS::opencl_global)) {
-  Diag(D.getIdentifierLoc(), diag::err_wrong_sampler_addressspace);
+if (R->isSamplerT()) {
+  // OpenCL v1.2 s6.9.b p4:
+  // The sampler type cannot be used with the __local and __global address
+  // space qualifiers.
+  if (R.getAddressSpace() == LangAS::opencl_local ||
+  R.getAddressSpace() == LangAS::opencl_global) {
+Diag(D.getIdentifierLoc(), diag::err_wrong_sampler_addressspace);
+  }
+
+  // OpenCL v1.2 s6.12.14.1:
+  // A global sampler must be declared with either the constant address
+  // space qualifier or with the const qualifier.
+  if (DC->isTranslationUnit() &&
+  !(R.getAddressSpace() == LangAS::opencl_constant ||
+  R.isConstQualified())) {
+Diag(D.getIdentifierLoc(), diag::err_opencl_nonconst_global_sampler);
+D.setInvalidType();
+  }
 }
 
 // OpenCL v1.2 s6.9.r:
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8297,6 +8297,8 @@
   "sampler_t variable required - got %0">;
 def err_wrong_sampler_addressspace: Error<
   "sampler type cannot be used with the __local and __global address space 
qualifiers">;
+def err_opencl_nonconst_global_sampler : Error<
+  "global sampler requires a const or constant address space qualifier">;
 def err_opencl_cast_non_zero_to_event_t : Error<
   "cannot cast non-zero value '%0' to 'event_t'">;
 def err_opencl_global_invalid_addr_space : Error<


Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -9,7 +9,8 @@
 
 constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
 constant sampler_t glb_smp2; // expected-error{{variable in constant address space must be initialized}}
-global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}}
+global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sample

[PATCH] D32424: Add a fix-it for -Wunguarded-availability

2017-05-05 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington accepted this revision.
erik.pilkington added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D32424



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


[PATCH] D32914: Introduce Wzero-as-null-pointer-constant.

2017-05-05 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.

Add an opt-in warning that fires when 0 is used as a null pointer. 
gcc has this warning, and there's some demand for it:
http://stackoverflow.com/questions/34953361/which-clang-warning-is-equivalent-to-wzero-as-null-pointer-constant-from-gcc
https://twitter.com/StephanTLavavej/status/859943696443166720


https://reviews.llvm.org/D32914

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/Sema.cpp
  test/SemaCXX/warn-zero-nullptr.cpp


Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8962,6 +8962,9 @@
   "implicit conversion from nullable pointer %0 to non-nullable pointer "
   "type %1">,
   InGroup, DefaultIgnore;
+def warn_zero_as_null_pointer_constant : Warning<
+  "zero as null pointer constant">,
+  InGroup>, DefaultIgnore;
 
 def err_nullability_cs_multilevel : Error<
   "nullability keyword %0 cannot be applied to multi-level pointer type %1">;
Index: test/SemaCXX/warn-zero-nullptr.cpp
===
--- test/SemaCXX/warn-zero-nullptr.cpp
+++ test/SemaCXX/warn-zero-nullptr.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wzero-as-null-pointer-constant 
-std=c++11
+
+struct S {};
+
+int (S::*mp0) = nullptr;
+void* p0 = nullptr;
+
+int (S::*mp1) = 0; // expected-warning{{zero as null pointer constant}}
+void* p1 = 0; // expected-warning{{zero as null pointer constant}}
+
+// NULL is an integer constant expression, so warn on it too:
+void* p2 = __null; // expected-warning{{zero as null pointer constant}}
+int (S::*mp2) = __null; // expected-warning{{zero as null pointer constant}}
+
+void f0(void* v = 0); // expected-warning{{zero as null pointer constant}}
+void f1(void* v);
+
+void g() {
+  f1(0); // expected-warning{{zero as null pointer constant}}
+}
+
+// Warn on these too. Matches gcc and arguably makes sense.
+void* pp = (decltype(nullptr))0; // expected-warning{{zero as null pointer 
constant}}
+void* pp2 = static_cast(0); // expected-warning{{zero as 
null pointer constant}}
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -3757,6 +3757,9 @@
   void diagnoseNullableToNonnullConversion(QualType DstType, QualType SrcType,
SourceLocation Loc);
 
+  /// \brief Warn when implicitly casting 0 to nullptr.
+  void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E);
+
   ParsingDeclState PushParsingDeclaration(sema::DelayedDiagnosticPool &pool) {
 return DelayedDiagnostics.push(pool);
   }
Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -383,6 +383,19 @@
   Diag(Loc, diag::warn_nullability_lost) << SrcType << DstType;
 }
 
+void Sema::diagnoseZeroToNullptrConversion(CastKind Kind, const Expr* E) {
+  if (Kind != CK_NullToPointer && Kind != CK_NullToMemberPointer)
+return;
+  if (E->getType()->isNullPtrType())
+return;
+  // nullptr only exists from C++11 on, so don't warn on its absence earlier.
+  if (!getLangOpts().CPlusPlus11)
+return;
+
+  Diag(E->getLocStart(), diag::warn_zero_as_null_pointer_constant)
+  << FixItHint::CreateReplacement(E->getSourceRange(), "nullptr");
+}
+
 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
 /// If there is already an implicit cast, merge into the existing one.
 /// The result is of the given category.
@@ -407,6 +420,7 @@
 #endif
 
   diagnoseNullableToNonnullConversion(Ty, E->getType(), E->getLocStart());
+  diagnoseZeroToNullptrConversion(Kind, E);
 
   QualType ExprTy = Context.getCanonicalType(E->getType());
   QualType TypeTy = Context.getCanonicalType(Ty);


Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8962,6 +8962,9 @@
   "implicit conversion from nullable pointer %0 to non-nullable pointer "
   "type %1">,
   InGroup, DefaultIgnore;
+def warn_zero_as_null_pointer_constant : Warning<
+  "zero as null pointer constant">,
+  InGroup>, DefaultIgnore;
 
 def err_nullability_cs_multilevel : Error<
   "nullability keyword %0 cannot be applied to multi-level pointer type %1">;
Index: test/SemaCXX/warn-zero-nullptr.cpp
===
--- test/SemaCXX/warn-zero-nullptr.cpp
+++ test/SemaCXX/warn-zero-nullptr.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wzero-as-null-pointer-constant -std=c++11
+
+struct S {};
+
+int (S::*mp0) = nullptr;
+void* p0 = nullptr;
+
+int (S::*mp1) = 0; // expected-warning{{zero as null poi

[PATCH] D32914: Introduce Wzero-as-null-pointer-constant.

2017-05-05 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Nice. Some comments, but lgtm.




Comment at: include/clang/Sema/Sema.h:3760
 
+  /// \brief Warn when implicitly casting 0 to nullptr.
+  void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E);

\brief is redudant here I believe and doesn't seem used for the surrounding 
functions.



Comment at: lib/Sema/Sema.cpp:396
+  Diag(E->getLocStart(), diag::warn_zero_as_null_pointer_constant)
+  << FixItHint::CreateReplacement(E->getSourceRange(), "nullptr");
+}

I was about to say that a fixit would be nice, but you were way ahead of me :-)



Comment at: test/SemaCXX/warn-zero-nullptr.cpp:9
+int (S::*mp1) = 0; // expected-warning{{zero as null pointer constant}}
+void* p1 = 0; // expected-warning{{zero as null pointer constant}}
+

If I understand the code correctly, the warning will fire for function pointers 
too because that's also CK_NullToPointer. May be worth adding to the test 
anyway though.


https://reviews.llvm.org/D32914



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


r302247 - Introduce Wzero-as-null-pointer-constant.

2017-05-05 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri May  5 11:11:08 2017
New Revision: 302247

URL: http://llvm.org/viewvc/llvm-project?rev=302247&view=rev
Log:
Introduce Wzero-as-null-pointer-constant.

Add an opt-in warning that fires when 0 is used as a null pointer. 
gcc has this warning, and there's some demand for it.

https://reviews.llvm.org/D32914

Added:
cfe/trunk/test/SemaCXX/warn-zero-nullptr.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/Sema.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=302247&r1=302246&r2=302247&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri May  5 11:11:08 
2017
@@ -8975,6 +8975,9 @@ def warn_nullability_lost : Warning<
   "implicit conversion from nullable pointer %0 to non-nullable pointer "
   "type %1">,
   InGroup, DefaultIgnore;
+def warn_zero_as_null_pointer_constant : Warning<
+  "zero as null pointer constant">,
+  InGroup>, DefaultIgnore;
 
 def err_nullability_cs_multilevel : Error<
   "nullability keyword %0 cannot be applied to multi-level pointer type %1">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=302247&r1=302246&r2=302247&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri May  5 11:11:08 2017
@@ -3766,6 +3766,9 @@ public:
   void diagnoseNullableToNonnullConversion(QualType DstType, QualType SrcType,
SourceLocation Loc);
 
+  /// Warn when implicitly casting 0 to nullptr.
+  void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E);
+
   ParsingDeclState PushParsingDeclaration(sema::DelayedDiagnosticPool &pool) {
 return DelayedDiagnostics.push(pool);
   }

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=302247&r1=302246&r2=302247&view=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Fri May  5 11:11:08 2017
@@ -383,6 +383,19 @@ void Sema::diagnoseNullableToNonnullConv
   Diag(Loc, diag::warn_nullability_lost) << SrcType << DstType;
 }
 
+void Sema::diagnoseZeroToNullptrConversion(CastKind Kind, const Expr* E) {
+  if (Kind != CK_NullToPointer && Kind != CK_NullToMemberPointer)
+return;
+  if (E->getType()->isNullPtrType())
+return;
+  // nullptr only exists from C++11 on, so don't warn on its absence earlier.
+  if (!getLangOpts().CPlusPlus11)
+return;
+
+  Diag(E->getLocStart(), diag::warn_zero_as_null_pointer_constant)
+  << FixItHint::CreateReplacement(E->getSourceRange(), "nullptr");
+}
+
 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
 /// If there is already an implicit cast, merge into the existing one.
 /// The result is of the given category.
@@ -407,6 +420,7 @@ ExprResult Sema::ImpCastExprToType(Expr
 #endif
 
   diagnoseNullableToNonnullConversion(Ty, E->getType(), E->getLocStart());
+  diagnoseZeroToNullptrConversion(Kind, E);
 
   QualType ExprTy = Context.getCanonicalType(E->getType());
   QualType TypeTy = Context.getCanonicalType(Ty);

Added: cfe/trunk/test/SemaCXX/warn-zero-nullptr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-zero-nullptr.cpp?rev=302247&view=auto
==
--- cfe/trunk/test/SemaCXX/warn-zero-nullptr.cpp (added)
+++ cfe/trunk/test/SemaCXX/warn-zero-nullptr.cpp Fri May  5 11:11:08 2017
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wzero-as-null-pointer-constant 
-std=c++11
+
+struct S {};
+
+int (S::*mp0) = nullptr;
+void (*fp0)() = nullptr;
+void* p0 = nullptr;
+
+int (S::*mp1) = 0; // expected-warning{{zero as null pointer constant}}
+void (*fp1)() = 0; // expected-warning{{zero as null pointer constant}}
+void* p1 = 0; // expected-warning{{zero as null pointer constant}}
+
+// NULL is an integer constant expression, so warn on it too:
+void* p2 = __null; // expected-warning{{zero as null pointer constant}}
+void (*fp2)() = __null; // expected-warning{{zero as null pointer constant}}
+int (S::*mp2) = __null; // expected-warning{{zero as null pointer constant}}
+
+void f0(void* v = 0); // expected-warning{{zero as null pointer constant}}
+void f1(void* v);
+
+void g() {
+  f1(0); // expected-warning{{zero as null pointer constant}}
+}
+
+// Warn on these too. Matches gcc and arguably makes sense.
+void* pp = (decltype(nullptr))0; // expected-warning{{zero as null pointer 

[PATCH] D32914: Introduce Wzero-as-null-pointer-constant.

2017-05-05 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis marked 3 inline comments as done.
thakis added a comment.

Thanks! Add one and landed in r302247.




Comment at: include/clang/Sema/Sema.h:3760
 
+  /// \brief Warn when implicitly casting 0 to nullptr.
+  void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E);

hans wrote:
> \brief is redudant here I believe and doesn't seem used for the surrounding 
> functions.
diagnoseNullableToNonnullConversion right above has it but the rest doesn't. 
removed.


https://reviews.llvm.org/D32914



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


[PATCH] D32914: Introduce Wzero-as-null-pointer-constant.

2017-05-05 Thread Nico Weber via Phabricator via cfe-commits
thakis marked an inline comment as done.
thakis added a comment.

s/Add one/All done/


https://reviews.llvm.org/D32914



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


r302250 - [ObjC] Don't disallow vector parameters/return values in methods

2017-05-05 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri May  5 11:15:17 2017
New Revision: 302250

URL: http://llvm.org/viewvc/llvm-project?rev=302250&view=rev
Log:
[ObjC] Don't disallow vector parameters/return values in methods
whose introduced version is lower than the allowed version.

We should just rely on the target version as this introduced version can lead
to false positives (e.g. deprecated declarations).

rdar://31964333

Modified:
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/SemaObjC/x86-method-vector-values.m

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=302250&r1=302249&r2=302250&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri May  5 11:15:17 2017
@@ -4347,10 +4347,8 @@ static void checkObjCMethodX86VectorType
 AcceptedInVersion = VersionTuple(/*Major=*/10, /*Minor=*/11);
   else
 return;
-  VersionTuple MethodVersion = Method->getVersionIntroduced();
   if (SemaRef.getASTContext().getTargetInfo().getPlatformMinVersion() >=
-  AcceptedInVersion &&
-  (MethodVersion.empty() || MethodVersion >= AcceptedInVersion))
+  AcceptedInVersion)
 return;
   SemaRef.Diag(Loc, diag::err_objc_method_unsupported_param_ret_type)
   << T << (Method->getReturnType()->isVectorType() ? /*return value*/ 1

Modified: cfe/trunk/test/SemaObjC/x86-method-vector-values.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/x86-method-vector-values.m?rev=302250&r1=302249&r2=302250&view=diff
==
--- cfe/trunk/test/SemaObjC/x86-method-vector-values.m (original)
+++ cfe/trunk/test/SemaObjC/x86-method-vector-values.m Fri May  5 11:15:17 2017
@@ -68,6 +68,8 @@ struct AggregateFloat { float v; };
 
 #else
 
+// expected-no-diagnostics
+
 -(void)takeVector:(float3)v {
 }
 
@@ -84,15 +86,9 @@ struct AggregateFloat { float v; };
 }
 
 -(void)takeVector2:(float3)v AVAILABLE_MACOS_10_10 {
-#ifdef MAC
-// expected-error@-2 {{'float3' (vector of 3 'float' values) parameter type is 
unsupported}}
-#endif
 }
 
 - (__m128)retM128_2 AVAILABLE_MACOS_10_10 {
-#ifdef MAC
-// expected-error@-2 {{'__m128' (vector of 4 'float' values) return type is 
unsupported}}
-#endif
   __m128 value;
   return value;
 }
@@ -101,9 +97,6 @@ struct AggregateFloat { float v; };
 }
 
 -(void)takeVector4:(float3)v AVAILABLE_IOS_8 {
-#ifdef IOS
-  // expected-error@-2 {{'float3' (vector of 3 'float' values) parameter type 
is unsupported}}
-#endif
 }
 
 -(void)takeVector5:(float3)v AVAILABLE_IOS_9 { // no error


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


[PATCH] D31160: [clang-tidy] Fix misc-move-const-arg for move-only types.

2017-05-05 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh updated this revision to Diff 97971.
alexfh added a comment.
Herald added a subscriber: xazax.hun.

Rebased on HEAD.


https://reviews.llvm.org/D31160

Files:
  clang-tidy/misc/MoveConstantArgumentCheck.cpp
  test/clang-tidy/misc-move-const-arg.cpp


Index: test/clang-tidy/misc-move-const-arg.cpp
===
--- test/clang-tidy/misc-move-const-arg.cpp
+++ test/clang-tidy/misc-move-const-arg.cpp
@@ -158,3 +158,16 @@
   // a lambda that is, in turn, an argument to a macro.
   CALL([no_move_semantics] { M3(NoMoveSemantics, no_move_semantics); });
 }
+
+class MoveOnly {
+public:
+  MoveOnly(const MoveOnly &other) = delete;
+  MoveOnly &operator=(const MoveOnly &other) = delete;
+  MoveOnly(MoveOnly &&other) = default;
+  MoveOnly &operator=(MoveOnly &&other) = default;
+};
+template 
+void Q(T);
+void moveOnlyNegatives(MoveOnly val) {
+  Q(std::move(val));
+}
Index: clang-tidy/misc/MoveConstantArgumentCheck.cpp
===
--- clang-tidy/misc/MoveConstantArgumentCheck.cpp
+++ clang-tidy/misc/MoveConstantArgumentCheck.cpp
@@ -73,6 +73,12 @@
   Arg->getType().isTriviallyCopyableType(*Result.Context);
 
   if (IsConstArg || IsTriviallyCopyable) {
+if (const CXXRecordDecl *R = Arg->getType()->getAsCXXRecordDecl()) {
+  for (const auto *Ctor : R->ctors()) {
+if (Ctor->isCopyConstructor() && Ctor->isDeleted())
+  return;
+  }
+}
 bool IsVariable = isa(Arg);
 const auto *Var =
 IsVariable ? dyn_cast(Arg)->getDecl() : nullptr;


Index: test/clang-tidy/misc-move-const-arg.cpp
===
--- test/clang-tidy/misc-move-const-arg.cpp
+++ test/clang-tidy/misc-move-const-arg.cpp
@@ -158,3 +158,16 @@
   // a lambda that is, in turn, an argument to a macro.
   CALL([no_move_semantics] { M3(NoMoveSemantics, no_move_semantics); });
 }
+
+class MoveOnly {
+public:
+  MoveOnly(const MoveOnly &other) = delete;
+  MoveOnly &operator=(const MoveOnly &other) = delete;
+  MoveOnly(MoveOnly &&other) = default;
+  MoveOnly &operator=(MoveOnly &&other) = default;
+};
+template 
+void Q(T);
+void moveOnlyNegatives(MoveOnly val) {
+  Q(std::move(val));
+}
Index: clang-tidy/misc/MoveConstantArgumentCheck.cpp
===
--- clang-tidy/misc/MoveConstantArgumentCheck.cpp
+++ clang-tidy/misc/MoveConstantArgumentCheck.cpp
@@ -73,6 +73,12 @@
   Arg->getType().isTriviallyCopyableType(*Result.Context);
 
   if (IsConstArg || IsTriviallyCopyable) {
+if (const CXXRecordDecl *R = Arg->getType()->getAsCXXRecordDecl()) {
+  for (const auto *Ctor : R->ctors()) {
+if (Ctor->isCopyConstructor() && Ctor->isDeleted())
+  return;
+  }
+}
 bool IsVariable = isa(Arg);
 const auto *Var =
 IsVariable ? dyn_cast(Arg)->getDecl() : nullptr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31160: [clang-tidy] Fix misc-move-const-arg for move-only types.

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

Friendly ping.


https://reviews.llvm.org/D31160



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


[PATCH] D32856: [OpenCL] Check that global samplers are const

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

LGTM. Thanks!


https://reviews.llvm.org/D32856



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


[PATCH] D31160: [clang-tidy] Fix misc-move-const-arg for move-only types.

2017-05-05 Thread Samuel Benzaquen via Phabricator via cfe-commits
sbenza added inline comments.



Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:76
   if (IsConstArg || IsTriviallyCopyable) {
+if (const CXXRecordDecl *R = Arg->getType()->getAsCXXRecordDecl()) {
+  for (const auto *Ctor : R->ctors()) {

Can we get this from R->hasTrivialCopyConstructor or 
R->hasNonTrivialCopyConstructor instead of iterating all constructors?


https://reviews.llvm.org/D31160



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


r302253 - Add a fix-it for -Wunguarded-availability

2017-05-05 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri May  5 11:42:44 2017
New Revision: 302253

URL: http://llvm.org/viewvc/llvm-project?rev=302253&view=rev
Log:
Add a fix-it for -Wunguarded-availability

This patch adds a fix-it for the -Wunguarded-availability warning. This fix-it
is similar to the Swift one: it suggests that you wrap the statement in an
`if (@available)` check. The produced fixits are indented (just like the Swift
ones) to make them look nice in Xcode's fix-it preview.

rdar://31680358

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

Added:
cfe/trunk/test/FixIt/fixit-availability.c
cfe/trunk/test/FixIt/fixit-availability.mm
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Lex/Lexer.h
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/attr-availability.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=302253&r1=302252&r2=302253&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri May  5 11:42:44 
2017
@@ -2868,7 +2868,8 @@ def warn_partial_availability : Warning<
 def note_partial_availability_silence : Note<
   "explicitly redeclare %0 to silence this warning">;
 def note_unguarded_available_silence : Note<
-  "enclose %0 in an @available check to silence this warning">;
+  "enclose %0 in %select{an @available|a __builtin_available}1 check to 
silence"
+  " this warning">;
 def warn_partial_message : Warning<"%0 is partial: %1">,
 InGroup, DefaultIgnore;
 def warn_partial_fwdclass_message : Warning<

Modified: cfe/trunk/include/clang/Lex/Lexer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Lexer.h?rev=302253&r1=302252&r2=302253&view=diff
==
--- cfe/trunk/include/clang/Lex/Lexer.h (original)
+++ cfe/trunk/include/clang/Lex/Lexer.h Fri May  5 11:42:44 2017
@@ -478,6 +478,11 @@ public:
 return getCharAndSizeSlowNoWarn(Ptr, Size, LangOpts);
   }
 
+  /// Returns the leading whitespace for line that corresponds to the given
+  /// location \p Loc.
+  static StringRef getIndentationForLine(SourceLocation Loc,
+ const SourceManager &SM);
+
   
//======//
   // Internal implementation interfaces.
 private:

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=302253&r1=302252&r2=302253&view=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Fri May  5 11:42:44 2017
@@ -452,6 +452,29 @@ bool Lexer::getRawToken(SourceLocation L
   return false;
 }
 
+/// Returns the pointer that points to the beginning of line that contains
+/// the given offset, or null if the offset if invalid.
+static const char *findBeginningOfLine(StringRef Buffer, unsigned Offset) {
+  const char *BufStart = Buffer.data();
+  if (Offset >= Buffer.size())
+return nullptr;
+  const char *StrData = BufStart + Offset;
+
+  if (StrData[0] == '\n' || StrData[0] == '\r')
+return StrData;
+
+  const char *LexStart = StrData;
+  while (LexStart != BufStart) {
+if (LexStart[0] == '\n' || LexStart[0] == '\r') {
+  ++LexStart;
+  break;
+}
+
+--LexStart;
+  }
+  return LexStart;
+}
+
 static SourceLocation getBeginningOfFileToken(SourceLocation Loc,
   const SourceManager &SM,
   const LangOptions &LangOpts) {
@@ -467,27 +490,15 @@ static SourceLocation getBeginningOfFile
 
   // Back up from the current location until we hit the beginning of a line
   // (or the buffer). We'll relex from that point.
-  const char *BufStart = Buffer.data();
-  if (LocInfo.second >= Buffer.size())
+  const char *StrData = Buffer.data() + LocInfo.second;
+  const char *LexStart = findBeginningOfLine(Buffer, LocInfo.second);
+  if (!LexStart || LexStart == StrData)
 return Loc;
   
-  const char *StrData = BufStart+LocInfo.second;
-  if (StrData[0] == '\n' || StrData[0] == '\r')
-return Loc;
-
-  const char *LexStart = StrData;
-  while (LexStart != BufStart) {
-if (LexStart[0] == '\n' || LexStart[0] == '\r') {
-  ++LexStart;
-  break;
-}
-
---LexStart;
-  }
-  
   // Create a lexer starting at the beginning of this token.
   SourceLocation LexerStartLoc = Loc.getLocWithOffset(-LocInfo.second);
-  Lexer TheLexer(LexerStartLoc, LangOpts, BufStart, LexStart, Buffer.end());
+  Lexer TheLexer(LexerStartLoc, LangOpts, Buffer.data(), LexStart,
+ Buffer.end());
   TheLexer.S

[PATCH] D32424: Add a fix-it for -Wunguarded-availability

2017-05-05 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302253: Add a fix-it for -Wunguarded-availability (authored 
by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D32424?vs=97922&id=97977#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32424

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Lex/Lexer.h
  cfe/trunk/lib/Lex/Lexer.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/FixIt/fixit-availability.c
  cfe/trunk/test/FixIt/fixit-availability.mm
  cfe/trunk/test/Sema/attr-availability.c

Index: cfe/trunk/include/clang/Lex/Lexer.h
===
--- cfe/trunk/include/clang/Lex/Lexer.h
+++ cfe/trunk/include/clang/Lex/Lexer.h
@@ -478,6 +478,11 @@
 return getCharAndSizeSlowNoWarn(Ptr, Size, LangOpts);
   }
 
+  /// Returns the leading whitespace for line that corresponds to the given
+  /// location \p Loc.
+  static StringRef getIndentationForLine(SourceLocation Loc,
+ const SourceManager &SM);
+
   //======//
   // Internal implementation interfaces.
 private:
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2868,7 +2868,8 @@
 def note_partial_availability_silence : Note<
   "explicitly redeclare %0 to silence this warning">;
 def note_unguarded_available_silence : Note<
-  "enclose %0 in an @available check to silence this warning">;
+  "enclose %0 in %select{an @available|a __builtin_available}1 check to silence"
+  " this warning">;
 def warn_partial_message : Warning<"%0 is partial: %1">,
 InGroup, DefaultIgnore;
 def warn_partial_fwdclass_message : Warning<
Index: cfe/trunk/test/Sema/attr-availability.c
===
--- cfe/trunk/test/Sema/attr-availability.c
+++ cfe/trunk/test/Sema/attr-availability.c
@@ -30,7 +30,7 @@
   ATSFontGetPostScriptName(100); // expected-error {{'ATSFontGetPostScriptName' is unavailable: obsoleted in macOS 9.0 - use ATSFontGetFullPostScriptName}}
 
 #if defined(WARN_PARTIAL)
-  // expected-warning@+2 {{is only available on macOS 10.8 or newer}} expected-note@+2 {{enclose 'PartiallyAvailable' in an @available check to silence this warning}}
+  // expected-warning@+2 {{is only available on macOS 10.8 or newer}} expected-note@+2 {{enclose 'PartiallyAvailable' in a __builtin_available check to silence this warning}}
 #endif
   PartiallyAvailable();
 }
Index: cfe/trunk/test/FixIt/fixit-availability.c
===
--- cfe/trunk/test/FixIt/fixit-availability.c
+++ cfe/trunk/test/FixIt/fixit-availability.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunguarded-availability -fdiagnostics-parseable-fixits -triple x86_64-apple-darwin9 %s 2>&1 | FileCheck %s
+
+__attribute__((availability(macos, introduced=10.12)))
+int function(void);
+
+void use() {
+  function();
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (__builtin_available(macos 10.12, *)) {\n  "
+// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:14-[[@LINE-2]]:14}:"\n  } else {\n  // Fallback on earlier versions\n  }"
+}
Index: cfe/trunk/test/FixIt/fixit-availability.mm
===
--- cfe/trunk/test/FixIt/fixit-availability.mm
+++ cfe/trunk/test/FixIt/fixit-availability.mm
@@ -0,0 +1,111 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunguarded-availability -fdiagnostics-parseable-fixits -triple x86_64-apple-darwin9 %s 2>&1 | FileCheck %s
+
+__attribute__((availability(macos, introduced=10.12)))
+int function(void);
+
+void anotherFunction(int function);
+
+int use() {
+  function();
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:14-[[@LINE-2]]:14}:"\n  } else {\n  // Fallback on earlier versions\n  }"
+  int y = function(), x = 0;
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:29-[[@LINE-2]]:29}:"\n  } else {\n  // Fallback on earlier versions\n  }"
+  x += function();
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:19-[[@LINE-2]]:19}:"\n  } else {\n  // Fallback on earlier versions\n  }"
+  if (1) {
+x = function();
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:5-[[@LINE-1]]:5}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:20-[[@LINE-2]]:20}:"\n  } else {\n  // Fallback on earlier versions\n  }"
+  }
+  anotherFunction(function());
+// CHECK: fix-it

[PATCH] D31160: [clang-tidy] Fix misc-move-const-arg for move-only types.

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



Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:76
   if (IsConstArg || IsTriviallyCopyable) {
+if (const CXXRecordDecl *R = Arg->getType()->getAsCXXRecordDecl()) {
+  for (const auto *Ctor : R->ctors()) {

sbenza wrote:
> Can we get this from R->hasTrivialCopyConstructor or 
> R->hasNonTrivialCopyConstructor instead of iterating all constructors?
Interesting idea, trying `R->hasTrivialCopyConstructor() || 
R->hasNonTrivialCopyConstructor()`.


https://reviews.llvm.org/D31160



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


[PATCH] D32767: [clang-tidy] Fix PR32896: detect initializer lists in modernize-use-empalce

2017-05-05 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek accepted this revision.
Prazek added a comment.

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D32767



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


[PATCH] D32351: [Tooling][libclang] Remove unused CompilationDatabase::MappedSources

2017-05-05 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

@klimek: We don't have any clients of this field inside clang.


https://reviews.llvm.org/D32351



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


[PATCH] D31160: [clang-tidy] Fix misc-move-const-arg for move-only types.

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



Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:76
   if (IsConstArg || IsTriviallyCopyable) {
+if (const CXXRecordDecl *R = Arg->getType()->getAsCXXRecordDecl()) {
+  for (const auto *Ctor : R->ctors()) {

alexfh wrote:
> sbenza wrote:
> > Can we get this from R->hasTrivialCopyConstructor or 
> > R->hasNonTrivialCopyConstructor instead of iterating all constructors?
> Interesting idea, trying `R->hasTrivialCopyConstructor() || 
> R->hasNonTrivialCopyConstructor()`.
I meant the opposite: `!R->hasTrivialCopyConstructor() && 
!R->hasNonTrivialCopyConstructor()`. But anyway it doesn't work. We could store 
another bit for deleted copy constructor, but it wouldn't worth it, if it's 
needed in this single case.


https://reviews.llvm.org/D31160



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


r302255 - Warn that the [] spelling of uuid(...) is deprecated.

2017-05-05 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri May  5 12:05:56 2017
New Revision: 302255

URL: http://llvm.org/viewvc/llvm-project?rev=302255&view=rev
Log:
Warn that the [] spelling of uuid(...) is deprecated.

https://reviews.llvm.org/D32879

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Parser/MicrosoftExtensions.cpp
cfe/trunk/test/Parser/ms-square-bracket-attributes.mm
cfe/trunk/test/SemaCXX/ms-uuid.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=302255&r1=302254&r2=302255&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri May  5 12:05:56 
2017
@@ -730,6 +730,9 @@ def err_super_in_lambda_unsupported : Er
 def warn_pragma_unused_undeclared_var : Warning<
   "undeclared variable %0 used as an argument for '#pragma unused'">,
   InGroup;
+def warn_atl_uuid_deprecated : Warning<
+  "specifying 'uuid' as an ATL attribute is deprecated; use __declspec 
instead">,
+  InGroup;
 def warn_pragma_unused_expected_var_arg : Warning<
   "only variables can be arguments to '#pragma unused'">,
   InGroup;

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=302255&r1=302254&r2=302255&view=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Fri May  5 12:05:56 2017
@@ -4151,8 +4151,6 @@ void Parser::ParseMicrosoftUuidAttribute
   }
 
   if (!T.consumeClose()) {
-// FIXME: Warn that this syntax is deprecated, with a Fix-It suggesting
-// using __declspec(uuid()) instead.
 Attrs.addNew(UuidIdent, SourceRange(UuidLoc, T.getCloseLocation()), 
nullptr,
  SourceLocation(), ArgExprs.data(), ArgExprs.size(),
  AttributeList::AS_Microsoft);

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=302255&r1=302254&r2=302255&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri May  5 12:05:56 2017
@@ -5079,6 +5079,15 @@ static void handleUuidAttr(Sema &S, Decl
 }
   }
 
+  // FIXME: It'd be nice to also emit a fixit removing uuid(...) (and, if it's
+  // the only thing in the [] list, the [] too), and add an insertion of
+  // __declspec(uuid(...)).  But sadly, neither the SourceLocs of the commas
+  // separating attributes nor of the [ and the ] are in the AST.
+  // Cf "SourceLocations of attribute list delimiters – [[ ... , ... ]] etc"
+  // on cfe-dev.
+  if (Attr.isMicrosoftAttribute()) // Check for [uuid(...)] spelling.
+S.Diag(Attr.getLoc(), diag::warn_atl_uuid_deprecated);
+
   UuidAttr *UA = S.mergeUuidAttr(D, Attr.getRange(),
  Attr.getAttributeSpellingListIndex(), StrRef);
   if (UA)

Modified: cfe/trunk/test/Parser/MicrosoftExtensions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/MicrosoftExtensions.cpp?rev=302255&r1=302254&r2=302255&view=diff
==
--- cfe/trunk/test/Parser/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/Parser/MicrosoftExtensions.cpp Fri May  5 12:05:56 2017
@@ -60,7 +60,7 @@ struct struct_without_uuid { };
 struct __declspec(uuid("00A0---C000-0049"))
 struct_with_uuid2;
 
-[uuid("00A0---C000-0049")] struct struct_with_uuid3;
+[uuid("00A0---C000-0049")] struct struct_with_uuid3; // 
expected-warning{{specifying 'uuid' as an ATL attribute is deprecated; use 
__declspec instead}}
 
 struct
 struct_with_uuid2 {} ;

Modified: cfe/trunk/test/Parser/ms-square-bracket-attributes.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/ms-square-bracket-attributes.mm?rev=302255&r1=302254&r2=302255&view=diff
==
--- cfe/trunk/test/Parser/ms-square-bracket-attributes.mm (original)
+++ cfe/trunk/test/Parser/ms-square-bracket-attributes.mm Fri May  5 12:05:56 
2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify -fms-extensions %s 
-Wno-deprecated-declarations
 
 typedef struct _GUID {
   unsigned long Data1;

Modified: cfe/trunk/test/SemaCXX/ms-uuid.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ms-uuid.cpp?rev=302255&r1=302254&r2=302255&view=diff
===

[PATCH] D32879: Warn that the [] spelling of uuid(...) is deprecated.

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

r302255, thanks!


https://reviews.llvm.org/D32879



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


Re: r302255 - Warn that the [] spelling of uuid(...) is deprecated.

2017-05-05 Thread Nico Weber via cfe-commits
Timestamps on cfe-commits are a bit messed up. I landed that just now, but
the timestamp is from 13 minutes in the past. Maybe the clock on the mail
server is off by 13 min?

On Fri, May 5, 2017 at 1:05 PM, Nico Weber via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: nico
> Date: Fri May  5 12:05:56 2017
> New Revision: 302255
>
> URL: http://llvm.org/viewvc/llvm-project?rev=302255&view=rev
> Log:
> Warn that the [] spelling of uuid(...) is deprecated.
>
> https://reviews.llvm.org/D32879
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/test/Parser/MicrosoftExtensions.cpp
> cfe/trunk/test/Parser/ms-square-bracket-attributes.mm
> cfe/trunk/test/SemaCXX/ms-uuid.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticSemaKinds.td?rev=302255&r1=302254&r2=302255&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri May  5
> 12:05:56 2017
> @@ -730,6 +730,9 @@ def err_super_in_lambda_unsupported : Er
>  def warn_pragma_unused_undeclared_var : Warning<
>"undeclared variable %0 used as an argument for '#pragma unused'">,
>InGroup;
> +def warn_atl_uuid_deprecated : Warning<
> +  "specifying 'uuid' as an ATL attribute is deprecated; use __declspec
> instead">,
> +  InGroup;
>  def warn_pragma_unused_expected_var_arg : Warning<
>"only variables can be arguments to '#pragma unused'">,
>InGroup;
>
> Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/
> ParseDeclCXX.cpp?rev=302255&r1=302254&r2=302255&view=diff
> 
> ==
> --- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Fri May  5 12:05:56 2017
> @@ -4151,8 +4151,6 @@ void Parser::ParseMicrosoftUuidAttribute
>}
>
>if (!T.consumeClose()) {
> -// FIXME: Warn that this syntax is deprecated, with a Fix-It
> suggesting
> -// using __declspec(uuid()) instead.
>  Attrs.addNew(UuidIdent, SourceRange(UuidLoc, T.getCloseLocation()),
> nullptr,
>   SourceLocation(), ArgExprs.data(), ArgExprs.size(),
>   AttributeList::AS_Microsoft);
>
> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaDeclAttr.cpp?rev=302255&r1=302254&r2=302255&view=diff
> 
> ==
> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri May  5 12:05:56 2017
> @@ -5079,6 +5079,15 @@ static void handleUuidAttr(Sema &S, Decl
>  }
>}
>
> +  // FIXME: It'd be nice to also emit a fixit removing uuid(...) (and, if
> it's
> +  // the only thing in the [] list, the [] too), and add an insertion of
> +  // __declspec(uuid(...)).  But sadly, neither the SourceLocs of the
> commas
> +  // separating attributes nor of the [ and the ] are in the AST.
> +  // Cf "SourceLocations of attribute list delimiters – [[ ... , ... ]]
> etc"
> +  // on cfe-dev.
> +  if (Attr.isMicrosoftAttribute()) // Check for [uuid(...)] spelling.
> +S.Diag(Attr.getLoc(), diag::warn_atl_uuid_deprecated);
> +
>UuidAttr *UA = S.mergeUuidAttr(D, Attr.getRange(),
>   Attr.getAttributeSpellingListIndex(),
> StrRef);
>if (UA)
>
> Modified: cfe/trunk/test/Parser/MicrosoftExtensions.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/
> MicrosoftExtensions.cpp?rev=302255&r1=302254&r2=302255&view=diff
> 
> ==
> --- cfe/trunk/test/Parser/MicrosoftExtensions.cpp (original)
> +++ cfe/trunk/test/Parser/MicrosoftExtensions.cpp Fri May  5 12:05:56 2017
> @@ -60,7 +60,7 @@ struct struct_without_uuid { };
>  struct __declspec(uuid("00A0---C000-0049"))
>  struct_with_uuid2;
>
> -[uuid("00A0---C000-0049")] struct struct_with_uuid3;
> +[uuid("00A0---C000-0049")] struct struct_with_uuid3;
> // expected-warning{{specifying 'uuid' as an ATL attribute is deprecated;
> use __declspec instead}}
>
>  struct
>  struct_with_uuid2 {} ;
>
> Modified: cfe/trunk/test/Parser/ms-square-bracket-attributes.mm
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/
> ms-square-bracket-attributes.mm?rev=302255&r1=302254&r2=302255&view=diff
> 
> ==
> --- cfe/trunk/test/Parser/ms-square-bracket-attributes.mm (original)
> +++ cfe/trunk/test/Parser/ms-square-bracket-attribute

Re: r302255 - Warn that the [] spelling of uuid(...) is deprecated.

2017-05-05 Thread Aaron Ballman via cfe-commits
On Fri, May 5, 2017 at 1:05 PM, Nico Weber via cfe-commits
 wrote:
> Author: nico
> Date: Fri May  5 12:05:56 2017
> New Revision: 302255
>
> URL: http://llvm.org/viewvc/llvm-project?rev=302255&view=rev
> Log:
> Warn that the [] spelling of uuid(...) is deprecated.
>
> https://reviews.llvm.org/D32879
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/test/Parser/MicrosoftExtensions.cpp
> cfe/trunk/test/Parser/ms-square-bracket-attributes.mm
> cfe/trunk/test/SemaCXX/ms-uuid.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=302255&r1=302254&r2=302255&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri May  5 12:05:56 
> 2017
> @@ -730,6 +730,9 @@ def err_super_in_lambda_unsupported : Er
>  def warn_pragma_unused_undeclared_var : Warning<
>"undeclared variable %0 used as an argument for '#pragma unused'">,
>InGroup;
> +def warn_atl_uuid_deprecated : Warning<
> +  "specifying 'uuid' as an ATL attribute is deprecated; use __declspec 
> instead">,
> +  InGroup;
>  def warn_pragma_unused_expected_var_arg : Warning<
>"only variables can be arguments to '#pragma unused'">,
>InGroup;
>
> Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=302255&r1=302254&r2=302255&view=diff
> ==
> --- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Fri May  5 12:05:56 2017
> @@ -4151,8 +4151,6 @@ void Parser::ParseMicrosoftUuidAttribute
>}
>
>if (!T.consumeClose()) {
> -// FIXME: Warn that this syntax is deprecated, with a Fix-It suggesting
> -// using __declspec(uuid()) instead.
>  Attrs.addNew(UuidIdent, SourceRange(UuidLoc, T.getCloseLocation()), 
> nullptr,
>   SourceLocation(), ArgExprs.data(), ArgExprs.size(),
>   AttributeList::AS_Microsoft);
>
> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=302255&r1=302254&r2=302255&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri May  5 12:05:56 2017
> @@ -5079,6 +5079,15 @@ static void handleUuidAttr(Sema &S, Decl
>  }
>}
>
> +  // FIXME: It'd be nice to also emit a fixit removing uuid(...) (and, if 
> it's
> +  // the only thing in the [] list, the [] too), and add an insertion of
> +  // __declspec(uuid(...)).  But sadly, neither the SourceLocs of the commas
> +  // separating attributes nor of the [ and the ] are in the AST.
> +  // Cf "SourceLocations of attribute list delimiters – [[ ... , ... ]] 
> etc"

You introduced some non-ASCII characters in this comment. Can you fix that up?

Thanks!

~Aaron

> +  // on cfe-dev.
> +  if (Attr.isMicrosoftAttribute()) // Check for [uuid(...)] spelling.
> +S.Diag(Attr.getLoc(), diag::warn_atl_uuid_deprecated);
> +
>UuidAttr *UA = S.mergeUuidAttr(D, Attr.getRange(),
>   Attr.getAttributeSpellingListIndex(), 
> StrRef);
>if (UA)
>
> Modified: cfe/trunk/test/Parser/MicrosoftExtensions.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/MicrosoftExtensions.cpp?rev=302255&r1=302254&r2=302255&view=diff
> ==
> --- cfe/trunk/test/Parser/MicrosoftExtensions.cpp (original)
> +++ cfe/trunk/test/Parser/MicrosoftExtensions.cpp Fri May  5 12:05:56 2017
> @@ -60,7 +60,7 @@ struct struct_without_uuid { };
>  struct __declspec(uuid("00A0---C000-0049"))
>  struct_with_uuid2;
>
> -[uuid("00A0---C000-0049")] struct struct_with_uuid3;
> +[uuid("00A0---C000-0049")] struct struct_with_uuid3; // 
> expected-warning{{specifying 'uuid' as an ATL attribute is deprecated; use 
> __declspec instead}}
>
>  struct
>  struct_with_uuid2 {} ;
>
> Modified: cfe/trunk/test/Parser/ms-square-bracket-attributes.mm
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/ms-square-bracket-attributes.mm?rev=302255&r1=302254&r2=302255&view=diff
> ==
> --- cfe/trunk/test/Parser/ms-square-bracket-attributes.mm (original)
> +++ cfe/trunk/test/Parser/ms-square-bracket-attributes.mm Fri May  5 12:05:56 
> 2017
> @@ -1,4 +1,4 @@
> -// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify -fms-extensi

r302258 - ANSIfy. No behavior change.

2017-05-05 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri May  5 12:15:08 2017
New Revision: 302258

URL: http://llvm.org/viewvc/llvm-project?rev=302258&view=rev
Log:
ANSIfy. No behavior change.

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=302258&r1=302257&r2=302258&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri May  5 12:15:08 2017
@@ -2751,7 +2751,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 
 // Push a clang.arc.use cleanup for each object in RetainableOperands. The
 // cleanup will cause the use to appear after the final log call, keeping
-// the object valid while it’s held in the log buffer.  Note that if 
there’s
+// the object valid while it's held in the log buffer.  Note that if 
there’s
 // a release cleanup on the object, it will already be active; since
 // cleanups are emitted in reverse order, the use will occur before the
 // object is released.

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=302258&r1=302257&r2=302258&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri May  5 12:15:08 2017
@@ -5083,7 +5083,7 @@ static void handleUuidAttr(Sema &S, Decl
   // the only thing in the [] list, the [] too), and add an insertion of
   // __declspec(uuid(...)).  But sadly, neither the SourceLocs of the commas
   // separating attributes nor of the [ and the ] are in the AST.
-  // Cf "SourceLocations of attribute list delimiters – [[ ... , ... ]] etc"
+  // Cf "SourceLocations of attribute list delimiters - [[ ... , ... ]] etc"
   // on cfe-dev.
   if (Attr.isMicrosoftAttribute()) // Check for [uuid(...)] spelling.
 S.Diag(Attr.getLoc(), diag::warn_atl_uuid_deprecated);

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=302258&r1=302257&r2=302258&view=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Fri May  5 12:15:08 2017
@@ -2828,7 +2828,7 @@ Sema::PerformMoveOrCopyInitialization(co
 
 // [...] If the first overload resolution fails or was not performed, 
or
 // if the type of the first parameter of the selected constructor is 
not
-// an rvalue reference to the object’s type (possibly cv-qualified),
+// an rvalue reference to the object's type (possibly cv-qualified),
 // overload resolution is performed again, considering the object as an
 // lvalue.
 if (!RRefType ||


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


Re: r302255 - Warn that the [] spelling of uuid(...) is deprecated.

2017-05-05 Thread Nico Weber via cfe-commits
On Fri, May 5, 2017 at 1:21 PM, Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Fri, May 5, 2017 at 1:05 PM, Nico Weber via cfe-commits
>  wrote:
> > Author: nico
> > Date: Fri May  5 12:05:56 2017
> > New Revision: 302255
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=302255&view=rev
> > Log:
> > Warn that the [] spelling of uuid(...) is deprecated.
> >
> > https://reviews.llvm.org/D32879
> >
> > Modified:
> > cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> > cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> > cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> > cfe/trunk/test/Parser/MicrosoftExtensions.cpp
> > cfe/trunk/test/Parser/ms-square-bracket-attributes.mm
> > cfe/trunk/test/SemaCXX/ms-uuid.cpp
> >
> > Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticSemaKinds.td?rev=302255&r1=302254&r2=302255&view=diff
> > 
> ==
> > --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> > +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri May  5
> 12:05:56 2017
> > @@ -730,6 +730,9 @@ def err_super_in_lambda_unsupported : Er
> >  def warn_pragma_unused_undeclared_var : Warning<
> >"undeclared variable %0 used as an argument for '#pragma unused'">,
> >InGroup;
> > +def warn_atl_uuid_deprecated : Warning<
> > +  "specifying 'uuid' as an ATL attribute is deprecated; use __declspec
> instead">,
> > +  InGroup;
> >  def warn_pragma_unused_expected_var_arg : Warning<
> >"only variables can be arguments to '#pragma unused'">,
> >InGroup;
> >
> > Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/
> ParseDeclCXX.cpp?rev=302255&r1=302254&r2=302255&view=diff
> > 
> ==
> > --- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
> > +++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Fri May  5 12:05:56 2017
> > @@ -4151,8 +4151,6 @@ void Parser::ParseMicrosoftUuidAttribute
> >}
> >
> >if (!T.consumeClose()) {
> > -// FIXME: Warn that this syntax is deprecated, with a Fix-It
> suggesting
> > -// using __declspec(uuid()) instead.
> >  Attrs.addNew(UuidIdent, SourceRange(UuidLoc, T.getCloseLocation()),
> nullptr,
> >   SourceLocation(), ArgExprs.data(), ArgExprs.size(),
> >   AttributeList::AS_Microsoft);
> >
> > Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaDeclAttr.cpp?rev=302255&r1=302254&r2=302255&view=diff
> > 
> ==
> > --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> > +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri May  5 12:05:56 2017
> > @@ -5079,6 +5079,15 @@ static void handleUuidAttr(Sema &S, Decl
> >  }
> >}
> >
> > +  // FIXME: It'd be nice to also emit a fixit removing uuid(...) (and,
> if it's
> > +  // the only thing in the [] list, the [] too), and add an insertion of
> > +  // __declspec(uuid(...)).  But sadly, neither the SourceLocs of the
> commas
> > +  // separating attributes nor of the [ and the ] are in the AST.
> > +  // Cf "SourceLocations of attribute list delimiters – [[ ... , ...
> ]] etc"
>
> You introduced some non-ASCII characters in this comment. Can you fix that
> up?
>

Sure, 302258. Thanks for catching.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r302259 - ANSIfy more. Still no behavior change.

2017-05-05 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri May  5 12:16:58 2017
New Revision: 302259

URL: http://llvm.org/viewvc/llvm-project?rev=302259&view=rev
Log:
ANSIfy more. Still no behavior change.

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=302259&r1=302258&r2=302259&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri May  5 12:16:58 2017
@@ -2751,7 +2751,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 
 // Push a clang.arc.use cleanup for each object in RetainableOperands. The
 // cleanup will cause the use to appear after the final log call, keeping
-// the object valid while it's held in the log buffer.  Note that if 
there’s
+// the object valid while it's held in the log buffer.  Note that if 
there's
 // a release cleanup on the object, it will already be active; since
 // cleanups are emitted in reverse order, the use will occur before the
 // object is released.


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


Re: r302259 - ANSIfy more. Still no behavior change.

2017-05-05 Thread Nico Weber via cfe-commits
I had run `ack "[\x80-\xFF]" lib` to find these, and didn't expect that it
can fire more than once on a given line. (We had 4 instance in all of
clang, 2 in this line.)

On Fri, May 5, 2017 at 1:16 PM, Nico Weber via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: nico
> Date: Fri May  5 12:16:58 2017
> New Revision: 302259
>
> URL: http://llvm.org/viewvc/llvm-project?rev=302259&view=rev
> Log:
> ANSIfy more. Still no behavior change.
>
> Modified:
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CGBuiltin.cpp?rev=302259&r1=302258&r2=302259&view=diff
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri May  5 12:16:58 2017
> @@ -2751,7 +2751,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(
>
>  // Push a clang.arc.use cleanup for each object in
> RetainableOperands. The
>  // cleanup will cause the use to appear after the final log call,
> keeping
> -// the object valid while it's held in the log buffer.  Note that if
> there’s
> +// the object valid while it's held in the log buffer.  Note that if
> there's
>  // a release cleanup on the object, it will already be active; since
>  // cleanups are emitted in reverse order, the use will occur before
> the
>  // object is released.
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r302258 - ANSIfy. No behavior change.

2017-05-05 Thread Aaron Ballman via cfe-commits
On Fri, May 5, 2017 at 1:15 PM, Nico Weber via cfe-commits
 wrote:
> Author: nico
> Date: Fri May  5 12:15:08 2017
> New Revision: 302258
>
> URL: http://llvm.org/viewvc/llvm-project?rev=302258&view=rev
> Log:
> ANSIfy. No behavior change.

Thank you for handling these!

~Aaron

>
> Modified:
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/lib/Sema/SemaStmt.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=302258&r1=302257&r2=302258&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri May  5 12:15:08 2017
> @@ -2751,7 +2751,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(
>
>  // Push a clang.arc.use cleanup for each object in RetainableOperands. 
> The
>  // cleanup will cause the use to appear after the final log call, keeping
> -// the object valid while it’s held in the log buffer.  Note that if 
> there’s
> +// the object valid while it's held in the log buffer.  Note that if 
> there’s
>  // a release cleanup on the object, it will already be active; since
>  // cleanups are emitted in reverse order, the use will occur before the
>  // object is released.
>
> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=302258&r1=302257&r2=302258&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri May  5 12:15:08 2017
> @@ -5083,7 +5083,7 @@ static void handleUuidAttr(Sema &S, Decl
>// the only thing in the [] list, the [] too), and add an insertion of
>// __declspec(uuid(...)).  But sadly, neither the SourceLocs of the commas
>// separating attributes nor of the [ and the ] are in the AST.
> -  // Cf "SourceLocations of attribute list delimiters – [[ ... , ... ]] 
> etc"
> +  // Cf "SourceLocations of attribute list delimiters - [[ ... , ... ]] etc"
>// on cfe-dev.
>if (Attr.isMicrosoftAttribute()) // Check for [uuid(...)] spelling.
>  S.Diag(Attr.getLoc(), diag::warn_atl_uuid_deprecated);
>
> Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=302258&r1=302257&r2=302258&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaStmt.cpp Fri May  5 12:15:08 2017
> @@ -2828,7 +2828,7 @@ Sema::PerformMoveOrCopyInitialization(co
>
>  // [...] If the first overload resolution fails or was not 
> performed, or
>  // if the type of the first parameter of the selected constructor is 
> not
> -// an rvalue reference to the object’s type (possibly 
> cv-qualified),
> +// an rvalue reference to the object's type (possibly cv-qualified),
>  // overload resolution is performed again, considering the object as 
> an
>  // lvalue.
>  if (!RRefType ||
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r302261 - [clang-tidy] Fix misc-move-const-arg for move-only types.

2017-05-05 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri May  5 12:33:49 2017
New Revision: 302261

URL: http://llvm.org/viewvc/llvm-project?rev=302261&view=rev
Log:
[clang-tidy] Fix misc-move-const-arg for move-only types.

Summary: Fix misc-move-const-arg false positives on move-only types.

Reviewers: sbenza

Reviewed By: sbenza

Subscribers: xazax.hun, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp?rev=302261&r1=302260&r2=302261&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp Fri 
May  5 12:33:49 2017
@@ -73,6 +73,12 @@ void MoveConstantArgumentCheck::check(co
   Arg->getType().isTriviallyCopyableType(*Result.Context);
 
   if (IsConstArg || IsTriviallyCopyable) {
+if (const CXXRecordDecl *R = Arg->getType()->getAsCXXRecordDecl()) {
+  for (const auto *Ctor : R->ctors()) {
+if (Ctor->isCopyConstructor() && Ctor->isDeleted())
+  return;
+  }
+}
 bool IsVariable = isa(Arg);
 const auto *Var =
 IsVariable ? dyn_cast(Arg)->getDecl() : nullptr;

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp?rev=302261&r1=302260&r2=302261&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp Fri May  5 
12:33:49 2017
@@ -158,3 +158,16 @@ void moveToConstReferenceNegatives() {
   // a lambda that is, in turn, an argument to a macro.
   CALL([no_move_semantics] { M3(NoMoveSemantics, no_move_semantics); });
 }
+
+class MoveOnly {
+public:
+  MoveOnly(const MoveOnly &other) = delete;
+  MoveOnly &operator=(const MoveOnly &other) = delete;
+  MoveOnly(MoveOnly &&other) = default;
+  MoveOnly &operator=(MoveOnly &&other) = default;
+};
+template 
+void Q(T);
+void moveOnlyNegatives(MoveOnly val) {
+  Q(std::move(val));
+}


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


[PATCH] D31160: [clang-tidy] Fix misc-move-const-arg for move-only types.

2017-05-05 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302261: [clang-tidy] Fix misc-move-const-arg for move-only 
types. (authored by alexfh).

Changed prior to commit:
  https://reviews.llvm.org/D31160?vs=97971&id=97985#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31160

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


Index: clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
@@ -158,3 +158,16 @@
   // a lambda that is, in turn, an argument to a macro.
   CALL([no_move_semantics] { M3(NoMoveSemantics, no_move_semantics); });
 }
+
+class MoveOnly {
+public:
+  MoveOnly(const MoveOnly &other) = delete;
+  MoveOnly &operator=(const MoveOnly &other) = delete;
+  MoveOnly(MoveOnly &&other) = default;
+  MoveOnly &operator=(MoveOnly &&other) = default;
+};
+template 
+void Q(T);
+void moveOnlyNegatives(MoveOnly val) {
+  Q(std::move(val));
+}
Index: clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
@@ -73,6 +73,12 @@
   Arg->getType().isTriviallyCopyableType(*Result.Context);
 
   if (IsConstArg || IsTriviallyCopyable) {
+if (const CXXRecordDecl *R = Arg->getType()->getAsCXXRecordDecl()) {
+  for (const auto *Ctor : R->ctors()) {
+if (Ctor->isCopyConstructor() && Ctor->isDeleted())
+  return;
+  }
+}
 bool IsVariable = isa(Arg);
 const auto *Var =
 IsVariable ? dyn_cast(Arg)->getDecl() : nullptr;


Index: clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
@@ -158,3 +158,16 @@
   // a lambda that is, in turn, an argument to a macro.
   CALL([no_move_semantics] { M3(NoMoveSemantics, no_move_semantics); });
 }
+
+class MoveOnly {
+public:
+  MoveOnly(const MoveOnly &other) = delete;
+  MoveOnly &operator=(const MoveOnly &other) = delete;
+  MoveOnly(MoveOnly &&other) = default;
+  MoveOnly &operator=(MoveOnly &&other) = default;
+};
+template 
+void Q(T);
+void moveOnlyNegatives(MoveOnly val) {
+  Q(std::move(val));
+}
Index: clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
@@ -73,6 +73,12 @@
   Arg->getType().isTriviallyCopyableType(*Result.Context);
 
   if (IsConstArg || IsTriviallyCopyable) {
+if (const CXXRecordDecl *R = Arg->getType()->getAsCXXRecordDecl()) {
+  for (const auto *Ctor : R->ctors()) {
+if (Ctor->isCopyConstructor() && Ctor->isDeleted())
+  return;
+  }
+}
 bool IsVariable = isa(Arg);
 const auto *Var =
 IsVariable ? dyn_cast(Arg)->getDecl() : nullptr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32635: [libcxx] regex: fix backreferences in forward assertions

2017-05-05 Thread Peter Ammon via Phabricator via cfe-commits
pammon added a comment.

ping?


https://reviews.llvm.org/D32635



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


Re: r302255 - Warn that the [] spelling of uuid(...) is deprecated.

2017-05-05 Thread Friedman, Eli via cfe-commits

On 5/5/2017 10:20 AM, Nico Weber via cfe-commits wrote:
Timestamps on cfe-commits are a bit messed up. I landed that just now, 
but the timestamp is from 13 minutes in the past. Maybe the clock on 
the mail server is off by 13 min?


The timestamp on the message matches the timestamp in the svn log. But 
yes, it looks like the clock on that server is way off.


-Eli

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project

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


r302270 - CodeGen: avoid use of @clang.arc.use intrinsic at O0

2017-05-05 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri May  5 13:39:06 2017
New Revision: 302270

URL: http://llvm.org/viewvc/llvm-project?rev=302270&view=rev
Log:
CodeGen: avoid use of @clang.arc.use intrinsic at O0

The clang.arc.use intrinsic is removed via the ARC Contract Pass.  This
pass is only executed in optimized builds (>= opt level 1).  Prevent the
optimization implemented in SVN r301667 from triggering at optimization
level 0 like every other ARC use intrinsic usage.

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/test/CodeGenObjC/arc-foreach.m

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=302270&r1=302269&r2=302270&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Fri May  5 13:39:06 2017
@@ -623,9 +623,13 @@ static void enterBlockScope(CodeGenFunct
 // For const-qualified captures, emit clang.arc.use to ensure the captured
 // object doesn't get released while we are still depending on its validity
 // within the block.
-if (VT.isConstQualified() && VT.getObjCLifetime() == 
Qualifiers::OCL_Strong)
+if (VT.isConstQualified() &&
+VT.getObjCLifetime() == Qualifiers::OCL_Strong &&
+CGF.CGM.getCodeGenOpts().OptimizationLevel != 0) {
+  assert(CGF.CGM.getLangOpts().ObjCAutoRefCount &&
+ "expected ObjC ARC to be enabled");
   destroyer = CodeGenFunction::emitARCIntrinsicUse;
-else if (dtorKind == QualType::DK_objc_strong_lifetime) {
+} else if (dtorKind == QualType::DK_objc_strong_lifetime) {
   destroyer = CodeGenFunction::destroyARCStrongImprecise;
 } else {
   destroyer = CGF.getDestroyer(dtorKind);

Modified: cfe/trunk/test/CodeGenObjC/arc-foreach.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-foreach.m?rev=302270&r1=302269&r2=302270&view=diff
==
--- cfe/trunk/test/CodeGenObjC/arc-foreach.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc-foreach.m Fri May  5 13:39:06 2017
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fblocks -fobjc-arc -fobjc-runtime-has-weak -triple 
x86_64-apple-darwin -emit-llvm %s -o %t-64.s
-// RUN: FileCheck -check-prefix CHECK-LP64 --input-file=%t-64.s %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fblocks -fobjc-arc 
-fobjc-runtime-has-weak -emit-llvm %s -o - | FileCheck -check-prefix CHECK-LP64 
%s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -fblocks -fobjc-arc 
-fobjc-runtime-has-weak -emit-llvm %s -o - | FileCheck -check-prefix 
CHECK-LP64-OPT %s
 // rdar://9503326
 // rdar://9606600
 
@@ -29,6 +29,11 @@ void test0(NSArray *array) {
 // CHECK-LP64-NEXT: [[BUFFER:%.*]] = alloca [16 x i8*], align 8
 // CHECK-LP64-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
 
+// CHECK-LP64-OPT-LABEL: define void @test0
+// CHECK-LP64-OPT: [[STATE:%.*]] = alloca [[STATE_T:%.*]], align 8
+// CHECK-LP64-OPT-NEXT: [[BUFFER:%.*]] = alloca [16 x i8*], align 8
+// CHECK-LP64-OPT-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]], align 8
+
 // Initialize 'array'.
 // CHECK-LP64-NEXT: store [[ARRAY_T]]* null, [[ARRAY_T]]** [[ARRAY]]
 // CHECK-LP64-NEXT: [[ZERO:%.*]] = bitcast [[ARRAY_T]]** [[ARRAY]] to i8**
@@ -66,8 +71,12 @@ void test0(NSArray *array) {
 // CHECK-LP64-NEXT: store i8* [[T1]], i8** [[T0]]
 // CHECK-LP64-NEXT: [[BLOCK1:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]]
 // CHECK-LP64-NEXT: call void @use_block(void ()* [[BLOCK1]])
-// CHECK-LP64-NEXT: [[CAPTURE:%.*]] = load i8*, i8** [[D0]]
-// CHECK-LP64: call void (...) @clang.arc.use(i8* [[CAPTURE]])
+// CHECK-LP64-NEXT: call void @objc_storeStrong(i8** [[D0]], i8* null)
+// CHECK-LP64-NOT:  call void (...) @clang.arc.use(i8* [[CAPTURE]])
+
+// CHECK-LP64-OPT: [[D0:%.*]] = getelementptr inbounds [[BLOCK_T]], 
[[BLOCK_T]]* [[BLOCK]], i64 0, i32 5
+// CHECK-LP64-OPT: [[CAPTURE:%.*]] = load i8*, i8** [[D0]]
+// CHECK-LP64-OPT: call void (...) @clang.arc.use(i8* [[CAPTURE]])
 
 // CHECK-LP64:  [[T0:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_
 // CHECK-LP64-NEXT: [[T1:%.*]] = bitcast [[ARRAY_T]]* [[SAVED_ARRAY]] to i8*
@@ -200,15 +209,24 @@ NSArray *array4;
 // CHECK-LP64: [[T0:%.*]] = getelementptr inbounds <{ i8*, i32, i32, 
i8*, %struct.__block_descriptor*, [[TY]]* }>, <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor*, [[TY]]* }>* [[BLOCK]], i32 0, i32 5
 // CHECK-LP64: [[BC:%.*]] = getelementptr inbounds <{ i8*, i32, i32, 
i8*, %struct.__block_descriptor*, [[TY]]* }>, <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor*, [[TY]]* }>* [[BLOCK]], i32 0, i32 5
 // CHECK-LP64: [[T1:%.*]] = load [[TY]]*, [[TY]]** [[SELF_ADDR]]
-// CHECK-LP64: store [[TY]]* [[T1]], [[TY]]** [[BC]]
+// CHECK-LP64: store [[TY]]* [[T1]], [[TY]]** [[BC]], align 8
 
-// CHECK-LP64: [[T5:%.*]] = load [[TY]]*, [[TY]]** [[T0]]
-// CHECK-L

[PATCH] D32918: [ARM] Limit the diagnose when an ISR calls a regular function

2017-05-05 Thread Weiming Zhao via Phabricator via cfe-commits
weimingz created this revision.
Herald added subscribers: javed.absar, rengolin, aemerson.

When the function is compiled with soft-float or on CPU with no FPU, we
don't need to diagnose for a call from an ISR to a regular function.


Repository:
  rL LLVM

https://reviews.llvm.org/D32918

Files:
  lib/Basic/Targets.cpp
  lib/Sema/SemaExpr.cpp
  test/Sema/arm-interrupt-attr.c


Index: test/Sema/arm-interrupt-attr.c
===
--- test/Sema/arm-interrupt-attr.c
+++ test/Sema/arm-interrupt-attr.c
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 %s -triple arm-apple-darwin -verify -fsyntax-only
-// RUN: %clang_cc1 %s -triple thumb-apple-darwin -verify -fsyntax-only
-// RUN: %clang_cc1 %s -triple armeb-none-eabi -verify -fsyntax-only
-// RUN: %clang_cc1 %s -triple thumbeb-none-eabi -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple arm-apple-darwin  -target-feature +vfp2 -verify 
-fsyntax-only
+// RUN: %clang_cc1 %s -triple thumb-apple-darwin  -target-feature +vfp3 
-verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple armeb-none-eabi  -target-feature +vfp4 -verify 
-fsyntax-only
+// RUN: %clang_cc1 %s -triple thumbeb-none-eabi  -target-feature +neon -verify 
-fsyntax-only
+// RUN: %clang_cc1 %s -triple thumbeb-none-eabi -target-feature +neon 
-target-feature +soft-float -DSOFT -verify -fsyntax-only
 
 __attribute__((interrupt(IRQ))) void foo() {} // expected-error {{'interrupt' 
attribute requires a string}}
 __attribute__((interrupt("irq"))) void foo1() {} // expected-warning 
{{'interrupt' attribute argument not supported: irq}}
@@ -24,6 +25,8 @@
   callee1();
   callee2();
 }
+
+#ifndef SOFT
 __attribute__((interrupt("IRQ"))) void caller2() {
   callee1(); // expected-warning {{call to function without interrupt 
attribute could clobber interruptee's VFP registers}}
   callee2();
@@ -33,3 +36,14 @@
 __attribute__((interrupt("IRQ"))) void caller3() {
   callee3(); // expected-warning {{call to function without interrupt 
attribute could clobber interruptee's VFP registers}}
 }
+#else
+__attribute__((interrupt("IRQ"))) void caller2() {
+  callee1();
+  callee2();
+}
+
+void (*callee3)();
+__attribute__((interrupt("IRQ"))) void caller3() {
+  callee3();
+}
+#endif
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -5399,9 +5399,11 @@
   // that the callee might not preserve them. This is easy to diagnose here,
   // but can be very challenging to debug.
   if (auto *Caller = getCurFunctionDecl())
-if (Caller->hasAttr())
-  if (!FDecl || !FDecl->hasAttr())
+if (Caller->hasAttr()) {
+  bool VFP = Context.getTargetInfo().hasFeature("vfp");
+  if (VFP && (!FDecl || !FDecl->hasAttr()))
 Diag(Fn->getExprLoc(), diag::warn_arm_interrupt_calling_convention);
+}
 
   // Promote the function operand.
   // We special-case function promotion here because we only allow promoting
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -5443,6 +5443,7 @@
 .Case("softfloat", SoftFloat)
 .Case("thumb", isThumb())
 .Case("neon", (FPU & NeonFPU) && !SoftFloat)
+.Case("vfp", FPU && !SoftFloat)
 .Case("hwdiv", HWDiv & HWDivThumb)
 .Case("hwdiv-arm", HWDiv & HWDivARM)
 .Default(false);


Index: test/Sema/arm-interrupt-attr.c
===
--- test/Sema/arm-interrupt-attr.c
+++ test/Sema/arm-interrupt-attr.c
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 %s -triple arm-apple-darwin -verify -fsyntax-only
-// RUN: %clang_cc1 %s -triple thumb-apple-darwin -verify -fsyntax-only
-// RUN: %clang_cc1 %s -triple armeb-none-eabi -verify -fsyntax-only
-// RUN: %clang_cc1 %s -triple thumbeb-none-eabi -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple arm-apple-darwin  -target-feature +vfp2 -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple thumb-apple-darwin  -target-feature +vfp3 -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple armeb-none-eabi  -target-feature +vfp4 -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple thumbeb-none-eabi  -target-feature +neon -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple thumbeb-none-eabi -target-feature +neon -target-feature +soft-float -DSOFT -verify -fsyntax-only
 
 __attribute__((interrupt(IRQ))) void foo() {} // expected-error {{'interrupt' attribute requires a string}}
 __attribute__((interrupt("irq"))) void foo1() {} // expected-warning {{'interrupt' attribute argument not supported: irq}}
@@ -24,6 +25,8 @@
   callee1();
   callee2();
 }
+
+#ifndef SOFT
 __attribute__((interrupt("IRQ"))) void caller2() {
   callee1(); // expected-warning {{call to function without interrupt attribute could clobber interruptee's VFP registers}}
   callee2();
@@ -33,3 +36,14 @@
 __attribute__((interrupt("IRQ"))) void caller3() {
   callee3(

[PATCH] D32918: [ARM] Limit the diagnose when an ISR calls a regular function

2017-05-05 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs accepted this revision.
jroelofs added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for doing that... I totally forgot!


Repository:
  rL LLVM

https://reviews.llvm.org/D32918



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


[PATCH] D32918: [ARM] Limit the diagnose when an ISR calls a regular function

2017-05-05 Thread Weiming Zhao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302274: [ARM] Limit the diagnose when an ISR calls a regular 
function (authored by weimingz).

Changed prior to commit:
  https://reviews.llvm.org/D32918?vs=97996&id=98001#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32918

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/test/Sema/arm-interrupt-attr.c


Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -5399,9 +5399,11 @@
   // that the callee might not preserve them. This is easy to diagnose here,
   // but can be very challenging to debug.
   if (auto *Caller = getCurFunctionDecl())
-if (Caller->hasAttr())
-  if (!FDecl || !FDecl->hasAttr())
+if (Caller->hasAttr()) {
+  bool VFP = Context.getTargetInfo().hasFeature("vfp");
+  if (VFP && (!FDecl || !FDecl->hasAttr()))
 Diag(Fn->getExprLoc(), diag::warn_arm_interrupt_calling_convention);
+}
 
   // Promote the function operand.
   // We special-case function promotion here because we only allow promoting
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -5443,6 +5443,7 @@
 .Case("softfloat", SoftFloat)
 .Case("thumb", isThumb())
 .Case("neon", (FPU & NeonFPU) && !SoftFloat)
+.Case("vfp", FPU && !SoftFloat)
 .Case("hwdiv", HWDiv & HWDivThumb)
 .Case("hwdiv-arm", HWDiv & HWDivARM)
 .Default(false);
Index: cfe/trunk/test/Sema/arm-interrupt-attr.c
===
--- cfe/trunk/test/Sema/arm-interrupt-attr.c
+++ cfe/trunk/test/Sema/arm-interrupt-attr.c
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 %s -triple arm-apple-darwin -verify -fsyntax-only
-// RUN: %clang_cc1 %s -triple thumb-apple-darwin -verify -fsyntax-only
-// RUN: %clang_cc1 %s -triple armeb-none-eabi -verify -fsyntax-only
-// RUN: %clang_cc1 %s -triple thumbeb-none-eabi -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple arm-apple-darwin  -target-feature +vfp2 -verify 
-fsyntax-only
+// RUN: %clang_cc1 %s -triple thumb-apple-darwin  -target-feature +vfp3 
-verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple armeb-none-eabi  -target-feature +vfp4 -verify 
-fsyntax-only
+// RUN: %clang_cc1 %s -triple thumbeb-none-eabi  -target-feature +neon -verify 
-fsyntax-only
+// RUN: %clang_cc1 %s -triple thumbeb-none-eabi -target-feature +neon 
-target-feature +soft-float -DSOFT -verify -fsyntax-only
 
 __attribute__((interrupt(IRQ))) void foo() {} // expected-error {{'interrupt' 
attribute requires a string}}
 __attribute__((interrupt("irq"))) void foo1() {} // expected-warning 
{{'interrupt' attribute argument not supported: irq}}
@@ -24,6 +25,8 @@
   callee1();
   callee2();
 }
+
+#ifndef SOFT
 __attribute__((interrupt("IRQ"))) void caller2() {
   callee1(); // expected-warning {{call to function without interrupt 
attribute could clobber interruptee's VFP registers}}
   callee2();
@@ -33,3 +36,14 @@
 __attribute__((interrupt("IRQ"))) void caller3() {
   callee3(); // expected-warning {{call to function without interrupt 
attribute could clobber interruptee's VFP registers}}
 }
+#else
+__attribute__((interrupt("IRQ"))) void caller2() {
+  callee1();
+  callee2();
+}
+
+void (*callee3)();
+__attribute__((interrupt("IRQ"))) void caller3() {
+  callee3();
+}
+#endif


Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -5399,9 +5399,11 @@
   // that the callee might not preserve them. This is easy to diagnose here,
   // but can be very challenging to debug.
   if (auto *Caller = getCurFunctionDecl())
-if (Caller->hasAttr())
-  if (!FDecl || !FDecl->hasAttr())
+if (Caller->hasAttr()) {
+  bool VFP = Context.getTargetInfo().hasFeature("vfp");
+  if (VFP && (!FDecl || !FDecl->hasAttr()))
 Diag(Fn->getExprLoc(), diag::warn_arm_interrupt_calling_convention);
+}
 
   // Promote the function operand.
   // We special-case function promotion here because we only allow promoting
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -5443,6 +5443,7 @@
 .Case("softfloat", SoftFloat)
 .Case("thumb", isThumb())
 .Case("neon", (FPU & NeonFPU) && !SoftFloat)
+.Case("vfp", FPU && !SoftFloat)
 .Case("hwdiv", HWDiv & HWDivThumb)
 .Case("hwdiv-arm", HWDiv & HWDivARM)
 .Default(false);
Index: cfe/trunk/test/Sema/arm-interrupt-attr.c
===
--- cfe/trunk/

r302274 - [ARM] Limit the diagnose when an ISR calls a regular function

2017-05-05 Thread Weiming Zhao via cfe-commits
Author: weimingz
Date: Fri May  5 14:25:29 2017
New Revision: 302274

URL: http://llvm.org/viewvc/llvm-project?rev=302274&view=rev
Log:
[ARM] Limit the diagnose when an ISR calls a regular function

Summary:
When the function is compiled with soft-float or on CPU with no FPU, we
don't need to diagnose for a call from an ISR to a regular function.

Reviewers: jroelofs, eli.friedman

Reviewed By: jroelofs

Subscribers: aemerson, rengolin, javed.absar, cfe-commits

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/arm-interrupt-attr.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=302274&r1=302273&r2=302274&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri May  5 14:25:29 2017
@@ -5443,6 +5443,7 @@ public:
 .Case("softfloat", SoftFloat)
 .Case("thumb", isThumb())
 .Case("neon", (FPU & NeonFPU) && !SoftFloat)
+.Case("vfp", FPU && !SoftFloat)
 .Case("hwdiv", HWDiv & HWDivThumb)
 .Case("hwdiv-arm", HWDiv & HWDivARM)
 .Default(false);

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=302274&r1=302273&r2=302274&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri May  5 14:25:29 2017
@@ -5399,9 +5399,11 @@ Sema::BuildResolvedCallExpr(Expr *Fn, Na
   // that the callee might not preserve them. This is easy to diagnose here,
   // but can be very challenging to debug.
   if (auto *Caller = getCurFunctionDecl())
-if (Caller->hasAttr())
-  if (!FDecl || !FDecl->hasAttr())
+if (Caller->hasAttr()) {
+  bool VFP = Context.getTargetInfo().hasFeature("vfp");
+  if (VFP && (!FDecl || !FDecl->hasAttr()))
 Diag(Fn->getExprLoc(), diag::warn_arm_interrupt_calling_convention);
+}
 
   // Promote the function operand.
   // We special-case function promotion here because we only allow promoting

Modified: cfe/trunk/test/Sema/arm-interrupt-attr.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/arm-interrupt-attr.c?rev=302274&r1=302273&r2=302274&view=diff
==
--- cfe/trunk/test/Sema/arm-interrupt-attr.c (original)
+++ cfe/trunk/test/Sema/arm-interrupt-attr.c Fri May  5 14:25:29 2017
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 %s -triple arm-apple-darwin -verify -fsyntax-only
-// RUN: %clang_cc1 %s -triple thumb-apple-darwin -verify -fsyntax-only
-// RUN: %clang_cc1 %s -triple armeb-none-eabi -verify -fsyntax-only
-// RUN: %clang_cc1 %s -triple thumbeb-none-eabi -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple arm-apple-darwin  -target-feature +vfp2 -verify 
-fsyntax-only
+// RUN: %clang_cc1 %s -triple thumb-apple-darwin  -target-feature +vfp3 
-verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple armeb-none-eabi  -target-feature +vfp4 -verify 
-fsyntax-only
+// RUN: %clang_cc1 %s -triple thumbeb-none-eabi  -target-feature +neon -verify 
-fsyntax-only
+// RUN: %clang_cc1 %s -triple thumbeb-none-eabi -target-feature +neon 
-target-feature +soft-float -DSOFT -verify -fsyntax-only
 
 __attribute__((interrupt(IRQ))) void foo() {} // expected-error {{'interrupt' 
attribute requires a string}}
 __attribute__((interrupt("irq"))) void foo1() {} // expected-warning 
{{'interrupt' attribute argument not supported: irq}}
@@ -24,6 +25,8 @@ void caller1() {
   callee1();
   callee2();
 }
+
+#ifndef SOFT
 __attribute__((interrupt("IRQ"))) void caller2() {
   callee1(); // expected-warning {{call to function without interrupt 
attribute could clobber interruptee's VFP registers}}
   callee2();
@@ -33,3 +36,14 @@ void (*callee3)();
 __attribute__((interrupt("IRQ"))) void caller3() {
   callee3(); // expected-warning {{call to function without interrupt 
attribute could clobber interruptee's VFP registers}}
 }
+#else
+__attribute__((interrupt("IRQ"))) void caller2() {
+  callee1();
+  callee2();
+}
+
+void (*callee3)();
+__attribute__((interrupt("IRQ"))) void caller3() {
+  callee3();
+}
+#endif


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


r302275 - Do not redefine the THREAD_ANNOTATION_ATTRIBUTE__ macro in the documentation.

2017-05-05 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri May  5 14:56:09 2017
New Revision: 302275

URL: http://llvm.org/viewvc/llvm-project?rev=302275&view=rev
Log:
Do not redefine the THREAD_ANNOTATION_ATTRIBUTE__ macro in the documentation.

Patch by Roman Lebedev.

Modified:
cfe/trunk/docs/ThreadSafetyAnalysis.rst

Modified: cfe/trunk/docs/ThreadSafetyAnalysis.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ThreadSafetyAnalysis.rst?rev=302275&r1=302274&r2=302275&view=diff
==
--- cfe/trunk/docs/ThreadSafetyAnalysis.rst (original)
+++ cfe/trunk/docs/ThreadSafetyAnalysis.rst Fri May  5 14:56:09 2017
@@ -764,8 +764,6 @@ implementation.
   #define THREAD_ANNOTATION_ATTRIBUTE__(x)   // no-op
   #endif
 
-  #define THREAD_ANNOTATION_ATTRIBUTE__(x)   __attribute__((x))
-
   #define CAPABILITY(x) \
 THREAD_ANNOTATION_ATTRIBUTE__(capability(x))
 


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


[PATCH] D32743: [clang-tidy] Add new cert-dcl21-cpp check.

2017-05-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/cert/CMakeLists.txt:8
   FloatLoopCounter.cpp
+  PostfixOperatorCheck.cpp
   LimitedRandomnessCheck.cpp

aaron.ballman wrote:
> Please keep the list of source files alphabetized.
This is still in the wrong position in the list.



Comment at: clang-tidy/cert/PostfixOperatorCheck.cpp:72
+
+  diag(Location, "return type of overloaded %0 is not a constant type")
+  << FuncDecl << FixItHint::CreateInsertion(Location, "const ");

aaron.ballman wrote:
> JonasToth wrote:
> > for clarity, this could be an else path to the if in line 69.
> > The if could check on the negation as well, and fix only in that case. 
> > (kinda swap the logic). I think that would be clearer.
> Instead of using "constant type", I would use "constant object type", and 
> reword it to be more similar to the previous diagnostic. In fact, you could 
> even combine the two diagnostics into one with a %select, because this 
> diagnostic should also receive the same fixit as the above one.
> ```
> "overloaded %0 returns a %select{reference|non-constant object}1, instead of 
> a constant object type"
> ```
Is there a reason you didn't combine the two diagnostics?


https://reviews.llvm.org/D32743



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


[libcxx] r302280 - Fix new warnings emitted by GCC 7

2017-05-05 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri May  5 15:32:26 2017
New Revision: 302280

URL: http://llvm.org/viewvc/llvm-project?rev=302280&view=rev
Log:
Fix new warnings emitted by GCC 7

Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/locale
libcxx/trunk/src/locale.cpp

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=302280&r1=302279&r2=302280&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri May  5 15:32:26 2017
@@ -1089,6 +1089,13 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 # define _LIBCPP_DIAGNOSE_ERROR(...)
 #endif
 
+#if __has_attribute(fallthough) || defined(_LIBCPP_COMPILER_GCC)
+// Use a function like macro to imply that it must be followed by a semicolon
+#define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
+#else
+#define _LIBCPP_FALLTHROUGH() ((void)0)
+#endif
+
 #if defined(_LIBCPP_ABI_MICROSOFT) && \
(defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
 # define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)

Modified: libcxx/trunk/include/locale
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/locale?rev=302280&r1=302279&r2=302280&view=diff
==
--- libcxx/trunk/include/locale (original)
+++ libcxx/trunk/include/locale Fri May  5 15:32:26 2017
@@ -2825,7 +2825,7 @@ money_get<_CharT, _InputIterator>::__do_
 return false;
 }
 }
-// drop through
+_LIBCPP_FALLTHROUGH();
 case money_base::none:
 if (__p != 3)
 {

Modified: libcxx/trunk/src/locale.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/locale.cpp?rev=302280&r1=302279&r2=302280&view=diff
==
--- libcxx/trunk/src/locale.cpp (original)
+++ libcxx/trunk/src/locale.cpp Fri May  5 15:32:26 2017
@@ -68,8 +68,8 @@ T&
 make(A0 a0)
 {
 static typename aligned_storage::type buf;
-::new (&buf) T(a0);
-return *reinterpret_cast(&buf);
+auto *obj = ::new (&buf) T(a0);
+return *obj;
 }
 
 template 
@@ -88,8 +88,8 @@ T&
 make(A0 a0, A1 a1, A2 a2)
 {
 static typename aligned_storage::type buf;
-::new (&buf) T(a0, a1, a2);
-return *reinterpret_cast(&buf);
+auto *obj = ::new (&buf) T(a0, a1, a2);
+return *obj;
 }
 
 template 
@@ -480,8 +480,8 @@ locale::__imp::make_global()
 {
 // only one thread can get in here and it only gets in once
 static aligned_storage::type buf;
-::new (&buf) locale(locale::classic());
-return *reinterpret_cast(&buf);
+auto *obj = ::new (&buf) locale(locale::classic());
+return *obj;
 }
 
 locale&


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


[clang-tools-extra] r302281 - [clang-tidy] Fix PR32896: detect initializer lists in modernize-use-empalce

2017-05-05 Thread Jakub Kuderski via cfe-commits
Author: kuhar
Date: Fri May  5 15:35:30 2017
New Revision: 302281

URL: http://llvm.org/viewvc/llvm-project?rev=302281&view=rev
Log:
[clang-tidy] Fix PR32896: detect initializer lists in modernize-use-empalce

Summary:
This patch fixes [[ https://bugs.llvm.org/show_bug.cgi?id=32896 | PR32896 ]].

The problem was that modernize-use-emplace incorrectly removed changed 
push_back into emplace_back, removing explicit constructor call with 
initializer list parameter, resulting in compiler error after applying fixits.
modernize-use-emplace used to check if matched constructor had InitListExpr, 
but didn't check against CXXStdInitializerListExpr.

Eg.

```
std::vector> v;
  v.push_back(std::vector({1})); // --> v.emplace_back({1});
```

Reviewers: Prazek, alexfh, aaron.ballman

Reviewed By: Prazek, alexfh, aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang-tools-extra

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp?rev=302281&r1=302280&r2=302281&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp Fri May  5 
15:35:30 2017
@@ -20,6 +20,12 @@ AST_MATCHER(DeclRefExpr, hasExplicitTemp
   return Node.hasExplicitTemplateArgs();
 }
 
+namespace impl {
+// FIXME: This matcher should be replaced by a matcher from ASTMatcher.h
+const ast_matchers::internal::VariadicDynCastAllOfMatcher cxxStdInitializerListExpr;
+} // namespace impl
+
 const auto DefaultContainersWithPushBack =
 "::std::vector; ::std::list; ::std::deque";
 const auto DefaultSmartPointers =
@@ -74,7 +80,11 @@ void UseEmplaceCheck::registerMatchers(M
   // emplace_back can't access private constructor.
   auto IsPrivateCtor = hasDeclaration(cxxConstructorDecl(isPrivate()));
 
-  auto HasInitList = has(ignoringImplicit(initListExpr()));
+  auto HasInitList = anyOf(has(ignoringImplicit(initListExpr())),
+   has(impl::cxxStdInitializerListExpr()));
+  // FIXME: Replace internal C++ initializer list matcher with one from
+  // ASTMatchers.h
+
   // FIXME: Discard 0/NULL (as nullptr), static inline const data members,
   // overloaded functions and template names.
   auto SoughtConstructExpr =

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace.cpp?rev=302281&r1=302280&r2=302281&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace.cpp Fri May  
5 15:35:30 2017
@@ -4,9 +4,19 @@
 // RUN:   value: '::std::vector; ::std::list; ::std::deque; 
llvm::LikeASmallVector'}]}" -- -std=c++11
 
 namespace std {
+template 
+class initializer_list
+{
+public:
+  initializer_list() noexcept {}
+};
+
 template 
 class vector {
 public:
+  vector() = default;
+  vector(initializer_list) {}
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
@@ -455,3 +465,16 @@ void testWithDtor() {
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
   // CHECK-FIXES: v.emplace_back(42);
 }
+
+void testInitializerList() {
+  std::vector> v;
+  v.push_back(std::vector({1}));
+  // Test against the bug reported in PR32896.
+
+  v.push_back({{2}});
+
+  using PairIntVector = std::pair>;
+  std::vector x;
+  x.push_back(PairIntVector(3, {4}));
+  x.push_back({5, {6}});
+}


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


[PATCH] D32767: [clang-tidy] Fix PR32896: detect initializer lists in modernize-use-empalce

2017-05-05 Thread Jakub Kuderski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302281: [clang-tidy] Fix PR32896: detect initializer lists 
in modernize-use-empalce (authored by kuhar).

Changed prior to commit:
  https://reviews.llvm.org/D32767?vs=97704&id=98013#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32767

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace.cpp


Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace.cpp
@@ -4,9 +4,19 @@
 // RUN:   value: '::std::vector; ::std::list; ::std::deque; 
llvm::LikeASmallVector'}]}" -- -std=c++11
 
 namespace std {
+template 
+class initializer_list
+{
+public:
+  initializer_list() noexcept {}
+};
+
 template 
 class vector {
 public:
+  vector() = default;
+  vector(initializer_list) {}
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
@@ -455,3 +465,16 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
   // CHECK-FIXES: v.emplace_back(42);
 }
+
+void testInitializerList() {
+  std::vector> v;
+  v.push_back(std::vector({1}));
+  // Test against the bug reported in PR32896.
+
+  v.push_back({{2}});
+
+  using PairIntVector = std::pair>;
+  std::vector x;
+  x.push_back(PairIntVector(3, {4}));
+  x.push_back({5, {6}});
+}
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
@@ -20,6 +20,12 @@
   return Node.hasExplicitTemplateArgs();
 }
 
+namespace impl {
+// FIXME: This matcher should be replaced by a matcher from ASTMatcher.h
+const ast_matchers::internal::VariadicDynCastAllOfMatcher cxxStdInitializerListExpr;
+} // namespace impl
+
 const auto DefaultContainersWithPushBack =
 "::std::vector; ::std::list; ::std::deque";
 const auto DefaultSmartPointers =
@@ -74,7 +80,11 @@
   // emplace_back can't access private constructor.
   auto IsPrivateCtor = hasDeclaration(cxxConstructorDecl(isPrivate()));
 
-  auto HasInitList = has(ignoringImplicit(initListExpr()));
+  auto HasInitList = anyOf(has(ignoringImplicit(initListExpr())),
+   has(impl::cxxStdInitializerListExpr()));
+  // FIXME: Replace internal C++ initializer list matcher with one from
+  // ASTMatchers.h
+
   // FIXME: Discard 0/NULL (as nullptr), static inline const data members,
   // overloaded functions and template names.
   auto SoughtConstructExpr =


Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace.cpp
@@ -4,9 +4,19 @@
 // RUN:   value: '::std::vector; ::std::list; ::std::deque; llvm::LikeASmallVector'}]}" -- -std=c++11
 
 namespace std {
+template 
+class initializer_list
+{
+public:
+  initializer_list() noexcept {}
+};
+
 template 
 class vector {
 public:
+  vector() = default;
+  vector(initializer_list) {}
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
@@ -455,3 +465,16 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
   // CHECK-FIXES: v.emplace_back(42);
 }
+
+void testInitializerList() {
+  std::vector> v;
+  v.push_back(std::vector({1}));
+  // Test against the bug reported in PR32896.
+
+  v.push_back({{2}});
+
+  using PairIntVector = std::pair>;
+  std::vector x;
+  x.push_back(PairIntVector(3, {4}));
+  x.push_back({5, {6}});
+}
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
@@ -20,6 +20,12 @@
   return Node.hasExplicitTemplateArgs();
 }
 
+namespace impl {
+// FIXME: This matcher should be replaced by a matcher from ASTMatcher.h
+const ast_matchers::internal::VariadicDynCastAllOfMatcher cxxStdInitializerListExpr;
+} // namespace impl
+
 const auto DefaultContainersWithPushBack =
 "::std::vector; ::std::list; ::std::deque";
 const auto DefaultSmartPointers =
@@ -74,7 +80,11 @@
   // emplace_back can't access private constructor.
   auto IsPrivateCtor = hasDeclaration(cxxConstructorDecl(isPrivate()));
 
-  auto HasInitList = has(ignoringImplicit(initListExpr()));
+  auto HasInitList = anyOf(has(ignoringImplicit(initListExpr())),
+   has(impl::cxxStdInitializerListExpr()));
+  // FIXME: Replace internal C++ initializer list matcher with one 

[libcxx] r302283 - Fix remaining GCC 7 build warnings

2017-05-05 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri May  5 15:39:03 2017
New Revision: 302283

URL: http://llvm.org/viewvc/llvm-project?rev=302283&view=rev
Log:
Fix remaining GCC 7 build warnings

Modified:
libcxx/trunk/src/experimental/filesystem/operations.cpp

Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/operations.cpp?rev=302283&r1=302282&r2=302283&view=diff
==
--- libcxx/trunk/src/experimental/filesystem/operations.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp Fri May  5 15:39:03 
2017
@@ -513,8 +513,8 @@ bool checked_set(CType* out, ChronoType
 return true;
 }
 
-using TimeSpec = struct ::timespec;
-using StatT = struct ::stat;
+using TimeSpec = struct timespec;
+using StatT =  struct stat;
 
 #if defined(__APPLE__)
 TimeSpec extract_mtime(StatT const& st) { return st.st_mtimespec; }


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


r302284 - [ODRHash] Fix typo, NFC

2017-05-05 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri May  5 15:47:50 2017
New Revision: 302284

URL: http://llvm.org/viewvc/llvm-project?rev=302284&view=rev
Log:
[ODRHash] Fix typo, NFC

NestedNameSpecifer to NestedNameSpecifier.  This was not a problem before since
one of the included headers transitively brought in the definition of the class
and only manifested as a problem when using the typoed NestedNameSpecifer and
getting an incomplete type error instead of a typo correction.

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

Modified: cfe/trunk/include/clang/AST/ODRHash.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ODRHash.h?rev=302284&r1=302283&r2=302284&view=diff
==
--- cfe/trunk/include/clang/AST/ODRHash.h (original)
+++ cfe/trunk/include/clang/AST/ODRHash.h Fri May  5 15:47:50 2017
@@ -25,7 +25,7 @@ namespace clang {
 
 class Decl;
 class IdentifierInfo;
-class NestedNameSpecifer;
+class NestedNameSpecifier;
 class Stmt;
 class TemplateParameterList;
 


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


[libcxx] r302285 - Fix detection for [[fallthrough]] with GCC

2017-05-05 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri May  5 15:50:24 2017
New Revision: 302285

URL: http://llvm.org/viewvc/llvm-project?rev=302285&view=rev
Log:
Fix detection for [[fallthrough]] with GCC

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=302285&r1=302284&r2=302285&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri May  5 15:50:24 2017
@@ -1089,7 +1089,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 # define _LIBCPP_DIAGNOSE_ERROR(...)
 #endif
 
-#if __has_attribute(fallthough) || defined(_LIBCPP_COMPILER_GCC)
+#if __has_attribute(fallthough) || _GNUC_VER >= 700
 // Use a function like macro to imply that it must be followed by a semicolon
 #define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
 #else


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


r302287 - Add cxxStdInitializerListExpr AST matcher

2017-05-05 Thread Jakub Kuderski via cfe-commits
Author: kuhar
Date: Fri May  5 16:01:12 2017
New Revision: 302287

URL: http://llvm.org/viewvc/llvm-project?rev=302287&view=rev
Log:
Add cxxStdInitializerListExpr AST matcher

Summary:
This adds a new ASTMatcher for CXXStdInitializerListExprs that matches C++ 
initializer list expressions.

The primary motivation is to use it to fix [[ 
https://bugs.llvm.org/show_bug.cgi?id=32896 | PR32896 ]] (review here [[ 
https://reviews.llvm.org/D32767 | D32767 ]]).

Reviewers: alexfh, Prazek, aaron.ballman

Reviewed By: alexfh, aaron.ballman

Subscribers: malcolm.parsons, cfe-commits, klimek

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

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

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=302287&r1=302286&r2=302287&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Fri May  5 16:01:12 2017
@@ -924,6 +924,19 @@ in
 
 
 
+MatcherStmt>cxxStdInitializerListExprMatcherCXXStdInitializerListExpr>...
+Matches 
C++ initializer list expressions.
+
+Given
+  std::vector a({ 1, 2, 3 });
+  std::vector b = { 4, 5 };
+  int c[] = { 6, 7 };
+  std::pair d = { 8, 9 };
+cxxStdInitializerListExpr()
+  matches "{ 1, 2, 3 }" and "{ 4, 5 }"
+
+
+
 MatcherStmt>cxxTemporaryObjectExprMatcherCXXTemporaryObjectExpr>...
 Matches 
functional cast expressions having N != 1 arguments
 
@@ -1160,7 +1173,7 @@ Example matches [&](){return 5;}
 Matches 
nodes where temporaries are materialized.
 
 Example: Given
-  struct T {void func()};
+  struct T {void func();};
   T f();
   void g(T);
 materializeTemporaryExpr() matches 'f()' in these statements
@@ -5233,7 +5246,7 @@ Example matches y in x(y)
 Matches on the 
receiver of an ObjectiveC Message expression.
 
 Example
-matcher = objCMessageExpr(hasRecieverType(asString("UIWebView *")));
+matcher = objCMessageExpr(hasReceiverType(asString("UIWebView *")));
 matches the [webView ...] message invocation.
   NSString *webViewJavaScript = ...
   UIWebView *webView = ...

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=302287&r1=302286&r2=302287&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Fri May  5 16:01:12 2017
@@ -1223,6 +1223,20 @@ AST_MATCHER_P(InitListExpr, hasSyntactic
   InnerMatcher.matches(*SyntForm, Finder, Builder));
 }
 
+/// \brief Matches C++ initializer list expressions.
+///
+/// Given
+/// \code
+///   std::vector a({ 1, 2, 3 });
+///   std::vector b = { 4, 5 };
+///   int c[] = { 6, 7 };
+///   std::pair d = { 8, 9 };
+/// \endcode
+/// cxxStdInitializerListExpr()
+///   matches "{ 1, 2, 3 }" and "{ 4, 5 }"
+const internal::VariadicDynCastAllOfMatcher cxxStdInitializerListExpr;
+
 /// \brief Matches implicit initializers of init list expressions.
 ///
 /// Given

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=302287&r1=302286&r2=302287&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Fri May  5 16:01:12 2017
@@ -153,6 +153,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(cxxRecordDecl);
   REGISTER_MATCHER(cxxReinterpretCastExpr);
   REGISTER_MATCHER(cxxStaticCastExpr);
+  REGISTER_MATCHER(cxxStdInitializerListExpr);
   REGISTER_MATCHER(cxxTemporaryObjectExpr);
   REGISTER_MATCHER(cxxThisExpr);
   REGISTER_MATCHER(cxxThrowExpr);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp?rev=302287&r1=302286&r2=302287&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp Fri May  5 16:01:12 
2017
@@ -1020,6 +1020,29 @@ TEST(InitListExpression, MatchesInitList
 matches("int i[1] = {42, [0] = 43};", integerLiteral(equals(42;
 }
 
+TEST(CX

[PATCH] D32810: Add cxxStdInitializerListExpr AST matcher

2017-05-05 Thread Jakub Kuderski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302287: Add cxxStdInitializerListExpr AST matcher (authored 
by kuhar).

Changed prior to commit:
  https://reviews.llvm.org/D32810?vs=97700&id=98018#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32810

Files:
  cfe/trunk/docs/LibASTMatchersReference.html
  cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
  cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -1223,6 +1223,20 @@
   InnerMatcher.matches(*SyntForm, Finder, Builder));
 }
 
+/// \brief Matches C++ initializer list expressions.
+///
+/// Given
+/// \code
+///   std::vector a({ 1, 2, 3 });
+///   std::vector b = { 4, 5 };
+///   int c[] = { 6, 7 };
+///   std::pair d = { 8, 9 };
+/// \endcode
+/// cxxStdInitializerListExpr()
+///   matches "{ 1, 2, 3 }" and "{ 4, 5 }"
+const internal::VariadicDynCastAllOfMatcher cxxStdInitializerListExpr;
+
 /// \brief Matches implicit initializers of init list expressions.
 ///
 /// Given
Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -153,6 +153,7 @@
   REGISTER_MATCHER(cxxRecordDecl);
   REGISTER_MATCHER(cxxReinterpretCastExpr);
   REGISTER_MATCHER(cxxStaticCastExpr);
+  REGISTER_MATCHER(cxxStdInitializerListExpr);
   REGISTER_MATCHER(cxxTemporaryObjectExpr);
   REGISTER_MATCHER(cxxThisExpr);
   REGISTER_MATCHER(cxxThrowExpr);
Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1020,6 +1020,29 @@
 matches("int i[1] = {42, [0] = 43};", integerLiteral(equals(42;
 }
 
+TEST(CXXStdInitializerListExpression, MatchesCXXStdInitializerListExpression) {
+  const std::string code = "namespace std {"
+   "template  class initializer_list {"
+   "  public: initializer_list() noexcept {}"
+   "};"
+   "}"
+   "struct A {"
+   "  A(std::initializer_list) {}"
+   "};";
+  EXPECT_TRUE(matches(code + "A a{0};",
+  cxxConstructExpr(has(cxxStdInitializerListExpr()),
+   hasDeclaration(cxxConstructorDecl(
+   ofClass(hasName("A")));
+  EXPECT_TRUE(matches(code + "A a = {0};",
+  cxxConstructExpr(has(cxxStdInitializerListExpr()),
+   hasDeclaration(cxxConstructorDecl(
+   ofClass(hasName("A")));
+
+  EXPECT_TRUE(notMatches("int a[] = { 1, 2 };", cxxStdInitializerListExpr()));
+  EXPECT_TRUE(notMatches("struct B { int x, y; }; B b = { 5, 6 };",
+ cxxStdInitializerListExpr()));
+}
+
 TEST(UsingDeclaration, MatchesUsingDeclarations) {
   EXPECT_TRUE(matches("namespace X { int x; } using X::x;",
   usingDecl()));
Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -924,6 +924,19 @@
 
 
 
+MatcherStmt>cxxStdInitializerListExprMatcherCXXStdInitializerListExpr>...
+Matches C++ initializer list expressions.
+
+Given
+  std::vector a({ 1, 2, 3 });
+  std::vector b = { 4, 5 };
+  int c[] = { 6, 7 };
+  std::pair d = { 8, 9 };
+cxxStdInitializerListExpr()
+  matches "{ 1, 2, 3 }" and "{ 4, 5 }"
+
+
+
 MatcherStmt>cxxTemporaryObjectExprMatcherCXXTemporaryObjectExpr>...
 Matches functional cast expressions having N != 1 arguments
 
@@ -1160,7 +1173,7 @@
 Matches nodes where temporaries are materialized.
 
 Example: Given
-  struct T {void func()};
+  struct T {void func();};
   T f();
   void g(T);
 materializeTemporaryExpr() matches 'f()' in these statements
@@ -5233,7 +5246,7 @@
 Matches on the receiver of an ObjectiveC Message expression.
 
 Example
-matcher = objCMessageExpr(hasRecieverType(asString("UIWebView *")));
+matcher = objCMessageExpr(hasReceiverType(asString("UIWebView *")));
 matches the [webView ...] mes

[PATCH] D32842: Specify which sanitizers are covered by a sanitizer blacklist

2017-05-05 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added reviewers: kcc, kubamracek.
vsk added a subscriber: zaks.anna.
vsk added a comment.

@zaks.anna suggested some more reviewers who may be interested.


https://reviews.llvm.org/D32842



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


LLVM buildmaster will be updated and restarted tonight

2017-05-05 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


r302296 - Multilib: add dump methods

2017-05-05 Thread Jonathan Roelofs via cfe-commits
Author: jroelofs
Date: Fri May  5 16:30:13 2017
New Revision: 302296

URL: http://llvm.org/viewvc/llvm-project?rev=302296&view=rev
Log:
Multilib: add dump methods

Modified:
cfe/trunk/include/clang/Driver/Multilib.h
cfe/trunk/lib/Driver/Multilib.cpp

Modified: cfe/trunk/include/clang/Driver/Multilib.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Multilib.h?rev=302296&r1=302295&r2=302296&view=diff
==
--- cfe/trunk/include/clang/Driver/Multilib.h (original)
+++ cfe/trunk/include/clang/Driver/Multilib.h Fri May  5 16:30:13 2017
@@ -84,6 +84,7 @@ public:
 return *this;
   }
 
+  LLVM_DUMP_METHOD void dump() const;
   /// \brief print summary of the Multilib
   void print(raw_ostream &OS) const;
 
@@ -157,6 +158,7 @@ public:
 
   unsigned size() const { return Multilibs.size(); }
 
+  LLVM_DUMP_METHOD void dump() const;
   void print(raw_ostream &OS) const;
 
   MultilibSet &setIncludeDirsCallback(IncludeDirsFunc F) {

Modified: cfe/trunk/lib/Driver/Multilib.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Multilib.cpp?rev=302296&r1=302295&r2=302296&view=diff
==
--- cfe/trunk/lib/Driver/Multilib.cpp (original)
+++ cfe/trunk/lib/Driver/Multilib.cpp Fri May  5 16:30:13 2017
@@ -80,6 +80,10 @@ Multilib &Multilib::includeSuffix(String
   return *this;
 }
 
+LLVM_DUMP_METHOD void Multilib::dump() const {
+  print(llvm::errs());
+}
+
 void Multilib::print(raw_ostream &OS) const {
   assert(GCCSuffix.empty() || (StringRef(GCCSuffix).front() == '/'));
   if (GCCSuffix.empty())
@@ -270,6 +274,10 @@ bool MultilibSet::select(const Multilib:
   return false;
 }
 
+LLVM_DUMP_METHOD void MultilibSet::dump() const {
+  print(llvm::errs());
+}
+
 void MultilibSet::print(raw_ostream &OS) const {
   for (const Multilib &M : *this)
 OS << M << "\n";


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


[libcxx] r302297 - Fix condition_variable::wait_until and wait_for on Windows.

2017-05-05 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri May  5 16:31:22 2017
New Revision: 302297

URL: http://llvm.org/viewvc/llvm-project?rev=302297&view=rev
Log:
Fix condition_variable::wait_until and wait_for on Windows.

The ERROR_TIMEDOUT returned by the Windows API does not
have the same value as ETIMEDOUT. This caused condition_variable
to return timeouts as unknown errors.

Modified:
libcxx/trunk/include/__threading_support

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=302297&r1=302296&r2=302297&view=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Fri May  5 16:31:22 2017
@@ -474,7 +474,10 @@ int __libcpp_condvar_timedwait(__libcpp_
  timeout_ms.count() > 0 ? timeout_ms.count()
 : 0,
  0))
-return GetLastError();
+{
+  auto __ec = GetLastError();
+  return __ec == ERROR_TIMEOUT ? ETIMEDOUT : __ec;
+}
   return 0;
 }
 


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


[libcxx] r302298 - Mark test using as UNSUPPORTED on Windows

2017-05-05 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri May  5 16:32:37 2017
New Revision: 302298

URL: http://llvm.org/viewvc/llvm-project?rev=302298&view=rev
Log:
Mark test using  as UNSUPPORTED on Windows

Modified:

libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp

Modified: 
libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp?rev=302298&r1=302297&r2=302298&view=diff
==
--- 
libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp
 Fri May  5 16:32:37 2017
@@ -9,6 +9,9 @@
 //
 // UNSUPPORTED: libcpp-has-no-threads
 
+// This test uses the POSIX header  which Windows doesn't provide
+// UNSUPPORTED: windows
+
 // This test depends on signal behaviour until r210210, so some system libs
 // don't pass.
 //


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


[PATCH] D32923: [clang-tidy] Use cxxStdInitializerListExpr in modernize-use-emplace

2017-05-05 Thread Jakub Kuderski via Phabricator via cfe-commits
kuhar created this revision.
kuhar added a project: clang-tools-extra.
Herald added a subscriber: xazax.hun.

Use the cxxStdInitializerListExp matcher from ASTMatchers.h instead of a local 
one.


Repository:
  rL LLVM

https://reviews.llvm.org/D32923

Files:
  clang-tidy/modernize/UseEmplaceCheck.cpp


Index: clang-tidy/modernize/UseEmplaceCheck.cpp
===
--- clang-tidy/modernize/UseEmplaceCheck.cpp
+++ clang-tidy/modernize/UseEmplaceCheck.cpp
@@ -20,12 +20,6 @@
   return Node.hasExplicitTemplateArgs();
 }
 
-namespace impl {
-// FIXME: This matcher should be replaced by a matcher from ASTMatcher.h
-const ast_matchers::internal::VariadicDynCastAllOfMatcher cxxStdInitializerListExpr;
-} // namespace impl
-
 const auto DefaultContainersWithPushBack =
 "::std::vector; ::std::list; ::std::deque";
 const auto DefaultSmartPointers =
@@ -81,9 +75,7 @@
   auto IsPrivateCtor = hasDeclaration(cxxConstructorDecl(isPrivate()));
 
   auto HasInitList = anyOf(has(ignoringImplicit(initListExpr())),
-   has(impl::cxxStdInitializerListExpr()));
-  // FIXME: Replace internal C++ initializer list matcher with one from
-  // ASTMatchers.h
+   has(cxxStdInitializerListExpr()));
 
   // FIXME: Discard 0/NULL (as nullptr), static inline const data members,
   // overloaded functions and template names.


Index: clang-tidy/modernize/UseEmplaceCheck.cpp
===
--- clang-tidy/modernize/UseEmplaceCheck.cpp
+++ clang-tidy/modernize/UseEmplaceCheck.cpp
@@ -20,12 +20,6 @@
   return Node.hasExplicitTemplateArgs();
 }
 
-namespace impl {
-// FIXME: This matcher should be replaced by a matcher from ASTMatcher.h
-const ast_matchers::internal::VariadicDynCastAllOfMatcher cxxStdInitializerListExpr;
-} // namespace impl
-
 const auto DefaultContainersWithPushBack =
 "::std::vector; ::std::list; ::std::deque";
 const auto DefaultSmartPointers =
@@ -81,9 +75,7 @@
   auto IsPrivateCtor = hasDeclaration(cxxConstructorDecl(isPrivate()));
 
   auto HasInitList = anyOf(has(ignoringImplicit(initListExpr())),
-   has(impl::cxxStdInitializerListExpr()));
-  // FIXME: Replace internal C++ initializer list matcher with one from
-  // ASTMatchers.h
+   has(cxxStdInitializerListExpr()));
 
   // FIXME: Discard 0/NULL (as nullptr), static inline const data members,
   // overloaded functions and template names.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32924: [libcxx] [test] Fix MSVC "warning C6326: Potential comparison of a constant with another constant".

2017-05-05 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT created this revision.

[libcxx] [test] Fix MSVC "warning C6326: Potential comparison of a constant 
with another constant".

The expressions `1 == 1` and `true` have the same type, value category, and 
value.


https://reviews.llvm.org/D32924

Files:
  test/std/containers/sequences/vector.bool/emplace_back.pass.cpp


Index: test/std/containers/sequences/vector.bool/emplace_back.pass.cpp
===
--- test/std/containers/sequences/vector.bool/emplace_back.pass.cpp
+++ test/std/containers/sequences/vector.bool/emplace_back.pass.cpp
@@ -48,7 +48,7 @@
 assert(c.front() == false);
 assert(c.back() == true);
 #endif
-c.emplace_back(1 == 1);
+c.emplace_back(true);
 assert(c.size() == 3);
 assert(c.front() == false);
 assert(c[1] == true);
@@ -82,7 +82,7 @@
 assert(c.front() == false);
 assert(c.back() == true);
 #endif
-c.emplace_back(1 == 1);
+c.emplace_back(true);
 assert(c.size() == 3);
 assert(c.front() == false);
 assert(c[1] == true);


Index: test/std/containers/sequences/vector.bool/emplace_back.pass.cpp
===
--- test/std/containers/sequences/vector.bool/emplace_back.pass.cpp
+++ test/std/containers/sequences/vector.bool/emplace_back.pass.cpp
@@ -48,7 +48,7 @@
 assert(c.front() == false);
 assert(c.back() == true);
 #endif
-c.emplace_back(1 == 1);
+c.emplace_back(true);
 assert(c.size() == 3);
 assert(c.front() == false);
 assert(c[1] == true);
@@ -82,7 +82,7 @@
 assert(c.front() == false);
 assert(c.back() == true);
 #endif
-c.emplace_back(1 == 1);
+c.emplace_back(true);
 assert(c.size() == 3);
 assert(c.front() == false);
 assert(c[1] == true);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32724: [Modules] Include the enabled sanitizers in the module hash

2017-05-05 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 98030.
vsk edited the summary of this revision.
vsk added a comment.

- Exclude sanitizers which cannot affect AST generation from the module hash.
- Improve the test to check modules are actually rebuilt when we expect them to 
be rebuilt, and not rebuilt otherwise.


https://reviews.llvm.org/D32724

Files:
  include/clang/Basic/Sanitizers.h
  lib/Basic/LangOptions.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Modules/Inputs/check-for-sanitizer-feature/check.h
  test/Modules/Inputs/check-for-sanitizer-feature/map
  test/Modules/check-for-sanitizer-feature.cpp

Index: test/Modules/check-for-sanitizer-feature.cpp
===
--- /dev/null
+++ test/Modules/check-for-sanitizer-feature.cpp
@@ -0,0 +1,50 @@
+// RUN: rm -rf %t.1 %t.2
+// RUN: mkdir %t.1 %t.2
+
+// Build and use an ASan-enabled module.
+// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 2
+
+// Force a module rebuild by disabling ASan.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 3
+
+// Enable ASan again: check that there is no import failure, and no rebuild.
+// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 3
+
+// Some sanitizers can not affect AST generation when enabled. Check that
+// module rebuilds don't occur when these sanitizers are enabled.
+//
+// First, built without any sanitization.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.2 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.2 | count 2
+//
+// Next, build with sanitization, and check that a new module isn't built.
+// RUN: %clang_cc1 -fsanitize=cfi-vcall,unsigned-integer-overflow,nullability-arg,null -fmodules \
+// RUN:   -fmodules-cache-path=%t.2 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.2 | count 2
+
+#include "check.h"
+
+#if __has_feature(address_sanitizer)
+#if HAS_ASAN != 1
+#error Does not have the address_sanitizer feature, but should.
+#endif
+#else
+#if HAS_ASAN != 0
+#error Has the address_sanitizer feature, but shouldn't.
+#endif
+#endif
+
+// expected-no-diagnostics
Index: test/Modules/Inputs/check-for-sanitizer-feature/map
===
--- /dev/null
+++ test/Modules/Inputs/check-for-sanitizer-feature/map
@@ -0,0 +1,3 @@
+module check_feature {
+  header "check.h"
+}
Index: test/Modules/Inputs/check-for-sanitizer-feature/check.h
===
--- /dev/null
+++ test/Modules/Inputs/check-for-sanitizer-feature/check.h
@@ -0,0 +1,5 @@
+#if __has_feature(address_sanitizer)
+#define HAS_ASAN 1
+#else
+#define HAS_ASAN 0
+#endif
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2693,6 +2693,14 @@
 code = ext->hashExtension(code);
   }
 
+  // Extend the signature with the enabled sanitizers, if at least one is
+  // enabled. Sanitizers which cannot affect AST generation aren't hashed.
+  SanitizerSet SanHash = LangOpts->Sanitize;
+  SanHash.clear(SanitizerKind::CFI | SanitizerKind::Integer |
+SanitizerKind::Nullability | SanitizerKind::Undefined);
+  if (!SanHash.empty())
+code = hash_combine(code, SanHash.Mask);
+
   return llvm::APInt(64, code).toString(36, /*Signed=*/false);
 }
 
Index: lib/Basic/LangOptions.cpp
===
--- lib/Basic/LangOptions.cpp
+++ lib/Basic/LangOptions.cpp
@@ -29,9 +29,7 @@
   Name = Default;
 #include "clang/Basic/LangOptions.def"
 
-  // FIXME: This should not be reset; modules can be different with different
-  // sanitizer options (this affects __has_feature(address_sanitizer) etc).
-  Sanitize.clear();
+  // These options do not affect AST generation.
   SanitizerBlacklistFiles.clear();
   XRayAlwaysInstrumentFiles.clear();
   XRayNeverInstrumentFiles.clear();
Index: include/clang/Basic/Sanitizers.h
===
--- include/clang/Basic/Sanitizers.h
+++ include/clang/Basic/Sanitizers.h
@@ -61,8 +61,9 @@
 Mask = Value ? (Mask | K) : (Mask & ~K);
   }
 
-  /// \brief Disable all sanitizers.
-  void clear()

r302309 - Add support for building modules from preprocessed source.

2017-05-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May  5 17:18:51 2017
New Revision: 302309

URL: http://llvm.org/viewvc/llvm-project?rev=302309&view=rev
Log:
Add support for building modules from preprocessed source.

To support this, an optional marker "#pragma clang module contents" is
recognized in module map files, and the rest of the module map file from that
point onwards is treated as the source of the module. Preprocessing a module
map produces the input module followed by the marker and then the preprocessed
contents of the module.

Ignoring line markers, a preprocessed module might look like this:

  module A {
header "a.h"
  }
  #pragma clang module contents
  #pragma clang module begin A
  // ... a.h ...
  #pragma clang module end

The preprocessed output generates line markers, which are not accepted by the
module map parser, so -x c++-module-map-cpp-output should be used to compile
such outputs.

A couple of major parts do not work yet:

1) The files that are listed in the module map must exist on disk, in order to
   build the on-disk header -> module lookup table in the PCM file. To fix
   this, we need the preprocessed output to track the file size and other stat
   information we might use to build the lookup table.

2) Declaration ownership semantics don't work properly yet, since mapping from
   a source location to a module relies on mapping from FileIDs to modules,
   which we can't do if module transitions can occur in the middle of a file.

Modified:
cfe/trunk/include/clang/Frontend/FrontendAction.h
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Modules/preprocess-module.cpp

Modified: cfe/trunk/include/clang/Frontend/FrontendAction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendAction.h?rev=302309&r1=302308&r2=302309&view=diff
==
--- cfe/trunk/include/clang/Frontend/FrontendAction.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendAction.h Fri May  5 17:18:51 2017
@@ -146,6 +146,8 @@ public:
 return *CurrentASTUnit;
   }
 
+  Module *getCurrentModule() const;
+
   std::unique_ptr takeCurrentASTUnit() {
 return std::move(CurrentASTUnit);
   }

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=302309&r1=302308&r2=302309&view=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Fri May  5 17:18:51 2017
@@ -538,9 +538,15 @@ public:
   ///
   /// \param File The module map file.
   /// \param IsSystem Whether this file is in a system header directory.
+  /// \param ID If the module map file is already mapped (perhaps as part of
+  ///processing a preprocessed module), the ID of the file.
+  /// \param Offset [inout] An offset within ID to start parsing. On exit,
+  ///filled by the end of the parsed contents (either EOF or the
+  ///location of an end-of-module-map pragma).
   ///
   /// \returns true if an error occurred, false otherwise.
-  bool loadModuleMapFile(const FileEntry *File, bool IsSystem);
+  bool loadModuleMapFile(const FileEntry *File, bool IsSystem,
+ FileID ID = FileID(), unsigned *Offset = nullptr);
 
   /// \brief Collect the set of all known, top-level modules.
   ///
@@ -686,7 +692,9 @@ private:
 
   LoadModuleMapResult loadModuleMapFileImpl(const FileEntry *File,
 bool IsSystem,
-const DirectoryEntry *Dir);
+const DirectoryEntry *Dir,
+FileID ID = FileID(),
+unsigned *Offset = nullptr);
 
   /// \brief Try to load the module map file in the given directory.
   ///

Modified: cfe/trunk/include/clang/Lex/ModuleMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=302309&r1=302308&r2=302309&view=diff
==
--- cfe/trunk/include/clang/Lex/ModuleMap.h (original)
+++ cfe/trunk/include/clang/Lex/ModuleMap.h Fri May  5 17:18:51 2017
@@ -546,14 +546,20 @@ public:
   /// \param HomeDir The directory in which relative paths within this module
   ///map file will be resolved.
   ///
+  /// \param ID The FileID of the file to process, if we've already entered it.
+  ///
+  /// \param Offset [inout] On input the offset at which to start parsing. On

[PATCH] D32724: [Modules] Include the enabled sanitizers in the module hash

2017-05-05 Thread Sean Callanan via Phabricator via cfe-commits
spyffe requested changes to this revision.
spyffe added a comment.
This revision now requires changes to proceed.

A few minor nits, but the operation of ignoring certain sanitizer flags seems 
to be happening in the wrong place.




Comment at: lib/Basic/LangOptions.cpp:32
 
-  // FIXME: This should not be reset; modules can be different with different
-  // sanitizer options (this affects __has_feature(address_sanitizer) etc).
-  Sanitize.clear();
+  // These options do not affect AST generation.
   SanitizerBlacklistFiles.clear();

I'd replace this with
```
Sanitize.clear(SanitizerKind::CFI | SanitizerKind::Integer | 
SanitizerKind::Nullability | SanitizerKind::Undefined);
```
We know those options don't affect modules, as demonstrated by you clearing 
them anyway in CompilerInvocation...



Comment at: lib/Frontend/CompilerInvocation.cpp:2699
+  SanitizerSet SanHash = LangOpts->Sanitize;
+  SanHash.clear(SanitizerKind::CFI | SanitizerKind::Integer |
+SanitizerKind::Nullability | SanitizerKind::Undefined);

If `clearNonModularOptions()` does the right thing, you may not need to clear 
these flags here



Comment at: test/Modules/check-for-sanitizer-feature.cpp:25
+//
+// First, built without any sanitization.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.2 \

Typo: //build//



Comment at: test/Modules/check-for-sanitizer-feature.cpp:42
+#if HAS_ASAN != 1
+#error Does not have the address_sanitizer feature, but should.
+#endif

This error isn't very illuminating: I'd say
> Module doesn't have the address_sanitizer feature, but main program does.
Same below.




https://reviews.llvm.org/D32724



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


[PATCH] D32724: [Modules] Include the enabled sanitizers in the module hash

2017-05-05 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Is it the right solution to use the module hash for correctness, or should the 
mismatch of the serialized langopts trigger a module rebuild and the module 
hash is only there to tune the performance/disk size tradeoff?


https://reviews.llvm.org/D32724



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


r302312 - Permit keywords in module names in #pragma clang module *.

2017-05-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May  5 17:34:07 2017
New Revision: 302312

URL: http://llvm.org/viewvc/llvm-project?rev=302312&view=rev
Log:
Permit keywords in module names in #pragma clang module *.

This is necessary to be able to build a libc++ module from preprocessed source
(due to the submodule std.new).

Modified:
cfe/trunk/lib/Lex/Pragma.cpp
cfe/trunk/test/Preprocessor/pragma_module.c

Modified: cfe/trunk/lib/Lex/Pragma.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=302312&r1=302311&r2=302312&view=diff
==
--- cfe/trunk/lib/Lex/Pragma.cpp (original)
+++ cfe/trunk/lib/Lex/Pragma.cpp Fri May  5 17:34:07 2017
@@ -1307,7 +1307,7 @@ static bool LexModuleName(
 &ModuleName) {
   while (true) {
 PP.LexUnexpandedToken(Tok);
-if (Tok.isNot(tok::identifier)) {
+if (Tok.isAnnotation() || !Tok.getIdentifierInfo()) {
   PP.Diag(Tok.getLocation(), diag::err_pp_expected_module_name)
 << ModuleName.empty();
   return true;

Modified: cfe/trunk/test/Preprocessor/pragma_module.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/pragma_module.c?rev=302312&r1=302311&r2=302312&view=diff
==
--- cfe/trunk/test/Preprocessor/pragma_module.c (original)
+++ cfe/trunk/test/Preprocessor/pragma_module.c Fri May  5 17:34:07 2017
@@ -1,13 +1,14 @@
 // RUN: rm -rf %t
 // RUN: mkdir %t
-// RUN: echo 'module foo { module a {} module b {} } module bar {}' > 
%t/module.map
-// RUN: %clang -cc1 -E -fmodules %s -verify -fmodule-name=foo 
-fmodule-map-file=%t/module.map
-// RUN: %clang -cc1 -E -fmodules %s -verify -fmodule-name=foo 
-fmodule-map-file=%t/module.map -fmodules-local-submodule-visibility -DLOCAL_VIS
+// RUN: echo 'module foo { module a {} module b {} } module bar {} module if 
{}' > %t/module.map
+// RUN: %clang -cc1 -fmodules -fmodule-name=if -x c %t/module.map -emit-module 
-o %t/if.pcm
+// RUN: %clang -cc1 -E -fmodules %s -fmodule-file=%t/if.pcm -verify 
-fmodule-name=foo -fmodule-map-file=%t/module.map
+// RUN: %clang -cc1 -E -fmodules %s -fmodule-file=%t/if.pcm -verify 
-fmodule-name=foo -fmodule-map-file=%t/module.map 
-fmodules-local-submodule-visibility -DLOCAL_VIS
 
 // Just checking the syntax here; the semantics are tested elsewhere.
 #pragma clang module import // expected-error {{expected module name}}
 #pragma clang module import ! // expected-error {{expected module name}}
-#pragma clang module import if // expected-error {{expected module name}}
+#pragma clang module import if // ok
 #pragma clang module import foo ? bar // expected-warning {{extra tokens at 
end of #pragma}}
 #pragma clang module import foo. // expected-error {{expected identifier after 
'.' in module name}}
 #pragma clang module import foo.bar.baz.quux // expected-error {{no submodule 
named 'bar' in module 'foo'}}


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


[PATCH] D32923: [clang-tidy] Use cxxStdInitializerListExpr in modernize-use-emplace

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

LGTM!


Repository:
  rL LLVM

https://reviews.llvm.org/D32923



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


r302313 - AArch64: fix weird edge case in ABI.

2017-05-05 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Fri May  5 17:36:06 2017
New Revision: 302313

URL: http://llvm.org/viewvc/llvm-project?rev=302313&view=rev
Log:
AArch64: fix weird edge case in ABI.

It turns out there are some sort-of-but-not-quite empty structs that break all
the rules. For example:

struct SuperEmpty { int arr[0]; };
struct SortOfEmpty { struct SuperEmpty e; };

Both of these have sizeof == 0, even in C++ mode, for GCC compatibility. The
first one also doesn't occupy a register when passed by value in GNU C++ mode,
unlike everything else.

On Darwin, we want to ignore the lot (and especially don't want to try to use
an i0 as we were).

Added:
cfe/trunk/test/CodeGen/aarch64-args.cpp
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=302313&r1=302312&r2=302313&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri May  5 17:36:06 2017
@@ -4890,10 +4890,16 @@ ABIArgInfo AArch64ABIInfo::classifyArgum
 
   // Empty records are always ignored on Darwin, but actually passed in C++ 
mode
   // elsewhere for GNU compatibility.
-  if (isEmptyRecord(getContext(), Ty, true)) {
+  uint64_t Size = getContext().getTypeSize(Ty);
+  bool IsEmpty = isEmptyRecord(getContext(), Ty, true);
+  if (IsEmpty || Size == 0) {
 if (!getContext().getLangOpts().CPlusPlus || isDarwinPCS())
   return ABIArgInfo::getIgnore();
 
+// GNU C mode. The only argument that gets ignored is an empty one with 
size
+// 0.
+if (IsEmpty && Size == 0)
+  return ABIArgInfo::getIgnore();
 return ABIArgInfo::getDirect(llvm::Type::getInt8Ty(getVMContext()));
   }
 
@@ -4906,7 +4912,6 @@ ABIArgInfo AArch64ABIInfo::classifyArgum
   }
 
   // Aggregates <= 16 bytes are passed directly in registers or on the stack.
-  uint64_t Size = getContext().getTypeSize(Ty);
   if (Size <= 128) {
 // On RenderScript, coerce Aggregates <= 16 bytes to an integer array of
 // same size and alignment.
@@ -4946,7 +4951,8 @@ ABIArgInfo AArch64ABIInfo::classifyRetur
 : ABIArgInfo::getDirect());
   }
 
-  if (isEmptyRecord(getContext(), RetTy, true))
+  uint64_t Size = getContext().getTypeSize(RetTy);
+  if (isEmptyRecord(getContext(), RetTy, true) || Size == 0)
 return ABIArgInfo::getIgnore();
 
   const Type *Base = nullptr;
@@ -4956,7 +4962,6 @@ ABIArgInfo AArch64ABIInfo::classifyRetur
 return ABIArgInfo::getDirect();
 
   // Aggregates <= 16 bytes are returned directly in registers or on the stack.
-  uint64_t Size = getContext().getTypeSize(RetTy);
   if (Size <= 128) {
 // On RenderScript, coerce Aggregates <= 16 bytes to an integer array of
 // same size and alignment.

Added: cfe/trunk/test/CodeGen/aarch64-args.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-args.cpp?rev=302313&view=auto
==
--- cfe/trunk/test/CodeGen/aarch64-args.cpp (added)
+++ cfe/trunk/test/CodeGen/aarch64-args.cpp Fri May  5 17:36:06 2017
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios7.0 -target-abi darwinpcs -emit-llvm 
-o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - -x c %s | 
FileCheck %s --check-prefix=CHECK-GNU-C
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck %s 
--check-prefix=CHECK-GNU-CXX
+
+// Empty structs are ignored for PCS purposes on Darwin and in C mode 
elsewhere.
+// In C++ mode on ELF they consume a register slot though. Functions are
+// slightly bigger than minimal to make confirmation against actual GCC
+// behaviour easier.
+
+#if __cplusplus
+#define EXTERNC extern "C"
+#else
+#define EXTERNC
+#endif
+
+struct Empty {};
+
+// CHECK: define i32 @empty_arg(i32 %a)
+// CHECK-GNU-C: define i32 @empty_arg(i32 %a)
+// CHECK-GNU-CXX: define i32 @empty_arg(i8 %e.coerce, i32 %a)
+EXTERNC int empty_arg(struct Empty e, int a) {
+  return a;
+}
+
+// CHECK: define void @empty_ret()
+// CHECK-GNU-C: define void @empty_ret()
+// CHECK-GNU-CXX: define void @empty_ret()
+EXTERNC struct Empty empty_ret() {
+  struct Empty e;
+  return e;
+}
+
+// However, what counts as "empty" is a baroque mess. This is super-empty, it's
+// ignored even in C++ mode. It also has sizeof == 0, violating C++, but that's
+// legacy for you:
+
+struct SuperEmpty {
+  int arr[0];
+};
+
+// CHECK: define i32 @super_empty_arg(i32 %a)
+// CHECK-GNU-C: define i32 @super_empty_arg(i32 %a)
+// CHECK-GNU-CXX: define i32 @super_empty_arg(i32 %a)
+EXTERNC int super_empty_arg(struct SuperEmpty e, int a) {
+  return a;
+}
+
+// This is not empty. It has 0 size but consumes a register slot for GCC.
+
+struct SortOfEmpty {
+  struct SuperEmpty e;
+};
+
+// CHECK: define i32 @sort_of_empty_arg(i32 %a)
+// CHECK-GNU-C: defin

[PATCH] D32923: [clang-tidy] Use cxxStdInitializerListExpr in modernize-use-emplace

2017-05-05 Thread Jakub Kuderski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302317: [clang-tidy] Use cxxStdInitializerListExpr in 
modernize-use-emplace (authored by kuhar).

Changed prior to commit:
  https://reviews.llvm.org/D32923?vs=98024&id=98034#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32923

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp


Index: clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
@@ -20,12 +20,6 @@
   return Node.hasExplicitTemplateArgs();
 }
 
-namespace impl {
-// FIXME: This matcher should be replaced by a matcher from ASTMatcher.h
-const ast_matchers::internal::VariadicDynCastAllOfMatcher cxxStdInitializerListExpr;
-} // namespace impl
-
 const auto DefaultContainersWithPushBack =
 "::std::vector; ::std::list; ::std::deque";
 const auto DefaultSmartPointers =
@@ -81,9 +75,7 @@
   auto IsPrivateCtor = hasDeclaration(cxxConstructorDecl(isPrivate()));
 
   auto HasInitList = anyOf(has(ignoringImplicit(initListExpr())),
-   has(impl::cxxStdInitializerListExpr()));
-  // FIXME: Replace internal C++ initializer list matcher with one from
-  // ASTMatchers.h
+   has(cxxStdInitializerListExpr()));
 
   // FIXME: Discard 0/NULL (as nullptr), static inline const data members,
   // overloaded functions and template names.


Index: clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
@@ -20,12 +20,6 @@
   return Node.hasExplicitTemplateArgs();
 }
 
-namespace impl {
-// FIXME: This matcher should be replaced by a matcher from ASTMatcher.h
-const ast_matchers::internal::VariadicDynCastAllOfMatcher cxxStdInitializerListExpr;
-} // namespace impl
-
 const auto DefaultContainersWithPushBack =
 "::std::vector; ::std::list; ::std::deque";
 const auto DefaultSmartPointers =
@@ -81,9 +75,7 @@
   auto IsPrivateCtor = hasDeclaration(cxxConstructorDecl(isPrivate()));
 
   auto HasInitList = anyOf(has(ignoringImplicit(initListExpr())),
-   has(impl::cxxStdInitializerListExpr()));
-  // FIXME: Replace internal C++ initializer list matcher with one from
-  // ASTMatchers.h
+   has(cxxStdInitializerListExpr()));
 
   // FIXME: Discard 0/NULL (as nullptr), static inline const data members,
   // overloaded functions and template names.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r302317 - [clang-tidy] Use cxxStdInitializerListExpr in modernize-use-emplace

2017-05-05 Thread Jakub Kuderski via cfe-commits
Author: kuhar
Date: Fri May  5 18:00:37 2017
New Revision: 302317

URL: http://llvm.org/viewvc/llvm-project?rev=302317&view=rev
Log:
[clang-tidy] Use cxxStdInitializerListExpr in modernize-use-emplace

Summary: Use the cxxStdInitializerListExp matcher from ASTMatchers.h instead of 
a local one.

Reviewers: aaron.ballman, alexfh, Prazek

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang-tools-extra

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp?rev=302317&r1=302316&r2=302317&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp Fri May  5 
18:00:37 2017
@@ -20,12 +20,6 @@ AST_MATCHER(DeclRefExpr, hasExplicitTemp
   return Node.hasExplicitTemplateArgs();
 }
 
-namespace impl {
-// FIXME: This matcher should be replaced by a matcher from ASTMatcher.h
-const ast_matchers::internal::VariadicDynCastAllOfMatcher cxxStdInitializerListExpr;
-} // namespace impl
-
 const auto DefaultContainersWithPushBack =
 "::std::vector; ::std::list; ::std::deque";
 const auto DefaultSmartPointers =
@@ -81,9 +75,7 @@ void UseEmplaceCheck::registerMatchers(M
   auto IsPrivateCtor = hasDeclaration(cxxConstructorDecl(isPrivate()));
 
   auto HasInitList = anyOf(has(ignoringImplicit(initListExpr())),
-   has(impl::cxxStdInitializerListExpr()));
-  // FIXME: Replace internal C++ initializer list matcher with one from
-  // ASTMatchers.h
+   has(cxxStdInitializerListExpr()));
 
   // FIXME: Discard 0/NULL (as nullptr), static inline const data members,
   // overloaded functions and template names.


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


[libcxx] r302318 - [libcxx] [test] Be compatible with LWG 2438 "std::iterator inheritance shouldn't be mandated".

2017-05-05 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Fri May  5 18:01:38 2017
New Revision: 302318

URL: http://llvm.org/viewvc/llvm-project?rev=302318&view=rev
Log:
[libcxx] [test] Be compatible with LWG 2438 "std::iterator inheritance 
shouldn't be mandated".

In C++17, these iterators are allowed but not required
to inherit from the deprecated std::iterator base class.

Fixes D32727.

Modified:

libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp

libcxx/trunk/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp

libcxx/trunk/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp

Modified: 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp?rev=302318&r1=302317&r2=302318&view=diff
==
--- 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp
 Fri May  5 18:01:38 2017
@@ -40,12 +40,22 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 typedef std::istream_iterator I1; // double is trivially 
destructible
+#if TEST_STD_VER <= 14
 static_assert((std::is_convertible >::value), "");
+#else
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), 
"");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+#endif
 static_assert((std::is_same::value), "");
 static_assert((std::is_same 
>::value), "");
 static_assert((std::is_same::value), "");
@@ -53,9 +63,17 @@ int main()
 static_assert( std::is_trivially_destructible::value, "");
 
 typedef std::istream_iterator I2; // unsigned is 
trivially destructible
+#if TEST_STD_VER <= 14
 static_assert((std::is_convertible >::value), "");
+#else
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), 
"");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+#endif
 static_assert((std::is_same::value), "");
 static_assert((std::is_same 
>::value), "");
 static_assert((std::is_same::value), "");

Modified: 
libcxx/trunk/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp?rev=302318&r1=302317&r2=302318&view=diff
==
--- 
libcxx/trunk/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
 Fri May  5 18:01:38 2017
@@ -23,17 +23,35 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 typedef std::ostream_iterator I1;
+#if TEST_STD_VER <= 14
 static_assert((std::is_convertible 
>::value), "");
+#else
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+#endif
 static_assert((std::is_same::value), "");
 static_assert((std::is_same 
>::value), "");
 static_assert((std::is_same::value), "");
 typedef std::ostream_iterator I2;
+#if TEST_STD_VER <= 14
 static_assert((std::is_convertible 
>::value), "");
+#else
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+#endif
 static_assert((std::is_same::value), "");
 static_assert((std::is_same 
>::value), "");
 static_assert((std::is_same::value), "");

Modified: 
libcxx/trunk/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp?rev=302318&r1=302317&r2=302318&view=diff
==
--- 
libcxx/trunk/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
 Fri May  5 18:01:38 2017
@@ -24,19 +24,37 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 typedef std::ostreambuf_iterator I1;
+#if TEST_STD_VER <= 14
 static_assert((std::is_convertible 
>::value), "");
+#else
+static_assert((std::is_same::value), "");
+static_assert((std::is_same::value), "");
+   

[PATCH] D32727: [libcxx] [test] Be compatible with LWG 2438 "std::iterator inheritance shouldn't be mandated".

2017-05-05 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT closed this revision.
STL_MSFT added a comment.

Committed with requested changes.


https://reviews.llvm.org/D32727



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


  1   2   >