[PATCH] D52384: [Sema] Fix redeclaration contexts for enumerators in C

2018-09-27 Thread David Majnemer via Phabricator via cfe-commits
majnemer added inline comments.



Comment at: lib/AST/DeclBase.cpp:1711-1712
+  // contexts are always skipped.
+  while (SkipRecords ? Ctx->isTransparentContext() || Ctx->isRecord()
+ : Ctx->isTransparentContext())
 Ctx = Ctx->getParent();

Seems simpler as:
  while ((SkipRecords && Ctx->isRecord()) || Ctx->isTransparentContext())


https://reviews.llvm.org/D52384



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


r343293 - Handle dependent class template names in class template argument

2018-09-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Sep 27 20:18:53 2018
New Revision: 343293

URL: http://llvm.org/viewvc/llvm-project?rev=343293=rev
Log:
Handle dependent class template names in class template argument
deduction for new-expressions.

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

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=343293=343292=343293=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Thu Sep 27 20:18:53 2018
@@ -9155,8 +9155,11 @@ QualType Sema::DeduceTemplateSpecializat
   TSInfo->getType()->getContainedDeducedType());
   assert(DeducedTST && "not a deduced template specialization type");
 
-  // We can only perform deduction for class templates.
   auto TemplateName = DeducedTST->getTemplateName();
+  if (TemplateName.isDependent())
+return Context.DependentTy;
+
+  // We can only perform deduction for class templates.
   auto *Template =
   dyn_cast_or_null(TemplateName.getAsTemplateDecl());
   if (!Template) {

Modified: cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp?rev=343293=343292=343293=diff
==
--- cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp 
(original)
+++ cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp Thu Sep 
27 20:18:53 2018
@@ -307,6 +307,13 @@ namespace dependent {
   template int Var(int);
   template int Cast(int);
   template int New(int);
+
+  template typename Y> void test() {
+Y(0);
+new Y(0);
+Y y(0);
+  }
+  template void test();
 }
 
 namespace injected_class_name {


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


[PATCH] D52578: Thread safety analysis: Allow scoped releasing of capabilities

2018-09-27 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

Maybe you should have a look at the tests first. I thought about the semantics 
that I think you are suggesting, but then we could have code like:

  class SCOPED_LOCKABLE MutexLockUnlock {
  public:
MutexLockUnlock(Mutex *mu1, Mutex *mu2) EXCLUSIVE_UNLOCK_FUNCTION(mu1) 
EXCLUSIVE_LOCK_FUNCTION(mu2);
~MutexLockUnlock() /* what annotation do we use here? */;
  
void a() EXCLUSIVE_UNLOCK_FUNCTION();
void b() EXCLUSIVE_LOCK_FUNCTION();
  };

Then what do `a` and `b` do? Or do we not allow this pattern? It's not 
straightforward either way, which is why I wanted to talk my way out of this in 
the bug report. ;)




Comment at: lib/Analysis/ThreadSafety.cpp:893
 private:
-  SmallVector UnderlyingMutexes;
+  enum UnderlyingCapabilityKind {
+UCK_Acquired,  ///< Any kind of acquired capability.

delesley wrote:
> IMHO, it would make more sense to break this into two properties (or bits): 
> acquired/released and shared/exclusive. 
We don't use the information (shared/exclusive) for acquired locks, but we need 
two bits anyway, so why not.



Comment at: lib/Analysis/ThreadSafety.cpp:916
+for (const auto  : ShrdRel)
+  UnderlyingMutexes.emplace_back(M.sexpr(), UCK_ReleasedExclusive);
   }

delesley wrote:
> UCK_ReleasedShared?  (Shouldn't this have been caught by a test case?)
There is no test case for the shared variant yet. I'll add one.



Comment at: lib/Analysis/ThreadSafety.cpp:951
+}
   } else {
+// We're removing the underlying mutex. Warn on double unlocking.

delesley wrote:
> I find this very confusing.  A lock here unlocks the underlying mutex, and 
> vice versa.  At the very least, some methods need to be renamed, or maybe we 
> can have separate classes for ScopedLockable and ScopedUnlockable. 
I agree that it's confusing, but it follows what I think was the idea behind 
scoped capabilities: that they are also capabilities that can be 
acquired/released. Now since the scoped capability releases a mutex on 
construction (i.e. when it is acquired), it has to acquire the mutex when 
released. So the way it handles the released mutexes mirrors what happens on 
the scoped capability itself.

It's definitely not very intuitive, but I feel it's the most consistent variant 
with what we have already.

The nice thing about this is that it works pretty well with the existing 
semantics and allows constructs such as `MutexLockUnlock` (see the tests) that 
unlocks one mutex and locks another. Not sure if anyone needs this, but why not?



Comment at: lib/Analysis/ThreadSafety.cpp:992
+FSet.removeLock(FactMan, UnderCp);
+FSet.addLock(FactMan, std::move(UnderEntry));
+  }

delesley wrote:
> Shouldn't this be outside of the else?
If we don't find `UnderCp` anymore, the negation should be there already. But I 
can also keep it outside if you like.


Repository:
  rC Clang

https://reviews.llvm.org/D52578



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


[PATCH] D52400: Improve -Wshadow warnings with enumerators

2018-09-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: echristo.
aaron.ballman added a comment.

Ping?


https://reviews.llvm.org/D52400



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


[PATCH] D52384: [Sema] Fix redeclaration contexts for enumerators in C

2018-09-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: echristo.
aaron.ballman added a comment.

Ping?


https://reviews.llvm.org/D52384



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


[PATCH] D52395: Thread safety analysis: Require exclusive lock for passing by non-const reference

2018-09-27 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

I've thought about your concerns and the important thing is: I didn't actually 
test this on a larger code base. The change makes sense to me, but maybe I'm 
missing something. So maybe instead of pushing through further restrictions, I 
should focus on rolling out the analysis on our own messy code base. Maybe I'm 
going to see the false positives right there.

However, as messy as our code may be, it might be messy in different ways than 
Google's code. So I might not see the same issues. Then on the other hand, 
there might be (probably smaller) code bases which don't have a problem with 
stricter rules. So I think additional flags are probably not the worst idea, 
but we need to keep their number small.

> Second, there needs to be a thread-safety-variant of "const_cast" -- i.e. a 
> way to pass a reference to a function without triggering the warning.  That 
> may already be possible via clever use of our current annotations, or you may 
> have to fiddle with something, but it needs to appear in the test cases.

There is such a mechanism in the test suite. It uses that we don't check the 
arguments for functions annotated with `no_thread_safety_analysis`, introduced 
by r246806 :

  // Takes a reference to a guarded data member, and returns an unguarded
  // reference.
  template 
  inline const T& ts_unchecked_read(const T& v) NO_THREAD_SAFETY_ANALYSIS {
return v;
  }
  
  template 
  inline T& ts_unchecked_read(T& v) NO_THREAD_SAFETY_ANALYSIS {
return v;
  }


Repository:
  rC Clang

https://reviews.llvm.org/D52395



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


r343285 - [cxx2a] P0641R2: (Some) type mismatches on defaulted functions only

2018-09-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Sep 27 18:16:43 2018
New Revision: 343285

URL: http://llvm.org/viewvc/llvm-project?rev=343285=rev
Log:
[cxx2a] P0641R2: (Some) type mismatches on defaulted functions only
render the function deleted instead of rendering the program ill-formed.

This change also adds an enabled-by-default warning for the case where
an explicitly-defaulted special member function of a non-template class
is implicitly deleted by the type checking rules. (This fires either due
to this language change or due to pre-C++20 reasons for the member being
implicitly deleted). I've tested this on a large codebase and found only
bugs (where the program means something that's clearly different from
what the programmer intended), so this is enabled by default, but we
should revisit this if there are problems with this being enabled by
default.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CXX/class.derived/class.abstract/p16.cpp
cfe/trunk/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p1.cpp
cfe/trunk/test/CXX/drs/dr6xx.cpp
cfe/trunk/test/CXX/special/class.copy/p12-0x.cpp
cfe/trunk/test/CXX/special/class.copy/p23-cxx11.cpp
cfe/trunk/test/CXX/special/class.ctor/p5-0x.cpp
cfe/trunk/test/CXX/special/class.dtor/p5-0x.cpp
cfe/trunk/test/SemaCUDA/implicit-member-target.cu
cfe/trunk/test/SemaCXX/cxx0x-deleted-default-ctor.cpp
cfe/trunk/test/SemaCXX/cxx17-compat.cpp
cfe/trunk/test/SemaCXX/dr1301.cpp
cfe/trunk/test/SemaCXX/microsoft-dtor-lookup-cxx11.cpp
cfe/trunk/test/SemaTemplate/exception-spec-crash.cpp
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=343285=343284=343285=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Sep 27 18:16:43 
2018
@@ -7760,9 +7760,19 @@ def err_incorrect_defaulted_exception_sp
 def err_incorrect_defaulted_constexpr : Error<
   "defaulted definition of %sub{select_special_member_kind}0 "
   "is not constexpr">;
+def warn_defaulted_method_deleted : Warning<
+  "explicitly defaulted %sub{select_special_member_kind}0 is implicitly "
+  "deleted">, InGroup>;
 def err_out_of_line_default_deletes : Error<
   "defaulting this %sub{select_special_member_kind}0 "
   "would delete it after its first declaration">;
+def note_deleted_type_mismatch : Note<
+  "function is implicitly deleted because its declared type does not match "
+  "the type of an implicit %sub{select_special_member_kind}0">;
+def warn_cxx17_compat_defaulted_method_type_mismatch : Warning<
+  "explicitly defaulting this %sub{select_special_member_kind}0 with a type "
+  "different from the implicit type is incompatible with C++ standards before "
+  "C++2a">, InGroup, DefaultIgnore;
 def warn_vbase_moved_multiple_times : Warning<
   "defaulted move assignment operator of %0 will move assign virtual base "
   "class %1 multiple times">, InGroup>;

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=343285=343284=343285=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Sep 27 18:16:43 2018
@@ -6451,20 +6451,29 @@ void Sema::CheckExplicitlyDefaultedSpeci
   //copy operation can take a non-const reference) as an implicit
   //declaration, and
   // -- not have default arguments.
+  // C++2a changes the second bullet to instead delete the function if it's
+  // defaulted on its first declaration, unless it's "an assignment operator,
+  // and its return type differs or its parameter type is not a reference".
+  bool DeleteOnTypeMismatch = getLangOpts().CPlusPlus2a && First;
+  bool ShouldDeleteForTypeMismatch = false;
   unsigned ExpectedParams = 1;
   if (CSM == CXXDefaultConstructor || CSM == CXXDestructor)
 ExpectedParams = 0;
   if (MD->getNumParams() != ExpectedParams) {
-// This also checks for default arguments: a copy or move constructor with 
a
+// This checks for default arguments: a copy or move constructor with a
 // default argument is classified as a default constructor, and assignment
 // operations and destructors can't have default arguments.
 Diag(MD->getLocation(), diag::err_defaulted_special_member_params)
   << CSM << MD->getSourceRange();
 HadError = true;
   } else if (MD->isVariadic()) {
-Diag(MD->getLocation(), diag::err_defaulted_special_member_variadic)
-  << CSM << MD->getSourceRange();
-HadError = true;
+if (DeleteOnTypeMismatch)
+  ShouldDeleteForTypeMismatch = true;
+else {
+  

[PATCH] D50850: clang: Add triples support for MIPS r6

2018-09-27 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 167419.
Herald added a subscriber: dexonsmith.

https://reviews.llvm.org/D50850

Files:
  include/llvm/ADT/Triple.h
  lib/Support/Triple.cpp
  lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
  unittests/ADT/TripleTest.cpp

Index: unittests/ADT/TripleTest.cpp
===
--- unittests/ADT/TripleTest.cpp
+++ unittests/ADT/TripleTest.cpp
@@ -366,59 +366,163 @@
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::Linux, T.getOS());
   EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
   T = Triple("mips64el");
   EXPECT_EQ(Triple::mips64el, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
 
   T = Triple("mips64-unknown-linux-gnuabi64");
   EXPECT_EQ(Triple::mips64, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::Linux, T.getOS());
   EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
   T = Triple("mips64");
   EXPECT_EQ(Triple::mips64, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
+
+  T = Triple("mipsisa64r6el-unknown-linux-gnuabi64");
+  EXPECT_EQ(Triple::mips64el, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::Linux, T.getOS());
+  EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
+  EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
+  T = Triple("mips64r6el");
+  EXPECT_EQ(Triple::mips64el, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
+  EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
+  T = Triple("mipsisa64r6el");
+  EXPECT_EQ(Triple::mips64el, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
+  EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
+
+  T = Triple("mipsisa64r6-unknown-linux-gnuabi64");
+  EXPECT_EQ(Triple::mips64, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::Linux, T.getOS());
+  EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
+  EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
+  T = Triple("mips64r6");
+  EXPECT_EQ(Triple::mips64, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
+  EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
+  T = Triple("mipsisa64r6");
+  EXPECT_EQ(Triple::mips64, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
+  EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
 
   T = Triple("mips64el-unknown-linux-gnuabin32");
   EXPECT_EQ(Triple::mips64el, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::Linux, T.getOS());
   EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
   T = Triple("mipsn32el");
   EXPECT_EQ(Triple::mips64el, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
 
   T = Triple("mips64-unknown-linux-gnuabin32");
   EXPECT_EQ(Triple::mips64, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::Linux, T.getOS());
   EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
   T = Triple("mipsn32");
   EXPECT_EQ(Triple::mips64, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
+
+  T = Triple("mipsisa64r6el-unknown-linux-gnuabin32");
+  EXPECT_EQ(Triple::mips64el, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::Linux, T.getOS());
+  EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
+  EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
+  T = Triple("mipsn32r6el");
+  EXPECT_EQ(Triple::mips64el, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
+  EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
+
+  T = Triple("mipsisa64r6-unknown-linux-gnuabin32");
+  EXPECT_EQ(Triple::mips64, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::Linux, T.getOS());
+  EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
+  EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
+  T = Triple("mipsn32r6");
+  EXPECT_EQ(Triple::mips64, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
+  EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
 

[PATCH] D52586: [X86] Add the movbe instruction intrinsics from icc.

2018-09-27 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 167416.
craig.topper added a comment.

Add comment. Fix typo. Add preprocessor define checks to the various CPUs that 
have MOVBE


https://reviews.llvm.org/D52586

Files:
  lib/Basic/Targets/X86.cpp
  lib/Headers/immintrin.h
  test/CodeGen/movbe-builtins.c
  test/Preprocessor/predefined-arch-macros.c

Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -524,6 +524,7 @@
 // CHECK_CORE_AVX2_M32: #define __INVPCID__ 1
 // CHECK_CORE_AVX2_M32: #define __LZCNT__ 1
 // CHECK_CORE_AVX2_M32: #define __MMX__ 1
+// CHECK_CORE_AVX2_M32: #define __MOVBE__ 1
 // CHECK_CORE_AVX2_M32: #define __PCLMUL__ 1
 // CHECK_CORE_AVX2_M32: #define __POPCNT__ 1
 // CHECK_CORE_AVX2_M32: #define __RDRND__ 1
@@ -554,6 +555,7 @@
 // CHECK_CORE_AVX2_M64: #define __INVPCID__ 1
 // CHECK_CORE_AVX2_M64: #define __LZCNT__ 1
 // CHECK_CORE_AVX2_M64: #define __MMX__ 1
+// CHECK_CORE_AVX2_M64: #define __MOVBE__ 1
 // CHECK_CORE_AVX2_M64: #define __PCLMUL__ 1
 // CHECK_CORE_AVX2_M64: #define __POPCNT__ 1
 // CHECK_CORE_AVX2_M64: #define __RDRND__ 1
@@ -588,6 +590,7 @@
 // CHECK_BROADWELL_M32: #define __INVPCID__ 1
 // CHECK_BROADWELL_M32: #define __LZCNT__ 1
 // CHECK_BROADWELL_M32: #define __MMX__ 1
+// CHECK_BROADWELL_M32: #define __MOVBE__ 1
 // CHECK_BROADWELL_M32: #define __PCLMUL__ 1
 // CHECK_BROADWELL_M32: #define __POPCNT__ 1
 // CHECK_BROADWELL_M32: #define __PRFCHW__ 1
@@ -621,6 +624,7 @@
 // CHECK_BROADWELL_M64: #define __INVPCID__ 1
 // CHECK_BROADWELL_M64: #define __LZCNT__ 1
 // CHECK_BROADWELL_M64: #define __MMX__ 1
+// CHECK_BROADWELL_M64: #define __MOVBE__ 1
 // CHECK_BROADWELL_M64: #define __PCLMUL__ 1
 // CHECK_BROADWELL_M64: #define __POPCNT__ 1
 // CHECK_BROADWELL_M64: #define __PRFCHW__ 1
@@ -659,6 +663,7 @@
 // CHECK_SKL_M32: #define __INVPCID__ 1
 // CHECK_SKL_M32: #define __LZCNT__ 1
 // CHECK_SKL_M32: #define __MMX__ 1
+// CHECK_SKL_M32: #define __MOVBE__ 1
 // CHECK_SKL_M32: #define __MPX__ 1
 // CHECK_SKL_M32: #define __PCLMUL__ 1
 // CHECK_SKL_M32: #define __POPCNT__ 1
@@ -694,6 +699,7 @@
 // CHECK_SKL_M64: #define __INVPCID__ 1
 // CHECK_SKL_M64: #define __LZCNT__ 1
 // CHECK_SKL_M64: #define __MMX__ 1
+// CHECK_SKL_M64: #define __MOVBE__ 1
 // CHECK_SKL_M64: #define __MPX__ 1
 // CHECK_SKL_M64: #define __PCLMUL__ 1
 // CHECK_SKL_M64: #define __POPCNT__ 1
@@ -735,6 +741,7 @@
 // CHECK_KNL_M32: #define __FMA__ 1
 // CHECK_KNL_M32: #define __LZCNT__ 1
 // CHECK_KNL_M32: #define __MMX__ 1
+// CHECK_KNL_M32: #define __MOVBE__ 1
 // CHECK_KNL_M32: #define __PCLMUL__ 1
 // CHECK_KNL_M32: #define __POPCNT__ 1
 // CHECK_KNL_M32: #define __PREFETCHWT1__ 1
@@ -772,6 +779,7 @@
 // CHECK_KNL_M64: #define __FMA__ 1
 // CHECK_KNL_M64: #define __LZCNT__ 1
 // CHECK_KNL_M64: #define __MMX__ 1
+// CHECK_KNL_M64: #define __MOVBE__ 1
 // CHECK_KNL_M64: #define __PCLMUL__ 1
 // CHECK_KNL_M64: #define __POPCNT__ 1
 // CHECK_KNL_M64: #define __PREFETCHWT1__ 1
@@ -813,6 +821,7 @@
 // CHECK_KNM_M32: #define __FMA__ 1
 // CHECK_KNM_M32: #define __LZCNT__ 1
 // CHECK_KNM_M32: #define __MMX__ 1
+// CHECK_KNM_M32: #define __MOVBE__ 1
 // CHECK_KNM_M32: #define __PCLMUL__ 1
 // CHECK_KNM_M32: #define __POPCNT__ 1
 // CHECK_KNM_M32: #define __PREFETCHWT1__ 1
@@ -848,6 +857,7 @@
 // CHECK_KNM_M64: #define __FMA__ 1
 // CHECK_KNM_M64: #define __LZCNT__ 1
 // CHECK_KNM_M64: #define __MMX__ 1
+// CHECK_KNM_M64: #define __MOVBE__ 1
 // CHECK_KNM_M64: #define __PCLMUL__ 1
 // CHECK_KNM_M64: #define __POPCNT__ 1
 // CHECK_KNM_M64: #define __PREFETCHWT1__ 1
@@ -889,6 +899,7 @@
 // CHECK_SKX_M32: #define __INVPCID__ 1
 // CHECK_SKX_M32: #define __LZCNT__ 1
 // CHECK_SKX_M32: #define __MMX__ 1
+// CHECK_SKX_M32: #define __MOVBE__ 1
 // CHECK_SKX_M32: #define __MPX__ 1
 // CHECK_SKX_M32: #define __PCLMUL__ 1
 // CHECK_SKX_M32: #define __PKU__ 1
@@ -935,6 +946,7 @@
 // CHECK_SKX_M64: #define __INVPCID__ 1
 // CHECK_SKX_M64: #define __LZCNT__ 1
 // CHECK_SKX_M64: #define __MMX__ 1
+// CHECK_SKX_M64: #define __MOVBE__ 1
 // CHECK_SKX_M64: #define __MPX__ 1
 // CHECK_SKX_M64: #define __PCLMUL__ 1
 // CHECK_SKX_M64: #define __PKU__ 1
@@ -986,6 +998,7 @@
 // CHECK_CNL_M32: #define __INVPCID__ 1
 // CHECK_CNL_M32: #define __LZCNT__ 1
 // CHECK_CNL_M32: #define __MMX__ 1
+// CHECK_CNL_M32: #define __MOVBE__ 1
 // CHECK_CNL_M32: #define __MPX__ 1
 // CHECK_CNL_M32: #define __PCLMUL__ 1
 // CHECK_CNL_M32: #define __PKU__ 1
@@ -1035,6 +1048,7 @@
 // CHECK_CNL_M64: #define __INVPCID__ 1
 // CHECK_CNL_M64: #define __LZCNT__ 1
 // CHECK_CNL_M64: #define __MMX__ 1
+// CHECK_CNL_M64: #define __MOVBE__ 1
 // CHECK_CNL_M64: #define __MPX__ 1
 // CHECK_CNL_M64: #define __PCLMUL__ 1
 // CHECK_CNL_M64: #define __PKU__ 1
@@ -1090,6 +1104,7 @@
 // CHECK_ICL_M32: #define __INVPCID__ 1
 // CHECK_ICL_M32: #define __LZCNT__ 1
 // CHECK_ICL_M32: #define __MMX__ 1
+// 

[PATCH] D51714: CMake: Deprecate using llvm-config to detect llvm installation

2018-09-27 Thread Tom Stellard via Phabricator via cfe-commits
tstellar updated this revision to Diff 167413.
tstellar added a comment.

Use cmake's DEPRECATION message.


Repository:
  rC Clang

https://reviews.llvm.org/D51714

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -7,9 +7,14 @@
 
   # Rely on llvm-config.
   set(CONFIG_OUTPUT)
-  find_program(LLVM_CONFIG "llvm-config")
   if(LLVM_CONFIG)
+set (LLVM_CONFIG_FOUND 1)
 message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
+message(DEPRECATION "Using llvm-config to detect the LLVM installation is \
+  deprecated.  The installed cmake files should be used \
+  instead.  CMake should be able to detect your LLVM install \
+  automatically, but you can also use LLVM_DIR to specify \
+  the path containing LLVMConfig.cmake.")
 set(CONFIG_COMMAND ${LLVM_CONFIG}
   "--assertion-mode"
   "--bindir"
@@ -32,41 +37,51 @@
   message(STATUS "${CONFIG_COMMAND_STR}")
   message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
 endif()
-  else()
-message(FATAL_ERROR "llvm-config not found -- ${LLVM_CONFIG}")
+
+list(GET CONFIG_OUTPUT 0 ENABLE_ASSERTIONS)
+list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR)
+list(GET CONFIG_OUTPUT 2 LIBRARY_DIR)
+list(GET CONFIG_OUTPUT 3 INCLUDE_DIR)
+list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT)
+list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR)
+list(GET CONFIG_OUTPUT 6 LLVM_CONFIG_CMAKE_PATH)
+
+# Normalize LLVM_CMAKE_PATH. --cmakedir might contain backslashes.
+# CMake assumes slashes as PATH.
+file(TO_CMAKE_PATH ${LLVM_CONFIG_CMAKE_PATH} LLVM_CMAKE_PATH)
   endif()
 
-  list(GET CONFIG_OUTPUT 0 ENABLE_ASSERTIONS)
-  list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR)
-  list(GET CONFIG_OUTPUT 2 LIBRARY_DIR)
-  list(GET CONFIG_OUTPUT 3 INCLUDE_DIR)
-  list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT)
-  list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR)
-  list(GET CONFIG_OUTPUT 6 LLVM_CONFIG_CMAKE_PATH)
 
   if(NOT MSVC_IDE)
 set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
   CACHE BOOL "Enable assertions")
 # Assertions should follow llvm-config's.
 mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
   endif()
 
+  find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_PATH}")
+  list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
+
+  # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
+  # LLVM_CONFIG.
+  if (NOT LLVM_CONFIG_FOUND)
+# Pull values from LLVMConfig.cmake.  We can drop this once the llvm-config
+# path is removed.
+set(TOOLS_BINARY_DIR ${LLVM_TOOLS_BINARY_DIR})
+set(LIBRARY_DIR ${LLVM_LIBRARY_DIR})
+set(INCLUDE_DIR ${LLVM_INCLUDE_DIR})
+set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR})
+  endif()
+
   set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin")
   set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
   set(LLVM_MAIN_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
   set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
   set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
 
-  # Normalize LLVM_CMAKE_PATH. --cmakedir might contain backslashes.
-  # CMake assumes slashes as PATH.
-  file(TO_CMAKE_PATH ${LLVM_CONFIG_CMAKE_PATH} LLVM_CMAKE_PATH)
-
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
 NO_DEFAULT_PATH)
 
-  find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_PATH}")
-  list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
-
   # They are used as destination of target generators.
   set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
   set(LLVM_LIBRARY_OUTPUT_INTDIR 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -7,9 +7,14 @@
 
   # Rely on llvm-config.
   set(CONFIG_OUTPUT)
-  find_program(LLVM_CONFIG "llvm-config")
   if(LLVM_CONFIG)
+set (LLVM_CONFIG_FOUND 1)
 message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
+message(DEPRECATION "Using llvm-config to detect the LLVM installation is \
+  deprecated.  The installed cmake files should be used \
+  instead.  CMake should be able to detect your LLVM install \
+  automatically, but you can also use LLVM_DIR to specify \
+  the path containing LLVMConfig.cmake.")
 set(CONFIG_COMMAND ${LLVM_CONFIG}
   "--assertion-mode"
   "--bindir"
@@ -32,41 +37,51 @@
   message(STATUS "${CONFIG_COMMAND_STR}")
   message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
 endif()
-  else()
-message(FATAL_ERROR "llvm-config not found -- ${LLVM_CONFIG}")
+
+list(GET CONFIG_OUTPUT 0 ENABLE_ASSERTIONS)
+list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR)
+list(GET CONFIG_OUTPUT 2 LIBRARY_DIR)
+list(GET CONFIG_OUTPUT 3 INCLUDE_DIR)
+list(GET CONFIG_OUTPUT 4 

[PATCH] D30806: [nonnull] Teach Clang to attach the nonnull LLVM attribute to declarations and calls instead of just definitions, and then teach it to *not* attach such attributes even if the source c

2018-09-27 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

In https://reviews.llvm.org/D30806#1248575, @efriedma wrote:

> This was merged in https://reviews.llvm.org/rC298491 .


But it got reverted soon after due to miscompiles:
https://reviews.llvm.org/rL298695

And the functionality hasn't been reimplemented AFAICT.


https://reviews.llvm.org/D30806



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


Re: r342925 - P0962R1: only use the member form of 'begin' and 'end' in a range-based

2018-09-27 Thread Richard Smith via cfe-commits
Looks like you fixed this in r343150, thanks!

On Tue, 25 Sep 2018 at 10:49, Vitaly Buka via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/24083
>
> FAIL: Clang :: CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp (1692 of 13357)
>  TEST 'Clang :: 
> CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp' FAILED 
> Script:
> --
> : 'RUN: at line 1';   
> /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/clang -cc1 
> -internal-isystem 
> /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/lib/clang/8.0.0/include 
> -nostdsysteminc -std=c++11 -fsyntax-only -verify 
> /b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
> : 'RUN: at line 2';   
> /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/clang -cc1 
> -internal-isystem 
> /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/lib/clang/8.0.0/include 
> -nostdsysteminc -std=c++14 -fsyntax-only -verify 
> /b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
> : 'RUN: at line 3';   
> /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/clang -cc1 
> -internal-isystem 
> /b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/lib/clang/8.0.0/include 
> -nostdsysteminc -std=c++17 -fsyntax-only -verify 
> /b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
> --
> Exit Code: 1
>
> Command Output (stderr):
> --
> /b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/Sema/Lookup.h:185:19:
>  runtime error: load of value 32764, which is not a valid value for type 
> 'typename std::remove_reference::type' (aka 
> 'clang::LookupResult::AmbiguityKind')
> #0 0x49b97ec in clang::LookupResult::LookupResult(clang::LookupResult&&) 
> /b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/Sema/Lookup.h:185:19
> #1 0x49b8a2b in BuildNonArrayForRange(clang::Sema&, clang::Expr*, 
> clang::Expr*, clang::QualType, clang::VarDecl*, clang::VarDecl*, 
> clang::SourceLocation, clang::SourceLocation, clang::OverloadCandidateSet*, 
> clang::ActionResult*, clang::ActionResult true>*, (anonymous namespace)::BeginEndFunction*)::$_3::operator()((anonymous 
> namespace)::BeginEndFunction, clang::LookupResult&, 
> llvm::function_ref, 
> llvm::function_ref) const 
> /b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Sema/SemaStmt.cpp:2225:33
> #2 0x49a5ed0 in BuildNonArrayForRange 
> /b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Sema/SemaStmt.cpp
> #3 0x49a5ed0 in clang::Sema::BuildCXXForRangeStmt(clang::SourceLocation, 
> clang::SourceLocation, clang::SourceLocation, clang::Stmt*, clang::Stmt*, 
> clang::Stmt*, clang::Expr*, clang::Expr*, clang::Stmt*, 
> clang::SourceLocation, clang::Sema::BuildForRangeKind) 
> /b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Sema/SemaStmt.cpp:2497
> #4 0x49a49df in clang::Sema::ActOnCXXForRangeStmt(clang::Scope*, 
> clang::SourceLocation, clang::SourceLocation, clang::Stmt*, 
> clang::SourceLocation, clang::Expr*, clang::SourceLocation, 
> clang::Sema::BuildForRangeKind) 
> /b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Sema/SemaStmt.cpp:2122:10
> #5 0x41a3301 in clang::Parser::ParseForStatement(clang::SourceLocation*) 
> /b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseStmt.cpp:1762:28
> #6 0x419fe76 in 
> clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector  32u>&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*, 
> clang::Parser::ParsedAttributesWithRange&) 
> /b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseStmt.cpp:251:12
> #7 0x419f496 in 
> clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector 32u>&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*) 
> /b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseStmt.cpp:110:20
> #8 0x41a563b in clang::Parser::ParseCompoundStatementBody(bool) 
> /b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseStmt.cpp:997:11
> #9 0x41a61c8 in clang::Parser::ParseFunctionStatementBody(clang::Decl*, 
> clang::Parser::ParseScope&) 
> /b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseStmt.cpp:1971:21
> #10 0x410fde8 in 
> clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, 
> clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) 
> /b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:1246:10
> #11 0x412cc1c in clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, 
> clang::DeclaratorContext, clang::SourceLocation*, 
> clang::Parser::ForRangeInit*) 
> /b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:1968:11
> #12 0x410e9ab in 
> 

[PATCH] D52578: Thread safety analysis: Allow scoped releasing of capabilities

2018-09-27 Thread Delesley Hutchins via Phabricator via cfe-commits
delesley added inline comments.



Comment at: lib/Analysis/ThreadSafety.cpp:893
 private:
-  SmallVector UnderlyingMutexes;
+  enum UnderlyingCapabilityKind {
+UCK_Acquired,  ///< Any kind of acquired capability.

IMHO, it would make more sense to break this into two properties (or bits): 
acquired/released and shared/exclusive. 



Comment at: lib/Analysis/ThreadSafety.cpp:916
+for (const auto  : ShrdRel)
+  UnderlyingMutexes.emplace_back(M.sexpr(), UCK_ReleasedExclusive);
   }

UCK_ReleasedShared?  (Shouldn't this have been caught by a test case?)



Comment at: lib/Analysis/ThreadSafety.cpp:926
+  FactMan, CapabilityExpr(UnderlyingMutex.getPointer(), false));
+  if ((UnderlyingMutex.getInt() == UCK_Acquired) == (Entry != nullptr)) {
 // If this scoped lock manages another mutex, and if the underlying

This if statement makes my head hurt.  Can you find a different way of 
expressing it?



Comment at: lib/Analysis/ThreadSafety.cpp:951
+}
   } else {
+// We're removing the underlying mutex. Warn on double unlocking.

I find this very confusing.  A lock here unlocks the underlying mutex, and vice 
versa.  At the very least, some methods need to be renamed, or maybe we can 
have separate classes for ScopedLockable and ScopedUnlockable. 



Comment at: lib/Analysis/ThreadSafety.cpp:992
+FSet.removeLock(FactMan, UnderCp);
+FSet.addLock(FactMan, std::move(UnderEntry));
+  }

Shouldn't this be outside of the else?


Repository:
  rC Clang

