[PATCH] D36580: [OpenCL] Support variable memory scope in atomic builtins

2017-08-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: cfe/trunk/lib/Frontend/InitPreprocessor.cpp:581
   // Define macros for the OpenCL memory scope.
   // The values should match clang SyncScope enum.
+  static_assert(

t-tye wrote:
> // The values should match clang AtomicScopeOpenCLModel::ID enum.
Fixed. Thanks.


Repository:
  rL LLVM

https://reviews.llvm.org/D36580



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


r310986 - Fix comments about __OPENCL_MEMORY_SCOPE_* macros

2017-08-15 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue Aug 15 21:15:28 2017
New Revision: 310986

URL: http://llvm.org/viewvc/llvm-project?rev=310986=rev
Log:
Fix comments about __OPENCL_MEMORY_SCOPE_* macros

Modified:
cfe/trunk/lib/Frontend/InitPreprocessor.cpp

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=310986=310985=310986=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Tue Aug 15 21:15:28 2017
@@ -578,7 +578,7 @@ static void InitializePredefinedMacros(c
   Builder.defineMacro("__ATOMIC_SEQ_CST", "5");
 
   // Define macros for the OpenCL memory scope.
-  // The values should match clang SyncScope enum.
+  // The values should match AtomicScopeOpenCLModel::ID enum.
   static_assert(
   static_cast(AtomicScopeOpenCLModel::WorkGroup) == 1 &&
   static_cast(AtomicScopeOpenCLModel::Device) == 2 &&


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


[PATCH] D36678: [OpenCL] Do not use vararg in emitted functions for enqueue_kernel

2017-08-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 111302.
yaxunl marked an inline comment as done.
yaxunl added a comment.

Revised by Anastasia's comments.


https://reviews.llvm.org/D36678

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGenOpenCL/cl20-device-side-enqueue.cl

Index: test/CodeGenOpenCL/cl20-device-side-enqueue.cl
===
--- test/CodeGenOpenCL/cl20-device-side-enqueue.cl
+++ test/CodeGenOpenCL/cl20-device-side-enqueue.cl
@@ -49,20 +49,18 @@
 
   // COMMON: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t{{.*}}*, %opencl.queue_t{{.*}}** %default_queue
   // COMMON: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
-  // B32: call i32 (%opencl.queue_t{{.*}}*, i32, %struct.ndrange_t*, i8 addrspace(4)*, i32, ...) @__enqueue_kernel_vaargs(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{(.[0-9]+)?}}, i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor addrspace(2)* } addrspace(1)* @__block_literal_global{{(.[0-9]+)?}} to i8 addrspace(1)*) to i8 addrspace(4)*), i32 1, i32 256)
-  // B64: call i32 (%opencl.queue_t{{.*}}*, i32, %struct.ndrange_t*, i8 addrspace(4)*, i32, ...) @__enqueue_kernel_vaargs(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{(.[0-9]+)?}}, i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor addrspace(2)* } addrspace(1)* @__block_literal_global{{(.[0-9]+)?}} to i8 addrspace(1)*) to i8 addrspace(4)*), i32 1, i64 256)
+  // B32: call i32 @__enqueue_kernel_vaargs(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{(.[0-9]+)?}}, i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor addrspace(2)* } addrspace(1)* @__block_literal_global{{(.[0-9]+)?}} to i8 addrspace(1)*) to i8 addrspace(4)*), i32 1, i32* {{.*}})
+  // B64: call i32 @__enqueue_kernel_vaargs(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{(.[0-9]+)?}}, i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor addrspace(2)* } addrspace(1)* @__block_literal_global{{(.[0-9]+)?}} to i8 addrspace(1)*) to i8 addrspace(4)*), i32 1, i64* {{.*}})
   enqueue_kernel(default_queue, flags, ndrange,
  ^(local void *p) {
return;
  },
  256);
   char c;
   // COMMON: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t{{.*}}*, %opencl.queue_t{{.*}}** %default_queue
   // COMMON: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
-  // B32: [[SIZE:%[0-9]+]] = zext i8 {{%[0-9]+}} to i32
-  // B32: call i32 (%opencl.queue_t{{.*}}*, i32, %struct.ndrange_t*, i8 addrspace(4)*, i32, ...) @__enqueue_kernel_vaargs(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{(.[0-9]+)?}}, i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor addrspace(2)* } addrspace(1)* @__block_literal_global{{(.[0-9]+)?}} to i8 addrspace(1)*) to i8 addrspace(4)*), i32 1, i32 [[SIZE]])
-  // B64: [[SIZE:%[0-9]+]] = zext i8 {{%[0-9]+}} to i64
-  // B64: call i32 (%opencl.queue_t{{.*}}*, i32, %struct.ndrange_t*, i8 addrspace(4)*, i32, ...) @__enqueue_kernel_vaargs(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{(.[0-9]+)?}}, i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor addrspace(2)* } addrspace(1)* @__block_literal_global{{(.[0-9]+)?}} to i8 addrspace(1)*) to i8 addrspace(4)*), i32 1, i64 [[SIZE]])
+  // B32: call i32 @__enqueue_kernel_vaargs(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{(.[0-9]+)?}}, i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor addrspace(2)* } addrspace(1)* @__block_literal_global{{(.[0-9]+)?}} to i8 addrspace(1)*) to i8 addrspace(4)*), i32 1, i32* {{.*}})
+  // B64: call i32 @__enqueue_kernel_vaargs(%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{(.[0-9]+)?}}, i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor addrspace(2)* } addrspace(1)* @__block_literal_global{{(.[0-9]+)?}} to i8 addrspace(1)*) to i8 addrspace(4)*), i32 1, i64* {{.*}})
   enqueue_kernel(default_queue, flags, ndrange,
  ^(local void *p) {
return;
@@ -74,8 +72,8 @@
   // COMMON: [[AD:%arraydecay[0-9]*]] = getelementptr inbounds [1 x %opencl.clk_event_t*], [1 x %opencl.clk_event_t*]* %event_wait_list2, i32 0, i32 0
   // COMMON: [[WAIT_EVNT:%[0-9]+]] = addrspacecast %opencl.clk_event_t{{.*}}** [[AD]] to %opencl.clk_event_t{{.*}}* addrspace(4)*
   // COMMON: [[EVNT:%[0-9]+]]  = addrspacecast %opencl.clk_event_t{{.*}}** %clk_event to %opencl.clk_event_t{{.*}}* addrspace(4)*
-  // B32: call i32 

[PATCH] D36678: [OpenCL] Do not use vararg in emitted functions for enqueue_kernel

2017-08-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: test/CodeGenOpenCL/cl20-device-side-enqueue.cl:64
+  // B32: call i32 @__enqueue_kernel_vaargs(%opencl.queue_t{{.*}}* [[DEF_Q]], 
i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{(.[0-9]+)?}}, i8 addrspace(4)* 
addrspacecast (i8 addrspace(1)* bitcast ({ i8**, i32, i32, i8*, 
%struct.__block_descriptor addrspace(2)* } addrspace(1)* 
@__block_literal_global{{(.[0-9]+)?}} to i8 addrspace(1)*) to i8 
addrspace(4)*), i32 1, i32* {{.*}})
   // B64: [[SIZE:%[0-9]+]] = zext i8 {{%[0-9]+}} to i64
+  // B64: call i32 @__enqueue_kernel_vaargs(%opencl.queue_t{{.*}}* [[DEF_Q]], 
i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{(.[0-9]+)?}}, i8 addrspace(4)* 
addrspacecast (i8 addrspace(1)* bitcast ({ i8**, i32, i32, i8*, 
%struct.__block_descriptor addrspace(2)* } addrspace(1)* 
@__block_literal_global{{(.[0-9]+)?}} to i8 addrspace(1)*) to i8 
addrspace(4)*), i32 1, i64* {{.*}})

Anastasia wrote:
> This is no longer needed?
> 
> Could we check the code for array generation too?
> 
> Also could we modify one test to take more than argument to the block? It 
> seems to be missing in testing.
will do.


https://reviews.llvm.org/D36678



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


[PATCH] D36779: [Driver] SafeStack does not need a runtime library on Fuchsia

2017-08-15 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr created this revision.
mcgrathr added a project: Sanitizers.

Repository:
  rL LLVM

https://reviews.llvm.org/D36779

Files:
  include/clang/Driver/SanitizerArgs.h
  lib/Driver/SanitizerArgs.cpp
  test/Driver/fuchsia.c


Index: test/Driver/fuchsia.c
===
--- test/Driver/fuchsia.c
+++ test/Driver/fuchsia.c
@@ -45,6 +45,8 @@
 // RUN: -fsanitize=safe-stack 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-SAFESTACK
 // CHECK-SAFESTACK: "-fsanitize=safe-stack"
+// CHECK-SAFESTACK-NOT: "{{.*[/\\]}}libclang_rt.safestack-x86_64.a"
+// CHECK-SAFESTACK-NOT: "__safestack_init"
 
 // RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
 // RUN: -fsanitize=address 2>&1 \
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -605,6 +605,11 @@
 AsanUseAfterScope = false;
   }
 
+  if (AllAddedKinds & SafeStack) {
+// SafeStack runtime is built into the system on Fuchsia.
+SafeStackRuntime = !TC.getTriple().isOSFuchsia();
+  }
+
   // Parse -link-cxx-sanitizer flag.
   LinkCXXRuntimes =
   Args.hasArg(options::OPT_fsanitize_link_cxx_runtime) || D.CCCIsCXX();
Index: include/clang/Driver/SanitizerArgs.h
===
--- include/clang/Driver/SanitizerArgs.h
+++ include/clang/Driver/SanitizerArgs.h
@@ -38,6 +38,7 @@
   bool AsanGlobalsDeadStripping = false;
   bool LinkCXXRuntimes = false;
   bool NeedPIE = false;
+  bool SafeStackRuntime = false;
   bool Stats = false;
   bool TsanMemoryAccess = true;
   bool TsanFuncEntryExit = true;
@@ -58,9 +59,7 @@
   }
   bool needsUbsanRt() const;
   bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); }
-  bool needsSafeStackRt() const {
-return Sanitizers.has(SanitizerKind::SafeStack);
-  }
+  bool needsSafeStackRt() const { return SafeStackRuntime; }
   bool needsCfiRt() const;
   bool needsCfiDiagRt() const;
   bool needsStatsRt() const { return Stats; }


Index: test/Driver/fuchsia.c
===
--- test/Driver/fuchsia.c
+++ test/Driver/fuchsia.c
@@ -45,6 +45,8 @@
 // RUN: -fsanitize=safe-stack 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-SAFESTACK
 // CHECK-SAFESTACK: "-fsanitize=safe-stack"
+// CHECK-SAFESTACK-NOT: "{{.*[/\\]}}libclang_rt.safestack-x86_64.a"
+// CHECK-SAFESTACK-NOT: "__safestack_init"
 
 // RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
 // RUN: -fsanitize=address 2>&1 \
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -605,6 +605,11 @@
 AsanUseAfterScope = false;
   }
 
+  if (AllAddedKinds & SafeStack) {
+// SafeStack runtime is built into the system on Fuchsia.
+SafeStackRuntime = !TC.getTriple().isOSFuchsia();
+  }
+
   // Parse -link-cxx-sanitizer flag.
   LinkCXXRuntimes =
   Args.hasArg(options::OPT_fsanitize_link_cxx_runtime) || D.CCCIsCXX();
Index: include/clang/Driver/SanitizerArgs.h
===
--- include/clang/Driver/SanitizerArgs.h
+++ include/clang/Driver/SanitizerArgs.h
@@ -38,6 +38,7 @@
   bool AsanGlobalsDeadStripping = false;
   bool LinkCXXRuntimes = false;
   bool NeedPIE = false;
+  bool SafeStackRuntime = false;
   bool Stats = false;
   bool TsanMemoryAccess = true;
   bool TsanFuncEntryExit = true;
@@ -58,9 +59,7 @@
   }
   bool needsUbsanRt() const;
   bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); }
-  bool needsSafeStackRt() const {
-return Sanitizers.has(SanitizerKind::SafeStack);
-  }
+  bool needsSafeStackRt() const { return SafeStackRuntime; }
   bool needsCfiRt() const;
   bool needsCfiDiagRt() const;
   bool needsStatsRt() const { return Stats; }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-15 Thread Richard Smith via cfe-commits
On 15 August 2017 at 08:56, Diana Picus via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Ugh, I'm not sure that last email made it through.
>
> Here's the IR with -Xclang -disable-llvm-passes, at r310400 and r310401:
> https://goo.gl/4n84SR
> https://goo.gl/gxhxp9
>
> The diff between them is small enough so I don't think there's much
> point in reducing it further.
> Hope that helps.


Yes, that helps a lot. The problem was that the implicitly-generated
va_list struct for ARM wasn't getting the "CanPassInRegisters" flag set,
and got passed indirectly (contrary to the ABI).

I've added a test for that kind of problem in r310982, and re-committed the
patch as r310983.

Thanks for all your assistance here!


> On 15 August 2017 at 17:51, Diana Picus  wrote:
> > Actually, I'm not sure I need to reduce it, the diff between the IR
> > with -Xclang -no-llvm-passes is pretty small for the version
> > with/without the patch. See attached. I hope this helps, it does look
> > like a problem with va_arg handling.
> >
> > Sorry again that this is going so slowly...
> >
> > On 15 August 2017 at 16:52, Diana Picus  wrote:
> >> On 15 August 2017 at 01:25, Richard Smith 
> wrote:
> >>> On 14 August 2017 at 03:27, Diana Picus via cfe-commits
> >>>  wrote:
> 
>  Hi,
> 
>  Strangely enough, it turns out that if I run
>  Asan-armhf-with-calls-Noinst-Test on the command line it fails,
>  although it doesn't fail when run with lit.
> >>>
> >>>
> >>> Looks like the crash is within the "use_colors == true" portion of
> >>> ColoredPrintf, so this would make sense if running the test within lit
> turns
> >>> off color support (perhaps because the output is not a terminal).
> >>>
> >>
> >> That's a good catch, it seems if I run it with --gtest-color=no it
> >> still passes, but prints some garbage at the end:
> >> [ PASSED ] 97 tests.
> >> YOU HAVE -1094542056 DISABLED F]�뀼��_8�pGD2
> >>
> >>
> 
>  I've attached the stack
>  trace from gdb. It looks like some trouble passing down va_arg
>  parameters, but I haven't looked into too much details. The segfault
>  happens when we try to do a   ldrb   r3, [r0, r1], with r1 set to 0 by
>  the current function and r0 passed down from the caller. I'm not sure
>  if this is the exact same problem as the other tests, but feel free to
>  have a look at that code.
> >>>
> >>>
> >>> Have you tried running Asan-armhf-with-calls-Noinst-Test on the
> command line
> >>> without this patch applied? (It's possible that this is a pre-existing
> bug
> >>> in ARM varargs call lowering, and is unrelated to the bug we're trying
> to
> >>> track down. This code path performs an unrelated varargs call between a
> >>> va_start / va_end pair, which seems like quite a rare situation, and I
> could
> >>> easily believe there's something wrong with our lowering that allows
> some
> >>> portion of the outer va_list state to be clobbered in that scenario.)
> >>>
> >>
> >> It seems to work without the patch. I'm currently trying to reduce
> >> Asan-armhf-with-calls-Test and I'll get back to you with the IR or
> >> assembly files (whichever makes any difference).
> >>
>  Meanwhile, I've removed some clutter from Asan-armhf-with-calls-Test
>  (which is the original failure that we were seeing) and left only one
>  failing test that seemed small enough. I'll try to look at the
>  disassembly before/after the patch and maybe even run valgrind on it
>  (running it on the original binary naturally takes forever).
> 
>  Let me know if there's anything else I could try. I can also send you
>  disassembly or even LLVM IR for the Asan-armhf-with-calls-Noinst-Test
>  if you think it helps.
> 
>  Cheers,
>  Diana
> ___
> 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


r310983 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Aug 15 18:49:53 2017
New Revision: 310983

URL: http://llvm.org/viewvc/llvm-project?rev=310983=rev
Log:
PR19668, PR23034: Fix handling of move constructors and deleted copy
constructors when deciding whether classes should be passed indirectly.

This fixes ABI differences between Clang and GCC:

 * Previously, Clang ignored the move constructor when making this
   determination. It now takes the move constructor into account, per
   https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may
   seem recent, but the ABI change was agreed on the Itanium C++ ABI
   list a long time ago).

 * Previously, Clang's behavior when the copy constructor was deleted
   was unstable -- depending on whether the lazy declaration of the
   copy constructor had been triggered, you might get different behavior.
   We now eagerly declare the copy constructor whenever its deletedness
   is unclear, and ignore deleted copy/move constructors when looking for
   a trivial such constructor.

This also fixes an ABI difference between Clang and MSVC:

 * If the copy constructor would be implicitly deleted (but has not been
   lazily declared yet), for instance because the class has an rvalue
   reference member, we would pass it directly. We now pass such a class
   indirectly, matching MSVC.

Based on a patch by Vassil Vassilev, which was based on a patch by Bernd
Schmidt, which was based on a patch by Reid Kleckner!

This is a re-commit of r310401, which was reverted in r310464 due to ARM
failures (which should now be fixed).

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/CodeGen/CGCXXABI.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310983=310982=310983=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug 15 18:49:53 2017
@@ -374,6 +374,7 @@ class CXXRecordDecl : public RecordDecl
 /// \brief These flags are \c true if a defaulted corresponding special
 /// member can't be fully analyzed without performing overload resolution.
 /// @{
+unsigned NeedOverloadResolutionForCopyConstructor : 1;
 unsigned NeedOverloadResolutionForMoveConstructor : 1;
 unsigned NeedOverloadResolutionForMoveAssignment : 1;
 unsigned NeedOverloadResolutionForDestructor : 1;
@@ -382,6 +383,7 @@ class CXXRecordDecl : public RecordDecl
 /// \brief These flags are \c true if an implicit defaulted corresponding
 /// special member would be defined as deleted.
 /// @{
+unsigned DefaultedCopyConstructorIsDeleted : 1;
 unsigned DefaultedMoveConstructorIsDeleted : 1;
 unsigned DefaultedMoveAssignmentIsDeleted : 1;
 unsigned DefaultedDestructorIsDeleted : 1;
@@ -414,6 +416,12 @@ class CXXRecordDecl : public RecordDecl
 /// constructor.
 unsigned HasDefaultedDefaultConstructor : 1;
 
+/// \brief True if this class can be passed in a non-address-preserving
+/// fashion (such as in registers) according to the C++ language rules.
+/// This does not imply anything about how the ABI in use will actually
+/// pass an object of this class.
+unsigned CanPassInRegisters : 1;
+
 /// \brief True if a defaulted default constructor for this class would
 /// be constexpr.
 unsigned DefaultedDefaultConstructorIsConstexpr : 1;
@@ -810,18 +818,50 @@ public:
 return data().FirstFriend.isValid();
   }
 
+  /// \brief \c true if a defaulted copy constructor for this class would be
+  /// deleted.
+  bool defaultedCopyConstructorIsDeleted() const {
+assert((!needsOverloadResolutionForCopyConstructor() ||
+(data().DeclaredSpecialMembers & SMF_CopyConstructor)) &&
+   "this property has not yet been computed by Sema");
+return data().DefaultedCopyConstructorIsDeleted;
+  }
+
+  /// \brief \c true if a defaulted move constructor for this class would be
+  /// deleted.
+  bool defaultedMoveConstructorIsDeleted() const {
+assert((!needsOverloadResolutionForMoveConstructor() ||
+(data().DeclaredSpecialMembers & SMF_MoveConstructor)) &&
+   "this property has not yet been computed by Sema");
+return data().DefaultedMoveConstructorIsDeleted;
+  }
+
+  /// \brief \c true if a defaulted destructor for this class would be deleted.
+  bool defaultedDestructorIsDeleted() const {
+return !data().DefaultedDestructorIsDeleted;
+  }
+
+  /// \brief \c true if we 

r310982 - Add test that we get the correct calling convention and mangling for va_list.

2017-08-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Aug 15 18:46:46 2017
New Revision: 310982

URL: http://llvm.org/viewvc/llvm-project?rev=310982=rev
Log:
Add test that we get the correct calling convention and mangling for va_list.

Added:
cfe/trunk/test/Headers/stdarg.cpp

Added: cfe/trunk/test/Headers/stdarg.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/stdarg.cpp?rev=310982=auto
==
--- cfe/trunk/test/Headers/stdarg.cpp (added)
+++ cfe/trunk/test/Headers/stdarg.cpp Tue Aug 15 18:46:46 2017
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -emit-llvm -std=c99 -x c %s -triple aarch64-linux -o - | 
FileCheck %s --check-prefix=AARCH64-C
+// RUN: %clang_cc1 -emit-llvm -std=c++17 -x c++ %s -triple aarch64-linux -o - 
| FileCheck %s --check-prefix=AARCH64-CXX
+// RUN: %clang_cc1 -emit-llvm -std=c99 -x c %s -triple x86_64-linux -o - | 
FileCheck %s --check-prefix=X86_64-C
+// RUN: %clang_cc1 -emit-llvm -std=c++17 -x c++ %s -triple x86_64-linux -o - | 
FileCheck %s --check-prefix=X86_64-CXX
+// RUN: %clang_cc1 -emit-llvm -std=c99 -x c %s -triple ppc64-linux -o - | 
FileCheck %s --check-prefix=PPC64-C
+// RUN: %clang_cc1 -emit-llvm -std=c++17 -x c++ %s -triple ppc64-linux -o - | 
FileCheck %s --check-prefix=PPC64-CXX
+// RUN: %clang_cc1 -emit-llvm -std=c99 -x c %s -triple armv7-apple-darwin9 
-target-abi aapcs -o - | FileCheck %s --check-prefix=AAPCS-C
+// RUN: %clang_cc1 -emit-llvm -std=c++17 -x c++ %s -triple armv7-apple-darwin9 
-target-abi aapcs -o - | FileCheck %s --check-prefix=AAPCS-CXX
+// RUN: %clang_cc1 -emit-llvm -std=c99 -x c %s -triple s390x-linux -o - | 
FileCheck %s --check-prefix=SYSTEMZ-C
+// RUN: %clang_cc1 -emit-llvm -std=c++17 -x c++ %s -triple s390x-linux -o - | 
FileCheck %s --check-prefix=SYSTEMZ-CXX
+// RUN: %clang_cc1 -emit-llvm -std=c99 -x c %s -triple le32-nacl -o - | 
FileCheck %s --check-prefix=PNACL-C
+// RUN: %clang_cc1 -emit-llvm -std=c++17 -x c++ %s -triple le32-nacl -o - | 
FileCheck %s --check-prefix=PNACL-CXX
+// RUN: %clang_cc1 -emit-llvm -std=c99 -x c %s -triple i686-linux -o - | 
FileCheck %s --check-prefix=CHARPTR-C
+// RUN: %clang_cc1 -emit-llvm -std=c++17 -x c++ %s -triple i686-linux -o - | 
FileCheck %s --check-prefix=CHARPTR-CXX
+// RUN: %clang_cc1 -emit-llvm -std=c99 -x c %s -triple xcore -o - | FileCheck 
%s --check-prefix=VOIDPTR-C
+// RUN: %clang_cc1 -emit-llvm -std=c++17 -x c++ %s -triple xcore -o - | 
FileCheck %s --check-prefix=VOIDPTR-CXX
+
+#include 
+
+// AARCH64-C: define {{.*}} @f(i32 %n, %struct.__va_list* %list)
+// AARCH64-CXX: define {{.*}} @_Z1fiSt9__va_list(i32 %n, 
%"struct.std::__va_list"* %list)
+// X86_64-C: define {{.*}} @f(i32 %n, %struct.__va_list_tag* %list)
+// X86_64-CXX: define {{.*}} @_Z1fiP13__va_list_tag(i32 %n, 
%struct.__va_list_tag* %list)
+// PPC64-C: define {{.*}} @f(i32 signext %n, i8* %list)
+// PPC64-CXX: define {{.*}} @_Z1fiPc(i32 signext %n, i8* %list)
+// AAPCS-C: define {{.*}} @f(i32 %n, [1 x i32] %list.coerce)
+// AAPCS-CXX: define {{.*}} @_Z1fiSt9__va_list(i32 %n, [1 x i32] %list.coerce)
+// SYSTEMZ-C: define {{.*}} @f(i32 signext %n, %struct.__va_list_tag* %list)
+// SYSTEMZ-CXX: define {{.*}} @_Z1fiP13__va_list_tag(i32 signext %n, 
%struct.__va_list_tag* %list)
+// PNACL-C: define {{.*}} @f(i32 %n, i32* %list)
+// PNACL-CXX: define {{.*}} @_Z1fiPi(i32 %n, i32* %list)
+// CHARPTR-C: define {{.*}} @f(i32 %n, i8* %list)
+// CHARPTR-CXX: define {{.*}} @_Z1fiPc(i32 %n, i8* %list)
+// VOIDPTR-C: define {{.*}} @f(i32 %n, i8* %list)
+// VOIDPTR-CXX: define {{.*}} @_Z1fiPv(i32 %n, i8* %list)
+void f(int n, va_list list) {}


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


[PATCH] D35020: [Modules] Add ability to specify module name to module file mapping

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



Comment at: docs/ClangCommandLineReference.rst:3-4
   ---
   NOTE: This file is automatically generated by running clang-tblgen
   -gen-opt-docs. Do not edit this file by hand!!
   ---

Please revert the change to this file; we can regenerate it after this lands 
(as a separate commit).



Comment at: include/clang/Driver/Options.td:1105
+  Group, Flags<[DriverOption,CC1Option]>, 
MetaVarName<"[=]">,
+  HelpText<"Specify the mapping of module name to precompiled module file 
loading it if name is omitted.">;
 def fmodules_ignore_macro : Joined<["-"], "fmodules-ignore-macro=">, 
Group, Flags<[CC1Option]>,

How about "Specify the mapping of module name to precompiled module file, or 
load a module file if name is omitted."?



Comment at: include/clang/Serialization/ModuleManager.h:52-53
 
+  /// \brief All loaded prebuilt/explicit modules, indexed by module name.
+  std::map PrebuiltModules;
+

`llvm::StringMap` would be preferable here.



Comment at: lib/Driver/ToolChains/Clang.cpp:3613-3622
+  // The -fmodule-file= form can be used to load files containing
+  // precompiled modules.
+  for (const Arg *A : Args.filtered(options::OPT_fmodule_file)) {
+StringRef Val = A->getValue();
+if (Val.find('=') == StringRef::npos) {
   if (HaveAnyModules)
+CmdArgs.push_back(Args.MakeArgString("-fmodule-file=" + Val));

What's the purpose of splitting this into two separate loops? I see that you're 
passing on all `-fmodule-file=name=value` flags even if modules is not enabled. 
Is that useful?



Comment at: lib/Frontend/CompilerInstance.cpp:1623-1630
+/// FIXME: perhaps we should (a) look for a module using the module name
+//  to file map (PrebuiltModuleFiles) and (b) diagnose if still not found?
+//if (Module == nullptr) {
+//  getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_found)
+//<< ModuleName;
+//  ModuleBuildFailed = true;
+//  return ModuleLoadResult();

This doesn't make sense for header modules (defined by a module map). For the 
case of a Modules TS module implementation unit, we should skip this 
`CurrentModule` check, but let's leave that for a separate patch.



Comment at: lib/Frontend/CompilerInvocation.cpp:982
+StringRef Val = A->getValue();
+if (Val.find('=') == StringRef::npos)
+  Opts.ExtraDeps.push_back(Val);

There should be some way to specify a module file that contains a `=` in its 
file name. Ideally, that way would be compatible with our currently-supported 
form of `-fmodule-name=filename`. I don't see a way to support that other than 
`stat`ing every value we're given and checking to see whether it exists before 
attempting to split on a `=`... thoughts?

One somewhat hackish alternative would be to only recognize an `=` if there is 
no preceding `/`. (So `-fmodule-file=foo=bar.pcm` specifies a mapping, and 
`-fmodule-file=./foo=bar.pcm` specifies the file `./foo=bar.pcm`.)

(FWIW, we also support module names containing `=` characters.)



Comment at: lib/Lex/HeaderSearch.cpp:131
 
 std::string HeaderSearch::getModuleFileName(Module *Module) {
   const FileEntry *ModuleMap =

I like the renaming you've done here. Should this one also be renamed to 
`getCachedModuleFileName`?



Comment at: lib/Serialization/ASTReader.cpp:4145-4146
+// by-name lookup.
+if (Type == MK_PrebuiltModule || Type == MK_ExplicitModule)
+  ModuleMgr.registerPrebuilt(F);
 break;

I'm worried by this: the `Type` can be different for different imports of the 
same .pcm file, and you'll only get here for the *first* import edge. So you 
can fail to add the module to the "prebuilt modules" map here, and then later 
attempt to look it up there (when processing the module offset map) and fail to 
find it.

Instead of keeping a separate lookup structure on the module manager, could you 
look up the `Module`, and then use its `ASTFile` to find the corresponding 
`ModuleFile`?

(If you go that way, the changes to module lookup when reading the module 
offset map could be generalized to apply to all `MK_*Module` types.)


https://reviews.llvm.org/D35020



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


[PATCH] D36728: Switch to consumeError(), since this can crash otherwise.

2017-08-15 Thread Lang Hames via Phabricator via cfe-commits
lhames added a comment.

> Is it ok to drop the assertion in that case (and convert it to a comment)? I 
> didn't want to alter too much of this check, since perhaps the original 
> author(s) were more skeptical about this breaking (hence the assertion). 
> Something like:
> 
> // Replacements must not conflict since ranges have been merged.
>  llvm::cantFail(FakeReplaces.add(...));

Yep - cantFail asserts that the result is success, so your proposed change 
(with the assertion text above the call) is ideal.


Repository:
  rL LLVM

https://reviews.llvm.org/D36728



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


Re: r310382 - [Availability] Don't make an availability attribute imply default visibility on macOS

2017-08-15 Thread Erik Pilkington via cfe-commits

Probably not, this might be a risky change.
- Erik

On 8/15/17 9:15 AM, Nico Weber wrote:

Do we want to merge this to 5.0?

On Tue, Aug 8, 2017 at 1:09 PM, Erik Pilkington via cfe-commits 
> wrote:


Author: epilk
Date: Tue Aug  8 10:09:09 2017
New Revision: 310382

URL: http://llvm.org/viewvc/llvm-project?rev=310382=rev

Log:
[Availability] Don't make an availability attribute imply default
visibility on macOS

Fixes PR33796, rdar://33655115

Differential revision: https://reviews.llvm.org/D36191


Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/test/CodeGen/attr-availability.c

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=310382=310381=310382=diff



==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Tue Aug  8 10:09:09 2017
@@ -94,6 +94,9 @@ Clang now supports the ...
 Attribute Changes in Clang
 --

+- The presence of __attribute__((availability(...))) on a
declaration no longer
+  implies default visibility for that declaration on macOS.
+
 - ...

 Windows Support

Modified: cfe/trunk/lib/AST/Decl.cpp
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=310382=310381=310382=diff



==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Aug  8 10:09:09 2017
@@ -216,14 +216,6 @@ static Optional getVisibilit
 return getVisibilityFromAttr(A);
   }

-  // If we're on Mac OS X, an 'availability' for Mac OS X attribute
-  // implies visibility(default).
-  if (D->getASTContext().getTargetInfo().getTriple().isOSDarwin()) {
-for (const auto *A : D->specific_attrs())
-  if (A->getPlatform()->getName().equals("macos"))
-return DefaultVisibility;
-  }
-
   return None;
 }


Modified: cfe/trunk/test/CodeGen/attr-availability.c
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-availability.c?rev=310382=310381=310382=diff



==
--- cfe/trunk/test/CodeGen/attr-availability.c (original)
+++ cfe/trunk/test/CodeGen/attr-availability.c Tue Aug 8 10:09:09 2017
@@ -8,9 +8,9 @@
 void f2();
 void f2() { }

-// CHECK-10_4-LABEL: define void @f3
-// CHECK-10_5-LABEL: define void @f3
-// CHECK-10_6-LABEL: define void @f3
+// CHECK-10_4-LABEL: define hidden void @f3
+// CHECK-10_5-LABEL: define hidden void @f3
+// CHECK-10_6-LABEL: define hidden void @f3
 void f3() __attribute__((availability(macosx,introduced=10.5)));
 void f3() { }



___
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] D36777: [Sema] Don't emit -Wunguarded-availability for switch cases

2017-08-15 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.

Currently, this has pretty terrible ergonomics for the fairly common case of 
switching over an enum which has some entries that are partial. Thanks to Nico 
Weber for pointing this out!

Thanks,
Erik


https://reviews.llvm.org/D36777

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/SemaObjC/unguarded-availability.m


