Re: [PATCH] D18203: [OPENMP] Implementation of codegen for firstprivate clause of target directive

2016-03-15 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: lib/Sema/SemaOpenMP.cpp:9779-9780
@@ +9778,4 @@
+if (DKind == OMPD_target) {
+  if(VD && DSAStack->isPrivate(VD)) {
+auto DVar = DSAStack->getTopDSA(VD, false);
+Diag(ELoc, diag::err_omp_variable_in_map_and_dsa)

You still use `getTopDSA()` here, maybe it is better to not call `isPrivate()` 
and use direct checks like this:
```
auto DVar = DSAStack->getTopDSA(D, false);
if (VD && isOpenMPPrivate(DVar.CKind))
 .
```
Besides, I don't think we need `isPrivate()` and `isFirstPrivate()` member 
functions.


Comment at: lib/Sema/SemaOpenMP.cpp:9782-9783
@@ +9781,4 @@
+Diag(ELoc, diag::err_omp_variable_in_map_and_dsa)
+<< getOpenMPClauseName(DSAStack->isFirstPrivate(VD) ?
+   OMPC_firstprivate : OMPC_private)
+<< getOpenMPDirectiveName(DSAStack->getCurrentDirective());

Again, `DSAStack->isFirstPrivate(VD) ? OMPC_firstprivate : OMPC_private` can be 
replaced by simple code like this one `DVar.CKind`
Also, additional checks must be added to private clauses, which does not allow 
to privatize variables, that already are mapped. Maybe you need to use new DSA 
kind `OMPC_map` and mark all mapped variables as one having `OMPC_map` 
data-sharing attribute?


Repository:
  rL LLVM

http://reviews.llvm.org/D18203



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


Re: [PATCH] D15944: [OpenMP] Parsing and sema support for target update directive

2016-03-15 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: include/clang/AST/OpenMPClause.h:3466
@@ -3465,1 +3465,3 @@
 };
+
+/// \brief This represents clause 'from' in the '#pragma omp ...'

New clauses must be added in separate patches



http://reviews.llvm.org/D15944



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


r263617 - Reapply: [VFS] Add support for handling path traversals

2016-03-15 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Mar 15 23:39:38 2016
New Revision: 263617

URL: http://llvm.org/viewvc/llvm-project?rev=263617=rev
Log:
Reapply: [VFS] Add support for handling path traversals

This is originally r261551, reverted because of windows bots failing on
unittests. Change the current behavior to do not handle path traversals
on windows.

Handle ".", ".." and "./" with trailing slashes while collecting files
to be dumped into the vfs overlay directory.

Include the support for symlinks into components. Given the path:

/install-dir/bin/../lib/clang/3.8.0/include/altivec.h, if "bin"
component is a symlink, it's not safe to use `path::remove_dots` here,
and `realpath` is used to get the right answer. Since `realpath`
is expensive, we only do it at collecting time (which only happens
during the crash reproducer) and cache the base directory for fast lookups.

Overall, this makes the input to the VFS YAML file to be canonicalized
to never contain traversal components.

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

rdar://problem/24499339

Added:
cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m
cfe/trunk/test/Modules/crash-vfs-path-traversal.m
Modified:
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=263617=263616=263617=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Tue Mar 15 23:39:38 2016
@@ -112,6 +112,20 @@ bool FileSystem::exists(const Twine 
   return Status && Status->exists();
 }
 
+#ifndef NDEBUG
+static bool isTraversalComponent(StringRef Component) {
+  return Component.equals("..") || Component.equals(".");
+}
+
+static bool pathHasTraversal(StringRef Path) {
+  using namespace llvm::sys;
+  for (StringRef Comp : llvm::make_range(path::begin(Path), path::end(Path)))
+if (isTraversalComponent(Comp))
+  return true;
+  return false;
+}
+#endif
+
 
//===---===/
 // RealFileSystem implementation
 
//===---===/
@@ -819,6 +833,16 @@ class RedirectingFileSystem : public vfs
   bool UseExternalNames;
   /// @}
 
+  /// Virtual file paths and external files could be canonicalized without 
"..",
+  /// "." and "./" in their paths. FIXME: some unittests currently fail on
+  /// win32 when using remove_dots and remove_leading_dotslash on paths.
+  bool UseCanonicalizedPaths =
+#ifdef LLVM_ON_WIN32
+  false;
+#else
+  true;
+#endif
+
   friend class RedirectingFileSystemParser;
 
 private:
@@ -954,7 +978,7 @@ class RedirectingFileSystemParser {
 return true;
   }
 
-  std::unique_ptr parseEntry(yaml::Node *N) {
+  std::unique_ptr parseEntry(yaml::Node *N, RedirectingFileSystem *FS) {
 yaml::MappingNode *M = dyn_cast(N);
 if (!M) {
   error(N, "expected mapping node for file or directory entry");
@@ -994,7 +1018,17 @@ class RedirectingFileSystemParser {
   if (Key == "name") {
 if (!parseScalarString(I->getValue(), Value, Buffer))
   return nullptr;
-Name = Value;
+
+if (FS->UseCanonicalizedPaths) {
+  SmallString<256> Path(Value);
+  // Guarantee that old YAML files containing paths with ".." and "."
+  // are properly canonicalized before read into the VFS.
+  Path = sys::path::remove_leading_dotslash(Path);
+  sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
+  Name = Path.str();
+} else {
+  Name = Value;
+}
   } else if (Key == "type") {
 if (!parseScalarString(I->getValue(), Value, Buffer))
   return nullptr;
@@ -1024,7 +1058,7 @@ class RedirectingFileSystemParser {
 for (yaml::SequenceNode::iterator I = Contents->begin(),
   E = Contents->end();
  I != E; ++I) {
-  if (std::unique_ptr E = parseEntry(&*I))
+  if (std::unique_ptr E = parseEntry(&*I, FS))
 EntryArrayContents.push_back(std::move(E));
   else
 return nullptr;
@@ -1038,7 +1072,16 @@ class RedirectingFileSystemParser {
 HasContents = true;
 if (!parseScalarString(I->getValue(), Value, Buffer))
   return nullptr;
-ExternalContentsPath = Value;
+if (FS->UseCanonicalizedPaths) {
+  SmallString<256> Path(Value);
+  // Guarantee that old YAML files containing paths with ".." and "."
+  // are properly canonicalized before read into the VFS.
+  Path = sys::path::remove_leading_dotslash(Path);
+  sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
+  ExternalContentsPath = Path.str();
+} else {
+ 

Re: [PATCH] D16965: Fix for Bug 14644 - clang confuses scope operator for global namespace giving extra qualification on member

2016-03-15 Thread Ryan Yee via cfe-commits
ryee88 added a comment.

Anyone want to pick up this review?


http://reviews.llvm.org/D16965



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


[PATCH] D18203: [OPENMP] Implementation of codegen for firstprivate clause of target directive

2016-03-15 Thread Carlo Bertolli via cfe-commits
carlo.bertolli created this revision.
carlo.bertolli added reviewers: ABataev, kkwli0.
carlo.bertolli added subscribers: sfantao, arpith-jacob, caomhin, fraggamuffin, 
cfe-commits.
carlo.bertolli set the repository for this revision to rL LLVM.

This patch implements the following aspects:

- It extends sema to check that a variable is not reference in both a map 
clause and firstprivate or private. This is needed to ensure correct 
functioning at codegen level, apart from being useful for the user.

- It implements firstprivate for target in codegen. The implementation applies 
to both host and nvptx devices.

- It adds regression tests for codegen of firstprivate, host and device side 
when using the host as device, and nvptx side.
Please note that the regression test for nvptx codegen is missing VLAs. This is 
because VLAs currently require saving and restoring the stack which appears not 
to be a supported operation by nvptx backend.

- It adds a check in sema regression tests for target map, firstprivate, and 
private clauses. 

Repository:
  rL LLVM

http://reviews.llvm.org/D18203

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/nvptx_target_firstprivate_codegen.cpp
  test/OpenMP/target_firstprivate_codegen.cpp
  test/OpenMP/target_firstprivate_messages.cpp
  test/OpenMP/target_map_messages.cpp
  test/OpenMP/target_private_messages.cpp

Index: test/OpenMP/target_private_messages.cpp
===
--- test/OpenMP/target_private_messages.cpp
+++ test/OpenMP/target_private_messages.cpp
@@ -189,6 +189,8 @@
   static int si;
 #pragma omp target private(si) // OK
   {}
+#pragma omp target map(i) private(i) // expected-error {{private variable cannot be in a map clause in '#pragma omp target' directive}}
+  {}
   s6 = s6_0; // expected-note {{in instantiation of member function 'S6::operator=' requested here}}
   s7 = s7_0; // expected-note {{in instantiation of member function 'S7::operator=' requested here}}
   return foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain' requested here}}
Index: test/OpenMP/target_map_messages.cpp
===
--- test/OpenMP/target_map_messages.cpp
+++ test/OpenMP/target_map_messages.cpp
@@ -500,6 +500,10 @@
 #pragma omp target data map(always, tofrom: always, tofrom, x)
 #pragma omp target map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
   foo();
+#pragma omp target private(j) map(j) // expected-error {{private variable cannot be in a map clause in '#pragma omp target' directive}}  expected-note {{defined as private}}
+  {}
+#pragma omp target firstprivate(j) map(j)  // expected-error {{firstprivate variable cannot be in a map clause in '#pragma omp target' directive}} expected-note {{defined as firstprivate}}
+  {}
   return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
 #endif
Index: test/OpenMP/target_firstprivate_messages.cpp
===
--- test/OpenMP/target_firstprivate_messages.cpp
+++ test/OpenMP/target_firstprivate_messages.cpp
@@ -189,6 +189,8 @@
   static int si;
 #pragma omp target firstprivate(si) // OK
   {}
+#pragma omp target map(i) firstprivate(i) // expected-error {{firstprivate variable cannot be in a map clause in '#pragma omp target' directive}}
+  {}
   s6 = s6_0; // expected-note {{in instantiation of member function 'S6::operator=' requested here}}
   s7 = s7_0; // expected-note {{in instantiation of member function 'S7::operator=' requested here}}
   return foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain' requested here}}
Index: test/OpenMP/target_firstprivate_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_firstprivate_codegen.cpp
@@ -0,0 +1,595 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK 

Re: [PATCH] D17815: [libc++abi] Use fallback_malloc to allocate __cxa_eh_globals in case of dynamic memory exhaustion.

2016-03-15 Thread Igor Kudrin via cfe-commits
ikudrin added a comment.

Thanks! I'll see what I can do about it.


http://reviews.llvm.org/D17815



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


Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-15 Thread Eric Fiselier via cfe-commits
EricWF closed this revision.
EricWF added a comment.

Committed in r263611.


http://reviews.llvm.org/D14731



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


[libcxx] r263611 - Add clang thread safety annotations to mutex and lock_guard. Patch by jam...@google.com.

2016-03-15 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Mar 15 21:30:06 2016
New Revision: 263611

URL: http://llvm.org/viewvc/llvm-project?rev=263611=rev
Log:
Add clang thread safety annotations to mutex and lock_guard. Patch by 
jam...@google.com.

This adds clang thread safety annotations to std::mutex and
std::lock_guard so code using these types can use these types directly
instead of having to wrap the types to provide annotations. These checks
when enabled by -Wthread-safety provide simple but useful static
checking to detect potential race conditions.
See http://clang.llvm.org/docs/ThreadSafetyAnalysis.html for details.

This patch was reviewed in http://reviews.llvm.org/D14731.

Added:
libcxx/trunk/test/libcxx/thread/thread.mutex/

libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp

libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp

libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp

libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp

libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/__mutex_base
libcxx/trunk/test/libcxx/test/config.py

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=263611=263610=263611=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Tue Mar 15 21:30:06 2016
@@ -859,6 +859,11 @@ extern "C" void __sanitizer_annotate_con
 #endif
 #endif
 
+#if (defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) \
+  && __has_attribute(acquire_capability))
+#define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
+#endif
+
 #endif // __cplusplus
 
 #endif // _LIBCPP_CONFIG

Modified: libcxx/trunk/include/__mutex_base
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__mutex_base?rev=263611=263610=263611=diff
==
--- libcxx/trunk/include/__mutex_base (original)
+++ libcxx/trunk/include/__mutex_base Tue Mar 15 21:30:06 2016
@@ -26,7 +26,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 #ifndef _LIBCPP_HAS_NO_THREADS
 
-class _LIBCPP_TYPE_VIS mutex
+#ifndef _LIBCPP_THREAD_SAFETY_ANNOTATION
+#  ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
+#define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
+#  else
+#define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
+#  endif
+#endif  // _LIBCPP_THREAD_SAFETY_ANNOTATION
+
+class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) 
mutex
 {
 pthread_mutex_t __m_;
 
@@ -44,9 +52,9 @@ private:
 mutex& operator=(const mutex&);// = delete;
 
 public:
-void lock();
-bool try_lock() _NOEXCEPT;
-void unlock() _NOEXCEPT;
+void lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability());
+bool try_lock() _NOEXCEPT 
_LIBCPP_THREAD_SAFETY_ANNOTATION(try_acquire_capability(true));
+void unlock() _NOEXCEPT 
_LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability());
 
 typedef pthread_mutex_t* native_handle_type;
 _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return 
&__m_;}
@@ -71,7 +79,7 @@ constexpr adopt_lock_t  adopt_lock  = ad
 #endif
 
 template 
-class _LIBCPP_TYPE_VIS_ONLY lock_guard
+class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable) 
lock_guard
 {
 public:
 typedef _Mutex mutex_type;
@@ -81,13 +89,13 @@ private:
 public:
 
 _LIBCPP_INLINE_VISIBILITY
-explicit lock_guard(mutex_type& __m)
+explicit lock_guard(mutex_type& __m) 
_LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m))
 : __m_(__m) {__m_.lock();}
 _LIBCPP_INLINE_VISIBILITY
-lock_guard(mutex_type& __m, adopt_lock_t)
+lock_guard(mutex_type& __m, adopt_lock_t) 
_LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
 : __m_(__m) {}
 _LIBCPP_INLINE_VISIBILITY
-~lock_guard() {__m_.unlock();}
+~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) 
{__m_.unlock();}
 
 private:
 lock_guard(lock_guard const&);// = delete;

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=263611=263610=263611=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Tue Mar 15 21:30:06 2016
@@ -98,6 +98,7 @@ class Configuration(object):
 self.configure_cxx_library_root()
 self.configure_use_system_cxx_lib()
 self.configure_use_clang_verify()
+self.configure_use_thread_safety()
 self.configure_execute_external()
 self.configure_ccache()
 self.configure_compile_flags()
@@ -218,6 +219,14 @@ 

Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-15 Thread James Robinson via cfe-commits
jamesr updated this revision to Diff 50793.
jamesr added a comment.

Add LLVM license headers to new test files


http://reviews.llvm.org/D14731

Files:
  include/__config
  include/__mutex_base
  test/libcxx/test/config.py
  test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
  test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp
  test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp
  test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp
  test/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp

Index: test/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp
@@ -0,0 +1,29 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// REQUIRES: thread-safety
+
+// 
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+void increment() __attribute__((requires_capability(m))) {
+  foo++;
+}
+
+int main() {
+  m.lock();
+  increment();
+  m.unlock();
+}
Index: test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp
@@ -0,0 +1,22 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// REQUIRES: thread-safety
+
+// 
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+
+int main() {
+  m.lock();
+} // expected-error {{mutex 'm' is still held at the end of function}}
Index: test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp
@@ -0,0 +1,25 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// REQUIRES: thread-safety
+
+// 
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+int main() {
+  m.lock();
+  foo++;
+  m.unlock();
+}
Index: test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp
@@ -0,0 +1,24 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// REQUIRES: thread-safety
+
+// 
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+int main() {
+  std::lock_guard lock(m);
+  foo++;
+}
Index: test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
@@ -0,0 +1,24 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// This test does not define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS so it
+// should compile without any warnings or errors even though this pattern is not
+// understood by the thread safety annotations.
+
+#include 
+
+int main() {
+  std::mutex m;
+  m.lock();
+  {
+std::unique_lock g(m, std::adopt_lock);
+  }
+}
Index: test/libcxx/test/config.py

Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-15 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

Oh fudge. One last change. The tests need license headers. Just copy it from an 
existing test. LGTM after that.

Thanks again.


http://reviews.llvm.org/D14731



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


Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-15 Thread James Robinson via cfe-commits
jamesr updated this revision to Diff 50791.
jamesr added a comment.

Use // REQUIRES: thread-safety instead of macros to feature guard tests


http://reviews.llvm.org/D14731

Files:
  include/__config
  include/__mutex_base
  test/libcxx/test/config.py
  test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
  test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp
  test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp
  test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp
  test/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp

Index: test/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp
@@ -0,0 +1,18 @@
+// REQUIRES: thread-safety
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+void increment() __attribute__((requires_capability(m))) {
+  foo++;
+}
+
+int main() {
+  m.lock();
+  increment();
+  m.unlock();
+}
Index: test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp
@@ -0,0 +1,11 @@
+// REQUIRES: thread-safety
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+
+int main() {
+  m.lock();
+} // expected-error {{mutex 'm' is still held at the end of function}}
Index: test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp
@@ -0,0 +1,14 @@
+// REQUIRES: thread-safety
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+int main() {
+  m.lock();
+  foo++;
+  m.unlock();
+}
Index: test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp
@@ -0,0 +1,13 @@
+// REQUIRES: thread-safety
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+int main() {
+  std::lock_guard lock(m);
+  foo++;
+}
Index: test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
@@ -0,0 +1,13 @@
+// This test does not define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS so it
+// should compile without any warnings or errors even though this pattern is not
+// understood by the thread safety annotations.
+
+#include 
+
+int main() {
+  std::mutex m;
+  m.lock();
+  {
+std::unique_lock g(m, std::adopt_lock);
+  }
+}
Index: test/libcxx/test/config.py
===
--- test/libcxx/test/config.py
+++ test/libcxx/test/config.py
@@ -98,6 +98,7 @@
 self.configure_cxx_library_root()
 self.configure_use_system_cxx_lib()
 self.configure_use_clang_verify()
+self.configure_use_thread_safety()
 self.configure_execute_external()
 self.configure_ccache()
 self.configure_compile_flags()
@@ -218,6 +219,14 @@
 self.lit_config.note(
 "inferred use_clang_verify as: %r" % self.use_clang_verify)
 
+def configure_use_thread_safety(self):
+'''If set, run clang with -verify on failing tests.'''
+has_thread_safety = self.cxx.hasCompileFlag('-Werror=thread-safety')
+if has_thread_safety:
+self.cxx.compile_flags += ['-Werror=thread-safety']
+self.config.available_features.add('thread-safety')
+self.lit_config.note("enabling thread-safety annotations")
+
 def configure_execute_external(self):
 # Choose between lit's internal shell pipeline runner and a real shell.
 # If LIT_USE_INTERNAL_SHELL is in the environment, we use that as the
Index: include/__mutex_base
===
--- include/__mutex_base
+++ include/__mutex_base
@@ -26,7 +26,15 @@
 
 #ifndef _LIBCPP_HAS_NO_THREADS
 
-class _LIBCPP_TYPE_VIS mutex
+#ifndef _LIBCPP_THREAD_SAFETY_ANNOTATION
+#  ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
+#define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
+#  else
+#define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
+#  endif
+#endif  // _LIBCPP_THREAD_SAFETY_ANNOTATION
+
+class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex
 {
 pthread_mutex_t __m_;
 
@@ -44,9 +52,9 @@
   

Re: [modules] PR24954

2016-03-15 Thread Richard Smith via cfe-commits
Please restrict this to the case where the function template is a
friend (check D->getFriendObjectKind()). Otherwise, this looks good to
me. Thanks!

On Mon, Mar 7, 2016 at 2:23 AM, Vassil Vassilev  wrote:
> ping...
>
> On 22/02/16 21:51, Vassil Vassilev wrote:
>>
>> On 02/02/16 02:52, Richard Smith via cfe-commits wrote:
>>>
>>> On Thu, Jan 28, 2016 at 8:23 AM, Vassil Vassilev 
>>> wrote:

 Would this patch be more reasonable? It follows what
 RegisterTemplateSpecialization (introduced in r245779) does. AFAICT this
 adds an update record far less often.
>>>
>>> It's still adding redundant update records. We'll write the
>>> appropriate update record as part of serializing the declaration
>>> itself, so we only need to ensure that the declaration is emitted, not
>>> actually emit an update record for it. Perhaps you could store a list
>>> of such declarations on the ASTWriter, and call GetDeclRef on each of
>>> them once we start emitting the AST file (or maybe just push them into
>>> UpdatingVisibleDecls). Please also restrict this to the template
>>> friend corner case.
>>
>> The attached patch fixes the issues more or less in the direction you
>> suggest. I am not sure if I expressed well enough the conditions of the
>> template friend corner case. Could you have a look?
>>>
>>>
 --Vassil

 On 12/12/15 16:13, Vassil Vassilev wrote:

 I couldn't find GetDecl routine in the ASTWriter. Could you elaborate?

 Assuming you meant ASTWriter::GetDeclRef(D): It seems that the
 conditions
 when calling GetDeclRef differ from the conditions of
 AddedCXXTemplateSpecialization. Eg:

 ASTWriter::AddedCXXTemplateSpecialization {
assert(!WritingAST && "Already writing the AST!");
...
 }
 ASTWriter::GetDeclRef {
assert(WritingAST && "Cannot request a declaration ID before AST
 writing");
..
 }

 IIUC this particular instantiation happens *after* module B was built,
 thus
 it needs to be retrospectively added to the serialized namespace. It
 looks
 like even avoiding somehow the asserts of GetDeclRef it wouldn't help
 much.

 Alternatively I could try to reduce the redundant update records by
 narrowing down to instantiations coming in the context of friends.

 --Vassil

 On 12/12/15 01:07, Richard Smith wrote:

 Instead of adding an update record directly in this case (which will
 emit
 far more update records than necessary), how about just calling
 GetDecl(D)
 from AddedCXXTemplateSpecialization to ensure that it gets emitted?

 On Fri, Dec 4, 2015 at 7:46 AM, Vassil Vassilev 
 wrote:
>
> Hi,
>Could you review my fix please.
> Many thanks,
> Vassil
>
> On 08/10/15 15:53, Vassil Vassilev wrote:
>>
>> Hi Richard,
>>I started working on https://llvm.org/bugs/show_bug.cgi?id=24954
>>
>>IIUC r228485 introduces an abstraction to deal with
>> not-really-anonymous friend decls
>> (serialization::needsAnonymousDeclarationNumber in ASTCommon.cpp).
>>
>>A comment explicitly says:
>>"// This doesn't apply to friend tag decls; Sema makes those
>> available
>> to name
>> // lookup in the surrounding context."
>>
>>In the bug reproducer, the friend function (wrt __iom_t10) is
>> forward
>> declared in the same namespace, where Sema makes the friend available
>> for a
>> name lookup.
>>
>>It seems that the friend operator<< in __iom_t10 (sorry about the
>> names
>> they come from libcxx) doesn't get registered in the ASTWriter's
>> DeclIDs but
>> it gets registered in outer namespace's lookup table. Thus, assert is
>> triggered when finalizing module A, since it rebuilds the lookups of
>> the
>> updated contexts.
>>
>>The issue only appears when building module A deserializes/uses
>> module
>> B.
>>
>>Currently I was assume that something wrong happens in either
>> needsAnonymousDeclarationNumber or I hit a predicted issue
>> ASTWriterDecl.cpp:1602
>>  // FIXME: This is not correct; when we reach an imported
>> declaration
>> we
>>  // won't emit its previous declaration.
>>  (void)Writer.GetDeclRef(D->getPreviousDecl());
>>  (void)Writer.GetDeclRef(MostRecent);
>>
>>The issue seems a fairly complex one and I am a bit stuck.
>>
>>Any hints are very very welcome ;)
>> Many thanks,
>> Vassil
>>
>>
>>


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

Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-15 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Yes exactly. `// REQUIRES: ` tells LIT to skip the test (and report it 
as UNSUPPORTED) whenever the feature is not present.


http://reviews.llvm.org/D14731



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


Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-15 Thread James Robinson via cfe-commits
jamesr added a comment.

In http://reviews.llvm.org/D14731#376138, @EricWF wrote:

> So this LGTM except for one last change (I'm sorry). LIT now knows when 
> "-Werror=thread-safety" is being passed. Could you change the tests guarded 
> by "#if !defined(__clang__) || !__has_attribute(aquire_capability)` to say 
> "// REQUIRES: thread-safety" instead? I prefer using LIT to manage when tests 
> run because it can report un-run tests where simply using macros cant.
>
> After that LGTM.


If I do that, does that mean I can omit the extra main()s, etc, and the LIT 
harness will avoid attempting the test at all when the feature bit is set?


http://reviews.llvm.org/D14731



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


Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-15 Thread Eric Fiselier via cfe-commits
EricWF added inline comments.


Comment at: include/__mutex_base:37
@@ -30,1 +36,3 @@
+
+class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) 
mutex
 {

I appreciate the super thorough answer!


http://reviews.llvm.org/D14731



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


Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-15 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

So this LGTM except for one last change (I'm sorry). LIT now knows when 
"-Werror=thread-safety" is being passed. Could you change the tests guarded by 
"#if !defined(__clang__) || !__has_attribute(aquire_capability)` to say "// 
REQUIRES: thread-safety" instead? I prefer using LIT to manage when tests run 
because it can report un-run tests where simply using macros cant.

After that LGTM.


http://reviews.llvm.org/D14731



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


Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-15 Thread James Robinson via cfe-commits
jamesr added a comment.

In http://reviews.llvm.org/D14731#376128, @EricWF wrote:

> So I fixed up LIT so that it also adds "-Werror=thread-safety" for both 
> ".pass.cpp" and ".fail.cpp" tests. Could you apply it to your patch?
>  https://gist.github.com/EricWF/8a0bfb6ff02f8c9f9940


Cool! Applied and confirmed that it's set for both.



Comment at: include/__mutex_base:37
@@ -30,1 +36,3 @@
+
+class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) 
mutex
 {

EricWF wrote:
> Does `capability` have a alternative keyword that's a reserved name? ie 
> `__capability__`? If so we should use that instead.
If I'm reading 
https://github.com/llvm-mirror/clang/blob/master/include/clang/Basic/Attr.td#L1657
 correctly:

def Capability : InheritableAttr {
  let Spellings = [GNU<"capability">, CXX11<"clang", "capability">,
   GNU<"shared_capability">,
   CXX11<"clang", "shared_capability">];

then the answer is unfortunately "no"


http://reviews.llvm.org/D14731



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


Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-15 Thread James Robinson via cfe-commits
jamesr updated this revision to Diff 50790.

http://reviews.llvm.org/D14731

Files:
  include/__config
  include/__mutex_base
  test/libcxx/test/config.py
  test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
  test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp
  test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp
  test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp
  test/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp

Index: test/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp
@@ -0,0 +1,26 @@
+#if !defined(__clang__) || !__has_attribute(acquire_capability)
+// This test is only meaningful on versions of clang that understand thread
+// safety annotations.
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+void increment() __attribute__((requires_capability(m))) {
+  foo++;
+}
+
+int main() {
+  m.lock();
+  increment();
+  m.unlock();
+}
+
+#else
+
+int main() {}
+
+#endif
Index: test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp
@@ -0,0 +1,15 @@
+#if !defined(__clang__) || !__has_attribute(acquire_capability)
+// This test is only meaningful on versions of clang that understand thread
+// safety annotations.
+#error Test only supported on clang versions that support the acquire_capability annotation
+#endif
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+
+int main() {
+  m.lock();
+} // expected-error {{mutex 'm' is still held at the end of function}}
Index: test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp
@@ -0,0 +1,22 @@
+#if !defined(__clang__) || !__has_attribute(acquire_capability)
+// This test is only meaningful on versions of clang that understand thread
+// safety annotations.
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+int main() {
+  m.lock();
+  foo++;
+  m.unlock();
+}
+
+#else
+
+int main() {}
+
+#endif
Index: test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp
@@ -0,0 +1,21 @@
+#if !defined(__clang__) || !__has_attribute(acquire_capability)
+// This test is only meaningful on versions of clang that understand thread
+// safety annotations.
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+int main() {
+  std::lock_guard lock(m);
+  foo++;
+}
+
+#else
+
+int main() {}
+
+#endif
Index: test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
@@ -0,0 +1,13 @@
+// This test does not define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS so it
+// should compile without any warnings or errors even though this pattern is not
+// understood by the thread safety annotations.
+
+#include 
+
+int main() {
+  std::mutex m;
+  m.lock();
+  {
+std::unique_lock g(m, std::adopt_lock);
+  }
+}
Index: test/libcxx/test/config.py
===
--- test/libcxx/test/config.py
+++ test/libcxx/test/config.py
@@ -98,6 +98,7 @@
 self.configure_cxx_library_root()
 self.configure_use_system_cxx_lib()
 self.configure_use_clang_verify()
+self.configure_use_thread_safety()
 self.configure_execute_external()
 self.configure_ccache()
 self.configure_compile_flags()
@@ -218,6 +219,14 @@
 self.lit_config.note(
 "inferred use_clang_verify as: %r" % self.use_clang_verify)
 
+def configure_use_thread_safety(self):
+'''If set, run clang with -verify on failing tests.'''
+has_thread_safety = self.cxx.hasCompileFlag('-Werror=thread-safety')
+if has_thread_safety:
+self.cxx.compile_flags += ['-Werror=thread-safety']
+self.config.available_features.add('thread-safety')
+self.lit_config.note("enabling thread-safety annotations")
+
 def configure_execute_external(self):
 # Choose between lit's internal shell pipeline runner and a real shell.
 # If LIT_USE_INTERNAL_SHELL is in the 

Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-15 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

So I fixed up LIT so that it also adds "-Werror=thread-safety" for both 
".pass.cpp" and ".fail.cpp" tests. Could you apply it to your patch?
https://gist.github.com/EricWF/8a0bfb6ff02f8c9f9940



Comment at: include/__mutex_base:37
@@ -30,1 +36,3 @@
+
+class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) 
mutex
 {

Does `capability` have a alternative keyword that's a reserved name? ie 
`__capability__`? If so we should use that instead.


http://reviews.llvm.org/D14731



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


Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-15 Thread James Robinson via cfe-commits
jamesr updated this revision to Diff 50788.

http://reviews.llvm.org/D14731

Files:
  include/__config
  include/__mutex_base
  test/libcxx/test/format.py
  test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
  test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp
  test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp
  test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp
  test/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp

Index: test/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp
@@ -0,0 +1,26 @@
+#if !defined(__clang__) || !__has_attribute(acquire_capability)
+// This test is only meaningful on versions of clang that understand thread
+// safety annotations.
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+void increment() __attribute__((requires_capability(m))) {
+  foo++;
+}
+
+int main() {
+  m.lock();
+  increment();
+  m.unlock();
+}
+
+#else
+
+int main() {}
+
+#endif
Index: test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp
@@ -0,0 +1,15 @@
+#if !defined(__clang__) || !__has_attribute(acquire_capability)
+// This test is only meaningful on versions of clang that understand thread
+// safety annotations.
+#error Test only supported on clang versions that support the acquire_capability annotation
+#endif
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+
+int main() {
+  m.lock();
+} // expected-error {{mutex 'm' is still held at the end of function}}
Index: test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp
@@ -0,0 +1,22 @@
+#if !defined(__clang__) || !__has_attribute(acquire_capability)
+// This test is only meaningful on versions of clang that understand thread
+// safety annotations.
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+int main() {
+  m.lock();
+  foo++;
+  m.unlock();
+}
+
+#else
+
+int main() {}
+
+#endif
Index: test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp
@@ -0,0 +1,21 @@
+#if !defined(__clang__) || !__has_attribute(acquire_capability)
+// This test is only meaningful on versions of clang that understand thread
+// safety annotations.
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+int main() {
+  std::lock_guard lock(m);
+  foo++;
+}
+
+#else
+
+int main() {}
+
+#endif
Index: test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
@@ -0,0 +1,13 @@
+// This test does not define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS so it
+// should compile without any warnings or errors even though this pattern is not
+// understood by the thread safety annotations.
+
+#include 
+
+int main() {
+  std::mutex m;
+  m.lock();
+  {
+std::unique_lock g(m, std::adopt_lock);
+  }
+}
Index: test/libcxx/test/format.py
===
--- test/libcxx/test/format.py
+++ test/libcxx/test/format.py
@@ -167,7 +167,7 @@
 # when using Clang.
 extra_flags = []
 if self.cxx.type != 'gcc':
-extra_flags += ['-fsyntax-only']
+extra_flags += ['-fsyntax-only', '-Werror=thread-safety']
 if use_verify:
 extra_flags += ['-Xclang', '-verify',
 '-Xclang', '-verify-ignore-unexpected=note']
Index: include/__mutex_base
===
--- include/__mutex_base
+++ include/__mutex_base
@@ -26,7 +26,15 @@
 
 #ifndef _LIBCPP_HAS_NO_THREADS
 
-class _LIBCPP_TYPE_VIS mutex
+#ifndef _LIBCPP_THREAD_SAFETY_ANNOTATION
+#  ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
+#define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
+#  else
+#define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
+#  endif
+#endif  // _LIBCPP_THREAD_SAFETY_ANNOTATION
+
+class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex
 {
 pthread_mutex_t __m_;
 
@@ -44,9 +52,9 @@
 mutex& operator=(const 

Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2016-03-15 Thread James Robinson via cfe-commits
jamesr marked 5 inline comments as done.
jamesr added a comment.

Thank you for the comments, new patch coming.. (is there a way to post comments 
and upload a new patch at the same time?)


http://reviews.llvm.org/D14731



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


Re: [PATCH] D14737: Convert some ObjC msgSends to runtime calls

2016-03-15 Thread Pete Cooper via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL263607: Convert some ObjC msgSends to runtime calls. 
(authored by pete).

Changed prior to commit:
  http://reviews.llvm.org/D14737?vs=50651=50785#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14737

Files:
  cfe/trunk/include/clang/Basic/ObjCRuntime.h
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/lib/CodeGen/CGObjC.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/CodeGen/CodeGenModule.h
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m
  cfe/trunk/test/Driver/objc-convert-messages-to-runtime-calls.m

Index: cfe/trunk/lib/CodeGen/CGObjC.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjC.cpp
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp
@@ -338,6 +338,69 @@
   return nullptr;
 }
 
+/// The ObjC runtime may provide entrypoints that are likely to be faster
+/// than an ordinary message send of the appropriate selector.
+///
+/// The entrypoints are guaranteed to be equivalent to just sending the
+/// corresponding message.  If the entrypoint is implemented naively as just a
+/// message send, using it is a trade-off: it sacrifices a few cycles of
+/// overhead to save a small amount of code.  However, it's possible for
+/// runtimes to detect and special-case classes that use "standard"
+/// retain/release behavior; if that's dynamically a large proportion of all
+/// retained objects, using the entrypoint will also be faster than using a
+/// message send.
+///
+/// If the runtime does support a required entrypoint, then this method will
+/// generate a call and return the resulting value.  Otherwise it will return
+/// None and the caller can generate a msgSend instead.
+static Optional
+tryGenerateSpecializedMessageSend(CodeGenFunction , QualType ResultType,
+  llvm::Value *Receiver, Selector Sel,
+  const ObjCMethodDecl *method) {
+  auto  = CGF.CGM;
+  if (!CGM.getCodeGenOpts().ObjCConvertMessagesToRuntimeCalls)
+return None;
+
+  auto  = CGM.getLangOpts().ObjCRuntime;
+  switch (Sel.getMethodFamily()) {
+  case OMF_alloc:
+// Make sure the name is exactly 'alloc'.  All methods with that
+// prefix are identified as OMF_alloc but we only want to call the
+// runtime for this version.
+if (Runtime.shouldUseRuntimeFunctionsForAlloc() && Sel.isUnarySelector() &&
+Sel.getNameForSlot(0) == "alloc" &&
+ResultType->isObjCObjectPointerType())
+  return CGF.EmitObjCAlloc(Receiver, CGF.ConvertType(ResultType));
+break;
+
+  case OMF_autorelease:
+if (ResultType->isObjCObjectPointerType() &&
+CGM.getLangOpts().getGC() == LangOptions::NonGC &&
+Runtime.shouldUseARCFunctionsForRetainRelease())
+  return CGF.EmitARCAutorelease(Receiver, CGF.ConvertType(ResultType));
+break;
+
+  case OMF_retain:
+if (ResultType->isObjCObjectPointerType() &&
+CGM.getLangOpts().getGC() == LangOptions::NonGC &&
+Runtime.shouldUseARCFunctionsForRetainRelease())
+  return CGF.EmitARCRetainNonBlock(Receiver, CGF.ConvertType(ResultType));
+break;
+
+  case OMF_release:
+if (ResultType->isVoidType() &&
+CGM.getLangOpts().getGC() == LangOptions::NonGC &&
+Runtime.shouldUseARCFunctionsForRetainRelease()) {
+  CGF.EmitARCRelease(Receiver, ARCPreciseLifetime);
+  return nullptr;
+}
+break;
+  default:
+break;
+  }
+  return None;
+}
+
 RValue CodeGenFunction::EmitObjCMessageExpr(const ObjCMessageExpr *E,
 ReturnValueSlot Return) {
   // Only the lookup mechanism and first two arguments of the method
@@ -460,10 +523,16 @@
   Args,
   method);
   } else {
-result = Runtime.GenerateMessageSend(*this, Return, ResultType,
- E->getSelector(),
- Receiver, Args, OID,
- method);
+// Call runtime methods directly if we can.
+if (Optional SpecializedResult =
+tryGenerateSpecializedMessageSend(*this, ResultType, Receiver,
+  E->getSelector(), method)) {
+  result = RValue::get(SpecializedResult.getValue());
+} else {
+  result = Runtime.GenerateMessageSend(*this, Return, ResultType,
+   E->getSelector(), Receiver, Args,
+   OID, method);
+}
   }
 
   // For delegate init calls in ARC, implicitly store the result of
@@ -1814,6 +1883,7 @@
 /// where a null input causes a no-op and returns null.
 static llvm::Value 

r263607 - Convert some ObjC msgSends to runtime calls.

2016-03-15 Thread Pete Cooper via cfe-commits
Author: pete
Date: Tue Mar 15 19:33:21 2016
New Revision: 263607

URL: http://llvm.org/viewvc/llvm-project?rev=263607=rev
Log:
Convert some ObjC msgSends to runtime calls.

It is faster to directly call the ObjC runtime for methods such as 
retain/release instead of sending a message to those functions.

This patch adds support for converting messages to 
retain/release/alloc/autorelease to their equivalent runtime calls.

Tests included for the positive case of applying this transformation, negative 
tests that we ensure we only convert "alloc" to objc_alloc, not "alloc2", and 
also a driver test to ensure we enable this only for supported runtime versions.

Reviewed by John McCall.

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

Added:
cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m
cfe/trunk/test/Driver/objc-convert-messages-to-runtime-calls.m
Modified:
cfe/trunk/include/clang/Basic/ObjCRuntime.h
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Basic/ObjCRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/ObjCRuntime.h?rev=263607=263606=263607=diff
==
--- cfe/trunk/include/clang/Basic/ObjCRuntime.h (original)
+++ cfe/trunk/include/clang/Basic/ObjCRuntime.h Tue Mar 15 19:33:21 2016
@@ -171,6 +171,79 @@ public:
 llvm_unreachable("bad kind");
   }
 
+  /// Does this runtime provide ARC entrypoints that are likely to be faster
+  /// than an ordinary message send of the appropriate selector?
+  ///
+  /// The ARC entrypoints are guaranteed to be equivalent to just sending the
+  /// corresponding message.  If the entrypoint is implemented naively as just 
a
+  /// message send, using it is a trade-off: it sacrifices a few cycles of
+  /// overhead to save a small amount of code.  However, it's possible for
+  /// runtimes to detect and special-case classes that use "standard"
+  /// retain/release behavior; if that's dynamically a large proportion of all
+  /// retained objects, using the entrypoint will also be faster than using a
+  /// message send.
+  ///
+  /// When this method returns true, Clang will turn non-super message sends of
+  /// certain selectors into calls to the correspond entrypoint:
+  ///   retain => objc_retain
+  ///   release => objc_release
+  bool shouldUseARCFunctionsForRetainRelease() const {
+switch (getKind()) {
+case FragileMacOSX:
+  return false;
+case MacOSX:
+  return getVersion() >= VersionTuple(10, 10);
+case iOS:
+  return getVersion() >= VersionTuple(8);
+case WatchOS:
+  return true;
+
+case GCC:
+  return false;
+case GNUstep:
+  return false;
+case ObjFW:
+  return false;
+}
+llvm_unreachable("bad kind");
+  }
+
+  /// Does this runtime provide entrypoints that are likely to be faster
+  /// than an ordinary message send of the "alloc" selector?
+  ///
+  /// The "alloc" entrypoint is guaranteed to be equivalent to just sending the
+  /// corresponding message.  If the entrypoint is implemented naively as just 
a
+  /// message send, using it is a trade-off: it sacrifices a few cycles of
+  /// overhead to save a small amount of code.  However, it's possible for
+  /// runtimes to detect and special-case classes that use "standard"
+  /// alloc behavior; if that's dynamically a large proportion of all
+  /// objects, using the entrypoint will also be faster than using a message
+  /// send.
+  ///
+  /// When this method returns true, Clang will turn non-super message sends of
+  /// certain selectors into calls to the correspond entrypoint:
+  ///   alloc => objc_alloc
+  bool shouldUseRuntimeFunctionsForAlloc() const {
+switch (getKind()) {
+case FragileMacOSX:
+  return false;
+case MacOSX:
+  return getVersion() >= VersionTuple(10, 10);
+case iOS:
+  return getVersion() >= VersionTuple(8);
+case WatchOS:
+  return true;
+
+case GCC:
+  return false;
+case GNUstep:
+  return false;
+case ObjFW:
+  return false;
+}
+llvm_unreachable("bad kind");
+  }
+
   /// \brief Does this runtime supports optimized setter entrypoints?
   bool hasOptimizedSetter() const {
 switch (getKind()) {

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=263607=263606=263607=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Mar 15 19:33:21 2016
@@ -933,6 +933,10 @@ def 

Re: [PATCH] D18196: [CodeGen] Emit lifetime.end intrinsic after destructor call in landing pad

2016-03-15 Thread John McCall via cfe-commits
rjmccall added a comment.

You should talk to Reid or someone else involved in MSVC-style EH support to 
ensure that they generate a reasonable code pattern for this.

You should also check that any back-end peepholes we have in place (null type 
infos to signify a call-terminate landingpad?) aren't disturbed by the lifetime 
intrinsics.


http://reviews.llvm.org/D18196



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


Re: [PATCH] D18175: Avoid using LookupResult's implicit copy ctor and assignment operator to avoid warnings

2016-03-15 Thread John McCall via cfe-commits
rjmccall added a comment.

Thank you, LGTM.


Repository:
  rL LLVM

http://reviews.llvm.org/D18175



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


Re: [PATCH] D18088: Add a new warning to notify users of mismatched SDK and deployment target

2016-03-15 Thread Bob Wilson via cfe-commits
bob.wilson added a comment.

This is a good idea overall. See comments.



Comment at: include/clang/Basic/DiagnosticDriverKinds.td:198
@@ -197,2 +197,3 @@
   InGroup>;
+def warn_incompatible_sdk : Warning<"using SDK for '%0' but deploying to 
'%1'">;
 def warn_debug_compression_unavailable : Warning<"cannot compress debug 
sections (zlib not installed)">,

Instead of the driver option, you should add this to the diagnostic: 
InGroup>


Comment at: include/clang/Driver/Options.td:1090
@@ -1089,1 +1089,3 @@
 def Wframe_larger_than_EQ : Joined<["-"], "Wframe-larger-than=">, 
Group, Flags<[DriverOption]>;
+def Wincompatible_sdk : Flag<["-"], "Wincompatible-sdk">, Group,
+  Flags<[DriverOption]>;

You should not need to add this option. See above.


Comment at: lib/Driver/ToolChains.cpp:333
@@ +332,3 @@
+StringRef Darwin::getPlatformFamily() const {
+  switch(TargetPlatform) {
+  case DarwinPlatformKind::MacOS:

Please add a space before the open paren.


Comment at: lib/Driver/ToolChains.cpp:742
@@ +741,3 @@
+
+  if(Args.hasArg(options::OPT_Wincompatible_sdk)) {
+if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {

Please add a space before the open paren.


Comment at: lib/Driver/ToolChains.cpp:750
@@ +749,3 @@
+StringRef SDK = isysroot.slice(BeginSDK + 5, EndSDK);
+if(!SDK.startswith(getPlatformFamily()))
+  getDriver().Diag(diag::warn_incompatible_sdk) << SDK

Please add a space before the open paren. You should run the patch through 
clang-format since you have several formatting issues.


http://reviews.llvm.org/D18088



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


Re: [PATCH] D18175: Avoid using LookupResult's implicit copy ctor and assignment operator to avoid warnings

2016-03-15 Thread Marina Yatsina via cfe-commits
myatsina updated this revision to Diff 50780.
myatsina added a comment.

Adding requested test case + changing the code accordingly


Repository:
  rL LLVM

http://reviews.llvm.org/D18175

Files:
  lib/Sema/SemaStmtAsm.cpp
  test/CodeGen/ms-inline-asm-errors.cpp

Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -623,16 +623,12 @@
 
   if (!LookupName(BaseResult, getCurScope()))
 return true;
-
-  LookupResult CurrBaseResult(BaseResult);
-
+  
+  if(!BaseResult.isSingleResult())
+return true;
+  NamedDecl *FoundDecl = BaseResult.getFoundDecl();
   for (StringRef NextMember : Members) {
-
-if (!CurrBaseResult.isSingleResult())
-  return true;
-
 const RecordType *RT = nullptr;
-NamedDecl *FoundDecl = CurrBaseResult.getFoundDecl();
 if (VarDecl *VD = dyn_cast(FoundDecl))
   RT = VD->getType()->getAs();
 else if (TypedefNameDecl *TD = dyn_cast(FoundDecl)) {
@@ -655,13 +651,15 @@
 if (!LookupQualifiedName(FieldResult, RT->getDecl()))
   return true;
 
+if (!FieldResult.isSingleResult())
+  return true;
+FoundDecl = FieldResult.getFoundDecl();
+
 // FIXME: Handle IndirectFieldDecl?
-FieldDecl *FD = dyn_cast(FieldResult.getFoundDecl());
+FieldDecl *FD = dyn_cast(FoundDecl);
 if (!FD)
   return true;
 
-CurrBaseResult = FieldResult;
-
 const ASTRecordLayout  = Context.getASTRecordLayout(RT->getDecl());
 unsigned i = FD->getFieldIndex();
 CharUnits Result = Context.toCharUnitsFromBits(RL.getFieldOffset(i));
Index: test/CodeGen/ms-inline-asm-errors.cpp
===
--- test/CodeGen/ms-inline-asm-errors.cpp
+++ test/CodeGen/ms-inline-asm-errors.cpp
@@ -0,0 +1,15 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -x c++ %s -triple i386-apple-darwin10 -std=c++11 
-fasm-blocks -verify
+
+class A {
+public:
+  void foo(int a)   {}
+  void foo(float a) {}
+};
+
+
+void t_fail() {
+   __asm {
+   mov ecx, [eax]A.foo // expected-error {{Unable to lookup field 
reference!}}
+   }
+}


Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -623,16 +623,12 @@
 
   if (!LookupName(BaseResult, getCurScope()))
 return true;
-
-  LookupResult CurrBaseResult(BaseResult);
-
+  
+  if(!BaseResult.isSingleResult())
+return true;
+  NamedDecl *FoundDecl = BaseResult.getFoundDecl();
   for (StringRef NextMember : Members) {
-
-if (!CurrBaseResult.isSingleResult())
-  return true;
-
 const RecordType *RT = nullptr;
-NamedDecl *FoundDecl = CurrBaseResult.getFoundDecl();
 if (VarDecl *VD = dyn_cast(FoundDecl))
   RT = VD->getType()->getAs();
 else if (TypedefNameDecl *TD = dyn_cast(FoundDecl)) {
@@ -655,13 +651,15 @@
 if (!LookupQualifiedName(FieldResult, RT->getDecl()))
   return true;
 
+if (!FieldResult.isSingleResult())
+  return true;
+FoundDecl = FieldResult.getFoundDecl();
+
 // FIXME: Handle IndirectFieldDecl?
-FieldDecl *FD = dyn_cast(FieldResult.getFoundDecl());
+FieldDecl *FD = dyn_cast(FoundDecl);
 if (!FD)
   return true;
 
-CurrBaseResult = FieldResult;
-
 const ASTRecordLayout  = Context.getASTRecordLayout(RT->getDecl());
 unsigned i = FD->getFieldIndex();
 CharUnits Result = Context.toCharUnitsFromBits(RL.getFieldOffset(i));
Index: test/CodeGen/ms-inline-asm-errors.cpp
===
--- test/CodeGen/ms-inline-asm-errors.cpp
+++ test/CodeGen/ms-inline-asm-errors.cpp
@@ -0,0 +1,15 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -x c++ %s -triple i386-apple-darwin10 -std=c++11 -fasm-blocks -verify
+
+class A {
+public:
+  void foo(int a)   {}
+  void foo(float a) {}
+};
+
+
+void t_fail() {
+	__asm {
+		mov ecx, [eax]A.foo // expected-error {{Unable to lookup field reference!}}
+	}
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17815: [libc++abi] Use fallback_malloc to allocate __cxa_eh_globals in case of dynamic memory exhaustion.

2016-03-15 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

By including `fallback_malloc.ipp` in a new C++ file we now have 2 different 
OOM emergancy buffers. I think it would be preferable to use only one. This 
would require a fairly large restructuring of `fallback_malloc.ipp` though.


http://reviews.llvm.org/D17815



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


r263596 - Myriad: define __myriad2 macro automatically

2016-03-15 Thread Douglas Katzman via cfe-commits
Author: dougk
Date: Tue Mar 15 17:34:02 2016
New Revision: 263596

URL: http://llvm.org/viewvc/llvm-project?rev=263596=rev
Log:
Myriad: define __myriad2 macro automatically

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Driver/myriad-toolchain.c
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=263596=263595=263596=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Mar 15 17:34:02 2016
@@ -6031,7 +6031,9 @@ public:
 CK_NIAGARA,
 CK_NIAGARA2,
 CK_NIAGARA3,
-CK_NIAGARA4
+CK_NIAGARA4,
+CK_MYRIAD2_1,
+CK_MYRIAD2_2
   } CPU = CK_GENERIC;
 
   enum CPUGeneration {
@@ -6050,6 +6052,8 @@ public:
 case CK_SPARCLITE86X:
 case CK_SPARCLET:
 case CK_TSC701:
+case CK_MYRIAD2_1:
+case CK_MYRIAD2_2:
   return CG_V8;
 case CK_V9:
 case CK_ULTRASPARC:
@@ -6080,6 +6084,9 @@ public:
 .Case("niagara2", CK_NIAGARA2)
 .Case("niagara3", CK_NIAGARA3)
 .Case("niagara4", CK_NIAGARA4)
+.Case("myriad2", CK_MYRIAD2_1)
+.Case("myriad2.1", CK_MYRIAD2_1)
+.Case("myriad2.2", CK_MYRIAD2_2)
 .Default(CK_GENERIC);
   }
 
@@ -6177,6 +6184,20 @@ public:
   }
   break;
 }
+if (getTriple().getVendor() == llvm::Triple::Myriad) {
+  switch (CPU) {
+  case CK_MYRIAD2_1:
+Builder.defineMacro("__myriad2", "1");
+Builder.defineMacro("__myriad2__", "1");
+break;
+  case CK_MYRIAD2_2:
+Builder.defineMacro("__myriad2", "2");
+Builder.defineMacro("__myriad2__", "2");
+break;
+  default:
+break;
+  }
+}
   }
 };
 

Modified: cfe/trunk/test/Driver/myriad-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/myriad-toolchain.c?rev=263596=263595=263596=diff
==
--- cfe/trunk/test/Driver/myriad-toolchain.c (original)
+++ cfe/trunk/test/Driver/myriad-toolchain.c Tue Mar 15 17:34:02 2016
@@ -36,10 +36,10 @@
 // As such, we test only for a trailing quote in its rendering.
 // The same goes for "moviAsm".
 
-// RUN: %clang -target shave-myriad -mcpu=myriad1 -c -### %s -isystem 
somewhere -Icommon -Wa,-yippee 2>&1 \
+// RUN: %clang -target shave-myriad -mcpu=myriad2.2 -c -### %s -isystem 
somewhere -Icommon -Wa,-yippee 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MOVICOMPILE
-// MOVICOMPILE: moviCompile{{(.exe)?}}" "-S" "-fno-exceptions" "-DMYRIAD2" 
"-mcpu=myriad1" "-isystem" "somewhere" "-I" "common"
-// MOVICOMPILE: moviAsm{{(.exe)?}}" "-no6thSlotCompression" "-cv:myriad1" 
"-noSPrefixing" "-a"
+// MOVICOMPILE: moviCompile{{(.exe)?}}" "-S" "-fno-exceptions" "-DMYRIAD2" 
"-mcpu=myriad2.2" "-isystem" "somewhere" "-I" "common"
+// MOVICOMPILE: moviAsm{{(.exe)?}}" "-no6thSlotCompression" "-cv:myriad2.2" 
"-noSPrefixing" "-a"
 // MOVICOMPILE: "-yippee" "-i:somewhere" "-i:common" "-elf"
 
 // RUN: %clang -target shave-myriad -c -### %s -DEFINE_ME -UNDEFINE_ME 2>&1 \

Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=263596=263595=263596=diff
==
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Tue Mar 15 17:34:02 
2016
@@ -1903,8 +1903,17 @@
 // RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN: -target sparcel-unknown-linux \
 // RUN:   | FileCheck %s -check-prefix=CHECK_SPARCEL
-//
+// RUN: %clang -E -dM %s -o - -target sparcel-myriad -mcpu=myriad2 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK_MYRIAD2-1 
-check-prefix=CHECK_SPARCEL
+// RUN: %clang -E -dM %s -o - -target sparcel-myriad -mcpu=myriad2.1 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK_MYRIAD2-1 
-check-prefix=CHECK_SPARCEL
+// RUN: %clang -E -dM %s -o - -target sparcel-myriad -mcpu=myriad2.2 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK_MYRIAD2-2 
-check-prefix=CHECK_SPARCEL
 // CHECK_SPARCEL: #define __LITTLE_ENDIAN__ 1
+// CHECK_MYRIAD2-1: #define __myriad2 1
+// CHECK_MYRIAD2-1: #define __myriad2__ 1
+// CHECK_MYRIAD2-2: #define __myriad2 2
+// CHECK_MYRIAD2-2: #define __myriad2__ 2
 // CHECK_SPARCEL: #define __sparc 1
 // CHECK_SPARCEL: #define __sparc__ 1
 // CHECK_SPARCEL: #define __sparcv8 1


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


Re: [PATCH] D15944: [OpenMP] Parsing and sema support for target update directive

2016-03-15 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Thanks Kelvin,

I'm fine with the patch. Let's wait for Alexey to see if he has any concern.

Thanks again!
Samuel


http://reviews.llvm.org/D15944



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


Re: [PATCH] D15944: [OpenMP] Parsing and sema support for target update directive

2016-03-15 Thread Kelvin Li via cfe-commits
kkwli0 updated this revision to Diff 50774.
kkwli0 marked 5 inline comments as done.
kkwli0 added a comment.

Addressed the comments from the last review: added assert calls and outline the 
common code in ActOnOpenMPToClause, ActOnOpenMPFromClause and 
ActOnOpenMPMapClause to a static function.


http://reviews.llvm.org/D15944

Files:
  include/clang-c/Index.h
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/StmtOpenMP.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Basic/StmtNodes.td
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/OpenMPClause.cpp
  lib/AST/StmtOpenMP.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/OpenMP/nesting_of_regions.cpp
  test/OpenMP/target_map_messages.cpp
  test/OpenMP/target_parallel_for_map_messages.cpp
  test/OpenMP/target_parallel_map_messages.cpp
  test/OpenMP/target_update_ast_print.cpp
  test/OpenMP/target_update_device_messages.cpp
  test/OpenMP/target_update_from_messages.cpp
  test/OpenMP/target_update_if_messages.cpp
  test/OpenMP/target_update_messages.cpp
  test/OpenMP/target_update_to_messages.cpp
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -612,6 +612,9 @@
   case Stmt::OMPTargetParallelForDirectiveClass:
 K = CXCursor_OMPTargetParallelForDirective;
 break;
+  case Stmt::OMPTargetUpdateDirectiveClass:
+K = CXCursor_OMPTargetUpdateDirective;
+break;
   case Stmt::OMPTeamsDirectiveClass:
 K = CXCursor_OMPTeamsDirective;
 break;
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -2255,6 +2255,12 @@
 }
 void OMPClauseEnqueue::VisitOMPDefaultmapClause(
 const OMPDefaultmapClause * /*C*/) {}
+void OMPClauseEnqueue::VisitOMPFromClause(const OMPFromClause *C) {
+  VisitOMPClauseList(C);
+}
+void OMPClauseEnqueue::VisitOMPToClause(const OMPToClause *C) {
+  VisitOMPClauseList(C);
+}
 }
 
 void EnqueueVisitor::EnqueueChildren(const OMPClause *S) {
@@ -4825,6 +4831,8 @@
 return cxstring::createRef("OMPTargetParallelDirective");
   case CXCursor_OMPTargetParallelForDirective:
 return cxstring::createRef("OMPTargetParallelForDirective");
+  case CXCursor_OMPTargetUpdateDirective:
+return cxstring::createRef("OMPTargetUpdateDirective");
   case CXCursor_OMPTeamsDirective:
 return cxstring::createRef("OMPTeamsDirective");
   case CXCursor_OMPCancellationPointDirective:
Index: test/OpenMP/target_update_to_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_update_to_messages.cpp
@@ -0,0 +1,175 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note 2 {{declared here}}
+extern S1 a;
+class S2 {
+  mutable int a;
+public:
+  S2():a(0) { }
+  S2(S2 ):a(s2.a) { }
+  static float S2s; // expected-note 4 {{mappable type cannot contain static members}}
+  static const float S2sc; // expected-note 4 {{mappable type cannot contain static members}}
+};
+const float S2::S2sc = 0;
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+public:
+  S3():a(0) { }
+  S3(S3 ):a(s3.a) { }
+};
+const S3 c;
+const S3 ca[5];
+extern const int f;
+class S4 {
+  int a;
+  S4();
+  S4(const S4 );
+public:
+  S4(int v):a(v) { }
+};
+class S5 {
+  int a;
+  S5():a(0) {}
+  S5(const S5 ):a(s5.a) { }
+public:
+  S5(int v):a(v) { }
+};
+struct S6 {
+  int ii;
+  int aa[30];
+  float xx;
+  double *pp;
+};
+struct S7 {
+  int i;
+  int a[50];
+  float x;
+  S6 s6[5];
+  double *p;
+  unsigned bfa : 4;
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+
+typedef int from;
+
+template  // expected-note {{declared here}}
+T tmain(T argc) {
+  const T d = 5;
+  const T da[5] = { 0 };
+  S4 e(4);
+  S5 g(5);
+  T *m;
+  T i, t[20];
+  T  = i;
+  T *k = 
+  T x;
+  T y;
+  T to;
+  const T ()[5] = da;
+  S7 s7;
+
+#pragma omp target update to // expected-error {{expected '(' after 'to'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update to( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} expected-error {{expected at least one 'to' clause or 'from' clause 

Re: [PATCH] D14737: Convert some ObjC msgSends to runtime calls

2016-03-15 Thread John McCall via cfe-commits
rjmccall added a comment.

Yes, LGTM.


http://reviews.llvm.org/D14737



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


[PATCH] D18199: CodeGen: Implement IR generation for the relative vtable ABI (PR26723).

2016-03-15 Thread Peter Collingbourne via cfe-commits
pcc created this revision.
pcc added reviewers: rjmccall, rsmith, rafael, joker.eph, majnemer, rnk.
pcc added a subscriber: cfe-commits.

Also add documentation for the new feature.

The new IR scheme for virtual calls
(http://lists.llvm.org/pipermail/llvm-dev/2016-February/096146.html) will
be implemented in a follow-up patch. This patch does some refactoring that
puts us in a good position to do that.

Depends on http://reviews.llvm.org/D17893

Depends on http://reviews.llvm.org/D17938

http://reviews.llvm.org/D18199

Files:
  docs/UsersManual.rst
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CGVTables.h
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/vtable-relative-abi.cpp

Index: test/CodeGenCXX/vtable-relative-abi.cpp
===
--- /dev/null
+++ test/CodeGenCXX/vtable-relative-abi.cpp
@@ -0,0 +1,123 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -funstable-c++-abi-classes -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=CHECK-ITANIUM %s
+// RUN: %clang_cc1 %s -triple x86_64-unknown-windows-msvc -funstable-c++-abi-classes -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MS %s
+
+// CHECK-ITANIUM: @_ZTV1S = unnamed_addr constant { i8*, i8*, i32, i32 } { i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1S to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f1Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32, i32 }, { i8*, i8*, i32, i32 }* @_ZTV1S, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f2Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32, i32 }, { i8*, i8*, i32, i32 }* @_ZTV1S, i32 0, i32 2) to i64)) to i32) }, align 8
+// CHECK-MS: @0 = private unnamed_addr constant { i8*, i32, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4S@@6B@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @"\01?f1@S@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32, i32 }, { i8*, i32, i32 }* @0, i32 0, i32 1) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @"\01?f2@S@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32, i32 }, { i8*, i32, i32 }* @0, i32 0, i32 1) to i64)) to i32) }, comdat($"\01??_7S@@6B@")
+struct S {
+  S();
+  virtual void f1();
+  virtual void f2();
+};
+
+// CHECK-ITANIUM: @_ZTV1T = unnamed_addr constant { i8*, i8*, i32 } { i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1T to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.T*)* @_ZN1T1gEv to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32 }, { i8*, i8*, i32 }* @_ZTV1T, i32 0, i32 2) to i64)) to i32) }
+// CHECK-MS: @1 = private unnamed_addr constant { i8*, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4T@@6B@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.T*)* @"\01?g@T@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32 }, { i8*, i32 }* @1, i32 0, i32 1) to i64)) to i32) }, comdat($"\01??_7T@@6B@")
+struct T {
+  T();
+  virtual void g();
+};
+
+// CHECK-ITANIUM: @_ZTV1U = unnamed_addr constant { i8*, i8*, i32, i32, i8*, i8*, i32 } { i8* null, i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64, i8*, i64 }* @_ZTI1U to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.U*)* @_ZN1U2f1Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32, i32, i8*, i8*, i32 }, { i8*, i8*, i32, i32, i8*, i8*, i32 }* @_ZTV1U, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f2Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32, i32, i8*, i8*, i32 }, { i8*, i8*, i32, i32, i8*, i8*, i32 }* @_ZTV1U, i32 0, i32 2) to i64)) to i32), i8* inttoptr (i64 -8 to i8*), i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64, i8*, i64 }* @_ZTI1U to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.T*)* @_ZN1T1gEv to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32, i32, i8*, i8*, i32 }, { i8*, i8*, i32, i32, i8*, i8*, i32 }* @_ZTV1U, i32 0, i32 6) to i64)) to i32) }, align 8
+// CHECK-MS: @2 = private unnamed_addr constant { i8*, i32, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4U@@6BS@@@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.U*)* @"\01?f1@U@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32, i32 }, { i8*, i32, i32 }* @2, i32 0, i32 1) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @"\01?f2@S@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32, i32 }, { i8*, i32, i32 }* @2, i32 0, i32 1) to i64)) to i32) }, comdat($"\01??_7U@@6BS@@@")
+// CHECK-MS: @3 = private unnamed_addr constant { i8*, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4U@@6BT@@@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.T*)* @"\01?g@T@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr 

Re: [PATCH] D18138: Add -fnative-half-arguments-and-returns

2016-03-15 Thread Stephen Hines via cfe-commits
srhines added a reviewer: kristof.beyls.
srhines added a comment.

Kristof, can you or someone at ARM (where this is clearly relevant) take a look 
here? The CL obviously looks fine to me, but I might not have all of the 
original context as to why this was so constrained to OpenCL. Thanks.


http://reviews.llvm.org/D18138



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


Re: [PATCH] D14737: Convert some ObjC msgSends to runtime calls

2016-03-15 Thread Pete Cooper via cfe-commits
pete added a comment.

In http://reviews.llvm.org/D14737#375739, @rjmccall wrote:

> Ah, okay, if you changed it to cast explicitly, that's all I was concerned 
> about.


Cool.  Thanks.  Any other concerns or does this look good to you?


http://reviews.llvm.org/D14737



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


[PATCH] D18196: [CodeGen] Emit lifetime.end intrinsic after destructor call in landing pad

2016-03-15 Thread Akira Hatanaka via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rnk, rjmccall.
ahatanak added a subscriber: cfe-commits.

This patch fixes a bug in CodeGen where lifetime.end intrinsics were not being 
inserted after destructor calls in landing pad blocks, which prevented 
StackColoring from merging stack slots for allocas because it couldn't tell 
their lifetime ranges were disjoint.

This patch changes the code in CodeGenFunction::EmitAutoVarCleanup to pass 
NormalAndEHCleanup instead of NormalCleanup to EHScopeStack::pushCleanup so 
that CallLifetimeEnd runs the cleanup code when a scope is exited using 
exceptional control flow too. I initially considered adding code to 
DestroyObject::Emit to emit lifetime.end after the destructor call, but letting 
CallLifetimeEnd emit lifetime.end seemed like a better approach. 
 
This is the link to the discussion on llvm-dev:

http://lists.llvm.org/pipermail/llvm-dev/2016-March/096233.html

http://reviews.llvm.org/D18196

Files:
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/EHScopeStack.h
  test/CodeGenCXX/destructors.cpp

Index: test/CodeGenCXX/destructors.cpp
===
--- test/CodeGenCXX/destructors.cpp
+++ test/CodeGenCXX/destructors.cpp
@@ -4,6 +4,8 @@
 // RUN: FileCheck --check-prefix=CHECK3 --input-file=%t %s
 // RUN: FileCheck --check-prefix=CHECK4 --input-file=%t %s
 // RUN: FileCheck --check-prefix=CHECK5 --input-file=%t %s
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions -O1 -disable-llvm-optzns -std=c++11 > %t2
+// RUN: FileCheck --check-prefix=CHECK6 --input-file=%t2 %s
 
 struct A {
   int a;
@@ -428,3 +430,64 @@
 return true;
   }
 }
+
+#if __cplusplus >= 201103L
+namespace test11 {
+
+// Check that lifetime.end is emitted in the landing pad.
+
+// CHECK6-LABEL: define void @_ZN6test1115testLifetimeEndEi(
+// CHECK6: entry:
+// CHECK6: [[T1:%[a-z0-9]+]] = alloca %"struct.test11::S1"
+// CHECK6: [[T2:%[a-z0-9]+]] = alloca %"struct.test11::S1"
+// CHECK6: [[T3:%[a-z0-9]+]] = alloca %"struct.test11::S1"
+
+// CHECK6: {{^}}invoke.cont
+// CHECK6: call void @_ZN6test112S1D1Ev(%"struct.test11::S1"* [[T1]])
+// CHECK6: [[BC1:%[a-z0-9]+]] = bitcast %"struct.test11::S1"* [[T1]] to i8*
+// CHECK6: call void @llvm.lifetime.end(i64 32, i8* [[BC1]])
+// CHECK6: {{^}}lpad
+// CHECK6: call void @_ZN6test112S1D1Ev(%"struct.test11::S1"* [[T1]])
+// CHECK6: [[BC2:%[a-z0-9]+]] = bitcast %"struct.test11::S1"* [[T1]] to i8*
+// CHECK6: call void @llvm.lifetime.end(i64 32, i8* [[BC2]])
+
+// CHECK6: {{^}}invoke.cont
+// CHECK6: call void @_ZN6test112S1D1Ev(%"struct.test11::S1"* [[T2]])
+// CHECK6: [[BC3:%[a-z0-9]+]] = bitcast %"struct.test11::S1"* [[T2]] to i8*
+// CHECK6: call void @llvm.lifetime.end(i64 32, i8* [[BC3]])
+// CHECK6: {{^}}lpad
+// CHECK6: call void @_ZN6test112S1D1Ev(%"struct.test11::S1"* [[T2]])
+// CHECK6: [[BC4:%[a-z0-9]+]] = bitcast %"struct.test11::S1"* [[T2]] to i8*
+// CHECK6: call void @llvm.lifetime.end(i64 32, i8* [[BC4]])
+
+// CHECK6: {{^}}invoke.cont
+// CHECK6: call void @_ZN6test112S1D1Ev(%"struct.test11::S1"* [[T3]])
+// CHECK6: [[BC5:%[a-z0-9]+]] = bitcast %"struct.test11::S1"* [[T3]] to i8*
+// CHECK6: call void @llvm.lifetime.end(i64 32, i8* [[BC5]])
+// CHECK6: {{^}}lpad
+// CHECK6: call void @_ZN6test112S1D1Ev(%"struct.test11::S1"* [[T3]])
+// CHECK6: [[BC6:%[a-z0-9]+]] = bitcast %"struct.test11::S1"* [[T3]] to i8*
+// CHECK6: call void @llvm.lifetime.end(i64 32, i8* [[BC6]])
+
+  struct S1 {
+~S1();
+int a[8];
+  };
+
+  void func1(S1 &) noexcept(false);
+
+  void testLifetimeEnd(int n) {
+if (n < 10) {
+  S1 t1;
+  func1(t1);
+} else if (n < 100) {
+  S1 t2;
+  func1(t2);
+} else if (n < 1000) {
+  S1 t3;
+  func1(t3);
+}
+  }
+
+}
+#endif
Index: lib/CodeGen/EHScopeStack.h
===
--- lib/CodeGen/EHScopeStack.h
+++ lib/CodeGen/EHScopeStack.h
@@ -341,9 +341,7 @@
   /// Determines whether the exception-scopes stack is empty.
   bool empty() const { return StartOfData == EndOfBuffer; }
 
-  bool requiresLandingPad() const {
-return InnermostEHScope != stable_end();
-  }
+  bool requiresLandingPad() const;
 
   /// Determines whether there are any normal cleanups on the stack.
   bool hasNormalCleanups() const {
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -1388,7 +1388,7 @@
   // Make sure we call @llvm.lifetime.end.  This needs to happen
   // *last*, so the cleanup needs to be pushed *first*.
   if (emission.useLifetimeMarkers()) {
-EHStack.pushCleanup(NormalCleanup,
+EHStack.pushCleanup(NormalAndEHCleanup,
  emission.getAllocatedAddress(),
  emission.getSizeForLifetimeMarkers());
 EHCleanupScope  = 

r263589 - Revert commit http://reviews.llvm.org/D17877 to fix tests on x86.

2016-03-15 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Tue Mar 15 16:26:34 2016
New Revision: 263589

URL: http://llvm.org/viewvc/llvm-project?rev=263589=rev
Log:
Revert commit http://reviews.llvm.org/D17877 to fix tests on x86.


Removed:
cfe/trunk/test/OpenMP/nvptx_target_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

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=263589=263588=263589=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Mar 15 16:26:34 2016
@@ -4145,14 +4145,6 @@ void CGOpenMPRuntime::emitTargetOutlined
 CGF.EmitStmt(CS.getCapturedStmt());
   };
 
-  emitTargetOutlinedFunctionHelper(D, ParentName, OutlinedFn, OutlinedFnID,
-   IsOffloadEntry, CodeGen);
-}
-
-void CGOpenMPRuntime::emitTargetOutlinedFunctionHelper(
-const OMPExecutableDirective , StringRef ParentName,
-llvm::Function *, llvm::Constant *,
-bool IsOffloadEntry, const RegionCodeGenTy ) {
   // Create a unique name for the entry function using the source location
   // information of the current target region. The name will be something like:
   //
@@ -4174,8 +4166,6 @@ void CGOpenMPRuntime::emitTargetOutlined
<< llvm::format("_%x_", FileID) << ParentName << "_l" << Line;
   }
 
-  const CapturedStmt  = *cast(D.getAssociatedStmt());
-
   CodeGenFunction CGF(CGM, true);
   CGOpenMPTargetRegionInfo CGInfo(CS, CodeGen, EntryFnName);
   CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, );

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=263589=263588=263589=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Tue Mar 15 16:26:34 2016
@@ -49,31 +49,7 @@ class CodeGenModule;
 typedef llvm::function_ref RegionCodeGenTy;
 
 class CGOpenMPRuntime {
-protected:
   CodeGenModule 
-
-  /// \brief Creates offloading entry for the provided entry ID \a ID,
-  /// address \a Addr and size \a Size.
-  virtual void createOffloadEntry(llvm::Constant *ID, llvm::Constant *Addr,
-  uint64_t Size);
-
-  /// \brief Helper to emit outlined function for 'target' directive.
-  /// \param D Directive to emit.
-  /// \param ParentName Name of the function that encloses the target region.
-  /// \param OutlinedFn Outlined function value to be defined by this call.
-  /// \param OutlinedFnID Outlined function ID value to be defined by this 
call.
-  /// \param IsOffloadEntry True if the outlined function is an offload entry.
-  /// \param CodeGen Lambda codegen specific to an accelerator device.
-  /// An oulined function may not be an entry if, e.g. the if clause always
-  /// evaluates to false.
-  virtual void emitTargetOutlinedFunctionHelper(const OMPExecutableDirective 
,
-StringRef ParentName,
-llvm::Function *,
-llvm::Constant *,
-bool IsOffloadEntry,
-const RegionCodeGenTy 
);
-
-private:
   /// \brief Default const ident_t object used for initialization of all other
   /// ident_t objects.
   llvm::Constant *DefaultOpenMPPSource = nullptr;
@@ -291,6 +267,11 @@ private:
   /// compilation unit. The function that does the registration is returned.
   llvm::Function *createOffloadingBinaryDescriptorRegistration();
 
+  /// \brief Creates offloading entry for the provided entry ID \a ID,
+  /// address \a Addr and size \a Size.
+  void createOffloadEntry(llvm::Constant *ID, llvm::Constant *Addr,
+  uint64_t Size);
+
   /// \brief Creates all the offload entries in the current compilation unit
   /// along with the associated metadata.
   void createOffloadEntriesAndInfoMetadata();

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=263589=263588=263589=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Tue Mar 15 16:26:34 2016
@@ -18,326 +18,5 @@
 using namespace clang;
 using namespace CodeGen;
 
-/// \brief Get the GPU warp size.
-llvm::Value *CGOpenMPRuntimeNVPTX::getNVPTXWarpSize(CodeGenFunction ) {
-  CGBuilderTy  = CGF.Builder;
-  return Bld.CreateCall(
- 

Re: [PATCH] D18174: Fix libcxx build on musl

2016-03-15 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

The method @bcraig is describing is documented here: 
http://libcxx.llvm.org/docs/BuildingLibcxx.html#id4


http://reviews.llvm.org/D18174



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


r263587 - [OpenMP] Base support for target directive codegen on NVPTX device.

2016-03-15 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Tue Mar 15 16:04:57 2016
New Revision: 263587

URL: http://llvm.org/viewvc/llvm-project?rev=263587=rev
Log:
[OpenMP] Base support for target directive codegen on NVPTX device.

Summary:
This patch adds base support for codegen of the target directive on the NVPTX 
device.

Reviewers: ABataev

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


Added:
cfe/trunk/test/OpenMP/nvptx_target_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

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=263587=263586=263587=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Mar 15 16:04:57 2016
@@ -4145,6 +4145,14 @@ void CGOpenMPRuntime::emitTargetOutlined
 CGF.EmitStmt(CS.getCapturedStmt());
   };
 
+  emitTargetOutlinedFunctionHelper(D, ParentName, OutlinedFn, OutlinedFnID,
+   IsOffloadEntry, CodeGen);
+}
+
+void CGOpenMPRuntime::emitTargetOutlinedFunctionHelper(
+const OMPExecutableDirective , StringRef ParentName,
+llvm::Function *, llvm::Constant *,
+bool IsOffloadEntry, const RegionCodeGenTy ) {
   // Create a unique name for the entry function using the source location
   // information of the current target region. The name will be something like:
   //
@@ -4166,6 +4174,8 @@ void CGOpenMPRuntime::emitTargetOutlined
<< llvm::format("_%x_", FileID) << ParentName << "_l" << Line;
   }
 
+  const CapturedStmt  = *cast(D.getAssociatedStmt());
+
   CodeGenFunction CGF(CGM, true);
   CGOpenMPTargetRegionInfo CGInfo(CS, CodeGen, EntryFnName);
   CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, );

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=263587=263586=263587=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Tue Mar 15 16:04:57 2016
@@ -49,7 +49,31 @@ class CodeGenModule;
 typedef llvm::function_ref RegionCodeGenTy;
 
 class CGOpenMPRuntime {
+protected:
   CodeGenModule 
+
+  /// \brief Creates offloading entry for the provided entry ID \a ID,
+  /// address \a Addr and size \a Size.
+  virtual void createOffloadEntry(llvm::Constant *ID, llvm::Constant *Addr,
+  uint64_t Size);
+
+  /// \brief Helper to emit outlined function for 'target' directive.
+  /// \param D Directive to emit.
+  /// \param ParentName Name of the function that encloses the target region.
+  /// \param OutlinedFn Outlined function value to be defined by this call.
+  /// \param OutlinedFnID Outlined function ID value to be defined by this 
call.
+  /// \param IsOffloadEntry True if the outlined function is an offload entry.
+  /// \param CodeGen Lambda codegen specific to an accelerator device.
+  /// An oulined function may not be an entry if, e.g. the if clause always
+  /// evaluates to false.
+  virtual void emitTargetOutlinedFunctionHelper(const OMPExecutableDirective 
,
+StringRef ParentName,
+llvm::Function *,
+llvm::Constant *,
+bool IsOffloadEntry,
+const RegionCodeGenTy 
);
+
+private:
   /// \brief Default const ident_t object used for initialization of all other
   /// ident_t objects.
   llvm::Constant *DefaultOpenMPPSource = nullptr;
@@ -267,11 +291,6 @@ class CGOpenMPRuntime {
   /// compilation unit. The function that does the registration is returned.
   llvm::Function *createOffloadingBinaryDescriptorRegistration();
 
-  /// \brief Creates offloading entry for the provided entry ID \a ID,
-  /// address \a Addr and size \a Size.
-  void createOffloadEntry(llvm::Constant *ID, llvm::Constant *Addr,
-  uint64_t Size);
-
   /// \brief Creates all the offload entries in the current compilation unit
   /// along with the associated metadata.
   void createOffloadEntriesAndInfoMetadata();

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=263587=263586=263587=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Tue Mar 15 16:04:57 2016
@@ -18,5 +18,326 @@
 using namespace clang;
 using 

Re: r263299 - Add fix-it for format-security warnings.

2016-03-15 Thread Bob Wilson via cfe-commits
I think r263584 does what you suggest. Let me know if not.

> On Mar 11, 2016, at 4:53 PM, Bob Wilson via cfe-commits 
>  wrote:
> 
> OK. I will do that.
> 
>> On Mar 11, 2016, at 4:15 PM, David Blaikie > > wrote:
>> 
>> 
>> 
>> On Fri, Mar 11, 2016 at 4:14 PM, Bob Wilson via cfe-commits 
>> > wrote:
>> I’m not sure how to interpret that. It says: "Clang must recover from errors 
>> as if the fix-it had been applied.” I suppose that format-security could be 
>> an error if you’re building with -Werror, but I had been interpreting that 
>> to mean an error that would block further compilation. Can someone clarify 
>> this expectation?
>> 
>> I don’t think we can change -Wformat-security to be a note.
>> 
>> The suggestion isn't to change it to be a note, but to keep the warning but 
>> move the fixit to a note associated with the warning.
>> 
>> That way -fix-it doesn't automatically apply the fix-it, which avoids the 
>> issue of recovery as-if the fixit was applied.
>>  
>> It is an existing warning, and people expect us to match GCC on it as well.
>> 
>> 
>>> On Mar 11, 2016, at 4:03 PM, Nico Weber >> > wrote:
>>> 
>>> I think http://clang.llvm.org/docs/InternalsManual.html#fix-it-hints 
>>>  says that if 
>>> a fixit is on a warning, then clang should process the code as if the fixit 
>>> had been applied. That's not the case here, so I think the fixit should be 
>>> on a note instead.
>>> 
>>> On Fri, Mar 11, 2016 at 4:55 PM, Bob Wilson via cfe-commits 
>>> > wrote:
>>> Author: bwilson
>>> Date: Fri Mar 11 15:55:37 2016
>>> New Revision: 263299
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=263299=rev 
>>> 
>>> Log:
>>> Add fix-it for format-security warnings.
>>> 
>>> Added:
>>> cfe/trunk/test/SemaObjC/format-strings-objc-fixit.m
>>> Modified:
>>> cfe/trunk/lib/Sema/SemaChecking.cpp
>>> cfe/trunk/test/Sema/format-strings-fixit.c
>>> 
>>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=263299=263298=263299=diff
>>>  
>>> 
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Mar 11 15:55:37 2016
>>> @@ -3621,20 +3621,32 @@ bool Sema::CheckFormatArguments(ArrayRef
>>>// format is either NSString or CFString. This is a hack to prevent
>>>// diag when using the NSLocalizedString and CFCopyLocalizedString macros
>>>// which are usually used in place of NS and CF string literals.
>>> -  if (Type == FST_NSString &&
>>> -  SourceMgr.isInSystemMacro(Args[format_idx]->getLocStart()))
>>> +  SourceLocation FormatLoc = Args[format_idx]->getLocStart();
>>> +  if (Type == FST_NSString && SourceMgr.isInSystemMacro(FormatLoc))
>>>  return false;
>>> 
>>>// If there are no arguments specified, warn with -Wformat-security, 
>>> otherwise
>>>// warn only with -Wformat-nonliteral.
>>> -  if (Args.size() == firstDataArg)
>>> -Diag(Args[format_idx]->getLocStart(),
>>> - diag::warn_format_nonliteral_noargs)
>>> +  if (Args.size() == firstDataArg) {
>>> +const SemaDiagnosticBuilder  =
>>> +  Diag(FormatLoc, diag::warn_format_nonliteral_noargs);
>>> +switch (Type) {
>>> +default:
>>> +  D << OrigFormatExpr->getSourceRange();
>>> +  break;
>>> +case FST_Kprintf:
>>> +case FST_FreeBSDKPrintf:
>>> +case FST_Printf:
>>> +  D << FixItHint::CreateInsertion(FormatLoc, "\"%s\", ");
>>> +  break;
>>> +case FST_NSString:
>>> +  D << FixItHint::CreateInsertion(FormatLoc, "@\"%@\", ");
>>> +  break;
>>> +}
>>> +  } else {
>>> +Diag(FormatLoc, diag::warn_format_nonliteral)
>>><< OrigFormatExpr->getSourceRange();
>>> -  else
>>> -Diag(Args[format_idx]->getLocStart(),
>>> - diag::warn_format_nonliteral)
>>> -   << OrigFormatExpr->getSourceRange();
>>> +  }
>>>return false;
>>>  }
>>> 
>>> 
>>> Modified: cfe/trunk/test/Sema/format-strings-fixit.c
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings-fixit.c?rev=263299=263298=263299=diff
>>>  
>>> 
>>> ==
>>> --- cfe/trunk/test/Sema/format-strings-fixit.c (original)
>>> +++ cfe/trunk/test/Sema/format-strings-fixit.c Fri Mar 11 15:55:37 2016
>>> @@ 

r263584 - Move the fixit for -Wformat-security to a note.

2016-03-15 Thread Bob Wilson via cfe-commits
Author: bwilson
Date: Tue Mar 15 15:56:38 2016
New Revision: 263584

URL: http://llvm.org/viewvc/llvm-project?rev=263584=rev
Log:
Move the fixit for -Wformat-security to a note.

r263299 added a fixit for the -Wformat-security warning, but that runs
into complications with our guideline that error recovery should be done
as-if the fixit had been applied. Putting the fixit on a note avoids that.

Removed:
cfe/trunk/test/SemaObjC/format-strings-objc-fixit.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/format-strings-fixit.c
cfe/trunk/test/Sema/format-strings.c
cfe/trunk/test/SemaCXX/format-strings-0x.cpp
cfe/trunk/test/SemaCXX/format-strings.cpp
cfe/trunk/test/SemaObjC/format-strings-objc.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=263584=263583=263584=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Mar 15 15:56:38 
2016
@@ -7152,6 +7152,8 @@ def warn_scanf_scanlist_incomplete : War
 def note_format_string_defined : Note<"format string is defined here">;
 def note_format_fix_specifier : Note<"did you mean to use '%0'?">;
 def note_printf_c_str: Note<"did you mean to call the %0 method?">;
+def note_format_security_fixit: Note<
+  "treat the string as an argument to avoid this">;
 
 def warn_null_arg : Warning<
   "null passed to a callee that requires a non-null argument">,

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=263584=263583=263584=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Mar 15 15:56:38 2016
@@ -3628,19 +3628,20 @@ bool Sema::CheckFormatArguments(ArrayRef
   // If there are no arguments specified, warn with -Wformat-security, 
otherwise
   // warn only with -Wformat-nonliteral.
   if (Args.size() == firstDataArg) {
-const SemaDiagnosticBuilder  =
-  Diag(FormatLoc, diag::warn_format_nonliteral_noargs);
+Diag(FormatLoc, diag::warn_format_nonliteral_noargs)
+  << OrigFormatExpr->getSourceRange();
 switch (Type) {
 default:
-  D << OrigFormatExpr->getSourceRange();
   break;
 case FST_Kprintf:
 case FST_FreeBSDKPrintf:
 case FST_Printf:
-  D << FixItHint::CreateInsertion(FormatLoc, "\"%s\", ");
+  Diag(FormatLoc, diag::note_format_security_fixit)
+<< FixItHint::CreateInsertion(FormatLoc, "\"%s\", ");
   break;
 case FST_NSString:
-  D << FixItHint::CreateInsertion(FormatLoc, "@\"%@\", ");
+  Diag(FormatLoc, diag::note_format_security_fixit)
+<< FixItHint::CreateInsertion(FormatLoc, "@\"%@\", ");
   break;
 }
   } else {

Modified: cfe/trunk/test/Sema/format-strings-fixit.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings-fixit.c?rev=263584=263583=263584=diff
==
--- cfe/trunk/test/Sema/format-strings-fixit.c (original)
+++ cfe/trunk/test/Sema/format-strings-fixit.c Tue Mar 15 15:56:38 2016
@@ -16,8 +16,6 @@ typedef __UINTMAX_TYPE__ uintmax_t;
 typedef __PTRDIFF_TYPE__ ptrdiff_t;
 typedef __WCHAR_TYPE__ wchar_t;
 
-extern const char *NonliteralString;
-
 void test() {
   // Basic types
   printf("%s", (int) 123);
@@ -96,9 +94,6 @@ void test() {
   printf("%G", (long double) 42);
   printf("%a", (long double) 42);
   printf("%A", (long double) 42);
-
-  // nonliteral format
-  printf(NonliteralString);
 }
 
 int scanf(char const *, ...);
@@ -223,7 +218,6 @@ void test2(int intSAParm[static 2]) {
 // CHECK: printf("%LG", (long double) 42);
 // CHECK: printf("%La", (long double) 42);
 // CHECK: printf("%LA", (long double) 42);
-// CHECK: printf("%s", NonliteralString);
 
 // CHECK: scanf("%99s", str);
 // CHECK: scanf("%s", vstr);

Modified: cfe/trunk/test/Sema/format-strings.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings.c?rev=263584=263583=263584=diff
==
--- cfe/trunk/test/Sema/format-strings.c (original)
+++ cfe/trunk/test/Sema/format-strings.c Tue Mar 15 15:56:38 2016
@@ -29,15 +29,22 @@ void check_string_literal( FILE* fp, con
   va_start(ap,buf);
 
   printf(s); // expected-warning {{format string is not a string literal}}
+  // expected-note@-1{{treat the string as an argument to avoid this}}
   vprintf(s,ap); // expected-warning {{format string is not a string literal}}
   fprintf(fp,s); // expected-warning {{format string is not a string literal}}
+  // expected-note@-1{{treat the string as an 

Re: [PATCH] D18174: Fix libcxx build on musl

2016-03-15 Thread Ben Craig via cfe-commits
bcraig added a comment.

In http://reviews.llvm.org/D18174#375813, @raj.khem wrote:

> I think my problem was that while compiling libcxxabi, it wants to peek into 
> libcxx headers but then libcxxabi cmake infra doesnt have the musl support 
> like libcxx. So Now I solved it by adding -D_LIBCPP_HAS_MUSL_LIBC to CXXFLAGS.


When cross-compiling, I have found it to be best to build libcxx and libcxxabi 
as sub-projects of LLVM (i.e. I place libcxx under llvm/projects/libcxx).  I 
can then configure libcxxabi and libcxx at once.  When I get around to 
building, I specifically dodge building LLVM and/or clang by running "make 
cxxabi cxx".

If you go with that approach, I think all of the _LIBCPP_HAS_MUSL_LIBC stuff 
gets worked out, because libcxxabi looks at the __ config header that #includes 
__config_site.


http://reviews.llvm.org/D18174



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


Re: [PATCH] D16962: clang-tidy: avoid std::bind

2016-03-15 Thread Jonathan B Coe via cfe-commits
jbcoe added inline comments.


Comment at: clang-tidy/readability/AvoidStdBindCheck.cpp:42
@@ +41,3 @@
+
+  for (size_t I = 1, ArgCount = C->getNumArgs(); I < ArgCount; ++I) {
+const Expr *E = C->getArg(I);

alexfh wrote:
> Please use a range-based for loop over `C->arguments()`.
I'm starting at 1 not zero, hence the explicit loop.

Elements are non-contiguous so I can't use a restricted ArrayView.

I've added a comment saying why it starts at 1, not 0.


Comment at: clang-tidy/readability/AvoidStdBindCheck.cpp:127
@@ +126,3 @@
+  auto DiagnosticBuilder =
+  diag(MatchedDecl->getLocStart(), "avoid using std::bind");
+

alexfh wrote:
> alexfh wrote:
> > Should the message recommend something instead?
> In pre-C++11 code the check will just warn without suggesting any 
> alternative. That will lead to a lot of user confusion. We either need to 
> restrict the warning to C++14 code or suggest a better alternative even in 
> pre-C++14 code.
The message now recommends using a lambda so I think this is addressed.


http://reviews.llvm.org/D16962



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


Re: [PATCH] D18175: Avoid using LookupResult's implicit copy ctor and assignment operator to avoid warnings

2016-03-15 Thread John McCall via cfe-commits
rjmccall added a comment.

Hmm.  Checking whether LookupName returns false will catch a lot of simple 
cases.  I think the test case you need might have to be a lookup that finds 
multiple overloads of a function in C++.


Repository:
  rL LLVM

http://reviews.llvm.org/D18175



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


Re: [PATCH] D18175: Avoid using LookupResult's implicit copy ctor and assignment operator to avoid warnings

2016-03-15 Thread Marina Yatsina via cfe-commits
myatsina added a comment.

How can I create a test case where isSingleResult() returns false?
I don't see existent tests in the commit that added this method's functionality.


Repository:
  rL LLVM

http://reviews.llvm.org/D18175



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


Re: [PATCH] D17360: [cfi] Fix handling of sanitize trap/recover flags in the cross-DSO CFI mode.

2016-03-15 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

r263578, finally


Repository:
  rL LLVM

http://reviews.llvm.org/D17360



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


r263578 - [cfi] Don't emit checks for disabled CFI kinds.

2016-03-15 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Tue Mar 15 15:19:29 2016
New Revision: 263578

URL: http://llvm.org/viewvc/llvm-project?rev=263578=rev
Log:
[cfi] Don't emit checks for disabled CFI kinds.

In the cross-DSO CFI mode clang emits __cfi_check_fail that handles
errors triggered from other modules with targets in the current
module. With this change, __cfi_check_fail will handle errors for
CFI kinds that are not enabled in the current module as if they
have the trapping behaviour (-fsanitize-trap=...).

This fixes a bug where some combinations of -fsanitize* flags may
result in a link failure due to a missing sanitizer runtime library
for the diagnostic calls in __cfi_check_fail.

Added:
cfe/trunk/test/CodeGen/cfi-check-fail2.c
  - copied, changed from r263574, cfe/trunk/test/CodeGen/cfi-check-fail.c
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/test/CodeGen/cfi-check-fail.c

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=263578=263577=263578=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Mar 15 15:19:29 2016
@@ -2479,16 +2479,12 @@ void CodeGenFunction::EmitCheck(
   assert(JointCond);
 
   CheckRecoverableKind RecoverKind = getRecoverableKind(Checked[0].second);
-  // In cross-DSO CFI mode this code is used to generate __cfi_check_fail, 
which
-  // includes all checks, even those that are not in SanOpts.
-  assert(CGM.getCodeGenOpts().SanitizeCfiCrossDso ||
- SanOpts.has(Checked[0].second));
+  assert(SanOpts.has(Checked[0].second));
 #ifndef NDEBUG
   for (int i = 1, n = Checked.size(); i < n; ++i) {
 assert(RecoverKind == getRecoverableKind(Checked[i].second) &&
"All recoverable kinds in a single check must be same!");
-assert(CGM.getCodeGenOpts().SanitizeCfiCrossDso ||
-   SanOpts.has(Checked[i].second));
+assert(SanOpts.has(Checked[i].second));
   }
 #endif
 
@@ -2670,8 +2666,11 @@ void CodeGenFunction::EmitCfiCheckFail()
 SanitizerMask Mask = CheckKindMaskPair.second;
 llvm::Value *Cond =
 Builder.CreateICmpNE(CheckKind, llvm::ConstantInt::get(Int8Ty, Kind));
-EmitCheck(std::make_pair(Cond, Mask), "cfi_check_fail", {},
-  {Data, Addr, ValidVtable});
+if (CGM.getLangOpts().Sanitize.has(Mask))
+  EmitCheck(std::make_pair(Cond, Mask), "cfi_check_fail", {},
+{Data, Addr, ValidVtable});
+else
+  EmitTrapCheck(Cond);
   }
 
   FinishFunction();

Modified: cfe/trunk/test/CodeGen/cfi-check-fail.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cfi-check-fail.c?rev=263578=263577=263578=diff
==
--- cfe/trunk/test/CodeGen/cfi-check-fail.c (original)
+++ cfe/trunk/test/CodeGen/cfi-check-fail.c Tue Mar 15 15:19:29 2016
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize=cfi-icall 
-fsanitize-cfi-cross-dso \
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \
+// RUN: 
-fsanitize=cfi-icall,cfi-nvcall,cfi-vcall,cfi-unrelated-cast,cfi-derived-cast \
 // RUN: -fsanitize-trap=cfi-icall,cfi-nvcall 
-fsanitize-recover=cfi-vcall,cfi-unrelated-cast \
 // RUN: -emit-llvm -o - %s | FileCheck %s
 

Copied: cfe/trunk/test/CodeGen/cfi-check-fail2.c (from r263574, 
cfe/trunk/test/CodeGen/cfi-check-fail.c)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cfi-check-fail2.c?p2=cfe/trunk/test/CodeGen/cfi-check-fail2.c=cfe/trunk/test/CodeGen/cfi-check-fail.c=263574=263578=263578=diff
==
--- cfe/trunk/test/CodeGen/cfi-check-fail.c (original)
+++ cfe/trunk/test/CodeGen/cfi-check-fail2.c Tue Mar 15 15:19:29 2016
@@ -1,5 +1,6 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize=cfi-icall 
-fsanitize-cfi-cross-dso \
-// RUN: -fsanitize-trap=cfi-icall,cfi-nvcall 
-fsanitize-recover=cfi-vcall,cfi-unrelated-cast \
+// __cfi_check_fail codegen when not all CFI checkers are enabled.
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \
+// RUN: -fsanitize=cfi-vcall \
 // RUN: -emit-llvm -o - %s | FileCheck %s
 
 void caller(void (*f)()) {
@@ -30,8 +31,8 @@ void caller(void (*f)()) {
 // CHECK: [[HANDLE0]]:
 // CHECK:   %[[DATA0:.*]] = ptrtoint i8* %[[DATA]] to i64,
 // CHECK:   %[[ADDR0:.*]] = ptrtoint i8* %[[ADDR]] to i64,
-// CHECK:   call void @__ubsan_handle_cfi_check_fail(i64 %[[DATA0]], i64 
%[[ADDR0]], i64 %[[VTVALID]])
-// CHECK:   br label %[[CONT1]]
+// CHECK:   call void @__ubsan_handle_cfi_check_fail_abort(i64 %[[DATA0]], i64 
%[[ADDR0]], i64 %[[VTVALID]])
+// CHECK:   unreachable
 
 // CHECK: [[CONT1]]:
 // CHECK:   %[[NOT_1:.*]] = icmp ne i8 %[[KIND]], 1
@@ -43,23 +44,19 @@ void caller(void (*f)()) {
 
 // CHECK: 

Re: [PATCH] D17360: [cfi] Fix handling of sanitize trap/recover flags in the cross-DSO CFI mode.

2016-03-15 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

No, this is not committed.
I've run dcommit in the wrong checkout and landed 
http://reviews.llvm.org/D17900 instead.


Repository:
  rL LLVM

http://reviews.llvm.org/D17360



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


Re: [PATCH] D18174: Fix libcxx build on musl

2016-03-15 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

That patch looks hugely dangerous because you've now changed when your static 
mutex's get initialized.  Please file a bug against libc++.


http://reviews.llvm.org/D18174



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


Re: [PATCH] D18174: Fix libcxx build on musl

2016-03-15 Thread Khem Raj via cfe-commits
raj.khem added a comment.

libcxx still has problem compiling on musl/aarch64 though. I fixed it with this 
patch

https://github.com/kraj/meta-clang/blob/master/recipes-devtools/clang/libcxx/0001-use-constexpr-when-using-glibc.patch

does this make sense ?


http://reviews.llvm.org/D18174



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


Re: [PATCH] D18174: Fix libcxx build on musl

2016-03-15 Thread Eric Fiselier via cfe-commits
EricWF added a subscriber: EricWF.
EricWF added a comment.

@raj.khem Can you file a bug against libc++abi please?


http://reviews.llvm.org/D18174



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


Re: [PATCH] D18174: Fix libcxx build on musl

2016-03-15 Thread Khem Raj via cfe-commits
raj.khem added a comment.

I think my problem was that while compiling libcxxabi, it wants to peek into 
libcxx headers but then libcxxabi cmake infra doesnt have the musl support like 
libcxx. So Now I solved it by adding -D_LIBCPP_HAS_MUSL_LIBC to CXXFLAGS.


http://reviews.llvm.org/D18174



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


Re: [PATCH] D18174: Fix libcxx build on musl

2016-03-15 Thread Khem Raj via cfe-commits
raj.khem added a comment.

3.8 has it in there. So may be this is just not required. I will add 
-DLIBCXX_HAS_MUSL_LIBC=ON to Cmake and see what comes out


http://reviews.llvm.org/D18174



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


Re: [PATCH] D18193: [ARM] Add more ARM Cortex-R8 regression tests to Clang.

2016-03-15 Thread Tim Northover via cfe-commits
t.p.northover added a subscriber: t.p.northover.
t.p.northover accepted this revision.
t.p.northover added a reviewer: t.p.northover.
t.p.northover added a comment.
This revision is now accepted and ready to land.

This looks fine to me.

Tim.


http://reviews.llvm.org/D18193



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


r263574 - Test commit - Remove some trailing whitespace

2016-03-15 Thread Pablo Barrio via cfe-commits
Author: pabbar01
Date: Tue Mar 15 14:03:09 2016
New Revision: 263574

URL: http://llvm.org/viewvc/llvm-project?rev=263574=rev
Log:
Test commit - Remove some trailing whitespace

Modified:
cfe/trunk/test/Preprocessor/arm-target-features.c

Modified: cfe/trunk/test/Preprocessor/arm-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/arm-target-features.c?rev=263574=263573=263574=diff
==
--- cfe/trunk/test/Preprocessor/arm-target-features.c (original)
+++ cfe/trunk/test/Preprocessor/arm-target-features.c Tue Mar 15 14:03:09 2016
@@ -14,7 +14,7 @@
 // CHECK-V7: __ARM_ARCH 7
 // CHECK-V7: __ARM_ARCH_7A__ 1
 // CHECK-V7-NOT: __ARM_FEATURE_CRC32
-// CHECK-V7-NOT: __ARM_FEATURE_NUMERIC_MAXMIN  
 
+// CHECK-V7-NOT: __ARM_FEATURE_NUMERIC_MAXMIN
 // CHECK-V7-NOT: __ARM_FEATURE_DIRECTED_ROUNDING
 // CHECK-V7: __ARM_FP 0xC
 


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


Re: [PATCH] D18174: Fix libcxx build on musl

2016-03-15 Thread Khem Raj via cfe-commits
raj.khem added a comment.

@bcraig, right, check for __GLIBC__ can be moved after including features.h. 
https://chromium.googlesource.com/native_client/pnacl-libcxx/+/master%5E!/
seems to add needed tweaks which can be enabled by passing -D__musl__ in CFLAGS
may be it can be backported to 3.8 branch


http://reviews.llvm.org/D18174



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


Re: [PATCH] D18182: [test] Don't use UNSUPPORTED in FileCheck prefixes

2016-03-15 Thread John McCall via cfe-commits
rjmccall added a comment.

LGTM.


http://reviews.llvm.org/D18182



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


Re: [PATCH] D18174: Fix libcxx build on musl

2016-03-15 Thread Ben Craig via cfe-commits
bcraig added a comment.

If I understand it correctly, __GLIBC__ is defined in features.h, so this won't 
work.

I suspect that the build isn't broken.  You likely just need to define 
LIBCXX_HAS_MUSL_LIBC on your cmake line.  That will cause __config_site.in to 
#define _LIBCPP_HAS_MUSL_LIBC for you.


http://reviews.llvm.org/D18174



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


Re: [PATCH] D15599: [CodeGen] Fix a crash that occurs when attribute "naked" is attached to a c++ member function

2016-03-15 Thread Akira Hatanaka via cfe-commits
ahatanak marked 2 inline comments as done.


Comment at: test/CodeGen/attr-naked.c:20
@@ -19,3 +19,3 @@
 __attribute((naked)) void t3(int x) {
-// CHECK: define void @t3(i32)
+// CHECK: define void @t3(i32 %x)
 // CHECK-NOT: alloca

This is a side effect of not exiting early in 
CodeGenFunction::EmitFunctionProlog.


Comment at: test/CodeGenCXX/attr-naked.cpp:8
@@ +7,3 @@
+// CHECK-NEXT: unreachable
+// CHECK-NEXT: }
+

I've also added a check to make sure the thunk isn't marked naked.


http://reviews.llvm.org/D15599



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


Re: [PATCH] D15599: [CodeGen] Fix a crash that occurs when attribute "naked" is attached to a c++ member function

2016-03-15 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 50759.
ahatanak added a comment.

Address review comments.

- Rewrite cleanupNakedFunction.
- Fix test case attr-naked.cpp. Check that the thunk function doesn't get 
removed when the virtual function is marked "naked".


http://reviews.llvm.org/D15599

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/attr-naked.c
  test/CodeGenCXX/attr-naked.cpp
  test/CodeGenCXX/ms-inline-asm-return.cpp

Index: test/CodeGenCXX/ms-inline-asm-return.cpp
===
--- test/CodeGenCXX/ms-inline-asm-return.cpp
+++ test/CodeGenCXX/ms-inline-asm-return.cpp
@@ -1,5 +1,5 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 %s -triple i686-pc-windows-msvc -emit-llvm -o - -fasm-blocks | FileCheck %s
+// RUN: %clang_cc1 %s -triple i686-pc-windows-msvc -emit-llvm -o - -fasm-blocks -fms-compatibility | FileCheck %s
 
 // Check that we take EAX or EAX:EDX and return it from these functions for MSVC
 // compatibility.
@@ -98,3 +98,17 @@
 // CHECK-LABEL: define i32 @main()
 // CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "xor eax, eax", "={eax},{{.*}}"
 // CHECK: ret i32 %[[r]]
+
+// Don't set the return value if the function is marked as naked.
+__declspec(naked) int nakedFunc(int a, int b)
+{
+  __asm {
+ret
+  }
+}
+
+// CHECK: define i32 @{{.*}}nakedFunc
+// CHECK-NEXT: entry:
+// CHECK-NEXT: call void asm sideeffect inteldialect "ret
+// CHECK-NEXT: unreachable
+// CHECK-NEXT: }
Index: test/CodeGenCXX/attr-naked.cpp
===
--- /dev/null
+++ test/CodeGenCXX/attr-naked.cpp
@@ -0,0 +1,79 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s
+// REQUIRES: asserts
+
+// CHECK: define internal i32 @"_ZZ4foo1iP6Class1ENK3$_0clEv"(%class.anon* %this) [[ATTR1:#[0-9]]]
+// CHECK-NEXT: entry:
+// CHECK-NEXT: call void asm sideeffect "retq
+// CHECK-NEXT: unreachable
+// CHECK-NEXT: }
+
+// CHECK: define linkonce_odr i32 @_ZN6Class12m2Ev(%class.Class1* %this) [[ATTR2:#[0-9]]]
+// CHECK-NEXT: entry:
+// CHECK-NEXT: call void asm sideeffect "retq
+// CHECK-NEXT: unreachable
+// CHECK-NEXT: }
+
+// CHECK: define linkonce_odr void @_ZN6Class12m1Ev(%class.Class1* %this) [[ATTR2]]
+// CHECK-NEXT: entry:
+// CHECK-NEXT: call void asm sideeffect "retq
+// CHECK-NEXT: unreachable
+// CHECK-NEXT: }
+
+class Class1 {
+public:
+  void __attribute__((naked)) m1() { __asm__ volatile("retq"); }
+  int __attribute__((naked)) m2() { __asm__ volatile("retq"); }
+};
+
+int foo1(int a, Class1 *c1) {
+  auto Fn = []() __attribute__((naked))->int {
+__asm__ volatile("retq");
+  };
+
+  if (a < 0)
+return Fn();
+
+  if (a > 0)
+return c1->m2();
+
+  c1->m1();
+  return 1;
+}
+
+// Check for the absence of llvm.trap.
+
+// CHECK: define i32 @_Z4foo2i(i32 %a) [[ATTR2]]
+// CHECK-NEXT: entry:
+// CHECK-NEXT: call void asm sideeffect "retq
+// CHECK-NEXT: unreachable
+// CHECK-NEXT: }
+
+int __attribute__((naked)) foo2(int a) {
+  __asm__ volatile("retq");
+}
+
+// Make sure attaching "naked" to D0::m1 doesn't remove the thunk.
+
+// CHECK: define linkonce_odr void @_ZThn8_N2D02m1Ev(%struct.D0* %this) unnamed_addr [[ATTR3:#[0-9]]]
+
+struct B0 {
+  virtual void m1();
+};
+
+struct B1 {
+  virtual void m1();
+};
+
+struct D0 : B0, B1 {
+  void __attribute__((naked)) m1() { __asm__ volatile("retq"); }
+};
+
+void foo3() {
+  D0 d0;
+  B1 *b1 = 
+  b1->m1();
+}
+
+// CHECK: attributes [[ATTR1]] = { {{.*}}naked{{.*}} }
+// CHECK: attributes [[ATTR2]] = { {{.*}}naked{{.*}} }
+// CHECK-NOT: attributes [[ATTR3]] = { {{.*}}naked{{.*}} }
Index: test/CodeGen/attr-naked.c
===
--- test/CodeGen/attr-naked.c
+++ test/CodeGen/attr-naked.c
@@ -17,7 +17,7 @@
 
 // Make sure not to generate prolog or epilog for naked functions.
 __attribute((naked)) void t3(int x) {
-// CHECK: define void @t3(i32)
+// CHECK: define void @t3(i32 %x)
 // CHECK-NOT: alloca
 // CHECK-NOT: store
 // CHECK: unreachable
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -3132,6 +3132,13 @@
   llvm::Value *emitBuiltinObjectSize(const Expr *E, unsigned Type,
  llvm::IntegerType *ResType);
 
+  /// Return true if CurCodeDecl has attribute Naked.
+  bool isNakedFunction() const;
+
+  /// Clean up naked functions removing allocas and their users and all blocks
+  /// except the entry.
+  void cleanupNakedFunction();
+
 public:
 #ifndef NDEBUG
   // Determine whether the given argument is an Objective-C method
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp

Re: [PATCH] D14737: Convert some ObjC msgSends to runtime calls

2016-03-15 Thread John McCall via cfe-commits
rjmccall added a comment.

Ah, okay, if you changed it to cast explicitly, that's all I was concerned 
about.


http://reviews.llvm.org/D14737



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


Re: [PATCH] D17988: Fix destructor definition of invalid classes

2016-03-15 Thread John McCall via cfe-commits
rjmccall added a comment.

Seems okay to me.


http://reviews.llvm.org/D17988



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


Re: [PATCH] D14737: Convert some ObjC msgSends to runtime calls

2016-03-15 Thread Pete Cooper via cfe-commits
pete added a comment.

In http://reviews.llvm.org/D14737#375735, @rjmccall wrote:

> Can you find where that bitcast is being added?  I know that different parts 
> of IRGen are differently sensitive to types — it's possible that the return 
> code is one of those more-permissive places.


Sure, will do.

I should say that the bit cast here is my doing.  I should have said that I 
added code to emitARCValueOperation which optionally takes a return type to 
cast to, instead of always casting to the receiver type as you noted it was 
doing before.  But as you point out, even without that change, the IR is still 
getting bit casts when needed.


http://reviews.llvm.org/D14737



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


Re: [PATCH] D18175: Avoid using LookupResult's implicit copy ctor and assignment operator to avoid warnings

2016-03-15 Thread David Blaikie via cfe-commits
On Tue, Mar 15, 2016 at 11:26 AM, John McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> rjmccall added a comment.
>
> Ignore Dave and fix the problem, please. :)
>

+1, sorry for the race on review.


>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D18175
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14737: Convert some ObjC msgSends to runtime calls

2016-03-15 Thread John McCall via cfe-commits
rjmccall added a comment.

Can you find where that bitcast is being added?  I know that different parts of 
IRGen are differently sensitive to types — it's possible that the return code 
is one of those more-permissive places.


http://reviews.llvm.org/D14737



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


r263571 - [CMake] Updating Apple build configurations

2016-03-15 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue Mar 15 13:27:28 2016
New Revision: 263571

URL: http://llvm.org/viewvc/llvm-project?rev=263571=rev
Log:
[CMake] Updating Apple build configurations

This updates Apple build configurations to adapt to r263566 & r263570, which 
added a PACKAGE_VENDOR variable.

Modified:
cfe/trunk/cmake/caches/Apple-stage2.cmake

Modified: cfe/trunk/cmake/caches/Apple-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage2.cmake?rev=263571=263570=263571=diff
==
--- cfe/trunk/cmake/caches/Apple-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake Tue Mar 15 13:27:28 2016
@@ -2,7 +2,7 @@
 # specified by the stage1 build.
 
 set(LLVM_TARGETS_TO_BUILD X86 ARM AArch64 CACHE STRING "") 
-set(CLANG_VENDOR Apple CACHE STRING "")
+set(PACKAGE_VENDOR Apple 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 "")


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


r263570 - [CMake] Defaulting CLANG_VENDOR to PACKAGE_VENDOR

2016-03-15 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue Mar 15 13:25:36 2016
New Revision: 263570

URL: http://llvm.org/viewvc/llvm-project?rev=263570=rev
Log:
[CMake] Defaulting CLANG_VENDOR to PACKAGE_VENDOR

LLVM r263566 adds a generic PACKAGE_VENDOR configuration which can be used to 
specify the vendor for LLVM toolchain tools. This change defaults the 
CLANG_VENDOR to the PACKAGE_VENDOR so that you don't have to specify both when 
building a package.

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=263570=263569=263570=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Tue Mar 15 13:25:36 2016
@@ -209,7 +209,7 @@ endif()
 set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING
   "Default OpenMP runtime used by -fopenmp.")
 
-set(CLANG_VENDOR "" CACHE STRING
+set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING
   "Vendor-specific text for showing with version information.")
 
 if( CLANG_VENDOR )


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


Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

2016-03-15 Thread John McCall via cfe-commits
rjmccall added a comment.

It's languished because the idea itself has unavoidable problems with 
incomplete types.


http://reviews.llvm.org/D18035



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


Re: [PATCH] D18123: Fix implicit copy ctor and copy assignment operator warnings when -Wdeprecated passed.

2016-03-15 Thread John McCall via cfe-commits
rjmccall added a comment.

Making UnresolvedSet copyable / movable seems reasonable to me.


http://reviews.llvm.org/D18123



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


Re: [PATCH] D18175: Avoid using LookupResult's implicit copy ctor and assignment operator to avoid warnings

2016-03-15 Thread John McCall via cfe-commits
rjmccall added a comment.

Ignore Dave and fix the problem, please. :)


Repository:
  rL LLVM

http://reviews.llvm.org/D18175



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


r263568 - Fix a bot I broke.

2016-03-15 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue Mar 15 13:17:48 2016
New Revision: 263568

URL: http://llvm.org/viewvc/llvm-project?rev=263568=rev
Log:
Fix a bot I broke.

The builtin library isn't added by the driver unless it exists, so we shouldn't 
check for it. I've marked this as a FIXME, because we probably should have a 
way to test this.

Modified:
cfe/trunk/test/Driver/darwin-ld.c

Modified: cfe/trunk/test/Driver/darwin-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-ld.c?rev=263568=263567=263568=diff
==
--- cfe/trunk/test/Driver/darwin-ld.c (original)
+++ cfe/trunk/test/Driver/darwin-ld.c Tue Mar 15 13:17:48 2016
@@ -156,7 +156,10 @@
 // RUN: FileCheck -check-prefix=LINK_IOSSIM_PROFILE %s < %t.log
 // LINK_IOSSIM_PROFILE: {{ld(.exe)?"}}
 // LINK_IOSSIM_PROFILE: libclang_rt.profile_iossim.a
-// LINK_IOSSIM_PROFILE: libclang_rt.ios.a
+
+// FIXME: Currently the builtin library is only added to the command line if 
it,
+// so we can't check for it here
+// FIXME_LINK_IOSSIM_PROFILE: libclang_rt.ios.a
 
 // RUN: %clang -target arm64-apple-tvos8.3 -mtvos-version-min=8.3 -### %t.o 2> 
%t.log
 // RUN: FileCheck -check-prefix=LINK_TVOS_ARM64 %s < %t.log


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


Re: [PATCH] D18139: [Cxx1z] Implement Lambda Capture of *this by Value as [=, *this] (P0018R3)

2016-03-15 Thread Faisal Vali via cfe-commits
faisalv updated this revision to Diff 50757.
faisalv added a comment.

Added some more comments (hopefully didn't go overboard).

Thanks again for reviewing Richard!


http://reviews.llvm.org/D18139

Files:
  include/clang/AST/LambdaCapture.h
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Lambda.h
  include/clang/Sema/ScopeInfo.h
  include/clang/Sema/Sema.h
  lib/AST/ExprCXX.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  test/CodeGenCXX/cxx1z-lambda-star-this.cpp
  test/SemaCXX/cxx1z-lambda-star-this.cpp

Index: test/SemaCXX/cxx1z-lambda-star-this.cpp
===
--- /dev/null
+++ test/SemaCXX/cxx1z-lambda-star-this.cpp
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -emit-llvm-only %s
+// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -fdelayed-template-parsing %s -DDELAYED_TEMPLATE_PARSING
+// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -fms-extensions %s -DMS_EXTENSIONS
+// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -fdelayed-template-parsing -fms-extensions %s -DMS_EXTENSIONS -DDELAYED_TEMPLATE_PARSING
+
+
+namespace test_star_this {
+namespace ns1 {
+class A {
+  int x = 345;
+  auto foo() {
+(void) [*this, this] { };  //expected-error{{'this' can appear only once}}
+(void) [this] { ++x; };
+(void) [*this] { ++x; };  //expected-error{{read-only variable}}
+(void) [*this] () mutable { ++x; };
+(void) [=] { return x; };
+(void) [&, this] { return x; };
+(void) [=, *this] { return x; };
+(void) [&, *this] { return x; };
+  }
+};
+} // end ns1
+
+namespace ns2 {
+  class B {
+B(const B&) = delete; //expected-note{{deleted here}}
+int *x = (int *) 456;
+void foo() {
+  (void)[this] { return x; };
+  (void)[*this] { return x; }; //expected-error{{call to deleted}}
+}
+  };
+} // end ns2
+namespace ns3 {
+  class B {
+B(const B&) = delete; //expected-note2{{deleted here}}
+
+int *x = (int *) 456;
+public: 
+template
+void foo() {
+  (void)[this] { return x; };
+  (void)[*this] { return x; }; //expected-error2{{call to deleted}}
+}
+
+B() = default;
+  } b;
+  B *c = (b.foo(), nullptr); //expected-note{{in instantiation}}
+} // end ns3
+
+namespace ns4 {
+template
+class B {
+  B(const B&) = delete; //expected-note{{deleted here}}
+  double d = 3.14;
+  public: 
+  template
+  auto foo() {
+const auto  = [*this] (auto a) mutable { //expected-error{{call to deleted}}
+  d += a; 
+  return [this] (auto b) { return d +=b; }; 
+}; 
+  }
+  
+  B() = default;
+};
+void main() {
+  B b;
+  b.foo(); //expected-note{{in instantiation}}
+} // end main  
+} // end ns4
+} //end ns test_star_this
Index: test/CodeGenCXX/cxx1z-lambda-star-this.cpp
===
--- /dev/null
+++ test/CodeGenCXX/cxx1z-lambda-star-this.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++1y -triple i686-pc-windows-msvc -emit-llvm %s -o - | FileCheck %s
+//CHECK: %[[A_LAMBDA:.*]] = type { %struct.A }
+//CHECK: %[[B_LAMBDA:.*]] = type { %struct.B* }
+struct A {
+  double a = 111;
+  auto foo() { return [*this] { return a; }; }
+};
+
+namespace ns1 {
+int X = A{}.foo()();
+} //end ns1
+
+//CHECK: @"\01?foo@A@@QAE?A?@@XZ"(%struct.A* %this, %class.anon* noalias sret %[[A_LAMBDA_RETVAL:.*]])
+// get the first object with the closure type, which is of type 'struct.A'
+//CHECK: %0 = getelementptr inbounds %[[A_LAMBDA]], %[[A_LAMBDA]]* %[[A_LAMBDA_RETVAL]], i32 0, i32 0
+//CHECK: %1 = bitcast %struct.A* %0 to i8*
+//CHECK: %2 = bitcast %struct.A* %this1 to i8*
+// copy the contents ...
+//CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %1, i8* %2, i32 8, i32 8, i1 false)
+
+struct B {
+  double b = 222;
+  auto bar() { return [this] { return b; }; };
+};
+
+namespace ns2 {
+int X = B{}.bar()();
+}
+//CHECK: @"\01?bar@B@@QAE?A?@@XZ"(%struct.B* %this, %class.anon.0* noalias sret %agg.result)
+//CHECK: %0 = getelementptr inbounds %class.anon.0, %class.anon.0* %agg.result, i32 0, i32 0
+//CHECK: store %struct.B* %this1, %struct.B** %0, align 4
\ No newline at end of file
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -5631,6 +5631,7 @@
   Record.push_back(Capture.isImplicit());
   Record.push_back(Capture.getCaptureKind());
   switch (Capture.getCaptureKind()) {
+  case LCK_StarThis:
   case LCK_This:
   case LCK_VLAType:
 break;
Index: 

[PATCH] D18193: [ARM] Add more ARM Cortex-R8 regression tests to Clang.

2016-03-15 Thread Pablo Barrio via cfe-commits
pbarrio created this revision.
pbarrio added reviewers: rengolin, bsmith.
pbarrio added a subscriber: cfe-commits.
Herald added subscribers: rengolin, aemerson.

This patch adds Clang tests for Cortex-R8 related to FP capabilities and
hardware integer divide.

http://reviews.llvm.org/D18193

Files:
  test/CodeGen/arm-target-features.c
  test/Driver/arm-cortex-cpus.c
  test/Preprocessor/arm-acle-6.4.c
  test/Preprocessor/arm-target-features.c

Index: test/Preprocessor/arm-target-features.c
===
--- test/Preprocessor/arm-target-features.c
+++ test/Preprocessor/arm-target-features.c
@@ -389,16 +389,18 @@
 // R5-THUMB:#define __ARM_FEATURE_DSP
 // R5-THUMB:#define __ARM_FP 0xC
 
-// Test whether predefines are as expected when targeting cortex-r7.
-// RUN: %clang -target armv7 -mcpu=cortex-r7 -x c -E -dM %s -o - | FileCheck 
--check-prefix=R7-ARM %s
-// R7-ARM:#define __ARM_ARCH_EXT_IDIV__ 1
-// R7-ARM:#define __ARM_FEATURE_DSP
-// R7-ARM:#define __ARM_FP 0xE
-
-// RUN: %clang -target armv7 -mthumb -mcpu=cortex-r7 -x c -E -dM %s -o - | 
FileCheck --check-prefix=R7-THUMB %s
-// R7-THUMB:#define __ARM_ARCH_EXT_IDIV__ 1
-// R7-THUMB:#define __ARM_FEATURE_DSP
-// R7-THUMB:#define __ARM_FP 0xE
+// Test whether predefines are as expected when targeting cortex-r7 and 
cortex-r8.
+// RUN: %clang -target armv7 -mcpu=cortex-r7 -x c -E -dM %s -o - | FileCheck 
--check-prefix=R7-R8-ARM %s
+// RUN: %clang -target armv7 -mcpu=cortex-r8 -x c -E -dM %s -o - | FileCheck 
--check-prefix=R7-R8-ARM %s
+// R7-R8-ARM:#define __ARM_ARCH_EXT_IDIV__ 1
+// R7-R8-ARM:#define __ARM_FEATURE_DSP
+// R7-R8-ARM:#define __ARM_FP 0xE
+
+// RUN: %clang -target armv7 -mthumb -mcpu=cortex-r7 -x c -E -dM %s -o - | 
FileCheck --check-prefix=R7-R8-THUMB %s
+// RUN: %clang -target armv7 -mthumb -mcpu=cortex-r8 -x c -E -dM %s -o - | 
FileCheck --check-prefix=R7-R8-THUMB %s
+// R7-R8-THUMB:#define __ARM_ARCH_EXT_IDIV__ 1
+// R7-R8-THUMB:#define __ARM_FEATURE_DSP
+// R7-R8-THUMB:#define __ARM_FP 0xE
 
 // Test whether predefines are as expected when targeting cortex-m0.
 // RUN: %clang -target armv7 -mthumb -mcpu=cortex-m0 -x c -E -dM %s -o - | 
FileCheck --check-prefix=M0-THUMB %s
Index: test/Preprocessor/arm-acle-6.4.c
===
--- test/Preprocessor/arm-acle-6.4.c
+++ test/Preprocessor/arm-acle-6.4.c
@@ -140,6 +140,7 @@
 
 // RUN: %clang -target arm-none-linux-eabi -mcpu=cortex-r5 -x c -E -dM %s -o - 
| FileCheck %s -check-prefix CHECK-V7R-IDIV
 // RUN: %clang -target arm-none-linux-eabi -mcpu=cortex-r7 -x c -E -dM %s -o - 
| FileCheck %s -check-prefix CHECK-V7R-IDIV
+// RUN: %clang -target arm-none-linux-eabi -mcpu=cortex-r8 -x c -E -dM %s -o - 
| FileCheck %s -check-prefix CHECK-V7R-IDIV
 
 // CHECK-V7R-IDIV: __ARM_FEATURE_IDIV 1
 
Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -419,16 +419,19 @@
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r4f -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV7R %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r5 -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV7R %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r7 -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV7R %s
+// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r8 -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV7R %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r4 -mlittle-endian -### 
-c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7R %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r4f -mlittle-endian -### 
-c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7R %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r5 -mlittle-endian -### 
-c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7R %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r7 -mlittle-endian -### 
-c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7R %s
+// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r8 -mlittle-endian -### 
-c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7R %s
 // CHECK-CPUV7R: "-cc1"{{.*}} "-triple" "armv7r-{{.*}}
 
 // RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-r4 -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-CPUV7R %s
 // RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-r4f -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-CPUV7R %s
 // RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-r5 -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-CPUV7R %s
 // RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-r7 -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-CPUV7R %s
+// RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-r8 -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-CPUV7R %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r4 -mbig-endian -### -c 
%s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R %s
 // 

r263567 - [Driver] [Darwin] Fix linking libclang_rt.profile_*sim.a

2016-03-15 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue Mar 15 13:08:20 2016
New Revision: 263567

URL: http://llvm.org/viewvc/llvm-project?rev=263567=rev
Log:
[Driver] [Darwin] Fix linking libclang_rt.profile_*sim.a

Summary: isTarget*() calls are order-dependent. This is because iOS Sim *is* 
iOS. This means checks for the simulator version of the platform must always be 
ahead of checks for the embedded platform.

Reviewers: zaks.anna, bogner

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=263567=263566=263567=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Mar 15 13:08:20 2016
@@ -353,34 +353,8 @@ void Darwin::addProfileRTLibs(const ArgL
   ArgStringList ) const {
   if (!needsProfileRT(Args)) return;
 
-  // TODO: Clean this up once autoconf is gone
-  SmallString<128> P(getDriver().ResourceDir);
-  llvm::sys::path::append(P, "lib", "darwin");
-  const char *Library = "libclang_rt.profile_osx.a";
-
-  // Select the appropriate runtime library for the target.
-  if (isTargetWatchOS()) {
-Library = "libclang_rt.profile_watchos.a";
-  } else if (isTargetWatchOSSimulator()) {
-llvm::sys::path::append(P, "libclang_rt.profile_watchossim.a");
-Library = getVFS().exists(P) ? "libclang_rt.profile_watchossim.a"
- : "libclang_rt.profile_watchos.a";
-  } else if (isTargetTvOS()) {
-Library = "libclang_rt.profile_tvos.a";
-  } else if (isTargetTvOSSimulator()) {
-llvm::sys::path::append(P, "libclang_rt.profile_tvossim.a");
-Library = getVFS().exists(P) ? "libclang_rt.profile_tvossim.a"
- : "libclang_rt.profile_tvos.a";
-  } else if (isTargetIPhoneOS()) {
-Library = "libclang_rt.profile_ios.a";
-  } else if (isTargetIOSSimulator()) {
-llvm::sys::path::append(P, "libclang_rt.profile_iossim.a");
-Library = getVFS().exists(P) ? "libclang_rt.profile_iossim.a"
- : "libclang_rt.profile_ios.a";
-  } else {
-assert(isTargetMacOS() && "unexpected non MacOS platform");
-  }
-  AddLinkRuntimeLib(Args, CmdArgs, Library,
+  AddLinkRuntimeLib(Args, CmdArgs, (Twine("libclang_rt.profile_") +
+   getOSLibraryNameSuffix() + ".a").str(),
 /*AlwaysLink*/ true);
 }
 

Modified: cfe/trunk/test/Driver/darwin-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-ld.c?rev=263567=263566=263567=diff
==
--- cfe/trunk/test/Driver/darwin-ld.c (original)
+++ cfe/trunk/test/Driver/darwin-ld.c Tue Mar 15 13:08:20 2016
@@ -152,6 +152,12 @@
 // RUN: FileCheck -check-prefix=LINK_NO_IOS_ARM64_CRT1 %s < %t.log
 // LINK_NO_IOS_ARM64_CRT1-NOT: crt
 
+// RUN: %clang -target x86_64-apple-ios6.0 -miphoneos-version-min=6.0 
-fprofile-instr-generate -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_IOSSIM_PROFILE %s < %t.log
+// LINK_IOSSIM_PROFILE: {{ld(.exe)?"}}
+// LINK_IOSSIM_PROFILE: libclang_rt.profile_iossim.a
+// LINK_IOSSIM_PROFILE: libclang_rt.ios.a
+
 // RUN: %clang -target arm64-apple-tvos8.3 -mtvos-version-min=8.3 -### %t.o 2> 
%t.log
 // RUN: FileCheck -check-prefix=LINK_TVOS_ARM64 %s < %t.log
 // LINK_TVOS_ARM64: {{ld(.exe)?"}}


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


Re: [PATCH] D17947: [Driver] [Darwin] Fix linking libclang_rt.profile_*sim.a

2016-03-15 Thread Chris Bieneman via cfe-commits
beanz added a comment.

Ping.


http://reviews.llvm.org/D17947



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


Re: [PATCH] D18175: Avoid using LookupResult's implicit copy ctor and assignment operator to avoid warnings

2016-03-15 Thread David Blaikie via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Looks good - thanks!


Repository:
  rL LLVM

http://reviews.llvm.org/D18175



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


Re: [PATCH] D14000: [CUDA] Allow code generation for functions with target attributes that don't match compilation mode.

2016-03-15 Thread Jingyue Wu via cfe-commits
jingyue added a comment.

Is this patch obsolete? Are you still trying to push it in?


http://reviews.llvm.org/D14000



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


[PATCH] D18191: [clang-tidy] Add check for function parameters that are const& to builtin types

2016-03-15 Thread Steve Downey via cfe-commits
sdowney created this revision.
sdowney added a reviewer: alexfh.
sdowney added a subscriber: cfe-commits.

Add a check for const& to builtin types. Add FixIt replacing, for example, 
'const& int i' with 'int i'.

http://reviews.llvm.org/D18191

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/ConstRefBuiltinCheck.cpp
  clang-tidy/misc/ConstRefBuiltinCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-const-ref-builtin.rst
  test/clang-tidy/misc-const-ref-builtin.cpp

Index: test/clang-tidy/misc-const-ref-builtin.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-const-ref-builtin.cpp
@@ -0,0 +1,34 @@
+// RUN: %check_clang_tidy %s misc-const-ref-builtin %t
+
+void f(const int& i);
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: const reference to 'int' at parameter 'i' in function 'f' [misc-const-ref-builtin]
+
+void f2(const int&);
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: const reference to 'int' type at index '0' in function 'f2' [misc-const-ref-builtin]
+
+typedef int Int;
+void t(const Int& i);
+// CHECK-MESSAGES: :[[@LINE-1]]:19:  warning: const reference to 'Int' (aka 'int') at parameter 'i' in function 't' [misc-const-ref-builtin]
+
+template
+void g(const T&);
+
+void X() {
+  g(5);
+}
+
+void f3();
+
+void h(int& i);
+
+class Bar {};
+void f4(const Bar& bar);
+
+class Baz {
+  int i;
+};
+void f5(const Baz& baz);
+
+void f(const int& i, const int& j);
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: const reference to 'int' at parameter 'i' in function 'f' [misc-const-ref-builtin]
+// CHECK-MESSAGES: :[[@LINE-2]]:33: warning: const reference to 'int' at parameter 'j' in function 'f' [misc-const-ref-builtin]
Index: docs/clang-tidy/checks/misc-const-ref-builtin.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-const-ref-builtin.rst
@@ -0,0 +1,28 @@
+.. title:: clang-tidy - misc-const-ref-builtin
+
+misc-const-ref-builtin
+==
+
+This check will warn about function arguments that are const refs to builtin
+types, such as int or double. It will also warn about const refs to typedefs to
+builtin types. It will not flag function arguments that are due to template
+instantiations.
+
+Example code::
+
+  void f(const int& i);
+
+
+The parameter i will be flagged.
+
+Example code::
+
+  template
+  void g(const T&);
+
+  void X() {
+  g(5);
+  }
+
+
+The instantion of g will not be flagged.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -48,6 +48,7 @@
misc-assert-side-effect
misc-assign-operator-signature
misc-bool-pointer-implicit-conversion
+   misc-const-ref-builtin
misc-definitions-in-headers
misc-inaccurate-erase
misc-incorrect-roundings
Index: clang-tidy/misc/MiscTidyModule.cpp
===
--- clang-tidy/misc/MiscTidyModule.cpp
+++ clang-tidy/misc/MiscTidyModule.cpp
@@ -14,6 +14,7 @@
 #include "AssertSideEffectCheck.h"
 #include "AssignOperatorSignatureCheck.h"
 #include "BoolPointerImplicitConversionCheck.h"
+#include "ConstRefBuiltinCheck.h"
 #include "DefinitionsInHeadersCheck.h"
 #include "InaccurateEraseCheck.h"
 #include "IncorrectRoundings.h"
@@ -53,6 +54,8 @@
 "misc-assign-operator-signature");
 CheckFactories.registerCheck(
 "misc-bool-pointer-implicit-conversion");
+CheckFactories.registerCheck(
+"misc-const-ref-builtin");
 CheckFactories.registerCheck(
 "misc-definitions-in-headers");
 CheckFactories.registerCheck(
Index: clang-tidy/misc/ConstRefBuiltinCheck.h
===
--- /dev/null
+++ clang-tidy/misc/ConstRefBuiltinCheck.h
@@ -0,0 +1,39 @@
+//===--- ConstRefBuiltinCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_CONST_REF_BUILTIN_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_CONST_REF_BUILTIN_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+/// Checks for function parameters that are const& to builtin types.
+///
+/// Const reference to builtin type, such as int, adds an unnecessary layer of
+/// indirection. The Check will also warn on const& to typedef to builtin. It
+/// will not warn if the const& paramter was due to template instantiation.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-const-ref-builtin.html
+class 

Re: [PATCH] D18175: Avoid using LookupResult's implicit copy ctor and assignment operator to avoid warnings

2016-03-15 Thread John McCall via cfe-commits
rjmccall added a comment.

You can't call getFoundDecl() if !isSingleResult().  You should add a test case 
that actually tests the possibility that this lookup will fail.


Repository:
  rL LLVM

http://reviews.llvm.org/D18175



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


Re: [PATCH] D18186: Myriad: pass -mcpu flag to moviCompile, no default

2016-03-15 Thread Douglas Katzman via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL263556: Myriad: Pass -mcpu to movi{Compile,Asm} (authored by 
dougk).

Changed prior to commit:
  http://reviews.llvm.org/D18186?vs=50739=50748#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18186

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/myriad-toolchain.c

Index: cfe/trunk/test/Driver/myriad-toolchain.c
===
--- cfe/trunk/test/Driver/myriad-toolchain.c
+++ cfe/trunk/test/Driver/myriad-toolchain.c
@@ -36,10 +36,10 @@
 // As such, we test only for a trailing quote in its rendering.
 // The same goes for "moviAsm".
 
-// RUN: %clang -target shave-myriad -c -### %s -isystem somewhere -Icommon 
-Wa,-yippee 2>&1 \
+// RUN: %clang -target shave-myriad -mcpu=myriad1 -c -### %s -isystem 
somewhere -Icommon -Wa,-yippee 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MOVICOMPILE
-// MOVICOMPILE: moviCompile{{(.exe)?}}" "-S" "-fno-exceptions" "-mcpu=myriad2" 
"-DMYRIAD2" "-isystem" "somewhere" "-I" "common"
-// MOVICOMPILE: moviAsm{{(.exe)?}}" "-no6thSlotCompression" "-cv:myriad2" 
"-noSPrefixing" "-a"
+// MOVICOMPILE: moviCompile{{(.exe)?}}" "-S" "-fno-exceptions" "-DMYRIAD2" 
"-mcpu=myriad1" "-isystem" "somewhere" "-I" "common"
+// MOVICOMPILE: moviAsm{{(.exe)?}}" "-no6thSlotCompression" "-cv:myriad1" 
"-noSPrefixing" "-a"
 // MOVICOMPILE: "-yippee" "-i:somewhere" "-i:common" "-elf"
 
 // RUN: %clang -target shave-myriad -c -### %s -DEFINE_ME -UNDEFINE_ME 2>&1 \
@@ -58,15 +58,15 @@
 
 // RUN: %clang -target shave-myriad -c %s -o foo.o -### -MD -MF dep.d 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MDMF
-// MDMF: "-S" "-fno-exceptions" "-mcpu=myriad2" "-DMYRIAD2" "-MD" "-MF" 
"dep.d" "-MT" "foo.o"
+// MDMF: "-S" "-fno-exceptions" "-DMYRIAD2" "-MD" "-MF" "dep.d" "-MT" "foo.o"
 
-// RUN: %clang -target shave-myriad -std=gnu++11 -S %s -o foo.o -### 2>&1 \
+// RUN: %clang -target shave-myriad -std=gnu++11 -mcpu=anothercpu -S %s -o 
foo.o -### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=STDEQ
-// STDEQ: "-S" "-fno-exceptions" "-mcpu=myriad2" "-DMYRIAD2" "-std=gnu++11"
+// STDEQ: "-S" "-fno-exceptions" "-DMYRIAD2" "-std=gnu++11" "-mcpu=anothercpu"
 
 // RUN: %clang -target shave-myriad -E -Ifoo %s -o foo.i -### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=PREPROCESS
-// PREPROCESS: "-E" "-mcpu=myriad2" "-DMYRIAD2" "-I" "foo"
+// PREPROCESS: "-E" "-DMYRIAD2" "-I" "foo"
 
 // RUN: %clang -target sparc-myriad -### --driver-mode=g++ %s 2>&1 | FileCheck 
%s --check-prefix=STDLIBCXX
 // STDLIBCXX: "-lstdc++" "-lc" "-lgcc"
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -10431,7 +10431,6 @@
 CmdArgs.push_back("-S");
 CmdArgs.push_back("-fno-exceptions"); // Always do this even if 
unspecified.
   }
-  CmdArgs.push_back("-mcpu=myriad2");
   CmdArgs.push_back("-DMYRIAD2");
 
   // Append all -I, -iquote, -isystem paths, defines/undefines,
@@ -10441,7 +10440,8 @@
 options::OPT_std_EQ, options::OPT_D, 
options::OPT_U,
 options::OPT_f_Group, options::OPT_f_clang_Group,
 options::OPT_g_Group, options::OPT_M_Group,
-options::OPT_O_Group, options::OPT_W_Group});
+options::OPT_O_Group, options::OPT_W_Group,
+options::OPT_mcpu_EQ});
 
   // If we're producing a dependency file, and assembly is the final action,
   // then the name of the target in the dependency file should be the '.o'
@@ -10481,7 +10481,10 @@
   assert(Output.getType() == types::TY_Object);
 
   CmdArgs.push_back("-no6thSlotCompression");
-  CmdArgs.push_back("-cv:myriad2"); // Chip Version
+  const Arg *CPUArg = Args.getLastArg(options::OPT_mcpu_EQ);
+  if (CPUArg)
+CmdArgs.push_back(
+Args.MakeArgString("-cv:" + StringRef(CPUArg->getValue(;
   CmdArgs.push_back("-noSPrefixing");
   CmdArgs.push_back("-a"); // Mystery option.
   Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, 
options::OPT_Xassembler);


Index: cfe/trunk/test/Driver/myriad-toolchain.c
===
--- cfe/trunk/test/Driver/myriad-toolchain.c
+++ cfe/trunk/test/Driver/myriad-toolchain.c
@@ -36,10 +36,10 @@
 // As such, we test only for a trailing quote in its rendering.
 // The same goes for "moviAsm".
 
-// RUN: %clang -target shave-myriad -c -### %s -isystem somewhere -Icommon -Wa,-yippee 2>&1 \
+// RUN: %clang -target shave-myriad -mcpu=myriad1 -c -### %s -isystem somewhere -Icommon -Wa,-yippee 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MOVICOMPILE
-// MOVICOMPILE: moviCompile{{(.exe)?}}" "-S" "-fno-exceptions" "-mcpu=myriad2" "-DMYRIAD2" "-isystem" "somewhere" "-I" "common"
-// MOVICOMPILE: moviAsm{{(.exe)?}}" 

r263556 - Myriad: Pass -mcpu to movi{Compile,Asm}

2016-03-15 Thread Douglas Katzman via cfe-commits
Author: dougk
Date: Tue Mar 15 11:41:31 2016
New Revision: 263556

URL: http://llvm.org/viewvc/llvm-project?rev=263556=rev
Log:
Myriad: Pass -mcpu to movi{Compile,Asm}

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/myriad-toolchain.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=263556=263555=263556=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Mar 15 11:41:31 2016
@@ -10431,7 +10431,6 @@ void tools::SHAVE::Compiler::ConstructJo
 CmdArgs.push_back("-S");
 CmdArgs.push_back("-fno-exceptions"); // Always do this even if 
unspecified.
   }
-  CmdArgs.push_back("-mcpu=myriad2");
   CmdArgs.push_back("-DMYRIAD2");
 
   // Append all -I, -iquote, -isystem paths, defines/undefines,
@@ -10441,7 +10440,8 @@ void tools::SHAVE::Compiler::ConstructJo
 options::OPT_std_EQ, options::OPT_D, 
options::OPT_U,
 options::OPT_f_Group, options::OPT_f_clang_Group,
 options::OPT_g_Group, options::OPT_M_Group,
-options::OPT_O_Group, options::OPT_W_Group});
+options::OPT_O_Group, options::OPT_W_Group,
+options::OPT_mcpu_EQ});
 
   // If we're producing a dependency file, and assembly is the final action,
   // then the name of the target in the dependency file should be the '.o'
@@ -10481,7 +10481,10 @@ void tools::SHAVE::Assembler::ConstructJ
   assert(Output.getType() == types::TY_Object);
 
   CmdArgs.push_back("-no6thSlotCompression");
-  CmdArgs.push_back("-cv:myriad2"); // Chip Version
+  const Arg *CPUArg = Args.getLastArg(options::OPT_mcpu_EQ);
+  if (CPUArg)
+CmdArgs.push_back(
+Args.MakeArgString("-cv:" + StringRef(CPUArg->getValue(;
   CmdArgs.push_back("-noSPrefixing");
   CmdArgs.push_back("-a"); // Mystery option.
   Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, 
options::OPT_Xassembler);

Modified: cfe/trunk/test/Driver/myriad-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/myriad-toolchain.c?rev=263556=263555=263556=diff
==
--- cfe/trunk/test/Driver/myriad-toolchain.c (original)
+++ cfe/trunk/test/Driver/myriad-toolchain.c Tue Mar 15 11:41:31 2016
@@ -36,10 +36,10 @@
 // As such, we test only for a trailing quote in its rendering.
 // The same goes for "moviAsm".
 
-// RUN: %clang -target shave-myriad -c -### %s -isystem somewhere -Icommon 
-Wa,-yippee 2>&1 \
+// RUN: %clang -target shave-myriad -mcpu=myriad1 -c -### %s -isystem 
somewhere -Icommon -Wa,-yippee 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MOVICOMPILE
-// MOVICOMPILE: moviCompile{{(.exe)?}}" "-S" "-fno-exceptions" "-mcpu=myriad2" 
"-DMYRIAD2" "-isystem" "somewhere" "-I" "common"
-// MOVICOMPILE: moviAsm{{(.exe)?}}" "-no6thSlotCompression" "-cv:myriad2" 
"-noSPrefixing" "-a"
+// MOVICOMPILE: moviCompile{{(.exe)?}}" "-S" "-fno-exceptions" "-DMYRIAD2" 
"-mcpu=myriad1" "-isystem" "somewhere" "-I" "common"
+// MOVICOMPILE: moviAsm{{(.exe)?}}" "-no6thSlotCompression" "-cv:myriad1" 
"-noSPrefixing" "-a"
 // MOVICOMPILE: "-yippee" "-i:somewhere" "-i:common" "-elf"
 
 // RUN: %clang -target shave-myriad -c -### %s -DEFINE_ME -UNDEFINE_ME 2>&1 \
@@ -58,15 +58,15 @@
 
 // RUN: %clang -target shave-myriad -c %s -o foo.o -### -MD -MF dep.d 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MDMF
-// MDMF: "-S" "-fno-exceptions" "-mcpu=myriad2" "-DMYRIAD2" "-MD" "-MF" 
"dep.d" "-MT" "foo.o"
+// MDMF: "-S" "-fno-exceptions" "-DMYRIAD2" "-MD" "-MF" "dep.d" "-MT" "foo.o"
 
-// RUN: %clang -target shave-myriad -std=gnu++11 -S %s -o foo.o -### 2>&1 \
+// RUN: %clang -target shave-myriad -std=gnu++11 -mcpu=anothercpu -S %s -o 
foo.o -### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=STDEQ
-// STDEQ: "-S" "-fno-exceptions" "-mcpu=myriad2" "-DMYRIAD2" "-std=gnu++11"
+// STDEQ: "-S" "-fno-exceptions" "-DMYRIAD2" "-std=gnu++11" "-mcpu=anothercpu"
 
 // RUN: %clang -target shave-myriad -E -Ifoo %s -o foo.i -### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=PREPROCESS
-// PREPROCESS: "-E" "-mcpu=myriad2" "-DMYRIAD2" "-I" "foo"
+// PREPROCESS: "-E" "-DMYRIAD2" "-I" "foo"
 
 // RUN: %clang -target sparc-myriad -### --driver-mode=g++ %s 2>&1 | FileCheck 
%s --check-prefix=STDLIBCXX
 // STDLIBCXX: "-lstdc++" "-lc" "-lgcc"


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


r263555 - Reverted http://reviews.llvm.org/D17877 to fix tests.

2016-03-15 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Tue Mar 15 11:19:13 2016
New Revision: 263555

URL: http://llvm.org/viewvc/llvm-project?rev=263555=rev
Log:
Reverted http://reviews.llvm.org/D17877 to fix tests.


Removed:
cfe/trunk/test/OpenMP/nvptx_target_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

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=263555=263554=263555=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Mar 15 11:19:13 2016
@@ -4145,14 +4145,6 @@ void CGOpenMPRuntime::emitTargetOutlined
 CGF.EmitStmt(CS.getCapturedStmt());
   };
 
-  emitTargetOutlinedFunctionHelper(D, ParentName, OutlinedFn, OutlinedFnID,
-   IsOffloadEntry, CodeGen);
-}
-
-void CGOpenMPRuntime::emitTargetOutlinedFunctionHelper(
-const OMPExecutableDirective , StringRef ParentName,
-llvm::Function *, llvm::Constant *,
-bool IsOffloadEntry, const RegionCodeGenTy ) {
   // Create a unique name for the entry function using the source location
   // information of the current target region. The name will be something like:
   //
@@ -4174,8 +4166,6 @@ void CGOpenMPRuntime::emitTargetOutlined
<< llvm::format("_%x_", FileID) << ParentName << "_l" << Line;
   }
 
-  const CapturedStmt  = *cast(D.getAssociatedStmt());
-
   CodeGenFunction CGF(CGM, true);
   CGOpenMPTargetRegionInfo CGInfo(CS, CodeGen, EntryFnName);
   CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, );

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=263555=263554=263555=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Tue Mar 15 11:19:13 2016
@@ -49,31 +49,7 @@ class CodeGenModule;
 typedef llvm::function_ref RegionCodeGenTy;
 
 class CGOpenMPRuntime {
-protected:
   CodeGenModule 
-
-  /// \brief Creates offloading entry for the provided entry ID \a ID,
-  /// address \a Addr and size \a Size.
-  virtual void createOffloadEntry(llvm::Constant *ID, llvm::Constant *Addr,
-  uint64_t Size);
-
-  /// \brief Helper to emit outlined function for 'target' directive.
-  /// \param D Directive to emit.
-  /// \param ParentName Name of the function that encloses the target region.
-  /// \param OutlinedFn Outlined function value to be defined by this call.
-  /// \param OutlinedFnID Outlined function ID value to be defined by this 
call.
-  /// \param IsOffloadEntry True if the outlined function is an offload entry.
-  /// \param CodeGen Lambda codegen specific to an accelerator device.
-  /// An oulined function may not be an entry if, e.g. the if clause always
-  /// evaluates to false.
-  virtual void emitTargetOutlinedFunctionHelper(const OMPExecutableDirective 
,
-StringRef ParentName,
-llvm::Function *,
-llvm::Constant *,
-bool IsOffloadEntry,
-const RegionCodeGenTy 
);
-
-private:
   /// \brief Default const ident_t object used for initialization of all other
   /// ident_t objects.
   llvm::Constant *DefaultOpenMPPSource = nullptr;
@@ -291,6 +267,11 @@ private:
   /// compilation unit. The function that does the registration is returned.
   llvm::Function *createOffloadingBinaryDescriptorRegistration();
 
+  /// \brief Creates offloading entry for the provided entry ID \a ID,
+  /// address \a Addr and size \a Size.
+  void createOffloadEntry(llvm::Constant *ID, llvm::Constant *Addr,
+  uint64_t Size);
+
   /// \brief Creates all the offload entries in the current compilation unit
   /// along with the associated metadata.
   void createOffloadEntriesAndInfoMetadata();

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=263555=263554=263555=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Tue Mar 15 11:19:13 2016
@@ -18,326 +18,5 @@
 using namespace clang;
 using namespace CodeGen;
 
-/// \brief Get the GPU warp size.
-llvm::Value *CGOpenMPRuntimeNVPTX::getNVPTXWarpSize(CodeGenFunction ) {
-  CGBuilderTy  = CGF.Builder;
-  return Bld.CreateCall(
-  

Re: [PATCH] D18187: [libcxx] Remove localization tests for Russian month names

2016-03-15 Thread Jonas Hahnfeld via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL263554: [libcxx] Remove localization tests for Russian month 
names (authored by Hahnfeld).

Changed prior to commit:
  http://reviews.llvm.org/D18187?vs=50738=50742#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18187

Files:
  
libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp
  
libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp

Index: 
libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
===
--- 
libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
+++ 
libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
@@ -9,15 +9,8 @@
 
 // REQUIRES: locale.en_US.UTF-8
 // REQUIRES: locale.fr_FR.UTF-8
-// REQUIRES: locale.ru_RU.UTF-8
 // REQUIRES: locale.zh_CN.UTF-8
 
-// NOTE: debian and opensuse use bad locale data for ru_RU.UTF-8 abbreviated
-// months. This locale data was fixed in glibc 2.14.
-// Debian uses glibc 2.13 as of 20/11/2014
-// OpenSuse uses glibc 2.19 with old locale data as of 20/11/2014
-// XFAIL: debian, opensuse
-
 // 
 
 // class time_get_byname
@@ -79,16 +72,6 @@
 assert(err == std::ios_base::eofbit);
 }
 {
-const my_facet f(LOCALE_ru_RU_UTF_8, 1);
-const wchar_t in[] = L"\x438\x44E\x43D\x44F";
-err = std::ios_base::goodbit;
-t = std::tm();
-I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, 
err, );
-assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
-assert(t.tm_mon == 5);
-assert(err == std::ios_base::eofbit);
-}
-{
 const my_facet f(LOCALE_zh_CN_UTF_8, 1);
 const wchar_t in[] = L"\x516D\x6708";
 err = std::ios_base::goodbit;
Index: 
libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp
===
--- 
libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp
+++ 
libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp
@@ -9,15 +9,8 @@
 
 // REQUIRES: locale.en_US.UTF-8
 // REQUIRES: locale.fr_FR.UTF-8
-// REQUIRES: locale.ru_RU.UTF-8
 // REQUIRES: locale.zh_CN.UTF-8
 
-// NOTE: debian and opensuse use old locale data for ru_RU.UTF-8 abbreviated
-// months. This locale data was changed in glibc 2.14.
-// Debian uses glibc 2.13 as of 20/11/2014
-// OpenSuse uses glibc 2.19 with old locale data as of 20/11/2014
-// XFAIL: debian, opensuse
-
 // 
 
 // class time_get_byname
@@ -70,16 +63,6 @@
 assert(err == std::ios_base::eofbit);
 }
 {
-const my_facet f(LOCALE_ru_RU_UTF_8, 1);
-const char in[] = "\xD0\xB8\xD1\x8E\xD0\xBD\xD1\x8F";
-err = std::ios_base::goodbit;
-t = std::tm();
-I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, 
err, );
-assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
-assert(t.tm_mon == 5);
-assert(err == std::ios_base::eofbit);
-}
-{
 const my_facet f(LOCALE_zh_CN_UTF_8, 1);
 const char in[] = "\xE5\x85\xAD\xE6\x9C\x88";
 err = std::ios_base::goodbit;


Index: libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
===
--- libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
+++ libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
@@ -9,15 +9,8 @@
 
 // REQUIRES: locale.en_US.UTF-8
 // REQUIRES: locale.fr_FR.UTF-8
-// REQUIRES: locale.ru_RU.UTF-8
 // REQUIRES: locale.zh_CN.UTF-8
 
-// NOTE: debian and opensuse use bad locale data for ru_RU.UTF-8 abbreviated
-// months. This locale data was fixed in glibc 2.14.
-// Debian uses glibc 2.13 as of 20/11/2014
-// OpenSuse uses glibc 2.19 with old locale data as of 20/11/2014
-// XFAIL: debian, opensuse
-
 // 
 
 // class time_get_byname
@@ -79,16 +72,6 @@
 assert(err == std::ios_base::eofbit);
 }
 {
-const my_facet f(LOCALE_ru_RU_UTF_8, 1);
-const wchar_t in[] = L"\x438\x44E\x43D\x44F";
-err = std::ios_base::goodbit;
-t = std::tm();
-I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, );
-assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
-assert(t.tm_mon == 

[libcxx] r263554 - [libcxx] Remove localization tests for Russian month names

2016-03-15 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Tue Mar 15 10:55:58 2016
New Revision: 263554

URL: http://llvm.org/viewvc/llvm-project?rev=263554=rev
Log:
[libcxx] Remove localization tests for Russian month names

Commit f49839299a085505eb673544744b61d2d9cdd1db in glibc-2.14 changed the
locales to the currently required format. However, they were again changed in
commit 55bdd2866f23b28422d969060b3518909a12b100 which has been released in 2.17.

That leads to the current situation where Debian and e.g. CentOS 6 have the
pre-2.14 locales, for example Ubuntu 14.04 has pre-2.17 and CentOS 7 on the
other hand has the newest locales in glibc-2.17.

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

Modified:

libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp

Modified: 
libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp?rev=263554=263553=263554=diff
==
--- 
libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp
 Tue Mar 15 10:55:58 2016
@@ -9,15 +9,8 @@
 
 // REQUIRES: locale.en_US.UTF-8
 // REQUIRES: locale.fr_FR.UTF-8
-// REQUIRES: locale.ru_RU.UTF-8
 // REQUIRES: locale.zh_CN.UTF-8
 
-// NOTE: debian and opensuse use old locale data for ru_RU.UTF-8 abbreviated
-// months. This locale data was changed in glibc 2.14.
-// Debian uses glibc 2.13 as of 20/11/2014
-// OpenSuse uses glibc 2.19 with old locale data as of 20/11/2014
-// XFAIL: debian, opensuse
-
 // 
 
 // class time_get_byname
@@ -65,16 +58,6 @@ int main()
 err = std::ios_base::goodbit;
 t = std::tm();
 I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, 
err, );
-assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
-assert(t.tm_mon == 5);
-assert(err == std::ios_base::eofbit);
-}
-{
-const my_facet f(LOCALE_ru_RU_UTF_8, 1);
-const char in[] = "\xD0\xB8\xD1\x8E\xD0\xBD\xD1\x8F";
-err = std::ios_base::goodbit;
-t = std::tm();
-I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, 
err, );
 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
 assert(t.tm_mon == 5);
 assert(err == std::ios_base::eofbit);

Modified: 
libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp?rev=263554=263553=263554=diff
==
--- 
libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
 Tue Mar 15 10:55:58 2016
@@ -9,15 +9,8 @@
 
 // REQUIRES: locale.en_US.UTF-8
 // REQUIRES: locale.fr_FR.UTF-8
-// REQUIRES: locale.ru_RU.UTF-8
 // REQUIRES: locale.zh_CN.UTF-8
 
-// NOTE: debian and opensuse use bad locale data for ru_RU.UTF-8 abbreviated
-// months. This locale data was fixed in glibc 2.14.
-// Debian uses glibc 2.13 as of 20/11/2014
-// OpenSuse uses glibc 2.19 with old locale data as of 20/11/2014
-// XFAIL: debian, opensuse
-
 // 
 
 // class time_get_byname
@@ -74,16 +67,6 @@ int main()
 err = std::ios_base::goodbit;
 t = std::tm();
 I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, 
err, );
-assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
-assert(t.tm_mon == 5);
-assert(err == std::ios_base::eofbit);
-}
-{
-const my_facet f(LOCALE_ru_RU_UTF_8, 1);
-const wchar_t in[] = L"\x438\x44E\x43D\x44F";
-err = std::ios_base::goodbit;
-t = std::tm();
-I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, 
err, );
 assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
 assert(t.tm_mon == 5);
 assert(err == std::ios_base::eofbit);


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


Re: [PATCH] D18187: [libcxx] Remove localization tests for Russian month names

2016-03-15 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

It seems like we are not losing test coverage with these removals. And they 
have caused us a ton of pain.

I agree lets just get rid of them!

LGTM.


http://reviews.llvm.org/D18187



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


Re: [PATCH] D14286: ASTImporter: expressions, pt.1

2016-03-15 Thread Aleksei Sidorin via cfe-commits
a.sidorin updated this revision to Diff 50741.
a.sidorin added a comment.

An attempt to fix ParenListExpr test on Windows


http://reviews.llvm.org/D14286

Files:
  include/clang/AST/Type.h
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp
  unittests/AST/CMakeLists.txt

Index: unittests/AST/CMakeLists.txt
===
--- unittests/AST/CMakeLists.txt
+++ unittests/AST/CMakeLists.txt
@@ -4,6 +4,7 @@
 
 add_clang_unittest(ASTTests
   ASTContextParentMapTest.cpp
+  ASTImporterTest.cpp
   ASTTypeTraitsTest.cpp
   ASTVectorTest.cpp
   CommentLexer.cpp
Index: unittests/AST/ASTImporterTest.cpp
===
--- /dev/null
+++ unittests/AST/ASTImporterTest.cpp
@@ -0,0 +1,471 @@
+//===- unittest/AST/ASTImporterTest.cpp - AST node import test ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Tests for the correct import of AST nodes from one AST context to another.
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTImporter.h"
+#include "MatchVerifier.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace ast_matchers {
+
+using clang::tooling::newFrontendActionFactory;
+using clang::tooling::runToolOnCodeWithArgs;
+using clang::tooling::FrontendActionFactory;
+
+typedef std::vector StringVector;
+
+void getLangArgs(Language Lang, StringVector ) {
+  switch (Lang) {
+  case Lang_C:
+Args.insert(Args.end(), { "-x", "c", "-std=c99" });
+break;
+  case Lang_C89:
+Args.insert(Args.end(), { "-x", "c", "-std=c89" });
+break;
+  case Lang_CXX:
+Args.push_back("-std=c++98");
+break;
+  case Lang_CXX11:
+Args.push_back("-std=c++11");
+break;
+  case Lang_OpenCL:
+  case Lang_OBJCXX:
+break;
+  }
+}
+
+template
+testing::AssertionResult
+testImport(const std::string , Language FromLang,
+   const std::string , Language ToLang,
+   MatchVerifier ,
+   const MatcherType ) {
+  StringVector FromArgs, ToArgs;
+  getLangArgs(FromLang, FromArgs);
+  getLangArgs(ToLang, ToArgs);
+
+  const char * const InputFileName = "input.cc";
+  const char * const OutputFileName = "output.cc";
+
+  std::unique_ptr
+  FromAST = tooling::buildASTFromCodeWithArgs(
+FromCode, FromArgs, InputFileName),
+  ToAST = tooling::buildASTFromCodeWithArgs(ToCode, ToArgs, OutputFileName);
+
+  ASTContext  = FromAST->getASTContext(),
+   = ToAST->getASTContext();
+
+  // Add input.cc to virtual file system so importer can 'find' it
+  // while importing SourceLocations.
+  vfs::OverlayFileSystem *OFS = static_cast(
+ToCtx.getSourceManager().getFileManager().getVirtualFileSystem().get());
+  vfs::InMemoryFileSystem *MFS = static_cast(
+OFS->overlays_begin()->get());
+  MFS->addFile(InputFileName, 0,
+   llvm::MemoryBuffer::getMemBuffer(FromCode.c_str()));
+
+  ASTImporter Importer(ToCtx, ToAST->getFileManager(),
+   FromCtx, FromAST->getFileManager(), false);
+
+  IdentifierInfo *ImportedII = ("declToImport");
+  assert(ImportedII && "Declaration with 'declToImport' name"
+   "should be specified in test!");
+  DeclarationName ImportDeclName(ImportedII);
+  SmallVector FoundDecls;
+  FromCtx.getTranslationUnitDecl()->localUncachedLookup(
+ImportDeclName, FoundDecls);
+
+  if (FoundDecls.size() != 1)
+return testing::AssertionFailure() << "Multiple declarations were found!";
+
+  auto Imported = Importer.Import(*FoundDecls.begin());
+  if (!Imported)
+return testing::AssertionFailure() << "Import failed, nullptr returned!";
+
+  // This should dump source locations and assert if some source locations
+  // were not imported
+  SmallString<1024> ImportChecker;
+  llvm::raw_svector_ostream ToNothing(ImportChecker);
+  ToCtx.getTranslationUnitDecl()->print(ToNothing);
+
+  return Verifier.match(Imported, AMatcher);
+}
+
+TEST(ImportExpr, ImportStringLiteral) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(testImport("void declToImport() { \"foo\"; }",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ functionDecl(
+   hasBody(
+ compoundStmt(
+   has(
+ stringLiteral(
+   hasType(
+ asString("const char [4]");
+  EXPECT_TRUE(testImport("void declToImport() { L\"foo\"; }",
+ 

[PATCH] D18187: [libcxx] Remove localization tests for Russian month names

2016-03-15 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld created this revision.
Hahnfeld added a reviewer: EricWF.
Hahnfeld added a subscriber: cfe-commits.

Commit `f49839299a085505eb673544744b61d2d9cdd1db` in glibc-2.14 changed the 
locales to the currently required format. However, they were again changed in 
commit `55bdd2866f23b28422d969060b3518909a12b100` which has been released in 
2.17.

That leads to the current situation where Debian and e.g. CentOS 6 have the 
pre-2.14 locales, for example Ubuntu 14.04 has pre-2.17 and CentOS 7 on the 
other hand has the newest locales in glibc-2.17.

http://reviews.llvm.org/D18187

Files:
  
test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp
  
test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp

Index: 
test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
===
--- 
test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
+++ 
test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
@@ -9,15 +9,8 @@
 
 // REQUIRES: locale.en_US.UTF-8
 // REQUIRES: locale.fr_FR.UTF-8
-// REQUIRES: locale.ru_RU.UTF-8
 // REQUIRES: locale.zh_CN.UTF-8
 
-// NOTE: debian and opensuse use bad locale data for ru_RU.UTF-8 abbreviated
-// months. This locale data was fixed in glibc 2.14.
-// Debian uses glibc 2.13 as of 20/11/2014
-// OpenSuse uses glibc 2.19 with old locale data as of 20/11/2014
-// XFAIL: debian, opensuse
-
 // 
 
 // class time_get_byname
@@ -79,16 +72,6 @@
 assert(err == std::ios_base::eofbit);
 }
 {
-const my_facet f(LOCALE_ru_RU_UTF_8, 1);
-const wchar_t in[] = L"\x438\x44E\x43D\x44F";
-err = std::ios_base::goodbit;
-t = std::tm();
-I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, 
err, );
-assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
-assert(t.tm_mon == 5);
-assert(err == std::ios_base::eofbit);
-}
-{
 const my_facet f(LOCALE_zh_CN_UTF_8, 1);
 const wchar_t in[] = L"\x516D\x6708";
 err = std::ios_base::goodbit;
Index: 
test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp
===
--- 
test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp
+++ 
test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp
@@ -9,15 +9,8 @@
 
 // REQUIRES: locale.en_US.UTF-8
 // REQUIRES: locale.fr_FR.UTF-8
-// REQUIRES: locale.ru_RU.UTF-8
 // REQUIRES: locale.zh_CN.UTF-8
 
-// NOTE: debian and opensuse use old locale data for ru_RU.UTF-8 abbreviated
-// months. This locale data was changed in glibc 2.14.
-// Debian uses glibc 2.13 as of 20/11/2014
-// OpenSuse uses glibc 2.19 with old locale data as of 20/11/2014
-// XFAIL: debian, opensuse
-
 // 
 
 // class time_get_byname
@@ -70,16 +63,6 @@
 assert(err == std::ios_base::eofbit);
 }
 {
-const my_facet f(LOCALE_ru_RU_UTF_8, 1);
-const char in[] = "\xD0\xB8\xD1\x8E\xD0\xBD\xD1\x8F";
-err = std::ios_base::goodbit;
-t = std::tm();
-I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, 
err, );
-assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
-assert(t.tm_mon == 5);
-assert(err == std::ios_base::eofbit);
-}
-{
 const my_facet f(LOCALE_zh_CN_UTF_8, 1);
 const char in[] = "\xE5\x85\xAD\xE6\x9C\x88";
 err = std::ios_base::goodbit;


Index: test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
===
--- test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
+++ test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
@@ -9,15 +9,8 @@
 
 // REQUIRES: locale.en_US.UTF-8
 // REQUIRES: locale.fr_FR.UTF-8
-// REQUIRES: locale.ru_RU.UTF-8
 // REQUIRES: locale.zh_CN.UTF-8
 
-// NOTE: debian and opensuse use bad locale data for ru_RU.UTF-8 abbreviated
-// months. This locale data was fixed in glibc 2.14.
-// Debian uses glibc 2.13 as of 20/11/2014
-// OpenSuse uses glibc 2.19 with old locale data as of 20/11/2014
-// XFAIL: debian, opensuse
-
 // 
 
 // class time_get_byname
@@ -79,16 +72,6 @@
 assert(err == std::ios_base::eofbit);
 }
 {
-const my_facet f(LOCALE_ru_RU_UTF_8, 1);
-const wchar_t in[] = L"\x438\x44E\x43D\x44F";
-err = std::ios_base::goodbit;
-t = std::tm();
-I i = f.get_monthname(I(in), 

Re: [PATCH] D18186: Myriad: pass -mcpu flag to moviCompile, no default

2016-03-15 Thread Douglas Katzman via cfe-commits
dougk updated this revision to Diff 50739.
dougk added a comment.

also moviAsm


http://reviews.llvm.org/D18186

Files:
  lib/Driver/Tools.cpp
  test/Driver/myriad-toolchain.c

Index: test/Driver/myriad-toolchain.c
===
--- test/Driver/myriad-toolchain.c
+++ test/Driver/myriad-toolchain.c
@@ -36,10 +36,10 @@
 // As such, we test only for a trailing quote in its rendering.
 // The same goes for "moviAsm".
 
-// RUN: %clang -target shave-myriad -c -### %s -isystem somewhere -Icommon 
-Wa,-yippee 2>&1 \
+// RUN: %clang -target shave-myriad -mcpu=myriad1 -c -### %s -isystem 
somewhere -Icommon -Wa,-yippee 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MOVICOMPILE
-// MOVICOMPILE: moviCompile{{(.exe)?}}" "-S" "-fno-exceptions" "-mcpu=myriad2" 
"-DMYRIAD2" "-isystem" "somewhere" "-I" "common"
-// MOVICOMPILE: moviAsm{{(.exe)?}}" "-no6thSlotCompression" "-cv:myriad2" 
"-noSPrefixing" "-a"
+// MOVICOMPILE: moviCompile{{(.exe)?}}" "-S" "-fno-exceptions" "-DMYRIAD2" 
"-mcpu=myriad1" "-isystem" "somewhere" "-I" "common"
+// MOVICOMPILE: moviAsm{{(.exe)?}}" "-no6thSlotCompression" "-cv:myriad1" 
"-noSPrefixing" "-a"
 // MOVICOMPILE: "-yippee" "-i:somewhere" "-i:common" "-elf"
 
 // RUN: %clang -target shave-myriad -c -### %s -DEFINE_ME -UNDEFINE_ME 2>&1 \
@@ -58,15 +58,15 @@
 
 // RUN: %clang -target shave-myriad -c %s -o foo.o -### -MD -MF dep.d 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MDMF
-// MDMF: "-S" "-fno-exceptions" "-mcpu=myriad2" "-DMYRIAD2" "-MD" "-MF" 
"dep.d" "-MT" "foo.o"
+// MDMF: "-S" "-fno-exceptions" "-DMYRIAD2" "-MD" "-MF" "dep.d" "-MT" "foo.o"
 
-// RUN: %clang -target shave-myriad -std=gnu++11 -S %s -o foo.o -### 2>&1 \
+// RUN: %clang -target shave-myriad -std=gnu++11 -mcpu=anothercpu -S %s -o 
foo.o -### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=STDEQ
-// STDEQ: "-S" "-fno-exceptions" "-mcpu=myriad2" "-DMYRIAD2" "-std=gnu++11"
+// STDEQ: "-S" "-fno-exceptions" "-DMYRIAD2" "-std=gnu++11" "-mcpu=anothercpu"
 
 // RUN: %clang -target shave-myriad -E -Ifoo %s -o foo.i -### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=PREPROCESS
-// PREPROCESS: "-E" "-mcpu=myriad2" "-DMYRIAD2" "-I" "foo"
+// PREPROCESS: "-E" "-DMYRIAD2" "-I" "foo"
 
 // RUN: %clang -target sparc-myriad -### --driver-mode=g++ %s 2>&1 | FileCheck 
%s --check-prefix=STDLIBCXX
 // STDLIBCXX: "-lstdc++" "-lc" "-lgcc"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -10431,7 +10431,6 @@
 CmdArgs.push_back("-S");
 CmdArgs.push_back("-fno-exceptions"); // Always do this even if 
unspecified.
   }
-  CmdArgs.push_back("-mcpu=myriad2");
   CmdArgs.push_back("-DMYRIAD2");
 
   // Append all -I, -iquote, -isystem paths, defines/undefines,
@@ -10441,7 +10440,8 @@
 options::OPT_std_EQ, options::OPT_D, 
options::OPT_U,
 options::OPT_f_Group, options::OPT_f_clang_Group,
 options::OPT_g_Group, options::OPT_M_Group,
-options::OPT_O_Group, options::OPT_W_Group});
+options::OPT_O_Group, options::OPT_W_Group,
+options::OPT_mcpu_EQ});
 
   // If we're producing a dependency file, and assembly is the final action,
   // then the name of the target in the dependency file should be the '.o'
@@ -10481,7 +10481,10 @@
   assert(Output.getType() == types::TY_Object);
 
   CmdArgs.push_back("-no6thSlotCompression");
-  CmdArgs.push_back("-cv:myriad2"); // Chip Version
+  const Arg *CPUArg = Args.getLastArg(options::OPT_mcpu_EQ);
+  if (CPUArg)
+CmdArgs.push_back(
+Args.MakeArgString("-cv:" + StringRef(CPUArg->getValue(;
   CmdArgs.push_back("-noSPrefixing");
   CmdArgs.push_back("-a"); // Mystery option.
   Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, 
options::OPT_Xassembler);


Index: test/Driver/myriad-toolchain.c
===
--- test/Driver/myriad-toolchain.c
+++ test/Driver/myriad-toolchain.c
@@ -36,10 +36,10 @@
 // As such, we test only for a trailing quote in its rendering.
 // The same goes for "moviAsm".
 
-// RUN: %clang -target shave-myriad -c -### %s -isystem somewhere -Icommon -Wa,-yippee 2>&1 \
+// RUN: %clang -target shave-myriad -mcpu=myriad1 -c -### %s -isystem somewhere -Icommon -Wa,-yippee 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MOVICOMPILE
-// MOVICOMPILE: moviCompile{{(.exe)?}}" "-S" "-fno-exceptions" "-mcpu=myriad2" "-DMYRIAD2" "-isystem" "somewhere" "-I" "common"
-// MOVICOMPILE: moviAsm{{(.exe)?}}" "-no6thSlotCompression" "-cv:myriad2" "-noSPrefixing" "-a"
+// MOVICOMPILE: moviCompile{{(.exe)?}}" "-S" "-fno-exceptions" "-DMYRIAD2" "-mcpu=myriad1" "-isystem" "somewhere" "-I" "common"
+// MOVICOMPILE: moviAsm{{(.exe)?}}" "-no6thSlotCompression" "-cv:myriad1" "-noSPrefixing" "-a"
 // MOVICOMPILE: "-yippee" 

Re: [PATCH] D17877: [OpenMP] Base support for target directive codegen on NVPTX device.

2016-03-15 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL263552: [OpenMP] Base support for target directive codegen 
on NVPTX device. (authored by arpith).

Changed prior to commit:
  http://reviews.llvm.org/D17877?vs=50143=50737#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17877

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/test/OpenMP/nvptx_target_codegen.cpp

Index: cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp
===
--- cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp
+++ cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp
@@ -0,0 +1,587 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fomptargets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fomptargets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fomp-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 -fomptargets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -fomptargets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fomp-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-DAG: [[OMP_NT:@.+]] = common addrspace(3) global i32 0
+// CHECK-DAG: [[OMP_WID:@.+]] = common addrspace(3) global i64 0
+
+template
+struct TT{
+  tx X;
+  ty Y;
+};
+
+int foo(int n) {
+  int a = 0;
+  short aa = 0;
+  float b[10];
+  float bn[n];
+  double c[5][10];
+  double cn[5][n];
+  TT d;
+
+  // CHECK: define {{.*}}void [[T1:@__omp_offloading_.+foo.+]]_worker()
+  // CHECK: br label {{%?}}[[AWAIT_WORK:.+]]
+  //
+  // CHECK: [[AWAIT_WORK]]
+  // CHECK-NEXT: call void @llvm.nvvm.barrier0()
+  // CHECK-NEXT: [[WORK:%.+]] = load i64, i64 addrspace(3)* [[OMP_WID]],
+  // CHECK-NEXT: [[SHOULD_EXIT:%.+]] = icmp eq i64 [[WORK]], 0
+  // CHECK-NEXT: br i1 [[SHOULD_EXIT]], label {{%?}}[[EXIT:.+]], label {{%?}}[[SEL_WORKERS:.+]]
+  //
+  // CHECK: [[SEL_WORKERS]]
+  // CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-NEXT: [[NT:%.+]] = load i32, i32 addrspace(3)* [[OMP_NT]]
+  // CHECK-NEXT: [[IS_ACTIVE:%.+]] = icmp slt i32 [[TID]], [[NT]]
+  // CHECK-NEXT: br i1 [[IS_ACTIVE]], label {{%?}}[[EXEC_PARALLEL:.+]], label {{%?}}[[BAR_PARALLEL:.+]]
+  //
+  // CHECK: [[EXEC_PARALLEL]]
+  // CHECK-NEXT: br label {{%?}}[[TERM_PARALLEL:.+]]
+  //
+  // CHECK: [[TERM_PARALLEL]]
+  // CHECK-NEXT: br label {{%?}}[[BAR_PARALLEL]]
+  //
+  // CHECK: [[BAR_PARALLEL]]
+  // CHECK-NEXT: call void @llvm.nvvm.barrier0()
+  // CHECK-NEXT: br label {{%?}}[[AWAIT_WORK]]
+  //
+  // CHECK: [[EXIT]]
+  // CHECK-NEXT: ret void
+
+  // CHECK: define {{.*}}void [[T1]]()
+  // CHECK: [[NTID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
+  // CHECK-NEXT: [[WS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
+  // CHECK-NEXT: [[A:%.+]] = sub i32 [[WS]], 1
+  // CHECK-NEXT: [[B:%.+]] = sub i32 [[NTID]], 1
+  // CHECK-NEXT: [[C:%.+]] = xor i32 [[A]], -1
+  // CHECK-NEXT: [[MID:%.+]] = and i32 [[B]], [[C]]
+  // CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-NEXT: [[EXCESS:%.+]] = icmp ugt i32 [[TID]], [[MID]]
+  // CHECK-NEXT: br i1 [[EXCESS]], label {{%?}}[[EXIT:.+]], label {{%?}}[[CHECK_WORKER:.+]]
+  //
+  // CHECK: [[CHECK_WORKER]]
+  // CHECK-NEXT: [[IS_WORKER:%.+]] = icmp ult i32 [[TID]], [[MID]]
+  // CHECK-NEXT: br i1 [[IS_WORKER]], label {{%?}}[[WORKER:.+]], label {{%?}}[[MASTER:.+]]
+  //
+  // CHECK: [[WORKER]]
+  // CHECK-NEXT: call void [[T1]]_worker()
+  // CHECK-NEXT: br label {{%?}}[[EXIT]]
+  //
+  // CHECK: [[MASTER]]
+  // CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-NEXT: call void @__kmpc_kernel_init(i32 0, i32 [[TID]])
+  // CHECK-NEXT: br label {{%?}}[[TERM:.+]]
+  //
+  // CHECK: [[TERM]]
+  // CHECK-NEXT: store i64 0, i64 addrspace(3)* [[OMP_WID]],
+  // CHECK-NEXT: call void @llvm.nvvm.barrier0()
+  // CHECK-NEXT: br label {{%?}}[[EXIT]]
+  //
+  // CHECK: [[EXIT]]
+  // CHECK-NEXT: ret void
+  #pragma omp target
+  {
+  }
+
+  // CHECK-NOT: define {{.*}}void [[T2:@__omp_offloading_.+foo.+]]_worker()
+  #pragma omp target if(0)
+  {
+  }
+
+  // CHECK: define {{.*}}void [[T3:@__omp_offloading_.+foo.+]]_worker()
+  // CHECK: br label {{%?}}[[AWAIT_WORK:.+]]
+  //
+  // CHECK: [[AWAIT_WORK]]
+  // CHECK-NEXT: call void @llvm.nvvm.barrier0()
+  // CHECK-NEXT: [[WORK:%.+]] = load i64, i64 addrspace(3)* [[OMP_WID]],
+  // 

r263552 - [OpenMP] Base support for target directive codegen on NVPTX device.

2016-03-15 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Tue Mar 15 10:24:52 2016
New Revision: 263552

URL: http://llvm.org/viewvc/llvm-project?rev=263552=rev
Log:
[OpenMP] Base support for target directive codegen on NVPTX device.

Summary:
This patch adds base support for codegen of the target directive on the NVPTX 
device.

Reviewers: ABataev

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


Added:
cfe/trunk/test/OpenMP/nvptx_target_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

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=263552=263551=263552=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Mar 15 10:24:52 2016
@@ -4145,6 +4145,14 @@ void CGOpenMPRuntime::emitTargetOutlined
 CGF.EmitStmt(CS.getCapturedStmt());
   };
 
+  emitTargetOutlinedFunctionHelper(D, ParentName, OutlinedFn, OutlinedFnID,
+   IsOffloadEntry, CodeGen);
+}
+
+void CGOpenMPRuntime::emitTargetOutlinedFunctionHelper(
+const OMPExecutableDirective , StringRef ParentName,
+llvm::Function *, llvm::Constant *,
+bool IsOffloadEntry, const RegionCodeGenTy ) {
   // Create a unique name for the entry function using the source location
   // information of the current target region. The name will be something like:
   //
@@ -4166,6 +4174,8 @@ void CGOpenMPRuntime::emitTargetOutlined
<< llvm::format("_%x_", FileID) << ParentName << "_l" << Line;
   }
 
+  const CapturedStmt  = *cast(D.getAssociatedStmt());
+
   CodeGenFunction CGF(CGM, true);
   CGOpenMPTargetRegionInfo CGInfo(CS, CodeGen, EntryFnName);
   CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, );

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=263552=263551=263552=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Tue Mar 15 10:24:52 2016
@@ -49,7 +49,31 @@ class CodeGenModule;
 typedef llvm::function_ref RegionCodeGenTy;
 
 class CGOpenMPRuntime {
+protected:
   CodeGenModule 
+
+  /// \brief Creates offloading entry for the provided entry ID \a ID,
+  /// address \a Addr and size \a Size.
+  virtual void createOffloadEntry(llvm::Constant *ID, llvm::Constant *Addr,
+  uint64_t Size);
+
+  /// \brief Helper to emit outlined function for 'target' directive.
+  /// \param D Directive to emit.
+  /// \param ParentName Name of the function that encloses the target region.
+  /// \param OutlinedFn Outlined function value to be defined by this call.
+  /// \param OutlinedFnID Outlined function ID value to be defined by this 
call.
+  /// \param IsOffloadEntry True if the outlined function is an offload entry.
+  /// \param CodeGen Lambda codegen specific to an accelerator device.
+  /// An oulined function may not be an entry if, e.g. the if clause always
+  /// evaluates to false.
+  virtual void emitTargetOutlinedFunctionHelper(const OMPExecutableDirective 
,
+StringRef ParentName,
+llvm::Function *,
+llvm::Constant *,
+bool IsOffloadEntry,
+const RegionCodeGenTy 
);
+
+private:
   /// \brief Default const ident_t object used for initialization of all other
   /// ident_t objects.
   llvm::Constant *DefaultOpenMPPSource = nullptr;
@@ -267,11 +291,6 @@ class CGOpenMPRuntime {
   /// compilation unit. The function that does the registration is returned.
   llvm::Function *createOffloadingBinaryDescriptorRegistration();
 
-  /// \brief Creates offloading entry for the provided entry ID \a ID,
-  /// address \a Addr and size \a Size.
-  void createOffloadEntry(llvm::Constant *ID, llvm::Constant *Addr,
-  uint64_t Size);
-
   /// \brief Creates all the offload entries in the current compilation unit
   /// along with the associated metadata.
   void createOffloadEntriesAndInfoMetadata();

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=263552=263551=263552=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Tue Mar 15 10:24:52 2016
@@ -18,5 +18,326 @@
 using namespace clang;
 using 

[PATCH] D18186: Myriad: pass -mcpu flag to moviCompile, no default

2016-03-15 Thread Douglas Katzman via cfe-commits
dougk created this revision.
dougk added a reviewer: jyknight.
dougk added a subscriber: cfe-commits.

http://reviews.llvm.org/D18186

Files:
  lib/Driver/Tools.cpp
  test/Driver/myriad-toolchain.c

Index: test/Driver/myriad-toolchain.c
===
--- test/Driver/myriad-toolchain.c
+++ test/Driver/myriad-toolchain.c
@@ -38,7 +38,7 @@
 
 // RUN: %clang -target shave-myriad -c -### %s -isystem somewhere -Icommon 
-Wa,-yippee 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MOVICOMPILE
-// MOVICOMPILE: moviCompile{{(.exe)?}}" "-S" "-fno-exceptions" "-mcpu=myriad2" 
"-DMYRIAD2" "-isystem" "somewhere" "-I" "common"
+// MOVICOMPILE: moviCompile{{(.exe)?}}" "-S" "-fno-exceptions" "-DMYRIAD2" 
"-isystem" "somewhere" "-I" "common"
 // MOVICOMPILE: moviAsm{{(.exe)?}}" "-no6thSlotCompression" "-cv:myriad2" 
"-noSPrefixing" "-a"
 // MOVICOMPILE: "-yippee" "-i:somewhere" "-i:common" "-elf"
 
@@ -58,15 +58,15 @@
 
 // RUN: %clang -target shave-myriad -c %s -o foo.o -### -MD -MF dep.d 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MDMF
-// MDMF: "-S" "-fno-exceptions" "-mcpu=myriad2" "-DMYRIAD2" "-MD" "-MF" 
"dep.d" "-MT" "foo.o"
+// MDMF: "-S" "-fno-exceptions" "-DMYRIAD2" "-MD" "-MF" "dep.d" "-MT" "foo.o"
 
-// RUN: %clang -target shave-myriad -std=gnu++11 -S %s -o foo.o -### 2>&1 \
+// RUN: %clang -target shave-myriad -std=gnu++11 -mcpu=acpu -S %s -o foo.o 
-### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=STDEQ
-// STDEQ: "-S" "-fno-exceptions" "-mcpu=myriad2" "-DMYRIAD2" "-std=gnu++11"
+// STDEQ: "-S" "-fno-exceptions" "-DMYRIAD2" "-std=gnu++11" "-mcpu=acpu"
 
 // RUN: %clang -target shave-myriad -E -Ifoo %s -o foo.i -### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=PREPROCESS
-// PREPROCESS: "-E" "-mcpu=myriad2" "-DMYRIAD2" "-I" "foo"
+// PREPROCESS: "-E" "-DMYRIAD2" "-I" "foo"
 
 // RUN: %clang -target sparc-myriad -### --driver-mode=g++ %s 2>&1 | FileCheck 
%s --check-prefix=STDLIBCXX
 // STDLIBCXX: "-lstdc++" "-lc" "-lgcc"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -10431,7 +10431,6 @@
 CmdArgs.push_back("-S");
 CmdArgs.push_back("-fno-exceptions"); // Always do this even if 
unspecified.
   }
-  CmdArgs.push_back("-mcpu=myriad2");
   CmdArgs.push_back("-DMYRIAD2");
 
   // Append all -I, -iquote, -isystem paths, defines/undefines,
@@ -10441,7 +10440,8 @@
 options::OPT_std_EQ, options::OPT_D, 
options::OPT_U,
 options::OPT_f_Group, options::OPT_f_clang_Group,
 options::OPT_g_Group, options::OPT_M_Group,
-options::OPT_O_Group, options::OPT_W_Group});
+options::OPT_O_Group, options::OPT_W_Group,
+options::OPT_mcpu_EQ});
 
   // If we're producing a dependency file, and assembly is the final action,
   // then the name of the target in the dependency file should be the '.o'


Index: test/Driver/myriad-toolchain.c
===
--- test/Driver/myriad-toolchain.c
+++ test/Driver/myriad-toolchain.c
@@ -38,7 +38,7 @@
 
 // RUN: %clang -target shave-myriad -c -### %s -isystem somewhere -Icommon -Wa,-yippee 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MOVICOMPILE
-// MOVICOMPILE: moviCompile{{(.exe)?}}" "-S" "-fno-exceptions" "-mcpu=myriad2" "-DMYRIAD2" "-isystem" "somewhere" "-I" "common"
+// MOVICOMPILE: moviCompile{{(.exe)?}}" "-S" "-fno-exceptions" "-DMYRIAD2" "-isystem" "somewhere" "-I" "common"
 // MOVICOMPILE: moviAsm{{(.exe)?}}" "-no6thSlotCompression" "-cv:myriad2" "-noSPrefixing" "-a"
 // MOVICOMPILE: "-yippee" "-i:somewhere" "-i:common" "-elf"
 
@@ -58,15 +58,15 @@
 
 // RUN: %clang -target shave-myriad -c %s -o foo.o -### -MD -MF dep.d 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MDMF
-// MDMF: "-S" "-fno-exceptions" "-mcpu=myriad2" "-DMYRIAD2" "-MD" "-MF" "dep.d" "-MT" "foo.o"
+// MDMF: "-S" "-fno-exceptions" "-DMYRIAD2" "-MD" "-MF" "dep.d" "-MT" "foo.o"
 
-// RUN: %clang -target shave-myriad -std=gnu++11 -S %s -o foo.o -### 2>&1 \
+// RUN: %clang -target shave-myriad -std=gnu++11 -mcpu=acpu -S %s -o foo.o -### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=STDEQ
-// STDEQ: "-S" "-fno-exceptions" "-mcpu=myriad2" "-DMYRIAD2" "-std=gnu++11"
+// STDEQ: "-S" "-fno-exceptions" "-DMYRIAD2" "-std=gnu++11" "-mcpu=acpu"
 
 // RUN: %clang -target shave-myriad -E -Ifoo %s -o foo.i -### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=PREPROCESS
-// PREPROCESS: "-E" "-mcpu=myriad2" "-DMYRIAD2" "-I" "foo"
+// PREPROCESS: "-E" "-DMYRIAD2" "-I" "foo"
 
 // RUN: %clang -target sparc-myriad -### --driver-mode=g++ %s 2>&1 | FileCheck %s --check-prefix=STDLIBCXX
 // STDLIBCXX: "-lstdc++" "-lc" "-lgcc"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ 

Re: [PATCH] D18149: Add check for unneeded copies of locals

2016-03-15 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Thank you for the patch! Looks mostly good, a few style nits.



Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.cpp:21
@@ -20,2 +20,3 @@
 using namespace ::clang::ast_matchers;
+using clang::tidy::decl_ref_expr_utils::isOnlyUsedAsConst;
 

No need for clang::tidy:: here.


Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.cpp:43
@@ +42,3 @@
+  auto localVarCopiedFrom = [](
+  const ast_matchers::internal::Matcher& CopyCtorArg) {
+return compoundStmt(

I guess, there's no need for ast_matchers:: here.


Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.cpp:127
@@ +126,3 @@
+  auto Diagnostic = diag(NewVar.getLocation(),
+ "local copy %0 of the variable %1 is never modified, "
+ "consider avoiding the copy")

nit: I'd use a semicolon instead of the comma here, like in other clang-tidy 
messages. 


Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.h:29
@@ -28,3 +28,3 @@
 public:
-  UnnecessaryCopyInitialization(StringRef Name, ClangTidyContext *Context)
+  UnnecessaryCopyInitialization(StringRef Name, ClangTidyContext* Context)
   : ClangTidyCheck(Name, Context) {}

LLVM style is to put *'s and &'s to the variable. Looks like your clang-format 
didn't understand it should use LLVM style. You might want to explicitly 
specify `-style=llvm` next time.


http://reviews.llvm.org/D18149



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


Re: [PATCH] D18149: Add check for unneeded copies of locals

2016-03-15 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Please always add 'cfe-commits' to Subscribers when you send a patch for review 
(I've added it now).

Substantial comments later.


http://reviews.llvm.org/D18149



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


[PATCH] D18182: [test] Don't use UNSUPPORTED in FileCheck prefixes

2016-03-15 Thread Greg Parker via cfe-commits
gparker42 created this revision.
gparker42 added a reviewer: rjmccall.
gparker42 added a subscriber: cfe-commits.

lit uses "UNSUPPORTED" for its own purposes and may be confused if that text 
appears elsewhere in the test file. 

http://reviews.llvm.org/D18182

Files:
  test/Driver/arc.c
  test/Driver/objc-weak.m

Index: test/Driver/objc-weak.m
===
--- test/Driver/objc-weak.m
+++ test/Driver/objc-weak.m
@@ -10,9 +10,9 @@
 // ARC-NO-WEAK: -fobjc-arc
 // ARC-NO-WEAK: -fno-objc-weak
 
-// RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min=10.5 -S -### 
%s -fobjc-arc -fobjc-weak 2>&1 | FileCheck %s --check-prefix 
ARC-WEAK-UNSUPPORTED
-// RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min=10.5 -S -### 
%s -fno-objc-weak -fobjc-weak -fobjc-arc  2>&1 | FileCheck %s --check-prefix 
ARC-WEAK-UNSUPPORTED
-// ARC-WEAK-UNSUPPORTED: error: -fobjc-weak is not supported on the current 
deployment target
+// RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min=10.5 -S -### 
%s -fobjc-arc -fobjc-weak 2>&1 | FileCheck %s --check-prefix 
ARC-WEAK-NOTSUPPORTED
+// RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min=10.5 -S -### 
%s -fno-objc-weak -fobjc-weak -fobjc-arc  2>&1 | FileCheck %s --check-prefix 
ARC-WEAK-NOTSUPPORTED
+// ARC-WEAK-NOTSUPPORTED: error: -fobjc-weak is not supported on the current 
deployment target
 
 // RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min=10.7 -S -### 
%s -fobjc-weak 2>&1 | FileCheck %s --check-prefix MRC-WEAK
 // RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min=10.7 -S -### 
%s -fno-objc-weak -fobjc-weak 2>&1 | FileCheck %s --check-prefix MRC-WEAK
@@ -22,6 +22,6 @@
 // RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min=10.7 -S -### 
%s -fobjc-weak -fno-objc-weak 2>&1 | FileCheck %s --check-prefix MRC-NO-WEAK
 // MRC-NO-WEAK: -fno-objc-weak
 
-// RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min=10.5 -S -### 
%s -fobjc-weak 2>&1 | FileCheck %s --check-prefix MRC-WEAK-UNSUPPORTED
-// RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min=10.5 -S -### 
%s -fno-objc-weak -fobjc-weak 2>&1 | FileCheck %s --check-prefix 
MRC-WEAK-UNSUPPORTED
-// MRC-WEAK-UNSUPPORTED: error: -fobjc-weak is not supported on the current 
deployment target
+// RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min=10.5 -S -### 
%s -fobjc-weak 2>&1 | FileCheck %s --check-prefix MRC-WEAK-NOTSUPPORTED
+// RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min=10.5 -S -### 
%s -fno-objc-weak -fobjc-weak 2>&1 | FileCheck %s --check-prefix 
MRC-WEAK-NOTSUPPORTED
+// MRC-WEAK-NOTSUPPORTED: error: -fobjc-weak is not supported on the current 
deployment target
Index: test/Driver/arc.c
===
--- test/Driver/arc.c
+++ test/Driver/arc.c
@@ -3,7 +3,7 @@
 // RUN: not %clang -x objective-c++ -target i386-apple-darwin10 -m32 
-fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
 // RUN: not %clang -x c -target i386-apple-darwin10 -m32 -fobjc-arc %s 
-fsyntax-only 2>&1 | FileCheck -check-prefix NOTOBJC %s
 // RUN: not %clang -x c++ -target i386-apple-darwin10 -m32 -fobjc-arc %s 
-fsyntax-only 2>&1 | FileCheck -check-prefix NOTOBJC %s
-// RUN: not %clang -x objective-c -target x86_64-apple-darwin11 
-mmacosx-version-min=10.5 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck 
-check-prefix UNSUPPORTED %s
+// RUN: not %clang -x objective-c -target x86_64-apple-darwin11 
-mmacosx-version-min=10.5 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck 
-check-prefix NOTSUPPORTED %s
 
 // Just to test clang is working.
 # foo
@@ -14,4 +14,4 @@
 // NOTOBJC-NOT: error: -fobjc-arc is not supported on platforms using the 
legacy runtime
 // NOTOBJC: invalid preprocessing directive
 
-// UNSUPPORTED: error: -fobjc-arc is not supported on versions of OS X prior 
to 10.6
+// NOTSUPPORTED: error: -fobjc-arc is not supported on versions of OS X prior 
to 10.6


Index: test/Driver/objc-weak.m
===
--- test/Driver/objc-weak.m
+++ test/Driver/objc-weak.m
@@ -10,9 +10,9 @@
 // ARC-NO-WEAK: -fobjc-arc
 // ARC-NO-WEAK: -fno-objc-weak
 
-// RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min=10.5 -S -### %s -fobjc-arc -fobjc-weak 2>&1 | FileCheck %s --check-prefix ARC-WEAK-UNSUPPORTED
-// RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min=10.5 -S -### %s -fno-objc-weak -fobjc-weak -fobjc-arc  2>&1 | FileCheck %s --check-prefix ARC-WEAK-UNSUPPORTED
-// ARC-WEAK-UNSUPPORTED: error: -fobjc-weak is not supported on the current deployment target
+// RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min=10.5 -S -### %s -fobjc-arc -fobjc-weak 2>&1 | FileCheck %s --check-prefix ARC-WEAK-NOTSUPPORTED
+// RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min=10.5 -S -### %s -fno-objc-weak -fobjc-weak -fobjc-arc  2>&1 | FileCheck %s --check-prefix 

Re: [PATCH] D15729: Load compiler plugins in ASTUnit, too

2016-03-15 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.

This looks good, thanks for the patch. When this goes in please watch the 
windows buildbots as plugin support on windows is somewhat broken and we may 
have to disable tests there.

Also, while this is a strict improvement and should go in I'm not so sure that 
it solves the "plugins in libclang" issue. I couldn't get it to work even with 
this patch due to the way we build libclang in Release mode.


http://reviews.llvm.org/D15729



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


Re: [PATCH] D15729: Load compiler plugins in ASTUnit, too

2016-03-15 Thread Kevin Funk via cfe-commits
kfunk updated this revision to Diff 50720.
kfunk added a comment.

Remove unrelated hunk


http://reviews.llvm.org/D15729

Files:
  include/clang/Frontend/CompilerInstance.h
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  unittests/Frontend/CMakeLists.txt
  unittests/Frontend/FrontendActionTest.cpp
  unittests/Frontend/PrintFunctionNamesTestPlugin/CMakeLists.txt
  
unittests/Frontend/PrintFunctionNamesTestPlugin/PrintFunctionNamesTestPlugin.cpp

Index: unittests/Frontend/PrintFunctionNamesTestPlugin/PrintFunctionNamesTestPlugin.cpp
===
--- /dev/null
+++ unittests/Frontend/PrintFunctionNamesTestPlugin/PrintFunctionNamesTestPlugin.cpp
@@ -0,0 +1,123 @@
+//===- PrintFunctionNames.cpp -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Example clang plugin which simply prints the names of all the top-level decls
+// in the input file.
+//
+//===--===//
+
+#include "clang/Frontend/FrontendPluginRegistry.h"
+#include "clang/AST/AST.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Sema/Sema.h"
+#include "llvm/Support/raw_ostream.h"
+using namespace clang;
+
+namespace {
+
+class PrintFunctionsConsumer : public ASTConsumer {
+  CompilerInstance 
+  std::set ParsedTemplates;
+
+public:
+  PrintFunctionsConsumer(CompilerInstance ,
+ std::set ParsedTemplates)
+  : Instance(Instance), ParsedTemplates(ParsedTemplates) {}
+
+  bool HandleTopLevelDecl(DeclGroupRef DG) override {
+for (DeclGroupRef::iterator i = DG.begin(), e = DG.end(); i != e; ++i) {
+  const Decl *D = *i;
+  if (const NamedDecl *ND = dyn_cast(D))
+llvm::errs() << "top-level-decl: \"" << ND->getNameAsString() << "\"\n";
+}
+
+return true;
+  }
+
+  void HandleTranslationUnit(ASTContext& context) override {
+if (!Instance.getLangOpts().DelayedTemplateParsing)
+  return;
+
+// This demonstrates how to force instantiation of some templates in
+// -fdelayed-template-parsing mode. (Note: Doing this unconditionally for
+// all templates is similar to not using -fdelayed-template-parsig in the
+// first place.)
+// The advantage of doing this in HandleTranslationUnit() is that all
+// codegen (when using -add-plugin) is completely finished and this can't
+// affect the compiler output.
+struct Visitor : public RecursiveASTVisitor {
+  const std::set 
+  Visitor(const std::set )
+  : ParsedTemplates(ParsedTemplates) {}
+  bool VisitFunctionDecl(FunctionDecl *FD) {
+if (FD->isLateTemplateParsed() &&
+ParsedTemplates.count(FD->getNameAsString()))
+  LateParsedDecls.insert(FD);
+return true;
+  }
+
+  std::set LateParsedDecls;
+} v(ParsedTemplates);
+v.TraverseDecl(context.getTranslationUnitDecl());
+clang::Sema  = Instance.getSema();
+for (const FunctionDecl *FD : v.LateParsedDecls) {
+  clang::LateParsedTemplate* LPT = sema.LateParsedTemplateMap.lookup(FD);
+  sema.LateTemplateParser(sema.OpaqueParser, *LPT);
+  llvm::errs() << "late-parsed-decl: \"" << FD->getNameAsString() << "\"\n";
+}
+  }
+};
+
+class PrintFunctionNamesAction : public PluginASTAction {
+  std::set ParsedTemplates;
+protected:
+  std::unique_ptr CreateASTConsumer(CompilerInstance ,
+ llvm::StringRef) override {
+return llvm::make_unique(CI, ParsedTemplates);
+  }
+
+  bool ParseArgs(const CompilerInstance ,
+ const std::vector ) override {
+for (unsigned i = 0, e = args.size(); i != e; ++i) {
+  llvm::errs() << "PrintFunctionNames arg = " << args[i] << "\n";
+
+  // Example error handling.
+  DiagnosticsEngine  = CI.getDiagnostics();
+  if (args[i] == "-an-error") {
+unsigned DiagID = D.getCustomDiagID(DiagnosticsEngine::Error,
+"invalid argument '%0'");
+D.Report(DiagID) << args[i];
+return false;
+  } else if (args[i] == "-parse-template") {
+if (i + 1 >= e) {
+  D.Report(D.getCustomDiagID(DiagnosticsEngine::Error,
+ "missing -parse-template argument"));
+  return false;
+}
+++i;
+ParsedTemplates.insert(args[i]);
+  }
+}
+if (!args.empty() && args[0] == "help")
+  PrintHelp(llvm::errs());
+
+return true;
+  }
+  void PrintHelp(llvm::raw_ostream& ros) {
+ros << 

[PATCH] D18175: Avoid using LookupResult's implicit copy ctor and assignment operator to avoid warnings

2016-03-15 Thread Marina Yatsina via cfe-commits
myatsina created this revision.
myatsina added reviewers: rnk, hintonda, rjmccall, dblaikie.
myatsina added a subscriber: cfe-commits.
myatsina set the repository for this revision to rL LLVM.

The purpose of this patch is to keep the same functionality without using 
LookupResult's implicit copy ctor and assignment operator, because they cause 
warnings when -Wdeprecated is passed.
This patch is meant to help the following review: 
http://reviews.llvm.org/D18123.




Repository:
  rL LLVM

http://reviews.llvm.org/D18175

Files:
  lib/Sema/SemaStmtAsm.cpp

Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -623,16 +623,15 @@
 
   if (!LookupName(BaseResult, getCurScope()))
 return true;
-
-  LookupResult CurrBaseResult(BaseResult);
-
+  
+  bool IsSingleRes = BaseResult.isSingleResult();
+  NamedDecl *FoundDecl = BaseResult.getFoundDecl();
   for (StringRef NextMember : Members) {
 
-if (!CurrBaseResult.isSingleResult())
+if (!IsSingleRes)
   return true;
 
 const RecordType *RT = nullptr;
-NamedDecl *FoundDecl = CurrBaseResult.getFoundDecl();
 if (VarDecl *VD = dyn_cast(FoundDecl))
   RT = VD->getType()->getAs();
 else if (TypedefNameDecl *TD = dyn_cast(FoundDecl)) {
@@ -660,7 +659,8 @@
 if (!FD)
   return true;
 
-CurrBaseResult = FieldResult;
+IsSingleRes = FieldResult.isSingleResult();
+FoundDecl = FieldResult.getFoundDecl();
 
 const ASTRecordLayout  = Context.getASTRecordLayout(RT->getDecl());
 unsigned i = FD->getFieldIndex();


Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -623,16 +623,15 @@
 
   if (!LookupName(BaseResult, getCurScope()))
 return true;
-
-  LookupResult CurrBaseResult(BaseResult);
-
+  
+  bool IsSingleRes = BaseResult.isSingleResult();
+  NamedDecl *FoundDecl = BaseResult.getFoundDecl();
   for (StringRef NextMember : Members) {
 
-if (!CurrBaseResult.isSingleResult())
+if (!IsSingleRes)
   return true;
 
 const RecordType *RT = nullptr;
-NamedDecl *FoundDecl = CurrBaseResult.getFoundDecl();
 if (VarDecl *VD = dyn_cast(FoundDecl))
   RT = VD->getType()->getAs();
 else if (TypedefNameDecl *TD = dyn_cast(FoundDecl)) {
@@ -660,7 +659,8 @@
 if (!FD)
   return true;
 
-CurrBaseResult = FieldResult;
+IsSingleRes = FieldResult.isSingleResult();
+FoundDecl = FieldResult.getFoundDecl();
 
 const ASTRecordLayout  = Context.getASTRecordLayout(RT->getDecl());
 unsigned i = FD->getFieldIndex();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15332: new clang-tidy checker readability-non-const-parameter

2016-03-15 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki updated this revision to Diff 50705.
danielmarjamaki marked 3 inline comments as done.
danielmarjamaki added a comment.

Fixed review comments


http://reviews.llvm.org/D15332

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/NonConstParameterCheck.cpp
  clang-tidy/readability/NonConstParameterCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-non-const-parameter.rst
  test/clang-tidy/readability-non-const-parameter.cpp

Index: test/clang-tidy/readability-non-const-parameter.cpp
===
--- test/clang-tidy/readability-non-const-parameter.cpp
+++ test/clang-tidy/readability-non-const-parameter.cpp
@@ -0,0 +1,251 @@
+// RUN: %check_clang_tidy %s readability-non-const-parameter %t
+
+// Currently the checker only warns about pointer arguments.
+//
+// It can be defined both that the data is const and that the pointer is const,
+// the checker only checks if the data can be const-specified.
+//
+// It does not warn about pointers to records or function pointers.
+
+// Some external function where first argument is nonconst and second is const.
+char *strcpy1(char *dest, const char *src);
+unsigned my_strcpy(char *buf, const char *s);
+unsigned my_strlen(const char *buf);
+
+// CHECK-MESSAGES: :[[@LINE+1]]:29: warning: parameter 'last' can be const [readability-non-const-parameter]
+void warn1(int *first, int *last) {
+  // CHECK-FIXES: {{^}}void warn1(int *first, const int *last) {{{$}}
+  *first = 0;
+  if (first < last) {
+  } // <- last can be const
+}
+
+// TODO: warning should be written here
+void warn2(char *p) {
+  char buf[10];
+  strcpy1(buf, p);
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:19: warning: parameter 'p' can be const
+void assign1(int *p) {
+  // CHECK-FIXES: {{^}}void assign1(const int *p) {{{$}}
+  const int *q;
+  q = p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:19: warning: parameter 'p' can be const
+void assign2(int *p) {
+  // CHECK-FIXES: {{^}}void assign2(const int *p) {{{$}}
+  const int *q;
+  q = p + 1;
+}
+
+void assign3(int *p) {
+  *p = 0;
+}
+
+void assign4(int *p) {
+  *p += 2;
+}
+
+void assign5(char *p) {
+  p[0] = 0;
+}
+
+void assign6(int *p) {
+  int *q;
+  q = p++;
+}
+
+void assign7(char *p) {
+  char *a, *b;
+  a = b = p;
+}
+
+void assign8(char *a, char *b) {
+  char *x;
+  x = (a ? a : b);
+}
+
+void assign9(unsigned char *str, const unsigned int i) {
+  unsigned char *p;
+  for (p = str + i; *p;) {
+  }
+}
+
+void assign10(int *buf) {
+  int i, *p;
+  for (i = 0, p = buf; i < 10; i++, p++) {
+*p = 1;
+  }
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:17: warning: parameter 'p' can be const
+void init1(int *p) {
+  // CHECK-FIXES: {{^}}void init1(const int *p) {{{$}}
+  const int *q = p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:17: warning: parameter 'p' can be const
+void init2(int *p) {
+  // CHECK-FIXES: {{^}}void init2(const int *p) {{{$}}
+  const int *q = p + 1;
+}
+
+void init3(int *p) {
+  int *q = p;
+}
+
+void init4(float *p) {
+  int *q = (int *)p;
+}
+
+void init5(int *p) {
+  int *i = p ? p : 0;
+}
+
+void init6(int *p) {
+  int *a[] = {p, p, 0};
+}
+
+void init7(int *p, int x) {
+  for (int *q = p + x - 1; 0; q++)
+;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:18: warning: parameter 'p' can be const
+int return1(int *p) {
+  // CHECK-FIXES: {{^}}int return1(const int *p) {{{$}}
+  return *p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:25: warning: parameter 'p' can be const
+const int *return2(int *p) {
+  // CHECK-FIXES: {{^}}const int *return2(const int *p) {{{$}}
+  return p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:25: warning: parameter 'p' can be const
+const int *return3(int *p) {
+  // CHECK-FIXES: {{^}}const int *return3(const int *p) {{{$}}
+  return p + 1;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:27: warning: parameter 'p' can be const
+const char *return4(char *p) {
+  // CHECK-FIXES: {{^}}const char *return4(const char *p) {{{$}}
+  return p ? p : "";
+}
+
+char *return5(char *s) {
+  return s;
+}
+
+char *return6(char *s) {
+  return s + 1;
+}
+
+char *return7(char *a, char *b) {
+  return a ? a : b;
+}
+
+char return8(int *p) {
+  return ++(*p);
+}
+
+void dontwarn1(int *p) {
+  ++(*p);
+}
+
+void dontwarn2(int *p) {
+  (*p)++;
+}
+
+int dontwarn3(_Atomic(int) * p) {
+  return *p;
+}
+
+void callFunction1(char *p) {
+  strcpy1(p, "abc");
+}
+
+void callFunction2(char *p) {
+  strcpy1([0], "abc");
+}
+
+void callFunction3(char *p) {
+  strcpy1(p + 2, "abc");
+}
+
+char *callFunction4(char *p) {
+  return strcpy1(p, "abc");
+}
+
+unsigned callFunction5(char *buf) {
+  unsigned len = my_strlen(buf);
+  return len + my_strcpy(buf, "abc");
+}
+
+void f6(int **p);
+void callFunction6(int *p) { f6(); }
+
+typedef union { void *v; } t;
+void f7(t obj);
+void callFunction7(int *p) {
+  f7((t){p});
+}
+
+void f8(int );
+void callFunction8(int *p) {
+  f8(*p);
+}
+
+// Don't warn about nonconst 

Re: [PATCH] D15332: new clang-tidy checker readability-non-const-parameter

2016-03-15 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki marked 12 inline comments as done.


Comment at: docs/clang-tidy/checks/readability-non-const-parameter.rst:6
@@ +5,3 @@
+
+Finds function parameters that should be const. When const is used properly,
+many mistakes can be avoided. Advantages when using const properly:

hokein wrote:
> Looks like what the document says isn't consistent with the check, since the 
> check only finds non-const pointer parameter. 
I changed "Finds function parameters.." to "Finds function pointer 
parameters..".


Comment at: test/clang-tidy/readability-non-const-parameter.cpp:3
@@ +2,3 @@
+
+// Currently the checker only warns about pointer arguments.
+//

hokein wrote:
> It makes sense to move this document to the `rst`, I think.
Done. First line in rst will now say: "Finds function pointer parameters that 
should be const".


Comment at: test/clang-tidy/readability-non-const-parameter.cpp:219
@@ +218,3 @@
+public:
+  C(int *p) : p(p) {}
+private:

hokein wrote:
> Please add a test case:
> 
> ```
> class C {
> public:
>   C(int *p) : p(p) {}
> private:
>   const int *p;
> };
> ```
> 
> BTW, does the check support class method?
Thanks, I added such class.

I also added one class that shows that class methods are supported.



http://reviews.llvm.org/D15332



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


Re: r263429 - [Frontend] Disable value name discarding for all sanitizers.

2016-03-15 Thread Benjamin Kramer via cfe-commits
On Mon, Mar 14, 2016 at 5:50 PM, Richard Smith  wrote:
> On 14 Mar 2016 6:28 a.m., "Benjamin Kramer via cfe-commits"
>  wrote:
>>
>> Author: d0k
>> Date: Mon Mar 14 08:23:58 2016
>> New Revision: 263429
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=263429=rev
>> Log:
>> [Frontend] Disable value name discarding for all sanitizers.
>>
>> ASan also relies on names on allocas and will emit unhelpful output if
>> they're not present. Just force-enable value names for now. Should
>> unbreak release builds of asan.
>>
>> Modified:
>> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>>
>> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=263429=263428=263429=diff
>>
>> ==
>> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
>> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Mar 14 08:23:58 2016
>> @@ -541,6 +541,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
>>Opts.DisableFPElim =
>>(Args.hasArg(OPT_mdisable_fp_elim) || Args.hasArg(OPT_pg));
>>Opts.DisableFree = Args.hasArg(OPT_disable_free);
>> +  Opts.DiscardValueNames = Args.hasArg(OPT_discard_value_names);
>>Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
>>Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
>>if (Arg *A = Args.getLastArg(OPT_meabi)) {
>> @@ -793,12 +794,6 @@ static bool ParseCodeGenArgs(CodeGenOpti
>>Opts.CudaGpuBinaryFileNames =
>>Args.getAllArgValues(OPT_fcuda_include_gpubinary);
>>
>> -  // DiscardValueNames is set here so that it can depend (perhaps
>> temporarily)
>> -  // on other options.
>> -  // We check SanitizeMemoryTrackOrigins here because the backend pass
>> depends
>> -  // on the name of the alloca in order to print out names.
>> -  Opts.DiscardValueNames =
>> -  Args.hasArg(OPT_discard_value_names) &&
>> !Opts.SanitizeMemoryTrackOrigins;
>>return Success;
>>  }
>>
>> @@ -2158,6 +2153,12 @@ bool CompilerInvocation::CreateFromArgs(
>>  if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
>>Res.getLangOpts()->ObjCExceptions = 1;
>>}
>> +
>> +  // FIXME: Override value name discarding when sanitizers are used
>> because the
>> +  // backend passes depend on the name of the alloca in order to print
>> out
>> +  // names.
>> +  Res.getCodeGenOpts().DiscardValueNames &=
>> Res.getLangOpts()->Sanitize.empty();
>
> This should not be applied to all sanitizers. UBSan checks have no need of
> this (there is no backend pass).

Fair enough. r263541 only does this when asan or msan is enabled.

>
>>// FIXME: ParsePreprocessorArgs uses the FileManager to read the
>> contents of
>>// PCH file and find the original header name. Remove the need to do
>> that in
>>// ParsePreprocessorArgs and remove the FileManager
>>
>>
>> ___
>> 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


  1   2   >