https://reviews.llvm.org/D52578



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


r343279 - [cxx2a] P0624R2: Lambdas with no capture-default are

2018-09-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Sep 27 15:47:04 2018
New Revision: 343279

URL: http://llvm.org/viewvc/llvm-project?rev=343279=rev
Log:
[cxx2a] P0624R2: Lambdas with no capture-default are
default-constructible and assignable.

Added:
cfe/trunk/test/SemaCXX/cxx2a-lambda-default-ctor-assign.cpp
Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/cxx17-compat.cpp
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=343279=343278=343279=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Sep 27 15:47:04 2018
@@ -974,10 +974,7 @@ public:
   bool needsImplicitDefaultConstructor() const {
 return !data().UserDeclaredConstructor &&
!(data().DeclaredSpecialMembers & SMF_DefaultConstructor) &&
-   // C++14 [expr.prim.lambda]p20:
-   //   The closure type associated with a lambda-expression has no
-   //   default constructor.
-   !isLambda();
+   (!isLambda() || lambdaIsDefaultConstructibleAndAssignable());
   }
 
   /// Determine whether this class has any user-declared constructors.
@@ -1167,10 +1164,7 @@ public:
!hasUserDeclaredCopyAssignment() &&
!hasUserDeclaredMoveConstructor() &&
!hasUserDeclaredDestructor() &&
-   // C++1z [expr.prim.lambda]p21: "the closure type has a deleted copy
-   // assignment operator". The intent is that this counts as a user
-   // declared copy assignment, but we do not model it that way.
-   !isLambda();
+   (!isLambda() || lambdaIsDefaultConstructibleAndAssignable());
   }
 
   /// Determine whether we need to eagerly declare a move assignment
@@ -1210,6 +1204,10 @@ public:
   /// a template).
   bool isGenericLambda() const;
 
+  /// Determine whether this lambda should have an implicit default constructor
+  /// and copy and move assignment operators.
+  bool lambdaIsDefaultConstructibleAndAssignable() const;
+
   /// Retrieve the lambda call operator of the closure type
   /// if this is a closure type.
   CXXMethodDecl *getLambdaCallOperator() const;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=343279=343278=343279=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Sep 27 15:47:04 
2018
@@ -6633,6 +6633,11 @@ let CategoryName = "Lambda Issue" in {
 InGroup, DefaultIgnore;
   def note_deprecated_this_capture : Note<
 "add an explicit capture of 'this' to capture '*this' by reference">;
+
+  // C++2a default constructible / assignable lambdas.
+  def warn_cxx17_compat_lambda_def_ctor_assign : Warning<
+"%select{default construction|assignment}0 of lambda is incompatible with "
+"C++ standards before C++2a">, InGroup, DefaultIgnore;
 }
 
 def err_return_in_captured_stmt : Error<

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=343279=343278=343279=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Thu Sep 27 15:47:04 2018
@@ -628,6 +628,24 @@ bool CXXRecordDecl::hasSubobjectAtOffset
   return false;
 }
 
+bool CXXRecordDecl::lambdaIsDefaultConstructibleAndAssignable() const {
+  assert(isLambda() && "not a lambda");
+
+  // C++2a [expr.prim.lambda.capture]p11:
+  //   The closure type associated with a lambda-expression has no default
+  //   constructor if the lambda-expression has a lambda-capture and a
+  //   defaulted default constructor otherwise. It has a deleted copy
+  //   assignment operator if the lambda-expression has a lambda-capture and
+  //   defaulted copy and move assignment operators otherwise.
+  //
+  // C++17 [expr.prim.lambda]p21:
+  //   The closure type associated with a lambda-expression has no default
+  //   constructor and a deleted copy assignment operator.
+  if (getLambdaCaptureDefault() != LCD_None)
+return false;
+  return getASTContext().getLangOpts().CPlusPlus2a;
+}
+
 void CXXRecordDecl::addedMember(Decl *D) {
   if (!D->isImplicit() &&
   !isa(D) &&

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=343279=343278=343279=diff
==
--- 

[PATCH] D51714: CMake: Deprecate using llvm-config to detect llvm installation

2018-09-27 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

Is there anything holding this up?


Repository:
  rC Clang

https://reviews.llvm.org/D51714



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


r343276 - [analyzer] Hotfix for the bug in exploded graph printing

2018-09-27 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Sep 27 15:31:13 2018
New Revision: 343276

URL: http://llvm.org/viewvc/llvm-project?rev=343276=rev
Log:
[analyzer] Hotfix for the bug in exploded graph printing

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=343276=343275=343276=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Thu Sep 27 15:31:13 2018
@@ -2985,11 +2985,13 @@ struct DOTGraphTraits :
 }
 const ExplodedNode *OtherNode = FirstHiddenNode;
 while (true) {
+  PreCallback(OtherNode);
   if (Stop(OtherNode))
 return true;
 
   if (OtherNode == N)
 break;
+  PostCallback(OtherNode);
 
   OtherNode = *OtherNode->succ_begin();
 }


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


[PATCH] D52443: Thread safety analysis: Examine constructor arguments

2018-09-27 Thread Delesley Hutchins via Phabricator via cfe-commits
delesley added inline comments.



Comment at: lib/Analysis/ThreadSafety.cpp:2046
   const CXXConstructorDecl *D = Exp->getConstructor();
   if (D && D->isCopyConstructor()) {
 const Expr* Source = Exp->getArg(0);

As a side note, we should probably special-case the move constructor too, with 
AK_Written.  That should be in a separate patch, though, and needs to be 
sequestered under -Wthread-safety-beta, which is complicated.   


Repository:
  rC Clang

https://reviews.llvm.org/D52443



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


[PATCH] D52443: Thread safety analysis: Examine constructor arguments

2018-09-27 Thread Delesley Hutchins via Phabricator via cfe-commits
delesley added a comment.

This looks good, and resolves an outstanding bug that was on my list.   Thanks 
for the patch!




Comment at: lib/Analysis/ThreadSafety.cpp:1537
   void handleCall(const Expr *Exp, const NamedDecl *D, VarDecl *VD = nullptr);
+  void ExamineCallArguments(const FunctionDecl *FD,
+CallExpr::const_arg_iterator ArgBegin,

Nit: capitalization does not match other methods.


Repository:
  rC Clang

https://reviews.llvm.org/D52443



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


[PATCH] D52395: Thread safety analysis: Require exclusive lock for passing by non-const reference

2018-09-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D52395#1248608, @delesley wrote:

> With respect to data, I really think these patches should be tested against 
> Google's code base, because otherwise you're going to start seeing angry 
> rollbacks.  However, I don't work on the C++ team any more, and I don't have 
> time to do it.  When I was actively developing the analysis, I spent about 
> 90% of my time just running tests and fixing the code base.  Each incremental 
> improvement in the analysis itself was a hard upward slog.  If you're going 
> to be adding lots of improvements, we need to have someone at Google running 
> point.


Do you have a recommendation for who this point person could be? What do we do 
if we cannot find such a person? (I assume we won't halt progress on thread 
safety analysis and that propose->review->accept->commit->revert is not an 
acceptable workflow.)


Repository:
  rC Clang

https://reviews.llvm.org/D52395



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


[PATCH] D52395: Thread safety analysis: Require exclusive lock for passing by non-const reference

2018-09-27 Thread Delesley Hutchins via Phabricator via cfe-commits
delesley added a comment.

With respect to data, I really think these patches should be tested against 
Google's code base, because otherwise you're going to start seeing angry 
rollbacks.  However, I don't work on the C++ team any more, and I don't have 
time to do it.  When I was actively developing the analysis, I spent about 90% 
of my time just running tests and fixing the code base.  Each incremental 
improvement in the analysis itself was a hard upward slog.  If you're going to 
be adding lots of improvements, we need to have someone at Google running point.


Repository:
  rC Clang

https://reviews.llvm.org/D52395



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


[PATCH] D52395: Thread safety analysis: Require exclusive lock for passing by non-const reference

2018-09-27 Thread Delesley Hutchins via Phabricator via cfe-commits
delesley added a comment.

I have mixed feelings about this patch.  When you pass an object to a function, 
either by pointer or by reference, no actual load from memory has yet occurred. 
 Thus, there is a real risk of false positives; what you are saying is that the 
function *might* read or write from protected memory, not that it actually 
will.  In fact, the false positive rate is high enough that this particular 
warning is sequestered under -Wthread-safety-reference, and is not used with 
warnings-as-errors at Google.

In theory, the correct way to deal with references is to make GUARDED_BY an 
attribute of the type, rather than an attribute of the data member; that way 
taking the address of a member, or passing it by reference, wouldn't cast away 
the annotation.  But that would require a properly parametric dependent type 
system for C++, which is pretty much impossible.  So you're left with two bad 
options: either issue a warning eagerly, and deal with false positives, or 
suppress the warning, and deal with false negatives.  At Google, false 
positives usually break the build, which has forced me to prefer false 
negatives in most cases; my strategy has been to gradually tighten the analysis 
bit by bit.  Thankfully, that's less of a concern here.

Adding to the difficulty is the fact that the correct use of "const" in 
real-world C++ code is spotty at best.  There is LOTS of code that arguably 
should be using const, but doesn't for various reasons.  E.g. if program A 
calls library B, and library B forgot to provide const-qualified versions of a 
few methods, than A has to make a choice: either drop the const qualifier, or 
insert ugly const-casts, neither of which is pleasant.  In other-words, 
non-constness has a tendency to propagate through the code base, and you can't 
depend on "const" being accurate.

I have two recommendations.  First think the default behavior should be to 
require only a read-only lock, as it currently does.  That's a compromise 
between the "false-positive" and "false-negative" camps.  It catches a lot of 
errors, because you have to hold the lock in some way, but doesn't require 
accurate const-ness.  For people who want more accuracy, there should be a 
different variant of the warning -- maybe -Wthread-safety-reference-precise?  
Between beta/precise/reference etc. there are a now a lot of analysis options, 
and I would love to consolidate them in some fashion.  However, different code 
bases have different needs, and I think "one size fits all" is not really 
appropriate.

Second, there needs to be a thread-safety-variant of "const_cast" -- i.e. a way 
to pass a reference to a function without triggering the warning.  That may 
already be possible via clever use of our current annotations, or you may have 
to fiddle with something, but it needs to appear in the test cases.


Repository:
  rC Clang

https://reviews.llvm.org/D52395



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


[PATCH] D52443: Thread safety analysis: Examine constructor arguments

2018-09-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/Analysis/ThreadSafety.cpp:1970
+  // There can be default arguments, so we stop when one iterator is at end().
+  for (auto Arg = ArgBegin; Param != Params.end() && Arg != ArgEnd;
+   ++Param, ++Arg) {

aaronpuchert wrote:
> aaron.ballman wrote:
> > How should this interact with variadic functions? Either ones that use 
> > `...` with a C varargs function, or ones that use parameter packs in C++. 
> > (I realize this is basically existing code, but the question remains.)
> For instantiated variadic templates we match against the instantiation of the 
> template, so we can match the parameters just as for an ordinary function. My 
> understanding is that the thread safety analysis doesn't run over templates, 
> only instantiations, so that should be fine.
> 
> With C variadic arguments we should have a shorter parameter list, so we 
> don't check the matching variadic arguments. However, if I'm not mistakten, 
> the variadic arguments are passed by value, so the reference checks aren't 
> needed.
> 
> Maybe I can add some tests for these cases.
Good points -- we're likely fine here, but if we lack some test coverage for 
this, it'd be good to add some. If you find you need to add tests that wind up 
Just Working, feel free to commit them without review.


Repository:
  rC Clang

https://reviews.llvm.org/D52443



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


[PATCH] D30806: [nonnull] Teach Clang to attach the nonnull LLVM attribute to declarations and calls instead of just definitions, and then teach it to *not* attach such attributes even if the source c

2018-09-27 Thread Eli Friedman via Phabricator via cfe-commits
efriedma closed this revision.
efriedma added a comment.

This was merged in https://reviews.llvm.org/rC298491 .


https://reviews.llvm.org/D30806



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


[PATCH] D52443: Thread safety analysis: Examine constructor arguments

2018-09-27 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added inline comments.



Comment at: lib/Analysis/ThreadSafety.cpp:1970
+  // There can be default arguments, so we stop when one iterator is at end().
+  for (auto Arg = ArgBegin; Param != Params.end() && Arg != ArgEnd;
+   ++Param, ++Arg) {

aaron.ballman wrote:
> How should this interact with variadic functions? Either ones that use `...` 
> with a C varargs function, or ones that use parameter packs in C++. (I 
> realize this is basically existing code, but the question remains.)
For instantiated variadic templates we match against the instantiation of the 
template, so we can match the parameters just as for an ordinary function. My 
understanding is that the thread safety analysis doesn't run over templates, 
only instantiations, so that should be fine.

With C variadic arguments we should have a shorter parameter list, so we don't 
check the matching variadic arguments. However, if I'm not mistakten, the 
variadic arguments are passed by value, so the reference checks aren't needed.

Maybe I can add some tests for these cases.



Comment at: lib/Analysis/ThreadSafety.cpp:2050
+  } else {
+ExamineCallArguments(D, Exp->arg_begin(), Exp->arg_end(), false);
   }

aaron.ballman wrote:
> Can you add a comment for the bool argument? e.g., `/*OperatorFun*/false`
Depending on `OperatorFun`, we shift some of the iterators. We could also do 
that on the caller site. I'll see if that looks better.


Repository:
  rC Clang

https://reviews.llvm.org/D52443



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


[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 167400.
JonasToth added a comment.

- last cleanup for today, testing on clang/lib looks good, but is already very 
clean


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/IsolateDeclCheck.cpp
  clang-tidy/readability/IsolateDeclCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-isolate-decl.rst
  test/clang-tidy/readability-isolate-decl-cxx17.cpp
  test/clang-tidy/readability-isolate-decl-fixing.cpp
  test/clang-tidy/readability-isolate-decl.cpp

Index: test/clang-tidy/readability-isolate-decl.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-isolate-decl.cpp
@@ -0,0 +1,356 @@
+// RUN: %check_clang_tidy %s readability-isolate-decl %t
+
+void f() {
+  int i;
+}
+
+void f2() {
+  int i, j, *k, lala = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int j;
+  // CHECK-FIXES: {{^  }}int *k;
+  // CHECK-FIXES: {{^  }}int lala = 42;
+
+  int normal, weird = /* comment */ 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int normal;
+  // CHECK-FIXES: {{^  }}int weird = /* comment */ 42;
+  //
+  int /* here is a comment */ v1,
+  // another comment
+  v2 = 42 // Ok, more comments
+  ;
+  // CHECK-MESSAGES: [[@LINE-4]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int /* here is a comment */ v1;
+  // CHECK-FIXES: {{^  }}int /* here is a comment */ // another comment
+  // CHECK-FIXES: {{^  }}v2 = 42 // Ok, more comments
+  // CHECK-FIXES: {{^  }};
+}
+
+void f3() {
+  int i, *pointer1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int *pointer1;
+  //
+  int *pointer2 = nullptr, *pointer3 = 
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int *pointer2 = nullptr;
+  // CHECK-FIXES: {{^  }}int *pointer3 = 
+}
+
+void f4() {
+  double d = 42. /* foo */, z = 43., /* hi */ y, c /* */ /*  */, l = 2.;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: double d = 42. /* foo */;
+  // CHECK-FIXES: {{^  }}double z = 43.;
+  // CHECK-FIXES: {{^  }}double /* hi */ y;
+  // CHECK-FIXES: {{^  }}double c /* */ /*  */;
+  // CHECK-FIXES: {{^  }}double l = 2.;
+}
+
+struct SomeClass {
+  SomeClass() = default;
+  SomeClass(int value);
+};
+
+class Point {
+  double x;
+  double y;
+
+public:
+  Point(double x, double y) : x(x), y(y) {}
+};
+
+class Rectangle {
+  Point TopLeft;
+  Point BottomRight;
+
+public:
+  Rectangle(Point TopLeft, Point BottomRight) : TopLeft(TopLeft), BottomRight(BottomRight) {}
+};
+
+void f5() {
+  SomeClass v1, v2(42), v3{42}, v4(42.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: SomeClass v1;
+  // CHECK-FIXES: {{^  }}SomeClass v2(42);
+  // CHECK-FIXES: {{^  }}SomeClass v3{42};
+  // CHECK-FIXES: {{^  }}SomeClass v4(42.5);
+
+  SomeClass v5 = 42, *p1 = nullptr;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: SomeClass v5 = 42;
+  // CHECK-FIXES: {{^  }}SomeClass *p1 = nullptr;
+
+  Point P1(0., 2.), P2{2., 0.};
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: Point P1(0., 2.);
+  // CHECK-FIXES: {{^  }}Point P2{2., 0.};
+
+  Rectangle R1({0., 0.}, {1., -2.}), R2{{0., 1.}, {1., 0.}}, R3(P1, P2), R4{P1, P2};
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: Rectangle R1({0., 0.}, {1., -2.});
+  // CHECK-FIXES: {{^  }}Rectangle R2{{[{][{]}}0., 1.}, {1., 0.{{[}][}]}};
+  // CHECK-FIXES: {{^  }}Rectangle R3(P1, P2);
+  // CHECK-FIXES: {{^  }}Rectangle R4{P1, P2};
+}
+
+void f6() {
+  int array1[] = {1, 2, 3, 4}, array2[] = {1, 2, 3}, value1, value2 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int array1[] = {1, 2, 3, 4};
+  // CHECK-FIXES: {{^  }}int array2[] = {1, 2, 3};
+  // CHECK-FIXES: {{^  }}int value1;
+  // CHECK-FIXES: {{^  }}int value2 = 42;
+}
+
+template 
+struct TemplatedType {
+  TemplatedType() = default;
+  TemplatedType(T value);
+};
+
+void f7() {
+  TemplatedType TT1(42), 

[PATCH] D52586: [X86] Add the movbe instruction intrinsics from icc.

2018-09-27 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

The struct hack isn't obvious to me. Without that, we would produce a load with 
default alignment based on the size of the load (i132 -> align 4, etc)? But we 
want to force align 1 regardless of the load size, so the __packed__ attribute 
on the struct gets us that IIUC. What does __may_alias__ do?

Explain this in a code comment in the header to make this less tricky?




Comment at: lib/Headers/immintrin.h:359
+#endif
+#endif /* __MOVEBE */
+

MOVEBE -> MOVBE


https://reviews.llvm.org/D52586



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


[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 167397.
JonasToth added a comment.

- fix doc typo


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/IsolateDeclCheck.cpp
  clang-tidy/readability/IsolateDeclCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-isolate-decl.rst
  test/clang-tidy/readability-isolate-decl-cxx17.cpp
  test/clang-tidy/readability-isolate-decl-fixing.cpp
  test/clang-tidy/readability-isolate-decl.cpp

Index: test/clang-tidy/readability-isolate-decl.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-isolate-decl.cpp
@@ -0,0 +1,356 @@
+// RUN: %check_clang_tidy %s readability-isolate-decl %t
+
+void f() {
+  int i;
+}
+
+void f2() {
+  int i, j, *k, lala = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int j;
+  // CHECK-FIXES: {{^  }}int *k;
+  // CHECK-FIXES: {{^  }}int lala = 42;
+
+  int normal, weird = /* comment */ 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int normal;
+  // CHECK-FIXES: {{^  }}int weird = /* comment */ 42;
+  //
+  int /* here is a comment */ v1,
+  // another comment
+  v2 = 42 // Ok, more comments
+  ;
+  // CHECK-MESSAGES: [[@LINE-4]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int /* here is a comment */ v1;
+  // CHECK-FIXES: {{^  }}int /* here is a comment */ // another comment
+  // CHECK-FIXES: {{^  }}v2 = 42 // Ok, more comments
+  // CHECK-FIXES: {{^  }};
+}
+
+void f3() {
+  int i, *pointer1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int *pointer1;
+  //
+  int *pointer2 = nullptr, *pointer3 = 
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int *pointer2 = nullptr;
+  // CHECK-FIXES: {{^  }}int *pointer3 = 
+}
+
+void f4() {
+  double d = 42. /* foo */, z = 43., /* hi */ y, c /* */ /*  */, l = 2.;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: double d = 42. /* foo */;
+  // CHECK-FIXES: {{^  }}double z = 43.;
+  // CHECK-FIXES: {{^  }}double /* hi */ y;
+  // CHECK-FIXES: {{^  }}double c /* */ /*  */;
+  // CHECK-FIXES: {{^  }}double l = 2.;
+}
+
+struct SomeClass {
+  SomeClass() = default;
+  SomeClass(int value);
+};
+
+class Point {
+  double x;
+  double y;
+
+public:
+  Point(double x, double y) : x(x), y(y) {}
+};
+
+class Rectangle {
+  Point TopLeft;
+  Point BottomRight;
+
+public:
+  Rectangle(Point TopLeft, Point BottomRight) : TopLeft(TopLeft), BottomRight(BottomRight) {}
+};
+
+void f5() {
+  SomeClass v1, v2(42), v3{42}, v4(42.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: SomeClass v1;
+  // CHECK-FIXES: {{^  }}SomeClass v2(42);
+  // CHECK-FIXES: {{^  }}SomeClass v3{42};
+  // CHECK-FIXES: {{^  }}SomeClass v4(42.5);
+
+  SomeClass v5 = 42, *p1 = nullptr;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: SomeClass v5 = 42;
+  // CHECK-FIXES: {{^  }}SomeClass *p1 = nullptr;
+
+  Point P1(0., 2.), P2{2., 0.};
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: Point P1(0., 2.);
+  // CHECK-FIXES: {{^  }}Point P2{2., 0.};
+
+  Rectangle R1({0., 0.}, {1., -2.}), R2{{0., 1.}, {1., 0.}}, R3(P1, P2), R4{P1, P2};
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: Rectangle R1({0., 0.}, {1., -2.});
+  // CHECK-FIXES: {{^  }}Rectangle R2{{[{][{]}}0., 1.}, {1., 0.{{[}][}]}};
+  // CHECK-FIXES: {{^  }}Rectangle R3(P1, P2);
+  // CHECK-FIXES: {{^  }}Rectangle R4{P1, P2};
+}
+
+void f6() {
+  int array1[] = {1, 2, 3, 4}, array2[] = {1, 2, 3}, value1, value2 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int array1[] = {1, 2, 3, 4};
+  // CHECK-FIXES: {{^  }}int array2[] = {1, 2, 3};
+  // CHECK-FIXES: {{^  }}int value1;
+  // CHECK-FIXES: {{^  }}int value2 = 42;
+}
+
+template 
+struct TemplatedType {
+  TemplatedType() = default;
+  TemplatedType(T value);
+};
+
+void f7() {
+  TemplatedType TT1(42), TT2{42}, TT3;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple 

[PATCH] D52574: NFC: Fix some darwin linker warnings introduced in r338385

2018-09-27 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC343263: NFC: Fix some darwin linker warnings introduced in 
r338385 (authored by epilk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52574?vs=167193=167394#toc

Repository:
  rC Clang

https://reviews.llvm.org/D52574

Files:
  lib/Driver/CMakeLists.txt
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains/RISCV.cpp
  lib/Driver/ToolChains/RISCV.h
  lib/Driver/ToolChains/RISCVToolchain.cpp
  lib/Driver/ToolChains/RISCVToolchain.h

Index: lib/Driver/CMakeLists.txt
===
--- lib/Driver/CMakeLists.txt
+++ lib/Driver/CMakeLists.txt
@@ -57,7 +57,7 @@
   ToolChains/NetBSD.cpp
   ToolChains/OpenBSD.cpp
   ToolChains/PS4CPU.cpp
-  ToolChains/RISCV.cpp
+  ToolChains/RISCVToolchain.cpp
   ToolChains/Solaris.cpp
   ToolChains/TCE.cpp
   ToolChains/WebAssembly.cpp
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -37,7 +37,7 @@
 #include "ToolChains/NetBSD.h"
 #include "ToolChains/OpenBSD.h"
 #include "ToolChains/PS4CPU.h"
-#include "ToolChains/RISCV.h"
+#include "ToolChains/RISCVToolchain.h"
 #include "ToolChains/Solaris.h"
 #include "ToolChains/TCE.h"
 #include "ToolChains/WebAssembly.h"
Index: lib/Driver/ToolChains/RISCVToolchain.h
===
--- lib/Driver/ToolChains/RISCVToolchain.h
+++ lib/Driver/ToolChains/RISCVToolchain.h
@@ -0,0 +1,63 @@
+//===--- RISCVToolchain.h - RISCV ToolChain Implementations -*- 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_LIB_DRIVER_TOOLCHAINS_RISCVTOOLCHAIN_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_RISCVTOOLCHAIN_H
+
+#include "Gnu.h"
+#include "clang/Driver/ToolChain.h"
+
+namespace clang {
+namespace driver {
+namespace toolchains {
+
+class LLVM_LIBRARY_VISIBILITY RISCVToolChain : public Generic_ELF {
+public:
+  RISCVToolChain(const Driver , const llvm::Triple ,
+ const llvm::opt::ArgList );
+
+  bool IsIntegratedAssemblerDefault() const override { return true; }
+  void addClangTargetOptions(const llvm::opt::ArgList ,
+ llvm::opt::ArgStringList ,
+ Action::OffloadKind) const override;
+  void
+  AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const override;
+  void
+  addLibStdCxxIncludePaths(const llvm::opt::ArgList ,
+   llvm::opt::ArgStringList ) const override;
+
+protected:
+  Tool *buildLinker() const override;
+
+private:
+  std::string computeSysRoot() const;
+};
+
+} // end namespace toolchains
+
+namespace tools {
+namespace RISCV {
+class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
+public:
+  Linker(const ToolChain ) : GnuTool("RISCV::Linker", "ld", TC) {}
+  bool hasIntegratedCPP() const override { return false; }
+  bool isLinkJob() const override { return true; }
+  void ConstructJob(Compilation , const JobAction ,
+const InputInfo , const InputInfoList ,
+const llvm::opt::ArgList ,
+const char *LinkingOutput) const override;
+};
+} // end namespace RISCV
+} // end namespace tools
+
+} // end namespace driver
+} // end namespace clang
+
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_RISCVTOOLCHAIN_H
Index: lib/Driver/ToolChains/RISCVToolchain.cpp
===
--- lib/Driver/ToolChains/RISCVToolchain.cpp
+++ lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -0,0 +1,141 @@
+//===--- RISCVToolchain.cpp - RISCV ToolChain Implementations ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "RISCVToolchain.h"
+#include "CommonArgs.h"
+#include "InputInfo.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Options.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang::driver;
+using namespace clang::driver::toolchains;
+using namespace clang::driver::tools;
+using namespace clang;
+using namespace llvm::opt;
+
+/// RISCV Toolchain
+RISCVToolChain::RISCVToolChain(const Driver , const llvm::Triple ,
+   const ArgList )
+: Generic_ELF(D, Triple, Args) {
+  GCCInstallation.init(Triple, Args);
+  

r343263 - NFC: Fix some darwin linker warnings introduced in r338385

2018-09-27 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Thu Sep 27 13:36:28 2018
New Revision: 343263

URL: http://llvm.org/viewvc/llvm-project?rev=343263=rev
Log:
NFC: Fix some darwin linker warnings introduced in r338385

The darwin linker was complaining about Toolchains/RISCV.cpp and
Toolchains/Arch/RISCV.cpp had the same name. Fix is to just rename
Toolchains/RISCV.cpp to Toolchains/RISCVToolchain.cpp.

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

Added:
cfe/trunk/lib/Driver/ToolChains/RISCVToolchain.cpp
cfe/trunk/lib/Driver/ToolChains/RISCVToolchain.h
Removed:
cfe/trunk/lib/Driver/ToolChains/RISCV.cpp
cfe/trunk/lib/Driver/ToolChains/RISCV.h
Modified:
cfe/trunk/lib/Driver/CMakeLists.txt
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/lib/Driver/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/CMakeLists.txt?rev=343263=343262=343263=diff
==
--- cfe/trunk/lib/Driver/CMakeLists.txt (original)
+++ cfe/trunk/lib/Driver/CMakeLists.txt Thu Sep 27 13:36:28 2018
@@ -57,7 +57,7 @@ add_clang_library(clangDriver
   ToolChains/NetBSD.cpp
   ToolChains/OpenBSD.cpp
   ToolChains/PS4CPU.cpp
-  ToolChains/RISCV.cpp
+  ToolChains/RISCVToolchain.cpp
   ToolChains/Solaris.cpp
   ToolChains/TCE.cpp
   ToolChains/WebAssembly.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=343263=343262=343263=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Sep 27 13:36:28 2018
@@ -37,7 +37,7 @@
 #include "ToolChains/NetBSD.h"
 #include "ToolChains/OpenBSD.h"
 #include "ToolChains/PS4CPU.h"
-#include "ToolChains/RISCV.h"
+#include "ToolChains/RISCVToolchain.h"
 #include "ToolChains/Solaris.h"
 #include "ToolChains/TCE.h"
 #include "ToolChains/WebAssembly.h"

Removed: cfe/trunk/lib/Driver/ToolChains/RISCV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/RISCV.cpp?rev=343262=auto
==
--- cfe/trunk/lib/Driver/ToolChains/RISCV.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/RISCV.cpp (removed)
@@ -1,141 +0,0 @@
-//===--- RISCV.cpp - RISCV ToolChain Implementations *- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include "RISCV.h"
-#include "CommonArgs.h"
-#include "InputInfo.h"
-#include "clang/Driver/Compilation.h"
-#include "clang/Driver/Options.h"
-#include "llvm/Option/ArgList.h"
-#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/Path.h"
-#include "llvm/Support/raw_ostream.h"
-
-using namespace clang::driver;
-using namespace clang::driver::toolchains;
-using namespace clang::driver::tools;
-using namespace clang;
-using namespace llvm::opt;
-
-/// RISCV Toolchain
-RISCVToolChain::RISCVToolChain(const Driver , const llvm::Triple ,
-   const ArgList )
-: Generic_ELF(D, Triple, Args) {
-  GCCInstallation.init(Triple, Args);
-  getFilePaths().push_back(computeSysRoot() + "/lib");
-  if (GCCInstallation.isValid()) {
-getFilePaths().push_back(GCCInstallation.getInstallPath().str());
-getProgramPaths().push_back(
-(GCCInstallation.getParentLibPath() + "/../bin").str());
-  }
-}
-
-Tool *RISCVToolChain::buildLinker() const {
-  return new tools::RISCV::Linker(*this);
-}
-
-void RISCVToolChain::addClangTargetOptions(
-const llvm::opt::ArgList ,
-llvm::opt::ArgStringList ,
-Action::OffloadKind) const {
-  CC1Args.push_back("-nostdsysteminc");
-  CC1Args.push_back("-fuse-init-array");
-}
-
-void RISCVToolChain::AddClangSystemIncludeArgs(const ArgList ,
-   ArgStringList ) const {
-  if (DriverArgs.hasArg(options::OPT_nostdinc))
-return;
-
-  if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
-SmallString<128> Dir(computeSysRoot());
-llvm::sys::path::append(Dir, "include");
-addSystemInclude(DriverArgs, CC1Args, Dir.str());
-  }
-}
-
-void RISCVToolChain::addLibStdCxxIncludePaths(
-const llvm::opt::ArgList ,
-llvm::opt::ArgStringList ) const {
-  const GCCVersion  = GCCInstallation.getVersion();
-  StringRef TripleStr = GCCInstallation.getTriple().str();
-  const Multilib  = GCCInstallation.getMultilib();
-  addLibStdCXXIncludePaths(computeSysRoot() + "/include/c++/" + Version.Text,
-  "", TripleStr, "", "", Multilib.includeSuffix(), DriverArgs, CC1Args);
-}
-
-std::string RISCVToolChain::computeSysRoot() const {
-  if (!getDriver().SysRoot.empty())
-return getDriver().SysRoot;
-
-  if (!GCCInstallation.isValid())
-return std::string();
-
-  

[PATCH] D50901: [clang][ubsan] Split Implicit Integer Truncation Sanitizer into unsigned and signed checks

2018-09-27 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 167391.
lebedev.ri marked an inline comment as done and 3 inline comments as not done.
lebedev.ri added a comment.

- Rebased


Repository:
  rC Clang

https://reviews.llvm.org/D50901

Files:
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Basic/Sanitizers.def
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGen/catch-implicit-integer-conversions-basics.c
  test/CodeGen/catch-implicit-integer-truncations-basics-negatives.c
  test/CodeGen/catch-implicit-integer-truncations-basics.c
  test/CodeGen/catch-implicit-integer-truncations.c
  test/CodeGen/catch-implicit-signed-integer-truncations-basics-negatives.c
  test/CodeGen/catch-implicit-signed-integer-truncations-basics.c
  test/CodeGen/catch-implicit-unsigned-integer-truncations-basics-negatives.c
  test/CodeGen/catch-implicit-unsigned-integer-truncations-basics.c
  test/CodeGenCXX/catch-implicit-integer-truncations.cpp
  test/Driver/fsanitize.c

Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -29,22 +29,37 @@
 // CHECK-COVERAGE-WIN64: "--dependent-lib={{[^"]*}}ubsan_standalone-x86_64.lib"
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=integer %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-INTEGER -implicit-check-not="-fsanitize-address-use-after-scope"
-// CHECK-INTEGER: "-fsanitize={{((signed-integer-overflow|unsigned-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent|implicit-integer-truncation),?){6}"}}
+// CHECK-INTEGER: "-fsanitize={{((signed-integer-overflow|unsigned-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent|implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){7}"}}
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-RECOVER
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion -fsanitize-recover=implicit-conversion %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-RECOVER
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion -fno-sanitize-recover=implicit-conversion %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-NORECOVER
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion -fsanitize-trap=implicit-conversion %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-TRAP
-// CHECK-implicit-conversion: "-fsanitize={{((implicit-integer-truncation),?){1}"}}
-// CHECK-implicit-conversion-RECOVER: "-fsanitize-recover={{((implicit-integer-truncation),?){1}"}}
-// CHECK-implicit-conversion-RECOVER-NOT: "-fno-sanitize-recover={{((implicit-integer-truncation),?){1}"}}
-// CHECK-implicit-conversion-RECOVER-NOT: "-fsanitize-trap={{((implicit-integer-truncation),?){1}"}}
-// CHECK-implicit-conversion-NORECOVER-NOT: "-fno-sanitize-recover={{((implicit-integer-truncation),?){1}"}} // ???
-// CHECK-implicit-conversion-NORECOVER-NOT: "-fsanitize-recover={{((implicit-integer-truncation),?){1}"}}
-// CHECK-implicit-conversion-NORECOVER-NOT: "-fsanitize-trap={{((implicit-integer-truncation),?){1}"}}
-// CHECK-implicit-conversion-TRAP: "-fsanitize-trap={{((implicit-integer-truncation),?){1}"}}
-// CHECK-implicit-conversion-TRAP-NOT: "-fsanitize-recover={{((implicit-integer-truncation),?){1}"}}
-// CHECK-implicit-conversion-TRAP-NOT: "-fno-sanitize-recover={{((implicit-integer-truncation),?){1}"}}
+// CHECK-implicit-conversion: "-fsanitize={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
+// CHECK-implicit-conversion-RECOVER: "-fsanitize-recover={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
+// CHECK-implicit-conversion-RECOVER-NOT: "-fno-sanitize-recover={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
+// CHECK-implicit-conversion-RECOVER-NOT: "-fsanitize-trap={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
+// CHECK-implicit-conversion-NORECOVER-NOT: "-fno-sanitize-recover={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}} // ???
+// CHECK-implicit-conversion-NORECOVER-NOT: "-fsanitize-recover={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
+// CHECK-implicit-conversion-NORECOVER-NOT: "-fsanitize-trap={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
+// CHECK-implicit-conversion-TRAP: "-fsanitize-trap={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
+// CHECK-implicit-conversion-TRAP-NOT: "-fsanitize-recover={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation),?){2}"}}
+// CHECK-implicit-conversion-TRAP-NOT: 

[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 167389.
JonasToth added a comment.

- bail out in transformation if there are PP directives in the source range of 
the DeclStmt


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/IsolateDeclCheck.cpp
  clang-tidy/readability/IsolateDeclCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-isolate-decl.rst
  test/clang-tidy/readability-isolate-decl-cxx17.cpp
  test/clang-tidy/readability-isolate-decl-fixing.cpp
  test/clang-tidy/readability-isolate-decl.cpp

Index: test/clang-tidy/readability-isolate-decl.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-isolate-decl.cpp
@@ -0,0 +1,356 @@
+// RUN: %check_clang_tidy %s readability-isolate-decl %t
+
+void f() {
+  int i;
+}
+
+void f2() {
+  int i, j, *k, lala = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int j;
+  // CHECK-FIXES: {{^  }}int *k;
+  // CHECK-FIXES: {{^  }}int lala = 42;
+
+  int normal, weird = /* comment */ 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int normal;
+  // CHECK-FIXES: {{^  }}int weird = /* comment */ 42;
+  //
+  int /* here is a comment */ v1,
+  // another comment
+  v2 = 42 // Ok, more comments
+  ;
+  // CHECK-MESSAGES: [[@LINE-4]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int /* here is a comment */ v1;
+  // CHECK-FIXES: {{^  }}int /* here is a comment */ // another comment
+  // CHECK-FIXES: {{^  }}v2 = 42 // Ok, more comments
+  // CHECK-FIXES: {{^  }};
+}
+
+void f3() {
+  int i, *pointer1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int *pointer1;
+  //
+  int *pointer2 = nullptr, *pointer3 = 
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int *pointer2 = nullptr;
+  // CHECK-FIXES: {{^  }}int *pointer3 = 
+}
+
+void f4() {
+  double d = 42. /* foo */, z = 43., /* hi */ y, c /* */ /*  */, l = 2.;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: double d = 42. /* foo */;
+  // CHECK-FIXES: {{^  }}double z = 43.;
+  // CHECK-FIXES: {{^  }}double /* hi */ y;
+  // CHECK-FIXES: {{^  }}double c /* */ /*  */;
+  // CHECK-FIXES: {{^  }}double l = 2.;
+}
+
+struct SomeClass {
+  SomeClass() = default;
+  SomeClass(int value);
+};
+
+class Point {
+  double x;
+  double y;
+
+public:
+  Point(double x, double y) : x(x), y(y) {}
+};
+
+class Rectangle {
+  Point TopLeft;
+  Point BottomRight;
+
+public:
+  Rectangle(Point TopLeft, Point BottomRight) : TopLeft(TopLeft), BottomRight(BottomRight) {}
+};
+
+void f5() {
+  SomeClass v1, v2(42), v3{42}, v4(42.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: SomeClass v1;
+  // CHECK-FIXES: {{^  }}SomeClass v2(42);
+  // CHECK-FIXES: {{^  }}SomeClass v3{42};
+  // CHECK-FIXES: {{^  }}SomeClass v4(42.5);
+
+  SomeClass v5 = 42, *p1 = nullptr;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: SomeClass v5 = 42;
+  // CHECK-FIXES: {{^  }}SomeClass *p1 = nullptr;
+
+  Point P1(0., 2.), P2{2., 0.};
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: Point P1(0., 2.);
+  // CHECK-FIXES: {{^  }}Point P2{2., 0.};
+
+  Rectangle R1({0., 0.}, {1., -2.}), R2{{0., 1.}, {1., 0.}}, R3(P1, P2), R4{P1, P2};
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: Rectangle R1({0., 0.}, {1., -2.});
+  // CHECK-FIXES: {{^  }}Rectangle R2{{[{][{]}}0., 1.}, {1., 0.{{[}][}]}};
+  // CHECK-FIXES: {{^  }}Rectangle R3(P1, P2);
+  // CHECK-FIXES: {{^  }}Rectangle R4{P1, P2};
+}
+
+void f6() {
+  int array1[] = {1, 2, 3, 4}, array2[] = {1, 2, 3}, value1, value2 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int array1[] = {1, 2, 3, 4};
+  // CHECK-FIXES: {{^  }}int array2[] = {1, 2, 3};
+  // CHECK-FIXES: {{^  }}int value1;
+  // CHECK-FIXES: {{^  }}int value2 = 42;
+}
+
+template 
+struct TemplatedType {
+  TemplatedType() = default;
+  TemplatedType(T value);
+};
+
+void f7() {
+  TemplatedType 

[PATCH] D52629: [OpenMP] Make default parallel for schedule in NVPTX target regions in SPMD mode achieve coalescing

2018-09-27 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC343260: [OpenMP] Make default parallel for schedule in NVPTX 
target regions in SPMD… (authored by gbercea, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52629?vs=167386=167387#toc

Repository:
  rC Clang

https://reviews.llvm.org/D52629

Files:
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp

Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
@@ -89,7 +89,7 @@
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL2]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -103,7 +103,7 @@
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL3]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -119,7 +119,7 @@
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL4]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
@@ -94,7 +94,7 @@
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL2]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -108,7 +108,7 @@
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL3]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -124,7 +124,7 @@
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL4]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.h
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.h
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.h
@@ -340,11 +340,16 @@
   ///
   void functionFinished(CodeGenFunction ) override;
 
-  /// Choose a default value for the schedule clause.
+  /// Choose a default value for the dist_schedule clause.
   void getDefaultDistScheduleAndChunk(CodeGenFunction ,
   const OMPLoopDirective , OpenMPDistScheduleClauseKind ,
   llvm::Value *) const override;
 
+  /// Choose a default value for the schedule clause.
+  void getDefaultScheduleAndChunk(CodeGenFunction ,
+  const OMPLoopDirective , OpenMPScheduleClauseKind ,
+  llvm::Value *) const override;
+
 private:
   /// Track the execution mode when codegening directives within a target
   /// region. The appropriate mode (SPMD/NON-SPMD) is set on entry to the
Index: lib/CodeGen/CGOpenMPRuntime.h
===
--- lib/CodeGen/CGOpenMPRuntime.h
+++ lib/CodeGen/CGOpenMPRuntime.h
@@ -1496,6 +1496,12 @@
   const OMPLoopDirective , OpenMPDistScheduleClauseKind ,
   llvm::Value *) const {}
 
+  /// Choose default schedule type and chunk value for the
+  /// schedule clause.
+  virtual void getDefaultScheduleAndChunk(CodeGenFunction ,
+  const OMPLoopDirective , OpenMPScheduleClauseKind ,
+  llvm::Value *) const {}
+
   /// Emits call of the outlined function with the provided arguments,
   /// translating these arguments to correct target-specific arguments.
   virtual void
Index: lib/CodeGen/CGStmtOpenMP.cpp
===
--- lib/CodeGen/CGStmtOpenMP.cpp
+++ lib/CodeGen/CGStmtOpenMP.cpp
@@ -2310,6 +2310,10 @@
S.getIterationVariable()->getType(),
S.getBeginLoc());
 }
+  } else {
+

r343260 - [OpenMP] Make default parallel for schedule in NVPTX target regions in SPMD mode achieve coalescing

2018-09-27 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Thu Sep 27 13:29:00 2018
New Revision: 343260

URL: http://llvm.org/viewvc/llvm-project?rev=343260=rev
Log:
[OpenMP] Make default parallel for schedule in NVPTX target regions in SPMD 
mode achieve coalescing

Summary: Set default schedule for parallel for loops to schedule(static, 1) 
when using SPMD mode on the NVPTX device offloading toolchain to ensure 
coalescing.

Reviewers: ABataev, Hahnfeld, caomhin

Reviewed By: ABataev

Subscribers: jholewinski, guansong, cfe-commits

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

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

cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=343260=343259=343260=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Thu Sep 27 13:29:00 2018
@@ -1496,6 +1496,12 @@ public:
   const OMPLoopDirective , OpenMPDistScheduleClauseKind ,
   llvm::Value *) const {}
 
+  /// Choose default schedule type and chunk value for the
+  /// schedule clause.
+  virtual void getDefaultScheduleAndChunk(CodeGenFunction ,
+  const OMPLoopDirective , OpenMPScheduleClauseKind ,
+  llvm::Value *) const {}
+
   /// Emits call of the outlined function with the provided arguments,
   /// translating these arguments to correct target-specific arguments.
   virtual void

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=343260=343259=343260=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Thu Sep 27 13:29:00 2018
@@ -4093,3 +4093,14 @@ void CGOpenMPRuntimeNVPTX::getDefaultDis
 S.getIterationVariable()->getType(), S.getBeginLoc());
   }
 }
+
+void CGOpenMPRuntimeNVPTX::getDefaultScheduleAndChunk(
+CodeGenFunction , const OMPLoopDirective ,
+OpenMPScheduleClauseKind ,
+llvm::Value *) const {
+  if (getExecutionMode() == CGOpenMPRuntimeNVPTX::EM_SPMD) {
+ScheduleKind = OMPC_SCHEDULE_static;
+Chunk = CGF.Builder.getIntN(CGF.getContext().getTypeSize(
+S.getIterationVariable()->getType()), 1);
+  }
+}

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h?rev=343260=343259=343260=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h Thu Sep 27 13:29:00 2018
@@ -340,11 +340,16 @@ public:
   ///
   void functionFinished(CodeGenFunction ) override;
 
-  /// Choose a default value for the schedule clause.
+  /// Choose a default value for the dist_schedule clause.
   void getDefaultDistScheduleAndChunk(CodeGenFunction ,
   const OMPLoopDirective , OpenMPDistScheduleClauseKind ,
   llvm::Value *) const override;
 
+  /// Choose a default value for the schedule clause.
+  void getDefaultScheduleAndChunk(CodeGenFunction ,
+  const OMPLoopDirective , OpenMPScheduleClauseKind ,
+  llvm::Value *) const override;
+
 private:
   /// Track the execution mode when codegening directives within a target
   /// region. The appropriate mode (SPMD/NON-SPMD) is set on entry to the

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=343260=343259=343260=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Sep 27 13:29:00 2018
@@ -2310,6 +2310,10 @@ bool CodeGenFunction::EmitOMPWorksharing
S.getIterationVariable()->getType(),
S.getBeginLoc());
 }
+  } else {
+// Default behaviour for schedule clause.
+CGM.getOpenMPRuntime().getDefaultScheduleAndChunk(
+*this, S, ScheduleKind.Schedule, Chunk);
   }
   const unsigned IVSize = getContext().getTypeSize(IVExpr->getType());
   const bool IVSigned = 
