[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 88662.
pirama added a comment.

Changed the name of the utility that builds the arch-specific directory.


https://reviews.llvm.org/D30015

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/Tools.cpp
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i686/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/.keep
  test/Driver/openmp-arch-dir.c

Index: test/Driver/openmp-arch-dir.c
===
--- /dev/null
+++ test/Driver/openmp-arch-dir.c
@@ -0,0 +1,57 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the search path.  This allows multilib toolchains
+// to package libomp.so for multiple architectures.
+
+// Directory resource_dir_with_arch_subdir is setup only for Linux
+// REQUIRES: linux
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// Check correctness when -fopenmp is omitted
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR \
+// RUN:   --check-prefix=CHECK-NO-LOMP %s
+//
+// CHECK-ARCHDIR: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
+// CHECK-LOMP: -lomp
+// CHECK-NO-LOMP-NOT: -lomp
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3260,6 +3260,12 @@
 options::OPT_fno_openmp, false))
 return;
 
+  // Add /lib// to the linker search path if it
+  // exists.
+  std::string CandidateLibPath = TC.getArchSpecificLibPath();
+  if (llvm::sys::fs::is_directory(CandidateLibPath))
+CmdArgs.push_back(Args.MakeArgString("-L" + CandidateLibPath));
+
   switch (TC.getDriver().getOpenMPRuntime(Args)) {
   case Driver::OMPRT_OMP:
 CmdArgs.push_back("-lomp");
@@ -10316,6 +10322,12 @@
 // FIXME: Does this really make sense for all GNU toolchains?
 WantPthread = true;
 
+// Add /lib// to the linker search path if it
+// exists.
+std::string CandidateLibPath = ToolChain.getArchSpecificLibPath();
+if (llvm::sys::fs::is_directory(CandidateLibPath))
+  CmdArgs.push_back(Args.MakeArgString("-L" + CandidateLibPath));
+
 // Also link the particular OpenMP runtimes.
 switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
 case Driver::OMPRT_OMP:
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -320,6 +320,14 @@
   return Args.MakeArgString(getCompilerRT(Args, Component, Shared));
 }
 
+const std::string ToolChain::getArchSpecificLibPath() const {
+  SmallString<128> Path(getDriver().ResourceDir);
+  StringRef OSLibName = getTriple().isOSFreeBSD() ? "freebsd" : getOS();
+  llvm::sys::pa

[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: lib/Driver/ToolChain.cpp:327
+  llvm::sys::path::append(Path, "lib", OSLibName,
+  getArchName());
+  return Path.str();

I would suggest using arch type, to avoid e.g. i386/i486/i586 mess. It's really 
hard to clean it up afterwards, see D26796.


https://reviews.llvm.org/D30015



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


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: lib/Driver/Tools.cpp:3267
+  if (llvm::sys::fs::is_directory(CandidateLibPath))
+CmdArgs.push_back(Args.MakeArgString("-L" + CandidateLibPath));
+

Don't you also need rpath for it? Or is this purely for static runtime?


https://reviews.llvm.org/D30015



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


[PATCH] D30000: Fix for pr31836 - pp_nonportable_path on absolute paths: broken delimiters

2017-02-16 Thread Axel Naumann via Phabricator via cfe-commits
karies added inline comments.



Comment at: lib/Lex/PPDirectives.cpp:1983
+  isLeadingSeparator = false;
+else
+  Path.append(Component);

eric_niebler wrote:
> What happens on Windows for an absolute path like "C:/hello/world.h", I 
> wonder? Does this correctly generate the fixit? @karies?
I also cannot reproduce this diag on Windows, likely because NTFS and FAT are 
case indifferent (not preserving like MacOS) so the file system cannot reply 
with "this is how *I* would have spelled the file name".


https://reviews.llvm.org/D3



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


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 88663.
pirama added a comment.

Use getArchTypeName() instead of getArchName().


https://reviews.llvm.org/D30015

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/Tools.cpp
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/.keep
  test/Driver/openmp-arch-dir.c

Index: test/Driver/openmp-arch-dir.c
===
--- /dev/null
+++ test/Driver/openmp-arch-dir.c
@@ -0,0 +1,57 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the search path.  This allows multilib toolchains
+// to package libomp.so for multiple architectures.
+
+// Directory resource_dir_with_arch_subdir is setup only for Linux
+// REQUIRES: linux
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// Check correctness when -fopenmp is omitted
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR \
+// RUN:   --check-prefix=CHECK-NO-LOMP %s
+//
+// CHECK-ARCHDIR: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
+// CHECK-LOMP: -lomp
+// CHECK-NO-LOMP-NOT: -lomp
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3260,6 +3260,12 @@
 options::OPT_fno_openmp, false))
 return;
 
+  // Add /lib// to the linker search path if it
+  // exists.
+  std::string CandidateLibPath = TC.getArchSpecificLibPath();
+  if (llvm::sys::fs::is_directory(CandidateLibPath))
+CmdArgs.push_back(Args.MakeArgString("-L" + CandidateLibPath));
+
   switch (TC.getDriver().getOpenMPRuntime(Args)) {
   case Driver::OMPRT_OMP:
 CmdArgs.push_back("-lomp");
@@ -10316,6 +10322,12 @@
 // FIXME: Does this really make sense for all GNU toolchains?
 WantPthread = true;
 
+// Add /lib// to the linker search path if it
+// exists.
+std::string CandidateLibPath = ToolChain.getArchSpecificLibPath();
+if (llvm::sys::fs::is_directory(CandidateLibPath))
+  CmdArgs.push_back(Args.MakeArgString("-L" + CandidateLibPath));
+
 // Also link the particular OpenMP runtimes.
 switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
 case Driver::OMPRT_OMP:
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -320,6 +320,14 @@
   return Args.MakeArgString(getCompilerRT(Args, Component, Shared));
 }
 
+const std::string ToolChain::getArchSpecificLibPath() const {
+  SmallString<128> Path(getDriver().ResourceDir);
+  StringRef OSLibName = getTriple().isOSFreeBSD() ? "freebsd" : getOS();
+  llvm::sys::path::append(Path, "lib", O

Re: r294954 - Fix r291495 -- Normalize LLVM_CMAKE_PATH in clang standalone build.

2017-02-16 Thread NAKAMURA Takumi via cfe-commits
Michał,

It'd make sense to use file(TO_CMAKE_PATH). I forgot it.
I think get_file_component() satisfies in this case. Do you think to use
file(TO_CMAKE_PATH) anyways?
I'll wait for you as an opinion before proposing this fix to release_40.
The bug is still in release_40.

I don't think we could twiddle llvm-config stuff in future. FYI, I explain
its history.

- When autoconf was alive, I tweaked it to let cmake configure against
installed tree generated by autoconf.
- Brad King (@kitware) proposed a mechanism for autoconf to provide cmake
information in llvm.
- Autoconf was killed.

In the ecosystem of cmake, we may go w/o llvm-config but find_package() by
cmake's way.
Then, I suggest to rip out llvm-config here.

Why I introduced cache variables for items supplied by llvm-config;
I thought they are configurable w/o autoconf to specify their variables
manually.

BTW, do you think if llvm-config had an option like "--emit-cmake-tmpl"
to help creating cmake project?

On Tue, Feb 14, 2017 at 12:45 AM Michał Górny  wrote:

> W dniu 13.02.2017, pon o godzinie 14∶59 +, użytkownik NAKAMURA
> Takumi via cfe-commits napisał:
> > Author: chapuni
> > Date: Mon Feb 13 08:59:53 2017
> > New Revision: 294954
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=294954&view=rev
> > Log:
> > Fix r291495 -- Normalize LLVM_CMAKE_PATH in clang standalone build.
> >
> > CMake handles paths with slashes. It caused cmake/install failure on
> msbuild.exe.
> >
> > Note, Other llvm-config-oriented variables have been normalized since
> they are stored in the cache attributed with PATH.
> >
> > Modified:
> > cfe/trunk/CMakeLists.txt
> >
> > Modified: cfe/trunk/CMakeLists.txt
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=294954&r1=294953&r2=294954&view=diff
> >
> ==
> > --- cfe/trunk/CMakeLists.txt (original)
> > +++ cfe/trunk/CMakeLists.txt Mon Feb 13 08:59:53 2017
> > @@ -42,7 +42,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
> >list(GET CONFIG_OUTPUT 3 INCLUDE_DIR)
> >list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT)
> >list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR)
> > -  list(GET CONFIG_OUTPUT 6 LLVM_CMAKE_PATH)
> > +  list(GET CONFIG_OUTPUT 6 LLVM_CONFIG_CMAKE_PATH)
> >
> >if(NOT MSVC_IDE)
> >  set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
> > @@ -57,6 +57,10 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
> >set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build
> tree")
> >set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source
> tree")
> >
> > +  # Normalize LLVM_CMAKE_PATH. --cmakedir might contain backslashes.
> > +  # CMake assumes slashes as PATH.
> > +  get_filename_component(LLVM_CMAKE_PATH ${LLVM_CONFIG_CMAKE_PATH}
> ABSOLUTE)
>
> Are you sure this is the best way of doing it? I'm not a Windows expert
> but I've seen others using file(TO_CMAKE_PATH ...) for what I suppose
> was the same goal.
>
> > +
> >find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
> >  NO_DEFAULT_PATH)
> >
> >
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
> --
> Best regards,
> Michał Górny
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a subscriber: openmp-commits.
pirama marked an inline comment as done.
pirama added inline comments.



Comment at: lib/Driver/Tools.cpp:3267
+  if (llvm::sys::fs::is_directory(CandidateLibPath))
+CmdArgs.push_back(Args.MakeArgString("-L" + CandidateLibPath));
+

mgorny wrote:
> Don't you also need rpath for it? Or is this purely for static runtime?
I am doing this for a cross-compiling toolchain (Android NDK) where the actual 
rpath is not valid at runtime.  The runtime is packaged with the application 
and made available to the loader behind the scenes.

That said, I don't think providing an rpath doesn't hurt.  I'll wait for input 
from @cbergstrom and OpenMP folks to see if this'd be useful.


https://reviews.llvm.org/D30015



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


[PATCH] D29922: [OpenMP] Prepare Sema for initial implementation for pragma 'distribute parallel for'

2017-02-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rL LLVM

https://reviews.llvm.org/D29922



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


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

I still think this should not be done for OpenMP only and hence move out of 
`addOpenMPRuntime`.

(Why the heck are there //two// places to add `-lomp`?!? I'll clean that up 
later...)


https://reviews.llvm.org/D30015



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


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

I am fine to do this more generally, but not sure of the scope.  Should this be 
always added or only if a runtime (sanitizer or openmp or xray) is requested?


https://reviews.llvm.org/D30015



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


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

In https://reviews.llvm.org/D30015#678294, @pirama wrote:

> I am fine to do this more generally, but not sure of the scope.  Should this 
> be always added or only if a runtime (sanitizer or openmp or xray) is 
> requested?


I think always. From my point of view, this would be the right solution for my 
https://reviews.llvm.org/D26244.


https://reviews.llvm.org/D30015



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


[PATCH] D30032: Process attributes 'ifunc' and 'alias' when checking for redefinition

2017-02-16 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff created this revision.

These attributes effectively turns a non-defining declaration into a
definition, so the case when the declaration already has a body must
be diagnosed properly.


https://reviews.llvm.org/D30032

Files:
  lib/Sema/SemaDecl.cpp
  test/Sema/alias-redefinition.c
  test/Sema/attr-ifunc.c


Index: test/Sema/attr-ifunc.c
===
--- test/Sema/attr-ifunc.c
+++ test/Sema/attr-ifunc.c
@@ -39,5 +39,9 @@
 //expected-error@-1 {{definition with same mangled name as another definition}}
 void* f1_ifunc() { return 0; }
 
+void* f6_ifunc(int i);
+void __attribute__((ifunc("f6_ifunc"))) f6() {}
+//expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
+
 #endif
 #endif
Index: test/Sema/alias-redefinition.c
===
--- test/Sema/alias-redefinition.c
+++ test/Sema/alias-redefinition.c
@@ -19,9 +19,8 @@
 void fun4(void) __attribute((alias("f4")));
 void fun4(void);
 
-// FIXME: We should produce a special case error for this.
 void f5() {}
-void __attribute((alias("f5"))) fun5(void) {} // expected-error {{redefinition 
of 'fun5'}} // expected-note {{previous definition}}
+void __attribute((alias("f5"))) fun5(void) {} // expected-error {{definition 
'fun5' cannot also be an alias}}
 
 int var1 __attribute((alias("v1"))); // expected-error {{definition 'var1' 
cannot also be an alias}}
 static int var2 __attribute((alias("v2"))) = 2; // expected-error {{definition 
'var2' cannot also be an alias}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -11790,6 +11790,18 @@
   else
 FD = cast(D);
 
+  // Check for defining attributes before the check for redefinition.
+  if (const auto *Attr = FD->getAttr()) {
+Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 0;
+FD->dropAttr();
+FD->setInvalidDecl();
+  }
+  if (const auto *Attr = FD->getAttr()) {
+Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 1;
+FD->dropAttr();
+FD->setInvalidDecl();
+  }
+
   // See if this is a redefinition.
   if (!FD->isLateTemplateParsed()) {
 CheckForFunctionRedefinition(FD, nullptr, SkipBody);


Index: test/Sema/attr-ifunc.c
===
--- test/Sema/attr-ifunc.c
+++ test/Sema/attr-ifunc.c
@@ -39,5 +39,9 @@
 //expected-error@-1 {{definition with same mangled name as another definition}}
 void* f1_ifunc() { return 0; }
 
+void* f6_ifunc(int i);
+void __attribute__((ifunc("f6_ifunc"))) f6() {}
+//expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
+
 #endif
 #endif
Index: test/Sema/alias-redefinition.c
===
--- test/Sema/alias-redefinition.c
+++ test/Sema/alias-redefinition.c
@@ -19,9 +19,8 @@
 void fun4(void) __attribute((alias("f4")));
 void fun4(void);
 
-// FIXME: We should produce a special case error for this.
 void f5() {}
-void __attribute((alias("f5"))) fun5(void) {} // expected-error {{redefinition of 'fun5'}} // expected-note {{previous definition}}
+void __attribute((alias("f5"))) fun5(void) {} // expected-error {{definition 'fun5' cannot also be an alias}}
 
 int var1 __attribute((alias("v1"))); // expected-error {{definition 'var1' cannot also be an alias}}
 static int var2 __attribute((alias("v2"))) = 2; // expected-error {{definition 'var2' cannot also be an alias}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -11790,6 +11790,18 @@
   else
 FD = cast(D);
 
+  // Check for defining attributes before the check for redefinition.
+  if (const auto *Attr = FD->getAttr()) {
+Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 0;
+FD->dropAttr();
+FD->setInvalidDecl();
+  }
+  if (const auto *Attr = FD->getAttr()) {
+Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 1;
+FD->dropAttr();
+FD->setInvalidDecl();
+  }
+
   // See if this is a redefinition.
   if (!FD->isLateTemplateParsed()) {
 CheckForFunctionRedefinition(FD, nullptr, SkipBody);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29755: Cache FileID when translating diagnostics in PCH files

2017-02-16 Thread Erik Verbruggen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295301: Cache FileID when translating diagnostics in PCH 
files (authored by erikjv).

Changed prior to commit:
  https://reviews.llvm.org/D29755?vs=88366&id=88701#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29755

Files:
  cfe/trunk/lib/Frontend/ASTUnit.cpp


Index: cfe/trunk/lib/Frontend/ASTUnit.cpp
===
--- cfe/trunk/lib/Frontend/ASTUnit.cpp
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp
@@ -2541,14 +2541,19 @@
 
   SmallVector Result;
   Result.reserve(Diags.size());
+  const FileEntry *PreviousFE = nullptr;
+  FileID FID;
   for (const StandaloneDiagnostic &SD : Diags) {
 // Rebuild the StoredDiagnostic.
 if (SD.Filename.empty())
   continue;
 const FileEntry *FE = FileMgr.getFile(SD.Filename);
 if (!FE)
   continue;
-FileID FID = SrcMgr.translateFile(FE);
+if (FE != PreviousFE) {
+  FID = SrcMgr.translateFile(FE);
+  PreviousFE = FE;
+}
 SourceLocation FileLoc = SrcMgr.getLocForStartOfFile(FID);
 if (FileLoc.isInvalid())
   continue;


Index: cfe/trunk/lib/Frontend/ASTUnit.cpp
===
--- cfe/trunk/lib/Frontend/ASTUnit.cpp
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp
@@ -2541,14 +2541,19 @@
 
   SmallVector Result;
   Result.reserve(Diags.size());
+  const FileEntry *PreviousFE = nullptr;
+  FileID FID;
   for (const StandaloneDiagnostic &SD : Diags) {
 // Rebuild the StoredDiagnostic.
 if (SD.Filename.empty())
   continue;
 const FileEntry *FE = FileMgr.getFile(SD.Filename);
 if (!FE)
   continue;
-FileID FID = SrcMgr.translateFile(FE);
+if (FE != PreviousFE) {
+  FID = SrcMgr.translateFile(FE);
+  PreviousFE = FE;
+}
 SourceLocation FileLoc = SrcMgr.getLocForStartOfFile(FID);
 if (FileLoc.isInvalid())
   continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r295301 - Cache FileID when translating diagnostics in PCH files

2017-02-16 Thread Erik Verbruggen via cfe-commits
Author: erikjv
Date: Thu Feb 16 03:49:30 2017
New Revision: 295301

URL: http://llvm.org/viewvc/llvm-project?rev=295301&view=rev
Log:
Cache FileID when translating diagnostics in PCH files

Modules/preambles/PCH files can contain diagnostics, which, when used,
are added to the current ASTUnit. For that to work, they are translated
to use the current FileManager's FileIDs. When the entry is not the
main file, all local source locations will be checked by a linear
search. Now this is a problem, when there are lots of diagnostics (say,
25000) and lots of local source locations (say, 44), and end up
taking seconds when using such a preamble.

The fix is to cache the last FileID, because many subsequent diagnostics
refer to the same file. This reduces the time spent in
ASTUnit::TranslateStoredDiagnostics from seconds to a few milliseconds
for files with many slocs/diagnostics.

This fixes PR31353.
Differential Revision: https://reviews.llvm.org/D29755

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

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=295301&r1=295300&r2=295301&view=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Thu Feb 16 03:49:30 2017
@@ -2541,6 +2541,8 @@ void ASTUnit::TranslateStoredDiagnostics
 
   SmallVector Result;
   Result.reserve(Diags.size());
+  const FileEntry *PreviousFE = nullptr;
+  FileID FID;
   for (const StandaloneDiagnostic &SD : Diags) {
 // Rebuild the StoredDiagnostic.
 if (SD.Filename.empty())
@@ -2548,7 +2550,10 @@ void ASTUnit::TranslateStoredDiagnostics
 const FileEntry *FE = FileMgr.getFile(SD.Filename);
 if (!FE)
   continue;
-FileID FID = SrcMgr.translateFile(FE);
+if (FE != PreviousFE) {
+  FID = SrcMgr.translateFile(FE);
+  PreviousFE = FE;
+}
 SourceLocation FileLoc = SrcMgr.getLocForStartOfFile(FID);
 if (FileLoc.isInvalid())
   continue;


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


[PATCH] D29990: [clangd] Implement format on type

2017-02-16 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 88703.
krasimir edited the summary of this revision.
krasimir added a comment.

- Address review comments


https://reviews.llvm.org/D29990

Files:
  clangd/ClangDMain.cpp
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  test/clangd/formatting.test

Index: test/clangd/formatting.test
===
--- test/clangd/formatting.test
+++ test/clangd/formatting.test
@@ -4,11 +4,12 @@
 Content-Length: 125
 
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
-# CHECK: Content-Length: 191
+# CHECK: Content-Length: 294
 # CHECK: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{
 # CHECK:   "textDocumentSync": 1,
 # CHECK:   "documentFormattingProvider": true,
-# CHECK:   "documentRangeFormattingProvider": true
+# CHECK:   "documentRangeFormattingProvider": true,
+# CHECK:   "documentOnTypeFormattingProvider": {"firstTriggerCharacter":"}","moreTriggerCharacter":[]}
 # CHECK: }}}
 #
 Content-Length: 193
@@ -48,6 +49,17 @@
 {"jsonrpc":"2.0","id":4,"method":"textDocument/formatting","params":{"textDocument":{"uri":"file:///foo.c"},"options":{"tabSize":4,"insertSpaces":true}}}
 # CHECK: {"jsonrpc":"2.0","id":4,"result":[]}
 #
+Content-Length: 193
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///foo.c","version":5},"contentChanges":[{"text":"int foo ( int x ) {\n  x = x + 1;\n  return x;\n}"}]}}
+#
+#
+Content-Length: 204
+
+{"jsonrpc":"2.0","id":5,"method":"textDocument/onTypeFormatting","params":{"textDocument":{"uri":"file:///foo.c"},"position":{"line":3,"character":1},"ch":"}","options":{"tabSize":4,"insertSpaces":true}}}
+# CHECK: {"jsonrpc":"2.0","id":5,"result":[{"range": {"start": {"line": 0, "character": 7}, "end": {"line": 0, "character": 8}}, "newText": ""},{"range": {"start": {"line": 0, "character": 9}, "end": {"line": 0, "character": 10}}, "newText": ""},{"range": {"start": {"line": 0, "character": 15}, "end": {"line": 0, "character": 16}}, "newText": ""}]}
+#
+
 Content-Length: 44
 
-{"jsonrpc":"2.0","id":5,"method":"shutdown"}
+{"jsonrpc":"2.0","id":6,"method":"shutdown"}
Index: clangd/ProtocolHandlers.h
===
--- clangd/ProtocolHandlers.h
+++ clangd/ProtocolHandlers.h
@@ -33,7 +33,8 @@
 R"(,"result":{"capabilities":{
   "textDocumentSync": 1,
   "documentFormattingProvider": true,
-  "documentRangeFormattingProvider": true
+  "documentRangeFormattingProvider": true,
+  "documentOnTypeFormattingProvider": {"firstTriggerCharacter":"}","moreTriggerCharacter":[]}
 }}})");
   }
 };
@@ -71,6 +72,16 @@
   DocumentStore &Store;
 };
 
+struct TextDocumentOnTypeFormattingHandler : Handler {
+  TextDocumentOnTypeFormattingHandler(JSONOutput &Output, DocumentStore &Store)
+  : Handler(Output), Store(Store) {}
+
+  void handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) override;
+
+private:
+  DocumentStore &Store;
+};
+
 struct TextDocumentRangeFormattingHandler : Handler {
   TextDocumentRangeFormattingHandler(JSONOutput &Output, DocumentStore &Store)
   : Handler(Output), Store(Store) {}
Index: clangd/ProtocolHandlers.cpp
===
--- clangd/ProtocolHandlers.cpp
+++ clangd/ProtocolHandlers.cpp
@@ -104,6 +104,27 @@
   {clang::tooling::Range(Begin, Len)}, ID));
 }
 
+void TextDocumentOnTypeFormattingHandler::handleMethod(
+llvm::yaml::MappingNode *Params, StringRef ID) {
+  auto DOTFP = DocumentOnTypeFormattingParams::parse(Params);
+  if (!DOTFP) {
+Output.logs() << "Failed to decode DocumentOnTypeFormattingParams!\n";
+return;
+  }
+
+  // Look for the previous opening brace from the character position and format
+  // starting from there.
+  std::string Code = Store.getDocument(DOTFP->textDocument.uri);
+  size_t CursorPos = positionToOffset(Code, DOTFP->position);
+  size_t PreviousLBracePos = StringRef(Code).find_last_of('{', CursorPos);
+  if (PreviousLBracePos == StringRef::npos)
+PreviousLBracePos = CursorPos;
+  size_t Len = 1 + CursorPos - PreviousLBracePos;
+
+  writeMessage(formatCode(Code, DOTFP->textDocument.uri,
+  {clang::tooling::Range(PreviousLBracePos, Len)}, ID));
+}
+
 void TextDocumentFormattingHandler::handleMethod(
 llvm::yaml::MappingNode *Params, StringRef ID) {
   auto DFP = DocumentFormattingParams::parse(Params);
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -144,6 +144,23 @@
   parse(llvm::yaml::MappingNode *Params);
 };
 