Index: test/SemaObjC/unguarded-availability.m
===
--- test/SemaObjC/unguarded-availability.m
+++ test/SemaObjC/unguarded-availability.m
@@ -287,3 +287,22 @@
 @interface BaseClass (CategoryWithNewProtocolRequirement) 
 
 @end
+
+typedef enum {
+  AK_Dodo __attribute__((availability(macos, deprecated=10.3))), // 
expected-note 2 {{marked deprecated here}}
+  AK_Cat __attribute__((availability(macos, introduced=10.4))),
+  AK_CyborgCat __attribute__((availability(macos, introduced=10.12))), // 
expected-note {{marked partial here}}
+} Animals;
+
+void switchAnimals(Animals a) {
+  switch (a) {
+  case AK_Dodo: break; // expected-warning{{'AK_Dodo' is deprecated}}
+  case AK_Cat: break;
+  case AK_Cat|AK_CyborgCat: break; // expected-warning{{case value not in 
enum}}
+  case AK_CyborgCat: break; // no warn
+  }
+
+  (void)AK_Dodo; // expected-warning{{'AK_Dodo' is deprecated}}
+  (void)AK_Cat; // no warning
+  (void)AK_CyborgCat; // expected-warning{{'AK_CyborgCat' is only available on 
macOS 10.12 or newer}} expected-note {{@available}}
+}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -7513,6 +7513,15 @@
 
   bool TraverseLambdaExpr(LambdaExpr *E) { return true; }
 
+  bool TraverseCaseStmt(CaseStmt *CS) {
+// for 'case X:' statements, don't bother looking at the 'X'; it can't lead
+// to any useful diagnostics.
+for (Stmt *Child : llvm::drop_begin(CS->children(), 1))
+  if (!Base::TraverseStmt(Child))
+return false;
+return true;
+  }
+
   bool VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *PRE) {
 if (PRE->isClassReceiver())
   DiagnoseDeclAvailability(PRE->getClassReceiver(), 
PRE->getReceiverLocation());


Index: test/SemaObjC/unguarded-availability.m
===
--- test/SemaObjC/unguarded-availability.m
+++ test/SemaObjC/unguarded-availability.m
@@ -287,3 +287,22 @@
 @interface BaseClass (CategoryWithNewProtocolRequirement) 
 
 @end
+
+typedef enum {
+  AK_Dodo __attribute__((availability(macos, deprecated=10.3))), // expected-note 2 {{marked deprecated here}}
+  AK_Cat __attribute__((availability(macos, introduced=10.4))),
+  AK_CyborgCat __attribute__((availability(macos, introduced=10.12))), // expected-note {{marked partial here}}
+} Animals;
+
+void switchAnimals(Animals a) {
+  switch (a) {
+  case AK_Dodo: break; // expected-warning{{'AK_Dodo' is deprecated}}
+  case AK_Cat: break;
+  case AK_Cat|AK_CyborgCat: break; // expected-warning{{case value not in enum}}
+  case AK_CyborgCat: break; // no warn
+  }
+
+  (void)AK_Dodo; // expected-warning{{'AK_Dodo' is deprecated}}
+  (void)AK_Cat; // no warning
+  (void)AK_CyborgCat; // expected-warning{{'AK_CyborgCat' is only available on macOS 10.12 or newer}} expected-note {{@available}}
+}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -7513,6 +7513,15 @@
 
   bool TraverseLambdaExpr(LambdaExpr *E) { return true; }
 
+  bool TraverseCaseStmt(CaseStmt *CS) {
+// for 'case X:' statements, don't bother looking at the 'X'; it can't lead
+// to any useful diagnostics.
+for (Stmt *Child : llvm::drop_begin(CS->children(), 1))
+  if (!Base::TraverseStmt(Child))
+return false;
+return true;
+  }
+
   bool VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *PRE) {
 if (PRE->isClassReceiver())
   DiagnoseDeclAvailability(PRE->getClassReceiver(), PRE->getReceiverLocation());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35678: Omit sumbodule semantics for TS modules

2017-08-15 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D35678#840092, @boris wrote:

> My understanding of your comment is that the rest is ok for now (since there 
> will probably be a redesign in this area). If, however, I misunderstood and 
> you sill want to move the id flattening to the caller, let me know.


I'd still like the id flattening moved to the caller. I don't know when or if 
the redesign will ever happen, so we should aim for the state of the codebase 
to be consistent in the interim (which might be forever). I'm fine with that 
being done as a separate change after this one, though, if you'd prefer.

Do you need someone to commit this for you?


https://reviews.llvm.org/D35678



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


r310978 - Add missing test for warning added in r310803.

2017-08-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Aug 15 17:06:07 2017
New Revision: 310978

URL: http://llvm.org/viewvc/llvm-project?rev=310978=rev
Log:
Add missing test for warning added in r310803.

Added:
cfe/trunk/test/Lexer/cxx2a_keyword_as_cxx17.cpp

Added: cfe/trunk/test/Lexer/cxx2a_keyword_as_cxx17.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/cxx2a_keyword_as_cxx17.cpp?rev=310978=auto
==
--- cfe/trunk/test/Lexer/cxx2a_keyword_as_cxx17.cpp (added)
+++ cfe/trunk/test/Lexer/cxx2a_keyword_as_cxx17.cpp Tue Aug 15 17:06:07 2017
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Wc++2a-compat -std=c++17
+
+#define concept constexpr bool
+template
+concept x = 0;
+#undef concept
+
+int concept = 0; // expected-warning {{'concept' is a keyword in C++2a}}
+int requires = 0; // expected-warning {{'requires' is a keyword in C++2a}}


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


r310976 - Revert "Add a target for new LTO plugin name tests."

2017-08-15 Thread Dan Albert via cfe-commits
Author: danalbert
Date: Tue Aug 15 16:57:32 2017
New Revision: 310976

URL: http://llvm.org/viewvc/llvm-project?rev=310976=rev
Log:
Revert "Add a target for new LTO plugin name tests."

Modified:
cfe/trunk/test/Driver/lto-plugin-darwin.c
cfe/trunk/test/Driver/lto-plugin-linux.c
cfe/trunk/test/Driver/lto-plugin-windows.c

Modified: cfe/trunk/test/Driver/lto-plugin-darwin.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/lto-plugin-darwin.c?rev=310976=310975=310976=diff
==
--- cfe/trunk/test/Driver/lto-plugin-darwin.c (original)
+++ cfe/trunk/test/Driver/lto-plugin-darwin.c Tue Aug 15 16:57:32 2017
@@ -1,6 +1,6 @@
 // Check that Darwin uses LLVMgold.dylib.
 // REQUIRES: system-darwin
-// RUN: %clang -target x86_64-unknown-linux -### %s -flto 2>&1 \
+// RUN: %clang -### %s -flto 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
 //
 // CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.dylib"

Modified: cfe/trunk/test/Driver/lto-plugin-linux.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/lto-plugin-linux.c?rev=310976=310975=310976=diff
==
--- cfe/trunk/test/Driver/lto-plugin-linux.c (original)
+++ cfe/trunk/test/Driver/lto-plugin-linux.c Tue Aug 15 16:57:32 2017
@@ -1,6 +1,6 @@
 // Check that non-Windows, non-Darwin OSs use LLVMgold.so.
 // REQUIRES: !system-darwin && !system-windows
-// RUN: %clang -target x86_64-unknown-linux -### %s -flto 2>&1 \
+// RUN: %clang -### %s -flto 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
 //
 // CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.so"

Modified: cfe/trunk/test/Driver/lto-plugin-windows.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/lto-plugin-windows.c?rev=310976=310975=310976=diff
==
--- cfe/trunk/test/Driver/lto-plugin-windows.c (original)
+++ cfe/trunk/test/Driver/lto-plugin-windows.c Tue Aug 15 16:57:32 2017
@@ -1,6 +1,6 @@
 // Check that Windows uses LLVMgold.dll.
 // REQUIRES: system-windows
-// RUN: %clang -target x86_64-unknown-linux -### %s -flto 2>&1 \
+// RUN: %clang -### %s -flto 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
 //
 // CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.dll"


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


r310977 - Revert "Revert "Revert "Fix LLVMgold plugin name/path for non-Linux."""

2017-08-15 Thread Dan Albert via cfe-commits
Author: danalbert
Date: Tue Aug 15 16:57:34 2017
New Revision: 310977

URL: http://llvm.org/viewvc/llvm-project?rev=310977=rev
Log:
Revert "Revert "Revert "Fix LLVMgold plugin name/path for non-Linux."""

Removed:
cfe/trunk/test/Driver/lto-plugin-darwin.c
cfe/trunk/test/Driver/lto-plugin-linux.c
cfe/trunk/test/Driver/lto-plugin-windows.c
Modified:
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/test/Driver/freebsd.c
cfe/trunk/test/Driver/gold-lto.c
cfe/trunk/test/Driver/lto.c
cfe/trunk/test/Driver/thinlto.c

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=310977=310976=310977=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Tue Aug 15 16:57:34 2017
@@ -376,20 +376,8 @@ void tools::AddGoldPlugin(const ToolChai
   // as gold requires -plugin to come before any -plugin-opt that -Wl might
   // forward.
   CmdArgs.push_back("-plugin");
-
-#if defined(LLVM_ON_WIN32)
-  const char *Suffix = ".dll";
-#elif defined(__APPLE__)
-  const char *Suffix = ".dylib";
-#else
-  const char *Suffix = ".so";
-#endif
-
-  SmallString<1024> Plugin;
-  llvm::sys::path::native(Twine(ToolChain.getDriver().Dir) +
-  "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold" +
-  Suffix,
-  Plugin);
+  std::string Plugin =
+  ToolChain.getDriver().Dir + "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold.so";
   CmdArgs.push_back(Args.MakeArgString(Plugin));
 
   // Try to pass driver level flags relevant to LTO code generation down to

Modified: cfe/trunk/test/Driver/freebsd.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/freebsd.c?rev=310977=310976=310977=diff
==
--- cfe/trunk/test/Driver/freebsd.c (original)
+++ cfe/trunk/test/Driver/freebsd.c Tue Aug 15 16:57:34 2017
@@ -127,7 +127,7 @@
 
 // RUN: %clang -target x86_64-pc-freebsd8 %s -### -flto 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-LTO %s
-// CHECK-LTO: ld{{.*}}" "-plugin{{.*}}LLVMgold.{{dll|dylib|so}}
+// CHECK-LTO: ld{{.*}}" "-plugin{{.*}}LLVMgold.so
 
 // RUN: %clang -target sparc-unknown-freebsd8 %s -### -fpic -no-integrated-as 
2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-SPARC-PIE %s

Modified: cfe/trunk/test/Driver/gold-lto.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/gold-lto.c?rev=310977=310976=310977=diff
==
--- cfe/trunk/test/Driver/gold-lto.c (original)
+++ cfe/trunk/test/Driver/gold-lto.c Tue Aug 15 16:57:34 2017
@@ -3,14 +3,14 @@
 // RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
 // RUN: -Wl,-plugin-opt=foo -O3 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-64-BASIC
-// CHECK-X86-64-BASIC: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
+// CHECK-X86-64-BASIC: "-plugin" "{{.*}}/LLVMgold.so"
 // CHECK-X86-64-BASIC: "-plugin-opt=O3"
 // CHECK-X86-64-BASIC: "-plugin-opt=foo"
 //
 // RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
 // RUN: -march=corei7 -Wl,-plugin-opt=foo -Ofast \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-64-COREI7
-// CHECK-X86-64-COREI7: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
+// CHECK-X86-64-COREI7: "-plugin" "{{.*}}/LLVMgold.so"
 // CHECK-X86-64-COREI7: "-plugin-opt=mcpu=corei7"
 // CHECK-X86-64-COREI7: "-plugin-opt=O3"
 // CHECK-X86-64-COREI7: "-plugin-opt=foo"
@@ -18,11 +18,11 @@
 // RUN: %clang -target arm-unknown-linux -### %t.o -flto 2>&1 \
 // RUN: -march=armv7a -Wl,-plugin-opt=foo -O0 \
 // RUN: | FileCheck %s --check-prefix=CHECK-ARM-V7A
-// CHECK-ARM-V7A: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
+// CHECK-ARM-V7A: "-plugin" "{{.*}}/LLVMgold.so"
 // CHECK-ARM-V7A: "-plugin-opt=mcpu=generic"
 // CHECK-ARM-V7A: "-plugin-opt=O0"
 // CHECK-ARM-V7A: "-plugin-opt=foo"
 //
 // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-ANDROID
-// CHECK-X86-ANDROID: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
+// CHECK-X86-ANDROID: "-plugin" "{{.*}}/LLVMgold.so"

Removed: cfe/trunk/test/Driver/lto-plugin-darwin.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/lto-plugin-darwin.c?rev=310976=auto
==
--- cfe/trunk/test/Driver/lto-plugin-darwin.c (original)
+++ cfe/trunk/test/Driver/lto-plugin-darwin.c (removed)
@@ -1,6 +0,0 @@
-// Check that Darwin uses LLVMgold.dylib.
-// REQUIRES: system-darwin
-// RUN: %clang -### %s -flto 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
-//
-// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.dylib"

Removed: 

RE: r310960 - Revert "Revert "Fix LLVMgold plugin name/path for non-Linux.""

2017-08-15 Thread Yung, Douglas via cfe-commits
Hi Dan,

I don't know if you are aware, but the tests you added/changed in this commit 
are causing failures on the PS4 Windows bot. The root cause seems to be that 
you are looking for a forward slash, but Windows generates double backslashes, 
so the match fails:

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/11545/steps/test/logs/stdio:

$ 
"C:/ps4-buildslave2/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/llvm.obj/./bin/clang.EXE"
 "-target" "x86_64-unknown-linux" "-###" 
"C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Driver\lto-plugin-windows.c"
 "-flto"
$ 
"C:/ps4-buildslave2/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/llvm.obj/./bin\FileCheck.EXE"
 "-check-prefix=CHECK-LTO-PLUGIN" 
"C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Driver\lto-plugin-windows.c"
# command stderr:
C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\test\Driver\lto-plugin-windows.c:6:22:
 error: expected string not found in input

// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.dll"

 ^

:1:1: note: scanning from here

clang version 6.0.0 (trunk 310972)

^

:6:230: note: possible intended match here

 "ld" "--eh-frame-hdr" "-m" "elf_x86_64" "-dynamic-linker" 
"/lib64/ld-linux-x86-64.so.2" "-o" "a.out" "crt1.o" "crti.o" "crtbegin.o" 
"-LC:\\ps4-buildslave2\\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\\llvm.obj\\bin/../lib"
 "-plugin" 
"C:\\ps4-buildslave2\\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\\llvm.obj\\bin\\..\\lib\\LLVMgold.dll"
 "-plugin-opt=mcpu=x86-64" 
"c:\\users\\buildbot\\appdata\\local\\temp\\lit_tmp_wsgjna\\lto-plugin-windows-5f76f0.o"
 "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" 
"-lgcc_s" "--no-as-needed" "crtend.o" "crtn.o"



The affected tests are:

Driver/gold-lto.c
Driver/lto-plugin-windows.c
Driver/lto.c
Driver/thinlto.c

Can you fix these tests?

Thanks!

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of Dan
> Albert via cfe-commits
> Sent: Tuesday, August 15, 2017 14:31
> To: cfe-commits@lists.llvm.org
> Subject: r310960 - Revert "Revert "Fix LLVMgold plugin name/path for non-
> Linux.""
> 
> Author: danalbert
> Date: Tue Aug 15 14:31:17 2017
> New Revision: 310960
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=310960=rev
> Log:
> Revert "Revert "Fix LLVMgold plugin name/path for non-Linux.""
> 
> Summary:
> Relanding https://reviews.llvm.org/D35739 which was reverted because it broke
> the tests on non-Linux. The tests have been fixed to be platform agnostic, and
> additional tests have been added to make sure that the plugin has the correct
> extension on each platform (%pluginext doesn't work in CHECK lines).
> 
> Reviewers: srhines, pirama
> 
> Reviewed By: srhines
> 
> Subscribers: emaste, mehdi_amini, eraman, cfe-commits
> 
> Differential Revision: https://reviews.llvm.org/D36769
> 
> Added:
> cfe/trunk/test/Driver/lto-plugin-darwin.c
> cfe/trunk/test/Driver/lto-plugin-linux.c
> cfe/trunk/test/Driver/lto-plugin-windows.c
> Modified:
> cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
> cfe/trunk/test/Driver/freebsd.c
> cfe/trunk/test/Driver/gold-lto.c
> cfe/trunk/test/Driver/lto.c
> cfe/trunk/test/Driver/thinlto.c
> 
> Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=310960=310959
> =310960=diff
> ==
> --- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Tue Aug 15 14:31:17
> +++ 2017
> @@ -376,8 +376,20 @@ void tools::AddGoldPlugin(const ToolChai
>// as gold requires -plugin to come before any -plugin-opt that -Wl might
>// forward.
>CmdArgs.push_back("-plugin");
> -  std::string Plugin =
> -  ToolChain.getDriver().Dir + "/../lib" CLANG_LIBDIR_SUFFIX
> "/LLVMgold.so";
> +
> +#if defined(LLVM_ON_WIN32)
> +  const char *Suffix = ".dll";
> +#elif defined(__APPLE__)
> +  const char *Suffix = ".dylib";
> +#else
> +  const char *Suffix = ".so";
> +#endif
> +
> +  SmallString<1024> Plugin;
> +  llvm::sys::path::native(Twine(ToolChain.getDriver().Dir) +
> +  "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold" +
> +  Suffix,
> +  Plugin);
>CmdArgs.push_back(Args.MakeArgString(Plugin));
> 
>// Try to pass driver level flags relevant to LTO code generation down to
> 
> Modified: cfe/trunk/test/Driver/freebsd.c
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/test/Driver/freebsd.c?rev=310960=310959=310960=di
> ff
> ==
> --- cfe/trunk/test/Driver/freebsd.c 

[PATCH] D36713: [libc++] Add a persistent way to disable availability

2017-08-15 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

@mclow.lists does this seem reasonable to you?


https://reviews.llvm.org/D36713



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


[PATCH] D36771: AMDGPU: add missing amdgcn processors and tests

2017-08-15 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

We should also be defining __devicename__ macros. I opened a bug for this last 
week


https://reviews.llvm.org/D36771



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


[PATCH] D36580: [OpenCL] Support variable memory scope in atomic builtins

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



Comment at: cfe/trunk/lib/Frontend/InitPreprocessor.cpp:581
   // Define macros for the OpenCL memory scope.
   // The values should match clang SyncScope enum.
+  static_assert(

// The values should match clang AtomicScopeOpenCLModel::ID enum.


Repository:
  rL LLVM

https://reviews.llvm.org/D36580



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


[PATCH] D36712: Emit section information for extern variables

2017-08-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: docs/LangRef.rst:628
+information. Attaching section information to an external declaration is an 
+assertion that it's definition is located in the specified section. If the 
+definition is located in a different section, the behavior is undefined.   

"its".


https://reviews.llvm.org/D36712



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


[PATCH] D36773: Fix for internal compiler error when calling __builtin_signbit with invalid arguments

2017-08-15 Thread Josh Seba via Phabricator via cfe-commits
jseba created this revision.
jseba added a project: clang.

Clang has had a regression since version 3.8 where calls to __builtin_signbit 
(and friends signbitf & signbitl) without passing any arguments would cause it 
to segfault because it didn't abort compilation, even though it would properly 
flag the function call as having too few arguments passed in. This patch fixes 
the issue by including signbit in the checks for floating point parameters 
during semantic checks for builtin functions, same as isnan or isinf.

This addresses https://bugs.llvm.org/show_bug.cgi?id=28653 and 
https://bugs.llvm.org/show_bug.cgi?id=28653


https://reviews.llvm.org/D36773

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/builtin-unary-fp.c


Index: test/Sema/builtin-unary-fp.c
===
--- test/Sema/builtin-unary-fp.c
+++ test/Sema/builtin-unary-fp.c
@@ -9,6 +9,9 @@
   check(__builtin_isfinite(1)); // expected-error{{requires argument of 
floating point type}}
   check(__builtin_isinf()); // expected-error{{too few arguments}}
   check(__builtin_isnan(1,2)); // expected-error{{too many arguments}}
+  check(__builtin_signbit()); // expected-error{{too few arguments}}
+  check(__builtin_signbit(1,2)); // expected-error{{too many arguments}}
+  check(__builtin_signbit(1)); // expected-error{{requires argument of 
floating point type}}
   check(__builtin_fpclassify(0, 0, 0, 0, 0, 1.0));
   check(__builtin_fpclassify(0, 0, 0, 0, 0, 1)); // expected-error{{requires 
argument of floating point type}}
   check(__builtin_fpclassify(0, 1, 2, 3, 4.5, 5.0)); // 
expected-warning{{implicit conversion from 'double' to 'int' changes value from 
4.5 to 4}}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -839,6 +839,9 @@
   case Builtin::BI__builtin_isinf_sign:
   case Builtin::BI__builtin_isnan:
   case Builtin::BI__builtin_isnormal:
+  case Builtin::BI__builtin_signbit:
+  case Builtin::BI__builtin_signbitf:
+  case Builtin::BI__builtin_signbitl:
 if (SemaBuiltinFPClassification(TheCall, 1))
   return ExprError();
 break;


Index: test/Sema/builtin-unary-fp.c
===
--- test/Sema/builtin-unary-fp.c
+++ test/Sema/builtin-unary-fp.c
@@ -9,6 +9,9 @@
   check(__builtin_isfinite(1)); // expected-error{{requires argument of floating point type}}
   check(__builtin_isinf()); // expected-error{{too few arguments}}
   check(__builtin_isnan(1,2)); // expected-error{{too many arguments}}
+  check(__builtin_signbit()); // expected-error{{too few arguments}}
+  check(__builtin_signbit(1,2)); // expected-error{{too many arguments}}
+  check(__builtin_signbit(1)); // expected-error{{requires argument of floating point type}}
   check(__builtin_fpclassify(0, 0, 0, 0, 0, 1.0));
   check(__builtin_fpclassify(0, 0, 0, 0, 0, 1)); // expected-error{{requires argument of floating point type}}
   check(__builtin_fpclassify(0, 1, 2, 3, 4.5, 5.0)); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 4.5 to 4}}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -839,6 +839,9 @@
   case Builtin::BI__builtin_isinf_sign:
   case Builtin::BI__builtin_isnan:
   case Builtin::BI__builtin_isnormal:
+  case Builtin::BI__builtin_signbit:
+  case Builtin::BI__builtin_signbitf:
+  case Builtin::BI__builtin_signbitl:
 if (SemaBuiltinFPClassification(TheCall, 1))
   return ExprError();
 break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r310972 - Do not look through pack expansions when looking for unexpanded parameter packs.

2017-08-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Aug 15 15:58:45 2017
New Revision: 310972

URL: http://llvm.org/viewvc/llvm-project?rev=310972=rev
Log:
Do not look through pack expansions when looking for unexpanded parameter packs.

Fixes a selection of rejects-valids when pack-expanding a lambda that itself
contains a pack expansion.

Modified:
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=310972=310971=310972=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Tue Aug 15 15:58:45 2017
@@ -267,6 +267,12 @@ public:
   bool TraverseTemplateArguments(const TemplateArgument *Args,
  unsigned NumArgs);
 
+  /// \brief Recursively visit a base specifier. This can be overridden by a
+  /// subclass.
+  ///
+  /// \returns false if the visitation was terminated early, true otherwise.
+  bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier );
+
   /// \brief Recursively visit a constructor initializer.  This
   /// automatically dispatches to another visitor for the initializer
   /// expression, but not for the name of the initializer, so may
@@ -1769,12 +1775,19 @@ bool RecursiveASTVisitor::Trave
 }
 
 template 
+bool RecursiveASTVisitor::TraverseCXXBaseSpecifier(
+const CXXBaseSpecifier ) {
+  TRY_TO(TraverseTypeLoc(Base.getTypeSourceInfo()->getTypeLoc()));
+  return true;
+}
+
+template 
 bool RecursiveASTVisitor::TraverseCXXRecordHelper(CXXRecordDecl *D) {
   if (!TraverseRecordHelper(D))
 return false;
   if (D->isCompleteDefinition()) {
 for (const auto  : D->bases()) {
-  TRY_TO(TraverseTypeLoc(I.getTypeSourceInfo()->getTypeLoc()));
+  TRY_TO(TraverseCXXBaseSpecifier(I));
 }
 // We don't traverse the friends or the conversions, as they are
 // already in decls_begin()/decls_end().

Modified: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp?rev=310972=310971=310972=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp Tue Aug 15 15:58:45 2017
@@ -161,7 +161,7 @@ namespace {
   return true;
 }
 
-/// \brief Suppress traversel into types with location information
+/// \brief Suppress traversal into types with location information
 /// that do not contain unexpanded parameter packs.
 bool TraverseTypeLoc(TypeLoc TL) {
   if ((!TL.getType().isNull() && 
@@ -172,19 +172,48 @@ namespace {
   return true;
 }
 
-/// \brief Suppress traversal of non-parameter declarations, since
-/// they cannot contain unexpanded parameter packs.
+/// \brief Suppress traversal of parameter packs.
 bool TraverseDecl(Decl *D) { 
-  auto *PVD = dyn_cast_or_null(D);
   // A function parameter pack is a pack expansion, so cannot contain
-  // an unexpanded parameter pack.
-  if (PVD && PVD->isParameterPack())
+  // an unexpanded parameter pack. Likewise for a template parameter
+  // pack that contains any references to other packs.
+  if (D->isParameterPack())
 return true;
 
-  if (PVD || InLambda)
-return inherited::TraverseDecl(D);
+  return inherited::TraverseDecl(D);
+}
 
-  return true;
+/// \brief Suppress traversal of pack-expanded attributes.
+bool TraverseAttr(Attr *A) {
+  if (A->isPackExpansion())
+return true;
+
+  return inherited::TraverseAttr(A);
+}
+
+/// \brief Suppress traversal of pack expansion expressions and types.
+///@{
+bool TraversePackExpansionType(PackExpansionType *T) { return true; }
+bool TraversePackExpansionTypeLoc(PackExpansionTypeLoc TL) { return true; }
+bool TraversePackExpansionExpr(PackExpansionExpr *E) { return true; }
+bool TraverseCXXFoldExpr(CXXFoldExpr *E) { return true; }
+
+///@}
+
+/// \brief Suppress traversal of using-declaration pack expansion.
+bool TraverseUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) {
+  if (D->isPackExpansion())
+return true;
+
+  return inherited::TraverseUnresolvedUsingValueDecl(D);
+}
+
+/// \brief Suppress traversal of using-declaration pack expansion.
+bool TraverseUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D) {
+  if (D->isPackExpansion())
+return true;
+
+  return inherited::TraverseUnresolvedUsingTypenameDecl(D);
 }
 
 /// \brief Suppress traversal of template argument pack expansions.
@@ 

[PATCH] D36771: AMDGPU: add missing amdgcn processors and tests

2017-08-15 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl created this revision.
Herald added subscribers: tpr, dstuttard, yaxunl, nhaehnle, wdng.

- gfx600
- gfx601
- gfx703
- gfx902
- gfx903


https://reviews.llvm.org/D36771

Files:
  lib/Basic/Targets/AMDGPU.cpp
  test/Driver/r600-mcpu.cl

Index: test/Driver/r600-mcpu.cl
===
--- test/Driver/r600-mcpu.cl
+++ test/Driver/r600-mcpu.cl
@@ -26,22 +26,6 @@
 // RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=caicos %s -o - 2>&1 | FileCheck --check-prefix=CAICOS-CHECK %s
 // RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=cayman %s -o - 2>&1 | FileCheck --check-prefix=CAYMAN-CHECK %s
 // RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=aruba %s -o - 2>&1 | FileCheck --check-prefix=CAYMAN-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=tahiti %s -o - 2>&1 | FileCheck --check-prefix=TAHITI-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=pitcairn %s -o - 2>&1 | FileCheck --check-prefix=PITCAIRN-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=verde %s -o - 2>&1 | FileCheck --check-prefix=VERDE-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=oland %s -o - 2>&1 | FileCheck --check-prefix=OLAND-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=bonaire %s -o - 2>&1 | FileCheck --check-prefix=BONAIRE-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kabini %s -o - 2>&1 | FileCheck --check-prefix=KABINI-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri %s -o - 2>&1 | FileCheck --check-prefix=KAVERI-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=hawaii %s -o - 2>&1 | FileCheck --check-prefix=HAWAII-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=mullins %s -o - 2>&1 | FileCheck --check-prefix=MULLINS-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=tonga %s -o - 2>&1 | FileCheck --check-prefix=TONGA-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=iceland %s -o - 2>&1 | FileCheck --check-prefix=ICELAND-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=carrizo %s -o - 2>&1 | FileCheck --check-prefix=CARRIZO-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=fiji %s -o - 2>&1 | FileCheck --check-prefix=FIJI-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=stoney %s -o - 2>&1 | FileCheck --check-prefix=STONEY-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx900 %s -o - 2>&1 | FileCheck --check-prefix=GFX900-CHECK %s
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx901 %s -o - 2>&1 | FileCheck --check-prefix=GFX901-CHECK %s
 
 // R600-CHECK:  "-target-cpu" "r600"
 // RS880-CHECK: "-target-cpu" "rs880"
@@ -58,19 +42,71 @@
 // TURKS-CHECK: "-target-cpu" "turks"
 // CAICOS-CHECK: "-target-cpu" "caicos"
 // CAYMAN-CHECK: "-target-cpu" "cayman"
+
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx600 %s -o - 2>&1 | FileCheck --check-prefix=GFX600-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=tahiti %s -o - 2>&1 | FileCheck --check-prefix=TAHITI-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx601 %s -o - 2>&1 | FileCheck --check-prefix=GFX601-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=pitcairn %s -o - 2>&1 | FileCheck --check-prefix=PITCAIRN-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=verde %s -o - 2>&1 | FileCheck --check-prefix=VERDE-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=oland %s -o - 2>&1 | FileCheck --check-prefix=OLAND-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=hainan %s -o - 2>&1 | FileCheck --check-prefix=HAINAN-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx700 %s -o - 2>&1 | FileCheck --check-prefix=GFX700-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=bonaire %s -o - 2>&1 | FileCheck --check-prefix=BONAIRE-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri %s -o - 2>&1 | FileCheck --check-prefix=KAVERI-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx701 %s -o - 2>&1 | FileCheck --check-prefix=GFX701-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=hawaii %s -o - 2>&1 | FileCheck --check-prefix=HAWAII-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx702 %s -o - 2>&1 | FileCheck --check-prefix=GFX702-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx703 %s -o - 2>&1 | FileCheck --check-prefix=GFX703-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kabini %s -o - 2>&1 | FileCheck --check-prefix=KABINI-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=mullins %s -o - 2>&1 | FileCheck 

[libclc] r310968 - configure.py: Drop explicit import of int builtin

2017-08-15 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Tue Aug 15 15:24:05 2017
New Revision: 310968

URL: http://llvm.org/viewvc/llvm-project?rev=310968=rev
Log:
configure.py: Drop explicit import of int builtin

I can't reproduce the error that made me add this.

Reported-by: Kim Gräsman 
Signed-off-by: Jan Vesely 
Reviewed-by: Kim Gräsman 
Reviewed-by: Aaron Watry 

Modified:
libclc/trunk/configure.py

Modified: libclc/trunk/configure.py
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/configure.py?rev=310968=310967=310968=diff
==
--- libclc/trunk/configure.py (original)
+++ libclc/trunk/configure.py Tue Aug 15 15:24:05 2017
@@ -1,12 +1,6 @@
 #!/usr/bin/python
 from __future__ import print_function
 
-# We only need this for int() cast, which works by default in python 2
-try:
-from builtins import int
-except:
-pass
-
 def c_compiler_rule(b, name, description, compiler, flags):
   command = "%s -MMD -MF $out.d %s -c -o $out $in" % (compiler, flags)
   b.rule(name, command, description + " $out", depfile="$out.d")


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


r310966 - Add a target for new LTO plugin name tests.

2017-08-15 Thread Dan Albert via cfe-commits
Author: danalbert
Date: Tue Aug 15 15:10:44 2017
New Revision: 310966

URL: http://llvm.org/viewvc/llvm-project?rev=310966=rev
Log:
Add a target for new LTO plugin name tests.

Not all targets will use -plugin with -flto. Pick a fixed target so
this works regardless of the default target (regardless of host OS,
the toolchain should be picking the correct LTO plugin for a target
that supports it).

Modified:
cfe/trunk/test/Driver/lto-plugin-darwin.c
cfe/trunk/test/Driver/lto-plugin-linux.c
cfe/trunk/test/Driver/lto-plugin-windows.c

Modified: cfe/trunk/test/Driver/lto-plugin-darwin.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/lto-plugin-darwin.c?rev=310966=310965=310966=diff
==
--- cfe/trunk/test/Driver/lto-plugin-darwin.c (original)
+++ cfe/trunk/test/Driver/lto-plugin-darwin.c Tue Aug 15 15:10:44 2017
@@ -1,6 +1,6 @@
 // Check that Darwin uses LLVMgold.dylib.
 // REQUIRES: system-darwin
-// RUN: %clang -### %s -flto 2>&1 \
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
 //
 // CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.dylib"

Modified: cfe/trunk/test/Driver/lto-plugin-linux.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/lto-plugin-linux.c?rev=310966=310965=310966=diff
==
--- cfe/trunk/test/Driver/lto-plugin-linux.c (original)
+++ cfe/trunk/test/Driver/lto-plugin-linux.c Tue Aug 15 15:10:44 2017
@@ -1,6 +1,6 @@
 // Check that non-Windows, non-Darwin OSs use LLVMgold.so.
 // REQUIRES: !system-darwin && !system-windows
-// RUN: %clang -### %s -flto 2>&1 \
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
 //
 // CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.so"

Modified: cfe/trunk/test/Driver/lto-plugin-windows.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/lto-plugin-windows.c?rev=310966=310965=310966=diff
==
--- cfe/trunk/test/Driver/lto-plugin-windows.c (original)
+++ cfe/trunk/test/Driver/lto-plugin-windows.c Tue Aug 15 15:10:44 2017
@@ -1,6 +1,6 @@
 // Check that Windows uses LLVMgold.dll.
 // REQUIRES: system-windows
-// RUN: %clang -### %s -flto 2>&1 \
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
 //
 // CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.dll"


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


r310962 - Allow StmtVisitor visitation to be parameterized. NFC.

2017-08-15 Thread John McCall via cfe-commits
Author: rjmccall
Date: Tue Aug 15 14:42:42 2017
New Revision: 310962

URL: http://llvm.org/viewvc/llvm-project?rev=310962=rev
Log:
Allow StmtVisitor visitation to be parameterized.  NFC.

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

Modified: cfe/trunk/include/clang/AST/StmtVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtVisitor.h?rev=310962=310961=310962=diff
==
--- cfe/trunk/include/clang/AST/StmtVisitor.h (original)
+++ cfe/trunk/include/clang/AST/StmtVisitor.h Tue Aug 15 14:42:42 2017
@@ -29,15 +29,17 @@ template  struct make_const_
 /// StmtVisitorBase - This class implements a simple visitor for Stmt
 /// subclasses. Since Expr derives from Stmt, this also includes support for
 /// visiting Exprs.
-template class Ptr, typename ImplClass, typename 
RetTy=void>
+template class Ptr, typename ImplClass, typename 
RetTy=void,
+ class... ParamTys>
 class StmtVisitorBase {
 public:
 
 #define PTR(CLASS) typename Ptr::type
 #define DISPATCH(NAME, CLASS) \
- return static_cast(this)->Visit ## 
NAME(static_cast(S))
+  return static_cast(this)->Visit ## NAME( \
+static_cast(S), std::forward(P)...)
 
-  RetTy Visit(PTR(Stmt) S) {
+  RetTy Visit(PTR(Stmt) S, ParamTys... P) {
 
 // If we have a binary expr, dispatch to the subcode of the binop.  A smart
 // optimizer (e.g. LLVM) will fold this comparison into the switch stmt
@@ -111,13 +113,13 @@ public:
   // If the implementation chooses not to implement a certain visit method, 
fall
   // back on VisitExpr or whatever else is the superclass.
 #define STMT(CLASS, PARENT)   \
-  RetTy Visit ## CLASS(PTR(CLASS) S) { DISPATCH(PARENT, PARENT); }
+  RetTy Visit ## CLASS(PTR(CLASS) S, ParamTys... P) { DISPATCH(PARENT, 
PARENT); }
 #include "clang/AST/StmtNodes.inc"
 
   // If the implementation doesn't implement binary operator methods, fall back
   // on VisitBinaryOperator.
 #define BINOP_FALLBACK(NAME) \
-  RetTy VisitBin ## NAME(PTR(BinaryOperator) S) { \
+  RetTy VisitBin ## NAME(PTR(BinaryOperator) S, ParamTys... P) { \
 DISPATCH(BinaryOperator, BinaryOperator); \
   }
   BINOP_FALLBACK(PtrMemD)BINOP_FALLBACK(PtrMemI)
@@ -137,7 +139,7 @@ public:
   // If the implementation doesn't implement compound assignment operator
   // methods, fall back on VisitCompoundAssignOperator.
 #define CAO_FALLBACK(NAME) \
-  RetTy VisitBin ## NAME(PTR(CompoundAssignOperator) S) { \
+  RetTy VisitBin ## NAME(PTR(CompoundAssignOperator) S, ParamTys... P) { \
 DISPATCH(CompoundAssignOperator, CompoundAssignOperator); \
   }
   CAO_FALLBACK(MulAssign) CAO_FALLBACK(DivAssign) CAO_FALLBACK(RemAssign)
@@ -149,7 +151,7 @@ public:
   // If the implementation doesn't implement unary operator methods, fall back
   // on VisitUnaryOperator.
 #define UNARYOP_FALLBACK(NAME) \
-  RetTy VisitUnary ## NAME(PTR(UnaryOperator) S) { \
+  RetTy VisitUnary ## NAME(PTR(UnaryOperator) S, ParamTys... P) { \
 DISPATCH(UnaryOperator, UnaryOperator);\
   }
   UNARYOP_FALLBACK(PostInc)   UNARYOP_FALLBACK(PostDec)