IVExpr->getType()->hasSignedIntegerRepresentation();

Modified: 
cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
URL: 

[PATCH] D52629: [OpenMP] Make default parallel for schedule in NVPTX target regions in SPMD mode achieve coalescing

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

LG


Repository:
  rC Clang

https://reviews.llvm.org/D52629



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


[PATCH] D52629: [OpenMP] Make default parallel for schedule in NVPTX target regions in SPMD mode achieve coalescing

2018-09-27 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 167386.
gtbercea added a comment.

Address comment.


Repository:
  rC Clang

https://reviews.llvm.org/D52629

Files:
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp

Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
@@ -89,7 +89,7 @@
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL2]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -103,7 +103,7 @@
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL3]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -119,7 +119,7 @@
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL4]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
@@ -94,7 +94,7 @@
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL2]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -108,7 +108,7 @@
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL3]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -124,7 +124,7 @@
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL4]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
Index: lib/CodeGen/CGStmtOpenMP.cpp
===
--- lib/CodeGen/CGStmtOpenMP.cpp
+++ lib/CodeGen/CGStmtOpenMP.cpp
@@ -2310,6 +2310,10 @@
S.getIterationVariable()->getType(),
S.getBeginLoc());
 }
+  } else {
+// Default behaviour for schedule clause.
+CGM.getOpenMPRuntime().getDefaultScheduleAndChunk(
+*this, S, ScheduleKind.Schedule, Chunk);
   }
   const unsigned IVSize = getContext().getTypeSize(IVExpr->getType());
   const bool IVSigned = IVExpr->getType()->hasSignedIntegerRepresentation();
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.h
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.h
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.h
@@ -340,11 +340,16 @@
   ///
   void functionFinished(CodeGenFunction ) override;
 
-  /// Choose a default value for the schedule clause.
+  /// Choose a default value for the dist_schedule clause.
   void getDefaultDistScheduleAndChunk(CodeGenFunction ,
   const OMPLoopDirective , OpenMPDistScheduleClauseKind ,
   llvm::Value *) const override;
 
+  /// Choose a default value for the schedule clause.
+  void getDefaultScheduleAndChunk(CodeGenFunction ,
+  const OMPLoopDirective , OpenMPScheduleClauseKind ,
+  llvm::Value *) const override;
+
 private:
   /// Track the execution mode when codegening directives within a target
   /// region. The appropriate mode (SPMD/NON-SPMD) is set on entry to the
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4093,3 +4093,14 @@
 S.getIterationVariable()->getType(), S.getBeginLoc());
   }
 }
+
+void CGOpenMPRuntimeNVPTX::getDefaultScheduleAndChunk(
+CodeGenFunction , const OMPLoopDirective ,
+OpenMPScheduleClauseKind ,
+llvm::Value *) const {
+  if (getExecutionMode() == CGOpenMPRuntimeNVPTX::EM_SPMD) {
+ScheduleKind = OMPC_SCHEDULE_static;
+Chunk = 

[PATCH] D52629: [OpenMP] Make default parallel for schedule in NVPTX target regions in SPMD mode achieve coalescing

2018-09-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:4103
+ScheduleKind = OMPC_SCHEDULE_static;
+Chunk = CGF.Builder.getIntN(CGM.getDataLayout().getTypeAllocSizeInBits(
+CGF.ConvertType(S.getIterationVariable()->getType())), 1);

Use `getContext().getTypeSize(S.getIterationVariable()->getType())` 


Repository:
  rC Clang

https://reviews.llvm.org/D52629



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


r343258 - Test commit. NFC

2018-09-27 Thread Patrick Lyster via cfe-commits
Author: plyster
Date: Thu Sep 27 12:30:32 2018
New Revision: 343258

URL: http://llvm.org/viewvc/llvm-project?rev=343258=rev
Log:
Test commit. NFC

Modified:
cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=343258=343257=343258=diff
==
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Thu Sep 27 12:30:32 2018
@@ -8421,7 +8421,7 @@ TreeTransform::TransformOMPNogr
 template 
 OMPClause *TreeTransform::TransformOMPUnifiedAddressClause(
 OMPUnifiedAddressClause *C) {
-  llvm_unreachable("unified address clause cannot appear in dependent 
context");
+  llvm_unreachable("unified_address clause cannot appear in dependent 
context");
 }
 
 template 


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


[PATCH] D52629: [OpenMP] Make default parallel for schedule in NVPTX target regions in SPMD mode achieve coalescing

2018-09-27 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: ABataev, Hahnfeld, caomhin.
Herald added subscribers: cfe-commits, guansong, jholewinski.

Set default schedule for parallel for loops to schedule(static, 1) when using 
SPMD mode on the NVPTX device offloading toolchain to ensure coalescing.


Repository:
  rC Clang

https://reviews.llvm.org/D52629

Files:
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp

Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
@@ -89,7 +89,7 @@
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL2]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -103,7 +103,7 @@
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL3]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -119,7 +119,7 @@
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL4]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
@@ -94,7 +94,7 @@
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL2]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -108,7 +108,7 @@
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL3]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -124,7 +124,7 @@
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTL4]](
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 34,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 33,
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
Index: lib/CodeGen/CGStmtOpenMP.cpp
===
--- lib/CodeGen/CGStmtOpenMP.cpp
+++ lib/CodeGen/CGStmtOpenMP.cpp
@@ -2310,6 +2310,10 @@
S.getIterationVariable()->getType(),
S.getBeginLoc());
 }
+  } else {
+// Default behaviour for schedule clause.
+CGM.getOpenMPRuntime().getDefaultScheduleAndChunk(
+*this, S, ScheduleKind.Schedule, Chunk);
   }
   const unsigned IVSize = getContext().getTypeSize(IVExpr->getType());
   const bool IVSigned = IVExpr->getType()->hasSignedIntegerRepresentation();
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.h
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.h
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.h
@@ -340,11 +340,16 @@
   ///
   void functionFinished(CodeGenFunction ) override;
 
-  /// Choose a default value for the schedule clause.
+  /// Choose a default value for the dist_schedule clause.
   void getDefaultDistScheduleAndChunk(CodeGenFunction ,
   const OMPLoopDirective , OpenMPDistScheduleClauseKind ,
   llvm::Value *) const override;
 
+  /// Choose a default value for the schedule clause.
+  void getDefaultScheduleAndChunk(CodeGenFunction ,
+  const OMPLoopDirective , OpenMPScheduleClauseKind ,
+  llvm::Value *) const override;
+
 private:
   /// Track the execution mode when codegening directives within a target
   /// region. The appropriate mode (SPMD/NON-SPMD) is set on entry to the
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4093,3 +4093,14 @@
 S.getIterationVariable()->getType(), S.getBeginLoc());
   }
 }