+struct DocumentOnTypeFormattingParams {
+  /// The document to format.
+  TextDocumentIdentifier textDocument;
+
+  /// The position at which this reque

[PATCH] D30025: [compiler-rt] [builtins] Fix building atomic.c with GCC

2017-02-16 Thread David Chisnall via Phabricator via cfe-commits
theraven added a comment.

This code is working around something that's probably a clang bug.  It would be 
better to fix the clang bug than add more complex workarounds.


Repository:
  rL LLVM

https://reviews.llvm.org/D30025



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


[PATCH] D29943: [clang-format] Align block comment decorations

2017-02-16 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: lib/Format/BreakableToken.cpp:397
+//
+// Don't try aligning if there are less lines, since some patterns like
+//

fewer lines



Comment at: lib/Format/BreakableToken.cpp:402
+//
+// are common.
+if (e >= 3 && !Decoration.empty()) {

Why wouldn't we want to align those
/* line
 */
?


https://reviews.llvm.org/D29943



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


[PATCH] D29990: [clangd] Implement format on type

2017-02-16 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


https://reviews.llvm.org/D29990



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


[PATCH] D30035: Add const to function parameters

2017-02-16 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya created this revision.

https://reviews.llvm.org/D30035

Files:
  include/locale


Index: include/locale
===
--- include/locale
+++ include/locale
@@ -385,12 +385,12 @@
   _CharT& __thousands_sep);
 static int __stage2_int_loop(_CharT __ct, int __base, char* __a, char*& 
__a_end,
   unsigned& __dc, _CharT __thousands_sep, const string& 
__grouping,
-  unsigned* __g, unsigned*& __g_end, _CharT* __atoms);
+  unsigned* __g, unsigned*& __g_end, const _CharT* __atoms);
 static int __stage2_float_loop(_CharT __ct, bool& __in_units, char& __exp,
char* __a, char*& __a_end,
_CharT __decimal_point, _CharT 
__thousands_sep,
const string& __grouping, unsigned* __g,
-   unsigned*& __g_end, unsigned& __dc, _CharT* 
__atoms);
+   unsigned*& __g_end, unsigned& __dc, const 
_CharT* __atoms);
 };
 
 template 
@@ -421,7 +421,7 @@
 int
 __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, 
char*& __a_end,
   unsigned& __dc, _CharT __thousands_sep, const string& 
__grouping,
-  unsigned* __g, unsigned*& __g_end, _CharT* __atoms)
+  unsigned* __g, unsigned*& __g_end, const _CharT* __atoms)
 {
 if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25]))
 {
@@ -468,7 +468,7 @@
 int
 __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& 
__exp, char* __a, char*& __a_end,
 _CharT __decimal_point, _CharT __thousands_sep, const 
string& __grouping,
-unsigned* __g, unsigned*& __g_end, unsigned& __dc, _CharT* 
__atoms)
+unsigned* __g, unsigned*& __g_end, unsigned& __dc, const 
_CharT* __atoms)
 {
 if (__ct == __decimal_point)
 {


Index: include/locale
===
--- include/locale
+++ include/locale
@@ -385,12 +385,12 @@
   _CharT& __thousands_sep);
 static int __stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
   unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
-  unsigned* __g, unsigned*& __g_end, _CharT* __atoms);
+  unsigned* __g, unsigned*& __g_end, const _CharT* __atoms);
 static int __stage2_float_loop(_CharT __ct, bool& __in_units, char& __exp,
char* __a, char*& __a_end,
_CharT __decimal_point, _CharT __thousands_sep,
const string& __grouping, unsigned* __g,
-   unsigned*& __g_end, unsigned& __dc, _CharT* __atoms);
+   unsigned*& __g_end, unsigned& __dc, const _CharT* __atoms);
 };
 
 template 
@@ -421,7 +421,7 @@
 int
 __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
   unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
-  unsigned* __g, unsigned*& __g_end, _CharT* __atoms)
+  unsigned* __g, unsigned*& __g_end, const _CharT* __atoms)
 {
 if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25]))
 {
@@ -468,7 +468,7 @@
 int
 __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __exp, char* __a, char*& __a_end,
 _CharT __decimal_point, _CharT __thousands_sep, const string& __grouping,
-unsigned* __g, unsigned*& __g_end, unsigned& __dc, _CharT* __atoms)
+unsigned* __g, unsigned*& __g_end, unsigned& __dc, const _CharT* __atoms)
 {
 if (__ct == __decimal_point)
 {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r295303 - [clang-tidy] Ignore spaces between globs in the Checks option.

2017-02-16 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Feb 16 04:23:18 2017
New Revision: 295303

URL: http://llvm.org/viewvc/llvm-project?rev=295303&view=rev
Log:
[clang-tidy] Ignore spaces between globs in the Checks option.

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp

clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=295303&r1=295302&r2=295303&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Thu Feb 
16 04:23:18 2017
@@ -119,6 +119,7 @@ ClangTidyError::ClangTidyError(StringRef
 // Returns true if GlobList starts with the negative indicator ('-'), removes 
it
 // from the GlobList.
 static bool ConsumeNegativeIndicator(StringRef &GlobList) {
+  GlobList = GlobList.trim(' ');
   if (GlobList.startswith("-")) {
 GlobList = GlobList.substr(1);
 return true;

Modified: 
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp?rev=295303&r1=295302&r2=295303&view=diff
==
--- 
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
 (original)
+++ 
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
 Thu Feb 16 04:23:18 2017
@@ -67,7 +67,7 @@ TEST(GlobList, Simple) {
 }
 
 TEST(GlobList, Complex) {
-  GlobList Filter("*,-a.*,-b.*,a.1.*,-a.1.A.*,-..,-...,-..+,-*$,-*qwe*");
+  GlobList Filter("*,-a.*, -b.*,   a.1.* ,-a.1.A.*,-..,-...,-..+,-*$, -*qwe* 
");
 
   EXPECT_TRUE(Filter.contains("aaa"));
   EXPECT_TRUE(Filter.contains("qqq"));


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


[PATCH] D29944: libclang: Print namespaces for typedefs and type aliases

2017-02-16 Thread Michael via Phabricator via cfe-commits
redm123 added a comment.

In https://reviews.llvm.org/D29944#678033, @arphaman wrote:

> Do these diagnostics have the full qualifiers for errors that occur with 
> record types instead of typedefs?


Not sure what you mean by that, but as far as I can see all the changed errors 
refer to typedefs/aliases. Normal records types should not be affected.


https://reviews.llvm.org/D29944



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


[PATCH] D30034: [clang-tidy] Fix a false positive for explicit template instantiations in misc-unused-using-decls.

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

>   it may introduce true positives

True positives is all we need from clang-tidy checks ;) I guess, you meant 
"false negatives" 
(https://en.wikipedia.org/wiki/False_positives_and_false_negatives).

The main question here is whether we should extend the AST instead of hacking 
around its limitations. It's probably best to discuss with Richard Smith.


https://reviews.llvm.org/D30034



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


[PATCH] D29990: [clangd] Implement format on type

2017-02-16 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295304: [clangd] Implement format on type (authored by 
krasimir).

Changed prior to commit:
  https://reviews.llvm.org/D29990?vs=88703&id=88708#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29990

Files:
  clang-tools-extra/trunk/clangd/ClangDMain.cpp
  clang-tools-extra/trunk/clangd/Protocol.cpp
  clang-tools-extra/trunk/clangd/Protocol.h
  clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
  clang-tools-extra/trunk/clangd/ProtocolHandlers.h
  clang-tools-extra/trunk/test/clangd/formatting.test

Index: clang-tools-extra/trunk/test/clangd/formatting.test
===
--- clang-tools-extra/trunk/test/clangd/formatting.test
+++ clang-tools-extra/trunk/test/clangd/formatting.test
@@ -4,11 +4,12 @@
 Content-Length: 125
 
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
-# CHECK: Content-Length: 191
+# CHECK: Content-Length: 294
 # CHECK: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{
 # CHECK:   "textDocumentSync": 1,
 # CHECK:   "documentFormattingProvider": true,
-# CHECK:   "documentRangeFormattingProvider": true
+# CHECK:   "documentRangeFormattingProvider": true,
+# CHECK:   "documentOnTypeFormattingProvider": {"firstTriggerCharacter":"}","moreTriggerCharacter":[]}
 # CHECK: }}}
 #
 Content-Length: 193
@@ -48,6 +49,17 @@
 {"jsonrpc":"2.0","id":4,"method":"textDocument/formatting","params":{"textDocument":{"uri":"file:///foo.c"},"options":{"tabSize":4,"insertSpaces":true}}}
 # CHECK: {"jsonrpc":"2.0","id":4,"result":[]}
 #
+Content-Length: 193
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///foo.c","version":5},"contentChanges":[{"text":"int foo ( int x ) {\n  x = x + 1;\n  return x;\n}"}]}}
+#
+#
+Content-Length: 204
+
+{"jsonrpc":"2.0","id":5,"method":"textDocument/onTypeFormatting","params":{"textDocument":{"uri":"file:///foo.c"},"position":{"line":3,"character":1},"ch":"}","options":{"tabSize":4,"insertSpaces":true}}}
+# CHECK: {"jsonrpc":"2.0","id":5,"result":[{"range": {"start": {"line": 0, "character": 7}, "end": {"line": 0, "character": 8}}, "newText": ""},{"range": {"start": {"line": 0, "character": 9}, "end": {"line": 0, "character": 10}}, "newText": ""},{"range": {"start": {"line": 0, "character": 15}, "end": {"line": 0, "character": 16}}, "newText": ""}]}
+#
+
 Content-Length: 44
 
-{"jsonrpc":"2.0","id":5,"method":"shutdown"}
+{"jsonrpc":"2.0","id":6,"method":"shutdown"}
Index: clang-tools-extra/trunk/clangd/ClangDMain.cpp
===
--- clang-tools-extra/trunk/clangd/ClangDMain.cpp
+++ clang-tools-extra/trunk/clangd/ClangDMain.cpp
@@ -47,6 +47,9 @@
   "textDocument/rangeFormatting",
   llvm::make_unique(Out, Store));
   Dispatcher.registerHandler(
+  "textDocument/onTypeFormatting",
+  llvm::make_unique(Out, Store));
+  Dispatcher.registerHandler(
   "textDocument/formatting",
   llvm::make_unique(Out, Store));
 
Index: clang-tools-extra/trunk/clangd/ProtocolHandlers.h
===
--- clang-tools-extra/trunk/clangd/ProtocolHandlers.h
+++ clang-tools-extra/trunk/clangd/ProtocolHandlers.h
@@ -33,7 +33,8 @@
 R"(,"result":{"capabilities":{
   "textDocumentSync": 1,
   "documentFormattingProvider": true,
-  "documentRangeFormattingProvider": true
+  "documentRangeFormattingProvider": true,
+  "documentOnTypeFormattingProvider": {"firstTriggerCharacter":"}","moreTriggerCharacter":[]}
 }}})");
   }
 };
@@ -71,6 +72,16 @@
   DocumentStore &Store;
 };
 
+struct TextDocumentOnTypeFormattingHandler : Handler {
+  TextDocumentOnTypeFormattingHandler(JSONOutput &Output, DocumentStore &Store)
+  : Handler(Output), Store(Store) {}
+
+  void handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) override;
+
+private:
+  DocumentStore &Store;
+};
+
 struct TextDocumentRangeFormattingHandler : Handler {
   TextDocumentRangeFormattingHandler(JSONOutput &Output, DocumentStore &Store)
   : Handler(Output), Store(Store) {}
Index: clang-tools-extra/trunk/clangd/Protocol.h
===
--- clang-tools-extra/trunk/clangd/Protocol.h
+++ clang-tools-extra/trunk/clangd/Protocol.h
@@ -144,6 +144,23 @@
   parse(llvm::yaml::MappingNode *Params);
 };
 
+struct DocumentOnTypeFormattingParams {
+  /// The document to format.
+  TextDocumentIdentifier textDocument;
+
+  /// The position at which this request was sent.
+  Position position;
+
+  /// The character that has been typed.
+  std::string ch;
+
+  /// The format options.
+  FormattingOptions options;
+
+  static llvm::Optional
+  parse(llvm::yaml::MappingNode *Params);
+};
+
 struct DocumentFormattingParams {
   /// The document to

[clang-tools-extra] r295304 - [clangd] Implement format on type

2017-02-16 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Thu Feb 16 04:49:46 2017
New Revision: 295304

URL: http://llvm.org/viewvc/llvm-project?rev=295304&view=rev
Log:
[clangd] Implement format on type

Summary:
This patch adds onTypeFormatting to clangd.

The trigger character is '}' and it works by scanning for the matching '{' and 
formatting the range in-between.

There are problems with ';' as a trigger character, the cursor position is 
before the `|`:
```
int main() {
  int i;|
}
```
becomes:
```
int main() {  int i;| }
```
which is not likely what the user intended.

Also formatting at semicolon in a non-properly closed scope puts the following 
tokens in the same unwrapped line, which doesn't reformat nicely.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangDMain.cpp
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
clang-tools-extra/trunk/clangd/ProtocolHandlers.h
clang-tools-extra/trunk/test/clangd/formatting.test

Modified: clang-tools-extra/trunk/clangd/ClangDMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangDMain.cpp?rev=295304&r1=295303&r2=295304&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangDMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangDMain.cpp Thu Feb 16 04:49:46 2017
@@ -47,6 +47,9 @@ int main(int argc, char *argv[]) {
   "textDocument/rangeFormatting",
   llvm::make_unique(Out, Store));
   Dispatcher.registerHandler(
+  "textDocument/onTypeFormatting",
+  llvm::make_unique(Out, Store));
+  Dispatcher.registerHandler(
   "textDocument/formatting",
   llvm::make_unique(Out, Store));
 

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=295304&r1=295303&r2=295304&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Thu Feb 16 04:49:46 2017
@@ -378,6 +378,53 @@ DocumentRangeFormattingParams::parse(llv
   return Result;
 }
 
+llvm::Optional
+DocumentOnTypeFormattingParams::parse(llvm::yaml::MappingNode *Params) {
+  DocumentOnTypeFormattingParams Result;
+  for (auto &NextKeyValue : *Params) {
+auto *KeyString = dyn_cast(NextKeyValue.getKey());
+if (!KeyString)
+  return llvm::None;
+
+llvm::SmallString<10> KeyStorage;
+StringRef KeyValue = KeyString->getValue(KeyStorage);
+
+if (KeyValue == "ch") {
+  auto *ScalarValue =
+  dyn_cast_or_null(NextKeyValue.getValue());
+  if (!ScalarValue)
+return llvm::None;
+  llvm::SmallString<10> Storage;
+  Result.ch = ScalarValue->getValue(Storage);
+  continue;
+}
+
+auto *Value =
+dyn_cast_or_null(NextKeyValue.getValue());
+if (!Value)
+  return llvm::None;
+if (KeyValue == "textDocument") {
+  auto Parsed = TextDocumentIdentifier::parse(Value);
+  if (!Parsed)
+return llvm::None;
+  Result.textDocument = std::move(*Parsed);
+} else if (KeyValue == "position") {
+  auto Parsed = Position::parse(Value);
+  if (!Parsed)
+return llvm::None;
+  Result.position = std::move(*Parsed);
+} else if (KeyValue == "options") {
+  auto Parsed = FormattingOptions::parse(Value);
+  if (!Parsed)
+return llvm::None;
+  Result.options = std::move(*Parsed);
+} else {
+  return llvm::None;
+}
+  }
+  return Result;
+}
+
 llvm::Optional
 DocumentFormattingParams::parse(llvm::yaml::MappingNode *Params) {
   DocumentFormattingParams Result;

Modified: clang-tools-extra/trunk/clangd/Protocol.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=295304&r1=295303&r2=295304&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.h (original)
+++ clang-tools-extra/trunk/clangd/Protocol.h Thu Feb 16 04:49:46 2017
@@ -144,6 +144,23 @@ struct DocumentRangeFormattingParams {
   parse(llvm::yaml::MappingNode *Params);
 };
 
+struct DocumentOnTypeFormattingParams {
+  /// The document to format.
+  TextDocumentIdentifier textDocument;
+
+  /// The position at which this request was sent.
+  Position position;
+
+  /// The character that has been typed.
+  std::string ch;
+
+  /// The format options.
+  FormattingOptions options;
+
+  static llvm::Optional
+  parse(llvm::yaml::MappingNode *Params);
+};
+
 struct DocumentFormattingParams {
   /// The document to format.
   TextDocumentIdentifier textDocument;

Modified: clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-ext

[clang-tools-extra] r295305 - [clangd] Fix Output.log error

2017-02-16 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Thu Feb 16 04:53:27 2017
New Revision: 295305

URL: http://llvm.org/viewvc/llvm-project?rev=295305&view=rev
Log:
[clangd] Fix Output.log error

Modified:
clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp

Modified: clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp?rev=295305&r1=295304&r2=295305&view=diff
==
--- clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp (original)
+++ clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp Thu Feb 16 04:53:27 2017
@@ -108,7 +108,7 @@ void TextDocumentOnTypeFormattingHandler
 llvm::yaml::MappingNode *Params, StringRef ID) {
   auto DOTFP = DocumentOnTypeFormattingParams::parse(Params);
   if (!DOTFP) {
-Output.logs() << "Failed to decode DocumentOnTypeFormattingParams!\n";
+Output.log("Failed to decode DocumentOnTypeFormattingParams!\n");
 return;
   }
 


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


[PATCH] D29879: [OpenMP] Teams reduction on the NVPTX device.

2017-02-16 Thread Arpith Jacob via Phabricator via cfe-commits
arpith-jacob marked an inline comment as done.
arpith-jacob added a comment.

Alexey, do you any more comments on this patch?


https://reviews.llvm.org/D29879



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


[PATCH] D30034: [clang-tidy] Fix a false positive for explicit template instantiations in misc-unused-using-decls.

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

Richard, it seems like the AST could be improved here by adding nodes for the 
explicit instantiation declarations and definitions or using existing nodes, if 
there are suitable ones. What do you think?


https://reviews.llvm.org/D30034



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


r295307 - [OpenCL] Disallow blocks capture other blocks (v2.0, s6.12.5)

2017-02-16 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Thu Feb 16 05:13:30 2017
New Revision: 295307

URL: http://llvm.org/viewvc/llvm-project?rev=295307&view=rev
Log:
[OpenCL] Disallow blocks capture other blocks (v2.0, s6.12.5)


Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaOpenCL/invalid-block.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=295307&r1=295306&r2=295307&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Feb 16 05:13:30 
2017
@@ -8299,6 +8299,8 @@ def err_opencl_invalid_block_declaration
   "invalid block variable declaration - must be %select{const 
qualified|initialized}0">;
 def err_opencl_extern_block_declaration : Error<
   "invalid block variable declaration - using 'extern' storage class is 
disallowed">;
+def err_opencl_block_ref_block : Error<
+  "cannot refer to a block inside block">;
 
 // OpenCL v2.0 s6.13.9 - Address space qualifier functions. 
 def err_opencl_builtin_to_addr_arg_num : Error<

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=295307&r1=295306&r2=295307&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Feb 16 05:13:30 2017
@@ -13565,6 +13565,13 @@ static bool isVariableCapturable(Capturi
 }
 return false;
   }
+  // OpenCL v2.0 s6.12.5: Blocks cannot reference/capture other blocks
+  if (S.getLangOpts().OpenCL && IsBlock &&
+  Var->getType()->isBlockPointerType()) {
+if (Diagnose)
+  S.Diag(Loc, diag::err_opencl_block_ref_block);
+return false;
+  }
 
   return true;
 }

Modified: cfe/trunk/test/SemaOpenCL/invalid-block.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid-block.cl?rev=295307&r1=295306&r2=295307&view=diff
==
--- cfe/trunk/test/SemaOpenCL/invalid-block.cl (original)
+++ cfe/trunk/test/SemaOpenCL/invalid-block.cl Thu Feb 16 05:13:30 2017
@@ -66,3 +66,18 @@ void f6(bl2_t *bl_ptr) { // expected-err
   *bl;  // expected-error {{invalid argument type 'bl2_t' (aka 'int 
(__generic ^const)(int)') to unary expression}}
   &bl;  // expected-error {{invalid argument type 'bl2_t' (aka 'int 
(__generic ^const)(int)') to unary expression}}
 }
+// A block can't reference another block
+kernel void f7() {
+  bl2_t bl1 = ^(int i) {
+return 1;
+  };
+  void (^bl2)(void) = ^{
+int i = bl1(1); // expected-error {{cannot refer to a block inside block}}
+  };
+  void (^bl3)(void) = ^{
+  };
+  void (^bl4)(void) = ^{
+bl3(); // expected-error {{cannot refer to a block inside block}}
+  };
+  return;
+}


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


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

Maybe something like the following (without tests):

  diff --git a/include/clang/Driver/ToolChain.h 
b/include/clang/Driver/ToolChain.h
  index ffb0d60..0f3507d 100644
  --- a/include/clang/Driver/ToolChain.h
  +++ b/include/clang/Driver/ToolChain.h
  @@ -299,6 +299,11 @@ public:
 const char *getCompilerRTArgString(const llvm::opt::ArgList &Args,
StringRef Component,
bool Shared = false) const;
  +
  +  /// Returns /lib//.  This is used by runtimes 
(such
  +  /// as OpenMP) to find arch-specific libraries.
  +  const std::string getArchSpecificLibPath() const;
  +
 /// needsProfileRT - returns true if instrumentation profile is on.
 static bool needsProfileRT(const llvm::opt::ArgList &Args);
   
  diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp
  index 6adc038..ae2c08e 100644
  --- a/lib/Driver/ToolChain.cpp
  +++ b/lib/Driver/ToolChain.cpp
  @@ -10,6 +10,7 @@
   #include "clang/Driver/ToolChain.h"
   #include "Tools.h"
   #include "clang/Basic/ObjCRuntime.h"
  +#include "clang/Basic/VirtualFileSystem.h"
   #include "clang/Config/config.h"
   #include "clang/Driver/Action.h"
   #include "clang/Driver/Driver.h"
  @@ -74,6 +75,10 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple 
&T,
   if (!isThreadModelSupported(A->getValue()))
 D.Diag(diag::err_drv_invalid_thread_model_for_target)
 << A->getValue() << A->getAsString(Args);
  +
  +  std::string CandidateLibPath = getArchSpecificLibPath();
  +  if (getVFS().exists(CandidateLibPath))
  +getFilePaths().push_back(CandidateLibPath);
   }
   
   ToolChain::~ToolChain() {
  @@ -320,6 +325,14 @@ const char *ToolChain::getCompilerRTArgString(const 
llvm::opt::ArgList &Args,
 return Args.MakeArgString(getCompilerRT(Args, Component, Shared));
   }
   
  +const std::string ToolChain::getArchSpecificLibPath() const {
  +  SmallString<128> Path(getDriver().ResourceDir);
  +  StringRef OSLibName = getTriple().isOSFreeBSD() ? "freebsd" : getOS();
  +  llvm::sys::path::append(Path, "lib", OSLibName,
  +  llvm::Triple::getArchTypeName(getArch()));
  +  return Path.str();
  +}
  +
   bool ToolChain::needsProfileRT(const ArgList &Args) {
 if (Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs,
  false) ||
  diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
  index cc7d9e1..c0fb4bc 100644
  --- a/lib/Driver/Tools.cpp
  +++ b/lib/Driver/Tools.cpp
  @@ -14,6 +14,7 @@
   #include "clang/Basic/LangOptions.h"
   #include "clang/Basic/ObjCRuntime.h"
   #include "clang/Basic/Version.h"
  +#include "clang/Basic/VirtualFileSystem.h"
   #include "clang/Config/config.h"
   #include "clang/Driver/Action.h"
   #include "clang/Driver/Compilation.h"
  @@ -276,8 +277,15 @@ static void AddLinkerInputs(const ToolChain &TC, const 
InputInfoList &Inputs,
   
 // LIBRARY_PATH - included following the user specified library paths.
 //and only supported on native toolchains.
  -  if (!TC.isCrossCompiling())
  +  if (!TC.isCrossCompiling()) {
   addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
  +
  +std::string CandidateRPath = TC.getArchSpecificLibPath();
  +if (D.getVFS().exists(CandidateRPath)) {
  +  CmdArgs.push_back("-rpath");
  +  CmdArgs.push_back(Args.MakeArgString(CandidateRPath.c_str()));
  +}
  +  }
   }
   
   /// Add OpenMP linker script arguments at the end of the argument list so 
that


https://reviews.llvm.org/D30015



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


[PATCH] D29879: [OpenMP] Teams reduction on the NVPTX device.

2017-02-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:715
+// lane_offset, int16_t shortCircuit),
+// void (*kmp_InterWarpCopyFctPtr)(void* src, int warp_num),
+// void (*kmp_CopyToScratchpadFctPtr)(void *reduce_data, void * scratchpad,

`int32_t`, not `int`



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:1040-1041
+  llvm::Value *RemoteLaneOffset = nullptr,
+  llvm::Value *ScratchpadIndex = nullptr,
+  llvm::Value *ScratchpadWidth = nullptr) {
 

To many params already, try to join them in the struct.



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:1255
+ /*Id=*/nullptr,
+ C.getIntTypeForBitwidth(32, /* Signed */ true));
+  // Row width of an element in the scratchpad array, typically

It is better to create `Int32Ty` att the beginning of the function rather than 
call `C.getIntTypeForBitwidth()` each time



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:1393
+ /*Id=*/nullptr,
+ C.getIntTypeForBitwidth(32, /* Signed */ true));
+

