[libcxx] r266855 - Add cxx_runtime_root options for testing against a different libc++ at runtime

2016-04-19 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 19 23:17:39 2016
New Revision: 266855

URL: http://llvm.org/viewvc/llvm-project?rev=266855&view=rev
Log:
Add cxx_runtime_root options for testing against a different libc++ at runtime

Modified:
libcxx/trunk/docs/TestingLibcxx.rst
libcxx/trunk/test/libcxx/test/config.py
libcxx/trunk/test/libcxx/test/target_info.py

Modified: libcxx/trunk/docs/TestingLibcxx.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/TestingLibcxx.rst?rev=266855&r1=266854&r2=266855&view=diff
==
--- libcxx/trunk/docs/TestingLibcxx.rst (original)
+++ libcxx/trunk/docs/TestingLibcxx.rst Tue Apr 19 23:17:39 2016
@@ -118,11 +118,20 @@ configuration. Passing the option on the
   Specify the libc++ headers that are tested. By default the headers in the
   source tree are used.
 
-.. option:: libcxx_library=
+.. option:: cxx_library_root=
 
-  Specify the libc++ library that is tested. By default the library in the
-  build directory is used. This option cannot be used when use_system_lib is
-  provided.
+  Specify the directory of the libc++ library to be tested. By default the
+  library folder of the build directory is used. This option cannot be used
+  when use_system_lib is provided.
+
+
+.. option:: cxx_runtime_root=
+
+  Specify the directory of the libc++ library to use at runtime. This directory
+  is not added to the linkers search path. This can be used to compile tests
+  against one version of libc++ and run them using another. The default value
+  for this option is `cxx_library_root`. This option cannot be used
+  when use_system_lib is provided.
 
 .. option:: use_system_lib=
 

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=266855&r1=266854&r2=266855&view=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Tue Apr 19 23:17:39 2016
@@ -61,6 +61,7 @@ class Configuration(object):
 self.libcxx_src_root = None
 self.libcxx_obj_root = None
 self.cxx_library_root = None
+self.cxx_runtime_root = None
 self.abi_library_root = None
 self.env = {}
 self.use_target = False
@@ -195,6 +196,8 @@ class Configuration(object):
 def configure_cxx_library_root(self):
 self.cxx_library_root = self.get_lit_conf('cxx_library_root',
   self.libcxx_obj_root)
+self.cxx_runtime_root = self.get_lit_conf('cxx_runtime_root',
+   self.cxx_library_root)
 
 def configure_use_system_cxx_lib(self):
 # This test suite supports testing against either the system library or
@@ -439,9 +442,11 @@ class Configuration(object):
 self.cxx.link_flags += shlex.split(link_flags_str)
 
 def configure_link_flags_cxx_library_path(self):
-if not self.use_system_cxx_lib and self.cxx_library_root:
-self.cxx.link_flags += ['-L' + self.cxx_library_root,
-'-Wl,-rpath,' + self.cxx_library_root]
+if not self.use_system_cxx_lib:
+if self.cxx_library_root:
+self.cxx.link_flags += ['-L' + self.cxx_library_root]
+if self.cxx_runtime_root:
+self.cxx.link_flags += ['-Wl,-rpath,' + self.cxx_runtime_root]
 
 def configure_link_flags_abi_library_path(self):
 # Configure ABI library paths.

Modified: libcxx/trunk/test/libcxx/test/target_info.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/target_info.py?rev=266855&r1=266854&r2=266855&view=diff
==
--- libcxx/trunk/test/libcxx/test/target_info.py (original)
+++ libcxx/trunk/test/libcxx/test/target_info.py Tue Apr 19 23:17:39 2016
@@ -92,8 +92,8 @@ class DarwinLocalTI(DefaultTargetInfo):
 # Configure the library path for libc++
 if self.full_config.use_system_cxx_lib:
 pass
-elif self.full_config.cxx_library_root:
-library_paths += [self.full_config.cxx_library_root]
+elif self.full_config.cxx_runtime_root:
+library_paths += [self.full_config.cxx_runtime_root]
 # Configure the abi library path
 if self.full_config.abi_library_root:
 library_paths += [self.full_config.abi_library_root]


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


r266853 - [OPENMP] Codegen for untied tasks.

2016-04-19 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Apr 19 23:01:36 2016
New Revision: 266853

URL: http://llvm.org/viewvc/llvm-project?rev=266853&view=rev
Log:
[OPENMP] Codegen for untied tasks.

If the untied clause is present on a task construct, any thread in the
team can resume the task region after a suspension. Patch adds proper
codegen for untied tasks.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/task_codegen.cpp
cfe/trunk/test/OpenMP/task_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/task_private_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=266853&r1=266852&r2=266853&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Apr 19 23:01:36 2016
@@ -72,6 +72,8 @@ public:
   /// \return LValue for thread id variable. This LValue always has type 
int32*.
   virtual LValue getThreadIDVariableLValue(CodeGenFunction &CGF);
 
+  virtual void emitUntiedSwitch(CodeGenFunction & /*CGF*/) {}
+
   CGOpenMPRegionKind getRegionKind() const { return RegionKind; }
 
   OpenMPDirectiveKind getDirectiveKind() const { return Kind; }
@@ -82,6 +84,8 @@ public:
 return Info->getKind() == CR_OpenMP;
   }
 
+  ~CGOpenMPRegionInfo() override = default;
+
 protected:
   CGOpenMPRegionKind RegionKind;
   RegionCodeGenTy CodeGen;
@@ -90,7 +94,7 @@ protected:
 };
 
 /// \brief API for captured statement code generation in OpenMP constructs.