+
+void CGOpenMPRuntimeNVPTX::getDefaultScheduleAndChunk(
+

[PATCH] D52625: [OPENMP] Add 'unified_shared_memory' clause to OMP5 'requires' directive

2018-09-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

I forgot to mention that you need an ast print test (the positive test)


Repository:
  rC Clang

https://reviews.llvm.org/D52625



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


[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth marked 9 inline comments as done.
JonasToth added inline comments.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:211
+  std::vector Snippets;
+  Snippets.reserve(Ranges.size());
+

kbobyrev wrote:
> nit: It would be probably easier to have `Snippets(Ranges.size()` and then 
> insert each `Snippet` to the correct position. That would require sacrificing 
> for-range loop and having a counter, but I think that it would make this 
> piece slightly better. Up to you, I don't have strong opinion about this part.
I prefer this one :)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949



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


[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 167381.
JonasToth marked 9 inline comments as done.
JonasToth added a comment.

- simplification on FIXME:/TODO:


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/IsolateDeclCheck.cpp
  clang-tidy/readability/IsolateDeclCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-isolate-decl.rst
  test/clang-tidy/readability-isolate-decl-cxx17.cpp
  test/clang-tidy/readability-isolate-decl-fixing.cpp
  test/clang-tidy/readability-isolate-decl.cpp

Index: test/clang-tidy/readability-isolate-decl.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-isolate-decl.cpp
@@ -0,0 +1,347 @@
+// RUN: %check_clang_tidy %s readability-isolate-decl %t
+
+void f() {
+  int i;
+}
+
+void f2() {
+  int i, j, *k, lala = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int j;
+  // CHECK-FIXES: {{^  }}int *k;
+  // CHECK-FIXES: {{^  }}int lala = 42;
+
+  int normal, weird = /* comment */ 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int normal;
+  // CHECK-FIXES: {{^  }}int weird = /* comment */ 42;
+  //
+  int /* here is a comment */ v1,
+  // another comment
+  v2 = 42 // Ok, more comments
+  ;
+  // CHECK-MESSAGES: [[@LINE-4]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int /* here is a comment */ v1;
+  // CHECK-FIXES: {{^  }}int /* here is a comment */ // another comment
+  // CHECK-FIXES: {{^  }}v2 = 42 // Ok, more comments
+  // CHECK-FIXES: {{^  }};
+}
+
+void f3() {
+  int i, *pointer1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int *pointer1;
+  //
+  int *pointer2 = nullptr, *pointer3 = 
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int *pointer2 = nullptr;
+  // CHECK-FIXES: {{^  }}int *pointer3 = 
+}
+
+void f4() {
+  double d = 42. /* foo */, z = 43., /* hi */ y, c /* */ /*  */, l = 2.;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: double d = 42. /* foo */;
+  // CHECK-FIXES: {{^  }}double z = 43.;
+  // CHECK-FIXES: {{^  }}double /* hi */ y;
+  // CHECK-FIXES: {{^  }}double c /* */ /*  */;
+  // CHECK-FIXES: {{^  }}double l = 2.;
+}
+
+struct SomeClass {
+  SomeClass() = default;
+  SomeClass(int value);
+};
+
+class Point {
+  double x;
+  double y;
+
+public:
+  Point(double x, double y) : x(x), y(y) {}
+};
+
+class Rectangle {
+  Point TopLeft;
+  Point BottomRight;
+
+public:
+  Rectangle(Point TopLeft, Point BottomRight) : TopLeft(TopLeft), BottomRight(BottomRight) {}
+};
+
+void f5() {
+  SomeClass v1, v2(42), v3{42}, v4(42.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: SomeClass v1;
+  // CHECK-FIXES: {{^  }}SomeClass v2(42);
+  // CHECK-FIXES: {{^  }}SomeClass v3{42};
+  // CHECK-FIXES: {{^  }}SomeClass v4(42.5);
+
+  SomeClass v5 = 42, *p1 = nullptr;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: SomeClass v5 = 42;
+  // CHECK-FIXES: {{^  }}SomeClass *p1 = nullptr;
+
+  Point P1(0., 2.), P2{2., 0.};
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: Point P1(0., 2.);
+  // CHECK-FIXES: {{^  }}Point P2{2., 0.};
+
+  Rectangle R1({0., 0.}, {1., -2.}), R2{{0., 1.}, {1., 0.}}, R3(P1, P2), R4{P1, P2};
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: Rectangle R1({0., 0.}, {1., -2.});
+  // CHECK-FIXES: {{^  }}Rectangle R2{{[{][{]}}0., 1.}, {1., 0.{{[}][}]}};
+  // CHECK-FIXES: {{^  }}Rectangle R3(P1, P2);
+  // CHECK-FIXES: {{^  }}Rectangle R4{P1, P2};
+}
+
+void f6() {
+  int array1[] = {1, 2, 3, 4}, array2[] = {1, 2, 3}, value1, value2 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int array1[] = {1, 2, 3, 4};
+  // CHECK-FIXES: {{^  }}int array2[] = {1, 2, 3};
+  // CHECK-FIXES: {{^  }}int value1;
+  // CHECK-FIXES: {{^  }}int value2 = 42;
+}
+
+template 
+struct TemplatedType {
+  TemplatedType() = default;
+  TemplatedType(T value);
+};
+
+void f7() {
+  TemplatedType TT1(42), TT2{42}, TT3;

[PATCH] D52625: [OPENMP] Add 'unified_shared_memory' clause to OMP5 'requires' directive

2018-09-27 Thread Patrick Lyster via Phabricator via cfe-commits
patricklyster created this revision.
patricklyster added reviewers: ABataev, Hahnfeld, RaviNarayanaswamy, mikerice, 
kkwli0, hfinkel, gtbercea.
patricklyster added projects: clang, OpenMP.
Herald added a subscriber: guansong.

Added new `unified_shared_memory` clause to existing OMP5.0 `requires` directive


Repository:
  rC Clang

https://reviews.llvm.org/D52625

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/requires_unified_address_messages.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2210,6 +2210,9 @@
 void OMPClauseEnqueue::VisitOMPUnifiedAddressClause(
 const OMPUnifiedAddressClause *) {}
 
+void OMPClauseEnqueue::VisitOMPUnifiedSharedMemoryClause(
+const OMPUnifiedSharedMemoryClause *) {}
+
 void OMPClauseEnqueue::VisitOMPDeviceClause(const OMPDeviceClause *C) {
   Visitor->AddStmt(C->getDevice());
 }
Index: clang/test/OpenMP/requires_unified_address_messages.cpp
===
--- clang/test/OpenMP/requires_unified_address_messages.cpp
+++ clang/test/OpenMP/requires_unified_address_messages.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100  %s
 
-#pragma omp requires unified_address // expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}}
+#pragma omp requires unified_address // expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note{{unified_address clause previously used here}}
+
+#pragma omp requires unified_shared_memory // expected-note {{unified_shared_memory clause previously used here}} expected-note{{unified_shared_memory clause previously used here}}
+
+#pragma omp requires unified_shared_memory, unified_shared_memory // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_shared_memory' clause}}
 
 #pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} 
 
@@ -16,6 +20,8 @@
 
 #pragma omp requires invalid_clause unified_address // expected-warning {{extra tokens at the end of '#pragma omp requires' are ignored}} expected-error {{expected at least one clause on '#pragma omp requires' directive}}
 
+#pragma omp requires unified_shared_memory, unified_address // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error{{Only one unified_address clause can appear on a requires directive in a single translation unit}}
+
 namespace A {
   #pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}}
   namespace B {
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -6932,3 +6932,6 @@
 }
 
 void OMPClauseWriter::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClause *) {}
+
+void OMPClauseWriter::VisitOMPUnifiedSharedMemoryClause(
+OMPUnifiedSharedMemoryClause *) {}
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -11723,6 +11723,9 @@
   case OMPC_unified_address:
 C = new (Context) OMPUnifiedAddressClause();
 break;
+  case OMPC_unified_shared_memory:
+C = new (Context) OMPUnifiedSharedMemoryClause();
+break;
   case OMPC_private:
 C = OMPPrivateClause::CreateEmpty(Context, Record.readInt());
 break;
@@ -11953,6 +11956,9 @@
 
 void 

[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:343
+  auto Diag =
+  diag(WholeDecl->getBeginLoc(), "this statement declares %0 variables")
+  << static_cast(

aaron.ballman wrote:
> JonasToth wrote:
> > kbobyrev wrote:
> > > aaron.ballman wrote:
> > > > lebedev.ri wrote:
> > > > > kbobyrev wrote:
> > > > > > JonasToth wrote:
> > > > > > > kbobyrev wrote:
> > > > > > > > How about `multiple declarations within a single statement 
> > > > > > > > hurts readability`?
> > > > > > > s/hurts/reduces/? hurts sound a bit weird i think.
> > > > > > > 
> > > > > > > Lebedev wanted the number of decls in the diagnostic, would you 
> > > > > > > include it or rather now?
> > > > > > "decreases" is also fine. "hurts" is probably too strong, I agree.
> > > > > > 
> > > > > > Up to you. Personally, I don't see any value in having the 
> > > > > > diagnostic message saying "hey, you have 2 declarations within one 
> > > > > > statement, that's really bad!" or "hey, you have 5 declarations 
> > > > > > within one statement..." - in both cases the point is that there 
> > > > > > are *multiple* declarations. I also don't think it would make 
> > > > > > debugging easier because you also check the formatting, so you 
> > > > > > already imply that the correct number of declarations was detected.
> > > > > > 
> > > > > > I'm interested to know what @lebedev.ri thinks.
> > > > > > I'm interested to know what @lebedev.ri thinks.
> > > > > 
> > > > > "This translation unit has an error. Can not continue" is also a 
> > > > > diagnostic message.
> > > > > Why are we not ok with that one, and want compiler to be a bit more 
> > > > > specific?
> > > > > 
> > > > > Similarly here, why just point out that this code is bad as per the 
> > > > > check,
> > > > > without giving a little bit more info, that you already have?
> > > > > "This translation unit has an error. Can not continue" is also a 
> > > > > diagnostic message.
> > > > >Why are we not ok with that one, and want compiler to be a bit more 
> > > > >specific?
> > > > >
> > > > > Similarly here, why just point out that this code is bad as per the 
> > > > > check, without giving a little bit more info, that you already have?
> > > > 
> > > > More information doesn't always equate into more understanding, 
> > > > especially when that information causes a distraction. For instance, 
> > > > you could argue that the type of the declared variables is also 
> > > > information we already have, but what purpose would it serve to tell it 
> > > > to the user?
> > > > 
> > > > Can you give an example where the specific number of declarations 
> > > > involved would help you to correct the diagnostic? I can't come up with 
> > > > one, so it feels to me like having the count is more of a distraction; 
> > > > especially given that there's no configurable threshold for "now you 
> > > > have too many declarations". I'd feel differently if there was a config 
> > > > option, because then the count is truly useful to know.
> > > Oh, but that's different: "This translation unit has an error. Can not 
> > > continue" does not provide enough information for users to fix the issue, 
> > > pointing out that there are *multiple* declarations per statement is 
> > > definitely enough.
> > I am personally against having the number in the diagnostic as well, it 
> > would only add value if the declarations are expanded from a macro.
> > 
> > @aaron.ballman Configuration of this check would be intersting but i would 
> > rather postpone that and have a basic working check first. Given that this 
> > aims to be utility-like to evaluate `const-correctness` and/or to be usable 
> > with other checks doing type transformations.
> Yeah, I wasn't suggesting a threshold config option for this patch so much as 
> pointing out why I'm opposed to putting the count in the diagnostic.
I used a different wording without the variable count. Adding configuration, 
more advanced diagnostic can be done in a follow up or in a different check, 
e.g. `readability-function-size`, as it does counting (might not be the perfect 
fit though)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949



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


[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 167377.
JonasToth added a comment.

- address review comments, most nits solved
- fix typedefs and function pointers with comments as distraction
- make memberpointer detection more accurate
- move functioning member pointer test
- clean debug output
- clean lexer utils as well
- adjust diagnostic message


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/IsolateDeclCheck.cpp
  clang-tidy/readability/IsolateDeclCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-isolate-decl.rst
  test/clang-tidy/readability-isolate-decl-cxx17.cpp
  test/clang-tidy/readability-isolate-decl-fixing.cpp
  test/clang-tidy/readability-isolate-decl.cpp

Index: test/clang-tidy/readability-isolate-decl.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-isolate-decl.cpp
@@ -0,0 +1,347 @@
+// RUN: %check_clang_tidy %s readability-isolate-decl %t
+
+void f() {
+  int i;
+}
+
+void f2() {
+  int i, j, *k, lala = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int j;
+  // CHECK-FIXES: {{^  }}int *k;
+  // CHECK-FIXES: {{^  }}int lala = 42;
+
+  int normal, weird = /* comment */ 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int normal;
+  // CHECK-FIXES: {{^  }}int weird = /* comment */ 42;
+  //
+  int /* here is a comment */ v1,
+  // another comment
+  v2 = 42 // Ok, more comments
+  ;
+  // CHECK-MESSAGES: [[@LINE-4]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int /* here is a comment */ v1;
+  // CHECK-FIXES: {{^  }}int /* here is a comment */ // another comment
+  // CHECK-FIXES: {{^  }}v2 = 42 // Ok, more comments
+  // CHECK-FIXES: {{^  }};
+}
+
+void f3() {
+  int i, *pointer1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int *pointer1;
+  //
+  int *pointer2 = nullptr, *pointer3 = 
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int *pointer2 = nullptr;
+  // CHECK-FIXES: {{^  }}int *pointer3 = 
+}
+
+void f4() {
+  double d = 42. /* foo */, z = 43., /* hi */ y, c /* */ /*  */, l = 2.;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: double d = 42. /* foo */;
+  // CHECK-FIXES: {{^  }}double z = 43.;
+  // CHECK-FIXES: {{^  }}double /* hi */ y;
+  // CHECK-FIXES: {{^  }}double c /* */ /*  */;
+  // CHECK-FIXES: {{^  }}double l = 2.;
+}
+
+struct SomeClass {
+  SomeClass() = default;
+  SomeClass(int value);
+};
+
+class Point {
+  double x;
+  double y;
+
+public:
+  Point(double x, double y) : x(x), y(y) {}
+};
+
+class Rectangle {
+  Point TopLeft;
+  Point BottomRight;
+
+public:
+  Rectangle(Point TopLeft, Point BottomRight) : TopLeft(TopLeft), BottomRight(BottomRight) {}
+};
+
+void f5() {
+  SomeClass v1, v2(42), v3{42}, v4(42.5);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: SomeClass v1;
+  // CHECK-FIXES: {{^  }}SomeClass v2(42);
+  // CHECK-FIXES: {{^  }}SomeClass v3{42};
+  // CHECK-FIXES: {{^  }}SomeClass v4(42.5);
+
+  SomeClass v5 = 42, *p1 = nullptr;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: SomeClass v5 = 42;
+  // CHECK-FIXES: {{^  }}SomeClass *p1 = nullptr;
+
+  Point P1(0., 2.), P2{2., 0.};
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: Point P1(0., 2.);
+  // CHECK-FIXES: {{^  }}Point P2{2., 0.};
+
+  Rectangle R1({0., 0.}, {1., -2.}), R2{{0., 1.}, {1., 0.}}, R3(P1, P2), R4{P1, P2};
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: Rectangle R1({0., 0.}, {1., -2.});
+  // CHECK-FIXES: {{^  }}Rectangle R2{{[{][{]}}0., 1.}, {1., 0.{{[}][}]}};
+  // CHECK-FIXES: {{^  }}Rectangle R3(P1, P2);
+  // CHECK-FIXES: {{^  }}Rectangle R4{P1, P2};
+}
+
+void f6() {
+  int array1[] = {1, 2, 3, 4}, array2[] = {1, 2, 3}, value1, value2 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int array1[] = {1, 2, 3, 4};
+  // CHECK-FIXES: {{^  }}int array2[] = {1, 2, 3};
+  // CHECK-FIXES: {{^  }}int value1;
+  // 

[PATCH] D47233: [CodeGen] Emit MSVC RTTI for Obj-C EH types

2018-09-27 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: lib/CodeGen/CGObjCMac.cpp:7457-7460
 CGObjCNonFragileABIMac::GetEHType(QualType T) {
   // There's a particular fixed type info for 'id'.
   if (T->isObjCIdType() || T->isObjCQualifiedIdType()) {
+if (CGM.getTriple().isWindowsMSVCEnvironment())

rjmccall wrote:
> smeenai wrote:
> > smeenai wrote:
> > > rjmccall wrote:
> > > > smeenai wrote:
> > > > > rjmccall wrote:
> > > > > > rnk wrote:
> > > > > > > @rjmccall how should this be organized in the long run? At this 
> > > > > > > point, the naming seems totally wrong. Is the non-fragile ABI 
> > > > > > > sort of the canonical way forward for Obj-C, i.e. it's what a new 
> > > > > > > platform would want to use to best stay in sync with the future 
> > > > > > > of obj-c?
> > > > > > For Darwin, yes, absolutely.
> > > > > > 
> > > > > > I think this method should probably just completely delegate to the 
> > > > > > `CGCXXABI` using a new `getAddrOfObjCRTTIDescriptor` method.
> > > > > To be clear, you'd want the entirety of the EHType emission logic to 
> > > > > be shifted to CGCXXABI? I think that would make sense, and I can look 
> > > > > into it.
> > > > Right.
> > > Sorry, getting back to this now.
> > > 
> > > What did you have in mind for handling the different Obj-C runtimes? Were 
> > > you envisioning the new getAddrOfObjCRTTIDescriptor method supporting 
> > > just the non-fragile Mac ABI or all of them?
> > Looked into this more. ItaniumRTTIBuilder already has a 
> > BuildObjCObjectTypeInfo, which confused me for a bit until I realized it's 
> > only ever used for the fragile ABI, and even then only when using C++ 
> > try/catch (instead of Obj-C style @try/@catch), which is a bit strange. 
> > Everything else does its own thing.
> > 
> > From what I've been able to make out, these are the current possibilities 
> > for generating Obj-C RTTI for the Itanium ABI:
> > * Fragile macOS runtime using Obj-C @try/@catch: doesn't actually seem to 
> > generate any RTTI as far as I can tell, and uses `objc_exception_match` 
> > instead.
> > * Fragile macOS runtime using C++ try/catch: goes through 
> > `ItaniumRTTIBuilder::BuildObjCObjectTypeInfo`, which generates C++ 
> > compatible RTTI referencing a C++ class type info.
> > * Non-fragile macOS runtime: generates its own C++ compatible RTTI 
> > referencing `objc_ehtype_vtable`.
> > * GNUStep for Objective-C++: generates its own C++ compatible RTTI 
> > referencing `_ZTVN7gnustep7libobjc22__objc_class_type_infoE`.
> > * All other GNU runtimes (including GNUStep for Objective-C): just uses the 
> > identifier name string of the interface as its "RTTI".
> > 
> > I think it makes sense to only have the new `getAddrOfObjCRTTIDescriptor` 
> > method handle the non-fragile macOS runtime for now, and perhaps 
> > `ItaniumRTTIBuilder::BuildObjCObjectTypeInfo` should be renamed (or at 
> > least have a comment added) to indicate that it's only used for the fragile 
> > macOS runtime when catching an Obj-C type with C++ catch.
> Yeah, that makes sense to me for now.
@rjmccall Sorry, I've been severely distracted, but I'm trying to come back and 
finish this up now. I'm fully aware you've probably lost all context on this by 
now as well, and I do apologize for the delay.

I did try implementing this approach, where I had `getAddrOfObjCRTTIDescriptor` 
as part of `CGCXXABI`. I ran into issues with trying to take the existing 
Itanium implementation of `CGObjCNonFragileABIMac::GetInterfaceEHType` and 
porting it over to to `CGCXXABI`, however. Specifically, it calls 
`GetClassName` and `GetClassGlobal`, both of which are non-trivial internal 
functions, and which I would then have to make accessible to `CGCXXABI` to end 
up with equivalent RTT generation.

I can put up a diff demonstrating what it would end up looking like if you want 
to see it, but I'm less convinced now that moving the entire RTTI emission 
logic out to `CGCXXABI` will end up being cleaner.


Repository:
  rC Clang

https://reviews.llvm.org/D47233



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


[PATCH] D52434: [OpenMP] Make default distribute schedule for NVPTX target regions in SPMD mode achieve coalescing

2018-09-27 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC343253: [OpenMP] Make default distribute schedule for NVPTX 
target regions in SPMD mode… (authored by gbercea, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52434?vs=167326=167373#toc

Repository:
  rC Clang

https://reviews.llvm.org/D52434

Files:
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp

Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
@@ -33,7 +33,7 @@
 l = i;
   }
 
-  #pragma omp target teams distribute parallel for simd map(tofrom: aa) num_teams(M) thread_limit(64)
+ #pragma omp target teams distribute parallel for simd map(tofrom: aa) num_teams(M) thread_limit(64)
   for(int i = 0; i < n; i++) {
 aa[i] += 1;
   }
@@ -82,7 +82,7 @@
 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+}}(
 // CHECK-DAG: [[THREAD_LIMIT:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
 // CHECK: call void @__kmpc_spmd_kernel_init(i32 [[THREAD_LIMIT]], i16 0, i16 0)
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 92,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
 // CHECK: {{call|invoke}} void [[OUTL2:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_spmd_kernel_deinit()
@@ -96,7 +96,7 @@
 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+}}(
 // CHECK-DAG: [[THREAD_LIMIT:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
 // CHECK: call void @__kmpc_spmd_kernel_init(i32 [[THREAD_LIMIT]], i16 0, i16 0)
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 92,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
 // CHECK: {{call|invoke}} void [[OUTL3:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_spmd_kernel_deinit()
@@ -112,7 +112,7 @@
 // CHECK-DAG: [[THREAD_LIMIT:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
 // CHECK: call void @__kmpc_spmd_kernel_init(i32 [[THREAD_LIMIT]], i16 0, i16 0)
 // CHECK: store {{.+}} 99, {{.+}}* [[COMB_UB:%.+]], align
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 92, {{.+}}, {{.+}}, {{.+}}* [[COMB_UB]],
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91, {{.+}}, {{.+}}, {{.+}}* [[COMB_UB]],
 // CHECK: {{call|invoke}} void [[OUTL4:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_spmd_kernel_deinit()
Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
@@ -35,7 +35,7 @@
 l = i;
   }
 
-  #pragma omp target teams distribute parallel for map(tofrom: aa) num_teams(M) thread_limit(64)
+#pragma omp target teams distribute parallel for map(tofrom: aa) num_teams(M) thread_limit(64)
   for(int i = 0; i < n; i++) {
 aa[i] += 1;
   }
@@ -87,7 +87,7 @@
 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+}}(
 // CHECK-DAG: [[THREAD_LIMIT:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
 // CHECK: call void @__kmpc_spmd_kernel_init(i32 [[THREAD_LIMIT]], i16 0, i16 0)
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 92,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
 // CHECK: {{call|invoke}} void [[OUTL2:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_spmd_kernel_deinit()
@@ -101,7 +101,7 @@
 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+}}(
 // CHECK-DAG: [[THREAD_LIMIT:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
 // CHECK: call void @__kmpc_spmd_kernel_init(i32 [[THREAD_LIMIT]], i16 0, i16 0)
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 92,
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91,
 // CHECK: {{call|invoke}} void [[OUTL3:@.+]](
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_spmd_kernel_deinit()
@@ -117,7 +117,7 @@
 // CHECK-DAG: [[THREAD_LIMIT:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
 // CHECK: call void @__kmpc_spmd_kernel_init(i32 [[THREAD_LIMIT]], i16 0, i16 0)
 // CHECK: store {{.+}} 99, {{.+}}* [[COMB_UB:%.+]], align
-// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 92, {{.+}}, {{.+}}, {{.+}}* [[COMB_UB]],
+// CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91, {{.+}}, {{.+}}, 

r343253 - [OpenMP] Make default distribute schedule for NVPTX target regions in SPMD mode achieve coalescing

2018-09-27 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Thu Sep 27 12:22:56 2018
New Revision: 343253

URL: http://llvm.org/viewvc/llvm-project?rev=343253=rev
Log:
[OpenMP] Make default distribute schedule for NVPTX target regions in SPMD mode 
achieve coalescing

Summary: For the OpenMP NVPTX toolchain choose a default distribute schedule 
that ensures coalescing on the GPU when in SPMD mode. This significantly 
increases the performance of offloaded target code and reduces the number of 
registers used on the GPU side.

Reviewers: ABataev, caomhin, Hahnfeld

Reviewed By: ABataev, Hahnfeld

Subscribers: Hahnfeld, jholewinski, guansong, cfe-commits

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

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

cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=343253=343252=343253=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Thu Sep 27 12:22:56 2018
@@ -1490,6 +1490,12 @@ public:
   const VarDecl *NativeParam,
   const VarDecl *TargetParam) const;
 
+  /// Choose default schedule type and chunk value for the
+  /// dist_schedule clause.
+  virtual void getDefaultDistScheduleAndChunk(CodeGenFunction ,
+  const OMPLoopDirective , OpenMPDistScheduleClauseKind ,
+  llvm::Value *) const {}
+
   /// Emits call of the outlined function with the provided arguments,
   /// translating these arguments to correct target-specific arguments.
   virtual void

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=343253=343252=343253=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Thu Sep 27 12:22:56 2018
@@ -4081,3 +4081,15 @@ void CGOpenMPRuntimeNVPTX::functionFinis
   FunctionGlobalizedDecls.erase(CGF.CurFn);
   CGOpenMPRuntime::functionFinished(CGF);
 }
+
+void CGOpenMPRuntimeNVPTX::getDefaultDistScheduleAndChunk(
+CodeGenFunction , const OMPLoopDirective ,
+OpenMPDistScheduleClauseKind ,
+llvm::Value *) const {
+  if (getExecutionMode() == CGOpenMPRuntimeNVPTX::EM_SPMD) {
+ScheduleKind = OMPC_DIST_SCHEDULE_static;
+Chunk = CGF.EmitScalarConversion(getNVPTXNumThreads(CGF),
+CGF.getContext().getIntTypeForBitwidth(32, /*Signed=*/0),
+S.getIterationVariable()->getType(), S.getBeginLoc());
+  }
+}

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h?rev=343253=343252=343253=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h Thu Sep 27 12:22:56 2018
@@ -340,6 +340,11 @@ public:
   ///
   void functionFinished(CodeGenFunction ) override;
 
+  /// Choose a default value for the schedule clause.
+  void getDefaultDistScheduleAndChunk(CodeGenFunction ,
+  const OMPLoopDirective , OpenMPDistScheduleClauseKind ,
+  llvm::Value *) const override;
+
 private:
   /// Track the execution mode when codegening directives within a target
   /// region. The appropriate mode (SPMD/NON-SPMD) is set on entry to the

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=343253=343252=343253=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Sep 27 12:22:56 2018
@@ -3325,6 +3325,10 @@ void CodeGenFunction::EmitOMPDistributeL
S.getIterationVariable()->getType(),
S.getBeginLoc());
 }
+  } else {
+// Default behaviour for dist_schedule clause.
+CGM.getOpenMPRuntime().getDefaultDistScheduleAndChunk(
+*this, S, ScheduleKind, Chunk);
   }
   const unsigned IVSize = getContext().getTypeSize(IVExpr->getType());
   const bool IVSigned = 
IVExpr->getType()->hasSignedIntegerRepresentation();

Modified: 
cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
URL: 

[PATCH] D52419: [clangd] Cache FS stat() calls when building preamble.

2018-09-27 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/FS.cpp:29
+PreambleFileStatusCache::lookup(llvm::StringRef File) const {
+  auto I = StatCache.find(File);
+  if (I != StatCache.end())

sammccall wrote:
> ioeric wrote:
> > sammccall wrote:
> > > lock
> > After a second thought, I'm wondering if the mutex is necessary, if the 
> > cache is only updated during preamble build in a single thread. The cache 
> > would also remain the same in preamble reuses.
> Indeed if you have the following sequencing:
> 
>  - one FS writes to the cache from one thread (or several but strictly 
> sequenced)
>  - sequence point (no writes after this point, no reads before)
>  - several FSs read from the cache
> 
> then no lock is required, either for writer or reader.
> The API doesn't particularly suggest this, so please explicitly document the 
> threading model in the header.
> (An API that would suggest it is to e.g. make the producing FS the top-level 
> object, give it a &&-qualified method to retrieve the cache, and give the 
> cache methods to retrieve the consuming FSes. But I think that's awkward here 
> with the VFS interface)
(Stole some wording here. Thanks!)



Comment at: clangd/FS.cpp:53
+  // likely to be cached in the underlying file system anyway.
+  if (auto S = File->get()->status())
+StatCache.update(getUnderlyingFS(), std::move(*S));

sammccall wrote:
> do you want to check if the file is already in the stat cache first?
This would always invalidate status in cache when file is reopened or restated 
in case file status has changed during preamble build. Added a comment.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52419



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


[PATCH] D52419: [clangd] Cache FS stat() calls when building preamble.

2018-09-27 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 167370.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- Address review comments
- address review comments
- address review comments


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52419

Files:
  clangd/CMakeLists.txt
  clangd/ClangdServer.cpp
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/FS.cpp
  clangd/FS.h
  unittests/clangd/CMakeLists.txt
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/FSTests.cpp
  unittests/clangd/TestFS.cpp

Index: unittests/clangd/TestFS.cpp
===
--- unittests/clangd/TestFS.cpp
+++ unittests/clangd/TestFS.cpp
@@ -23,6 +23,7 @@
 llvm::StringMap const ) {
   IntrusiveRefCntPtr MemFS(
   new vfs::InMemoryFileSystem);
+  MemFS->setCurrentWorkingDirectory(testRoot());
   for (auto  : Files) {
 StringRef File = FileAndContents.first();
 MemFS->addFile(
Index: unittests/clangd/FSTests.cpp
===
--- /dev/null
+++ unittests/clangd/FSTests.cpp
@@ -0,0 +1,46 @@
+//===-- FSTests.cpp - File system related tests -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FS.h"
+#include "TestFS.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+TEST(FSTests, PreambleStatusCache) {
+  llvm::StringMap Files;
+  Files["x"] = "";
+  Files["y"] = "";
+  auto FS = buildTestFS(Files);
+  FS->setCurrentWorkingDirectory(testRoot());
+
+  PreambleFileStatusCache StatCache;
+  auto ProduceFS = StatCache.getProducingFS(FS);
+  EXPECT_TRUE(ProduceFS->openFileForRead("x"));
+  EXPECT_TRUE(ProduceFS->status("y"));
+
+  EXPECT_TRUE(StatCache.lookup(testPath("x")).hasValue());
+  EXPECT_TRUE(StatCache.lookup(testPath("y")).hasValue());
+
+  vfs::Status S("fake", llvm::sys::fs::UniqueID(0, 0),
+std::chrono::system_clock::now(), 0, 0, 1024,
+llvm::sys::fs::file_type::regular_file, llvm::sys::fs::all_all);
+  StatCache.update(*FS, S);
+  auto ConsumeFS = StatCache.getConsumingFS(FS);
+  auto Cached = ConsumeFS->status(testPath("fake"));
+  EXPECT_TRUE(Cached);
+  EXPECT_EQ(Cached->getName(), S.getName());
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -963,6 +963,71 @@
Field(::Name, "baz")));
 }
 
+// Check that running code completion doesn't stat() a bunch of files from the
+// preamble again. (They should be using the preamble's stat-cache)
+TEST(ClangdTests, PreambleVFSStatCache) {
+  class ListenStatsFSProvider : public FileSystemProvider {
+  public:
+ListenStatsFSProvider(llvm::StringMap )
+: CountStats(CountStats) {}
+
+IntrusiveRefCntPtr getFileSystem() override {
+  class ListenStatVFS : public vfs::ProxyFileSystem {
+  public:
+ListenStatVFS(IntrusiveRefCntPtr FS,
+  llvm::StringMap )
+: ProxyFileSystem(std::move(FS)), CountStats(CountStats) {}
+
+llvm::ErrorOr>
+openFileForRead(const Twine ) override {
+  ++CountStats[llvm::sys::path::filename(Path.str())];
+  return ProxyFileSystem::openFileForRead(Path);
+}
+llvm::ErrorOr status(const Twine ) override {
+  ++CountStats[llvm::sys::path::filename(Path.str())];
+  return ProxyFileSystem::status(Path);
+}
+
+  private:
+llvm::StringMap 
+  };
+
+  return IntrusiveRefCntPtr(
+  new ListenStatVFS(buildTestFS(Files), CountStats));
+}
+
+// If relative paths are used, they are resolved with testPath().
+llvm::StringMap Files;
+llvm::StringMap 
+  };
+
+  llvm::StringMap CountStats;
+  ListenStatsFSProvider FS(CountStats);
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  auto SourcePath = testPath("foo.cpp");
+  auto HeaderPath = testPath("foo.h");
+  FS.Files[HeaderPath] = "struct TestSym {};";
+  Annotations Code(R"cpp(
+#include "foo.h"
+
+int main() {
+  TestSy^
+})cpp");
+
+  runAddDocument(Server, SourcePath, Code.code());
+
+  EXPECT_EQ(CountStats["foo.h"], 1u);
+  auto Completions = cantFail(runCodeComplete(Server, SourcePath, Code.point(),
+  clangd::CodeCompleteOptions()))
+ .Completions;
+  EXPECT_EQ(CountStats["foo.h"], 

[PATCH] D52589: [clang][ubsan][NFC] Slight test cleanup in preparation for D50901

2018-09-27 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343251: [clang][ubsan][NFC] Slight test cleanup in 
preparation for D50901 (authored by lebedevri, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52589?vs=167245=167367#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52589

Files:
  cfe/trunk/test/CodeGen/catch-implicit-integer-conversions-basics.c
  cfe/trunk/test/CodeGen/catch-implicit-integer-truncations-basics-negatives.c
  cfe/trunk/test/CodeGen/catch-implicit-integer-truncations-basics.c
  cfe/trunk/test/CodeGen/catch-implicit-integer-truncations.c

Index: cfe/trunk/test/CodeGen/catch-implicit-integer-truncations-basics.c
===
--- cfe/trunk/test/CodeGen/catch-implicit-integer-truncations-basics.c
+++ cfe/trunk/test/CodeGen/catch-implicit-integer-truncations-basics.c
@@ -16,116 +16,100 @@
 
 // CHECK-LABEL: @convert_unsigned_int_to_unsigned_int
 unsigned int convert_unsigned_int_to_unsigned_int(unsigned int x) {
-  // CHECK: }
 #line 100
   return x;
 }
 
 // CHECK-LABEL: @convert_unsigned_char_to_unsigned_char
 unsigned char convert_unsigned_char_to_unsigned_char(unsigned char x) {
-  // CHECK: }
 #line 200
   return x;
 }
 
 // CHECK-LABEL: @convert_signed_int_to_signed_int
 signed int convert_signed_int_to_signed_int(signed int x) {
-  // CHECK: }
 #line 300
   return x;
 }
 
 // CHECK-LABEL: @convert_signed_char_to_signed_char
 signed char convert_signed_char_to_signed_char(signed char x) {
-  // CHECK: }
 #line 400
   return x;
 }
 
 // CHECK-LABEL: @convert_unsigned_int_to_unsigned_char
 unsigned char convert_unsigned_int_to_unsigned_char(unsigned int x) {
   // CHECK: call void @__ubsan_handle_implicit_conversion(i8* bitcast ({ {{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_500_TRUNCATION]] to i8*)
-  // CHECK: }
 #line 500
   return x;
 }
 
 // CHECK-LABEL: @convert_unsigned_char_to_unsigned_int
 unsigned int convert_unsigned_char_to_unsigned_int(unsigned char x) {
-  // CHECK: }
 #line 600
   return x;
 }
 
 // CHECK-LABEL: @convert_unsigned_char_to_signed_int
 signed int convert_unsigned_char_to_signed_int(unsigned char x) {
-  // CHECK: }
 #line 700
   return x;
 }
 
 // CHECK-LABEL: @convert_signed_char_to_signed_int
 signed int convert_signed_char_to_signed_int(signed char x) {
-  // CHECK: }
 #line 800
   return x;
 }
 
 // CHECK-LABEL: @convert_unsigned_int_to_signed_int
 signed int convert_unsigned_int_to_signed_int(unsigned int x) {
-  // CHECK: }
 #line 900
   return x;
 }
 
 // CHECK-LABEL: @convert_signed_int_to_unsigned_int
 unsigned int convert_signed_int_to_unsigned_int(signed int x) {
-  // CHECK: }
 #line 1000
   return x;
 }
 
 // CHECK-LABEL: @convert_signed_int_to_unsigned_char
 unsigned char convert_signed_int_to_unsigned_char(signed int x) {
   // CHECK: call void @__ubsan_handle_implicit_conversion(i8* bitcast ({ {{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_1100_TRUNCATION]] to i8*)
-  // CHECK: }
 #line 1100
   return x;
 }
 
 // CHECK-LABEL: @convert_signed_char_to_unsigned_char
 unsigned char convert_signed_char_to_unsigned_char(signed char x) {
-  // CHECK: }
 #line 1200
   return x;
 }
 
 // CHECK-LABEL: @convert_unsigned_char_to_signed_char
 signed char convert_unsigned_char_to_signed_char(unsigned char x) {
-  // CHECK: }
 #line 1300
   return x;
 }
 
 // CHECK-LABEL: @convert_signed_char_to_unsigned_int
 unsigned int convert_signed_char_to_unsigned_int(signed char x) {
-  // CHECK: }
 #line 1400
   return x;
 }
 
 // CHECK-LABEL: @convert_unsigned_int_to_signed_char
 signed char convert_unsigned_int_to_signed_char(unsigned int x) {
   // CHECK: call void @__ubsan_handle_implicit_conversion(i8* bitcast ({ {{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_1500_TRUNCATION]] to i8*)
-  // CHECK: }
 #line 1500
   return x;
 }
 
 // CHECK-LABEL: @convert_signed_int_to_signed_char
 signed char convert_signed_int_to_signed_char(signed int x) {
   // CHECK: call void @__ubsan_handle_implicit_conversion(i8* bitcast ({ {{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_1600_TRUNCATION]] to i8*)
-  // CHECK: }
 #line 1600
   return x;
 }
Index: cfe/trunk/test/CodeGen/catch-implicit-integer-truncations.c
===
--- cfe/trunk/test/CodeGen/catch-implicit-integer-truncations.c
+++ cfe/trunk/test/CodeGen/catch-implicit-integer-truncations.c
@@ -6,16 +6,16 @@
 // CHECK-SANITIZE-ANYRECOVER: @[[UNSIGNED_INT:.*]] = {{.*}} c"'unsigned int'\00" }
 // CHECK-SANITIZE-ANYRECOVER: @[[UNSIGNED_CHAR:.*]] = {{.*}} c"'unsigned char'\00" }
 
-// CHECK-SANITIZE-ANYRECOVER: @[[LINE_100:.*]] = {{.*}}, i32 100, i32 10 }, {{.*}}* @[[UNSIGNED_INT]], {{.*}}* @[[UNSIGNED_CHAR]], i8 0 }
+// CHECK-SANITIZE-ANYRECOVER: @[[LINE_100_TRUNCATION:.*]] = {{.*}}, i32 100, i32 10 }, {{.*}}* @[[UNSIGNED_INT]], {{.*}}* @[[UNSIGNED_CHAR]], i8 0 }
 // CHECK-SANITIZE-ANYRECOVER: 

r343251 - [clang][ubsan][NFC] Slight test cleanup in preparation for D50901

2018-09-27 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Thu Sep 27 12:07:48 2018
New Revision: 343251

URL: http://llvm.org/viewvc/llvm-project?rev=343251=rev
Log:
[clang][ubsan][NFC] Slight test cleanup in preparation for D50901

Reviewers: vsk, vitalybuka, filcab

Reviewed By: vitalybuka

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/CodeGen/catch-implicit-integer-truncations-basics-negatives.c
Modified:
cfe/trunk/test/CodeGen/catch-implicit-integer-conversions-basics.c
cfe/trunk/test/CodeGen/catch-implicit-integer-truncations-basics.c
cfe/trunk/test/CodeGen/catch-implicit-integer-truncations.c

Modified: cfe/trunk/test/CodeGen/catch-implicit-integer-conversions-basics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/catch-implicit-integer-conversions-basics.c?rev=343251=343250=343251=diff
==
--- cfe/trunk/test/CodeGen/catch-implicit-integer-conversions-basics.c 
(original)
+++ cfe/trunk/test/CodeGen/catch-implicit-integer-conversions-basics.c Thu Sep 
27 12:07:48 2018
@@ -16,28 +16,24 @@
 
 // CHECK-LABEL: @convert_unsigned_int_to_unsigned_int
 unsigned int convert_unsigned_int_to_unsigned_int(unsigned int x) {
-  // CHECK: }
 #line 100
   return x;
 }
 
 // CHECK-LABEL: @convert_unsigned_char_to_unsigned_char
 unsigned char convert_unsigned_char_to_unsigned_char(unsigned char x) {
-  // CHECK: }
 #line 200
   return x;
 }
 
 // CHECK-LABEL: @convert_signed_int_to_signed_int
 signed int convert_signed_int_to_signed_int(signed int x) {
-  // CHECK: }
 #line 300
   return x;
 }
 
 // CHECK-LABEL: @convert_signed_char_to_signed_char
 signed char convert_signed_char_to_signed_char(signed char x) {
-  // CHECK: }
 #line 400
   return x;
 }
@@ -45,42 +41,36 @@ signed char convert_signed_char_to_signe
 // CHECK-LABEL: @convert_unsigned_int_to_unsigned_char
 unsigned char convert_unsigned_int_to_unsigned_char(unsigned int x) {
   // CHECK: call void @__ubsan_handle_implicit_conversion(i8* bitcast ({ 
{{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_500_TRUNCATION]] to i8*)
-  // CHECK: }
 #line 500
   return x;
 }
 
 // CHECK-LABEL: @convert_unsigned_char_to_unsigned_int
 unsigned int convert_unsigned_char_to_unsigned_int(unsigned char x) {
-  // CHECK: }
 #line 600
   return x;
 }
 
 // CHECK-LABEL: @convert_unsigned_char_to_signed_int
 signed int convert_unsigned_char_to_signed_int(unsigned char x) {
-  // CHECK: }
 #line 700
   return x;
 }
 
 // CHECK-LABEL: @convert_signed_char_to_signed_int
 signed int convert_signed_char_to_signed_int(signed char x) {
-  // CHECK: }
 #line 800
   return x;
 }
 
 // CHECK-LABEL: @convert_unsigned_int_to_signed_int
 signed int convert_unsigned_int_to_signed_int(unsigned int x) {
-  // CHECK: }
 #line 900
   return x;
 }
 
 // CHECK-LABEL: @convert_signed_int_to_unsigned_int
 unsigned int convert_signed_int_to_unsigned_int(signed int x) {
-  // CHECK: }
 #line 1000
   return x;
 }
@@ -88,28 +78,24 @@ unsigned int convert_signed_int_to_unsig
 // CHECK-LABEL: @convert_signed_int_to_unsigned_char
 unsigned char convert_signed_int_to_unsigned_char(signed int x) {
   // CHECK: call void @__ubsan_handle_implicit_conversion(i8* bitcast ({ 
{{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_1100_TRUNCATION]] to i8*)
-  // CHECK: }
 #line 1100
   return x;
 }
 
 // CHECK-LABEL: @convert_signed_char_to_unsigned_char
 unsigned char convert_signed_char_to_unsigned_char(signed char x) {
-  // CHECK: }
 #line 1200
   return x;
 }
 
 // CHECK-LABEL: @convert_unsigned_char_to_signed_char
 signed char convert_unsigned_char_to_signed_char(unsigned char x) {
-  // CHECK: }
 #line 1300
   return x;
 }
 
 // CHECK-LABEL: @convert_signed_char_to_unsigned_int
 unsigned int convert_signed_char_to_unsigned_int(signed char x) {
-  // CHECK: }
 #line 1400
   return x;
 }
@@ -117,7 +103,6 @@ unsigned int convert_signed_char_to_unsi
 // CHECK-LABEL: @convert_unsigned_int_to_signed_char
 signed char convert_unsigned_int_to_signed_char(unsigned int x) {
   // CHECK: call void @__ubsan_handle_implicit_conversion(i8* bitcast ({ 
{{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_1500_TRUNCATION]] to i8*)
-  // CHECK: }
 #line 1500
   return x;
 }
@@ -125,7 +110,6 @@ signed char convert_unsigned_int_to_sign
 // CHECK-LABEL: @convert_signed_int_to_signed_char
 signed char convert_signed_int_to_signed_char(signed int x) {
   // CHECK: call void @__ubsan_handle_implicit_conversion(i8* bitcast ({ 
{{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_1600_TRUNCATION]] to i8*)
-  // CHECK: }
 #line 1600
   return x;
 }

Added: 
cfe/trunk/test/CodeGen/catch-implicit-integer-truncations-basics-negatives.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/catch-implicit-integer-truncations-basics-negatives.c?rev=343251=auto
==
--- 
cfe/trunk/test/CodeGen/catch-implicit-integer-truncations-basics-negatives.c 

[PATCH] D52617: [clangd] Make stable_partition on include candidates less slow. NFC

2018-09-27 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 167361.
ioeric marked 3 inline comments as done.
ioeric added a comment.

- simplify the code.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52617

Files:
  clangd/CodeComplete.cpp


Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -406,25 +406,27 @@
   Includes.shouldInsertInclude(*ResolvedDeclaring, *ResolvedInserted));
 };
 bool ShouldInsert = C.headerToInsertIfAllowed().hasValue();