It is better to create `Int32Ty` att the beginning of the function rather than 
call `C.getIntTypeForBitwidth()` each time


https://reviews.llvm.org/D29879



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


[PATCH] D30025: [compiler-rt] [builtins] Fix building atomic.c with GCC

2017-02-16 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D30025#678462, @theraven wrote:

> This code is working around something that's probably a clang bug.  It would 
> be better to fix the clang bug than add more complex workarounds.


Well, clang explicitly rejects those functions as errors, so I would guess it 
does that by design.


Repository:
  rL LLVM

https://reviews.llvm.org/D30025



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


r295311 - [OpenCL] Correct ndrange_t implementation

2017-02-16 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Thu Feb 16 06:27:47 2017
New Revision: 295311

URL: http://llvm.org/viewvc/llvm-project?rev=295311&view=rev
Log:
[OpenCL] Correct ndrange_t implementation

Removed ndrange_t as Clang builtin type and added
as a struct type in the OpenCL header.

Use type name to do the Sema checking in enqueue_kernel
and modify IR generation accordingly.

Review: D28058

Patch by Dmitry Borisenkov!  
 

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/BuiltinTypes.def
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/NSAPI.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypeLoc.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Headers/opencl-c.h
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
cfe/trunk/test/Headers/opencl-c-header.cl
cfe/trunk/test/PCH/ocl_types.h
cfe/trunk/test/SemaOpenCL/cl20-device-side-enqueue.cl
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=295311&r1=295310&r2=295311&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Feb 16 06:27:47 2017
@@ -976,7 +976,7 @@ public:
   CanQualType SingletonId;
 #include "clang/Basic/OpenCLImageTypes.def"
   CanQualType OCLSamplerTy, OCLEventTy, OCLClkEventTy;
-  CanQualType OCLQueueTy, OCLNDRangeTy, OCLReserveIDTy;
+  CanQualType OCLQueueTy, OCLReserveIDTy;
   CanQualType OMPArraySectionTy;
 
   // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.

Modified: cfe/trunk/include/clang/AST/BuiltinTypes.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/BuiltinTypes.def?rev=295311&r1=295310&r2=295311&view=diff
==
--- cfe/trunk/include/clang/AST/BuiltinTypes.def (original)
+++ cfe/trunk/include/clang/AST/BuiltinTypes.def Thu Feb 16 06:27:47 2017
@@ -169,9 +169,6 @@ BUILTIN_TYPE(OCLClkEvent, OCLClkEventTy)
 // OpenCL queue_t.
 BUILTIN_TYPE(OCLQueue, OCLQueueTy)
 
-// OpenCL ndrange_t.
-BUILTIN_TYPE(OCLNDRange, OCLNDRangeTy)
-
 // OpenCL reserve_id_t.
 BUILTIN_TYPE(OCLReserveID, OCLReserveIDTy)
 

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=295311&r1=295310&r2=295311&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Thu Feb 16 06:27:47 2017
@@ -1744,7 +1744,6 @@ public:
   bool isEventT() const;// OpenCL event_t
   bool isClkEventT() const; // OpenCL clk_event_t
   bool isQueueT() const;// OpenCL queue_t
-  bool isNDRangeT() const;  // OpenCL ndrange_t
   bool isReserveIDT() const;// OpenCL reserve_id_t
 
   bool isPipeType() const;  // OpenCL pipe type
@@ -5801,10 +5800,6 @@ inline bool Type::isQueueT() const {
   return isSpecificBuiltinType(BuiltinType::OCLQueue);
 }
 
-inline bool Type::isNDRangeT() const {
-  return isSpecificBuiltinType(BuiltinType::OCLNDRange);
-}
-
 inline bool Type::isReserveIDT() const {
   return isSpecificBuiltinType(BuiltinType::OCLReserveID);
 }
@@ -5822,7 +5817,7 @@ inline bool Type::isPipeType() const {
 
 inline bool Type::isOpenCLSpecificType() const {
   return isSamplerT() || isEventT() || isImageType() || isClkEventT() ||
- isQueueT() || isNDRangeT() || isReserveIDT() || isPipeType();
+ isQueueT() || isReserveIDT() || isPipeType();
 }
 
 inline bool Type::isTemplateTypeParmType() const {

Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=295311&r1=295310&r2=295311&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Thu Feb 16 06:27:47 2017
@@ -803,14 +803,12 @@ namespace clang {
   PREDEF_TYPE_SAMPLER_ID= 39,
   /// \brief Op

[PATCH] D29943: [clang-format] Align block comment decorations

2017-02-16 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 88713.
krasimir added a comment.

- Align decorations of block comments spanning two lines


https://reviews.llvm.org/D29943

Files:
  lib/Format/BreakableToken.cpp
  lib/Format/BreakableToken.h
  unittests/Format/FormatTest.cpp
  unittests/Format/FormatTestComments.cpp

Index: unittests/Format/FormatTestComments.cpp
===
--- unittests/Format/FormatTestComments.cpp
+++ unittests/Format/FormatTestComments.cpp
@@ -937,11 +937,11 @@
getLLVMStyleWithColumns(20)));
 
   EXPECT_EQ("/* some comment\n"
-" *   a comment\n"
-"* that we break\n"
-" * another comment\n"
-"* we have to break\n"
-"* a left comment\n"
+" *   a comment that\n"
+" * we break another\n"
+" * comment we have\n"
+" * to break a left\n"
+" * comment\n"
 " */",
 format("  /* some comment\n"
"   *   a comment that we break\n"
@@ -1856,10 +1856,10 @@
getLLVMStyleWithColumns(15)));
   EXPECT_EQ("/*\n**\n*/", format("/*\n**\n*/"));
   EXPECT_EQ("/*\n"
-"*\n"
+" *\n"
 " * aa\n"
 " * aa\n"
-"*/",
+" */",
 format("/*\n"
"*\n"
" * aa aa\n"
@@ -2164,6 +2164,194 @@
"   long b;",
getLLVMStyleWithColumns(80)));
 }
+
+TEST_F(FormatTestComments, AlignsBlockCommentDecorations) {
+  EXPECT_EQ("/*\n"
+" */",
+format("/*\n"
+   "*/", getLLVMStyle()));
+  EXPECT_EQ("/*\n"
+" */",
+format("/*\n"
+   " */", getLLVMStyle()));
+  EXPECT_EQ("/*\n"
+" */",
+format("/*\n"
+   "  */", getLLVMStyle()));
+
+  // Align a single line.
+  EXPECT_EQ("/*\n"
+" * line */",
+format("/*\n"
+   "* line */",
+   getLLVMStyle()));
+  EXPECT_EQ("/*\n"
+" * line */",
+format("/*\n"
+   " * line */",
+   getLLVMStyle()));
+  EXPECT_EQ("/*\n"
+" * line */",
+format("/*\n"
+   "  * line */",
+   getLLVMStyle()));
+  EXPECT_EQ("/*\n"
+" * line */",
+format("/*\n"
+   "   * line */",
+   getLLVMStyle()));
+  EXPECT_EQ("/**\n"
+" * line */",
+format("/**\n"
+   "* line */",
+   getLLVMStyle()));
+  EXPECT_EQ("/**\n"
+" * line */",
+format("/**\n"
+   " * line */",
+   getLLVMStyle()));
+  EXPECT_EQ("/**\n"
+" * line */",
+format("/**\n"
+   "  * line */",
+   getLLVMStyle()));
+  EXPECT_EQ("/**\n"
+" * line */",
+format("/**\n"
+   "   * line */",
+   getLLVMStyle()));
+  EXPECT_EQ("/**\n"
+" * line */",
+format("/**\n"
+   "* line */",
+   getLLVMStyle()));
+
+  // Align the end '*/' after a line.
+  EXPECT_EQ("/*\n"
+" * line\n"
+" */",
+format("/*\n"
+   "* line\n"
+   "*/", getLLVMStyle()));
+  EXPECT_EQ("/*\n"
+" * line\n"
+" */",
+format("/*\n"
+   "   * line\n"
+   "  */", getLLVMStyle()));
+  EXPECT_EQ("/*\n"
+" * line\n"
+" */",
+format("/*\n"
+   "  * line\n"
+   "  */", getLLVMStyle()));
+
+  // Align two lines.
+  EXPECT_EQ("/* line 1\n"
+" * line 2 */",
+format("/* line 1\n"
+   " * line 2 */",
+   getLLVMStyle()));
+  EXPECT_EQ("/* line 1\n"
+" * line 2 */",
+format("/* line 1\n"
+   "* line 2 */",
+   getLLVMStyle()));
+  EXPECT_EQ("/* line 1\n"
+" * line 2 */",
+format("/* line 1\n"
+   "  * line 2 */",
+   getLLVMStyle()));
+  EXPECT_EQ("/* line 1\n"
+" * line 2 */",
+format("/* line 1\n"
+   "   * line 2 */",
+   getLLVMStyle()));
+  EXPECT_EQ("/* line 1\n"
+" * line 2 */",
+format("/* line 1\n"
+   "* line 2 */",
+   getLLVMStyle()));
+  EXPECT_EQ("int i; /* line 1\n"
+"* line 2 */",
+format("int i; /* line 1\n"
+   "* line 2 */",
+   getLLVMStyle()));
+  EXPECT_EQ("int i; /* line 1\n"
+"* line 2 */",
+ 

[PATCH] D29943: [clang-format] Align block comment decorations

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

lg


https://reviews.llvm.org/D29943



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


r295312 - [clang-format] Align block comment decorations

2017-02-16 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Thu Feb 16 06:39:31 2017
New Revision: 295312

URL: http://llvm.org/viewvc/llvm-project?rev=295312&view=rev
Log:
[clang-format] Align block comment decorations

Summary:
This patch implements block comment decoration alignment.

source:
```
/* line 1
* line 2
*/
```

result before:
```
/* line 1
* line 2
*/
```

result after:
```
/* line 1
 * line 2
 */
```

Reviewers: djasper, bkramer, klimek

Reviewed By: klimek

Subscribers: mprobst, cfe-commits, klimek

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

Modified:
cfe/trunk/lib/Format/BreakableToken.cpp
cfe/trunk/lib/Format/BreakableToken.h
cfe/trunk/unittests/Format/FormatTest.cpp
cfe/trunk/unittests/Format/FormatTestComments.cpp

Modified: cfe/trunk/lib/Format/BreakableToken.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.cpp?rev=295312&r1=295311&r2=295312&view=diff
==
--- cfe/trunk/lib/Format/BreakableToken.cpp (original)
+++ cfe/trunk/lib/Format/BreakableToken.cpp Thu Feb 16 06:39:31 2017
@@ -344,6 +344,20 @@ BreakableBlockComment::BreakableBlockCom
   for (size_t i = 1; i < Lines.size(); ++i)
 adjustWhitespace(i, IndentDelta);
 
+  // Align decorations with the column of the star on the first line,
+  // that is one column after the start "/*".
+  DecorationColumn = StartColumn + 1;
+
+  // Account for comment decoration patterns like this:
+  //
+  // /*
+  // ** blah blah blah
+  // */
+  if (Lines.size() >= 2 && Content[1].startswith("**") &&
+  static_cast(ContentColumn[1]) == StartColumn) {
+DecorationColumn = StartColumn;
+  }
+
   Decoration = "* ";
   if (Lines.size() == 1 && !FirstInLine) {
 // Comments for which FirstInLine is false can start on arbitrary column,
@@ -373,6 +387,10 @@ BreakableBlockComment::BreakableBlockCom
 // trailing */. We also need to preserve whitespace, so that */ is
 // correctly indented.
 LastLineNeedsDecoration = false;
+// Align the star in the last '*/' with the stars on the previous 
lines.
+if (e >= 2 && !Decoration.empty()) {
+  ContentColumn[i] = DecorationColumn;
+}
   } else if (Decoration.empty()) {
 // For all other lines, set the start column to 0 if they're empty, so
 // we do not insert trailing whitespace anywhere.
@@ -382,12 +400,15 @@ BreakableBlockComment::BreakableBlockCom
 }
 
 // The first line already excludes the star.
+// The last line excludes the star if LastLineNeedsDecoration is false.
 // For all other lines, adjust the line to exclude the star and
 // (optionally) the first whitespace.
 unsigned DecorationSize = Decoration.startswith(Content[i])
   ? Content[i].size()
   : Decoration.size();
-ContentColumn[i] += DecorationSize;
+if (DecorationSize) {
+  ContentColumn[i] = DecorationColumn + DecorationSize;
+}
 Content[i] = Content[i].substr(DecorationSize);
 if (!Decoration.startswith(Content[i]))
   IndentAtLineBreak =
@@ -400,7 +421,8 @@ BreakableBlockComment::BreakableBlockCom
 llvm::dbgs() << "IndentAtLineBreak " << IndentAtLineBreak << "\n";
 for (size_t i = 0; i < Lines.size(); ++i) {
   llvm::dbgs() << i << " |" << Content[i] << "| "
-   << (Content[i].data() - Lines[i].data()) << "\n";
+   << "CC=" << ContentColumn[i] << "| "
+   << "IN=" << (Content[i].data() - Lines[i].data()) << "\n";
 }
   });
 }

Modified: cfe/trunk/lib/Format/BreakableToken.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.h?rev=295312&r1=295311&r2=295312&view=diff
==
--- cfe/trunk/lib/Format/BreakableToken.h (original)
+++ cfe/trunk/lib/Format/BreakableToken.h Thu Feb 16 06:39:31 2017
@@ -358,6 +358,10 @@ private:
 
   // Either "* " if all lines begin with a "*", or empty.
   StringRef Decoration;
+
+  // If this block comment has decorations, this is the column of the start of
+  // the decorations.
+  unsigned DecorationColumn;
 };
 
 class BreakableLineCommentSection : public BreakableComment {

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=295312&r1=295311&r2=295312&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Feb 16 06:39:31 2017
@@ -1966,7 +1966,7 @@ TEST_F(FormatTest, EscapedNewlines) {
   format("#define A \\\nint i;\\\n  int j;", getLLVMStyleWithColumns(11)));
   EXPECT_EQ("#define A\n\nint i;", format("#define A \\\n\n int i;"));
   EXPECT_EQ("template  f();", format("\\\ntemplate  f();"));
-  EXPECT_EQ("/* \\  \\  \\\n*/", 

[PATCH] D29943: [clang-format] Align block comment decorations

2017-02-16 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295312: [clang-format] Align block comment decorations 
(authored by krasimir).

Changed prior to commit:
  https://reviews.llvm.org/D29943?vs=88713&id=88714#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29943

Files:
  cfe/trunk/lib/Format/BreakableToken.cpp
  cfe/trunk/lib/Format/BreakableToken.h
  cfe/trunk/unittests/Format/FormatTest.cpp
  cfe/trunk/unittests/Format/FormatTestComments.cpp

Index: cfe/trunk/lib/Format/BreakableToken.h
===
--- cfe/trunk/lib/Format/BreakableToken.h
+++ cfe/trunk/lib/Format/BreakableToken.h
@@ -358,6 +358,10 @@
 
   // Either "* " if all lines begin with a "*", or empty.
   StringRef Decoration;
+
+  // If this block comment has decorations, this is the column of the start of
+  // the decorations.
+  unsigned DecorationColumn;
 };
 
 class BreakableLineCommentSection : public BreakableComment {
Index: cfe/trunk/lib/Format/BreakableToken.cpp
===
--- cfe/trunk/lib/Format/BreakableToken.cpp
+++ cfe/trunk/lib/Format/BreakableToken.cpp
@@ -344,6 +344,20 @@
   for (size_t i = 1; i < Lines.size(); ++i)
 adjustWhitespace(i, IndentDelta);
 
+  // Align decorations with the column of the star on the first line,
+  // that is one column after the start "/*".
+  DecorationColumn = StartColumn + 1;
+
+  // Account for comment decoration patterns like this:
+  //
+  // /*
+  // ** blah blah blah
+  // */
+  if (Lines.size() >= 2 && Content[1].startswith("**") &&
+  static_cast(ContentColumn[1]) == StartColumn) {
+DecorationColumn = StartColumn;
+  }
+
   Decoration = "* ";
   if (Lines.size() == 1 && !FirstInLine) {
 // Comments for which FirstInLine is false can start on arbitrary column,
@@ -373,6 +387,10 @@
 // trailing */. We also need to preserve whitespace, so that */ is
 // correctly indented.
 LastLineNeedsDecoration = false;
+// Align the star in the last '*/' with the stars on the previous lines.
+if (e >= 2 && !Decoration.empty()) {
+  ContentColumn[i] = DecorationColumn;
+}
   } else if (Decoration.empty()) {
 // For all other lines, set the start column to 0 if they're empty, so
 // we do not insert trailing whitespace anywhere.
@@ -382,12 +400,15 @@
 }
 
 // The first line already excludes the star.
+// The last line excludes the star if LastLineNeedsDecoration is false.
 // For all other lines, adjust the line to exclude the star and
 // (optionally) the first whitespace.
 unsigned DecorationSize = Decoration.startswith(Content[i])
   ? Content[i].size()
   : Decoration.size();
-ContentColumn[i] += DecorationSize;
+if (DecorationSize) {
+  ContentColumn[i] = DecorationColumn + DecorationSize;
+}
 Content[i] = Content[i].substr(DecorationSize);
 if (!Decoration.startswith(Content[i]))
   IndentAtLineBreak =
@@ -400,7 +421,8 @@
 llvm::dbgs() << "IndentAtLineBreak " << IndentAtLineBreak << "\n";
 for (size_t i = 0; i < Lines.size(); ++i) {
   llvm::dbgs() << i << " |" << Content[i] << "| "
-   << (Content[i].data() - Lines[i].data()) << "\n";
+   << "CC=" << ContentColumn[i] << "| "
+   << "IN=" << (Content[i].data() - Lines[i].data()) << "\n";
 }
   });
 }
Index: cfe/trunk/unittests/Format/FormatTestComments.cpp
===
--- cfe/trunk/unittests/Format/FormatTestComments.cpp
+++ cfe/trunk/unittests/Format/FormatTestComments.cpp
@@ -937,11 +937,11 @@
getLLVMStyleWithColumns(20)));
 
   EXPECT_EQ("/* some comment\n"
-" *   a comment\n"
-"* that we break\n"
-" * another comment\n"
-"* we have to break\n"
-"* a left comment\n"
+" *   a comment that\n"
+" * we break another\n"
+" * comment we have\n"
+" * to break a left\n"
+" * comment\n"
 " */",
 format("  /* some comment\n"
"   *   a comment that we break\n"
@@ -1856,10 +1856,10 @@
getLLVMStyleWithColumns(15)));
   EXPECT_EQ("/*\n**\n*/", format("/*\n**\n*/"));
   EXPECT_EQ("/*\n"
-"*\n"
+" *\n"
 " * aa\n"
 " * aa\n"
-"*/",
+" */",
 format("/*\n"
"*\n"
" * aa aa\n"
@@ -2164,6 +2164,194 @@
"   long b;",
getLLVMStyleWithColumns(80)));
 }
