[PATCH] D39611: [CodeGen] make cbrt and fma constant (never set errno); document complex calls as always constant

2017-11-03 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D39611#915799, @efriedma wrote:

> > In general, because all of these functions are well defined over the entire 
> > complex domain, they don't have errors. The "no errors defined" is likely 
> > correct.
>
> One, it is not true that all these functions are well-defined over the entire 
> complex domain.  For example, according to the C standard `catanh(1)` raises 
> a divide-by-zero error.


True. That's why I said that the statement was true in general. There are a few 
exceptions.

> Two, even for the functions which are defined over the entire complex domain, 
> the result can still overflow and/or underflow, and therefore they could set 
> errno to ERANGE.  cabs() can overflow, cexp() can overflow, etc.
> 
> Three, even if we only care about the behavior of the current version of 
> glibc, cabs() actually does modify errno. (Try `cabs(1.7e308+I*1.7e308)`).

As I understand things currently, that's a bug:

In the C specification, 7.12 specifies the requirements for functions in 
math.h. For those functions, 7.12.1 (Treatment of error conditions) says that 
overflows do set ERANGE, and that it's implementation defined if the same is 
true for underflows. That's true for functions in math.h in general. 7.3 
specifies the requirements for functions in complex.h. Here, 7.3.2 says, "An 
implementation may set errno but is not required to." That, as I understand it, 
applies to all functions in complex.h (unless otherwise noted, I presume). 
However, because setting errno is not required by C for functions in complex.h, 
when POSIX says "No errors are defined." that constrains the choice (POSIX is 
constraining the implementation choice allowed by C; this is not a contraction 
with the C specification). As a result, under POSIX, the functions in complex.h 
don't set errno (some, as you've noted, may raise FP exceptions, but that's 
another matter).

Regarding glibc-specific behavior, I do want us to be careful only to model 
this behavior when the target triple has -gnu. Otherwise, we should stick to 
the standard behavior.


https://reviews.llvm.org/D39611



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


[PATCH] D33620: [CodeGenCXX] do not default to dllimport storage for mingw-w64

2017-11-03 Thread Martell Malone via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317398: CodeGenCXX: no default dllimport storage for mingw 
(authored by martell).

Changed prior to commit:
  https://reviews.llvm.org/D33620?vs=100523=121578#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33620

Files:
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/test/CodeGenCXX/runtime-dllstorage.cpp


Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -2284,7 +2284,8 @@
   F->setCallingConv(getRuntimeCC());
 
   if (!Local && getTriple().isOSBinFormatCOFF() &&
-  !getCodeGenOpts().LTOVisibilityPublicStd) {
+  !getCodeGenOpts().LTOVisibilityPublicStd &&
+  !getTriple().isWindowsGNUEnvironment()) {
 const FunctionDecl *FD = GetRuntimeFunctionDecl(Context, Name);
 if (!FD || FD->hasAttr()) {
   F->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
Index: cfe/trunk/test/CodeGenCXX/runtime-dllstorage.cpp
===
--- cfe/trunk/test/CodeGenCXX/runtime-dllstorage.cpp
+++ cfe/trunk/test/CodeGenCXX/runtime-dllstorage.cpp
@@ -12,7 +12,7 @@
 // %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm 
-o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA 
-check-prefix CHECK-DYNAMIC-IA-ATEXIT
 // %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm 
-o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA 
-check-prefix CHECK-STATIC-IA-ATEXIT
 
-// RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck 
%s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA
+// RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck 
%s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
 // RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix 
CHECK-STATIC-IA
 // RUN: %clang_cc1 -triple i686-windows-cygnus -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck 
%s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA
 // RUN: %clang_cc1 -triple i686-windows-cygnus -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix 
CHECK-STATIC-IA


Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -2284,7 +2284,8 @@
   F->setCallingConv(getRuntimeCC());
 
   if (!Local && getTriple().isOSBinFormatCOFF() &&
-  !getCodeGenOpts().LTOVisibilityPublicStd) {
+  !getCodeGenOpts().LTOVisibilityPublicStd &&
+  !getTriple().isWindowsGNUEnvironment()) {
 const FunctionDecl *FD = GetRuntimeFunctionDecl(Context, Name);
 if (!FD || FD->hasAttr()) {
   F->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
Index: cfe/trunk/test/CodeGenCXX/runtime-dllstorage.cpp
===
--- cfe/trunk/test/CodeGenCXX/runtime-dllstorage.cpp
+++ cfe/trunk/test/CodeGenCXX/runtime-dllstorage.cpp
@@ -12,7 +12,7 @@
 // %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA -check-prefix CHECK-DYNAMIC-IA-ATEXIT
 // %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA -check-prefix CHECK-STATIC-IA-ATEXIT
 
-// RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA
+// RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
 // RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std -emit-llvm -o - %s | FileCheck %s 

r317398 - CodeGenCXX: no default dllimport storage for mingw

2017-11-03 Thread Martell Malone via cfe-commits
Author: martell
Date: Fri Nov  3 19:15:49 2017
New Revision: 317398

URL: http://llvm.org/viewvc/llvm-project?rev=317398=rev
Log:
CodeGenCXX: no default dllimport storage for mingw

GNU frontends don't have options like /MT, /MD
This fixes a few link error regressions with libc++ and libc++abi

Reviewers: rnk, mstorsjo, compnerd

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

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCXX/runtime-dllstorage.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=317398=317397=317398=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Nov  3 19:15:49 2017
@@ -2284,7 +2284,8 @@ CodeGenModule::CreateRuntimeFunction(llv
   F->setCallingConv(getRuntimeCC());
 
   if (!Local && getTriple().isOSBinFormatCOFF() &&
-  !getCodeGenOpts().LTOVisibilityPublicStd) {
+  !getCodeGenOpts().LTOVisibilityPublicStd &&
+  !getTriple().isWindowsGNUEnvironment()) {
 const FunctionDecl *FD = GetRuntimeFunctionDecl(Context, Name);
 if (!FD || FD->hasAttr()) {
   F->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);

Modified: cfe/trunk/test/CodeGenCXX/runtime-dllstorage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/runtime-dllstorage.cpp?rev=317398=317397=317398=diff
==
--- cfe/trunk/test/CodeGenCXX/runtime-dllstorage.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/runtime-dllstorage.cpp Fri Nov  3 19:15:49 2017
@@ -12,7 +12,7 @@
 // %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm 
-o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA 
-check-prefix CHECK-DYNAMIC-IA-ATEXIT
 // %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm 
-o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA 
-check-prefix CHECK-STATIC-IA-ATEXIT
 
-// RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck 
%s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA
+// RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck 
%s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
 // RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix 
CHECK-STATIC-IA
 // RUN: %clang_cc1 -triple i686-windows-cygnus -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck 
%s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA
 // RUN: %clang_cc1 -triple i686-windows-cygnus -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix 
CHECK-STATIC-IA


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


r317397 - [Driver] MinGW: Remove custom linker detection

2017-11-03 Thread Martell Malone via cfe-commits
Author: martell
Date: Fri Nov  3 19:07:59 2017
New Revision: 317397

URL: http://llvm.org/viewvc/llvm-project?rev=317397=rev
Log:
[Driver] MinGW: Remove custom linker detection

This is a re-apply of rL313082 which was reverted in rL313088

In rL289668 the ability to specify the default linker at compile time
was added but because the MinGW driver used custom detection we could
not take advantage of this new CMAKE flag CLANG_DEFAULT_LINKER.

rL289668 added no test cases and the mingw driver was either overlooked
or purposefully skipped because it has some custom linker tests
Removing them here because they are covered by the generic case.

Reviewers: rnk

Differntial Revision: https://reviews.llvm.org/D37727

Removed:
cfe/trunk/test/Driver/mingw-useld.c
Modified:
cfe/trunk/lib/Driver/ToolChains/MinGW.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MinGW.cpp?rev=317397=317396=317397=diff
==
--- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp Fri Nov  3 19:07:59 2017
@@ -107,14 +107,6 @@ void tools::MinGW::Linker::ConstructJob(
   // handled somewhere else.
   Args.ClaimAllArgs(options::OPT_w);
 
-  StringRef LinkerName = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "ld");
-  if (LinkerName.equals_lower("lld")) {
-CmdArgs.push_back("-flavor");
-CmdArgs.push_back("gnu");
-  } else if (!LinkerName.equals_lower("ld")) {
-D.Diag(diag::err_drv_unsupported_linker) << LinkerName;
-  }
-
   if (!D.SysRoot.empty())
 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
 
@@ -244,7 +236,7 @@ void tools::MinGW::Linker::ConstructJob(
 
   if (Args.hasArg(options::OPT_static))
 CmdArgs.push_back("--end-group");
-  else if (!LinkerName.equals_lower("lld"))
+  else
 AddLibGCC(Args, CmdArgs);
 }
 
@@ -255,7 +247,7 @@ void tools::MinGW::Linker::ConstructJob(
   CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtend.o")));
 }
   }
-  const char *Exec = Args.MakeArgString(TC.GetProgramPath(LinkerName.data()));
+  const char *Exec = Args.MakeArgString(TC.GetLinkerPath());
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 

Removed: cfe/trunk/test/Driver/mingw-useld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mingw-useld.c?rev=317396=auto
==
--- cfe/trunk/test/Driver/mingw-useld.c (original)
+++ cfe/trunk/test/Driver/mingw-useld.c (removed)
@@ -1,19 +0,0 @@
-// RUN: %clang -### -target i686-pc-windows-gnu 
--sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck 
-check-prefix=CHECK_LD_32 %s
-// CHECK_LD_32: ld{{(.exe)?}}"
-// CHECK_LD_32: "i386pe"
-// CHECK_LD_32-NOT: "-flavor" "gnu"
-
-// RUN: %clang -### -target i686-pc-windows-gnu 
--sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=lld 2>&1 | FileCheck 
-check-prefix=CHECK_LLD_32 %s
-// CHECK_LLD_32-NOT: invalid linker name in argument
-// CHECK_LLD_32: lld{{(.exe)?}}" "-flavor" "gnu"
-// CHECK_LLD_32: "i386pe"
-
-// RUN: %clang -### -target x86_64-pc-windows-gnu 
--sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=lld 2>&1 | FileCheck 
-check-prefix=CHECK_LLD_64 %s
-// CHECK_LLD_64-NOT: invalid linker name in argument
-// CHECK_LLD_64: lld{{(.exe)?}}" "-flavor" "gnu"
-// CHECK_LLD_64: "i386pep"
-
-// RUN: %clang -### -target arm-pc-windows-gnu 
--sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=lld 2>&1 | FileCheck 
-check-prefix=CHECK_LLD_ARM %s
-// CHECK_LLD_ARM-NOT: invalid linker name in argument
-// CHECK_LLD_ARM: lld{{(.exe)?}}" "-flavor" "gnu"
-// CHECK_LLD_ARM: "thumb2pe"


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


[PATCH] D39611: [CodeGen] make cbrt and fma constant (never set errno); document complex calls as always constant

2017-11-03 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> In general, because all of these functions are well defined over the entire 
> complex domain, they don't have errors. The "no errors defined" is likely 
> correct.

One, it is not true that all these functions are well-defined over the entire 
complex domain.  For example, according to the C standard `catanh(1)` raises a 
divide-by-zero error.

Two, even for the functions which are defined over the entire complex domain, 
the result can still overflow and/or underflow, and therefore they could set 
errno to ERANGE.  cabs() can overflow, cexp() can overflow, etc.

Three, even if we only care about the behavior of the current version of glibc, 
cabs() actually does modify errno. (Try `cabs(1.7e308+I*1.7e308)`).


https://reviews.llvm.org/D39611



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


r317394 - Update ODR hashing tests

2017-11-03 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Nov  3 18:20:50 2017
New Revision: 317394

URL: http://llvm.org/viewvc/llvm-project?rev=317394=rev
Log:
Update ODR hashing tests

Add a mix of postive and negative tests to check that wrong Decls won't be
flagged in the diagnostic.  Split the check everything test and moved the
pieces closer to where the related tests are.

Modified:
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=317394=317393=317394=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri Nov  3 18:20:50 2017
@@ -12,6 +12,10 @@
 // RUN: echo "#define SECOND" >> %t/Inputs/second.h
 // RUN: cat %s>> %t/Inputs/second.h
 
+// Test that each header can compile
+// RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++1z %t/Inputs/first.h
+// RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++1z %t/Inputs/second.h
+
 // Build module map file
 // RUN: echo "module FirstModule {" >> %t/Inputs/module.map
 // RUN: echo "header \"first.h\""   >> %t/Inputs/module.map
@@ -28,6 +32,13 @@
 #include "second.h"
 #endif
 
+// Used for testing
+#if defined(FIRST)
+#define ACCESS public:
+#elif defined(SECOND)
+#define ACCESS private:
+#endif
+
 namespace AccessSpecifiers {
 #if defined(FIRST)
 struct S1 {
@@ -55,6 +66,32 @@ S2 s2;
 // expected-error@second.h:* {{'AccessSpecifiers::S2' has different 
definitions in different modules; first difference is definition in module 
'SecondModule' found protected access specifier}}
 // expected-note@first.h:* {{but in 'FirstModule' found public access 
specifier}}
 #endif
+
+#define DECLS \
+public:   \
+private:  \
+protected:
+
+#if defined(FIRST) || defined(SECOND)
+struct Valid1 {
+  DECLS
+};
+#else
+Valid1 v1;
+#endif
+
+#if defined(FIRST) || defined(SECOND)
+struct Invalid1 {
+  DECLS
+  ACCESS
+};
+#else
+Invalid1 i1;
+// expected-error@second.h:* {{'AccessSpecifiers::Invalid1' has different 
definitions in different modules; first difference is definition in module 
'SecondModule' found private access specifier}}
+// expected-note@first.h:* {{but in 'FirstModule' found public access 
specifier}}
+#endif
+
+#undef DECLS
 } // namespace AccessSpecifiers
 
 namespace StaticAssert {
@@ -113,7 +150,31 @@ S4 s4;
 // expected-error@second.h:* {{'StaticAssert::S4' has different definitions in 
different modules; first difference is definition in module 'SecondModule' 
found public access specifier}}
 // expected-note@first.h:* {{but in 'FirstModule' found static assert}}
 #endif
-}
+
+#define DECLS   \
+  static_assert(4 == 4, "Message"); \
+  static_assert(5 == 5);
+
+#if defined(FIRST) || defined(SECOND)
+struct Valid1 {
+  DECLS
+};
+#else
+Valid1 v1;
+#endif
+
+#if defined(FIRST) || defined(SECOND)
+struct Invalid1 {
+  DECLS
+  ACCESS
+};
+#else
+Invalid1 i1;
+// expected-error@second.h:* {{'StaticAssert::Invalid1' has different 
definitions in different modules; first difference is definition in module 
'SecondModule' found private access specifier}}
+// expected-note@first.h:* {{but in 'FirstModule' found public access 
specifier}}
+#endif
+#undef DECLS
+}  // namespace StaticAssert
 
 namespace Field {
 #if defined(FIRST)
@@ -302,6 +363,38 @@ S13 s13;
 // expected-error@first.h:* {{'Field::S13::x' from module 'FirstModule' is not 
present in definition of 'Field::S13' in module 'SecondModule'}}
 // expected-note@second.h:* {{declaration of 'x' does not match}}
 #endif
+
+#define DECLS \
+  int a;  \
+  int b : 3;  \
+  unsigned c : 1 + 2; \
+  s d;\
+  double e = 1.0; \
+  long f[5];
+
+#if defined(FIRST) || defined(SECOND)
+typedef short s;
+#endif
+
+#if defined(FIRST) || defined(SECOND)
+struct Valid1 {
+  DECLS
+};
+#else
+Valid1 v1;
+#endif
+
+#if defined(FIRST) || defined(SECOND)
+struct Invalid1 {
+  DECLS
+  ACCESS
+};
+#else
+Invalid1 i1;
+// expected-error@second.h:* {{'Field::Invalid1' has different definitions in 
different modules; first difference is definition in module 'SecondModule' 
found private access specifier}}
+// expected-note@first.h:* {{but in 'FirstModule' found public access 
specifier}}
+#endif
+#undef DECLS
 }  // namespace Field
 
 namespace Method {
@@ -531,6 +624,40 @@ S15 s15;
 // expected-error@first.h:* {{'Method::S15::A' from module 'FirstModule' is 
not present in definition of 'Method::S15' in module 'SecondModule'}}
 // expected-note@second.h:* {{declaration of 'A' does not match}}
 #endif
+
+#define DECLS\
+  void A();  \
+  static void B();   \
+  virtual void C();  \
+  virtual void D() = 0;  \
+  inline void E();   \
+  void F() const;\
+  void G() volatile; \
+  void H(int x); \
+  void I(int x = 5 + 5); \
+  void J(int);   \
+  void K(int x[2]);  

[PATCH] D39611: [CodeGen] make cbrt and fma constant (never set errno); document complex calls as always constant

2017-11-03 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D39611#915560, @efriedma wrote:

> > The POSIX docs all have language like this for complex calls:
> >  "No errors are defined."
>
> I would not trust the POSIX documentation.
>
> carg() is an alias for atan2(), and cabs() is an alias for hypot(), so they 
> should be marked the same way.  (On glibc, cabs/hypot will set errno; not 
> sure about carg/atan2.)


That seems like a bug if they set errno. The complex versions shouldn't set 
errno. glibc's docs say that neither hypot or set errno (although the POSIX 
spec allows for it in theory).

> For the others transcendental functions... they can raise exceptions in some 
> cases, so they could in theory set errno, but it looks like they don't on 
> glibc?  Not sure if that's documented anywhere, or something we should depend 
> on.

In general, because all of these functions are well defined over the entire 
complex domain, they don't have errors. The "no errors defined" is likely 
correct.


https://reviews.llvm.org/D39611



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


Re: [PATCH] D39520: [libcxx][CMake] Fix libc++ build when no LLVM source tree is available.

2017-11-03 Thread Volodymyr Sapsai via cfe-commits
For now it is gone in the meaning that you don’t have to dedicate time and 
effort to support this configuration. But I wouldn’t say that taking other 
dependencies on llvm is welcome. In this aspect nothing has changed.

> On Nov 3, 2017, at 15:22, Zachary Turner  wrote:
> 
> The reason I ask is because I remember several months ago when I originally 
> made these changes, there was quite a bit of difficulty because some of the 
> Jenkins builders were wanting to run libcxx tests without any llvm source 
> tree on the machine.
> 
> Does this configuration still exist, or is it gone?  If it is gone, I think 
> many libcxx maintainers would be very happy if they can assume the presence 
> of an LLVM source tree somewhere on the disk.
> 
> On Fri, Nov 3, 2017 at 3:18 PM Volodymyr Sapsai  > wrote:
> We have llvm source tree next to libcxx and configure libcxx with -DLLVM_PATH.
> 
> 
>> On Nov 2, 2017, at 16:53, Zachary Turner > > wrote:
>> 
>> No problem.  If you don't mind me asking, what was the configuration change 
>> you made?  Or do you have a link to the patch which fixed it that I can look 
>> at?
>> 
>> On Thu, Nov 2, 2017 at 4:43 PM Volodymyr Sapsai via Phabricator 
>> > wrote:
>> vsapsai abandoned this revision.
>> vsapsai added a comment.
>> 
>> Fixed by changing libcxx build configuration, no CMake change required.
>> 
>> 
>> https://reviews.llvm.org/D39520 
>> 
>> 
>> 
> 

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


Re: [PATCH] D39622: Fix type debug information generation for enum-based template specialization

2017-11-03 Thread David Blaikie via cfe-commits
When you say "symbols table" - what are you referring to?

On Fri, Nov 3, 2017 at 4:20 PM Adrian Prantl via Phabricator <
revi...@reviews.llvm.org> wrote:

> aprantl added a comment.
>
> Can you add a testcase?
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D39622
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39622: Fix type debug information generation for enum-based template specialization

2017-11-03 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: include/clang/AST/PrettyPrinter.h:68
   /// \brief The number of spaces to use to indent each line.
-  unsigned Indentation : 8;
+  unsigned Indentation : 7;
 

this change looks like it has the potential to break existing code.


Repository:
  rL LLVM

https://reviews.llvm.org/D39622



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


[PATCH] D39622: Fix type debug information generation for enum-based template specialization

2017-11-03 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: include/clang/AST/PrettyPrinter.h:227
+
+  /// \brief Use formatting compatible with ABI specification. It is necessary 
for
+  /// saving entities into debug tables which have to be compatible with

Te \brief is redundant and can be omitted.


Repository:
  rL LLVM

https://reviews.llvm.org/D39622



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


[PATCH] D39622: Fix type debug information generation for enum-based template specialization

2017-11-03 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Can you add a testcase?


Repository:
  rL LLVM

https://reviews.llvm.org/D39622



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


[PATCH] D39622: Fix type debug information generation for enum-based template specialization

2017-11-03 Thread Anton via Phabricator via cfe-commits
xgsa created this revision.
xgsa added a project: clang.
Herald added a subscriber: aprantl.

Currently, there is an inconsistency between type name record in ".apple_types" 
section and entry in symbols table for the same type. In particular, for such 
types lldb is unable to resolve the real type using RTTI. Consider an example:

  enum class TagType : bool
  {
  Tag1
  };
  
  class I
  {
  };
  
  template 
  class Impl : public I
  {
  private:
  int v = 123;
  };
  
  int main(int argc, const char * argv[]) {
  Impl impl;
  I& i = impl;
  return 0;  // [*]
  }

For such code clang generates class name "Impl" into 
".apple_types" and "Impl<(TagType)0>" into symbols table. Thus at point [*], 
the lldb is unable to resolve the real type of the "i" variable (shows the type 
as "I&"), whereas it is expected to be "Impl" or 
"Impl<(TagType)0>".

This patch fixes the issue. I haven't found the existing ticket in bugzilla for 
the described issue (https://bugs.llvm.org/show_bug.cgi?id=24198 -- this one 
looks similar, but it's not the same and actually it is not reproducible 
anymore).


Repository:
  rL LLVM

https://reviews.llvm.org/D39622

Files:
  include/clang/AST/PrettyPrinter.h
  lib/AST/TemplateBase.cpp
  lib/CodeGen/CGDebugInfo.cpp


Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -234,6 +234,7 @@
   if (CGM.getCodeGenOpts().EmitCodeView)
 PP.MSVCFormatting = true;
 
+  PP.ABICompatibleFormatting = true;
   return PP;
 }
 