-// Calculate include paths and edits for all possible headers.
+// Put includes with insertions after those without.
+llvm::SmallVector 
InsertableCandidates;
+Completion.Includes.reserve(C.RankedIncludeHeaders.size());
+InsertableCandidates.reserve(C.RankedIncludeHeaders.size());
 for (const auto  : C.RankedIncludeHeaders) {
   if (auto ToInclude = Inserted(Inc)) {
 CodeCompletion::IncludeCandidate Include;
 Include.Header = ToInclude->first;
 if (ToInclude->second && ShouldInsert)
   Include.Insertion = Includes.insert(ToInclude->first);
-Completion.Includes.push_back(std::move(Include));
+(Include.Insertion ? InsertableCandidates : Completion.Includes)
+.push_back(std::move(Include));
+
   } else
 log("Failed to generate include insertion edits for adding header "
 "(FileURI='{0}', IncludeHeader='{1}') into {2}",
 C.IndexResult->CanonicalDeclaration.FileURI, Inc, FileName);
 }
-// Prefer includes that do not need edits (i.e. already exist).
-std::stable_partition(Completion.Includes.begin(),
-  Completion.Includes.end(),
-  [](const CodeCompletion::IncludeCandidate ) {
-return !I.Insertion.hasValue();
-  });
+if (!InsertableCandidates.empty())
+  std::move(InsertableCandidates.begin(), InsertableCandidates.end(),
+std::back_inserter(Completion.Includes));
   }
 
   void add(const CompletionCandidate , CodeCompletionString *SemaCCS) {


Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -406,25 +406,27 @@
   Includes.shouldInsertInclude(*ResolvedDeclaring, *ResolvedInserted));
 };
 bool ShouldInsert = C.headerToInsertIfAllowed().hasValue();
-// Calculate include paths and edits for all possible headers.
+// Put includes with insertions after those without.
+llvm::SmallVector InsertableCandidates;
+Completion.Includes.reserve(C.RankedIncludeHeaders.size());
+InsertableCandidates.reserve(C.RankedIncludeHeaders.size());
 for (const auto  : C.RankedIncludeHeaders) {
   if (auto ToInclude = Inserted(Inc)) {
 CodeCompletion::IncludeCandidate Include;
 Include.Header = ToInclude->first;
 if (ToInclude->second && ShouldInsert)
   Include.Insertion = Includes.insert(ToInclude->first);
-Completion.Includes.push_back(std::move(Include));
+(Include.Insertion ? InsertableCandidates : Completion.Includes)
+.push_back(std::move(Include));
+
   } else
 log("Failed to generate include insertion edits for adding header "
 "(FileURI='{0}', IncludeHeader='{1}') into {2}",
 C.IndexResult->CanonicalDeclaration.FileURI, Inc, FileName);
 }
-// Prefer includes that do not need edits (i.e. already exist).
-std::stable_partition(Completion.Includes.begin(),
-  Completion.Includes.end(),
-  [](const CodeCompletion::IncludeCandidate ) {
-return !I.Insertion.hasValue();
-  });
+if (!InsertableCandidates.empty())
+  std::move(InsertableCandidates.begin(), InsertableCandidates.end(),
+std::back_inserter(Completion.Includes));
   }
 
   void add(const CompletionCandidate , CodeCompletionString *SemaCCS) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52574: NFC: Fix some darwin linker warnings introduced in r338385

2018-09-27 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 accepted this revision.
xbolva00 added a comment.
This revision is now accepted and ready to land.

ok, thanks


Repository:
  rC Clang

https://reviews.llvm.org/D52574



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


[PATCH] D52581: [AST] Revert mangling changes from r339428

2018-09-27 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a subscriber: rnk.
smeenai added a comment.

Adding @rnk, since this'll touch MS ABI mangling. For context, we want `struct 
X` to have the same mangling as `@interface X` normally, but we want to be able 
to distinguish them for the purpose of exception handling. See this diff's 
summary for more details.

The simplest option is something like https://reviews.llvm.org/P8109, where we 
add a `.objc` discriminator when mangling the RTTI itself. It would require the 
GNUStep runtime for Windows to be altered accordingly (e.g. 
https://github.com/gnustep/libobjc2/blob/master/eh_win32_msvc.cc#L85 would have 
to use `".objc.PAU"` instead of `".PAU.objc_cls_"`); would that be acceptable, 
@theraven and @DHowett-MSFT?

If we want to keep the Obj-C discriminator as an infix instead of a prefix, 
we'll probably have to keep some state around in the mangler indicating if 
we're mangling for RTTI or not. That seems ugly, but I don't know if there's 
any other way to do it.


Repository:
  rC Clang

https://reviews.llvm.org/D52581



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


[PATCH] D30806: [nonnull] Teach Clang to attach the nonnull LLVM attribute to declarations and calls instead of just definitions, and then teach it to *not* attach such attributes even if the source c

2018-09-27 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.
Herald added a subscriber: sanjoy.

Coming from https://reviews.llvm.org/D50039. This patch was accepted but never 
merged?


https://reviews.llvm.org/D30806



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


[PATCH] D52364: [clangd] Initial supoprt for cross-namespace global code completion.

2018-09-27 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE343248: [clangd] Initial supoprt for cross-namespace 
global code completion. (authored by ioeric, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52364?vs=167356=167357#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52364

Files:
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/index/Index.h
  clangd/index/MemIndex.cpp
  clangd/index/dex/Dex.cpp
  clangd/tool/ClangdMain.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/DexTests.cpp

Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -136,6 +136,15 @@
 "enabled separatedly."),
 llvm::cl::init(true), llvm::cl::Hidden);
 
+static llvm::cl::opt AllScopesCompletion(
+"all-scopes-completion",
+llvm::cl::desc(
+"If set to true, code completion will include index symbols that are "
+"not defined in the scopes (e.g. "
+"namespaces) visible from the code completion point. Such completions "
+"can insert scope qualifiers."),
+llvm::cl::init(false), llvm::cl::Hidden);
+
 static llvm::cl::opt
 ShowOrigins("debug-origin",
 llvm::cl::desc("Show origins of completion items"),
@@ -304,6 +313,7 @@
   }
   CCOpts.SpeculativeIndexRequest = Opts.StaticIndex;
   CCOpts.EnableFunctionArgSnippets = EnableFunctionArgSnippets;
+  CCOpts.AllScopes = AllScopesCompletion;
 
   // Initialize and run ClangdLSPServer.
   ClangdLSPServer LSPServer(
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -44,6 +44,7 @@
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "clang/Sema/Sema.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Error.h"
@@ -330,6 +331,7 @@
 struct CodeCompletionBuilder {
   CodeCompletionBuilder(ASTContext , const CompletionCandidate ,
 CodeCompletionString *SemaCCS,
+llvm::ArrayRef QueryScopes,
 const IncludeInserter , StringRef FileName,
 CodeCompletionContext::Kind ContextKind,
 const CodeCompleteOptions )
@@ -374,6 +376,18 @@
 Completion.Kind = toCompletionItemKind(C.IndexResult->SymInfo.Kind);
   if (Completion.Name.empty())
 Completion.Name = C.IndexResult->Name;
+  // If the completion was visible to Sema, no qualifier is needed. This
+  // avoids unneeded qualifiers in cases like with `using ns::X`.
+  if (Completion.RequiredQualifier.empty() && !C.SemaResult) {
+StringRef ShortestQualifier = C.IndexResult->Scope;
+for (StringRef Scope : QueryScopes) {
+  StringRef Qualifier = C.IndexResult->Scope;
+  if (Qualifier.consume_front(Scope) &&
+  Qualifier.size() < ShortestQualifier.size())
+ShortestQualifier = Qualifier;
+}
+Completion.RequiredQualifier = ShortestQualifier;
+  }
   Completion.Deprecated |= (C.IndexResult->Flags & Symbol::Deprecated);
 }
 
@@ -604,9 +618,11 @@
   }
 };
 
-// Get all scopes that will be queried in indexes.
-std::vector getQueryScopes(CodeCompletionContext ,
-const SourceManager ) {
+// Get all scopes that will be queried in indexes and whether symbols from
+// any scope is allowed.
+std::pair, bool>
+getQueryScopes(CodeCompletionContext , const SourceManager ,
+   const CodeCompleteOptions ) {
   auto GetAllAccessibleScopes = [](CodeCompletionContext ) {
 SpecifiedScope Info;
 for (auto *Context : CCContext.getVisitedContexts()) {
@@ -627,13 +643,15 @@
 // FIXME: Capture scopes and use for scoring, for example,
 //"using namespace std; namespace foo {v^}" =>
 //foo::value > std::vector > boost::variant
-return GetAllAccessibleScopes(CCContext).scopesForIndexQuery();
+auto Scopes = GetAllAccessibleScopes(CCContext).scopesForIndexQuery();
+// Allow AllScopes completion only for there is no explicit scope qualifier.
+return {Scopes, Opts.AllScopes};
   }
 
   // Qualified completion ("std::vec^"), we have two cases depending on whether
   // the qualifier can be resolved by Sema.
   if ((*SS)->isValid()) { // Resolved qualifier.
-return GetAllAccessibleScopes(CCContext).scopesForIndexQuery();
+return {GetAllAccessibleScopes(CCContext).scopesForIndexQuery(), false};
   }
 
   // Unresolved qualifier.
@@ -651,7 +669,7 @@
   if (!Info.UnresolvedQualifier->empty())
 *Info.UnresolvedQualifier += "::";
 
-  return Info.scopesForIndexQuery();
+  return {Info.scopesForIndexQuery(), false};
 }
 
 // Should we perform 

[clang-tools-extra] r343248 - [clangd] Initial supoprt for cross-namespace global code completion.

2018-09-27 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Sep 27 11:46:00 2018
New Revision: 343248

URL: http://llvm.org/viewvc/llvm-project?rev=343248=rev
Log:
[clangd] Initial supoprt for cross-namespace global code completion.

Summary:
When no scope qualifier is specified, allow completing index symbols
from any scope and insert proper automatically. This is still experimental and
hidden behind a flag.

Things missing:
- Scope proximity based scoring.
- FuzzyFind supports weighted scopes.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: kbobyrev, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, 
cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/CodeComplete.h
clang-tools-extra/trunk/clangd/index/Index.h
clang-tools-extra/trunk/clangd/index/MemIndex.cpp
clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
clang-tools-extra/trunk/unittests/clangd/DexTests.cpp

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=343248=343247=343248=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Thu Sep 27 11:46:00 2018
@@ -44,6 +44,7 @@
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "clang/Sema/Sema.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Error.h"
@@ -330,6 +331,7 @@ struct ScoredBundleGreater {
 struct CodeCompletionBuilder {
   CodeCompletionBuilder(ASTContext , const CompletionCandidate ,
 CodeCompletionString *SemaCCS,
+llvm::ArrayRef QueryScopes,
 const IncludeInserter , StringRef FileName,
 CodeCompletionContext::Kind ContextKind,
 const CodeCompleteOptions )
@@ -374,6 +376,18 @@ struct CodeCompletionBuilder {
 Completion.Kind = toCompletionItemKind(C.IndexResult->SymInfo.Kind);
   if (Completion.Name.empty())
 Completion.Name = C.IndexResult->Name;
+  // If the completion was visible to Sema, no qualifier is needed. This
+  // avoids unneeded qualifiers in cases like with `using ns::X`.
+  if (Completion.RequiredQualifier.empty() && !C.SemaResult) {
+StringRef ShortestQualifier = C.IndexResult->Scope;
+for (StringRef Scope : QueryScopes) {
+  StringRef Qualifier = C.IndexResult->Scope;
+  if (Qualifier.consume_front(Scope) &&
+  Qualifier.size() < ShortestQualifier.size())
+ShortestQualifier = Qualifier;
+}
+Completion.RequiredQualifier = ShortestQualifier;
+  }
   Completion.Deprecated |= (C.IndexResult->Flags & Symbol::Deprecated);
 }
 
@@ -604,9 +618,11 @@ struct SpecifiedScope {
   }
 };
 
-// Get all scopes that will be queried in indexes.
-std::vector getQueryScopes(CodeCompletionContext ,
-const SourceManager ) {
+// Get all scopes that will be queried in indexes and whether symbols from
+// any scope is allowed.
+std::pair, bool>
+getQueryScopes(CodeCompletionContext , const SourceManager ,
+   const CodeCompleteOptions ) {
   auto GetAllAccessibleScopes = [](CodeCompletionContext ) {
 SpecifiedScope Info;
 for (auto *Context : CCContext.getVisitedContexts()) {
@@ -627,13 +643,15 @@ std::vector getQueryScopes(
 // FIXME: Capture scopes and use for scoring, for example,
 //"using namespace std; namespace foo {v^}" =>
 //foo::value > std::vector > boost::variant
-return GetAllAccessibleScopes(CCContext).scopesForIndexQuery();
+auto Scopes = GetAllAccessibleScopes(CCContext).scopesForIndexQuery();
+// Allow AllScopes completion only for there is no explicit scope 
qualifier.
+return {Scopes, Opts.AllScopes};
   }
 
   // Qualified completion ("std::vec^"), we have two cases depending on whether
   // the qualifier can be resolved by Sema.
   if ((*SS)->isValid()) { // Resolved qualifier.
-return GetAllAccessibleScopes(CCContext).scopesForIndexQuery();
+return {GetAllAccessibleScopes(CCContext).scopesForIndexQuery(), false};
   }
 
   // Unresolved qualifier.
@@ -651,7 +669,7 @@ std::vector getQueryScopes(
   if (!Info.UnresolvedQualifier->empty())
 *Info.UnresolvedQualifier += "::";
 
-  return Info.scopesForIndexQuery();
+  return {Info.scopesForIndexQuery(), false};
 }
 
 // Should we perform index-based completion in a context of the specified kind?
@@ -1262,8 +1280,10 @@ class CodeCompleteFlow {
   CompletionRecorder *Recorder = nullptr;
   int 

[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth marked 11 inline comments as done.
JonasToth added inline comments.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:68
+if (Start.isInvalid() || Start.isMacroID())
+  return SourceLocation();
+  }

kbobyrev wrote:
> Also, I don't think this should happen with the correct behavior. 
> `llvm::Expected` looks like a better alternative for error handling here.
It currently happens for `typedef int * IntPtr; IntPtr p;`.  Regarding 
`Expected` see other comment.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:278
+  if (!PotentialSnippets)
+return;
+

kbobyrev wrote:
> Both for `PotentialSlices` and `PotentialSnippets`: is there any case where 
> any can not be determined and this is not an error? They both are 
> `llvm::Optional`s and the `check(Result)` just returns if any of them are 
> not set, is there any case when any of the variables is actually not set, but 
> this is the correct behavior? If not, IMO it would be better to use 
> `llvm::Expected`: then, if the check fails, either print `.takeError()` 
> message or propagate it "upstairs" (although I'm not really sure what would 
> be better here).
Currently the `Optional` and checking for invalid and so on everywhere is 
result of the WIP and the bugs I encountered and try to fix. In general the 
operations, like re-lexing can fail judging from the interface, same for 
retrieving SourceLocations, so I took the very conservative approach to check 
everything.
In my opinion it is more user-friendly to just emit the warning, but without 
transformation instead of an error that the transformation fails for some 
reason. Running this check over multiple bigger code-bases will give better 
data to make an actual judgement on this.

In general there are code-constructs where transformation _could_ be dangerous 
or unexpted, all I can think of includes macros.

```
int SomeConfig = 42,
#if BUILD_WITH_X
 AnotherConfig = 43;
