[PATCH] D45517: [analyzer] False positive refutation with Z3

2018-05-30 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:2382
+// Reset the solver
+RefutationMgr.reset();
+  }

george.karpenkov wrote:
> george.karpenkov wrote:
> > (apologies in advance for nitpicking not on your code).
> > 
> > Currently, this is written in a stateful way: we have a solver, at each 
> > iteration we add constraints, and at the end we reset it. To me it would 
> > make considerably more sense to write the code in a functional style: as we 
> > go, generate a vector of formulas, then once we reach the path end, create 
> > the solver object, check satisfiability, and then destroy the entire solver.
> Elaborating more: we are already forced to have visitor object state, let's 
> use that. `RefutationMgr` is essentially a wrapper around a Z3 solver object, 
> let's just create one when visitor is constructed (directly or in unique_ptr) 
> and then rely on the destructor to destroy it.
> Then no `reset` is necessary.
Note that while constructing the constraint solver here might make perfect 
sense now, it also inhibits incremental solving.  If we do not plan to 
experiment with incremental solvers anytime soon I am fine with this direction 
as well.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1264
+
+if (OnlyPurged && SuccCR.contains(Sym))
+  continue;

george.karpenkov wrote:
> I would guess that this is an optimization done in order not to re-add the 
> constraints we already have.
> I think we should really not bother doing that, as Z3 will do a much better 
> job here then we can.
Note that we are using lots of domain knowledge here like we have the most info 
about a symbol just before it dies. Also This optimization is a single lookup 
on the symbol level. I am not sure if Z3 could deal with this on the symbol 
level. It might need to do this on the constraint level.
My point is, I am perfectly fine removing this optimization but I would like to 
see some performance numbers first either on a project that exercises 
refutation quite a bit or on some synthetic test cases.



https://reviews.llvm.org/D45517



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


[PATCH] D40181: [libcxx] Allow to set locale on Windows.

2018-05-30 Thread Alexey Pavlov via Phabricator via cfe-commits
Alexpux added a comment.
Herald added subscribers: llvm-commits, christof.

I'm not be able to build libcxx with 64-bit mingw-w64 due to this commit.
Have error like:

  [ 10%] Building CXX object 
projects/libcxx/lib/CMakeFiles/cxx_objects.dir/__/src/algorithm.cpp.obj
  In file included from 
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/ctype.h:39:0,
   from 
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/cctype:39,
   from 
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/cwctype:54,
   from 
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/cwchar:107,
   from 
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/string:481,
   from 
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/random:1645,
   from 
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/src/algorithm.cpp:11:
  C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/locale: In 
static member function 'static void 
std::__1::__num_put<_CharT>::__widen_and_group_float(char*, char*, char*, 
_CharT*, _CharT*&, _CharT*&, const std::__1::locale&)':
  
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/support/win32/locale_win32.h:150:20:
 error: ambiguous overload for 'operator!=' (operand types are 'locale_t' and 
'long long int')
   #define isxdigit_l _isxdigit_l
  ^
  
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/locale:1198:18:
 note: in expansion of macro 'isxdigit_l'
   if (!isxdigit_l(*__ns, _LIBCPP_GET_C_LOCALE))
^~
  
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/support/win32/locale_win32.h:150:20:
 note: candidate: operator!=(int, long long int) 
   #define isxdigit_l _isxdigit_l
  ^
  
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/locale:1198:18:
 note: in expansion of macro 'isxdigit_l'
   if (!isxdigit_l(*__ns, _LIBCPP_GET_C_LOCALE))
^~
  
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/support/win32/locale_win32.h:150:20:
 note: candidate: operator!=(_locale_t {aka localeinfo_struct*}, _locale_t {aka 
localeinfo_struct*}) 
   #define isxdigit_l _isxdigit_l
  ^
  
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/locale:1198:18:
 note: in expansion of macro 'isxdigit_l'
   if (!isxdigit_l(*__ns, _LIBCPP_GET_C_LOCALE))
^~
  In file included from 
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/__locale:23:0,
   from 
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/ios:216,
   from 
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/ostream:138,
   from 
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/istream:163,
   from 
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/random:1646,
   from 
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/src/algorithm.cpp:11:
  
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/support/win32/locale_win32.h:73:17:
 note: candidate: bool operator!=(int, const locale_t&)
   friend bool operator!=(int __left, const locale_t& __right) {
   ^~~~
  
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/support/win32/locale_win32.h:69:17:
 note: candidate: bool operator!=(const locale_t&, std::nullptr_t)
   friend bool operator!=(const locale_t& __left, std::nullptr_t __right) {
   ^~~~
  
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/support/win32/locale_win32.h:65:17:
 note: candidate: bool operator!=(const locale_t&, int)
   friend bool operator!=(const locale_t& __left, int __right) {
   ^~~~
  
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/support/win32/locale_win32.h:61:17:
 note: candidate: bool operator!=(const locale_t&, const locale_t&)
   friend bool operator!=(const locale_t& __left, const locale_t& __right) {
   ^~~~
  In file included from 
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/ctype.h:39:0,
   from 
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/cctype:39,
   from 
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/cwctype:54,
   from 
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/cwchar:107,
   from 
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/string:481,
   from 
C:/repo/mingw-w64-clang/src/llvm-6.0.0.src/projects/libcxx/include/random:1645,
   

[PATCH] D47515: [clang-format] Process line's children once in guessIsObjC

2018-05-30 Thread Attila via Phabricator via cfe-commits
Uran198 created this revision.
Uran198 added reviewers: djasper, klimek.

Repository:
  rC Clang

https://reviews.llvm.org/D47515

Files:
  lib/Format/Format.cpp


Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1558,9 +1558,9 @@
TT_ObjCMethodSpecifier, TT_ObjCProperty)) {
   return true;
 }
-if (guessIsObjC(Line->Children, Keywords))
-  return true;
   }
+  if (guessIsObjC(Line->Children, Keywords))
+return true;
 }
 return false;
   }


Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1558,9 +1558,9 @@
TT_ObjCMethodSpecifier, TT_ObjCProperty)) {
   return true;
 }
-if (guessIsObjC(Line->Children, Keywords))
-  return true;
   }
+  if (guessIsObjC(Line->Children, Keywords))
+return true;
 }
 return false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45686: [Driver] Clean up tmp files when deleting Compilation objects

2018-05-30 Thread David Stenberg via Phabricator via cfe-commits
dstenb added a comment.

Any more comments or concerns, or can I land this?


https://reviews.llvm.org/D45686



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


[PATCH] D47313: [ASTImporter] Corrected lookup at import of templated record decl

2018-05-30 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Balazs, I'll commit it for you in an hour.


Repository:
  rC Clang

https://reviews.llvm.org/D47313



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


[PATCH] D47476: Support __iso_volatile_load8 etc on aarch64-win32.

2018-05-30 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC333513: Support __iso_volatile_load8 etc on aarch64-win32. 
(authored by statham, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47476?vs=148900&id=149055#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47476

Files:
  include/clang/Basic/BuiltinsAArch64.def
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/ms-volatile-aarch64.c

Index: include/clang/Basic/BuiltinsAArch64.def
===
--- include/clang/Basic/BuiltinsAArch64.def
+++ include/clang/Basic/BuiltinsAArch64.def
@@ -69,5 +69,15 @@
 LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
 LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
 
+// MSVC intrinsics for volatile but non-acquire/release loads and stores
+LANGBUILTIN(__iso_volatile_load8,   "ccCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load16,  "ssCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load32,  "iiCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load64,  "LLiLLiCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store8,  "vcD*c", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store16, "vsD*s", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store32, "viD*i", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store64, "vLLiD*LLi", "n", ALL_MS_LANGUAGES)
+
 #undef BUILTIN
 #undef LANGBUILTIN
Index: test/CodeGen/ms-volatile-aarch64.c
===
--- test/CodeGen/ms-volatile-aarch64.c
+++ test/CodeGen/ms-volatile-aarch64.c
@@ -0,0 +1,13 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-win32 -emit-llvm -fms-extensions -fms-volatile -o - < %s | FileCheck %s
+
+void test1(int volatile *p, int v) {
+  __iso_volatile_store32(p, v);
+  // CHECK-LABEL: @test1
+  // CHECK: store volatile {{.*}}, {{.*}}
+}
+int test2(const int volatile *p) {
+  return __iso_volatile_load32(p);
+  // CHECK-LABEL: @test2
+  // CHECK: load volatile {{.*}}
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -5179,6 +5179,34 @@
   return true;
 }
 
+Value *CodeGenFunction::EmitISOVolatileLoad(const CallExpr *E) {
+  Value *Ptr = EmitScalarExpr(E->getArg(0));
+  QualType ElTy = E->getArg(0)->getType()->getPointeeType();
+  CharUnits LoadSize = getContext().getTypeSizeInChars(ElTy);
+  llvm::Type *ITy = llvm::IntegerType::get(getLLVMContext(),
+   LoadSize.getQuantity() * 8);
+  Ptr = Builder.CreateBitCast(Ptr, ITy->getPointerTo());
+  llvm::LoadInst *Load =
+Builder.CreateAlignedLoad(Ptr, LoadSize);
+  Load->setVolatile(true);
+  return Load;
+}
+
+Value *CodeGenFunction::EmitISOVolatileStore(const CallExpr *E) {
+  Value *Ptr = EmitScalarExpr(E->getArg(0));
+  Value *Value = EmitScalarExpr(E->getArg(1));
+  QualType ElTy = E->getArg(0)->getType()->getPointeeType();
+  CharUnits StoreSize = getContext().getTypeSizeInChars(ElTy);
+  llvm::Type *ITy = llvm::IntegerType::get(getLLVMContext(),
+   StoreSize.getQuantity() * 8);
+  Ptr = Builder.CreateBitCast(Ptr, ITy->getPointerTo());
+  llvm::StoreInst *Store =
+Builder.CreateAlignedStore(Value, Ptr,
+   StoreSize);
+  Store->setVolatile(true);
+  return Store;
+}
+
 Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
const CallExpr *E,
llvm::Triple::ArchType Arch) {
@@ -5421,35 +5449,13 @@
   case ARM::BI__iso_volatile_load8:
   case ARM::BI__iso_volatile_load16:
   case ARM::BI__iso_volatile_load32:
-  case ARM::BI__iso_volatile_load64: {
-Value *Ptr = EmitScalarExpr(E->getArg(0));
-QualType ElTy = E->getArg(0)->getType()->getPointeeType();
-CharUnits LoadSize = getContext().getTypeSizeInChars(ElTy);
-llvm::Type *ITy = llvm::IntegerType::get(getLLVMContext(),
- LoadSize.getQuantity() * 8);
-Ptr = Builder.CreateBitCast(Ptr, ITy->getPointerTo());
-llvm::LoadInst *Load =
-  Builder.CreateAlignedLoad(Ptr, LoadSize);
-Load->setVolatile(true);
-return Load;
-  }
+  case ARM::BI__iso_volatile_load64:
+return EmitISOVolatileLoad(E);
   case ARM::BI__iso_volatile_store8:
   case ARM::BI__iso_volatile_store16:
   case ARM::BI__iso_volatile_store32:
-  case ARM::BI__iso_volatile_store64: {
-Value *Ptr = EmitScalarExpr(E->getArg(0));
-Value *Value = EmitScalarExpr(E->getArg(1));
-QualType ElTy = E->getArg(0)->getType()->getPointeeType();
-CharUnits StoreSize = getContext().getTypeSizeInChars(ElTy);
-llvm::Type *ITy = llvm::IntegerType::get(getLLVMContext(),
- Store

[PATCH] D47476: Support __iso_volatile_load8 etc on aarch64-win32.

2018-05-30 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333513: Support __iso_volatile_load8 etc on aarch64-win32. 
(authored by statham, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D47476

Files:
  cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/test/CodeGen/ms-volatile-aarch64.c

Index: cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
+++ cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
@@ -69,5 +69,15 @@
 LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
 LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
 
+// MSVC intrinsics for volatile but non-acquire/release loads and stores
+LANGBUILTIN(__iso_volatile_load8,   "ccCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load16,  "ssCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load32,  "iiCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load64,  "LLiLLiCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store8,  "vcD*c", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store16, "vsD*s", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store32, "viD*i", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store64, "vLLiD*LLi", "n", ALL_MS_LANGUAGES)
+
 #undef BUILTIN
 #undef LANGBUILTIN
Index: cfe/trunk/test/CodeGen/ms-volatile-aarch64.c
===
--- cfe/trunk/test/CodeGen/ms-volatile-aarch64.c
+++ cfe/trunk/test/CodeGen/ms-volatile-aarch64.c
@@ -0,0 +1,13 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-win32 -emit-llvm -fms-extensions -fms-volatile -o - < %s | FileCheck %s
+
+void test1(int volatile *p, int v) {
+  __iso_volatile_store32(p, v);
+  // CHECK-LABEL: @test1
+  // CHECK: store volatile {{.*}}, {{.*}}
+}
+int test2(const int volatile *p) {
+  return __iso_volatile_load32(p);
+  // CHECK-LABEL: @test2
+  // CHECK: load volatile {{.*}}
+}
Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -5179,6 +5179,34 @@
   return true;
 }
 
+Value *CodeGenFunction::EmitISOVolatileLoad(const CallExpr *E) {
+  Value *Ptr = EmitScalarExpr(E->getArg(0));
+  QualType ElTy = E->getArg(0)->getType()->getPointeeType();
+  CharUnits LoadSize = getContext().getTypeSizeInChars(ElTy);
+  llvm::Type *ITy = llvm::IntegerType::get(getLLVMContext(),
+   LoadSize.getQuantity() * 8);
+  Ptr = Builder.CreateBitCast(Ptr, ITy->getPointerTo());
+  llvm::LoadInst *Load =
+Builder.CreateAlignedLoad(Ptr, LoadSize);
+  Load->setVolatile(true);
+  return Load;
+}
+
+Value *CodeGenFunction::EmitISOVolatileStore(const CallExpr *E) {
+  Value *Ptr = EmitScalarExpr(E->getArg(0));
+  Value *Value = EmitScalarExpr(E->getArg(1));
+  QualType ElTy = E->getArg(0)->getType()->getPointeeType();
+  CharUnits StoreSize = getContext().getTypeSizeInChars(ElTy);
+  llvm::Type *ITy = llvm::IntegerType::get(getLLVMContext(),
+   StoreSize.getQuantity() * 8);
+  Ptr = Builder.CreateBitCast(Ptr, ITy->getPointerTo());
+  llvm::StoreInst *Store =
+Builder.CreateAlignedStore(Value, Ptr,
+   StoreSize);
+  Store->setVolatile(true);
+  return Store;
+}
+
 Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
const CallExpr *E,
llvm::Triple::ArchType Arch) {
@@ -5421,35 +5449,13 @@
   case ARM::BI__iso_volatile_load8:
   case ARM::BI__iso_volatile_load16:
   case ARM::BI__iso_volatile_load32:
-  case ARM::BI__iso_volatile_load64: {
-Value *Ptr = EmitScalarExpr(E->getArg(0));
-QualType ElTy = E->getArg(0)->getType()->getPointeeType();
-CharUnits LoadSize = getContext().getTypeSizeInChars(ElTy);
-llvm::Type *ITy = llvm::IntegerType::get(getLLVMContext(),
- LoadSize.getQuantity() * 8);
-Ptr = Builder.CreateBitCast(Ptr, ITy->getPointerTo());
-llvm::LoadInst *Load =
-  Builder.CreateAlignedLoad(Ptr, LoadSize);
-Load->setVolatile(true);
-return Load;
-  }
+  case ARM::BI__iso_volatile_load64:
+return EmitISOVolatileLoad(E);
   case ARM::BI__iso_volatile_store8:
   case ARM::BI__iso_volatile_store16:
   case ARM::BI__iso_volatile_store32:
-  case ARM::BI__iso_volatile_store64: {
-Value *Ptr = EmitScalarExpr(E->getArg(0));
-Value *Value = EmitScalarExpr(E->getArg(1));
-QualType ElTy = E->getArg(0)->getType()->getPointeeType();
-CharUnits StoreSize = getContext().getTypeSizeInChars(ElTy);
-llvm::Type *ITy = llvm:

r333514 - Fix -Wunused in NDEBUG introduced by HIP r333484

2018-05-30 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed May 30 01:03:43 2018
New Revision: 333514

URL: http://llvm.org/viewvc/llvm-project?rev=333514&view=rev
Log:
Fix -Wunused in NDEBUG introduced by HIP r333484

Modified:
cfe/trunk/lib/Driver/ToolChains/HIP.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/HIP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/HIP.cpp?rev=333514&r1=333513&r2=333514&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/HIP.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/HIP.cpp Wed May 30 01:03:43 2018
@@ -186,9 +186,7 @@ void AMDGCN::Linker::ConstructJob(Compil
const ArgList &Args,
const char *LinkingOutput) const {
 
-  const auto &TC =
-  static_cast(getToolChain());
-  assert(TC.getTriple().getArch() == llvm::Triple::amdgcn &&
+  assert(getToolChain().getTriple().getArch() == llvm::Triple::amdgcn &&
  "Unsupported target");
 
   std::string SubArchName = JA.getOffloadingArch();
@@ -224,6 +222,7 @@ void HIPToolChain::addClangTargetOptions
 
   StringRef GpuArch = DriverArgs.getLastArgValue(options::OPT_march_EQ);
   assert(!GpuArch.empty() && "Must have an explicit GPU arch.");
+  (void) GpuArch;
   assert(DeviceOffloadingKind == Action::OFK_HIP &&
  "Only HIP offloading kinds are supported for GPUs.");
 


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


r333515 - Add missing curly from r333509

2018-05-30 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed May 30 01:05:24 2018
New Revision: 333515

URL: http://llvm.org/viewvc/llvm-project?rev=333515&view=rev
Log:
Add missing curly from r333509

Modified:
cfe/trunk/lib/Headers/avx512vlvnniintrin.h

Modified: cfe/trunk/lib/Headers/avx512vlvnniintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlvnniintrin.h?rev=333515&r1=333514&r2=333515&view=diff
==
--- cfe/trunk/lib/Headers/avx512vlvnniintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlvnniintrin.h Wed May 30 01:05:24 2018
@@ -76,7 +76,7 @@ _mm256_maskz_dpbusds_epi32(__mmask8 __U,
   return (__m256i)__builtin_ia32_selectd_256(__U,
  (__v8si)_mm256_dpbusds_epi32(__S, __A, 
__B),
  (__v8si)_mm256_setzero_si256());
-
+}
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_dpwssd_epi32(__m256i __S, __m256i __A, __m256i __B)


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


Re: r333509 - [X86] Remove masking from the AVX512VNNI builtins. Use a select in IR instead.

2018-05-30 Thread Hans Wennborg via cfe-commits
On Wed, May 30, 2018 at 7:26 AM, Craig Topper via cfe-commits
 wrote:
> Author: ctopper
> Date: Tue May 29 22:26:04 2018
> New Revision: 333509
>
> URL: http://llvm.org/viewvc/llvm-project?rev=333509&view=rev
> Log:
> [X86] Remove masking from the AVX512VNNI builtins. Use a select in IR instead.
>
> Modified:
> cfe/trunk/include/clang/Basic/BuiltinsX86.def
> cfe/trunk/lib/Headers/avx512vlvnniintrin.h
> cfe/trunk/lib/Headers/avx512vnniintrin.h
> cfe/trunk/test/CodeGen/avx512vlvnni-builtins.c
> cfe/trunk/test/CodeGen/avx512vnni-builtins.c

[...]

> --- cfe/trunk/lib/Headers/avx512vlvnniintrin.h (original)
> +++ cfe/trunk/lib/Headers/avx512vlvnniintrin.h Tue May 29 22:26:04 2018

[...]

>  static __inline__ __m256i __DEFAULT_FN_ATTRS
>  _mm256_maskz_dpbusds_epi32(__mmask8 __U, __m256i __S, __m256i __A, __m256i 
> __B)
>  {
> -  return (__m256i) __builtin_ia32_vpdpbusds256_maskz ((__v8si) __S,
> -  (__v8si) __A,
> -  (__v8si) __B,
> -  (__mmask8) __U);
> -}

Oops :-) Missing curly added back in r333515 to make the bots happier.

> +  return (__m256i)__builtin_ia32_selectd_256(__U,
> + (__v8si)_mm256_dpbusds_epi32(__S, __A, 
> __B),
> + (__v8si)_mm256_setzero_si256());
> +
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47519: [clang-format] Detect amp type as TT_PointerOrReference in function annotations

2018-05-30 Thread Attila via Phabricator via cfe-commits
Uran198 created this revision.
Uran198 added reviewers: klimek, krasimir, djasper.

Repository:
  rC Clang

https://reviews.llvm.org/D47519

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


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -6156,6 +6156,12 @@
"operator()() && {}");
   verifyGoogleFormat("template \n"
  "auto x() & -> int {}");
+  verifyGoogleFormat("template \n"
+ "auto x() const& noexcept -> bool {}");
+  verifyGoogleFormat("template \n"
+ "void f() &noexcept {}");
+  verifyGoogleFormat("template \n"
+ "auto operator+() &MACRO {}");
 }
 
 TEST_F(FormatTest, UnderstandsAttributes) {
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1563,7 +1563,7 @@
 (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))
   return TT_PointerOrReference;
 
-if (PrevToken->is(tok::coloncolon))
+if (PrevToken->isOneOf(tok::coloncolon, tok::kw_const))
   return TT_PointerOrReference;
 
 if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
@@ -1585,7 +1585,9 @@
   FormatToken *TokenBeforeMatchingParen =
   PrevToken->MatchingParen->getPreviousNonComment();
   if (TokenBeforeMatchingParen &&
-  TokenBeforeMatchingParen->isOneOf(tok::kw_typeof, tok::kw_decltype))
+  TokenBeforeMatchingParen->isOneOf(
+  tok::kw_typeof, tok::kw_decltype, TT_FunctionDeclarationName,
+  TT_StartOfName, TT_OverloadedOperator))
 return TT_PointerOrReference;
 }
 


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -6156,6 +6156,12 @@
"operator()() && {}");
   verifyGoogleFormat("template \n"
  "auto x() & -> int {}");
+  verifyGoogleFormat("template \n"
+ "auto x() const& noexcept -> bool {}");
+  verifyGoogleFormat("template \n"
+ "void f() &noexcept {}");
+  verifyGoogleFormat("template \n"
+ "auto operator+() &MACRO {}");
 }
 
 TEST_F(FormatTest, UnderstandsAttributes) {
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1563,7 +1563,7 @@
 (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))
   return TT_PointerOrReference;
 
-if (PrevToken->is(tok::coloncolon))
+if (PrevToken->isOneOf(tok::coloncolon, tok::kw_const))
   return TT_PointerOrReference;
 
 if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
@@ -1585,7 +1585,9 @@
   FormatToken *TokenBeforeMatchingParen =
   PrevToken->MatchingParen->getPreviousNonComment();
   if (TokenBeforeMatchingParen &&
-  TokenBeforeMatchingParen->isOneOf(tok::kw_typeof, tok::kw_decltype))
+  TokenBeforeMatchingParen->isOneOf(
+  tok::kw_typeof, tok::kw_decltype, TT_FunctionDeclarationName,
+  TT_StartOfName, TT_OverloadedOperator))
 return TT_PointerOrReference;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47466: [clangd] Avoid inserting new #include when declaration is present in the main file.

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

Addressed review comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47466