@@ -163,7 +165,7 @@ public:
 #undef UNARYOP_FALLBACK
 
   // Base case, ignore it. :)
-  RetTy VisitStmt(PTR(Stmt) Node) { return RetTy(); }
+  RetTy VisitStmt(PTR(Stmt) Node, ParamTys... P) { return RetTy(); }
 
 #undef PTR
 #undef DISPATCH
@@ -174,18 +176,18 @@ public:
 ///
 /// This class does not preserve constness of Stmt pointers (see also
 /// ConstStmtVisitor).
-template
+template
 class StmtVisitor
- : public StmtVisitorBase {};
+ : public StmtVisitorBase {};
 
 /// ConstStmtVisitor - This class implements a simple visitor for Stmt
 /// subclasses. Since Expr derives from Stmt, this also includes support for
 /// visiting Exprs.
 ///
 /// This class preserves constness of Stmt pointers (see also StmtVisitor).
-template
+template
 class ConstStmtVisitor
- : public StmtVisitorBase {};
+ : public StmtVisitorBase {};
 
 /// \brief This class implements a simple visitor for OMPClause
 /// subclasses.


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


r310963 - Allow the target field of a CK_ToUnion to be more easily recovered.

2017-08-15 Thread John McCall via cfe-commits
Author: rjmccall
Date: Tue Aug 15 14:42:47 2017
New Revision: 310963

URL: http://llvm.org/viewvc/llvm-project?rev=310963=rev
Log:
Allow the target field of a CK_ToUnion to be more easily recovered.

Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/Sema/SemaCast.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=310963=310962=310963=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Aug 15 14:42:47 2017
@@ -2772,6 +2772,16 @@ public:
   path_const_iterator path_begin() const { return path_buffer(); }
   path_const_iterator path_end() const { return path_buffer() + path_size(); }
 
+  const FieldDecl *getTargetUnionField() const {
+assert(getCastKind() == CK_ToUnion);
+return getTargetFieldForToUnionCast(getType(), getSubExpr()->getType());
+  }
+
+  static const FieldDecl *getTargetFieldForToUnionCast(QualType unionType,
+   QualType opType);
+  static const FieldDecl *getTargetFieldForToUnionCast(const RecordDecl *RD,
+   QualType opType);
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() >= firstCastExprConstant &&
T->getStmtClass() <= lastCastExprConstant;

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=310963=310962=310963=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Tue Aug 15 14:42:47 2017
@@ -1695,6 +1695,26 @@ CXXBaseSpecifier **CastExpr::path_buffer
   }
 }
 
+const FieldDecl *CastExpr::getTargetFieldForToUnionCast(QualType unionType,
+QualType opType) {
+  auto RD = unionType->castAs()->getDecl();
+  return getTargetFieldForToUnionCast(RD, opType);
+}
+
+const FieldDecl *CastExpr::getTargetFieldForToUnionCast(const RecordDecl *RD,
+QualType OpType) {
+  auto  = RD->getASTContext();
+  RecordDecl::field_iterator Field, FieldEnd;
+  for (Field = RD->field_begin(), FieldEnd = RD->field_end();
+   Field != FieldEnd; ++Field) {
+if (Ctx.hasSameUnqualifiedType(Field->getType(), OpType) &&
+!Field->isUnnamedBitfield()) {
+  return *Field;
+}
+  }
+  return nullptr;
+}
+
 ImplicitCastExpr *ImplicitCastExpr::Create(const ASTContext , QualType T,
CastKind Kind, Expr *Operand,
const CXXCastPath *BasePath,

Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=310963=310962=310963=diff
==
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCast.cpp Tue Aug 15 14:42:47 2017
@@ -2458,24 +2458,17 @@ void CastOperation::CheckCStyleCast() {
 // GCC's cast to union extension.
 if (DestRecordTy && DestRecordTy->getDecl()->isUnion()) {
   RecordDecl *RD = DestRecordTy->getDecl();
-  RecordDecl::field_iterator Field, FieldEnd;
-  for (Field = RD->field_begin(), FieldEnd = RD->field_end();
-   Field != FieldEnd; ++Field) {
-if (Self.Context.hasSameUnqualifiedType(Field->getType(), SrcType) &&
-!Field->isUnnamedBitfield()) {
-  Self.Diag(OpRange.getBegin(), diag::ext_typecheck_cast_to_union)
-<< SrcExpr.get()->getSourceRange();
-  break;
-}
-  }
-  if (Field == FieldEnd) {
+  if (CastExpr::getTargetFieldForToUnionCast(RD, SrcType)) {
+Self.Diag(OpRange.getBegin(), diag::ext_typecheck_cast_to_union)
+  << SrcExpr.get()->getSourceRange();
+Kind = CK_ToUnion;
+return;
+  } else {
 Self.Diag(OpRange.getBegin(), 
diag::err_typecheck_cast_to_union_no_type)
   << SrcType << SrcExpr.get()->getSourceRange();
 SrcExpr = ExprError();
 return;
   }
-  Kind = CK_ToUnion;
-  return;
 }
 
 // OpenCL v2.0 s6.13.10 - Allow casts from '0' to event_t type.


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


r310964 - Extract IRGen's constant-emitter into its own helper class and clean up

2017-08-15 Thread John McCall via cfe-commits
Author: rjmccall
Date: Tue Aug 15 14:42:52 2017
New Revision: 310964

URL: http://llvm.org/viewvc/llvm-project?rev=310964=rev
Log:
Extract IRGen's constant-emitter into its own helper class and clean up
the interface.

The ultimate goal here is to make it easier to do some more interesting
things in constant emission, like emit constant initializers that have
ignorable side-effects, or doing the majority of an initialization
in-place and then patching up the last few things with calls.  But for
now this is mostly just a refactoring.

Added:
cfe/trunk/lib/CodeGen/ConstantEmitter.h
Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=310964=310963=310964=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Tue Aug 15 14:42:52 2017
@@ -16,6 +16,7 @@
 #include "CGObjCRuntime.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
+#include "ConstantEmitter.h"
 #include "clang/CodeGen/ConstantInitBuilder.h"
 #include "clang/AST/DeclObjC.h"
 #include "llvm/ADT/SmallSet.h"
@@ -290,7 +291,7 @@ static llvm::Constant *tryCaptureAsConst
   const Expr *init = var->getInit();
   if (!init) return nullptr;
 
-  return CGM.EmitConstantInit(*var, CGF);
+  return ConstantEmitter(CGM, CGF).tryEmitAbstractForInitializer(*var);
 }
 
 /// Get the low bit of a nonzero character count.  This is the

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=310964=310963=310964=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Aug 15 14:42:52 2017
@@ -16,6 +16,7 @@
 #include "CGOpenCLRuntime.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
+#include "ConstantEmitter.h"
 #include "TargetInfo.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
@@ -680,7 +681,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   default: break;  // Handle intrinsics and libm functions below.
   case Builtin::BI__builtin___CFStringMakeConstantString:
   case Builtin::BI__builtin___NSStringMakeConstantString:
-return RValue::get(CGM.EmitConstantExpr(E, E->getType(), nullptr));
+return RValue::get(ConstantEmitter(*this).emitAbstract(E, E->getType()));
   case Builtin::BI__builtin_stdarg_start:
   case Builtin::BI__builtin_va_start:
   case Builtin::BI__va_start:
@@ -1366,8 +1367,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   llvm::ConstantInt::get(Int32Ty, 
Offset)));
   }
   case Builtin::BI__builtin_return_address: {
-Value *Depth =
-CGM.EmitConstantExpr(E->getArg(0), getContext().UnsignedIntTy, this);
+Value *Depth = ConstantEmitter(*this).emitAbstract(E->getArg(0),
+   getContext().UnsignedIntTy);
 Value *F = CGM.getIntrinsic(Intrinsic::returnaddress);
 return RValue::get(Builder.CreateCall(F, Depth));
   }
@@ -1376,8 +1377,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 return RValue::get(Builder.CreateCall(F, Builder.getInt32(0)));
   }
   case Builtin::BI__builtin_frame_address: {
-Value *Depth =
-CGM.EmitConstantExpr(E->getArg(0), getContext().UnsignedIntTy, this);
+Value *Depth = ConstantEmitter(*this).emitAbstract(E->getArg(0),
+   getContext().UnsignedIntTy);
 Value *F = CGM.getIntrinsic(Intrinsic::frameaddress);
 return RValue::get(Builder.CreateCall(F, Depth));
   }

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=310964=310963=310964=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Aug 15 14:42:52 2017
@@ -18,6 +18,7 @@
 #include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
+#include "ConstantEmitter.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -1601,7 +1602,7 @@ CGDebugInfo::CollectTemplateParams(const
   QualType T = E->getType();
   if (E->isGLValue())
 T = CGM.getContext().getLValueReferenceType(T);
-  llvm::Constant *V = CGM.EmitConstantExpr(E, T);
+  llvm::Constant *V = 

[PATCH] D36728: Switch to consumeError(), since this can crash otherwise.

2017-08-15 Thread Stephen Hines via Phabricator via cfe-commits
srhines added a comment.

In https://reviews.llvm.org/D36728#842644, @lhames wrote:

> The preferred solution to this is actually to wrap the call with cantFail 
> (See 
> http://llvm.org/docs/ProgrammersManual.html#using-cantfail-to-simplify-safe-callsites)
>  -- it will handle both the assertion and consumption of the value for you, 
> and will simplify calls that return an Expected.


Is it ok to drop the assertion in that case (and convert it to a comment)? I 
didn't want to alter too much of this check, since perhaps the original 
author(s) were more skeptical about this breaking (hence the assertion). 
Something like:

// Replacements must not conflict since ranges have been merged.
llvm::cantFail(FakeReplaces.add(...));


Repository:
  rL LLVM

https://reviews.llvm.org/D36728



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


[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-15 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann added inline comments.



Comment at: unittests/Format/FormatTest.cpp:2405-2408
+  // Defect: We currently do not deal with cases where legitimate lines may be
+  // outside an include guard. Examples are #pragma once and
+  // #pragma GCC diagnostic, or anything else that does not change the meaning
+  // of the file if it's included multiple times.

mzeren-vmw wrote:
> We need to handle comments (like copyrights) before the include guard. There 
> is an analogous problem with trailing blank lines, or trailing comments.
> 
> I think we need a small state machine: Init, Start, Open, Closed, NotGuard 
> (terminal). `FoundIncludeGuardStart` should change from a bool to an enum to 
> track this state. `PPMaybeIncludeGuard` can then drop it's "mabye". Whether 
> or not it is null depends directly on the state. It does not determine state 
> itself. While parsing, each line updates the state. If we get to `eof` in the 
> Closed state then we have detected an include guard. ... Or similar logic
> 
> Note that support for comments before the guard opens the door to support for 
> #pragma once. It is tempting to add that, but that is a slippery slope. I 
> would recommend leaving that as a defect that can be addressed later.
@djasper @klimek
Do you have any comments on this? I've begun to implement an enum/state machine 
but I'd like to know if you'd like me to implement a different way.


https://reviews.llvm.org/D35955



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


[PATCH] D36769: Revert "Revert "Fix LLVMgold plugin name/path for non-Linux.""

2017-08-15 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310960: Revert "Revert "Fix LLVMgold plugin name/path for 
non-Linux."" (authored by danalbert).

Repository:
  rL LLVM

https://reviews.llvm.org/D36769

Files:
  cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
  cfe/trunk/test/Driver/freebsd.c
  cfe/trunk/test/Driver/gold-lto.c
  cfe/trunk/test/Driver/lto-plugin-darwin.c
  cfe/trunk/test/Driver/lto-plugin-linux.c
  cfe/trunk/test/Driver/lto-plugin-windows.c
  cfe/trunk/test/Driver/lto.c
  cfe/trunk/test/Driver/thinlto.c

Index: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
@@ -376,8 +376,20 @@
   // as gold requires -plugin to come before any -plugin-opt that -Wl might
   // forward.
   CmdArgs.push_back("-plugin");
-  std::string Plugin =
-  ToolChain.getDriver().Dir + "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold.so";
+
+#if defined(LLVM_ON_WIN32)
+  const char *Suffix = ".dll";
+#elif defined(__APPLE__)
+  const char *Suffix = ".dylib";
+#else
+  const char *Suffix = ".so";
+#endif
+
+  SmallString<1024> Plugin;
+  llvm::sys::path::native(Twine(ToolChain.getDriver().Dir) +
+  "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold" +
+  Suffix,
+  Plugin);
   CmdArgs.push_back(Args.MakeArgString(Plugin));
 
   // Try to pass driver level flags relevant to LTO code generation down to
Index: cfe/trunk/test/Driver/lto-plugin-windows.c
===
--- cfe/trunk/test/Driver/lto-plugin-windows.c
+++ cfe/trunk/test/Driver/lto-plugin-windows.c
@@ -0,0 +1,6 @@
+// Check that Windows uses LLVMgold.dll.
+// REQUIRES: system-windows
+// RUN: %clang -### %s -flto 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
+//
+// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.dll"
Index: cfe/trunk/test/Driver/lto-plugin-linux.c
===
--- cfe/trunk/test/Driver/lto-plugin-linux.c
+++ cfe/trunk/test/Driver/lto-plugin-linux.c
@@ -0,0 +1,6 @@
+// Check that non-Windows, non-Darwin OSs use LLVMgold.so.
+// REQUIRES: !system-darwin && !system-windows
+// RUN: %clang -### %s -flto 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
+//
+// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.so"
Index: cfe/trunk/test/Driver/lto-plugin-darwin.c
===
--- cfe/trunk/test/Driver/lto-plugin-darwin.c
+++ cfe/trunk/test/Driver/lto-plugin-darwin.c
@@ -0,0 +1,6 @@
+// Check that Darwin uses LLVMgold.dylib.
+// REQUIRES: system-darwin
+// RUN: %clang -### %s -flto 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
+//
+// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.dylib"
Index: cfe/trunk/test/Driver/gold-lto.c
===
--- cfe/trunk/test/Driver/gold-lto.c
+++ cfe/trunk/test/Driver/gold-lto.c
@@ -3,26 +3,26 @@
 // RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
 // RUN: -Wl,-plugin-opt=foo -O3 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-64-BASIC
-// CHECK-X86-64-BASIC: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-X86-64-BASIC: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 // CHECK-X86-64-BASIC: "-plugin-opt=O3"
 // CHECK-X86-64-BASIC: "-plugin-opt=foo"
 //
 // RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
 // RUN: -march=corei7 -Wl,-plugin-opt=foo -Ofast \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-64-COREI7
-// CHECK-X86-64-COREI7: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-X86-64-COREI7: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 // CHECK-X86-64-COREI7: "-plugin-opt=mcpu=corei7"
 // CHECK-X86-64-COREI7: "-plugin-opt=O3"
 // CHECK-X86-64-COREI7: "-plugin-opt=foo"
 //
 // RUN: %clang -target arm-unknown-linux -### %t.o -flto 2>&1 \
 // RUN: -march=armv7a -Wl,-plugin-opt=foo -O0 \
 // RUN: | FileCheck %s --check-prefix=CHECK-ARM-V7A
-// CHECK-ARM-V7A: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-ARM-V7A: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 // CHECK-ARM-V7A: "-plugin-opt=mcpu=generic"
 // CHECK-ARM-V7A: "-plugin-opt=O0"
 // CHECK-ARM-V7A: "-plugin-opt=foo"
 //
 // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-ANDROID
-// CHECK-X86-ANDROID: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-X86-ANDROID: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
Index: cfe/trunk/test/Driver/thinlto.c
===
--- cfe/trunk/test/Driver/thinlto.c
+++ cfe/trunk/test/Driver/thinlto.c
@@ -19,19 +19,19 @@
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=full -fno-lto -flto=thin 2> %t
 // RUN: FileCheck 

r310960 - Revert "Revert "Fix LLVMgold plugin name/path for non-Linux.""

2017-08-15 Thread Dan Albert via cfe-commits
Author: danalbert
Date: Tue Aug 15 14:31:17 2017
New Revision: 310960

URL: http://llvm.org/viewvc/llvm-project?rev=310960=rev
Log:
Revert "Revert "Fix LLVMgold plugin name/path for non-Linux.""

Summary:
Relanding https://reviews.llvm.org/D35739 which was reverted because
it broke the tests on non-Linux. The tests have been fixed to be
platform agnostic, and additional tests have been added to make sure
that the plugin has the correct extension on each platform
(%pluginext doesn't work in CHECK lines).

Reviewers: srhines, pirama

Reviewed By: srhines

Subscribers: emaste, mehdi_amini, eraman, cfe-commits

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

Added:
cfe/trunk/test/Driver/lto-plugin-darwin.c
cfe/trunk/test/Driver/lto-plugin-linux.c
cfe/trunk/test/Driver/lto-plugin-windows.c
Modified:
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/test/Driver/freebsd.c
cfe/trunk/test/Driver/gold-lto.c
cfe/trunk/test/Driver/lto.c
cfe/trunk/test/Driver/thinlto.c

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=310960=310959=310960=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Tue Aug 15 14:31:17 2017
@@ -376,8 +376,20 @@ void tools::AddGoldPlugin(const ToolChai
   // as gold requires -plugin to come before any -plugin-opt that -Wl might
   // forward.
   CmdArgs.push_back("-plugin");
-  std::string Plugin =
-  ToolChain.getDriver().Dir + "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold.so";
+
+#if defined(LLVM_ON_WIN32)
+  const char *Suffix = ".dll";
+#elif defined(__APPLE__)
+  const char *Suffix = ".dylib";
+#else
+  const char *Suffix = ".so";
+#endif
+
+  SmallString<1024> Plugin;
+  llvm::sys::path::native(Twine(ToolChain.getDriver().Dir) +
+  "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold" +
+  Suffix,
+  Plugin);
   CmdArgs.push_back(Args.MakeArgString(Plugin));
 
   // Try to pass driver level flags relevant to LTO code generation down to

Modified: cfe/trunk/test/Driver/freebsd.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/freebsd.c?rev=310960=310959=310960=diff
==
--- cfe/trunk/test/Driver/freebsd.c (original)
+++ cfe/trunk/test/Driver/freebsd.c Tue Aug 15 14:31:17 2017
@@ -127,7 +127,7 @@
 
 // RUN: %clang -target x86_64-pc-freebsd8 %s -### -flto 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-LTO %s
-// CHECK-LTO: ld{{.*}}" "-plugin{{.*}}LLVMgold.so
+// CHECK-LTO: ld{{.*}}" "-plugin{{.*}}LLVMgold.{{dll|dylib|so}}
 
 // RUN: %clang -target sparc-unknown-freebsd8 %s -### -fpic -no-integrated-as 
2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-SPARC-PIE %s

Modified: cfe/trunk/test/Driver/gold-lto.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/gold-lto.c?rev=310960=310959=310960=diff
==
--- cfe/trunk/test/Driver/gold-lto.c (original)
+++ cfe/trunk/test/Driver/gold-lto.c Tue Aug 15 14:31:17 2017
@@ -3,14 +3,14 @@
 // RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
 // RUN: -Wl,-plugin-opt=foo -O3 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-64-BASIC
-// CHECK-X86-64-BASIC: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-X86-64-BASIC: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 // CHECK-X86-64-BASIC: "-plugin-opt=O3"
 // CHECK-X86-64-BASIC: "-plugin-opt=foo"
 //
 // RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
 // RUN: -march=corei7 -Wl,-plugin-opt=foo -Ofast \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-64-COREI7
-// CHECK-X86-64-COREI7: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-X86-64-COREI7: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 // CHECK-X86-64-COREI7: "-plugin-opt=mcpu=corei7"
 // CHECK-X86-64-COREI7: "-plugin-opt=O3"
 // CHECK-X86-64-COREI7: "-plugin-opt=foo"
@@ -18,11 +18,11 @@
 // RUN: %clang -target arm-unknown-linux -### %t.o -flto 2>&1 \
 // RUN: -march=armv7a -Wl,-plugin-opt=foo -O0 \
 // RUN: | FileCheck %s --check-prefix=CHECK-ARM-V7A
-// CHECK-ARM-V7A: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-ARM-V7A: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 // CHECK-ARM-V7A: "-plugin-opt=mcpu=generic"
 // CHECK-ARM-V7A: "-plugin-opt=O0"
 // CHECK-ARM-V7A: "-plugin-opt=foo"
 //
 // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-ANDROID
-// CHECK-X86-ANDROID: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-X86-ANDROID: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"

Added: cfe/trunk/test/Driver/lto-plugin-darwin.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/lto-plugin-darwin.c?rev=310960=auto

[PATCH] D36728: Switch to consumeError(), since this can crash otherwise.

2017-08-15 Thread Lang Hames via Phabricator via cfe-commits
lhames added a comment.

The preferred solution to this is actually to wrap the call with cantFail (See 
http://llvm.org/docs/ProgrammersManual.html#using-cantfail-to-simplify-safe-callsites)
 -- it will handle both the assertion and consumption of the value for you, and 
will simplify calls that return an Expected.


Repository:
  rL LLVM

https://reviews.llvm.org/D36728



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


[PATCH] D36769: Revert "Revert "Fix LLVMgold plugin name/path for non-Linux.""

2017-08-15 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
Herald added subscribers: eraman, mehdi_amini, emaste.

Relanding https://reviews.llvm.org/D35739 which was reverted because
it broke the tests on non-Linux. The tests have been fixed to be
platform agnostic, and additional tests have been added to make sure
that the plugin has the correct extension on each platform
(%pluginext doesn't work in CHECK lines).


https://reviews.llvm.org/D36769

Files:
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/freebsd.c
  test/Driver/gold-lto.c
  test/Driver/lto-plugin-darwin.c
  test/Driver/lto-plugin-linux.c
  test/Driver/lto-plugin-windows.c
  test/Driver/lto.c
  test/Driver/thinlto.c

Index: test/Driver/thinlto.c
===
--- test/Driver/thinlto.c
+++ test/Driver/thinlto.c
@@ -19,19 +19,19 @@
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=full -fno-lto -flto=thin 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-THIN-ACTION < %t %s
 //
-// CHECK-LINK-THIN-ACTION: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-THIN-ACTION: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 // CHECK-LINK-THIN-ACTION: "-plugin-opt=thinlto"
 
 // Check that subsequent -flto=full takes precedence
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -flto=full 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-FULL-ACTION < %t %s
 //
-// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 // CHECK-LINK-FULL-ACTION-NOT: "-plugin-opt=thinlto"
 
 // Check that subsequent -fno-lto takes precedence
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -fno-lto 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-NOLTO-ACTION < %t %s
 //
-// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 // CHECK-LINK-NOLTO-ACTION-NOT: "-plugin-opt=thinlto"
Index: test/Driver/lto.c
===
--- test/Driver/lto.c
+++ test/Driver/lto.c
@@ -36,19 +36,19 @@
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-LTO-ACTION < %t %s
 //
-// CHECK-LINK-LTO-ACTION: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-LTO-ACTION: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 
 // -flto=full should cause link using gold plugin
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=full 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-FULL-ACTION < %t %s
 //
-// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 
 // Check that subsequent -fno-lto takes precedence
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=full -fno-lto 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-NOLTO-ACTION < %t %s
 //
-// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 
 // -flto passes along an explicit debugger tuning argument.
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto -glldb 2> %t
Index: test/Driver/lto-plugin-windows.c
===
--- /dev/null
+++ test/Driver/lto-plugin-windows.c
@@ -0,0 +1,6 @@
+// Check that Windows uses LLVMgold.dll.
+// REQUIRES: system-windows
+// RUN: %clang -### %s -flto 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
+//
+// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.dll"
Index: test/Driver/lto-plugin-linux.c
===
--- /dev/null
+++ test/Driver/lto-plugin-linux.c
@@ -0,0 +1,6 @@
+// Check that non-Windows, non-Darwin OSs use LLVMgold.so.
+// REQUIRES: !system-darwin && !system-windows
+// RUN: %clang -### %s -flto 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
+//
+// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.so"
Index: test/Driver/lto-plugin-darwin.c
===
--- /dev/null
+++ test/Driver/lto-plugin-darwin.c
@@ -0,0 +1,6 @@
+// Check that Darwin uses LLVMgold.dylib.
+// REQUIRES: system-darwin
+// RUN: %clang -### %s -flto 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
+//
+// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.dylib"
Index: test/Driver/gold-lto.c
===
--- test/Driver/gold-lto.c
+++ test/Driver/gold-lto.c
@@ -3,26 +3,26 @@
 // RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
 // RUN: -Wl,-plugin-opt=foo -O3 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-64-BASIC
-// CHECK-X86-64-BASIC: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-X86-64-BASIC: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 // CHECK-X86-64-BASIC: "-plugin-opt=O3"
 // CHECK-X86-64-BASIC: "-plugin-opt=foo"
 //
 // RUN: %clang -target 

[PATCH] D36728: Switch to consumeError(), since this can crash otherwise.

2017-08-15 Thread Stephen Hines via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310958: Switch to consumeError(), since this can crash 
otherwise. (authored by srhines).

Repository:
  rL LLVM

https://reviews.llvm.org/D36728

Files:
  cfe/trunk/lib/Tooling/Core/Replacement.cpp


Index: cfe/trunk/lib/Tooling/Core/Replacement.cpp
===
--- cfe/trunk/lib/Tooling/Core/Replacement.cpp
+++ cfe/trunk/lib/Tooling/Core/Replacement.cpp
@@ -503,7 +503,7 @@
 std::string(R.getLength(), ' ')));
 assert(!Err &&
"Replacements must not conflict since ranges have been merged.");
-(void)Err;
+llvm::consumeError(std::move(Err));
   }
   return FakeReplaces.merge(Replaces).getAffectedRanges();
 }


Index: cfe/trunk/lib/Tooling/Core/Replacement.cpp
===
--- cfe/trunk/lib/Tooling/Core/Replacement.cpp
+++ cfe/trunk/lib/Tooling/Core/Replacement.cpp
@@ -503,7 +503,7 @@
 std::string(R.getLength(), ' ')));
 assert(!Err &&
"Replacements must not conflict since ranges have been merged.");
-(void)Err;
+llvm::consumeError(std::move(Err));
   }
   return FakeReplaces.merge(Replaces).getAffectedRanges();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r310958 - Switch to consumeError(), since this can crash otherwise.

2017-08-15 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Tue Aug 15 14:20:41 2017
New Revision: 310958

URL: http://llvm.org/viewvc/llvm-project?rev=310958=rev
Log:
Switch to consumeError(), since this can crash otherwise.

Summary:
If assertions are disabled, but LLVM_ABI_BREAKING_CHANGES is enabled,
this will cause an issue with an unchecked Success. Switching to
consumeError() is the correct way to bypass the check.

Reviewers: llvm-commits, cfe-commits, arphaman

Reviewed By: arphaman

Subscribers: arphaman, klimek, pirama

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

Modified:
cfe/trunk/lib/Tooling/Core/Replacement.cpp

Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Replacement.cpp?rev=310958=310957=310958=diff
==
--- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
+++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Tue Aug 15 14:20:41 2017
@@ -503,7 +503,7 @@ calculateRangesAfterReplacements(const R
 std::string(R.getLength(), ' ')));
 assert(!Err &&
"Replacements must not conflict since ranges have been merged.");
-(void)Err;
+llvm::consumeError(std::move(Err));
   }
   return FakeReplaces.merge(Replaces).getAffectedRanges();
 }


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