#else 
AnotherConfig = 44;
#endif
```

This example is not unreasonable and currently transformed incorrectly. I 
wanted to have an mechanism to just bail if something is fishy. I tried 
`llvm::Expected` but thought that using `llvm::Optional` was just simpler for 
prototyping.
Semantically `Expected` would fit better, because the transformation is 
actually expected to work. Emitting notes that contain information from the 
errors might be user-friendly, but having a `note: Can not automatically 
transform this declaration statement` is probably similarly  informative.
For now I'd stick with `Optional` and it might be even the better fit in 
general, considering that more declaration kinds should be implemented in the 
future (similar to the other, currently staled check).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949



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


[PATCH] D52364: [clangd] Initial supoprt for cross-namespace global code completion.

2018-09-27 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 167356.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- address review comments


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52364

Files:
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/index/Index.h
  clangd/index/MemIndex.cpp
  clangd/index/dex/Dex.cpp
  clangd/tool/ClangdMain.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/DexTests.cpp

Index: unittests/clangd/DexTests.cpp
===
--- unittests/clangd/DexTests.cpp
+++ unittests/clangd/DexTests.cpp
@@ -523,6 +523,17 @@
   EXPECT_THAT(match(*I, Req), UnorderedElementsAre("a::y1"));
 }
 
+TEST(DexTest, WildcardScope) {
+  auto I =
+  Dex::build(generateSymbols({"a::y1", "a::b::y2", "c::y3"}), URISchemes);
+  FuzzyFindRequest Req;
+  Req.Query = "y";
+  Req.Scopes = {"a::"};
+  Req.AnyScope = true;
+  EXPECT_THAT(match(*I, Req),
+  UnorderedElementsAre("a::y1", "a::b::y2", "c::y3"));
+}
+
 TEST(DexTest, IgnoreCases) {
   auto I = Dex::build(generateSymbols({"ns::ABC", "ns::abc"}), URISchemes);
   FuzzyFindRequest Req;
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -2093,6 +2093,57 @@
 Has("bar.h\"", CompletionItemKind::File)));
 }
 
+TEST(CompletionTest, NoAllScopesCompletionWhenQualified) {
+  clangd::CodeCompleteOptions Opts = {};
+  Opts.AllScopes = true;
+
+  auto Results = completions(
+  R"cpp(
+void f() { na::Clangd^ }
+  )cpp",
+  {cls("na::ClangdA"), cls("nx::ClangdX"), cls("Clangd3")}, Opts);
+  EXPECT_THAT(Results.Completions,
+  UnorderedElementsAre(
+  AllOf(Qualifier(""), Scope("na::"), Named("ClangdA";
+}
+
+TEST(CompletionTest, AllScopesCompletion) {
+  clangd::CodeCompleteOptions Opts = {};
+  Opts.AllScopes = true;
+
+  auto Results = completions(
+  R"cpp(
+namespace na {
+void f() { Clangd^ }
+}
+  )cpp",
+  {cls("nx::Clangd1"), cls("ny::Clangd2"), cls("Clangd3"),
+   cls("na::nb::Clangd4")},
+  Opts);
+  EXPECT_THAT(
+  Results.Completions,
+  UnorderedElementsAre(AllOf(Qualifier("nx::"), Named("Clangd1")),
+   AllOf(Qualifier("ny::"), Named("Clangd2")),
+   AllOf(Qualifier(""), Scope(""), Named("Clangd3")),
+   AllOf(Qualifier("nb::"), Named("Clangd4";
+}
+
+TEST(CompletionTest, NoQualifierIfShadowed) {
+  clangd::CodeCompleteOptions Opts = {};
+  Opts.AllScopes = true;
+
+  auto Results = completions(R"cpp(
+namespace nx { class Clangd1 {}; }
+using nx::Clangd1;
+void f() { Clangd^ }
+  )cpp",
+ {cls("nx::Clangd1"), cls("nx::Clangd2")}, Opts);
+  // Although Clangd1 is from another namespace, Sema tells us it's in-scope and
+  // needs no qualifier.
+  EXPECT_THAT(Results.Completions,
+  UnorderedElementsAre(AllOf(Qualifier(""), Named("Clangd1")),
+   AllOf(Qualifier("nx::"), Named("Clangd2";
+}
 
 } // namespace
 } // namespace clangd
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -136,6 +136,15 @@
 "enabled separatedly."),
 llvm::cl::init(true), llvm::cl::Hidden);
 
+static llvm::cl::opt AllScopesCompletion(
+"all-scopes-completion",
+llvm::cl::desc(
+"If set to true, code completion will include index symbols that are "
+"not defined in the scopes (e.g. "
+"namespaces) visible from the code completion point. Such completions "
+"can insert scope qualifiers."),
+llvm::cl::init(false), llvm::cl::Hidden);
+
 static llvm::cl::opt
 ShowOrigins("debug-origin",
 llvm::cl::desc("Show origins of completion items"),
@@ -304,6 +313,7 @@
   }
   CCOpts.SpeculativeIndexRequest = Opts.StaticIndex;
   CCOpts.EnableFunctionArgSnippets = EnableFunctionArgSnippets;
+  CCOpts.AllScopes = AllScopesCompletion;
 
   // Initialize and run ClangdLSPServer.
   ClangdLSPServer LSPServer(
Index: clangd/index/dex/Dex.cpp
===
--- clangd/index/dex/Dex.cpp
+++ clangd/index/dex/Dex.cpp
@@ -13,6 +13,8 @@
 #include "Logger.h"
 #include "Quality.h"
 #include "Trace.h"
+#include "index/Index.h"
+#include "index/dex/Iterator.h"
 #include "llvm/ADT/StringSet.h"
 #include 
 #include 
@@ -166,6 +168,10 @@
 if (It != InvertedIndex.end())
   ScopeIterators.push_back(It->second.iterator());
   }
+  if (Req.AnyScope)
+ScopeIterators.push_back(createBoost(createTrue(Symbols.size()),
+ ScopeIterators.empty() ? 1.0 : 0.2));
+
   // Add OR iterator for scopes if there are any Scope 

[PATCH] D52611: [clangd] Add more tracing to index queries. NFC

2018-09-27 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343247: [clangd] Add more tracing to index queries. NFC 
(authored by ioeric, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52611

Files:
  clang-tools-extra/trunk/clangd/index/MemIndex.cpp
  clang-tools-extra/trunk/clangd/index/Merge.cpp
  clang-tools-extra/trunk/clangd/index/dex/Dex.cpp

Index: clang-tools-extra/trunk/clangd/index/MemIndex.cpp
===
--- clang-tools-extra/trunk/clangd/index/MemIndex.cpp
+++ clang-tools-extra/trunk/clangd/index/MemIndex.cpp
@@ -11,6 +11,7 @@
 #include "FuzzyMatch.h"
 #include "Logger.h"
 #include "Quality.h"
+#include "Trace.h"
 
 namespace clang {
 namespace clangd {
@@ -28,6 +29,7 @@
 llvm::function_ref Callback) const {
   assert(!StringRef(Req.Query).contains("::") &&
  "There must be no :: in query.");
+  trace::Span Tracer("MemIndex fuzzyFind");
 
   TopN> Top(
   Req.Limit ? *Req.Limit : std::numeric_limits::max());
@@ -47,13 +49,16 @@
   if (Top.push({*Score * quality(*Sym), Sym}))
 More = true; // An element with smallest score was discarded.
   }
-  for (const auto  : std::move(Top).items())
+  auto Results = std::move(Top).items();
+  SPAN_ATTACH(Tracer, "results", static_cast(Results.size()));
+  for (const auto  : Results)
 Callback(*Item.second);
   return More;
 }
 
 void MemIndex::lookup(const LookupRequest ,
   llvm::function_ref Callback) const {
+  trace::Span Tracer("MemIndex lookup");
   for (const auto  : Req.IDs) {
 auto I = Index.find(ID);
 if (I != Index.end())
@@ -63,6 +68,7 @@
 
 void MemIndex::refs(const RefsRequest ,
 llvm::function_ref Callback) const {
+  trace::Span Tracer("MemIndex refs");
   for (const auto  : Req.IDs) {
 auto SymRefs = Refs.find(ReqID);
 if (SymRefs == Refs.end())
Index: clang-tools-extra/trunk/clangd/index/Merge.cpp
===
--- clang-tools-extra/trunk/clangd/index/Merge.cpp
+++ clang-tools-extra/trunk/clangd/index/Merge.cpp
@@ -9,6 +9,7 @@
 
 #include "Merge.h"
 #include "Logger.h"
+#include "Trace.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/raw_ostream.h"
@@ -38,19 +39,31 @@
  //a) if it's not in the dynamic slab, yield it directly
  //b) if it's in the dynamic slab, merge it and yield the result
  //  3) now yield all the dynamic symbols we haven't processed.
+ trace::Span Tracer("MergedIndex fuzzyFind");
  bool More = false; // We'll be incomplete if either source was.
  SymbolSlab::Builder DynB;
- More |= Dynamic->fuzzyFind(Req, [&](const Symbol ) { DynB.insert(S); });
+ unsigned DynamicCount = 0;
+ unsigned StaticCount = 0;
+ unsigned MergedCount = 0;
+ More |= Dynamic->fuzzyFind(Req, [&](const Symbol ) {
+   ++DynamicCount;
+   DynB.insert(S);
+ });
  SymbolSlab Dyn = std::move(DynB).build();
 
  DenseSet SeenDynamicSymbols;
  More |= Static->fuzzyFind(Req, [&](const Symbol ) {
auto DynS = Dyn.find(S.ID);
+   ++StaticCount;
if (DynS == Dyn.end())
  return Callback(S);
+   ++MergedCount;
SeenDynamicSymbols.insert(S.ID);
Callback(mergeSymbol(*DynS, S));
  });
+ SPAN_ATTACH(Tracer, "dynamic", DynamicCount);
+ SPAN_ATTACH(Tracer, "static", StaticCount);
+ SPAN_ATTACH(Tracer, "merged", MergedCount);
  for (const Symbol  : Dyn)
if (!SeenDynamicSymbols.count(S.ID))
  Callback(S);
@@ -60,6 +73,7 @@
   void
   lookup(const LookupRequest ,
  llvm::function_ref Callback) const override {
+trace::Span Tracer("MergedIndex lookup");
 SymbolSlab::Builder B;
 
 Dynamic->lookup(Req, [&](const Symbol ) { B.insert(S); });
@@ -80,6 +94,7 @@
 
   void refs(const RefsRequest ,
 llvm::function_ref Callback) const override {
+trace::Span Tracer("MergedIndex refs");
 // We don't want duplicated refs from the static/dynamic indexes,
 // and we can't reliably duplicate them because offsets may differ slightly.
 // We consider the dynamic index authoritative and report all its refs,
Index: clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
===
--- clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
+++ clang-tools-extra/trunk/clangd/index/dex/Dex.cpp
@@ -12,6 +12,7 @@
 #include "FuzzyMatch.h"
 #include "Logger.h"
 #include "Quality.h"
+#include "Trace.h"
 #include "llvm/ADT/StringSet.h"
 #include 
 #include 
@@ -139,6 +140,8 @@
 llvm::function_ref Callback) const {
   assert(!StringRef(Req.Query).contains("::") &&
  "There must be no :: in query.");
+  // FIXME: attach the query tree to the trace span.
+  trace::Span Tracer("Dex fuzzyFind");
   

[clang-tools-extra] r343247 - [clangd] Add more tracing to index queries. NFC

2018-09-27 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Sep 27 11:23:23 2018
New Revision: 343247

URL: http://llvm.org/viewvc/llvm-project?rev=343247=rev
Log:
[clangd] Add more tracing to index queries. NFC

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/index/MemIndex.cpp
clang-tools-extra/trunk/clangd/index/Merge.cpp
clang-tools-extra/trunk/clangd/index/dex/Dex.cpp

Modified: clang-tools-extra/trunk/clangd/index/MemIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/MemIndex.cpp?rev=343247=343246=343247=diff
==
--- clang-tools-extra/trunk/clangd/index/MemIndex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/MemIndex.cpp Thu Sep 27 11:23:23 2018
@@ -11,6 +11,7 @@
 #include "FuzzyMatch.h"
 #include "Logger.h"
 #include "Quality.h"
+#include "Trace.h"
 
 namespace clang {
 namespace clangd {
@@ -28,6 +29,7 @@ bool MemIndex::fuzzyFind(
 llvm::function_ref Callback) const {
   assert(!StringRef(Req.Query).contains("::") &&
  "There must be no :: in query.");
+  trace::Span Tracer("MemIndex fuzzyFind");
 
   TopN> Top(
   Req.Limit ? *Req.Limit : std::numeric_limits::max());
@@ -47,13 +49,16 @@ bool MemIndex::fuzzyFind(
   if (Top.push({*Score * quality(*Sym), Sym}))
 More = true; // An element with smallest score was discarded.
   }
-  for (const auto  : std::move(Top).items())
+  auto Results = std::move(Top).items();
+  SPAN_ATTACH(Tracer, "results", static_cast(Results.size()));
+  for (const auto  : Results)
 Callback(*Item.second);
   return More;
 }
 
 void MemIndex::lookup(const LookupRequest ,
   llvm::function_ref Callback) const 
{
+  trace::Span Tracer("MemIndex lookup");
   for (const auto  : Req.IDs) {
 auto I = Index.find(ID);
 if (I != Index.end())
@@ -63,6 +68,7 @@ void MemIndex::lookup(const LookupReques
 
 void MemIndex::refs(const RefsRequest ,
 llvm::function_ref Callback) const {
+  trace::Span Tracer("MemIndex refs");
   for (const auto  : Req.IDs) {
 auto SymRefs = Refs.find(ReqID);
 if (SymRefs == Refs.end())

Modified: clang-tools-extra/trunk/clangd/index/Merge.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Merge.cpp?rev=343247=343246=343247=diff
==
--- clang-tools-extra/trunk/clangd/index/Merge.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Merge.cpp Thu Sep 27 11:23:23 2018
@@ -9,6 +9,7 @@
 
 #include "Merge.h"
 #include "Logger.h"
+#include "Trace.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/raw_ostream.h"
@@ -38,19 +39,31 @@ class MergedIndex : public SymbolIndex {
  //a) if it's not in the dynamic slab, yield it directly
  //b) if it's in the dynamic slab, merge it and yield the result
  //  3) now yield all the dynamic symbols we haven't processed.
+ trace::Span Tracer("MergedIndex fuzzyFind");
  bool More = false; // We'll be incomplete if either source was.
  SymbolSlab::Builder DynB;
- More |= Dynamic->fuzzyFind(Req, [&](const Symbol ) { DynB.insert(S); });
+ unsigned DynamicCount = 0;
+ unsigned StaticCount = 0;
+ unsigned MergedCount = 0;
+ More |= Dynamic->fuzzyFind(Req, [&](const Symbol ) {
+   ++DynamicCount;
+   DynB.insert(S);
+ });
  SymbolSlab Dyn = std::move(DynB).build();
 
  DenseSet SeenDynamicSymbols;
  More |= Static->fuzzyFind(Req, [&](const Symbol ) {
auto DynS = Dyn.find(S.ID);
+   ++StaticCount;
if (DynS == Dyn.end())
  return Callback(S);
+   ++MergedCount;
SeenDynamicSymbols.insert(S.ID);
Callback(mergeSymbol(*DynS, S));
  });
+ SPAN_ATTACH(Tracer, "dynamic", DynamicCount);
+ SPAN_ATTACH(Tracer, "static", StaticCount);
+ SPAN_ATTACH(Tracer, "merged", MergedCount);
  for (const Symbol  : Dyn)
if (!SeenDynamicSymbols.count(S.ID))
  Callback(S);
@@ -60,6 +73,7 @@ class MergedIndex : public SymbolIndex {
   void
   lookup(const LookupRequest ,
  llvm::function_ref Callback) const override {
+trace::Span Tracer("MergedIndex lookup");
 SymbolSlab::Builder B;
 
 Dynamic->lookup(Req, [&](const Symbol ) { B.insert(S); });
@@ -80,6 +94,7 @@ class MergedIndex : public SymbolIndex {
 
   void refs(const RefsRequest ,
 llvm::function_ref Callback) const override {
+trace::Span Tracer("MergedIndex refs");
 // We don't want duplicated refs from the static/dynamic indexes,
 // and we can't reliably duplicate them because offsets may differ 
slightly.
 // We consider the dynamic index authoritative and report all its refs,

Modified: 

[PATCH] D52423: [analyzer] Make ConversionChecker load StdCLibraryFunctionsChecker

2018-09-27 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

As far as i understand, these driver-controlled thingies are for platform 
owners to be able to say "hey we clearly don't want this checker to be turned 
on on our platform". As long as there's no indication of that sort of issue, we 
should instead keep it all in one place, which is `Checkers.td`. It's already 
hard enough to figure out which checkers are on by default by looking at the 
list of checkers.


Repository:
  rC Clang

https://reviews.llvm.org/D52423



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


[PATCH] D52589: [clang][ubsan][NFC] Slight test cleanup in preparation for D50901

2018-09-27 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Thank you for the review!




Comment at: test/CodeGen/catch-implicit-integer-truncations-basics-negatives.c:7
+////
+// Unsigned case.
+////

vitalybuka wrote:
> This is a new test, not just cleanup?
Kind of both.
The follow-up adds a new tests here, so i have thought it should be split out 
too.


Repository:
  rC Clang

https://reviews.llvm.org/D52589



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


[PATCH] D52589: [clang][ubsan][NFC] Slight test cleanup in preparation for D50901

2018-09-27 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added inline comments.
This revision is now accepted and ready to land.



Comment at: test/CodeGen/catch-implicit-integer-truncations-basics-negatives.c:7
+////
+// Unsigned case.
+////

This is a new test, not just cleanup?


Repository:
  rC Clang

https://reviews.llvm.org/D52589



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


[PATCH] D50318: Support Swift in platform availability attribute

2018-09-27 Thread Jeff Muizelaar via Phabricator via cfe-commits
jrmuizel added a comment.

Review ping


Repository:
  rC Clang

https://reviews.llvm.org/D50318



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


[PATCH] D52619: Fix greedy FileCheck expression in test/Driver/mips-abi.c

2018-09-27 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343240: Fix greedy FileCheck expression in 
test/Driver/mips-abi.c (authored by Hahnfeld, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52619?vs=167344=167350#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52619

Files:
  cfe/trunk/test/Driver/mips-abi.c


Index: cfe/trunk/test/Driver/mips-abi.c
===
--- cfe/trunk/test/Driver/mips-abi.c
+++ cfe/trunk/test/Driver/mips-abi.c
@@ -169,21 +169,21 @@
 // TARGET-O32: "-triple" "mips-unknown-linux-gnu"
 // TARGET-O32: "-target-cpu" "mips32r2"
 // TARGET-O32: "-target-abi" "o32"
-// TARGET-O32: ld{{.*}}"
+// TARGET-O32: ld{{(.exe)?}}"
 // TARGET-O32: "-m" "elf32btsmip"
 
 // RUN: %clang -target mips-linux-gnu -mabi=n32 -### %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=TARGET-N32 %s
 // TARGET-N32: "-triple" "mips64-unknown-linux-gnu"
 // TARGET-N32: "-target-cpu" "mips64r2"
 // TARGET-N32: "-target-abi" "n32"
-// TARGET-N32: ld{{.*}}"
+// TARGET-N32: ld{{(.exe)?}}"
 // TARGET-N32: "-m" "elf32btsmipn32"
 
 // RUN: %clang -target mips-linux-gnu -mabi=64 -### %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=TARGET-N64 %s
 // TARGET-N64: "-triple" "mips64-unknown-linux-gnu"
 // TARGET-N64: "-target-cpu" "mips64r2"
 // TARGET-N64: "-target-abi" "n64"
-// TARGET-N64: ld{{.*}}"
+// TARGET-N64: ld{{(.exe)?}}"
 // TARGET-N64: "-m" "elf64btsmip"


Index: cfe/trunk/test/Driver/mips-abi.c
===
--- cfe/trunk/test/Driver/mips-abi.c
+++ cfe/trunk/test/Driver/mips-abi.c
@@ -169,21 +169,21 @@
 // TARGET-O32: "-triple" "mips-unknown-linux-gnu"
 // TARGET-O32: "-target-cpu" "mips32r2"
 // TARGET-O32: "-target-abi" "o32"
-// TARGET-O32: ld{{.*}}"
+// TARGET-O32: ld{{(.exe)?}}"
 // TARGET-O32: "-m" "elf32btsmip"
 
 // RUN: %clang -target mips-linux-gnu -mabi=n32 -### %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=TARGET-N32 %s
 // TARGET-N32: "-triple" "mips64-unknown-linux-gnu"
 // TARGET-N32: "-target-cpu" "mips64r2"
 // TARGET-N32: "-target-abi" "n32"
-// TARGET-N32: ld{{.*}}"
+// TARGET-N32: ld{{(.exe)?}}"
 // TARGET-N32: "-m" "elf32btsmipn32"
 
 // RUN: %clang -target mips-linux-gnu -mabi=64 -### %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=TARGET-N64 %s
 // TARGET-N64: "-triple" "mips64-unknown-linux-gnu"
 // TARGET-N64: "-target-cpu" "mips64r2"
 // TARGET-N64: "-target-abi" "n64"
-// TARGET-N64: ld{{.*}}"
+// TARGET-N64: ld{{(.exe)?}}"
 // TARGET-N64: "-m" "elf64btsmip"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r343240 - Fix greedy FileCheck expression in test/Driver/mips-abi.c

2018-09-27 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Thu Sep 27 10:27:48 2018
New Revision: 343240

URL: http://llvm.org/viewvc/llvm-project?rev=343240=rev
Log:
Fix greedy FileCheck expression in test/Driver/mips-abi.c

'ld{{.*}}"' seems to match the complete line for me which is failing
the test. Only allow an optional '.exe' for Windows systems as most
other tests do.
Another possibility would be to collapse the greedy expression with
the next check to avoid matching the full line.

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

Modified:
cfe/trunk/test/Driver/mips-abi.c

Modified: cfe/trunk/test/Driver/mips-abi.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-abi.c?rev=343240=343239=343240=diff
==
--- cfe/trunk/test/Driver/mips-abi.c (original)
+++ cfe/trunk/test/Driver/mips-abi.c Thu Sep 27 10:27:48 2018
@@ -169,7 +169,7 @@
 // TARGET-O32: "-triple" "mips-unknown-linux-gnu"
 // TARGET-O32: "-target-cpu" "mips32r2"
 // TARGET-O32: "-target-abi" "o32"
-// TARGET-O32: ld{{.*}}"
+// TARGET-O32: ld{{(.exe)?}}"
 // TARGET-O32: "-m" "elf32btsmip"
 
 // RUN: %clang -target mips-linux-gnu -mabi=n32 -### %s 2>&1 \
@@ -177,7 +177,7 @@
 // TARGET-N32: "-triple" "mips64-unknown-linux-gnu"
 // TARGET-N32: "-target-cpu" "mips64r2"
 // TARGET-N32: "-target-abi" "n32"
-// TARGET-N32: ld{{.*}}"
+// TARGET-N32: ld{{(.exe)?}}"
 // TARGET-N32: "-m" "elf32btsmipn32"
 
 // RUN: %clang -target mips-linux-gnu -mabi=64 -### %s 2>&1 \
@@ -185,5 +185,5 @@
 // TARGET-N64: "-triple" "mips64-unknown-linux-gnu"
 // TARGET-N64: "-target-cpu" "mips64r2"
 // TARGET-N64: "-target-abi" "n64"
-// TARGET-N64: ld{{.*}}"
+// TARGET-N64: ld{{(.exe)?}}"
 // TARGET-N64: "-m" "elf64btsmip"


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


[PATCH] D52584: [analyzer] Highlight nodes which have error reports in them in red in exploded graph

2018-09-27 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC343239: [analyzer] Highlight nodes which have error reports 
in them in red in exploded… (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52584?vs=167234=167349#toc

Repository:
  rC Clang

https://reviews.llvm.org/D52584

Files:
  lib/StaticAnalyzer/Core/ExprEngine.cpp

Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -2953,49 +2953,89 @@
 struct DOTGraphTraits : public DefaultDOTGraphTraits {
   DOTGraphTraits (bool isSimple = false) : DefaultDOTGraphTraits(isSimple) {}
 
-  // FIXME: Since we do not cache error nodes in ExprEngine now, this does not
-  // work.
-  static std::string getNodeAttributes(const ExplodedNode *N,
-   ExplodedGraph *G) {
-if (N->isSink())
-  return "color=red";
-return {};
-  }
-
-  static bool isNodeHidden(const ExplodedNode *N) {
-return N->isTrivial();
+  static bool nodeHasBugReport(const ExplodedNode *N) {
+BugReporter  = static_cast(
+  N->getState()->getStateManager().getOwningEngine())->getBugReporter();
+
+const auto EQClasses =
+llvm::make_range(BR.EQClasses_begin(), BR.EQClasses_end());
+
+for (const auto  : EQClasses) {
+  for (const BugReport  : EQ) {
+if (Report.getErrorNode() == N)
+  return true;
+  }
+}
+return false;
   }
 
-  static std::string getNodeLabel(const ExplodedNode *N, ExplodedGraph *G){
-std::string sbuf;
-llvm::raw_string_ostream Out(sbuf);
-
-// Find the first node which program point and tag has to be included in
-// the output.
+  /// \p PreCallback: callback before break.
+  /// \p PostCallback: callback after break.
+  /// \p Stop: stop iteration if returns {@code true}
+  /// \return Whether {@code Stop} ever returned {@code true}.
+  static bool traverseHiddenNodes(
+  const ExplodedNode *N,
+  llvm::function_ref PreCallback,
+  llvm::function_ref PostCallback,
+  llvm::function_ref Stop) {
 const ExplodedNode *FirstHiddenNode = N;
 while (FirstHiddenNode->pred_size() == 1 &&
isNodeHidden(*FirstHiddenNode->pred_begin())) {
   FirstHiddenNode = *FirstHiddenNode->pred_begin();
 }
-
-ProgramStateRef State = N->getState();
-
-// Dump program point for all the previously skipped nodes.
 const ExplodedNode *OtherNode = FirstHiddenNode;
 while (true) {
-  OtherNode->getLocation().print(/*CR=*/"\\l", Out);
-
-  if (const ProgramPointTag *Tag = OtherNode->getLocation().getTag())
-Out << "\\lTag:" << Tag->getTagDescription();
+  if (Stop(OtherNode))
+return true;
 
   if (OtherNode == N)
 break;
 
   OtherNode = *OtherNode->succ_begin();
+}
+return false;
+  }
 
-  Out << "\\l\\l";
+  static std::string getNodeAttributes(const ExplodedNode *N,
+   ExplodedGraph *G) {
+SmallVector Out;
+auto Noop = [](const ExplodedNode*){};
+if (traverseHiddenNodes(N, Noop, Noop, )) {
+  Out.push_back("style=filled");
+  Out.push_back("fillcolor=red");
 }
 
+if (traverseHiddenNodes(N, Noop, Noop,
+[](const ExplodedNode *C) { return C->isSink(); }))
+  Out.push_back("color=blue");
+return llvm::join(Out, ",");
+  }
+
+  static bool isNodeHidden(const ExplodedNode *N) {
+return N->isTrivial();
+  }
+
+  static std::string getNodeLabel(const ExplodedNode *N, ExplodedGraph *G){
+std::string sbuf;
+llvm::raw_string_ostream Out(sbuf);
+
+ProgramStateRef State = N->getState();
+
+// Dump program point for all the previously skipped nodes.
+traverseHiddenNodes(
+N,
+[&](const ExplodedNode *OtherNode) {
+  OtherNode->getLocation().print(/*CR=*/"\\l", Out);
+  if (const ProgramPointTag *Tag = OtherNode->getLocation().getTag())
+Out << "\\lTag:" << Tag->getTagDescription();
+  if (N->isSink())
+Out << "\\lNode is sink\\l";
+  if (nodeHasBugReport(N))
+Out << "\\lBug report attached\\l";
+},
+[&](const ExplodedNode *OtherNode) { Out << "\\l\\l"; },
+[&](const ExplodedNode *N) { return false; });
+
 Out << "\\l\\|";
 
 Out << "StateID: ST" << State->getID() << ", NodeID: N" << N->getID(G)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r343239 - [analyzer] Highlight nodes which have error reports in them in red in exploded graph

2018-09-27 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Sep 27 10:26:41 2018
New Revision: 343239

URL: http://llvm.org/viewvc/llvm-project?rev=343239=rev
Log:
[analyzer] Highlight nodes which have error reports in them in red in exploded 
graph

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=343239=343238=343239=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Thu Sep 27 10:26:41 2018
@@ -2953,49 +2953,89 @@ template<>
 struct DOTGraphTraits : public DefaultDOTGraphTraits {
   DOTGraphTraits (bool isSimple = false) : DefaultDOTGraphTraits(isSimple) {}
 
-  // FIXME: Since we do not cache error nodes in ExprEngine now, this does not
-  // work.
-  static std::string getNodeAttributes(const ExplodedNode *N,
-   ExplodedGraph *G) {
-if (N->isSink())
-  return "color=red";
-return {};
-  }
-
-  static bool isNodeHidden(const ExplodedNode *N) {
-return N->isTrivial();
+  static bool nodeHasBugReport(const ExplodedNode *N) {
+BugReporter  = static_cast(
+  N->getState()->getStateManager().getOwningEngine())->getBugReporter();
+
+const auto EQClasses =
+llvm::make_range(BR.EQClasses_begin(), BR.EQClasses_end());
+
+for (const auto  : EQClasses) {
+  for (const BugReport  : EQ) {
+if (Report.getErrorNode() == N)
+  return true;
+  }
+}
+return false;
   }
 
-  static std::string getNodeLabel(const ExplodedNode *N, ExplodedGraph *G){
-std::string sbuf;
-llvm::raw_string_ostream Out(sbuf);
-
-// Find the first node which program point and tag has to be included in
-// the output.
+  /// \p PreCallback: callback before break.
+  /// \p PostCallback: callback after break.
+  /// \p Stop: stop iteration if returns {@code true}
+  /// \return Whether {@code Stop} ever returned {@code true}.
+  static bool traverseHiddenNodes(
+  const ExplodedNode *N,
+  llvm::function_ref PreCallback,
+  llvm::function_ref PostCallback,
+  llvm::function_ref Stop) {
 const ExplodedNode *FirstHiddenNode = N;
 while (FirstHiddenNode->pred_size() == 1 &&
isNodeHidden(*FirstHiddenNode->pred_begin())) {
   FirstHiddenNode = *FirstHiddenNode->pred_begin();
 }
-
-ProgramStateRef State = N->getState();
-
-// Dump program point for all the previously skipped nodes.
 const ExplodedNode *OtherNode = FirstHiddenNode;
 while (true) {
-  OtherNode->getLocation().print(/*CR=*/"\\l", Out);
-
-  if (const ProgramPointTag *Tag = OtherNode->getLocation().getTag())
-Out << "\\lTag:" << Tag->getTagDescription();
+  if (Stop(OtherNode))
+return true;
 
   if (OtherNode == N)
 break;
 
   OtherNode = *OtherNode->succ_begin();
+}
+return false;
+  }
 
-  Out << "\\l\\l";
+  static std::string getNodeAttributes(const ExplodedNode *N,
+   ExplodedGraph *G) {
+SmallVector Out;
+auto Noop = [](const ExplodedNode*){};
+if (traverseHiddenNodes(N, Noop, Noop, )) {
+  Out.push_back("style=filled");
+  Out.push_back("fillcolor=red");
 }
 
+if (traverseHiddenNodes(N, Noop, Noop,
+[](const ExplodedNode *C) { return C->isSink(); }))
+  Out.push_back("color=blue");
+return llvm::join(Out, ",");
+  }
+
+  static bool isNodeHidden(const ExplodedNode *N) {
+return N->isTrivial();
+  }
+
+  static std::string getNodeLabel(const ExplodedNode *N, ExplodedGraph *G){
+std::string sbuf;
+llvm::raw_string_ostream Out(sbuf);
+
+ProgramStateRef State = N->getState();
+
+// Dump program point for all the previously skipped nodes.
+traverseHiddenNodes(
+N,
+[&](const ExplodedNode *OtherNode) {
+  OtherNode->getLocation().print(/*CR=*/"\\l", Out);
+  if (const ProgramPointTag *Tag = OtherNode->getLocation().getTag())
+Out << "\\lTag:" << Tag->getTagDescription();
+  if (N->isSink())
+Out << "\\lNode is sink\\l";
+  if (nodeHasBugReport(N))
+Out << "\\lBug report attached\\l";
+},
+[&](const ExplodedNode *OtherNode) { Out << "\\l\\l"; },
+[&](const ExplodedNode *N) { return false; });
+
 Out << "\\l\\|";
 
 Out << "StateID: ST" << State->getID() << ", NodeID: N" << N->getID(G)


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


[PATCH] D52619: Fix greedy FileCheck expression in test/Driver/mips-abi.c

2018-09-27 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D52619



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


[PATCH] D52616: Introduce completionItemKind capability support.

2018-09-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE343237: Introduce completionItemKind capability support. 
(authored by kadircet, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52616?vs=167346=167347#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52616

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/Protocol.cpp
  clangd/Protocol.h

Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -233,13 +233,65 @@
 };
 bool fromJSON(const llvm::json::Value &, CompletionItemClientCapabilities &);
 
+/// The kind of a completion entry.
+enum class CompletionItemKind {
+  Missing = 0,
+  Text = 1,
+  Method = 2,
+  Function = 3,
+  Constructor = 4,
+  Field = 5,
+  Variable = 6,
+  Class = 7,
+  Interface = 8,
+  Module = 9,
+  Property = 10,
+  Unit = 11,
+  Value = 12,
+  Enum = 13,
+  Keyword = 14,
+  Snippet = 15,
+  Color = 16,
+  File = 17,
+  Reference = 18,
+  Folder = 19,
+  EnumMember = 20,
+  Constant = 21,
+  Struct = 22,
+  Event = 23,
+  Operator = 24,
+  TypeParameter = 25,
+};
+bool fromJSON(const llvm::json::Value &, CompletionItemKind &);
+
+struct CompletionItemKindCapabilities {
+  /// The CompletionItemKinds that the client supports. If not set, the client
+  /// only supports <= CompletionItemKind::Reference and will not fall back to a
+  /// valid default value.
+  llvm::Optional> valueSet;
+};
+// Discards unknown CompletionItemKinds.
+bool fromJSON(const llvm::json::Value &, std::vector &);
+bool fromJSON(const llvm::json::Value &, CompletionItemKindCapabilities &);
+
+constexpr auto CompletionItemKindMin =
+static_cast(CompletionItemKind::Text);
+constexpr auto CompletionItemKindMax =
+static_cast(CompletionItemKind::TypeParameter);
+using CompletionItemKindBitset = std::bitset;
+CompletionItemKind
+adjustKindToCapability(CompletionItemKind Kind,
+   CompletionItemKindBitset );
+
 struct CompletionClientCapabilities {
   /// Whether completion supports dynamic registration.
   bool dynamicRegistration = false;
   /// The client supports the following `CompletionItem` specific capabilities.
   CompletionItemClientCapabilities completionItem;
-  // NOTE: not used by clangd at the moment.
-  // llvm::Optional completionItemKind;
+  /// The CompletionItemKinds that the client supports. If not set, the client
+  /// only supports <= CompletionItemKind::Reference and will not fall back to a
+  /// valid default value.
+  llvm::Optional completionItemKind;
 
   /// The client supports to send additional context information for a
   /// `textDocument/completion` request.
@@ -305,6 +357,7 @@
   /// value.
   llvm::Optional> valueSet;
 };
+// Discards unknown SymbolKinds.
 bool fromJSON(const llvm::json::Value &, std::vector &);
 bool fromJSON(const llvm::json::Value &, SymbolKindCapabilities &);
 SymbolKind adjustKindToCapability(SymbolKind Kind,
@@ -683,36 +736,6 @@
 };
 llvm::json::Value toJSON(const Hover );
 
-/// The kind of a completion entry.
-enum class CompletionItemKind {
-  Missing = 0,
-  Text = 1,
-  Method = 2,
-  Function = 3,
-  Constructor = 4,
-  Field = 5,
-  Variable = 6,
-  Class = 7,
-  Interface = 8,
-  Module = 9,
-  Property = 10,
-  Unit = 11,
-  Value = 12,
-  Enum = 13,
-  Keyword = 14,
-  Snippet = 15,
-  Color = 16,
-  File = 17,
-  Reference = 18,
-  Folder = 19,
-  EnumMember = 20,
-  Constant = 21,
-  Struct = 22,
-  Event = 23,
-  Operator = 24,
-  TypeParameter = 25,
-};
-
 /// Defines whether the insert text in a completion item should be interpreted
 /// as plain text or a snippet.
 enum class InsertTextFormat {
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -496,6 +496,57 @@
   return std::move(Result);
 }
 
+bool fromJSON(const json::Value , CompletionItemKind ) {
+  if (auto T = E.getAsInteger()) {
+if (*T < static_cast(CompletionItemKind::Text) ||
+*T > static_cast(CompletionItemKind::TypeParameter))
+  return false;
+Out = static_cast(*T);
+return true;
+  }
+  return false;
+}
+
+CompletionItemKind
+adjustKindToCapability(CompletionItemKind Kind,
+   CompletionItemKindBitset ) {
+  auto KindVal = static_cast(Kind);
+  if (KindVal >= CompletionItemKindMin &&
+  KindVal <= supportedCompletionItemKinds.size() &&
+  supportedCompletionItemKinds[KindVal])
+return Kind;
+
+  switch (Kind) {
+  // Provide some fall backs for common kinds that are close enough.
+  case CompletionItemKind::Folder:
+return CompletionItemKind::File;
+  case CompletionItemKind::EnumMember:
+return CompletionItemKind::Enum;
+  case CompletionItemKind::Struct:
+return CompletionItemKind::Class;
+  default:
+return CompletionItemKind::Text;
+  }
+}
+
+bool fromJSON(const json::Value , std::vector 

[clang-tools-extra] r343237 - Introduce completionItemKind capability support.

2018-09-27 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Thu Sep 27 10:13:07 2018
New Revision: 343237

URL: http://llvm.org/viewvc/llvm-project?rev=343237=rev
Log:
Introduce completionItemKind capability support.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, ioeric, jkorous, arphaman, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdLSPServer.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=343237=343236=343237=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Thu Sep 27 10:13:07 2018
@@ -70,6 +70,14 @@ SymbolKindBitset defaultSymbolKinds() {
   return Defaults;
 }
 
+CompletionItemKindBitset defaultCompletionItemKinds() {
+  CompletionItemKindBitset Defaults;
+  for (size_t I = CompletionItemKindMin;
+   I <= static_cast(CompletionItemKind::Reference); ++I)
+Defaults.set(I);
+  return Defaults;
+}
+
 } // namespace
 
 void ClangdLSPServer::onInitialize(InitializeParams ) {
@@ -89,13 +97,20 @@ void ClangdLSPServer::onInitialize(Initi
   Params.capabilities.textDocument.publishDiagnostics.categorySupport;
 
   if (Params.capabilities.workspace && Params.capabilities.workspace->symbol &&
-  Params.capabilities.workspace->symbol->symbolKind) {
+  Params.capabilities.workspace->symbol->symbolKind &&
+  Params.capabilities.workspace->symbol->symbolKind->valueSet) {
 for (SymbolKind Kind :
  *Params.capabilities.workspace->symbol->symbolKind->valueSet) {
   SupportedSymbolKinds.set(static_cast(Kind));
 }
   }
 
+  if (Params.capabilities.textDocument.completion.completionItemKind &&
+  Params.capabilities.textDocument.completion.completionItemKind->valueSet)
+for (CompletionItemKind Kind : *Params.capabilities.textDocument.completion
+.completionItemKind->valueSet)
+  SupportedCompletionItemKinds.set(static_cast(Kind));
+
   reply(json::Object{
   {{"capabilities",
 json::Object{
@@ -347,8 +362,12 @@ void ClangdLSPServer::onCompletion(TextD
return replyError(List.takeError());
  CompletionList LSPList;
  LSPList.isIncomplete = List->HasMore;
- for (const auto  : List->Completions)
-   LSPList.items.push_back(R.render(CCOpts));
+ for (const auto  : List->Completions) {
+   CompletionItem C = R.render(CCOpts);
+   C.kind = adjustKindToCapability(
+   C.kind, SupportedCompletionItemKinds);
+   LSPList.items.push_back(std::move(C));
+ }
  return reply(std::move(LSPList));
});
 }
@@ -459,6 +478,7 @@ ClangdLSPServer::ClangdLSPServer(JSONOut
  : CompilationDB::makeDirectoryBased(
std::move(CompileCommandsDir))),
   CCOpts(CCOpts), SupportedSymbolKinds(defaultSymbolKinds()),
+  SupportedCompletionItemKinds(defaultCompletionItemKinds()),
   Server(new ClangdServer(CDB.getCDB(), FSProvider, /*DiagConsumer=*/*this,
   Opts)) {}
 

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=343237=343236=343237=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Thu Sep 27 10:13:07 2018
@@ -164,6 +164,8 @@ private:
   ClangdDiagnosticOptions DiagOpts;
   /// The supported kinds of the client.
   SymbolKindBitset SupportedSymbolKinds;
+  /// The supported completion item kinds of the client.
+  CompletionItemKindBitset SupportedCompletionItemKinds;
 
   // Store of the current versions of the open documents.
   DraftStore DraftMgr;

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=343237=343236=343237=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Thu Sep 27 10:13:07 2018
@@ -496,6 +496,57 @@ json::Value toJSON(const Hover ) {
   return std::move(Result);
 }
 
+bool fromJSON(const json::Value , CompletionItemKind ) {
+  if (auto T = 

[PATCH] D52616: Introduce completionItemKind capability support.

2018-09-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 167346.
kadircet marked 3 inline comments as done.
kadircet added a comment.

- Address comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52616

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/Protocol.cpp
  clangd/Protocol.h

Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -233,13 +233,65 @@
 };
 bool fromJSON(const llvm::json::Value &, CompletionItemClientCapabilities &);
 
+/// The kind of a completion entry.
+enum class CompletionItemKind {
+  Missing = 0,
+  Text = 1,
+  Method = 2,
+  Function = 3,
+  Constructor = 4,
+  Field = 5,
+  Variable = 6,
+  Class = 7,
+  Interface = 8,
+  Module = 9,
+  Property = 10,
+  Unit = 11,
+  Value = 12,
+  Enum = 13,
+  Keyword = 14,
+  Snippet = 15,
+  Color = 16,
+  File = 17,
+  Reference = 18,
+  Folder = 19,
+  EnumMember = 20,
+  Constant = 21,
+  Struct = 22,
+  Event = 23,
+  Operator = 24,
+  TypeParameter = 25,
+};
+bool fromJSON(const llvm::json::Value &, CompletionItemKind &);
+
+struct CompletionItemKindCapabilities {
+  /// The CompletionItemKinds that the client supports. If not set, the client
+  /// only supports <= CompletionItemKind::Reference and will not fall back to a
+  /// valid default value.
+  llvm::Optional> valueSet;
+};
+// Discards unknown CompletionItemKinds.
+bool fromJSON(const llvm::json::Value &, std::vector &);
+bool fromJSON(const llvm::json::Value &, CompletionItemKindCapabilities &);
+
+constexpr auto CompletionItemKindMin =
+static_cast(CompletionItemKind::Text);
+constexpr auto CompletionItemKindMax =
+static_cast(CompletionItemKind::TypeParameter);
+using CompletionItemKindBitset = std::bitset;
+CompletionItemKind
+adjustKindToCapability(CompletionItemKind Kind,
+   CompletionItemKindBitset );
+
 struct CompletionClientCapabilities {
   /// Whether completion supports dynamic registration.
   bool dynamicRegistration = false;
   /// The client supports the following `CompletionItem` specific capabilities.
   CompletionItemClientCapabilities completionItem;
-  // NOTE: not used by clangd at the moment.
-  // llvm::Optional completionItemKind;
+  /// The CompletionItemKinds that the client supports. If not set, the client
+  /// only supports <= CompletionItemKind::Reference and will not fall back to a
+  /// valid default value.
+  llvm::Optional completionItemKind;
 
   /// The client supports to send additional context information for a
   /// `textDocument/completion` request.
@@ -305,6 +357,7 @@
   /// value.
   llvm::Optional> valueSet;
 };
+// Discards unknown SymbolKinds.
 bool fromJSON(const llvm::json::Value &, std::vector &);
 bool fromJSON(const llvm::json::Value &, SymbolKindCapabilities &);
 SymbolKind adjustKindToCapability(SymbolKind Kind,
@@ -683,36 +736,6 @@
 };
 llvm::json::Value toJSON(const Hover );
 
-/// The kind of a completion entry.
-enum class CompletionItemKind {
-  Missing = 0,
-  Text = 1,
-  Method = 2,
-  Function = 3,
-  Constructor = 4,
-  Field = 5,
-  Variable = 6,
-  Class = 7,
-  Interface = 8,
-  Module = 9,
-  Property = 10,
-  Unit = 11,
-  Value = 12,
-  Enum = 13,
-  Keyword = 14,
-  Snippet = 15,
-  Color = 16,
-  File = 17,
-  Reference = 18,
-  Folder = 19,
-  EnumMember = 20,
-  Constant = 21,
-  Struct = 22,
-  Event = 23,
-  Operator = 24,
-  TypeParameter = 25,
-};
-
 /// Defines whether the insert text in a completion item should be interpreted
 /// as plain text or a snippet.
 enum class InsertTextFormat {
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -496,6 +496,57 @@
   return std::move(Result);
 }
 
+bool fromJSON(const json::Value , CompletionItemKind ) {
+  if (auto T = E.getAsInteger()) {
+if (*T < static_cast(CompletionItemKind::Text) ||
+*T > static_cast(CompletionItemKind::TypeParameter))
+  return false;
+Out = static_cast(*T);
+return true;
+  }
+  return false;
+}
+
+CompletionItemKind
+adjustKindToCapability(CompletionItemKind Kind,
+   CompletionItemKindBitset ) {
+  auto KindVal = static_cast(Kind);
+  if (KindVal >= CompletionItemKindMin &&
+  KindVal <= supportedCompletionItemKinds.size() &&
+  supportedCompletionItemKinds[KindVal])
+return Kind;
+
+  switch (Kind) {
+  // Provide some fall backs for common kinds that are close enough.
+  case CompletionItemKind::Folder:
+return CompletionItemKind::File;
+  case CompletionItemKind::EnumMember:
+return CompletionItemKind::Enum;
+  case CompletionItemKind::Struct:
+return CompletionItemKind::Class;
+  default:
+return CompletionItemKind::Text;
+  }
+}
+
+bool fromJSON(const json::Value , std::vector ) {
+  if (auto *A = E.getAsArray()) {
+Out.clear();
+for (size_t I = 0; I < A->size(); ++I) {
+  CompletionItemKind 

[PATCH] D52620: Added Support for StatOnly Files in VFS.

2018-09-27 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 created this revision.
Herald added subscribers: cfe-commits, mgrang.

Some files are only Statted by Clang and not read. Clang mostly uses
them for checking the existence of some files and in rare cases uses the
value of the Status to proceed further (for example while loading
module files, it checks the sizes of some files).

This change adds support to represent files that are supposed to be only
statted by Clang.


Repository:
  rC Clang

https://reviews.llvm.org/D52620

Files:
  include/clang/Basic/VirtualFileSystem.h
  lib/Basic/VirtualFileSystem.cpp
  unittests/Basic/VirtualFileSystemTest.cpp

Index: unittests/Basic/VirtualFileSystemTest.cpp
===
--- unittests/Basic/VirtualFileSystemTest.cpp
+++ unittests/Basic/VirtualFileSystemTest.cpp
@@ -553,8 +553,8 @@
   for (DirIter E; !EC && I != E; I.increment(EC))
 InputToCheck.push_back(I->path());
 
-  llvm::sort(InputToCheck);
-  llvm::sort(Expected);
+  llvm::sort(InputToCheck.begin(), InputToCheck.end());
+  llvm::sort(Expected.begin(), Expected.end());
   EXPECT_EQ(InputToCheck.size(), Expected.size());
 
   unsigned LastElt = std::min(InputToCheck.size(), Expected.size());
@@ -1063,15 +1063,50 @@
 TEST_F(InMemoryFileSystemTest, RecursiveIterationWithHardLink) {
   std::error_code EC;
   FS.addFile("/a/b", 0, MemoryBuffer::getMemBuffer("content string"));
+  FS.addStatOnlyFile("/a/d", 0, 10);
   EXPECT_TRUE(FS.addHardLink("/c/d", "/a/b"));
   auto I = vfs::recursive_directory_iterator(FS, "/", EC);
   ASSERT_FALSE(EC);
   std::vector Nodes;
   for (auto E = vfs::recursive_directory_iterator(); !EC && I != E;
I.increment(EC)) {
 Nodes.push_back(getPosixPath(I->path()));
   }
-  EXPECT_THAT(Nodes, testing::UnorderedElementsAre("/a", "/a/b", "/c", "/c/d"));
+  EXPECT_THAT(Nodes, testing::UnorderedElementsAre("/a", "/a/d", "/a/b",
+   "/c", "/c/d"));
+}
+
+TEST_F(InMemoryFileSystemTest, AddStatOnlyFileWithCorrectSize) {
+  FS.addStatOnlyFile("/a/b", 0, 10);
+  auto Stat = FS.status("/a/b");
+  EXPECT_EQ(Stat.get().getSize(), 10);
+}
+
+TEST_F(InMemoryFileSystemTest, AddMultipleFilesUnderStatOnlyFile) {
+  FS.addStatOnlyFile("/a/b", 0, 10);
+  EXPECT_FALSE(FS.addStatOnlyFile("/a/b", 0, 11));
+  EXPECT_TRUE(FS.addStatOnlyFile("/a/b", 0, 10));
+  EXPECT_FALSE(FS.addFile("/a/b", 0, MemoryBuffer::getMemBuffer("content")));
+}
+
+TEST_F(InMemoryFileSystemTest, DeathWhenBufferRequestedForStatOnlyFile) {
+  FS.addStatOnlyFile("/a/b", 0, 10);
+  EXPECT_DEATH(FS.getBufferForFile("/a/b"),
+   "Cannot get buffer for StatOnlyFile");
+}
+
+TEST_F(InMemoryFileSystemTest, AddHardLinksToStatOnlyFile) {
+  FS.addStatOnlyFile("/target", 0, 10);
+  FS.addHardLink("/link1", "/target");
+  FS.addHardLink("/link2", "/link1");
+  EXPECT_THAT("/link1", IsHardLinkTo(, "/target"));
+  EXPECT_THAT("/link2", IsHardLinkTo(, "/target"));
+}
+
+TEST_F(InMemoryFileSystemTest, AddFileUnderHardLinkToStatOnlyFile) {
+  FS.addStatOnlyFile("/target", 0, 10);
+  FS.addHardLink("/link", "/target");
+  EXPECT_FALSE(FS.addFile("/link",  0, MemoryBuffer::getMemBuffer("content")));
 }
 
 // NOTE: in the tests below, we use '//root/' as our root directory, since it is
Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -492,20 +492,26 @@
 class InMemoryFile : public InMemoryNode {
   Status Stat;
   std::unique_ptr Buffer;
+  bool StatOnlyFile;
 
 public:
-  InMemoryFile(Status Stat, std::unique_ptr Buffer)
+  InMemoryFile(Status Stat, std::unique_ptr Buffer,
+   bool StatOnlyFile)
   : InMemoryNode(Stat.getName(), IME_File), Stat(std::move(Stat)),
-Buffer(std::move(Buffer)) {}
+Buffer(std::move(Buffer)), StatOnlyFile(StatOnlyFile) {}
 
   /// Return the \p Status for this node. \p RequestedName should be the name
   /// through which the caller referred to this node. It will override
   /// \p Status::Name in the return value, to mimic the behavior of \p RealFile.
   Status getStatus(StringRef RequestedName) const {
 return Status::copyWithNewName(Stat, RequestedName);
   }
-  llvm::MemoryBuffer *getBuffer() const { return Buffer.get(); }
+  llvm::MemoryBuffer *getBuffer() const {
+assert(!StatOnlyFile && "Cannot get buffer for StatOnlyFile");
+return Buffer.get();
+  }
 
+  bool IsStatOnlyFile() const { return StatOnlyFile; }
   std::string toString(unsigned Indent) const override {
 return (std::string(Indent, ' ') + Stat.getName() + "\n").str();
   }
@@ -640,7 +646,8 @@
  Optional Group,
  Optional Type,
  Optional Perms,
- const detail::InMemoryFile *HardLinkTarget) {
+ const detail::InMemoryFile *HardLinkTarget,
+  

[PATCH] D52419: [clangd] Cache FS stat() calls when building preamble.

2018-09-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/FS.cpp:29
+PreambleFileStatusCache::lookup(llvm::StringRef File) const {
+  auto I = StatCache.find(File);
+  if (I != StatCache.end())

ioeric wrote:
> sammccall wrote:
> > lock
> After a second thought, I'm wondering if the mutex is necessary, if the cache 
> is only updated during preamble build in a single thread. The cache would 
> also remain the same in preamble reuses.
Indeed if you have the following sequencing:

 - one FS writes to the cache from one thread (or several but strictly 
sequenced)
 - sequence point (no writes after this point, no reads before)
 - several FSs read from the cache

then no lock is required, either for writer or reader.
The API doesn't particularly suggest this, so please explicitly document the 
threading model in the header.
(An API that would suggest it is to e.g. make the producing FS the top-level 
object, give it a &&-qualified method to retrieve the cache, and give the cache 
methods to retrieve the consuming FSes. But I think that's awkward here with 
the VFS interface)



Comment at: clangd/FS.cpp:48
+return File;
+  if (auto S = File->get()->status())
+StatCache.update(getUnderlyingFS(), std::move(*S));

ioeric wrote:
> sammccall wrote:
> > I'm not sure I get this: AFAICT (at least on linux) the status is never 
> > available on a newly opened file, so this will always be a stat() call, so 
> > we're just doing the work eagerly and caching it for later. Isn't this just 
> > moving the work around?
> > 
> > I'm sure you've verified this is important somehow, but a comment 
> > explaining how would be much appreciated :-)
> Files opened via `openFileForRead()` wouldn't usually trigger `status()` 
> calls on the wrap FS. And most header files are opened instead of `stat`ed.
> 
> Added comment explaining this.
Ah, OK.
The implementation comment is good, but this is significantly different from 
"caching stat calls" as described in the header files.

Maybe update the comment there: e.g. "Records status information for files 
open()ed or stat()ed during preamble build, so we can avoid stat()s on the 
underlying FS when reusing the preamble"



Comment at: clangd/FS.cpp:53
+  // likely to be cached in the underlying file system anyway.
+  if (auto S = File->get()->status())
+StatCache.update(getUnderlyingFS(), std::move(*S));

do you want to check if the file is already in the stat cache first?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52419



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


[PATCH] D52581: [AST] Revert mangling changes from r339428

2018-09-27 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In https://reviews.llvm.org/D52581#1247409, @theraven wrote:

> > I would have done the same for the GNUstep RTTI here, except I don't 
> > actually
> >  see the code for that anywhere, and no tests seem to break either, so I
> >  believe it's not upstreamed yet.
>
> I'm not sure I understand this comment.  The compiler code is in LLVM and the 
> tests that you've modified are the ones that would fail.  The corresponding 
> code is upstreamed in the runtime, to generate EH metadata for the throw with 
> the same mangling.  If you are going to change the mangling, please make sure 
> that the existing mangling is preserved for EH when compiling for the GNUstep 
> / Microsoft ABI on Windows.
>
> I'm also deeply unconvinced by the idea that it's okay to have a `struct I` 
> in one compilation unit and a `@class I` in another.  The `struct` version 
> will not do any of the correct things with respect to memory management.  
> Code that has this idiom is very likely to be broken.


Ah, it looks like it's sharing the C++ RTTI codepath. What I meant by tests 
specifically was ones like in https://reviews.llvm.org/D47233, where you're 
explicitly checking the RTTI generated for catch handlers. None of the tests 
that I'm modifying in this diff provide that sort of coverage, and no other 
tests break, so we don't have that coverage at all.

The header idiom is used by WebKit among others 
(https://github.com/WebKit/webkit/blob/d68641002aa054fd1f5fdf06d957be3912185e14/Source/WTF/wtf/Compiler.h#L291),
 so I think it's worth giving them the benefit of the doubt.

I'm assuming https://github.com/gnustep/libobjc2/blob/master/eh_win32_msvc.cc 
is the corresponding runtime code. I'll adjust the mangling of RTTI emission 
accordingly, but I also really think you should explicitly add regression tests 
in clang itself for the RTTI emission, otherwise it's liable to break in the 
future as well. (I'll try to add a few basic regression tests if I have the 
time.)


Repository:
  rC Clang

https://reviews.llvm.org/D52581



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


[PATCH] D52364: [clangd] Initial supoprt for cross-namespace global code completion.

2018-09-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clangd/CodeComplete.cpp:1251
+  // from any scope.
+  std::pair, bool> QueryScopes;
   // Include-insertion and proximity scoring rely on the include structure.

consider splitting out AllScopes as a separate variable, and assign 
`std::tie(QueryScopes, AllScopes) = getQueryScopes(...)`, for readability



Comment at: clangd/index/Index.h:432
+  /// wildcard.
+  /// FIXME: support assigning different weight to each scope.
   std::vector Scopes;

ioeric wrote:
> sammccall wrote:
> > May not want a heavyweight API with explicit weights...
> > 
> > I think what we really **need** here is the ability to weight 
> > `clang::clangd::` > `clang::` > `` when you're in the scope of namespace 
> > clangd.
> > 
> > We could just say something like "the primary scope should come first" and 
> > do some FileDistance-like penalizing of the others...
> Changed the wording of `FIXME`.
> 
> > I think what we really need here is the ability to weight clang::clangd:: > 
> > clang:: > `` when you're in the scope of namespace clangd.
> It's unclear what this would mean for scopes from `using-namespace` 
> directives. But we can revisit when we get there.
Yeah, my hypothesis is that it doesn't matter much, as long as the 
using-namespaces are ranked lower than the enclosing namespaces, and above 
"any" namespaces.



Comment at: clangd/index/dex/Dex.cpp:171
   }
+  if (Req.AnyScope)
+ScopeIterators.push_back(createBoost(createTrue(Symbols.size()), 0.2));

kbobyrev wrote:
> Probably also check `!ScopeIterators.empty()`: otherwise the latency might 
> increase for queries without any scope/any scope known to `Dex`.
if there are no other scopes, the "naive" query tree will end up looking like 
and(..., or(boost(true)).

The or() will already be optimized away today.
I'd suggest you just remove the boost() here if req.scopes is empty (or better: 
make the boost 1) and we make "generic optimizations" take care of eliminating 
boosts with value 1, and dropping true when it's an argument to and()


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52364



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


[PATCH] D52617: [clangd] Make stable_partition on include candidates less slow. NFC

2018-09-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/CodeComplete.cpp:325
+CodeCompletion::IncludeCandidates
+moveNonInsertingIncludesToFront(CodeCompletion::IncludeCandidates Includes) {
+  if (Includes.size() <= 1)

this seems a bit overly complicated. It does seem like a worry that this code 
is hot enough to optimize, especially compared to *generating* the list.

But I think we can do something simpler...



Comment at: clangd/CodeComplete.cpp:415
 // Calculate include paths and edits for all possible headers.
+llvm::SmallVector IncludeCandidates;
 for (const auto  : C.RankedIncludeHeaders) {

if this is really hot, you might want to reserve(C.RankedIncludeHeaders.size())



Comment at: clangd/CodeComplete.cpp:422
   Include.Insertion = Includes.insert(ToInclude->first);
-Completion.Includes.push_back(std::move(Include));
+IncludeCandidates.push_back(std::move(Include));
   } else

What about
`(Include.Insertion ? InsertableCandidates : 
IncludeCandidates).push_back(std::move(Include))`

where `InsertableCandidates` is a vector declared above, and then just move it 
onto the end of the list after the loop?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52617



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


[PATCH] D52619: Fix greedy FileCheck expression in test/Driver/mips-abi.c

2018-09-27 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.
Hahnfeld added reviewers: atanasyan, rnk.
Herald added subscribers: cfe-commits, jrtc27, arichardson, sdardis.

`ld{{.*}}"` seems to match the complete line for me which is failing
the test. Only allow an optional `.exe` for Windows systems as most
other tests do.
Another possibility would be to collapse the greedy expression with
the next check to avoid matching the full line.