-class CGOpenMPOutlinedRegionInfo : public CGOpenMPRegionInfo {
+class CGOpenMPOutlinedRegionInfo final : public CGOpenMPRegionInfo {
 public:
   CGOpenMPOutlinedRegionInfo(const CapturedStmt &CS, const VarDecl 
*ThreadIDVar,
  const RegionCodeGenTy &CodeGen,
@@ -121,14 +125,62 @@ private:
 };
 
 /// \brief API for captured statement code generation in OpenMP constructs.
-class CGOpenMPTaskOutlinedRegionInfo : public CGOpenMPRegionInfo {
+class CGOpenMPTaskOutlinedRegionInfo final : public CGOpenMPRegionInfo {
 public:
+  class UntiedTaskActionTy final : public PrePostActionTy {
+bool Untied;
+const VarDecl *PartIDVar;
+const RegionCodeGenTy UntiedCodeGen;
+llvm::SwitchInst *UntiedSwitch = nullptr;
+
+  public:
+UntiedTaskActionTy(bool Tied, const VarDecl *PartIDVar,
+   const RegionCodeGenTy &UntiedCodeGen)
+: Untied(!Tied), PartIDVar(PartIDVar), UntiedCodeGen(UntiedCodeGen) {}
+void Enter(CodeGenFunction &CGF) override {
+  if (Untied) {
+// Emit task switching point.
+auto PartIdLVal = CGF.EmitLoadOfPointerLValue(
+CGF.GetAddrOfLocalVar(PartIDVar),
+PartIDVar->getType()->castAs());
+auto *Res = CGF.EmitLoadOfScalar(PartIdLVal, SourceLocation());
+auto *DoneBB = CGF.createBasicBlock(".untied.done.");
+UntiedSwitch = CGF.Builder.CreateSwitch(Res, DoneBB);
+CGF.EmitBlock(DoneBB);
+CGF.EmitBranchThroughCleanup(CGF.ReturnBlock);
+CGF.EmitBlock(CGF.createBasicBlock(".untied.jmp."));
+UntiedSwitch->addCase(CGF.Builder.getInt32(0),
+  CGF.Builder.GetInsertBlock());
+emitUntiedSwitch(CGF);
+  }
+}
+void emitUntiedSwitch(CodeGenFunction &CGF) const {
+  if (Untied) {
+auto PartIdLVal = CGF.EmitLoadOfPointerLValue(
+CGF.GetAddrOfLocalVar(PartIDVar),
+PartIDVar->getType()->castAs());
+
CGF.EmitStoreOfScalar(CGF.Builder.getInt32(UntiedSwitch->getNumCases()),
+  PartIdLVal);
+UntiedCodeGen(CGF);
+CodeGenFunction::JumpDest CurPoint =
+CGF.getJumpDestInCurrentScope(".untied.next.");
+CGF.EmitBranchThroughCleanup(CGF.ReturnBlock);
+CGF.EmitBlock(CGF.createBasicBlock(".untied.jmp."));
+
UntiedSwitch->addCase(CGF.Builder.getInt32(UntiedSwitch->getNumCases()),
+  CGF.Builder.GetInsertBlock());
+CGF.EmitBranchThroughCleanup(CurPoint);
+CGF.EmitBlock(CurPoint.getBlock());
+  }
+}
+unsigned getNumberOfParts() const { return UntiedSwitch->getNumCases(); }
+  };
   CGOpenMPTaskOutlinedRegionInfo(const CapturedStmt &CS,
  const VarDecl *ThreadIDVar,
  const RegionCodeGenTy &CodeGen,
- OpenMPDirectiveKind Kind, bool HasCancel)
+ OpenMPDirectiveKind Kind, bool HasCancel,
+ const UntiedTaskActionTy &Action)
   : CGOpenMPRegionInfo(CS, TaskOutlinedRegion, CodeGen, Kind, HasCancel),
-ThreadIDVar(ThreadIDVar) {
+ThreadIDVar(ThreadIDVar), Action(Action)

Re: [PATCH] D15404: Cleanup: move visibility/linkage attributes to the first declaration (part 2).

2016-04-19 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

It seems my changes to the IO headers removes a bunch of symbols from the 
dylib. I'll look into it. I'm assuming it's because clang was already ignoring 
the "_LIBCPP_INLINE_VISIBILITY" attribute when instantiating extern templates. 
The symbols get removed even if we don't build with "internal_linkage".


Repository:
  rL LLVM

http://reviews.llvm.org/D15404



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


Re: [PATCH] D15404: Cleanup: move visibility/linkage attributes to the first declaration (part 2).

2016-04-19 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

I've updated the diff so it merges and also fixed , , 
 and . It can be found here: 
https://gist.github.com/EricWF/487e5b1de2bb320e93fbb3c9c758b013


Repository:
  rL LLVM

http://reviews.llvm.org/D15404



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


Re: [PATCH] D15404: Cleanup: move visibility/linkage attributes to the first declaration (part 2).

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

LGTM.



Comment at: test/libcxx/test/config.py:367
@@ -366,2 +366,3 @@
 self.cxx.compile_flags.extend(sysroot_flags)
+   self.cxx.compile_flags.append("-ferror-limit=0")
 

Get rid of this.


Repository:
  rL LLVM

http://reviews.llvm.org/D15404



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


r266852 - Enable ODR uniquing of DITypes for ThinLTO backends

2016-04-19 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Tue Apr 19 21:23:52 2016
New Revision: 266852

URL: http://llvm.org/viewvc/llvm-project?rev=266852&view=rev
Log:
Enable ODR uniquing of DITypes for ThinLTO backends

Summary:
This is a follow-on to apply Duncan's new DIType ODR uniquing from
r266549 and r266713 in more places.

When invoking ThinLTO backend compiles via clang (for a distributed
build), invoke enableDebugTypeODRUniquing() before parsing the module.

Reviewers: dexonsmith, joker.eph

Subscribers: llvm-commits, joker.eph

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

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

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=266852&r1=266851&r2=266852&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Tue Apr 19 21:23:52 2016
@@ -794,6 +794,11 @@ void CodeGenAction::ExecuteAction() {
 if (Invalid)
   return;
 
+// For ThinLTO backend invocations, ensure that the context
+// merges types based on ODR identifiers.
+if (!CI.getCodeGenOpts().ThinLTOIndexFile.empty())
+  VMContext->enableDebugTypeODRUniquing();
+
 llvm::SMDiagnostic Err;
 TheModule = parseIR(MainFile->getMemBufferRef(), Err, *VMContext);
 if (!TheModule) {


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


Re: [PATCH] D16360: unordered_map: Avoid unnecessary mallocs when no insert occurs

2016-04-19 Thread Eric Fiselier via cfe-commits
EricWF resigned from this revision.
EricWF removed a reviewer: EricWF.
EricWF added a comment.
This revision now requires review to proceed.

This is done.


http://reviews.llvm.org/D16360



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


[libcxx] r266851 - [libcxx] Fix PR15638 - Only allocate in parent when starting a thread to prevent calling terminate.

2016-04-19 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 19 21:21:33 2016
New Revision: 266851

URL: http://llvm.org/viewvc/llvm-project?rev=266851&view=rev
Log:
[libcxx] Fix PR15638 - Only allocate in parent when starting a thread to 
prevent calling terminate.

Summary:
Hi,

When creating a new thread libc++ performs at least 2 allocations. The first 
allocates a tuple of args and the functor that will be passed to the new 
thread. The second allocation is for the thread local storage needed internally 
by libc++. Currently the second allocation happens in the child thread, meaning 
that if it throws the program will terminate with an uncaught bad alloc.

The solution to this is to allocate ALL memory in the parent thread and then 
pass it to the child.

See https://llvm.org/bugs/show_bug.cgi?id=15638

Reviewers: mclow.lists, danalbert, jroelofs, EricWF

Subscribers: cfe-commits

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

Modified:
libcxx/trunk/include/thread

libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp

Modified: libcxx/trunk/include/thread
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/thread?rev=266851&r1=266850&r2=266851&view=diff
==
--- libcxx/trunk/include/thread (original)
+++ libcxx/trunk/include/thread Tue Apr 19 21:21:33 2016
@@ -339,21 +339,21 @@ public:
 
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 
-template 
+template 
 inline _LIBCPP_INLINE_VISIBILITY
 void
-__thread_execute(tuple<_Fp, _Args...>& __t, __tuple_indices<_Indices...>)
+__thread_execute(tuple<_TSp, _Fp, _Args...>& __t, __tuple_indices<_Indices...>)
 {
-__invoke(_VSTD::move(_VSTD::get<0>(__t)), 
_VSTD::move(_VSTD::get<_Indices>(__t))...);
+__invoke(_VSTD::move(_VSTD::get<1>(__t)), 
_VSTD::move(_VSTD::get<_Indices>(__t))...);
 }
 
 template 
-void*
-__thread_proxy(void* __vp)
+void* __thread_proxy(void* __vp)
 {
-__thread_local_data().reset(new __thread_struct);
+// _Fp = std::tuple< unique_ptr<__thread_struct>, Functor, Args...>
 std::unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
-typedef typename __make_tuple_indices::value, 1>::type 
_Index;
+__thread_local_data().reset(_VSTD::get<0>(*__p).release());
+typedef typename __make_tuple_indices::value, 2>::type 
_Index;
 __thread_execute(*__p, _Index());
 return nullptr;
 }
@@ -363,9 +363,13 @@ template 
 thread::thread(_Fp&& __f, _Args&&... __args)
 {
-typedef tuple::type, typename decay<_Args>::type...> 
_Gp;
-_VSTD::unique_ptr<_Gp> __p(new _Gp(__decay_copy(_VSTD::forward<_Fp>(__f)),
-
__decay_copy(_VSTD::forward<_Args>(__args))...));
+typedef unique_ptr<__thread_struct> _TSPtr;
+_TSPtr __tsp(new __thread_struct);
+typedef tuple<_TSPtr, typename decay<_Fp>::type, typename 
decay<_Args>::type...> _Gp;
+_VSTD::unique_ptr<_Gp> __p(
+new _Gp(std::move(__tsp),
+__decay_copy(_VSTD::forward<_Fp>(__f)),
+__decay_copy(_VSTD::forward<_Args>(__args))...));
 int __ec = pthread_create(&__t_, 0, &__thread_proxy<_Gp>, __p.get());
 if (__ec == 0)
 __p.release();
@@ -376,22 +380,34 @@ thread::thread(_Fp&& __f, _Args&&... __a
 #else  // _LIBCPP_HAS_NO_VARIADICS
 
 template 
-void*
-__thread_proxy(void* __vp)
+struct __thread_invoke_pair {
+// This type is used to pass memory for thread local storage and a functor
+// to a newly created thread because std::pair doesn't work with
+// std::unique_ptr in C++03.
+__thread_invoke_pair(_Fp& __f) : __tsp_(new __thread_struct), __fn_(__f) {}
+unique_ptr<__thread_struct> __tsp_;
+_Fp __fn_;
+};
+
+template 
+void* __thread_proxy_cxx03(void* __vp)
 {
-__thread_local_data().reset(new __thread_struct);
 std::unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
-(*__p)();
+__thread_local_data().reset(__p->__tsp_.release());
+(__p->__fn_)();
 return nullptr;
 }
 
 template 
 thread::thread(_Fp __f)
 {
-std::unique_ptr<_Fp> __p(new _Fp(__f));
-int __ec = pthread_create(&__t_, 0, &__thread_proxy<_Fp>, __p.get());
+
+typedef __thread_invoke_pair<_Fp> _InvokePair;
+typedef std::unique_ptr<_InvokePair> _PairPtr;
+_PairPtr __pp(new _InvokePair(__f));
+int __ec = pthread_create(&__t_, 0, &__thread_proxy_cxx03<_InvokePair>, 
__pp.get());
 if (__ec == 0)
-__p.release();
+__pp.release();
 else
 __throw_system_error(__ec, "thread constructor failed");
 }

Modified: 
libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp?rev=266851&r1=266850&r2=266851&view=diff
==
--- 
libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thre

Re: [PATCH] D13748: [libcxx] Fix PR15638 - Only allocate in parent when starting a thread to prevent calling terminate.

2016-04-19 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a reviewer: EricWF.
EricWF added a comment.
This revision is now accepted and ready to land.

Accepting.


http://reviews.llvm.org/D13748



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


Re: [PATCH] D11329: [libcxx] Add __invoke_constexpr functions. Try 2.

2016-04-19 Thread Eric Fiselier via cfe-commits
EricWF abandoned this revision.
EricWF added a comment.

Another solution has been committed.


http://reviews.llvm.org/D11329



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


r266843 - [Clang] Remove unwanted --check-prefix=CHECK from unit tests. NFC.

2016-04-19 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Tue Apr 19 20:02:18 2016
New Revision: 266843

URL: http://llvm.org/viewvc/llvm-project?rev=266843&view=rev
Log:
[Clang] Remove unwanted --check-prefix=CHECK from unit tests. NFC.

Summary:
Removed unwanted --check-prefix=CHECK from the following unit tests:
  test/CXX/special/class.copy/implicit-move-def.cpp
  test/CodeGen/cleanup-destslot-simple.c
  test/CodeGen/inline-asm-immediate-ubsan.c
  test/CodeGen/mips-interrupt-attr.c
  test/CodeGenCXX/cfi-stats.cpp
  test/CodeGenCXX/copy-constructor-elim.cpp
  test/CodeGenCXX/microsoft-templ-uuidof.cpp
  test/CodeGenCXX/vtable-linkage.cpp
  test/CodeGenObjC/messages-2.m
  test/Driver/noinline.c
  test/Index/remap-load.c
  test/Index/retain-comments-from-system-headers.c
  test/OpenMP/task_if_codegen.cpp
  test/Preprocessor/comment_save_macro.c

Patch by:  Mandeep Singh Grang (mgrang)

Reviewers: rafael, ABataev, rengolin

Projects: #clang-c

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

Modified:
cfe/trunk/test/CXX/special/class.copy/implicit-move-def.cpp
cfe/trunk/test/CodeGen/cleanup-destslot-simple.c
cfe/trunk/test/CodeGen/inline-asm-immediate-ubsan.c
cfe/trunk/test/CodeGen/mips-interrupt-attr.c
cfe/trunk/test/CodeGenCXX/cfi-stats.cpp
cfe/trunk/test/CodeGenCXX/copy-constructor-elim.cpp
cfe/trunk/test/CodeGenCXX/microsoft-templ-uuidof.cpp
cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp
cfe/trunk/test/CodeGenObjC/messages-2.m
cfe/trunk/test/Driver/noinline.c
cfe/trunk/test/Index/remap-load.c
cfe/trunk/test/Index/retain-comments-from-system-headers.c
cfe/trunk/test/OpenMP/task_if_codegen.cpp
cfe/trunk/test/Preprocessor/comment_save_macro.c

Modified: cfe/trunk/test/CXX/special/class.copy/implicit-move-def.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/special/class.copy/implicit-move-def.cpp?rev=266843&r1=266842&r2=266843&view=diff
==
--- cfe/trunk/test/CXX/special/class.copy/implicit-move-def.cpp (original)
+++ cfe/trunk/test/CXX/special/class.copy/implicit-move-def.cpp Tue Apr 19 
20:02:18 2016
@@ -1,4 +1,4 @@
-// FIXME: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -o - -std=c++11 %s 
| FileCheck -check-prefix=CHECK %s
+// FIXME: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -o - -std=c++11 %s 
| FileCheck %s
 // RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -o - -std=c++11 %s | 
FileCheck -check-prefix=CHECK-ASSIGN %s
 // RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -o - -std=c++11 %s | 
FileCheck -check-prefix=CHECK-CTOR %s
 

Modified: cfe/trunk/test/CodeGen/cleanup-destslot-simple.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cleanup-destslot-simple.c?rev=266843&r1=266842&r2=266843&view=diff
==
--- cfe/trunk/test/CodeGen/cleanup-destslot-simple.c (original)
+++ cfe/trunk/test/CodeGen/cleanup-destslot-simple.c Tue Apr 19 20:02:18 2016
@@ -1,8 +1,8 @@
 // RUN: %clang_cc1 -O1 -triple x86_64-none-linux-gnu -emit-llvm 
-debug-info-kind=line-tables-only %s -o - | FileCheck %s --check-prefix=CHECK 
--check-prefix=LIFETIME
 
 // We shouldn't have markers at -O0 or with msan.
-// RUN: %clang_cc1 -O0 -triple x86_64-none-linux-gnu -emit-llvm 
-debug-info-kind=line-tables-only %s -o - | FileCheck %s --check-prefix=CHECK
-// RUN: %clang_cc1 -O1 -triple x86_64-none-linux-gnu -emit-llvm 
-debug-info-kind=line-tables-only %s -o - -fsanitize=memory | FileCheck %s 
--check-prefix=CHECK
+// RUN: %clang_cc1 -O0 -triple x86_64-none-linux-gnu -emit-llvm 
-debug-info-kind=line-tables-only %s -o - | FileCheck %s
+// RUN: %clang_cc1 -O1 -triple x86_64-none-linux-gnu -emit-llvm 
-debug-info-kind=line-tables-only %s -o - -fsanitize=memory | FileCheck %s
 
 // There is no exception to handle here, lifetime.end is not a destructor,
 // so there is no need have cleanup dest slot related code

Modified: cfe/trunk/test/CodeGen/inline-asm-immediate-ubsan.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/inline-asm-immediate-ubsan.c?rev=266843&r1=266842&r2=266843&view=diff
==
--- cfe/trunk/test/CodeGen/inline-asm-immediate-ubsan.c (original)
+++ cfe/trunk/test/CodeGen/inline-asm-immediate-ubsan.c Tue Apr 19 20:02:18 2016
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s \
 // RUN: -fsanitize=signed-integer-overflow \
-// RUN:   | FileCheck %s --check-prefix=CHECK
+// RUN:   | FileCheck %s
 
 // Verify we emit constants for "immediate" inline assembly arguments.
 // Emitting a scalar expression can make the immediate be generated as

Modified: cfe/trunk/test/CodeGen/mips-interrupt-attr.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips-interrupt-attr.c?rev=266843&r1=266842&r2=266843&

r266840 - MarkEOLs should only be true for clang-cl.exe.

2016-04-19 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Tue Apr 19 19:33:06 2016
New Revision: 266840

URL: http://llvm.org/viewvc/llvm-project?rev=266840&view=rev
Log:
MarkEOLs should only be true for clang-cl.exe.

Summary:
https://llvm.org/bugs/show_bug.cgi?id=27396

This fixes an issue in response files where "\r\n" was being interpreted
as two EOL markers (i.e. we consumed the '\r' as terminating the
previous token, and then parsed the '\n' as a significant EOL). This
breaks response files where joined arguments get split across multiple
lines (like "-x\r\nc"). I also fixed an accidental issue in the
response-file.c test, where the response file is appended to, instead of
being overwritten.

Reviewers: rnk

Subscribers: danalbert, llvm-commits

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

Added:
cfe/trunk/test/Driver/response-file-extra-whitespace.c
Modified:
cfe/trunk/test/Driver/response-file.c
cfe/trunk/tools/driver/driver.cpp

Added: cfe/trunk/test/Driver/response-file-extra-whitespace.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/response-file-extra-whitespace.c?rev=266840&view=auto
==
--- cfe/trunk/test/Driver/response-file-extra-whitespace.c (added)
+++ cfe/trunk/test/Driver/response-file-extra-whitespace.c Tue Apr 19 19:33:06 
2016
@@ -0,0 +1,12 @@
+// Check that clang is able to process response files with extra whitespace.
+// We generate a dos-style file with \r\n for line endings, and then split
+// some joined arguments (like "-x c") across lines to ensure that regular
+// clang (not clang-cl) can process it correctly.
+//
+// RUN: echo -en "-x\r\nc\r\n-DTEST\r\n" > %t.0.txt
+// RUN: %clang -E @%t.0.txt %s -v 2>&1 | FileCheck %s -check-prefix=SHORT
+// SHORT: extern int it_works;
+
+#ifdef TEST
+extern int it_works;
+#endif

Modified: cfe/trunk/test/Driver/response-file.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/response-file.c?rev=266840&r1=266839&r2=266840&view=diff
==
--- cfe/trunk/test/Driver/response-file.c (original)
+++ cfe/trunk/test/Driver/response-file.c Tue Apr 19 19:33:06 2016
@@ -4,7 +4,7 @@
 // Since this is a short response file, clang must not use a response file
 // to pass its parameters to other tools. This is only necessary for a large
 // number of parameters.
-// RUN: echo "-DTEST" >> %t.0.txt
+// RUN: echo "-DTEST" > %t.0.txt
 // RUN: %clang -E @%t.0.txt %s -v 2>&1 | FileCheck %s -check-prefix=SHORT
 // SHORT-NOT: Arguments passed via response file
 // SHORT: extern int it_works;

Modified: cfe/trunk/tools/driver/driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=266840&r1=266839&r2=266840&view=diff
==
--- cfe/trunk/tools/driver/driver.cpp (original)
+++ cfe/trunk/tools/driver/driver.cpp Tue Apr 19 19:33:06 2016
@@ -338,18 +338,26 @@ int main(int argc_, const char **argv_)
   // have to manually search for a --driver-mode=cl argument the hard way.
   // Finally, our -cc1 tools don't care which tokenization mode we use because
   // response files written by clang will tokenize the same way in either mode.
-  llvm::cl::TokenizerCallback Tokenizer = &llvm::cl::TokenizeGNUCommandLine;
+  bool ClangCLMode = false;
   if (TargetAndMode.second == "--driver-mode=cl" ||
   std::find_if(argv.begin(), argv.end(), [](const char *F) {
 return F && strcmp(F, "--driver-mode=cl") == 0;
   }) != argv.end()) {
-Tokenizer = &llvm::cl::TokenizeWindowsCommandLine;
+ClangCLMode = true;
   }
 
   // Determines whether we want nullptr markers in argv to indicate response
-  // files end-of-lines. We only use this for the /LINK driver argument.
-  bool MarkEOLs = true;
-  if (argv.size() > 1 && StringRef(argv[1]).startswith("-cc1"))
+  // files end-of-lines. We only use this for the /LINK driver argument with
+  // clang-cl.exe on Windows.
+  bool MarkEOLs = false;
+
+  llvm::cl::TokenizerCallback Tokenizer = &llvm::cl::TokenizeGNUCommandLine;
+  if (ClangCLMode) {
+Tokenizer = &llvm::cl::TokenizeWindowsCommandLine;
+MarkEOLs = true;
+  }
+
+  if (MarkEOLs && argv.size() > 1 && StringRef(argv[1]).startswith("-cc1"))
 MarkEOLs = false;
   llvm::cl::ExpandResponseFiles(Saver, Tokenizer, argv, MarkEOLs);
 


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


Re: [PATCH] D19299: lower __builtin_expect() directly to prof metadata instead of LLVM intrinsic

2016-04-19 Thread David Li via cfe-commits
davidxl added a comment.

I like the direction this patch is going. Will look into details soon.


http://reviews.llvm.org/D19299



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


[libcxx] r266836 - Add 'is_callable' and 'is_nothrow_callable' traits and cleanup INVOKE.

2016-04-19 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Apr 19 19:14:32 2016
New Revision: 266836

URL: http://llvm.org/viewvc/llvm-project?rev=266836&view=rev
Log:
Add 'is_callable' and 'is_nothrow_callable' traits and cleanup INVOKE.

The primary purpose of this patch is to add the 'is_callable' traits.
Since 'is_nothrow_callable' required making 'INVOKE' conditionally noexcept
I also took this oppertunity to implement a constexpr version of INVOKE.
This fixes 'std::experimental::apply' which required constexpr 'INVOKE support'.

This patch will be followed up with some cleanup. Primarly removing most
of "__member_function_traits" since it's no longer used by INVOKE (in C++11 at 
least).

Added:

libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/PR23141_invoke_not_constexpr.pass.cpp

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_cxx03.pass.cpp
libcxx/trunk/test/std/utilities/meta/meta.rel/is_callable.pass.cpp
libcxx/trunk/test/std/utilities/meta/meta.rel/is_nothrow_callable.pass.cpp
Removed:

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_no_variadics.pass.cpp
Modified:
libcxx/trunk/include/__functional_base
libcxx/trunk/include/experimental/tuple
libcxx/trunk/include/type_traits

libcxx/trunk/test/std/experimental/utilities/tuple/tuple.apply/constexpr_types.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_1_2_3.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.require/invoke_helpers.h

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp

libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp

libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/__functional_base
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__functional_base?rev=266836&r1=266835&r2=266836&view=diff
==
--- libcxx/trunk/include/__functional_base (original)
+++ libcxx/trunk/include/__functional_base Tue Apr 19 19:14:32 2016
@@ -306,97 +306,19 @@ struct __weak_result_type<_Rp (_Cp::*)(_
 
 #endif // _LIBCPP_HAS_NO_VARIADICS
 
-// __invoke
+#ifndef _LIBCPP_CXX03_LANG
 
-#ifndef _LIBCPP_HAS_NO_VARIADICS
-
-// bullets 1 and 2
-
-template 
-inline _LIBCPP_INLINE_VISIBILITY
-auto
-__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
--> 
decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
-{
-return (_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...);
-}
-
-
-template 
-inline _LIBCPP_INLINE_VISIBILITY
-auto
-__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
--> decltype((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
-{
-return (__a0.get().*__f)(_VSTD::forward<_Args>(__args)...);
-}
-
-template 
-inline _LIBCPP_INLINE_VISIBILITY
-auto
-__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
--> 
decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
-{
-return 
((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...);
-}
-
-// bullets 3 and 4
-
-template 
-inline _LIBCPP_INLINE_VISIBILITY
-auto
-__invoke(_Fp&& __f, _A0&& __a0)
--> decltype(_VSTD::forward<_A0>(__a0).*__f)
-{
-return _VSTD::forward<_A0>(__a0).*__f;
-}
-
-
-template 
-inline _LIBCPP_INLINE_VISIBILITY
-auto
-__invoke(_Fp&& __f, _A0&& __a0)
--> decltype(__a0.get().*__f)
-{
-return __a0.get().*__f;
-}
-
-template 
-inline _LIBCPP_INLINE_VISIBILITY
-auto
-__invoke(_Fp&& __f, _A0&& __a0)
--> decltype((*_VSTD::forward<_A0>(__a0)).*__f)
-{
-return (*_VSTD::forward<_A0>(__a0)).*__f;
-}
-
-// bullet 5
-
-template 
-inline _LIBCPP_INLINE_VISIBILITY
-auto
-__invoke(_Fp&& __f, _Args&& ...__args)
--> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
-{
-return _VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...);
-}
 template 
 struct __invoke_return
 {
 typedef decltype(__invoke(_VSTD::declval<_Tp>(), 
_VSTD::declval<_Args>()...)) type;
 };
 
-#else // _LIBCPP_HAS_NO_VARIADICS
+#else // defined(_LIBCPP_CXX03_LANG)
 
 #include <__functional_base_03>
 
-#endif  // _LIBCPP_HAS_NO_VARIADICS
+#endif  // !defined(_LIBCPP_CXX03_LANG)
 
 
 template 

Modified: libcxx/trunk/include/experimental/tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/tuple?rev=266836&r1=266835&r2=266836&view=diff
==
--- libcxx/trunk/include/experimental/tuple (original)
+++ libcxx/trunk/include/experimental/tuple Tue Apr 19 19:14:32 2016
@@ 

Re: r266496 - [CUDA] Raise an error if the CUDA install can't be found.

2016-04-19 Thread Chandler Carruth via cfe-commits
Thanks!

On Tue, Apr 19, 2016 at 11:58 AM Justin Lebar via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Committed a test in r266796.
>
> On Tue, Apr 19, 2016 at 11:42 AM, Justin Lebar  wrote:
> >> I don't really understand why having to change the test when we change
> the code it test changes...
> >
> > My thought was, this code isn't really testing how we detect a CUDA
> > installation.  That's a separate matter, involving --cuda-path,
> > various default locations we check, and so on.
> >
> > Anyway I now see that we're already biting that cost with existing
> > tests, so adding a test for this shouldn't be a big deal.
> >
> > On Tue, Apr 19, 2016 at 11:33 AM, Chandler Carruth 
> wrote:
> >> I don't really understand why having to change the test when we change
> the
> >> code it test changes...
> >>
> >> We have several fake install trees in the driver tests to check pretty
> much
> >> exactly these kinds of things?
> >>
> >> On Tue, Apr 19, 2016 at 11:31 AM Justin Lebar via cfe-commits
> >>  wrote:
> >>>
> >>> Yes, in general our testing story around the CUDA installs needs work.
> >>> In particular, our wrapper headers are complicated and fragile, and
> >>> have zero coverage at the moment.  That's why Art is working on
> >>> getting CUDA tests into the test-suite.
> >>>
> >>> It's possible to test this particular change without access to a full
> >>> CUDA installation.  However, I was hesitant to do so, because such a
> >>> test would have to create a fake cuda installation.  Our test would
> >>> then be fragile with respect to exactly how clang detects that a CUDA
> >>> install is "real".  If we changed those heuristics, we'd have to
> >>> change our test.
> >>>
> >>> On Tue, Apr 19, 2016 at 11:21 AM, Chandler Carruth <
> chandl...@gmail.com>
> >>> wrote:
> >>> > This commit is missing a test.
> >>> >
> >>> >
> >>> > On Fri, Apr 15, 2016 at 5:16 PM Justin Lebar via cfe-commits
> >>> >  wrote:
> >>> >>
> >>> >> Author: jlebar
> >>> >> Date: Fri Apr 15 19:11:11 2016
> >>> >> New Revision: 266496
> >>> >>
> >>> >> URL: http://llvm.org/viewvc/llvm-project?rev=266496&view=rev
> >>> >> Log:
> >>> >> [CUDA] Raise an error if the CUDA install can't be found.
> >>> >>
> >>> >> Summary:
> >>> >> Without this change, we silently proceed on without including
> >>> >> __clang_cuda_runtime_wrapper.h.  This leads to very strange
> behavior --
> >>> >> you say you're compiling CUDA code, but e.g. __device__ is not
> defined!
> >>> >>
> >>> >> Reviewers: tra
> >>> >>
> >>> >> Subscribers: cfe-commits
> >>> >>
> >>> >> Differential Revision: http://reviews.llvm.org/D19180
> >>> >>
> >>> >> Modified:
> >>> >> cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> >>> >> cfe/trunk/lib/Driver/ToolChains.cpp
> >>> >>
> >>> >> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> >>> >> URL:
> >>> >>
> >>> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=266496&r1=266495&r2=266496&view=diff
> >>> >>
> >>> >>
> >>> >>
> ==
> >>> >> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> (original)
> >>> >> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Apr
> 15
> >>> >> 19:11:11 2016
> >>> >> @@ -23,6 +23,9 @@ def err_drv_unknown_language : Error<"la
> >>> >>  def err_drv_invalid_arch_name : Error<
> >>> >>"invalid arch name '%0'">;
> >>> >>  def err_drv_cuda_bad_gpu_arch : Error<"Unsupported CUDA gpu
> >>> >> architecture:
> >>> >> %0">;
> >>> >> +def err_drv_no_cuda_installation : Error<
> >>> >> +  "cannot find CUDA installation.  Provide its path via
> --cuda-path,
> >>> >> or
> >>> >> pass "
> >>> >> +  "-nocudainc to build without CUDA includes.">;
> >>> >>  def err_drv_invalid_thread_model_for_target : Error<
> >>> >>"invalid thread model '%0' in '%1' for this target">;
> >>> >>  def err_drv_invalid_linker_name : Error<
> >>> >>
> >>> >> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
> >>> >> URL:
> >>> >>
> >>> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=266496&r1=266495&r2=266496&view=diff
> >>> >>
> >>> >>
> >>> >>
> ==
> >>> >> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
> >>> >> +++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Apr 15 19:11:11 2016
> >>> >> @@ -4118,11 +4118,14 @@ void Linux::AddCudaIncludeArgs(const Arg
> >>> >>if (DriverArgs.hasArg(options::OPT_nocudainc))
> >>> >>  return;
> >>> >>
> >>> >> -  if (CudaInstallation.isValid()) {
> >>> >> -addSystemInclude(DriverArgs, CC1Args,
> >>> >> CudaInstallation.getIncludePath());
> >>> >> -CC1Args.push_back("-include");
> >>> >> -CC1Args.push_back("__clang_cuda_runtime_wrapper.h");
> >>> >> +  if (!CudaInstallation.isValid()) {
> >>> >> +getDriver().Diag(diag::err_drv_no_cuda_installation);
> >>> >> +return;
> >>> >>}
> >>> >> 

[PATCH] D19299: lower __builtin_expect() directly to prof metadata instead of LLVM intrinsic

2016-04-19 Thread Sanjay Patel via cfe-commits
spatel created this revision.
spatel added reviewers: hfinkel, davidxl, bkramer.
spatel added a subscriber: cfe-commits.
Herald added subscribers: mcrosier, aemerson.

__builtin_expect() is a GCC-derived builtin that's used as a hint for branch 
prediction:
https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html

The Clang/LLVM implementation of this feature introduced an LLVM intrinsic to 
convey the hint to the optimizer:
https://marc.info/?l=llvm-commits&m=130997676129580&w=4

There are problems with this (and several were noted in the above thread, but 
it didn't change the outcome):
1. We created an intrinsic to improve perf, but the intrinsic can harm 
optimization by interfering with other passes.

2. To solve that, create a pass to always transform the intrinsic into metadata 
at a very early stage. But now every program is paying a compile-time tax for a 
feature that is rarely used.

3. The IR lowering uses profile weight metadata as the means for conveying the 
hint. But the hint is meant to be a programmer override for profile data. That 
is, "I don't care what the profile says; I want my code to use this 
source-level hint." So it should use a different kind of metadata, not profile 
weight. We added the inverse programmer hint as metadata - 
__builtin_unpredictable():
http://llvm.org/docs/LangRef.html#unpredictable-metadata
http://reviews.llvm.org/D12341
so I think we can enhance that to solve this problem.

This patch is an intermediate step. It doesn't try to solve #3 above, but it 
handles #1 and clears the way to deprecate the llvm.expect intrinsic and delete 
the LowerExpectIntrinsic pass (problem #2).

This is part of solving:
https://llvm.org/bugs/show_bug.cgi?id=27344
But to complete that, we need to make changes in SimplifyCFG and possibly other 
places, so that we're propagating and using the expect/unpredictable metadata 
as intended. Ref: D18133, D18220, rL264527, rL266442


http://reviews.llvm.org/D19299

Files:
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CodeGenFunction.cpp
  test/CodeGen/builtin-expect.c

Index: test/CodeGen/builtin-expect.c
===
--- test/CodeGen/builtin-expect.c
+++ test/CodeGen/builtin-expect.c
@@ -1,13 +1,15 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -O1 -disable-llvm-optzns | FileCheck %s --check-prefix=ALL --check-prefix=O1
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -O0 | FileCheck %s --check-prefix=ALL --check-prefix=O0
 
-// In all tests, make sure that no expect is generated if optimizations are off.
-// If optimizations are on, generate the correct expect and preserve other necessary operations.
+// In all tests, make sure that the builtin is gone.
+// If optimizations are on, generate the correct expect metadata and preserve other necessary operations.
+// If optimizations are off, no expect metadata is generated but other operations should be preserved.
 
 int expect_taken(int x) {
 // ALL-LABEL: define i32 @expect_taken
-// O1:call i64 @llvm.expect.i64(i64 {{%.*}}, i64 1)
-// O0-NOT:@llvm.expect
+// ALL-NOT:   builtin_expect
+// O1:!prof [[BR_TRUE_METADATA:.+]]
+// O0-NOT:!prof
 
   if (__builtin_expect (x, 1))
 return 0;
@@ -17,8 +19,9 @@
 
 int expect_not_taken(int x) {
 // ALL-LABEL: define i32 @expect_not_taken
-// O1:call i64 @llvm.expect.i64(i64 {{%.*}}, i64 0)
-// O0-NOT:@llvm.expect
+// ALL-NOT:   builtin_expect
+// O1:!prof [[BR_FALSE_METADATA:.+]]
+// O0-NOT:!prof
 
   if (__builtin_expect (x, 0))
 return 0;
@@ -33,9 +36,10 @@
 void expect_value_side_effects() {
 // ALL-LABEL: define void @expect_value_side_effects()
 // ALL:   [[CALL:%.*]] = call i32 @y
+// ALL-NOT:   builtin_expect
 // O1:[[SEXT:%.*]] = sext i32 [[CALL]] to i64
-// O1:call i64 @llvm.expect.i64(i64 {{%.*}}, i64 [[SEXT]])
-// O0-NOT:@llvm.expect
+// O1:!prof [[BR_TRUE_METADATA:.+]]
+// O0-NOT:!prof
 
   if (__builtin_expect (x, y()))
 foo ();
@@ -52,17 +56,18 @@
 // ALL-LABEL: define i32 @main()
 // ALL:   call void @isigprocmask()
 // ALL:   [[CALL:%.*]] = call i64 (...) @bar()
-// O1:call i64 @llvm.expect.i64(i64 0, i64 [[CALL]])
-// O0-NOT:@llvm.expect
+// ALL-NOT:   builtin_expect
+// ALL-NOT:   !prof
 
   (void) __builtin_expect((isigprocmask(), 0), bar());
 }
 
 
 int switch_cond(int x) {
 // ALL-LABEL: define i32 @switch_cond
-// O1:call i64 @llvm.expect.i64(i64 {{%.*}}, i64 5)
-// O0-NOT:@llvm.expect
+// ALL-NOT:   builtin_expect
+// O1:!prof [[SWITCH_METADATA:.+]]
+// O0-NOT:!prof
 
   switch(__builtin_expect(x, 5)) {
   default:
@@ -78,3 +83,7 @@
   return 0;
 }
 
+// O1: [[BR_TRUE_METADATA]] = !{!"branch_weights", i32 64, i32 4}
+// O1: [[BR_FALSE_METADATA]] = !{!"branch_weights", i32 4, i32 64}
+// O1: [[SWITCH_METADATA]] = !{!"branch_weights", i32 4, i32 4, i32 4, i32 4, i32 64}
+
In

Re: [PATCH] D19146: [clang-tidy] New checker to detect suspicious string constructor.

2016-04-19 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good with a nit.

In http://reviews.llvm.org/D19146#403234, @alexfh wrote:

> In http://reviews.llvm.org/D19146#402414, @alexfh wrote:
>
> > In http://reviews.llvm.org/D19146#402410, @alexfh wrote:
> >
> > > I wonder whether `misc-swapped-arguments` can be tuned to handle these 
> > > cases in a more generic way? The only missing part so far seems to be the 
> > > lack of `cxxConstructExpr` support.
> >
> >
> > And by "these cases" I mean the swapped arguments mistake, not the more 
> > string-specific ones.
>
>
> What about this comment?


As per offline discussion, there might be value in having the check for swapped 
std::string ctor arguments here, since this specialized check is likely to have 
much lower false positive rate than the more generic misc-swapped-arguments 
check.



Comment at: clang-tidy/misc/StringConstructorCheck.cpp:116
@@ +115,3 @@
+  } else if (Result.Nodes.getNodeAs("literal-with-length")) {
+const auto *S = Result.Nodes.getNodeAs("str");
+const auto *L = Result.Nodes.getNodeAs("int");

`S` and `L` are neither descriptive nor seem to be a commonly used name for 
this purpose. Can you expand variable names a bit?


http://reviews.llvm.org/D19146



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


Re: [PATCH] D18703: [clang-tidy] Add new checker for comparison with runtime string functions.

2016-04-19 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good with a couple of nits. Thank you!



Comment at: clang-tidy/misc/SuspiciousStringCompareCheck.cpp:25
@@ +24,3 @@
+
+static const char *KnownStringCompareFunctions = "__builtin_memcmp;"
+ "__builtin_strcasecmp;"

The variable is not const right now. I recently started preferring the 
`constexpr char X[] = ...` way of defining string constants.


Comment at: clang-tidy/misc/SuspiciousStringCompareCheck.cpp:108
@@ +107,3 @@
+  std::vector FuntionNames;
+  ParseFunctionNames(KnownStringCompareFunctions, &FuntionNames);
+  ParseFunctionNames(StringCompareLikeFunctions, &FuntionNames);

nit: FuntionNames -> FunctionNames


http://reviews.llvm.org/D18703



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


Re: [PATCH] D19200: [clang-tidy] Cleanup some ast-matchers and lift some to utils.

2016-04-19 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good! Thank you for the cleanup!


http://reviews.llvm.org/D19200



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


[PATCH] D19295: [profile] Clang support for memory-mapping profile counters

2016-04-19 Thread Vedant Kumar via cfe-commits
vsk created this revision.
vsk added a reviewer: davidxl.
vsk added a subscriber: cfe-commits.

**Summary**

Using memory-mapped profile counters makes it possible to take snapshots of a 
running process's profiling information without changing the program. This is 
useful if the process exits abnormally, or if profiling data needs to be 
collected periodically.

Add the clang support required to create instrumented programs which memory-map 
their counters directly onto a raw profile.

**More details**

This patch teaches clang to page-align the __llvm_prf_counts section (just on 
Darwin, initially). Because clang only knows the host system's page size -- not 
the target system's -- this is a best-effort attempt. If the instrumented 
program detects that the counters section has the wrong alignment, it will 
disable the memory-mapped counters feature.

I can add support for other platforms and linkers in follow-up patches.

Depends on: http://reviews.llvm.org/D19293 (llvm)

http://reviews.llvm.org/D19295

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  test/Driver/instrprof-ld.c

Index: test/Driver/instrprof-ld.c
===
--- test/Driver/instrprof-ld.c
+++ test/Driver/instrprof-ld.c
@@ -73,38 +73,43 @@
 //
 // CHECK-DARWIN-X86-64: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-DARWIN-X86-64: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}darwin{{/|}}libclang_rt.profile_osx.a"
+// CHECK-DARWIN-X86-64: "-sectalign" "__DATA" "__llvm_prf_cnts" "0x{{[0-9a-f]+}}"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-apple-darwin14 -fprofile-instr-generate -nostdlib \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN:   | FileCheck --check-prefix=CHECK-DARWIN-NOSTDLIB-X86-64 %s
 //
 // CHECK-DARWIN-NOSTDLIB-X86-64: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-DARWIN-NOSTDLIB-X86-64: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}darwin{{/|}}libclang_rt.profile_osx.a"
+// CHECK-DARWIN-NOSTDLIB-X86-64: "-sectalign" "__DATA" "__llvm_prf_cnts" "0x{{[0-9a-f]+}}"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target arm64-apple-ios -fprofile-instr-generate \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN:   | FileCheck --check-prefix=CHECK-DARWIN-ARM64 %s
 //
 // CHECK-DARWIN-ARM64: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-DARWIN-ARM64: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}darwin{{/|}}libclang_rt.profile_ios.a"
+// CHECK-DARWIN-ARM64-X86-64: "-sectalign" "__DATA" "__llvm_prf_cnts" "0x{{[0-9a-f]+}}"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target armv7-apple-darwin -mtvos-version-min=8.3 -fprofile-instr-generate \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN:   | FileCheck --check-prefix=CHECK-TVOS-ARMV7 %s
 //
 // CHECK-TVOS-ARMV7: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-TVOS-ARMV7: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}darwin{{/|}}libclang_rt.profile_tvos.a"
+// CHECK-TVOS-ARMV7: "-sectalign" "__DATA" "__llvm_prf_cnts" "0x{{[0-9a-f]+}}"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target armv7s-apple-darwin10 -mwatchos-version-min=2.0 -arch armv7k -fprofile-instr-generate \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN:   | FileCheck --check-prefix=CHECK-WATCHOS-ARMV7 %s
 //
 // CHECK-WATCHOS-ARMV7: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-WATCHOS-ARMV7: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}darwin{{/|}}libclang_rt.profile_watchos.a"
+// CHECK-WATCHOS-ARMV7: "-sectalign" "__DATA" "__llvm_prf_cnts" "0x{{[0-9a-f]+}}"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target i386-pc-win32 -fprofile-instr-generate \
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -7583,7 +7583,7 @@
   if (Args.hasArg(options::OPT_fnested_functions))
 CmdArgs.push_back("-allow_stack_execute");
 
-  getMachOToolChain().addProfileRTLibs(Args, CmdArgs);
+  getMachOToolChain().addProfileRTOpts(Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 if (getToolChain().getDriver().CCCIsCXX())
@@ -7779,7 +7779,7 @@
   }
   CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath("crtn.o")));
 
-  getToolChain().addProfileRTLibs(Args, CmdArgs);
+  getToolChain().addProfileRTOpts(Args, CmdArgs);
 
   const char *Exec = Args.MakeArgString(getToolChain().GetLinkerPath());
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
@@ -8384,7 +8384,7 @@
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o")));
   }
 
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
+  ToolChain.addProfileRTOpts(Arg

r266829 - [Parse] Reuse OptionUnroll rather than matching it again. NFC

2016-04-19 Thread Adam Nemet via cfe-commits
Author: anemet
Date: Tue Apr 19 17:29:24 2016
New Revision: 266829

URL: http://llvm.org/viewvc/llvm-project?rev=266829&view=rev
Log:
[Parse] Reuse OptionUnroll rather than matching it again. NFC

Modified:
cfe/trunk/lib/Parse/ParsePragma.cpp

Modified: cfe/trunk/lib/Parse/ParsePragma.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParsePragma.cpp?rev=266829&r1=266828&r2=266829&view=diff
==
--- cfe/trunk/lib/Parse/ParsePragma.cpp (original)
+++ cfe/trunk/lib/Parse/ParsePragma.cpp Tue Apr 19 17:29:24 2016
@@ -824,8 +824,7 @@ bool Parser::HandlePragmaLoopHint(LoopHi
 StateOption = llvm::StringSwitch(OptionInfo->getName())
   .Case("vectorize", true)
   .Case("interleave", true)
-  .Case("unroll", true)
-  .Default(false);
+  .Default(false) || OptionUnroll;
   }
 
   // Verify loop hint has an argument.


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


r266827 - [Parse] Use StringSwitch to improve readability. NFC

2016-04-19 Thread Adam Nemet via cfe-commits
Author: anemet
Date: Tue Apr 19 17:17:45 2016
New Revision: 266827

URL: http://llvm.org/viewvc/llvm-project?rev=266827&view=rev
Log:
[Parse] Use StringSwitch to improve readability. NFC

A subsequent patch will propose a "distribute" loop hint.  Similarly to
unroll, this does not have a "assume_safety" argument either so this
condition will get more complex.

Modified:
cfe/trunk/lib/Parse/ParsePragma.cpp

Modified: cfe/trunk/lib/Parse/ParsePragma.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParsePragma.cpp?rev=266827&r1=266826&r2=266827&view=diff
==
--- cfe/trunk/lib/Parse/ParsePragma.cpp (original)
+++ cfe/trunk/lib/Parse/ParsePragma.cpp Tue Apr 19 17:17:45 2016
@@ -841,10 +841,14 @@ bool Parser::HandlePragmaLoopHint(LoopHi
 ConsumeToken(); // The annotation token.
 SourceLocation StateLoc = Toks[0].getLocation();
 IdentifierInfo *StateInfo = Toks[0].getIdentifierInfo();
-if (!StateInfo ||
-(!StateInfo->isStr("enable") && !StateInfo->isStr("disable") &&
- ((OptionUnroll && !StateInfo->isStr("full")) ||
-  (!OptionUnroll && !StateInfo->isStr("assume_safety") {
+
+bool Valid = StateInfo &&
+ llvm::StringSwitch(StateInfo->getName())
+ .Cases("enable", "disable", true)
+ .Case("full", OptionUnroll)
+ .Case("assume_safety", !OptionUnroll)
+ .Default(false);
+if (!Valid) {
   Diag(Toks[0].getLocation(), diag::err_pragma_invalid_keyword)
   << /*FullKeyword=*/OptionUnroll;
   return false;


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


Re: [PATCH] D18624: [PGO] PGOFuncName meta data if PGOFuncName is different from function's raw name.

2016-04-19 Thread Adam Nemet via cfe-commits
anemet added a comment.

Sure, I'll try.

Also sounds like you are missing a test in this patch that fails with the old 
version but passes with the new?!


http://reviews.llvm.org/D18624



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


Re: [PATCH] D18624: [PGO] PGOFuncName meta data if PGOFuncName is different from function's raw name.

2016-04-19 Thread Rong Xu via cfe-commits
xur updated this revision to Diff 54275.
xur added a comment.

Previous patch was bad (as David noticed) -- we might not annotate all the 
functions that we interested.

This updated patch should work.

BTW, I got the following promotions for 453.provay:

LLVM gold plugin: csg.cpp:157:15: Promote indirect call to 
_ZN3povL23All_Plane_IntersectionsEPNS_13Object_StructEPNS_10Ray_StructEPNS_13istack_structE
 with count 1654869 out of 1695169
LLVM gold plugin: csg.cpp:157:15: Promote indirect call to 
_ZN3povL31All_CSG_Intersect_IntersectionsEPNS_13Object_StructEPNS_10Ray_StructEPNS_13istack_structE
 with count 40300 out of 40300
LLVM gold plugin: csg.cpp:252:11: Promote indirect call to 
_ZN3povL24All_Sphere_IntersectionsEPNS_13Object_StructEPNS_10Ray_StructEPNS_13istack_structE
 with count 72389427 out of 132687016
LLVM gold plugin: csg.cpp:252:11: Promote indirect call to 
_ZN3povL23All_Plane_IntersectionsEPNS_13Object_StructEPNS_10Ray_StructEPNS_13istack_structE
 with count 44987633 out of 60297589
LLVM gold plugin: lighting.cpp:828:11: Promote indirect call to 
_ZN3povL31All_CSG_Intersect_IntersectionsEPNS_13Object_StructEPNS_10Ray_StructEPNS_13istack_structE
 with count 271222 out of 581624
LLVM gold plugin: lighting.cpp:828:11: Promote indirect call to 
_ZN3povL27All_Ellipsoid_IntersectionsEPNS_13Object_StructEPNS_10Ray_StructEPNS_13istack_structE
 with count 220561 out of 310402
LLVM gold plugin: objects.cpp:111:7: Promote indirect call to 
_ZN3povL31All_CSG_Intersect_IntersectionsEPNS_13Object_StructEPNS_10Ray_StructEPNS_13istack_structE
 with count 14382553 out of 16537858
LLVM gold plugin: objects.cpp:111:7: Promote indirect call to 
_ZN3povL23All_Plane_IntersectionsEPNS_13Object_StructEPNS_10Ray_StructEPNS_13istack_structE
 with count 1489615 out of 2155305
LLVM gold plugin: objects.cpp:175:11: Promote indirect call to 
_ZN3povL12Inside_PlaneEPdPNS_13Object_StructE with count 50136636 out of 
70129039
LLVM gold plugin: objects.cpp:175:11: Promote indirect call to 
_ZN3povL14Inside_QuadricEPdPNS_13Object_StructE with count 16280600 out of 
19992403
LLVM gold plugin: render.cpp:3579:9: Promote indirect call to 
_ZN3povL23Inside_CSG_IntersectionEPdPNS_13Object_StructE with count 4065174 out 
of 4516860
LLVM gold plugin: render.cpp:3579:9: Promote indirect call to 
_ZN3povL12Inside_PlaneEPdPNS_13Object_StructE with count 451686 out of 451686
LLVM gold plugin: spec_qsort.cpp:38:14: Promote indirect call to 
_ZN3povL9compboxesEPvS0_ with count 9339 out of 9339
LLVM gold plugin: textstreambuffer.cpp:278:4: Promote indirect call to 
_ZN12pov_frontend21DefaultRenderFrontend19DefaultStreamBuffer12directoutputEPKcj
 with count 9922 out of 9924
LLVM gold plugin: textstreambuffer.cpp:237:4: Promote indirect call to 
_ZN12pov_frontend21DefaultRenderFrontend19DefaultStreamBuffer10lineoutputEPKcj 
with count 9922 out of 9924

Adam: Could you try again?

Thanks,

-Rong


http://reviews.llvm.org/D18624

Files:
  lib/CodeGen/CodeGenPGO.cpp

Index: lib/CodeGen/CodeGenPGO.cpp
===
--- lib/CodeGen/CodeGenPGO.cpp
+++ lib/CodeGen/CodeGenPGO.cpp
@@ -43,6 +43,9 @@
 
 void CodeGenPGO::setFuncName(llvm::Function *Fn) {
   setFuncName(Fn->getName(), Fn->getLinkage());
+  // Create PGOFuncName meta data.
+  if (!llvm::getPGOFuncNameMetadata(*Fn))
+llvm::createPGOFuncNameMetadata(*Fn);
 }
 
 namespace {


Index: lib/CodeGen/CodeGenPGO.cpp
===
--- lib/CodeGen/CodeGenPGO.cpp
+++ lib/CodeGen/CodeGenPGO.cpp
@@ -43,6 +43,9 @@
 
 void CodeGenPGO::setFuncName(llvm::Function *Fn) {
   setFuncName(Fn->getName(), Fn->getLinkage());
+  // Create PGOFuncName meta data.
+  if (!llvm::getPGOFuncNameMetadata(*Fn))
+llvm::createPGOFuncNameMetadata(*Fn);
 }
 
 namespace {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19270: Fix a crash in cppcoreguidelines-pro-type-member-init related to missing constructor bodies.

2016-04-19 Thread Michael Miller via cfe-commits
michael_miller added a comment.

In http://reviews.llvm.org/D19270#405805, @alexfh wrote:

> LG. Do you need me to submit the patch?


Yeah, that's be awesome—thanks!


http://reviews.llvm.org/D19270



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


Re: [PATCH] D19270: Fix a crash in cppcoreguidelines-pro-type-member-init related to missing constructor bodies.

2016-04-19 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

LG. Do you need me to submit the patch?


http://reviews.llvm.org/D19270



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


Re: [PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit

2016-04-19 Thread Derek Schuff via cfe-commits
dschuff updated this revision to Diff 54274.
dschuff marked 2 inline comments as done.
dschuff added a comment.

- Clean up condition, add ARM to test
- Clarify condition, remove redundant check
- more cleanup


http://reviews.llvm.org/D19275

Files:
  lib/CodeGen/CGDeclCXX.cpp
  test/CodeGenCXX/runtimecc.cpp
  test/CodeGenCXX/static-destructor.cpp

Index: test/CodeGenCXX/static-destructor.cpp
===
--- /dev/null
+++ test/CodeGenCXX/static-destructor.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck 
--check-prefix=X86 %s
+// RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck 
--check-prefix=WASM %s
+// RUN: %clang_cc1 %s -triple=armv7-apple-darwin9 -emit-llvm -o - | FileCheck 
--check-prefix=WASM %s
+
+// Test that destructors are not passed directly to __cxa_atexit when their
+// signatures do not match the type of its first argument.
+// e.g. ARM and WebAssembly have destructors that return this instead of void.
+
+
+class Foo {
+ public:
+  ~Foo() {
+  }
+};
+
+Foo global;
+
+// X86 destructors have void return, and are registered directly with 
__cxa_atexit.
+// X86: define internal void @__cxx_global_var_init()
+// X86-NEXT: entry:
+// X86-NEXT:   %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (void 
(%class.Foo*)* @_ZN3FooD1Ev to void (i8*)*), i8* getelementptr inbounds 
(%class.Foo, %class.Foo* @global, i32 0, i32 0), i8* @__dso_handle)
+
+// Wasm destructors return this, and use a wrapper function, which is 
registered
+// with __cxa_atexit.
+// WASM: define internal void @__cxx_global_var_init()
+// WASM-NEXT: entry:
+// WASM-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* 
@__cxx_global_array_dtor, i8* null, i8* @__dso_handle)
+
+// WASM: define internal void @__cxx_global_array_dtor(i8*)
+// WASM: %call = call %class.Foo* @_ZN3FooD1Ev(%class.Foo* @global)
Index: test/CodeGenCXX/runtimecc.cpp
===
--- test/CodeGenCXX/runtimecc.cpp
+++ test/CodeGenCXX/runtimecc.cpp
@@ -22,8 +22,13 @@
   A global;
 // CHECK-LABEL:define internal void @__cxx_global_var_init()
 // CHECK:  call [[A]]* @_ZN5test01AC1Ev([[A]]* @_ZN5test06globalE)
-// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* bitcast ([[A]]* ([[A]]*)* 
@_ZN5test01AD1Ev to void (i8*)*), i8* bitcast ([[A]]* @_ZN5test06globalE to 
i8*), i8* @__dso_handle) [[NOUNWIND:#[0-9]+]]
+// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* @__cxx_global_array_dtor, 
i8* null, i8* @__dso_handle) [[NOUNWIND:#[0-9]+]]
 // CHECK-NEXT: ret void
+
+// CHECK-LABEL: define internal void @__cxx_global_array_dtor(i8*)
+// CHECK: call [[A]]* @_ZN5test01AD1Ev([[A]]* @_ZN5test06globalE)
+// CHECK-NEXT: ret void
+
 }
 
 // CHECK: declare i32 @__cxa_atexit(void (i8*)*, i8*, i8*) [[NOUNWIND]]
Index: lib/CodeGen/CGDeclCXX.cpp
===
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -86,13 +86,20 @@
   llvm::Constant *function;
   llvm::Constant *argument;
 
-  // Special-case non-array C++ destructors, where there's a function
-  // with the right signature that we can just call.
-  const CXXRecordDecl *record = nullptr;
-  if (dtorKind == QualType::DK_cxx_destructor &&
-  (record = type->getAsCXXRecordDecl())) {
-assert(!record->hasTrivialDestructor());
-CXXDestructorDecl *dtor = record->getDestructor();
+  // Special-case non-array C++ destructors, if they have the right signature.
+  // Under some ABIs, destructors return this instead of void, and cannot be
+  // passed directly to __cxa_atexit.
+  const CXXRecordDecl *Record = type->getAsCXXRecordDecl();
+  bool CanRegisterDestructor = Record &&
+   !CGM.getCXXABI().HasThisReturn(GlobalDecl(
+   Record->getDestructor(), Dtor_Complete));
+  // If __cxa_atexit is disabled via a flag, a different helper function is
+  // generated elsewhere which uses atexit instead, and it takes the destructor
+  // directly.
+  bool UsingExternalHelper = !CGM.getCodeGenOpts().CXAAtExit;
+  if (Record && (CanRegisterDestructor || UsingExternalHelper)) {
+assert(!Record->hasTrivialDestructor());
+CXXDestructorDecl *dtor = Record->getDestructor();
 
 function = CGM.getAddrOfCXXStructor(dtor, StructorType::Complete);
 argument = llvm::ConstantExpr::getBitCast(


Index: test/CodeGenCXX/static-destructor.cpp
===
--- /dev/null
+++ test/CodeGenCXX/static-destructor.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck --check-prefix=X86 %s
+// RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck --check-prefix=WASM %s
+// RUN: %clang_cc1 %s -triple=armv7-apple-darwin9 -emit-llvm -o - | FileCheck --check-prefix=WASM %s
+
+// Test that destructors are not passed directly to __cxa_atexit when their

Re: [PATCH] D18136: boost-use-to-string check

2016-04-19 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: test/clang-tidy/boost-use-to-string.cpp:2
@@ +1,3 @@
+// RUN: %check_clang_tidy %s boost-use-to-string %t
+
+

nit: Remove one empty line.


http://reviews.llvm.org/D18136



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


Re: [PATCH] D18136: boost-use-to-string check

2016-04-19 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

FYI, an alternative fix has been submitted in http://reviews.llvm.org/D19231. 
Please check whether it fixes the issue.


http://reviews.llvm.org/D18136



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


Re: [PATCH] D19144: Handle TemplateArgument in DynTypedNode comparison operations.

2016-04-19 Thread Alexander Kornienko via cfe-commits
alexfh abandoned this revision.
alexfh added a comment.

Ok, let's drop this on the floor.


http://reviews.llvm.org/D19144



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


Re: [PATCH] D19278: [scan-build] fix logic error warnings emitted on clang code base

2016-04-19 Thread Apelete Seketeli via cfe-commits
apelete marked an inline comment as done.
apelete added a comment.

http://reviews.llvm.org/D19278



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


Re: [PATCH] D19278: [scan-build] fix logic error warnings emitted on clang code base

2016-04-19 Thread Apelete Seketeli via cfe-commits
apelete updated this revision to Diff 54269.
apelete added a comment.

[scan-build] fix logic error warnings emitted on clang code base

Following changes were done since last revision:

- lib/Sema/SemaOverload.cpp: avoid interleaving (FromExpr) and 
(!FromExpr->isLValue()) conditions in if() statement for better readability.


http://reviews.llvm.org/D19278

Files:
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/SemaOverload.cpp
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp

Index: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -693,6 +693,8 @@
 !Param->getType()->isReferenceType())
   continue;
 
+assert(ArgExpr && "cannot get the type of a NULL expression");
+
 NullConstraint Nullness = getNullConstraint(*ArgSVal, State);
 
 Nullability RequiredNullability =
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -8705,6 +8705,7 @@
 
 void Sema::diagnoseEquivalentInternalLinkageDeclarations(
 SourceLocation Loc, const NamedDecl *D, ArrayRef Equiv) {
+  assert(D && "named declaration must be not NULL");
   Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D;
 
   Module *M = getOwningModule(const_cast(D));
@@ -9185,7 +9186,9 @@
 !ToRefTy->getPointeeType()->isIncompleteType() &&
 S.IsDerivedFrom(SourceLocation(), ToRefTy->getPointeeType(), FromTy)) {
   BaseToDerivedConversion = 3;
-} else if (ToTy->isLValueReferenceType() && !FromExpr->isLValue() &&
+} else if (FromExpr &&
+   !FromExpr->isLValue() &&
+   ToTy->isLValueReferenceType() &&
ToTy.getNonReferenceType().getCanonicalType() ==
FromTy.getNonReferenceType().getCanonicalType()) {
   S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_lvalue)
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -939,6 +939,7 @@
 (VD && DSAStack->isForceVarCapturing()))
   return VD ? VD : Info.second;
 auto DVarPrivate = DSAStack->getTopDSA(D, DSAStack->isClauseParsingMode());
+assert(DVarPrivate.PrivateCopy && "DSAStackTy object must be not NULL");
 if (DVarPrivate.CKind != OMPC_unknown && isOpenMPPrivate(DVarPrivate.CKind))
   return VD ? VD : cast(DVarPrivate.PrivateCopy->getDecl());
 DVarPrivate = DSAStack->hasDSA(D, isOpenMPPrivate, MatchesAlways(),
@@ -3924,6 +3925,7 @@
 static ExprResult
 tryBuildCapture(Sema &SemaRef, Expr *Capture,
 llvm::MapVector &Captures) {
+  assert(Capture && "cannot build capture if expression is NULL");
   if (Capture->isEvaluatable(SemaRef.Context, Expr::SE_AllowSideEffects))
 return SemaRef.PerformImplicitConversion(
 Capture->IgnoreImpCasts(), Capture->getType(), Sema::AA_Converting,
@@ -4177,7 +4179,7 @@
 SemaRef.Diag(CollapseLoopCountExpr->getExprLoc(),
  diag::note_omp_collapse_ordered_expr)
 << 0 << CollapseLoopCountExpr->getSourceRange();
-  else
+  else if (OrderedLoopCountExpr)
 SemaRef.Diag(OrderedLoopCountExpr->getExprLoc(),
  diag::note_omp_collapse_ordered_expr)
 << 1 << OrderedLoopCountExpr->getSourceRange();
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -434,6 +434,9 @@
 /// error, false otherwise.
 bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old,
 Scope *S) {
+  assert(New && "New function declaration is NULL, aborting merge.");
+  assert(Old && "Old function declaration is NULL, aborting merge.");
+
   bool Invalid = false;
 
   // The declaration context corresponding to the scope is the semantic
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -2303,6 +2303,7 @@
 
 unsigned CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D,
  unsigned AddrSpace) {
+  assert(D && "variable declaration must be not NULL");
   if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {
 if (D->hasAttr())
   AddrSpace = getContext().getTargetAddressSpace(LangAS::cuda_constant);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -1312,6 +1312,7 @@
 CGM.getContext().toCharUnitsFromBits((int6

Re: [PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit

2016-04-19 Thread JF Bastien via cfe-commits
jfb added a comment.

lgtm besides two nits. Would be good to get a review from @t.p.northover or 
someone from ARM.



Comment at: lib/CodeGen/CGDeclCXX.cpp:95
@@ +94,3 @@
+   Record->getDestructor(), Dtor_Complete));
+  // If __cxa_atexit is disabled via a flag, a different helper function is
+  // generated elsewhere which uses atexit instead, and it takes the destructor

Connecting the dots between "the right signature" and "has this return" isn't 
obvious IMO.


Comment at: lib/CodeGen/CGDeclCXX.cpp:100
@@ +99,3 @@
+  if (Record &&
+  (CanRegisterDestructor || UsingExternalHelper)) {
+assert(!Record->hasTrivialDestructor());

clang-format


http://reviews.llvm.org/D19275



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


Re: [PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit

2016-04-19 Thread Derek Schuff via cfe-commits
dschuff added inline comments.


Comment at: lib/CodeGen/CGDeclCXX.cpp:92
@@ +91,3 @@
+  // disabled via a flag, a different helper function is generated anyway.
+  const CXXRecordDecl *Record = type->getAsCXXRecordDecl();
+  bool CanRegisterDestructor = Record &&

jfb wrote:
> Can you do that unconditionally? Or do you have to test for `dtorKind == 
> QualType::DK_cxx_destructor` first? It looks like the function already does a 
> `dyncast_or_null` so the previous code was doing a check it didn't need to.
Yes, that's why I made it unconditional. And actually I just noticed that the 
switch statement above returns from the function if `dtorKind != 
DK_cxx_destructor` anyway, so I removed the check here too.


Comment at: lib/CodeGen/CGDeclCXX.cpp:95
@@ +94,3 @@
+   !CGM.getCXXABI().HasThisReturn(GlobalDecl(
+   Record->getDestructor(), Dtor_Complete));
+

jfb wrote:
> Comment on why you can't register dtor when has this return (ABI mismatch).
Doesn't the new text in the comment right above on line 98 cover that?


Comment at: lib/CodeGen/CGDeclCXX.cpp:97
@@ +96,3 @@
+
+  if (dtorKind == QualType::DK_cxx_destructor && Record &&
+  (CanRegisterDestructor || !CGM.getCodeGenOpts().CXAAtExit)) {

jfb wrote:
> Do you need to check `Record` here? Doesn't it also imply `dtorKind == 
> QualType::DK_cxx_destructor`?
Yes, there can be a case where `Record` is nullptr and 
`CGM.getCodeGenOpts().CXAAtExit` is false.


Comment at: lib/CodeGen/CGDeclCXX.cpp:98
@@ +97,3 @@
+  if (dtorKind == QualType::DK_cxx_destructor && Record &&
+  (CanRegisterDestructor || !CGM.getCodeGenOpts().CXAAtExit)) {
+assert(!Record->hasTrivialDestructor());

jfb wrote:
> ` || !CGM.getCodeGenOpts().CXAAtExit` seems wrong here. Shouldn't the 
> condition be `CanRegisterDestructor && CGM.getCodeGenOpts().CXAAtExit`? I may 
> be misunderstanding...
I split and expanded the comment and made a variable with a name. See if it 
makes more sense now.


http://reviews.llvm.org/D19275



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


Re: [PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit

2016-04-19 Thread Derek Schuff via cfe-commits
dschuff updated this revision to Diff 54264.
dschuff added a comment.

- Clarify condition, remove redundant check


http://reviews.llvm.org/D19275

Files:
  lib/CodeGen/CGDeclCXX.cpp
  test/CodeGenCXX/runtimecc.cpp
  test/CodeGenCXX/static-destructor.cpp

Index: test/CodeGenCXX/static-destructor.cpp
===
--- /dev/null
+++ test/CodeGenCXX/static-destructor.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck 
--check-prefix=X86 %s
+// RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck 
--check-prefix=WASM %s
+// RUN: %clang_cc1 %s -triple=armv7-apple-darwin9 -emit-llvm -o - | FileCheck 
--check-prefix=WASM %s
+
+// Test that destructors are not passed directly to __cxa_atexit when their
+// signatures do not match the type of its first argument.
+// e.g. ARM and WebAssembly have destructors that return this instead of void.
+
+
+class Foo {
+ public:
+  ~Foo() {
+  }
+};
+
+Foo global;
+
+// X86 destructors have void return, and are registered directly with 
__cxa_atexit.
+// X86: define internal void @__cxx_global_var_init()
+// X86-NEXT: entry:
+// X86-NEXT:   %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (void 
(%class.Foo*)* @_ZN3FooD1Ev to void (i8*)*), i8* getelementptr inbounds 
(%class.Foo, %class.Foo* @global, i32 0, i32 0), i8* @__dso_handle)
+
+// Wasm destructors return this, and use a wrapper function, which is 
registered
+// with __cxa_atexit.
+// WASM: define internal void @__cxx_global_var_init()
+// WASM-NEXT: entry:
+// WASM-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* 
@__cxx_global_array_dtor, i8* null, i8* @__dso_handle)
+
+// WASM: define internal void @__cxx_global_array_dtor(i8*)
+// WASM: %call = call %class.Foo* @_ZN3FooD1Ev(%class.Foo* @global)
Index: test/CodeGenCXX/runtimecc.cpp
===
--- test/CodeGenCXX/runtimecc.cpp
+++ test/CodeGenCXX/runtimecc.cpp
@@ -22,8 +22,13 @@
   A global;
 // CHECK-LABEL:define internal void @__cxx_global_var_init()
 // CHECK:  call [[A]]* @_ZN5test01AC1Ev([[A]]* @_ZN5test06globalE)
-// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* bitcast ([[A]]* ([[A]]*)* 
@_ZN5test01AD1Ev to void (i8*)*), i8* bitcast ([[A]]* @_ZN5test06globalE to 
i8*), i8* @__dso_handle) [[NOUNWIND:#[0-9]+]]
+// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* @__cxx_global_array_dtor, 
i8* null, i8* @__dso_handle) [[NOUNWIND:#[0-9]+]]
 // CHECK-NEXT: ret void
+
+// CHECK-LABEL: define internal void @__cxx_global_array_dtor(i8*)
+// CHECK: call [[A]]* @_ZN5test01AD1Ev([[A]]* @_ZN5test06globalE)
+// CHECK-NEXT: ret void
+
 }
 
 // CHECK: declare i32 @__cxa_atexit(void (i8*)*, i8*, i8*) [[NOUNWIND]]
Index: lib/CodeGen/CGDeclCXX.cpp
===
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -86,13 +86,20 @@
   llvm::Constant *function;
   llvm::Constant *argument;
 
-  // Special-case non-array C++ destructors, where there's a function
-  // with the right signature that we can just call.
-  const CXXRecordDecl *record = nullptr;
-  if (dtorKind == QualType::DK_cxx_destructor &&
-  (record = type->getAsCXXRecordDecl())) {
-assert(!record->hasTrivialDestructor());
-CXXDestructorDecl *dtor = record->getDestructor();
+  // Special-case non-array C++ destructors, if they have the right signature
+  // that can be directly registered with __cxa_atexit.
+  const CXXRecordDecl *Record = type->getAsCXXRecordDecl();
+  bool CanRegisterDestructor = Record &&
+   !CGM.getCXXABI().HasThisReturn(GlobalDecl(
+   Record->getDestructor(), Dtor_Complete));
+  // If __cxa_atexit is disabled via a flag, a different helper function is
+  // generated elsewhere which uses atexit instead, and it takes the destructor
+  // directly.
+  bool UsingExternalHelper = !CGM.getCodeGenOpts().CXAAtExit;
+  if (Record &&
+  (CanRegisterDestructor || UsingExternalHelper)) {
+assert(!Record->hasTrivialDestructor());
+CXXDestructorDecl *dtor = Record->getDestructor();
 
 function = CGM.getAddrOfCXXStructor(dtor, StructorType::Complete);
 argument = llvm::ConstantExpr::getBitCast(


Index: test/CodeGenCXX/static-destructor.cpp
===
--- /dev/null
+++ test/CodeGenCXX/static-destructor.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck --check-prefix=X86 %s
+// RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck --check-prefix=WASM %s
+// RUN: %clang_cc1 %s -triple=armv7-apple-darwin9 -emit-llvm -o - | FileCheck --check-prefix=WASM %s
+
+// Test that destructors are not passed directly to __cxa_atexit when their
+// signatures do not match the type of its first argument.
+// e.g. ARM and WebAssembly have destructors that return this instead of void.
+
+
+clas

Re: [PATCH] D19099: [clang] [AArch64] Fix D19098 fallout.

2016-04-19 Thread Marcin Kościelnicki via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266817: [AArch64] Fix D19098 fallout. (authored by koriakin).

Changed prior to commit:
  http://reviews.llvm.org/D19099?vs=53667&id=54254#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19099

Files:
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/test/CodeGen/builtins-arm64.c

Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -4647,11 +4647,6 @@
 return Builder.CreateCall(F);
   }
 
-  if (BuiltinID == AArch64::BI__builtin_thread_pointer) {
-Function *F = CGM.getIntrinsic(Intrinsic::aarch64_thread_pointer);
-return Builder.CreateCall(F);
-  }
-
   // CRC32
   Intrinsic::ID CRCIntrinsicID = Intrinsic::not_intrinsic;
   switch (BuiltinID) {
Index: cfe/trunk/test/CodeGen/builtins-arm64.c
===
--- cfe/trunk/test/CodeGen/builtins-arm64.c
+++ cfe/trunk/test/CodeGen/builtins-arm64.c
@@ -7,7 +7,7 @@
 
 void *tp (void) {
   return __builtin_thread_pointer ();
-// CHECK: call {{.*}} @llvm.aarch64.thread.pointer()
+// CHECK: call {{.*}} @llvm.thread.pointer()
 }
 
 // CHECK: call {{.*}} @llvm.aarch64.rbit.i32(i32 %a)


Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -4647,11 +4647,6 @@
 return Builder.CreateCall(F);
   }
 
-  if (BuiltinID == AArch64::BI__builtin_thread_pointer) {
-Function *F = CGM.getIntrinsic(Intrinsic::aarch64_thread_pointer);
-return Builder.CreateCall(F);
-  }
-
   // CRC32
   Intrinsic::ID CRCIntrinsicID = Intrinsic::not_intrinsic;
   switch (BuiltinID) {
Index: cfe/trunk/test/CodeGen/builtins-arm64.c
===
--- cfe/trunk/test/CodeGen/builtins-arm64.c
+++ cfe/trunk/test/CodeGen/builtins-arm64.c
@@ -7,7 +7,7 @@
 
 void *tp (void) {
   return __builtin_thread_pointer ();
-// CHECK: call {{.*}} @llvm.aarch64.thread.pointer()
+// CHECK: call {{.*}} @llvm.thread.pointer()
 }
 
 // CHECK: call {{.*}} @llvm.aarch64.rbit.i32(i32 %a)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r266817 - [AArch64] Fix D19098 fallout.

2016-04-19 Thread Marcin Koscielnicki via cfe-commits
Author: koriakin
Date: Tue Apr 19 15:51:00 2016
New Revision: 266817

URL: http://llvm.org/viewvc/llvm-project?rev=266817&view=rev
Log:
[AArch64] Fix D19098 fallout.

The intrinsic is now called llvm.thread.pointer, not
llvm.aarch64.thread.pointer.  Also, the code handling it in CGBuiltin.cpp
is dead - it's already covered by GCCBuiltin.  Remove it.

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

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins-arm64.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=266817&r1=266816&r2=266817&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Apr 19 15:51:00 2016
@@ -4647,11 +4647,6 @@ Value *CodeGenFunction::EmitAArch64Built
 return Builder.CreateCall(F);
   }
 
-  if (BuiltinID == AArch64::BI__builtin_thread_pointer) {
-Function *F = CGM.getIntrinsic(Intrinsic::aarch64_thread_pointer);
-return Builder.CreateCall(F);
-  }
-
   // CRC32
   Intrinsic::ID CRCIntrinsicID = Intrinsic::not_intrinsic;
   switch (BuiltinID) {

Modified: cfe/trunk/test/CodeGen/builtins-arm64.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-arm64.c?rev=266817&r1=266816&r2=266817&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-arm64.c (original)
+++ cfe/trunk/test/CodeGen/builtins-arm64.c Tue Apr 19 15:51:00 2016
@@ -7,7 +7,7 @@ void f0(void *a, void *b) {
 
 void *tp (void) {
   return __builtin_thread_pointer ();
-// CHECK: call {{.*}} @llvm.aarch64.thread.pointer()
+// CHECK: call {{.*}} @llvm.thread.pointer()
 }
 
 // CHECK: call {{.*}} @llvm.aarch64.rbit.i32(i32 %a)


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


Re: [PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit

2016-04-19 Thread JF Bastien via cfe-commits
jfb added inline comments.


Comment at: lib/CodeGen/CGDeclCXX.cpp:92
@@ +91,3 @@
+  // disabled via a flag, a different helper function is generated anyway.
+  const CXXRecordDecl *Record = type->getAsCXXRecordDecl();
+  bool CanRegisterDestructor = Record &&

Can you do that unconditionally? Or do you have to test for `dtorKind == 
QualType::DK_cxx_destructor` first? It looks like the function already does a 
`dyncast_or_null` so the previous code was doing a check it didn't need to.


Comment at: lib/CodeGen/CGDeclCXX.cpp:95
@@ +94,3 @@
+   !CGM.getCXXABI().HasThisReturn(GlobalDecl(
+   Record->getDestructor(), Dtor_Complete));
+

Comment on why you can't register dtor when has this return (ABI mismatch).


Comment at: lib/CodeGen/CGDeclCXX.cpp:97
@@ +96,3 @@
+
+  if (dtorKind == QualType::DK_cxx_destructor && Record &&
+  (CanRegisterDestructor || !CGM.getCodeGenOpts().CXAAtExit)) {

Do you need to check `Record` here? Doesn't it also imply `dtorKind == 
QualType::DK_cxx_destructor`?


Comment at: lib/CodeGen/CGDeclCXX.cpp:98
@@ +97,3 @@
+  if (dtorKind == QualType::DK_cxx_destructor && Record &&
+  (CanRegisterDestructor || !CGM.getCodeGenOpts().CXAAtExit)) {
+assert(!Record->hasTrivialDestructor());

` || !CGM.getCodeGenOpts().CXAAtExit` seems wrong here. Shouldn't the condition 
be `CanRegisterDestructor && CGM.getCodeGenOpts().CXAAtExit`? I may be 
misunderstanding...


http://reviews.llvm.org/D19275



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


[libcxx] r266820 - XFAILing new test on C++03

2016-04-19 Thread Ben Craig via cfe-commits
Author: bcraig
Date: Tue Apr 19 16:07:30 2016
New Revision: 266820

URL: http://llvm.org/viewvc/llvm-project?rev=266820&view=rev
Log:
XFAILing new test on C++03

initializer_list doesn't exist in C++03.

Modified:
libcxx/trunk/test/std/utilities/utility/synopsis.pass.cpp

Modified: libcxx/trunk/test/std/utilities/utility/synopsis.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/synopsis.pass.cpp?rev=266820&r1=266819&r2=266820&view=diff
==
--- libcxx/trunk/test/std/utilities/utility/synopsis.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/utility/synopsis.pass.cpp Tue Apr 19 
16:07:30 2016
@@ -8,6 +8,7 @@
 
//===--===//
 
 // 
+// XFAIL: c++03
 
 // #include 
 


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


Re: [PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit

2016-04-19 Thread Derek Schuff via cfe-commits
dschuff updated this revision to Diff 54260.
dschuff marked 3 inline comments as done.
dschuff added a comment.

- Clean up condition, add ARM to test


http://reviews.llvm.org/D19275

Files:
  lib/CodeGen/CGDeclCXX.cpp
  test/CodeGenCXX/runtimecc.cpp
  test/CodeGenCXX/static-destructor.cpp

Index: test/CodeGenCXX/static-destructor.cpp
===
--- /dev/null
+++ test/CodeGenCXX/static-destructor.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck 
--check-prefix=X86 %s
+// RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck 
--check-prefix=WASM %s
+// RUN: %clang_cc1 %s -triple=armv7-apple-darwin9 -emit-llvm -o - | FileCheck 
--check-prefix=WASM %s
+
+// Test that destructors are not passed directly to __cxa_atexit when their
+// signatures do not match the type of its first argument.
+// e.g. ARM and WebAssembly have destructors that return this instead of void.
+
+
+class Foo {
+ public:
+  ~Foo() {
+  }
+};
+
+Foo global;
+
+// X86 destructors have void return, and are registered directly with 
__cxa_atexit.
+// X86: define internal void @__cxx_global_var_init()
+// X86-NEXT: entry:
+// X86-NEXT:   %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (void 
(%class.Foo*)* @_ZN3FooD1Ev to void (i8*)*), i8* getelementptr inbounds 
(%class.Foo, %class.Foo* @global, i32 0, i32 0), i8* @__dso_handle)
+
+// Wasm destructors return this, and use a wrapper function, which is 
registered
+// with __cxa_atexit.
+// WASM: define internal void @__cxx_global_var_init()
+// WASM-NEXT: entry:
+// WASM-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* 
@__cxx_global_array_dtor, i8* null, i8* @__dso_handle)
+
+// WASM: define internal void @__cxx_global_array_dtor(i8*)
+// WASM: %call = call %class.Foo* @_ZN3FooD1Ev(%class.Foo* @global)
Index: test/CodeGenCXX/runtimecc.cpp
===
--- test/CodeGenCXX/runtimecc.cpp
+++ test/CodeGenCXX/runtimecc.cpp
@@ -22,8 +22,13 @@
   A global;
 // CHECK-LABEL:define internal void @__cxx_global_var_init()
 // CHECK:  call [[A]]* @_ZN5test01AC1Ev([[A]]* @_ZN5test06globalE)
-// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* bitcast ([[A]]* ([[A]]*)* 
@_ZN5test01AD1Ev to void (i8*)*), i8* bitcast ([[A]]* @_ZN5test06globalE to 
i8*), i8* @__dso_handle) [[NOUNWIND:#[0-9]+]]
+// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* @__cxx_global_array_dtor, 
i8* null, i8* @__dso_handle) [[NOUNWIND:#[0-9]+]]
 // CHECK-NEXT: ret void
+
+// CHECK-LABEL: define internal void @__cxx_global_array_dtor(i8*)
+// CHECK: call [[A]]* @_ZN5test01AD1Ev([[A]]* @_ZN5test06globalE)
+// CHECK-NEXT: ret void
+
 }
 
 // CHECK: declare i32 @__cxa_atexit(void (i8*)*, i8*, i8*) [[NOUNWIND]]
Index: lib/CodeGen/CGDeclCXX.cpp
===
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -86,13 +86,18 @@
   llvm::Constant *function;
   llvm::Constant *argument;
 
-  // Special-case non-array C++ destructors, where there's a function
-  // with the right signature that we can just call.
-  const CXXRecordDecl *record = nullptr;
-  if (dtorKind == QualType::DK_cxx_destructor &&
-  (record = type->getAsCXXRecordDecl())) {
-assert(!record->hasTrivialDestructor());
-CXXDestructorDecl *dtor = record->getDestructor();
+  // Special-case non-array C++ destructors, if they have the right signature
+  // that can be directly registered with __cxa_atexit. If __cxa_atexit is
+  // disabled via a flag, a different helper function is generated anyway.
+  const CXXRecordDecl *Record = type->getAsCXXRecordDecl();
+  bool CanRegisterDestructor = Record &&
+   !CGM.getCXXABI().HasThisReturn(GlobalDecl(
+   Record->getDestructor(), Dtor_Complete));
+
+  if (dtorKind == QualType::DK_cxx_destructor && Record &&
+  (CanRegisterDestructor || !CGM.getCodeGenOpts().CXAAtExit)) {
+assert(!Record->hasTrivialDestructor());
+CXXDestructorDecl *dtor = Record->getDestructor();
 
 function = CGM.getAddrOfCXXStructor(dtor, StructorType::Complete);
 argument = llvm::ConstantExpr::getBitCast(


Index: test/CodeGenCXX/static-destructor.cpp
===
--- /dev/null
+++ test/CodeGenCXX/static-destructor.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck --check-prefix=X86 %s
+// RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck --check-prefix=WASM %s
+// RUN: %clang_cc1 %s -triple=armv7-apple-darwin9 -emit-llvm -o - | FileCheck --check-prefix=WASM %s
+
+// Test that destructors are not passed directly to __cxa_atexit when their
+// signatures do not match the type of its first argument.
+// e.g. ARM and WebAssembly have destructors that return this instead of void.
+
+
+class Foo {
+ public:
+  ~Foo() {
+  }
+};
+
+Foo glo

Re: [PATCH] D19278: [scan-build] fix logic error warnings emitted on clang code base

2016-04-19 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: lib/Sema/SemaOverload.cpp:9191
@@ -9189,1 +9190,3 @@
+   ToTy->isLValueReferenceType() &&
+   !FromExpr->isLValue() &&
ToTy.getNonReferenceType().getCanonicalType() ==

Interleaving these conditions looks strange.  Please group the FromExpr-related 
checks next to each other.

Otherwise LGTM.


http://reviews.llvm.org/D19278



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


Re: [PATCH] D18635: Rework interface for bitset-using features to use a notion of LTO visibility.

2016-04-19 Thread Richard Smith via cfe-commits
rsmith added a comment.

Generally-speaking, I think this is looking really good. I think we need to be 
careful and precise in how we document this new visibility notion; most of my 
comments are on that.

I wonder if we'd benefit from a diagram in the documentation showing the 
nesting levels between object files (translated translation units in C / C++ 
parlance), LTO units (or whatever you want to call them), and DSOs (or linkage 
units or whatever you want to call executable / .so / .dylib / .dll files), and 
precise definitions of the terms we use for each. The two of us seem to be 
using different terms for the same entities, so a single set of terms we define 
and use consistently -- at least within Clang's documentation -- would be great.



Comment at: docs/LTOVisibility.rst:5-8
@@ +4,6 @@
+
+LTO visibility is a concept used by the compiler to determine which classes
+the virtual function call optimization and control flow integrity features
+apply to. These features use whole-program information, so they require
+visibility of entire class hierarchies to work correctly.
+

Please start with a definition of this that says what it means separate from 
how we're going to use it. Something like:

"""
//LTO visibility// is a property of an entity that specifies whether it can be 
referenced from outside the current LTO unit. An //LTO unit// is one or more 
translation units that are linked together using link-time optimization; in the 
case where LTO is not being used, each translation unit is a separate LTO unit.

The LTO visibility of a class is used by the compiler to determine whether 
certain virtual function call optimizations and control flow integrity features 
can be applied to the class. These features use whole-program information, so 
they require the entire class hierarchy to be visible in order to work 
correctly.
"""


Comment at: docs/LTOVisibility.rst:10-12
@@ +9,5 @@
+
+It is effectively an ODR violation to declare a class with hidden LTO
+visibility in multiple linkage units, or to declare such a class in an
+translation unit not built with LTO. A class with default LTO visibility
+has no such restrictions, but the tradeoff is that the virtual function

"[...] or to declare such a class in multiple translation units not built with 
LTO."


Comment at: docs/LTOVisibility.rst:11
@@ +10,3 @@
+It is effectively an ODR violation to declare a class with hidden LTO
+visibility in multiple linkage units, or to declare such a class in an
+translation unit not built with LTO. A class with default LTO visibility

What do you mean by linkage units here? Do you mean DSOs? (In which case this 
seems imprecise, since I can link multiple LTO units into a single DSO.)


Comment at: docs/LTOVisibility.rst:28-30
@@ +27,5 @@
+
+1. If a linkage unit is produced from a combination of LTO object files and
+   non-LTO object files, any classes defined in translation units from which
+   the non-LTO object files were built will require default LTO visibility.
+

The LTO'd files may also need the attribute if the classes are referenced by 
the non-LTO'd files.


Comment at: docs/LTOVisibility.rst:37-43
@@ +36,8 @@
+
+Classes that fall into either of these categories can be marked up with
+the ``[[clang::lto_visibility_default]]`` attribute. To specifically
+handle the COM case, the ``__declspec(uuid())`` attribute implies
+``[[clang::lto_visibility_default]]``. On Windows platforms, the ``/MT`` and
+``/MTd`` flags link the program against a prebuilt static standard library;
+these flags imply default LTO visibility for every class declared in the
+``std`` and `stdext`` namespaces.

"default" is a terrible name for this. It was a mistake for the GNU attribute 
to use "default" to mean "public"; let's not replicate this mistake for LTO 
visibility.


Comment at: docs/LTOVisibility.rst:39-40
@@ +38,4 @@
+the ``[[clang::lto_visibility_default]]`` attribute. To specifically
+handle the COM case, the ``__declspec(uuid())`` attribute implies
+``[[clang::lto_visibility_default]]``. On Windows platforms, the ``/MT`` and
+``/MTd`` flags link the program against a prebuilt static standard library;

It seems to me that `__declspec(uuid(...))` should notionally imply that the 
class is visible to other DSOs, not just that it's visible outside the LTO unit 
within its DSO. I'm not sure we have a reasonable way to model that, though 
(dllexport and default visibility both imply other things that we don't really 
mean here).


Comment at: docs/LTOVisibility.rst:40
@@ +39,3 @@
+handle the COM case, the ``__declspec(uuid())`` attribute implies
+``[[clang::lto_visibility_default]]``. On Windows platforms, the ``/MT`` and
+``/MTd`` flags link the program against a prebuilt static standard library;

Don't sa

r266814 - cc1as: Don't crash when CIE is requested and no DWARF version is specified.

2016-04-19 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Apr 19 15:31:19 2016
New Revision: 266814

URL: http://llvm.org/viewvc/llvm-project?rev=266814&view=rev
Log:
cc1as: Don't crash when CIE is requested and no DWARF version is specified.
This patch changes the default DWARF version for cc1as from invalid 0 to 2,
which should be the lowest common denominator on all platforms.

rdar://problem/24735813

Added:
cfe/trunk/test/Driver/as-dwarf-cie.s
Modified:
cfe/trunk/tools/driver/cc1as_main.cpp

Added: cfe/trunk/test/Driver/as-dwarf-cie.s
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/as-dwarf-cie.s?rev=266814&view=auto
==
--- cfe/trunk/test/Driver/as-dwarf-cie.s (added)
+++ cfe/trunk/test/Driver/as-dwarf-cie.s Tue Apr 19 15:31:19 2016
@@ -0,0 +1,37 @@
+# REQUIRES: x86-registered-target
+# Test that there is a sane default CIE version.
+# RUN: %clang -cc1as -triple i386-apple-darwin -filetype obj %s -o %t
+# RUN: llvm-objdump -dwarf=frames %t | FileCheck %s
+# CHECK: .debug_frame contents:
+# CHECK: CIE
+# CHECK: Version:   1
+   .section__TEXT,__text,regular,pure_instructions
+   .globl  _f
+   .p2align4, 0x90
+_f: ## @f
+Lfunc_begin0:
+   .file   1 "test.c"
+   .loc1 1 0   ## test.c:1:0
+   .cfi_startproc
+## BB#0:## %entry
+   pushl   %ebp
+Ltmp0:
+   .cfi_def_cfa_offset 8
+Ltmp1:
+   .cfi_offset %ebp, -8
+   movl%esp, %ebp
+Ltmp2:
+   .cfi_def_cfa_register %ebp
+Ltmp3:
+   .loc1 1 11 prologue_end ## test.c:1:11
+   popl%ebp
+   retl
+Ltmp4:
+Lfunc_end0:
+   .cfi_endproc
+   .cfi_sections .debug_frame
+
+.subsections_via_symbols
+   .section__DWARF,__debug_line,regular,debug
+Lsection_line:
+Lline_table_start0:

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=266814&r1=266813&r2=266814&view=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Tue Apr 19 15:31:19 2016
@@ -200,7 +200,7 @@ bool AssemblerInvocation::CreateFromArgs
   // Any DebugInfoKind implies GenDwarfForAssembly.
   Opts.GenDwarfForAssembly = Args.hasArg(OPT_debug_info_kind_EQ);
   Opts.CompressDebugSections = Args.hasArg(OPT_compress_debug_sections);
-  Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 0, Diags);
+  Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 2, Diags);
   Opts.DwarfDebugFlags = Args.getLastArgValue(OPT_dwarf_debug_flags);
   Opts.DwarfDebugProducer = Args.getLastArgValue(OPT_dwarf_debug_producer);
   Opts.DebugCompilationDir = Args.getLastArgValue(OPT_fdebug_compilation_dir);


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


Re: [PATCH] D19280: Include initializer_list from utility

2016-04-19 Thread Ben Craig via cfe-commits
bcraig closed this revision.
bcraig added a comment.

Test added.  r266808


http://reviews.llvm.org/D19280



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


r266790 - reuse mustBeJSIdent for interface detection

2016-04-19 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Tue Apr 19 13:19:06 2016
New Revision: 266790

URL: http://llvm.org/viewvc/llvm-project?rev=266790&view=rev
Log:
reuse mustBeJSIdent for interface detection

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=266790&r1=266789&r2=266790&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Apr 19 13:19:06 2016
@@ -663,10 +663,8 @@ static bool tokenCanStartNewLine(const c
  Tok.isNot(tok::kw_noexcept);
 }
 
-static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords,
- const FormatToken *FormatTok) {
-  if (FormatTok->Tok.isLiteral())
-return true;
+static bool mustBeJSIdent(const AdditionalKeywords &Keywords,
+  const FormatToken *FormatTok) {
   // FIXME: This returns true for C/C++ keywords like 'struct'.
   return FormatTok->is(tok::identifier) &&
  (FormatTok->Tok.getIdentifierInfo() == nullptr ||
@@ -679,6 +677,11 @@ static bool mustBeJSIdentOrValue(const A
   Keywords.kw_interface, Keywords.kw_throws));
 }
 
+static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords,
+ const FormatToken *FormatTok) {
+  return FormatTok->Tok.isLiteral() || mustBeJSIdent(Keywords, FormatTok);
+}
+
 // isJSDeclOrStmt returns true if |FormatTok| starts a declaration or statement
 // when encountered after a value (see mustBeJSIdentOrValue).
 static bool isJSDeclOrStmt(const AdditionalKeywords &Keywords,
@@ -1015,9 +1018,7 @@ void UnwrappedLineParser::parseStructura
   unsigned StoredPosition = Tokens->getPosition();
   FormatToken *Next = Tokens->getNextToken();
   FormatTok = Tokens->setPosition(StoredPosition);
-  if (Next && (Next->isNot(tok::identifier) ||
-   Next->isOneOf(Keywords.kw_instanceof, Keywords.kw_of,
- Keywords.kw_in))) {
+  if (Next && !mustBeJSIdent(Keywords, Next)) {
 nextToken();
 break;
   }


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


[libcxx] r266808 - Include initializer_list from utility

2016-04-19 Thread Ben Craig via cfe-commits
Author: bcraig
Date: Tue Apr 19 15:13:55 2016
New Revision: 266808

URL: http://llvm.org/viewvc/llvm-project?rev=266808&view=rev
Log:
Include initializer_list from utility

The C++11 and C++14 standards both say in the header  synopsis that
 shall include .

Added:
libcxx/trunk/test/std/utilities/utility/synopsis.pass.cpp
Modified:
libcxx/trunk/include/utility

Modified: libcxx/trunk/include/utility
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=266808&r1=266807&r2=266808&view=diff
==
--- libcxx/trunk/include/utility (original)
+++ libcxx/trunk/include/utility Tue Apr 19 15:13:55 2016
@@ -178,6 +178,7 @@ template
 #include <__config>
 #include <__tuple>
 #include 
+#include 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header

Added: libcxx/trunk/test/std/utilities/utility/synopsis.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/synopsis.pass.cpp?rev=266808&view=auto
==
--- libcxx/trunk/test/std/utilities/utility/synopsis.pass.cpp (added)
+++ libcxx/trunk/test/std/utilities/utility/synopsis.pass.cpp Tue Apr 19 
15:13:55 2016
@@ -0,0 +1,20 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// #include 
+
+#include 
+
+int main()
+{
+std::initializer_list x;
+}
+


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


r266789 - clang-format: [JS] support `interface` as a free standing identifier.

2016-04-19 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Tue Apr 19 13:18:59 2016
New Revision: 266789

URL: http://llvm.org/viewvc/llvm-project?rev=266789&view=rev
Log:
clang-format: [JS] support `interface` as a free standing identifier.

Summary:
`interface` can be used as a fee standing identifier in JavaScript/TypeScript.
This change uses the heuristic of whether it's followed by another identifier
as an indication.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=266789&r1=266788&r2=266789&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Apr 19 13:18:59 2016
@@ -1007,6 +1007,21 @@ void UnwrappedLineParser::parseStructura
   if ((Style.Language == FormatStyle::LK_JavaScript ||
Style.Language == FormatStyle::LK_Java) &&
   FormatTok->is(Keywords.kw_interface)) {
+if (Style.Language == FormatStyle::LK_JavaScript) {
+  // In JavaScript/TypeScript, "interface" can be used as a standalone
+  // identifier, e.g. in `var interface = 1;`. If "interface" is
+  // followed by another identifier, it is very like to be an actual
+  // interface declaration.
+  unsigned StoredPosition = Tokens->getPosition();
+  FormatToken *Next = Tokens->getNextToken();
+  FormatTok = Tokens->setPosition(StoredPosition);
+  if (Next && (Next->isNot(tok::identifier) ||
+   Next->isOneOf(Keywords.kw_instanceof, Keywords.kw_of,
+ Keywords.kw_in))) {
+nextToken();
+break;
+  }
+}
 parseRecord();
 addUnwrappedLine();
 return;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=266789&r1=266788&r2=266789&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Apr 19 13:18:59 2016
@@ -136,6 +136,9 @@ TEST_F(FormatTestJS, ReservedWords) {
"};");
   verifyFormat("var struct = 2;");
   verifyFormat("var union = 2;");
+  verifyFormat("var interface = 2;");
+  verifyFormat("interface = 2;");
+  verifyFormat("x = interface instanceof y;");
 }
 
 TEST_F(FormatTestJS, CppKeywords) {


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


Re: [PATCH] D19278: [scan-build] fix logic error warnings emitted on clang code base

2016-04-19 Thread Mandeep Singh Grang via cfe-commits
mgrang added a comment.

LGTM.
Could you please check who owns the files you modified and then add a couple of 
reviewers. You can try "git blame " or check CODE_OWNERS.TXT file to 
get the owners.


http://reviews.llvm.org/D19278



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


Re: [PATCH] D19278: [scan-build] fix logic error warnings emitted on clang code base

2016-04-19 Thread Apelete Seketeli via cfe-commits
apelete marked an inline comment as done.
apelete added a comment.

http://reviews.llvm.org/D19278



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


Re: [PATCH] D19278: [scan-build] fix logic error warnings emitted on clang code base

2016-04-19 Thread Apelete Seketeli via cfe-commits
apelete updated this revision to Diff 54246.
apelete added a comment.

[scan-build] fix logic error warnings emitted on clang code base

Following changes were done since last revision:

- fix a typo in lib/Sema/SemaDeclCXX.cpp: decalration ==> declaration.


http://reviews.llvm.org/D19278

Files:
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/SemaOverload.cpp
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp

Index: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -693,6 +693,8 @@
 !Param->getType()->isReferenceType())
   continue;
 
+assert(ArgExpr && "cannot get the type of a NULL expression");
+
 NullConstraint Nullness = getNullConstraint(*ArgSVal, State);
 
 Nullability RequiredNullability =
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -8705,6 +8705,7 @@
 
 void Sema::diagnoseEquivalentInternalLinkageDeclarations(
 SourceLocation Loc, const NamedDecl *D, ArrayRef Equiv) {
+  assert(D && "named declaration must be not NULL");
   Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D;
 
   Module *M = getOwningModule(const_cast(D));
@@ -9185,7 +9186,9 @@
 !ToRefTy->getPointeeType()->isIncompleteType() &&
 S.IsDerivedFrom(SourceLocation(), ToRefTy->getPointeeType(), FromTy)) {
   BaseToDerivedConversion = 3;
-} else if (ToTy->isLValueReferenceType() && !FromExpr->isLValue() &&
+} else if (FromExpr &&
+   ToTy->isLValueReferenceType() &&
+   !FromExpr->isLValue() &&
ToTy.getNonReferenceType().getCanonicalType() ==
FromTy.getNonReferenceType().getCanonicalType()) {
   S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_lvalue)
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -939,6 +939,7 @@
 (VD && DSAStack->isForceVarCapturing()))
   return VD ? VD : Info.second;
 auto DVarPrivate = DSAStack->getTopDSA(D, DSAStack->isClauseParsingMode());
+assert(DVarPrivate.PrivateCopy && "DSAStackTy object must be not NULL");
 if (DVarPrivate.CKind != OMPC_unknown && isOpenMPPrivate(DVarPrivate.CKind))
   return VD ? VD : cast(DVarPrivate.PrivateCopy->getDecl());
 DVarPrivate = DSAStack->hasDSA(D, isOpenMPPrivate, MatchesAlways(),
@@ -3924,6 +3925,7 @@
 static ExprResult
 tryBuildCapture(Sema &SemaRef, Expr *Capture,
 llvm::MapVector &Captures) {
+  assert(Capture && "cannot build capture if expression is NULL");
   if (Capture->isEvaluatable(SemaRef.Context, Expr::SE_AllowSideEffects))
 return SemaRef.PerformImplicitConversion(
 Capture->IgnoreImpCasts(), Capture->getType(), Sema::AA_Converting,
@@ -4177,7 +4179,7 @@
 SemaRef.Diag(CollapseLoopCountExpr->getExprLoc(),
  diag::note_omp_collapse_ordered_expr)
 << 0 << CollapseLoopCountExpr->getSourceRange();
-  else
+  else if (OrderedLoopCountExpr)
 SemaRef.Diag(OrderedLoopCountExpr->getExprLoc(),
  diag::note_omp_collapse_ordered_expr)
 << 1 << OrderedLoopCountExpr->getSourceRange();
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -434,6 +434,9 @@
 /// error, false otherwise.
 bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old,
 Scope *S) {
+  assert(New && "New function declaration is NULL, aborting merge.");
+  assert(Old && "Old function declaration is NULL, aborting merge.");
+
   bool Invalid = false;
 
   // The declaration context corresponding to the scope is the semantic
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -2303,6 +2303,7 @@
 
 unsigned CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D,
  unsigned AddrSpace) {
+  assert(D && "variable declaration must be not NULL");
   if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {
 if (D->hasAttr())
   AddrSpace = getContext().getTargetAddressSpace(LangAS::cuda_constant);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -1312,6 +1312,7 @@
 CGM.getContext().toCharUnitsFromBits((int64_t)fieldOffset);
 V = CGM.getCXXABI().EmitMemberDataPointer(M

Re: [PATCH] D19280: Include initializer_list from utility

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

LGTM. Thanks.

Could you commit this with a new test 
`test/std/utilities/utility/synopsis.pass.cpp` which checks for the presence of 
initializer list?


http://reviews.llvm.org/D19280



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


[PATCH] D19280: Include initializer_list from utility

2016-04-19 Thread Ben Craig via cfe-commits
bcraig created this revision.
bcraig added reviewers: mclow.lists, EricWF, howard.hinnant.
bcraig added a subscriber: cfe-commits.

The C++11 and C++14 standards both say in the header  synopsis that 
 shall include .

http://reviews.llvm.org/D19280

Files:
  include/utility

Index: include/utility
===
--- include/utility
+++ include/utility
@@ -178,6 +178,7 @@
 #include <__config>
 #include <__tuple>
 #include 
+#include 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header


Index: include/utility
===
--- include/utility
+++ include/utility
@@ -178,6 +178,7 @@
 #include <__config>
 #include <__tuple>
 #include 
+#include 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r266807 - [ARM NEON] Define vfms_f32 on ARM, and all vfms using vfma.

2016-04-19 Thread Ahmed Bougacha via cfe-commits
Author: ab
Date: Tue Apr 19 14:44:45 2016
New Revision: 266807

URL: http://llvm.org/viewvc/llvm-project?rev=266807&view=rev
Log:
[ARM NEON] Define vfms_f32 on ARM, and all vfms using vfma.

r259537 added vfma/vfms to armv7, but the builtin was only lowered
on the AArch64 side. Instead of supporting it on ARM, get rid of it.

The vfms builtin lowered to:
  %nb = fsub float -0.0, %b
  %r = @llvm.fma.f32(%a, %nb, %c)

Instead, define the operation in terms of vfma, and swap the
multiplicands. It now lowers to:
  %na = fsub float -0.0, %a
  %r = @llvm.fma.f32(%na, %b, %c)

This matches the instruction more closely, and lets current LLVM
generate the "natural" operand ordering:
  fmls.2s v0, v1, v2
instead of the crooked (but equivalent):
  fmls.2s v0, v2, v1
Except for theses changes, assembly is identical.

LLVM accepts both commutations, and the LLVM tests in:
  test/CodeGen/AArch64/arm64-fmadd.ll
  test/CodeGen/AArch64/fp-dp3.ll
  test/CodeGen/AArch64/neon-fma.ll
  test/CodeGen/ARM/fusedMAC.ll
already check either the new one only, or both.

Also verified against the test-suite unittests.

Modified:
cfe/trunk/include/clang/Basic/arm_neon.td
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/aarch64-neon-2velem.c
cfe/trunk/test/CodeGen/aarch64-neon-fma.c
cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
cfe/trunk/test/CodeGen/aarch64-neon-scalar-x-indexed-elem.c
cfe/trunk/test/CodeGen/arm_neon_intrinsics.c

Modified: cfe/trunk/include/clang/Basic/arm_neon.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=266807&r1=266806&r2=266807&view=diff
==
--- cfe/trunk/include/clang/Basic/arm_neon.td (original)
+++ cfe/trunk/include/clang/Basic/arm_neon.td Tue Apr 19 14:44:45 2016
@@ -339,6 +339,7 @@ def OP_MLALHi   : Op<(call "vmlal", $p0,
  (call "vget_high", $p2))>;
 def OP_MLALHi_N : Op<(call "vmlal_n", $p0, (call "vget_high", $p1), $p2)>;
 def OP_MLS  : Op<(op "-", $p0, (op "*", $p1, $p2))>;
+def OP_FMLS : Op<(call "vfma", $p0, (op "-", $p1), $p2)>;
 def OP_MLSL : Op<(op "-", $p0, (call "vmull", $p1, $p2))>;
 def OP_MLSLHi   : Op<(call "vmlsl", $p0, (call "vget_high", $p1),
  (call "vget_high", $p2))>;
@@ -347,7 +348,7 @@ def OP_MUL_N: Op<(op "*", $p0, (dup
 def OP_MLA_N: Op<(op "+", $p0, (op "*", $p1, (dup $p2)))>;
 def OP_MLS_N: Op<(op "-", $p0, (op "*", $p1, (dup $p2)))>;
 def OP_FMLA_N   : Op<(call "vfma", $p0, $p1, (dup $p2))>;
-def OP_FMLS_N   : Op<(call "vfms", $p0, $p1, (dup $p2))>;
+def OP_FMLS_N   : Op<(call "vfma", $p0, (op "-", $p1), (dup $p2))>;
 def OP_MLAL_N   : Op<(op "+", $p0, (call "vmull", $p1, (dup $p2)))>;
 def OP_MLSL_N   : Op<(op "-", $p0, (call "vmull", $p1, (dup $p2)))>;
 def OP_MUL_LN   : Op<(op "*", $p0, (splat $p1, $p2))>;
@@ -377,8 +378,8 @@ def OP_QRDMLAH : Op<(call "vqadd", $p0,
 def OP_QRDMLSH : Op<(call "vqsub", $p0, (call "vqrdmulh", $p1, $p2))>;
 def OP_QRDMLAH_LN : Op<(call "vqadd", $p0, (call "vqrdmulh", $p1, (splat $p2, 
$p3)))>;
 def OP_QRDMLSH_LN : Op<(call "vqsub", $p0, (call "vqrdmulh", $p1, (splat $p2, 
$p3)))>;
-def OP_FMS_LN   : Op<(call "vfma_lane", $p0, $p1, (op "-", $p2), $p3)>;
-def OP_FMS_LNQ  : Op<(call "vfma_laneq", $p0, $p1, (op "-", $p2), $p3)>;
+def OP_FMS_LN   : Op<(call "vfma_lane", $p0, (op "-", $p1), $p2, $p3)>;
+def OP_FMS_LNQ  : Op<(call "vfma_laneq", $p0, (op "-", $p1), $p2, $p3)>;
 def OP_TRN1 : Op<(shuffle $p0, $p1, (interleave (decimate mask0, 2),
 (decimate mask1, 2)))>;
 def OP_ZIP1 : Op<(shuffle $p0, $p1, (lowhalf (interleave mask0, mask1)))>;
@@ -826,7 +827,7 @@ def VREINTERPRET
 
 let ArchGuard = "defined(__ARM_FEATURE_FMA)" in {
   def VFMA : SInst<"vfma", "", "fQf">;
-  def VFMS : SInst<"vfms", "", "fQf">;
+  def VFMS : SOpInst<"vfms", "", "fQf", OP_FMLS>;
 }
 
 

@@ -911,7 +912,7 @@ def FDIV : IOpInst<"vdiv", "ddd",  "fdQf
 

 // Vector fused multiply-add operations
 def FMLA : SInst<"vfma", "", "dQd">;
-def FMLS : SInst<"vfms", "", "dQd">;
+def FMLS : SOpInst<"vfms", "", "dQd", OP_FMLS>;
 
 

 // MUL, MLA, MLS, FMA, FMS definitions with scalar argument

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=266807&r1=266806&r2=266807&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Apr 19 14:44:45 2016
@@ -5319,22 +5319,6 @@ Value *CodeGenFunction::EmitAArch64Built
   

Re: [PATCH] D19278: [scan-build] fix logic error warnings emitted on clang code base

2016-04-19 Thread Mandeep Singh Grang via cfe-commits
mgrang added a subscriber: mgrang.


Comment at: lib/Sema/SemaDeclCXX.cpp:438
@@ +437,3 @@
+  assert(New && "New function decalration is NULL, aborting merge.");
+  assert(Old && "Old function decalration is NULL, aborting merge.");
+

typo: decalration ==> declaration


http://reviews.llvm.org/D19278



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


Re: [PATCH] D19071: [OpenCL] Add predefined macros.

2016-04-19 Thread Yaxun Liu via cfe-commits
yaxunl updated the summary for this revision.
yaxunl updated this revision to Diff 54243.
yaxunl marked an inline comment as done.
yaxunl added a comment.

Added __OPENCL_C_VERSION__ and CL_VERSION_X_Y for all OpenCL versions.

Also fixed the test using -std=c99 for OpenCL and limit allowed language 
standard for OpenCL.

I think an OpenCL program by definition should follow certain OpenCL language 
standard.


http://reviews.llvm.org/D19071

Files:
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/Frontend/stdlang.c
  test/Preprocessor/predefined-macros.c

Index: test/Preprocessor/predefined-macros.c
===
--- test/Preprocessor/predefined-macros.c
+++ test/Preprocessor/predefined-macros.c
@@ -146,3 +146,30 @@
 // CHECK-SYNC_CAS_MIPS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
 // CHECK-SYNC_CAS_MIPS32-NOT: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
 // CHECK-SYNC_CAS_MIPS64: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+
+// RUN: %clang_cc1 %s -E -dM -o - -x cl \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL1.1 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL11
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL1.2 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL12
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL2.0 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL20
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-fast-relaxed-math \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
+// CHECK-CL10: #define CL_VERSION_1_0 100
+// CHECK-CL10: #define __OPENCL_C_VERSION__ 100
+// CHECK-CL11: #define CL_VERSION_1_0 100
+// CHECK-CL11: #define CL_VERSION_1_1 110
+// CHECK-CL11: #define __OPENCL_C_VERSION__ 110
+// CHECK-CL12: #define CL_VERSION_1_0 100
+// CHECK-CL12: #define CL_VERSION_1_1 110
+// CHECK-CL12: #define CL_VERSION_1_2 120
+// CHECK-CL12: #define __OPENCL_C_VERSION__ 120
+// CHECK-CL20: #define CL_VERSION_1_0 100
+// CHECK-CL20: #define CL_VERSION_1_1 110
+// CHECK-CL20: #define CL_VERSION_1_2 120
+// CHECK-CL20: #define CL_VERSION_2_0 200
+// CHECK-CL20: #define __OPENCL_C_VERSION__ 200
+// CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
+
Index: test/Frontend/stdlang.c
===
--- test/Frontend/stdlang.c
+++ test/Frontend/stdlang.c
@@ -1,9 +1,17 @@
 // RUN: %clang_cc1 -x cuda -std=c++11 -DCUDA %s
-// RUN: %clang_cc1 -x cl -std=c99 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CL -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CL1.1 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=CL2.0 -DOPENCL %s
+// RUN: not %clang_cc1 -x cl -std=c99 -DOPENCL_C99 %s 2>&1 | FileCheck %s
+// CHECK: error: invalid argument '-std=c99' not allowed with 'OpenCL'
+#ifndef OPENCL_C99
 // expected-no-diagnostics
+#endif
 
 #if defined(CUDA)
   __attribute__((device)) void f_device();
-#elif defined(OPENCL)
+#elif defined(OPENCL) || defined(OPENCL_C99)
   kernel void func(void);
 #endif
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -408,6 +408,39 @@
   if (LangOpts.ObjC1)
 Builder.defineMacro("__OBJC__");
 
+  // OpenCL v1.0/1.1 s6.9, v1.2/2.0 s6.10: Preprocessor Directives and Macros.
+  if (LangOpts.OpenCL) {
+// OpenCL v1.0 and v1.1 do not have a predefined macro to indicate the
+// language standard with which the program is compiled. __OPENCL_VERSION__
+// is for the OpenCL version supported by the OpenCL device, which is not
+// necessarily the language standard with which the program is compiled.
+// A shared OpenCL header file requires a macro to indicate the language
+// standard. As a workaround, __CLANG_OPENCL_C_VERSION__ is defined for
+// OpenCL v1.0 and v1.1.
+switch (LangOpts.OpenCLVersion) {
+case 100:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "100");
+  break;
+case 110:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "110");
+  break;
+case 120:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "120");
+  break;
+case 200:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "200");
+  break;
+default:
+  llvm_unreachable("Unsupported OpenCL version");
+}
+Builder.defineMacro("CL_VERSION_1_0", "100");
+Builder.defineMacro("CL_VERSION_1_1", "110");
+Builder.defineMacro("CL_VERSION_1_2", "120");
+Builder.defineMacro("CL_VERSION_2_0", "200");
+
+if (LangOpts.FastRelaxedMath)
+  Builder.defineMacro("__FAST_RELAXED_MATH__");
+  }
   // Not "standard" per se, but available even with the -undef flag.
   if (LangOpts.AsmPreprocessor)
 Builder.defineMacro("__ASSEMBLER__");
Inde

Re: [PATCH] D19106: Fixed a bug in AnnotatedLine::startsWith when there are comments in the line.

2016-04-19 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266803: Fixed a bug in AnnotatedLine::startsWith when there 
are comments in the line. (authored by ioeric).

Changed prior to commit:
  http://reviews.llvm.org/D19106?vs=54240&id=54242#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19106

Files:
  cfe/trunk/lib/Format/TokenAnnotator.h

Index: cfe/trunk/lib/Format/TokenAnnotator.h
===
--- cfe/trunk/lib/Format/TokenAnnotator.h
+++ cfe/trunk/lib/Format/TokenAnnotator.h
@@ -83,7 +83,7 @@
   /// \c true if this line starts with the given tokens in order, ignoring
   /// comments.
   template  bool startsWith(Ts... Tokens) const {
-return startsWith(First, Tokens...);
+return startsWithInternal(First, Tokens...);
   }
 
   /// \c true if this line looks like a function definition instead of a
@@ -124,15 +124,24 @@
   void operator=(const AnnotatedLine &) = delete;
 
   template 
-  bool startsWith(FormatToken *Tok, A K1) const {
+  bool startsWithInternal(const FormatToken *Tok, A K1) const {
+// Even though we skip comments in the outer `startWithInternal` function,
+// this loop is still necessary if it is invoked by the public interface
+// `startsWith`.
 while (Tok && Tok->is(tok::comment))
   Tok = Tok->Next;
 return Tok && Tok->is(K1);
   }
 
   template 
-  bool startsWith(FormatToken *Tok, A K1, Ts... Tokens) const {
-return startsWith(Tok, K1) && startsWith(Tok->Next, Tokens...);
+  bool startsWithInternal(const FormatToken *Tok, A K1, Ts... Tokens) const {
+// Skip comments before calling `startsWithInternal(Tok, K1)` so that  the
+// second call to `startsWithInternal` takes the correct `Tok->Next`, which
+// should be the next token of the token checked in the first call.
+while (Tok && Tok->is(tok::comment))
+  Tok = Tok->Next;
+return Tok && startsWithInternal(Tok, K1) &&
+   startsWithInternal(Tok->Next, Tokens...);
   }
 };
 


Index: cfe/trunk/lib/Format/TokenAnnotator.h
===
--- cfe/trunk/lib/Format/TokenAnnotator.h
+++ cfe/trunk/lib/Format/TokenAnnotator.h
@@ -83,7 +83,7 @@
   /// \c true if this line starts with the given tokens in order, ignoring
   /// comments.
   template  bool startsWith(Ts... Tokens) const {
-return startsWith(First, Tokens...);
+return startsWithInternal(First, Tokens...);
   }
 
   /// \c true if this line looks like a function definition instead of a
@@ -124,15 +124,24 @@
   void operator=(const AnnotatedLine &) = delete;
 
   template 
-  bool startsWith(FormatToken *Tok, A K1) const {
+  bool startsWithInternal(const FormatToken *Tok, A K1) const {
+// Even though we skip comments in the outer `startWithInternal` function,
+// this loop is still necessary if it is invoked by the public interface
+// `startsWith`.
 while (Tok && Tok->is(tok::comment))
   Tok = Tok->Next;
 return Tok && Tok->is(K1);
   }
 
   template 
-  bool startsWith(FormatToken *Tok, A K1, Ts... Tokens) const {
-return startsWith(Tok, K1) && startsWith(Tok->Next, Tokens...);
+  bool startsWithInternal(const FormatToken *Tok, A K1, Ts... Tokens) const {
+// Skip comments before calling `startsWithInternal(Tok, K1)` so that  the
+// second call to `startsWithInternal` takes the correct `Tok->Next`, which
+// should be the next token of the token checked in the first call.
+while (Tok && Tok->is(tok::comment))
+  Tok = Tok->Next;
+return Tok && startsWithInternal(Tok, K1) &&
+   startsWithInternal(Tok->Next, Tokens...);
   }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19084: [clang-analyzer] fix warnings emitted on clang code base

2016-04-19 Thread Apelete Seketeli via cfe-commits
apelete added a comment.

Ping :).
Can someone help this one find its way into he main repo ?


http://reviews.llvm.org/D19084



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


r266803 - Fixed a bug in AnnotatedLine::startsWith when there are comments in the line.

2016-04-19 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Apr 19 14:25:33 2016
New Revision: 266803

URL: http://llvm.org/viewvc/llvm-project?rev=266803&view=rev
Log:
Fixed a bug in AnnotatedLine::startsWith when there are comments in the line.

Summary: When there are comments in the line, one token may be checked multiple 
times.

Reviewers: mprobst, djasper

Subscribers: ioeric, cfe-commits, klimek

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.h

Modified: cfe/trunk/lib/Format/TokenAnnotator.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.h?rev=266803&r1=266802&r2=266803&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.h (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.h Tue Apr 19 14:25:33 2016
@@ -83,7 +83,7 @@ public:
   /// \c true if this line starts with the given tokens in order, ignoring
   /// comments.
   template  bool startsWith(Ts... Tokens) const {
-return startsWith(First, Tokens...);
+return startsWithInternal(First, Tokens...);
   }
 
   /// \c true if this line looks like a function definition instead of a
@@ -124,15 +124,24 @@ private:
   void operator=(const AnnotatedLine &) = delete;
 
   template 
-  bool startsWith(FormatToken *Tok, A K1) const {
+  bool startsWithInternal(const FormatToken *Tok, A K1) const {
+// Even though we skip comments in the outer `startWithInternal` function,
+// this loop is still necessary if it is invoked by the public interface
+// `startsWith`.
 while (Tok && Tok->is(tok::comment))
   Tok = Tok->Next;
 return Tok && Tok->is(K1);
   }
 
   template 
-  bool startsWith(FormatToken *Tok, A K1, Ts... Tokens) const {
-return startsWith(Tok, K1) && startsWith(Tok->Next, Tokens...);
+  bool startsWithInternal(const FormatToken *Tok, A K1, Ts... Tokens) const {
+// Skip comments before calling `startsWithInternal(Tok, K1)` so that  the
+// second call to `startsWithInternal` takes the correct `Tok->Next`, which
+// should be the next token of the token checked in the first call.
+while (Tok && Tok->is(tok::comment))
+  Tok = Tok->Next;
+return Tok && startsWithInternal(Tok, K1) &&
+   startsWithInternal(Tok->Next, Tokens...);
   }
 };
 


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


Re: [PATCH] D19106: Fixed a bug in AnnotatedLine::startsWith when there are comments in the line.

2016-04-19 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 54240.
ioeric marked an inline comment as done.
ioeric added a comment.

- nit fixed


http://reviews.llvm.org/D19106

Files:
  lib/Format/TokenAnnotator.h

Index: lib/Format/TokenAnnotator.h
===
--- lib/Format/TokenAnnotator.h
+++ lib/Format/TokenAnnotator.h
@@ -83,7 +83,7 @@
   /// \c true if this line starts with the given tokens in order, ignoring
   /// comments.
   template  bool startsWith(Ts... Tokens) const {
-return startsWith(First, Tokens...);
+return startsWithInternal(First, Tokens...);
   }
 
   /// \c true if this line looks like a function definition instead of a
@@ -124,15 +124,24 @@
   void operator=(const AnnotatedLine &) = delete;
 
   template 
-  bool startsWith(FormatToken *Tok, A K1) const {
+  bool startsWithInternal(const FormatToken *Tok, A K1) const {
+// Even though we skip comments in the outer `startWithInternal` function,
+// this loop is still necessary if it is invoked by the public interface
+// `startsWith`.
 while (Tok && Tok->is(tok::comment))
   Tok = Tok->Next;
 return Tok && Tok->is(K1);
   }
 
   template 
-  bool startsWith(FormatToken *Tok, A K1, Ts... Tokens) const {
-return startsWith(Tok, K1) && startsWith(Tok->Next, Tokens...);
+  bool startsWithInternal(const FormatToken *Tok, A K1, Ts... Tokens) const {
+// Skip comments before calling `startsWithInternal(Tok, K1)` so that  the
+// second call to `startsWithInternal` takes the correct `Tok->Next`, which
+// should be the next token of the token checked in the first call.
+while (Tok && Tok->is(tok::comment))
+  Tok = Tok->Next;
+return Tok && startsWithInternal(Tok, K1) &&
+   startsWithInternal(Tok->Next, Tokens...);
   }
 };
 


Index: lib/Format/TokenAnnotator.h
===
--- lib/Format/TokenAnnotator.h
+++ lib/Format/TokenAnnotator.h
@@ -83,7 +83,7 @@
   /// \c true if this line starts with the given tokens in order, ignoring
   /// comments.
   template  bool startsWith(Ts... Tokens) const {
-return startsWith(First, Tokens...);
+return startsWithInternal(First, Tokens...);
   }
 
   /// \c true if this line looks like a function definition instead of a
@@ -124,15 +124,24 @@
   void operator=(const AnnotatedLine &) = delete;
 
   template 
-  bool startsWith(FormatToken *Tok, A K1) const {
+  bool startsWithInternal(const FormatToken *Tok, A K1) const {
+// Even though we skip comments in the outer `startWithInternal` function,
+// this loop is still necessary if it is invoked by the public interface
+// `startsWith`.
 while (Tok && Tok->is(tok::comment))
   Tok = Tok->Next;
 return Tok && Tok->is(K1);
   }
 
   template 
-  bool startsWith(FormatToken *Tok, A K1, Ts... Tokens) const {
-return startsWith(Tok, K1) && startsWith(Tok->Next, Tokens...);
+  bool startsWithInternal(const FormatToken *Tok, A K1, Ts... Tokens) const {
+// Skip comments before calling `startsWithInternal(Tok, K1)` so that  the
+// second call to `startsWithInternal` takes the correct `Tok->Next`, which
+// should be the next token of the token checked in the first call.
+while (Tok && Tok->is(tok::comment))
+  Tok = Tok->Next;
+return Tok && startsWithInternal(Tok, K1) &&
+   startsWithInternal(Tok->Next, Tokens...);
   }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19278: [scan-build] fix logic error warnings emitted on clang code base

2016-04-19 Thread Apelete Seketeli via cfe-commits
apelete created this revision.
apelete added a subscriber: cfe-commits.

This partch fixes a few "Logic error" warnings of the type "Called c++
object pointer is null" reported by Clang Static Analyzer on the
following files:

- lib/AST/ExprConstant.cpp,
- lib/CodeGen/CGDebugInfo.cpp,
- lib/CodeGen/CodeGenModule.cpp,
- lib/Sema/SemaDeclCXX.cpp,
- lib/Sema/SemaOpenMP.cpp,
- lib/Sema/SemaOverload.cpp,
- lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp.

Signed-off-by: Apelete Seketeli 

http://reviews.llvm.org/D19278

Files:
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/SemaOverload.cpp
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp

Index: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -693,6 +693,8 @@
 !Param->getType()->isReferenceType())
   continue;
 
+assert(ArgExpr && "cannot get the type of a NULL expression");
+
 NullConstraint Nullness = getNullConstraint(*ArgSVal, State);
 
 Nullability RequiredNullability =
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -8721,6 +8721,7 @@
 
 void Sema::diagnoseEquivalentInternalLinkageDeclarations(
 SourceLocation Loc, const NamedDecl *D, ArrayRef Equiv) {
+  assert(D && "named declaration must be not NULL");
   Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D;
 
   Module *M = getOwningModule(const_cast(D));
@@ -9201,7 +9202,9 @@
 !ToRefTy->getPointeeType()->isIncompleteType() &&
 S.IsDerivedFrom(SourceLocation(), ToRefTy->getPointeeType(), FromTy)) {
   BaseToDerivedConversion = 3;
-} else if (ToTy->isLValueReferenceType() && !FromExpr->isLValue() &&
+} else if (FromExpr &&
+   ToTy->isLValueReferenceType() &&
+   !FromExpr->isLValue() &&
ToTy.getNonReferenceType().getCanonicalType() ==
FromTy.getNonReferenceType().getCanonicalType()) {
   S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_lvalue)
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -939,6 +939,7 @@
 (VD && DSAStack->isForceVarCapturing()))
   return VD ? VD : Info.second;
 auto DVarPrivate = DSAStack->getTopDSA(D, DSAStack->isClauseParsingMode());
+assert(DVarPrivate.PrivateCopy && "DSAStackTy object must be not NULL");
 if (DVarPrivate.CKind != OMPC_unknown && isOpenMPPrivate(DVarPrivate.CKind))
   return VD ? VD : cast(DVarPrivate.PrivateCopy->getDecl());
 DVarPrivate = DSAStack->hasDSA(D, isOpenMPPrivate, MatchesAlways(),
@@ -3924,6 +3925,7 @@
 static ExprResult
 tryBuildCapture(Sema &SemaRef, Expr *Capture,
 llvm::MapVector &Captures) {
+  assert(Capture && "cannot build capture if expression is NULL");
   if (Capture->isEvaluatable(SemaRef.Context, Expr::SE_AllowSideEffects))
 return SemaRef.PerformImplicitConversion(
 Capture->IgnoreImpCasts(), Capture->getType(), Sema::AA_Converting,
@@ -4177,7 +4179,7 @@
 SemaRef.Diag(CollapseLoopCountExpr->getExprLoc(),
  diag::note_omp_collapse_ordered_expr)
 << 0 << CollapseLoopCountExpr->getSourceRange();
-  else
+  else if (OrderedLoopCountExpr)
 SemaRef.Diag(OrderedLoopCountExpr->getExprLoc(),
  diag::note_omp_collapse_ordered_expr)
 << 1 << OrderedLoopCountExpr->getSourceRange();
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -434,6 +434,9 @@
 /// error, false otherwise.
 bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old,
 Scope *S) {
+  assert(New && "New function decalration is NULL, aborting merge.");
+  assert(Old && "Old function decalration is NULL, aborting merge.");
+
   bool Invalid = false;
 
   // The declaration context corresponding to the scope is the semantic
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -2303,6 +2303,7 @@
 
 unsigned CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D,
  unsigned AddrSpace) {
+  assert(D && "variable declaration must be not NULL");
   if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {
 if (D->hasAttr())
   AddrSpace = getContext().getTargetAddressSpace(LangAS::cuda_constant);
Index: lib/CodeGen/CGDebugInfo.cpp
===

r266800 - ObjC Class Property: don't emit class properties on old deployment targets.

2016-04-19 Thread Manman Ren via cfe-commits
Author: mren
Date: Tue Apr 19 14:05:03 2016
New Revision: 266800

URL: http://llvm.org/viewvc/llvm-project?rev=266800&view=rev
Log:
ObjC Class Property: don't emit class properties on old deployment targets.

For old deployment targets, emit nil for all class property lists.

rdar://25616128

Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/test/CodeGenObjC/metadata-class-properties.m

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=266800&r1=266799&r2=266800&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Tue Apr 19 14:05:03 2016
@@ -2953,6 +2953,15 @@ llvm::Constant *CGObjCCommonMac::EmitPro
const ObjCContainerDecl *OCD,
const ObjCCommonTypesHelper &ObjCTypes,
bool IsClassProperty) {
+  if (IsClassProperty) {
+// Make this entry NULL for OS X with deployment target < 10.11, for iOS
+// with deployment target < 9.0.
+const llvm::Triple &Triple = CGM.getTarget().getTriple();
+if ((Triple.isMacOSX() && Triple.isMacOSXVersionLT(10, 11)) ||
+(Triple.isiOS() && Triple.isOSVersionLT(9)))
+  return llvm::Constant::getNullValue(ObjCTypes.PropertyListPtrTy);
+  }
+
   SmallVector Properties;
   llvm::SmallPtrSet PropertySet;
 

Modified: cfe/trunk/test/CodeGenObjC/metadata-class-properties.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/metadata-class-properties.m?rev=266800&r1=266799&r2=266800&view=diff
==
--- cfe/trunk/test/CodeGenObjC/metadata-class-properties.m (original)
+++ cfe/trunk/test/CodeGenObjC/metadata-class-properties.m Tue Apr 19 14:05:03 
2016
@@ -1,5 +1,6 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10  -emit-llvm -o - %s | 
FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10  -emit-llvm -o - 
-fobjc-runtime=macosx-fragile-10.5 %s | FileCheck -check-prefix=CHECK-FRAGILE %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11  -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10  -emit-llvm -o - %s | 
FileCheck -check-prefix=CHECK-NULL %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11  -emit-llvm -o - 
-fobjc-runtime=macosx-fragile-10.5 %s | FileCheck -check-prefix=CHECK-FRAGILE %s
 
 // CHECK: @"\01l_OBJC_$_CLASS_PROP_LIST_Proto" = private global {{.*}} section 
"__DATA, __objc_const", align 8
 // CHECK: @"\01l_OBJC_PROTOCOL_$_Proto" = {{.*}} global %struct._protocol_t { 
{{.*}} i32 96, i32 {{.*}} @"\01l_OBJC_$_CLASS_PROP_LIST_Proto" {{.*}} }
@@ -11,6 +12,16 @@
 
 // CHECK: !{i32 1, !"Objective-C Class Properties", i32 64}
 
+// CHECK-NULL-NOT: @"\01l_OBJC_$_CLASS_PROP_LIST_Proto"
+// CHECK-NULL: @"\01l_OBJC_PROTOCOL_$_Proto" = {{.*}} global 
%struct._protocol_t { {{.*}} %struct._prop_list_t* null, i32 96, i32 {{.*}} 
%struct._prop_list_t* null }
+// CHECK-NULL-NOT: @"\01l_OBJC_$_CLASS_PROP_LIST_Foo_$_Category" = private 
global {{.*}} section "__DATA, __objc_const", align 8
+// CHECK-NULL: @"\01l_OBJC_$_CATEGORY_Foo_$_Category" = private global 
%struct._category_t { {{.*}} %struct._prop_list_t* null, %struct._prop_list_t* 
null, {{.*}} }, section "__DATA, __objc_const", align 8
+
+// CHECK-NULL-NOT: @"\01l_OBJC_$_CLASS_PROP_LIST_C" = private global {{.*}} 
section "__DATA, __objc_const", align 8
+// CHECK-NULL: @"\01l_OBJC_METACLASS_RO_$_C" = private global 
%struct._class_ro_t { {{.*}} %struct._prop_list_t* null }, section "__DATA, 
__objc_const", align 8
+
+// CHECK-NULL: !{i32 1, !"Objective-C Class Properties", i32 64}
+
 // CHECK-FRAGILE: @"OBJC_$_CLASS_PROP_PROTO_LIST_Proto" = private global 
{{.*}} section "__OBJC,__property,regular,no_dead_strip", align 8
 // CHECK-FRAGILE: @"\01l_OBJC_PROTOCOLEXT_Proto" = private global 
%struct._objc_protocol_extension { i32 48, {{.*}} 
@"OBJC_$_CLASS_PROP_PROTO_LIST_Proto" {{.*}} }, align 8
 // CHECK-FRAGILE: @"\01l_OBJC_$_CLASS_PROP_LIST_Foo_Category" = private global 
{{.*}} section "__OBJC,__property,regular,no_dead_strip", align 8


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


r266797 - Fix PR26999 better- RenderDebugEnablingArgs() once only

2016-04-19 Thread Douglas Katzman via cfe-commits
Author: dougk
Date: Tue Apr 19 13:55:53 2016
New Revision: 266797

URL: http://llvm.org/viewvc/llvm-project?rev=266797&view=rev
Log:
Fix PR26999 better- RenderDebugEnablingArgs() once only

Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=266797&r1=266796&r2=266797&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Apr 19 13:55:53 2016
@@ -6227,24 +6227,28 @@ void ClangAs::ConstructJob(Compilation &
 
   // Forward -g and handle debug info related flags, assuming we are dealing
   // with an actual assembly file.
+  bool WantDebug = false;
+  unsigned DwarfVersion = 0;
+  Args.ClaimAllArgs(options::OPT_g_Group);
+  if (Arg *A = Args.getLastArg(options::OPT_g_Group)) {
+WantDebug = !A->getOption().matches(options::OPT_g0) &&
+!A->getOption().matches(options::OPT_ggdb0);
+if (WantDebug)
+  DwarfVersion = DwarfVersionNum(A->getSpelling());
+  }
+  if (DwarfVersion == 0)
+DwarfVersion = getToolChain().GetDefaultDwarfVersion();
+
+  codegenoptions::DebugInfoKind DebugInfoKind = codegenoptions::NoDebugInfo;
+
   if (SourceAction->getType() == types::TY_Asm ||
   SourceAction->getType() == types::TY_PP_Asm) {
-bool WantDebug = false;
-unsigned DwarfVersion = 0;
-Args.ClaimAllArgs(options::OPT_g_Group);
-if (Arg *A = Args.getLastArg(options::OPT_g_Group)) {
-  WantDebug = !A->getOption().matches(options::OPT_g0) &&
-!A->getOption().matches(options::OPT_ggdb0);
-  if (WantDebug)
-DwarfVersion = DwarfVersionNum(A->getSpelling());
-}
-if (DwarfVersion == 0)
-  DwarfVersion = getToolChain().GetDefaultDwarfVersion();
-RenderDebugEnablingArgs(Args, CmdArgs,
-(WantDebug ? codegenoptions::LimitedDebugInfo
-   : codegenoptions::NoDebugInfo),
-DwarfVersion, llvm::DebuggerKind::Default);
-
+// You might think that it would be ok to set DebugInfoKind outside of
+// the guard for source type, however there is a test which asserts
+// that some assembler invocation receives no -debug-info-kind,
+// and it's not clear whether that test is just overly restrictive.
+DebugInfoKind = (WantDebug ? codegenoptions::LimitedDebugInfo
+   : codegenoptions::NoDebugInfo);
 // Add the -fdebug-compilation-dir flag if needed.
 addDebugCompDirArg(Args, CmdArgs);
 
@@ -6257,6 +6261,8 @@ void ClangAs::ConstructJob(Compilation &
 // And pass along -I options
 Args.AddAllArgs(CmdArgs, options::OPT_I);
   }
+  RenderDebugEnablingArgs(Args, CmdArgs, DebugInfoKind, DwarfVersion,
+  llvm::DebuggerKind::Default);
 
   // Handle -fPIC et al -- the relocation-model affects the assembler
   // for some targets.
@@ -6314,12 +6320,6 @@ void ClangAs::ConstructJob(Compilation &
   // FIXME: Stop lying and consume only the appropriate driver flags
   Args.ClaimAllArgs(options::OPT_W_Group);
 
-  // Assemblers that want to know the dwarf version can't assume a value,
-  // since the defaulting logic resides in the driver. Put in something
-  // reasonable now, in case a subsequent "-Wa,-g" changes it.
-  RenderDebugEnablingArgs(Args, CmdArgs, codegenoptions::NoDebugInfo,
-  getToolChain().GetDefaultDwarfVersion(),
-  llvm::DebuggerKind::Default);
   CollectArgsForIntegratedAssembler(C, Args, CmdArgs,
 getToolChain().getDriver());
 


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


Re: r266496 - [CUDA] Raise an error if the CUDA install can't be found.

2016-04-19 Thread Justin Lebar via cfe-commits
Committed a test in r266796.

On Tue, Apr 19, 2016 at 11:42 AM, Justin Lebar  wrote:
>> I don't really understand why having to change the test when we change the 
>> code it test changes...
>
> My thought was, this code isn't really testing how we detect a CUDA
> installation.  That's a separate matter, involving --cuda-path,
> various default locations we check, and so on.
>
> Anyway I now see that we're already biting that cost with existing
> tests, so adding a test for this shouldn't be a big deal.
>
> On Tue, Apr 19, 2016 at 11:33 AM, Chandler Carruth  
> wrote:
>> I don't really understand why having to change the test when we change the
>> code it test changes...
>>
>> We have several fake install trees in the driver tests to check pretty much
>> exactly these kinds of things?
>>
>> On Tue, Apr 19, 2016 at 11:31 AM Justin Lebar via cfe-commits
>>  wrote:
>>>
>>> Yes, in general our testing story around the CUDA installs needs work.
>>> In particular, our wrapper headers are complicated and fragile, and
>>> have zero coverage at the moment.  That's why Art is working on
>>> getting CUDA tests into the test-suite.
>>>
>>> It's possible to test this particular change without access to a full
>>> CUDA installation.  However, I was hesitant to do so, because such a
>>> test would have to create a fake cuda installation.  Our test would
>>> then be fragile with respect to exactly how clang detects that a CUDA
>>> install is "real".  If we changed those heuristics, we'd have to
>>> change our test.
>>>
>>> On Tue, Apr 19, 2016 at 11:21 AM, Chandler Carruth 
>>> wrote:
>>> > This commit is missing a test.
>>> >
>>> >
>>> > On Fri, Apr 15, 2016 at 5:16 PM Justin Lebar via cfe-commits
>>> >  wrote:
>>> >>
>>> >> Author: jlebar
>>> >> Date: Fri Apr 15 19:11:11 2016
>>> >> New Revision: 266496
>>> >>
>>> >> URL: http://llvm.org/viewvc/llvm-project?rev=266496&view=rev
>>> >> Log:
>>> >> [CUDA] Raise an error if the CUDA install can't be found.
>>> >>
>>> >> Summary:
>>> >> Without this change, we silently proceed on without including
>>> >> __clang_cuda_runtime_wrapper.h.  This leads to very strange behavior --
>>> >> you say you're compiling CUDA code, but e.g. __device__ is not defined!
>>> >>
>>> >> Reviewers: tra
>>> >>
>>> >> Subscribers: cfe-commits
>>> >>
>>> >> Differential Revision: http://reviews.llvm.org/D19180
>>> >>
>>> >> Modified:
>>> >> cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
>>> >> cfe/trunk/lib/Driver/ToolChains.cpp
>>> >>
>>> >> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
>>> >> URL:
>>> >>
>>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=266496&r1=266495&r2=266496&view=diff
>>> >>
>>> >>
>>> >> ==
>>> >> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
>>> >> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Apr 15
>>> >> 19:11:11 2016
>>> >> @@ -23,6 +23,9 @@ def err_drv_unknown_language : Error<"la
>>> >>  def err_drv_invalid_arch_name : Error<
>>> >>"invalid arch name '%0'">;
>>> >>  def err_drv_cuda_bad_gpu_arch : Error<"Unsupported CUDA gpu
>>> >> architecture:
>>> >> %0">;
>>> >> +def err_drv_no_cuda_installation : Error<
>>> >> +  "cannot find CUDA installation.  Provide its path via --cuda-path,
>>> >> or
>>> >> pass "
>>> >> +  "-nocudainc to build without CUDA includes.">;
>>> >>  def err_drv_invalid_thread_model_for_target : Error<
>>> >>"invalid thread model '%0' in '%1' for this target">;
>>> >>  def err_drv_invalid_linker_name : Error<
>>> >>
>>> >> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
>>> >> URL:
>>> >>
>>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=266496&r1=266495&r2=266496&view=diff
>>> >>
>>> >>
>>> >> ==
>>> >> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
>>> >> +++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Apr 15 19:11:11 2016
>>> >> @@ -4118,11 +4118,14 @@ void Linux::AddCudaIncludeArgs(const Arg
>>> >>if (DriverArgs.hasArg(options::OPT_nocudainc))
>>> >>  return;
>>> >>
>>> >> -  if (CudaInstallation.isValid()) {
>>> >> -addSystemInclude(DriverArgs, CC1Args,
>>> >> CudaInstallation.getIncludePath());
>>> >> -CC1Args.push_back("-include");
>>> >> -CC1Args.push_back("__clang_cuda_runtime_wrapper.h");
>>> >> +  if (!CudaInstallation.isValid()) {
>>> >> +getDriver().Diag(diag::err_drv_no_cuda_installation);
>>> >> +return;
>>> >>}
>>> >> +
>>> >> +  addSystemInclude(DriverArgs, CC1Args,
>>> >> CudaInstallation.getIncludePath());
>>> >> +  CC1Args.push_back("-include");
>>> >> +  CC1Args.push_back("__clang_cuda_runtime_wrapper.h");
>>> >>  }
>>> >>
>>> >>  bool Linux::isPIEDefault() const { return
>>> >> getSanitizerArgs().requiresPIE(); }
>>> >>
>>> >>
>>> >> ___
>

r266796 - [CUDA] Add a test for r266496 (raise an error if a CUDA installation isn't found)

2016-04-19 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Tue Apr 19 13:52:28 2016
New Revision: 266796

URL: http://llvm.org/viewvc/llvm-project?rev=266796&view=rev
Log:
[CUDA] Add a test for r266496 (raise an error if a CUDA installation isn't 
found)

Added:
cfe/trunk/test/Driver/cuda-not-found.cu

Added: cfe/trunk/test/Driver/cuda-not-found.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-not-found.cu?rev=266796&view=auto
==
--- cfe/trunk/test/Driver/cuda-not-found.cu (added)
+++ cfe/trunk/test/Driver/cuda-not-found.cu Tue Apr 19 13:52:28 2016
@@ -0,0 +1,12 @@
+// REQUIRES: clang-driver
+
+// Check that we raise an error if we're trying to compile CUDA code but can't
+// find a CUDA install, unless -nocudainc was passed.
+
+// RUN: %clang -### --sysroot=%s/no-cuda-there %s 2>&1 | FileCheck %s 
--check-prefix ERR
+// RUN: %clang -### --cuda-path=%s/no-cuda-there %s 2>&1 | FileCheck %s 
--check-prefix ERR
+// ERR: cannot find CUDA installation
+
+// RUN: %clang -### -nocudainc --sysroot=%s/no-cuda-there %s 2>&1 | FileCheck 
%s --check-prefix OK
+// RUN: %clang -### -nocudainc --cuda-path=%s/no-cuda-there %s 2>&1 | 
FileCheck %s --check-prefix OK
+// OK-NOT: cannot find CUDA installation


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


[clang-tools-extra] r266795 - [Clang-tidy] Fix extra semicolon warning in cppcoreguidelines/ProTypeMemberInitCheck.cpp.

2016-04-19 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Tue Apr 19 13:49:21 2016
New Revision: 266795

URL: http://llvm.org/viewvc/llvm-project?rev=266795&view=rev
Log:
[Clang-tidy] Fix extra semicolon warning in 
cppcoreguidelines/ProTypeMemberInitCheck.cpp.

Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp?rev=266795&r1=266794&r2=266795&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
Tue Apr 19 13:49:21 2016
@@ -77,7 +77,7 @@ SourceLocation getLocationForEndOfToken(
 SourceLocation Location) {
   return Lexer::getLocForEndOfToken(Location, 0, Context.getSourceManager(),
 Context.getLangOpts());
-};
+}
 
 // There are 3 kinds of insertion placements:
 enum class InitializerPlacement {
@@ -248,7 +248,7 @@ void forEachField(const RecordDecl *Reco
   }
 }
 
-} // namespace
+} // anonymous namespace
 
 ProTypeMemberInitCheck::ProTypeMemberInitCheck(StringRef Name,
ClangTidyContext *Context)


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


Re: r266496 - [CUDA] Raise an error if the CUDA install can't be found.

2016-04-19 Thread Justin Lebar via cfe-commits
> I don't really understand why having to change the test when we change the 
> code it test changes...

My thought was, this code isn't really testing how we detect a CUDA
installation.  That's a separate matter, involving --cuda-path,
various default locations we check, and so on.

Anyway I now see that we're already biting that cost with existing
tests, so adding a test for this shouldn't be a big deal.

On Tue, Apr 19, 2016 at 11:33 AM, Chandler Carruth  wrote:
> I don't really understand why having to change the test when we change the
> code it test changes...
>
> We have several fake install trees in the driver tests to check pretty much
> exactly these kinds of things?
>
> On Tue, Apr 19, 2016 at 11:31 AM Justin Lebar via cfe-commits
>  wrote:
>>
>> Yes, in general our testing story around the CUDA installs needs work.
>> In particular, our wrapper headers are complicated and fragile, and
>> have zero coverage at the moment.  That's why Art is working on
>> getting CUDA tests into the test-suite.
>>
>> It's possible to test this particular change without access to a full
>> CUDA installation.  However, I was hesitant to do so, because such a
>> test would have to create a fake cuda installation.  Our test would
>> then be fragile with respect to exactly how clang detects that a CUDA
>> install is "real".  If we changed those heuristics, we'd have to
>> change our test.
>>
>> On Tue, Apr 19, 2016 at 11:21 AM, Chandler Carruth 
>> wrote:
>> > This commit is missing a test.
>> >
>> >
>> > On Fri, Apr 15, 2016 at 5:16 PM Justin Lebar via cfe-commits
>> >  wrote:
>> >>
>> >> Author: jlebar
>> >> Date: Fri Apr 15 19:11:11 2016
>> >> New Revision: 266496
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=266496&view=rev
>> >> Log:
>> >> [CUDA] Raise an error if the CUDA install can't be found.
>> >>
>> >> Summary:
>> >> Without this change, we silently proceed on without including
>> >> __clang_cuda_runtime_wrapper.h.  This leads to very strange behavior --
>> >> you say you're compiling CUDA code, but e.g. __device__ is not defined!
>> >>
>> >> Reviewers: tra
>> >>
>> >> Subscribers: cfe-commits
>> >>
>> >> Differential Revision: http://reviews.llvm.org/D19180
>> >>
>> >> Modified:
>> >> cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
>> >> cfe/trunk/lib/Driver/ToolChains.cpp
>> >>
>> >> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
>> >> URL:
>> >>
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=266496&r1=266495&r2=266496&view=diff
>> >>
>> >>
>> >> ==
>> >> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
>> >> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Apr 15
>> >> 19:11:11 2016
>> >> @@ -23,6 +23,9 @@ def err_drv_unknown_language : Error<"la
>> >>  def err_drv_invalid_arch_name : Error<
>> >>"invalid arch name '%0'">;
>> >>  def err_drv_cuda_bad_gpu_arch : Error<"Unsupported CUDA gpu
>> >> architecture:
>> >> %0">;
>> >> +def err_drv_no_cuda_installation : Error<
>> >> +  "cannot find CUDA installation.  Provide its path via --cuda-path,
>> >> or
>> >> pass "
>> >> +  "-nocudainc to build without CUDA includes.">;
>> >>  def err_drv_invalid_thread_model_for_target : Error<
>> >>"invalid thread model '%0' in '%1' for this target">;
>> >>  def err_drv_invalid_linker_name : Error<
>> >>
>> >> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
>> >> URL:
>> >>
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=266496&r1=266495&r2=266496&view=diff
>> >>
>> >>
>> >> ==
>> >> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
>> >> +++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Apr 15 19:11:11 2016
>> >> @@ -4118,11 +4118,14 @@ void Linux::AddCudaIncludeArgs(const Arg
>> >>if (DriverArgs.hasArg(options::OPT_nocudainc))
>> >>  return;
>> >>
>> >> -  if (CudaInstallation.isValid()) {
>> >> -addSystemInclude(DriverArgs, CC1Args,
>> >> CudaInstallation.getIncludePath());
>> >> -CC1Args.push_back("-include");
>> >> -CC1Args.push_back("__clang_cuda_runtime_wrapper.h");
>> >> +  if (!CudaInstallation.isValid()) {
>> >> +getDriver().Diag(diag::err_drv_no_cuda_installation);
>> >> +return;
>> >>}
>> >> +
>> >> +  addSystemInclude(DriverArgs, CC1Args,
>> >> CudaInstallation.getIncludePath());
>> >> +  CC1Args.push_back("-include");
>> >> +  CC1Args.push_back("__clang_cuda_runtime_wrapper.h");
>> >>  }
>> >>
>> >>  bool Linux::isPIEDefault() const { return
>> >> getSanitizerArgs().requiresPIE(); }
>> >>
>> >>
>> >> ___
>> >> cfe-commits mailing list
>> >> cfe-commits@lists.llvm.org
>> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>> ___
>> cfe-commits mailing list
>> cfe-co

Re: [PATCH] D19106: Fixed a bug in AnnotatedLine::startsWith when there are comments in the line.

2016-04-19 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.



Comment at: lib/Format/TokenAnnotator.h:128
@@ +127,3 @@
+  bool startsWithInternal(const FormatToken *Tok, A K1) const {
+// Even though we skip comments in the outter `startWithInternal` function,
+// this loop is still necessary if it is invoked by the public interface

s/outter/outer/


http://reviews.llvm.org/D19106



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


Re: [PATCH] D19106: Fixed a bug in AnnotatedLine::startsWith when there are comments in the line.

2016-04-19 Thread Eric Liu via cfe-commits
PING.

On Thu, Apr 14, 2016 at 1:52 PM Eric Liu  wrote:

> ioeric updated this revision to Diff 53691.
> ioeric added a comment.
>
> - Addressed reviewer comment.
>
>
> http://reviews.llvm.org/D19106
>
> Files:
>   lib/Format/TokenAnnotator.h
>
> Index: lib/Format/TokenAnnotator.h
> ===
> --- lib/Format/TokenAnnotator.h
> +++ lib/Format/TokenAnnotator.h
> @@ -83,7 +83,7 @@
>/// \c true if this line starts with the given tokens in order, ignoring
>/// comments.
>template  bool startsWith(Ts... Tokens) const {
> -return startsWith(First, Tokens...);
> +return startsWithInternal(First, Tokens...);
>}
>
>/// \c true if this line looks like a function definition instead of a
> @@ -124,15 +124,24 @@
>void operator=(const AnnotatedLine &) = delete;
>
>template 
> -  bool startsWith(FormatToken *Tok, A K1) const {
> +  bool startsWithInternal(const FormatToken *Tok, A K1) const {
> +// Even though we skip comments in the outter `startWithInternal`
> function,
> +// this loop is still necessary if it is invoked by the public
> interface
> +// `startsWith`.
>  while (Tok && Tok->is(tok::comment))
>Tok = Tok->Next;
>  return Tok && Tok->is(K1);
>}
>
>template 
> -  bool startsWith(FormatToken *Tok, A K1, Ts... Tokens) const {
> -return startsWith(Tok, K1) && startsWith(Tok->Next, Tokens...);
> +  bool startsWithInternal(const FormatToken *Tok, A K1, Ts... Tokens)
> const {
> +// Skip comments before calling `startsWithInternal(Tok, K1)` so
> that  the
> +// second call to `startsWithInternal` takes the correct `Tok->Next`,
> which
> +// should be the next token of the token checked in the first call.
> +while (Tok && Tok->is(tok::comment))
> +  Tok = Tok->Next;
> +return Tok && startsWithInternal(Tok, K1) &&
> +   startsWithInternal(Tok->Next, Tokens...);
>}
>  };
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r266496 - [CUDA] Raise an error if the CUDA install can't be found.

2016-04-19 Thread Chandler Carruth via cfe-commits
I don't really understand why having to change the test when we change the
code it test changes...

We have several fake install trees in the driver tests to check pretty much
exactly these kinds of things?

On Tue, Apr 19, 2016 at 11:31 AM Justin Lebar via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Yes, in general our testing story around the CUDA installs needs work.
> In particular, our wrapper headers are complicated and fragile, and
> have zero coverage at the moment.  That's why Art is working on
> getting CUDA tests into the test-suite.
>
> It's possible to test this particular change without access to a full
> CUDA installation.  However, I was hesitant to do so, because such a
> test would have to create a fake cuda installation.  Our test would
> then be fragile with respect to exactly how clang detects that a CUDA
> install is "real".  If we changed those heuristics, we'd have to
> change our test.
>
> On Tue, Apr 19, 2016 at 11:21 AM, Chandler Carruth 
> wrote:
> > This commit is missing a test.
> >
> >
> > On Fri, Apr 15, 2016 at 5:16 PM Justin Lebar via cfe-commits
> >  wrote:
> >>
> >> Author: jlebar
> >> Date: Fri Apr 15 19:11:11 2016
> >> New Revision: 266496
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=266496&view=rev
> >> Log:
> >> [CUDA] Raise an error if the CUDA install can't be found.
> >>
> >> Summary:
> >> Without this change, we silently proceed on without including
> >> __clang_cuda_runtime_wrapper.h.  This leads to very strange behavior --
> >> you say you're compiling CUDA code, but e.g. __device__ is not defined!
> >>
> >> Reviewers: tra
> >>
> >> Subscribers: cfe-commits
> >>
> >> Differential Revision: http://reviews.llvm.org/D19180
> >>
> >> Modified:
> >> cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> >> cfe/trunk/lib/Driver/ToolChains.cpp
> >>
> >> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=266496&r1=266495&r2=266496&view=diff
> >>
> >>
> ==
> >> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
> >> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Apr 15
> >> 19:11:11 2016
> >> @@ -23,6 +23,9 @@ def err_drv_unknown_language : Error<"la
> >>  def err_drv_invalid_arch_name : Error<
> >>"invalid arch name '%0'">;
> >>  def err_drv_cuda_bad_gpu_arch : Error<"Unsupported CUDA gpu
> architecture:
> >> %0">;
> >> +def err_drv_no_cuda_installation : Error<
> >> +  "cannot find CUDA installation.  Provide its path via --cuda-path, or
> >> pass "
> >> +  "-nocudainc to build without CUDA includes.">;
> >>  def err_drv_invalid_thread_model_for_target : Error<
> >>"invalid thread model '%0' in '%1' for this target">;
> >>  def err_drv_invalid_linker_name : Error<
> >>
> >> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=266496&r1=266495&r2=266496&view=diff
> >>
> >>
> ==
> >> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
> >> +++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Apr 15 19:11:11 2016
> >> @@ -4118,11 +4118,14 @@ void Linux::AddCudaIncludeArgs(const Arg
> >>if (DriverArgs.hasArg(options::OPT_nocudainc))
> >>  return;
> >>
> >> -  if (CudaInstallation.isValid()) {
> >> -addSystemInclude(DriverArgs, CC1Args,
> >> CudaInstallation.getIncludePath());
> >> -CC1Args.push_back("-include");
> >> -CC1Args.push_back("__clang_cuda_runtime_wrapper.h");
> >> +  if (!CudaInstallation.isValid()) {
> >> +getDriver().Diag(diag::err_drv_no_cuda_installation);
> >> +return;
> >>}
> >> +
> >> +  addSystemInclude(DriverArgs, CC1Args,
> >> CudaInstallation.getIncludePath());
> >> +  CC1Args.push_back("-include");
> >> +  CC1Args.push_back("__clang_cuda_runtime_wrapper.h");
> >>  }
> >>
> >>  bool Linux::isPIEDefault() const { return
> >> getSanitizerArgs().requiresPIE(); }
> >>
> >>
> >> ___
> >> 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
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19204: clang-format: [JS] generator and async functions.

2016-04-19 Thread Martin Probst via cfe-commits
mprobst marked an inline comment as done.


Comment at: unittests/Format/FormatTestJS.cpp:339
@@ +338,3 @@
+TEST_F(FormatTestJS, AsyncFunctions) {
+  verifyFormat("async function f() {\n"
+   "  let x = 1;\n"

djasper wrote:
> Fundamentally, I think there is two things we might need to do:
> 1. Not allow wrapping it. I am ok with keeping that based on the operator 
> wrapping for now, but it seems a bit dodgy.
> 2. The ExpressionParser in TokenAnnotator.cpp must not treat this as a binary 
> operator or else it might do weird things with indentation. What't the token 
> type at the moment?
For (1) if needed we can detect the immediately preceding `function`.
For (2), token type is `tok::star`. Indentation in the wrapping example seems 
fine.

Overall I find it highly unlikely that this becomes a problem, having generator 
functions that wrap is unlikely, they tend to be top level functions.


http://reviews.llvm.org/D19204



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


Re: r266496 - [CUDA] Raise an error if the CUDA install can't be found.

2016-04-19 Thread Justin Lebar via cfe-commits
Yes, in general our testing story around the CUDA installs needs work.
In particular, our wrapper headers are complicated and fragile, and
have zero coverage at the moment.  That's why Art is working on
getting CUDA tests into the test-suite.

It's possible to test this particular change without access to a full
CUDA installation.  However, I was hesitant to do so, because such a
test would have to create a fake cuda installation.  Our test would
then be fragile with respect to exactly how clang detects that a CUDA
install is "real".  If we changed those heuristics, we'd have to
change our test.

On Tue, Apr 19, 2016 at 11:21 AM, Chandler Carruth  wrote:
> This commit is missing a test.
>
>
> On Fri, Apr 15, 2016 at 5:16 PM Justin Lebar via cfe-commits
>  wrote:
>>
>> Author: jlebar
>> Date: Fri Apr 15 19:11:11 2016
>> New Revision: 266496
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=266496&view=rev
>> Log:
>> [CUDA] Raise an error if the CUDA install can't be found.
>>
>> Summary:
>> Without this change, we silently proceed on without including
>> __clang_cuda_runtime_wrapper.h.  This leads to very strange behavior --
>> you say you're compiling CUDA code, but e.g. __device__ is not defined!
>>
>> Reviewers: tra
>>
>> Subscribers: cfe-commits
>>
>> Differential Revision: http://reviews.llvm.org/D19180
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
>> cfe/trunk/lib/Driver/ToolChains.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=266496&r1=266495&r2=266496&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Apr 15
>> 19:11:11 2016
>> @@ -23,6 +23,9 @@ def err_drv_unknown_language : Error<"la
>>  def err_drv_invalid_arch_name : Error<
>>"invalid arch name '%0'">;
>>  def err_drv_cuda_bad_gpu_arch : Error<"Unsupported CUDA gpu architecture:
>> %0">;
>> +def err_drv_no_cuda_installation : Error<
>> +  "cannot find CUDA installation.  Provide its path via --cuda-path, or
>> pass "
>> +  "-nocudainc to build without CUDA includes.">;
>>  def err_drv_invalid_thread_model_for_target : Error<
>>"invalid thread model '%0' in '%1' for this target">;
>>  def err_drv_invalid_linker_name : Error<
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=266496&r1=266495&r2=266496&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Apr 15 19:11:11 2016
>> @@ -4118,11 +4118,14 @@ void Linux::AddCudaIncludeArgs(const Arg
>>if (DriverArgs.hasArg(options::OPT_nocudainc))
>>  return;
>>
>> -  if (CudaInstallation.isValid()) {
>> -addSystemInclude(DriverArgs, CC1Args,
>> CudaInstallation.getIncludePath());
>> -CC1Args.push_back("-include");
>> -CC1Args.push_back("__clang_cuda_runtime_wrapper.h");
>> +  if (!CudaInstallation.isValid()) {
>> +getDriver().Diag(diag::err_drv_no_cuda_installation);
>> +return;
>>}
>> +
>> +  addSystemInclude(DriverArgs, CC1Args,
>> CudaInstallation.getIncludePath());
>> +  CC1Args.push_back("-include");
>> +  CC1Args.push_back("__clang_cuda_runtime_wrapper.h");
>>  }
>>
>>  bool Linux::isPIEDefault() const { return
>> getSanitizerArgs().requiresPIE(); }
>>
>>
>> ___
>> 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] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-04-19 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 54233.
ioeric marked 6 inline comments as done.
ioeric added a comment.

- Rebased
- Make Formatter and Cleaner inherit from TokenAnalyzer (new name for 
CodeProcessor).


http://reviews.llvm.org/D18551

Files:
  include/clang/Format/Format.h
  lib/Format/AffectedRangeManager.cpp
  lib/Format/AffectedRangeManager.h
  lib/Format/CMakeLists.txt
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.h
  unittests/Format/CMakeLists.txt
  unittests/Format/CleanupTest.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11526,6 +11526,35 @@
   Code, formatReplacements(Code, Replaces, Style)));
 }
 
+TEST_F(ReplacementTest, FixOnlyAffectedCodeAfterReplacements) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n"
+ "  int x;\n"
+ "} // namespace B\n"
+ "} // namespace A\n"
+ "\n"
+ "namespace C {\n"
+ "namespace D { int i; }\n"
+ "inline namespace E { namespace { int y; } }\n"
+ "int x= 0;"
+ "}";
+  std::string Expected = "\n\nnamespace C {\n"
+ "namespace D { int i; }\n\n"
+ "int x= 0;"
+ "}";
+  FileID ID = Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 3, 3), 6, ""));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 9, 34), 6, ""));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto FinalReplaces = formatReplacements(
+  Code, cleanupAroundReplacements(Code, Replaces, Style), Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: unittests/Format/CleanupTest.cpp
===
--- /dev/null
+++ unittests/Format/CleanupTest.cpp
@@ -0,0 +1,118 @@
+//===- unittest/Format/CleanupTest.cpp - Code cleanup unit tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Format/Format.h"
+
+#include "clang/Tooling/Core/Replacement.h"
+
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace format {
+namespace {
+
+class CleanupTest : public ::testing::Test {
+protected:
+  std::string cleanup(llvm::StringRef Code,
+  const std::vector &Ranges,
+  const FormatStyle &Style = getLLVMStyle()) {
+tooling::Replacements Replaces = format::cleanup(Style, Code, Ranges);
+
+std::string Result = applyAllReplacements(Code, Replaces);
+EXPECT_NE("", Result);
+return Result;
+  }
+};
+
+TEST_F(CleanupTest, DeleteEmptyNamespaces) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n"
+ "} // namespace B\n"
+ "} // namespace A\n\n"
+ "namespace C {\n"
+ "namespace D { int i; }\n"
+ "inline namespace E { namespace { } }\n"
+ "}";
+  std::string Expected = "\n\n\n\n\nnamespace C {\n"
+ "namespace D { int i; }\n   \n"
+ "}";
+  std::vector Ranges;
+  Ranges.push_back(tooling::Range(28, 0));
+  Ranges.push_back(tooling::Range(91, 6));
+  Ranges.push_back(tooling::Range(132, 0));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, NamespaceWithSyntaxError) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n" // missing r_brace
+ "} // namespace A\n\n"
+ "namespace C {\n"
+ "namespace D int i; }\n"
+ "inline namespace E { namespace { } }\n"
+ "}";
+  std::string Expected = "namespace A {\n"
+ "\n\n\nnamespace C {\n"
+ "namespace D int i; }\n   \n"
+ "}";
+  std::vector Ranges(1, tooling::Range(0, Code.size()));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, EmptyNamespaceNotAffected) {
+  std::string Code = "namespace A {\n\n"
+ "namespace {\n\n}}";
+  // Even though the namespaces are empty, but the inner most empty namespace
+  // block is not affected by the changed ranges.
+  std:

Re: [PATCH] D19204: clang-format: [JS] generator and async functions.

2016-04-19 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: unittests/Format/FormatTestJS.cpp:339
@@ +338,3 @@
+TEST_F(FormatTestJS, AsyncFunctions) {
+  verifyFormat("async function f() {\n"
+   "  let x = 1;\n"

Fundamentally, I think there is two things we might need to do:
1. Not allow wrapping it. I am ok with keeping that based on the operator 
wrapping for now, but it seems a bit dodgy.
2. The ExpressionParser in TokenAnnotator.cpp must not treat this as a binary 
operator or else it might do weird things with indentation. What't the token 
type at the moment?


http://reviews.llvm.org/D19204



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


Re: [PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit

2016-04-19 Thread JF Bastien via cfe-commits
jfb added inline comments.


Comment at: lib/CodeGen/CGDeclCXX.cpp:94
@@ -92,2 +93,3 @@
   if (dtorKind == QualType::DK_cxx_destructor &&
-  (record = type->getAsCXXRecordDecl())) {
+  (record = type->getAsCXXRecordDecl()) &&
+  (!CGM.getCXXABI().HasThisReturn(

This assignment is looking pretty ugly now, would be better to move out of line.


Comment at: lib/CodeGen/CGDeclCXX.cpp:97
@@ -94,1 +96,3 @@
+  GlobalDecl(record->getDestructor(), Dtor_Complete)) ||
+   !CGM.getCodeGenOpts().CXAAtExit)) {
 assert(!record->hasTrivialDestructor());

Could you also pull out these conditions into their own bool? I find the ands 
and ors hard to follow!


Comment at: test/CodeGenCXX/static-destructor.cpp:6
@@ +5,3 @@
+// signatures do not match the type of its first argument.
+// e.g. ARM and WebAssembly have destructors that return this instead of void.
+

You mention ARM but don't test ARM here.


http://reviews.llvm.org/D19275



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


Re: [PATCH] D19240: clang-format: [JS] support `interface` as a free standing identifier.

2016-04-19 Thread Martin Probst via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266789: clang-format: [JS] support `interface` as a free 
standing identifier. (authored by mprobst).

Changed prior to commit:
  http://reviews.llvm.org/D19240?vs=54218&id=54232#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19240

Files:
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp

Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -1007,6 +1007,21 @@
   if ((Style.Language == FormatStyle::LK_JavaScript ||
Style.Language == FormatStyle::LK_Java) &&
   FormatTok->is(Keywords.kw_interface)) {
+if (Style.Language == FormatStyle::LK_JavaScript) {
+  // In JavaScript/TypeScript, "interface" can be used as a standalone
+  // identifier, e.g. in `var interface = 1;`. If "interface" is
+  // followed by another identifier, it is very like to be an actual
+  // interface declaration.
+  unsigned StoredPosition = Tokens->getPosition();
+  FormatToken *Next = Tokens->getNextToken();
+  FormatTok = Tokens->setPosition(StoredPosition);
+  if (Next && (Next->isNot(tok::identifier) ||
+   Next->isOneOf(Keywords.kw_instanceof, Keywords.kw_of,
+ Keywords.kw_in))) {
+nextToken();
+break;
+  }
+}
 parseRecord();
 addUnwrappedLine();
 return;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -136,6 +136,9 @@
"};");
   verifyFormat("var struct = 2;");
   verifyFormat("var union = 2;");
+  verifyFormat("var interface = 2;");
+  verifyFormat("interface = 2;");
+  verifyFormat("x = interface instanceof y;");
 }
 
 TEST_F(FormatTestJS, CppKeywords) {


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -1007,6 +1007,21 @@
   if ((Style.Language == FormatStyle::LK_JavaScript ||
Style.Language == FormatStyle::LK_Java) &&
   FormatTok->is(Keywords.kw_interface)) {
+if (Style.Language == FormatStyle::LK_JavaScript) {
+  // In JavaScript/TypeScript, "interface" can be used as a standalone
+  // identifier, e.g. in `var interface = 1;`. If "interface" is
+  // followed by another identifier, it is very like to be an actual
+  // interface declaration.
+  unsigned StoredPosition = Tokens->getPosition();
+  FormatToken *Next = Tokens->getNextToken();
+  FormatTok = Tokens->setPosition(StoredPosition);
+  if (Next && (Next->isNot(tok::identifier) ||
+   Next->isOneOf(Keywords.kw_instanceof, Keywords.kw_of,
+ Keywords.kw_in))) {
+nextToken();
+break;
+  }
+}
 parseRecord();
 addUnwrappedLine();
 return;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -136,6 +136,9 @@
"};");
   verifyFormat("var struct = 2;");
   verifyFormat("var union = 2;");
+  verifyFormat("var interface = 2;");
+  verifyFormat("interface = 2;");
+  verifyFormat("x = interface instanceof y;");
 }
 
 TEST_F(FormatTestJS, CppKeywords) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r266788 - [builtin_expect] tighten checks, add test, add comments

2016-04-19 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Tue Apr 19 13:17:34 2016
New Revision: 266788

URL: http://llvm.org/viewvc/llvm-project?rev=266788&view=rev
Log:
[builtin_expect] tighten checks, add test, add comments

Modified:
cfe/trunk/test/CodeGen/builtin-expect.c

Modified: cfe/trunk/test/CodeGen/builtin-expect.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-expect.c?rev=266788&r1=266787&r2=266788&view=diff
==
--- cfe/trunk/test/CodeGen/builtin-expect.c (original)
+++ cfe/trunk/test/CodeGen/builtin-expect.c Tue Apr 19 13:17:34 2016
@@ -1,45 +1,69 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | 
FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -O0 | 
FileCheck %s --check-prefix=CHECK_O0
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -O1 
-disable-llvm-optzns | FileCheck %s --check-prefix=ALL --check-prefix=O1
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -O0 | 
FileCheck %s --check-prefix=ALL --check-prefix=O0
+
+// In all tests, make sure that no expect is generated if optimizations are 
off.
+// If optimizations are on, generate the correct expect and preserve other 
necessary operations.
+
+int expect_taken(int x) {
+// ALL-LABEL: define i32 @expect_taken
+// O1:call i64 @llvm.expect.i64(i64 {{%.*}}, i64 1)
+// O0-NOT:@llvm.expect
+
+  if (__builtin_expect (x, 1))
+return 0;
+  return x;
+}
+
+
+int expect_not_taken(int x) {
+// ALL-LABEL: define i32 @expect_not_taken
+// O1:call i64 @llvm.expect.i64(i64 {{%.*}}, i64 0)
+// O0-NOT:@llvm.expect
+
+  if (__builtin_expect (x, 0))
+return 0;
+  return x;
+}
+
 
 int x;
 int y(void);
 void foo();
-void FUNC() {
-// CHECK-LABEL: define void @FUNC()
-// CHECK: [[call:%.*]] = call i32 @y
-// CHECK_O0: [[call:%.*]] = call i32 @y
-// CHECK_O0-NOT: call i64 @llvm.expect
+
+void expect_value_side_effects() {
+// ALL-LABEL: define void @expect_value_side_effects()
+// ALL:   [[CALL:%.*]] = call i32 @y
+// O1:[[SEXT:%.*]] = sext i32 [[CALL]] to i64
+// O1:call i64 @llvm.expect.i64(i64 {{%.*}}, i64 [[SEXT]])
+// O0-NOT:@llvm.expect
+
   if (__builtin_expect (x, y()))
 foo ();
 }
 
+
+// Make sure that issigprocmask() is called before bar()?
+// There's no compare, so there's nothing to expect?
 // rdar://9330105
 void isigprocmask(void);
 long bar();
 
 int main() {
-(void) __builtin_expect((isigprocmask(), 0), bar());
-}
+// ALL-LABEL: define i32 @main()
+// ALL:   call void @isigprocmask()
+// ALL:   [[CALL:%.*]] = call i64 (...) @bar()
+// O1:call i64 @llvm.expect.i64(i64 0, i64 [[CALL]])
+// O0-NOT:@llvm.expect
 
-// CHECK-LABEL: define i32 @main()
-// CHECK: call void @isigprocmask()
-// CHECK: [[C:%.*]] = call i64 (...) @bar()
-// CHECK_O0: call void @isigprocmask()
-// CHECK_O0: [[C:%.*]] = call i64 (...) @bar()
-// CHECK_O0-NOT: call i64 @llvm.expect
+  (void) __builtin_expect((isigprocmask(), 0), bar());
+}
 
 
-// CHECK-LABEL: define i32 @test1
-int test1(int x) {
-// CHECK_O0-NOT: call i64 @llvm.expect
-  if (__builtin_expect (x, 1))
-return 0;
-  return x;
-}
+int switch_cond(int x) {
+// ALL-LABEL: define i32 @switch_cond
+// O1:call i64 @llvm.expect.i64(i64 {{%.*}}, i64 5)
+// O0-NOT:@llvm.expect
 
-// CHECK: define i32 @test2
-int test2(int x) {
-// CHECK_O0-NOT: call i64 @llvm.expect
   switch(__builtin_expect(x, 5)) {
   default:
 return 0;
@@ -53,3 +77,4 @@ int test2(int x) {
 
   return 0;
 }
+


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


Re: r266496 - [CUDA] Raise an error if the CUDA install can't be found.

2016-04-19 Thread Chandler Carruth via cfe-commits
This commit is missing a test.

On Fri, Apr 15, 2016 at 5:16 PM Justin Lebar via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: jlebar
> Date: Fri Apr 15 19:11:11 2016
> New Revision: 266496
>
> URL: http://llvm.org/viewvc/llvm-project?rev=266496&view=rev
> Log:
> [CUDA] Raise an error if the CUDA install can't be found.
>
> Summary:
> Without this change, we silently proceed on without including
> __clang_cuda_runtime_wrapper.h.  This leads to very strange behavior --
> you say you're compiling CUDA code, but e.g. __device__ is not defined!
>
> Reviewers: tra
>
> Subscribers: cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D19180
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> cfe/trunk/lib/Driver/ToolChains.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=266496&r1=266495&r2=266496&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Apr 15
> 19:11:11 2016
> @@ -23,6 +23,9 @@ def err_drv_unknown_language : Error<"la
>  def err_drv_invalid_arch_name : Error<
>"invalid arch name '%0'">;
>  def err_drv_cuda_bad_gpu_arch : Error<"Unsupported CUDA gpu architecture:
> %0">;
> +def err_drv_no_cuda_installation : Error<
> +  "cannot find CUDA installation.  Provide its path via --cuda-path, or
> pass "
> +  "-nocudainc to build without CUDA includes.">;
>  def err_drv_invalid_thread_model_for_target : Error<
>"invalid thread model '%0' in '%1' for this target">;
>  def err_drv_invalid_linker_name : Error<
>
> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=266496&r1=266495&r2=266496&view=diff
>
> ==
> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Apr 15 19:11:11 2016
> @@ -4118,11 +4118,14 @@ void Linux::AddCudaIncludeArgs(const Arg
>if (DriverArgs.hasArg(options::OPT_nocudainc))
>  return;
>
> -  if (CudaInstallation.isValid()) {
> -addSystemInclude(DriverArgs, CC1Args,
> CudaInstallation.getIncludePath());
> -CC1Args.push_back("-include");
> -CC1Args.push_back("__clang_cuda_runtime_wrapper.h");
> +  if (!CudaInstallation.isValid()) {
> +getDriver().Diag(diag::err_drv_no_cuda_installation);
> +return;
>}
> +
> +  addSystemInclude(DriverArgs, CC1Args,
> CudaInstallation.getIncludePath());
> +  CC1Args.push_back("-include");
> +  CC1Args.push_back("__clang_cuda_runtime_wrapper.h");
>  }
>
>  bool Linux::isPIEDefault() const { return
> getSanitizerArgs().requiresPIE(); }
>
>
> ___
> 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] D19275: Do not register incompatible C++ destructors with __cxa_atexit

2016-04-19 Thread Derek Schuff via cfe-commits
dschuff added a reviewer: sunfish.
dschuff added a comment.

Will want a reviewer who's involved with ARM too, still looking.


http://reviews.llvm.org/D19275



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


[PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit

2016-04-19 Thread Derek Schuff via cfe-commits
dschuff created this revision.
dschuff added a subscriber: cfe-commits.
Herald added subscribers: dschuff, jfb, aemerson.

For a static object with a nontrivial destructor, clang generates an
initializer function (__cxx_global_var_init) which registers that
object's destructor using __cxa_atexit. However some ABIs (ARM,
WebAssembly) use destructors that return 'this' instead of having void
return (which does not match the signature of function pointers passed
to __cxa_atexit). This results in undefined behavior when the destructors are
called. All the calling conventions I know of on ARM can tolerate this,
but WebAssembly requires the signatures of indirect calls to match the
called function.

This patch disables that direct registration of destructors for ABIs
that have this-returning destructors.

http://reviews.llvm.org/D19275

Files:
  lib/CodeGen/CGDeclCXX.cpp
  test/CodeGenCXX/runtimecc.cpp
  test/CodeGenCXX/static-destructor.cpp

Index: test/CodeGenCXX/static-destructor.cpp
===
--- /dev/null
+++ test/CodeGenCXX/static-destructor.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck 
--check-prefix=X86 %s
+// RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck 
--check-prefix=WASM %s
+
+// Test that destructors are not passed directly to __cxa_atexit when their
+// signatures do not match the type of its first argument.
+// e.g. ARM and WebAssembly have destructors that return this instead of void.
+
+
+class Foo {
+ public:
+  ~Foo() {
+  }
+};
+
+Foo global;
+
+// X86 destructors have void return, and are registered directly with 
__cxa_atexit.
+// X86: define internal void @__cxx_global_var_init()
+// X86-NEXT: entry:
+// X86-NEXT:   %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (void 
(%class.Foo*)* @_ZN3FooD1Ev to void (i8*)*), i8* getelementptr inbounds 
(%class.Foo, %class.Foo* @global, i32 0, i32 0), i8* @__dso_handle)
+
+// Wasm destructors return this, and use a wrapper function, which is 
registered
+// with __cxa_atexit.
+// WASM: define internal void @__cxx_global_var_init()
+// WASM-NEXT: entry:
+// WASM-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* 
@__cxx_global_array_dtor, i8* null, i8* @__dso_handle)
+
+// WASM: define internal void @__cxx_global_array_dtor(i8*)
+// WASM: %call = call %class.Foo* @_ZN3FooD1Ev(%class.Foo* @global)
Index: test/CodeGenCXX/runtimecc.cpp
===
--- test/CodeGenCXX/runtimecc.cpp
+++ test/CodeGenCXX/runtimecc.cpp
@@ -22,8 +22,13 @@
   A global;
 // CHECK-LABEL:define internal void @__cxx_global_var_init()
 // CHECK:  call [[A]]* @_ZN5test01AC1Ev([[A]]* @_ZN5test06globalE)
-// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* bitcast ([[A]]* ([[A]]*)* 
@_ZN5test01AD1Ev to void (i8*)*), i8* bitcast ([[A]]* @_ZN5test06globalE to 
i8*), i8* @__dso_handle) [[NOUNWIND:#[0-9]+]]
+// CHECK-NEXT: call i32 @__cxa_atexit(void (i8*)* @__cxx_global_array_dtor, 
i8* null, i8* @__dso_handle) [[NOUNWIND:#[0-9]+]]
 // CHECK-NEXT: ret void
+
+// CHECK-LABEL: define internal void @__cxx_global_array_dtor(i8*)
+// CHECK: call [[A]]* @_ZN5test01AD1Ev([[A]]* @_ZN5test06globalE)
+// CHECK-NEXT: ret void
+
 }
 
 // CHECK: declare i32 @__cxa_atexit(void (i8*)*, i8*, i8*) [[NOUNWIND]]
Index: lib/CodeGen/CGDeclCXX.cpp
===
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -86,11 +86,15 @@
   llvm::Constant *function;
   llvm::Constant *argument;
 
-  // Special-case non-array C++ destructors, where there's a function
-  // with the right signature that we can just call.
+  // Special-case non-array C++ destructors, if they have the right signature
+  // that can be directly registered with __cxa_atexit. If __cxa_atexit is
+  // disabled via a flag, a different helper function is generated anyway.
   const CXXRecordDecl *record = nullptr;
   if (dtorKind == QualType::DK_cxx_destructor &&
-  (record = type->getAsCXXRecordDecl())) {
+  (record = type->getAsCXXRecordDecl()) &&
+  (!CGM.getCXXABI().HasThisReturn(
+  GlobalDecl(record->getDestructor(), Dtor_Complete)) ||
+   !CGM.getCodeGenOpts().CXAAtExit)) {
 assert(!record->hasTrivialDestructor());
 CXXDestructorDecl *dtor = record->getDestructor();
 


Index: test/CodeGenCXX/static-destructor.cpp
===
--- /dev/null
+++ test/CodeGenCXX/static-destructor.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck --check-prefix=X86 %s
+// RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck --check-prefix=WASM %s
+
+// Test that destructors are not passed directly to __cxa_atexit when their
+// signatures do not match the type of its first argument.
+// e.g. ARM and WebAssembly have destructors that return this instead of void.
+
+
+class Foo {

r266787 - reduce indentation; NFCI

2016-04-19 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Tue Apr 19 13:06:33 2016
New Revision: 266787

URL: http://llvm.org/viewvc/llvm-project?rev=266787&view=rev
Log:
reduce indentation; NFCI

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

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=266787&r1=266786&r2=266787&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Tue Apr 19 13:06:33 2016
@@ -1313,15 +1313,12 @@ void CodeGenFunction::EmitBranchOnBoolEx
   // create metadata that specifies that the branch is unpredictable.
   // Don't bother if not optimizing because that metadata would not be used.
   llvm::MDNode *Unpredictable = nullptr;
-  if (CGM.getCodeGenOpts().OptimizationLevel != 0) {
-if (const CallExpr *Call = dyn_cast(Cond)) {
-  const Decl *TargetDecl = Call->getCalleeDecl();
-  if (const FunctionDecl *FD = dyn_cast_or_null(TargetDecl)) 
{
-if (FD->getBuiltinID() == Builtin::BI__builtin_unpredictable) {
-  llvm::MDBuilder MDHelper(getLLVMContext());
-  Unpredictable = MDHelper.createUnpredictable();
-}
-  }
+  auto *Call = dyn_cast(Cond);
+  if (Call && CGM.getCodeGenOpts().OptimizationLevel != 0) {
+auto *FD = dyn_cast_or_null(Call->getCalleeDecl());
+if (FD && FD->getBuiltinID() == Builtin::BI__builtin_unpredictable) {
+  llvm::MDBuilder MDHelper(getLLVMContext());
+  Unpredictable = MDHelper.createUnpredictable();
 }
   }
 


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


Re: [PATCH] D19274: Compilation for Intel MCU (Part 2/3)

2016-04-19 Thread Mandeep Singh Grang via cfe-commits
mgrang added a subscriber: mgrang.


Comment at: lib/Driver/Tools.cpp:580
@@ -573,1 +579,3 @@
+  if (IsIAMCU)
+getToolChain().AddIAMCUIncludeArgs(Args, CmdArgs);
 }

Is it better to move this above in the else part of the condition "if 
(!IsIAMCU)"?


Comment at: lib/Driver/Tools.cpp:3625
@@ +3624,3 @@
+  // C++ is not supported for IAMCU.
+  if(IsIAMCU && types::isCXX(Input.getType()))
+D.Diag(diag::err_drv_cxx_not_supported) << 
getToolChain().getTriple().str();

nitpick: Missing space between if and (


http://reviews.llvm.org/D19274



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


Re: [PATCH] D18998: [CodeGen] Explicitly widen non-power-of-2 vector HFA base types.

2016-04-19 Thread Ahmed Bougacha via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266784: [CodeGen] Widen non-power-of-2 vector HFA base 
types. (authored by ab).

Changed prior to commit:
  http://reviews.llvm.org/D18998?vs=53336&id=54224#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18998

Files:
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/CodeGen/aarch64-arguments-hfa-v3.c
  cfe/trunk/test/CodeGen/arm64-arguments.c
  cfe/trunk/test/CodeGen/ppc64le-aggregates.c

Index: cfe/trunk/test/CodeGen/aarch64-arguments-hfa-v3.c
===
--- cfe/trunk/test/CodeGen/aarch64-arguments-hfa-v3.c
+++ cfe/trunk/test/CodeGen/aarch64-arguments-hfa-v3.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios -target-feature +neon -target-abi darwinpcs -fallow-half-arguments-and-returns -emit-llvm -o - %s | FileCheck %s
+
+typedef __attribute__((__ext_vector_type__(16))) signed char int8x16_t;
+typedef __attribute__((__ext_vector_type__(3))) float float32x3_t;
+
+// CHECK: %struct.HFAv3 = type { [4 x <3 x float>] }
+typedef struct { float32x3_t arr[4]; } HFAv3;
+
+// CHECK: %struct.MixedHFAv3 = type { [3 x <3 x float>], <16 x i8> }
+typedef struct { float32x3_t arr[3]; int8x16_t b; } MixedHFAv3;
+
+// CHECK: define %struct.HFAv3 @test([4 x <4 x float>] %{{.*}}, [4 x <4 x float>] %{{.*}}, [4 x <4 x float>] %{{.*}})
+HFAv3 test(HFAv3 a0, HFAv3 a1, HFAv3 a2) {
+  return a2;
+}
+
+// CHECK: define %struct.MixedHFAv3 @test_mixed([4 x <4 x float>] %{{.*}}, [4 x <4 x float>] %{{.*}}, [4 x <4 x float>] %{{.*}})
+MixedHFAv3 test_mixed(MixedHFAv3 a0, MixedHFAv3 a1, MixedHFAv3 a2) {
+  return a2;
+}
Index: cfe/trunk/test/CodeGen/ppc64le-aggregates.c
===
--- cfe/trunk/test/CodeGen/ppc64le-aggregates.c
+++ cfe/trunk/test/CodeGen/ppc64le-aggregates.c
@@ -255,84 +255,84 @@
 struct v3fab { float3 a; float3 b; };
 struct v3fabc { float3 a; float3 b; float3 c; };
 
-// CHECK: define [1 x <3 x float>] @func_v3f1(<3 x float> inreg %x.coerce)
+// CHECK: define [1 x <4 x float>] @func_v3f1(<3 x float> inreg %x.coerce)
 struct v3f1 func_v3f1(struct v3f1 x) { return x; }
 
-// CHECK: define [2 x <3 x float>] @func_v3f2([2 x <3 x float>] %x.coerce)
+// CHECK: define [2 x <4 x float>] @func_v3f2([2 x <4 x float>] %x.coerce)
 struct v3f2 func_v3f2(struct v3f2 x) { return x; }
 
-// CHECK: define [3 x <3 x float>] @func_v3f3([3 x <3 x float>] %x.coerce)
+// CHECK: define [3 x <4 x float>] @func_v3f3([3 x <4 x float>] %x.coerce)
 struct v3f3 func_v3f3(struct v3f3 x) { return x; }
 
-// CHECK: define [4 x <3 x float>] @func_v3f4([4 x <3 x float>] %x.coerce)
+// CHECK: define [4 x <4 x float>] @func_v3f4([4 x <4 x float>] %x.coerce)
 struct v3f4 func_v3f4(struct v3f4 x) { return x; }
 
-// CHECK: define [5 x <3 x float>] @func_v3f5([5 x <3 x float>] %x.coerce)
+// CHECK: define [5 x <4 x float>] @func_v3f5([5 x <4 x float>] %x.coerce)
 struct v3f5 func_v3f5(struct v3f5 x) { return x; }
 
-// CHECK: define [6 x <3 x float>] @func_v3f6([6 x <3 x float>] %x.coerce)
+// CHECK: define [6 x <4 x float>] @func_v3f6([6 x <4 x float>] %x.coerce)
 struct v3f6 func_v3f6(struct v3f6 x) { return x; }
 
-// CHECK: define [7 x <3 x float>] @func_v3f7([7 x <3 x float>] %x.coerce)
+// CHECK: define [7 x <4 x float>] @func_v3f7([7 x <4 x float>] %x.coerce)
 struct v3f7 func_v3f7(struct v3f7 x) { return x; }
 
-// CHECK: define [8 x <3 x float>] @func_v3f8([8 x <3 x float>] %x.coerce)
+// CHECK: define [8 x <4 x float>] @func_v3f8([8 x <4 x float>] %x.coerce)
 struct v3f8 func_v3f8(struct v3f8 x) { return x; }
 
 // CHECK: define void @func_v3f9(%struct.v3f9* noalias sret %agg.result, %struct.v3f9* byval align 16 %x)
 struct v3f9 func_v3f9(struct v3f9 x) { return x; }
 
-// CHECK: define [2 x <3 x float>] @func_v3fab([2 x <3 x float>] %x.coerce)
+// CHECK: define [2 x <4 x float>] @func_v3fab([2 x <4 x float>] %x.coerce)
 struct v3fab func_v3fab(struct v3fab x) { return x; }
 
-// CHECK: define [3 x <3 x float>] @func_v3fabc([3 x <3 x float>] %x.coerce)
+// CHECK: define [3 x <4 x float>] @func_v3fabc([3 x <4 x float>] %x.coerce)
 struct v3fabc func_v3fabc(struct v3fabc x) { return x; }
 
 // CHECK-LABEL: @call_v3f1
 // CHECK: %[[TMP:[^ ]+]] = load <3 x float>, <3 x float>* getelementptr inbounds (%struct.v3f1, %struct.v3f1* @global_v3f1, i32 0, i32 0, i32 0), align 1
-// CHECK: call [1 x <3 x float>] @func_v3f1(<3 x float> inreg %[[TMP]])
+// CHECK: call [1 x <4 x float>] @func_v3f1(<3 x float> inreg %[[TMP]])
 struct v3f1 global_v3f1;
 void call_v3f1(void) { global_v3f1 = func_v3f1(global_v3f1); }
 
 // CHECK-LABEL: @call_v3f2
-// CHECK: %[[TMP:[^ ]+]] = load [2 x <3 x float>], [2 x <3 x float>]* getelementptr inbounds (%struct.v3f2, %struct.v3f2* @global_v3f2, i32 0, i32 0), align 1
-// CHECK: call [2 x <3 x float>] @func_v3f2([2 x <3 x float>] %[[TMP]])
+// CHECK: %[[TMP:[^ ]+]] = load [2 x <4 x float>], [2 x <4 x f

r266783 - [CodeGen] Fix whitespace. NFC.

2016-04-19 Thread Ahmed Bougacha via cfe-commits
Author: ab
Date: Tue Apr 19 12:54:24 2016
New Revision: 266783

URL: http://llvm.org/viewvc/llvm-project?rev=266783&view=rev
Log:
[CodeGen] Fix whitespace. NFC.

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

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=266783&r1=266782&r2=266783&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue Apr 19 12:54:24 2016
@@ -4472,7 +4472,7 @@ ABIArgInfo AArch64ABIInfo::classifyArgum
   if (isIllegalVectorType(Ty)) {
 uint64_t Size = getContext().getTypeSize(Ty);
 // Android promotes <2 x i8> to i16, not i32
-if(isAndroid() && (Size <= 16)) {
+if (isAndroid() && (Size <= 16)) {
   llvm::Type *ResType = llvm::Type::getInt16Ty(getVMContext());
   return ABIArgInfo::getDirect(ResType);
 }


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


r266784 - [CodeGen] Widen non-power-of-2 vector HFA base types.

2016-04-19 Thread Ahmed Bougacha via cfe-commits
Author: ab
Date: Tue Apr 19 12:54:29 2016
New Revision: 266784

URL: http://llvm.org/viewvc/llvm-project?rev=266784&view=rev
Log:
[CodeGen] Widen non-power-of-2 vector HFA base types.

Currently, for the ppc64--gnu and aarch64 ABIs, we recognize:
  typedef __attribute__((__ext_vector_type__(3))) float v3f32;
  typedef __attribute__((__ext_vector_type__(16))) char v16i8;
  struct HFA {
v3f32 a;
v16i8 b;
  };

as an HFA. Since the first type encountered is used as the base type,
we pass the HFA as:
[2 x <3 x float>]
Which leads to incorrect IR (relying on padding values) when the
second field is used.

Instead, explicitly widen the vector (after size rounding) in
isHomogeneousAggregate.

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

Added:
cfe/trunk/test/CodeGen/aarch64-arguments-hfa-v3.c
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGen/arm64-arguments.c
cfe/trunk/test/CodeGen/ppc64le-aggregates.c

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=266784&r1=266783&r2=266784&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue Apr 19 12:54:29 2016
@@ -4120,8 +4120,19 @@ bool ABIInfo::isHomogeneousAggregate(Qua
 // agree in both total size and mode (float vs. vector) are
 // treated as being equivalent here.
 const Type *TyPtr = Ty.getTypePtr();
-if (!Base)
+if (!Base) {
   Base = TyPtr;
+  // If it's a non-power-of-2 vector, its size is already a power-of-2,
+  // so make sure to widen it explicitly.
+  if (const VectorType *VT = Base->getAs()) {
+QualType EltTy = VT->getElementType();
+unsigned NumElements =
+getContext().getTypeSize(VT) / getContext().getTypeSize(EltTy);
+Base = getContext()
+   .getVectorType(EltTy, NumElements, VT->getVectorKind())
+   .getTypePtr();
+  }
+}
 
 if (Base->isVectorType() != TyPtr->isVectorType() ||
 getContext().getTypeSize(Base) != getContext().getTypeSize(TyPtr))

Added: cfe/trunk/test/CodeGen/aarch64-arguments-hfa-v3.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-arguments-hfa-v3.c?rev=266784&view=auto
==
--- cfe/trunk/test/CodeGen/aarch64-arguments-hfa-v3.c (added)
+++ cfe/trunk/test/CodeGen/aarch64-arguments-hfa-v3.c Tue Apr 19 12:54:29 2016
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios -target-feature +neon -target-abi 
darwinpcs -fallow-half-arguments-and-returns -emit-llvm -o - %s | FileCheck %s
+
+typedef __attribute__((__ext_vector_type__(16))) signed char int8x16_t;
+typedef __attribute__((__ext_vector_type__(3))) float float32x3_t;
+
+// CHECK: %struct.HFAv3 = type { [4 x <3 x float>] }
+typedef struct { float32x3_t arr[4]; } HFAv3;
+
+// CHECK: %struct.MixedHFAv3 = type { [3 x <3 x float>], <16 x i8> }
+typedef struct { float32x3_t arr[3]; int8x16_t b; } MixedHFAv3;
+
+// CHECK: define %struct.HFAv3 @test([4 x <4 x float>] %{{.*}}, [4 x <4 x 
float>] %{{.*}}, [4 x <4 x float>] %{{.*}})
+HFAv3 test(HFAv3 a0, HFAv3 a1, HFAv3 a2) {
+  return a2;
+}
+
+// CHECK: define %struct.MixedHFAv3 @test_mixed([4 x <4 x float>] %{{.*}}, [4 
x <4 x float>] %{{.*}}, [4 x <4 x float>] %{{.*}})
+MixedHFAv3 test_mixed(MixedHFAv3 a0, MixedHFAv3 a1, MixedHFAv3 a2) {
+  return a2;
+}

Modified: cfe/trunk/test/CodeGen/arm64-arguments.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm64-arguments.c?rev=266784&r1=266783&r2=266784&view=diff
==
--- cfe/trunk/test/CodeGen/arm64-arguments.c (original)
+++ cfe/trunk/test/CodeGen/arm64-arguments.c Tue Apr 19 12:54:29 2016
@@ -714,3 +714,34 @@ int32x4_t test_toobig_hva(int n, ...) {
   struct TooBigHVA h = __builtin_va_arg(thelist, struct TooBigHVA);
   return h.d;
 }
+
+typedef __attribute__((__ext_vector_type__(3))) float float32x3_t;
+typedef struct { float32x3_t arr[4]; } HFAv3;
+
+float32x3_t test_hva_v3(int n, ...) {
+// CHECK-LABEL: define <3 x float> @test_hva_v3(i32 %n, ...)
+// CHECK: [[THELIST:%.*]] = alloca i8*
+// CHECK: [[CURLIST:%.*]] = load i8*, i8** [[THELIST]]
+
+  // HVA is not indirect, so occupies its full 16 bytes on the stack. but it
+  // must be properly aligned.
+// CHECK: [[ALIGN0:%.*]] = ptrtoint i8* [[CURLIST]] to i64
+// CHECK: [[ALIGN1:%.*]] = add i64 [[ALIGN0]], 15
+// CHECK: [[ALIGN2:%.*]] = and i64 [[ALIGN1]], -16
+// CHECK: [[ALIGNED_LIST:%.*]] = inttoptr i64 [[ALIGN2]] to i8*
+
+// CHECK: [[NEXTLIST:%.*]] = getelementptr inbounds i8, i8* [[ALIGNED_LIST]], 
i64 64
+// CHECK: store i8* [[NEXTLIST]], i8** [[THELIST]]
+
+// CHECK: bitcast i8* [[ALIGNED_LIST]] to %struct.HFAv3*
+  __builtin_va_list l;
+  __builtin_

[PATCH] D19274: Compilation for Intel MCU (Part 2/3)

2016-04-19 Thread Andrey Turetskiy via cfe-commits
aturetsk created this revision.
aturetsk added reviewers: rsmith, bruno, bkramer.
aturetsk added subscribers: cfe-commits, DavidKreitzer, zinovy.nis.

This is the second patch required to support compilation for Intel MCU target 
(e.g. Intel(R) Quark(TM) micro controller D 2000).

When IAMCU triple is used:
* Recognize and use IAMCU GCC toolchain
* Set up include paths
* Forbid C++

The linker-related changes will be in the last part.

http://reviews.llvm.org/D19274

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/ToolChain.h
  lib/Driver/Driver.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  test/Driver/miamcu-opt.c
  test/Driver/miamcu-opt.cpp

Index: test/Driver/miamcu-opt.cpp
===
--- /dev/null
+++ test/Driver/miamcu-opt.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang -miamcu %s -### -o %t.o 2>&1 | FileCheck %s
+
+// CHECK: error: C++ is not supported for target 'i586-intel-elfiamcu'
Index: test/Driver/miamcu-opt.c
===
--- test/Driver/miamcu-opt.c
+++ test/Driver/miamcu-opt.c
@@ -17,5 +17,5 @@
 // CHECK: "-mfloat-abi" "soft"
 // CHECK: "-mstack-alignment=4"
 
-// CHECK: bin/gcc
+// CHECK: bin/ld
 // CHECK: "-static"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -296,6 +296,8 @@
 const ToolChain *AuxToolChain) const {
   Arg *A;
 
+  const bool IsIAMCU = getToolChain().getTriple().isOSIAMCU();
+
   CheckPreprocessingOptions(D, Args);
 
   Args.AddLastArg(CmdArgs, options::OPT_C);
@@ -562,14 +564,20 @@
   AuxToolChain->AddClangCXXStdlibIncludeArgs(Args, CmdArgs);
   }
 
-  // Add system include arguments.
-  getToolChain().AddClangSystemIncludeArgs(Args, CmdArgs);
-  if (AuxToolChain)
+  // Add system include arguments for all targets but IAMCU.
+  if (!IsIAMCU) {
+getToolChain().AddClangSystemIncludeArgs(Args, CmdArgs);
+if (AuxToolChain)
   AuxToolChain->AddClangCXXStdlibIncludeArgs(Args, CmdArgs);
+  }
 
   // Add CUDA include arguments, if needed.
   if (types::isCuda(Inputs[0].getType()))
 getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
+
+  // Add IAMCU include arguments, if needed.
+  if (IsIAMCU)
+getToolChain().AddIAMCUIncludeArgs(Args, CmdArgs);
 }
 
 // FIXME: Move to target hook.
@@ -3602,6 +3610,7 @@
   getToolChain().getTriple().isWindowsCygwinEnvironment();
   bool IsWindowsMSVC = getToolChain().getTriple().isWindowsMSVCEnvironment();
   bool IsPS4CPU = getToolChain().getTriple().isPS4CPU();
+  bool IsIAMCU = getToolChain().getTriple().isOSIAMCU();
 
   // Check number of inputs for sanity. We need at least one input.
   assert(Inputs.size() >= 1 && "Must have at least one input.");
@@ -3612,6 +3621,10 @@
   bool IsCuda = types::isCuda(Input.getType());
   assert((IsCuda || Inputs.size() == 1) && "Unable to handle multiple inputs.");
 
+  // C++ is not supported for IAMCU.
+  if(IsIAMCU && types::isCXX(Input.getType()))
+D.Diag(diag::err_drv_cxx_not_supported) << getToolChain().getTriple().str();
+
   // Invoke ourselves in -cc1 mode.
   //
   // FIXME: Implement custom jobs for internal actions.
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -806,6 +806,8 @@
   llvm::opt::ArgStringList &CC1Args) const override;
   void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
+  void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+   llvm::opt::ArgStringList &CC1Args) const override;
   bool isPIEDefault() const override;
   SanitizerMask getSupportedSanitizers() const override;
   void addProfileRTLibs(const llvm::opt::ArgList &Args,
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1570,9 +1570,13 @@
 break;
   case llvm::Triple::x86:
 LibDirs.append(begin(X86LibDirs), end(X86LibDirs));
-TripleAliases.append(begin(X86Triples), end(X86Triples));
-BiarchLibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
-BiarchTripleAliases.append(begin(X86_64Triples), end(X86_64Triples));
+// MCU toolchain is 32 bit only and its triple alias is TargetTriple
+// itself, which will be appended below.
+if (!TargetTriple.isOSIAMCU()) {
+  TripleAliases.append(begin(X86Triples), end(X86Triples));
+  BiarchLibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
+  BiarchTripleAliases.append(begin(X86_64Triples), end(X86_64Triples));
+}
 break;
   case llvm::Triple::mips:
 LibDirs.append(begin(MIPSLibDirs), end(MIPSLibDirs));
@@

r266775 - Pass dwarf-version to cc1as.

2016-04-19 Thread Douglas Katzman via cfe-commits
Author: dougk
Date: Tue Apr 19 12:43:54 2016
New Revision: 266775

URL: http://llvm.org/viewvc/llvm-project?rev=266775&view=rev
Log:
Pass dwarf-version to cc1as.

Fix PR26999 - crashing in cc1as with any '*bsd' target.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/save-temps.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=266775&r1=266774&r2=266775&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Apr 19 12:43:54 2016
@@ -6314,6 +6314,12 @@ void ClangAs::ConstructJob(Compilation &
   // FIXME: Stop lying and consume only the appropriate driver flags
   Args.ClaimAllArgs(options::OPT_W_Group);
 
+  // Assemblers that want to know the dwarf version can't assume a value,
+  // since the defaulting logic resides in the driver. Put in something
+  // reasonable now, in case a subsequent "-Wa,-g" changes it.
+  RenderDebugEnablingArgs(Args, CmdArgs, codegenoptions::NoDebugInfo,
+  getToolChain().GetDefaultDwarfVersion(),
+  llvm::DebuggerKind::Default);
   CollectArgsForIntegratedAssembler(C, Args, CmdArgs,
 getToolChain().getDriver());
 

Modified: cfe/trunk/test/Driver/save-temps.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/save-temps.c?rev=266775&r1=266774&r2=266775&view=diff
==
--- cfe/trunk/test/Driver/save-temps.c (original)
+++ cfe/trunk/test/Driver/save-temps.c Tue Apr 19 12:43:54 2016
@@ -77,3 +77,8 @@
 // CHECK-OBJ-NOO: "-o" "save-temps.s"
 // CHECK-OBJ-NOO: "-o" "save-temps.o"
 // CHECK-OBJ-NOO: "-o" "a.out"
+
+// RUN: %clang -target i386-unknown-freebsd -save-temps -g -c %s -### 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-SAVE-TEMPS
+// CHECK-SAVE-TEMPS: "-cc1as"
+// CHECK-SAVE-TEMPS: "-dwarf-version={{.}}"


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


[clang-tools-extra] r266770 - [Release Notes] Mention Clang-tidy misc-unused-using-decls check.

2016-04-19 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Tue Apr 19 12:31:58 2016
New Revision: 266770

URL: http://llvm.org/viewvc/llvm-project?rev=266770&view=rev
Log:
[Release Notes] Mention Clang-tidy misc-unused-using-decls check.

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=266770&r1=266769&r2=266770&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Tue Apr 19 12:31:58 2016
@@ -135,6 +135,11 @@ identified.  The improvements since the
   Finds most instances of stray semicolons that unexpectedly alter the meaning
   of the code.
 
+- New `misc-unused-using-decls
+  
`_ 
check
+
+  Finds unused ``using`` declarations.
+
 - New `modernize-deprecated-headers
   
`_
 check
 


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


Re: [PATCH] D18998: [CodeGen] Explicitly widen non-power-of-2 vector HFA base types.

2016-04-19 Thread Tim Northover via cfe-commits
t.p.northover accepted this revision.
t.p.northover added a comment.
This revision is now accepted and ready to land.

Sorry, I thought I'd already commented here. It looked good to me too.

Tim.


http://reviews.llvm.org/D18998



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


Re: [PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields

2016-04-19 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:6437-6445
@@ +6436,11 @@
+  // Warn immediately if -Wshadow-field-in-constructor is set.
+  Diag(R.getNameLoc(), diag::warn_ctor_parm_shadows_field)
+  << D << FD << FD->getParent();
+  Diag(FD->getLocation(), diag::note_previous_declaration);
+  // Remember that this was shadowed so we can warn later if it is
+  // modified.
+  ShadowingDecls.insert({D, FD});
+  return;
+}
+  }
+

Here's what I was thinking:

 * The new warning goes in its own group, say 
`-Wshadow-field-in-constructor-modified`
 * The new warning group is part of both `-Wshadow` and 
`-Wshadow-field-in-constructor`
 * We produce the `-Wshadow-field-in-constructor` warning from `ActOnPopScope` 
whenever we remove something from the map.

This means that our behavior is as if `-W` flags filter our warning output, and 
we only get one warning for each instance of shadowing, and 
`-Wshadow-field-in-constructor` can be used to control all 
constructor-parameter-shadows-field warnings (and even obscure cases like 
`-Wshadow -Wno-shadow-field-in-constructor` do what they look like they should 
do).


http://reviews.llvm.org/D18271



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


r266765 - reduce indentation; NFCI

2016-04-19 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Tue Apr 19 12:13:14 2016
New Revision: 266765

URL: http://llvm.org/viewvc/llvm-project?rev=266765&view=rev
Log:
reduce indentation; NFCI

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

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=266765&r1=266764&r2=266765&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Tue Apr 19 12:13:14 2016
@@ -1550,16 +1550,13 @@ void CodeGenFunction::EmitSwitchStmt(con
   // If the switch has a condition wrapped by __builtin_unpredictable,
   // create metadata that specifies that the switch is unpredictable.
   // Don't bother if not optimizing because that metadata would not be used.
-  if (CGM.getCodeGenOpts().OptimizationLevel != 0) {
-if (const CallExpr *Call = dyn_cast(S.getCond())) {
-  const Decl *TargetDecl = Call->getCalleeDecl();
-  if (const FunctionDecl *FD = dyn_cast_or_null(TargetDecl)) 
{
-if (FD->getBuiltinID() == Builtin::BI__builtin_unpredictable) {
-  llvm::MDBuilder MDHelper(getLLVMContext());
-  SwitchInsn->setMetadata(llvm::LLVMContext::MD_unpredictable,
-  MDHelper.createUnpredictable());
-}
-  }
+  auto *Call = dyn_cast(S.getCond());
+  if (Call && CGM.getCodeGenOpts().OptimizationLevel != 0) {
+auto *FD = dyn_cast_or_null(Call->getCalleeDecl());
+if (FD && FD->getBuiltinID() == Builtin::BI__builtin_unpredictable) {
+  llvm::MDBuilder MDHelper(getLLVMContext());
+  SwitchInsn->setMetadata(llvm::LLVMContext::MD_unpredictable,
+  MDHelper.createUnpredictable());
 }
   }
 


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


Re: [PATCH] D19071: [OpenCL] Add predefined macros.

2016-04-19 Thread Yaxun Liu via cfe-commits
yaxunl marked 7 inline comments as done.


Comment at: lib/Frontend/InitPreprocessor.cpp:421
@@ +420,3 @@
+switch (LangOpts.OpenCLVersion) {
+case 0:
+case 100:

yaxunl wrote:
> pxli168 wrote:
> > What is 0 stand for as OpenCLVersion, it seems the default OpenCLVersion if 
> > we did not pass any -cl-std=CLXX is 100.
> > So maybe we did not need this case 0:
> There is a test test/Frontend/stdlang.c:
> 
>   // RUN: %clang_cc1 -x cl -std=c99 -DOPENCL %s
> 
> With this test, LangOpts.OpenCL is 1 but LangOpts.OpenCLVersion is 0.
> 
> If we all agree that this test is invalid and -x cl can only be compiled with 
> OpenCL language standard and the default one is OpenCL 1.0, I can fix that 
> test first and then remove case 0 in this switch.
Anastasia,

What's your opinion on this? Should we limit the allowed language standard for 
cl to OpenCL standard only? Should I diagnose invalid language standard and 
also add a lit test for that?

Thanks.


Comment at: lib/Frontend/InitPreprocessor.cpp:439
@@ +438,3 @@
+if (LangOpts.OpenCLVersion >= 110)
+  Builder.defineMacro("CL_VERSION_1_1", "110");
+if (LangOpts.OpenCLVersion >= 120)

Anastasia wrote:
> yaxunl wrote:
> > yaxunl wrote:
> > > pxli168 wrote:
> > > > These macros maybe need for all cl version, and in the header we should 
> > > > compare  __OPENCL_C_VERSION__ with CL_VERSION_2_0 instead of the 
> > > > integer 200 in the header of  http://reviews.llvm.org/D18369? 
> > > Each OpenCL version only defines some of these macros by spec.
> > > 
> > > In the header file `__OPENCL_C_VERSION__` can compare with 200 since the 
> > > spec defines the integer value for `__OPENCL_C_VERSION__`. Comparing with 
> > > CL_VERSION_2_0 requires checking CL_VERSION_2_0 is available first. I 
> > > think probably I can define a macro 
> > > 
> > >   #define _OPENCL20_AND_ABOVE defined(__OPENCL_C_VERSION__) and 
> > > defined(CL_VERSION_2_0) and __OPENCL_C_VERSION__ >= 200
> > > 
> > > and then use this macro for conditioning 2.0 specific functions.
> > should be
> > 
> >   #if defined(__OPENCL_C_VERSION__) && defined(CL_VERSION_2_0) && 
> > __OPENCL_C_VERSION__ >= CL_VERSION_2_0
> >   #define _CL20_AND_ABOVE 1
> >   #endif
> > 
> Where do you plan to add this code?
> 
> My point is that the code is a bit complicated and messy with this checks and 
> on the other hand it's kind of logical that compiler supporting all CL 
> version would also accept all CL_VERSION_X_Y macros irrespectively from the 
> passed -cl-std flag... I don't think spec is being that explicit on how CL2.0 
> compliant compiler should enable those macros when earlier versions of 
> -cl-std are being passed.
OK I will add these macros.


http://reviews.llvm.org/D19071



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


r266763 - [Clang][Builtin][AVX512] Adding intrinsics for VGETMANT{PD|PS} and VGETEXP{PD|PS} instruction set

2016-04-19 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Tue Apr 19 12:10:29 2016
New Revision: 266763

URL: http://llvm.org/viewvc/llvm-project?rev=266763&view=rev
Log:
[Clang][Builtin][AVX512] Adding intrinsics for VGETMANT{PD|PS} and 
VGETEXP{PD|PS} instruction set

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


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/CodeGen/avx512vl-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=266763&r1=266762&r2=266763&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue Apr 19 12:10:29 2016
@@ -2121,6 +2121,14 @@ TARGET_BUILTIN(__builtin_ia32_insertf64x
 TARGET_BUILTIN(__builtin_ia32_inserti64x2_256_mask, 
"V4LLiV4LLiV2LLiIiV4LLiUc","","avx512dq,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_insertf32x4_256_mask, 
"V8fV8fV4fIiV8fUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_inserti32x4_256_mask, 
"V8iV8iV4iIiV8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_getmantpd128_mask, "V2dV2diV2dUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_getmantpd256_mask, "V4dV4diV4dUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_getmantps128_mask, "V4fV4fiV4fUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_getmantps256_mask, "V8fV8fiV8fUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_getmantpd512_mask, "V8dV8diV8dUcIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_getmantps512_mask, 
"V16fV16fiV16fUsIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_getexppd512_mask, "V8dV8dV8dUcIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_getexpps512_mask, 
"V16fV16fV16fUsIi","","avx512f")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=266763&r1=266762&r2=266763&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Tue Apr 19 12:10:29 2016
@@ -6148,6 +6148,179 @@ __builtin_ia32_inserti64x4_mask ((__v8di
 (__mmask8)( __U));\
 })
 
+#define _mm512_getmant_round_pd( __A, __B, __C, __R) __extension__ ({ \
+__builtin_ia32_getmantpd512_mask ((__v8df)( __A),\
+ (__C << 2) |( __B),\
+ (__v8df) _mm512_undefined_pd (),\
+ (__mmask8) -1,( __R));\
+})
+
+#define _mm512_mask_getmant_round_pd( __W, __U, __A, __B, __C, __R) 
__extension__ ({ \
+__builtin_ia32_getmantpd512_mask ((__v8df)( __A),\
+ (__C << 2) |( __B),\
+ (__v8df)( __W),(__mmask8)( __U),\
+ ( __R));\
+})
+
+#define _mm512_maskz_getmant_round_pd( __U, __A, __B, __C, __R) __extension__ 
({ \
+__builtin_ia32_getmantpd512_mask ((__v8df)( __A),\
+ (__C << 2) |( __B),\
+ (__v8df) _mm512_setzero_pd (),\
+ (__mmask8)( __U),( __R));\
+})
+
+#define _mm512_getmant_pd( __A, __B, __C) __extension__ ({ \
+__builtin_ia32_getmantpd512_mask ((__v8df)( __A),\
+ (__C << 2) |( __B),\
+ (__v8df) _mm512_setzero_pd (),\
+ (__mmask8) -1, _MM_FROUND_CUR_DIRECTION);\
+})
+
+#define _mm512_mask_getmant_pd( __W, __U, __A, __B, __C) __extension__ ({ \
+__builtin_ia32_getmantpd512_mask ((__v8df)( __A),\
+ (__C << 2) |( __B),\
+ (__v8df)( __W), (__mmask8)( __U), _MM_FROUND_CUR_DIRECTION);\
+})
+
+#define _mm512_maskz_getmant_pd( __U, __A, __B, __C) __extension__ ({ \
+__builtin_ia32_getmantpd512_mask ((__v8df)( __A),\
+ (__C << 2) |( __B),\
+ (__v8df) _mm512_setzero_pd (),\
+ (__mmask8)( __U), _MM_FROUND_CUR_DIRECTION);\
+})
+
+#define _mm512_getmant_round_ps( __A, __B, __C, __R) __extension__ ({ \
+__builtin_ia32_getmantps512_mask ((__v16sf)( __A),\
+ (__C << 2) |( __B),\
+ (__v16sf) _mm512_undefined_ps (),\
+ (__mmask16) -1,( __R));\
+})
+
+#define _mm512_mask_getmant_round_ps( __W, __U, __A, __B, __C, __R) 
__extension__ ({ \
+__builtin_ia32_getmantps512_mask ((__v16sf)( __A),\
+ (__C << 2) |( __B),\
+ (__v16sf)( __W),(__mmask16)( __U),\
+ ( __R));\
+})
+
+#define _mm512_maskz_getmant_round_ps( __U, __A, __B, __C, __R) __extension__ 
({ \
+__builtin_ia32_getmantps512_mask ((__v16sf)( __A),\
+ (__C << 2) |( __B),\
+ (__v16sf) _mm512_setzero_ps (),\
+ ( __U),( __R));\
+})
+
+#define _mm512_getmant_ps( __A, __B, __C) __extension__ ({ \
+__builtin_ia32_getmantps512_mask ((__v16sf)( __A),\
+ (__C

Re: [PATCH] D18998: [CodeGen] Explicitly widen non-power-of-2 vector HFA base types.

2016-04-19 Thread Ahmed Bougacha via cfe-commits
ab added a comment.

Thanks Ulrich.  Tim?


http://reviews.llvm.org/D18998



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


Re: [PATCH] D19144: Handle TemplateArgument in DynTypedNode comparison operations.

2016-04-19 Thread Samuel Benzaquen via cfe-commits
sbenza added a comment.

> > We can proceed with this change if you want, but it is not required 
> > anymore. I don't know whether we need the extra complexity of 
> > `TemplateArgumentLess`.

> 

> 

> If this patch is not going to help with performance, I'm happy to abandon it.


It might help in the cases where you are doing hasAncestor with 
TemplateArgument bound nodes, but that is a small corner case and I don't think 
we need to optimize for it.


http://reviews.llvm.org/D19144



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


Re: [PATCH] D19240: clang-format: [JS] support `interface` as a free standing identifier.

2016-04-19 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.


http://reviews.llvm.org/D19240



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


Re: [PATCH] D19240: clang-format: [JS] support `interface` as a free standing identifier.

2016-04-19 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 54218.
mprobst added a comment.

- reuse mustBeJSIdent for interface detection


http://reviews.llvm.org/D19240

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

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -136,6 +136,9 @@
"};");
   verifyFormat("var struct = 2;");
   verifyFormat("var union = 2;");
+  verifyFormat("var interface = 2;");
+  verifyFormat("interface = 2;");
+  verifyFormat("x = interface instanceof y;");
 }
 
 TEST_F(FormatTestJS, CppKeywords) {
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -663,10 +663,8 @@
  Tok.isNot(tok::kw_noexcept);
 }
 
-static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords,
- const FormatToken *FormatTok) {
-  if (FormatTok->Tok.isLiteral())
-return true;
+static bool mustBeJSIdent(const AdditionalKeywords &Keywords,
+  const FormatToken *FormatTok) {
   // FIXME: This returns true for C/C++ keywords like 'struct'.
   return FormatTok->is(tok::identifier) &&
  (FormatTok->Tok.getIdentifierInfo() == nullptr ||
@@ -679,6 +677,11 @@
   Keywords.kw_interface, Keywords.kw_throws));
 }
 
+static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords,
+ const FormatToken *FormatTok) {
+  return FormatTok->Tok.isLiteral() || mustBeJSIdent(Keywords, FormatTok);
+}
+
 // isJSDeclOrStmt returns true if |FormatTok| starts a declaration or statement
 // when encountered after a value (see mustBeJSIdentOrValue).
 static bool isJSDeclOrStmt(const AdditionalKeywords &Keywords,
@@ -1007,6 +1010,19 @@
   if ((Style.Language == FormatStyle::LK_JavaScript ||
Style.Language == FormatStyle::LK_Java) &&
   FormatTok->is(Keywords.kw_interface)) {
+if (Style.Language == FormatStyle::LK_JavaScript) {
+  // In JavaScript/TypeScript, "interface" can be used as a standalone
+  // identifier, e.g. in `var interface = 1;`. If "interface" is
+  // followed by another identifier, it is very like to be an actual
+  // interface declaration.
+  unsigned StoredPosition = Tokens->getPosition();
+  FormatToken *Next = Tokens->getNextToken();
+  FormatTok = Tokens->setPosition(StoredPosition);
+  if (Next && !mustBeJSIdent(Keywords, Next)) {
+nextToken();
+break;
+  }
+}
 parseRecord();
 addUnwrappedLine();
 return;


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -136,6 +136,9 @@
"};");
   verifyFormat("var struct = 2;");
   verifyFormat("var union = 2;");
+  verifyFormat("var interface = 2;");
+  verifyFormat("interface = 2;");
+  verifyFormat("x = interface instanceof y;");
 }
 
 TEST_F(FormatTestJS, CppKeywords) {
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -663,10 +663,8 @@
  Tok.isNot(tok::kw_noexcept);
 }
 
-static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords,
- const FormatToken *FormatTok) {
-  if (FormatTok->Tok.isLiteral())
-return true;
+static bool mustBeJSIdent(const AdditionalKeywords &Keywords,
+  const FormatToken *FormatTok) {
   // FIXME: This returns true for C/C++ keywords like 'struct'.
   return FormatTok->is(tok::identifier) &&
  (FormatTok->Tok.getIdentifierInfo() == nullptr ||
@@ -679,6 +677,11 @@
   Keywords.kw_interface, Keywords.kw_throws));
 }
 
+static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords,
+ const FormatToken *FormatTok) {
+  return FormatTok->Tok.isLiteral() || mustBeJSIdent(Keywords, FormatTok);
+}
+
 // isJSDeclOrStmt returns true if |FormatTok| starts a declaration or statement
 // when encountered after a value (see mustBeJSIdentOrValue).
 static bool isJSDeclOrStmt(const AdditionalKeywords &Keywords,
@@ -1007,6 +1010,19 @@
   if ((Style.Language == FormatStyle::LK_JavaScript ||
Style.Language == FormatStyle::LK_Java) &&
   FormatTok->is(Keywords.kw_interface)) {
+if (Style.Language == FormatStyle::LK_JavaScript) {
+  // In JavaScript/TypeScript, "interface" can be used as a standalone
+  // identifier, e.g. in `var interface = 1;`. If "interface" is
+  // followed b

Re: [PATCH] D19240: clang-format: [JS] support `interface` as a free standing identifier.

2016-04-19 Thread Martin Probst via cfe-commits
mprobst marked an inline comment as done.
mprobst added a comment.

http://reviews.llvm.org/D19240



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


Re: [PATCH] D18635: Rework interface for bitset-using features to use a notion of LTO visibility.

2016-04-19 Thread Peter Collingbourne via cfe-commits
pcc added a comment.

@rsmith Ping.


http://reviews.llvm.org/D18635



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


Re: [PATCH] D19270: Fix a crash in cppcoreguidelines-pro-type-member-init related to missing constructor bodies.

2016-04-19 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


http://reviews.llvm.org/D19270



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


Re: [PATCH] D18624: [PGO] PGOFuncName meta data if PGOFuncName is different from function's raw name.

2016-04-19 Thread Adam Nemet via cfe-commits
anemet added a comment.

Thanks, the indirect call is via the All_Intersections macro in 
All_CSG_Intersect_Intersections and the top targets are: 
All_Sphere_Intersections and All_Plane_Intersections.


http://reviews.llvm.org/D18624



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


  1   2   >