[PATCH] D32959: Add -target option when clang is invoked to check syntax

2017-05-08 Thread Kazuhiro Yabe via Phabricator via cfe-commits
kazuhiro.yabe created this revision.
Herald added subscribers: rengolin, aemerson.

Dear all,

This patch adds the '-target' option to the clang option to invoke to
check the syntax when scan-build is called with the --analyzer-target
option.

I'm using scan-build in cross compile project. (target: armv7-a)
Even when cross compiling, scan-build invokes clang with -triple (HOST
ARCH) to check syntax.
Therefore, if my code has some errors, clang reports error in syntax checking:

error: unknown target CPU 'armv7-a'

This patch fixes that issue.

Thanks.


https://reviews.llvm.org/D32959

Files:
  tools/scan-build/libexec/ccc-analyzer


Index: tools/scan-build/libexec/ccc-analyzer
===
--- tools/scan-build/libexec/ccc-analyzer
+++ tools/scan-build/libexec/ccc-analyzer
@@ -224,6 +224,10 @@
   else {
 $Cmd = $Clang;
 
+if (defined $AnalyzerTarget) {
+  push @Args, "-target", $AnalyzerTarget;
+}
+
 # Create arguments for doing regular parsing.
 my $SyntaxArgs = GetCCArgs($HtmlDir, "-fsyntax-only", \@Args);
 @CmdArgsSansAnalyses = @$SyntaxArgs;
@@ -248,10 +252,6 @@
   push @Args, "-Xclang", "-analyzer-viz-egraph-ubigraph";
 }
 
-if (defined $AnalyzerTarget) {
-  push @Args, "-target", $AnalyzerTarget;
-}
-
 my $AnalysisArgs = GetCCArgs($HtmlDir, "--analyze", \@Args);
 @CmdArgs = @$AnalysisArgs;
   }


Index: tools/scan-build/libexec/ccc-analyzer
===
--- tools/scan-build/libexec/ccc-analyzer
+++ tools/scan-build/libexec/ccc-analyzer
@@ -224,6 +224,10 @@
   else {
 $Cmd = $Clang;
 
+if (defined $AnalyzerTarget) {
+  push @Args, "-target", $AnalyzerTarget;
+}
+
 # Create arguments for doing regular parsing.
 my $SyntaxArgs = GetCCArgs($HtmlDir, "-fsyntax-only", \@Args);
 @CmdArgsSansAnalyses = @$SyntaxArgs;
@@ -248,10 +252,6 @@
   push @Args, "-Xclang", "-analyzer-viz-egraph-ubigraph";
 }
 
-if (defined $AnalyzerTarget) {
-  push @Args, "-target", $AnalyzerTarget;
-}
-
 my $AnalysisArgs = GetCCArgs($HtmlDir, "--analyze", \@Args);
 @CmdArgs = @$AnalysisArgs;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30018: [XRay] Add __xray_customeevent(...) as a clang-supported builtin

2017-05-08 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris added inline comments.