+
+TEST_F(FormatTestComments, AlignsBlockCommentDecorations) {
+  EXPECT_EQ("/*\n"
+" */",
+format("/*\n"
+   "*/",

[PATCH] D29879: [OpenMP] Teams reduction on the NVPTX device.

2017-02-16 Thread Arpith Jacob via Phabricator via cfe-commits
arpith-jacob updated this revision to Diff 88715.
arpith-jacob added a comment.

Addressed review comments.


https://reviews.llvm.org/D29879

Files:
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/nvptx_teams_reduction_codegen.cpp

Index: test/OpenMP/nvptx_teams_reduction_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/nvptx_teams_reduction_codegen.cpp
@@ -0,0 +1,1143 @@
+// Test target codegen - host bc file has to be created first.
+// 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 --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -verify -fopenmp -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// Check for the data transfer medium in shared memory to transfer the reduction list to the first warp.
+// CHECK-DAG: [[TRANSFER_STORAGE:@.+]] = common addrspace([[SHARED_ADDRSPACE:[0-9]+]]) global [32 x i64]
+
+// Check that the execution mode of all 3 target regions is set to Generic Mode.
+// CHECK-DAG: {{@__omp_offloading_.+l27}}_exec_mode = weak constant i8 1
+// CHECK-DAG: {{@__omp_offloading_.+l33}}_exec_mode = weak constant i8 1
+// CHECK-DAG: {{@__omp_offloading_.+l40}}_exec_mode = weak constant i8 1
+
+template
+tx ftemplate(int n) {
+  int a;
+  short b;
+  tx c;
+  float d;
+  double e;
+
+  #pragma omp target
+  #pragma omp teams reduction(+: e)
+  {
+e += 5;
+  }
+
+  #pragma omp target
+  #pragma omp teams reduction(^: c) reduction(*: d)
+  {
+c ^= 2;
+d *= 33;
+  }
+
+  #pragma omp target
+  #pragma omp teams reduction(|: a) reduction(max: b)
+  {
+a |= 1;
+b = 99 > b ? 99 : b;
+  }
+
+  return a+b+c+d+e;
+}
+
+int bar(int n){
+  int a = 0;
+
+  a += ftemplate(n);
+
+  return a;
+}
+
+  // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+template.+l27}}_worker()
+
+  // CHECK: define {{.*}}void [[T1:@__omp_offloading_.+template.+l27]](
+  //
+  // CHECK: {{call|invoke}} void [[T1]]_worker()
+  //
+  // CHECK: call void @__kmpc_kernel_init(
+  //
+  // CHECK: store double {{[0\.e\+]+}}, double* [[E:%.+]], align
+  // CHECK: [[EV:%.+]] = load double, double* [[E]], align
+  // CHECK: [[ADD:%.+]] = fadd double [[EV]], 5
+  // CHECK: store double [[ADD]], double* [[E]], align
+  // CHECK: [[PTR1:%.+]] = getelementptr inbounds [[RLT:.+]], [1 x i8*]* [[RL:%.+]], i[[SZ:32|64]] 0, i{{32|64}} 0
+  // CHECK: [[E_CAST:%.+]] = bitcast double* [[E]] to i8*
+  // CHECK: store i8* [[E_CAST]], i8** [[PTR1]], align
+  // CHECK: [[ARG_RL:%.+]] = bitcast [[RLT]]* [[RL]] to i8*
+  // CHECK: [[RET:%.+]] = call i32 @__kmpc_nvptx_teams_reduce_nowait(i32 {{.+}}, i32 1, i[[SZ]] {{4|8}}, i8* [[ARG_RL]], void (i8*, i16, i16, i16)* [[SHUFFLE_REDUCE_FN:@.+]], void (i8*, i32)* [[WARP_COPY_FN:@.+]], void (i8*, i8*, i32, i32)* [[SCRATCH_COPY_FN:@.+]], void (i8*, i8*, i32, i32, i32)* [[LOAD_REDUCE_FN:@.+]])
+  // CHECK: [[COND:%.+]] = icmp eq i32 [[RET]], 1
+  // CHECK: br i1 [[COND]], label {{%?}}[[IFLABEL:.+]], label {{%?}}[[EXIT:.+]]
+  //
+  // CHECK: [[IFLABEL]]
+  // CHECK: [[E_INV:%.+]] = load double, double* [[E_IN:%.+]], align
+  // CHECK: [[EV:%.+]] = load double, double* [[E]], align
+  // CHECK: [[ADD:%.+]] = fadd double [[E_INV]], [[EV]]
+  // CHECK: store double [[ADD]], double* [[E_IN]], align
+  // CHECK: call void @__kmpc_nvptx_end_reduce_nowait(
+  // CHECK: br label %[[EXIT]]
+  //
+  // CHECK: [[EXIT]]
+  // CHECK: call void @__kmpc_kernel_deinit()
+
+  //
+  // Reduction function
+  // CHECK: define internal void [[REDUCTION_FUNC:@.+]](i8*, i8*)
+  // CHECK: [[VAR_RHS_REF:%.+]] = getelementptr inbounds [[RLT]], [[RLT]]* [[RED_LIST_RHS:%.+]], i[[SZ]] 0, i[[SZ]] 0
+  // CHECK: [[VAR_RHS_VOID:%.+]] = load i8*, i8** [[VAR_RHS_REF]],
+  // CHECK: [[VAR_RHS:%.+]] = bitcast i8* [[VAR_RHS_VOID]] to double*
+  //
+  // CHECK: [[VAR_LHS_REF:%.+]] = getelementptr inbounds [[RLT]], [[RLT]]* [[RED_LIST_LHS:%.+]], i[[SZ]] 0, i[[SZ]] 0
+  // CHECK: [[VAR_LHS_VOID:%.+]] = load i8*, i8** [[VAR_LHS_REF]],
+  // CHECK: [[VAR_LHS:%.+]] = bitcast i8* [[V

r295313 - [OpenCL][Doc] Added OpenCL vendor extension description to user manual doc

2017-02-16 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Thu Feb 16 06:49:29 2017
New Revision: 295313

URL: http://llvm.org/viewvc/llvm-project?rev=295313&view=rev
Log:
[OpenCL][Doc] Added OpenCL vendor extension description to user manual doc

Added description of a new feature that allows to specify
vendor extension in flexible way using compiler pragma instead
of modifying source code directly (committed in clang@r289979).

Review: D29829


Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=295313&r1=295312&r2=295313&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Thu Feb 16 06:49:29 2017
@@ -2073,6 +2073,8 @@ can be given manually.
 In this case the kernel code should contain ``#include `` just as a
 regular C include.
 
+.. _opencl_cl_ext:
+
 .. option:: -cl-ext
 
 Disables support of OpenCL extensions. All OpenCL targets provide a list
@@ -2194,6 +2196,41 @@ To enable modules for OpenCL:
 
  $ clang -target spir-unknown-unknown -c -emit-llvm -Xclang 
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path= test.cl
 
+OpenCL Extensions
+-
+
+All of the ``cl_khr_*`` extensions from `the official OpenCL specification
+`_
+up to and including version 2.0 are available and set per target depending on 
the
+support available in the specific architecture.
+
+It is possible to alter the default extensions setting per target using
+``-cl-ext`` flag. (See :ref:`flags description ` for more 
details).
+
+Vendor extensions can be added flexibly by declaring the list of types and
+functions associated with each extensions enclosed within the following
+compiler pragma directives:
+
+  .. code-block:: c
+
+   #pragma OPENCL EXTENSION the_new_extension_name : begin
+   // declare types and functions associated with the extension here
+   #pragma OPENCL EXTENSION the_new_extension_name : end
+
+For example, parsing the following code adds ``my_t`` type and ``my_func``
+function to the custom ``my_ext`` extension.
+
+  .. code-block:: c
+
+   #pragma OPENCL EXTENSION my_ext : begin
+   typedef struct{
+ int a;
+   }my_t;
+   void my_func(my_t);
+   #pragma OPENCL EXTENSION my_ext : end
+
+Declaring the same types in different vendor extensions is disallowed.
+
 OpenCL Metadata
 ---
 
@@ -2232,7 +2269,7 @@ does not have any effect on the IR. For
 `_
 
 
-opencl_hint_unroll
+opencl_unroll_hint
 ^^
 
 The implementation of this feature mirrors the unroll hint for C.


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


Re: r295279 - [cxx1z-constexpr-lambda] Implement captures - thus completing implementation of constexpr lambdas.

2017-02-16 Thread Faisal Vali via cfe-commits
Of course Richard - I'll be happy to bump that value for C++1z
hopefully later today.
Thanks!
Faisal Vali



On Wed, Feb 15, 2017 at 10:30 PM, Richard Smith  wrote:
> On 15 February 2017 at 20:12, Faisal Vali via cfe-commits
>  wrote:
>>
>> Author: faisalv
>> Date: Wed Feb 15 22:12:21 2017
>> New Revision: 295279
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=295279&view=rev
>> Log:
>> [cxx1z-constexpr-lambda] Implement captures - thus completing
>> implementation of constexpr lambdas.
>>
>> Enable evaluation of captures within constexpr lambdas by using a strategy
>> similar to that used in CodeGen:
>>   - when starting evaluation of a lambda's call operator, create a map
>> from VarDecl's to a closure's FieldDecls
>>   - every time a VarDecl (or '*this) that represents a capture is
>> encountered while evaluating the expression via the expression evaluator
>> (specifically the LValueEvaluator) in ExprConstant.cpp - it is replaced by
>> the corresponding FieldDecl LValue (an Lvalue-to-Rvalue conversion on this
>> LValue representation then determines the right rvalue when needed).
>>
>> Thanks to Richard Smith and Hubert Tong for their review and feedback!
>
>
> Awesome, thanks Faisal!
>
> Want to bump our value for __cpp_constexpr to 201603 in C++1z mode to
> advertise support for this?
>
>>
>> https://reviews.llvm.org/D29748
>>
>>
>> Modified:
>> cfe/trunk/lib/AST/ExprConstant.cpp
>> cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
>>
>> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=295279&r1=295278&r2=295279&view=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
>> +++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Feb 15 22:12:21 2017
>> @@ -425,6 +425,17 @@ namespace {
>>  /// Index - The call index of this call.
>>  unsigned Index;
>>
>> +// FIXME: Adding this to every 'CallStackFrame' may have a nontrivial
>> impact
>> +// on the overall stack usage of deeply-recursing constexpr
>> evaluataions.
>> +// (We should cache this map rather than recomputing it repeatedly.)
>> +// But let's try this and see how it goes; we can look into caching
>> the map
>> +// as a later change.
>> +
>> +/// LambdaCaptureFields - Mapping from captured variables/this to
>> +/// corresponding data members in the closure class.
>> +llvm::DenseMap LambdaCaptureFields;
>> +FieldDecl *LambdaThisCaptureField;
>> +
>>  CallStackFrame(EvalInfo &Info, SourceLocation CallLoc,
>> const FunctionDecl *Callee, const LValue *This,
>> APValue *Arguments);
>> @@ -2279,6 +2290,10 @@ static bool HandleLValueComplexElement(E
>>return true;
>>  }
>>
>> +static bool handleLValueToRValueConversion(EvalInfo &Info, const Expr
>> *Conv,
>> +   QualType Type, const LValue
>> &LVal,
>> +   APValue &RVal);
>> +
>>  /// Try to evaluate the initializer for a variable declaration.
>>  ///
>>  /// \param Info   Information about the ongoing evaluation.
>> @@ -2290,6 +2305,7 @@ static bool HandleLValueComplexElement(E
>>  static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
>>  const VarDecl *VD, CallStackFrame *Frame,
>>  APValue *&Result) {
>> +
>>// If this is a parameter to an active constexpr function call, perform
>>// argument substitution.
>>if (const ParmVarDecl *PVD = dyn_cast(VD)) {
>> @@ -4180,6 +4196,10 @@ static bool HandleFunctionCall(SourceLoc
>>return false;
>>  This->moveInto(Result);
>>  return true;
>> +  } else if (MD && isLambdaCallOperator(MD)) {
>> +// We're in a lambda; determine the lambda capture field maps.
>> +MD->getParent()->getCaptureFields(Frame.LambdaCaptureFields,
>> +  Frame.LambdaThisCaptureField);
>>}
>>
>>StmtResult Ret = {Result, ResultSlot};
>> @@ -5041,6 +5061,33 @@ bool LValueExprEvaluator::VisitDeclRefEx
>>
>>
>>  bool LValueExprEvaluator::VisitVarDecl(const Expr *E, const VarDecl *VD)
>> {
>> +
>> +  // If we are within a lambda's call operator, check whether the 'VD'
>> referred
>> +  // to within 'E' actually represents a lambda-capture that maps to a
>> +  // data-member/field within the closure object, and if so, evaluate to
>> the
>> +  // field or what the field refers to.
>> +  if (Info.CurrentCall && isLambdaCallOperator(Info.CurrentCall->Callee))
>> {
>> +if (auto *FD = Info.CurrentCall->LambdaCaptureFields.lookup(VD)) {
>> +  if (Info.checkingPotentialConstantExpression())
>> +return false;
>> +  // Start with 'Result' referring to the complete closure object...
>> +  Result = *Info.CurrentCall->This;
>> +  // ... then update it to refer to the field of the closure object

[PATCH] D29879: [OpenMP] Teams reduction on the NVPTX device.

2017-02-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D29879



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


[clang-tools-extra] r295317 - Fix clang-move test after clang-format update r295312

2017-02-16 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Thu Feb 16 07:17:38 2017
New Revision: 295317

URL: http://llvm.org/viewvc/llvm-project?rev=295317&view=rev
Log:
Fix clang-move test after clang-format update r295312

Modified:
clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp

Modified: clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp?rev=295317&r1=295316&r2=295317&view=diff
==
--- clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp Thu Feb 16 
07:17:38 2017
@@ -65,7 +65,7 @@ const char TestCC[] = "#include \"foo.h\
   "static int kConstInt2 = 1;\n"
   "\n"
   "/** comment4\n"
-  "*/\n"
+  " */\n"
   "static int help() {\n"
   "  int a = 0;\n"
   "  return a;\n"
@@ -120,7 +120,7 @@ const char ExpectedTestCC[] = "#include
   "static int kConstInt2 = 1;\n"
   "\n"
   "/** comment4\n"
-  "*/\n"
+  " */\n"
   "static int help() {\n"
   "  int a = 0;\n"
   "  return a;\n"
@@ -174,7 +174,7 @@ const char ExpectedNewCC[] = "namespace
  "static int kConstInt2 = 1;\n"
  "\n"
  "/** comment4\n"
- "*/\n"
+ " */\n"
  "static int help() {\n"
  "  int a = 0;\n"
  "  return a;\n"


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


[PATCH] D29943: [clang-format] Align block comment decorations

2017-02-16 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

Maybe this could be added to the release notes?


Repository:
  rL LLVM

https://reviews.llvm.org/D29943



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


[PATCH] D30035: Add const to function parameters

2017-02-16 Thread Sebastian Pop via Phabricator via cfe-commits
sebpop added a comment.

Looks good to me.


https://reviews.llvm.org/D30035



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


[PATCH] D30025: [compiler-rt] [builtins] Fix building atomic.c with GCC

2017-02-16 Thread David Chisnall via Phabricator via cfe-commits
theraven added a comment.

No, it's a bug in clang.  Clang does not reject other functions that are used 
to implement builtins (if it did, compiler-rt would be a lot more difficult to 
build).


Repository:
  rL LLVM

https://reviews.llvm.org/D30025



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


[PATCH] D29830: [OpenCL][Doc] Relase 4.0 notes for OpenCL

2017-02-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia closed this revision.
Anastasia added a comment.

Committed to release40@295315


https://reviews.llvm.org/D29830



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


[PATCH] D28058: [OpenCL] Correct ndrange_t implementation

2017-02-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia closed this revision.
Anastasia added a comment.

Committed in 295311


https://reviews.llvm.org/D28058



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


r295319 - [OpenMP] Parallel reduction on the NVPTX device.

2017-02-16 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Thu Feb 16 08:03:36 2017
New Revision: 295319

URL: http://llvm.org/viewvc/llvm-project?rev=295319&view=rev
Log:
[OpenMP] Parallel reduction on the NVPTX device.

This patch implements codegen for the reduction clause on
any parallel construct for elementary data types.  An efficient
implementation requires hierarchical reduction within a
warp and a threadblock.  It is complicated by the fact that
variables declared in the stack of a CUDA thread cannot be
shared with other threads.

The patch creates a struct to hold reduction variables and
a number of helper functions.  The OpenMP runtime on the GPU
implements reduction algorithms that uses these helper
functions to perform reductions within a team.  Variables are
shared between CUDA threads using shuffle intrinsics.

An implementation of reductions on the NVPTX device is
substantially different to that of CPUs.  However, this patch
is written so that there are minimal changes to the rest of
OpenMP codegen.

The implemented design allows the compiler and runtime to be
decoupled, i.e., the runtime does not need to know of the
reduction operation(s), the type of the reduction variable(s),
or the number of reductions.  The design also allows reuse of
host codegen, with appropriate specialization for the NVPTX
device.

While the patch does introduce a number of abstractions, the
expected use case calls for inlining of the GPU OpenMP runtime.
After inlining and optimizations in LLVM, these abstractions
are unwound and performance of OpenMP reductions is comparable
to CUDA-canonical code.

Patch by Tian Jin in collaboration with Arpith Jacob

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29758

Added:
cfe/trunk/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=295319&r1=295318&r2=295319&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Feb 16 08:03:36 2017
@@ -4257,12 +4257,10 @@ static void emitReductionCombiner(CodeGe
   CGF.EmitIgnoredExpr(ReductionOp);
 }
 
-static llvm::Value *emitReductionFunction(CodeGenModule &CGM,
-  llvm::Type *ArgsType,
-  ArrayRef Privates,
-  ArrayRef LHSExprs,
-  ArrayRef RHSExprs,
-  ArrayRef ReductionOps) 
{
+llvm::Value *CGOpenMPRuntime::emitReductionFunction(
+CodeGenModule &CGM, llvm::Type *ArgsType, ArrayRef Privates,
+ArrayRef LHSExprs, ArrayRef RHSExprs,
+ArrayRef ReductionOps) {
   auto &C = CGM.getContext();
 
   // void reduction_func(void *LHSArg, void *RHSArg);
@@ -4345,11 +4343,11 @@ static llvm::Value *emitReductionFunctio
   return Fn;
 }
 
-static void emitSingleReductionCombiner(CodeGenFunction &CGF,
-const Expr *ReductionOp,
-const Expr *PrivateRef,
-const DeclRefExpr *LHS,
-const DeclRefExpr *RHS) {
+void CGOpenMPRuntime::emitSingleReductionCombiner(CodeGenFunction &CGF,
+  const Expr *ReductionOp,
+  const Expr *PrivateRef,
+  const DeclRefExpr *LHS,
+  const DeclRefExpr *RHS) {
   if (PrivateRef->getType()->isArrayType()) {
 // Emit reduction for array section.
 auto *LHSVar = cast(LHS->getDecl());
@@ -4369,9 +4367,13 @@ void CGOpenMPRuntime::emitReduction(Code
 ArrayRef LHSExprs,
 ArrayRef RHSExprs,
 ArrayRef ReductionOps,
-bool WithNowait, bool SimpleReduction) {
+ReductionOptionsTy Options) {
   if (!CGF.HaveInsertPoint())
 return;
+
+  bool WithNowait = Options.WithNowait;
+  bool SimpleReduction = Options.SimpleReduction;
+
   // Next code should be emitted for reduction:
   //
   // static kmp_critical_name lock = { 0 };
@@ -4513,12 +4515,13 @@ void CGOpenMPRuntime::emitReduction(Code
   };
   auto &&CodeGen = [&Privates, &LHSExprs, &RHSExprs, &ReductionOps](
   CodeGenFunction &CGF, PrePostActionTy &Action) {
+auto &RT = CGF.CGM.getOpenMP

[PATCH] D29758: [OpenMP] Parallel reduction on the NVPTX device.

2017-02-16 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295319: [OpenMP] Parallel reduction on the NVPTX device. 
(authored by arpith).

Changed prior to commit:
  https://reviews.llvm.org/D29758?vs=88149&id=88726#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29758

Files:
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp

Index: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
===
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
@@ -67,12 +67,6 @@
   /// \brief Signal termination of Spmd mode execution.
   void emitSpmdEntryFooter(CodeGenFunction &CGF, EntryFunctionState &EST);
 
-  /// \brief Returns specified OpenMP runtime function for the current OpenMP
-  /// implementation.  Specialized for the NVPTX device.
-  /// \param Function OpenMP runtime function.
-  /// \return Specified function.
-  llvm::Constant *createNVPTXRuntimeFunction(unsigned Function);
-
   //
   // Base class overrides.
   //
@@ -248,7 +242,32 @@
 ArrayRef CapturedVars,
 const Expr *IfCond) override;
 
-public:
+  /// Emit a code for reduction clause.
+  ///
+  /// \param Privates List of private copies for original reduction arguments.
+  /// \param LHSExprs List of LHS in \a ReductionOps reduction operations.
+  /// \param RHSExprs List of RHS in \a ReductionOps reduction operations.
+  /// \param ReductionOps List of reduction operations in form 'LHS binop RHS'
+  /// or 'operator binop(LHS, RHS)'.
+  /// \param Options List of options for reduction codegen:
+  /// WithNowait true if parent directive has also nowait clause, false
+  /// otherwise.
+  /// SimpleReduction Emit reduction operation only. Used for omp simd
+  /// directive on the host.
+  /// ReductionKind The kind of reduction to perform.
+  virtual void emitReduction(CodeGenFunction &CGF, SourceLocation Loc,
+ ArrayRef Privates,
+ ArrayRef LHSExprs,
+ ArrayRef RHSExprs,
+ ArrayRef ReductionOps,
+ ReductionOptionsTy Options) override;
+
+  /// Returns specified OpenMP runtime function for the current OpenMP
+  /// implementation.  Specialized for the NVPTX device.
+  /// \param Function OpenMP runtime function.
+  /// \return Specified function.
+  llvm::Constant *createNVPTXRuntimeFunction(unsigned Function);
+
   /// Target codegen is specialized based on two programming models: the
   /// 'generic' fork-join model of OpenMP, and a more GPU efficient 'spmd'
   /// model for constructs like 'target parallel' that support it.
Index: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
===
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1190,7 +1190,7 @@
 }
 
 void CodeGenFunction::EmitOMPReductionClauseFinal(
-const OMPExecutableDirective &D) {
+const OMPExecutableDirective &D, const OpenMPDirectiveKind ReductionKind) {
   if (!HaveInsertPoint())
 return;
   llvm::SmallVector Privates;
@@ -1206,14 +1206,15 @@
 ReductionOps.append(C->reduction_ops().begin(), C->reduction_ops().end());
   }
   if (HasAtLeastOneReduction) {
+bool WithNowait = D.getSingleClause() ||
+  isOpenMPParallelDirective(D.getDirectiveKind()) ||
+  D.getDirectiveKind() == OMPD_simd;
+bool SimpleReduction = D.getDirectiveKind() == OMPD_simd;
 // Emit nowait reduction if nowait clause is present or directive is a
 // parallel directive (it always has implicit barrier).
 CGM.getOpenMPRuntime().emitReduction(
 *this, D.getLocEnd(), Privates, LHSExprs, RHSExprs, ReductionOps,
-D.getSingleClause() ||
-isOpenMPParallelDirective(D.getDirectiveKind()) ||
-D.getDirectiveKind() == OMPD_simd,
-D.getDirectiveKind() == OMPD_simd);
+{WithNowait, SimpleReduction, ReductionKind});
   }
 }
 
@@ -1295,7 +1296,7 @@
 CGF.EmitOMPReductionClauseInit(S, PrivateScope);
 (void)PrivateScope.Privatize();
 CGF.EmitStmt(cast(S.getAssociatedStmt())->getCapturedStmt());
-CGF.EmitOMPReductionClauseFinal(S);
+CGF.EmitOMPReductionClauseFinal(S, /*ReductionKind=*/OMPD_parallel);
   };
   emitCommonOMPParallelDirective(*this, S, OMPD_parallel, CodeGen);
   emitPostUpdateForReductionClause(
@@ -1708,7 +1709,7 @@
   // Emit final copy of the lastprivate variables at the end of loops.
   if (HasLastprivateClause)
 CGF.EmitOMPLastprivateClauseFina

[PATCH] D29829: [OpenCL][Doc] Description for adding OpenCL vendor extension in user manual

2017-02-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia closed this revision.
Anastasia added a comment.

Committed in 295313!


https://reviews.llvm.org/D29829



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


[PATCH] D29724: [Driver] Report available language standards on user error

2017-02-16 Thread Paweł Żukowski via Phabricator via cfe-commits
idlecode closed this revision.
idlecode added a comment.

Committed as r295113


https://reviews.llvm.org/D29724



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


r295320 - Silence sign compare warning. NFC.

2017-02-16 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Feb 16 08:08:41 2017
New Revision: 295320

URL: http://llvm.org/viewvc/llvm-project?rev=295320&view=rev
Log:
Silence sign compare warning. NFC.

ExprConstant.cpp:6344:20: warning: comparison of integers of different
signs: 'const size_t' (aka 'const unsigned long') and 'typename
iterator_traits::difference_type' (aka 'long')
[-Wsign-compare]

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=295320&r1=295319&r2=295320&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Feb 16 08:08:41 2017
@@ -6340,12 +6340,12 @@ bool RecordExprEvaluator::VisitLambdaExp
   
   const size_t NumFields =
   std::distance(ClosureClass->field_begin(), ClosureClass->field_end());
-  
-  assert(NumFields ==
-std::distance(E->capture_init_begin(), E->capture_init_end()) &&
-"The number of lambda capture initializers should equal the number of "
-"fields within the closure type");
-  
+
+  assert(NumFields == (size_t)std::distance(E->capture_init_begin(),
+E->capture_init_end()) &&
+ "The number of lambda capture initializers should equal the number of 
"
+ "fields within the closure type");
+
   Result = APValue(APValue::UninitStruct(), /*NumBases*/0, NumFields);
   // Iterate through all the lambda's closure object's fields and initialize
   // them.


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


[PATCH] D30025: [compiler-rt] [builtins] Fix building atomic.c with GCC

2017-02-16 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

Note that the normal compiler-rt functions have a different name than the 
builtins they provide, at least from the C frontend view.


Repository:
  rL LLVM

https://reviews.llvm.org/D30025



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


RE: D29829: [OpenCL][Doc] Description for adding OpenCL vendor extension in user manual

2017-02-16 Thread Anastasia Stulova via cfe-commits
Hans, could we merge this documentation only change (r295313) in release40 
branch. I can commit myself if needed. :)

Thanks in advance,
Anastasia

-Original Message-
From: Anastasia Stulova via Phabricator [mailto:revi...@reviews.llvm.org]
Sent: 16 February 2017 14:15
To: Anastasia Stulova; yaxun@amd.com
Cc: cfe-commits@lists.llvm.org
Subject: [PATCH] D29829: [OpenCL][Doc] Description for adding OpenCL vendor 
extension in user manual

Anastasia closed this revision.
Anastasia added a comment.

Committed in 295313!


https://reviews.llvm.org/D29829



IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29764: [OpenCL] Blocks cannot capture/reference another block

2017-02-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia closed this revision.
Anastasia added a comment.

Committed in r295307!


https://reviews.llvm.org/D29764



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


r295323 - Revert r295319 while investigating buildbot failure.

2017-02-16 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Thu Feb 16 08:25:35 2017
New Revision: 295323

URL: http://llvm.org/viewvc/llvm-project?rev=295323&view=rev
Log:
Revert r295319 while investigating buildbot failure.

Removed:
cfe/trunk/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=295323&r1=295322&r2=295323&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Feb 16 08:25:35 2017
@@ -4257,10 +4257,12 @@ static void emitReductionCombiner(CodeGe
   CGF.EmitIgnoredExpr(ReductionOp);
 }
 
-llvm::Value *CGOpenMPRuntime::emitReductionFunction(
-CodeGenModule &CGM, llvm::Type *ArgsType, ArrayRef Privates,
-ArrayRef LHSExprs, ArrayRef RHSExprs,
-ArrayRef ReductionOps) {
+static llvm::Value *emitReductionFunction(CodeGenModule &CGM,
+  llvm::Type *ArgsType,
+  ArrayRef Privates,
+  ArrayRef LHSExprs,
+  ArrayRef RHSExprs,
+  ArrayRef ReductionOps) 
{
   auto &C = CGM.getContext();
 
   // void reduction_func(void *LHSArg, void *RHSArg);
@@ -4343,11 +4345,11 @@ llvm::Value *CGOpenMPRuntime::emitReduct
   return Fn;
 }
 
-void CGOpenMPRuntime::emitSingleReductionCombiner(CodeGenFunction &CGF,
-  const Expr *ReductionOp,
-  const Expr *PrivateRef,
-  const DeclRefExpr *LHS,
-  const DeclRefExpr *RHS) {
+static void emitSingleReductionCombiner(CodeGenFunction &CGF,
+const Expr *ReductionOp,
+const Expr *PrivateRef,
+const DeclRefExpr *LHS,
+const DeclRefExpr *RHS) {
   if (PrivateRef->getType()->isArrayType()) {
 // Emit reduction for array section.
 auto *LHSVar = cast(LHS->getDecl());
@@ -4367,13 +4369,9 @@ void CGOpenMPRuntime::emitReduction(Code
 ArrayRef LHSExprs,
 ArrayRef RHSExprs,
 ArrayRef ReductionOps,
-ReductionOptionsTy Options) {
+bool WithNowait, bool SimpleReduction) {
   if (!CGF.HaveInsertPoint())
 return;
-
-  bool WithNowait = Options.WithNowait;
-  bool SimpleReduction = Options.SimpleReduction;
-
   // Next code should be emitted for reduction:
   //
   // static kmp_critical_name lock = { 0 };
@@ -4515,13 +4513,12 @@ void CGOpenMPRuntime::emitReduction(Code
   };
   auto &&CodeGen = [&Privates, &LHSExprs, &RHSExprs, &ReductionOps](
   CodeGenFunction &CGF, PrePostActionTy &Action) {
-auto &RT = CGF.CGM.getOpenMPRuntime();
 auto IPriv = Privates.begin();
 auto ILHS = LHSExprs.begin();
 auto IRHS = RHSExprs.begin();
 for (auto *E : ReductionOps) {
-  RT.emitSingleReductionCombiner(CGF, E, *IPriv, cast(*ILHS),
- cast(*IRHS));
+  emitSingleReductionCombiner(CGF, E, *IPriv, cast(*ILHS),
+  cast(*IRHS));
   ++IPriv;
   ++ILHS;
   ++IRHS;

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=295323&r1=295322&r2=295323&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Thu Feb 16 08:25:35 2017
@@ -893,32 +893,6 @@ public:
 OpenMPDirectiveKind InnermostKind,
 const RegionCodeGenTy &CodeGen,
 bool HasCancel = false);
-
-  /// Emits reduction function.
-  /// \param ArgsType Array type containing pointers to reduction variables.
-  /// \param Privates List of private copies for original reduction arguments.
-  /// \param LHSExprs List of LHS in \a ReductionOps reduction operations.
-  /// \param RHSExprs List of RHS in \a ReductionOps reduction operations.
-  /// \param ReductionOps List of reduction operations in form 'LHS binop RHS'
-  /// or 'operator binop(LHS, RHS)'.
-  llvm::Value *em

[PATCH] D28172: [libcxx] Remove unexpected handlers in C++17

2017-02-16 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

LGTM. Sorry for the slow response.


https://reviews.llvm.org/D28172



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


[PATCH] D30045: Remove `std::random_shuffle` in C++17

2017-02-16 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4190  removed 
`random_shuffle` from C++1z. (and other stuff)

Wrap all the random_shuffle bits in an #ifdef so they disappear when compiling 
with `-std=c++1z` or later.

Introduce a new configuration option, 
`_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE` which allows user code to 
continue using `random_shuffle` in C++1z mode if desired.

Add a test for `_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE`, and mark all the 
rest of the `random_shuffle` tests to XFAIL for c++1z


https://reviews.llvm.org/D30045

Files:
  include/algorithm
  
test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
  
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
  
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp

Index: test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
===
--- test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
+++ test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 // 
+// REQUIRES-ANY: c++98, c++03, c++11, c++14
 
 // template Rand>
 //   requires ShuffleIterator
Index: test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
===
--- test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
+++ test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 // 
+// REQUIRES-ANY: c++98, c++03, c++11, c++14
 
 // template
 //   requires ShuffleIterator
Index: test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
===
--- test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
+++ test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
@@ -0,0 +1,46 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template 
+// void
+// random_shuffle(RandomAccessIterator first, RandomAccessIterator last);
+// 
+// template 
+// void
+// random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
+//RandomNumberGenerator& rand);
+
+//
+//  In C++17, random_shuffle has been removed.
+//  However, for backwards compatibility, if _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
+//  is defined before including , then random_shuffle will be restored.
+
+#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
+
+#include 
+#include 
+
+struct gen
+{
+std::ptrdiff_t operator()(std::ptrdiff_t n)
+{
+return n-1;
+}
+};
+
+
+int main()
+{
+std::vector v;
+std::random_shuffle(v.begin(), v.end());
+gen r;
+std::random_shuffle(v.begin(), v.end(), r);
+}
Index: include/algorithm
===
--- include/algorithm
+++ include/algorithm
@@ -281,12 +281,12 @@
 
 template 
 void
-random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14
+random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
 
 template 
 void
 random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
-   RandomNumberGenerator& rand);  // deprecated in C++14
+   RandomNumberGenerator& rand);  // deprecated in C++14, removed in C++17
 
 template
@@ -3026,6 +3026,7 @@
 return static_cast(__u + __p.a());
 }
 
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE)
 class _LIBCPP_TYPE_VIS __rs_default;
 
 _LIBCPP_FUNC_VIS __rs_default __rs_get();
@@ -3095,6 +3096,7 @@
 }
 }
 }
+#endif
 
 template 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r291905 - [Sema] Add warning for unused lambda captures

2017-02-16 Thread Aaron Ballman via cfe-commits
On Wed, Feb 15, 2017 at 7:42 PM, Richard Smith via cfe-commits
 wrote:
> https://bugs.llvm.org/show_bug.cgi?id=31977 makes the good point that this
> is warning on a certain idiomatic use of capture-by-value to extend the
> lifetime of an RAII object; consider:
>
>   shared_ptr p = /*...*/;
>   int *q = &p->n;
>   return [=, p] { return *q++; }
>
> Here, we'll warn that the capture of p is unused, but it's not -- the "use"
> is to hold a reference to keep the Foo object alive.
>
> I'd suggest suppressing the warning for a by-copy capture of a variable with
> a non-trivial destructor (this mirrors what we do for -Wunused-variable).

Thank you for the compelling example -- I agree, that's a good
solution to the issue.

~Aaron

>
> On 13 January 2017 at 07:01, Malcolm Parsons via cfe-commits
>  wrote:
>>
>> Author: malcolm.parsons
>> Date: Fri Jan 13 09:01:06 2017
>> New Revision: 291905
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=291905&view=rev
>> Log:
>> [Sema] Add warning for unused lambda captures
>>
>> Summary:
>> Warn when a lambda explicitly captures something that is not used in its
>> body.
>>
>> The warning is part of -Wunused and can be enabled with
>> -Wunused-lambda-capture.
>>
>> Reviewers: rsmith, arphaman, jbcoe, aaron.ballman
>>
>> Subscribers: Quuxplusone, arphaman, cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D28467
>>
>> Added:
>> cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/include/clang/Sema/ScopeInfo.h
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/lib/Sema/SemaExpr.cpp
>> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>> cfe/trunk/lib/Sema/SemaLambda.cpp
>> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp
>> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp
>> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp
>> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp
>> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp
>> cfe/trunk/test/SemaCXX/uninitialized.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=291905&r1=291904&r2=291905&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jan 13 09:01:06
>> 2017
>> @@ -480,6 +480,7 @@ def UnusedFunction : DiagGroup<"unused-f
>>  def UnusedMemberFunction : DiagGroup<"unused-member-function",
>>   [UnneededMemberFunction]>;
>>  def UnusedLabel : DiagGroup<"unused-label">;
>> +def UnusedLambdaCapture : DiagGroup<"unused-lambda-capture">;
>>  def UnusedParameter : DiagGroup<"unused-parameter">;
>>  def UnusedResult : DiagGroup<"unused-result">;
>>  def PotentiallyEvaluatedExpression :
>> DiagGroup<"potentially-evaluated-expression">;
>> @@ -617,8 +618,9 @@ def Unused : DiagGroup<"unused",
>> [UnusedArgument, UnusedFunction, UnusedLabel,
>>  // UnusedParameter, (matches GCC's behavior)
>>  // UnusedMemberFunction, (clean-up llvm before
>> enabling)
>> -UnusedPrivateField, UnusedLocalTypedef,
>> -UnusedValue, UnusedVariable,
>> UnusedPropertyIvar]>,
>> +UnusedPrivateField, UnusedLambdaCapture,
>> +UnusedLocalTypedef, UnusedValue, UnusedVariable,
>> +UnusedPropertyIvar]>,
>>  DiagCategory<"Unused Entity Issue">;
>>
>>  // Format settings.
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=291905&r1=291904&r2=291905&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jan 13
>> 09:01:06 2017
>> @@ -316,6 +316,9 @@ def warn_unneeded_member_function : Warn
>>InGroup, DefaultIgnore;
>>  def warn_unused_private_field: Warning<"private field %0 is not used">,
>>InGroup, DefaultIgnore;
>> +def warn_unused_lambda_capture: Warning<"lambda capture %0 is not "
>> +  "%select{used|required to be captured for use in an unevaluated
>> context}1">,
>> +  InGroup, DefaultIgnore;
>>
>>  def warn_parameter_size: Warning<
>>"%0 is a large (%1 bytes) pass-by-value argument; "
>>
>> Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=291905&r1=291904&r2=291905&view=diff
>>
>> =

[libcxx] r295330 - math: correct the MSVCRT condition

2017-02-16 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Feb 16 09:47:50 2017
New Revision: 295330

URL: http://llvm.org/viewvc/llvm-project?rev=295330&view=rev
Log:
math: correct the MSVCRT condition

Fixes a number of tests in the testsuite on Windows.

Modified:
libcxx/trunk/include/cmath
libcxx/trunk/include/math.h

Modified: libcxx/trunk/include/cmath
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cmath?rev=295330&r1=295329&r2=295330&view=diff
==
--- libcxx/trunk/include/cmath (original)
+++ libcxx/trunk/include/cmath Thu Feb 16 09:47:50 2017
@@ -398,7 +398,7 @@ using ::cbrtf;
 using ::copysign;
 using ::copysignf;
 
-#if !defined(_LIBCPP_MSVCRT) || ((_VC_CRT_NAJOR_VERSION-0) >= 14)
+#if !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
 using ::erf;
 using ::erff;
 using ::erfc;
@@ -435,7 +435,7 @@ using ::lrint;
 using ::lrintf;
 using ::lround;
 using ::lroundf;
-#endif // _LIBCPP_MSVCRT
+#endif // !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
 
 using ::nan;
 using ::nanf;

Modified: libcxx/trunk/include/math.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/math.h?rev=295330&r1=295329&r2=295330&view=diff
==
--- libcxx/trunk/include/math.h (original)
+++ libcxx/trunk/include/math.h Thu Feb 16 09:47:50 2017
@@ -1020,7 +1020,7 @@ copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NO
 return ::copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
 }
 
-#if !defined(_LIBCPP_MSVCRT) || ((_VC_CRT_MAJOR_VERSION-0) >= 14)
+#if !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
 
 // erf
 
@@ -1404,7 +1404,7 @@ inline _LIBCPP_INLINE_VISIBILITY
 typename std::enable_if::value, double>::type
 trunc(_A1 __lcpp_x) _NOEXCEPT {return ::trunc((double)__lcpp_x);}
 
-#endif // !defined(_LIBCPP_MSVCRT) || ((_VC_CRT_MAJOR_VERSION-0) >= 14)
+#endif // !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
 
 } // extern "C++"
 


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


[libcxx] r295329 - threading_support: make __thread_sleep_for be alertable

2017-02-16 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Feb 16 09:47:45 2017
New Revision: 295329

URL: http://llvm.org/viewvc/llvm-project?rev=295329&view=rev
Log:
threading_support: make __thread_sleep_for be alertable

On Windows, we were using `Sleep` which is not alertable.  This means
that if the thread was used for a user APC or WinProc handling and
thread::sleep was used, we could potentially dead lock.  Use `SleepEx`
with an alertable sleep, resuming until the time has expired if we are
awoken early.

Modified:
libcxx/trunk/include/__threading_support

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=295329&r1=295328&r2=295329&view=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Thu Feb 16 09:47:45 2017
@@ -589,11 +589,14 @@ void __libcpp_thread_yield()
 
 void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns)
 {
-  using namespace chrono;
+  using namespace _VSTD::chrono;
+
   // round-up to the nearest milisecond
   milliseconds __ms =
   duration_cast(__ns + chrono::nanoseconds(99));
-  Sleep(__ms.count());
+  auto start = system_clock::now();
+  while (::SleepEx((__ms - (system_clock::now() - start)).count(),
+   TRUE) == WAIT_IO_COMPLETION);
 }
 
 // Thread Local Storage


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


r295333 - [OpenMP] Parallel reduction on the NVPTX device.

2017-02-16 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Thu Feb 16 10:20:16 2017
New Revision: 295333

URL: http://llvm.org/viewvc/llvm-project?rev=295333&view=rev
Log:
[OpenMP] Parallel reduction on the NVPTX device.

This patch implements codegen for the reduction clause on
any parallel construct for elementary data types.  An efficient
implementation requires hierarchical reduction within a
warp and a threadblock.  It is complicated by the fact that
variables declared in the stack of a CUDA thread cannot be
shared with other threads.

The patch creates a struct to hold reduction variables and
a number of helper functions.  The OpenMP runtime on the GPU
implements reduction algorithms that uses these helper
functions to perform reductions within a team.  Variables are
shared between CUDA threads using shuffle intrinsics.

An implementation of reductions on the NVPTX device is
substantially different to that of CPUs.  However, this patch
is written so that there are minimal changes to the rest of
OpenMP codegen.

The implemented design allows the compiler and runtime to be
decoupled, i.e., the runtime does not need to know of the
reduction operation(s), the type of the reduction variable(s),
or the number of reductions.  The design also allows reuse of
host codegen, with appropriate specialization for the NVPTX
device.

While the patch does introduce a number of abstractions, the
expected use case calls for inlining of the GPU OpenMP runtime.
After inlining and optimizations in LLVM, these abstractions
are unwound and performance of OpenMP reductions is comparable
to CUDA-canonical code.

Patch by Tian Jin in collaboration with Arpith Jacob

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29758

Added:
cfe/trunk/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=295333&r1=295332&r2=295333&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Feb 16 10:20:16 2017
@@ -4257,12 +4257,10 @@ static void emitReductionCombiner(CodeGe
   CGF.EmitIgnoredExpr(ReductionOp);
 }
 
-static llvm::Value *emitReductionFunction(CodeGenModule &CGM,
-  llvm::Type *ArgsType,
-  ArrayRef Privates,
-  ArrayRef LHSExprs,
-  ArrayRef RHSExprs,
-  ArrayRef ReductionOps) 
{
+llvm::Value *CGOpenMPRuntime::emitReductionFunction(
+CodeGenModule &CGM, llvm::Type *ArgsType, ArrayRef Privates,
+ArrayRef LHSExprs, ArrayRef RHSExprs,
+ArrayRef ReductionOps) {
   auto &C = CGM.getContext();
 
   // void reduction_func(void *LHSArg, void *RHSArg);
@@ -4345,11 +4343,11 @@ static llvm::Value *emitReductionFunctio
   return Fn;
 }
 
-static void emitSingleReductionCombiner(CodeGenFunction &CGF,
-const Expr *ReductionOp,
-const Expr *PrivateRef,
-const DeclRefExpr *LHS,
-const DeclRefExpr *RHS) {
+void CGOpenMPRuntime::emitSingleReductionCombiner(CodeGenFunction &CGF,
+  const Expr *ReductionOp,
+  const Expr *PrivateRef,
+  const DeclRefExpr *LHS,
+  const DeclRefExpr *RHS) {
   if (PrivateRef->getType()->isArrayType()) {
 // Emit reduction for array section.
 auto *LHSVar = cast(LHS->getDecl());
@@ -4369,9 +4367,13 @@ void CGOpenMPRuntime::emitReduction(Code
 ArrayRef LHSExprs,
 ArrayRef RHSExprs,
 ArrayRef ReductionOps,
-bool WithNowait, bool SimpleReduction) {
+ReductionOptionsTy Options) {
   if (!CGF.HaveInsertPoint())
 return;
+
+  bool WithNowait = Options.WithNowait;
+  bool SimpleReduction = Options.SimpleReduction;
+
   // Next code should be emitted for reduction:
   //
   // static kmp_critical_name lock = { 0 };
@@ -4513,12 +4515,13 @@ void CGOpenMPRuntime::emitReduction(Code
   };
   auto &&CodeGen = [&Privates, &LHSExprs, &RHSExprs, &ReductionOps](
   CodeGenFunction &CGF, PrePostActionTy &Action) {
+auto &RT = CGF.CGM.getOpenMP

r295335 - [OpenMP] Teams reduction on the NVPTX device.

2017-02-16 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Thu Feb 16 10:48:49 2017
New Revision: 295335

URL: http://llvm.org/viewvc/llvm-project?rev=295335&view=rev
Log:
[OpenMP] Teams reduction on the NVPTX device.

This patch implements codegen for the reduction clause on
any teams construct for elementary data types.  It builds
on parallel reductions on the GPU.  Subsequently,
the team master writes to a unique location in a global
memory scratchpad.  The last team to do so loads and
reduces this array to calculate the final result.

This patch emits two helper functions that are used by
the OpenMP runtime on the GPU to perform reductions across
teams.

Patch by Tian Jin in collaboration with Arpith Jacob

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29879

Added:
cfe/trunk/test/OpenMP/nvptx_teams_reduction_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=295335&r1=295334&r2=295335&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Thu Feb 16 10:48:49 2017
@@ -56,6 +56,16 @@ enum OpenMPRTLFunctionNVPTX {
   /// lane_offset, int16_t shortCircuit),
   /// void (*kmp_InterWarpCopyFctPtr)(void* src, int32_t warp_num));
   OMPRTL_NVPTX__kmpc_parallel_reduce_nowait,
+  /// \brief Call to __kmpc_nvptx_teams_reduce_nowait(int32_t global_tid,
+  /// int32_t num_vars, size_t reduce_size, void *reduce_data,
+  /// void (*kmp_ShuffleReductFctPtr)(void *rhs, int16_t lane_id, int16_t
+  /// lane_offset, int16_t shortCircuit),
+  /// void (*kmp_InterWarpCopyFctPtr)(void* src, int32_t warp_num),
+  /// void (*kmp_CopyToScratchpadFctPtr)(void *reduce_data, void * scratchpad,
+  /// int32_t index, int32_t width),
+  /// void (*kmp_LoadReduceFctPtr)(void *reduce_data, void * scratchpad, 
int32_t
+  /// index, int32_t width, int32_t reduce))
+  OMPRTL_NVPTX__kmpc_teams_reduce_nowait,
   /// \brief Call to __kmpc_nvptx_end_reduce_nowait(int32_t global_tid);
   OMPRTL_NVPTX__kmpc_end_reduce_nowait
 };
@@ -125,6 +135,9 @@ enum MachineConfiguration : unsigned {
   /// computed as log_2(WarpSize).
   LaneIDBits = 5,
   LaneIDMask = WarpSize - 1,
+
+  /// Global memory alignment for performance.
+  GlobalMemoryAlignment = 256,
 };
 
 enum NamedBarrier : unsigned {
@@ -694,6 +707,49 @@ CGOpenMPRuntimeNVPTX::createNVPTXRuntime
 FnTy, /*Name=*/"__kmpc_nvptx_parallel_reduce_nowait");
 break;
   }
+  case OMPRTL_NVPTX__kmpc_teams_reduce_nowait: {
+// Build int32_t __kmpc_nvptx_teams_reduce_nowait(int32_t global_tid,
+// int32_t num_vars, size_t reduce_size, void *reduce_data,
+// void (*kmp_ShuffleReductFctPtr)(void *rhsData, int16_t lane_id, int16_t
+// lane_offset, int16_t shortCircuit),
+// void (*kmp_InterWarpCopyFctPtr)(void* src, int32_t warp_num),
+// void (*kmp_CopyToScratchpadFctPtr)(void *reduce_data, void * scratchpad,
+// int32_t index, int32_t width),
+// void (*kmp_LoadReduceFctPtr)(void *reduce_data, void * scratchpad,
+// int32_t index, int32_t width, int32_t reduce))
+llvm::Type *ShuffleReduceTypeParams[] = {CGM.VoidPtrTy, CGM.Int16Ty,
+ CGM.Int16Ty, CGM.Int16Ty};
+auto *ShuffleReduceFnTy =
+llvm::FunctionType::get(CGM.VoidTy, ShuffleReduceTypeParams,
+/*isVarArg=*/false);
+llvm::Type *InterWarpCopyTypeParams[] = {CGM.VoidPtrTy, CGM.Int32Ty};
+auto *InterWarpCopyFnTy =
+llvm::FunctionType::get(CGM.VoidTy, InterWarpCopyTypeParams,
+/*isVarArg=*/false);
+llvm::Type *CopyToScratchpadTypeParams[] = {CGM.VoidPtrTy, CGM.VoidPtrTy,
+CGM.Int32Ty, CGM.Int32Ty};
+auto *CopyToScratchpadFnTy =
+llvm::FunctionType::get(CGM.VoidTy, CopyToScratchpadTypeParams,
+/*isVarArg=*/false);
+llvm::Type *LoadReduceTypeParams[] = {
+CGM.VoidPtrTy, CGM.VoidPtrTy, CGM.Int32Ty, CGM.Int32Ty, CGM.Int32Ty};
+auto *LoadReduceFnTy =
+llvm::FunctionType::get(CGM.VoidTy, LoadReduceTypeParams,
+/*isVarArg=*/false);
+llvm::Type *TypeParams[] = {CGM.Int32Ty,
+CGM.Int32Ty,
+CGM.SizeTy,
+CGM.VoidPtrTy,
+ShuffleReduceFnTy->getPointerTo(),
+InterWarpCopyFnTy->getPointerTo(),
+CopyToScratchpadFnTy->getPointerTo(),
+LoadReduceFnTy->getPointerTo()};
+llvm::FunctionType *FnTy =
+llvm::FunctionType::get(CGM.Int32Ty, TypeParams, /*isVarArg=*/f

[PATCH] D29879: [OpenMP] Teams reduction on the NVPTX device.

2017-02-16 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295335: [OpenMP] Teams reduction on the NVPTX device. 
(authored by arpith).

Changed prior to commit:
  https://reviews.llvm.org/D29879?vs=88715&id=88746#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29879

Files:
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
  cfe/trunk/test/OpenMP/nvptx_teams_reduction_codegen.cpp

Index: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
===
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
@@ -3553,10 +3553,14 @@
 OMPPrivateScope PrivateScope(CGF);
 (void)CGF.EmitOMPFirstprivateClause(S, PrivateScope);
 CGF.EmitOMPPrivateClause(S, PrivateScope);
+CGF.EmitOMPReductionClauseInit(S, PrivateScope);
 (void)PrivateScope.Privatize();
 CGF.EmitStmt(cast(S.getAssociatedStmt())->getCapturedStmt());
+CGF.EmitOMPReductionClauseFinal(S, /*ReductionKind=*/OMPD_teams);
   };
   emitCommonOMPTeamsDirective(*this, S, OMPD_teams, CodeGen);
+  emitPostUpdateForReductionClause(
+  *this, S, [](CodeGenFunction &) -> llvm::Value * { return nullptr; });
 }
 
 static void emitTargetTeamsRegion(CodeGenFunction &CGF, PrePostActionTy &Action,
Index: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -56,6 +56,16 @@
   /// lane_offset, int16_t shortCircuit),
   /// void (*kmp_InterWarpCopyFctPtr)(void* src, int32_t warp_num));
   OMPRTL_NVPTX__kmpc_parallel_reduce_nowait,
+  /// \brief Call to __kmpc_nvptx_teams_reduce_nowait(int32_t global_tid,
+  /// int32_t num_vars, size_t reduce_size, void *reduce_data,
+  /// void (*kmp_ShuffleReductFctPtr)(void *rhs, int16_t lane_id, int16_t
+  /// lane_offset, int16_t shortCircuit),
+  /// void (*kmp_InterWarpCopyFctPtr)(void* src, int32_t warp_num),
+  /// void (*kmp_CopyToScratchpadFctPtr)(void *reduce_data, void * scratchpad,
+  /// int32_t index, int32_t width),
+  /// void (*kmp_LoadReduceFctPtr)(void *reduce_data, void * scratchpad, int32_t
+  /// index, int32_t width, int32_t reduce))
+  OMPRTL_NVPTX__kmpc_teams_reduce_nowait,
   /// \brief Call to __kmpc_nvptx_end_reduce_nowait(int32_t global_tid);
   OMPRTL_NVPTX__kmpc_end_reduce_nowait
 };
@@ -125,6 +135,9 @@
   /// computed as log_2(WarpSize).
   LaneIDBits = 5,
   LaneIDMask = WarpSize - 1,
+
+  /// Global memory alignment for performance.
+  GlobalMemoryAlignment = 256,
 };
 
 enum NamedBarrier : unsigned {
@@ -694,6 +707,49 @@
 FnTy, /*Name=*/"__kmpc_nvptx_parallel_reduce_nowait");
 break;
   }
+  case OMPRTL_NVPTX__kmpc_teams_reduce_nowait: {
+// Build int32_t __kmpc_nvptx_teams_reduce_nowait(int32_t global_tid,
+// int32_t num_vars, size_t reduce_size, void *reduce_data,
+// void (*kmp_ShuffleReductFctPtr)(void *rhsData, int16_t lane_id, int16_t
+// lane_offset, int16_t shortCircuit),
+// void (*kmp_InterWarpCopyFctPtr)(void* src, int32_t warp_num),
+// void (*kmp_CopyToScratchpadFctPtr)(void *reduce_data, void * scratchpad,
+// int32_t index, int32_t width),
+// void (*kmp_LoadReduceFctPtr)(void *reduce_data, void * scratchpad,
+// int32_t index, int32_t width, int32_t reduce))
+llvm::Type *ShuffleReduceTypeParams[] = {CGM.VoidPtrTy, CGM.Int16Ty,
+ CGM.Int16Ty, CGM.Int16Ty};
+auto *ShuffleReduceFnTy =
+llvm::FunctionType::get(CGM.VoidTy, ShuffleReduceTypeParams,
+/*isVarArg=*/false);
+llvm::Type *InterWarpCopyTypeParams[] = {CGM.VoidPtrTy, CGM.Int32Ty};
+auto *InterWarpCopyFnTy =
+llvm::FunctionType::get(CGM.VoidTy, InterWarpCopyTypeParams,
+/*isVarArg=*/false);
+llvm::Type *CopyToScratchpadTypeParams[] = {CGM.VoidPtrTy, CGM.VoidPtrTy,
+CGM.Int32Ty, CGM.Int32Ty};
+auto *CopyToScratchpadFnTy =
+llvm::FunctionType::get(CGM.VoidTy, CopyToScratchpadTypeParams,
+/*isVarArg=*/false);
+llvm::Type *LoadReduceTypeParams[] = {
+CGM.VoidPtrTy, CGM.VoidPtrTy, CGM.Int32Ty, CGM.Int32Ty, CGM.Int32Ty};
+auto *LoadReduceFnTy =
+llvm::FunctionType::get(CGM.VoidTy, LoadReduceTypeParams,
+/*isVarArg=*/false);
+llvm::Type *TypeParams[] = {CGM.Int32Ty,
+CGM.Int32Ty,
+CGM.SizeTy,
+CGM.VoidPtrTy,
+ShuffleReduceFnTy->getPointerTo(),
+InterWarpCopyFnTy->getPointerTo(),
+CopyToScratchpadFnTy->getPointerTo(),
+LoadReduceFnTy->getPoi

Re: D29829: [OpenCL][Doc] Description for adding OpenCL vendor extension in user manual

2017-02-16 Thread Hans Wennborg via cfe-commits
I've merged it in r295340.

Cheers,
Hans

On Thu, Feb 16, 2017 at 6:26 AM, Anastasia Stulova
 wrote:
> Hans, could we merge this documentation only change (r295313) in release40 
> branch. I can commit myself if needed. :)
>
> Thanks in advance,
> Anastasia
>
> -Original Message-
> From: Anastasia Stulova via Phabricator [mailto:revi...@reviews.llvm.org]
> Sent: 16 February 2017 14:15
> To: Anastasia Stulova; yaxun@amd.com
> Cc: cfe-commits@lists.llvm.org
> Subject: [PATCH] D29829: [OpenCL][Doc] Description for adding OpenCL vendor 
> extension in user manual
>
> Anastasia closed this revision.
> Anastasia added a comment.
>
> Committed in 295313!
>
>
> https://reviews.llvm.org/D29829
>
>
>
> IMPORTANT NOTICE: The contents of this email and any attachments are 
> confidential and may also be privileged. If you are not the intended 
> recipient, please notify the sender immediately and do not disclose the 
> contents to any other person, use it for any purpose, or store or copy the 
> information in any medium. Thank you.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27486: Correct class-template deprecation behavior

2017-02-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

@rsmith  did you ever get a chance to re-review this?  Is this what you were 
wanting for this?


https://reviews.llvm.org/D27486



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


[PATCH] D28266: Transparent_union attribute should be possible in front of union (rework)

2017-02-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Hi guys-
Since this is a rework of Vlad's changes, I'm not sure you noticed that this 
was a different review!  Anyone have opinions?  Additionally, I had 1 question 
in SemaDecl.cpp that I think was right, otherwise I hope this is a pretty light 
review.


https://reviews.llvm.org/D28266



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


[PATCH] D29401: Fix MSVC Compatibility around dependent type with missing 'typename'

2017-02-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Thoughts?


https://reviews.llvm.org/D29401



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


[PATCH] D29530: [ubsan] Reduce null checking of C++ object pointers (PR27581)

2017-02-16 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


https://reviews.llvm.org/D29530



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


[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D30009#678091, @hfinkel wrote:

> I don't understand why it only supports some attributes. Is there some 
> handling that needs to take place (I don't see anything obvious in this 
> patch)? If most attributes will "just work", I'd much rather opt-out the few 
> exceptions (which we can then explicitly document), if any, than using this 
> opt-in solution.


I think it would be reasonable to use an opt-out approach. I think the 
following set of initial rules should determine when an attribute should not be 
supported by the pragma:

- If an attribute is late parsed
- Or if it has no GNU/CXX11 spelling
- Or if it has no subject list, or its subject list is empty (excluding 
annotate)
- Or if it derives from StmtAttr or TypeAttr


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-16 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D30009#678890, @arphaman wrote:

> In https://reviews.llvm.org/D30009#678091, @hfinkel wrote:
>
> > I don't understand why it only supports some attributes. Is there some 
> > handling that needs to take place (I don't see anything obvious in this 
> > patch)? If most attributes will "just work", I'd much rather opt-out the 
> > few exceptions (which we can then explicitly document), if any, than using 
> > this opt-in solution.
>
>
> I think it would be reasonable to use an opt-out approach. I think the 
> following set of initial rules should determine when an attribute should not 
> be supported by the pragma:
>
> - If an attribute is late parsed
> - Or if it has no GNU/CXX11 spelling
> - Or if it has no subject list, or its subject list is empty (excluding 
> annotate)
> - Or if it derives from StmtAttr or TypeAttr


SGTM.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D29401: Fix MSVC Compatibility around dependent type with missing 'typename'

2017-02-16 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/Parse/ParseStmt.cpp:186
 // found.
-if (Next.isNot(tok::coloncolon)) {
+if (Next.isNot(tok::coloncolon) && (!getLangOpts().MSVCCompat ||
+Next.isNot(tok::less))) {

erichkeane wrote:
> Clang-tidy created this layout here that I'm not thrilled with, if OK, I'd 
> like to move the entirety of the 2nd component to the "&&" on its own line.  
> Additionally, if anyone has a better way to do this logic, I'm all ears!
Why is this checking for MSVCCompat?  I think we want to detect constructs like 
your testcase in all modes so we can generate a good error message.



Comment at: test/SemaCXX/MicrosoftCompatibility.cpp:222
+const A::TYPE var2 = 2; // expected-warning {{missing 'typename' prior 
to dependent type name}}
+A::TYPE var3 = 2; // expected-warning {{missing 'typename' prior to 
dependent type name}}
+MissingTypename::A::TYPE var4 = 2; // expected-warning {{missing 
'typename' prior to dependent type name}}

erichkeane wrote:
> This is the line that previously failed.  Curiously, the one above and below 
> seemed to succeed without this change.
The first one is obviously a declaration because of the "const" keyword, so we 
don't follow the same codepath.  I would guess the last one hits the 
"Next.isNot(tok::coloncolon)" check in the if statment you're modifying.

A couple more related testcases:

```
A::TYPE const var3 = 2; // const after type
A::TYPE *var3 = 2; // we can't tell this is invalid until the template is 
instantiated
```


https://reviews.llvm.org/D29401



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


[PATCH] D29401: Fix MSVC Compatibility around dependent type with missing 'typename'

2017-02-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: lib/Parse/ParseStmt.cpp:186
 // found.
-if (Next.isNot(tok::coloncolon)) {
+if (Next.isNot(tok::coloncolon) && (!getLangOpts().MSVCCompat ||
+Next.isNot(tok::less))) {

efriedma wrote:
> erichkeane wrote:
> > Clang-tidy created this layout here that I'm not thrilled with, if OK, I'd 
> > like to move the entirety of the 2nd component to the "&&" on its own line. 
> >  Additionally, if anyone has a better way to do this logic, I'm all ears!
> Why is this checking for MSVCCompat?  I think we want to detect constructs 
> like your testcase in all modes so we can generate a good error message.
We get a good error message here ("typename missing") in normal mode.  The 
issue here is that the examples below work in MSVC's relaxed 'typename' 
situation, thus this should only be accepting code in MSVC mode, right?  Or am 
I missing something.



Comment at: test/SemaCXX/MicrosoftCompatibility.cpp:222
+const A::TYPE var2 = 2; // expected-warning {{missing 'typename' prior 
to dependent type name}}
+A::TYPE var3 = 2; // expected-warning {{missing 'typename' prior to 
dependent type name}}
+MissingTypename::A::TYPE var4 = 2; // expected-warning {{missing 
'typename' prior to dependent type name}}

efriedma wrote:
> erichkeane wrote:
> > This is the line that previously failed.  Curiously, the one above and 
> > below seemed to succeed without this change.
> The first one is obviously a declaration because of the "const" keyword, so 
> we don't follow the same codepath.  I would guess the last one hits the 
> "Next.isNot(tok::coloncolon)" check in the if statment you're modifying.
> 
> A couple more related testcases:
> 
> ```
> A::TYPE const var3 = 2; // const after type
> A::TYPE *var3 = 2; // we can't tell this is invalid until the template is 
> instantiated
> ```
Ah, right!  I'll add those tests as well!


https://reviews.llvm.org/D29401



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


[libcxx] r295355 - Update a couple of issue statuses

2017-02-16 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Feb 16 12:50:30 2017
New Revision: 295355

URL: http://llvm.org/viewvc/llvm-project?rev=295355&view=rev
Log:
Update a couple of issue statuses

Modified:
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=295355&r1=295354&r2=295355&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Thu Feb 16 12:50:30 2017
@@ -55,14 +55,14 @@
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3911";>N3911LWGTransformationTrait
 Alias 
void_t.UrbanaComplete3.6
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4089";>N4089LWGSafe
 conversions in unique_ptr.UrbanaIn 
progress3.9
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4169";>N4169LWGA
 proposal to add invoke function 
templateUrbanaComplete3.7
-   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4190";>N4190LWGRemoving
 auto_ptr, random_shuffle(), And Old  
Stuff.Urbana
+   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4190";>N4190LWGRemoving
 auto_ptr, random_shuffle(), And Old  
Stuff.UrbanaIn progress
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4258";>N4258LWGCleaning-up
 noexcept in the Library.UrbanaIn 
progress3.7
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4259";>N4259CWGWording
 for 
std::uncaught_exceptionsUrbanaComplete3.7
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4277";>N4277LWGTriviallyCopyable
 
reference_wrapper.UrbanaComplete3.2
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4279";>N4279LWGImproved
 insertion interface for unique-key 
maps.UrbanaComplete3.7
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4280";>N4280LWGNon-member
 size() and moreUrbanaComplete3.6
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4284";>N4284LWGContiguous
 Iterators.UrbanaComplete3.6
-   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4285";>N4285CWGCleanup
 for exception-specification and 
throw-expression.Urbana
+   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4285";>N4285CWGCleanup
 for exception-specification and 
throw-expression.UrbanaComplete4.0

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4387";>N4387LWGimproving
 pair and tupleLenexaComplete4.0
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4389";>N4389LWGbool_constantLenexaComplete3.7
@@ -417,7 +417,7 @@
 
   
 
-  Last Updated: 26-Jan-2017
+  Last Updated: 16-Feb-2017
 
 
 


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


[PATCH] D29401: Fix MSVC Compatibility around dependent type with missing 'typename'

2017-02-16 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/Parse/ParseStmt.cpp:186
 // found.
-if (Next.isNot(tok::coloncolon)) {
+if (Next.isNot(tok::coloncolon) && (!getLangOpts().MSVCCompat ||
+Next.isNot(tok::less))) {

erichkeane wrote:
> efriedma wrote:
> > erichkeane wrote:
> > > Clang-tidy created this layout here that I'm not thrilled with, if OK, 
> > > I'd like to move the entirety of the 2nd component to the "&&" on its own 
> > > line.  Additionally, if anyone has a better way to do this logic, I'm all 
> > > ears!
> > Why is this checking for MSVCCompat?  I think we want to detect constructs 
> > like your testcase in all modes so we can generate a good error message.
> We get a good error message here ("typename missing") in normal mode.  The 
> issue here is that the examples below work in MSVC's relaxed 'typename' 
> situation, thus this should only be accepting code in MSVC mode, right?  Or 
> am I missing something.
This is what I see for the testcase in your commit message on trunk:

```
:7:4: error: expected ';' after expression
  S::TD varname =0;
   ^
   ;
:7:14: error: use of undeclared identifier 'varname'
  S::TD varname =0;
 ^
:7:3: error: missing 'typename' prior to dependent type name 'S::TD'
  S::TD varname =0;
  ^~
:11:3: note: in instantiation of function template specialization 
'foo' requested here
  foo();
  ^
3 errors generated.
```

Technically speaking, we do get the "missing typename" message, but I still 
wouldn't call this result "a good error message".


https://reviews.llvm.org/D29401



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


[PATCH] D29401: Fix MSVC Compatibility around dependent type with missing 'typename'

2017-02-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: lib/Parse/ParseStmt.cpp:186
 // found.
-if (Next.isNot(tok::coloncolon)) {
+if (Next.isNot(tok::coloncolon) && (!getLangOpts().MSVCCompat ||
+Next.isNot(tok::less))) {

efriedma wrote:
> erichkeane wrote:
> > efriedma wrote:
> > > erichkeane wrote:
> > > > Clang-tidy created this layout here that I'm not thrilled with, if OK, 
> > > > I'd like to move the entirety of the 2nd component to the "&&" on its 
> > > > own line.  Additionally, if anyone has a better way to do this logic, 
> > > > I'm all ears!
> > > Why is this checking for MSVCCompat?  I think we want to detect 
> > > constructs like your testcase in all modes so we can generate a good 
> > > error message.
> > We get a good error message here ("typename missing") in normal mode.  The 
> > issue here is that the examples below work in MSVC's relaxed 'typename' 
> > situation, thus this should only be accepting code in MSVC mode, right?  Or 
> > am I missing something.
> This is what I see for the testcase in your commit message on trunk:
> 
> ```
> :7:4: error: expected ';' after expression
>   S::TD varname =0;
>^
>;
> :7:14: error: use of undeclared identifier 'varname'
>   S::TD varname =0;
>  ^
> :7:3: error: missing 'typename' prior to dependent type name 
> 'S::TD'
>   S::TD varname =0;
>   ^~
> :11:3: note: in instantiation of function template specialization 
> 'foo' requested here
>   foo();
>   ^
> 3 errors generated.
> ```
> 
> Technically speaking, we do get the "missing typename" message, but I still 
> wouldn't call this result "a good error message".
Ah, I see!  You're right, I got caught up in this a bunch.  I'll look to see if 
I can get both cases to be better.  Thanks!


https://reviews.llvm.org/D29401



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


[PATCH] D24812: Lit C++11 Compatibility Patch #11

2017-02-16 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge added a comment.

@rjmccall

Hi John, I've made the changes to volatile.cpp.
I take it this patch is good for commit?


https://reviews.llvm.org/D24812



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


[PATCH] D30000: Fix for pr31836 - pp_nonportable_path on absolute paths: broken delimiters

2017-02-16 Thread Axel Naumann via Phabricator via cfe-commits
karies added inline comments.



Comment at: test/Lexer/case-insensitive-include-pr31836.sh:6
+// RUN: touch %T/case-insensitive-include-pr31836.h
+// RUN: echo "#include \"%T/Case-Insensitive-Include-Pr31836.h\"" | %clang_cc1 
-E - 2>&1 | FileCheck %s
+

@twoh Does that actually work on Linux? I thought (most?) Linux file systems 
are case sensitive? I.e. I'd expect to get a "file not found" diag on the 
`#include`.


https://reviews.llvm.org/D3



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


[PATCH] D30000: Fix for pr31836 - pp_nonportable_path on absolute paths: broken delimiters

2017-02-16 Thread Taewook Oh via Phabricator via cfe-commits
twoh added inline comments.



Comment at: test/Lexer/case-insensitive-include-pr31836.sh:6
+// RUN: touch %T/case-insensitive-include-pr31836.h
+// RUN: echo "#include \"%T/Case-Insensitive-Include-Pr31836.h\"" | %clang_cc1 
-E - 2>&1 | FileCheck %s
+

karies wrote:
> @twoh Does that actually work on Linux? I thought (most?) Linux file systems 
> are case sensitive? I.e. I'd expect to get a "file not found" diag on the 
> `#include`.
This is an unsupported test on Linux because of REQUIRES: 
case-insensitive-filesystem.


https://reviews.llvm.org/D3



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


Re: [libcxx] r295330 - math: correct the MSVCRT condition

2017-02-16 Thread Andrey Khalyavin via cfe-commits
What is _VC_CRT_NAJOR_VERSION? Is it misprint or a hack? Google gives zero
results.

-- Andrey Khalyavin

On Thu, Feb 16, 2017 at 6:47 PM, Saleem Abdulrasool via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: compnerd
> Date: Thu Feb 16 09:47:50 2017
> New Revision: 295330
>
> URL: http://llvm.org/viewvc/llvm-project?rev=295330&view=rev
> Log:
> math: correct the MSVCRT condition
>
> Fixes a number of tests in the testsuite on Windows.
>
> Modified:
> libcxx/trunk/include/cmath
> libcxx/trunk/include/math.h
>
> Modified: libcxx/trunk/include/cmath
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/
> cmath?rev=295330&r1=295329&r2=295330&view=diff
> 
> ==
> --- libcxx/trunk/include/cmath (original)
> +++ libcxx/trunk/include/cmath Thu Feb 16 09:47:50 2017
> @@ -398,7 +398,7 @@ using ::cbrtf;
>  using ::copysign;
>  using ::copysignf;
>
> -#if !defined(_LIBCPP_MSVCRT) || ((_VC_CRT_NAJOR_VERSION-0) >= 14)
> +#if !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
>  using ::erf;
>  using ::erff;
>  using ::erfc;
> @@ -435,7 +435,7 @@ using ::lrint;
>  using ::lrintf;
>  using ::lround;
>  using ::lroundf;
> -#endif // _LIBCPP_MSVCRT
> +#endif // !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
>
>  using ::nan;
>  using ::nanf;
>
> Modified: libcxx/trunk/include/math.h
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/
> math.h?rev=295330&r1=295329&r2=295330&view=diff
> 
> ==
> --- libcxx/trunk/include/math.h (original)
> +++ libcxx/trunk/include/math.h Thu Feb 16 09:47:50 2017
> @@ -1020,7 +1020,7 @@ copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NO
>  return ::copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
>  }
>
> -#if !defined(_LIBCPP_MSVCRT) || ((_VC_CRT_MAJOR_VERSION-0) >= 14)
> +#if !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
>
>  // erf
>
> @@ -1404,7 +1404,7 @@ inline _LIBCPP_INLINE_VISIBILITY
>  typename std::enable_if::value, double>::type
>  trunc(_A1 __lcpp_x) _NOEXCEPT {return ::trunc((double)__lcpp_x);}
>
> -#endif // !defined(_LIBCPP_MSVCRT) || ((_VC_CRT_MAJOR_VERSION-0) >= 14)
> +#endif // !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
>
>  } // extern "C++"
>
>
>
> ___
> 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] D30009: Add support for '#pragma clang attribute'