Repository:
  rC Clang

https://reviews.llvm.org/D52619

Files:
  test/Driver/mips-abi.c


Index: test/Driver/mips-abi.c
===
--- test/Driver/mips-abi.c
+++ test/Driver/mips-abi.c
@@ -169,21 +169,21 @@
 // TARGET-O32: "-triple" "mips-unknown-linux-gnu"
 // TARGET-O32: "-target-cpu" "mips32r2"
 // TARGET-O32: "-target-abi" "o32"
-// TARGET-O32: ld{{.*}}"
+// TARGET-O32: ld{{(.exe)?}}"
 // TARGET-O32: "-m" "elf32btsmip"
 
 // RUN: %clang -target mips-linux-gnu -mabi=n32 -### %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=TARGET-N32 %s
 // TARGET-N32: "-triple" "mips64-unknown-linux-gnu"
 // TARGET-N32: "-target-cpu" "mips64r2"
 // TARGET-N32: "-target-abi" "n32"
-// TARGET-N32: ld{{.*}}"
+// TARGET-N32: ld{{(.exe)?}}"
 // TARGET-N32: "-m" "elf32btsmipn32"
 
 // RUN: %clang -target mips-linux-gnu -mabi=64 -### %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=TARGET-N64 %s
 // TARGET-N64: "-triple" "mips64-unknown-linux-gnu"
 // TARGET-N64: "-target-cpu" "mips64r2"
 // TARGET-N64: "-target-abi" "n64"
-// TARGET-N64: ld{{.*}}"
+// TARGET-N64: ld{{(.exe)?}}"
 // TARGET-N64: "-m" "elf64btsmip"


Index: test/Driver/mips-abi.c
===
--- test/Driver/mips-abi.c
+++ test/Driver/mips-abi.c
@@ -169,21 +169,21 @@
 // TARGET-O32: "-triple" "mips-unknown-linux-gnu"
 // TARGET-O32: "-target-cpu" "mips32r2"
 // TARGET-O32: "-target-abi" "o32"
-// TARGET-O32: ld{{.*}}"
+// TARGET-O32: ld{{(.exe)?}}"
 // TARGET-O32: "-m" "elf32btsmip"
 
 // RUN: %clang -target mips-linux-gnu -mabi=n32 -### %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=TARGET-N32 %s
 // TARGET-N32: "-triple" "mips64-unknown-linux-gnu"
 // TARGET-N32: "-target-cpu" "mips64r2"
 // TARGET-N32: "-target-abi" "n32"
-// TARGET-N32: ld{{.*}}"
+// TARGET-N32: ld{{(.exe)?}}"
 // TARGET-N32: "-m" "elf32btsmipn32"
 
 // RUN: %clang -target mips-linux-gnu -mabi=64 -### %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=TARGET-N64 %s
 // TARGET-N64: "-triple" "mips64-unknown-linux-gnu"
 // TARGET-N64: "-target-cpu" "mips64r2"
 // TARGET-N64: "-target-abi" "n64"
-// TARGET-N64: ld{{.*}}"
+// TARGET-N64: ld{{(.exe)?}}"
 // TARGET-N64: "-m" "elf64btsmip"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52616: Introduce completionItemKind capability support.

2018-09-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clangd/ClangdLSPServer.cpp:108
+  if (Params.capabilities.textDocument.completion.completionItemKind)
+for (CompletionItemKind Kind : *Params.capabilities.textDocument.completion
+.completionItemKind->valueSet)

also check if valueSet is None before dereferencing it?



Comment at: clangd/Protocol.h:265
+};
+
+bool fromJSON(const llvm::json::Value &, CompletionItemKind &);

(nit: drop blank line for consistency)



Comment at: clangd/Protocol.h:274
+};
+bool fromJSON(const llvm::json::Value &, std::vector &);
+bool fromJSON(const llvm::json::Value &, CompletionItemKindCapabilities &);

wasn't obvious why this is necessary vs the default...
Maybe add a comment `// Discards unknown kinds` (and to SymbolKind)?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52616



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


[PATCH] D51686: [OpenMP] Improve search for libomptarget-nvptx

2018-09-27 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC343230: [OpenMP] Improve search for libomptarget-nvptx 
(authored by Hahnfeld, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D51686

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -30,6 +30,22 @@
 
 /// ###
 
+/// Check that -lomptarget-nvptx is passed to nvlink.
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp \
+// RUN:  -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NVLINK %s
+/// Check that the value of --libomptarget-nvptx-path is forwarded to nvlink.
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp \
+// RUN:  --libomptarget-nvptx-path=/path/to/libomptarget/ \
+// RUN:  -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=CHK-NVLINK,CHK-LIBOMPTARGET-NVPTX-PATH %s
+
+// CHK-NVLINK: nvlink
+// CHK-LIBOMPTARGET-NVPTX-PATH-SAME: "-L/path/to/libomptarget/"
+// CHK-NVLINK-SAME: "-lomptarget-nvptx"
+
+/// ###
+
 /// Check cubin file generation and usage by nvlink
 // RUN:   %clang -### -no-canonical-prefixes -target 
powerpc64le-unknown-linux-gnu -fopenmp=libomp \
 // RUN:  -fopenmp-targets=nvptx64-nvidia-cuda -save-temps %s 2>&1 \
@@ -151,6 +167,11 @@
 // RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
 // RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-BCLIB %s
+/// The user can override default detection using --libomptarget-nvptx-path=.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
--libomptarget-nvptx-path=%S/Inputs/libomptarget \
+// RUN:   -Xopenmp-target -march=sm_20 
--cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB %s
 
 // CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}libomptarget-nvptx-sm_20.bc
 // CHK-BCLIB-NOT: {{error:|warning:}}
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -511,6 +511,11 @@
   CmdArgs.push_back("-arch");
   CmdArgs.push_back(Args.MakeArgString(GPUArch));
 
+  // Assume that the directory specified with --libomptarget_nvptx_path
+  // contains the static library libomptarget-nvptx.a.
+  if (const Arg *A = Args.getLastArg(options::OPT_libomptarget_nvptx_path_EQ))
+CmdArgs.push_back(Args.MakeArgString(Twine("-L") + A->getValue()));
+
   // Add paths specified in LIBRARY_PATH environment variable as -L options.
   addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
 
@@ -647,12 +652,9 @@
 
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
 SmallVector LibraryPaths;
-// Add path to lib and/or lib64 folders.
-SmallString<256> DefaultLibPath =
-  llvm::sys::path::parent_path(getDriver().Dir);
-llvm::sys::path::append(DefaultLibPath,
-Twine("lib") + CLANG_LIBDIR_SUFFIX);
-LibraryPaths.emplace_back(DefaultLibPath.c_str());
+
+if (const Arg *A = 
DriverArgs.getLastArg(options::OPT_libomptarget_nvptx_path_EQ))
+  LibraryPaths.push_back(A->getValue());
 
 // Add user defined library paths from LIBRARY_PATH.
 llvm::Optional LibPath =
@@ -665,6 +667,12 @@
 LibraryPaths.emplace_back(Path.trim());
 }
 
+// Add path to lib / lib64 folder.
+SmallString<256> DefaultLibPath =
+llvm::sys::path::parent_path(getDriver().Dir);
+llvm::sys::path::append(DefaultLibPath, Twine("lib") + 
CLANG_LIBDIR_SUFFIX);
+LibraryPaths.emplace_back(DefaultLibPath.c_str());
+
 std::string LibOmpTargetName =
   "libomptarget-nvptx-" + GpuArch.str() + ".bc";
 bool FoundBCLibrary = false;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -596,6 +596,8 @@
   HelpText<"HIP device library">;
 def fhip_dump_offload_linker_script : Flag<["-"], 
"fhip-dump-offload-linker-script">,
   Group, Flags<[NoArgumentUnused, HelpHidden]>;
+def libomptarget_nvptx_path_EQ : Joined<["--"], "libomptarget-nvptx-path=">, 
Group,
+  HelpText<"Path to libomptarget-nvptx libraries">;
 def dA : Flag<["-"], "dA">, Group;
 def dD : Flag<["-"], "dD">, Group, Flags<[CC1Option]>,
   HelpText<"Print macro definitions in -E mode in addition to normal 

Re: [PATCH] D50850: clang: Add triples support for MIPS r6

2018-09-27 Thread YunQiang Su via cfe-commits
I updated N32 patch for clang.
Simon Atanasyan via Phabricator 
于2018年9月27日周四 下午8:23写道:
>
> atanasyan added a comment.
>
> Could you please update the patch against the current trunk?
>
>
> Repository:
>   rC Clang
>
> https://reviews.llvm.org/D50850
>
>
>


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


r343230 - [OpenMP] Improve search for libomptarget-nvptx

2018-09-27 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Thu Sep 27 09:12:32 2018
New Revision: 343230

URL: http://llvm.org/viewvc/llvm-project?rev=343230=rev
Log:
[OpenMP] Improve search for libomptarget-nvptx

When looking for the bclib Clang considered the default library
path first while it preferred directories in LIBRARY_PATH when
constructing the invocation of nvlink. The latter actually makes
more sense because during development it allows using a non-default
runtime library. So change the search for the bclib to start
looking in directories given by LIBRARY_PATH.
Additionally add a new option --libomptarget-nvptx-path= which
will be searched first. This will be handy for testing purposes.

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
cfe/trunk/test/Driver/openmp-offload-gpu.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=343230=343229=343230=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Sep 27 09:12:32 2018
@@ -596,6 +596,8 @@ def hip_device_lib_EQ : Joined<["--"], "
   HelpText<"HIP device library">;
 def fhip_dump_offload_linker_script : Flag<["-"], 
"fhip-dump-offload-linker-script">,
   Group, Flags<[NoArgumentUnused, HelpHidden]>;
+def libomptarget_nvptx_path_EQ : Joined<["--"], "libomptarget-nvptx-path=">, 
Group,
+  HelpText<"Path to libomptarget-nvptx libraries">;
 def dA : Flag<["-"], "dA">, Group;
 def dD : Flag<["-"], "dD">, Group, Flags<[CC1Option]>,
   HelpText<"Print macro definitions in -E mode in addition to normal output">;

Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=343230=343229=343230=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Thu Sep 27 09:12:32 2018
@@ -511,6 +511,11 @@ void NVPTX::OpenMPLinker::ConstructJob(C
   CmdArgs.push_back("-arch");
   CmdArgs.push_back(Args.MakeArgString(GPUArch));
 
+  // Assume that the directory specified with --libomptarget_nvptx_path
+  // contains the static library libomptarget-nvptx.a.
+  if (const Arg *A = Args.getLastArg(options::OPT_libomptarget_nvptx_path_EQ))
+CmdArgs.push_back(Args.MakeArgString(Twine("-L") + A->getValue()));
+
   // Add paths specified in LIBRARY_PATH environment variable as -L options.
   addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
 
@@ -647,12 +652,9 @@ void CudaToolChain::addClangTargetOption
 
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
 SmallVector LibraryPaths;
-// Add path to lib and/or lib64 folders.
-SmallString<256> DefaultLibPath =
-  llvm::sys::path::parent_path(getDriver().Dir);
-llvm::sys::path::append(DefaultLibPath,
-Twine("lib") + CLANG_LIBDIR_SUFFIX);
-LibraryPaths.emplace_back(DefaultLibPath.c_str());
+
+if (const Arg *A = 
DriverArgs.getLastArg(options::OPT_libomptarget_nvptx_path_EQ))
+  LibraryPaths.push_back(A->getValue());
 
 // Add user defined library paths from LIBRARY_PATH.
 llvm::Optional LibPath =
@@ -665,6 +667,12 @@ void CudaToolChain::addClangTargetOption
 LibraryPaths.emplace_back(Path.trim());
 }
 
+// Add path to lib / lib64 folder.
+SmallString<256> DefaultLibPath =
+llvm::sys::path::parent_path(getDriver().Dir);
+llvm::sys::path::append(DefaultLibPath, Twine("lib") + 
CLANG_LIBDIR_SUFFIX);
+LibraryPaths.emplace_back(DefaultLibPath.c_str());
+
 std::string LibOmpTargetName =
   "libomptarget-nvptx-" + GpuArch.str() + ".bc";
 bool FoundBCLibrary = false;

Modified: cfe/trunk/test/Driver/openmp-offload-gpu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openmp-offload-gpu.c?rev=343230=343229=343230=diff
==
--- cfe/trunk/test/Driver/openmp-offload-gpu.c (original)
+++ cfe/trunk/test/Driver/openmp-offload-gpu.c Thu Sep 27 09:12:32 2018
@@ -30,6 +30,22 @@
 
 /// ###
 
+/// Check that -lomptarget-nvptx is passed to nvlink.
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp \
+// RUN:  -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NVLINK %s
+/// Check that the value of --libomptarget-nvptx-path is forwarded to nvlink.
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp \
+// RUN:  --libomptarget-nvptx-path=/path/to/libomptarget/ \
+// RUN:  -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=CHK-NVLINK,CHK-LIBOMPTARGET-NVPTX-PATH %s
+
+// 

[PATCH] D50850: clang: Add triples support for MIPS r6

2018-09-27 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a subscriber: rsmith.
wzssyqa added a comment.

I updated N32 patch for clang.
Simon Atanasyan via Phabricator 
于2018年9月27日周四 下午8:23写道:

> atanasyan added a comment.
> 
> Could you please update the patch against the current trunk?
> 
> Repository:
> 
>   rC Clang
> 
> https://reviews.llvm.org/D50850


Repository:
  rC Clang

https://reviews.llvm.org/D50850



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


[PATCH] D51464: clang: fix MIPS/N32 triple and paths

2018-09-27 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 167340.

https://reviews.llvm.org/D51464

Files:
  lib/Basic/Targets/Mips.h
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp
  test/CodeGen/atomics-inlining.c
  test/CodeGen/mips-zero-sized-struct.c
  test/CodeGen/target-data.c
  test/CodeGen/xray-attributes-supported.cpp
  test/Driver/clang-translation.c

Index: test/Driver/clang-translation.c
===
--- test/Driver/clang-translation.c
+++ test/Driver/clang-translation.c
@@ -330,6 +330,38 @@
 // MIPS64EL: "-target-cpu" "mips64r2"
 // MIPS64EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mips64-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64-GNUABI64 %s
+// MIPS64-GNUABI64: clang
+// MIPS64-GNUABI64: "-cc1"
+// MIPS64-GNUABI64: "-target-cpu" "mips64r2"
+// MIPS64-GNUABI64: "-target-abi" "n64"
+// MIPS64-GNUABI64: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64el-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64EL-GNUABI64 %s
+// MIPS64EL-GNUABI64: clang
+// MIPS64EL-GNUABI64: "-cc1"
+// MIPS64EL-GNUABI64: "-target-cpu" "mips64r2"
+// MIPS64EL-GNUABI64: "-target-abi" "n64"
+// MIPS64EL-GNUABI64: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32 %s
+// MIPSN32: clang
+// MIPSN32: "-cc1"
+// MIPSN32: "-target-cpu" "mips64r2"
+// MIPSN32: "-target-abi" "n32"
+// MIPSN32: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64el-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32EL %s
+// MIPSN32EL: clang
+// MIPSN32EL: "-cc1"
+// MIPSN32EL: "-target-cpu" "mips64r2"
+// MIPSN32EL: "-target-abi" "n32"
+// MIPSN32EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-ANDROID %s
 // MIPS64EL-ANDROID: clang
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- test/CodeGen/xray-attributes-supported.cpp
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -11,6 +11,14 @@
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
 // RUN: -triple mips64el-unknown-linux-gnu | FileCheck %s
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64el-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64-unknown-linux-gnuabin32 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64el-unknown-linux-gnuabin32 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
 // RUN: -triple powerpc64le-unknown-linux-gnu | FileCheck %s
 
 // Make sure that the LLVM attribute for XRay-annotated functions do show up.
Index: test/CodeGen/target-data.c
===
--- test/CodeGen/target-data.c
+++ test/CodeGen/target-data.c
@@ -42,18 +42,34 @@
 // RUN: FileCheck %s -check-prefix=MIPS-64EL
 // MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EL
+// MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -o - -emit-llvm -target-abi n32 \
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
 // MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabin32 -o - -emit-llvm \
+// RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
+// MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
 // MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EB
+// MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s -target-abi n32 \
 // RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
 // MIPS-64EB-N32: target datalayout = "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64-linux-gnuabin32 -o - -emit-llvm %s \
+// RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
+// MIPS-64EB-N32: target datalayout = "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple powerpc64-lv2 

