[PATCH] D44295: [clang-tidy] Detects and fixes calls to grand-...parent virtual methods instead of calls to parent's virtual methods

2018-03-19 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis marked 2 inline comments as done.
zinovy.nis added a comment.

Hope I satisfied all your requests now.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44295



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


[PATCH] D39930: [CMake] Use libc++ and compiler-rt as default libraries in Fuchsia toolchain

2018-03-19 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 138882.
phosek marked an inline comment as done.

Repository:
  rC Clang

https://reviews.llvm.org/D39930

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


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -19,6 +19,8 @@
   set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
   set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 endif()
+set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
+set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
 
 set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
@@ -32,12 +34,26 @@
 endforeach()
 
 set(LLVM_RUNTIME_TARGETS 
"default;x86_64-fuchsia;aarch64-fuchsia;x86_64-fuchsia-asan:x86_64-fuchsia;aarch64-fuchsia-asan:aarch64-fuchsia"
 CACHE STRING "")
+
+# Set the default target options.
+set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
+set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
+set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
+set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
+
+# Set the per-target options.
 foreach(target x86_64;aarch64)
   set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL 
"")
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
   set(RUNTIMES_${target}-fuchsia_UNIX 1 CACHE BOOL "")
-  set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -19,6 +19,8 @@
   set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
   set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 endif()
+set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
+set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
 
 set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
@@ -32,12 +34,26 @@
 endforeach()
 
 set(LLVM_RUNTIME_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia;x86_64-fuchsia-asan:x86_64-fuchsia;aarch64-fuchsia-asan:aarch64-fuchsia" CACHE STRING "")
+
+# Set the default target options.
+set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
+set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
+set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
+set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
+
+# Set the per-target options.
 foreach(target x86_64;aarch64)
   set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} CACHE PATH "")
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
   set(RUNTIMES_${target}-fuchsia_UNIX 1 CACHE BOOL "")
-  set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44607: Recompute invalidated iterator in insertTargetAndModeArgs

2018-03-19 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

Good catch, thank you.

To avoid code duplication you could change `InsertionPoint` into an index and 
use `begin() + InsertionPoint` in calls to `insert`.


Repository:
  rC Clang

https://reviews.llvm.org/D44607



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


[PATCH] D44607: Recompute invalidated iterator in insertTargetAndModeArgs

2018-03-19 Thread Hector Martin via Phabricator via cfe-commits
marcan updated this revision to Diff 13.

Repository:
  rC Clang

https://reviews.llvm.org/D44607

Files:
  tools/driver/driver.cpp


Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -212,20 +212,21 @@
   // Put target and mode arguments at the start of argument list so that
   // arguments specified in command line could override them. Avoid putting
   // them at index 0, as an option like '-cc1' must remain the first.
-  auto InsertionPoint = ArgVector.begin();
-  if (InsertionPoint != ArgVector.end())
+  int InsertionPoint = 0;
+  if (ArgVector.size() > 0)
 ++InsertionPoint;
 
   if (NameParts.DriverMode) {
 // Add the mode flag to the arguments.
-ArgVector.insert(InsertionPoint,
+ArgVector.insert(ArgVector.begin() + InsertionPoint,
  GetStableCStr(SavedStrings, NameParts.DriverMode));
   }
 
   if (NameParts.TargetIsValid) {
 const char *arr[] = {"-target", GetStableCStr(SavedStrings,
   NameParts.TargetPrefix)};
-ArgVector.insert(InsertionPoint, std::begin(arr), std::end(arr));
+ArgVector.insert(ArgVector.begin() + InsertionPoint,
+ std::begin(arr), std::end(arr));
   }
 }
 


Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -212,20 +212,21 @@
   // Put target and mode arguments at the start of argument list so that
   // arguments specified in command line could override them. Avoid putting
   // them at index 0, as an option like '-cc1' must remain the first.