2017-02-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 88764.
arphaman marked an inline comment as done.
arphaman added a comment.

The updated patch switches over to the opt-out approach, allows the C++11 style 
syntax and improves documentation.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TokenKinds.def
  include/clang/Parse/Parser.h
  include/clang/Sema/AttributeList.h
  include/clang/Sema/Sema.h
  lib/Parse/ParsePragma.cpp
  lib/Parse/ParseStmt.cpp
  lib/Parse/Parser.cpp
  lib/Sema/AttributeList.cpp
  lib/Sema/SemaAttr.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaObjCProperty.cpp
  test/Parser/pragma-attribute.cpp
  test/Sema/pragma-attribute.c
  test/SemaCXX/pragma-attribute.cpp
  test/SemaObjC/pragma-attribute.m
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -1522,6 +1522,38 @@
   OS << "#endif // CLANG_ATTR_LATE_PARSED_LIST\n\n";
 }
 
+static bool hasGNUorCXX11Spelling(const Record &Attribute) {
+  std::vector Spellings = GetFlattenedSpellings(Attribute);
+  for (const auto &I : Spellings) {
+if (I.variety() == "GNU" || I.variety() == "CXX11")
+  return true;
+  }
+  return false;
+}
+
+static bool isSupportedByPragmaAttribute(const Record &Attribute) {
+  if (Attribute.getValueAsBit("ForcePragmaAttributeSupport"))
+return true;
+  // Opt-out rules:
+  // An attribute requires delayed parsing (LateParsed is on)
+  if (Attribute.getValueAsBit("LateParsed"))
+return false;
+  // An attribute has no GNU/CXX11 spelling
+  if (!hasGNUorCXX11Spelling(Attribute))
+return false;
+  // An attribute has no subject list or its subject list is empty
+  if (Attribute.isValueUnset("Subjects"))
+return false;
+  const Record *SubjectObj = Attribute.getValueAsDef("Subjects");
+  std::vector Subjects = SubjectObj->getValueAsListOfDefs("Subjects");
+  if (Subjects.empty())
+return false;
+  // An attribute derives from a StmtAttr or a TypeAttr
+  if (Attribute.isSubClassOf("TypeAttr") || Attribute.isSubClassOf("StmtAttr"))
+return false;
+  return true;
+}
+
 template 
 static void forEachUniqueSpelling(const Record &Attr, Fn &&F) {
   std::vector Spellings = GetFlattenedSpellings(Attr);
@@ -2692,9 +2724,13 @@
   return B + "Decl";
 }
 