Index: lib/AST/TemplateBase.cpp
===
--- lib/AST/TemplateBase.cpp
+++ lib/AST/TemplateBase.cpp
@@ -41,14 +41,22 @@
   const llvm::APSInt  = TemplArg.getAsIntegral();
 
   if (const EnumType *ET = T->getAs()) {
-for (const EnumConstantDecl* ECD : ET->getDecl()->enumerators()) {
-  // In Sema::CheckTemplateArugment, enum template arguments value are
-  // extended to the size of the integer underlying the enum type.  This
-  // may create a size difference between the enum value and template
-  // argument value, requiring isSameValue here instead of operator==.
-  if (llvm::APSInt::isSameValue(ECD->getInitVal(), Val)) {
-ECD->printQualifiedName(Out, Policy);
-return;
+if (Policy.ABICompatibleFormatting) {
+  Out << "(";
+  ET->getDecl()->getNameForDiagnostic(Out, Policy, true);
+  Out << ")";
+  Out << Val;
+  return;
+} else {
+  for (const EnumConstantDecl* ECD : ET->getDecl()->enumerators()) {
+// In Sema::CheckTemplateArugment, enum template arguments value are
+// extended to the size of the integer underlying the enum type.  This
+// may create a size difference between the enum value and template
+// argument value, requiring isSameValue here instead of operator==.
+if (llvm::APSInt::isSameValue(ECD->getInitVal(), Val)) {
+  ECD->printQualifiedName(Out, Policy);
+  return;
+}
   }
 }
   }
Index: include/clang/AST/PrettyPrinter.h
===
--- include/clang/AST/PrettyPrinter.h
+++ include/clang/AST/PrettyPrinter.h
@@ -51,7 +51,8 @@
   TerseOutput(false), PolishForDeclaration(false),
   Half(LO.Half), MSWChar(LO.MicrosoftExt && !LO.WChar),
   IncludeNewlines(true), MSVCFormatting(false),
-  ConstantsAsWritten(false), SuppressImplicitBase(false) { }
+  ConstantsAsWritten(false), SuppressImplicitBase(false),
+  ABICompatibleFormatting(false) { }
 
   /// \brief Adjust this printing policy for cases where it's known that
   /// we're printing C++ code (for instance, if AST dumping reaches a
@@ -64,7 +65,7 @@
   }
 
   /// \brief The number of spaces to use to indent each line.
-  unsigned Indentation : 8;
+  unsigned Indentation : 7;
 
   /// \brief Whether we should suppress printing of the actual specifiers for
   /// the given type or declaration.
@@ -222,6 +223,13 @@
 
   /// \brief When true, don't print the implicit 'self' or 'this' expressions.
   bool SuppressImplicitBase : 1;
+
+  /// \brief Use formatting compatible with ABI specification. It is necessary 
for
+  /// saving entities into debug tables which have to be compatible with
+  /// the representation, described in ABI specification. In particular, this 
forces
+  /// templates parametrized with enums to be represented as "T<(Enum)0>" 
instead of
+  /// "T".
+  bool ABICompatibleFormatting : 1;
 };
 
 } // end namespace clang


Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -234,6 +234,7 @@
   if (CGM.getCodeGenOpts().EmitCodeView)
 PP.MSVCFormatting = true;
 
+  PP.ABICompatibleFormatting = true;
   return PP;
 }
 
Index: lib/AST/TemplateBase.cpp

[PATCH] D39615: [CodeGen] add remquo to list of recognized library calls

2017-11-03 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D39615



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


r317381 - [Basic] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

2017-11-03 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Fri Nov  3 15:35:27 2017
New Revision: 317381

URL: http://llvm.org/viewvc/llvm-project?rev=317381=rev
Log:
[Basic] Fix some Clang-tidy modernize and Include What You Use warnings; other 
minor fixes (NFC).

Modified:
cfe/trunk/include/clang/Basic/IdentifierTable.h
cfe/trunk/include/clang/Basic/Module.h
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/include/clang/Basic/SourceManagerInternals.h
cfe/trunk/lib/Basic/IdentifierTable.cpp
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/lib/Basic/SourceManager.cpp

Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?rev=317381=317380=317381=diff
==
--- cfe/trunk/include/clang/Basic/IdentifierTable.h (original)
+++ cfe/trunk/include/clang/Basic/IdentifierTable.h Fri Nov  3 15:35:27 2017
@@ -1,4 +1,4 @@
-//===--- IdentifierTable.h - Hash table for identifier lookup ---*- C++ 
-*-===//
+//===- IdentifierTable.h - Hash table for identifier lookup -*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -6,11 +6,11 @@
 // License. See LICENSE.TXT for details.
 //
 
//===--===//
-///
+//
 /// \file
 /// \brief Defines the clang::IdentifierInfo, clang::IdentifierTable, and
 /// clang::Selector interfaces.
-///
+//
 
//===--===//
 
 #ifndef LLVM_CLANG_BASIC_IDENTIFIERTABLE_H
@@ -18,35 +18,29 @@
 
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/TokenKinds.h"
+#include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
+#include "llvm/Support/PointerLikeTypeTraits.h"
+#include "llvm/Support/type_traits.h"
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
-namespace llvm {
-
-  template  struct DenseMapInfo;
-
-} // end namespace llvm
-
 namespace clang {
 
-  class LangOptions;
-  class IdentifierInfo;
-  class IdentifierTable;
-  class SourceLocation;
-  class MultiKeywordSelector; // private class used by Selector
-  class DeclarationName;  // AST class that stores declaration names
+class IdentifierInfo;
+class LangOptions;
+class MultiKeywordSelector;
+class SourceLocation;
 
-  /// \brief A simple pair of identifier info and location.
-  typedef std::pair IdentifierLocPair;
+/// \brief A simple pair of identifier info and location.
+using IdentifierLocPair = std::pair;
 
 /// One of these records is kept for each identifier that
 /// is lexed.  This contains information about whether the token was 
\#define'd,
@@ -85,8 +79,10 @@ class IdentifierInfo {
// keyword.
   // 29 bit left in 64-bit word.
 
-  void *FETokenInfo;   // Managed by the language front-end.
-  llvm::StringMapEntry *Entry;
+  // Managed by the language front-end.
+  void *FETokenInfo = nullptr;
+
+  llvm::StringMapEntry *Entry = nullptr;
 
 public:
   IdentifierInfo();
@@ -104,7 +100,6 @@ public:
 
   /// \brief Return the beginning of the actual null-terminated string for this
   /// identifier.
-  ///
   const char *getNameStart() const {
 if (Entry) return Entry->getKeyData();
 // FIXME: This is gross. It would be best not to embed specific details
@@ -112,12 +107,12 @@ public:
 // The 'this' pointer really points to a
 // std::pair, where internal pointer
 // points to the external string data.
-typedef std::pair actualtype;
+using actualtype = std::pair;
+
 return ((const actualtype*) this)->second;
   }
 
   /// \brief Efficiently return the length of this identifier info.
-  ///
   unsigned getLength() const {
 if (Entry) return Entry->getKeyLength();
 // FIXME: This is gross. It would be best not to embed specific details
@@ -125,7 +120,8 @@ public:
 // The 'this' pointer really points to a
 // std::pair, where internal pointer
 // points to the external string data.
-typedef std::pair actualtype;
+using actualtype = std::pair;
+
 const char* p = ((const actualtype*) this)->second - 2;
 return (((unsigned) p[0]) | (((unsigned) p[1]) << 8)) - 1;
   }
@@ -465,7 +461,7 @@ public:
 class IdentifierTable {
   // Shark shows that using MallocAllocator is *much* slower than using this
   // BumpPtrAllocator!
-  typedef llvm::StringMap HashTableTy;
+  using HashTableTy = llvm::StringMap;
   HashTableTy HashTable;
 
   IdentifierInfoLookup* ExternalLookup;
@@ -551,8 +547,8 @@ public:
 

LLVM buildmaster will be updated and restarted tonight

2017-11-03 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 7 PM Pacific time.

Thanks

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


Re: [PATCH] D39520: [libcxx][CMake] Fix libc++ build when no LLVM source tree is available.

2017-11-03 Thread Zachary Turner via cfe-commits
The reason I ask is because I remember several months ago when I originally
made these changes, there was quite a bit of difficulty because some of the
Jenkins builders were wanting to run libcxx tests without any llvm source
tree on the machine.

Does this configuration still exist, or is it gone?  If it is gone, I think
many libcxx maintainers would be very happy if they can assume the presence
of an LLVM source tree somewhere on the disk.

On Fri, Nov 3, 2017 at 3:18 PM Volodymyr Sapsai  wrote:

> We have llvm source tree next to libcxx and configure libcxx with
> -DLLVM_PATH.
>
>
> On Nov 2, 2017, at 16:53, Zachary Turner  wrote:
>
> No problem.  If you don't mind me asking, what was the configuration
> change you made?  Or do you have a link to the patch which fixed it that I
> can look at?
>
> On Thu, Nov 2, 2017 at 4:43 PM Volodymyr Sapsai via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> vsapsai abandoned this revision.
>> vsapsai added a comment.
>>
>> Fixed by changing libcxx build configuration, no CMake change required.
>>
>>
>> https://reviews.llvm.org/D39520
>>
>>
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37299: [Modules] Add ability to specify module name to module file mapping in a file

2017-11-03 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I'm still unconvinced that this mechanism is worth supporting.

The use case of putting this information into .d files doesn't make sense to 
me. .d files are generally outputs of prior compilations, whereas this 
information is a compilation input, needed in every compilation (including the 
first), and must be eagerly updated if a change to the source code adds a new 
dependency.


https://reviews.llvm.org/D37299



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


[PATCH] D39620: [analyzer] [NFC] Remove unused typedef

2017-11-03 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov created this revision.
Herald added subscribers: szepet, xazax.hun.

https://reviews.llvm.org/D39620

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h


Index: include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -103,9 +103,6 @@
 return *static_cast(this);
   }
 
-  /// BufferTy - A temporary buffer to hold a set of SVals.
-  typedef SmallVector BufferTy;
-
   inline unsigned getRawKind() const { return Kind; }
   inline BaseKind getBaseKind() const { return (BaseKind) (Kind & BaseMask); }
   inline unsigned getSubKind() const { return (Kind & ~BaseMask) >> BaseBits; }


Index: include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -103,9 +103,6 @@
 return *static_cast(this);
   }
 
-  /// BufferTy - A temporary buffer to hold a set of SVals.
-  typedef SmallVector BufferTy;
-
   inline unsigned getRawKind() const { return Kind; }
   inline BaseKind getBaseKind() const { return (BaseKind) (Kind & BaseMask); }
   inline unsigned getSubKind() const { return (Kind & ~BaseMask) >> BaseBits; }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r317372 - Add -fcxx-exceptions for ExtractionSemicolonPolicy.cpp to appease PS4 bots

2017-11-03 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Nov  3 14:31:10 2017
New Revision: 317372

URL: http://llvm.org/viewvc/llvm-project?rev=317372=rev
Log:
Add -fcxx-exceptions for ExtractionSemicolonPolicy.cpp to appease PS4 bots

Modified:
cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp

Modified: cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp?rev=317372=317371=317372=diff
==
--- cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp (original)
+++ cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp Fri Nov  3 
14:31:10 2017
@@ -1,4 +1,4 @@
-// RUN: clang-refactor extract -selection=test:%s %s -- -std=c++11 2>&1 | grep 
-v CHECK | FileCheck %s
+// RUN: clang-refactor extract -selection=test:%s %s -- -std=c++11 
-fcxx-exceptions | grep -v CHECK | FileCheck %s
 
 struct Rectangle { int width, height; };
 


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


[PATCH] D38976: [OpenMP] Add implicit data sharing support when offloading to NVIDIA GPUs using OpenMP device offloading

2017-11-03 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 121543.
gtbercea edited the summary of this revision.
gtbercea added a comment.

Remove blocks.


https://reviews.llvm.org/D38976

Files:
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  test/OpenMP/nvptx_data_sharing.cpp
  test/OpenMP/nvptx_parallel_codegen.cpp
  test/OpenMP/nvptx_target_teams_codegen.cpp

Index: test/OpenMP/nvptx_target_teams_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_codegen.cpp
@@ -60,7 +60,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]])
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]], i8*** %shared_args)
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
@@ -146,7 +146,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]])
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]], i8*** %shared_args)
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
Index: test/OpenMP/nvptx_parallel_codegen.cpp
===
--- test/OpenMP/nvptx_parallel_codegen.cpp
+++ test/OpenMP/nvptx_parallel_codegen.cpp
@@ -78,7 +78,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]])
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]],
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
@@ -92,20 +92,20 @@
   //
   // CHECK: [[EXEC_PARALLEL]]
   // CHECK: [[WF1:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
-  // CHECK: [[WM1:%.+]] = icmp eq i8* [[WF1]], bitcast (void (i32*, i32*)* [[PARALLEL_FN1:@.+]] to i8*)
+  // CHECK: [[WM1:%.+]] = icmp eq i8* [[WF1]], bitcast (void (i16, i32, i8**)* [[PARALLEL_FN1:@.+]]_wrapper to i8*)
   // CHECK: br i1 [[WM1]], label {{%?}}[[EXEC_PFN1:.+]], label {{%?}}[[CHECK_NEXT1:.+]]
   //
   // CHECK: [[EXEC_PFN1]]
-  // CHECK: call void [[PARALLEL_FN1]](
+  // CHECK: call void [[PARALLEL_FN1]]_wrapper(
   // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
   //
   // CHECK: [[CHECK_NEXT1]]
   // CHECK: [[WF2:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
-  // CHECK: [[WM2:%.+]] = icmp eq i8* [[WF2]], bitcast (void (i32*, i32*)* [[PARALLEL_FN2:@.+]] to i8*)
+  // CHECK: [[WM2:%.+]] = icmp eq i8* [[WF2]], bitcast (void (i16, i32, i8**)* [[PARALLEL_FN2:@.+]]_wrapper to i8*)
   // CHECK: br i1 [[WM2]], label {{%?}}[[EXEC_PFN2:.+]], label {{%?}}[[CHECK_NEXT2:.+]]
   //
   // CHECK: [[EXEC_PFN2]]
-  // CHECK: call void [[PARALLEL_FN2]](
+  // CHECK: call void [[PARALLEL_FN2]]_wrapper(
   // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
   //
   // CHECK: [[CHECK_NEXT2]]
@@ -152,13 +152,13 @@
   // CHECK-DAG: [[MWS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
   // CHECK: [[MTMP1:%.+]] = sub i32 [[MNTH]], [[MWS]]
   // CHECK: call void @__kmpc_kernel_init(i32 [[MTMP1]]
-  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i32*, i32*)* [[PARALLEL_FN1]] to i8*))
+  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32, i8**)* [[PARALLEL_FN1]]_wrapper to i8*),
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: call void @__kmpc_serialized_parallel(
   // CHECK: {{call|invoke}} void [[PARALLEL_FN3:@.+]](
   // CHECK: call void @__kmpc_end_serialized_parallel(
-  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i32*, i32*)* [[PARALLEL_FN2]] to i8*))
+  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32, i8**)* [[PARALLEL_FN2]]_wrapper to i8*),
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK-64-DAG: load i32, i32* [[REF_A]]
@@ -203,7 +203,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]])
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]],
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
@@ -217,11 +217,11 @@
   //
   // CHECK: [[EXEC_PARALLEL]]
   // CHECK: [[WF:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
-  // CHECK: [[WM:%.+]] = icmp eq i8* [[WF]], bitcast 

[PATCH] D39611: [CodeGen] make cbrt and fma constant (never set errno); document complex calls as always constant

2017-11-03 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: include/clang/Basic/Builtins.def:169
+// Disregard that 'cbrt' could set errno with a NaN input. The C standard says
+// that NaN arguments generally do not raise FP exceptions.
+BUILTIN(__builtin_cbrt , "dd", "Fnc")

Not sure adding this comment specifically for cbrt adds anything; the same 
could be said of a bunch of other functions, like ceil().


https://reviews.llvm.org/D39611



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


Re: r317343 - [refactor][extract] insert semicolons into extracted/inserted code

2017-11-03 Thread Galina Kistanova via cfe-commits
Hello Alex,

This commit broke tests on few builders:

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

. . .

Failing Tests (1):
Clang :: Refactor/Extract/ExtractionSemicolonPolicy.cpp

Please have a look?

Thanks

Galina

On Fri, Nov 3, 2017 at 11:11 AM, Alex Lorenz via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: arphaman
> Date: Fri Nov  3 11:11:22 2017
> New Revision: 317343
>
> URL: http://llvm.org/viewvc/llvm-project?rev=317343=rev
> Log:
> [refactor][extract] insert semicolons into extracted/inserted code
> when needed
>
> This commit implements the semicolon insertion logic into the extract
> refactoring. The following rules are used:
>
> - extracting expression: add terminating ';' to the extracted function.
> - extracting statements that don't require terminating ';' (e.g. switch):
> add
>   terminating ';' to the callee.
> - extracting statements with ';':  move (if possible) the original ';'
> from the
>   callee and add terminating ';'.
> - otherwise, add ';' to both places.
>
> Differential Revision: https://reviews.llvm.org/D39441
>
> Added:
> cfe/trunk/lib/Tooling/Refactoring/Extract/
> cfe/trunk/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp
> cfe/trunk/lib/Tooling/Refactoring/Extract/SourceExtraction.h
> cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp
> cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.m
> Modified:
> cfe/trunk/include/clang/Lex/Lexer.h
> cfe/trunk/lib/Lex/Lexer.cpp
> cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
> cfe/trunk/lib/Tooling/Refactoring/Extract.cpp
> cfe/trunk/test/Refactor/Extract/ExtractExprIntoFunction.cpp
>
> Modified: cfe/trunk/include/clang/Lex/Lexer.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Lex/Lexer.h?rev=317343=317342=317343=diff
> 
> ==
> --- cfe/trunk/include/clang/Lex/Lexer.h (original)
> +++ cfe/trunk/include/clang/Lex/Lexer.h Fri Nov  3 11:11:22 2017
> @@ -466,6 +466,13 @@ public:
>  const LangOptions ,
>  unsigned MaxLines = 0);
>
> +  /// Finds the token that comes right after the given location.
> +  ///
> +  /// Returns the next token, or none if the location is inside a macro.
> +  static Optional findNextToken(SourceLocation Loc,
> +   const SourceManager ,
> +   const LangOptions );
> +
>/// \brief Checks that the given token is the first token that occurs
> after
>/// the given location (this excludes comments and whitespace). Returns
> the
>/// location immediately after the specified token. If the token is not
> found
>
> Modified: cfe/trunk/lib/Lex/Lexer.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/
> Lexer.cpp?rev=317343=317342=317343=diff
> 
> ==
> --- cfe/trunk/lib/Lex/Lexer.cpp (original)
> +++ cfe/trunk/lib/Lex/Lexer.cpp Fri Nov  3 11:11:22 2017
> @@ -1212,18 +1212,12 @@ const char *Lexer::SkipEscapedNewLines(c
>}
>  }
>
> -/// \brief Checks that the given token is the first token that occurs
> after the
> -/// given location (this excludes comments and whitespace). Returns the
> location
> -/// immediately after the specified token. If the token is not found or
> the
> -/// location is inside a macro, the returned source location will be
> invalid.
> -SourceLocation Lexer::findLocationAfterToken(SourceLocation Loc,
> -tok::TokenKind TKind,
> -const SourceManager ,
> -const LangOptions ,
> -bool
> SkipTrailingWhitespaceAndNewLine) {
> +Optional Lexer::findNextToken(SourceLocation Loc,
> + const SourceManager ,
> + const LangOptions ) {
>if (Loc.isMacroID()) {
>  if (!Lexer::isAtEndOfMacroExpansion(Loc, SM, LangOpts, ))
> -  return SourceLocation();
> +  return None;
>}
>Loc = Lexer::getLocForEndOfToken(Loc, 0, SM, LangOpts);
>
> @@ -1234,7 +1228,7 @@ SourceLocation Lexer::findLocationAfterT
>bool InvalidTemp = false;
>StringRef File = SM.getBufferData(LocInfo.first, );
>if (InvalidTemp)
> -return SourceLocation();
> +return None;
>
>const char *TokenBegin = File.data() + LocInfo.second;
>
> @@ -1244,15 +1238,25 @@ SourceLocation Lexer::findLocationAfterT
>// Find the token.
>Token Tok;
>lexer.LexFromRawLexer(Tok);
> -  if (Tok.isNot(TKind))
> +  return Tok;
> +}
> +
> +/// \brief Checks that the given token is the first token that occurs
> after the
> +/// given 

[PATCH] D39611: [CodeGen] make cbrt and fma constant (never set errno); document complex calls as always constant

2017-11-03 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> The POSIX docs all have language like this for complex calls:
>  "No errors are defined."

I would not trust the POSIX documentation.

carg() is an alias for atan2(), and cabs() is an alias for hypot(), so they 
should be marked the same way.  (On glibc, cabs/hypot will set errno; not sure 
about carg/atan2.)

For the others transcendental functions... they can raise exceptions in some 
cases, so they could in theory set errno, but it looks like they don't on 
glibc?  Not sure if that's documented anywhere, or something we should depend 
on.


https://reviews.llvm.org/D39611



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


[PATCH] D38976: [OpenMP] Add implicit data sharing support when offloading to NVIDIA GPUs using OpenMP device offloading

2017-11-03 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 121538.

Repository:
  rL LLVM

https://reviews.llvm.org/D38976

Files:
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  test/OpenMP/nvptx_data_sharing.cpp
  test/OpenMP/nvptx_parallel_codegen.cpp
  test/OpenMP/nvptx_target_teams_codegen.cpp

Index: test/OpenMP/nvptx_target_teams_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_codegen.cpp
@@ -60,7 +60,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]])
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]], i8*** %shared_args)
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
@@ -146,7 +146,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]])
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]], i8*** %shared_args)
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
Index: test/OpenMP/nvptx_parallel_codegen.cpp
===
--- test/OpenMP/nvptx_parallel_codegen.cpp
+++ test/OpenMP/nvptx_parallel_codegen.cpp
@@ -78,7 +78,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]])
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]],
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
@@ -92,20 +92,20 @@
   //
   // CHECK: [[EXEC_PARALLEL]]
   // CHECK: [[WF1:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
-  // CHECK: [[WM1:%.+]] = icmp eq i8* [[WF1]], bitcast (void (i32*, i32*)* [[PARALLEL_FN1:@.+]] to i8*)
+  // CHECK: [[WM1:%.+]] = icmp eq i8* [[WF1]], bitcast (void (i16, i32, i8**)* [[PARALLEL_FN1:@.+]]_wrapper to i8*)
   // CHECK: br i1 [[WM1]], label {{%?}}[[EXEC_PFN1:.+]], label {{%?}}[[CHECK_NEXT1:.+]]
   //
   // CHECK: [[EXEC_PFN1]]