-  auto InsertionPoint = ArgVector.begin();
-  if (InsertionPoint != ArgVector.end())
+  int InsertionPoint = 0;
+  if (ArgVector.size() > 0)
 ++InsertionPoint;
 
   if (NameParts.DriverMode) {
 // Add the mode flag to the arguments.
-ArgVector.insert(InsertionPoint,
+ArgVector.insert(ArgVector.begin() + InsertionPoint,
  GetStableCStr(SavedStrings, NameParts.DriverMode));
   }
 
   if (NameParts.TargetIsValid) {
 const char *arr[] = {"-target", GetStableCStr(SavedStrings,
   NameParts.TargetPrefix)};
-ArgVector.insert(InsertionPoint, std::begin(arr), std::end(arr));
+ArgVector.insert(ArgVector.begin() + InsertionPoint,
+ std::begin(arr), std::end(arr));
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44561: [ARM] Pass half or i16 types for NEON intrinsics

2018-03-19 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer updated this revision to Diff 138890.
SjoerdMeijer retitled this revision from "[ARM] Add HasFloat16 to TargetInfo" 
to "[ARM] Pass half or i16 types for NEON intrinsics".
SjoerdMeijer added a comment.
Herald added a subscriber: rengolin.

Removed unused function argument, and renamed HasFloat16


https://reviews.llvm.org/D44561

Files:
  include/clang/Basic/TargetInfo.h
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/AArch64.cpp
  lib/Basic/Targets/ARM.cpp
  lib/Basic/Targets/ARM.h
  lib/CodeGen/CGBuiltin.cpp

Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -3441,7 +3441,7 @@
 
 static llvm::VectorType *GetNeonType(CodeGenFunction *CGF,
  NeonTypeFlags TypeFlags,
- llvm::Triple::ArchType Arch,
+ bool HasLegalHalfType=true,
  bool V1Ty=false) {
   int IsQuad = TypeFlags.isQuad();
   switch (TypeFlags.getEltType()) {
@@ -3452,9 +3452,7 @@
   case NeonTypeFlags::Poly16:
 return llvm::VectorType::get(CGF->Int16Ty, V1Ty ? 1 : (4 << IsQuad));
   case NeonTypeFlags::Float16:
-// FIXME: Only AArch64 backend can so far properly handle half types.
-// Remove else part once ARM backend support for half is complete.
-if (Arch == llvm::Triple::aarch64)
+if (HasLegalHalfType)
   return llvm::VectorType::get(CGF->HalfTy, V1Ty ? 1 : (4 << IsQuad));
 else
   return llvm::VectorType::get(CGF->Int16Ty, V1Ty ? 1 : (4 << IsQuad));
@@ -4338,8 +4336,9 @@
   NeonTypeFlags Type(NeonTypeConst.getZExtValue());
   bool Usgn = Type.isUnsigned();
   bool Quad = Type.isQuad();
+  const bool HasLegalHalfType = getTarget().hasLegalHalfType();
 
-  llvm::VectorType *VTy = GetNeonType(this, Type, Arch);
+  llvm::VectorType *VTy = GetNeonType(this, Type, HasLegalHalfType);
   llvm::Type *Ty = VTy;
   if (!Ty)
 return nullptr;
@@ -4413,13 +4412,15 @@
   case NEON::BI__builtin_neon_vcvt_f32_v:
   case NEON::BI__builtin_neon_vcvtq_f32_v:
 Ops[0] = Builder.CreateBitCast(Ops[0], Ty);
-Ty = GetNeonType(this, NeonTypeFlags(NeonTypeFlags::Float32, false, Quad), Arch);
+Ty = GetNeonType(this, NeonTypeFlags(NeonTypeFlags::Float32, false, Quad),
+ HasLegalHalfType);
 return Usgn ? Builder.CreateUIToFP(Ops[0], Ty, "vcvt")
 : Builder.CreateSIToFP(Ops[0], Ty, "vcvt");
   case NEON::BI__builtin_neon_vcvt_f16_v:
   case NEON::BI__builtin_neon_vcvtq_f16_v:
 Ops[0] = Builder.CreateBitCast(Ops[0], Ty);
-Ty = GetNeonType(this, NeonTypeFlags(NeonTypeFlags::Float16, false, Quad), Arch);
+Ty = GetNeonType(this, NeonTypeFlags(NeonTypeFlags::Float16, false, Quad),
+ HasLegalHalfType);
 return Usgn ? Builder.CreateUIToFP(Ops[0], Ty, "vcvt")
 : Builder.CreateSIToFP(Ops[0], Ty, "vcvt");
   case NEON::BI__builtin_neon_vcvt_n_f16_v:
@@ -5528,7 +5529,8 @@
   bool usgn = Type.isUnsigned();
   bool rightShift = false;
 
-  llvm::VectorType *VTy = GetNeonType(this, Type, Arch);
+  llvm::VectorType *VTy = GetNeonType(this, Type,
+  getTarget().hasLegalHalfType());
   llvm::Type *Ty = VTy;
   if (!Ty)
 return nullptr;
@@ -5774,7 +5776,7 @@
 
   // Determine the type of this overloaded NEON intrinsic.
   NeonTypeFlags Type(Result.getZExtValue());
-  llvm::VectorType *Ty = GetNeonType(&CGF, Type, Arch);
+  llvm::VectorType *Ty = GetNeonType(&CGF, Type);
   if (!Ty)
 return nullptr;
 
@@ -6828,7 +6830,7 @@
   }
   }
 
-  llvm::VectorType *VTy = GetNeonType(this, Type, Arch);
+  llvm::VectorType *VTy = GetNeonType(this, Type);
   llvm::Type *Ty = VTy;
   if (!Ty)
 return nullptr;
@@ -6893,7 +6895,7 @@
   Ops[0] = Builder.CreateBitCast(Ops[0], DoubleTy);
   Ops[1] = Builder.CreateBitCast(Ops[1], DoubleTy);
   llvm::Type *VTy = GetNeonType(this,
-NeonTypeFlags(NeonTypeFlags::Float64, false, true), Arch);
+NeonTypeFlags(NeonTypeFlags::Float64, false, true));
   Ops[2] = Builder.CreateBitCast(Ops[2], VTy);
   Ops[2] = Builder.CreateExtractElement(Ops[2], Ops[3], "extract");
   Value *F = CGM.getIntrinsic(Intrinsic::fma, DoubleTy);
@@ -7132,22 +7134,22 @@
   case NEON::BI__builtin_neon_vcvt_f64_v:
   case NEON::BI__builtin_neon_vcvtq_f64_v:
 Ops[0] = Builder.CreateBitCast(Ops[0], Ty);
-Ty = GetNeonType(this, NeonTypeFlags(NeonTypeFlags::Float64, false, quad), Arch);
+Ty = GetNeonType(this, NeonTypeFlags(NeonTypeFlags::Float64, false, quad));
 return usgn ? Builder.CreateUIToFP(Ops[0], Ty, "vcvt")
 : Builder.CreateSIToFP(Ops[0], Ty, "vcvt");
   case NEON::BI__builtin_neon_vcvt_f64_f32: {
 assert(Type.getEltType() == NeonTypeFlags::Float64 && quad &&
"unexpected vcvt_f64_f32 builtin");
 NeonTypeFlags SrcFlag = NeonTypeFlags(NeonTypeFlags::Float3

[PATCH] D44561: [ARM] Pass half or i16 types for NEON intrinsics

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

Thanks. I think this looks reasonable now.


https://reviews.llvm.org/D44561



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


[PATCH] D41537: Optionally add code completion results for arrow instead of dot

2018-03-19 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

Ping


https://reviews.llvm.org/D41537



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


[PATCH] D44248: [clangd][cmake] Provide libatomic when there is no native support for 64bit atomics

2018-03-19 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

Ping?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44248



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


[PATCH] D43281: [AMDGPU] fixes for lds f32 builtins

2018-03-19 Thread Daniil Fukalov via Phabricator via cfe-commits
dfukalov added a comment.

> My real question was what happens if you put 11 in the description string?

in this case CanT.getAddressSpace() returns target addrspace value "20" (also 
shifted in the enum by 9==LangAS::FirstTargetAddressSpace)

So again ASTContext::getAddrSpaceQualType decieds that these addrspaces are not 
equal and then asserts
a
The main reason of these change is to allow usage of the builtins with __local 
described pointers. Such pointers have LangAS AddressSpace in the 
ASTContext::getAddrSpaceQualType() equal to "2".
But we have no way to obtain this value from CanT.getAddressSpace() since it 
returns target addrspace and it is >= 10.

So I'm going to switch to custom processing of these builtins and the patch is 
preparation to be able to remove their links in llvm repo.


Repository:
  rC Clang

https://reviews.llvm.org/D43281



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


[PATCH] D44248: [clangd][cmake] Provide libatomic when there is no native support for 64bit atomics

2018-03-19 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

lgtm

(Please add reviewers to your patch if you intend it to be reviewed.)




Comment at: clangd/CMakeLists.txt:7
+if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
+  list(APPEND CLANGD_ATOMIC_LIB atomic)
+endif()

nit: s/atomic/"atomic"/


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44248



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


[PATCH] D44248: [clangd][cmake] Provide libatomic when there is no native support for 64bit atomics

2018-03-19 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

Thanks, I wasn't sure who to add as a reviewer.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44248



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


[PATCH] D44561: [ARM] Pass half or i16 types for NEON intrinsics

2018-03-19 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

Thanks a lot for your help and reviews.


https://reviews.llvm.org/D44561



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


[PATCH] D44155: Fix support for try_acquire_capability

2018-03-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Ping.


https://reviews.llvm.org/D44155



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


[PATCH] D44426: Fix llvm + clang build with Intel compiler

2018-03-19 Thread Nicolai Hähnle via Phabricator via cfe-commits
nhaehnle added a comment.

Is that compiler really supported? Look at this:

  void operator delete(void *) = delete;

It's  been there in the code since early 2015. The bitwise OR on ELF::xxx has 
been there even longer.

Are you telling me that we officially support a compiler, but nobody has 
actually used it for more than 3 years? What's going on here?


https://reviews.llvm.org/D44426



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


[PATCH] D44539: [Sema][Objective-C] Add check to warn when property of objc type has assign attribute

2018-03-19 Thread Alfred Zien via Phabricator via cfe-commits
QF5690 added reviewers: aaron.ballman, benhamilton.
QF5690 added a comment.

Hey, saw many revisions around obj-c and sema that you are reviewing. Can you 
help me with this one?


Repository:
  rC Clang

https://reviews.llvm.org/D44539



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


[PATCH] D44426: Fix llvm + clang build with Intel compiler

2018-03-19 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

@nhaehnle And that's the problem. There's no build machine for intel compiler 
and nobody cares.
And if somebody like me want to build it - there's no solution rather than 
searching for workarounds yourself.
This patch is not that complex in the end as you see so it should be possible 
to support one more compiler with not too many headache.

That's why I suggest this patch to at least make people know that it's possible 
to build. Or probably to grab someone's interest to the problem and set up 
builds.


https://reviews.llvm.org/D44426



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


[PATCH] D44155: Fix support for try_acquire_capability

2018-03-19 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Please upload patches with full context (`-U9`)  :)


https://reviews.llvm.org/D44155



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


[PATCH] D44155: Fix support for try_acquire_capability

2018-03-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 138900.
aaron.ballman added a comment.

Now: with more context!


https://reviews.llvm.org/D44155

Files:
  lib/Analysis/ThreadSafety.cpp
  test/SemaCXX/warn-thread-safety-analysis.cpp


Index: test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- test/SemaCXX/warn-thread-safety-analysis.cpp
+++ test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wthread-safety 
-Wthread-safety-beta -Wno-thread-safety-negative -fcxx-exceptions 
-DUSE_ASSERT_CAPABILITY=0 %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wthread-safety 
-Wthread-safety-beta -Wno-thread-safety-negative -fcxx-exceptions 
-DUSE_ASSERT_CAPABILITY=1 %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wthread-safety 
-Wthread-safety-beta -Wno-thread-safety-negative -fcxx-exceptions 
-DUSE_ASSERT_CAPABILITY=0 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wthread-safety 
-Wthread-safety-beta -Wno-thread-safety-negative -fcxx-exceptions 
-DUSE_ASSERT_CAPABILITY=1 -DUSE_TRY_ACQUIRE_CAPABILITY %s
 
 // FIXME: should also run  %clang_cc1 -fsyntax-only -verify -Wthread-safety 
-std=c++11 -Wc++98-compat %s
 // FIXME: should also run  %clang_cc1 -fsyntax-only -verify -Wthread-safety %s
@@ -24,8 +25,13 @@
 #define ASSERT_SHARED_LOCK(...) 
__attribute__((assert_shared_lock(__VA_ARGS__)))
 #endif
 
+#ifdef USE_TRY_ACQUIRE_CAPABILITY
+#define EXCLUSIVE_TRYLOCK_FUNCTION(...) 
__attribute__((try_acquire_capability(__VA_ARGS__)))
+#define SHARED_TRYLOCK_FUNCTION(...)
__attribute__((try_acquire_shared_capability(__VA_ARGS__)))
+#else
 #define EXCLUSIVE_TRYLOCK_FUNCTION(...) 
__attribute__((exclusive_trylock_function(__VA_ARGS__)))
 #define SHARED_TRYLOCK_FUNCTION(...)
__attribute__((shared_trylock_function(__VA_ARGS__)))
+#endif
 #define UNLOCK_FUNCTION(...)
__attribute__((unlock_function(__VA_ARGS__)))
 #define EXCLUSIVE_UNLOCK_FUNCTION(...)  
__attribute__((release_capability(__VA_ARGS__)))
 #define SHARED_UNLOCK_FUNCTION(...) 
__attribute__((release_shared_capability(__VA_ARGS__)))
@@ -41,8 +47,8 @@
   void Lock() __attribute__((exclusive_lock_function));
   void ReaderLock() __attribute__((shared_lock_function));
   void Unlock() __attribute__((unlock_function));
-  bool TryLock() __attribute__((exclusive_trylock_function(true)));
-  bool ReaderTryLock() __attribute__((shared_trylock_function(true)));
+  bool TryLock() EXCLUSIVE_TRYLOCK_FUNCTION(true);
+  bool ReaderTryLock() SHARED_TRYLOCK_FUNCTION(true);
   void LockWhen(const int &cond) __attribute__((exclusive_lock_function));
 
   // for negative capabilities
Index: lib/Analysis/ThreadSafety.cpp
===
--- lib/Analysis/ThreadSafety.cpp
+++ lib/Analysis/ThreadSafety.cpp
@@ -1450,6 +1450,14 @@
   // If the condition is a call to a Trylock function, then grab the attributes
   for (const auto *Attr : FunDecl->attrs()) {
 switch (Attr->getKind()) {
+  case attr::TryAcquireCapability: {
+auto *A = cast(Attr);
+getMutexIDs(A->isShared() ? SharedLocksToAdd : ExclusiveLocksToAdd, A,
+Exp, FunDecl, PredBlock, CurrBlock, A->getSuccessValue(),
+Negate);
+CapDiagKind = ClassifyDiagnostic(A);
+break;
+  };
   case attr::ExclusiveTrylockFunction: {
 const auto *A = cast(Attr);
 getMutexIDs(ExclusiveLocksToAdd, A, Exp, FunDecl,
@@ -2249,10 +2257,13 @@
 A, nullptr, D);
 CapDiagKind = ClassifyDiagnostic(A);
   } else if (isa(Attr)) {
-// Don't try to check trylock functions for now
+// Don't try to check trylock functions for now.
 return;
   } else if (isa(Attr)) {
-// Don't try to check trylock functions for now
+// Don't try to check trylock functions for now.
+return;
+  } else if (isa(Attr)) {
+// Don't try to check trylock functions for now.
 return;
   }
 }


Index: test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- test/SemaCXX/warn-thread-safety-analysis.cpp
+++ test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wthread-safety -Wthread-safety-beta -Wno-thread-safety-negative -fcxx-exceptions -DUSE_ASSERT_CAPABILITY=0 %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wthread-safety -Wthread-safety-beta -Wno-thread-safety-negative -fcxx-exceptions -DUSE_ASSERT_CAPABILITY=1 %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wthread-safety -Wthread-safety-beta -Wno-thread-safety-negative -fcxx-exceptions -DUSE_ASSERT_CAPABILITY=0 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wthread-safety -Wthread-safety-beta -Wno-thread-safety-negative -fcxx-exceptions -DUSE_ASSERT_CAPABI

[PATCH] D44155: Fix support for try_acquire_capability

2018-03-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D44155#1041584, @lebedev.ri wrote:

> Please upload patches with full context (`-U9`)  :)


Ugh, yes. TortoiseSVN has no option for this, so I perpetually forget.


https://reviews.llvm.org/D44155



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


[PATCH] D41655: [clang-tidy] New check bugprone-unused-return-value

2018-03-19 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL327833: [clang-tidy] New check bugprone-unused-return-value 
(authored by alexfh, committed by ).
Herald added subscribers: llvm-commits, klimek.

Changed prior to commit:
  https://reviews.llvm.org/D41655?vs=138595&id=138901#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41655

Files:
  clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
  clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-unused-return-value.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value-custom.cpp
  clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value.cpp

Index: clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -43,6 +43,7 @@
 #include "UndefinedMemoryManipulationCheck.h"
 #include "UndelegatedConstructorCheck.h"
 #include "UnusedRaiiCheck.h"
+#include "UnusedReturnValueCheck.h"
 #include "UseAfterMoveCheck.h"
 #include "VirtualNearMissCheck.h"
 
@@ -119,6 +120,8 @@
 "bugprone-undelegated-constructor");
 CheckFactories.registerCheck(
 "bugprone-unused-raii");
+CheckFactories.registerCheck(
+"bugprone-unused-return-value");
 CheckFactories.registerCheck(
 "bugprone-use-after-move");
 CheckFactories.registerCheck(
Index: clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
@@ -35,6 +35,7 @@
   UndefinedMemoryManipulationCheck.cpp
   UndelegatedConstructorCheck.cpp
   UnusedRaiiCheck.cpp
+  UnusedReturnValueCheck.cpp
   UseAfterMoveCheck.cpp
   VirtualNearMissCheck.cpp
 
Index: clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -0,0 +1,82 @@
+//===--- UnusedReturnValueCheck.cpp - clang-tidy---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "UnusedReturnValueCheck.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+using namespace clang::ast_matchers::internal;
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+UnusedReturnValueCheck::UnusedReturnValueCheck(llvm::StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  CheckedFunctions(Options.get("CheckedFunctions", "::std::async;"
+   "::std::launder;"
+   "::std::remove;"
+   "::std::remove_if;"
+   "::std::unique")) {}
+
+void UnusedReturnValueCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "CheckedFunctions", CheckedFunctions);
+}
+
+void UnusedReturnValueCheck::registerMatchers(MatchFinder *Finder) {
+  auto FunVec = utils::options::parseStringList(CheckedFunctions);
+  auto MatchedCallExpr = expr(ignoringImplicit(ignoringParenImpCasts(
+  callExpr(
+  callee(functionDecl(
+  // Don't match void overloads of checked functions.
+  unless(returns(voidType())), hasAnyName(std::vector(
+   FunVec.begin(), FunVec.end())
+  .bind("match";
+
+  auto UnusedInCompoundStmt =
+  compoundStmt(forEach(MatchedCallExpr),
+   // The checker can't currently differentiate between the
+   // return statement and other statements inside GNU statement
+   // expressions, so disable the checker inside them to avoid
+   // false positives.
+   unless(hasParent(stmtExpr(;
+  auto UnusedInIfStmt =
+  ifStmt(eachOf(hasThen(MatchedCallExpr), hasElse(MatchedCallExp

[clang-tools-extra] r327833 - [clang-tidy] New check bugprone-unused-return-value

2018-03-19 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Mar 19 06:02:32 2018
New Revision: 327833

URL: http://llvm.org/viewvc/llvm-project?rev=327833&view=rev
Log:
[clang-tidy] New check bugprone-unused-return-value

Summary:
Detects function calls where the return value is unused.

Checked functions can be configured.

Reviewers: alexfh, aaron.ballman, ilya-biryukov, hokein

Reviewed By: alexfh, aaron.ballman

Subscribers: hintonda, JonasToth, Eugene.Zelenko, mgorny, xazax.hun, cfe-commits

Tags: #clang-tools-extra

Patch by Kalle Huttunen!

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

Added:
clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-unused-return-value.rst

clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value-custom.cpp
clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp?rev=327833&r1=327832&r2=327833&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp Mon Mar 
19 06:02:32 2018
@@ -43,6 +43,7 @@
 #include "UndefinedMemoryManipulationCheck.h"
 #include "UndelegatedConstructorCheck.h"
 #include "UnusedRaiiCheck.h"
+#include "UnusedReturnValueCheck.h"
 #include "UseAfterMoveCheck.h"
 #include "VirtualNearMissCheck.h"
 
@@ -119,6 +120,8 @@ public:
 "bugprone-undelegated-constructor");
 CheckFactories.registerCheck(
 "bugprone-unused-raii");
+CheckFactories.registerCheck(
+"bugprone-unused-return-value");
 CheckFactories.registerCheck(
 "bugprone-use-after-move");
 CheckFactories.registerCheck(

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt?rev=327833&r1=327832&r2=327833&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt Mon Mar 19 
06:02:32 2018
@@ -35,6 +35,7 @@ add_clang_library(clangTidyBugproneModul
   UndefinedMemoryManipulationCheck.cpp
   UndelegatedConstructorCheck.cpp
   UnusedRaiiCheck.cpp
+  UnusedReturnValueCheck.cpp
   UseAfterMoveCheck.cpp
   VirtualNearMissCheck.cpp
 

Added: clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp?rev=327833&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp Mon 
Mar 19 06:02:32 2018
@@ -0,0 +1,82 @@
+//===--- UnusedReturnValueCheck.cpp - 
clang-tidy---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "UnusedReturnValueCheck.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+using namespace clang::ast_matchers::internal;
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+UnusedReturnValueCheck::UnusedReturnValueCheck(llvm::StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  CheckedFunctions(Options.get("CheckedFunctions", "::std::async;"
+   "::std::launder;"
+   "::std::remove;"
+   "::std::remove_if;"
+   "::std::unique")) {}
+
+void UnusedReturnValueCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "CheckedFunctions", CheckedFunctions);
+}
+
+void UnusedReturnValueCheck::registerMatchers(MatchFinder *Finder) {
+  auto FunVec = utils::options::parseStringList(CheckedFunctions);
+  auto MatchedCallEx

[PATCH] D44607: Recompute invalidated iterator in insertTargetAndModeArgs

2018-03-19 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff accepted this revision.
sepavloff added a comment.
This revision is now accepted and ready to land.

LGTM.

Thank you!


Repository:
  rC Clang

https://reviews.llvm.org/D44607



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


[PATCH] D44588: [OpenMP][Clang] Pass global thread ID to outlined function

2018-03-19 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

Tests?


Repository:
  rC Clang

https://reviews.llvm.org/D44588



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


r327836 - [ARM] Pass half or i16 types for NEON intrinsics

2018-03-19 Thread Sjoerd Meijer via cfe-commits
Author: sjoerdmeijer
Date: Mon Mar 19 06:22:49 2018
New Revision: 327836

URL: http://llvm.org/viewvc/llvm-project?rev=327836&view=rev
Log:
[ARM] Pass half or i16 types for NEON intrinsics

For generating NEON intrinsics, this determines the NEON data type, and whether
it should be a half type or an i16 type. I.e., we always pass a half type for
AArch64, this hasn't changed, but now also for ARM but only when FullFP16 is
enabled, and i16 otherwise.

This is intended to be non-functional change, but together with the backend
work in D44538 which adds support for f16 vectors, this enables adding the
AArch32 FP16 (vector) intrinsics.

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

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets/AArch64.cpp
cfe/trunk/lib/Basic/Targets/ARM.cpp
cfe/trunk/lib/Basic/Targets/ARM.h
cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=327836&r1=327835&r2=327836&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Mon Mar 19 06:22:49 2018
@@ -61,6 +61,8 @@ protected:
   bool TLSSupported;
   bool VLASupported;
   bool NoAsmVariants;  // True if {|} are normal characters.
+  bool HasLegalHalfType; // True if the backend supports operations on the half
+ // LLVM IR type.
   bool HasFloat128;
   unsigned char PointerWidth, PointerAlign;
   unsigned char BoolWidth, BoolAlign;
@@ -361,6 +363,9 @@ public:
 return (getPointerWidth(0) >= 64) || getTargetOpts().ForceEnableInt128;
   } // FIXME
 
+  /// \brief Determine whether _Float16 is supported on this target.
+  virtual bool hasLegalHalfType() const { return HasLegalHalfType; }
+
   /// \brief Determine whether the __float128 type is supported on this target.
   virtual bool hasFloat128Type() const { return HasFloat128; }
 

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=327836&r1=327835&r2=327836&view=diff
==
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Mon Mar 19 06:22:49 2018
@@ -32,6 +32,7 @@ TargetInfo::TargetInfo(const llvm::Tripl
   TLSSupported = true;
   VLASupported = true;
   NoAsmVariants = false;
+  HasLegalHalfType = false;
   HasFloat128 = false;
   PointerWidth = PointerAlign = 32;
   BoolWidth = BoolAlign = 8;

Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=327836&r1=327835&r2=327836&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Mon Mar 19 06:22:49 2018
@@ -49,6 +49,8 @@ AArch64TargetInfo::AArch64TargetInfo(con
 IntMaxType = SignedLong;
   }
 
+  // All AArch64 implementations support ARMv8 FP, which makes half a legal 
type.
+  HasLegalHalfType = true;
 
   LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
   MaxVectorAlign = 128;

Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=327836&r1=327835&r2=327836&view=diff
==
--- cfe/trunk/lib/Basic/Targets/ARM.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/ARM.cpp Mon Mar 19 06:22:49 2018
@@ -379,7 +379,6 @@ bool ARMTargetInfo::handleTargetFeatures
   Unaligned = 1;
   SoftFloat = SoftFloatABI = false;
   HWDiv = 0;
-  HasFullFP16 = 0;
 
   // This does not diagnose illegal cases like having both
   // "+vfpv2" and "+vfpv3" or having "+neon" and "+fp-only-sp".
@@ -421,7 +420,7 @@ bool ARMTargetInfo::handleTargetFeatures
 } else if (Feature == "+fp16") {
   HW_FP |= HW_FP_HP;
 } else if (Feature == "+fullfp16") {
-  HasFullFP16 = 1;
+  HasLegalHalfType = true;
 }
   }
   HW_FP &= ~HW_FP_remove;
@@ -714,11 +713,11 @@ void ARMTargetInfo::getTargetDefines(con
 Builder.defineMacro("__ARM_FP_FAST", "1");
 
   // Armv8.2-A FP16 vector intrinsic
-  if ((FPU & NeonFPU) && HasFullFP16)
+  if ((FPU & NeonFPU) && HasLegalHalfType)
 Builder.defineMacro("__ARM_FEATURE_FP16_VECTOR_ARITHMETIC", "1");
 
   // Armv8.2-A FP16 scalar intrinsics
-  if (HasFullFP16)
+  if (HasLegalHalfType)
 Builder.defineMacro("__ARM_FEATURE_FP16_SCALAR_ARITHMETIC", "1");
 
 

Modified: cfe/trunk/lib/Basic/Targets/ARM.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.h?rev=327836&r1=327835&r2=327836&view=diff
===

[PATCH] D44561: [ARM] Pass half or i16 types for NEON intrinsics

2018-03-19 Thread Sjoerd Meijer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL327836: [ARM] Pass half or i16 types for NEON intrinsics 
(authored by SjoerdMeijer, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44561?vs=138890&id=138904#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44561

Files:
  cfe/trunk/include/clang/Basic/TargetInfo.h
  cfe/trunk/lib/Basic/TargetInfo.cpp
  cfe/trunk/lib/Basic/Targets/AArch64.cpp
  cfe/trunk/lib/Basic/Targets/ARM.cpp
  cfe/trunk/lib/Basic/Targets/ARM.h
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Index: cfe/trunk/include/clang/Basic/TargetInfo.h
===
--- cfe/trunk/include/clang/Basic/TargetInfo.h
+++ cfe/trunk/include/clang/Basic/TargetInfo.h
@@ -61,6 +61,8 @@
   bool TLSSupported;
   bool VLASupported;
   bool NoAsmVariants;  // True if {|} are normal characters.
+  bool HasLegalHalfType; // True if the backend supports operations on the half
+ // LLVM IR type.
   bool HasFloat128;
   unsigned char PointerWidth, PointerAlign;
   unsigned char BoolWidth, BoolAlign;
@@ -361,6 +363,9 @@
 return (getPointerWidth(0) >= 64) || getTargetOpts().ForceEnableInt128;
   } // FIXME
 
+  /// \brief Determine whether _Float16 is supported on this target.
+  virtual bool hasLegalHalfType() const { return HasLegalHalfType; }
+
   /// \brief Determine whether the __float128 type is supported on this target.
   virtual bool hasFloat128Type() const { return HasFloat128; }
 
Index: cfe/trunk/lib/Basic/Targets/ARM.h
===
--- cfe/trunk/lib/Basic/Targets/ARM.h
+++ cfe/trunk/lib/Basic/Targets/ARM.h
@@ -69,7 +69,6 @@
   unsigned Crypto : 1;
   unsigned DSP : 1;
   unsigned Unaligned : 1;
-  unsigned HasFullFP16 : 1;
 
   enum {
 LDREX_B = (1 << 0), /// byte (8-bit)
Index: cfe/trunk/lib/Basic/Targets/AArch64.cpp
===
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp
@@ -49,6 +49,8 @@
 IntMaxType = SignedLong;
   }
 
+  // All AArch64 implementations support ARMv8 FP, which makes half a legal type.
+  HasLegalHalfType = true;
 
   LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
   MaxVectorAlign = 128;
Index: cfe/trunk/lib/Basic/Targets/ARM.cpp
===
--- cfe/trunk/lib/Basic/Targets/ARM.cpp
+++ cfe/trunk/lib/Basic/Targets/ARM.cpp
@@ -379,7 +379,6 @@
   Unaligned = 1;
   SoftFloat = SoftFloatABI = false;
   HWDiv = 0;
-  HasFullFP16 = 0;
 
   // This does not diagnose illegal cases like having both
   // "+vfpv2" and "+vfpv3" or having "+neon" and "+fp-only-sp".
@@ -421,7 +420,7 @@
 } else if (Feature == "+fp16") {
   HW_FP |= HW_FP_HP;
 } else if (Feature == "+fullfp16") {
-  HasFullFP16 = 1;
+  HasLegalHalfType = true;
 }
   }
   HW_FP &= ~HW_FP_remove;
@@ -714,11 +713,11 @@
 Builder.defineMacro("__ARM_FP_FAST", "1");
 
   // Armv8.2-A FP16 vector intrinsic
-  if ((FPU & NeonFPU) && HasFullFP16)
+  if ((FPU & NeonFPU) && HasLegalHalfType)
 Builder.defineMacro("__ARM_FEATURE_FP16_VECTOR_ARITHMETIC", "1");
 
   // Armv8.2-A FP16 scalar intrinsics
-  if (HasFullFP16)
+  if (HasLegalHalfType)
 Builder.defineMacro("__ARM_FEATURE_FP16_SCALAR_ARITHMETIC", "1");
 
 
Index: cfe/trunk/lib/Basic/TargetInfo.cpp
===
--- cfe/trunk/lib/Basic/TargetInfo.cpp
+++ cfe/trunk/lib/Basic/TargetInfo.cpp
@@ -32,6 +32,7 @@
   TLSSupported = true;
   VLASupported = true;
   NoAsmVariants = false;
+  HasLegalHalfType = false;
   HasFloat128 = false;
   PointerWidth = PointerAlign = 32;
   BoolWidth = BoolAlign = 8;
Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -3441,7 +3441,7 @@
 
 static llvm::VectorType *GetNeonType(CodeGenFunction *CGF,
  NeonTypeFlags TypeFlags,
- llvm::Triple::ArchType Arch,
+ bool HasLegalHalfType=true,
  bool V1Ty=false) {
   int IsQuad = TypeFlags.isQuad();
   switch (TypeFlags.getEltType()) {
@@ -3452,9 +3452,7 @@
   case NeonTypeFlags::Poly16:
 return llvm::VectorType::get(CGF->Int16Ty, V1Ty ? 1 : (4 << IsQuad));
   case NeonTypeFlags::Float16:
-// FIXME: Only AArch64 backend can so far properly handle half types.
-// Remove else part once ARM backend support for half is complete.
-if (Arch == llvm::Triple::aarch64)
+if (HasLegalHalfType)
   return llvm::VectorType::get(CGF->HalfTy, V1Ty ? 1 : (4 << IsQuad));
 else
   return llvm::VectorType::get(CGF->Int16Ty, V1Ty ? 1 : (4

[PATCH] D44607: Recompute invalidated iterator in insertTargetAndModeArgs

2018-03-19 Thread Hector Martin via Phabricator via cfe-commits
marcan added a comment.

Note that I don't have commit access, so someone else will have to commit it 
for me :)


Repository:
  rC Clang

https://reviews.llvm.org/D44607



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


[PATCH] D36828: Updated a usage of createTemporaryFile that does not expect file to be created.

2018-03-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

Self-LGTMing since it's a trivial follow-up to an accepted change.


https://reviews.llvm.org/D36828



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


r327802 - Resolve unused variable 'VR' warning in RetainCountChecker.cpp

2018-03-19 Thread Bjorn Pettersson via cfe-commits
Author: bjope
Date: Sun Mar 18 09:07:20 2018
New Revision: 327802

URL: http://llvm.org/viewvc/llvm-project?rev=327802&view=rev
Log:
Resolve unused variable 'VR' warning in RetainCountChecker.cpp

Getting rid of
  error: unused variable 'VR' [-Werror,-Wunused-variable]
warning/error at
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:1933

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=327802&r1=327801&r2=327802&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Sun Mar 18 
09:07:20 2018
@@ -1931,7 +1931,7 @@ static bool isNumericLiteralExpression(c
 
 static Optional describeRegion(const MemRegion *MR) {
   if (const auto *VR = dyn_cast_or_null(MR))
-return std::string(cast(MR)->getDecl()->getName());
+return std::string(VR->getDecl()->getName());
   // Once we support more storage locations for bindings,
   // this would need to be improved.
   return None;


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


[PATCH] D44222: [AArch64] Add vmulxh_lane FP16 intrinsics

2018-03-19 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer abandoned this revision.
SjoerdMeijer added a comment.

This is implemented in https://reviews.llvm.org/D44591.


https://reviews.llvm.org/D44222



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


[PATCH] D44591: [AArch64] Add vmulxh_lane FP16 vector intrinsic

2018-03-19 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer accepted this revision.
SjoerdMeijer added a comment.
This revision is now accepted and ready to land.

This looks good to me, but we need a companion LLVM patch and add codegen tests 
for this to: CodeGen/AArch64/fp16_intrinsic_lane.ll.


https://reviews.llvm.org/D44591



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


[PATCH] D38455: [clang-tidy] new cppcoreguidelines-narrowing-conversions check.

2018-03-19 Thread Clement Courbet via Phabricator via cfe-commits
courbet updated this revision to Diff 138910.
courbet added a comment.
Herald added a subscriber: cfe-commits.

Do not trigger on `some_int += std::floor(some_float)`;


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38455

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
  clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-narrowing-conversions.cpp

Index: test/clang-tidy/cppcoreguidelines-narrowing-conversions.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-narrowing-conversions.cpp
@@ -0,0 +1,38 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-narrowing-conversions %t
+
+float ceil(float);
+namespace std {
+double ceil(double);
+long double floor(long double);
+} // namespace std
+
+void not_ok(double d) {
+  int i = 0;
+  i += 0.5;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
+  i += 0.5f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
+  i += d;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
+  // We warn on the following even though it's not dangerous because there is no
+  // reason to use a double literal here.
+  // TODO(courbet): Provide an automatic fix.
+  i += 2.0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
+  i += 2.0f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
+}
+
+void ok(double d) {
+  int i = 0;
+  i += 1;
+  i += static_cast(3.0);
+  i += static_cast(d);
+  i += std::ceil(3.0);
+  i += ::std::floor(3.0);
+  {
+using std::ceil;
+i += ceil(3.0f);
+  }
+  i += ceil(3.0f);
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -74,6 +74,7 @@
cppcoreguidelines-avoid-goto
cppcoreguidelines-c-copy-assignment-signature (redirects to misc-unconventional-assign-operator) 
cppcoreguidelines-interfaces-global-init
+   cppcoreguidelines-narrowing-conversions
cppcoreguidelines-no-malloc
cppcoreguidelines-owning-memory
cppcoreguidelines-pro-bounds-array-to-pointer-decay
Index: docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
@@ -0,0 +1,13 @@
+.. title:: clang-tidy - cppcoreguidelines-narrowing-conversions
+
+cppcoreguidelines-narrowing-conversions
+===
+
+Checks for silent narrowing conversions, e.g: ``int i = 0; i += 0.1;``. While
+the issue is obvious in this former example, it might not be so in the
+following: ``void MyClass::f(double d) { int_member_ += d; }``.
+
+This rule is part of the "Expressions and statements" profile of the C++ Core
+Guidelines, corresponding to rule ES.46. See
+
+https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Res-narrowing.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -178,6 +178,11 @@
 - The 'misc-unused-raii' check was renamed to `bugprone-unused-raii
   `_
 
+- New `cppcoreguidelines-narrowing-conversions
+  `_ check
+
+  Checks for narrowing conversions, e.g. ``int i = 0; i += 0.1;``.
+
 Improvements to include-fixer
 -
 
Index: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h
===
--- /dev/null
+++ clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h
@@ -0,0 +1,37 @@
+//===--- NarrowingConversionsCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_NARROWING_CONVERSIONS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_NARROWING_CONVERSIONS_H
+
+#include ".

[PATCH] D36828: Updated a usage of createTemporaryFile that does not expect file to be created.

2018-03-19 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL327852: Updated a usage of createTemporaryFile that does not 
expect file to be created. (authored by ibiryukov, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D36828

Files:
  cfe/trunk/unittests/Tooling/ToolingTest.cpp


Index: cfe/trunk/unittests/Tooling/ToolingTest.cpp
===
--- cfe/trunk/unittests/Tooling/ToolingTest.cpp
+++ cfe/trunk/unittests/Tooling/ToolingTest.cpp
@@ -319,8 +319,8 @@
 
 TEST(runToolOnCodeWithArgs, TestNoDepFile) {
   llvm::SmallString<32> DepFilePath;
-  ASSERT_FALSE(
-  llvm::sys::fs::createTemporaryFile("depfile", "d", DepFilePath));
+  ASSERT_FALSE(llvm::sys::fs::getPotentiallyUniqueTempFileName("depfile", "d",
+   DepFilePath));
   std::vector Args;
   Args.push_back("-MMD");
   Args.push_back("-MT");


Index: cfe/trunk/unittests/Tooling/ToolingTest.cpp
===
--- cfe/trunk/unittests/Tooling/ToolingTest.cpp
+++ cfe/trunk/unittests/Tooling/ToolingTest.cpp
@@ -319,8 +319,8 @@
 
 TEST(runToolOnCodeWithArgs, TestNoDepFile) {
   llvm::SmallString<32> DepFilePath;
-  ASSERT_FALSE(
-  llvm::sys::fs::createTemporaryFile("depfile", "d", DepFilePath));
+  ASSERT_FALSE(llvm::sys::fs::getPotentiallyUniqueTempFileName("depfile", "d",
+   DepFilePath));
   std::vector Args;
   Args.push_back("-MMD");
   Args.push_back("-MT");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r327852 - Updated a usage of createTemporaryFile that does not expect file to be created.

2018-03-19 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon Mar 19 07:20:25 2018
New Revision: 327852

URL: http://llvm.org/viewvc/llvm-project?rev=327852&view=rev
Log:
Updated a usage of createTemporaryFile that does not expect file to be created.

Summary:
This fixes a usage of createTemporaryFile in clang repo after
a change in llvm repo.

Reviewers: klimek, bkramer, krasimir, espindola, ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: cfe-commits

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

Modified:
cfe/trunk/unittests/Tooling/ToolingTest.cpp

Modified: cfe/trunk/unittests/Tooling/ToolingTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/ToolingTest.cpp?rev=327852&r1=327851&r2=327852&view=diff
==
--- cfe/trunk/unittests/Tooling/ToolingTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/ToolingTest.cpp Mon Mar 19 07:20:25 2018
@@ -319,8 +319,8 @@ TEST(runToolOnCode, TestSkipFunctionBody
 
 TEST(runToolOnCodeWithArgs, TestNoDepFile) {
   llvm::SmallString<32> DepFilePath;
-  ASSERT_FALSE(
-  llvm::sys::fs::createTemporaryFile("depfile", "d", DepFilePath));
+  ASSERT_FALSE(llvm::sys::fs::getPotentiallyUniqueTempFileName("depfile", "d",
+   DepFilePath));
   std::vector Args;
   Args.push_back("-MMD");
   Args.push_back("-MT");


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


[PATCH] D21508: Diagnose friend function template redefinitions

2018-03-19 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

Other compilers successfully recognize errors (checked using 
https://godbolt.org/). For instance, the code:

  template inline void func_35(T *x);
  template
  struct C35a {
template friend void func_35(T *x) {}
  };
  template
  struct C35b {
template friend void func_35(T *x) {}
  };
  C35a v35a;
  C35b v35b;

is rejected by MSVC 19:

  example.cpp
  (7): error C2995: 'void func_37(T *)': function template has already 
been defined
  (1): note: see declaration of 'func_37'
  Microsoft (R) C/C++ Optimizing Compiler Version 19.10.25017 for x64
  Copyright (C) Microsoft Corporation.  All rights reserved.
  Compiler returned: 2

by  gcc 7.3:

  :7:27: error: redefinition of 'template void func_37(T*)'
   template void func_37(T *x) {}
 ^~~
  :1:27: note: 'template void func_37(T*)' previously declared 
here
   template void func_37(T *x);
 ^~~
  Compiler returned: 1

and icc 18:

  (7): error: function template "func_37" has already been defined
template void func_37(T *x) {}
  ^
  compilation aborted for  (code 2)
  Compiler returned: 2


Repository:
  rC Clang

https://reviews.llvm.org/D21508



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


[PATCH] D44588: [OpenMP][Clang] Pass global thread ID to outlined function

2018-03-19 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea abandoned this revision.
gtbercea added a comment.

After some internal discussion with @ABataev he is going to replace the manual 
computation of the thread ID with a call to the runtime in a new patch.


Repository:
  rC Clang

https://reviews.llvm.org/D44588



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


[clang-tools-extra] r327854 - run-clang-tidy: forward clang-tidy exit status

2018-03-19 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Mon Mar 19 07:43:59 2018
New Revision: 327854

URL: http://llvm.org/viewvc/llvm-project?rev=327854&view=rev
Log:
run-clang-tidy: forward clang-tidy exit status

Exit with a non-zero value in case any of the underlying clang-tidy
invocations exit with a non-zero value.

This is useful in case WarningsAsErrors is enabled for some of the
checks: if any of those checks find something, the exit status now
reflects that.

Also add the ability to use run-clang-tidy.py via lit, and assert that
the exit code is not 0 when modernize-use-auto is triggered
intentionally.

Reviewers: alexfh, aaron.ballman

Reviewed By: aaron.ballman

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

Added:
clang-tools-extra/trunk/test/clang-tidy/run-clang-tidy.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
clang-tools-extra/trunk/test/lit.cfg

Modified: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py?rev=327854&r1=327853&r2=327854&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py Mon Mar 19 
07:43:59 2018
@@ -153,7 +153,7 @@ def apply_fixes(args, tmpdir):
   subprocess.call(invocation)
 
 
-def run_tidy(args, tmpdir, build_path, queue):
+def run_tidy(args, tmpdir, build_path, queue, failed_files):
   """Takes filenames out of queue and runs clang-tidy on them."""
   while True:
 name = queue.get()
@@ -162,7 +162,9 @@ def run_tidy(args, tmpdir, build_path, q
  args.extra_arg, args.extra_arg_before,
  args.quiet, args.config)
 sys.stdout.write(' '.join(invocation) + '\n')
-subprocess.call(invocation)
+return_code = subprocess.call(invocation)
+if return_code != 0:
+  failed_files.append(name)
 queue.task_done()
 
 
@@ -255,12 +257,15 @@ def main():
   # Build up a big regexy filter from all command line arguments.
   file_name_re = re.compile('|'.join(args.files))
 
+  return_code = 0
   try:
 # Spin up a bunch of tidy-launching threads.
 task_queue = queue.Queue(max_task)
+# List of files with a non-zero return code.
+failed_files = []
 for _ in range(max_task):
   t = threading.Thread(target=run_tidy,
-   args=(args, tmpdir, build_path, task_queue))
+   args=(args, tmpdir, build_path, task_queue, 
failed_files))
   t.daemon = True
   t.start()
 
@@ -271,6 +276,8 @@ def main():
 
 # Wait for all threads to be done.
 task_queue.join()
+if len(failed_files):
+  return_code = 1
 
   except KeyboardInterrupt:
 # This is a sad hack. Unfortunately subprocess goes
@@ -280,7 +287,6 @@ def main():
   shutil.rmtree(tmpdir)
 os.kill(0, 9)
 
-  return_code = 0
   if args.export_fixes:
 print('Writing fixes to ' + args.export_fixes + ' ...')
 try:

Added: clang-tools-extra/trunk/test/clang-tidy/run-clang-tidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/run-clang-tidy.cpp?rev=327854&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/run-clang-tidy.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/run-clang-tidy.cpp Mon Mar 19 
07:43:59 2018
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c 
%/t/test.cpp\",\"file\":\"%/t/test.cpp\"}]" | sed -e 's/\\//g' > 
%t/compile_commands.json
+// RUN: echo "Checks: '-*,modernize-use-auto'" > %t/.clang-tidy
+// RUN: echo "WarningsAsErrors: '*'" >> %t/.clang-tidy
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: cd "%t"
+// RUN: not %run_clang_tidy "%t/test.cpp"
+
+int main()
+{
+  int* x = new int();
+  delete x;
+}

Modified: clang-tools-extra/trunk/test/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/lit.cfg?rev=327854&r1=327853&r2=327854&view=diff
==
--- clang-tools-extra/trunk/test/lit.cfg (original)
+++ clang-tools-extra/trunk/test/lit.cfg Mon Mar 19 07:43:59 2018
@@ -129,6 +129,11 @@ if config.clang_staticanalyzer:
 config.substitutions.append(
 ('%clang_tidy_diff',
  '%s %s' % (config.python_executable, clang_tidy_diff)) )
+run_clang_tidy = os.path.join(
+config.test_source_root, "..", "clang-tidy", "tool", 
"run-clang-tidy.py")
+config.substitutions.append(
+('%run_clang_tidy',
+ '%s %s' % (config.python_executable, run_clang_tidy)) )
 else:
 # exclude the clang-tidy test directory
 config.excludes.append('clang-tidy')


___
cfe-commits mailing list
cfe-commi

[PATCH] D44366: run-clang-tidy: forward clang-tidy exit status

2018-03-19 Thread Miklos Vajna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE327854: run-clang-tidy: forward clang-tidy exit status 
(authored by vmiklos, committed by ).
Herald added a subscriber: cfe-commits.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44366

Files:
  clang-tidy/tool/run-clang-tidy.py
  test/clang-tidy/run-clang-tidy.cpp
  test/lit.cfg


Index: clang-tidy/tool/run-clang-tidy.py
===
--- clang-tidy/tool/run-clang-tidy.py
+++ clang-tidy/tool/run-clang-tidy.py
@@ -153,16 +153,18 @@
   subprocess.call(invocation)
 
 
-def run_tidy(args, tmpdir, build_path, queue):
+def run_tidy(args, tmpdir, build_path, queue, failed_files):
   """Takes filenames out of queue and runs clang-tidy on them."""
   while True:
 name = queue.get()
 invocation = get_tidy_invocation(name, args.clang_tidy_binary, args.checks,
  tmpdir, build_path, args.header_filter,
  args.extra_arg, args.extra_arg_before,
  args.quiet, args.config)
 sys.stdout.write(' '.join(invocation) + '\n')
-subprocess.call(invocation)
+return_code = subprocess.call(invocation)
+if return_code != 0:
+  failed_files.append(name)
 queue.task_done()
 
 
@@ -255,12 +257,15 @@
   # Build up a big regexy filter from all command line arguments.
   file_name_re = re.compile('|'.join(args.files))
 
+  return_code = 0
   try:
 # Spin up a bunch of tidy-launching threads.
 task_queue = queue.Queue(max_task)
+# List of files with a non-zero return code.
+failed_files = []
 for _ in range(max_task):
   t = threading.Thread(target=run_tidy,
-   args=(args, tmpdir, build_path, task_queue))
+   args=(args, tmpdir, build_path, task_queue, 
failed_files))
   t.daemon = True
   t.start()
 
@@ -271,6 +276,8 @@
 
 # Wait for all threads to be done.
 task_queue.join()
+if len(failed_files):
+  return_code = 1
 
   except KeyboardInterrupt:
 # This is a sad hack. Unfortunately subprocess goes
@@ -280,7 +287,6 @@
   shutil.rmtree(tmpdir)
 os.kill(0, 9)
 
-  return_code = 0
   if args.export_fixes:
 print('Writing fixes to ' + args.export_fixes + ' ...')
 try:
Index: test/clang-tidy/run-clang-tidy.cpp
===
--- test/clang-tidy/run-clang-tidy.cpp
+++ test/clang-tidy/run-clang-tidy.cpp
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c 
%/t/test.cpp\",\"file\":\"%/t/test.cpp\"}]" | sed -e 's/\\//g' > 
%t/compile_commands.json
+// RUN: echo "Checks: '-*,modernize-use-auto'" > %t/.clang-tidy
+// RUN: echo "WarningsAsErrors: '*'" >> %t/.clang-tidy
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: cd "%t"
+// RUN: not %run_clang_tidy "%t/test.cpp"
+
+int main()
+{
+  int* x = new int();
+  delete x;
+}
Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -129,6 +129,11 @@
 config.substitutions.append(
 ('%clang_tidy_diff',
  '%s %s' % (config.python_executable, clang_tidy_diff)) )
+run_clang_tidy = os.path.join(
+config.test_source_root, "..", "clang-tidy", "tool", 
"run-clang-tidy.py")
+config.substitutions.append(
+('%run_clang_tidy',
+ '%s %s' % (config.python_executable, run_clang_tidy)) )
 else:
 # exclude the clang-tidy test directory
 config.excludes.append('clang-tidy')


Index: clang-tidy/tool/run-clang-tidy.py
===
--- clang-tidy/tool/run-clang-tidy.py
+++ clang-tidy/tool/run-clang-tidy.py
@@ -153,16 +153,18 @@
   subprocess.call(invocation)
 
 
-def run_tidy(args, tmpdir, build_path, queue):
+def run_tidy(args, tmpdir, build_path, queue, failed_files):
   """Takes filenames out of queue and runs clang-tidy on them."""
   while True:
 name = queue.get()
 invocation = get_tidy_invocation(name, args.clang_tidy_binary, args.checks,
  tmpdir, build_path, args.header_filter,
  args.extra_arg, args.extra_arg_before,
  args.quiet, args.config)
 sys.stdout.write(' '.join(invocation) + '\n')
-subprocess.call(invocation)
+return_code = subprocess.call(invocation)
+if return_code != 0:
+  failed_files.append(name)
 queue.task_done()
 
 
@@ -255,12 +257,15 @@
   # Build up a big regexy filter from all command line arguments.
   file_name_re = re.compile('|'.join(args.files))
 
+  return_code = 0
   try:
 # Spin up a bunch of tidy-launching threads.
 task_queue = queue.Queue(max_task)
+# List of files with a non-zero return code.
+failed_files = []
 for _ in r

[PATCH] D44628: Backport changes from llvm/.clang_tidy to clang/.clang_tidy configs

2018-03-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a subscriber: simark.
ilya-biryukov added a comment.

Found by @simark while working on https://reviews.llvm.org/D44272.


Repository:
  rC Clang

https://reviews.llvm.org/D44628



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


[PATCH] D44628: Backport changes from llvm/.clang_tidy to clang/.clang_tidy configs

2018-03-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: alexfh.
ilya-biryukov added a subscriber: simark.
ilya-biryukov added a comment.

Found by @simark while working on https://reviews.llvm.org/D44272.


LLVM .clang_tidy seems to be more up-to-date.


Repository:
  rC Clang

https://reviews.llvm.org/D44628

Files:
  .clang-tidy


Index: .clang-tidy
===
--- .clang-tidy
+++ .clang-tidy
@@ -5,8 +5,13 @@
   - key: readability-identifier-naming.EnumCase
 value:   CamelCase
   - key: readability-identifier-naming.FunctionCase
-value:   lowerCase
+value:   camelBack
+  - key: readability-identifier-naming.MemberCase
+value:   CamelCase
+  - key: readability-identifier-naming.ParameterCase
+value:   CamelCase
   - key: readability-identifier-naming.UnionCase
 value:   CamelCase
   - key: readability-identifier-naming.VariableCase
 value:   CamelCase
+


Index: .clang-tidy
===
--- .clang-tidy
+++ .clang-tidy
@@ -5,8 +5,13 @@
   - key: readability-identifier-naming.EnumCase
 value:   CamelCase
   - key: readability-identifier-naming.FunctionCase
-value:   lowerCase
+value:   camelBack
+  - key: readability-identifier-naming.MemberCase
+value:   CamelCase
+  - key: readability-identifier-naming.ParameterCase
+value:   CamelCase
   - key: readability-identifier-naming.UnionCase
 value:   CamelCase
   - key: readability-identifier-naming.VariableCase
 value:   CamelCase
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41102: Setup clang-doc frontend framework

2018-03-19 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added a comment.

I was just thinking of disabling the one test that has an issue 
(class-in-function) on Windows -- the filename is only used in generating 
*some* USRs, so all of the other ones are fine. We ran into some issues with 
that though, since `UNSUPPORTED: system-windows` didn't seem to disable the 
test on the machine I have access to. Thoughts?


Repository:
  rL LLVM

https://reviews.llvm.org/D41102



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


r327860 - [CMake] Use libc++ and compiler-rt as default libraries in Fuchsia toolchain

2018-03-19 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Mon Mar 19 08:19:19 2018
New Revision: 327860

URL: http://llvm.org/viewvc/llvm-project?rev=327860&view=rev
Log:
[CMake] Use libc++ and compiler-rt as default libraries in Fuchsia toolchain

Fuchsia already defaults to libc++ and compiler-rt, but we want to use
these as default runtimes even on the host platform.

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

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

Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=327860&r1=327859&r2=327860&view=diff
==
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Mon Mar 19 08:19:19 2018
@@ -19,6 +19,8 @@ if(NOT APPLE)
   set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
   set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 endif()
+set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
+set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
 
 set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
@@ -26,18 +28,34 @@ set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 
 set(LLVM_BUILTIN_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia" CACHE STRING 
"")
+
+# Set the per-target builtins options.
 foreach(target x86_64;aarch64)
   set(BUILTINS_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
   set(BUILTINS_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
 endforeach()
 
 set(LLVM_RUNTIME_TARGETS 
"default;x86_64-fuchsia;aarch64-fuchsia;x86_64-fuchsia-asan:x86_64-fuchsia;aarch64-fuchsia-asan:aarch64-fuchsia"
 CACHE STRING "")
+
+# Set the default target runtimes options.
+set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
+set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
+set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
+set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
+
+# Set the per-target runtimes options.
 foreach(target x86_64;aarch64)
   set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL 
"")
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
   set(RUNTIMES_${target}-fuchsia_UNIX 1 CACHE BOOL "")
-  set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")


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


[PATCH] D41102: Setup clang-doc frontend framework

2018-03-19 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D41102#1041773, @juliehockett wrote:

> I was just thinking of disabling the one test that has an issue 
> (class-in-function) on Windows -- the filename is only used in generating 
> *some* USRs, so all of the other ones are fine. We ran into some issues with 
> that though, since `UNSUPPORTED: system-windows` didn't seem to disable the 
> test on the machine I have access to. Thoughts?




> `UNSUPPORTED: system-windows`

Perhaps that is only for msvc?

Have you tried something more broad, like
`UNSUPPORTED: mingw32,win32`
?


Repository:
  rL LLVM

https://reviews.llvm.org/D41102



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


[PATCH] D39930: [CMake] Use libc++ and compiler-rt as default libraries in Fuchsia toolchain

2018-03-19 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC327860: [CMake] Use libc++ and compiler-rt as default 
libraries in Fuchsia toolchain (authored by phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D39930?vs=138882&id=138936#toc

Repository:
  rC Clang

https://reviews.llvm.org/D39930

Files:
  cmake/caches/Fuchsia-stage2.cmake


Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -19,25 +19,43 @@
   set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
   set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 endif()
+set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
+set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
 
 set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 
 set(LLVM_BUILTIN_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia" CACHE STRING 
"")
+
+# Set the per-target builtins options.
 foreach(target x86_64;aarch64)
   set(BUILTINS_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
   set(BUILTINS_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
 endforeach()
 
 set(LLVM_RUNTIME_TARGETS 
"default;x86_64-fuchsia;aarch64-fuchsia;x86_64-fuchsia-asan:x86_64-fuchsia;aarch64-fuchsia-asan:aarch64-fuchsia"
 CACHE STRING "")
+
+# Set the default target runtimes options.
+set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
+set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
+set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
+set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
+
+# Set the per-target runtimes options.
 foreach(target x86_64;aarch64)
   set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL 
"")
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
   set(RUNTIMES_${target}-fuchsia_UNIX 1 CACHE BOOL "")
-  set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")


Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -19,25 +19,43 @@
   set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
   set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 endif()
+set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
+set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
 
 set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE STRING "")
 
 set(LLVM_BUILTIN_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia" CACHE STRING "")
+
+# Set the per-target builtins options.
 foreach(target x86_64;aarch64)
   set(BUILTINS_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} CACHE PATH "")
   set(BUILTINS_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
 endforeach()
 
 set(LLVM_RUNTIME_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia;x86_64-fuchsia-asan:x86_64-fuchsia;aarch64-fuchsia-asan:aarch64-fuchsia" CACHE STRING "")
+
+# Set the default target runtimes options.
+set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
+set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
+set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
+set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
+
+# Set the per-target runtimes options.
 foreach(target x86_64;aarch64)
   set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} CACHE PATH "")
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSTEM_NAME F

[PATCH] D41102: Setup clang-doc frontend framework

2018-03-19 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added a comment.

In https://reviews.llvm.org/D41102#1041791, @lebedev.ri wrote:

> Have you tried something more broad, like
>  `UNSUPPORTED: mingw32,win32`
>  ?


That wasn't working either, confusingly, at least on the local windows machine 
I have.


Repository:
  rL LLVM

https://reviews.llvm.org/D41102



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


[PATCH] D44630: [ms] Parse #pragma optimize and ignore it behind its own flag

2018-03-19 Thread Hans Wennborg via Phabricator via cfe-commits
hans created this revision.
hans added reviewers: thakis, rnk.

This allows users to turn off warnings about this pragma specifically, while 
still receiving warnings about other ignored pragmas.


https://reviews.llvm.org/D44630

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Parse/Parser.h
  lib/Parse/ParsePragma.cpp
  test/Preprocessor/pragma_microsoft.c

Index: test/Preprocessor/pragma_microsoft.c
===
--- test/Preprocessor/pragma_microsoft.c
+++ test/Preprocessor/pragma_microsoft.c
@@ -190,3 +190,11 @@
 #pragma intrinsic(asdf) // no-warning
 #pragma clang diagnostic pop
 #pragma intrinsic(asdf) // expected-warning {{'asdf' is not a recognized builtin; consider including }}
+
+#pragma optimize  // expected-warning{{missing '(' after '#pragma optimize'}}
+#pragma optimize( // expected-warning{{expected string literal in '#pragma optimize'}}
+#pragma optimize(a// expected-warning{{expected string literal in '#pragma optimize'}}
+#pragma optimize("g"  // expected-warning{{expected ',' in '#pragma optimize'}}
+#pragma optimize("g", // expected-warning{{missing argument to '#pragma optimize'; expected 'on' or 'off'}}
+#pragma optimize("g",xyz  // expected-warning{{unexpected argument 'xyz' to '#pragma optimize'; expected 'on' or 'off'}}
+#pragma optimize("g",on)  // expected-warning{{#pragma optimize' is not supported; use '#pragma clang optimize on|off' instead}}
Index: lib/Parse/ParsePragma.cpp
===
--- lib/Parse/ParsePragma.cpp
+++ lib/Parse/ParsePragma.cpp
@@ -220,6 +220,12 @@
 Token &FirstToken) override;
 };
 
+struct PragmaMSOptimizeHandler : public PragmaHandler {
+  PragmaMSOptimizeHandler() : PragmaHandler("optimize") {}
+  void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
+Token &FirstToken) override;
+};
+
 struct PragmaForceCUDAHostDeviceHandler : public PragmaHandler {
   PragmaForceCUDAHostDeviceHandler(Sema &Actions)
   : PragmaHandler("force_cuda_host_device"), Actions(Actions) {}
@@ -324,6 +330,8 @@
 PP.AddPragmaHandler(MSRuntimeChecks.get());
 MSIntrinsic.reset(new PragmaMSIntrinsicHandler());
 PP.AddPragmaHandler(MSIntrinsic.get());
+MSOptimize.reset(new PragmaMSOptimizeHandler());
+PP.AddPragmaHandler(MSOptimize.get());
   }
 
   if (getLangOpts().CUDA) {
@@ -410,6 +418,8 @@
 MSRuntimeChecks.reset();
 PP.RemovePragmaHandler(MSIntrinsic.get());
 MSIntrinsic.reset();
+PP.RemovePragmaHandler(MSOptimize.get());
+MSOptimize.reset();
   }
 
   if (getLangOpts().CUDA) {
@@ -2949,6 +2959,61 @@
 PP.Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
 << "intrinsic";
 }
+
+// #pragma optimize("gsty", on|off)
+void PragmaMSOptimizeHandler::HandlePragma(Preprocessor &PP,
+   PragmaIntroducerKind Introducer,
+   Token &Tok) {
+  SourceLocation StartLoc = Tok.getLocation();
+  PP.Lex(Tok);
+
+  if (Tok.isNot(tok::l_paren)) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_lparen) << "optimize";
+return;
+  }
+  PP.Lex(Tok);
+
+  if (Tok.isNot(tok::string_literal)) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_string) << "optimize";
+return;
+  }
+  // We could syntax check the string but it's probably not worth the effort.
+  PP.Lex(Tok);
+
+  if (Tok.isNot(tok::comma)) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_comma) << "optimize";
+return;
+  }
+  PP.Lex(Tok);
+
+  if (Tok.is(tok::eod) || Tok.is(tok::r_paren)) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_missing_argument)
+<< "optimize" << /*Expected=*/true << "'on' or 'off'";
+return;
+  }
+  IdentifierInfo *II = Tok.getIdentifierInfo();
+  if (!II || (!II->isStr("on") && !II->isStr("off"))) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_invalid_argument)
+<< PP.getSpelling(Tok) << "optimize" << /*Expected=*/true
+<< "'on' or 'off'";
+return;
+  }
+  PP.Lex(Tok);
+
+  if (Tok.isNot(tok::r_paren)) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_rparen) << "optimize";
+return;
+  }
+  PP.Lex(Tok);
+
+  if (Tok.isNot(tok::eod)) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
+<< "optimize";
+return;
+  }
+  PP.Diag(StartLoc, diag::warn_pragma_optimize);
+}
+
 void PragmaForceCUDAHostDeviceHandler::HandlePragma(
 Preprocessor &PP, PragmaIntroducerKind Introducer, Token &Tok) {
   Token FirstTok = Tok;
Index: include/clang/Parse/Parser.h
===
--- include/clang/Parse/Parser.h
+++ include/clang/Parse/Parser.h
@@ -179,6 +179,7 @@
   std::unique_ptr MSSection;
   std::unique_ptr MSRuntimeChecks;
   std::unique_ptr MSIn

[PATCH] D44272: [clangd] Support incremental document syncing

2018-03-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdLSPServer.cpp:164
+  if (!Contents) {
+log(llvm::toString(Contents.takeError()));
+return;

We should signal an error to the client by calling `replyError`



Comment at: clangd/ClangdLSPServer.cpp:149
 void ClangdLSPServer::onDocumentDidChange(DidChangeTextDocumentParams &Params) 
{
   if (Params.contentChanges.size() != 1)
 return replyError(ErrorCode::InvalidParams,

simark wrote:
> ilya-biryukov wrote:
> > simark wrote:
> > > ilya-biryukov wrote:
> > > > We should handle more than a single change here.
> > > Ok, I'll try that.  I am not sure I interpret the spec correctly.  If you 
> > > have two changes, the second change applies to the state of the document 
> > > after having applied the first change, is that right?  If that's the 
> > > case, I think we only need to iterate on the changes and call addDocument 
> > > on them sequentially (which could be done in the DraftMgr, given the 
> > > interface change to DraftStore you suggest lower).
> > I am interpreting it in the same manner, i.e. we need to apply the edits in 
> > the sequence they were provided.
> > But I would double-check on a client that actually send multiple changes. 
> > Does VSCode do that?
> I don't know of any client that does that.  AFAIK, vscode doesn't:
> 
> https://github.com/Microsoft/vscode-languageserver-node/blob/master/client/src/client.ts#L907-L908
> 
> It's the only place I could find where a `DidChangeTextDocumentParams` is 
> created, and it comes from a single `TextDocumentChangeEvent`, so there will 
> always be only one item in the array.
But `TextDocumentChangeEvent` may contain multiple content changes, see [[ 
https://github.com/Microsoft/vscode-languageserver-node/blob/6501c8f2b79afcd8f18afd3a247c4566c2f67471/client/src/codeConverter.ts#L141
 | codeConverter.ts ]].

Anyway, the spec seems to be clear enough here. Let's support multiple changes, 
it should be super-easy on our side (just call a function that does the update 
in a loop)



Comment at: clangd/DraftStore.cpp:47
+DocVersion DraftStore::updateDraft(PathRef File, StringRef Contents,
+   llvm::Optional range,
+   std::string *NewContents) {

simark wrote:
> ilya-biryukov wrote:
> > simark wrote:
> > > ilya-biryukov wrote:
> > > > NIT: LLVM uses `UpperCamelCase` for parameters and local variables
> > > Woops.  I should learn to use clang-tidy.  It found other instances (the 
> > > local variables) but it doesn't find the parameters not written in camel 
> > > case.  Do you have an idea why?  I dumped the config and see these:
> > > 
> > > ```
> > >   - key: readability-identifier-naming.ClassCase
> > > value:   CamelCase
> > >   - key: readability-identifier-naming.EnumCase
> > > value:   CamelCase
> > >   - key: readability-identifier-naming.UnionCase
> > > value:   CamelCase
> > >   - key: readability-identifier-naming.VariableCase
> > > value:   CamelCase
> > > ```
> > > 
> > > I assume there must be a `ParamCase` or something like that, but I can't 
> > > find the exhaustive list of parameters for that check.
> > There is indeed a `readability-idenfitier.ParameterCase` key.
> > Found in the code, it is probably missing from the docs. [[ 
> > https://github.com/llvm-mirror/clang-tools-extra/blob/master/clang-tidy/readability/IdentifierNamingCheck.cpp#L67
> >  | IdentifierNamingCheck.cpp ]].
> > We should probably update the relevant clang-tidy config. (not sure where 
> > it is, though, I don't use clang-tidy for clangd development. should really 
> > start doing that :-))
> The .clang-tidy file in the root of the llvm repo contains it.  But the one 
> in the clang repo overrides the `readability-identifier-naming` section 
> without defining `ParameterCase`.  That's probably why it's not enabled.
> 
> ```
> 'llvm-header-guard' is enabled in the 
> /home/emaisin/src/llvm/tools/clang/tools/extra/clangd/.clang-tidy.
> 'llvm-include-order' is enabled in the 
> /home/emaisin/src/llvm/tools/clang/tools/extra/clangd/.clang-tidy.
> 'llvm-namespace-comment' is enabled in the 
> /home/emaisin/src/llvm/tools/clang/tools/extra/clangd/.clang-tidy.
> 'llvm-twine-local' is enabled in the 
> /home/emaisin/src/llvm/tools/clang/tools/extra/clangd/.clang-tidy.
> 'misc-definitions-in-headers' is enabled in the 
> /home/emaisin/src/llvm/tools/clang/tools/extra/clangd/.clang-tidy.
> 'misc-misplaced-const' is enabled in the 
> /home/emaisin/src/llvm/tools/clang/tools/extra/clangd/.clang-tidy.
> 'misc-new-delete-overloads' is enabled in the 
> /home/emaisin/src/llvm/tools/clang/tools/extra/clangd/.clang-tidy.
> 'misc-non-copyable-objects' is enabled in the 
> /home/emaisin/src/llvm/tools/clang/tools/extra/clangd/.clang-tidy.
> 'misc-redundant-e

[PATCH] D44631: [clang-format] Remove empty lines before }[; ] // comment

2018-03-19 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added subscribers: cfe-commits, klimek.

This addresses bug 36766 and a FIXME in tests about empty lines before 
`}[;] // comment` lines.


Repository:
  rC Clang

https://reviews.llvm.org/D44631

Files:
  lib/Format/UnwrappedLineFormatter.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -276,7 +276,6 @@
"\n"
"}"));
 
-  // FIXME: This is slightly inconsistent.
   FormatStyle LLVMWithNoNamespaceFix = getLLVMStyle();
   LLVMWithNoNamespaceFix.FixNamespaceComments = false;
   EXPECT_EQ("namespace {\n"
@@ -295,12 +294,25 @@
"}"));
   EXPECT_EQ("namespace {\n"
 "int i;\n"
-"\n"
+"};",
+format("namespace {\n"
+   "int i;\n"
+   "\n"
+   "};"));
+  EXPECT_EQ("namespace {\n"
+"int i;\n"
 "} // namespace",
 format("namespace {\n"
"int i;\n"
"\n"
"}  // namespace"));
+  EXPECT_EQ("namespace {\n"
+"int i;\n"
+"}; // namespace",
+format("namespace {\n"
+   "int i;\n"
+   "\n"
+   "};  // namespace"));
 
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
Index: lib/Format/UnwrappedLineFormatter.cpp
===
--- lib/Format/UnwrappedLineFormatter.cpp
+++ lib/Format/UnwrappedLineFormatter.cpp
@@ -1133,8 +1133,12 @@
   std::min(RootToken.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1);
   // Remove empty lines before "}" where applicable.
   if (RootToken.is(tok::r_brace) &&
+  // Look for "}", "} // comment", "};" or "}; // comment".
   (!RootToken.Next ||
-   (RootToken.Next->is(tok::semi) && !RootToken.Next->Next)))
+   (RootToken.Next->is(tok::comment) && !RootToken.Next->Next) ||
+   (RootToken.Next->is(tok::semi) &&
+(!RootToken.Next->Next || (RootToken.Next->Next->is(tok::comment) &&
+   !RootToken.Next->Next->Next)
 Newlines = std::min(Newlines, 1u);
   // Remove empty lines at the start of nested blocks (lambdas/arrow functions)
   if (PreviousLine == nullptr && Line.Level > 0)


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -276,7 +276,6 @@
"\n"
"}"));
 
-  // FIXME: This is slightly inconsistent.
   FormatStyle LLVMWithNoNamespaceFix = getLLVMStyle();
   LLVMWithNoNamespaceFix.FixNamespaceComments = false;
   EXPECT_EQ("namespace {\n"
@@ -295,12 +294,25 @@
"}"));
   EXPECT_EQ("namespace {\n"
 "int i;\n"
-"\n"
+"};",
+format("namespace {\n"
+   "int i;\n"
+   "\n"
+   "};"));
+  EXPECT_EQ("namespace {\n"
+"int i;\n"
 "} // namespace",
 format("namespace {\n"
"int i;\n"
"\n"
"}  // namespace"));
+  EXPECT_EQ("namespace {\n"
+"int i;\n"
+"}; // namespace",
+format("namespace {\n"
+   "int i;\n"
+   "\n"
+   "};  // namespace"));
 
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
Index: lib/Format/UnwrappedLineFormatter.cpp
===
--- lib/Format/UnwrappedLineFormatter.cpp
+++ lib/Format/UnwrappedLineFormatter.cpp
@@ -1133,8 +1133,12 @@
   std::min(RootToken.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1);
   // Remove empty lines before "}" where applicable.
   if (RootToken.is(tok::r_brace) &&
+  // Look for "}", "} // comment", "};" or "}; // comment".
   (!RootToken.Next ||
-   (RootToken.Next->is(tok::semi) && !RootToken.Next->Next)))
+   (RootToken.Next->is(tok::comment) && !RootToken.Next->Next) ||
+   (RootToken.Next->is(tok::semi) &&
+(!RootToken.Next->Next || (RootToken.Next->Next->is(tok::comment) &&
+   !RootToken.Next->Next->Next)
 Newlines = std::min(Newlines, 1u);
   // Remove empty lines at the start of nested blocks (lambdas/arrow functions)
   if (PreviousLine == nullptr && Line.Level > 0)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r327861 - [clang-format] Remove empty lines before }[;] // comment

2018-03-19 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Mon Mar 19 08:33:40 2018
New Revision: 327861

URL: http://llvm.org/viewvc/llvm-project?rev=327861&view=rev
Log:
[clang-format] Remove empty lines before }[;] // comment

Summary:
This addresses bug 36766 and a FIXME in tests about empty lines before
`}[;] // comment` lines.

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp?rev=327861&r1=327860&r2=327861&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp Mon Mar 19 08:33:40 2018
@@ -1133,8 +1133,12 @@ void UnwrappedLineFormatter::formatFirst
   std::min(RootToken.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1);
   // Remove empty lines before "}" where applicable.
   if (RootToken.is(tok::r_brace) &&
+  // Look for "}", "} // comment", "};" or "}; // comment".
   (!RootToken.Next ||
-   (RootToken.Next->is(tok::semi) && !RootToken.Next->Next)))
+   (RootToken.Next->is(tok::comment) && !RootToken.Next->Next) ||
+   (RootToken.Next->is(tok::semi) &&
+(!RootToken.Next->Next || (RootToken.Next->Next->is(tok::comment) &&
+   !RootToken.Next->Next->Next)
 Newlines = std::min(Newlines, 1u);
   // Remove empty lines at the start of nested blocks (lambdas/arrow functions)
   if (PreviousLine == nullptr && Line.Level > 0)

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=327861&r1=327860&r2=327861&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Mar 19 08:33:40 2018
@@ -276,7 +276,6 @@ TEST_F(FormatTest, RemovesEmptyLines) {
"\n"
"}"));
 
-  // FIXME: This is slightly inconsistent.
   FormatStyle LLVMWithNoNamespaceFix = getLLVMStyle();
   LLVMWithNoNamespaceFix.FixNamespaceComments = false;
   EXPECT_EQ("namespace {\n"
@@ -295,12 +294,25 @@ TEST_F(FormatTest, RemovesEmptyLines) {
"}"));
   EXPECT_EQ("namespace {\n"
 "int i;\n"
-"\n"
+"};",
+format("namespace {\n"
+   "int i;\n"
+   "\n"
+   "};"));
+  EXPECT_EQ("namespace {\n"
+"int i;\n"
 "} // namespace",
 format("namespace {\n"
"int i;\n"
"\n"
"}  // namespace"));
+  EXPECT_EQ("namespace {\n"
+"int i;\n"
+"}; // namespace",
+format("namespace {\n"
+   "int i;\n"
+   "\n"
+   "};  // namespace"));
 
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;


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


[PATCH] D44631: [clang-format] Remove empty lines before }[; ] // comment

2018-03-19 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rC327861: [clang-format] Remove empty lines before }[;] // 
comment (authored by krasimir, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44631?vs=138941&id=138942#toc

Repository:
  rC Clang

https://reviews.llvm.org/D44631

Files:
  lib/Format/UnwrappedLineFormatter.cpp
  unittests/Format/FormatTest.cpp


Index: lib/Format/UnwrappedLineFormatter.cpp
===
--- lib/Format/UnwrappedLineFormatter.cpp
+++ lib/Format/UnwrappedLineFormatter.cpp
@@ -1133,8 +1133,12 @@
   std::min(RootToken.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1);
   // Remove empty lines before "}" where applicable.
   if (RootToken.is(tok::r_brace) &&
+  // Look for "}", "} // comment", "};" or "}; // comment".
   (!RootToken.Next ||
-   (RootToken.Next->is(tok::semi) && !RootToken.Next->Next)))
+   (RootToken.Next->is(tok::comment) && !RootToken.Next->Next) ||
+   (RootToken.Next->is(tok::semi) &&
+(!RootToken.Next->Next || (RootToken.Next->Next->is(tok::comment) &&
+   !RootToken.Next->Next->Next)
 Newlines = std::min(Newlines, 1u);
   // Remove empty lines at the start of nested blocks (lambdas/arrow functions)
   if (PreviousLine == nullptr && Line.Level > 0)
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -276,7 +276,6 @@
"\n"
"}"));
 
-  // FIXME: This is slightly inconsistent.
   FormatStyle LLVMWithNoNamespaceFix = getLLVMStyle();
   LLVMWithNoNamespaceFix.FixNamespaceComments = false;
   EXPECT_EQ("namespace {\n"
@@ -295,12 +294,25 @@
"}"));
   EXPECT_EQ("namespace {\n"
 "int i;\n"
-"\n"
+"};",
+format("namespace {\n"
+   "int i;\n"
+   "\n"
+   "};"));
+  EXPECT_EQ("namespace {\n"
+"int i;\n"
 "} // namespace",
 format("namespace {\n"
"int i;\n"
"\n"
"}  // namespace"));
+  EXPECT_EQ("namespace {\n"
+"int i;\n"
+"}; // namespace",
+format("namespace {\n"
+   "int i;\n"
+   "\n"
+   "};  // namespace"));
 
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;


Index: lib/Format/UnwrappedLineFormatter.cpp
===
--- lib/Format/UnwrappedLineFormatter.cpp
+++ lib/Format/UnwrappedLineFormatter.cpp
@@ -1133,8 +1133,12 @@
   std::min(RootToken.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1);
   // Remove empty lines before "}" where applicable.
   if (RootToken.is(tok::r_brace) &&
+  // Look for "}", "} // comment", "};" or "}; // comment".
   (!RootToken.Next ||
-   (RootToken.Next->is(tok::semi) && !RootToken.Next->Next)))
+   (RootToken.Next->is(tok::comment) && !RootToken.Next->Next) ||
+   (RootToken.Next->is(tok::semi) &&
+(!RootToken.Next->Next || (RootToken.Next->Next->is(tok::comment) &&
+   !RootToken.Next->Next->Next)
 Newlines = std::min(Newlines, 1u);
   // Remove empty lines at the start of nested blocks (lambdas/arrow functions)
   if (PreviousLine == nullptr && Line.Level > 0)
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -276,7 +276,6 @@
"\n"
"}"));
 
-  // FIXME: This is slightly inconsistent.
   FormatStyle LLVMWithNoNamespaceFix = getLLVMStyle();
   LLVMWithNoNamespaceFix.FixNamespaceComments = false;
   EXPECT_EQ("namespace {\n"
@@ -295,12 +294,25 @@
"}"));
   EXPECT_EQ("namespace {\n"
 "int i;\n"
-"\n"
+"};",
+format("namespace {\n"
+   "int i;\n"
+   "\n"
+   "};"));
+  EXPECT_EQ("namespace {\n"
+"int i;\n"
 "} // namespace",
 format("namespace {\n"
"int i;\n"
"\n"
"}  // namespace"));
+  EXPECT_EQ("namespace {\n"
+"int i;\n"
+"}; // namespace",
+format("namespace {\n"
+   "int i;\n"
+   "\n"
+   "};  // namespace"));
 
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
___
cfe-commits m

[PATCH] D44632: [clang-format] Add a few more Core Graphics identifiers to ObjC heuristic

2018-03-19 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: jolesiak, djasper.
Herald added subscribers: cfe-commits, klimek.

We received reports of the Objective-C style guesser getting a false
negative on header files like:

CGSize SizeOfThing(MyThing thing);

This adds more Core Graphics identifiers to the Objective-C style
guesser.

Test Plan: New tests added. Ran tests with:

  % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests


Repository:
  rC Clang

https://reviews.llvm.org/D44632

Files:
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -12096,6 +12096,11 @@
   EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo.h", "@interface 
Foo\n@end\n"));
   EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo", ""));
   EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo", "@interface 
Foo\n@end\n"));
+  EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo.h", "int DoStuff(CGRect 
rect);\n"));
+  EXPECT_EQ(
+  FormatStyle::LK_ObjC,
+  guessLanguage("foo.h",
+"#define MY_POINT_MAKE(x, y) CGPointMake((x), (y));\n"));
 }
 
 TEST_F(FormatTest, GuessLanguageWithCpp11AttributeSpecifiers) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1449,6 +1449,19 @@
 // Keep this array sorted, since we are binary searching over it.
 static constexpr llvm::StringLiteral FoundationIdentifiers[] = {
 "CGFloat",
+"CGPoint",
+"CGPointMake",
+"CGPointZero",
+"CGRect",
+"CGRectEdge",
+"CGRectInfinite",
+"CGRectMake",
+"CGRectNull",
+"CGRectZero",
+"CGSize",
+"CGSizeMake",
+"CGVector",
+"CGVectorMake",
 "NSAffineTransform",
 "NSArray",
 "NSAttributedString",
@@ -1497,6 +1510,8 @@
 "NSURLQueryItem",
 "NSUUID",
 "NSValue",
+"UIImage",
+"UIView",
 };
 
 for (auto &Line : AnnotatedLines) {


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -12096,6 +12096,11 @@
   EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo.h", "@interface Foo\n@end\n"));
   EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo", ""));
   EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo", "@interface Foo\n@end\n"));
+  EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo.h", "int DoStuff(CGRect rect);\n"));
+  EXPECT_EQ(
+  FormatStyle::LK_ObjC,
+  guessLanguage("foo.h",
+"#define MY_POINT_MAKE(x, y) CGPointMake((x), (y));\n"));
 }
 
 TEST_F(FormatTest, GuessLanguageWithCpp11AttributeSpecifiers) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1449,6 +1449,19 @@
 // Keep this array sorted, since we are binary searching over it.
 static constexpr llvm::StringLiteral FoundationIdentifiers[] = {
 "CGFloat",
+"CGPoint",
+"CGPointMake",
+"CGPointZero",
+"CGRect",
+"CGRectEdge",
+"CGRectInfinite",
+"CGRectMake",
+"CGRectNull",
+"CGRectZero",
+"CGSize",
+"CGSizeMake",
+"CGVector",
+"CGVectorMake",
 "NSAffineTransform",
 "NSArray",
 "NSAttributedString",
@@ -1497,6 +1510,8 @@
 "NSURLQueryItem",
 "NSUUID",
 "NSValue",
+"UIImage",
+"UIView",
 };
 
 for (auto &Line : AnnotatedLines) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44628: Backport changes from llvm/.clang_tidy to clang/.clang_tidy configs

2018-03-19 Thread Simon Marchi via Phabricator via cfe-commits
simark requested changes to this revision.
simark added inline comments.
This revision now requires changes to proceed.



Comment at: .clang-tidy:8
   - key: readability-identifier-naming.FunctionCase
-value:   lowerCase
+value:   camelBack
+  - key: readability-identifier-naming.MemberCase

In practice, don't we use `CamelCase` for functions?


Repository:
  rC Clang

https://reviews.llvm.org/D44628



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


[PATCH] D41537: Optionally add code completion results for arrow instead of dot

2018-03-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Sorry for the delay.




Comment at: include/clang/Sema/CodeCompleteConsumer.h:565
+  /// \brief For this completion result correction is required.
+  Optional Corr = None;
+

Having a string replacement without an actual range to replace still moves a 
lot of responsibility onto the clients. We should probably model corrections 
after the fix-its for diagnostics:
- replacements need to provide a range to be replaced, alongside with a text 
for the replacement,
- we should provide a list of edits to allow corrections that touch two 
separate pieces of code.

For the fix-its in the diagnostics, see 
[[https://reviews.llvm.org/source/clang/browse/cfe/trunk/tools/libclang/CXLoadedDiagnostic.h;327861$84
 | CXLoadedDiagnostic.h]] for an interface exported via libclang and 
[[https://reviews.llvm.org/source/clang/browse/cfe/trunk/include/clang/Basic/Diagnostic.h;327861$947|Diagnostic.h]]
 for an interface exported in C++ API.
WDYT?


https://reviews.llvm.org/D41537



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


[PATCH] D44630: [ms] Parse #pragma optimize and ignore it behind its own flag

2018-03-19 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm, thanks!




Comment at: lib/Parse/ParsePragma.cpp:2970
+
+  if (Tok.isNot(tok::l_paren)) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_lparen) << 
"optimize";

One day, someone ought to refactor pragma parsing to be less verbose and error 
prone, but today is not that day.


https://reviews.llvm.org/D44630



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


[PATCH] D44605: [Driver] Default to DWARF 5 for Fuchsia

2018-03-19 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

I should also point out that even in DWARF v5 mode LLVM does not yet emit DWARF 
5 variants of all sections as DWARF v5 support in LLVM is not yet 
feature-complete.


Repository:
  rC Clang

https://reviews.llvm.org/D44605



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


[PATCH] D41102: Setup clang-doc frontend framework

2018-03-19 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Huh, something weird is going on there.
What about the other way around, `REQUIRES: linux` ?


Repository:
  rL LLVM

https://reviews.llvm.org/D41102



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


[PATCH] D44272: [clangd] Support incremental document syncing

2018-03-19 Thread Simon Marchi via Phabricator via cfe-commits
simark marked 4 inline comments as done.
simark added inline comments.



Comment at: clangd/ClangdLSPServer.cpp:164
+  if (!Contents) {
+log(llvm::toString(Contents.takeError()));
+return;

ilya-biryukov wrote:
> We should signal an error to the client by calling `replyError`
`textDocument/didChange` is a jsonrpc notification, not request, so we can't 
send back an error.



Comment at: clangd/DraftStore.cpp:106
+} else {
+  NewContents = Change.text;
+}

ilya-biryukov wrote:
> It is impossible to mix full content changes with incremental range changes, 
> right?
> 
> I suggest handling the full content change as a separate case at the start of 
> the function:
> ```
> if (Changes.size() == 1 && !Changes[0].range) {
>   Contents = std::move(Change.text);
>   return Contents;
> }
> 
> for (auto &Change : Changes) {
>   if (!Change.range)
> return make_error("Full change in the middle of incremental changes");
> }
> ```
> 
I'd say it is unlikely and there's probably no reason to do it, but the way the 
data structure is allows it.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44272



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


[PATCH] D44248: [clangd][cmake] Provide libatomic when there is no native support for 64bit atomics

2018-03-19 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

In https://reviews.llvm.org/D44248#1041531, @sdardis wrote:

> Thanks, I wasn't sure who to add as a reviewer.


Authors/reviewers of recent patches for the same files are usually good 
approximations :)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44248



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


r327863 - [Driver] Avoid invalidated iterator in insertTargetAndModeArgs

2018-03-19 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Mon Mar 19 09:13:43 2018
New Revision: 327863

URL: http://llvm.org/viewvc/llvm-project?rev=327863&view=rev
Log:
[Driver] Avoid invalidated iterator in insertTargetAndModeArgs

Doing an .insert() can potentially invalidate iterators by reallocating the
vector's storage. When all the stars align just right, this causes segfaults
or glibc aborts.

Gentoo Linux bug (crashes while building Chromium): 
https://bugs.gentoo.org/650082.

Patch by Hector Martin!

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

Modified:
cfe/trunk/tools/driver/driver.cpp

Modified: cfe/trunk/tools/driver/driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=327863&r1=327862&r2=327863&view=diff
==
--- cfe/trunk/tools/driver/driver.cpp (original)
+++ cfe/trunk/tools/driver/driver.cpp Mon Mar 19 09:13:43 2018
@@ -212,20 +212,21 @@ static void insertTargetAndModeArgs(cons
   // Put target and mode arguments at the start of argument list so that
   // arguments specified in command line could override them. Avoid putting
   // them at index 0, as an option like '-cc1' must remain the first.
-  auto InsertionPoint = ArgVector.begin();
-  if (InsertionPoint != ArgVector.end())
+  int InsertionPoint = 0;
+  if (ArgVector.size() > 0)
 ++InsertionPoint;
 
   if (NameParts.DriverMode) {
 // Add the mode flag to the arguments.
-ArgVector.insert(InsertionPoint,
+ArgVector.insert(ArgVector.begin() + InsertionPoint,
  GetStableCStr(SavedStrings, NameParts.DriverMode));
   }
 
   if (NameParts.TargetIsValid) {
 const char *arr[] = {"-target", GetStableCStr(SavedStrings,
   NameParts.TargetPrefix)};
-ArgVector.insert(InsertionPoint, std::begin(arr), std::end(arr));
+ArgVector.insert(ArgVector.begin() + InsertionPoint,
+ std::begin(arr), std::end(arr));
   }
 }
 


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


[PATCH] D44607: Recompute invalidated iterator in insertTargetAndModeArgs

2018-03-19 Thread Serge Pavlov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL327863: [Driver] Avoid invalidated iterator in 
insertTargetAndModeArgs (authored by sepavloff, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44607?vs=13&id=138952#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44607

Files:
  cfe/trunk/tools/driver/driver.cpp


Index: cfe/trunk/tools/driver/driver.cpp
===
--- cfe/trunk/tools/driver/driver.cpp
+++ cfe/trunk/tools/driver/driver.cpp
@@ -212,20 +212,21 @@
   // Put target and mode arguments at the start of argument list so that
   // arguments specified in command line could override them. Avoid putting
   // them at index 0, as an option like '-cc1' must remain the first.
-  auto InsertionPoint = ArgVector.begin();
-  if (InsertionPoint != ArgVector.end())
+  int InsertionPoint = 0;
+  if (ArgVector.size() > 0)
 ++InsertionPoint;
 
   if (NameParts.DriverMode) {
 // Add the mode flag to the arguments.
-ArgVector.insert(InsertionPoint,
+ArgVector.insert(ArgVector.begin() + InsertionPoint,
  GetStableCStr(SavedStrings, NameParts.DriverMode));
   }
 
   if (NameParts.TargetIsValid) {
 const char *arr[] = {"-target", GetStableCStr(SavedStrings,
   NameParts.TargetPrefix)};
-ArgVector.insert(InsertionPoint, std::begin(arr), std::end(arr));
+ArgVector.insert(ArgVector.begin() + InsertionPoint,
+ std::begin(arr), std::end(arr));
   }
 }
 


Index: cfe/trunk/tools/driver/driver.cpp
===
--- cfe/trunk/tools/driver/driver.cpp
+++ cfe/trunk/tools/driver/driver.cpp
@@ -212,20 +212,21 @@
   // Put target and mode arguments at the start of argument list so that
   // arguments specified in command line could override them. Avoid putting
   // them at index 0, as an option like '-cc1' must remain the first.
-  auto InsertionPoint = ArgVector.begin();
-  if (InsertionPoint != ArgVector.end())
+  int InsertionPoint = 0;
+  if (ArgVector.size() > 0)
 ++InsertionPoint;
 
   if (NameParts.DriverMode) {
 // Add the mode flag to the arguments.
-ArgVector.insert(InsertionPoint,
+ArgVector.insert(ArgVector.begin() + InsertionPoint,
  GetStableCStr(SavedStrings, NameParts.DriverMode));
   }
 
   if (NameParts.TargetIsValid) {
 const char *arr[] = {"-target", GetStableCStr(SavedStrings,
   NameParts.TargetPrefix)};
-ArgVector.insert(InsertionPoint, std::begin(arr), std::end(arr));
+ArgVector.insert(ArgVector.begin() + InsertionPoint,
+ std::begin(arr), std::end(arr));
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44634: [clang-format] Detect Objective-C for #import

2018-03-19 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: jolesiak, djasper.
Herald added subscribers: cfe-commits, klimek.

Previously, the Objective-C heuristic failed to detect
headers which #imported Objective-C system framework(s) and declared C
functions on top them.

This extends the heuristic to look for statements of the form:

and check if "Foo" is one of the known Objective-C system frameworks.

Test Plan: New tests added. Ran tests with:

  % make -j12 FormatTests &&
  ./tools/clang/unittests/Format/FormatTests


Repository:
  rC Clang

https://reviews.llvm.org/D44634

Files:
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -12097,6 +12097,14 @@
   EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo", ""));
   EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo", "@interface Foo\n@end\n"));
   EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo.h", "int DoStuff(CGRect rect);\n"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "#import \n"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "#import \n"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "#import \n"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "#include \n"));
   EXPECT_EQ(
   FormatStyle::LK_ObjC,
   guessLanguage("foo.h",
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1513,6 +1513,79 @@
 "UIImage",
 "UIView",
 };
+// Keep this array sorted, since we are binary searching over it.
+static constexpr llvm::StringLiteral ObjCFrameworks[] = {
+"ARKit",
+"AVFoundation",
+"Accounts",
+"AddressBookUI",
+"AppKit",
+"AssetsLibrary",
+"AudioToolbox",
+"CloudKit",
+"Contacts",
+"ContactsUI",
+"CoreAudioKit",
+"CoreBluetooth",
+"CoreData",
+"CoreImage",
+"CoreLocation",
+"CoreMIDI",
+"CoreML",
+"CoreMotion",
+"CoreNFC",
+"CoreSpotlight",
+"CoreTelephony",
+"DeviceCheck",
+"EventKit",
+"ExternalAccessory",
+"FileProvider",
+"FileProviderUI",
+"Foundation",
+"GLKit",
+"GameController",
+"GameKit",
+"GameplayKit",
+"HealthKit",
+"HomeKit",
+"IOSurface",
+"IdentityLookup",
+"Intents",
+"IntentsUI",
+"JavaScriptCore",
+"MapKit",
+"MediaPlayer",
+"MessageUI",
+"Metal",
+"MetalKit",
+"MetalPerformanceShaders",
+"ModelIO",
+"MultipeerConnectivity",
+"NetworkExtension",
+"NewsstandKit",
+"NotificationCenter",
+"PDFKit",
+"PassKit",
+"Photos",
+"PhotosUI",
+"PushKit",
+"QuartzCore",
+"QuickLook",
+"ReplayKit",
+"SafariServices",
+"SceneKit",
+"Social",
+"Speech",
+"SpriteKit",
+"StoreKit",
+"UIKit",
+"UserNotifications",
+"VideoSubscriberAccount",
+"Vision",
+"WatchConnectivity",
+"WatchKit",
+"WebKit",
+};
 
 for (auto &Line : AnnotatedLines) {
   for (FormatToken *FormatTok = Line->First; FormatTok;
@@ -1534,6 +1607,18 @@
TT_ObjCDecl, TT_ObjCForIn, TT_ObjCMethodExpr,
TT_ObjCMethodSpecifier, TT_ObjCProperty)) {
   return true;
+} else if (Line->Type == LT_ImportStatement &&
+   !FormatTok->getPreviousNonComment() &&
+   // #import 
+   FormatTok->startsSequence(
+   tok::hash, tok::identifier, tok::less, tok::identifier,
+   tok::slash, tok::identifier, tok::period,
+   tok::identifier, tok::greater) &&
+   FormatTok->Next->TokenText == "import" &&
+   std::binary_search(std::begin(ObjCFrameworks),
+  std::end(ObjCFrameworks),
+  FormatTok->Next->Next->Next->TokenText)) {
+  return true;
 }
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41938: [Analyzer] SValBuilder Comparison Rearrangement (with Restrictions and Analyzer Option)

2018-03-19 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added inline comments.



Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:330
+  nonloc::ConcreteInt(Max), SVB.getConditionType());
+  if (auto DV = IsCappedFromAbove.getAs()) {
+if (State->assume(*DV, false))

george.karpenkov wrote:
> 6 lines of branching is probably better expressed as
> 
> ```
> if (!isa(IsCappedFromAbove) || 
> State->assume(*dyn_cast(IsCappedFromAbove), false))
>return false
> ```
SVal is not a pointer, so isa<>() and dyn_cast<>() does not work here.



Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:376
+  // Fail to decompose: "reduce" the problem to the "$x + 0" case.
+  return std::make_tuple(Sym, BO_Add, BV.getValue(0, Sym->getType()));
+}

george.karpenkov wrote:
> Is it beneficial to do this though? At the point where `decomposeSymbol` is 
> called we are still checking whether the rearrangement could be performed, so 
> maybe just returning a false flag would be better?
Failing to decompose a symbol does not mean the rearrangement could not be 
performed. If we have just A on the left side instead of A+m or A-m, then we 
regard it as A+0.



Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:432
+// "$x - $y" vs. "$y - $x" because those are solver's keys.
+if (LInt > RInt) {
+  ResultSym = SymMgr.getSymSymExpr(RSym, BO_Sub, LSym, SymTy);

george.karpenkov wrote:
> I think this could be shortened and made more explicit by constructing the 
> LHS and RHS first, and then reversing both and the comparison operator if RHS 
> is negative.
Are you sure it would be shorter? Anyway, how to reverse a SymSymExpr?


https://reviews.llvm.org/D41938



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


[PATCH] D41938: [Analyzer] SValBuilder Comparison Rearrangement (with Restrictions and Analyzer Option)

2018-03-19 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 138954.
baloghadamsoftware added a comment.

Updated according to the comments.


https://reviews.llvm.org/D41938

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/conditional-path-notes.c
  test/Analysis/explain-svals.cpp
  test/Analysis/svalbuilder-rearrange-comparisons.c

Index: test/Analysis/svalbuilder-rearrange-comparisons.c
===
--- /dev/null
+++ test/Analysis/svalbuilder-rearrange-comparisons.c
@@ -0,0 +1,931 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection,core.builtin -analyzer-config aggressive-relational-comparison-simplification=true -verify %s
+
+void clang_analyzer_dump(int x);
+void clang_analyzer_eval(int x);
+
+void exit(int);
+
+#define UINT_MAX (~0U)
+#define INT_MAX (UINT_MAX & (UINT_MAX >> 1))
+
+extern void __assert_fail (__const char *__assertion, __const char *__file,
+unsigned int __line, __const char *__function)
+ __attribute__ ((__noreturn__));
+#define assert(expr) \
+  ((expr)  ? (void)(0)  : __assert_fail (#expr, __FILE__, __LINE__, __func__))
+
+int g();
+int f() {
+  int x = g();
+  // Assert that no overflows occur in this test file.
+  // Assuming that concrete integers are also within that range.
+  assert(x <= ((int)INT_MAX / 4));
+  assert(x >= -((int)INT_MAX / 4));
+  return x;
+}
+
+void compare_different_symbol_equal() {
+  int x = f(), y = f();
+  clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_dump(y); // expected-warning{{conj_$9{int}}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$2{int}) - (conj_$9{int})) == 0}}
+}
+
+void compare_different_symbol_plus_left_int_equal() {
+  int x = f()+1, y = f();
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 1}}
+  clang_analyzer_dump(y); // expected-warning{{conj_$9{int}}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$9{int}) - (conj_$2{int})) == 1}}
+}
+
+void compare_different_symbol_minus_left_int_equal() {
+  int x = f()-1, y = f();
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 1}}
+  clang_analyzer_dump(y); // expected-warning{{conj_$9{int}}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$2{int}) - (conj_$9{int})) == 1}}
+}
+
+void compare_different_symbol_plus_right_int_equal() {
+  int x = f(), y = f()+2;
+  clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_dump(y); // expected-warning{{(conj_$9{int}) + 2}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$2{int}) - (conj_$9{int})) == 2}}
+}
+
+void compare_different_symbol_minus_right_int_equal() {
+  int x = f(), y = f()-2;
+  clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_dump(y); // expected-warning{{(conj_$9{int}) - 2}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$9{int}) - (conj_$2{int})) == 2}}
+}
+
+void compare_different_symbol_plus_left_plus_right_int_equal() {
+  int x = f()+2, y = f()+1;
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 2}}
+  clang_analyzer_dump(y); // expected-warning{{(conj_$9{int}) + 1}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$9{int}) - (conj_$2{int})) == 1}}
+}
+
+void compare_different_symbol_plus_left_minus_right_int_equal() {
+  int x = f()+2, y = f()-1;
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 2}}
+  clang_analyzer_dump(y); // expected-warning{{(conj_$9{int}) - 1}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$9{int}) - (conj_$2{int})) == 3}}
+}
+
+void compare_different_symbol_minus_left_plus_right_int_equal() {
+  int x = f()-2, y = f()+1;
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 2}}
+  clang_analyzer_dump(y); // expected-warning{{(conj_$9{int}) + 1}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$2{int}) - (conj_$9{int})) == 3}}
+}
+
+void compare_different_symbol_minus_left_minus_right_int_equal() {
+  int x = f()-2, y = f()-1;
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) - 2}}
+  clang_analyzer_dump(y); // expected-warning{{(conj_$9{int}) - 1}}
+  clang_analyzer_dump(x == y);
+  // expected-warning@-1{{((conj_$2{int}) - (conj_$9{int})) == 1}}
+}
+
+void compare_same_symbol_equal() {
+  int x = f(), y = x;
+  clang_analyzer_dump(x); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_eval(x == y);
+  // expected-warning@-1{{TRUE}}
+}
+
+void compare_same_symbol_plus_left_int_equal() {
+  int x = f(), y = x;
+  ++x;
+  clang_analyzer_dump(x); // expected-warning{{(conj_$2{int}) + 1}}
+  clang_analyzer_dump(y); // expected-warning{{conj_$2{int}}}
+  clang_analyzer_eval(x == y);
+  // expected-warning@-1{{FALSE}}
+}
+
+void compare_same_s

[PATCH] D44426: Fix llvm + clang build with Intel compiler

2018-03-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Adding @mibintc to take a look, as she's a good representative of the ICC dev 
team.


https://reviews.llvm.org/D44426



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


[PATCH] D41938: [Analyzer] SValBuilder Comparison Rearrangement (with Restrictions and Analyzer Option)

2018-03-19 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 12 inline comments as done.
baloghadamsoftware added inline comments.



Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:326
+
+  llvm::APSInt Max = AT.getMaxValue() >> 2; // Divide by 4.
+  SVal IsCappedFromAbove =

george.karpenkov wrote:
> Would just division produce the same result? Also probably it's better to 
> make "4" a constant, at least with `#define`
I changed it to division, but I am not sure if we a constant would be more 
readable here than 4.



Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:337
+
+  llvm::APSInt Min = -Max;
+  SVal IsCappedFromBelow =

george.karpenkov wrote:
> 326-335 duplicates 338-346.
> Perhaps we could have
> 
> ```
> static bool isCappedFrom(bool Above, llvm::APSInt bound, ...)
> ```
> 
> ?
isInRelation(), because the opcode itself is passed instead of a bool.


https://reviews.llvm.org/D41938



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


r327867 - [OPENMP, NVPTX] Emit correct thread id.

2018-03-19 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Mar 19 10:04:07 2018
New Revision: 327867

URL: http://llvm.org/viewvc/llvm-project?rev=327867&view=rev
Log:
[OPENMP, NVPTX] Emit correct thread id.

We emitted fake thread id for the outined function in NVPTX codegen.
Patch adds emission of the real thread id.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/test/OpenMP/nvptx_teams_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=327867&r1=327866&r2=327867&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Mon Mar 19 10:04:07 2018
@@ -268,6 +268,10 @@ protected:
   void emitCall(CodeGenFunction &CGF, SourceLocation Loc, llvm::Value *Callee,
 ArrayRef Args = llvm::None) const;
 
+  /// \brief Emits address of the word in a memory where current thread id is
+  /// stored.
+  virtual Address emitThreadIDAddress(CodeGenFunction &CGF, SourceLocation 
Loc);
+
 private:
   /// \brief Default const ident_t object used for initialization of all other
   /// ident_t objects.
@@ -564,10 +568,6 @@ private:
   /// \return Cache variable for the specified threadprivate.
   llvm::Constant *getOrCreateThreadPrivateCache(const VarDecl *VD);
 
-  /// \brief Emits address of the word in a memory where current thread id is
-  /// stored.
-  virtual Address emitThreadIDAddress(CodeGenFunction &CGF, SourceLocation 
Loc);
-
   /// \brief Gets (if variable with the given name already exist) or creates
   /// internal global variable with the specified Name. The created variable 
has
   /// linkage CommonLinkage by default and is initialized by null value.

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=327867&r1=327866&r2=327867&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Mon Mar 19 10:04:07 2018
@@ -608,7 +608,7 @@ void CGOpenMPRuntimeNVPTX::emitGenericEn
   Bld.CreateCondBr(IsWorker, WorkerBB, MasterCheckBB);
 
   CGF.EmitBlock(WorkerBB);
-  emitOutlinedFunctionCall(CGF, WST.Loc, WST.WorkerFn);
+  emitCall(CGF, WST.Loc, WST.WorkerFn);
   CGF.EmitBranch(EST.ExitBB);
 
   CGF.EmitBlock(MasterCheckBB);
@@ -831,10 +831,9 @@ void CGOpenMPRuntimeNVPTX::emitWorkerLoo
 // Insert call to work function via shared wrapper. The shared
 // wrapper takes two arguments:
 //   - the parallelism level;
-//   - the master thread ID;
-emitOutlinedFunctionCall(CGF, WST.Loc, W,
- {Bld.getInt16(/*ParallelLevel=*/0),
-  getMasterThreadID(CGF)});
+//   - the thread ID;
+emitCall(CGF, WST.Loc, W,
+ {Bld.getInt16(/*ParallelLevel=*/0), getThreadID(CGF, WST.Loc)});
 
 // Go to end of parallel region.
 CGF.EmitBranch(TerminateBB);
@@ -1316,12 +1315,12 @@ void CGOpenMPRuntimeNVPTX::emitTeamsCall
   if (!CGF.HaveInsertPoint())
 return;
 
-  Address ZeroAddr =
-  CGF.CreateTempAlloca(CGF.Int32Ty, CharUnits::fromQuantity(4),
-   /*Name*/ ".zero.addr");
+  Address ZeroAddr = CGF.CreateMemTemp(
+  CGF.getContext().getIntTypeForBitwidth(/*DestWidth=*/32, /*Signed=*/1),
+  /*Name*/ ".zero.addr");
   CGF.InitTempAlloca(ZeroAddr, CGF.Builder.getInt32(/*C*/ 0));
   llvm::SmallVector OutlinedFnArgs;
-  OutlinedFnArgs.push_back(ZeroAddr.getPointer());
+  OutlinedFnArgs.push_back(emitThreadIDAddress(CGF, Loc).getPointer());
   OutlinedFnArgs.push_back(ZeroAddr.getPointer());
   OutlinedFnArgs.append(CapturedVars.begin(), CapturedVars.end());
   emitOutlinedFunctionCall(CGF, Loc, OutlinedFn, OutlinedFnArgs);
@@ -1350,7 +1349,7 @@ void CGOpenMPRuntimeNVPTX::emitGenericPa
   // Force inline this outlined function at its call site.
   Fn->setLinkage(llvm::GlobalValue::InternalLinkage);
 
-  auto &&L0ParallelGen = [this, WFn, &CapturedVars](CodeGenFunction &CGF,
+  auto &&L0ParallelGen = [this, WFn, CapturedVars](CodeGenFunction &CGF,
 PrePostActionTy &) {
 CGBuilderTy &Bld = CGF.Builder;
 
@@ -1420,17 +1419,20 @@ void CGOpenMPRuntimeNVPTX::emitGenericPa
   auto *ThreadID = getThreadID(CGF, Loc);
   llvm::Value *Args[] = {RTLoc, ThreadID};
 
-  auto &&SeqGen = [this, Fn, &CapturedVars, &Args, Loc](CodeGenFunction &CGF,
-PrePostActionTy &) {
-auto &&CodeGen = [this, Fn, &CapturedVars, Loc](CodeGenFunction &CGF,
-PrePostActionTy &Action) {
+  auto &&SeqGen = [this, Fn, CapturedVars, Args, Loc](CodeGenFunction &CGF,
+

Re: r327738 - [MS] Don't escape MS C++ names with \01

2018-03-19 Thread Rafael Avila de Espindola via cfe-commits
Thanks!

Reid Kleckner via cfe-commits  writes:

> Author: rnk
> Date: Fri Mar 16 13:36:49 2018
> New Revision: 327738
>
> URL: http://llvm.org/viewvc/llvm-project?rev=327738&view=rev
> Log:
> [MS] Don't escape MS C++ names with \01
>
> It is not needed after LLVM r327734. Now it will be easier to copy-paste
> IR symbol names from Clang.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44539: [Sema][Objective-C] Add check to warn when property of objc type has assign attribute

2018-03-19 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added a comment.

I wonder if this wouldn't be better as a clang-tidy check:

https://github.com/llvm-mirror/clang-tools-extra/tree/master/clang-tidy/objc


Repository:
  rC Clang

https://reviews.llvm.org/D44539



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


r327868 - [OPENMP] Fix build with MSVC, NFC.

2018-03-19 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Mar 19 10:18:13 2018
New Revision: 327868

URL: http://llvm.org/viewvc/llvm-project?rev=327868&view=rev
Log:
[OPENMP] Fix build with MSVC, NFC.

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

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=327868&r1=327867&r2=327868&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Mon Mar 19 10:18:13 2018
@@ -1419,8 +1419,8 @@ void CGOpenMPRuntimeNVPTX::emitGenericPa
   auto *ThreadID = getThreadID(CGF, Loc);
   llvm::Value *Args[] = {RTLoc, ThreadID};
 
-  auto &&SeqGen = [this, Fn, CapturedVars, Args, Loc](CodeGenFunction &CGF,
-  PrePostActionTy &) {
+  auto &&SeqGen = [this, Fn, CapturedVars, &Args, Loc](CodeGenFunction &CGF,
+   PrePostActionTy &) {
 auto &&CodeGen = [this, Fn, CapturedVars, Loc](CodeGenFunction &CGF,
PrePostActionTy &Action) {
   Action.Enter(CGF);


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


[PATCH] D44272: [clangd] Support incremental document syncing

2018-03-19 Thread Simon Marchi via Phabricator via cfe-commits
simark marked 3 inline comments as done.
simark added inline comments.



Comment at: clangd/DraftStore.cpp:61
+  const Position &Start = Change.range->start;
+  size_t StartIndex = positionToOffset(Contents, Start);
+  if (StartIndex > Contents.length()) {

ilya-biryukov wrote:
> `positionToOffset` always truncates to size of contents. It has to return 
> `Expected` too here.
Indeed, it would be better.



Comment at: clangd/DraftStore.cpp:73
+  if (EndIndex > Contents.length()) {
+return llvm::make_error(
+llvm::formatv("Range's end position (line={0}, character={1}) is "

ilya-biryukov wrote:
> Having partially applied changes in the map seems weird. Maybe the code 
> applying the diffs to a separate function that returns either new contents or 
> an error and use it here?
> I.e. we won't be able to end up in a state with partially applied changes:
> 
> ```
> Expected applyChanges(StringRef Contents, 
> ArrayRef Changes) {
> }
> 
> // See other comment about Version.
> Expected updateDraft(StringRef File, /*int Version,*/ 
> ArrayRef Changes) {
>   // check File is in the map and version matches
>   //...
>   string& Contents = ...;
>   auto NewContents = applyChanges(Contents, Changes);
>   if (!NewContents) 
> return NewContents.takeError();
>   Contents = *NewContents;
>   return std::move(*NewContents);
> }
> ```
It makes sense, but I think we can achieve the same result by just tweaking the 
current code. I don't think a separate function is really needed here.



Comment at: clangd/DraftStore.cpp:97
+
+  NewContents.reserve(StartIndex + Change.text.length() +
+  (Contents.length() - EndIndex));

ilya-biryukov wrote:
> The math is correct, but I'm confused on how to properly read the formula 
> here. 
> Maybe change to:
> `Contents.length() - (EndIndex - StartIndex) + Change.text.length()`?
> 
> This clearly reads as:
> `LengthBefore - LengthRemoved + LengthAdded`
I saw it as `LengthOfTheSliceFromTheOriginalThatWeKeepBefore + LengthOfNewStuff 
+ LengthOfTheSliceFromTheOriginalThatWeKeepAfter`.  But I don't mind changing 
it.



Comment at: clangd/DraftStore.cpp:103
+
+  if (EndIndex < Contents.length())
+NewContents += Contents.substr(EndIndex);

ilya-biryukov wrote:
> This check seems unnecessary, we've already checked for range errors. Maybe 
> remove it?
Note that this check is not equivalent to the previous

if (EndIndex > Contents.length())

for the case where `EndIndex == Contents.length()`. In our case, it's possible 
(and valid) for EndIndex to be equal to Contents.length(), when referring to 
the end of the document (past the last character).  I thought that doing 
`Contents.substr(Contents.length())` would be throw `std::out_of_range` or be 
undefined behavior, but now that I read it correctly:

@throw  std::out_of_range  If __pos > size().

So it looks like it would fine to have pos == Contents.length().


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44272



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


r327870 - [ObjC] Allow declaring __weak pointer fields in C structs in ARC.

2018-03-19 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon Mar 19 10:38:40 2018
New Revision: 327870

URL: http://llvm.org/viewvc/llvm-project?rev=327870&view=rev
Log:
[ObjC] Allow declaring __weak pointer fields in C structs in ARC.

This patch uses the infrastructure added in r326307 for enabling
non-trivial fields to be declared in C structs to allow __weak fields in
C structs in ARC.

This recommits r327206, which was reverted because it caused
module-enabled builders to fail. I discovered that the
CXXRecordDecl::CanPassInRegisters flag wasn't being set correctly in
some cases after I moved it to RecordDecl.

Thanks to Eric Liu for helping me investigate the bug.

rdar://problem/33599681

https://reviews.llvm.org/D44095

Added:
cfe/trunk/test/CodeGenObjC/weak-in-c-struct.m
cfe/trunk/test/Modules/Inputs/template-nontrivial0.h
cfe/trunk/test/Modules/Inputs/template-nontrivial1.h
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGNonTrivialStruct.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/CodeGenObjC/nontrivial-c-struct-exception.m
cfe/trunk/test/Modules/Inputs/module.map
cfe/trunk/test/Modules/templates.mm

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=327870&r1=327869&r2=327870&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Mar 19 10:38:40 2018
@@ -3553,6 +3553,12 @@ class RecordDecl : public TagDecl {
   bool NonTrivialToPrimitiveCopy : 1;
   bool NonTrivialToPrimitiveDestroy : 1;
 
+  /// True if this class can be passed in a non-address-preserving fashion
+  /// (such as in registers).
+  /// This does not imply anything about how the ABI in use will actually
+  /// pass an object of this class.
+  bool CanPassInRegisters : 1;
+
 protected:
   RecordDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC,
  SourceLocation StartLoc, SourceLocation IdLoc,
@@ -3636,6 +3642,18 @@ public:
 NonTrivialToPrimitiveDestroy = V;
   }
 
+  /// Determine whether this class can be passed in registers. In C++ mode,
+  /// it must have at least one trivial, non-deleted copy or move constructor.
+  /// FIXME: This should be set as part of completeDefinition.
+  bool canPassInRegisters() const {
+return CanPassInRegisters;
+  }
+
+  /// Set that we can pass this RecordDecl in registers.
+  void setCanPassInRegisters(bool CanPass) {
+CanPassInRegisters = CanPass;
+  }
+
   /// \brief Determines whether this declaration represents the
   /// injected class name.
   ///

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=327870&r1=327869&r2=327870&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Mon Mar 19 10:38:40 2018
@@ -467,12 +467,6 @@ class CXXRecordDecl : public RecordDecl
 /// constructor.
 unsigned HasDefaultedDefaultConstructor : 1;
 
-/// \brief True if this class can be passed in a non-address-preserving
-/// fashion (such as in registers) according to the C++ language rules.
-/// This does not imply anything about how the ABI in use will actually
-/// pass an object of this class.
-unsigned CanPassInRegisters : 1;
-
 /// \brief True if a defaulted default constructor for this class would
 /// be constexpr.
 unsigned DefaultedDefaultConstructorIsConstexpr : 1;
@@ -1474,18 +1468,6 @@ public:
 return data().HasIrrelevantDestructor;
   }
 
-  /// \brief Determine whether this class has at least one trivial, non-deleted
-  /// copy or move constructor.
-  bool canPassInRegisters() const {
-return data().CanPassInRegisters;
-  }
-
-  /// \brief Set that we can pass this RecordDecl in registers.
-  // FIXME: This should be set as part of completeDefinition.
-  void setCanPassInRegisters(bool CanPass) {
-data().CanPassInRegisters = CanPass;
-  }
-
   /// Determine whether the triviality for the purpose of calls for this class
   /// is overridden to be trivial because this class or the type of one of its
   /// subobjects has attribute "trivial_abi".

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h

[PATCH] D44095: [ObjC] Allow declaring __weak pointer fields in C structs in ObjC-ARC

2018-03-19 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

This was reverted in r327294 because it caused module-enabled builders to fail 
after I moved CXXRecordDecl::CanPassInRegisters to RecordDecl. I'm recommitting 
this patch with fixes to ASTDeclReader and ASTWriter.


Repository:
  rC Clang

https://reviews.llvm.org/D44095



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


[PATCH] D44619: [CodeGen] Add cleanup scope to EmitInlinedInheritingCXXConstructorCall

2018-03-19 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

Code looks good, but we should make the test more robust and self-documenting.




Comment at: test/CodeGenCXX/inheriting-constructor-cleanup.cpp:22
+// CHECK-LABEL: define void @_Z1fv
+// CHECK: call void @_ZN1SD2Ev

The landingpad should be trivially dead, since T has nothing that throws in it, 
right? Clang is usually pretty smart about not emitting unused exceptional-only 
destructors, so I'd try to defend against it getting smart in the future. I'd 
put a function call `foo` in `T(int, ...)`, then CHECK for the invoke of it, 
and that it unwinds to a landingpad preceding this destructor call.


Repository:
  rC Clang

https://reviews.llvm.org/D44619



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


r327873 - [OPENMP, NVPTX] Reworked castToType() function, NFC.

2018-03-19 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Mar 19 10:53:56 2018
New Revision: 327873

URL: http://llvm.org/viewvc/llvm-project?rev=327873&view=rev
Log:
[OPENMP, NVPTX] Reworked castToType() function, NFC.

Reworked function castToType to use more frontend functionality rather
than the backend.

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

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=327873&r1=327872&r2=327873&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Mon Mar 19 10:53:56 2018
@@ -1477,49 +1477,53 @@ void CGOpenMPRuntimeNVPTX::emitSpmdParal
 }
 
 /// Cast value to the specified type.
-static llvm::Value *
-castValueToType(CodeGenFunction &CGF, llvm::Value *Val, llvm::Type *CastTy,
-llvm::Optional IsSigned = llvm::None) {
-  if (Val->getType() == CastTy)
+static llvm::Value *castValueToType(CodeGenFunction &CGF, llvm::Value *Val,
+QualType ValTy, QualType CastTy,
+SourceLocation Loc) {
+  assert(!CGF.getContext().getTypeSizeInChars(CastTy).isZero() &&
+ "Cast type must sized.");
+  assert(!CGF.getContext().getTypeSizeInChars(ValTy).isZero() &&
+ "Val type must sized.");
+  llvm::Type *LLVMCastTy = CGF.ConvertTypeForMem(CastTy);
+  if (ValTy == CastTy)
 return Val;
-  if (Val->getType()->getPrimitiveSizeInBits() > 0 &&
-  CastTy->getPrimitiveSizeInBits() > 0 &&
-  Val->getType()->getPrimitiveSizeInBits() ==
-  CastTy->getPrimitiveSizeInBits())
-return CGF.Builder.CreateBitCast(Val, CastTy);
-  if (IsSigned.hasValue() && CastTy->isIntegerTy() &&
-  Val->getType()->isIntegerTy())
-return CGF.Builder.CreateIntCast(Val, CastTy, *IsSigned);
-  Address CastItem = CGF.CreateTempAlloca(
-  CastTy,
-  CharUnits::fromQuantity(
-  CGF.CGM.getDataLayout().getPrefTypeAlignment(Val->getType(;
+  if (CGF.getContext().getTypeSizeInChars(ValTy) ==
+  CGF.getContext().getTypeSizeInChars(CastTy))
+return CGF.Builder.CreateBitCast(Val, LLVMCastTy);
+  if (CastTy->isIntegerType() && ValTy->isIntegerType())
+return CGF.Builder.CreateIntCast(Val, LLVMCastTy,
+ CastTy->hasSignedIntegerRepresentation());
+  Address CastItem = CGF.CreateMemTemp(CastTy);
   Address ValCastItem = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
   CastItem, Val->getType()->getPointerTo(CastItem.getAddressSpace()));
-  CGF.Builder.CreateStore(Val, ValCastItem);
-  return CGF.Builder.CreateLoad(CastItem);
+  CGF.EmitStoreOfScalar(Val, ValCastItem, /*Volatile=*/false, ValTy);
+  return CGF.EmitLoadOfScalar(CastItem, /*Volatile=*/false, CastTy, Loc);
 }
 
 /// This function creates calls to one of two shuffle functions to copy
 /// variables between lanes in a warp.
 static llvm::Value *createRuntimeShuffleFunction(CodeGenFunction &CGF,
  llvm::Value *Elem,
- llvm::Value *Offset) {
+ QualType ElemType,
+ llvm::Value *Offset,
+ SourceLocation Loc) {
   auto &CGM = CGF.CGM;
   auto &Bld = CGF.Builder;
   CGOpenMPRuntimeNVPTX &RT =
   *(static_cast(&CGM.getOpenMPRuntime()));
 
-  unsigned Size = CGM.getDataLayout().getTypeStoreSize(Elem->getType());
-  assert(Size <= 8 && "Unsupported bitwidth in shuffle instruction.");
+  CharUnits Size = CGF.getContext().getTypeSizeInChars(ElemType);
+  assert(Size.getQuantity() <= 8 &&
+ "Unsupported bitwidth in shuffle instruction.");
 
-  OpenMPRTLFunctionNVPTX ShuffleFn = Size <= 4
+  OpenMPRTLFunctionNVPTX ShuffleFn = Size.getQuantity() <= 4
  ? OMPRTL_NVPTX__kmpc_shuffle_int32
  : OMPRTL_NVPTX__kmpc_shuffle_int64;
 
   // Cast all types to 32- or 64-bit values before calling shuffle routines.
-  llvm::Type *CastTy = Size <= 4 ? CGM.Int32Ty : CGM.Int64Ty;
-  llvm::Value *ElemCast = castValueToType(CGF, Elem, CastTy, 
/*isSigned=*/true);
+  QualType CastTy = CGF.getContext().getIntTypeForBitwidth(
+  Size.getQuantity() <= 4 ? 32 : 64, /*Signed=*/1);
+  llvm::Value *ElemCast = castValueToType(CGF, Elem, ElemType, CastTy, Loc);
   auto *WarpSize =
   Bld.CreateIntCast(getNVPTXWarpSize(CGF), CGM.Int16Ty, /*isSigned=*/true);
 
@@ -1527,7 +1531,7 @@ static llvm::Value *createRuntimeShuffle
   CGF.EmitRuntimeCall(RT.createNVPTXRuntimeFunction(ShuffleFn),
   {ElemCast, Offset, WarpSize});
 
-  return castValueToType(CGF, ShuffledVal, Elem->getType(), /*isSigned=*/true);
+  return castValueToType(CGF, Shu

[PATCH] D44638: [clang-format] Fix ObjC selectors with multiple params passed to macro

2018-03-19 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: jolesiak, djasper, Wizard.
Herald added subscribers: cfe-commits, klimek.

Objective-C selectors can with arguments be in the form:

foo:
foo:bar:
foo:bar:baz:

These can be passed to a macro, like NS_SWIFT_NAME():

https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html

and must never have spaces inserted around the colons.

Previously, there was logic in TokenAnnotator's tok::colon parser to
handle the single-argument case, but it failed for the
multiple-argument cases.

This diff fixes the bug and adds more tests.

Test Plan: New tests added. Ran tests with:

  % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests


Repository:
  rC Clang

https://reviews.llvm.org/D44638

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestObjC.cpp


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -618,6 +618,9 @@
   verifyFormat("for (id foo in [self getStuffFor:bla]) {\n"
"}");
   verifyFormat("[self a:MACRO(a, b:, c:)];");
+  verifyFormat("[self a:MACRO(a, b:c:, d:e:)];");
+  verifyFormat("[self a:MACRO(a, b:c:d:, e:f:g:)];");
+  verifyFormat("int XYMyFoo(int a, int b) NS_SWIFT_NAME(foo(self:scale:));");
   verifyFormat("[self a:(1 + 2) b:3];");
   verifyFormat("[self a:(Type)a b:3];");
 
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -701,7 +701,8 @@
 else
   Tok->Type = TT_InheritanceColon;
   } else if (Tok->Previous->is(tok::identifier) && Tok->Next &&
- Tok->Next->isOneOf(tok::r_paren, tok::comma)) {
+ (Tok->Next->isOneOf(tok::r_paren, tok::comma) ||
+  Tok->Next->startsSequence(tok::identifier, tok::colon))) {
 // This handles a special macro in ObjC code where selectors including
 // the colon are passed as macro arguments.
 Tok->Type = TT_ObjCMethodExpr;


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -618,6 +618,9 @@
   verifyFormat("for (id foo in [self getStuffFor:bla]) {\n"
"}");
   verifyFormat("[self a:MACRO(a, b:, c:)];");
+  verifyFormat("[self a:MACRO(a, b:c:, d:e:)];");
+  verifyFormat("[self a:MACRO(a, b:c:d:, e:f:g:)];");
+  verifyFormat("int XYMyFoo(int a, int b) NS_SWIFT_NAME(foo(self:scale:));");
   verifyFormat("[self a:(1 + 2) b:3];");
   verifyFormat("[self a:(Type)a b:3];");
 
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -701,7 +701,8 @@
 else
   Tok->Type = TT_InheritanceColon;
   } else if (Tok->Previous->is(tok::identifier) && Tok->Next &&
- Tok->Next->isOneOf(tok::r_paren, tok::comma)) {
+ (Tok->Next->isOneOf(tok::r_paren, tok::comma) ||
+  Tok->Next->startsSequence(tok::identifier, tok::colon))) {
 // This handles a special macro in ObjC code where selectors including
 // the colon are passed as macro arguments.
 Tok->Type = TT_ObjCMethodExpr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36918: [Sema] Take into account the current context when checking the accessibility of a member function pointer

2018-03-19 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

ping


https://reviews.llvm.org/D36918



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


[PATCH] D44606: [analyzer] Fix the crash in `IteratorChecker.cpp` when `SymbolConjured` has a null Stmt.

2018-03-19 Thread Peter Szecsi via Phabricator via cfe-commits
szepet added a comment.

Nice catch, it looks good to me! Thank you!
One small nit for future debugging people: Could you insert a comment line in 
the test case where you explain what is this all about? E.g what you just have 
written in the description: "invalidateRegions() will construct the 
SymbolConjured with null Stmt" or something like this.


Repository:
  rC Clang

https://reviews.llvm.org/D44606



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


[PATCH] D44640: [CodeGen] Add funclet token to ARC marker

2018-03-19 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
smeenai added reviewers: ahatanak, compnerd, majnemer, rjmccall, rnk.

The inline assembly generated for the ARC autorelease elision marker
must have a funclet token if it's emitted inside a funclet, otherwise
the inline assembly (and all subsequent code in the funclet) will be
marked unreachable. r324689 fixed this issue for regular inline assembly
blocks.

Note that clang only emits the marker at -O0, so this only fixes that
case. The optimizations case (where the marker is emitted by the
backend) will be fixed in a separate change.


Repository:
  rC Clang

https://reviews.llvm.org/D44640

Files:
  lib/CodeGen/CGObjC.cpp
  test/CodeGenObjCXX/arc-marker-funclet.mm


Index: test/CodeGenObjCXX/arc-marker-funclet.mm
===
--- /dev/null
+++ test/CodeGenObjCXX/arc-marker-funclet.mm
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fobjc-runtime=ios-6.0 
-fobjc-arc \
+// RUN:   -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s
+
+id f();
+void g() {
+  try {
+f();
+  } catch (...) {
+f();
+  }
+}
+
+// CHECK: call i8* @"\01?f@@YAPAUobjc_object@@XZ"() [ "funclet"(token %1) ]
+// CHECK-NEXT: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""() [ 
"funclet"(token %1) ]
+
+// The corresponding f() call was invoked from the entry basic block.
+// CHECK: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""(){{$}}
Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -2034,7 +2034,7 @@
 
   // Call the marker asm if we made one, which we do only at -O0.
   if (marker)
-CGF.Builder.CreateCall(marker);
+CGF.Builder.CreateCall(marker, None, CGF.getBundlesForFunclet(marker));
 }
 
 /// Retain the given object which is the result of a function call.


Index: test/CodeGenObjCXX/arc-marker-funclet.mm
===
--- /dev/null
+++ test/CodeGenObjCXX/arc-marker-funclet.mm
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fobjc-runtime=ios-6.0 -fobjc-arc \
+// RUN:   -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s
+
+id f();
+void g() {
+  try {
+f();
+  } catch (...) {
+f();
+  }
+}
+
+// CHECK: call i8* @"\01?f@@YAPAUobjc_object@@XZ"() [ "funclet"(token %1) ]
+// CHECK-NEXT: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""() [ "funclet"(token %1) ]
+
+// The corresponding f() call was invoked from the entry basic block.
+// CHECK: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""(){{$}}
Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -2034,7 +2034,7 @@
 
   // Call the marker asm if we made one, which we do only at -O0.
   if (marker)
-CGF.Builder.CreateCall(marker);
+CGF.Builder.CreateCall(marker, None, CGF.getBundlesForFunclet(marker));
 }
 
 /// Retain the given object which is the result of a function call.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r327887 - [clang-move] Fix the failing test caused by changes in clang-format.

2018-03-19 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon Mar 19 12:13:03 2018
New Revision: 327887

URL: http://llvm.org/viewvc/llvm-project?rev=327887&view=rev
Log:
[clang-move] Fix the failing test caused by changes in clang-format.

Modified:
clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp

Modified: clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp?rev=327887&r1=327886&r2=327887&view=diff
==
--- clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp Mon Mar 
19 12:13:03 2018
@@ -412,7 +412,6 @@
 // CHECK-NEW-CPP-NEXT: }
 // CHECK-NEW-CPP-SAME: {{[[:space:]]}}
 // CHECK-NEW-CPP-NEXT: void Fun1() { HelperFun5(); }
-// CHECK-NEW-CPP-SAME: {{[[:space:]]}}
 // CHECK-NEW-CPP-NEXT: } // namespace a
 // CHECK-NEW-CPP-SAME: {{[[:space:]]}}
 // CHECK-NEW-CPP-NEXT: namespace b {


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


[PATCH] D44640: [CodeGen] Add funclet token to ARC marker

2018-03-19 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.

We should really just switch the reclaim to be marked with a bundle in the 
first place, but that's not a reasonable thing to ask you to do.


Repository:
  rC Clang

https://reviews.llvm.org/D44640



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


[PATCH] D44426: Fix llvm + clang build with Intel compiler

2018-03-19 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

I added some inline comments. You are using the Intel 18.0 compiler on Windows 
- what version of Visual Studio is in the environment?




Comment at: include/llvm-c/Target.h:25
 
-#if defined(_MSC_VER) && !defined(inline)
+#if defined(_MSC_VER) && !defined(inline) && !defined(__INTEL_COMPILER)
 #define inline __inline

I really think all the Intel-compiler bug workarounds should be version 
specific. For example, in the boost.org customizations we have checks like this:
#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1500)

I believe you are using the most recent Intel compiler, 18.0, which has version 
1800.  Let's assume the bug will either be fixed in our 18.0 compiler or in our 
next compiler which would be numbered 1900, so the check could be like this:
#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER < 1900) // employ the 
workaround for the Intel 18.0 compiler and older

This way the workaround will "disappear" when the bug gets fixed.

For that matter I wonder if it's still necessary to use the workaround for the 
Microsoft compiler?

Thanks for reporting the bug into the Intel forum. If we put a bug workaround 
into LLVM it would be very nice to have the bug reported to the offending 
compiler. 




Comment at: include/llvm/ADT/BitmaskEnum.h:73
 
+#ifdef __INTEL_COMPILER
+template 

what problem is being worked around here? I checked your post into the Intel 
compiler forum "enum members are not visible to template specialization" and I 
can observe the bug on our Windows compiler but not our Linux compiler. 



Comment at: include/llvm/Analysis/AliasAnalysis.h:254
   FMRB_OnlyAccessesInaccessibleOrArgMem = FMRL_InaccessibleMem |
-  FMRL_ArgumentPointees |
+  
static_cast(FMRL_ArgumentPointees) |
   static_cast(ModRefInfo::ModRef),

is this a necessary workaround for the Intel compiler? It's not pretty.  
Suggest we add the #if around it? Long term i hope this would not be necessary.



Comment at: lib/Target/AMDGPU/SIISelLowering.cpp:6131
 
+#ifndef __INTEL_COMPILER
 static_assert(((~(SIInstrFlags::S_NAN |

this assesrts with Intel compiler?  Or the expression needs to be rewritten 
with static_cast as above?


https://reviews.llvm.org/D44426



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


r327892 - [CodeGen] Add funclet token to ARC marker

2018-03-19 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Mon Mar 19 12:34:39 2018
New Revision: 327892

URL: http://llvm.org/viewvc/llvm-project?rev=327892&view=rev
Log:
[CodeGen] Add funclet token to ARC marker

The inline assembly generated for the ARC autorelease elision marker
must have a funclet token if it's emitted inside a funclet, otherwise
the inline assembly (and all subsequent code in the funclet) will be
marked unreachable. r324689 fixed this issue for regular inline assembly
blocks.

Note that clang only emits the marker at -O0, so this only fixes that
case. The optimizations case (where the marker is emitted by the
backend) will be fixed in a separate change.

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

Added:
cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm
Modified:
cfe/trunk/lib/CodeGen/CGObjC.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=327892&r1=327891&r2=327892&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Mon Mar 19 12:34:39 2018
@@ -2034,7 +2034,7 @@ static void emitAutoreleasedReturnValueM
 
   // Call the marker asm if we made one, which we do only at -O0.
   if (marker)
-CGF.Builder.CreateCall(marker);
+CGF.Builder.CreateCall(marker, None, CGF.getBundlesForFunclet(marker));
 }
 
 /// Retain the given object which is the result of a function call.

Added: cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm?rev=327892&view=auto
==
--- cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm (added)
+++ cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm Mon Mar 19 12:34:39 2018
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fobjc-runtime=ios-6.0 
-fobjc-arc \
+// RUN:   -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s
+
+id f();
+void g() {
+  try {
+f();
+  } catch (...) {
+f();
+  }
+}
+
+// CHECK: call i8* @"?f@@YAPAUobjc_object@@XZ"() [ "funclet"(token %1) ]
+// CHECK-NEXT: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""() [ 
"funclet"(token %1) ]
+
+// The corresponding f() call was invoked from the entry basic block.
+// CHECK: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""(){{$}}


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


[PATCH] D44643: [Lex] Change HeaderSearchOptions arguments to std::string.

2018-03-19 Thread Frederich Munch via Phabricator via cfe-commits
marsupial updated this revision to Diff 138982.

https://reviews.llvm.org/D44643

Files:
  include/clang/Lex/HeaderSearchOptions.h


Index: include/clang/Lex/HeaderSearchOptions.h
===
--- include/clang/Lex/HeaderSearchOptions.h
+++ include/clang/Lex/HeaderSearchOptions.h
@@ -203,34 +203,35 @@
 
   unsigned ModulesHashContent : 1;
 
-  HeaderSearchOptions(StringRef _Sysroot = "/")
-  : Sysroot(_Sysroot), ModuleFormat("raw"), DisableModuleHash(false),
-ImplicitModuleMaps(false), ModuleMapFileHomeIsCwd(false),
-UseBuiltinIncludes(true), UseStandardSystemIncludes(true),
-UseStandardCXXIncludes(true), UseLibcxx(false), Verbose(false),
+  HeaderSearchOptions(std::string _Sysroot = "/")
+  : Sysroot(std::move(_Sysroot)), ModuleFormat("raw"),
+DisableModuleHash(false), ImplicitModuleMaps(false),
+ModuleMapFileHomeIsCwd(false), UseBuiltinIncludes(true),
+UseStandardSystemIncludes(true), UseStandardCXXIncludes(true),
+UseLibcxx(false), Verbose(false),
 ModulesValidateOncePerBuildSession(false),
 ModulesValidateSystemHeaders(false), UseDebugInfo(false),
 ModulesValidateDiagnosticOptions(true), ModulesHashContent(false) {}
 
   /// AddPath - Add the \p Path path to the specified \p Group list.
-  void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
+  void AddPath(std::string Path, frontend::IncludeDirGroup Group,
bool IsFramework, bool IgnoreSysRoot) {
-UserEntries.emplace_back(Path, Group, IsFramework, IgnoreSysRoot);
+UserEntries.emplace_back(std::move(Path), Group, IsFramework, 
IgnoreSysRoot);
   }
 
   /// AddSystemHeaderPrefix - Override whether \#include directives naming a
   /// path starting with \p Prefix should be considered as naming a system
   /// header.
-  void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
-SystemHeaderPrefixes.emplace_back(Prefix, IsSystemHeader);
+  void AddSystemHeaderPrefix(std::string Prefix, bool IsSystemHeader) {
+SystemHeaderPrefixes.emplace_back(std::move(Prefix), IsSystemHeader);
   }
 
-  void AddVFSOverlayFile(StringRef Name) {
-VFSOverlayFiles.push_back(Name);
+  void AddVFSOverlayFile(std::string Name) {
+VFSOverlayFiles.emplace_back(std::move(Name));
   }
 
-  void AddPrebuiltModulePath(StringRef Name) {
-PrebuiltModulePaths.push_back(Name);
+  void AddPrebuiltModulePath(std::string Name) {
+PrebuiltModulePaths.emplace_back(std::move(Name));
   }
 };
 


Index: include/clang/Lex/HeaderSearchOptions.h
===
--- include/clang/Lex/HeaderSearchOptions.h
+++ include/clang/Lex/HeaderSearchOptions.h
@@ -203,34 +203,35 @@
 
   unsigned ModulesHashContent : 1;
 
-  HeaderSearchOptions(StringRef _Sysroot = "/")
-  : Sysroot(_Sysroot), ModuleFormat("raw"), DisableModuleHash(false),
-ImplicitModuleMaps(false), ModuleMapFileHomeIsCwd(false),
-UseBuiltinIncludes(true), UseStandardSystemIncludes(true),
-UseStandardCXXIncludes(true), UseLibcxx(false), Verbose(false),
+  HeaderSearchOptions(std::string _Sysroot = "/")
+  : Sysroot(std::move(_Sysroot)), ModuleFormat("raw"),
+DisableModuleHash(false), ImplicitModuleMaps(false),
+ModuleMapFileHomeIsCwd(false), UseBuiltinIncludes(true),
+UseStandardSystemIncludes(true), UseStandardCXXIncludes(true),
+UseLibcxx(false), Verbose(false),
 ModulesValidateOncePerBuildSession(false),
 ModulesValidateSystemHeaders(false), UseDebugInfo(false),
 ModulesValidateDiagnosticOptions(true), ModulesHashContent(false) {}
 
   /// AddPath - Add the \p Path path to the specified \p Group list.
-  void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
+  void AddPath(std::string Path, frontend::IncludeDirGroup Group,
bool IsFramework, bool IgnoreSysRoot) {
-UserEntries.emplace_back(Path, Group, IsFramework, IgnoreSysRoot);
+UserEntries.emplace_back(std::move(Path), Group, IsFramework, IgnoreSysRoot);
   }
 
   /// AddSystemHeaderPrefix - Override whether \#include directives naming a
   /// path starting with \p Prefix should be considered as naming a system
   /// header.
-  void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
-SystemHeaderPrefixes.emplace_back(Prefix, IsSystemHeader);
+  void AddSystemHeaderPrefix(std::string Prefix, bool IsSystemHeader) {
+SystemHeaderPrefixes.emplace_back(std::move(Prefix), IsSystemHeader);
   }
 
-  void AddVFSOverlayFile(StringRef Name) {
-VFSOverlayFiles.push_back(Name);
+  void AddVFSOverlayFile(std::string Name) {
+VFSOverlayFiles.emplace_back(std::move(Name));
   }
 
-  void AddPrebuiltModulePath(StringRef Name) {
-PrebuiltModulePaths.push_back(Name);
+  void AddPrebuiltModulePath(std::string Name) {
+PrebuiltModulePaths.emplace_back(std::move(Name));
   }
 };
 
_

[PATCH] D44643: [Lex] Change HeaderSearchOptions arguments to std::string.

2018-03-19 Thread Frederich Munch via Phabricator via cfe-commits
marsupial created this revision.
marsupial added reviewers: eugene, boris.
marsupial added a project: clang.
marsupial updated this revision to Diff 138982.

Arguments passed to HeaderSearchOptions methods are stored as std::strings, 
having them converted to a StringRef at the call site can result in unnecessary 
conversions and copies.


https://reviews.llvm.org/D44643

Files:
  include/clang/Lex/HeaderSearchOptions.h


Index: include/clang/Lex/HeaderSearchOptions.h
===
--- include/clang/Lex/HeaderSearchOptions.h
+++ include/clang/Lex/HeaderSearchOptions.h
@@ -203,34 +203,35 @@
 
   unsigned ModulesHashContent : 1;
 
-  HeaderSearchOptions(StringRef _Sysroot = "/")
-  : Sysroot(_Sysroot), ModuleFormat("raw"), DisableModuleHash(false),
-ImplicitModuleMaps(false), ModuleMapFileHomeIsCwd(false),
-UseBuiltinIncludes(true), UseStandardSystemIncludes(true),
-UseStandardCXXIncludes(true), UseLibcxx(false), Verbose(false),
+  HeaderSearchOptions(std::string _Sysroot = "/")
+  : Sysroot(std::move(_Sysroot)), ModuleFormat("raw"),
+DisableModuleHash(false), ImplicitModuleMaps(false),
+ModuleMapFileHomeIsCwd(false), UseBuiltinIncludes(true),
+UseStandardSystemIncludes(true), UseStandardCXXIncludes(true),
+UseLibcxx(false), Verbose(false),
 ModulesValidateOncePerBuildSession(false),
 ModulesValidateSystemHeaders(false), UseDebugInfo(false),
 ModulesValidateDiagnosticOptions(true), ModulesHashContent(false) {}
 
   /// AddPath - Add the \p Path path to the specified \p Group list.
-  void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
+  void AddPath(std::string Path, frontend::IncludeDirGroup Group,
bool IsFramework, bool IgnoreSysRoot) {
-UserEntries.emplace_back(Path, Group, IsFramework, IgnoreSysRoot);
+UserEntries.emplace_back(std::move(Path), Group, IsFramework, 
IgnoreSysRoot);
   }
 
   /// AddSystemHeaderPrefix - Override whether \#include directives naming a
   /// path starting with \p Prefix should be considered as naming a system
   /// header.
-  void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
-SystemHeaderPrefixes.emplace_back(Prefix, IsSystemHeader);
+  void AddSystemHeaderPrefix(std::string Prefix, bool IsSystemHeader) {
+SystemHeaderPrefixes.emplace_back(std::move(Prefix), IsSystemHeader);
   }
 
-  void AddVFSOverlayFile(StringRef Name) {
-VFSOverlayFiles.push_back(Name);
+  void AddVFSOverlayFile(std::string Name) {
+VFSOverlayFiles.emplace_back(std::move(Name));
   }
 
-  void AddPrebuiltModulePath(StringRef Name) {
-PrebuiltModulePaths.push_back(Name);
+  void AddPrebuiltModulePath(std::string Name) {
+PrebuiltModulePaths.emplace_back(std::move(Name));
   }
 };
 


Index: include/clang/Lex/HeaderSearchOptions.h
===
--- include/clang/Lex/HeaderSearchOptions.h
+++ include/clang/Lex/HeaderSearchOptions.h
@@ -203,34 +203,35 @@
 
   unsigned ModulesHashContent : 1;
 
-  HeaderSearchOptions(StringRef _Sysroot = "/")
-  : Sysroot(_Sysroot), ModuleFormat("raw"), DisableModuleHash(false),
-ImplicitModuleMaps(false), ModuleMapFileHomeIsCwd(false),
-UseBuiltinIncludes(true), UseStandardSystemIncludes(true),
-UseStandardCXXIncludes(true), UseLibcxx(false), Verbose(false),
+  HeaderSearchOptions(std::string _Sysroot = "/")
+  : Sysroot(std::move(_Sysroot)), ModuleFormat("raw"),
+DisableModuleHash(false), ImplicitModuleMaps(false),
+ModuleMapFileHomeIsCwd(false), UseBuiltinIncludes(true),
+UseStandardSystemIncludes(true), UseStandardCXXIncludes(true),
+UseLibcxx(false), Verbose(false),
 ModulesValidateOncePerBuildSession(false),
 ModulesValidateSystemHeaders(false), UseDebugInfo(false),
 ModulesValidateDiagnosticOptions(true), ModulesHashContent(false) {}
 
   /// AddPath - Add the \p Path path to the specified \p Group list.
-  void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
+  void AddPath(std::string Path, frontend::IncludeDirGroup Group,
bool IsFramework, bool IgnoreSysRoot) {
-UserEntries.emplace_back(Path, Group, IsFramework, IgnoreSysRoot);
+UserEntries.emplace_back(std::move(Path), Group, IsFramework, IgnoreSysRoot);
   }
 
   /// AddSystemHeaderPrefix - Override whether \#include directives naming a
   /// path starting with \p Prefix should be considered as naming a system
   /// header.
-  void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
-SystemHeaderPrefixes.emplace_back(Prefix, IsSystemHeader);
+  void AddSystemHeaderPrefix(std::string Prefix, bool IsSystemHeader) {
+SystemHeaderPrefixes.emplace_back(std::move(Prefix), IsSystemHeader);
   }
 
-  void AddVFSOverlayFile(StringRef Name) {
-VFSOverlayFiles.push_back(Name);
+  void AddVFSOverlayFile(std::strin

[PATCH] D44640: [CodeGen] Add funclet token to ARC marker

2018-03-19 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC327892: [CodeGen] Add funclet token to ARC marker (authored 
by smeenai, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44640?vs=138973&id=138983#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44640

Files:
  lib/CodeGen/CGObjC.cpp
  test/CodeGenObjCXX/arc-marker-funclet.mm


Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -2034,7 +2034,7 @@
 
   // Call the marker asm if we made one, which we do only at -O0.
   if (marker)
-CGF.Builder.CreateCall(marker);
+CGF.Builder.CreateCall(marker, None, CGF.getBundlesForFunclet(marker));
 }
 
 /// Retain the given object which is the result of a function call.
Index: test/CodeGenObjCXX/arc-marker-funclet.mm
===
--- test/CodeGenObjCXX/arc-marker-funclet.mm
+++ test/CodeGenObjCXX/arc-marker-funclet.mm
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fobjc-runtime=ios-6.0 
-fobjc-arc \
+// RUN:   -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s
+
+id f();
+void g() {
+  try {
+f();
+  } catch (...) {
+f();
+  }
+}
+
+// CHECK: call i8* @"?f@@YAPAUobjc_object@@XZ"() [ "funclet"(token %1) ]
+// CHECK-NEXT: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""() [ 
"funclet"(token %1) ]
+
+// The corresponding f() call was invoked from the entry basic block.
+// CHECK: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""(){{$}}


Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -2034,7 +2034,7 @@
 
   // Call the marker asm if we made one, which we do only at -O0.
   if (marker)
-CGF.Builder.CreateCall(marker);
+CGF.Builder.CreateCall(marker, None, CGF.getBundlesForFunclet(marker));
 }
 
 /// Retain the given object which is the result of a function call.
Index: test/CodeGenObjCXX/arc-marker-funclet.mm
===
--- test/CodeGenObjCXX/arc-marker-funclet.mm
+++ test/CodeGenObjCXX/arc-marker-funclet.mm
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fobjc-runtime=ios-6.0 -fobjc-arc \
+// RUN:   -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s
+
+id f();
+void g() {
+  try {
+f();
+  } catch (...) {
+f();
+  }
+}
+
+// CHECK: call i8* @"?f@@YAPAUobjc_object@@XZ"() [ "funclet"(token %1) ]
+// CHECK-NEXT: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""() [ "funclet"(token %1) ]
+
+// The corresponding f() call was invoked from the entry basic block.
+// CHECK: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""(){{$}}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44640: [CodeGen] Add funclet token to ARC marker

2018-03-19 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL327892: [CodeGen] Add funclet token to ARC marker (authored 
by smeenai, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44640?vs=138973&id=138984#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44640

Files:
  cfe/trunk/lib/CodeGen/CGObjC.cpp
  cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm


Index: cfe/trunk/lib/CodeGen/CGObjC.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjC.cpp
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp
@@ -2034,7 +2034,7 @@
 
   // Call the marker asm if we made one, which we do only at -O0.
   if (marker)
-CGF.Builder.CreateCall(marker);
+CGF.Builder.CreateCall(marker, None, CGF.getBundlesForFunclet(marker));
 }
 
 /// Retain the given object which is the result of a function call.
Index: cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm
===
--- cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm
+++ cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fobjc-runtime=ios-6.0 
-fobjc-arc \
+// RUN:   -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s
+
+id f();
+void g() {
+  try {
+f();
+  } catch (...) {
+f();
+  }
+}
+
+// CHECK: call i8* @"?f@@YAPAUobjc_object@@XZ"() [ "funclet"(token %1) ]
+// CHECK-NEXT: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""() [ 
"funclet"(token %1) ]
+
+// The corresponding f() call was invoked from the entry basic block.
+// CHECK: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""(){{$}}


Index: cfe/trunk/lib/CodeGen/CGObjC.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjC.cpp
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp
@@ -2034,7 +2034,7 @@
 
   // Call the marker asm if we made one, which we do only at -O0.
   if (marker)
-CGF.Builder.CreateCall(marker);
+CGF.Builder.CreateCall(marker, None, CGF.getBundlesForFunclet(marker));
 }
 
 /// Retain the given object which is the result of a function call.
Index: cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm
===
--- cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm
+++ cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fobjc-runtime=ios-6.0 -fobjc-arc \
+// RUN:   -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s
+
+id f();
+void g() {
+  try {
+f();
+  } catch (...) {
+f();
+  }
+}
+
+// CHECK: call i8* @"?f@@YAPAUobjc_object@@XZ"() [ "funclet"(token %1) ]
+// CHECK-NEXT: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""() [ "funclet"(token %1) ]
+
+// The corresponding f() call was invoked from the entry basic block.
+// CHECK: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""(){{$}}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44630: [ms] Parse #pragma optimize and ignore it behind its own flag

2018-03-19 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.

Awesome, thanks! One nit below:




Comment at: include/clang/Basic/DiagnosticParseKinds.td:973
+def warn_pragma_optimize : Warning<
+  "'#pragma optimize' is not supported; use '#pragma clang optimize on|off' 
instead">,
+  InGroup;

Is `pragma clang optimize` really what we want to recommend here? `pragma 
optimize` is used in practice mostly to work around cl.exe compiler bugs, or to 
disable inlining. In neither case, `pragma clang optimize` is what you'd really 
want to use. Maybe just omit everything after ; and instead add a blurb about 
this in DiagnosticDocs.td ?


https://reviews.llvm.org/D44630



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


[PATCH] D43494: [Modules] Fix creating fake definition data for lambdas.

2018-03-19 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

I think we have agreement on this change. If there are no objections, I plan to 
commit it on Wednesday, March 21.


https://reviews.llvm.org/D43494



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


[PATCH] D44645: [test] Fix Cross-DSO CFI Android sanitizer test for -rtlib=compiler-rt

2018-03-19 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added a reviewer: eugenis.
Herald added subscribers: dberris, srhines.
mgorny added inline comments.



Comment at: test/Driver/sanitizer-ld.c:517
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"
 // CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.
 

(an alternative would be to replace this 'NOT' clause with more specific 
library name — but I don't know which library could 'accidentally' appear here)


Fix the CHECK-CFI-CROSS-DSO-ANDROID test to force -rtlib=libgcc.
Otherwise, if clang is built with CLANG_DEFAULT_RTLIB=compiler-rt,
the clang_rt.builtins library gets added to the command-line and causes
the 'clang_rt.' substring to unexpectedly match.


Repository:
  rC Clang

https://reviews.llvm.org/D44645

Files:
  test/Driver/sanitizer-ld.c


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -510,7 +510,7 @@
 
 // Cross-DSO CFI on Android does not link runtime libraries.
 // RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \
-// RUN: -target aarch64-linux-android -fuse-ld=ld \
+// RUN: -target aarch64-linux-android -fuse-ld=ld -rtlib=libgcc \
 // RUN: --sysroot=%S/Inputs/basic_android_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-ANDROID %s
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -510,7 +510,7 @@
 
 // Cross-DSO CFI on Android does not link runtime libraries.
 // RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \
-// RUN: -target aarch64-linux-android -fuse-ld=ld \
+// RUN: -target aarch64-linux-android -fuse-ld=ld -rtlib=libgcc \
 // RUN: --sysroot=%S/Inputs/basic_android_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-ANDROID %s
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44645: [test] Fix Cross-DSO CFI Android sanitizer test for -rtlib=compiler-rt

2018-03-19 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: test/Driver/sanitizer-ld.c:517
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"
 // CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.
 

(an alternative would be to replace this 'NOT' clause with more specific 
library name — but I don't know which library could 'accidentally' appear here)


Repository:
  rC Clang

https://reviews.llvm.org/D44645



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


[PATCH] D44646: Sema: in msvc compatibility mode, don't allow forceinline on variadics

2018-03-19 Thread Dustin L. Howett via Phabricator via cfe-commits
DHowett-MSFT created this revision.
DHowett-MSFT added reviewers: rnk, majnemer.
DHowett-MSFT added a project: clang.
Herald added subscribers: cfe-commits, eraman.

The MSVC compiler rejects `__forceinline` on variadic functions with the 
following warning (at /https://reviews.llvm.org/W4):

  C4714: function 'void msvc_variadic(int,...)' marked as __forceinline not 
inlined

This fixes a bug in LLVM where a variadic was getting inlined into a function 
of calling convention x86_thiscallcc. The LLVM lowering passes cannot consume 
an `@llvm.va_start` intrinsic call in a thiscall function without emitting an 
assertion.

Inlining variadics should almost certainly be possible; however, this is a fix 
to bring Clang in line with MSVC.


Repository:
  rC Clang

https://reviews.llvm.org/D44646

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/ms-forceinline-on-variadic.cpp


Index: test/Sema/ms-forceinline-on-variadic.cpp
===
--- /dev/null
+++ test/Sema/ms-forceinline-on-variadic.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple i686-windows -verify 
-fms-extensions %s \
+// RUN:| FileCheck %s
+//
+// (instruction scheduling crash test)
+// RUN: %clang_cc1 -S -o - -triple i686-windows -fms-extensions %s
+
+inline __attribute__((always_inline)) void attribute_variadic(int f, ...) { } 
// expected-warning {{inlining attribute 'always_inline' ignored on variadic 
function}}
+
+__forceinline inline void msvc_variadic(int f, ...) { // expected-warning 
{{inlining attribute '__forceinline' ignored on variadic function}}
+// CHECK-DAG: define {{.*}} void [[MSVC_VARIADIC:@".*msvc_variadic.*"]](
+__builtin_va_list ap;
+__builtin_va_start(ap, f);
+__builtin_va_end(ap);
+}
+
+struct a {
+// members are, by default, thiscall; enforce it for the purposes of the 
test
+void __thiscall dispatcher();
+};
+
+void __thiscall a::dispatcher() {
+msvc_variadic(1, 2, 3);
+// CHECK-DAG: define dso_local x86_thiscallcc void @"{{.*dispatcher.*}}"(
+// CHECK-DAG: call void {{.*}} [[MSVC_VARIADIC]]
+}
+
+void t() {
+a{}.dispatcher();
+}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3886,6 +3886,12 @@
 return nullptr;
   }
 
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft()
+ && hasFunctionProto(D) && isFunctionOrMethodVariadic(D)) {
+Diag(Range.getBegin(), diag::warn_always_inline_on_variadic) << Ident;
+return nullptr;
+  }
+
   if (D->hasAttr())
 return nullptr;
 
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2694,6 +2694,9 @@
 def warn_attribute_after_definition_ignored : Warning<
   "attribute %0 after definition is ignored">,
InGroup;
+def warn_always_inline_on_variadic : Warning<
+  "inlining attribute %0 ignored on variadic function">,
+   InGroup;
 def warn_unknown_attribute_ignored : Warning<
   "unknown attribute %0 ignored">, InGroup;
 def warn_cxx11_gnu_attribute_on_type : Warning<


Index: test/Sema/ms-forceinline-on-variadic.cpp
===
--- /dev/null
+++ test/Sema/ms-forceinline-on-variadic.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple i686-windows -verify -fms-extensions %s \
+// RUN:| FileCheck %s
+//
+// (instruction scheduling crash test)
+// RUN: %clang_cc1 -S -o - -triple i686-windows -fms-extensions %s
+
+inline __attribute__((always_inline)) void attribute_variadic(int f, ...) { } // expected-warning {{inlining attribute 'always_inline' ignored on variadic function}}
+
+__forceinline inline void msvc_variadic(int f, ...) { // expected-warning {{inlining attribute '__forceinline' ignored on variadic function}}
+// CHECK-DAG: define {{.*}} void [[MSVC_VARIADIC:@".*msvc_variadic.*"]](
+__builtin_va_list ap;
+__builtin_va_start(ap, f);
+__builtin_va_end(ap);
+}
+
+struct a {
+// members are, by default, thiscall; enforce it for the purposes of the test
+void __thiscall dispatcher();
+};
+
+void __thiscall a::dispatcher() {
+msvc_variadic(1, 2, 3);
+// CHECK-DAG: define dso_local x86_thiscallcc void @"{{.*dispatcher.*}}"(
+// CHECK-DAG: call void {{.*}} [[MSVC_VARIADIC]]
+}
+
+void t() {
+a{}.dispatcher();
+}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3886,6 +3886,12 @@
 return nullptr;
   }
 
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft()
+ && hasFunctionProto(D) && isFunctionOrMethodVariadic(D)) {
+Diag(Range.getBegin(), diag::warn_always_inline_on_variadic) << Ident;
+return nullptr

[PATCH] D44646: Sema: in msvc compatibility mode, don't allow forceinline on variadics

2018-03-19 Thread Dustin L. Howett via Phabricator via cfe-commits
DHowett-MSFT added a comment.

Apologies if I've chosen the wrong set of reviewers.


Repository:
  rC Clang

https://reviews.llvm.org/D44646



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


Re: [clang-tools-extra] r327833 - [clang-tidy] New check bugprone-unused-return-value

2018-03-19 Thread Galina Kistanova via cfe-commits
Hello Alexander,

This commit broke at least two of our builders:

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/26909
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast

. . .
Failing Tests (1):
Clang Tools :: clang-tidy/bugprone-unused-return-value.cpp

Please have a look?

It is not good idea to keep the bot red for too long. This hides new
problem which later hard to track down.

Thanks

Galina

On Mon, Mar 19, 2018 at 6:02 AM, Alexander Kornienko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: alexfh
> Date: Mon Mar 19 06:02:32 2018
> New Revision: 327833
>
> URL: http://llvm.org/viewvc/llvm-project?rev=327833&view=rev
> Log:
> [clang-tidy] New check bugprone-unused-return-value
>
> Summary:
> Detects function calls where the return value is unused.
>
> Checked functions can be configured.
>
> Reviewers: alexfh, aaron.ballman, ilya-biryukov, hokein
>
> Reviewed By: alexfh, aaron.ballman
>
> Subscribers: hintonda, JonasToth, Eugene.Zelenko, mgorny, xazax.hun,
> cfe-commits
>
> Tags: #clang-tools-extra
>
> Patch by Kalle Huttunen!
>
> Differential Revision: https://reviews.llvm.org/D41655
>
> Added:
> clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
> clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.h
> clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-
> unused-return-value.rst
> clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-
> return-value-custom.cpp
> clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-
> return-value.cpp
> Modified:
> clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
> clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
> clang-tools-extra/trunk/docs/ReleaseNotes.rst
> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>
> Modified: clang-tools-extra/trunk/clang-tidy/bugprone/
> BugproneTidyModule.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/bugprone/BugproneTidyModule.cpp?rev=
> 327833&r1=327832&r2=327833&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
> Mon Mar 19 06:02:32 2018
> @@ -43,6 +43,7 @@
>  #include "UndefinedMemoryManipulationCheck.h"
>  #include "UndelegatedConstructorCheck.h"
>  #include "UnusedRaiiCheck.h"
> +#include "UnusedReturnValueCheck.h"
>  #include "UseAfterMoveCheck.h"
>  #include "VirtualNearMissCheck.h"
>
> @@ -119,6 +120,8 @@ public:
>  "bugprone-undelegated-constructor");
>  CheckFactories.registerCheck(
>  "bugprone-unused-raii");
> +CheckFactories.registerCheck(
> +"bugprone-unused-return-value");
>  CheckFactories.registerCheck(
>  "bugprone-use-after-move");
>  CheckFactories.registerCheck(
>
> Modified: clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/bugprone/CMakeLists.txt?rev=327833&r1=
> 327832&r2=327833&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt (original)
> +++ clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt Mon Mar 19
> 06:02:32 2018
> @@ -35,6 +35,7 @@ add_clang_library(clangTidyBugproneModul
>UndefinedMemoryManipulationCheck.cpp
>UndelegatedConstructorCheck.cpp
>UnusedRaiiCheck.cpp
> +  UnusedReturnValueCheck.cpp
>UseAfterMoveCheck.cpp
>VirtualNearMissCheck.cpp
>
>
> Added: clang-tools-extra/trunk/clang-tidy/bugprone/
> UnusedReturnValueCheck.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp?rev=327833&view=auto
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
> (added)
> +++ clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
> Mon Mar 19 06:02:32 2018
> @@ -0,0 +1,82 @@
> +//===--- UnusedReturnValueCheck.cpp - clang-tidy
> ---===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open Source
> +// License. See LICENSE.TXT for details.
> +//
> +//===--
> ===//
> +
> +#include "UnusedReturnValueCheck.h"
> +#include "../utils/OptionsUtils.h"
> +#include "clang/AST/ASTContext.h"
> +#include "clang/ASTMatchers/ASTMatchFinder.h"
> +
> +using namespace clang::ast_matchers;
> +using namespace clang::ast_matchers::internal;
> +
> +namespace clang {
> +namespace tidy {
> +namespace bugprone {
> +
> +UnusedReturnValueCheck::UnusedReturnValueChec

[PATCH] D44646: Sema: in msvc compatibility mode, don't allow forceinline on variadics

2018-03-19 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a reviewer: compnerd.
smeenai added a comment.

@DHowett-MSFT the reviewers look fine to me. Reid is the code owner for clang's 
MSVC compat support. David doesn't work on this stuff directly anymore, I 
think, but he's still pretty active in code reviews for it. I'm adding Saleem, 
who's also pretty active on Windows stuff.




Comment at: lib/Sema/SemaDeclAttr.cpp:3890
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft()
+ && hasFunctionProto(D) && isFunctionOrMethodVariadic(D)) {
+Diag(Range.getBegin(), diag::warn_always_inline_on_variadic) << Ident;

The formatting here looks off (it doesn't look clang-formatted).


Repository:
  rC Clang

https://reviews.llvm.org/D44646



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


[PATCH] D44435: Add the module name to __cuda_module_ctor and __cuda_module_dtor for unique function names

2018-03-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: unittests/CodeGen/IncrementalProcessingTest.cpp:176-178
+
+// In CUDA incremental processing, a CUDA ctor or dtor will be generated for 
+// every statement if a fatbinary file exists.

SimeonEhrig wrote:
> tra wrote:
> > SimeonEhrig wrote:
> > > tra wrote:
> > > > SimeonEhrig wrote:
> > > > > tra wrote:
> > > > > > I don't understand the comment. What is 'CUDA incremental 
> > > > > > processing' and what exactly is meant by 'statement' here? I'd 
> > > > > > appreciate if you could give me more details. My understanding is 
> > > > > > that ctor/dtor are generated once per TU. I suspect "incremental 
> > > > > > processing" may change that, but I have no idea what exactly does 
> > > > > > it do.
> > > > > A CUDA ctor/dtor will generates for every llvm::module. The TU can 
> > > > > also composed of many modules. In our interpreter, we add new code to 
> > > > > our AST with new modules at runtime. 
> > > > > The ctor/dtor generation is depend on the fatbinary code. The CodeGen 
> > > > > checks, if a path to a fatbinary file is set. If it is, it generates 
> > > > > an ctor with at least a __cudaRegisterFatBinary() function call. So, 
> > > > > the generation is independent of the source code in the module and we 
> > > > > can use every statement. A statement can be an expression, a 
> > > > > declaration, a definition and so one.   
> > > > I still don't understand how it's going to work. Do you have some sort 
> > > > of design document outlining how the interpreter is going to work with 
> > > > CUDA?
> > > > 
> > > > The purpose of the ctor/dtor is to stitch together host-side kernel 
> > > > launch with the GPU-side kernel binary which resides in the GPU binary 
> > > > created by device-side compilation. 
> > > > 
> > > > So, the question #1 -- if you pass GPU-side binary to the compiler, 
> > > > where did you get it? Normally it's the result of device-side 
> > > > compilation of the same TU. In your case it's not quite clear what 
> > > > exactly would that be, if you feed the source to the compiler 
> > > > incrementally. I.e. do you somehow recompile everything we've seen on 
> > > > device side so far for each new chunk of host-side source you feed to 
> > > > the compiler? 
> > > > 
> > > > Next question is -- assuming that device side does have correct 
> > > > GPU-side binary, when do you call those ctors/dtors? JIT model does not 
> > > > quite fit the assumptions that drive regular CUDA compilation.
> > > > 
> > > > Let's consider this:
> > > > ```
> > > > __global__ void foo();
> > > > __global__ void bar();
> > > > 
> > > > // If that's all we've  fed to compiler so far, we have no GPU code 
> > > > yet, so there 
> > > > // should be no fatbin file. If we do have it, what's in it?
> > > > 
> > > > void launch() {
> > > >   foo<<<1,1>>>();
> > > >   bar<<<1,1>>>();
> > > > }
> > > > // If you've generated ctors/dtors at this point they would be 
> > > > // useless as no GPU code exists in the preceding code.
> > > > 
> > > > __global__ void foo() {}
> > > > // Now we'd have some GPU code, but how can we need to retrofit it into 
> > > > // all the ctors/dtors we've generated before. 
> > > > __global__ void bar() {}
> > > > // Does bar end up in its own fatbinary? Or is it combined into a new 
> > > > // fatbin which contains both boo and bar?
> > > > // If it's a new fatbin, you somehow need to update existing 
> > > > ctors/dtors, 
> > > > // unless you want to leak CUDA resources fast.
> > > > // If it's a separate fatbin, then you will need to at the very least 
> > > > change the way 
> > > > // ctors/dtors are generated by the 'launch' function, because now they 
> > > > need to 
> > > > // tie each kernel launch to a different fatbin.
> > > > 
> > > > ```
> > > > 
> > > > It looks to me that if you want to JIT CUDA code you will need to take 
> > > > over GPU-side kernel management.
> > > > ctors/dtors do that for full-TU compilation, but they rely on 
> > > > device-side code being compiled and available during host-side 
> > > > compilation. For JIT, the interpreter should be in charge of 
> > > > registering new kernels with the CUDA runtime and 
> > > > unregistering/unloading them when a kernel goes away. This makes 
> > > > ctors/dtors completely irrelevant.
> > > At the moment, there is no documentation, because we still develop the 
> > > feature. I try to describe how it works.
> > > 
> > > The device side compilation works with a second compiler (a normal 
> > > clang), which we start via syscall. In the interpreter, we check if the 
> > > input line is a kernel definition or a kernel launch. Then we write the 
> > > source code to a file and compile it with the clang to a PCH-file.  Then 
> > > the PCH-file will be compiled to PTX and then to a fatbin. If we add a 
> > > new kernel, we will send the source code with the existing PCH-file to 
> > > clang compiler. So we easy extend the AST and 

[PATCH] D39562: [CodeGen][ObjC] Fix an assertion failure caused by copy elision

2018-03-19 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Alright, LGTM.


https://reviews.llvm.org/D39562



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


[PATCH] D44646: Sema: in msvc compatibility mode, don't allow forceinline on variadics

2018-03-19 Thread Dustin L. Howett via Phabricator via cfe-commits
DHowett-MSFT updated this revision to Diff 138995.
DHowett-MSFT added a comment.

Fixed formatting.


Repository:
  rC Clang

https://reviews.llvm.org/D44646

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/ms-forceinline-on-variadic.cpp


Index: test/Sema/ms-forceinline-on-variadic.cpp
===
--- /dev/null
+++ test/Sema/ms-forceinline-on-variadic.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple i686-windows -verify 
-fms-extensions %s \
+// RUN:| FileCheck %s
+//
+// (instruction scheduling crash test)
+// RUN: %clang_cc1 -S -o - -triple i686-windows -fms-extensions %s
+
+inline __attribute__((always_inline)) void attribute_variadic(int f, ...) { } 
// expected-warning {{inlining attribute 'always_inline' ignored on variadic 
function}}
+
+__forceinline inline void msvc_variadic(int f, ...) { // expected-warning 
{{inlining attribute '__forceinline' ignored on variadic function}}
+// CHECK-DAG: define {{.*}} void [[MSVC_VARIADIC:@".*msvc_variadic.*"]](
+__builtin_va_list ap;
+__builtin_va_start(ap, f);
+__builtin_va_end(ap);
+}
+
+struct a {
+// members are, by default, thiscall; enforce it for the purposes of the 
test
+void __thiscall dispatcher();
+};
+
+void __thiscall a::dispatcher() {
+msvc_variadic(1, 2, 3);
+// CHECK-DAG: define dso_local x86_thiscallcc void @"{{.*dispatcher.*}}"(
+// CHECK-DAG: call void {{.*}} [[MSVC_VARIADIC]]
+}
+
+void t() {
+a{}.dispatcher();
+}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3886,6 +3886,12 @@
 return nullptr;
   }
 
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
+  hasFunctionProto(D) && isFunctionOrMethodVariadic(D)) {
+Diag(Range.getBegin(), diag::warn_always_inline_on_variadic) << Ident;
+return nullptr;
+  }
+
   if (D->hasAttr())
 return nullptr;
 
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2694,6 +2694,9 @@
 def warn_attribute_after_definition_ignored : Warning<
   "attribute %0 after definition is ignored">,
InGroup;
+def warn_always_inline_on_variadic : Warning<
+  "inlining attribute %0 ignored on variadic function">,
+   InGroup;
 def warn_unknown_attribute_ignored : Warning<
   "unknown attribute %0 ignored">, InGroup;
 def warn_cxx11_gnu_attribute_on_type : Warning<


Index: test/Sema/ms-forceinline-on-variadic.cpp
===
--- /dev/null
+++ test/Sema/ms-forceinline-on-variadic.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple i686-windows -verify -fms-extensions %s \
+// RUN:| FileCheck %s
+//
+// (instruction scheduling crash test)
+// RUN: %clang_cc1 -S -o - -triple i686-windows -fms-extensions %s
+
+inline __attribute__((always_inline)) void attribute_variadic(int f, ...) { } // expected-warning {{inlining attribute 'always_inline' ignored on variadic function}}
+
+__forceinline inline void msvc_variadic(int f, ...) { // expected-warning {{inlining attribute '__forceinline' ignored on variadic function}}
+// CHECK-DAG: define {{.*}} void [[MSVC_VARIADIC:@".*msvc_variadic.*"]](
+__builtin_va_list ap;
+__builtin_va_start(ap, f);
+__builtin_va_end(ap);
+}
+
+struct a {
+// members are, by default, thiscall; enforce it for the purposes of the test
+void __thiscall dispatcher();
+};
+
+void __thiscall a::dispatcher() {
+msvc_variadic(1, 2, 3);
+// CHECK-DAG: define dso_local x86_thiscallcc void @"{{.*dispatcher.*}}"(
+// CHECK-DAG: call void {{.*}} [[MSVC_VARIADIC]]
+}
+
+void t() {
+a{}.dispatcher();
+}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3886,6 +3886,12 @@
 return nullptr;
   }
 
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
+  hasFunctionProto(D) && isFunctionOrMethodVariadic(D)) {
+Diag(Range.getBegin(), diag::warn_always_inline_on_variadic) << Ident;
+return nullptr;
+  }
+
   if (D->hasAttr())
 return nullptr;
 
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2694,6 +2694,9 @@
 def warn_attribute_after_definition_ignored : Warning<
   "attribute %0 after definition is ignored">,
InGroup;
+def warn_always_inline_on_variadic : Warning<
+  "inlining attribute %0 ignored on variadic function">,
+   InGroup;
 def warn_unknown_attribute_ignored : Warning<
   "unknown attribute %0 ignored">, InGroup;
 def warn_cxx11_gnu_attribu

[PATCH] D44580: Sema: allow comparison between blocks & block-compatible objc types

2018-03-19 Thread Dustin L. Howett via Phabricator via cfe-commits
DHowett-MSFT updated this revision to Diff 138996.
DHowett-MSFT added a comment.

Ran `clang-format` over changed lines. Reuploaded diff with full context.


Repository:
  rC Clang

https://reviews.llvm.org/D44580

Files:
  lib/Sema/SemaExpr.cpp
  test/SemaObjC/block-compare.mm


Index: test/SemaObjC/block-compare.mm
===
--- /dev/null
+++ test/SemaObjC/block-compare.mm
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -S -o - -triple i686-windows -verify -fblocks \
+// RUN: -Wno-unused-comparison %s
+
+#pragma clang diagnostic ignored "-Wunused-comparison"
+
+#define nil ((id)nullptr)
+
+@protocol NSObject
+@end
+
+@protocol NSCopying
+@end
+
+@protocol OtherProtocol
+@end
+
+__attribute__((objc_root_class))
+@interface NSObject 
+@end
+
+__attribute__((objc_root_class))
+@interface Test
+@end
+
+int main() {
+  void (^block)() = ^{};
+  NSObject *object;
+  id qualifiedId;
+
+  id poorlyQualified1;
+  Test *objectOfWrongType;
+
+  block == nil;
+  block == object;
+  block == qualifiedId;
+
+  nil == block;
+  object == block;
+  qualifiedId == block;
+
+  // these are still not valid: blocks must be compared with id, NSObject*, or 
a protocol-qualified id
+  // conforming to NSCopying or NSObject.
+
+  block == poorlyQualified1; // expected-error {{invalid operands to binary 
expression ('void (^)()' and 'id')}}
+  block == objectOfWrongType; // expected-error {{invalid operands to binary 
expression ('void (^)()' and 'Test *')}}
+
+  poorlyQualified1 == block; // expected-error {{invalid operands to binary 
expression ('id' and 'void (^)()')}}
+  objectOfWrongType == block; // expected-error {{invalid operands to binary 
expression ('Test *' and 'void (^)()')}}
+
+  return 0;
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -10028,6 +10028,19 @@
 RHS = ImpCastExprToType(RHS.get(), LHSType, CK_BitCast);
   return ResultTy;
 }
+
+if (!IsRelational && LHSType->isBlockPointerType() &&
+RHSType->isBlockCompatibleObjCPointerType(Context)) {
+  LHS = ImpCastExprToType(LHS.get(), RHSType,
+  CK_BlockPointerToObjCPointerCast);
+  return ResultTy;
+} else if (!IsRelational &&
+   LHSType->isBlockCompatibleObjCPointerType(Context) &&
+   RHSType->isBlockPointerType()) {
+  RHS = ImpCastExprToType(RHS.get(), LHSType,
+  CK_BlockPointerToObjCPointerCast);
+  return ResultTy;
+}
   }
   if ((LHSType->isAnyPointerType() && RHSType->isIntegerType()) ||
   (LHSType->isIntegerType() && RHSType->isAnyPointerType())) {


Index: test/SemaObjC/block-compare.mm
===
--- /dev/null
+++ test/SemaObjC/block-compare.mm
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -S -o - -triple i686-windows -verify -fblocks \
+// RUN: -Wno-unused-comparison %s
+
+#pragma clang diagnostic ignored "-Wunused-comparison"
+
+#define nil ((id)nullptr)
+
+@protocol NSObject
+@end
+
+@protocol NSCopying
+@end
+
+@protocol OtherProtocol
+@end
+
+__attribute__((objc_root_class))
+@interface NSObject 
+@end
+
+__attribute__((objc_root_class))
+@interface Test
+@end
+
+int main() {
+  void (^block)() = ^{};
+  NSObject *object;
+  id qualifiedId;
+
+  id poorlyQualified1;
+  Test *objectOfWrongType;
+
+  block == nil;
+  block == object;
+  block == qualifiedId;
+
+  nil == block;
+  object == block;
+  qualifiedId == block;
+
+  // these are still not valid: blocks must be compared with id, NSObject*, or a protocol-qualified id
+  // conforming to NSCopying or NSObject.
+
+  block == poorlyQualified1; // expected-error {{invalid operands to binary expression ('void (^)()' and 'id')}}
+  block == objectOfWrongType; // expected-error {{invalid operands to binary expression ('void (^)()' and 'Test *')}}
+
+  poorlyQualified1 == block; // expected-error {{invalid operands to binary expression ('id' and 'void (^)()')}}
+  objectOfWrongType == block; // expected-error {{invalid operands to binary expression ('Test *' and 'void (^)()')}}
+
+  return 0;
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -10028,6 +10028,19 @@
 RHS = ImpCastExprToType(RHS.get(), LHSType, CK_BitCast);
   return ResultTy;
 }
+
+if (!IsRelational && LHSType->isBlockPointerType() &&
+RHSType->isBlockCompatibleObjCPointerType(Context)) {
+  LHS = ImpCastExprToType(LHS.get(), RHSType,
+  CK_BlockPointerToObjCPointerCast);
+  return ResultTy;
+} else if (!IsRelational &&
+   LHSType->isBlockCompatibleObjCPointerType(Context) &&
+   RHSType->isBlockPointerType()) {
+  RHS = ImpCastExprToType(RHS.get(), LHSType,
+  CK_B

[clang-tools-extra] r327901 - [clangd][nfc] Give name to a magic constant

2018-03-19 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Mar 19 13:26:15 2018
New Revision: 327901

URL: http://llvm.org/viewvc/llvm-project?rev=327901&view=rev
Log:
[clangd][nfc] Give name to a magic constant

Modified:
clang-tools-extra/trunk/clangd/index/Index.h

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=327901&r1=327900&r2=327901&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Mon Mar 19 13:26:15 2018
@@ -56,16 +56,18 @@ public:
   }
 
 private:
+  static constexpr unsigned HashByteLength = 20;
+
   friend llvm::hash_code hash_value(const SymbolID &ID) {
 // We already have a good hash, just return the first bytes.
-static_assert(sizeof(size_t) <= 20, "size_t longer than SHA1!");
+static_assert(sizeof(size_t) <= HashByteLength, "size_t longer than 
SHA1!");
 return *reinterpret_cast(ID.HashValue.data());
   }
   friend llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
const SymbolID &ID);
   friend void operator>>(llvm::StringRef Str, SymbolID &ID);
 
-  std::array HashValue;
+  std::array HashValue;
 };
 
 // Write SymbolID into the given stream. SymbolID is encoded as a 40-bytes


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


[clang-tools-extra] r327902 - [clangd] Fix undefined behavior due to misaligned type cast

2018-03-19 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Mar 19 13:26:18 2018
New Revision: 327902

URL: http://llvm.org/viewvc/llvm-project?rev=327902&view=rev
Log:
[clangd] Fix undefined behavior due to misaligned type cast

The current code was casting pointer to a misaligned type which is undefined 
behavior.
Found by compiling with Undefined Behavior Sanitizer and running tests 
(check-clang-tools).

Modified:
clang-tools-extra/trunk/clangd/index/Index.h

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=327902&r1=327901&r2=327902&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Mon Mar 19 13:26:18 2018
@@ -61,7 +61,9 @@ private:
   friend llvm::hash_code hash_value(const SymbolID &ID) {
 // We already have a good hash, just return the first bytes.
 static_assert(sizeof(size_t) <= HashByteLength, "size_t longer than 
SHA1!");
-return *reinterpret_cast(ID.HashValue.data());
+size_t Result;
+memcpy(&Result, ID.HashValue.data(), sizeof(size_t));
+return llvm::hash_code(Result);
   }
   friend llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
const SymbolID &ID);


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


[clang-tools-extra] r327885 - [clang-move] Fix move-used-helper-decls.cpp test.

2018-03-19 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Mon Mar 19 12:05:53 2018
New Revision: 327885

URL: http://llvm.org/viewvc/llvm-project?rev=327885&view=rev
Log:
[clang-move] Fix move-used-helper-decls.cpp test.

Modified:
clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp

Modified: clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp?rev=327885&r1=327884&r2=327885&view=diff
==
--- clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp Mon Mar 
19 12:05:53 2018
@@ -335,7 +335,6 @@
 // CHECK-NEW-H-NEXT: void Fun1();
 // CHECK-NEW-H-SAME: {{[[:space:]]}}
 // CHECK-NEW-H-NEXT: inline void Fun2() {}
-// CHECK-NEW-H-SAME: {{[[:space:]]}}
 // CHECK-NEW-H-NEXT: } // namespace a
 
 


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


  1   2   >