+static std::string functionNameForCustomAppertainsTo(const Record &Subject) {
+  return "is" + Subject.getName().str();
+}
+
 static std::string GenerateCustomAppertainsTo(const Record &Subject,
   raw_ostream &OS) {
-  std::string FnName = "is" + Subject.getName().str();
+  std::string FnName = functionNameForCustomAppertainsTo(Subject);
 
   // If this code has already been generated, simply return the previous
   // instance of it.
@@ -2779,6 +2815,50 @@
   return FnName;
 }
 
+static void GenerateDefaultAppliesTo(raw_ostream &OS) {
+  OS << "static bool defaultAttributeAppliesTo(Sema &, const Decl *) {\n";
+  OS << "  return true;\n";
+  OS << "}\n\n";
+}
+
+static std::string GenerateAppliesTo(const Record &Attr, raw_ostream &OS) {
+  // If the attribute doesn't support '#pragma clang attribute' or if it doesn't
+  // contain a subjects definition, then use the default appliedTo logic.
+  if (!isSupportedByPragmaAttribute(Attr) || Attr.isValueUnset("Subjects"))
+return "defaultAttributeAppliesTo";
+
+  const Record *SubjectObj = Attr.getValueAsDef("Subjects");
+  std::vector Subjects = SubjectObj->getValueAsListOfDefs("Subjects");
+
+  // If the list of subjects is empty, it is assumed that the attribute applies
+  // to everything.
+  if (Subjects.empty())
+return "defaultAttributeAppliesTo";
+
+  // Otherwise, generate an appliesTo check specific to this attribute which
+  // checks all of the given subjects against the Decl passed in. Return the
+  // name of that check to the caller.
+  std::string FnName = "check" + Attr.getName().str() + "AttributeAppliesTo";
+  std::stringstream SS;
+  SS << "static bool " << FnName << "(Sema &S, const Decl *D) {\n";
+  SS << "  return ";
+  for (auto I = Subjects.begin(), E = Subjects.end(); I != E; ++I) {
+// If the subject has custom code associated with it, use the function
+// that was generated for GenerateAppertainsTo to check if the declaration
+// is valid.
+if ((*I)->isSubClassOf("SubsetSubject"))
+  SS << functionNameForCustomAppertainsTo(**I) << "(D)";
+else
+  SS << "isa<" << GetSubjectWithSuffix(*I) << ">(D)";
+
+if (I + 1 != E)
+  SS << " || ";
+  }
+  SS << ";\n}\n\n";
+  OS << SS.str();
+  return FnName;
+}
+
 static void GenerateDefaultLangOptRequirements(raw_ostream &OS) {
   OS << "static boo

[PATCH] D30009: Add support for '#pragma clang attribute'

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



Comment at: docs/LanguageExtensions.rst:2349
+attribute is supported by the pragma by referring to the
+:doc:`individual documentation for that attribute `.

arphaman wrote:
> efriedma wrote:
> > I'm wondering if we can tweak the approach so that we don't have to 
> > separately define how this works for each attribute; for example, `#pragma 
> > clang attribute_function_declaration push(...)` would apply to each 
> > function declaration, `#pragma clang attribute_global_variable_declaration 
> > push(...)` would apply to each global variable declaration, etc.
> I agree with this idea, I think it would be useful to have the ability to 
> specify the target declarations. I do think it would be better to use the 
> 'clang attribute' umbrella pragma, and maybe add an extra argument to the 
> 'push', e.g.:
> 
> ```
> #pragma attribute push (annotate("functions-only"), applicable_to=function) 
> // or maybe received_by=?
> #pragma attribute push (annotate("struct+enum"), applicable_to=struct, 
> applicable_to=enum)
> ```
I think that the further tweaks that control which declarations receive the 
attributes should be kept for a follow-up patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 88768.
pirama added a comment.

- Arch-subdir is now always added to -L
- It is added to -rpath during native compilation.
- Tests have been updated


https://reviews.llvm.org/D30015

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/Tools.cpp
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/.keep
  test/Driver/arch-specific-libdir-rpath.c
  test/Driver/arch-specific-libdir.c

Index: test/Driver/arch-specific-libdir.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir.c
@@ -0,0 +1,38 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the search path.
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+//
+// CHECK-ARCHDIR: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
Index: test/Driver/arch-specific-libdir-rpath.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir-rpath.c
@@ -0,0 +1,19 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native
+// compilations.
+//
+// -rpath only gets added during native compilation
+// REQUIRES: native
+//
+// RUN: %clang %s -### 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+//
+// CHECK-ARCHDIR: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux{{.*}} "-rpath" {{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
+// CHECK-NO-ARCHDIR-NOT: "-rpath" {{.*}}/Inputs/resource_dir
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -14,6 +14,7 @@
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/Version.h"
+#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Action.h"
 #include "clang/Driver/Compilation.h"
@@ -276,8 +277,18 @@
 
   // LIBRARY_PATH - included following the user specified library paths.
   //and only supported on native toolchains.
-  if (!TC.isCrossCompiling())
+  if (!TC.isCrossCompiling()) {
 addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
+
+// If we are not cross-compling, add '-rpath' with architecture-specific
+// library path so libraries lined from this path can be automatically
+// found.
+std::string CandidateRPath = TC.getArchSpecificLibPath();
+if (D.getVFS().exists(CandidateRPath)) {
+  CmdArgs.push_back("-rpath");
+  CmdArgs.push_back(Args.MakeArgString(CandidateRPath.c_str()));
+}
+  }
 }
 
 /// Add OpenMP linker script arguments at the end of the argument list so that
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -10,6 +10,7 @@
 #include "clang/Driver/ToolChain.h"
 #include "Tools.h"
 #include "clan