-  // CHECK: call void [[PARALLEL_FN1]](
+  // CHECK: call void [[PARALLEL_FN1]]_wrapper(
   // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
   //
   // CHECK: [[CHECK_NEXT1]]
   // CHECK: [[WF2:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
-  // CHECK: [[WM2:%.+]] = icmp eq i8* [[WF2]], bitcast (void (i32*, i32*)* [[PARALLEL_FN2:@.+]] to i8*)
+  // CHECK: [[WM2:%.+]] = icmp eq i8* [[WF2]], bitcast (void (i16, i32, i8**)* [[PARALLEL_FN2:@.+]]_wrapper to i8*)
   // CHECK: br i1 [[WM2]], label {{%?}}[[EXEC_PFN2:.+]], label {{%?}}[[CHECK_NEXT2:.+]]
   //
   // CHECK: [[EXEC_PFN2]]
-  // CHECK: call void [[PARALLEL_FN2]](
+  // CHECK: call void [[PARALLEL_FN2]]_wrapper(
   // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
   //
   // CHECK: [[CHECK_NEXT2]]
@@ -152,13 +152,13 @@
   // CHECK-DAG: [[MWS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
   // CHECK: [[MTMP1:%.+]] = sub i32 [[MNTH]], [[MWS]]
   // CHECK: call void @__kmpc_kernel_init(i32 [[MTMP1]]
-  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i32*, i32*)* [[PARALLEL_FN1]] to i8*))
+  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32, i8**)* [[PARALLEL_FN1]]_wrapper to i8*),
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: call void @__kmpc_serialized_parallel(
   // CHECK: {{call|invoke}} void [[PARALLEL_FN3:@.+]](
   // CHECK: call void @__kmpc_end_serialized_parallel(
-  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i32*, i32*)* [[PARALLEL_FN2]] to i8*))
+  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32, i8**)* [[PARALLEL_FN2]]_wrapper to i8*),
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK-64-DAG: load i32, i32* [[REF_A]]
@@ -203,7 +203,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]])
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]],
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
@@ -217,11 +217,11 @@
   //
   // CHECK: [[EXEC_PARALLEL]]
   // CHECK: [[WF:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
-  // CHECK: [[WM:%.+]] = icmp eq i8* [[WF]], bitcast (void (i32*, i32*)* [[PARALLEL_FN4:@.+]] to i8*)
+  // CHECK: 

[PATCH] D39615: [CodeGen] add remquo to list of recognized library calls

2017-11-03 Thread Sanjay Patel via Phabricator via cfe-commits
spatel created this revision.
Herald added a subscriber: mcrosier.

I assume this is just an oversight because we already do recognize 
__builtin_remquo() with the same signature.

http://en.cppreference.com/w/c/numeric/math/remquo
http://pubs.opengroup.org/onlinepubs/9699919799/functions/remquo.html


https://reviews.llvm.org/D39615

Files:
  include/clang/Basic/Builtins.def
  test/CodeGen/libcalls-errno.c


Index: test/CodeGen/libcalls-errno.c
===
--- test/CodeGen/libcalls-errno.c
+++ test/CodeGen/libcalls-errno.c
@@ -418,10 +418,14 @@
 // HAS_ERRNO: declare float @remainderf(float, float) [[NOT_READNONE]]
 // HAS_ERRNO: declare x86_fp80 @remainderl(x86_fp80, x86_fp80) [[NOT_READNONE]]
 