[PATCH] D36767: Implement the standard for timeouts for std::condition_variable

2017-08-15 Thread Tom via Phabricator via cfe-commits
tomcherry added a comment.

This is mostly an RFC.  The underlying issue is that we cannot use timed waits 
based on CLOCK_REALTIME on Android.  In trying to fix that, I figured I might 
as well try implementing the standard as described, though I understand that 
there'd be resistance to such a re-implementation.


https://reviews.llvm.org/D36767



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


[PATCH] D36767: Implement the standard for timeouts for std::condition_variable

2017-08-15 Thread Tom via Phabricator via cfe-commits
tomcherry created this revision.

The C++ standard calls for wait_for() to use steady clock and
 wait_until() to use the clock that is provided as an argument.  This
 is not currently done in libc++ and is not possible with the pthreads
 API, however it is possible with the underlying futex system call.

  

This change re-implements std::condition_variable with a tweaked
 version of the implementation of pthread_cond_* from Android bionic to
 support the correct semantics.

  

Bug: 35756266


https://reviews.llvm.org/D36767

Files:
  include/__mutex_base
  src/condition_variable.cpp

Index: src/condition_variable.cpp
===
--- src/condition_variable.cpp
+++ src/condition_variable.cpp
@@ -11,6 +11,10 @@
 
 #ifndef _LIBCPP_HAS_NO_THREADS
 
+#include 
+#include 
+#include 
+
 #include "condition_variable"
 #include "thread"
 #include "system_error"
@@ -20,60 +24,95 @@
 
 condition_variable::~condition_variable()
 {
-__libcpp_condvar_destroy(&__cv_);
+atomic_store_explicit(&__state, 0xdeadc04d, memory_order_relaxed);
+}
+
+void
+condition_variable::__pulse(int thread_count) _NOEXCEPT
+{
+_LIBCPP_CONSTEXPR unsigned int kCondCounterStep = 0x0004;
+atomic_fetch_add_explicit(&__state, kCondCounterStep, memory_order_relaxed);
+__futex(&__state, FUTEX_WAKE_PRIVATE, thread_count, nullptr, 0);
 }
 
 void
 condition_variable::notify_one() _NOEXCEPT
 {
-__libcpp_condvar_signal(&__cv_);
+__pulse(1);
 }
 
 void
 condition_variable::notify_all() _NOEXCEPT
 {
-__libcpp_condvar_broadcast(&__cv_);
+__pulse(numeric_limits::max());
 }
 
 void
 condition_variable::wait(unique_lock& lk) _NOEXCEPT
 {
-if (!lk.owns_lock())
-__throw_system_error(EPERM,
-  "condition_variable::wait: mutex not locked");
-int ec = __libcpp_condvar_wait(&__cv_, lk.mutex()->native_handle());
-if (ec)
-__throw_system_error(ec, "condition_variable wait failed");
+__wait(lk, chrono::nanoseconds(0), false, false);
 }
 
-void
-condition_variable::__do_timed_wait(unique_lock& lk,
- chrono::time_point tp) _NOEXCEPT
+int
+condition_variable::__wait(unique_lock& __lk, chrono::nanoseconds __t,
+   bool __rel_timeout, bool __realtime) _NOEXCEPT
 {
+int op;
+int val3;
+
+if (__t.count() == 0 || __rel_timeout) {
+op = FUTEX_WAIT_PRIVATE;
+val3 = 0;
+} else if (__realtime) {
+op = FUTEX_WAIT_BITSET_PRIVATE | FUTEX_CLOCK_REALTIME;
+val3 = FUTEX_BITSET_MATCH_ANY;
+} else {
+op = FUTEX_WAIT_BITSET_PRIVATE;
+val3 = FUTEX_BITSET_MATCH_ANY;
+}
+
 using namespace chrono;
-if (!lk.owns_lock())
-__throw_system_error(EPERM,
-"condition_variable::timed wait: mutex not locked");
-nanoseconds d = tp.time_since_epoch();
-if (d > nanoseconds(0x59682F00E941))
-d = nanoseconds(0x59682F00E941);
+if (__t > nanoseconds(0x59682F00E941))
+__t = nanoseconds(0x59682F00E941);
 timespec ts;
-seconds s = duration_cast(d);
-typedef decltype(ts.tv_sec) ts_sec;
-_LIBCPP_CONSTEXPR ts_sec ts_sec_max = numeric_limits::max();
-if (s.count() < ts_sec_max)
-{
-ts.tv_sec = static_cast(s.count());
-ts.tv_nsec = static_cast((d - s).count());
+timespec* pts = nullptr;
+
+if (__t.count() > 0) {
+seconds s = duration_cast(__t);
+typedef decltype(ts.tv_sec) ts_sec;
+_LIBCPP_CONSTEXPR ts_sec ts_sec_max = numeric_limits::max();
+if (s.count() < ts_sec_max)
+{
+ts.tv_sec = static_cast(s.count());
+ts.tv_nsec = static_cast((__t - s).count());
+}
+else
+{
+ts.tv_sec = ts_sec_max;
+ts.tv_nsec = giga::num - 1;
+}
+pts = 
 }
-else
-{
-ts.tv_sec = ts_sec_max;
-ts.tv_nsec = giga::num - 1;
+
+unsigned int old_state = atomic_load_explicit(&__state, memory_order_relaxed);
+__lk.unlock();
+int ec = __futex(&__state, op, old_state, pts, val3);
+__lk.lock();
+
+return ec;
+}
+
+int condition_variable::__futex(volatile void* ftx, int op, int value,
+const struct timespec* timeout,
+int bitset) _NOEXCEPT {
+// Our generated syscall assembler sets errno, but our callers don't want to.
+int saved_errno = errno;
+int result = syscall(__NR_futex, ftx, op, value, timeout, NULL, bitset);
+if (result == -1) {
+result = -errno;
+errno = saved_errno;
 }
-int ec = __libcpp_condvar_timedwait(&__cv_, lk.mutex()->native_handle(), );
-if (ec != 0 && ec != ETIMEDOUT)
-__throw_system_error(ec, "condition_variable timed_wait failed");
+return result;
 }
 
 void
Index: 

[PATCH] D36761: [clang-tidy] Use CloexecCheck as base class.

2017-08-15 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 111243.
chh edited the summary of this revision.

https://reviews.llvm.org/D36761

Files:
  clang-tidy/android/CloexecCheck.cpp
  clang-tidy/android/CloexecCheck.h
  clang-tidy/android/CloexecCreatCheck.cpp
  clang-tidy/android/CloexecCreatCheck.h
  clang-tidy/android/CloexecFopenCheck.cpp
  clang-tidy/android/CloexecFopenCheck.h
  clang-tidy/android/CloexecOpenCheck.cpp
  clang-tidy/android/CloexecOpenCheck.h
  clang-tidy/android/CloexecSocketCheck.cpp
  clang-tidy/android/CloexecSocketCheck.h

Index: clang-tidy/android/CloexecSocketCheck.h
===
--- clang-tidy/android/CloexecSocketCheck.h
+++ clang-tidy/android/CloexecSocketCheck.h
@@ -10,7 +10,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_SOCKET_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_SOCKET_H
 
-#include "../ClangTidy.h"
+#include "CloexecCheck.h"
 
 namespace clang {
 namespace tidy {
@@ -20,10 +20,10 @@
 ///
 /// For the user-facing documentation see:
 /// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-socket.html
-class CloexecSocketCheck : public ClangTidyCheck {
+class CloexecSocketCheck : public CloexecCheck {
 public:
   CloexecSocketCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  : CloexecCheck(Name, Context) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
 };
Index: clang-tidy/android/CloexecSocketCheck.cpp
===
--- clang-tidy/android/CloexecSocketCheck.cpp
+++ clang-tidy/android/CloexecSocketCheck.cpp
@@ -8,7 +8,6 @@
 //===--===//
 
 #include "CloexecSocketCheck.h"
-#include "../utils/ASTUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
@@ -21,35 +20,16 @@
 static constexpr const char *SOCK_CLOEXEC = "SOCK_CLOEXEC";
 
 void CloexecSocketCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(
-  callExpr(callee(functionDecl(isExternC(), returns(isInteger()),
-   hasName("socket"),
-   hasParameter(0, hasType(isInteger())),
-   hasParameter(1, hasType(isInteger())),
-   hasParameter(2, hasType(isInteger(
-  .bind("funcDecl")))
-  .bind("socketFn"),
-  this);
+  registerMatchersImpl(Finder,
+   functionDecl(isExternC(), returns(isInteger()),
+hasName("socket"),
+hasParameter(0, hasType(isInteger())),
+hasParameter(1, hasType(isInteger())),
+hasParameter(2, hasType(isInteger();
 }
 
 void CloexecSocketCheck::check(const MatchFinder::MatchResult ) {
-  const auto *MatchedCall = Result.Nodes.getNodeAs("socketFn");
-  const auto *FD = Result.Nodes.getNodeAs("funcDecl");
-  const Expr *FlagArg = MatchedCall->getArg(1);
-  SourceManager  = *Result.SourceManager;
-
-  if (utils::exprHasBitFlagWithSpelling(FlagArg->IgnoreParenCasts(), SM,
- Result.Context->getLangOpts(), SOCK_CLOEXEC))
-return;
-
-  SourceLocation EndLoc =
-  Lexer::getLocForEndOfToken(SM.getFileLoc(FlagArg->getLocEnd()), 0, SM,
- Result.Context->getLangOpts());
-
-  diag(EndLoc, "%0 should use %1 where possible")
-  << FD << SOCK_CLOEXEC
-  << FixItHint::CreateInsertion(EndLoc,
-(Twine(" | ") + SOCK_CLOEXEC).str());
+  insertMacroFlag(Result, /*MarcoFlag=*/"SOCK_CLOEXEC", /*ArgPos=*/1);
 }
 
 } // namespace android
Index: clang-tidy/android/CloexecOpenCheck.h
===
--- clang-tidy/android/CloexecOpenCheck.h
+++ clang-tidy/android/CloexecOpenCheck.h
@@ -10,7 +10,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_OPEN_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_OPEN_H
 
-#include "../ClangTidy.h"
+#include "CloexecCheck.h"
 
 namespace clang {
 namespace tidy {
@@ -25,10 +25,10 @@
 ///
 /// Only the symbolic 'O_CLOEXEC' macro definition is checked, not the concrete
 /// value.
-class CloexecOpenCheck : public ClangTidyCheck {
+class CloexecOpenCheck : public CloexecCheck {
 public:
   CloexecOpenCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  : CloexecCheck(Name, Context) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
 };
Index: clang-tidy/android/CloexecOpenCheck.cpp
===
--- 

[PATCH] D36755: [clang-tidy] Use CloexecCheck as base class of CloexecCreatCheck.

2017-08-15 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh abandoned this revision.
chh added a comment.

Included in https://reviews.llvm.org/D36761.


https://reviews.llvm.org/D36755



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


[PATCH] D36756: [clang-tidy] Use CloexecCheck as base class of CloexecSocketCheck.

2017-08-15 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh abandoned this revision.
chh added a comment.

Included in https://reviews.llvm.org/D36761.


https://reviews.llvm.org/D36756



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


[PATCH] D36759: [clang-tidy] Use CloexecCheck as base class of CloexecFopenCheck.

2017-08-15 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh abandoned this revision.
chh added a comment.

Included in  https://reviews.llvm.org/D36761.


https://reviews.llvm.org/D36759



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


[PATCH] D36759: [clang-tidy] Use CloexecCheck as base class of CloexecFopenCheck.

2017-08-15 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please abandon this and other similar revisions as obsoleted by 
https://reviews.llvm.org/D36761.


https://reviews.llvm.org/D36759



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


[PATCH] D36712: Emit section information for extern variables

2017-08-15 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added inline comments.



Comment at: docs/LangRef.rst:629
+corresponding to the LLVM module, section information specified in the 
+declaration is retained in LLVM IR to enable OpenCL processes.
+

kparzysz wrote:
> sdardis wrote:
> > efriedma wrote:
> > > This doesn't really explain the part that matters. For LangRef, it 
> > > doesn't matter how the frontend decides to generate declarations (and it 
> > > might be different for frontends other than clang).  And OpenCL might 
> > > motivate this, but it has nothing to do with the semantics.
> > > 
> > > The key question here is what it actually means.  Is it a promise the 
> > > that a definition will exist for the given symbol in the given section?  
> > > If so, what happens if the symbol is actually in a different section?  
> > > ("Undefined behavior" is probably an acceptable answer, but it needs to 
> > > be stated explicitly.)
> > > to enable OpenCL processes.
> > 
> > for targets which make use of this section information. 
> > 
> > I would also work in a sentence that says that attaching section 
> > information to a external declaration is an assertion or promise that the 
> > definition is located in that section. If the definition is actually 
> > located in a different section the behaviour is undefined.
> > 
> > I'm favouring "undefined behaviour" in the error case as behaviour is so 
> > target and environment specific.
> The other side of the problem is, what if the declarations don't have any 
> section information, but the definition does? Is that also an undefined 
> behavior? I'm in favor of considering it UB as well, but I'm not sure what 
> impact it would have on currently valid IR.
The changes I made in Clang assume that the definition is located in the same 
section specified in the declaration. If its different, the IR for the 
translation unit with the extern declaration will emit whatever section was 
specified in the declaration while the variable is actually located elsewhere. 
I am not sure what the consequences of this are.



https://reviews.llvm.org/D36712



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


[PATCH] D36764: The following functions and tests work fine for powerpc64, so enable them.

2017-08-15 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine created this revision.

These functions were disabled for powerpc in the initial
checkin all the way back in 2009. The reasons why are lost to history,
but they work fine with modern clang and powerpc64.  I have no way
to test them on 32-bit systems, but will clean this up if the someone
finds a failure.


https://reviews.llvm.org/D36764

Files:
  compiler-rt/lib/builtins/divxc3.c
  compiler-rt/lib/builtins/mulxc3.c
  compiler-rt/lib/builtins/powixf2.c
  compiler-rt/test/builtins/Unit/divxc3_test.c
  compiler-rt/test/builtins/Unit/mulxc3_test.c
  compiler-rt/test/builtins/Unit/powixf2_test.c

Index: compiler-rt/test/builtins/Unit/powixf2_test.c
===
--- compiler-rt/test/builtins/Unit/powixf2_test.c
+++ compiler-rt/test/builtins/Unit/powixf2_test.c
@@ -1,5 +1,4 @@
 // RUN: %clang_builtins %s %librt -o %t && %run %t
-// UNSUPPORTED: powerpc64
 //===-- powixf2_test.cpp - Test __powixf2 -===//
 //
 // The LLVM Compiler Infrastructure
@@ -13,8 +12,6 @@
 //
 //===--===//
 
-#if !_ARCH_PPC
-
 #include "int_lib.h"
 #include 
 #include 
@@ -33,11 +30,8 @@
 return !correct;
 }
 
-#endif
-
 int main()
 {
-#if !_ARCH_PPC
 if (test__powixf2(0, 0, 1))
 return 1;
 if (test__powixf2(1, 0, 1))
@@ -227,8 +221,5 @@
 if (test__powixf2(-2, -31, -1/2147483648.))
 return 1;
 
-#else
-printf("skipped\n");
-#endif
 return 0;
 }
Index: compiler-rt/test/builtins/Unit/mulxc3_test.c
===
--- compiler-rt/test/builtins/Unit/mulxc3_test.c
+++ compiler-rt/test/builtins/Unit/mulxc3_test.c
@@ -1,5 +1,4 @@
 // RUN: %clang_builtins %s %librt -lm -o %t && %run %t
-// UNSUPPORTED: powerpc64
 //===-- mulxc3_test.c - Test __mulxc3 -===//
 //
 // The LLVM Compiler Infrastructure
@@ -13,8 +12,6 @@
 //
 //===--===//
 
-#if !_ARCH_PPC
-
 #include "int_lib.h"
 #include 
 #include 
@@ -357,11 +354,8 @@
 
 };
 
-#endif
-
 int main()
 {
-#if !_ARCH_PPC
 const unsigned N = sizeof(x) / sizeof(x[0]);
 unsigned i, j;
 for (i = 0; i < N; ++i)
@@ -373,8 +367,5 @@
 }
 }
 
-#else
-printf("skipped\n");
-#endif
 return 0;
 }
Index: compiler-rt/test/builtins/Unit/divxc3_test.c
===
--- compiler-rt/test/builtins/Unit/divxc3_test.c
+++ compiler-rt/test/builtins/Unit/divxc3_test.c
@@ -1,5 +1,4 @@
 // RUN: %clang_builtins %s %librt -lm -o %t && %run %t
-// UNSUPPORTED: powerpc64
 //===-- divxc3_test.c - Test __divxc3 -===//
 //
 // The LLVM Compiler Infrastructure
@@ -13,8 +12,6 @@
 //
 //===--===//
 
-#if !_ARCH_PPC
-
 #include "int_lib.h"
 #include 
 #include 
@@ -361,11 +358,8 @@
 
 };
 
-#endif
-
 int main()
 {
-#if !_ARCH_PPC
 const unsigned N = sizeof(x) / sizeof(x[0]);
 unsigned i, j;
 for (i = 0; i < N; ++i)
@@ -377,8 +371,5 @@
 }
 }
 
-#else
-printf("skipped\n");
-#endif
 return 0;
 }
Index: compiler-rt/lib/builtins/powixf2.c
===
--- compiler-rt/lib/builtins/powixf2.c
+++ compiler-rt/lib/builtins/powixf2.c
@@ -12,8 +12,6 @@
  * ===--===
  */
 
-#if !_ARCH_PPC
-
 #include "int_lib.h"
 
 /* Returns: a ^ b */
@@ -34,5 +32,3 @@
 }
 return recip ? 1/r : r;
 }
-
-#endif
Index: compiler-rt/lib/builtins/mulxc3.c
===
--- compiler-rt/lib/builtins/mulxc3.c
+++ compiler-rt/lib/builtins/mulxc3.c
@@ -12,8 +12,6 @@
  * ===--===
  */
 
-#if !_ARCH_PPC
-
 #include "int_lib.h"
 #include "int_math.h"
 
@@ -73,5 +71,3 @@
 }
 return z;
 }
-
-#endif
Index: compiler-rt/lib/builtins/divxc3.c
===
--- compiler-rt/lib/builtins/divxc3.c
+++ compiler-rt/lib/builtins/divxc3.c
@@ -11,8 +11,6 @@
  *
  */
 
-#if !_ARCH_PPC
-
 #include "int_lib.h"
 #include "int_math.h"
 
@@ -59,5 +57,3 @@
 }
 return z;
 }
-
-#endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36712: Emit section information for extern variables

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

In https://reviews.llvm.org/D36712#842433, @efriedma wrote:

> I can't see how "undefined behavior" could possibly be the right answer in 
> that case.  Every definition has to end up in some section eventually, and in 
> many cases we don't know what section that will be when a global is declared. 
>  (For example, we put constants into different sections depending on the 
> contents of the initializer.)


These constants don't have explicit section information in the IR.  The typical 
scenario is that neither the declarations of a global, nor its definition have 
that.  In the cases when the section is explicitly given on a definition, it 
was likely imposed by something like the "section" attribute in the source.  I 
don't think it's unreasonable to expect that the declarations (in the original 
source as well as in the generated IR) should carry that information as well.  
However, since clang has apparently been ignoring that attribute on 
declarations, it's been generating IR where declarations may not have sections, 
but the corresponding definitions do.


https://reviews.llvm.org/D36712



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


r310952 - Fixup for r310950: Also remove the new instance of %T from html-diags.c

2017-08-15 Thread Kuba Mracek via cfe-commits
Author: kuba.brecka
Date: Tue Aug 15 12:54:04 2017
New Revision: 310952

URL: http://llvm.org/viewvc/llvm-project?rev=310952=rev
Log:
Fixup for r310950: Also remove the new instance of %T from html-diags.c


Modified:
cfe/trunk/test/Analysis/html-diags.c

Modified: cfe/trunk/test/Analysis/html-diags.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/html-diags.c?rev=310952=310951=310952=diff
==
--- cfe/trunk/test/Analysis/html-diags.c (original)
+++ cfe/trunk/test/Analysis/html-diags.c Tue Aug 15 12:54:04 2017
@@ -4,10 +4,10 @@
 // RUN: ls %t | grep report
 
 // D30406: Test new html-single-file output
-// RUN: rm -fR %T/dir
-// RUN: mkdir %T/dir
-// RUN: %clang_analyze_cc1 -analyzer-output=html-single-file 
-analyzer-checker=core -o %T/dir %s
-// RUN: ls %T/dir | grep report
+// RUN: rm -fR %t
+// RUN: mkdir %t
+// RUN: %clang_analyze_cc1 -analyzer-output=html-single-file 
-analyzer-checker=core -o %t %s
+// RUN: ls %t | grep report
 
 // PR16547: Test relative paths
 // RUN: cd %t


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


[PATCH] D36437: [clang] Get rid of "%T" expansions

2017-08-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310950: [clang] Get rid of "%T" expansions (authored by 
kuba.brecka).

Changed prior to commit:
  https://reviews.llvm.org/D36437?vs=110113=111232#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36437

Files:
  cfe/trunk/test/Analysis/html-diags.c
  cfe/trunk/test/CoverageMapping/abspath.cpp
  cfe/trunk/test/Driver/compilation_database.c
  cfe/trunk/test/Driver/cpath.c
  cfe/trunk/test/Driver/darwin-ld-lto.c
  cfe/trunk/test/Driver/linker-opts.c
  cfe/trunk/test/Driver/output-file-cleanup.c
  cfe/trunk/test/Driver/parse-progname.c
  cfe/trunk/test/Driver/ps4-linker-non-win.c
  cfe/trunk/test/Driver/ps4-linker-win.c
  cfe/trunk/test/Driver/warning-options.cpp
  cfe/trunk/test/FixIt/fixit-include.c
  cfe/trunk/test/Format/style-on-command-line.cpp
  cfe/trunk/test/Lexer/case-insensitive-include-ms.c
  cfe/trunk/test/Lexer/case-insensitive-include-pr31836.sh
  cfe/trunk/test/Lexer/case-insensitive-include.c
  cfe/trunk/test/Lexer/case-insensitive-system-include.c
  cfe/trunk/test/Modules/crash-typo-correction-visibility.cpp
  cfe/trunk/test/Modules/modules-cache-path-canonicalization.m
  cfe/trunk/test/PCH/case-insensitive-include.c
  cfe/trunk/test/PCH/include-timestamp.cpp
  cfe/trunk/test/Preprocessor/cuda-types.cu
  cfe/trunk/test/Tooling/clang-diff-basic.cpp

Index: cfe/trunk/test/Driver/parse-progname.c
===
--- cfe/trunk/test/Driver/parse-progname.c
+++ cfe/trunk/test/Driver/parse-progname.c
@@ -1,58 +1,58 @@
 // REQUIRES: shell, arm-registered-target
 
+// RUN: mkdir -p %t
 
-
-// RUN: ln -fs %clang %T/clang++
-// RUN: ln -fs %clang %T/clang++3.5.0
-// RUN: ln -fs %clang %T/clang++-3.5
-// RUN: ln -fs %clang %T/clang++-tot
-// RUN: ln -fs %clang %T/clang-c++
-// RUN: ln -fs %clang %T/clang-g++
-// RUN: ln -fs %clang %T/c++
-// RUN: ln -fs %clang %T/foo-clang++
-// RUN: ln -fs %clang %T/foo-clang++-3.5
-// RUN: ln -fs %clang %T/foo-clang++3.5
-// RUN: %T/clang++  -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
-// RUN: %T/clang++3.5.0 -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
-// RUN: %T/clang++-3.5  -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
-// RUN: %T/clang++-tot  -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
-// RUN: %T/clang-c++-### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
-// RUN: %T/clang-g++-### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
-// RUN: %T/c++  -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
-// RUN: %T/foo-clang++  -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
-// RUN: %T/foo-clang++-3.5  -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
-// RUN: %T/foo-clang++3.5   -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
+// RUN: ln -fs %clang %t/clang++
+// RUN: ln -fs %clang %t/clang++3.5.0
+// RUN: ln -fs %clang %t/clang++-3.5
+// RUN: ln -fs %clang %t/clang++-tot
+// RUN: ln -fs %clang %t/clang-c++
+// RUN: ln -fs %clang %t/clang-g++
+// RUN: ln -fs %clang %t/c++
+// RUN: ln -fs %clang %t/foo-clang++
+// RUN: ln -fs %clang %t/foo-clang++-3.5
+// RUN: ln -fs %clang %t/foo-clang++3.5
+// RUN: %t/clang++  -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
+// RUN: %t/clang++3.5.0 -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
+// RUN: %t/clang++-3.5  -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
+// RUN: %t/clang++-tot  -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
+// RUN: %t/clang-c++-### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
+// RUN: %t/clang-g++-### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
+// RUN: %t/c++  -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
+// RUN: %t/foo-clang++  -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
+// RUN: %t/foo-clang++-3.5  -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
+// RUN: %t/foo-clang++3.5   -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
 // CXXMODE: "-x" "c++"
 
 
-// RUN: ln -fs %clang %T/clang-cl
-// RUN: ln -fs %clang %T/cl
-// RUN: ln -fs %clang %T/cl.exe
-// RUN: ln -fs %clang %T/clang-cl3.5
-// RUN: ln -fs %clang %T/clang-cl-3.5
+// RUN: ln -fs %clang %t/clang-cl
+// RUN: ln -fs %clang %t/cl
+// RUN: ln -fs %clang %t/cl.exe
+// RUN: ln -fs %clang %t/clang-cl3.5
+// RUN: ln -fs %clang %t/clang-cl-3.5
 // Note: use -- in front of the filename so it's not mistaken for an option on
 // filesystems that use slashes for dir separators.
-// RUN: %T/clang-cl -### -- %s 2>&1 | FileCheck -check-prefix=CLMODE %s
-// RUN: %T/cl   -### -- %s 2>&1 | FileCheck -check-prefix=CLMODE %s
-// RUN: %T/cl.exe   -### -- %s 2>&1 | FileCheck -check-prefix=CLMODE %s
-// RUN: %T/clang-cl3.5  -### -- %s 2>&1 | FileCheck -check-prefix=CLMODE %s
-// RUN: %T/clang-cl-3.5 -### -- %s 2>&1 | FileCheck -check-prefix=CLMODE %s
+// RUN: %t/clang-cl -### -- %s 2>&1 | FileCheck -check-prefix=CLMODE %s
+// RUN: 

r310950 - [clang] Get rid of "%T" expansions

2017-08-15 Thread Kuba Mracek via cfe-commits
Author: kuba.brecka
Date: Tue Aug 15 12:47:06 2017
New Revision: 310950

URL: http://llvm.org/viewvc/llvm-project?rev=310950=rev
Log:
[clang] Get rid of "%T" expansions

The %T lit expansion expands to a common directory shared between all the tests 
in the same directory, which is unexpected and unintuitive, and more 
importantly, it's been a source of subtle race conditions and flaky tests. In 
https://reviews.llvm.org/D35396, it was agreed that it would be best to simply 
ban %T and only keep %t, which is unique to each test. When a test needs a 
temporary directory, it can just create one using mkdir %t.

This patch removes %T in clang.

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


Modified:
cfe/trunk/test/Analysis/html-diags.c
cfe/trunk/test/CoverageMapping/abspath.cpp
cfe/trunk/test/Driver/compilation_database.c
cfe/trunk/test/Driver/cpath.c
cfe/trunk/test/Driver/darwin-ld-lto.c
cfe/trunk/test/Driver/linker-opts.c
cfe/trunk/test/Driver/output-file-cleanup.c
cfe/trunk/test/Driver/parse-progname.c
cfe/trunk/test/Driver/ps4-linker-non-win.c
cfe/trunk/test/Driver/ps4-linker-win.c
cfe/trunk/test/Driver/warning-options.cpp
cfe/trunk/test/FixIt/fixit-include.c
cfe/trunk/test/Format/style-on-command-line.cpp
cfe/trunk/test/Lexer/case-insensitive-include-ms.c
cfe/trunk/test/Lexer/case-insensitive-include-pr31836.sh
cfe/trunk/test/Lexer/case-insensitive-include.c
cfe/trunk/test/Lexer/case-insensitive-system-include.c
cfe/trunk/test/Modules/crash-typo-correction-visibility.cpp
cfe/trunk/test/Modules/modules-cache-path-canonicalization.m
cfe/trunk/test/PCH/case-insensitive-include.c
cfe/trunk/test/PCH/include-timestamp.cpp
cfe/trunk/test/Preprocessor/cuda-types.cu
cfe/trunk/test/Tooling/clang-diff-basic.cpp

Modified: cfe/trunk/test/Analysis/html-diags.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/html-diags.c?rev=310950=310949=310950=diff
==
--- cfe/trunk/test/Analysis/html-diags.c (original)
+++ cfe/trunk/test/Analysis/html-diags.c Tue Aug 15 12:47:06 2017
@@ -1,7 +1,7 @@
-// RUN: rm -fR %T/dir
-// RUN: mkdir %T/dir
-// RUN: %clang_analyze_cc1 -analyzer-output=html -analyzer-checker=core -o 
%T/dir %s
-// RUN: ls %T/dir | grep report
+// RUN: rm -fR %t
+// RUN: mkdir %t
+// RUN: %clang_analyze_cc1 -analyzer-output=html -analyzer-checker=core -o %t 
%s
+// RUN: ls %t | grep report
 
 // D30406: Test new html-single-file output
 // RUN: rm -fR %T/dir
@@ -10,9 +10,9 @@
 // RUN: ls %T/dir | grep report
 
 // PR16547: Test relative paths
-// RUN: cd %T/dir
+// RUN: cd %t
 // RUN: %clang_analyze_cc1 -analyzer-output=html -analyzer-checker=core -o 
testrelative %s
-// RUN: ls %T/dir/testrelative | grep report
+// RUN: ls %t/testrelative | grep report
 
 // Currently this test mainly checks that the HTML diagnostics doesn't crash
 // when handling macros will calls with macros.  We should actually validate

Modified: cfe/trunk/test/CoverageMapping/abspath.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/abspath.cpp?rev=310950=310949=310950=diff
==
--- cfe/trunk/test/CoverageMapping/abspath.cpp (original)
+++ cfe/trunk/test/CoverageMapping/abspath.cpp Tue Aug 15 12:47:06 2017
@@ -4,7 +4,7 @@
 // RMDOTS-NOT: Inputs
 // RMDOTS: "
 
-// RUN: cd %T && mkdir -p test && cd test
+// RUN: mkdir -p %t/test && cd %t/test
 // RUN: echo "void f1() {}" > f1.c
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-main-file-name abspath.cpp ../test/f1.c -o - | FileCheck -check-prefix=RELPATH 
%s
 

Modified: cfe/trunk/test/Driver/compilation_database.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/compilation_database.c?rev=310950=310949=310950=diff
==
--- cfe/trunk/test/Driver/compilation_database.c (original)
+++ cfe/trunk/test/Driver/compilation_database.c Tue Aug 15 12:47:06 2017
@@ -1,4 +1,4 @@
-// RUN: cd "%T"
+// RUN: mkdir -p %t && cd %t
 // RUN: %clang -MD -MP --sysroot=somewhere -c -x c %s -xc++ %s -Wall -MJ - 
-no-canonical-prefixes 2>&1 | FileCheck %s
 // RUN: not %clang -c -x c %s -MJ %s/non-existant -no-canonical-prefixes 2>&1 
| FileCheck --check-prefix=ERROR %s
 

Modified: cfe/trunk/test/Driver/cpath.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cpath.c?rev=310950=310949=310950=diff
==
--- cfe/trunk/test/Driver/cpath.c (original)
+++ cfe/trunk/test/Driver/cpath.c Tue Aug 15 12:47:06 2017
@@ -1,20 +1,20 @@
-// RUN: mkdir -p %T/test1 %T/test2 %T/test3
+// RUN: mkdir -p %t/test1 %t/test2 %t/test3
 
-// RUN: env "CPATH=%T/test1%{pathsep}%T/test2" %clang -x c -E -v %s 2>&1 | 
FileCheck %s -check-prefix=CPATH

[PATCH] D36712: Emit section information for extern variables

2017-08-15 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews updated this revision to Diff 111227.
eandrews added a comment.

I updated the documentation to include Simon's comments. I wasn't sure whether 
to include the line about section information being retained in LLVM IR, since 
Eli mentioned it could vary for different front-ends. I have included it in 
this revision.


https://reviews.llvm.org/D36712

Files:
  docs/LangRef.rst


Index: docs/LangRef.rst
===
--- docs/LangRef.rst
+++ docs/LangRef.rst
@@ -622,6 +622,12 @@
 Additionally, the global can placed in a comdat if the target has the necessary
 support.
 