Files:
  clangd/CodeComplete.cpp
  unittests/clangd/CodeCompleteTests.cpp

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -159,7 +159,7 @@
   return sym(Name, index::SymbolKind::Function, "@F@\\0#"); // no args
 }
 Symbol cls(StringRef Name) {
-  return sym(Name, index::SymbolKind::Class, "@S@\\0@S@\\0");
+  return sym(Name, index::SymbolKind::Class, "@S@\\0");
 }
 Symbol var(StringRef Name) {
   return sym(Name, index::SymbolKind::Variable, "@\\0");
@@ -425,10 +425,9 @@
   auto Results = completions(
   R"cpp(
   class Adapter {
-void method();
   };
 
-  void Adapter::method() {
+  void f() {
 Adapter^
   }
   )cpp",
@@ -559,6 +558,37 @@
   ElementsAre(AllOf(Named("X"), Not(HasAdditionalEdits();
 }
 
+TEST(CompletionTest, NoIncludeInsertionWhenDeclFoundInFile) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+  Symbol::Details Scratch;
+  Symbol SymX = cls("ns::X");
+  Symbol SymY = cls("ns::Y");
+  std::string BarHeader = testPath("bar.h");
+  auto BarURI = URI::createFile(BarHeader).toString();
+  SymX.CanonicalDeclaration.FileURI = BarURI;
+  SymY.CanonicalDeclaration.FileURI = BarURI;
+  Scratch.IncludeHeader = "";
+  SymX.Detail = &Scratch;
+  SymY.Detail = &Scratch;
+  // Shoten include path based on search dirctory and insert.
+  auto Results = completions(Server,
+ R"cpp(
+  namespace ns {
+class X;
+class Y {}
+  }
+  int main() { ns::^ }
+  )cpp",
+ {SymX, SymY});
+  EXPECT_THAT(Results.items,
+  ElementsAre(AllOf(Named("X"), Not(HasAdditionalEdits())),
+  AllOf(Named("Y"), Not(HasAdditionalEdits();
+}
+
 TEST(CompletionTest, IndexSuppressesPreambleCompletions) {
   MockFSProvider FS;
   MockCompilationDatabase CDB;
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -235,13 +235,28 @@
llvm::StringRef SemaDocComment) const {
 assert(bool(SemaResult) == bool(SemaCCS));
 CompletionItem I;
+bool ShouldInsertInclude = true;
 if (SemaResult) {
   I.kind = toCompletionItemKind(SemaResult->Kind, SemaResult->CursorKind);
   getLabelAndInsertText(*SemaCCS, &I.label, &I.insertText,
 Opts.EnableSnippets);
   I.filterText = getFilterText(*SemaCCS);
   I.documentation = formatDocumentation(*SemaCCS, SemaDocComment);
   I.detail = getDetail(*SemaCCS);
+  // Avoid inserting new #include if the declaration is found in the current
+  // file e.g. the symbol is forward declared.
+  if (SemaResult->Kind == CodeCompletionResult::RK_Declaration) {
+if (const auto *D = SemaResult->getDeclaration()) {
+  const auto &SM = D->getASTContext().getSourceManager();
+  ShouldInsertInclude =
+  ShouldInsertInclude &&
+  std::none_of(D->redecls_begin(), D->redecls_end(),
+   [&SM](const Decl *RD) {
+ return SM.isInMainFile(
+ SM.getExpansionLoc(RD->getLocStart()));
+   });
+}
+  }
 }
 if (IndexResult) {
   if (I.kind == CompletionItemKind::Missing)
@@ -263,7 +278,7 @@
   I.documentation = D->Documentation;
 if (I.detail.empty())
   I.detail = D->CompletionDetail;
-if (Includes && !D->IncludeHeader.empty()) {
+if (ShouldInsertInclude && Includes && !D->IncludeHeader.empty()) {
   auto Edit = [&]() -> Expected> {
 auto ResolvedDeclaring = toHeaderFile(
 IndexResult->CanonicalDeclaration.FileURI, FileName);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r333519 - [clangd] Avoid inserting new #include when declaration is present in the main file.

2018-05-30 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed May 30 02:03:39 2018
New Revision: 333519

URL: http://llvm.org/viewvc/llvm-project?rev=333519&view=rev
Log:
[clangd] Avoid inserting new #include when declaration is present in the main 
file.

Summary:
Also fix USR generation for classes in unit tests. The previous USR
only works for class members, which happens to work when completing class name
inside the class, where constructors are suggested by sema.

Reviewers: sammccall, ilya-biryukov

Subscribers: klimek, MaskRay, jkorous, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=333519&r1=333518&r2=333519&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Wed May 30 02:03:39 2018
@@ -235,6 +235,7 @@ struct CompletionCandidate {
llvm::StringRef SemaDocComment) const {
 assert(bool(SemaResult) == bool(SemaCCS));
 CompletionItem I;
+bool ShouldInsertInclude = true;
 if (SemaResult) {
   I.kind = toCompletionItemKind(SemaResult->Kind, SemaResult->CursorKind);
   getLabelAndInsertText(*SemaCCS, &I.label, &I.insertText,
@@ -242,6 +243,20 @@ struct CompletionCandidate {
   I.filterText = getFilterText(*SemaCCS);
   I.documentation = formatDocumentation(*SemaCCS, SemaDocComment);
   I.detail = getDetail(*SemaCCS);
+  // Avoid inserting new #include if the declaration is found in the 
current
+  // file e.g. the symbol is forward declared.
+  if (SemaResult->Kind == CodeCompletionResult::RK_Declaration) {
+if (const auto *D = SemaResult->getDeclaration()) {
+  const auto &SM = D->getASTContext().getSourceManager();
+  ShouldInsertInclude =
+  ShouldInsertInclude &&
+  std::none_of(D->redecls_begin(), D->redecls_end(),
+   [&SM](const Decl *RD) {
+ return SM.isInMainFile(
+ SM.getExpansionLoc(RD->getLocStart()));
+   });
+}
+  }
 }
 if (IndexResult) {
   if (I.kind == CompletionItemKind::Missing)
@@ -263,7 +278,7 @@ struct CompletionCandidate {
   I.documentation = D->Documentation;
 if (I.detail.empty())
   I.detail = D->CompletionDetail;
-if (Includes && !D->IncludeHeader.empty()) {
+if (ShouldInsertInclude && Includes && !D->IncludeHeader.empty()) {
   auto Edit = [&]() -> Expected> {
 auto ResolvedDeclaring = toHeaderFile(
 IndexResult->CanonicalDeclaration.FileURI, FileName);

Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=333519&r1=333518&r2=333519&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Wed May 30 
02:03:39 2018
@@ -159,7 +159,7 @@ Symbol func(StringRef Name) { // Assumes
   return sym(Name, index::SymbolKind::Function, "@F@\\0#"); // no args
 }
 Symbol cls(StringRef Name) {
-  return sym(Name, index::SymbolKind::Class, "@S@\\0@S@\\0");
+  return sym(Name, index::SymbolKind::Class, "@S@\\0");
 }
 Symbol var(StringRef Name) {
   return sym(Name, index::SymbolKind::Variable, "@\\0");
@@ -425,10 +425,9 @@ TEST(CompletionTest, NoDuplicates) {
   auto Results = completions(
   R"cpp(
   class Adapter {
-void method();
   };
 
-  void Adapter::method() {
+  void f() {
 Adapter^
   }
   )cpp",
@@ -559,6 +558,37 @@ TEST(CompletionTest, IncludeInsertionPre
   ElementsAre(AllOf(Named("X"), Not(HasAdditionalEdits();
 }
 
+TEST(CompletionTest, NoIncludeInsertionWhenDeclFoundInFile) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+  Symbol::Details Scratch;
+  Symbol SymX = cls("ns::X");
+  Symbol SymY = cls("ns::Y");
+  std::string BarHeader = testPath("bar.h");
+  auto BarURI = URI::createFile(BarHeader).toString();
+  SymX.CanonicalDeclaration.FileURI = BarURI;
+  SymY.CanonicalDeclaration.FileURI = BarURI;
+  Scratch.IncludeHeader = "";
+  SymX.Detail = &Scratch;
+  SymY.Detail = &Scratch;
+  // Shoten include path based on search dirctory and insert.
+  auto Results = completions(Server,
+ R"cpp(
+  namespace 

[PATCH] D47196: [Time-report ](2): Recursive timers in Clang

2018-05-30 Thread Andrew V. Tischenko via Phabricator via cfe-commits
avt77 added a comment.

Hi All,
What should I do to simplify the review?
I could remove all LLVM_DEBUG related stuff; I could remove all addtional 
counters and leave only necessary one or two of them. As result the patch will 
become shorter.

Should I do all these truncations to simplify the review?
Or maybe I should add comments and/or docs in Utils.h describing the new 
infrastructure?
Maybe you need examples of the produced output?


https://reviews.llvm.org/D47196



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


[PATCH] D47466: [clangd] Avoid inserting new #include when declaration is present in the main file.

2018-05-30 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333519: [clangd] Avoid inserting new #include when 
declaration is present in the main… (authored by ioeric, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D47466

Files:
  clang-tools-extra/trunk/clangd/CodeComplete.cpp
  clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp

Index: clang-tools-extra/trunk/clangd/CodeComplete.cpp
===
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp
@@ -235,13 +235,28 @@
llvm::StringRef SemaDocComment) const {
 assert(bool(SemaResult) == bool(SemaCCS));
 CompletionItem I;
+bool ShouldInsertInclude = true;
 if (SemaResult) {
   I.kind = toCompletionItemKind(SemaResult->Kind, SemaResult->CursorKind);
   getLabelAndInsertText(*SemaCCS, &I.label, &I.insertText,
 Opts.EnableSnippets);
   I.filterText = getFilterText(*SemaCCS);
   I.documentation = formatDocumentation(*SemaCCS, SemaDocComment);
   I.detail = getDetail(*SemaCCS);
+  // Avoid inserting new #include if the declaration is found in the current
+  // file e.g. the symbol is forward declared.
+  if (SemaResult->Kind == CodeCompletionResult::RK_Declaration) {
+if (const auto *D = SemaResult->getDeclaration()) {
+  const auto &SM = D->getASTContext().getSourceManager();
+  ShouldInsertInclude =
+  ShouldInsertInclude &&
+  std::none_of(D->redecls_begin(), D->redecls_end(),
+   [&SM](const Decl *RD) {
+ return SM.isInMainFile(
+ SM.getExpansionLoc(RD->getLocStart()));
+   });
+}
+  }
 }
 if (IndexResult) {
   if (I.kind == CompletionItemKind::Missing)
@@ -263,7 +278,7 @@
   I.documentation = D->Documentation;
 if (I.detail.empty())
   I.detail = D->CompletionDetail;
-if (Includes && !D->IncludeHeader.empty()) {
+if (ShouldInsertInclude && Includes && !D->IncludeHeader.empty()) {
   auto Edit = [&]() -> Expected> {
 auto ResolvedDeclaring = toHeaderFile(
 IndexResult->CanonicalDeclaration.FileURI, FileName);
Index: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
@@ -159,7 +159,7 @@
   return sym(Name, index::SymbolKind::Function, "@F@\\0#"); // no args
 }
 Symbol cls(StringRef Name) {
-  return sym(Name, index::SymbolKind::Class, "@S@\\0@S@\\0");
+  return sym(Name, index::SymbolKind::Class, "@S@\\0");
 }
 Symbol var(StringRef Name) {
   return sym(Name, index::SymbolKind::Variable, "@\\0");
@@ -425,10 +425,9 @@
   auto Results = completions(
   R"cpp(
   class Adapter {
-void method();
   };
 
-  void Adapter::method() {
+  void f() {
 Adapter^
   }
   )cpp",
@@ -559,6 +558,37 @@
   ElementsAre(AllOf(Named("X"), Not(HasAdditionalEdits();
 }
 
+TEST(CompletionTest, NoIncludeInsertionWhenDeclFoundInFile) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+  Symbol::Details Scratch;
+  Symbol SymX = cls("ns::X");
+  Symbol SymY = cls("ns::Y");
+  std::string BarHeader = testPath("bar.h");
+  auto BarURI = URI::createFile(BarHeader).toString();
+  SymX.CanonicalDeclaration.FileURI = BarURI;
+  SymY.CanonicalDeclaration.FileURI = BarURI;
+  Scratch.IncludeHeader = "";
+  SymX.Detail = &Scratch;
+  SymY.Detail = &Scratch;
+  // Shoten include path based on search dirctory and insert.
+  auto Results = completions(Server,
+ R"cpp(
+  namespace ns {
+class X;
+class Y {}
+  }
+  int main() { ns::^ }
+  )cpp",
+ {SymX, SymY});
+  EXPECT_THAT(Results.items,
+  ElementsAre(AllOf(Named("X"), Not(HasAdditionalEdits())),
+  AllOf(Named("Y"), Not(HasAdditionalEdits();
+}
+
 TEST(CompletionTest, IndexSuppressesPreambleCompletions) {
   MockFSProvider FS;
   MockCompilationDatabase CDB;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47095: [clang-format/ObjC] Correctly parse Objective-C methods with 'class' in name

2018-05-30 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.

LG


Repository:
  rC Clang

https://reviews.llvm.org/D47095



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


r333522 - [ASTImporter] Corrected lookup at import of templated record decl

2018-05-30 Thread Gabor Marton via cfe-commits
Author: martong
Date: Wed May 30 02:19:26 2018
New Revision: 333522

URL: http://llvm.org/viewvc/llvm-project?rev=333522&view=rev
Log:
[ASTImporter] Corrected lookup at import of templated record decl

Summary:
When a CXXRecordDecl under ClassTemplateDecl is imported, check
the templated record decl for similarity instead of the template.

Reviewers: a.sidorin

Reviewed By: a.sidorin

Subscribers: martong, cfe-commits

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

Patch by Balazs Keri!

Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=333522&r1=333521&r2=333522&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Wed May 30 02:19:26 2018
@@ -2015,7 +2015,14 @@ Decl *ASTNodeImporter::VisitRecordDecl(R
 if (const auto *Tag = Typedef->getUnderlyingType()->getAs())
   Found = Tag->getDecl();
   }
-  
+
+  if (D->getDescribedTemplate()) {
+if (auto *Template = dyn_cast(Found))
+  Found = Template->getTemplatedDecl();
+else
+  continue;
+  }
+
   if (auto *FoundRecord = dyn_cast(Found)) {
 if (!SearchName) {
   // If both unnamed structs/unions are in a record context, make sure

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=333522&r1=333521&r2=333522&view=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Wed May 30 02:19:26 2018
@@ -1107,6 +1107,50 @@ TEST(ImportExpr, DependentSizedArrayType
  has(fieldDecl(hasType(dependentSizedArrayType(;
 }
 
+TEST_P(ASTImporterTestBase, ImportOfTemplatedDeclOfClassTemplateDecl) {
+  Decl *FromTU = getTuDecl("template struct S{};", Lang_CXX);
+  auto From =
+  FirstDeclMatcher().match(FromTU, classTemplateDecl());
+  ASSERT_TRUE(From);
+  auto To = cast(Import(From, Lang_CXX));
+  ASSERT_TRUE(To);
+  Decl *ToTemplated = To->getTemplatedDecl();
+  Decl *ToTemplated1 = Import(From->getTemplatedDecl(), Lang_CXX);
+  EXPECT_TRUE(ToTemplated1);
+  EXPECT_EQ(ToTemplated1, ToTemplated);
+}
+
+TEST_P(ASTImporterTestBase, ImportCorrectTemplatedDecl) {
+  auto Code =
+R"(
+namespace x {
+  template struct S1{};
+  template struct S2{};
+  template struct S3{};
+}
+)";
+  Decl *FromTU = getTuDecl(Code, Lang_CXX);
+  auto FromNs =
+  FirstDeclMatcher().match(FromTU, namespaceDecl());
+  auto ToNs = cast(Import(FromNs, Lang_CXX));
+  ASSERT_TRUE(ToNs);
+  auto From =
+  FirstDeclMatcher().match(FromTU,
+  classTemplateDecl(
+  hasName("S2")));
+  auto To =
+  FirstDeclMatcher().match(ToNs,
+  classTemplateDecl(
+  hasName("S2")));
+  ASSERT_TRUE(From);
+  ASSERT_TRUE(To);
+  auto ToTemplated = To->getTemplatedDecl();
+  auto ToTemplated1 =
+  cast(Import(From->getTemplatedDecl(), Lang_CXX));
+  EXPECT_TRUE(ToTemplated1);
+  ASSERT_EQ(ToTemplated1, ToTemplated);
+}
+
 TEST_P(ASTImporterTestBase, DISABLED_ImportFunctionWithBackReferringParameter) 
{
   Decl *From, *To;
   std::tie(From, To) = getImportedDecl(


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


[PATCH] D47520: [clang-format] Allow break between question and lambda

2018-05-30 Thread Attila via Phabricator via cfe-commits
Uran198 created this revision.
Uran198 added reviewers: djasper, klimek.

Before the change clang-format would break and make no reformatting.


Repository:
  rC Clang

https://reviews.llvm.org/D47520

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


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -4682,6 +4682,14 @@
   "aa =  ? aa ? 
a\n"
   "   : aa\n"
   "  : ;");
+  verifyFormat(
+  "aa =  ?\n"
+  "  [&]() { //\n"
+  "return true;\n"
+  "  }()\n"
+  "  ? \n"
+  "  : aaa\n"
+  "  : ;");
 
   FormatStyle NoBinPacking = getLLVMStyle();
   NoBinPacking.BinPackArguments = false;
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -3015,6 +3015,8 @@
 return false;
   if (Right.is(TT_ConditionalExpr) || Right.is(tok::question))
 return Style.BreakBeforeTernaryOperators;
+  if (Left.is(tok::question) && Right.is(TT_LambdaLSquare))
+return true;
   if (Left.is(TT_ConditionalExpr) || Left.is(tok::question))
 return !Style.BreakBeforeTernaryOperators;
   if (Right.is(TT_InheritanceColon))


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -4682,6 +4682,14 @@
   "aa =  ? aa ? a\n"
   "   : aa\n"
   "  : ;");
+  verifyFormat(
+  "aa =  ?\n"
+  "  [&]() { //\n"
+  "return true;\n"
+  "  }()\n"
+  "  ? \n"
+  "  : aaa\n"
+  "  : ;");
 
   FormatStyle NoBinPacking = getLLVMStyle();
   NoBinPacking.BinPackArguments = false;
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -3015,6 +3015,8 @@
 return false;
   if (Right.is(TT_ConditionalExpr) || Right.is(tok::question))
 return Style.BreakBeforeTernaryOperators;
+  if (Left.is(tok::question) && Right.is(TT_LambdaLSquare))
+return true;
   if (Left.is(TT_ConditionalExpr) || Left.is(tok::question))
 return !Style.BreakBeforeTernaryOperators;
   if (Right.is(TT_InheritanceColon))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47313: [ASTImporter] Corrected lookup at import of templated record decl

2018-05-30 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC333522: [ASTImporter] Corrected lookup at import of 
templated record decl (authored by martong, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47313?vs=148361&id=149065#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47313

Files:
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp


Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -2015,7 +2015,14 @@
 if (const auto *Tag = Typedef->getUnderlyingType()->getAs())
   Found = Tag->getDecl();
   }
-  
+
+  if (D->getDescribedTemplate()) {
+if (auto *Template = dyn_cast(Found))
+  Found = Template->getTemplatedDecl();
+else
+  continue;
+  }
+
   if (auto *FoundRecord = dyn_cast(Found)) {
 if (!SearchName) {
   // If both unnamed structs/unions are in a record context, make sure
Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -1107,6 +1107,50 @@
  has(fieldDecl(hasType(dependentSizedArrayType(;
 }
 
+TEST_P(ASTImporterTestBase, ImportOfTemplatedDeclOfClassTemplateDecl) {
+  Decl *FromTU = getTuDecl("template struct S{};", Lang_CXX);
+  auto From =
+  FirstDeclMatcher().match(FromTU, classTemplateDecl());
+  ASSERT_TRUE(From);
+  auto To = cast(Import(From, Lang_CXX));
+  ASSERT_TRUE(To);
+  Decl *ToTemplated = To->getTemplatedDecl();
+  Decl *ToTemplated1 = Import(From->getTemplatedDecl(), Lang_CXX);
+  EXPECT_TRUE(ToTemplated1);
+  EXPECT_EQ(ToTemplated1, ToTemplated);
+}
+
+TEST_P(ASTImporterTestBase, ImportCorrectTemplatedDecl) {
+  auto Code =
+R"(
+namespace x {
+  template struct S1{};
+  template struct S2{};
+  template struct S3{};
+}
+)";
+  Decl *FromTU = getTuDecl(Code, Lang_CXX);
+  auto FromNs =
+  FirstDeclMatcher().match(FromTU, namespaceDecl());
+  auto ToNs = cast(Import(FromNs, Lang_CXX));
+  ASSERT_TRUE(ToNs);
+  auto From =
+  FirstDeclMatcher().match(FromTU,
+  classTemplateDecl(
+  hasName("S2")));
+  auto To =
+  FirstDeclMatcher().match(ToNs,
+  classTemplateDecl(
+  hasName("S2")));
+  ASSERT_TRUE(From);
+  ASSERT_TRUE(To);
+  auto ToTemplated = To->getTemplatedDecl();
+  auto ToTemplated1 =
+  cast(Import(From->getTemplatedDecl(), Lang_CXX));
+  EXPECT_TRUE(ToTemplated1);
+  ASSERT_EQ(ToTemplated1, ToTemplated);
+}
+
 TEST_P(ASTImporterTestBase, DISABLED_ImportFunctionWithBackReferringParameter) 
{
   Decl *From, *To;
   std::tie(From, To) = getImportedDecl(


Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -2015,7 +2015,14 @@
 if (const auto *Tag = Typedef->getUnderlyingType()->getAs())
   Found = Tag->getDecl();
   }
-  
+
+  if (D->getDescribedTemplate()) {
+if (auto *Template = dyn_cast(Found))
+  Found = Template->getTemplatedDecl();
+else
+  continue;
+  }
+
   if (auto *FoundRecord = dyn_cast(Found)) {
 if (!SearchName) {
   // If both unnamed structs/unions are in a record context, make sure
Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -1107,6 +1107,50 @@
  has(fieldDecl(hasType(dependentSizedArrayType(;
 }
 
+TEST_P(ASTImporterTestBase, ImportOfTemplatedDeclOfClassTemplateDecl) {
+  Decl *FromTU = getTuDecl("template struct S{};", Lang_CXX);
+  auto From =
+  FirstDeclMatcher().match(FromTU, classTemplateDecl());
+  ASSERT_TRUE(From);
+  auto To = cast(Import(From, Lang_CXX));
+  ASSERT_TRUE(To);
+  Decl *ToTemplated = To->getTemplatedDecl();
+  Decl *ToTemplated1 = Import(From->getTemplatedDecl(), Lang_CXX);
+  EXPECT_TRUE(ToTemplated1);
+  EXPECT_EQ(ToTemplated1, ToTemplated);
+}
+
+TEST_P(ASTImporterTestBase, ImportCorrectTemplatedDecl) {
+  auto Code =
+R"(
+namespace x {
+  template struct S1{};
+  template struct S2{};
+  template struct S3{};
+}
+)";
+  Decl *FromTU = getTuDecl(Code, Lang_CXX);
+  auto FromNs =
+  FirstDeclMatcher().match(FromTU, namespaceDecl());
+  auto ToNs = cast(Import(FromNs, Lang_CXX));
+  ASSERT_TRUE(ToNs);
+  auto From =
+  FirstDeclMatcher().match(FromTU,
+  classTemplateD

[PATCH] D47521: [clang-format] Fix parsing lambdas with noexcept

2018-05-30 Thread Attila via Phabricator via cfe-commits
Uran198 created this revision.
Uran198 added reviewers: klimek, djasper.

Repository:
  rC Clang

https://reviews.llvm.org/D47521

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


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11522,6 +11522,12 @@
"  ;\n"
"};");
 
+  verifyFormat("if (a && []() noexcept {\n"
+   "  doo_dah();\n"
+   "  doo_dah();\n"
+   "}()) {\n"
+   "}");
+
   // Lambdas with complex multiline introducers.
   verifyFormat(
   "a.(\n"
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1387,6 +1387,7 @@
 case tok::amp:
 case tok::star:
 case tok::kw_const:
+case tok::kw_noexcept:
 case tok::comma:
 case tok::less:
 case tok::greater:


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11522,6 +11522,12 @@
"  ;\n"
"};");
 
+  verifyFormat("if (a && []() noexcept {\n"
+   "  doo_dah();\n"
+   "  doo_dah();\n"
+   "}()) {\n"
+   "}");
+
   // Lambdas with complex multiline introducers.
   verifyFormat(
   "a.(\n"
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1387,6 +1387,7 @@
 case tok::amp:
 case tok::star:
 case tok::kw_const:
+case tok::kw_noexcept:
 case tok::comma:
 case tok::less:
 case tok::greater:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47063: [clangd] Keep only a limited number of idle ASTs in memory

2018-05-30 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 149073.
ilya-biryukov marked 2 inline comments as done.
ilya-biryukov added a comment.

- Added a unit test
- Address review comments
- Add ASTRetentionPolicy param to ClangdServer


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47063

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h
  test/clangd/trace.test
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/TUSchedulerTests.cpp

Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -18,8 +18,11 @@
 namespace clang {
 namespace clangd {
 
+using ::testing::_;
+using ::testing::AnyOf;
 using ::testing::Pair;
 using ::testing::Pointee;
+using ::testing::UnorderedElementsAre;
 
 void ignoreUpdate(llvm::Optional>) {}
 void ignoreError(llvm::Error Err) {
@@ -43,7 +46,8 @@
   TUScheduler S(getDefaultAsyncThreadsCount(),
 /*StorePreamblesInMemory=*/true,
 /*PreambleParsedCallback=*/nullptr,
-/*UpdateDebounce=*/std::chrono::steady_clock::duration::zero());
+/*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
+ASTRetentionPolicy());
 
   auto Added = testPath("added.cpp");
   Files[Added] = "";
@@ -99,7 +103,8 @@
 getDefaultAsyncThreadsCount(),
 /*StorePreamblesInMemory=*/true,
 /*PreambleParsedCallback=*/nullptr,
-/*UpdateDebounce=*/std::chrono::steady_clock::duration::zero());
+/*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
+ASTRetentionPolicy());
 auto Path = testPath("foo.cpp");
 S.update(Path, getInputs(Path, ""), WantDiagnostics::Yes,
  [&](std::vector) { Ready.wait(); });
@@ -127,7 +132,8 @@
 TUScheduler S(getDefaultAsyncThreadsCount(),
   /*StorePreamblesInMemory=*/true,
   /*PreambleParsedCallback=*/nullptr,
-  /*UpdateDebounce=*/std::chrono::seconds(1));
+  /*UpdateDebounce=*/std::chrono::seconds(1),
+  ASTRetentionPolicy());
 // FIXME: we could probably use timeouts lower than 1 second here.
 auto Path = testPath("foo.cpp");
 S.update(Path, getInputs(Path, "auto (debounced)"), WantDiagnostics::Auto,
@@ -158,7 +164,8 @@
 TUScheduler S(getDefaultAsyncThreadsCount(),
   /*StorePreamblesInMemory=*/true,
   /*PreambleParsedCallback=*/nullptr,
-  /*UpdateDebounce=*/std::chrono::milliseconds(50));
+  /*UpdateDebounce=*/std::chrono::milliseconds(50),
+  ASTRetentionPolicy());
 
 std::vector Files;
 for (int I = 0; I < FilesCount; ++I) {
@@ -219,18 +226,18 @@
 
 {
   WithContextValue WithNonce(NonceKey, ++Nonce);
-  S.runWithPreamble(
-  "CheckPreamble", File,
-  [Inputs, Nonce, &Mut, &TotalPreambleReads](
-  llvm::Expected Preamble) {
-EXPECT_THAT(Context::current().get(NonceKey), Pointee(Nonce));
-
-ASSERT_TRUE((bool)Preamble);
-EXPECT_EQ(Preamble->Contents, Inputs.Contents);
-
-std::lock_guard Lock(Mut);
-++TotalPreambleReads;
-  });
+  S.runWithPreamble("CheckPreamble", File,
+[Inputs, Nonce, &Mut, &TotalPreambleReads](
+llvm::Expected Preamble) {
+  EXPECT_THAT(Context::current().get(NonceKey),
+  Pointee(Nonce));
+
+  ASSERT_TRUE((bool)Preamble);
+  EXPECT_EQ(Preamble->Contents, Inputs.Contents);
+
+  std::lock_guard Lock(Mut);
+  ++TotalPreambleReads;
+});
 }
   }
 }
@@ -242,5 +249,55 @@
   EXPECT_EQ(TotalPreambleReads, FilesCount * UpdatesPerFile);
 }
 
+TEST_F(TUSchedulerTests, EvictedAST) {
+  ASTRetentionPolicy Policy;
+  Policy.MaxRetainedASTs = 2;
+  TUScheduler S(
+  /*AsyncThreadsCount=*/1, /*StorePreambleInMemory=*/true,
+  PreambleParsedCallback(),
+  /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(), Policy);
+
+  llvm::StringLiteral SourceContents = R"cpp(
+int* a;
+double* b = a;
+  )cpp";
+
+  auto Foo = testPath("foo.cpp");
+  auto Bar = testPath("bar.cpp");
+  auto Baz = testPath("baz.cpp");
+
+  std::atomic BuiltASTCounter;
+  BuiltASTCounter = false;
+  // Build one file in advance. We will not access it later, so it will be the
+  // one that the cache will evict.
+  S.update(Foo, getInputs(Foo, SourceContents), WantDiagnostics::Yes,
+   [&BuiltASTCounter](std::vector Diags) { ++BuiltASTCou

[PATCH] D47063: [clangd] Keep only a limited number of idle ASTs in memory

2018-05-30 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdUnit.h:143
+std::shared_ptr
+buildPreamble(PathRef FileName, CompilerInvocation &CI,
+  std::shared_ptr OldPreamble,

sammccall wrote:
> nit: i think filename here is only used for logging, just use 
> Inputs.CompileCommand.Filename?
Tried doing that, but the filename parameter is actually passed to 
PreambleCallback that updates the dynamic index. Using filename from compile 
command there seems fragile, so I kept the parameter for now.



Comment at: clangd/TUScheduler.h:66
+  std::chrono::steady_clock::duration UpdateDebounce,
+  ASTRetentionPolicy RetentionPolicy = {});
   ~TUScheduler();

sammccall wrote:
> does this actually have more than one caller? what's the plan for exposing 
> this option to embedders/CLI users (not saying we necessarily need the 
> latter)?
Yes, just one caller outside the tests.
The plan was to expose it only in `ClangdServer` for now. Giving this knob in 
CLI might be useful, if we have good reasons for that, but I hope that we could 
pick the default that work for everyone instead.
Added that as a parameter of `ClangdServer`.

Maybe we should move the default value of 3 to `ClangdServer`? WDYT?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47063



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


[PATCH] D47527: Revert "[clang-format] Fix putting ObjC message arguments in one line for multiline receiver"

2018-05-30 Thread Jacek Olesiak via Phabricator via cfe-commits
jolesiak created this revision.
Herald added subscribers: cfe-commits, klimek.

This reverts commit db9e5e9a616d7fdd4d1ba4c3b2cd89d8a0238533.


Repository:
  rC Clang

https://reviews.llvm.org/D47527

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


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -796,41 +796,6 @@
   verifyFormat("[((Foo *)foo) bar];");
   verifyFormat("[((Foo *)foo) bar:1 blech:2];");
 
-  // Message receiver taking multiple lines.
-  Style.ColumnLimit = 20;
-  // Non-corner case.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] a:42 b:42];");
-  // Arguments just fit into one line.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] aaa:42 b:42];");
-  // Arguments just over a column limit.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] aaa:42\n"
-   "bb:42];");
-  // Arguments just fit into one line.
-  Style.ColumnLimit = 23;
-  verifyFormat("[[obj a:42\n"
-   "  b:42\n"
-   "  c:42\n"
-   "  d:42] e:42 f:42];");
-
-  // Arguments do not fit into one line with a receiver.
-  Style.ColumnLimit = 20;
-  verifyFormat("[[obj a:42] a:42\n"
-   "b:42];");
-  verifyFormat("[[obj a:42] a:42\n"
-   "b:42\n"
-   "c:42];");
-  verifyFormat("[[obj aa:42\n"
-   "   b:42]\n"
-   "cc:42\n"
-   " d:42];");
-
-
   Style.ColumnLimit = 70;
   verifyFormat(
   "void f() {\n"
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1387,29 +1387,6 @@
(Current.is(tok::greater) && Current.is(TT_DictLiteral
 State.Stack.pop_back();
 
-  // Reevaluate whether ObjC message arguments fit into one line.
-  // If a receiver spans multiple lines, e.g.:
-  //   [[object block:^{
-  // return 42;
-  //   }] a:42 b:42];
-  // BreakBeforeParameter is calculated based on an incorrect assumption
-  // (it is checked whether the whole expression fits into one line without
-  // considering a line break inside a message receiver).
-  // We check whether arguements fit after receiver scope closer (into the same
-  // line).
-  if (Current.MatchingParen && Current.MatchingParen->Previous) {
-const FormatToken &CurrentScopeOpener = *Current.MatchingParen->Previous;
-if (CurrentScopeOpener.is(TT_ObjCMethodExpr) &&
-CurrentScopeOpener.MatchingParen) {
-  int NecessarySpaceInLine =
-  getLengthToMatchingParen(CurrentScopeOpener, State.Stack) +
-  CurrentScopeOpener.TotalLength - Current.TotalLength - 1;
-  if (State.Column + Current.ColumnWidth + NecessarySpaceInLine <=
-  Style.ColumnLimit)
-State.Stack.back().BreakBeforeParameter = false;
-}
-  }
-
   if (Current.is(tok::r_square)) {
 // If this ends the array subscript expr, reset the corresponding value.
 const FormatToken *NextNonComment = Current.getNextNonComment();


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -796,41 +796,6 @@
   verifyFormat("[((Foo *)foo) bar];");
   verifyFormat("[((Foo *)foo) bar:1 blech:2];");
 
-  // Message receiver taking multiple lines.
-  Style.ColumnLimit = 20;
-  // Non-corner case.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] a:42 b:42];");
-  // Arguments just fit into one line.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] aaa:42 b:42];");
-  // Arguments just over a column limit.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] aaa:42\n"
-   "bb:42];");
-  // Arguments just fit into one line.
-  Style.ColumnLimit = 23;
-  verifyFormat("[[obj a:42\n"
-   "  b:42\n"
-   "  c:42\n"
-   "  d:42] e:42 f:42];");
-
-  // Arguments do not fit into one line with a receiver.
-  Style.ColumnLimit = 20;
-  verifyFormat("[[obj a:42] a:42\n"
-   "b:42];");
-  verifyFormat("[[obj a:42] a:42\n"
-   "b:42\n"
-   "c:42];");
-  verifyFormat("[[obj aa:42\n"
-   "   b:42]\n"
-   "cc:42\n"
-   " d:42];");
-
-
   Style.ColumnLimit = 70;
   verifyFormat(
   "void f() {\n"
Index: lib/Format/ContinuationIndenter.cpp
===

[PATCH] D47063: [clangd] Keep only a limited number of idle ASTs in memory

2018-05-30 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 149075.
ilya-biryukov added a comment.

- Fixed formatting


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47063

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h
  test/clangd/trace.test
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/TUSchedulerTests.cpp

Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -18,8 +18,11 @@
 namespace clang {
 namespace clangd {
 
+using ::testing::_;
+using ::testing::AnyOf;
 using ::testing::Pair;
 using ::testing::Pointee;
+using ::testing::UnorderedElementsAre;
 
 void ignoreUpdate(llvm::Optional>) {}
 void ignoreError(llvm::Error Err) {
@@ -43,7 +46,8 @@
   TUScheduler S(getDefaultAsyncThreadsCount(),
 /*StorePreamblesInMemory=*/true,
 /*PreambleParsedCallback=*/nullptr,
-/*UpdateDebounce=*/std::chrono::steady_clock::duration::zero());
+/*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
+ASTRetentionPolicy());
 
   auto Added = testPath("added.cpp");
   Files[Added] = "";
@@ -99,7 +103,8 @@
 getDefaultAsyncThreadsCount(),
 /*StorePreamblesInMemory=*/true,
 /*PreambleParsedCallback=*/nullptr,
-/*UpdateDebounce=*/std::chrono::steady_clock::duration::zero());
+/*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
+ASTRetentionPolicy());
 auto Path = testPath("foo.cpp");
 S.update(Path, getInputs(Path, ""), WantDiagnostics::Yes,
  [&](std::vector) { Ready.wait(); });
@@ -127,7 +132,8 @@
 TUScheduler S(getDefaultAsyncThreadsCount(),
   /*StorePreamblesInMemory=*/true,
   /*PreambleParsedCallback=*/nullptr,
-  /*UpdateDebounce=*/std::chrono::seconds(1));
+  /*UpdateDebounce=*/std::chrono::seconds(1),
+  ASTRetentionPolicy());
 // FIXME: we could probably use timeouts lower than 1 second here.
 auto Path = testPath("foo.cpp");
 S.update(Path, getInputs(Path, "auto (debounced)"), WantDiagnostics::Auto,
@@ -158,7 +164,8 @@
 TUScheduler S(getDefaultAsyncThreadsCount(),
   /*StorePreamblesInMemory=*/true,
   /*PreambleParsedCallback=*/nullptr,
-  /*UpdateDebounce=*/std::chrono::milliseconds(50));
+  /*UpdateDebounce=*/std::chrono::milliseconds(50),
+  ASTRetentionPolicy());
 
 std::vector Files;
 for (int I = 0; I < FilesCount; ++I) {
@@ -219,18 +226,18 @@
 
 {
   WithContextValue WithNonce(NonceKey, ++Nonce);
-  S.runWithPreamble(
-  "CheckPreamble", File,
-  [Inputs, Nonce, &Mut, &TotalPreambleReads](
-  llvm::Expected Preamble) {
-EXPECT_THAT(Context::current().get(NonceKey), Pointee(Nonce));
-
-ASSERT_TRUE((bool)Preamble);
-EXPECT_EQ(Preamble->Contents, Inputs.Contents);
-
-std::lock_guard Lock(Mut);
-++TotalPreambleReads;
-  });
+  S.runWithPreamble("CheckPreamble", File,
+[Inputs, Nonce, &Mut, &TotalPreambleReads](
+llvm::Expected Preamble) {
+  EXPECT_THAT(Context::current().get(NonceKey),
+  Pointee(Nonce));
+
+  ASSERT_TRUE((bool)Preamble);
+  EXPECT_EQ(Preamble->Contents, Inputs.Contents);
+
+  std::lock_guard Lock(Mut);
+  ++TotalPreambleReads;
+});
 }
   }
 }
@@ -242,5 +249,55 @@
   EXPECT_EQ(TotalPreambleReads, FilesCount * UpdatesPerFile);
 }
 
+TEST_F(TUSchedulerTests, EvictedAST) {
+  ASTRetentionPolicy Policy;
+  Policy.MaxRetainedASTs = 2;
+  TUScheduler S(
+  /*AsyncThreadsCount=*/1, /*StorePreambleInMemory=*/true,
+  PreambleParsedCallback(),
+  /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(), Policy);
+
+  llvm::StringLiteral SourceContents = R"cpp(
+int* a;
+double* b = a;
+  )cpp";
+
+  auto Foo = testPath("foo.cpp");
+  auto Bar = testPath("bar.cpp");
+  auto Baz = testPath("baz.cpp");
+
+  std::atomic BuiltASTCounter;
+  BuiltASTCounter = false;
+  // Build one file in advance. We will not access it later, so it will be the
+  // one that the cache will evict.
+  S.update(Foo, getInputs(Foo, SourceContents), WantDiagnostics::Yes,
+   [&BuiltASTCounter](std::vector Diags) { ++BuiltASTCounter; });
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(1)));
+  ASSERT_EQ(BuiltASTCounter.load(), 1);
+
+  // Build two 

[PATCH] D47394: [OpenMP][Clang][NVPTX] Replace bundling with partial linking for the OpenMP NVPTX device offloading toolchain

2018-05-30 Thread Samuel Antao via Phabricator via cfe-commits
sfantao added a comment.

> In a discussion off-list I proposed adding constructor functions to all 
> object files and handle them like shared libraries are already handled today 
> (ie register separately and let the runtime figure out how to relocate 
> symbols in different translation units). I don't have an implementation of 
> that approach so I can't claim that it works and doesn't have a huge 
> performance impact (which we don't want either), but it should be agnostic of 
> the offloading target so it may be worth investigating.

I don't understand how this would work. Doing something like that would require 
reimplementing the GPU-code linker, which requires knowing proprietary 
information of the GPU binary format. I would know how to resolve all the 
relocations in the device code. In my view, the solution would only work (or at 
least be more easily implemented) if we don't have relocatable code.

> Assuming we do proceed with back-to-CUDA approach, one thing I'd consider 
> would be using clang's -fcuda-include-gpubinary option which CUDA uses to 
> include GPU code into the host object. You may be able to use it to avoid 
> compiling and partially linking .fatbin and host .o.

Cool, I agree this is worth investigating.




Comment at: lib/Driver/ToolChains/Cuda.cpp:536
+  }
 }
 

gtbercea wrote:
> sfantao wrote:
> > What prevents all this from being done in the bundler? If I understand it 
> > correctly, if the bundler implements this wrapping all the checks for 
> > librariers wouldn't be required and, only two changes would be required in 
> > the driver:
> > 
> > - generate fatbin instead of cubin. This is straightforward to do by 
> > changing the device assembling job. In terms of the loading of the kernels 
> > by the device API, doing it through fatbin or cubin should be equivalent 
> > except that fatbin enables storing the PTX format and JIT for newer GPUs.
> > - Use NVIDIA linker as host linker.
> > 
> > This last requirement could be problematic if we get two targets attempting 
> >  to use different (incompatible linkers). If we get this kind of 
> > incompatibility we should get the appropriate diagnostic.
> What prevents it is the fact that the bundler is called AFTER the HOST and 
> DEVICE object files have been produced. The creation of the fatbin (FATBINARY 
> + CALNG++) needs to happen within the NVPTX toolchain.
> 
Why does it have to happen in NVPTX toolchain, you are making the NVPTX 
toolchain generate an ELF object from another toolchain, right? What I'm 
suggesting is to do the stuff that mixes two (or more) toolchains in the 
bundler. Your inputs are still a fatbin and a host file.   



Comment at: test/Driver/openmp-offload.c:497
 // RUN:   %clang -###  -fopenmp=libomp -o %t.out -lsomelib -target 
powerpc64le-linux 
-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i 
-no-canonical-prefixes 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-UBJOBS %s
 // RUN:   %clang -### -fopenmp=libomp -o %t.out -lsomelib -target 
powerpc64le-linux 
-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i -save-temps 
-no-canonical-prefixes 2>&1 \

gtbercea wrote:
> gtbercea wrote:
> > sfantao wrote:
> > > We need a test for the static linking. The host linker has to be nvcc in 
> > > that case, right?
> > The host linker is "ld". The "bundling" step is replaced (in the case of 
> > OpenMP NVPTX device offloading only) by a call to "ld -r" to partially link 
> > the 2 object files: the object file produced by the HOST toolchain and the 
> > object file produced by the OpenMP NVPTX device offloading toolchain 
> > (because we want to produce a single output).
> nvcc is not called at all in this patch.
Ok, so how do you link device code? I.e. if you have two compilation units that 
depend on each other (some definition in one unit is used in the other), where 
are they linked together? Something has to understand the two files resulting 
from your "ld -r" step, my understanding is that that something is nvcc that 
calls nvlink behind the scenes, right? So, nvcc will do the unbundling+linking 
bit, right?


Repository:
  rC Clang

https://reviews.llvm.org/D47394



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


[PATCH] D47459: [ASTImporter] Eliminated some unittest warnings.

2018-05-30 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 149079.
balazske added a comment.

[ASTImporter] Fixed test code in ASTImporter tests.

Test code is fixed instead of turn off the warnings.
For this to work change of match expressions was needed.


Repository:
  rC Clang

https://reviews.llvm.org/D47459

Files:
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -427,117 +427,99 @@
 
 TEST(ImportExpr, ImportStringLiteral) {
   MatchVerifier Verifier;
-  testImport("void declToImport() { \"foo\"; }",
+  testImport("void declToImport() { (void)\"foo\"; }",
  Lang_CXX, "", Lang_CXX, Verifier,
  functionDecl(
-   hasBody(
- compoundStmt(
-   has(
- stringLiteral(
-   hasType(
- asString("const char [4]";
-  testImport("void declToImport() { L\"foo\"; }",
+   hasDescendant(
+ stringLiteral(
+   hasType(
+ asString("const char [4]"));
+  testImport("void declToImport() { (void)L\"foo\"; }",
  Lang_CXX, "", Lang_CXX, Verifier,
  functionDecl(
-   hasBody(
- compoundStmt(
-   has(
- stringLiteral(
-   hasType(
-asString("const wchar_t [4]";
-  testImport("void declToImport() { \"foo\" \"bar\"; }",
+   hasDescendant(
+ stringLiteral(
+   hasType(
+ asString("const wchar_t [4]"));
+  testImport("void declToImport() { (void) \"foo\" \"bar\"; }",
  Lang_CXX, "", Lang_CXX, Verifier,
  functionDecl(
-   hasBody(
- compoundStmt(
-   has(
- stringLiteral(
-   hasType(
- asString("const char [7]";
+   hasDescendant(
+ stringLiteral(
+   hasType(
+ asString("const char [7]"));
 }
 
 TEST(ImportExpr, ImportGNUNullExpr) {
   MatchVerifier Verifier;
-  testImport("void declToImport() { __null; }",
+  testImport("void declToImport() { (void)__null; }",
  Lang_CXX, "", Lang_CXX, Verifier,
  functionDecl(
-   hasBody(
- compoundStmt(
-   has(
- gnuNullExpr(
-   hasType(isInteger(;
+   hasDescendant(
+ gnuNullExpr(
+   hasType(isInteger());
 }
 
 TEST(ImportExpr, ImportCXXNullPtrLiteralExpr) {
   MatchVerifier Verifier;
-  testImport("void declToImport() { nullptr; }",
+  testImport("void declToImport() { (void)nullptr; }",
  Lang_CXX11, "", Lang_CXX11, Verifier,
  functionDecl(
-   hasBody(
- compoundStmt(
-   has(
- cxxNullPtrLiteralExpr());
+   hasDescendant(
+ cxxNullPtrLiteralExpr(;
 }
 
 
 TEST(ImportExpr, ImportFloatinglLiteralExpr) {
   MatchVerifier Verifier;
-  testImport("void declToImport() { 1.0; }",
+  testImport("void declToImport() { (void)1.0; }",
  Lang_C, "", Lang_C, Verifier,
  functionDecl(
-   hasBody(
- compoundStmt(
-   has(
- floatLiteral(
-   equals(1.0),
-   hasType(asString("double";
-  testImport("void declToImport() { 1.0e-5f; }",
+   hasDescendant(
+ floatLiteral(
+   equals(1.0),
+   hasType(asString("double"));
+  testImport("void declToImport() { (void)1.0e-5f; }",
   Lang_C, "", Lang_C, Verifier,
   functionDecl(
-hasBody(
-  compoundStmt(
-has(
-  floatLiteral(
-equals(1.0e-5f),
-hasType(asString("float";
+hasDescendant(
+  floatLiteral(
+equals(1.0e-5f),
+hasType(asString("float"));
 }
 
 TEST(ImportExpr, ImportCompoundLiteralExpr) {
   MatchVerifier Verifier;
   testImport("void declToImport() {"
  "  struct s { int x; long y; unsigned z; }; "
- "  (struct s){ 42, 0L, 1U }; }",
+ "  (void) (struct s){ 42, 0L, 1U }; }",
  Lang_CXX, "", Lang_CXX, Verifier,
  functionDecl(
-   hasBody(
- compoundStmt(
-   has(
- compoundLiteralExpr(
-   hasType(asString("struct s")),
- 

[clang-tools-extra] r333528 - [clangd] Enable parsing of non-doxygen comments in global-symbol-builder

2018-05-30 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed May 30 03:43:00 2018
New Revision: 333528

URL: http://llvm.org/viewvc/llvm-project?rev=333528&view=rev
Log:
[clangd] Enable parsing of non-doxygen comments in global-symbol-builder

Reviewers: ioeric, sammccall

Reviewed By: ioeric

Subscribers: klimek, MaskRay, jkorous, cfe-commits

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

Modified:

clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp

Modified: 
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp?rev=333528&r1=333527&r2=333528&view=diff
==
--- 
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
 (original)
+++ 
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
 Wed May 30 03:43:00 2018
@@ -73,6 +73,12 @@ public:
 return WrapperFrontendAction::CreateASTConsumer(CI, InFile);
   }
 
+  bool BeginInvocation(CompilerInstance &CI) override {
+// We want all comments, not just the doxygen ones.
+CI.getLangOpts().CommentOpts.ParseAllComments = true;
+return WrapperFrontendAction::BeginInvocation(CI);
+  }
+
   void EndSourceFileAction() override {
 WrapperFrontendAction::EndSourceFileAction();
 


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


[PATCH] D47065: [clangd] Enable parsing of non-doxygen comments in global-symbol-builder

2018-05-30 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333528: [clangd] Enable parsing of non-doxygen comments in 
global-symbol-builder (authored by ibiryukov, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D47065

Files:
  
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp


Index: 
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
===
--- 
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
+++ 
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
@@ -73,6 +73,12 @@
 return WrapperFrontendAction::CreateASTConsumer(CI, InFile);
   }
 
+  bool BeginInvocation(CompilerInstance &CI) override {
+// We want all comments, not just the doxygen ones.
+CI.getLangOpts().CommentOpts.ParseAllComments = true;
+return WrapperFrontendAction::BeginInvocation(CI);
+  }
+
   void EndSourceFileAction() override {
 WrapperFrontendAction::EndSourceFileAction();
 


Index: clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
===
--- clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
+++ clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
@@ -73,6 +73,12 @@
 return WrapperFrontendAction::CreateASTConsumer(CI, InFile);
   }
 
+  bool BeginInvocation(CompilerInstance &CI) override {
+// We want all comments, not just the doxygen ones.
+CI.getLangOpts().CommentOpts.ParseAllComments = true;
+return WrapperFrontendAction::BeginInvocation(CI);
+  }
+
   void EndSourceFileAction() override {
 WrapperFrontendAction::EndSourceFileAction();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r333513 - Support __iso_volatile_load8 etc on aarch64-win32.

2018-05-30 Thread Simon Tatham via cfe-commits
Author: statham
Date: Wed May 30 00:54:05 2018
New Revision: 333513

URL: http://llvm.org/viewvc/llvm-project?rev=333513&view=rev
Log:
Support __iso_volatile_load8 etc on aarch64-win32.

These intrinsics are used by MSVC's header files on AArch64 Windows as
well as AArch32, so we should support them for both targets. I've
factored them out of CodeGenFunction::EmitARMBuiltinExpr into separate
functions that EmitAArch64BuiltinExpr can call as well.

Reviewers: javed.absar, mstorsjo

Reviewed By: mstorsjo

Subscribers: kristof.beyls, cfe-commits

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

Added:
cfe/trunk/test/CodeGen/ms-volatile-aarch64.c   (with props)
Modified:
cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAArch64.def?rev=333513&r1=333512&r2=333513&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAArch64.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAArch64.def Wed May 30 00:54:05 2018
@@ -69,5 +69,15 @@ LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_L
 LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
 LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
 
+// MSVC intrinsics for volatile but non-acquire/release loads and stores
+LANGBUILTIN(__iso_volatile_load8,   "ccCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load16,  "ssCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load32,  "iiCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load64,  "LLiLLiCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store8,  "vcD*c", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store16, "vsD*s", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store32, "viD*i", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_store64, "vLLiD*LLi", "n", ALL_MS_LANGUAGES)
+
 #undef BUILTIN
 #undef LANGBUILTIN

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=333513&r1=333512&r2=333513&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed May 30 00:54:05 2018
@@ -5179,6 +5179,34 @@ static bool HasExtraNeonArgument(unsigne
   return true;
 }
 
+Value *CodeGenFunction::EmitISOVolatileLoad(const CallExpr *E) {
+  Value *Ptr = EmitScalarExpr(E->getArg(0));
+  QualType ElTy = E->getArg(0)->getType()->getPointeeType();
+  CharUnits LoadSize = getContext().getTypeSizeInChars(ElTy);
+  llvm::Type *ITy = llvm::IntegerType::get(getLLVMContext(),
+   LoadSize.getQuantity() * 8);
+  Ptr = Builder.CreateBitCast(Ptr, ITy->getPointerTo());
+  llvm::LoadInst *Load =
+Builder.CreateAlignedLoad(Ptr, LoadSize);
+  Load->setVolatile(true);
+  return Load;
+}
+
+Value *CodeGenFunction::EmitISOVolatileStore(const CallExpr *E) {
+  Value *Ptr = EmitScalarExpr(E->getArg(0));
+  Value *Value = EmitScalarExpr(E->getArg(1));
+  QualType ElTy = E->getArg(0)->getType()->getPointeeType();
+  CharUnits StoreSize = getContext().getTypeSizeInChars(ElTy);
+  llvm::Type *ITy = llvm::IntegerType::get(getLLVMContext(),
+   StoreSize.getQuantity() * 8);
+  Ptr = Builder.CreateBitCast(Ptr, ITy->getPointerTo());
+  llvm::StoreInst *Store =
+Builder.CreateAlignedStore(Value, Ptr,
+   StoreSize);
+  Store->setVolatile(true);
+  return Store;
+}
+
 Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
const CallExpr *E,
llvm::Triple::ArchType Arch) {
@@ -5421,35 +5449,13 @@ Value *CodeGenFunction::EmitARMBuiltinEx
   case ARM::BI__iso_volatile_load8:
   case ARM::BI__iso_volatile_load16:
   case ARM::BI__iso_volatile_load32:
-  case ARM::BI__iso_volatile_load64: {
-Value *Ptr = EmitScalarExpr(E->getArg(0));
-QualType ElTy = E->getArg(0)->getType()->getPointeeType();
-CharUnits LoadSize = getContext().getTypeSizeInChars(ElTy);
-llvm::Type *ITy = llvm::IntegerType::get(getLLVMContext(),
- LoadSize.getQuantity() * 8);
-Ptr = Builder.CreateBitCast(Ptr, ITy->getPointerTo());
-llvm::LoadInst *Load =
-  Builder.CreateAlignedLoad(Ptr, LoadSize);
-Load->setVolatile(true);
-return Load;
-  }
+  case ARM::BI__iso_volatile_load64:
+return EmitISOVolatileLoad(E);
   case ARM::BI__iso_volatile_store8:
   case ARM::BI__iso_volatile_store16:
   case ARM::BI__iso_volatile_store32:
-  case ARM::BI__iso_volatile_store64: {
-Value *Ptr = EmitScalarExpr(E->getArg(0));
-Value *Value = EmitScalarExpr(E->getArg(1

r333529 - Fix a (possible) division by zero check in the CmpRuns script

2018-05-30 Thread Mikhail R. Gadelha via cfe-commits
Author: mramalho
Date: Wed May 30 04:17:55 2018
New Revision: 333529

URL: http://llvm.org/viewvc/llvm-project?rev=333529&view=rev
Log:
Fix a (possible) division by zero check in the CmpRuns script

I missed updating the check in r75

Modified:
cfe/trunk/utils/analyzer/CmpRuns.py

Modified: cfe/trunk/utils/analyzer/CmpRuns.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/CmpRuns.py?rev=333529&r1=333528&r2=333529&view=diff
==
--- cfe/trunk/utils/analyzer/CmpRuns.py (original)
+++ cfe/trunk/utils/analyzer/CmpRuns.py Wed May 30 04:17:55 2018
@@ -311,7 +311,7 @@ def compareStats(resultsA, resultsB):
 report = "%.3f -> %.3f" % (valA, valB)
 # Only apply highlighting when writing to TTY and it's not Windows
 if sys.stdout.isatty() and os.name != 'nt':
-if valA != 0:
+if valB != 0:
   ratio = (valB - valA) / valB
   if ratio < -0.2:
   report = Colors.GREEN + report + Colors.CLEAR


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


[PATCH] D37035: Implement __builtin_LINE() et. al. to support source location capture.

2018-05-30 Thread Lucio Asnaghi via Phabricator via cfe-commits
kunitoki added a comment.

Any news on the status of this ? Would be really nice to have it in.


https://reviews.llvm.org/D37035



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


r333531 - [analyzer] Remove the redundant check about same state transition in `ArrayBoundCheckerV2.cpp`.

2018-05-30 Thread Henry Wong via cfe-commits
Author: henrywong
Date: Wed May 30 04:46:45 2018
New Revision: 333531

URL: http://llvm.org/viewvc/llvm-project?rev=333531&view=rev
Log:
[analyzer] Remove the redundant check about same state transition in 
`ArrayBoundCheckerV2.cpp`.

Summary: Since the `addTransitionImpl()` has a check about same state 
transition, there is no need to check it in `ArrayBoundCheckerV2.cpp`.

Reviewers: NoQ, xazax.hun, george.karpenkov

Reviewed By: NoQ

Subscribers: szepet, rnkovacs, a.sidorin, cfe-commits, MTC

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

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

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp?rev=333531&r1=333530&r2=333531&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp Wed May 30 
04:46:45 2018
@@ -125,7 +125,6 @@ void ArrayBoundCheckerV2::checkLocation(
   // have some flexibility in defining the base region, we can achieve
   // various levels of conservatism in our buffer overflow checking.
   ProgramStateRef state = checkerContext.getState();
-  ProgramStateRef originalState = state;
 
   SValBuilder &svalBuilder = checkerContext.getSValBuilder();
   const RegionRawOffsetV2 &rawOffset =
@@ -224,8 +223,7 @@ void ArrayBoundCheckerV2::checkLocation(
   }
   while (false);
 
-  if (state != originalState)
-checkerContext.addTransition(state);
+  checkerContext.addTransition(state);
 }
 
 void ArrayBoundCheckerV2::reportOOB(


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


[PATCH] D47157: Warning for framework headers using double quote includes

2018-05-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D47157#1115445, @bruno wrote:

> > Consistency would be nice, but at the same time, I don't see a good metric 
> > for when we'd know it's time to switch it to being on by default. I'm 
> > worried that it'll remain off by default forever simply because no one 
> > thinks to go turn it on (because it's silent by default). Perhaps 
> > on-by-default here and off-by-default downstream would be the better 
> > approach, or do you think this would be too disruptive to enable by default 
> > anywhere?
>
> I believe this could be too disruptive to enable now, since it's still very 
> common to find quoted includes in framework headers. This is very important 
> for Modules to properly work with frameworks (quoted headers are usually 
> considered non-modular when modules builds kick in) and is actually very 
> compelling for us to turn it on by default on Darwin as soon as we can, but 
> we need to educate users first.


That sounds like good justification for it being off by default then, thank you.




Comment at: include/clang/Basic/DiagnosticLexKinds.td:713
+def warn_quoted_include_in_framework_header : Warning<
+  "double-quoted include \"%0\" in framework header, expected system style 
 include"
+  >, InGroup, DefaultIgnore;

bruno wrote:
> aaron.ballman wrote:
> > 80-col limit?
> > 
> > Also, I'd probably drop "system style" and reword slightly to:
> > 
> > `"double-quoted include \"%0\" in framework header, expected 
> > angle-bracketed include <%0> instead"`
> Unfortunately this won't work because for framework style includes we use the 
> angled-bracketed with the framework name. For example, if one wants to 
> include `Foo.h` from `Foo.framework`, one should use `#include `, 
> although on disk you actually have `Foo.framework/Headers/Foo.h`. Framework 
> header lookup does this magic and other similar ones.
> 
> Since we don't know which framework the quoted header could be part of, it 
> was not included in the warning (doing so would require extra header searches 
> - which could be expensive for this specific warning). However it seems that 
> I can do better to indicate that the framework name is desired here, perhaps:
> 
> `"double-quoted include \"%0\" in framework header, expected angle-bracketed 
> include  instead"`
> 
> How does that sound to you? Other suggestions?
Thank you for the explanation!

I think your suggested text sounds good, though I do wonder how expensive is 
"expensive" in finding the intended header? Not only would it provide a better 
diagnostic, it would also let you use a fixit that doesn't use editor 
placeholders.


Repository:
  rC Clang

https://reviews.llvm.org/D47157



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


[PATCH] D45686: [Driver] Clean up tmp files when deleting Compilation objects

2018-05-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

In https://reviews.llvm.org/D45686#1115836, @dstenb wrote:

> Any more comments or concerns, or can I land this?


None from me; you're good to land it. Any further comments can be handled 
post-commit.


https://reviews.llvm.org/D45686



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


[PATCH] D47451: [analyzer] Remove the redundant check about same state transition in `ArrayBoundCheckerV2.cpp`.

2018-05-30 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333531: [analyzer] Remove the redundant check about same 
state transition in… (authored by henrywong, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D47451

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp


Index: cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
@@ -125,7 +125,6 @@
   // have some flexibility in defining the base region, we can achieve
   // various levels of conservatism in our buffer overflow checking.
   ProgramStateRef state = checkerContext.getState();
-  ProgramStateRef originalState = state;
 
   SValBuilder &svalBuilder = checkerContext.getSValBuilder();
   const RegionRawOffsetV2 &rawOffset =
@@ -224,8 +223,7 @@
   }
   while (false);
 
-  if (state != originalState)
-checkerContext.addTransition(state);
+  checkerContext.addTransition(state);
 }
 
 void ArrayBoundCheckerV2::reportOOB(


Index: cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
@@ -125,7 +125,6 @@
   // have some flexibility in defining the base region, we can achieve
   // various levels of conservatism in our buffer overflow checking.
   ProgramStateRef state = checkerContext.getState();
-  ProgramStateRef originalState = state;
 
   SValBuilder &svalBuilder = checkerContext.getSValBuilder();
   const RegionRawOffsetV2 &rawOffset =
@@ -224,8 +223,7 @@
   }
   while (false);
 
-  if (state != originalState)
-checkerContext.addTransition(state);
+  checkerContext.addTransition(state);
 }
 
 void ArrayBoundCheckerV2::reportOOB(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47068: Move #include manipulation code to new lib/Tooling/Inclusions.

2018-05-30 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 149091.
ioeric added a comment.

- Fix module build.


Repository:
  rC Clang

https://reviews.llvm.org/D47068

Files:
  include/clang/Format/Format.h
  include/clang/Tooling/Core/HeaderIncludes.h
  include/clang/Tooling/Core/IncludeStyle.h
  include/clang/Tooling/Inclusions/HeaderIncludes.h
  include/clang/Tooling/Inclusions/IncludeStyle.h
  include/clang/module.modulemap
  lib/Format/CMakeLists.txt
  lib/Format/Format.cpp
  lib/Tooling/CMakeLists.txt
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/HeaderIncludes.cpp
  lib/Tooling/Core/IncludeStyle.cpp
  lib/Tooling/Inclusions/CMakeLists.txt
  lib/Tooling/Inclusions/HeaderIncludes.cpp
  lib/Tooling/Inclusions/IncludeStyle.cpp
  unittests/Tooling/HeaderIncludesTest.cpp

Index: unittests/Tooling/HeaderIncludesTest.cpp
===
--- unittests/Tooling/HeaderIncludesTest.cpp
+++ unittests/Tooling/HeaderIncludesTest.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 
-#include "clang/Tooling/Core/HeaderIncludes.h"
+#include "clang/Tooling/Inclusions/HeaderIncludes.h"
 #include "../Tooling/ReplacementTest.h"
 #include "../Tooling/RewriterTestContext.h"
 #include "clang/Format/Format.h"
Index: lib/Tooling/Inclusions/IncludeStyle.cpp
===
--- lib/Tooling/Inclusions/IncludeStyle.cpp
+++ lib/Tooling/Inclusions/IncludeStyle.cpp
@@ -7,8 +7,7 @@
 //
 //===--===//
 
-#include "clang/Tooling/Core/IncludeStyle.h"
-
+#include "clang/Tooling/Inclusions/IncludeStyle.h"
 
 using clang::tooling::IncludeStyle;
 
Index: lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 
-#include "clang/Tooling/Core/HeaderIncludes.h"
+#include "clang/Tooling/Inclusions/HeaderIncludes.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
 
Index: lib/Tooling/Inclusions/CMakeLists.txt
===
--- lib/Tooling/Inclusions/CMakeLists.txt
+++ lib/Tooling/Inclusions/CMakeLists.txt
@@ -1,15 +1,12 @@
 set(LLVM_LINK_COMPONENTS support)
 
-add_clang_library(clangToolingCore
-  Diagnostic.cpp
+add_clang_library(clangToolingInclusions
   HeaderIncludes.cpp
   IncludeStyle.cpp
-  Lookup.cpp
-  Replacement.cpp
 
   LINK_LIBS
-  clangAST
   clangBasic
   clangLex
   clangRewrite
+  clangToolingCore
   )
Index: lib/Tooling/Core/CMakeLists.txt
===
--- lib/Tooling/Core/CMakeLists.txt
+++ lib/Tooling/Core/CMakeLists.txt
@@ -2,8 +2,6 @@
 
 add_clang_library(clangToolingCore
   Diagnostic.cpp
-  HeaderIncludes.cpp
-  IncludeStyle.cpp
   Lookup.cpp
   Replacement.cpp
 
Index: lib/Tooling/CMakeLists.txt
===
--- lib/Tooling/CMakeLists.txt
+++ lib/Tooling/CMakeLists.txt
@@ -4,6 +4,7 @@
   )
 
 add_subdirectory(Core)
+add_subdirectory(Inclusions)
 add_subdirectory(Refactoring)
 add_subdirectory(ASTDiff)
 
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -31,7 +31,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Lex/Lexer.h"
-#include "clang/Tooling/Core/HeaderIncludes.h"
+#include "clang/Tooling/Inclusions/HeaderIncludes.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
Index: lib/Format/CMakeLists.txt
===
--- lib/Format/CMakeLists.txt
+++ lib/Format/CMakeLists.txt
@@ -20,4 +20,5 @@
   clangBasic
   clangLex
   clangToolingCore
+  clangToolingInclusions
   )
Index: include/clang/module.modulemap
===
--- include/clang/module.modulemap
+++ include/clang/module.modulemap
@@ -153,3 +153,8 @@
   requires cplusplus
   umbrella "Tooling/Core" module * { export * }
 }
+
+module Clang_ToolingInclusions {
+  requires cplusplus
+  umbrella "Tooling/Inclusions" module * { export * }
+}
Index: include/clang/Tooling/Inclusions/IncludeStyle.h
===
--- include/clang/Tooling/Inclusions/IncludeStyle.h
+++ include/clang/Tooling/Inclusions/IncludeStyle.h
@@ -7,8 +7,8 @@
 //
 //===--===//
 
-#ifndef LLVM_CLANG_TOOLING_CORE_INCLUDESTYLE_H
-#define LLVM_CLANG_TOOLING_CORE_INCLUDESTYLE_H
+#ifndef LLVM_CLANG_TOOLING_INCLUSIONS_INCLUDESTYLE_H
+#def

r333532 - Reland "Move #include manipulation code to new lib/Tooling/Inclusions."

2018-05-30 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed May 30 04:51:48 2018
New Revision: 333532

URL: http://llvm.org/viewvc/llvm-project?rev=333532&view=rev
Log:
Reland "Move #include manipulation code to new lib/Tooling/Inclusions."

This reverts commit r332751 (i.e. reland r332720) after fixing module
build.

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

Added:
cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h
  - copied, changed from r333522, 
cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h
  - copied, changed from r333522, 
cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
cfe/trunk/lib/Tooling/Inclusions/CMakeLists.txt
  - copied, changed from r333522, cfe/trunk/lib/Tooling/Core/CMakeLists.txt
cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
  - copied, changed from r333522, 
cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp
  - copied, changed from r333522, 
cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
Removed:
cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
Modified:
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/include/clang/module.modulemap
cfe/trunk/lib/Format/CMakeLists.txt
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Tooling/CMakeLists.txt
cfe/trunk/lib/Tooling/Core/CMakeLists.txt
cfe/trunk/unittests/Tooling/HeaderIncludesTest.cpp

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=333532&r1=333531&r2=333532&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Wed May 30 04:51:48 2018
@@ -16,8 +16,8 @@
 #define LLVM_CLANG_FORMAT_FORMAT_H
 
 #include "clang/Basic/LangOptions.h"
-#include "clang/Tooling/Core/IncludeStyle.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "clang/Tooling/Inclusions/IncludeStyle.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/Regex.h"
 #include 

Removed: cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h?rev=333531&view=auto
==
--- cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h (original)
+++ cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h (removed)
@@ -1,137 +0,0 @@
-//===--- HeaderIncludes.h - Insert/Delete #includes for C++ code--*- 
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_TOOLING_CORE_HEADERINCLUDES_H
-#define LLVM_CLANG_TOOLING_CORE_HEADERINCLUDES_H
-
-#include "clang/Basic/SourceManager.h"
-#include "clang/Tooling/Core/Replacement.h"
-#include "clang/Tooling/Core/IncludeStyle.h"
-#include "llvm/Support/Path.h"
-#include "llvm/Support/Regex.h"
-#include 
-
-namespace clang {
-namespace tooling {
-
-/// This class manages priorities of C++ #include categories and calculates
-/// priorities for headers.
-/// FIXME(ioeric): move this class into implementation file when clang-format's
-/// include sorting functions are also moved here.
-class IncludeCategoryManager {
-public:
-  IncludeCategoryManager(const IncludeStyle &Style, StringRef FileName);
-
-  /// Returns the priority of the category which \p IncludeName belongs to.
-  /// If \p CheckMainHeader is true and \p IncludeName is a main header, 
returns
-  /// 0. Otherwise, returns the priority of the matching category or INT_MAX.
-  /// NOTE: this API is not thread-safe!
-  int getIncludePriority(StringRef IncludeName, bool CheckMainHeader) const;
-
-private:
-  bool isMainHeader(StringRef IncludeName) const;
-
-  const IncludeStyle Style;
-  bool IsMainFile;
-  std::string FileName;
-  // This refers to a substring in FileName.
-  StringRef FileStem;
-  // Regex is not thread-safe.
-  mutable SmallVector CategoryRegexs;
-};
-
-/// Generates replacements for inserting or deleting #include directives in a
-/// file.
-class HeaderIncludes {
-public:
-  HeaderIncludes(llvm::StringRef FileName, llvm::StringRef Code,
- const IncludeStyle &Style);
-
-  /// Inserts an #include directive of \p Header into the code. If \p IsAngled
-  /// is true, \p Header will be quoted with <> in the directive; otherwise, it
-  /// will be quoted with "".
-  ///
-  /// When searching for points to insert new header, this ignores #include's
-  /// after the #include block(s) in the beginning of a file to avo

[clang-tools-extra] r333533 - Reland "[clangd] Adapt file migration in r332720"

2018-05-30 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed May 30 04:52:01 2018
New Revision: 333533

URL: http://llvm.org/viewvc/llvm-project?rev=333533&view=rev
Log:
Reland "[clangd] Adapt file migration in r332720"

This reverts commit r332752 (i.e. reland r332721).

Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/clangd/Headers.h

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=333533&r1=333532&r2=333533&view=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Wed May 30 04:52:01 2018
@@ -56,6 +56,7 @@ add_clang_library(clangDaemon
   clangSerialization
   clangTooling
   clangToolingCore
+  clangToolingInclusions
   clangToolingRefactor
   ${LLVM_PTHREAD_LIB}
   ${CLANGD_ATOMIC_LIB}

Modified: clang-tools-extra/trunk/clangd/Headers.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Headers.h?rev=333533&r1=333532&r2=333533&view=diff
==
--- clang-tools-extra/trunk/clangd/Headers.h (original)
+++ clang-tools-extra/trunk/clangd/Headers.h Wed May 30 04:52:01 2018
@@ -17,7 +17,7 @@
 #include "clang/Format/Format.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/PPCallbacks.h"
-#include "clang/Tooling/Core/HeaderIncludes.h"
+#include "clang/Tooling/Inclusions/HeaderIncludes.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Error.h"


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


[PATCH] D47068: Move #include manipulation code to new lib/Tooling/Inclusions.

2018-05-30 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333532: Reland "Move #include manipulation code to new 
lib/Tooling/Inclusions." (authored by ioeric, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47068?vs=149091&id=149092#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47068

Files:
  cfe/trunk/include/clang/Format/Format.h
  cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
  cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
  cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h
  cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h
  cfe/trunk/include/clang/module.modulemap
  cfe/trunk/lib/Format/CMakeLists.txt
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Tooling/CMakeLists.txt
  cfe/trunk/lib/Tooling/Core/CMakeLists.txt
  cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
  cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
  cfe/trunk/lib/Tooling/Inclusions/CMakeLists.txt
  cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
  cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp
  cfe/trunk/unittests/Tooling/HeaderIncludesTest.cpp

Index: cfe/trunk/unittests/Tooling/HeaderIncludesTest.cpp
===
--- cfe/trunk/unittests/Tooling/HeaderIncludesTest.cpp
+++ cfe/trunk/unittests/Tooling/HeaderIncludesTest.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 
-#include "clang/Tooling/Core/HeaderIncludes.h"
+#include "clang/Tooling/Inclusions/HeaderIncludes.h"
 #include "../Tooling/ReplacementTest.h"
 #include "../Tooling/RewriterTestContext.h"
 #include "clang/Format/Format.h"
Index: cfe/trunk/include/clang/Format/Format.h
===
--- cfe/trunk/include/clang/Format/Format.h
+++ cfe/trunk/include/clang/Format/Format.h
@@ -16,8 +16,8 @@
 #define LLVM_CLANG_FORMAT_FORMAT_H
 
 #include "clang/Basic/LangOptions.h"
-#include "clang/Tooling/Core/IncludeStyle.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "clang/Tooling/Inclusions/IncludeStyle.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/Regex.h"
 #include 
Index: cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h
===
--- cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h
+++ cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h
@@ -0,0 +1,133 @@
+//===--- IncludeStyle.h - Style of C++ #include directives ---*- 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_TOOLING_INCLUSIONS_INCLUDESTYLE_H
+#define LLVM_CLANG_TOOLING_INCLUSIONS_INCLUDESTYLE_H
+
+#include "llvm/Support/YAMLTraits.h"
+#include 
+#include 
+
+namespace clang {
+namespace tooling {
+
+/// Style for sorting and grouping C++ #include directives.
+struct IncludeStyle {
+  /// Styles for sorting multiple ``#include`` blocks.
+  enum IncludeBlocksStyle {
+/// Sort each ``#include`` block separately.
+/// \code
+///#include "b.h"   into  #include "b.h"
+///
+///#include   #include "a.h"
+///#include "a.h" #include 
+/// \endcode
+IBS_Preserve,
+/// Merge multiple ``#include`` blocks together and sort as one.
+/// \code
+///#include "b.h"   into  #include "a.h"
+///   #include "b.h"
+///#include   #include 
+///#include "a.h"
+/// \endcode
+IBS_Merge,
+/// Merge multiple ``#include`` blocks together and sort as one.
+/// Then split into groups based on category priority. See
+/// ``IncludeCategories``.
+/// \code
+///#include "b.h"   into  #include "a.h"
+///   #include "b.h"
+///#include 
+///#include "a.h" #include 
+/// \endcode
+IBS_Regroup,
+  };
+
+  /// Dependent on the value, multiple ``#include`` blocks can be sorted
+  /// as one and divided based on category.
+  IncludeBlocksStyle IncludeBlocks;
+
+  /// See documentation of ``IncludeCategories``.
+  struct IncludeCategory {
+/// The regular expression that this category matches.
+std::string Regex;
+/// The priority to assign to this category.
+int Priority;
+bool operator==(const IncludeCategory &Other) const {
+  return Regex == Other.Regex && Priority == Other.Priority;
+}
+  };
+
+  /// Regular expressions denoting the different ``#include`` categories
+  /// used for ordering ``#includes``.
+  ///
+  /// These regular expressions are matched against the filename o

[PATCH] D47367: [ASTImporter] Add ms compatibility to tests which use the TestBase

2018-05-30 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 149093.
martong added a comment.

- Moved the family of `testImport` functions under a test fixture class, so we 
can use parameterized test.
- Refactored `testImport` and `testImportSequence`, because for loops over the 
different compiler options is no longer needed, that is handeld by the test 
framework via parameters from now on.


Repository:
  rC Clang

https://reviews.llvm.org/D47367

Files:
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -50,111 +50,236 @@
llvm::MemoryBuffer::getMemBuffer(Code));
 }
 
-template 
-NodeType importNode(ASTUnit *From, ASTUnit *To, ASTImporter &Importer,
-NodeType Node) {
-  ASTContext &ToCtx = To->getASTContext();
+const StringRef DeclToImportID = "declToImport";
+const StringRef DeclToVerifyID = "declToVerify";
 
-  // Add 'From' file to virtual file system so importer can 'find' it
-  // while importing SourceLocations. It is safe to add same file multiple
-  // times - it just isn't replaced.
-  StringRef FromFileName = From->getMainFileName();
-  createVirtualFileIfNeeded(To, FromFileName,
-From->getBufferForFile(FromFileName));
+// Common base for the different families of ASTImporter tests that are
+// parameterized on the compiler options which may result a different AST. E.g.
+// -fms-compatibility or -fdelayed-template-parsing.
+struct ParameterizedTestsFixture : ::testing::TestWithParam {
 
-  auto Imported = Importer.Import(Node);
+  // Returns the argument vector used for a specific language option, this set
+  // can be tweaked by the test parameters.
+  ArgVector getArgVectorForLanguage(Language Lang) const {
+ArgVector Args = getBasicRunOptionsForLanguage(Lang);
+ArgVector ExtraArgs = GetParam();
+for (const auto &Arg : ExtraArgs) {
+  Args.push_back(Arg);
+}
+return Args;
+  }
 
-  // This should dump source locations and assert if some source locations
-  // were not imported.
-  SmallString<1024> ImportChecker;
-  llvm::raw_svector_ostream ToNothing(ImportChecker);
-  ToCtx.getTranslationUnitDecl()->print(ToNothing);
+};
 
-  // This traverses the AST to catch certain bugs like poorly or not
-  // implemented subtrees.
-  Imported->dump(ToNothing);
+// Base class for those tests which use the family of `testImport` functions.
+class TestImportBase : public ParameterizedTestsFixture {
 
-  return Imported;
-}
+  template 
+  NodeType importNode(ASTUnit *From, ASTUnit *To, ASTImporter &Importer,
+  NodeType Node) {
+ASTContext &ToCtx = To->getASTContext();
 
-const StringRef DeclToImportID = "declToImport";
-const StringRef DeclToVerifyID = "declToVerify";
+// Add 'From' file to virtual file system so importer can 'find' it
+// while importing SourceLocations. It is safe to add same file multiple
+// times - it just isn't replaced.
+StringRef FromFileName = From->getMainFileName();
+createVirtualFileIfNeeded(To, FromFileName,
+  From->getBufferForFile(FromFileName));
 
-template 
-testing::AssertionResult
-testImport(const std::string &FromCode, const ArgVector &FromArgs,
-   const std::string &ToCode, const ArgVector &ToArgs,
-   MatchVerifier &Verifier,
-   const BindableMatcher &SearchMatcher,
-   const BindableMatcher &VerificationMatcher) {
-  const char *const InputFileName = "input.cc";
-  const char *const OutputFileName = "output.cc";
+auto Imported = Importer.Import(Node);
 
-  std::unique_ptr
-  FromAST = tooling::buildASTFromCodeWithArgs(
-FromCode, FromArgs, InputFileName),
-  ToAST = tooling::buildASTFromCodeWithArgs(ToCode, ToArgs, OutputFileName);
-
-  ASTContext &FromCtx = FromAST->getASTContext(),
-  &ToCtx = ToAST->getASTContext();
-
-  ASTImporter Importer(ToCtx, ToAST->getFileManager(),
-   FromCtx, FromAST->getFileManager(), false);
-
-  auto FoundNodes = match(SearchMatcher, FromCtx);
-  if (FoundNodes.size() != 1)
-return testing::AssertionFailure()
-   << "Multiple potential nodes were found!";
-
-  auto ToImport = selectFirst(DeclToImportID, FoundNodes);
-  if (!ToImport)
-return testing::AssertionFailure() << "Node type mismatch!";
-
-  // Sanity check: the node being imported should match in the same way as
-  // the result node.
-  BindableMatcher WrapperMatcher(VerificationMatcher);
-  EXPECT_TRUE(Verifier.match(ToImport, WrapperMatcher));
-
-  auto Imported = importNode(FromAST.get(), ToAST.get(), Importer, ToImport);
-  if (!Imported)
-return testing::AssertionFailure() << "Import failed, nullptr returned!";
-
-  return Verifier.match(Imported, WrapperMatcher);
-}
-
-template 
-testing::AssertionResult
-testImport(const std::string &FromCo

[PATCH] D47367: [ASTImporter] Add ms compatibility to tests

2018-05-30 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 149094.
martong added a comment.

- Forgot to instantiate some of the parameterized tests


Repository:
  rC Clang

https://reviews.llvm.org/D47367

Files:
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -50,111 +50,236 @@
llvm::MemoryBuffer::getMemBuffer(Code));
 }
 
-template 
-NodeType importNode(ASTUnit *From, ASTUnit *To, ASTImporter &Importer,
-NodeType Node) {
-  ASTContext &ToCtx = To->getASTContext();
+const StringRef DeclToImportID = "declToImport";
+const StringRef DeclToVerifyID = "declToVerify";
 
-  // Add 'From' file to virtual file system so importer can 'find' it
-  // while importing SourceLocations. It is safe to add same file multiple
-  // times - it just isn't replaced.
-  StringRef FromFileName = From->getMainFileName();
-  createVirtualFileIfNeeded(To, FromFileName,
-From->getBufferForFile(FromFileName));
+// Common base for the different families of ASTImporter tests that are
+// parameterized on the compiler options which may result a different AST. E.g.
+// -fms-compatibility or -fdelayed-template-parsing.
+struct ParameterizedTestsFixture : ::testing::TestWithParam {
 
-  auto Imported = Importer.Import(Node);
+  // Returns the argument vector used for a specific language option, this set
+  // can be tweaked by the test parameters.
+  ArgVector getArgVectorForLanguage(Language Lang) const {
+ArgVector Args = getBasicRunOptionsForLanguage(Lang);
+ArgVector ExtraArgs = GetParam();
+for (const auto &Arg : ExtraArgs) {
+  Args.push_back(Arg);
+}
+return Args;
+  }
 
-  // This should dump source locations and assert if some source locations
-  // were not imported.
-  SmallString<1024> ImportChecker;
-  llvm::raw_svector_ostream ToNothing(ImportChecker);
-  ToCtx.getTranslationUnitDecl()->print(ToNothing);
+};
 
-  // This traverses the AST to catch certain bugs like poorly or not
-  // implemented subtrees.
-  Imported->dump(ToNothing);
+// Base class for those tests which use the family of `testImport` functions.
+class TestImportBase : public ParameterizedTestsFixture {
 
-  return Imported;
-}
+  template 
+  NodeType importNode(ASTUnit *From, ASTUnit *To, ASTImporter &Importer,
+  NodeType Node) {
+ASTContext &ToCtx = To->getASTContext();
 
-const StringRef DeclToImportID = "declToImport";
-const StringRef DeclToVerifyID = "declToVerify";
+// Add 'From' file to virtual file system so importer can 'find' it
+// while importing SourceLocations. It is safe to add same file multiple
+// times - it just isn't replaced.
+StringRef FromFileName = From->getMainFileName();
+createVirtualFileIfNeeded(To, FromFileName,
+  From->getBufferForFile(FromFileName));
 
-template 
-testing::AssertionResult
-testImport(const std::string &FromCode, const ArgVector &FromArgs,
-   const std::string &ToCode, const ArgVector &ToArgs,
-   MatchVerifier &Verifier,
-   const BindableMatcher &SearchMatcher,
-   const BindableMatcher &VerificationMatcher) {
-  const char *const InputFileName = "input.cc";
-  const char *const OutputFileName = "output.cc";
+auto Imported = Importer.Import(Node);
 
-  std::unique_ptr
-  FromAST = tooling::buildASTFromCodeWithArgs(
-FromCode, FromArgs, InputFileName),
-  ToAST = tooling::buildASTFromCodeWithArgs(ToCode, ToArgs, OutputFileName);
-
-  ASTContext &FromCtx = FromAST->getASTContext(),
-  &ToCtx = ToAST->getASTContext();
-
-  ASTImporter Importer(ToCtx, ToAST->getFileManager(),
-   FromCtx, FromAST->getFileManager(), false);
-
-  auto FoundNodes = match(SearchMatcher, FromCtx);
-  if (FoundNodes.size() != 1)
-return testing::AssertionFailure()
-   << "Multiple potential nodes were found!";
-
-  auto ToImport = selectFirst(DeclToImportID, FoundNodes);
-  if (!ToImport)
-return testing::AssertionFailure() << "Node type mismatch!";
-
-  // Sanity check: the node being imported should match in the same way as
-  // the result node.
-  BindableMatcher WrapperMatcher(VerificationMatcher);
-  EXPECT_TRUE(Verifier.match(ToImport, WrapperMatcher));
-
-  auto Imported = importNode(FromAST.get(), ToAST.get(), Importer, ToImport);
-  if (!Imported)
-return testing::AssertionFailure() << "Import failed, nullptr returned!";
-
-  return Verifier.match(Imported, WrapperMatcher);
-}
-
-template 
-testing::AssertionResult
-testImport(const std::string &FromCode, const ArgVector &FromArgs,
-   const std::string &ToCode, const ArgVector &ToArgs,
-   MatchVerifier &Verifier,
-   const BindableMatcher &VerificationMatcher) {
-  return testImport(
-  FromCode, FromArgs, ToCode, 

r333534 - Revert "Reland "Move #include manipulation code to new lib/Tooling/Inclusions.""

2018-05-30 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed May 30 05:09:58 2018
New Revision: 333534

URL: http://llvm.org/viewvc/llvm-project?rev=333534&view=rev
Log:
Revert "Reland "Move #include manipulation code to new lib/Tooling/Inclusions.""

This reverts commit r333532. Revert for now to fix an internal bot issue.

Added:
cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h
  - copied, changed from r333532, 
cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h
cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h
  - copied, changed from r333532, 
cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h
cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp
  - copied, changed from r333532, 
cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp
  - copied, changed from r333532, 
cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp
Removed:
cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h
cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h
cfe/trunk/lib/Tooling/Inclusions/CMakeLists.txt
cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp
cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp
Modified:
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/include/clang/module.modulemap
cfe/trunk/lib/Format/CMakeLists.txt
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Tooling/CMakeLists.txt
cfe/trunk/lib/Tooling/Core/CMakeLists.txt
cfe/trunk/unittests/Tooling/HeaderIncludesTest.cpp

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=333534&r1=333533&r2=333534&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Wed May 30 05:09:58 2018
@@ -16,8 +16,8 @@
 #define LLVM_CLANG_FORMAT_FORMAT_H
 
 #include "clang/Basic/LangOptions.h"
+#include "clang/Tooling/Core/IncludeStyle.h"
 #include "clang/Tooling/Core/Replacement.h"
-#include "clang/Tooling/Inclusions/IncludeStyle.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/Regex.h"
 #include 

Copied: cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h (from r333532, 
cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h?p2=cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h&p1=cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h&r1=333532&r2=333534&rev=333534&view=diff
==
--- cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h (original)
+++ cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h Wed May 30 05:09:58 
2018
@@ -7,12 +7,12 @@
 //
 
//===--===//
 
-#ifndef LLVM_CLANG_TOOLING_INCLUSIONS_HEADERINCLUDES_H
-#define LLVM_CLANG_TOOLING_INCLUSIONS_HEADERINCLUDES_H
+#ifndef LLVM_CLANG_TOOLING_CORE_HEADERINCLUDES_H
+#define LLVM_CLANG_TOOLING_CORE_HEADERINCLUDES_H
 
 #include "clang/Basic/SourceManager.h"
 #include "clang/Tooling/Core/Replacement.h"
-#include "clang/Tooling/Inclusions/IncludeStyle.h"
+#include "clang/Tooling/Core/IncludeStyle.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Regex.h"
 #include 
@@ -134,4 +134,4 @@ private:
 } // namespace tooling
 } // namespace clang
 
-#endif // LLVM_CLANG_TOOLING_INCLUSIONS_HEADERINCLUDES_H
+#endif // LLVM_CLANG_TOOLING_CORE_HEADERINCLUDES_H

Copied: cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h (from r333532, 
cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h?p2=cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h&p1=cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h&r1=333532&r2=333534&rev=333534&view=diff
==
--- cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h (original)
+++ cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h Wed May 30 05:09:58 2018
@@ -7,8 +7,8 @@
 //
 
//===--===//
 
-#ifndef LLVM_CLANG_TOOLING_INCLUSIONS_INCLUDESTYLE_H
-#define LLVM_CLANG_TOOLING_INCLUSIONS_INCLUDESTYLE_H
+#ifndef LLVM_CLANG_TOOLING_CORE_INCLUDESTYLE_H
+#define LLVM_CLANG_TOOLING_CORE_INCLUDESTYLE_H
 
 #include "llvm/Support/YAMLTraits.h"
 #include 
@@ -130,4 +130,4 @@ struct ScalarEnumerationTraits<
 } // namespace yaml
 } // namespace llvm
 
-#endif // LLVM_CLANG_TOOLING_INCLUSIONS_INCLUDESTYLE_H
+#endif // LLVM_CLANG_TOOLING_CORE_INCLUDESTYLE_H

Removed: cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h?rev=333533&view=auto

[clang-tools-extra] r333535 - Revert "Reland "[clangd] Adapt file migration in r332720""

2018-05-30 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed May 30 05:10:07 2018
New Revision: 333535

URL: http://llvm.org/viewvc/llvm-project?rev=333535&view=rev
Log:
Revert "Reland "[clangd] Adapt file migration in r332720""

This reverts commit r333533.

Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/clangd/Headers.h

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=333535&r1=333534&r2=333535&view=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Wed May 30 05:10:07 2018
@@ -56,7 +56,6 @@ add_clang_library(clangDaemon
   clangSerialization
   clangTooling
   clangToolingCore
-  clangToolingInclusions
   clangToolingRefactor
   ${LLVM_PTHREAD_LIB}
   ${CLANGD_ATOMIC_LIB}

Modified: clang-tools-extra/trunk/clangd/Headers.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Headers.h?rev=333535&r1=333534&r2=333535&view=diff
==
--- clang-tools-extra/trunk/clangd/Headers.h (original)
+++ clang-tools-extra/trunk/clangd/Headers.h Wed May 30 05:10:07 2018
@@ -17,7 +17,7 @@
 #include "clang/Format/Format.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/PPCallbacks.h"
-#include "clang/Tooling/Inclusions/HeaderIncludes.h"
+#include "clang/Tooling/Core/HeaderIncludes.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Error.h"


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


[PATCH] D47367: [ASTImporter] Add ms compatibility to tests

2018-05-30 Thread Gabor Marton via Phabricator via cfe-commits
martong added a reviewer: balazske.
martong added a comment.

Balazs, could you please review this patch as well? (This code is not in our 
fork yet.)


Repository:
  rC Clang

https://reviews.llvm.org/D47367



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


[PATCH] D47367: [ASTImporter] Add ms compatibility to tests

2018-05-30 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 149095.
martong added a comment.

- Remove unused function


Repository:
  rC Clang

https://reviews.llvm.org/D47367

Files:
  unittests/AST/ASTImporterTest.cpp
  unittests/AST/Language.cpp
  unittests/AST/Language.h

Index: unittests/AST/Language.h
===
--- unittests/AST/Language.h
+++ unittests/AST/Language.h
@@ -39,7 +39,6 @@
 }
 
 ArgVector getBasicRunOptionsForLanguage(Language Lang);
-RunOptions getRunOptionsForLanguage(Language Lang);
 
 } // end namespace ast_matchers
 } // end namespace clang
Index: unittests/AST/Language.cpp
===
--- unittests/AST/Language.cpp
+++ unittests/AST/Language.cpp
@@ -42,19 +42,5 @@
   return BasicArgs;
 }
 
-RunOptions getRunOptionsForLanguage(Language Lang) {
-  ArgVector BasicArgs = getBasicRunOptionsForLanguage(Lang);
-
-  // For C++, test with "-fdelayed-template-parsing" enabled to handle MSVC
-  // default behaviour.
-  if (isCXX(Lang)) {
-ArgVector ArgsForDelayedTemplateParse = BasicArgs;
-ArgsForDelayedTemplateParse.emplace_back("-fdelayed-template-parsing");
-return {BasicArgs, ArgsForDelayedTemplateParse};
-  }
-
-  return {BasicArgs};
-}
-
 } // end namespace ast_matchers
 } // end namespace clang
Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -50,111 +50,236 @@
llvm::MemoryBuffer::getMemBuffer(Code));
 }
 
-template 
-NodeType importNode(ASTUnit *From, ASTUnit *To, ASTImporter &Importer,
-NodeType Node) {
-  ASTContext &ToCtx = To->getASTContext();
+const StringRef DeclToImportID = "declToImport";
+const StringRef DeclToVerifyID = "declToVerify";
 
-  // Add 'From' file to virtual file system so importer can 'find' it
-  // while importing SourceLocations. It is safe to add same file multiple
-  // times - it just isn't replaced.
-  StringRef FromFileName = From->getMainFileName();
-  createVirtualFileIfNeeded(To, FromFileName,
-From->getBufferForFile(FromFileName));
+// Common base for the different families of ASTImporter tests that are
+// parameterized on the compiler options which may result a different AST. E.g.
+// -fms-compatibility or -fdelayed-template-parsing.
+struct ParameterizedTestsFixture : ::testing::TestWithParam {
 
-  auto Imported = Importer.Import(Node);
+  // Returns the argument vector used for a specific language option, this set
+  // can be tweaked by the test parameters.
+  ArgVector getArgVectorForLanguage(Language Lang) const {
+ArgVector Args = getBasicRunOptionsForLanguage(Lang);
+ArgVector ExtraArgs = GetParam();
+for (const auto &Arg : ExtraArgs) {
+  Args.push_back(Arg);
+}
+return Args;
+  }
 
-  // This should dump source locations and assert if some source locations
-  // were not imported.
-  SmallString<1024> ImportChecker;
-  llvm::raw_svector_ostream ToNothing(ImportChecker);
-  ToCtx.getTranslationUnitDecl()->print(ToNothing);
+};
 
-  // This traverses the AST to catch certain bugs like poorly or not
-  // implemented subtrees.
-  Imported->dump(ToNothing);
+// Base class for those tests which use the family of `testImport` functions.
+class TestImportBase : public ParameterizedTestsFixture {
 
-  return Imported;
-}
+  template 
+  NodeType importNode(ASTUnit *From, ASTUnit *To, ASTImporter &Importer,
+  NodeType Node) {
+ASTContext &ToCtx = To->getASTContext();
 
-const StringRef DeclToImportID = "declToImport";
-const StringRef DeclToVerifyID = "declToVerify";
+// Add 'From' file to virtual file system so importer can 'find' it
+// while importing SourceLocations. It is safe to add same file multiple
+// times - it just isn't replaced.
+StringRef FromFileName = From->getMainFileName();
+createVirtualFileIfNeeded(To, FromFileName,
+  From->getBufferForFile(FromFileName));
 
-template 
-testing::AssertionResult
-testImport(const std::string &FromCode, const ArgVector &FromArgs,
-   const std::string &ToCode, const ArgVector &ToArgs,
-   MatchVerifier &Verifier,
-   const BindableMatcher &SearchMatcher,
-   const BindableMatcher &VerificationMatcher) {
-  const char *const InputFileName = "input.cc";
-  const char *const OutputFileName = "output.cc";
+auto Imported = Importer.Import(Node);
 
-  std::unique_ptr
-  FromAST = tooling::buildASTFromCodeWithArgs(
-FromCode, FromArgs, InputFileName),
-  ToAST = tooling::buildASTFromCodeWithArgs(ToCode, ToArgs, OutputFileName);
-
-  ASTContext &FromCtx = FromAST->getASTContext(),
-  &ToCtx = ToAST->getASTContext();
-
-  ASTImporter Importer(ToCtx, ToAST->getFileManager(),
-   FromCtx, FromAST->getFileManager()

[PATCH] D47367: [ASTImporter] Add ms compatibility to tests

2018-05-30 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 149096.
martong added a comment.

- Remove unused RunOptions typedef and isCXX function


Repository:
  rC Clang

https://reviews.llvm.org/D47367

Files:
  unittests/AST/ASTImporterTest.cpp
  unittests/AST/Language.cpp
  unittests/AST/Language.h

Index: unittests/AST/Language.h
===
--- unittests/AST/Language.h
+++ unittests/AST/Language.h
@@ -22,7 +22,6 @@
 namespace ast_matchers {
 
 typedef std::vector ArgVector;
-typedef std::vector RunOptions;
 
 enum Language {
 Lang_C,
@@ -34,12 +33,7 @@
 Lang_OBJCXX
 };
 
-inline bool isCXX(Language Lang) {
-  return Lang == Lang_CXX || Lang == Lang_CXX11 || Lang == Lang_CXX14;
-}
-
 ArgVector getBasicRunOptionsForLanguage(Language Lang);
-RunOptions getRunOptionsForLanguage(Language Lang);
 
 } // end namespace ast_matchers
 } // end namespace clang
Index: unittests/AST/Language.cpp
===
--- unittests/AST/Language.cpp
+++ unittests/AST/Language.cpp
@@ -42,19 +42,5 @@
   return BasicArgs;
 }
 
-RunOptions getRunOptionsForLanguage(Language Lang) {
-  ArgVector BasicArgs = getBasicRunOptionsForLanguage(Lang);
-
-  // For C++, test with "-fdelayed-template-parsing" enabled to handle MSVC
-  // default behaviour.
-  if (isCXX(Lang)) {
-ArgVector ArgsForDelayedTemplateParse = BasicArgs;
-ArgsForDelayedTemplateParse.emplace_back("-fdelayed-template-parsing");
-return {BasicArgs, ArgsForDelayedTemplateParse};
-  }
-
-  return {BasicArgs};
-}
-
 } // end namespace ast_matchers
 } // end namespace clang
Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -50,111 +50,236 @@
llvm::MemoryBuffer::getMemBuffer(Code));
 }
 
-template 
-NodeType importNode(ASTUnit *From, ASTUnit *To, ASTImporter &Importer,
-NodeType Node) {
-  ASTContext &ToCtx = To->getASTContext();
+const StringRef DeclToImportID = "declToImport";
+const StringRef DeclToVerifyID = "declToVerify";
 
-  // Add 'From' file to virtual file system so importer can 'find' it
-  // while importing SourceLocations. It is safe to add same file multiple
-  // times - it just isn't replaced.
-  StringRef FromFileName = From->getMainFileName();
-  createVirtualFileIfNeeded(To, FromFileName,
-From->getBufferForFile(FromFileName));
+// Common base for the different families of ASTImporter tests that are
+// parameterized on the compiler options which may result a different AST. E.g.
+// -fms-compatibility or -fdelayed-template-parsing.
+struct ParameterizedTestsFixture : ::testing::TestWithParam {
 
-  auto Imported = Importer.Import(Node);
+  // Returns the argument vector used for a specific language option, this set
+  // can be tweaked by the test parameters.
+  ArgVector getArgVectorForLanguage(Language Lang) const {
+ArgVector Args = getBasicRunOptionsForLanguage(Lang);
+ArgVector ExtraArgs = GetParam();
+for (const auto &Arg : ExtraArgs) {
+  Args.push_back(Arg);
+}
+return Args;
+  }
 
-  // This should dump source locations and assert if some source locations
-  // were not imported.
-  SmallString<1024> ImportChecker;
-  llvm::raw_svector_ostream ToNothing(ImportChecker);
-  ToCtx.getTranslationUnitDecl()->print(ToNothing);
+};
 
-  // This traverses the AST to catch certain bugs like poorly or not
-  // implemented subtrees.
-  Imported->dump(ToNothing);
+// Base class for those tests which use the family of `testImport` functions.
+class TestImportBase : public ParameterizedTestsFixture {
 
-  return Imported;
-}
+  template 
+  NodeType importNode(ASTUnit *From, ASTUnit *To, ASTImporter &Importer,
+  NodeType Node) {
+ASTContext &ToCtx = To->getASTContext();
 
-const StringRef DeclToImportID = "declToImport";
-const StringRef DeclToVerifyID = "declToVerify";
+// Add 'From' file to virtual file system so importer can 'find' it
+// while importing SourceLocations. It is safe to add same file multiple
+// times - it just isn't replaced.
+StringRef FromFileName = From->getMainFileName();
+createVirtualFileIfNeeded(To, FromFileName,
+  From->getBufferForFile(FromFileName));
 
-template 
-testing::AssertionResult
-testImport(const std::string &FromCode, const ArgVector &FromArgs,
-   const std::string &ToCode, const ArgVector &ToArgs,
-   MatchVerifier &Verifier,
-   const BindableMatcher &SearchMatcher,
-   const BindableMatcher &VerificationMatcher) {
-  const char *const InputFileName = "input.cc";
-  const char *const OutputFileName = "output.cc";
+auto Imported = Importer.Import(Node);
 
-  std::unique_ptr
-  FromAST = tooling::buildASTFromCodeWithArgs(
-FromCode, FromArgs, Inp

[PATCH] D47419: [SemaDeclCXX] Allow inheriting constructor declaration that specify a cv-qualified type

2018-05-30 Thread S. B. Tam via Phabricator via cfe-commits
cpplearner added inline comments.



Comment at: lib/Sema/SemaDeclCXX.cpp:9690
+  CanQualType CanonicalDesiredBase = DesiredBase->getCanonicalTypeUnqualified()
+.getUnqualifiedType();
   for (auto &Base : Derived->bases()) {

rsmith wrote:
> How are we getting a qualified type here? Is this actually a bug in 
> `getCanonicalTypeUnqualified`?
It seems that `getCanonicalTypeUnqualified` does not strip qualifiers from the 
canonical type. I guess "Unqualified" here just means the method does not 
include local qualifiers, unlike QualType::getCanonicalType.

Thus, in the case of `using cbase = const base;`, `getCanonicalTypeUnqualified` 
will return the canonical type of `cbase` as is, which is `const base`, a 
const-qualified type.


Repository:
  rC Clang

https://reviews.llvm.org/D47419



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


[PATCH] D47474: Implement cpu_dispatch/cpu_specific Multiversioning

2018-05-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/AST/Decl.h:2212-2213
 
+  bool isCpuDispatchMultiVersion() const;
+  bool isCpuSpecificMultiVersion() const;
+

Pedantic nit: CPU instead of Cpu?



Comment at: include/clang/Basic/Attr.td:850
+def CpuSpecific : InheritableAttr {
+  let Spellings = [GCC<"cpu_specific">];
+  let Args = [VariadicIdentifierArgument<"Cpus">];

Does GCC really support this spelling? I couldn't find documentation to suggest 
it, and a quick test suggests it's not supported there. Perhaps this should use 
the Clang spelling instead?



Comment at: include/clang/Basic/Attr.td:851
+  let Spellings = [GCC<"cpu_specific">];
+  let Args = [VariadicIdentifierArgument<"Cpus">];
+  let Subjects = SubjectList<[Function]>;

Be sure to add a test for using this attribute with the C++ spelling, as I'm 
not certain how well we would parse something like 
`[[gnu::cpu_specific(ivybridge)]]` currently (it may just work, however).

Also, why an identifier instead of a string literal?



Comment at: include/clang/Basic/Attr.td:864
+def CpuDispatch : InheritableAttr {
+  let Spellings = [GCC<"cpu_dispatch">];
+  let Args = [VariadicIdentifierArgument<"Cpus">];

Same here.



Comment at: include/clang/Basic/AttrDocs.td:225-226
+as a parameter (like ``cpu_specific``). However, ``cpu_dispatch`` functions
+may not have a body in its definition. An empty definition is permissible for
+ICC compatibility, and all other definitions will have their body ignored.
+

How empty is empty? e.g., is it lexically empty (no tokens whatsoever) or 
notionally empty (empty after preprocessing)?
```
__attribute__((cpu_dispatch(atom))) void multi_cpu_1(void) {
  /* Is this empty enough? */
}

__attribute__((cpu_dispatch(atom))) void multi_cpu_2(void) {
  #if 0
#error How about this?
  #endif
}
```



Comment at: lib/Parse/ParseDecl.cpp:209
 
-/// Determine whether the given attribute has an identifier argument.
+/// Determine whether the given attribute has a variadic identifier argument.
 static bool attributeHasIdentifierArg(const IdentifierInfo &II) {

This comment seems to be in the wrong place.



Comment at: lib/Sema/SemaDeclAttr.cpp:1877-1878
+static void handleCpuSpecificAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  FunctionDecl *FD = D->getAsFunction();
+  assert(FD && "CPU Specific/Dispatch only valid on a Function Decl");
+

Better to just use `cast(D)` here as it already asserts properly.



Comment at: utils/TableGen/ClangAttrEmitter.cpp:2130
+  std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
+  for (const auto *Attr : Attrs) {
+// Determine whether the first argument is a variadic identifier.

Please don't use `Attr` as a local name; it's a type.


https://reviews.llvm.org/D47474



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


[clang-tools-extra] r333537 - [clangd] clang-format the source code. NFC

2018-05-30 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed May 30 05:41:19 2018
New Revision: 333537

URL: http://llvm.org/viewvc/llvm-project?rev=333537&view=rev
Log:
[clangd] clang-format the source code. NFC

Modified:
clang-tools-extra/trunk/clangd/AST.h
clang-tools-extra/trunk/clangd/Quality.h
clang-tools-extra/trunk/clangd/Trace.h
clang-tools-extra/trunk/clangd/URI.h
clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h
clang-tools-extra/trunk/clangd/index/Index.h
clang-tools-extra/trunk/clangd/index/SymbolYAML.h

Modified: clang-tools-extra/trunk/clangd/AST.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/AST.h?rev=333537&r1=333536&r2=333537&view=diff
==
--- clang-tools-extra/trunk/clangd/AST.h (original)
+++ clang-tools-extra/trunk/clangd/AST.h Wed May 30 05:41:19 2018
@@ -26,7 +26,7 @@ namespace clangd {
 ///
 /// The returned location is usually the spelling location where the name of 
the
 /// decl occurs in the code.
-SourceLocation findNameLoc(const clang::Decl* D);
+SourceLocation findNameLoc(const clang::Decl *D);
 
 } // namespace clangd
 } // namespace clang

Modified: clang-tools-extra/trunk/clangd/Quality.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Quality.h?rev=333537&r1=333536&r2=333537&view=diff
==
--- clang-tools-extra/trunk/clangd/Quality.h (original)
+++ clang-tools-extra/trunk/clangd/Quality.h Wed May 30 05:41:19 2018
@@ -116,8 +116,8 @@ private:
   Compare Greater;
 };
 
-/// Returns a string that sorts in the same order as (-Score, Tiebreak), for 
LSP.
-/// (The highest score compares smallest so it sorts at the top).
+/// Returns a string that sorts in the same order as (-Score, Tiebreak), for
+/// LSP. (The highest score compares smallest so it sorts at the top).
 std::string sortText(float Score, llvm::StringRef Tiebreak = "");
 
 } // namespace clangd

Modified: clang-tools-extra/trunk/clangd/Trace.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Trace.h?rev=333537&r1=333536&r2=333537&view=diff
==
--- clang-tools-extra/trunk/clangd/Trace.h (original)
+++ clang-tools-extra/trunk/clangd/Trace.h Wed May 30 05:41:19 2018
@@ -45,7 +45,7 @@ public:
   // The Context returned by beginSpan is active, but Args is not ready.
   // Tracers should not override this unless they need to observe strict
   // per-thread nesting. Instead they should observe context destruction.
-  virtual void endSpan() {};
+  virtual void endSpan(){};
 
   /// Called for instant events.
   virtual void instant(llvm::StringRef Name, json::obj &&Args) = 0;

Modified: clang-tools-extra/trunk/clangd/URI.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/URI.h?rev=333537&r1=333536&r2=333537&view=diff
==
--- clang-tools-extra/trunk/clangd/URI.h (original)
+++ clang-tools-extra/trunk/clangd/URI.h Wed May 30 05:41:19 2018
@@ -107,9 +107,8 @@ public:
 
   /// Returns the include path of the file (e.g. , "path"), which can be
   /// #included directly. See URI::includeSpelling for details.
-  virtual llvm::Expected
-  getIncludeSpelling(const URI& U) const {
-return "";  // no customized include path for this scheme.
+  virtual llvm::Expected getIncludeSpelling(const URI &U) const {
+return ""; // no customized include path for this scheme.
   }
 };
 

Modified: clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h?rev=333537&r1=333536&r2=333537&view=diff
==
--- clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h (original)
+++ clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h Wed May 30 
05:41:19 2018
@@ -90,4 +90,4 @@ void addSystemHeadersMapping(CanonicalIn
 } // namespace clangd
 } // namespace clang
 
-#endif //LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_HEADERMAPCOLLECTOR_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_HEADERMAPCOLLECTOR_H

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=333537&r1=333536&r2=333537&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Wed May 30 05:41:19 2018
@@ -228,27 +228,27 @@ public:
   // SymbolSlab::Builder is a mutable container that can 'freeze' to 
SymbolSlab.
   // The frozen SymbolSlab will use less memory.
   class Builder {
-   public:
- // Adds a symbol, overwriting any existing one with the same ID.
- // This is a deep copy: un

[PATCH] D44480: [Sema] Don't skip function bodies with 'auto' without trailing return type

2018-05-30 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 149099.
ilya-biryukov added a comment.

- Fix the comments


Repository:
  rC Clang

https://reviews.llvm.org/D44480

Files:
  lib/Sema/SemaDecl.cpp
  test/CodeCompletion/crash-skipped-bodies-template-inst.cpp
  test/CodeCompletion/skip-auto-funcs.cpp

Index: test/CodeCompletion/skip-auto-funcs.cpp
===
--- /dev/null
+++ test/CodeCompletion/skip-auto-funcs.cpp
@@ -0,0 +1,43 @@
+// We run clang in completion mode to force skipping of function bodies and
+// check if the function bodies were skipped by observing the warnings that
+// clang produces.
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:42:1 %s -o - 2>&1 | FileCheck %s
+template 
+auto not_skipped() {
+  int x;
+  if (x = 10) {}
+  // Check that this function is not skipped.
+  // CHECK: 8:9: warning: using the result of an assignment as a condition without parentheses
+  return 1;
+}
+
+template 
+auto lambda_not_skipped = []() {
+  int x;
+  if (x = 10) {}
+  // Check that this function is not skipped.
+  // CHECK: 17:9: warning: using the result of an assignment as a condition without parentheses
+  return 1;
+}
+
+template 
+auto skipped() -> T {
+  int x;
+  if (x = 10) {}
+  // Check that this function is skipped.
+  // CHECK-NOT: 26:9: warning: using the result of an assignment as a condition without parentheses
+  return 1;
+};
+
+auto lambda_skipped = []() -> int {
+  int x;
+  if (x = 10) {}
+  // This could potentially be skipped, but it isn't at the moment.
+  // CHECK: 34:9: warning: using the result of an assignment as a condition without parentheses
+  return 1;
+};
+
+int test() {
+  int complete_in_this_function;
+  // CHECK: COMPLETION: complete_in_this_function
+}
Index: test/CodeCompletion/crash-skipped-bodies-template-inst.cpp
===
--- /dev/null
+++ test/CodeCompletion/crash-skipped-bodies-template-inst.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:24:5 %s -o - 2>&1 | FileCheck %s
+template 
+auto make_func() {
+  struct impl {
+impl* func() {
+  int x;
+  if (x = 10) {}
+  // Check that body of this function is actually skipped.
+  // CHECK-NOT: crash-skipped-bodies-template-inst.cpp:7:{{[0-9]+}}: warning: using the result of an assignment as a condition without parentheses
+  return this;
+}
+  };
+
+  int x;
+  if (x = 10) {}
+  // Check that this function is not skipped.
+  // CHECK: crash-skipped-bodies-template-inst.cpp:15:9: warning: using the result of an assignment as a condition without parentheses
+  return impl();
+}
+
+void foo() {
+  []() {
+make_func();
+m
+// CHECK: COMPLETION: make_func : [#auto#]make_func<<#class T#>>()
+  };
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -12660,9 +12660,15 @@
   // rest of the file.
   // We cannot skip the body of a function with an undeduced return type,
   // because any callers of that function need to know the type.
-  if (const FunctionDecl *FD = D->getAsFunction())
-if (FD->isConstexpr() || FD->getReturnType()->isUndeducedType())
+  if (const FunctionDecl *FD = D->getAsFunction()) {
+if (FD->isConstexpr())
   return false;
+// We can't simply call Type::isUndeducedType here, because inside template
+// auto can be deduced to a dependent type, which is not considered
+// "undeduced".
+if (FD->getReturnType()->getContainedDeducedType())
+  return false;
+  }
   return Consumer.shouldSkipFunctionBody(D);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44480: [Sema] Don't skip function bodies with 'auto' without trailing return type

2018-05-30 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333538: [Sema] Don't skip function bodies with 
'auto' without trailing return type (authored by ibiryukov, committed 
by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D44480

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/CodeCompletion/crash-skipped-bodies-template-inst.cpp
  cfe/trunk/test/CodeCompletion/skip-auto-funcs.cpp

Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -12660,9 +12660,15 @@
   // rest of the file.
   // We cannot skip the body of a function with an undeduced return type,
   // because any callers of that function need to know the type.
-  if (const FunctionDecl *FD = D->getAsFunction())
-if (FD->isConstexpr() || FD->getReturnType()->isUndeducedType())
+  if (const FunctionDecl *FD = D->getAsFunction()) {
+if (FD->isConstexpr())
   return false;
+// We can't simply call Type::isUndeducedType here, because inside template
+// auto can be deduced to a dependent type, which is not considered
+// "undeduced".
+if (FD->getReturnType()->getContainedDeducedType())
+  return false;
+  }
   return Consumer.shouldSkipFunctionBody(D);
 }
 
Index: cfe/trunk/test/CodeCompletion/skip-auto-funcs.cpp
===
--- cfe/trunk/test/CodeCompletion/skip-auto-funcs.cpp
+++ cfe/trunk/test/CodeCompletion/skip-auto-funcs.cpp
@@ -0,0 +1,43 @@
+// We run clang in completion mode to force skipping of function bodies and
+// check if the function bodies were skipped by observing the warnings that
+// clang produces.
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:42:1 %s -o - 2>&1 | FileCheck %s
+template 
+auto not_skipped() {
+  int x;
+  if (x = 10) {}
+  // Check that this function is not skipped.
+  // CHECK: 8:9: warning: using the result of an assignment as a condition without parentheses
+  return 1;
+}
+
+template 
+auto lambda_not_skipped = []() {
+  int x;
+  if (x = 10) {}
+  // Check that this function is not skipped.
+  // CHECK: 17:9: warning: using the result of an assignment as a condition without parentheses
+  return 1;
+}
+
+template 
+auto skipped() -> T {
+  int x;
+  if (x = 10) {}
+  // Check that this function is skipped.
+  // CHECK-NOT: 26:9: warning: using the result of an assignment as a condition without parentheses
+  return 1;
+};
+
+auto lambda_skipped = []() -> int {
+  int x;
+  if (x = 10) {}
+  // This could potentially be skipped, but it isn't at the moment.
+  // CHECK: 34:9: warning: using the result of an assignment as a condition without parentheses
+  return 1;
+};
+
+int test() {
+  int complete_in_this_function;
+  // CHECK: COMPLETION: complete_in_this_function
+}
Index: cfe/trunk/test/CodeCompletion/crash-skipped-bodies-template-inst.cpp
===
--- cfe/trunk/test/CodeCompletion/crash-skipped-bodies-template-inst.cpp
+++ cfe/trunk/test/CodeCompletion/crash-skipped-bodies-template-inst.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:24:5 %s -o - 2>&1 | FileCheck %s
+template 
+auto make_func() {
+  struct impl {
+impl* func() {
+  int x;
+  if (x = 10) {}
+  // Check that body of this function is actually skipped.
+  // CHECK-NOT: crash-skipped-bodies-template-inst.cpp:7:{{[0-9]+}}: warning: using the result of an assignment as a condition without parentheses
+  return this;
+}
+  };
+
+  int x;
+  if (x = 10) {}
+  // Check that this function is not skipped.
+  // CHECK: crash-skipped-bodies-template-inst.cpp:15:9: warning: using the result of an assignment as a condition without parentheses
+  return impl();
+}
+
+void foo() {
+  []() {
+make_func();
+m
+// CHECK: COMPLETION: make_func : [#auto#]make_func<<#class T#>>()
+  };
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r333538 - [Sema] Don't skip function bodies with 'auto' without trailing return type

2018-05-30 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed May 30 05:50:48 2018
New Revision: 333538

URL: http://llvm.org/viewvc/llvm-project?rev=333538&view=rev
Log:
[Sema] Don't skip function bodies with 'auto' without trailing return type

Summary:
Skipping them was clearly not intentional. It's impossible to
guarantee correctness if the bodies are skipped.
Also adds a test case for r327504, now that it does not produce
invalid errors that made the test fail.

Reviewers: aaron.ballman, sammccall, rsmith

Reviewed By: rsmith

Subscribers: rayglover-ibm, rwols, cfe-commits

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

Added:
cfe/trunk/test/CodeCompletion/crash-skipped-bodies-template-inst.cpp
cfe/trunk/test/CodeCompletion/skip-auto-funcs.cpp
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=333538&r1=333537&r2=333538&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed May 30 05:50:48 2018
@@ -12660,9 +12660,15 @@ bool Sema::canSkipFunctionBody(Decl *D)
   // rest of the file.
   // We cannot skip the body of a function with an undeduced return type,
   // because any callers of that function need to know the type.
-  if (const FunctionDecl *FD = D->getAsFunction())
-if (FD->isConstexpr() || FD->getReturnType()->isUndeducedType())
+  if (const FunctionDecl *FD = D->getAsFunction()) {
+if (FD->isConstexpr())
   return false;
+// We can't simply call Type::isUndeducedType here, because inside template
+// auto can be deduced to a dependent type, which is not considered
+// "undeduced".
+if (FD->getReturnType()->getContainedDeducedType())
+  return false;
+  }
   return Consumer.shouldSkipFunctionBody(D);
 }
 

Added: cfe/trunk/test/CodeCompletion/crash-skipped-bodies-template-inst.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/crash-skipped-bodies-template-inst.cpp?rev=333538&view=auto
==
--- cfe/trunk/test/CodeCompletion/crash-skipped-bodies-template-inst.cpp (added)
+++ cfe/trunk/test/CodeCompletion/crash-skipped-bodies-template-inst.cpp Wed 
May 30 05:50:48 2018
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:24:5 %s -o - 2>&1 | 
FileCheck %s
+template 
+auto make_func() {
+  struct impl {
+impl* func() {
+  int x;
+  if (x = 10) {}
+  // Check that body of this function is actually skipped.
+  // CHECK-NOT: crash-skipped-bodies-template-inst.cpp:7:{{[0-9]+}}: 
warning: using the result of an assignment as a condition without parentheses
+  return this;
+}
+  };
+
+  int x;
+  if (x = 10) {}
+  // Check that this function is not skipped.
+  // CHECK: crash-skipped-bodies-template-inst.cpp:15:9: warning: using the 
result of an assignment as a condition without parentheses
+  return impl();
+}
+
+void foo() {
+  []() {
+make_func();
+m
+// CHECK: COMPLETION: make_func : [#auto#]make_func<<#class T#>>()
+  };
+}

Added: cfe/trunk/test/CodeCompletion/skip-auto-funcs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/skip-auto-funcs.cpp?rev=333538&view=auto
==
--- cfe/trunk/test/CodeCompletion/skip-auto-funcs.cpp (added)
+++ cfe/trunk/test/CodeCompletion/skip-auto-funcs.cpp Wed May 30 05:50:48 2018
@@ -0,0 +1,43 @@
+// We run clang in completion mode to force skipping of function bodies and
+// check if the function bodies were skipped by observing the warnings that
+// clang produces.
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:42:1 %s -o - 2>&1 
| FileCheck %s
+template 
+auto not_skipped() {
+  int x;
+  if (x = 10) {}
+  // Check that this function is not skipped.
+  // CHECK: 8:9: warning: using the result of an assignment as a condition 
without parentheses
+  return 1;
+}
+
+template 
+auto lambda_not_skipped = []() {
+  int x;
+  if (x = 10) {}
+  // Check that this function is not skipped.
+  // CHECK: 17:9: warning: using the result of an assignment as a condition 
without parentheses
+  return 1;
+}
+
+template 
+auto skipped() -> T {
+  int x;
+  if (x = 10) {}
+  // Check that this function is skipped.
+  // CHECK-NOT: 26:9: warning: using the result of an assignment as a 
condition without parentheses
+  return 1;
+};
+
+auto lambda_skipped = []() -> int {
+  int x;
+  if (x = 10) {}
+  // This could potentially be skipped, but it isn't at the moment.
+  // CHECK: 34:9: warning: using the result of an assignment as a condition 
without parentheses
+  return 1;
+};
+
+int test() {
+  int complete_in_this_function;
+  // CHECK: COMPLETION: complete_in_this_function
+}


___
cfe-commits mailing list
cfe-commits@lis

r333539 - Revert "[clang-format] Fix putting ObjC message arguments in one line for multiline receiver"

2018-05-30 Thread Jacek Olesiak via cfe-commits
Author: jolesiak
Date: Wed May 30 05:57:58 2018
New Revision: 333539

URL: http://llvm.org/viewvc/llvm-project?rev=333539&view=rev
Log:
Revert "[clang-format] Fix putting ObjC message arguments in one line for 
multiline receiver"

Summary:
This reverts commit db9e5e9a616d7fdd4d1ba4c3b2cd89d8a0238533 (rC333171).

Mentioned change introduced unintended formatting of ObjC code due to split 
priorities inherited from C/C++, e.g.:
```
fooo = [
[obj fooo] aaa:42 aaa:42];
```
instead of
```
fooo =
[[obj fooo] aaa:42
aaa:42];
```
when formatted with ColumnLimit = 30.

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: benhamilton, klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTestObjC.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=333539&r1=333538&r2=333539&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Wed May 30 05:57:58 2018
@@ -1387,29 +1387,6 @@ void ContinuationIndenter::moveStatePast
(Current.is(tok::greater) && Current.is(TT_DictLiteral
 State.Stack.pop_back();
 
-  // Reevaluate whether ObjC message arguments fit into one line.
-  // If a receiver spans multiple lines, e.g.:
-  //   [[object block:^{
-  // return 42;
-  //   }] a:42 b:42];
-  // BreakBeforeParameter is calculated based on an incorrect assumption
-  // (it is checked whether the whole expression fits into one line without
-  // considering a line break inside a message receiver).
-  // We check whether arguements fit after receiver scope closer (into the same
-  // line).
-  if (Current.MatchingParen && Current.MatchingParen->Previous) {
-const FormatToken &CurrentScopeOpener = *Current.MatchingParen->Previous;
-if (CurrentScopeOpener.is(TT_ObjCMethodExpr) &&
-CurrentScopeOpener.MatchingParen) {
-  int NecessarySpaceInLine =
-  getLengthToMatchingParen(CurrentScopeOpener, State.Stack) +
-  CurrentScopeOpener.TotalLength - Current.TotalLength - 1;
-  if (State.Column + Current.ColumnWidth + NecessarySpaceInLine <=
-  Style.ColumnLimit)
-State.Stack.back().BreakBeforeParameter = false;
-}
-  }
-
   if (Current.is(tok::r_square)) {
 // If this ends the array subscript expr, reset the corresponding value.
 const FormatToken *NextNonComment = Current.getNextNonComment();

Modified: cfe/trunk/unittests/Format/FormatTestObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestObjC.cpp?rev=333539&r1=333538&r2=333539&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp Wed May 30 05:57:58 2018
@@ -796,41 +796,6 @@ TEST_F(FormatTestObjC, FormatObjCMethodE
   verifyFormat("[((Foo *)foo) bar];");
   verifyFormat("[((Foo *)foo) bar:1 blech:2];");
 
-  // Message receiver taking multiple lines.
-  Style.ColumnLimit = 20;
-  // Non-corner case.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] a:42 b:42];");
-  // Arguments just fit into one line.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] aaa:42 b:42];");
-  // Arguments just over a column limit.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] aaa:42\n"
-   "bb:42];");
-  // Arguments just fit into one line.
-  Style.ColumnLimit = 23;
-  verifyFormat("[[obj a:42\n"
-   "  b:42\n"
-   "  c:42\n"
-   "  d:42] e:42 f:42];");
-
-  // Arguments do not fit into one line with a receiver.
-  Style.ColumnLimit = 20;
-  verifyFormat("[[obj a:42] a:42\n"
-   "b:42];");
-  verifyFormat("[[obj a:42] a:42\n"
-   "b:42\n"
-   "c:42];");
-  verifyFormat("[[obj aa:42\n"
-   "   b:42]\n"
-   "cc:42\n"
-   " d:42];");
-
-
   Style.ColumnLimit = 70;
   verifyFormat(
   "void f() {\n"


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


[PATCH] D47527: Revert "[clang-format] Fix putting ObjC message arguments in one line for multiline receiver"

2018-05-30 Thread Jacek Olesiak via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC333539: Revert "[clang-format] Fix putting ObjC message 
arguments in one line for… (authored by jolesiak, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47527?vs=149074&id=149101#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47527

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


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -796,41 +796,6 @@
   verifyFormat("[((Foo *)foo) bar];");
   verifyFormat("[((Foo *)foo) bar:1 blech:2];");
 
-  // Message receiver taking multiple lines.
-  Style.ColumnLimit = 20;
-  // Non-corner case.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] a:42 b:42];");
-  // Arguments just fit into one line.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] aaa:42 b:42];");
-  // Arguments just over a column limit.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] aaa:42\n"
-   "bb:42];");
-  // Arguments just fit into one line.
-  Style.ColumnLimit = 23;
-  verifyFormat("[[obj a:42\n"
-   "  b:42\n"
-   "  c:42\n"
-   "  d:42] e:42 f:42];");
-
-  // Arguments do not fit into one line with a receiver.
-  Style.ColumnLimit = 20;
-  verifyFormat("[[obj a:42] a:42\n"
-   "b:42];");
-  verifyFormat("[[obj a:42] a:42\n"
-   "b:42\n"
-   "c:42];");
-  verifyFormat("[[obj aa:42\n"
-   "   b:42]\n"
-   "cc:42\n"
-   " d:42];");
-
-
   Style.ColumnLimit = 70;
   verifyFormat(
   "void f() {\n"
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1387,29 +1387,6 @@
(Current.is(tok::greater) && Current.is(TT_DictLiteral
 State.Stack.pop_back();
 
-  // Reevaluate whether ObjC message arguments fit into one line.
-  // If a receiver spans multiple lines, e.g.:
-  //   [[object block:^{
-  // return 42;
-  //   }] a:42 b:42];
-  // BreakBeforeParameter is calculated based on an incorrect assumption
-  // (it is checked whether the whole expression fits into one line without
-  // considering a line break inside a message receiver).
-  // We check whether arguements fit after receiver scope closer (into the same
-  // line).
-  if (Current.MatchingParen && Current.MatchingParen->Previous) {
-const FormatToken &CurrentScopeOpener = *Current.MatchingParen->Previous;
-if (CurrentScopeOpener.is(TT_ObjCMethodExpr) &&
-CurrentScopeOpener.MatchingParen) {
-  int NecessarySpaceInLine =
-  getLengthToMatchingParen(CurrentScopeOpener, State.Stack) +
-  CurrentScopeOpener.TotalLength - Current.TotalLength - 1;
-  if (State.Column + Current.ColumnWidth + NecessarySpaceInLine <=
-  Style.ColumnLimit)
-State.Stack.back().BreakBeforeParameter = false;
-}
-  }
-
   if (Current.is(tok::r_square)) {
 // If this ends the array subscript expr, reset the corresponding value.
 const FormatToken *NextNonComment = Current.getNextNonComment();


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -796,41 +796,6 @@
   verifyFormat("[((Foo *)foo) bar];");
   verifyFormat("[((Foo *)foo) bar:1 blech:2];");
 
-  // Message receiver taking multiple lines.
-  Style.ColumnLimit = 20;
-  // Non-corner case.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] a:42 b:42];");
-  // Arguments just fit into one line.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] aaa:42 b:42];");
-  // Arguments just over a column limit.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] aaa:42\n"
-   "bb:42];");
-  // Arguments just fit into one line.
-  Style.ColumnLimit = 23;
-  verifyFormat("[[obj a:42\n"
-   "  b:42\n"
-   "  c:42\n"
-   "  d:42] e:42 f:42];");
-
-  // Arguments do not fit into one line with a receiver.
-  Style.ColumnLimit = 20;
-  verifyFormat("[[obj a:42] a:42\n"
-   "b:42];");
-  verifyFormat("[[obj a:42] a:42\n"
-   "b:42\n"
-   "c:42];");
-  verifyFormat("[[obj aa:42\n"
-   "   b:42]\n"
-   "cc:42\n"
-   " d:42]

[PATCH] D47460: Treat files as volatile by default

2018-05-30 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov requested changes to this revision.
ilya-biryukov added a comment.
This revision now requires changes to proceed.

It's a very subtle change and it isn't clear if that's the right thing to do 
without understanding the problem that we're trying to solve.
Could you please elaborate on the problem?

>   accidental memory mapping for main file which sometimes happens through 
> FileSystem::getBufferForFile

Why is memory mapping considered accidental and what problems does it cause?


https://reviews.llvm.org/D47460



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


[PATCH] D47532: [ASTImporter] Import the whole redecl chain of functions

2018-05-30 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: a.sidorin, r.stahl, xazax.hun, balazske.
Herald added subscribers: cfe-commits, dkrupp, rnkovacs.

With this patch when any `FunctionDecl` of a redeclaration chain is imported
then we bring in the whole declaration chain.  This involves functions and
function template specializations.  Also friend functions are affected.  The
chain is imported as it is in the "from" tu, the order of the redeclarations
are kept.  I also changed the lookup logic in order to find friends, but first
making them visible in their declaration context.  We may have long
redeclaration chains if all TU contains the same prototype, but our
measurements shows no degradation in time of CTU analysis (Tmux, Xerces,
Bitcoin, Protobuf).  Also, as further work we could squash redundant
prototypes, but first ensure that functionality is working properly; then
should we optimize.

This may seem like a huge patch, sorry about that. But, most of the changes are
new tests, changes in the production code is not that much.  I also tried to
create a smaller patch which does not affect specializations, but that patch
failed to pass some of the `clang-import-test`s because there we import
function specializations. Also very importantly, we can't just change the
import of `FunctionDecl`s without changing the import of function template
specializations because they are handled as `FunctionDecl`s.


Repository:
  rC Clang

https://reviews.llvm.org/D47532

Files:
  include/clang/AST/ASTImporter.h
  lib/AST/ASTImporter.cpp
  lib/AST/DeclBase.cpp
  test/ASTMerge/class/test.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -20,7 +20,7 @@
 
 #include "DeclMatcher.h"
 #include "Language.h"
-#include "gtest/gtest.h"
+#include "gmock/gmock.h"
 #include "llvm/ADT/StringMap.h"
 
 namespace clang {
@@ -425,6 +425,48 @@
   }
 }
 
+struct CanonicalRedeclChain : ASTImporterTestBase {};
+
+TEST_P(CanonicalRedeclChain, ShouldBeConsequentWithMatchers) {
+  Decl *FromTU = getTuDecl("void f();", Lang_CXX);
+  auto Pattern = functionDecl(hasName("f"));
+  auto D0 = FirstDeclMatcher().match(FromTU, Pattern);
+
+  auto Redecls = getCanonicalForwardRedeclChain(D0);
+  ASSERT_EQ(Redecls.size(), 1u);
+  EXPECT_EQ(D0, Redecls[0]);
+}
+
+TEST_P(CanonicalRedeclChain, ShouldBeConsequentWithMatchers2) {
+  Decl *FromTU = getTuDecl("void f(); void f(); void f();", Lang_CXX);
+  auto Pattern = functionDecl(hasName("f"));
+  auto D0 = FirstDeclMatcher().match(FromTU, Pattern);
+  auto D2 = LastDeclMatcher().match(FromTU, Pattern);
+  FunctionDecl *D1 = D2->getPreviousDecl();
+
+  auto Redecls = getCanonicalForwardRedeclChain(D0);
+  ASSERT_EQ(Redecls.size(), 3u);
+  EXPECT_EQ(D0, Redecls[0]);
+  EXPECT_EQ(D1, Redecls[1]);
+  EXPECT_EQ(D2, Redecls[2]);
+}
+
+TEST_P(CanonicalRedeclChain, ShouldBeSameForAllDeclInTheChain) {
+  Decl *FromTU = getTuDecl("void f(); void f(); void f();", Lang_CXX);
+  auto Pattern = functionDecl(hasName("f"));
+  auto D0 = FirstDeclMatcher().match(FromTU, Pattern);
+  auto D2 = LastDeclMatcher().match(FromTU, Pattern);
+  FunctionDecl *D1 = D2->getPreviousDecl();
+
+  auto RedeclsD0 = getCanonicalForwardRedeclChain(D0);
+  auto RedeclsD1 = getCanonicalForwardRedeclChain(D1);
+  auto RedeclsD2 = getCanonicalForwardRedeclChain(D2);
+
+  EXPECT_THAT(RedeclsD0, ::testing::ContainerEq(RedeclsD1));
+  EXPECT_THAT(RedeclsD1, ::testing::ContainerEq(RedeclsD2));
+}
+
+
 TEST(ImportExpr, ImportStringLiteral) {
   MatchVerifier Verifier;
   testImport("void declToImport() { \"foo\"; }",
@@ -1607,41 +1649,9 @@
 .match(ToTU, classTemplateSpecializationDecl()));
 }
 
-INSTANTIATE_TEST_CASE_P(
-ParameterizedTests, ASTImporterTestBase,
-::testing::Values(ArgVector(), ArgVector{"-fdelayed-template-parsing"}),);
-
 struct ImportFunctions : ASTImporterTestBase {};
 
 TEST_P(ImportFunctions,
-   PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition) {
-  Decl *FromTU = getTuDecl("void f();", Lang_CXX);
-  auto Pattern = functionDecl(hasName("f"));
-  FunctionDecl *FromD =
-  FirstDeclMatcher().match(FromTU, Pattern);
-
-  Decl *ImportedD = Import(FromD, Lang_CXX);
-  Decl *ToTU = ImportedD->getTranslationUnitDecl();
-
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 1u);
-  EXPECT_TRUE(!cast(ImportedD)->doesThisDeclarationHaveABody());
-}
-
-TEST_P(ImportFunctions,
-   PrototypeShouldBeImportedAsDefintionWhenThereIsADefinition) {
-  Decl *FromTU = getTuDecl("void f(); void f() {}", Lang_CXX);
-  auto Pattern = functionDecl(hasName("f"));
-  FunctionDecl *FromD = // Prototype
-  FirstDeclMatcher().match(FromTU, Pattern);
-
-  Decl *ImportedD = Import(FromD, Lang_CXX);
-  Decl *ToTU = ImportedD->getTranslationUnitDecl();
-
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 1u);
-  EXPECT_TRUE(cast(Impo

[PATCH] D47460: Treat files as volatile by default

2018-05-30 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

Memory mapping locks the file on Windows. That means that in the addressed case 
it locks main file which we are editing. After that happens many tools struggle 
to do something with this file, for example git.
It's the quickest solution, probably not the best. Better one would introduce 
isVolatile parameter in FileSystem::getBufferForFile which should be set to 
true somewhere (I didn't have to to search for the specific location yet)


https://reviews.llvm.org/D47460



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


[PATCH] D47532: [ASTImporter] Import the whole redecl chain of functions

2018-05-30 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 149107.
martong added a comment.

- Add a missing "else"


Repository:
  rC Clang

https://reviews.llvm.org/D47532

Files:
  include/clang/AST/ASTImporter.h
  lib/AST/ASTImporter.cpp
  lib/AST/DeclBase.cpp
  test/ASTMerge/class/test.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -20,7 +20,7 @@
 
 #include "DeclMatcher.h"
 #include "Language.h"
-#include "gtest/gtest.h"
+#include "gmock/gmock.h"
 #include "llvm/ADT/StringMap.h"
 
 namespace clang {
@@ -425,6 +425,48 @@
   }
 }
 
+struct CanonicalRedeclChain : ASTImporterTestBase {};
+
+TEST_P(CanonicalRedeclChain, ShouldBeConsequentWithMatchers) {
+  Decl *FromTU = getTuDecl("void f();", Lang_CXX);
+  auto Pattern = functionDecl(hasName("f"));
+  auto D0 = FirstDeclMatcher().match(FromTU, Pattern);
+
+  auto Redecls = getCanonicalForwardRedeclChain(D0);
+  ASSERT_EQ(Redecls.size(), 1u);
+  EXPECT_EQ(D0, Redecls[0]);
+}
+
+TEST_P(CanonicalRedeclChain, ShouldBeConsequentWithMatchers2) {
+  Decl *FromTU = getTuDecl("void f(); void f(); void f();", Lang_CXX);
+  auto Pattern = functionDecl(hasName("f"));
+  auto D0 = FirstDeclMatcher().match(FromTU, Pattern);
+  auto D2 = LastDeclMatcher().match(FromTU, Pattern);
+  FunctionDecl *D1 = D2->getPreviousDecl();
+
+  auto Redecls = getCanonicalForwardRedeclChain(D0);
+  ASSERT_EQ(Redecls.size(), 3u);
+  EXPECT_EQ(D0, Redecls[0]);
+  EXPECT_EQ(D1, Redecls[1]);
+  EXPECT_EQ(D2, Redecls[2]);
+}
+
+TEST_P(CanonicalRedeclChain, ShouldBeSameForAllDeclInTheChain) {
+  Decl *FromTU = getTuDecl("void f(); void f(); void f();", Lang_CXX);
+  auto Pattern = functionDecl(hasName("f"));
+  auto D0 = FirstDeclMatcher().match(FromTU, Pattern);
+  auto D2 = LastDeclMatcher().match(FromTU, Pattern);
+  FunctionDecl *D1 = D2->getPreviousDecl();
+
+  auto RedeclsD0 = getCanonicalForwardRedeclChain(D0);
+  auto RedeclsD1 = getCanonicalForwardRedeclChain(D1);
+  auto RedeclsD2 = getCanonicalForwardRedeclChain(D2);
+
+  EXPECT_THAT(RedeclsD0, ::testing::ContainerEq(RedeclsD1));
+  EXPECT_THAT(RedeclsD1, ::testing::ContainerEq(RedeclsD2));
+}
+
+
 TEST(ImportExpr, ImportStringLiteral) {
   MatchVerifier Verifier;
   testImport("void declToImport() { \"foo\"; }",
@@ -1607,41 +1649,9 @@
 .match(ToTU, classTemplateSpecializationDecl()));
 }
 
-INSTANTIATE_TEST_CASE_P(
-ParameterizedTests, ASTImporterTestBase,
-::testing::Values(ArgVector(), ArgVector{"-fdelayed-template-parsing"}),);
-
 struct ImportFunctions : ASTImporterTestBase {};
 
 TEST_P(ImportFunctions,
-   PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition) {
-  Decl *FromTU = getTuDecl("void f();", Lang_CXX);
-  auto Pattern = functionDecl(hasName("f"));
-  FunctionDecl *FromD =
-  FirstDeclMatcher().match(FromTU, Pattern);
-
-  Decl *ImportedD = Import(FromD, Lang_CXX);
-  Decl *ToTU = ImportedD->getTranslationUnitDecl();
-
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 1u);
-  EXPECT_TRUE(!cast(ImportedD)->doesThisDeclarationHaveABody());
-}
-
-TEST_P(ImportFunctions,
-   PrototypeShouldBeImportedAsDefintionWhenThereIsADefinition) {
-  Decl *FromTU = getTuDecl("void f(); void f() {}", Lang_CXX);
-  auto Pattern = functionDecl(hasName("f"));
-  FunctionDecl *FromD = // Prototype
-  FirstDeclMatcher().match(FromTU, Pattern);
-
-  Decl *ImportedD = Import(FromD, Lang_CXX);
-  Decl *ToTU = ImportedD->getTranslationUnitDecl();
-
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 1u);
-  EXPECT_TRUE(cast(ImportedD)->doesThisDeclarationHaveABody());
-}
-
-TEST_P(ImportFunctions,
DefinitionShouldBeImportedAsDefintionWhenThereIsAPrototype) {
   Decl *FromTU = getTuDecl("void f(); void f() {}", Lang_CXX);
   auto Pattern = functionDecl(hasName("f"));
@@ -1651,7 +1661,7 @@
   Decl *ImportedD = Import(FromD, Lang_CXX);
   Decl *ToTU = ImportedD->getTranslationUnitDecl();
 
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 1u);
+  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 2u);
   EXPECT_TRUE(cast(ImportedD)->doesThisDeclarationHaveABody());
 }
 
@@ -1668,80 +1678,116 @@
   EXPECT_TRUE(cast(ImportedD)->doesThisDeclarationHaveABody());
 }
 
-TEST_P(ImportFunctions, DISABLED_ImportPrototypeOfRecursiveFunction) {
+TEST_P(ImportFunctions, ImportPrototypeOfRecursiveFunction) {
   Decl *FromTU = getTuDecl("void f(); void f() { f(); }", Lang_CXX);
   auto Pattern = functionDecl(hasName("f"));
-  FunctionDecl *PrototypeFD =
-  FirstDeclMatcher().match(FromTU, Pattern);
+  auto From =
+  FirstDeclMatcher().match(FromTU, Pattern); // Proto
 
-  Decl *ImportedD = Import(PrototypeFD, Lang_CXX);
+  Decl *ImportedD = Import(From, Lang_CXX);
   Decl *ToTU = ImportedD->getTranslationUnitDecl();
 
-  EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 1u);
-  EXPECT_TRUE(cast(ImportedD)->doesThisDeclarationHaveABody());
+  EXPEC

[PATCH] D47367: [ASTImporter] Add ms compatibility to tests

2018-05-30 Thread Balázs Kéri via Phabricator via cfe-commits
balazske accepted this revision.
balazske added a comment.
This revision is now accepted and ready to land.

Found no big problems. But not all extra options are applicable to all 
languages (template related things to C) so there may be redundant tests.


Repository:
  rC Clang

https://reviews.llvm.org/D47367



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


[PATCH] D47450: [ASTImporter] Use InjectedClassNameType at import of templated record.

2018-05-30 Thread Balázs Kéri via Phabricator via cfe-commits
balazske requested review of this revision.
balazske added inline comments.



Comment at: lib/AST/ASTImporter.cpp:2131
 D2CXX->setDescribedClassTemplate(ToDescribed);
+if (!DCXX->isInjectedClassName()) {
+  // In a record describing a template the type should be a

a.sidorin wrote:
> Maybe we should fix it a bit upper (line 2100)?
The `ToDescribed` is used in this code, not available before the new record is 
created.


Repository:
  rC Clang

https://reviews.llvm.org/D47450



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


[PATCH] D47450: [ASTImporter] Use InjectedClassNameType at import of templated record.

2018-05-30 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: test/ASTMerge/injected-class-name-decl-1/Inputs/inject1.cpp:16
+} // namespace google
+namespace a {
+template  class g;

a.sidorin wrote:
> This looks like raw creduce output. Is there a way to simplify this or make 
> human-readable? Do we really need nested namespaces, unused decls and other 
> stuff not removed by creduce? I know that creduce is bad at reducing 
> templates because we often meet similar output internally. But it is usually 
> not a problem to resolve some redundancy manually to assist creduce. In this 
> case, we can start by removing `k` and `n`.
> We can leave this code as-is only if removing declarations or simplifying 
> templates affects import order causing the bug to disappear. But even in this 
> case we have to humanize the test.
Probably remove this test? There was some bug in a previous version of the fix 
that was triggered by this test. Before that fix (and on current master) this 
test does not fail so it is not possible to simplify it.


Repository:
  rC Clang

https://reviews.llvm.org/D47450



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


[PATCH] D47534: [ASTImporter] Add new tests about templated-described swing

2018-05-30 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: a.sidorin, r.stahl, xazax.hun.
Herald added subscribers: cfe-commits, dkrupp, rnkovacs.

Add a new test about importing a partial specialization (of a class).  Also,
this patch adds new tests about the templated-described swing, some of these
fail ATM, but subsequent patches will fix them.


Repository:
  rC Clang

https://reviews.llvm.org/D47534

Files:
  unittests/AST/ASTImporterTest.cpp


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -1087,6 +1087,22 @@
  unless(has(cxxRecordDecl(hasName("declToImport";
 }
 
+TEST(ImportDecl, ImportClassTemplatePartialSpecialization) {
+  MatchVerifier Verifier;
+  auto Code =
+  R"s(
+struct declToImport {
+  template 
+  struct X;
+   template 
+  struct X {};
+};
+)s";
+  testImport(Code, Lang_CXX, "", Lang_CXX, Verifier,
+ recordDecl(has(classTemplateDecl()),
+has(classTemplateSpecializationDecl(;
+}
+
 TEST(ImportExpr, CXXOperatorCallExpr) {
   MatchVerifier Verifier;
   testImport("class declToImport {"
@@ -1120,6 +1136,52 @@
   EXPECT_EQ(ToTemplated1, ToTemplated);
 }
 
+TEST_P(ASTImporterTestBase,
+   DISABLED_ImportOfTemplatedDeclOfFunctionTemplateDecl) {
+  Decl *FromTU = getTuDecl("template void f(){}", Lang_CXX);
+  auto From = FirstDeclMatcher().match(
+  FromTU, functionTemplateDecl());
+  ASSERT_TRUE(From);
+  auto To = cast(Import(From, Lang_CXX));
+  ASSERT_TRUE(To);
+  Decl *ToTemplated = To->getTemplatedDecl();
+  Decl *ToTemplated1 = Import(From->getTemplatedDecl(), Lang_CXX);
+  EXPECT_TRUE(ToTemplated1);
+  EXPECT_EQ(ToTemplated1, ToTemplated);
+}
+
+TEST_P(ASTImporterTestBase,
+   ImportOfTemplatedDeclShouldImportTheClassTemplateDecl) {
+  Decl *FromTU = getTuDecl("template struct S{};", Lang_CXX);
+  auto FromFT =
+  FirstDeclMatcher().match(FromTU, classTemplateDecl());
+  ASSERT_TRUE(FromFT);
+
+  auto ToTemplated =
+  cast(Import(FromFT->getTemplatedDecl(), Lang_CXX));
+  EXPECT_TRUE(ToTemplated);
+  auto ToTU = ToTemplated->getTranslationUnitDecl();
+  auto ToFT =
+  FirstDeclMatcher().match(ToTU, classTemplateDecl());
+  EXPECT_TRUE(ToFT);
+}
+
+TEST_P(ASTImporterTestBase,
+   DISABLED_ImportOfTemplatedDeclShouldImportTheFunctionTemplateDecl) {
+  Decl *FromTU = getTuDecl("template void f(){}", Lang_CXX);
+  auto FromFT = FirstDeclMatcher().match(
+  FromTU, functionTemplateDecl());
+  ASSERT_TRUE(FromFT);
+
+  auto ToTemplated =
+  cast(Import(FromFT->getTemplatedDecl(), Lang_CXX));
+  EXPECT_TRUE(ToTemplated);
+  auto ToTU = ToTemplated->getTranslationUnitDecl();
+  auto ToFT = FirstDeclMatcher().match(
+  ToTU, functionTemplateDecl());
+  EXPECT_TRUE(ToFT);
+}
+
 TEST_P(ASTImporterTestBase, ImportCorrectTemplatedDecl) {
   auto Code =
 R"(


Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -1087,6 +1087,22 @@
  unless(has(cxxRecordDecl(hasName("declToImport";
 }
 
+TEST(ImportDecl, ImportClassTemplatePartialSpecialization) {
+  MatchVerifier Verifier;
+  auto Code =
+  R"s(
+struct declToImport {
+  template 
+  struct X;
+   template 
+  struct X {};
+};
+)s";
+  testImport(Code, Lang_CXX, "", Lang_CXX, Verifier,
+ recordDecl(has(classTemplateDecl()),
+has(classTemplateSpecializationDecl(;
+}
+
 TEST(ImportExpr, CXXOperatorCallExpr) {
   MatchVerifier Verifier;
   testImport("class declToImport {"
@@ -1120,6 +1136,52 @@
   EXPECT_EQ(ToTemplated1, ToTemplated);
 }
 
+TEST_P(ASTImporterTestBase,
+   DISABLED_ImportOfTemplatedDeclOfFunctionTemplateDecl) {
+  Decl *FromTU = getTuDecl("template void f(){}", Lang_CXX);
+  auto From = FirstDeclMatcher().match(
+  FromTU, functionTemplateDecl());
+  ASSERT_TRUE(From);
+  auto To = cast(Import(From, Lang_CXX));
+  ASSERT_TRUE(To);
+  Decl *ToTemplated = To->getTemplatedDecl();
+  Decl *ToTemplated1 = Import(From->getTemplatedDecl(), Lang_CXX);
+  EXPECT_TRUE(ToTemplated1);
+  EXPECT_EQ(ToTemplated1, ToTemplated);
+}
+
+TEST_P(ASTImporterTestBase,
+   ImportOfTemplatedDeclShouldImportTheClassTemplateDecl) {
+  Decl *FromTU = getTuDecl("template struct S{};", Lang_CXX);
+  auto FromFT =
+  FirstDeclMatcher().match(FromTU, classTemplateDecl());
+  ASSERT_TRUE(FromFT);
+
+  auto ToTemplated =
+  cast(Import(FromFT->getTemplatedDecl(), Lang_CXX));
+  EXPECT_TRUE(ToTemplated);
+  auto ToTU = ToTemplated->getTranslationUnitDecl();
+  auto ToFT =
+  FirstDeclMatcher().match(ToTU, classTemplateDecl());
+  EXPECT_TRUE(ToFT);
+}
+
+TEST_P(ASTImporterTestBase,
+   DISABLED_ImportOfTemplatedDeclShouldImportTheFuncti

[PATCH] D47067: Update NRVO logic to support early return

2018-05-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Unfortunately this seems to miscompile, the stage1 built clang is crashing on 
the multistage buildbots:

http://lab.llvm.org:8011/builders/clang-s390x-linux-multistage/builds/2926 
shows this crash present already at 333500
I've locally verified the crash and that that reverting this patch fixes it.

I'm going to revert it.


Repository:
  rC Clang

https://reviews.llvm.org/D47067



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


r333547 - Revert "Update NRVO logic to support early return"

2018-05-30 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Wed May 30 07:14:58 2018
New Revision: 333547

URL: http://llvm.org/viewvc/llvm-project?rev=333547&view=rev
Log:
Revert "Update NRVO logic to support early return"

This reverts commit r333500, which causes stage2 compiler crashes.

Removed:
cfe/trunk/test/CodeGenCXX/nrvo-noopt.cpp
cfe/trunk/test/SemaCXX/nrvo-ast.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/Sema/Scope.h
cfe/trunk/lib/Sema/Scope.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/CodeGenCXX/nrvo.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=333547&r1=333546&r2=333547&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed May 30 07:14:58 2018
@@ -879,12 +879,6 @@ protected:
 DAK_Normal
   };
 
-  enum NRVOMode {
-NRVO_Candidate,
-NRVO_Disabled,
-NRVO_Enabled,
-  };
-
   class ParmVarDeclBitfields {
 friend class ASTDeclReader;
 friend class ParmVarDecl;
@@ -937,7 +931,7 @@ protected:
 /// Whether this local variable could be allocated in the return
 /// slot of its function, enabling the named return value optimization
 /// (NRVO).
-unsigned NRVOMode : 2;
+unsigned NRVOVariable : 1;
 
 /// Whether this variable is the for-range-declaration in a C++0x
 /// for-range statement.
@@ -1325,20 +1319,12 @@ public:
   /// return slot when returning from the function. Within the function body,
   /// each return that returns the NRVO object will have this variable as its
   /// NRVO candidate.
-  NRVOMode getNRVOMode() const {
-if (isa(this))
-  return NRVO_Disabled;
-return static_cast(NonParmVarDeclBits.NRVOMode);
-  }
-  bool isNRVOCandidate() const {
-return isa(this) ? false : NonParmVarDeclBits.NRVOMode == 
NRVO_Candidate;
-  }
   bool isNRVOVariable() const {
-return isa(this) ? false : NonParmVarDeclBits.NRVOMode == 
NRVO_Enabled;
+return isa(this) ? false : NonParmVarDeclBits.NRVOVariable;
   }
   void setNRVOVariable(bool NRVO) {
 assert(!isa(this));
-NonParmVarDeclBits.NRVOMode = NRVO ? NRVO_Enabled : NRVO_Disabled;
+NonParmVarDeclBits.NRVOVariable = NRVO;
   }
 
   /// Determine whether this variable is the for-range-declaration in

Modified: cfe/trunk/include/clang/Sema/Scope.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Scope.h?rev=333547&r1=333546&r2=333547&view=diff
==
--- cfe/trunk/include/clang/Sema/Scope.h (original)
+++ cfe/trunk/include/clang/Sema/Scope.h Wed May 30 07:14:58 2018
@@ -201,6 +201,10 @@ private:
   /// Used to determine if errors occurred in this scope.
   DiagnosticErrorTrap ErrorTrap;
 
+  /// A lattice consisting of undefined, a single NRVO candidate variable in
+  /// this scope, or over-defined. The bit is true when over-defined.
+  llvm::PointerIntPair NRVO;
+
   void setFlags(Scope *Parent, unsigned F);
 
 public:
@@ -462,7 +466,23 @@ public:
   UsingDirectives.end());
   }
 
-  void setNRVOCandidate(VarDecl *Candidate);
+  void addNRVOCandidate(VarDecl *VD) {
+if (NRVO.getInt())
+  return;
+if (NRVO.getPointer() == nullptr) {
+  NRVO.setPointer(VD);
+  return;
+}
+if (NRVO.getPointer() != VD)
+  setNoNRVO();
+  }
+
+  void setNoNRVO() {
+NRVO.setInt(true);
+NRVO.setPointer(nullptr);
+  }
+
+  void mergeNRVOIntoParent();
 
   /// Init - This is used by the parser to implement scope caching.
   void Init(Scope *parent, unsigned flags);

Modified: cfe/trunk/lib/Sema/Scope.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Scope.cpp?rev=333547&r1=333546&r2=333547&view=diff
==
--- cfe/trunk/lib/Sema/Scope.cpp (original)
+++ cfe/trunk/lib/Sema/Scope.cpp Wed May 30 07:14:58 2018
@@ -92,6 +92,7 @@ void Scope::Init(Scope *parent, unsigned
   UsingDirectives.clear();
   Entity = nullptr;
   ErrorTrap.reset();
+  NRVO.setPointerAndInt(nullptr, 0);
 }
 
 bool Scope::containedInPrototypeScope() const {
@@ -118,15 +119,19 @@ void Scope::AddFlags(unsigned FlagsToSet
   Flags |= FlagsToSet;
 }
 
-void Scope::setNRVOCandidate(VarDecl *Candidate) {
-  for (Decl *D : DeclsInScope) {
-VarDecl *VD = dyn_cast(D);
-if (VD && VD != Candidate && VD->isNRVOCandidate())
-  VD->setNRVOVariable(false);
+void Scope::mergeNRVOIntoParent() {
+  if (VarDecl *Candidate = NRVO.getPointer()) {
+if (isDeclScope(Candidate))
+  Candidate->setNRVOVariable(true);
   }
 
-  if (Scope *parent = getParent())
-parent->setNRVOCan

[PATCH] D47063: [clangd] Keep only a limited number of idle ASTs in memory

2018-05-30 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/TUScheduler.h:66
+  std::chrono::steady_clock::duration UpdateDebounce,
+  ASTRetentionPolicy RetentionPolicy = {});
   ~TUScheduler();

ilya-biryukov wrote:
> sammccall wrote:
> > does this actually have more than one caller? what's the plan for exposing 
> > this option to embedders/CLI users (not saying we necessarily need the 
> > latter)?
> Yes, just one caller outside the tests.
> The plan was to expose it only in `ClangdServer` for now. Giving this knob in 
> CLI might be useful, if we have good reasons for that, but I hope that we 
> could pick the default that work for everyone instead.
> Added that as a parameter of `ClangdServer`.
> 
> Maybe we should move the default value of 3 to `ClangdServer`? WDYT?
CLI when needed SG.
I think we want to give our cloud folks the chance to set it to zero.
So maybe put the default in ClangdLSPServer? (or make it a param there too and 
move the value to main)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47063



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


[clang-tools-extra] r333548 - [clangd] Add forgotten include guard to TestFS.h. NFC

2018-05-30 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed May 30 07:21:31 2018
New Revision: 333548

URL: http://llvm.org/viewvc/llvm-project?rev=333548&view=rev
Log:
[clangd] Add forgotten include guard to TestFS.h. NFC

Modified:
clang-tools-extra/trunk/unittests/clangd/TestFS.h

Modified: clang-tools-extra/trunk/unittests/clangd/TestFS.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/TestFS.h?rev=333548&r1=333547&r2=333548&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/TestFS.h (original)
+++ clang-tools-extra/trunk/unittests/clangd/TestFS.h Wed May 30 07:21:31 2018
@@ -10,6 +10,8 @@
 // Allows setting up fake filesystem environments for tests.
 //
 
//===--===//
+#ifndef LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTFS_H
+#define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTFS_H
 #include "ClangdServer.h"
 #include "clang/Basic/VirtualFileSystem.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
@@ -56,3 +58,4 @@ std::string testPath(PathRef File);
 
 } // namespace clangd
 } // namespace clang
+#endif


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


[PATCH] D46084: [Fixed Point Arithmetic] Addition of the Fixed Point _Accum type

2018-05-30 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added a comment.

Sorry for the late notice; I missed something.




Comment at: include/clang/Basic/TokenKinds.def:393
+// ISO/IEC JTC1 SC22 WG14 N1169 Extension
+KEYWORD(_Accum  , KEYALL)
+

I believe that having KEYALL will enable the keyword even if -fno-fixed-point 
is given. Is this desired? It will mean that `_Accum` will not be a valid 
identifier in standard C regardless of the flag.


Repository:
  rC Clang

https://reviews.llvm.org/D46084



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


[PATCH] D47450: [ASTImporter] Use InjectedClassNameType at import of templated record.

2018-05-30 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: test/ASTMerge/injected-class-name-decl-1/Inputs/inject1.cpp:16
+} // namespace google
+namespace a {
+template  class g;

balazske wrote:
> a.sidorin wrote:
> > This looks like raw creduce output. Is there a way to simplify this or make 
> > human-readable? Do we really need nested namespaces, unused decls and other 
> > stuff not removed by creduce? I know that creduce is bad at reducing 
> > templates because we often meet similar output internally. But it is 
> > usually not a problem to resolve some redundancy manually to assist 
> > creduce. In this case, we can start by removing `k` and `n`.
> > We can leave this code as-is only if removing declarations or simplifying 
> > templates affects import order causing the bug to disappear. But even in 
> > this case we have to humanize the test.
> Probably remove this test? There was some bug in a previous version of the 
> fix that was triggered by this test. Before that fix (and on current master) 
> this test does not fail so it is not possible to simplify it.
I vote on deleting this test then. We already have another clear and simple 
test.


Repository:
  rC Clang

https://reviews.llvm.org/D47450



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


[PATCH] D40988: Clang-format: add finer-grained options for putting all arguments on one line

2018-05-30 Thread Russell McClellan via Phabricator via cfe-commits
russellmcc added inline comments.



Comment at: lib/Format/ContinuationIndenter.cpp:760
 (!Style.AllowAllParametersOfDeclarationOnNextLine &&
  State.Line->MustBeDeclaration) ||
+(!Style.AllowAllArgumentsOnNextLine &&

djasper wrote:
> This still looks suspicious to me. State.Line->MustBeDeclaration is either 
> true or false meaning that AllowAllParametersOfDeclarationOnNextLine or 
> AllowAllArgumentsOnNextLine can always affect the behavior here, leading to 
> BreakBeforeParameter to be set to true, even if we are in the case for 
> PreviousIsBreakingCtorInitializerColon being true.
> 
> So, my guess would be that if you set one of AllowAllArgumentsOnNextLine and 
> AllowAllParametersOfDeclarationOnNextLine to false, then 
> AllowAllConstructorInitializersOnNextLine doesn't have an effect anymore.
> 
> Please verify, and if this is true, please fix and add tests. I think this 
> might be easier to understand if you pulled the one if statement apart.
Actually, I think this logic works.  The case you are worried about 
(interaction between arguments, parameters, and constructor initializers) is 
already tested in the unit tests in the 
`AllowAllConstructorInitializersOnNextLine` test.  The specific concern you 
have is solved by the separate if statement below.

I agree that this logic is a bit complex, but I think it's necessary since in 
most cases we don't want to change the existing value of 
`State.Stack.back().BreakBeforeParameter` - we only want to change this when we 
are sure we should or shouldn't bin-pack.  I've tried hard not to change any 
existing behavior unless it was clearly a bug.  I think we could simplify this 
logic if we wanted to be less conservative.

I'm not sure what you mean by breaking up the if statement - did you mean 
something like this?  To me, this reads much more verbose and is a bit more 
confusing; however I'm happy to edit the diff if it makes more sense to you:

```
// If we are breaking after '(', '{', '<', or this is the break after a ':'
// to start a member initializater list in a constructor, this should not
// be considered bin packing unless the relevant AllowAll option is false or
// this is a dict/object literal.
bool PreviousIsBreakingCtorInitializerColon =
Previous.is(TT_CtorInitializerColon) &&
Style.BreakConstructorInitializers == FormatStyle::BCIS_AfterColon;

if (!(Previous.isOneOf(tok::l_paren, tok::l_brace, TT_BinaryOperator) ||
  PreviousIsBreakingCtorInitializerColon))
  State.Stack.back().BreakBeforeParameter = true;

if (!Style.AllowAllParametersOfDeclarationOnNextLine &&
State.Line->MustBeDeclaration)
  State.Stack.back().BreakBeforeParameter = true;

if (!Style.AllowAllArgumentsOnNextLine && !State.Line->MustBeDeclaration)
  State.Stack.back().BreakBeforeParameter = true;

if (!Style.AllowAllConstructorInitializersOnNextLine &&
PreviousIsBreakingCtorInitializerColon)
  State.Stack.back().BreakBeforeParameter = true;

if (Previous.is(TT_DictLiteral)))
  State.Stack.back().BreakBeforeParameter = true;

// If we are breaking after a ':' to start a member initializer list,
// and we allow all arguments on the next line, we should not break
// before the next parameter.
if (PreviousIsBreakingCtorInitializerColon &&
Style.AllowAllConstructorInitializersOnNextLine)
  State.Stack.back().BreakBeforeParameter = false;
```


https://reviews.llvm.org/D40988



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


[PATCH] D47067: Update NRVO logic to support early return

2018-05-30 Thread Taiju Tsuiki via Phabricator via cfe-commits
tzik added a comment.

In https://reviews.llvm.org/D47067#1116246, @sammccall wrote:

> Unfortunately this seems to miscompile, the stage1 built clang is crashing on 
> the multistage buildbots:
>
> http://lab.llvm.org:8011/builders/clang-s390x-linux-multistage/builds/2926 
> shows this crash present already at 333500
>  I've locally verified the crash and that that reverting this patch fixes it.
>
> I'm going to revert it.


Ah... Thanks for taking care.


Repository:
  rC Clang

https://reviews.llvm.org/D47067



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


[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen

2018-05-30 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 149116.
Charusso added a comment.

@xbolva00 idea implemented, doubled the checker's power. Now if the given 
argument is a DeclRefExpr this should handle it as it would be inlined as a 
simple CallExpr.

Results:
I have found 37 `memcpy()` and 2 `memchr()` errors in: curl, FFmpeg, git, 
memcached, OpenSSL, PostGreSQL, Redis, twin.

Example of this new DRE case:
F6291767: postgresql-src-common-md5-c.html 

Found `memchr()` errors:
F6291768: git-vcs-svn-fast_export-c.html 
F6291769: twin-clients-dialog-c.html 

All findings: F6291784: memcpy_and_memchr_errors.rar 



https://reviews.llvm.org/D45050

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
  clang-tidy/bugprone/NotNullTerminatedResultCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-not-null-terminated-result-in-initialization.c
  test/clang-tidy/bugprone-not-null-terminated-result-strlen-before-safe.c
  test/clang-tidy/bugprone-not-null-terminated-result-strlen-safe.c
  test/clang-tidy/bugprone-not-null-terminated-result-wcslen-before-safe.c
  test/clang-tidy/bugprone-not-null-terminated-result-wcslen-safe.c

Index: test/clang-tidy/bugprone-not-null-terminated-result-wcslen-safe.c
===
--- /dev/null
+++ test/clang-tidy/bugprone-not-null-terminated-result-wcslen-safe.c
@@ -0,0 +1,150 @@
+// RUN: %check_clang_tidy %s bugprone-not-null-terminated-result %t -- \
+// RUN: -- -std=c11
+
+typedef unsigned int size_t;
+typedef unsigned int wchar_t;
+typedef int errno_t;
+size_t wcslen(const wchar_t *);
+wchar_t *wcschr(const wchar_t *, int);
+errno_t *wcsncpy_s(wchar_t *, const wchar_t *, size_t);
+
+void *alloca(size_t);
+void *calloc(size_t, size_t);
+void *malloc(size_t);
+void *realloc(void *, size_t);
+
+void *wmemcpy(void *, const void *, size_t);
+errno_t wmemcpy_s(void *, size_t, const void *, size_t);
+void *wmemchr(const void *, int, size_t);
+void *wmemmove(void *, const void *, size_t);
+errno_t wmemmove_s(void *, size_t, const void *, size_t);
+void *wmemset(void *, int, size_t);
+
+int wcsncmp(const wchar_t *, const wchar_t *, size_t);
+size_t wcsxfrm(wchar_t *, const wchar_t *, size_t);
+
+
+void bad_alloca(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)alloca(wcslen(src));
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: memory allocated by 'alloca' is insufficient to hold the null terminator [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: alloca(wcslen(src) + 1);
+}
+
+void good_alloca(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)alloca(wcslen(src) + 1);
+}
+
+void bad_calloc(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)calloc(wcslen(src), sizeof(wchar_t));
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: memory allocated by 'calloc' is insufficient to hold the null terminator [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: calloc((wcslen(src) + 1), sizeof(wchar_t));
+}
+
+void good_calloc(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)calloc((wcslen(src) + 1), sizeof(wchar_t));
+}
+
+void bad_malloc(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)malloc(wcslen(src) * 2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: memory allocated by 'malloc' is insufficient to hold the null terminator [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: malloc((wcslen(src) * 2) + 1);
+}
+
+void good_malloc(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)malloc((wcslen(src) * 2) + 1);
+}
+
+void bad_realloc(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)realloc(dest, (wcslen(dest) + wcslen(src)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: memory allocated by 'realloc' is insufficient to hold the null terminator [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: realloc(dest, (wcslen(dest) + (wcslen(src) + 1)));
+}
+
+void good_realloc(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)realloc(dest, (wcslen(dest) + (wcslen(src) + 1)));
+}
+
+void bad_wmemcpy(wchar_t *dest, const wchar_t *src) {
+  wmemcpy(dest, src, wcslen(src));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'wmemcpy' is not null-terminated [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: wcsncpy_s(dest, src, wcslen(src));
+}
+
+void good_wmemcpy_safe(wchar_t *dest, const wchar_t *src) {
+  wcsncpy_s(dest, src, wcslen(src));
+}
+
+void bad_wmemcpy_s(wchar_t *dest, const wchar_t *src) {
+  wmemcpy_s(dest, wcslen(dest), src, wcslen(src));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'wmemcpy_s' is not null-terminated [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: wcsn

[PATCH] D47537: [clang-rename] Move clang-rename documentation to Clang repository

2018-05-30 Thread Kirill Bobyrev via Phabricator via cfe-commits
omtcyfz created this revision.
omtcyfz added reviewers: ioeric, klimek, arphaman.
omtcyfz added projects: clang, clang-tools-extra.

clang-rename was moved to the Clang repository in r306840, but documentation 
was left behind, which might be confusing. The Doxygen configuration file in 
clang-tools-extra also referenced non-existent clang-rename directory.

This patch completes the clang-rename migration and cleans up Doxygen config in 
clang-tools-extra repository.


https://reviews.llvm.org/D47537

Files:
  clang-tools-extra/docs/clang-rename.rst
  clang-tools-extra/docs/doxygen.cfg.in
  clang-tools-extra/docs/index.rst
  clang/docs/ClangRename.rst
  clang/docs/index.rst


Index: clang/docs/index.rst
===
--- clang/docs/index.rst
+++ clang/docs/index.rst
@@ -74,6 +74,7 @@
ClangCheck
ClangFormat
ClangFormatStyleOptions
+   ClangRename
 
 Design Documents
 
Index: clang/docs/ClangRename.rst
===
--- clang/docs/ClangRename.rst
+++ clang/docs/ClangRename.rst
@@ -1,5 +1,5 @@
 
-Clang-Rename
+ClangRename
 
 
 .. contents::
Index: clang-tools-extra/docs/index.rst
===
--- clang-tools-extra/docs/index.rst
+++ clang-tools-extra/docs/index.rst
@@ -24,7 +24,6 @@
include-fixer
modularize
pp-trace
-   clang-rename
clangd
clang-doc
 
Index: clang-tools-extra/docs/doxygen.cfg.in
===
--- clang-tools-extra/docs/doxygen.cfg.in
+++ clang-tools-extra/docs/doxygen.cfg.in
@@ -747,7 +747,6 @@
  @abs_srcdir@/../clang-tidy \
  @abs_srcdir@/../clang-apply-replacements \
  @abs_srcdir@/../clang-query \
- @abs_srcdir@/../clang-rename \
  @abs_srcdir@/../modularize \
  @abs_srcdir@/../pp-trace \
  @abs_srcdir@/../tool-template \


Index: clang/docs/index.rst
===
--- clang/docs/index.rst
+++ clang/docs/index.rst
@@ -74,6 +74,7 @@
ClangCheck
ClangFormat
ClangFormatStyleOptions
+   ClangRename
 
 Design Documents
 
Index: clang/docs/ClangRename.rst
===
--- clang/docs/ClangRename.rst
+++ clang/docs/ClangRename.rst
@@ -1,5 +1,5 @@
 
-Clang-Rename
+ClangRename
 
 
 .. contents::
Index: clang-tools-extra/docs/index.rst
===
--- clang-tools-extra/docs/index.rst
+++ clang-tools-extra/docs/index.rst
@@ -24,7 +24,6 @@
include-fixer
modularize
pp-trace
-   clang-rename
clangd
clang-doc
 
Index: clang-tools-extra/docs/doxygen.cfg.in
===
--- clang-tools-extra/docs/doxygen.cfg.in
+++ clang-tools-extra/docs/doxygen.cfg.in
@@ -747,7 +747,6 @@
  @abs_srcdir@/../clang-tidy \
  @abs_srcdir@/../clang-apply-replacements \
  @abs_srcdir@/../clang-query \
- @abs_srcdir@/../clang-rename \
  @abs_srcdir@/../modularize \
  @abs_srcdir@/../pp-trace \
  @abs_srcdir@/../tool-template \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47095: [clang-format/ObjC] Correctly parse Objective-C methods with 'class' in name

2018-05-30 Thread Ben Hamilton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC333553: [clang-format/ObjC] Correctly parse Objective-C 
methods with 'class' in name (authored by benhamilton, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47095?vs=148231&id=149124#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47095

Files:
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/UnwrappedLineParser.h
  unittests/Format/FormatTestObjC.cpp

Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -328,7 +328,14 @@
"}\n"
"+ (id)init;\n"
"@end");
-
+  verifyFormat("@interface Foo\n"
+   "- (void)foo {\n"
+   "}\n"
+   "@end\n"
+   "@implementation Bar\n"
+   "- (void)bar {\n"
+   "}\n"
+   "@end");
   Style.ColumnLimit = 40;
   verifyFormat("@interface c () <\n"
"c, c,\n"
@@ -969,6 +976,59 @@
   verifyFormat("MACRO(new:)\n");
   verifyFormat("MACRO(delete:)\n");
   verifyFormat("foo = @{MACRO(new:) : MACRO(delete:)}\n");
+  verifyFormat("@implementation Foo\n"
+   "// Testing\n"
+   "- (Class)class {\n"
+   "}\n"
+   "- (void)foo {\n"
+   "}\n"
+   "@end\n");
+  verifyFormat("@implementation Foo\n"
+   "- (Class)class {\n"
+   "}\n"
+   "- (void)foo {\n"
+   "}\n"
+   "@end");
+  verifyFormat("@implementation Foo\n"
+   "+ (Class)class {\n"
+   "}\n"
+   "- (void)foo {\n"
+   "}\n"
+   "@end");
+  verifyFormat("@implementation Foo\n"
+   "- (Class)class:(Class)klass {\n"
+   "}\n"
+   "- (void)foo {\n"
+   "}\n"
+   "@end");
+  verifyFormat("@implementation Foo\n"
+   "+ (Class)class:(Class)klass {\n"
+   "}\n"
+   "- (void)foo {\n"
+   "}\n"
+   "@end");
+
+  verifyFormat("@interface Foo\n"
+   "// Testing\n"
+   "- (Class)class;\n"
+   "- (void)foo;\n"
+   "@end\n");
+  verifyFormat("@interface Foo\n"
+   "- (Class)class;\n"
+   "- (void)foo;\n"
+   "@end");
+  verifyFormat("@interface Foo\n"
+   "+ (Class)class;\n"
+   "- (void)foo;\n"
+   "@end");
+  verifyFormat("@interface Foo\n"
+   "- (Class)class:(Class)klass;\n"
+   "- (void)foo;\n"
+   "@end");
+  verifyFormat("@interface Foo\n"
+   "+ (Class)class:(Class)klass;\n"
+   "- (void)foo;\n"
+   "@end");
 }
 
 TEST_F(FormatTestObjC, ObjCLiterals) {
Index: lib/Format/UnwrappedLineParser.h
===
--- lib/Format/UnwrappedLineParser.h
+++ lib/Format/UnwrappedLineParser.h
@@ -120,6 +120,7 @@
   // parses the record as a child block, i.e. if the class declaration is an
   // expression.
   void parseRecord(bool ParseAsExpr = false);
+  void parseObjCMethod();
   void parseObjCProtocolList();
   void parseObjCUntilAtEnd();
   void parseObjCInterfaceOrImplementation();
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -2130,6 +2130,24 @@
   // "} n, m;" will end up in one unwrapped line.
 }
 
+void UnwrappedLineParser::parseObjCMethod() {
+  assert(FormatTok->Tok.isOneOf(tok::l_paren, tok::identifier) &&
+ "'(' or identifier expected.");
+  do {
+if (FormatTok->Tok.is(tok::semi)) {
+  nextToken();
+  addUnwrappedLine();
+  return;
+} else if (FormatTok->Tok.is(tok::l_brace)) {
+  parseBlock(/*MustBeDeclaration=*/false);
+  addUnwrappedLine();
+  return;
+} else {
+  nextToken();
+}
+  } while (!eof());
+}
+
 void UnwrappedLineParser::parseObjCProtocolList() {
   assert(FormatTok->Tok.is(tok::less) && "'<' expected.");
   do {
@@ -2157,6 +2175,9 @@
   // Ignore stray "}". parseStructuralElement doesn't consume them.
   nextToken();
   addUnwrappedLine();
+} else if (FormatTok->isOneOf(tok::minus, tok::plus)) {
+  nextToken();
+  parseObjCMethod();
 } else {
   parseStructuralElement();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r333553 - [clang-format/ObjC] Correctly parse Objective-C methods with 'class' in name

2018-05-30 Thread Ben Hamilton via cfe-commits
Author: benhamilton
Date: Wed May 30 08:21:38 2018
New Revision: 333553

URL: http://llvm.org/viewvc/llvm-project?rev=333553&view=rev
Log:
[clang-format/ObjC] Correctly parse Objective-C methods with 'class' in name

Summary:
Please take a close look at this CL. I haven't touched much of
`UnwrappedLineParser` before, so I may have gotten things wrong.

Previously, clang-format would incorrectly format the following:

```
@implementation Foo

- (Class)class {
}

- (void)foo {
}

@end
```

as:

```
@implementation Foo

- (Class)class {
}

- (void)foo {
}

@end
```

The problem is whenever `UnwrappedLineParser::parseStructuralElement()`
sees any of the keywords `class`, `struct`, or `enum`, it calls
`parseRecord()` to parse them as a C/C++ record.

This causes subsequent lines to be parsed incorrectly, which
causes them to be indented incorrectly.

In Objective-C/Objective-C++, these keywords are valid selector
components.

This diff fixes the issue by explicitly handling `+` and `-` lines
inside `@implementation` / `@interface` / `@protocol` blocks
and parsing them as Objective-C methods.

Test Plan: New tests added. Ran tests with:
  make -j16 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: jolesiak, klimek

Reviewed By: jolesiak, klimek

Subscribers: klimek, cfe-commits, Wizard

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

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.h
cfe/trunk/unittests/Format/FormatTestObjC.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=333553&r1=333552&r2=333553&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Wed May 30 08:21:38 2018
@@ -2130,6 +2130,24 @@ void UnwrappedLineParser::parseRecord(bo
   // "} n, m;" will end up in one unwrapped line.
 }
 
+void UnwrappedLineParser::parseObjCMethod() {
+  assert(FormatTok->Tok.isOneOf(tok::l_paren, tok::identifier) &&
+ "'(' or identifier expected.");
+  do {
+if (FormatTok->Tok.is(tok::semi)) {
+  nextToken();
+  addUnwrappedLine();
+  return;
+} else if (FormatTok->Tok.is(tok::l_brace)) {
+  parseBlock(/*MustBeDeclaration=*/false);
+  addUnwrappedLine();
+  return;
+} else {
+  nextToken();
+}
+  } while (!eof());
+}
+
 void UnwrappedLineParser::parseObjCProtocolList() {
   assert(FormatTok->Tok.is(tok::less) && "'<' expected.");
   do {
@@ -2157,6 +2175,9 @@ void UnwrappedLineParser::parseObjCUntil
   // Ignore stray "}". parseStructuralElement doesn't consume them.
   nextToken();
   addUnwrappedLine();
+} else if (FormatTok->isOneOf(tok::minus, tok::plus)) {
+  nextToken();
+  parseObjCMethod();
 } else {
   parseStructuralElement();
 }

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.h?rev=333553&r1=333552&r2=333553&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.h (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.h Wed May 30 08:21:38 2018
@@ -120,6 +120,7 @@ private:
   // parses the record as a child block, i.e. if the class declaration is an
   // expression.
   void parseRecord(bool ParseAsExpr = false);
+  void parseObjCMethod();
   void parseObjCProtocolList();
   void parseObjCUntilAtEnd();
   void parseObjCInterfaceOrImplementation();

Modified: cfe/trunk/unittests/Format/FormatTestObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestObjC.cpp?rev=333553&r1=333552&r2=333553&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp Wed May 30 08:21:38 2018
@@ -328,7 +328,14 @@ TEST_F(FormatTestObjC, FormatObjCInterfa
"}\n"
"+ (id)init;\n"
"@end");
-
+  verifyFormat("@interface Foo\n"
+   "- (void)foo {\n"
+   "}\n"
+   "@end\n"
+   "@implementation Bar\n"
+   "- (void)bar {\n"
+   "}\n"
+   "@end");
   Style.ColumnLimit = 40;
   verifyFormat("@interface c () <\n"
"c, c,\n"
@@ -969,6 +976,59 @@ TEST_F(FormatTestObjC, ObjCCxxKeywords)
   verifyFormat("MACRO(new:)\n");
   verifyFormat("MACRO(delete:)\n");
   verifyFormat("foo = @{MACRO(new:) : MACRO(delete:)}\n");
+  verifyFormat("@implementation Foo\n"
+   "// Testing\n"
+   "- (Class)class {\n"
+   "}\n"
+   "- (void)foo {\n"
+   "}\n"
+   

[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen

2018-05-30 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Thanks! Happy to see it is more powerful now :)


https://reviews.llvm.org/D45050



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


[PATCH] D44480: [Sema] Don't skip function bodies with 'auto' without trailing return type

2018-05-30 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

I've stumbled about this bug too and was looking into it and then I saw the 
mail about this change being submitted :)

I've ended up with a slightly different change (https://dpaste.de/PSpM/raw , 
instead of FD->getReturnType()->getContainedDeducedType() I have 
FD->getReturnType()->getAs()). It looks like the tests from this 
change pass with my change and my tests pass with this change (consider to add 
decltype(auto) tests, too!). So I'm wondering whether there is a test case that 
fails for one change but not the other (if there is, the test case should 
probably be added), or if there are differences in the performance.

I'm not familiar enough with the code base to justify the getAs(), 
I've just observed that it made my tests pass.


Repository:
  rL LLVM

https://reviews.llvm.org/D44480



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


[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen

2018-05-30 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 149129.
Charusso added a comment.

Clang format.


https://reviews.llvm.org/D45050

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
  clang-tidy/bugprone/NotNullTerminatedResultCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-not-null-terminated-result-in-initialization.c
  test/clang-tidy/bugprone-not-null-terminated-result-strlen-before-safe.c
  test/clang-tidy/bugprone-not-null-terminated-result-strlen-safe.c
  test/clang-tidy/bugprone-not-null-terminated-result-wcslen-before-safe.c
  test/clang-tidy/bugprone-not-null-terminated-result-wcslen-safe.c

Index: test/clang-tidy/bugprone-not-null-terminated-result-wcslen-safe.c
===
--- /dev/null
+++ test/clang-tidy/bugprone-not-null-terminated-result-wcslen-safe.c
@@ -0,0 +1,150 @@
+// RUN: %check_clang_tidy %s bugprone-not-null-terminated-result %t -- \
+// RUN: -- -std=c11
+
+typedef unsigned int size_t;
+typedef unsigned int wchar_t;
+typedef int errno_t;
+size_t wcslen(const wchar_t *);
+wchar_t *wcschr(const wchar_t *, int);
+errno_t *wcsncpy_s(wchar_t *, const wchar_t *, size_t);
+
+void *alloca(size_t);
+void *calloc(size_t, size_t);
+void *malloc(size_t);
+void *realloc(void *, size_t);
+
+void *wmemcpy(void *, const void *, size_t);
+errno_t wmemcpy_s(void *, size_t, const void *, size_t);
+void *wmemchr(const void *, int, size_t);
+void *wmemmove(void *, const void *, size_t);
+errno_t wmemmove_s(void *, size_t, const void *, size_t);
+void *wmemset(void *, int, size_t);
+
+int wcsncmp(const wchar_t *, const wchar_t *, size_t);
+size_t wcsxfrm(wchar_t *, const wchar_t *, size_t);
+
+
+void bad_alloca(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)alloca(wcslen(src));
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: memory allocated by 'alloca' is insufficient to hold the null terminator [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: alloca(wcslen(src) + 1);
+}
+
+void good_alloca(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)alloca(wcslen(src) + 1);
+}
+
+void bad_calloc(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)calloc(wcslen(src), sizeof(wchar_t));
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: memory allocated by 'calloc' is insufficient to hold the null terminator [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: calloc((wcslen(src) + 1), sizeof(wchar_t));
+}
+
+void good_calloc(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)calloc((wcslen(src) + 1), sizeof(wchar_t));
+}
+
+void bad_malloc(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)malloc(wcslen(src) * 2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: memory allocated by 'malloc' is insufficient to hold the null terminator [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: malloc((wcslen(src) * 2) + 1);
+}
+
+void good_malloc(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)malloc((wcslen(src) * 2) + 1);
+}
+
+void bad_realloc(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)realloc(dest, (wcslen(dest) + wcslen(src)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: memory allocated by 'realloc' is insufficient to hold the null terminator [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: realloc(dest, (wcslen(dest) + (wcslen(src) + 1)));
+}
+
+void good_realloc(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)realloc(dest, (wcslen(dest) + (wcslen(src) + 1)));
+}
+
+void bad_wmemcpy(wchar_t *dest, const wchar_t *src) {
+  wmemcpy(dest, src, wcslen(src));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'wmemcpy' is not null-terminated [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: wcsncpy_s(dest, src, wcslen(src));
+}
+
+void good_wmemcpy_safe(wchar_t *dest, const wchar_t *src) {
+  wcsncpy_s(dest, src, wcslen(src));
+}
+
+void bad_wmemcpy_s(wchar_t *dest, const wchar_t *src) {
+  wmemcpy_s(dest, wcslen(dest), src, wcslen(src));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'wmemcpy_s' is not null-terminated [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: wcsncpy_s(dest, src, wcslen(src));
+}
+
+void good_wmemcpy_s(wchar_t *dest, const wchar_t *src) {
+  wcsncpy_s(dest, src, wcslen(src));
+}
+
+void bad_wmemchr(wchar_t *dest, const wchar_t *src) {
+  dest = (wchar_t *)wmemchr(src, '\0', wcslen(src));
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: the result from calling 'wmemchr' is not null-terminated [bugprone-not-null-terminated-result]
+  // CHECK-FIXES: wcschr(src, '\0');
+}
+
+void good_wmemchr(wchar_t *dest, const wchar_t *src) {
+  dest = wcschr(src, '\0');
+}
+
+void bad_wmemmove(wchar_t *dest, const wchar_t *src) {
+  wmemmove(dest, src, wcslen(src));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 

[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen

2018-05-30 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

memcpy(crypt_buf, passwd, passwd_len); <--- warning
memcpy(crypt_buf + passwd_len, salt, salt_len);

This is a false warning since it appends strings using memcpy. But no idea what 
to do and if it is possible to avoid these false warnings.


https://reviews.llvm.org/D45050



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


[PATCH] D47121: [NEON] Support VLD1xN intrinsics in AArch32 mode (Clang part)

2018-05-30 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev added a comment.

Ping.


https://reviews.llvm.org/D47121



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


[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen

2018-05-30 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In https://reviews.llvm.org/D45050#1116361, @xbolva00 wrote:

> memcpy(crypt_buf, passwd, passwd_len); <--- warning
>  memcpy(crypt_buf + passwd_len, salt, salt_len);
>
> This is a false warning since it appends strings using memcpy. But no idea 
> what to do and if it is possible to avoid these false warnings.


I have just tested it because of the `malloc()` function. I'm using CodeChecker 
and leaved the default settings, so `IsSafeFunctionsAreAvailable = 1`. Because 
of the malloc `strncpy_s()` cannot handle this case, but if the check would ran 
with `IsSafeFunctionsAreAvailable = 0`, it rewrites it to `strncpy(crypt_buf, 
passwd, passwd_len + 1)` which is a good transformation, as the official 
`memcpy()`'s result not null-terminated.


https://reviews.llvm.org/D45050



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


[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen

2018-05-30 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

In https://reviews.llvm.org/D45050#1116396, @Charusso wrote:

> In https://reviews.llvm.org/D45050#1116361, @xbolva00 wrote:
>
> > memcpy(crypt_buf, passwd, passwd_len); <--- warning
> >  memcpy(crypt_buf + passwd_len, salt, salt_len);
> >
> > This is a false warning since it appends strings using memcpy. But no idea 
> > what to do and if it is possible to avoid these false warnings.
>
>
> I have just tested it because of the `malloc()` function. I'm using 
> CodeChecker and leaved the default settings, so `IsSafeFunctionsAreAvailable 
> = 1`. Because of the malloc `strncpy_s()` cannot handle this case, but if the 
> check would ran with `IsSafeFunctionsAreAvailable = 0`, it rewrites it to 
> `strncpy(crypt_buf, passwd, passwd_len + 1)` which is a good transformation, 
> as the official `memcpy()`'s result not null-terminated.


Yeah, it is a valid recommendation.


https://reviews.llvm.org/D45050



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


[PATCH] D47121: [NEON] Support VLD1xN intrinsics in AArch32 mode (Clang part)

2018-05-30 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

Had only a first brief look; see some first drive by comments inline.




Comment at: lib/CodeGen/CGBuiltin.cpp:7865
   }
 // FIXME: Sharing loads & stores with 32-bit is complicated by the absence
 // of an Align parameter here.

How about this FIXME? Is it still relevant? And does it need to be moved up? Or 
perhaps better: move the code back here to minimise the diff?



Comment at: test/CodeGen/arm-neon-vld.c:4
+// RUN: FileCheck -check-prefixes=CHECK,CHECK-A64 %s
+// RUN: %clang_cc1 -triple armv8-none-linux-gnueabi -target-feature +neon \
+// RUN: -S -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | \

Should this be armv7?


https://reviews.llvm.org/D47121



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


[PATCH] D44480: [Sema] Don't skip function bodies with 'auto' without trailing return type

2018-05-30 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D44480#1116359, @nik wrote:

> I've stumbled about this bug too and was looking into it and then I saw the 
> mail about this change being submitted :)
>
> I've ended up with a slightly different change (https://dpaste.de/PSpM/raw , 
> instead of FD->getReturnType()->getContainedDeducedType() I have 
> FD->getReturnType()->getAs()). It looks like the tests from this 
> change pass with my change and my tests pass with this change (consider to 
> add decltype(auto) tests, too!). So I'm wondering whether there is a test 
> case that fails for one change but not the other (if there is, the test case 
> should probably be added), or if there are differences in the performance.
>
> I'm not familiar enough with the code base to justify the getAs(), 
> I've just observed that it made my tests pass.


I'm sure there should be no significant differences in performance. Adding 
`decltype(auto)`  to the test would certainly be useful.
W.r.t. correctness I think at this point checks for DeducedType and AutoType 
are equivalent. There is only one other inheritor of DeducedType, the 
DeducedTemplateSpecializationType, and it should not appear in the function 
return type IIUC.

When the concepts get into the standard and clangd implements them, this might 
change, as the comment of `DeducedType` suggests:

  /// Common base class for placeholders for types that get replaced by
  /// placeholder type deduction: C++11 auto, C++14 decltype(auto), C++17 
deduced
  /// class template types, and (eventually) constrained type names from the C++
  /// Concepts TS.

I don't know the exact details of the latest Concepts proposal, but would 
assume usages of constrained template parameters from Concepts TS shouldn't 
block skipping of function bodies. In which case, your fix seems to do the 
right thing and this one doesn't.
@rsmith, WDYT? Should we check for AutoType instead?


Repository:
  rL LLVM

https://reviews.llvm.org/D44480



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


[PATCH] D47537: [clang-tools-extra] Cleanup documentation routine

2018-05-30 Thread Kirill Bobyrev via Phabricator via cfe-commits
omtcyfz updated this revision to Diff 149138.
omtcyfz retitled this revision from "[clang-rename] Move clang-rename 
documentation to Clang repository" to "[clang-tools-extra] Cleanup 
documentation routine".
omtcyfz edited the summary of this revision.
omtcyfz added a comment.
Herald added a subscriber: ilya-biryukov.

I also noticed that some directories in clang-tools-extra are not present in 
Doxygen configuration file and hence these directories are not processed. I 
removed irrelevant Doxygen configuration file (which seems to be abandoned and 
unused) and updated the input list.


https://reviews.llvm.org/D47537

Files:
  clang-tools-extra/docs/Doxyfile
  clang-tools-extra/docs/clang-rename.rst
  clang-tools-extra/docs/doxygen.cfg.in
  clang-tools-extra/docs/index.rst
  clang/docs/ClangRename.rst
  clang/docs/index.rst

Index: clang/docs/index.rst
===
--- clang/docs/index.rst
+++ clang/docs/index.rst
@@ -74,6 +74,7 @@
ClangCheck
ClangFormat
ClangFormatStyleOptions
+   ClangRename
 
 Design Documents
 
Index: clang/docs/ClangRename.rst
===
--- clang/docs/ClangRename.rst
+++ clang/docs/ClangRename.rst
@@ -1,5 +1,5 @@
 
-Clang-Rename
+ClangRename
 
 
 .. contents::
Index: clang-tools-extra/docs/index.rst
===
--- clang-tools-extra/docs/index.rst
+++ clang-tools-extra/docs/index.rst
@@ -24,7 +24,6 @@
include-fixer
modularize
pp-trace
-   clang-rename
clangd
clang-doc
 
Index: clang-tools-extra/docs/doxygen.cfg.in
===
--- clang-tools-extra/docs/doxygen.cfg.in
+++ clang-tools-extra/docs/doxygen.cfg.in
@@ -743,15 +743,20 @@
 # spaces.
 # Note: If this tag is empty the current directory is searched.
 
-INPUT  = \
- @abs_srcdir@/../clang-tidy \
- @abs_srcdir@/../clang-apply-replacements \
- @abs_srcdir@/../clang-query \
- @abs_srcdir@/../clang-rename \
- @abs_srcdir@/../modularize \
- @abs_srcdir@/../pp-trace \
- @abs_srcdir@/../tool-template \
- @abs_srcdir@/doxygen-mainpage.dox
+INPUT  =  \
+  @abs_srcdir@/../change-namespace \
+  @abs_srcdir@/../clang-apply-replacements \
+  @abs_srcdir@/../clang-doc \
+  @abs_srcdir@/../clang-move \
+  @abs_srcdir@/../clang-query \
+  @abs_srcdir@/../clang-reorder-fields \
+  @abs_srcdir@/../clang-tidy \
+  @abs_srcdir@/../clangd \
+  @abs_srcdir@/../include-fixer \
+  @abs_srcdir@/../modularize \
+  @abs_srcdir@/../pp-trace \
+  @abs_srcdir@/../tool-template \
+  @abs_srcdir@/doxygen-mainpage.dox
 
 # This tag can be used to specify the character encoding of the source files
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Index: clang-tools-extra/docs/Doxyfile
===
--- clang-tools-extra/docs/Doxyfile
+++ /dev/null
@@ -1,1808 +0,0 @@
-# Doxyfile 1.7.6.1
-
-# This file describes the settings to be used by the documentation system
-# doxygen (www.doxygen.org) for a project
-#
-# All text after a hash (#) is considered a comment and will be ignored
-# The format is:
-#   TAG = value [value, ...]
-# For lists items can also be appended using:
-#   TAG += value [value, ...]
-# Values that contain spaces should be placed between quotes (" ")
-
-#---
-# Project related configuration options
-#---
-
-# This tag specifies the encoding used for all characters in the config file
-# that follow. The default is UTF-8 which is also the encoding used for all
-# text before the first occurrence of this tag. Doxygen uses libiconv (or the
-# iconv built into libc) for the transcoding. See
-# http://www.gnu.org/software/libiconv for the list of possible encodings.
-
-DOXYFILE_ENCODING  = UTF-8
-
-# The PROJECT_NAME tag is a single word (or sequence of words) that should
-# identify the project. Note that if you do not use Doxywizard you need
-# to put quotes around the project name if it contains spaces.
-
-PROJECT_NAME   = clang-tools-extra
-
-# The PROJECT_NUMBER tag can be used to enter a project or revision number.
-# This could be handy for archiving the generated documentation or
-#

[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen

2018-05-30 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

I would like to see more negative tests.
What does it do if the len/size is a constant?
Variable that wasn't just assigned with `strlen()` return?


https://reviews.llvm.org/D45050



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


[PATCH] D47474: Implement cpu_dispatch/cpu_specific Multiversioning

2018-05-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 149145.
erichkeane marked 11 inline comments as done.
erichkeane added a comment.

Fix based on @craig.topper and @aaron.ballman s comments.


https://reviews.llvm.org/D47474

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/X86Target.def
  lib/AST/Decl.cpp
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Parse/ParseDecl.cpp
  lib/Sema/AnalysisBasedWarnings.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOverload.cpp
  test/CodeGen/attr-cpuspecific.c
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/Sema/attr-cpuspecific.c
  test/SemaCXX/attr-cpuspecific.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -1173,6 +1173,13 @@
 }
   };
 
+  class VariadicIdentifierArgument : public VariadicArgument {
+  public:
+VariadicIdentifierArgument(const Record &Arg, StringRef Attr)
+  : VariadicArgument(Arg, Attr, "IdentifierInfo *")
+{}
+  };
+
   class VariadicStringArgument : public VariadicArgument {
   public:
 VariadicStringArgument(const Record &Arg, StringRef Attr)
@@ -1278,6 +1285,8 @@
 Ptr = llvm::make_unique(Arg, Attr);
   else if (ArgName == "ParamIdxArgument")
 Ptr = llvm::make_unique(Arg, Attr, "ParamIdx");
+  else if (ArgName == "VariadicIdentifierArgument")
+Ptr = llvm::make_unique(Arg, Attr);
   else if (ArgName == "VersionArgument")
 Ptr = llvm::make_unique(Arg, Attr);
 
@@ -2106,6 +2115,34 @@
 .Default(false);
 }
 
+static bool isVariadicIdentifierArgument(Record *Arg) {
+  return !Arg->getSuperClasses().empty() &&
+ llvm::StringSwitch(
+ Arg->getSuperClasses().back().first->getName())
+ .Case("VariadicIdentifierArgument", true)
+ .Default(false);
+}
+
+static void emitClangAttrVariadicIdentifierArgList(RecordKeeper &Records,
+   raw_ostream &OS) {
+  OS << "#if defined(CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST)\n";
+  std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
+  for (const auto *A : Attrs) {
+// Determine whether the first argument is a variadic identifier.
+std::vector Args = A->getValueAsListOfDefs("Args");
+if (Args.empty() || !isVariadicIdentifierArgument(Args[0]))
+  continue;
+
+// All these spellings take an identifier argument.
+forEachUniqueSpelling(*A, [&](const FlattenedSpelling &S) {
+  OS << ".Case(\"" << S.name() << "\", "
+ << "true"
+ << ")\n";
+});
+  }
+  OS << "#endif // CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST\n\n";
+}
+
 // Emits the first-argument-is-identifier property for attributes.
 static void emitClangAttrIdentifierArgList(RecordKeeper &Records, raw_ostream &OS) {
   OS << "#if defined(CLANG_ATTR_IDENTIFIER_ARG_LIST)\n";
@@ -3696,6 +3733,7 @@
   emitSourceFileHeader("Parser-related llvm::StringSwitch cases", OS);
   emitClangAttrArgContextList(Records, OS);
   emitClangAttrIdentifierArgList(Records, OS);
+  emitClangAttrVariadicIdentifierArgList(Records, OS);
   emitClangAttrTypeArgList(Records, OS);
   emitClangAttrLateParsedList(Records, OS);
 }
Index: test/SemaCXX/attr-cpuspecific.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-cpuspecific.cpp
@@ -0,0 +1,111 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu  -fsyntax-only -verify -fexceptions -fcxx-exceptions %s -std=c++14
+
+// expected-error@+1{{invalid option 'invalid' for cpu_dispatch}}
+void __attribute__((cpu_dispatch(atom, invalid))) invalid_cpu();
+
+void __attribute__((cpu_specific(atom))) no_default(void);
+void __attribute__((cpu_specific(sandybridge)))  no_default(void);
+
+struct MVReference {
+  int __attribute__((cpu_specific(sandybridge))) bar(void);
+  int __attribute__((cpu_specific(ivybridge))) bar(void);
+  int __attribute__((cpu_specific(sandybridge))) foo(void);
+};
+
+void use1(void){
+  // OK, will fail in the linker, unless another TU provides the cpu_dispatch.
+  no_default();
+
+  // expected-error@+1 {{call to non-static member function without an object argument}}
+  +MVReference::bar;
+  // expected-error@+1 {{call to non-static member function without an object argument}}
+  +MVReference::foo;
+  // expected-error@+1 {{reference to multiversioned function could not be resolved; did you mean to call it?}}
+  &MVReference::bar;
+  // expected-error@+1 {{reference to multiversioned 

[PATCH] D47474: Implement cpu_dispatch/cpu_specific Multiversioning

2018-05-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Responding to comments :)




Comment at: include/clang/Basic/Attr.td:850
+def CpuSpecific : InheritableAttr {
+  let Spellings = [GCC<"cpu_specific">];
+  let Args = [VariadicIdentifierArgument<"Cpus">];

aaron.ballman wrote:
> Does GCC really support this spelling? I couldn't find documentation to 
> suggest it, and a quick test suggests it's not supported there. Perhaps this 
> should use the Clang spelling instead?
Yep, you're right.  I'd forgotten about that differentiation here.  Thanks!



Comment at: include/clang/Basic/Attr.td:851
+  let Spellings = [GCC<"cpu_specific">];
+  let Args = [VariadicIdentifierArgument<"Cpus">];
+  let Subjects = SubjectList<[Function]>;

aaron.ballman wrote:
> Be sure to add a test for using this attribute with the C++ spelling, as I'm 
> not certain how well we would parse something like 
> `[[gnu::cpu_specific(ivybridge)]]` currently (it may just work, however).
> 
> Also, why an identifier instead of a string literal?
I'll add it, presumably as 'clang::cpu_specific'.  The decision for 
string-literal vs identifier was made quite a few years before I was here 
sadly.  I believe the EDG FE doesn't make identifiers any more difficult so the 
implementer here chose to make it that way.

In this case, I'd very much like to keep it with the same implementation as 
ICC, simply because users of this are already familiar with it in this form.



Comment at: include/clang/Basic/AttrDocs.td:225-226
+as a parameter (like ``cpu_specific``). However, ``cpu_dispatch`` functions
+may not have a body in its definition. An empty definition is permissible for
+ICC compatibility, and all other definitions will have their body ignored.
+

aaron.ballman wrote:
> How empty is empty? e.g., is it lexically empty (no tokens whatsoever) or 
> notionally empty (empty after preprocessing)?
> ```
> __attribute__((cpu_dispatch(atom))) void multi_cpu_1(void) {
>   /* Is this empty enough? */
> }
> 
> __attribute__((cpu_dispatch(atom))) void multi_cpu_2(void) {
>   #if 0
> #error How about this?
>   #endif
> }
> ```
Well, ANY are permissible (even non-empty bodies...) since I issue a warning if 
I detect that it is not empty.  I detect it at the AST level, so anything that 
doesn't add to the AST isn't counted against 'empty'.  In this case, those two 
are both empty.

Do you have a suggestion on how I can word this more clearly?


https://reviews.llvm.org/D47474



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


[PATCH] D37035: Implement __builtin_LINE() et. al. to support source location capture.

2018-05-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF marked 5 inline comments as done.
EricWF added a comment.

In https://reviews.llvm.org/D37035#1116102, @kunitoki wrote:

> Any news on the status of this ? Would be really nice to have it in.


I think this patch is ready to go; but there is more work to be done, as a 
separate patch, to support `std::source_location` in a better manner as 
suggested by @rsmith in the inline comments.




Comment at: test/SemaCXX/source_location.cpp:10-35
+struct source_location {
+private:
+  unsigned int __m_line = 0;
+  unsigned int __m_col = 0;
+  const char *__m_file = nullptr;
+  const char *__m_func = nullptr;
+public:

rsmith wrote:
> This seems suboptimal. It would seem better for the compiler to generate a 
> global containing the relevant data and to represent a `source_location` as a 
> pointer to such a value. We should also try to minimize the number of 
> relocations necessary to build a `source_location` object, since such 
> constructions are likely to be extremely common in some codebases. We should 
> also keep in mind that we're likely to want to add fields to 
> `source_location` in future, so designing it in a way that avoids an ABI 
> break for such cases would be preferable.
> 
> How long has GCC supported this?
@rsmith, I agree with your design for `std::source_location`. However, would it 
be acceptable for now to commit this patch as only the builtins, since we need 
those for GCC compatibility anyway?

Then the changes for something like `__builtin_source_location()` can be added 
afterwards?


https://reviews.llvm.org/D37035



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


r333563 - [X86] Remove 'return' from a bunch of intrinsics that return void and use a builtin that returns void.

2018-05-30 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed May 30 10:23:45 2018
New Revision: 333563

URL: http://llvm.org/viewvc/llvm-project?rev=333563&view=rev
Log:
[X86] Remove 'return' from a bunch of intrinsics that return void and use a 
builtin that returns void.

Found by running the intrinsic headers through -pedantic -ansi.

Modified:
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/lib/Headers/emmintrin.h
cfe/trunk/lib/Headers/fxsrintrin.h
cfe/trunk/lib/Headers/ia32intrin.h
cfe/trunk/lib/Headers/immintrin.h
cfe/trunk/lib/Headers/pkuintrin.h
cfe/trunk/lib/Headers/xmmintrin.h
cfe/trunk/lib/Headers/xsaveintrin.h
cfe/trunk/lib/Headers/xsaveoptintrin.h

Modified: cfe/trunk/lib/Headers/avx512vlintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlintrin.h?rev=333563&r1=333562&r2=333563&view=diff
==
--- cfe/trunk/lib/Headers/avx512vlintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlintrin.h Wed May 30 10:23:45 2018
@@ -7432,7 +7432,7 @@ _mm256_maskz_cvtusepi64_epi16 (__mmask8
 static __inline__ void __DEFAULT_FN_ATTRS
 _mm256_mask_cvtusepi64_storeu_epi16 (void * __P, __mmask8 __M, __m256i __A)
 {
-  return __builtin_ia32_pmovusqw256mem_mask ((__v8hi *) __P, (__v4di) __A, 
__M);
+  __builtin_ia32_pmovusqw256mem_mask ((__v8hi *) __P, (__v4di) __A, __M);
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS

Modified: cfe/trunk/lib/Headers/emmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/emmintrin.h?rev=333563&r1=333562&r2=333563&view=diff
==
--- cfe/trunk/lib/Headers/emmintrin.h (original)
+++ cfe/trunk/lib/Headers/emmintrin.h Wed May 30 10:23:45 2018
@@ -1979,7 +1979,7 @@ _mm_store1_pd(double *__dp, __m128d __a)
 static __inline__ void __DEFAULT_FN_ATTRS
 _mm_store_pd1(double *__dp, __m128d __a)
 {
-  return _mm_store1_pd(__dp, __a);
+  _mm_store1_pd(__dp, __a);
 }
 
 /// Stores a 128-bit vector of [2 x double] into an unaligned memory

Modified: cfe/trunk/lib/Headers/fxsrintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/fxsrintrin.h?rev=333563&r1=333562&r2=333563&view=diff
==
--- cfe/trunk/lib/Headers/fxsrintrin.h (original)
+++ cfe/trunk/lib/Headers/fxsrintrin.h Wed May 30 10:23:45 2018
@@ -43,7 +43,7 @@
 static __inline__ void __DEFAULT_FN_ATTRS
 _fxsave(void *__p)
 {
-  return __builtin_ia32_fxsave(__p);
+  __builtin_ia32_fxsave(__p);
 }
 
 /// Restores the XMM, MMX, MXCSR and x87 FPU registers from the 512-byte
@@ -61,7 +61,7 @@ _fxsave(void *__p)
 static __inline__ void __DEFAULT_FN_ATTRS
 _fxrstor(void *__p)
 {
-  return __builtin_ia32_fxrstor(__p);
+  __builtin_ia32_fxrstor(__p);
 }
 
 #ifdef __x86_64__
@@ -78,7 +78,7 @@ _fxrstor(void *__p)
 static __inline__ void __DEFAULT_FN_ATTRS
 _fxsave64(void *__p)
 {
-  return __builtin_ia32_fxsave64(__p);
+  __builtin_ia32_fxsave64(__p);
 }
 
 /// Restores the XMM, MMX, MXCSR and x87 FPU registers from the 512-byte
@@ -96,7 +96,7 @@ _fxsave64(void *__p)
 static __inline__ void __DEFAULT_FN_ATTRS
 _fxrstor64(void *__p)
 {
-  return __builtin_ia32_fxrstor64(__p);
+  __builtin_ia32_fxrstor64(__p);
 }
 #endif
 

Modified: cfe/trunk/lib/Headers/ia32intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/ia32intrin.h?rev=333563&r1=333562&r2=333563&view=diff
==
--- cfe/trunk/lib/Headers/ia32intrin.h (original)
+++ cfe/trunk/lib/Headers/ia32intrin.h Wed May 30 10:23:45 2018
@@ -72,7 +72,7 @@ __rdtscp(unsigned int *__A) {
 
 static __inline__ void __attribute__((__always_inline__, __nodebug__))
 _wbinvd(void) {
-  return __builtin_ia32_wbinvd();
+  __builtin_ia32_wbinvd();
 }
 
 #endif /* __IA32INTRIN_H */

Modified: cfe/trunk/lib/Headers/immintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/immintrin.h?rev=333563&r1=333562&r2=333563&view=diff
==
--- cfe/trunk/lib/Headers/immintrin.h (original)
+++ cfe/trunk/lib/Headers/immintrin.h Wed May 30 10:23:45 2018
@@ -282,25 +282,25 @@ _readgsbase_u64(void)
 static __inline__ void __attribute__((__always_inline__, __nodebug__, 
__target__("fsgsbase")))
 _writefsbase_u32(unsigned int __V)
 {
-  return __builtin_ia32_wrfsbase32(__V);
+  __builtin_ia32_wrfsbase32(__V);
 }
 
 static __inline__ void __attribute__((__always_inline__, __nodebug__, 
__target__("fsgsbase")))
 _writefsbase_u64(unsigned long long __V)
 {
-  return __builtin_ia32_wrfsbase64(__V);
+  __builtin_ia32_wrfsbase64(__V);
 }
 
 static __inline__ void __attribute__((__always_inline__, __nodebug__, 
__target__("fsgsbase")))
 _writegsbase_u32(unsigned int __V)
 {
-  return __builtin_ia32_wrgsbase32(__V);
+  __builtin_ia32_wrgsbase32(__V);
 }
 
 static __inline__ void _

[PATCH] D45517: [analyzer] False positive refutation with Z3

2018-05-30 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added inline comments.



Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:2382
+// Reset the solver
+RefutationMgr.reset();
+  }

xazax.hun wrote:
> george.karpenkov wrote:
> > george.karpenkov wrote:
> > > (apologies in advance for nitpicking not on your code).
> > > 
> > > Currently, this is written in a stateful way: we have a solver, at each 
> > > iteration we add constraints, and at the end we reset it. To me it would 
> > > make considerably more sense to write the code in a functional style: as 
> > > we go, generate a vector of formulas, then once we reach the path end, 
> > > create the solver object, check satisfiability, and then destroy the 
> > > entire solver.
> > Elaborating more: we are already forced to have visitor object state, let's 
> > use that. `RefutationMgr` is essentially a wrapper around a Z3 solver 
> > object, let's just create one when visitor is constructed (directly or in 
> > unique_ptr) and then rely on the destructor to destroy it.
> > Then no `reset` is necessary.
> Note that while constructing the constraint solver here might make perfect 
> sense now, it also inhibits incremental solving.  If we do not plan to 
> experiment with incremental solvers anytime soon I am fine with this 
> direction as well.
@xazax.hun Right, I see.
However, we should not optimize prematurely --- IF we decide to have 
incremental solving, then we would change our design to support it.

Now I don't think incremental solving would help, and I don't think that having 
a global solver object would be helpful for it.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1249
+bool Z3ConstraintManager::isModelFeasible() {
+  return Solver.check() != Z3_L_FALSE;
+}

rnkovacs wrote:
> george.karpenkov wrote:
> > solver can also return "unknown", what happens then?
> If it returns `Z3_L_UNDEF`, e.g. in case of a timeout, this assumes that the 
> state was feasible because we couldn't prove the opposite. In that case the 
> report won't be invalidated.
@rnkovacs that's possibly valid (though the exact behavior might need to be 
behind an option), but the current implementation is wrong and the decision 
should be made at a different stack level.
This method is responsible for "whether the model is valid", and it should not 
say "yes" when the solver returns "unknown". We could return an 
`Optional` here, or a tri-value logic type (IIRC LLVM had one, which 
could represent true/false/unknown)



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1259
+return;
+  ConstraintRangeTy CR = OnlyPurged ? PrevCR : SuccCR;
+

rnkovacs wrote:
> george.karpenkov wrote:
> > TBH I'm really confused here. Why does the method take two constraint 
> > ranges? What's `OnlyPurged`? From reading the code it seems it's set by 
> > seeing whether the program point only purges dead symbols, but at least a 
> > comment should be added as to why this affects behavior.
> The logic was:
>   - add every constraint from the last node (first visited),
>   - for other nodes on the path, only add those that disappear in the next 
> step.
> 
> So `OnlyPurged` is meant to signal that we only want to add those symbols to 
> the solver that are getting purged from the program state.
@rnkovacs right, so that's an optimization not to add extra constraints?

1. I would not do it at all, all formulas in Z3 are hash-consed, so a new 
formula would not even be *constructed* if it's already asserted in the solver.

2. Even if we do do it (which we shouldn't), this logic does not belong to 
Z3ConstraintManager. The method should have simple semantics: take a state, add 
all constraints to solver.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1264
+
+if (OnlyPurged && SuccCR.contains(Sym))
+  continue;

xazax.hun wrote:
> george.karpenkov wrote:
> > I would guess that this is an optimization done in order not to re-add the 
> > constraints we already have.
> > I think we should really not bother doing that, as Z3 will do a much better 
> > job here then we can.
> Note that we are using lots of domain knowledge here like we have the most 
> info about a symbol just before it dies. Also This optimization is a single 
> lookup on the symbol level. I am not sure if Z3 could deal with this on the 
> symbol level. It might need to do this on the constraint level.
> My point is, I am perfectly fine removing this optimization but I would like 
> to see some performance numbers first either on a project that exercises 
> refutation quite a bit or on some synthetic test cases.
> 
> This optimization is a single lookup on the symbol level. I am not sure if Z3 
> could deal with this on the symbol level

What do you mean? I'm positive adding redundant constraints to Z3 would not 
slow solving down.

> I would like to see some performance numbers fi

[PATCH] D46084: [Fixed Point Arithmetic] Addition of the Fixed Point _Accum type

2018-05-30 Thread JF Bastien via Phabricator via cfe-commits
jfb added inline comments.



Comment at: include/clang/Basic/TokenKinds.def:393
+// ISO/IEC JTC1 SC22 WG14 N1169 Extension
+KEYWORD(_Accum  , KEYALL)
+

ebevhan wrote:
> I believe that having KEYALL will enable the keyword even if -fno-fixed-point 
> is given. Is this desired? It will mean that `_Accum` will not be a valid 
> identifier in standard C regardless of the flag.
That seems fine: identifiers starting with underscore and a capital letter 
already aren't valid identifiers in C and C++ because they're reserved for the 
implementation.


Repository:
  rC Clang

https://reviews.llvm.org/D46084



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


[PATCH] D35450: [analyzer] Support generating and reasoning over more symbolic constraint types

2018-05-30 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.
Herald added subscribers: a.sidorin, zzheng, rnkovacs, szepet.
Herald added a reviewer: george.karpenkov.

@ddcc Hi, are you still interested in landing the fixes associated with this 
patch? I can take a look as I'm currently reviewing 
https://reviews.llvm.org/D45517, but it is likely that the patch would need to 
be changed substantially before it could land.


https://reviews.llvm.org/D35450



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


[PATCH] D46084: [Fixed Point Arithmetic] Addition of the Fixed Point _Accum type

2018-05-30 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 149162.

Repository:
  rC Clang

https://reviews.llvm.org/D46084

Files:
  include/clang-c/Index.h
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/TokenKinds.def
  include/clang/Driver/Options.td
  include/clang/Sema/DeclSpec.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/Basic/TargetInfo.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  test/Frontend/fixed_point.c
  test/Frontend/fixed_point_bit_widths.c
  test/Frontend/fixed_point_errors.c
  test/Frontend/fixed_point_errors.cpp
  test/Frontend/fixed_point_not_enabled.c
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -53,6 +53,12 @@
 BTCASE(Float);
 BTCASE(Double);
 BTCASE(LongDouble);
+BTCASE(ShortAccum);
+BTCASE(Accum);
+BTCASE(LongAccum);
+BTCASE(UShortAccum);
+BTCASE(UAccum);
+BTCASE(ULongAccum);
 BTCASE(Float16);
 BTCASE(Float128);
 BTCASE(NullPtr);
@@ -546,6 +552,12 @@
 TKIND(Float);
 TKIND(Double);
 TKIND(LongDouble);
+TKIND(ShortAccum);
+TKIND(Accum);
+TKIND(LongAccum);
+TKIND(UShortAccum);
+TKIND(UAccum);
+TKIND(ULongAccum);
 TKIND(Float16);
 TKIND(Float128);
 TKIND(NullPtr);
Index: test/Frontend/fixed_point_not_enabled.c
===
--- /dev/null
+++ test/Frontend/fixed_point_not_enabled.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -x c -verify %s
+// RUN: %clang_cc1 -x c -fno-fixed-point -verify %s
+
+// Primary fixed point types
+signed short _Accum s_short_accum;// expected-error{{compile with '-ffixed-point' to enable fixed point types}}
+signed _Accum s_accum;// expected-error{{compile with '-ffixed-point' to enable fixed point types}}
+signed long _Accum s_long_accum;  // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
+unsigned short _Accum u_short_accum;  // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
+unsigned _Accum u_accum;  // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
+unsigned long _Accum u_long_accum;// expected-error{{compile with '-ffixed-point' to enable fixed point types}}
+
+// Aliased fixed point types
+short _Accum short_accum; // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
+_Accum accum; // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
+  // expected-warning@-1{{type specifier missing, defaults to 'int'}}
+long _Accum long_accum;   // expected-error{{compile with '-ffixed-point' to enable fixed point types}}
Index: test/Frontend/fixed_point_errors.cpp
===
--- /dev/null
+++ test/Frontend/fixed_point_errors.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -x c++ -ffixed-point %s -verify
+
+// Name namgling is not provided for fixed point types in c++
+
+_Accum accum;   // expected-error{{unknown type name '_Accum'}}
Index: test/Frontend/fixed_point_errors.c
===
--- /dev/null
+++ test/Frontend/fixed_point_errors.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -verify -ffixed-point %s
+
+/* We do not yet support long long. No recommended bit widths are given for this
+ * size. */
+
+long long _Accum longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+unsigned long long _Accum u_longlong_accum;   // expected-error{{'long long _Accum' is invalid}}
+
+/* Although _Complex types work with floating point numbers, the extension
+ * provides no info for complex fixed point types. */
+
+_Complex signed short _Accum cmplx_s_short_accum;   // expected-error{{'_Complex _Accum' is invalid}}
+_Complex signed _Accum cmplx_s_accum;   // expected-error{{'_Complex _Accum' is invalid}}
+_Complex signed long _Accum cmplx_s_long_accum; // expected-error{{'_Complex _Accum' is invalid}}
+_Complex unsigned short _Accum cmplx_u_short_accum; // expected

[PATCH] D46084: [Fixed Point Arithmetic] Addition of the Fixed Point _Accum type

2018-05-30 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: include/clang/Basic/TokenKinds.def:393
+// ISO/IEC JTC1 SC22 WG14 N1169 Extension
+KEYWORD(_Accum  , KEYALL)
+

jfb wrote:
> ebevhan wrote:
> > I believe that having KEYALL will enable the keyword even if 
> > -fno-fixed-point is given. Is this desired? It will mean that `_Accum` will 
> > not be a valid identifier in standard C regardless of the flag.
> That seems fine: identifiers starting with underscore and a capital letter 
> already aren't valid identifiers in C and C++ because they're reserved for 
> the implementation.
I think my test for `-fno-fixed-point` already catches this, but I did not 
notice until now the `KEYNOCXX` keyword until now. Using this instead allows 
for not having to check if the language is c++ since `_Accum` is no longer 
treated as a typename. The corresponding test checking fixed points in c++ has 
been updated to reflect this.


Repository:
  rC Clang

https://reviews.llvm.org/D46084



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


r333568 - [X86] Reduce the number of setzero intrinsics to just the set defined by the Intel Intrinsics Guide.

2018-05-30 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed May 30 11:02:11 2018
New Revision: 333568

URL: http://llvm.org/viewvc/llvm-project?rev=333568&view=rev
Log:
[X86] Reduce the number of setzero intrinsics to just the set defined by the 
Intel Intrinsics Guide.

We had quite a few for different element sizes of integers sometimes with 
strange target features attached to them.

We only need a single version for each of _m128i, _m256i, and _m512i with the 
target feature that first introduced those types.

Modified:
cfe/trunk/lib/Headers/avx512bitalgintrin.h
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/lib/Headers/avx512dqintrin.h
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avx512vbmi2intrin.h
cfe/trunk/lib/Headers/avx512vlbwintrin.h
cfe/trunk/lib/Headers/avx512vlcdintrin.h
cfe/trunk/lib/Headers/avx512vldqintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/lib/Headers/gfniintrin.h
cfe/trunk/lib/Headers/mmintrin.h
cfe/trunk/test/CodeGen/avx512bw-builtins.c
cfe/trunk/test/Headers/x86intrin-2.c

Modified: cfe/trunk/lib/Headers/avx512bitalgintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bitalgintrin.h?rev=333568&r1=333567&r2=333568&view=diff
==
--- cfe/trunk/lib/Headers/avx512bitalgintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bitalgintrin.h Wed May 30 11:02:11 2018
@@ -48,7 +48,7 @@ _mm512_mask_popcnt_epi16(__m512i __A, __
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_maskz_popcnt_epi16(__mmask32 __U, __m512i __B)
 {
-  return _mm512_mask_popcnt_epi16((__m512i) _mm512_setzero_hi(),
+  return _mm512_mask_popcnt_epi16((__m512i) _mm512_setzero_si512(),
   __U,
   __B);
 }
@@ -70,7 +70,7 @@ _mm512_mask_popcnt_epi8(__m512i __A, __m
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_maskz_popcnt_epi8(__mmask64 __U, __m512i __B)
 {
-  return _mm512_mask_popcnt_epi8((__m512i) _mm512_setzero_qi(),
+  return _mm512_mask_popcnt_epi8((__m512i) _mm512_setzero_si512(),
   __U,
   __B);
 }

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=333568&r1=333567&r2=333568&view=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Wed May 30 11:02:11 2018
@@ -34,26 +34,6 @@ typedef unsigned long long __mmask64;
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("avx512bw")))
 
-static  __inline __m512i __DEFAULT_FN_ATTRS
-_mm512_setzero_qi(void) {
-  return (__m512i)(__v64qi){ 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0 };
-}
-
-static  __inline __m512i __DEFAULT_FN_ATTRS
-_mm512_setzero_hi(void) {
-  return (__m512i)(__v32hi){ 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0 };
-}
-
 /* Integer compare */
 
 #define _mm512_cmp_epi8_mask(a, b, p) __extension__ ({ \
@@ -212,7 +192,7 @@ static __inline__ __m512i __DEFAULT_FN_A
 _mm512_maskz_add_epi8(__mmask64 __U, __m512i __A, __m512i __B) {
   return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U,
  (__v64qi)_mm512_add_epi8(__A, 
__B),
- (__v64qi)_mm512_setzero_qi());
+ (__v64qi)_mm512_setzero_si512());
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
@@ -231,7 +211,7 @@ static __inline__ __m512i __DEFAULT_FN_A
 _mm512_maskz_sub_epi8(__mmask64 __U, __m512i __A, __m512i __B) {
   return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U,
  (__v64qi)_mm512_sub_epi8(__A, 
__B),
- (__v64qi)_mm512_setzero_qi());
+ (__v64qi)_mm512_setzero_si512());
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
@@ -250,7 +230,7 @@ static __inline__ __m512i __DEFAULT_FN_A
 _mm512_maskz_add_epi16(__mmask32 __U, __m512i __A, __m512i __B) {
   return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U,
  (__v32hi)_mm512_add_epi16(__A, 
__B),
- (__v32hi)_mm512_setzero_hi());
+ (__v32hi)_mm512_setzer

[PATCH] D46911: [Fixed Point Arithmetic] Addition of the remaining fixed point types and their saturated equivalents

2018-05-30 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 149169.
leonardchan added a comment.

Forgot to include tests for the `_Fract` and `_Sat` keywords in c++ usage


Repository:
  rC Clang

https://reviews.llvm.org/D46911

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/AST/Type.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/Basic/TargetInfo.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  test/Frontend/fixed_point.c
  test/Frontend/fixed_point_bit_widths.c
  test/Frontend/fixed_point_errors.c
  test/Frontend/fixed_point_errors.cpp

Index: test/Frontend/fixed_point_errors.cpp
===
--- test/Frontend/fixed_point_errors.cpp
+++ test/Frontend/fixed_point_errors.cpp
@@ -1,5 +1,9 @@
+// RUN: %clang_cc1 -x c++ %s -verify
 // RUN: %clang_cc1 -x c++ -ffixed-point %s -verify
 
 // Name namgling is not provided for fixed point types in c++
 
 _Accum accum;   // expected-error{{unknown type name '_Accum'}}
+_Fract fract;   // expected-error{{unknown type name '_Fract'}}
+_Sat _Accum sat_accum;  // expected-error{{unknown type name '_Sat'}}
+// expected-error@-1{{expected ';' after top level declarator}}
Index: test/Frontend/fixed_point_errors.c
===
--- test/Frontend/fixed_point_errors.c
+++ test/Frontend/fixed_point_errors.c
@@ -5,6 +5,14 @@
 
 long long _Accum longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
 unsigned long long _Accum u_longlong_accum;   // expected-error{{'long long _Accum' is invalid}}
+long long _Fract longlong_fract;  // expected-error{{'long long _Fract' is invalid}}
+unsigned long long _Fract u_longlong_fract;   // expected-error{{'long long _Fract' is invalid}}
+
+_Sat long long _Accum sat_longlong_accum; // expected-error{{'long long _Accum' is invalid}}
+_Sat unsigned long long _Accum sat_u_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+_Sat long long _Fract sat_longlong_fract; // expected-error{{'long long _Fract' is invalid}}
+_Sat unsigned long long _Fract sat_u_longlong_fract;  // expected-error{{'long long _Fract' is invalid}}
+
 
 /* Although _Complex types work with floating point numbers, the extension
  * provides no info for complex fixed point types. */
@@ -19,9 +27,53 @@
 _Complex _Accum cmplx_s_accum;  // expected-error{{'_Complex _Accum' is invalid}}
 _Complex long _Accum cmplx_s_long_accum;// expected-error{{'_Complex _Accum' is invalid}}
 
+_Complex signed short _Fract cmplx_s_short_fract;   // expected-error{{'_Complex _Fract' is invalid}}
+_Complex signed _Fract cmplx_s_fract;   // expected-error{{'_Complex _Fract' is invalid}}
+_Complex signed long _Fract cmplx_s_long_fract; // expected-error{{'_Complex _Fract' is invalid}}
+_Complex unsigned short _Fract cmplx_u_short_fract; // expected-error{{'_Complex _Fract' is invalid}}
+_Complex unsigned _Fract cmplx_u_fract; // expected-error{{'_Complex _Fract' is invalid}}
+_Complex unsigned long _Fract cmplx_u_long_fract;   // expected-error{{'_Complex _Fract' is invalid}}
+_Complex short _Fract cmplx_s_short_fract;  // expected-error{{'_Complex _Fract' is invalid}}
+_Complex _Fract cmplx_s_fract;  // expected-error{{'_Complex _Fract' is invalid}}
+_Complex long _Fract cmplx_s_long_fract;// expected-error{{'_Complex _Fract' is invalid}}
+
+_Complex _Sat signed short _Accum cmplx_sat_s_short_accum;   // expected-error{{'_Complex _Accum' is invalid}}
+_Complex _Sat signed _Accum cmplx_sat_s_accum;   // expected-error{{'_Complex _Accum' is invalid}}
+_Complex _Sat signed long _Accum cmplx_sat_s_long_accum; // expected-error{{'_Complex _Accum' is invalid}}
+_Complex _Sat unsigned short _Accum cmplx_sat_u_short_accum; // expected-error{{'_Complex _Accum' is invalid}}
+_Complex _Sat unsigned _Accum cmplx_sat_u_accum; // expected-error{{'_Complex _Accum' is invalid}}
+_Complex _Sat unsigned long _Accum cmplx_sat_u_long_accum;   // expected-error{{'_Complex _Accum' is invalid}}
+_Complex _Sat short _Accum cmplx_sat_s_shor

r333572 - [X86] Simplify the implementation of _mm_sqrt_ss, _mm_rcp_ss, and _mm_rsqrt_ss.

2018-05-30 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed May 30 11:27:07 2018
New Revision: 333572

URL: http://llvm.org/viewvc/llvm-project?rev=333572&view=rev
Log:
[X86] Simplify the implementation of _mm_sqrt_ss, _mm_rcp_ss, and _mm_rsqrt_ss.

We don't need the insertion back into the original vector at the end. The 
builtin already understands that.

This is different than _mm_sqrt_sd which takes two arguments and we do need to 
insert.

Modified:
cfe/trunk/lib/Headers/xmmintrin.h
cfe/trunk/test/CodeGen/sse-builtins.c

Modified: cfe/trunk/lib/Headers/xmmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/xmmintrin.h?rev=333572&r1=333571&r2=333572&view=diff
==
--- cfe/trunk/lib/Headers/xmmintrin.h (original)
+++ cfe/trunk/lib/Headers/xmmintrin.h Wed May 30 11:27:07 2018
@@ -224,8 +224,7 @@ _mm_div_ps(__m128 __a, __m128 __b)
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_sqrt_ss(__m128 __a)
 {
-  __m128 __c = __builtin_ia32_sqrtss((__v4sf)__a);
-  return (__m128) { __c[0], __a[1], __a[2], __a[3] };
+  return (__m128)__builtin_ia32_sqrtss((__v4sf)__a);
 }
 
 /// Calculates the square roots of the values stored in a 128-bit vector
@@ -260,8 +259,7 @@ _mm_sqrt_ps(__m128 __a)
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_rcp_ss(__m128 __a)
 {
-  __m128 __c = __builtin_ia32_rcpss((__v4sf)__a);
-  return (__m128) { __c[0], __a[1], __a[2], __a[3] };
+  return (__m128)__builtin_ia32_rcpss((__v4sf)__a);
 }
 
 /// Calculates the approximate reciprocals of the values stored in a
@@ -278,7 +276,7 @@ _mm_rcp_ss(__m128 __a)
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_rcp_ps(__m128 __a)
 {
-  return __builtin_ia32_rcpps((__v4sf)__a);
+  return (__m128)__builtin_ia32_rcpps((__v4sf)__a);
 }
 
 /// Calculates the approximate reciprocal of the square root of the value
@@ -297,8 +295,7 @@ _mm_rcp_ps(__m128 __a)
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_rsqrt_ss(__m128 __a)
 {
-  __m128 __c = __builtin_ia32_rsqrtss((__v4sf)__a);
-  return (__m128) { __c[0], __a[1], __a[2], __a[3] };
+  return __builtin_ia32_rsqrtss((__v4sf)__a);
 }
 
 /// Calculates the approximate reciprocals of the square roots of the

Modified: cfe/trunk/test/CodeGen/sse-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse-builtins.c?rev=333572&r1=333571&r2=333572&view=diff
==
--- cfe/trunk/test/CodeGen/sse-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse-builtins.c Wed May 30 11:27:07 2018
@@ -508,14 +508,6 @@ __m128 test_mm_rcp_ps(__m128 x) {
 __m128 test_mm_rcp_ss(__m128 x) {
   // CHECK-LABEL: test_mm_rcp_ss
   // CHECK: call <4 x float> @llvm.x86.sse.rcp.ss(<4 x float> {{.*}})
-  // CHECK: extractelement <4 x float> {{.*}}, i32 0
-  // CHECK: insertelement <4 x float> undef, float {{.*}}, i32 0
-  // CHECK: extractelement <4 x float> {{.*}}, i32 1
-  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i32 1
-  // CHECK: extractelement <4 x float> {{.*}}, i32 2
-  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i32 2
-  // CHECK: extractelement <4 x float> {{.*}}, i32 3
-  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i32 3
   return _mm_rcp_ss(x);
 }
 
@@ -528,14 +520,6 @@ __m128 test_mm_rsqrt_ps(__m128 x) {
 __m128 test_mm_rsqrt_ss(__m128 x) {
   // CHECK-LABEL: test_mm_rsqrt_ss
   // CHECK: call <4 x float> @llvm.x86.sse.rsqrt.ss(<4 x float> {{.*}})
-  // CHECK: extractelement <4 x float> {{.*}}, i32 0
-  // CHECK: insertelement <4 x float> undef, float {{.*}}, i32 0
-  // CHECK: extractelement <4 x float> {{.*}}, i32 1
-  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i32 1
-  // CHECK: extractelement <4 x float> {{.*}}, i32 2
-  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i32 2
-  // CHECK: extractelement <4 x float> {{.*}}, i32 3
-  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i32 3
   return _mm_rsqrt_ss(x);
 }
 
@@ -662,14 +646,6 @@ __m128 test_mm_sqrt_ps(__m128 x) {
 __m128 test_sqrt_ss(__m128 x) {
   // CHECK: define {{.*}} @test_sqrt_ss
   // CHECK: call <4 x float> @llvm.x86.sse.sqrt.ss
-  // CHECK: extractelement <4 x float> {{.*}}, i32 0
-  // CHECK: insertelement <4 x float> undef, float {{.*}}, i32 0
-  // CHECK: extractelement <4 x float> {{.*}}, i32 1
-  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i32 1
-  // CHECK: extractelement <4 x float> {{.*}}, i32 2
-  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i32 2
-  // CHECK: extractelement <4 x float> {{.*}}, i32 3
-  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i32 3
   return _mm_sqrt_ss(x);
 }
 


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


[PATCH] D47480: clang-cl: Expose -no-canonical-prefixes

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

lgtm




Comment at: test/Driver/cl-options.c:595
+// RUN: -no-canonical-prefixes \
+// RUN: -fno-coverage-mapping \
 // RUN: --version \

takuto.ikuta wrote:
> Is this related to this change?
It's a test for a previous change that I made.


https://reviews.llvm.org/D47480



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


[PATCH] D46664: Fix null MSInheritanceAttr deref in CXXRecordDecl::getMSInheritanceModel()

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

As far as workarounds go, this looks great! Please add a test case, I think you 
had one in the initial patch.

Should I go ahead and commit this?


https://reviews.llvm.org/D46664



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


r333574 - [AST] Fix loss of enum forward decl from decl context

2018-05-30 Thread Joel E. Denny via cfe-commits
Author: jdenny
Date: Wed May 30 11:33:53 2018
New Revision: 333574

URL: http://llvm.org/viewvc/llvm-project?rev=333574&view=rev
Log:
[AST] Fix loss of enum forward decl from decl context

For example, given:

  enum __attribute__((deprecated)) T *p;

-ast-print produced:

  enum T *p;

The attribute was lost because the enum forward decl was lost.

Another example is the loss of enum forward decls from C++ namespaces
(in MS compatibility mode).

The trouble was that the EnumDecl node was suppressed, as revealed by
-ast-dump.  The suppression of the EnumDecl was intentional in
r116122, but I don't understand why.  The suppression isn't needed for
the test suite to behave.

Reviewed by: rsmith

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

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/ast-print.c
cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=333574&r1=333573&r2=333574&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed May 30 11:33:53 2018
@@ -14287,7 +14287,6 @@ CreateNewDecl:
   // PrevDecl.
   TagDecl *New;
 
-  bool IsForwardReference = false;
   if (Kind == TTK_Enum) {
 // FIXME: Tag decls should be chained to any simultaneous vardecls, e.g.:
 // enum X { A, B, C } D;D should chain to X.
@@ -14317,12 +14316,6 @@ CreateNewDecl:
 else if (getLangOpts().CPlusPlus)
   DiagID = diag::err_forward_ref_enum;
 Diag(Loc, DiagID);
-
-// If this is a forward-declared reference to an enumeration, make a
-// note of it; we won't actually be introducing the declaration into
-// the declaration context.
-if (TUK == TUK_Reference)
-  IsForwardReference = true;
   }
 }
 
@@ -14480,9 +14473,7 @@ CreateNewDecl:
 PushOnScopeChains(New, EnclosingScope, /* AddToContext = */ false);
   } else if (Name) {
 S = getNonFieldDeclScope(S);
-PushOnScopeChains(New, S, !IsForwardReference);
-if (IsForwardReference)
-  SearchDC->makeDeclVisibleInContext(New);
+PushOnScopeChains(New, S, true);
   } else {
 CurContext->addDecl(New);
   }

Modified: cfe/trunk/test/Sema/ast-print.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/ast-print.c?rev=333574&r1=333573&r2=333574&view=diff
==
--- cfe/trunk/test/Sema/ast-print.c (original)
+++ cfe/trunk/test/Sema/ast-print.c Wed May 30 11:33:53 2018
@@ -4,6 +4,8 @@
 // RUN: echo >> %t.c "// expected""-warning@* {{use of GNU old-style field 
designator extension}}"
 // RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes' is 
deprecated}}"
 // RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes' has been 
explicitly marked deprecated here}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes2' is 
deprecated}}"
+// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes2' has been 
explicitly marked deprecated here}}"
 // RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes3' is 
deprecated}}"
 // RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes3' has been 
explicitly marked deprecated here}}"
 // RUN: %clang_cc1 -fsyntax-only %t.c -verify
@@ -86,8 +88,7 @@ enum EnumWithAttributes { // expected-wa
   // CHECK-NEXT: } *EnumWithAttributesPtr;
 } __attribute__((deprecated)) *EnumWithAttributesPtr; // expected-note 
{{'EnumWithAttributes' has been explicitly marked deprecated here}}
 
-// FIXME: If enum is forward-declared at file scope, attributes are lost.
-// CHECK-LABEL: enum EnumWithAttributes2 *EnumWithAttributes2Ptr;
+// CHECK-LABEL: enum __attribute__((deprecated(""))) EnumWithAttributes2 
*EnumWithAttributes2Ptr;
 // expected-warning@+2 {{'EnumWithAttributes2' is deprecated}}
 // expected-note@+1 {{'EnumWithAttributes2' has been explicitly marked 
deprecated here}}
 enum __attribute__((deprecated)) EnumWithAttributes2 *EnumWithAttributes2Ptr;

Modified: cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp?rev=333574&r1=333573&r2=333574&view=diff
==
--- cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp Wed May 30 11:33:53 2018
@@ -239,6 +239,15 @@ enum ENUM2 {
ENUM2_c = 0x1 // expected-warning {{enumerator value is not 
representable in the underlying type 'int'}}
 };
 
+namespace NsEnumForwardDecl {
+  enum E *p; // expected-warning {{forward references to 'enum' types are a 
Microsoft extension}}
+  extern E e;
+}
+// Clang used to complain that NsEnumForwardDecl::E was undeclared below.
+NsEnumForwa

  1   2   >