-//
-// FIXME: remquo is not recognized as a mathlib call.
-//
-  // remquo(f,f,i);  remquof(f,f,i); remquol(f,f,i);
+  remquo(f,f,i);  remquof(f,f,i); remquol(f,f,i);
+
+// NO__ERRNO: declare double @remquo(double, double, i32*) [[NOT_READNONE]]
+// NO__ERRNO: declare float @remquof(float, float, i32*) [[NOT_READNONE]]
+// NO__ERRNO: declare x86_fp80 @remquol(x86_fp80, x86_fp80, i32*) 
[[NOT_READNONE]]
+// HAS_ERRNO: declare double @remquo(double, double, i32*) [[NOT_READNONE]]
+// HAS_ERRNO: declare float @remquof(float, float, i32*) [[NOT_READNONE]]
+// HAS_ERRNO: declare x86_fp80 @remquol(x86_fp80, x86_fp80, i32*) 
[[NOT_READNONE]]
 
   rint(f);   rintf(f);  rintl(f);
 
Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -1162,6 +1162,10 @@
 LIBBUILTIN(remainderf, "fff", "fne", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(remainderl, "LdLdLd", "fne", "math.h", ALL_LANGUAGES)
 
+LIBBUILTIN(remquo, "dddi*", "fn", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(remquof, "fffi*", "fn", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(remquol, "LdLdLdi*", "fn", "math.h", ALL_LANGUAGES)
+
 LIBBUILTIN(rint, "dd", "fnc", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(rintf, "ff", "fnc", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(rintl, "LdLd", "fnc", "math.h", ALL_LANGUAGES)


Index: test/CodeGen/libcalls-errno.c
===
--- test/CodeGen/libcalls-errno.c
+++ test/CodeGen/libcalls-errno.c
@@ -418,10 +418,14 @@
 // HAS_ERRNO: declare float @remainderf(float, float) [[NOT_READNONE]]
 // HAS_ERRNO: declare x86_fp80 @remainderl(x86_fp80, x86_fp80) [[NOT_READNONE]]
 
-//
-// FIXME: remquo is not recognized as a mathlib call.
-//
-  // remquo(f,f,i);  remquof(f,f,i); remquol(f,f,i);
+  remquo(f,f,i);  remquof(f,f,i); remquol(f,f,i);
+
+// NO__ERRNO: declare double @remquo(double, double, i32*) [[NOT_READNONE]]
+// NO__ERRNO: declare float @remquof(float, float, i32*) [[NOT_READNONE]]
+// NO__ERRNO: declare x86_fp80 @remquol(x86_fp80, x86_fp80, i32*) [[NOT_READNONE]]
+// HAS_ERRNO: declare double @remquo(double, double, i32*) [[NOT_READNONE]]
+// HAS_ERRNO: declare float @remquof(float, float, i32*) [[NOT_READNONE]]
+// HAS_ERRNO: declare x86_fp80 @remquol(x86_fp80, x86_fp80, i32*) [[NOT_READNONE]]
 
   rint(f);   rintf(f);  rintl(f);
 
Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -1162,6 +1162,10 @@
 LIBBUILTIN(remainderf, "fff", "fne", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(remainderl, "LdLdLd", "fne", "math.h", ALL_LANGUAGES)
 
+LIBBUILTIN(remquo, "dddi*", "fn", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(remquof, "fffi*", "fn", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(remquol, "LdLdLdi*", "fn", "math.h", ALL_LANGUAGES)
+
 LIBBUILTIN(rint, "dd", "fnc", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(rintf, "ff", "fnc", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(rintl, "LdLd", "fnc", "math.h", ALL_LANGUAGES)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r317359 - Replace a use of std::for_each() with llvm::for_each(); NFC.

2017-11-03 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Nov  3 13:09:17 2017
New Revision: 317359

URL: http://llvm.org/viewvc/llvm-project?rev=317359=rev
Log:
Replace a use of std::for_each() with llvm::for_each(); NFC.

Modified:
cfe/trunk/lib/Sema/SemaPseudoObject.cpp

Modified: cfe/trunk/lib/Sema/SemaPseudoObject.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaPseudoObject.cpp?rev=317359=317358=317359=diff
==
--- cfe/trunk/lib/Sema/SemaPseudoObject.cpp (original)
+++ cfe/trunk/lib/Sema/SemaPseudoObject.cpp Fri Nov  3 13:09:17 2017
@@ -1442,8 +1442,7 @@ MSPropertyOpBuilder::getBaseMSProperty(M
 
 Expr *MSPropertyOpBuilder::rebuildAndCaptureObject(Expr *syntacticBase) {
   InstanceBase = capture(RefExpr->getBaseExpr());
-  std::for_each(CallArgs.begin(), CallArgs.end(),
-[this](Expr *) { Arg = capture(Arg); });
+  llvm::for_each(CallArgs, [this](Expr *) { Arg = capture(Arg); });
   syntacticBase = Rebuilder(S, [=](Expr *, unsigned Idx) -> Expr * {
 switch (Idx) {
 case 0:


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


[PATCH] D38976: [OpenMP] Add implicit data sharing support when offloading to NVIDIA GPUs using OpenMP device offloading

2017-11-03 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:2393
+
+  // Level0(CGF);
+

Is this meant to be a comment or should there be something happening here?



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:2396
+  CGF.EmitBranch(AfterBB);
+  if (NextBB)
+CGF.EmitBlock(NextBB);

Especially, `NextBB` can never be anything else than `nullptr`...


Repository:
  rL LLVM

https://reviews.llvm.org/D38976



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


[PATCH] D35472: Implement P0463R1: "Endian just Endian"

2017-11-03 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF requested changes to this revision.
EricWF added inline comments.
This revision now requires changes to proceed.



Comment at: include/type_traits:4746
+big= 0xFACE,
+#if _LIBCPP_LITTLE_ENDIAN
+native = little

These macros have been changed to be `#ifdef` style.



Comment at: include/type_traits:4750
+native = big
+#else
+native = 0xCAFE

Does this else case ever actually happen? 


https://reviews.llvm.org/D35472



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


[PATCH] D38976: [OpenMP] Add implicit data sharing support when offloading to NVIDIA GPUs using OpenMP device offloading

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

LG


Repository:
  rL LLVM

https://reviews.llvm.org/D38976



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


[PATCH] D39430: [clangd] formatting: don't ignore style

2017-11-03 Thread Raoul Wols via Phabricator via cfe-commits
rwols marked 2 inline comments as done.
rwols added inline comments.



Comment at: clangd/ClangdServer.cpp:41
   // Call clang-format.
-  // FIXME: Don't ignore style.
-  format::FormatStyle Style = format::getLLVMStyle();
-  auto Result = format::reformat(Style, Code, Ranges, Filename);
-
+  auto StyleOrError = format::getStyle("file", Filename, "LLVM");
+  if (!StyleOrError)

sammccall wrote:
> This needs to use the VFS I think. (I'm not familiar with the details of the 
> VFS usage I'm afraid)
Haven't tried implementing this yet, but from some simple experiments it 
doesn't seem necessary.


https://reviews.llvm.org/D39430



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


[PATCH] D39430: [clangd] formatting: don't ignore style

2017-11-03 Thread Raoul Wols via Phabricator via cfe-commits
rwols updated this revision to Diff 121524.
rwols added a comment.

Use llvm::Error for beautiful handling of errors.

It's perhaps an idea to write a `replyExpected(llvm::Expected)`, that will
transparently handle `llvm::Error`s.

I'll write a unit test for these changes next.

It's probably best to wait for https://reviews.llvm.org/D39435 to land, and 
then rebase.


https://reviews.llvm.org/D39430

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/JSONRPCDispatcher.cpp
  clangd/JSONRPCDispatcher.h
  test/clangd/formatting.test

Index: test/clangd/formatting.test
===
--- test/clangd/formatting.test
+++ test/clangd/formatting.test
@@ -1,4 +1,4 @@
-# RUN: clangd < %s | FileCheck %s
+# RUN: clangd -run-synchronously < %s | FileCheck %s
 # It is absolutely vital that this file has CRLF line endings.
 #
 Content-Length: 125
Index: clangd/JSONRPCDispatcher.h
===
--- clangd/JSONRPCDispatcher.h
+++ clangd/JSONRPCDispatcher.h
@@ -15,6 +15,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/YAMLParser.h"
+#include "llvm/Support/Error.h"
 #include 
 #include 
 
@@ -58,6 +59,8 @@
   void reply(const Twine );
   /// Sends an error response to the client, and logs it.
   void replyError(int code, const llvm::StringRef );
+  /// Send all error messages contained in Err to the client, and log them.
+  void replyError(llvm::Error Err);
 
 private:
   JSONOutput 
Index: clangd/JSONRPCDispatcher.cpp
===
--- clangd/JSONRPCDispatcher.cpp
+++ clangd/JSONRPCDispatcher.cpp
@@ -64,6 +64,11 @@
   }
 }
 
+void RequestContext::replyError(llvm::Error Err) {
+  const auto Message = llvm::toString(std::move(Err));
+  replyError(/*UnknownErrorCode*/ -32001, Message);
+}
+
 void JSONRPCDispatcher::registerHandler(StringRef Method, Handler H) {
   assert(!Handlers.count(Method) && "Handler already registered!");
   Handlers[Method] = std::move(H);
Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -285,11 +285,15 @@
   llvm::Optional switchSourceHeader(PathRef Path);
 
   /// Run formatting for \p Rng inside \p File.
-  std::vector formatRange(PathRef File, Range Rng);
+  llvm::Expected formatRange(PathRef File,
+Range Rng);
+
   /// Run formatting for the whole \p File.
-  std::vector formatFile(PathRef File);
+  llvm::Expected formatFile(PathRef File);
+
   /// Run formatting after a character was typed at \p Pos in \p File.
-  std::vector formatOnType(PathRef File, Position Pos);
+  llvm::Expected formatOnType(PathRef File,
+ Position Pos);
 
   /// Gets current document contents for \p File. \p File must point to a
   /// currently tracked file.
Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -34,13 +34,14 @@
   std::promise 
 };
 
-std::vector formatCode(StringRef Code, StringRef Filename,
- ArrayRef Ranges) {
+llvm::Expected
+formatCode(StringRef Code, StringRef Filename,
+   ArrayRef Ranges) {
   // Call clang-format.
-  // FIXME: Don't ignore style.
-  format::FormatStyle Style = format::getLLVMStyle();
-  auto Result = format::reformat(Style, Code, Ranges, Filename);
-
+  auto StyleOrError = format::getStyle("file", Filename, "LLVM", Code);
+  if (!StyleOrError)
+return StyleOrError.takeError();
+  auto Result = format::reformat(StyleOrError.get(), Code, Ranges, Filename);
   return std::vector(Result.begin(), Result.end());
 }
 
@@ -301,23 +302,24 @@
   return make_tagged(std::move(Result), TaggedFS.Tag);
 }
 
-std::vector ClangdServer::formatRange(PathRef File,
-Range Rng) {
+llvm::Expected
+ClangdServer::formatRange(PathRef File, Range Rng) {
   std::string Code = getDocument(File);
 
   size_t Begin = positionToOffset(Code, Rng.start);
   size_t Len = positionToOffset(Code, Rng.end) - Begin;
   return formatCode(Code, File, {tooling::Range(Begin, Len)});
 }
 
-std::vector ClangdServer::formatFile(PathRef File) {
+llvm::Expected
+ClangdServer::formatFile(PathRef File) {
   // Format everything.
   std::string Code = getDocument(File);
   return formatCode(Code, File, {tooling::Range(0, Code.size())});
 }
 
-std::vector ClangdServer::formatOnType(PathRef File,
- Position Pos) {
+llvm::Expected
+ClangdServer::formatOnType(PathRef File, Position Pos) {
   

[PATCH] D39121: [clang-tidy] Misplaced Operator in Strlen in Alloc

2017-11-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D39121#915441, @baloghadamsoftware wrote:

> In https://reviews.llvm.org/D39121#915123, @aaron.ballman wrote:
>
> > Out of curiosity, were there any true positives, either?
>
>
> No, in a release version there should be no true positives of this kind, I 
> think.


I figured there wouldn't be, but was curious just the same.




Comment at: clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp:86
+  diag(Alloc->getLocStart(),
+   "Addition operator is applied to the argument of "
+   "%0 instead of its result; surround the addition subexpression with "

aaron.ballman wrote:
> Addition -> addition
> 
> (Diagnostics are never complete sentences with capitalization and 
> punctuation, unlike comments.)
This change still needs to be applied.



Comment at: test/clang-tidy/bugprone-misplaced-operator-in-strlen-in-alloc.c:1
+// RUN: %check_clang_tidy %s bugprone-misplaced-operator-in-strlen-in-alloc %t
+

Please clang-format this file.



Comment at: test/clang-tidy/bugprone-misplaced-operator-in-strlen-in-alloc.cpp:1
+// RUN: %check_clang_tidy %s bugprone-misplaced-operator-in-strlen-in-alloc %t
+

Please clang-format this file.


https://reviews.llvm.org/D39121



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


[PATCH] D38688: [clang-tidy] Misc redundant expressions checker updated for macros

2017-11-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

Aside from some minor commenting nits, this LGTM.




Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:445
 
+  // Do not bind to double negation, it is uneffective.
   const auto NegateNegateRelationalExpr =

aaron.ballman wrote:
> I understand the first part of the comment, but not the second part -- why is 
> double negation ineffective?
> 
> (Btw, typo: unaffective -> ineffective)
Comment is missing a full stop at the end.



Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:377
 // Match a binary operator between a symbolic expression and an integer 
constant
-// expression.
+// expression
 static ast_matchers::internal::Matcher

This commenting change is incorrect, the comment should end with a full stop.


https://reviews.llvm.org/D38688



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


[PATCH] D39121: [clang-tidy] Misplaced Operator in Strlen in Alloc

2017-11-03 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In https://reviews.llvm.org/D39121#915123, @aaron.ballman wrote:

> Out of curiosity, were there any true positives, either?


No, in a release version there should be no true positives of this kind, I 
think.


https://reviews.llvm.org/D39121



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


[PATCH] D33722: [clang-tidy] Add checker for undelegated copy of base classes

2017-11-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D33722#915134, @xazax.hun wrote:

> Two problems are not resolved. One is Aaron prefers to query some infor from 
> the AST instead of relexing. The second is providing base initializers in the 
> wrong order.
>  I think there are other checks that do relexing in some cases, this should 
> not be a blocker.


In the other cases, it is not clear that the re-lexed information should be 
carried in the AST. In this case, I think it's pretty clear that the AST should 
carry this information. Further, I don't know that the re-lexing is correct (I 
pointed out an example that I think will be problematic) and carrying the 
information in the AST would solve that more cleanly than trying to reimplement 
the logic here.

> I am not sure that we should complicate the fixit logic with the order. If 
> -Wreorder has fixit hints, user should be able to get rid of the warning by 
> applying that.

I disagree. We should not be changing code to be incorrect, requiring the user 
to find that next incorrectness only through an additional compilation. That is 
a rather poor user experience.


https://reviews.llvm.org/D33722



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


[PATCH] D39611: [CodeGen] make cbrt and fma constant (never set errno); document complex calls as always constant

2017-11-03 Thread Sanjay Patel via Phabricator via cfe-commits
spatel created this revision.
Herald added a subscriber: mcrosier.

These are 3 errno-related diffs raised in D39841.

1. Cube root

We're going to dismiss POSIX language like this:
"On successful completion, cbrt() returns the cube root of x. If x is NaN, 
cbrt() returns NaN and errno may be set to [EDOM]. "
http://pubs.opengroup.org/onlinepubs/7908799/xsh/cbrt.html

And favor an interpretation based on the C standard that says:
"Functions with a NaN argument return a NaN result and raise no floating-point 
exception, except where stated otherwise."

2. Floating multiply-add

The C standard is silent?
http://pubs.opengroup.org/onlinepubs/9699919799/functions/fma.html - clearly 
says "...then errno shall be set..."
but:
https://linux.die.net/man/3/fma - "These functions do not set errno."

Let's opt for the - hopefully common - implementation where errno is not set. 
Note that there's no test change because as noted in the earlier discussion, 
we're ignoring the const attr in CodeGenFunction::EmitBuiltinExpr(). I'll look 
at what needs fixing in that function next.

3. Complex

This is came up specifically for 'carg', but I'm hoping we can use 1 
justification for the whole lib.

The POSIX docs all have language like this for complex calls:
"No errors are defined."
http://pubs.opengroup.org/onlinepubs/9699919799/functions/ccos.html

The lack of errno handling is allowed by the inclusion of "optionally" in the C 
standard definitions of all of the complex ops?
"csqrt(x + iNaN) returns NaN + iNaN and optionally raises the ‘‘invalid’’ 
floating-point exception, for finite x"


https://reviews.llvm.org/D39611

Files:
  include/clang/Basic/Builtins.def
  test/CodeGen/builtin-errno.c
  test/CodeGen/libcalls-errno.c

Index: test/CodeGen/libcalls-errno.c
===
--- test/CodeGen/libcalls-errno.c
+++ test/CodeGen/libcalls-errno.c
@@ -153,9 +153,9 @@
 // NO__ERRNO: declare double @cbrt(double) [[READNONE]]
 // NO__ERRNO: declare float @cbrtf(float) [[READNONE]]
 // NO__ERRNO: declare x86_fp80 @cbrtl(x86_fp80) [[READNONE]]
-// HAS_ERRNO: declare double @cbrt(double) [[NOT_READNONE]]
-// HAS_ERRNO: declare float @cbrtf(float) [[NOT_READNONE]]
-// HAS_ERRNO: declare x86_fp80 @cbrtl(x86_fp80) [[NOT_READNONE]]
+// HAS_ERRNO: declare double @cbrt(double) [[READNONE]]
+// HAS_ERRNO: declare float @cbrtf(float) [[READNONE]]
+// HAS_ERRNO: declare x86_fp80 @cbrtl(x86_fp80) [[READNONE]]
 
   ceil(f);   ceilf(f);  ceill(f);
 
Index: test/CodeGen/builtin-errno.c
===
--- test/CodeGen/builtin-errno.c
+++ test/CodeGen/builtin-errno.c
@@ -198,9 +198,9 @@
 // NO__ERRNO: declare double @cbrt(double) [[READNONE]]
 // NO__ERRNO: declare float @cbrtf(float) [[READNONE]]
 // NO__ERRNO: declare x86_fp80 @cbrtl(x86_fp80) [[READNONE]]
-// HAS_ERRNO: declare double @cbrt(double) [[NOT_READNONE]]
-// HAS_ERRNO: declare float @cbrtf(float) [[NOT_READNONE]]
-// HAS_ERRNO: declare x86_fp80 @cbrtl(x86_fp80) [[NOT_READNONE]]
+// HAS_ERRNO: declare double @cbrt(double) [[READNONE]]
+// HAS_ERRNO: declare float @cbrtf(float) [[READNONE]]
+// HAS_ERRNO: declare x86_fp80 @cbrtl(x86_fp80) [[READNONE]]
 
   __builtin_ceil(f);   __builtin_ceilf(f);  __builtin_ceill(f);
 
Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -165,9 +165,11 @@
 BUILTIN(__builtin_atanh , "dd", "Fne")
 BUILTIN(__builtin_atanhf, "ff", "Fne")
 BUILTIN(__builtin_atanhl, "LdLd", "Fne")
-BUILTIN(__builtin_cbrt , "dd", "Fne")
-BUILTIN(__builtin_cbrtf, "ff", "Fne")
-BUILTIN(__builtin_cbrtl, "LdLd", "Fne")
+// Disregard that 'cbrt' could set errno with a NaN input. The C standard says
+// that NaN arguments generally do not raise FP exceptions.
+BUILTIN(__builtin_cbrt , "dd", "Fnc")
+BUILTIN(__builtin_cbrtf, "ff", "Fnc")
+BUILTIN(__builtin_cbrtl, "LdLd", "Fnc")
 BUILTIN(__builtin_ceil , "dd"  , "Fnc")
 BUILTIN(__builtin_ceilf, "ff"  , "Fnc")
 BUILTIN(__builtin_ceill, "LdLd", "Fnc")
@@ -198,9 +200,11 @@
 BUILTIN(__builtin_floor , "dd"  , "Fnc")
 BUILTIN(__builtin_floorf, "ff"  , "Fnc")
 BUILTIN(__builtin_floorl, "LdLd", "Fnc")
-BUILTIN(__builtin_fma, "", "Fne")
-BUILTIN(__builtin_fmaf, "", "Fne")
-BUILTIN(__builtin_fmal, "LdLdLdLd", "Fne")
+// Disregard that 'fma' could set errno. This is based on the assumption that no
+// reasonable implementation would set errno and harm performance of a basic op.
+BUILTIN(__builtin_fma, "", "Fnc")
+BUILTIN(__builtin_fmaf, "", "Fnc")
+BUILTIN(__builtin_fmal, "LdLdLdLd", "Fnc")
 BUILTIN(__builtin_fmax, "ddd", "Fnc")
 BUILTIN(__builtin_fmaxf, "fff", "Fnc")
 BUILTIN(__builtin_fmaxl, "LdLdLd", "Fnc")
@@ -293,6 +297,8 @@
 BUILTIN(__builtin_truncl, "LdLd", "Fnc")
 
 // C99 complex builtins
+// All complex calls are marked const regardless of errno because exceptions are

r317337 - [Driver] Add Scudo as a possible -fsanitize= option

2017-11-03 Thread Kostya Kortchinsky via cfe-commits
Author: cryptoad
Date: Fri Nov  3 10:04:13 2017
New Revision: 317337

URL: http://llvm.org/viewvc/llvm-project?rev=317337=rev
Log:
[Driver] Add Scudo as a possible -fsanitize= option

Summary:
This change adds Scudo as a possible Sanitizer option via -fsanitize=.
This allows for easier static & shared linking of the Scudo library, it allows
us to enforce PIE (otherwise the security of the allocator is moot), and check
for incompatible Sanitizers combo.

In its current form, Scudo is not compatible with any other Sanitizer, but the
plan is to make it work in conjunction with UBsan (-fsanitize=scudo,undefined),
which will require additional work outside of the scope of this change.

Reviewers: eugenis, kcc, alekseyshl

Reviewed By: eugenis, alekseyshl

Subscribers: llvm-commits, srhines

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

Modified:
cfe/trunk/include/clang/Basic/Sanitizers.def
cfe/trunk/include/clang/Driver/SanitizerArgs.h
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/lib/Driver/ToolChains/Linux.cpp
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/test/Driver/fsanitize.c
cfe/trunk/test/Driver/sanitizer-ld.c

Modified: cfe/trunk/include/clang/Basic/Sanitizers.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.def?rev=317337=317336=317337=diff
==
--- cfe/trunk/include/clang/Basic/Sanitizers.def (original)
+++ cfe/trunk/include/clang/Basic/Sanitizers.def Fri Nov  3 10:04:13 2017
@@ -135,6 +135,9 @@ SANITIZER("efficiency-working-set", Effi
 SANITIZER_GROUP("efficiency-all", Efficiency,
 EfficiencyCacheFrag | EfficiencyWorkingSet)
 
+// Scudo hardened allocator
+SANITIZER("scudo", Scudo)
+
 // Magic group, containing all sanitizers. For example, "-fno-sanitize=all"
 // can be used to disable all the sanitizers.
 SANITIZER_GROUP("all", All, ~0ULL)

Modified: cfe/trunk/include/clang/Driver/SanitizerArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/SanitizerArgs.h?rev=317337=317336=317337=diff
==
--- cfe/trunk/include/clang/Driver/SanitizerArgs.h (original)
+++ cfe/trunk/include/clang/Driver/SanitizerArgs.h Fri Nov  3 10:04:13 2017
@@ -72,6 +72,7 @@ class SanitizerArgs {
   bool needsEsanRt() const {
 return Sanitizers.hasOneOf(SanitizerKind::Efficiency);
   }
+  bool needsScudoRt() const { return Sanitizers.has(SanitizerKind::Scudo); }
 
   bool requiresPIE() const;
   bool needsUnwindTables() const;

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=317337=317336=317337=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Fri Nov  3 10:04:13 2017
@@ -30,7 +30,7 @@ enum : SanitizerMask {
   NeedsUbsanCxxRt = Vptr | CFI,
   NotAllowedWithTrap = Vptr,
   NotAllowedWithMinimalRuntime = Vptr,
-  RequiresPIE = DataFlow,
+  RequiresPIE = DataFlow | Scudo,
   NeedsUnwindTables = Address | Thread | Memory | DataFlow,
   SupportsCoverage = Address | KernelAddress | Memory | Leak | Undefined |
  Integer | Nullability | DataFlow | Fuzzer | FuzzerNoLink,
@@ -173,7 +173,7 @@ static SanitizerMask parseSanitizeTrapAr
 bool SanitizerArgs::needsUbsanRt() const {
   // All of these include ubsan.
   if (needsAsanRt() || needsMsanRt() || needsTsanRt() || needsDfsanRt() ||
-  needsLsanRt() || needsCfiDiagRt())
+  needsLsanRt() || needsCfiDiagRt() || needsScudoRt())
 return false;
 
   return (Sanitizers.Mask & NeedsUbsanRt & ~TrapSanitizers.Mask) ||
@@ -370,17 +370,14 @@ SanitizerArgs::SanitizerArgs(const ToolC
 
   // Warn about incompatible groups of sanitizers.
   std::pair IncompatibleGroups[] = {
-  std::make_pair(Address, Thread), std::make_pair(Address, Memory),
-  std::make_pair(Thread, Memory), std::make_pair(Leak, Thread),
-  std::make_pair(Leak, Memory), std::make_pair(KernelAddress, Address),
-  std::make_pair(KernelAddress, Leak),
-  std::make_pair(KernelAddress, Thread),
-  std::make_pair(KernelAddress, Memory),
-  std::make_pair(Efficiency, Address),
-  std::make_pair(Efficiency, Leak),
-  std::make_pair(Efficiency, Thread),
-  std::make_pair(Efficiency, Memory),
-  std::make_pair(Efficiency, KernelAddress)};
+  std::make_pair(Address, Thread | Memory),
+  std::make_pair(Thread, Memory),
+  std::make_pair(Leak, Thread | Memory),
+  std::make_pair(KernelAddress, Address| Leak | Thread | Memory),
+  std::make_pair(Efficiency, Address | Leak | Thread | Memory |
+ KernelAddress),
+  std::make_pair(Scudo, Address | Leak | 

r317344 - Move Extract.cpp that wasn't moved in r317343

2017-11-03 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Nov  3 11:21:06 2017
New Revision: 317344

URL: http://llvm.org/viewvc/llvm-project?rev=317344=rev
Log:
Move Extract.cpp that wasn't moved in r317343

Added:
cfe/trunk/lib/Tooling/Refactoring/Extract/Extract.cpp
Removed:
cfe/trunk/lib/Tooling/Refactoring/Extract.cpp

Removed: cfe/trunk/lib/Tooling/Refactoring/Extract.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/Extract.cpp?rev=317343=auto
==
--- cfe/trunk/lib/Tooling/Refactoring/Extract.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/Extract.cpp (removed)
@@ -1,199 +0,0 @@
-//===--- Extract.cpp - Clang refactoring library 
--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-///
-/// \file
-/// \brief Implements the "extract" refactoring that can pull code into
-/// new functions, methods or declare new variables.
-///
-//===--===//
-
-#include "clang/Tooling/Refactoring/Extract/Extract.h"
-#include "SourceExtraction.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/DeclCXX.h"
-#include "clang/AST/Expr.h"
-#include "clang/AST/ExprObjC.h"
-#include "clang/Rewrite/Core/Rewriter.h"
-
-namespace clang {
-namespace tooling {
-
-namespace {
-
-/// Returns true if \c E is a simple literal or a reference expression that
-/// should not be extracted.
-bool isSimpleExpression(const Expr *E) {
-  if (!E)
-return false;
-  switch (E->IgnoreParenCasts()->getStmtClass()) {
-  case Stmt::DeclRefExprClass:
-  case Stmt::PredefinedExprClass:
-  case Stmt::IntegerLiteralClass:
-  case Stmt::FloatingLiteralClass:
-  case Stmt::ImaginaryLiteralClass:
-  case Stmt::CharacterLiteralClass:
-  case Stmt::StringLiteralClass:
-return true;
-  default:
-return false;
-  }
-}
-
-SourceLocation computeFunctionExtractionLocation(const Decl *D) {
-  if (isa(D)) {
-// Code from method that is defined in class body should be extracted to a
-// function defined just before the class.
-while (const auto *RD = 
dyn_cast(D->getLexicalDeclContext()))
-  D = RD;
-  }
-  return D->getLocStart();
-}
-
-} // end anonymous namespace
-
-const RefactoringDescriptor ::describe() {
-  static const RefactoringDescriptor Descriptor = {
-  "extract-function",
-  "Extract Function",
-  "(WIP action; use with caution!) Extracts code into a new function",
-  };
-  return Descriptor;
-}
-
-Expected
-ExtractFunction::initiate(RefactoringRuleContext ,
-  CodeRangeASTSelection Code,
-  Optional DeclName) {
-  // We would like to extract code out of functions/methods/blocks.
-  // Prohibit extraction from things like global variable / field
-  // initializers and other top-level expressions.
-  if (!Code.isInFunctionLikeBodyOfCode())
-return Context.createDiagnosticError(
-diag::err_refactor_code_outside_of_function);
-
-  if (Code.size() == 1) {
-// Avoid extraction of simple literals and references.
-if (isSimpleExpression(dyn_cast(Code[0])))
-  return Context.createDiagnosticError(
-  diag::err_refactor_extract_simple_expression);
-
-// Property setters can't be extracted.
-if (const auto *PRE = dyn_cast(Code[0])) {
-  if (!PRE->isMessagingGetter())
-return Context.createDiagnosticError(
-diag::err_refactor_extract_prohibited_expression);
-}
-  }
-
-  return ExtractFunction(std::move(Code), DeclName);
-}
-
-// FIXME: Support C++ method extraction.
-// FIXME: Support Objective-C method extraction.
-Expected
-ExtractFunction::createSourceReplacements(RefactoringRuleContext ) {
-  const Decl *ParentDecl = Code.getFunctionLikeNearestParent();
-  assert(ParentDecl && "missing parent");
-
-  // Compute the source range of the code that should be extracted.
-  SourceRange ExtractedRange(Code[0]->getLocStart(),
- Code[Code.size() - 1]->getLocEnd());
-  // FIXME (Alex L): Add code that accounts for macro locations.
-
-  ASTContext  = Context.getASTContext();
-  SourceManager  = AST.getSourceManager();
-  const LangOptions  = AST.getLangOpts();
-  Rewriter ExtractedCodeRewriter(SM, LangOpts);
-
-  // FIXME: Capture used variables.
-
-  // Compute the return type.
-  QualType ReturnType = AST.VoidTy;
-  // FIXME (Alex L): Account for the return statement in extracted code.
-  // FIXME (Alex L): Check for lexical expression instead.
-  bool IsExpr = Code.size() == 1 && isa(Code[0]);
-  if (IsExpr) {
-// FIXME (Alex L): Get a more user-friendly type if needed.
-ReturnType = cast(Code[0])->getType();
-  }
-
-  // FIXME: Rewrite the extracted code performing any 

[PATCH] D39441: [refactor][extract] insert semicolons into extracted/inserted code when needed

2017-11-03 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317343: [refactor][extract] insert semicolons into 
extracted/inserted code (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D39441?vs=121339=121516#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39441

Files:
  cfe/trunk/include/clang/Lex/Lexer.h
  cfe/trunk/lib/Lex/Lexer.cpp
  cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
  cfe/trunk/lib/Tooling/Refactoring/Extract.cpp
  cfe/trunk/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp
  cfe/trunk/lib/Tooling/Refactoring/Extract/SourceExtraction.h
  cfe/trunk/test/Refactor/Extract/ExtractExprIntoFunction.cpp
  cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp
  cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.m

Index: cfe/trunk/lib/Lex/Lexer.cpp
===
--- cfe/trunk/lib/Lex/Lexer.cpp
+++ cfe/trunk/lib/Lex/Lexer.cpp
@@ -1212,18 +1212,12 @@
   }
 }
 
-/// \brief Checks that the given token is the first token that occurs after the
-/// given location (this excludes comments and whitespace). Returns the location
-/// immediately after the specified token. If the token is not found or the
-/// location is inside a macro, the returned source location will be invalid.
-SourceLocation Lexer::findLocationAfterToken(SourceLocation Loc,
-tok::TokenKind TKind,
-const SourceManager ,
-const LangOptions ,
-bool SkipTrailingWhitespaceAndNewLine) {
+Optional Lexer::findNextToken(SourceLocation Loc,
+ const SourceManager ,
+ const LangOptions ) {
   if (Loc.isMacroID()) {
 if (!Lexer::isAtEndOfMacroExpansion(Loc, SM, LangOpts, ))
-  return SourceLocation();
+  return None;
   }
   Loc = Lexer::getLocForEndOfToken(Loc, 0, SM, LangOpts);
 
@@ -1234,7 +1228,7 @@
   bool InvalidTemp = false;
   StringRef File = SM.getBufferData(LocInfo.first, );
   if (InvalidTemp)
-return SourceLocation();
+return None;
 
   const char *TokenBegin = File.data() + LocInfo.second;
 
@@ -1244,15 +1238,25 @@
   // Find the token.
   Token Tok;
   lexer.LexFromRawLexer(Tok);
-  if (Tok.isNot(TKind))
+  return Tok;
+}
+
+/// \brief Checks that the given token is the first token that occurs after the
+/// given location (this excludes comments and whitespace). Returns the location
+/// immediately after the specified token. If the token is not found or the
+/// location is inside a macro, the returned source location will be invalid.
+SourceLocation Lexer::findLocationAfterToken(
+SourceLocation Loc, tok::TokenKind TKind, const SourceManager ,
+const LangOptions , bool SkipTrailingWhitespaceAndNewLine) {
+  Optional Tok = findNextToken(Loc, SM, LangOpts);
+  if (!Tok || Tok->isNot(TKind))
 return SourceLocation();
-  SourceLocation TokenLoc = Tok.getLocation();
+  SourceLocation TokenLoc = Tok->getLocation();
 
   // Calculate how much whitespace needs to be skipped if any.
   unsigned NumWhitespaceChars = 0;
   if (SkipTrailingWhitespaceAndNewLine) {
-const char *TokenEnd = SM.getCharacterData(TokenLoc) +
-   Tok.getLength();
+const char *TokenEnd = SM.getCharacterData(TokenLoc) + Tok->getLength();
 unsigned char C = *TokenEnd;
 while (isHorizontalWhitespace(C)) {
   C = *(++TokenEnd);
@@ -1269,7 +1273,7 @@
 }
   }
 
-  return TokenLoc.getLocWithOffset(Tok.getLength() + NumWhitespaceChars);
+  return TokenLoc.getLocWithOffset(Tok->getLength() + NumWhitespaceChars);
 }
 
 /// getCharAndSizeSlow - Peek a single 'character' from the specified buffer,
Index: cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
===
--- cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
+++ cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
@@ -4,7 +4,8 @@
   ASTSelection.cpp
   ASTSelectionRequirements.cpp
   AtomicChange.cpp
-  Extract.cpp
+  Extract/Extract.cpp
+  Extract/SourceExtraction.cpp
   RefactoringActions.cpp
   Rename/RenamingAction.cpp
   Rename/SymbolOccurrences.cpp
Index: cfe/trunk/lib/Tooling/Refactoring/Extract.cpp
===
--- cfe/trunk/lib/Tooling/Refactoring/Extract.cpp
+++ cfe/trunk/lib/Tooling/Refactoring/Extract.cpp
@@ -14,6 +14,7 @@
 //===--===//
 
 #include "clang/Tooling/Refactoring/Extract/Extract.h"
+#include "SourceExtraction.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/Expr.h"
@@ -145,6 +146,8 @@
   PP.SuppressLifetimeQualifiers = true;
   PP.SuppressUnwrittenScope = true;
 
+  ExtractionSemicolonPolicy Semicolons = 

r317343 - [refactor][extract] insert semicolons into extracted/inserted code

2017-11-03 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Nov  3 11:11:22 2017
New Revision: 317343

URL: http://llvm.org/viewvc/llvm-project?rev=317343=rev
Log:
[refactor][extract] insert semicolons into extracted/inserted code
when needed

This commit implements the semicolon insertion logic into the extract
refactoring. The following rules are used:

- extracting expression: add terminating ';' to the extracted function.
- extracting statements that don't require terminating ';' (e.g. switch): add
  terminating ';' to the callee.
- extracting statements with ';':  move (if possible) the original ';' from the
  callee and add terminating ';'.
- otherwise, add ';' to both places.

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

Added:
cfe/trunk/lib/Tooling/Refactoring/Extract/
cfe/trunk/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp
cfe/trunk/lib/Tooling/Refactoring/Extract/SourceExtraction.h
cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp
cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.m
Modified:
cfe/trunk/include/clang/Lex/Lexer.h
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
cfe/trunk/lib/Tooling/Refactoring/Extract.cpp
cfe/trunk/test/Refactor/Extract/ExtractExprIntoFunction.cpp

Modified: cfe/trunk/include/clang/Lex/Lexer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Lexer.h?rev=317343=317342=317343=diff
==
--- cfe/trunk/include/clang/Lex/Lexer.h (original)
+++ cfe/trunk/include/clang/Lex/Lexer.h Fri Nov  3 11:11:22 2017
@@ -466,6 +466,13 @@ public:
 const LangOptions ,
 unsigned MaxLines = 0);
 
+  /// Finds the token that comes right after the given location.
+  ///
+  /// Returns the next token, or none if the location is inside a macro.
+  static Optional findNextToken(SourceLocation Loc,
+   const SourceManager ,
+   const LangOptions );
+
   /// \brief Checks that the given token is the first token that occurs after
   /// the given location (this excludes comments and whitespace). Returns the
   /// location immediately after the specified token. If the token is not found

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=317343=317342=317343=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Fri Nov  3 11:11:22 2017
@@ -1212,18 +1212,12 @@ const char *Lexer::SkipEscapedNewLines(c
   }
 }
 
-/// \brief Checks that the given token is the first token that occurs after the
-/// given location (this excludes comments and whitespace). Returns the 
location
-/// immediately after the specified token. If the token is not found or the
-/// location is inside a macro, the returned source location will be invalid.
-SourceLocation Lexer::findLocationAfterToken(SourceLocation Loc,
-tok::TokenKind TKind,
-const SourceManager ,
-const LangOptions ,
-bool SkipTrailingWhitespaceAndNewLine) 
{
+Optional Lexer::findNextToken(SourceLocation Loc,
+ const SourceManager ,
+ const LangOptions ) {
   if (Loc.isMacroID()) {
 if (!Lexer::isAtEndOfMacroExpansion(Loc, SM, LangOpts, ))
-  return SourceLocation();
+  return None;
   }
   Loc = Lexer::getLocForEndOfToken(Loc, 0, SM, LangOpts);
 
@@ -1234,7 +1228,7 @@ SourceLocation Lexer::findLocationAfterT
   bool InvalidTemp = false;
   StringRef File = SM.getBufferData(LocInfo.first, );
   if (InvalidTemp)
-return SourceLocation();
+return None;
 
   const char *TokenBegin = File.data() + LocInfo.second;
 
@@ -1244,15 +1238,25 @@ SourceLocation Lexer::findLocationAfterT
   // Find the token.
   Token Tok;
   lexer.LexFromRawLexer(Tok);
-  if (Tok.isNot(TKind))
+  return Tok;
+}
+
+/// \brief Checks that the given token is the first token that occurs after the
+/// given location (this excludes comments and whitespace). Returns the 
location
+/// immediately after the specified token. If the token is not found or the
+/// location is inside a macro, the returned source location will be invalid.
+SourceLocation Lexer::findLocationAfterToken(
+SourceLocation Loc, tok::TokenKind TKind, const SourceManager ,
+const LangOptions , bool SkipTrailingWhitespaceAndNewLine) {
+  Optional Tok = findNextToken(Loc, SM, LangOpts);
+  if (!Tok || Tok->isNot(TKind))
 return SourceLocation();
-  SourceLocation TokenLoc = Tok.getLocation();
+  SourceLocation TokenLoc = Tok->getLocation();
 
   // Calculate how much whitespace needs to be 

[PATCH] D39587: [clang-format] Handle unary operator overload with arguments and specifiers

2017-11-03 Thread Igor Sugak via Phabricator via cfe-commits
sugak added a comment.

@djasper: would you accept and push this for me :)


https://reviews.llvm.org/D39587



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


[PATCH] D39603: [clang-tidy] Support relative paths in run-clang-tidy.py

2017-11-03 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun created this revision.
Herald added subscribers: baloghadamsoftware, whisperity.

Currently relative paths wasn't supperted by run-clang-tidy.py

I added the support, however I did not find any existing tests. Is it ok for 
this to land without a test or should I introduce one?


https://reviews.llvm.org/D39603

Files:
  clang-tidy/tool/run-clang-tidy.py


Index: clang-tidy/tool/run-clang-tidy.py
===
--- clang-tidy/tool/run-clang-tidy.py
+++ clang-tidy/tool/run-clang-tidy.py
@@ -67,6 +67,11 @@
 result += '../'
   return os.path.realpath(result)
 
+def make_absolute(f, directory):
+  if os.path.isabs(f):
+return f
+  return os.path.normpath(os.path.join(directory, f))
+
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
 header_filter, extra_arg, extra_arg_before, quiet):
@@ -223,7 +228,8 @@
 
   # Load the database and extract all files.
   database = json.load(open(os.path.join(build_path, db_path)))
-  files = [entry['file'] for entry in database]
+  files = [make_absolute(entry['file'], entry['directory'])
+  for entry in database]
 
   max_task = args.j
   if max_task == 0:


Index: clang-tidy/tool/run-clang-tidy.py
===
--- clang-tidy/tool/run-clang-tidy.py
+++ clang-tidy/tool/run-clang-tidy.py
@@ -67,6 +67,11 @@
 result += '../'
   return os.path.realpath(result)
 
+def make_absolute(f, directory):
+  if os.path.isabs(f):
+return f
+  return os.path.normpath(os.path.join(directory, f))
+
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
 header_filter, extra_arg, extra_arg_before, quiet):
@@ -223,7 +228,8 @@
 
   # Load the database and extract all files.
   database = json.load(open(os.path.join(build_path, db_path)))
-  files = [entry['file'] for entry in database]
+  files = [make_absolute(entry['file'], entry['directory'])
+  for entry in database]
 
   max_task = args.j
   if max_task == 0:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39419: Fix crash when parsing objective-c++ containing invalid lambda

2017-11-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D39419



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


r317336 - [CodeGen] add libcall attr tests to show errno-related diffs; NFC

2017-11-03 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Fri Nov  3 09:27:27 2017
New Revision: 317336

URL: http://llvm.org/viewvc/llvm-project?rev=317336=rev
Log:
[CodeGen] add libcall attr tests to show errno-related diffs; NFC

See rL317220 for the builtin siblings.

Added:
cfe/trunk/test/CodeGen/libcalls-errno.c

Added: cfe/trunk/test/CodeGen/libcalls-errno.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/libcalls-errno.c?rev=317336=auto
==
--- cfe/trunk/test/CodeGen/libcalls-errno.c (added)
+++ cfe/trunk/test/CodeGen/libcalls-errno.c Fri Nov  3 09:27:27 2017
@@ -0,0 +1,732 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm
  %s | FileCheck %s -check-prefix=NO__ERRNO
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm 
-fmath-errno %s | FileCheck %s -check-prefix=HAS_ERRNO
+
+// Test attributes of library calls to see how errno affects the resulting 
codegen. 
+
+
+double *d;
+float f;
+float *fp;
+long double *l;
+int *i;
+const char *c;
+
+void foo() {
+  atan2(f,f);atan2f(f,f) ;  atan2l(f, f);
+
+// NO__ERRNO: declare double @atan2(double, double) [[READNONE:#[0-9]+]]
+// NO__ERRNO: declare float @atan2f(float, float) [[READNONE]]
+// NO__ERRNO: declare x86_fp80 @atan2l(x86_fp80, x86_fp80) [[READNONE]]
+// HAS_ERRNO: declare double @atan2(double, double) [[NOT_READNONE:#[0-9]+]]
+// HAS_ERRNO: declare float @atan2f(float, float) [[NOT_READNONE]]
+// HAS_ERRNO: declare x86_fp80 @atan2l(x86_fp80, x86_fp80) [[NOT_READNONE]]
+
+  copysign(f,f); copysignf(f,f);copysignl(f,f);
+
+// NO__ERRNO: declare double @copysign(double, double) [[READNONE]]
+// NO__ERRNO: declare float @copysignf(float, float) [[READNONE]]
+// NO__ERRNO: declare x86_fp80 @copysignl(x86_fp80, x86_fp80) [[READNONE]]
+// HAS_ERRNO: declare double @copysign(double, double) [[READNONE:#[0-9]+]]
+// HAS_ERRNO: declare float @copysignf(float, float) [[READNONE]]
+// HAS_ERRNO: declare x86_fp80 @copysignl(x86_fp80, x86_fp80) [[READNONE]]
+
+  fabs(f);   fabsf(f);  fabsl(f);
+
+// NO__ERRNO: declare double @fabs(double) [[READNONE]]
+// NO__ERRNO: declare float @fabsf(float) [[READNONE]]
+// NO__ERRNO: declare x86_fp80 @fabsl(x86_fp80) [[READNONE]]
+// HAS_ERRNO: declare double @fabs(double) [[READNONE]]
+// HAS_ERRNO: declare float @fabsf(float) [[READNONE]]
+// HAS_ERRNO: declare x86_fp80 @fabsl(x86_fp80) [[READNONE]]
+
+  fmod(f,f); fmodf(f,f);fmodl(f,f);
+
+// NO__ERRNO: declare double @fmod(double, double) [[READNONE]]
+// NO__ERRNO: declare float @fmodf(float, float) [[READNONE]]
+// NO__ERRNO: declare x86_fp80 @fmodl(x86_fp80, x86_fp80) [[READNONE]]
+// HAS_ERRNO: declare double @fmod(double, double) [[NOT_READNONE]]
+// HAS_ERRNO: declare float @fmodf(float, float) [[NOT_READNONE]]
+// HAS_ERRNO: declare x86_fp80 @fmodl(x86_fp80, x86_fp80) [[NOT_READNONE]]
+
+  frexp(f,i);frexpf(f,i);   frexpl(f,i);
+
+// NO__ERRNO: declare double @frexp(double, i32*) [[NOT_READNONE:#[0-9]+]]
+// NO__ERRNO: declare float @frexpf(float, i32*) [[NOT_READNONE]]
+// NO__ERRNO: declare x86_fp80 @frexpl(x86_fp80, i32*) [[NOT_READNONE]]
+// HAS_ERRNO: declare double @frexp(double, i32*) [[NOT_READNONE]]
+// HAS_ERRNO: declare float @frexpf(float, i32*) [[NOT_READNONE]]
+// HAS_ERRNO: declare x86_fp80 @frexpl(x86_fp80, i32*) [[NOT_READNONE]]
+
+  ldexp(f,f);ldexpf(f,f);   ldexpl(f,f);  
+
+// NO__ERRNO: declare double @ldexp(double, i32) [[READNONE]]
+// NO__ERRNO: declare float @ldexpf(float, i32) [[READNONE]]
+// NO__ERRNO: declare x86_fp80 @ldexpl(x86_fp80, i32) [[READNONE]]
+// HAS_ERRNO: declare double @ldexp(double, i32) [[NOT_READNONE]]
+// HAS_ERRNO: declare float @ldexpf(float, i32) [[NOT_READNONE]]
+// HAS_ERRNO: declare x86_fp80 @ldexpl(x86_fp80, i32) [[NOT_READNONE]]
+
+  modf(f,d);   modff(f,fp);  modfl(f,l); 
+
+// NO__ERRNO: declare double @modf(double, double*) [[NOT_READNONE]]
+// NO__ERRNO: declare float @modff(float, float*) [[NOT_READNONE]]
+// NO__ERRNO: declare x86_fp80 @modfl(x86_fp80, x86_fp80*) [[NOT_READNONE]]
+// HAS_ERRNO: declare double @modf(double, double*) [[NOT_READNONE]]
+// HAS_ERRNO: declare float @modff(float, float*) [[NOT_READNONE]]
+// HAS_ERRNO: declare x86_fp80 @modfl(x86_fp80, x86_fp80*) [[NOT_READNONE]]
+
+  nan(c);nanf(c);   nanl(c);  
+
+// NO__ERRNO: declare double @nan(i8*) [[READONLY:#[0-9]+]]
+// NO__ERRNO: declare float @nanf(i8*) [[READONLY]]
+// NO__ERRNO: declare x86_fp80 @nanl(i8*) [[READONLY]]
+// HAS_ERRNO: declare double @nan(i8*) [[READONLY:#[0-9]+]]
+// HAS_ERRNO: declare float @nanf(i8*) [[READONLY]]
+// HAS_ERRNO: declare x86_fp80 @nanl(i8*) [[READONLY]]
+
+  pow(f,f);powf(f,f);   powl(f,f);
+
+// NO__ERRNO: declare double @llvm.pow.f64(double, double) 
[[READNONE_INTRINSIC:#[0-9]+]]
+// NO__ERRNO: declare float @llvm.pow.f32(float, float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare x86_fp80 @llvm.pow.f80(x86_fp80, 

[PATCH] D37554: [libclang] Allow crash recovery with LIBCLANG_NOTHREADS

2017-11-03 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

Ping...


https://reviews.llvm.org/D37554



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


[clang-tools-extra] r317333 - Use ToolExecutor framework in the sample tool-template.

2017-11-03 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri Nov  3 09:03:56 2017
New Revision: 317333

URL: http://llvm.org/viewvc/llvm-project?rev=317333=rev
Log:
Use ToolExecutor framework in the sample tool-template.

Modified:
clang-tools-extra/trunk/tool-template/CMakeLists.txt
clang-tools-extra/trunk/tool-template/ToolTemplate.cpp

Modified: clang-tools-extra/trunk/tool-template/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/tool-template/CMakeLists.txt?rev=317333=317332=317333=diff
==
--- clang-tools-extra/trunk/tool-template/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/tool-template/CMakeLists.txt Fri Nov  3 09:03:56 
2017
@@ -12,4 +12,5 @@ target_link_libraries(tool-template
   clangBasic
   clangFrontend
   clangTooling
+  clangToolingRefactor
   )

Modified: clang-tools-extra/trunk/tool-template/ToolTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/tool-template/ToolTemplate.cpp?rev=317333=317332=317333=diff
==
--- clang-tools-extra/trunk/tool-template/ToolTemplate.cpp (original)
+++ clang-tools-extra/trunk/tool-template/ToolTemplate.cpp Fri Nov  3 09:03:56 
2017
@@ -40,7 +40,9 @@
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/Execution.h"
 #include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Refactoring/AtomicChange.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -54,19 +56,31 @@ using namespace llvm;
 namespace {
 class ToolTemplateCallback : public MatchFinder::MatchCallback {
 public:
-  ToolTemplateCallback(std::map *Replace)
-  : Replace(Replace) {}
+  ToolTemplateCallback(ExecutionContext ) : Context(Context) {}
 
   void run(const MatchFinder::MatchResult ) override {
 // TODO: This routine will get called for each thing that the matchers
 // find.
 // At this point, you can examine the match, and do whatever you want,
 // including replacing the matched text with other text
-(void)Replace; // This to prevent an "unused member variable" warning;
+auto *D = Result.Nodes.getNodeAs("decl");
+assert(D);
+// Use AtomicChange to get a key.
+if (D->getLocStart().isValid()) {
+  AtomicChange Change(*Result.SourceManager, D->getLocStart());
+  Context.reportResult(Change.getKey(), D->getQualifiedNameAsString());
+}
+  }
+
+  void onStartOfTranslationUnit() override {
+Context.reportResult("START", "Start of TU.");
+  }
+  void onEndOfTranslationUnit() override {
+Context.reportResult("END", "End of TU.");
   }
 
 private:
-  std::map *Replace;
+  ExecutionContext 
 };
 } // end anonymous namespace
 
@@ -76,15 +90,33 @@ static cl::OptionCategory ToolTemplateCa
 
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
-  CommonOptionsParser OptionsParser(argc, argv, ToolTemplateCategory);
-  RefactoringTool Tool(OptionsParser.getCompilations(),
-   OptionsParser.getSourcePathList());
+
+  auto Executor = clang::tooling::createExecutorFromCommandLineArgs(
+  argc, argv, ToolTemplateCategory);
+
+  if (!Executor) {
+llvm::errs() << llvm::toString(Executor.takeError()) << "\n";
+return 1;
+  }
+
   ast_matchers::MatchFinder Finder;
-  ToolTemplateCallback Callback(());
+  ToolTemplateCallback Callback(*Executor->get()->getExecutionContext());
 
   // TODO: Put your matchers here.
   // Use Finder.addMatcher(...) to define the patterns in the AST that you
   // want to match against. You are not limited to just one matcher!
-
-  return Tool.run(newFrontendActionFactory().get());
+  //
+  // This is a sample matcher:
+  Finder.addMatcher(
+  namedDecl(cxxRecordDecl(), isExpansionInMainFile()).bind("decl"),
+  );
+
+  auto Err = Executor->get()->execute(newFrontendActionFactory());
+  if (Err) {
+llvm::errs() << llvm::toString(std::move(Err)) << "\n";
+  }
+  Executor->get()->getToolResults()->forEachResult(
+  [](llvm::StringRef key, llvm::StringRef value) {
+llvm::errs() << "" << key.str() << "\n" << value.str() << "\n";
+  });
 }


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


r317332 - [Tooling] Fix linking of StandaloneToolExecutorPlugin.

2017-11-03 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri Nov  3 08:57:27 2017
New Revision: 317332

URL: http://llvm.org/viewvc/llvm-project?rev=317332=rev
Log:
[Tooling] Fix linking of StandaloneToolExecutorPlugin.

Modified:
cfe/trunk/lib/Tooling/Execution.cpp
cfe/trunk/lib/Tooling/StandaloneExecution.cpp
cfe/trunk/unittests/Tooling/ExecutionTest.cpp

Modified: cfe/trunk/lib/Tooling/Execution.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Execution.cpp?rev=317332=317331=317332=diff
==
--- cfe/trunk/lib/Tooling/Execution.cpp (original)
+++ cfe/trunk/lib/Tooling/Execution.cpp Fri Nov  3 08:57:27 2017
@@ -61,7 +61,7 @@ createExecutorFromCommandLineArgsImpl(in
   const char *Overview) {
   auto OptionsParser =
   CommonOptionsParser::create(argc, argv, Category, llvm::cl::ZeroOrMore,
-  /*Overview=*/nullptr);
+  /*Overview=*/Overview);
   if (!OptionsParser)
 return OptionsParser.takeError();
   for (auto I = ToolExecutorPluginRegistry::begin(),
@@ -95,5 +95,11 @@ createExecutorFromCommandLineArgs(int 
  Overview);
 }
 
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the StandaloneToolExecutorPlugin.
+extern volatile int StandaloneToolExecutorAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED StandaloneToolExecutorAnchorDest =
+StandaloneToolExecutorAnchorSource;
+
 } // end namespace tooling
 } // end namespace clang

Modified: cfe/trunk/lib/Tooling/StandaloneExecution.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/StandaloneExecution.cpp?rev=317332=317331=317332=diff
==
--- cfe/trunk/lib/Tooling/StandaloneExecution.cpp (original)
+++ cfe/trunk/lib/Tooling/StandaloneExecution.cpp Fri Nov  3 08:57:27 2017
@@ -79,13 +79,13 @@ public:
   }
 };
 
-// This anchor is used to force the linker to link in the generated object file
-// and thus register the plugin.
-volatile int ToolExecutorPluginAnchorSource = 0;
-
 static ToolExecutorPluginRegistry::Add
 X("standalone", "Runs FrontendActions on a set of files provided "
 "via positional arguments.");
 
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the plugin.
+volatile int StandaloneToolExecutorAnchorSource = 0;
+
 } // end namespace tooling
 } // end namespace clang

Modified: cfe/trunk/unittests/Tooling/ExecutionTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/ExecutionTest.cpp?rev=317332=317331=317332=diff
==
--- cfe/trunk/unittests/Tooling/ExecutionTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/ExecutionTest.cpp Fri Nov  3 08:57:27 2017
@@ -125,13 +125,6 @@ public:
   }
 };
 
-// This anchor is used to force the linker to link in the generated object file
-// and thus register the plugin.
-extern volatile int ToolExecutorPluginAnchorSource;
-
-static int LLVM_ATTRIBUTE_UNUSED TestToolExecutorPluginAnchorDest =
-ToolExecutorPluginAnchorSource;
-
 static ToolExecutorPluginRegistry::Add
 X("test-executor", "Plugin for TestToolExecutor.");
 


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


[PATCH] D39571: [clangd] DidChangeConfiguration Notification

2017-11-03 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle requested changes to this revision.
malaperle added inline comments.
This revision now requires changes to proceed.



Comment at: clangd/ClangdLSPServer.cpp:51
+  "definitionProvider": true,
+  "configurationChangeProvider": true
 }})");

Are you sure the existing tests don't fail? usually when we change this, some 
tests have to be adjusted.



Comment at: clangd/ClangdLSPServer.cpp:199
+Ctx C, DidChangeConfigurationParams ) {
+  std::map SettingsMap;
+  SettingsMap.insert(std::pair(

I'm thinking, maybe it's better not to have the map and just pass along the 
ClangdConfigurationParams to the server (instead of the map). I think 
ClangdConfigurationParams is more useful as a structure than a "flat" map with 
all the keys being at the same level. In ClangdConfigurationParams, we'll be 
able to add sub-configurations sections (index, code-completion, more?) which 
is well suited to reflect the JSON format.

Unless perhaps you had another use case for the map that I'm not thinking about?



Comment at: clangd/ClangdLSPServer.cpp:201
+  SettingsMap.insert(std::pair(
+  "CDBPath", Params.settings.compilationDatabasePath.getValue()));
+  
CDB.setCompileCommandsDir(Params.settings.compilationDatabasePath.getValue());

Won't getValue crash if compilationDatabasePath was not set since it's optional?



Comment at: clangd/ClangdLSPServer.cpp:203
+  
CDB.setCompileCommandsDir(Params.settings.compilationDatabasePath.getValue());
+  
CDB.getCompilationDatabase(StringRef(CDB.getCompileCommandsDir().getValue()));
+

Why is this line needed? Maybe there should be a comment?
I think its meant to reload the actual CompilationDatabase object? I think you 
could call this in setCompileCommandsDir and not have to make 
getCompilationDatabase public. You also woudn't need getCompileCommandsDir at 
all.



Comment at: clangd/ClangdLSPServer.cpp:208
+  // map and sent with this function call.
+  Server.changeConfiguration(SettingsMap);
+}

Pass Params.settings? see previous comment.



Comment at: clangd/ClangdServer.cpp:441
+std::map ChangedSettings) {
+  if (!ChangedSettings.empty()) {
+  }

I think we need to discuss what should happen when the compilation database 
changes. Since this is mainly for switching "configuration", I think it should 
invalidate all previously parsed units. Otherwise, if the user has a file open 
in the editor, it will report diagnostics based on the old configuration and 
similarly code completion will be outdated (until Clangd is restarted?). Would 
it be unreasonable to reparse all units in memory? Perhaps 
ClangdServer::forceReparse would be useful for that?
I'm not sure what is the right approach but we should make sure the editors are 
not left in a confusing state.



Comment at: clangd/GlobalCompilationDatabase.h:55
   getCompileCommands(PathRef File) override;
+  llvm::Optional getCompileCommandsDir() { return CompileCommandsDir; }
+  void setCompileCommandsDir(Path P) { CompileCommandsDir = P; }

remove?



Comment at: clangd/GlobalCompilationDatabase.h:56
+  llvm::Optional getCompileCommandsDir() { return CompileCommandsDir; }
+  void setCompileCommandsDir(Path P) { CompileCommandsDir = P; }
+

call getCompilationDatabase from here?



Comment at: clangd/GlobalCompilationDatabase.h:58
+
+  tooling::CompilationDatabase *getCompilationDatabase(PathRef File);
 

move back to private?



Comment at: clangd/Protocol.cpp:534
 
+llvm::Optional
+DidChangeConfigurationParams::parse(llvm::yaml::MappingNode *Params,

I think this needs a test, perhaps create did-change-configuration.test? It can 
also test the ClangdConfigurationParams::parse code
If you do, I think it's a good idea to test a few failing cases:
- "settings" is not a mapping node. You can test this with a scalar node like 
"settings": ""
- Something else than "settings" is present, so that it goes through 
logIgnoredField
- "settings" is not set at all. In this case, because it's mandatory in the 
protocol, return llvm::None. This can be checked after the loop after all 
key/values were read.

There are similar tests in execute-command.test if you'd like an example.
And of course also add a "successful" case as well  :)



Comment at: clangd/Protocol.cpp:561
+
+  return Result;
+}

If "settings" was not set in the end, return llvm::None, because this is 
mandatory in the protocol.



Comment at: clangd/Protocol.cpp:578
+if (!Value)
+  return llvm::None;
+

Here there should be a test when 

r317328 - [Tooling] Put createExecutorFromCommandLineArgs implementation in a wrapper. NFC

2017-11-03 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri Nov  3 08:20:57 2017
New Revision: 317328

URL: http://llvm.org/viewvc/llvm-project?rev=317328=rev
Log:
[Tooling] Put createExecutorFromCommandLineArgs implementation in a wrapper. NFC

Modified:
cfe/trunk/include/clang/Tooling/Execution.h
cfe/trunk/lib/Tooling/Execution.cpp

Modified: cfe/trunk/include/clang/Tooling/Execution.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Execution.h?rev=317328=317327=317328=diff
==
--- cfe/trunk/include/clang/Tooling/Execution.h (original)
+++ cfe/trunk/include/clang/Tooling/Execution.h Fri Nov  3 08:20:57 2017
@@ -162,6 +162,13 @@ createExecutorFromCommandLineArgs(int 
   llvm::cl::OptionCategory ,
   const char *Overview = nullptr);
 
+namespace internal {
+llvm::Expected
+createExecutorFromCommandLineArgsImpl(int , const char **argv,
+  llvm::cl::OptionCategory ,
+  const char *Overview = nullptr);
+} // end namespace internal
+
 } // end namespace tooling
 } // end namespace clang
 

Modified: cfe/trunk/lib/Tooling/Execution.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Execution.cpp?rev=317328=317327=317328=diff
==
--- cfe/trunk/lib/Tooling/Execution.cpp (original)
+++ cfe/trunk/lib/Tooling/Execution.cpp Fri Nov  3 08:20:57 2017
@@ -54,10 +54,11 @@ llvm::Error ToolExecutor::execute(std::u
   return execute(Actions);
 }
 
+namespace internal {
 llvm::Expected
-createExecutorFromCommandLineArgs(int , const char **argv,
-  llvm::cl::OptionCategory ,
-  const char *Overview) {
+createExecutorFromCommandLineArgsImpl(int , const char **argv,
+  llvm::cl::OptionCategory ,
+  const char *Overview) {
   auto OptionsParser =
   CommonOptionsParser::create(argc, argv, Category, llvm::cl::ZeroOrMore,
   /*Overview=*/nullptr);
@@ -84,6 +85,15 @@ createExecutorFromCommandLineArgs(int 
   llvm::Twine("Executor \"") + ExecutorName + "\" is not registered.",
   llvm::inconvertibleErrorCode());
 }
+} // end namespace internal
+
+llvm::Expected
+createExecutorFromCommandLineArgs(int , const char **argv,
+  llvm::cl::OptionCategory ,
+  const char *Overview) {
+  return internal::createExecutorFromCommandLineArgsImpl(argc, argv, Category,
+ Overview);
+}
 
 } // end namespace tooling
 } // end namespace clang


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


[PATCH] D33722: [clang-tidy] Add checker for undelegated copy of base classes

2017-11-03 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked 5 inline comments as done.
xazax.hun added a comment.

Two problems are not resolved. One is Aaron prefers to query some infor from 
the AST instead of relexing. The second is providing base initializers in the 
wrong order.
I think there are other checks that do relexing in some cases, this should not 
be a blocker. I am not sure that we should complicate the fixit logic with the 
order. If -Wreorder has fixit hints, user should be able to get rid of the 
warning by applying that.


https://reviews.llvm.org/D33722



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


[PATCH] D33722: [clang-tidy] Add checker for undelegated copy of base classes

2017-11-03 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 121477.
xazax.hun added a comment.

- Dominic said he no longer have time to continue with this patch, so I 
commandeered this revision
- Skip template instantiations
- Do not attempt fix macro expansions
- Do not attempt fix type aliases and typedef types
- Do not attempt to fix cases where the parameter is unnamed
- Use a more conservative approach and only warn for default constructors 
invoked by copy ctors. This could be refined in a followup patch.
- Skip the check for empty base classes
- Do not use matchers in the check callback
- Add tests for relevant changes
- Fix style issues in tests and docs
- Rebased for latest ToT


https://reviews.llvm.org/D33722

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/CopyConstructorInitCheck.cpp
  clang-tidy/misc/CopyConstructorInitCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-copy-constructor-init.rst
  test/clang-tidy/misc-copy-constructor-init.cpp

Index: test/clang-tidy/misc-copy-constructor-init.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-copy-constructor-init.cpp
@@ -0,0 +1,152 @@
+// RUN: %check_clang_tidy %s misc-copy-constructor-init %t
+
+class Copyable {
+public:
+  Copyable() = default;
+  Copyable(const Copyable &) = default;
+
+private:
+  int a;
+};
+
+class Copyable2 {
+public:
+  Copyable2() = default;
+  Copyable2(const Copyable2 &) = default;
+
+private:
+  int a;
+};
+
+class Copyable3 : public Copyable {
+public:
+  Copyable3() = default;
+  Copyable3(const Copyable3 &) = default;
+};
+
+template 
+class Copyable4 {
+public:
+  Copyable4() = default;
+  Copyable4(const Copyable4 &) = default;
+
+private:
+  int a;
+};
+
+template 
+class Copyable5 {
+public:
+  Copyable5() = default;
+  Copyable5(const Copyable5 &) = default;
+
+private:
+  int a;
+};
+
+class EmptyCopyable {
+public:
+  EmptyCopyable() = default;
+  EmptyCopyable(const EmptyCopyable &) = default;
+};
+
+template 
+using CopyableAlias = Copyable5;
+
+typedef Copyable5 CopyableAlias2;
+
+class X : public Copyable, public EmptyCopyable {
+  X(const X ) : Copyable(other) {}
+};
+
+class X2 : public Copyable2 {
+  X2(const X2 ) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor other than the copy constructor [misc-copy-constructor-init]
+  // CHECK-FIXES: X2(const X2 )  : Copyable2(other) {}
+};
+
+class X2_A : public Copyable2 {
+  X2_A(const X2_A &) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X2_A(const X2_A &) {}
+};
+
+class X3 : public Copyable, public Copyable2 {
+  X3(const X3 ) : Copyable(other) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X3(const X3 ) : Copyable2(other), Copyable(other) {}
+};
+
+class X4 : public Copyable {
+  X4(const X4 ) : Copyable() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X4(const X4 ) : Copyable(other) {}
+};
+
+class X5 : public Copyable3 {
+  X5(const X5 ) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X5(const X5 )  : Copyable3(other) {}
+};
+
+class X6 : public Copyable2, public Copyable3 {
+  X6(const X6 ) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X6(const X6 )  : Copyable2(other), Copyable3(other) {}
+};
+
+class X7 : public Copyable, public Copyable2 {
+  X7(const X7 ) : Copyable() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X7(const X7 ) : Copyable2(other), Copyable(other) {}
+};
+
+class X8 : public Copyable4 {
+  X8(const X8 ) : Copyable4(other) {}
+};
+
+class X9 : public Copyable4 {
+  X9(const X9 ) : Copyable4() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X9(const X9 ) : Copyable4(other) {}
+};
+
+class X10 : public Copyable4 {
+  X10(const X10 ) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X10(const X10 )  : Copyable4(other) {}
+};
+
+class X11 : public Copyable5 {
+  X11(const X11 ) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X11(const X11 )  : Copyable5(other) {}
+};
+
+class X12 : public CopyableAlias {
+  X12(const X12 ) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor
+  // CHECK-FIXES: X12(const X12 ) {}
+};
+
+template 
+class X13 : T {
+  X13(const X13 ) {}
+};
+
+template class X13;
+template class X13;
+
+#define FROMMACRO\
+  class X14 : public Copyable2 { \
+X14(const X14 ) {} \
+  };
+
+FROMMACRO
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: calling a base constructor
+
+class X15 : public CopyableAlias2 {
+  X15(const X15 ) {}
+  // CHECK-MESSAGES: 

[PATCH] D39121: [clang-tidy] Misplaced Operator in Strlen in Alloc

2017-11-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D39121#914871, @baloghadamsoftware wrote:

> I tested it on a C project (Postgres) and found no false positives.


Out of curiosity, were there any true positives, either?


https://reviews.llvm.org/D39121



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


[PATCH] D39549: [clang-format] Sort using-declarations case sensitively with a special case for '_'

2017-11-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317325: [clang-format] Sort using-declarations case 
sensitively with a special case for… (authored by krasimir).

Repository:
  rL LLVM

https://reviews.llvm.org/D39549

Files:
  cfe/trunk/lib/Format/UsingDeclarationsSorter.cpp
  cfe/trunk/unittests/Format/UsingDeclarationsSorterTest.cpp

Index: cfe/trunk/lib/Format/UsingDeclarationsSorter.cpp
===
--- cfe/trunk/lib/Format/UsingDeclarationsSorter.cpp
+++ cfe/trunk/lib/Format/UsingDeclarationsSorter.cpp
@@ -33,8 +33,27 @@
   UsingDeclaration(const AnnotatedLine *Line, const std::string )
   : Line(Line), Label(Label) {}
 
+  // Compares lexicographically with the exception that '_' is just before 'A'.
   bool operator<(const UsingDeclaration ) const {
-return StringRef(Label).compare_lower(Other.Label) < 0;
+size_t Size = Label.size();
+size_t OtherSize = Other.Label.size();
+for (size_t I = 0, E = std::min(Size, OtherSize); I < E; ++I) {
+  char Rank = rank(Label[I]);
+  char OtherRank = rank(Other.Label[I]);
+  if (Rank != OtherRank)
+return Rank < OtherRank;
+}
+return Size < OtherSize;
+  }
+
+  // Returns the position of c in a lexicographic ordering with the exception
+  // that '_' is just before 'A'.
+  static char rank(char c) {
+if (c == '_')
+  return 'A';
+if ('A' <= c && c < '_')
+  return c + 1;
+return c;
   }
 };
 
@@ -77,7 +96,7 @@
 SmallVectorImpl *UsingDeclarations,
 const SourceManager , tooling::Replacements *Fixes) {
   bool BlockAffected = false;
-  for (const UsingDeclaration& Declaration : *UsingDeclarations) {
+  for (const UsingDeclaration  : *UsingDeclarations) {
 if (Declaration.Line->Affected) {
   BlockAffected = true;
   break;
Index: cfe/trunk/unittests/Format/UsingDeclarationsSorterTest.cpp
===
--- cfe/trunk/unittests/Format/UsingDeclarationsSorterTest.cpp
+++ cfe/trunk/unittests/Format/UsingDeclarationsSorterTest.cpp
@@ -86,19 +86,25 @@
   "using a, b;"));
 }
 
-TEST_F(UsingDeclarationsSorterTest, SortsCaseInsensitively) {
+TEST_F(UsingDeclarationsSorterTest, SortsCaseSensitively) {
   EXPECT_EQ("using A;\n"
 "using a;",
 sortUsingDeclarations("using A;\n"
   "using a;"));
-  EXPECT_EQ("using a;\n"
-"using A;",
+  EXPECT_EQ("using A;\n"
+"using a;",
 sortUsingDeclarations("using a;\n"
   "using A;"));
-  EXPECT_EQ("using a;\n"
-"using B;",
+  EXPECT_EQ("using B;\n"
+"using a;",
 sortUsingDeclarations("using B;\n"
   "using a;"));
+
+  // Sorts '_' right before 'A'.
+  EXPECT_EQ("using _;\n"
+"using A;",
+sortUsingDeclarations("using A;\n"
+  "using _;"));
   EXPECT_EQ("using _;\n"
 "using a;",
 sortUsingDeclarations("using a;\n"
@@ -110,53 +116,16 @@
 
   EXPECT_EQ("using ::testing::_;\n"
 "using ::testing::Aardvark;\n"
-"using ::testing::apple::Honeycrisp;\n"
 "using ::testing::Xylophone;\n"
+"using ::testing::apple::Honeycrisp;\n"
 "using ::testing::zebra::Stripes;",
 sortUsingDeclarations("using ::testing::Aardvark;\n"
   "using ::testing::Xylophone;\n"
   "using ::testing::_;\n"
   "using ::testing::apple::Honeycrisp;\n"
   "using ::testing::zebra::Stripes;"));
 }
 
-TEST_F(UsingDeclarationsSorterTest, SortsStably) {
-  EXPECT_EQ("using a;\n"
-"using a;\n"
-"using A;\n"
-"using a;\n"
-"using A;\n"
-"using a;\n"
-"using A;\n"
-"using a;\n"
-"using B;\n"
-"using b;\n"
-"using b;\n"
-"using B;\n"
-"using b;\n"
-"using b;\n"
-"using b;\n"
-"using B;\n"
-"using b;",
-sortUsingDeclarations("using a;\n"
-  "using B;\n"
-  "using a;\n"
-  "using b;\n"
-  "using A;\n"
-  "using a;\n"
-  "using b;\n"
-  "using B;\n"
-  "using b;\n"
-  "using A;\n"
-  "using a;\n"
-  "using b;\n"
-  "using b;\n"
-  "using B;\n"
-

r317325 - [clang-format] Sort using-declarations case sensitively with a special case for '_'

2017-11-03 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Fri Nov  3 07:38:07 2017
New Revision: 317325

URL: http://llvm.org/viewvc/llvm-project?rev=317325=rev
Log:
[clang-format] Sort using-declarations case sensitively with a special case for 
'_'

Summary:
This makes clang-format sort using declarations case-sensitive with the
exception that '_' comes just before 'A'. This is better than the current case
insensitive version, because it groups uppercase names in the same namespace
together.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/lib/Format/UsingDeclarationsSorter.cpp
cfe/trunk/unittests/Format/UsingDeclarationsSorterTest.cpp

Modified: cfe/trunk/lib/Format/UsingDeclarationsSorter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UsingDeclarationsSorter.cpp?rev=317325=317324=317325=diff
==
--- cfe/trunk/lib/Format/UsingDeclarationsSorter.cpp (original)
+++ cfe/trunk/lib/Format/UsingDeclarationsSorter.cpp Fri Nov  3 07:38:07 2017
@@ -33,8 +33,27 @@ struct UsingDeclaration {
   UsingDeclaration(const AnnotatedLine *Line, const std::string )
   : Line(Line), Label(Label) {}
 
+  // Compares lexicographically with the exception that '_' is just before 'A'.
   bool operator<(const UsingDeclaration ) const {
-return StringRef(Label).compare_lower(Other.Label) < 0;
+size_t Size = Label.size();
+size_t OtherSize = Other.Label.size();
+for (size_t I = 0, E = std::min(Size, OtherSize); I < E; ++I) {
+  char Rank = rank(Label[I]);
+  char OtherRank = rank(Other.Label[I]);
+  if (Rank != OtherRank)
+return Rank < OtherRank;
+}
+return Size < OtherSize;
+  }
+
+  // Returns the position of c in a lexicographic ordering with the exception
+  // that '_' is just before 'A'.
+  static char rank(char c) {
+if (c == '_')
+  return 'A';
+if ('A' <= c && c < '_')
+  return c + 1;
+return c;
   }
 };
 
@@ -77,7 +96,7 @@ void endUsingDeclarationBlock(
 SmallVectorImpl *UsingDeclarations,
 const SourceManager , tooling::Replacements *Fixes) {
   bool BlockAffected = false;
-  for (const UsingDeclaration& Declaration : *UsingDeclarations) {
+  for (const UsingDeclaration  : *UsingDeclarations) {
 if (Declaration.Line->Affected) {
   BlockAffected = true;
   break;

Modified: cfe/trunk/unittests/Format/UsingDeclarationsSorterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/UsingDeclarationsSorterTest.cpp?rev=317325=317324=317325=diff
==
--- cfe/trunk/unittests/Format/UsingDeclarationsSorterTest.cpp (original)
+++ cfe/trunk/unittests/Format/UsingDeclarationsSorterTest.cpp Fri Nov  3 
07:38:07 2017
@@ -86,19 +86,25 @@ TEST_F(UsingDeclarationsSorterTest, Swap
   "using a, b;"));
 }
 
-TEST_F(UsingDeclarationsSorterTest, SortsCaseInsensitively) {
+TEST_F(UsingDeclarationsSorterTest, SortsCaseSensitively) {
   EXPECT_EQ("using A;\n"
 "using a;",
 sortUsingDeclarations("using A;\n"
   "using a;"));
-  EXPECT_EQ("using a;\n"
-"using A;",
+  EXPECT_EQ("using A;\n"
+"using a;",
 sortUsingDeclarations("using a;\n"
   "using A;"));
-  EXPECT_EQ("using a;\n"
-"using B;",
+  EXPECT_EQ("using B;\n"
+"using a;",
 sortUsingDeclarations("using B;\n"
   "using a;"));
+
+  // Sorts '_' right before 'A'.
+  EXPECT_EQ("using _;\n"
+"using A;",
+sortUsingDeclarations("using A;\n"
+  "using _;"));
   EXPECT_EQ("using _;\n"
 "using a;",
 sortUsingDeclarations("using a;\n"
@@ -110,8 +116,8 @@ TEST_F(UsingDeclarationsSorterTest, Sort
 
   EXPECT_EQ("using ::testing::_;\n"
 "using ::testing::Aardvark;\n"
-"using ::testing::apple::Honeycrisp;\n"
 "using ::testing::Xylophone;\n"
+"using ::testing::apple::Honeycrisp;\n"
 "using ::testing::zebra::Stripes;",
 sortUsingDeclarations("using ::testing::Aardvark;\n"
   "using ::testing::Xylophone;\n"
@@ -120,43 +126,6 @@ TEST_F(UsingDeclarationsSorterTest, Sort
   "using ::testing::zebra::Stripes;"));
 }
 
-TEST_F(UsingDeclarationsSorterTest, SortsStably) {
-  EXPECT_EQ("using a;\n"
-"using a;\n"
-"using A;\n"
-"using a;\n"
-"using A;\n"
-"using a;\n"
-"using A;\n"
-"using a;\n"
-"using B;\n"
-"using b;\n"
-"using b;\n"
-"using B;\n"
-"using b;\n"
-"using b;\n"
-  

[PATCH] D39549: [clang-format] Sort using-declarations case sensitively with a special case for '_'

2017-11-03 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg, thanks!


https://reviews.llvm.org/D39549



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


[PATCH] D39549: [clang-format] Sort using-declarations case sensitively with a special case for '_'

2017-11-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 121475.
krasimir added a comment.

- Address review comment


https://reviews.llvm.org/D39549

Files:
  lib/Format/UsingDeclarationsSorter.cpp
  unittests/Format/UsingDeclarationsSorterTest.cpp

Index: unittests/Format/UsingDeclarationsSorterTest.cpp
===
--- unittests/Format/UsingDeclarationsSorterTest.cpp
+++ unittests/Format/UsingDeclarationsSorterTest.cpp
@@ -86,19 +86,25 @@
   "using a, b;"));
 }
 
-TEST_F(UsingDeclarationsSorterTest, SortsCaseInsensitively) {
+TEST_F(UsingDeclarationsSorterTest, SortsCaseSensitively) {
   EXPECT_EQ("using A;\n"
 "using a;",
 sortUsingDeclarations("using A;\n"
   "using a;"));
-  EXPECT_EQ("using a;\n"
-"using A;",
+  EXPECT_EQ("using A;\n"
+"using a;",
 sortUsingDeclarations("using a;\n"
   "using A;"));
-  EXPECT_EQ("using a;\n"
-"using B;",
+  EXPECT_EQ("using B;\n"
+"using a;",
 sortUsingDeclarations("using B;\n"
   "using a;"));
+
+  // Sorts '_' right before 'A'.
+  EXPECT_EQ("using _;\n"
+"using A;",
+sortUsingDeclarations("using A;\n"
+  "using _;"));
   EXPECT_EQ("using _;\n"
 "using a;",
 sortUsingDeclarations("using a;\n"
@@ -110,53 +116,16 @@
 
   EXPECT_EQ("using ::testing::_;\n"
 "using ::testing::Aardvark;\n"
-"using ::testing::apple::Honeycrisp;\n"
 "using ::testing::Xylophone;\n"
+"using ::testing::apple::Honeycrisp;\n"
 "using ::testing::zebra::Stripes;",
 sortUsingDeclarations("using ::testing::Aardvark;\n"
   "using ::testing::Xylophone;\n"
   "using ::testing::_;\n"
   "using ::testing::apple::Honeycrisp;\n"
   "using ::testing::zebra::Stripes;"));
 }
 
-TEST_F(UsingDeclarationsSorterTest, SortsStably) {
-  EXPECT_EQ("using a;\n"
-"using a;\n"
-"using A;\n"
-"using a;\n"
-"using A;\n"
-"using a;\n"
-"using A;\n"
-"using a;\n"
-"using B;\n"
-"using b;\n"
-"using b;\n"
-"using B;\n"
-"using b;\n"
-"using b;\n"
-"using b;\n"
-"using B;\n"
-"using b;",
-sortUsingDeclarations("using a;\n"
-  "using B;\n"
-  "using a;\n"
-  "using b;\n"
-  "using A;\n"
-  "using a;\n"
-  "using b;\n"
-  "using B;\n"
-  "using b;\n"
-  "using A;\n"
-  "using a;\n"
-  "using b;\n"
-  "using b;\n"
-  "using B;\n"
-  "using b;\n"
-  "using A;\n"
-  "using a;"));
-}
-
 TEST_F(UsingDeclarationsSorterTest, SortsMultipleTopLevelDeclarations) {
   EXPECT_EQ("using a;\n"
 "using b;\n"
Index: lib/Format/UsingDeclarationsSorter.cpp
===
--- lib/Format/UsingDeclarationsSorter.cpp
+++ lib/Format/UsingDeclarationsSorter.cpp
@@ -33,8 +33,27 @@
   UsingDeclaration(const AnnotatedLine *Line, const std::string )
   : Line(Line), Label(Label) {}
 
+  // Compares lexicographically with the exception that '_' is just before 'A'.
   bool operator<(const UsingDeclaration ) const {
-return StringRef(Label).compare_lower(Other.Label) < 0;
+size_t Size = Label.size();
+size_t OtherSize = Other.Label.size();
+for (size_t I = 0, E = std::min(Size, OtherSize); I < E; ++I) {
+  char Rank = rank(Label[I]);
+  char OtherRank = rank(Other.Label[I]);
+  if (Rank != OtherRank)
+return Rank < OtherRank;
+}
+return Size < OtherSize;
+  }
+
+  // Returns the position of c in a lexicographic ordering with the exception
+  // that '_' is just before 'A'.
+  static char rank(char c) {
+if (c == '_')
+  return 'A';
+if ('A' <= c && c < '_')
+  return c + 1;
+return c;
   }
 };
 
@@ -77,7 +96,7 @@
 SmallVectorImpl *UsingDeclarations,
 const SourceManager , tooling::Replacements *Fixes) {
   bool BlockAffected = false;
-  for (const UsingDeclaration& Declaration : *UsingDeclarations) {
+  for (const UsingDeclaration  : *UsingDeclarations) {
 if 

[clang-tools-extra] r317322 - [clangd] Handle clangd.applyFix server-side

2017-11-03 Thread Marc-Andre Laperle via cfe-commits
Author: malaperle
Date: Fri Nov  3 06:39:15 2017
New Revision: 317322

URL: http://llvm.org/viewvc/llvm-project?rev=317322=rev
Log:
[clangd] Handle clangd.applyFix server-side

Summary:
When the user selects a fix-it (or any code action with commands), it is
possible to let the client forward the selected command to the server.
When the clangd.applyFix command is handled on the server, it can send a
workspace/applyEdit request to the client. This has the advantage that
the client doesn't explicitly have to know how to handle
clangd.applyFix. Therefore, the code to handle clangd.applyFix in the VS
Code extension (and any other Clangd client) is not required anymore.

Reviewers: ilya-biryukov, sammccall, Nebiroth, hokein

Reviewed By: hokein

Subscribers: ioeric, hokein, rwols, puremourning, bkramer, ilya-biryukov

Tags: #clang-tools-extra

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

Added:
clang-tools-extra/trunk/test/clangd/execute-command.test
Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdLSPServer.h
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
clang-tools-extra/trunk/clangd/ProtocolHandlers.h
clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
clang-tools-extra/trunk/test/clangd/fixits.test
clang-tools-extra/trunk/test/clangd/initialize-params-invalid.test
clang-tools-extra/trunk/test/clangd/initialize-params.test

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=317322=317321=317322=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Fri Nov  3 06:39:15 2017
@@ -10,27 +10,25 @@
 #include "ClangdLSPServer.h"
 #include "JSONRPCDispatcher.h"
 
+#include "llvm/Support/FormatVariadic.h"
+
 using namespace clang::clangd;
 using namespace clang;
 
 namespace {
 
-std::string
+std::vector
 replacementsToEdits(StringRef Code,
 const std::vector ) {
+  std::vector Edits;
   // Turn the replacements into the format specified by the Language Server
-  // Protocol. Fuse them into one big JSON array.
-  std::string Edits;
+  // Protocol.
   for (auto  : Replacements) {
 Range ReplacementRange = {
 offsetToPosition(Code, R.getOffset()),
 offsetToPosition(Code, R.getOffset() + R.getLength())};
-TextEdit TE = {ReplacementRange, R.getReplacementText()};
-Edits += TextEdit::unparse(TE);
-Edits += ',';
+Edits.push_back({ReplacementRange, R.getReplacementText()});
   }
-  if (!Edits.empty())
-Edits.pop_back();
 
   return Edits;
 }
@@ -47,7 +45,9 @@ void ClangdLSPServer::onInitialize(Ctx C
   "codeActionProvider": true,
   "completionProvider": {"resolveProvider": false, 
"triggerCharacters": [".",">",":"]},
   "signatureHelpProvider": {"triggerCharacters": ["(",","]},
-  "definitionProvider": true
+  "definitionProvider": true,
+  "executeCommandProvider": {"commands": [")" +
+  ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND + R"("]}
 }})");
   if (Params.rootUri && !Params.rootUri->file.empty())
 Server.setRootPath(Params.rootUri->file);
@@ -84,6 +84,34 @@ void ClangdLSPServer::onFileEvent(Ctx C,
   Server.onFileEvent(Params);
 }
 
+void ClangdLSPServer::onCommand(Ctx C, ExecuteCommandParams ) {
+  if (Params.command == ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND &&
+  Params.workspaceEdit) {
+// The flow for "apply-fix" :
+// 1. We publish a diagnostic, including fixits
+// 2. The user clicks on the diagnostic, the editor asks us for code 
actions
+// 3. We send code actions, with the fixit embedded as context
+// 4. The user selects the fixit, the editor asks us to apply it
+// 5. We unwrap the changes and send them back to the editor
+// 6. The editor applies the changes (applyEdit), and sends us a reply (but
+// we ignore it)
+
+ApplyWorkspaceEditParams ApplyEdit;
+ApplyEdit.edit = *Params.workspaceEdit;
+C.reply("\"Fix applied.\"");
+// We don't need the response so id == 1 is OK.
+// Ideally, we would wait for the response and if there is no error, we
+// would reply success/failure to the original RPC.
+C.call("workspace/applyEdit", 
ApplyWorkspaceEditParams::unparse(ApplyEdit));
+  } else {
+// We should not get here because ExecuteCommandParams would not have
+// parsed in the first place and this handler should not be called. But if
+// more commands are added, this will be here has a safe guard.
+C.replyError(
+1, 

[PATCH] D39549: [clang-format] Sort using-declarations case sensitively with a special case for '_'

2017-11-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

How about this trade-off? I don't really want to re-implement comparison (it 
makes the code harder to read), so I replaced the state with an explicit 
computation.


https://reviews.llvm.org/D39549



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


[PATCH] D39549: [clang-format] Sort using-declarations case sensitively with a special case for '_'

2017-11-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 121465.
krasimir added a comment.

- Remove SortLabel


https://reviews.llvm.org/D39549

Files:
  lib/Format/UsingDeclarationsSorter.cpp
  unittests/Format/UsingDeclarationsSorterTest.cpp

Index: unittests/Format/UsingDeclarationsSorterTest.cpp
===
--- unittests/Format/UsingDeclarationsSorterTest.cpp
+++ unittests/Format/UsingDeclarationsSorterTest.cpp
@@ -86,19 +86,25 @@
   "using a, b;"));
 }
 
-TEST_F(UsingDeclarationsSorterTest, SortsCaseInsensitively) {
+TEST_F(UsingDeclarationsSorterTest, SortsCaseSensitively) {
   EXPECT_EQ("using A;\n"
 "using a;",
 sortUsingDeclarations("using A;\n"
   "using a;"));
-  EXPECT_EQ("using a;\n"
-"using A;",
+  EXPECT_EQ("using A;\n"
+"using a;",
 sortUsingDeclarations("using a;\n"
   "using A;"));
-  EXPECT_EQ("using a;\n"
-"using B;",
+  EXPECT_EQ("using B;\n"
+"using a;",
 sortUsingDeclarations("using B;\n"
   "using a;"));
+
+  // Sorts '_' right before 'A'.
+  EXPECT_EQ("using _;\n"
+"using A;",
+sortUsingDeclarations("using A;\n"
+  "using _;"));
   EXPECT_EQ("using _;\n"
 "using a;",
 sortUsingDeclarations("using a;\n"
@@ -110,53 +116,16 @@
 
   EXPECT_EQ("using ::testing::_;\n"
 "using ::testing::Aardvark;\n"
-"using ::testing::apple::Honeycrisp;\n"
 "using ::testing::Xylophone;\n"
+"using ::testing::apple::Honeycrisp;\n"
 "using ::testing::zebra::Stripes;",
 sortUsingDeclarations("using ::testing::Aardvark;\n"
   "using ::testing::Xylophone;\n"
   "using ::testing::_;\n"
   "using ::testing::apple::Honeycrisp;\n"
   "using ::testing::zebra::Stripes;"));
 }
 
-TEST_F(UsingDeclarationsSorterTest, SortsStably) {
-  EXPECT_EQ("using a;\n"
-"using a;\n"
-"using A;\n"
-"using a;\n"
-"using A;\n"
-"using a;\n"
-"using A;\n"
-"using a;\n"
-"using B;\n"
-"using b;\n"
-"using b;\n"
-"using B;\n"
-"using b;\n"
-"using b;\n"
-"using b;\n"
-"using B;\n"
-"using b;",
-sortUsingDeclarations("using a;\n"
-  "using B;\n"
-  "using a;\n"
-  "using b;\n"
-  "using A;\n"
-  "using a;\n"
-  "using b;\n"
-  "using B;\n"
-  "using b;\n"
-  "using A;\n"
-  "using a;\n"
-  "using b;\n"
-  "using b;\n"
-  "using B;\n"
-  "using b;\n"
-  "using A;\n"
-  "using a;"));
-}
-
 TEST_F(UsingDeclarationsSorterTest, SortsMultipleTopLevelDeclarations) {
   EXPECT_EQ("using a;\n"
 "using b;\n"
Index: lib/Format/UsingDeclarationsSorter.cpp
===
--- lib/Format/UsingDeclarationsSorter.cpp
+++ lib/Format/UsingDeclarationsSorter.cpp
@@ -33,8 +33,27 @@
   UsingDeclaration(const AnnotatedLine *Line, const std::string )
   : Line(Line), Label(Label) {}
 
+  // Compares lexicographically with the exception that '_' is just before 'A'.
   bool operator<(const UsingDeclaration ) const {
-return StringRef(Label).compare_lower(Other.Label) < 0;
+return computeSortLabel(Label) < computeSortLabel(Other.Label);
+  }
+
+  // Returns the position of c in a lexicographic ordering with the exception
+  // that '_' is just before 'A'.
+  static char rank(char c) {
+if (c == '_')
+  return 'A';
+if ('A' <= c && c < '_')
+  return c + 1;
+return c;
+  }
+
+  static std::string computeSortLabel(const std::string ) {
+std::string SortLabel;
+SortLabel.reserve(Label.size());
+for (char C : Label)
+  SortLabel += rank(C);
+return SortLabel;
   }
 };
 
@@ -77,7 +96,7 @@
 SmallVectorImpl *UsingDeclarations,
 const SourceManager , tooling::Replacements *Fixes) {
   bool BlockAffected = false;
-  for (const UsingDeclaration& Declaration : *UsingDeclarations) {
+  for (const UsingDeclaration  : *UsingDeclarations) {
 if (Declaration.Line->Affected) {
   BlockAffected = true;
   break;

[PATCH] D35109: [Analyzer] SValBuilder Comparison Rearrangement

2017-11-03 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Thank you for you work! Probably I did some mistake because my MAX/4solution 
did not work when I it earlier. Your solution seems to work. For the iterator 
checkers this is surely enough. Should I upload my patch patched with your one?


https://reviews.llvm.org/D35109



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


[PATCH] D39588: Distro: initial support for alpine

2017-11-03 Thread Martell Malone via Phabricator via cfe-commits
martell updated this revision to Diff 121462.
martell edited the summary of this revision.

Repository:
  rL LLVM

https://reviews.llvm.org/D39588

Files:
  include/clang/Driver/Distro.h
  lib/Driver/Distro.cpp
  lib/Driver/ToolChains/Linux.cpp
  test/Driver/pic.c


Index: test/Driver/pic.c
===
--- test/Driver/pic.c
+++ test/Driver/pic.c
@@ -152,6 +152,22 @@
 // RUN: %clang %s -target i386-unknown-linux -shared -pie -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIE
 //
+// On Musl Linux, PIE is enabled by default, but can be disabled.
+// RUN: %clang -c %s -target x86_64-linux-musl -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target i686-linux-musl -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target armv6-linux-musleabihf -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target armv7-linux-musleabihf -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang %s -target x86_64-linux-musl -nopie -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIE
+// RUN: %clang %s -target x86_64-linux-musl -pie -nopie -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIE
+// RUN: %clang %s -target x86_64-linux-musl -nopie -pie -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+//
 // Darwin is a beautiful and unique snowflake when it comes to these flags.
 // When targeting a 32-bit darwin system, only level 2 is supported. On 64-bit
 // targets, there is simply nothing you can do, there is no PIE, there is only
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -210,7 +210,12 @@
 
   Distro Distro(D.getVFS());
 
-  if (Distro.IsOpenSUSE() || Distro.IsUbuntu()) {
+  if (Distro.IsAlpineLinux()) {
+ExtraOpts.push_back("-z");
+ExtraOpts.push_back("now");
+  }
+
+  if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux()) {
 ExtraOpts.push_back("-z");
 ExtraOpts.push_back("relro");
   }
@@ -232,7 +237,7 @@
   // Android loader does not support .gnu.hash.
   // Hexagon linker/loader does not support .gnu.hash
   if (!IsMips && !IsAndroid && !IsHexagon) {
-if (Distro.IsRedhat() || Distro.IsOpenSUSE() ||
+if (Distro.IsRedhat() || Distro.IsOpenSUSE() || Distro.IsAlpineLinux() ||
 (Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick))
   ExtraOpts.push_back("--hash-style=gnu");
 
@@ -812,7 +817,7 @@
 
 bool Linux::isPIEDefault() const {
   return (getTriple().isAndroid() && !getTriple().isAndroidVersionLT(16)) ||
- getSanitizerArgs().requiresPIE();
+  getTriple().isMusl() || getSanitizerArgs().requiresPIE();
 }
 
 SanitizerMask Linux::getSupportedSanitizers() const {
Index: lib/Driver/Distro.cpp
===
--- lib/Driver/Distro.cpp
+++ lib/Driver/Distro.cpp
@@ -129,6 +129,9 @@
   if (VFS.exists("/etc/exherbo-release"))
 return Distro::Exherbo;
 
+  if (VFS.exists("/etc/alpine-release"))
+return Distro::AlpineLinux;
+
   if (VFS.exists("/etc/arch-release"))
 return Distro::ArchLinux;
 
Index: include/clang/Driver/Distro.h
===
--- include/clang/Driver/Distro.h
+++ include/clang/Driver/Distro.h
@@ -26,6 +26,7 @@
 // NB: Releases of a particular Linux distro should be kept together
 // in this enum, because some tests are done by integer comparison against
 // the first and last known member in the family, e.g. IsRedHat().
+AlpineLinux,
 ArchLinux,
 DebianLenny,
 DebianSqueeze,
@@ -116,6 +117,10 @@
 return DistroVal >= UbuntuHardy && DistroVal <= UbuntuBionic;
   }
 
+  bool IsAlpineLinux() const {
+return DistroVal == AlpineLinux;
+  }
+
   /// @}
 };
 


Index: test/Driver/pic.c
===
--- test/Driver/pic.c
+++ test/Driver/pic.c
@@ -152,6 +152,22 @@
 // RUN: %clang %s -target i386-unknown-linux -shared -pie -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIE
 //
+// On Musl Linux, PIE is enabled by default, but can be disabled.
+// RUN: %clang -c %s -target x86_64-linux-musl -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target i686-linux-musl -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target armv6-linux-musleabihf -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target armv7-linux-musleabihf -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang %s -target x86_64-linux-musl -nopie -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIE
+// RUN: %clang %s -target x86_64-linux-musl -pie 

[PATCH] D39332: [clang-refactor] Introduce a new rename rule for qualified symbols

2017-11-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: lib/Tooling/Refactoring/Rename/RenamingAction.cpp:101
+  std::string NewQualifiedName) {
+  return QualifiedRenameRule(std::move(OldQualifiedName),
+ std::move(NewQualifiedName));

arphaman wrote:
> ioeric wrote:
> > hokein wrote:
> > > arphaman wrote:
> > > > It might be better to find the declaration (and report error if needed) 
> > > > during in initiation, and then pass the `ND` to the class. Maybe then 
> > > > both `RenameOccurrences` and `QualifiedRenameRule` could subclass from 
> > > > one base class that actually does just this:
> > > > 
> > > > ``` 
> > > > auto USRs = getUSRsForDeclaration(ND, Context.getASTContext());
> > > >   assert(!USRs.empty());
> > > >   return tooling::createRenameAtomicChanges(
> > > >   USRs, NewQualifiedName, 
> > > > Context.getASTContext().getTranslationUnitDecl());
> > > > ```
> > > Done. Introduced a common interface `USRRenameRule`.
> > `USRRenameRule` doesn't seem to be a very useful abstraction. I think what 
> > Alex proposed is a base class that implements `createSourceReplacements` 
> > which could be shared by both `RenameOccurrences` and 
> > `QualifiedRenameRule`. Intuitively, un-qualified rename is a special case 
> > of qualified rename (maybe?), where namespace is not changed.
> Yep, I meant that indeed.
Ah, sorry for the misunderstanding. 

Unfortunately, `RenameOccurrences` and `QualifiedRenameRule` could not share 
the same `createSourceReplacements` implementation, 

* Their supported use cases are different. `QualifiedRenameRule` only supports 
renaming class, function, enums, alias and class members, which doesn't cover 
all the cases of `RenameOccurrences` (like renaming local variable in function 
body).

* we have separated implementations in the code 
base(`createRenameAtomicChanges` for qualified rename, 
`createRenameReplacements` for un-qualified rename). The implementation of 
qualified rename does more things, including calculating the shortest prefix 
qualifiers, getting correct range of replacement.  





Comment at: lib/Tooling/Refactoring/Rename/RenamingAction.cpp:115
+  /*Description=*/
+  "Finds and renames qualified symbols in code with no indexer support",
+  };

ioeric wrote:
> We should also document the behavior when namespace is changed. What would 
> happen to symbol definitions and symbol references?
Sound good! Done.


https://reviews.llvm.org/D39332



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


[PATCH] D39332: [clang-refactor] Introduce a new rename rule for qualified symbols

2017-11-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 121456.
hokein marked an inline comment as done.
hokein added a comment.

Document the qualified rename.


https://reviews.llvm.org/D39332

Files:
  include/clang/Tooling/Refactoring/Rename/RenamingAction.h
  lib/Tooling/Refactoring/RefactoringActions.cpp
  lib/Tooling/Refactoring/Rename/RenamingAction.cpp
  test/Refactor/LocalRename/QualifiedRename.cpp
  tools/clang-refactor/ClangRefactor.cpp

Index: tools/clang-refactor/ClangRefactor.cpp
===
--- tools/clang-refactor/ClangRefactor.cpp
+++ tools/clang-refactor/ClangRefactor.cpp
@@ -283,10 +283,10 @@
 
   const RefactoringActionRules () const { return ActionRules; }
 
-  /// Parses the command-line arguments that are specific to this rule.
+  /// Parses the "-selection" command-line argument.
   ///
   /// \returns true on error, false otherwise.
-  bool parseArguments() {
+  bool parseSelectionArgument() {
 if (Selection) {
   ParsedSelection = SourceSelectionArgument::fromString(*Selection);
   if (!ParsedSelection)
@@ -464,20 +464,20 @@
 SmallVector MatchingRules;
 llvm::StringSet<> MissingOptions;
 
-bool HasSelection = false;
 for (const auto  : Subcommand.getActionRules()) {
-  bool SelectionMatches = true;
-  if (Rule->hasSelectionRequirement()) {
-HasSelection = true;
-if (!Subcommand.getSelection()) {
-  MissingOptions.insert("selection");
-  SelectionMatches = false;
-}
-  }
   CommandLineRefactoringOptionVisitor Visitor(Subcommand.getOptions());
   Rule->visitRefactoringOptions(Visitor);
-  if (SelectionMatches && Visitor.getMissingRequiredOptions().empty()) {
-MatchingRules.push_back(Rule.get());
+  if (Visitor.getMissingRequiredOptions().empty()) {
+if (!Rule->hasSelectionRequirement()) {
+  MatchingRules.push_back(Rule.get());
+} else {
+  Subcommand.parseSelectionArgument();
+  if (Subcommand.getSelection()) {
+MatchingRules.push_back(Rule.get());
+  } else {
+MissingOptions.insert("selection");
+  }
+}
 continue;
   }
   for (const RefactoringOption *Opt : Visitor.getMissingRequiredOptions())
@@ -490,6 +490,14 @@
 llvm::errs() << "  missing '-" << Opt.getKey() << "' option\n";
   return true;
 }
+if (MatchingRules.size() > 1) {
+  llvm::errs() << "error: find multiple matched action rules for the given "
+  "arguments\n";
+  return true;
+}
+
+RefactoringActionRule* MatchingRule = MatchingRules[0];
+bool HasSelection = MatchingRule->hasSelectionRequirement();
 
 ClangRefactorConsumer Consumer;
 bool HasFailed = false;
@@ -499,16 +507,7 @@
 
   auto InvokeRule = [&](RefactoringResultConsumer ) {
 logInvocation(Subcommand, Context);
-for (RefactoringActionRule *Rule : MatchingRules) {
-  if (!Rule->hasSelectionRequirement())
-continue;
-  Rule->invoke(Consumer, Context);
-  return;
-}
-// FIXME (Alex L): If more than one initiation succeeded, then the
-// rules are ambiguous.
-llvm_unreachable(
-"The action must have at least one selection rule");
+MatchingRule->invoke(Consumer, Context);
   };
 
   std::unique_ptr CustomConsumer;
@@ -530,7 +529,8 @@
 ActiveConsumer.endTU();
 return;
   }
-  // FIXME (Alex L): Implement non-selection based invocation path.
+
+  InvokeRule(ActiveConsumer);
   ActiveConsumer.endTU();
 }))
   return true;
@@ -567,8 +567,6 @@
   }
   RefactoringActionSubcommand  = **It;
 
-  if (ActionCommand.parseArguments())
-return 1;
   if (Tool.invokeAction(ActionCommand, Options.getCompilations(),
 Options.getSourcePathList()))
 return 1;
Index: test/Refactor/LocalRename/QualifiedRename.cpp
===
--- /dev/null
+++ test/Refactor/LocalRename/QualifiedRename.cpp
@@ -0,0 +1,24 @@
+// RUN: clang-refactor local-rename -old-qualified-name="foo::A" -new-qualified-name="bar::B" %s -- -std=c++11 2>&1 | grep -v CHECK | FileCheck %s
+
+namespace foo {
+class A {};
+}
+// CHECK: namespace foo {
+// CHECK-NEXT: class B {};
+// CHECK-NEXT: }
+
+namespace bar {
+void f(foo::A* a) {
+  foo::A b;
+}
+// CHECK: void f(B* a) {
+// CHECK-NEXT:   B b;
+// CHECK-NEXT: }
+}
+
+void f(foo::A* a) {
+  foo::A b;
+}
+// CHECK: void f(bar::B* a) {
+// CHECK-NEXT:   bar::B b;
+// CHECK-NEXT: }
Index: lib/Tooling/Refactoring/Rename/RenamingAction.cpp
===
--- lib/Tooling/Refactoring/Rename/RenamingAction.cpp
+++ lib/Tooling/Refactoring/Rename/RenamingAction.cpp
@@ -31,6 +31,8 @@
 #include 

[PATCH] D39342: [Bash-autocompletion] Pass all flags in shell command-line to Clang

2017-11-03 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 121449.
yamaguchi added a comment.

Made a trivial fix in the testcase


https://reviews.llvm.org/D39342

Files:
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/autocomplete.c
  clang/utils/bash-autocomplete.sh
  llvm/lib/Option/OptTable.cpp

Index: llvm/lib/Option/OptTable.cpp
===
--- llvm/lib/Option/OptTable.cpp
+++ llvm/lib/Option/OptTable.cpp
@@ -219,7 +219,7 @@
 
 std::vector Result;
 for (StringRef Val : Candidates)
-  if (Val.startswith(Arg))
+  if (Val.startswith(Arg) && Arg.compare(Val))
 Result.push_back(Val);
 return Result;
   }
@@ -240,7 +240,7 @@
   std::string S = std::string(In.Prefixes[I]) + std::string(In.Name) + "\t";
   if (In.HelpText)
 S += In.HelpText;
-  if (StringRef(S).startswith(Cur))
+  if (StringRef(S).startswith(Cur) && S.compare(std::string(Cur) + "\t"))
 Ret.push_back(S);
 }
   }
Index: clang/utils/bash-autocomplete.sh
===
--- clang/utils/bash-autocomplete.sh
+++ clang/utils/bash-autocomplete.sh
@@ -25,35 +25,16 @@
 w2="${COMP_WORDS[$cword - 2]}"
   fi
 
-  # Clang want to know if -cc1 or -Xclang option is specified or not, because we don't want to show
-  # cc1 options otherwise.
-  if [[ "${COMP_WORDS[1]}" == "-cc1" || "$w1" == "-Xclang" ]]; then
-arg="#"
-  fi
-
-  # bash always separates '=' as a token even if there's no space before/after '='.
-  # On the other hand, '=' is just a regular character for clang options that
-  # contain '='. For example, "-stdlib=" is defined as is, instead of "-stdlib" and "=".
-  # So, we need to partially undo bash tokenization here for integrity.
-  if [[ "$cur" == -* ]]; then
-# -foo
-arg="$arg$cur"
-  elif [[ "$w1" == -*  && "$cur" == '=' ]]; then
-# -foo=
-arg="$arg$w1=,"
-  elif [[ "$cur" == -*= ]]; then
-# -foo=
-arg="$arg$cur,"
-  elif [[ "$w1" == -* ]]; then
-# -foo  or -foo bar
-arg="$arg$w1,$cur"
-  elif [[ "$w2" == -* && "$w1" == '=' ]]; then
-# -foo=bar
-arg="$arg$w2=,$cur"
-  elif [[ ${cur: -1} != '=' && ${cur/=} != $cur ]]; then
-# -foo=bar
-arg="$arg${cur%=*}=,${cur#*=}"
-  fi
+  # Pass all the current command-line flags to clang, so that clang can handle
+  # these internally.
+  # '=' is separated differently by bash, so we have to concat them without ','
+  for i in `seq 1 $cword`; do
+if [[ $i == $cword || "${COMP_WORDS[$(($i+1))]}" == '=' ]]; then
+  arg="$arg${COMP_WORDS[$i]}"
+else
+  arg="$arg${COMP_WORDS[$i]},"
+fi
+  done
 
   # expand ~ to $HOME
   eval local path=${COMP_WORDS[0]}
@@ -67,7 +48,7 @@
 
   # When clang does not emit any possible autocompletion, or user pushed tab after " ",
   # just autocomplete files.
-  if [[ "$flags" == "$(echo -e '\n')" || "$arg" == "" ]]; then
+  if [[ "$flags" == "$(echo -e '\n')" ]]; then
 # If -foo= and there was no possible values, autocomplete files.
 [[ "$cur" == '=' || "$cur" == -*= ]] && cur=""
 _clang_filedir
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -3,41 +3,36 @@
 // add/modify flags, change HelpTexts or the values of some flags.
 
 // Some corner cases.
-// RUN: %clang --autocomplete= | FileCheck %s -check-prefix=ALL_FLAGS
-// RUN: %clang --autocomplete=# | FileCheck %s -check-prefix=ALL_FLAGS
-// Let's pick some example flags that are hopefully unlikely to change.
-// ALL_FLAGS: -fast
-// ALL_FLAGS: -fastcp
-// ALL_FLAGS: -fastf
 // Just test that this doesn't crash:
+// RUN: %clang --autocomplete=
 // RUN: %clang --autocomplete=,
 // RUN: %clang --autocomplete==
 // RUN: %clang --autocomplete=,,
 // RUN: %clang --autocomplete=-
 
 // RUN: %clang --autocomplete=-fsyn | FileCheck %s -check-prefix=FSYN
 // FSYN: -fsyntax-only
-// RUN: %clang --autocomplete=-std= | FileCheck %s -check-prefix=STD
+// RUN: %clang --autocomplete=-std | FileCheck %s -check-prefix=STD
 // STD: -std= Language standard to compile for
 // RUN: %clang --autocomplete=foo | FileCheck %s -check-prefix=FOO
 // FOO-NOT: foo
 // RUN: %clang --autocomplete=-stdlib=,l | FileCheck %s -check-prefix=STDLIB
 // STDLIB: libc++
 // STDLIB-NEXT: libstdc++
-// RUN: %clang --autocomplete=-stdlib=, | FileCheck %s -check-prefix=STDLIBALL
+// RUN: %clang --autocomplete=-stdlib= | FileCheck %s -check-prefix=STDLIBALL
 // STDLIBALL: libc++
 // STDLIBALL-NEXT: libstdc++
 // STDLIBALL-NEXT: platform
 // RUN: %clang --autocomplete=-meabi,d | FileCheck %s -check-prefix=MEABI
 // MEABI: default
-// RUN: %clang --autocomplete=-meabi, | FileCheck %s -check-prefix=MEABIALL
+// RUN: %clang --autocomplete=-meabi | FileCheck %s -check-prefix=MEABIALL
 // MEABIALL: 4
 // MEABIALL-NEXT: 5
 // MEABIALL-NEXT: default
 // 

[PATCH] D39419: Fix crash when parsing objective-c++ containing invalid lambda

2017-11-03 Thread Jan Korous via Phabricator via cfe-commits
jkorous-apple updated this revision to Diff 121448.
jkorous-apple added a comment.

newline at the end of test file


https://reviews.llvm.org/D39419

Files:
  lib/Parse/ParseExprCXX.cpp
  test/Parser/objcxx11-invalid-lambda.cpp


Index: test/Parser/objcxx11-invalid-lambda.cpp
===
--- /dev/null
+++ test/Parser/objcxx11-invalid-lambda.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -x objective-c++ -std=c++11 %s
+
+void foo() {  // expected-note {{to match this '{'}}
+  int bar;
+  auto baz = [
+  bar(  // expected-note {{to match this '('}} expected-note {{to match 
this '('}}
+foo_undeclared() // expected-error{{use of undeclared identifier 
'foo_undeclared'}} expected-error{{use of undeclared identifier 
'foo_undeclared'}}
+  /* ) */
+] () { };   // expected-error{{expected ')'}}
+}   // expected-error{{expected ')'}} expected-error{{expected ';' 
at end of declaration}} expected-error{{expected '}'}}
Index: lib/Parse/ParseExprCXX.cpp
===
--- lib/Parse/ParseExprCXX.cpp
+++ lib/Parse/ParseExprCXX.cpp
@@ -991,27 +991,34 @@
 ///
 /// Returns true if it hit something unexpected.
 bool Parser::TryParseLambdaIntroducer(LambdaIntroducer ) {
-  TentativeParsingAction PA(*this);
+  {
+bool SkippedInits = false;
+TentativeParsingAction PA1(*this);
 
-  bool SkippedInits = false;
-  Optional DiagID(ParseLambdaIntroducer(Intro, ));
+if (ParseLambdaIntroducer(Intro, )) {
+  PA1.Revert();
+  return true;
+}
 
-  if (DiagID) {
-PA.Revert();
-return true;
+if (!SkippedInits) {
+  PA1.Commit();
+  return false;
+}
+
+PA1.Revert();
   }
 
-  if (SkippedInits) {
-// Parse it again, but this time parse the init-captures too.
-PA.Revert();
-Intro = LambdaIntroducer();
-DiagID = ParseLambdaIntroducer(Intro);
-assert(!DiagID && "parsing lambda-introducer failed on reparse");
+  // Try to parse it again, but this time parse the init-captures too.
+  Intro = LambdaIntroducer();
+  TentativeParsingAction PA2(*this);
+
+  if (!ParseLambdaIntroducer(Intro)) {
+PA2.Commit();
 return false;
   }
 
-  PA.Commit();
-  return false;
+  PA2.Revert();
+  return true;
 }
 
 static void


Index: test/Parser/objcxx11-invalid-lambda.cpp
===
--- /dev/null
+++ test/Parser/objcxx11-invalid-lambda.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -x objective-c++ -std=c++11 %s
+
+void foo() {  // expected-note {{to match this '{'}}
+  int bar;
+  auto baz = [
+  bar(  // expected-note {{to match this '('}} expected-note {{to match this '('}}
+foo_undeclared() // expected-error{{use of undeclared identifier 'foo_undeclared'}} expected-error{{use of undeclared identifier 'foo_undeclared'}}
+  /* ) */
+] () { };   // expected-error{{expected ')'}}
+}   // expected-error{{expected ')'}} expected-error{{expected ';' at end of declaration}} expected-error{{expected '}'}}
Index: lib/Parse/ParseExprCXX.cpp
===
--- lib/Parse/ParseExprCXX.cpp
+++ lib/Parse/ParseExprCXX.cpp
@@ -991,27 +991,34 @@
 ///
 /// Returns true if it hit something unexpected.
 bool Parser::TryParseLambdaIntroducer(LambdaIntroducer ) {
-  TentativeParsingAction PA(*this);
+  {
+bool SkippedInits = false;
+TentativeParsingAction PA1(*this);
 
-  bool SkippedInits = false;
-  Optional DiagID(ParseLambdaIntroducer(Intro, ));
+if (ParseLambdaIntroducer(Intro, )) {
+  PA1.Revert();
+  return true;
+}
 
-  if (DiagID) {
-PA.Revert();
-return true;
+if (!SkippedInits) {
+  PA1.Commit();
+  return false;
+}
+
+PA1.Revert();
   }
 
-  if (SkippedInits) {
-// Parse it again, but this time parse the init-captures too.
-PA.Revert();
-Intro = LambdaIntroducer();
-DiagID = ParseLambdaIntroducer(Intro);
-assert(!DiagID && "parsing lambda-introducer failed on reparse");
+  // Try to parse it again, but this time parse the init-captures too.
+  Intro = LambdaIntroducer();
+  TentativeParsingAction PA2(*this);
+
+  if (!ParseLambdaIntroducer(Intro)) {
+PA2.Commit();
 return false;
   }
 
-  PA.Commit();
-  return false;
+  PA2.Revert();
+  return true;
 }
 
 static void
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39419: Fix crash when parsing objective-c++ containing invalid lambda

2017-11-03 Thread Jan Korous via Phabricator via cfe-commits
jkorous-apple added inline comments.



Comment at: lib/Parse/ParseExprCXX.cpp:1020
 
-  PA.Commit();
-  return false;
+  PA2.Revert();
+  return true;

arphaman wrote:
> Just to clarify: It seems like this revert (in addition to two TPAs) is the 
> main addition. Did we hit the assertion previously with the crash?
Yes, the crash was done by this assert.
Two TPAs are needed because once TPA is reverted it is not active anymore and 
cannot be committed. As far as I understand it the assert is not necessary 
since we are parsing just tentatively and using return value for error 
signaling.



Comment at: test/Parser/objcxx11-invalid-lambda.cpp:11
+}   // expected-error{{expected ')'}} expected-error{{expected ';' 
at end of declaration}} expected-error{{expected '}'}}
\ No newline at end of file


arphaman wrote:
> Nit: missing newline.
Thanks, will add one.


https://reviews.llvm.org/D39419



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


r317308 - [preamble] Also record the "skipping" state of the preprocessor

2017-11-03 Thread Erik Verbruggen via cfe-commits
Author: erikjv
Date: Fri Nov  3 02:40:07 2017
New Revision: 317308

URL: http://llvm.org/viewvc/llvm-project?rev=317308=rev
Log:
[preamble] Also record the "skipping" state of the preprocessor

When a preamble ends in a conditional preprocessor block that is being
skipped, the preprocessor needs to continue skipping that block when
the preamble is used.

This fixes PR34570.

Added:
cfe/trunk/test/Index/preamble-conditionals-skipping.cpp
Modified:
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/Index/preamble-conditionals-inverted.cpp

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=317308=317307=317308=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Fri Nov  3 02:40:07 2017
@@ -286,6 +286,23 @@ class Preprocessor {
   /// This is used when loading a precompiled preamble.
   std::pair SkipMainFilePreamble;
 
+public:
+  struct PreambleSkipInfo {
+PreambleSkipInfo(SourceLocation HashTokenLoc, SourceLocation IfTokenLoc,
+ bool FoundNonSkipPortion, bool FoundElse,
+ SourceLocation ElseLoc)
+: HashTokenLoc(HashTokenLoc), IfTokenLoc(IfTokenLoc),
+  FoundNonSkipPortion(FoundNonSkipPortion), FoundElse(FoundElse),
+  ElseLoc(ElseLoc) {}
+
+SourceLocation HashTokenLoc;
+SourceLocation IfTokenLoc;
+bool FoundNonSkipPortion;
+bool FoundElse;
+SourceLocation ElseLoc;
+  };
+
+private:
   class PreambleConditionalStackStore {
 enum State {
   Off = 0,
@@ -319,6 +336,12 @@ class Preprocessor {
 
 bool hasRecordedPreamble() const { return !ConditionalStack.empty(); }
 
+bool reachedEOFWhileSkipping() const { return SkipInfo.hasValue(); }
+
+void clearSkipInfo() { SkipInfo.reset(); }
+
+llvm::Optional SkipInfo;
+
   private:
 SmallVector ConditionalStack;
 State ConditionalStackState;
@@ -1839,7 +1862,7 @@ private:
   /// \p FoundElse is false, then \#else directives are ok, if not, then we 
have
   /// already seen one so a \#else directive is a duplicate.  When this 
returns,
   /// the caller can lex the first valid token.
-  void SkipExcludedConditionalBlock(const Token ,
+  void SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
 SourceLocation IfTokenLoc,
 bool FoundNonSkipPortion, bool FoundElse,
 SourceLocation ElseLoc = SourceLocation());
@@ -2019,9 +2042,15 @@ public:
 PreambleConditionalStack.setStack(s);
   }
 
-  void setReplayablePreambleConditionalStack(ArrayRef s) {
+  void setReplayablePreambleConditionalStack(ArrayRef s,
+ llvm::Optional 
SkipInfo) {
 PreambleConditionalStack.startReplaying();
 PreambleConditionalStack.setStack(s);
+PreambleConditionalStack.SkipInfo = SkipInfo;
+  }
+
+  llvm::Optional getPreambleSkipInfo() const {
+return PreambleConditionalStack.SkipInfo;
   }
 
 private:

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=317308=317307=317308=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Fri Nov  3 02:40:07 2017
@@ -350,7 +350,7 @@ void Preprocessor::CheckEndOfDirective(c
 /// If ElseOk is true, then \#else directives are ok, if not, then we have
 /// already seen one so a \#else directive is a duplicate.  When this returns,
 /// the caller can lex the first valid token.
-void Preprocessor::SkipExcludedConditionalBlock(const Token ,
+void Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
 SourceLocation IfTokenLoc,
 bool FoundNonSkipPortion,
 bool FoundElse,
@@ -358,8 +358,11 @@ void Preprocessor::SkipExcludedCondition
   ++NumSkipped;
   assert(!CurTokenLexer && CurPPLexer && "Lexing a macro, not a file?");
 
-  CurPPLexer->pushConditionalLevel(IfTokenLoc, /*isSkipping*/false,
- FoundNonSkipPortion, FoundElse);
+  if (PreambleConditionalStack.reachedEOFWhileSkipping())
+PreambleConditionalStack.clearSkipInfo();
+  else
+CurPPLexer->pushConditionalLevel(IfTokenLoc, /*isSkipping*/ false,
+ FoundNonSkipPortion, FoundElse);
 
   if (CurPTHLexer) {
 PTHSkipExcludedConditionalBlock();
@@ -385,6 +388,9 @@ 

[PATCH] D39342: [Bash-autocompletion] Pass all flags in shell command-line to Clang

2017-11-03 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 121444.
yamaguchi added a comment.
Herald added a subscriber: hiraditya.

Update diff. Pass all flags just with "," including values.


https://reviews.llvm.org/D39342

Files:
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/autocomplete.c
  clang/utils/bash-autocomplete.sh
  llvm/lib/Option/OptTable.cpp

Index: llvm/lib/Option/OptTable.cpp
===
--- llvm/lib/Option/OptTable.cpp
+++ llvm/lib/Option/OptTable.cpp
@@ -219,7 +219,7 @@
 
 std::vector Result;
 for (StringRef Val : Candidates)
-  if (Val.startswith(Arg))
+  if (Val.startswith(Arg) && Arg.compare(Val))
 Result.push_back(Val);
 return Result;
   }
@@ -240,7 +240,7 @@
   std::string S = std::string(In.Prefixes[I]) + std::string(In.Name) + "\t";
   if (In.HelpText)
 S += In.HelpText;
-  if (StringRef(S).startswith(Cur))
+  if (StringRef(S).startswith(Cur) && S.compare(std::string(Cur) + "\t"))
 Ret.push_back(S);
 }
   }
Index: clang/utils/bash-autocomplete.sh
===
--- clang/utils/bash-autocomplete.sh
+++ clang/utils/bash-autocomplete.sh
@@ -25,35 +25,16 @@
 w2="${COMP_WORDS[$cword - 2]}"
   fi
 
-  # Clang want to know if -cc1 or -Xclang option is specified or not, because we don't want to show
-  # cc1 options otherwise.
-  if [[ "${COMP_WORDS[1]}" == "-cc1" || "$w1" == "-Xclang" ]]; then
-arg="#"
-  fi
-
-  # bash always separates '=' as a token even if there's no space before/after '='.
-  # On the other hand, '=' is just a regular character for clang options that
-  # contain '='. For example, "-stdlib=" is defined as is, instead of "-stdlib" and "=".
-  # So, we need to partially undo bash tokenization here for integrity.
-  if [[ "$cur" == -* ]]; then
-# -foo
-arg="$arg$cur"
-  elif [[ "$w1" == -*  && "$cur" == '=' ]]; then
-# -foo=
-arg="$arg$w1=,"
-  elif [[ "$cur" == -*= ]]; then
-# -foo=
-arg="$arg$cur,"
-  elif [[ "$w1" == -* ]]; then
-# -foo  or -foo bar
-arg="$arg$w1,$cur"
-  elif [[ "$w2" == -* && "$w1" == '=' ]]; then
-# -foo=bar
-arg="$arg$w2=,$cur"
-  elif [[ ${cur: -1} != '=' && ${cur/=} != $cur ]]; then
-# -foo=bar
-arg="$arg${cur%=*}=,${cur#*=}"
-  fi
+  # Pass all the current command-line flags to clang, so that clang can handle
+  # these internally.
+  # '=' is separated differently by bash, so we have to concat them without ','
+  for i in `seq 1 $cword`; do
+if [[ $i == $cword || "${COMP_WORDS[$(($i+1))]}" == '=' ]]; then
+  arg="$arg${COMP_WORDS[$i]}"
+else
+  arg="$arg${COMP_WORDS[$i]},"
+fi
+  done
 
   # expand ~ to $HOME
   eval local path=${COMP_WORDS[0]}
@@ -67,7 +48,7 @@
 
   # When clang does not emit any possible autocompletion, or user pushed tab after " ",
   # just autocomplete files.
-  if [[ "$flags" == "$(echo -e '\n')" || "$arg" == "" ]]; then
+  if [[ "$flags" == "$(echo -e '\n')" ]]; then
 # If -foo= and there was no possible values, autocomplete files.
 [[ "$cur" == '=' || "$cur" == -*= ]] && cur=""
 _clang_filedir
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -3,21 +3,16 @@
 // add/modify flags, change HelpTexts or the values of some flags.
 
 // Some corner cases.
-// RUN: %clang --autocomplete= | FileCheck %s -check-prefix=ALL_FLAGS
-// RUN: %clang --autocomplete=# | FileCheck %s -check-prefix=ALL_FLAGS
-// Let's pick some example flags that are hopefully unlikely to change.
-// ALL_FLAGS: -fast
-// ALL_FLAGS: -fastcp
-// ALL_FLAGS: -fastf
 // Just test that this doesn't crash:
+// RUN: %clang --autocomplete=
 // RUN: %clang --autocomplete=,
 // RUN: %clang --autocomplete==
 // RUN: %clang --autocomplete=,,
 // RUN: %clang --autocomplete=-
 
 // RUN: %clang --autocomplete=-fsyn | FileCheck %s -check-prefix=FSYN
 // FSYN: -fsyntax-only
-// RUN: %clang --autocomplete=-std= | FileCheck %s -check-prefix=STD
+// RUN: %clang --autocomplete=-std | FileCheck %s -check-prefix=STD
 // STD: -std= Language standard to compile for
 // RUN: %clang --autocomplete=foo | FileCheck %s -check-prefix=FOO
 // FOO-NOT: foo
@@ -30,14 +25,14 @@
 // STDLIBALL-NEXT: platform
 // RUN: %clang --autocomplete=-meabi,d | FileCheck %s -check-prefix=MEABI
 // MEABI: default
-// RUN: %clang --autocomplete=-meabi, | FileCheck %s -check-prefix=MEABIALL
+// RUN: %clang --autocomplete=-meabi | FileCheck %s -check-prefix=MEABIALL
 // MEABIALL: 4
 // MEABIALL-NEXT: 5
 // MEABIALL-NEXT: default
 // MEABIALL-NEXT: gnu
 // RUN: %clang --autocomplete=-cl-std=,CL2 | FileCheck %s -check-prefix=CLSTD
 // CLSTD: CL2.0
-// RUN: %clang --autocomplete=-cl-std=, | FileCheck %s -check-prefix=CLSTDALL
+// RUN: %clang --autocomplete=-cl-std= | FileCheck %s 

[PATCH] D20124: [PCH] Serialize skipped preprocessor ranges

2017-11-03 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv added a comment.

The patch has aged a bit since upload, so does it still apply? And, can you add 
a testcase please?


Repository:
  rL LLVM

https://reviews.llvm.org/D20124



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


[PATCH] D39587: [clang-format] Handle unary operator overload with arguments and specifiers

2017-11-03 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Looks good, thank you.


https://reviews.llvm.org/D39587



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


[PATCH] D39121: [clang-tidy] Misplaced Operator in Strlen in Alloc

2017-11-03 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In https://reviews.llvm.org/D39121#914875, @Abpostelnicu wrote:

> I can test this on our repo, Mozilla, since it's a large code-base I think we 
> you will have a better understanding of the false-positive ratio.


Thank you in advance!


https://reviews.llvm.org/D39121



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


[PATCH] D39121: [clang-tidy] Misplaced Operator in Strlen in Alloc

2017-11-03 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added a comment.

I can test this on our repo, Mozilla, since it's a large code-base I think we 
you will have a better understanding of the false-positive ratio.


https://reviews.llvm.org/D39121



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


[PATCH] D39441: [refactor][extract] insert semicolons into extracted/inserted code when needed

2017-11-03 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rL LLVM

https://reviews.llvm.org/D39441



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


[PATCH] D39121: [clang-tidy] Misplaced Operator in Strlen in Alloc

2017-11-03 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

I tested it on a C project (Postgres) and found no false positives.


https://reviews.llvm.org/D39121



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


[PATCH] D37299: [Modules] Add ability to specify module name to module file mapping in a file

2017-11-03 Thread Boris Kolpackov via Phabricator via cfe-commits
boris added a comment.

Ping.


https://reviews.llvm.org/D37299



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


[PATCH] D39534: [libunwind] Add ifdefs around ELF specific parts of UnwindRegisters*.S for ARM

2017-11-03 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: src/UnwindRegistersRestore.S:396
   .fpu vfpv3-d16
+#endif
 
DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreVFPWithFLDMDEPy)

mstorsjo wrote:
> compnerd wrote:
> > This really isn't an ELF vs COFF/Mach-O thing.  Does MASM let you do 
> > something similar?  This should at the very least be `!defined(_WIN32)`.  
> > The same throughout.
> MASM is only for x86, and MS armasm uses a wholly different syntax (with 
> afaik nothing similar to `.arch` or `.fpu`).
> 
> And similarly, if you try assembling a file with this directive, it will fail 
> both for iOS and windows:
> 
> ```
> $ cat test.s
> .text
> .fpu vfpv3-d16
> add r0, r0, r0
> $ clang -target armv7-linux-gnueabi test.s -c -o test.o
> $ clang -target armv7-apple-darwin test.s -c -o test.o
> test.s:2:1: error: unknown directive
> .fpu vfpv3-d16
> ^
> $ clang -target thumbv7-win32-gnu test.s -c -o test.o
> test.s:2:1: error: unknown directive
> .fpu vfpv3-d16
> ^
> ```
If you really wanted to, I could make it `!defined(__APPLE__) && 
!defined(_WIN32)`, but I really think `defined(__ELF__)` is more 
straightforward. (The corresponding parts in the asm parser in LLVM is within 
an `if (!IsMachO && !IsCOFF)` block though.)


https://reviews.llvm.org/D39534



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


[PATCH] D39419: Fix crash when parsing objective-c++ containing invalid lambda

2017-11-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Parse/ParseExprCXX.cpp:1020
 
-  PA.Commit();
-  return false;
+  PA2.Revert();
+  return true;

Just to clarify: It seems like this revert (in addition to two TPAs) is the 
main addition. Did we hit the assertion previously with the crash?



Comment at: test/Parser/objcxx11-invalid-lambda.cpp:11
+}   // expected-error{{expected ')'}} expected-error{{expected ';' 
at end of declaration}} expected-error{{expected '}'}}
\ No newline at end of file


Nit: missing newline.


https://reviews.llvm.org/D39419



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