[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:343
+  auto Diag =
+  diag(WholeDecl->getBeginLoc(), "this statement declares %0 variables")
+  << static_cast(

JonasToth wrote:
> kbobyrev wrote:
> > aaron.ballman wrote:
> > > lebedev.ri wrote:
> > > > kbobyrev wrote:
> > > > > JonasToth wrote:
> > > > > > kbobyrev wrote:
> > > > > > > How about `multiple declarations within a single statement hurts 
> > > > > > > readability`?
> > > > > > s/hurts/reduces/? hurts sound a bit weird i think.
> > > > > > 
> > > > > > Lebedev wanted the number of decls in the diagnostic, would you 
> > > > > > include it or rather now?
> > > > > "decreases" is also fine. "hurts" is probably too strong, I agree.
> > > > > 
> > > > > Up to you. Personally, I don't see any value in having the diagnostic 
> > > > > message saying "hey, you have 2 declarations within one statement, 
> > > > > that's really bad!" or "hey, you have 5 declarations within one 
> > > > > statement..." - in both cases the point is that there are *multiple* 
> > > > > declarations. I also don't think it would make debugging easier 
> > > > > because you also check the formatting, so you already imply that the 
> > > > > correct number of declarations was detected.
> > > > > 
> > > > > I'm interested to know what @lebedev.ri thinks.
> > > > > I'm interested to know what @lebedev.ri thinks.
> > > > 
> > > > "This translation unit has an error. Can not continue" is also a 
> > > > diagnostic message.
> > > > Why are we not ok with that one, and want compiler to be a bit more 
> > > > specific?
> > > > 
> > > > Similarly here, why just point out that this code is bad as per the 
> > > > check,
> > > > without giving a little bit more info, that you already have?
> > > > "This translation unit has an error. Can not continue" is also a 
> > > > diagnostic message.
> > > >Why are we not ok with that one, and want compiler to be a bit more 
> > > >specific?
> > > >
> > > > Similarly here, why just point out that this code is bad as per the 
> > > > check, without giving a little bit more info, that you already have?
> > > 
> > > More information doesn't always equate into more understanding, 
> > > especially when that information causes a distraction. For instance, you 
> > > could argue that the type of the declared variables is also information 
> > > we already have, but what purpose would it serve to tell it to the user?
> > > 
> > > Can you give an example where the specific number of declarations 
> > > involved would help you to correct the diagnostic? I can't come up with 
> > > one, so it feels to me like having the count is more of a distraction; 
> > > especially given that there's no configurable threshold for "now you have 
> > > too many declarations". I'd feel differently if there was a config 
> > > option, because then the count is truly useful to know.
> > Oh, but that's different: "This translation unit has an error. Can not 
> > continue" does not provide enough information for users to fix the issue, 
> > pointing out that there are *multiple* declarations per statement is 
> > definitely enough.
> I am personally against having the number in the diagnostic as well, it would 
> only add value if the declarations are expanded from a macro.
> 
> @aaron.ballman Configuration of this check would be intersting but i would 
> rather postpone that and have a basic working check first. Given that this 
> aims to be utility-like to evaluate `const-correctness` and/or to be usable 
> with other checks doing type transformations.
Yeah, I wasn't suggesting a threshold config option for this patch so much as 
pointing out why I'm opposed to putting the count in the diagnostic.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949



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


[PATCH] D52611: [clangd] Add more tracing to index queries. NFC

2018-09-27 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 167336.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- address comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52611

Files:
  clangd/index/MemIndex.cpp
  clangd/index/Merge.cpp
  clangd/index/dex/Dex.cpp

Index: clangd/index/dex/Dex.cpp
===
--- clangd/index/dex/Dex.cpp
+++ clangd/index/dex/Dex.cpp
@@ -12,6 +12,7 @@
 #include "FuzzyMatch.h"
 #include "Logger.h"
 #include "Quality.h"
+#include "Trace.h"
 #include "llvm/ADT/StringSet.h"
 #include 
 #include 
@@ -139,6 +140,8 @@
 llvm::function_ref Callback) const {
   assert(!StringRef(Req.Query).contains("::") &&
  "There must be no :: in query.");
+  // FIXME: attach the query tree to the trace span.
+  trace::Span Tracer("Dex fuzzyFind");
   FuzzyMatcher Filter(Req.Query);
   bool More = false;
 
@@ -228,6 +231,7 @@
 
 void Dex::lookup(const LookupRequest ,
  llvm::function_ref Callback) const {
+  trace::Span Tracer("Dex lookup");
   for (const auto  : Req.IDs) {
 auto I = LookupTable.find(ID);
 if (I != LookupTable.end())
@@ -237,6 +241,7 @@
 
 void Dex::refs(const RefsRequest ,
llvm::function_ref Callback) const {
+  trace::Span Tracer("Dex refs");
   log("refs is not implemented.");
 }
 
Index: clangd/index/Merge.cpp
===
--- clangd/index/Merge.cpp
+++ clangd/index/Merge.cpp
@@ -9,6 +9,7 @@
 
 #include "Merge.h"
 #include "Logger.h"
+#include "Trace.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/raw_ostream.h"
@@ -38,19 +39,31 @@
  //a) if it's not in the dynamic slab, yield it directly
  //b) if it's in the dynamic slab, merge it and yield the result
  //  3) now yield all the dynamic symbols we haven't processed.
+ trace::Span Tracer("MergedIndex fuzzyFind");
  bool More = false; // We'll be incomplete if either source was.
  SymbolSlab::Builder DynB;
- More |= Dynamic->fuzzyFind(Req, [&](const Symbol ) { DynB.insert(S); });
+ unsigned DynamicCount = 0;
+ unsigned StaticCount = 0;
+ unsigned MergedCount = 0;
+ More |= Dynamic->fuzzyFind(Req, [&](const Symbol ) {
+   ++DynamicCount;
+   DynB.insert(S);
+ });
  SymbolSlab Dyn = std::move(DynB).build();
 
  DenseSet SeenDynamicSymbols;
  More |= Static->fuzzyFind(Req, [&](const Symbol ) {
auto DynS = Dyn.find(S.ID);
+   ++StaticCount;
if (DynS == Dyn.end())
  return Callback(S);
+   ++MergedCount;
SeenDynamicSymbols.insert(S.ID);
Callback(mergeSymbol(*DynS, S));
  });
+ SPAN_ATTACH(Tracer, "dynamic", DynamicCount);
+ SPAN_ATTACH(Tracer, "static", StaticCount);
+ SPAN_ATTACH(Tracer, "merged", MergedCount);
  for (const Symbol  : Dyn)
if (!SeenDynamicSymbols.count(S.ID))
  Callback(S);
@@ -60,6 +73,7 @@
   void
   lookup(const LookupRequest ,
  llvm::function_ref Callback) const override {
+trace::Span Tracer("MergedIndex lookup");
 SymbolSlab::Builder B;
 
 Dynamic->lookup(Req, [&](const Symbol ) { B.insert(S); });
@@ -80,6 +94,7 @@
 
   void refs(const RefsRequest ,
 llvm::function_ref Callback) const override {
+trace::Span Tracer("MergedIndex refs");
 // We don't want duplicated refs from the static/dynamic indexes,
 // and we can't reliably duplicate them because offsets may differ slightly.
 // We consider the dynamic index authoritative and report all its refs,
Index: clangd/index/MemIndex.cpp
===
--- clangd/index/MemIndex.cpp
+++ clangd/index/MemIndex.cpp
@@ -11,6 +11,7 @@
 #include "FuzzyMatch.h"
 #include "Logger.h"
 #include "Quality.h"
+#include "Trace.h"
 
 namespace clang {
 namespace clangd {
@@ -28,6 +29,7 @@
 llvm::function_ref Callback) const {
   assert(!StringRef(Req.Query).contains("::") &&
  "There must be no :: in query.");
+  trace::Span Tracer("MemIndex fuzzyFind");
 
   TopN> Top(
   Req.Limit ? *Req.Limit : std::numeric_limits::max());
@@ -47,13 +49,16 @@
   if (Top.push({*Score * quality(*Sym), Sym}))
 More = true; // An element with smallest score was discarded.
   }
-  for (const auto  : std::move(Top).items())
+  auto Results = std::move(Top).items();
+  SPAN_ATTACH(Tracer, "results", static_cast(Results.size()));
+  for (const auto  : Results)
 Callback(*Item.second);
   return More;
 }
 
 void MemIndex::lookup(const LookupRequest ,
   llvm::function_ref Callback) const {
+  trace::Span Tracer("MemIndex lookup");
   for (const auto  : Req.IDs) {
 auto I = Index.find(ID);
 if (I != Index.end())
@@ -63,6 +68,7 @@
 
 void MemIndex::refs(const RefsRequest ,
 llvm::function_ref Callback) const {
+  trace::Span 

[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:343
+  auto Diag =
+  diag(WholeDecl->getBeginLoc(), "this statement declares %0 variables")
+  << static_cast(

kbobyrev wrote:
> aaron.ballman wrote:
> > lebedev.ri wrote:
> > > kbobyrev wrote:
> > > > JonasToth wrote:
> > > > > kbobyrev wrote:
> > > > > > How about `multiple declarations within a single statement hurts 
> > > > > > readability`?
> > > > > s/hurts/reduces/? hurts sound a bit weird i think.
> > > > > 
> > > > > Lebedev wanted the number of decls in the diagnostic, would you 
> > > > > include it or rather now?
> > > > "decreases" is also fine. "hurts" is probably too strong, I agree.
> > > > 
> > > > Up to you. Personally, I don't see any value in having the diagnostic 
> > > > message saying "hey, you have 2 declarations within one statement, 
> > > > that's really bad!" or "hey, you have 5 declarations within one 
> > > > statement..." - in both cases the point is that there are *multiple* 
> > > > declarations. I also don't think it would make debugging easier because 
> > > > you also check the formatting, so you already imply that the correct 
> > > > number of declarations was detected.
> > > > 
> > > > I'm interested to know what @lebedev.ri thinks.
> > > > I'm interested to know what @lebedev.ri thinks.
> > > 
> > > "This translation unit has an error. Can not continue" is also a 
> > > diagnostic message.
> > > Why are we not ok with that one, and want compiler to be a bit more 
> > > specific?
> > > 
> > > Similarly here, why just point out that this code is bad as per the check,
> > > without giving a little bit more info, that you already have?
> > > "This translation unit has an error. Can not continue" is also a 
> > > diagnostic message.
> > >Why are we not ok with that one, and want compiler to be a bit more 
> > >specific?
> > >
> > > Similarly here, why just point out that this code is bad as per the 
> > > check, without giving a little bit more info, that you already have?
> > 
> > More information doesn't always equate into more understanding, especially 
> > when that information causes a distraction. For instance, you could argue 
> > that the type of the declared variables is also information we already 
> > have, but what purpose would it serve to tell it to the user?
> > 
> > Can you give an example where the specific number of declarations involved 
> > would help you to correct the diagnostic? I can't come up with one, so it 
> > feels to me like having the count is more of a distraction; especially 
> > given that there's no configurable threshold for "now you have too many 
> > declarations". I'd feel differently if there was a config option, because 
> > then the count is truly useful to know.
> Oh, but that's different: "This translation unit has an error. Can not 
> continue" does not provide enough information for users to fix the issue, 
> pointing out that there are *multiple* declarations per statement is 
> definitely enough.
I am personally against having the number in the diagnostic as well, it would 
only add value if the declarations are expanded from a macro.

@aaron.ballman Configuration of this check would be intersting but i would 
rather postpone that and have a basic working check first. Given that this aims 
to be utility-like to evaluate `const-correctness` and/or to be usable with 
other checks doing type transformations.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949



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


[PATCH] D52595: [ARM] Alter test to account for change to armv6k default CPU

2018-09-27 Thread Renato Golin via Phabricator via cfe-commits
rengolin accepted this revision.
rengolin added a comment.
This revision is now accepted and ready to land.

Thanks Peter. LGTM!


https://reviews.llvm.org/D52595



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


[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

There are testcases with macro around line 100 in the default tests. I
am not sure yet if `#define I_DECLS int i1, i2, i3;` should be
diagnosed, but the other cases should.

Am 27.09.2018 um 16:28 schrieb Kirill Bobyrev via Phabricator:

> kbobyrev added a comment.
> 
> Also, regarding error handling and `llvm::Option` vs `llvm::Expected`: I 
> think the case where the check most likely wouldn't be able to provide useful 
> diagnostics and perform enough analysis is when there are macro expansions 
> within inspected statement `SourceRange`. It might make sense to completely 
> disable it in this case both because it's hard to do anything about the range 
> transformation and because it seems to be hard to analyze this case. E.g. if 
> the whole statement is expanded from a single macro and then the check would 
> report on every macro usage (while the actual problem is in the macro 
> itself). I don't know whether the check should support macros at all, it 
> might make sense to mention this in the documentation and add few tests if we 
> decide to go this way.
> 
> Repository:
> 
>   rCTE Clang Tools Extra
> 
> https://reviews.llvm.org/D51949


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949



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


[PATCH] D52423: [analyzer] Make ConversionChecker load StdCLibraryFunctionsChecker

2018-09-27 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy added a comment.

Yes, moving StdCLibraryFunctionsChecker to an always-loaded package is probably 
a better solution than adding this one particular dependency link. (Evaluating 
these functions may be useful for other checkers as well, although it does not 
seem to change the results of other regression tests.) As an alternative to 
moving this checker to either the core or the apiModeling package, we could add 
unix.StdCLibraryFunctions to the dozen or so loaded-by-default checkers listed 
in lib/Driver/ToolChains/Clang.cpp without moving it to a different package. 
Which of these options is the best?


Repository:
  rC Clang

https://reviews.llvm.org/D52423



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


[PATCH] D52617: [clangd] Make stable_partition on include candidates less slow. NFC

2018-09-27 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: sammccall.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.

stable_partition on objects is slow (due to copies). Do it on pointers
instead.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52617

Files:
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h


Index: clangd/CodeComplete.h
===
--- clangd/CodeComplete.h
+++ clangd/CodeComplete.h
@@ -145,7 +145,8 @@
   // include is used.
   // If we've bundled together overloads that have different sets of includes,
   // thse includes may not be accurate for all of them.
-  llvm::SmallVector Includes;
+  using IncludeCandidates = llvm::SmallVector;
+  IncludeCandidates Includes;
 
   /// Holds information about small corrections that needs to be done. Like
   /// converting '->' to '.' on member access.
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -320,6 +320,25 @@
   }
 };
 
+// Moves includes that do not need edits (i.e. already exist) to the front.
+CodeCompletion::IncludeCandidates
+moveNonInsertingIncludesToFront(CodeCompletion::IncludeCandidates Includes) {
+  if (Includes.size() <= 1)
+return Includes;
+  // stable_partition on objects is slow. Do it on pointers instead.
+  llvm::SmallVector Pointers;
+  for (auto  : Includes)
+Pointers.push_back();
+  std::stable_partition(Pointers.begin(), Pointers.end(),
+[](const CodeCompletion::IncludeCandidate *I) {
+  return !I->Insertion.hasValue();
+});
+  CodeCompletion::IncludeCandidates Results;
+  for (auto *Inc : Pointers)
+Results.push_back(std::move(*Inc));
+  return Results;
+}
+
 // Assembles a code completion out of a bundle of >=1 completion candidates.
 // Many of the expensive strings are only computed at this point, once we know
 // the candidate bundle is going to be returned.
@@ -393,24 +412,21 @@
 };
 bool ShouldInsert = C.headerToInsertIfAllowed().hasValue();
 // Calculate include paths and edits for all possible headers.
+llvm::SmallVector IncludeCandidates;
 for (const auto  : C.RankedIncludeHeaders) {
   if (auto ToInclude = Inserted(Inc)) {
 CodeCompletion::IncludeCandidate Include;
 Include.Header = ToInclude->first;
 if (ToInclude->second && ShouldInsert)
   Include.Insertion = Includes.insert(ToInclude->first);
-Completion.Includes.push_back(std::move(Include));
+IncludeCandidates.push_back(std::move(Include));
   } else
 log("Failed to generate include insertion edits for adding header "
 "(FileURI='{0}', IncludeHeader='{1}') into {2}",
 C.IndexResult->CanonicalDeclaration.FileURI, Inc, FileName);
 }
-// Prefer includes that do not need edits (i.e. already exist).
-std::stable_partition(Completion.Includes.begin(),
-  Completion.Includes.end(),
-  [](const CodeCompletion::IncludeCandidate ) {
-return !I.Insertion.hasValue();
-  });
+Completion.Includes =
+moveNonInsertingIncludesToFront(std::move(IncludeCandidates));
   }
 
   void add(const CompletionCandidate , CodeCompletionString *SemaCCS) {


Index: clangd/CodeComplete.h
===
--- clangd/CodeComplete.h
+++ clangd/CodeComplete.h
@@ -145,7 +145,8 @@
   // include is used.
   // If we've bundled together overloads that have different sets of includes,
   // thse includes may not be accurate for all of them.
-  llvm::SmallVector Includes;
+  using IncludeCandidates = llvm::SmallVector;
+  IncludeCandidates Includes;
 
   /// Holds information about small corrections that needs to be done. Like
   /// converting '->' to '.' on member access.
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -320,6 +320,25 @@
   }
 };
 
+// Moves includes that do not need edits (i.e. already exist) to the front.
+CodeCompletion::IncludeCandidates
+moveNonInsertingIncludesToFront(CodeCompletion::IncludeCandidates Includes) {
+  if (Includes.size() <= 1)
+return Includes;
+  // stable_partition on objects is slow. Do it on pointers instead.
+  llvm::SmallVector Pointers;
+  for (auto  : Includes)
+Pointers.push_back();
+  std::stable_partition(Pointers.begin(), Pointers.end(),
+[](const CodeCompletion::IncludeCandidate *I) {
+  return !I->Insertion.hasValue();
+});
+  CodeCompletion::IncludeCandidates Results;
+  for (auto *Inc : Pointers)
+Results.push_back(std::move(*Inc));
+  return Results;
+}
+
 // 

[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:343
+  auto Diag =
+  diag(WholeDecl->getBeginLoc(), "this statement declares %0 variables")
+  << static_cast(

aaron.ballman wrote:
> lebedev.ri wrote:
> > kbobyrev wrote:
> > > JonasToth wrote:
> > > > kbobyrev wrote:
> > > > > How about `multiple declarations within a single statement hurts 
> > > > > readability`?
> > > > s/hurts/reduces/? hurts sound a bit weird i think.
> > > > 
> > > > Lebedev wanted the number of decls in the diagnostic, would you include 
> > > > it or rather now?
> > > "decreases" is also fine. "hurts" is probably too strong, I agree.
> > > 
> > > Up to you. Personally, I don't see any value in having the diagnostic 
> > > message saying "hey, you have 2 declarations within one statement, that's 
> > > really bad!" or "hey, you have 5 declarations within one statement..." - 
> > > in both cases the point is that there are *multiple* declarations. I also 
> > > don't think it would make debugging easier because you also check the 
> > > formatting, so you already imply that the correct number of declarations 
> > > was detected.
> > > 
> > > I'm interested to know what @lebedev.ri thinks.
> > > I'm interested to know what @lebedev.ri thinks.
> > 
> > "This translation unit has an error. Can not continue" is also a diagnostic 
> > message.
> > Why are we not ok with that one, and want compiler to be a bit more 
> > specific?
> > 
> > Similarly here, why just point out that this code is bad as per the check,
> > without giving a little bit more info, that you already have?
> > "This translation unit has an error. Can not continue" is also a diagnostic 
> > message.
> >Why are we not ok with that one, and want compiler to be a bit more specific?
> >
> > Similarly here, why just point out that this code is bad as per the check, 
> > without giving a little bit more info, that you already have?
> 
> More information doesn't always equate into more understanding, especially 
> when that information causes a distraction. For instance, you could argue 
> that the type of the declared variables is also information we already have, 
> but what purpose would it serve to tell it to the user?
> 
> Can you give an example where the specific number of declarations involved 
> would help you to correct the diagnostic? I can't come up with one, so it 
> feels to me like having the count is more of a distraction; especially given 
> that there's no configurable threshold for "now you have too many 
> declarations". I'd feel differently if there was a config option, because 
> then the count is truly useful to know.
Oh, but that's different: "This translation unit has an error. Can not 
continue" does not provide enough information for users to fix the issue, 
pointing out that there are *multiple* declarations per statement is definitely 
enough.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949



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


[PATCH] D52616: Introduce completionItemKind capability support.

2018-09-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 167332.
kadircet added a comment.

- Minimum CompletionItemKind is Text.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52616

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/Protocol.cpp
  clangd/Protocol.h

Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -233,13 +233,65 @@
 };
 bool fromJSON(const llvm::json::Value &, CompletionItemClientCapabilities &);
 
+/// The kind of a completion entry.
+enum class CompletionItemKind {
+  Missing = 0,
+  Text = 1,
+  Method = 2,
+  Function = 3,
+  Constructor = 4,
+  Field = 5,
+  Variable = 6,
+  Class = 7,
+  Interface = 8,
+  Module = 9,
+  Property = 10,
+  Unit = 11,
+  Value = 12,
+  Enum = 13,
+  Keyword = 14,
+  Snippet = 15,
+  Color = 16,
+  File = 17,
+  Reference = 18,
+  Folder = 19,
+  EnumMember = 20,
+  Constant = 21,
+  Struct = 22,
+  Event = 23,
+  Operator = 24,
+  TypeParameter = 25,
+};
+
+bool fromJSON(const llvm::json::Value &, CompletionItemKind &);
+
+struct CompletionItemKindCapabilities {
+  /// The CompletionItemKinds that the client supports. If not set, the client
+  /// only supports <= CompletionItemKind::Reference and will not fall back to a
+  /// valid default value.
+  llvm::Optional> valueSet;
+};
+bool fromJSON(const llvm::json::Value &, std::vector &);
+bool fromJSON(const llvm::json::Value &, CompletionItemKindCapabilities &);
+
+constexpr auto CompletionItemKindMin =
+static_cast(CompletionItemKind::Text);
+constexpr auto CompletionItemKindMax =
+static_cast(CompletionItemKind::TypeParameter);
+using CompletionItemKindBitset = std::bitset;
+CompletionItemKind
+adjustKindToCapability(CompletionItemKind Kind,
+   CompletionItemKindBitset );
+
 struct CompletionClientCapabilities {
   /// Whether completion supports dynamic registration.
   bool dynamicRegistration = false;
   /// The client supports the following `CompletionItem` specific capabilities.
   CompletionItemClientCapabilities completionItem;
-  // NOTE: not used by clangd at the moment.
-  // llvm::Optional completionItemKind;
+  /// The CompletionItemKinds that the client supports. If not set, the client
+  /// only supports <= CompletionItemKind::Reference and will not fall back to a
+  /// valid default value.
+  llvm::Optional completionItemKind;
 
   /// The client supports to send additional context information for a
   /// `textDocument/completion` request.
@@ -683,36 +735,6 @@
 };
 llvm::json::Value toJSON(const Hover );
 
-/// The kind of a completion entry.
-enum class CompletionItemKind {
-  Missing = 0,
-  Text = 1,
-  Method = 2,
-  Function = 3,
-  Constructor = 4,
-  Field = 5,
-  Variable = 6,
-  Class = 7,
-  Interface = 8,
-  Module = 9,
-  Property = 10,
-  Unit = 11,
-  Value = 12,
-  Enum = 13,
-  Keyword = 14,
-  Snippet = 15,
-  Color = 16,
-  File = 17,
-  Reference = 18,
-  Folder = 19,
-  EnumMember = 20,
-  Constant = 21,
-  Struct = 22,
-  Event = 23,
-  Operator = 24,
-  TypeParameter = 25,
-};
-
 /// Defines whether the insert text in a completion item should be interpreted
 /// as plain text or a snippet.
 enum class InsertTextFormat {
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -496,6 +496,57 @@
   return std::move(Result);
 }
 
+bool fromJSON(const json::Value , CompletionItemKind ) {
+  if (auto T = E.getAsInteger()) {
+if (*T < static_cast(CompletionItemKind::Text) ||
+*T > static_cast(CompletionItemKind::TypeParameter))
+  return false;
+Out = static_cast(*T);
+return true;
+  }
+  return false;
+}
+
+CompletionItemKind
+adjustKindToCapability(CompletionItemKind Kind,
+   CompletionItemKindBitset ) {
+  auto KindVal = static_cast(Kind);
+  if (KindVal >= CompletionItemKindMin &&
+  KindVal <= supportedCompletionItemKinds.size() &&
+  supportedCompletionItemKinds[KindVal])
+return Kind;
+
+  switch (Kind) {
+  // Provide some fall backs for common kinds that are close enough.
+  case CompletionItemKind::Folder:
+return CompletionItemKind::File;
+  case CompletionItemKind::EnumMember:
+return CompletionItemKind::Enum;
+  case CompletionItemKind::Struct:
+return CompletionItemKind::Class;
+  default:
+return CompletionItemKind::Text;
+  }
+}
+
+bool fromJSON(const json::Value , std::vector ) {
+  if (auto *A = E.getAsArray()) {
+Out.clear();
+for (size_t I = 0; I < A->size(); ++I) {
+  CompletionItemKind KindOut;
+  if (fromJSON((*A)[I], KindOut))
+Out.push_back(KindOut);
+}
+return true;
+  }
+  return false;
+}
+
+bool fromJSON(const json::Value , CompletionItemKindCapabilities ) {
+  json::ObjectMapper O(Params);
+  return O && O.map("valueSet", R.valueSet);
+}
+
 json::Value toJSON(const CompletionItem ) {
   

[PATCH] D50901: [clang][ubsan] Split Implicit Integer Truncation Sanitizer into unsigned and signed checks

2018-09-27 Thread Filipe Cabecinhas via Phabricator via cfe-commits
filcab added inline comments.



Comment at: lib/CodeGen/CGExprScalar.cpp:305
   enum ImplicitConversionCheckKind : unsigned char {
-ICCK_IntegerTruncation = 0,
+ICCK_IntegerTruncation = 0, // Legacy, no longer used.
+ICCK_UnsignedIntegerTruncation = 1,

vitalybuka wrote:
> lebedev.ri wrote:
> > vitalybuka wrote:
> > > why do you need to keep it?
> > *Here* - for consistency with the compiler-rt part.
> > 
> > There - what about mismatch in the used clang version
> > (which still only produced the `(ImplicitConversionCheckKind)0`), and 
> > compiler-rt version
> > (which has `(ImplicitConversionCheckKind)1` and 
> > `(ImplicitConversionCheckKind)2`)?
> > Is it 100.00% guaranteed not to happen? I'm not so sure.
> I don't think we try support mismatched versions of clang and compiler-rt
We don't make a big effort in open source. But we try to at least make it work 
(check previous work on type_mismatch handler, before versions were 
introduced), or error "loudly" when linking (versioned checks).

I think having keeping the older check number free is a good thing and allows 
us to have binary compatibility with older objects (and keep supporting old 
object files (we *did* release llvm 7.0 with the old-type check)).

If we hadn't had a release in between, I'd be all for reusing.


Repository:
  rC Clang

https://reviews.llvm.org/D50901



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


[PATCH] D52434: [OpenMP] Make default schedules for NVPTX target regions in SPMD mode achieve coalescing

2018-09-27 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld accepted this revision.
Hahnfeld added a comment.

In https://reviews.llvm.org/D52434#1248032, @gtbercea wrote:

> That is the intention. I just took out that part from here to not confuse 
> things since I wanted to have that as a separate patch. :)


Ok, perfect. I was probably confused that the title still speaks about 
"schedules" (plural).


Repository:
  rC Clang

https://reviews.llvm.org/D52434



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


[PATCH] D52434: [OpenMP] Make default schedules for NVPTX target regions in SPMD mode achieve coalescing

2018-09-27 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

In https://reviews.llvm.org/D52434#1248012, @Hahnfeld wrote:

> Should we also change the default `schedule` to `static, 1`? I know that's 
> not really needed for `teams distribute parallel for` (because the new 
> default `dist_schedule` only leaves one iteration per thread), but this 
> doesn't happen for `target parallel for`. Additionally it would make the 
> intent more explicit and LLVM doesn't need to look through divisions needed 
> to implement `static` without chunk. Just thinking aloud, not sure if that's 
> worth it.


That is the intention. I just took out that part from here to not confuse 
things since I wanted to have that as a separate patch. :)


Repository:
  rC Clang

https://reviews.llvm.org/D52434



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


[PATCH] D52616: Introduce completionItemKind capability support.

2018-09-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, arphaman, jkorous, ioeric, ilya-biryukov.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52616

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/Protocol.cpp
  clangd/Protocol.h

Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -233,13 +233,65 @@
 };
 bool fromJSON(const llvm::json::Value &, CompletionItemClientCapabilities &);
 
+/// The kind of a completion entry.
+enum class CompletionItemKind {
+  Missing = 0,
+  Text = 1,
+  Method = 2,
+  Function = 3,
+  Constructor = 4,
+  Field = 5,
+  Variable = 6,
+  Class = 7,
+  Interface = 8,
+  Module = 9,
+  Property = 10,
+  Unit = 11,
+  Value = 12,
+  Enum = 13,
+  Keyword = 14,
+  Snippet = 15,
+  Color = 16,
+  File = 17,
+  Reference = 18,
+  Folder = 19,
+  EnumMember = 20,
+  Constant = 21,
+  Struct = 22,
+  Event = 23,
+  Operator = 24,
+  TypeParameter = 25,
+};
+
+bool fromJSON(const llvm::json::Value &, CompletionItemKind &);
+
+struct CompletionItemKindCapabilities {
+  /// The CompletionItemKinds that the client supports. If not set, the client
+  /// only supports <= CompletionItemKind::Reference and will not fall back to a
+  /// valid default value.
+  llvm::Optional> valueSet;
+};
+bool fromJSON(const llvm::json::Value &, std::vector &);
+bool fromJSON(const llvm::json::Value &, CompletionItemKindCapabilities &);
+
+constexpr auto CompletionItemKindMin =
+static_cast(CompletionItemKind::Text);
+constexpr auto CompletionItemKindMax =
+static_cast(CompletionItemKind::TypeParameter);
+using CompletionItemKindBitset = std::bitset;
+CompletionItemKind
+adjustKindToCapability(CompletionItemKind Kind,
+   CompletionItemKindBitset );
+
 struct CompletionClientCapabilities {
   /// Whether completion supports dynamic registration.
   bool dynamicRegistration = false;
   /// The client supports the following `CompletionItem` specific capabilities.
   CompletionItemClientCapabilities completionItem;
-  // NOTE: not used by clangd at the moment.
-  // llvm::Optional completionItemKind;
+  /// The CompletionItemKinds that the client supports. If not set, the client
+  /// only supports <= CompletionItemKind::Reference and will not fall back to a
+  /// valid default value.
+  llvm::Optional completionItemKind;
 
   /// The client supports to send additional context information for a
   /// `textDocument/completion` request.
@@ -683,36 +735,6 @@
 };
 llvm::json::Value toJSON(const Hover );
 
-/// The kind of a completion entry.
-enum class CompletionItemKind {
-  Missing = 0,
-  Text = 1,
-  Method = 2,
-  Function = 3,
-  Constructor = 4,
-  Field = 5,
-  Variable = 6,
-  Class = 7,
-  Interface = 8,
-  Module = 9,
-  Property = 10,
-  Unit = 11,
-  Value = 12,
-  Enum = 13,
-  Keyword = 14,
-  Snippet = 15,
-  Color = 16,
-  File = 17,
-  Reference = 18,
-  Folder = 19,
-  EnumMember = 20,
-  Constant = 21,
-  Struct = 22,
-  Event = 23,
-  Operator = 24,
-  TypeParameter = 25,
-};
-
 /// Defines whether the insert text in a completion item should be interpreted
 /// as plain text or a snippet.
 enum class InsertTextFormat {
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -496,6 +496,57 @@
   return std::move(Result);
 }
 
+bool fromJSON(const json::Value , CompletionItemKind ) {
+  if (auto T = E.getAsInteger()) {
+if (*T < static_cast(CompletionItemKind::File) ||
+*T > static_cast(CompletionItemKind::TypeParameter))
+  return false;
+Out = static_cast(*T);
+return true;
+  }
+  return false;
+}
+
+CompletionItemKind
+adjustKindToCapability(CompletionItemKind Kind,
+   CompletionItemKindBitset ) {
+  auto KindVal = static_cast(Kind);
+  if (KindVal >= CompletionItemKindMin &&
+  KindVal <= supportedCompletionItemKinds.size() &&
+  supportedCompletionItemKinds[KindVal])
+return Kind;
+
+  switch (Kind) {
+  // Provide some fall backs for common kinds that are close enough.
+  case CompletionItemKind::Folder:
+return CompletionItemKind::File;
+  case CompletionItemKind::EnumMember:
+return CompletionItemKind::Enum;
+  case CompletionItemKind::Struct:
+return CompletionItemKind::Class;
+  default:
+return CompletionItemKind::Text;
+  }
+}
+
+bool fromJSON(const json::Value , std::vector ) {
+  if (auto *A = E.getAsArray()) {
+Out.clear();
+for (size_t I = 0; I < A->size(); ++I) {
+  CompletionItemKind KindOut;
+  if (fromJSON((*A)[I], KindOut))
+Out.push_back(KindOut);
+}
+return true;
+  }
+  return false;
+}
+
+bool fromJSON(const json::Value , CompletionItemKindCapabilities ) {
+  json::ObjectMapper O(Params);
+  return O && O.map("valueSet", R.valueSet);
+}
+
 json::Value toJSON(const 

[PATCH] D52615: Handle -fsanitize-address-poison-class-member-array-new-cookie in the driver and propagate it to cc1

2018-09-27 Thread Filipe Cabecinhas via Phabricator via cfe-commits
filcab created this revision.
filcab added reviewers: rjmccall, kcc, rsmith.

Repository:
  rC Clang

https://reviews.llvm.org/D52615

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


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -191,6 +191,24 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE
 // CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE: -cc1{{.*}}address-use-after-scope
 
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-address-poison-class-member-array-new-cookie %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE
+// RUN: %clang_cl --target=x86_64-windows -fsanitize=address 
-fsanitize-address-poison-class-member-array-new-cookie -### -- %s 2>&1 | 
FileCheck %s --check-prefix=CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE
+// CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE: 
-cc1{{.*}}-fsanitize-address-poison-class-member-array-new-cookie
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fno-sanitize-address-poison-class-member-array-new-cookie %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE-OFF
+// RUN: %clang_cl --target=x86_64-windows -fsanitize=address 
-fno-sanitize-address-poison-class-member-array-new-cookie -### -- %s 2>&1 | 
FileCheck %s --check-prefix=CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE-OFF
+// CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE-OFF-NOT: 
-cc1{{.*}}address-poison-class-member-array-new-cookie
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fno-sanitize-address-poison-class-member-array-new-cookie 
-fsanitize-address-poison-class-member-array-new-cookie %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE-BOTH
+// RUN: %clang_cl --target=x86_64-windows -fsanitize=address 
-fno-sanitize-address-poison-class-member-array-new-cookie 
-fsanitize-address-poison-class-member-array-new-cookie -### -- %s 2>&1 | 
FileCheck %s --check-prefix=CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE-BOTH
+// CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE-BOTH: 
-cc1{{.*}}-fsanitize-address-poison-class-member-array-new-cookie
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-address-poison-class-member-array-new-cookie 
-fno-sanitize-address-poison-class-member-array-new-cookie %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE-BOTH-OFF
+// CHECK-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE-BOTH-OFF-NOT: 
-cc1{{.*}}address-poison-class-member-array-new-cookie
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | 
FileCheck %s 
--check-prefix=CHECK-ASAN-WITHOUT-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE
+// CHECK-ASAN-WITHOUT-POISON-CLASS-MEMBER-ARRAY-NEW-COOKIE-NOT: 
-cc1{{.*}}address-poison-class-member-array-new-cookie
+
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-address-globals-dead-stripping %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-ASAN-GLOBALS
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-NO-ASAN-GLOBALS
 // RUN: %clang_cl --target=x86_64-windows-msvc -fsanitize=address 
-fsanitize-address-globals-dead-stripping -### -- %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-ASAN-GLOBALS
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -724,6 +724,11 @@
 options::OPT_fsanitize_address_use_after_scope,
 options::OPT_fno_sanitize_address_use_after_scope, AsanUseAfterScope);
 
+AsanPoisonClassMemberOperatorNew = Args.hasFlag(
+options::OPT_fsanitize_address_poison_class_member_array_new_cookie,
+options::OPT_fno_sanitize_address_poison_class_member_array_new_cookie,
+AsanPoisonClassMemberOperatorNew);
+
 // As a workaround for a bug in gold 2.26 and earlier, dead stripping of
 // globals in ASan is disabled by default on ELF targets.
 // See https://sourceware.org/bugzilla/show_bug.cgi?id=19002
@@ -897,6 +902,10 @@
   if (AsanUseAfterScope)
 CmdArgs.push_back("-fsanitize-address-use-after-scope");
 
+  if (AsanPoisonClassMemberOperatorNew)
+CmdArgs.push_back(
+"-fsanitize-address-poison-class-member-array-new-cookie");
+
   if (AsanGlobalsDeadStripping)
 CmdArgs.push_back("-fsanitize-address-globals-dead-stripping");
 
Index: include/clang/Driver/SanitizerArgs.h
===
--- include/clang/Driver/SanitizerArgs.h
+++ include/clang/Driver/SanitizerArgs.h
@@ -36,6 +36,7 @@
   int AsanFieldPadding = 0;
   bool SharedRuntime = false;
   bool AsanUseAfterScope = true;
+  bool 

[PATCH] D51949: [WIP][clang-tidy] initial ideas to isolate variable declarations

2018-09-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/readability/IsolateDeclCheck.cpp:343
+  auto Diag =
+  diag(WholeDecl->getBeginLoc(), "this statement declares %0 variables")
+  << static_cast(

lebedev.ri wrote:
> kbobyrev wrote:
> > JonasToth wrote:
> > > kbobyrev wrote:
> > > > How about `multiple declarations within a single statement hurts 
> > > > readability`?
> > > s/hurts/reduces/? hurts sound a bit weird i think.
> > > 
> > > Lebedev wanted the number of decls in the diagnostic, would you include 
> > > it or rather now?
> > "decreases" is also fine. "hurts" is probably too strong, I agree.
> > 
> > Up to you. Personally, I don't see any value in having the diagnostic 
> > message saying "hey, you have 2 declarations within one statement, that's 
> > really bad!" or "hey, you have 5 declarations within one statement..." - in 
> > both cases the point is that there are *multiple* declarations. I also 
> > don't think it would make debugging easier because you also check the 
> > formatting, so you already imply that the correct number of declarations 
> > was detected.
> > 
> > I'm interested to know what @lebedev.ri thinks.
> > I'm interested to know what @lebedev.ri thinks.
> 
> "This translation unit has an error. Can not continue" is also a diagnostic 
> message.
> Why are we not ok with that one, and want compiler to be a bit more specific?
> 
> Similarly here, why just point out that this code is bad as per the check,
> without giving a little bit more info, that you already have?
> "This translation unit has an error. Can not continue" is also a diagnostic 
> message.
>Why are we not ok with that one, and want compiler to be a bit more specific?
>
> Similarly here, why just point out that this code is bad as per the check, 
> without giving a little bit more info, that you already have?

More information doesn't always equate into more understanding, especially when 
that information causes a distraction. For instance, you could argue that the 
type of the declared variables is also information we already have, but what 
purpose would it serve to tell it to the user?

Can you give an example where the specific number of declarations involved 
would help you to correct the diagnostic? I can't come up with one, so it feels 
to me like having the count is more of a distraction; especially given that 
there's no configurable threshold for "now you have too many declarations". I'd 
feel differently if there was a config option, because then the count is truly 
useful to know.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949



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


  1   2   >