[PATCH] D26654: [CMake] Add Fuchsia toolchain CMake cache files

2017-02-16 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 88770.

Repository:
  rL LLVM

https://reviews.llvm.org/D26654

Files:
  cmake/caches/Fuchsia-stage2.cmake
  cmake/caches/Fuchsia.cmake

Index: cmake/caches/Fuchsia.cmake
===
--- /dev/null
+++ cmake/caches/Fuchsia.cmake
@@ -0,0 +1,44 @@
+# This file sets up a CMakeCache for a Fuchsia toolchain build.
+
+set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
+
+set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
+
+set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
+set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
+set(CLANG_INCLUDE_TESTS OFF CACHE BOOL "")
+set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
+set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
+
+set(CMAKE_BUILD_TYPE Release CACHE STRING "")
+
+set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
+if(NOT APPLE)
+  set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
+endif()
+
+set(CLANG_BOOTSTRAP_TARGETS
+  check-all
+  check-llvm
+  check-clang
+  llvm-config
+  test-suite
+  test-depends
+  llvm-test-depends
+  clang-test-depends
+  distribution
+  install-distribution
+  clang CACHE STRING "")
+
+if(FUCHSIA_SYSROOT)
+  set(EXTRA_ARGS -DFUCHSIA_SYSROOT=${FUCHSIA_SYSROOT})
+endif()
+
+# Setup the bootstrap build.
+set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
+set(CLANG_BOOTSTRAP_CMAKE_ARGS
+  ${EXTRA_ARGS}
+  -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake
+  CACHE STRING "")
Index: cmake/caches/Fuchsia-stage2.cmake
===
--- /dev/null
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -0,0 +1,61 @@
+# This file sets up a CMakeCache for the second stage of a Fuchsia toolchain
+# build.
+
+set(LLVM_TARGETS_TO_BUILD X86;AArch64 CACHE STRING "")
+
+set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
+
+set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
+set(LLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD OFF CACHE BOOL "")
+set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
+set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
+set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
+
+set(LLVM_ENABLE_LTO ON CACHE BOOL "")
+if(NOT APPLE)
+  set(LLVM_ENABLE_LLD ON CACHE BOOL "")
+  set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
+endif()
+
+set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "")
+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "")
+
+set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia-none;aarch64-fuchsia-none" CACHE STRING "")
+set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING "")
+set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING "")
+set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+
+# Setup toolchain.
+set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
+set(LLVM_TOOLCHAIN_TOOLS
+  llvm-ar
+  llvm-cov
+  llvm-cxxfilt
+  llvm-dwarfdump
+  llvm-dsymutil
+  llvm-lib
+  llvm-nm
+  llvm-objdump
+  llvm-profdata
+  llvm-ranlib
+  llvm-readobj
+  llvm-size
+  llvm-symbolizer
+  CACHE STRING "")
+
+set(LLVM_DISTRIBUTION_COMPONENTS
+  clang
+  lld
+  lldb
+  LTO
+  clang-format
+  clang-headers
+  builtins-x86_64-fuchsia-none
+  builtins-aarch64-fuchsia-none
+  runtimes
+  ${LLVM_TOOLCHAIN_TOOLS}
+  CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: test/Driver/arch-specific-libdir-rpath.c:6
+// -rpath only gets added during native compilation
+// REQUIRES: native
+//

I feel this test is fragile.  Any idea how to further restrict and require that 
the default target triple has linux and one of i386, x86_64, arm, aarch64?

I could create sub-dirs for all archs returned by Triple::getArchTypeName 
(llvm/lib/Support/Triple.cpp) but it seems overkill.


https://reviews.llvm.org/D30015



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


[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-16 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: docs/LanguageExtensions.rst:2349
+attribute is supported by the pragma by referring to the
+:doc:`individual documentation for that attribute `.

arphaman wrote:
> arphaman wrote:
> > efriedma wrote:
> > > I'm wondering if we can tweak the approach so that we don't have to 
> > > separately define how this works for each attribute; for example, 
> > > `#pragma clang attribute_function_declaration push(...)` would apply to 
> > > each function declaration, `#pragma clang 
> > > attribute_global_variable_declaration push(...)` would apply to each 
> > > global variable declaration, etc.
> > I agree with this idea, I think it would be useful to have the ability to 
> > specify the target declarations. I do think it would be better to use the 
> > 'clang attribute' umbrella pragma, and maybe add an extra argument to the 
> > 'push', e.g.:
> > 
> > ```
> > #pragma attribute push (annotate("functions-only"), applicable_to=function) 
> > // or maybe received_by=?
> > #pragma attribute push (annotate("struct+enum"), applicable_to=struct, 
> > applicable_to=enum)
> > ```
> I think that the further tweaks that control which declarations receive the 
> attributes should be kept for a follow-up patch.
I'm not sure we can wait to address this, especially if we're turning this on 
for all attributes by default.  There's a compatibility hazard here: if the 
push doesn't specify what declarations it applies to, we can never change 
AttributeAppliesToDecl for any existing attribute.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D30009: Add support for '#pragma clang attribute'

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



Comment at: docs/LanguageExtensions.rst:2349
+attribute is supported by the pragma by referring to the
+:doc:`individual documentation for that attribute `.

efriedma wrote:
> arphaman wrote:
> > arphaman wrote:
> > > efriedma wrote:
> > > > I'm wondering if we can tweak the approach so that we don't have to 
> > > > separately define how this works for each attribute; for example, 
> > > > `#pragma clang attribute_function_declaration push(...)` would apply to 
> > > > each function declaration, `#pragma clang 
> > > > attribute_global_variable_declaration push(...)` would apply to each 
> > > > global variable declaration, etc.
> > > I agree with this idea, I think it would be useful to have the ability to 
> > > specify the target declarations. I do think it would be better to use the 
> > > 'clang attribute' umbrella pragma, and maybe add an extra argument to the 
> > > 'push', e.g.:
> > > 
> > > ```
> > > #pragma attribute push (annotate("functions-only"), 
> > > applicable_to=function) // or maybe received_by=?
> > > #pragma attribute push (annotate("struct+enum"), applicable_to=struct, 
> > > applicable_to=enum)
> > > ```
> > I think that the further tweaks that control which declarations receive the 
> > attributes should be kept for a follow-up patch.
> I'm not sure we can wait to address this, especially if we're turning this on 
> for all attributes by default.  There's a compatibility hazard here: if the 
> push doesn't specify what declarations it applies to, we can never change 
> AttributeAppliesToDecl for any existing attribute.
Are you saying that we should never allow a push without specifying which 
declarations should the attribute apply to? I think that would make this 
feature less useful, as some attributes have a well defined set of declarations 
that they apply to. Even if we will change the attribute's subjects in the 
future, I think it might be more likely that the users would've wanted to apply 
the attribute to the updated compiler-determined subject list.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D28670: [ObjC] Disallow vector parameters and return values in Objective-C methods on older X86 targets

2017-02-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Ping.


Repository:
  rL LLVM

https://reviews.llvm.org/D28670



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


Re: r295224 - PR24440: Do not silently discard a fold-expression appearing as the operand of a cast-expression.

2017-02-16 Thread Hans Wennborg via cfe-commits
Merged in r295375.

Thanks,
Hans

On Wed, Feb 15, 2017 at 12:14 PM, Richard Smith  wrote:
> Hans, this would be a good candidate for Clang 4. The bug in question is not
> a regression, but it is an accepts-invalid / wrong-code bug.
>
> On 15 February 2017 at 11:57, Richard Smith via cfe-commits
>  wrote:
>>
>> Author: rsmith
>> Date: Wed Feb 15 13:57:10 2017
>> New Revision: 295224
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=295224&view=rev
>> Log:
>> PR24440: Do not silently discard a fold-expression appearing as the
>> operand of a cast-expression.
>>
>> Modified:
>> cfe/trunk/lib/Parse/ParseExpr.cpp
>> cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
>> cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp
>>
>> Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=295224&r1=295223&r2=295224&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
>> +++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Feb 15 13:57:10 2017
>> @@ -2409,7 +2409,7 @@ Parser::ParseParenExpression(ParenParseO
>>// fold-expressions, we'll need to allow multiple ArgExprs here.
>>if (ArgExprs.size() == 1 && isFoldOperator(Tok.getKind()) &&
>>NextToken().is(tok::ellipsis))
>> -return ParseFoldExpression(Result, T);
>> +return ParseFoldExpression(ArgExprs[0], T);
>>
>>ExprType = SimpleExpr;
>>Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(),
>>
>> Modified: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp?rev=295224&r1=295223&r2=295224&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp Wed Feb 15 13:57:10 2017
>> @@ -1015,6 +1015,11 @@ ExprResult Sema::ActOnCXXFoldExpr(Source
>>CheckFoldOperand(*this, LHS);
>>CheckFoldOperand(*this, RHS);
>>
>> +  auto DiscardOperands = [&] {
>> +CorrectDelayedTyposInExpr(LHS);
>> +CorrectDelayedTyposInExpr(RHS);
>> +  };
>> +
>>// [expr.prim.fold]p3:
>>//   In a binary fold, op1 and op2 shall be the same fold-operator, and
>>//   either e1 shall contain an unexpanded parameter pack or e2 shall
>> contain
>> @@ -1022,6 +1027,7 @@ ExprResult Sema::ActOnCXXFoldExpr(Source
>>if (LHS && RHS &&
>>LHS->containsUnexpandedParameterPack() ==
>>RHS->containsUnexpandedParameterPack()) {
>> +DiscardOperands();
>>  return Diag(EllipsisLoc,
>>  LHS->containsUnexpandedParameterPack()
>>  ? diag::err_fold_expression_packs_both_sides
>> @@ -1035,6 +1041,7 @@ ExprResult Sema::ActOnCXXFoldExpr(Source
>>if (!LHS || !RHS) {
>>  Expr *Pack = LHS ? LHS : RHS;
>>  assert(Pack && "fold expression with neither LHS nor RHS");
>> +DiscardOperands();
>>  if (!Pack->containsUnexpandedParameterPack())
>>return Diag(EllipsisLoc,
>> diag::err_pack_expansion_without_parameter_packs)
>>   << Pack->getSourceRange();
>>
>> Modified: cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp?rev=295224&r1=295223&r2=295224&view=diff
>>
>> ==
>> --- cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp (original)
>> +++ cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp Wed Feb 15 13:57:10
>> 2017
>> @@ -34,3 +34,12 @@ template int bad9() { return (
>>  template int bad10() { return (3 ? ... : N); } //
>> expected-error +{{}} expected-note {{to match}}
>>  template int bad11() { return (N + ... 0); } // expected-error
>> {{expected a foldable binary operator}} expected-error {{expected
>> expression}}
>>  template int bad12() { return (... N); } // expected-error
>> {{expected expression}}
>> +
>> +template void as_operand_of_cast(int a, T ...t) {
>> +  return
>> +(int)(a + ... + undeclared_junk) + // expected-error {{undeclared}}
>> expected-error {{does not contain any unexpanded}}
>> +(int)(t + ... + undeclared_junk) + // expected-error {{undeclared}}
>> +(int)(... + undeclared_junk) + // expected-error {{undeclared}}
>> expected-error {{does not contain any unexpanded}}
>> +(int)(undeclared_junk + ...) + // expected-error {{undeclared}}
>> +(int)(a + ...); // expected-error {{does not contain any unexpanded}}
>> +}
>>
>>
>> ___
>> 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] D30009: Add support for '#pragma clang attribute'

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



Comment at: docs/LanguageExtensions.rst:2418
+In general, the attributes are applied to a declaration only when there would
+have been no error or warning for that attribute if it was specified 
explicitly.
+An attribute is applied to each relevant declaration individually,

So then this code does not produce an error?
```
#pragma clang attribute push(hot)

void func(void) __attribute__((cold));

#pragma clang attribute pop
```



Comment at: docs/LanguageExtensions.rst:2428
+whether or not an attribute is supported by the pragma by referring to the
+:doc:`individual documentation for that attribute `.

This doesn't make clear what would happen with something like:
```
  #pragma clang attribute push(cdecl)

  void function(void (*fp)(int));

  #pragma clang attribute pop
```
Naively, I would expect the cdecl attribute to appertain to both `function` and 
`fp`, but I'm guessing that's not what actually happens (because cdecl is both 
a decl and a type attribute at the same time).

Also, why is this not available for __declspec attributes?

Why do C++ attributes require the syntax to be present in the #pragma, but 
GNU-style attributes do not? There are also MS-style attribute (currently 
unsupported, but there have been some efforts to include them in the past) and 
__declspec attributes as well. Why not require the syntax so that any of them 
can be supported?



Comment at: include/clang/Basic/Attr.td:308-311
+  // - An attribute requires delayed parsing (LateParsed is on)
+  // - An attribute has no GNU/CXX11 spelling
+  // - An attribute has no subject list
+  // - An attribute derives from a StmtAttr or a TypeAttr

I have strong reservations about this -- users are going to have no idea what 
attributes are and are not supported because they're not going to know whether 
the attribute has a subject list or requires delayed parsing. We have a 
considerable number of attributes for which the Subjects line is currently 
commented out simply because no one has bothered to fix that. This means those 
attributes can't be used with this pragma until someone fixes that, but when it 
happens, they magically can be used, which is a good thing. But the converse is 
more problematic -- if there's an existing Subjects line that gets removed 
because a subject is added that is difficult to express in TableGen it may 
break user code.

We can fix the discoverability issues somewhat by updating the documentation 
emitter to spit out some wording that says when an attribute is/is not 
supported by this feature, but that only works for attributes which have 
documentation and so it's not a particularly reliable workaround.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-16 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: docs/LanguageExtensions.rst:2349
+attribute is supported by the pragma by referring to the
+:doc:`individual documentation for that attribute `.

arphaman wrote:
> efriedma wrote:
> > arphaman wrote:
> > > arphaman wrote:
> > > > efriedma wrote:
> > > > > I'm wondering if we can tweak the approach so that we don't have to 
> > > > > separately define how this works for each attribute; for example, 
> > > > > `#pragma clang attribute_function_declaration push(...)` would apply 
> > > > > to each function declaration, `#pragma clang 
> > > > > attribute_global_variable_declaration push(...)` would apply to each 
> > > > > global variable declaration, etc.
> > > > I agree with this idea, I think it would be useful to have the ability 
> > > > to specify the target declarations. I do think it would be better to 
> > > > use the 'clang attribute' umbrella pragma, and maybe add an extra 
> > > > argument to the 'push', e.g.:
> > > > 
> > > > ```
> > > > #pragma attribute push (annotate("functions-only"), 
> > > > applicable_to=function) // or maybe received_by=?
> > > > #pragma attribute push (annotate("struct+enum"), applicable_to=struct, 
> > > > applicable_to=enum)
> > > > ```
> > > I think that the further tweaks that control which declarations receive 
> > > the attributes should be kept for a follow-up patch.
> > I'm not sure we can wait to address this, especially if we're turning this 
> > on for all attributes by default.  There's a compatibility hazard here: if 
> > the push doesn't specify what declarations it applies to, we can never 
> > change AttributeAppliesToDecl for any existing attribute.
> Are you saying that we should never allow a push without specifying which 
> declarations should the attribute apply to? I think that would make this 
> feature less useful, as some attributes have a well defined set of 
> declarations that they apply to. Even if we will change the attribute's 
> subjects in the future, I think it might be more likely that the users 
> would've wanted to apply the attribute to the updated compiler-determined 
> subject list.
I agree, users shouldn't have to repeat that attribute "target" applies to 
functions and attribute "warn_unused" applies to record types. Asking the user 
to figure it out just makes it harder to use.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D29401: Fix MSVC Compatibility around dependent type with missing 'typename'

2017-02-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Well hmm... changing this from MSVC to always caused a ton of regressions.  I 
no longer think that this is a proper patch as it sits.  Additionally, it 
doesn't fix the A::TYPE *var3 condition.


https://reviews.llvm.org/D29401



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


r295379 - Properly set up the DeclContext for parameters of implicit deduction guides;

2017-02-16 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Feb 16 15:29:21 2017
New Revision: 295379

URL: http://llvm.org/viewvc/llvm-project?rev=295379&view=rev
Log:
Properly set up the DeclContext for parameters of implicit deduction guides;
this is needed for deferred instantiation of default arguments.

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=295379&r1=295378&r2=295379&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Feb 16 15:29:21 2017
@@ -1677,6 +1677,9 @@ private:
  bool Explicit, TypeSourceInfo *TInfo,
  SourceLocation LocStart, SourceLocation Loc,
  SourceLocation LocEnd) {
+ArrayRef Params =
+TInfo->getTypeLoc().castAs().getParams();
+
 // Build the implicit deduction guide template.
 auto *Guide = FunctionDecl::Create(SemaRef.Context, DC, LocStart, Loc,
DeductionGuideName, TInfo->getType(),
@@ -1685,8 +1688,10 @@ private:
 if (Explicit)
   Guide->setExplicitSpecified();
 Guide->setRangeEnd(LocEnd);
-Guide->setParams(
-TInfo->getTypeLoc().castAs().getParams());
+Guide->setParams(Params);
+
+for (auto *Param : Params)
+  Param->setDeclContext(Guide);
 
 auto *GuideTemplate = FunctionTemplateDecl::Create(
 SemaRef.Context, DC, Loc, DeductionGuideName, TemplateParams, Guide);

Modified: cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp?rev=295379&r1=295378&r2=295379&view=diff
==
--- cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp 
(original)
+++ cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp Thu Feb 
16 15:29:21 2017
@@ -168,3 +168,11 @@ namespace nondeducible {
typename ...B>
   X(float) -> X; // ok
 }
+
+namespace default_args_from_ctor {
+  template  struct S { S(A = 0) {} };
+  S s(0);
+
+  template  struct T { template T(A = 0, B = 0) {} };
+  T t(0, 0);
+}


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


Re: [PATCH] D29753: [PCH] Avoid early VarDecl emission attempt if no owning module avaiable

2017-02-16 Thread Hans Wennborg via cfe-commits
Richard, can you take a look when you have a moment? The PR is marked
as a release blocker.

On Thu, Feb 9, 2017 at 1:54 PM, Duncan P. N. Exon Smith via
Phabricator via cfe-commits  wrote:
> dexonsmith added a comment.
>
> I'm not comfortable signing off on this, but it seems like this should be set 
> up as a blocker for LLVM 4.0 if it isn't already.
>
>
>
> 
> Comment at: lib/Serialization/ASTReaderDecl.cpp:2518-2523
>// An ImportDecl or VarDecl imported from a module will get emitted when
>// we import the relevant module.
> -  if ((isa(D) || isa(D)) && Ctx.DeclMustBeEmitted(D) &&
> -  D->getImportedOwningModule())
> +  if ((isa(D) || isa(D)) && 
> D->getImportedOwningModule() &&
> +  Ctx.DeclMustBeEmitted(D))
>  return false;
>
> 
> It's not locally obvious why the order matters.  Can you add a comment 
> explaining why you need to check getImportedOwningModule first?  It might be 
> worth splitting Ctx.DeclMustBeEmitted into its own; e.g.,
> ```
> // An ImportDecl or VarDecl imported from a module will get emitted when
> // we import the relevant module.
> if ((isa(D) || isa(D)) && D->getImportedOwningModule())
>   // Only check DeclMustBeEmitted if D has been fully imported, since it may
>   // emit D as a side effect.
>   if (Ctx.DeclMustBeEmitted(D))
> return false;
> ```
> but anything that prevents someone from swapping the conditions when they 
> refactor this would be good enough I think.
>
>
> https://reviews.llvm.org/D29753
>
>
>
> ___
> 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] D30009: Add support for '#pragma clang attribute'

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



Comment at: include/clang/Basic/Attr.td:308-311
+  // - An attribute requires delayed parsing (LateParsed is on)
+  // - An attribute has no GNU/CXX11 spelling
+  // - An attribute has no subject list
+  // - An attribute derives from a StmtAttr or a TypeAttr

aaron.ballman wrote:
> I have strong reservations about this -- users are going to have no idea what 
> attributes are and are not supported because they're not going to know 
> whether the attribute has a subject list or requires delayed parsing. We have 
> a considerable number of attributes for which the Subjects line is currently 
> commented out simply because no one has bothered to fix that. This means 
> those attributes can't be used with this pragma until someone fixes that, but 
> when it happens, they magically can be used, which is a good thing. But the 
> converse is more problematic -- if there's an existing Subjects line that 
> gets removed because a subject is added that is difficult to express in 
> TableGen it may break user code.
> 
> We can fix the discoverability issues somewhat by updating the documentation 
> emitter to spit out some wording that says when an attribute is/is not 
> supported by this feature, but that only works for attributes which have 
> documentation and so it's not a particularly reliable workaround.
> I have strong reservations about this -- users are going to have no idea what 
> attributes are and are not supported because they're not going to know 
> whether the attribute has a subject list or requires delayed parsing. We have 
> a considerable number of attributes for which the Subjects line is currently 
> commented out simply because no one has bothered to fix that. This means 
> those attributes can't be used with this pragma until someone fixes that, but 
> when it happens, they magically can be used, which is a good thing. But the 
> converse is more problematic -- if there's an existing Subjects line that 
> gets removed because a subject is added that is difficult to express in 
> TableGen it may break user code.

That's a good point. I think we can address this problem by creating a test 
that verifies the list of attributes that support the pragma. This would allow 
us to ensure that no attributes loose the ability to use the pragma.

> We can fix the discoverability issues somewhat by updating the documentation 
> emitter to spit out some wording that says when an attribute is/is not 
> supported by this feature, but that only works for attributes which have 
> documentation and so it's not a particularly reliable workaround.

We can enforce the rule that the attributes can only be used with '#pragma 
clang attribute' when they're documented. This way we can ensure that all 
attributes that can be used with the pragma are explicitly documented.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D29753: [PCH] Avoid early VarDecl emission attempt if no owning module avaiable

2017-02-16 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

It seems to me that the problem here is that `DeclMustBeEmitted` is not safe to 
call in the middle of deserialization if anything partially-deserialized might 
be reachable from the declaration we're querying, and yet we're currently 
calling it in that case. I don't see how this patch actually addresses that 
problem, though: if you build this testcase as a module instead of a PCH, won't 
it still fail in the same way that it does now?

I think we probably need to track all the declarations we deserialize in a 
top-level deserialization,  and only check whether they're interesting when we 
finish recursive deserialization (somewhere around 
`ASTReader::FinishedDeserializing`). For the update record case, this will need 
some care in order to retain the property that we only pass a declaration to 
the consumer once, but I think we can make that work by observing that it 
should generally be safe to call `DeclMustBeEmitted` on a declaration that we 
didn't create in this deserialization step, and when we're loading update 
records we know whether that's the case.


https://reviews.llvm.org/D29753



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


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: test/Driver/arch-specific-libdir.c:6
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//

Please be more specific in the tests, i.e. check if the correct arch dir is 
selected. Also add a test for i386-* triple, and make sure that both i386-* and 
i686-* give the same result.


https://reviews.llvm.org/D30015



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


[PATCH] D29901: Modular Codegen: Add/use a bit in serialized function definitions to track whether they are the subject of modular codegen

2017-02-16 Thread David Blaikie via Phabricator via cfe-commits
dblaikie updated this revision to Diff 88792.
dblaikie added a comment.

- Simplify ModuleFile lookup


https://reviews.llvm.org/D29901

Files:
  include/clang/AST/ExternalASTSource.h
  include/clang/Sema/MultiplexExternalSemaSource.h
  include/clang/Serialization/ASTReader.h
  lib/AST/ASTContext.cpp
  lib/AST/ExternalASTSource.cpp
  lib/Sema/MultiplexExternalSemaSource.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/Modules/Inputs/codegen/foo.h
  test/Modules/Inputs/codegen/use.cpp
  test/Modules/codegen.test

Index: test/Modules/codegen.test
===
--- test/Modules/codegen.test
+++ test/Modules/codegen.test
@@ -3,8 +3,23 @@
 
 RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++ -fmodules -emit-module -fmodule-name=foo %S/Inputs/codegen/foo.modulemap -o %t/foo.pcm
 
-RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %t/foo.pcm | FileCheck %s
+RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %t/foo.pcm | FileCheck --check-prefix=FOO --check-prefix=BOTH %s
+RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - -fmodules -fmodule-file=%t/foo.pcm %S/Inputs/codegen/use.cpp | FileCheck --check-prefix=BOTH --check-prefix=USE %s
 
-CHECK: $_Z2f1PKcz = comdat any
-CHECK: define weak_odr void @_Z2f1PKcz(i8* %fmt, ...) #{{[0-9]+}} comdat
-CHECK:   call void @llvm.va_start(i8* %{{[a-zA-Z0-9]*}})
+FOO: $_Z2f1PKcz = comdat any
+FOO: $_ZN13implicit_dtorD1Ev = comdat any
+USE: $_Z4instIiEvv = comdat any
+FOO: $_ZN13implicit_dtorD2Ev = comdat any
+FOO: define weak_odr void @_Z2f1PKcz(i8* %fmt, ...) #{{[0-9]+}} comdat
+FOO:   call void @llvm.va_start(i8* %{{[a-zA-Z0-9]*}})
+
+Test that implicit special members (like this dtor) are emitted into both module (if they're used there) and user.
+FIXME: Proactively instantiate any valid implicit special members to emit them into the module object.
+
+FOO: define weak_odr void @_ZN13implicit_dtorD1Ev(%struct.implicit_dtor* %this) unnamed_addr #0 comdat align 2 {
+FOO: define weak_odr void @_Z4instIfEvv() #0 comdat {
+FOO: define weak_odr void @_ZN13implicit_dtorD2Ev(%struct.implicit_dtor* %this) unnamed_addr #0 comdat align 2 {
+
+USE: define linkonce_odr void @_ZN20uninst_implicit_dtorD1Ev(%struct.uninst_implicit_dtor* %this) unnamed_addr #0 comdat align 2 {
+USE: define linkonce_odr void @_Z4instIiEvv() #0 comdat {
+USE: define linkonce_odr void @_ZN20uninst_implicit_dtorD2Ev(%struct.uninst_implicit_dtor* %this) unnamed_addr #0 comdat align 2 {
Index: test/Modules/Inputs/codegen/use.cpp
===
--- /dev/null
+++ test/Modules/Inputs/codegen/use.cpp
@@ -0,0 +1,8 @@
+#include "foo.h"
+void non_modular_use_of_implicit_dtor() {
+  implicit_dtor d1;
+  uninst_implicit_dtor d2;
+}
+void use_of_instantiated_declaration_without_definition() {
+  inst();
+}
Index: test/Modules/Inputs/codegen/foo.h
===
--- test/Modules/Inputs/codegen/foo.h
+++ test/Modules/Inputs/codegen/foo.h
@@ -2,3 +2,29 @@
   __builtin_va_list args;
   __builtin_va_start(args, fmt);
 }
+
+struct non_trivial_dtor {
+  ~non_trivial_dtor();
+};
+
+struct implicit_dtor {
+  non_trivial_dtor d;
+};
+
+struct uninst_implicit_dtor {
+  non_trivial_dtor d;
+};
+
+inline void use_implicit_dtor() {
+  implicit_dtor d;
+}
+
+template
+void inst() {
+}
+
+inline void inst_decl() {
+  // cause inst's declaration to be instantiated, without a definition.
+  (void)sizeof(&inst);
+  inst();
+}
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -2224,6 +2224,8 @@
   Writer->ClearSwitchCaseIDs();
 
   assert(FD->doesThisDeclarationHaveABody());
+  Record->push_back(Writer->Context->getLangOpts().ModularCodegen &&
+Writer->WritingModule);
   if (auto *CD = dyn_cast(FD)) {
 Record->push_back(CD->getNumCtorInitializers());
 if (CD->getNumCtorInitializers())
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -423,6 +423,11 @@
 }
 
 void ASTDeclReader::ReadFunctionDefinition(FunctionDecl *FD) {
+  if (Record.readInt()) {
+Reader.BodySource[FD] = Loc.F->Kind == ModuleKind::MK_MainFile
+? ExternalASTSource::EK_Never
+: ExternalASTSource::EK_Always;
+  }
   if (auto *CD = dyn_cast(FD)) {
 CD->NumCtorInitializers = Record.readInt();
 if (CD->NumCtorInitializers)
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -7911,16 +7911,11 @@
   return None;
 

[PATCH] D29930: Add `__reference_binds_to_temporary` trait for checking safe reference initialization.

2017-02-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 88794.
EricWF retitled this revision from "Add `__is_direct_constructible` trait for 
checking safe reference initialization." to "Add 
`__reference_binds_to_temporary` trait for checking safe reference 
initialization.".
EricWF edited the summary of this revision.
EricWF added a comment.

Address all of @rsmith's comments.


https://reviews.llvm.org/D29930

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/TokenKinds.def
  include/clang/Basic/TypeTraits.h
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/type-traits.cpp

Index: test/SemaCXX/type-traits.cpp
===
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -2048,6 +2048,8 @@
 
   // PR25513
   { int arr[F(__is_constructible(int(int)))]; }
+
+  { int arr[T(__is_constructible(int const&, long))]; }
 }
 
 // Instantiation of __is_trivially_constructible
@@ -2078,6 +2080,46 @@
   { int arr[F((is_trivially_constructible::value))]; } // PR19178
 }
 
+template 
+struct ConvertsToRef {
+  operator RefType() const { return static_cast(obj); }
+  mutable T obj = 42;
+};
+
+void reference_binds_to_temporary_checks() {
+  { int arr[F((__reference_binds_to_temporary(int&, int&)))]; }
+  { int arr[F((__reference_binds_to_temporary(int&, int&&)))]; }
+
+  { int arr[F((__reference_binds_to_temporary(int const&, int&)))]; }
+  { int arr[F((__reference_binds_to_temporary(int const&, int const&)))]; }
+  { int arr[F((__reference_binds_to_temporary(int const&, int&&)))]; }
+
+  { int arr[F((__reference_binds_to_temporary(int&, long &)))]; } // doesn't construct
+  { int arr[T((__reference_binds_to_temporary(int const&, long&)))]; }
+  { int arr[T((__reference_binds_to_temporary(int const&, long&&)))]; }
+  { int arr[T((__reference_binds_to_temporary(int&&, long&)))]; }
+
+  using LRef = ConvertsToRef;
+  using RRef = ConvertsToRef;
+  using CLRef = ConvertsToRef;
+  using LongRef = ConvertsToRef;
+  { int arr[T((__is_constructible(int&, LRef)))]; }
+  { int arr[F((__reference_binds_to_temporary(int&, LRef)))]; }
+
+  { int arr[T((__is_constructible(int&&, RRef)))]; }
+  { int arr[F((__reference_binds_to_temporary(int&&, RRef)))]; }
+
+  { int arr[T((__is_constructible(int const&, CLRef)))]; }
+  { int arr[F((__reference_binds_to_temporary(int&&, CLRef)))]; }
+
+  { int arr[T((__is_constructible(int const&, LongRef)))]; }
+  { int arr[T((__reference_binds_to_temporary(int const&, LongRef)))]; }
+
+  // Test that it doesn't accept non-reference types as input.
+  { int arr[F((__reference_binds_to_temporary(int, long)))]; }
+
+}
+
 void array_rank() {
   int t01[T(__array_rank(IntAr) == 1)];
   int t02[T(__array_rank(ConstIntArAr) == 2)];
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4564,11 +4564,14 @@
   if (Kind <= UTT_Last)
 return EvaluateUnaryTypeTrait(S, Kind, KWLoc, Args[0]->getType());
 
-  if (Kind <= BTT_Last)
+  // Evaluate BTT_ReferenceBindsToTemporary along side the IsConstructible
+  // traits to avoid duplication.
+  if (Kind <= BTT_Last && Kind != BTT_ReferenceBindsToTemporary)
 return EvaluateBinaryTypeTrait(S, Kind, Args[0]->getType(),
Args[1]->getType(), RParenLoc);
 
   switch (Kind) {
+  case clang::BTT_ReferenceBindsToTemporary:
   case clang::TT_IsConstructible:
   case clang::TT_IsNothrowConstructible:
   case clang::TT_IsTriviallyConstructible: {
@@ -4644,6 +4647,15 @@
 if (Kind == clang::TT_IsConstructible)
   return true;
 
+if (Kind == clang::BTT_ReferenceBindsToTemporary) {
+  if (!T->isReferenceType())
+return false;
+
+  assert(isa(Result.get())
+ == !Init.isDirectReferenceBinding());
+  return !Init.isDirectReferenceBinding();
+}
+
 if (Kind == clang::TT_IsNothrowConstructible)
   return S.canThrow(Result.get()) == CT_Cannot;
 
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -847,6 +847,7 @@
   REVERTIBLE_TYPE_TRAIT(__is_unsigned);
   REVERTIBLE_TYPE_TRAIT(__is_void);
   REVERTIBLE_TYPE_TRAIT(__is_volatile);
+  REVERTIBLE_TYPE_TRAIT(__reference_binds_to_temporary);
 #undef REVERTIBLE_TYPE_TRAIT
 #undef RTT_JOIN
 }
Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -1431,7 +1431,8 @@
   tok::kw___is_union,
   tok::kw___is_unsigned,
   tok::kw___is_void,
-  tok::kw___is_volatile))
+  tok::kw___is_volatile,
+  tok::kw___reference_binds_to_temporary))
 // GNU libstdc++ 4.2 and libc++ use certain

[PATCH] D30009: Add support for '#pragma clang attribute'

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



Comment at: include/clang/Basic/Attr.td:308-311
+  // - An attribute requires delayed parsing (LateParsed is on)
+  // - An attribute has no GNU/CXX11 spelling
+  // - An attribute has no subject list
+  // - An attribute derives from a StmtAttr or a TypeAttr

arphaman wrote:
> aaron.ballman wrote:
> > I have strong reservations about this -- users are going to have no idea 
> > what attributes are and are not supported because they're not going to know 
> > whether the attribute has a subject list or requires delayed parsing. We 
> > have a considerable number of attributes for which the Subjects line is 
> > currently commented out simply because no one has bothered to fix that. 
> > This means those attributes can't be used with this pragma until someone 
> > fixes that, but when it happens, they magically can be used, which is a 
> > good thing. But the converse is more problematic -- if there's an existing 
> > Subjects line that gets removed because a subject is added that is 
> > difficult to express in TableGen it may break user code.
> > 
> > We can fix the discoverability issues somewhat by updating the 
> > documentation emitter to spit out some wording that says when an attribute 
> > is/is not supported by this feature, but that only works for attributes 
> > which have documentation and so it's not a particularly reliable workaround.
> > I have strong reservations about this -- users are going to have no idea 
> > what attributes are and are not supported because they're not going to know 
> > whether the attribute has a subject list or requires delayed parsing. We 
> > have a considerable number of attributes for which the Subjects line is 
> > currently commented out simply because no one has bothered to fix that. 
> > This means those attributes can't be used with this pragma until someone 
> > fixes that, but when it happens, they magically can be used, which is a 
> > good thing. But the converse is more problematic -- if there's an existing 
> > Subjects line that gets removed because a subject is added that is 
> > difficult to express in TableGen it may break user code.
> 
> That's a good point. I think we can address this problem by creating a test 
> that verifies the list of attributes that support the pragma. This would 
> allow us to ensure that no attributes loose the ability to use the pragma.
> 
> > We can fix the discoverability issues somewhat by updating the 
> > documentation emitter to spit out some wording that says when an attribute 
> > is/is not supported by this feature, but that only works for attributes 
> > which have documentation and so it's not a particularly reliable workaround.
> 
> We can enforce the rule that the attributes can only be used with '#pragma 
> clang attribute' when they're documented. This way we can ensure that all 
> attributes that can be used with the pragma are explicitly documented.
> That's a good point. I think we can address this problem by creating a test 
> that verifies the list of attributes that support the pragma. This would 
> allow us to ensure that no attributes loose the ability to use the pragma.

That would be good.

> We can enforce the rule that the attributes can only be used with '#pragma 
> clang attribute' when they're documented. This way we can ensure that all 
> attributes that can be used with the pragma are explicitly documented.

This addresses the concern about discoverability, but it worsens the concerns 
about fragility. The biggest problem is: the user has very little hope of 
understanding what attributes will apply to what declarations with which 
version of the compiler they're using. With this sort of thing, the act of us 
adding documentation can impact the behavior of a user's program from one 
release to the next.

While I can imagine this pragma reducing some amount of code clutter, it is far 
too "magical" for me to feel comfortable with it (at least in the proposed 
form). I cannot read the user's source code and understand what attributes are 
going to be applied to which declarations, and that's not a good story for 
usability of the feature.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D29930: Add `__reference_binds_to_temporary` trait for checking safe reference initialization.

2017-02-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 88795.
EricWF added a comment.

Remove test code that snuck in.


https://reviews.llvm.org/D29930

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/TokenKinds.def
  include/clang/Basic/TypeTraits.h
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/type-traits.cpp

Index: test/SemaCXX/type-traits.cpp
===
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -2048,6 +2048,8 @@
 
   // PR25513
   { int arr[F(__is_constructible(int(int)))]; }
+
+  { int arr[T(__is_constructible(int const&, long))]; }
 }
 
 // Instantiation of __is_trivially_constructible
@@ -2078,6 +2080,46 @@
   { int arr[F((is_trivially_constructible::value))]; } // PR19178
 }
 
+template 
+struct ConvertsToRef {
+  operator RefType() const { return static_cast(obj); }
+  mutable T obj = 42;
+};
+
+void reference_binds_to_temporary_checks() {
+  { int arr[F((__reference_binds_to_temporary(int&, int&)))]; }
+  { int arr[F((__reference_binds_to_temporary(int&, int&&)))]; }
+
+  { int arr[F((__reference_binds_to_temporary(int const&, int&)))]; }
+  { int arr[F((__reference_binds_to_temporary(int const&, int const&)))]; }
+  { int arr[F((__reference_binds_to_temporary(int const&, int&&)))]; }
+
+  { int arr[F((__reference_binds_to_temporary(int&, long &)))]; } // doesn't construct
+  { int arr[T((__reference_binds_to_temporary(int const&, long&)))]; }
+  { int arr[T((__reference_binds_to_temporary(int const&, long&&)))]; }
+  { int arr[T((__reference_binds_to_temporary(int&&, long&)))]; }
+
+  using LRef = ConvertsToRef;
+  using RRef = ConvertsToRef;
+  using CLRef = ConvertsToRef;
+  using LongRef = ConvertsToRef;
+  { int arr[T((__is_constructible(int&, LRef)))]; }
+  { int arr[F((__reference_binds_to_temporary(int&, LRef)))]; }
+
+  { int arr[T((__is_constructible(int&&, RRef)))]; }
+  { int arr[F((__reference_binds_to_temporary(int&&, RRef)))]; }
+
+  { int arr[T((__is_constructible(int const&, CLRef)))]; }
+  { int arr[F((__reference_binds_to_temporary(int&&, CLRef)))]; }
+
+  { int arr[T((__is_constructible(int const&, LongRef)))]; }
+  { int arr[T((__reference_binds_to_temporary(int const&, LongRef)))]; }
+
+  // Test that it doesn't accept non-reference types as input.
+  { int arr[F((__reference_binds_to_temporary(int, long)))]; }
+
+}
+
 void array_rank() {
   int t01[T(__array_rank(IntAr) == 1)];
   int t02[T(__array_rank(ConstIntArAr) == 2)];
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4564,11 +4564,14 @@
   if (Kind <= UTT_Last)
 return EvaluateUnaryTypeTrait(S, Kind, KWLoc, Args[0]->getType());
 
-  if (Kind <= BTT_Last)
+  // Evaluate BTT_ReferenceBindsToTemporary along side the IsConstructible
+  // traits to avoid duplication.
+  if (Kind <= BTT_Last && Kind != BTT_ReferenceBindsToTemporary)
 return EvaluateBinaryTypeTrait(S, Kind, Args[0]->getType(),
Args[1]->getType(), RParenLoc);
 
   switch (Kind) {
+  case clang::BTT_ReferenceBindsToTemporary:
   case clang::TT_IsConstructible:
   case clang::TT_IsNothrowConstructible:
   case clang::TT_IsTriviallyConstructible: {
@@ -4644,6 +4647,13 @@
 if (Kind == clang::TT_IsConstructible)
   return true;
 
+if (Kind == clang::BTT_ReferenceBindsToTemporary) {
+  if (!T->isReferenceType())
+return false;
+
+  return !Init.isDirectReferenceBinding();
+}
+
 if (Kind == clang::TT_IsNothrowConstructible)
   return S.canThrow(Result.get()) == CT_Cannot;
 
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -847,6 +847,7 @@
   REVERTIBLE_TYPE_TRAIT(__is_unsigned);
   REVERTIBLE_TYPE_TRAIT(__is_void);
   REVERTIBLE_TYPE_TRAIT(__is_volatile);
+  REVERTIBLE_TYPE_TRAIT(__reference_binds_to_temporary);
 #undef REVERTIBLE_TYPE_TRAIT
 #undef RTT_JOIN
 }
Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -1431,7 +1431,8 @@
   tok::kw___is_union,
   tok::kw___is_unsigned,
   tok::kw___is_void,
-  tok::kw___is_volatile))
+  tok::kw___is_volatile,
+  tok::kw___reference_binds_to_temporary))
 // GNU libstdc++ 4.2 and libc++ use certain intrinsic names as the
 // name of struct templates, but some are keywords in GCC >= 4.3
 // and Clang. Therefore, when we see the token sequence "struct
Index: include/clang/Basic/TypeTraits.h
===
--- include/clang/Basic/TypeTraits.h
+++ include/clang/Basic/TypeTraits.h
@@ -77,7 

  1   2   >