Comment at: lib/Headers/xrayintrin.h:28
+extern "C" {
+inline void __xray_customevent(const char*, size_t) {
+  // Does nothing by design. The intent is the compiler's back-end will handle

rnk wrote:
> I don't think you need this header. Also, the extern "C" would have to be 
> guarded on __cplusplus.
Reverted the file.


https://reviews.llvm.org/D30018



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


[PATCH] D30018: [XRay] Add __xray_customeevent(...) as a clang-supported builtin

2017-05-08 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris updated this revision to Diff 98129.
dberris marked 6 inline comments as done.
dberris added a comment.

Address comments.


https://reviews.llvm.org/D30018

Files:
  include/clang/Basic/Builtins.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/xray-customevent.cpp


Index: test/CodeGen/xray-customevent.cpp
===
--- /dev/null
+++ test/CodeGen/xray-customevent.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fxray-instrument -x c++ -std=c++11 -triple 
x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: @_Z16alwaysInstrumentv
+[[clang::xray_always_instrument]] void alwaysInstrument() {
+  static constexpr char kPhase[] = "instrument";
+  __xray_customevent(kPhase, 10);
+  // CHECK: call void @llvm.xray.customevent(i8*{{.*}}, i32 10)
+}
+
+// CHECK-LABEL: @_Z15neverInstrumentv
+[[clang::xray_never_instrument]] void neverInstrument() {
+  static constexpr char kPhase[] = "never";
+  __xray_customevent(kPhase, 5);
+  // CHECK-NOT: call void @llvm.xray.customevent(i8*{{.*}}, i32 5)
+}
+
+// CHECK-LABEL: @_Z21conditionalInstrumenti
+[[clang::xray_always_instrument]] void conditionalInstrument(int v) {
+  static constexpr char kTrue[] = "true";
+  static constexpr char kUntrue[] = "untrue";
+  if (v % 2)
+__xray_customevent(kTrue, 4);
+  else
+__xray_customevent(kUntrue, 6);
+
+  // CHECK: call void @llvm.xray.customevent(i8*{{.*}}, i32 4)
+  // CHECK: call void @llvm.xray.customevent(i8*{{.*}}, i32 6)
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -2769,6 +2769,32 @@
 return RValue::get(ConstantInt::get(ConvertType(E->getType()),
 Layout.size().getQuantity()));
   }
+  case Builtin::BI__xray_customevent: {
+if (!ShouldXRayInstrumentFunction())
+  return RValue::getIgnored();
+if (const auto *XRayAttr =
+this->CurFuncDecl->getAttr()) {
+  if (XRayAttr->neverXRayInstrument())
+return RValue::getIgnored();
+}
+Function *F = CGM.getIntrinsic(Intrinsic::xray_customevent);
+auto FTy = F->getFunctionType();
+auto Arg0 = E->getArg(0);
+auto Arg0Val = EmitScalarExpr(Arg0);
+auto Arg0Ty = Arg0->getType();
+auto PTy0 = FTy->getParamType(0);
+if (PTy0 != Arg0Val->getType()) {
+  if (Arg0Ty->isArrayType())
+Arg0Val = EmitArrayToPointerDecay(Arg0).getPointer();
+  else
+Arg0Val = Builder.CreatePointerCast(Arg0Val, PTy0);
+}
+auto Arg1 = EmitScalarExpr(E->getArg(1));
+auto PTy1 = FTy->getParamType(1);
+if (PTy1 != Arg1->getType())
+  Arg1 = Builder.CreateTruncOrBitCast(Arg1, PTy1);
+return RValue::get(Builder.CreateCall(F, {Arg0Val, Arg1}));
+  }
   }
 
   // If this is an alias for a lib function (e.g. __builtin_sin), emit
Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -1409,6 +1409,9 @@
 BUILTIN(__builtin_os_log_format_buffer_size, "zcC*.", "p:0:nut")
 BUILTIN(__builtin_os_log_format, "v*v*cC*.", "p:0:nt")
 
+// Builtins for XRay
+BUILTIN(__xray_customevent, "vcC*z", "")
+
 #undef BUILTIN
 #undef LIBBUILTIN
 #undef LANGBUILTIN


Index: test/CodeGen/xray-customevent.cpp
===
--- /dev/null
+++ test/CodeGen/xray-customevent.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fxray-instrument -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: @_Z16alwaysInstrumentv
+[[clang::xray_always_instrument]] void alwaysInstrument() {
+  static constexpr char kPhase[] = "instrument";
+  __xray_customevent(kPhase, 10);
+  // CHECK: call void @llvm.xray.customevent(i8*{{.*}}, i32 10)
+}
+
+// CHECK-LABEL: @_Z15neverInstrumentv
+[[clang::xray_never_instrument]] void neverInstrument() {
+  static constexpr char kPhase[] = "never";
+  __xray_customevent(kPhase, 5);
+  // CHECK-NOT: call void @llvm.xray.customevent(i8*{{.*}}, i32 5)
+}
+
+// CHECK-LABEL: @_Z21conditionalInstrumenti
+[[clang::xray_always_instrument]] void conditionalInstrument(int v) {
+  static constexpr char kTrue[] = "true";
+  static constexpr char kUntrue[] = "untrue";
+  if (v % 2)
+__xray_customevent(kTrue, 4);
+  else
+__xray_customevent(kUntrue, 6);
+
+  // CHECK: call void @llvm.xray.customevent(i8*{{.*}}, i32 4)
+  // CHECK: call void @llvm.xray.customevent(i8*{{.*}}, i32 6)
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -2769,6 +2769,32 @@
 return RValue::get(ConstantInt::get(ConvertType(E->getType()),
 Layout.size().getQuantity()));
   }
+  case Builtin::BI__xray_customevent: {
+if (!Should

r302411 - [OpenCL] Check that global samplers are const

2017-05-08 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Mon May  8 04:29:06 2017
New Revision: 302411

URL: http://llvm.org/viewvc/llvm-project?rev=302411&view=rev
Log:
[OpenCL] Check that global samplers are const

Patch by Simon Perretta.

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


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

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=302411&r1=302410&r2=302411&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon May  8 04:29:06 
2017
@@ -8305,6 +8305,8 @@ def err_sampler_argument_required : Erro
   "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<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=302411&r1=302410&r2=302411&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon May  8 04:29:06 2017
@@ -6070,12 +6070,24 @@ NamedDecl *Sema::ActOnVariableDeclarator
   }
 }
 
-// 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:

Modified: cfe/trunk/test/SemaOpenCL/sampler_t.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/sampler_t.cl?rev=302411&r1=302410&r2=302411&view=diff
==
--- cfe/trunk/test/SemaOpenCL/sampler_t.cl (original)
+++ cfe/trunk/test/SemaOpenCL/sampler_t.cl Mon May  8 04:29:06 2017
@@ -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 @@ constant struct sampler_s {
 
 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 
__loca

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

2017-05-08 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302411: [OpenCL] Check that global samplers are const 
(authored by svenvh).

Changed prior to commit:
  https://reviews.llvm.org/D32856?vs=97959&id=98143#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32856

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


Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/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: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8305,6 +8305,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: cfe/trunk/test/SemaOpenCL/sampler_t.cl
===
--- cfe/trunk/test/SemaOpenCL/sampler_t.cl
+++ cfe/trunk/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: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/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.getAdd

[PATCH] D32770: [X86][LWP] Add clang support for LWP instructions.

2017-05-08 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

ping? llvm support landed at https://reviews.llvm.org/rL302041


Repository:
  rL LLVM

https://reviews.llvm.org/D32770



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


[PATCH] D32770: [X86][LWP] Add clang support for LWP instructions.

2017-05-08 Thread Andrea Di Biagio via Phabricator via cfe-commits
andreadb accepted this revision.
andreadb added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rL LLVM

https://reviews.llvm.org/D32770



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


r302418 - [X86][LWP] Add clang support for LWP instructions.

2017-05-08 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Mon May  8 07:09:45 2017
New Revision: 302418

URL: http://llvm.org/viewvc/llvm-project?rev=302418&view=rev
Log:
[X86][LWP] Add clang support for LWP instructions.

This patch adds support for the the LightWeight Profiling (LWP) instructions 
which are available on all AMD Bulldozer class CPUs (bdver1 to bdver4).

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

Added:
cfe/trunk/lib/Headers/lwpintrin.h   (with props)
cfe/trunk/test/CodeGen/lwp-builtins.c   (with props)
Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/include/clang/Basic/BuiltinsX86_64.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/lib/Headers/x86intrin.h

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=302418&r1=302417&r2=302418&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon May  8 07:09:45 2017
@@ -668,6 +668,12 @@ TARGET_BUILTIN(__builtin_ia32_pext_si, "
 // TBM
 TARGET_BUILTIN(__builtin_ia32_bextri_u32, "UiUiIUi", "", "tbm")
 
+// LWP
+TARGET_BUILTIN(__builtin_ia32_llwpcb, "vv*", "", "lwp")
+TARGET_BUILTIN(__builtin_ia32_slwpcb, "v*", "", "lwp")
+TARGET_BUILTIN(__builtin_ia32_lwpins32, "UcUiUiUi", "", "lwp")
+TARGET_BUILTIN(__builtin_ia32_lwpval32, "vUiUiUi", "", "lwp")
+
 // SHA
 TARGET_BUILTIN(__builtin_ia32_sha1rnds4, "V4iV4iV4iIc", "", "sha")
 TARGET_BUILTIN(__builtin_ia32_sha1nexte, "V4iV4iV4i", "", "sha")

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86_64.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86_64.def?rev=302418&r1=302417&r2=302418&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86_64.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86_64.def Mon May  8 07:09:45 2017
@@ -69,6 +69,8 @@ TARGET_BUILTIN(__builtin_ia32_bzhi_di, "
 TARGET_BUILTIN(__builtin_ia32_pdep_di, "ULLiULLiULLi", "", "bmi2")
 TARGET_BUILTIN(__builtin_ia32_pext_di, "ULLiULLiULLi", "", "bmi2")
 TARGET_BUILTIN(__builtin_ia32_bextri_u64, "ULLiULLiIULLi", "", "tbm")
+TARGET_BUILTIN(__builtin_ia32_lwpins64, "UcULLiUiUi", "", "lwp")
+TARGET_BUILTIN(__builtin_ia32_lwpval64, "vULLiUiUi", "", "lwp")
 TARGET_BUILTIN(__builtin_ia32_pbroadcastq512_gpr_mask, "V8LLiLLiV8LLiUc", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_pbroadcastq128_gpr_mask, 
"V2LLiULLiV2LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pbroadcastq256_gpr_mask, 
"V4LLiULLiV4LLiUc","","avx512vl")

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=302418&r1=302417&r2=302418&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon May  8 07:09:45 2017
@@ -1752,6 +1752,7 @@ def mno_bmi : Flag<["-"], "mno-bmi">, Gr
 def mno_bmi2 : Flag<["-"], "mno-bmi2">, Group;
 def mno_popcnt : Flag<["-"], "mno-popcnt">, Group;
 def mno_tbm : Flag<["-"], "mno-tbm">, Group;
+def mno_lwp : Flag<["-"], "mno-lwp">, Group;
 def mno_fma4 : Flag<["-"], "mno-fma4">, Group;
 def mno_fma : Flag<["-"], "mno-fma">, Group;
 def mno_xop : Flag<["-"], "mno-xop">, Group;
@@ -1951,6 +1952,7 @@ def mbmi : Flag<["-"], "mbmi">, Group, Group;
 def mpopcnt : Flag<["-"], "mpopcnt">, Group;
 def mtbm : Flag<["-"], "mtbm">, Group;
+def mlwp : Flag<["-"], "mlwp">, Group;
 def mfma4 : Flag<["-"], "mfma4">, Group;
 def mfma : Flag<["-"], "mfma">, Group;
 def mxop : Flag<["-"], "mxop">, Group;

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=302418&r1=302417&r2=302418&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon May  8 07:09:45 2017
@@ -2591,6 +2591,7 @@ class X86TargetInfo : public TargetInfo
   bool HasRDSEED = false;
   bool HasADX = false;
   bool HasTBM = false;
+  bool HasLWP = false;
   bool HasFMA = false;
   bool HasF16C = false;
   bool HasAVX512CD = false;
@@ -3363,6 +3364,7 @@ bool X86TargetInfo::initFeatureMap(
   case CK_BDVER1:
 // xop implies avx, sse4a and fma4.
 setFeatureEnabledImpl(Features, "xop", true);
+setFeatureEnabledImpl(Features, "lwp", true);
 setFeatureEnabledImpl(Features, "lzcnt", true);
 setFeatureEnabledImpl(Features, "aes", true);
 setFeatureEnabledImpl(Features, "pclmul", true);
@@ -3634,6 +3636,8 @@ bool X86TargetInfo::handleTargetFeatures
   HasADX = true;
 } else if (Feature == "+tbm") {
   HasTBM = true;

[PATCH] D32770: [X86][LWP] Add clang support for LWP instructions.

2017-05-08 Thread Simon Pilgrim via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302418: [X86][LWP] Add clang support for LWP instructions. 
(authored by RKSimon).

Changed prior to commit:
  https://reviews.llvm.org/D32770?vs=97521&id=98156#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32770

Files:
  cfe/trunk/include/clang/Basic/BuiltinsX86.def
  cfe/trunk/include/clang/Basic/BuiltinsX86_64.def
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Headers/CMakeLists.txt
  cfe/trunk/lib/Headers/lwpintrin.h
  cfe/trunk/lib/Headers/x86intrin.h
  cfe/trunk/test/CodeGen/lwp-builtins.c

Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1752,6 +1752,7 @@
 def mno_bmi2 : Flag<["-"], "mno-bmi2">, Group;
 def mno_popcnt : Flag<["-"], "mno-popcnt">, Group;
 def mno_tbm : Flag<["-"], "mno-tbm">, Group;
+def mno_lwp : Flag<["-"], "mno-lwp">, Group;
 def mno_fma4 : Flag<["-"], "mno-fma4">, Group;
 def mno_fma : Flag<["-"], "mno-fma">, Group;
 def mno_xop : Flag<["-"], "mno-xop">, Group;
@@ -1951,6 +1952,7 @@
 def mbmi2 : Flag<["-"], "mbmi2">, Group;
 def mpopcnt : Flag<["-"], "mpopcnt">, Group;
 def mtbm : Flag<["-"], "mtbm">, Group;
+def mlwp : Flag<["-"], "mlwp">, Group;
 def mfma4 : Flag<["-"], "mfma4">, Group;
 def mfma : Flag<["-"], "mfma">, Group;
 def mxop : Flag<["-"], "mxop">, Group;
Index: cfe/trunk/include/clang/Basic/BuiltinsX86_64.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsX86_64.def
+++ cfe/trunk/include/clang/Basic/BuiltinsX86_64.def
@@ -69,6 +69,8 @@
 TARGET_BUILTIN(__builtin_ia32_pdep_di, "ULLiULLiULLi", "", "bmi2")
 TARGET_BUILTIN(__builtin_ia32_pext_di, "ULLiULLiULLi", "", "bmi2")
 TARGET_BUILTIN(__builtin_ia32_bextri_u64, "ULLiULLiIULLi", "", "tbm")
+TARGET_BUILTIN(__builtin_ia32_lwpins64, "UcULLiUiUi", "", "lwp")
+TARGET_BUILTIN(__builtin_ia32_lwpval64, "vULLiUiUi", "", "lwp")
 TARGET_BUILTIN(__builtin_ia32_pbroadcastq512_gpr_mask, "V8LLiLLiV8LLiUc", "", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_pbroadcastq128_gpr_mask, "V2LLiULLiV2LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pbroadcastq256_gpr_mask, "V4LLiULLiV4LLiUc","","avx512vl")
Index: cfe/trunk/include/clang/Basic/BuiltinsX86.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def
@@ -668,6 +668,12 @@
 // TBM
 TARGET_BUILTIN(__builtin_ia32_bextri_u32, "UiUiIUi", "", "tbm")
 
+// LWP
+TARGET_BUILTIN(__builtin_ia32_llwpcb, "vv*", "", "lwp")
+TARGET_BUILTIN(__builtin_ia32_slwpcb, "v*", "", "lwp")
+TARGET_BUILTIN(__builtin_ia32_lwpins32, "UcUiUiUi", "", "lwp")
+TARGET_BUILTIN(__builtin_ia32_lwpval32, "vUiUiUi", "", "lwp")
+
 // SHA
 TARGET_BUILTIN(__builtin_ia32_sha1rnds4, "V4iV4iV4iIc", "", "sha")
 TARGET_BUILTIN(__builtin_ia32_sha1nexte, "V4iV4iV4i", "", "sha")
Index: cfe/trunk/test/CodeGen/lwp-builtins.c
===
--- cfe/trunk/test/CodeGen/lwp-builtins.c
+++ cfe/trunk/test/CodeGen/lwp-builtins.c
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +lwp -emit-llvm -o - -Wall -Werror | FileCheck %s
+
+#include 
+
+void test_llwpcb(void *ptr) {
+  // CHECK-LABEL: @test_llwpcb
+  // CHECK: call void @llvm.x86.llwpcb(i8* %{{.*}})
+  __llwpcb(ptr);
+}
+
+void* test_slwpcb() {
+  // CHECK-LABEL: @test_slwpcb
+  // CHECK: call i8* @llvm.x86.slwpcb()
+  return __slwpcb();
+}
+
+unsigned char test_lwpins32(unsigned val2, unsigned val1) {
+  // CHECK-LABEL: @test_lwpins32
+  // CHECK: call i8 @llvm.x86.lwpins32(i32
+  return __lwpins32(val2, val1, 0x01234);
+}
+
+unsigned char test_lwpins64(unsigned long long val2, unsigned val1) {
+  // CHECK-LABEL: @test_lwpins64
+  // CHECK: call i8 @llvm.x86.lwpins64(i64
+  return __lwpins64(val2, val1, 0x56789);
+}
+
+void test_lwpval32(unsigned val2, unsigned val1) {
+  // CHECK-LABEL: @test_lwpval32
+  // CHECK: call void @llvm.x86.lwpval32(i32
+  __lwpval32(val2, val1, 0x01234);
+}
+
+void test_lwpval64(unsigned long long val2, unsigned val1) {
+  // CHECK-LABEL: @test_lwpval64
+  // CHECK: call void @llvm.x86.lwpval64(i64
+  __lwpval64(val2, val1, 0xABCDEF);
+}
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -2591,6 +2591,7 @@
   bool HasRDSEED = false;
   bool HasADX = false;
   bool HasTBM = false;
+  bool HasLWP = false;
   bool HasFMA = false;
   bool HasF16C = false;
   bool HasAVX512CD = false;
@@ -3363,6 +3364,7 @@
   case CK_BDVER1:
 // xop implies avx, sse4a and fma4.
 setFeatureEnabledImpl(Features, "xop", true);
+setFeatureEnabledImpl(Features

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

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



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

alexfh wrote:
> 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.
In addition to these tests, I'd like to see a test for the following:
```
struct S {};
typedef S& SRef;

SRef operator++(SRef, int);

struct T {
  typedef T& TRef;
  
  TRef operator++(int);
};

struct U {
  typedef const U& ConstURef;
  
  ConstURef& operator++(int); // There's an extra ref shoved on here for fun.
};

struct V {
  V *operator++(int);
  V *const operator--(int);
};
```


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] D32914: Introduce Wzero-as-null-pointer-constant.

2017-05-08 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

Have you looked at the tests for clang-tidy's modernize-use-nullptr check?

I wouldn't expect to see a warning for template types:

  template
  class TemplateClass {
   public:
explicit TemplateClass(int a, T default_value = 0) {}
  };
  void IgnoreSubstTemplateType() {
TemplateClass a(1);
  }

  test/clang-tidy/modernize-use-nullptr.cpp:252:51: warning: zero as null 
pointer constant [-Wzero-as-null-pointer-constant]
explicit TemplateClass(int a, T default_value = 0) {}
^
nullptr


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] D32945: clang-tidy: add IgnoreMacros option to modernize-use-default-member-init

2017-05-08 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D32945#748250, @vmiklos wrote:

> The updated patch uses `getLocalOrGlobal()` for the new option.


Please change modernize-use-using to match.


https://reviews.llvm.org/D32945



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


r302419 - Correct the attribute spelling for guarded_var and pt_guarded_var.

2017-05-08 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon May  8 07:39:17 2017
New Revision: 302419

URL: http://llvm.org/viewvc/llvm-project?rev=302419&view=rev
Log:
Correct the attribute spelling for guarded_var and pt_guarded_var.

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=302419&r1=302418&r2=302419&view=diff
==
--- cfe/trunk/docs/ThreadSafetyAnalysis.rst (original)
+++ cfe/trunk/docs/ThreadSafetyAnalysis.rst Mon May  8 07:39:17 2017
@@ -884,11 +884,11 @@ implementation.
 
   // Deprecated.
   #define PT_GUARDED_VAR \
-THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded)
+THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_var)
 
   // Deprecated.
   #define GUARDED_VAR \
-THREAD_ANNOTATION_ATTRIBUTE__(guarded)
+THREAD_ANNOTATION_ATTRIBUTE__(guarded_var)
 
   // Replaced by REQUIRES
   #define EXCLUSIVE_LOCKS_REQUIRED(...) \


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


[libcxx] r302421 - Fix Windows tests when __config_site is present.

2017-05-08 Thread Ben Craig via cfe-commits
Author: bcraig
Date: Mon May  8 08:15:22 2017
New Revision: 302421

URL: http://llvm.org/viewvc/llvm-project?rev=302421&view=rev
Log:
Fix Windows tests when __config_site is present.
Previously, the force includes would complain about a missing _DEBUG symbol.
Now we dump macros before adding the force includes to the command line.

Modified:
libcxx/trunk/utils/libcxx/test/config.py

Modified: libcxx/trunk/utils/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=302421&r1=302420&r2=302421&view=diff
==
--- libcxx/trunk/utils/libcxx/test/config.py (original)
+++ libcxx/trunk/utils/libcxx/test/config.py Mon May  8 08:15:22 2017
@@ -1,1113 +1,1113 @@
-#===--===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is dual licensed under the MIT and the University of Illinois Open
-# Source Licenses. See LICENSE.TXT for details.
-#
-#===--===##
-
-import locale
-import os
-import platform
-import pkgutil
-import pipes
-import re
-import shlex
-import shutil
-import sys
-
-from libcxx.compiler import CXXCompiler
-from libcxx.test.target_info import make_target_info
-from libcxx.test.executor import *
-from libcxx.test.tracing import *
-import libcxx.util
-
-def loadSiteConfig(lit_config, config, param_name, env_name):
-# We haven't loaded the site specific configuration (the user is
-# probably trying to run on a test file directly, and either the site
-# configuration hasn't been created by the build system, or we are in an
-# out-of-tree build situation).
-site_cfg = lit_config.params.get(param_name,
- os.environ.get(env_name))
-if not site_cfg:
-lit_config.warning('No site specific configuration file found!'
-   ' Running the tests in the default configuration.')
-elif not os.path.isfile(site_cfg):
-lit_config.fatal(
-"Specified site configuration file does not exist: '%s'" %
-site_cfg)
-else:
-lit_config.note('using site specific configuration at %s' % site_cfg)
-ld_fn = lit_config.load_config
-
-# Null out the load_config function so that lit.site.cfg doesn't
-# recursively load a config even if it tries.
-# TODO: This is one hell of a hack. Fix it.
-def prevent_reload_fn(*args, **kwargs):
-pass
-lit_config.load_config = prevent_reload_fn
-ld_fn(config, site_cfg)
-lit_config.load_config = ld_fn
-
-class Configuration(object):
-# pylint: disable=redefined-outer-name
-def __init__(self, lit_config, config):
-self.lit_config = lit_config
-self.config = config
-self.is_windows = platform.system() == 'Windows'
-self.cxx = None
-self.cxx_is_clang_cl = None
-self.cxx_stdlib_under_test = None
-self.project_obj_root = None
-self.libcxx_src_root = None
-self.libcxx_obj_root = None
-self.cxx_library_root = None
-self.cxx_runtime_root = None
-self.abi_library_root = None
-self.link_shared = self.get_lit_bool('enable_shared', default=True)
-self.debug_build = self.get_lit_bool('debug_build',   default=False)
-self.exec_env = {}
-self.use_target = False
-self.use_system_cxx_lib = False
-self.use_clang_verify = False
-self.long_tests = None
-self.execute_external = False
-
-def get_lit_conf(self, name, default=None):
-val = self.lit_config.params.get(name, None)
-if val is None:
-val = getattr(self.config, name, None)
-if val is None:
-val = default
-return val
-
-def get_lit_bool(self, name, default=None, env_var=None):
-def check_value(value, var_name):
-if value is None:
-return default
-if isinstance(value, bool):
-return value
-if not isinstance(value, str):
-raise TypeError('expected bool or string')
-if value.lower() in ('1', 'true'):
-return True
-if value.lower() in ('', '0', 'false'):
-return False
-self.lit_config.fatal(
-"parameter '{}' should be true or false".format(var_name))
-
-conf_val = self.get_lit_conf(name)
-if env_var is not None and env_var in os.environ and \
-os.environ[env_var] is not None:
-val = os.environ[env_var]
-if conf_val is not None:
-self.lit_config.warning(
-'Environment variable %s=%s is overriding explicit '
-'--param=%s=%s' % (env_var, val, name, conf_val))
-

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

2017-05-08 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 98162.
xazax.hun added a comment.

- Added more test cases and make them pass.


https://reviews.llvm.org/D32743

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  clang-tidy/cert/PostfixOperatorCheck.cpp
  clang-tidy/cert/PostfixOperatorCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cert-dcl21-cpp.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cert-dcl21-cpp.cpp

Index: test/clang-tidy/cert-dcl21-cpp.cpp
===
--- /dev/null
+++ test/clang-tidy/cert-dcl21-cpp.cpp
@@ -0,0 +1,135 @@
+// RUN: %check_clang_tidy %s cert-dcl21-cpp %t
+
+class A {};
+
+A operator++(A &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator++' returns a non-constant object instead of a constant object type [cert-dcl21-cpp]
+// CHECK-FIXES: {{^}}const A operator++(A &, int);
+
+A operator--(A &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator--' returns a no
+// CHECK-FIXES: {{^}}const A operator--(A &, int);
+
+class B {};
+
+B &operator++(B &);
+const B operator++(B &, int);
+
+B &operator--(B &);
+const B operator--(B &, int);
+
+
+class D {
+D &operator++();
+const D operator++(int);
+
+D &operator--();
+const D operator--(int);
+};
+
+class C {
+C operator++(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator++' returns a no
+// CHECK-FIXES: {{^}}const C operator++(int);
+
+C operator--(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator--' returns a no
+// CHECK-FIXES: {{^}}const C operator--(int);
+};
+
+class E {};
+
+E &operator++(E &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator++' returns a reference instead of a constant object type [cert-dcl21-cpp]
+// CHECK-FIXES: {{^}}const E operator++(E &, int);
+
+E &operator--(E &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator--' returns a re
+// CHECK-FIXES: {{^}}const E operator--(E &, int);
+
+class G {
+G &operator++(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator++' returns a re
+// CHECK-FIXES: {{^}}const G operator++(int);
+
+G &operator--(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator--' returns a re
+// CHECK-FIXES: {{^}}const G operator--(int);
+};
+
+class F {};
+
+const F &operator++(F &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator++' returns a re
+// CHECK-FIXES: {{^}}const F operator++(F &, int);
+
+const F &operator--(F &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator--' returns a re
+// CHECK-FIXES: {{^}}const F operator--(F &, int);
+
+class H {
+const H &operator++(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator++' returns a re
+// CHECK-FIXES: {{^}}const H operator++(int);
+
+const H &operator--(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator--' returns a re
+// CHECK-FIXES: {{^}}const H operator--(int);
+};
+
+
+#define FROM_MACRO P&
+class P {
+const FROM_MACRO operator++(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator++' returns a re
+// CHECK-FIXES: {{^}}const FROM_MACRO operator++(int);
+};
+
+
+template
+class Q {
+const Q &operator++(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator++' returns a re
+// CHECK-FIXES: {{^}}const Q operator++(int);
+
+const Q &operator--(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator--' returns a re
+// CHECK-FIXES: {{^}}const Q operator--(int);
+};
+
+void foobar() {
+  Q a;
+  Q b;
+  (void)a;
+  (void)b;
+}
+
+struct S {};
+typedef S& SRef;
+
+SRef operator++(SRef, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator++' returns a re
+// CHECK-FIXES: {{^}}const S  operator++(SRef, int);
+
+struct T {
+  typedef T& TRef;
+  
+  TRef operator++(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: overloaded 'operator++' returns a re
+// CHECK-FIXES: {{^}}  const T  operator++(int);
+};
+
+struct U {
+  typedef const U& ConstURef;
+  
+  ConstURef& operator++(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: overloaded 'operator++' returns a re
+// FIXME: Insert const for the return type.
+// CHECK-FIXES: {{^}}  U  operator++(int);
+};
+
+struct V {
+  V *operator++(int);
+  V *const operator--(int);
+};
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -6,6 +6,7 @@
 .. toctree::
boost-use-to-string
cert-dcl03-c (redirects to misc-static-assert) 
+   cert-dcl21-cpp
cert-dcl50-cpp
cert-dcl54-cpp (redirects to misc-new-delete-overloads) 
cert-dcl58-cpp
Index: docs/clang-tidy/checks/cert-dcl21-cpp.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cert-dcl21-cpp.rst
@@ -0,0 +1,12 @@
+.. title:: clang-t

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

2017-05-08 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



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

aaron.ballman wrote:
> alexfh wrote:
> > 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.
> In addition to these tests, I'd like to see a test for the following:
> ```
> struct S {};
> typedef S& SRef;
> 
> SRef operator++(SRef, int);
> 
> struct T {
>   typedef T& TRef;
>   
>   TRef operator++(int);
> };
> 
> struct U {
>   typedef const U& ConstURef;
>   
>   ConstURef& operator++(int); // There's an extra ref shoved on here for fun.
> };
> 
> struct V {
>   V *operator++(int);
>   V *const operator--(int);
> };
> ```
I added those test cases.

I choose not to warn about primitive and pointer types since it makes no sense 
to make them const. Do you agree?

Unfortunately, the current fixits might use the underlying type instead of the 
typedef. Is that a blocker for this to be commited?
In same cases it is not possible to preserve the typedef, e.g. when the 
underlying type is a reference. (Or we need to insert a `std::remove_reference` 
meta call).

In one case the const is not added. This is because the underlying type is 
already const. Rewriting the fixit is not trivial, because it is not easy to 
get the source range for the whole return type. Unfortunately, 
`getReturnTypeSourceRange` ignores the qualifiers. 


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] D32759: Fix errored return value in CheckFunctionReturnType and add a fixit hint

2017-05-08 Thread Wei-Ren Chen via Phabricator via cfe-commits
chenwj added a comment.

In https://reviews.llvm.org/D32759#748007, @efriedma wrote:

> The difference between returning true and false here is just the way error 
> recovery works: when we return true, we know the type is invalid, so we 
> suppress it, and subsequent errors involving the declaration.  Example 
> (Objective-C++) where we currently print two errors:


So when we see `T->isObjCObjectType()` is true, then we should return true 
since the return type is invalid?


https://reviews.llvm.org/D32759



___
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-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



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

xazax.hun wrote:
> aaron.ballman wrote:
> > alexfh wrote:
> > > 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.
> > In addition to these tests, I'd like to see a test for the following:
> > ```
> > struct S {};
> > typedef S& SRef;
> > 
> > SRef operator++(SRef, int);
> > 
> > struct T {
> >   typedef T& TRef;
> >   
> >   TRef operator++(int);
> > };
> > 
> > struct U {
> >   typedef const U& ConstURef;
> >   
> >   ConstURef& operator++(int); // There's an extra ref shoved on here for 
> > fun.
> > };
> > 
> > struct V {
> >   V *operator++(int);
> >   V *const operator--(int);
> > };
> > ```
> I added those test cases.
> 
> I choose not to warn about primitive and pointer types since it makes no 
> sense to make them const. Do you agree?
> 
> Unfortunately, the current fixits might use the underlying type instead of 
> the typedef. Is that a blocker for this to be commited?
> In same cases it is not possible to preserve the typedef, e.g. when the 
> underlying type is a reference. (Or we need to insert a 
> `std::remove_reference` meta call).
> 
> In one case the const is not added. This is because the underlying type is 
> already const. Rewriting the fixit is not trivial, because it is not easy to 
> get the source range for the whole return type. Unfortunately, 
> `getReturnTypeSourceRange` ignores the qualifiers. 
> I choose not to warn about primitive and pointer types since it makes no 
> sense to make them const. Do you agree?

I think that's reasonable behavior, yes.

> Unfortunately, the current fixits might use the underlying type instead of 
> the typedef. Is that a blocker for this to be commited?

That's what I was wondering about. You may want to simply disable the fixit if 
the underlying type is a typedef (or alias, etc).

> In same cases it is not possible to preserve the typedef, e.g. when the 
> underlying type is a reference. (Or we need to insert a std::remove_reference 
> meta call).

Yes, I think it's a complex problem that doesn't need to be solved right now.

> In one case the const is not added. This is because the underlying type is 
> already const. Rewriting the fixit is not trivial, because it is not easy to 
> get the source range for the whole return type. Unfortunately, 
> getReturnTypeSourceRange ignores the qualifiers.

That is unfortunate, but I don't think it's a deal-breaker, either.


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] D32945: clang-tidy: add IgnoreMacros option to modernize-use-default-member-init

2017-05-08 Thread Miklos Vajna via Phabricator via cfe-commits
vmiklos updated this revision to Diff 98163.

https://reviews.llvm.org/D32945

Files:
  clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  clang-tidy/modernize/UseDefaultMemberInitCheck.h
  clang-tidy/modernize/UseUsingCheck.cpp
  docs/clang-tidy/checks/modernize-use-default-member-init.rst
  test/clang-tidy/modernize-use-default-member-init-macros.cpp
  test/clang-tidy/modernize-use-default-member-init.cpp

Index: test/clang-tidy/modernize-use-default-member-init.cpp
===
--- test/clang-tidy/modernize-use-default-member-init.cpp
+++ test/clang-tidy/modernize-use-default-member-init.cpp
@@ -380,3 +380,12 @@
 
 NegativeTemplateExisting ntei(0);
 NegativeTemplateExisting nted(0);
+
+// This resulted in a warning by default.
+#define MACRO() \
+  struct MacroS { \
+void *P; \
+MacroS() : P(nullptr) {} \
+  };
+
+MACRO();
Index: test/clang-tidy/modernize-use-default-member-init-macros.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-default-member-init-macros.cpp
@@ -0,0 +1,18 @@
+// RUN: %check_clang_tidy %s modernize-use-default-member-init %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-default-member-init.IgnoreMacros, value: 0}]}" \
+// RUN:   -- -std=c++11
+
+#define MACRO() \
+  struct S { \
+void *P; \
+S() : P(nullptr) {} \
+  };
+
+MACRO();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use default member initializer for 'P'
+
+struct S2 {
+  void *P;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use default member initializer for 'P'
+  S2() : P(nullptr) {}
+};
Index: docs/clang-tidy/checks/modernize-use-default-member-init.rst
===
--- docs/clang-tidy/checks/modernize-use-default-member-init.rst
+++ docs/clang-tidy/checks/modernize-use-default-member-init.rst
@@ -47,3 +47,8 @@
 int i = 5;
 double j = 10.0;
   };
+
+.. option:: IgnoreMacros
+
+   If this option is set to non-zero (default is `1`), the check will not warn
+   about members declared inside macros.
Index: clang-tidy/modernize/UseUsingCheck.cpp
===
--- clang-tidy/modernize/UseUsingCheck.cpp
+++ clang-tidy/modernize/UseUsingCheck.cpp
@@ -19,7 +19,7 @@
 
 UseUsingCheck::UseUsingCheck(StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  IgnoreMacros(Options.get("IgnoreMacros", true)) {}
+  IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {}
 
 void UseUsingCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus11)
Index: clang-tidy/modernize/UseDefaultMemberInitCheck.h
===
--- clang-tidy/modernize/UseDefaultMemberInitCheck.h
+++ clang-tidy/modernize/UseDefaultMemberInitCheck.h
@@ -36,6 +36,7 @@
  const CXXCtorInitializer *Init);
 
   const bool UseAssignment;
+  const bool IgnoreMacros;
 };
 
 } // namespace modernize
Index: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -139,11 +139,13 @@
 UseDefaultMemberInitCheck::UseDefaultMemberInitCheck(StringRef Name,
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  UseAssignment(Options.get("UseAssignment", 0) != 0) {}
+  UseAssignment(Options.get("UseAssignment", 0) != 0),
+  IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", 1) != 0) {}
 
 void UseDefaultMemberInitCheck::storeOptions(
 ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "UseAssignment", UseAssignment);
+  Options.store(Opts, "IgnoreMacros", IgnoreMacros);
 }
 
 void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
@@ -197,6 +199,10 @@
 const MatchFinder::MatchResult &Result, const CXXCtorInitializer *Init) {
   const FieldDecl *Field = Init->getMember();
 
+  SourceLocation StartLoc = Field->getLocStart();
+  if (StartLoc.isMacroID() && IgnoreMacros)
+return;
+
   SourceLocation FieldEnd =
   Lexer::getLocForEndOfToken(Field->getSourceRange().getEnd(), 0,
  *Result.SourceManager, getLangOpts());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32945: clang-tidy: add IgnoreMacros option to modernize-use-default-member-init

2017-05-08 Thread Miklos Vajna via Phabricator via cfe-commits
vmiklos added a comment.

In https://reviews.llvm.org/D32945#748604, @malcolm.parsons wrote:

> Please change modernize-use-using to match.


Done.


https://reviews.llvm.org/D32945



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


[clang-tools-extra] r302425 - [clang-tidy] Ignore private =deleted methods in macros.

2017-05-08 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon May  8 09:17:27 2017
New Revision: 302425

URL: http://llvm.org/viewvc/llvm-project?rev=302425&view=rev
Log:
[clang-tidy] Ignore private =deleted methods in macros.

modernize-use-equals-delete is extremely noisy in code using
DISALLOW_COPY_AND_ASSIGN-style macros and there's no easy way to automatically
fix the warning when macros are in play.

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp?rev=302425&r1=302424&r2=302425&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp Mon 
May  8 09:17:27 2017
@@ -57,13 +57,18 @@ void UseEqualsDeleteCheck::check(const M
 SourceLocation EndLoc = Lexer::getLocForEndOfToken(
 Func->getLocEnd(), 0, *Result.SourceManager, getLangOpts());
 
-// FIXME: Improve FixItHint to make method public
+// FIXME: Improve FixItHint to make the method public.
 diag(Func->getLocation(),
  "use '= delete' to prohibit calling of a special member function")
 << FixItHint::CreateInsertion(EndLoc, " = delete");
   } else if (const auto *Func =
  Result.Nodes.getNodeAs(DeletedNotPublic)) {
-// FIXME: Add FixItHint to make method public
+// Ignore this warning in macros, since it's extremely noisy in code using
+// DISALLOW_COPY_AND_ASSIGN-style macros and there's no easy way to
+// automatically fix the warning when macros are in play.
+if (Func->getLocation().isMacroID())
+  return;
+// FIXME: Add FixItHint to make the method public.
 diag(Func->getLocation(), "deleted member function should be public");
   }
 }

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp?rev=302425&r1=302424&r2=302425&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp Mon 
May  8 09:17:27 2017
@@ -158,3 +158,30 @@ struct PublicDeleted {
 public:
   PublicDeleted(const PublicDeleted &) = delete;
 };
+
+#define M1 \
+  struct PrivateDeletedMacro { \
+  private: \
+PrivateDeletedMacro(const PrivateDeletedMacro &) = delete; \
+  };   \
+  struct ProtectedDeletedMacro {   \
+  protected:   \
+ProtectedDeletedMacro(const ProtectedDeletedMacro &) = delete; \
+  }
+
+M1;
+
+#define DISALLOW_COPY_AND_ASSIGN(name) \
+  name(const name &) = delete; \
+  void operator=(const name &) = delete
+
+struct PrivateDeletedMacro2 {
+private:
+  DISALLOW_COPY_AND_ASSIGN(PrivateDeletedMacro2);
+};
+
+struct ProtectedDeletedMacro2 {
+protected:
+  DISALLOW_COPY_AND_ASSIGN(ProtectedDeletedMacro2);
+};
+


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


[PATCH] D32945: clang-tidy: add IgnoreMacros option to modernize-use-default-member-init

2017-05-08 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons accepted this revision.
malcolm.parsons added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D32945



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


r302428 - [clang-format] Convert AlignEscapedNewlinesLeft to an enum, adding

2017-05-08 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon May  8 10:08:00 2017
New Revision: 302428

URL: http://llvm.org/viewvc/llvm-project?rev=302428&view=rev
Log:
[clang-format] Convert AlignEscapedNewlinesLeft to an enum, adding
DontAlign

This converts the clang-format option AlignEscapedNewlinesLeft from a
boolean to an enum, named AlignEscapedNewlines, with options Left (prev.
true), Right (prev. false), and a new option DontAlign.

When set to DontAlign, the backslashes are placed just after the last token in 
each line:
  #define EXAMPLE \
do { \
int x = a; \
int b; \
int dd; \
} while (0)

Patch by jtbandes. Thank you!

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/WhitespaceManager.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
cfe/trunk/unittests/Format/FormatTestSelective.cpp

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=302428&r1=302427&r2=302428&view=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Mon May  8 10:08:00 2017
@@ -209,23 +209,45 @@ the configuration (without a prefix: ``A
 float   b = 23;
 std::string ccc = 23;
 
-**AlignEscapedNewlinesLeft** (``bool``)
-  If ``true``, aligns escaped newlines as far left as possible.
-  Otherwise puts them into the right-most column.
+**AlignEscapedNewlines** (``EscapedNewlineAlignmentStyle``)
+  Options for aligning backslashes in escaped newlines.
 
-  .. code-block:: c++
+  Possible values:
+
+  * ``ENAS_DontAlign`` (in configuration: ``DontAlign``)
+Don't align escaped newlines.
+
+.. code-block:: c++
+
+  #define A \
+int ; \
+int b; \
+int dd;
+
+  * ``ENAS_Left`` (in configuration: ``Left``)
+Align escaped newlines as far left as possible.
+
+.. code-block:: c++
+
+  true:
+  #define A   \
+int ; \
+int b;\
+int dd;
+
+  false:
+
+  * ``ENAS_Right`` (in configuration: ``Right``)
+Align escaped newlines in the right-most column.
+
+.. code-block:: c++
+
+  #define A
  \
+int ;  
  \
+int b; 
  \
+int dd;
 
-true:
-#define A   \
-  int ; \
-  int b;\
-  int dd;
 
-false:
-#define A  
\
-  int ;
\
-  int b;   
\
-  int dd;
 
 **AlignOperands** (``bool``)
   If ``true``, horizontally align operands of binary and ternary
@@ -1525,7 +1547,7 @@ the configuration (without a prefix: ``A
 Use C++03-compatible syntax.
 
   * ``LS_Cpp11`` (in configuration: ``Cpp11``)
-Use features of C++11, C++14 and C++1z (e.g. ``A>`` instead of 
+Use features of C++11, C++14 and C++1z (e.g. ``A>`` instead of
 ``A >``).
 
   * ``LS_Auto`` (in configuration: ``Auto``)

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=302428&r1=302427&r2=302428&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Mon May  8 10:08:00 2017
@@ -98,22 +98,39 @@ struct FormatStyle {
   /// \endcode
   bool AlignConsecutiveDeclarations;
 
-  /// \brief If ``true``, aligns escaped newlines as far left as possible.
-  /// Otherwise puts them into the right-most column.
-  /// \code
-  ///   true:
-  ///   #define A   \
-  /// int ; \
-  /// int b;\
-  /// int dd;
-  ///
-  ///   false:
-  ///   #define A  
\
-  /// int ;
\
-  /// int b;   
\
-  /// int dd;
-  /// \endcode
-  bool AlignEscapedNewlinesLeft;
+  /// \brief Different styles for aligning escaped newlines.
+  enum EscapedNewlineAlignmentStyle {
+/// \brief Don't align escaped newlines.
+/// \code
+///   #define A \
+/// int ; \
+/// int b; \
+/// int dd;
+/// \endcode
+ENAS_DontAlign,
+/// \brief Align escaped newlines as far left as possible.
+/// \code
+///   true:
+///   #define A

[PATCH] D32733: [clang-format] Convert AlignEscapedNewlinesLeft to an enum, adding DontAlign

2017-05-08 Thread Daniel Jasper via Phabricator via cfe-commits
djasper closed this revision.
djasper added a comment.

Submitted as r302428.


https://reviews.llvm.org/D32733



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


[PATCH] D32475: [clang-format] Don’t propagate AvoidBinPacking into argument subexpressions

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

Submitted as r302427.


https://reviews.llvm.org/D32475



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


[PATCH] D32945: clang-tidy: add IgnoreMacros option to modernize-use-default-member-init

2017-05-08 Thread Miklos Vajna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302429: clang-tidy: add IgnoreMacros option to 
modernize-use-default-member-init (authored by vmiklos).

Changed prior to commit:
  https://reviews.llvm.org/D32945?vs=98163&id=98173#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32945

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.h
  clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp
  
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default-member-init.rst
  
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-macros.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -139,11 +139,13 @@
 UseDefaultMemberInitCheck::UseDefaultMemberInitCheck(StringRef Name,
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  UseAssignment(Options.get("UseAssignment", 0) != 0) {}
+  UseAssignment(Options.get("UseAssignment", 0) != 0),
+  IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", 1) != 0) {}
 
 void UseDefaultMemberInitCheck::storeOptions(
 ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "UseAssignment", UseAssignment);
+  Options.store(Opts, "IgnoreMacros", IgnoreMacros);
 }
 
 void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
@@ -197,6 +199,10 @@
 const MatchFinder::MatchResult &Result, const CXXCtorInitializer *Init) {
   const FieldDecl *Field = Init->getMember();
 
+  SourceLocation StartLoc = Field->getLocStart();
+  if (StartLoc.isMacroID() && IgnoreMacros)
+return;
+
   SourceLocation FieldEnd =
   Lexer::getLocForEndOfToken(Field->getSourceRange().getEnd(), 0,
  *Result.SourceManager, getLangOpts());
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp
@@ -19,7 +19,7 @@
 
 UseUsingCheck::UseUsingCheck(StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  IgnoreMacros(Options.get("IgnoreMacros", true)) {}
+  IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {}
 
 void UseUsingCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus11)
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.h
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.h
@@ -36,6 +36,7 @@
  const CXXCtorInitializer *Init);
 
   const bool UseAssignment;
+  const bool IgnoreMacros;
 };
 
 } // namespace modernize
Index: clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default-member-init.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default-member-init.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default-member-init.rst
@@ -47,3 +47,8 @@
 int i = 5;
 double j = 10.0;
   };
+
+.. option:: IgnoreMacros
+
+   If this option is set to non-zero (default is `1`), the check will not warn
+   about members declared inside macros.
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp
@@ -380,3 +380,12 @@
 
 NegativeTemplateExisting ntei(0);
 NegativeTemplateExisting nted(0);
+
+// This resulted in a warning by default.
+#define MACRO() \
+  struct MacroS { \
+void *P; \
+MacroS() : P(nullptr) {} \
+  };
+
+MACRO();
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-macros.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-macros.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-macros.cpp
@@ -0,0 +1,18 @@
+// RUN: %check_clang_tidy %s modernize-use-default-member-init %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-default-member-init.IgnoreMacros, value: 0}]}" \
+// RUN:  

[clang-tools-extra] r302429 - clang-tidy: add IgnoreMacros option to modernize-use-default-member-init

2017-05-08 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Mon May  8 10:13:31 2017
New Revision: 302429

URL: http://llvm.org/viewvc/llvm-project?rev=302429&view=rev
Log:
clang-tidy: add IgnoreMacros option to modernize-use-default-member-init

Summary:
And also enable it by default to be consistent with e.g.
modernize-use-using.

This helps e.g. when running this check on cppunit client code where the
macro is provided by the system, so there is no easy way to modify it.

Reviewers: alexfh, malcolm.parsons

Reviewed By: malcolm.parsons

Subscribers: cfe-commits

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

Added:

clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-macros.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.h
clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default-member-init.rst

clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp?rev=302429&r1=302428&r2=302429&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
Mon May  8 10:13:31 2017
@@ -139,11 +139,13 @@ static bool sameValue(const Expr *E1, co
 UseDefaultMemberInitCheck::UseDefaultMemberInitCheck(StringRef Name,
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  UseAssignment(Options.get("UseAssignment", 0) != 0) {}
+  UseAssignment(Options.get("UseAssignment", 0) != 0),
+  IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", 1) != 0) {}
 
 void UseDefaultMemberInitCheck::storeOptions(
 ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "UseAssignment", UseAssignment);
+  Options.store(Opts, "IgnoreMacros", IgnoreMacros);
 }
 
 void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
@@ -197,6 +199,10 @@ void UseDefaultMemberInitCheck::checkDef
 const MatchFinder::MatchResult &Result, const CXXCtorInitializer *Init) {
   const FieldDecl *Field = Init->getMember();
 
+  SourceLocation StartLoc = Field->getLocStart();
+  if (StartLoc.isMacroID() && IgnoreMacros)
+return;
+
   SourceLocation FieldEnd =
   Lexer::getLocForEndOfToken(Field->getSourceRange().getEnd(), 0,
  *Result.SourceManager, getLangOpts());

Modified: 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.h?rev=302429&r1=302428&r2=302429&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.h 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.h 
Mon May  8 10:13:31 2017
@@ -36,6 +36,7 @@ private:
  const CXXCtorInitializer *Init);
 
   const bool UseAssignment;
+  const bool IgnoreMacros;
 };
 
 } // namespace modernize

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp?rev=302429&r1=302428&r2=302429&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp Mon May  8 
10:13:31 2017
@@ -19,7 +19,7 @@ namespace modernize {
 
 UseUsingCheck::UseUsingCheck(StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  IgnoreMacros(Options.get("IgnoreMacros", true)) {}
+  IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {}
 
 void UseUsingCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus11)

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default-member-init.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default-member-init.rst?rev=302429&r1=302428&r2=302429&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default-member-init.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default-member-init.rst
 Mon May  8 10:13:31 2017
@@ -47,3 +47,8 @@ Options
 int i = 5;
 double j = 10.0;
   };
+
+.. option:: 

[clang-tools-extra] r302431 - [clang-tidy] Fix readability-implicit-bool-cast false positives

2017-05-08 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon May  8 10:22:09 2017
New Revision: 302431

URL: http://llvm.org/viewvc/llvm-project?rev=302431&view=rev
Log:
[clang-tidy] Fix readability-implicit-bool-cast false positives

The patch makes the check treat binary conditional operator (`x ?: y`), `while`
and regular `for` loops as conditional statements for the purpose of
AllowConditional*Cast options.

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

clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp?rev=302431&r1=302430&r2=302431&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp 
Mon May  8 10:22:09 2017
@@ -227,7 +227,8 @@ bool isAllowedConditionalCast(const Impl
   const Stmt *S = N.get();
   if (!S)
 return false;
-  if (isa(S) || isa(S))
+  if (isa(S) || isa(S) || isa(S) ||
+  isa(S) || isa(S))
 return true;
   if (isa(S) || isa(S) ||
   isUnaryLogicalNotOperator(S) ||

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp?rev=302431&r1=302430&r2=302431&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp
 Mon May  8 10:22:09 2017
@@ -27,9 +27,17 @@ void implicitCastIntegerToBoolInConditio
   if (!functionReturningInt()) {}
   if (functionReturningInt() && functionReturningPointer()) {}
   if (!functionReturningInt() && !functionReturningPointer()) {}
+  for (; functionReturningInt(); ) {}
+  for (; functionReturningPointer(); ) {}
+  for (; functionReturningInt() && !functionReturningPointer() || 
(!functionReturningInt() && functionReturningPointer()); ) {}
+  while (functionReturningInt()) {}
+  while (functionReturningPointer()) {}
+  while (functionReturningInt() && !functionReturningPointer() || 
(!functionReturningInt() && functionReturningPointer())) {}
   int value1 = functionReturningInt() ? 1 : 2;
   int value2 = !functionReturningInt() ? 1 : 2;
   int value3 = (functionReturningInt() && functionReturningPointer() || 
!functionReturningInt()) ? 1 : 2;
+  int value4 = functionReturningInt() ?: value3;
+  int *p1 = functionReturningPointer() ?: &value3;
 }
 
 void regularImplicitCastPointerToBoolIsNotIgnored() {


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


[PATCH] D30268: Avoid copy of __atoms when char_type is char

2017-05-08 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya added a comment.

Ping


https://reviews.llvm.org/D30268



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


[PATCH] D30018: [XRay] Add __xray_customeevent(...) as a clang-supported builtin

2017-05-08 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: lib/CodeGen/CGBuiltin.cpp:2748
+if (const auto *XRayAttr =
+this->CurFuncDecl->getAttr()) {
+  if (XRayAttr->neverXRayInstrument())

rnk wrote:
> Don't need `this->`
Do you think `this->` is necessary?


https://reviews.llvm.org/D30018



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


r302435 - [Sema] Fix typos handling in an overloadable call.

2017-05-08 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Mon May  8 11:05:54 2017
New Revision: 302435

URL: http://llvm.org/viewvc/llvm-project?rev=302435&view=rev
Log:
[Sema] Fix typos handling in an overloadable call.

In C typos in arguments in a call of an overloadable function lead
to a failure of construction of CallExpr and following recovery does
not handle created delayed typos. This causes an assertion fail in
Sema::~Sema since Sema::DelayedTypos remains not empty.

The patch fixes that behavior by handling a call with arguments
having dependant types in the way that C++ does.

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

Patch by Dmitry Borisenkov!


Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/typo-correction.c

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=302435&r1=302434&r2=302435&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon May  8 11:05:54 2017
@@ -5277,6 +5277,9 @@ ExprResult Sema::ActOnCallExpr(Scope *Sc
 
 // We aren't supposed to apply this logic if there's an '&' involved.
 if (!find.HasFormOfMemberPointer) {
+  if (Expr::hasAnyTypeDependentArguments(ArgExprs))
+return new (Context) CallExpr(
+Context, Fn, ArgExprs, Context.DependentTy, VK_RValue, RParenLoc);
   OverloadExpr *ovl = find.Expression;
   if (UnresolvedLookupExpr *ULE = dyn_cast(ovl))
 return BuildOverloadedCallExpr(

Modified: cfe/trunk/test/Sema/typo-correction.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/typo-correction.c?rev=302435&r1=302434&r2=302435&view=diff
==
--- cfe/trunk/test/Sema/typo-correction.c (original)
+++ cfe/trunk/test/Sema/typo-correction.c Mon May  8 11:05:54 2017
@@ -80,3 +80,10 @@ int h() {
   g(x, 5 ? z : 0); // expected-error 2 {{use of undeclared identifier}}
   (x, 5 ? z : 0);  // expected-error 2 {{use of undeclared identifier}}
 }
+
+__attribute__((overloadable)) void func_overloadable(int);
+__attribute__((overloadable)) void func_overloadable(float);
+
+void overloadable_callexpr(int arg) {
+   func_overloadable(ar); //expected-error{{use of undeclared identifier}}
+}


___
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-08 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 98179.
xazax.hun added a comment.

- Do not do fixits for type aliases.


https://reviews.llvm.org/D32743

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  clang-tidy/cert/PostfixOperatorCheck.cpp
  clang-tidy/cert/PostfixOperatorCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cert-dcl21-cpp.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cert-dcl21-cpp.cpp

Index: test/clang-tidy/cert-dcl21-cpp.cpp
===
--- /dev/null
+++ test/clang-tidy/cert-dcl21-cpp.cpp
@@ -0,0 +1,134 @@
+// RUN: %check_clang_tidy %s cert-dcl21-cpp %t
+
+class A {};
+
+A operator++(A &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator++' returns a non-constant object instead of a constant object type [cert-dcl21-cpp]
+// CHECK-FIXES: {{^}}const A operator++(A &, int);
+
+A operator--(A &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator--' returns a no
+// CHECK-FIXES: {{^}}const A operator--(A &, int);
+
+class B {};
+
+B &operator++(B &);
+const B operator++(B &, int);
+
+B &operator--(B &);
+const B operator--(B &, int);
+
+
+class D {
+D &operator++();
+const D operator++(int);
+
+D &operator--();
+const D operator--(int);
+};
+
+class C {
+C operator++(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator++' returns a no
+// CHECK-FIXES: {{^}}const C operator++(int);
+
+C operator--(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator--' returns a no
+// CHECK-FIXES: {{^}}const C operator--(int);
+};
+
+class E {};
+
+E &operator++(E &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator++' returns a reference instead of a constant object type [cert-dcl21-cpp]
+// CHECK-FIXES: {{^}}const E operator++(E &, int);
+
+E &operator--(E &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator--' returns a re
+// CHECK-FIXES: {{^}}const E operator--(E &, int);
+
+class G {
+G &operator++(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator++' returns a re
+// CHECK-FIXES: {{^}}const G operator++(int);
+
+G &operator--(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator--' returns a re
+// CHECK-FIXES: {{^}}const G operator--(int);
+};
+
+class F {};
+
+const F &operator++(F &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator++' returns a re
+// CHECK-FIXES: {{^}}const F operator++(F &, int);
+
+const F &operator--(F &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator--' returns a re
+// CHECK-FIXES: {{^}}const F operator--(F &, int);
+
+class H {
+const H &operator++(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator++' returns a re
+// CHECK-FIXES: {{^}}const H operator++(int);
+
+const H &operator--(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator--' returns a re
+// CHECK-FIXES: {{^}}const H operator--(int);
+};
+
+
+#define FROM_MACRO P&
+class P {
+const FROM_MACRO operator++(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator++' returns a re
+// CHECK-FIXES: {{^}}const FROM_MACRO operator++(int);
+};
+
+
+template
+class Q {
+const Q &operator++(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator++' returns a re
+// CHECK-FIXES: {{^}}const Q operator++(int);
+
+const Q &operator--(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator--' returns a re
+// CHECK-FIXES: {{^}}const Q operator--(int);
+};
+
+void foobar() {
+  Q a;
+  Q b;
+  (void)a;
+  (void)b;
+}
+
+struct S {};
+typedef S& SRef;
+
+SRef operator++(SRef, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator++' returns a re
+// CHECK-FIXES: {{^}}SRef operator++(SRef, int);
+
+struct T {
+  typedef T& TRef;
+  
+  TRef operator++(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: overloaded 'operator++' returns a re
+// CHECK-FIXES: {{^}}  TRef operator++(int);
+};
+
+struct U {
+  typedef const U& ConstURef;
+  
+  ConstURef& operator++(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: overloaded 'operator++' returns a re
+// CHECK-FIXES: {{^}}  ConstURef& operator++(int);
+};
+
+struct V {
+  V *operator++(int);
+  V *const operator--(int);
+};
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -6,6 +6,7 @@
 .. toctree::
boost-use-to-string
cert-dcl03-c (redirects to misc-static-assert) 
+   cert-dcl21-cpp
cert-dcl50-cpp
cert-dcl54-cpp (redirects to misc-new-delete-overloads) 
cert-dcl58-cpp
Index: docs/clang-tidy/checks/cert-dcl21-cpp.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cert-dcl21-cpp.rst
@@ -0,0 +1,12 @@
+.. title:: clang-tidy - cert-dcl21-cpp
+
+cert-dcl21-cpp
+

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

2017-05-08 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked 4 inline comments as done.
xazax.hun added inline comments.



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

aaron.ballman wrote:
> xazax.hun wrote:
> > aaron.ballman wrote:
> > > alexfh wrote:
> > > > 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.
> > > In addition to these tests, I'd like to see a test for the following:
> > > ```
> > > struct S {};
> > > typedef S& SRef;
> > > 
> > > SRef operator++(SRef, int);
> > > 
> > > struct T {
> > >   typedef T& TRef;
> > >   
> > >   TRef operator++(int);
> > > };
> > > 
> > > struct U {
> > >   typedef const U& ConstURef;
> > >   
> > >   ConstURef& operator++(int); // There's an extra ref shoved on here for 
> > > fun.
> > > };
> > > 
> > > struct V {
> > >   V *operator++(int);
> > >   V *const operator--(int);
> > > };
> > > ```
> > I added those test cases.
> > 
> > I choose not to warn about primitive and pointer types since it makes no 
> > sense to make them const. Do you agree?
> > 
> > Unfortunately, the current fixits might use the underlying type instead of 
> > the typedef. Is that a blocker for this to be commited?
> > In same cases it is not possible to preserve the typedef, e.g. when the 
> > underlying type is a reference. (Or we need to insert a 
> > `std::remove_reference` meta call).
> > 
> > In one case the const is not added. This is because the underlying type is 
> > already const. Rewriting the fixit is not trivial, because it is not easy 
> > to get the source range for the whole return type. Unfortunately, 
> > `getReturnTypeSourceRange` ignores the qualifiers. 
> > I choose not to warn about primitive and pointer types since it makes no 
> > sense to make them const. Do you agree?
> 
> I think that's reasonable behavior, yes.
> 
> > Unfortunately, the current fixits might use the underlying type instead of 
> > the typedef. Is that a blocker for this to be commited?
> 
> That's what I was wondering about. You may want to simply disable the fixit 
> if the underlying type is a typedef (or alias, etc).
> 
> > In same cases it is not possible to preserve the typedef, e.g. when the 
> > underlying type is a reference. (Or we need to insert a 
> > std::remove_reference meta call).
> 
> Yes, I think it's a complex problem that doesn't need to be solved right now.
> 
> > In one case the const is not added. This is because the underlying type is 
> > already const. Rewriting the fixit is not trivial, because it is not easy 
> > to get the source range for the whole return type. Unfortunately, 
> > getReturnTypeSourceRange ignores the qualifiers.
> 
> That is unfortunate, but I don't think it's a deal-breaker, either.
Good idea, done. 


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] D32770: [X86][LWP] Add clang support for LWP instructions.

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

Sorry I missed this patch, but shouldn't we had __LWP__ to the relevant 
processors in  test/Preprocessor/predefined-arch-macros.c and the command line 
switch testing to test/Preprocessor/x86_target_features.c


Repository:
  rL LLVM

https://reviews.llvm.org/D32770



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


r302440 - [AST] Fix copy&paste error in comment. NFC.

2017-05-08 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Mon May  8 11:43:29 2017
New Revision: 302440

URL: http://llvm.org/viewvc/llvm-project?rev=302440&view=rev
Log:
[AST] Fix copy&paste error in comment. NFC.

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

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=302440&r1=302439&r2=302440&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon May  8 11:43:29 2017
@@ -2478,7 +2478,7 @@ public:
   void setCapturedVLAType(const VariableArrayType *VLAType);
 
   /// getParent - Returns the parent of this field declaration, which
-  /// is the struct in which this method is defined.
+  /// is the struct in which this field is defined.
   const RecordDecl *getParent() const {
 return cast(getDeclContext());
   }


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


[PATCH] D25051: Fix PR 10758: Infinite recursion when dealing with copy-initialization

2017-05-08 Thread ~paul via Phabricator via cfe-commits
cynecx added a comment.

Would it be possible to land this patch? I would really like to see this fixed.


Repository:
  rL LLVM

https://reviews.llvm.org/D25051



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


r302443 - Fix grammar in comment. NFC

2017-05-08 Thread Jonathan Roelofs via cfe-commits
Author: jroelofs
Date: Mon May  8 12:06:17 2017
New Revision: 302443

URL: http://llvm.org/viewvc/llvm-project?rev=302443&view=rev
Log:
Fix grammar in comment. NFC

Modified:
cfe/trunk/test/Misc/warning-flags.c

Modified: cfe/trunk/test/Misc/warning-flags.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/warning-flags.c?rev=302443&r1=302442&r2=302443&view=diff
==
--- cfe/trunk/test/Misc/warning-flags.c (original)
+++ cfe/trunk/test/Misc/warning-flags.c Mon May  8 12:06:17 2017
@@ -6,8 +6,8 @@ This test serves two purposes:
 (1) It documents all existing warnings that currently have no associated -W 
flag,
 and ensures that the list never grows.
 
-If take an existing warning and add a flag, this test will fail.  To
-fix this test, simply remove that warning from the list below.
+If you take an existing warning and add a flag, this test will fail.
+To fix this test, simply remove that warning from the list below.
 
 (2) It prevents us adding new warnings to Clang that have no -W flag.  All
 new warnings should have -W flags.


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


[PATCH] D32972: [index] Index simple dependent declaration references

2017-05-08 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

This patch implements basic support for indexing of dependent declaration 
references. Now the indexer tries to find a suitable match in the base template 
for a dependent member ref/decl ref/dependent type.

This will be used to improve the "go-to-definition" / "find usages" features in 
Xcode.


Repository:
  rL LLVM

https://reviews.llvm.org/D32972

Files:
  include/clang/AST/CXXInheritance.h
  include/clang/AST/DeclCXX.h
  lib/AST/CXXInheritance.cpp
  lib/Index/IndexBody.cpp
  lib/Index/IndexTypeSourceInfo.cpp
  test/Index/Core/index-dependent-source.cpp

Index: test/Index/Core/index-dependent-source.cpp
===
--- /dev/null
+++ test/Index/Core/index-dependent-source.cpp
@@ -0,0 +1,124 @@
+// RUN: c-index-test core -print-source-symbols -- %s -std=c++14 -target x86_64-apple-macosx10.7 | FileCheck %s
+
+int invalid;
+
+class Base {
+  void baseFunction();
+
+  int baseField;
+
+  static void staticBaseFunction();
+};
+
+template
+class BaseTemplate {
+public:
+  T baseTemplateFunction();
+
+  T baseTemplateField;
+
+  static T baseTemplateVariable;
+};
+
+template
+class TemplateClass: public Base , public BaseTemplate {
+public:
+  ~TemplateClass();
+
+  T function() { }
+
+  static void staticFunction() { }
+
+  T field;
+
+  static T variable;
+
+  struct Struct { };
+
+  enum Enum { EnumValue };
+
+  using TypeAlias = S;
+  typedef T Typedef;
+
+  void overload1(const T &);
+  void overload1(const S &);
+};
+
+template
+void indexSimpleDependentDeclarations(const TemplateClass &object) {
+  // Valid instance members:
+  object.function();
+// CHECK: [[@LINE-1]]:10 | instance-method/C++ | function | c:@ST>2#T#T@TemplateClass@F@function# |  | Ref,Call,RelCall,RelCont | rel: 1
+  object.field;
+// CHECK: [[@LINE-1]]:10 | field/C++ | field | c:@ST>2#T#T@TemplateClass@FI@field |  | Ref,RelCont | rel: 1
+  object.baseFunction();
+// CHECK: [[@LINE-1]]:10 | instance-method/C++ | baseFunction | c:@S@Base@F@baseFunction# | __ZN4Base12baseFunctionEv | Ref,Call,RelCall,RelCont | rel: 1
+  object.baseField;
+// CHECK: [[@LINE-1]]:10 | field/C++ | baseField | c:@S@Base@FI@baseField |  | Ref,RelCont | rel: 1
+  object.baseTemplateFunction();
+// CHECK: [[@LINE-1]]:10 | instance-method/C++ | baseTemplateFunction | c:@ST>1#T@BaseTemplate@F@baseTemplateFunction# |  | Ref,Call,RelCall,RelCont | rel: 1
+  object.baseTemplateField;
+// CHECK: [[@LINE-1]]:10 | field/C++ | baseTemplateField | c:@ST>1#T@BaseTemplate@FI@baseTemplateField |  | Ref,RelCont | rel: 1
+
+  // Invalid instance members:
+  object.variable;
+// CHECK-NOT: [[@LINE-1]]:10
+  object.staticFunction();
+// CHECK-NOT: [[@LINE-1]]:10
+  object.Struct;
+// CHECK-NOT: [[@LINE-1]]:10
+  object.EnumValue;
+// CHECK-NOT: [[@LINE-1]]:10
+
+  // Valid static members:
+  TemplateClass::staticFunction();
+// CHECK: [[@LINE-1]]:24 | static-method/C++ | staticFunction | c:@ST>2#T#T@TemplateClass@F@staticFunction#S |  | Ref,Call,RelCall,RelCont | rel: 1
+  TemplateClass::variable;
+// CHECK: [[@LINE-1]]:24 | static-property/C++ | variable | c:@ST>2#T#T@TemplateClass@variable | __ZN13TemplateClass8variableE | Ref,RelCont | rel: 1
+  TemplateClass::staticBaseFunction();
+// CHECK: [[@LINE-1]]:24 | static-method/C++ | staticBaseFunction | c:@S@Base@F@staticBaseFunction#S | __ZN4Base18staticBaseFunctionEv | Ref,Call,RelCall,RelCont | rel: 1
+  TemplateClass::baseTemplateVariable;
+// CHECK: [[@LINE-1]]:24 | static-property/C++ | baseTemplateVariable | c:@ST>1#T@BaseTemplate@baseTemplateVariable | __ZN12BaseTemplate20baseTemplateVariableE | Ref,RelCont | rel: 1
+  TemplateClass::EnumValue;
+// CHECK: [[@LINE-1]]:24 | enumerator/C | EnumValue | c:@ST>2#T#T@TemplateClass@E@Enum@EnumValue |  | Ref,RelCont | rel: 1
+  TemplateClass::Struct();
+// CHECK: [[@LINE-1]]:24 | struct/C | Struct | c:@ST>2#T#T@TemplateClass@S@Struct |  | Ref,Call,RelCall,RelCont | rel: 1
+
+  // Invalid static members:
+  TemplateClass::field;
+// CHECK-NOT: [[@LINE-1]]:24
+  TemplateClass::function();
+// CHECK-NOT: [[@LINE-1]]:24
+
+  // Valid type names:
+  typename TemplateClass::Struct Val;
+// CHECK: [[@LINE-1]]:33 | struct/C | Struct | c:@ST>2#T#T@TemplateClass@S@Struct |  | Ref,RelCont | rel: 1
+  typename TemplateClass::Enum EnumVal;
+// CHECK: [[@LINE-1]]:33 | enum/C | Enum | c:@ST>2#T#T@TemplateClass@E@Enum |  | Ref,RelCont | rel: 1
+  typename TemplateClass::TypeAlias Val2;
+// CHECK: [[@LINE-1]]:33 | type-alias/C++ | TypeAlias | c:@ST>2#T#T@TemplateClass@TypeAlias |  | Ref,RelCont | rel: 1
+  typename TemplateClass::Typedef Val3;
+// CHECK: [[@LINE-1]]:33 | type-alias/C | Typedef | c:{{.*}}index-dependent-source.cpp@ST>2#T#T@TemplateClass@T@Typedef |  | Ref,RelCont | rel: 1
+
+  // Invalid type names:
+  typename TemplateClass::field Val4;
+// CHECK-NOT: [[@LINE-1]]:33
+  typename TemplateClass::staticFunction Val5;
+// CHECK-NOT: [[@LINE-1]]:33
+
+
+  object.invalid;
+// CHECK-NOT: [[@LINE-1]]:

r302445 - [X86][LWP] Add __LWP__ macro tests

2017-05-08 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Mon May  8 12:25:48 2017
New Revision: 302445

URL: http://llvm.org/viewvc/llvm-project?rev=302445&view=rev
Log:
[X86][LWP] Add __LWP__ macro tests

Missed in rL302418

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

Modified:
cfe/trunk/test/Preprocessor/predefined-arch-macros.c
cfe/trunk/test/Preprocessor/x86_target_features.c

Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=302445&r1=302444&r2=302445&view=diff
==
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Mon May  8 12:25:48 
2017
@@ -1601,6 +1601,7 @@
 // CHECK_BDVER1_M32: #define __AES__ 1
 // CHECK_BDVER1_M32: #define __AVX__ 1
 // CHECK_BDVER1_M32: #define __FMA4__ 1
+// CHECK_BDVER1_M32: #define __LWP__ 1
 // CHECK_BDVER1_M32: #define __LZCNT__ 1
 // CHECK_BDVER1_M32: #define __MMX__ 1
 // CHECK_BDVER1_M32: #define __PCLMUL__ 1
@@ -1630,6 +1631,7 @@
 // CHECK_BDVER1_M64: #define __AES__ 1
 // CHECK_BDVER1_M64: #define __AVX__ 1
 // CHECK_BDVER1_M64: #define __FMA4__ 1
+// CHECK_BDVER1_M64: #define __LWP__ 1
 // CHECK_BDVER1_M64: #define __LZCNT__ 1
 // CHECK_BDVER1_M64: #define __MMX__ 1
 // CHECK_BDVER1_M64: #define __PCLMUL__ 1
@@ -1664,6 +1666,7 @@
 // CHECK_BDVER2_M32: #define __F16C__ 1
 // CHECK_BDVER2_M32: #define __FMA4__ 1
 // CHECK_BDVER2_M32: #define __FMA__ 1
+// CHECK_BDVER2_M32: #define __LWP__ 1
 // CHECK_BDVER2_M32: #define __LZCNT__ 1
 // CHECK_BDVER2_M32: #define __MMX__ 1
 // CHECK_BDVER2_M32: #define __PCLMUL__ 1
@@ -1697,6 +1700,7 @@
 // CHECK_BDVER2_M64: #define __F16C__ 1
 // CHECK_BDVER2_M64: #define __FMA4__ 1
 // CHECK_BDVER2_M64: #define __FMA__ 1
+// CHECK_BDVER2_M64: #define __LWP__ 1
 // CHECK_BDVER2_M64: #define __LZCNT__ 1
 // CHECK_BDVER2_M64: #define __MMX__ 1
 // CHECK_BDVER2_M64: #define __PCLMUL__ 1
@@ -1733,6 +1737,7 @@
 // CHECK_BDVER3_M32: #define __FMA4__ 1
 // CHECK_BDVER3_M32: #define __FMA__ 1
 // CHECK_BDVER3_M32: #define __FSGSBASE__ 1
+// CHECK_BDVER3_M32: #define __LWP__ 1
 // CHECK_BDVER3_M32: #define __LZCNT__ 1
 // CHECK_BDVER3_M32: #define __MMX__ 1
 // CHECK_BDVER3_M32: #define __PCLMUL__ 1
@@ -1768,6 +1773,7 @@
 // CHECK_BDVER3_M64: #define __FMA4__ 1
 // CHECK_BDVER3_M64: #define __FMA__ 1
 // CHECK_BDVER3_M64: #define __FSGSBASE__ 1
+// CHECK_BDVER3_M64: #define __LWP__ 1
 // CHECK_BDVER3_M64: #define __LZCNT__ 1
 // CHECK_BDVER3_M64: #define __MMX__ 1
 // CHECK_BDVER3_M64: #define __PCLMUL__ 1
@@ -1807,6 +1813,7 @@
 // CHECK_BDVER4_M32: #define __FMA4__ 1
 // CHECK_BDVER4_M32: #define __FMA__ 1
 // CHECK_BDVER4_M32: #define __FSGSBASE__ 1
+// CHECK_BDVER4_M32: #define __LWP__ 1
 // CHECK_BDVER4_M32: #define __LZCNT__ 1
 // CHECK_BDVER4_M32: #define __MMX__ 1
 // CHECK_BDVER4_M32: #define __PCLMUL__ 1
@@ -1843,6 +1850,7 @@
 // CHECK_BDVER4_M64: #define __FMA4__ 1
 // CHECK_BDVER4_M64: #define __FMA__ 1
 // CHECK_BDVER4_M64: #define __FSGSBASE__ 1
+// CHECK_BDVER4_M64: #define __LWP__ 1
 // CHECK_BDVER4_M64: #define __LZCNT__ 1
 // CHECK_BDVER4_M64: #define __MMX__ 1
 // CHECK_BDVER4_M64: #define __PCLMUL__ 1

Modified: cfe/trunk/test/Preprocessor/x86_target_features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/x86_target_features.c?rev=302445&r1=302444&r2=302445&view=diff
==
--- cfe/trunk/test/Preprocessor/x86_target_features.c (original)
+++ cfe/trunk/test/Preprocessor/x86_target_features.c Mon May  8 12:25:48 2017
@@ -272,6 +272,14 @@
 // AESNOSSE2-NOT: #define __SSE2__ 1
 // AESNOSSE2-NOT: #define __SSE3__ 1
 
+// RUN: %clang -target i386-unknown-unknown -march=pentiumpro -mlwp -x c -E 
-dM -o - %s | FileCheck -match-full-lines --check-prefix=LWP %s
+
+// LWP: #define __LWP__ 1
+
+// RUN: %clang -target i386-unknown-unknown -march=bdver1 -mno-lwp -x c -E -dM 
-o - %s | FileCheck -match-full-lines --check-prefix=NOLWP %s
+
+// NOLWP-NOT: #define __LWP__ 1
+
 // RUN: %clang -target i386-unknown-unknown -march=pentiumpro -msha -x c -E 
-dM -o - %s | FileCheck -match-full-lines --check-prefix=SHA %s
 
 // SHA: #define __SHA__ 1


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


[PATCH] D32770: [X86][LWP] Add clang support for LWP instructions.

2017-05-08 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

In https://reviews.llvm.org/D32770#748762, @craig.topper wrote:

> Sorry I missed this patch, but shouldn't we had __LWP__ to the relevant 
> processors in  test/Preprocessor/predefined-arch-macros.c and the command 
> line switch testing to test/Preprocessor/x86_target_features.c


Thanks! https://reviews.llvm.org/rL302445


Repository:
  rL LLVM

https://reviews.llvm.org/D32770



___
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-08 Thread Sean Callanan via Phabricator via cfe-commits
spyffe added inline comments.



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();

vsk wrote:
> spyffe wrote:
> > 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...
> I don't think this would work, and don't quite see a way to make it work. The 
> problem is that when importing a module into a CU, the CU's hash is required 
> to match the to-be-imported module's hash [1]. If we clear some sanitizer 
> options in resetNonModularOptions(), then the "matching hashes" check would 
> break, because you can't reset the non-modular options in a CU that you're 
> importing a module into. You'd end up disabling the sanitizers for the CU 
> you're building.
> 
> [1] CompilerInstance.cpp
> ```
> 1095   assert(ImportingInstance.getInvocation().getModuleHash() ==
>   
>   
>   
>   
> 1096  Invocation->getModuleHash() && "Module hash mismatch!"); 
> ```
Okay, I probably just didn't understand the role of `resetNonModularOptions()`.


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] D32341: Fix a bug that warnings generated with -M or -MM flags

2017-05-08 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi added a comment.

@teemperor ping..?


https://reviews.llvm.org/D32341



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


[PATCH] D31885: Remove TBAA information from LValues representing union members

2017-05-08 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz added a comment.

Ping.

What's the next step here?


Repository:
  rL LLVM

https://reviews.llvm.org/D31885



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


[PATCH] D31885: Remove TBAA information from LValues representing union members

2017-05-08 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D31885#748873, @kparzysz wrote:

> Ping.
>
> What's the next step here?


Sounds to me like we should just not apply struct-path TBAA data that runs 
through a union field because either LLVM's representation can't handle it or 
Clang isn't generating the representation right.  That should be simple to do 
in a targeted place in Clang rather than awkwardly doing it retroactively like 
in the current patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D31885



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


[PATCH] D32759: Fix errored return value in CheckFunctionReturnType and add a fixit hint

2017-05-08 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

In https://reviews.llvm.org/D32759#748653, @chenwj wrote:

> In https://reviews.llvm.org/D32759#748007, @efriedma wrote:
>
> > The difference between returning true and false here is just the way error 
> > recovery works: when we return true, we know the type is invalid, so we 
> > suppress it, and subsequent errors involving the declaration.  Example 
> > (Objective-C++) where we currently print two errors:
>
>
> So when we see `T->isObjCObjectType()` is true, then we should return true 
> since the return type is invalid?


Yes.


https://reviews.llvm.org/D32759



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


[PATCH] D32977: [OpenCL] Emit function-scope variable in constant address space as static variable

2017-05-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
Herald added a subscriber: nhaehnle.

https://reviews.llvm.org/D32977

Files:
  include/clang/AST/Decl.h
  lib/Sema/SemaDecl.cpp
  test/CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl
  test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl
  test/CodeGenOpenCL/constant-addr-space-globals.cl
  test/SemaOpenCL/storageclass.cl

Index: test/SemaOpenCL/storageclass.cl
===
--- test/SemaOpenCL/storageclass.cl
+++ test/SemaOpenCL/storageclass.cl
@@ -5,7 +5,7 @@
 int G3 = 0;// expected-error{{program scope variable must reside in constant address space}}
 global int G4 = 0; // expected-error{{program scope variable must reside in constant address space}}
 
-void kernel foo() {
+void kernel foo(int x) {
   // static is not allowed at local scope before CL2.0
   static int S1 = 5;  // expected-error{{variables in function scope cannot be declared static}}
   static constant int S2 = 5; // expected-error{{variables in function scope cannot be declared static}}
@@ -15,6 +15,12 @@
 
   auto int L3 = 7; // expected-error{{OpenCL version 1.2 does not support the 'auto' storage class specifier}}
   global int L4;   // expected-error{{function scope variable cannot be declared in global address space}}
+
+  constant int L5 = x; // expected-error {{initializer element is not a compile-time constant}}
+  global int *constant L6 = &G4;
+  private int *constant L7 = &x; // expected-error {{initializer element is not a compile-time constant}}
+  constant int *constant L8 = &L1;
+  local int *constant L9 = &L2; // expected-error {{initializer element is not a compile-time constant}}
 }
 
 static void kernel bar() { // expected-error{{kernel functions cannot be declared static}}
@@ -29,4 +35,7 @@
   }
   global int L3; // expected-error{{function scope variable cannot be declared in global address space}}
   extern constant float L4;
+  extern local float L5; // expected-error{{extern variable must reside in constant address space}}
+  static int L6 = 0; // expected-error{{variables in function scope cannot be declared static}}
+  static int L7; // expected-error{{variables in function scope cannot be declared static}}
 }
Index: test/CodeGenOpenCL/constant-addr-space-globals.cl
===
--- test/CodeGenOpenCL/constant-addr-space-globals.cl
+++ test/CodeGenOpenCL/constant-addr-space-globals.cl
@@ -11,17 +11,21 @@
 // but create a copy in the original address space (unless a variable itself is
 // in the constant address space).
 
-void foo(constant const int *p1, const int *p2, const int *p3);
+void foo(constant int* p, constant const int *p1, const int *p2, const int *p3);
 // CHECK: @k.arr1 = internal addrspace(2) constant [3 x i32] [i32 1, i32 2, i32 3]
 // CHECK: @k.arr2 = private unnamed_addr addrspace(2) constant [3 x i32] [i32 4, i32 5, i32 6]
 // CHECK: @k.arr3 = private unnamed_addr addrspace(2) constant [3 x i32] [i32 7, i32 8, i32 9]
+// CHECK: @k.var1 = internal addrspace(2) constant i32 1
 kernel void k(void) {
   // CHECK-NOT: %arr1 = alloca [3 x i32]
   constant const int arr1[] = {1, 2, 3};
   // CHECK: %arr2 = alloca [3 x i32]
   const int arr2[] = {4, 5, 6};
   // CHECK: %arr3 = alloca [3 x i32]
   int arr3[] = {7, 8, 9};
 
-  foo(arr1, arr2, arr3);
+  constant int var1 = 1;
+  
+  // CHECK: call spir_func void @foo(i32 addrspace(2)* @k.var1, i32 addrspace(2)* getelementptr inbounds ([3 x i32], [3 x i32] addrspace(2)* @k.arr1, i32 0, i32 0)
+  foo(&var1, arr1, arr2, arr3);
 }
Index: test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl
===
--- test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl
+++ test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl
@@ -80,21 +80,21 @@
   // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(4)** {{.*}}, metadata ![[FUNCVAR4]], metadata ![[PRIVATE]]), !dbg !{{[0-9]+}}
   int *FuncVar4 = Tmp1;
 
-  // CHECK-DAG: ![[FUNCVAR5:[0-9]+]] = !DILocalVariable(name: "FuncVar5", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
-  // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(1)** {{.*}}, metadata ![[FUNCVAR5]], metadata ![[NONE:[0-9]+]]), !dbg !{{[0-9]+}}
-  global int *constant FuncVar5 = KernelArg0;
-  // CHECK-DAG: ![[FUNCVAR6:[0-9]+]] = !DILocalVariable(name: "FuncVar6", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
-  // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(2)** {{.*}}, metadata ![[FUNCVAR6]], metadata ![[NONE]]), !dbg !{{[0-9]+}}
-  constant int *constant FuncVar6 = KernelArg1;
-  // CHECK-DAG: ![[FUNCVAR7:[0-9]+]] = !DILocalVariable(name: "FuncVar7", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
-  // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(3)** {

[PATCH] D32248: CodeGen: Cast alloca to expected address space

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



Comment at: lib/CodeGen/CGDecl.cpp:1105-1119
+  // Alloca always returns a pointer in alloca address space, which may
+  // be different from the type defined by the language. For example,
+  // in C++ the auto variables are in the default address space. Therefore
+  // cast alloca to the expected address space when necessary.
+  auto Addr = address.getPointer();
+  auto AddrTy = cast(Addr->getType());
+  auto ExpectedAddrSpace = 
CGM.getTypes().getVariableType(D)->getAddressSpace();

Anastasia wrote:
> rjmccall wrote:
> > yaxunl wrote:
> > > yaxunl wrote:
> > > > rjmccall wrote:
> > > > > Anastasia wrote:
> > > > > > yaxunl wrote:
> > > > > > > yaxunl wrote:
> > > > > > > > t-tye wrote:
> > > > > > > > > Is any assert done to ensure that it is legal to address 
> > > > > > > > > space cast from variable address space to expected address 
> > > > > > > > > space? Presumably the language, by definition, will only be 
> > > > > > > > > causing legal casts. For example from alloca address space to 
> > > > > > > > > generic (which includes the alloca address space).
> > > > > > > > > 
> > > > > > > > > For OpenCL, can you explain how the local variable can have 
> > > > > > > > > the constant address space and use an alloca for allocation? 
> > > > > > > > > Wouldn't a constant address space mean it was static and so 
> > > > > > > > > should not be using alloca? And if it is using an alloca, how 
> > > > > > > > > can it then be accessed as if it was in constant address 
> > > > > > > > > space?
> > > > > > > > If the auto var has address space qualifier specified through 
> > > > > > > > `__attribute__((address_space(n)))`, there is not much we can 
> > > > > > > > check in clang since it is target dependent. We will just emit 
> > > > > > > > address space cast when necessary and let the backend check the 
> > > > > > > > validity of the address space cast.
> > > > > > > > 
> > > > > > > > Otherwise, for OpenCL, we can assert the expected address space 
> > > > > > > > is default (for OpenCL default address space in AST represents 
> > > > > > > > private address space in source language) or constant. For 
> > > > > > > > other languages we can assert the expected address space 
> > > > > > > > qualifier is default (no address space qualifier). It is not 
> > > > > > > > convenient to further check whether the emitted LLVM address 
> > > > > > > > space cast instruction is valid since it requires target 
> > > > > > > > specific information, therefore such check is better deferred 
> > > > > > > > to the backend.
> > > > > > > > 
> > > > > > > > For OpenCL, currently automatic variable in constant address 
> > > > > > > > space is emitted in private address space. For example, 
> > > > > > > > currently Clang does not diagnose the following code
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > void f(global int* a) {
> > > > > > > >   global int* constant p = a;
> > > > > > > > }
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > Instead, it emits alloca for p, essentially treats it as 
> > > > > > > > `global int* const p`. This seems to be a bug to me (or maybe 
> > > > > > > > we can call it a feature? since there seems no better way to 
> > > > > > > > translate this to LLVM IR, or simply diagnose this as an 
> > > > > > > > error). However, this is better addressed by another patch.
> > > > > > > 
> > > > > > > Hi Anastasia,
> > > > > > > 
> > > > > > > Any comments about the automatic variable in constant address 
> > > > > > > space? Thanks.
> > > > > > From the spec s6.5.3 it feels like we should follow the same 
> > > > > > implementation path in Clang for constant AS inside kernel function 
> > > > > > as local AS. Because constant AS objects are essentially global 
> > > > > > objects.
> > > > > > 
> > > > > >  Although, we didn't have any issues up to now because const just 
> > > > > > does the trick of optimising the objects out eventually. I am not 
> > > > > > clear if this creates any issue now with your allocation change. It 
> > > > > > feels though that it should probably work fine just as is?
> > > > > If these __constant locals are required to be const (or are 
> > > > > implicitly const?) and have constant initializers, it seems to me the 
> > > > > implementation obviously intended by the spec is that you allocate 
> > > > > them statically in the constant address space.  It's likely that just 
> > > > > implicitly making the variable static in Sema, the same way you make 
> > > > > it implicitly const, will make IRGen and various other parts of the 
> > > > > compiler just do the right thing.
> > > > My patch does not change the current behaviour of Clang regarding 
> > > > function-scope variable in constant address space. Basically there is 
> > > > no issue if there is no address taken. However, if there is address 
> > > > taken, there will be assertion due to casting private pointer to 
> > > > constant add

[PATCH] D32886: [asan] A clang flag to enable ELF globals-gc

2017-05-08 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis updated this revision to Diff 98200.
Herald added a subscriber: krytarowski.

Repository:
  rL LLVM

https://reviews.llvm.org/D32886

Files:
  include/clang/Driver/Options.td
  include/clang/Driver/SanitizerArgs.h
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/asan-globals-gc.cpp
  test/Driver/fsanitize.c

Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -126,6 +126,13 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE
 // CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE: -cc1{{.*}}address-use-after-scope
 
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-address-globals-dead-stripping %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ASAN-GLOBALS
+// RUN: %clang_cl -target x86_64-windows-msvc -fsanitize=address -fsanitize-address-globals-dead-stripping -### -- %s 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
+// RUN: %clang_cl -target x86_64-windows-msvc -fsanitize=address -### -- %s 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
+// CHECK-ASAN-GLOBALS: -cc1{{.*}}-fsanitize-address-globals-dead-stripping
+// CHECK-NO-ASAN-GLOBALS-NOT: -cc1{{.*}}-fsanitize-address-globals-dead-stripping
+
 // RUN: %clang -target x86_64-linux-gnu -fsanitize-memory-track-origins -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-TRACK-ORIGINS
 // CHECK-ONLY-TRACK-ORIGINS: warning: argument unused during compilation: '-fsanitize-memory-track-origins'
 
Index: test/CodeGen/asan-globals-gc.cpp
===
--- test/CodeGen/asan-globals-gc.cpp
+++ test/CodeGen/asan-globals-gc.cpp
@@ -1,5 +1,16 @@
-// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITH-GC
-// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-windows-msvc -fdata-sections %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fno-integrated-as -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fno-integrated-as -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC
+// RUN: %clang_cc1 -fsanitize=address -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC
+
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fno-data-sections -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fdata-sections -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fdata-sections -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITHOUT-GC
+
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fno-data-sections -emit-llvm -o - -triple x86_64-apple-macosx11 %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fdata-sections -emit-llvm -o - -triple x86_64-apple-macosx11 %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fdata-sections -emit-llvm -o - -triple x86_64-apple-macosx11 %s | FileCheck %s --check-prefix=WITHOUT-GC
 
 int global;
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -778,6 +778,8 @@
 Opts.SanitizeAddressUseAfterScope =
 A->getOption().getID() == OPT_fsanitize_address_use_after_scope;
   }
+  Opts.SanitizeAddressGlobalsDeadStripping =
+  Args.hasArg(OPT_fsanitize_address_globals_dead_stripping);
   Opts.SSPBufferSize =
   getLastArgIntValue(Args, OPT_stack_protector_buffer_size, 8, Diags);
   Opts.StackRealignment = Args.hasArg(OPT_mstackrealign);
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -569,6 +569,12 @@
   AsanUseAft

r302463 - If we are building a module, and we read a second description of the same

2017-05-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon May  8 15:30:47 2017
New Revision: 302463

URL: http://llvm.org/viewvc/llvm-project?rev=302463&view=rev
Log:
If we are building a module, and we read a second description of the same
module from a different module map, ignore it.

This happens during builds of preprocessed modules (where it is harmless).

Modified:
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/test/Modules/preprocess-module.cpp

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=302463&r1=302462&r2=302463&view=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Mon May  8 15:30:47 2017
@@ -1485,7 +1485,19 @@ void ModuleMapParser::parseModuleDecl()
   
   // Determine whether this (sub)module has already been defined.
   if (Module *Existing = Map.lookupModuleQualified(ModuleName, ActiveModule)) {
-if (Existing->DefinitionLoc.isInvalid() && !ActiveModule) {
+// We might see a (re)definition of a module that we already have a
+// definition for in two cases:
+//  - If we loaded one definition from an AST file and we've just found a
+//corresponding definition in a module map file, or
+bool LoadedFromASTFile = Existing->DefinitionLoc.isInvalid();
+//  - If we're building a (preprocessed) module and we've just loaded the
+//module map file from which it was created.
+bool ParsedAsMainInput =
+Map.LangOpts.getCompilingModule() == LangOptions::CMK_ModuleMap &&
+Map.LangOpts.CurrentModule == ModuleName &&
+SourceMgr.getDecomposedLoc(ModuleNameLoc).first !=
+SourceMgr.getDecomposedLoc(Existing->DefinitionLoc).first;
+if (!ActiveModule && (LoadedFromASTFile || ParsedAsMainInput)) {
   // Skip the module definition.
   skipUntil(MMToken::RBrace);
   if (Tok.is(MMToken::RBrace))

Modified: cfe/trunk/test/Modules/preprocess-module.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/preprocess-module.cpp?rev=302463&r1=302462&r2=302463&view=diff
==
--- cfe/trunk/test/Modules/preprocess-module.cpp (original)
+++ cfe/trunk/test/Modules/preprocess-module.cpp Mon May  8 15:30:47 2017
@@ -19,6 +19,11 @@
 // RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodule-file=%t/fwd.pcm -x 
c++-module-map-cpp-output %t/no-rewrite.ii -emit-module -o %t/no-rewrite.pcm
 // RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodule-file=%t/fwd.pcm -x 
c++-module-map-cpp-output %t/rewrite.ii -emit-module -o %t/rewrite.pcm
 
+// Check that we can load the original module map in the same compilation (this
+// could happen if we had a redundant -fmodule-map-file= in the original
+// build).
+// RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodule-file=%t/fwd.pcm 
-fmodule-map-file=%S/Inputs/preprocess/module.modulemap -x 
c++-module-map-cpp-output %t/rewrite.ii -emit-module -o /dev/null
+
 // Check the module we built works.
 // RUN: %clang_cc1 -fmodules -fmodule-file=%t/no-rewrite.pcm %s -verify
 // RUN: %clang_cc1 -fmodules -fmodule-file=%t/rewrite.pcm %s -verify


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


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

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

Thanks!
On 06/05/17 00:34, Richard Smith via cfe-commits wrote:

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



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


[PATCH] D29621: Add ASTMatchRefactorer and ReplaceNodeWithTemplate to RefactoringCallbacks

2017-05-08 Thread Julian Bangert via Phabricator via cfe-commits
jbangert updated this revision to Diff 98203.
jbangert added a comment.

Ran check-clang


https://reviews.llvm.org/D29621

Files:
  include/clang/Tooling/RefactoringCallbacks.h
  lib/Tooling/RefactoringCallbacks.cpp
  unittests/Tooling/RefactoringCallbacksTest.cpp

Index: unittests/Tooling/RefactoringCallbacksTest.cpp
===
--- unittests/Tooling/RefactoringCallbacksTest.cpp
+++ unittests/Tooling/RefactoringCallbacksTest.cpp
@@ -7,31 +7,30 @@
 //
 //===--===//
 
-#include "clang/Tooling/RefactoringCallbacks.h"
 #include "RewriterTestContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/RefactoringCallbacks.h"
 #include "gtest/gtest.h"
 
 namespace clang {
 namespace tooling {
 
 using namespace ast_matchers;
 
 template 
-void expectRewritten(const std::string &Code,
- const std::string &Expected,
- const T &AMatcher,
- RefactoringCallback &Callback) {
-  MatchFinder Finder;
+void expectRewritten(const std::string &Code, const std::string &Expected,
+ const T &AMatcher, RefactoringCallback &Callback) {
+  std::map FileToReplace;
+  ASTMatchRefactorer Finder(FileToReplace);
   Finder.addMatcher(AMatcher, &Callback);
   std::unique_ptr Factory(
   tooling::newFrontendActionFactory(&Finder));
   ASSERT_TRUE(tooling::runToolOnCode(Factory->create(), Code))
   << "Parsing error in \"" << Code << "\"";
   RewriterTestContext Context;
   FileID ID = Context.createInMemoryFile("input.cc", Code);
-  EXPECT_TRUE(tooling::applyAllReplacements(Callback.getReplacements(),
+  EXPECT_TRUE(tooling::applyAllReplacements(FileToReplace["input.cc"],
 Context.Rewrite));
   EXPECT_EQ(Expected, Context.getRewrittenText(ID));
 }
@@ -61,40 +60,94 @@
   std::string Code = "void f() { int i = 1; }";
   std::string Expected = "void f() { int i = 2; }";
   ReplaceStmtWithText Callback("id", "2");
-  expectRewritten(Code, Expected, id("id", expr(integerLiteral())),
-  Callback);
+  expectRewritten(Code, Expected, id("id", expr(integerLiteral())), Callback);
 }
 
 TEST(RefactoringCallbacksTest, ReplacesStmtWithStmt) {
   std::string Code = "void f() { int i = false ? 1 : i * 2; }";
   std::string Expected = "void f() { int i = i * 2; }";
   ReplaceStmtWithStmt Callback("always-false", "should-be");
-  expectRewritten(Code, Expected,
-  id("always-false", conditionalOperator(
-  hasCondition(cxxBoolLiteral(equals(false))),
-  hasFalseExpression(id("should-be", expr(),
+  expectRewritten(
+  Code, Expected,
+  id("always-false",
+ conditionalOperator(hasCondition(cxxBoolLiteral(equals(false))),
+ hasFalseExpression(id("should-be", expr(),
   Callback);
 }
 
 TEST(RefactoringCallbacksTest, ReplacesIfStmt) {
   std::string Code = "bool a; void f() { if (a) f(); else a = true; }";
   std::string Expected = "bool a; void f() { f(); }";
   ReplaceIfStmtWithItsBody Callback("id", true);
-  expectRewritten(Code, Expected,
-  id("id", ifStmt(
-  hasCondition(implicitCastExpr(hasSourceExpression(
-  declRefExpr(to(varDecl(hasName("a"),
+  expectRewritten(
+  Code, Expected,
+  id("id", ifStmt(hasCondition(implicitCastExpr(hasSourceExpression(
+   declRefExpr(to(varDecl(hasName("a"),
   Callback);
 }
 
 TEST(RefactoringCallbacksTest, RemovesEntireIfOnEmptyElse) {
   std::string Code = "void f() { if (false) int i = 0; }";
   std::string Expected = "void f() {  }";
   ReplaceIfStmtWithItsBody Callback("id", false);
   expectRewritten(Code, Expected,
-  id("id", ifStmt(hasCondition(cxxBoolLiteral(equals(false),
-  Callback);
+  id("id", ifStmt(hasCondition(cxxBoolLiteral(equals(false),
+  Callback);
 }
 
+TEST(RefactoringCallbacksTest, TemplateJustText) {
+  std::string Code = "void f() { int i = 1; }";
+  std::string Expected = "void f() { FOO }";
+  auto Callback = ReplaceNodeWithTemplate::create("id", "FOO");
+  EXPECT_FALSE(Callback.takeError());
+  expectRewritten(Code, Expected, id("id", declStmt()), **Callback);
+}
+
+TEST(RefactoringCallbacksTest, TemplateSimpleSubst) {
+  std::string Code = "void f() { int i = 1; }";
+  std::string Expected = "void f() { long x = 1; }";
+  auto Callback = ReplaceNodeWithTemplate::create("decl", "long x = ${init}");
+  EXPECT_FALSE(Callback.takeError());
+  expectRewritten(Code, Expected,
+  id("decl", varDecl(hasInitializer(id("init", expr(),
+  **Callback);
+}
+
+TEST(RefactoringCallbacksTest, TemplateLiteral) {
+  std::string Code = "void f() { int i = 1; }";
+  std::string Expected = "void f() { string x = \"$-1\"; }";
+  auto Callback =

[PATCH] D32309: [libcxx] [test] Resolve compiler warnings in LCM/GCD tests

2017-05-08 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal updated this revision to Diff 98205.
BillyONeal added a comment.

Resolved CR comments


https://reviews.llvm.org/D32309

Files:
  test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
  test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp

Index: test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
===
--- test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
+++ test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
@@ -11,12 +11,14 @@
 // 
 
 // template
-// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
+// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n)
 
 #include 
 #include 
+#include 
+#include 
 #include 
-#include 
+#include 
 
 constexpr struct {
   int x;
@@ -34,11 +36,19 @@
 };
 
 template 
-constexpr bool test0(Input1 in1, Input2 in2, Output out)
+constexpr bool test0(int in1, int in2, int out)
 {
-static_assert((std::is_same::value), "" );
-static_assert((std::is_same::value), "" );
-return out == std::lcm(in1, in2) ? true : (std::abort(), false);
+static_assert(std::is_same(0), static_cast(0)))>::value, "");
+static_assert(std::is_same(0), static_cast(0)))>::value, "");
+const bool result = static_cast(out) ==
+std::lcm(static_cast(in1), static_cast(in2));
+if (!result) {
+std::abort();
+}
+
+return result;
 }
 
 
@@ -101,15 +111,15 @@
 assert(do_test(non_cce));
 assert(do_test(non_cce));
 
-static_assert(do_test< int8_t>(), "");
-static_assert(do_test(), "");
-static_assert(do_test(), "");
-static_assert(do_test(), "");
+static_assert(do_test(), "");
+static_assert(do_test(), "");
+static_assert(do_test(), "");
+static_assert(do_test(), "");
 
-assert(do_test< int8_t>(non_cce));
-assert(do_test(non_cce));
-assert(do_test(non_cce));
-assert(do_test(non_cce));
+assert(do_test(non_cce));
+assert(do_test(non_cce));
+assert(do_test(non_cce));
+assert(do_test(non_cce));
 
 static_assert(do_test(), "");
 static_assert(do_test(), "");
@@ -131,9 +141,9 @@
 
 //  LWG#2837
 {
-auto res1 = std::lcm((int64_t)1234, (int32_t)-2147483648);
-(void) std::lcm(INT_MIN, 2);	// this used to trigger UBSAN
-static_assert( std::is_same::type>::value, "");
-	assert(res1 == 1324997410816LL);
+auto res1 = std::lcm(static_cast(1234), INT32_MIN);
+(void)std::lcm(INT_MIN, 2UL);	// this used to trigger UBSAN
+static_assert(std::is_same::value, "");
+assert(res1 == 1324997410816LL);
 }
 }
Index: test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
===
--- test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
+++ test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
@@ -16,8 +16,10 @@
 
 #include 
 #include 
+#include 
+#include 
 #include // for rand()
-#include 
+#include 
 
 constexpr struct {
   int x;
@@ -36,11 +38,19 @@
 
 
 template 
-constexpr bool test0(Input1 in1, Input2 in2, Output out)
+constexpr bool test0(int in1, int in2, int out)
 {
-static_assert((std::is_same::value), "" );
-static_assert((std::is_same::value), "" );
-return out == std::gcd(in1, in2) ? true : (std::abort(), false);
+static_assert(std::is_same(0), static_cast(0)))>::value, "");
+static_assert(std::is_same(0), static_cast(0)))>::value, "");
+const bool result = static_cast(out) ==
+std::gcd(static_cast(in1), static_cast(in2));
+if (!result) {
+std::abort();
+}
+
+return result;
 }
 
 
@@ -103,15 +113,15 @@
 assert(do_test(non_cce));
 assert(do_test(non_cce));
 
-static_assert(do_test< int8_t>(), "");
-static_assert(do_test(), "");
-static_assert(do_test(), "");
-static_assert(do_test(), "");
+static_assert(do_test(), "");
+static_assert(do_test(), "");
+static_assert(do_test(), "");
+static_assert(do_test(), "");
 
-assert(do_test< int8_t>(non_cce));
-assert(do_test(non_cce));
-assert(do_test(non_cce));
-assert(do_test(non_cce));
+assert(do_test(non_cce));
+assert(do_test(non_cce));
+assert(do_test(non_cce));
+assert(do_test(non_cce));
 
 static_assert(do_test(), "");
 static_assert(do_test(), "");
@@ -133,8 +143,8 @@
 
 //  LWG#2837
 {
-auto res = std::gcd((int64_t)1234, (int32_t)-2147483648);
-static_assert( std::is_same::type>::value, "");
-assert(res == 2);
+auto res = std::gcd(static_cast(1234), INT32_MIN);
+static_assert(std::is_same::value, "");
+assert(res == 2);
 }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32248: CodeGen: Cast alloca to expected address space

2017-05-08 Thread Tony Tye via Phabricator via cfe-commits
t-tye added inline comments.



Comment at: lib/CodeGen/CGDecl.cpp:1115
+  if (AddrTy->getAddressSpace() != ExpectedAddrSpace &&
+  Ty.getAddressSpace() != LangAS::opencl_constant) {
+address = Address(Builder.CreateAddrSpaceCast(Addr,

Anastasia wrote:
> Do you need to check this? I thought your change doesn't affect OpenCL 
> because alloca AS == private AS in OpenCL  and constant AS local objects are 
> treated as private const objects anyways.
Given patch D32977 that makes function local variables marked with the constant 
address space treated as static, will they ever be processed by this function 
now? If so then the extra test for opencl_constant would not be needed.


https://reviews.llvm.org/D32248



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


r302468 - [Driver] Don't enable -fsanitize-use-after-scope when ASan is disabled

2017-05-08 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Mon May  8 16:11:55 2017
New Revision: 302468

URL: http://llvm.org/viewvc/llvm-project?rev=302468&view=rev
Log:
[Driver] Don't enable -fsanitize-use-after-scope when ASan is disabled

When enabling any sanitizer, -fsanitize-use-after-scope is enabled by
default. This doesn't actually turn ASan on, because we've been getting
lucky and there are extra checks in BackendUtil that stop this from
happening.

However, this has been causing a behavior change: extra lifetime markers
are emitted in some cases where they aren't needed or expected.

Modified:
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=302468&r1=302467&r2=302468&view=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Mon May  8 16:11:55 2017
@@ -563,12 +563,11 @@ SanitizerArgs::SanitizerArgs(const ToolC
   }
 }
 
-if (Arg *A = Args.getLastArg(
-options::OPT_fsanitize_address_use_after_scope,
-options::OPT_fno_sanitize_address_use_after_scope)) {
-  AsanUseAfterScope = A->getOption().getID() ==
-  options::OPT_fsanitize_address_use_after_scope;
-}
+AsanUseAfterScope = Args.hasFlag(
+options::OPT_fsanitize_address_use_after_scope,
+options::OPT_fno_sanitize_address_use_after_scope, AsanUseAfterScope);
+  } else {
+AsanUseAfterScope = false;
   }
 
   // Parse -link-cxx-sanitizer flag.

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=302468&r1=302467&r2=302468&view=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Mon May  8 16:11:55 2017
@@ -30,7 +30,7 @@
 // RUN: %clang -target x86_64-pc-win32 -fsanitize-coverage=bb %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-COVERAGE-WIN64
 // CHECK-COVERAGE-WIN64: "--dependent-lib={{[^"]*}}ubsan_standalone-x86_64.lib"
 
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=integer %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-INTEGER
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=integer %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-INTEGER 
-implicit-check-not="-fsanitize-address-use-after-scope"
 // CHECK-INTEGER: 
"-fsanitize={{((signed-integer-overflow|unsigned-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent),?){5}"}}
 
 // RUN: %clang -fsanitize=bounds -### -fsyntax-only %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-BOUNDS


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


[PATCH] D32309: [libcxx] [test] Resolve compiler warnings in LCM/GCD tests

2017-05-08 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM, preferably with the suggested cleanups.




Comment at: test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp:146
+auto res = std::gcd(static_cast(1234), INT32_MIN);
+static_assert(std::is_same>::value, "");
 assert(res == 2);

BillyONeal wrote:
> EricWF wrote:
> > `std::common_type` here please. This test runs in C++03 where we don't have 
> > `std::foo_t`.
> C++17 library features in C++03?!? :(
> 
> OK, will fix.
> 
Sorry my bad. This test is truely C++17 only. I missed the `// UNSUPPORTED` 
line originally. Feel free to run wild with C++17 features.



Comment at: test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp:42
+constexpr bool test0(int in1, int in2, int out)
 {
+static_assert(std::is_same(in1);
auto value2 = static_cast(in2);
static_assert(std::is_same_v, "");
static_assert(std::is_same_v, "");
assert(static_cast(out) == std::gcd(value1, value2));
return true;
```

Also just use `assert` instead of `std::abort()`



Comment at: test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp:41
 {
-static_assert((std::is_same::value), "" );
-static_assert((std::is_same::value), "" );
-return out == std::lcm(in1, in2) ? true : (std::abort(), false);
+static_assert(std::is_same(0), static_cast(0)))>::value, "");

Same suggestion as on the above test.


https://reviews.llvm.org/D32309



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


[PATCH] D32574: [libcxx] [test] Fixed possible loss of data warnings in tests on amd64

2017-05-08 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal updated this revision to Diff 98214.
BillyONeal marked 4 inline comments as done.
BillyONeal edited the summary of this revision.
BillyONeal added a comment.

Instead, change the tests to pass around std::size_t instances, and explicitly
narrow when constructing the string type under test. This also allows
removal of explicit template arguments to std::min.


https://reviews.llvm.org/D32574

Files:
  test/std/strings/basic.string/string.cons/T_size_size.pass.cpp


Index: test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
===
--- test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
+++ test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
@@ -27,16 +27,17 @@
 
 template 
 void
-test(SV sv, unsigned pos, unsigned n)
+test(SV sv, std::size_t pos, std::size_t n)
 {
 typedef typename S::traits_type T;
 typedef typename S::allocator_type A;
+typedef typename S::size_type Size;
 if (pos <= sv.size())
 {
-S s2(sv, pos, n);
+S s2(sv, static_cast(pos), static_cast(n));
 LIBCPP_ASSERT(s2.__invariants());
 assert(pos <= sv.size());
-unsigned rlen = std::min(sv.size() - pos, n);
+std::size_t rlen = std::min(sv.size() - pos, n);
 assert(s2.size() == rlen);
 assert(T::compare(s2.data(), sv.data() + pos, rlen) == 0);
 assert(s2.get_allocator() == A());
@@ -47,7 +48,7 @@
 {
 try
 {
-S s2(sv, pos, n);
+S s2(sv, static_cast(pos), static_cast(n));
 assert(false);
 }
 catch (std::out_of_range&)
@@ -60,15 +61,16 @@
 
 template 
 void
-test(SV sv, unsigned pos, unsigned n, const typename S::allocator_type& a)
+test(SV sv, std::size_t pos, std::size_t n, const typename S::allocator_type& 
a)
 {
 typedef typename S::traits_type T;
+typedef typename S::size_type Size;
 if (pos <= sv.size())
 {
-S s2(sv, pos, n, a);
+S s2(sv, static_cast(pos), static_cast(n), a);
 LIBCPP_ASSERT(s2.__invariants());
 assert(pos <= sv.size());
-unsigned rlen = std::min(sv.size() - pos, n);
+std::size_t rlen = std::min(sv.size() - pos, n);
 assert(s2.size() == rlen);
 assert(T::compare(s2.data(), sv.data() + pos, rlen) == 0);
 assert(s2.get_allocator() == a);
@@ -79,7 +81,7 @@
 {
 try
 {
-S s2(sv, pos, n, a);
+S s2(sv, static_cast(pos), static_cast(n), a);
 assert(false);
 }
 catch (std::out_of_range&)


Index: test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
===
--- test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
+++ test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
@@ -27,16 +27,17 @@
 
 template 
 void
-test(SV sv, unsigned pos, unsigned n)
+test(SV sv, std::size_t pos, std::size_t n)
 {
 typedef typename S::traits_type T;
 typedef typename S::allocator_type A;
+typedef typename S::size_type Size;
 if (pos <= sv.size())
 {
-S s2(sv, pos, n);
+S s2(sv, static_cast(pos), static_cast(n));
 LIBCPP_ASSERT(s2.__invariants());
 assert(pos <= sv.size());
-unsigned rlen = std::min(sv.size() - pos, n);
+std::size_t rlen = std::min(sv.size() - pos, n);
 assert(s2.size() == rlen);
 assert(T::compare(s2.data(), sv.data() + pos, rlen) == 0);
 assert(s2.get_allocator() == A());
@@ -47,7 +48,7 @@
 {
 try
 {
-S s2(sv, pos, n);
+S s2(sv, static_cast(pos), static_cast(n));
 assert(false);
 }
 catch (std::out_of_range&)
@@ -60,15 +61,16 @@
 
 template 
 void
-test(SV sv, unsigned pos, unsigned n, const typename S::allocator_type& a)
+test(SV sv, std::size_t pos, std::size_t n, const typename S::allocator_type& a)
 {
 typedef typename S::traits_type T;
+typedef typename S::size_type Size;
 if (pos <= sv.size())
 {
-S s2(sv, pos, n, a);
+S s2(sv, static_cast(pos), static_cast(n), a);
 LIBCPP_ASSERT(s2.__invariants());
 assert(pos <= sv.size());
-unsigned rlen = std::min(sv.size() - pos, n);
+std::size_t rlen = std::min(sv.size() - pos, n);
 assert(s2.size() == rlen);
 assert(T::compare(s2.data(), sv.data() + pos, rlen) == 0);
 assert(s2.get_allocator() == a);
@@ -79,7 +81,7 @@
 {
 try
 {
-S s2(sv, pos, n, a);
+S s2(sv, static_cast(pos), static_cast(n), a);
 assert(false);
 }
 catch (std::out_of_range&)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32574: [libcxx] [test] Fixed possible loss of data warnings in tests on amd64

2017-05-08 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.

Still LGTM.


https://reviews.llvm.org/D32574



___
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-08 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs added a comment.

The current proposition could be that we only keep the first two cases, 
possibly merging in the google check for a third case (with its old name 
evoking original functionality). Separately, another check could be written 
that warns when the below mentioned memory management functions are used on not 
`TriviallyCopyable` objects.

I wonder if any of the commenters/reviewers/subscribers have any thoughts about 
this :)




Comment at: clang-tidy/misc/SuspiciousMemsetUsageCheck.cpp:21
+void SuspiciousMemsetUsageCheck::registerMatchers(MatchFinder *Finder) {
+  const auto HasCtorOrDtor =
+  eachOf(hasMethod(cxxConstructorDecl(unless(anyOf(

xazax.hun wrote:
> I think this might not be the best approach.
> 
> For example, if the constructor is compiler generated, but there is a member 
> of the class with non-trivial constructor, we still want to warn. 
> 
> E.g.:
> 
> ```
> struct X { X() { /* something nontrivial */ } };
> 
> struct Y { X x; };
> ```
> 
> Maybe we should check instead whether the class is a POD? Other alternative 
> might be something like 
> `CXXRecordDecl::hasNonTrivialDefaultConstructor`.
So, we had a discussion yesterday that I'll try to sum up here. The root of the 
problem is not exactly about constructors or the object being a POD, but rather 
about calling `memset()` on an object that is not `TriviallyCopyable`. But as 
you suggested, this holds for `memcpy()` and `memmove()` as well, and might be 
better placed in another check.


https://reviews.llvm.org/D32700



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


[PATCH] D32309: [libcxx] [test] Resolve compiler warnings in LCM/GCD tests

2017-05-08 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal added inline comments.



Comment at: test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp:42
+constexpr bool test0(int in1, int in2, int out)
 {
+static_assert(std::is_same Nit but this seems much cleaner and more readable without the casts.
> 
> ```
> auto value1 = static_cast(in1);
> auto value2 = static_cast(in2);
> static_assert(std::is_same_v, "");
> static_assert(std::is_same_v, "");
> assert(static_cast(out) == std::gcd(value1, value2));
> return true;
> ```
> 
> Also just use `assert` instead of `std::abort()`
I was under the impression the abort dance was because assert isn't constexpr.


https://reviews.llvm.org/D32309



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


[PATCH] D32309: [libcxx] [test] Resolve compiler warnings in LCM/GCD tests

2017-05-08 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp:42
+constexpr bool test0(int in1, int in2, int out)
 {
+static_assert(std::is_same EricWF wrote:
> > Nit but this seems much cleaner and more readable without the casts.
> > 
> > ```
> > auto value1 = static_cast(in1);
> > auto value2 = static_cast(in2);
> > static_assert(std::is_same_v, 
> > "");
> > static_assert(std::is_same_v, 
> > "");
> > assert(static_cast(out) == std::gcd(value1, value2));
> > return true;
> > ```
> > 
> > Also just use `assert` instead of `std::abort()`
> I was under the impression the abort dance was because assert isn't constexpr.
`assert` is constexpr for the exact same reason the `abort` dance was constexpr.

And I think somebody else was under the same misapprehension when they wrote 
this test.


https://reviews.llvm.org/D32309



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


[PATCH] D32981: [ASTImporter] Improve handling of incomplete types

2017-05-08 Thread Sean Callanan via Phabricator via cfe-commits
spyffe created this revision.

`ASTImporter` has some bugs when it's importing types that themselves come from 
an `ExternalASTSource`.  This is exposed particularly in the behavior when 
comparing complete TagDecls with forward declarations.  This patch does several 
things:

- Adds a test case making sure that conflicting forward-declarations are 
resolved correctly;
- Extends the `clang-import-test` harness to test two-level importing, so that 
we make sure we complete types when necessary; and
- Fixes a few bugs I found this way.  Failure to complete types was one; 
however, I also discovered that complete RecordDecls aren't properly added to 
the `redecls` chain for existing forward declarations.


Repository:
  rL LLVM

https://reviews.llvm.org/D32981

Files:
  include/clang/AST/ExternalASTMerger.h
  lib/AST/ASTImporter.cpp
  lib/AST/ASTStructuralEquivalence.cpp
  lib/AST/ExternalASTMerger.cpp
  test/Import/conflicting-struct/Inputs/S1.cpp
  test/Import/conflicting-struct/Inputs/S2.cpp
  test/Import/conflicting-struct/test.cpp
  tools/clang-import-test/clang-import-test.cpp

Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -42,6 +42,10 @@
 Imports("import", llvm::cl::ZeroOrMore,
 llvm::cl::desc("Path to a file containing declarations to import"));
 
+static llvm::cl::opt
+Direct("direct", llvm::cl::Optional,
+ llvm::cl::desc("Use the parsed declarations without indirection"));
+
 static llvm::cl::list
 ClangArgs("Xcc", llvm::cl::ZeroOrMore,
   llvm::cl::desc("Argument to pass to the CompilerInvocation"),
@@ -172,6 +176,14 @@
   return Ins;
 }
 
+std::unique_ptr
+BuildCompilerInstance(ArrayRef ClangArgs) {
+  std::vector ClangArgv(ClangArgs.size());
+  std::transform(ClangArgs.begin(), ClangArgs.end(), ClangArgv.begin(),
+ [](const std::string &s) -> const char * { return s.data(); });
+  return init_convenience::BuildCompilerInstance(ClangArgv);
+}
+
 std::unique_ptr
 BuildASTContext(CompilerInstance &CI, SelectorTable &ST, Builtin::Context &BC) {
   auto AST = llvm::make_unique(
@@ -205,6 +217,21 @@
   CI.getASTContext().getTranslationUnitDecl()->setHasExternalVisibleStorage();
 }
 
+std::unique_ptr BuildIndirect(std::unique_ptr &CI) {
+  std::vector ClangArgv(ClangArgs.size());
+  std::transform(ClangArgs.begin(), ClangArgs.end(), ClangArgv.begin(),
+ [](const std::string &s) -> const char * { return s.data(); });
+  std::unique_ptr IndirectCI =
+  init_convenience::BuildCompilerInstance(ClangArgv);
+  auto ST = llvm::make_unique();
+  auto BC = llvm::make_unique();
+  std::unique_ptr AST =
+  init_convenience::BuildASTContext(*IndirectCI, *ST, *BC);
+  IndirectCI->setASTContext(AST.release());
+  AddExternalSource(*IndirectCI, CI);
+  return IndirectCI;
+}
+
 llvm::Error ParseSource(const std::string &Path, CompilerInstance &CI,
 CodeGenerator &CG) {
   SourceManager &SM = CI.getSourceManager();
@@ -231,7 +258,9 @@
   std::unique_ptr AST =
   init_convenience::BuildASTContext(*CI, *ST, *BC);
   CI->setASTContext(AST.release());
-  AddExternalSource(*CI, Imports);
+  if (Imports.size()) {
+AddExternalSource(*CI, Imports);
+  }
 
   auto LLVMCtx = llvm::make_unique();
   std::unique_ptr CG =
@@ -268,12 +297,26 @@
   ImportCIs.push_back(std::move(*ImportCI));
 }
   }
+  std::vector> IndirectCIs;
+  if (!Direct) {
+for (auto &ImportCI : ImportCIs) {
+  llvm::Expected> IndirectCI =
+  BuildIndirect(ImportCI);
+  if (auto E = IndirectCI.takeError()) {
+llvm::errs() << llvm::toString(std::move(E));
+exit(-1);
+  } else {
+IndirectCIs.push_back(std::move(*IndirectCI));
+  }
+}
+  }
   llvm::Expected> ExpressionCI =
-  Parse(Expression, ImportCIs);
+  Parse(Expression, Direct ? ImportCIs : IndirectCIs);
   if (auto E = ExpressionCI.takeError()) {
 llvm::errs() << llvm::toString(std::move(E));
 exit(-1);
   } else {
 return 0;
   }
 }
+
Index: test/Import/conflicting-struct/test.cpp
===
--- /dev/null
+++ test/Import/conflicting-struct/test.cpp
@@ -0,0 +1,7 @@
+// RUN: clang-import-test --import %S/Inputs/S1.cpp --import %S/Inputs/S2.cpp -expression %s
+void expr() {
+  S MyS;
+  T MyT;
+  MyS.a = 3;
+  MyT.u.b = 2;
+}
Index: test/Import/conflicting-struct/Inputs/S2.cpp
===
--- /dev/null
+++ test/Import/conflicting-struct/Inputs/S2.cpp
@@ -0,0 +1,7 @@
+class U {
+  int b;
+};
+
+class T {
+  U u;
+};
Index: test/Import/conflicting-struct/Inputs/S1.cpp
===
--- /dev/null
+++ test/Import/conflicting-struct/Inputs/S1.cpp
@@ -0,0 +1,6 @@
+class T;
+
+cl

[PATCH] D32981: [ASTImporter] Improve handling of incomplete types

2017-05-08 Thread Sean Callanan via Phabricator via cfe-commits
spyffe updated this revision to Diff 98218.
spyffe added a comment.

Eliminated a //missing newline at end of file// error


Repository:
  rL LLVM

https://reviews.llvm.org/D32981

Files:
  include/clang/AST/ExternalASTMerger.h
  lib/AST/ASTImporter.cpp
  lib/AST/ASTStructuralEquivalence.cpp
  lib/AST/ExternalASTMerger.cpp
  test/Import/conflicting-struct/Inputs/S1.cpp
  test/Import/conflicting-struct/Inputs/S2.cpp
  test/Import/conflicting-struct/test.cpp
  tools/clang-import-test/clang-import-test.cpp

Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -42,6 +42,10 @@
 Imports("import", llvm::cl::ZeroOrMore,
 llvm::cl::desc("Path to a file containing declarations to import"));
 
+static llvm::cl::opt
+Direct("direct", llvm::cl::Optional,
+ llvm::cl::desc("Use the parsed declarations without indirection"));
+
 static llvm::cl::list
 ClangArgs("Xcc", llvm::cl::ZeroOrMore,
   llvm::cl::desc("Argument to pass to the CompilerInvocation"),
@@ -172,6 +176,14 @@
   return Ins;
 }
 
+std::unique_ptr
+BuildCompilerInstance(ArrayRef ClangArgs) {
+  std::vector ClangArgv(ClangArgs.size());
+  std::transform(ClangArgs.begin(), ClangArgs.end(), ClangArgv.begin(),
+ [](const std::string &s) -> const char * { return s.data(); });
+  return init_convenience::BuildCompilerInstance(ClangArgv);
+}
+
 std::unique_ptr
 BuildASTContext(CompilerInstance &CI, SelectorTable &ST, Builtin::Context &BC) {
   auto AST = llvm::make_unique(
@@ -205,6 +217,21 @@
   CI.getASTContext().getTranslationUnitDecl()->setHasExternalVisibleStorage();
 }
 
+std::unique_ptr BuildIndirect(std::unique_ptr &CI) {
+  std::vector ClangArgv(ClangArgs.size());
+  std::transform(ClangArgs.begin(), ClangArgs.end(), ClangArgv.begin(),
+ [](const std::string &s) -> const char * { return s.data(); });
+  std::unique_ptr IndirectCI =
+  init_convenience::BuildCompilerInstance(ClangArgv);
+  auto ST = llvm::make_unique();
+  auto BC = llvm::make_unique();
+  std::unique_ptr AST =
+  init_convenience::BuildASTContext(*IndirectCI, *ST, *BC);
+  IndirectCI->setASTContext(AST.release());
+  AddExternalSource(*IndirectCI, CI);
+  return IndirectCI;
+}
+
 llvm::Error ParseSource(const std::string &Path, CompilerInstance &CI,
 CodeGenerator &CG) {
   SourceManager &SM = CI.getSourceManager();
@@ -231,7 +258,9 @@
   std::unique_ptr AST =
   init_convenience::BuildASTContext(*CI, *ST, *BC);
   CI->setASTContext(AST.release());
-  AddExternalSource(*CI, Imports);
+  if (Imports.size()) {
+AddExternalSource(*CI, Imports);
+  }
 
   auto LLVMCtx = llvm::make_unique();
   std::unique_ptr CG =
@@ -268,12 +297,26 @@
   ImportCIs.push_back(std::move(*ImportCI));
 }
   }
+  std::vector> IndirectCIs;
+  if (!Direct) {
+for (auto &ImportCI : ImportCIs) {
+  llvm::Expected> IndirectCI =
+  BuildIndirect(ImportCI);
+  if (auto E = IndirectCI.takeError()) {
+llvm::errs() << llvm::toString(std::move(E));
+exit(-1);
+  } else {
+IndirectCIs.push_back(std::move(*IndirectCI));
+  }
+}
+  }
   llvm::Expected> ExpressionCI =
-  Parse(Expression, ImportCIs);
+  Parse(Expression, Direct ? ImportCIs : IndirectCIs);
   if (auto E = ExpressionCI.takeError()) {
 llvm::errs() << llvm::toString(std::move(E));
 exit(-1);
   } else {
 return 0;
   }
 }
+
Index: test/Import/conflicting-struct/test.cpp
===
--- /dev/null
+++ test/Import/conflicting-struct/test.cpp
@@ -0,0 +1,7 @@
+// RUN: clang-import-test --import %S/Inputs/S1.cpp --import %S/Inputs/S2.cpp -expression %s
+void expr() {
+  S MyS;
+  T MyT;
+  MyS.a = 3;
+  MyT.u.b = 2;
+}
Index: test/Import/conflicting-struct/Inputs/S2.cpp
===
--- /dev/null
+++ test/Import/conflicting-struct/Inputs/S2.cpp
@@ -0,0 +1,7 @@
+class U {
+  int b;
+};
+
+class T {
+  U u;
+};
Index: test/Import/conflicting-struct/Inputs/S1.cpp
===
--- /dev/null
+++ test/Import/conflicting-struct/Inputs/S1.cpp
@@ -0,0 +1,6 @@
+class T;
+
+class S {
+  T *t;
+  int a;
+};
Index: lib/AST/ExternalASTMerger.cpp
===
--- lib/AST/ExternalASTMerger.cpp
+++ lib/AST/ExternalASTMerger.cpp
@@ -178,3 +178,9 @@
 }
   });
 }
+
+void ExternalASTMerger::CompleteType(TagDecl *Tag) {
+  SmallVector Result;
+  FindExternalLexicalDecls(Tag, [](Decl::Kind) { return true; }, Result);
+  Tag->setHasExternalLexicalStorage(false);
+}
Index: lib/AST/ASTStructuralEquivalence.cpp
===
--- lib/AST/ASTStructural

[PATCH] D32309: [libcxx] [test] Resolve compiler warnings in LCM/GCD tests

2017-05-08 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal updated this revision to Diff 98219.
BillyONeal marked 2 inline comments as done.
BillyONeal edited the summary of this revision.
BillyONeal added a comment.

Do Eric's suggestions.


https://reviews.llvm.org/D32309

Files:
  test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
  test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp

Index: test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
===
--- test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
+++ test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
@@ -11,12 +11,14 @@
 // 
 
 // template
-// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
+// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n)
 
 #include 
 #include 
+#include 
+#include 
 #include 
-#include 
+#include 
 
 constexpr struct {
   int x;
@@ -34,21 +36,24 @@
 };
 
 template 
-constexpr bool test0(Input1 in1, Input2 in2, Output out)
+constexpr bool test0(int in1, int in2, int out)
 {
-static_assert((std::is_same::value), "" );
-static_assert((std::is_same::value), "" );
-return out == std::lcm(in1, in2) ? true : (std::abort(), false);
+auto value1 = static_cast(in1);
+auto value2 = static_cast(in2);
+static_assert(std::is_same_v, "");
+static_assert(std::is_same_v, "");
+assert(static_cast(out) == std::lcm(value1, value2));
+return true;
 }
 
 
 template 
 constexpr bool do_test(int = 0)
 {
-using S1 = typename std::make_signed::type;
-using S2 = typename std::make_signed::type;
-using U1 = typename std::make_unsigned::type;
-using U2 = typename std::make_unsigned::type;
+using S1 = std::make_signed_t;
+using S2 = std::make_signed_t;
+using U1 = std::make_unsigned_t;
+using U2 = std::make_unsigned_t;
 bool accumulate = true;
 for (auto TC : Cases) {
 { // Test with two signed types
@@ -101,15 +106,15 @@
 assert(do_test(non_cce));
 assert(do_test(non_cce));
 
-static_assert(do_test< int8_t>(), "");
-static_assert(do_test(), "");
-static_assert(do_test(), "");
-static_assert(do_test(), "");
+static_assert(do_test(), "");
+static_assert(do_test(), "");
+static_assert(do_test(), "");
+static_assert(do_test(), "");
 
-assert(do_test< int8_t>(non_cce));
-assert(do_test(non_cce));
-assert(do_test(non_cce));
-assert(do_test(non_cce));
+assert(do_test(non_cce));
+assert(do_test(non_cce));
+assert(do_test(non_cce));
+assert(do_test(non_cce));
 
 static_assert(do_test(), "");
 static_assert(do_test(), "");
@@ -131,9 +136,9 @@
 
 //  LWG#2837
 {
-auto res1 = std::lcm((int64_t)1234, (int32_t)-2147483648);
-(void) std::lcm(INT_MIN, 2);	// this used to trigger UBSAN
-static_assert( std::is_same::type>::value, "");
-	assert(res1 == 1324997410816LL);
+auto res1 = std::lcm(static_cast(1234), INT32_MIN);
+(void)std::lcm(INT_MIN, 2UL);	// this used to trigger UBSAN
+static_assert(std::is_same_v, "");
+assert(res1 == 1324997410816LL);
 }
 }
Index: test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
===
--- test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
+++ test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
@@ -16,8 +16,10 @@
 
 #include 
 #include 
+#include 
+#include 
 #include // for rand()
-#include 
+#include 
 
 constexpr struct {
   int x;
@@ -36,21 +38,24 @@
 
 
 template 
-constexpr bool test0(Input1 in1, Input2 in2, Output out)
+constexpr bool test0(int in1, int in2, int out)
 {
-static_assert((std::is_same::value), "" );
-static_assert((std::is_same::value), "" );
-return out == std::gcd(in1, in2) ? true : (std::abort(), false);
+auto value1 = static_cast(in1);
+auto value2 = static_cast(in2);
+static_assert(std::is_same_v, "");
+static_assert(std::is_same_v, "");
+assert(static_cast(out) == std::gcd(value1, value2));
+return true;
 }
 
 
 template 
 constexpr bool do_test(int = 0)
 {
-using S1 = typename std::make_signed::type;
-using S2 = typename std::make_signed::type;
-using U1 = typename std::make_unsigned::type;
-using U2 = typename std::make_unsigned::type;
+using S1 = std::make_signed_t;
+using S2 = std::make_signed_t;
+using U1 = std::make_unsigned_t;
+using U2 = std::make_unsigned_t;
 bool accumulate = true;
 for (auto TC : Cases) {
 { // Test with two signed types
@@ -103,15 +108,15 @@
 assert(do_test(non_cce));
 assert(do_test(non_cce));
 
-static_assert(do_test< int8_t>(), "");
-static_assert(do_test(), "");
-static_assert(do_test(), "");
-static_assert(do_test(), "");
+static_assert(do_test(), "");
+static_assert(do_test(), "");
+static_assert(do_test(), "");
+static_assert(do_test(), "");
 
-assert(do_test< int8_t>(non_cce));
-assert(do_test(non_cce));
- 

[libcxx] r302472 - Resolve integer overflow warnings in GCD and LCM tests

2017-05-08 Thread Billy Robert O'Neal III via cfe-commits
Author: bion
Date: Mon May  8 16:52:05 2017
New Revision: 302472

URL: http://llvm.org/viewvc/llvm-project?rev=302472&view=rev
Log:
Resolve integer overflow warnings in GCD and LCM tests

lcm.pass.cpp:
19: Update headers to that actually used in the test.
41: test0 was triggering narrowing warnings for all callers, because the
inputs were always ints, but some of the explicit template arguments were
smaller than that. Instead, have this function accept ints and static_cast
explicitly to the types we want before calling std::lcm.
47: Replace unnecessary ternary.
55: Use foo_t instead of typename foo<>::type
111/116: intX_t were not std::qualified but only  headers were included.
141: C1XX has a bug where it interprets 2147483648 as unsigned int. Then the
negation trips "negation of unsigned value, result still unsigned" warnings.
Perma-workaround this issue by saying INT_MIN, which better documents the
intended behavior and avoids triggering warnings on C1XX.

gcd.pass.cpp:
Same changes as lcm.pass.cpp but for GCD.

Modified:
libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp

Modified: 
libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp?rev=302472&r1=302471&r2=302472&view=diff
==
--- libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp 
(original)
+++ libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp Mon 
May  8 16:52:05 2017
@@ -16,8 +16,10 @@
 
 #include 
 #include 
+#include 
+#include 
 #include // for rand()
-#include 
+#include 
 
 constexpr struct {
   int x;
@@ -36,21 +38,24 @@ constexpr struct {
 
 
 template 
-constexpr bool test0(Input1 in1, Input2 in2, Output out)
+constexpr bool test0(int in1, int in2, int out)
 {
-static_assert((std::is_same::value), 
"" );
-static_assert((std::is_same::value), 
"" );
-return out == std::gcd(in1, in2) ? true : (std::abort(), false);
+auto value1 = static_cast(in1);
+auto value2 = static_cast(in2);
+static_assert(std::is_same_v, 
"");
+static_assert(std::is_same_v, 
"");
+assert(static_cast(out) == std::gcd(value1, value2));
+return true;
 }
 
 
 template 
 constexpr bool do_test(int = 0)
 {
-using S1 = typename std::make_signed::type;
-using S2 = typename std::make_signed::type;
-using U1 = typename std::make_unsigned::type;
-using U2 = typename std::make_unsigned::type;
+using S1 = std::make_signed_t;
+using S2 = std::make_signed_t;
+using U1 = std::make_unsigned_t;
+using U2 = std::make_unsigned_t;
 bool accumulate = true;
 for (auto TC : Cases) {
 { // Test with two signed types
@@ -103,15 +108,15 @@ int main()
 assert(do_test(non_cce));
 assert(do_test(non_cce));
 
-static_assert(do_test< int8_t>(), "");
-static_assert(do_test(), "");
-static_assert(do_test(), "");
-static_assert(do_test(), "");
-
-assert(do_test< int8_t>(non_cce));
-assert(do_test(non_cce));
-assert(do_test(non_cce));
-assert(do_test(non_cce));
+static_assert(do_test(), "");
+static_assert(do_test(), "");
+static_assert(do_test(), "");
+static_assert(do_test(), "");
+
+assert(do_test(non_cce));
+assert(do_test(non_cce));
+assert(do_test(non_cce));
+assert(do_test(non_cce));
 
 static_assert(do_test(), "");
 static_assert(do_test(), "");
@@ -133,8 +138,8 @@ int main()
 
 //  LWG#2837
 {
-auto res = std::gcd((int64_t)1234, (int32_t)-2147483648);
-static_assert( std::is_same::type>::value, "");
-assert(res == 2);
+auto res = std::gcd(static_cast(1234), INT32_MIN);
+static_assert(std::is_same_v, "");
+assert(res == 2);
 }
 }

Modified: 
libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp?rev=302472&r1=302471&r2=302472&view=diff
==
--- libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp 
(original)
+++ libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp Mon 
May  8 16:52:05 2017
@@ -11,12 +11,14 @@
 // 
 
 // template
-// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
+// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n)
 
 #include 
 #include 
+#include 
+#include 
 #include 
-#include 
+#include 
 
 constexpr struct {
   int x;
@@ -34,21 +36,24 @@ constexpr struct {
 };
 
 template 
-constexpr bool test0(Input1 in1, Input2 in2, Output out)
+constexpr bool test0(int in1, int in2, int out)
 {
-static_assert((std::is_same::value), "" );
-static_assert((std::is_same::value), "" );
-

[libcxx] r302473 - Fix possible loss of data warnings on amd64

2017-05-08 Thread Billy Robert O'Neal III via cfe-commits
Author: bion
Date: Mon May  8 16:54:53 2017
New Revision: 302473

URL: http://llvm.org/viewvc/llvm-project?rev=302473&view=rev
Log:
Fix possible loss of data warnings on amd64

In T_size_size.pass, there is an explicit template argument to std::min to ask
for unsigned, to avoid type deduction errors. However, C1XX' warnings still
hate this use, because a 64 bit value (a size_t) is being passed to a function
accepting an unsigned (a 32 bit value).

Instead, change the tests to pass around std::size_t instances, and explicitly
narrow when constructing the string type under test. This also allows
removal of explicit template arguments to std::min.

Modified:
libcxx/trunk/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp?rev=302473&r1=302472&r2=302473&view=diff
==
--- libcxx/trunk/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp 
(original)
+++ libcxx/trunk/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp 
Mon May  8 16:54:53 2017
@@ -27,16 +27,17 @@
 
 template 
 void
-test(SV sv, unsigned pos, unsigned n)
+test(SV sv, std::size_t pos, std::size_t n)
 {
 typedef typename S::traits_type T;
 typedef typename S::allocator_type A;
+typedef typename S::size_type Size;
 if (pos <= sv.size())
 {
-S s2(sv, pos, n);
+S s2(sv, static_cast(pos), static_cast(n));
 LIBCPP_ASSERT(s2.__invariants());
 assert(pos <= sv.size());
-unsigned rlen = std::min(sv.size() - pos, n);
+std::size_t rlen = std::min(sv.size() - pos, n);
 assert(s2.size() == rlen);
 assert(T::compare(s2.data(), sv.data() + pos, rlen) == 0);
 assert(s2.get_allocator() == A());
@@ -47,7 +48,7 @@ test(SV sv, unsigned pos, unsigned n)
 {
 try
 {
-S s2(sv, pos, n);
+S s2(sv, static_cast(pos), static_cast(n));
 assert(false);
 }
 catch (std::out_of_range&)
@@ -60,15 +61,16 @@ test(SV sv, unsigned pos, unsigned n)
 
 template 
 void
-test(SV sv, unsigned pos, unsigned n, const typename S::allocator_type& a)
+test(SV sv, std::size_t pos, std::size_t n, const typename S::allocator_type& 
a)
 {
 typedef typename S::traits_type T;
+typedef typename S::size_type Size;
 if (pos <= sv.size())
 {
-S s2(sv, pos, n, a);
+S s2(sv, static_cast(pos), static_cast(n), a);
 LIBCPP_ASSERT(s2.__invariants());
 assert(pos <= sv.size());
-unsigned rlen = std::min(sv.size() - pos, n);
+std::size_t rlen = std::min(sv.size() - pos, n);
 assert(s2.size() == rlen);
 assert(T::compare(s2.data(), sv.data() + pos, rlen) == 0);
 assert(s2.get_allocator() == a);
@@ -79,7 +81,7 @@ test(SV sv, unsigned pos, unsigned n, co
 {
 try
 {
-S s2(sv, pos, n, a);
+S s2(sv, static_cast(pos), static_cast(n), a);
 assert(false);
 }
 catch (std::out_of_range&)


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


[PATCH] D32248: CodeGen: Cast alloca to expected address space

2017-05-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 18 inline comments as done.
yaxunl added inline comments.



Comment at: lib/CodeGen/CGDecl.cpp:1115
+  if (AddrTy->getAddressSpace() != ExpectedAddrSpace &&
+  Ty.getAddressSpace() != LangAS::opencl_constant) {
+address = Address(Builder.CreateAddrSpaceCast(Addr,

t-tye wrote:
> Anastasia wrote:
> > Do you need to check this? I thought your change doesn't affect OpenCL 
> > because alloca AS == private AS in OpenCL  and constant AS local objects 
> > are treated as private const objects anyways.
> Given patch D32977 that makes function local variables marked with the 
> constant address space treated as static, will they ever be processed by this 
> function now? If so then the extra test for opencl_constant would not be 
> needed.
Will remove this.



Comment at: test/CodeGenCXX/amdgcn-automatic-variable.cpp:25
+  // CHECK: store i32 2, i32* %[[r1]]
+  int lv1;
+  lv1 = 1;

Anastasia wrote:
> I am wondering if all these different test cases are really needed. Are we 
> testing any different program paths from the patch?
> 
> Also would it make sense to add a test case with an object in an AS different 
> to 0 (i.e. with `__attribute__((address_space(n)))`)
I think at least I should cover the typical use cases of auto var.

I will add a test for __attribute__((address_space(n


https://reviews.llvm.org/D32248



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


[libcxx] r302474 - Refactor RAII guards to aid upcoming Windows locale changes.

2017-05-08 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May  8 17:02:43 2017
New Revision: 302474

URL: http://llvm.org/viewvc/llvm-project?rev=302474&view=rev
Log:
Refactor  RAII guards to aid upcoming Windows locale changes.

Previously  used std::unique_ptr, 
locale-mgmt-function>
as a scope guard for (A) creating new locales, and (B) setting the thread 
specific locale
in RAII safe manner.

However using unique_ptr has some problems, first it requires that locale_t is 
a pointer
type, which may not be the case (Windows will need a non-pointer locale_t type 
that emulates _locale_t).

The second problem is that users of the guards had to supply the locale 
management function to the custom
deleter at every call site. However these locale management functions don't 
exist natively Windows, making
a good Windows implementation of locale more difficult.

This patch creates distinct and simply RAII guards that replace unique_ptr. 
These guards handle calling
the correct locale management function so that callers don't have too. This 
simplification will
aid in upcoming Windows fixes.

Modified:
libcxx/trunk/include/__bsd_locale_fallbacks.h
libcxx/trunk/include/__locale
libcxx/trunk/include/locale
libcxx/trunk/src/locale.cpp
libcxx/trunk/src/support/win32/locale_win32.cpp

Modified: libcxx/trunk/include/__bsd_locale_fallbacks.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__bsd_locale_fallbacks.h?rev=302474&r1=302473&r2=302474&view=diff
==
--- libcxx/trunk/include/__bsd_locale_fallbacks.h (original)
+++ libcxx/trunk/include/__bsd_locale_fallbacks.h Mon May  8 17:02:43 2017
@@ -19,27 +19,24 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-typedef _VSTD::remove_pointer::type __use_locale_struct;
-typedef _VSTD::unique_ptr<__use_locale_struct, decltype(&uselocale)> 
__locale_raii;
-
 inline _LIBCPP_ALWAYS_INLINE
 decltype(MB_CUR_MAX) __libcpp_mb_cur_max_l(locale_t __l)
 {
-__locale_raii __current( uselocale(__l), uselocale );
+__libcpp_locale_guard __current(__l);
 return MB_CUR_MAX;
 }
 
 inline _LIBCPP_ALWAYS_INLINE
 wint_t __libcpp_btowc_l(int __c, locale_t __l)
 {
-__locale_raii __current( uselocale(__l), uselocale );
+__libcpp_locale_guard __current(__l);
 return btowc(__c);
 }
 
 inline _LIBCPP_ALWAYS_INLINE
 int __libcpp_wctob_l(wint_t __c, locale_t __l)
 {
-__locale_raii __current( uselocale(__l), uselocale );
+__libcpp_locale_guard __current(__l);
 return wctob(__c);
 }
 
@@ -47,14 +44,14 @@ inline _LIBCPP_ALWAYS_INLINE
 size_t __libcpp_wcsnrtombs_l(char *__dest, const wchar_t **__src, size_t __nwc,
  size_t __len, mbstate_t *__ps, locale_t __l)
 {
-__locale_raii __current( uselocale(__l), uselocale );
+__libcpp_locale_guard __current(__l);
 return wcsnrtombs(__dest, __src, __nwc, __len, __ps);
 }
 
 inline _LIBCPP_ALWAYS_INLINE
 size_t __libcpp_wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t 
__l)
 {
-__locale_raii __current( uselocale(__l), uselocale );
+__libcpp_locale_guard __current(__l);
 return wcrtomb(__s, __wc, __ps);
 }
 
@@ -62,7 +59,7 @@ inline _LIBCPP_ALWAYS_INLINE
 size_t __libcpp_mbsnrtowcs_l(wchar_t * __dest, const char **__src, size_t 
__nms,
   size_t __len, mbstate_t *__ps, locale_t __l)
 {
-__locale_raii __current( uselocale(__l), uselocale );
+__libcpp_locale_guard __current(__l);
 return mbsnrtowcs(__dest, __src, __nms, __len, __ps);
 }
 
@@ -70,28 +67,28 @@ inline _LIBCPP_ALWAYS_INLINE
 size_t __libcpp_mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n,
mbstate_t *__ps, locale_t __l)
 {
-__locale_raii __current( uselocale(__l), uselocale );
+__libcpp_locale_guard __current(__l);
 return mbrtowc(__pwc, __s, __n, __ps);
 }
 
 inline _LIBCPP_ALWAYS_INLINE
 int __libcpp_mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, 
locale_t __l)
 {
-__locale_raii __current( uselocale(__l), uselocale );
+__libcpp_locale_guard __current(__l);
 return mbtowc(__pwc, __pmb, __max);
 }
 
 inline _LIBCPP_ALWAYS_INLINE
 size_t __libcpp_mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, 
locale_t __l)
 {
-__locale_raii __current( uselocale(__l), uselocale );
+__libcpp_locale_guard __current(__l);
 return mbrlen(__s, __n, __ps);
 }
 
 inline _LIBCPP_ALWAYS_INLINE
 lconv *__libcpp_localeconv_l(locale_t __l)
 {
-__locale_raii __current( uselocale(__l), uselocale );
+__libcpp_locale_guard __current(__l);
 return localeconv();
 }
 
@@ -99,7 +96,7 @@ inline _LIBCPP_ALWAYS_INLINE
 size_t __libcpp_mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len,
  mbstate_t *__ps, locale_t __l)
 {
-__locale_raii __current( uselocale(__l), uselocale );
+__libcpp_locale_guard __current(__l);
 return mbsrtowcs(__dest, __src, __len, __ps);
 }
 
@@ -107,7 +104,7 @@ inline
 int __libcpp_snprintf_l(char *__s, siz

r302476 - Update testcase for upstream LLVM changes.

2017-05-08 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon May  8 17:44:00 2017
New Revision: 302476

URL: http://llvm.org/viewvc/llvm-project?rev=302476&view=rev
Log:
Update testcase for upstream LLVM changes.

Modified:
cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp

Modified: cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp?rev=302476&r1=302475&r2=302476&view=diff
==
--- cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp Mon May  8 
17:44:00 2017
@@ -12,8 +12,10 @@ void Derived::VariadicFunction(...) { }
 
 // CHECK: define void @_ZN7Derived16VariadicFunctionEz({{.*}} !dbg 
![[SP:[0-9]+]]
 // CHECK: ret void, !dbg ![[LOC:[0-9]+]]
-// CHECK-LABEL: define void @_ZT{{.+}}N7Derived16VariadicFunctionEz(
-// CHECK: ret void, !dbg ![[LOC:[0-9]+]]
+// CHECK: define void @_ZT{{.+}}N7Derived16VariadicFunctionEz({{.*}} !dbg 
![[SP_I:[0-9]+]]
+// CHECK: ret void, !dbg ![[LOC_I:[0-9]+]]
 //
 // CHECK: ![[SP]] = distinct !DISubprogram(name: "VariadicFunction"
 // CHECK: ![[LOC]] = !DILocation({{.*}}scope: ![[SP]])
+// CHECK: ![[SP_I]] = distinct !DISubprogram(name: "VariadicFunction"
+// CHECK: ![[LOC_I]] = !DILocation({{.*}}scope: ![[SP_I]])


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


[PATCH] D32984: [Sema] Implement Core 2094: Trivial copy/move constructor for class with volatile member

2017-05-08 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.

This patch implements 
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2094 which reverts 
Core 496.


https://reviews.llvm.org/D32984

Files:
  lib/AST/Type.cpp
  test/CXX/drs/dr20xx.cpp
  test/CXX/drs/dr4xx.cpp
  test/SemaCXX/type-traits.cpp


Index: test/SemaCXX/type-traits.cpp
===
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -1256,7 +1256,7 @@
   int t33[F(__is_trivially_copyable(ExtDefaulted))];
 
   int t34[T(__is_trivially_copyable(const int))];
-  int t35[F(__is_trivially_copyable(volatile int))];
+  int t35[T(__is_trivially_copyable(volatile int))];
 }
 
 struct CStruct {
Index: test/CXX/drs/dr4xx.cpp
===
--- test/CXX/drs/dr4xx.cpp
+++ test/CXX/drs/dr4xx.cpp
@@ -1202,16 +1202,15 @@
   long n2 = s2;
 }
 
-namespace dr496 { // dr496: no
+namespace dr496 { // dr496: reverted by dr2095 in 5.0
   struct A { int n; };
   struct B { volatile int n; };
   int check1[ __is_trivially_copyable(const int) ? 1 : -1];
-  int check2[!__is_trivially_copyable(volatile int) ? 1 : -1];
+  // FIXME: This checks the dr2095 behavior, not dr496
+  int check2[ __is_trivially_copyable(volatile int) ? 1 : -1];
   int check3[ __is_trivially_constructible(A, const A&) ? 1 : -1];
-  // FIXME: This is wrong.
   int check4[ __is_trivially_constructible(B, const B&) ? 1 : -1];
   int check5[ __is_trivially_assignable(A, const A&) ? 1 : -1];
-  // FIXME: This is wrong.
   int check6[ __is_trivially_assignable(B, const B&) ? 1 : -1];
 }
 
Index: test/CXX/drs/dr20xx.cpp
===
--- /dev/null
+++ test/CXX/drs/dr20xx.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors \
+// RUN:-Wno-variadic-macros -Wno-c11-extensions
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+
+// expected-no-diagnostics
+
+#if __cplusplus < 201103L
+#define static_assert(...) _Static_assert(__VA_ARGS__)
+#endif
+
+namespace dr2094 { // dr2094: 5.0
+  struct A { int n; };
+  struct B { volatile int n; };
+  static_assert(__is_trivially_copyable(volatile int), "");
+  static_assert(__is_trivially_copyable(const volatile int), "");
+  static_assert(__is_trivially_copyable(const volatile int[]), "");
+  static_assert(__is_trivially_copyable(A), "");
+  static_assert(__is_trivially_copyable(volatile A), "");
+  static_assert(__is_trivially_copyable(const volatile A), "");
+  static_assert(__is_trivially_copyable(const volatile A[]), "");
+  static_assert(__is_trivially_copyable(B), "");
+
+  static_assert(__is_trivially_constructible(A, A const&), "");
+  static_assert(__is_trivially_constructible(B, B const&), "");
+
+  static_assert(__is_trivially_assignable(A, const A&), "");
+  static_assert(__is_trivially_assignable(B, const B&), "");
+}
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -2114,18 +2114,15 @@
   if (hasNonTrivialObjCLifetime())
 return false;
 
-  // C++11 [basic.types]p9
+  // C++11 [basic.types]p9 - See Core 2094
   //   Scalar types, trivially copyable class types, arrays of such types, and
-  //   non-volatile const-qualified versions of these types are collectively
+  //   cv-qualified versions of these types are collectively
   //   called trivially copyable types.
 
   QualType CanonicalType = getCanonicalType();
   if (CanonicalType->isDependentType())
 return false;
 
-  if (CanonicalType.isVolatileQualified())
-return false;
-
   // Return false for incomplete types after skipping any incomplete array 
types
   // which are expressly allowed by the standard and thus our API.
   if (CanonicalType->isIncompleteType())


Index: test/SemaCXX/type-traits.cpp
===
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -1256,7 +1256,7 @@
   int t33[F(__is_trivially_copyable(ExtDefaulted))];
 
   int t34[T(__is_trivially_copyable(const int))];
-  int t35[F(__is_trivially_copyable(volatile int))];
+  int t35[T(__is_trivially_copyable(volatile int))];
 }
 
 struct CStruct {
Index: test/CXX/drs/dr4xx.cpp
===
--- test/CXX/drs/dr4xx.cpp
+++ test/CXX/drs/dr4xx.cpp
@@ -1202,16 +1202,15 @@
   long n2 = s2;
 }
 
-namespace dr496 { // dr496: no
+namespace dr496 { // dr496: reverted by dr2095 in 5.0
   struct A { int n; };
   struct B { volatile int n; };
  

[PATCH] D32984: [Sema] Implement Core 2094: Trivial copy/move constructor for class with volatile member

2017-05-08 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 98229.
EricWF added a comment.

- Use `sup` instead of `reverted by` to match style of other DRs.


https://reviews.llvm.org/D32984

Files:
  lib/AST/Type.cpp
  test/CXX/drs/dr20xx.cpp
  test/CXX/drs/dr4xx.cpp
  test/SemaCXX/type-traits.cpp


Index: test/SemaCXX/type-traits.cpp
===
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -1256,7 +1256,7 @@
   int t33[F(__is_trivially_copyable(ExtDefaulted))];
 
   int t34[T(__is_trivially_copyable(const int))];
-  int t35[F(__is_trivially_copyable(volatile int))];
+  int t35[T(__is_trivially_copyable(volatile int))];
 }
 
 struct CStruct {
Index: test/CXX/drs/dr4xx.cpp
===
--- test/CXX/drs/dr4xx.cpp
+++ test/CXX/drs/dr4xx.cpp
@@ -1202,16 +1202,15 @@
   long n2 = s2;
 }
 
-namespace dr496 { // dr496: no
+namespace dr496 { // dr496: sup dr2095 in 5.0
   struct A { int n; };
   struct B { volatile int n; };
   int check1[ __is_trivially_copyable(const int) ? 1 : -1];
-  int check2[!__is_trivially_copyable(volatile int) ? 1 : -1];
+  // FIXME: This checks the dr2095 behavior, not dr496
+  int check2[ __is_trivially_copyable(volatile int) ? 1 : -1];
   int check3[ __is_trivially_constructible(A, const A&) ? 1 : -1];
-  // FIXME: This is wrong.
   int check4[ __is_trivially_constructible(B, const B&) ? 1 : -1];
   int check5[ __is_trivially_assignable(A, const A&) ? 1 : -1];
-  // FIXME: This is wrong.
   int check6[ __is_trivially_assignable(B, const B&) ? 1 : -1];
 }
 
Index: test/CXX/drs/dr20xx.cpp
===
--- /dev/null
+++ test/CXX/drs/dr20xx.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors \
+// RUN:-Wno-variadic-macros -Wno-c11-extensions
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+
+// expected-no-diagnostics
+
+#if __cplusplus < 201103L
+#define static_assert(...) _Static_assert(__VA_ARGS__)
+#endif
+
+namespace dr2094 { // dr2094: 5.0
+  struct A { int n; };
+  struct B { volatile int n; };
+  static_assert(__is_trivially_copyable(volatile int), "");
+  static_assert(__is_trivially_copyable(const volatile int), "");
+  static_assert(__is_trivially_copyable(const volatile int[]), "");
+  static_assert(__is_trivially_copyable(A), "");
+  static_assert(__is_trivially_copyable(volatile A), "");
+  static_assert(__is_trivially_copyable(const volatile A), "");
+  static_assert(__is_trivially_copyable(const volatile A[]), "");
+  static_assert(__is_trivially_copyable(B), "");
+
+  static_assert(__is_trivially_constructible(A, A const&), "");
+  static_assert(__is_trivially_constructible(B, B const&), "");
+
+  static_assert(__is_trivially_assignable(A, const A&), "");
+  static_assert(__is_trivially_assignable(B, const B&), "");
+}
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -2114,18 +2114,15 @@
   if (hasNonTrivialObjCLifetime())
 return false;
 
-  // C++11 [basic.types]p9
+  // C++11 [basic.types]p9 - See Core 2094
   //   Scalar types, trivially copyable class types, arrays of such types, and
-  //   non-volatile const-qualified versions of these types are collectively
+  //   cv-qualified versions of these types are collectively
   //   called trivially copyable types.
 
   QualType CanonicalType = getCanonicalType();
   if (CanonicalType->isDependentType())
 return false;
 
-  if (CanonicalType.isVolatileQualified())
-return false;
-
   // Return false for incomplete types after skipping any incomplete array 
types
   // which are expressly allowed by the standard and thus our API.
   if (CanonicalType->isIncompleteType())


Index: test/SemaCXX/type-traits.cpp
===
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -1256,7 +1256,7 @@
   int t33[F(__is_trivially_copyable(ExtDefaulted))];
 
   int t34[T(__is_trivially_copyable(const int))];
-  int t35[F(__is_trivially_copyable(volatile int))];
+  int t35[T(__is_trivially_copyable(volatile int))];
 }
 
 struct CStruct {
Index: test/CXX/drs/dr4xx.cpp
===
--- test/CXX/drs/dr4xx.cpp
+++ test/CXX/drs/dr4xx.cpp
@@ -1202,16 +1202,15 @@
   long n2 = s2;
 }
 
-namespace dr496 { // dr496: no
+namespace dr496 { // dr496: sup dr2095 in 5.0
   struct A { int n; };
   struct B { volatile int n; };
   int check1[ __is_triviall

[PATCH] D32984: [Sema] Implement Core 2094: Trivial copy/move constructor for class with volatile member

2017-05-08 Thread Richard Smith via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: test/CXX/drs/dr4xx.cpp:1205
 
-namespace dr496 { // dr496: no
+namespace dr496 { // dr496: reverted by dr2095 in 5.0
   struct A { int n; };

Write this as "dr496: sup 2094" and then rerun the `make_cxx_dr_status` script 
in www/ to regenerate cxx_dr_status.html



Comment at: test/CXX/drs/dr4xx.cpp:1209
   int check1[ __is_trivially_copyable(const int) ? 1 : -1];
-  int check2[!__is_trivially_copyable(volatile int) ? 1 : -1];
+  // FIXME: This checks the dr2095 behavior, not dr496
+  int check2[ __is_trivially_copyable(volatile int) ? 1 : -1];

2095 -> 2094? Also, why FIXME?


https://reviews.llvm.org/D32984



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


[PATCH] D32886: [asan] A clang flag to enable ELF globals-gc

2017-05-08 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc accepted this revision.
pcc added a comment.

LGTM

Unfortunate, but I guess this is in the same category as things like 
`-fsized-deallocation`.




Comment at: lib/Driver/SanitizerArgs.cpp:573
+
+// This is a workaround for a bug in gold and enabled by default for 
non-ELF
+// targets.

Maybe include a binutils PR reference so that we can remove this eventually?



Comment at: lib/Driver/SanitizerArgs.cpp:729
+CmdArgs.push_back(
+Args.MakeArgString("-fsanitize-address-globals-dead-stripping"));
+

I think you don't need MakeArgString for string literals.


Repository:
  rL LLVM

https://reviews.llvm.org/D32886



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


[PATCH] D32984: [Sema] Implement Core 2094: Trivial copy/move constructor for class with volatile member

2017-05-08 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 98234.
EricWF marked 2 inline comments as done.
EricWF added a comment.

- Fix incorrect issue number.
- Regenerate issue list.


https://reviews.llvm.org/D32984

Files:
  lib/AST/Type.cpp
  test/CXX/drs/dr20xx.cpp
  test/CXX/drs/dr4xx.cpp
  test/SemaCXX/type-traits.cpp
  www/cxx_dr_status.html

Index: www/cxx_dr_status.html
===
--- www/cxx_dr_status.html
+++ www/cxx_dr_status.html
@@ -589,7 +589,7 @@
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#92";>92
-WP
+CD4
 Should exception-specifications be part of the type system?
 Clang 4 (C++17 onwards)
   
@@ -935,11 +935,11 @@
 Accessibility and ambiguity
 N/A
   
-  
-http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#150";>150
-open
+  
+http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#150";>150
+DR
 Template template parameters and default arguments
-Not resolved
+Unknown
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#151";>151
@@ -1310,7 +1310,7 @@
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#212";>212
-DR
+CD4
 Implicit instantiation is not described clearly enough
 Unknown
   
@@ -1466,7 +1466,7 @@
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#238";>238
-DR
+CD4
 Precision and accuracy constraints on floating point
 Unknown
   
@@ -1490,7 +1490,7 @@
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#242";>242
-DR
+CD4
 Interpretation of old-style casts
 Unknown
   
@@ -2019,7 +2019,7 @@
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#330";>330
-DRWP
+CD4
 Qualification conversions and pointers to arrays of pointers
 Unknown
   
@@ -2397,7 +2397,7 @@
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#393";>393
-DRWP
+CD4
 Pointer to array of unknown bound in template argument list in parameter
 Unknown
   
@@ -3017,7 +3017,7 @@
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#496";>496
 CD3
 Is a volatile-qualified type really a POD?
-No
+Superseded by dr2094
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#497";>497
@@ -3587,7 +3587,7 @@
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#591";>591
-DRWP
+CD4
 When a dependent base class is the current instantiation
 No
   
@@ -3695,7 +3695,7 @@
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#609";>609
-DRWP
+CD4
 What is a “top-level” cv-qualifier?
 Unknown
   
@@ -5735,7 +5735,7 @@
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#987";>987
-DRWP
+CD4
 Which declarations introduce namespace members?
 Unknown
   
@@ -5939,7 +5939,7 @@
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1021";>1021
-DRWP
+CD4
 Definitions of namespace members
 Unknown
   
@@ -6509,7 +6509,7 @@
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1116";>1116
-DRWP
+CD4
 Aliasing of union members
 Unknown
   
@@ -7295,7 +7295,7 @@
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1247";>1247
-DRWP
+CD4
 Restriction on alias name appearing in type-id
 Unknown
   
@@ -7457,7 +7457,7 @@
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1274";>1274
-DRWP
+CD4
 Common nonterminal for expression and braced-init-list
 Unknown
   
@@ -7517,7 +7517,7 @@
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1284";>1284
-DR
+CD4
 Should the lifetime of an array be independent of that of its elements?
 Unknown
   
@@ -7565,7 +7565,7 @@
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1292";>1292
-DRWP
+CD4
 Dependent calls with braced-init-lists containing a pack expansion
 Unknown
   
@@ -7667,7 +7667,7 @@
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1309";>1309
-DRWP
+CD4
 Incorrect note regarding lookup of a member of the current instantiation
 Unknown
   
@@ -7703,7 +7703,7 @@
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1315";>1315
-DR
+CD4
 Restrictions on non-type template arguments in partial specializations
 Partial
   
@@ -7841,7 +7841,7 @@
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1338";>1338
-DRWP
+CD4
 Aliasing and allocation functions
 Unknown
   
@@ -7870,8 +7870,8 @@
 Not resolved
   
   
-http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1343";>1343
-tentatively ready
+http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.h

[libcxx] r302488 - Fix GCC 7 test failures.

2017-05-08 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May  8 19:00:00 2017
New Revision: 302488

URL: http://llvm.org/viewvc/llvm-project?rev=302488&view=rev
Log:
Fix GCC 7 test failures.

This patch fixes the test failures and unexpected passes that occur
when testing against GCC 7. Specifically:

* don't mark __gcd as always inline because it's a recursive function. GCC 
diagnoses this.
* don't XFAIL the aligned allocation tests. GCC 7 supports them but not the 
-faligned-allocation option.
* Work around gcc.gnu.org/PR78489 in variants constructors.

Modified:
libcxx/trunk/include/experimental/numeric
libcxx/trunk/include/numeric
libcxx/trunk/include/variant

libcxx/trunk/test/std/experimental/utilities/meta/meta.type.synop/meta.unary.prop.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp

Modified: libcxx/trunk/include/experimental/numeric
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/numeric?rev=302488&r1=302487&r2=302488&view=diff
==
--- libcxx/trunk/include/experimental/numeric (original)
+++ libcxx/trunk/include/experimental/numeric Mon May  8 19:00:00 2017
@@ -66,11 +66,11 @@ struct __abs<_Result, _Source, false> {
 
 
 template
-_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
-_Tp __gcd(_Tp __m, _Tp __n)
+_LIBCPP_CONSTEXPR _LIBCPP_HIDDEN
+inline _Tp __gcd(_Tp __m, _Tp __n)
 {
 static_assert((!is_signed<_Tp>::value), "" );
-return __n == 0 ? __m : __gcd<_Tp>(__n, __m % __n);
+return __n == 0 ? __m : _VSTD_LFTS_V2::__gcd<_Tp>(__n, __m % __n);
 }
 
 
@@ -84,8 +84,9 @@ gcd(_Tp __m, _Up __n)
 static_assert((!is_same::type, bool>::value), 
"Second argument to gcd cannot be bool" );
 using _Rp = common_type_t<_Tp,_Up>;
 using _Wp = make_unsigned_t<_Rp>;
-return static_cast<_Rp>(__gcd(static_cast<_Wp>(__abs<_Rp, _Tp>()(__m)),
-  static_cast<_Wp>(__abs<_Rp, _Up>()(__n;
+return static_cast<_Rp>(_VSTD_LFTS_V2::__gcd(
+  static_cast<_Wp>(__abs<_Rp, _Tp>()(__m)),
+  static_cast<_Wp>(__abs<_Rp, _Up>()(__n;
 }
 
 template
@@ -100,7 +101,7 @@ lcm(_Tp __m, _Up __n)
 return 0;
 
 using _Rp = common_type_t<_Tp,_Up>;
-_Rp __val1 = __abs<_Rp, _Tp>()(__m) / gcd(__m, __n);
+_Rp __val1 = __abs<_Rp, _Tp>()(__m) / _VSTD_LFTS_V2::gcd(__m, __n);
 _Rp __val2 = __abs<_Rp, _Up>()(__n);
 _LIBCPP_ASSERT((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow 
in lcm");
 return __val1 * __val2;

Modified: libcxx/trunk/include/numeric
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/numeric?rev=302488&r1=302487&r2=302488&view=diff
==
--- libcxx/trunk/include/numeric (original)
+++ libcxx/trunk/include/numeric Mon May  8 19:00:00 2017
@@ -222,11 +222,11 @@ struct __abs<_Result, _Source, false> {
 
 
 template
-_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR _LIBCPP_HIDDEN
 _Tp __gcd(_Tp __m, _Tp __n)
 {
 static_assert((!is_signed<_Tp>::value), "");
-return __n == 0 ? __m : __gcd<_Tp>(__n, __m % __n);
+return __n == 0 ? __m : _VSTD::__gcd<_Tp>(__n, __m % __n);
 }
 
 
@@ -240,8 +240,9 @@ gcd(_Tp __m, _Up __n)
 static_assert((!is_same::type, bool>::value), 
"Second argument to gcd cannot be bool" );
 using _Rp = common_type_t<_Tp,_Up>;
 using _Wp = make_unsigned_t<_Rp>;
-return static_cast<_Rp>(__gcd(static_cast<_Wp>(__abs<_Rp, _Tp>()(__m)),
-  static_cast<_Wp>(__abs<_Rp, _Up>()(__n;
+return static_cast<_Rp>(_VSTD::__gcd(
+static_cast<_Wp>(__abs<_Rp, _Tp>()(__m)),
+static_cast<_Wp>(__abs<_Rp, _Up>()(__n;
 }
 
 template
@@ -256,7 +257,7 @@ lcm(_Tp __m, _Up __n)
 return 0;
 
 usin

LLVM buildmaster will be updated and restarted tonight

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


[libcxxabi] r302489 - XFAIL noexcept member function throw/catch test under GCC.

2017-05-08 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May  8 19:11:02 2017
New Revision: 302489

URL: http://llvm.org/viewvc/llvm-project?rev=302489&view=rev
Log:
XFAIL noexcept member function throw/catch test under GCC.

I'm still not exactly sure why the test fails, but I suspect it's
a bug in GCC. More investigation needed.

Modified:
libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp

Modified: libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp?rev=302489&r1=302488&r2=302489&view=diff
==
--- libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp (original)
+++ libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp Mon May  8 
19:11:02 2017
@@ -11,6 +11,10 @@
 // clause?
 // UNSUPPORTED: libcxxabi-no-exceptions, libcxxabi-no-noexcept-function-type
 
+// GCC 7 and 8 support noexcept function types but this test still fails.
+// This is likely a bug in their implementation. Investigation needed.
+// XFAIL: gcc-7, gcc-8
+
 #include 
 
 struct X {


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


r302490 - Rename a method. NFC.

2017-05-08 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Mon May  8 19:12:33 2017
New Revision: 302490

URL: http://llvm.org/viewvc/llvm-project?rev=302490&view=rev
Log:
Rename a method. NFC.

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

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=302490&r1=302489&r2=302490&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Mon May  8 19:12:33 2017
@@ -89,14 +89,14 @@ struct BinOpInfo {
   }
 
   /// Check if the binop computes a division or a remainder.
-  bool isDivisionLikeOperation() const {
+  bool isDivremOp() const {
 return Opcode == BO_Div || Opcode == BO_Rem || Opcode == BO_DivAssign ||
Opcode == BO_RemAssign;
   }
 
   /// Check if the binop can result in an integer division by zero.
   bool mayHaveIntegerDivisionByZero() const {
-if (isDivisionLikeOperation())
+if (isDivremOp())
   if (auto *CI = dyn_cast(RHS))
 return CI->isZero();
 return true;
@@ -104,7 +104,7 @@ struct BinOpInfo {
 
   /// Check if the binop can result in a float division by zero.
   bool mayHaveFloatDivisionByZero() const {
-if (isDivisionLikeOperation())
+if (isDivremOp())
   if (auto *CFP = dyn_cast(RHS))
 return CFP->isZero();
 return true;


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


r302491 - [Modules] Allow umbrella frameworks to define private submodules for subframeworks

2017-05-08 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon May  8 19:41:38 2017
New Revision: 302491

URL: http://llvm.org/viewvc/llvm-project?rev=302491&view=rev
Log:
[Modules] Allow umbrella frameworks to define private submodules for 
subframeworks

In r298391 we fixed the umbrella framework model to work when submodules
named "Private" are used. This complements the work by allowing the
umbrella framework model to work in general.

rdar://problem/31790067

Added:
cfe/trunk/test/Modules/Inputs/MainA.framework/
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/

cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/

cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/B.h

cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/Sub.h

cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/

cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/BPriv.h

cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/SubPriv.h
cfe/trunk/test/Modules/Inputs/MainA.framework/Headers/
cfe/trunk/test/Modules/Inputs/MainA.framework/Headers/A.h
cfe/trunk/test/Modules/Inputs/MainA.framework/Headers/Main.h
cfe/trunk/test/Modules/Inputs/MainA.framework/Modules/
cfe/trunk/test/Modules/Inputs/MainA.framework/Modules/module.modulemap

cfe/trunk/test/Modules/Inputs/MainA.framework/Modules/module.private.modulemap
cfe/trunk/test/Modules/Inputs/MainA.framework/PrivateHeaders/
cfe/trunk/test/Modules/Inputs/MainA.framework/PrivateHeaders/APriv.h
cfe/trunk/test/Modules/Inputs/MainA.framework/PrivateHeaders/MainPriv.h
Modified:
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/test/Modules/find-privateheaders.m

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=302491&r1=302490&r2=302491&view=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Mon May  8 19:41:38 2017
@@ -1913,8 +1913,10 @@ void ModuleMapParser::parseHeaderDecl(MM
 // 'framework module FrameworkName.Private', since a 
'Private.Framework'
 // does not usually exist. However, since both are currently widely 
used
 // for private modules, make sure we find the right path in both cases.
-RelativePathName.resize(ActiveModule->IsFramework ? 0
-  : 
RelativePathLength);
+if (ActiveModule->IsFramework && ActiveModule->Name == "Private")
+  RelativePathName.clear();
+else
+  RelativePathName.resize(RelativePathLength);
 FullPathName.resize(FullPathLength);
 llvm::sys::path::append(RelativePathName, "PrivateHeaders",
 Header.FileName);

Added: 
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/B.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/B.h?rev=302491&view=auto
==
--- 
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/B.h
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/B.h
 Mon May  8 19:41:38 2017
@@ -0,0 +1 @@
+// B.h

Added: 
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/Sub.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/Sub.h?rev=302491&view=auto
==
--- 
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/Sub.h
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/Sub.h
 Mon May  8 19:41:38 2017
@@ -0,0 +1,2 @@
+// Sub.h
+#import "B.h"

Added: 
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/BPriv.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/BPriv.h?rev=302491&view=auto
==
--- 
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/BPriv.h
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/BPriv.h
 Mon May  8 19:41:38 2017
@@ -0,0 +1 @@
+// BPriv.h

Added: 
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/SubPriv.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHead

r302492 - [XRay] Add __xray_customeevent(...) as a clang-supported builtin

2017-05-08 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Mon May  8 19:45:40 2017
New Revision: 302492

URL: http://llvm.org/viewvc/llvm-project?rev=302492&view=rev
Log:
[XRay] Add __xray_customeevent(...) as a clang-supported builtin

Summary:
We define the `__xray_customeevent` builtin that gets translated to
IR calls to the correct intrinsic. The default implementation of this is
a no-op function. The codegen side of this follows the following logic:

- When `-fxray-instrument` is not provided in the driver, we elide all
calls to `__xray_customevent`.
- When `-fxray-instrument` is enabled and a function is marked as "never
instrumented", we elide all calls to `__xray_customevent` in that
function; if either marked as "always instrumented" or subject to
threshold-based instrumentation, we emit a call to the
`llvm.xray.customevent` intrinsic from LLVM for each
`__xray_customevent` occurrence in the function.

This change depends on D27503 (to land in LLVM first).

Reviewers: echristo, rsmith

Subscribers: mehdi_amini, pelikan, lrl, cfe-commits

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

Added:
cfe/trunk/test/CodeGen/xray-customevent.cpp
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=302492&r1=302491&r2=302492&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Mon May  8 19:45:40 2017
@@ -1409,6 +1409,9 @@ LANGBUILTIN(to_private, "v*v*", "tn", OC
 BUILTIN(__builtin_os_log_format_buffer_size, "zcC*.", "p:0:nut")
 BUILTIN(__builtin_os_log_format, "v*v*cC*.", "p:0:nt")
 
+// Builtins for XRay
+BUILTIN(__xray_customevent, "vcC*z", "")
+
 #undef BUILTIN
 #undef LIBBUILTIN
 #undef LANGBUILTIN

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=302492&r1=302491&r2=302492&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon May  8 19:45:40 2017
@@ -2769,6 +2769,32 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 return RValue::get(ConstantInt::get(ConvertType(E->getType()),
 Layout.size().getQuantity()));
   }
+
+  case Builtin::BI__xray_customevent: {
+if (!ShouldXRayInstrumentFunction())
+  return RValue::getIgnored();
+if (const auto *XRayAttr = CurFuncDecl->getAttr()) {
+  if (XRayAttr->neverXRayInstrument())
+return RValue::getIgnored();
+}
+Function *F = CGM.getIntrinsic(Intrinsic::xray_customevent);
+auto FTy = F->getFunctionType();
+auto Arg0 = E->getArg(0);
+auto Arg0Val = EmitScalarExpr(Arg0);
+auto Arg0Ty = Arg0->getType();
+auto PTy0 = FTy->getParamType(0);
+if (PTy0 != Arg0Val->getType()) {
+  if (Arg0Ty->isArrayType())
+Arg0Val = EmitArrayToPointerDecay(Arg0).getPointer();
+  else
+Arg0Val = Builder.CreatePointerCast(Arg0Val, PTy0);
+}
+auto Arg1 = EmitScalarExpr(E->getArg(1));
+auto PTy1 = FTy->getParamType(1);
+if (PTy1 != Arg1->getType())
+  Arg1 = Builder.CreateTruncOrBitCast(Arg1, PTy1);
+return RValue::get(Builder.CreateCall(F, {Arg0Val, Arg1}));
+  }
   }
 
   // If this is an alias for a lib function (e.g. __builtin_sin), emit

Added: cfe/trunk/test/CodeGen/xray-customevent.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xray-customevent.cpp?rev=302492&view=auto
==
--- cfe/trunk/test/CodeGen/xray-customevent.cpp (added)
+++ cfe/trunk/test/CodeGen/xray-customevent.cpp Mon May  8 19:45:40 2017
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fxray-instrument -x c++ -std=c++11 -triple 
x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: @_Z16alwaysInstrumentv
+[[clang::xray_always_instrument]] void alwaysInstrument() {
+  static constexpr char kPhase[] = "instrument";
+  __xray_customevent(kPhase, 10);
+  // CHECK: call void @llvm.xray.customevent(i8*{{.*}}, i32 10)
+}
+
+// CHECK-LABEL: @_Z15neverInstrumentv
+[[clang::xray_never_instrument]] void neverInstrument() {
+  static constexpr char kPhase[] = "never";
+  __xray_customevent(kPhase, 5);
+  // CHECK-NOT: call void @llvm.xray.customevent(i8*{{.*}}, i32 5)
+}
+
+// CHECK-LABEL: @_Z21conditionalInstrumenti
+[[clang::xray_always_instrument]] void conditionalInstrument(int v) {
+  static constexpr char kTrue[] = "true";
+  static constexpr char kUntrue[] = "untrue";
+  if (v % 2)
+__xray_customevent(kTrue, 4);
+  else
+__xray_customevent(kUntrue, 6);
+
+  // CHECK: call void @llvm.xray.customevent(i8*{{.*}}, i32 4)
+  // CHECK: call void @llvm.xray.customevent(i8*{{.*}},

[PATCH] D30018: [XRay] Add __xray_customeevent(...) as a clang-supported builtin

2017-05-08 Thread Dean Michael Berris via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
dberris marked an inline comment as done.
Closed by commit rL302492: [XRay] Add __xray_customeevent(...) as a 
clang-supported builtin (authored by dberris).

Changed prior to commit:
  https://reviews.llvm.org/D30018?vs=98129&id=98239#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30018

Files:
  cfe/trunk/include/clang/Basic/Builtins.def
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/test/CodeGen/xray-customevent.cpp


Index: cfe/trunk/include/clang/Basic/Builtins.def
===
--- cfe/trunk/include/clang/Basic/Builtins.def
+++ cfe/trunk/include/clang/Basic/Builtins.def
@@ -1409,6 +1409,9 @@
 BUILTIN(__builtin_os_log_format_buffer_size, "zcC*.", "p:0:nut")
 BUILTIN(__builtin_os_log_format, "v*v*cC*.", "p:0:nt")
 
+// Builtins for XRay
+BUILTIN(__xray_customevent, "vcC*z", "")
+
 #undef BUILTIN
 #undef LIBBUILTIN
 #undef LANGBUILTIN
Index: cfe/trunk/test/CodeGen/xray-customevent.cpp
===
--- cfe/trunk/test/CodeGen/xray-customevent.cpp
+++ cfe/trunk/test/CodeGen/xray-customevent.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fxray-instrument -x c++ -std=c++11 -triple 
x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: @_Z16alwaysInstrumentv
+[[clang::xray_always_instrument]] void alwaysInstrument() {
+  static constexpr char kPhase[] = "instrument";
+  __xray_customevent(kPhase, 10);
+  // CHECK: call void @llvm.xray.customevent(i8*{{.*}}, i32 10)
+}
+
+// CHECK-LABEL: @_Z15neverInstrumentv
+[[clang::xray_never_instrument]] void neverInstrument() {
+  static constexpr char kPhase[] = "never";
+  __xray_customevent(kPhase, 5);
+  // CHECK-NOT: call void @llvm.xray.customevent(i8*{{.*}}, i32 5)
+}
+
+// CHECK-LABEL: @_Z21conditionalInstrumenti
+[[clang::xray_always_instrument]] void conditionalInstrument(int v) {
+  static constexpr char kTrue[] = "true";
+  static constexpr char kUntrue[] = "untrue";
+  if (v % 2)
+__xray_customevent(kTrue, 4);
+  else
+__xray_customevent(kUntrue, 6);
+
+  // CHECK: call void @llvm.xray.customevent(i8*{{.*}}, i32 4)
+  // CHECK: call void @llvm.xray.customevent(i8*{{.*}}, i32 6)
+}
Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -2769,6 +2769,32 @@
 return RValue::get(ConstantInt::get(ConvertType(E->getType()),
 Layout.size().getQuantity()));
   }
+
+  case Builtin::BI__xray_customevent: {
+if (!ShouldXRayInstrumentFunction())
+  return RValue::getIgnored();
+if (const auto *XRayAttr = CurFuncDecl->getAttr()) {
+  if (XRayAttr->neverXRayInstrument())
+return RValue::getIgnored();
+}
+Function *F = CGM.getIntrinsic(Intrinsic::xray_customevent);
+auto FTy = F->getFunctionType();
+auto Arg0 = E->getArg(0);
+auto Arg0Val = EmitScalarExpr(Arg0);
+auto Arg0Ty = Arg0->getType();
+auto PTy0 = FTy->getParamType(0);
+if (PTy0 != Arg0Val->getType()) {
+  if (Arg0Ty->isArrayType())
+Arg0Val = EmitArrayToPointerDecay(Arg0).getPointer();
+  else
+Arg0Val = Builder.CreatePointerCast(Arg0Val, PTy0);
+}
+auto Arg1 = EmitScalarExpr(E->getArg(1));
+auto PTy1 = FTy->getParamType(1);
+if (PTy1 != Arg1->getType())
+  Arg1 = Builder.CreateTruncOrBitCast(Arg1, PTy1);
+return RValue::get(Builder.CreateCall(F, {Arg0Val, Arg1}));
+  }
   }
 
   // If this is an alias for a lib function (e.g. __builtin_sin), emit


Index: cfe/trunk/include/clang/Basic/Builtins.def
===
--- cfe/trunk/include/clang/Basic/Builtins.def
+++ cfe/trunk/include/clang/Basic/Builtins.def
@@ -1409,6 +1409,9 @@
 BUILTIN(__builtin_os_log_format_buffer_size, "zcC*.", "p:0:nut")
 BUILTIN(__builtin_os_log_format, "v*v*cC*.", "p:0:nt")
 
+// Builtins for XRay
+BUILTIN(__xray_customevent, "vcC*z", "")
+
 #undef BUILTIN
 #undef LIBBUILTIN
 #undef LANGBUILTIN
Index: cfe/trunk/test/CodeGen/xray-customevent.cpp
===
--- cfe/trunk/test/CodeGen/xray-customevent.cpp
+++ cfe/trunk/test/CodeGen/xray-customevent.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fxray-instrument -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: @_Z16alwaysInstrumentv
+[[clang::xray_always_instrument]] void alwaysInstrument() {
+  static constexpr char kPhase[] = "instrument";
+  __xray_customevent(kPhase, 10);
+  // CHECK: call void @llvm.xray.customevent(i8*{{.*}}, i32 10)
+}
+
+// CHECK-LABEL: @_Z15neverInstrumentv
+[[clang::xray_never_instrument]] void neverInstrument() {
+  static constexpr char kPhase[] = "never";
+  __xray_customevent(kPhase, 5);
+  // CHECK-NOT: call void 

[PATCH] D30018: [XRay] Add __xray_customeevent(...) as a clang-supported builtin

2017-05-08 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris marked an inline comment as done.
dberris added a comment.

Thanks @rnk!




Comment at: lib/CodeGen/CGBuiltin.cpp:2748
+if (const auto *XRayAttr =
+this->CurFuncDecl->getAttr()) {
+  if (XRayAttr->neverXRayInstrument())

rnk wrote:
> rnk wrote:
> > Don't need `this->`
> Do you think `this->` is necessary?
Nope, just force of habit (and an aid to autocomplete) :D


https://reviews.llvm.org/D30018



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


r302495 - [CodeGen][ObjC] Emit @objc_retain at -O0 for variables captured by

2017-05-08 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon May  8 20:20:05 2017
New Revision: 302495

URL: http://llvm.org/viewvc/llvm-project?rev=302495&view=rev
Log:
[CodeGen][ObjC] Emit @objc_retain at -O0 for variables captured by
blocks.

r302270 made changes to avoid emitting clang.arc.use at -O0 and instead
emit @objc_release. We also have to emit @objc_retain for the captured
variable at -O0 to match the @objc_release instead of just storing the
pointer to the capture field.

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/test/CodeGenObjC/arc-blocks.m
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=302495&r1=302494&r2=302495&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Mon May  8 20:20:05 2017
@@ -878,7 +878,8 @@ llvm::Value *CodeGenFunction::EmitBlockL
 
 // If type is const-qualified, copy the value into the block field.
 } else if (type.isConstQualified() &&
-   type.getObjCLifetime() == Qualifiers::OCL_Strong) {
+   type.getObjCLifetime() == Qualifiers::OCL_Strong &&
+   CGM.getCodeGenOpts().OptimizationLevel != 0) {
   llvm::Value *value = Builder.CreateLoad(src, "captured");
   Builder.CreateStore(value, blockField);
 

Modified: cfe/trunk/test/CodeGenObjC/arc-blocks.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-blocks.m?rev=302495&r1=302494&r2=302495&view=diff
==
--- cfe/trunk/test/CodeGenObjC/arc-blocks.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc-blocks.m Mon May  8 20:20:05 2017
@@ -752,6 +752,16 @@ void test19(void (^b)(void)) {
 // CHECK-NEXT: call void @objc_release(i8* [[X]])
 // CHECK-NEXT: ret void
 
+// CHECK-UNOPT-LABEL: define void @test20(
+// CHECK-UNOPT: [[XADDR:%.*]] = alloca i8*
+// CHECK-UNOPT-NEXT: [[BLOCK:%.*]] = alloca <[[BLOCKTY:.*]]>
+// CHECK-UNOPT: [[CAPTUREFIELD:%.*]] = getelementptr inbounds <[[BLOCKTY]]>, 
<[[BLOCKTY]]>* [[BLOCK]], i32 0, i32 5
+// CHECK-UNOPT: [[BLOCKCAPTURED:%.*]] = getelementptr inbounds <[[BLOCKTY]]>, 
<[[BLOCKTY]]>* [[BLOCK]], i32 0, i32 5
+// CHECK-UNOPT: [[CAPTURED:%.*]] = load i8*, i8** [[XADDR]]
+// CHECK-UNOPT: [[RETAINED:%.*]] = call i8* @objc_retain(i8* [[CAPTURED]])
+// CHECK-UNOPT: store i8* [[RETAINED]], i8** [[BLOCKCAPTURED]]
+// CHECK-UNOPT: call void @objc_storeStrong(i8** [[CAPTUREFIELD]], i8* null)
+
 // CHECK-LABEL: define internal void @__copy_helper_block
 // CHECK: [[BLOCKSOURCE:%.*]] = bitcast i8* %{{.*}} to <[[BLOCKTY]]>*
 // CHECK: [[CAPTUREFIELD:%.*]] = getelementptr inbounds <[[BLOCKTY]]>, 
<[[BLOCKTY]]>* [[BLOCKSOURCE]], i32 0, i32 5

Modified: cfe/trunk/test/CodeGenObjC/arc-foreach.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-foreach.m?rev=302495&r1=302494&r2=302495&view=diff
==
--- cfe/trunk/test/CodeGenObjC/arc-foreach.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc-foreach.m Mon May  8 20:20:05 2017
@@ -68,7 +68,8 @@ void test0(NSArray *array) {
 // CHECK-LP64:  [[D0:%.*]] = getelementptr inbounds [[BLOCK_T]], 
[[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
 // CHECK-LP64:  [[T0:%.*]] = getelementptr inbounds [[BLOCK_T]], 
[[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
 // CHECK-LP64-NEXT: [[T1:%.*]] = load i8*, i8** [[X]]
-// CHECK-LP64-NEXT: store i8* [[T1]], i8** [[T0]]
+// CHECK-LP64-NEXT: [[T2:%.*]] = call i8* @objc_retain(i8* [[T1]])
+// CHECK-LP64-NEXT: store i8* [[T2]], i8** [[T0]]
 // CHECK-LP64-NEXT: [[BLOCK1:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]]
 // CHECK-LP64-NEXT: call void @use_block(void ()* [[BLOCK1]])
 // CHECK-LP64-NEXT: call void @objc_storeStrong(i8** [[D0]], i8* null)
@@ -209,7 +210,8 @@ 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]], align 8
+// CHECK-LP64: [[T2:%.*]] = bitcast [[TY]]* [[T1]] to i8*
+// CHECK-LP64: call i8* @objc_retain(i8* [[T2]])
 
 // CHECK-LP64-OPT-LABEL: define internal void @"\01-[I1 foo2]"(
 // CHECK-LP64-OPT: [[TY:%.*]]* %self


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


[PATCH] D32988: [libc++] Refactor Windows support headers.

2017-05-08 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.

This patch refactors and tries to remove as much of the Windows support headers 
as possible. This is needed because they currently introduce super weird 
include cycles and dependencies between STL and libc headers.

The changes in this patch are:

- remove `support/win32/support.h` completely. The required parts have either 
been moved into `support/win32/msvc_support.h` (for `MSVC` only helpers not 
needed by Clang), or directly into their respective `foo.h` headers.

- Combine `locale_win32.h` and `locale_mgmt_win32.h` into a single headers, 
this header should only be included within `__locale` or `locale` to avoid 
include cycles.

- Remove the unneeded parts of `limits_win32.h` and re-name it to 
`limits_msvc_win32.h` since it's only needed by Clang.

I've tested this patch using Clang on Windows, but I suspect it might 
technically regress our non-existent support for MSVC. Is somebody able to 
double check?

This refactor is needed to support upcoming fixes to `` on Windows.


https://reviews.llvm.org/D32988

Files:
  include/__config
  include/algorithm
  include/ctype.h
  include/limits
  include/stdio.h
  include/stdlib.h
  include/support/win32/limits_msvc_win32.h
  include/support/win32/limits_win32.h
  include/support/win32/locale_mgmt_win32.h
  include/support/win32/locale_win32.h
  include/support/win32/msvc_support.h
  include/support/win32/support.h
  include/wchar.h
  src/string.cpp
  src/support/runtime/exception_pointer_msvc.ipp

Index: src/support/runtime/exception_pointer_msvc.ipp
===
--- src/support/runtime/exception_pointer_msvc.ipp
+++ src/support/runtime/exception_pointer_msvc.ipp
@@ -10,6 +10,7 @@
 
 #include 
 #include 
+#include  // for _CRTIMP2_PURE
 
 _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCreate(_Out_ void*);
 _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrDestroy(_Inout_ void*);
Index: src/string.cpp
===
--- src/string.cpp
+++ src/string.cpp
@@ -13,9 +13,6 @@
 #include "cerrno"
 #include "limits"
 #include "stdexcept"
-#ifdef _LIBCPP_MSVCRT
-#include "support/win32/support.h"
-#endif // _LIBCPP_MSVCRT
 #include 
 
 _LIBCPP_BEGIN_NAMESPACE_STD
@@ -430,7 +427,7 @@
 #ifndef _LIBCPP_MSVCRT
 return swprintf;
 #else
-return static_cast(swprintf);
+return static_cast(_snwprintf);
 #endif
 }
 
Index: include/wchar.h
===
--- include/wchar.h
+++ include/wchar.h
@@ -166,9 +166,12 @@
 }
 #endif
 
-#if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT) || defined(__MINGW32__))
-extern "C++" {
-#include  // pull in *swprintf defines
+#if defined(__cplusplus) && defined(_LIBCPP_MSVCRT)
+extern "C" {
+size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
+  size_t nmc, size_t len, mbstate_t *__restrict ps);
+size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
+  size_t nwc, size_t len, mbstate_t *__restrict ps);
 }  // extern "C++"
 #endif  // __cplusplus && _LIBCPP_MSVCRT
 
Index: include/support/win32/support.h
===
--- include/support/win32/support.h
+++ /dev/null
@@ -1,177 +0,0 @@
-// -*- C++ -*-
-//===--- support/win32/support.h --===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-#ifndef _LIBCPP_SUPPORT_WIN32_SUPPORT_H
-#define _LIBCPP_SUPPORT_WIN32_SUPPORT_H
-
-// Functions and constants used in libc++ that
-// are missing from the Windows C library.
-
-#include  // mbstate_t
-#include  // va_ macros
-// "builtins" not implemented here for Clang or GCC as they provide
-// implementations. Assuming required for elsewhere else, certainly MSVC.
-#if defined(_LIBCPP_COMPILER_MSVC)
-#include 
-#endif
-#define swprintf _snwprintf
-#define vswprintf _vsnwprintf
-
-#ifndef NOMINMAX
-#define NOMINMAX
-#endif
-
-// The mingw headers already define these as static.
-#ifndef __MINGW32__
-extern "C" {
-
-int vasprintf(char **sptr, const char *__restrict fmt, va_list ap);
-int asprintf(char **sptr, const char *__restrict fmt, ...);
-size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
-  size_t nmc, size_t len, mbstate_t *__restrict ps);
-size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
-  size_t nwc, size_t len, mbstate_t *__restrict ps);
-}
-#endif // __MINGW32__
-
-#if defined(_LIBCPP_COMPILER_MSVC)
-
-// Bit builtin's make these assumptions when calling _BitScanForward/Reverse
-// etc. These assumptions are expected to be true for Win32/Win64 which this
-//

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

2017-05-08 Thread Akira Hatanaka via cfe-commits
Thank you for the fix. I committed a follow-up patch in r302495, which makes 
IRGen emit @objc_retain at -O0.

> On May 5, 2017, at 11:39 AM, Saleem Abdulrasool via cfe-commits 
>  wrote:
> 
> 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

[PATCH] D32989: Don't indent JavaScript IIFEs

2017-05-08 Thread Dan Beam via Phabricator via cfe-commits
danbeam created this revision.
Herald added a subscriber: klimek.

Because IIFEs[1] are often used like an anonymous namespace around large
sections of JavaScript code, it's useful not to indent to them (which
effectively reduces the column limit by the indent amount needlessly).

It's also common for developers to wrap these around entire files or
libraries.  When adopting clang-format, changing the indent entire file
can reduce the usefulness of the blame annotations.

  

Before:
(function() {

  // clang-format pushes stuff to here

})();

After:
(function() {
// clang-format pushes stuff to here
})();

[1] https://en.wikipedia.org/wiki/Immediately-invoked_function_expression


https://reviews.llvm.org/D32989

Files:
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/UnwrappedLineParser.h
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -367,6 +367,21 @@
"});");
 }
 
+TEST_F(FormatTestJS, IIFE) {
+  verifyFormat("(function() {\n"
+   "var a = 1;\n"
+   "}())");
+  verifyFormat("(function() {\n"
+   "var b = 2;\n"
+   "})()");
+  verifyFormat("(function() {\n"
+   "var c = 3;\n"
+   "})();");
+  verifyFormat("(function() {\n"
+   "var d = 4;\n"
+   "}());");
+}
+
 TEST_F(FormatTestJS, GoogModules) {
   verifyFormat("goog.module('this.is.really.absurdly.long');",
getGoogleJSStyleWithColumns(40));
Index: lib/Format/UnwrappedLineParser.h
===
--- lib/Format/UnwrappedLineParser.h
+++ lib/Format/UnwrappedLineParser.h
@@ -125,6 +125,7 @@
   void nextToken();
   const FormatToken *getPreviousToken();
   void readToken();
+  bool isIIFE() const;
 
   // Decides which comment tokens should be added to the current line and which
   // should be added as comments before the next token.
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -493,15 +493,16 @@
   FormatTok->BlockKind = BK_Block;
   nextToken();
   {
-bool GoogScope =
-Style.Language == FormatStyle::LK_JavaScript && isGoogScope(*Line);
+bool SkipIndent =
+Style.Language == FormatStyle::LK_JavaScript &&
+(isGoogScope(*Line) || isIIFE());
 ScopedLineState LineState(*this);
 ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack,
 /*MustBeDeclaration=*/false);
-Line->Level += GoogScope ? 0 : 1;
+Line->Level += SkipIndent ? 0 : 1;
 parseLevel(/*HasOpeningBrace=*/true);
 flushComments(isOnNewLine(*FormatTok));
-Line->Level -= GoogScope ? 0 : 1;
+Line->Level -= SkipIndent ? 0 : 1;
   }
   nextToken();
 }
@@ -2342,5 +2343,30 @@
   }
 }
 
+bool UnwrappedLineParser::isIIFE() const {
+  // Look for the start of an immediately invoked anonymous function.
+  // https://en.wikipedia.org/wiki/Immediately-invoked_function_expression
+  // This is commonly done in JavaScript to create a new, anonymous scope.
+  // Example: (function() { ... })()
+  // FIXME: check for the end invocation or alternate ways to start function
+  // expressions?
+  if (Line->Tokens.size() < 5)
+return false;
+  auto I = Line->Tokens.begin();
+  if (I->Tok->isNot(tok::l_paren))
+return false;
+  ++I;
+  if (I->Tok->isNot(Keywords.kw_function))
+return false;
+  ++I;
+  if (I->Tok->isNot(tok::l_paren))
+return false;
+  ++I;
+  if (I->Tok->isNot(tok::r_paren))
+return false;
+  ++I;
+  return I->Tok->is(tok::l_brace);
+}
+
 } // end namespace format
 } // end namespace clang


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -367,6 +367,21 @@
"});");
 }
 
+TEST_F(FormatTestJS, IIFE) {
+  verifyFormat("(function() {\n"
+   "var a = 1;\n"
+   "}())");
+  verifyFormat("(function() {\n"
+   "var b = 2;\n"
+   "})()");
+  verifyFormat("(function() {\n"
+   "var c = 3;\n"
+   "})();");
+  verifyFormat("(function() {\n"
+   "var d = 4;\n"
+   "}());");
+}
+
 TEST_F(FormatTestJS, GoogModules) {
   verifyFormat("goog.module('this.is.really.absurdly.long');",
getGoogleJSStyleWithColumns(40));
Index: lib/Format/UnwrappedLineParser.h
===
--- lib/Format/UnwrappedLineParser.h
+++ lib/Format/UnwrappedLineParser.h
@@ -125,6 +125,7 @@
   void nextToken();
   const FormatToken *getPreviousToken();
 

[libcxx] r302496 - Revert "Fix Windows tests when __config_site is present."

2017-05-08 Thread Ben Craig via cfe-commits
Author: bcraig
Date: Mon May  8 20:26:39 2017
New Revision: 302496

URL: http://llvm.org/viewvc/llvm-project?rev=302496&view=rev
Log:
Revert "Fix Windows tests when __config_site is present."
It's 2017, and line endings are still an issue.

Modified:
libcxx/trunk/utils/libcxx/test/config.py

Modified: libcxx/trunk/utils/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=302496&r1=302495&r2=302496&view=diff
==
--- libcxx/trunk/utils/libcxx/test/config.py (original)
+++ libcxx/trunk/utils/libcxx/test/config.py Mon May  8 20:26:39 2017
@@ -1,1113 +1,1113 @@
-#===--===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is dual licensed under the MIT and the University of Illinois Open
-# Source Licenses. See LICENSE.TXT for details.
-#
-#===--===##
-
-import locale
-import os
-import platform
-import pkgutil
-import pipes
-import re
-import shlex
-import shutil
-import sys
-
-from libcxx.compiler import CXXCompiler
-from libcxx.test.target_info import make_target_info
-from libcxx.test.executor import *
-from libcxx.test.tracing import *
-import libcxx.util
-
-def loadSiteConfig(lit_config, config, param_name, env_name):
-# We haven't loaded the site specific configuration (the user is
-# probably trying to run on a test file directly, and either the site
-# configuration hasn't been created by the build system, or we are in an
-# out-of-tree build situation).
-site_cfg = lit_config.params.get(param_name,
- os.environ.get(env_name))
-if not site_cfg:
-lit_config.warning('No site specific configuration file found!'
-   ' Running the tests in the default configuration.')
-elif not os.path.isfile(site_cfg):
-lit_config.fatal(
-"Specified site configuration file does not exist: '%s'" %
-site_cfg)
-else:
-lit_config.note('using site specific configuration at %s' % site_cfg)
-ld_fn = lit_config.load_config
-
-# Null out the load_config function so that lit.site.cfg doesn't
-# recursively load a config even if it tries.
-# TODO: This is one hell of a hack. Fix it.
-def prevent_reload_fn(*args, **kwargs):
-pass
-lit_config.load_config = prevent_reload_fn
-ld_fn(config, site_cfg)
-lit_config.load_config = ld_fn
-
-class Configuration(object):
-# pylint: disable=redefined-outer-name
-def __init__(self, lit_config, config):
-self.lit_config = lit_config
-self.config = config
-self.is_windows = platform.system() == 'Windows'
-self.cxx = None
-self.cxx_is_clang_cl = None
-self.cxx_stdlib_under_test = None
-self.project_obj_root = None
-self.libcxx_src_root = None
-self.libcxx_obj_root = None
-self.cxx_library_root = None
-self.cxx_runtime_root = None
-self.abi_library_root = None
-self.link_shared = self.get_lit_bool('enable_shared', default=True)
-self.debug_build = self.get_lit_bool('debug_build',   default=False)
-self.exec_env = {}
-self.use_target = False
-self.use_system_cxx_lib = False
-self.use_clang_verify = False
-self.long_tests = None
-self.execute_external = False
-
-def get_lit_conf(self, name, default=None):
-val = self.lit_config.params.get(name, None)
-if val is None:
-val = getattr(self.config, name, None)
-if val is None:
-val = default
-return val
-
-def get_lit_bool(self, name, default=None, env_var=None):
-def check_value(value, var_name):
-if value is None:
-return default
-if isinstance(value, bool):
-return value
-if not isinstance(value, str):
-raise TypeError('expected bool or string')
-if value.lower() in ('1', 'true'):
-return True
-if value.lower() in ('', '0', 'false'):
-return False
-self.lit_config.fatal(
-"parameter '{}' should be true or false".format(var_name))
-
-conf_val = self.get_lit_conf(name)
-if env_var is not None and env_var in os.environ and \
-os.environ[env_var] is not None:
-val = os.environ[env_var]
-if conf_val is not None:
-self.lit_config.warning(
-'Environment variable %s=%s is overriding explicit '
-'--param=%s=%s' % (env_var, val, name, conf_val))
-return check_value(val, env_var)
-return check_value(conf_val, name)
-
-d

[PATCH] D32988: [libc++] Refactor Windows support headers.

2017-05-08 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 98246.
EricWF added a comment.

- Rename `msvc_support.h` to `msvc_builtin_support.h`.


https://reviews.llvm.org/D32988

Files:
  include/__config
  include/algorithm
  include/ctype.h
  include/limits
  include/stdio.h
  include/stdlib.h
  include/support/win32/limits_msvc_win32.h
  include/support/win32/limits_win32.h
  include/support/win32/locale_mgmt_win32.h
  include/support/win32/locale_win32.h
  include/support/win32/msvc_builtin_support.h
  include/support/win32/support.h
  include/wchar.h
  src/string.cpp
  src/support/runtime/exception_pointer_msvc.ipp

Index: src/support/runtime/exception_pointer_msvc.ipp
===
--- src/support/runtime/exception_pointer_msvc.ipp
+++ src/support/runtime/exception_pointer_msvc.ipp
@@ -10,6 +10,7 @@
 
 #include 
 #include 
+#include  // for _CRTIMP2_PURE
 
 _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCreate(_Out_ void*);
 _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrDestroy(_Inout_ void*);
Index: src/string.cpp
===
--- src/string.cpp
+++ src/string.cpp
@@ -13,9 +13,6 @@
 #include "cerrno"
 #include "limits"
 #include "stdexcept"
-#ifdef _LIBCPP_MSVCRT
-#include "support/win32/support.h"
-#endif // _LIBCPP_MSVCRT
 #include 
 
 _LIBCPP_BEGIN_NAMESPACE_STD
@@ -430,7 +427,7 @@
 #ifndef _LIBCPP_MSVCRT
 return swprintf;
 #else
-return static_cast(swprintf);
+return static_cast(_snwprintf);
 #endif
 }
 
Index: include/wchar.h
===
--- include/wchar.h
+++ include/wchar.h
@@ -166,9 +166,12 @@
 }
 #endif
 
-#if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT) || defined(__MINGW32__))
-extern "C++" {
-#include  // pull in *swprintf defines
+#if defined(__cplusplus) && defined(_LIBCPP_MSVCRT)
+extern "C" {
+size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
+  size_t nmc, size_t len, mbstate_t *__restrict ps);
+size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
+  size_t nwc, size_t len, mbstate_t *__restrict ps);
 }  // extern "C++"
 #endif  // __cplusplus && _LIBCPP_MSVCRT
 
Index: include/support/win32/support.h
===
--- include/support/win32/support.h
+++ /dev/null
@@ -1,177 +0,0 @@
-// -*- C++ -*-
-//===--- support/win32/support.h --===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-#ifndef _LIBCPP_SUPPORT_WIN32_SUPPORT_H
-#define _LIBCPP_SUPPORT_WIN32_SUPPORT_H
-
-// Functions and constants used in libc++ that
-// are missing from the Windows C library.
-
-#include  // mbstate_t
-#include  // va_ macros
-// "builtins" not implemented here for Clang or GCC as they provide
-// implementations. Assuming required for elsewhere else, certainly MSVC.
-#if defined(_LIBCPP_COMPILER_MSVC)
-#include 
-#endif
-#define swprintf _snwprintf
-#define vswprintf _vsnwprintf
-
-#ifndef NOMINMAX
-#define NOMINMAX
-#endif
-
-// The mingw headers already define these as static.
-#ifndef __MINGW32__
-extern "C" {
-
-int vasprintf(char **sptr, const char *__restrict fmt, va_list ap);
-int asprintf(char **sptr, const char *__restrict fmt, ...);
-size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
-  size_t nmc, size_t len, mbstate_t *__restrict ps);
-size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
-  size_t nwc, size_t len, mbstate_t *__restrict ps);
-}
-#endif // __MINGW32__
-
-#if defined(_LIBCPP_COMPILER_MSVC)
-
-// Bit builtin's make these assumptions when calling _BitScanForward/Reverse
-// etc. These assumptions are expected to be true for Win32/Win64 which this
-// file supports.
-static_assert(sizeof(unsigned long long) == 8, "");
-static_assert(sizeof(unsigned long) == 4, "");
-static_assert(sizeof(unsigned int) == 4, "");
-
-_LIBCPP_ALWAYS_INLINE int __builtin_popcount(unsigned int x)
-{
-  // Binary: 0101...
-  static const unsigned int m1 = 0x;
-  // Binary: 00110011..
-  static const unsigned int m2 = 0x;
-  // Binary:  4 zeros,  4 ones ...
-  static const unsigned int m4 = 0x0f0f0f0f;
-  // The sum of 256 to the power of 0,1,2,3...
-  static const unsigned int h01 = 0x01010101;
-  // Put count of each 2 bits into those 2 bits.
-  x -= (x >> 1) & m1;
-  // Put count of each 4 bits into those 4 bits.
-  x = (x & m2) + ((x >> 2) & m2);
-  // Put count of each 8 bits into those 8 bits.
-  x = (x + (x >> 4)) & m4;
-  // Returns left 8 bits of x + (x<<8) + (x<<16) + (x<<24).
-  return (x * h01) >> 24;
-}
-
-_LIBCPP_ALWAYS_INLINE

[libcxx] r302497 - Fix Windows tests when __config_site is present.

2017-05-08 Thread Ben Craig via cfe-commits
Author: bcraig
Date: Mon May  8 20:34:12 2017
New Revision: 302497

URL: http://llvm.org/viewvc/llvm-project?rev=302497&view=rev
Log:
Fix Windows tests when __config_site is present.
Previously, the force includes would complain about a missing _DEBUG symbol.
Now we dump macros before adding the force includes to the command line.
Now with proper newlines.

Modified:
libcxx/trunk/utils/libcxx/test/config.py

Modified: libcxx/trunk/utils/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=302497&r1=302496&r2=302497&view=diff
==
--- libcxx/trunk/utils/libcxx/test/config.py (original)
+++ libcxx/trunk/utils/libcxx/test/config.py Mon May  8 20:34:12 2017
@@ -546,6 +546,7 @@ class Configuration(object):
 
 def configure_compile_flags_header_includes(self):
 support_path = os.path.join(self.libcxx_src_root, 'test', 'support')
+self.configure_config_site_header()
 if self.cxx_stdlib_under_test != 'libstdc++' and \
not self.is_windows:
 self.cxx.compile_flags += [
@@ -561,7 +562,6 @@ class Configuration(object):
 '-include', os.path.join(support_path,
  'set_windows_crt_report_mode.h')
 ]
-self.configure_config_site_header()
 cxx_headers = self.get_lit_conf('cxx_headers')
 if cxx_headers == '' or (cxx_headers is None
  and self.cxx_stdlib_under_test != 'libc++'):


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


r302500 - docs: Fix Sphinx detection with out-of-tree builds

2017-05-08 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Mon May  8 20:42:33 2017
New Revision: 302500

URL: http://llvm.org/viewvc/llvm-project?rev=302500&view=rev
Log:
docs: Fix Sphinx detection with out-of-tree builds

Adapt to changes made in r302499.

Modified:
cfe/trunk/docs/CMakeLists.txt

Modified: cfe/trunk/docs/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CMakeLists.txt?rev=302500&r1=302499&r2=302500&view=diff
==
--- cfe/trunk/docs/CMakeLists.txt (original)
+++ cfe/trunk/docs/CMakeLists.txt Mon May  8 20:42:33 2017
@@ -91,8 +91,8 @@ endif()
 endif()
 
 if (LLVM_ENABLE_SPHINX)
+  include(AddSphinxTarget)
   if (SPHINX_FOUND)
-include(AddSphinxTarget)
 if (${SPHINX_OUTPUT_HTML})
   add_sphinx_target(html clang)
   add_custom_command(TARGET docs-clang-html POST_BUILD


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


r302503 - [Sema][ObjC] Clean up possible null dereference.

2017-05-08 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon May  8 20:54:51 2017
New Revision: 302503

URL: http://llvm.org/viewvc/llvm-project?rev=302503&view=rev
Log:
[Sema][ObjC] Clean up possible null dereference.

It appears that the code is actually dead since unbridged-cast
placeholder types are created by calling CastOperation::complete and
ImplicitCastExprs are never passed to it.

Spotted by Vedant Kumar.

rdar://problem/31542226

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

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=302503&r1=302502&r2=302503&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Mon May  8 20:54:51 2017
@@ -4241,8 +4241,7 @@ void Sema::diagnoseARCUnbridgedCast(Expr
 castType = cast->getTypeAsWritten();
 CCK = CCK_OtherCast;
   } else {
-castType = cast->getType();
-CCK = CCK_ImplicitConversion;
+llvm_unreachable("Unexpected ImplicitCastExpr");
   }
 
   ARCConversionTypeClass castACTC =


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


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

2017-05-08 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.

Yep, this seems straight forward.


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


r302505 - [ODRHash] Loosen checks on typedefs.

2017-05-08 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Mon May  8 22:24:34 2017
New Revision: 302505

URL: http://llvm.org/viewvc/llvm-project?rev=302505&view=rev
Log:
[ODRHash] Loosen checks on typedefs.

When a type in a class is from a typedef, only check the canonical type.  Skip
checking the intermediate underlying types.  This is in response to PR 32965

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=302505&r1=302504&r2=302505&view=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Mon May  8 22:24:34 2017
@@ -411,7 +411,7 @@ public:
 
   void VisitTypedefType(const TypedefType *T) {
 AddDecl(T->getDecl());
-Hash.AddQualType(T->getDecl()->getUnderlyingType());
+AddQualType(T->getDecl()->getUnderlyingType().getCanonicalType());
 VisitType(T);
   }
 };

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=302505&r1=302504&r2=302505&view=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Mon May  8 22:24:34 2017
@@ -1078,6 +1078,39 @@ S s;
 #endif
 }
 
+namespace MultipleTypedefs {
+#if defined(FIRST)
+typedef int B1;
+typedef B1 A1;
+struct S1 {
+  A1 x;
+};
+#elif defined(SECOND)
+typedef int A1;
+struct S1 {
+  A1 x;
+};
+#else
+S1 s1;
+#endif
+
+#if defined(FIRST)
+struct T2 { int x; };
+typedef T2 B2;
+typedef B2 A2;
+struct S2 {
+  T2 x;
+};
+#elif defined(SECOND)
+struct T2 { int x; };
+typedef T2 A2;
+struct S2 {
+  T2 x;
+};
+#else
+S2 s2;
+#endif
+}
 
 // Keep macros contained to one file.
 #ifdef FIRST


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


[PATCH] D32248: CodeGen: Cast alloca to expected address space

2017-05-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added inline comments.



Comment at: test/CodeGenCXX/amdgcn-automatic-variable.cpp:25
+  // CHECK: store i32 2, i32* %[[r1]]
+  int lv1;
+  lv1 = 1;

yaxunl wrote:
> Anastasia wrote:
> > I am wondering if all these different test cases are really needed. Are we 
> > testing any different program paths from the patch?
> > 
> > Also would it make sense to add a test case with an object in an AS 
> > different to 0 (i.e. with `__attribute__((address_space(n)))`)
> I think at least I should cover the typical use cases of auto var.
> 
> I will add a test for __attribute__((address_space(n
Sorry. I just checked that C++ does not allow __attribute__((address_space(n))) 
on automatic var.


https://reviews.llvm.org/D32248



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


[PATCH] D32988: [libc++] Refactor Windows support headers.

2017-05-08 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF planned changes to this revision.
EricWF added a comment.

This breaks MinGW. I'll update soon.




Comment at: include/algorithm:647
 #endif
-#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
-#include "support/win32/support.h"
+#if defined(_LIBCPP_COMPILER_MSVC)
+#include "support/win32/msvc_builtin_support.h"

This change is incorrect too.



Comment at: include/limits:114
 
-#if defined(_LIBCPP_MSVCRT)
-#include "support/win32/limits_win32.h"
+#if defined(_LIBCPP_COMPILER_MSVC)
+#include "support/win32/limits_msvc_win32.h"

This is incorrect for MinGW.


https://reviews.llvm.org/D32988



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


r302506 - [Sema] Make typeof(OverloadedFunctionName) not a pointer.

2017-05-08 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Mon May  8 23:06:24 2017
New Revision: 302506

URL: http://llvm.org/viewvc/llvm-project?rev=302506&view=rev
Log:
[Sema] Make typeof(OverloadedFunctionName) not a pointer.

We were sometimes doing a function->pointer conversion in
Sema::CheckPlaceholderExpr, which isn't the job of CheckPlaceholderExpr.

So, when we saw typeof(OverloadedFunctionName), where
OverloadedFunctionName referenced a name with only one function that
could have its address taken, we'd give back a function pointer type
instead of a function type. This is incorrect.

I kept the logic for doing the function pointer conversion in
resolveAndFixAddressOfOnlyViableOverloadCandidate because it was more
consistent with existing ResolveAndFix* methods.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/Sema/overloadable.c
cfe/trunk/test/SemaCXX/enable_if.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=302506&r1=302505&r2=302506&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon May  8 23:06:24 2017
@@ -2726,7 +2726,8 @@ public:
   resolveAddressOfOnlyViableOverloadCandidate(Expr *E,
   DeclAccessPair &FoundResult);
 
-  bool resolveAndFixAddressOfOnlyViableOverloadCandidate(ExprResult &SrcExpr);
+  bool resolveAndFixAddressOfOnlyViableOverloadCandidate(
+  ExprResult &SrcExpr, bool DoFunctionPointerConversion = false);
 
   FunctionDecl *
   ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl,

Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=302506&r1=302505&r2=302506&view=diff
==
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCast.cpp Mon May  8 23:06:24 2017
@@ -1871,7 +1871,8 @@ static bool fixOverloadedReinterpretCast
   // No guarantees that ResolveAndFixSingleFunctionTemplateSpecialization
   // preserves Result.
   Result = E;
-  if (!Self.resolveAndFixAddressOfOnlyViableOverloadCandidate(Result))
+  if (!Self.resolveAndFixAddressOfOnlyViableOverloadCandidate(
+  Result, /*DoFunctionPointerConversion=*/true))
 return false;
   return Result.isUsable();
 }

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=302506&r1=302505&r2=302506&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon May  8 23:06:24 2017
@@ -11210,12 +11210,12 @@ Sema::resolveAddressOfOnlyViableOverload
 /// \brief Given an overloaded function, tries to turn it into a non-overloaded
 /// function reference using resolveAddressOfOnlyViableOverloadCandidate. This
 /// will perform access checks, diagnose the use of the resultant decl, and, if
-/// necessary, perform a function-to-pointer decay.
+/// requested, potentially perform a function-to-pointer decay.
 ///
 /// Returns false if resolveAddressOfOnlyViableOverloadCandidate fails.
 /// Otherwise, returns true. This may emit diagnostics and return true.
 bool Sema::resolveAndFixAddressOfOnlyViableOverloadCandidate(
-ExprResult &SrcExpr) {
+ExprResult &SrcExpr, bool DoFunctionPointerConverion) {
   Expr *E = SrcExpr.get();
   assert(E->getType() == Context.OverloadTy && "SrcExpr must be an overload");
 
@@ -11230,7 +11230,7 @@ bool Sema::resolveAndFixAddressOfOnlyVia
   DiagnoseUseOfDecl(Found, E->getExprLoc());
   CheckAddressOfMemberAccess(E, DAP);
   Expr *Fixed = FixOverloadedFunctionReference(E, DAP, Found);
-  if (Fixed->getType()->isFunctionType())
+  if (DoFunctionPointerConverion && Fixed->getType()->isFunctionType())
 SrcExpr = DefaultFunctionArrayConversion(Fixed, /*Diagnose=*/false);
   else
 SrcExpr = Fixed;

Modified: cfe/trunk/test/Sema/overloadable.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/overloadable.c?rev=302506&r1=302505&r2=302506&view=diff
==
--- cfe/trunk/test/Sema/overloadable.c (original)
+++ cfe/trunk/test/Sema/overloadable.c Mon May  8 23:06:24 2017
@@ -151,3 +151,18 @@ void dropping_qualifiers_is_incompatible
   foo(ccharbuf); // expected-error{{call to 'foo' is ambiguous}} 
expected-note@148{{candidate function}} expected-note@149{{candidate function}}
   foo(vcharbuf); // expected-error{{call to 'foo' is ambiguous}} 
expected-note@148{{candidate function}} expected-note@149{{candidate function}}
 }
+
+// Bug: we used to treat `__typeof__(foo)` as though it was `__typeof__(&foo)`
+// if `foo` was overloade

r302507 - Fix PR32638 : Make sure we switch Sema's CurContext to the substituted FunctionDecl when instantiating the exception specification.

2017-05-08 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Mon May  8 23:17:15 2017
New Revision: 302507

URL: http://llvm.org/viewvc/llvm-project?rev=302507&view=rev
Log:
Fix PR32638 : Make sure we switch Sema's CurContext to the substituted 
FunctionDecl when instantiating the exception specification.

This fixes the bug: https://bugs.llvm.org/show_bug.cgi?id=32638

  int main()
  {
[](auto x) noexcept(noexcept(x)) { } (0);
  }

In the above code, prior to this patch, when substituting into the noexcept 
expression, i.e. transforming the DeclRefExpr that represents 'x' - clang 
attempts to capture 'x' because Sema's CurContext is still pointing to the 
pattern FunctionDecl (i.e. the templated-decl set in 
FinishTemplateArgumentDeduction) which does not match the substituted 'x's 
DeclContext, which leads to an attempt to capture and an assertion failure.  

We fix this by adjusting Sema's CurContext to point to the substituted 
FunctionDecl under which the noexcept specifier's argument should be 
transformed, and so the ParmVarDecl that 'x' refers to has the same declcontext 
and no capture is attempted. 

I briefly investigated whether the SwitchContext should occur right after 
VisitMethodDecl creates the new substituted FunctionDecl, instead of only 
during instantiating the exception specification - but seeing no other code 
that seemed to rely on that, I decided to leave it just for the duration of the 
exception specification instantiation.


Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=302507&r1=302506&r2=302507&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Mon May  8 23:17:15 2017
@@ -3660,6 +3660,7 @@ TemplateDeclInstantiator::InitFunctionIn
   New->setType(SemaRef.Context.getFunctionType(
   NewProto->getReturnType(), NewProto->getParamTypes(), EPI));
 } else {
+  Sema::ContextRAII SwitchContext(SemaRef, New);
   SemaRef.SubstExceptionSpec(New, Proto, TemplateArgs);
 }
   }

Modified: cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas.cpp?rev=302507&r1=302506&r2=302507&view=diff
==
--- cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas.cpp Mon May  8 23:17:15 2017
@@ -986,3 +986,10 @@ class Enclosing3 {
   );
 };
 }
+
+namespace PR32638 {
+ //https://bugs.llvm.org/show_bug.cgi?id=32638
+ void test() {
+[](auto x) noexcept(noexcept(x)) { } (0);
+ }
+}
\ No newline at end of file


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