+External declarations may have an explicit section specified. Section 
+information is retained in LLVM IR for targets that make use of this 
+information. Attaching section information to an external declaration is an 
+assertion that it's definition is located in the specified section. If the 
+definition is located in a different section, the behavior is undefined.   
+
 By default, global initializers are optimized by assuming that global
 variables defined within the module are not modified from their
 initial values before the start of the global initializer. This is


Index: docs/LangRef.rst
===
--- docs/LangRef.rst
+++ docs/LangRef.rst
@@ -622,6 +622,12 @@
 Additionally, the global can placed in a comdat if the target has the necessary
 support.
 
+External declarations may have an explicit section specified. Section 
+information is retained in LLVM IR for targets that make use of this 
+information. Attaching section information to an external declaration is an 
+assertion that it's definition is located in the specified section. If the 
+definition is located in a different section, the behavior is undefined.   
+
 By default, global initializers are optimized by assuming that global
 variables defined within the module are not modified from their
 initial values before the start of the global initializer. This is
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36715: [clang] minor cleanup in clang/tooling/refactoring

2017-08-15 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310948: [clang] Code cleanup in clang/tooling (authored by 
alexshap).

Changed prior to commit:
  https://reviews.llvm.org/D36715?vs=111078=111229#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36715

Files:
  cfe/trunk/include/clang/Tooling/Refactoring/Rename/SymbolName.h
  cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp


Index: cfe/trunk/include/clang/Tooling/Refactoring/Rename/SymbolName.h
===
--- cfe/trunk/include/clang/Tooling/Refactoring/Rename/SymbolName.h
+++ cfe/trunk/include/clang/Tooling/Refactoring/Rename/SymbolName.h
@@ -29,7 +29,7 @@
 /// \endcode
 class SymbolName {
 public:
-  SymbolName(StringRef Name) {
+  explicit SymbolName(StringRef Name) {
 // While empty symbol names are valid (Objective-C selectors can have empty
 // name pieces), occurrences Objective-C selectors are created using an
 // array of strings instead of just one string.
Index: cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
===
--- cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
+++ cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
@@ -53,7 +53,7 @@
 }
 Changes.push_back(std::move(Change));
   }
-  return Changes;
+  return std::move(Changes);
 }
 
 /// Takes each atomic change and inserts its replacements into the set of


Index: cfe/trunk/include/clang/Tooling/Refactoring/Rename/SymbolName.h
===
--- cfe/trunk/include/clang/Tooling/Refactoring/Rename/SymbolName.h
+++ cfe/trunk/include/clang/Tooling/Refactoring/Rename/SymbolName.h
@@ -29,7 +29,7 @@
 /// \endcode
 class SymbolName {
 public:
-  SymbolName(StringRef Name) {
+  explicit SymbolName(StringRef Name) {
 // While empty symbol names are valid (Objective-C selectors can have empty
 // name pieces), occurrences Objective-C selectors are created using an
 // array of strings instead of just one string.
Index: cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
===
--- cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
+++ cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
@@ -53,7 +53,7 @@
 }
 Changes.push_back(std::move(Change));
   }
-  return Changes;
+  return std::move(Changes);
 }
 
 /// Takes each atomic change and inserts its replacements into the set of
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r310948 - [clang] Code cleanup in clang/tooling

2017-08-15 Thread Alexander Shaposhnikov via cfe-commits
Author: alexshap
Date: Tue Aug 15 12:23:54 2017
New Revision: 310948

URL: http://llvm.org/viewvc/llvm-project?rev=310948=rev
Log:
[clang] Code cleanup in clang/tooling

1. Add missing explicit for SymbolName constructor.
2. Add missing std::move in createRenameReplacements.

Differential revision: https://reviews.llvm.org/D36715

Modified:
cfe/trunk/include/clang/Tooling/Refactoring/Rename/SymbolName.h
cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp

Modified: cfe/trunk/include/clang/Tooling/Refactoring/Rename/SymbolName.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/Rename/SymbolName.h?rev=310948=310947=310948=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/Rename/SymbolName.h (original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/Rename/SymbolName.h Tue Aug 15 
12:23:54 2017
@@ -29,7 +29,7 @@ namespace tooling {
 /// \endcode
 class SymbolName {
 public:
-  SymbolName(StringRef Name) {
+  explicit SymbolName(StringRef Name) {
 // While empty symbol names are valid (Objective-C selectors can have empty
 // name pieces), occurrences Objective-C selectors are created using an
 // array of strings instead of just one string.

Modified: cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp?rev=310948=310947=310948=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp Tue Aug 15 
12:23:54 2017
@@ -53,7 +53,7 @@ createRenameReplacements(const SymbolOcc
 }
 Changes.push_back(std::move(Change));
   }
-  return Changes;
+  return std::move(Changes);
 }
 
 /// Takes each atomic change and inserts its replacements into the set of


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


[PATCH] D36642: [Lexer] Report more precise skipped regions (PR34166)

2017-08-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/Lex/PPDirectives.cpp:570
+  // We'll warn about reaching the end of file later.
+  if (C == '\0' || C == '\r' || C == '\n')
+break;

This doesn't really handle backslash-escaped newlines correctly.  (Not likely 
to matter, I guess, but better to get it right while we're messing with it.)

Could we use CurPPLexer->getSourceLocation() or something like that, instead of 
trying to scan the line ourselves?


https://reviews.llvm.org/D36642



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


r310946 - PR33082: Improve tracking of unexpanded parameter packs within variadic generic lambdas.

2017-08-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Aug 15 12:11:21 2017
New Revision: 310946

URL: http://llvm.org/viewvc/llvm-project?rev=310946=rev
Log:
PR33082: Improve tracking of unexpanded parameter packs within variadic generic 
lambdas.

Modified:
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas-variadics.cpp

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=310946=310945=310946=diff
==
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Tue Aug 15 12:11:21 2017
@@ -833,6 +833,12 @@ public:
 return FSI->Kind == SK_Lambda;
   }
 
+  /// Is this scope known to be for a generic lambda? (This will be false until
+  /// we parse the first 'auto'-typed parameter.
+  bool isGenericLambda() const {
+return !AutoTemplateParams.empty() || GLTemplateParameterList;
+  }
+
   ///
   /// \brief Add a variable that might potentially be captured by the 
   /// lambda and therefore the enclosing lambdas. 

Modified: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp?rev=310946=310945=310946=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp Tue Aug 15 12:11:21 2017
@@ -26,6 +26,19 @@ using namespace clang;
 // Visitor that collects unexpanded parameter packs
 //
 
+/// \brief Retrieve the depth and index of a parameter pack.
+static std::pair 
+getDepthAndIndex(NamedDecl *ND) {
+  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
+return std::make_pair(TTP->getDepth(), TTP->getIndex());
+  
+  if (NonTypeTemplateParmDecl *NTTP = dyn_cast(ND))
+return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
+  
+  TemplateTemplateParmDecl *TTP = cast(ND);
+  return std::make_pair(TTP->getDepth(), TTP->getIndex());
+}
+
 namespace {
   /// \brief A class that collects unexpanded parameter packs.
   class CollectUnexpandedParameterPacksVisitor :
@@ -36,15 +49,36 @@ namespace {
 
 SmallVectorImpl 
 
-bool InLambda;
+bool InLambda = false;
+unsigned DepthLimit = (unsigned)-1;
 
+void addUnexpanded(NamedDecl *ND, SourceLocation Loc = SourceLocation()) {
+  if (auto *PVD = dyn_cast(ND)) {
+// For now, the only problematic case is a generic lambda's templated
+// call operator, so we don't need to look for all the other ways we
+// could have reached a dependent parameter pack.
+auto *FD = dyn_cast(PVD->getDeclContext());
+auto *FTD = FD ? FD->getDescribedFunctionTemplate() : nullptr;
+if (FTD && FTD->getTemplateParameters()->getDepth() >= DepthLimit)
+  return;
+  } else if (getDepthAndIndex(ND).first >= DepthLimit)
+return;
+
+  Unexpanded.push_back({ND, Loc});
+}
+void addUnexpanded(const TemplateTypeParmType *T,
+   SourceLocation Loc = SourceLocation()) {
+  if (T->getDepth() < DepthLimit)
+Unexpanded.push_back({T, Loc});
+}
+
   public:
 explicit CollectUnexpandedParameterPacksVisitor(
-  SmallVectorImpl )
-  : Unexpanded(Unexpanded), InLambda(false) { }
+SmallVectorImpl )
+: Unexpanded(Unexpanded) {}
 
 bool shouldWalkTypesOfTypeLocs() const { return false; }
-
+
 //
 // Recording occurrences of (unexpanded) parameter packs.
 //
@@ -52,7 +86,7 @@ namespace {
 /// \brief Record occurrences of template type parameter packs.
 bool VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
   if (TL.getTypePtr()->isParameterPack())
-Unexpanded.push_back(std::make_pair(TL.getTypePtr(), TL.getNameLoc()));
+addUnexpanded(TL.getTypePtr(), TL.getNameLoc());
   return true;
 }
 
@@ -63,7 +97,7 @@ namespace {
 /// Ideally, this routine would never be used.
 bool VisitTemplateTypeParmType(TemplateTypeParmType *T) {
   if (T->isParameterPack())
-Unexpanded.push_back(std::make_pair(T, SourceLocation()));
+addUnexpanded(T);
 
   return true;
 }
@@ -72,18 +106,18 @@ namespace {
 /// parameter packs in an expression.
 bool VisitDeclRefExpr(DeclRefExpr *E) {
   if (E->getDecl()->isParameterPack())
-Unexpanded.push_back(std::make_pair(E->getDecl(), E->getLocation()));
+addUnexpanded(E->getDecl(), E->getLocation());
   
   return true;
 }
 
 /// \brief Record occurrences of template 

[PATCH] D36712: Emit section information for extern variables

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

> The other side of the problem is, what if the declarations don't have any 
> section information, but the definition does? Is that also an undefined 
> behavior?

I can't see how "undefined behavior" could possibly be the right answer in that 
case.  Every definition has to end up in some section eventually, and in many 
cases we don't know what section that will be when a global is declared.  (For 
example, we put constants into different sections depending on the contents of 
the initializer.)

But yes, it would be nice to explicitly define how this behaves.


https://reviews.llvm.org/D36712



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


Re: r310672 - [Sema][ObjC] Fix spurious -Wcast-qual warnings.

2017-08-15 Thread Akira Hatanaka via cfe-commits
Hans, is it okay to merge this to 5.0?

> On Aug 10, 2017, at 5:06 PM, Akira Hatanaka via cfe-commits 
>  wrote:
> 
> Author: ahatanak
> Date: Thu Aug 10 17:06:49 2017
> New Revision: 310672
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=310672=rev
> Log:
> [Sema][ObjC] Fix spurious -Wcast-qual warnings.
> 
> We do not meaningfully track object const-ness of Objective-C object
> types. Silence the -Wcast-qual warning that is issued when casting to or
> from Objective-C object types results in losing const qualification.
> 
> rdar://problem/33807915
> 
> Modified:
>cfe/trunk/lib/Sema/SemaCast.cpp
>cfe/trunk/test/SemaObjC/illegal-nonarc-bridged-cast.m
> 
> Modified: cfe/trunk/lib/Sema/SemaCast.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=310672=310671=310672=diff
> ==
> --- cfe/trunk/lib/Sema/SemaCast.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaCast.cpp Thu Aug 10 17:06:49 2017
> @@ -552,7 +552,14 @@ CastsAwayConstness(Sema , QualType
> Qualifiers SrcQuals, DestQuals;
> Self.Context.getUnqualifiedArrayType(UnwrappedSrcType, SrcQuals);
> Self.Context.getUnqualifiedArrayType(UnwrappedDestType, DestQuals);
> -
> +
> +// We do not meaningfully track object const-ness of Objective-C object
> +// types. Remove const from the source type if either the source or
> +// the destination is an Objective-C object type.
> +if (UnwrappedSrcType->isObjCObjectType() ||
> +UnwrappedDestType->isObjCObjectType())
> +  SrcQuals.removeConst();
> +
> Qualifiers RetainedSrcQuals, RetainedDestQuals;
> if (CheckCVR) {
>   RetainedSrcQuals.setCVRQualifiers(SrcQuals.getCVRQualifiers());
> 
> Modified: cfe/trunk/test/SemaObjC/illegal-nonarc-bridged-cast.m
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/illegal-nonarc-bridged-cast.m?rev=310672=310671=310672=diff
> ==
> --- cfe/trunk/test/SemaObjC/illegal-nonarc-bridged-cast.m (original)
> +++ cfe/trunk/test/SemaObjC/illegal-nonarc-bridged-cast.m Thu Aug 10 17:06:49 
> 2017
> @@ -1,8 +1,9 @@
> -// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fblocks 
> -verify %s
> +// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fblocks 
> -Wcast-qual -verify %s
> // rdar://10597832
> 
> typedef const void *CFTypeRef;
> typedef const struct __CFString *CFStringRef;
> +@class NSString;
> 
> @interface NSString
> @end
> @@ -18,7 +19,7 @@ NSString *CreateNSString();
> void from_cf() {
>   id obj1 = (__bridge_transfer id)CFCreateSomething(); // expected-warning 
> {{'__bridge_transfer' casts have no effect when not using ARC}}
>   id obj2 = (__bridge_transfer NSString*)CFCreateString(); // 
> expected-warning {{'__bridge_transfer' casts have no effect when not using 
> ARC}}
> -  (__bridge int*)CFCreateSomething(); // expected-warning {{expression 
> result unused}}
> +  (__bridge int*)CFCreateSomething(); // expected-warning {{expression 
> result unused}} expected-warning {{cast from 'const void *' to 'int *' drops 
> const qualifier}}
>   id obj3 = (__bridge id)CFGetSomething();
>   id obj4 = (__bridge NSString*)CFGetString();
> }
> @@ -41,3 +42,15 @@ void to_cf_ignored(id obj) {
>   CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething(); // 
> no-warning
>   CFTypeRef cf3 = (__bridge CFTypeRef)CreateSomething(); // no-warning
> }
> +
> +// Check that clang doesn't warn about dropping const from Objective-C object
> +// types.
> +void test_wcast_qual() {
> +  CFStringRef c;
> +  NSString *n0 = (NSString *)c;
> +  NSString **n1 = (NSString **)
> +  const NSString *n2;
> +  const NSString **n3;
> +  void *p0 = (void *)n2;
> +  void **p1 = (void **)n3;
> +}
> 
> 
> ___
> 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] D36759: [clang-tidy] Use CloexecCheck as base class of CloexecFopenCheck.

2017-08-15 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added a comment.

Okay, 3 changes are combined into https://reviews.llvm.org/D36761.


https://reviews.llvm.org/D36759



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


[PATCH] D36761: [clang-tidy] Use CloexecCheck as base class.

2017-08-15 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh created this revision.

Simplify registerMatchers and check functions in CloexecCreatCheck,
CloexecSocketCheck, and CloexecFopenCheck.


https://reviews.llvm.org/D36761

Files:
  clang-tidy/android/CloexecCreatCheck.cpp
  clang-tidy/android/CloexecCreatCheck.h
  clang-tidy/android/CloexecFopenCheck.cpp
  clang-tidy/android/CloexecFopenCheck.h
  clang-tidy/android/CloexecSocketCheck.cpp
  clang-tidy/android/CloexecSocketCheck.h

Index: clang-tidy/android/CloexecSocketCheck.h
===
--- clang-tidy/android/CloexecSocketCheck.h
+++ clang-tidy/android/CloexecSocketCheck.h
@@ -10,7 +10,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_SOCKET_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_SOCKET_H
 
-#include "../ClangTidy.h"
+#include "CloexecCheck.h"
 
 namespace clang {
 namespace tidy {
@@ -20,10 +20,10 @@
 ///
 /// For the user-facing documentation see:
 /// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-socket.html
-class CloexecSocketCheck : public ClangTidyCheck {
+class CloexecSocketCheck : public CloexecCheck {
 public:
   CloexecSocketCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  : CloexecCheck(Name, Context) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
 };
Index: clang-tidy/android/CloexecSocketCheck.cpp
===
--- clang-tidy/android/CloexecSocketCheck.cpp
+++ clang-tidy/android/CloexecSocketCheck.cpp
@@ -8,7 +8,6 @@
 //===--===//
 
 #include "CloexecSocketCheck.h"
-#include "../utils/ASTUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
@@ -21,35 +20,16 @@
 static constexpr const char *SOCK_CLOEXEC = "SOCK_CLOEXEC";
 
 void CloexecSocketCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(
-  callExpr(callee(functionDecl(isExternC(), returns(isInteger()),
-   hasName("socket"),
-   hasParameter(0, hasType(isInteger())),
-   hasParameter(1, hasType(isInteger())),
-   hasParameter(2, hasType(isInteger(
-  .bind("funcDecl")))
-  .bind("socketFn"),
-  this);
+  registerMatchersImpl(Finder,
+   functionDecl(isExternC(), returns(isInteger()),
+hasName("socket"),
+hasParameter(0, hasType(isInteger())),
+hasParameter(1, hasType(isInteger())),
+hasParameter(2, hasType(isInteger();
 }
 
 void CloexecSocketCheck::check(const MatchFinder::MatchResult ) {
-  const auto *MatchedCall = Result.Nodes.getNodeAs("socketFn");
-  const auto *FD = Result.Nodes.getNodeAs("funcDecl");
-  const Expr *FlagArg = MatchedCall->getArg(1);
-  SourceManager  = *Result.SourceManager;
-
-  if (utils::exprHasBitFlagWithSpelling(FlagArg->IgnoreParenCasts(), SM,
- Result.Context->getLangOpts(), SOCK_CLOEXEC))
-return;
-
-  SourceLocation EndLoc =
-  Lexer::getLocForEndOfToken(SM.getFileLoc(FlagArg->getLocEnd()), 0, SM,
- Result.Context->getLangOpts());
-
-  diag(EndLoc, "%0 should use %1 where possible")
-  << FD << SOCK_CLOEXEC
-  << FixItHint::CreateInsertion(EndLoc,
-(Twine(" | ") + SOCK_CLOEXEC).str());
+  insertMacroFlag(Result, /*MarcoFlag=*/"SOCK_CLOEXEC", /*ArgPos=*/1);
 }
 
 } // namespace android
Index: clang-tidy/android/CloexecFopenCheck.h
===
--- clang-tidy/android/CloexecFopenCheck.h
+++ clang-tidy/android/CloexecFopenCheck.h
@@ -10,7 +10,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_FOPEN_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_FOPEN_H
 
-#include "../ClangTidy.h"
+#include "CloexecCheck.h"
 
 namespace clang {
 namespace tidy {
@@ -23,10 +23,10 @@
 /// constant propagation.
 ///
 /// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-fopen.html
-class CloexecFopenCheck : public ClangTidyCheck {
+class CloexecFopenCheck : public CloexecCheck {
 public:
   CloexecFopenCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  : CloexecCheck(Name, Context) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
 };
Index: clang-tidy/android/CloexecFopenCheck.cpp
===
--- clang-tidy/android/CloexecFopenCheck.cpp
+++ 

[PATCH] D36759: [clang-tidy] Use CloexecCheck as base class of CloexecFopenCheck.

2017-08-15 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

In https://reviews.llvm.org/D36759#842367, @chh wrote:

> Eugene, do you mean combining this one,  https://reviews.llvm.org/D36756, and 
> https://reviews.llvm.org/D36755 into one?
>  I don't mind either way.


Sure. All three diffs are of same kind.


https://reviews.llvm.org/D36759



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


[PATCH] D36759: [clang-tidy] Use CloexecCheck as base class of CloexecFopenCheck.

2017-08-15 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added a comment.

Eugene, do you mean combining this one,  https://reviews.llvm.org/D36756, and 
https://reviews.llvm.org/D36755 into one?
I don't mind either way.


https://reviews.llvm.org/D36759



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


[PATCH] D36759: [clang-tidy] Use CloexecCheck as base class of CloexecFopenCheck.

2017-08-15 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

I think you could combine this refactoring into single change.


https://reviews.llvm.org/D36759



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


[PATCH] D36759: [clang-tidy] Use CloexecCheck as base class of CloexecFopenCheck.

2017-08-15 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh created this revision.

Simplify registerMatchers and check functions in CloexecFopenCheck.


https://reviews.llvm.org/D36759

Files:
  clang-tidy/android/CloexecFopenCheck.cpp
  clang-tidy/android/CloexecFopenCheck.h


Index: clang-tidy/android/CloexecFopenCheck.h
===
--- clang-tidy/android/CloexecFopenCheck.h
+++ clang-tidy/android/CloexecFopenCheck.h
@@ -10,7 +10,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_FOPEN_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_FOPEN_H
 
-#include "../ClangTidy.h"
+#include "CloexecCheck.h"
 
 namespace clang {
 namespace tidy {
@@ -23,10 +23,10 @@
 /// constant propagation.
 ///
 /// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-fopen.html
-class CloexecFopenCheck : public ClangTidyCheck {
+class CloexecFopenCheck : public CloexecCheck {
 public:
   CloexecFopenCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  : CloexecCheck(Name, Context) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
 };
Index: clang-tidy/android/CloexecFopenCheck.cpp
===
--- clang-tidy/android/CloexecFopenCheck.cpp
+++ clang-tidy/android/CloexecFopenCheck.cpp
@@ -18,55 +18,17 @@
 namespace tidy {
 namespace android {
 
-namespace {
-static const char MODE = 'e';
-
-// Build the replace text. If it's string constant, add 'e' directly in the end
-// of the string. Else, add "e".
-std::string BuildReplaceText(const Expr *Arg, const SourceManager ,
- const LangOptions ) {
-  if (Arg->getLocStart().isMacroID())
-return (Lexer::getSourceText(
-CharSourceRange::getTokenRange(Arg->getSourceRange()), SM,
-LangOpts) +
-" \"" + Twine(MODE) + "\"")
-.str();
-
-  StringRef SR = cast(Arg->IgnoreParenCasts())->getString();
-  return ("\"" + SR + Twine(MODE) + "\"").str();
-}
-} // namespace
-
 void CloexecFopenCheck::registerMatchers(MatchFinder *Finder) {
   auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter(;
-
-  Finder->addMatcher(
-  callExpr(callee(functionDecl(isExternC(), returns(asString("FILE *")),
-   hasName("fopen"),
-   hasParameter(0, CharPointerType),
-   hasParameter(1, CharPointerType))
-  .bind("funcDecl")))
-  .bind("fopenFn"),
-  this);
+  registerMatchersImpl(Finder,
+   functionDecl(isExternC(), returns(asString("FILE *")),
+hasName("fopen"),
+hasParameter(0, CharPointerType),
+hasParameter(1, CharPointerType)));
 }
 
 void CloexecFopenCheck::check(const MatchFinder::MatchResult ) {
-  const auto *MatchedCall = Result.Nodes.getNodeAs("fopenFn");
-  const auto *FD = Result.Nodes.getNodeAs("funcDecl");
-  const Expr *ModeArg = MatchedCall->getArg(1);
-
-  // Check if the 'e' may be in the mode string.
-  const auto *ModeStr = dyn_cast(ModeArg->IgnoreParenCasts());
-  if (!ModeStr || (ModeStr->getString().find(MODE) != StringRef::npos))
-return;
-
-  const std::string  = BuildReplaceText(
-  ModeArg, *Result.SourceManager, Result.Context->getLangOpts());
-
-  diag(ModeArg->getLocStart(), "use %0 mode 'e' to set O_CLOEXEC")
-  << FD
-  << FixItHint::CreateReplacement(ModeArg->getSourceRange(),
-  ReplacementText);
+  insertStringFlag(Result, 'e', 1);
 }
 
 } // namespace android


Index: clang-tidy/android/CloexecFopenCheck.h
===
--- clang-tidy/android/CloexecFopenCheck.h
+++ clang-tidy/android/CloexecFopenCheck.h
@@ -10,7 +10,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_FOPEN_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_FOPEN_H
 
-#include "../ClangTidy.h"
+#include "CloexecCheck.h"
 
 namespace clang {
 namespace tidy {
@@ -23,10 +23,10 @@
 /// constant propagation.
 ///
 /// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-fopen.html
-class CloexecFopenCheck : public ClangTidyCheck {
+class CloexecFopenCheck : public CloexecCheck {
 public:
   CloexecFopenCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  : CloexecCheck(Name, Context) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
 };
Index: clang-tidy/android/CloexecFopenCheck.cpp
===
--- clang-tidy/android/CloexecFopenCheck.cpp
+++ clang-tidy/android/CloexecFopenCheck.cpp
@@ -18,55 +18,17 @@
 

r310937 - Attempt to fix failure in CodeGenOpenCL/atomic-ops.cl again

2017-08-15 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue Aug 15 10:59:26 2017
New Revision: 310937

URL: http://llvm.org/viewvc/llvm-project?rev=310937=rev
Log:
Attempt to fix failure in CodeGenOpenCL/atomic-ops.cl again

Modified:
cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl

Modified: cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl?rev=310937=310936=310937=diff
==
--- cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl Tue Aug 15 10:59:26 2017
@@ -75,47 +75,47 @@ bool fi4(atomic_int *i) {
 
 void fi5(atomic_int *i, int scope) {
   // CHECK-LABEL: @fi5
-  // CHECK: switch i32 %{{.*}}, label %opencl_allsvmdevices [
-  // CHECK-NEXT: i32 1, label %opencl_workgroup
-  // CHECK-NEXT: i32 2, label %opencl_device
-  // CHECK-NEXT: i32 4, label %opencl_subgroup
+  // CHECK: switch i32 %{{.*}}, label %[[opencl_allsvmdevices:.*]] [
+  // CHECK-NEXT: i32 1, label %[[opencl_workgroup:.*]]
+  // CHECK-NEXT: i32 2, label %[[opencl_device:.*]]
+  // CHECK-NEXT: i32 4, label %[[opencl_subgroup:.*]]
   // CHECK-NEXT: ]
-  // CHECK: opencl_workgroup:
+  // CHECK: [[opencl_workgroup]]:
   // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} syncscope("workgroup") 
seq_cst
-  // CHECK: br label %atomic.scope.continue
-  // CHECK: opencl_device:
+  // CHECK: br label %[[continue:.*]]
+  // CHECK: [[opencl_device]]:
   // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} syncscope("agent") 
seq_cst
-  // CHECK: br label %atomic.scope.continue
-  // CHECK: opencl_allsvmdevices:
+  // CHECK: br label %[[continue]]
+  // CHECK: [[opencl_allsvmdevices]]:
   // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} seq_cst
-  // CHECK: br label %atomic.scope.continue
-  // CHECK: opencl_subgroup:
+  // CHECK: br label %[[continue]]
+  // CHECK: [[opencl_subgroup]]:
   // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} syncscope("subgroup") 
seq_cst
-  // CHECK: br label %atomic.scope.continue
-  // CHECK: atomic.scope.continue:
+  // CHECK: br label %[[continue]]
+  // CHECK: [[continue]]:
   int x = __opencl_atomic_load(i, memory_order_seq_cst, scope);
 }
 
 void fi6(atomic_int *i, int order, int scope) {
   // CHECK-LABEL: @fi6
-  // CHECK: switch i32 %{{.*}}, label %monotonic [
-  // CHECK-NEXT: i32 1, label %acquire
-  // CHECK-NEXT: i32 2, label %acquire
-  // CHECK-NEXT: i32 5, label %seqcst
+  // CHECK: switch i32 %{{.*}}, label %[[monotonic:.*]] [
+  // CHECK-NEXT: i32 1, label %[[acquire:.*]]
+  // CHECK-NEXT: i32 2, label %[[acquire:.*]]
+  // CHECK-NEXT: i32 5, label %[[seqcst:.*]]
   // CHECK-NEXT: ]
-  // CHECK: monotonic:
+  // CHECK: [[monotonic]]:
   // CHECK: switch i32 %{{.*}}, label %[[MON_ALL:.*]] [
   // CHECK-NEXT: i32 1, label %[[MON_WG:.*]]
   // CHECK-NEXT: i32 2, label %[[MON_DEV:.*]]
   // CHECK-NEXT: i32 4, label %[[MON_SUB:.*]]
   // CHECK-NEXT: ]
-  // CHECK: acquire:
+  // CHECK: [[acquire]]:
   // CHECK: switch i32 %{{.*}}, label %[[ACQ_ALL:.*]] [
   // CHECK-NEXT: i32 1, label %[[ACQ_WG:.*]]
   // CHECK-NEXT: i32 2, label %[[ACQ_DEV:.*]]
   // CHECK-NEXT: i32 4, label %[[ACQ_SUB:.*]]
   // CHECK-NEXT: ]
-  // CHECK: seqcst:
+  // CHECK: [[seqcst]]:
   // CHECK: switch i32 %{{.*}}, label %[[SEQ_ALL:.*]] [
   // CHECK-NEXT: i32 1, label %[[SEQ_WG:.*]]
   // CHECK-NEXT: i32 2, label %[[SEQ_DEV:.*]]


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


[PATCH] D36756: [clang-tidy] Use CloexecCheck as base class of CloexecSocketCheck.

2017-08-15 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh created this revision.

Simplify registerMatchers and check functions in CloexecSocketCheck.


https://reviews.llvm.org/D36756

Files:
  clang-tidy/android/CloexecSocketCheck.cpp
  clang-tidy/android/CloexecSocketCheck.h


Index: clang-tidy/android/CloexecSocketCheck.h
===
--- clang-tidy/android/CloexecSocketCheck.h
+++ clang-tidy/android/CloexecSocketCheck.h
@@ -10,7 +10,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_SOCKET_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_SOCKET_H
 
-#include "../ClangTidy.h"
+#include "CloexecCheck.h"
 
 namespace clang {
 namespace tidy {
@@ -20,10 +20,10 @@
 ///
 /// For the user-facing documentation see:
 /// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-socket.html
-class CloexecSocketCheck : public ClangTidyCheck {
+class CloexecSocketCheck : public CloexecCheck {
 public:
   CloexecSocketCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  : CloexecCheck(Name, Context) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
 };
Index: clang-tidy/android/CloexecSocketCheck.cpp
===
--- clang-tidy/android/CloexecSocketCheck.cpp
+++ clang-tidy/android/CloexecSocketCheck.cpp
@@ -8,7 +8,6 @@
 
//===--===//
 
 #include "CloexecSocketCheck.h"
-#include "../utils/ASTUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
@@ -21,35 +20,16 @@
 static constexpr const char *SOCK_CLOEXEC = "SOCK_CLOEXEC";
 
 void CloexecSocketCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(
-  callExpr(callee(functionDecl(isExternC(), returns(isInteger()),
-   hasName("socket"),
-   hasParameter(0, hasType(isInteger())),
-   hasParameter(1, hasType(isInteger())),
-   hasParameter(2, hasType(isInteger(
-  .bind("funcDecl")))
-  .bind("socketFn"),
-  this);
+  registerMatchersImpl(Finder,
+   functionDecl(isExternC(), returns(isInteger()),
+hasName("socket"),
+hasParameter(0, hasType(isInteger())),
+hasParameter(1, hasType(isInteger())),
+hasParameter(2, hasType(isInteger();
 }
 
 void CloexecSocketCheck::check(const MatchFinder::MatchResult ) {
-  const auto *MatchedCall = Result.Nodes.getNodeAs("socketFn");
-  const auto *FD = Result.Nodes.getNodeAs("funcDecl");
-  const Expr *FlagArg = MatchedCall->getArg(1);
-  SourceManager  = *Result.SourceManager;
-
-  if (utils::exprHasBitFlagWithSpelling(FlagArg->IgnoreParenCasts(), SM,
- Result.Context->getLangOpts(), SOCK_CLOEXEC))
-return;
-
-  SourceLocation EndLoc =
-  Lexer::getLocForEndOfToken(SM.getFileLoc(FlagArg->getLocEnd()), 0, SM,
- Result.Context->getLangOpts());
-
-  diag(EndLoc, "%0 should use %1 where possible")
-  << FD << SOCK_CLOEXEC
-  << FixItHint::CreateInsertion(EndLoc,
-(Twine(" | ") + SOCK_CLOEXEC).str());
+  insertMacroFlag(Result, /*MarcoFlag=*/"SOCK_CLOEXEC", /*ArgPos=*/1);
 }
 
 } // namespace android


Index: clang-tidy/android/CloexecSocketCheck.h
===
--- clang-tidy/android/CloexecSocketCheck.h
+++ clang-tidy/android/CloexecSocketCheck.h
@@ -10,7 +10,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_SOCKET_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_SOCKET_H
 
-#include "../ClangTidy.h"
+#include "CloexecCheck.h"
 
 namespace clang {
 namespace tidy {
@@ -20,10 +20,10 @@
 ///
 /// For the user-facing documentation see:
 /// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-socket.html
-class CloexecSocketCheck : public ClangTidyCheck {
+class CloexecSocketCheck : public CloexecCheck {
 public:
   CloexecSocketCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  : CloexecCheck(Name, Context) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
 };
Index: clang-tidy/android/CloexecSocketCheck.cpp
===
--- clang-tidy/android/CloexecSocketCheck.cpp
+++ clang-tidy/android/CloexecSocketCheck.cpp
@@ -8,7 +8,6 @@
 //===--===//
 
 #include "CloexecSocketCheck.h"
-#include "../utils/ASTUtils.h"
 

[PATCH] D36755: [clang-tidy] Use CloexecCheck as base class of CloexecCreatCheck.

2017-08-15 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh created this revision.

Simplify registerMatchers and check functions in CloexecCreatCheck.


https://reviews.llvm.org/D36755

Files:
  clang-tidy/android/CloexecCreatCheck.cpp
  clang-tidy/android/CloexecCreatCheck.h


Index: clang-tidy/android/CloexecCreatCheck.h
===
--- clang-tidy/android/CloexecCreatCheck.h
+++ clang-tidy/android/CloexecCreatCheck.h
@@ -10,7 +10,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_CREAT_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_CREAT_H
 
-#include "../ClangTidy.h"
+#include "CloexecCheck.h"
 
 namespace clang {
 namespace tidy {
@@ -20,10 +20,10 @@
 /// Find the usage of creat() and redirect user to use open().
 
 /// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-creat.html
-class CloexecCreatCheck : public ClangTidyCheck {
+class CloexecCreatCheck : public CloexecCheck {
 public:
   CloexecCreatCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  : CloexecCheck(Name, Context) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
 };
Index: clang-tidy/android/CloexecCreatCheck.cpp
===
--- clang-tidy/android/CloexecCreatCheck.cpp
+++ clang-tidy/android/CloexecCreatCheck.cpp
@@ -10,7 +10,6 @@
 #include "CloexecCreatCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
@@ -21,37 +20,22 @@
 void CloexecCreatCheck::registerMatchers(MatchFinder *Finder) {
   auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter(;
   auto MODETType = hasType(namedDecl(hasName("mode_t")));
-
-  Finder->addMatcher(
-  callExpr(callee(functionDecl(isExternC(), returns(isInteger()),
-   hasName("creat"),
-   hasParameter(0, CharPointerType),
-   hasParameter(1, MODETType))
-  .bind("funcDecl")))
-  .bind("creatFn"),
-  this);
+  registerMatchersImpl(Finder,
+   functionDecl(isExternC(), returns(isInteger()),
+hasName("creat"),
+hasParameter(0, CharPointerType),
+hasParameter(1, MODETType)));
 }
 
 void CloexecCreatCheck::check(const MatchFinder::MatchResult ) {
-  const auto *MatchedCall = Result.Nodes.getNodeAs("creatFn");
-  const SourceManager  = *Result.SourceManager;
-
   const std::string  =
-  (Twine("open (") +
-   Lexer::getSourceText(CharSourceRange::getTokenRange(
-MatchedCall->getArg(0)->getSourceRange()),
-SM, Result.Context->getLangOpts()) +
+  (Twine("open (") + getSpellingArg(Result, 0) +
", O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, " +
-   Lexer::getSourceText(CharSourceRange::getTokenRange(
-MatchedCall->getArg(1)->getSourceRange()),
-SM, Result.Context->getLangOpts()) +
-   ")")
+   getSpellingArg(Result, 1) + ")")
   .str();
-
-  diag(MatchedCall->getLocStart(),
-   "prefer open() to creat() because open() allows O_CLOEXEC")
-  << FixItHint::CreateReplacement(MatchedCall->getSourceRange(),
-  ReplacementText);
+  replaceFunc(Result,
+  "prefer open() to creat() because open() allows O_CLOEXEC",
+  ReplacementText);
 }
 
 } // namespace android


Index: clang-tidy/android/CloexecCreatCheck.h
===
--- clang-tidy/android/CloexecCreatCheck.h
+++ clang-tidy/android/CloexecCreatCheck.h
@@ -10,7 +10,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_CREAT_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_CREAT_H
 
-#include "../ClangTidy.h"
+#include "CloexecCheck.h"
 
 namespace clang {
 namespace tidy {
@@ -20,10 +20,10 @@
 /// Find the usage of creat() and redirect user to use open().
 
 /// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-creat.html
-class CloexecCreatCheck : public ClangTidyCheck {
+class CloexecCreatCheck : public CloexecCheck {
 public:
   CloexecCreatCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  : CloexecCheck(Name, Context) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
 };
Index: clang-tidy/android/CloexecCreatCheck.cpp
===
--- clang-tidy/android/CloexecCreatCheck.cpp
+++ clang-tidy/android/CloexecCreatCheck.cpp
@@ -10,7 +10,6 @@
 

[PATCH] D36678: [OpenCL] Do not use vararg in emitted functions for enqueue_kernel

2017-08-15 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: test/CodeGenOpenCL/cl20-device-side-enqueue.cl:64
+  // B32: call i32 @__enqueue_kernel_vaargs(%opencl.queue_t{{.*}}* [[DEF_Q]], 
i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{(.[0-9]+)?}}, i8 addrspace(4)* 
addrspacecast (i8 addrspace(1)* bitcast ({ i8**, i32, i32, i8*, 
%struct.__block_descriptor addrspace(2)* } addrspace(1)* 
@__block_literal_global{{(.[0-9]+)?}} to i8 addrspace(1)*) to i8 
addrspace(4)*), i32 1, i32* {{.*}})
   // B64: [[SIZE:%[0-9]+]] = zext i8 {{%[0-9]+}} to i64
+  // B64: call i32 @__enqueue_kernel_vaargs(%opencl.queue_t{{.*}}* [[DEF_Q]], 
i32 [[FLAGS]], %struct.ndrange_t* [[NDR]]{{(.[0-9]+)?}}, i8 addrspace(4)* 
addrspacecast (i8 addrspace(1)* bitcast ({ i8**, i32, i32, i8*, 
%struct.__block_descriptor addrspace(2)* } addrspace(1)* 
@__block_literal_global{{(.[0-9]+)?}} to i8 addrspace(1)*) to i8 
addrspace(4)*), i32 1, i64* {{.*}})

This is no longer needed?

Could we check the code for array generation too?

Also could we modify one test to take more than argument to the block? It seems 
to be missing in testing.


https://reviews.llvm.org/D36678



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


[PATCH] D36641: [index] Update indexing to handle CXXDeductionGuideDecls properly

2017-08-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310933: [index] Update indexing to handle 
CXXDeductionGuideDecls properly (authored by akirtzidis).

Changed prior to commit:
  https://reviews.llvm.org/D36641?vs=110829=99#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36641

Files:
  cfe/trunk/lib/Index/IndexDecl.cpp
  cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
  cfe/trunk/lib/Index/IndexingContext.cpp
  cfe/trunk/test/Index/Core/index-source.cpp


Index: cfe/trunk/test/Index/Core/index-source.cpp
===
--- cfe/trunk/test/Index/Core/index-source.cpp
+++ cfe/trunk/test/Index/Core/index-source.cpp
@@ -497,6 +497,19 @@
 
 }
 
+template
+struct Guided { T t; };
+// CHECK: [[@LINE-1]]:8 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | 
 | Def | rel: 0
+// CHECK-NEXT: [[@LINE-2]]:19 | field/C++ | t | c:@ST>1#T@Guided@FI@t | 
 | Def,RelChild | rel: 1
+// CHECK-NEXT: RelChild | Guided | c:@ST>1#T@Guided
+Guided(double) -> Guided;
+// CHECK: [[@LINE-1]]:19 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | 
 | Ref | rel: 0
+// CHECK-NEXT: [[@LINE-2]]:1 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | 
 | Ref | rel: 0
+auto guided = Guided{1.0};
+// CHECK: [[@LINE-1]]:6 | variable/C | guided | c:@guided | _guided | Def | 
rel: 0
+// CHECK-NEXT: [[@LINE-2]]:15 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | 
 | Ref,RelCont | rel: 1
+// CHECK-NEXT: RelCont | guided | c:@guided
+
 namespace rd33122110 {
 
 struct Outer {
Index: cfe/trunk/lib/Index/IndexingContext.cpp
===
--- cfe/trunk/lib/Index/IndexingContext.cpp
+++ cfe/trunk/lib/Index/IndexingContext.cpp
@@ -231,8 +231,8 @@
 
 /// Whether the given NamedDecl should be skipped because it has no name.
 static bool shouldSkipNamelessDecl(const NamedDecl *ND) {
-  return ND->getDeclName().isEmpty() && !isa(ND) &&
- !isa(ND);
+  return (ND->getDeclName().isEmpty() && !isa(ND) &&
+  !isa(ND)) || isa(ND);
 }
 
 static const Decl *adjustParent(const Decl *Parent) {
Index: cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
===
--- cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
+++ cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
@@ -126,8 +126,9 @@
 return true;
   }
 
-  bool VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) {
-if (const TemplateSpecializationType *T = TL.getTypePtr()) {
+  template
+  bool HandleTemplateSpecializationTypeLoc(TypeLocType TL) {
+if (const auto *T = TL.getTypePtr()) {
   if (IndexCtx.shouldIndexImplicitTemplateInsts()) {
 if (CXXRecordDecl *RD = T->getAsCXXRecordDecl())
   IndexCtx.handleReference(RD, TL.getTemplateNameLoc(),
@@ -141,6 +142,14 @@
 return true;
   }
 
+  bool VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) {
+return HandleTemplateSpecializationTypeLoc(TL);
+  }
+
+  bool 
VisitDeducedTemplateSpecializationTypeLoc(DeducedTemplateSpecializationTypeLoc 
TL) {
+return HandleTemplateSpecializationTypeLoc(TL);
+  }
+
   bool VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
 const DependentNameType *DNT = TL.getTypePtr();
 const NestedNameSpecifier *NNS = DNT->getQualifier();
Index: cfe/trunk/lib/Index/IndexDecl.cpp
===
--- cfe/trunk/lib/Index/IndexDecl.cpp
+++ cfe/trunk/lib/Index/IndexDecl.cpp
@@ -267,6 +267,10 @@
  TypeNameInfo->getTypeLoc().getLocStart(),
  Dtor->getParent(), Dtor->getDeclContext());
   }
+} else if (const auto *Guide = dyn_cast(D)) {
+  IndexCtx.handleReference(Guide->getDeducedTemplate()->getTemplatedDecl(),
+   Guide->getLocation(), Guide,
+   Guide->getDeclContext());
 }
 // Template specialization arguments.
 if (const ASTTemplateArgumentListInfo *TemplateArgInfo =


Index: cfe/trunk/test/Index/Core/index-source.cpp
===
--- cfe/trunk/test/Index/Core/index-source.cpp
+++ cfe/trunk/test/Index/Core/index-source.cpp
@@ -497,6 +497,19 @@
 
 }
 
+template
+struct Guided { T t; };
+// CHECK: [[@LINE-1]]:8 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided |  | Def | rel: 0
+// CHECK-NEXT: [[@LINE-2]]:19 | field/C++ | t | c:@ST>1#T@Guided@FI@t |  | Def,RelChild | rel: 1
+// CHECK-NEXT: RelChild | Guided | c:@ST>1#T@Guided
+Guided(double) -> Guided;
+// CHECK: [[@LINE-1]]:19 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided |  | Ref | rel: 0
+// CHECK-NEXT: [[@LINE-2]]:1 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided |  | Ref | rel: 0
+auto guided = Guided{1.0};
+// CHECK: [[@LINE-1]]:6 | variable/C | guided | c:@guided | _guided | Def | rel: 0
+// CHECK-NEXT: [[@LINE-2]]:15 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided |  | 

r310933 - [index] Update indexing to handle CXXDeductionGuideDecls properly

2017-08-15 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Tue Aug 15 10:20:37 2017
New Revision: 310933

URL: http://llvm.org/viewvc/llvm-project?rev=310933=rev
Log:
[index] Update indexing to handle CXXDeductionGuideDecls properly

CXXDeductionGuideDecls can't be referenced so there's no need to output a 
symbol occurrence for them.
Also handle DeducedTemplateSpecializationTypeLocs in the TypeIndexer so we 
don't miss the symbol occurrences of the corresponding template decls.

Patch by Nathan Hawes!

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

Modified:
cfe/trunk/lib/Index/IndexDecl.cpp
cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
cfe/trunk/lib/Index/IndexingContext.cpp
cfe/trunk/test/Index/Core/index-source.cpp

Modified: cfe/trunk/lib/Index/IndexDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=310933=310932=310933=diff
==
--- cfe/trunk/lib/Index/IndexDecl.cpp (original)
+++ cfe/trunk/lib/Index/IndexDecl.cpp Tue Aug 15 10:20:37 2017
@@ -267,6 +267,10 @@ public:
  TypeNameInfo->getTypeLoc().getLocStart(),
  Dtor->getParent(), Dtor->getDeclContext());
   }
+} else if (const auto *Guide = dyn_cast(D)) {
+  IndexCtx.handleReference(Guide->getDeducedTemplate()->getTemplatedDecl(),
+   Guide->getLocation(), Guide,
+   Guide->getDeclContext());
 }
 // Template specialization arguments.
 if (const ASTTemplateArgumentListInfo *TemplateArgInfo =

Modified: cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp?rev=310933=310932=310933=diff
==
--- cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp (original)
+++ cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp Tue Aug 15 10:20:37 2017
@@ -126,8 +126,9 @@ public:
 return true;
   }
 
-  bool VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) {
-if (const TemplateSpecializationType *T = TL.getTypePtr()) {
+  template
+  bool HandleTemplateSpecializationTypeLoc(TypeLocType TL) {
+if (const auto *T = TL.getTypePtr()) {
   if (IndexCtx.shouldIndexImplicitTemplateInsts()) {
 if (CXXRecordDecl *RD = T->getAsCXXRecordDecl())
   IndexCtx.handleReference(RD, TL.getTemplateNameLoc(),
@@ -141,6 +142,14 @@ public:
 return true;
   }
 
+  bool VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) {
+return HandleTemplateSpecializationTypeLoc(TL);
+  }
+
+  bool 
VisitDeducedTemplateSpecializationTypeLoc(DeducedTemplateSpecializationTypeLoc 
TL) {
+return HandleTemplateSpecializationTypeLoc(TL);
+  }
+
   bool VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
 const DependentNameType *DNT = TL.getTypePtr();
 const NestedNameSpecifier *NNS = DNT->getQualifier();

Modified: cfe/trunk/lib/Index/IndexingContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexingContext.cpp?rev=310933=310932=310933=diff
==
--- cfe/trunk/lib/Index/IndexingContext.cpp (original)
+++ cfe/trunk/lib/Index/IndexingContext.cpp Tue Aug 15 10:20:37 2017
@@ -231,8 +231,8 @@ static bool isDeclADefinition(const Decl
 
 /// Whether the given NamedDecl should be skipped because it has no name.
 static bool shouldSkipNamelessDecl(const NamedDecl *ND) {
-  return ND->getDeclName().isEmpty() && !isa(ND) &&
- !isa(ND);
+  return (ND->getDeclName().isEmpty() && !isa(ND) &&
+  !isa(ND)) || isa(ND);
 }
 
 static const Decl *adjustParent(const Decl *Parent) {

Modified: cfe/trunk/test/Index/Core/index-source.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=310933=310932=310933=diff
==
--- cfe/trunk/test/Index/Core/index-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-source.cpp Tue Aug 15 10:20:37 2017
@@ -497,6 +497,19 @@ void localStructuredBindingAndRef() {
 
 }
 
+template
+struct Guided { T t; };
+// CHECK: [[@LINE-1]]:8 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | 
 | Def | rel: 0
+// CHECK-NEXT: [[@LINE-2]]:19 | field/C++ | t | c:@ST>1#T@Guided@FI@t | 
 | Def,RelChild | rel: 1
+// CHECK-NEXT: RelChild | Guided | c:@ST>1#T@Guided
+Guided(double) -> Guided;
+// CHECK: [[@LINE-1]]:19 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | 
 | Ref | rel: 0
+// CHECK-NEXT: [[@LINE-2]]:1 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | 
 | Ref | rel: 0
+auto guided = Guided{1.0};
+// CHECK: [[@LINE-1]]:6 | variable/C | guided | c:@guided | _guided | Def | 
rel: 0
+// CHECK-NEXT: [[@LINE-2]]:15 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | 
 | Ref,RelCont | rel: 1
+// CHECK-NEXT: RelCont | guided | c:@guided
+
 

r310932 - Attempt to fix failure in CodeGenOpenCL/atomic-ops.cl

2017-08-15 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue Aug 15 10:16:44 2017
New Revision: 310932

URL: http://llvm.org/viewvc/llvm-project?rev=310932=rev
Log:
Attempt to fix failure in CodeGenOpenCL/atomic-ops.cl

Modified:
cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl

Modified: cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl?rev=310932=310931=310932=diff
==
--- cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl Tue Aug 15 10:16:44 2017
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -O0 -o - 
-triple=amdgcn-amd-amdhsa-opencl | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -O0 -o - 
-triple=amdgcn-amd-amdhsa-opencl | opt -instnamer -S | FileCheck %s
 
 // Also test serialization of atomic operations here, to avoid duplicating the 
test.
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-pch -O0 -o %t 
-triple=amdgcn-amd-amdhsa-opencl
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -include-pch %t -O0 
-triple=amdgcn-amd-amdhsa-opencl -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -include-pch %t -O0 
-triple=amdgcn-amd-amdhsa-opencl -emit-llvm -o - | opt -instnamer -S | 
FileCheck %s
 
 #ifndef ALREADY_INCLUDED
 #define ALREADY_INCLUDED
@@ -87,10 +87,10 @@ void fi5(atomic_int *i, int scope) {
   // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} syncscope("agent") 
seq_cst
   // CHECK: br label %atomic.scope.continue
   // CHECK: opencl_allsvmdevices:
-  // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} seq_cst, align 4
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} seq_cst
   // CHECK: br label %atomic.scope.continue
   // CHECK: opencl_subgroup:
-  // CHECK: %5 = load atomic i32, i32 addrspace(4)* %0 syncscope("subgroup") 
seq_cst, align 4
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} syncscope("subgroup") 
seq_cst
   // CHECK: br label %atomic.scope.continue
   // CHECK: atomic.scope.continue:
   int x = __opencl_atomic_load(i, memory_order_seq_cst, scope);
@@ -116,7 +116,7 @@ void fi6(atomic_int *i, int order, int s
   // CHECK-NEXT: i32 4, label %[[ACQ_SUB:.*]]
   // CHECK-NEXT: ]
   // CHECK: seqcst:
-  // CHECK: switch i32 %2, label %[[SEQ_ALL:.*]] [
+  // CHECK: switch i32 %{{.*}}, label %[[SEQ_ALL:.*]] [
   // CHECK-NEXT: i32 1, label %[[SEQ_WG:.*]]
   // CHECK-NEXT: i32 2, label %[[SEQ_DEV:.*]]
   // CHECK-NEXT: i32 4, label %[[SEQ_SUB:.*]]


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


[PATCH] D36492: [time-report] Add preprocessor timer

2017-08-15 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added subscribers: vsk, mzolotukhin.
modocache added a comment.

Oops, sorry, didn't mean to remove the subscribers. `arc diff --verbatim` 
strikes again.


https://reviews.llvm.org/D36492



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


[PATCH] D36492: [time-report] Add preprocessor timer

2017-08-15 Thread Brian Gesiak via Phabricator via cfe-commits
modocache updated this revision to Diff 95.
modocache retitled this revision from "[RFC][time-report] Add preprocessor 
timer" to "[time-report] Add preprocessor timer".
modocache edited the summary of this revision.
modocache removed subscribers: vsk, mzolotukhin.
modocache added a comment.

Add `PreprocessorOptions::getTimer`, and move the timer to the top of 
`Preprocessor::Lex()`.


https://reviews.llvm.org/D36492

Files:
  include/clang/Lex/PreprocessorOptions.h
  lib/Frontend/CompilerInstance.cpp
  lib/Lex/Preprocessor.cpp


Index: lib/Lex/Preprocessor.cpp
===
--- lib/Lex/Preprocessor.cpp
+++ lib/Lex/Preprocessor.cpp
@@ -743,6 +743,8 @@
 }
 
 void Preprocessor::Lex(Token ) {
+  llvm::TimeRegion(PPOpts->getTimer());
+
   // We loop here until a lex function returns a token; this avoids recursion.
   bool ReturnedToken;
   do {
Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -367,7 +367,9 @@
 // Preprocessor
 
 void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
-  const PreprocessorOptions  = getPreprocessorOpts();
+  PreprocessorOptions  = getPreprocessorOpts();
+  if (getFrontendOpts().ShowTimers)
+PPOpts.ShowTimers = true;
 
   // Create a PTH manager if we are using some form of a token cache.
   PTHManager *PTHMgr = nullptr;
Index: include/clang/Lex/PreprocessorOptions.h
===
--- include/clang/Lex/PreprocessorOptions.h
+++ include/clang/Lex/PreprocessorOptions.h
@@ -14,6 +14,7 @@
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
+#include "llvm/Support/Timer.h"
 #include 
 #include 
 #include 
@@ -37,10 +38,11 @@
   /// \brief libstdc++
   ARCXX_libstdcxx
 };
-  
+
 /// PreprocessorOptions - This class is used for passing the various options
 /// used in preprocessor initialization to InitializePreprocessor().
 class PreprocessorOptions {
+  llvm::Timer PPTimer;
 public:
   std::vector > Macros;
   std::vector Includes;
@@ -127,7 +129,11 @@
   /// manipulation of the compiler invocation object, in cases where the 
   /// compiler invocation and its buffers will be reused.
   bool RetainRemappedFileBuffers;
-  
+
+  /// \brief Whether to measure the amount of time spent in code related to
+  /// preprocessing. This flag defaults to false.
+  bool ShowTimers;
+
   /// \brief The Objective-C++ ARC standard library that we should support,
   /// by providing appropriate definitions to retrofit the standard library
   /// with support for lifetime-qualified pointers.
@@ -156,14 +162,17 @@
   std::shared_ptr FailedModules;
 
 public:
-  PreprocessorOptions() : UsePredefines(true), DetailedRecord(false),
+  PreprocessorOptions() : PPTimer("preprocessor", "Preprocessing"),
+  UsePredefines(true),
+  DetailedRecord(false),
   DisablePCHValidation(false),
   AllowPCHWithCompilerErrors(false),
   DumpDeserializedPCHDecls(false),
   PrecompiledPreambleBytes(0, true),
   GeneratePreamble(false),
   RemappedFilesKeepOriginalName(true),
   RetainRemappedFileBuffers(false),
+  ShowTimers(false),
   ObjCXXARCStandardLibrary(ARCXX_nolib) { }
 
   void addMacroDef(StringRef Name) { Macros.emplace_back(Name, false); }
@@ -197,6 +206,10 @@
 PrecompiledPreambleBytes.first = 0;
 PrecompiledPreambleBytes.second = 0;
   }
+
+  llvm::Timer *getTimer() {
+return ShowTimers ?  : nullptr;
+  }
 };
 
 } // end namespace clang


Index: lib/Lex/Preprocessor.cpp
===
--- lib/Lex/Preprocessor.cpp
+++ lib/Lex/Preprocessor.cpp
@@ -743,6 +743,8 @@
 }
 
 void Preprocessor::Lex(Token ) {
+  llvm::TimeRegion(PPOpts->getTimer());
+
   // We loop here until a lex function returns a token; this avoids recursion.
   bool ReturnedToken;
   do {
Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -367,7 +367,9 @@
 // Preprocessor
 
 void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
-  const PreprocessorOptions  = getPreprocessorOpts();
+  PreprocessorOptions  = getPreprocessorOpts();
+  if (getFrontendOpts().ShowTimers)
+PPOpts.ShowTimers = true;
 
   // Create a PTH manager if we are using some form of a token cache.
   PTHManager *PTHMgr = nullptr;
Index: include/clang/Lex/PreprocessorOptions.h
===

[PATCH] D36676: Remove -finclude-default-header in OpenCL atomic tests

2017-08-15 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310927: Remove -finclude-default-header in OpenCL atomic 
tests (authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D36676?vs=110953=91#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36676

Files:
  cfe/trunk/test/CodeGenOpenCL/atomic-ops-libcall.cl
  cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl
  cfe/trunk/test/SemaOpenCL/atomic-ops.cl

Index: cfe/trunk/test/SemaOpenCL/atomic-ops.cl
===
--- cfe/trunk/test/SemaOpenCL/atomic-ops.cl
+++ cfe/trunk/test/SemaOpenCL/atomic-ops.cl
@@ -1,11 +1,32 @@
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -verify -fsyntax-only -triple=spir64
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -verify -fsyntax-only -triple=amdgcn-amdhsa-amd-opencl
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only -triple=spir64
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only -triple=amdgcn-amdhsa-amd-opencl
 
 // Basic parsing/Sema tests for __opencl_atomic_*
 
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable
 #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable
 
+typedef __INTPTR_TYPE__ intptr_t;
+typedef int int8 __attribute__((ext_vector_type(8)));
+
+typedef enum memory_order {
+  memory_order_relaxed = __ATOMIC_RELAXED,
+  memory_order_acquire = __ATOMIC_ACQUIRE,
+  memory_order_release = __ATOMIC_RELEASE,
+  memory_order_acq_rel = __ATOMIC_ACQ_REL,
+  memory_order_seq_cst = __ATOMIC_SEQ_CST
+} memory_order;
+
+typedef enum memory_scope {
+  memory_scope_work_item = __OPENCL_MEMORY_SCOPE_WORK_ITEM,
+  memory_scope_work_group = __OPENCL_MEMORY_SCOPE_WORK_GROUP,
+  memory_scope_device = __OPENCL_MEMORY_SCOPE_DEVICE,
+  memory_scope_all_svm_devices = __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES,
+#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
+  memory_scope_sub_group = __OPENCL_MEMORY_SCOPE_SUB_GROUP
+#endif
+} memory_scope;
+
 struct S { char c[3]; };
 
 char i8;
@@ -170,5 +191,5 @@
 
 void nullPointerWarning(atomic_int *Ap, int *p, int val) {
   // The 'expected' pointer shouldn't be NULL.
-  (void)__opencl_atomic_compare_exchange_strong(Ap, NULL, val, memory_order_relaxed, memory_order_relaxed, memory_scope_work_group); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  (void)__opencl_atomic_compare_exchange_strong(Ap, (void *)0, val, memory_order_relaxed, memory_order_relaxed, memory_scope_work_group); // expected-warning {{null passed to a callee that requires a non-null argument}}
 }
Index: cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl
===
--- cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl
+++ cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl
@@ -1,12 +1,33 @@
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -finclude-default-header -O0 -o - -triple=amdgcn-amd-amdhsa-opencl | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -O0 -o - -triple=amdgcn-amd-amdhsa-opencl | FileCheck %s
 
 // Also test serialization of atomic operations here, to avoid duplicating the test.
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -emit-pch -O0 -o %t -triple=amdgcn-amd-amdhsa-opencl
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -include-pch %t -O0 -triple=amdgcn-amd-amdhsa-opencl -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-pch -O0 -o %t -triple=amdgcn-amd-amdhsa-opencl
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -include-pch %t -O0 -triple=amdgcn-amd-amdhsa-opencl -emit-llvm -o - | FileCheck %s
 
 #ifndef ALREADY_INCLUDED
 #define ALREADY_INCLUDED
 
+typedef __INTPTR_TYPE__ intptr_t;
+typedef int int8 __attribute__((ext_vector_type(8)));
+
+typedef enum memory_order {
+  memory_order_relaxed = __ATOMIC_RELAXED,
+  memory_order_acquire = __ATOMIC_ACQUIRE,
+  memory_order_release = __ATOMIC_RELEASE,
+  memory_order_acq_rel = __ATOMIC_ACQ_REL,
+  memory_order_seq_cst = __ATOMIC_SEQ_CST
+} memory_order;
+
+typedef enum memory_scope {
+  memory_scope_work_item = __OPENCL_MEMORY_SCOPE_WORK_ITEM,
+  memory_scope_work_group = __OPENCL_MEMORY_SCOPE_WORK_GROUP,
+  memory_scope_device = __OPENCL_MEMORY_SCOPE_DEVICE,
+  memory_scope_all_svm_devices = __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES,
+#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
+  memory_scope_sub_group = __OPENCL_MEMORY_SCOPE_SUB_GROUP
+#endif
+} memory_scope;
+
 atomic_int j;
 
 void fi1(atomic_int *i) {
Index: cfe/trunk/test/CodeGenOpenCL/atomic-ops-libcall.cl
===
--- cfe/trunk/test/CodeGenOpenCL/atomic-ops-libcall.cl
+++ cfe/trunk/test/CodeGenOpenCL/atomic-ops-libcall.cl
@@ -1,5 +1,22 @@
-// RUN: %clang_cc1 < %s -cl-std=CL2.0 -finclude-default-header -triple spir64 -emit-llvm | FileCheck -check-prefix=SPIR %s
-// RUN: %clang_cc1 < %s -cl-std=CL2.0 

r310927 - Remove -finclude-default-header in OpenCL atomic tests

2017-08-15 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue Aug 15 09:30:31 2017
New Revision: 310927

URL: http://llvm.org/viewvc/llvm-project?rev=310927=rev
Log:
Remove -finclude-default-header in OpenCL atomic tests

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

Modified:
cfe/trunk/test/CodeGenOpenCL/atomic-ops-libcall.cl
cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl
cfe/trunk/test/SemaOpenCL/atomic-ops.cl

Modified: cfe/trunk/test/CodeGenOpenCL/atomic-ops-libcall.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/atomic-ops-libcall.cl?rev=310927=310926=310927=diff
==
--- cfe/trunk/test/CodeGenOpenCL/atomic-ops-libcall.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/atomic-ops-libcall.cl Tue Aug 15 09:30:31 2017
@@ -1,5 +1,22 @@
-// RUN: %clang_cc1 < %s -cl-std=CL2.0 -finclude-default-header -triple spir64 
-emit-llvm | FileCheck -check-prefix=SPIR %s
-// RUN: %clang_cc1 < %s -cl-std=CL2.0 -finclude-default-header -triple 
armv5e-none-linux-gnueabi -emit-llvm | FileCheck -check-prefix=ARM %s
+// RUN: %clang_cc1 < %s -cl-std=CL2.0 -triple spir64 -emit-llvm | FileCheck 
-check-prefix=SPIR %s
+// RUN: %clang_cc1 < %s -cl-std=CL2.0 -triple armv5e-none-linux-gnueabi 
-emit-llvm | FileCheck -check-prefix=ARM %s
+typedef enum memory_order {
+  memory_order_relaxed = __ATOMIC_RELAXED,
+  memory_order_acquire = __ATOMIC_ACQUIRE,
+  memory_order_release = __ATOMIC_RELEASE,
+  memory_order_acq_rel = __ATOMIC_ACQ_REL,
+  memory_order_seq_cst = __ATOMIC_SEQ_CST
+} memory_order;
+
+typedef enum memory_scope {
+  memory_scope_work_item = __OPENCL_MEMORY_SCOPE_WORK_ITEM,
+  memory_scope_work_group = __OPENCL_MEMORY_SCOPE_WORK_GROUP,
+  memory_scope_device = __OPENCL_MEMORY_SCOPE_DEVICE,
+  memory_scope_all_svm_devices = __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES,
+#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
+  memory_scope_sub_group = __OPENCL_MEMORY_SCOPE_SUB_GROUP
+#endif
+} memory_scope;
 
 void f(atomic_int *i, atomic_uint *ui, int cmp, int order, int scope) {
   int x;

Modified: cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl?rev=310927=310926=310927=diff
==
--- cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl Tue Aug 15 09:30:31 2017
@@ -1,12 +1,33 @@
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -finclude-default-header -O0 -o 
- -triple=amdgcn-amd-amdhsa-opencl | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -O0 -o - 
-triple=amdgcn-amd-amdhsa-opencl | FileCheck %s
 
 // Also test serialization of atomic operations here, to avoid duplicating the 
test.
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -emit-pch -O0 -o 
%t -triple=amdgcn-amd-amdhsa-opencl
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -include-pch %t 
-O0 -triple=amdgcn-amd-amdhsa-opencl -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-pch -O0 -o %t 
-triple=amdgcn-amd-amdhsa-opencl
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -include-pch %t -O0 
-triple=amdgcn-amd-amdhsa-opencl -emit-llvm -o - | FileCheck %s
 
 #ifndef ALREADY_INCLUDED
 #define ALREADY_INCLUDED
 
+typedef __INTPTR_TYPE__ intptr_t;
+typedef int int8 __attribute__((ext_vector_type(8)));
+
+typedef enum memory_order {
+  memory_order_relaxed = __ATOMIC_RELAXED,
+  memory_order_acquire = __ATOMIC_ACQUIRE,
+  memory_order_release = __ATOMIC_RELEASE,
+  memory_order_acq_rel = __ATOMIC_ACQ_REL,
+  memory_order_seq_cst = __ATOMIC_SEQ_CST
+} memory_order;
+
+typedef enum memory_scope {
+  memory_scope_work_item = __OPENCL_MEMORY_SCOPE_WORK_ITEM,
+  memory_scope_work_group = __OPENCL_MEMORY_SCOPE_WORK_GROUP,
+  memory_scope_device = __OPENCL_MEMORY_SCOPE_DEVICE,
+  memory_scope_all_svm_devices = __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES,
+#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
+  memory_scope_sub_group = __OPENCL_MEMORY_SCOPE_SUB_GROUP
+#endif
+} memory_scope;
+
 atomic_int j;
 
 void fi1(atomic_int *i) {

Modified: cfe/trunk/test/SemaOpenCL/atomic-ops.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/atomic-ops.cl?rev=310927=310926=310927=diff
==
--- cfe/trunk/test/SemaOpenCL/atomic-ops.cl (original)
+++ cfe/trunk/test/SemaOpenCL/atomic-ops.cl Tue Aug 15 09:30:31 2017
@@ -1,11 +1,32 @@
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -verify 
-fsyntax-only -triple=spir64
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -verify 
-fsyntax-only -triple=amdgcn-amdhsa-amd-opencl
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only -triple=spir64
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only 
-triple=amdgcn-amdhsa-amd-opencl
 
 // Basic parsing/Sema tests for __opencl_atomic_*

Re: r310382 - [Availability] Don't make an availability attribute imply default visibility on macOS

2017-08-15 Thread Nico Weber via cfe-commits
Do we want to merge this to 5.0?

On Tue, Aug 8, 2017 at 1:09 PM, Erik Pilkington via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: epilk
> Date: Tue Aug  8 10:09:09 2017
> New Revision: 310382
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310382=rev
> Log:
> [Availability] Don't make an availability attribute imply default
> visibility on macOS
>
> Fixes PR33796, rdar://33655115
>
> Differential revision: https://reviews.llvm.org/D36191
>
> Modified:
> cfe/trunk/docs/ReleaseNotes.rst
> cfe/trunk/lib/AST/Decl.cpp
> cfe/trunk/test/CodeGen/attr-availability.c
>
> Modified: cfe/trunk/docs/ReleaseNotes.rst
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/
> ReleaseNotes.rst?rev=310382=310381=310382=diff
> 
> ==
> --- cfe/trunk/docs/ReleaseNotes.rst (original)
> +++ cfe/trunk/docs/ReleaseNotes.rst Tue Aug  8 10:09:09 2017
> @@ -94,6 +94,9 @@ Clang now supports the ...
>  Attribute Changes in Clang
>  --
>
> +- The presence of __attribute__((availability(...))) on a declaration no
> longer
> +  implies default visibility for that declaration on macOS.
> +
>  - ...
>
>  Windows Support
>
> Modified: cfe/trunk/lib/AST/Decl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> Decl.cpp?rev=310382=310381=310382=diff
> 
> ==
> --- cfe/trunk/lib/AST/Decl.cpp (original)
> +++ cfe/trunk/lib/AST/Decl.cpp Tue Aug  8 10:09:09 2017
> @@ -216,14 +216,6 @@ static Optional getVisibilit
>  return getVisibilityFromAttr(A);
>}
>
> -  // If we're on Mac OS X, an 'availability' for Mac OS X attribute
> -  // implies visibility(default).
> -  if (D->getASTContext().getTargetInfo().getTriple().isOSDarwin()) {
> -for (const auto *A : D->specific_attrs())
> -  if (A->getPlatform()->getName().equals("macos"))
> -return DefaultVisibility;
> -  }
> -
>return None;
>  }
>
>
> Modified: cfe/trunk/test/CodeGen/attr-availability.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> CodeGen/attr-availability.c?rev=310382=310381=310382=diff
> 
> ==
> --- cfe/trunk/test/CodeGen/attr-availability.c (original)
> +++ cfe/trunk/test/CodeGen/attr-availability.c Tue Aug  8 10:09:09 2017
> @@ -8,9 +8,9 @@
>  void f2();
>  void f2() { }
>
> -// CHECK-10_4-LABEL: define void @f3
> -// CHECK-10_5-LABEL: define void @f3
> -// CHECK-10_6-LABEL: define void @f3
> +// CHECK-10_4-LABEL: define hidden void @f3
> +// CHECK-10_5-LABEL: define hidden void @f3
> +// CHECK-10_6-LABEL: define hidden void @f3
>  void f3() __attribute__((availability(macosx,introduced=10.5)));
>  void f3() { }
>
>
>
> ___
> 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] D36580: [OpenCL] Support variable memory scope in atomic builtins

2017-08-15 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310924: [OpenCL] Support variable memory scope in atomic 
builtins (authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D36580?vs=60=85#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36580

Files:
  cfe/trunk/include/clang/AST/Expr.h
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Basic/SyncScope.h
  cfe/trunk/lib/AST/Expr.cpp
  cfe/trunk/lib/CodeGen/CGAtomic.cpp
  cfe/trunk/lib/Frontend/InitPreprocessor.cpp
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/CodeGenOpenCL/atomic-ops-libcall.cl
  cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl
  cfe/trunk/test/SemaOpenCL/atomic-ops.cl

Index: cfe/trunk/lib/CodeGen/CGAtomic.cpp
===
--- cfe/trunk/lib/CodeGen/CGAtomic.cpp
+++ cfe/trunk/lib/CodeGen/CGAtomic.cpp
@@ -18,6 +18,7 @@
 #include "TargetInfo.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/Operator.h"
@@ -659,6 +660,61 @@
   return DeclPtr;
 }
 
+static void EmitAtomicOp(CodeGenFunction , AtomicExpr *Expr, Address Dest,
+ Address Ptr, Address Val1, Address Val2,
+ llvm::Value *IsWeak, llvm::Value *FailureOrder,
+ uint64_t Size, llvm::AtomicOrdering Order,
+ llvm::Value *Scope) {
+  auto ScopeModel = Expr->getScopeModel();
+
+  // LLVM atomic instructions always have synch scope. If clang atomic
+  // expression has no scope operand, use default LLVM synch scope.
+  if (!ScopeModel) {
+EmitAtomicOp(CGF, Expr, Dest, Ptr, Val1, Val2, IsWeak, FailureOrder, Size,
+ Order, CGF.CGM.getLLVMContext().getOrInsertSyncScopeID(""));
+return;
+  }
+
+  // Handle constant scope.
+  if (auto SC = dyn_cast(Scope)) {
+auto SCID = CGF.getTargetHooks().getLLVMSyncScopeID(
+ScopeModel->map(SC->getZExtValue()), CGF.CGM.getLLVMContext());
+EmitAtomicOp(CGF, Expr, Dest, Ptr, Val1, Val2, IsWeak, FailureOrder, Size,
+ Order, SCID);
+return;
+  }
+
+  // Handle non-constant scope.
+  auto  = CGF.Builder;
+  auto Scopes = ScopeModel->getRuntimeValues();
+  llvm::DenseMap BB;
+  for (auto S : Scopes)
+BB[S] = CGF.createBasicBlock(getAsString(ScopeModel->map(S)), CGF.CurFn);
+
+  llvm::BasicBlock *ContBB =
+  CGF.createBasicBlock("atomic.scope.continue", CGF.CurFn);
+
+  auto *SC = Builder.CreateIntCast(Scope, Builder.getInt32Ty(), false);
+  // If unsupported synch scope is encountered at run time, assume a fallback
+  // synch scope value.
+  auto FallBack = ScopeModel->getFallBackValue();
+  llvm::SwitchInst *SI = Builder.CreateSwitch(SC, BB[FallBack]);
+  for (auto S : Scopes) {
+auto *B = BB[S];
+if (S != FallBack)
+  SI->addCase(Builder.getInt32(S), B);
+
+Builder.SetInsertPoint(B);
+EmitAtomicOp(CGF, Expr, Dest, Ptr, Val1, Val2, IsWeak, FailureOrder, Size,
+ Order,
+ CGF.getTargetHooks().getLLVMSyncScopeID(ScopeModel->map(S),
+ CGF.getLLVMContext()));
+Builder.CreateBr(ContBB);
+  }
+
+  Builder.SetInsertPoint(ContBB);
+}
+
 static void
 AddDirectArgument(CodeGenFunction , CallArgList ,
   bool UseOptimizedLibcall, llvm::Value *Val, QualType ValTy,
@@ -711,7 +767,8 @@
   }
 
   llvm::Value *Order = EmitScalarExpr(E->getOrder());
-  llvm::Value *Scope = EmitScalarExpr(E->getScope());
+  llvm::Value *Scope =
+  E->getScopeModel() ? EmitScalarExpr(E->getScope()) : nullptr;
 
   switch (E->getOp()) {
   case AtomicExpr::AO__c11_atomic_init:
@@ -1132,44 +1189,38 @@
 E->getOp() == AtomicExpr::AO__atomic_load ||
 E->getOp() == AtomicExpr::AO__atomic_load_n;
 
-  assert(isa(Scope) &&
-  "Non-constant synchronization scope not supported");
-  auto SCID = getTargetHooks().getLLVMSyncScopeID(
-  static_cast(cast(Scope)->getZExtValue()),
-  getLLVMContext());
-
   if (isa(Order)) {
 auto ord = cast(Order)->getZExtValue();
 // We should not ever get to a case where the ordering isn't a valid C ABI
 // value, but it's hard to enforce that in general.
 if (llvm::isValidAtomicOrderingCABI(ord))
   switch ((llvm::AtomicOrderingCABI)ord) {
   case llvm::AtomicOrderingCABI::relaxed:
 EmitAtomicOp(*this, E, Dest, Ptr, Val1, Val2, IsWeak, OrderFail, Size,
- llvm::AtomicOrdering::Monotonic, SCID);
+ llvm::AtomicOrdering::Monotonic, Scope);
 break;
   case llvm::AtomicOrderingCABI::consume:
   case llvm::AtomicOrderingCABI::acquire:
 if (IsStore)
   break; // Avoid crashing on code with undefined behavior
 

r310924 - [OpenCL] Support variable memory scope in atomic builtins

2017-08-15 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue Aug 15 09:02:49 2017
New Revision: 310924

URL: http://llvm.org/viewvc/llvm-project?rev=310924=rev
Log:
[OpenCL] Support variable memory scope in atomic builtins

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

Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/SyncScope.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/CodeGen/CGAtomic.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGenOpenCL/atomic-ops-libcall.cl
cfe/trunk/test/CodeGenOpenCL/atomic-ops.cl
cfe/trunk/test/SemaOpenCL/atomic-ops.cl

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=310924=310923=310924=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Aug 15 09:02:49 2017
@@ -24,6 +24,7 @@
 #include "clang/AST/Type.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SyncScope.h"
 #include "clang/Basic/TypeTraits.h"
 #include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/APSInt.h"
@@ -5067,8 +5068,8 @@ public:
 /// similarly-named C++11 instructions, and __c11 variants for ,
 /// and corresponding __opencl_atomic_* for OpenCL 2.0.
 /// All of these instructions take one primary pointer, at least one memory
-/// order, and one synchronization scope. The C++11 and __c11 atomic AtomicExpr
-/// always take the default synchronization scope.
+/// order. The instructions for which getScopeModel returns non-null value
+/// take one synch scope.
 class AtomicExpr : public Expr {
 public:
   enum AtomicOp {
@@ -5080,14 +5081,16 @@ public:
   };
 
 private:
-  enum { PTR, ORDER, SCOPE, VAL1, ORDER_FAIL, VAL2, WEAK, END_EXPR };
-  Stmt* SubExprs[END_EXPR];
+  /// \brief Location of sub-expressions.
+  /// The location of Scope sub-expression is NumSubExprs - 1, which is
+  /// not fixed, therefore is not defined in enum.
+  enum { PTR, ORDER, VAL1, ORDER_FAIL, VAL2, WEAK, END_EXPR };
+  Stmt *SubExprs[END_EXPR + 1];
   unsigned NumSubExprs;
   SourceLocation BuiltinLoc, RParenLoc;
   AtomicOp Op;
 
   friend class ASTStmtReader;
-
 public:
   AtomicExpr(SourceLocation BLoc, ArrayRef args, QualType t,
  AtomicOp op, SourceLocation RP);
@@ -5106,7 +5109,8 @@ public:
 return cast(SubExprs[ORDER]);
   }
   Expr *getScope() const {
-return cast(SubExprs[SCOPE]);
+assert(getScopeModel() && "No scope");
+return cast(SubExprs[NumSubExprs - 1]);
   }
   Expr *getVal1() const {
 if (Op == AO__c11_atomic_init || Op == AO__opencl_atomic_init)
@@ -5173,6 +5177,24 @@ public:
   const_child_range children() const {
 return const_child_range(SubExprs, SubExprs + NumSubExprs);
   }
+
+  /// \brief Get atomic scope model for the atomic op code.
+  /// \return empty atomic scope model if the atomic op code does not have
+  ///   scope operand.
+  static std::unique_ptr getScopeModel(AtomicOp Op) {
+auto Kind =
+(Op >= AO__opencl_atomic_load && Op <= AO__opencl_atomic_fetch_max)
+? AtomicScopeModelKind::OpenCL
+: AtomicScopeModelKind::None;
+return AtomicScopeModel::create(Kind);
+  }
+
+  /// \brief Get atomic scope model.
+  /// \return empty atomic scope model if this atomic expression does not have
+  ///   scope operand.
+  std::unique_ptr getScopeModel() const {
+return getScopeModel(getOp());
+  }
 };
 
 /// TypoExpr - Internal placeholder for expressions where typo correction

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=310924=310923=310924=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Aug 15 09:02:49 
2017
@@ -7012,8 +7012,6 @@ def warn_atomic_op_has_invalid_memory_or
   InGroup>;
 def err_atomic_op_has_invalid_synch_scope : Error<
   "synchronization scope argument to atomic operation is invalid">;
-def err_atomic_op_has_non_constant_synch_scope : Error<
-  "non-constant synchronization scope argument to atomic operation is not 
supported">;
 
 def err_overflow_builtin_must_be_int : Error<
   "operand argument to overflow builtin must be an integer (%0 invalid)">;

Modified: cfe/trunk/include/clang/Basic/SyncScope.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SyncScope.h?rev=310924=310923=310924=diff
==
--- cfe/trunk/include/clang/Basic/SyncScope.h (original)
+++ cfe/trunk/include/clang/Basic/SyncScope.h Tue Aug 15 09:02:49 

Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-15 Thread Diana Picus via cfe-commits
Ugh, I'm not sure that last email made it through.

Here's the IR with -Xclang -disable-llvm-passes, at r310400 and r310401:
https://goo.gl/4n84SR
https://goo.gl/gxhxp9

The diff between them is small enough so I don't think there's much
point in reducing it further.
Hope that helps.

On 15 August 2017 at 17:51, Diana Picus  wrote:
> Actually, I'm not sure I need to reduce it, the diff between the IR
> with -Xclang -no-llvm-passes is pretty small for the version
> with/without the patch. See attached. I hope this helps, it does look
> like a problem with va_arg handling.
>
> Sorry again that this is going so slowly...
>
> On 15 August 2017 at 16:52, Diana Picus  wrote:
>> On 15 August 2017 at 01:25, Richard Smith  wrote:
>>> On 14 August 2017 at 03:27, Diana Picus via cfe-commits
>>>  wrote:

 Hi,

 Strangely enough, it turns out that if I run
 Asan-armhf-with-calls-Noinst-Test on the command line it fails,
 although it doesn't fail when run with lit.
>>>
>>>
>>> Looks like the crash is within the "use_colors == true" portion of
>>> ColoredPrintf, so this would make sense if running the test within lit turns
>>> off color support (perhaps because the output is not a terminal).
>>>
>>
>> That's a good catch, it seems if I run it with --gtest-color=no it
>> still passes, but prints some garbage at the end:
>> [ PASSED ] 97 tests.
>> YOU HAVE -1094542056 DISABLED F]�뀼��_8�pGD2
>>
>>

 I've attached the stack
 trace from gdb. It looks like some trouble passing down va_arg
 parameters, but I haven't looked into too much details. The segfault
 happens when we try to do a   ldrb   r3, [r0, r1], with r1 set to 0 by
 the current function and r0 passed down from the caller. I'm not sure
 if this is the exact same problem as the other tests, but feel free to
 have a look at that code.
>>>
>>>
>>> Have you tried running Asan-armhf-with-calls-Noinst-Test on the command line
>>> without this patch applied? (It's possible that this is a pre-existing bug
>>> in ARM varargs call lowering, and is unrelated to the bug we're trying to
>>> track down. This code path performs an unrelated varargs call between a
>>> va_start / va_end pair, which seems like quite a rare situation, and I could
>>> easily believe there's something wrong with our lowering that allows some
>>> portion of the outer va_list state to be clobbered in that scenario.)
>>>
>>
>> It seems to work without the patch. I'm currently trying to reduce
>> Asan-armhf-with-calls-Test and I'll get back to you with the IR or
>> assembly files (whichever makes any difference).
>>
 Meanwhile, I've removed some clutter from Asan-armhf-with-calls-Test
 (which is the original failure that we were seeing) and left only one
 failing test that seemed small enough. I'll try to look at the
 disassembly before/after the patch and maybe even run valgrind on it
 (running it on the original binary naturally takes forever).

 Let me know if there's anything else I could try. I can also send you
 disassembly or even LLVM IR for the Asan-armhf-with-calls-Noinst-Test
 if you think it helps.

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


[PATCH] D36750: [analyzer] RetainCount: When diagnosing overrelease, mention if it's coming from a nested block.

2017-08-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
Herald added a subscriber: xazax.hun.

RetainCountChecker's warning message "`Incorrect decrement of the reference 
count of an object that is not owned at this point by the caller`" does not 
explicitly mention the caller, which may be confusing when there is a nested 
block, especially when the block is hard to notice. It should be obvious to 
which caller it refers. The patch tries to improve on that.

By the way, plist-based tests in `retain-release.m` are disabled since r163536 
(~2012), and need to be updated. It's trivial to re-enable them but annoying to 
maintain - would we prefer to re-enable or delete them or replace with 
`-analyzer-output=text` tests?


https://reviews.llvm.org/D36750

Files:
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  test/Analysis/retain-release.m

Index: test/Analysis/retain-release.m
===
--- test/Analysis/retain-release.m
+++ test/Analysis/retain-release.m
@@ -2300,6 +2300,23 @@
   CFRelease(obj);
 }
 
+//===--===//
+// When warning within blocks make it obvious that warnings refer to blocks.
+//===--===//
+
+int useBlock(int (^block)());
+void rdar31699502_hardToNoticeBlocks() {
+  if (useBlock(^{
+NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+NSArray *array = [NSArray array];
+[array release]; // expected-warning{{Incorrect decrement of the reference count of an object that is not owned at this point by the current block}}
+[pool drain];
+return 0;
+  })) {
+return;
+  }
+}
+
 // CHECK:  diagnostics
 // CHECK-NEXT:  
 // CHECK-NEXT:   
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -86,6 +86,7 @@
 ErrorDeallocGC, // Calling -dealloc with GC enabled.
 ErrorUseAfterRelease, // Object used after released.
 ErrorReleaseNotOwned, // Release of an object that was not owned.
+ErrorReleaseNotOwnedByBlock, // Release of an object not owned by a block.
 ERROR_LEAK_START,
 ErrorLeak,  // A memory leak due to excessive reference counts.
 ErrorLeakReturned, // A memory leak due to the returning method not having
@@ -331,6 +332,9 @@
   Out << "Release of Not-Owned [ERROR]";
   break;
 
+case ErrorReleaseNotOwnedByBlock:
+  Out << "Release of Not-Owned by Block [ERROR]";
+
 case RefVal::ErrorOverAutorelease:
   Out << "Over-autoreleased";
   break;
@@ -1714,6 +1718,17 @@
 }
   };
 
+  class BadReleaseByBlock : public CFRefBug {
+  public:
+BadReleaseByBlock(const CheckerBase *checker)
+: CFRefBug(checker, "Bad release") {}
+
+const char *getDescription() const override {
+  return "Incorrect decrement of the reference count of an object that is "
+ "not owned at this point by the current block";
+}
+  };
+
   class DeallocGC : public CFRefBug {
   public:
 DeallocGC(const CheckerBase *checker)
@@ -2510,7 +2525,8 @@
 check::RegionChanges,
 eval::Assume,
 eval::Call > {
-  mutable std::unique_ptr useAfterRelease, releaseNotOwned;
+  mutable std::unique_ptr useAfterRelease;
+  mutable std::unique_ptr releaseNotOwned, releaseNotOwnedByBlock;
   mutable std::unique_ptr deallocGC, deallocNotOwned;
   mutable std::unique_ptr overAutorelease, returnNotOwnedForOwned;
   mutable std::unique_ptr leakWithinFunction, leakAtReturn;
@@ -3299,7 +3315,10 @@
   return removeRefBinding(state, sym);
 V = V.releaseViaIvar() ^ RefVal::Released;
   } else {
-V = V ^ RefVal::ErrorReleaseNotOwned;
+if (isa(C.getLocationContext()->getDecl()))
+  V = V ^ RefVal::ErrorReleaseNotOwnedByBlock;
+else
+  V = V ^ RefVal::ErrorReleaseNotOwned;
 hasErr = V.getKind();
   }
   break;
@@ -3349,6 +3368,11 @@
 releaseNotOwned.reset(new BadRelease(this));
   BT = releaseNotOwned.get();
   break;
+case RefVal::ErrorReleaseNotOwnedByBlock:
+  if (!releaseNotOwnedByBlock)
+releaseNotOwnedByBlock.reset(new BadReleaseByBlock(this));
+  BT = releaseNotOwnedByBlock.get();
+  break;
 case RefVal::ErrorDeallocGC:
   if (!deallocGC)
 deallocGC.reset(new DeallocGC(this));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36707: [CodeGen]Refactor CpuSupports/CPUIs Builtin Code Gen to better work with "target" implementation

2017-08-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Of course, overnight I realized I am probably better off having the 
'CpuSupports' validate MULTIPLE features at a time!  I'll update this patch 
with an improvement when I get one that I think is really useful.  Sorry for 
the thrash.


https://reviews.llvm.org/D36707



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


Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-15 Thread Diana Picus via cfe-commits
On 15 August 2017 at 01:25, Richard Smith  wrote:
> On 14 August 2017 at 03:27, Diana Picus via cfe-commits
>  wrote:
>>
>> Hi,
>>
>> Strangely enough, it turns out that if I run
>> Asan-armhf-with-calls-Noinst-Test on the command line it fails,
>> although it doesn't fail when run with lit.
>
>
> Looks like the crash is within the "use_colors == true" portion of
> ColoredPrintf, so this would make sense if running the test within lit turns
> off color support (perhaps because the output is not a terminal).
>

That's a good catch, it seems if I run it with --gtest-color=no it
still passes, but prints some garbage at the end:
[ PASSED ] 97 tests.
YOU HAVE -1094542056 DISABLED F]�뀼��_8�pGD2


>>
>> I've attached the stack
>> trace from gdb. It looks like some trouble passing down va_arg
>> parameters, but I haven't looked into too much details. The segfault
>> happens when we try to do a   ldrb   r3, [r0, r1], with r1 set to 0 by
>> the current function and r0 passed down from the caller. I'm not sure
>> if this is the exact same problem as the other tests, but feel free to
>> have a look at that code.
>
>
> Have you tried running Asan-armhf-with-calls-Noinst-Test on the command line
> without this patch applied? (It's possible that this is a pre-existing bug
> in ARM varargs call lowering, and is unrelated to the bug we're trying to
> track down. This code path performs an unrelated varargs call between a
> va_start / va_end pair, which seems like quite a rare situation, and I could
> easily believe there's something wrong with our lowering that allows some
> portion of the outer va_list state to be clobbered in that scenario.)
>

It seems to work without the patch. I'm currently trying to reduce
Asan-armhf-with-calls-Test and I'll get back to you with the IR or
assembly files (whichever makes any difference).

>> Meanwhile, I've removed some clutter from Asan-armhf-with-calls-Test
>> (which is the original failure that we were seeing) and left only one
>> failing test that seemed small enough. I'll try to look at the
>> disassembly before/after the patch and maybe even run valgrind on it
>> (running it on the original binary naturally takes forever).
>>
>> Let me know if there's anything else I could try. I can also send you
>> disassembly or even LLVM IR for the Asan-armhf-with-calls-Noinst-Test
>> if you think it helps.
>>
>> Cheers,
>> Diana
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36580: [OpenCL] Support variable memory scope in atomic builtins

2017-08-15 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.

Thanks, that looks great.


https://reviews.llvm.org/D36580



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


r310921 - Allow pretty platform names in availability attributes

2017-08-15 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Aug 15 07:42:01 2017
New Revision: 310921

URL: http://llvm.org/viewvc/llvm-project?rev=310921=rev
Log:
Allow pretty platform names in availability attributes

rdar://32076651

Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/Sema/attr-availability-app-extensions.c
cfe/trunk/test/Sema/attr-availability-ios.c
cfe/trunk/test/Sema/attr-availability-macosx.c
cfe/trunk/test/Sema/attr-availability-tvos.c
cfe/trunk/test/Sema/attr-availability-watchos.c

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=310921=310920=310921=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Aug 15 07:42:01 2017
@@ -912,13 +912,18 @@ void Parser::ParseAvailabilityAttribute(
 return;
   }
   IdentifierLoc *Platform = ParseIdentifierLoc();
-  // Canonicalize platform name from "macosx" to "macos".
-  if (Platform->Ident && Platform->Ident->getName() == "macosx")
-Platform->Ident = PP.getIdentifierInfo("macos");
-  // Canonicalize platform name from "macosx_app_extension" to
-  // "macos_app_extension".
-  if (Platform->Ident && Platform->Ident->getName() == "macosx_app_extension")
-Platform->Ident = PP.getIdentifierInfo("macos_app_extension");
+  if (const IdentifierInfo *const Ident = Platform->Ident) {
+// Canonicalize platform name from "macosx" to "macos".
+if (Ident->getName() == "macosx")
+  Platform->Ident = PP.getIdentifierInfo("macos");
+// Canonicalize platform name from "macosx_app_extension" to
+// "macos_app_extension".
+else if (Ident->getName() == "macosx_app_extension")
+  Platform->Ident = PP.getIdentifierInfo("macos_app_extension");
+else
+  Platform->Ident = PP.getIdentifierInfo(
+  AvailabilityAttr::canonicalizePlatformName(Ident->getName()));
+  }
 
   // Parse the ',' following the platform name.
   if (ExpectAndConsume(tok::comma)) {

Modified: cfe/trunk/test/Sema/attr-availability-app-extensions.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-availability-app-extensions.c?rev=310921=310920=310921=diff
==
--- cfe/trunk/test/Sema/attr-availability-app-extensions.c (original)
+++ cfe/trunk/test/Sema/attr-availability-app-extensions.c Tue Aug 15 07:42:01 
2017
@@ -21,8 +21,19 @@ __attribute__((availability(ios,unavaila
 #endif
 void f1(int); // expected-note {{'f1' has been explicitly marked unavailable 
here}}
 
+#if __has_feature(attribute_availability_app_extension)
+ __attribute__((availability(macOSApplicationExtension,unavailable)))
+#ifndef TVOS
+ __attribute__((availability(iOSApplicationExtension,unavailable)))
+#else
+ __attribute__((availability(tvOSApplicationExtension,unavailable)))
+#endif
+#endif
+void f2(int); // expected-note {{'f2' has been explicitly marked unavailable 
here}}
+
 void test() {
   f0(1); // expected-error {{'f0' is unavailable: not available on}}
   f1(1); // expected-error {{'f1' is unavailable}}
+  f2(2); // expected-error {{'f2' is unavailable: not available on}}
 }
 

Modified: cfe/trunk/test/Sema/attr-availability-ios.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-availability-ios.c?rev=310921=310920=310921=diff
==
--- cfe/trunk/test/Sema/attr-availability-ios.c (original)
+++ cfe/trunk/test/Sema/attr-availability-ios.c Tue Aug 15 07:42:01 2017
@@ -2,13 +2,13 @@
 
 void f0(int) __attribute__((availability(ios,introduced=2.0,deprecated=2.1))); 
// expected-note {{'f0' has been explicitly marked deprecated here}}
 void f1(int) __attribute__((availability(ios,introduced=2.1)));
-void f2(int) __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); 
// expected-note {{'f2' has been explicitly marked deprecated here}}
+void f2(int) __attribute__((availability(iOS,introduced=2.0,deprecated=3.0))); 
// expected-note {{'f2' has been explicitly marked deprecated here}}
 void f3(int) __attribute__((availability(ios,introduced=3.0)));
 void f4(int) 
__attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5),
 availability(ios,introduced=2.0,deprecated=2.1,obsoleted=3.0))); // 
expected-note{{explicitly marked unavailable}}
 
 void f5(int) __attribute__((availability(ios,introduced=2.0))) 
__attribute__((availability(ios,deprecated=3.0))); // expected-note {{'f5' has 
been explicitly marked deprecated here}}
 void f6(int) __attribute__((availability(ios,deprecated=3.0)));
-void f6(int) __attribute__((availability(ios,introduced=2.0))); // 
expected-note {{'f6' has been explicitly marked deprecated here}}
+void f6(int) __attribute__((availability(iOS,introduced=2.0))); // 
expected-note {{'f6' has been explicitly marked deprecated here}}
 
 void test() {

[PATCH] D36610: [Tooling] Add option to getFullyQualifiedName using a custom PritingPolicy

2017-08-15 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho updated this revision to Diff 63.
mikhail.ramalho added a comment.

Updated QualTypeNamesTest.cpp to use multiline string in all tests.

Also ran clang-format -style=LLVM for code style.


https://reviews.llvm.org/D36610

Files:
  include/clang/Tooling/Core/QualTypeNames.h
  lib/Tooling/Core/QualTypeNames.cpp
  unittests/Tooling/QualTypeNamesTest.cpp

Index: unittests/Tooling/QualTypeNamesTest.cpp
===
--- unittests/Tooling/QualTypeNamesTest.cpp
+++ unittests/Tooling/QualTypeNamesTest.cpp
@@ -7,28 +7,40 @@
 //
 //===--===//
 
-#include "clang/Tooling/Core/QualTypeNames.h"
 #include "TestVisitor.h"
+#include "clang/Tooling/Core/QualTypeNames.h"
 using namespace clang;
 
 namespace {
 struct TypeNameVisitor : TestVisitor {
   llvm::StringMap ExpectedQualTypeNames;
   bool WithGlobalNsPrefix = false;
+  bool CustomPrintingPolicy = false;
 
   // ValueDecls are the least-derived decl with both a qualtype and a
   // name.
   bool traverseDecl(Decl *D) {
-return true;  // Always continue
+return true; // Always continue
   }
 
   bool VisitValueDecl(const ValueDecl *VD) {
 std::string ExpectedName =
 ExpectedQualTypeNames.lookup(VD->getNameAsString());
 if (ExpectedName != "") {
-  std::string ActualName =
-  TypeName::getFullyQualifiedName(VD->getType(), *Context,
-  WithGlobalNsPrefix);
+  std::string ActualName;
+  if (!CustomPrintingPolicy)
+ActualName = TypeName::getFullyQualifiedName(VD->getType(), *Context,
+ WithGlobalNsPrefix);
+  else {
+PrintingPolicy Policy(Context->getPrintingPolicy());
+Policy.SuppressScope = false;
+Policy.AnonymousTagLocations = true;
+Policy.PolishForDeclaration = true;
+Policy.SuppressUnwrittenScope = true;
+ActualName = TypeName::getFullyQualifiedName(
+VD->getType(), *Context, Policy, WithGlobalNsPrefix);
+  }
+
   if (ExpectedName != ActualName) {
 // A custom message makes it much easier to see what declaration
 // failed compared to EXPECT_EQ.
@@ -93,94 +105,92 @@
   Visitor.ExpectedQualTypeNames["CheckM"] = "const A::B::Class0 *";
   Visitor.ExpectedQualTypeNames["CheckN"] = "const X *";
   Visitor.runOver(
-  "int CheckInt;\n"
-  "template \n"
-  "class OuterTemplateClass { };\n"
-  "namespace A {\n"
-  " namespace B {\n"
-  "   class Class0 { };\n"
-  "   namespace C {\n"
-  " typedef int MyInt;"
-  " template \n"
-  " using InnerAlias = OuterTemplateClass;\n"
-  " InnerAlias AliasTypeVal;\n"
-  "   }\n"
-  "   template class Template0;"
-  "   template class Template1;"
-  "   typedef B::Class0 AnotherClass;\n"
-  "   void Function1(Template0 CheckC);\n"
-  "   void Function2(Template0,\n"
-  "Template0 > CheckD);\n"
-  "   void Function3(const B::Class0* CheckM);\n"
-  "  }\n"
-  "template class Variadic {};\n"
-  "Variadic, "
-  " B::Template1, "
-  " B::C::MyInt > CheckE;\n"
-  " namespace BC = B::C;\n"
-  " BC::MyInt CheckL;\n"
-  "}\n"
-  "using A::B::Class0;\n"
-  "void Function(Class0 CheckF);\n"
-  "using namespace A::B::C;\n"
-  "void Function(MyInt CheckG);\n"
-  "void f() {\n"
-  "  struct X {} CheckH;\n"
-  "}\n"
-  "struct X;\n"
-  "void f(const ::X* CheckN) {}\n"
-  "namespace {\n"
-  "  class aClass {};\n"
-  "   aClass CheckI;\n"
-  "}\n"
-  "namespace A {\n"
-  "  struct aStruct {} CheckJ;\n"
-  "}\n"
-  "namespace {\n"
-  "  namespace D {\n"
-  "namespace {\n"
-  "  class aStruct {};\n"
-  "  aStruct CheckK;\n"
-  "}\n"
-  "  }\n"
-  "}\n"
-  "template struct Foo {\n"
-  "  typedef typename T::A dependent_type;\n"
-  "  typedef int non_dependent_type;\n"
-  "  dependent_type dependent_type_var;\n"
-  "  non_dependent_type non_dependent_type_var;\n"
-  "};\n"
-  "struct X { typedef int A; };"
-  "Foo var;"
-  "void F() {\n"
-  "  var.dependent_type_var = 0;\n"
-  "var.non_dependent_type_var = 0;\n"
-  "}\n"
-  "class EnumScopeClass {\n"
-  "public:\n"
-  "  enum AnEnum { ZERO, ONE };\n"
-  "};\n"
-  "EnumScopeClass::AnEnum AnEnumVar;\n",
-  TypeNameVisitor::Lang_CXX11
-);
+  R"(int CheckInt;
+ template 
+ class OuterTemplateClass { };
+ namespace A {
+  namespace B {
+class Class0 { };
+namespace C {
+  typedef int MyInt;
+ 

r310920 - [OPENMP] Fix compiler crash on argument translate for NVPTX.

2017-08-15 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Aug 15 07:34:04 2017
New Revision: 310920

URL: http://llvm.org/viewvc/llvm-project?rev=310920=rev
Log:
[OPENMP] Fix compiler crash on argument translate for NVPTX.

When translating arguments for NVPTX target it is not taken into account
that function may have variable number of arguments. Patch fixes this
problem.

Added:
cfe/trunk/test/OpenMP/nvptx_param_translate.c
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=310920=310919=310920=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Tue Aug 15 07:34:04 2017
@@ -2295,9 +2295,14 @@ void CGOpenMPRuntimeNVPTX::emitOutlinedF
 CodeGenFunction , SourceLocation Loc, llvm::Value *OutlinedFn,
 ArrayRef Args) const {
   SmallVector TargetArgs;
+  TargetArgs.reserve(Args.size());
   auto *FnType =
   cast(OutlinedFn->getType()->getPointerElementType());
   for (unsigned I = 0, E = Args.size(); I < E; ++I) {
+if (FnType->isVarArg() && FnType->getNumParams() <= I) {
+  TargetArgs.append(std::next(Args.begin(), I), Args.end());
+  break;
+}
 llvm::Type *TargetType = FnType->getParamType(I);
 llvm::Value *NativeArg = Args[I];
 if (!TargetType->isPointerTy()) {

Added: cfe/trunk/test/OpenMP/nvptx_param_translate.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_param_translate.c?rev=310920=auto
==
--- cfe/trunk/test/OpenMP/nvptx_param_translate.c (added)
+++ cfe/trunk/test/OpenMP/nvptx_param_translate.c Tue Aug 15 07:34:04 2017
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// expected-no-diagnostics
+
+// CHECK: [[MAP_FN:%.+]] = load void (i8*, ...)*, void (i8*, ...)** %
+// CHECK: call void (i8*, ...) [[MAP_FN]](i8* %
+int main() {
+  double a, b;
+
+#pragma omp target map(tofrom  \
+   : a) map(to \
+: b)
+  {
+#pragma omp taskgroup
+#pragma omp task shared(a)
+a = b;
+  }
+  return 0;
+}


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


[PATCH] D36712: Emit section information for extern variables

2017-08-15 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz added inline comments.



Comment at: docs/LangRef.rst:629
+corresponding to the LLVM module, section information specified in the 
+declaration is retained in LLVM IR to enable OpenCL processes.
+

sdardis wrote:
> efriedma wrote:
> > This doesn't really explain the part that matters. For LangRef, it doesn't 
> > matter how the frontend decides to generate declarations (and it might be 
> > different for frontends other than clang).  And OpenCL might motivate this, 
> > but it has nothing to do with the semantics.
> > 
> > The key question here is what it actually means.  Is it a promise the that 
> > a definition will exist for the given symbol in the given section?  If so, 
> > what happens if the symbol is actually in a different section?  ("Undefined 
> > behavior" is probably an acceptable answer, but it needs to be stated 
> > explicitly.)
> > to enable OpenCL processes.
> 
> for targets which make use of this section information. 
> 
> I would also work in a sentence that says that attaching section information 
> to a external declaration is an assertion or promise that the definition is 
> located in that section. If the definition is actually located in a different 
> section the behaviour is undefined.
> 
> I'm favouring "undefined behaviour" in the error case as behaviour is so 
> target and environment specific.
The other side of the problem is, what if the declarations don't have any 
section information, but the definition does? Is that also an undefined 
behavior? I'm in favor of considering it UB as well, but I'm not sure what 
impact it would have on currently valid IR.


https://reviews.llvm.org/D36712



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


[PATCH] D36580: [OpenCL] Support variable memory scope in atomic builtins

2017-08-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 60.
yaxunl marked 3 inline comments as done.
yaxunl added a comment.

Revised by John's comments.


https://reviews.llvm.org/D36580

Files:
  include/clang/AST/Expr.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/SyncScope.h
  lib/AST/Expr.cpp
  lib/CodeGen/CGAtomic.cpp
  lib/Frontend/InitPreprocessor.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGenOpenCL/atomic-ops-libcall.cl
  test/CodeGenOpenCL/atomic-ops.cl
  test/SemaOpenCL/atomic-ops.cl

Index: test/SemaOpenCL/atomic-ops.cl
===
--- test/SemaOpenCL/atomic-ops.cl
+++ test/SemaOpenCL/atomic-ops.cl
@@ -14,7 +14,6 @@
 int8 i64;
 
 atomic_int gn;
-
 void f(atomic_int *i, const atomic_int *ci,
atomic_intptr_t *p, atomic_float *d,
int *I, const int *CI,
@@ -81,6 +80,13 @@
 }
 
 void memory_checks(atomic_int *Ap, int *p, int val) {
+  // non-integer memory order argument is casted to integer type.
+  (void)__opencl_atomic_load(Ap, 1.0f, memory_scope_work_group);
+  float forder;
+  (void)__opencl_atomic_load(Ap, forder, memory_scope_work_group);
+  struct S s;
+  (void)__opencl_atomic_load(Ap, s, memory_scope_work_group); // expected-error {{passing 'struct S' to parameter of incompatible type 'int'}}
+
   (void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_work_group);
   (void)__opencl_atomic_load(Ap, memory_order_acquire, memory_scope_work_group);
   (void)__opencl_atomic_load(Ap, memory_order_consume, memory_scope_work_group); // expected-error {{use of undeclared identifier 'memory_order_consume'}}
@@ -151,8 +157,15 @@
   (void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_device);
   (void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_all_svm_devices);
   (void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_sub_group);
-  (void)__opencl_atomic_load(Ap, memory_order_relaxed, scope); // expected-error{{non-constant synchronization scope argument to atomic operation is not supported}}
+  (void)__opencl_atomic_load(Ap, memory_order_relaxed, scope);
   (void)__opencl_atomic_load(Ap, memory_order_relaxed, 10);//expected-error{{synchronization scope argument to atomic operation is invalid}}
+
+  // non-integer memory scope is casted to integer type.
+  float fscope;
+  (void)__opencl_atomic_load(Ap, memory_order_relaxed, 1.0f);
+  (void)__opencl_atomic_load(Ap, memory_order_relaxed, fscope);
+  struct S s;
+  (void)__opencl_atomic_load(Ap, memory_order_relaxed, s); //expected-error{{passing 'struct S' to parameter of incompatible type 'int'}}
 }
 
 void nullPointerWarning(atomic_int *Ap, int *p, int val) {
Index: test/CodeGenOpenCL/atomic-ops.cl
===
--- test/CodeGenOpenCL/atomic-ops.cl
+++ test/CodeGenOpenCL/atomic-ops.cl
@@ -52,6 +52,81 @@
   return __opencl_atomic_compare_exchange_strong(i, , 1, memory_order_acquire, memory_order_acquire, memory_scope_work_group);
 }
 
+void fi5(atomic_int *i, int scope) {
+  // CHECK-LABEL: @fi5
+  // CHECK: switch i32 %{{.*}}, label %opencl_allsvmdevices [
+  // CHECK-NEXT: i32 1, label %opencl_workgroup
+  // CHECK-NEXT: i32 2, label %opencl_device
+  // CHECK-NEXT: i32 4, label %opencl_subgroup
+  // CHECK-NEXT: ]
+  // CHECK: opencl_workgroup:
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} syncscope("workgroup") seq_cst
+  // CHECK: br label %atomic.scope.continue
+  // CHECK: opencl_device:
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} syncscope("agent") seq_cst
+  // CHECK: br label %atomic.scope.continue
+  // CHECK: opencl_allsvmdevices:
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} seq_cst, align 4
+  // CHECK: br label %atomic.scope.continue
+  // CHECK: opencl_subgroup:
+  // CHECK: %5 = load atomic i32, i32 addrspace(4)* %0 syncscope("subgroup") seq_cst, align 4
+  // CHECK: br label %atomic.scope.continue
+  // CHECK: atomic.scope.continue:
+  int x = __opencl_atomic_load(i, memory_order_seq_cst, scope);
+}
+
+void fi6(atomic_int *i, int order, int scope) {
+  // CHECK-LABEL: @fi6
+  // CHECK: switch i32 %{{.*}}, label %monotonic [
+  // CHECK-NEXT: i32 1, label %acquire
+  // CHECK-NEXT: i32 2, label %acquire
+  // CHECK-NEXT: i32 5, label %seqcst
+  // CHECK-NEXT: ]
+  // CHECK: monotonic:
+  // CHECK: switch i32 %{{.*}}, label %[[MON_ALL:.*]] [
+  // CHECK-NEXT: i32 1, label %[[MON_WG:.*]]
+  // CHECK-NEXT: i32 2, label %[[MON_DEV:.*]]
+  // CHECK-NEXT: i32 4, label %[[MON_SUB:.*]]
+  // CHECK-NEXT: ]
+  // CHECK: acquire:
+  // CHECK: switch i32 %{{.*}}, label %[[ACQ_ALL:.*]] [
+  // CHECK-NEXT: i32 1, label %[[ACQ_WG:.*]]
+  // CHECK-NEXT: i32 2, label %[[ACQ_DEV:.*]]
+  // CHECK-NEXT: i32 4, label %[[ACQ_SUB:.*]]
+  // CHECK-NEXT: ]
+  // CHECK: seqcst:
+  // CHECK: switch i32 %2, label %[[SEQ_ALL:.*]] [
+  // CHECK-NEXT: i32 1, label %[[SEQ_WG:.*]]
+  // CHECK-NEXT: i32 2, label %[[SEQ_DEV:.*]]
+  // CHECK-NEXT: i32 

[PATCH] D36423: [libc++] Introsort based sorting function

2017-08-15 Thread Ben Craig via Phabricator via cfe-commits
bcraig added a comment.

The test headers should not be in the production include folder.  They should 
probably be in the benchmark folder.

If possible, follow the style and conventions of the existing tests.  When you 
can't follow the style and convention of the existing tests, try to make it 
obvious (or leave a comment) as to why the new test is special.

For example, one way to follow the existing conventions would be to have a test 
that looks like this...

BENCHMARK_CAPTURE(BM_Sort, **qsort_worst_uint32**, 
**getQSortKiller**)->Arg(TestNumInputs);

That test would be called qsort_worst_uint32.  You would need to author the 
sequence generator so that it had a signature like this...
template  std::vector getQSortKiller(size_t N)

On an encouraging note, I don't see anything wrong with the production code.  
I'm optimistic about getting this in once we iron out the test issues.


https://reviews.llvm.org/D36423



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


[PATCH] D36712: Emit section information for extern variables

2017-08-15 Thread Simon Dardis via Phabricator via cfe-commits
sdardis requested changes to this revision.
sdardis added a reviewer: kparzysz.
sdardis added a comment.
This revision now requires changes to proceed.

+kparzysz as Hexagon also makes use of the small data section.




Comment at: docs/LangRef.rst:629
+corresponding to the LLVM module, section information specified in the 
+declaration is retained in LLVM IR to enable OpenCL processes.
+

efriedma wrote:
> This doesn't really explain the part that matters. For LangRef, it doesn't 
> matter how the frontend decides to generate declarations (and it might be 
> different for frontends other than clang).  And OpenCL might motivate this, 
> but it has nothing to do with the semantics.
> 
> The key question here is what it actually means.  Is it a promise the that a 
> definition will exist for the given symbol in the given section?  If so, what 
> happens if the symbol is actually in a different section?  ("Undefined 
> behavior" is probably an acceptable answer, but it needs to be stated 
> explicitly.)
> to enable OpenCL processes.

for targets which make use of this section information. 

I would also work in a sentence that says that attaching section information to 
a external declaration is an assertion or promise that the definition is 
located in that section. If the definition is actually located in a different 
section the behaviour is undefined.

I'm favouring "undefined behaviour" in the error case as behaviour is so target 
and environment specific.


https://reviews.llvm.org/D36712



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


[PATCH] D36737: [analyzer] Store design discussions in docs/analyzer for future use.

2017-08-15 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Good idea!

I think some of your extremely helpful responses from the mailing list would 
worth archiving in a form of documentation as well.
Also, as far as I can recall, you are also maintaining a pdf which is a very 
good reference. In some form, I would love to see that information upstream too.


https://reviews.llvm.org/D36737



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


[PATCH] D36737: [analyzer] Store design discussions in docs/analyzer for future use.

2017-08-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.

Because i tend to raise important design questions in weird places like tiny 
phabricator patches, we had a thought that it's better to archive them in 
`docs/analyzer` for future reference. We should be able to pick them up 
whenever time comes to solve these problems.

I initialize a new folder in `docs/analyzer` for this sort of stuff with the 
discussion in https://reviews.llvm.org/D35216; we also have a few more 
discussions that might look good in such archive.


https://reviews.llvm.org/D36737

Files:
  docs/analyzer/DesignDiscussions/InitializerLists.txt

Index: docs/analyzer/DesignDiscussions/InitializerLists.txt
===
--- /dev/null
+++ docs/analyzer/DesignDiscussions/InitializerLists.txt
@@ -0,0 +1,325 @@
+This discussion took place in https://reviews.llvm.org/D35216
+"Escape symbols when creating std::initializer_list".
+
+It touches problems of modelling C++ standard library constructs in general,
+including modelling implementation-defined fields within C++ standard library
+objects, in particular constructing objects into pointers held by such fields,
+and separation of responsibilities between analyzer's core and checkers.
+
+
+
+== Artem: ==
+
+I've seen a few false positives that appear because we construct C++11
+std::initializer_list objects with brace initializers, and such construction is
+not properly modeled. For instance, if a new object is constructed on the heap
+only to be put into a brace-initialized STL container, the object is reported to
+be leaked.
+
+Approach (0): This can be trivially fixed by this patch, which causes pointers
+passed into initializer list expressions to immediately escape.
+
+This fix is overly conservative though. So i did a bit of investigation as to
+how model std::initializer_list better.
+
+According to the standard, std::initializer_list is an object that has
+methods begin(), end(), and size(), where begin() returns a pointer to continous
+array of size() objects of type T, and end() is equal to begin() plus size().
+The standard does hint that it should be possible to implement
+std::initializer_list as a pair of pointers, or as a pointer and a size
+integer, however specific fields that the object would contain are an
+implementation detail.
+
+Ideally, we should be able to model the initializer list's methods precisely.
+Or, at least, it should be possible to explain to the analyzer that the list
+somehow "takes hold" of the values put into it. Initializer lists can also be
+copied, which is a separate story that i'm not trying to address here.
+
+The obvious approach to modeling std::initializer_list in a checker would be to
+construct a SymbolMetadata for the memory region of the initializer list object,
+which would be of type T* and represent begin(), so we'd trivially model begin()
+as a function that returns this symbol. The array pointed to by that symbol
+would be bindLoc()ed to contain the list's contents (probably as a CompoundVal
+to produce less bindings in the store). Extent of this array would represent
+size() and would be equal to the length of the list as written.
+
+So this sounds good, however apparently it does nothing to address our false
+positives: when the list escapes, our RegionStoreManager is not magically
+guessing that the metadata symbol attached to it, together with its contents,
+should also escape. In fact, it's impossible to trigger a pointer escape from
+within the checker.
+
+Approach (1): If only we enabled ProgramState::bindLoc(..., notifyChanges=true)
+to cause pointer escapes (not only region changes) (which sounds like the right
+thing to do anyway) such checker would be able to solve the false positives by
+triggering escapes when binding list elements to the list. However, it'd be as
+conservative as the current patch's solution. Ideally, we do not want escapes to
+happen so early. Instead, we'd prefer them to be delayed until the list itself
+escapes.
+
+So i believe that escaping metadata symbols whenever their base regions escape
+would be the right thing to do. Currently we didn't think about that because we
+had neither pointer-type metadatas nor non-pointer escapes.
+
+Approach (2): We could teach the Store to scan itself for bindings to
+metadata-symbolic-based regions during scanReachableSymbols() whenever a region
+turns out to be reachable. This requires no work on checker side, but it sounds
+performance-heavy.
+
+Approach (3): We could let checkers maintain the set of active metadata symbols
+in the program state (ideally somewhere in the Store, which sounds weird but
+causes the smallest amount of layering violations), so that the core knew what
+to escape. This puts a stress on the checkers, but with a smart data map it
+wouldn't be a problem.
+
+Approach (4): We could allow checkers to trigger pointer escapes in 

[PATCH] D35216: [analyzer] Escape symbols when creating std::initializer_list.

2017-08-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 56.
NoQ added a comment.

Actually update the diff.


https://reviews.llvm.org/D35216

Files:
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Analysis/initializer.cpp

Index: test/Analysis/initializer.cpp
===
--- test/Analysis/initializer.cpp
+++ test/Analysis/initializer.cpp
@@ -1,7 +1,9 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config c++-inlining=constructors -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDeleteLeaks,debug.ExprInspection -analyzer-config c++-inlining=constructors -std=c++11 -verify %s
 
 void clang_analyzer_eval(bool);
 
+#include "Inputs/system-header-simulator-cxx.h"
+
 class A {
   int x;
 public:
@@ -204,3 +206,13 @@
const char()[2];
 };
 }
+
+namespace CXX_initializer_lists {
+struct C {
+  C(std::initializer_list list);
+};
+void foo() {
+  int *x = new int;
+  C c{x}; // no-warning
+}
+}
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -806,6 +806,21 @@
   }
 }
 
+namespace {
+class CollectReachableSymbolsCallback final : public SymbolVisitor {
+  InvalidatedSymbols Symbols;
+
+public:
+  explicit CollectReachableSymbolsCallback(ProgramStateRef State) {}
+  const InvalidatedSymbols () const { return Symbols; }
+
+  bool VisitSymbol(SymbolRef Sym) override {
+Symbols.insert(Sym);
+return true;
+  }
+};
+} // end anonymous namespace
+
 void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
ExplodedNodeSet ) {
   PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(),
@@ -1082,8 +1097,28 @@
 SVal result = svalBuilder.conjureSymbolVal(nullptr, Ex, LCtx,
resultType,
currBldrCtx->blockCount());
-ProgramStateRef state = N->getState()->BindExpr(Ex, LCtx, result);
-Bldr2.generateNode(S, N, state);
+ProgramStateRef State = N->getState()->BindExpr(Ex, LCtx, result);
+
+// FIXME: Remove this first check when we begin modelling these
+// expression classes separately.
+if (!isa(Ex))
+  for (auto Child : Ex->children()) {
+if (!Child)
+  continue;
+
+SVal Val = State->getSVal(Child, LCtx);
+
+CollectReachableSymbolsCallback Scanner =
+State->scanReachableSymbols(
+Val);
+const InvalidatedSymbols  = Scanner.getSymbols();
+
+State = getCheckerManager().runCheckersForPointerEscape(
+State, EscapedSymbols,
+/*CallEvent*/ nullptr, PSK_EscapeOther, nullptr);
+  }
+
+Bldr2.generateNode(S, N, State);
   }
 
   getCheckerManager().runCheckersForPostStmt(Dst, Tmp, S, *this);
@@ -2217,21 +2252,6 @@
   getCheckerManager().runCheckersForPostStmt(Dst, AfterInvalidateSet, AE, *this);
 }
 
-namespace {
-class CollectReachableSymbolsCallback final : public SymbolVisitor {
-  InvalidatedSymbols Symbols;
-
-public:
-  CollectReachableSymbolsCallback(ProgramStateRef State) {}
-  const InvalidatedSymbols () const { return Symbols; }
-
-  bool VisitSymbol(SymbolRef Sym) override {
-Symbols.insert(Sym);
-return true;
-  }
-};
-} // end anonymous namespace
-
 // A value escapes in three possible cases:
 // (1) We are binding to something that is not a memory region.
 // (2) We are binding to a MemrRegion that does not have stack storage.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35216: [analyzer] Escape symbols when creating std::initializer_list.

2017-08-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked an inline comment as done.
NoQ added a comment.

We've discussed it in person with Devin, and he provided more points to think 
about:

- If the initializer list consists of non-POD data, constructors of list's 
objects need to take the sub-region of the list's region as `this`-region In 
the current (v2) version of this patch, these objects are constructed elsewhere 
and then trivial-copied into the list's metadata pointer region, which may be 
incorrect. This is our overall problem with C++ constructors, which manifests 
in this case as well. Additionally, objects would need to be constructed in the 
analyzer's core, which would not be able to predict that it needs to take a 
checker-specific region as `this`-region, which makes it harder, though it 
might be mitigated by sharing the checker state traits.

- Because "ghost variables" are not material to the user, we need to somehow 
make super sure that they don't make it into the diagnostic messages.

So, because this needs further digging into overall C++ support and rises too 
many questions, i'm delaying a better approach to this problem and will fall 
back to the original trivial patch.


https://reviews.llvm.org/D35216



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


[PATCH] D36715: [clang] minor cleanup in clang/tooling/refactoring

2017-08-15 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D36715



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


r310916 - [Sema] Silence -Wobjc-missing-property-synthesis for unavailable properties

2017-08-15 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Aug 15 05:40:01 2017
New Revision: 310916

URL: http://llvm.org/viewvc/llvm-project?rev=310916=rev
Log:
[Sema] Silence -Wobjc-missing-property-synthesis for unavailable properties

rdar://30296911

Modified:
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/test/SemaObjC/default-synthesize-1.m

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=310916=310915=310916=diff
==
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Tue Aug 15 05:40:01 2017
@@ -1895,7 +1895,7 @@ void Sema::DefaultSynthesizeProperties(S
 /* property = */ Prop->getIdentifier(),
 /* ivar = */ 
Prop->getDefaultSynthIvarName(Context),
 Prop->getLocation(), Prop->getQueryKind()));
-if (PIDecl) {
+if (PIDecl && !Prop->isUnavailable()) {
   Diag(Prop->getLocation(), diag::warn_missing_explicit_synthesis);
   Diag(IMPDecl->getLocation(), diag::note_while_in_implementation);
 }

Modified: cfe/trunk/test/SemaObjC/default-synthesize-1.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/default-synthesize-1.m?rev=310916=310915=310916=diff
==
--- cfe/trunk/test/SemaObjC/default-synthesize-1.m (original)
+++ cfe/trunk/test/SemaObjC/default-synthesize-1.m Tue Aug 15 05:40:01 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wobjc-missing-property-synthesis -verify 
-Wno-objc-root-class %s
+// RUN: %clang_cc1 -fsyntax-only -Wobjc-missing-property-synthesis -verify 
-Wno-objc-root-class -triple=x86_64-apple-macos10.10 %s
 // rdar://11295716
 
 @interface NSObject 
@@ -141,3 +141,17 @@
 return _description; // expected-error {{use of undeclared identifier 
'_description'}}
 }
 @end
+
+@interface DontWarnOnUnavailable
+
+// No warning expected:
+@property (nonatomic, readonly) int un1 __attribute__((unavailable));
+@property (readwrite) int un2 __attribute__((availability(macos, 
unavailable)));
+
+@property (readwrite) int un3 __attribute__((availability(ios, unavailable))); 
// expected-warning {{auto property synthesis is synthesizing property not 
explicitly synthesized}}
+
+@end
+
+@implementation DontWarnOnUnavailable // expected-note {{detected while 
default synthesizing properties in class implementation}}
+
+@end


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


[PATCH] D24461: CodeGen: Cast llvm.flt.rounds result to match __builtin_flt_rounds

2017-08-15 Thread Edward Jones via Phabricator via cfe-commits
edward-jones added a comment.

No, this doesn't seem to have been committed yet.


https://reviews.llvm.org/D24461



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


[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-15 Thread Mark Zeren via Phabricator via cfe-commits
mzeren-vmw added inline comments.



Comment at: unittests/Format/FormatTest.cpp:2281
 
 TEST_F(FormatTest, LayoutMacroDefinitionsStatementsSpanningBlocks) {
   verifyFormat("#define A \\\n"

mzeren-vmw wrote:
> Experimenting with the patch locally I found that comment indentation is 
> broken in some cases. Please add tests that cover comments. For example:
> 
> comment indented at code level as expected:
>   void f() {
>   #if 0
> // Comment
> code();
>   #  define FOO 0
>   #endif
>   }
> comment not indented at code level when there's a guard:
>   #ifndef _SOMEFILE_H
>   #define _SOMEFILE_H
>   void f() {
>   #if 0
>   // Comment
> code();
>   #  define FOO 0
>   #endif
>   }
>   #endif
> 
> The `#define FOO 0` is required to trigger this behavior.
Erik spent some time investigating issues with comment indentation. A couple of 
insights so far:

a) We need tests for wrapped macros (with trailing \ continuations). These need 
to include embedded comments.

b) It would be most natural to align comments with the following non-comment 
line. So a comment may be indented at "preprocessor level" or "code level". If 
indented at preprocessor level we have to handle the extra space introduced by 
the leading hash. This may require an extra bit per line to indicate whether 
the "aligned-to" line is preprocessor or code.


https://reviews.llvm.org/D35955



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


[PATCH] D36670: misc-misplaced-widening-cast: fix assertion

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



Comment at: test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp:63
+  enum Type {};
+  static char *m_fn1() { char p = (Type)( - m_fn1()); }
+};

Isn't this testcase a bit overcomplicated to demonstrate the issue?


Repository:
  rL LLVM

https://reviews.llvm.org/D36670



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


[PATCH] D36670: misc-misplaced-widening-cast: fix assertion

2017-08-15 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rL LLVM

https://reviews.llvm.org/D36670



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


[PATCH] D36731: [ARM][AArch64] Cortex-A75 and Cortex-A55 support

2017-08-15 Thread Sam Parker via Phabricator via cfe-commits
samparker created this revision.
Herald added subscribers: kristof.beyls, javed.absar, rengolin, aemerson.

This patch introduces support for Cortex-A75 and Cortex-A55, Arm's latest 
big.LITTLE A-class cores. They implement the ARMv8.2-A architecture, including 
the cryptography and RAS extensions, plus the optional dot product extension. 
They also implement the RCpc AArch64 extension from ARMv8.3-A.

  

Cortex-A75:
https://developer.arm.com/products/processors/cortex-a/cortex-a75

  

Cortex-A55:
https://developer.arm.com/products/processors/cortex-a/cortex-a55


https://reviews.llvm.org/D36731

Files:
  lib/Driver/ToolChains/Arch/ARM.cpp
  test/Driver/aarch64-cpus.c
  test/Driver/aarch64-dotprod.c
  test/Driver/aarch64-ras.c
  test/Driver/aarch64-rcpc.s
  test/Driver/arm-cortex-cpus.c
  test/Driver/arm-dotprod.c
  test/Driver/arm-ras.c

Index: test/Driver/arm-ras.c
===
--- test/Driver/arm-ras.c
+++ test/Driver/arm-ras.c
@@ -1,5 +1,7 @@
 // RUN: %clang -target arm-none-none-eabi -march=armv8a+ras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-RAS %s
 // RUN: %clang -target arm-none-none-eabi -mcpu=generic+ras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-RAS %s
+// RUN: %clang -target arm-none-none-eabi -mcpu=cortex-a75 -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-RAS %s
+// RUN: %clang -target arm-none-none-eabi -mcpu=cortex-a55 -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-RAS %s
 // CHECK-RAS: "-target-feature" "+ras"
 
 // RUN: %clang -target arm-none-none-eabi -march=armv8a+noras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-NORAS %s
Index: test/Driver/arm-dotprod.c
===
--- /dev/null
+++ test/Driver/arm-dotprod.c
@@ -0,0 +1,11 @@
+// RUN: %clang -### -target arm %s 2>&1 | FileCheck %s --check-prefix=CHECK-NONE
+// RUN: %clang -### -target arm -march=armv8.1a %s 2>&1 | FileCheck %s --check-prefix=CHECK-NONE
+// RUN: %clang -### -target arm -march=armv8.2a %s 2>&1 | FileCheck %s --check-prefix=CHECK-NONE
+// RUN: %clang -### -target arm -march=armv8.3a %s 2>&1 | FileCheck %s --check-prefix=CHECK-NONE
+// CHECK-NONE-NOT: "-target-feature" "+dotprod"
+
+// RUN: %clang -### -target arm -march=armv8.2a+dotprod %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target arm -march=armv8.3a+dotprod %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target arm -mcpu=cortex-a75 %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target arm -mcpu=cortex-a55 %s 2>&1 | FileCheck %s
+// CHECK: "+dotprod"
Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -258,34 +258,34 @@
 // RUN: %clang -target armv8.2a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V82A %s
 // RUN: %clang -target arm -march=armv8.2a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V82A %s
 // RUN: %clang -target arm -mlittle-endian -march=armv8.2-a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V82A %s
-// CHECK-V82A: "-cc1"{{.*}} "-triple" "armv8.2{{.*}}" "-target-cpu" "generic"
+// CHECK-V82A: "-cc1"{{.*}} "-triple" "armv8.2{{.*}}" "-target-cpu" "cortex-a55"
 
 // RUN: %clang -target armebv8.2a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V82A %s
 // RUN: %clang -target armv8.2a -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V82A %s
 // RUN: %clang -target armeb -march=armebv8.2a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V82A %s
 // RUN: %clang -target armeb -march=armebv8.2-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V82A %s
 // RUN: %clang -target arm -march=armebv8.2a -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V82A %s
 // RUN: %clang -target arm -march=armebv8.2-a -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V82A %s
-// CHECK-BE-V82A: "-cc1"{{.*}} "-triple" "armebv8.2{{.*}}" "-target-cpu" "generic"
+// CHECK-BE-V82A: "-cc1"{{.*}} "-triple" "armebv8.2{{.*}}" "-target-cpu" "cortex-a55"
 
 // RUN: %clang -target armv8.2a -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V82A-THUMB %s
 // RUN: %clang -target arm -march=armv8.2a -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V82A-THUMB %s
 // RUN: %clang -target arm -march=armv8.2-a -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V82A-THUMB %s
 // RUN: %clang -target armv8.2a -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V82A-THUMB %s
 // RUN: %clang -target arm -march=armv8.2a -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V82A-THUMB %s
 // RUN: %clang -target arm -march=armv8.2-a -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V82A-THUMB %s
-// CHECK-V82A-THUMB: "-cc1"{{.*}} "-triple" "thumbv8.2a-{{.*}}" "-target-cpu" "generic"
+// CHECK-V82A-THUMB: "-cc1"{{.*}} "-triple" "thumbv8.2a-{{.*}}" "-target-cpu" 

  1   2   >